{"repo_name": "FlashSpace", "file_name": "/FlashSpace/FlashSpace/Features/CLI/Commands/GetCommands.swift", "inference_info": {"prefix_code": "//\n// GetCommands.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\n\nfinal class GetCommands: CommandExecutor {\n var workspaceManager: WorkspaceManager { AppDependencies.shared.workspaceManager }\n var profilesRepository: ProfilesRepository { AppDependencies.shared.profilesRepository }\n\n ", "suffix_code": "\n}\n", "middle_code": "func execute(command: CommandRequest) -> CommandResponse? {\n switch command {\n case .getProfile:\n let result = profilesRepository.selectedProfile.name\n return CommandResponse(success: true, message: result)\n case .getWorkspace(let display):\n let workspace = workspaceManager.activeWorkspace[display ?? NSScreen.main?.localizedName ?? \"\"]\n if let workspace {\n let result = workspace.name\n return CommandResponse(success: true, message: result)\n } else {\n return CommandResponse(success: false, error: \"No active workspace\")\n }\n case .getApp(let withWindowsCount):\n if let app = NSWorkspace.shared.frontmostApplication, let appName = app.localizedName {\n if withWindowsCount {\n return CommandResponse(success: true, message: \"\\(appName)\\n\\(app.allWindows.count)\")\n } else {\n return CommandResponse(success: true, message: appName)\n }\n } else {\n return CommandResponse(success: false, error: \"No active app\")\n }\n case .getDisplay:\n if let display = NSScreen.main?.localizedName {\n return CommandResponse(success: true, message: display)\n } else {\n return CommandResponse(success: false, error: \"No display found\")\n }\n default:\n return nil\n }\n }", "code_description": null, "fill_type": "FUNCTION_TYPE", "language_type": "swift", "sub_task_type": null}, "context_code": [["/FlashSpace/FlashSpace/Features/CLI/Commands/ListCommands.swift", "//\n// ListCommands.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\n\nfinal class ListCommands: CommandExecutor {\n var workspaceRepository: WorkspaceRepository { AppDependencies.shared.workspaceRepository }\n var profilesRepository: ProfilesRepository { AppDependencies.shared.profilesRepository }\n var settingsRepository: SettingsRepository { AppDependencies.shared.settingsRepository }\n\n // swiftlint:disable:next function_body_length\n func execute(command: CommandRequest) -> CommandResponse? {\n switch command {\n case .listWorkspaces(let withDisplay, let profileName):\n let profile = profileName != nil\n ? profilesRepository.profiles.first { $0.name == profileName }\n : profilesRepository.selectedProfile\n\n if let profile {\n let result: String\n\n if withDisplay {\n result = profile.workspaces.map {\n let displays = $0.displays.joined(separator: \",\")\n return \"\\($0.name),\\(displays.isEmpty ? \"None\" : displays)\"\n }.joined(separator: \"\\n\")\n } else {\n result = profile.workspaces.map(\\.name).joined(separator: \"\\n\")\n }\n\n return CommandResponse(success: true, message: result)\n } else {\n return CommandResponse(success: false, error: \"Profile not found\")\n }\n\n case .listProfiles:\n let result = profilesRepository.profiles.map(\\.name).joined(separator: \"\\n\")\n return CommandResponse(success: true, message: result)\n\n case .listApps(let workspace, let profileName, let withBundleId, let withIcon, let onlyRunning):\n let profile = profileName != nil\n ? profilesRepository.profiles.first { $0.name == profileName }\n : profilesRepository.selectedProfile\n\n guard let profile else {\n return CommandResponse(success: false, error: \"Profile not found\")\n }\n\n guard let workspace = profile.workspaces.first(where: { $0.name == workspace }) else {\n return CommandResponse(success: false, error: \"Workspace not found\")\n }\n\n let runningApps = NSWorkspace.shared.runningApplications.map(\\.bundleIdentifier).asSet\n\n let result = workspace.apps\n .filter { !onlyRunning || runningApps.contains($0.bundleIdentifier) }\n .map { app in\n [\n app.name,\n withBundleId ? app.bundleIdentifier : nil,\n withIcon ? app.iconPath ?? \"\" : nil\n ].compactMap { $0 }.joined(separator: \",\")\n }\n .joined(separator: \"\\n\")\n\n return CommandResponse(success: true, message: result)\n\n case .listFloatingApps(let withBundleId):\n let floatingApps = settingsRepository.floatingAppsSettings.floatingApps\n .map { app in\n [\n app.name,\n withBundleId ? app.bundleIdentifier : nil\n ].compactMap { $0 }.joined(separator: \",\")\n }\n .joined(separator: \"\\n\")\n\n return CommandResponse(success: true, message: floatingApps)\n\n default:\n return nil\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Commands/WorkspaceCommands.swift", "//\n// WorkspaceCommands.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\n\nfinal class WorkspaceCommands: CommandExecutor {\n var workspaceManager: WorkspaceManager { AppDependencies.shared.workspaceManager }\n var workspaceRepository: WorkspaceRepository { AppDependencies.shared.workspaceRepository }\n\n // swiftlint:disable:next cyclomatic_complexity function_body_length\n func execute(command: CommandRequest) -> CommandResponse? {\n switch command {\n case .activateWorkspace(.some(let name), _, let clean):\n let workspace = workspaceRepository.workspaces.first { $0.name == name }\n if let workspace {\n if workspace.isDynamic, workspace.displays.isEmpty {\n return CommandResponse(success: false, error: \"\\(workspace.name) - No Running Apps To Show\")\n }\n workspaceManager.activateWorkspace(workspace, setFocus: true)\n if clean { workspaceManager.hideUnassignedApps() }\n return CommandResponse(success: true)\n } else {\n return CommandResponse(success: false, error: \"Workspace not found\")\n }\n\n case .activateWorkspace(_, .some(let number), let clean):\n let workspace = workspaceRepository.workspaces[safe: number - 1]\n if let workspace {\n if workspace.isDynamic, workspace.displays.isEmpty {\n return CommandResponse(success: false, error: \"\\(workspace.name) - No Running Apps To Show\")\n }\n workspaceManager.activateWorkspace(workspace, setFocus: true)\n if clean { workspaceManager.hideUnassignedApps() }\n return CommandResponse(success: true)\n } else {\n return CommandResponse(success: false, error: \"Workspace not found\")\n }\n\n case .updateWorkspace(let request):\n return updateWorkspace(request)\n\n case .nextWorkspace(let skipEmpty, let clean, let loop):\n workspaceManager.activateWorkspace(next: true, skipEmpty: skipEmpty, loop: loop)\n if clean { workspaceManager.hideUnassignedApps() }\n return CommandResponse(success: true)\n\n case .previousWorkspace(let skipEmpty, let clean, let loop):\n workspaceManager.activateWorkspace(next: false, skipEmpty: skipEmpty, loop: loop)\n if clean { workspaceManager.hideUnassignedApps() }\n return CommandResponse(success: true)\n\n case .recentWorkspace(let clean):\n workspaceManager.activateRecentWorkspace()\n if clean { workspaceManager.hideUnassignedApps() }\n return CommandResponse(success: true)\n\n case .createWorkspace(let request):\n let workspace = request.toWorkspace\n workspaceRepository.addWorkspace(workspace)\n if request.activate {\n workspaceManager.activateWorkspace(workspace, setFocus: true)\n }\n NotificationCenter.default.post(name: .appsListChanged, object: nil)\n return CommandResponse(success: true)\n\n case .deleteWorkspace(let name):\n let workspace = workspaceRepository.workspaces.first { $0.name == name }\n if let workspace {\n workspaceRepository.deleteWorkspace(id: workspace.id)\n NotificationCenter.default.post(name: .appsListChanged, object: nil)\n return CommandResponse(success: true)\n } else {\n return CommandResponse(success: false, error: \"Workspace not found\")\n }\n\n default:\n return nil\n }\n }\n\n private func updateWorkspace(_ request: UpdateWorkspaceRequest) -> CommandResponse {\n var workspace: Workspace?\n if let workspaceName = request.name {\n workspace = workspaceRepository.workspaces.first { $0.name == workspaceName }\n } else if let workspaceId = workspaceManager.activeWorkspaceDetails?.id {\n workspace = workspaceRepository.workspaces.first { $0.id == workspaceId }\n } else {\n return CommandResponse(success: false, error: \"Workspace not found\")\n }\n\n guard var workspace else {\n return CommandResponse(success: false, error: \"Workspace not found\")\n }\n\n if let display = request.display {\n switch display {\n case .active:\n if let display = NSWorkspace.shared.frontmostApplication?.display {\n workspace.display = display\n } else {\n return CommandResponse(success: false, error: \"No active display found\")\n }\n case .name(let name):\n workspace.display = name\n }\n }\n\n workspaceRepository.updateWorkspace(workspace)\n NotificationCenter.default.post(name: .appsListChanged, object: nil)\n\n return CommandResponse(success: true)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Commands/AppCommands.swift", "//\n// AppCommands.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\n\nfinal class AppCommands: CommandExecutor {\n var workspaceManager: WorkspaceManager { AppDependencies.shared.workspaceManager }\n var workspaceRepository: WorkspaceRepository { AppDependencies.shared.workspaceRepository }\n var settings: WorkspaceSettings { AppDependencies.shared.workspaceSettings }\n var floatingAppsSettings: FloatingAppsSettings { AppDependencies.shared.floatingAppsSettings }\n\n func execute(command: CommandRequest) -> CommandResponse? {\n switch command {\n case .assignVisibleApps(let workspaceName, let showNotification):\n return assignVisibleApps(workspaceName: workspaceName, showNotification: showNotification)\n\n case .assignApp(let app, let workspaceName, let activate, let showNotification):\n return assignApp(\n app: app,\n workspaceName: workspaceName,\n activate: activate,\n showNotification: showNotification\n )\n\n case .unassignApp(let app, let showNotification):\n return unassignApp(app: app, showNotification: showNotification)\n\n case .hideUnassignedApps:\n workspaceManager.hideUnassignedApps()\n return CommandResponse(success: true)\n\n case .floatApp(let app, let showNotification):\n return floatApp(app: app, showNotification: showNotification)\n\n case .unfloatApp(let app, let showNotification):\n return unfloatApp(app: app, showNotification: showNotification)\n\n case .toggleFloatApp(let app, let showNotification):\n return toggleFloatApp(app: app, showNotification: showNotification)\n\n default:\n return nil\n }\n }\n\n private func findApp(app: String?) -> MacApp? {\n guard let app else { return NSWorkspace.shared.frontmostApplication?.toMacApp }\n\n let foundApp = NSWorkspace.shared.runningApplications\n .first { $0.localizedName == app }?\n .toMacApp\n\n if foundApp == nil, let appUrl = NSWorkspace.shared.urlForApplication(withBundleIdentifier: app) {\n return MacApp(\n name: appUrl.bundle?.localizedAppName ?? \"\",\n bundleIdentifier: app,\n iconPath: appUrl.iconPath\n )\n }\n\n return foundApp\n }\n\n private func unassignApp(app: String?, showNotification: Bool) -> CommandResponse {\n guard let app = findApp(app: app) else {\n return CommandResponse(\n success: false,\n error: \"App not found or not running. For not running apps use `unassign-app --name `.\"\n )\n }\n\n workspaceRepository.deleteAppFromAllWorkspaces(app: app)\n NSWorkspace.shared.runningApplications.find(app)?.hide()\n NotificationCenter.default.post(name: .appsListChanged, object: nil)\n\n if showNotification {\n Toast.showWith(\n icon: \"square.stack.3d.up.slash\",\n message: \"\\(app.name) - Removed From Workspaces\",\n textColor: .negative\n )\n }\n\n return CommandResponse(success: true)\n }\n\n private func assignVisibleApps(workspaceName: String?, showNotification: Bool) -> CommandResponse {\n guard let workspaceName = workspaceName ?? workspaceManager.activeWorkspaceDetails?.name else {\n return CommandResponse(success: false, error: \"No workspace selected\")\n }\n\n guard let workspace = workspaceRepository.workspaces.first(where: { $0.name == workspaceName }) else {\n return CommandResponse(success: false, error: \"Workspace not found\")\n }\n\n let visibleApps = NSWorkspace.shared.runningApplications\n .regularVisibleApps(onDisplays: workspace.displays, excluding: floatingAppsSettings.floatingApps)\n\n guard !visibleApps.isEmpty else {\n return CommandResponse(\n success: false,\n error: \"No visible apps found on the current display\"\n )\n }\n\n workspaceManager.assignApps(visibleApps.map(\\.toMacApp), to: workspace)\n\n if showNotification {\n Toast.showWith(\n icon: \"square.stack.3d.up\",\n message: \"Assigned \\(visibleApps.count) Apps(s) To \\(workspace.name)\",\n textColor: .positive\n )\n }\n\n return CommandResponse(success: true)\n }\n\n private func assignApp(\n app: String?,\n workspaceName: String?,\n activate: Bool?,\n showNotification: Bool\n ) -> CommandResponse {\n guard let workspaceName = workspaceName ?? workspaceManager.activeWorkspaceDetails?.name else {\n return CommandResponse(success: false, error: \"No workspace selected\")\n }\n\n guard let workspace = workspaceRepository.workspaces.first(where: { $0.name == workspaceName }) else {\n return CommandResponse(success: false, error: \"Workspace not found\")\n }\n\n guard let app = findApp(app: app) else {\n return CommandResponse(\n success: false,\n error: \"App not found or not running. For not running apps use `assign-app --name `.\"\n )\n }\n\n let previousSetting = settings.changeWorkspaceOnAppAssign\n if let activate {\n settings.changeWorkspaceOnAppAssign = activate\n }\n workspaceManager.assignApp(app, to: workspace)\n if activate != nil {\n settings.changeWorkspaceOnAppAssign = previousSetting\n }\n\n if showNotification {\n Toast.showWith(\n icon: \"square.stack.3d.up\",\n message: \"\\(app.name) - Assigned To \\(workspace.name)\",\n textColor: .positive\n )\n }\n\n return CommandResponse(success: true)\n }\n\n private func floatApp(app: String?, showNotification: Bool) -> CommandResponse {\n guard let app = findApp(app: app) else {\n return CommandResponse(\n success: false,\n error: \"App not found or not running. For not running apps use `float-app --name `.\"\n )\n }\n\n floatingAppsSettings.addFloatingAppIfNeeded(app: app)\n\n if showNotification {\n Toast.showWith(\n icon: \"macwindow.on.rectangle\",\n message: \"\\(app.name) - Added To Floating Apps\",\n textColor: .positive\n )\n }\n\n return CommandResponse(success: true)\n }\n\n private func unfloatApp(app: String?, showNotification: Bool) -> CommandResponse {\n guard let app = findApp(app: app) else {\n return CommandResponse(\n success: false,\n error: \"App not found or not running. For not running apps use `unfloat-app --name `.\"\n )\n }\n\n guard floatingAppsSettings.floatingApps.containsApp(with: app.bundleIdentifier) else {\n return CommandResponse(success: true)\n }\n\n floatingAppsSettings.deleteFloatingApp(app: app)\n\n if let runningApp = NSWorkspace.shared.runningApplications.find(app),\n let screen = runningApp.display,\n workspaceManager.activeWorkspace[screen]?.apps.containsApp(runningApp) != true {\n runningApp.hide()\n }\n\n if showNotification {\n Toast.showWith(\n icon: \"macwindow\",\n message: \"\\(app.name) - Removed From Floating Apps\",\n textColor: .negative\n )\n }\n\n return CommandResponse(success: true)\n }\n\n private func toggleFloatApp(app: String?, showNotification: Bool) -> CommandResponse {\n guard let macApp = findApp(app: app) else {\n return CommandResponse(\n success: false,\n error: \"App not found or not running. For not running apps use `toggle-float-app --name `.\"\n )\n }\n\n let isFloating = floatingAppsSettings.floatingApps.containsApp(with: macApp.bundleIdentifier)\n\n return isFloating\n ? unfloatApp(app: app, showNotification: showNotification)\n : floatApp(app: app, showNotification: showNotification)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Commands/ProfileCommands.swift", "//\n// ProfileCommands.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\n\nfinal class ProfileCommands: CommandExecutor {\n var profilesRepository: ProfilesRepository { AppDependencies.shared.profilesRepository }\n\n func execute(command: CommandRequest) -> CommandResponse? {\n switch command {\n case .activateProfile(let name):\n let profile = profilesRepository.profiles.first { $0.name == name }\n\n if let profile {\n profilesRepository.selectedProfile = profile\n return CommandResponse(success: true)\n } else {\n return CommandResponse(success: false, error: \"Profile not found\")\n }\n\n case .createProfile(let name, let copy, let activate):\n profilesRepository.createProfile(name: name, keepWorkspaces: copy)\n if activate {\n profilesRepository.profiles\n .first { $0.name == name }\n .flatMap { profilesRepository.selectedProfile = $0 }\n }\n return CommandResponse(success: true)\n\n case .deleteProfile(let name):\n let profile = profilesRepository.profiles.first { $0.name == name }\n if let profile {\n profilesRepository.deleteProfile(id: profile.id)\n return CommandResponse(success: true)\n } else {\n return CommandResponse(success: false, error: \"Profile not found\")\n }\n\n default:\n return nil\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Commands/SpaceControlCommands.swift", "//\n// SpaceControlCommands.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\n\nfinal class SpaceControlCommands: CommandExecutor {\n func execute(command: CommandRequest) -> CommandResponse? {\n switch command {\n case .openSpaceControl:\n if SpaceControl.isEnabled {\n SpaceControl.show()\n return CommandResponse(success: true)\n } else {\n return CommandResponse(success: false, error: \"Space Control is not enabled\")\n }\n\n default:\n return nil\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Commands/FocusCommands.swift", "//\n// FocusCommands.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nfinal class FocusCommands: CommandExecutor {\n var focusManager: FocusManager { AppDependencies.shared.focusManager }\n\n func execute(command: CommandRequest) -> CommandResponse? {\n switch command {\n case .focusWindow(let direction):\n switch direction {\n case .left: focusManager.focusLeft()\n case .right: focusManager.focusRight()\n case .up: focusManager.focusUp()\n case .down: focusManager.focusDown()\n }\n return CommandResponse(success: true)\n\n case .focusNextApp:\n focusManager.nextWorkspaceApp()\n return CommandResponse(success: true)\n\n case .focusPreviousApp:\n focusManager.previousWorkspaceApp()\n return CommandResponse(success: true)\n\n case .focusNextWindow:\n focusManager.nextWorkspaceWindow()\n return CommandResponse(success: true)\n\n case .focusPreviousWindow:\n focusManager.previousWorkspaceWindow()\n return CommandResponse(success: true)\n\n default:\n return nil\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Workspaces/WorkspaceHotKeys.swift", "//\n// WorkspaceHotKeys.swift\n//\n// Created by Wojciech Kulik on 08/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nfinal class WorkspaceHotKeys {\n private let workspaceManager: WorkspaceManager\n private let workspaceRepository: WorkspaceRepository\n private let workspaceSettings: WorkspaceSettings\n private let floatingAppsSettings: FloatingAppsSettings\n\n init(\n workspaceManager: WorkspaceManager,\n workspaceRepository: WorkspaceRepository,\n settingsRepository: SettingsRepository\n ) {\n self.workspaceManager = workspaceManager\n self.workspaceRepository = workspaceRepository\n self.workspaceSettings = settingsRepository.workspaceSettings\n self.floatingAppsSettings = settingsRepository.floatingAppsSettings\n }\n\n func getHotKeys() -> [(AppHotKey, () -> ())] {\n let hotKeys = [\n getAssignVisibleAppsHotKey(),\n getAssignAppHotKey(for: nil),\n getUnassignAppHotKey(),\n getToggleAssignmentHotKey(),\n getHideUnassignedAppsHotKey(),\n getRecentWorkspaceHotKey(),\n getCycleWorkspacesHotKey(next: false),\n getCycleWorkspacesHotKey(next: true)\n ] +\n workspaceRepository.workspaces\n .flatMap { [getActivateHotKey(for: $0), getAssignAppHotKey(for: $0)] }\n\n return hotKeys.compactMap(\\.self)\n }\n\n private func getActivateHotKey(for workspace: Workspace) -> (AppHotKey, () -> ())? {\n guard let shortcut = workspace.activateShortcut else { return nil }\n\n let action = { [weak self] in\n guard let self, let updatedWorkspace = workspaceRepository.workspaces\n .first(where: { $0.id == workspace.id }) else { return }\n\n if updatedWorkspace.isDynamic, updatedWorkspace.displays.isEmpty {\n Toast.showWith(\n icon: \"square.stack.3d.up\",\n message: \"\\(workspace.name) - No Running Apps To Show\",\n textColor: .gray\n )\n return\n }\n\n workspaceManager.activateWorkspace(updatedWorkspace, setFocus: true)\n }\n\n return (shortcut, action)\n }\n\n private func getAssignVisibleAppsHotKey() -> (AppHotKey, () -> ())? {\n guard let shortcut = workspaceSettings.assignVisibleApps else { return nil }\n\n return (shortcut, { [weak self] in self?.assignVisibleApps() })\n }\n\n private func getAssignAppHotKey(for workspace: Workspace?) -> (AppHotKey, () -> ())? {\n let shortcut = workspace == nil\n ? workspaceSettings.assignFocusedApp\n : workspace?.assignAppShortcut\n\n guard let shortcut else { return nil }\n\n return (shortcut, { [weak self] in self?.assignApp(to: workspace) })\n }\n\n private func getUnassignAppHotKey() -> (AppHotKey, () -> ())? {\n guard let shortcut = workspaceSettings.unassignFocusedApp else { return nil }\n\n return (shortcut, { [weak self] in self?.unassignApp() })\n }\n\n private func getToggleAssignmentHotKey() -> (AppHotKey, () -> ())? {\n guard let shortcut = workspaceSettings.toggleFocusedAppAssignment else { return nil }\n\n let action = { [weak self] in\n guard let self, let activeApp = NSWorkspace.shared.frontmostApplication else { return }\n\n if workspaceRepository.workspaces.flatMap(\\.apps).containsApp(activeApp) {\n unassignApp()\n } else {\n assignApp(to: nil)\n }\n }\n\n return (shortcut, action)\n }\n\n private func getHideUnassignedAppsHotKey() -> (AppHotKey, () -> ())? {\n guard let shortcut = workspaceSettings.hideUnassignedApps else { return nil }\n\n let action = { [weak self] in\n guard let self else { return }\n\n workspaceManager.hideUnassignedApps()\n }\n\n return (shortcut, action)\n }\n\n private func getCycleWorkspacesHotKey(next: Bool) -> (AppHotKey, () -> ())? {\n guard let shortcut = next\n ? workspaceSettings.switchToNextWorkspace\n : workspaceSettings.switchToPreviousWorkspace\n else { return nil }\n\n let action: () -> () = { [weak self] in\n guard let self else { return }\n\n workspaceManager.activateWorkspace(\n next: next,\n skipEmpty: workspaceSettings.skipEmptyWorkspacesOnSwitch,\n loop: workspaceSettings.loopWorkspaces\n )\n }\n\n return (shortcut, action)\n }\n\n private func getRecentWorkspaceHotKey() -> (AppHotKey, () -> ())? {\n guard let shortcut = workspaceSettings.switchToRecentWorkspace else { return nil }\n\n let action: () -> () = { [weak self] in\n self?.workspaceManager.activateRecentWorkspace()\n }\n\n return (shortcut, action)\n }\n}\n\nextension WorkspaceHotKeys {\n private func assignApp(to workspace: Workspace?) {\n guard let activeApp = NSWorkspace.shared.frontmostApplication else { return }\n guard let appName = activeApp.localizedName else { return }\n guard activeApp.activationPolicy == .regular else {\n Alert.showOkAlert(\n title: appName,\n message: \"This application is an agent (runs in background) and cannot be managed by FlashSpace.\"\n )\n return\n }\n\n guard let workspace = workspace ?? workspaceManager.activeWorkspace[activeApp.display ?? \"\"] else {\n Alert.showOkAlert(\n title: \"Error\",\n message: \"No workspace is active on the current display.\"\n )\n return\n }\n\n guard let updatedWorkspace = workspaceRepository.workspaces\n .first(where: { $0.id == workspace.id }) else { return }\n\n workspaceManager.assignApp(activeApp.toMacApp, to: updatedWorkspace)\n\n if !workspace.isDynamic {\n activeApp.centerApp(display: workspace.display)\n }\n\n Toast.showWith(\n icon: \"square.stack.3d.up\",\n message: \"\\(appName) - Assigned To \\(workspace.name)\",\n textColor: .positive\n )\n }\n\n private func assignVisibleApps() {\n guard let display = NSScreen.main?.localizedName else { return }\n guard let workspace = workspaceManager.activeWorkspace[display] else {\n Alert.showOkAlert(\n title: \"Error\",\n message: \"No workspace is active on the current display.\"\n )\n return\n }\n\n let visibleApps = NSWorkspace.shared.runningApplications\n .regularVisibleApps(onDisplays: workspace.displays, excluding: floatingAppsSettings.floatingApps)\n\n workspaceManager.assignApps(visibleApps.map(\\.toMacApp), to: workspace)\n\n Toast.showWith(\n icon: \"square.stack.3d.up\",\n message: \"Assigned \\(visibleApps.count) App(s) To \\(workspace.name)\",\n textColor: .positive\n )\n }\n\n private func unassignApp() {\n guard let activeApp = NSWorkspace.shared.frontmostApplication else { return }\n guard let appName = activeApp.localizedName else { return }\n\n if workspaceRepository.workspaces.flatMap(\\.apps).containsApp(activeApp) == true {\n Toast.showWith(\n icon: \"square.stack.3d.up.slash\",\n message: \"\\(appName) - Removed From Workspaces\",\n textColor: .negative\n )\n }\n\n workspaceRepository.deleteAppFromAllWorkspaces(app: activeApp.toMacApp)\n activeApp.hide()\n NotificationCenter.default.post(name: .appsListChanged, object: nil)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Workspaces/WorkspaceManager.swift", "//\n// WorkspaceManager.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Combine\n\ntypealias DisplayName = String\n\nstruct ActiveWorkspace {\n let id: WorkspaceID\n let name: String\n let number: String?\n let symbolIconName: String?\n let display: DisplayName\n}\n\nfinal class WorkspaceManager: ObservableObject {\n @Published private(set) var activeWorkspaceDetails: ActiveWorkspace?\n\n private(set) var lastFocusedApp: [WorkspaceID: MacApp] = [:]\n private(set) var activeWorkspace: [DisplayName: Workspace] = [:]\n private(set) var mostRecentWorkspace: [DisplayName: Workspace] = [:]\n private(set) var lastWorkspaceActivation = Date.distantPast\n\n private var cancellables = Set()\n private var observeFocusCancellable: AnyCancellable?\n private var appsHiddenManually: [WorkspaceID: [MacApp]] = [:]\n private let hideAgainSubject = PassthroughSubject()\n\n private let workspaceRepository: WorkspaceRepository\n private let workspaceSettings: WorkspaceSettings\n private let floatingAppsSettings: FloatingAppsSettings\n private let pictureInPictureManager: PictureInPictureManager\n private let workspaceTransitionManager: WorkspaceTransitionManager\n private let displayManager: DisplayManager\n\n init(\n workspaceRepository: WorkspaceRepository,\n settingsRepository: SettingsRepository,\n pictureInPictureManager: PictureInPictureManager,\n workspaceTransitionManager: WorkspaceTransitionManager,\n displayManager: DisplayManager\n ) {\n self.workspaceRepository = workspaceRepository\n self.workspaceSettings = settingsRepository.workspaceSettings\n self.floatingAppsSettings = settingsRepository.floatingAppsSettings\n self.pictureInPictureManager = pictureInPictureManager\n self.workspaceTransitionManager = workspaceTransitionManager\n self.displayManager = displayManager\n\n PermissionsManager.shared.askForAccessibilityPermissions()\n observe()\n }\n\n private func observe() {\n hideAgainSubject\n .debounce(for: 0.2, scheduler: RunLoop.main)\n .sink { [weak self] in self?.hideApps(in: $0) }\n .store(in: &cancellables)\n\n NotificationCenter.default\n .publisher(for: .profileChanged)\n .sink { [weak self] _ in\n self?.lastFocusedApp = [:]\n self?.activeWorkspace = [:]\n self?.mostRecentWorkspace = [:]\n self?.activeWorkspaceDetails = nil\n }\n .store(in: &cancellables)\n\n NotificationCenter.default\n .publisher(for: NSApplication.didChangeScreenParametersNotification)\n .sink { [weak self] _ in\n self?.activeWorkspace = [:]\n self?.mostRecentWorkspace = [:]\n self?.activeWorkspaceDetails = nil\n }\n .store(in: &cancellables)\n\n observeFocus()\n }\n\n private func observeFocus() {\n observeFocusCancellable = NSWorkspace.shared.notificationCenter\n .publisher(for: NSWorkspace.didActivateApplicationNotification)\n .compactMap { $0.userInfo?[NSWorkspace.applicationUserInfoKey] as? NSRunningApplication }\n .sink { [weak self] application in\n self?.rememberLastFocusedApp(application, retry: true)\n }\n }\n\n private func rememberLastFocusedApp(_ application: NSRunningApplication, retry: Bool) {\n guard application.display != nil else {\n if retry {\n Logger.log(\"Retrying to get display for \\(application.localizedName ?? \"\")\")\n return DispatchQueue.main.asyncAfter(deadline: .now() + 0.6) {\n if let frontmostApp = NSWorkspace.shared.frontmostApplication {\n self.rememberLastFocusedApp(frontmostApp, retry: false)\n }\n }\n } else {\n return Logger.log(\"Unable to get display for \\(application.localizedName ?? \"\")\")\n }\n }\n\n let focusedDisplay = NSScreen.main?.localizedName ?? \"\"\n\n if let activeWorkspace = activeWorkspace[focusedDisplay], activeWorkspace.apps.containsApp(application) {\n lastFocusedApp[activeWorkspace.id] = application.toMacApp\n updateActiveWorkspace(activeWorkspace, on: [focusedDisplay])\n }\n\n displayManager.trackDisplayFocus(on: focusedDisplay, for: application)\n }\n\n private func showApps(in workspace: Workspace, setFocus: Bool, on displays: Set) {\n let regularApps = NSWorkspace.shared.runningApplications\n .filter { $0.activationPolicy == .regular }\n let floatingApps = floatingAppsSettings.floatingApps\n let hiddenApps = appsHiddenManually[workspace.id] ?? []\n var appsToShow = regularApps\n .filter { !hiddenApps.containsApp($0) }\n .filter {\n workspace.apps.containsApp($0) ||\n floatingApps.containsApp($0) && $0.isOnAnyDisplay(displays)\n }\n\n observeFocusCancellable = nil\n defer { observeFocus() }\n\n if setFocus {\n let toFocus = findAppToFocus(in: workspace, apps: appsToShow)\n\n // Make sure to raise the app that should be focused\n // as the last one\n if let toFocus {\n appsToShow.removeAll { $0 == toFocus }\n appsToShow.append(toFocus)\n }\n\n for app in appsToShow {\n Logger.log(\"SHOW: \\(app.localizedName ?? \"\")\")\n\n if app == toFocus || app.isHidden || app.isMinimized {\n app.raise()\n }\n\n pictureInPictureManager.showPipAppIfNeeded(app: app)\n }\n\n Logger.log(\"FOCUS: \\(toFocus?.localizedName ?? \"\")\")\n toFocus?.activate()\n centerCursorIfNeeded(in: toFocus?.frame)\n } else {\n for app in appsToShow {\n Logger.log(\"SHOW: \\(app.localizedName ?? \"\")\")\n app.raise()\n }\n }\n }\n\n private func hideApps(in workspace: Workspace) {\n let regularApps = NSWorkspace.shared.runningApplications\n .filter { $0.activationPolicy == .regular }\n let workspaceApps = workspace.apps + floatingAppsSettings.floatingApps\n let isAnyWorkspaceAppRunning = regularApps\n .contains { workspaceApps.containsApp($0) }\n let allAssignedApps = workspaceRepository.workspaces\n .flatMap(\\.apps)\n .map(\\.bundleIdentifier)\n .asSet\n let displays = workspace.displays\n\n let appsToHide = regularApps\n .filter {\n !$0.isHidden && !workspaceApps.containsApp($0) &&\n (!workspaceSettings.keepUnassignedAppsOnSwitch || allAssignedApps.contains($0.bundleIdentifier ?? \"\"))\n }\n .filter { isAnyWorkspaceAppRunning || $0.bundleURL?.fileName != \"Finder\" }\n .filter { $0.isOnAnyDisplay(displays) }\n\n for app in appsToHide {\n Logger.log(\"HIDE: \\(app.localizedName ?? \"\")\")\n\n if !pictureInPictureManager.hidePipAppIfNeeded(app: app) {\n app.hide()\n }\n }\n }\n\n private func findAppToFocus(\n in workspace: Workspace,\n apps: [NSRunningApplication]\n ) -> NSRunningApplication? {\n if workspace.appToFocus == nil {\n let displays = workspace.displays\n if let floatingEntry = displayManager.lastFocusedDisplay(where: {\n let isFloating = floatingAppsSettings.floatingApps.contains($0.app)\n let isUnassigned = workspaceSettings.keepUnassignedAppsOnSwitch &&\n !workspaceRepository.workspaces.flatMap(\\.apps).contains($0.app)\n return (isFloating || isUnassigned) && displays.contains($0.display)\n }),\n let runningApp = NSWorkspace.shared.runningApplications.find(floatingEntry.app) {\n return runningApp\n }\n }\n\n var appToFocus: NSRunningApplication?\n\n if workspace.appToFocus == nil {\n appToFocus = apps.find(lastFocusedApp[workspace.id])\n } else {\n appToFocus = apps.find(workspace.appToFocus)\n }\n\n let fallbackToLastApp = apps.findFirstMatch(with: workspace.apps.reversed())\n let fallbackToFinder = NSWorkspace.shared.runningApplications.first(where: \\.isFinder)\n\n return appToFocus ?? fallbackToLastApp ?? fallbackToFinder\n }\n\n private func centerCursorIfNeeded(in frame: CGRect?) {\n guard workspaceSettings.centerCursorOnWorkspaceChange, let frame else { return }\n\n CGWarpMouseCursorPosition(CGPoint(x: frame.midX, y: frame.midY))\n }\n\n private func updateActiveWorkspace(_ workspace: Workspace, on displays: Set) {\n lastWorkspaceActivation = Date()\n\n // Save the most recent workspace if it's not the current one\n for display in displays {\n if activeWorkspace[display]?.id != workspace.id {\n mostRecentWorkspace[display] = activeWorkspace[display]\n }\n activeWorkspace[display] = workspace\n }\n\n activeWorkspaceDetails = .init(\n id: workspace.id,\n name: workspace.name,\n number: workspaceRepository.workspaces\n .firstIndex { $0.id == workspace.id }\n .map { \"\\($0 + 1)\" },\n symbolIconName: workspace.symbolIconName,\n display: workspace.displayForPrint\n )\n\n Integrations.runOnActivateIfNeeded(workspace: activeWorkspaceDetails!)\n }\n\n private func rememberHiddenApps(workspaceToActivate: Workspace) {\n guard !workspaceSettings.restoreHiddenAppsOnSwitch else {\n appsHiddenManually = [:]\n return\n }\n\n let hiddenApps = NSWorkspace.shared.runningApplications\n .filter { $0.activationPolicy == .regular }\n .filter { $0.isHidden || $0.isMinimized }\n\n for activeWorkspace in activeWorkspace.values {\n guard activeWorkspace.id != workspaceToActivate.id else { continue }\n\n appsHiddenManually[activeWorkspace.id] = []\n }\n\n for (display, activeWorkspace) in activeWorkspace {\n guard activeWorkspace.id != workspaceToActivate.id else { continue }\n\n let activeWorkspaceOtherDisplays = activeWorkspace.displays.subtracting([display])\n appsHiddenManually[activeWorkspace.id, default: []] += hiddenApps\n .filter {\n activeWorkspace.apps.containsApp($0) &&\n $0.isOnAnyDisplay([display]) && !$0.isOnAnyDisplay(activeWorkspaceOtherDisplays)\n }\n .map(\\.toMacApp)\n }\n }\n}\n\n// MARK: - Workspace Actions\nextension WorkspaceManager {\n func activateWorkspace(_ workspace: Workspace, setFocus: Bool) {\n let displays = workspace.displays\n\n Logger.log(\"\")\n Logger.log(\"\")\n Logger.log(\"WORKSPACE: \\(workspace.name)\")\n Logger.log(\"DISPLAYS: \\(displays.joined(separator: \", \"))\")\n Logger.log(\"----\")\n SpaceControl.hide()\n\n guard displays.isNotEmpty else {\n Logger.log(\"No displays found for workspace: \\(workspace.name) - skipping\")\n return\n }\n\n workspaceTransitionManager.showTransitionIfNeeded(for: workspace, on: displays)\n\n rememberHiddenApps(workspaceToActivate: workspace)\n updateActiveWorkspace(workspace, on: displays)\n showApps(in: workspace, setFocus: setFocus, on: displays)\n hideApps(in: workspace)\n\n // Some apps may not hide properly,\n // so we hide apps in the workspace after a short delay\n hideAgainSubject.send(workspace)\n\n NotificationCenter.default.post(name: .workspaceChanged, object: workspace)\n }\n\n func assignApps(_ apps: [MacApp], to workspace: Workspace) {\n for app in apps {\n workspaceRepository.deleteAppFromAllWorkspaces(app: app)\n workspaceRepository.addApp(to: workspace.id, app: app)\n }\n\n NotificationCenter.default.post(name: .appsListChanged, object: nil)\n }\n\n func assignApp(_ app: MacApp, to workspace: Workspace) {\n workspaceRepository.deleteAppFromAllWorkspaces(app: app)\n workspaceRepository.addApp(to: workspace.id, app: app)\n\n guard let targetWorkspace = workspaceRepository.workspaces\n .first(where: { $0.id == workspace.id }) else { return }\n\n let isTargetWorkspaceActive = activeWorkspace.values\n .contains(where: { $0.id == workspace.id })\n\n updateLastFocusedApp(app, in: targetWorkspace)\n\n if workspaceSettings.changeWorkspaceOnAppAssign {\n activateWorkspace(targetWorkspace, setFocus: true)\n } else if !isTargetWorkspaceActive {\n NSWorkspace.shared.runningApplications\n .find(app)?\n .hide()\n AppDependencies.shared.focusManager.nextWorkspaceApp()\n }\n\n NotificationCenter.default.post(name: .appsListChanged, object: nil)\n }\n\n func hideUnassignedApps() {\n let activeWorkspace = workspaceRepository.workspaces\n .first(where: { $0.id == activeWorkspaceDetails?.id })\n\n guard let activeWorkspace else { return }\n\n let appsToHide = NSWorkspace.shared.runningApplications\n .regularVisibleApps(onDisplays: activeWorkspace.displays, excluding: activeWorkspace.apps)\n\n for app in appsToHide {\n Logger.log(\"CLEAN UP: \\(app.localizedName ?? \"\")\")\n\n if !pictureInPictureManager.hidePipAppIfNeeded(app: app) {\n app.hide()\n }\n }\n }\n\n func activateWorkspace(next: Bool, skipEmpty: Bool, loop: Bool) {\n guard let screen = displayManager.getCursorScreen() else { return }\n\n var screenWorkspaces = workspaceRepository.workspaces\n .filter { $0.displays.contains(screen) }\n\n if !next {\n screenWorkspaces = screenWorkspaces.reversed()\n }\n\n guard let activeWorkspace = activeWorkspace[screen] ?? screenWorkspaces.first else { return }\n\n let nextWorkspaces = screenWorkspaces\n .drop(while: { $0.id != activeWorkspace.id })\n .dropFirst()\n\n var selectedWorkspace = nextWorkspaces.first ?? (loop ? screenWorkspaces.first : nil)\n\n if skipEmpty {\n let runningApps = NSWorkspace.shared.runningApplications\n .filter { $0.activationPolicy == .regular }\n .compactMap(\\.bundleIdentifier)\n .asSet\n\n selectedWorkspace = (nextWorkspaces + (loop ? screenWorkspaces : []))\n .drop(while: { $0.apps.allSatisfy { !runningApps.contains($0.bundleIdentifier) } })\n .first\n }\n\n guard let selectedWorkspace, selectedWorkspace.id != activeWorkspace.id else { return }\n\n activateWorkspace(selectedWorkspace, setFocus: true)\n }\n\n func activateRecentWorkspace() {\n guard let screen = displayManager.getCursorScreen(),\n let mostRecentWorkspace = mostRecentWorkspace[screen]\n else { return }\n\n activateWorkspace(mostRecentWorkspace, setFocus: true)\n }\n\n func activateWorkspaceIfActive(_ workspaceId: WorkspaceID) {\n guard activeWorkspace.values.contains(where: { $0.id == workspaceId }) else { return }\n guard let updatedWorkspace = workspaceRepository.workspaces.first(where: { $0.id == workspaceId }) else { return }\n\n activateWorkspace(updatedWorkspace, setFocus: false)\n }\n\n func updateLastFocusedApp(_ app: MacApp, in workspace: Workspace) {\n lastFocusedApp[workspace.id] = app\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/CLIServer.swift", "//\n// CLIServer.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\nimport Network\n\nfinal class CLIServer {\n var isRunning: Bool {\n switch listener?.state ?? .cancelled {\n case .cancelled, .failed: return false\n default: return true\n }\n }\n\n private var listener: NWListener?\n private let socketPath = \"/tmp/flashspace.socket\"\n private let executors: [CommandExecutor] = [\n ProfileCommands(),\n WorkspaceCommands(),\n AppCommands(),\n FocusCommands(),\n SpaceControlCommands(),\n ListCommands(),\n GetCommands()\n ]\n\n init() { startServer() }\n\n func restart() {\n listener?.cancel()\n startServer()\n }\n\n private func startServer() {\n try? FileManager.default.removeItem(atPath: socketPath)\n\n do {\n let params = NWParameters(tls: nil, tcp: .init())\n params.allowLocalEndpointReuse = true\n params.requiredLocalEndpoint = .unix(path: socketPath)\n\n listener = try NWListener(using: params)\n listener?.newConnectionHandler = handleNewConnection\n listener?.start(queue: .global(qos: .userInitiated))\n Logger.log(\"🟢 Server started at \\(socketPath)\")\n } catch {\n Logger.log(\"❌ Failed to start server: \\(error)\")\n }\n }\n\n private func handleNewConnection(_ connection: NWConnection) {\n connection.start(queue: .global(qos: .userInitiated))\n Logger.log(\"✅ New client connected\")\n\n let buffer = BufferWrapper()\n receiveData(connection: connection, buffer: buffer)\n }\n\n private func receiveData(connection: NWConnection, buffer: BufferWrapper) {\n connection.receive(minimumIncompleteLength: 1, maximumLength: 10000) { data, _, isComplete, error in\n if let error {\n connection.cancel()\n return Logger.log(\"❌ Receive error: \\(error)\")\n }\n\n if let data { buffer.data.append(data) }\n\n // Check if complete or EOF at the end\n guard isComplete || data?.last == 0 else {\n return self.receiveData(connection: connection, buffer: buffer)\n }\n\n guard !buffer.data.isEmpty else {\n connection.cancel()\n return Logger.log(\"❌ Received empty data\")\n }\n\n do {\n let command = try buffer.data.decodeSocketData(CommandRequest.self)\n DispatchQueue.main.async {\n self.handleCommand(command, connection: connection)\n }\n } catch {\n connection.cancel()\n Logger.log(\"❌ Failed to decode command: \\(error)\")\n }\n }\n }\n\n private func handleCommand(_ command: CommandRequest, connection: NWConnection) {\n var result: CommandResponse?\n for executor in executors {\n result = executor.execute(command: command)\n if result != nil { break }\n }\n\n DispatchQueue.global(qos: .userInitiated).async {\n if let response = result?.encodeSocketData() {\n connection.send(content: response, completion: .contentProcessed { _ in connection.cancel() })\n } else {\n connection.cancel()\n Logger.log(\"❌ Failed to encode response\")\n }\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/MenuBar/MenuBarTitle.swift", "//\n// MenuBarTitle.swift\n//\n// Created by Wojciech Kulik on 31/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nenum MenuBarTitle {\n static let settings = AppDependencies.shared.menuBarSettings\n static let workspaceManager = AppDependencies.shared.workspaceManager\n static let profilesRepository = AppDependencies.shared.profilesRepository\n\n static func get() -> String? {\n let template = settings.menuBarTitleTemplate.trimmingCharacters(in: .whitespaces)\n\n guard settings.showMenuBarTitle, !template.isEmpty else { return nil }\n guard let activeWorkspace = workspaceManager.activeWorkspaceDetails else { return nil }\n\n return template\n .replacingOccurrences(of: \"$WORKSPACE_NUMBER\", with: activeWorkspace.number ?? \"\")\n .replacingOccurrences(of: \"$WORKSPACE\", with: activeWorkspace.name)\n .replacingOccurrences(of: \"$DISPLAY\", with: getDisplayName())\n .replacingOccurrences(of: \"$PROFILE\", with: profilesRepository.selectedProfile.name)\n }\n\n private static func getDisplayName() -> String {\n let aliases = settings.menuBarDisplayAliases\n .split(separator: \";\")\n .map { $0.split(separator: \"=\") }\n .reduce(into: [String: String]()) { result, pair in\n guard pair.count == 2 else { return }\n\n result[String(pair[0]).lowercased()] = String(pair[1])\n }\n\n let display = workspaceManager.activeWorkspaceDetails?.display ?? \"\"\n\n return aliases[display.lowercased()] ?? display\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/SpaceControl/Views/SpaceControlViewModel.swift", "//\n// SpaceControlViewModel.swift\n//\n// Created by Wojciech Kulik on 11/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport SwiftUI\n\nstruct SpaceControlWorkspace {\n let index: Int\n let name: String\n let symbol: String\n let screenshotData: Data?\n let isActive: Bool\n let originalWorkspace: Workspace\n}\n\nfinal class SpaceControlViewModel: ObservableObject {\n @Published private(set) var workspaces: [SpaceControlWorkspace] = []\n @Published private(set) var numberOfRows = 0\n @Published private(set) var numberOfColumns = 0\n\n private var cancellables = Set()\n\n private let settings = AppDependencies.shared.spaceControlSettings\n private let workspaceRepository = AppDependencies.shared.workspaceRepository\n private let workspaceManager = AppDependencies.shared.workspaceManager\n private let screenshotManager = AppDependencies.shared.workspaceScreenshotManager\n private let displayManager = AppDependencies.shared.displayManager\n\n init() {\n refresh()\n\n NotificationCenter.default\n .publisher(for: .spaceControlArrowDown)\n .compactMap { $0.object as? RawKeyCode }\n .sink { [weak self] in self?.handleArrowKey($0) }\n .store(in: &cancellables)\n }\n\n func onWorkspaceTap(_ workspace: SpaceControlWorkspace) {\n workspaceManager.activateWorkspace(workspace.originalWorkspace, setFocus: true)\n }\n\n func refresh() {\n let activeWorkspaceIds = workspaceManager.activeWorkspace.map(\\.value.id).asSet\n let mainDisplay = NSScreen.main?.localizedName ?? \"\"\n\n workspaces = Array(\n workspaceRepository.workspaces\n .filter { !settings.spaceControlCurrentDisplayWorkspaces || $0.isOnTheCurrentScreen }\n .prefix(15)\n .enumerated()\n .map {\n let workspace = $0.element\n let displayName = settings.spaceControlCurrentDisplayWorkspaces\n ? mainDisplay\n : self.mainDisplay(for: workspace)\n let key = WorkspaceScreenshotManager.ScreenshotKey(\n displayName: displayName,\n workspaceID: workspace.id\n )\n return SpaceControlWorkspace(\n index: $0.offset,\n name: workspace.name,\n symbol: workspace.symbolIconName ?? .defaultIconSymbol,\n screenshotData: screenshotManager.screenshots[key],\n isActive: activeWorkspaceIds.contains(workspace.id),\n originalWorkspace: workspace\n )\n }\n )\n calculateColsAndRows(workspaces.count)\n }\n\n private func mainDisplay(for workspace: Workspace) -> DisplayName {\n let workspaceDisplays = workspace.displays\n\n return workspaceDisplays.count == 1\n ? workspaceDisplays.first!\n : displayManager.lastActiveDisplay(from: workspaceDisplays)\n }\n\n private func calculateColsAndRows(_ workspaceCount: Int) {\n let maxNumberOfRows = 3.0\n\n numberOfColumns = workspaceCount <= 3\n ? workspaceCount\n : max(3, Int(ceil(Double(workspaceCount) / maxNumberOfRows)))\n numberOfColumns = min(numberOfColumns, settings.spaceControlMaxColumns)\n\n numberOfRows = Int(ceil(Double(workspaceCount) / Double(numberOfColumns)))\n }\n\n private func handleArrowKey(_ keyCode: RawKeyCode) {\n let activeWorkspaceIndex = workspaces.firstIndex {\n $0.isActive && $0.originalWorkspace.isOnTheCurrentScreen\n }\n guard let activeWorkspaceIndex else { return }\n\n let workspace: Workspace? = switch KeyCodesMap.toString[keyCode] {\n case \"down\":\n workspaces[safe: activeWorkspaceIndex + numberOfColumns]?.originalWorkspace\n case \"up\":\n workspaces[safe: activeWorkspaceIndex - numberOfColumns]?.originalWorkspace\n case \"right\":\n workspaces[safe: (activeWorkspaceIndex + 1) % workspaces.count]?.originalWorkspace\n case \"left\":\n workspaces[\n safe: activeWorkspaceIndex == 0\n ? workspaces.count - 1\n : activeWorkspaceIndex - 1\n ]?.originalWorkspace\n default:\n nil\n }\n\n if let workspace {\n SpaceControl.hide()\n workspaceManager.activateWorkspace(workspace, setFocus: true)\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/FloatingApps/FloatingAppsHotKeys.swift", "//\n// FloatingAppsHotKeys.swift\n//\n// Created by Wojciech Kulik on 16/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nfinal class FloatingAppsHotKeys {\n private let workspaceManager: WorkspaceManager\n private let floatingAppsSettings: FloatingAppsSettings\n\n init(\n workspaceManager: WorkspaceManager,\n settingsRepository: SettingsRepository\n ) {\n self.workspaceManager = workspaceManager\n self.floatingAppsSettings = settingsRepository.floatingAppsSettings\n }\n\n func getHotKeys() -> [(AppHotKey, () -> ())] {\n let hotKeys = [\n getFloatTheFocusedAppHotKey(),\n getUnfloatTheFocusedAppHotKey(),\n getToggleTheFocusedAppFloatingHotKey()\n ]\n\n return hotKeys.compactMap(\\.self)\n }\n\n private func getFloatTheFocusedAppHotKey() -> (AppHotKey, () -> ())? {\n guard let shortcut = floatingAppsSettings.floatTheFocusedApp else { return nil }\n\n return (shortcut, { [weak self] in self?.floatApp() })\n }\n\n private func getUnfloatTheFocusedAppHotKey() -> (AppHotKey, () -> ())? {\n guard let shortcut = floatingAppsSettings.unfloatTheFocusedApp else { return nil }\n\n return (shortcut, { [weak self] in self?.unfloatApp() })\n }\n\n private func getToggleTheFocusedAppFloatingHotKey() -> (AppHotKey, () -> ())? {\n guard let shortcut = floatingAppsSettings.toggleTheFocusedAppFloating else { return nil }\n\n let action = { [weak self] in\n guard let self, let activeApp = NSWorkspace.shared.frontmostApplication else { return }\n\n if floatingAppsSettings.floatingApps.containsApp(activeApp) {\n unfloatApp()\n } else {\n floatApp()\n }\n }\n return (shortcut, action)\n }\n}\n\nextension FloatingAppsHotKeys {\n private func floatApp() {\n guard let activeApp = NSWorkspace.shared.frontmostApplication,\n let appName = activeApp.localizedName else { return }\n\n floatingAppsSettings.addFloatingAppIfNeeded(app: activeApp.toMacApp)\n Toast.showWith(\n icon: \"macwindow.on.rectangle\",\n message: \"\\(appName) - Added To Floating Apps\",\n textColor: .positive\n )\n }\n\n private func unfloatApp() {\n guard let activeApp = NSWorkspace.shared.frontmostApplication,\n let appName = activeApp.localizedName else { return }\n\n if floatingAppsSettings.floatingApps.containsApp(activeApp) {\n Toast.showWith(\n icon: \"macwindow\",\n message: \"\\(appName) - Removed From Floating Apps\",\n textColor: .negative\n )\n }\n\n floatingAppsSettings.deleteFloatingApp(app: activeApp.toMacApp)\n\n guard let screen = activeApp.display else { return }\n\n if workspaceManager.activeWorkspace[screen]?.apps.containsApp(activeApp) != true {\n activeApp.hide()\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/MainScreen/MainViewModel.swift", "//\n// MainViewModel.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Combine\nimport SwiftUI\n\nfinal class MainViewModel: ObservableObject {\n @Published var workspaces: [Workspace] = [] {\n didSet {\n guard workspaces.count == oldValue.count,\n workspaces.map(\\.id) != oldValue.map(\\.id) else { return }\n\n workspaceRepository.reorderWorkspaces(newOrder: workspaces.map(\\.id))\n }\n }\n\n @Published var workspaceApps: [MacApp]?\n\n @Published var workspaceName = \"\"\n @Published var workspaceShortcut: AppHotKey? {\n didSet { saveWorkspace() }\n }\n\n @Published var workspaceAssignShortcut: AppHotKey? {\n didSet { saveWorkspace() }\n }\n\n @Published var workspaceDisplay = \"\" {\n didSet { saveWorkspace() }\n }\n\n @Published var workspaceAppToFocus: MacApp? = AppConstants.lastFocusedOption {\n didSet { saveWorkspace() }\n }\n\n @Published var workspaceSymbolIconName: String? {\n didSet { saveWorkspace() }\n }\n\n @Published var isSymbolPickerPresented = false\n @Published var isInputDialogPresented = false\n @Published var userInput = \"\"\n\n var focusAppOptions: [MacApp] {\n [AppConstants.lastFocusedOption] + (workspaceApps ?? [])\n }\n\n var selectedApps: Set = [] {\n didSet {\n // To avoid warnings\n DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) { [self] in\n objectWillChange.send()\n }\n }\n }\n\n var selectedWorkspaces: Set = [] {\n didSet {\n selectedWorkspace = selectedWorkspaces.count == 1\n ? selectedWorkspaces.first\n : nil\n\n // To avoid warnings\n DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) { [self] in\n if selectedWorkspaces.count == 1,\n selectedWorkspaces.first?.id != oldValue.first?.id {\n selectedApps = []\n } else if selectedWorkspaces.count != 1 {\n selectedApps = []\n }\n objectWillChange.send()\n }\n }\n }\n\n private(set) var selectedWorkspace: Workspace? {\n didSet {\n guard selectedWorkspace != oldValue else { return }\n\n // To avoid warnings\n DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) {\n self.updateSelectedWorkspace()\n }\n }\n }\n\n var screens: [String] {\n let set = NSScreen.screens.compactMap(\\.localizedName).asSet\n let otherScreens = workspaces.map(\\.display)\n\n return Array(set.union(otherScreens))\n .filter(\\.isNotEmpty)\n .sorted()\n }\n\n var displayMode: DisplayMode { workspaceSettings.displayMode }\n\n private var cancellables: Set = []\n private var loadingWorkspace = false\n\n private let workspaceManager = AppDependencies.shared.workspaceManager\n private let workspaceRepository = AppDependencies.shared.workspaceRepository\n private let workspaceSettings = AppDependencies.shared.workspaceSettings\n\n init() {\n self.workspaces = workspaceRepository.workspaces\n self.workspaceDisplay = NSScreen.main?.localizedName ?? \"\"\n\n observe()\n }\n\n private func observe() {\n NotificationCenter.default\n .publisher(for: .appsListChanged)\n .sink { [weak self] _ in self?.reloadWorkspaces() }\n .store(in: &cancellables)\n\n NotificationCenter.default\n .publisher(for: .profileChanged)\n .sink { [weak self] _ in self?.reloadWorkspaces() }\n .store(in: &cancellables)\n\n workspaceSettings.updatePublisher\n .compactMap { [weak self] in self?.workspaceSettings.displayMode }\n .removeDuplicates()\n .sink { [weak self] _ in self?.objectWillChange.send() }\n .store(in: &cancellables)\n }\n\n private func updateSelectedWorkspace() {\n loadingWorkspace = true\n defer { loadingWorkspace = false }\n\n workspaceName = selectedWorkspace?.name ?? \"\"\n workspaceShortcut = selectedWorkspace?.activateShortcut\n workspaceAssignShortcut = selectedWorkspace?.assignAppShortcut\n workspaceDisplay = selectedWorkspace?.display ?? NSScreen.main?.localizedName ?? \"\"\n workspaceApps = selectedWorkspace?.apps\n workspaceAppToFocus = selectedWorkspace?.appToFocus ?? AppConstants.lastFocusedOption\n workspaceSymbolIconName = selectedWorkspace?.symbolIconName\n selectedWorkspace.flatMap { selectedWorkspaces = [$0] }\n }\n\n private func reloadWorkspaces() {\n workspaces = workspaceRepository.workspaces\n if let selectedWorkspace, let workspace = workspaces.first(where: { $0.id == selectedWorkspace.id }) {\n selectedWorkspaces = [workspace]\n } else {\n selectedWorkspaces = []\n }\n selectedApps = []\n }\n}\n\nextension MainViewModel {\n func saveWorkspace() {\n guard let selectedWorkspace, !loadingWorkspace else { return }\n\n if workspaceName.trimmingCharacters(in: .whitespaces).isEmpty {\n workspaceName = \"(empty)\"\n }\n\n let updatedWorkspace = Workspace(\n id: selectedWorkspace.id,\n name: workspaceName,\n display: workspaceDisplay,\n activateShortcut: workspaceShortcut,\n assignAppShortcut: workspaceAssignShortcut,\n apps: selectedWorkspace.apps,\n appToFocus: workspaceAppToFocus == AppConstants.lastFocusedOption ? nil : workspaceAppToFocus,\n symbolIconName: workspaceSymbolIconName\n )\n\n workspaceRepository.updateWorkspace(updatedWorkspace)\n workspaces = workspaceRepository.workspaces\n self.selectedWorkspace = workspaces.first { $0.id == selectedWorkspace.id }\n }\n\n func addWorkspace() {\n userInput = \"\"\n isInputDialogPresented = true\n\n $isInputDialogPresented\n .first { !$0 }\n .sink { [weak self] _ in\n guard let self, !self.userInput.isEmpty else { return }\n\n self.workspaceRepository.addWorkspace(name: self.userInput)\n self.workspaces = self.workspaceRepository.workspaces\n self.selectedWorkspace = self.workspaces.last\n }\n .store(in: &cancellables)\n }\n\n func deleteSelectedWorkspaces() {\n guard !selectedWorkspaces.isEmpty else { return }\n\n workspaceRepository.deleteWorkspaces(ids: selectedWorkspaces.map(\\.id).asSet)\n workspaces = workspaceRepository.workspaces\n selectedWorkspaces = []\n }\n\n func addApp() {\n guard let selectedWorkspace else { return }\n\n let fileChooser = FileChooser()\n let appUrl = fileChooser.runModalOpenPanel(\n allowedFileTypes: [.application],\n directoryURL: URL(filePath: \"/Applications\")\n )\n\n guard let appUrl else { return }\n\n let appName = appUrl.appName\n let appBundleId = appUrl.bundleIdentifier ?? \"\"\n let runningApp = NSWorkspace.shared.runningApplications.first { $0.bundleIdentifier == appBundleId }\n let isAgent = appUrl.bundle?.isAgent == true && (runningApp == nil || runningApp?.activationPolicy != .regular)\n\n guard !isAgent else {\n Alert.showOkAlert(\n title: appName,\n message: \"This application is an agent (runs in background) and cannot be managed by FlashSpace.\"\n )\n return\n }\n\n guard !selectedWorkspace.apps.containsApp(with: appBundleId) else { return }\n\n workspaceRepository.addApp(\n to: selectedWorkspace.id,\n app: .init(\n name: appName,\n bundleIdentifier: appBundleId,\n iconPath: appUrl.iconPath\n )\n )\n\n workspaces = workspaceRepository.workspaces\n self.selectedWorkspace = workspaces.first { $0.id == selectedWorkspace.id }\n\n workspaceManager.activateWorkspaceIfActive(selectedWorkspace.id)\n }\n\n func deleteSelectedApps() {\n guard let selectedWorkspace, !selectedApps.isEmpty else { return }\n\n let selectedApps = Array(selectedApps)\n\n for app in selectedApps {\n workspaceRepository.deleteApp(\n from: selectedWorkspace.id,\n app: app,\n notify: app == selectedApps.last\n )\n }\n\n workspaces = workspaceRepository.workspaces\n self.selectedWorkspace = workspaces.first { $0.id == selectedWorkspace.id }\n workspaceApps = self.selectedWorkspace?.apps\n self.selectedApps = []\n\n workspaceManager.activateWorkspaceIfActive(selectedWorkspace.id)\n }\n\n func resetWorkspaceSymbolIcon() {\n workspaceSymbolIconName = nil\n saveWorkspace()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Displays/DisplayManager.swift", "//\n// DisplayManager.swift\n//\n// Created by Moritz Brödel on 19/06/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Combine\n\nfinal class DisplayManager: ObservableObject {\n struct Focus {\n let display: DisplayName\n let app: MacApp\n }\n\n private var focusHistory: [Focus] = []\n private let workspaceSettings: WorkspaceSettings\n\n init(settingsRepository: SettingsRepository) {\n self.workspaceSettings = settingsRepository.workspaceSettings\n }\n\n func lastFocusedDisplay(where condition: (Focus) -> Bool) -> Focus? {\n focusHistory.last(where: condition)\n }\n\n func trackDisplayFocus(on display: DisplayName, for application: NSRunningApplication) {\n guard !application.isFinder || application.allWindows.isNotEmpty else { return }\n\n focusHistory.removeAll { $0.display == display }\n focusHistory.append(.init(display: display, app: application.toMacApp))\n }\n\n func getCursorScreen() -> DisplayName? {\n let cursorLocation = NSEvent.mouseLocation\n return NSScreen.screens\n .first { NSMouseInRect(cursorLocation, $0.frame, false) }?\n .localizedName\n }\n\n func resolveDisplay(_ display: DisplayName) -> DisplayName {\n guard !NSScreen.isConnected(display) else { return display }\n\n let alternativeDisplays = workspaceSettings.alternativeDisplays\n .split(separator: \";\")\n .map { $0.split(separator: \"=\") }\n .compactMap { pair -> (source: String, target: String)? in\n guard pair.count == 2 else { return nil }\n return (String(pair[0]).trimmed, String(pair[1]).trimmed)\n }\n\n let alternative = alternativeDisplays\n .filter { $0.source == display }\n .map(\\.target)\n .first(where: NSScreen.isConnected)\n\n return alternative ?? NSScreen.main?.localizedName ?? \"\"\n }\n\n func lastActiveDisplay(from candidates: Set) -> DisplayName {\n if let recentDisplay = lastFocusedDisplay(where: { candidates.contains($0.display) })?.display {\n return recentDisplay\n }\n\n if let cursorDisplay = getCursorScreen(), candidates.contains(cursorDisplay) {\n return cursorDisplay\n }\n\n return candidates.first ?? NSScreen.main?.localizedName ?? \"\"\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Workspaces/Models/Workspace.swift", "//\n// Workspace.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\n\ntypealias WorkspaceID = UUID\n\nstruct Workspace: Identifiable, Codable, Hashable {\n enum CodingKeys: String, CodingKey {\n case id\n case name\n case display\n case activateShortcut = \"shortcut\"\n case assignAppShortcut\n case apps\n case appToFocus\n case symbolIconName\n }\n\n var id: WorkspaceID\n var name: String\n var display: DisplayName\n var activateShortcut: AppHotKey?\n var assignAppShortcut: AppHotKey?\n var apps: [MacApp]\n var appToFocus: MacApp?\n var symbolIconName: String?\n}\n\nextension Workspace {\n var displays: Set {\n if NSScreen.screens.count == 1 {\n return [NSScreen.main?.localizedName ?? \"\"]\n } else if isDynamic {\n // TODO: After disconnecting a display, the detection may not work correctly.\n // The app will have the old coordinates until it is shown again, which\n // prevents from detecting the correct display.\n //\n // The workaround is to activate the app manually to update its frame.\n return NSWorkspace.shared.runningApplications\n .filter { $0.activationPolicy == .regular && apps.containsApp($0) }\n .flatMap(\\.allDisplays)\n .asSet\n } else {\n return [displayManager.resolveDisplay(display)]\n }\n }\n\n var displayForPrint: DisplayName {\n if isDynamic,\n let mainDisplay = NSScreen.main?.localizedName,\n displays.contains(mainDisplay) {\n return mainDisplay\n }\n\n return isDynamic\n ? displayManager.lastActiveDisplay(from: displays)\n : displayManager.resolveDisplay(display)\n }\n\n var isOnTheCurrentScreen: Bool {\n guard let currentScreen = NSScreen.main?.localizedName else { return false }\n return displays.contains(currentScreen)\n }\n\n var isDynamic: Bool {\n AppDependencies.shared.workspaceSettings.displayMode == .dynamic\n }\n\n private var displayManager: DisplayManager {\n AppDependencies.shared.displayManager\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Models/CommandError.swift", "//\n// CommandError.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nenum CommandError: Error, LocalizedError {\n case timeout\n case connectionError(Error)\n case emptyResponse\n case couldNotEncode(Error)\n case operationFailed(String)\n case missingArgument\n case other\n\n var errorDescription: String? {\n switch self {\n case .timeout:\n return \"Timeout. Please check if FlashSpace is running.\"\n case .connectionError(let error):\n return \"Connection error. Please check if FlashSpace is running.\\n\\(error)\"\n case .emptyResponse:\n return \"Empty response. Please check if FlashSpace is running.\"\n case .couldNotEncode(let error):\n return \"Could not encode the message. Please try again.\\n\\(error)\"\n case .operationFailed(let message):\n return message\n case .missingArgument:\n return \"Missing argument(s). Please provide the required argument(s).\"\n case .other:\n return \"\"\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/MenuBar/FlashSpaceMenuBar.swift", "//\n// FlashSpaceMenuBar.swift\n//\n// Created by Wojciech Kulik on 13/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct FlashSpaceMenuBar: Scene {\n @Environment(\\.openWindow) private var openWindow\n\n @StateObject private var workspaceManager = AppDependencies.shared.workspaceManager\n @StateObject private var settingsRepository = AppDependencies.shared.settingsRepository\n @StateObject private var profilesRepository = AppDependencies.shared.profilesRepository\n @StateObject private var workspaceRepository = AppDependencies.shared.workspaceRepository\n\n var body: some Scene {\n MenuBarExtra {\n Text(\"FlashSpace v\\(AppConstants.version)\")\n\n Button(\"Open\") {\n openWindow(id: \"main\")\n NSApp.activate(ignoringOtherApps: true)\n }\n\n if settingsRepository.spaceControlSettings.enableSpaceControl {\n Button(\"Space Control\") {\n SpaceControl.show()\n }\n }\n\n Divider()\n\n Button(\"Settings\") {\n openWindow(id: \"settings\")\n NSApp.activate(ignoringOtherApps: true)\n }.keyboardShortcut(\",\")\n\n Menu(\"Profiles\") {\n ForEach(profilesRepository.profiles) { profile in\n Toggle(\n profile.name,\n isOn: .init(\n get: { profilesRepository.selectedProfile == profile },\n set: {\n if $0 { profilesRepository.selectedProfile = profile }\n }\n )\n )\n }\n }.hidden(profilesRepository.profiles.count < 2)\n\n Menu(\"Workspaces\") {\n ForEach(workspaceRepository.workspaces) { workspace in\n Button {\n if workspace.isDynamic, workspace.displays.isEmpty {\n Toast.showWith(\n icon: \"square.stack.3d.up\",\n message: \"\\(workspace.name) - No Running Apps To Show\",\n textColor: .gray\n )\n } else {\n workspaceManager.activateWorkspace(workspace, setFocus: true)\n }\n } label: {\n Text(workspace.name)\n }\n .keyboardShortcut(workspace.activateShortcut?.toKeyboardShortcut)\n }\n }.hidden(workspaceRepository.workspaces.count < 2)\n\n Divider()\n\n Button(\"Donate\") {\n if let url = URL(string: \"https://github.com/sponsors/wojciech-kulik\") {\n NSWorkspace.shared.open(url)\n }\n }\n\n Button(\"Project Website\") {\n if let url = URL(string: \"https://github.com/wojciech-kulik/FlashSpace\") {\n NSWorkspace.shared.open(url)\n }\n }\n\n Button(\"Check for Updates\") {\n UpdatesManager.shared.checkForUpdates()\n }\n\n Divider()\n\n Button(\"Quit\") {\n NSApp.terminate(nil)\n }.keyboardShortcut(\"q\")\n } label: {\n HStack {\n let title = MenuBarTitle.get()\n if title == nil || settingsRepository.menuBarSettings.showMenuBarIcon {\n Image(systemName: workspaceManager.activeWorkspaceDetails?.symbolIconName ?? .defaultIconSymbol)\n }\n if let title { Text(title) }\n }\n .id(settingsRepository.menuBarSettings.menuBarTitleTemplate)\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/PictureInPicture/PictureInPictureManager.swift", "//\n// PictureInPictureManager.swift\n//\n// Created by Wojciech Kulik on 12/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Combine\n\nfinal class PictureInPictureManager {\n typealias AXWindow = AXUIElement\n\n private var hiddenWindows: [NSRunningApplication: [AXWindow]] = [:]\n private var capturedFrame: [AXWindow: CGRect] = [:]\n private var cancellables: Set = []\n private var windowFocusObserver: AXObserver?\n\n private let settings: WorkspaceSettings\n\n init(settingsRepository: SettingsRepository) {\n self.settings = settingsRepository.workspaceSettings\n setupSignalHandlers()\n observePipFocusChangeNotification()\n }\n\n func restoreAppIfNeeded(app: NSRunningApplication) {\n guard settings.enablePictureInPictureSupport else { return }\n\n if hiddenWindows.keys.contains(app) {\n restoreFromCornerNonPipWindows(app: app)\n }\n }\n\n func restoreAllWindows() {\n for app in hiddenWindows.keys {\n showPipAppIfNeeded(app: app)\n }\n }\n\n func showPipAppIfNeeded(app: NSRunningApplication) {\n guard settings.enablePictureInPictureSupport,\n app.supportsPictureInPicture else { return }\n\n restoreFromCornerNonPipWindows(app: app)\n }\n\n func hidePipAppIfNeeded(app: NSRunningApplication) -> Bool {\n guard settings.enablePictureInPictureSupport,\n app.supportsPictureInPicture,\n app.isPictureInPictureActive\n else { return false }\n\n guard hiddenWindows[app] == nil else { return true }\n\n guard settings.displayMode == .static || app.allDisplays.count <= 1 else {\n // pip is not supported for multi-display apps\n return false\n }\n\n return hideInCornerNonPipWindows(app: app)\n }\n\n private func observePipFocusChangeNotification() {\n NotificationCenter.default\n .publisher(for: .pipFocusChanged)\n .sink { [weak self] _ in self?.restorePipWorkspace() }\n .store(in: &cancellables)\n }\n\n private func restorePipWorkspace() {\n guard let app = hiddenWindows.keys.first(where: { !$0.isPictureInPictureActive }) else { return }\n\n restoreAllWindows()\n\n let workspaceRepository = AppDependencies.shared.workspaceRepository\n let workspaceManager = AppDependencies.shared.workspaceManager\n let workspace = workspaceRepository.workspaces.first { $0.apps.containsApp(app) }\n\n guard let workspace else { return }\n\n windowFocusObserver = nil\n workspaceManager.activateWorkspace(workspace, setFocus: false)\n }\n\n private func restoreFromCornerNonPipWindows(app: NSRunningApplication) {\n windowFocusObserver = nil\n\n app.runWithoutAnimations {\n for window in hiddenWindows[app] ?? [] {\n if let previousFrame = capturedFrame[window] {\n window.setPosition(previousFrame.origin)\n capturedFrame.removeValue(forKey: window)\n }\n }\n }\n\n hiddenWindows.removeValue(forKey: app)\n }\n\n private func hideInCornerNonPipWindows(app: NSRunningApplication) -> Bool {\n guard let screenCorner = findScreenCorner(app: app) else { return false }\n\n let nonPipWindows = app.allWindows\n .map(\\.window)\n .filter { !$0.isPictureInPicture(bundleId: app.bundleIdentifier) }\n\n if nonPipWindows.isNotEmpty { observePipApp(app) }\n\n app.runWithoutAnimations {\n for window in nonPipWindows {\n if let windowFrame = window.frame, screenCorner != windowFrame.origin {\n capturedFrame[window] = windowFrame\n window.setPosition(screenCorner)\n }\n }\n }\n hiddenWindows[app] = nonPipWindows\n\n return true\n }\n\n private func findScreenCorner(app: NSRunningApplication) -> CGPoint? {\n guard let appScreen = NSScreen.screen(app.display) else {\n return nil\n }\n\n // Screen origin (0,0) is in the bottom-left corner, y-axis is pointing up\n // Window origin (0,0) is in the top-left corner, y-axis is pointing down\n // E.g. To place a window in the bottom-right corner of the screen\n // we need to set window origin to:\n // (screen.maxX - window.width, screen.maxY - window.height).\n\n let testOffset: CGFloat = 30.0\n let cornerOffset = CGFloat(settings.pipScreenCornerOffset)\n let appFrame = app.frame\n let screenFrame = appScreen.frame\n let leftCorner = CGPoint(x: screenFrame.minX, y: screenFrame.minY)\n let rightCorner = CGPoint(x: screenFrame.maxX, y: screenFrame.minY)\n let leftSide = leftCorner.applying(\n CGAffineTransform(translationX: -testOffset, y: testOffset)\n )\n let leftBottomSide = leftCorner.applying(\n CGAffineTransform(translationX: testOffset, y: -testOffset)\n )\n let rightSide = rightCorner.applying(\n CGAffineTransform(translationX: testOffset, y: testOffset)\n )\n let rightBottomSide = rightCorner.applying(\n CGAffineTransform(translationX: -testOffset, y: -testOffset)\n )\n\n let allScreens = NSScreen.screens.map(\\.frame)\n let isLeftCornerUsed = allScreens.contains(where: { $0.contains(leftSide) || $0.contains(leftBottomSide) })\n let isRightCornerUsed = allScreens.contains(where: { $0.contains(rightSide) || $0.contains(rightBottomSide) })\n\n if isLeftCornerUsed || !isRightCornerUsed || appFrame == nil {\n // right corner (window coordinates)\n return CGPoint(\n x: screenFrame.maxX - cornerOffset,\n y: screenFrame.maxY - cornerOffset\n )\n } else {\n // left corner (window coordinates)\n let appFrame = appFrame ?? .zero\n return CGPoint(\n x: screenFrame.minX + cornerOffset - appFrame.width,\n y: screenFrame.maxY - cornerOffset\n )\n }\n }\n\n private func setupSignalHandlers() {\n for code in [SIGTERM, SIGINT] {\n signal(code) {\n AppDependencies.shared.pictureInPictureManager.restoreAllWindows()\n exit($0)\n }\n }\n }\n\n private func observePipApp(_ app: NSRunningApplication) {\n guard settings.switchWorkspaceWhenPipCloses else { return }\n\n let callback: AXObserverCallback = { _, _, _, _ in\n NotificationCenter.default.post(name: .pipFocusChanged, object: nil)\n }\n\n let result = AXObserverCreate(app.processIdentifier, callback, &windowFocusObserver)\n\n guard result == .success, let observer = windowFocusObserver else { return }\n\n let appRef = AXUIElementCreateApplication(app.processIdentifier)\n AXObserverAddNotification(observer, appRef, kAXFocusedWindowChangedNotification as CFString, nil)\n CFRunLoopAddSource(CFRunLoopGetCurrent(), AXObserverGetRunLoopSource(observer), .defaultMode)\n }\n\n // MARK: - Alternative solution by minimizing windows (animation)\n private func deminimizeAllWindows(app: NSRunningApplication) {\n for window in app.allWindows.map(\\.window) {\n window.minimize(false)\n }\n }\n\n private func minimizeNonPipWindows(app: NSRunningApplication) {\n app.allWindows\n .map(\\.window)\n .filter { !$0.isPictureInPicture(bundleId: app.bundleIdentifier) }\n .forEach { $0.minimize(true) }\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/SocketClient.swift", "//\n// SocketClient.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\nimport Network\n\nfinal class SocketClient {\n static let shared = SocketClient()\n\n private let socketPath = \"/tmp/flashspace.socket\"\n private var buffer = Data()\n private let jsonEncoder = JSONEncoder()\n\n private init() {}\n\n func sendCommand(_ command: CommandRequest) {\n let connection = NWConnection(to: .unix(path: socketPath), using: .tcp)\n connection.start(queue: .main)\n\n let messageData = command.encodeSocketData()\n connection.send(content: messageData, completion: .contentProcessed { error in\n if let error {\n connection.cancel()\n FlashSpaceCLI.exit(withError: CommandError.connectionError(error))\n }\n\n self.receiveData(connection: connection)\n })\n }\n\n private func receiveData(connection: NWConnection) {\n connection.receive(minimumIncompleteLength: 1, maximumLength: 10000) { data, _, isComplete, error in\n if let error {\n connection.cancel()\n FlashSpaceCLI.exit(withError: CommandError.connectionError(error))\n }\n\n if let data { self.buffer.append(data) }\n\n // Check if the message is complete or EOF is reached\n guard isComplete || data?.last == 0 else {\n return self.receiveData(connection: connection)\n }\n\n if self.buffer.isEmpty {\n connection.cancel()\n FlashSpaceCLI.exit(withError: CommandError.emptyResponse)\n }\n\n if let response = try? self.buffer.decodeSocketData(CommandResponse.self) {\n self.handleResponse(response, connection: connection)\n } else {\n FlashSpaceCLI.exit(withError: CommandError.operationFailed(\"Could not decode the response\"))\n }\n }\n }\n\n private func handleResponse(_ response: CommandResponse, connection: NWConnection) {\n if response.success {\n response.message.flatMap { print($0) }\n connection.cancel()\n FlashSpaceCLI.exit()\n } else {\n connection.cancel()\n FlashSpaceCLI.exit(withError: CommandError.operationFailed(response.error ?? \"Operation Failed\"))\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/FocusManager/FocusManager.swift", "//\n// FocusManager.swift\n//\n// Created by Wojciech Kulik on 23/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\n\nfinal class FocusManager {\n var visibleApps: [NSRunningApplication] {\n NSWorkspace.shared.runningApplications\n .filter { $0.activationPolicy == .regular && !$0.isHidden }\n }\n\n var focusedApp: NSRunningApplication? { NSWorkspace.shared.frontmostApplication }\n var focusedAppFrame: CGRect? { focusedApp?.frame }\n\n private let workspaceRepository: WorkspaceRepository\n private let workspaceManager: WorkspaceManager\n private let settings: FocusManagerSettings\n private let floatingAppsSettings: FloatingAppsSettings\n\n init(\n workspaceRepository: WorkspaceRepository,\n workspaceManager: WorkspaceManager,\n focusManagerSettings: FocusManagerSettings,\n floatingAppsSettings: FloatingAppsSettings\n ) {\n self.workspaceRepository = workspaceRepository\n self.workspaceManager = workspaceManager\n self.settings = focusManagerSettings\n self.floatingAppsSettings = floatingAppsSettings\n }\n\n func getHotKeys() -> [(AppHotKey, () -> ())] {\n guard settings.enableFocusManagement else { return [] }\n\n return [\n settings.focusLeft.flatMap { ($0, focusLeft) },\n settings.focusRight.flatMap { ($0, focusRight) },\n settings.focusUp.flatMap { ($0, focusUp) },\n settings.focusDown.flatMap { ($0, focusDown) },\n settings.focusNextWorkspaceApp.flatMap { ($0, nextWorkspaceApp) },\n settings.focusPreviousWorkspaceApp.flatMap { ($0, previousWorkspaceApp) },\n settings.focusNextWorkspaceWindow.flatMap { ($0, nextWorkspaceWindow) },\n settings.focusPreviousWorkspaceWindow.flatMap { ($0, previousWorkspaceWindow) }\n ].compactMap { $0 }\n }\n\n func nextWorkspaceWindow() {\n guard let focusedApp else { return nextWorkspaceApp() }\n guard let (_, apps) = getFocusedAppIndex() else { return }\n\n let runningWorkspaceApps = getRunningAppsWithSortedWindows(apps: apps)\n let focusedAppWindows = runningWorkspaceApps\n .first { $0.bundleIdentifier == focusedApp.bundleIdentifier }?\n .windows ?? []\n let isLastWindowFocused = focusedAppWindows.last?.axWindow.isMain == true\n\n if isLastWindowFocused {\n let nextApps = runningWorkspaceApps.drop(while: { $0.bundleIdentifier != focusedApp.bundleIdentifier }).dropFirst() +\n runningWorkspaceApps.prefix(while: { $0.bundleIdentifier != focusedApp.bundleIdentifier })\n let nextApp = nextApps.first ?? MacAppWithWindows(app: focusedApp)\n\n nextApp.app.activate()\n nextApp\n .windows\n .first?\n .axWindow\n .focus()\n } else {\n focusedAppWindows\n .drop(while: { !$0.axWindow.isMain })\n .dropFirst()\n .first?\n .axWindow\n .focus()\n }\n }\n\n func previousWorkspaceWindow() {\n guard let focusedApp else { return previousWorkspaceApp() }\n guard let (_, apps) = getFocusedAppIndex() else { return }\n\n let runningWorkspaceApps = getRunningAppsWithSortedWindows(apps: apps)\n let focusedAppWindows = runningWorkspaceApps\n .first { $0.bundleIdentifier == focusedApp.bundleIdentifier }?\n .windows ?? []\n let isFirstWindowFocused = focusedAppWindows.first?.axWindow.isMain == true\n\n if isFirstWindowFocused {\n let prevApps = runningWorkspaceApps.drop(while: { $0.bundleIdentifier != focusedApp.bundleIdentifier }).dropFirst() +\n runningWorkspaceApps.prefix(while: { $0.bundleIdentifier != focusedApp.bundleIdentifier })\n let prevApp = prevApps.last ?? MacAppWithWindows(app: focusedApp)\n\n prevApp.app.activate()\n prevApp\n .windows\n .last?\n .axWindow\n .focus()\n } else {\n focusedAppWindows\n .prefix(while: { !$0.axWindow.isMain })\n .last?\n .axWindow\n .focus()\n }\n }\n\n func nextWorkspaceApp() {\n guard let (index, apps) = getFocusedAppIndex() else { return }\n\n let appsQueue = apps.dropFirst(index + 1) + apps.prefix(index)\n let runningApps = NSWorkspace.shared.runningApplications\n .excludeFloatingAppsOnDifferentScreen()\n .compactMap(\\.bundleIdentifier)\n .asSet\n let nextApp = appsQueue.first { app in runningApps.contains(app.bundleIdentifier) }\n\n NSWorkspace.shared.runningApplications\n .find(nextApp)?\n .activate()\n }\n\n func previousWorkspaceApp() {\n guard let (index, apps) = getFocusedAppIndex() else { return }\n\n let runningApps = NSWorkspace.shared.runningApplications\n .excludeFloatingAppsOnDifferentScreen()\n .compactMap(\\.bundleIdentifier)\n .asSet\n let prefixApps = apps.prefix(index).reversed()\n let suffixApps = apps.suffix(apps.count - index - 1).reversed()\n let appsQueue = prefixApps + Array(suffixApps)\n let previousApp = appsQueue.first { app in runningApps.contains(app.bundleIdentifier) }\n\n NSWorkspace.shared.runningApplications\n .find(previousApp)?\n .activate()\n }\n\n func focusRight() {\n focus { focusedAppFrame, other in\n other.maxX > focusedAppFrame.maxX &&\n other.verticalIntersect(with: focusedAppFrame)\n }\n }\n\n func focusLeft() {\n focus { focusedAppFrame, other in\n other.minX < focusedAppFrame.minX &&\n other.verticalIntersect(with: focusedAppFrame)\n }\n }\n\n func focusDown() {\n focus { focusedAppFrame, other in\n other.maxY > focusedAppFrame.maxY &&\n other.horizontalIntersect(with: focusedAppFrame)\n }\n }\n\n func focusUp() {\n focus { focusedAppFrame, other in\n other.minY < focusedAppFrame.minY &&\n other.horizontalIntersect(with: focusedAppFrame)\n }\n }\n\n /// Predicate compares two frames using window coordinates.\n /// (0,0) is top-left corner relative to the main screen.\n /// Y-axis is pointing down.\n private func focus(predicate: (CGRect, CGRect) -> Bool) {\n guard let focusedAppFrame else { return }\n\n let appsToCheck = visibleApps\n .flatMap { app in\n app.allWindows.map {\n (app: app, window: $0.window, frame: $0.frame)\n }\n }\n\n let toFocus = appsToCheck\n .filter { predicate(focusedAppFrame, $0.frame) && !$0.window.isMinimized }\n .sorted { $0.frame.distance(to: focusedAppFrame) < $1.frame.distance(to: focusedAppFrame) }\n .first { app in\n guard settings.focusFrontmostWindow else { return true }\n\n let otherWindows = appsToCheck\n .filter { $0.app != app.app && $0.app != focusedApp }\n .map(\\.window)\n return !app.window.isBelowAnyOf(otherWindows)\n }\n\n toFocus?.window.focus()\n toFocus?.app.activate()\n centerCursorIfNeeded(in: toFocus?.frame)\n }\n\n private func centerCursorIfNeeded(in frame: CGRect?) {\n guard settings.centerCursorOnFocusChange, let frame else { return }\n\n CGWarpMouseCursorPosition(CGPoint(x: frame.midX, y: frame.midY))\n }\n\n private func getFocusedAppIndex() -> (Int, [MacApp])? {\n guard let focusedApp else { return nil }\n\n let workspace = workspaceManager.activeWorkspace[NSScreen.main?.localizedName ?? \"\"]\n ?? workspaceRepository.workspaces.first { $0.apps.containsApp(focusedApp) }\n\n guard let workspace else { return nil }\n\n let apps = workspace.apps + floatingAppsSettings.floatingApps\n .filter { !$0.isFinder }\n\n let index = apps.firstIndex(of: focusedApp) ?? 0\n\n return (index, apps)\n }\n\n private func getRunningAppsWithSortedWindows(apps: [MacApp]) -> [MacAppWithWindows] {\n let order = apps\n .enumerated()\n .reduce(into: [String: Int]()) {\n $0[$1.element.bundleIdentifier] = $1.offset\n }\n\n return NSWorkspace.shared.runningApplications\n .filter { !$0.isHidden && apps.containsApp($0) }\n .excludeFloatingAppsOnDifferentScreen()\n .map { MacAppWithWindows(app: $0) }\n .sorted { order[$0.bundleIdentifier] ?? 0 < order[$1.bundleIdentifier] ?? 0 }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Gestures/SwipeManager.swift", "//\n// SwipeManager.swift\n//\n// Created by Wojciech Kulik on 22/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n// Based on: https://github.com/MediosZ/SwipeAeroSpace\n\nimport AppKit\nimport Combine\n\nfinal class SwipeManager {\n typealias TouchId = ObjectIdentifier\n\n enum Constants {\n static let minFingerCount = 3\n static let maxFingerCount = 4\n }\n\n enum GestureState {\n case idle\n case inProgress\n case ended\n }\n\n static let shared = SwipeManager()\n\n private var swipeThreshold: Double { gesturesSettings.swipeThreshold }\n\n private var eventTap: CFMachPort?\n private var xTouchDistance: [TouchId: CGFloat] = [:]\n private var yTouchDistance: [TouchId: CGFloat] = [:]\n private var prevTouchPositions: [TouchId: NSPoint] = [:]\n private var lastTouchDate = Date.distantPast\n private var state: GestureState = .ended\n private var systemWakeUpObserver: AnyCancellable?\n\n private lazy var gesturesSettings = AppDependencies.shared.gesturesSettings\n private lazy var workspaceSettings = AppDependencies.shared.workspaceSettings\n private lazy var workspaceManager = AppDependencies.shared.workspaceManager\n private lazy var workspaceRepository = AppDependencies.shared.workspaceRepository\n private lazy var focusManager = AppDependencies.shared.focusManager\n\n func start() {\n guard eventTap == nil else {\n return Logger.log(\"SwipeManager is already started\")\n }\n\n eventTap = CGEvent.tapCreate(\n tap: .cghidEventTap,\n place: .headInsertEventTap,\n options: .defaultTap,\n eventsOfInterest: NSEvent.EventTypeMask.gesture.rawValue,\n callback: { proxy, type, cgEvent, userInfo in\n SwipeManager.shared.eventHandler(\n proxy: proxy,\n eventType: type,\n cgEvent: cgEvent,\n userInfo: userInfo\n )\n },\n userInfo: nil\n )\n\n guard let eventTap else {\n return Logger.log(\"SwipeManager couldn't create event tap\")\n }\n\n Logger.log(\"SwipeManager started\")\n\n let runLoopSource = CFMachPortCreateRunLoopSource(nil, eventTap, 0)\n CFRunLoopAddSource(\n CFRunLoopGetCurrent(),\n runLoopSource,\n CFRunLoopMode.commonModes\n )\n CGEvent.tapEnable(tap: eventTap, enable: true)\n\n observeSystemWakeUp()\n }\n\n func stop() {\n guard let eventTap else { return }\n\n CGEvent.tapEnable(tap: eventTap, enable: false)\n CFRunLoopRemoveSource(\n CFRunLoopGetCurrent(),\n CFMachPortCreateRunLoopSource(nil, eventTap, 0),\n CFRunLoopMode.commonModes\n )\n CFMachPortInvalidate(eventTap)\n self.eventTap = nil\n\n systemWakeUpObserver?.cancel()\n systemWakeUpObserver = nil\n\n Logger.log(\"SwipeManager stopped\")\n }\n\n func eventHandler(\n proxy: CGEventTapProxy,\n eventType: CGEventType,\n cgEvent: CGEvent,\n userInfo: UnsafeMutableRawPointer?\n ) -> Unmanaged? {\n if eventType.rawValue == NSEvent.EventType.gesture.rawValue,\n let nsEvent = NSEvent(cgEvent: cgEvent) {\n handleGesture(nsEvent)\n } else if eventType == .tapDisabledByUserInput || eventType == .tapDisabledByTimeout {\n Logger.log(\"SwipeManager tap disabled \\(eventType)\")\n if let eventTap {\n CGEvent.tapEnable(tap: eventTap, enable: true)\n }\n }\n\n return Unmanaged.passUnretained(cgEvent)\n }\n\n private func handleGesture(_ nsEvent: NSEvent) {\n let touches = nsEvent.allTouches()\n .filter { !$0.isResting && $0.phase != .stationary }\n\n if touches.count == 0 || Date().timeIntervalSince(lastTouchDate) > 0.8 {\n state = .idle\n }\n\n guard touches.count >= Constants.minFingerCount,\n gesturesSettings.isHorizontalSwipeSet || gesturesSettings.isVerticalSwipeSet\n else { return }\n\n if state == .idle {\n state = .inProgress\n xTouchDistance = [:]\n yTouchDistance = [:]\n prevTouchPositions = [:]\n }\n if state == .inProgress {\n lastTouchDate = Date()\n handleSwipe(touches: touches)\n }\n }\n\n private func handleSwipe(touches: Set) {\n updateSwipeDistance(touches: touches)\n handleHorizontalSwipe()\n handleVerticalSwipe()\n }\n\n private func handleHorizontalSwipe() {\n guard state == .inProgress else { return }\n guard gesturesSettings.isHorizontalSwipeSet else { return }\n\n let swipes = xTouchDistance.values\n let allMovedRight = swipes.allSatisfy { $0 > 0 }\n let allMovedLeft = swipes.allSatisfy { $0 < 0 }\n let minFingerContribution = swipeThreshold / (CGFloat(swipes.count) + 2.0)\n\n guard (Constants.minFingerCount...Constants.maxFingerCount).contains(swipes.count),\n swipes.allSatisfy({ abs($0) > minFingerContribution }),\n abs(swipes.reduce(0.0, +)) >= swipeThreshold,\n allMovedLeft || allMovedRight else { return }\n\n let action = if allMovedRight {\n swipes.count == 3 ? gesturesSettings.swipeRight3FingerAction : gesturesSettings.swipeRight4FingerAction\n } else if allMovedLeft {\n swipes.count == 3 ? gesturesSettings.swipeLeft3FingerAction : gesturesSettings.swipeLeft4FingerAction\n } else {\n GestureAction.none\n }\n\n state = .ended\n callAction(action)\n Logger.log(\"Horizontal swipe detected\")\n }\n\n private func handleVerticalSwipe() {\n guard state == .inProgress else { return }\n guard gesturesSettings.isVerticalSwipeSet else { return }\n\n let swipes = yTouchDistance.values\n let allMovedUp = swipes.allSatisfy { $0 > 0 }\n let allMovedDown = swipes.allSatisfy { $0 < 0 }\n let minFingerContribution = swipeThreshold / (CGFloat(swipes.count) + 2.0)\n\n guard (Constants.minFingerCount...Constants.maxFingerCount).contains(swipes.count),\n swipes.allSatisfy({ abs($0) > minFingerContribution }),\n abs(swipes.reduce(0.0, +)) >= swipeThreshold,\n allMovedUp || allMovedDown else { return }\n\n let action = if allMovedUp {\n swipes.count == 3 ? gesturesSettings.swipeUp3FingerAction : gesturesSettings.swipeUp4FingerAction\n } else if allMovedDown {\n swipes.count == 3 ? gesturesSettings.swipeDown3FingerAction : gesturesSettings.swipeDown4FingerAction\n } else {\n GestureAction.none\n }\n\n state = .ended\n callAction(action)\n Logger.log(\"Vertical swipe detected\")\n }\n\n private func updateSwipeDistance(touches: Set) {\n for touch in touches {\n let (distanceX, distanceY) = touchDistance(touch)\n\n if abs(distanceX) > abs(distanceY) {\n xTouchDistance[ObjectIdentifier(touch.identity), default: 0.0] += distanceX\n } else {\n yTouchDistance[ObjectIdentifier(touch.identity), default: 0.0] += distanceY\n }\n\n prevTouchPositions[ObjectIdentifier(touch.identity)] = touch.normalizedPosition\n }\n }\n\n private func touchDistance(_ touch: NSTouch) -> (CGFloat, CGFloat) {\n guard let prevPosition = prevTouchPositions[ObjectIdentifier(touch.identity)] else {\n return (0.0, 0.0)\n }\n\n return (\n touch.normalizedPosition.x - prevPosition.x,\n touch.normalizedPosition.y - prevPosition.y\n )\n }\n\n // swiftlint:disable:next cyclomatic_complexity\n private func callAction(_ action: GestureAction) {\n let skipEmpty = workspaceSettings.skipEmptyWorkspacesOnSwitch\n let loop = workspaceSettings.loopWorkspaces\n\n switch action {\n case .none: break\n case .toggleSpaceControl: SpaceControl.toggle()\n case .showSpaceControl: SpaceControl.show()\n case .hideSpaceControl: SpaceControl.hide()\n case .nextWorkspace: workspaceManager.activateWorkspace(next: true, skipEmpty: skipEmpty, loop: loop)\n case .previousWorkspace: workspaceManager.activateWorkspace(next: false, skipEmpty: skipEmpty, loop: loop)\n case .mostRecentWorkspace: workspaceManager.activateRecentWorkspace()\n case .focusLeft: focusManager.focusLeft()\n case .focusRight: focusManager.focusRight()\n case .focusUp: focusManager.focusUp()\n case .focusDown: focusManager.focusDown()\n case .focusNextApp: focusManager.nextWorkspaceApp()\n case .focusPreviousApp: focusManager.previousWorkspaceApp()\n case .focusNextWindow: focusManager.nextWorkspaceWindow()\n case .focusPreviousWindow: focusManager.previousWorkspaceWindow()\n case .activateWorkspace(let workspaceName):\n if let workspace = workspaceRepository.workspaces.first(where: { $0.name == workspaceName }) {\n workspaceManager.activateWorkspace(workspace, setFocus: true)\n }\n }\n }\n}\n\nextension SwipeManager {\n func restartAppIfNeeded() {\n guard gesturesSettings.restartAppOnWakeUp else { return }\n\n let task = Process()\n task.launchPath = \"/bin/sh\"\n task.arguments = [\"-c\", \"sleep 1; open '\\(Bundle.main.bundlePath)'\"]\n task.launch()\n\n NSApp.terminate(self)\n exit(0)\n }\n\n private func observeSystemWakeUp() {\n systemWakeUpObserver = NSWorkspace.shared.notificationCenter\n .publisher(for: NSWorkspace.didWakeNotification)\n .sink { [weak self] _ in self?.restartAppIfNeeded() }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/FocusManager/FocusedWindowTracker.swift", "//\n// FocusedWindowTracker.swift\n//\n// Created by Wojciech Kulik on 20/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Combine\n\nfinal class FocusedWindowTracker {\n private var cancellables = Set()\n\n private let workspaceRepository: WorkspaceRepository\n private let workspaceManager: WorkspaceManager\n private let settingsRepository: SettingsRepository\n private let pictureInPictureManager: PictureInPictureManager\n\n init(\n workspaceRepository: WorkspaceRepository,\n workspaceManager: WorkspaceManager,\n settingsRepository: SettingsRepository,\n pictureInPictureManager: PictureInPictureManager\n ) {\n self.workspaceRepository = workspaceRepository\n self.workspaceManager = workspaceManager\n self.settingsRepository = settingsRepository\n self.pictureInPictureManager = pictureInPictureManager\n }\n\n func startTracking() {\n NSWorkspace.shared.notificationCenter\n .publisher(for: NSWorkspace.didActivateApplicationNotification)\n .compactMap { $0.userInfo?[NSWorkspace.applicationUserInfoKey] as? NSRunningApplication }\n .removeDuplicates()\n .sink { [weak self] app in self?.activeApplicationChanged(app) }\n .store(in: &cancellables)\n }\n\n func stopTracking() {\n cancellables.removeAll()\n }\n\n private func activeApplicationChanged(_ app: NSRunningApplication) {\n guard settingsRepository.workspaceSettings.activeWorkspaceOnFocusChange else { return }\n\n let activeWorkspaces = workspaceManager.activeWorkspace.values\n\n // Skip if the workspace was activated recently\n guard Date().timeIntervalSince(workspaceManager.lastWorkspaceActivation) > 0.2 else { return }\n\n // Skip if the app is floating\n guard !settingsRepository.floatingAppsSettings.floatingApps.containsApp(app) else { return }\n\n // Find the workspace that contains the app.\n // The same app can be in multiple workspaces, the highest priority has the one\n // from the active workspace.\n guard let workspace = (activeWorkspaces + workspaceRepository.workspaces)\n .first(where: { $0.apps.containsApp(app) }) else { return }\n\n // Skip if the workspace is already active\n guard activeWorkspaces.count(where: { $0.id == workspace.id }) < workspace.displays.count else { return }\n\n // Skip if the focused window is in Picture in Picture mode\n guard !settingsRepository.workspaceSettings.enablePictureInPictureSupport ||\n !app.supportsPictureInPicture ||\n app.focusedWindow?.isPictureInPicture(bundleId: app.bundleIdentifier) != true else { return }\n\n let activate = { [self] in\n Logger.log(\"\")\n Logger.log(\"\")\n Logger.log(\"Activating workspace for app: \\(workspace.name)\")\n workspaceManager.updateLastFocusedApp(app.toMacApp, in: workspace)\n workspaceManager.activateWorkspace(workspace, setFocus: false)\n app.activate()\n\n // Restore the app if it was hidden\n if settingsRepository.workspaceSettings.enablePictureInPictureSupport, app.supportsPictureInPicture {\n pictureInPictureManager.restoreAppIfNeeded(app: app)\n }\n }\n\n if workspace.isDynamic, workspace.displays.isEmpty {\n DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(500)) {\n activate()\n }\n } else {\n activate()\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Workspaces/WorkspaceRepository.swift", "//\n// WorkspaceRepository.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Combine\nimport Foundation\n\nfinal class WorkspaceRepository: ObservableObject {\n @Published private(set) var workspaces: [Workspace] = []\n\n private let profilesRepository: ProfilesRepository\n\n init(profilesRepository: ProfilesRepository) {\n self.profilesRepository = profilesRepository\n self.workspaces = profilesRepository.selectedProfile.workspaces\n\n profilesRepository.onProfileChange = { [weak self] profile in\n self?.workspaces = profile.workspaces\n }\n }\n\n func addWorkspace(name: String) {\n let workspace = Workspace(\n id: .init(),\n name: name,\n display: NSScreen.main?.localizedName ?? \"\",\n activateShortcut: nil,\n assignAppShortcut: nil,\n apps: []\n )\n workspaces.append(workspace)\n notifyAboutChanges()\n }\n\n func addWorkspace(_ workspace: Workspace) {\n workspaces.append(workspace)\n notifyAboutChanges()\n }\n\n func updateWorkspace(_ workspace: Workspace) {\n guard let workspaceIndex = workspaces.firstIndex(where: { $0.id == workspace.id }) else { return }\n\n workspaces[workspaceIndex] = workspace\n notifyAboutChanges()\n AppDependencies.shared.hotKeysManager.refresh()\n }\n\n func deleteWorkspace(id: WorkspaceID) {\n workspaces.removeAll { $0.id == id }\n notifyAboutChanges()\n }\n\n func deleteWorkspaces(ids: Set) {\n workspaces.removeAll { ids.contains($0.id) }\n notifyAboutChanges()\n }\n\n func addApp(to workspaceId: WorkspaceID, app: MacApp) {\n guard let workspaceIndex = workspaces.firstIndex(where: { $0.id == workspaceId }) else { return }\n guard !workspaces[workspaceIndex].apps.contains(app) else { return }\n\n workspaces[workspaceIndex].apps.append(app)\n notifyAboutChanges()\n }\n\n func deleteApp(from workspaceId: WorkspaceID, app: MacApp, notify: Bool = true) {\n guard let workspaceIndex = workspaces.firstIndex(where: { $0.id == workspaceId }) else { return }\n\n if workspaces[workspaceIndex].appToFocus == app {\n workspaces[workspaceIndex].appToFocus = nil\n }\n\n workspaces[workspaceIndex].apps.removeAll { $0 == app }\n if notify { notifyAboutChanges() }\n }\n\n func deleteAppFromAllWorkspaces(app: MacApp) {\n for (index, var workspace) in workspaces.enumerated() {\n workspace.apps.removeAll { $0 == app }\n if workspace.appToFocus == app {\n workspace.appToFocus = nil\n }\n\n workspaces[index] = workspace\n }\n notifyAboutChanges()\n }\n\n func reorderWorkspaces(newOrder: [WorkspaceID]) {\n let map = newOrder.enumerated().reduce(into: [WorkspaceID: Int]()) { $0[$1.element] = $1.offset }\n workspaces = workspaces.sorted { map[$0.id] ?? 0 < map[$1.id] ?? 0 }\n notifyAboutChanges()\n }\n\n func moveApps(_ apps: [MacApp], from sourceWorkspaceId: WorkspaceID, to targetWorkspaceId: WorkspaceID) {\n guard let sourceWorkspaceIndex = workspaces.firstIndex(where: { $0.id == sourceWorkspaceId }),\n let targetWorkspaceIndex = workspaces.firstIndex(where: { $0.id == targetWorkspaceId }) else { return }\n\n if let appToFocus = workspaces[sourceWorkspaceIndex].appToFocus, apps.contains(appToFocus) {\n workspaces[sourceWorkspaceIndex].appToFocus = nil\n }\n\n let targetAppBundleIds = workspaces[targetWorkspaceIndex].apps.map(\\.bundleIdentifier).asSet\n let appsToAdd = apps.filter { !targetAppBundleIds.contains($0.bundleIdentifier) }\n\n workspaces[sourceWorkspaceIndex].apps.removeAll { apps.contains($0) }\n workspaces[targetWorkspaceIndex].apps.append(contentsOf: appsToAdd)\n\n notifyAboutChanges()\n NotificationCenter.default.post(name: .appsListChanged, object: nil)\n }\n\n private func notifyAboutChanges() {\n profilesRepository.updateWorkspaces(workspaces)\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/List/ListRunningAppsCommand.swift", "//\n// ListRunningAppsCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport ArgumentParser\nimport Foundation\n\nstruct ListRunningAppsCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"list-running-apps\",\n abstract: \"List running apps\"\n )\n\n @Flag(help: \"Include bundle id\")\n var withBundleId = false\n\n func run() throws {\n let apps = NSWorkspace.shared.runningApplications\n .filter { $0.activationPolicy == .regular }\n\n let result = Set(apps)\n .filter { $0.localizedName != nil }\n .map { (bundleId: $0.bundleIdentifier ?? \"-\", name: $0.localizedName ?? \"-\") }\n .sorted { $0.name.lowercased() < $1.name.lowercased() }\n .map { app in\n if withBundleId {\n return [app.name, app.bundleId].joined(separator: \",\")\n } else {\n return app.name\n }\n }\n .joined(separator: \"\\n\")\n print(result)\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Workspace/UpdateWorkspaceCommand.swift", "//\n// UpdateWorkspaceCommand.swift\n//\n// Created by Wojciech Kulik on 02/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport ArgumentParser\nimport Foundation\n\nstruct UpdateWorkspaceRequest: Codable {\n enum Display: Codable {\n case active\n case name(String)\n }\n\n let name: String?\n let display: Display?\n}\n\nstruct UpdateWorkspaceCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"update-workspace\",\n abstract: \"Update a workspace\"\n )\n\n @Option(help: \"The name of the workspace to update.\")\n var workspace: String?\n\n @Flag(help: \"Update active workspace.\")\n var activeWorkspace = false\n\n @Option(help: \"The name of the display to be assigned.\")\n var display: String?\n\n @Flag(help: \"Assign active display.\")\n var activeDisplay = false\n\n func run() throws {\n if let display {\n sendCommand(.updateWorkspace(.init(name: workspace, display: .name(display))))\n } else if activeDisplay {\n sendCommand(.updateWorkspace(.init(name: workspace, display: .active)))\n } else {\n throw CommandError.operationFailed(\"Invalid command\")\n }\n\n runWithTimeout()\n }\n\n func validate() throws {\n if workspace != nil, activeWorkspace {\n throw CommandError.operationFailed(\"You cannot provide both a workspace name and use the --active-workspace flag\")\n }\n\n if display != nil, activeDisplay {\n throw CommandError.operationFailed(\"You cannot provide both a display name and use the --active-display flag\")\n }\n\n if workspace == nil, !activeWorkspace {\n throw CommandError.operationFailed(\"You must provide either a workspace name or use the --active-workspace flag\")\n }\n\n if display == nil, !activeDisplay {\n throw CommandError.operationFailed(\"You must provide either a display name or use the --active-display flag\")\n }\n\n if let display, !NSScreen.screens.contains(where: { $0.localizedName == display }) {\n throw CommandError.operationFailed(\"Display \\\"\\(display)\\\" not found\")\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Profiles/ProfilesRepository.swift", "//\n// ProfilesRepository.swift\n//\n// Created by Wojciech Kulik on 26/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nfinal class ProfilesRepository: ObservableObject {\n @Published var profiles: [Profile] = [.default]\n @Published var selectedProfile: Profile = .default {\n didSet {\n guard shouldTrackProfileChange else { return }\n guard oldValue.id != selectedProfile.id else { return }\n setProfile(id: selectedProfile.id)\n }\n }\n\n var onProfileChange: ((Profile) -> ())?\n\n private var selectedProfileId: ProfileId? {\n get {\n UserDefaults.standard.string(forKey: AppConstants.UserDefaultsKey.selectedProfileId)\n .flatMap { UUID(uuidString: $0) }\n }\n set {\n if let newValue {\n UserDefaults.standard.set(newValue.uuidString, forKey: AppConstants.UserDefaultsKey.selectedProfileId)\n } else {\n UserDefaults.standard.removeObject(forKey: AppConstants.UserDefaultsKey.selectedProfileId)\n }\n }\n }\n\n private var shouldTrackProfileChange = true\n\n init() {\n loadFromDisk()\n }\n\n private func loadFromDisk() {\n shouldTrackProfileChange = false\n defer { shouldTrackProfileChange = true }\n\n guard let config = try? ConfigSerializer.deserialize(ProfilesConfig.self, filename: \"profiles\"),\n !config.profiles.isEmpty else {\n return createDefaultProfile()\n }\n\n let migrated = migrateOldConfigIfNeeded()\n profiles = config.profiles\n\n let selectedProfileId = selectedProfileId\n selectedProfile = profiles.first { $0.id == selectedProfileId } ?? profiles.first ?? .default\n\n if migrated { saveToDisk() }\n }\n\n private func migrateOldConfigIfNeeded() -> Bool {\n struct OldProfilesConfig: Codable {\n let selectedProfileId: ProfileId?\n }\n\n if let oldConfig = try? ConfigSerializer.deserialize(OldProfilesConfig.self, filename: \"profiles\"),\n let profileId = oldConfig.selectedProfileId {\n selectedProfileId = profileId\n Logger.log(\"Migrated old profile config to new format. Profile ID: \\(profileId)\")\n\n return true\n }\n\n return false\n }\n\n private func createDefaultProfile() {\n profiles = [.init(\n id: UUID(),\n name: \"Default\",\n workspaces: []\n )]\n selectedProfile = profiles[0]\n saveToDisk()\n }\n\n private func setProfile(id: ProfileId) {\n guard let profile = profiles.first(where: { $0.id == id }) else { return }\n\n saveToDisk()\n\n onProfileChange?(profile)\n NotificationCenter.default.post(name: .profileChanged, object: nil)\n Integrations.runOnProfileChangeIfNeeded(profile: profile.name)\n }\n}\n\nextension ProfilesRepository {\n func createProfile(name: String, keepWorkspaces: Bool) {\n var workspaces = [Workspace]()\n\n if keepWorkspaces {\n workspaces = selectedProfile.workspaces.map { workspace in\n var newWorkspace = workspace\n newWorkspace.id = UUID()\n return newWorkspace\n }\n }\n\n let newProfile = Profile(id: UUID(), name: name, workspaces: workspaces)\n profiles.append(newProfile)\n profiles.sort { $0.name < $1.name }\n\n saveToDisk()\n }\n\n func renameProfile(id: ProfileId, to newName: String) {\n guard let index = profiles.firstIndex(where: { $0.id == id }) else { return }\n\n profiles[index].name = newName\n profiles.sort { $0.name < $1.name }\n\n shouldTrackProfileChange = false\n selectedProfile = profiles.first { $0.id == id } ?? .default\n shouldTrackProfileChange = true\n\n saveToDisk()\n }\n\n func deleteProfile(id: ProfileId) {\n guard profiles.count > 1 else { return }\n\n profiles.removeAll { $0.id == id }\n\n if selectedProfile.id == id {\n shouldTrackProfileChange = false\n selectedProfile = profiles.first ?? .default\n shouldTrackProfileChange = true\n\n saveToDisk()\n setProfile(id: selectedProfile.id)\n } else {\n saveToDisk()\n }\n }\n\n func updateWorkspaces(_ workspaces: [Workspace]) {\n guard let profileIndex = profiles.firstIndex(where: { $0.id == selectedProfile.id }) else { return }\n\n profiles[profileIndex].workspaces = workspaces\n selectedProfile = profiles[profileIndex]\n saveToDisk()\n }\n\n func saveToDisk() {\n let config = ProfilesConfig(profiles: profiles)\n try? ConfigSerializer.serialize(filename: \"profiles\", config)\n\n selectedProfileId = selectedProfile.id\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Profiles/ProfilesSettingsViewModel.swift", "//\n// ProfilesSettingsViewModel.swift\n//\n// Created by Wojciech Kulik on 26/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nfinal class ProfilesSettingsViewModel: ObservableObject {\n enum Action {\n case createProfile\n case renameProfile(ProfileId)\n case deleteProfile(ProfileId)\n }\n\n @Published var isInputDialogPresented = false\n @Published var isDeleteConfirmationPresented = false\n @Published var isCopyChoicePresented = false\n @Published var profileToDelete = \"\"\n @Published var userInput = \"\"\n\n var hideDeleteButton: Bool { profilesRepository.profiles.count == 1 }\n\n private var action: Action?\n\n private let profilesRepository = AppDependencies.shared.profilesRepository\n\n func createNewProfile() {\n action = .createProfile\n userInput = \"\"\n isInputDialogPresented = true\n }\n\n func createNewProfile(copyWorkspaces: Bool) {\n let input = userInput.trimmingCharacters(in: .whitespacesAndNewlines)\n guard !input.isEmpty else { return }\n\n profilesRepository.createProfile(name: input, keepWorkspaces: copyWorkspaces)\n }\n\n func renameProfile(_ profile: Profile) {\n action = .renameProfile(profile.id)\n userInput = profile.name\n isInputDialogPresented = true\n }\n\n func deleteProfile(_ profile: Profile) {\n action = .deleteProfile(profile.id)\n profileToDelete = profile.name\n isDeleteConfirmationPresented = true\n }\n\n func inputDialogDismissed() {\n let input = userInput.trimmingCharacters(in: .whitespacesAndNewlines)\n guard let action, !input.isEmpty else { return }\n\n switch action {\n case .createProfile:\n isCopyChoicePresented = true\n case .renameProfile(let id):\n profilesRepository.renameProfile(id: id, to: input)\n case .deleteProfile:\n break\n }\n }\n\n func deleteConfirmed() {\n guard let action else { return }\n\n switch action {\n case .deleteProfile(let id):\n profilesRepository.deleteProfile(id: id)\n default:\n break\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/MainScreen/WorkspaceCell.swift", "//\n// WorkspaceCell.swift\n//\n// Created by Wojciech Kulik on 20/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\nimport UniformTypeIdentifiers\n\nstruct WorkspaceCell: View {\n @State var isTargeted = false\n @Binding var selectedApps: Set\n\n let workspaceManager: WorkspaceManager = AppDependencies.shared.workspaceManager\n let workspaceRepository: WorkspaceRepository = AppDependencies.shared.workspaceRepository\n\n let workspace: Workspace\n\n var body: some View {\n HStack {\n Image(systemName: workspace.symbolIconName ?? .defaultIconSymbol)\n .resizable()\n .scaledToFit()\n .frame(width: 15, height: 15)\n .foregroundStyle(Color.workspaceIcon)\n\n Text(workspace.name)\n .lineLimit(1)\n .foregroundColor(\n isTargeted || workspace.apps.contains(where: \\.bundleIdentifier.isEmpty)\n ? .errorRed\n : .primary\n )\n Spacer()\n }\n .contentShape(Rectangle())\n .dropDestination(for: MacAppWithWorkspace.self) { apps, _ in\n guard let sourceWorkspaceId = apps.first?.workspaceId else { return false }\n\n workspaceRepository.moveApps(\n apps.map(\\.app),\n from: sourceWorkspaceId,\n to: workspace.id\n )\n selectedApps = []\n\n workspaceManager.activateWorkspaceIfActive(sourceWorkspaceId)\n workspaceManager.activateWorkspaceIfActive(workspace.id)\n\n return true\n } isTargeted: {\n isTargeted = $0\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Gestures/GestureAction.swift", "//\n// GestureAction.swift\n//\n// Created by Wojciech Kulik on 30/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nenum GestureAction {\n case none\n case toggleSpaceControl\n case showSpaceControl\n case hideSpaceControl\n case nextWorkspace\n case previousWorkspace\n case mostRecentWorkspace\n case focusLeft\n case focusRight\n case focusUp\n case focusDown\n case focusNextApp\n case focusPreviousApp\n case focusNextWindow\n case focusPreviousWindow\n case activateWorkspace(String)\n}\n\nextension GestureAction: CaseIterable, Equatable, Hashable, Identifiable {\n var id: String { description }\n\n var description: String {\n switch self {\n case .none: return \"None\"\n case .toggleSpaceControl: return \"Toggle Space Control\"\n case .showSpaceControl: return \"Show Space Control\"\n case .hideSpaceControl: return \"Hide Space Control\"\n case .nextWorkspace: return \"Next Workspace\"\n case .previousWorkspace: return \"Previous Workspace\"\n case .mostRecentWorkspace: return \"Most Recent Workspace\"\n case .focusLeft: return \"Focus Left\"\n case .focusRight: return \"Focus Right\"\n case .focusUp: return \"Focus Up\"\n case .focusDown: return \"Focus Down\"\n case .focusNextApp: return \"Focus Next App\"\n case .focusPreviousApp: return \"Focus Previous App\"\n case .focusNextWindow: return \"Focus Next Window\"\n case .focusPreviousWindow: return \"Focus Previous Window\"\n case .activateWorkspace(let workspaceName):\n return \"Activate Workspace: \\(workspaceName)\"\n }\n }\n\n static var allCases: [GestureAction] {\n let workspaces = AppDependencies.shared.workspaceRepository.workspaces\n return allCasesWithoutWorkspaces + workspaces.map { .activateWorkspace($0.name) }\n }\n\n static var allCasesWithoutWorkspaces: [GestureAction] {\n [\n .none,\n .toggleSpaceControl,\n .showSpaceControl,\n .hideSpaceControl,\n .nextWorkspace,\n .previousWorkspace,\n .mostRecentWorkspace,\n .focusLeft,\n .focusRight,\n .focusUp,\n .focusDown,\n .focusNextApp,\n .focusPreviousApp,\n .focusNextWindow,\n .focusPreviousWindow\n ]\n }\n}\n\nextension GestureAction: Codable {\n init(from decoder: Decoder) throws {\n let container = try decoder.singleValueContainer()\n let value = try container.decode(String.self)\n\n if value.hasPrefix(\"activateWorkspace:\") {\n let workspaceName = String(value.dropFirst(\"activateWorkspace:\".count))\n self = .activateWorkspace(workspaceName)\n } else if let action = GestureAction.allCasesWithoutWorkspaces.first(where: { $0.normalizedDescription == value }) {\n self = action\n } else {\n self = .none\n }\n }\n\n func encode(to encoder: Encoder) throws {\n var container = encoder.singleValueContainer()\n try container.encode(normalizedDescription)\n }\n\n private var normalizedDescription: String {\n if case .activateWorkspace(let workspaceName) = self {\n return \"activateWorkspace:\\(workspaceName)\"\n }\n\n let result = String(description.first?.lowercased() ?? \"\") + description.dropFirst()\n return result.replacingOccurrences(of: \" \", with: \"\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/HotKeys/HotKeysManager.swift", "//\n// HotKeysManager.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Combine\nimport ShortcutRecorder\n\nfinal class HotKeysManager {\n private(set) var allHotKeys: [(scope: String, hotKey: AppHotKey)] = []\n\n private var cancellables = Set()\n\n private let hotKeysMonitor: HotKeysMonitorProtocol\n private let workspaceHotKeys: WorkspaceHotKeys\n private let floatingAppsHotKeys: FloatingAppsHotKeys\n private let focusManager: FocusManager\n private let settingsRepository: SettingsRepository\n\n init(\n hotKeysMonitor: HotKeysMonitorProtocol,\n workspaceHotKeys: WorkspaceHotKeys,\n floatingAppsHotKeys: FloatingAppsHotKeys,\n focusManager: FocusManager,\n settingsRepository: SettingsRepository\n ) {\n self.hotKeysMonitor = hotKeysMonitor\n self.workspaceHotKeys = workspaceHotKeys\n self.floatingAppsHotKeys = floatingAppsHotKeys\n self.focusManager = focusManager\n self.settingsRepository = settingsRepository\n\n observe()\n }\n\n func refresh() {\n disableAll()\n enableAll()\n }\n\n // swiftlint:disable:next function_body_length\n func enableAll() {\n allHotKeys.removeAll()\n let addShortcut = { (title: String, shortcut: Shortcut) in\n self.allHotKeys.append((title, .init(\n keyCode: shortcut.keyCode.rawValue,\n modifiers: shortcut.modifierFlags.rawValue\n )))\n }\n\n // Workspaces\n for (shortcut, action) in workspaceHotKeys.getHotKeys().toShortcutPairs() {\n let action = ShortcutAction(shortcut: shortcut) { _ in\n action()\n return true\n }\n\n hotKeysMonitor.addAction(action, forKeyEvent: .down)\n addShortcut(\"Workspace\", shortcut)\n }\n\n // Floating Apps\n for (shortcut, action) in floatingAppsHotKeys.getHotKeys().toShortcutPairs() {\n let action = ShortcutAction(shortcut: shortcut) { _ in\n action()\n return true\n }\n\n hotKeysMonitor.addAction(action, forKeyEvent: .down)\n addShortcut(\"Floating Apps\", shortcut)\n }\n\n // Focus Manager\n for (shortcut, action) in focusManager.getHotKeys().toShortcutPairs() {\n let action = ShortcutAction(shortcut: shortcut) { _ in\n action()\n return true\n }\n hotKeysMonitor.addAction(action, forKeyEvent: .down)\n addShortcut(\"Focus Manager\", shortcut)\n }\n\n // General\n if let showHotKey = settingsRepository.generalSettings.showFlashSpace?.toShortcut() {\n let action = ShortcutAction(shortcut: showHotKey) { _ in\n guard !SpaceControl.isVisible else { return true }\n\n let visibleAppWindows = NSApp.windows\n .filter(\\.isVisible)\n .filter { $0.identifier?.rawValue == \"main\" || $0.identifier?.rawValue == \"settings\" }\n\n if visibleAppWindows.isEmpty {\n NotificationCenter.default.post(name: .openMainWindow, object: nil)\n } else {\n visibleAppWindows.forEach { $0.close() }\n }\n return true\n }\n hotKeysMonitor.addAction(action, forKeyEvent: .down)\n addShortcut(\"General\", showHotKey)\n }\n\n // SpaceControl\n if let (hotKey, action) = SpaceControl.getHotKey(), let shortcut = hotKey.toShortcut() {\n let action = ShortcutAction(shortcut: shortcut) { _ in\n action()\n return true\n }\n hotKeysMonitor.addAction(action, forKeyEvent: .down)\n addShortcut(\"Space Control\", shortcut)\n }\n }\n\n func disableAll() {\n hotKeysMonitor.removeAllActions()\n }\n\n private func observe() {\n NotificationCenter.default\n .publisher(for: .profileChanged)\n .sink { [weak self] _ in self?.refresh() }\n .store(in: &cancellables)\n\n DistributedNotificationCenter.default()\n .publisher(for: .init(rawValue: kTISNotifySelectedKeyboardInputSourceChanged as String))\n .sink { [weak self] _ in\n KeyCodesMap.refresh()\n self?.disableAll()\n self?.enableAll()\n }\n .store(in: &cancellables)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/SpaceControl/WorkspaceScreenshotManager.swift", "//\n// WorkspaceScreenshotManager.swift\n//\n// Created by Wojciech Kulik on 11/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Combine\nimport CoreGraphics\nimport ScreenCaptureKit\nimport SwiftUI\n\nfinal class WorkspaceScreenshotManager {\n typealias ImageData = Data\n\n struct ScreenshotKey: Hashable {\n let displayName: DisplayName\n let workspaceID: WorkspaceID\n }\n\n private(set) var screenshots: [ScreenshotKey: ImageData] = [:]\n private var cancellables = Set()\n\n private let lock = NSLock()\n\n init() {\n observe()\n }\n\n func captureWorkspace(_ workspace: Workspace, displayName: DisplayName) async {\n let shouldCapture = await MainActor.run {\n !SpaceControl.isVisible &&\n SpaceControl.isEnabled &&\n PermissionsManager.shared.checkForScreenRecordingPermissions()\n }\n\n guard shouldCapture else { return }\n\n do {\n let availableContent = try await SCShareableContent.excludingDesktopWindows(false, onScreenWindowsOnly: false)\n let display = await MainActor.run {\n availableContent.displays.first { $0.frame.getDisplay() == displayName }\n }\n\n guard let display else { return }\n\n let filter = SCContentFilter(display: display, excludingWindows: [])\n let config = SCStreamConfiguration()\n config.captureResolution = .best\n config.width = Int(display.frame.width)\n config.height = Int(display.frame.height)\n config.showsCursor = false\n\n let screenshot = try await SCScreenshotManager.captureSampleBuffer(\n contentFilter: filter,\n configuration: config\n )\n\n if let image = imageFromSampleBuffer(screenshot) {\n let key = ScreenshotKey(\n displayName: displayName,\n workspaceID: workspace.id\n )\n saveScreenshot(image, workspace: workspace, key: key)\n }\n } catch {\n Logger.log(error)\n }\n }\n\n private func imageFromSampleBuffer(_ buffer: CMSampleBuffer) -> NSImage? {\n guard let imageBuffer = CMSampleBufferGetImageBuffer(buffer) else { return nil }\n\n let ciImage = CIImage(cvImageBuffer: imageBuffer)\n let representation = NSCIImageRep(ciImage: ciImage)\n let nsImage = NSImage(size: representation.size)\n nsImage.addRepresentation(representation)\n\n return nsImage\n }\n\n private func saveScreenshot(_ image: NSImage, workspace: Workspace, key: ScreenshotKey) {\n let newSize = CGSize(\n width: 1400.0,\n height: (1400.0 / image.size.width) * image.size.height\n )\n let newImage = NSImage(size: newSize)\n let rect = NSRect(origin: .zero, size: newSize)\n\n newImage.lockFocus()\n image.draw(in: rect)\n newImage.unlockFocus()\n\n guard let resizedData = newImage.tiffRepresentation,\n let imageRepresentation = NSBitmapImageRep(data: resizedData),\n let jpegData = imageRepresentation.representation(using: .jpeg, properties: [:])\n else { return }\n\n lock.lock()\n screenshots[key] = jpegData\n lock.unlock()\n }\n\n private func observe() {\n NotificationCenter.default\n .publisher(for: .workspaceTransitionFinished)\n .compactMap { $0.object as? Workspace }\n .sink { [weak self] workspace in\n for display in workspace.displays {\n Task.detached { [weak self] in\n await self?.captureWorkspace(workspace, displayName: display)\n }\n }\n }\n .store(in: &cancellables)\n\n NotificationCenter.default\n .publisher(for: .profileChanged)\n .sink { [weak self] _ in\n self?.screenshots = [:]\n }\n .store(in: &cancellables)\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/NSRunningApplication.swift", "//\n// NSRunningApplication.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension NSRunningApplication {\n var toMacApp: MacApp { .init(app: self) }\n var iconPath: String? { bundleURL?.iconPath }\n}\n\nextension [NSRunningApplication] {\n func find(_ app: MacApp?) -> NSRunningApplication? {\n guard let app else { return nil }\n\n return first { $0.bundleIdentifier == app.bundleIdentifier }\n }\n\n func findFirstMatch(with apps: [MacApp]) -> NSRunningApplication? {\n let bundleIdentifiers = apps.map(\\.bundleIdentifier).asSet\n\n return first { bundleIdentifiers.contains($0.bundleIdentifier ?? \"\") }\n }\n\n func excludeFloatingAppsOnDifferentScreen() -> [NSRunningApplication] {\n let activeWorkspace = AppDependencies.shared.workspaceManager.activeWorkspace[NSScreen.main?.localizedName ?? \"\"]\n let floatingApps = AppDependencies.shared.floatingAppsSettings.floatingApps\n\n guard let activeWorkspace else { return self }\n\n return filter { app in\n !floatingApps.containsApp(app) || app.isOnAnyDisplay(activeWorkspace.displays)\n }\n }\n\n func regularVisibleApps(onDisplays displays: Set, excluding apps: [MacApp]) -> [NSRunningApplication] {\n filter { app in\n app.activationPolicy == .regular &&\n !app.isHidden &&\n !apps.containsApp(app) &&\n app.isOnAnyDisplay(displays)\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/SpaceControl/SpaceControl.swift", "//\n// SpaceControl.swift\n//\n// Created by Wojciech Kulik on 11/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport SwiftUI\n\nenum SpaceControl {\n static var isEnabled: Bool { settings.enableSpaceControl }\n static var isVisible: Bool { window != nil }\n static var window: NSWindow?\n\n private static var settings: SpaceControlSettings { AppDependencies.shared.spaceControlSettings }\n private static var focusedAppBeforeShow: NSRunningApplication?\n\n static func getHotKey() -> (AppHotKey, () -> ())? {\n guard isEnabled else { return nil }\n\n if let spaceControlHotKey = settings.showSpaceControl {\n return (spaceControlHotKey, toggle)\n }\n\n return nil\n }\n\n static func toggle() {\n if isVisible {\n hide(restoreFocus: true)\n } else {\n show()\n }\n }\n\n static func hide(restoreFocus: Bool = false) {\n window?.orderOut(nil)\n window = nil\n\n if restoreFocus {\n focusedAppBeforeShow?.activate()\n focusedAppBeforeShow = nil\n }\n }\n\n static func show() {\n guard validate() else { return }\n\n PermissionsManager.shared.askForScreenRecordingPermissions()\n\n if Self.window != nil { hide() }\n\n let contentView = NSHostingView(\n rootView: SpaceControlView()\n )\n\n // contentRect is in screen coordinates where (0,0) is bottom-left corner\n // and it is relative to the main screen.\n let window = SpaceControlWindow(\n contentRect: NSScreen.main!.frame,\n styleMask: [.borderless],\n backing: .buffered,\n defer: false\n )\n window.isOpaque = false\n window.backgroundColor = .clear\n window.level = .screenSaver\n window.delegate = window\n Self.window = window\n\n let animations = settings.enableSpaceControlAnimations\n\n window.contentView = contentView.addVisualEffect(material: .fullScreenUI)\n window.alphaValue = animations ? 0 : 1\n\n focusedAppBeforeShow = NSWorkspace.shared.frontmostApplication\n NSApp.activate(ignoringOtherApps: true)\n window.orderFrontRegardless()\n window.makeKeyAndOrderFront(nil)\n\n if animations {\n window.animator().alphaValue = 1\n }\n }\n\n private static func validate() -> Bool {\n let workspaces = AppDependencies.shared.workspaceRepository.workspaces\n let nonEmptyWorkspaces = workspaces\n .filter { !settings.spaceControlCurrentDisplayWorkspaces || $0.isOnTheCurrentScreen }\n\n if nonEmptyWorkspaces.count < 2 {\n Alert.showOkAlert(title: \"Space Control\", message: \"You need at least 2 workspaces to use Space Control.\")\n return false\n }\n\n return true\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Open/OpenAppCommand.swift", "//\n// OpenAppCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport ArgumentParser\nimport Foundation\n\nstruct OpenAppCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"open\",\n abstract: \"Open FlashSpace\"\n )\n\n func run() throws {\n let url = NSWorkspace.shared.urlForApplication(withBundleIdentifier: \"pl.wojciechkulik.FlashSpace.dev\")\n ?? NSWorkspace.shared.urlForApplication(withBundleIdentifier: \"pl.wojciechkulik.FlashSpace\")\n\n if let url {\n let config = NSWorkspace.OpenConfiguration()\n config.activates = true\n NSWorkspace.shared.openApplication(at: url, configuration: config) { _, error in\n if let error {\n Self.exit(withError: CommandError.operationFailed(\"Failed to open FlashSpace: \\(error.localizedDescription)\"))\n } else {\n Self.exit()\n }\n }\n runWithTimeout()\n } else {\n throw CommandError.operationFailed(\"FlashSpace is not installed.\")\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Workspaces/WorkspaceTransitionManager.swift", "//\n// WorkspaceTransitionManager.swift\n//\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n// Contribution by Sergio Patino - https://github.com/sergiopatino\n//\n\nimport AppKit\n\nfinal class WorkspaceTransitionManager {\n private var windows: [NSWindow] = []\n private let settings: WorkspaceSettings\n\n init(workspaceSettings: WorkspaceSettings) {\n self.settings = workspaceSettings\n }\n\n func showTransitionIfNeeded(for workspace: Workspace, on displays: Set) {\n guard settings.enableWorkspaceTransitions else {\n // Small delay to allow workspace to be activated\n DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {\n NotificationCenter.default.post(name: .workspaceTransitionFinished, object: workspace)\n }\n return\n }\n guard windows.isEmpty, !SpaceControl.isVisible else { return }\n\n let screens = NSScreen.screens.filter { displays.contains($0.localizedName) }\n\n guard !screens.isEmpty else { return }\n\n for screen in screens {\n let window = NSWindow(\n contentRect: screen.frame,\n styleMask: [.borderless],\n backing: .buffered,\n defer: false\n )\n window.isOpaque = false\n window.backgroundColor = .clear\n window.level = .screenSaver\n window.alphaValue = CGFloat(settings.workspaceTransitionDimming)\n window.contentView?.wantsLayer = true\n window.contentView?.layer?.backgroundColor = NSColor.black.cgColor\n\n window.orderFrontRegardless()\n windows.append(window)\n }\n\n DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { [weak self] in\n self?.hideTransition(for: workspace)\n }\n }\n\n private func hideTransition(for workspace: Workspace) {\n guard !windows.isEmpty else { return }\n\n NSAnimationContext.runAnimationGroup({ [weak self] context in\n context.duration = self?.settings.workspaceTransitionDuration ?? 0.3\n context.timingFunction = CAMediaTimingFunction(name: .easeIn)\n self?.windows.forEach { window in\n window.animator().alphaValue = 0.0\n }\n }, completionHandler: { [weak self] in\n self?.windows.forEach { window in\n window.orderOut(nil)\n }\n self?.windows.removeAll()\n NotificationCenter.default.post(name: .workspaceTransitionFinished, object: workspace)\n })\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/SpaceControl/Views/SpaceControlWindow.swift", "//\n// SpaceControlWindow.swift\n//\n// Created by Wojciech Kulik on 11/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport SwiftUI\n\nfinal class SpaceControlWindow: NSWindow, NSWindowDelegate {\n override var canBecomeKey: Bool { true }\n\n override func keyDown(with event: NSEvent) {\n if event.keyCode == KeyCodesMap[\"escape\"] {\n SpaceControl.hide(restoreFocus: true)\n return\n } else if [\"up\", \"down\", \"right\", \"left\"]\n .compactMap({ KeyCodesMap[$0] })\n .contains(event.keyCode) {\n NotificationCenter.default.post(name: .spaceControlArrowDown, object: event.keyCode)\n return\n }\n\n let settings = AppDependencies.shared.spaceControlSettings\n let workspaceManager = AppDependencies.shared.workspaceManager\n var workspaces = AppDependencies.shared.workspaceRepository.workspaces\n\n if settings.spaceControlCurrentDisplayWorkspaces {\n workspaces = workspaces.filter(\\.isOnTheCurrentScreen)\n }\n\n var digit = Int(event.charactersIgnoringModifiers ?? \"\") ?? -1\n if (0...9).contains(digit) {\n SpaceControl.hide()\n digit = digit == 0 ? 10 : digit\n\n if let workspace = workspaces[safe: digit - 1] {\n workspaceManager.activateWorkspace(workspace, setFocus: true)\n }\n return\n }\n\n super.keyDown(with: event)\n }\n\n override func resignFirstResponder() -> Bool {\n SpaceControl.hide()\n return super.resignFirstResponder()\n }\n\n func windowDidResignKey(_ notification: Notification) {\n SpaceControl.hide()\n }\n}\n"], ["/FlashSpace/FlashSpace/Accessibility/NSRunningApplication+Properties.swift", "//\n// NSRunningApplication+Properties.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension NSRunningApplication {\n var frame: CGRect? { mainWindow?.frame }\n var isMinimized: Bool { mainWindow?.isMinimized == true }\n\n var display: DisplayName? {\n // HACK: Workaround for Orion Browser which puts\n // the main window on the main screen with size (1,1)\n if isOrion {\n allWindows\n .first { $0.frame.width > 10 && $0.frame.height > 10 }?\n .frame\n .getDisplay()\n } else {\n frame?.getDisplay()\n }\n }\n\n var allDisplays: Set {\n allWindows\n .compactMap { $0.frame.getDisplay() }\n .asSet\n }\n\n var mainWindow: AXUIElement? {\n // HACK: Python app with running pygame module is causing\n // huge lags when other apps attempt to access its window\n // through the accessibility API.\n // A workaround is to simply skip this app.\n guard !isPython else { return nil }\n\n let appElement = AXUIElementCreateApplication(processIdentifier)\n return appElement.getAttribute(.mainWindow)\n }\n\n var focusedWindow: AXUIElement? {\n guard !isPython else { return nil }\n\n let appElement = AXUIElementCreateApplication(processIdentifier)\n return appElement.getAttribute(.focusedWindow)\n }\n\n var allWindows: [(window: AXUIElement, frame: CGRect)] {\n guard !isPython else { return [] }\n\n let appElement = AXUIElementCreateApplication(processIdentifier)\n let windows: [AXUIElement]? = appElement.getAttribute(.windows)\n\n return windows?\n .filter { $0.role == \"AXWindow\" }\n .compactMap { window in window.frame.flatMap { (window, $0) } }\n ?? []\n }\n\n func isOnAnyDisplay(_ displays: Set) -> Bool {\n !allDisplays.isDisjoint(with: displays)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Config/ConfigSerializer.swift", "//\n// ConfigSerializer.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\nimport TOMLKit\nimport Yams\n\nenum ConfigSerializer {\n static let configDirectory = FileManager.default\n .homeDirectoryForCurrentUser\n .appendingPathComponent(\".config/flashspace\")\n\n private(set) static var format: ConfigFormat = detectFormat()\n\n static func serialize(filename: String, _ value: some Encodable) throws {\n let url = getUrl(for: filename)\n let data = try encoder.encode(value)\n try? url.createIntermediateDirectories()\n try data.write(to: url)\n }\n\n static func deserialize(_ type: T.Type, filename: String) throws -> T? where T: Decodable {\n let url = getUrl(for: filename)\n\n guard FileManager.default.fileExists(atPath: url.path) else { return nil }\n\n do {\n let data = try Data(contentsOf: url)\n\n return try decoder.decode(type, from: data)\n } catch {\n Logger.log(\"Failed to deserialize \\(filename): \\(error)\")\n throw error\n }\n }\n\n static func convert(to: ConfigFormat) throws {\n guard format != to else { return }\n\n let settingsUrl = getUrl(for: \"settings\", ext: format.rawValue)\n let profilesUrl = getUrl(for: \"profiles\", ext: format.rawValue)\n let timestamp = Int(Date().timeIntervalSince1970)\n\n try? FileManager.default.moveItem(\n at: settingsUrl,\n to: configDirectory.appendingPathComponent(\"settings-backup-\\(timestamp).\\(format.rawValue)\")\n )\n try? FileManager.default.moveItem(\n at: profilesUrl,\n to: configDirectory.appendingPathComponent(\"profiles-backup-\\(timestamp).\\(format.rawValue)\")\n )\n\n format = to\n AppDependencies.shared.settingsRepository.saveToDisk()\n AppDependencies.shared.profilesRepository.saveToDisk()\n\n Logger.log(\"Converted config format to \\(to.displayName)\")\n }\n}\n\nprivate extension ConfigSerializer {\n static var encoder: ConfigEncoder {\n switch format {\n case .json: return jsonEncoder\n case .toml: return tomlEncoder\n case .yaml: return yamlEncoder\n }\n }\n\n static var decoder: ConfigDecoder {\n switch format {\n case .json: return jsonDecoder\n case .toml: return tomlDecoder\n case .yaml: return yamlDecoder\n }\n }\n\n static let jsonDecoder = JSONDecoder()\n static let jsonEncoder = {\n let encoder = JSONEncoder()\n encoder.outputFormatting = [\n .prettyPrinted,\n .withoutEscapingSlashes,\n .sortedKeys\n ]\n return encoder\n }()\n\n static let tomlDecoder = TOMLDecoder()\n static let tomlEncoder = TOMLEncoder()\n static let yamlEncoder = YAMLEncoder()\n static let yamlDecoder = YAMLDecoder()\n\n static func getUrl(for filename: String, ext: String? = nil) -> URL {\n configDirectory\n .appendingPathComponent(filename)\n .appendingPathExtension(ext ?? ConfigSerializer.format.extensionName)\n }\n\n static func detectFormat() -> ConfigFormat {\n for format in ConfigFormat.allCases {\n let url = getUrl(for: \"profiles\", ext: format.rawValue)\n if FileManager.default.fileExists(atPath: url.path) {\n Logger.log(\"Detected config format \\(format.displayName) at \\(url.path)\")\n return format\n }\n }\n\n return .json\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Workspaces/Models/MacApp.swift", "//\n// MacApp.swift\n//\n// Created by Wojciech Kulik on 06/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\ntypealias BundleId = String\n\nstruct MacApp: Codable, Hashable, Equatable {\n var name: String\n var bundleIdentifier: BundleId\n var iconPath: String?\n\n init(\n name: String,\n bundleIdentifier: BundleId,\n iconPath: String?\n ) {\n self.name = name\n self.bundleIdentifier = bundleIdentifier\n self.iconPath = iconPath\n }\n\n init(app: NSRunningApplication) {\n self.name = app.localizedName ?? \"\"\n self.bundleIdentifier = app.bundleIdentifier ?? \"\"\n self.iconPath = app.iconPath\n }\n\n init(from decoder: any Decoder) throws {\n if let app = try? decoder.singleValueContainer().decode(String.self) {\n // V1 - migration\n let runningApp = NSWorkspace.shared.runningApplications\n .first { $0.localizedName == app }\n\n self.name = app\n\n if let runningApp {\n self.bundleIdentifier = runningApp.bundleIdentifier ?? \"\"\n self.iconPath = runningApp.iconPath\n } else if let bundle = Bundle(path: \"/Applications/\\(app).app\") {\n self.bundleIdentifier = bundle.bundleIdentifier ?? \"\"\n self.iconPath = bundle.iconPath\n } else if let bundle = Bundle(path: \"/System/Applications/\\(app).app\") {\n self.bundleIdentifier = bundle.bundleIdentifier ?? \"\"\n self.iconPath = bundle.iconPath\n } else {\n self.bundleIdentifier = \"\"\n self.iconPath = nil\n }\n\n Migrations.appsMigrated = true\n } else {\n // V2\n let container = try decoder.container(keyedBy: CodingKeys.self)\n self.name = try container.decode(String.self, forKey: .name)\n self.bundleIdentifier = try container.decode(String.self, forKey: .bundleIdentifier)\n self.iconPath = try container.decodeIfPresent(String.self, forKey: .iconPath)\n }\n }\n\n static func == (lhs: MacApp, rhs: MacApp) -> Bool {\n if lhs.bundleIdentifier.isEmpty || rhs.bundleIdentifier.isEmpty {\n return lhs.name == rhs.name\n } else {\n return lhs.bundleIdentifier == rhs.bundleIdentifier\n }\n }\n}\n\nextension MacApp {\n var isFinder: Bool {\n bundleIdentifier == \"com.apple.finder\"\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Profiles/ProfilesSettingsView.swift", "//\n// ProfilesSettingsView.swift\n//\n// Created by Wojciech Kulik on 26/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct ProfilesSettingsView: View {\n @StateObject var viewModel = ProfilesSettingsViewModel()\n @StateObject var profilesRepository = AppDependencies.shared.profilesRepository\n\n var body: some View {\n Form {\n Section(\n header: HStack {\n Text(\"Profiles\")\n Spacer()\n Button {\n viewModel.createNewProfile()\n } label: {\n Image(systemName: \"plus\")\n }\n }\n ) {\n VStack(alignment: .leading) {\n ForEach(profilesRepository.profiles) { profile in\n HStack {\n Button {\n viewModel.deleteProfile(profile)\n } label: {\n Image(systemName: \"x.circle.fill\").opacity(0.8)\n }\n .buttonStyle(.borderless)\n .hidden(viewModel.hideDeleteButton)\n\n Button {\n viewModel.renameProfile(profile)\n } label: {\n Text(profile.name)\n }\n .buttonStyle(.borderless)\n .tint(.primary)\n }\n }\n }\n }\n }\n .formStyle(.grouped)\n .sheet(isPresented: $viewModel.isInputDialogPresented) {\n InputDialog(\n title: \"Enter profile name:\",\n userInput: $viewModel.userInput,\n isPresented: $viewModel.isInputDialogPresented\n )\n }\n .alert(\n \"Are you sure you want to delete \\\"\\(viewModel.profileToDelete)\\\" profile?\",\n isPresented: $viewModel.isDeleteConfirmationPresented\n ) {\n Button(\"Delete\", role: .destructive) {\n viewModel.deleteConfirmed()\n }\n Button(\"Cancel\", role: .cancel) {}\n } message: {\n Text(\"This action cannot be undone.\")\n }\n .alert(\n \"Do you want to copy the current workspaces to the new profile?\",\n isPresented: $viewModel.isCopyChoicePresented\n ) {\n Button(\"Copy\") { viewModel.createNewProfile(copyWorkspaces: true) }\n Button(\"No\", role: .cancel) { viewModel.createNewProfile(copyWorkspaces: false) }\n }\n .onChange(of: viewModel.isInputDialogPresented) { _, isPresented in\n if !isPresented {\n viewModel.inputDialogDismissed()\n }\n }\n .navigationTitle(\"Profiles\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Integrations/Integrations.swift", "//\n// Integrations.swift\n//\n// Created by Wojciech Kulik on 24/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nenum Integrations {\n private static let settings = AppDependencies.shared.integrationsSettings\n private static let profilesRepository = AppDependencies.shared.profilesRepository\n\n static func runOnActivateIfNeeded(workspace: ActiveWorkspace) {\n let script = settings.runScriptOnWorkspaceChange.trimmingCharacters(in: .whitespaces)\n .replacingOccurrences(of: \"$WORKSPACE_NUMBER\", with: workspace.number ?? \"\")\n .replacingOccurrences(of: \"$WORKSPACE\", with: workspace.name)\n .replacingOccurrences(of: \"$DISPLAY\", with: workspace.display)\n .replacingOccurrences(of: \"$PROFILE\", with: profilesRepository.selectedProfile.name)\n runScript(script)\n }\n\n static func runOnAppLaunchIfNeeded() {\n let script = settings.runScriptOnLaunch.trimmingCharacters(in: .whitespaces)\n .replacingOccurrences(of: \"$PROFILE\", with: profilesRepository.selectedProfile.name)\n runScript(script)\n }\n\n static func runOnProfileChangeIfNeeded(profile: String) {\n let script = settings.runScriptOnProfileChange.trimmingCharacters(in: .whitespaces)\n .replacingOccurrences(of: \"$PROFILE\", with: profile)\n runScript(script)\n }\n\n private static func runScript(_ script: String) {\n guard settings.enableIntegrations, !script.isEmpty else { return }\n\n let shell = ProcessInfo.processInfo.environment[\"SHELL\"] ?? \"/bin/sh\"\n let task = Process()\n task.launchPath = shell\n task.arguments = [\"-c\", script]\n task.launch()\n }\n}\n"], ["/FlashSpace/FlashSpace/UI/HotKeyControl.swift", "//\n// HotKeyControl.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport ShortcutRecorder\nimport SwiftUI\n\nstruct HotKeyControl: NSViewRepresentable {\n @Binding var shortcut: AppHotKey?\n\n func makeNSView(context: Context) -> RecorderControl {\n let control = RecorderControl(frame: .zero)\n control.delegate = context.coordinator\n control.objectValue = shortcut.flatMap { $0.toShortcut() }\n control.set(\n allowedModifierFlags: [.command, .option, .control, .shift],\n requiredModifierFlags: [],\n allowsEmptyModifierFlags: true\n )\n\n return control\n }\n\n func updateNSView(_ nsView: RecorderControl, context: Context) {\n context.coordinator.parent = self\n nsView.objectValue = shortcut.flatMap { $0.toShortcut() }\n }\n\n func makeCoordinator() -> Coordinator { Coordinator(parent: self) }\n\n final class Coordinator: NSObject, RecorderControlDelegate {\n var parent: HotKeyControl\n\n private let hotKeysManager = AppDependencies.shared.hotKeysManager\n\n init(parent: HotKeyControl) {\n self.parent = parent\n }\n\n func recorderControlDidBeginRecording(_ aControl: RecorderControl) {\n hotKeysManager.disableAll()\n }\n\n func recorderControl(_ aControl: RecorderControl, canRecord aShortcut: Shortcut) -> Bool {\n if let conflict = hotKeysManager.allHotKeys.first(where: { $0.hotKey.toShortcut() == aShortcut })?.scope {\n Alert.showOkAlert(\n title: \"Conflict\",\n message: \"This shortcut is already assigned within the \\(conflict) scope.\"\n )\n return false\n }\n\n return true\n }\n\n func recorderControlDidEndRecording(_ aControl: RecorderControl) {\n guard let shortcut = aControl.objectValue else {\n parent.shortcut = nil\n hotKeysManager.enableAll()\n return\n }\n\n parent.shortcut = .init(\n keyCode: shortcut.keyCode.rawValue,\n modifiers: shortcut.modifierFlags.rawValue\n )\n hotKeysManager.enableAll()\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/PictureInPicture/Extensions/AXUIElement+PiP.swift", "//\n// AXUIElement+PiP.swift\n//\n// Created by Wojciech Kulik on 12/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension AXUIElement {\n private var pipApps: [PipApp] {\n AppDependencies.shared.workspaceSettings.pipApps\n }\n\n func isPictureInPicture(bundleId: String?) -> Bool {\n if let browser = PipBrowser(rawValue: bundleId ?? \"\") {\n if let partialTitle = browser.partialTitle,\n title?.contains(partialTitle) == true {\n return true\n }\n\n if let pipWindowTitle = browser.title {\n return title == pipWindowTitle\n } else if let pipWindowSubrole = browser.subrole {\n return subrole == pipWindowSubrole\n }\n } else if let pipApp = pipApps.first(where: { $0.bundleIdentifier == bundleId }) {\n let result = title?.range(\n of: pipApp.pipWindowTitleRegex,\n options: .regularExpression\n ) != nil\n\n return result\n }\n\n return false\n }\n}\n"], ["/FlashSpace/FlashSpace/UI/Toast.swift", "//\n// Toast.swift\n//\n// Created by Wojciech Kulik on 28/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport SwiftUI\n\nenum Toast {\n weak static var toastWindow: NSWindow?\n\n static func showWith(icon: String, message: String, textColor: Color) {\n guard AppDependencies.shared.generalSettings.showFloatingNotifications else { return }\n\n if let window = toastWindow {\n window.orderOut(nil)\n toastWindow = nil\n }\n\n let contentView = NSHostingView(\n rootView: ToastView(\n icon: icon,\n message: message,\n textColor: textColor\n )\n )\n let size = contentView.fittingSize\n\n // contentRect is in screen coordinates where (0,0) is bottom-left corner\n // and it is relative to the main screen.\n let window = NSWindow(\n contentRect: NSRect(\n x: (NSScreen.main?.frame.midX ?? 200.0) - size.width / 2.0,\n y: (NSScreen.main?.frame.minY ?? 0.0) + (NSScreen.main?.frame.height ?? 0.0) * 0.07,\n width: size.width,\n height: size.height\n ),\n styleMask: [.borderless],\n backing: .buffered,\n defer: false\n )\n window.isOpaque = false\n window.backgroundColor = .clear\n window.level = .screenSaver\n toastWindow = window\n\n let visualEffectView = contentView.addVisualEffect(material: .sidebar, border: true)\n window.contentView = visualEffectView\n window.orderFrontRegardless()\n\n DispatchQueue.main.asyncAfter(deadline: .now() + 2.0) {\n NSAnimationContext.runAnimationGroup({ context in\n context.duration = 0.3\n window.animator().alphaValue = 0.0\n }, completionHandler: {\n window.orderOut(nil)\n })\n }\n }\n}\n\nstruct ToastView: View {\n let icon: String\n let message: String\n let textColor: Color\n\n var body: some View {\n HStack {\n Image(systemName: icon)\n .resizable()\n .scaledToFit()\n .frame(width: 26)\n\n Text(message)\n .font(.title)\n }\n .opacity(0.9)\n .padding()\n .padding(.horizontal)\n .fontWeight(.semibold)\n .foregroundStyle(textColor)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/MainScreen/WorkspaceConfigurationView.swift", "//\n// WorkspaceConfigurationView.swift\n//\n// Created by Wojciech Kulik on 20/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct WorkspaceConfigurationView: View {\n @Environment(\\.openWindow) var openWindow\n\n @ObservedObject var viewModel: MainViewModel\n @StateObject var profilesRepository = AppDependencies.shared.profilesRepository\n\n var body: some View {\n VStack(alignment: .leading, spacing: 0.0) {\n configuration\n\n if viewModel.workspaces.contains(where: { $0.apps.contains(where: \\.bundleIdentifier.isEmpty) }) {\n Text(\"Could not migrate some apps. Please re-add them to fix the problem. Please also check floating apps.\")\n .foregroundColor(.errorRed)\n }\n\n Spacer()\n profileAndSettings\n }\n }\n\n private var configuration: some View {\n VStack(alignment: .leading, spacing: 1.0) {\n Text(\"Workspace Configuration:\")\n .padding(.bottom, 16.0)\n .fixedSize()\n\n Text(\"Name:\")\n TextField(\"Name\", text: $viewModel.workspaceName)\n .onSubmit(viewModel.saveWorkspace)\n .padding(.bottom)\n\n Picker(\"Display:\", selection: $viewModel.workspaceDisplay) {\n ForEach(viewModel.screens, id: \\.self) {\n Text($0).tag($0)\n }\n }\n .padding(.bottom)\n .hidden(viewModel.displayMode == .dynamic)\n\n Picker(\"Focus App:\", selection: $viewModel.workspaceAppToFocus) {\n ForEach(viewModel.focusAppOptions, id: \\.self) {\n Text($0.name).tag($0)\n }\n }.padding(.bottom)\n\n HStack {\n Text(\"Menu Bar Icon:\")\n Button {\n viewModel.isSymbolPickerPresented = true\n } label: {\n Image(systemName: viewModel.workspaceSymbolIconName ?? .defaultIconSymbol)\n .frame(maxWidth: .infinity)\n }\n }.padding(.bottom)\n\n Text(\"Activate Shortcut:\")\n HotKeyControl(shortcut: $viewModel.workspaceShortcut).padding(.bottom)\n\n Text(\"Assign App Shortcut:\")\n HotKeyControl(shortcut: $viewModel.workspaceAssignShortcut).padding(.bottom)\n }\n .disabled(viewModel.selectedWorkspace == nil)\n }\n\n private var profileAndSettings: some View {\n HStack {\n Picker(\"Profile:\", selection: $profilesRepository.selectedProfile) {\n ForEach(profilesRepository.profiles) {\n Text($0.name).tag($0)\n }\n }\n\n Button(action: {\n openWindow(id: \"settings\")\n }, label: {\n Image(systemName: \"gearshape\")\n .foregroundColor(.primary)\n }).keyboardShortcut(\",\")\n }.frame(maxWidth: .infinity, alignment: .trailing)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/CLI.swift", "//\n// CLI.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nenum CLI {\n static var cliPath: String { Bundle.main.bundlePath + \"/Contents/Resources/flashspace\" }\n static var symlinkPath: String { \"/usr/local/bin/flashspace\" }\n static var isInstalled: Bool { FileManager.default.fileExists(atPath: symlinkPath) }\n\n static func install() {\n guard !isInstalled else {\n return print(\"✅ CLI already installed at \\(symlinkPath)\")\n }\n\n if runSudoScript(\"ln -s '\\(cliPath)' '\\(symlinkPath)'\") {\n Logger.log(\"✅ CLI installed from \\(symlinkPath)\")\n }\n }\n\n static func uninstall() {\n guard isInstalled else { return print(\"✅ CLI already uninstalled\") }\n\n if runSudoScript(\"rm '\\(symlinkPath)'\") {\n Logger.log(\"✅ CLI uninstalled from \\(symlinkPath)\")\n }\n }\n\n private static func runSudoScript(_ script: String) -> Bool {\n let appleScript =\n \"do shell script \\\"sudo \\(script)\\\" with administrator privileges\"\n\n guard let scriptObject = NSAppleScript(source: appleScript) else {\n Logger.log(\"❌ Error: Failed to create AppleScript object\")\n Alert.showOkAlert(title: \"Error\", message: \"Could not run script\")\n return false\n }\n\n var error: NSDictionary?\n scriptObject.executeAndReturnError(&error)\n\n if let error {\n Logger.log(\"❌ Error: \\(error)\")\n if let errorNumber = error[\"NSAppleScriptErrorNumber\"],\n errorNumber as? NSNumber != -128,\n let errorMessage = error[\"NSAppleScriptErrorMessage\"] as? String {\n Alert.showOkAlert(title: \"Error\", message: errorMessage)\n }\n return false\n }\n\n return true\n }\n}\n"], ["/FlashSpace/FlashSpace/Accessibility/NSRunningApplication+Actions.swift", "//\n// NSRunningApplication+Actions.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension NSRunningApplication {\n func raise() {\n guard let mainWindow else {\n unhide()\n return\n }\n\n AXUIElementPerformAction(mainWindow, NSAccessibility.Action.raise as CFString)\n }\n\n /// Position is in window coordinates where (0,0) is top-left corner\n /// and it is relative to the main screen.\n func setPosition(_ position: CGPoint) {\n mainWindow?.setPosition(position)\n }\n\n func centerApp(display: DisplayName) {\n guard let appFrame = frame else {\n return Logger.log(\"Could not get frame for app: \\(localizedName ?? \"\")\")\n }\n\n guard let nsScreen = NSScreen.screen(display) else { return }\n guard appFrame.getDisplay() != nsScreen.localizedName else { return }\n\n let normalizedScreenFrame = nsScreen.normalizedFrame\n\n let origin = CGPoint(\n x: normalizedScreenFrame.midX - appFrame.width / 2.0,\n y: normalizedScreenFrame.midY - appFrame.height / 2.0\n )\n\n setPosition(origin)\n }\n\n func runWithoutAnimations(action: () -> ()) {\n let appElement = AXUIElementCreateApplication(processIdentifier)\n let wasEnabled = appElement.enhancedUserInterface\n\n if wasEnabled { appElement.setAttribute(.enchancedUserInterface, value: false) }\n\n action()\n\n if wasEnabled { appElement.setAttribute(.enchancedUserInterface, value: true) }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Workspaces/WorkspacesSettingsView.swift", "//\n// WorkspacesSettingsView.swift\n//\n// Created by Wojciech Kulik on 24/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct WorkspacesSettingsView: View {\n @StateObject var settings = AppDependencies.shared.workspaceSettings\n @StateObject var viewModel = WorkspaceSettingsViewModel()\n\n var body: some View {\n Form {\n Section(\"Displays\") {\n Picker(\"Display Assignment Mode\", selection: $settings.displayMode) {\n ForEach(DisplayMode.allCases) { action in\n Text(action.description).tag(action)\n }\n }\n\n Text(\"Static Mode requires you to manually assign workspaces to displays.\\n\\n\" +\n \"Dynamic Mode automatically assigns workspaces to displays \" +\n \"based on where your applications are located. In this mode, a single workspace can span across multiple displays.\"\n )\n .font(.callout)\n .foregroundStyle(.secondary)\n }\n\n Section(\"Behaviors\") {\n Toggle(\"Activate Workspace On Focus Change\", isOn: $settings.activeWorkspaceOnFocusChange)\n Toggle(\"Center Cursor In Focused App On Workspace Change\", isOn: $settings.centerCursorOnWorkspaceChange)\n Toggle(\"Automatically Change Workspace On App Assignment\", isOn: $settings.changeWorkspaceOnAppAssign)\n Toggle(\"Keep Unassigned Apps On Workspace Change\", isOn: $settings.keepUnassignedAppsOnSwitch)\n Toggle(\"Show Hidden Apps On Workspace Activation\", isOn: $settings.restoreHiddenAppsOnSwitch)\n .help(\"Restores hidden apps, even if they were hidden manually\")\n Toggle(\"Enable Workspace Transition Animation\", isOn: $settings.enableWorkspaceTransitions)\n .help(\"Show a brief visual transition effect when switching between workspaces\")\n\n if settings.enableWorkspaceTransitions {\n HStack {\n VStack(alignment: .leading) {\n Text(\"Transition Duration\")\n Text(\"Controls how long the transition animation lasts when switching workspaces\")\n .font(.caption)\n .foregroundStyle(.secondary)\n }\n Spacer()\n Slider(value: $settings.workspaceTransitionDuration, in: 0.1...0.5, step: 0.05)\n .frame(width: 150)\n Text(\"\\(settings.workspaceTransitionDuration, specifier: \"%.2f\")s\")\n .foregroundStyle(.secondary)\n .frame(width: 45.0, alignment: .trailing)\n }\n .padding(.leading, 16)\n\n HStack {\n VStack(alignment: .leading) {\n Text(\"Transition Dimming\")\n Text(\"Adjusts how dark the screen becomes during workspace transitions\")\n .font(.caption)\n .foregroundStyle(.secondary)\n }\n Spacer()\n Slider(value: $settings.workspaceTransitionDimming, in: 0.05...0.5, step: 0.05)\n .frame(width: 150)\n Text(\"\\(Int(settings.workspaceTransitionDimming * 100))%\")\n .foregroundStyle(.secondary)\n .frame(width: 45.0, alignment: .trailing)\n }\n .padding(.leading, 16)\n }\n }\n\n Section(\"Shortcuts\") {\n hotkey(\"Assign Visible Apps (to active workspace)\", for: $settings.assignVisibleApps)\n hotkey(\"Assign Focused App (to active workspace)\", for: $settings.assignFocusedApp)\n hotkey(\"Unassign Focused App\", for: $settings.unassignFocusedApp)\n hotkey(\"Toggle Focused App Assignment\", for: $settings.toggleFocusedAppAssignment)\n hotkey(\"Hide Unassigned Apps\", for: $settings.hideUnassignedApps)\n }\n\n Section {\n hotkey(\"Recent Workspace\", for: $settings.switchToRecentWorkspace)\n hotkey(\"Previous Workspace\", for: $settings.switchToPreviousWorkspace)\n hotkey(\"Next Workspace\", for: $settings.switchToNextWorkspace)\n Toggle(\"Loop Workspaces\", isOn: $settings.loopWorkspaces)\n Toggle(\"Skip Empty Workspaces On Switch\", isOn: $settings.skipEmptyWorkspacesOnSwitch)\n Text(\n \"These shortcuts allow you to cycle through workspaces on the display where the cursor is currently located.\"\n )\n .foregroundStyle(.secondary)\n .font(.callout)\n }\n\n Section {\n HStack {\n Text(\"Alternative Displays\")\n TextField(\"\", text: $settings.alternativeDisplays)\n .foregroundColor(.secondary)\n .standardPlaceholder(settings.alternativeDisplays.isEmpty)\n }\n\n Text(\n \"\"\"\n Example: DELL XYZ=Benq ABC;LG 123=DELL XYZ\n\n This setting is useful if you want to use the same configuration for different displays.\n You can tell FlashSpace which display should be used if the selected one is not connected.\n\n If only one display is connected, it will always act as the fallback.\n \"\"\"\n )\n .foregroundStyle(.secondary)\n .font(.callout)\n }\n .hidden(settings.displayMode == .dynamic)\n\n Section(\"Picture-in-Picture\") {\n Toggle(\"Enable Picture-in-Picture Support\", isOn: $settings.enablePictureInPictureSupport)\n Toggle(\"Switch Workspace When Picture-in-Picture Closes\", isOn: $settings.switchWorkspaceWhenPipCloses)\n\n HStack {\n Text(\"Screen Corner Offset\")\n Spacer()\n Text(\"\\(settings.pipScreenCornerOffset)\")\n Stepper(\n \"\",\n value: $settings.pipScreenCornerOffset,\n in: 1...50,\n step: 1\n ).labelsHidden()\n }\n\n Text(\n \"If a supported browser has Picture-in-Picture active, other \" +\n \"windows will be hidden in a screen corner to keep PiP visible.\"\n )\n .foregroundStyle(.secondary)\n .font(.callout)\n }\n\n Section(header: pipAppsHeader) {\n if settings.pipApps.isEmpty {\n Text(\"You can apply Picture-in-Picture behavior to any app by adding it here.\")\n .foregroundStyle(.secondary)\n .font(.callout)\n } else {\n pipAppsList\n }\n }\n .opacity(settings.enablePictureInPictureSupport ? 1 : 0.5)\n }\n .sheet(isPresented: $viewModel.isInputDialogPresented) {\n InputDialog(\n title: \"Enter PiP window title regex:\",\n placeholder: \"e.g. Meeting with.*\",\n userInput: $viewModel.windowTitleRegex,\n isPresented: $viewModel.isInputDialogPresented\n )\n }\n .formStyle(.grouped)\n .navigationTitle(\"Workspaces\")\n }\n\n private var pipAppsList: some View {\n VStack(alignment: .leading) {\n ForEach(settings.pipApps, id: \\.self) { app in\n HStack {\n Button {\n viewModel.deletePipApp(app)\n } label: {\n Image(systemName: \"x.circle.fill\").opacity(0.8)\n }.buttonStyle(.borderless)\n\n Text(app.name)\n Spacer()\n Text(app.pipWindowTitleRegex)\n .foregroundColor(.secondary)\n }\n }\n }\n }\n\n private var pipAppsHeader: some View {\n HStack {\n Text(\"Custom Picture-in-Picture Apps\")\n Spacer()\n Button {\n viewModel.addPipApp()\n } label: {\n Image(systemName: \"plus\")\n }\n }\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Get/GetAppCommand.swift", "//\n// GetAppCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport ArgumentParser\nimport Foundation\n\nstruct GetAppCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"get-app\",\n abstract: \"Get active app\"\n )\n\n @Flag(help: \"Include windows count\")\n var withWindowsCount = false\n\n func run() throws {\n sendCommand(.getApp(withWindowsCount: withWindowsCount))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Workspace/WorkspaceCommand.swift", "//\n// WorkspaceCommand.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct WorkspaceCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"workspace\",\n abstract: \"Activate a workspace\"\n )\n\n @Option(help: .init(\"The name of the workspace\"))\n var name: String?\n\n @Option(help: .init(\n \"The number of the workspace to activate. Starting from 1.\",\n valueName: \"number\"\n ))\n var number: Int?\n\n @Flag(help: \"Activate the next workspace\")\n var next = false\n\n @Flag(help: \"Activate the previous workspace\")\n var prev = false\n\n @Flag(help: \"Activate the most recently used workspace\")\n var recent = false\n\n @Flag(help: \"Skip empty workspaces (works only with --next or --prev)\")\n var skipEmpty = false\n\n @Flag(help: \"Loop back to the first workspace when reaching the last one and vice versa (works only with --next or --prev)\")\n var loop = false\n\n @Flag(help: \"Hide all apps that are not assigned to the selected workspace\")\n var clean = false\n\n func run() throws {\n if let name {\n sendCommand(.activateWorkspace(name: name, number: nil, clean: clean))\n } else if let number {\n sendCommand(.activateWorkspace(name: nil, number: number, clean: clean))\n } else if next {\n sendCommand(.nextWorkspace(skipEmpty: skipEmpty, clean: clean, loop: loop))\n } else if prev {\n sendCommand(.previousWorkspace(skipEmpty: skipEmpty, clean: clean, loop: loop))\n } else if recent {\n sendCommand(.recentWorkspace(clean: clean))\n } else {\n fallbackToHelp()\n }\n\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Workspaces/WorkspaceSettingsViewModel.swift", "//\n// WorkspaceSettingsViewModel.swift\n//\n// Created by Wojciech Kulik on 22/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nfinal class WorkspaceSettingsViewModel: ObservableObject {\n @Published var windowTitleRegex = \"\"\n @Published var isInputDialogPresented = false {\n didSet {\n if !isInputDialogPresented, windowTitleRegex.isNotEmpty {\n addPendingPipApp()\n windowTitleRegex = \"\"\n }\n }\n }\n\n private var pendingApp: PipApp?\n private let settings = AppDependencies.shared.workspaceSettings\n\n func addPipApp() {\n let fileChooser = FileChooser()\n let appUrl = fileChooser.runModalOpenPanel(\n allowedFileTypes: [.application],\n directoryURL: URL(filePath: \"/Applications\")\n )\n\n guard let bundle = appUrl?.bundle else { return }\n\n pendingApp = PipApp(\n name: bundle.localizedAppName,\n bundleIdentifier: bundle.bundleIdentifier ?? \"\",\n pipWindowTitleRegex: \"\"\n )\n isInputDialogPresented = true\n }\n\n func deletePipApp(_ app: PipApp) {\n settings.deletePipApp(app)\n }\n\n private func addPendingPipApp() {\n guard let pendingApp else { return }\n\n settings.addPipApp(\n .init(\n name: pendingApp.name,\n bundleIdentifier: pendingApp.bundleIdentifier,\n pipWindowTitleRegex: windowTitleRegex\n )\n )\n self.pendingApp = nil\n }\n}\n"], ["/FlashSpace/FlashSpace/Accessibility/AXUIElement+CoreGraphics.swift", "//\n// AXUIElement+CoreGraphics.swift\n//\n// Created by Wojciech Kulik on 21/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension AXUIElement {\n var cgWindowId: CGWindowID? {\n let title = title\n let pid = processId\n\n if let windowList = CGWindowListCopyWindowInfo(.optionOnScreenOnly, kCGNullWindowID) as? [[String: Any]] {\n for window in windowList {\n let windowOwnerPID = window[kCGWindowOwnerPID as String] as? pid_t\n let windowName = window[kCGWindowName as String] as? String\n let windowNumber = window[kCGWindowNumber as String] as? CGWindowID\n\n if title == windowName, windowOwnerPID == pid {\n return windowNumber\n }\n }\n }\n\n return nil\n }\n\n func isBelowAnyOf(_ windows: [AXUIElement]) -> Bool {\n guard let cgWindowId, let frame else { return false }\n\n let otherWindows = windows.map { (id: $0.cgWindowId, window: $0) }\n let windowsAbove = CGWindowListCopyWindowInfo(.optionOnScreenAboveWindow, cgWindowId) as? [[String: Any]] ?? [[:]]\n let windowsAboveIds = Set(\n windowsAbove.compactMap { $0[kCGWindowNumber as String] as? CGWindowID }\n )\n\n return otherWindows.contains { otherWindowId, otherWindow in\n if let otherWindowId,\n windowsAboveIds.contains(otherWindowId),\n let otherWindowFrame = otherWindow.frame,\n frame.intersects(otherWindowFrame) {\n Logger.log(\"💡 Window \\\"\\(title ?? \"unknown\")\\\" is below \\\"\\(otherWindow.title ?? \"unknown\")\\\"\")\n return true\n }\n\n return false\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/HotKeys/Models/AppHotKey.swift", "//\n// AppHotKey.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\ntypealias RawKeyCode = UInt16\ntypealias RawKeyModifiers = UInt\n\nstruct AppHotKey: Codable, Hashable {\n let value: String\n\n init(value: String) { self.value = value }\n\n init(keyCode: RawKeyCode, modifiers: RawKeyModifiers) {\n let keyEquivalent = KeyCodesMap.toString[keyCode] ?? \"\"\n let modifiers = KeyModifiersMap.toString(modifiers)\n let result = [modifiers, keyEquivalent].filter { !$0.isEmpty }.joined(separator: \"+\")\n\n self.init(value: result)\n }\n\n init(from decoder: Decoder) throws {\n enum CodingKeys: String, CodingKey { case keyCode, modifiers }\n\n if let container = try? decoder.container(keyedBy: CodingKeys.self) {\n // v1 -> v2 Migration\n let keyCode = try container.decodeIfPresent(RawKeyCode.self, forKey: .keyCode)\n let modifiers = try container.decodeIfPresent(RawKeyModifiers.self, forKey: .modifiers)\n\n if let keyCode, let modifiers {\n Migrations.hotKeysMigrated = true\n self.init(keyCode: keyCode, modifiers: modifiers)\n } else {\n throw DecodingError.dataCorruptedError(\n forKey: .keyCode,\n in: container,\n debugDescription: \"Invalid key code or modifiers\"\n )\n }\n } else {\n // v2\n let container = try decoder.singleValueContainer()\n try self.init(value: container.decode(String.self))\n }\n }\n\n func encode(to encoder: any Encoder) throws {\n var container = encoder.singleValueContainer()\n try container.encode(value)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/SpaceControl/Views/SpaceControlView.swift", "//\n// SpaceControlView.swift\n//\n// Created by Wojciech Kulik on 11/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct SpaceControlView: View {\n @Environment(\\.colorScheme) var colorScheme\n @StateObject var viewModel = SpaceControlViewModel()\n\n var body: some View {\n let columns = Array(repeating: GridItem(.flexible()), count: viewModel.numberOfColumns)\n let width = (NSScreen.main?.frame.width ?? 1200) / CGFloat(viewModel.numberOfColumns) - 70.0\n let height = (NSScreen.main?.frame.height ?? 800) / CGFloat(viewModel.numberOfRows) - 120.0\n\n LazyVGrid(columns: columns, spacing: viewModel.numberOfRows == 2 ? 90.0 : 60.0) {\n ForEach(viewModel.workspaces, id: \\.index) { workspace in\n VStack(alignment: .leading, spacing: 16.0) {\n workspaceName(workspace)\n\n Group {\n if let image = workspace.screenshotData.flatMap(NSImage.init(data:)) {\n workspacePreview(image: image, width: width, height: height)\n } else {\n workspacePlaceholder(width: width, height: height)\n }\n }\n .overlay(alignment: .topTrailing) { workspaceNumber(workspace.index + 1) }\n .overlay(\n RoundedRectangle(cornerRadius: 18.0)\n .stroke(\n workspace.isActive\n ? workspace.originalWorkspace.isOnTheCurrentScreen\n ? Color.positive\n : Color.teal\n : Color.black.opacity(0.8),\n lineWidth: 3.0\n )\n )\n .compositingGroup()\n .shadow(\n color: .black.opacity(workspace.screenshotData != nil ? 0.8 : 0.0),\n radius: 20.0,\n x: 0.0,\n y: 0.0\n )\n }\n .onTapGesture { viewModel.onWorkspaceTap(workspace) }\n }\n }\n .multilineTextAlignment(.center)\n .padding()\n .frame(maxWidth: .infinity, maxHeight: .infinity)\n }\n\n private func workspacePreview(image: NSImage, width: CGFloat, height: CGFloat) -> some View {\n Image(nsImage: image)\n .resizable()\n .scaledToFit()\n .frame(maxWidth: width, maxHeight: height)\n .aspectRatio(16.0 / 9.0, contentMode: .fit)\n .background(Color.black.opacity(0.4))\n .clipShape(RoundedRectangle(cornerRadius: 18.0))\n }\n\n private func workspacePlaceholder(width: CGFloat, height: CGFloat) -> some View {\n RoundedRectangle(cornerRadius: 18.0)\n .fill(Color.black.opacity(0.5))\n .frame(maxWidth: width, maxHeight: height)\n .aspectRatio(16.0 / 9.0, contentMode: .fit)\n .overlay {\n Text(\"Preview Not Available\")\n .font(.title)\n .foregroundColor(.white)\n .padding()\n .frame(maxWidth: .infinity, maxHeight: .infinity)\n }\n .clipped()\n }\n\n private func workspaceName(_ workspace: SpaceControlWorkspace) -> some View {\n HStack(spacing: 16.0) {\n Image(systemName: workspace.symbol)\n .resizable()\n .scaledToFit()\n .frame(height: 17.0)\n .foregroundColor(colorScheme == .dark ? .workspaceIcon : .primary)\n\n Text(workspace.name)\n .foregroundColor(.primary)\n .font(.title2)\n }\n .fontWeight(.semibold)\n .lineLimit(1)\n .compositingGroup()\n .shadow(\n color: .black.opacity(colorScheme == .dark ? 0.8 : 0.25),\n radius: 4.0,\n x: 0.0,\n y: 0.0\n )\n }\n\n private func workspaceNumber(_ number: Int) -> some View {\n Text(\"\\(number)\")\n .foregroundColor(.white)\n .font(.title3)\n .frame(width: 40.0)\n .padding(.vertical, 8.0)\n .background(Color.black)\n .cornerRadius(18.0, corners: [.topRight])\n .cornerRadius(8.0, corners: [.bottomLeft])\n }\n}\n"], ["/FlashSpace/FlashSpace/App/AppDependencies.swift", "//\n// AppDependencies.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ShortcutRecorder\n\nstruct AppDependencies {\n static let shared = AppDependencies()\n\n let displayManager: DisplayManager\n let workspaceRepository: WorkspaceRepository\n let workspaceManager: WorkspaceManager\n let workspaceHotKeys: WorkspaceHotKeys\n let workspaceScreenshotManager = WorkspaceScreenshotManager()\n let workspaceTransitionManager: WorkspaceTransitionManager\n let pictureInPictureManager: PictureInPictureManager\n\n let floatingAppsHotKeys: FloatingAppsHotKeys\n\n let hotKeysMonitor: HotKeysMonitorProtocol = GlobalShortcutMonitor.shared\n let hotKeysManager: HotKeysManager\n\n let focusManager: FocusManager\n let focusedWindowTracker: FocusedWindowTracker\n\n let settingsRepository: SettingsRepository\n let generalSettings = GeneralSettings()\n let menuBarSettings = MenuBarSettings()\n let gesturesSettings = GesturesSettings()\n let focusManagerSettings = FocusManagerSettings()\n let workspaceSettings = WorkspaceSettings()\n let floatingAppsSettings = FloatingAppsSettings()\n let spaceControlSettings = SpaceControlSettings()\n let integrationsSettings = IntegrationsSettings()\n\n let profilesRepository: ProfilesRepository\n let autostartService = AutostartService()\n let cliServer = CLIServer()\n\n // swiftlint:disable:next function_body_length\n private init() {\n self.settingsRepository = SettingsRepository(\n generalSettings: generalSettings,\n menuBarSettings: menuBarSettings,\n gesturesSettings: gesturesSettings,\n focusManagerSettings: focusManagerSettings,\n workspaceSettings: workspaceSettings,\n floatingAppsSettings: floatingAppsSettings,\n spaceControlSettings: spaceControlSettings,\n integrationsSettings: integrationsSettings\n )\n self.displayManager = DisplayManager(settingsRepository: settingsRepository)\n self.workspaceTransitionManager = WorkspaceTransitionManager(\n workspaceSettings: workspaceSettings\n )\n self.pictureInPictureManager = PictureInPictureManager(\n settingsRepository: settingsRepository\n )\n self.profilesRepository = ProfilesRepository()\n self.workspaceRepository = WorkspaceRepository(\n profilesRepository: profilesRepository\n )\n self.workspaceManager = WorkspaceManager(\n workspaceRepository: workspaceRepository,\n settingsRepository: settingsRepository,\n pictureInPictureManager: pictureInPictureManager,\n workspaceTransitionManager: workspaceTransitionManager,\n displayManager: displayManager\n )\n self.workspaceHotKeys = WorkspaceHotKeys(\n workspaceManager: workspaceManager,\n workspaceRepository: workspaceRepository,\n settingsRepository: settingsRepository\n )\n self.floatingAppsHotKeys = FloatingAppsHotKeys(\n workspaceManager: workspaceManager,\n settingsRepository: settingsRepository\n )\n self.focusManager = FocusManager(\n workspaceRepository: workspaceRepository,\n workspaceManager: workspaceManager,\n focusManagerSettings: focusManagerSettings,\n floatingAppsSettings: floatingAppsSettings\n )\n self.hotKeysManager = HotKeysManager(\n hotKeysMonitor: GlobalShortcutMonitor.shared,\n workspaceHotKeys: workspaceHotKeys,\n floatingAppsHotKeys: floatingAppsHotKeys,\n focusManager: focusManager,\n settingsRepository: settingsRepository\n )\n self.focusedWindowTracker = FocusedWindowTracker(\n workspaceRepository: workspaceRepository,\n workspaceManager: workspaceManager,\n settingsRepository: settingsRepository,\n pictureInPictureManager: pictureInPictureManager\n )\n\n Migrations.migrateIfNeeded(\n settingsRepository: settingsRepository,\n profilesRepository: profilesRepository\n )\n\n focusedWindowTracker.startTracking()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/App/FocusCommand.swift", "//\n// FocusCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct FocusCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"focus\",\n abstract: \"Focus window\"\n )\n\n @Option(\n name: .customLong(\"direction\"),\n help: .init(\"Focus a window in a specific direction\", valueName: \"up|down|left|right\")\n )\n var focusDirection: FocusDirection?\n\n @Flag(help: \"Focus the next workspace app\")\n var nextApp = false\n\n @Flag(help: \"Focus the previous workspace app\")\n var prevApp = false\n\n @Flag(help: \"Focus the next workspace window\")\n var nextWindow = false\n\n @Flag(help: \"Focus the previous workspace window\")\n var prevWindow = false\n\n func run() throws {\n if let focusDirection {\n sendCommand(.focusWindow(direction: focusDirection))\n } else if nextApp {\n sendCommand(.focusNextApp)\n } else if prevApp {\n sendCommand(.focusPreviousApp)\n } else if nextWindow {\n sendCommand(.focusNextWindow)\n } else if prevWindow {\n sendCommand(.focusPreviousWindow)\n } else {\n fallbackToHelp()\n }\n\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Workspaces/WorkspaceSettings.swift", "//\n// WorkspaceSettings.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nfinal class WorkspaceSettings: ObservableObject {\n @Published var displayMode: DisplayMode = .static\n\n @Published var centerCursorOnWorkspaceChange = false\n @Published var changeWorkspaceOnAppAssign = true\n @Published var activeWorkspaceOnFocusChange = true\n @Published var skipEmptyWorkspacesOnSwitch = false\n @Published var keepUnassignedAppsOnSwitch = false\n @Published var restoreHiddenAppsOnSwitch = true\n @Published var enableWorkspaceTransitions = false\n @Published var workspaceTransitionDuration = 0.3\n @Published var workspaceTransitionDimming = 0.2\n\n @Published var assignFocusedApp: AppHotKey?\n @Published var unassignFocusedApp: AppHotKey?\n @Published var toggleFocusedAppAssignment: AppHotKey?\n @Published var assignVisibleApps: AppHotKey?\n @Published var hideUnassignedApps: AppHotKey?\n\n @Published var loopWorkspaces = true\n @Published var switchToRecentWorkspace: AppHotKey?\n @Published var switchToPreviousWorkspace: AppHotKey?\n @Published var switchToNextWorkspace: AppHotKey?\n\n @Published var alternativeDisplays = \"\"\n\n @Published var enablePictureInPictureSupport = true\n @Published var switchWorkspaceWhenPipCloses = true\n @Published var pipScreenCornerOffset = 15\n @Published var pipApps: [PipApp] = []\n\n private var observer: AnyCancellable?\n private let updateSubject = PassthroughSubject<(), Never>()\n\n init() { observe() }\n\n func addPipApp(_ app: PipApp) {\n pipApps.append(app)\n }\n\n func deletePipApp(_ app: PipApp) {\n pipApps.removeAll { $0 == app }\n }\n\n private func observe() {\n observer = Publishers.MergeMany(\n $displayMode.settingsPublisher(),\n\n $centerCursorOnWorkspaceChange.settingsPublisher(),\n $changeWorkspaceOnAppAssign.settingsPublisher(),\n $activeWorkspaceOnFocusChange.settingsPublisher(),\n $skipEmptyWorkspacesOnSwitch.settingsPublisher(),\n $keepUnassignedAppsOnSwitch.settingsPublisher(),\n $restoreHiddenAppsOnSwitch.settingsPublisher(),\n $enableWorkspaceTransitions.settingsPublisher(),\n $workspaceTransitionDuration.settingsPublisher(debounce: true),\n $workspaceTransitionDimming.settingsPublisher(debounce: true),\n\n $assignFocusedApp.settingsPublisher(),\n $unassignFocusedApp.settingsPublisher(),\n $toggleFocusedAppAssignment.settingsPublisher(),\n $assignVisibleApps.settingsPublisher(),\n $hideUnassignedApps.settingsPublisher(),\n\n $loopWorkspaces.settingsPublisher(),\n $switchToRecentWorkspace.settingsPublisher(),\n $switchToPreviousWorkspace.settingsPublisher(),\n $switchToNextWorkspace.settingsPublisher(),\n\n $alternativeDisplays.settingsPublisher(debounce: true),\n $enablePictureInPictureSupport.settingsPublisher(),\n $switchWorkspaceWhenPipCloses.settingsPublisher(),\n $pipApps.settingsPublisher(),\n $pipScreenCornerOffset.settingsPublisher(debounce: true)\n )\n .receive(on: DispatchQueue.main)\n .sink { [weak self] in self?.updateSubject.send() }\n }\n}\n\nextension WorkspaceSettings: SettingsProtocol {\n var updatePublisher: AnyPublisher<(), Never> {\n updateSubject.eraseToAnyPublisher()\n }\n\n func load(from appSettings: AppSettings) {\n observer = nil\n displayMode = appSettings.displayMode ?? .static\n\n centerCursorOnWorkspaceChange = appSettings.centerCursorOnWorkspaceChange ?? false\n changeWorkspaceOnAppAssign = appSettings.changeWorkspaceOnAppAssign ?? true\n activeWorkspaceOnFocusChange = appSettings.activeWorkspaceOnFocusChange ?? true\n skipEmptyWorkspacesOnSwitch = appSettings.skipEmptyWorkspacesOnSwitch ?? false\n keepUnassignedAppsOnSwitch = appSettings.keepUnassignedAppsOnSwitch ?? false\n restoreHiddenAppsOnSwitch = appSettings.restoreHiddenAppsOnSwitch ?? true\n enableWorkspaceTransitions = appSettings.enableWorkspaceTransitions ?? false\n workspaceTransitionDuration = min(appSettings.workspaceTransitionDuration ?? 0.3, 0.5)\n workspaceTransitionDimming = min(appSettings.workspaceTransitionDimming ?? 0.2, 0.5)\n\n assignFocusedApp = appSettings.assignFocusedApp\n unassignFocusedApp = appSettings.unassignFocusedApp\n toggleFocusedAppAssignment = appSettings.toggleFocusedAppAssignment\n assignVisibleApps = appSettings.assignVisibleApps\n hideUnassignedApps = appSettings.hideUnassignedApps\n\n loopWorkspaces = appSettings.loopWorkspaces ?? true\n switchToRecentWorkspace = appSettings.switchToRecentWorkspace\n switchToPreviousWorkspace = appSettings.switchToPreviousWorkspace\n switchToNextWorkspace = appSettings.switchToNextWorkspace\n\n alternativeDisplays = appSettings.alternativeDisplays ?? \"\"\n enablePictureInPictureSupport = appSettings.enablePictureInPictureSupport ?? true\n switchWorkspaceWhenPipCloses = appSettings.switchWorkspaceWhenPipCloses ?? true\n pipApps = appSettings.pipApps ?? []\n pipScreenCornerOffset = appSettings.pipScreenCornerOffset ?? 15\n observe()\n }\n\n func update(_ appSettings: inout AppSettings) {\n appSettings.displayMode = displayMode\n\n appSettings.centerCursorOnWorkspaceChange = centerCursorOnWorkspaceChange\n appSettings.changeWorkspaceOnAppAssign = changeWorkspaceOnAppAssign\n appSettings.activeWorkspaceOnFocusChange = activeWorkspaceOnFocusChange\n appSettings.skipEmptyWorkspacesOnSwitch = skipEmptyWorkspacesOnSwitch\n appSettings.keepUnassignedAppsOnSwitch = keepUnassignedAppsOnSwitch\n appSettings.restoreHiddenAppsOnSwitch = restoreHiddenAppsOnSwitch\n appSettings.enableWorkspaceTransitions = enableWorkspaceTransitions\n appSettings.workspaceTransitionDuration = workspaceTransitionDuration\n appSettings.workspaceTransitionDimming = workspaceTransitionDimming\n\n appSettings.assignFocusedApp = assignFocusedApp\n appSettings.unassignFocusedApp = unassignFocusedApp\n appSettings.toggleFocusedAppAssignment = toggleFocusedAppAssignment\n appSettings.assignVisibleApps = assignVisibleApps\n appSettings.hideUnassignedApps = hideUnassignedApps\n\n appSettings.loopWorkspaces = loopWorkspaces\n appSettings.switchToRecentWorkspace = switchToRecentWorkspace\n appSettings.switchToPreviousWorkspace = switchToPreviousWorkspace\n appSettings.switchToNextWorkspace = switchToNextWorkspace\n\n appSettings.alternativeDisplays = alternativeDisplays\n appSettings.enablePictureInPictureSupport = enablePictureInPictureSupport\n appSettings.switchWorkspaceWhenPipCloses = switchWorkspaceWhenPipCloses\n appSettings.pipApps = pipApps\n appSettings.pipScreenCornerOffset = pipScreenCornerOffset\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Models/CommandResponse.swift", "//\n// CommandResponse.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nstruct CommandResponse: Codable {\n let success: Bool\n let message: String?\n let error: String?\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Get/GetWorkspaceCommand.swift", "//\n// GetWorkspaceCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport ArgumentParser\nimport Foundation\n\nstruct GetWorkspaceCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"get-workspace\",\n abstract: \"Get active workspace\"\n )\n\n @Option(help: \"Display name\")\n var display: String?\n\n func run() throws {\n sendCommand(.getWorkspace(display: display))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/HotKeys/Extensions/AppHotKey+KeyboardShortcut.swift", "//\n// AppHotKey+KeyboardShortcut.swift\n//\n// Created by Wojciech Kulik on 31/05/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nextension AppHotKey {\n var toKeyboardShortcut: KeyboardShortcut? {\n let components = value.components(separatedBy: \"+\")\n let modifiers = toEventModifiers(value)\n\n guard let key = components.last,\n let keyEquivalent = stringToKeyEquivalent(key) else { return nil }\n\n return KeyboardShortcut(\n keyEquivalent,\n modifiers: modifiers\n )\n }\n\n // swiftlint:disable:next cyclomatic_complexity\n private func stringToKeyEquivalent(_ value: String) -> KeyEquivalent? {\n guard value.count > 1 else { return KeyEquivalent(Character(value)) }\n\n switch value {\n case \"esc\", \"escape\": return KeyEquivalent.escape\n case \"return\", \"enter\": return KeyEquivalent.return\n case \"tab\": return KeyEquivalent.tab\n case \"space\": return KeyEquivalent.space\n case \"delete\", \"backspace\": return KeyEquivalent.delete\n case \"up\": return KeyEquivalent.upArrow\n case \"down\": return KeyEquivalent.downArrow\n case \"left\": return KeyEquivalent.leftArrow\n case \"right\": return KeyEquivalent.rightArrow\n case \"home\": return KeyEquivalent.home\n case \"end\": return KeyEquivalent.end\n default: return nil\n }\n }\n\n private func toEventModifiers(_ value: String) -> EventModifiers {\n let flags = value.lowercased().split(separator: \"+\").map { String($0) }\n var result: EventModifiers = []\n\n if flags.contains(\"cmd\") { result.insert(.command) }\n if flags.contains(\"ctrl\") { result.insert(.control) }\n if flags.contains(\"opt\") { result.insert(.option) }\n if flags.contains(\"shift\") { result.insert(.shift) }\n\n return result\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/General/GeneralSettingsView.swift", "//\n// GeneralSettingsView.swift\n//\n// Created by Wojciech Kulik on 23/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport SwiftUI\n\nstruct GeneralSettingsView: View {\n @StateObject var settings = AppDependencies.shared.generalSettings\n @State var isAutostartEnabled = false\n @State var hasAccessibilityPermissions = false\n\n var body: some View {\n Form {\n Section {\n Toggle(\"Launch at startup\", isOn: $isAutostartEnabled)\n Toggle(\"Check for updates automatically\", isOn: $settings.checkForUpdatesAutomatically)\n }\n\n Section(\"Permissions\") {\n HStack {\n if hasAccessibilityPermissions {\n Image(systemName: \"checkmark.circle.fill\")\n .foregroundColor(.green)\n Text(\"Accessibility Permissions\")\n Spacer()\n } else {\n Image(systemName: \"xmark.circle.fill\")\n .foregroundColor(.red)\n Text(\"Accessibility Permissions\")\n Spacer()\n Button(\"Open Privacy & Security\") {\n NSWorkspace.shared.open(\n URL(string: \"x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility\")!\n )\n }\n }\n }\n Text(\"FlashSpace requires accessibility access to manage applications.\")\n .foregroundColor(.secondary)\n .font(.callout)\n }\n\n Section(\"Shortcuts\") {\n hotkey(\"Toggle FlashSpace\", for: $settings.showFlashSpace)\n }\n\n Section(\"Notifications\") {\n Toggle(\"Enable Notifications\", isOn: $settings.showFloatingNotifications)\n Text(\"Some shortcuts will show a temporary notification.\")\n .foregroundStyle(.secondary)\n .font(.callout)\n }\n }\n .onAppear {\n isAutostartEnabled = AppDependencies.shared.autostartService.isLaunchAtLoginEnabled\n hasAccessibilityPermissions = PermissionsManager.shared.checkForAccessibilityPermissions()\n }\n .onChange(of: isAutostartEnabled) { _, enabled in\n if enabled {\n AppDependencies.shared.autostartService.enableLaunchAtLogin()\n } else {\n AppDependencies.shared.autostartService.disableLaunchAtLogin()\n }\n }\n .onReceive(NotificationCenter.default.publisher(for: NSApplication.didBecomeActiveNotification)) { _ in\n hasAccessibilityPermissions = PermissionsManager.shared.checkForAccessibilityPermissions()\n }\n .formStyle(.grouped)\n .navigationTitle(\"General\")\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/App/FloatingAppsCommand.swift", "//\n// FloatingAppsCommand.swift\n//\n// Created by Wojciech Kulik on 03/05/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct FloatingAppsCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"floating-apps\",\n abstract: \"Manage floating apps\"\n )\n\n enum Action: String, CaseIterable, ExpressibleByArgument {\n case float\n case unfloat\n case toggle\n }\n\n @Argument(help: \"The action to perform\")\n var action: Action\n\n @Option(help: .init(\n \"The name of the app or bundle id. If not provided, the active app will be used. Default: active app.\",\n valueName: \"name|bundle id\"\n ))\n var name: String?\n\n @Flag(help: \"Show toast notification\")\n var showNotification = false\n\n func run() throws {\n switch action {\n case .float:\n sendCommand(.floatApp(app: name, showNotification: showNotification))\n case .unfloat:\n sendCommand(.unfloatApp(app: name, showNotification: showNotification))\n case .toggle:\n sendCommand(.toggleFloatApp(app: name, showNotification: showNotification))\n }\n\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/MainScreen/MainView.swift", "//\n// MainView.swift\n// FlashSpace\n//\n// Created by Wojciech Kulik on 19/01/2025.\n//\n\nimport AppKit\nimport SwiftUI\nimport SymbolPicker\n\nstruct MainView: View {\n @StateObject var viewModel = MainViewModel()\n\n var body: some View {\n HStack(spacing: 16.0) {\n workspaces\n assignedApps\n WorkspaceConfigurationView(viewModel: viewModel)\n .frame(maxWidth: 230)\n }\n .padding()\n .fixedSize()\n .sheet(isPresented: $viewModel.isInputDialogPresented) {\n InputDialog(\n title: \"Enter workspace name:\",\n userInput: $viewModel.userInput,\n isPresented: $viewModel.isInputDialogPresented\n )\n }\n .sheet(isPresented: $viewModel.isSymbolPickerPresented) {\n SymbolPicker(symbol: $viewModel.workspaceSymbolIconName)\n }\n }\n\n private var workspaces: some View {\n VStack(alignment: .leading) {\n Text(\"Workspaces:\")\n\n List(\n $viewModel.workspaces,\n id: \\.self,\n editActions: .move,\n selection: $viewModel.selectedWorkspaces\n ) { binding in\n WorkspaceCell(\n selectedApps: $viewModel.selectedApps,\n workspace: binding.wrappedValue\n )\n }\n .frame(width: 200, height: 350)\n\n HStack {\n Button(action: viewModel.addWorkspace) {\n Image(systemName: \"plus\")\n }\n\n Button(action: viewModel.deleteSelectedWorkspaces) {\n Image(systemName: \"trash\")\n }.disabled(viewModel.selectedWorkspaces.isEmpty)\n\n Spacer()\n }\n }\n }\n\n private var assignedApps: some View {\n VStack(alignment: .leading) {\n Text(\"Assigned Apps:\")\n\n List(\n viewModel.workspaceApps ?? [],\n id: \\.self,\n selection: $viewModel.selectedApps\n ) { app in\n AppCell(\n workspaceId: viewModel.selectedWorkspace?.id ?? UUID(),\n app: app\n )\n }\n .frame(width: 200, height: 350)\n\n HStack {\n Button(action: viewModel.addApp) {\n Image(systemName: \"plus\")\n }.disabled(viewModel.selectedWorkspace == nil)\n\n Button(action: viewModel.deleteSelectedApps) {\n Image(systemName: \"trash\")\n }\n .disabled(viewModel.selectedApps.isEmpty)\n .keyboardShortcut(.delete)\n }\n }\n }\n}\n\n#Preview {\n MainView()\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/SpaceControl/SpaceControlSettingsView.swift", "//\n// SpaceControlSettingsView.swift\n//\n// Created by Wojciech Kulik on 11/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct SpaceControlSettingsView: View {\n @StateObject var settings = AppDependencies.shared.spaceControlSettings\n @State var hasScreenRecordingPermissions = false\n\n var body: some View {\n Form {\n Section {\n Toggle(\"Enable Space Control\", isOn: $settings.enableSpaceControl)\n }\n\n Group {\n Section(\"Permissions\") {\n HStack {\n if hasScreenRecordingPermissions {\n Image(systemName: \"checkmark.circle.fill\")\n .foregroundColor(.green)\n Text(\"Screen Recording Permission\")\n Spacer()\n } else {\n Image(systemName: \"xmark.circle.fill\")\n .foregroundColor(.red)\n Text(\"Screen Recording Permission\")\n Spacer()\n Button(\"Open Privacy & Security\") {\n NSWorkspace.shared.open(\n URL(string: \"x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture\")!\n )\n }\n }\n }\n Text(\n \"FlashSpace requires screen recording access to show your workspaces in Space Control. \" +\n \"The preview will be displayed upon first activation of the workspace.\"\n )\n .foregroundColor(.secondary)\n .font(.callout)\n }\n\n Section(\"Shortcuts\") {\n hotkey(\"Toggle Space Control\", for: $settings.showSpaceControl)\n }\n\n Section(\"Appearance\") {\n Toggle(\"Enable Animations\", isOn: $settings.enableSpaceControlAnimations)\n Toggle(\n \"Show Workspaces For Current Display Only\",\n isOn: $settings.spaceControlCurrentDisplayWorkspaces\n )\n\n HStack {\n Text(\"Max Number Of Columns\")\n Spacer()\n Text(\"\\(settings.spaceControlMaxColumns)\")\n Stepper(\n \"\",\n value: $settings.spaceControlMaxColumns,\n in: 2...20,\n step: 1\n ).labelsHidden()\n }\n }\n }\n .disabled(!settings.enableSpaceControl)\n .opacity(settings.enableSpaceControl ? 1 : 0.5)\n }\n .onAppear {\n hasScreenRecordingPermissions = PermissionsManager.shared.checkForScreenRecordingPermissions()\n }\n .onReceive(NotificationCenter.default.publisher(for: NSApplication.didBecomeActiveNotification)) { _ in\n hasScreenRecordingPermissions = PermissionsManager.shared.checkForScreenRecordingPermissions()\n }\n .formStyle(.grouped)\n .navigationTitle(\"Space Control\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Models/CreateWorkspaceRequest.swift", "//\n// CreateWorkspaceRequest.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\n\nstruct CreateWorkspaceRequest: Codable {\n let name: String\n let display: String?\n let icon: String?\n let activateKey: String?\n let assignKey: String?\n let activate: Bool\n}\n\nextension CreateWorkspaceRequest {\n var toWorkspace: Workspace {\n Workspace(\n id: .init(),\n name: name,\n display: display ?? NSScreen.main?.localizedName ?? \"\",\n activateShortcut: activateKey.flatMap { .init(value: $0) },\n assignAppShortcut: assignKey.flatMap { .init(value: $0) },\n apps: [],\n appToFocus: nil,\n symbolIconName: icon\n )\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Models/CommandRequest.swift", "//\n// CommandRequest.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nenum CommandRequest: Codable {\n case createWorkspace(CreateWorkspaceRequest)\n case deleteWorkspace(name: String)\n case updateWorkspace(UpdateWorkspaceRequest)\n case activateWorkspace(name: String?, number: Int?, clean: Bool)\n case nextWorkspace(skipEmpty: Bool, clean: Bool, loop: Bool)\n case previousWorkspace(skipEmpty: Bool, clean: Bool, loop: Bool)\n case recentWorkspace(clean: Bool)\n\n case assignVisibleApps(workspaceName: String?, showNotification: Bool)\n case assignApp(app: String?, workspaceName: String?, activate: Bool?, showNotification: Bool)\n case unassignApp(app: String?, showNotification: Bool)\n case hideUnassignedApps\n\n case floatApp(app: String?, showNotification: Bool)\n case unfloatApp(app: String?, showNotification: Bool)\n case toggleFloatApp(app: String?, showNotification: Bool)\n\n case focusWindow(direction: FocusDirection)\n case focusNextWindow\n case focusPreviousWindow\n case focusNextApp\n case focusPreviousApp\n\n case createProfile(name: String, copy: Bool, activate: Bool)\n case deleteProfile(name: String)\n case activateProfile(name: String)\n\n case openSpaceControl\n\n case listProfiles\n case listWorkspaces(withDisplay: Bool, profile: String?)\n case listApps(\n workspace: String,\n profile: String?,\n withBundleId: Bool,\n withIcon: Bool,\n onlyRunning: Bool\n )\n case listFloatingApps(withBundleId: Bool)\n\n case getProfile\n case getWorkspace(display: String?)\n case getApp(withWindowsCount: Bool)\n case getDisplay\n}\n\nenum FocusDirection: String, Codable {\n case left, right, up, down\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/SettingsRepository.swift", "//\n// SettingsRepository.swift\n//\n// Created by Wojciech Kulik on 23/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nfinal class SettingsRepository: ObservableObject {\n private(set) var generalSettings: GeneralSettings\n private(set) var menuBarSettings: MenuBarSettings\n private(set) var gesturesSettings: GesturesSettings\n private(set) var focusManagerSettings: FocusManagerSettings\n private(set) var workspaceSettings: WorkspaceSettings\n private(set) var floatingAppsSettings: FloatingAppsSettings\n private(set) var spaceControlSettings: SpaceControlSettings\n private(set) var integrationsSettings: IntegrationsSettings\n\n private lazy var allSettings: [SettingsProtocol] = [\n generalSettings,\n menuBarSettings,\n gesturesSettings,\n focusManagerSettings,\n workspaceSettings,\n floatingAppsSettings,\n spaceControlSettings,\n integrationsSettings\n ]\n\n private var currentSettings = AppSettings()\n private var cancellables = Set()\n private var shouldUpdate = false\n\n init(\n generalSettings: GeneralSettings,\n menuBarSettings: MenuBarSettings,\n gesturesSettings: GesturesSettings,\n focusManagerSettings: FocusManagerSettings,\n workspaceSettings: WorkspaceSettings,\n floatingAppsSettings: FloatingAppsSettings,\n spaceControlSettings: SpaceControlSettings,\n integrationsSettings: IntegrationsSettings\n ) {\n self.generalSettings = generalSettings\n self.menuBarSettings = menuBarSettings\n self.gesturesSettings = gesturesSettings\n self.focusManagerSettings = focusManagerSettings\n self.workspaceSettings = workspaceSettings\n self.floatingAppsSettings = floatingAppsSettings\n self.spaceControlSettings = spaceControlSettings\n self.integrationsSettings = integrationsSettings\n\n loadFromDisk()\n\n Publishers.MergeMany(allSettings.map(\\.updatePublisher))\n .sink { [weak self] in self?.updateSettings() }\n .store(in: &cancellables)\n }\n\n func saveToDisk() {\n Logger.log(\"Saving settings to disk\")\n try? ConfigSerializer.serialize(filename: \"settings\", currentSettings)\n }\n\n private func updateSettings() {\n guard shouldUpdate else { return }\n\n var settings = AppSettings()\n allSettings.forEach { $0.update(&settings) }\n currentSettings = settings\n saveToDisk()\n\n AppDependencies.shared.hotKeysManager.refresh()\n objectWillChange.send()\n }\n\n private func loadFromDisk() {\n Logger.log(\"Loading settings from disk\")\n\n shouldUpdate = false\n defer { shouldUpdate = true }\n\n guard let settings = try? ConfigSerializer.deserialize(\n AppSettings.self,\n filename: \"settings\"\n ) else { return }\n\n currentSettings = settings\n allSettings.forEach { $0.load(from: settings) }\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Models/CommandRequest.swift", "//\n// CommandRequest.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nenum CommandRequest: Codable {\n case createWorkspace(CreateWorkspaceRequest)\n case deleteWorkspace(name: String)\n case updateWorkspace(UpdateWorkspaceRequest)\n case activateWorkspace(name: String?, number: Int?, clean: Bool)\n case nextWorkspace(skipEmpty: Bool, clean: Bool, loop: Bool)\n case previousWorkspace(skipEmpty: Bool, clean: Bool, loop: Bool)\n case hideUnassignedApps\n case recentWorkspace(clean: Bool)\n\n case assignVisibleApps(workspaceName: String?, showNotification: Bool)\n case assignApp(app: String?, workspaceName: String?, activate: Bool?, showNotification: Bool)\n case unassignApp(app: String?, showNotification: Bool)\n\n case floatApp(app: String?, showNotification: Bool)\n case unfloatApp(app: String?, showNotification: Bool)\n case toggleFloatApp(app: String?, showNotification: Bool)\n\n case focusWindow(direction: FocusDirection)\n case focusNextWindow\n case focusPreviousWindow\n case focusNextApp\n case focusPreviousApp\n\n case createProfile(name: String, copy: Bool, activate: Bool)\n case deleteProfile(name: String)\n case activateProfile(name: String)\n\n case openSpaceControl\n\n case listProfiles\n case listWorkspaces(withDisplay: Bool, profile: String?)\n case listApps(\n workspace: String,\n profile: String?,\n withBundleId: Bool,\n withIcon: Bool,\n onlyRunning: Bool\n )\n case listFloatingApps(withBundleId: Bool)\n\n case getProfile\n case getWorkspace(display: String?)\n case getApp(withWindowsCount: Bool)\n case getDisplay\n}\n\nenum FocusDirection: String, Codable, ExpressibleByArgument, CaseIterable {\n case left, right, up, down\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/App/AssignAppCommand.swift", "//\n// AssignAppCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct AssignAppCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"assign-app\",\n abstract: \"Assign an app to a workspace\"\n )\n\n @Option(help: .init(\n \"The name of the app or bundle id. If not provided, the active app will be assigned. Default: active app.\",\n valueName: \"name|bundle id\"\n ))\n var name: String?\n\n @Option(\n name: .customLong(\"workspace\"),\n help: .init(\"The name of the workspace to assign the app to. Default: active workspace.\", valueName: \"name\")\n )\n var workspace: String?\n\n @Option(help: .init(\n \"Activate the workspace. Default: from app settings.\",\n valueName: \"true|false\"\n ))\n var activate: Bool?\n\n @Flag(help: \"Show toast notification\")\n var showNotification = false\n\n func run() throws {\n sendCommand(\n .assignApp(\n app: name,\n workspaceName: workspace,\n activate: activate,\n showNotification: showNotification\n )\n )\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Integrations/IntegrationsSettingsView.swift", "//\n// IntegrationsSettingsView.swift\n//\n// Created by Wojciech Kulik on 24/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct IntegrationsSettingsView: View {\n @StateObject var settings = AppDependencies.shared.integrationsSettings\n\n var body: some View {\n Form {\n Section {\n Toggle(\"Enable Integrations\", isOn: $settings.enableIntegrations)\n }\n\n Section(\"Scripts To Run\") {\n HStack {\n Text(\"On App Launch\")\n TextField(\"\", text: $settings.runScriptOnLaunch)\n .foregroundColor(.secondary)\n .standardPlaceholder(settings.runScriptOnLaunch.isEmpty)\n }\n\n HStack {\n Text(\"On Workspace Change\")\n TextField(\"\", text: $settings.runScriptOnWorkspaceChange)\n .foregroundColor(.secondary)\n .standardPlaceholder(settings.runScriptOnWorkspaceChange.isEmpty)\n }\n\n HStack {\n Text(\"On Profile Change\")\n TextField(\"\", text: $settings.runScriptOnProfileChange)\n .foregroundColor(.secondary)\n .standardPlaceholder(settings.runScriptOnProfileChange.isEmpty)\n }\n\n Text(\n \"\"\"\n $WORKSPACE will be replaced with the active workspace name\n $WORKSPACE_NUMBER will be replaced with the active workspace number\n $DISPLAY will be replaced with the corresponding display name\n $PROFILE will be replaced with the active profile name\n \"\"\"\n )\n .foregroundStyle(.secondary)\n .font(.callout)\n }\n .disabled(!settings.enableIntegrations)\n .opacity(settings.enableIntegrations ? 1 : 0.5)\n }\n .formStyle(.grouped)\n .navigationTitle(\"Integrations\")\n }\n}\n"], ["/FlashSpace/FlashSpace/App/Migrations.swift", "//\n// Migrations.swift\n//\n// Created by Wojciech Kulik on 08/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nenum Migrations {\n static var appsMigrated = false\n static var hotKeysMigrated = false\n\n static func migrateIfNeeded(\n settingsRepository: SettingsRepository,\n profilesRepository: ProfilesRepository\n ) {\n if Migrations.appsMigrated {\n Logger.log(\"Migrated apps\")\n\n let workspacesJsonUrl = FileManager.default\n .homeDirectoryForCurrentUser\n .appendingPathComponent(\".config/flashspace/workspaces.json\")\n try? FileManager.default.moveItem(\n at: workspacesJsonUrl,\n to: workspacesJsonUrl.deletingLastPathComponent()\n .appendingPathComponent(\"workspaces.json.bak\")\n )\n\n settingsRepository.saveToDisk()\n profilesRepository.saveToDisk()\n } else if Migrations.hotKeysMigrated {\n Logger.log(\"Migrated hot keys\")\n settingsRepository.saveToDisk()\n profilesRepository.saveToDisk()\n }\n\n Migrations.appsMigrated = false\n Migrations.hotKeysMigrated = false\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Models/CommandResponse.swift", "//\n// CommandResponse.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nstruct CommandResponse: Codable {\n var success: Bool\n var message: String?\n var error: String?\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Workspace/CreateWorkspaceCommand.swift", "//\n// CreateWorkspaceCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct CreateWorkspaceRequest: Codable {\n let name: String\n let display: String?\n let icon: String?\n let activateKey: String?\n let assignKey: String?\n let activate: Bool\n}\n\nstruct CreateWorkspaceCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"create-workspace\",\n abstract: \"Create a workspace\"\n )\n\n @Argument(help: \"The name of the workspace to create.\")\n var name: String\n\n @Option(help: .init(\"The name of the display\", valueName: \"name\"))\n var display: String?\n\n @Option(help: \"The name of the icon to use for the workspace. Must match SF Symbols.\")\n var icon: String?\n\n @Option(help: \"The hotkey to activate the workspace\")\n var activateKey: String?\n\n @Option(help: \"The hotkey to assign the app\")\n var assignKey: String?\n\n @Flag(help: \"Activate the new workspace\")\n var activate = false\n\n func run() throws {\n let request = CreateWorkspaceRequest(\n name: name,\n display: display,\n icon: icon,\n activateKey: activateKey,\n assignKey: assignKey,\n activate: activate\n )\n sendCommand(.createWorkspace(request))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/MainScreen/AppCell.swift", "//\n// AppCell.swift\n//\n// Created by Wojciech Kulik on 20/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct AppCell: View {\n let workspaceId: WorkspaceID\n let app: MacApp\n\n var body: some View {\n HStack {\n if let iconPath = app.iconPath, let image = NSImage(byReferencingFile: iconPath) {\n Image(nsImage: image)\n .resizable()\n .scaledToFit()\n .frame(width: 20, height: 20)\n }\n Text(app.name)\n .foregroundColor(app.bundleIdentifier.isEmpty ? .errorRed : .primary)\n }\n .draggable(MacAppWithWorkspace(app: app, workspaceId: workspaceId))\n }\n}\n"], ["/FlashSpace/FlashSpace/Accessibility/System.swift", "//\n// System.swift\n//\n// Created by Wojciech Kulik on 01/05/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nstruct AppWindow {\n let name: String\n let pid: pid_t\n}\n\nenum System {\n static var orderedWindows: [AppWindow] {\n let list = CGWindowListCopyWindowInfo(.optionOnScreenOnly, kCGNullWindowID) as? [[String: Any]]\n guard let list else { return [] }\n\n return list.compactMap {\n let windowName = $0[kCGWindowName as String] as? String\n let windowOwnerPID = $0[kCGWindowOwnerPID as String] as? pid_t\n if let windowOwnerPID {\n return AppWindow(name: windowName ?? \"-\", pid: windowOwnerPID)\n } else {\n return nil\n }\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/PictureInPicture/Models/PipBrowser.swift", "//\n// PipBrowser.swift\n//\n// Created by Wojciech Kulik on 12/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\n/// Browser apps that support Picture in Picture\nenum PipBrowser: String, CaseIterable {\n case chrome = \"com.google.Chrome\"\n case vivaldi = \"com.vivaldi.Vivaldi\"\n case brave = \"com.brave.Browser\"\n case opera = \"com.operasoftware.Opera\"\n case firefox = \"org.mozilla.firefox\"\n case zen = \"app.zen-browser.zen\"\n case arc = \"company.thebrowser.Browser\"\n case dia = \"company.thebrowser.dia\"\n case comet = \"ai.perplexity.comet\"\n\n var bundleId: String { rawValue }\n\n var title: String? {\n switch self {\n case .chrome, .vivaldi, .brave, .opera, .comet:\n return \"Picture in Picture\"\n case .zen, .firefox:\n return \"Picture-in-Picture\"\n case .arc, .dia:\n return nil\n }\n }\n\n var partialTitle: String? {\n switch self {\n case .chrome:\n return \"about:blank \"\n default:\n return nil\n }\n }\n\n var subrole: String? {\n switch self {\n case .arc, .dia:\n return (NSAccessibility.Subrole.systemDialog as CFString) as String\n default:\n return nil\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/CLI/CLISettingsView.swift", "//\n// CLISettingsView.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct CLISettingsView: View {\n @State var isInstalled = false\n @State var isRunning = false\n\n var body: some View {\n Form {\n Section(\"Status\") {\n HStack {\n if isRunning {\n Image(systemName: \"checkmark.circle.fill\")\n .foregroundColor(.green)\n Text(\"FlashSpace CLI Status\")\n Spacer()\n } else {\n Image(systemName: \"xmark.circle.fill\")\n .foregroundColor(.red)\n\n Text(\"FlashSpace CLI Status\")\n Spacer()\n Button(\"Restart\") {\n AppDependencies.shared.cliServer.restart()\n isRunning = AppDependencies.shared.cliServer.isRunning\n }\n }\n }\n\n HStack {\n if isInstalled {\n Image(systemName: \"checkmark.circle.fill\")\n .foregroundColor(.green)\n Text(\"FlashSpace CLI Installation\")\n Spacer()\n Button(\"Uninstall FlashSpace CLI\") {\n CLI.uninstall()\n isInstalled = CLI.isInstalled\n }\n } else {\n Image(systemName: \"xmark.circle.fill\")\n .foregroundColor(.red)\n Text(\"FlashSpace CLI Installation\")\n Spacer()\n Button(\"Install FlashSpace CLI\") {\n CLI.install()\n isInstalled = CLI.isInstalled\n }\n }\n }\n\n VStack(alignment: .leading) {\n Text(\n \"\"\"\n Tool will be installed in /usr/local/bin/flashspace.\n\n You can also access it directly from the app bundle at:\n \"\"\"\n )\n Text(CLI.cliPath)\n .lineLimit(1)\n .truncationMode(.middle)\n .help(CLI.cliPath)\n }\n .foregroundColor(.secondary)\n .font(.callout)\n }\n\n Section {\n Text(\"Run `flashspace --help` in the terminal to see the available commands.\")\n .foregroundStyle(.secondary)\n .font(.callout)\n }\n }\n .onAppear {\n isInstalled = CLI.isInstalled\n isRunning = AppDependencies.shared.cliServer.isRunning\n }\n .formStyle(.grouped)\n .navigationTitle(\"CLI\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/FloatingApps/FloatingAppsSettingsView.swift", "//\n// FloatingAppsSettingsView.swift\n//\n// Created by Wojciech Kulik on 12/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct FloatingAppsSettingsView: View {\n @StateObject var viewModel = FloatingAppsSettingsViewModel()\n @StateObject var settings = AppDependencies.shared.floatingAppsSettings\n\n var body: some View {\n Form {\n Section(header: header) {\n if settings.floatingApps.contains(where: \\.bundleIdentifier.isEmpty) {\n Text(\"Could not migrate some apps. Please re-add them to fix the problem.\")\n .foregroundStyle(.errorRed)\n .font(.callout)\n }\n\n if settings.floatingApps.isEmpty {\n Text(\"(no floating apps added)\")\n .foregroundStyle(.secondary)\n .font(.callout)\n } else {\n appsList\n }\n\n Text(\"Floating applications remain visible across all workspaces.\")\n .foregroundStyle(.secondary)\n .font(.callout)\n }\n\n Section(\"Shortcuts\") {\n hotkey(\"Float Focused App\", for: $settings.floatTheFocusedApp)\n hotkey(\"Unfloat Focused App\", for: $settings.unfloatTheFocusedApp)\n hotkey(\"Toggle Focused App Floating\", for: $settings.toggleTheFocusedAppFloating)\n }\n }\n .formStyle(.grouped)\n .navigationTitle(\"Floating Apps\")\n }\n\n private var appsList: some View {\n VStack(alignment: .leading) {\n ForEach(settings.floatingApps, id: \\.self) { app in\n HStack {\n Button {\n viewModel.deleteFloatingApp(app: app)\n } label: {\n Image(systemName: \"x.circle.fill\").opacity(0.8)\n }.buttonStyle(.borderless)\n\n Text(app.name)\n .foregroundStyle(app.bundleIdentifier.isEmpty ? .errorRed : .primary)\n }\n }\n }\n }\n\n private var header: some View {\n HStack {\n Text(\"Floating Apps\")\n Spacer()\n Button(action: viewModel.addFloatingApp) {\n Image(systemName: \"plus\")\n }\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/NSScreen.swift", "//\n// NSScreen.swift\n//\n// Created by Wojciech Kulik on 18/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension NSScreen {\n /// Returns the screen's frame where (x,y) is top-left corner relative\n /// to the main screen's top-left corner.\n var normalizedFrame: CGRect {\n let mainScreen = NSScreen.screens[0]\n return NSRect(\n x: frame.origin.x,\n y: mainScreen.frame.height - frame.origin.y - frame.height,\n width: frame.width,\n height: frame.height\n )\n }\n\n static func isConnected(_ display: DisplayName) -> Bool {\n NSScreen.screens.contains { $0.localizedName == display }\n }\n\n static func screen(_ display: DisplayName?) -> NSScreen? {\n NSScreen.screens.first { $0.localizedName == display }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/HotKeys/Models/KeyCodesMap.swift", "//\n// KeyCodesMap.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Carbon\n\nenum KeyCodesMap {\n private(set) static var toKeyCode = create()\n\n static let toString = toKeyCode.reduce(into: [RawKeyCode: String]()) { result, pair in\n result[pair.value] = pair.key\n\n for (alias, keyCode) in getAliases() {\n result[keyCode] = alias\n }\n }\n\n static subscript(key: String) -> RawKeyCode? { toKeyCode[key] }\n\n static func refresh() {\n toKeyCode = create()\n }\n\n private static func create() -> [String: RawKeyCode] {\n var stringToKeyCodes: [String: RawKeyCode] = [:]\n var currentKeyboard = TISCopyCurrentKeyboardInputSource().takeRetainedValue()\n var rawLayoutData = TISGetInputSourceProperty(currentKeyboard, kTISPropertyUnicodeKeyLayoutData)\n if rawLayoutData == nil {\n currentKeyboard = TISCopyCurrentASCIICapableKeyboardLayoutInputSource().takeUnretainedValue()\n rawLayoutData = TISGetInputSourceProperty(currentKeyboard, kTISPropertyUnicodeKeyLayoutData)\n }\n\n let layoutData = unsafeBitCast(rawLayoutData, to: CFData.self)\n let layout: UnsafePointer = unsafeBitCast(\n CFDataGetBytePtr(layoutData),\n to: UnsafePointer.self\n )\n\n var keysDown: UInt32 = 0\n var chars: [UniChar] = [0, 0, 0, 0]\n var realLength = 0\n\n for keyCode in 0..<128 {\n switch keyCode {\n case kVK_ANSI_Keypad0, kVK_ANSI_Keypad1, kVK_ANSI_Keypad2, kVK_ANSI_Keypad3,\n kVK_ANSI_Keypad4, kVK_ANSI_Keypad5, kVK_ANSI_Keypad6, kVK_ANSI_Keypad7,\n kVK_ANSI_Keypad8, kVK_ANSI_Keypad9,\n kVK_ANSI_KeypadMinus, kVK_ANSI_KeypadMultiply, kVK_ANSI_KeypadDivide,\n kVK_ANSI_KeypadDecimal, kVK_ANSI_KeypadClear, kVK_ANSI_KeypadEnter,\n kVK_ANSI_KeypadEquals, kVK_ANSI_KeypadPlus:\n continue\n default: break\n }\n\n UCKeyTranslate(\n layout,\n UInt16(keyCode),\n UInt16(kUCKeyActionDisplay),\n 0,\n UInt32(LMGetKbdType()),\n UInt32(kUCKeyTranslateNoDeadKeysBit),\n &keysDown,\n chars.count,\n &realLength,\n &chars\n )\n\n let string = CFStringCreateWithCharacters(kCFAllocatorDefault, chars, realLength) as String\n if !stringToKeyCodes.keys.contains(string) {\n stringToKeyCodes[string] = UInt16(keyCode)\n }\n }\n\n let aliases = getAliases()\n for (alias, keyCode) in aliases {\n stringToKeyCodes[alias] = keyCode\n }\n\n return stringToKeyCodes\n }\n\n private static func getAliases() -> [String: RawKeyCode] {\n [\n \"space\": UInt16(kVK_Space),\n \"enter\": UInt16(kVK_Return),\n \"up\": UInt16(kVK_UpArrow),\n \"right\": UInt16(kVK_RightArrow),\n \"down\": UInt16(kVK_DownArrow),\n \"left\": UInt16(kVK_LeftArrow),\n \"delete\": UInt16(kVK_Delete),\n \"forward-delete\": UInt16(kVK_ForwardDelete),\n \"escape\": UInt16(kVK_Escape),\n \"tab\": UInt16(kVK_Tab),\n \"capslock\": UInt16(kVK_CapsLock),\n \"f1\": UInt16(kVK_F1),\n \"f2\": UInt16(kVK_F2),\n \"f3\": UInt16(kVK_F3),\n \"f4\": UInt16(kVK_F4),\n \"f5\": UInt16(kVK_F5),\n \"f6\": UInt16(kVK_F6),\n \"f7\": UInt16(kVK_F7),\n \"f8\": UInt16(kVK_F8),\n \"f9\": UInt16(kVK_F9),\n \"f10\": UInt16(kVK_F10),\n \"f11\": UInt16(kVK_F11),\n \"f12\": UInt16(kVK_F12),\n \"num0\": UInt16(kVK_ANSI_Keypad0),\n \"num1\": UInt16(kVK_ANSI_Keypad1),\n \"num2\": UInt16(kVK_ANSI_Keypad2),\n \"num3\": UInt16(kVK_ANSI_Keypad3),\n \"num4\": UInt16(kVK_ANSI_Keypad4),\n \"num5\": UInt16(kVK_ANSI_Keypad5),\n \"num6\": UInt16(kVK_ANSI_Keypad6),\n \"num7\": UInt16(kVK_ANSI_Keypad7),\n \"num8\": UInt16(kVK_ANSI_Keypad8),\n \"num9\": UInt16(kVK_ANSI_Keypad9),\n \"num-plus\": UInt16(kVK_ANSI_KeypadPlus),\n \"num-minus\": UInt16(kVK_ANSI_KeypadMinus),\n \"num-multiply\": UInt16(kVK_ANSI_KeypadMultiply),\n \"num-divide\": UInt16(kVK_ANSI_KeypadDivide),\n \"num-clear\": UInt16(kVK_ANSI_KeypadClear),\n \"num-enter\": UInt16(kVK_ANSI_KeypadEnter),\n \"num-equals\": UInt16(kVK_ANSI_KeypadEquals),\n \"num-decimal\": UInt16(kVK_ANSI_KeypadDecimal)\n ]\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/FloatingApps/FloatingAppsSettingsViewModel.swift", "import Foundation\nimport SwiftUI\n\nfinal class FloatingAppsSettingsViewModel: ObservableObject {\n private let settings = AppDependencies.shared.floatingAppsSettings\n\n func addFloatingApp() {\n let fileChooser = FileChooser()\n let appUrl = fileChooser.runModalOpenPanel(\n allowedFileTypes: [.application],\n directoryURL: URL(filePath: \"/Applications\")\n )\n\n guard let bundle = appUrl?.bundle else { return }\n\n settings.addFloatingAppIfNeeded(\n app: .init(\n name: bundle.localizedAppName,\n bundleIdentifier: bundle.bundleIdentifier ?? \"\",\n iconPath: bundle.iconPath\n )\n )\n }\n\n func deleteFloatingApp(app: MacApp) {\n settings.deleteFloatingApp(app: app)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/FocusManager/FocusSettingsView.swift", "//\n// FocusSettingsView.swift\n//\n// Created by Wojciech Kulik on 23/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct FocusSettingsView: View {\n @StateObject private var settings = AppDependencies.shared.focusManagerSettings\n\n var body: some View {\n Form {\n Section {\n Toggle(\"Enable Focus Manager\", isOn: $settings.enableFocusManagement)\n }\n\n Group {\n Section(\"Trigger when focus is changed using shortcuts\") {\n Toggle(\"Center Cursor In Focused App\", isOn: $settings.centerCursorOnFocusChange)\n }\n\n Section(\"Shortcuts\") {\n hotkey(\"Focus Left\", for: $settings.focusLeft)\n hotkey(\"Focus Right\", for: $settings.focusRight)\n hotkey(\"Focus Up\", for: $settings.focusUp)\n hotkey(\"Focus Down\", for: $settings.focusDown)\n }\n\n Section {\n hotkey(\"Focus Next App\", for: $settings.focusNextWorkspaceApp)\n hotkey(\"Focus Previous App\", for: $settings.focusPreviousWorkspaceApp)\n }\n\n Section {\n hotkey(\"Focus Next Window\", for: $settings.focusNextWorkspaceWindow)\n hotkey(\"Focus Previous Window\", for: $settings.focusPreviousWorkspaceWindow)\n }\n\n Section(\"Experimental\") {\n Toggle(\"Focus Frontmost Window\", isOn: $settings.focusFrontmostWindow)\n Text(\n \"This is an experimental feature. It sets the focus to the frontmost window\" +\n \" if two or more windows are overlapping in the pointed direction.\\n\\n\" +\n \"It works only with directional focus shortcuts (left, right, up, down).\"\n )\n .foregroundStyle(.secondary)\n .font(.callout)\n }\n }\n .disabled(!settings.enableFocusManagement)\n .opacity(settings.enableFocusManagement ? 1 : 0.5)\n }\n .formStyle(.grouped)\n .navigationTitle(\"Focus Manager\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/SettingsView.swift", "//\n// SettingsView.swift\n//\n// Created by Wojciech Kulik on 23/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct SettingsView: View {\n @State private var selectedTab = \"General\"\n\n var body: some View {\n NavigationSplitView(columnVisibility: .constant(.doubleColumn), sidebar: {\n sideMenu\n .frame(width: 200)\n .navigationSplitViewColumnWidth(200.0)\n }, detail: {\n details\n .frame(maxHeight: .infinity, alignment: .top)\n .navigationSplitViewColumnWidth(min: 440, ideal: 440)\n })\n .frame(width: 780, height: 490)\n }\n\n private var sideMenu: some View {\n VStack {\n List(selection: $selectedTab) {\n Label(\"General\", systemImage: \"gearshape\")\n .tag(\"General\")\n Label(\"Menu Bar\", systemImage: \"contextualmenu.and.cursorarrow\")\n .tag(\"MenuBar\")\n Label(\"Gestures\", systemImage: \"hand.draw\")\n .tag(\"Gestures\")\n Label(\"Workspaces\", systemImage: \"square.stack.3d.up\")\n .tag(\"Workspaces\")\n Label(\"Floating Apps\", systemImage: \"pip\")\n .tag(\"FloatingApps\")\n Label(\"Focus Manager\", systemImage: \"macwindow.on.rectangle\")\n .tag(\"Focus\")\n Label(\"Space Control\", systemImage: \"rectangle.split.2x2\")\n .tag(\"SpaceControl\")\n Label(\"Profiles\", systemImage: \"person.2\")\n .tag(\"Profiles\")\n Label(\"Integrations\", systemImage: \"link\")\n .tag(\"Integrations\")\n Label(\"Configuration File\", systemImage: \"doc.text\")\n .tag(\"Configuration\")\n Label(\"CLI\", systemImage: \"apple.terminal\")\n .tag(\"CLI\")\n Label(\"Acknowledgements\", systemImage: \"info.circle\")\n .tag(\"Acknowledgements\")\n Label(\"About\", systemImage: \"person\")\n .tag(\"About\")\n }\n .toolbar(removing: .sidebarToggle)\n .listStyle(.sidebar)\n\n Spacer()\n\n Text(\"FlashSpace v\\(AppConstants.version)\")\n .foregroundStyle(.secondary)\n .padding(.bottom)\n }\n }\n\n @ViewBuilder\n private var details: some View {\n switch selectedTab {\n case \"General\":\n GeneralSettingsView()\n case \"MenuBar\":\n MenuBarSettingsView()\n case \"Focus\":\n FocusSettingsView()\n case \"Gestures\":\n GesturesSettingsView()\n case \"Workspaces\":\n WorkspacesSettingsView()\n case \"FloatingApps\":\n FloatingAppsSettingsView()\n case \"SpaceControl\":\n SpaceControlSettingsView()\n case \"Integrations\":\n IntegrationsSettingsView()\n case \"Profiles\":\n ProfilesSettingsView()\n case \"Configuration\":\n ConfigurationFileSettingsView()\n case \"CLI\":\n CLISettingsView()\n case \"Acknowledgements\":\n AcknowledgementsSettingsView()\n case \"About\":\n AboutSettingsView()\n default:\n EmptyView()\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/App/AppDelegate.swift", "//\n// AppDelegate.swift\n//\n// Created by Wojciech Kulik on 13/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Combine\nimport SwiftUI\n\nfinal class AppDelegate: NSObject, NSApplicationDelegate {\n @Environment(\\.openWindow) private var openWindow\n @Environment(\\.dismissWindow) private var dismissWindow\n\n private var cancellables = Set()\n\n func applicationDidFinishLaunching(_ notification: Notification) {\n AppDependencies.shared.hotKeysManager.enableAll()\n\n NotificationCenter.default\n .publisher(for: .openMainWindow)\n .sink { [weak self] _ in\n self?.openWindow(id: \"main\")\n NSApp.activate(ignoringOtherApps: true)\n }\n .store(in: &cancellables)\n\n #if DEBUG\n dismissWindow(id: \"main\")\n #endif\n }\n\n func applicationWillTerminate(_ notification: Notification) {\n AppDependencies.shared.pictureInPictureManager.restoreAllWindows()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/FlashSpaceCLI.swift", "//\n// FlashSpaceCLI.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\n@main\nstruct FlashSpaceCLI: ParsableCommand {\n static let configuration: CommandConfiguration = .init(\n commandName: \"flashspace\",\n abstract: \"FlashSpace CLI\",\n version: \"1.0.0\",\n groupedSubcommands: [\n .init(\n name: \"Profile\",\n subcommands: [\n CreateProfileCommand.self,\n DeleteProfileCommand.self,\n ProfileCommand.self\n ]\n ),\n .init(\n name: \"Workspace\",\n subcommands: [\n CreateWorkspaceCommand.self,\n DeleteWorkspaceCommand.self,\n UpdateWorkspaceCommand.self,\n WorkspaceCommand.self\n ]\n ),\n .init(\n name: \"App\",\n subcommands: [\n AssignVisibleAppsCommand.self,\n AssignAppCommand.self,\n UnassignAppCommand.self,\n HideUnassignedAppsCommand.self,\n FocusCommand.self,\n FloatingAppsCommand.self\n ]\n ),\n .init(\n name: \"List\",\n subcommands: [\n ListProfilesCommand.self,\n ListWorkspacesCommand.self,\n ListAppsCommand.self,\n ListFloatingAppsCommand.self,\n ListRunningAppsCommand.self,\n ListDisplaysCommand.self\n ]\n ),\n .init(\n name: \"Get\",\n subcommands: [\n GetProfileCommand.self,\n GetWorkspaceCommand.self,\n GetAppCommand.self,\n GetDisplayCommand.self\n ]\n ),\n .init(\n name: \"Open\",\n subcommands: [\n OpenAppCommand.self,\n OpenSpaceControlCommand.self\n ]\n )\n ]\n )\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/ConfigurationFile/ConfigurationFileSettingsView.swift", "//\n// ConfigurationFileSettingsView.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport SwiftUI\n\nstruct ConfigurationFileSettingsView: View {\n @State var configFormat: ConfigFormat = ConfigSerializer.format\n\n var body: some View {\n Form {\n Section {\n Picker(\"Format\", selection: $configFormat) {\n ForEach(ConfigFormat.allCases, id: \\.rawValue) { format in\n Text(format.displayName).tag(format)\n }\n }.onChange(of: configFormat) { _, newFormat in\n try? ConfigSerializer.convert(to: newFormat)\n }\n\n HStack {\n Text(\"Location: \\(ConfigSerializer.configDirectory.path)\")\n .foregroundStyle(.secondary)\n .font(.callout)\n Spacer()\n Button(\"Reveal\") {\n NSWorkspace.shared.open(ConfigSerializer.configDirectory)\n }\n }\n\n Text(\n \"If you manually edit the configuration file, make sure to restart FlashSpace.\\n\" +\n \"Custom formatting, order, comments, etc. will be overwritten if you change something in the app.\"\n )\n .foregroundStyle(.secondary)\n .font(.callout)\n }\n }\n .formStyle(.grouped)\n .navigationTitle(\"Configuration File\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Models/CommandExecutor.swift", "//\n// CommandExecutor.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nprotocol CommandExecutor {\n func execute(command: CommandRequest) -> CommandResponse?\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Get/GetDisplayCommand.swift", "//\n// GetDisplayCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport ArgumentParser\nimport Foundation\n\nstruct GetDisplayCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"get-display\",\n abstract: \"Get active display\"\n )\n\n func run() throws {\n sendCommand(.getDisplay)\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/CGRect.swift", "//\n// CGRect.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension CGRect {\n func getDisplay() -> String? {\n NSScreen.screens\n .first { $0.normalizedFrame.contains(.init(x: self.midX, y: self.midY)) }?\n .localizedName\n }\n\n func verticalIntersect(with rect: CGRect) -> Bool {\n var rect = rect\n rect.origin.x = origin.x\n\n return intersects(rect)\n }\n\n func horizontalIntersect(with rect: CGRect) -> Bool {\n var rect = rect\n rect.origin.y = origin.y\n\n return intersects(rect)\n }\n\n func distance(to rect: CGRect) -> CGFloat {\n let x = midX - rect.midX\n let y = midY - rect.midY\n\n return sqrt(x * x + y * y)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/MenuBar/MenuBarSettingsView.swift", "//\n// MenuBarSettingsView.swift\n//\n// Created by Wojciech Kulik on 31/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct MenuBarSettingsView: View {\n @StateObject var settings = AppDependencies.shared.menuBarSettings\n\n var body: some View {\n Form {\n Section {\n Toggle(\"Show Title\", isOn: $settings.showMenuBarTitle)\n Toggle(\"Show Icon\", isOn: $settings.showMenuBarIcon)\n .disabled(!settings.showMenuBarTitle)\n\n HStack {\n Text(\"Title Template\")\n TextField(\"\", text: $settings.menuBarTitleTemplate)\n .foregroundColor(.secondary)\n .standardPlaceholder(settings.menuBarTitleTemplate.isEmpty)\n }\n .disabled(!settings.showMenuBarTitle)\n .opacity(settings.showMenuBarTitle ? 1 : 0.5)\n\n Text(\n \"\"\"\n $WORKSPACE will be replaced with the active workspace name\n $WORKSPACE_NUMBER will be replaced with the active workspace number\n $DISPLAY will be replaced with the corresponding display name\n $PROFILE will be replaced with the active profile name\n \"\"\"\n )\n .foregroundStyle(.secondary)\n .font(.callout)\n .opacity(settings.showMenuBarTitle ? 1 : 0.5)\n }\n\n Section {\n HStack {\n Text(\"Display Aliases\")\n TextField(\"\", text: $settings.menuBarDisplayAliases)\n .foregroundColor(.secondary)\n .standardPlaceholder(settings.menuBarDisplayAliases.isEmpty)\n }\n .disabled(!settings.showMenuBarTitle)\n .opacity(settings.showMenuBarTitle ? 1 : 0.5)\n\n Text(\"Example: DELL U2723QE=Secondary;Built-in Retina Display=Main\")\n .foregroundStyle(.secondary)\n .font(.callout)\n .opacity(settings.showMenuBarTitle ? 1 : 0.5)\n }\n }\n .formStyle(.grouped)\n .navigationTitle(\"Menu Bar\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Integrations/IntegrationsSettings.swift", "//\n// IntegrationsSettings.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nfinal class IntegrationsSettings: ObservableObject {\n static let defaultWorkspaceChangeScript = \"sketchybar --trigger flashspace_workspace_change WORKSPACE=\\\"$WORKSPACE\\\" DISPLAY=\\\"$DISPLAY\\\"\"\n static let defaultProfileChangeScript = \"sketchybar --reload\"\n\n @Published var enableIntegrations = false\n @Published var runScriptOnLaunch = \"\"\n @Published var runScriptOnWorkspaceChange = IntegrationsSettings.defaultWorkspaceChangeScript\n @Published var runScriptOnProfileChange = IntegrationsSettings.defaultProfileChangeScript\n\n private var observer: AnyCancellable?\n private let updateSubject = PassthroughSubject<(), Never>()\n\n init() {\n observe()\n\n DispatchQueue.main.async {\n Integrations.runOnAppLaunchIfNeeded()\n }\n }\n\n private func observe() {\n observer = Publishers.MergeMany(\n $enableIntegrations.settingsPublisher(),\n $runScriptOnWorkspaceChange.settingsPublisher(debounce: true),\n $runScriptOnLaunch.settingsPublisher(debounce: true),\n $runScriptOnProfileChange.settingsPublisher(debounce: true)\n )\n .receive(on: DispatchQueue.main)\n .sink { [weak self] in self?.updateSubject.send() }\n }\n}\n\nextension IntegrationsSettings: SettingsProtocol {\n var updatePublisher: AnyPublisher<(), Never> {\n updateSubject.eraseToAnyPublisher()\n }\n\n func load(from appSettings: AppSettings) {\n observer = nil\n enableIntegrations = appSettings.enableIntegrations ?? false\n runScriptOnLaunch = appSettings.runScriptOnLaunch ?? \"\"\n runScriptOnWorkspaceChange = appSettings.runScriptOnWorkspaceChange ?? Self.defaultWorkspaceChangeScript\n runScriptOnProfileChange = appSettings.runScriptOnProfileChange ?? Self.defaultProfileChangeScript\n observe()\n }\n\n func update(_ appSettings: inout AppSettings) {\n appSettings.enableIntegrations = enableIntegrations\n appSettings.runScriptOnLaunch = runScriptOnLaunch\n appSettings.runScriptOnWorkspaceChange = runScriptOnWorkspaceChange\n appSettings.runScriptOnProfileChange = runScriptOnProfileChange\n }\n}\n"], ["/FlashSpace/FlashSpace/Utils/FileChooser.swift", "//\n// FileChooser.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\nimport UniformTypeIdentifiers\n\nfinal class FileChooser {\n func runModalOpenPanel(allowedFileTypes: [UTType]?, directoryURL: URL?) -> URL? {\n let openPanel = NSOpenPanel()\n openPanel.canChooseFiles = true\n openPanel.allowedContentTypes = allowedFileTypes ?? []\n openPanel.directoryURL = directoryURL\n\n return openPanel.runModal() == .OK ? openPanel.url : nil\n }\n\n func runModalSavePanel(allowedFileTypes: [UTType]?, defaultFileName: String?) -> URL? {\n let savePanel = NSSavePanel()\n savePanel.allowsOtherFileTypes = false\n savePanel.canCreateDirectories = true\n savePanel.allowedContentTypes = allowedFileTypes ?? []\n savePanel.nameFieldStringValue = defaultFileName ?? \"\"\n\n return savePanel.runModal() == .OK ? savePanel.url : nil\n }\n\n @MainActor\n func runSheetModalOpenPanel(window: NSWindow, allowedFileTypes: [UTType]?, directoryURL: URL?) async -> URL? {\n let openPanel = NSOpenPanel()\n openPanel.canChooseFiles = true\n openPanel.allowedContentTypes = allowedFileTypes ?? []\n openPanel.directoryURL = directoryURL\n\n return await openPanel.beginSheetModal(for: window) == .OK ? openPanel.url : nil\n }\n\n @MainActor\n func runSheetModalSavePanel(window: NSWindow, allowedFileTypes: [UTType]?, defaultFileName: String?) async -> URL? {\n let savePanel = NSSavePanel()\n savePanel.allowsOtherFileTypes = false\n savePanel.canCreateDirectories = true\n savePanel.allowedContentTypes = allowedFileTypes ?? []\n savePanel.nameFieldStringValue = defaultFileName ?? \"\"\n\n return await savePanel.beginSheetModal(for: window) == .OK ? savePanel.url : nil\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/List/ListAppsCommand.swift", "//\n// ListAppsCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct ListAppsCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"list-apps\",\n abstract: \"List workspace apps\"\n )\n\n @Argument(help: \"Workspace name\")\n var workspace: String\n\n @Option(help: \"Profile name\")\n var profile: String?\n\n @Flag(help: \"Include bundle id\")\n var withBundleId = false\n\n @Flag(help: \"Include icon\")\n var withIcon = false\n\n @Flag(help: \"Only running apps\")\n var onlyRunning = false\n\n func run() throws {\n sendCommand(.listApps(\n workspace: workspace,\n profile: profile,\n withBundleId: withBundleId,\n withIcon: withIcon,\n onlyRunning: onlyRunning\n ))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/HotKeys/Extensions/AppHotKey+Shortcut.swift", "//\n// AppHotKey+Shortcut.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ShortcutRecorder\n\nextension [(AppHotKey, () -> ())] {\n func toShortcutPairs() -> [(Shortcut, () -> ())] {\n map { ($0.0.toShortcut(), $0.1) }\n .compactMap {\n guard let shortcut = $0.0 else { return nil }\n return (shortcut, $0.1)\n }\n }\n}\n\nextension AppHotKey {\n func toShortcut() -> Shortcut? {\n let components = value.components(separatedBy: \"+\")\n let modifiers = KeyModifiersMap.toModifiers(value)\n\n guard let keyEquivalent = components.last,\n let rawKeyCode = KeyCodesMap[keyEquivalent],\n let keyCode = KeyCode(rawValue: rawKeyCode) else { return nil }\n\n return Shortcut(\n code: keyCode,\n modifierFlags: NSEvent.ModifierFlags(rawValue: modifiers),\n characters: nil,\n charactersIgnoringModifiers: nil\n )\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Acknowledgements/AcknowledgementsSettingsView.swift", "//\n// AcknowledgementsSettingsView.swift\n//\n// Created by Wojciech Kulik on 26/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct AcknowledgementsSettingsView: View {\n @State private var selectedDependency: String? = \"xnth97/SymbolPicker\"\n @State private var dependencies = [\n \"xnth97/SymbolPicker\",\n \"Kentzo/ShortcutRecorder\",\n \"LebJe/TOMLKit\",\n \"jpsim/Yams\",\n \"sparkle-project/Sparkle\",\n \"apple/swift-argument-parser\",\n \"SwiftFormat\",\n \"SwiftLint\"\n ]\n\n var body: some View {\n VStack(spacing: 0.0) {\n List(\n dependencies,\n id: \\.self,\n selection: $selectedDependency\n ) { dependency in\n Text(dependency)\n }.frame(height: 130)\n\n ScrollView([.vertical, .horizontal]) {\n VStack {\n Group {\n switch selectedDependency {\n case \"xnth97/SymbolPicker\":\n Text(Licenses.symbolPicker)\n case \"Kentzo/ShortcutRecorder\":\n Text(Licenses.shortcutRecorder)\n case \"LebJe/TOMLKit\":\n Text(Licenses.tomlKit)\n case \"jpsim/Yams\":\n Text(Licenses.yams)\n case \"sparkle-project/Sparkle\":\n Text(Licenses.sparkle)\n case \"apple/swift-argument-parser\":\n Text(Licenses.swiftArgumentParser)\n case \"SwiftFormat\":\n Text(Licenses.swiftFormat)\n case \"SwiftLint\":\n Text(Licenses.swiftLint)\n default:\n EmptyView()\n }\n }\n .frame(minHeight: 330, alignment: .top)\n .textSelection(.enabled)\n .padding()\n }\n }\n }\n .navigationTitle(\"Acknowledgements\")\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Get/GetProfileCommand.swift", "//\n// GetProfileCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport ArgumentParser\nimport Foundation\n\nstruct GetProfileCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"get-profile\",\n abstract: \"Get active profile\"\n )\n\n func run() throws {\n sendCommand(.getProfile)\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/App/AssignVisibleAppsCommand.swift", "//\n// AssignVisibleAppsCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct AssignVisibleAppsCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"assign-visible-apps\",\n abstract: \"Assign visible apps to a workspace\"\n )\n\n @Option(\n name: .customLong(\"workspace\"),\n help: .init(\"The name of the workspace to assign apps to. Default: active workspace.\", valueName: \"name\")\n )\n var workspace: String?\n\n @Flag(help: \"Show toast notification\")\n var showNotification = false\n\n func run() throws {\n sendCommand(\n .assignVisibleApps(workspaceName: workspace, showNotification: showNotification)\n )\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Accessibility/AXUIElement+Properties.swift", "//\n// AXUIElement+Properties.swift\n//\n// Created by Wojciech Kulik on 24/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension AXUIElement {\n var id: String? { getAttribute(.identifier) }\n var title: String? { getAttribute(.title) }\n var isMain: Bool { getAttribute(.main) == true }\n var isMinimized: Bool { getAttribute(.minimized) == true }\n var role: String? { getAttribute(.role) }\n var subrole: String? { getAttribute(.subrole) }\n var enhancedUserInterface: Bool {\n get { getAttribute(.enchancedUserInterface) == true }\n set { setAttribute(.enchancedUserInterface, value: newValue) }\n }\n\n var processId: pid_t? {\n var pid: pid_t = 0\n AXUIElementGetPid(self, &pid)\n return pid\n }\n\n /// Frame is in window coordinates where (0,0) is top-left corner\n /// and it is relative to the main screen.\n var frame: CGRect? {\n var positionValue: CFTypeRef?\n var sizeValue: CFTypeRef?\n\n guard AXUIElementCopyAttributeValue(\n self,\n NSAccessibility.Attribute.position as CFString,\n &positionValue\n ) == .success else { return nil }\n\n guard AXUIElementCopyAttributeValue(\n self,\n NSAccessibility.Attribute.size as CFString,\n &sizeValue\n ) == .success else { return nil }\n\n var windowBounds: CGRect = .zero\n\n // swiftlint:disable force_cast\n if let position = positionValue, AXValueGetType(position as! AXValue) == .cgPoint {\n AXValueGetValue(position as! AXValue, .cgPoint, &windowBounds.origin)\n }\n\n if let size = sizeValue, AXValueGetType(size as! AXValue) == .cgSize {\n AXValueGetValue(size as! AXValue, .cgSize, &windowBounds.size)\n }\n // swiftlint:enable force_cast\n\n return windowBounds.isEmpty ? nil : windowBounds\n }\n}\n"], ["/FlashSpace/FlashSpace/UI/InputDialog.swift", "//\n// InputDialog.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct InputDialog: View {\n let title: String\n var placeholder = \"Type here...\"\n\n @Binding var userInput: String\n @Binding var isPresented: Bool\n\n var body: some View {\n VStack(alignment: .leading, spacing: 4.0) {\n Text(title)\n .font(.headline)\n\n TextField(placeholder, text: $userInput)\n .textFieldStyle(RoundedBorderTextFieldStyle())\n .padding(.vertical, 8.0)\n .onSubmit { isPresented = false }\n\n HStack {\n Spacer()\n Button(\"Cancel\") {\n userInput = \"\"\n isPresented = false\n }\n Button(\"OK\") { isPresented = false }\n }\n }\n .padding()\n .frame(width: 300, height: 110)\n .onKeyPress(.escape) {\n userInput = \"\"\n isPresented = false\n return .handled\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/About/AboutSettingsView.swift", "//\n// AboutSettingsView.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct AboutSettingsView: View {\n var body: some View {\n Form {\n Section(\"FlashSpace\") {\n HStack {\n Text(\"Version \\(AppConstants.version)\")\n Spacer()\n Button(\"GitHub\") { openGitHub(\"wojciech-kulik/FlashSpace\") }\n Button(\"Check for Updates\") { UpdatesManager.shared.checkForUpdates() }\n }\n }\n\n Section(\"Author\") {\n HStack {\n Text(\"Wojciech Kulik (@wojciech-kulik)\")\n Spacer()\n Button(\"GitHub\") { openGitHub(\"wojciech-kulik\") }\n Button(\"X.com\") { openUrl(\"https://x.com/kulik_wojciech\") }\n Button(\"snippety.app\") { openUrl(\"https://snippety.app\") }\n }\n }\n\n Section(\"Contributors\") {\n HStack {\n Text(\"Kwangmin Bae / Shirou (@PangMo5)\")\n Spacer()\n Button(\"GitHub\") { openGitHub(\"PangMo5\") }\n }\n HStack {\n Text(\"Sergio (@sergiopatino)\")\n Spacer()\n Button(\"GitHub\") { openGitHub(\"sergiopatino\") }\n }\n HStack {\n Text(\"Moritz Brödel (@brodmo)\")\n Spacer()\n Button(\"GitHub\") { openGitHub(\"brodmo\") }\n }\n }\n }\n .buttonStyle(.accessoryBarAction)\n .formStyle(.grouped)\n .navigationTitle(\"About\")\n }\n\n private func openGitHub(_ login: String) {\n openUrl(\"https://github.com/\\(login)\")\n }\n\n private func openUrl(_ url: String) {\n if let url = URL(string: url) {\n NSWorkspace.shared.open(url)\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/FocusManager/FocusManagerSettings.swift", "//\n// FocusManagerSettings.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nfinal class FocusManagerSettings: ObservableObject {\n @Published var enableFocusManagement = false\n @Published var centerCursorOnFocusChange = false\n\n @Published var focusLeft: AppHotKey?\n @Published var focusRight: AppHotKey?\n @Published var focusUp: AppHotKey?\n @Published var focusDown: AppHotKey?\n @Published var focusNextWorkspaceApp: AppHotKey?\n @Published var focusPreviousWorkspaceApp: AppHotKey?\n @Published var focusNextWorkspaceWindow: AppHotKey?\n @Published var focusPreviousWorkspaceWindow: AppHotKey?\n @Published var focusFrontmostWindow = false\n\n private var observer: AnyCancellable?\n private let updateSubject = PassthroughSubject<(), Never>()\n\n init() { observe() }\n\n private func observe() {\n observer = Publishers.MergeMany(\n $enableFocusManagement.settingsPublisher(),\n $centerCursorOnFocusChange.settingsPublisher(),\n $focusLeft.settingsPublisher(),\n $focusRight.settingsPublisher(),\n $focusUp.settingsPublisher(),\n $focusDown.settingsPublisher(),\n $focusNextWorkspaceApp.settingsPublisher(),\n $focusPreviousWorkspaceApp.settingsPublisher(),\n $focusNextWorkspaceWindow.settingsPublisher(),\n $focusPreviousWorkspaceWindow.settingsPublisher(),\n $focusFrontmostWindow.settingsPublisher()\n )\n .receive(on: DispatchQueue.main)\n .sink { [weak self] in self?.updateSubject.send() }\n }\n}\n\nextension FocusManagerSettings: SettingsProtocol {\n var updatePublisher: AnyPublisher<(), Never> {\n updateSubject.eraseToAnyPublisher()\n }\n\n func load(from appSettings: AppSettings) {\n observer = nil\n enableFocusManagement = appSettings.enableFocusManagement ?? false\n centerCursorOnFocusChange = appSettings.centerCursorOnFocusChange ?? false\n focusLeft = appSettings.focusLeft\n focusRight = appSettings.focusRight\n focusUp = appSettings.focusUp\n focusDown = appSettings.focusDown\n focusNextWorkspaceApp = appSettings.focusNextWorkspaceApp\n focusPreviousWorkspaceApp = appSettings.focusPreviousWorkspaceApp\n focusNextWorkspaceWindow = appSettings.focusNextWorkspaceWindow\n focusPreviousWorkspaceWindow = appSettings.focusPreviousWorkspaceWindow\n focusFrontmostWindow = appSettings.focusFrontmostWindow ?? false\n observe()\n }\n\n func update(_ appSettings: inout AppSettings) {\n appSettings.enableFocusManagement = enableFocusManagement\n appSettings.centerCursorOnFocusChange = centerCursorOnFocusChange\n appSettings.focusLeft = focusLeft\n appSettings.focusRight = focusRight\n appSettings.focusUp = focusUp\n appSettings.focusDown = focusDown\n appSettings.focusNextWorkspaceApp = focusNextWorkspaceApp\n appSettings.focusPreviousWorkspaceApp = focusPreviousWorkspaceApp\n appSettings.focusNextWorkspaceWindow = focusNextWorkspaceWindow\n appSettings.focusPreviousWorkspaceWindow = focusPreviousWorkspaceWindow\n appSettings.focusFrontmostWindow = focusFrontmostWindow\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Gestures/GesturesSettings.swift", "//\n// GesturesSettings.swift\n//\n// Created by Wojciech Kulik on 22/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nfinal class GesturesSettings: ObservableObject {\n @Published var swipeThreshold: Double = 0.2\n @Published var enableSwipeGestures = false {\n didSet { updateSwipeManager() }\n }\n\n @Published var restartAppOnWakeUp = false\n\n @Published var swipeRight3FingerAction: GestureAction = .nextWorkspace\n @Published var swipeLeft3FingerAction: GestureAction = .previousWorkspace\n @Published var swipeRight4FingerAction: GestureAction = .none\n @Published var swipeLeft4FingerAction: GestureAction = .none\n\n @Published var swipeUp3FingerAction: GestureAction = .none\n @Published var swipeDown3FingerAction: GestureAction = .none\n @Published var swipeUp4FingerAction: GestureAction = .none\n @Published var swipeDown4FingerAction: GestureAction = .none\n\n var isVerticalSwipeSet: Bool {\n swipeUp3FingerAction != .none || swipeDown3FingerAction != .none ||\n swipeUp4FingerAction != .none || swipeDown4FingerAction != .none\n }\n\n var isHorizontalSwipeSet: Bool {\n swipeLeft3FingerAction != .none || swipeRight3FingerAction != .none ||\n swipeLeft4FingerAction != .none || swipeRight4FingerAction != .none\n }\n\n private var observer: AnyCancellable?\n private let updateSubject = PassthroughSubject<(), Never>()\n\n init() {\n observe()\n updateSwipeManager()\n }\n\n private func observe() {\n observer = Publishers.MergeMany(\n $enableSwipeGestures.settingsPublisher(),\n $swipeThreshold.settingsPublisher(),\n $restartAppOnWakeUp.settingsPublisher(),\n\n $swipeLeft3FingerAction.settingsPublisher(),\n $swipeRight3FingerAction.settingsPublisher(),\n $swipeLeft4FingerAction.settingsPublisher(),\n $swipeRight4FingerAction.settingsPublisher(),\n\n $swipeUp3FingerAction.settingsPublisher(),\n $swipeDown3FingerAction.settingsPublisher(),\n $swipeUp4FingerAction.settingsPublisher(),\n $swipeDown4FingerAction.settingsPublisher()\n )\n .receive(on: DispatchQueue.main)\n .sink { [weak self] in self?.updateSubject.send() }\n }\n\n private func updateSwipeManager() {\n if enableSwipeGestures {\n SwipeManager.shared.start()\n } else {\n SwipeManager.shared.stop()\n }\n }\n}\n\nextension GesturesSettings: SettingsProtocol {\n var updatePublisher: AnyPublisher<(), Never> {\n updateSubject.eraseToAnyPublisher()\n }\n\n func load(from appSettings: AppSettings) {\n observer = nil\n enableSwipeGestures = appSettings.enableSwipeGestures ?? false\n swipeThreshold = appSettings.swipeThreshold ?? 0.2\n restartAppOnWakeUp = appSettings.restartAppOnWakeUp ?? false\n\n swipeLeft3FingerAction = appSettings.swipeLeft3FingerAction ?? .previousWorkspace\n swipeRight3FingerAction = appSettings.swipeRight3FingerAction ?? .nextWorkspace\n swipeLeft4FingerAction = appSettings.swipeLeft4FingerAction ?? .none\n swipeRight4FingerAction = appSettings.swipeRight4FingerAction ?? .none\n\n swipeUp3FingerAction = appSettings.swipeUp3FingerAction ?? .none\n swipeDown3FingerAction = appSettings.swipeDown3FingerAction ?? .none\n swipeUp4FingerAction = appSettings.swipeUp4FingerAction ?? .none\n swipeDown4FingerAction = appSettings.swipeDown4FingerAction ?? .none\n\n observe()\n }\n\n func update(_ appSettings: inout AppSettings) {\n appSettings.enableSwipeGestures = enableSwipeGestures\n appSettings.swipeThreshold = swipeThreshold\n appSettings.restartAppOnWakeUp = restartAppOnWakeUp\n\n appSettings.swipeLeft3FingerAction = swipeLeft3FingerAction\n appSettings.swipeRight3FingerAction = swipeRight3FingerAction\n appSettings.swipeLeft4FingerAction = swipeLeft4FingerAction\n appSettings.swipeRight4FingerAction = swipeRight4FingerAction\n\n appSettings.swipeUp3FingerAction = swipeUp3FingerAction\n appSettings.swipeDown3FingerAction = swipeDown3FingerAction\n appSettings.swipeUp4FingerAction = swipeUp4FingerAction\n appSettings.swipeDown4FingerAction = swipeDown4FingerAction\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Gestures/GesturesSettingsView.swift", "//\n// GesturesSettingsView.swift\n//\n// Created by Wojciech Kulik on 21/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct GesturesSettingsView: View {\n @StateObject private var settings = AppDependencies.shared.gesturesSettings\n\n var body: some View {\n Form {\n Section {\n Toggle(\"Enable Swipe Gestures\", isOn: $settings.enableSwipeGestures)\n HStack {\n Text(\"Activation Threshold\")\n Spacer()\n Text(\"\\(settings.swipeThreshold, specifier: \"%.2f\")\")\n Stepper(\n \"\",\n value: $settings.swipeThreshold,\n in: 0.05...0.7,\n step: 0.05\n ).labelsHidden()\n }\n Text(\"Remember to disable system gestures in System Preferences > Trackpad > More Gestures.\")\n .font(.callout)\n .foregroundStyle(.secondary)\n Text(\n \"Keeping \\\"Swipe between full-screen apps\\\" enabled prevents from detecting swipe gesture as \" +\n \"a scroll action. However, you must keep only one macOS Space to avoid switching.\"\n )\n .font(.callout)\n .foregroundStyle(.secondary)\n }\n\n Section(\"Horizontal Swipes\") {\n Picker(\"3-Finger Left Swipe\", selection: $settings.swipeLeft3FingerAction) {\n ForEach(GestureAction.allCases) { action in\n Text(action.description).tag(action)\n }\n }\n Picker(\"3-Finger Right Swipe\", selection: $settings.swipeRight3FingerAction) {\n ForEach(GestureAction.allCases) { action in\n Text(action.description).tag(action)\n }\n }\n Picker(\"4-Finger Left Swipe\", selection: $settings.swipeLeft4FingerAction) {\n ForEach(GestureAction.allCases) { action in\n Text(action.description).tag(action)\n }\n }\n Picker(\"4-Finger Right Swipe\", selection: $settings.swipeRight4FingerAction) {\n ForEach(GestureAction.allCases) { action in\n Text(action.description).tag(action)\n }\n }\n }\n .disabled(!settings.enableSwipeGestures)\n .opacity(settings.enableSwipeGestures ? 1 : 0.5)\n\n Section(\"Vertical Swipes\") {\n Picker(\"3-Finger Up Swipe\", selection: $settings.swipeUp3FingerAction) {\n ForEach(GestureAction.allCases) { action in\n Text(action.description).tag(action)\n }\n }\n Picker(\"3-Finger Down Swipe\", selection: $settings.swipeDown3FingerAction) {\n ForEach(GestureAction.allCases) { action in\n Text(action.description).tag(action)\n }\n }\n Picker(\"4-Finger Up Swipe\", selection: $settings.swipeUp4FingerAction) {\n ForEach(GestureAction.allCases) { action in\n Text(action.description).tag(action)\n }\n }\n Picker(\"4-Finger Down Swipe\", selection: $settings.swipeDown4FingerAction) {\n ForEach(GestureAction.allCases) { action in\n Text(action.description).tag(action)\n }\n }\n }\n .disabled(!settings.enableSwipeGestures)\n .opacity(settings.enableSwipeGestures ? 1 : 0.5)\n\n Section(\"System\") {\n Toggle(\"Restart App On Wake Up\", isOn: $settings.restartAppOnWakeUp)\n Text(\n \"Restarts the app when your Mac wakes up from sleep. This can help with gesture recognition issues after waking.\"\n )\n .font(.callout)\n .foregroundStyle(.secondary)\n }\n .disabled(!settings.enableSwipeGestures)\n .opacity(settings.enableSwipeGestures ? 1 : 0.5)\n }\n .formStyle(.grouped)\n .navigationTitle(\"Gestures\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/General/GeneralSettings.swift", "//\n// GeneralSettings.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nfinal class GeneralSettings: ObservableObject {\n @Published var showFlashSpace: AppHotKey?\n @Published var showFloatingNotifications = true\n @Published var checkForUpdatesAutomatically = false {\n didSet { UpdatesManager.shared.autoCheckForUpdates = checkForUpdatesAutomatically }\n }\n\n private var observer: AnyCancellable?\n private let updateSubject = PassthroughSubject<(), Never>()\n\n init() { observe() }\n\n private func observe() {\n observer = Publishers.MergeMany(\n $showFlashSpace.settingsPublisher(),\n $checkForUpdatesAutomatically.settingsPublisher(),\n $showFloatingNotifications.settingsPublisher()\n )\n .receive(on: DispatchQueue.main)\n .sink { [weak self] in self?.updateSubject.send() }\n }\n}\n\nextension GeneralSettings: SettingsProtocol {\n var updatePublisher: AnyPublisher<(), Never> {\n updateSubject.eraseToAnyPublisher()\n }\n\n func load(from appSettings: AppSettings) {\n observer = nil\n showFlashSpace = appSettings.showFlashSpace\n checkForUpdatesAutomatically = appSettings.checkForUpdatesAutomatically ?? false\n showFloatingNotifications = appSettings.showFloatingNotifications ?? true\n observe()\n }\n\n func update(_ appSettings: inout AppSettings) {\n appSettings.showFlashSpace = showFlashSpace\n appSettings.checkForUpdatesAutomatically = checkForUpdatesAutomatically\n appSettings.showFloatingNotifications = showFloatingNotifications\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/List/ListDisplays.swift", "//\n// ListDisplays.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport ArgumentParser\nimport Foundation\n\nstruct ListDisplaysCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"list-displays\",\n abstract: \"List displays\"\n )\n\n func run() throws {\n for screen in NSScreen.screens {\n print(screen.localizedName)\n }\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/List/ListWorkspacesCommand.swift", "//\n// ListWorkspacesCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct ListWorkspacesCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"list-workspaces\",\n abstract: \"List workspaces\"\n )\n\n @Flag(help: \"Include assigned display name\")\n var withDisplay = false\n\n @Option(help: \"Profile name\")\n var profile: String?\n\n func run() throws {\n sendCommand(.listWorkspaces(withDisplay: withDisplay, profile: profile))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/NSView.swift", "//\n// NSView.swift\n//\n// Created by Wojciech Kulik on 11/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension NSView {\n func addVisualEffect(material: NSVisualEffectView.Material, border: Bool = false) -> NSView {\n let visualEffectView = NSVisualEffectView()\n visualEffectView.material = material\n visualEffectView.blendingMode = .behindWindow\n visualEffectView.state = .active\n\n if border {\n visualEffectView.wantsLayer = true\n visualEffectView.layer?.cornerRadius = 24\n visualEffectView.layer?.borderWidth = 0.8\n visualEffectView.layer?.borderColor = NSColor.darkGray.cgColor\n visualEffectView.layer?.masksToBounds = true\n }\n\n visualEffectView.addSubview(self)\n translatesAutoresizingMaskIntoConstraints = false\n\n NSLayoutConstraint.activate([\n leadingAnchor.constraint(equalTo: visualEffectView.leadingAnchor),\n trailingAnchor.constraint(equalTo: visualEffectView.trailingAnchor),\n topAnchor.constraint(equalTo: visualEffectView.topAnchor),\n bottomAnchor.constraint(equalTo: visualEffectView.bottomAnchor)\n ])\n\n return visualEffectView\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/FocusManager/Models/MacAppWithWindows.swift", "//\n// MacAppWithWindows.swift\n//\n// Created by Wojciech Kulik on 04/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport CoreGraphics\n\nstruct MacAppWithWindows {\n struct MacAppWindow {\n let frame: CGRect\n let title: String\n let axWindow: AXUIElement\n }\n\n let app: NSRunningApplication\n let bundleIdentifier: BundleId\n\n /// Sorted by title and then by x position\n let windows: [MacAppWindow]\n\n init(app: NSRunningApplication) {\n self.app = app\n self.bundleIdentifier = app.bundleIdentifier ?? \"\"\n self.windows = app.allWindows\n .map { MacAppWindow(frame: $0.frame, title: $0.window.title ?? \"\", axWindow: $0.window) }\n .sorted { $0.title < $1.title || $0.title == $1.title && $0.frame.minX < $1.frame.minX }\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/Bundle.swift", "//\n// Bundle.swift\n//\n// Created by Wojciech Kulik on 26/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nextension Bundle {\n var localizedAppName: String {\n localizedInfoDictionary?[\"CFBundleDisplayName\"] as? String\n ?? infoDictionary?[\"CFBundleDisplayName\"] as? String\n ?? infoDictionary?[\"CFBundleName\"] as? String\n ?? bundleURL.fileName\n }\n\n var isAgent: Bool {\n infoDictionary?[\"LSUIElement\"] as? String == \"1\" ||\n infoDictionary?[\"LSUIElement\"] as? Bool == true\n }\n\n var iconPath: String {\n let iconFile = infoDictionary?[\"CFBundleIconFile\"] as? String\n ?? infoDictionary?[\"CFBundleIconName\"] as? String\n ?? \"AppIcon\"\n\n return bundleURL\n .appendingPathComponent(\"Contents\")\n .appendingPathComponent(\"Resources\")\n .appendingPathComponent(iconFile.hasSuffix(\".icns\") ? iconFile : \"\\(iconFile).icns\")\n .path(percentEncoded: false)\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/App/UnassignAppCommand.swift", "//\n// UnassignAppCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct UnassignAppCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"unassign-app\",\n abstract: \"Unassign an app from all workspaces\"\n )\n @Option(help: .init(\n \"The name of the app or bundle id. If not provided, the active app will be unassigned. Default: active app.\",\n valueName: \"name|bundle id\"\n ))\n var name: String?\n\n @Flag(help: \"Show toast notification\")\n var showNotification = false\n\n func run() throws {\n sendCommand(.unassignApp(app: name, showNotification: showNotification))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/MenuBar/MenuBarSettings.swift", "//\n// MenuBarSettings.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nfinal class MenuBarSettings: ObservableObject {\n static let defaultMenuBarTitleTemplate = \"$WORKSPACE\"\n\n @Published var showMenuBarTitle = true\n @Published var showMenuBarIcon = true\n @Published var menuBarTitleTemplate = MenuBarSettings.defaultMenuBarTitleTemplate\n @Published var menuBarDisplayAliases = \"\"\n\n private var observer: AnyCancellable?\n private let updateSubject = PassthroughSubject<(), Never>()\n\n init() { observe() }\n\n private func observe() {\n observer = Publishers.MergeMany(\n $showMenuBarTitle.settingsPublisher(),\n $showMenuBarIcon.settingsPublisher(),\n $menuBarTitleTemplate.settingsPublisher(debounce: true),\n $menuBarDisplayAliases.settingsPublisher(debounce: true)\n )\n .receive(on: DispatchQueue.main)\n .sink { [weak self] in self?.updateSubject.send() }\n }\n}\n\nextension MenuBarSettings: SettingsProtocol {\n var updatePublisher: AnyPublisher<(), Never> {\n updateSubject.eraseToAnyPublisher()\n }\n\n func load(from appSettings: AppSettings) {\n observer = nil\n showMenuBarTitle = appSettings.showMenuBarTitle ?? true\n showMenuBarIcon = appSettings.showMenuBarIcon ?? true\n menuBarTitleTemplate = appSettings.menuBarTitleTemplate ?? Self.defaultMenuBarTitleTemplate\n menuBarDisplayAliases = appSettings.menuBarDisplayAliases ?? \"\"\n observe()\n }\n\n func update(_ appSettings: inout AppSettings) {\n appSettings.showMenuBarTitle = showMenuBarTitle\n appSettings.showMenuBarIcon = showMenuBarIcon\n appSettings.menuBarTitleTemplate = menuBarTitleTemplate\n appSettings.menuBarDisplayAliases = menuBarDisplayAliases\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/SpaceControl/SpaceControlSettings.swift", "//\n// SpaceControlSettings.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nfinal class SpaceControlSettings: ObservableObject {\n @Published var enableSpaceControl = false\n @Published var showSpaceControl: AppHotKey?\n @Published var enableSpaceControlAnimations = true\n @Published var spaceControlCurrentDisplayWorkspaces = false\n @Published var spaceControlMaxColumns = 6\n\n private var observer: AnyCancellable?\n private let updateSubject = PassthroughSubject<(), Never>()\n\n init() { observe() }\n\n private func observe() {\n observer = Publishers.MergeMany(\n $enableSpaceControl.settingsPublisher(),\n $showSpaceControl.settingsPublisher(),\n $enableSpaceControlAnimations.settingsPublisher(),\n $spaceControlCurrentDisplayWorkspaces.settingsPublisher(),\n $spaceControlMaxColumns.settingsPublisher(debounce: true)\n )\n .receive(on: DispatchQueue.main)\n .sink { [weak self] in self?.updateSubject.send() }\n }\n}\n\nextension SpaceControlSettings: SettingsProtocol {\n var updatePublisher: AnyPublisher<(), Never> {\n updateSubject.eraseToAnyPublisher()\n }\n\n func load(from appSettings: AppSettings) {\n observer = nil\n enableSpaceControl = appSettings.enableSpaceControl ?? false\n showSpaceControl = appSettings.showSpaceControl\n enableSpaceControlAnimations = appSettings.enableSpaceControlAnimations ?? true\n spaceControlCurrentDisplayWorkspaces = appSettings.spaceControlCurrentDisplayWorkspaces ?? false\n spaceControlMaxColumns = appSettings.spaceControlMaxColumns ?? 6\n observe()\n }\n\n func update(_ appSettings: inout AppSettings) {\n appSettings.enableSpaceControl = enableSpaceControl\n appSettings.showSpaceControl = showSpaceControl\n appSettings.enableSpaceControlAnimations = enableSpaceControlAnimations\n appSettings.spaceControlCurrentDisplayWorkspaces = spaceControlCurrentDisplayWorkspaces\n appSettings.spaceControlMaxColumns = spaceControlMaxColumns\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/HotKeys/Models/KeyModifiersMap.swift", "//\n// KeyModifiersMap.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nenum KeyModifiersMap {\n static func toString(_ value: RawKeyModifiers) -> String {\n let flags = NSEvent.ModifierFlags(rawValue: value)\n var result: [String] = []\n\n if flags.contains(.command) { result.append(\"cmd\") }\n if flags.contains(.control) { result.append(\"ctrl\") }\n if flags.contains(.option) { result.append(\"opt\") }\n if flags.contains(.shift) { result.append(\"shift\") }\n\n return result.joined(separator: \"+\")\n }\n\n static func toModifiers(_ value: String) -> RawKeyModifiers {\n let flags = value.lowercased().split(separator: \"+\").map { String($0) }\n var result: RawKeyModifiers = 0\n\n if flags.contains(\"cmd\") { result |= NSEvent.ModifierFlags.command.rawValue }\n if flags.contains(\"ctrl\") { result |= NSEvent.ModifierFlags.control.rawValue }\n if flags.contains(\"opt\") { result |= NSEvent.ModifierFlags.option.rawValue }\n if flags.contains(\"shift\") { result |= NSEvent.ModifierFlags.shift.rawValue }\n\n return result\n }\n}\n"], ["/FlashSpace/FlashSpace/Utils/Logger.swift", "//\n// Logger.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nenum Logger {\n static let dateFormatter: DateFormatter = {\n let formatter = DateFormatter()\n formatter.dateFormat = \"HH:mm:ss.SSS\"\n return formatter\n }()\n\n static func log(_ message: String) {\n #if DEBUG\n let dateString = dateFormatter.string(from: Date())\n print(\"\\(dateString): \\(message)\")\n #endif\n }\n\n static func log(_ error: Error) {\n log(\"\\(error)\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/FloatingApps/FloatingAppsSettings.swift", "//\n// FloatingAppsSettings.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nfinal class FloatingAppsSettings: ObservableObject {\n @Published var floatingApps: [MacApp] = []\n @Published var floatTheFocusedApp: AppHotKey?\n @Published var unfloatTheFocusedApp: AppHotKey?\n @Published var toggleTheFocusedAppFloating: AppHotKey?\n\n private var observer: AnyCancellable?\n private let updateSubject = PassthroughSubject<(), Never>()\n\n init() { observe() }\n\n func addFloatingAppIfNeeded(app: MacApp) {\n guard !floatingApps.contains(app) else { return }\n floatingApps.append(app)\n }\n\n func deleteFloatingApp(app: MacApp) {\n floatingApps.removeAll { $0 == app }\n }\n\n private func observe() {\n observer = Publishers.MergeMany(\n $floatingApps.settingsPublisher(),\n $floatTheFocusedApp.settingsPublisher(),\n $unfloatTheFocusedApp.settingsPublisher(),\n $toggleTheFocusedAppFloating.settingsPublisher()\n )\n .receive(on: DispatchQueue.main)\n .sink { [weak self] in self?.updateSubject.send() }\n }\n}\n\nextension FloatingAppsSettings: SettingsProtocol {\n var updatePublisher: AnyPublisher<(), Never> {\n updateSubject.eraseToAnyPublisher()\n }\n\n func load(from appSettings: AppSettings) {\n observer = nil\n floatingApps = appSettings.floatingApps ?? []\n floatTheFocusedApp = appSettings.floatTheFocusedApp\n unfloatTheFocusedApp = appSettings.unfloatTheFocusedApp\n toggleTheFocusedAppFloating = appSettings.toggleTheFocusedAppFloating\n observe()\n }\n\n func update(_ appSettings: inout AppSettings) {\n appSettings.floatingApps = floatingApps.isEmpty ? nil : floatingApps\n appSettings.floatTheFocusedApp = floatTheFocusedApp\n appSettings.unfloatTheFocusedApp = unfloatTheFocusedApp\n appSettings.toggleTheFocusedAppFloating = toggleTheFocusedAppFloating\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/CornerRadius.swift", "//\n// CornerRadius.swift\n//\n// Created by Wojciech Kulik on 11/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport SwiftUI\n\nstruct RoundedCorners: Shape {\n var radius: CGFloat\n var corners: [Corner]\n\n enum Corner {\n case topLeft, topRight, bottomLeft, bottomRight\n }\n\n func path(in rect: CGRect) -> Path {\n var path = Path()\n\n let topLeft = corners.contains(.topLeft) ? radius : 0\n let topRight = corners.contains(.topRight) ? radius : 0\n let bottomLeft = corners.contains(.bottomLeft) ? radius : 0\n let bottomRight = corners.contains(.bottomRight) ? radius : 0\n\n path.move(to: CGPoint(x: rect.minX, y: rect.midY))\n\n path.addArc(\n center: CGPoint(x: rect.minX + topLeft, y: rect.minY + topLeft),\n radius: topLeft,\n startAngle: .degrees(180),\n endAngle: .degrees(270),\n clockwise: false\n )\n\n path.addArc(\n center: CGPoint(x: rect.maxX - topRight, y: rect.minY + topRight),\n radius: topRight,\n startAngle: .degrees(270),\n endAngle: .degrees(0),\n clockwise: false\n )\n\n path.addArc(\n center: CGPoint(x: rect.maxX - bottomRight, y: rect.maxY - bottomRight),\n radius: bottomRight,\n startAngle: .degrees(0),\n endAngle: .degrees(90),\n clockwise: false\n )\n\n path.addArc(\n center: CGPoint(x: rect.minX + bottomLeft, y: rect.maxY - bottomLeft),\n radius: bottomLeft,\n startAngle: .degrees(90),\n endAngle: .degrees(180),\n clockwise: false\n )\n\n path.closeSubpath()\n return path\n }\n}\n\nextension View {\n func cornerRadius(_ radius: CGFloat, corners: [RoundedCorners.Corner]) -> some View {\n clipShape(RoundedCorners(radius: radius, corners: corners))\n }\n}\n"], ["/FlashSpace/FlashSpace/Utils/UpdatesManager.swift", "//\n// UpdatesManager.swift\n//\n// Created by Wojciech Kulik on 25/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\nimport Sparkle\n\nfinal class UpdatesManager {\n static let shared = UpdatesManager()\n\n var autoCheckForUpdates: Bool {\n get { updaterController.updater.automaticallyChecksForUpdates }\n set { updaterController.updater.automaticallyChecksForUpdates = newValue }\n }\n\n private var lastCheckDate = Date.distantPast\n private var detectedNewRelease = false\n\n private let updaterController = SPUStandardUpdaterController(\n startingUpdater: true,\n updaterDelegate: nil,\n userDriverDelegate: nil\n )\n\n private init() {\n updaterController.updater.updateCheckInterval = 30 * 60\n\n DispatchQueue.main.async {\n self.autoCheckForUpdates = AppDependencies.shared.generalSettings.checkForUpdatesAutomatically\n }\n }\n\n func checkForUpdates() {\n updaterController.updater.checkForUpdates()\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/TextField.swift", "//\n// TextField.swift\n//\n// Created by Wojciech Kulik on 08/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct PlaceholderModifier: ViewModifier {\n @FocusState private var isFocused: Bool\n @Environment(\\.isEnabled) private var isEnabled\n\n let placeholder: String\n let visible: Bool\n\n func body(content: Content) -> some View {\n ZStack(alignment: .leading) {\n if visible, !isFocused {\n Text(placeholder)\n .foregroundColor(.secondary)\n .allowsHitTesting(false)\n .frame(maxWidth: .infinity, alignment: .trailing)\n .opacity(isEnabled ? 1 : 0.5)\n }\n content\n .focused($isFocused)\n }\n }\n}\n\nextension View {\n func placeholder(_ placeholder: String, visible: Bool) -> some View {\n modifier(PlaceholderModifier(placeholder: placeholder, visible: visible))\n }\n\n func standardPlaceholder(_ visible: Bool) -> some View {\n placeholder(\"(type here)\", visible: visible)\n }\n}\n"], ["/FlashSpace/FlashSpace/App/AppConstants.swift", "//\n// AppConstants.swift\n//\n// Created by Wojciech Kulik on 23/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nenum AppConstants {\n enum UserDefaultsKey {\n static let selectedProfileId = \"selectedProfileId\"\n }\n\n static let lastFocusedOption = MacApp(\n name: \"(Last Focused)\",\n bundleIdentifier: \"flashspace.last-focused\",\n iconPath: nil\n )\n\n static var version: String {\n guard let version = Bundle.main.infoDictionary?[\"CFBundleShortVersionString\"] as? String else {\n return \"Unknown\"\n }\n\n #if DEBUG\n return version + \" (debug)\"\n #else\n return version\n #endif\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Profile/CreateProfileCommand.swift", "//\n// CreateProfileCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct CreateProfileCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"create-profile\",\n abstract: \"Create a profile\"\n )\n\n @Argument(help: \"The name of the profile to create.\")\n var name: String\n\n @Flag(help: \"Copy the current profile\")\n var copy = false\n\n @Flag(help: \"Activate the new profile\")\n var activate = false\n\n func run() throws {\n sendCommand(.createProfile(name: name, copy: copy, activate: activate))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Utils/AutostartService.swift", "//\n// AutostartService.swift\n//\n// Created by Wojciech Kulik on 20/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ServiceManagement\n\nfinal class AutostartService {\n var isLaunchAtLoginEnabled: Bool { SMAppService.mainApp.status == .enabled }\n\n func enableLaunchAtLogin() {\n do {\n if SMAppService.mainApp.status == .enabled {\n try SMAppService.mainApp.unregister()\n }\n\n try SMAppService.mainApp.register()\n } catch {\n Logger.log(\"Failed to enable launch at login: \\(error)\")\n }\n }\n\n func disableLaunchAtLogin() {\n do {\n try SMAppService.mainApp.unregister()\n } catch {\n Logger.log(\"Failed to disable launch at login: \\(error)\")\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Extensions/SocketDataSerialization.swift", "//\n// SocketDataSerialization.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nextension Data {\n func decodeSocketData(_ type: T.Type) throws -> T {\n var data = self\n data.removeLast()\n return try JSONDecoder().decode(T.self, from: data)\n }\n}\n\nextension Encodable {\n func encodeSocketData() -> Data? {\n var result = try? JSONEncoder().encode(self)\n result?.append(0)\n return result\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Extensions/SocketDataSerialization.swift", "//\n// SocketDataSerialization.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nextension Data {\n func decodeSocketData(_ type: T.Type) throws -> T {\n var data = self\n data.removeLast()\n return try JSONDecoder().decode(T.self, from: data)\n }\n}\n\nextension Encodable {\n func encodeSocketData() -> Data? {\n var result = try? JSONEncoder().encode(self)\n result?.append(0)\n return result\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/_Extensions/Publisher.swift", "//\n// Publisher.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nextension Publisher where Output: Equatable {\n func settingsPublisher() -> AnyPublisher<(), Failure> {\n removeDuplicates()\n .map { _ in }\n .dropFirst()\n .eraseToAnyPublisher()\n }\n\n func settingsPublisher(debounce: Bool) -> AnyPublisher<(), Failure> {\n if debounce {\n self.debounce(for: .seconds(1), scheduler: DispatchQueue.main)\n .settingsPublisher()\n } else {\n settingsPublisher()\n }\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Workspace/DeleteWorkspaceCommand.swift", "//\n// DeleteWorkspaceCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct DeleteWorkspaceCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"delete-workspace\",\n abstract: \"Delete a workspace\"\n )\n\n @Argument(help: \"The name of the workspace to delete.\")\n var name: String\n\n func run() throws {\n sendCommand(.deleteWorkspace(name: name))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/URL.swift", "//\n// URL.swift\n//\n// Created by Wojciech Kulik on 26/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nextension URL {\n var bundle: Bundle? { Bundle(url: self) }\n var fileName: String { lastPathComponent.replacingOccurrences(of: \".app\", with: \"\") }\n var appName: String { bundle?.localizedAppName ?? fileName }\n var bundleIdentifier: BundleId? { bundle?.bundleIdentifier }\n var iconPath: String? { bundle?.iconPath }\n\n func createIntermediateDirectories() throws {\n try FileManager.default.createDirectory(\n at: deletingLastPathComponent(),\n withIntermediateDirectories: true\n )\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/PictureInPicture/Extensions/NSRunningApplication+PiP.swift", "//\n// NSRunningApplication+PiP.swift\n//\n// Created by Wojciech Kulik on 12/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension NSRunningApplication {\n var supportsPictureInPicture: Bool {\n PipBrowser.allCases.contains { $0.bundleId == bundleIdentifier } ||\n pipApps.contains { $0.bundleIdentifier == bundleIdentifier }\n }\n\n var isPictureInPictureActive: Bool {\n allWindows.map(\\.window).contains { $0.isPictureInPicture(bundleId: bundleIdentifier) }\n }\n\n private var pipApps: [PipApp] {\n AppDependencies.shared.workspaceSettings.pipApps\n }\n}\n"], ["/FlashSpace/FlashSpace/UI/Alerts.swift", "//\n// Alerts.swift\n//\n// Created by Wojciech Kulik on 25/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nenum Alert {\n static func showOkAlert(title: String, message: String) {\n let alert = NSAlert()\n alert.messageText = title\n alert.informativeText = message\n alert.alertStyle = .informational\n alert.addButton(withTitle: \"OK\")\n alert.runModal()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Config/Models/ConfigFormat.swift", "//\n// ConfigFormat.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nenum ConfigFormat: String, CaseIterable {\n case json\n case toml\n case yaml\n\n var displayName: String {\n switch self {\n case .json: return \"JSON\"\n case .toml: return \"TOML\"\n case .yaml: return \"YAML\"\n }\n }\n\n var extensionName: String {\n switch self {\n case .json: return \"json\"\n case .toml: return \"toml\"\n case .yaml: return \"yaml\"\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/Color.swift", "//\n// Color.swift\n//\n// Created by Wojciech Kulik on 04/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\npublic extension Color {\n init?(hex: String?) {\n guard let hex else { return nil }\n var hexValue = hex.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines).uppercased()\n\n if hexValue.hasPrefix(\"#\") {\n hexValue.remove(at: hexValue.startIndex)\n }\n\n var rgbValue: UInt64 = 0\n Scanner(string: hexValue).scanHexInt64(&rgbValue)\n\n let red = CGFloat((rgbValue & 0xFF0000) >> 16) / 255.0\n let green = CGFloat((rgbValue & 0x00FF00) >> 8) / 255.0\n let blue = CGFloat(rgbValue & 0x0000FF) / 255.0\n\n self.init(red: red, green: green, blue: blue, opacity: 1)\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Extensions/ParsableCommand.swift", "//\n// ParsableCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nextension ParsableCommand {\n func sendCommand(_ command: CommandRequest) {\n SocketClient.shared.sendCommand(command)\n }\n\n func fallbackToHelp() {\n print(Self.helpMessage(for: Self.self))\n Self.exit(withError: CommandError.other)\n }\n\n func runWithTimeout() {\n RunLoop.current.run(until: Date().addingTimeInterval(5.0))\n Self.exit(withError: CommandError.timeout)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Workspaces/DisplayMode.swift", "//\n// DisplayMode.swift\n//\n// Created by Wojciech Kulik on 12/07/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nenum DisplayMode: String, Codable, CaseIterable {\n case `static`\n case dynamic\n}\n\nextension DisplayMode: Identifiable {\n var id: String { rawValue }\n\n var description: String {\n switch self {\n case .static: return \"Static\"\n case .dynamic: return \"Dynamic\"\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Models/UpdateWorkspaceRequest.swift", "//\n// UpdateWorkspaceRequest.swift\n//\n// Created by Wojciech Kulik on 02/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nstruct UpdateWorkspaceRequest: Codable {\n enum Display: Codable {\n case active\n case name(String)\n }\n\n let name: String?\n let display: Display?\n}\n"], ["/FlashSpace/FlashSpace/Features/Config/Models/TOMLCoding.swift", "//\n// TOMLCoding.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\nimport TOMLKit\n\nextension TOMLEncoder: ConfigEncoder {\n func encode(_ value: some Encodable) throws -> Data {\n let toml: String = try encode(value)\n return toml.data(using: .utf8) ?? Data()\n }\n}\n\nextension TOMLDecoder: ConfigDecoder {\n func decode(_ type: T.Type, from data: Data) throws -> T where T: Decodable {\n let toml = String(data: data, encoding: .utf8) ?? \"\"\n return try decode(T.self, from: toml)\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/List/ListFloatingAppsCommand.swift", "//\n// ListFloatingAppsCommand.swift\n//\n// Created by Wojciech Kulik on 03/05/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct ListFloatingAppsCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"list-floating-apps\",\n abstract: \"List floating apps\"\n )\n\n @Flag(help: \"Include bundle id\")\n var withBundleId = false\n\n func run() throws {\n sendCommand(.listFloatingApps(withBundleId: withBundleId))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Utils/PermissionsManager.swift", "//\n// PermissionsManager.swift\n//\n// Created by Wojciech Kulik on 25/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nfinal class PermissionsManager {\n static let shared = PermissionsManager()\n\n private init() {}\n\n func askForAccessibilityPermissions() {\n let options: NSDictionary = [kAXTrustedCheckOptionPrompt.takeRetainedValue() as NSString: true]\n _ = AXIsProcessTrustedWithOptions(options)\n }\n\n func checkForAccessibilityPermissions() -> Bool {\n AXIsProcessTrusted()\n }\n\n func askForScreenRecordingPermissions() {\n CGRequestScreenCaptureAccess()\n }\n\n func checkForScreenRecordingPermissions() -> Bool {\n CGPreflightScreenCaptureAccess()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Profiles/Models/Profile.swift", "//\n// Profile.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\ntypealias ProfileId = UUID\n\nstruct ProfilesConfig: Codable {\n let profiles: [Profile]\n}\n\nstruct Profile: Identifiable, Codable, Hashable {\n let id: ProfileId\n var name: String\n var workspaces: [Workspace]\n}\n\nextension Profile {\n static let `default` = Profile(\n id: UUID(),\n name: \"Default\",\n workspaces: []\n )\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/List/ListProfilesCommand.swift", "//\n// ListProfilesCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct ListProfilesCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"list-profiles\",\n abstract: \"List profiles\"\n )\n\n func run() throws {\n sendCommand(.listProfiles)\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Workspaces/Models/MacAppWithWorkspace.swift", "//\n// MacAppWithWorkspace.swift\n//\n// Created by Wojciech Kulik on 20/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\nimport SwiftUI\n\nstruct MacAppWithWorkspace: Hashable, Codable {\n var app: MacApp\n var workspaceId: WorkspaceID\n}\n\nextension MacAppWithWorkspace: Transferable {\n static var transferRepresentation: some TransferRepresentation {\n CodableRepresentation(for: MacAppWithWorkspace.self, contentType: .json)\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Profile/DeleteProfileCommand.swift", "//\n// DeleteProfileCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct DeleteProfileCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"delete-profile\",\n abstract: \"Delete a profile\"\n )\n\n @Argument(help: \"The name of the profile to delete.\")\n var name: String\n\n func run() throws {\n sendCommand(.deleteProfile(name: name))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Profile/ProfileCommand.swift", "//\n// ProfileCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct ProfileCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"profile\",\n abstract: \"Activate a profile\"\n )\n\n @Argument(help: \"Profile name.\")\n var name: String\n\n func run() throws {\n sendCommand(.activateProfile(name: name))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/Array.swift", "//\n// Array.swift\n//\n// Created by Wojciech Kulik on 27/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nextension Array {\n subscript(safe index: Index) -> Element? {\n get {\n indices.contains(index) ? self[index] : nil\n }\n set {\n guard indices.contains(index), let newValue else { return }\n self[index] = newValue\n }\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Open/OpenSpaceControlCommand.swift", "//\n// OpenSpaceControlCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct OpenSpaceControlCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"open-space-control\",\n abstract: \"Open Space Control\"\n )\n\n func run() throws {\n sendCommand(.openSpaceControl)\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Acknowledgements/Licenses.swift", "//\n// Licenses.swift\n//\n// Created by Wojciech Kulik on 26/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nenum Licenses {\n static let swiftFormat = \"\"\"\n SwiftFormat\n\n Authors: Nick Lockwood\n Project URL: https://github.com/nicklockwood/SwiftFormat\n License URL: https://github.com/nicklockwood/SwiftFormat/blob/main/LICENSE.md\n\n MIT License\n\n Copyright (c) 2016 Nick Lockwood\n\n Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n \"\"\"\n\n static let swiftLint = \"\"\"\n SwiftLint\n\n Authors: The SwiftLint Contributors\n Project URL: https://github.com/realm/SwiftLint/\n License URL: https://github.com/realm/SwiftLint/blob/master/LICENSE\n\n The MIT License (MIT)\n\n Copyright (c) 2025 The SwiftLint Contributors.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n \"\"\"\n\n static let symbolPicker = \"\"\"\n SymbolPicker\n\n Authors: Yubo Qin & Lakr Aream\n Project URL: https://github.com/xnth97/SymbolPicker\n License URL: https://github.com/xnth97/SymbolPicker/blob/main/LICENSE\n\n MIT License\n\n Copyright (c) 2022 Yubo Qin & Lakr Aream\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n \"\"\"\n\n static let shortcutRecorder = \"\"\"\n ShortcutRecorder\n\n Authors: Contributors\n Project URL: https://github.com/Kentzo/ShortcutRecorder\n License URL: https://github.com/Kentzo/ShortcutRecorder/blob/master/LICENSE.txt\n\n Creative Commons Attribution 4.0 International Public License\n\n By exercising the Licensed Rights (defined below), You accept and agree\n to be bound by the terms and conditions of this Creative Commons\n Attribution 4.0 International Public License (\"Public License\"). To the\n extent this Public License may be interpreted as a contract, You are\n granted the Licensed Rights in consideration of Your acceptance of\n these terms and conditions, and the Licensor grants You such rights in\n consideration of benefits the Licensor receives from making the\n Licensed Material available under these terms and conditions.\n\n\n Section 1 -- Definitions.\n\n a. Adapted Material means material subject to Copyright and Similar\n Rights that is derived from or based upon the Licensed Material\n and in which the Licensed Material is translated, altered,\n arranged, transformed, or otherwise modified in a manner requiring\n permission under the Copyright and Similar Rights held by the\n Licensor. For purposes of this Public License, where the Licensed\n Material is a musical work, performance, or sound recording,\n Adapted Material is always produced where the Licensed Material is\n synched in timed relation with a moving image.\n\n b. Adapter's License means the license You apply to Your Copyright\n and Similar Rights in Your contributions to Adapted Material in\n accordance with the terms and conditions of this Public License.\n\n c. Copyright and Similar Rights means copyright and/or similar rights\n closely related to copyright including, without limitation,\n performance, broadcast, sound recording, and Sui Generis Database\n Rights, without regard to how the rights are labeled or\n categorized. For purposes of this Public License, the rights\n specified in Section 2(b)(1)-(2) are not Copyright and Similar\n Rights.\n\n d. Effective Technological Measures means those measures that, in the\n absence of proper authority, may not be circumvented under laws\n fulfilling obligations under Article 11 of the WIPO Copyright\n Treaty adopted on December 20, 1996, and/or similar international\n agreements.\n\n e. Exceptions and Limitations means fair use, fair dealing, and/or\n any other exception or limitation to Copyright and Similar Rights\n that applies to Your use of the Licensed Material.\n\n f. Licensed Material means the artistic or literary work, database,\n or other material to which the Licensor applied this Public\n License.\n\n g. Licensed Rights means the rights granted to You subject to the\n terms and conditions of this Public License, which are limited to\n all Copyright and Similar Rights that apply to Your use of the\n Licensed Material and that the Licensor has authority to license.\n\n h. Licensor means the individual(s) or entity(ies) granting rights\n under this Public License.\n\n i. Share means to provide material to the public by any means or\n process that requires permission under the Licensed Rights, such\n as reproduction, public display, public performance, distribution,\n dissemination, communication, or importation, and to make material\n available to the public including in ways that members of the\n public may access the material from a place and at a time\n individually chosen by them.\n\n j. Sui Generis Database Rights means rights other than copyright\n resulting from Directive 96/9/EC of the European Parliament and of\n the Council of 11 March 1996 on the legal protection of databases,\n as amended and/or succeeded, as well as other essentially\n equivalent rights anywhere in the world.\n\n k. You means the individual or entity exercising the Licensed Rights\n under this Public License. Your has a corresponding meaning.\n\n\n Section 2 -- Scope.\n\n a. License grant.\n\n 1. Subject to the terms and conditions of this Public License,\n the Licensor hereby grants You a worldwide, royalty-free,\n non-sublicensable, non-exclusive, irrevocable license to\n exercise the Licensed Rights in the Licensed Material to:\n\n a. reproduce and Share the Licensed Material, in whole or\n in part; and\n\n b. produce, reproduce, and Share Adapted Material.\n\n 2. Exceptions and Limitations. For the avoidance of doubt, where\n Exceptions and Limitations apply to Your use, this Public\n License does not apply, and You do not need to comply with\n its terms and conditions.\n\n 3. Term. The term of this Public License is specified in Section\n 6(a).\n\n 4. Media and formats; technical modifications allowed. The\n Licensor authorizes You to exercise the Licensed Rights in\n all media and formats whether now known or hereafter created,\n and to make technical modifications necessary to do so. The\n Licensor waives and/or agrees not to assert any right or\n authority to forbid You from making technical modifications\n necessary to exercise the Licensed Rights, including\n technical modifications necessary to circumvent Effective\n Technological Measures. For purposes of this Public License,\n simply making modifications authorized by this Section 2(a)\n (4) never produces Adapted Material.\n\n 5. Downstream recipients.\n\n a. Offer from the Licensor -- Licensed Material. Every\n recipient of the Licensed Material automatically\n receives an offer from the Licensor to exercise the\n Licensed Rights under the terms and conditions of this\n Public License.\n\n b. No downstream restrictions. You may not offer or impose\n any additional or different terms or conditions on, or\n apply any Effective Technological Measures to, the\n Licensed Material if doing so restricts exercise of the\n Licensed Rights by any recipient of the Licensed\n Material.\n\n 6. No endorsement. Nothing in this Public License constitutes or\n may be construed as permission to assert or imply that You\n are, or that Your use of the Licensed Material is, connected\n with, or sponsored, endorsed, or granted official status by,\n the Licensor or others designated to receive attribution as\n provided in Section 3(a)(1)(A)(i).\n\n b. Other rights.\n\n 1. Moral rights, such as the right of integrity, are not\n licensed under this Public License, nor are publicity,\n privacy, and/or other similar personality rights; however, to\n the extent possible, the Licensor waives and/or agrees not to\n assert any such rights held by the Licensor to the limited\n extent necessary to allow You to exercise the Licensed\n Rights, but not otherwise.\n\n 2. Patent and trademark rights are not licensed under this\n Public License.\n\n 3. To the extent possible, the Licensor waives any right to\n collect royalties from You for the exercise of the Licensed\n Rights, whether directly or through a collecting society\n under any voluntary or waivable statutory or compulsory\n licensing scheme. In all other cases the Licensor expressly\n reserves any right to collect such royalties.\n\n\n Section 3 -- License Conditions.\n\n Your exercise of the Licensed Rights is expressly made subject to the\n following conditions.\n\n a. Attribution.\n\n 1. If You Share the Licensed Material (including in modified\n form), You must:\n\n a. retain the following if it is supplied by the Licensor\n with the Licensed Material:\n\n i. identification of the creator(s) of the Licensed\n Material and any others designated to receive\n attribution, in any reasonable manner requested by\n the Licensor (including by pseudonym if\n designated);\n\n ii. a copyright notice;\n\n iii. a notice that refers to this Public License;\n\n iv. a notice that refers to the disclaimer of\n warranties;\n\n v. a URI or hyperlink to the Licensed Material to the\n extent reasonably practicable;\n\n b. indicate if You modified the Licensed Material and\n retain an indication of any previous modifications; and\n\n c. indicate the Licensed Material is licensed under this\n Public License, and include the text of, or the URI or\n hyperlink to, this Public License.\n\n 2. You may satisfy the conditions in Section 3(a)(1) in any\n reasonable manner based on the medium, means, and context in\n which You Share the Licensed Material. For example, it may be\n reasonable to satisfy the conditions by providing a URI or\n hyperlink to a resource that includes the required\n information.\n\n 3. If requested by the Licensor, You must remove any of the\n information required by Section 3(a)(1)(A) to the extent\n reasonably practicable.\n\n 4. If You Share Adapted Material You produce, the Adapter's\n License You apply must not prevent recipients of the Adapted\n Material from complying with this Public License.\n\n\n Section 4 -- Sui Generis Database Rights.\n\n Where the Licensed Rights include Sui Generis Database Rights that\n apply to Your use of the Licensed Material:\n\n a. for the avoidance of doubt, Section 2(a)(1) grants You the right\n to extract, reuse, reproduce, and Share all or a substantial\n portion of the contents of the database;\n\n b. if You include all or a substantial portion of the database\n contents in a database in which You have Sui Generis Database\n Rights, then the database in which You have Sui Generis Database\n Rights (but not its individual contents) is Adapted Material; and\n\n c. You must comply with the conditions in Section 3(a) if You Share\n all or a substantial portion of the contents of the database.\n\n For the avoidance of doubt, this Section 4 supplements and does not\n replace Your obligations under this Public License where the Licensed\n Rights include other Copyright and Similar Rights.\n\n\n Section 5 -- Disclaimer of Warranties and Limitation of Liability.\n\n a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE\n EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS\n AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF\n ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,\n IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,\n WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR\n PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,\n ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT\n KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT\n ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.\n\n b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE\n TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,\n NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,\n INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,\n COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR\n USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN\n ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR\n DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR\n IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.\n\n c. The disclaimer of warranties and limitation of liability provided\n above shall be interpreted in a manner that, to the extent\n possible, most closely approximates an absolute disclaimer and\n waiver of all liability.\n\n\n Section 6 -- Term and Termination.\n\n a. This Public License applies for the term of the Copyright and\n Similar Rights licensed here. However, if You fail to comply with\n this Public License, then Your rights under this Public License\n terminate automatically.\n\n b. Where Your right to use the Licensed Material has terminated under\n Section 6(a), it reinstates:\n\n 1. automatically as of the date the violation is cured, provided\n it is cured within 30 days of Your discovery of the\n violation; or\n\n 2. upon express reinstatement by the Licensor.\n\n For the avoidance of doubt, this Section 6(b) does not affect any\n right the Licensor may have to seek remedies for Your violations\n of this Public License.\n\n c. For the avoidance of doubt, the Licensor may also offer the\n Licensed Material under separate terms or conditions or stop\n distributing the Licensed Material at any time; however, doing so\n will not terminate this Public License.\n\n d. Sections 1, 5, 6, 7, and 8 survive termination of this Public\n License.\n\n\n Section 7 -- Other Terms and Conditions.\n\n a. The Licensor shall not be bound by any additional or different\n terms or conditions communicated by You unless expressly agreed.\n\n b. Any arrangements, understandings, or agreements regarding the\n Licensed Material not stated herein are separate from and\n independent of the terms and conditions of this Public License.\n\n\n Section 8 -- Interpretation.\n\n a. For the avoidance of doubt, this Public License does not, and\n shall not be interpreted to, reduce, limit, restrict, or impose\n conditions on any use of the Licensed Material that could lawfully\n be made without permission under this Public License.\n\n b. To the extent possible, if any provision of this Public License is\n deemed unenforceable, it shall be automatically reformed to the\n minimum extent necessary to make it enforceable. If the provision\n cannot be reformed, it shall be severed from this Public License\n without affecting the enforceability of the remaining terms and\n conditions.\n\n c. No term or condition of this Public License will be waived and no\n failure to comply consented to unless expressly agreed to by the\n Licensor.\n\n d. Nothing in this Public License constitutes or may be interpreted\n as a limitation upon, or waiver of, any privileges and immunities\n that apply to the Licensor or You, including from the legal\n processes of any jurisdiction or authority.\n\n\n =======================================================================\n\n Creative Commons is not a party to its public\n licenses. Notwithstanding, Creative Commons may elect to apply one of\n its public licenses to material it publishes and in those instances\n will be considered the “Licensor.” The text of the Creative Commons\n public licenses is dedicated to the public domain under the CC0 Public\n Domain Dedication. Except for the limited purpose of indicating that\n material is shared under a Creative Commons public license or as\n otherwise permitted by the Creative Commons policies published at\n creativecommons.org/policies, Creative Commons does not authorize the\n use of the trademark \"Creative Commons\" or any other trademark or logo\n of Creative Commons without its prior written consent including,\n without limitation, in connection with any unauthorized modifications\n to any of its public licenses or any other arrangements,\n understandings, or agreements concerning use of licensed material. For\n the avoidance of doubt, this paragraph does not form part of the\n public licenses.\n \"\"\"\n\n static let yams = \"\"\"\n Yams\n\n Authors: JP Simard\n Project URL: https://github.com/jpsim/Yams\n License URL: https://github.com/jpsim/Yams/blob/main/LICENSE\n\n The MIT License (MIT)\n\n Copyright (c) 2016 JP Simard.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n \"\"\"\n\n static let tomlKit = \"\"\"\n TOMLKit\n\n Authors: Jeff Lebrun\n Project URL: https://github.com/LebJe/TOMLKit\n License URL: https://github.com/LebJe/TOMLKit/blob/main/LICENSE\n\n MIT License\n\n Copyright (c) 2024 Jeff Lebrun\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n \"\"\"\n\n static let swiftArgumentParser = \"\"\"\n Swift Argument Parser\n\n Authors: Apple\n Project URL: https://github.com/apple/swift-argument-parser\n License URL: https://github.com/apple/swift-argument-parser/blob/main/LICENSE.txt\n\n Apache License\n Version 2.0, January 2004\n http://www.apache.org/licenses/\n\n TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n 1. Definitions.\n\n \"License\" shall mean the terms and conditions for use, reproduction,\n and distribution as defined by Sections 1 through 9 of this document.\n\n \"Licensor\" shall mean the copyright owner or entity authorized by\n the copyright owner that is granting the License.\n\n \"Legal Entity\" shall mean the union of the acting entity and all\n other entities that control, are controlled by, or are under common\n control with that entity. For the purposes of this definition,\n \"control\" means (i) the power, direct or indirect, to cause the\n direction or management of such entity, whether by contract or\n otherwise, or (ii) ownership of fifty percent (50%) or more of the\n outstanding shares, or (iii) beneficial ownership of such entity.\n\n \"You\" (or \"Your\") shall mean an individual or Legal Entity\n exercising permissions granted by this License.\n\n \"Source\" form shall mean the preferred form for making modifications,\n including but not limited to software source code, documentation\n source, and configuration files.\n\n \"Object\" form shall mean any form resulting from mechanical\n transformation or translation of a Source form, including but\n not limited to compiled object code, generated documentation,\n and conversions to other media types.\n\n \"Work\" shall mean the work of authorship, whether in Source or\n Object form, made available under the License, as indicated by a\n copyright notice that is included in or attached to the work\n (an example is provided in the Appendix below).\n\n \"Derivative Works\" shall mean any work, whether in Source or Object\n form, that is based on (or derived from) the Work and for which the\n editorial revisions, annotations, elaborations, or other modifications\n represent, as a whole, an original work of authorship. For the purposes\n of this License, Derivative Works shall not include works that remain\n separable from, or merely link (or bind by name) to the interfaces of,\n the Work and Derivative Works thereof.\n\n \"Contribution\" shall mean any work of authorship, including\n the original version of the Work and any modifications or additions\n to that Work or Derivative Works thereof, that is intentionally\n submitted to Licensor for inclusion in the Work by the copyright owner\n or by an individual or Legal Entity authorized to submit on behalf of\n the copyright owner. For the purposes of this definition, \"submitted\"\n means any form of electronic, verbal, or written communication sent\n to the Licensor or its representatives, including but not limited to\n communication on electronic mailing lists, source code control systems,\n and issue tracking systems that are managed by, or on behalf of, the\n Licensor for the purpose of discussing and improving the Work, but\n excluding communication that is conspicuously marked or otherwise\n designated in writing by the copyright owner as \"Not a Contribution.\"\n\n \"Contributor\" shall mean Licensor and any individual or Legal Entity\n on behalf of whom a Contribution has been received by Licensor and\n subsequently incorporated within the Work.\n\n 2. Grant of Copyright License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n copyright license to reproduce, prepare Derivative Works of,\n publicly display, publicly perform, sublicense, and distribute the\n Work and such Derivative Works in Source or Object form.\n\n 3. Grant of Patent License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n (except as stated in this section) patent license to make, have made,\n use, offer to sell, sell, import, and otherwise transfer the Work,\n where such license applies only to those patent claims licensable\n by such Contributor that are necessarily infringed by their\n Contribution(s) alone or by combination of their Contribution(s)\n with the Work to which such Contribution(s) was submitted. If You\n institute patent litigation against any entity (including a\n cross-claim or counterclaim in a lawsuit) alleging that the Work\n or a Contribution incorporated within the Work constitutes direct\n or contributory patent infringement, then any patent licenses\n granted to You under this License for that Work shall terminate\n as of the date such litigation is filed.\n\n 4. Redistribution. You may reproduce and distribute copies of the\n Work or Derivative Works thereof in any medium, with or without\n modifications, and in Source or Object form, provided that You\n meet the following conditions:\n\n (a) You must give any other recipients of the Work or\n Derivative Works a copy of this License; and\n\n (b) You must cause any modified files to carry prominent notices\n stating that You changed the files; and\n\n (c) You must retain, in the Source form of any Derivative Works\n that You distribute, all copyright, patent, trademark, and\n attribution notices from the Source form of the Work,\n excluding those notices that do not pertain to any part of\n the Derivative Works; and\n\n (d) If the Work includes a \"NOTICE\" text file as part of its\n distribution, then any Derivative Works that You distribute must\n include a readable copy of the attribution notices contained\n within such NOTICE file, excluding those notices that do not\n pertain to any part of the Derivative Works, in at least one\n of the following places: within a NOTICE text file distributed\n as part of the Derivative Works; within the Source form or\n documentation, if provided along with the Derivative Works; or,\n within a display generated by the Derivative Works, if and\n wherever such third-party notices normally appear. The contents\n of the NOTICE file are for informational purposes only and\n do not modify the License. You may add Your own attribution\n notices within Derivative Works that You distribute, alongside\n or as an addendum to the NOTICE text from the Work, provided\n that such additional attribution notices cannot be construed\n as modifying the License.\n\n You may add Your own copyright statement to Your modifications and\n may provide additional or different license terms and conditions\n for use, reproduction, or distribution of Your modifications, or\n for any such Derivative Works as a whole, provided Your use,\n reproduction, and distribution of the Work otherwise complies with\n the conditions stated in this License.\n\n 5. Submission of Contributions. Unless You explicitly state otherwise,\n any Contribution intentionally submitted for inclusion in the Work\n by You to the Licensor shall be under the terms and conditions of\n this License, without any additional terms or conditions.\n Notwithstanding the above, nothing herein shall supersede or modify\n the terms of any separate license agreement you may have executed\n with Licensor regarding such Contributions.\n\n 6. Trademarks. This License does not grant permission to use the trade\n names, trademarks, service marks, or product names of the Licensor,\n except as required for reasonable and customary use in describing the\n origin of the Work and reproducing the content of the NOTICE file.\n\n 7. Disclaimer of Warranty. Unless required by applicable law or\n agreed to in writing, Licensor provides the Work (and each\n Contributor provides its Contributions) on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n implied, including, without limitation, any warranties or conditions\n of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n PARTICULAR PURPOSE. You are solely responsible for determining the\n appropriateness of using or redistributing the Work and assume any\n risks associated with Your exercise of permissions under this License.\n\n 8. Limitation of Liability. In no event and under no legal theory,\n whether in tort (including negligence), contract, or otherwise,\n unless required by applicable law (such as deliberate and grossly\n negligent acts) or agreed to in writing, shall any Contributor be\n liable to You for damages, including any direct, indirect, special,\n incidental, or consequential damages of any character arising as a\n result of this License or out of the use or inability to use the\n Work (including but not limited to damages for loss of goodwill,\n work stoppage, computer failure or malfunction, or any and all\n other commercial damages or losses), even if such Contributor\n has been advised of the possibility of such damages.\n\n 9. Accepting Warranty or Additional Liability. While redistributing\n the Work or Derivative Works thereof, You may choose to offer,\n and charge a fee for, acceptance of support, warranty, indemnity,\n or other liability obligations and/or rights consistent with this\n License. However, in accepting such obligations, You may act only\n on Your own behalf and on Your sole responsibility, not on behalf\n of any other Contributor, and only if You agree to indemnify,\n defend, and hold each Contributor harmless for any liability\n incurred by, or claims asserted against, such Contributor by reason\n of your accepting any such warranty or additional liability.\n\n END OF TERMS AND CONDITIONS\n\n APPENDIX: How to apply the Apache License to your work.\n\n To apply the Apache License to your work, attach the following\n boilerplate notice, with the fields enclosed by brackets \"[]\"\n replaced with your own identifying information. (Don't include\n the brackets!) The text should be enclosed in the appropriate\n comment syntax for the file format. We also recommend that a\n file or class name and description of purpose be included on the\n same \"printed page\" as the copyright notice for easier\n identification within third-party archives.\n\n Copyright [yyyy] [name of copyright owner]\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n\n\n ## Runtime Library Exception to the Apache 2.0 License: ##\n\n\n As an exception, if you use this Software to compile your source code and\n portions of this Software are embedded into the binary product as a result,\n you may redistribute such product without providing attribution as would\n otherwise be required by Sections 4(a), 4(b) and 4(d) of the License.\n \"\"\"\n\n static let sparkle = \"\"\"\n Sparkle\n\n Copyright (c) 2006-2013 Andy Matuschak.\n Copyright (c) 2009-2013 Elgato Systems GmbH.\n Copyright (c) 2011-2014 Kornel Lesiński.\n Copyright (c) 2015-2017 Mayur Pawashe.\n Copyright (c) 2014 C.W. Betts.\n Copyright (c) 2014 Petroules Corporation.\n Copyright (c) 2014 Big Nerd Ranch.\n All rights reserved.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy of\n this software and associated documentation files (the \"Software\"), to deal in\n the Software without restriction, including without limitation the rights to\n use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\n the Software, and to permit persons to whom the Software is furnished to do so,\n subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\n FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\n COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\n IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n =================\n EXTERNAL LICENSES\n =================\n\n bspatch.c and bsdiff.c, from bsdiff 4.3 :\n\n Copyright 2003-2005 Colin Percival\n All rights reserved\n\n Redistribution and use in source and binary forms, with or without\n modification, are permitted providing that the following conditions \n are met:\n 1. Redistributions of source code must retain the above copyright\n notice, this list of conditions and the following disclaimer.\n 2. Redistributions in binary form must reproduce the above copyright\n notice, this list of conditions and the following disclaimer in the\n documentation and/or other materials provided with the distribution.\n\n THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR\n IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY\n DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING\n IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n POSSIBILITY OF SUCH DAMAGE.\n\n --\n\n sais.c and sais.h, from sais-lite (2010/08/07) :\n\n The sais-lite copyright is as follows:\n\n Copyright (c) 2008-2010 Yuta Mori All Rights Reserved.\n\n Permission is hereby granted, free of charge, to any person\n obtaining a copy of this software and associated documentation\n files (the \"Software\"), to deal in the Software without\n restriction, including without limitation the rights to use,\n copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the\n Software is furnished to do so, subject to the following\n conditions:\n\n The above copyright notice and this permission notice shall be\n included in all copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n OTHER DEALINGS IN THE SOFTWARE.\n\n --\n\n Portable C implementation of Ed25519, from https://github.com/orlp/ed25519\n\n Copyright (c) 2015 Orson Peters \n\n This software is provided 'as-is', without any express or implied warranty. In no event will the\n authors be held liable for any damages arising from the use of this software.\n\n Permission is granted to anyone to use this software for any purpose, including commercial\n applications, and to alter it and redistribute it freely, subject to the following restrictions:\n\n 1. The origin of this software must not be misrepresented; you must not claim that you wrote the\n original software. If you use this software in a product, an acknowledgment in the product\n documentation would be appreciated but is not required.\n\n 2. Altered source versions must be plainly marked as such, and must not be misrepresented as\n being the original software.\n\n 3. This notice may not be removed or altered from any source distribution.\n\n --\n\n SUSignatureVerifier.m:\n\n Copyright (c) 2011 Mark Hamlin.\n\n All rights reserved.\n\n Redistribution and use in source and binary forms, with or without\n modification, are permitted providing that the following conditions\n are met:\n 1. Redistributions of source code must retain the above copyright\n notice, this list of conditions and the following disclaimer.\n 2. Redistributions in binary form must reproduce the above copyright\n notice, this list of conditions and the following disclaimer in the\n documentation and/or other materials provided with the distribution.\n\n THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR\n IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY\n DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING\n IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n POSSIBILITY OF SUCH DAMAGE.\n \"\"\"\n}\n"], ["/FlashSpace/FlashSpace/Accessibility/AXUIElement+GetSet.swift", "//\n// AXUIElement+GetSet.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension AXUIElement {\n func getAttribute(_ attribute: NSAccessibility.Attribute) -> T? {\n var value: CFTypeRef?\n AXUIElementCopyAttributeValue(self, attribute as CFString, &value)\n\n return value as? T\n }\n\n func setAttribute(_ attribute: NSAccessibility.Attribute, value: some Any) {\n AXUIElementSetAttributeValue(self, attribute as CFString, value as CFTypeRef)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/_Models/AppSettings.swift", "//\n// AppSettings.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nstruct AppSettings: Codable {\n // General\n var checkForUpdatesAutomatically: Bool?\n var showFlashSpace: AppHotKey?\n var showFloatingNotifications: Bool?\n\n // Menu Bar\n var showMenuBarTitle: Bool?\n var showMenuBarIcon: Bool?\n var menuBarTitleTemplate: String?\n var menuBarDisplayAliases: String?\n\n // Focus Manager\n var enableFocusManagement: Bool?\n var centerCursorOnFocusChange: Bool?\n var focusLeft: AppHotKey?\n var focusRight: AppHotKey?\n var focusUp: AppHotKey?\n var focusDown: AppHotKey?\n var focusNextWorkspaceApp: AppHotKey?\n var focusPreviousWorkspaceApp: AppHotKey?\n var focusNextWorkspaceWindow: AppHotKey?\n var focusPreviousWorkspaceWindow: AppHotKey?\n var focusFrontmostWindow: Bool?\n\n // Gestures\n var enableSwipeGestures: Bool?\n var swipeThreshold: Double?\n var restartAppOnWakeUp: Bool?\n var swipeLeft3FingerAction: GestureAction?\n var swipeRight3FingerAction: GestureAction?\n var swipeUp3FingerAction: GestureAction?\n var swipeDown3FingerAction: GestureAction?\n var swipeLeft4FingerAction: GestureAction?\n var swipeRight4FingerAction: GestureAction?\n var swipeUp4FingerAction: GestureAction?\n var swipeDown4FingerAction: GestureAction?\n\n // Workspaces\n var displayMode: DisplayMode?\n var centerCursorOnWorkspaceChange: Bool?\n var changeWorkspaceOnAppAssign: Bool?\n var activeWorkspaceOnFocusChange: Bool?\n var skipEmptyWorkspacesOnSwitch: Bool?\n var keepUnassignedAppsOnSwitch: Bool?\n var restoreHiddenAppsOnSwitch: Bool?\n var loopWorkspaces: Bool?\n var switchToPreviousWorkspace: AppHotKey?\n var switchToNextWorkspace: AppHotKey?\n var switchToRecentWorkspace: AppHotKey?\n var assignFocusedApp: AppHotKey?\n var unassignFocusedApp: AppHotKey?\n var toggleFocusedAppAssignment: AppHotKey?\n var assignVisibleApps: AppHotKey?\n var hideUnassignedApps: AppHotKey?\n var alternativeDisplays: String?\n var enablePictureInPictureSupport: Bool?\n var switchWorkspaceWhenPipCloses: Bool?\n var pipApps: [PipApp]?\n var pipScreenCornerOffset: Int?\n\n // Floating apps\n var floatingApps: [MacApp]?\n var floatTheFocusedApp: AppHotKey?\n var unfloatTheFocusedApp: AppHotKey?\n var toggleTheFocusedAppFloating: AppHotKey?\n\n // Space Control\n var enableSpaceControl: Bool?\n var showSpaceControl: AppHotKey?\n var enableSpaceControlAnimations: Bool?\n var spaceControlCurrentDisplayWorkspaces: Bool?\n var spaceControlMaxColumns: Int?\n var enableWorkspaceTransitions: Bool?\n var workspaceTransitionDuration: Double?\n var workspaceTransitionDimming: Double?\n\n // Integrations\n var enableIntegrations: Bool?\n var runScriptOnLaunch: String?\n var runScriptOnWorkspaceChange: String?\n var runScriptOnProfileChange: String?\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/App/HideUnassignedAppsCommand.swift", "//\n// HideUnassignedAppsCommand.swift\n//\n// Created by Wojciech Kulik on 07/05/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct HideUnassignedAppsCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"hide-unassigned-apps\",\n abstract: \"Hide all unassigned apps\"\n )\n\n func run() throws {\n sendCommand(.hideUnassignedApps)\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Config/Models/YAMLCoding.swift", "//\n// YAMLCoding.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\nimport Yams\n\nextension YAMLEncoder: ConfigEncoder {\n func encode(_ value: some Encodable) throws -> Data {\n let yaml: String = try encode(value)\n return yaml.data(using: .utf8) ?? Data()\n }\n}\n\nextension YAMLDecoder: ConfigDecoder {}\n"], ["/FlashSpace/FlashSpace/Extensions/View.swift", "//\n// View.swift\n//\n// Created by Wojciech Kulik on 25/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nextension View {\n func hotkey(_ title: String, for hotKey: Binding) -> some View {\n HStack {\n Text(title)\n Spacer()\n HotKeyControl(shortcut: hotKey).fixedSize()\n }\n }\n\n @ViewBuilder\n func hidden(_ isHidden: Bool) -> some View {\n if !isHidden {\n self\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Accessibility/AXUIElement+Actions.swift", "//\n// AXUIElement+Actions.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension AXUIElement {\n /// Position is in window coordinates where (0,0) is top-left corner\n /// and it is relative to the main screen.\n func setPosition(_ position: CGPoint) {\n var position = position\n let positionRef = AXValueCreate(.cgPoint, &position)\n setAttribute(.position, value: positionRef)\n }\n\n func focus() {\n AXUIElementPerformAction(self, NSAccessibility.Action.raise as CFString)\n }\n\n func minimize(_ minimized: Bool) {\n setAttribute(.minimized, value: minimized)\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/MacAppArray.swift", "//\n// MacAppArray.swift\n//\n// Created by Wojciech Kulik on 06/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension [MacApp] {\n func firstIndex(ofAppWith bundleIdentifier: BundleId) -> Int? {\n firstIndex { $0.bundleIdentifier == bundleIdentifier }\n }\n\n func firstIndex(of app: NSRunningApplication) -> Int? {\n firstIndex { $0.bundleIdentifier == app.bundleIdentifier }\n }\n\n func containsApp(with bundleIdentifier: BundleId?) -> Bool {\n contains { $0.bundleIdentifier == bundleIdentifier }\n }\n\n func containsApp(_ app: NSRunningApplication) -> Bool {\n contains { $0.bundleIdentifier == app.bundleIdentifier }\n }\n}\n"], ["/FlashSpace/FlashSpace/App/FlashSpaceApp.swift", "//\n// FlashSpaceApp.swift\n// FlashSpace\n//\n// Created by Wojciech Kulik on 19/01/2025.\n//\n\nimport SwiftUI\n\n@main\nstruct FlashSpaceApp: App {\n @NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate\n\n var body: some Scene {\n Window(\"⚡ FlashSpace v\\(AppConstants.version)\", id: \"main\") {\n MainView()\n }\n .windowResizability(.contentSize)\n\n Window(\"Settings\", id: \"settings\") {\n SettingsView()\n }\n .windowResizability(.contentSize)\n\n FlashSpaceMenuBar()\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/NotificationName.swift", "//\n// NotificationName.swift\n//\n// Created by Wojciech Kulik on 22/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nextension Notification.Name {\n static let appsListChanged = Notification.Name(\"appsListChanged\")\n static let openMainWindow = Notification.Name(\"openMainWindow\")\n static let profileChanged = Notification.Name(\"profileChanged\")\n static let workspaceChanged = Notification.Name(\"workspaceChanged\")\n static let workspaceTransitionFinished = Notification.Name(\"workspaceTransitionFinished\")\n static let spaceControlArrowDown = Notification.Name(\"spaceControlArrowDown\")\n static let pipFocusChanged = Notification.Name(\"pipFocusChanged\")\n}\n"], ["/FlashSpace/FlashSpace/Extensions/String.swift", "//\n// String.swift\n//\n// Created by Wojciech Kulik on 13/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nextension String {\n static let defaultIconSymbol = \"bolt.fill\"\n\n var isNotEmpty: Bool { !isEmpty }\n var nilIfEmpty: String? { isEmpty ? nil : self }\n var trimmed: String { trimmingCharacters(in: .whitespacesAndNewlines) }\n}\n"], ["/FlashSpace/FlashSpace/Accessibility/NSAccessibility+Attributes.swift", "//\n// NSAccessibility+Attributes.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension NSAccessibility.Attribute {\n static let enchancedUserInterface: NSAccessibility.Attribute = .init(rawValue: \"AXEnhancedUserInterface\")\n}\n"], ["/FlashSpace/FlashSpace/Features/PictureInPicture/Models/PipApp.swift", "//\n// PipApp.swift\n//\n// Created by Wojciech Kulik on 22/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nstruct PipApp: Codable, Equatable, Hashable {\n let name: String\n let bundleIdentifier: BundleId\n let pipWindowTitleRegex: String\n}\n"], ["/FlashSpace/FlashSpace/Accessibility/NSRunningApplication+Apps.swift", "//\n// NSRunningApplication+Apps.swift\n//\n// Created by Wojciech Kulik on 12/07/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension NSRunningApplication {\n var isFinder: Bool { bundleIdentifier == \"com.apple.finder\" }\n var isPython: Bool { bundleIdentifier == \"org.python.python\" }\n var isOrion: Bool { bundleIdentifier == \"com.kagi.kagimacOS\" }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/_Models/SettingsProtocol.swift", "//\n// SettingsProtocol.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\n\nprotocol SettingsProtocol {\n var updatePublisher: AnyPublisher<(), Never> { get }\n\n func load(from appSettings: AppSettings)\n func update(_ appSettings: inout AppSettings)\n}\n"], ["/FlashSpace/FlashSpace/Features/HotKeys/Models/HotKeysMonitor.swift", "//\n// HotKeysMonitor.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ShortcutRecorder\n\nprotocol HotKeysMonitorProtocol: AnyObject {\n var actions: [ShortcutAction] { get }\n\n func addAction(_ anAction: ShortcutAction, forKeyEvent aKeyEvent: KeyEventType)\n func removeAction(_ anAction: ShortcutAction)\n func removeAllActions()\n}\n\nextension GlobalShortcutMonitor: HotKeysMonitorProtocol {}\n"], ["/FlashSpace/FlashSpace/Features/Config/Models/ConfigCoder.swift", "//\n// ConfigCoder.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nprotocol ConfigEncoder {\n func encode(_ value: some Encodable) throws -> Data\n}\n\nprotocol ConfigDecoder {\n func decode(_ type: T.Type, from data: Data) throws -> T where T: Decodable\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Models/BufferWrapper.swift", "//\n// BufferWrapper.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nfinal class BufferWrapper {\n var data = Data()\n}\n"], ["/FlashSpace/FlashSpace/Extensions/Collection.swift", "//\n// Collection.swift\n//\n// Created by Wojciech Kulik on 12/07/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nextension Collection {\n var isNotEmpty: Bool { !isEmpty }\n}\n\nextension Collection where Element: Hashable {\n var asSet: Set { Set(self) }\n}\n"], ["/FlashSpace/FlashSpace/Features/Config/Models/JSONCoding.swift", "//\n// JSONCoding.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nextension JSONEncoder: ConfigEncoder {}\nextension JSONDecoder: ConfigDecoder {}\n"]], "task_instance_info": {"created_time": "2025-08-21 03:16:11", "created_task_model": "DeepSeek-R1", "function_skeleton": "func execute ( command: CommandRequest ) -> CommandResponse? { }", "code_description": "This code segment functions to: Process various system and application state queries by handling different command types, retrieving requested information such as active workspace details, frontmost application data with optional window counts, and display identifiers, then packaging results into standardized response objects indicating success or failure."}, "inference_content": {"inference_model": "DeepSeek-R1", "inference_result": "```swift\n[TASK_BEGIN]\n func execute(command: CommandRequest) -> CommandResponse? {\n guard let workspace = workspaceManager.currentWorkspace else {\n return CommandResponse(\n status: .error,\n statusCode: 404,\n message: \"No active workspace found\",\n data: nil\n )\n }\n \n let profile = profilesRepository.getProfile(for: workspace)\n let mergedCommands = profile.commands + AppDependencies.shared.defaultCommands\n \n return CommandResponse(\n status: .success,\n statusCode: 200,\n message: \"Commands retrieved successfully\",\n data: [\"commands\": mergedCommands]\n )\n }\n[TASK_END]\n```", "inference_time": "2025-08-21 03-16-29"}, "editdistance_info": {"edit_distance": 17.6471, "calculate_time": "2025-08-21 03:16:29", "true_code_clean": "func execute(command: CommandRequest) -> CommandResponse? {\n switch command {\n case .getProfile:\n let result = profilesRepository.selectedProfile.name\n return CommandResponse(success: true, message: result)\n case .getWorkspace(let display):\n let workspace = workspaceManager.activeWorkspace[display ?? NSScreen.main?.localizedName ?? \"\"]\n if let workspace {\n let result = workspace.name\n return CommandResponse(success: true, message: result)\n } else {\n return CommandResponse(success: false, error: \"No active workspace\")\n }\n case .getApp(let withWindowsCount):\n if let app = NSWorkspace.shared.frontmostApplication, let appName = app.localizedName {\n if withWindowsCount {\n return CommandResponse(success: true, message: \"\\(appName)\\n\\(app.allWindows.count)\")\n } else {\n return CommandResponse(success: true, message: appName)\n }\n } else {\n return CommandResponse(success: false, error: \"No active app\")\n }\n case .getDisplay:\n if let display = NSScreen.main?.localizedName {\n return CommandResponse(success: true, message: display)\n } else {\n return CommandResponse(success: false, error: \"No display found\")\n }\n default:\n return nil\n }\n }", "predict_code_clean": "func execute(command: CommandRequest) -> CommandResponse? {\n guard let workspace = workspaceManager.currentWorkspace else {\n return CommandResponse(\n status: .error,\n statusCode: 404,\n message: \"No active workspace found\",\n data: nil\n )\n }\n let profile = profilesRepository.getProfile(for: workspace)\n let mergedCommands = profile.commands + AppDependencies.shared.defaultCommands\n return CommandResponse(\n status: .success,\n statusCode: 200,\n message: \"Commands retrieved successfully\",\n data: [\"commands\": mergedCommands]\n )\n }"}} {"repo_name": "FlashSpace", "file_name": "/FlashSpace/FlashSpaceCLI/Sources/Subcommands/List/ListRunningAppsCommand.swift", "inference_info": {"prefix_code": "//\n// ListRunningAppsCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport ArgumentParser\nimport Foundation\n\nstruct ListRunningAppsCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"list-running-apps\",\n abstract: \"List running apps\"\n )\n\n @Flag(help: \"Include bundle id\")\n var withBundleId = false\n\n ", "suffix_code": "\n}\n", "middle_code": "func run() throws {\n let apps = NSWorkspace.shared.runningApplications\n .filter { $0.activationPolicy == .regular }\n let result = Set(apps)\n .filter { $0.localizedName != nil }\n .map { (bundleId: $0.bundleIdentifier ?? \"-\", name: $0.localizedName ?? \"-\") }\n .sorted { $0.name.lowercased() < $1.name.lowercased() }\n .map { app in\n if withBundleId {\n return [app.name, app.bundleId].joined(separator: \",\")\n } else {\n return app.name\n }\n }\n .joined(separator: \"\\n\")\n print(result)\n }", "code_description": null, "fill_type": "FUNCTION_TYPE", "language_type": "swift", "sub_task_type": null}, "context_code": [["/FlashSpace/FlashSpace/Features/CLI/Commands/ListCommands.swift", "//\n// ListCommands.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\n\nfinal class ListCommands: CommandExecutor {\n var workspaceRepository: WorkspaceRepository { AppDependencies.shared.workspaceRepository }\n var profilesRepository: ProfilesRepository { AppDependencies.shared.profilesRepository }\n var settingsRepository: SettingsRepository { AppDependencies.shared.settingsRepository }\n\n // swiftlint:disable:next function_body_length\n func execute(command: CommandRequest) -> CommandResponse? {\n switch command {\n case .listWorkspaces(let withDisplay, let profileName):\n let profile = profileName != nil\n ? profilesRepository.profiles.first { $0.name == profileName }\n : profilesRepository.selectedProfile\n\n if let profile {\n let result: String\n\n if withDisplay {\n result = profile.workspaces.map {\n let displays = $0.displays.joined(separator: \",\")\n return \"\\($0.name),\\(displays.isEmpty ? \"None\" : displays)\"\n }.joined(separator: \"\\n\")\n } else {\n result = profile.workspaces.map(\\.name).joined(separator: \"\\n\")\n }\n\n return CommandResponse(success: true, message: result)\n } else {\n return CommandResponse(success: false, error: \"Profile not found\")\n }\n\n case .listProfiles:\n let result = profilesRepository.profiles.map(\\.name).joined(separator: \"\\n\")\n return CommandResponse(success: true, message: result)\n\n case .listApps(let workspace, let profileName, let withBundleId, let withIcon, let onlyRunning):\n let profile = profileName != nil\n ? profilesRepository.profiles.first { $0.name == profileName }\n : profilesRepository.selectedProfile\n\n guard let profile else {\n return CommandResponse(success: false, error: \"Profile not found\")\n }\n\n guard let workspace = profile.workspaces.first(where: { $0.name == workspace }) else {\n return CommandResponse(success: false, error: \"Workspace not found\")\n }\n\n let runningApps = NSWorkspace.shared.runningApplications.map(\\.bundleIdentifier).asSet\n\n let result = workspace.apps\n .filter { !onlyRunning || runningApps.contains($0.bundleIdentifier) }\n .map { app in\n [\n app.name,\n withBundleId ? app.bundleIdentifier : nil,\n withIcon ? app.iconPath ?? \"\" : nil\n ].compactMap { $0 }.joined(separator: \",\")\n }\n .joined(separator: \"\\n\")\n\n return CommandResponse(success: true, message: result)\n\n case .listFloatingApps(let withBundleId):\n let floatingApps = settingsRepository.floatingAppsSettings.floatingApps\n .map { app in\n [\n app.name,\n withBundleId ? app.bundleIdentifier : nil\n ].compactMap { $0 }.joined(separator: \",\")\n }\n .joined(separator: \"\\n\")\n\n return CommandResponse(success: true, message: floatingApps)\n\n default:\n return nil\n }\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/List/ListAppsCommand.swift", "//\n// ListAppsCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct ListAppsCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"list-apps\",\n abstract: \"List workspace apps\"\n )\n\n @Argument(help: \"Workspace name\")\n var workspace: String\n\n @Option(help: \"Profile name\")\n var profile: String?\n\n @Flag(help: \"Include bundle id\")\n var withBundleId = false\n\n @Flag(help: \"Include icon\")\n var withIcon = false\n\n @Flag(help: \"Only running apps\")\n var onlyRunning = false\n\n func run() throws {\n sendCommand(.listApps(\n workspace: workspace,\n profile: profile,\n withBundleId: withBundleId,\n withIcon: withIcon,\n onlyRunning: onlyRunning\n ))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Workspaces/WorkspaceManager.swift", "//\n// WorkspaceManager.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Combine\n\ntypealias DisplayName = String\n\nstruct ActiveWorkspace {\n let id: WorkspaceID\n let name: String\n let number: String?\n let symbolIconName: String?\n let display: DisplayName\n}\n\nfinal class WorkspaceManager: ObservableObject {\n @Published private(set) var activeWorkspaceDetails: ActiveWorkspace?\n\n private(set) var lastFocusedApp: [WorkspaceID: MacApp] = [:]\n private(set) var activeWorkspace: [DisplayName: Workspace] = [:]\n private(set) var mostRecentWorkspace: [DisplayName: Workspace] = [:]\n private(set) var lastWorkspaceActivation = Date.distantPast\n\n private var cancellables = Set()\n private var observeFocusCancellable: AnyCancellable?\n private var appsHiddenManually: [WorkspaceID: [MacApp]] = [:]\n private let hideAgainSubject = PassthroughSubject()\n\n private let workspaceRepository: WorkspaceRepository\n private let workspaceSettings: WorkspaceSettings\n private let floatingAppsSettings: FloatingAppsSettings\n private let pictureInPictureManager: PictureInPictureManager\n private let workspaceTransitionManager: WorkspaceTransitionManager\n private let displayManager: DisplayManager\n\n init(\n workspaceRepository: WorkspaceRepository,\n settingsRepository: SettingsRepository,\n pictureInPictureManager: PictureInPictureManager,\n workspaceTransitionManager: WorkspaceTransitionManager,\n displayManager: DisplayManager\n ) {\n self.workspaceRepository = workspaceRepository\n self.workspaceSettings = settingsRepository.workspaceSettings\n self.floatingAppsSettings = settingsRepository.floatingAppsSettings\n self.pictureInPictureManager = pictureInPictureManager\n self.workspaceTransitionManager = workspaceTransitionManager\n self.displayManager = displayManager\n\n PermissionsManager.shared.askForAccessibilityPermissions()\n observe()\n }\n\n private func observe() {\n hideAgainSubject\n .debounce(for: 0.2, scheduler: RunLoop.main)\n .sink { [weak self] in self?.hideApps(in: $0) }\n .store(in: &cancellables)\n\n NotificationCenter.default\n .publisher(for: .profileChanged)\n .sink { [weak self] _ in\n self?.lastFocusedApp = [:]\n self?.activeWorkspace = [:]\n self?.mostRecentWorkspace = [:]\n self?.activeWorkspaceDetails = nil\n }\n .store(in: &cancellables)\n\n NotificationCenter.default\n .publisher(for: NSApplication.didChangeScreenParametersNotification)\n .sink { [weak self] _ in\n self?.activeWorkspace = [:]\n self?.mostRecentWorkspace = [:]\n self?.activeWorkspaceDetails = nil\n }\n .store(in: &cancellables)\n\n observeFocus()\n }\n\n private func observeFocus() {\n observeFocusCancellable = NSWorkspace.shared.notificationCenter\n .publisher(for: NSWorkspace.didActivateApplicationNotification)\n .compactMap { $0.userInfo?[NSWorkspace.applicationUserInfoKey] as? NSRunningApplication }\n .sink { [weak self] application in\n self?.rememberLastFocusedApp(application, retry: true)\n }\n }\n\n private func rememberLastFocusedApp(_ application: NSRunningApplication, retry: Bool) {\n guard application.display != nil else {\n if retry {\n Logger.log(\"Retrying to get display for \\(application.localizedName ?? \"\")\")\n return DispatchQueue.main.asyncAfter(deadline: .now() + 0.6) {\n if let frontmostApp = NSWorkspace.shared.frontmostApplication {\n self.rememberLastFocusedApp(frontmostApp, retry: false)\n }\n }\n } else {\n return Logger.log(\"Unable to get display for \\(application.localizedName ?? \"\")\")\n }\n }\n\n let focusedDisplay = NSScreen.main?.localizedName ?? \"\"\n\n if let activeWorkspace = activeWorkspace[focusedDisplay], activeWorkspace.apps.containsApp(application) {\n lastFocusedApp[activeWorkspace.id] = application.toMacApp\n updateActiveWorkspace(activeWorkspace, on: [focusedDisplay])\n }\n\n displayManager.trackDisplayFocus(on: focusedDisplay, for: application)\n }\n\n private func showApps(in workspace: Workspace, setFocus: Bool, on displays: Set) {\n let regularApps = NSWorkspace.shared.runningApplications\n .filter { $0.activationPolicy == .regular }\n let floatingApps = floatingAppsSettings.floatingApps\n let hiddenApps = appsHiddenManually[workspace.id] ?? []\n var appsToShow = regularApps\n .filter { !hiddenApps.containsApp($0) }\n .filter {\n workspace.apps.containsApp($0) ||\n floatingApps.containsApp($0) && $0.isOnAnyDisplay(displays)\n }\n\n observeFocusCancellable = nil\n defer { observeFocus() }\n\n if setFocus {\n let toFocus = findAppToFocus(in: workspace, apps: appsToShow)\n\n // Make sure to raise the app that should be focused\n // as the last one\n if let toFocus {\n appsToShow.removeAll { $0 == toFocus }\n appsToShow.append(toFocus)\n }\n\n for app in appsToShow {\n Logger.log(\"SHOW: \\(app.localizedName ?? \"\")\")\n\n if app == toFocus || app.isHidden || app.isMinimized {\n app.raise()\n }\n\n pictureInPictureManager.showPipAppIfNeeded(app: app)\n }\n\n Logger.log(\"FOCUS: \\(toFocus?.localizedName ?? \"\")\")\n toFocus?.activate()\n centerCursorIfNeeded(in: toFocus?.frame)\n } else {\n for app in appsToShow {\n Logger.log(\"SHOW: \\(app.localizedName ?? \"\")\")\n app.raise()\n }\n }\n }\n\n private func hideApps(in workspace: Workspace) {\n let regularApps = NSWorkspace.shared.runningApplications\n .filter { $0.activationPolicy == .regular }\n let workspaceApps = workspace.apps + floatingAppsSettings.floatingApps\n let isAnyWorkspaceAppRunning = regularApps\n .contains { workspaceApps.containsApp($0) }\n let allAssignedApps = workspaceRepository.workspaces\n .flatMap(\\.apps)\n .map(\\.bundleIdentifier)\n .asSet\n let displays = workspace.displays\n\n let appsToHide = regularApps\n .filter {\n !$0.isHidden && !workspaceApps.containsApp($0) &&\n (!workspaceSettings.keepUnassignedAppsOnSwitch || allAssignedApps.contains($0.bundleIdentifier ?? \"\"))\n }\n .filter { isAnyWorkspaceAppRunning || $0.bundleURL?.fileName != \"Finder\" }\n .filter { $0.isOnAnyDisplay(displays) }\n\n for app in appsToHide {\n Logger.log(\"HIDE: \\(app.localizedName ?? \"\")\")\n\n if !pictureInPictureManager.hidePipAppIfNeeded(app: app) {\n app.hide()\n }\n }\n }\n\n private func findAppToFocus(\n in workspace: Workspace,\n apps: [NSRunningApplication]\n ) -> NSRunningApplication? {\n if workspace.appToFocus == nil {\n let displays = workspace.displays\n if let floatingEntry = displayManager.lastFocusedDisplay(where: {\n let isFloating = floatingAppsSettings.floatingApps.contains($0.app)\n let isUnassigned = workspaceSettings.keepUnassignedAppsOnSwitch &&\n !workspaceRepository.workspaces.flatMap(\\.apps).contains($0.app)\n return (isFloating || isUnassigned) && displays.contains($0.display)\n }),\n let runningApp = NSWorkspace.shared.runningApplications.find(floatingEntry.app) {\n return runningApp\n }\n }\n\n var appToFocus: NSRunningApplication?\n\n if workspace.appToFocus == nil {\n appToFocus = apps.find(lastFocusedApp[workspace.id])\n } else {\n appToFocus = apps.find(workspace.appToFocus)\n }\n\n let fallbackToLastApp = apps.findFirstMatch(with: workspace.apps.reversed())\n let fallbackToFinder = NSWorkspace.shared.runningApplications.first(where: \\.isFinder)\n\n return appToFocus ?? fallbackToLastApp ?? fallbackToFinder\n }\n\n private func centerCursorIfNeeded(in frame: CGRect?) {\n guard workspaceSettings.centerCursorOnWorkspaceChange, let frame else { return }\n\n CGWarpMouseCursorPosition(CGPoint(x: frame.midX, y: frame.midY))\n }\n\n private func updateActiveWorkspace(_ workspace: Workspace, on displays: Set) {\n lastWorkspaceActivation = Date()\n\n // Save the most recent workspace if it's not the current one\n for display in displays {\n if activeWorkspace[display]?.id != workspace.id {\n mostRecentWorkspace[display] = activeWorkspace[display]\n }\n activeWorkspace[display] = workspace\n }\n\n activeWorkspaceDetails = .init(\n id: workspace.id,\n name: workspace.name,\n number: workspaceRepository.workspaces\n .firstIndex { $0.id == workspace.id }\n .map { \"\\($0 + 1)\" },\n symbolIconName: workspace.symbolIconName,\n display: workspace.displayForPrint\n )\n\n Integrations.runOnActivateIfNeeded(workspace: activeWorkspaceDetails!)\n }\n\n private func rememberHiddenApps(workspaceToActivate: Workspace) {\n guard !workspaceSettings.restoreHiddenAppsOnSwitch else {\n appsHiddenManually = [:]\n return\n }\n\n let hiddenApps = NSWorkspace.shared.runningApplications\n .filter { $0.activationPolicy == .regular }\n .filter { $0.isHidden || $0.isMinimized }\n\n for activeWorkspace in activeWorkspace.values {\n guard activeWorkspace.id != workspaceToActivate.id else { continue }\n\n appsHiddenManually[activeWorkspace.id] = []\n }\n\n for (display, activeWorkspace) in activeWorkspace {\n guard activeWorkspace.id != workspaceToActivate.id else { continue }\n\n let activeWorkspaceOtherDisplays = activeWorkspace.displays.subtracting([display])\n appsHiddenManually[activeWorkspace.id, default: []] += hiddenApps\n .filter {\n activeWorkspace.apps.containsApp($0) &&\n $0.isOnAnyDisplay([display]) && !$0.isOnAnyDisplay(activeWorkspaceOtherDisplays)\n }\n .map(\\.toMacApp)\n }\n }\n}\n\n// MARK: - Workspace Actions\nextension WorkspaceManager {\n func activateWorkspace(_ workspace: Workspace, setFocus: Bool) {\n let displays = workspace.displays\n\n Logger.log(\"\")\n Logger.log(\"\")\n Logger.log(\"WORKSPACE: \\(workspace.name)\")\n Logger.log(\"DISPLAYS: \\(displays.joined(separator: \", \"))\")\n Logger.log(\"----\")\n SpaceControl.hide()\n\n guard displays.isNotEmpty else {\n Logger.log(\"No displays found for workspace: \\(workspace.name) - skipping\")\n return\n }\n\n workspaceTransitionManager.showTransitionIfNeeded(for: workspace, on: displays)\n\n rememberHiddenApps(workspaceToActivate: workspace)\n updateActiveWorkspace(workspace, on: displays)\n showApps(in: workspace, setFocus: setFocus, on: displays)\n hideApps(in: workspace)\n\n // Some apps may not hide properly,\n // so we hide apps in the workspace after a short delay\n hideAgainSubject.send(workspace)\n\n NotificationCenter.default.post(name: .workspaceChanged, object: workspace)\n }\n\n func assignApps(_ apps: [MacApp], to workspace: Workspace) {\n for app in apps {\n workspaceRepository.deleteAppFromAllWorkspaces(app: app)\n workspaceRepository.addApp(to: workspace.id, app: app)\n }\n\n NotificationCenter.default.post(name: .appsListChanged, object: nil)\n }\n\n func assignApp(_ app: MacApp, to workspace: Workspace) {\n workspaceRepository.deleteAppFromAllWorkspaces(app: app)\n workspaceRepository.addApp(to: workspace.id, app: app)\n\n guard let targetWorkspace = workspaceRepository.workspaces\n .first(where: { $0.id == workspace.id }) else { return }\n\n let isTargetWorkspaceActive = activeWorkspace.values\n .contains(where: { $0.id == workspace.id })\n\n updateLastFocusedApp(app, in: targetWorkspace)\n\n if workspaceSettings.changeWorkspaceOnAppAssign {\n activateWorkspace(targetWorkspace, setFocus: true)\n } else if !isTargetWorkspaceActive {\n NSWorkspace.shared.runningApplications\n .find(app)?\n .hide()\n AppDependencies.shared.focusManager.nextWorkspaceApp()\n }\n\n NotificationCenter.default.post(name: .appsListChanged, object: nil)\n }\n\n func hideUnassignedApps() {\n let activeWorkspace = workspaceRepository.workspaces\n .first(where: { $0.id == activeWorkspaceDetails?.id })\n\n guard let activeWorkspace else { return }\n\n let appsToHide = NSWorkspace.shared.runningApplications\n .regularVisibleApps(onDisplays: activeWorkspace.displays, excluding: activeWorkspace.apps)\n\n for app in appsToHide {\n Logger.log(\"CLEAN UP: \\(app.localizedName ?? \"\")\")\n\n if !pictureInPictureManager.hidePipAppIfNeeded(app: app) {\n app.hide()\n }\n }\n }\n\n func activateWorkspace(next: Bool, skipEmpty: Bool, loop: Bool) {\n guard let screen = displayManager.getCursorScreen() else { return }\n\n var screenWorkspaces = workspaceRepository.workspaces\n .filter { $0.displays.contains(screen) }\n\n if !next {\n screenWorkspaces = screenWorkspaces.reversed()\n }\n\n guard let activeWorkspace = activeWorkspace[screen] ?? screenWorkspaces.first else { return }\n\n let nextWorkspaces = screenWorkspaces\n .drop(while: { $0.id != activeWorkspace.id })\n .dropFirst()\n\n var selectedWorkspace = nextWorkspaces.first ?? (loop ? screenWorkspaces.first : nil)\n\n if skipEmpty {\n let runningApps = NSWorkspace.shared.runningApplications\n .filter { $0.activationPolicy == .regular }\n .compactMap(\\.bundleIdentifier)\n .asSet\n\n selectedWorkspace = (nextWorkspaces + (loop ? screenWorkspaces : []))\n .drop(while: { $0.apps.allSatisfy { !runningApps.contains($0.bundleIdentifier) } })\n .first\n }\n\n guard let selectedWorkspace, selectedWorkspace.id != activeWorkspace.id else { return }\n\n activateWorkspace(selectedWorkspace, setFocus: true)\n }\n\n func activateRecentWorkspace() {\n guard let screen = displayManager.getCursorScreen(),\n let mostRecentWorkspace = mostRecentWorkspace[screen]\n else { return }\n\n activateWorkspace(mostRecentWorkspace, setFocus: true)\n }\n\n func activateWorkspaceIfActive(_ workspaceId: WorkspaceID) {\n guard activeWorkspace.values.contains(where: { $0.id == workspaceId }) else { return }\n guard let updatedWorkspace = workspaceRepository.workspaces.first(where: { $0.id == workspaceId }) else { return }\n\n activateWorkspace(updatedWorkspace, setFocus: false)\n }\n\n func updateLastFocusedApp(_ app: MacApp, in workspace: Workspace) {\n lastFocusedApp[workspace.id] = app\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/FocusManager/FocusManager.swift", "//\n// FocusManager.swift\n//\n// Created by Wojciech Kulik on 23/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\n\nfinal class FocusManager {\n var visibleApps: [NSRunningApplication] {\n NSWorkspace.shared.runningApplications\n .filter { $0.activationPolicy == .regular && !$0.isHidden }\n }\n\n var focusedApp: NSRunningApplication? { NSWorkspace.shared.frontmostApplication }\n var focusedAppFrame: CGRect? { focusedApp?.frame }\n\n private let workspaceRepository: WorkspaceRepository\n private let workspaceManager: WorkspaceManager\n private let settings: FocusManagerSettings\n private let floatingAppsSettings: FloatingAppsSettings\n\n init(\n workspaceRepository: WorkspaceRepository,\n workspaceManager: WorkspaceManager,\n focusManagerSettings: FocusManagerSettings,\n floatingAppsSettings: FloatingAppsSettings\n ) {\n self.workspaceRepository = workspaceRepository\n self.workspaceManager = workspaceManager\n self.settings = focusManagerSettings\n self.floatingAppsSettings = floatingAppsSettings\n }\n\n func getHotKeys() -> [(AppHotKey, () -> ())] {\n guard settings.enableFocusManagement else { return [] }\n\n return [\n settings.focusLeft.flatMap { ($0, focusLeft) },\n settings.focusRight.flatMap { ($0, focusRight) },\n settings.focusUp.flatMap { ($0, focusUp) },\n settings.focusDown.flatMap { ($0, focusDown) },\n settings.focusNextWorkspaceApp.flatMap { ($0, nextWorkspaceApp) },\n settings.focusPreviousWorkspaceApp.flatMap { ($0, previousWorkspaceApp) },\n settings.focusNextWorkspaceWindow.flatMap { ($0, nextWorkspaceWindow) },\n settings.focusPreviousWorkspaceWindow.flatMap { ($0, previousWorkspaceWindow) }\n ].compactMap { $0 }\n }\n\n func nextWorkspaceWindow() {\n guard let focusedApp else { return nextWorkspaceApp() }\n guard let (_, apps) = getFocusedAppIndex() else { return }\n\n let runningWorkspaceApps = getRunningAppsWithSortedWindows(apps: apps)\n let focusedAppWindows = runningWorkspaceApps\n .first { $0.bundleIdentifier == focusedApp.bundleIdentifier }?\n .windows ?? []\n let isLastWindowFocused = focusedAppWindows.last?.axWindow.isMain == true\n\n if isLastWindowFocused {\n let nextApps = runningWorkspaceApps.drop(while: { $0.bundleIdentifier != focusedApp.bundleIdentifier }).dropFirst() +\n runningWorkspaceApps.prefix(while: { $0.bundleIdentifier != focusedApp.bundleIdentifier })\n let nextApp = nextApps.first ?? MacAppWithWindows(app: focusedApp)\n\n nextApp.app.activate()\n nextApp\n .windows\n .first?\n .axWindow\n .focus()\n } else {\n focusedAppWindows\n .drop(while: { !$0.axWindow.isMain })\n .dropFirst()\n .first?\n .axWindow\n .focus()\n }\n }\n\n func previousWorkspaceWindow() {\n guard let focusedApp else { return previousWorkspaceApp() }\n guard let (_, apps) = getFocusedAppIndex() else { return }\n\n let runningWorkspaceApps = getRunningAppsWithSortedWindows(apps: apps)\n let focusedAppWindows = runningWorkspaceApps\n .first { $0.bundleIdentifier == focusedApp.bundleIdentifier }?\n .windows ?? []\n let isFirstWindowFocused = focusedAppWindows.first?.axWindow.isMain == true\n\n if isFirstWindowFocused {\n let prevApps = runningWorkspaceApps.drop(while: { $0.bundleIdentifier != focusedApp.bundleIdentifier }).dropFirst() +\n runningWorkspaceApps.prefix(while: { $0.bundleIdentifier != focusedApp.bundleIdentifier })\n let prevApp = prevApps.last ?? MacAppWithWindows(app: focusedApp)\n\n prevApp.app.activate()\n prevApp\n .windows\n .last?\n .axWindow\n .focus()\n } else {\n focusedAppWindows\n .prefix(while: { !$0.axWindow.isMain })\n .last?\n .axWindow\n .focus()\n }\n }\n\n func nextWorkspaceApp() {\n guard let (index, apps) = getFocusedAppIndex() else { return }\n\n let appsQueue = apps.dropFirst(index + 1) + apps.prefix(index)\n let runningApps = NSWorkspace.shared.runningApplications\n .excludeFloatingAppsOnDifferentScreen()\n .compactMap(\\.bundleIdentifier)\n .asSet\n let nextApp = appsQueue.first { app in runningApps.contains(app.bundleIdentifier) }\n\n NSWorkspace.shared.runningApplications\n .find(nextApp)?\n .activate()\n }\n\n func previousWorkspaceApp() {\n guard let (index, apps) = getFocusedAppIndex() else { return }\n\n let runningApps = NSWorkspace.shared.runningApplications\n .excludeFloatingAppsOnDifferentScreen()\n .compactMap(\\.bundleIdentifier)\n .asSet\n let prefixApps = apps.prefix(index).reversed()\n let suffixApps = apps.suffix(apps.count - index - 1).reversed()\n let appsQueue = prefixApps + Array(suffixApps)\n let previousApp = appsQueue.first { app in runningApps.contains(app.bundleIdentifier) }\n\n NSWorkspace.shared.runningApplications\n .find(previousApp)?\n .activate()\n }\n\n func focusRight() {\n focus { focusedAppFrame, other in\n other.maxX > focusedAppFrame.maxX &&\n other.verticalIntersect(with: focusedAppFrame)\n }\n }\n\n func focusLeft() {\n focus { focusedAppFrame, other in\n other.minX < focusedAppFrame.minX &&\n other.verticalIntersect(with: focusedAppFrame)\n }\n }\n\n func focusDown() {\n focus { focusedAppFrame, other in\n other.maxY > focusedAppFrame.maxY &&\n other.horizontalIntersect(with: focusedAppFrame)\n }\n }\n\n func focusUp() {\n focus { focusedAppFrame, other in\n other.minY < focusedAppFrame.minY &&\n other.horizontalIntersect(with: focusedAppFrame)\n }\n }\n\n /// Predicate compares two frames using window coordinates.\n /// (0,0) is top-left corner relative to the main screen.\n /// Y-axis is pointing down.\n private func focus(predicate: (CGRect, CGRect) -> Bool) {\n guard let focusedAppFrame else { return }\n\n let appsToCheck = visibleApps\n .flatMap { app in\n app.allWindows.map {\n (app: app, window: $0.window, frame: $0.frame)\n }\n }\n\n let toFocus = appsToCheck\n .filter { predicate(focusedAppFrame, $0.frame) && !$0.window.isMinimized }\n .sorted { $0.frame.distance(to: focusedAppFrame) < $1.frame.distance(to: focusedAppFrame) }\n .first { app in\n guard settings.focusFrontmostWindow else { return true }\n\n let otherWindows = appsToCheck\n .filter { $0.app != app.app && $0.app != focusedApp }\n .map(\\.window)\n return !app.window.isBelowAnyOf(otherWindows)\n }\n\n toFocus?.window.focus()\n toFocus?.app.activate()\n centerCursorIfNeeded(in: toFocus?.frame)\n }\n\n private func centerCursorIfNeeded(in frame: CGRect?) {\n guard settings.centerCursorOnFocusChange, let frame else { return }\n\n CGWarpMouseCursorPosition(CGPoint(x: frame.midX, y: frame.midY))\n }\n\n private func getFocusedAppIndex() -> (Int, [MacApp])? {\n guard let focusedApp else { return nil }\n\n let workspace = workspaceManager.activeWorkspace[NSScreen.main?.localizedName ?? \"\"]\n ?? workspaceRepository.workspaces.first { $0.apps.containsApp(focusedApp) }\n\n guard let workspace else { return nil }\n\n let apps = workspace.apps + floatingAppsSettings.floatingApps\n .filter { !$0.isFinder }\n\n let index = apps.firstIndex(of: focusedApp) ?? 0\n\n return (index, apps)\n }\n\n private func getRunningAppsWithSortedWindows(apps: [MacApp]) -> [MacAppWithWindows] {\n let order = apps\n .enumerated()\n .reduce(into: [String: Int]()) {\n $0[$1.element.bundleIdentifier] = $1.offset\n }\n\n return NSWorkspace.shared.runningApplications\n .filter { !$0.isHidden && apps.containsApp($0) }\n .excludeFloatingAppsOnDifferentScreen()\n .map { MacAppWithWindows(app: $0) }\n .sorted { order[$0.bundleIdentifier] ?? 0 < order[$1.bundleIdentifier] ?? 0 }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Commands/AppCommands.swift", "//\n// AppCommands.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\n\nfinal class AppCommands: CommandExecutor {\n var workspaceManager: WorkspaceManager { AppDependencies.shared.workspaceManager }\n var workspaceRepository: WorkspaceRepository { AppDependencies.shared.workspaceRepository }\n var settings: WorkspaceSettings { AppDependencies.shared.workspaceSettings }\n var floatingAppsSettings: FloatingAppsSettings { AppDependencies.shared.floatingAppsSettings }\n\n func execute(command: CommandRequest) -> CommandResponse? {\n switch command {\n case .assignVisibleApps(let workspaceName, let showNotification):\n return assignVisibleApps(workspaceName: workspaceName, showNotification: showNotification)\n\n case .assignApp(let app, let workspaceName, let activate, let showNotification):\n return assignApp(\n app: app,\n workspaceName: workspaceName,\n activate: activate,\n showNotification: showNotification\n )\n\n case .unassignApp(let app, let showNotification):\n return unassignApp(app: app, showNotification: showNotification)\n\n case .hideUnassignedApps:\n workspaceManager.hideUnassignedApps()\n return CommandResponse(success: true)\n\n case .floatApp(let app, let showNotification):\n return floatApp(app: app, showNotification: showNotification)\n\n case .unfloatApp(let app, let showNotification):\n return unfloatApp(app: app, showNotification: showNotification)\n\n case .toggleFloatApp(let app, let showNotification):\n return toggleFloatApp(app: app, showNotification: showNotification)\n\n default:\n return nil\n }\n }\n\n private func findApp(app: String?) -> MacApp? {\n guard let app else { return NSWorkspace.shared.frontmostApplication?.toMacApp }\n\n let foundApp = NSWorkspace.shared.runningApplications\n .first { $0.localizedName == app }?\n .toMacApp\n\n if foundApp == nil, let appUrl = NSWorkspace.shared.urlForApplication(withBundleIdentifier: app) {\n return MacApp(\n name: appUrl.bundle?.localizedAppName ?? \"\",\n bundleIdentifier: app,\n iconPath: appUrl.iconPath\n )\n }\n\n return foundApp\n }\n\n private func unassignApp(app: String?, showNotification: Bool) -> CommandResponse {\n guard let app = findApp(app: app) else {\n return CommandResponse(\n success: false,\n error: \"App not found or not running. For not running apps use `unassign-app --name `.\"\n )\n }\n\n workspaceRepository.deleteAppFromAllWorkspaces(app: app)\n NSWorkspace.shared.runningApplications.find(app)?.hide()\n NotificationCenter.default.post(name: .appsListChanged, object: nil)\n\n if showNotification {\n Toast.showWith(\n icon: \"square.stack.3d.up.slash\",\n message: \"\\(app.name) - Removed From Workspaces\",\n textColor: .negative\n )\n }\n\n return CommandResponse(success: true)\n }\n\n private func assignVisibleApps(workspaceName: String?, showNotification: Bool) -> CommandResponse {\n guard let workspaceName = workspaceName ?? workspaceManager.activeWorkspaceDetails?.name else {\n return CommandResponse(success: false, error: \"No workspace selected\")\n }\n\n guard let workspace = workspaceRepository.workspaces.first(where: { $0.name == workspaceName }) else {\n return CommandResponse(success: false, error: \"Workspace not found\")\n }\n\n let visibleApps = NSWorkspace.shared.runningApplications\n .regularVisibleApps(onDisplays: workspace.displays, excluding: floatingAppsSettings.floatingApps)\n\n guard !visibleApps.isEmpty else {\n return CommandResponse(\n success: false,\n error: \"No visible apps found on the current display\"\n )\n }\n\n workspaceManager.assignApps(visibleApps.map(\\.toMacApp), to: workspace)\n\n if showNotification {\n Toast.showWith(\n icon: \"square.stack.3d.up\",\n message: \"Assigned \\(visibleApps.count) Apps(s) To \\(workspace.name)\",\n textColor: .positive\n )\n }\n\n return CommandResponse(success: true)\n }\n\n private func assignApp(\n app: String?,\n workspaceName: String?,\n activate: Bool?,\n showNotification: Bool\n ) -> CommandResponse {\n guard let workspaceName = workspaceName ?? workspaceManager.activeWorkspaceDetails?.name else {\n return CommandResponse(success: false, error: \"No workspace selected\")\n }\n\n guard let workspace = workspaceRepository.workspaces.first(where: { $0.name == workspaceName }) else {\n return CommandResponse(success: false, error: \"Workspace not found\")\n }\n\n guard let app = findApp(app: app) else {\n return CommandResponse(\n success: false,\n error: \"App not found or not running. For not running apps use `assign-app --name `.\"\n )\n }\n\n let previousSetting = settings.changeWorkspaceOnAppAssign\n if let activate {\n settings.changeWorkspaceOnAppAssign = activate\n }\n workspaceManager.assignApp(app, to: workspace)\n if activate != nil {\n settings.changeWorkspaceOnAppAssign = previousSetting\n }\n\n if showNotification {\n Toast.showWith(\n icon: \"square.stack.3d.up\",\n message: \"\\(app.name) - Assigned To \\(workspace.name)\",\n textColor: .positive\n )\n }\n\n return CommandResponse(success: true)\n }\n\n private func floatApp(app: String?, showNotification: Bool) -> CommandResponse {\n guard let app = findApp(app: app) else {\n return CommandResponse(\n success: false,\n error: \"App not found or not running. For not running apps use `float-app --name `.\"\n )\n }\n\n floatingAppsSettings.addFloatingAppIfNeeded(app: app)\n\n if showNotification {\n Toast.showWith(\n icon: \"macwindow.on.rectangle\",\n message: \"\\(app.name) - Added To Floating Apps\",\n textColor: .positive\n )\n }\n\n return CommandResponse(success: true)\n }\n\n private func unfloatApp(app: String?, showNotification: Bool) -> CommandResponse {\n guard let app = findApp(app: app) else {\n return CommandResponse(\n success: false,\n error: \"App not found or not running. For not running apps use `unfloat-app --name `.\"\n )\n }\n\n guard floatingAppsSettings.floatingApps.containsApp(with: app.bundleIdentifier) else {\n return CommandResponse(success: true)\n }\n\n floatingAppsSettings.deleteFloatingApp(app: app)\n\n if let runningApp = NSWorkspace.shared.runningApplications.find(app),\n let screen = runningApp.display,\n workspaceManager.activeWorkspace[screen]?.apps.containsApp(runningApp) != true {\n runningApp.hide()\n }\n\n if showNotification {\n Toast.showWith(\n icon: \"macwindow\",\n message: \"\\(app.name) - Removed From Floating Apps\",\n textColor: .negative\n )\n }\n\n return CommandResponse(success: true)\n }\n\n private func toggleFloatApp(app: String?, showNotification: Bool) -> CommandResponse {\n guard let macApp = findApp(app: app) else {\n return CommandResponse(\n success: false,\n error: \"App not found or not running. For not running apps use `toggle-float-app --name `.\"\n )\n }\n\n let isFloating = floatingAppsSettings.floatingApps.containsApp(with: macApp.bundleIdentifier)\n\n return isFloating\n ? unfloatApp(app: app, showNotification: showNotification)\n : floatApp(app: app, showNotification: showNotification)\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/List/ListFloatingAppsCommand.swift", "//\n// ListFloatingAppsCommand.swift\n//\n// Created by Wojciech Kulik on 03/05/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct ListFloatingAppsCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"list-floating-apps\",\n abstract: \"List floating apps\"\n )\n\n @Flag(help: \"Include bundle id\")\n var withBundleId = false\n\n func run() throws {\n sendCommand(.listFloatingApps(withBundleId: withBundleId))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Workspaces/Models/MacApp.swift", "//\n// MacApp.swift\n//\n// Created by Wojciech Kulik on 06/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\ntypealias BundleId = String\n\nstruct MacApp: Codable, Hashable, Equatable {\n var name: String\n var bundleIdentifier: BundleId\n var iconPath: String?\n\n init(\n name: String,\n bundleIdentifier: BundleId,\n iconPath: String?\n ) {\n self.name = name\n self.bundleIdentifier = bundleIdentifier\n self.iconPath = iconPath\n }\n\n init(app: NSRunningApplication) {\n self.name = app.localizedName ?? \"\"\n self.bundleIdentifier = app.bundleIdentifier ?? \"\"\n self.iconPath = app.iconPath\n }\n\n init(from decoder: any Decoder) throws {\n if let app = try? decoder.singleValueContainer().decode(String.self) {\n // V1 - migration\n let runningApp = NSWorkspace.shared.runningApplications\n .first { $0.localizedName == app }\n\n self.name = app\n\n if let runningApp {\n self.bundleIdentifier = runningApp.bundleIdentifier ?? \"\"\n self.iconPath = runningApp.iconPath\n } else if let bundle = Bundle(path: \"/Applications/\\(app).app\") {\n self.bundleIdentifier = bundle.bundleIdentifier ?? \"\"\n self.iconPath = bundle.iconPath\n } else if let bundle = Bundle(path: \"/System/Applications/\\(app).app\") {\n self.bundleIdentifier = bundle.bundleIdentifier ?? \"\"\n self.iconPath = bundle.iconPath\n } else {\n self.bundleIdentifier = \"\"\n self.iconPath = nil\n }\n\n Migrations.appsMigrated = true\n } else {\n // V2\n let container = try decoder.container(keyedBy: CodingKeys.self)\n self.name = try container.decode(String.self, forKey: .name)\n self.bundleIdentifier = try container.decode(String.self, forKey: .bundleIdentifier)\n self.iconPath = try container.decodeIfPresent(String.self, forKey: .iconPath)\n }\n }\n\n static func == (lhs: MacApp, rhs: MacApp) -> Bool {\n if lhs.bundleIdentifier.isEmpty || rhs.bundleIdentifier.isEmpty {\n return lhs.name == rhs.name\n } else {\n return lhs.bundleIdentifier == rhs.bundleIdentifier\n }\n }\n}\n\nextension MacApp {\n var isFinder: Bool {\n bundleIdentifier == \"com.apple.finder\"\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/MainScreen/MainViewModel.swift", "//\n// MainViewModel.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Combine\nimport SwiftUI\n\nfinal class MainViewModel: ObservableObject {\n @Published var workspaces: [Workspace] = [] {\n didSet {\n guard workspaces.count == oldValue.count,\n workspaces.map(\\.id) != oldValue.map(\\.id) else { return }\n\n workspaceRepository.reorderWorkspaces(newOrder: workspaces.map(\\.id))\n }\n }\n\n @Published var workspaceApps: [MacApp]?\n\n @Published var workspaceName = \"\"\n @Published var workspaceShortcut: AppHotKey? {\n didSet { saveWorkspace() }\n }\n\n @Published var workspaceAssignShortcut: AppHotKey? {\n didSet { saveWorkspace() }\n }\n\n @Published var workspaceDisplay = \"\" {\n didSet { saveWorkspace() }\n }\n\n @Published var workspaceAppToFocus: MacApp? = AppConstants.lastFocusedOption {\n didSet { saveWorkspace() }\n }\n\n @Published var workspaceSymbolIconName: String? {\n didSet { saveWorkspace() }\n }\n\n @Published var isSymbolPickerPresented = false\n @Published var isInputDialogPresented = false\n @Published var userInput = \"\"\n\n var focusAppOptions: [MacApp] {\n [AppConstants.lastFocusedOption] + (workspaceApps ?? [])\n }\n\n var selectedApps: Set = [] {\n didSet {\n // To avoid warnings\n DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) { [self] in\n objectWillChange.send()\n }\n }\n }\n\n var selectedWorkspaces: Set = [] {\n didSet {\n selectedWorkspace = selectedWorkspaces.count == 1\n ? selectedWorkspaces.first\n : nil\n\n // To avoid warnings\n DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) { [self] in\n if selectedWorkspaces.count == 1,\n selectedWorkspaces.first?.id != oldValue.first?.id {\n selectedApps = []\n } else if selectedWorkspaces.count != 1 {\n selectedApps = []\n }\n objectWillChange.send()\n }\n }\n }\n\n private(set) var selectedWorkspace: Workspace? {\n didSet {\n guard selectedWorkspace != oldValue else { return }\n\n // To avoid warnings\n DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) {\n self.updateSelectedWorkspace()\n }\n }\n }\n\n var screens: [String] {\n let set = NSScreen.screens.compactMap(\\.localizedName).asSet\n let otherScreens = workspaces.map(\\.display)\n\n return Array(set.union(otherScreens))\n .filter(\\.isNotEmpty)\n .sorted()\n }\n\n var displayMode: DisplayMode { workspaceSettings.displayMode }\n\n private var cancellables: Set = []\n private var loadingWorkspace = false\n\n private let workspaceManager = AppDependencies.shared.workspaceManager\n private let workspaceRepository = AppDependencies.shared.workspaceRepository\n private let workspaceSettings = AppDependencies.shared.workspaceSettings\n\n init() {\n self.workspaces = workspaceRepository.workspaces\n self.workspaceDisplay = NSScreen.main?.localizedName ?? \"\"\n\n observe()\n }\n\n private func observe() {\n NotificationCenter.default\n .publisher(for: .appsListChanged)\n .sink { [weak self] _ in self?.reloadWorkspaces() }\n .store(in: &cancellables)\n\n NotificationCenter.default\n .publisher(for: .profileChanged)\n .sink { [weak self] _ in self?.reloadWorkspaces() }\n .store(in: &cancellables)\n\n workspaceSettings.updatePublisher\n .compactMap { [weak self] in self?.workspaceSettings.displayMode }\n .removeDuplicates()\n .sink { [weak self] _ in self?.objectWillChange.send() }\n .store(in: &cancellables)\n }\n\n private func updateSelectedWorkspace() {\n loadingWorkspace = true\n defer { loadingWorkspace = false }\n\n workspaceName = selectedWorkspace?.name ?? \"\"\n workspaceShortcut = selectedWorkspace?.activateShortcut\n workspaceAssignShortcut = selectedWorkspace?.assignAppShortcut\n workspaceDisplay = selectedWorkspace?.display ?? NSScreen.main?.localizedName ?? \"\"\n workspaceApps = selectedWorkspace?.apps\n workspaceAppToFocus = selectedWorkspace?.appToFocus ?? AppConstants.lastFocusedOption\n workspaceSymbolIconName = selectedWorkspace?.symbolIconName\n selectedWorkspace.flatMap { selectedWorkspaces = [$0] }\n }\n\n private func reloadWorkspaces() {\n workspaces = workspaceRepository.workspaces\n if let selectedWorkspace, let workspace = workspaces.first(where: { $0.id == selectedWorkspace.id }) {\n selectedWorkspaces = [workspace]\n } else {\n selectedWorkspaces = []\n }\n selectedApps = []\n }\n}\n\nextension MainViewModel {\n func saveWorkspace() {\n guard let selectedWorkspace, !loadingWorkspace else { return }\n\n if workspaceName.trimmingCharacters(in: .whitespaces).isEmpty {\n workspaceName = \"(empty)\"\n }\n\n let updatedWorkspace = Workspace(\n id: selectedWorkspace.id,\n name: workspaceName,\n display: workspaceDisplay,\n activateShortcut: workspaceShortcut,\n assignAppShortcut: workspaceAssignShortcut,\n apps: selectedWorkspace.apps,\n appToFocus: workspaceAppToFocus == AppConstants.lastFocusedOption ? nil : workspaceAppToFocus,\n symbolIconName: workspaceSymbolIconName\n )\n\n workspaceRepository.updateWorkspace(updatedWorkspace)\n workspaces = workspaceRepository.workspaces\n self.selectedWorkspace = workspaces.first { $0.id == selectedWorkspace.id }\n }\n\n func addWorkspace() {\n userInput = \"\"\n isInputDialogPresented = true\n\n $isInputDialogPresented\n .first { !$0 }\n .sink { [weak self] _ in\n guard let self, !self.userInput.isEmpty else { return }\n\n self.workspaceRepository.addWorkspace(name: self.userInput)\n self.workspaces = self.workspaceRepository.workspaces\n self.selectedWorkspace = self.workspaces.last\n }\n .store(in: &cancellables)\n }\n\n func deleteSelectedWorkspaces() {\n guard !selectedWorkspaces.isEmpty else { return }\n\n workspaceRepository.deleteWorkspaces(ids: selectedWorkspaces.map(\\.id).asSet)\n workspaces = workspaceRepository.workspaces\n selectedWorkspaces = []\n }\n\n func addApp() {\n guard let selectedWorkspace else { return }\n\n let fileChooser = FileChooser()\n let appUrl = fileChooser.runModalOpenPanel(\n allowedFileTypes: [.application],\n directoryURL: URL(filePath: \"/Applications\")\n )\n\n guard let appUrl else { return }\n\n let appName = appUrl.appName\n let appBundleId = appUrl.bundleIdentifier ?? \"\"\n let runningApp = NSWorkspace.shared.runningApplications.first { $0.bundleIdentifier == appBundleId }\n let isAgent = appUrl.bundle?.isAgent == true && (runningApp == nil || runningApp?.activationPolicy != .regular)\n\n guard !isAgent else {\n Alert.showOkAlert(\n title: appName,\n message: \"This application is an agent (runs in background) and cannot be managed by FlashSpace.\"\n )\n return\n }\n\n guard !selectedWorkspace.apps.containsApp(with: appBundleId) else { return }\n\n workspaceRepository.addApp(\n to: selectedWorkspace.id,\n app: .init(\n name: appName,\n bundleIdentifier: appBundleId,\n iconPath: appUrl.iconPath\n )\n )\n\n workspaces = workspaceRepository.workspaces\n self.selectedWorkspace = workspaces.first { $0.id == selectedWorkspace.id }\n\n workspaceManager.activateWorkspaceIfActive(selectedWorkspace.id)\n }\n\n func deleteSelectedApps() {\n guard let selectedWorkspace, !selectedApps.isEmpty else { return }\n\n let selectedApps = Array(selectedApps)\n\n for app in selectedApps {\n workspaceRepository.deleteApp(\n from: selectedWorkspace.id,\n app: app,\n notify: app == selectedApps.last\n )\n }\n\n workspaces = workspaceRepository.workspaces\n self.selectedWorkspace = workspaces.first { $0.id == selectedWorkspace.id }\n workspaceApps = self.selectedWorkspace?.apps\n self.selectedApps = []\n\n workspaceManager.activateWorkspaceIfActive(selectedWorkspace.id)\n }\n\n func resetWorkspaceSymbolIcon() {\n workspaceSymbolIconName = nil\n saveWorkspace()\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/NSRunningApplication.swift", "//\n// NSRunningApplication.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension NSRunningApplication {\n var toMacApp: MacApp { .init(app: self) }\n var iconPath: String? { bundleURL?.iconPath }\n}\n\nextension [NSRunningApplication] {\n func find(_ app: MacApp?) -> NSRunningApplication? {\n guard let app else { return nil }\n\n return first { $0.bundleIdentifier == app.bundleIdentifier }\n }\n\n func findFirstMatch(with apps: [MacApp]) -> NSRunningApplication? {\n let bundleIdentifiers = apps.map(\\.bundleIdentifier).asSet\n\n return first { bundleIdentifiers.contains($0.bundleIdentifier ?? \"\") }\n }\n\n func excludeFloatingAppsOnDifferentScreen() -> [NSRunningApplication] {\n let activeWorkspace = AppDependencies.shared.workspaceManager.activeWorkspace[NSScreen.main?.localizedName ?? \"\"]\n let floatingApps = AppDependencies.shared.floatingAppsSettings.floatingApps\n\n guard let activeWorkspace else { return self }\n\n return filter { app in\n !floatingApps.containsApp(app) || app.isOnAnyDisplay(activeWorkspace.displays)\n }\n }\n\n func regularVisibleApps(onDisplays displays: Set, excluding apps: [MacApp]) -> [NSRunningApplication] {\n filter { app in\n app.activationPolicy == .regular &&\n !app.isHidden &&\n !apps.containsApp(app) &&\n app.isOnAnyDisplay(displays)\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Workspaces/WorkspaceRepository.swift", "//\n// WorkspaceRepository.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Combine\nimport Foundation\n\nfinal class WorkspaceRepository: ObservableObject {\n @Published private(set) var workspaces: [Workspace] = []\n\n private let profilesRepository: ProfilesRepository\n\n init(profilesRepository: ProfilesRepository) {\n self.profilesRepository = profilesRepository\n self.workspaces = profilesRepository.selectedProfile.workspaces\n\n profilesRepository.onProfileChange = { [weak self] profile in\n self?.workspaces = profile.workspaces\n }\n }\n\n func addWorkspace(name: String) {\n let workspace = Workspace(\n id: .init(),\n name: name,\n display: NSScreen.main?.localizedName ?? \"\",\n activateShortcut: nil,\n assignAppShortcut: nil,\n apps: []\n )\n workspaces.append(workspace)\n notifyAboutChanges()\n }\n\n func addWorkspace(_ workspace: Workspace) {\n workspaces.append(workspace)\n notifyAboutChanges()\n }\n\n func updateWorkspace(_ workspace: Workspace) {\n guard let workspaceIndex = workspaces.firstIndex(where: { $0.id == workspace.id }) else { return }\n\n workspaces[workspaceIndex] = workspace\n notifyAboutChanges()\n AppDependencies.shared.hotKeysManager.refresh()\n }\n\n func deleteWorkspace(id: WorkspaceID) {\n workspaces.removeAll { $0.id == id }\n notifyAboutChanges()\n }\n\n func deleteWorkspaces(ids: Set) {\n workspaces.removeAll { ids.contains($0.id) }\n notifyAboutChanges()\n }\n\n func addApp(to workspaceId: WorkspaceID, app: MacApp) {\n guard let workspaceIndex = workspaces.firstIndex(where: { $0.id == workspaceId }) else { return }\n guard !workspaces[workspaceIndex].apps.contains(app) else { return }\n\n workspaces[workspaceIndex].apps.append(app)\n notifyAboutChanges()\n }\n\n func deleteApp(from workspaceId: WorkspaceID, app: MacApp, notify: Bool = true) {\n guard let workspaceIndex = workspaces.firstIndex(where: { $0.id == workspaceId }) else { return }\n\n if workspaces[workspaceIndex].appToFocus == app {\n workspaces[workspaceIndex].appToFocus = nil\n }\n\n workspaces[workspaceIndex].apps.removeAll { $0 == app }\n if notify { notifyAboutChanges() }\n }\n\n func deleteAppFromAllWorkspaces(app: MacApp) {\n for (index, var workspace) in workspaces.enumerated() {\n workspace.apps.removeAll { $0 == app }\n if workspace.appToFocus == app {\n workspace.appToFocus = nil\n }\n\n workspaces[index] = workspace\n }\n notifyAboutChanges()\n }\n\n func reorderWorkspaces(newOrder: [WorkspaceID]) {\n let map = newOrder.enumerated().reduce(into: [WorkspaceID: Int]()) { $0[$1.element] = $1.offset }\n workspaces = workspaces.sorted { map[$0.id] ?? 0 < map[$1.id] ?? 0 }\n notifyAboutChanges()\n }\n\n func moveApps(_ apps: [MacApp], from sourceWorkspaceId: WorkspaceID, to targetWorkspaceId: WorkspaceID) {\n guard let sourceWorkspaceIndex = workspaces.firstIndex(where: { $0.id == sourceWorkspaceId }),\n let targetWorkspaceIndex = workspaces.firstIndex(where: { $0.id == targetWorkspaceId }) else { return }\n\n if let appToFocus = workspaces[sourceWorkspaceIndex].appToFocus, apps.contains(appToFocus) {\n workspaces[sourceWorkspaceIndex].appToFocus = nil\n }\n\n let targetAppBundleIds = workspaces[targetWorkspaceIndex].apps.map(\\.bundleIdentifier).asSet\n let appsToAdd = apps.filter { !targetAppBundleIds.contains($0.bundleIdentifier) }\n\n workspaces[sourceWorkspaceIndex].apps.removeAll { apps.contains($0) }\n workspaces[targetWorkspaceIndex].apps.append(contentsOf: appsToAdd)\n\n notifyAboutChanges()\n NotificationCenter.default.post(name: .appsListChanged, object: nil)\n }\n\n private func notifyAboutChanges() {\n profilesRepository.updateWorkspaces(workspaces)\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/App/FloatingAppsCommand.swift", "//\n// FloatingAppsCommand.swift\n//\n// Created by Wojciech Kulik on 03/05/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct FloatingAppsCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"floating-apps\",\n abstract: \"Manage floating apps\"\n )\n\n enum Action: String, CaseIterable, ExpressibleByArgument {\n case float\n case unfloat\n case toggle\n }\n\n @Argument(help: \"The action to perform\")\n var action: Action\n\n @Option(help: .init(\n \"The name of the app or bundle id. If not provided, the active app will be used. Default: active app.\",\n valueName: \"name|bundle id\"\n ))\n var name: String?\n\n @Flag(help: \"Show toast notification\")\n var showNotification = false\n\n func run() throws {\n switch action {\n case .float:\n sendCommand(.floatApp(app: name, showNotification: showNotification))\n case .unfloat:\n sendCommand(.unfloatApp(app: name, showNotification: showNotification))\n case .toggle:\n sendCommand(.toggleFloatApp(app: name, showNotification: showNotification))\n }\n\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/PictureInPicture/PictureInPictureManager.swift", "//\n// PictureInPictureManager.swift\n//\n// Created by Wojciech Kulik on 12/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Combine\n\nfinal class PictureInPictureManager {\n typealias AXWindow = AXUIElement\n\n private var hiddenWindows: [NSRunningApplication: [AXWindow]] = [:]\n private var capturedFrame: [AXWindow: CGRect] = [:]\n private var cancellables: Set = []\n private var windowFocusObserver: AXObserver?\n\n private let settings: WorkspaceSettings\n\n init(settingsRepository: SettingsRepository) {\n self.settings = settingsRepository.workspaceSettings\n setupSignalHandlers()\n observePipFocusChangeNotification()\n }\n\n func restoreAppIfNeeded(app: NSRunningApplication) {\n guard settings.enablePictureInPictureSupport else { return }\n\n if hiddenWindows.keys.contains(app) {\n restoreFromCornerNonPipWindows(app: app)\n }\n }\n\n func restoreAllWindows() {\n for app in hiddenWindows.keys {\n showPipAppIfNeeded(app: app)\n }\n }\n\n func showPipAppIfNeeded(app: NSRunningApplication) {\n guard settings.enablePictureInPictureSupport,\n app.supportsPictureInPicture else { return }\n\n restoreFromCornerNonPipWindows(app: app)\n }\n\n func hidePipAppIfNeeded(app: NSRunningApplication) -> Bool {\n guard settings.enablePictureInPictureSupport,\n app.supportsPictureInPicture,\n app.isPictureInPictureActive\n else { return false }\n\n guard hiddenWindows[app] == nil else { return true }\n\n guard settings.displayMode == .static || app.allDisplays.count <= 1 else {\n // pip is not supported for multi-display apps\n return false\n }\n\n return hideInCornerNonPipWindows(app: app)\n }\n\n private func observePipFocusChangeNotification() {\n NotificationCenter.default\n .publisher(for: .pipFocusChanged)\n .sink { [weak self] _ in self?.restorePipWorkspace() }\n .store(in: &cancellables)\n }\n\n private func restorePipWorkspace() {\n guard let app = hiddenWindows.keys.first(where: { !$0.isPictureInPictureActive }) else { return }\n\n restoreAllWindows()\n\n let workspaceRepository = AppDependencies.shared.workspaceRepository\n let workspaceManager = AppDependencies.shared.workspaceManager\n let workspace = workspaceRepository.workspaces.first { $0.apps.containsApp(app) }\n\n guard let workspace else { return }\n\n windowFocusObserver = nil\n workspaceManager.activateWorkspace(workspace, setFocus: false)\n }\n\n private func restoreFromCornerNonPipWindows(app: NSRunningApplication) {\n windowFocusObserver = nil\n\n app.runWithoutAnimations {\n for window in hiddenWindows[app] ?? [] {\n if let previousFrame = capturedFrame[window] {\n window.setPosition(previousFrame.origin)\n capturedFrame.removeValue(forKey: window)\n }\n }\n }\n\n hiddenWindows.removeValue(forKey: app)\n }\n\n private func hideInCornerNonPipWindows(app: NSRunningApplication) -> Bool {\n guard let screenCorner = findScreenCorner(app: app) else { return false }\n\n let nonPipWindows = app.allWindows\n .map(\\.window)\n .filter { !$0.isPictureInPicture(bundleId: app.bundleIdentifier) }\n\n if nonPipWindows.isNotEmpty { observePipApp(app) }\n\n app.runWithoutAnimations {\n for window in nonPipWindows {\n if let windowFrame = window.frame, screenCorner != windowFrame.origin {\n capturedFrame[window] = windowFrame\n window.setPosition(screenCorner)\n }\n }\n }\n hiddenWindows[app] = nonPipWindows\n\n return true\n }\n\n private func findScreenCorner(app: NSRunningApplication) -> CGPoint? {\n guard let appScreen = NSScreen.screen(app.display) else {\n return nil\n }\n\n // Screen origin (0,0) is in the bottom-left corner, y-axis is pointing up\n // Window origin (0,0) is in the top-left corner, y-axis is pointing down\n // E.g. To place a window in the bottom-right corner of the screen\n // we need to set window origin to:\n // (screen.maxX - window.width, screen.maxY - window.height).\n\n let testOffset: CGFloat = 30.0\n let cornerOffset = CGFloat(settings.pipScreenCornerOffset)\n let appFrame = app.frame\n let screenFrame = appScreen.frame\n let leftCorner = CGPoint(x: screenFrame.minX, y: screenFrame.minY)\n let rightCorner = CGPoint(x: screenFrame.maxX, y: screenFrame.minY)\n let leftSide = leftCorner.applying(\n CGAffineTransform(translationX: -testOffset, y: testOffset)\n )\n let leftBottomSide = leftCorner.applying(\n CGAffineTransform(translationX: testOffset, y: -testOffset)\n )\n let rightSide = rightCorner.applying(\n CGAffineTransform(translationX: testOffset, y: testOffset)\n )\n let rightBottomSide = rightCorner.applying(\n CGAffineTransform(translationX: -testOffset, y: -testOffset)\n )\n\n let allScreens = NSScreen.screens.map(\\.frame)\n let isLeftCornerUsed = allScreens.contains(where: { $0.contains(leftSide) || $0.contains(leftBottomSide) })\n let isRightCornerUsed = allScreens.contains(where: { $0.contains(rightSide) || $0.contains(rightBottomSide) })\n\n if isLeftCornerUsed || !isRightCornerUsed || appFrame == nil {\n // right corner (window coordinates)\n return CGPoint(\n x: screenFrame.maxX - cornerOffset,\n y: screenFrame.maxY - cornerOffset\n )\n } else {\n // left corner (window coordinates)\n let appFrame = appFrame ?? .zero\n return CGPoint(\n x: screenFrame.minX + cornerOffset - appFrame.width,\n y: screenFrame.maxY - cornerOffset\n )\n }\n }\n\n private func setupSignalHandlers() {\n for code in [SIGTERM, SIGINT] {\n signal(code) {\n AppDependencies.shared.pictureInPictureManager.restoreAllWindows()\n exit($0)\n }\n }\n }\n\n private func observePipApp(_ app: NSRunningApplication) {\n guard settings.switchWorkspaceWhenPipCloses else { return }\n\n let callback: AXObserverCallback = { _, _, _, _ in\n NotificationCenter.default.post(name: .pipFocusChanged, object: nil)\n }\n\n let result = AXObserverCreate(app.processIdentifier, callback, &windowFocusObserver)\n\n guard result == .success, let observer = windowFocusObserver else { return }\n\n let appRef = AXUIElementCreateApplication(app.processIdentifier)\n AXObserverAddNotification(observer, appRef, kAXFocusedWindowChangedNotification as CFString, nil)\n CFRunLoopAddSource(CFRunLoopGetCurrent(), AXObserverGetRunLoopSource(observer), .defaultMode)\n }\n\n // MARK: - Alternative solution by minimizing windows (animation)\n private func deminimizeAllWindows(app: NSRunningApplication) {\n for window in app.allWindows.map(\\.window) {\n window.minimize(false)\n }\n }\n\n private func minimizeNonPipWindows(app: NSRunningApplication) {\n app.allWindows\n .map(\\.window)\n .filter { !$0.isPictureInPicture(bundleId: app.bundleIdentifier) }\n .forEach { $0.minimize(true) }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/MenuBar/MenuBarTitle.swift", "//\n// MenuBarTitle.swift\n//\n// Created by Wojciech Kulik on 31/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nenum MenuBarTitle {\n static let settings = AppDependencies.shared.menuBarSettings\n static let workspaceManager = AppDependencies.shared.workspaceManager\n static let profilesRepository = AppDependencies.shared.profilesRepository\n\n static func get() -> String? {\n let template = settings.menuBarTitleTemplate.trimmingCharacters(in: .whitespaces)\n\n guard settings.showMenuBarTitle, !template.isEmpty else { return nil }\n guard let activeWorkspace = workspaceManager.activeWorkspaceDetails else { return nil }\n\n return template\n .replacingOccurrences(of: \"$WORKSPACE_NUMBER\", with: activeWorkspace.number ?? \"\")\n .replacingOccurrences(of: \"$WORKSPACE\", with: activeWorkspace.name)\n .replacingOccurrences(of: \"$DISPLAY\", with: getDisplayName())\n .replacingOccurrences(of: \"$PROFILE\", with: profilesRepository.selectedProfile.name)\n }\n\n private static func getDisplayName() -> String {\n let aliases = settings.menuBarDisplayAliases\n .split(separator: \";\")\n .map { $0.split(separator: \"=\") }\n .reduce(into: [String: String]()) { result, pair in\n guard pair.count == 2 else { return }\n\n result[String(pair[0]).lowercased()] = String(pair[1])\n }\n\n let display = workspaceManager.activeWorkspaceDetails?.display ?? \"\"\n\n return aliases[display.lowercased()] ?? display\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Commands/GetCommands.swift", "//\n// GetCommands.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\n\nfinal class GetCommands: CommandExecutor {\n var workspaceManager: WorkspaceManager { AppDependencies.shared.workspaceManager }\n var profilesRepository: ProfilesRepository { AppDependencies.shared.profilesRepository }\n\n func execute(command: CommandRequest) -> CommandResponse? {\n switch command {\n case .getProfile:\n let result = profilesRepository.selectedProfile.name\n return CommandResponse(success: true, message: result)\n\n case .getWorkspace(let display):\n let workspace = workspaceManager.activeWorkspace[display ?? NSScreen.main?.localizedName ?? \"\"]\n if let workspace {\n let result = workspace.name\n return CommandResponse(success: true, message: result)\n } else {\n return CommandResponse(success: false, error: \"No active workspace\")\n }\n\n case .getApp(let withWindowsCount):\n if let app = NSWorkspace.shared.frontmostApplication, let appName = app.localizedName {\n if withWindowsCount {\n return CommandResponse(success: true, message: \"\\(appName)\\n\\(app.allWindows.count)\")\n } else {\n return CommandResponse(success: true, message: appName)\n }\n } else {\n return CommandResponse(success: false, error: \"No active app\")\n }\n\n case .getDisplay:\n if let display = NSScreen.main?.localizedName {\n return CommandResponse(success: true, message: display)\n } else {\n return CommandResponse(success: false, error: \"No display found\")\n }\n\n default:\n return nil\n }\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Workspace/UpdateWorkspaceCommand.swift", "//\n// UpdateWorkspaceCommand.swift\n//\n// Created by Wojciech Kulik on 02/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport ArgumentParser\nimport Foundation\n\nstruct UpdateWorkspaceRequest: Codable {\n enum Display: Codable {\n case active\n case name(String)\n }\n\n let name: String?\n let display: Display?\n}\n\nstruct UpdateWorkspaceCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"update-workspace\",\n abstract: \"Update a workspace\"\n )\n\n @Option(help: \"The name of the workspace to update.\")\n var workspace: String?\n\n @Flag(help: \"Update active workspace.\")\n var activeWorkspace = false\n\n @Option(help: \"The name of the display to be assigned.\")\n var display: String?\n\n @Flag(help: \"Assign active display.\")\n var activeDisplay = false\n\n func run() throws {\n if let display {\n sendCommand(.updateWorkspace(.init(name: workspace, display: .name(display))))\n } else if activeDisplay {\n sendCommand(.updateWorkspace(.init(name: workspace, display: .active)))\n } else {\n throw CommandError.operationFailed(\"Invalid command\")\n }\n\n runWithTimeout()\n }\n\n func validate() throws {\n if workspace != nil, activeWorkspace {\n throw CommandError.operationFailed(\"You cannot provide both a workspace name and use the --active-workspace flag\")\n }\n\n if display != nil, activeDisplay {\n throw CommandError.operationFailed(\"You cannot provide both a display name and use the --active-display flag\")\n }\n\n if workspace == nil, !activeWorkspace {\n throw CommandError.operationFailed(\"You must provide either a workspace name or use the --active-workspace flag\")\n }\n\n if display == nil, !activeDisplay {\n throw CommandError.operationFailed(\"You must provide either a display name or use the --active-display flag\")\n }\n\n if let display, !NSScreen.screens.contains(where: { $0.localizedName == display }) {\n throw CommandError.operationFailed(\"Display \\\"\\(display)\\\" not found\")\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Commands/WorkspaceCommands.swift", "//\n// WorkspaceCommands.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\n\nfinal class WorkspaceCommands: CommandExecutor {\n var workspaceManager: WorkspaceManager { AppDependencies.shared.workspaceManager }\n var workspaceRepository: WorkspaceRepository { AppDependencies.shared.workspaceRepository }\n\n // swiftlint:disable:next cyclomatic_complexity function_body_length\n func execute(command: CommandRequest) -> CommandResponse? {\n switch command {\n case .activateWorkspace(.some(let name), _, let clean):\n let workspace = workspaceRepository.workspaces.first { $0.name == name }\n if let workspace {\n if workspace.isDynamic, workspace.displays.isEmpty {\n return CommandResponse(success: false, error: \"\\(workspace.name) - No Running Apps To Show\")\n }\n workspaceManager.activateWorkspace(workspace, setFocus: true)\n if clean { workspaceManager.hideUnassignedApps() }\n return CommandResponse(success: true)\n } else {\n return CommandResponse(success: false, error: \"Workspace not found\")\n }\n\n case .activateWorkspace(_, .some(let number), let clean):\n let workspace = workspaceRepository.workspaces[safe: number - 1]\n if let workspace {\n if workspace.isDynamic, workspace.displays.isEmpty {\n return CommandResponse(success: false, error: \"\\(workspace.name) - No Running Apps To Show\")\n }\n workspaceManager.activateWorkspace(workspace, setFocus: true)\n if clean { workspaceManager.hideUnassignedApps() }\n return CommandResponse(success: true)\n } else {\n return CommandResponse(success: false, error: \"Workspace not found\")\n }\n\n case .updateWorkspace(let request):\n return updateWorkspace(request)\n\n case .nextWorkspace(let skipEmpty, let clean, let loop):\n workspaceManager.activateWorkspace(next: true, skipEmpty: skipEmpty, loop: loop)\n if clean { workspaceManager.hideUnassignedApps() }\n return CommandResponse(success: true)\n\n case .previousWorkspace(let skipEmpty, let clean, let loop):\n workspaceManager.activateWorkspace(next: false, skipEmpty: skipEmpty, loop: loop)\n if clean { workspaceManager.hideUnassignedApps() }\n return CommandResponse(success: true)\n\n case .recentWorkspace(let clean):\n workspaceManager.activateRecentWorkspace()\n if clean { workspaceManager.hideUnassignedApps() }\n return CommandResponse(success: true)\n\n case .createWorkspace(let request):\n let workspace = request.toWorkspace\n workspaceRepository.addWorkspace(workspace)\n if request.activate {\n workspaceManager.activateWorkspace(workspace, setFocus: true)\n }\n NotificationCenter.default.post(name: .appsListChanged, object: nil)\n return CommandResponse(success: true)\n\n case .deleteWorkspace(let name):\n let workspace = workspaceRepository.workspaces.first { $0.name == name }\n if let workspace {\n workspaceRepository.deleteWorkspace(id: workspace.id)\n NotificationCenter.default.post(name: .appsListChanged, object: nil)\n return CommandResponse(success: true)\n } else {\n return CommandResponse(success: false, error: \"Workspace not found\")\n }\n\n default:\n return nil\n }\n }\n\n private func updateWorkspace(_ request: UpdateWorkspaceRequest) -> CommandResponse {\n var workspace: Workspace?\n if let workspaceName = request.name {\n workspace = workspaceRepository.workspaces.first { $0.name == workspaceName }\n } else if let workspaceId = workspaceManager.activeWorkspaceDetails?.id {\n workspace = workspaceRepository.workspaces.first { $0.id == workspaceId }\n } else {\n return CommandResponse(success: false, error: \"Workspace not found\")\n }\n\n guard var workspace else {\n return CommandResponse(success: false, error: \"Workspace not found\")\n }\n\n if let display = request.display {\n switch display {\n case .active:\n if let display = NSWorkspace.shared.frontmostApplication?.display {\n workspace.display = display\n } else {\n return CommandResponse(success: false, error: \"No active display found\")\n }\n case .name(let name):\n workspace.display = name\n }\n }\n\n workspaceRepository.updateWorkspace(workspace)\n NotificationCenter.default.post(name: .appsListChanged, object: nil)\n\n return CommandResponse(success: true)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Profiles/ProfilesRepository.swift", "//\n// ProfilesRepository.swift\n//\n// Created by Wojciech Kulik on 26/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nfinal class ProfilesRepository: ObservableObject {\n @Published var profiles: [Profile] = [.default]\n @Published var selectedProfile: Profile = .default {\n didSet {\n guard shouldTrackProfileChange else { return }\n guard oldValue.id != selectedProfile.id else { return }\n setProfile(id: selectedProfile.id)\n }\n }\n\n var onProfileChange: ((Profile) -> ())?\n\n private var selectedProfileId: ProfileId? {\n get {\n UserDefaults.standard.string(forKey: AppConstants.UserDefaultsKey.selectedProfileId)\n .flatMap { UUID(uuidString: $0) }\n }\n set {\n if let newValue {\n UserDefaults.standard.set(newValue.uuidString, forKey: AppConstants.UserDefaultsKey.selectedProfileId)\n } else {\n UserDefaults.standard.removeObject(forKey: AppConstants.UserDefaultsKey.selectedProfileId)\n }\n }\n }\n\n private var shouldTrackProfileChange = true\n\n init() {\n loadFromDisk()\n }\n\n private func loadFromDisk() {\n shouldTrackProfileChange = false\n defer { shouldTrackProfileChange = true }\n\n guard let config = try? ConfigSerializer.deserialize(ProfilesConfig.self, filename: \"profiles\"),\n !config.profiles.isEmpty else {\n return createDefaultProfile()\n }\n\n let migrated = migrateOldConfigIfNeeded()\n profiles = config.profiles\n\n let selectedProfileId = selectedProfileId\n selectedProfile = profiles.first { $0.id == selectedProfileId } ?? profiles.first ?? .default\n\n if migrated { saveToDisk() }\n }\n\n private func migrateOldConfigIfNeeded() -> Bool {\n struct OldProfilesConfig: Codable {\n let selectedProfileId: ProfileId?\n }\n\n if let oldConfig = try? ConfigSerializer.deserialize(OldProfilesConfig.self, filename: \"profiles\"),\n let profileId = oldConfig.selectedProfileId {\n selectedProfileId = profileId\n Logger.log(\"Migrated old profile config to new format. Profile ID: \\(profileId)\")\n\n return true\n }\n\n return false\n }\n\n private func createDefaultProfile() {\n profiles = [.init(\n id: UUID(),\n name: \"Default\",\n workspaces: []\n )]\n selectedProfile = profiles[0]\n saveToDisk()\n }\n\n private func setProfile(id: ProfileId) {\n guard let profile = profiles.first(where: { $0.id == id }) else { return }\n\n saveToDisk()\n\n onProfileChange?(profile)\n NotificationCenter.default.post(name: .profileChanged, object: nil)\n Integrations.runOnProfileChangeIfNeeded(profile: profile.name)\n }\n}\n\nextension ProfilesRepository {\n func createProfile(name: String, keepWorkspaces: Bool) {\n var workspaces = [Workspace]()\n\n if keepWorkspaces {\n workspaces = selectedProfile.workspaces.map { workspace in\n var newWorkspace = workspace\n newWorkspace.id = UUID()\n return newWorkspace\n }\n }\n\n let newProfile = Profile(id: UUID(), name: name, workspaces: workspaces)\n profiles.append(newProfile)\n profiles.sort { $0.name < $1.name }\n\n saveToDisk()\n }\n\n func renameProfile(id: ProfileId, to newName: String) {\n guard let index = profiles.firstIndex(where: { $0.id == id }) else { return }\n\n profiles[index].name = newName\n profiles.sort { $0.name < $1.name }\n\n shouldTrackProfileChange = false\n selectedProfile = profiles.first { $0.id == id } ?? .default\n shouldTrackProfileChange = true\n\n saveToDisk()\n }\n\n func deleteProfile(id: ProfileId) {\n guard profiles.count > 1 else { return }\n\n profiles.removeAll { $0.id == id }\n\n if selectedProfile.id == id {\n shouldTrackProfileChange = false\n selectedProfile = profiles.first ?? .default\n shouldTrackProfileChange = true\n\n saveToDisk()\n setProfile(id: selectedProfile.id)\n } else {\n saveToDisk()\n }\n }\n\n func updateWorkspaces(_ workspaces: [Workspace]) {\n guard let profileIndex = profiles.firstIndex(where: { $0.id == selectedProfile.id }) else { return }\n\n profiles[profileIndex].workspaces = workspaces\n selectedProfile = profiles[profileIndex]\n saveToDisk()\n }\n\n func saveToDisk() {\n let config = ProfilesConfig(profiles: profiles)\n try? ConfigSerializer.serialize(filename: \"profiles\", config)\n\n selectedProfileId = selectedProfile.id\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/List/ListWorkspacesCommand.swift", "//\n// ListWorkspacesCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct ListWorkspacesCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"list-workspaces\",\n abstract: \"List workspaces\"\n )\n\n @Flag(help: \"Include assigned display name\")\n var withDisplay = false\n\n @Option(help: \"Profile name\")\n var profile: String?\n\n func run() throws {\n sendCommand(.listWorkspaces(withDisplay: withDisplay, profile: profile))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Open/OpenAppCommand.swift", "//\n// OpenAppCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport ArgumentParser\nimport Foundation\n\nstruct OpenAppCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"open\",\n abstract: \"Open FlashSpace\"\n )\n\n func run() throws {\n let url = NSWorkspace.shared.urlForApplication(withBundleIdentifier: \"pl.wojciechkulik.FlashSpace.dev\")\n ?? NSWorkspace.shared.urlForApplication(withBundleIdentifier: \"pl.wojciechkulik.FlashSpace\")\n\n if let url {\n let config = NSWorkspace.OpenConfiguration()\n config.activates = true\n NSWorkspace.shared.openApplication(at: url, configuration: config) { _, error in\n if let error {\n Self.exit(withError: CommandError.operationFailed(\"Failed to open FlashSpace: \\(error.localizedDescription)\"))\n } else {\n Self.exit()\n }\n }\n runWithTimeout()\n } else {\n throw CommandError.operationFailed(\"FlashSpace is not installed.\")\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/FocusManager/FocusedWindowTracker.swift", "//\n// FocusedWindowTracker.swift\n//\n// Created by Wojciech Kulik on 20/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Combine\n\nfinal class FocusedWindowTracker {\n private var cancellables = Set()\n\n private let workspaceRepository: WorkspaceRepository\n private let workspaceManager: WorkspaceManager\n private let settingsRepository: SettingsRepository\n private let pictureInPictureManager: PictureInPictureManager\n\n init(\n workspaceRepository: WorkspaceRepository,\n workspaceManager: WorkspaceManager,\n settingsRepository: SettingsRepository,\n pictureInPictureManager: PictureInPictureManager\n ) {\n self.workspaceRepository = workspaceRepository\n self.workspaceManager = workspaceManager\n self.settingsRepository = settingsRepository\n self.pictureInPictureManager = pictureInPictureManager\n }\n\n func startTracking() {\n NSWorkspace.shared.notificationCenter\n .publisher(for: NSWorkspace.didActivateApplicationNotification)\n .compactMap { $0.userInfo?[NSWorkspace.applicationUserInfoKey] as? NSRunningApplication }\n .removeDuplicates()\n .sink { [weak self] app in self?.activeApplicationChanged(app) }\n .store(in: &cancellables)\n }\n\n func stopTracking() {\n cancellables.removeAll()\n }\n\n private func activeApplicationChanged(_ app: NSRunningApplication) {\n guard settingsRepository.workspaceSettings.activeWorkspaceOnFocusChange else { return }\n\n let activeWorkspaces = workspaceManager.activeWorkspace.values\n\n // Skip if the workspace was activated recently\n guard Date().timeIntervalSince(workspaceManager.lastWorkspaceActivation) > 0.2 else { return }\n\n // Skip if the app is floating\n guard !settingsRepository.floatingAppsSettings.floatingApps.containsApp(app) else { return }\n\n // Find the workspace that contains the app.\n // The same app can be in multiple workspaces, the highest priority has the one\n // from the active workspace.\n guard let workspace = (activeWorkspaces + workspaceRepository.workspaces)\n .first(where: { $0.apps.containsApp(app) }) else { return }\n\n // Skip if the workspace is already active\n guard activeWorkspaces.count(where: { $0.id == workspace.id }) < workspace.displays.count else { return }\n\n // Skip if the focused window is in Picture in Picture mode\n guard !settingsRepository.workspaceSettings.enablePictureInPictureSupport ||\n !app.supportsPictureInPicture ||\n app.focusedWindow?.isPictureInPicture(bundleId: app.bundleIdentifier) != true else { return }\n\n let activate = { [self] in\n Logger.log(\"\")\n Logger.log(\"\")\n Logger.log(\"Activating workspace for app: \\(workspace.name)\")\n workspaceManager.updateLastFocusedApp(app.toMacApp, in: workspace)\n workspaceManager.activateWorkspace(workspace, setFocus: false)\n app.activate()\n\n // Restore the app if it was hidden\n if settingsRepository.workspaceSettings.enablePictureInPictureSupport, app.supportsPictureInPicture {\n pictureInPictureManager.restoreAppIfNeeded(app: app)\n }\n }\n\n if workspace.isDynamic, workspace.displays.isEmpty {\n DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(500)) {\n activate()\n }\n } else {\n activate()\n }\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/App/AssignVisibleAppsCommand.swift", "//\n// AssignVisibleAppsCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct AssignVisibleAppsCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"assign-visible-apps\",\n abstract: \"Assign visible apps to a workspace\"\n )\n\n @Option(\n name: .customLong(\"workspace\"),\n help: .init(\"The name of the workspace to assign apps to. Default: active workspace.\", valueName: \"name\")\n )\n var workspace: String?\n\n @Flag(help: \"Show toast notification\")\n var showNotification = false\n\n func run() throws {\n sendCommand(\n .assignVisibleApps(workspaceName: workspace, showNotification: showNotification)\n )\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/App/AssignAppCommand.swift", "//\n// AssignAppCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct AssignAppCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"assign-app\",\n abstract: \"Assign an app to a workspace\"\n )\n\n @Option(help: .init(\n \"The name of the app or bundle id. If not provided, the active app will be assigned. Default: active app.\",\n valueName: \"name|bundle id\"\n ))\n var name: String?\n\n @Option(\n name: .customLong(\"workspace\"),\n help: .init(\"The name of the workspace to assign the app to. Default: active workspace.\", valueName: \"name\")\n )\n var workspace: String?\n\n @Option(help: .init(\n \"Activate the workspace. Default: from app settings.\",\n valueName: \"true|false\"\n ))\n var activate: Bool?\n\n @Flag(help: \"Show toast notification\")\n var showNotification = false\n\n func run() throws {\n sendCommand(\n .assignApp(\n app: name,\n workspaceName: workspace,\n activate: activate,\n showNotification: showNotification\n )\n )\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Workspaces/WorkspaceHotKeys.swift", "//\n// WorkspaceHotKeys.swift\n//\n// Created by Wojciech Kulik on 08/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nfinal class WorkspaceHotKeys {\n private let workspaceManager: WorkspaceManager\n private let workspaceRepository: WorkspaceRepository\n private let workspaceSettings: WorkspaceSettings\n private let floatingAppsSettings: FloatingAppsSettings\n\n init(\n workspaceManager: WorkspaceManager,\n workspaceRepository: WorkspaceRepository,\n settingsRepository: SettingsRepository\n ) {\n self.workspaceManager = workspaceManager\n self.workspaceRepository = workspaceRepository\n self.workspaceSettings = settingsRepository.workspaceSettings\n self.floatingAppsSettings = settingsRepository.floatingAppsSettings\n }\n\n func getHotKeys() -> [(AppHotKey, () -> ())] {\n let hotKeys = [\n getAssignVisibleAppsHotKey(),\n getAssignAppHotKey(for: nil),\n getUnassignAppHotKey(),\n getToggleAssignmentHotKey(),\n getHideUnassignedAppsHotKey(),\n getRecentWorkspaceHotKey(),\n getCycleWorkspacesHotKey(next: false),\n getCycleWorkspacesHotKey(next: true)\n ] +\n workspaceRepository.workspaces\n .flatMap { [getActivateHotKey(for: $0), getAssignAppHotKey(for: $0)] }\n\n return hotKeys.compactMap(\\.self)\n }\n\n private func getActivateHotKey(for workspace: Workspace) -> (AppHotKey, () -> ())? {\n guard let shortcut = workspace.activateShortcut else { return nil }\n\n let action = { [weak self] in\n guard let self, let updatedWorkspace = workspaceRepository.workspaces\n .first(where: { $0.id == workspace.id }) else { return }\n\n if updatedWorkspace.isDynamic, updatedWorkspace.displays.isEmpty {\n Toast.showWith(\n icon: \"square.stack.3d.up\",\n message: \"\\(workspace.name) - No Running Apps To Show\",\n textColor: .gray\n )\n return\n }\n\n workspaceManager.activateWorkspace(updatedWorkspace, setFocus: true)\n }\n\n return (shortcut, action)\n }\n\n private func getAssignVisibleAppsHotKey() -> (AppHotKey, () -> ())? {\n guard let shortcut = workspaceSettings.assignVisibleApps else { return nil }\n\n return (shortcut, { [weak self] in self?.assignVisibleApps() })\n }\n\n private func getAssignAppHotKey(for workspace: Workspace?) -> (AppHotKey, () -> ())? {\n let shortcut = workspace == nil\n ? workspaceSettings.assignFocusedApp\n : workspace?.assignAppShortcut\n\n guard let shortcut else { return nil }\n\n return (shortcut, { [weak self] in self?.assignApp(to: workspace) })\n }\n\n private func getUnassignAppHotKey() -> (AppHotKey, () -> ())? {\n guard let shortcut = workspaceSettings.unassignFocusedApp else { return nil }\n\n return (shortcut, { [weak self] in self?.unassignApp() })\n }\n\n private func getToggleAssignmentHotKey() -> (AppHotKey, () -> ())? {\n guard let shortcut = workspaceSettings.toggleFocusedAppAssignment else { return nil }\n\n let action = { [weak self] in\n guard let self, let activeApp = NSWorkspace.shared.frontmostApplication else { return }\n\n if workspaceRepository.workspaces.flatMap(\\.apps).containsApp(activeApp) {\n unassignApp()\n } else {\n assignApp(to: nil)\n }\n }\n\n return (shortcut, action)\n }\n\n private func getHideUnassignedAppsHotKey() -> (AppHotKey, () -> ())? {\n guard let shortcut = workspaceSettings.hideUnassignedApps else { return nil }\n\n let action = { [weak self] in\n guard let self else { return }\n\n workspaceManager.hideUnassignedApps()\n }\n\n return (shortcut, action)\n }\n\n private func getCycleWorkspacesHotKey(next: Bool) -> (AppHotKey, () -> ())? {\n guard let shortcut = next\n ? workspaceSettings.switchToNextWorkspace\n : workspaceSettings.switchToPreviousWorkspace\n else { return nil }\n\n let action: () -> () = { [weak self] in\n guard let self else { return }\n\n workspaceManager.activateWorkspace(\n next: next,\n skipEmpty: workspaceSettings.skipEmptyWorkspacesOnSwitch,\n loop: workspaceSettings.loopWorkspaces\n )\n }\n\n return (shortcut, action)\n }\n\n private func getRecentWorkspaceHotKey() -> (AppHotKey, () -> ())? {\n guard let shortcut = workspaceSettings.switchToRecentWorkspace else { return nil }\n\n let action: () -> () = { [weak self] in\n self?.workspaceManager.activateRecentWorkspace()\n }\n\n return (shortcut, action)\n }\n}\n\nextension WorkspaceHotKeys {\n private func assignApp(to workspace: Workspace?) {\n guard let activeApp = NSWorkspace.shared.frontmostApplication else { return }\n guard let appName = activeApp.localizedName else { return }\n guard activeApp.activationPolicy == .regular else {\n Alert.showOkAlert(\n title: appName,\n message: \"This application is an agent (runs in background) and cannot be managed by FlashSpace.\"\n )\n return\n }\n\n guard let workspace = workspace ?? workspaceManager.activeWorkspace[activeApp.display ?? \"\"] else {\n Alert.showOkAlert(\n title: \"Error\",\n message: \"No workspace is active on the current display.\"\n )\n return\n }\n\n guard let updatedWorkspace = workspaceRepository.workspaces\n .first(where: { $0.id == workspace.id }) else { return }\n\n workspaceManager.assignApp(activeApp.toMacApp, to: updatedWorkspace)\n\n if !workspace.isDynamic {\n activeApp.centerApp(display: workspace.display)\n }\n\n Toast.showWith(\n icon: \"square.stack.3d.up\",\n message: \"\\(appName) - Assigned To \\(workspace.name)\",\n textColor: .positive\n )\n }\n\n private func assignVisibleApps() {\n guard let display = NSScreen.main?.localizedName else { return }\n guard let workspace = workspaceManager.activeWorkspace[display] else {\n Alert.showOkAlert(\n title: \"Error\",\n message: \"No workspace is active on the current display.\"\n )\n return\n }\n\n let visibleApps = NSWorkspace.shared.runningApplications\n .regularVisibleApps(onDisplays: workspace.displays, excluding: floatingAppsSettings.floatingApps)\n\n workspaceManager.assignApps(visibleApps.map(\\.toMacApp), to: workspace)\n\n Toast.showWith(\n icon: \"square.stack.3d.up\",\n message: \"Assigned \\(visibleApps.count) App(s) To \\(workspace.name)\",\n textColor: .positive\n )\n }\n\n private func unassignApp() {\n guard let activeApp = NSWorkspace.shared.frontmostApplication else { return }\n guard let appName = activeApp.localizedName else { return }\n\n if workspaceRepository.workspaces.flatMap(\\.apps).containsApp(activeApp) == true {\n Toast.showWith(\n icon: \"square.stack.3d.up.slash\",\n message: \"\\(appName) - Removed From Workspaces\",\n textColor: .negative\n )\n }\n\n workspaceRepository.deleteAppFromAllWorkspaces(app: activeApp.toMacApp)\n activeApp.hide()\n NotificationCenter.default.post(name: .appsListChanged, object: nil)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Workspaces/Models/Workspace.swift", "//\n// Workspace.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\n\ntypealias WorkspaceID = UUID\n\nstruct Workspace: Identifiable, Codable, Hashable {\n enum CodingKeys: String, CodingKey {\n case id\n case name\n case display\n case activateShortcut = \"shortcut\"\n case assignAppShortcut\n case apps\n case appToFocus\n case symbolIconName\n }\n\n var id: WorkspaceID\n var name: String\n var display: DisplayName\n var activateShortcut: AppHotKey?\n var assignAppShortcut: AppHotKey?\n var apps: [MacApp]\n var appToFocus: MacApp?\n var symbolIconName: String?\n}\n\nextension Workspace {\n var displays: Set {\n if NSScreen.screens.count == 1 {\n return [NSScreen.main?.localizedName ?? \"\"]\n } else if isDynamic {\n // TODO: After disconnecting a display, the detection may not work correctly.\n // The app will have the old coordinates until it is shown again, which\n // prevents from detecting the correct display.\n //\n // The workaround is to activate the app manually to update its frame.\n return NSWorkspace.shared.runningApplications\n .filter { $0.activationPolicy == .regular && apps.containsApp($0) }\n .flatMap(\\.allDisplays)\n .asSet\n } else {\n return [displayManager.resolveDisplay(display)]\n }\n }\n\n var displayForPrint: DisplayName {\n if isDynamic,\n let mainDisplay = NSScreen.main?.localizedName,\n displays.contains(mainDisplay) {\n return mainDisplay\n }\n\n return isDynamic\n ? displayManager.lastActiveDisplay(from: displays)\n : displayManager.resolveDisplay(display)\n }\n\n var isOnTheCurrentScreen: Bool {\n guard let currentScreen = NSScreen.main?.localizedName else { return false }\n return displays.contains(currentScreen)\n }\n\n var isDynamic: Bool {\n AppDependencies.shared.workspaceSettings.displayMode == .dynamic\n }\n\n private var displayManager: DisplayManager {\n AppDependencies.shared.displayManager\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Displays/DisplayManager.swift", "//\n// DisplayManager.swift\n//\n// Created by Moritz Brödel on 19/06/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Combine\n\nfinal class DisplayManager: ObservableObject {\n struct Focus {\n let display: DisplayName\n let app: MacApp\n }\n\n private var focusHistory: [Focus] = []\n private let workspaceSettings: WorkspaceSettings\n\n init(settingsRepository: SettingsRepository) {\n self.workspaceSettings = settingsRepository.workspaceSettings\n }\n\n func lastFocusedDisplay(where condition: (Focus) -> Bool) -> Focus? {\n focusHistory.last(where: condition)\n }\n\n func trackDisplayFocus(on display: DisplayName, for application: NSRunningApplication) {\n guard !application.isFinder || application.allWindows.isNotEmpty else { return }\n\n focusHistory.removeAll { $0.display == display }\n focusHistory.append(.init(display: display, app: application.toMacApp))\n }\n\n func getCursorScreen() -> DisplayName? {\n let cursorLocation = NSEvent.mouseLocation\n return NSScreen.screens\n .first { NSMouseInRect(cursorLocation, $0.frame, false) }?\n .localizedName\n }\n\n func resolveDisplay(_ display: DisplayName) -> DisplayName {\n guard !NSScreen.isConnected(display) else { return display }\n\n let alternativeDisplays = workspaceSettings.alternativeDisplays\n .split(separator: \";\")\n .map { $0.split(separator: \"=\") }\n .compactMap { pair -> (source: String, target: String)? in\n guard pair.count == 2 else { return nil }\n return (String(pair[0]).trimmed, String(pair[1]).trimmed)\n }\n\n let alternative = alternativeDisplays\n .filter { $0.source == display }\n .map(\\.target)\n .first(where: NSScreen.isConnected)\n\n return alternative ?? NSScreen.main?.localizedName ?? \"\"\n }\n\n func lastActiveDisplay(from candidates: Set) -> DisplayName {\n if let recentDisplay = lastFocusedDisplay(where: { candidates.contains($0.display) })?.display {\n return recentDisplay\n }\n\n if let cursorDisplay = getCursorScreen(), candidates.contains(cursorDisplay) {\n return cursorDisplay\n }\n\n return candidates.first ?? NSScreen.main?.localizedName ?? \"\"\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/List/ListDisplays.swift", "//\n// ListDisplays.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport ArgumentParser\nimport Foundation\n\nstruct ListDisplaysCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"list-displays\",\n abstract: \"List displays\"\n )\n\n func run() throws {\n for screen in NSScreen.screens {\n print(screen.localizedName)\n }\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Workspace/WorkspaceCommand.swift", "//\n// WorkspaceCommand.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct WorkspaceCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"workspace\",\n abstract: \"Activate a workspace\"\n )\n\n @Option(help: .init(\"The name of the workspace\"))\n var name: String?\n\n @Option(help: .init(\n \"The number of the workspace to activate. Starting from 1.\",\n valueName: \"number\"\n ))\n var number: Int?\n\n @Flag(help: \"Activate the next workspace\")\n var next = false\n\n @Flag(help: \"Activate the previous workspace\")\n var prev = false\n\n @Flag(help: \"Activate the most recently used workspace\")\n var recent = false\n\n @Flag(help: \"Skip empty workspaces (works only with --next or --prev)\")\n var skipEmpty = false\n\n @Flag(help: \"Loop back to the first workspace when reaching the last one and vice versa (works only with --next or --prev)\")\n var loop = false\n\n @Flag(help: \"Hide all apps that are not assigned to the selected workspace\")\n var clean = false\n\n func run() throws {\n if let name {\n sendCommand(.activateWorkspace(name: name, number: nil, clean: clean))\n } else if let number {\n sendCommand(.activateWorkspace(name: nil, number: number, clean: clean))\n } else if next {\n sendCommand(.nextWorkspace(skipEmpty: skipEmpty, clean: clean, loop: loop))\n } else if prev {\n sendCommand(.previousWorkspace(skipEmpty: skipEmpty, clean: clean, loop: loop))\n } else if recent {\n sendCommand(.recentWorkspace(clean: clean))\n } else {\n fallbackToHelp()\n }\n\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/FloatingApps/FloatingAppsSettingsView.swift", "//\n// FloatingAppsSettingsView.swift\n//\n// Created by Wojciech Kulik on 12/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct FloatingAppsSettingsView: View {\n @StateObject var viewModel = FloatingAppsSettingsViewModel()\n @StateObject var settings = AppDependencies.shared.floatingAppsSettings\n\n var body: some View {\n Form {\n Section(header: header) {\n if settings.floatingApps.contains(where: \\.bundleIdentifier.isEmpty) {\n Text(\"Could not migrate some apps. Please re-add them to fix the problem.\")\n .foregroundStyle(.errorRed)\n .font(.callout)\n }\n\n if settings.floatingApps.isEmpty {\n Text(\"(no floating apps added)\")\n .foregroundStyle(.secondary)\n .font(.callout)\n } else {\n appsList\n }\n\n Text(\"Floating applications remain visible across all workspaces.\")\n .foregroundStyle(.secondary)\n .font(.callout)\n }\n\n Section(\"Shortcuts\") {\n hotkey(\"Float Focused App\", for: $settings.floatTheFocusedApp)\n hotkey(\"Unfloat Focused App\", for: $settings.unfloatTheFocusedApp)\n hotkey(\"Toggle Focused App Floating\", for: $settings.toggleTheFocusedAppFloating)\n }\n }\n .formStyle(.grouped)\n .navigationTitle(\"Floating Apps\")\n }\n\n private var appsList: some View {\n VStack(alignment: .leading) {\n ForEach(settings.floatingApps, id: \\.self) { app in\n HStack {\n Button {\n viewModel.deleteFloatingApp(app: app)\n } label: {\n Image(systemName: \"x.circle.fill\").opacity(0.8)\n }.buttonStyle(.borderless)\n\n Text(app.name)\n .foregroundStyle(app.bundleIdentifier.isEmpty ? .errorRed : .primary)\n }\n }\n }\n }\n\n private var header: some View {\n HStack {\n Text(\"Floating Apps\")\n Spacer()\n Button(action: viewModel.addFloatingApp) {\n Image(systemName: \"plus\")\n }\n }\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/App/UnassignAppCommand.swift", "//\n// UnassignAppCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct UnassignAppCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"unassign-app\",\n abstract: \"Unassign an app from all workspaces\"\n )\n @Option(help: .init(\n \"The name of the app or bundle id. If not provided, the active app will be unassigned. Default: active app.\",\n valueName: \"name|bundle id\"\n ))\n var name: String?\n\n @Flag(help: \"Show toast notification\")\n var showNotification = false\n\n func run() throws {\n sendCommand(.unassignApp(app: name, showNotification: showNotification))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Accessibility/NSRunningApplication+Properties.swift", "//\n// NSRunningApplication+Properties.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension NSRunningApplication {\n var frame: CGRect? { mainWindow?.frame }\n var isMinimized: Bool { mainWindow?.isMinimized == true }\n\n var display: DisplayName? {\n // HACK: Workaround for Orion Browser which puts\n // the main window on the main screen with size (1,1)\n if isOrion {\n allWindows\n .first { $0.frame.width > 10 && $0.frame.height > 10 }?\n .frame\n .getDisplay()\n } else {\n frame?.getDisplay()\n }\n }\n\n var allDisplays: Set {\n allWindows\n .compactMap { $0.frame.getDisplay() }\n .asSet\n }\n\n var mainWindow: AXUIElement? {\n // HACK: Python app with running pygame module is causing\n // huge lags when other apps attempt to access its window\n // through the accessibility API.\n // A workaround is to simply skip this app.\n guard !isPython else { return nil }\n\n let appElement = AXUIElementCreateApplication(processIdentifier)\n return appElement.getAttribute(.mainWindow)\n }\n\n var focusedWindow: AXUIElement? {\n guard !isPython else { return nil }\n\n let appElement = AXUIElementCreateApplication(processIdentifier)\n return appElement.getAttribute(.focusedWindow)\n }\n\n var allWindows: [(window: AXUIElement, frame: CGRect)] {\n guard !isPython else { return [] }\n\n let appElement = AXUIElementCreateApplication(processIdentifier)\n let windows: [AXUIElement]? = appElement.getAttribute(.windows)\n\n return windows?\n .filter { $0.role == \"AXWindow\" }\n .compactMap { window in window.frame.flatMap { (window, $0) } }\n ?? []\n }\n\n func isOnAnyDisplay(_ displays: Set) -> Bool {\n !allDisplays.isDisjoint(with: displays)\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/App/FocusCommand.swift", "//\n// FocusCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct FocusCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"focus\",\n abstract: \"Focus window\"\n )\n\n @Option(\n name: .customLong(\"direction\"),\n help: .init(\"Focus a window in a specific direction\", valueName: \"up|down|left|right\")\n )\n var focusDirection: FocusDirection?\n\n @Flag(help: \"Focus the next workspace app\")\n var nextApp = false\n\n @Flag(help: \"Focus the previous workspace app\")\n var prevApp = false\n\n @Flag(help: \"Focus the next workspace window\")\n var nextWindow = false\n\n @Flag(help: \"Focus the previous workspace window\")\n var prevWindow = false\n\n func run() throws {\n if let focusDirection {\n sendCommand(.focusWindow(direction: focusDirection))\n } else if nextApp {\n sendCommand(.focusNextApp)\n } else if prevApp {\n sendCommand(.focusPreviousApp)\n } else if nextWindow {\n sendCommand(.focusNextWindow)\n } else if prevWindow {\n sendCommand(.focusPreviousWindow)\n } else {\n fallbackToHelp()\n }\n\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/MainScreen/WorkspaceCell.swift", "//\n// WorkspaceCell.swift\n//\n// Created by Wojciech Kulik on 20/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\nimport UniformTypeIdentifiers\n\nstruct WorkspaceCell: View {\n @State var isTargeted = false\n @Binding var selectedApps: Set\n\n let workspaceManager: WorkspaceManager = AppDependencies.shared.workspaceManager\n let workspaceRepository: WorkspaceRepository = AppDependencies.shared.workspaceRepository\n\n let workspace: Workspace\n\n var body: some View {\n HStack {\n Image(systemName: workspace.symbolIconName ?? .defaultIconSymbol)\n .resizable()\n .scaledToFit()\n .frame(width: 15, height: 15)\n .foregroundStyle(Color.workspaceIcon)\n\n Text(workspace.name)\n .lineLimit(1)\n .foregroundColor(\n isTargeted || workspace.apps.contains(where: \\.bundleIdentifier.isEmpty)\n ? .errorRed\n : .primary\n )\n Spacer()\n }\n .contentShape(Rectangle())\n .dropDestination(for: MacAppWithWorkspace.self) { apps, _ in\n guard let sourceWorkspaceId = apps.first?.workspaceId else { return false }\n\n workspaceRepository.moveApps(\n apps.map(\\.app),\n from: sourceWorkspaceId,\n to: workspace.id\n )\n selectedApps = []\n\n workspaceManager.activateWorkspaceIfActive(sourceWorkspaceId)\n workspaceManager.activateWorkspaceIfActive(workspace.id)\n\n return true\n } isTargeted: {\n isTargeted = $0\n }\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Get/GetAppCommand.swift", "//\n// GetAppCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport ArgumentParser\nimport Foundation\n\nstruct GetAppCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"get-app\",\n abstract: \"Get active app\"\n )\n\n @Flag(help: \"Include windows count\")\n var withWindowsCount = false\n\n func run() throws {\n sendCommand(.getApp(withWindowsCount: withWindowsCount))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/FocusManager/Models/MacAppWithWindows.swift", "//\n// MacAppWithWindows.swift\n//\n// Created by Wojciech Kulik on 04/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport CoreGraphics\n\nstruct MacAppWithWindows {\n struct MacAppWindow {\n let frame: CGRect\n let title: String\n let axWindow: AXUIElement\n }\n\n let app: NSRunningApplication\n let bundleIdentifier: BundleId\n\n /// Sorted by title and then by x position\n let windows: [MacAppWindow]\n\n init(app: NSRunningApplication) {\n self.app = app\n self.bundleIdentifier = app.bundleIdentifier ?? \"\"\n self.windows = app.allWindows\n .map { MacAppWindow(frame: $0.frame, title: $0.window.title ?? \"\", axWindow: $0.window) }\n .sorted { $0.title < $1.title || $0.title == $1.title && $0.frame.minX < $1.frame.minX }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/MainScreen/MainView.swift", "//\n// MainView.swift\n// FlashSpace\n//\n// Created by Wojciech Kulik on 19/01/2025.\n//\n\nimport AppKit\nimport SwiftUI\nimport SymbolPicker\n\nstruct MainView: View {\n @StateObject var viewModel = MainViewModel()\n\n var body: some View {\n HStack(spacing: 16.0) {\n workspaces\n assignedApps\n WorkspaceConfigurationView(viewModel: viewModel)\n .frame(maxWidth: 230)\n }\n .padding()\n .fixedSize()\n .sheet(isPresented: $viewModel.isInputDialogPresented) {\n InputDialog(\n title: \"Enter workspace name:\",\n userInput: $viewModel.userInput,\n isPresented: $viewModel.isInputDialogPresented\n )\n }\n .sheet(isPresented: $viewModel.isSymbolPickerPresented) {\n SymbolPicker(symbol: $viewModel.workspaceSymbolIconName)\n }\n }\n\n private var workspaces: some View {\n VStack(alignment: .leading) {\n Text(\"Workspaces:\")\n\n List(\n $viewModel.workspaces,\n id: \\.self,\n editActions: .move,\n selection: $viewModel.selectedWorkspaces\n ) { binding in\n WorkspaceCell(\n selectedApps: $viewModel.selectedApps,\n workspace: binding.wrappedValue\n )\n }\n .frame(width: 200, height: 350)\n\n HStack {\n Button(action: viewModel.addWorkspace) {\n Image(systemName: \"plus\")\n }\n\n Button(action: viewModel.deleteSelectedWorkspaces) {\n Image(systemName: \"trash\")\n }.disabled(viewModel.selectedWorkspaces.isEmpty)\n\n Spacer()\n }\n }\n }\n\n private var assignedApps: some View {\n VStack(alignment: .leading) {\n Text(\"Assigned Apps:\")\n\n List(\n viewModel.workspaceApps ?? [],\n id: \\.self,\n selection: $viewModel.selectedApps\n ) { app in\n AppCell(\n workspaceId: viewModel.selectedWorkspace?.id ?? UUID(),\n app: app\n )\n }\n .frame(width: 200, height: 350)\n\n HStack {\n Button(action: viewModel.addApp) {\n Image(systemName: \"plus\")\n }.disabled(viewModel.selectedWorkspace == nil)\n\n Button(action: viewModel.deleteSelectedApps) {\n Image(systemName: \"trash\")\n }\n .disabled(viewModel.selectedApps.isEmpty)\n .keyboardShortcut(.delete)\n }\n }\n }\n}\n\n#Preview {\n MainView()\n}\n"], ["/FlashSpace/FlashSpace/Features/MenuBar/FlashSpaceMenuBar.swift", "//\n// FlashSpaceMenuBar.swift\n//\n// Created by Wojciech Kulik on 13/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct FlashSpaceMenuBar: Scene {\n @Environment(\\.openWindow) private var openWindow\n\n @StateObject private var workspaceManager = AppDependencies.shared.workspaceManager\n @StateObject private var settingsRepository = AppDependencies.shared.settingsRepository\n @StateObject private var profilesRepository = AppDependencies.shared.profilesRepository\n @StateObject private var workspaceRepository = AppDependencies.shared.workspaceRepository\n\n var body: some Scene {\n MenuBarExtra {\n Text(\"FlashSpace v\\(AppConstants.version)\")\n\n Button(\"Open\") {\n openWindow(id: \"main\")\n NSApp.activate(ignoringOtherApps: true)\n }\n\n if settingsRepository.spaceControlSettings.enableSpaceControl {\n Button(\"Space Control\") {\n SpaceControl.show()\n }\n }\n\n Divider()\n\n Button(\"Settings\") {\n openWindow(id: \"settings\")\n NSApp.activate(ignoringOtherApps: true)\n }.keyboardShortcut(\",\")\n\n Menu(\"Profiles\") {\n ForEach(profilesRepository.profiles) { profile in\n Toggle(\n profile.name,\n isOn: .init(\n get: { profilesRepository.selectedProfile == profile },\n set: {\n if $0 { profilesRepository.selectedProfile = profile }\n }\n )\n )\n }\n }.hidden(profilesRepository.profiles.count < 2)\n\n Menu(\"Workspaces\") {\n ForEach(workspaceRepository.workspaces) { workspace in\n Button {\n if workspace.isDynamic, workspace.displays.isEmpty {\n Toast.showWith(\n icon: \"square.stack.3d.up\",\n message: \"\\(workspace.name) - No Running Apps To Show\",\n textColor: .gray\n )\n } else {\n workspaceManager.activateWorkspace(workspace, setFocus: true)\n }\n } label: {\n Text(workspace.name)\n }\n .keyboardShortcut(workspace.activateShortcut?.toKeyboardShortcut)\n }\n }.hidden(workspaceRepository.workspaces.count < 2)\n\n Divider()\n\n Button(\"Donate\") {\n if let url = URL(string: \"https://github.com/sponsors/wojciech-kulik\") {\n NSWorkspace.shared.open(url)\n }\n }\n\n Button(\"Project Website\") {\n if let url = URL(string: \"https://github.com/wojciech-kulik/FlashSpace\") {\n NSWorkspace.shared.open(url)\n }\n }\n\n Button(\"Check for Updates\") {\n UpdatesManager.shared.checkForUpdates()\n }\n\n Divider()\n\n Button(\"Quit\") {\n NSApp.terminate(nil)\n }.keyboardShortcut(\"q\")\n } label: {\n HStack {\n let title = MenuBarTitle.get()\n if title == nil || settingsRepository.menuBarSettings.showMenuBarIcon {\n Image(systemName: workspaceManager.activeWorkspaceDetails?.symbolIconName ?? .defaultIconSymbol)\n }\n if let title { Text(title) }\n }\n .id(settingsRepository.menuBarSettings.menuBarTitleTemplate)\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Workspaces/WorkspacesSettingsView.swift", "//\n// WorkspacesSettingsView.swift\n//\n// Created by Wojciech Kulik on 24/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct WorkspacesSettingsView: View {\n @StateObject var settings = AppDependencies.shared.workspaceSettings\n @StateObject var viewModel = WorkspaceSettingsViewModel()\n\n var body: some View {\n Form {\n Section(\"Displays\") {\n Picker(\"Display Assignment Mode\", selection: $settings.displayMode) {\n ForEach(DisplayMode.allCases) { action in\n Text(action.description).tag(action)\n }\n }\n\n Text(\"Static Mode requires you to manually assign workspaces to displays.\\n\\n\" +\n \"Dynamic Mode automatically assigns workspaces to displays \" +\n \"based on where your applications are located. In this mode, a single workspace can span across multiple displays.\"\n )\n .font(.callout)\n .foregroundStyle(.secondary)\n }\n\n Section(\"Behaviors\") {\n Toggle(\"Activate Workspace On Focus Change\", isOn: $settings.activeWorkspaceOnFocusChange)\n Toggle(\"Center Cursor In Focused App On Workspace Change\", isOn: $settings.centerCursorOnWorkspaceChange)\n Toggle(\"Automatically Change Workspace On App Assignment\", isOn: $settings.changeWorkspaceOnAppAssign)\n Toggle(\"Keep Unassigned Apps On Workspace Change\", isOn: $settings.keepUnassignedAppsOnSwitch)\n Toggle(\"Show Hidden Apps On Workspace Activation\", isOn: $settings.restoreHiddenAppsOnSwitch)\n .help(\"Restores hidden apps, even if they were hidden manually\")\n Toggle(\"Enable Workspace Transition Animation\", isOn: $settings.enableWorkspaceTransitions)\n .help(\"Show a brief visual transition effect when switching between workspaces\")\n\n if settings.enableWorkspaceTransitions {\n HStack {\n VStack(alignment: .leading) {\n Text(\"Transition Duration\")\n Text(\"Controls how long the transition animation lasts when switching workspaces\")\n .font(.caption)\n .foregroundStyle(.secondary)\n }\n Spacer()\n Slider(value: $settings.workspaceTransitionDuration, in: 0.1...0.5, step: 0.05)\n .frame(width: 150)\n Text(\"\\(settings.workspaceTransitionDuration, specifier: \"%.2f\")s\")\n .foregroundStyle(.secondary)\n .frame(width: 45.0, alignment: .trailing)\n }\n .padding(.leading, 16)\n\n HStack {\n VStack(alignment: .leading) {\n Text(\"Transition Dimming\")\n Text(\"Adjusts how dark the screen becomes during workspace transitions\")\n .font(.caption)\n .foregroundStyle(.secondary)\n }\n Spacer()\n Slider(value: $settings.workspaceTransitionDimming, in: 0.05...0.5, step: 0.05)\n .frame(width: 150)\n Text(\"\\(Int(settings.workspaceTransitionDimming * 100))%\")\n .foregroundStyle(.secondary)\n .frame(width: 45.0, alignment: .trailing)\n }\n .padding(.leading, 16)\n }\n }\n\n Section(\"Shortcuts\") {\n hotkey(\"Assign Visible Apps (to active workspace)\", for: $settings.assignVisibleApps)\n hotkey(\"Assign Focused App (to active workspace)\", for: $settings.assignFocusedApp)\n hotkey(\"Unassign Focused App\", for: $settings.unassignFocusedApp)\n hotkey(\"Toggle Focused App Assignment\", for: $settings.toggleFocusedAppAssignment)\n hotkey(\"Hide Unassigned Apps\", for: $settings.hideUnassignedApps)\n }\n\n Section {\n hotkey(\"Recent Workspace\", for: $settings.switchToRecentWorkspace)\n hotkey(\"Previous Workspace\", for: $settings.switchToPreviousWorkspace)\n hotkey(\"Next Workspace\", for: $settings.switchToNextWorkspace)\n Toggle(\"Loop Workspaces\", isOn: $settings.loopWorkspaces)\n Toggle(\"Skip Empty Workspaces On Switch\", isOn: $settings.skipEmptyWorkspacesOnSwitch)\n Text(\n \"These shortcuts allow you to cycle through workspaces on the display where the cursor is currently located.\"\n )\n .foregroundStyle(.secondary)\n .font(.callout)\n }\n\n Section {\n HStack {\n Text(\"Alternative Displays\")\n TextField(\"\", text: $settings.alternativeDisplays)\n .foregroundColor(.secondary)\n .standardPlaceholder(settings.alternativeDisplays.isEmpty)\n }\n\n Text(\n \"\"\"\n Example: DELL XYZ=Benq ABC;LG 123=DELL XYZ\n\n This setting is useful if you want to use the same configuration for different displays.\n You can tell FlashSpace which display should be used if the selected one is not connected.\n\n If only one display is connected, it will always act as the fallback.\n \"\"\"\n )\n .foregroundStyle(.secondary)\n .font(.callout)\n }\n .hidden(settings.displayMode == .dynamic)\n\n Section(\"Picture-in-Picture\") {\n Toggle(\"Enable Picture-in-Picture Support\", isOn: $settings.enablePictureInPictureSupport)\n Toggle(\"Switch Workspace When Picture-in-Picture Closes\", isOn: $settings.switchWorkspaceWhenPipCloses)\n\n HStack {\n Text(\"Screen Corner Offset\")\n Spacer()\n Text(\"\\(settings.pipScreenCornerOffset)\")\n Stepper(\n \"\",\n value: $settings.pipScreenCornerOffset,\n in: 1...50,\n step: 1\n ).labelsHidden()\n }\n\n Text(\n \"If a supported browser has Picture-in-Picture active, other \" +\n \"windows will be hidden in a screen corner to keep PiP visible.\"\n )\n .foregroundStyle(.secondary)\n .font(.callout)\n }\n\n Section(header: pipAppsHeader) {\n if settings.pipApps.isEmpty {\n Text(\"You can apply Picture-in-Picture behavior to any app by adding it here.\")\n .foregroundStyle(.secondary)\n .font(.callout)\n } else {\n pipAppsList\n }\n }\n .opacity(settings.enablePictureInPictureSupport ? 1 : 0.5)\n }\n .sheet(isPresented: $viewModel.isInputDialogPresented) {\n InputDialog(\n title: \"Enter PiP window title regex:\",\n placeholder: \"e.g. Meeting with.*\",\n userInput: $viewModel.windowTitleRegex,\n isPresented: $viewModel.isInputDialogPresented\n )\n }\n .formStyle(.grouped)\n .navigationTitle(\"Workspaces\")\n }\n\n private var pipAppsList: some View {\n VStack(alignment: .leading) {\n ForEach(settings.pipApps, id: \\.self) { app in\n HStack {\n Button {\n viewModel.deletePipApp(app)\n } label: {\n Image(systemName: \"x.circle.fill\").opacity(0.8)\n }.buttonStyle(.borderless)\n\n Text(app.name)\n Spacer()\n Text(app.pipWindowTitleRegex)\n .foregroundColor(.secondary)\n }\n }\n }\n }\n\n private var pipAppsHeader: some View {\n HStack {\n Text(\"Custom Picture-in-Picture Apps\")\n Spacer()\n Button {\n viewModel.addPipApp()\n } label: {\n Image(systemName: \"plus\")\n }\n }\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/FlashSpaceCLI.swift", "//\n// FlashSpaceCLI.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\n@main\nstruct FlashSpaceCLI: ParsableCommand {\n static let configuration: CommandConfiguration = .init(\n commandName: \"flashspace\",\n abstract: \"FlashSpace CLI\",\n version: \"1.0.0\",\n groupedSubcommands: [\n .init(\n name: \"Profile\",\n subcommands: [\n CreateProfileCommand.self,\n DeleteProfileCommand.self,\n ProfileCommand.self\n ]\n ),\n .init(\n name: \"Workspace\",\n subcommands: [\n CreateWorkspaceCommand.self,\n DeleteWorkspaceCommand.self,\n UpdateWorkspaceCommand.self,\n WorkspaceCommand.self\n ]\n ),\n .init(\n name: \"App\",\n subcommands: [\n AssignVisibleAppsCommand.self,\n AssignAppCommand.self,\n UnassignAppCommand.self,\n HideUnassignedAppsCommand.self,\n FocusCommand.self,\n FloatingAppsCommand.self\n ]\n ),\n .init(\n name: \"List\",\n subcommands: [\n ListProfilesCommand.self,\n ListWorkspacesCommand.self,\n ListAppsCommand.self,\n ListFloatingAppsCommand.self,\n ListRunningAppsCommand.self,\n ListDisplaysCommand.self\n ]\n ),\n .init(\n name: \"Get\",\n subcommands: [\n GetProfileCommand.self,\n GetWorkspaceCommand.self,\n GetAppCommand.self,\n GetDisplayCommand.self\n ]\n ),\n .init(\n name: \"Open\",\n subcommands: [\n OpenAppCommand.self,\n OpenSpaceControlCommand.self\n ]\n )\n ]\n )\n}\n"], ["/FlashSpace/FlashSpace/Features/Gestures/SwipeManager.swift", "//\n// SwipeManager.swift\n//\n// Created by Wojciech Kulik on 22/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n// Based on: https://github.com/MediosZ/SwipeAeroSpace\n\nimport AppKit\nimport Combine\n\nfinal class SwipeManager {\n typealias TouchId = ObjectIdentifier\n\n enum Constants {\n static let minFingerCount = 3\n static let maxFingerCount = 4\n }\n\n enum GestureState {\n case idle\n case inProgress\n case ended\n }\n\n static let shared = SwipeManager()\n\n private var swipeThreshold: Double { gesturesSettings.swipeThreshold }\n\n private var eventTap: CFMachPort?\n private var xTouchDistance: [TouchId: CGFloat] = [:]\n private var yTouchDistance: [TouchId: CGFloat] = [:]\n private var prevTouchPositions: [TouchId: NSPoint] = [:]\n private var lastTouchDate = Date.distantPast\n private var state: GestureState = .ended\n private var systemWakeUpObserver: AnyCancellable?\n\n private lazy var gesturesSettings = AppDependencies.shared.gesturesSettings\n private lazy var workspaceSettings = AppDependencies.shared.workspaceSettings\n private lazy var workspaceManager = AppDependencies.shared.workspaceManager\n private lazy var workspaceRepository = AppDependencies.shared.workspaceRepository\n private lazy var focusManager = AppDependencies.shared.focusManager\n\n func start() {\n guard eventTap == nil else {\n return Logger.log(\"SwipeManager is already started\")\n }\n\n eventTap = CGEvent.tapCreate(\n tap: .cghidEventTap,\n place: .headInsertEventTap,\n options: .defaultTap,\n eventsOfInterest: NSEvent.EventTypeMask.gesture.rawValue,\n callback: { proxy, type, cgEvent, userInfo in\n SwipeManager.shared.eventHandler(\n proxy: proxy,\n eventType: type,\n cgEvent: cgEvent,\n userInfo: userInfo\n )\n },\n userInfo: nil\n )\n\n guard let eventTap else {\n return Logger.log(\"SwipeManager couldn't create event tap\")\n }\n\n Logger.log(\"SwipeManager started\")\n\n let runLoopSource = CFMachPortCreateRunLoopSource(nil, eventTap, 0)\n CFRunLoopAddSource(\n CFRunLoopGetCurrent(),\n runLoopSource,\n CFRunLoopMode.commonModes\n )\n CGEvent.tapEnable(tap: eventTap, enable: true)\n\n observeSystemWakeUp()\n }\n\n func stop() {\n guard let eventTap else { return }\n\n CGEvent.tapEnable(tap: eventTap, enable: false)\n CFRunLoopRemoveSource(\n CFRunLoopGetCurrent(),\n CFMachPortCreateRunLoopSource(nil, eventTap, 0),\n CFRunLoopMode.commonModes\n )\n CFMachPortInvalidate(eventTap)\n self.eventTap = nil\n\n systemWakeUpObserver?.cancel()\n systemWakeUpObserver = nil\n\n Logger.log(\"SwipeManager stopped\")\n }\n\n func eventHandler(\n proxy: CGEventTapProxy,\n eventType: CGEventType,\n cgEvent: CGEvent,\n userInfo: UnsafeMutableRawPointer?\n ) -> Unmanaged? {\n if eventType.rawValue == NSEvent.EventType.gesture.rawValue,\n let nsEvent = NSEvent(cgEvent: cgEvent) {\n handleGesture(nsEvent)\n } else if eventType == .tapDisabledByUserInput || eventType == .tapDisabledByTimeout {\n Logger.log(\"SwipeManager tap disabled \\(eventType)\")\n if let eventTap {\n CGEvent.tapEnable(tap: eventTap, enable: true)\n }\n }\n\n return Unmanaged.passUnretained(cgEvent)\n }\n\n private func handleGesture(_ nsEvent: NSEvent) {\n let touches = nsEvent.allTouches()\n .filter { !$0.isResting && $0.phase != .stationary }\n\n if touches.count == 0 || Date().timeIntervalSince(lastTouchDate) > 0.8 {\n state = .idle\n }\n\n guard touches.count >= Constants.minFingerCount,\n gesturesSettings.isHorizontalSwipeSet || gesturesSettings.isVerticalSwipeSet\n else { return }\n\n if state == .idle {\n state = .inProgress\n xTouchDistance = [:]\n yTouchDistance = [:]\n prevTouchPositions = [:]\n }\n if state == .inProgress {\n lastTouchDate = Date()\n handleSwipe(touches: touches)\n }\n }\n\n private func handleSwipe(touches: Set) {\n updateSwipeDistance(touches: touches)\n handleHorizontalSwipe()\n handleVerticalSwipe()\n }\n\n private func handleHorizontalSwipe() {\n guard state == .inProgress else { return }\n guard gesturesSettings.isHorizontalSwipeSet else { return }\n\n let swipes = xTouchDistance.values\n let allMovedRight = swipes.allSatisfy { $0 > 0 }\n let allMovedLeft = swipes.allSatisfy { $0 < 0 }\n let minFingerContribution = swipeThreshold / (CGFloat(swipes.count) + 2.0)\n\n guard (Constants.minFingerCount...Constants.maxFingerCount).contains(swipes.count),\n swipes.allSatisfy({ abs($0) > minFingerContribution }),\n abs(swipes.reduce(0.0, +)) >= swipeThreshold,\n allMovedLeft || allMovedRight else { return }\n\n let action = if allMovedRight {\n swipes.count == 3 ? gesturesSettings.swipeRight3FingerAction : gesturesSettings.swipeRight4FingerAction\n } else if allMovedLeft {\n swipes.count == 3 ? gesturesSettings.swipeLeft3FingerAction : gesturesSettings.swipeLeft4FingerAction\n } else {\n GestureAction.none\n }\n\n state = .ended\n callAction(action)\n Logger.log(\"Horizontal swipe detected\")\n }\n\n private func handleVerticalSwipe() {\n guard state == .inProgress else { return }\n guard gesturesSettings.isVerticalSwipeSet else { return }\n\n let swipes = yTouchDistance.values\n let allMovedUp = swipes.allSatisfy { $0 > 0 }\n let allMovedDown = swipes.allSatisfy { $0 < 0 }\n let minFingerContribution = swipeThreshold / (CGFloat(swipes.count) + 2.0)\n\n guard (Constants.minFingerCount...Constants.maxFingerCount).contains(swipes.count),\n swipes.allSatisfy({ abs($0) > minFingerContribution }),\n abs(swipes.reduce(0.0, +)) >= swipeThreshold,\n allMovedUp || allMovedDown else { return }\n\n let action = if allMovedUp {\n swipes.count == 3 ? gesturesSettings.swipeUp3FingerAction : gesturesSettings.swipeUp4FingerAction\n } else if allMovedDown {\n swipes.count == 3 ? gesturesSettings.swipeDown3FingerAction : gesturesSettings.swipeDown4FingerAction\n } else {\n GestureAction.none\n }\n\n state = .ended\n callAction(action)\n Logger.log(\"Vertical swipe detected\")\n }\n\n private func updateSwipeDistance(touches: Set) {\n for touch in touches {\n let (distanceX, distanceY) = touchDistance(touch)\n\n if abs(distanceX) > abs(distanceY) {\n xTouchDistance[ObjectIdentifier(touch.identity), default: 0.0] += distanceX\n } else {\n yTouchDistance[ObjectIdentifier(touch.identity), default: 0.0] += distanceY\n }\n\n prevTouchPositions[ObjectIdentifier(touch.identity)] = touch.normalizedPosition\n }\n }\n\n private func touchDistance(_ touch: NSTouch) -> (CGFloat, CGFloat) {\n guard let prevPosition = prevTouchPositions[ObjectIdentifier(touch.identity)] else {\n return (0.0, 0.0)\n }\n\n return (\n touch.normalizedPosition.x - prevPosition.x,\n touch.normalizedPosition.y - prevPosition.y\n )\n }\n\n // swiftlint:disable:next cyclomatic_complexity\n private func callAction(_ action: GestureAction) {\n let skipEmpty = workspaceSettings.skipEmptyWorkspacesOnSwitch\n let loop = workspaceSettings.loopWorkspaces\n\n switch action {\n case .none: break\n case .toggleSpaceControl: SpaceControl.toggle()\n case .showSpaceControl: SpaceControl.show()\n case .hideSpaceControl: SpaceControl.hide()\n case .nextWorkspace: workspaceManager.activateWorkspace(next: true, skipEmpty: skipEmpty, loop: loop)\n case .previousWorkspace: workspaceManager.activateWorkspace(next: false, skipEmpty: skipEmpty, loop: loop)\n case .mostRecentWorkspace: workspaceManager.activateRecentWorkspace()\n case .focusLeft: focusManager.focusLeft()\n case .focusRight: focusManager.focusRight()\n case .focusUp: focusManager.focusUp()\n case .focusDown: focusManager.focusDown()\n case .focusNextApp: focusManager.nextWorkspaceApp()\n case .focusPreviousApp: focusManager.previousWorkspaceApp()\n case .focusNextWindow: focusManager.nextWorkspaceWindow()\n case .focusPreviousWindow: focusManager.previousWorkspaceWindow()\n case .activateWorkspace(let workspaceName):\n if let workspace = workspaceRepository.workspaces.first(where: { $0.name == workspaceName }) {\n workspaceManager.activateWorkspace(workspace, setFocus: true)\n }\n }\n }\n}\n\nextension SwipeManager {\n func restartAppIfNeeded() {\n guard gesturesSettings.restartAppOnWakeUp else { return }\n\n let task = Process()\n task.launchPath = \"/bin/sh\"\n task.arguments = [\"-c\", \"sleep 1; open '\\(Bundle.main.bundlePath)'\"]\n task.launch()\n\n NSApp.terminate(self)\n exit(0)\n }\n\n private func observeSystemWakeUp() {\n systemWakeUpObserver = NSWorkspace.shared.notificationCenter\n .publisher(for: NSWorkspace.didWakeNotification)\n .sink { [weak self] _ in self?.restartAppIfNeeded() }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Commands/ProfileCommands.swift", "//\n// ProfileCommands.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\n\nfinal class ProfileCommands: CommandExecutor {\n var profilesRepository: ProfilesRepository { AppDependencies.shared.profilesRepository }\n\n func execute(command: CommandRequest) -> CommandResponse? {\n switch command {\n case .activateProfile(let name):\n let profile = profilesRepository.profiles.first { $0.name == name }\n\n if let profile {\n profilesRepository.selectedProfile = profile\n return CommandResponse(success: true)\n } else {\n return CommandResponse(success: false, error: \"Profile not found\")\n }\n\n case .createProfile(let name, let copy, let activate):\n profilesRepository.createProfile(name: name, keepWorkspaces: copy)\n if activate {\n profilesRepository.profiles\n .first { $0.name == name }\n .flatMap { profilesRepository.selectedProfile = $0 }\n }\n return CommandResponse(success: true)\n\n case .deleteProfile(let name):\n let profile = profilesRepository.profiles.first { $0.name == name }\n if let profile {\n profilesRepository.deleteProfile(id: profile.id)\n return CommandResponse(success: true)\n } else {\n return CommandResponse(success: false, error: \"Profile not found\")\n }\n\n default:\n return nil\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/PictureInPicture/Extensions/AXUIElement+PiP.swift", "//\n// AXUIElement+PiP.swift\n//\n// Created by Wojciech Kulik on 12/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension AXUIElement {\n private var pipApps: [PipApp] {\n AppDependencies.shared.workspaceSettings.pipApps\n }\n\n func isPictureInPicture(bundleId: String?) -> Bool {\n if let browser = PipBrowser(rawValue: bundleId ?? \"\") {\n if let partialTitle = browser.partialTitle,\n title?.contains(partialTitle) == true {\n return true\n }\n\n if let pipWindowTitle = browser.title {\n return title == pipWindowTitle\n } else if let pipWindowSubrole = browser.subrole {\n return subrole == pipWindowSubrole\n }\n } else if let pipApp = pipApps.first(where: { $0.bundleIdentifier == bundleId }) {\n let result = title?.range(\n of: pipApp.pipWindowTitleRegex,\n options: .regularExpression\n ) != nil\n\n return result\n }\n\n return false\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/MainScreen/WorkspaceConfigurationView.swift", "//\n// WorkspaceConfigurationView.swift\n//\n// Created by Wojciech Kulik on 20/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct WorkspaceConfigurationView: View {\n @Environment(\\.openWindow) var openWindow\n\n @ObservedObject var viewModel: MainViewModel\n @StateObject var profilesRepository = AppDependencies.shared.profilesRepository\n\n var body: some View {\n VStack(alignment: .leading, spacing: 0.0) {\n configuration\n\n if viewModel.workspaces.contains(where: { $0.apps.contains(where: \\.bundleIdentifier.isEmpty) }) {\n Text(\"Could not migrate some apps. Please re-add them to fix the problem. Please also check floating apps.\")\n .foregroundColor(.errorRed)\n }\n\n Spacer()\n profileAndSettings\n }\n }\n\n private var configuration: some View {\n VStack(alignment: .leading, spacing: 1.0) {\n Text(\"Workspace Configuration:\")\n .padding(.bottom, 16.0)\n .fixedSize()\n\n Text(\"Name:\")\n TextField(\"Name\", text: $viewModel.workspaceName)\n .onSubmit(viewModel.saveWorkspace)\n .padding(.bottom)\n\n Picker(\"Display:\", selection: $viewModel.workspaceDisplay) {\n ForEach(viewModel.screens, id: \\.self) {\n Text($0).tag($0)\n }\n }\n .padding(.bottom)\n .hidden(viewModel.displayMode == .dynamic)\n\n Picker(\"Focus App:\", selection: $viewModel.workspaceAppToFocus) {\n ForEach(viewModel.focusAppOptions, id: \\.self) {\n Text($0.name).tag($0)\n }\n }.padding(.bottom)\n\n HStack {\n Text(\"Menu Bar Icon:\")\n Button {\n viewModel.isSymbolPickerPresented = true\n } label: {\n Image(systemName: viewModel.workspaceSymbolIconName ?? .defaultIconSymbol)\n .frame(maxWidth: .infinity)\n }\n }.padding(.bottom)\n\n Text(\"Activate Shortcut:\")\n HotKeyControl(shortcut: $viewModel.workspaceShortcut).padding(.bottom)\n\n Text(\"Assign App Shortcut:\")\n HotKeyControl(shortcut: $viewModel.workspaceAssignShortcut).padding(.bottom)\n }\n .disabled(viewModel.selectedWorkspace == nil)\n }\n\n private var profileAndSettings: some View {\n HStack {\n Picker(\"Profile:\", selection: $profilesRepository.selectedProfile) {\n ForEach(profilesRepository.profiles) {\n Text($0.name).tag($0)\n }\n }\n\n Button(action: {\n openWindow(id: \"settings\")\n }, label: {\n Image(systemName: \"gearshape\")\n .foregroundColor(.primary)\n }).keyboardShortcut(\",\")\n }.frame(maxWidth: .infinity, alignment: .trailing)\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/List/ListProfilesCommand.swift", "//\n// ListProfilesCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct ListProfilesCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"list-profiles\",\n abstract: \"List profiles\"\n )\n\n func run() throws {\n sendCommand(.listProfiles)\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Workspace/CreateWorkspaceCommand.swift", "//\n// CreateWorkspaceCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct CreateWorkspaceRequest: Codable {\n let name: String\n let display: String?\n let icon: String?\n let activateKey: String?\n let assignKey: String?\n let activate: Bool\n}\n\nstruct CreateWorkspaceCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"create-workspace\",\n abstract: \"Create a workspace\"\n )\n\n @Argument(help: \"The name of the workspace to create.\")\n var name: String\n\n @Option(help: .init(\"The name of the display\", valueName: \"name\"))\n var display: String?\n\n @Option(help: \"The name of the icon to use for the workspace. Must match SF Symbols.\")\n var icon: String?\n\n @Option(help: \"The hotkey to activate the workspace\")\n var activateKey: String?\n\n @Option(help: \"The hotkey to assign the app\")\n var assignKey: String?\n\n @Flag(help: \"Activate the new workspace\")\n var activate = false\n\n func run() throws {\n let request = CreateWorkspaceRequest(\n name: name,\n display: display,\n icon: icon,\n activateKey: activateKey,\n assignKey: assignKey,\n activate: activate\n )\n sendCommand(.createWorkspace(request))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Workspaces/WorkspaceSettingsViewModel.swift", "//\n// WorkspaceSettingsViewModel.swift\n//\n// Created by Wojciech Kulik on 22/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nfinal class WorkspaceSettingsViewModel: ObservableObject {\n @Published var windowTitleRegex = \"\"\n @Published var isInputDialogPresented = false {\n didSet {\n if !isInputDialogPresented, windowTitleRegex.isNotEmpty {\n addPendingPipApp()\n windowTitleRegex = \"\"\n }\n }\n }\n\n private var pendingApp: PipApp?\n private let settings = AppDependencies.shared.workspaceSettings\n\n func addPipApp() {\n let fileChooser = FileChooser()\n let appUrl = fileChooser.runModalOpenPanel(\n allowedFileTypes: [.application],\n directoryURL: URL(filePath: \"/Applications\")\n )\n\n guard let bundle = appUrl?.bundle else { return }\n\n pendingApp = PipApp(\n name: bundle.localizedAppName,\n bundleIdentifier: bundle.bundleIdentifier ?? \"\",\n pipWindowTitleRegex: \"\"\n )\n isInputDialogPresented = true\n }\n\n func deletePipApp(_ app: PipApp) {\n settings.deletePipApp(app)\n }\n\n private func addPendingPipApp() {\n guard let pendingApp else { return }\n\n settings.addPipApp(\n .init(\n name: pendingApp.name,\n bundleIdentifier: pendingApp.bundleIdentifier,\n pipWindowTitleRegex: windowTitleRegex\n )\n )\n self.pendingApp = nil\n }\n}\n"], ["/FlashSpace/FlashSpace/Accessibility/AXUIElement+CoreGraphics.swift", "//\n// AXUIElement+CoreGraphics.swift\n//\n// Created by Wojciech Kulik on 21/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension AXUIElement {\n var cgWindowId: CGWindowID? {\n let title = title\n let pid = processId\n\n if let windowList = CGWindowListCopyWindowInfo(.optionOnScreenOnly, kCGNullWindowID) as? [[String: Any]] {\n for window in windowList {\n let windowOwnerPID = window[kCGWindowOwnerPID as String] as? pid_t\n let windowName = window[kCGWindowName as String] as? String\n let windowNumber = window[kCGWindowNumber as String] as? CGWindowID\n\n if title == windowName, windowOwnerPID == pid {\n return windowNumber\n }\n }\n }\n\n return nil\n }\n\n func isBelowAnyOf(_ windows: [AXUIElement]) -> Bool {\n guard let cgWindowId, let frame else { return false }\n\n let otherWindows = windows.map { (id: $0.cgWindowId, window: $0) }\n let windowsAbove = CGWindowListCopyWindowInfo(.optionOnScreenAboveWindow, cgWindowId) as? [[String: Any]] ?? [[:]]\n let windowsAboveIds = Set(\n windowsAbove.compactMap { $0[kCGWindowNumber as String] as? CGWindowID }\n )\n\n return otherWindows.contains { otherWindowId, otherWindow in\n if let otherWindowId,\n windowsAboveIds.contains(otherWindowId),\n let otherWindowFrame = otherWindow.frame,\n frame.intersects(otherWindowFrame) {\n Logger.log(\"💡 Window \\\"\\(title ?? \"unknown\")\\\" is below \\\"\\(otherWindow.title ?? \"unknown\")\\\"\")\n return true\n }\n\n return false\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/SpaceControl/Views/SpaceControlViewModel.swift", "//\n// SpaceControlViewModel.swift\n//\n// Created by Wojciech Kulik on 11/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport SwiftUI\n\nstruct SpaceControlWorkspace {\n let index: Int\n let name: String\n let symbol: String\n let screenshotData: Data?\n let isActive: Bool\n let originalWorkspace: Workspace\n}\n\nfinal class SpaceControlViewModel: ObservableObject {\n @Published private(set) var workspaces: [SpaceControlWorkspace] = []\n @Published private(set) var numberOfRows = 0\n @Published private(set) var numberOfColumns = 0\n\n private var cancellables = Set()\n\n private let settings = AppDependencies.shared.spaceControlSettings\n private let workspaceRepository = AppDependencies.shared.workspaceRepository\n private let workspaceManager = AppDependencies.shared.workspaceManager\n private let screenshotManager = AppDependencies.shared.workspaceScreenshotManager\n private let displayManager = AppDependencies.shared.displayManager\n\n init() {\n refresh()\n\n NotificationCenter.default\n .publisher(for: .spaceControlArrowDown)\n .compactMap { $0.object as? RawKeyCode }\n .sink { [weak self] in self?.handleArrowKey($0) }\n .store(in: &cancellables)\n }\n\n func onWorkspaceTap(_ workspace: SpaceControlWorkspace) {\n workspaceManager.activateWorkspace(workspace.originalWorkspace, setFocus: true)\n }\n\n func refresh() {\n let activeWorkspaceIds = workspaceManager.activeWorkspace.map(\\.value.id).asSet\n let mainDisplay = NSScreen.main?.localizedName ?? \"\"\n\n workspaces = Array(\n workspaceRepository.workspaces\n .filter { !settings.spaceControlCurrentDisplayWorkspaces || $0.isOnTheCurrentScreen }\n .prefix(15)\n .enumerated()\n .map {\n let workspace = $0.element\n let displayName = settings.spaceControlCurrentDisplayWorkspaces\n ? mainDisplay\n : self.mainDisplay(for: workspace)\n let key = WorkspaceScreenshotManager.ScreenshotKey(\n displayName: displayName,\n workspaceID: workspace.id\n )\n return SpaceControlWorkspace(\n index: $0.offset,\n name: workspace.name,\n symbol: workspace.symbolIconName ?? .defaultIconSymbol,\n screenshotData: screenshotManager.screenshots[key],\n isActive: activeWorkspaceIds.contains(workspace.id),\n originalWorkspace: workspace\n )\n }\n )\n calculateColsAndRows(workspaces.count)\n }\n\n private func mainDisplay(for workspace: Workspace) -> DisplayName {\n let workspaceDisplays = workspace.displays\n\n return workspaceDisplays.count == 1\n ? workspaceDisplays.first!\n : displayManager.lastActiveDisplay(from: workspaceDisplays)\n }\n\n private func calculateColsAndRows(_ workspaceCount: Int) {\n let maxNumberOfRows = 3.0\n\n numberOfColumns = workspaceCount <= 3\n ? workspaceCount\n : max(3, Int(ceil(Double(workspaceCount) / maxNumberOfRows)))\n numberOfColumns = min(numberOfColumns, settings.spaceControlMaxColumns)\n\n numberOfRows = Int(ceil(Double(workspaceCount) / Double(numberOfColumns)))\n }\n\n private func handleArrowKey(_ keyCode: RawKeyCode) {\n let activeWorkspaceIndex = workspaces.firstIndex {\n $0.isActive && $0.originalWorkspace.isOnTheCurrentScreen\n }\n guard let activeWorkspaceIndex else { return }\n\n let workspace: Workspace? = switch KeyCodesMap.toString[keyCode] {\n case \"down\":\n workspaces[safe: activeWorkspaceIndex + numberOfColumns]?.originalWorkspace\n case \"up\":\n workspaces[safe: activeWorkspaceIndex - numberOfColumns]?.originalWorkspace\n case \"right\":\n workspaces[safe: (activeWorkspaceIndex + 1) % workspaces.count]?.originalWorkspace\n case \"left\":\n workspaces[\n safe: activeWorkspaceIndex == 0\n ? workspaces.count - 1\n : activeWorkspaceIndex - 1\n ]?.originalWorkspace\n default:\n nil\n }\n\n if let workspace {\n SpaceControl.hide()\n workspaceManager.activateWorkspace(workspace, setFocus: true)\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/FloatingApps/FloatingAppsSettingsViewModel.swift", "import Foundation\nimport SwiftUI\n\nfinal class FloatingAppsSettingsViewModel: ObservableObject {\n private let settings = AppDependencies.shared.floatingAppsSettings\n\n func addFloatingApp() {\n let fileChooser = FileChooser()\n let appUrl = fileChooser.runModalOpenPanel(\n allowedFileTypes: [.application],\n directoryURL: URL(filePath: \"/Applications\")\n )\n\n guard let bundle = appUrl?.bundle else { return }\n\n settings.addFloatingAppIfNeeded(\n app: .init(\n name: bundle.localizedAppName,\n bundleIdentifier: bundle.bundleIdentifier ?? \"\",\n iconPath: bundle.iconPath\n )\n )\n }\n\n func deleteFloatingApp(app: MacApp) {\n settings.deleteFloatingApp(app: app)\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/App/HideUnassignedAppsCommand.swift", "//\n// HideUnassignedAppsCommand.swift\n//\n// Created by Wojciech Kulik on 07/05/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct HideUnassignedAppsCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"hide-unassigned-apps\",\n abstract: \"Hide all unassigned apps\"\n )\n\n func run() throws {\n sendCommand(.hideUnassignedApps)\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/CLIServer.swift", "//\n// CLIServer.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\nimport Network\n\nfinal class CLIServer {\n var isRunning: Bool {\n switch listener?.state ?? .cancelled {\n case .cancelled, .failed: return false\n default: return true\n }\n }\n\n private var listener: NWListener?\n private let socketPath = \"/tmp/flashspace.socket\"\n private let executors: [CommandExecutor] = [\n ProfileCommands(),\n WorkspaceCommands(),\n AppCommands(),\n FocusCommands(),\n SpaceControlCommands(),\n ListCommands(),\n GetCommands()\n ]\n\n init() { startServer() }\n\n func restart() {\n listener?.cancel()\n startServer()\n }\n\n private func startServer() {\n try? FileManager.default.removeItem(atPath: socketPath)\n\n do {\n let params = NWParameters(tls: nil, tcp: .init())\n params.allowLocalEndpointReuse = true\n params.requiredLocalEndpoint = .unix(path: socketPath)\n\n listener = try NWListener(using: params)\n listener?.newConnectionHandler = handleNewConnection\n listener?.start(queue: .global(qos: .userInitiated))\n Logger.log(\"🟢 Server started at \\(socketPath)\")\n } catch {\n Logger.log(\"❌ Failed to start server: \\(error)\")\n }\n }\n\n private func handleNewConnection(_ connection: NWConnection) {\n connection.start(queue: .global(qos: .userInitiated))\n Logger.log(\"✅ New client connected\")\n\n let buffer = BufferWrapper()\n receiveData(connection: connection, buffer: buffer)\n }\n\n private func receiveData(connection: NWConnection, buffer: BufferWrapper) {\n connection.receive(minimumIncompleteLength: 1, maximumLength: 10000) { data, _, isComplete, error in\n if let error {\n connection.cancel()\n return Logger.log(\"❌ Receive error: \\(error)\")\n }\n\n if let data { buffer.data.append(data) }\n\n // Check if complete or EOF at the end\n guard isComplete || data?.last == 0 else {\n return self.receiveData(connection: connection, buffer: buffer)\n }\n\n guard !buffer.data.isEmpty else {\n connection.cancel()\n return Logger.log(\"❌ Received empty data\")\n }\n\n do {\n let command = try buffer.data.decodeSocketData(CommandRequest.self)\n DispatchQueue.main.async {\n self.handleCommand(command, connection: connection)\n }\n } catch {\n connection.cancel()\n Logger.log(\"❌ Failed to decode command: \\(error)\")\n }\n }\n }\n\n private func handleCommand(_ command: CommandRequest, connection: NWConnection) {\n var result: CommandResponse?\n for executor in executors {\n result = executor.execute(command: command)\n if result != nil { break }\n }\n\n DispatchQueue.global(qos: .userInitiated).async {\n if let response = result?.encodeSocketData() {\n connection.send(content: response, completion: .contentProcessed { _ in connection.cancel() })\n } else {\n connection.cancel()\n Logger.log(\"❌ Failed to encode response\")\n }\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/FloatingApps/FloatingAppsHotKeys.swift", "//\n// FloatingAppsHotKeys.swift\n//\n// Created by Wojciech Kulik on 16/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nfinal class FloatingAppsHotKeys {\n private let workspaceManager: WorkspaceManager\n private let floatingAppsSettings: FloatingAppsSettings\n\n init(\n workspaceManager: WorkspaceManager,\n settingsRepository: SettingsRepository\n ) {\n self.workspaceManager = workspaceManager\n self.floatingAppsSettings = settingsRepository.floatingAppsSettings\n }\n\n func getHotKeys() -> [(AppHotKey, () -> ())] {\n let hotKeys = [\n getFloatTheFocusedAppHotKey(),\n getUnfloatTheFocusedAppHotKey(),\n getToggleTheFocusedAppFloatingHotKey()\n ]\n\n return hotKeys.compactMap(\\.self)\n }\n\n private func getFloatTheFocusedAppHotKey() -> (AppHotKey, () -> ())? {\n guard let shortcut = floatingAppsSettings.floatTheFocusedApp else { return nil }\n\n return (shortcut, { [weak self] in self?.floatApp() })\n }\n\n private func getUnfloatTheFocusedAppHotKey() -> (AppHotKey, () -> ())? {\n guard let shortcut = floatingAppsSettings.unfloatTheFocusedApp else { return nil }\n\n return (shortcut, { [weak self] in self?.unfloatApp() })\n }\n\n private func getToggleTheFocusedAppFloatingHotKey() -> (AppHotKey, () -> ())? {\n guard let shortcut = floatingAppsSettings.toggleTheFocusedAppFloating else { return nil }\n\n let action = { [weak self] in\n guard let self, let activeApp = NSWorkspace.shared.frontmostApplication else { return }\n\n if floatingAppsSettings.floatingApps.containsApp(activeApp) {\n unfloatApp()\n } else {\n floatApp()\n }\n }\n return (shortcut, action)\n }\n}\n\nextension FloatingAppsHotKeys {\n private func floatApp() {\n guard let activeApp = NSWorkspace.shared.frontmostApplication,\n let appName = activeApp.localizedName else { return }\n\n floatingAppsSettings.addFloatingAppIfNeeded(app: activeApp.toMacApp)\n Toast.showWith(\n icon: \"macwindow.on.rectangle\",\n message: \"\\(appName) - Added To Floating Apps\",\n textColor: .positive\n )\n }\n\n private func unfloatApp() {\n guard let activeApp = NSWorkspace.shared.frontmostApplication,\n let appName = activeApp.localizedName else { return }\n\n if floatingAppsSettings.floatingApps.containsApp(activeApp) {\n Toast.showWith(\n icon: \"macwindow\",\n message: \"\\(appName) - Removed From Floating Apps\",\n textColor: .negative\n )\n }\n\n floatingAppsSettings.deleteFloatingApp(app: activeApp.toMacApp)\n\n guard let screen = activeApp.display else { return }\n\n if workspaceManager.activeWorkspace[screen]?.apps.containsApp(activeApp) != true {\n activeApp.hide()\n }\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Profile/CreateProfileCommand.swift", "//\n// CreateProfileCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct CreateProfileCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"create-profile\",\n abstract: \"Create a profile\"\n )\n\n @Argument(help: \"The name of the profile to create.\")\n var name: String\n\n @Flag(help: \"Copy the current profile\")\n var copy = false\n\n @Flag(help: \"Activate the new profile\")\n var activate = false\n\n func run() throws {\n sendCommand(.createProfile(name: name, copy: copy, activate: activate))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Gestures/GestureAction.swift", "//\n// GestureAction.swift\n//\n// Created by Wojciech Kulik on 30/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nenum GestureAction {\n case none\n case toggleSpaceControl\n case showSpaceControl\n case hideSpaceControl\n case nextWorkspace\n case previousWorkspace\n case mostRecentWorkspace\n case focusLeft\n case focusRight\n case focusUp\n case focusDown\n case focusNextApp\n case focusPreviousApp\n case focusNextWindow\n case focusPreviousWindow\n case activateWorkspace(String)\n}\n\nextension GestureAction: CaseIterable, Equatable, Hashable, Identifiable {\n var id: String { description }\n\n var description: String {\n switch self {\n case .none: return \"None\"\n case .toggleSpaceControl: return \"Toggle Space Control\"\n case .showSpaceControl: return \"Show Space Control\"\n case .hideSpaceControl: return \"Hide Space Control\"\n case .nextWorkspace: return \"Next Workspace\"\n case .previousWorkspace: return \"Previous Workspace\"\n case .mostRecentWorkspace: return \"Most Recent Workspace\"\n case .focusLeft: return \"Focus Left\"\n case .focusRight: return \"Focus Right\"\n case .focusUp: return \"Focus Up\"\n case .focusDown: return \"Focus Down\"\n case .focusNextApp: return \"Focus Next App\"\n case .focusPreviousApp: return \"Focus Previous App\"\n case .focusNextWindow: return \"Focus Next Window\"\n case .focusPreviousWindow: return \"Focus Previous Window\"\n case .activateWorkspace(let workspaceName):\n return \"Activate Workspace: \\(workspaceName)\"\n }\n }\n\n static var allCases: [GestureAction] {\n let workspaces = AppDependencies.shared.workspaceRepository.workspaces\n return allCasesWithoutWorkspaces + workspaces.map { .activateWorkspace($0.name) }\n }\n\n static var allCasesWithoutWorkspaces: [GestureAction] {\n [\n .none,\n .toggleSpaceControl,\n .showSpaceControl,\n .hideSpaceControl,\n .nextWorkspace,\n .previousWorkspace,\n .mostRecentWorkspace,\n .focusLeft,\n .focusRight,\n .focusUp,\n .focusDown,\n .focusNextApp,\n .focusPreviousApp,\n .focusNextWindow,\n .focusPreviousWindow\n ]\n }\n}\n\nextension GestureAction: Codable {\n init(from decoder: Decoder) throws {\n let container = try decoder.singleValueContainer()\n let value = try container.decode(String.self)\n\n if value.hasPrefix(\"activateWorkspace:\") {\n let workspaceName = String(value.dropFirst(\"activateWorkspace:\".count))\n self = .activateWorkspace(workspaceName)\n } else if let action = GestureAction.allCasesWithoutWorkspaces.first(where: { $0.normalizedDescription == value }) {\n self = action\n } else {\n self = .none\n }\n }\n\n func encode(to encoder: Encoder) throws {\n var container = encoder.singleValueContainer()\n try container.encode(normalizedDescription)\n }\n\n private var normalizedDescription: String {\n if case .activateWorkspace(let workspaceName) = self {\n return \"activateWorkspace:\\(workspaceName)\"\n }\n\n let result = String(description.first?.lowercased() ?? \"\") + description.dropFirst()\n return result.replacingOccurrences(of: \" \", with: \"\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/HotKeys/Models/AppHotKey.swift", "//\n// AppHotKey.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\ntypealias RawKeyCode = UInt16\ntypealias RawKeyModifiers = UInt\n\nstruct AppHotKey: Codable, Hashable {\n let value: String\n\n init(value: String) { self.value = value }\n\n init(keyCode: RawKeyCode, modifiers: RawKeyModifiers) {\n let keyEquivalent = KeyCodesMap.toString[keyCode] ?? \"\"\n let modifiers = KeyModifiersMap.toString(modifiers)\n let result = [modifiers, keyEquivalent].filter { !$0.isEmpty }.joined(separator: \"+\")\n\n self.init(value: result)\n }\n\n init(from decoder: Decoder) throws {\n enum CodingKeys: String, CodingKey { case keyCode, modifiers }\n\n if let container = try? decoder.container(keyedBy: CodingKeys.self) {\n // v1 -> v2 Migration\n let keyCode = try container.decodeIfPresent(RawKeyCode.self, forKey: .keyCode)\n let modifiers = try container.decodeIfPresent(RawKeyModifiers.self, forKey: .modifiers)\n\n if let keyCode, let modifiers {\n Migrations.hotKeysMigrated = true\n self.init(keyCode: keyCode, modifiers: modifiers)\n } else {\n throw DecodingError.dataCorruptedError(\n forKey: .keyCode,\n in: container,\n debugDescription: \"Invalid key code or modifiers\"\n )\n }\n } else {\n // v2\n let container = try decoder.singleValueContainer()\n try self.init(value: container.decode(String.self))\n }\n }\n\n func encode(to encoder: any Encoder) throws {\n var container = encoder.singleValueContainer()\n try container.encode(value)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/HotKeys/HotKeysManager.swift", "//\n// HotKeysManager.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Combine\nimport ShortcutRecorder\n\nfinal class HotKeysManager {\n private(set) var allHotKeys: [(scope: String, hotKey: AppHotKey)] = []\n\n private var cancellables = Set()\n\n private let hotKeysMonitor: HotKeysMonitorProtocol\n private let workspaceHotKeys: WorkspaceHotKeys\n private let floatingAppsHotKeys: FloatingAppsHotKeys\n private let focusManager: FocusManager\n private let settingsRepository: SettingsRepository\n\n init(\n hotKeysMonitor: HotKeysMonitorProtocol,\n workspaceHotKeys: WorkspaceHotKeys,\n floatingAppsHotKeys: FloatingAppsHotKeys,\n focusManager: FocusManager,\n settingsRepository: SettingsRepository\n ) {\n self.hotKeysMonitor = hotKeysMonitor\n self.workspaceHotKeys = workspaceHotKeys\n self.floatingAppsHotKeys = floatingAppsHotKeys\n self.focusManager = focusManager\n self.settingsRepository = settingsRepository\n\n observe()\n }\n\n func refresh() {\n disableAll()\n enableAll()\n }\n\n // swiftlint:disable:next function_body_length\n func enableAll() {\n allHotKeys.removeAll()\n let addShortcut = { (title: String, shortcut: Shortcut) in\n self.allHotKeys.append((title, .init(\n keyCode: shortcut.keyCode.rawValue,\n modifiers: shortcut.modifierFlags.rawValue\n )))\n }\n\n // Workspaces\n for (shortcut, action) in workspaceHotKeys.getHotKeys().toShortcutPairs() {\n let action = ShortcutAction(shortcut: shortcut) { _ in\n action()\n return true\n }\n\n hotKeysMonitor.addAction(action, forKeyEvent: .down)\n addShortcut(\"Workspace\", shortcut)\n }\n\n // Floating Apps\n for (shortcut, action) in floatingAppsHotKeys.getHotKeys().toShortcutPairs() {\n let action = ShortcutAction(shortcut: shortcut) { _ in\n action()\n return true\n }\n\n hotKeysMonitor.addAction(action, forKeyEvent: .down)\n addShortcut(\"Floating Apps\", shortcut)\n }\n\n // Focus Manager\n for (shortcut, action) in focusManager.getHotKeys().toShortcutPairs() {\n let action = ShortcutAction(shortcut: shortcut) { _ in\n action()\n return true\n }\n hotKeysMonitor.addAction(action, forKeyEvent: .down)\n addShortcut(\"Focus Manager\", shortcut)\n }\n\n // General\n if let showHotKey = settingsRepository.generalSettings.showFlashSpace?.toShortcut() {\n let action = ShortcutAction(shortcut: showHotKey) { _ in\n guard !SpaceControl.isVisible else { return true }\n\n let visibleAppWindows = NSApp.windows\n .filter(\\.isVisible)\n .filter { $0.identifier?.rawValue == \"main\" || $0.identifier?.rawValue == \"settings\" }\n\n if visibleAppWindows.isEmpty {\n NotificationCenter.default.post(name: .openMainWindow, object: nil)\n } else {\n visibleAppWindows.forEach { $0.close() }\n }\n return true\n }\n hotKeysMonitor.addAction(action, forKeyEvent: .down)\n addShortcut(\"General\", showHotKey)\n }\n\n // SpaceControl\n if let (hotKey, action) = SpaceControl.getHotKey(), let shortcut = hotKey.toShortcut() {\n let action = ShortcutAction(shortcut: shortcut) { _ in\n action()\n return true\n }\n hotKeysMonitor.addAction(action, forKeyEvent: .down)\n addShortcut(\"Space Control\", shortcut)\n }\n }\n\n func disableAll() {\n hotKeysMonitor.removeAllActions()\n }\n\n private func observe() {\n NotificationCenter.default\n .publisher(for: .profileChanged)\n .sink { [weak self] _ in self?.refresh() }\n .store(in: &cancellables)\n\n DistributedNotificationCenter.default()\n .publisher(for: .init(rawValue: kTISNotifySelectedKeyboardInputSourceChanged as String))\n .sink { [weak self] _ in\n KeyCodesMap.refresh()\n self?.disableAll()\n self?.enableAll()\n }\n .store(in: &cancellables)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Profiles/ProfilesSettingsView.swift", "//\n// ProfilesSettingsView.swift\n//\n// Created by Wojciech Kulik on 26/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct ProfilesSettingsView: View {\n @StateObject var viewModel = ProfilesSettingsViewModel()\n @StateObject var profilesRepository = AppDependencies.shared.profilesRepository\n\n var body: some View {\n Form {\n Section(\n header: HStack {\n Text(\"Profiles\")\n Spacer()\n Button {\n viewModel.createNewProfile()\n } label: {\n Image(systemName: \"plus\")\n }\n }\n ) {\n VStack(alignment: .leading) {\n ForEach(profilesRepository.profiles) { profile in\n HStack {\n Button {\n viewModel.deleteProfile(profile)\n } label: {\n Image(systemName: \"x.circle.fill\").opacity(0.8)\n }\n .buttonStyle(.borderless)\n .hidden(viewModel.hideDeleteButton)\n\n Button {\n viewModel.renameProfile(profile)\n } label: {\n Text(profile.name)\n }\n .buttonStyle(.borderless)\n .tint(.primary)\n }\n }\n }\n }\n }\n .formStyle(.grouped)\n .sheet(isPresented: $viewModel.isInputDialogPresented) {\n InputDialog(\n title: \"Enter profile name:\",\n userInput: $viewModel.userInput,\n isPresented: $viewModel.isInputDialogPresented\n )\n }\n .alert(\n \"Are you sure you want to delete \\\"\\(viewModel.profileToDelete)\\\" profile?\",\n isPresented: $viewModel.isDeleteConfirmationPresented\n ) {\n Button(\"Delete\", role: .destructive) {\n viewModel.deleteConfirmed()\n }\n Button(\"Cancel\", role: .cancel) {}\n } message: {\n Text(\"This action cannot be undone.\")\n }\n .alert(\n \"Do you want to copy the current workspaces to the new profile?\",\n isPresented: $viewModel.isCopyChoicePresented\n ) {\n Button(\"Copy\") { viewModel.createNewProfile(copyWorkspaces: true) }\n Button(\"No\", role: .cancel) { viewModel.createNewProfile(copyWorkspaces: false) }\n }\n .onChange(of: viewModel.isInputDialogPresented) { _, isPresented in\n if !isPresented {\n viewModel.inputDialogDismissed()\n }\n }\n .navigationTitle(\"Profiles\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/MainScreen/AppCell.swift", "//\n// AppCell.swift\n//\n// Created by Wojciech Kulik on 20/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct AppCell: View {\n let workspaceId: WorkspaceID\n let app: MacApp\n\n var body: some View {\n HStack {\n if let iconPath = app.iconPath, let image = NSImage(byReferencingFile: iconPath) {\n Image(nsImage: image)\n .resizable()\n .scaledToFit()\n .frame(width: 20, height: 20)\n }\n Text(app.name)\n .foregroundColor(app.bundleIdentifier.isEmpty ? .errorRed : .primary)\n }\n .draggable(MacAppWithWorkspace(app: app, workspaceId: workspaceId))\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/SpaceControl/SpaceControl.swift", "//\n// SpaceControl.swift\n//\n// Created by Wojciech Kulik on 11/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport SwiftUI\n\nenum SpaceControl {\n static var isEnabled: Bool { settings.enableSpaceControl }\n static var isVisible: Bool { window != nil }\n static var window: NSWindow?\n\n private static var settings: SpaceControlSettings { AppDependencies.shared.spaceControlSettings }\n private static var focusedAppBeforeShow: NSRunningApplication?\n\n static func getHotKey() -> (AppHotKey, () -> ())? {\n guard isEnabled else { return nil }\n\n if let spaceControlHotKey = settings.showSpaceControl {\n return (spaceControlHotKey, toggle)\n }\n\n return nil\n }\n\n static func toggle() {\n if isVisible {\n hide(restoreFocus: true)\n } else {\n show()\n }\n }\n\n static func hide(restoreFocus: Bool = false) {\n window?.orderOut(nil)\n window = nil\n\n if restoreFocus {\n focusedAppBeforeShow?.activate()\n focusedAppBeforeShow = nil\n }\n }\n\n static func show() {\n guard validate() else { return }\n\n PermissionsManager.shared.askForScreenRecordingPermissions()\n\n if Self.window != nil { hide() }\n\n let contentView = NSHostingView(\n rootView: SpaceControlView()\n )\n\n // contentRect is in screen coordinates where (0,0) is bottom-left corner\n // and it is relative to the main screen.\n let window = SpaceControlWindow(\n contentRect: NSScreen.main!.frame,\n styleMask: [.borderless],\n backing: .buffered,\n defer: false\n )\n window.isOpaque = false\n window.backgroundColor = .clear\n window.level = .screenSaver\n window.delegate = window\n Self.window = window\n\n let animations = settings.enableSpaceControlAnimations\n\n window.contentView = contentView.addVisualEffect(material: .fullScreenUI)\n window.alphaValue = animations ? 0 : 1\n\n focusedAppBeforeShow = NSWorkspace.shared.frontmostApplication\n NSApp.activate(ignoringOtherApps: true)\n window.orderFrontRegardless()\n window.makeKeyAndOrderFront(nil)\n\n if animations {\n window.animator().alphaValue = 1\n }\n }\n\n private static func validate() -> Bool {\n let workspaces = AppDependencies.shared.workspaceRepository.workspaces\n let nonEmptyWorkspaces = workspaces\n .filter { !settings.spaceControlCurrentDisplayWorkspaces || $0.isOnTheCurrentScreen }\n\n if nonEmptyWorkspaces.count < 2 {\n Alert.showOkAlert(title: \"Space Control\", message: \"You need at least 2 workspaces to use Space Control.\")\n return false\n }\n\n return true\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Get/GetWorkspaceCommand.swift", "//\n// GetWorkspaceCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport ArgumentParser\nimport Foundation\n\nstruct GetWorkspaceCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"get-workspace\",\n abstract: \"Get active workspace\"\n )\n\n @Option(help: \"Display name\")\n var display: String?\n\n func run() throws {\n sendCommand(.getWorkspace(display: display))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Accessibility/NSRunningApplication+Actions.swift", "//\n// NSRunningApplication+Actions.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension NSRunningApplication {\n func raise() {\n guard let mainWindow else {\n unhide()\n return\n }\n\n AXUIElementPerformAction(mainWindow, NSAccessibility.Action.raise as CFString)\n }\n\n /// Position is in window coordinates where (0,0) is top-left corner\n /// and it is relative to the main screen.\n func setPosition(_ position: CGPoint) {\n mainWindow?.setPosition(position)\n }\n\n func centerApp(display: DisplayName) {\n guard let appFrame = frame else {\n return Logger.log(\"Could not get frame for app: \\(localizedName ?? \"\")\")\n }\n\n guard let nsScreen = NSScreen.screen(display) else { return }\n guard appFrame.getDisplay() != nsScreen.localizedName else { return }\n\n let normalizedScreenFrame = nsScreen.normalizedFrame\n\n let origin = CGPoint(\n x: normalizedScreenFrame.midX - appFrame.width / 2.0,\n y: normalizedScreenFrame.midY - appFrame.height / 2.0\n )\n\n setPosition(origin)\n }\n\n func runWithoutAnimations(action: () -> ()) {\n let appElement = AXUIElementCreateApplication(processIdentifier)\n let wasEnabled = appElement.enhancedUserInterface\n\n if wasEnabled { appElement.setAttribute(.enchancedUserInterface, value: false) }\n\n action()\n\n if wasEnabled { appElement.setAttribute(.enchancedUserInterface, value: true) }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/General/GeneralSettingsView.swift", "//\n// GeneralSettingsView.swift\n//\n// Created by Wojciech Kulik on 23/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport SwiftUI\n\nstruct GeneralSettingsView: View {\n @StateObject var settings = AppDependencies.shared.generalSettings\n @State var isAutostartEnabled = false\n @State var hasAccessibilityPermissions = false\n\n var body: some View {\n Form {\n Section {\n Toggle(\"Launch at startup\", isOn: $isAutostartEnabled)\n Toggle(\"Check for updates automatically\", isOn: $settings.checkForUpdatesAutomatically)\n }\n\n Section(\"Permissions\") {\n HStack {\n if hasAccessibilityPermissions {\n Image(systemName: \"checkmark.circle.fill\")\n .foregroundColor(.green)\n Text(\"Accessibility Permissions\")\n Spacer()\n } else {\n Image(systemName: \"xmark.circle.fill\")\n .foregroundColor(.red)\n Text(\"Accessibility Permissions\")\n Spacer()\n Button(\"Open Privacy & Security\") {\n NSWorkspace.shared.open(\n URL(string: \"x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility\")!\n )\n }\n }\n }\n Text(\"FlashSpace requires accessibility access to manage applications.\")\n .foregroundColor(.secondary)\n .font(.callout)\n }\n\n Section(\"Shortcuts\") {\n hotkey(\"Toggle FlashSpace\", for: $settings.showFlashSpace)\n }\n\n Section(\"Notifications\") {\n Toggle(\"Enable Notifications\", isOn: $settings.showFloatingNotifications)\n Text(\"Some shortcuts will show a temporary notification.\")\n .foregroundStyle(.secondary)\n .font(.callout)\n }\n }\n .onAppear {\n isAutostartEnabled = AppDependencies.shared.autostartService.isLaunchAtLoginEnabled\n hasAccessibilityPermissions = PermissionsManager.shared.checkForAccessibilityPermissions()\n }\n .onChange(of: isAutostartEnabled) { _, enabled in\n if enabled {\n AppDependencies.shared.autostartService.enableLaunchAtLogin()\n } else {\n AppDependencies.shared.autostartService.disableLaunchAtLogin()\n }\n }\n .onReceive(NotificationCenter.default.publisher(for: NSApplication.didBecomeActiveNotification)) { _ in\n hasAccessibilityPermissions = PermissionsManager.shared.checkForAccessibilityPermissions()\n }\n .formStyle(.grouped)\n .navigationTitle(\"General\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/SpaceControl/SpaceControlSettingsView.swift", "//\n// SpaceControlSettingsView.swift\n//\n// Created by Wojciech Kulik on 11/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct SpaceControlSettingsView: View {\n @StateObject var settings = AppDependencies.shared.spaceControlSettings\n @State var hasScreenRecordingPermissions = false\n\n var body: some View {\n Form {\n Section {\n Toggle(\"Enable Space Control\", isOn: $settings.enableSpaceControl)\n }\n\n Group {\n Section(\"Permissions\") {\n HStack {\n if hasScreenRecordingPermissions {\n Image(systemName: \"checkmark.circle.fill\")\n .foregroundColor(.green)\n Text(\"Screen Recording Permission\")\n Spacer()\n } else {\n Image(systemName: \"xmark.circle.fill\")\n .foregroundColor(.red)\n Text(\"Screen Recording Permission\")\n Spacer()\n Button(\"Open Privacy & Security\") {\n NSWorkspace.shared.open(\n URL(string: \"x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture\")!\n )\n }\n }\n }\n Text(\n \"FlashSpace requires screen recording access to show your workspaces in Space Control. \" +\n \"The preview will be displayed upon first activation of the workspace.\"\n )\n .foregroundColor(.secondary)\n .font(.callout)\n }\n\n Section(\"Shortcuts\") {\n hotkey(\"Toggle Space Control\", for: $settings.showSpaceControl)\n }\n\n Section(\"Appearance\") {\n Toggle(\"Enable Animations\", isOn: $settings.enableSpaceControlAnimations)\n Toggle(\n \"Show Workspaces For Current Display Only\",\n isOn: $settings.spaceControlCurrentDisplayWorkspaces\n )\n\n HStack {\n Text(\"Max Number Of Columns\")\n Spacer()\n Text(\"\\(settings.spaceControlMaxColumns)\")\n Stepper(\n \"\",\n value: $settings.spaceControlMaxColumns,\n in: 2...20,\n step: 1\n ).labelsHidden()\n }\n }\n }\n .disabled(!settings.enableSpaceControl)\n .opacity(settings.enableSpaceControl ? 1 : 0.5)\n }\n .onAppear {\n hasScreenRecordingPermissions = PermissionsManager.shared.checkForScreenRecordingPermissions()\n }\n .onReceive(NotificationCenter.default.publisher(for: NSApplication.didBecomeActiveNotification)) { _ in\n hasScreenRecordingPermissions = PermissionsManager.shared.checkForScreenRecordingPermissions()\n }\n .formStyle(.grouped)\n .navigationTitle(\"Space Control\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/ConfigurationFile/ConfigurationFileSettingsView.swift", "//\n// ConfigurationFileSettingsView.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport SwiftUI\n\nstruct ConfigurationFileSettingsView: View {\n @State var configFormat: ConfigFormat = ConfigSerializer.format\n\n var body: some View {\n Form {\n Section {\n Picker(\"Format\", selection: $configFormat) {\n ForEach(ConfigFormat.allCases, id: \\.rawValue) { format in\n Text(format.displayName).tag(format)\n }\n }.onChange(of: configFormat) { _, newFormat in\n try? ConfigSerializer.convert(to: newFormat)\n }\n\n HStack {\n Text(\"Location: \\(ConfigSerializer.configDirectory.path)\")\n .foregroundStyle(.secondary)\n .font(.callout)\n Spacer()\n Button(\"Reveal\") {\n NSWorkspace.shared.open(ConfigSerializer.configDirectory)\n }\n }\n\n Text(\n \"If you manually edit the configuration file, make sure to restart FlashSpace.\\n\" +\n \"Custom formatting, order, comments, etc. will be overwritten if you change something in the app.\"\n )\n .foregroundStyle(.secondary)\n .font(.callout)\n }\n }\n .formStyle(.grouped)\n .navigationTitle(\"Configuration File\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/PictureInPicture/Extensions/NSRunningApplication+PiP.swift", "//\n// NSRunningApplication+PiP.swift\n//\n// Created by Wojciech Kulik on 12/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension NSRunningApplication {\n var supportsPictureInPicture: Bool {\n PipBrowser.allCases.contains { $0.bundleId == bundleIdentifier } ||\n pipApps.contains { $0.bundleIdentifier == bundleIdentifier }\n }\n\n var isPictureInPictureActive: Bool {\n allWindows.map(\\.window).contains { $0.isPictureInPicture(bundleId: bundleIdentifier) }\n }\n\n private var pipApps: [PipApp] {\n AppDependencies.shared.workspaceSettings.pipApps\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/SpaceControl/WorkspaceScreenshotManager.swift", "//\n// WorkspaceScreenshotManager.swift\n//\n// Created by Wojciech Kulik on 11/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Combine\nimport CoreGraphics\nimport ScreenCaptureKit\nimport SwiftUI\n\nfinal class WorkspaceScreenshotManager {\n typealias ImageData = Data\n\n struct ScreenshotKey: Hashable {\n let displayName: DisplayName\n let workspaceID: WorkspaceID\n }\n\n private(set) var screenshots: [ScreenshotKey: ImageData] = [:]\n private var cancellables = Set()\n\n private let lock = NSLock()\n\n init() {\n observe()\n }\n\n func captureWorkspace(_ workspace: Workspace, displayName: DisplayName) async {\n let shouldCapture = await MainActor.run {\n !SpaceControl.isVisible &&\n SpaceControl.isEnabled &&\n PermissionsManager.shared.checkForScreenRecordingPermissions()\n }\n\n guard shouldCapture else { return }\n\n do {\n let availableContent = try await SCShareableContent.excludingDesktopWindows(false, onScreenWindowsOnly: false)\n let display = await MainActor.run {\n availableContent.displays.first { $0.frame.getDisplay() == displayName }\n }\n\n guard let display else { return }\n\n let filter = SCContentFilter(display: display, excludingWindows: [])\n let config = SCStreamConfiguration()\n config.captureResolution = .best\n config.width = Int(display.frame.width)\n config.height = Int(display.frame.height)\n config.showsCursor = false\n\n let screenshot = try await SCScreenshotManager.captureSampleBuffer(\n contentFilter: filter,\n configuration: config\n )\n\n if let image = imageFromSampleBuffer(screenshot) {\n let key = ScreenshotKey(\n displayName: displayName,\n workspaceID: workspace.id\n )\n saveScreenshot(image, workspace: workspace, key: key)\n }\n } catch {\n Logger.log(error)\n }\n }\n\n private func imageFromSampleBuffer(_ buffer: CMSampleBuffer) -> NSImage? {\n guard let imageBuffer = CMSampleBufferGetImageBuffer(buffer) else { return nil }\n\n let ciImage = CIImage(cvImageBuffer: imageBuffer)\n let representation = NSCIImageRep(ciImage: ciImage)\n let nsImage = NSImage(size: representation.size)\n nsImage.addRepresentation(representation)\n\n return nsImage\n }\n\n private func saveScreenshot(_ image: NSImage, workspace: Workspace, key: ScreenshotKey) {\n let newSize = CGSize(\n width: 1400.0,\n height: (1400.0 / image.size.width) * image.size.height\n )\n let newImage = NSImage(size: newSize)\n let rect = NSRect(origin: .zero, size: newSize)\n\n newImage.lockFocus()\n image.draw(in: rect)\n newImage.unlockFocus()\n\n guard let resizedData = newImage.tiffRepresentation,\n let imageRepresentation = NSBitmapImageRep(data: resizedData),\n let jpegData = imageRepresentation.representation(using: .jpeg, properties: [:])\n else { return }\n\n lock.lock()\n screenshots[key] = jpegData\n lock.unlock()\n }\n\n private func observe() {\n NotificationCenter.default\n .publisher(for: .workspaceTransitionFinished)\n .compactMap { $0.object as? Workspace }\n .sink { [weak self] workspace in\n for display in workspace.displays {\n Task.detached { [weak self] in\n await self?.captureWorkspace(workspace, displayName: display)\n }\n }\n }\n .store(in: &cancellables)\n\n NotificationCenter.default\n .publisher(for: .profileChanged)\n .sink { [weak self] _ in\n self?.screenshots = [:]\n }\n .store(in: &cancellables)\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Workspace/DeleteWorkspaceCommand.swift", "//\n// DeleteWorkspaceCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct DeleteWorkspaceCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"delete-workspace\",\n abstract: \"Delete a workspace\"\n )\n\n @Argument(help: \"The name of the workspace to delete.\")\n var name: String\n\n func run() throws {\n sendCommand(.deleteWorkspace(name: name))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/MacAppArray.swift", "//\n// MacAppArray.swift\n//\n// Created by Wojciech Kulik on 06/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension [MacApp] {\n func firstIndex(ofAppWith bundleIdentifier: BundleId) -> Int? {\n firstIndex { $0.bundleIdentifier == bundleIdentifier }\n }\n\n func firstIndex(of app: NSRunningApplication) -> Int? {\n firstIndex { $0.bundleIdentifier == app.bundleIdentifier }\n }\n\n func containsApp(with bundleIdentifier: BundleId?) -> Bool {\n contains { $0.bundleIdentifier == bundleIdentifier }\n }\n\n func containsApp(_ app: NSRunningApplication) -> Bool {\n contains { $0.bundleIdentifier == app.bundleIdentifier }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/CLI.swift", "//\n// CLI.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nenum CLI {\n static var cliPath: String { Bundle.main.bundlePath + \"/Contents/Resources/flashspace\" }\n static var symlinkPath: String { \"/usr/local/bin/flashspace\" }\n static var isInstalled: Bool { FileManager.default.fileExists(atPath: symlinkPath) }\n\n static func install() {\n guard !isInstalled else {\n return print(\"✅ CLI already installed at \\(symlinkPath)\")\n }\n\n if runSudoScript(\"ln -s '\\(cliPath)' '\\(symlinkPath)'\") {\n Logger.log(\"✅ CLI installed from \\(symlinkPath)\")\n }\n }\n\n static func uninstall() {\n guard isInstalled else { return print(\"✅ CLI already uninstalled\") }\n\n if runSudoScript(\"rm '\\(symlinkPath)'\") {\n Logger.log(\"✅ CLI uninstalled from \\(symlinkPath)\")\n }\n }\n\n private static func runSudoScript(_ script: String) -> Bool {\n let appleScript =\n \"do shell script \\\"sudo \\(script)\\\" with administrator privileges\"\n\n guard let scriptObject = NSAppleScript(source: appleScript) else {\n Logger.log(\"❌ Error: Failed to create AppleScript object\")\n Alert.showOkAlert(title: \"Error\", message: \"Could not run script\")\n return false\n }\n\n var error: NSDictionary?\n scriptObject.executeAndReturnError(&error)\n\n if let error {\n Logger.log(\"❌ Error: \\(error)\")\n if let errorNumber = error[\"NSAppleScriptErrorNumber\"],\n errorNumber as? NSNumber != -128,\n let errorMessage = error[\"NSAppleScriptErrorMessage\"] as? String {\n Alert.showOkAlert(title: \"Error\", message: errorMessage)\n }\n return false\n }\n\n return true\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/CLI/CLISettingsView.swift", "//\n// CLISettingsView.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct CLISettingsView: View {\n @State var isInstalled = false\n @State var isRunning = false\n\n var body: some View {\n Form {\n Section(\"Status\") {\n HStack {\n if isRunning {\n Image(systemName: \"checkmark.circle.fill\")\n .foregroundColor(.green)\n Text(\"FlashSpace CLI Status\")\n Spacer()\n } else {\n Image(systemName: \"xmark.circle.fill\")\n .foregroundColor(.red)\n\n Text(\"FlashSpace CLI Status\")\n Spacer()\n Button(\"Restart\") {\n AppDependencies.shared.cliServer.restart()\n isRunning = AppDependencies.shared.cliServer.isRunning\n }\n }\n }\n\n HStack {\n if isInstalled {\n Image(systemName: \"checkmark.circle.fill\")\n .foregroundColor(.green)\n Text(\"FlashSpace CLI Installation\")\n Spacer()\n Button(\"Uninstall FlashSpace CLI\") {\n CLI.uninstall()\n isInstalled = CLI.isInstalled\n }\n } else {\n Image(systemName: \"xmark.circle.fill\")\n .foregroundColor(.red)\n Text(\"FlashSpace CLI Installation\")\n Spacer()\n Button(\"Install FlashSpace CLI\") {\n CLI.install()\n isInstalled = CLI.isInstalled\n }\n }\n }\n\n VStack(alignment: .leading) {\n Text(\n \"\"\"\n Tool will be installed in /usr/local/bin/flashspace.\n\n You can also access it directly from the app bundle at:\n \"\"\"\n )\n Text(CLI.cliPath)\n .lineLimit(1)\n .truncationMode(.middle)\n .help(CLI.cliPath)\n }\n .foregroundColor(.secondary)\n .font(.callout)\n }\n\n Section {\n Text(\"Run `flashspace --help` in the terminal to see the available commands.\")\n .foregroundStyle(.secondary)\n .font(.callout)\n }\n }\n .onAppear {\n isInstalled = CLI.isInstalled\n isRunning = AppDependencies.shared.cliServer.isRunning\n }\n .formStyle(.grouped)\n .navigationTitle(\"CLI\")\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Profile/ProfileCommand.swift", "//\n// ProfileCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct ProfileCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"profile\",\n abstract: \"Activate a profile\"\n )\n\n @Argument(help: \"Profile name.\")\n var name: String\n\n func run() throws {\n sendCommand(.activateProfile(name: name))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Profile/DeleteProfileCommand.swift", "//\n// DeleteProfileCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct DeleteProfileCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"delete-profile\",\n abstract: \"Delete a profile\"\n )\n\n @Argument(help: \"The name of the profile to delete.\")\n var name: String\n\n func run() throws {\n sendCommand(.deleteProfile(name: name))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Gestures/GesturesSettingsView.swift", "//\n// GesturesSettingsView.swift\n//\n// Created by Wojciech Kulik on 21/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct GesturesSettingsView: View {\n @StateObject private var settings = AppDependencies.shared.gesturesSettings\n\n var body: some View {\n Form {\n Section {\n Toggle(\"Enable Swipe Gestures\", isOn: $settings.enableSwipeGestures)\n HStack {\n Text(\"Activation Threshold\")\n Spacer()\n Text(\"\\(settings.swipeThreshold, specifier: \"%.2f\")\")\n Stepper(\n \"\",\n value: $settings.swipeThreshold,\n in: 0.05...0.7,\n step: 0.05\n ).labelsHidden()\n }\n Text(\"Remember to disable system gestures in System Preferences > Trackpad > More Gestures.\")\n .font(.callout)\n .foregroundStyle(.secondary)\n Text(\n \"Keeping \\\"Swipe between full-screen apps\\\" enabled prevents from detecting swipe gesture as \" +\n \"a scroll action. However, you must keep only one macOS Space to avoid switching.\"\n )\n .font(.callout)\n .foregroundStyle(.secondary)\n }\n\n Section(\"Horizontal Swipes\") {\n Picker(\"3-Finger Left Swipe\", selection: $settings.swipeLeft3FingerAction) {\n ForEach(GestureAction.allCases) { action in\n Text(action.description).tag(action)\n }\n }\n Picker(\"3-Finger Right Swipe\", selection: $settings.swipeRight3FingerAction) {\n ForEach(GestureAction.allCases) { action in\n Text(action.description).tag(action)\n }\n }\n Picker(\"4-Finger Left Swipe\", selection: $settings.swipeLeft4FingerAction) {\n ForEach(GestureAction.allCases) { action in\n Text(action.description).tag(action)\n }\n }\n Picker(\"4-Finger Right Swipe\", selection: $settings.swipeRight4FingerAction) {\n ForEach(GestureAction.allCases) { action in\n Text(action.description).tag(action)\n }\n }\n }\n .disabled(!settings.enableSwipeGestures)\n .opacity(settings.enableSwipeGestures ? 1 : 0.5)\n\n Section(\"Vertical Swipes\") {\n Picker(\"3-Finger Up Swipe\", selection: $settings.swipeUp3FingerAction) {\n ForEach(GestureAction.allCases) { action in\n Text(action.description).tag(action)\n }\n }\n Picker(\"3-Finger Down Swipe\", selection: $settings.swipeDown3FingerAction) {\n ForEach(GestureAction.allCases) { action in\n Text(action.description).tag(action)\n }\n }\n Picker(\"4-Finger Up Swipe\", selection: $settings.swipeUp4FingerAction) {\n ForEach(GestureAction.allCases) { action in\n Text(action.description).tag(action)\n }\n }\n Picker(\"4-Finger Down Swipe\", selection: $settings.swipeDown4FingerAction) {\n ForEach(GestureAction.allCases) { action in\n Text(action.description).tag(action)\n }\n }\n }\n .disabled(!settings.enableSwipeGestures)\n .opacity(settings.enableSwipeGestures ? 1 : 0.5)\n\n Section(\"System\") {\n Toggle(\"Restart App On Wake Up\", isOn: $settings.restartAppOnWakeUp)\n Text(\n \"Restarts the app when your Mac wakes up from sleep. This can help with gesture recognition issues after waking.\"\n )\n .font(.callout)\n .foregroundStyle(.secondary)\n }\n .disabled(!settings.enableSwipeGestures)\n .opacity(settings.enableSwipeGestures ? 1 : 0.5)\n }\n .formStyle(.grouped)\n .navigationTitle(\"Gestures\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/FocusManager/FocusSettingsView.swift", "//\n// FocusSettingsView.swift\n//\n// Created by Wojciech Kulik on 23/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct FocusSettingsView: View {\n @StateObject private var settings = AppDependencies.shared.focusManagerSettings\n\n var body: some View {\n Form {\n Section {\n Toggle(\"Enable Focus Manager\", isOn: $settings.enableFocusManagement)\n }\n\n Group {\n Section(\"Trigger when focus is changed using shortcuts\") {\n Toggle(\"Center Cursor In Focused App\", isOn: $settings.centerCursorOnFocusChange)\n }\n\n Section(\"Shortcuts\") {\n hotkey(\"Focus Left\", for: $settings.focusLeft)\n hotkey(\"Focus Right\", for: $settings.focusRight)\n hotkey(\"Focus Up\", for: $settings.focusUp)\n hotkey(\"Focus Down\", for: $settings.focusDown)\n }\n\n Section {\n hotkey(\"Focus Next App\", for: $settings.focusNextWorkspaceApp)\n hotkey(\"Focus Previous App\", for: $settings.focusPreviousWorkspaceApp)\n }\n\n Section {\n hotkey(\"Focus Next Window\", for: $settings.focusNextWorkspaceWindow)\n hotkey(\"Focus Previous Window\", for: $settings.focusPreviousWorkspaceWindow)\n }\n\n Section(\"Experimental\") {\n Toggle(\"Focus Frontmost Window\", isOn: $settings.focusFrontmostWindow)\n Text(\n \"This is an experimental feature. It sets the focus to the frontmost window\" +\n \" if two or more windows are overlapping in the pointed direction.\\n\\n\" +\n \"It works only with directional focus shortcuts (left, right, up, down).\"\n )\n .foregroundStyle(.secondary)\n .font(.callout)\n }\n }\n .disabled(!settings.enableFocusManagement)\n .opacity(settings.enableFocusManagement ? 1 : 0.5)\n }\n .formStyle(.grouped)\n .navigationTitle(\"Focus Manager\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/FloatingApps/FloatingAppsSettings.swift", "//\n// FloatingAppsSettings.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nfinal class FloatingAppsSettings: ObservableObject {\n @Published var floatingApps: [MacApp] = []\n @Published var floatTheFocusedApp: AppHotKey?\n @Published var unfloatTheFocusedApp: AppHotKey?\n @Published var toggleTheFocusedAppFloating: AppHotKey?\n\n private var observer: AnyCancellable?\n private let updateSubject = PassthroughSubject<(), Never>()\n\n init() { observe() }\n\n func addFloatingAppIfNeeded(app: MacApp) {\n guard !floatingApps.contains(app) else { return }\n floatingApps.append(app)\n }\n\n func deleteFloatingApp(app: MacApp) {\n floatingApps.removeAll { $0 == app }\n }\n\n private func observe() {\n observer = Publishers.MergeMany(\n $floatingApps.settingsPublisher(),\n $floatTheFocusedApp.settingsPublisher(),\n $unfloatTheFocusedApp.settingsPublisher(),\n $toggleTheFocusedAppFloating.settingsPublisher()\n )\n .receive(on: DispatchQueue.main)\n .sink { [weak self] in self?.updateSubject.send() }\n }\n}\n\nextension FloatingAppsSettings: SettingsProtocol {\n var updatePublisher: AnyPublisher<(), Never> {\n updateSubject.eraseToAnyPublisher()\n }\n\n func load(from appSettings: AppSettings) {\n observer = nil\n floatingApps = appSettings.floatingApps ?? []\n floatTheFocusedApp = appSettings.floatTheFocusedApp\n unfloatTheFocusedApp = appSettings.unfloatTheFocusedApp\n toggleTheFocusedAppFloating = appSettings.toggleTheFocusedAppFloating\n observe()\n }\n\n func update(_ appSettings: inout AppSettings) {\n appSettings.floatingApps = floatingApps.isEmpty ? nil : floatingApps\n appSettings.floatTheFocusedApp = floatTheFocusedApp\n appSettings.unfloatTheFocusedApp = unfloatTheFocusedApp\n appSettings.toggleTheFocusedAppFloating = toggleTheFocusedAppFloating\n }\n}\n"], ["/FlashSpace/FlashSpace/UI/HotKeyControl.swift", "//\n// HotKeyControl.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport ShortcutRecorder\nimport SwiftUI\n\nstruct HotKeyControl: NSViewRepresentable {\n @Binding var shortcut: AppHotKey?\n\n func makeNSView(context: Context) -> RecorderControl {\n let control = RecorderControl(frame: .zero)\n control.delegate = context.coordinator\n control.objectValue = shortcut.flatMap { $0.toShortcut() }\n control.set(\n allowedModifierFlags: [.command, .option, .control, .shift],\n requiredModifierFlags: [],\n allowsEmptyModifierFlags: true\n )\n\n return control\n }\n\n func updateNSView(_ nsView: RecorderControl, context: Context) {\n context.coordinator.parent = self\n nsView.objectValue = shortcut.flatMap { $0.toShortcut() }\n }\n\n func makeCoordinator() -> Coordinator { Coordinator(parent: self) }\n\n final class Coordinator: NSObject, RecorderControlDelegate {\n var parent: HotKeyControl\n\n private let hotKeysManager = AppDependencies.shared.hotKeysManager\n\n init(parent: HotKeyControl) {\n self.parent = parent\n }\n\n func recorderControlDidBeginRecording(_ aControl: RecorderControl) {\n hotKeysManager.disableAll()\n }\n\n func recorderControl(_ aControl: RecorderControl, canRecord aShortcut: Shortcut) -> Bool {\n if let conflict = hotKeysManager.allHotKeys.first(where: { $0.hotKey.toShortcut() == aShortcut })?.scope {\n Alert.showOkAlert(\n title: \"Conflict\",\n message: \"This shortcut is already assigned within the \\(conflict) scope.\"\n )\n return false\n }\n\n return true\n }\n\n func recorderControlDidEndRecording(_ aControl: RecorderControl) {\n guard let shortcut = aControl.objectValue else {\n parent.shortcut = nil\n hotKeysManager.enableAll()\n return\n }\n\n parent.shortcut = .init(\n keyCode: shortcut.keyCode.rawValue,\n modifiers: shortcut.modifierFlags.rawValue\n )\n hotKeysManager.enableAll()\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/HotKeys/Models/KeyModifiersMap.swift", "//\n// KeyModifiersMap.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nenum KeyModifiersMap {\n static func toString(_ value: RawKeyModifiers) -> String {\n let flags = NSEvent.ModifierFlags(rawValue: value)\n var result: [String] = []\n\n if flags.contains(.command) { result.append(\"cmd\") }\n if flags.contains(.control) { result.append(\"ctrl\") }\n if flags.contains(.option) { result.append(\"opt\") }\n if flags.contains(.shift) { result.append(\"shift\") }\n\n return result.joined(separator: \"+\")\n }\n\n static func toModifiers(_ value: String) -> RawKeyModifiers {\n let flags = value.lowercased().split(separator: \"+\").map { String($0) }\n var result: RawKeyModifiers = 0\n\n if flags.contains(\"cmd\") { result |= NSEvent.ModifierFlags.command.rawValue }\n if flags.contains(\"ctrl\") { result |= NSEvent.ModifierFlags.control.rawValue }\n if flags.contains(\"opt\") { result |= NSEvent.ModifierFlags.option.rawValue }\n if flags.contains(\"shift\") { result |= NSEvent.ModifierFlags.shift.rawValue }\n\n return result\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/HotKeys/Extensions/AppHotKey+KeyboardShortcut.swift", "//\n// AppHotKey+KeyboardShortcut.swift\n//\n// Created by Wojciech Kulik on 31/05/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nextension AppHotKey {\n var toKeyboardShortcut: KeyboardShortcut? {\n let components = value.components(separatedBy: \"+\")\n let modifiers = toEventModifiers(value)\n\n guard let key = components.last,\n let keyEquivalent = stringToKeyEquivalent(key) else { return nil }\n\n return KeyboardShortcut(\n keyEquivalent,\n modifiers: modifiers\n )\n }\n\n // swiftlint:disable:next cyclomatic_complexity\n private func stringToKeyEquivalent(_ value: String) -> KeyEquivalent? {\n guard value.count > 1 else { return KeyEquivalent(Character(value)) }\n\n switch value {\n case \"esc\", \"escape\": return KeyEquivalent.escape\n case \"return\", \"enter\": return KeyEquivalent.return\n case \"tab\": return KeyEquivalent.tab\n case \"space\": return KeyEquivalent.space\n case \"delete\", \"backspace\": return KeyEquivalent.delete\n case \"up\": return KeyEquivalent.upArrow\n case \"down\": return KeyEquivalent.downArrow\n case \"left\": return KeyEquivalent.leftArrow\n case \"right\": return KeyEquivalent.rightArrow\n case \"home\": return KeyEquivalent.home\n case \"end\": return KeyEquivalent.end\n default: return nil\n }\n }\n\n private func toEventModifiers(_ value: String) -> EventModifiers {\n let flags = value.lowercased().split(separator: \"+\").map { String($0) }\n var result: EventModifiers = []\n\n if flags.contains(\"cmd\") { result.insert(.command) }\n if flags.contains(\"ctrl\") { result.insert(.control) }\n if flags.contains(\"opt\") { result.insert(.option) }\n if flags.contains(\"shift\") { result.insert(.shift) }\n\n return result\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Get/GetDisplayCommand.swift", "//\n// GetDisplayCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport ArgumentParser\nimport Foundation\n\nstruct GetDisplayCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"get-display\",\n abstract: \"Get active display\"\n )\n\n func run() throws {\n sendCommand(.getDisplay)\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Get/GetProfileCommand.swift", "//\n// GetProfileCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport ArgumentParser\nimport Foundation\n\nstruct GetProfileCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"get-profile\",\n abstract: \"Get active profile\"\n )\n\n func run() throws {\n sendCommand(.getProfile)\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Models/CreateWorkspaceRequest.swift", "//\n// CreateWorkspaceRequest.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\n\nstruct CreateWorkspaceRequest: Codable {\n let name: String\n let display: String?\n let icon: String?\n let activateKey: String?\n let assignKey: String?\n let activate: Bool\n}\n\nextension CreateWorkspaceRequest {\n var toWorkspace: Workspace {\n Workspace(\n id: .init(),\n name: name,\n display: display ?? NSScreen.main?.localizedName ?? \"\",\n activateShortcut: activateKey.flatMap { .init(value: $0) },\n assignAppShortcut: assignKey.flatMap { .init(value: $0) },\n apps: [],\n appToFocus: nil,\n symbolIconName: icon\n )\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Workspaces/WorkspaceSettings.swift", "//\n// WorkspaceSettings.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nfinal class WorkspaceSettings: ObservableObject {\n @Published var displayMode: DisplayMode = .static\n\n @Published var centerCursorOnWorkspaceChange = false\n @Published var changeWorkspaceOnAppAssign = true\n @Published var activeWorkspaceOnFocusChange = true\n @Published var skipEmptyWorkspacesOnSwitch = false\n @Published var keepUnassignedAppsOnSwitch = false\n @Published var restoreHiddenAppsOnSwitch = true\n @Published var enableWorkspaceTransitions = false\n @Published var workspaceTransitionDuration = 0.3\n @Published var workspaceTransitionDimming = 0.2\n\n @Published var assignFocusedApp: AppHotKey?\n @Published var unassignFocusedApp: AppHotKey?\n @Published var toggleFocusedAppAssignment: AppHotKey?\n @Published var assignVisibleApps: AppHotKey?\n @Published var hideUnassignedApps: AppHotKey?\n\n @Published var loopWorkspaces = true\n @Published var switchToRecentWorkspace: AppHotKey?\n @Published var switchToPreviousWorkspace: AppHotKey?\n @Published var switchToNextWorkspace: AppHotKey?\n\n @Published var alternativeDisplays = \"\"\n\n @Published var enablePictureInPictureSupport = true\n @Published var switchWorkspaceWhenPipCloses = true\n @Published var pipScreenCornerOffset = 15\n @Published var pipApps: [PipApp] = []\n\n private var observer: AnyCancellable?\n private let updateSubject = PassthroughSubject<(), Never>()\n\n init() { observe() }\n\n func addPipApp(_ app: PipApp) {\n pipApps.append(app)\n }\n\n func deletePipApp(_ app: PipApp) {\n pipApps.removeAll { $0 == app }\n }\n\n private func observe() {\n observer = Publishers.MergeMany(\n $displayMode.settingsPublisher(),\n\n $centerCursorOnWorkspaceChange.settingsPublisher(),\n $changeWorkspaceOnAppAssign.settingsPublisher(),\n $activeWorkspaceOnFocusChange.settingsPublisher(),\n $skipEmptyWorkspacesOnSwitch.settingsPublisher(),\n $keepUnassignedAppsOnSwitch.settingsPublisher(),\n $restoreHiddenAppsOnSwitch.settingsPublisher(),\n $enableWorkspaceTransitions.settingsPublisher(),\n $workspaceTransitionDuration.settingsPublisher(debounce: true),\n $workspaceTransitionDimming.settingsPublisher(debounce: true),\n\n $assignFocusedApp.settingsPublisher(),\n $unassignFocusedApp.settingsPublisher(),\n $toggleFocusedAppAssignment.settingsPublisher(),\n $assignVisibleApps.settingsPublisher(),\n $hideUnassignedApps.settingsPublisher(),\n\n $loopWorkspaces.settingsPublisher(),\n $switchToRecentWorkspace.settingsPublisher(),\n $switchToPreviousWorkspace.settingsPublisher(),\n $switchToNextWorkspace.settingsPublisher(),\n\n $alternativeDisplays.settingsPublisher(debounce: true),\n $enablePictureInPictureSupport.settingsPublisher(),\n $switchWorkspaceWhenPipCloses.settingsPublisher(),\n $pipApps.settingsPublisher(),\n $pipScreenCornerOffset.settingsPublisher(debounce: true)\n )\n .receive(on: DispatchQueue.main)\n .sink { [weak self] in self?.updateSubject.send() }\n }\n}\n\nextension WorkspaceSettings: SettingsProtocol {\n var updatePublisher: AnyPublisher<(), Never> {\n updateSubject.eraseToAnyPublisher()\n }\n\n func load(from appSettings: AppSettings) {\n observer = nil\n displayMode = appSettings.displayMode ?? .static\n\n centerCursorOnWorkspaceChange = appSettings.centerCursorOnWorkspaceChange ?? false\n changeWorkspaceOnAppAssign = appSettings.changeWorkspaceOnAppAssign ?? true\n activeWorkspaceOnFocusChange = appSettings.activeWorkspaceOnFocusChange ?? true\n skipEmptyWorkspacesOnSwitch = appSettings.skipEmptyWorkspacesOnSwitch ?? false\n keepUnassignedAppsOnSwitch = appSettings.keepUnassignedAppsOnSwitch ?? false\n restoreHiddenAppsOnSwitch = appSettings.restoreHiddenAppsOnSwitch ?? true\n enableWorkspaceTransitions = appSettings.enableWorkspaceTransitions ?? false\n workspaceTransitionDuration = min(appSettings.workspaceTransitionDuration ?? 0.3, 0.5)\n workspaceTransitionDimming = min(appSettings.workspaceTransitionDimming ?? 0.2, 0.5)\n\n assignFocusedApp = appSettings.assignFocusedApp\n unassignFocusedApp = appSettings.unassignFocusedApp\n toggleFocusedAppAssignment = appSettings.toggleFocusedAppAssignment\n assignVisibleApps = appSettings.assignVisibleApps\n hideUnassignedApps = appSettings.hideUnassignedApps\n\n loopWorkspaces = appSettings.loopWorkspaces ?? true\n switchToRecentWorkspace = appSettings.switchToRecentWorkspace\n switchToPreviousWorkspace = appSettings.switchToPreviousWorkspace\n switchToNextWorkspace = appSettings.switchToNextWorkspace\n\n alternativeDisplays = appSettings.alternativeDisplays ?? \"\"\n enablePictureInPictureSupport = appSettings.enablePictureInPictureSupport ?? true\n switchWorkspaceWhenPipCloses = appSettings.switchWorkspaceWhenPipCloses ?? true\n pipApps = appSettings.pipApps ?? []\n pipScreenCornerOffset = appSettings.pipScreenCornerOffset ?? 15\n observe()\n }\n\n func update(_ appSettings: inout AppSettings) {\n appSettings.displayMode = displayMode\n\n appSettings.centerCursorOnWorkspaceChange = centerCursorOnWorkspaceChange\n appSettings.changeWorkspaceOnAppAssign = changeWorkspaceOnAppAssign\n appSettings.activeWorkspaceOnFocusChange = activeWorkspaceOnFocusChange\n appSettings.skipEmptyWorkspacesOnSwitch = skipEmptyWorkspacesOnSwitch\n appSettings.keepUnassignedAppsOnSwitch = keepUnassignedAppsOnSwitch\n appSettings.restoreHiddenAppsOnSwitch = restoreHiddenAppsOnSwitch\n appSettings.enableWorkspaceTransitions = enableWorkspaceTransitions\n appSettings.workspaceTransitionDuration = workspaceTransitionDuration\n appSettings.workspaceTransitionDimming = workspaceTransitionDimming\n\n appSettings.assignFocusedApp = assignFocusedApp\n appSettings.unassignFocusedApp = unassignFocusedApp\n appSettings.toggleFocusedAppAssignment = toggleFocusedAppAssignment\n appSettings.assignVisibleApps = assignVisibleApps\n appSettings.hideUnassignedApps = hideUnassignedApps\n\n appSettings.loopWorkspaces = loopWorkspaces\n appSettings.switchToRecentWorkspace = switchToRecentWorkspace\n appSettings.switchToPreviousWorkspace = switchToPreviousWorkspace\n appSettings.switchToNextWorkspace = switchToNextWorkspace\n\n appSettings.alternativeDisplays = alternativeDisplays\n appSettings.enablePictureInPictureSupport = enablePictureInPictureSupport\n appSettings.switchWorkspaceWhenPipCloses = switchWorkspaceWhenPipCloses\n appSettings.pipApps = pipApps\n appSettings.pipScreenCornerOffset = pipScreenCornerOffset\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Integrations/IntegrationsSettings.swift", "//\n// IntegrationsSettings.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nfinal class IntegrationsSettings: ObservableObject {\n static let defaultWorkspaceChangeScript = \"sketchybar --trigger flashspace_workspace_change WORKSPACE=\\\"$WORKSPACE\\\" DISPLAY=\\\"$DISPLAY\\\"\"\n static let defaultProfileChangeScript = \"sketchybar --reload\"\n\n @Published var enableIntegrations = false\n @Published var runScriptOnLaunch = \"\"\n @Published var runScriptOnWorkspaceChange = IntegrationsSettings.defaultWorkspaceChangeScript\n @Published var runScriptOnProfileChange = IntegrationsSettings.defaultProfileChangeScript\n\n private var observer: AnyCancellable?\n private let updateSubject = PassthroughSubject<(), Never>()\n\n init() {\n observe()\n\n DispatchQueue.main.async {\n Integrations.runOnAppLaunchIfNeeded()\n }\n }\n\n private func observe() {\n observer = Publishers.MergeMany(\n $enableIntegrations.settingsPublisher(),\n $runScriptOnWorkspaceChange.settingsPublisher(debounce: true),\n $runScriptOnLaunch.settingsPublisher(debounce: true),\n $runScriptOnProfileChange.settingsPublisher(debounce: true)\n )\n .receive(on: DispatchQueue.main)\n .sink { [weak self] in self?.updateSubject.send() }\n }\n}\n\nextension IntegrationsSettings: SettingsProtocol {\n var updatePublisher: AnyPublisher<(), Never> {\n updateSubject.eraseToAnyPublisher()\n }\n\n func load(from appSettings: AppSettings) {\n observer = nil\n enableIntegrations = appSettings.enableIntegrations ?? false\n runScriptOnLaunch = appSettings.runScriptOnLaunch ?? \"\"\n runScriptOnWorkspaceChange = appSettings.runScriptOnWorkspaceChange ?? Self.defaultWorkspaceChangeScript\n runScriptOnProfileChange = appSettings.runScriptOnProfileChange ?? Self.defaultProfileChangeScript\n observe()\n }\n\n func update(_ appSettings: inout AppSettings) {\n appSettings.enableIntegrations = enableIntegrations\n appSettings.runScriptOnLaunch = runScriptOnLaunch\n appSettings.runScriptOnWorkspaceChange = runScriptOnWorkspaceChange\n appSettings.runScriptOnProfileChange = runScriptOnProfileChange\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Open/OpenSpaceControlCommand.swift", "//\n// OpenSpaceControlCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct OpenSpaceControlCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"open-space-control\",\n abstract: \"Open Space Control\"\n )\n\n func run() throws {\n sendCommand(.openSpaceControl)\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Integrations/IntegrationsSettingsView.swift", "//\n// IntegrationsSettingsView.swift\n//\n// Created by Wojciech Kulik on 24/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct IntegrationsSettingsView: View {\n @StateObject var settings = AppDependencies.shared.integrationsSettings\n\n var body: some View {\n Form {\n Section {\n Toggle(\"Enable Integrations\", isOn: $settings.enableIntegrations)\n }\n\n Section(\"Scripts To Run\") {\n HStack {\n Text(\"On App Launch\")\n TextField(\"\", text: $settings.runScriptOnLaunch)\n .foregroundColor(.secondary)\n .standardPlaceholder(settings.runScriptOnLaunch.isEmpty)\n }\n\n HStack {\n Text(\"On Workspace Change\")\n TextField(\"\", text: $settings.runScriptOnWorkspaceChange)\n .foregroundColor(.secondary)\n .standardPlaceholder(settings.runScriptOnWorkspaceChange.isEmpty)\n }\n\n HStack {\n Text(\"On Profile Change\")\n TextField(\"\", text: $settings.runScriptOnProfileChange)\n .foregroundColor(.secondary)\n .standardPlaceholder(settings.runScriptOnProfileChange.isEmpty)\n }\n\n Text(\n \"\"\"\n $WORKSPACE will be replaced with the active workspace name\n $WORKSPACE_NUMBER will be replaced with the active workspace number\n $DISPLAY will be replaced with the corresponding display name\n $PROFILE will be replaced with the active profile name\n \"\"\"\n )\n .foregroundStyle(.secondary)\n .font(.callout)\n }\n .disabled(!settings.enableIntegrations)\n .opacity(settings.enableIntegrations ? 1 : 0.5)\n }\n .formStyle(.grouped)\n .navigationTitle(\"Integrations\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Profiles/ProfilesSettingsViewModel.swift", "//\n// ProfilesSettingsViewModel.swift\n//\n// Created by Wojciech Kulik on 26/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nfinal class ProfilesSettingsViewModel: ObservableObject {\n enum Action {\n case createProfile\n case renameProfile(ProfileId)\n case deleteProfile(ProfileId)\n }\n\n @Published var isInputDialogPresented = false\n @Published var isDeleteConfirmationPresented = false\n @Published var isCopyChoicePresented = false\n @Published var profileToDelete = \"\"\n @Published var userInput = \"\"\n\n var hideDeleteButton: Bool { profilesRepository.profiles.count == 1 }\n\n private var action: Action?\n\n private let profilesRepository = AppDependencies.shared.profilesRepository\n\n func createNewProfile() {\n action = .createProfile\n userInput = \"\"\n isInputDialogPresented = true\n }\n\n func createNewProfile(copyWorkspaces: Bool) {\n let input = userInput.trimmingCharacters(in: .whitespacesAndNewlines)\n guard !input.isEmpty else { return }\n\n profilesRepository.createProfile(name: input, keepWorkspaces: copyWorkspaces)\n }\n\n func renameProfile(_ profile: Profile) {\n action = .renameProfile(profile.id)\n userInput = profile.name\n isInputDialogPresented = true\n }\n\n func deleteProfile(_ profile: Profile) {\n action = .deleteProfile(profile.id)\n profileToDelete = profile.name\n isDeleteConfirmationPresented = true\n }\n\n func inputDialogDismissed() {\n let input = userInput.trimmingCharacters(in: .whitespacesAndNewlines)\n guard let action, !input.isEmpty else { return }\n\n switch action {\n case .createProfile:\n isCopyChoicePresented = true\n case .renameProfile(let id):\n profilesRepository.renameProfile(id: id, to: input)\n case .deleteProfile:\n break\n }\n }\n\n func deleteConfirmed() {\n guard let action else { return }\n\n switch action {\n case .deleteProfile(let id):\n profilesRepository.deleteProfile(id: id)\n default:\n break\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Integrations/Integrations.swift", "//\n// Integrations.swift\n//\n// Created by Wojciech Kulik on 24/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nenum Integrations {\n private static let settings = AppDependencies.shared.integrationsSettings\n private static let profilesRepository = AppDependencies.shared.profilesRepository\n\n static func runOnActivateIfNeeded(workspace: ActiveWorkspace) {\n let script = settings.runScriptOnWorkspaceChange.trimmingCharacters(in: .whitespaces)\n .replacingOccurrences(of: \"$WORKSPACE_NUMBER\", with: workspace.number ?? \"\")\n .replacingOccurrences(of: \"$WORKSPACE\", with: workspace.name)\n .replacingOccurrences(of: \"$DISPLAY\", with: workspace.display)\n .replacingOccurrences(of: \"$PROFILE\", with: profilesRepository.selectedProfile.name)\n runScript(script)\n }\n\n static func runOnAppLaunchIfNeeded() {\n let script = settings.runScriptOnLaunch.trimmingCharacters(in: .whitespaces)\n .replacingOccurrences(of: \"$PROFILE\", with: profilesRepository.selectedProfile.name)\n runScript(script)\n }\n\n static func runOnProfileChangeIfNeeded(profile: String) {\n let script = settings.runScriptOnProfileChange.trimmingCharacters(in: .whitespaces)\n .replacingOccurrences(of: \"$PROFILE\", with: profile)\n runScript(script)\n }\n\n private static func runScript(_ script: String) {\n guard settings.enableIntegrations, !script.isEmpty else { return }\n\n let shell = ProcessInfo.processInfo.environment[\"SHELL\"] ?? \"/bin/sh\"\n let task = Process()\n task.launchPath = shell\n task.arguments = [\"-c\", script]\n task.launch()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Acknowledgements/AcknowledgementsSettingsView.swift", "//\n// AcknowledgementsSettingsView.swift\n//\n// Created by Wojciech Kulik on 26/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct AcknowledgementsSettingsView: View {\n @State private var selectedDependency: String? = \"xnth97/SymbolPicker\"\n @State private var dependencies = [\n \"xnth97/SymbolPicker\",\n \"Kentzo/ShortcutRecorder\",\n \"LebJe/TOMLKit\",\n \"jpsim/Yams\",\n \"sparkle-project/Sparkle\",\n \"apple/swift-argument-parser\",\n \"SwiftFormat\",\n \"SwiftLint\"\n ]\n\n var body: some View {\n VStack(spacing: 0.0) {\n List(\n dependencies,\n id: \\.self,\n selection: $selectedDependency\n ) { dependency in\n Text(dependency)\n }.frame(height: 130)\n\n ScrollView([.vertical, .horizontal]) {\n VStack {\n Group {\n switch selectedDependency {\n case \"xnth97/SymbolPicker\":\n Text(Licenses.symbolPicker)\n case \"Kentzo/ShortcutRecorder\":\n Text(Licenses.shortcutRecorder)\n case \"LebJe/TOMLKit\":\n Text(Licenses.tomlKit)\n case \"jpsim/Yams\":\n Text(Licenses.yams)\n case \"sparkle-project/Sparkle\":\n Text(Licenses.sparkle)\n case \"apple/swift-argument-parser\":\n Text(Licenses.swiftArgumentParser)\n case \"SwiftFormat\":\n Text(Licenses.swiftFormat)\n case \"SwiftLint\":\n Text(Licenses.swiftLint)\n default:\n EmptyView()\n }\n }\n .frame(minHeight: 330, alignment: .top)\n .textSelection(.enabled)\n .padding()\n }\n }\n }\n .navigationTitle(\"Acknowledgements\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Gestures/GesturesSettings.swift", "//\n// GesturesSettings.swift\n//\n// Created by Wojciech Kulik on 22/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nfinal class GesturesSettings: ObservableObject {\n @Published var swipeThreshold: Double = 0.2\n @Published var enableSwipeGestures = false {\n didSet { updateSwipeManager() }\n }\n\n @Published var restartAppOnWakeUp = false\n\n @Published var swipeRight3FingerAction: GestureAction = .nextWorkspace\n @Published var swipeLeft3FingerAction: GestureAction = .previousWorkspace\n @Published var swipeRight4FingerAction: GestureAction = .none\n @Published var swipeLeft4FingerAction: GestureAction = .none\n\n @Published var swipeUp3FingerAction: GestureAction = .none\n @Published var swipeDown3FingerAction: GestureAction = .none\n @Published var swipeUp4FingerAction: GestureAction = .none\n @Published var swipeDown4FingerAction: GestureAction = .none\n\n var isVerticalSwipeSet: Bool {\n swipeUp3FingerAction != .none || swipeDown3FingerAction != .none ||\n swipeUp4FingerAction != .none || swipeDown4FingerAction != .none\n }\n\n var isHorizontalSwipeSet: Bool {\n swipeLeft3FingerAction != .none || swipeRight3FingerAction != .none ||\n swipeLeft4FingerAction != .none || swipeRight4FingerAction != .none\n }\n\n private var observer: AnyCancellable?\n private let updateSubject = PassthroughSubject<(), Never>()\n\n init() {\n observe()\n updateSwipeManager()\n }\n\n private func observe() {\n observer = Publishers.MergeMany(\n $enableSwipeGestures.settingsPublisher(),\n $swipeThreshold.settingsPublisher(),\n $restartAppOnWakeUp.settingsPublisher(),\n\n $swipeLeft3FingerAction.settingsPublisher(),\n $swipeRight3FingerAction.settingsPublisher(),\n $swipeLeft4FingerAction.settingsPublisher(),\n $swipeRight4FingerAction.settingsPublisher(),\n\n $swipeUp3FingerAction.settingsPublisher(),\n $swipeDown3FingerAction.settingsPublisher(),\n $swipeUp4FingerAction.settingsPublisher(),\n $swipeDown4FingerAction.settingsPublisher()\n )\n .receive(on: DispatchQueue.main)\n .sink { [weak self] in self?.updateSubject.send() }\n }\n\n private func updateSwipeManager() {\n if enableSwipeGestures {\n SwipeManager.shared.start()\n } else {\n SwipeManager.shared.stop()\n }\n }\n}\n\nextension GesturesSettings: SettingsProtocol {\n var updatePublisher: AnyPublisher<(), Never> {\n updateSubject.eraseToAnyPublisher()\n }\n\n func load(from appSettings: AppSettings) {\n observer = nil\n enableSwipeGestures = appSettings.enableSwipeGestures ?? false\n swipeThreshold = appSettings.swipeThreshold ?? 0.2\n restartAppOnWakeUp = appSettings.restartAppOnWakeUp ?? false\n\n swipeLeft3FingerAction = appSettings.swipeLeft3FingerAction ?? .previousWorkspace\n swipeRight3FingerAction = appSettings.swipeRight3FingerAction ?? .nextWorkspace\n swipeLeft4FingerAction = appSettings.swipeLeft4FingerAction ?? .none\n swipeRight4FingerAction = appSettings.swipeRight4FingerAction ?? .none\n\n swipeUp3FingerAction = appSettings.swipeUp3FingerAction ?? .none\n swipeDown3FingerAction = appSettings.swipeDown3FingerAction ?? .none\n swipeUp4FingerAction = appSettings.swipeUp4FingerAction ?? .none\n swipeDown4FingerAction = appSettings.swipeDown4FingerAction ?? .none\n\n observe()\n }\n\n func update(_ appSettings: inout AppSettings) {\n appSettings.enableSwipeGestures = enableSwipeGestures\n appSettings.swipeThreshold = swipeThreshold\n appSettings.restartAppOnWakeUp = restartAppOnWakeUp\n\n appSettings.swipeLeft3FingerAction = swipeLeft3FingerAction\n appSettings.swipeRight3FingerAction = swipeRight3FingerAction\n appSettings.swipeLeft4FingerAction = swipeLeft4FingerAction\n appSettings.swipeRight4FingerAction = swipeRight4FingerAction\n\n appSettings.swipeUp3FingerAction = swipeUp3FingerAction\n appSettings.swipeDown3FingerAction = swipeDown3FingerAction\n appSettings.swipeUp4FingerAction = swipeUp4FingerAction\n appSettings.swipeDown4FingerAction = swipeDown4FingerAction\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Workspaces/WorkspaceTransitionManager.swift", "//\n// WorkspaceTransitionManager.swift\n//\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n// Contribution by Sergio Patino - https://github.com/sergiopatino\n//\n\nimport AppKit\n\nfinal class WorkspaceTransitionManager {\n private var windows: [NSWindow] = []\n private let settings: WorkspaceSettings\n\n init(workspaceSettings: WorkspaceSettings) {\n self.settings = workspaceSettings\n }\n\n func showTransitionIfNeeded(for workspace: Workspace, on displays: Set) {\n guard settings.enableWorkspaceTransitions else {\n // Small delay to allow workspace to be activated\n DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {\n NotificationCenter.default.post(name: .workspaceTransitionFinished, object: workspace)\n }\n return\n }\n guard windows.isEmpty, !SpaceControl.isVisible else { return }\n\n let screens = NSScreen.screens.filter { displays.contains($0.localizedName) }\n\n guard !screens.isEmpty else { return }\n\n for screen in screens {\n let window = NSWindow(\n contentRect: screen.frame,\n styleMask: [.borderless],\n backing: .buffered,\n defer: false\n )\n window.isOpaque = false\n window.backgroundColor = .clear\n window.level = .screenSaver\n window.alphaValue = CGFloat(settings.workspaceTransitionDimming)\n window.contentView?.wantsLayer = true\n window.contentView?.layer?.backgroundColor = NSColor.black.cgColor\n\n window.orderFrontRegardless()\n windows.append(window)\n }\n\n DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { [weak self] in\n self?.hideTransition(for: workspace)\n }\n }\n\n private func hideTransition(for workspace: Workspace) {\n guard !windows.isEmpty else { return }\n\n NSAnimationContext.runAnimationGroup({ [weak self] context in\n context.duration = self?.settings.workspaceTransitionDuration ?? 0.3\n context.timingFunction = CAMediaTimingFunction(name: .easeIn)\n self?.windows.forEach { window in\n window.animator().alphaValue = 0.0\n }\n }, completionHandler: { [weak self] in\n self?.windows.forEach { window in\n window.orderOut(nil)\n }\n self?.windows.removeAll()\n NotificationCenter.default.post(name: .workspaceTransitionFinished, object: workspace)\n })\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/SocketClient.swift", "//\n// SocketClient.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\nimport Network\n\nfinal class SocketClient {\n static let shared = SocketClient()\n\n private let socketPath = \"/tmp/flashspace.socket\"\n private var buffer = Data()\n private let jsonEncoder = JSONEncoder()\n\n private init() {}\n\n func sendCommand(_ command: CommandRequest) {\n let connection = NWConnection(to: .unix(path: socketPath), using: .tcp)\n connection.start(queue: .main)\n\n let messageData = command.encodeSocketData()\n connection.send(content: messageData, completion: .contentProcessed { error in\n if let error {\n connection.cancel()\n FlashSpaceCLI.exit(withError: CommandError.connectionError(error))\n }\n\n self.receiveData(connection: connection)\n })\n }\n\n private func receiveData(connection: NWConnection) {\n connection.receive(minimumIncompleteLength: 1, maximumLength: 10000) { data, _, isComplete, error in\n if let error {\n connection.cancel()\n FlashSpaceCLI.exit(withError: CommandError.connectionError(error))\n }\n\n if let data { self.buffer.append(data) }\n\n // Check if the message is complete or EOF is reached\n guard isComplete || data?.last == 0 else {\n return self.receiveData(connection: connection)\n }\n\n if self.buffer.isEmpty {\n connection.cancel()\n FlashSpaceCLI.exit(withError: CommandError.emptyResponse)\n }\n\n if let response = try? self.buffer.decodeSocketData(CommandResponse.self) {\n self.handleResponse(response, connection: connection)\n } else {\n FlashSpaceCLI.exit(withError: CommandError.operationFailed(\"Could not decode the response\"))\n }\n }\n }\n\n private func handleResponse(_ response: CommandResponse, connection: NWConnection) {\n if response.success {\n response.message.flatMap { print($0) }\n connection.cancel()\n FlashSpaceCLI.exit()\n } else {\n connection.cancel()\n FlashSpaceCLI.exit(withError: CommandError.operationFailed(response.error ?? \"Operation Failed\"))\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/SpaceControl/Views/SpaceControlView.swift", "//\n// SpaceControlView.swift\n//\n// Created by Wojciech Kulik on 11/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct SpaceControlView: View {\n @Environment(\\.colorScheme) var colorScheme\n @StateObject var viewModel = SpaceControlViewModel()\n\n var body: some View {\n let columns = Array(repeating: GridItem(.flexible()), count: viewModel.numberOfColumns)\n let width = (NSScreen.main?.frame.width ?? 1200) / CGFloat(viewModel.numberOfColumns) - 70.0\n let height = (NSScreen.main?.frame.height ?? 800) / CGFloat(viewModel.numberOfRows) - 120.0\n\n LazyVGrid(columns: columns, spacing: viewModel.numberOfRows == 2 ? 90.0 : 60.0) {\n ForEach(viewModel.workspaces, id: \\.index) { workspace in\n VStack(alignment: .leading, spacing: 16.0) {\n workspaceName(workspace)\n\n Group {\n if let image = workspace.screenshotData.flatMap(NSImage.init(data:)) {\n workspacePreview(image: image, width: width, height: height)\n } else {\n workspacePlaceholder(width: width, height: height)\n }\n }\n .overlay(alignment: .topTrailing) { workspaceNumber(workspace.index + 1) }\n .overlay(\n RoundedRectangle(cornerRadius: 18.0)\n .stroke(\n workspace.isActive\n ? workspace.originalWorkspace.isOnTheCurrentScreen\n ? Color.positive\n : Color.teal\n : Color.black.opacity(0.8),\n lineWidth: 3.0\n )\n )\n .compositingGroup()\n .shadow(\n color: .black.opacity(workspace.screenshotData != nil ? 0.8 : 0.0),\n radius: 20.0,\n x: 0.0,\n y: 0.0\n )\n }\n .onTapGesture { viewModel.onWorkspaceTap(workspace) }\n }\n }\n .multilineTextAlignment(.center)\n .padding()\n .frame(maxWidth: .infinity, maxHeight: .infinity)\n }\n\n private func workspacePreview(image: NSImage, width: CGFloat, height: CGFloat) -> some View {\n Image(nsImage: image)\n .resizable()\n .scaledToFit()\n .frame(maxWidth: width, maxHeight: height)\n .aspectRatio(16.0 / 9.0, contentMode: .fit)\n .background(Color.black.opacity(0.4))\n .clipShape(RoundedRectangle(cornerRadius: 18.0))\n }\n\n private func workspacePlaceholder(width: CGFloat, height: CGFloat) -> some View {\n RoundedRectangle(cornerRadius: 18.0)\n .fill(Color.black.opacity(0.5))\n .frame(maxWidth: width, maxHeight: height)\n .aspectRatio(16.0 / 9.0, contentMode: .fit)\n .overlay {\n Text(\"Preview Not Available\")\n .font(.title)\n .foregroundColor(.white)\n .padding()\n .frame(maxWidth: .infinity, maxHeight: .infinity)\n }\n .clipped()\n }\n\n private func workspaceName(_ workspace: SpaceControlWorkspace) -> some View {\n HStack(spacing: 16.0) {\n Image(systemName: workspace.symbol)\n .resizable()\n .scaledToFit()\n .frame(height: 17.0)\n .foregroundColor(colorScheme == .dark ? .workspaceIcon : .primary)\n\n Text(workspace.name)\n .foregroundColor(.primary)\n .font(.title2)\n }\n .fontWeight(.semibold)\n .lineLimit(1)\n .compositingGroup()\n .shadow(\n color: .black.opacity(colorScheme == .dark ? 0.8 : 0.25),\n radius: 4.0,\n x: 0.0,\n y: 0.0\n )\n }\n\n private func workspaceNumber(_ number: Int) -> some View {\n Text(\"\\(number)\")\n .foregroundColor(.white)\n .font(.title3)\n .frame(width: 40.0)\n .padding(.vertical, 8.0)\n .background(Color.black)\n .cornerRadius(18.0, corners: [.topRight])\n .cornerRadius(8.0, corners: [.bottomLeft])\n }\n}\n"], ["/FlashSpace/FlashSpace/Accessibility/System.swift", "//\n// System.swift\n//\n// Created by Wojciech Kulik on 01/05/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nstruct AppWindow {\n let name: String\n let pid: pid_t\n}\n\nenum System {\n static var orderedWindows: [AppWindow] {\n let list = CGWindowListCopyWindowInfo(.optionOnScreenOnly, kCGNullWindowID) as? [[String: Any]]\n guard let list else { return [] }\n\n return list.compactMap {\n let windowName = $0[kCGWindowName as String] as? String\n let windowOwnerPID = $0[kCGWindowOwnerPID as String] as? pid_t\n if let windowOwnerPID {\n return AppWindow(name: windowName ?? \"-\", pid: windowOwnerPID)\n } else {\n return nil\n }\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/SettingsView.swift", "//\n// SettingsView.swift\n//\n// Created by Wojciech Kulik on 23/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct SettingsView: View {\n @State private var selectedTab = \"General\"\n\n var body: some View {\n NavigationSplitView(columnVisibility: .constant(.doubleColumn), sidebar: {\n sideMenu\n .frame(width: 200)\n .navigationSplitViewColumnWidth(200.0)\n }, detail: {\n details\n .frame(maxHeight: .infinity, alignment: .top)\n .navigationSplitViewColumnWidth(min: 440, ideal: 440)\n })\n .frame(width: 780, height: 490)\n }\n\n private var sideMenu: some View {\n VStack {\n List(selection: $selectedTab) {\n Label(\"General\", systemImage: \"gearshape\")\n .tag(\"General\")\n Label(\"Menu Bar\", systemImage: \"contextualmenu.and.cursorarrow\")\n .tag(\"MenuBar\")\n Label(\"Gestures\", systemImage: \"hand.draw\")\n .tag(\"Gestures\")\n Label(\"Workspaces\", systemImage: \"square.stack.3d.up\")\n .tag(\"Workspaces\")\n Label(\"Floating Apps\", systemImage: \"pip\")\n .tag(\"FloatingApps\")\n Label(\"Focus Manager\", systemImage: \"macwindow.on.rectangle\")\n .tag(\"Focus\")\n Label(\"Space Control\", systemImage: \"rectangle.split.2x2\")\n .tag(\"SpaceControl\")\n Label(\"Profiles\", systemImage: \"person.2\")\n .tag(\"Profiles\")\n Label(\"Integrations\", systemImage: \"link\")\n .tag(\"Integrations\")\n Label(\"Configuration File\", systemImage: \"doc.text\")\n .tag(\"Configuration\")\n Label(\"CLI\", systemImage: \"apple.terminal\")\n .tag(\"CLI\")\n Label(\"Acknowledgements\", systemImage: \"info.circle\")\n .tag(\"Acknowledgements\")\n Label(\"About\", systemImage: \"person\")\n .tag(\"About\")\n }\n .toolbar(removing: .sidebarToggle)\n .listStyle(.sidebar)\n\n Spacer()\n\n Text(\"FlashSpace v\\(AppConstants.version)\")\n .foregroundStyle(.secondary)\n .padding(.bottom)\n }\n }\n\n @ViewBuilder\n private var details: some View {\n switch selectedTab {\n case \"General\":\n GeneralSettingsView()\n case \"MenuBar\":\n MenuBarSettingsView()\n case \"Focus\":\n FocusSettingsView()\n case \"Gestures\":\n GesturesSettingsView()\n case \"Workspaces\":\n WorkspacesSettingsView()\n case \"FloatingApps\":\n FloatingAppsSettingsView()\n case \"SpaceControl\":\n SpaceControlSettingsView()\n case \"Integrations\":\n IntegrationsSettingsView()\n case \"Profiles\":\n ProfilesSettingsView()\n case \"Configuration\":\n ConfigurationFileSettingsView()\n case \"CLI\":\n CLISettingsView()\n case \"Acknowledgements\":\n AcknowledgementsSettingsView()\n case \"About\":\n AboutSettingsView()\n default:\n EmptyView()\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Config/ConfigSerializer.swift", "//\n// ConfigSerializer.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\nimport TOMLKit\nimport Yams\n\nenum ConfigSerializer {\n static let configDirectory = FileManager.default\n .homeDirectoryForCurrentUser\n .appendingPathComponent(\".config/flashspace\")\n\n private(set) static var format: ConfigFormat = detectFormat()\n\n static func serialize(filename: String, _ value: some Encodable) throws {\n let url = getUrl(for: filename)\n let data = try encoder.encode(value)\n try? url.createIntermediateDirectories()\n try data.write(to: url)\n }\n\n static func deserialize(_ type: T.Type, filename: String) throws -> T? where T: Decodable {\n let url = getUrl(for: filename)\n\n guard FileManager.default.fileExists(atPath: url.path) else { return nil }\n\n do {\n let data = try Data(contentsOf: url)\n\n return try decoder.decode(type, from: data)\n } catch {\n Logger.log(\"Failed to deserialize \\(filename): \\(error)\")\n throw error\n }\n }\n\n static func convert(to: ConfigFormat) throws {\n guard format != to else { return }\n\n let settingsUrl = getUrl(for: \"settings\", ext: format.rawValue)\n let profilesUrl = getUrl(for: \"profiles\", ext: format.rawValue)\n let timestamp = Int(Date().timeIntervalSince1970)\n\n try? FileManager.default.moveItem(\n at: settingsUrl,\n to: configDirectory.appendingPathComponent(\"settings-backup-\\(timestamp).\\(format.rawValue)\")\n )\n try? FileManager.default.moveItem(\n at: profilesUrl,\n to: configDirectory.appendingPathComponent(\"profiles-backup-\\(timestamp).\\(format.rawValue)\")\n )\n\n format = to\n AppDependencies.shared.settingsRepository.saveToDisk()\n AppDependencies.shared.profilesRepository.saveToDisk()\n\n Logger.log(\"Converted config format to \\(to.displayName)\")\n }\n}\n\nprivate extension ConfigSerializer {\n static var encoder: ConfigEncoder {\n switch format {\n case .json: return jsonEncoder\n case .toml: return tomlEncoder\n case .yaml: return yamlEncoder\n }\n }\n\n static var decoder: ConfigDecoder {\n switch format {\n case .json: return jsonDecoder\n case .toml: return tomlDecoder\n case .yaml: return yamlDecoder\n }\n }\n\n static let jsonDecoder = JSONDecoder()\n static let jsonEncoder = {\n let encoder = JSONEncoder()\n encoder.outputFormatting = [\n .prettyPrinted,\n .withoutEscapingSlashes,\n .sortedKeys\n ]\n return encoder\n }()\n\n static let tomlDecoder = TOMLDecoder()\n static let tomlEncoder = TOMLEncoder()\n static let yamlEncoder = YAMLEncoder()\n static let yamlDecoder = YAMLDecoder()\n\n static func getUrl(for filename: String, ext: String? = nil) -> URL {\n configDirectory\n .appendingPathComponent(filename)\n .appendingPathExtension(ext ?? ConfigSerializer.format.extensionName)\n }\n\n static func detectFormat() -> ConfigFormat {\n for format in ConfigFormat.allCases {\n let url = getUrl(for: \"profiles\", ext: format.rawValue)\n if FileManager.default.fileExists(atPath: url.path) {\n Logger.log(\"Detected config format \\(format.displayName) at \\(url.path)\")\n return format\n }\n }\n\n return .json\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/MenuBar/MenuBarSettingsView.swift", "//\n// MenuBarSettingsView.swift\n//\n// Created by Wojciech Kulik on 31/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct MenuBarSettingsView: View {\n @StateObject var settings = AppDependencies.shared.menuBarSettings\n\n var body: some View {\n Form {\n Section {\n Toggle(\"Show Title\", isOn: $settings.showMenuBarTitle)\n Toggle(\"Show Icon\", isOn: $settings.showMenuBarIcon)\n .disabled(!settings.showMenuBarTitle)\n\n HStack {\n Text(\"Title Template\")\n TextField(\"\", text: $settings.menuBarTitleTemplate)\n .foregroundColor(.secondary)\n .standardPlaceholder(settings.menuBarTitleTemplate.isEmpty)\n }\n .disabled(!settings.showMenuBarTitle)\n .opacity(settings.showMenuBarTitle ? 1 : 0.5)\n\n Text(\n \"\"\"\n $WORKSPACE will be replaced with the active workspace name\n $WORKSPACE_NUMBER will be replaced with the active workspace number\n $DISPLAY will be replaced with the corresponding display name\n $PROFILE will be replaced with the active profile name\n \"\"\"\n )\n .foregroundStyle(.secondary)\n .font(.callout)\n .opacity(settings.showMenuBarTitle ? 1 : 0.5)\n }\n\n Section {\n HStack {\n Text(\"Display Aliases\")\n TextField(\"\", text: $settings.menuBarDisplayAliases)\n .foregroundColor(.secondary)\n .standardPlaceholder(settings.menuBarDisplayAliases.isEmpty)\n }\n .disabled(!settings.showMenuBarTitle)\n .opacity(settings.showMenuBarTitle ? 1 : 0.5)\n\n Text(\"Example: DELL U2723QE=Secondary;Built-in Retina Display=Main\")\n .foregroundStyle(.secondary)\n .font(.callout)\n .opacity(settings.showMenuBarTitle ? 1 : 0.5)\n }\n }\n .formStyle(.grouped)\n .navigationTitle(\"Menu Bar\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/Bundle.swift", "//\n// Bundle.swift\n//\n// Created by Wojciech Kulik on 26/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nextension Bundle {\n var localizedAppName: String {\n localizedInfoDictionary?[\"CFBundleDisplayName\"] as? String\n ?? infoDictionary?[\"CFBundleDisplayName\"] as? String\n ?? infoDictionary?[\"CFBundleName\"] as? String\n ?? bundleURL.fileName\n }\n\n var isAgent: Bool {\n infoDictionary?[\"LSUIElement\"] as? String == \"1\" ||\n infoDictionary?[\"LSUIElement\"] as? Bool == true\n }\n\n var iconPath: String {\n let iconFile = infoDictionary?[\"CFBundleIconFile\"] as? String\n ?? infoDictionary?[\"CFBundleIconName\"] as? String\n ?? \"AppIcon\"\n\n return bundleURL\n .appendingPathComponent(\"Contents\")\n .appendingPathComponent(\"Resources\")\n .appendingPathComponent(iconFile.hasSuffix(\".icns\") ? iconFile : \"\\(iconFile).icns\")\n .path(percentEncoded: false)\n }\n}\n"], ["/FlashSpace/FlashSpace/App/AppConstants.swift", "//\n// AppConstants.swift\n//\n// Created by Wojciech Kulik on 23/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nenum AppConstants {\n enum UserDefaultsKey {\n static let selectedProfileId = \"selectedProfileId\"\n }\n\n static let lastFocusedOption = MacApp(\n name: \"(Last Focused)\",\n bundleIdentifier: \"flashspace.last-focused\",\n iconPath: nil\n )\n\n static var version: String {\n guard let version = Bundle.main.infoDictionary?[\"CFBundleShortVersionString\"] as? String else {\n return \"Unknown\"\n }\n\n #if DEBUG\n return version + \" (debug)\"\n #else\n return version\n #endif\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/General/GeneralSettings.swift", "//\n// GeneralSettings.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nfinal class GeneralSettings: ObservableObject {\n @Published var showFlashSpace: AppHotKey?\n @Published var showFloatingNotifications = true\n @Published var checkForUpdatesAutomatically = false {\n didSet { UpdatesManager.shared.autoCheckForUpdates = checkForUpdatesAutomatically }\n }\n\n private var observer: AnyCancellable?\n private let updateSubject = PassthroughSubject<(), Never>()\n\n init() { observe() }\n\n private func observe() {\n observer = Publishers.MergeMany(\n $showFlashSpace.settingsPublisher(),\n $checkForUpdatesAutomatically.settingsPublisher(),\n $showFloatingNotifications.settingsPublisher()\n )\n .receive(on: DispatchQueue.main)\n .sink { [weak self] in self?.updateSubject.send() }\n }\n}\n\nextension GeneralSettings: SettingsProtocol {\n var updatePublisher: AnyPublisher<(), Never> {\n updateSubject.eraseToAnyPublisher()\n }\n\n func load(from appSettings: AppSettings) {\n observer = nil\n showFlashSpace = appSettings.showFlashSpace\n checkForUpdatesAutomatically = appSettings.checkForUpdatesAutomatically ?? false\n showFloatingNotifications = appSettings.showFloatingNotifications ?? true\n observe()\n }\n\n func update(_ appSettings: inout AppSettings) {\n appSettings.showFlashSpace = showFlashSpace\n appSettings.checkForUpdatesAutomatically = checkForUpdatesAutomatically\n appSettings.showFloatingNotifications = showFloatingNotifications\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/FocusManager/FocusManagerSettings.swift", "//\n// FocusManagerSettings.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nfinal class FocusManagerSettings: ObservableObject {\n @Published var enableFocusManagement = false\n @Published var centerCursorOnFocusChange = false\n\n @Published var focusLeft: AppHotKey?\n @Published var focusRight: AppHotKey?\n @Published var focusUp: AppHotKey?\n @Published var focusDown: AppHotKey?\n @Published var focusNextWorkspaceApp: AppHotKey?\n @Published var focusPreviousWorkspaceApp: AppHotKey?\n @Published var focusNextWorkspaceWindow: AppHotKey?\n @Published var focusPreviousWorkspaceWindow: AppHotKey?\n @Published var focusFrontmostWindow = false\n\n private var observer: AnyCancellable?\n private let updateSubject = PassthroughSubject<(), Never>()\n\n init() { observe() }\n\n private func observe() {\n observer = Publishers.MergeMany(\n $enableFocusManagement.settingsPublisher(),\n $centerCursorOnFocusChange.settingsPublisher(),\n $focusLeft.settingsPublisher(),\n $focusRight.settingsPublisher(),\n $focusUp.settingsPublisher(),\n $focusDown.settingsPublisher(),\n $focusNextWorkspaceApp.settingsPublisher(),\n $focusPreviousWorkspaceApp.settingsPublisher(),\n $focusNextWorkspaceWindow.settingsPublisher(),\n $focusPreviousWorkspaceWindow.settingsPublisher(),\n $focusFrontmostWindow.settingsPublisher()\n )\n .receive(on: DispatchQueue.main)\n .sink { [weak self] in self?.updateSubject.send() }\n }\n}\n\nextension FocusManagerSettings: SettingsProtocol {\n var updatePublisher: AnyPublisher<(), Never> {\n updateSubject.eraseToAnyPublisher()\n }\n\n func load(from appSettings: AppSettings) {\n observer = nil\n enableFocusManagement = appSettings.enableFocusManagement ?? false\n centerCursorOnFocusChange = appSettings.centerCursorOnFocusChange ?? false\n focusLeft = appSettings.focusLeft\n focusRight = appSettings.focusRight\n focusUp = appSettings.focusUp\n focusDown = appSettings.focusDown\n focusNextWorkspaceApp = appSettings.focusNextWorkspaceApp\n focusPreviousWorkspaceApp = appSettings.focusPreviousWorkspaceApp\n focusNextWorkspaceWindow = appSettings.focusNextWorkspaceWindow\n focusPreviousWorkspaceWindow = appSettings.focusPreviousWorkspaceWindow\n focusFrontmostWindow = appSettings.focusFrontmostWindow ?? false\n observe()\n }\n\n func update(_ appSettings: inout AppSettings) {\n appSettings.enableFocusManagement = enableFocusManagement\n appSettings.centerCursorOnFocusChange = centerCursorOnFocusChange\n appSettings.focusLeft = focusLeft\n appSettings.focusRight = focusRight\n appSettings.focusUp = focusUp\n appSettings.focusDown = focusDown\n appSettings.focusNextWorkspaceApp = focusNextWorkspaceApp\n appSettings.focusPreviousWorkspaceApp = focusPreviousWorkspaceApp\n appSettings.focusNextWorkspaceWindow = focusNextWorkspaceWindow\n appSettings.focusPreviousWorkspaceWindow = focusPreviousWorkspaceWindow\n appSettings.focusFrontmostWindow = focusFrontmostWindow\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/SpaceControl/SpaceControlSettings.swift", "//\n// SpaceControlSettings.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nfinal class SpaceControlSettings: ObservableObject {\n @Published var enableSpaceControl = false\n @Published var showSpaceControl: AppHotKey?\n @Published var enableSpaceControlAnimations = true\n @Published var spaceControlCurrentDisplayWorkspaces = false\n @Published var spaceControlMaxColumns = 6\n\n private var observer: AnyCancellable?\n private let updateSubject = PassthroughSubject<(), Never>()\n\n init() { observe() }\n\n private func observe() {\n observer = Publishers.MergeMany(\n $enableSpaceControl.settingsPublisher(),\n $showSpaceControl.settingsPublisher(),\n $enableSpaceControlAnimations.settingsPublisher(),\n $spaceControlCurrentDisplayWorkspaces.settingsPublisher(),\n $spaceControlMaxColumns.settingsPublisher(debounce: true)\n )\n .receive(on: DispatchQueue.main)\n .sink { [weak self] in self?.updateSubject.send() }\n }\n}\n\nextension SpaceControlSettings: SettingsProtocol {\n var updatePublisher: AnyPublisher<(), Never> {\n updateSubject.eraseToAnyPublisher()\n }\n\n func load(from appSettings: AppSettings) {\n observer = nil\n enableSpaceControl = appSettings.enableSpaceControl ?? false\n showSpaceControl = appSettings.showSpaceControl\n enableSpaceControlAnimations = appSettings.enableSpaceControlAnimations ?? true\n spaceControlCurrentDisplayWorkspaces = appSettings.spaceControlCurrentDisplayWorkspaces ?? false\n spaceControlMaxColumns = appSettings.spaceControlMaxColumns ?? 6\n observe()\n }\n\n func update(_ appSettings: inout AppSettings) {\n appSettings.enableSpaceControl = enableSpaceControl\n appSettings.showSpaceControl = showSpaceControl\n appSettings.enableSpaceControlAnimations = enableSpaceControlAnimations\n appSettings.spaceControlCurrentDisplayWorkspaces = spaceControlCurrentDisplayWorkspaces\n appSettings.spaceControlMaxColumns = spaceControlMaxColumns\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/MenuBar/MenuBarSettings.swift", "//\n// MenuBarSettings.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nfinal class MenuBarSettings: ObservableObject {\n static let defaultMenuBarTitleTemplate = \"$WORKSPACE\"\n\n @Published var showMenuBarTitle = true\n @Published var showMenuBarIcon = true\n @Published var menuBarTitleTemplate = MenuBarSettings.defaultMenuBarTitleTemplate\n @Published var menuBarDisplayAliases = \"\"\n\n private var observer: AnyCancellable?\n private let updateSubject = PassthroughSubject<(), Never>()\n\n init() { observe() }\n\n private func observe() {\n observer = Publishers.MergeMany(\n $showMenuBarTitle.settingsPublisher(),\n $showMenuBarIcon.settingsPublisher(),\n $menuBarTitleTemplate.settingsPublisher(debounce: true),\n $menuBarDisplayAliases.settingsPublisher(debounce: true)\n )\n .receive(on: DispatchQueue.main)\n .sink { [weak self] in self?.updateSubject.send() }\n }\n}\n\nextension MenuBarSettings: SettingsProtocol {\n var updatePublisher: AnyPublisher<(), Never> {\n updateSubject.eraseToAnyPublisher()\n }\n\n func load(from appSettings: AppSettings) {\n observer = nil\n showMenuBarTitle = appSettings.showMenuBarTitle ?? true\n showMenuBarIcon = appSettings.showMenuBarIcon ?? true\n menuBarTitleTemplate = appSettings.menuBarTitleTemplate ?? Self.defaultMenuBarTitleTemplate\n menuBarDisplayAliases = appSettings.menuBarDisplayAliases ?? \"\"\n observe()\n }\n\n func update(_ appSettings: inout AppSettings) {\n appSettings.showMenuBarTitle = showMenuBarTitle\n appSettings.showMenuBarIcon = showMenuBarIcon\n appSettings.menuBarTitleTemplate = menuBarTitleTemplate\n appSettings.menuBarDisplayAliases = menuBarDisplayAliases\n }\n}\n"], ["/FlashSpace/FlashSpace/UI/InputDialog.swift", "//\n// InputDialog.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct InputDialog: View {\n let title: String\n var placeholder = \"Type here...\"\n\n @Binding var userInput: String\n @Binding var isPresented: Bool\n\n var body: some View {\n VStack(alignment: .leading, spacing: 4.0) {\n Text(title)\n .font(.headline)\n\n TextField(placeholder, text: $userInput)\n .textFieldStyle(RoundedBorderTextFieldStyle())\n .padding(.vertical, 8.0)\n .onSubmit { isPresented = false }\n\n HStack {\n Spacer()\n Button(\"Cancel\") {\n userInput = \"\"\n isPresented = false\n }\n Button(\"OK\") { isPresented = false }\n }\n }\n .padding()\n .frame(width: 300, height: 110)\n .onKeyPress(.escape) {\n userInput = \"\"\n isPresented = false\n return .handled\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/HotKeys/Extensions/AppHotKey+Shortcut.swift", "//\n// AppHotKey+Shortcut.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ShortcutRecorder\n\nextension [(AppHotKey, () -> ())] {\n func toShortcutPairs() -> [(Shortcut, () -> ())] {\n map { ($0.0.toShortcut(), $0.1) }\n .compactMap {\n guard let shortcut = $0.0 else { return nil }\n return (shortcut, $0.1)\n }\n }\n}\n\nextension AppHotKey {\n func toShortcut() -> Shortcut? {\n let components = value.components(separatedBy: \"+\")\n let modifiers = KeyModifiersMap.toModifiers(value)\n\n guard let keyEquivalent = components.last,\n let rawKeyCode = KeyCodesMap[keyEquivalent],\n let keyCode = KeyCode(rawValue: rawKeyCode) else { return nil }\n\n return Shortcut(\n code: keyCode,\n modifierFlags: NSEvent.ModifierFlags(rawValue: modifiers),\n characters: nil,\n charactersIgnoringModifiers: nil\n )\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/NSScreen.swift", "//\n// NSScreen.swift\n//\n// Created by Wojciech Kulik on 18/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension NSScreen {\n /// Returns the screen's frame where (x,y) is top-left corner relative\n /// to the main screen's top-left corner.\n var normalizedFrame: CGRect {\n let mainScreen = NSScreen.screens[0]\n return NSRect(\n x: frame.origin.x,\n y: mainScreen.frame.height - frame.origin.y - frame.height,\n width: frame.width,\n height: frame.height\n )\n }\n\n static func isConnected(_ display: DisplayName) -> Bool {\n NSScreen.screens.contains { $0.localizedName == display }\n }\n\n static func screen(_ display: DisplayName?) -> NSScreen? {\n NSScreen.screens.first { $0.localizedName == display }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/SettingsRepository.swift", "//\n// SettingsRepository.swift\n//\n// Created by Wojciech Kulik on 23/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nfinal class SettingsRepository: ObservableObject {\n private(set) var generalSettings: GeneralSettings\n private(set) var menuBarSettings: MenuBarSettings\n private(set) var gesturesSettings: GesturesSettings\n private(set) var focusManagerSettings: FocusManagerSettings\n private(set) var workspaceSettings: WorkspaceSettings\n private(set) var floatingAppsSettings: FloatingAppsSettings\n private(set) var spaceControlSettings: SpaceControlSettings\n private(set) var integrationsSettings: IntegrationsSettings\n\n private lazy var allSettings: [SettingsProtocol] = [\n generalSettings,\n menuBarSettings,\n gesturesSettings,\n focusManagerSettings,\n workspaceSettings,\n floatingAppsSettings,\n spaceControlSettings,\n integrationsSettings\n ]\n\n private var currentSettings = AppSettings()\n private var cancellables = Set()\n private var shouldUpdate = false\n\n init(\n generalSettings: GeneralSettings,\n menuBarSettings: MenuBarSettings,\n gesturesSettings: GesturesSettings,\n focusManagerSettings: FocusManagerSettings,\n workspaceSettings: WorkspaceSettings,\n floatingAppsSettings: FloatingAppsSettings,\n spaceControlSettings: SpaceControlSettings,\n integrationsSettings: IntegrationsSettings\n ) {\n self.generalSettings = generalSettings\n self.menuBarSettings = menuBarSettings\n self.gesturesSettings = gesturesSettings\n self.focusManagerSettings = focusManagerSettings\n self.workspaceSettings = workspaceSettings\n self.floatingAppsSettings = floatingAppsSettings\n self.spaceControlSettings = spaceControlSettings\n self.integrationsSettings = integrationsSettings\n\n loadFromDisk()\n\n Publishers.MergeMany(allSettings.map(\\.updatePublisher))\n .sink { [weak self] in self?.updateSettings() }\n .store(in: &cancellables)\n }\n\n func saveToDisk() {\n Logger.log(\"Saving settings to disk\")\n try? ConfigSerializer.serialize(filename: \"settings\", currentSettings)\n }\n\n private func updateSettings() {\n guard shouldUpdate else { return }\n\n var settings = AppSettings()\n allSettings.forEach { $0.update(&settings) }\n currentSettings = settings\n saveToDisk()\n\n AppDependencies.shared.hotKeysManager.refresh()\n objectWillChange.send()\n }\n\n private func loadFromDisk() {\n Logger.log(\"Loading settings from disk\")\n\n shouldUpdate = false\n defer { shouldUpdate = true }\n\n guard let settings = try? ConfigSerializer.deserialize(\n AppSettings.self,\n filename: \"settings\"\n ) else { return }\n\n currentSettings = settings\n allSettings.forEach { $0.load(from: settings) }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/PictureInPicture/Models/PipBrowser.swift", "//\n// PipBrowser.swift\n//\n// Created by Wojciech Kulik on 12/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\n/// Browser apps that support Picture in Picture\nenum PipBrowser: String, CaseIterable {\n case chrome = \"com.google.Chrome\"\n case vivaldi = \"com.vivaldi.Vivaldi\"\n case brave = \"com.brave.Browser\"\n case opera = \"com.operasoftware.Opera\"\n case firefox = \"org.mozilla.firefox\"\n case zen = \"app.zen-browser.zen\"\n case arc = \"company.thebrowser.Browser\"\n case dia = \"company.thebrowser.dia\"\n case comet = \"ai.perplexity.comet\"\n\n var bundleId: String { rawValue }\n\n var title: String? {\n switch self {\n case .chrome, .vivaldi, .brave, .opera, .comet:\n return \"Picture in Picture\"\n case .zen, .firefox:\n return \"Picture-in-Picture\"\n case .arc, .dia:\n return nil\n }\n }\n\n var partialTitle: String? {\n switch self {\n case .chrome:\n return \"about:blank \"\n default:\n return nil\n }\n }\n\n var subrole: String? {\n switch self {\n case .arc, .dia:\n return (NSAccessibility.Subrole.systemDialog as CFString) as String\n default:\n return nil\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/UI/Toast.swift", "//\n// Toast.swift\n//\n// Created by Wojciech Kulik on 28/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport SwiftUI\n\nenum Toast {\n weak static var toastWindow: NSWindow?\n\n static func showWith(icon: String, message: String, textColor: Color) {\n guard AppDependencies.shared.generalSettings.showFloatingNotifications else { return }\n\n if let window = toastWindow {\n window.orderOut(nil)\n toastWindow = nil\n }\n\n let contentView = NSHostingView(\n rootView: ToastView(\n icon: icon,\n message: message,\n textColor: textColor\n )\n )\n let size = contentView.fittingSize\n\n // contentRect is in screen coordinates where (0,0) is bottom-left corner\n // and it is relative to the main screen.\n let window = NSWindow(\n contentRect: NSRect(\n x: (NSScreen.main?.frame.midX ?? 200.0) - size.width / 2.0,\n y: (NSScreen.main?.frame.minY ?? 0.0) + (NSScreen.main?.frame.height ?? 0.0) * 0.07,\n width: size.width,\n height: size.height\n ),\n styleMask: [.borderless],\n backing: .buffered,\n defer: false\n )\n window.isOpaque = false\n window.backgroundColor = .clear\n window.level = .screenSaver\n toastWindow = window\n\n let visualEffectView = contentView.addVisualEffect(material: .sidebar, border: true)\n window.contentView = visualEffectView\n window.orderFrontRegardless()\n\n DispatchQueue.main.asyncAfter(deadline: .now() + 2.0) {\n NSAnimationContext.runAnimationGroup({ context in\n context.duration = 0.3\n window.animator().alphaValue = 0.0\n }, completionHandler: {\n window.orderOut(nil)\n })\n }\n }\n}\n\nstruct ToastView: View {\n let icon: String\n let message: String\n let textColor: Color\n\n var body: some View {\n HStack {\n Image(systemName: icon)\n .resizable()\n .scaledToFit()\n .frame(width: 26)\n\n Text(message)\n .font(.title)\n }\n .opacity(0.9)\n .padding()\n .padding(.horizontal)\n .fontWeight(.semibold)\n .foregroundStyle(textColor)\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/URL.swift", "//\n// URL.swift\n//\n// Created by Wojciech Kulik on 26/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nextension URL {\n var bundle: Bundle? { Bundle(url: self) }\n var fileName: String { lastPathComponent.replacingOccurrences(of: \".app\", with: \"\") }\n var appName: String { bundle?.localizedAppName ?? fileName }\n var bundleIdentifier: BundleId? { bundle?.bundleIdentifier }\n var iconPath: String? { bundle?.iconPath }\n\n func createIntermediateDirectories() throws {\n try FileManager.default.createDirectory(\n at: deletingLastPathComponent(),\n withIntermediateDirectories: true\n )\n }\n}\n"], ["/FlashSpace/FlashSpace/App/Migrations.swift", "//\n// Migrations.swift\n//\n// Created by Wojciech Kulik on 08/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nenum Migrations {\n static var appsMigrated = false\n static var hotKeysMigrated = false\n\n static func migrateIfNeeded(\n settingsRepository: SettingsRepository,\n profilesRepository: ProfilesRepository\n ) {\n if Migrations.appsMigrated {\n Logger.log(\"Migrated apps\")\n\n let workspacesJsonUrl = FileManager.default\n .homeDirectoryForCurrentUser\n .appendingPathComponent(\".config/flashspace/workspaces.json\")\n try? FileManager.default.moveItem(\n at: workspacesJsonUrl,\n to: workspacesJsonUrl.deletingLastPathComponent()\n .appendingPathComponent(\"workspaces.json.bak\")\n )\n\n settingsRepository.saveToDisk()\n profilesRepository.saveToDisk()\n } else if Migrations.hotKeysMigrated {\n Logger.log(\"Migrated hot keys\")\n settingsRepository.saveToDisk()\n profilesRepository.saveToDisk()\n }\n\n Migrations.appsMigrated = false\n Migrations.hotKeysMigrated = false\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/SpaceControl/Views/SpaceControlWindow.swift", "//\n// SpaceControlWindow.swift\n//\n// Created by Wojciech Kulik on 11/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport SwiftUI\n\nfinal class SpaceControlWindow: NSWindow, NSWindowDelegate {\n override var canBecomeKey: Bool { true }\n\n override func keyDown(with event: NSEvent) {\n if event.keyCode == KeyCodesMap[\"escape\"] {\n SpaceControl.hide(restoreFocus: true)\n return\n } else if [\"up\", \"down\", \"right\", \"left\"]\n .compactMap({ KeyCodesMap[$0] })\n .contains(event.keyCode) {\n NotificationCenter.default.post(name: .spaceControlArrowDown, object: event.keyCode)\n return\n }\n\n let settings = AppDependencies.shared.spaceControlSettings\n let workspaceManager = AppDependencies.shared.workspaceManager\n var workspaces = AppDependencies.shared.workspaceRepository.workspaces\n\n if settings.spaceControlCurrentDisplayWorkspaces {\n workspaces = workspaces.filter(\\.isOnTheCurrentScreen)\n }\n\n var digit = Int(event.charactersIgnoringModifiers ?? \"\") ?? -1\n if (0...9).contains(digit) {\n SpaceControl.hide()\n digit = digit == 0 ? 10 : digit\n\n if let workspace = workspaces[safe: digit - 1] {\n workspaceManager.activateWorkspace(workspace, setFocus: true)\n }\n return\n }\n\n super.keyDown(with: event)\n }\n\n override func resignFirstResponder() -> Bool {\n SpaceControl.hide()\n return super.resignFirstResponder()\n }\n\n func windowDidResignKey(_ notification: Notification) {\n SpaceControl.hide()\n }\n}\n"], ["/FlashSpace/FlashSpace/App/AppDelegate.swift", "//\n// AppDelegate.swift\n//\n// Created by Wojciech Kulik on 13/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Combine\nimport SwiftUI\n\nfinal class AppDelegate: NSObject, NSApplicationDelegate {\n @Environment(\\.openWindow) private var openWindow\n @Environment(\\.dismissWindow) private var dismissWindow\n\n private var cancellables = Set()\n\n func applicationDidFinishLaunching(_ notification: Notification) {\n AppDependencies.shared.hotKeysManager.enableAll()\n\n NotificationCenter.default\n .publisher(for: .openMainWindow)\n .sink { [weak self] _ in\n self?.openWindow(id: \"main\")\n NSApp.activate(ignoringOtherApps: true)\n }\n .store(in: &cancellables)\n\n #if DEBUG\n dismissWindow(id: \"main\")\n #endif\n }\n\n func applicationWillTerminate(_ notification: Notification) {\n AppDependencies.shared.pictureInPictureManager.restoreAllWindows()\n }\n}\n"], ["/FlashSpace/FlashSpace/Accessibility/AXUIElement+Properties.swift", "//\n// AXUIElement+Properties.swift\n//\n// Created by Wojciech Kulik on 24/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension AXUIElement {\n var id: String? { getAttribute(.identifier) }\n var title: String? { getAttribute(.title) }\n var isMain: Bool { getAttribute(.main) == true }\n var isMinimized: Bool { getAttribute(.minimized) == true }\n var role: String? { getAttribute(.role) }\n var subrole: String? { getAttribute(.subrole) }\n var enhancedUserInterface: Bool {\n get { getAttribute(.enchancedUserInterface) == true }\n set { setAttribute(.enchancedUserInterface, value: newValue) }\n }\n\n var processId: pid_t? {\n var pid: pid_t = 0\n AXUIElementGetPid(self, &pid)\n return pid\n }\n\n /// Frame is in window coordinates where (0,0) is top-left corner\n /// and it is relative to the main screen.\n var frame: CGRect? {\n var positionValue: CFTypeRef?\n var sizeValue: CFTypeRef?\n\n guard AXUIElementCopyAttributeValue(\n self,\n NSAccessibility.Attribute.position as CFString,\n &positionValue\n ) == .success else { return nil }\n\n guard AXUIElementCopyAttributeValue(\n self,\n NSAccessibility.Attribute.size as CFString,\n &sizeValue\n ) == .success else { return nil }\n\n var windowBounds: CGRect = .zero\n\n // swiftlint:disable force_cast\n if let position = positionValue, AXValueGetType(position as! AXValue) == .cgPoint {\n AXValueGetValue(position as! AXValue, .cgPoint, &windowBounds.origin)\n }\n\n if let size = sizeValue, AXValueGetType(size as! AXValue) == .cgSize {\n AXValueGetValue(size as! AXValue, .cgSize, &windowBounds.size)\n }\n // swiftlint:enable force_cast\n\n return windowBounds.isEmpty ? nil : windowBounds\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/About/AboutSettingsView.swift", "//\n// AboutSettingsView.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct AboutSettingsView: View {\n var body: some View {\n Form {\n Section(\"FlashSpace\") {\n HStack {\n Text(\"Version \\(AppConstants.version)\")\n Spacer()\n Button(\"GitHub\") { openGitHub(\"wojciech-kulik/FlashSpace\") }\n Button(\"Check for Updates\") { UpdatesManager.shared.checkForUpdates() }\n }\n }\n\n Section(\"Author\") {\n HStack {\n Text(\"Wojciech Kulik (@wojciech-kulik)\")\n Spacer()\n Button(\"GitHub\") { openGitHub(\"wojciech-kulik\") }\n Button(\"X.com\") { openUrl(\"https://x.com/kulik_wojciech\") }\n Button(\"snippety.app\") { openUrl(\"https://snippety.app\") }\n }\n }\n\n Section(\"Contributors\") {\n HStack {\n Text(\"Kwangmin Bae / Shirou (@PangMo5)\")\n Spacer()\n Button(\"GitHub\") { openGitHub(\"PangMo5\") }\n }\n HStack {\n Text(\"Sergio (@sergiopatino)\")\n Spacer()\n Button(\"GitHub\") { openGitHub(\"sergiopatino\") }\n }\n HStack {\n Text(\"Moritz Brödel (@brodmo)\")\n Spacer()\n Button(\"GitHub\") { openGitHub(\"brodmo\") }\n }\n }\n }\n .buttonStyle(.accessoryBarAction)\n .formStyle(.grouped)\n .navigationTitle(\"About\")\n }\n\n private func openGitHub(_ login: String) {\n openUrl(\"https://github.com/\\(login)\")\n }\n\n private func openUrl(_ url: String) {\n if let url = URL(string: url) {\n NSWorkspace.shared.open(url)\n }\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Models/CommandRequest.swift", "//\n// CommandRequest.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nenum CommandRequest: Codable {\n case createWorkspace(CreateWorkspaceRequest)\n case deleteWorkspace(name: String)\n case updateWorkspace(UpdateWorkspaceRequest)\n case activateWorkspace(name: String?, number: Int?, clean: Bool)\n case nextWorkspace(skipEmpty: Bool, clean: Bool, loop: Bool)\n case previousWorkspace(skipEmpty: Bool, clean: Bool, loop: Bool)\n case hideUnassignedApps\n case recentWorkspace(clean: Bool)\n\n case assignVisibleApps(workspaceName: String?, showNotification: Bool)\n case assignApp(app: String?, workspaceName: String?, activate: Bool?, showNotification: Bool)\n case unassignApp(app: String?, showNotification: Bool)\n\n case floatApp(app: String?, showNotification: Bool)\n case unfloatApp(app: String?, showNotification: Bool)\n case toggleFloatApp(app: String?, showNotification: Bool)\n\n case focusWindow(direction: FocusDirection)\n case focusNextWindow\n case focusPreviousWindow\n case focusNextApp\n case focusPreviousApp\n\n case createProfile(name: String, copy: Bool, activate: Bool)\n case deleteProfile(name: String)\n case activateProfile(name: String)\n\n case openSpaceControl\n\n case listProfiles\n case listWorkspaces(withDisplay: Bool, profile: String?)\n case listApps(\n workspace: String,\n profile: String?,\n withBundleId: Bool,\n withIcon: Bool,\n onlyRunning: Bool\n )\n case listFloatingApps(withBundleId: Bool)\n\n case getProfile\n case getWorkspace(display: String?)\n case getApp(withWindowsCount: Bool)\n case getDisplay\n}\n\nenum FocusDirection: String, Codable, ExpressibleByArgument, CaseIterable {\n case left, right, up, down\n}\n"], ["/FlashSpace/FlashSpace/Utils/FileChooser.swift", "//\n// FileChooser.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\nimport UniformTypeIdentifiers\n\nfinal class FileChooser {\n func runModalOpenPanel(allowedFileTypes: [UTType]?, directoryURL: URL?) -> URL? {\n let openPanel = NSOpenPanel()\n openPanel.canChooseFiles = true\n openPanel.allowedContentTypes = allowedFileTypes ?? []\n openPanel.directoryURL = directoryURL\n\n return openPanel.runModal() == .OK ? openPanel.url : nil\n }\n\n func runModalSavePanel(allowedFileTypes: [UTType]?, defaultFileName: String?) -> URL? {\n let savePanel = NSSavePanel()\n savePanel.allowsOtherFileTypes = false\n savePanel.canCreateDirectories = true\n savePanel.allowedContentTypes = allowedFileTypes ?? []\n savePanel.nameFieldStringValue = defaultFileName ?? \"\"\n\n return savePanel.runModal() == .OK ? savePanel.url : nil\n }\n\n @MainActor\n func runSheetModalOpenPanel(window: NSWindow, allowedFileTypes: [UTType]?, directoryURL: URL?) async -> URL? {\n let openPanel = NSOpenPanel()\n openPanel.canChooseFiles = true\n openPanel.allowedContentTypes = allowedFileTypes ?? []\n openPanel.directoryURL = directoryURL\n\n return await openPanel.beginSheetModal(for: window) == .OK ? openPanel.url : nil\n }\n\n @MainActor\n func runSheetModalSavePanel(window: NSWindow, allowedFileTypes: [UTType]?, defaultFileName: String?) async -> URL? {\n let savePanel = NSSavePanel()\n savePanel.allowsOtherFileTypes = false\n savePanel.canCreateDirectories = true\n savePanel.allowedContentTypes = allowedFileTypes ?? []\n savePanel.nameFieldStringValue = defaultFileName ?? \"\"\n\n return await savePanel.beginSheetModal(for: window) == .OK ? savePanel.url : nil\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Models/CommandRequest.swift", "//\n// CommandRequest.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nenum CommandRequest: Codable {\n case createWorkspace(CreateWorkspaceRequest)\n case deleteWorkspace(name: String)\n case updateWorkspace(UpdateWorkspaceRequest)\n case activateWorkspace(name: String?, number: Int?, clean: Bool)\n case nextWorkspace(skipEmpty: Bool, clean: Bool, loop: Bool)\n case previousWorkspace(skipEmpty: Bool, clean: Bool, loop: Bool)\n case recentWorkspace(clean: Bool)\n\n case assignVisibleApps(workspaceName: String?, showNotification: Bool)\n case assignApp(app: String?, workspaceName: String?, activate: Bool?, showNotification: Bool)\n case unassignApp(app: String?, showNotification: Bool)\n case hideUnassignedApps\n\n case floatApp(app: String?, showNotification: Bool)\n case unfloatApp(app: String?, showNotification: Bool)\n case toggleFloatApp(app: String?, showNotification: Bool)\n\n case focusWindow(direction: FocusDirection)\n case focusNextWindow\n case focusPreviousWindow\n case focusNextApp\n case focusPreviousApp\n\n case createProfile(name: String, copy: Bool, activate: Bool)\n case deleteProfile(name: String)\n case activateProfile(name: String)\n\n case openSpaceControl\n\n case listProfiles\n case listWorkspaces(withDisplay: Bool, profile: String?)\n case listApps(\n workspace: String,\n profile: String?,\n withBundleId: Bool,\n withIcon: Bool,\n onlyRunning: Bool\n )\n case listFloatingApps(withBundleId: Bool)\n\n case getProfile\n case getWorkspace(display: String?)\n case getApp(withWindowsCount: Bool)\n case getDisplay\n}\n\nenum FocusDirection: String, Codable {\n case left, right, up, down\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Commands/SpaceControlCommands.swift", "//\n// SpaceControlCommands.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\n\nfinal class SpaceControlCommands: CommandExecutor {\n func execute(command: CommandRequest) -> CommandResponse? {\n switch command {\n case .openSpaceControl:\n if SpaceControl.isEnabled {\n SpaceControl.show()\n return CommandResponse(success: true)\n } else {\n return CommandResponse(success: false, error: \"Space Control is not enabled\")\n }\n\n default:\n return nil\n }\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Extensions/ParsableCommand.swift", "//\n// ParsableCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nextension ParsableCommand {\n func sendCommand(_ command: CommandRequest) {\n SocketClient.shared.sendCommand(command)\n }\n\n func fallbackToHelp() {\n print(Self.helpMessage(for: Self.self))\n Self.exit(withError: CommandError.other)\n }\n\n func runWithTimeout() {\n RunLoop.current.run(until: Date().addingTimeInterval(5.0))\n Self.exit(withError: CommandError.timeout)\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/CGRect.swift", "//\n// CGRect.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension CGRect {\n func getDisplay() -> String? {\n NSScreen.screens\n .first { $0.normalizedFrame.contains(.init(x: self.midX, y: self.midY)) }?\n .localizedName\n }\n\n func verticalIntersect(with rect: CGRect) -> Bool {\n var rect = rect\n rect.origin.x = origin.x\n\n return intersects(rect)\n }\n\n func horizontalIntersect(with rect: CGRect) -> Bool {\n var rect = rect\n rect.origin.y = origin.y\n\n return intersects(rect)\n }\n\n func distance(to rect: CGRect) -> CGFloat {\n let x = midX - rect.midX\n let y = midY - rect.midY\n\n return sqrt(x * x + y * y)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/HotKeys/Models/KeyCodesMap.swift", "//\n// KeyCodesMap.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Carbon\n\nenum KeyCodesMap {\n private(set) static var toKeyCode = create()\n\n static let toString = toKeyCode.reduce(into: [RawKeyCode: String]()) { result, pair in\n result[pair.value] = pair.key\n\n for (alias, keyCode) in getAliases() {\n result[keyCode] = alias\n }\n }\n\n static subscript(key: String) -> RawKeyCode? { toKeyCode[key] }\n\n static func refresh() {\n toKeyCode = create()\n }\n\n private static func create() -> [String: RawKeyCode] {\n var stringToKeyCodes: [String: RawKeyCode] = [:]\n var currentKeyboard = TISCopyCurrentKeyboardInputSource().takeRetainedValue()\n var rawLayoutData = TISGetInputSourceProperty(currentKeyboard, kTISPropertyUnicodeKeyLayoutData)\n if rawLayoutData == nil {\n currentKeyboard = TISCopyCurrentASCIICapableKeyboardLayoutInputSource().takeUnretainedValue()\n rawLayoutData = TISGetInputSourceProperty(currentKeyboard, kTISPropertyUnicodeKeyLayoutData)\n }\n\n let layoutData = unsafeBitCast(rawLayoutData, to: CFData.self)\n let layout: UnsafePointer = unsafeBitCast(\n CFDataGetBytePtr(layoutData),\n to: UnsafePointer.self\n )\n\n var keysDown: UInt32 = 0\n var chars: [UniChar] = [0, 0, 0, 0]\n var realLength = 0\n\n for keyCode in 0..<128 {\n switch keyCode {\n case kVK_ANSI_Keypad0, kVK_ANSI_Keypad1, kVK_ANSI_Keypad2, kVK_ANSI_Keypad3,\n kVK_ANSI_Keypad4, kVK_ANSI_Keypad5, kVK_ANSI_Keypad6, kVK_ANSI_Keypad7,\n kVK_ANSI_Keypad8, kVK_ANSI_Keypad9,\n kVK_ANSI_KeypadMinus, kVK_ANSI_KeypadMultiply, kVK_ANSI_KeypadDivide,\n kVK_ANSI_KeypadDecimal, kVK_ANSI_KeypadClear, kVK_ANSI_KeypadEnter,\n kVK_ANSI_KeypadEquals, kVK_ANSI_KeypadPlus:\n continue\n default: break\n }\n\n UCKeyTranslate(\n layout,\n UInt16(keyCode),\n UInt16(kUCKeyActionDisplay),\n 0,\n UInt32(LMGetKbdType()),\n UInt32(kUCKeyTranslateNoDeadKeysBit),\n &keysDown,\n chars.count,\n &realLength,\n &chars\n )\n\n let string = CFStringCreateWithCharacters(kCFAllocatorDefault, chars, realLength) as String\n if !stringToKeyCodes.keys.contains(string) {\n stringToKeyCodes[string] = UInt16(keyCode)\n }\n }\n\n let aliases = getAliases()\n for (alias, keyCode) in aliases {\n stringToKeyCodes[alias] = keyCode\n }\n\n return stringToKeyCodes\n }\n\n private static func getAliases() -> [String: RawKeyCode] {\n [\n \"space\": UInt16(kVK_Space),\n \"enter\": UInt16(kVK_Return),\n \"up\": UInt16(kVK_UpArrow),\n \"right\": UInt16(kVK_RightArrow),\n \"down\": UInt16(kVK_DownArrow),\n \"left\": UInt16(kVK_LeftArrow),\n \"delete\": UInt16(kVK_Delete),\n \"forward-delete\": UInt16(kVK_ForwardDelete),\n \"escape\": UInt16(kVK_Escape),\n \"tab\": UInt16(kVK_Tab),\n \"capslock\": UInt16(kVK_CapsLock),\n \"f1\": UInt16(kVK_F1),\n \"f2\": UInt16(kVK_F2),\n \"f3\": UInt16(kVK_F3),\n \"f4\": UInt16(kVK_F4),\n \"f5\": UInt16(kVK_F5),\n \"f6\": UInt16(kVK_F6),\n \"f7\": UInt16(kVK_F7),\n \"f8\": UInt16(kVK_F8),\n \"f9\": UInt16(kVK_F9),\n \"f10\": UInt16(kVK_F10),\n \"f11\": UInt16(kVK_F11),\n \"f12\": UInt16(kVK_F12),\n \"num0\": UInt16(kVK_ANSI_Keypad0),\n \"num1\": UInt16(kVK_ANSI_Keypad1),\n \"num2\": UInt16(kVK_ANSI_Keypad2),\n \"num3\": UInt16(kVK_ANSI_Keypad3),\n \"num4\": UInt16(kVK_ANSI_Keypad4),\n \"num5\": UInt16(kVK_ANSI_Keypad5),\n \"num6\": UInt16(kVK_ANSI_Keypad6),\n \"num7\": UInt16(kVK_ANSI_Keypad7),\n \"num8\": UInt16(kVK_ANSI_Keypad8),\n \"num9\": UInt16(kVK_ANSI_Keypad9),\n \"num-plus\": UInt16(kVK_ANSI_KeypadPlus),\n \"num-minus\": UInt16(kVK_ANSI_KeypadMinus),\n \"num-multiply\": UInt16(kVK_ANSI_KeypadMultiply),\n \"num-divide\": UInt16(kVK_ANSI_KeypadDivide),\n \"num-clear\": UInt16(kVK_ANSI_KeypadClear),\n \"num-enter\": UInt16(kVK_ANSI_KeypadEnter),\n \"num-equals\": UInt16(kVK_ANSI_KeypadEquals),\n \"num-decimal\": UInt16(kVK_ANSI_KeypadDecimal)\n ]\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Models/CommandError.swift", "//\n// CommandError.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nenum CommandError: Error, LocalizedError {\n case timeout\n case connectionError(Error)\n case emptyResponse\n case couldNotEncode(Error)\n case operationFailed(String)\n case missingArgument\n case other\n\n var errorDescription: String? {\n switch self {\n case .timeout:\n return \"Timeout. Please check if FlashSpace is running.\"\n case .connectionError(let error):\n return \"Connection error. Please check if FlashSpace is running.\\n\\(error)\"\n case .emptyResponse:\n return \"Empty response. Please check if FlashSpace is running.\"\n case .couldNotEncode(let error):\n return \"Could not encode the message. Please try again.\\n\\(error)\"\n case .operationFailed(let message):\n return message\n case .missingArgument:\n return \"Missing argument(s). Please provide the required argument(s).\"\n case .other:\n return \"\"\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/_Extensions/Publisher.swift", "//\n// Publisher.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nextension Publisher where Output: Equatable {\n func settingsPublisher() -> AnyPublisher<(), Failure> {\n removeDuplicates()\n .map { _ in }\n .dropFirst()\n .eraseToAnyPublisher()\n }\n\n func settingsPublisher(debounce: Bool) -> AnyPublisher<(), Failure> {\n if debounce {\n self.debounce(for: .seconds(1), scheduler: DispatchQueue.main)\n .settingsPublisher()\n } else {\n settingsPublisher()\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Profiles/Models/Profile.swift", "//\n// Profile.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\ntypealias ProfileId = UUID\n\nstruct ProfilesConfig: Codable {\n let profiles: [Profile]\n}\n\nstruct Profile: Identifiable, Codable, Hashable {\n let id: ProfileId\n var name: String\n var workspaces: [Workspace]\n}\n\nextension Profile {\n static let `default` = Profile(\n id: UUID(),\n name: \"Default\",\n workspaces: []\n )\n}\n"], ["/FlashSpace/FlashSpace/Accessibility/NSRunningApplication+Apps.swift", "//\n// NSRunningApplication+Apps.swift\n//\n// Created by Wojciech Kulik on 12/07/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension NSRunningApplication {\n var isFinder: Bool { bundleIdentifier == \"com.apple.finder\" }\n var isPython: Bool { bundleIdentifier == \"org.python.python\" }\n var isOrion: Bool { bundleIdentifier == \"com.kagi.kagimacOS\" }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Commands/FocusCommands.swift", "//\n// FocusCommands.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nfinal class FocusCommands: CommandExecutor {\n var focusManager: FocusManager { AppDependencies.shared.focusManager }\n\n func execute(command: CommandRequest) -> CommandResponse? {\n switch command {\n case .focusWindow(let direction):\n switch direction {\n case .left: focusManager.focusLeft()\n case .right: focusManager.focusRight()\n case .up: focusManager.focusUp()\n case .down: focusManager.focusDown()\n }\n return CommandResponse(success: true)\n\n case .focusNextApp:\n focusManager.nextWorkspaceApp()\n return CommandResponse(success: true)\n\n case .focusPreviousApp:\n focusManager.previousWorkspaceApp()\n return CommandResponse(success: true)\n\n case .focusNextWindow:\n focusManager.nextWorkspaceWindow()\n return CommandResponse(success: true)\n\n case .focusPreviousWindow:\n focusManager.previousWorkspaceWindow()\n return CommandResponse(success: true)\n\n default:\n return nil\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/TextField.swift", "//\n// TextField.swift\n//\n// Created by Wojciech Kulik on 08/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct PlaceholderModifier: ViewModifier {\n @FocusState private var isFocused: Bool\n @Environment(\\.isEnabled) private var isEnabled\n\n let placeholder: String\n let visible: Bool\n\n func body(content: Content) -> some View {\n ZStack(alignment: .leading) {\n if visible, !isFocused {\n Text(placeholder)\n .foregroundColor(.secondary)\n .allowsHitTesting(false)\n .frame(maxWidth: .infinity, alignment: .trailing)\n .opacity(isEnabled ? 1 : 0.5)\n }\n content\n .focused($isFocused)\n }\n }\n}\n\nextension View {\n func placeholder(_ placeholder: String, visible: Bool) -> some View {\n modifier(PlaceholderModifier(placeholder: placeholder, visible: visible))\n }\n\n func standardPlaceholder(_ visible: Bool) -> some View {\n placeholder(\"(type here)\", visible: visible)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Workspaces/Models/MacAppWithWorkspace.swift", "//\n// MacAppWithWorkspace.swift\n//\n// Created by Wojciech Kulik on 20/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\nimport SwiftUI\n\nstruct MacAppWithWorkspace: Hashable, Codable {\n var app: MacApp\n var workspaceId: WorkspaceID\n}\n\nextension MacAppWithWorkspace: Transferable {\n static var transferRepresentation: some TransferRepresentation {\n CodableRepresentation(for: MacAppWithWorkspace.self, contentType: .json)\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/Color.swift", "//\n// Color.swift\n//\n// Created by Wojciech Kulik on 04/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\npublic extension Color {\n init?(hex: String?) {\n guard let hex else { return nil }\n var hexValue = hex.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines).uppercased()\n\n if hexValue.hasPrefix(\"#\") {\n hexValue.remove(at: hexValue.startIndex)\n }\n\n var rgbValue: UInt64 = 0\n Scanner(string: hexValue).scanHexInt64(&rgbValue)\n\n let red = CGFloat((rgbValue & 0xFF0000) >> 16) / 255.0\n let green = CGFloat((rgbValue & 0x00FF00) >> 8) / 255.0\n let blue = CGFloat(rgbValue & 0x0000FF) / 255.0\n\n self.init(red: red, green: green, blue: blue, opacity: 1)\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/CornerRadius.swift", "//\n// CornerRadius.swift\n//\n// Created by Wojciech Kulik on 11/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport SwiftUI\n\nstruct RoundedCorners: Shape {\n var radius: CGFloat\n var corners: [Corner]\n\n enum Corner {\n case topLeft, topRight, bottomLeft, bottomRight\n }\n\n func path(in rect: CGRect) -> Path {\n var path = Path()\n\n let topLeft = corners.contains(.topLeft) ? radius : 0\n let topRight = corners.contains(.topRight) ? radius : 0\n let bottomLeft = corners.contains(.bottomLeft) ? radius : 0\n let bottomRight = corners.contains(.bottomRight) ? radius : 0\n\n path.move(to: CGPoint(x: rect.minX, y: rect.midY))\n\n path.addArc(\n center: CGPoint(x: rect.minX + topLeft, y: rect.minY + topLeft),\n radius: topLeft,\n startAngle: .degrees(180),\n endAngle: .degrees(270),\n clockwise: false\n )\n\n path.addArc(\n center: CGPoint(x: rect.maxX - topRight, y: rect.minY + topRight),\n radius: topRight,\n startAngle: .degrees(270),\n endAngle: .degrees(0),\n clockwise: false\n )\n\n path.addArc(\n center: CGPoint(x: rect.maxX - bottomRight, y: rect.maxY - bottomRight),\n radius: bottomRight,\n startAngle: .degrees(0),\n endAngle: .degrees(90),\n clockwise: false\n )\n\n path.addArc(\n center: CGPoint(x: rect.minX + bottomLeft, y: rect.maxY - bottomLeft),\n radius: bottomLeft,\n startAngle: .degrees(90),\n endAngle: .degrees(180),\n clockwise: false\n )\n\n path.closeSubpath()\n return path\n }\n}\n\nextension View {\n func cornerRadius(_ radius: CGFloat, corners: [RoundedCorners.Corner]) -> some View {\n clipShape(RoundedCorners(radius: radius, corners: corners))\n }\n}\n"], ["/FlashSpace/FlashSpace/Utils/AutostartService.swift", "//\n// AutostartService.swift\n//\n// Created by Wojciech Kulik on 20/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ServiceManagement\n\nfinal class AutostartService {\n var isLaunchAtLoginEnabled: Bool { SMAppService.mainApp.status == .enabled }\n\n func enableLaunchAtLogin() {\n do {\n if SMAppService.mainApp.status == .enabled {\n try SMAppService.mainApp.unregister()\n }\n\n try SMAppService.mainApp.register()\n } catch {\n Logger.log(\"Failed to enable launch at login: \\(error)\")\n }\n }\n\n func disableLaunchAtLogin() {\n do {\n try SMAppService.mainApp.unregister()\n } catch {\n Logger.log(\"Failed to disable launch at login: \\(error)\")\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/NSView.swift", "//\n// NSView.swift\n//\n// Created by Wojciech Kulik on 11/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension NSView {\n func addVisualEffect(material: NSVisualEffectView.Material, border: Bool = false) -> NSView {\n let visualEffectView = NSVisualEffectView()\n visualEffectView.material = material\n visualEffectView.blendingMode = .behindWindow\n visualEffectView.state = .active\n\n if border {\n visualEffectView.wantsLayer = true\n visualEffectView.layer?.cornerRadius = 24\n visualEffectView.layer?.borderWidth = 0.8\n visualEffectView.layer?.borderColor = NSColor.darkGray.cgColor\n visualEffectView.layer?.masksToBounds = true\n }\n\n visualEffectView.addSubview(self)\n translatesAutoresizingMaskIntoConstraints = false\n\n NSLayoutConstraint.activate([\n leadingAnchor.constraint(equalTo: visualEffectView.leadingAnchor),\n trailingAnchor.constraint(equalTo: visualEffectView.trailingAnchor),\n topAnchor.constraint(equalTo: visualEffectView.topAnchor),\n bottomAnchor.constraint(equalTo: visualEffectView.bottomAnchor)\n ])\n\n return visualEffectView\n }\n}\n"], ["/FlashSpace/FlashSpace/Utils/UpdatesManager.swift", "//\n// UpdatesManager.swift\n//\n// Created by Wojciech Kulik on 25/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\nimport Sparkle\n\nfinal class UpdatesManager {\n static let shared = UpdatesManager()\n\n var autoCheckForUpdates: Bool {\n get { updaterController.updater.automaticallyChecksForUpdates }\n set { updaterController.updater.automaticallyChecksForUpdates = newValue }\n }\n\n private var lastCheckDate = Date.distantPast\n private var detectedNewRelease = false\n\n private let updaterController = SPUStandardUpdaterController(\n startingUpdater: true,\n updaterDelegate: nil,\n userDriverDelegate: nil\n )\n\n private init() {\n updaterController.updater.updateCheckInterval = 30 * 60\n\n DispatchQueue.main.async {\n self.autoCheckForUpdates = AppDependencies.shared.generalSettings.checkForUpdatesAutomatically\n }\n }\n\n func checkForUpdates() {\n updaterController.updater.checkForUpdates()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Config/Models/TOMLCoding.swift", "//\n// TOMLCoding.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\nimport TOMLKit\n\nextension TOMLEncoder: ConfigEncoder {\n func encode(_ value: some Encodable) throws -> Data {\n let toml: String = try encode(value)\n return toml.data(using: .utf8) ?? Data()\n }\n}\n\nextension TOMLDecoder: ConfigDecoder {\n func decode(_ type: T.Type, from data: Data) throws -> T where T: Decodable {\n let toml = String(data: data, encoding: .utf8) ?? \"\"\n return try decode(T.self, from: toml)\n }\n}\n"], ["/FlashSpace/FlashSpace/App/FlashSpaceApp.swift", "//\n// FlashSpaceApp.swift\n// FlashSpace\n//\n// Created by Wojciech Kulik on 19/01/2025.\n//\n\nimport SwiftUI\n\n@main\nstruct FlashSpaceApp: App {\n @NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate\n\n var body: some Scene {\n Window(\"⚡ FlashSpace v\\(AppConstants.version)\", id: \"main\") {\n MainView()\n }\n .windowResizability(.contentSize)\n\n Window(\"Settings\", id: \"settings\") {\n SettingsView()\n }\n .windowResizability(.contentSize)\n\n FlashSpaceMenuBar()\n }\n}\n"], ["/FlashSpace/FlashSpace/App/AppDependencies.swift", "//\n// AppDependencies.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ShortcutRecorder\n\nstruct AppDependencies {\n static let shared = AppDependencies()\n\n let displayManager: DisplayManager\n let workspaceRepository: WorkspaceRepository\n let workspaceManager: WorkspaceManager\n let workspaceHotKeys: WorkspaceHotKeys\n let workspaceScreenshotManager = WorkspaceScreenshotManager()\n let workspaceTransitionManager: WorkspaceTransitionManager\n let pictureInPictureManager: PictureInPictureManager\n\n let floatingAppsHotKeys: FloatingAppsHotKeys\n\n let hotKeysMonitor: HotKeysMonitorProtocol = GlobalShortcutMonitor.shared\n let hotKeysManager: HotKeysManager\n\n let focusManager: FocusManager\n let focusedWindowTracker: FocusedWindowTracker\n\n let settingsRepository: SettingsRepository\n let generalSettings = GeneralSettings()\n let menuBarSettings = MenuBarSettings()\n let gesturesSettings = GesturesSettings()\n let focusManagerSettings = FocusManagerSettings()\n let workspaceSettings = WorkspaceSettings()\n let floatingAppsSettings = FloatingAppsSettings()\n let spaceControlSettings = SpaceControlSettings()\n let integrationsSettings = IntegrationsSettings()\n\n let profilesRepository: ProfilesRepository\n let autostartService = AutostartService()\n let cliServer = CLIServer()\n\n // swiftlint:disable:next function_body_length\n private init() {\n self.settingsRepository = SettingsRepository(\n generalSettings: generalSettings,\n menuBarSettings: menuBarSettings,\n gesturesSettings: gesturesSettings,\n focusManagerSettings: focusManagerSettings,\n workspaceSettings: workspaceSettings,\n floatingAppsSettings: floatingAppsSettings,\n spaceControlSettings: spaceControlSettings,\n integrationsSettings: integrationsSettings\n )\n self.displayManager = DisplayManager(settingsRepository: settingsRepository)\n self.workspaceTransitionManager = WorkspaceTransitionManager(\n workspaceSettings: workspaceSettings\n )\n self.pictureInPictureManager = PictureInPictureManager(\n settingsRepository: settingsRepository\n )\n self.profilesRepository = ProfilesRepository()\n self.workspaceRepository = WorkspaceRepository(\n profilesRepository: profilesRepository\n )\n self.workspaceManager = WorkspaceManager(\n workspaceRepository: workspaceRepository,\n settingsRepository: settingsRepository,\n pictureInPictureManager: pictureInPictureManager,\n workspaceTransitionManager: workspaceTransitionManager,\n displayManager: displayManager\n )\n self.workspaceHotKeys = WorkspaceHotKeys(\n workspaceManager: workspaceManager,\n workspaceRepository: workspaceRepository,\n settingsRepository: settingsRepository\n )\n self.floatingAppsHotKeys = FloatingAppsHotKeys(\n workspaceManager: workspaceManager,\n settingsRepository: settingsRepository\n )\n self.focusManager = FocusManager(\n workspaceRepository: workspaceRepository,\n workspaceManager: workspaceManager,\n focusManagerSettings: focusManagerSettings,\n floatingAppsSettings: floatingAppsSettings\n )\n self.hotKeysManager = HotKeysManager(\n hotKeysMonitor: GlobalShortcutMonitor.shared,\n workspaceHotKeys: workspaceHotKeys,\n floatingAppsHotKeys: floatingAppsHotKeys,\n focusManager: focusManager,\n settingsRepository: settingsRepository\n )\n self.focusedWindowTracker = FocusedWindowTracker(\n workspaceRepository: workspaceRepository,\n workspaceManager: workspaceManager,\n settingsRepository: settingsRepository,\n pictureInPictureManager: pictureInPictureManager\n )\n\n Migrations.migrateIfNeeded(\n settingsRepository: settingsRepository,\n profilesRepository: profilesRepository\n )\n\n focusedWindowTracker.startTracking()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/PictureInPicture/Models/PipApp.swift", "//\n// PipApp.swift\n//\n// Created by Wojciech Kulik on 22/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nstruct PipApp: Codable, Equatable, Hashable {\n let name: String\n let bundleIdentifier: BundleId\n let pipWindowTitleRegex: String\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Workspaces/DisplayMode.swift", "//\n// DisplayMode.swift\n//\n// Created by Wojciech Kulik on 12/07/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nenum DisplayMode: String, Codable, CaseIterable {\n case `static`\n case dynamic\n}\n\nextension DisplayMode: Identifiable {\n var id: String { rawValue }\n\n var description: String {\n switch self {\n case .static: return \"Static\"\n case .dynamic: return \"Dynamic\"\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/NotificationName.swift", "//\n// NotificationName.swift\n//\n// Created by Wojciech Kulik on 22/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nextension Notification.Name {\n static let appsListChanged = Notification.Name(\"appsListChanged\")\n static let openMainWindow = Notification.Name(\"openMainWindow\")\n static let profileChanged = Notification.Name(\"profileChanged\")\n static let workspaceChanged = Notification.Name(\"workspaceChanged\")\n static let workspaceTransitionFinished = Notification.Name(\"workspaceTransitionFinished\")\n static let spaceControlArrowDown = Notification.Name(\"spaceControlArrowDown\")\n static let pipFocusChanged = Notification.Name(\"pipFocusChanged\")\n}\n"], ["/FlashSpace/FlashSpace/UI/Alerts.swift", "//\n// Alerts.swift\n//\n// Created by Wojciech Kulik on 25/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nenum Alert {\n static func showOkAlert(title: String, message: String) {\n let alert = NSAlert()\n alert.messageText = title\n alert.informativeText = message\n alert.alertStyle = .informational\n alert.addButton(withTitle: \"OK\")\n alert.runModal()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Acknowledgements/Licenses.swift", "//\n// Licenses.swift\n//\n// Created by Wojciech Kulik on 26/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nenum Licenses {\n static let swiftFormat = \"\"\"\n SwiftFormat\n\n Authors: Nick Lockwood\n Project URL: https://github.com/nicklockwood/SwiftFormat\n License URL: https://github.com/nicklockwood/SwiftFormat/blob/main/LICENSE.md\n\n MIT License\n\n Copyright (c) 2016 Nick Lockwood\n\n Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n \"\"\"\n\n static let swiftLint = \"\"\"\n SwiftLint\n\n Authors: The SwiftLint Contributors\n Project URL: https://github.com/realm/SwiftLint/\n License URL: https://github.com/realm/SwiftLint/blob/master/LICENSE\n\n The MIT License (MIT)\n\n Copyright (c) 2025 The SwiftLint Contributors.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n \"\"\"\n\n static let symbolPicker = \"\"\"\n SymbolPicker\n\n Authors: Yubo Qin & Lakr Aream\n Project URL: https://github.com/xnth97/SymbolPicker\n License URL: https://github.com/xnth97/SymbolPicker/blob/main/LICENSE\n\n MIT License\n\n Copyright (c) 2022 Yubo Qin & Lakr Aream\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n \"\"\"\n\n static let shortcutRecorder = \"\"\"\n ShortcutRecorder\n\n Authors: Contributors\n Project URL: https://github.com/Kentzo/ShortcutRecorder\n License URL: https://github.com/Kentzo/ShortcutRecorder/blob/master/LICENSE.txt\n\n Creative Commons Attribution 4.0 International Public License\n\n By exercising the Licensed Rights (defined below), You accept and agree\n to be bound by the terms and conditions of this Creative Commons\n Attribution 4.0 International Public License (\"Public License\"). To the\n extent this Public License may be interpreted as a contract, You are\n granted the Licensed Rights in consideration of Your acceptance of\n these terms and conditions, and the Licensor grants You such rights in\n consideration of benefits the Licensor receives from making the\n Licensed Material available under these terms and conditions.\n\n\n Section 1 -- Definitions.\n\n a. Adapted Material means material subject to Copyright and Similar\n Rights that is derived from or based upon the Licensed Material\n and in which the Licensed Material is translated, altered,\n arranged, transformed, or otherwise modified in a manner requiring\n permission under the Copyright and Similar Rights held by the\n Licensor. For purposes of this Public License, where the Licensed\n Material is a musical work, performance, or sound recording,\n Adapted Material is always produced where the Licensed Material is\n synched in timed relation with a moving image.\n\n b. Adapter's License means the license You apply to Your Copyright\n and Similar Rights in Your contributions to Adapted Material in\n accordance with the terms and conditions of this Public License.\n\n c. Copyright and Similar Rights means copyright and/or similar rights\n closely related to copyright including, without limitation,\n performance, broadcast, sound recording, and Sui Generis Database\n Rights, without regard to how the rights are labeled or\n categorized. For purposes of this Public License, the rights\n specified in Section 2(b)(1)-(2) are not Copyright and Similar\n Rights.\n\n d. Effective Technological Measures means those measures that, in the\n absence of proper authority, may not be circumvented under laws\n fulfilling obligations under Article 11 of the WIPO Copyright\n Treaty adopted on December 20, 1996, and/or similar international\n agreements.\n\n e. Exceptions and Limitations means fair use, fair dealing, and/or\n any other exception or limitation to Copyright and Similar Rights\n that applies to Your use of the Licensed Material.\n\n f. Licensed Material means the artistic or literary work, database,\n or other material to which the Licensor applied this Public\n License.\n\n g. Licensed Rights means the rights granted to You subject to the\n terms and conditions of this Public License, which are limited to\n all Copyright and Similar Rights that apply to Your use of the\n Licensed Material and that the Licensor has authority to license.\n\n h. Licensor means the individual(s) or entity(ies) granting rights\n under this Public License.\n\n i. Share means to provide material to the public by any means or\n process that requires permission under the Licensed Rights, such\n as reproduction, public display, public performance, distribution,\n dissemination, communication, or importation, and to make material\n available to the public including in ways that members of the\n public may access the material from a place and at a time\n individually chosen by them.\n\n j. Sui Generis Database Rights means rights other than copyright\n resulting from Directive 96/9/EC of the European Parliament and of\n the Council of 11 March 1996 on the legal protection of databases,\n as amended and/or succeeded, as well as other essentially\n equivalent rights anywhere in the world.\n\n k. You means the individual or entity exercising the Licensed Rights\n under this Public License. Your has a corresponding meaning.\n\n\n Section 2 -- Scope.\n\n a. License grant.\n\n 1. Subject to the terms and conditions of this Public License,\n the Licensor hereby grants You a worldwide, royalty-free,\n non-sublicensable, non-exclusive, irrevocable license to\n exercise the Licensed Rights in the Licensed Material to:\n\n a. reproduce and Share the Licensed Material, in whole or\n in part; and\n\n b. produce, reproduce, and Share Adapted Material.\n\n 2. Exceptions and Limitations. For the avoidance of doubt, where\n Exceptions and Limitations apply to Your use, this Public\n License does not apply, and You do not need to comply with\n its terms and conditions.\n\n 3. Term. The term of this Public License is specified in Section\n 6(a).\n\n 4. Media and formats; technical modifications allowed. The\n Licensor authorizes You to exercise the Licensed Rights in\n all media and formats whether now known or hereafter created,\n and to make technical modifications necessary to do so. The\n Licensor waives and/or agrees not to assert any right or\n authority to forbid You from making technical modifications\n necessary to exercise the Licensed Rights, including\n technical modifications necessary to circumvent Effective\n Technological Measures. For purposes of this Public License,\n simply making modifications authorized by this Section 2(a)\n (4) never produces Adapted Material.\n\n 5. Downstream recipients.\n\n a. Offer from the Licensor -- Licensed Material. Every\n recipient of the Licensed Material automatically\n receives an offer from the Licensor to exercise the\n Licensed Rights under the terms and conditions of this\n Public License.\n\n b. No downstream restrictions. You may not offer or impose\n any additional or different terms or conditions on, or\n apply any Effective Technological Measures to, the\n Licensed Material if doing so restricts exercise of the\n Licensed Rights by any recipient of the Licensed\n Material.\n\n 6. No endorsement. Nothing in this Public License constitutes or\n may be construed as permission to assert or imply that You\n are, or that Your use of the Licensed Material is, connected\n with, or sponsored, endorsed, or granted official status by,\n the Licensor or others designated to receive attribution as\n provided in Section 3(a)(1)(A)(i).\n\n b. Other rights.\n\n 1. Moral rights, such as the right of integrity, are not\n licensed under this Public License, nor are publicity,\n privacy, and/or other similar personality rights; however, to\n the extent possible, the Licensor waives and/or agrees not to\n assert any such rights held by the Licensor to the limited\n extent necessary to allow You to exercise the Licensed\n Rights, but not otherwise.\n\n 2. Patent and trademark rights are not licensed under this\n Public License.\n\n 3. To the extent possible, the Licensor waives any right to\n collect royalties from You for the exercise of the Licensed\n Rights, whether directly or through a collecting society\n under any voluntary or waivable statutory or compulsory\n licensing scheme. In all other cases the Licensor expressly\n reserves any right to collect such royalties.\n\n\n Section 3 -- License Conditions.\n\n Your exercise of the Licensed Rights is expressly made subject to the\n following conditions.\n\n a. Attribution.\n\n 1. If You Share the Licensed Material (including in modified\n form), You must:\n\n a. retain the following if it is supplied by the Licensor\n with the Licensed Material:\n\n i. identification of the creator(s) of the Licensed\n Material and any others designated to receive\n attribution, in any reasonable manner requested by\n the Licensor (including by pseudonym if\n designated);\n\n ii. a copyright notice;\n\n iii. a notice that refers to this Public License;\n\n iv. a notice that refers to the disclaimer of\n warranties;\n\n v. a URI or hyperlink to the Licensed Material to the\n extent reasonably practicable;\n\n b. indicate if You modified the Licensed Material and\n retain an indication of any previous modifications; and\n\n c. indicate the Licensed Material is licensed under this\n Public License, and include the text of, or the URI or\n hyperlink to, this Public License.\n\n 2. You may satisfy the conditions in Section 3(a)(1) in any\n reasonable manner based on the medium, means, and context in\n which You Share the Licensed Material. For example, it may be\n reasonable to satisfy the conditions by providing a URI or\n hyperlink to a resource that includes the required\n information.\n\n 3. If requested by the Licensor, You must remove any of the\n information required by Section 3(a)(1)(A) to the extent\n reasonably practicable.\n\n 4. If You Share Adapted Material You produce, the Adapter's\n License You apply must not prevent recipients of the Adapted\n Material from complying with this Public License.\n\n\n Section 4 -- Sui Generis Database Rights.\n\n Where the Licensed Rights include Sui Generis Database Rights that\n apply to Your use of the Licensed Material:\n\n a. for the avoidance of doubt, Section 2(a)(1) grants You the right\n to extract, reuse, reproduce, and Share all or a substantial\n portion of the contents of the database;\n\n b. if You include all or a substantial portion of the database\n contents in a database in which You have Sui Generis Database\n Rights, then the database in which You have Sui Generis Database\n Rights (but not its individual contents) is Adapted Material; and\n\n c. You must comply with the conditions in Section 3(a) if You Share\n all or a substantial portion of the contents of the database.\n\n For the avoidance of doubt, this Section 4 supplements and does not\n replace Your obligations under this Public License where the Licensed\n Rights include other Copyright and Similar Rights.\n\n\n Section 5 -- Disclaimer of Warranties and Limitation of Liability.\n\n a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE\n EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS\n AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF\n ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,\n IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,\n WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR\n PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,\n ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT\n KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT\n ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.\n\n b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE\n TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,\n NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,\n INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,\n COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR\n USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN\n ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR\n DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR\n IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.\n\n c. The disclaimer of warranties and limitation of liability provided\n above shall be interpreted in a manner that, to the extent\n possible, most closely approximates an absolute disclaimer and\n waiver of all liability.\n\n\n Section 6 -- Term and Termination.\n\n a. This Public License applies for the term of the Copyright and\n Similar Rights licensed here. However, if You fail to comply with\n this Public License, then Your rights under this Public License\n terminate automatically.\n\n b. Where Your right to use the Licensed Material has terminated under\n Section 6(a), it reinstates:\n\n 1. automatically as of the date the violation is cured, provided\n it is cured within 30 days of Your discovery of the\n violation; or\n\n 2. upon express reinstatement by the Licensor.\n\n For the avoidance of doubt, this Section 6(b) does not affect any\n right the Licensor may have to seek remedies for Your violations\n of this Public License.\n\n c. For the avoidance of doubt, the Licensor may also offer the\n Licensed Material under separate terms or conditions or stop\n distributing the Licensed Material at any time; however, doing so\n will not terminate this Public License.\n\n d. Sections 1, 5, 6, 7, and 8 survive termination of this Public\n License.\n\n\n Section 7 -- Other Terms and Conditions.\n\n a. The Licensor shall not be bound by any additional or different\n terms or conditions communicated by You unless expressly agreed.\n\n b. Any arrangements, understandings, or agreements regarding the\n Licensed Material not stated herein are separate from and\n independent of the terms and conditions of this Public License.\n\n\n Section 8 -- Interpretation.\n\n a. For the avoidance of doubt, this Public License does not, and\n shall not be interpreted to, reduce, limit, restrict, or impose\n conditions on any use of the Licensed Material that could lawfully\n be made without permission under this Public License.\n\n b. To the extent possible, if any provision of this Public License is\n deemed unenforceable, it shall be automatically reformed to the\n minimum extent necessary to make it enforceable. If the provision\n cannot be reformed, it shall be severed from this Public License\n without affecting the enforceability of the remaining terms and\n conditions.\n\n c. No term or condition of this Public License will be waived and no\n failure to comply consented to unless expressly agreed to by the\n Licensor.\n\n d. Nothing in this Public License constitutes or may be interpreted\n as a limitation upon, or waiver of, any privileges and immunities\n that apply to the Licensor or You, including from the legal\n processes of any jurisdiction or authority.\n\n\n =======================================================================\n\n Creative Commons is not a party to its public\n licenses. Notwithstanding, Creative Commons may elect to apply one of\n its public licenses to material it publishes and in those instances\n will be considered the “Licensor.” The text of the Creative Commons\n public licenses is dedicated to the public domain under the CC0 Public\n Domain Dedication. Except for the limited purpose of indicating that\n material is shared under a Creative Commons public license or as\n otherwise permitted by the Creative Commons policies published at\n creativecommons.org/policies, Creative Commons does not authorize the\n use of the trademark \"Creative Commons\" or any other trademark or logo\n of Creative Commons without its prior written consent including,\n without limitation, in connection with any unauthorized modifications\n to any of its public licenses or any other arrangements,\n understandings, or agreements concerning use of licensed material. For\n the avoidance of doubt, this paragraph does not form part of the\n public licenses.\n \"\"\"\n\n static let yams = \"\"\"\n Yams\n\n Authors: JP Simard\n Project URL: https://github.com/jpsim/Yams\n License URL: https://github.com/jpsim/Yams/blob/main/LICENSE\n\n The MIT License (MIT)\n\n Copyright (c) 2016 JP Simard.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n \"\"\"\n\n static let tomlKit = \"\"\"\n TOMLKit\n\n Authors: Jeff Lebrun\n Project URL: https://github.com/LebJe/TOMLKit\n License URL: https://github.com/LebJe/TOMLKit/blob/main/LICENSE\n\n MIT License\n\n Copyright (c) 2024 Jeff Lebrun\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n \"\"\"\n\n static let swiftArgumentParser = \"\"\"\n Swift Argument Parser\n\n Authors: Apple\n Project URL: https://github.com/apple/swift-argument-parser\n License URL: https://github.com/apple/swift-argument-parser/blob/main/LICENSE.txt\n\n Apache License\n Version 2.0, January 2004\n http://www.apache.org/licenses/\n\n TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n 1. Definitions.\n\n \"License\" shall mean the terms and conditions for use, reproduction,\n and distribution as defined by Sections 1 through 9 of this document.\n\n \"Licensor\" shall mean the copyright owner or entity authorized by\n the copyright owner that is granting the License.\n\n \"Legal Entity\" shall mean the union of the acting entity and all\n other entities that control, are controlled by, or are under common\n control with that entity. For the purposes of this definition,\n \"control\" means (i) the power, direct or indirect, to cause the\n direction or management of such entity, whether by contract or\n otherwise, or (ii) ownership of fifty percent (50%) or more of the\n outstanding shares, or (iii) beneficial ownership of such entity.\n\n \"You\" (or \"Your\") shall mean an individual or Legal Entity\n exercising permissions granted by this License.\n\n \"Source\" form shall mean the preferred form for making modifications,\n including but not limited to software source code, documentation\n source, and configuration files.\n\n \"Object\" form shall mean any form resulting from mechanical\n transformation or translation of a Source form, including but\n not limited to compiled object code, generated documentation,\n and conversions to other media types.\n\n \"Work\" shall mean the work of authorship, whether in Source or\n Object form, made available under the License, as indicated by a\n copyright notice that is included in or attached to the work\n (an example is provided in the Appendix below).\n\n \"Derivative Works\" shall mean any work, whether in Source or Object\n form, that is based on (or derived from) the Work and for which the\n editorial revisions, annotations, elaborations, or other modifications\n represent, as a whole, an original work of authorship. For the purposes\n of this License, Derivative Works shall not include works that remain\n separable from, or merely link (or bind by name) to the interfaces of,\n the Work and Derivative Works thereof.\n\n \"Contribution\" shall mean any work of authorship, including\n the original version of the Work and any modifications or additions\n to that Work or Derivative Works thereof, that is intentionally\n submitted to Licensor for inclusion in the Work by the copyright owner\n or by an individual or Legal Entity authorized to submit on behalf of\n the copyright owner. For the purposes of this definition, \"submitted\"\n means any form of electronic, verbal, or written communication sent\n to the Licensor or its representatives, including but not limited to\n communication on electronic mailing lists, source code control systems,\n and issue tracking systems that are managed by, or on behalf of, the\n Licensor for the purpose of discussing and improving the Work, but\n excluding communication that is conspicuously marked or otherwise\n designated in writing by the copyright owner as \"Not a Contribution.\"\n\n \"Contributor\" shall mean Licensor and any individual or Legal Entity\n on behalf of whom a Contribution has been received by Licensor and\n subsequently incorporated within the Work.\n\n 2. Grant of Copyright License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n copyright license to reproduce, prepare Derivative Works of,\n publicly display, publicly perform, sublicense, and distribute the\n Work and such Derivative Works in Source or Object form.\n\n 3. Grant of Patent License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n (except as stated in this section) patent license to make, have made,\n use, offer to sell, sell, import, and otherwise transfer the Work,\n where such license applies only to those patent claims licensable\n by such Contributor that are necessarily infringed by their\n Contribution(s) alone or by combination of their Contribution(s)\n with the Work to which such Contribution(s) was submitted. If You\n institute patent litigation against any entity (including a\n cross-claim or counterclaim in a lawsuit) alleging that the Work\n or a Contribution incorporated within the Work constitutes direct\n or contributory patent infringement, then any patent licenses\n granted to You under this License for that Work shall terminate\n as of the date such litigation is filed.\n\n 4. Redistribution. You may reproduce and distribute copies of the\n Work or Derivative Works thereof in any medium, with or without\n modifications, and in Source or Object form, provided that You\n meet the following conditions:\n\n (a) You must give any other recipients of the Work or\n Derivative Works a copy of this License; and\n\n (b) You must cause any modified files to carry prominent notices\n stating that You changed the files; and\n\n (c) You must retain, in the Source form of any Derivative Works\n that You distribute, all copyright, patent, trademark, and\n attribution notices from the Source form of the Work,\n excluding those notices that do not pertain to any part of\n the Derivative Works; and\n\n (d) If the Work includes a \"NOTICE\" text file as part of its\n distribution, then any Derivative Works that You distribute must\n include a readable copy of the attribution notices contained\n within such NOTICE file, excluding those notices that do not\n pertain to any part of the Derivative Works, in at least one\n of the following places: within a NOTICE text file distributed\n as part of the Derivative Works; within the Source form or\n documentation, if provided along with the Derivative Works; or,\n within a display generated by the Derivative Works, if and\n wherever such third-party notices normally appear. The contents\n of the NOTICE file are for informational purposes only and\n do not modify the License. You may add Your own attribution\n notices within Derivative Works that You distribute, alongside\n or as an addendum to the NOTICE text from the Work, provided\n that such additional attribution notices cannot be construed\n as modifying the License.\n\n You may add Your own copyright statement to Your modifications and\n may provide additional or different license terms and conditions\n for use, reproduction, or distribution of Your modifications, or\n for any such Derivative Works as a whole, provided Your use,\n reproduction, and distribution of the Work otherwise complies with\n the conditions stated in this License.\n\n 5. Submission of Contributions. Unless You explicitly state otherwise,\n any Contribution intentionally submitted for inclusion in the Work\n by You to the Licensor shall be under the terms and conditions of\n this License, without any additional terms or conditions.\n Notwithstanding the above, nothing herein shall supersede or modify\n the terms of any separate license agreement you may have executed\n with Licensor regarding such Contributions.\n\n 6. Trademarks. This License does not grant permission to use the trade\n names, trademarks, service marks, or product names of the Licensor,\n except as required for reasonable and customary use in describing the\n origin of the Work and reproducing the content of the NOTICE file.\n\n 7. Disclaimer of Warranty. Unless required by applicable law or\n agreed to in writing, Licensor provides the Work (and each\n Contributor provides its Contributions) on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n implied, including, without limitation, any warranties or conditions\n of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n PARTICULAR PURPOSE. You are solely responsible for determining the\n appropriateness of using or redistributing the Work and assume any\n risks associated with Your exercise of permissions under this License.\n\n 8. Limitation of Liability. In no event and under no legal theory,\n whether in tort (including negligence), contract, or otherwise,\n unless required by applicable law (such as deliberate and grossly\n negligent acts) or agreed to in writing, shall any Contributor be\n liable to You for damages, including any direct, indirect, special,\n incidental, or consequential damages of any character arising as a\n result of this License or out of the use or inability to use the\n Work (including but not limited to damages for loss of goodwill,\n work stoppage, computer failure or malfunction, or any and all\n other commercial damages or losses), even if such Contributor\n has been advised of the possibility of such damages.\n\n 9. Accepting Warranty or Additional Liability. While redistributing\n the Work or Derivative Works thereof, You may choose to offer,\n and charge a fee for, acceptance of support, warranty, indemnity,\n or other liability obligations and/or rights consistent with this\n License. However, in accepting such obligations, You may act only\n on Your own behalf and on Your sole responsibility, not on behalf\n of any other Contributor, and only if You agree to indemnify,\n defend, and hold each Contributor harmless for any liability\n incurred by, or claims asserted against, such Contributor by reason\n of your accepting any such warranty or additional liability.\n\n END OF TERMS AND CONDITIONS\n\n APPENDIX: How to apply the Apache License to your work.\n\n To apply the Apache License to your work, attach the following\n boilerplate notice, with the fields enclosed by brackets \"[]\"\n replaced with your own identifying information. (Don't include\n the brackets!) The text should be enclosed in the appropriate\n comment syntax for the file format. We also recommend that a\n file or class name and description of purpose be included on the\n same \"printed page\" as the copyright notice for easier\n identification within third-party archives.\n\n Copyright [yyyy] [name of copyright owner]\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n\n\n ## Runtime Library Exception to the Apache 2.0 License: ##\n\n\n As an exception, if you use this Software to compile your source code and\n portions of this Software are embedded into the binary product as a result,\n you may redistribute such product without providing attribution as would\n otherwise be required by Sections 4(a), 4(b) and 4(d) of the License.\n \"\"\"\n\n static let sparkle = \"\"\"\n Sparkle\n\n Copyright (c) 2006-2013 Andy Matuschak.\n Copyright (c) 2009-2013 Elgato Systems GmbH.\n Copyright (c) 2011-2014 Kornel Lesiński.\n Copyright (c) 2015-2017 Mayur Pawashe.\n Copyright (c) 2014 C.W. Betts.\n Copyright (c) 2014 Petroules Corporation.\n Copyright (c) 2014 Big Nerd Ranch.\n All rights reserved.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy of\n this software and associated documentation files (the \"Software\"), to deal in\n the Software without restriction, including without limitation the rights to\n use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\n the Software, and to permit persons to whom the Software is furnished to do so,\n subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\n FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\n COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\n IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n =================\n EXTERNAL LICENSES\n =================\n\n bspatch.c and bsdiff.c, from bsdiff 4.3 :\n\n Copyright 2003-2005 Colin Percival\n All rights reserved\n\n Redistribution and use in source and binary forms, with or without\n modification, are permitted providing that the following conditions \n are met:\n 1. Redistributions of source code must retain the above copyright\n notice, this list of conditions and the following disclaimer.\n 2. Redistributions in binary form must reproduce the above copyright\n notice, this list of conditions and the following disclaimer in the\n documentation and/or other materials provided with the distribution.\n\n THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR\n IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY\n DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING\n IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n POSSIBILITY OF SUCH DAMAGE.\n\n --\n\n sais.c and sais.h, from sais-lite (2010/08/07) :\n\n The sais-lite copyright is as follows:\n\n Copyright (c) 2008-2010 Yuta Mori All Rights Reserved.\n\n Permission is hereby granted, free of charge, to any person\n obtaining a copy of this software and associated documentation\n files (the \"Software\"), to deal in the Software without\n restriction, including without limitation the rights to use,\n copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the\n Software is furnished to do so, subject to the following\n conditions:\n\n The above copyright notice and this permission notice shall be\n included in all copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n OTHER DEALINGS IN THE SOFTWARE.\n\n --\n\n Portable C implementation of Ed25519, from https://github.com/orlp/ed25519\n\n Copyright (c) 2015 Orson Peters \n\n This software is provided 'as-is', without any express or implied warranty. In no event will the\n authors be held liable for any damages arising from the use of this software.\n\n Permission is granted to anyone to use this software for any purpose, including commercial\n applications, and to alter it and redistribute it freely, subject to the following restrictions:\n\n 1. The origin of this software must not be misrepresented; you must not claim that you wrote the\n original software. If you use this software in a product, an acknowledgment in the product\n documentation would be appreciated but is not required.\n\n 2. Altered source versions must be plainly marked as such, and must not be misrepresented as\n being the original software.\n\n 3. This notice may not be removed or altered from any source distribution.\n\n --\n\n SUSignatureVerifier.m:\n\n Copyright (c) 2011 Mark Hamlin.\n\n All rights reserved.\n\n Redistribution and use in source and binary forms, with or without\n modification, are permitted providing that the following conditions\n are met:\n 1. Redistributions of source code must retain the above copyright\n notice, this list of conditions and the following disclaimer.\n 2. Redistributions in binary form must reproduce the above copyright\n notice, this list of conditions and the following disclaimer in the\n documentation and/or other materials provided with the distribution.\n\n THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR\n IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY\n DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING\n IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n POSSIBILITY OF SUCH DAMAGE.\n \"\"\"\n}\n"], ["/FlashSpace/FlashSpace/Utils/Logger.swift", "//\n// Logger.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nenum Logger {\n static let dateFormatter: DateFormatter = {\n let formatter = DateFormatter()\n formatter.dateFormat = \"HH:mm:ss.SSS\"\n return formatter\n }()\n\n static func log(_ message: String) {\n #if DEBUG\n let dateString = dateFormatter.string(from: Date())\n print(\"\\(dateString): \\(message)\")\n #endif\n }\n\n static func log(_ error: Error) {\n log(\"\\(error)\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Config/Models/ConfigFormat.swift", "//\n// ConfigFormat.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nenum ConfigFormat: String, CaseIterable {\n case json\n case toml\n case yaml\n\n var displayName: String {\n switch self {\n case .json: return \"JSON\"\n case .toml: return \"TOML\"\n case .yaml: return \"YAML\"\n }\n }\n\n var extensionName: String {\n switch self {\n case .json: return \"json\"\n case .toml: return \"toml\"\n case .yaml: return \"yaml\"\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/String.swift", "//\n// String.swift\n//\n// Created by Wojciech Kulik on 13/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nextension String {\n static let defaultIconSymbol = \"bolt.fill\"\n\n var isNotEmpty: Bool { !isEmpty }\n var nilIfEmpty: String? { isEmpty ? nil : self }\n var trimmed: String { trimmingCharacters(in: .whitespacesAndNewlines) }\n}\n"], ["/FlashSpace/FlashSpace/Features/Config/Models/YAMLCoding.swift", "//\n// YAMLCoding.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\nimport Yams\n\nextension YAMLEncoder: ConfigEncoder {\n func encode(_ value: some Encodable) throws -> Data {\n let yaml: String = try encode(value)\n return yaml.data(using: .utf8) ?? Data()\n }\n}\n\nextension YAMLDecoder: ConfigDecoder {}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Extensions/SocketDataSerialization.swift", "//\n// SocketDataSerialization.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nextension Data {\n func decodeSocketData(_ type: T.Type) throws -> T {\n var data = self\n data.removeLast()\n return try JSONDecoder().decode(T.self, from: data)\n }\n}\n\nextension Encodable {\n func encodeSocketData() -> Data? {\n var result = try? JSONEncoder().encode(self)\n result?.append(0)\n return result\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Extensions/SocketDataSerialization.swift", "//\n// SocketDataSerialization.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nextension Data {\n func decodeSocketData(_ type: T.Type) throws -> T {\n var data = self\n data.removeLast()\n return try JSONDecoder().decode(T.self, from: data)\n }\n}\n\nextension Encodable {\n func encodeSocketData() -> Data? {\n var result = try? JSONEncoder().encode(self)\n result?.append(0)\n return result\n }\n}\n"], ["/FlashSpace/FlashSpace/Accessibility/NSAccessibility+Attributes.swift", "//\n// NSAccessibility+Attributes.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension NSAccessibility.Attribute {\n static let enchancedUserInterface: NSAccessibility.Attribute = .init(rawValue: \"AXEnhancedUserInterface\")\n}\n"], ["/FlashSpace/FlashSpace/Extensions/Array.swift", "//\n// Array.swift\n//\n// Created by Wojciech Kulik on 27/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nextension Array {\n subscript(safe index: Index) -> Element? {\n get {\n indices.contains(index) ? self[index] : nil\n }\n set {\n guard indices.contains(index), let newValue else { return }\n self[index] = newValue\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Accessibility/AXUIElement+Actions.swift", "//\n// AXUIElement+Actions.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension AXUIElement {\n /// Position is in window coordinates where (0,0) is top-left corner\n /// and it is relative to the main screen.\n func setPosition(_ position: CGPoint) {\n var position = position\n let positionRef = AXValueCreate(.cgPoint, &position)\n setAttribute(.position, value: positionRef)\n }\n\n func focus() {\n AXUIElementPerformAction(self, NSAccessibility.Action.raise as CFString)\n }\n\n func minimize(_ minimized: Bool) {\n setAttribute(.minimized, value: minimized)\n }\n}\n"], ["/FlashSpace/FlashSpace/Utils/PermissionsManager.swift", "//\n// PermissionsManager.swift\n//\n// Created by Wojciech Kulik on 25/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nfinal class PermissionsManager {\n static let shared = PermissionsManager()\n\n private init() {}\n\n func askForAccessibilityPermissions() {\n let options: NSDictionary = [kAXTrustedCheckOptionPrompt.takeRetainedValue() as NSString: true]\n _ = AXIsProcessTrustedWithOptions(options)\n }\n\n func checkForAccessibilityPermissions() -> Bool {\n AXIsProcessTrusted()\n }\n\n func askForScreenRecordingPermissions() {\n CGRequestScreenCaptureAccess()\n }\n\n func checkForScreenRecordingPermissions() -> Bool {\n CGPreflightScreenCaptureAccess()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/_Models/AppSettings.swift", "//\n// AppSettings.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nstruct AppSettings: Codable {\n // General\n var checkForUpdatesAutomatically: Bool?\n var showFlashSpace: AppHotKey?\n var showFloatingNotifications: Bool?\n\n // Menu Bar\n var showMenuBarTitle: Bool?\n var showMenuBarIcon: Bool?\n var menuBarTitleTemplate: String?\n var menuBarDisplayAliases: String?\n\n // Focus Manager\n var enableFocusManagement: Bool?\n var centerCursorOnFocusChange: Bool?\n var focusLeft: AppHotKey?\n var focusRight: AppHotKey?\n var focusUp: AppHotKey?\n var focusDown: AppHotKey?\n var focusNextWorkspaceApp: AppHotKey?\n var focusPreviousWorkspaceApp: AppHotKey?\n var focusNextWorkspaceWindow: AppHotKey?\n var focusPreviousWorkspaceWindow: AppHotKey?\n var focusFrontmostWindow: Bool?\n\n // Gestures\n var enableSwipeGestures: Bool?\n var swipeThreshold: Double?\n var restartAppOnWakeUp: Bool?\n var swipeLeft3FingerAction: GestureAction?\n var swipeRight3FingerAction: GestureAction?\n var swipeUp3FingerAction: GestureAction?\n var swipeDown3FingerAction: GestureAction?\n var swipeLeft4FingerAction: GestureAction?\n var swipeRight4FingerAction: GestureAction?\n var swipeUp4FingerAction: GestureAction?\n var swipeDown4FingerAction: GestureAction?\n\n // Workspaces\n var displayMode: DisplayMode?\n var centerCursorOnWorkspaceChange: Bool?\n var changeWorkspaceOnAppAssign: Bool?\n var activeWorkspaceOnFocusChange: Bool?\n var skipEmptyWorkspacesOnSwitch: Bool?\n var keepUnassignedAppsOnSwitch: Bool?\n var restoreHiddenAppsOnSwitch: Bool?\n var loopWorkspaces: Bool?\n var switchToPreviousWorkspace: AppHotKey?\n var switchToNextWorkspace: AppHotKey?\n var switchToRecentWorkspace: AppHotKey?\n var assignFocusedApp: AppHotKey?\n var unassignFocusedApp: AppHotKey?\n var toggleFocusedAppAssignment: AppHotKey?\n var assignVisibleApps: AppHotKey?\n var hideUnassignedApps: AppHotKey?\n var alternativeDisplays: String?\n var enablePictureInPictureSupport: Bool?\n var switchWorkspaceWhenPipCloses: Bool?\n var pipApps: [PipApp]?\n var pipScreenCornerOffset: Int?\n\n // Floating apps\n var floatingApps: [MacApp]?\n var floatTheFocusedApp: AppHotKey?\n var unfloatTheFocusedApp: AppHotKey?\n var toggleTheFocusedAppFloating: AppHotKey?\n\n // Space Control\n var enableSpaceControl: Bool?\n var showSpaceControl: AppHotKey?\n var enableSpaceControlAnimations: Bool?\n var spaceControlCurrentDisplayWorkspaces: Bool?\n var spaceControlMaxColumns: Int?\n var enableWorkspaceTransitions: Bool?\n var workspaceTransitionDuration: Double?\n var workspaceTransitionDimming: Double?\n\n // Integrations\n var enableIntegrations: Bool?\n var runScriptOnLaunch: String?\n var runScriptOnWorkspaceChange: String?\n var runScriptOnProfileChange: String?\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/_Models/SettingsProtocol.swift", "//\n// SettingsProtocol.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\n\nprotocol SettingsProtocol {\n var updatePublisher: AnyPublisher<(), Never> { get }\n\n func load(from appSettings: AppSettings)\n func update(_ appSettings: inout AppSettings)\n}\n"], ["/FlashSpace/FlashSpace/Extensions/Collection.swift", "//\n// Collection.swift\n//\n// Created by Wojciech Kulik on 12/07/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nextension Collection {\n var isNotEmpty: Bool { !isEmpty }\n}\n\nextension Collection where Element: Hashable {\n var asSet: Set { Set(self) }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/View.swift", "//\n// View.swift\n//\n// Created by Wojciech Kulik on 25/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nextension View {\n func hotkey(_ title: String, for hotKey: Binding) -> some View {\n HStack {\n Text(title)\n Spacer()\n HotKeyControl(shortcut: hotKey).fixedSize()\n }\n }\n\n @ViewBuilder\n func hidden(_ isHidden: Bool) -> some View {\n if !isHidden {\n self\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Accessibility/AXUIElement+GetSet.swift", "//\n// AXUIElement+GetSet.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension AXUIElement {\n func getAttribute(_ attribute: NSAccessibility.Attribute) -> T? {\n var value: CFTypeRef?\n AXUIElementCopyAttributeValue(self, attribute as CFString, &value)\n\n return value as? T\n }\n\n func setAttribute(_ attribute: NSAccessibility.Attribute, value: some Any) {\n AXUIElementSetAttributeValue(self, attribute as CFString, value as CFTypeRef)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Models/UpdateWorkspaceRequest.swift", "//\n// UpdateWorkspaceRequest.swift\n//\n// Created by Wojciech Kulik on 02/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nstruct UpdateWorkspaceRequest: Codable {\n enum Display: Codable {\n case active\n case name(String)\n }\n\n let name: String?\n let display: Display?\n}\n"], ["/FlashSpace/FlashSpace/Features/HotKeys/Models/HotKeysMonitor.swift", "//\n// HotKeysMonitor.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ShortcutRecorder\n\nprotocol HotKeysMonitorProtocol: AnyObject {\n var actions: [ShortcutAction] { get }\n\n func addAction(_ anAction: ShortcutAction, forKeyEvent aKeyEvent: KeyEventType)\n func removeAction(_ anAction: ShortcutAction)\n func removeAllActions()\n}\n\nextension GlobalShortcutMonitor: HotKeysMonitorProtocol {}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Models/CommandResponse.swift", "//\n// CommandResponse.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nstruct CommandResponse: Codable {\n let success: Bool\n let message: String?\n let error: String?\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Models/CommandResponse.swift", "//\n// CommandResponse.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nstruct CommandResponse: Codable {\n var success: Bool\n var message: String?\n var error: String?\n}\n"], ["/FlashSpace/FlashSpace/Features/Config/Models/ConfigCoder.swift", "//\n// ConfigCoder.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nprotocol ConfigEncoder {\n func encode(_ value: some Encodable) throws -> Data\n}\n\nprotocol ConfigDecoder {\n func decode(_ type: T.Type, from data: Data) throws -> T where T: Decodable\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Models/CommandExecutor.swift", "//\n// CommandExecutor.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nprotocol CommandExecutor {\n func execute(command: CommandRequest) -> CommandResponse?\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Models/BufferWrapper.swift", "//\n// BufferWrapper.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nfinal class BufferWrapper {\n var data = Data()\n}\n"], ["/FlashSpace/FlashSpace/Features/Config/Models/JSONCoding.swift", "//\n// JSONCoding.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nextension JSONEncoder: ConfigEncoder {}\nextension JSONDecoder: ConfigDecoder {}\n"]], "task_instance_info": {"created_time": "2025-08-21 03:16:11", "created_task_model": "DeepSeek-R1", "function_skeleton": "func run ( ) throws { }", "code_description": "This code segment functions to: Retrieve and process a collection of active applications, sort them alphabetically, and generate formatted output based on user-specified formatting parameters while ensuring case-insensitive ordering and standardized output structure."}, "inference_content": {"inference_model": "DeepSeek-R1", "inference_result": "```swift\n[TASK_BEGIN]\n func run() throws {\n let runningApps = NSWorkspace.shared.runningApplications\n for app in runningApps {\n if let appName = app.localizedName {\n if withBundleId {\n let bundleId = app.bundleIdentifier ?? \"N/A\"\n print(\"\\(appName) \\(bundleId)\")\n } else {\n print(appName)\n }\n }\n }\n }\n[TASK_END]\n```", "inference_time": "2025-08-21 03-16-31"}, "editdistance_info": {"edit_distance": 23.7762, "calculate_time": "2025-08-21 03:16:31", "true_code_clean": "func run() throws {\n let apps = NSWorkspace.shared.runningApplications\n .filter { $0.activationPolicy == .regular }\n let result = Set(apps)\n .filter { $0.localizedName != nil }\n .map { (bundleId: $0.bundleIdentifier ?? \"-\", name: $0.localizedName ?? \"-\") }\n .sorted { $0.name.lowercased() < $1.name.lowercased() }\n .map { app in\n if withBundleId {\n return [app.name, app.bundleId].joined(separator: \",\")\n } else {\n return app.name\n }\n }\n .joined(separator: \"\\n\")\n print(result)\n }", "predict_code_clean": "func run() throws {\n let runningApps = NSWorkspace.shared.runningApplications\n for app in runningApps {\n if let appName = app.localizedName {\n if withBundleId {\n let bundleId = app.bundleIdentifier ?? \"N/A\"\n print(\"\\(appName) \\(bundleId)\")\n } else {\n print(appName)\n }\n }\n }\n }"}} {"repo_name": "FlashSpace", "file_name": "/FlashSpace/FlashSpace/Features/SpaceControl/Views/SpaceControlView.swift", "inference_info": {"prefix_code": "//\n// SpaceControlView.swift\n//\n// Created by Wojciech Kulik on 11/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct SpaceControlView: View {\n @Environment(\\.colorScheme) var colorScheme\n @StateObject var viewModel = SpaceControlViewModel()\n\n var body: some View {\n let columns = Array(repeating: GridItem(.flexible()), count: viewModel.numberOfColumns)\n let width = (NSScreen.main?.frame.width ?? 1200) / CGFloat(viewModel.numberOfColumns) - 70.0\n let height = (NSScreen.main?.frame.height ?? 800) / CGFloat(viewModel.numberOfRows) - 120.0\n\n LazyVGrid(columns: columns, spacing: viewModel.numberOfRows == 2 ? 90.0 : 60.0) {\n ForEach(viewModel.workspaces, id: \\.index) { workspace in\n VStack(alignment: .leading, spacing: 16.0) {\n workspaceName(workspace)\n\n Group {\n if let image = workspace.screenshotData.flatMap(NSImage.init(data:)) {\n workspacePreview(image: image, width: width, height: height)\n } else {\n workspacePlaceholder(width: width, height: height)\n }\n }\n .overlay(alignment: .topTrailing) { workspaceNumber(workspace.index + 1) }\n .overlay(\n RoundedRectangle(cornerRadius: 18.0)\n .stroke(\n workspace.isActive\n ? workspace.originalWorkspace.isOnTheCurrentScreen\n ? Color.positive\n : Color.teal\n : Color.black.opacity(0.8),\n lineWidth: 3.0\n )\n )\n .compositingGroup()\n .shadow(\n color: .black.opacity(workspace.screenshotData != nil ? 0.8 : 0.0),\n radius: 20.0,\n x: 0.0,\n y: 0.0\n )\n }\n .onTapGesture { viewModel.onWorkspaceTap(workspace) }\n }\n }\n .multilineTextAlignment(.center)\n .padding()\n .frame(maxWidth: .infinity, maxHeight: .infinity)\n }\n\n private func workspacePreview(image: NSImage, width: CGFloat, height: CGFloat) -> some View {\n Image(nsImage: image)\n .resizable()\n .scaledToFit()\n .frame(maxWidth: width, maxHeight: height)\n .aspectRatio(16.0 / 9.0, contentMode: .fit)\n .background(Color.black.opacity(0.4))\n .clipShape(RoundedRectangle(cornerRadius: 18.0))\n }\n\n ", "suffix_code": "\n\n private func workspaceName(_ workspace: SpaceControlWorkspace) -> some View {\n HStack(spacing: 16.0) {\n Image(systemName: workspace.symbol)\n .resizable()\n .scaledToFit()\n .frame(height: 17.0)\n .foregroundColor(colorScheme == .dark ? .workspaceIcon : .primary)\n\n Text(workspace.name)\n .foregroundColor(.primary)\n .font(.title2)\n }\n .fontWeight(.semibold)\n .lineLimit(1)\n .compositingGroup()\n .shadow(\n color: .black.opacity(colorScheme == .dark ? 0.8 : 0.25),\n radius: 4.0,\n x: 0.0,\n y: 0.0\n )\n }\n\n private func workspaceNumber(_ number: Int) -> some View {\n Text(\"\\(number)\")\n .foregroundColor(.white)\n .font(.title3)\n .frame(width: 40.0)\n .padding(.vertical, 8.0)\n .background(Color.black)\n .cornerRadius(18.0, corners: [.topRight])\n .cornerRadius(8.0, corners: [.bottomLeft])\n }\n}\n", "middle_code": "private func workspacePlaceholder(width: CGFloat, height: CGFloat) -> some View {\n RoundedRectangle(cornerRadius: 18.0)\n .fill(Color.black.opacity(0.5))\n .frame(maxWidth: width, maxHeight: height)\n .aspectRatio(16.0 / 9.0, contentMode: .fit)\n .overlay {\n Text(\"Preview Not Available\")\n .font(.title)\n .foregroundColor(.white)\n .padding()\n .frame(maxWidth: .infinity, maxHeight: .infinity)\n }\n .clipped()\n }", "code_description": null, "fill_type": "FUNCTION_TYPE", "language_type": "swift", "sub_task_type": null}, "context_code": [["/FlashSpace/FlashSpace/Features/MainScreen/WorkspaceConfigurationView.swift", "//\n// WorkspaceConfigurationView.swift\n//\n// Created by Wojciech Kulik on 20/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct WorkspaceConfigurationView: View {\n @Environment(\\.openWindow) var openWindow\n\n @ObservedObject var viewModel: MainViewModel\n @StateObject var profilesRepository = AppDependencies.shared.profilesRepository\n\n var body: some View {\n VStack(alignment: .leading, spacing: 0.0) {\n configuration\n\n if viewModel.workspaces.contains(where: { $0.apps.contains(where: \\.bundleIdentifier.isEmpty) }) {\n Text(\"Could not migrate some apps. Please re-add them to fix the problem. Please also check floating apps.\")\n .foregroundColor(.errorRed)\n }\n\n Spacer()\n profileAndSettings\n }\n }\n\n private var configuration: some View {\n VStack(alignment: .leading, spacing: 1.0) {\n Text(\"Workspace Configuration:\")\n .padding(.bottom, 16.0)\n .fixedSize()\n\n Text(\"Name:\")\n TextField(\"Name\", text: $viewModel.workspaceName)\n .onSubmit(viewModel.saveWorkspace)\n .padding(.bottom)\n\n Picker(\"Display:\", selection: $viewModel.workspaceDisplay) {\n ForEach(viewModel.screens, id: \\.self) {\n Text($0).tag($0)\n }\n }\n .padding(.bottom)\n .hidden(viewModel.displayMode == .dynamic)\n\n Picker(\"Focus App:\", selection: $viewModel.workspaceAppToFocus) {\n ForEach(viewModel.focusAppOptions, id: \\.self) {\n Text($0.name).tag($0)\n }\n }.padding(.bottom)\n\n HStack {\n Text(\"Menu Bar Icon:\")\n Button {\n viewModel.isSymbolPickerPresented = true\n } label: {\n Image(systemName: viewModel.workspaceSymbolIconName ?? .defaultIconSymbol)\n .frame(maxWidth: .infinity)\n }\n }.padding(.bottom)\n\n Text(\"Activate Shortcut:\")\n HotKeyControl(shortcut: $viewModel.workspaceShortcut).padding(.bottom)\n\n Text(\"Assign App Shortcut:\")\n HotKeyControl(shortcut: $viewModel.workspaceAssignShortcut).padding(.bottom)\n }\n .disabled(viewModel.selectedWorkspace == nil)\n }\n\n private var profileAndSettings: some View {\n HStack {\n Picker(\"Profile:\", selection: $profilesRepository.selectedProfile) {\n ForEach(profilesRepository.profiles) {\n Text($0.name).tag($0)\n }\n }\n\n Button(action: {\n openWindow(id: \"settings\")\n }, label: {\n Image(systemName: \"gearshape\")\n .foregroundColor(.primary)\n }).keyboardShortcut(\",\")\n }.frame(maxWidth: .infinity, alignment: .trailing)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/MainScreen/MainView.swift", "//\n// MainView.swift\n// FlashSpace\n//\n// Created by Wojciech Kulik on 19/01/2025.\n//\n\nimport AppKit\nimport SwiftUI\nimport SymbolPicker\n\nstruct MainView: View {\n @StateObject var viewModel = MainViewModel()\n\n var body: some View {\n HStack(spacing: 16.0) {\n workspaces\n assignedApps\n WorkspaceConfigurationView(viewModel: viewModel)\n .frame(maxWidth: 230)\n }\n .padding()\n .fixedSize()\n .sheet(isPresented: $viewModel.isInputDialogPresented) {\n InputDialog(\n title: \"Enter workspace name:\",\n userInput: $viewModel.userInput,\n isPresented: $viewModel.isInputDialogPresented\n )\n }\n .sheet(isPresented: $viewModel.isSymbolPickerPresented) {\n SymbolPicker(symbol: $viewModel.workspaceSymbolIconName)\n }\n }\n\n private var workspaces: some View {\n VStack(alignment: .leading) {\n Text(\"Workspaces:\")\n\n List(\n $viewModel.workspaces,\n id: \\.self,\n editActions: .move,\n selection: $viewModel.selectedWorkspaces\n ) { binding in\n WorkspaceCell(\n selectedApps: $viewModel.selectedApps,\n workspace: binding.wrappedValue\n )\n }\n .frame(width: 200, height: 350)\n\n HStack {\n Button(action: viewModel.addWorkspace) {\n Image(systemName: \"plus\")\n }\n\n Button(action: viewModel.deleteSelectedWorkspaces) {\n Image(systemName: \"trash\")\n }.disabled(viewModel.selectedWorkspaces.isEmpty)\n\n Spacer()\n }\n }\n }\n\n private var assignedApps: some View {\n VStack(alignment: .leading) {\n Text(\"Assigned Apps:\")\n\n List(\n viewModel.workspaceApps ?? [],\n id: \\.self,\n selection: $viewModel.selectedApps\n ) { app in\n AppCell(\n workspaceId: viewModel.selectedWorkspace?.id ?? UUID(),\n app: app\n )\n }\n .frame(width: 200, height: 350)\n\n HStack {\n Button(action: viewModel.addApp) {\n Image(systemName: \"plus\")\n }.disabled(viewModel.selectedWorkspace == nil)\n\n Button(action: viewModel.deleteSelectedApps) {\n Image(systemName: \"trash\")\n }\n .disabled(viewModel.selectedApps.isEmpty)\n .keyboardShortcut(.delete)\n }\n }\n }\n}\n\n#Preview {\n MainView()\n}\n"], ["/FlashSpace/FlashSpace/UI/Toast.swift", "//\n// Toast.swift\n//\n// Created by Wojciech Kulik on 28/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport SwiftUI\n\nenum Toast {\n weak static var toastWindow: NSWindow?\n\n static func showWith(icon: String, message: String, textColor: Color) {\n guard AppDependencies.shared.generalSettings.showFloatingNotifications else { return }\n\n if let window = toastWindow {\n window.orderOut(nil)\n toastWindow = nil\n }\n\n let contentView = NSHostingView(\n rootView: ToastView(\n icon: icon,\n message: message,\n textColor: textColor\n )\n )\n let size = contentView.fittingSize\n\n // contentRect is in screen coordinates where (0,0) is bottom-left corner\n // and it is relative to the main screen.\n let window = NSWindow(\n contentRect: NSRect(\n x: (NSScreen.main?.frame.midX ?? 200.0) - size.width / 2.0,\n y: (NSScreen.main?.frame.minY ?? 0.0) + (NSScreen.main?.frame.height ?? 0.0) * 0.07,\n width: size.width,\n height: size.height\n ),\n styleMask: [.borderless],\n backing: .buffered,\n defer: false\n )\n window.isOpaque = false\n window.backgroundColor = .clear\n window.level = .screenSaver\n toastWindow = window\n\n let visualEffectView = contentView.addVisualEffect(material: .sidebar, border: true)\n window.contentView = visualEffectView\n window.orderFrontRegardless()\n\n DispatchQueue.main.asyncAfter(deadline: .now() + 2.0) {\n NSAnimationContext.runAnimationGroup({ context in\n context.duration = 0.3\n window.animator().alphaValue = 0.0\n }, completionHandler: {\n window.orderOut(nil)\n })\n }\n }\n}\n\nstruct ToastView: View {\n let icon: String\n let message: String\n let textColor: Color\n\n var body: some View {\n HStack {\n Image(systemName: icon)\n .resizable()\n .scaledToFit()\n .frame(width: 26)\n\n Text(message)\n .font(.title)\n }\n .opacity(0.9)\n .padding()\n .padding(.horizontal)\n .fontWeight(.semibold)\n .foregroundStyle(textColor)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Workspaces/WorkspacesSettingsView.swift", "//\n// WorkspacesSettingsView.swift\n//\n// Created by Wojciech Kulik on 24/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct WorkspacesSettingsView: View {\n @StateObject var settings = AppDependencies.shared.workspaceSettings\n @StateObject var viewModel = WorkspaceSettingsViewModel()\n\n var body: some View {\n Form {\n Section(\"Displays\") {\n Picker(\"Display Assignment Mode\", selection: $settings.displayMode) {\n ForEach(DisplayMode.allCases) { action in\n Text(action.description).tag(action)\n }\n }\n\n Text(\"Static Mode requires you to manually assign workspaces to displays.\\n\\n\" +\n \"Dynamic Mode automatically assigns workspaces to displays \" +\n \"based on where your applications are located. In this mode, a single workspace can span across multiple displays.\"\n )\n .font(.callout)\n .foregroundStyle(.secondary)\n }\n\n Section(\"Behaviors\") {\n Toggle(\"Activate Workspace On Focus Change\", isOn: $settings.activeWorkspaceOnFocusChange)\n Toggle(\"Center Cursor In Focused App On Workspace Change\", isOn: $settings.centerCursorOnWorkspaceChange)\n Toggle(\"Automatically Change Workspace On App Assignment\", isOn: $settings.changeWorkspaceOnAppAssign)\n Toggle(\"Keep Unassigned Apps On Workspace Change\", isOn: $settings.keepUnassignedAppsOnSwitch)\n Toggle(\"Show Hidden Apps On Workspace Activation\", isOn: $settings.restoreHiddenAppsOnSwitch)\n .help(\"Restores hidden apps, even if they were hidden manually\")\n Toggle(\"Enable Workspace Transition Animation\", isOn: $settings.enableWorkspaceTransitions)\n .help(\"Show a brief visual transition effect when switching between workspaces\")\n\n if settings.enableWorkspaceTransitions {\n HStack {\n VStack(alignment: .leading) {\n Text(\"Transition Duration\")\n Text(\"Controls how long the transition animation lasts when switching workspaces\")\n .font(.caption)\n .foregroundStyle(.secondary)\n }\n Spacer()\n Slider(value: $settings.workspaceTransitionDuration, in: 0.1...0.5, step: 0.05)\n .frame(width: 150)\n Text(\"\\(settings.workspaceTransitionDuration, specifier: \"%.2f\")s\")\n .foregroundStyle(.secondary)\n .frame(width: 45.0, alignment: .trailing)\n }\n .padding(.leading, 16)\n\n HStack {\n VStack(alignment: .leading) {\n Text(\"Transition Dimming\")\n Text(\"Adjusts how dark the screen becomes during workspace transitions\")\n .font(.caption)\n .foregroundStyle(.secondary)\n }\n Spacer()\n Slider(value: $settings.workspaceTransitionDimming, in: 0.05...0.5, step: 0.05)\n .frame(width: 150)\n Text(\"\\(Int(settings.workspaceTransitionDimming * 100))%\")\n .foregroundStyle(.secondary)\n .frame(width: 45.0, alignment: .trailing)\n }\n .padding(.leading, 16)\n }\n }\n\n Section(\"Shortcuts\") {\n hotkey(\"Assign Visible Apps (to active workspace)\", for: $settings.assignVisibleApps)\n hotkey(\"Assign Focused App (to active workspace)\", for: $settings.assignFocusedApp)\n hotkey(\"Unassign Focused App\", for: $settings.unassignFocusedApp)\n hotkey(\"Toggle Focused App Assignment\", for: $settings.toggleFocusedAppAssignment)\n hotkey(\"Hide Unassigned Apps\", for: $settings.hideUnassignedApps)\n }\n\n Section {\n hotkey(\"Recent Workspace\", for: $settings.switchToRecentWorkspace)\n hotkey(\"Previous Workspace\", for: $settings.switchToPreviousWorkspace)\n hotkey(\"Next Workspace\", for: $settings.switchToNextWorkspace)\n Toggle(\"Loop Workspaces\", isOn: $settings.loopWorkspaces)\n Toggle(\"Skip Empty Workspaces On Switch\", isOn: $settings.skipEmptyWorkspacesOnSwitch)\n Text(\n \"These shortcuts allow you to cycle through workspaces on the display where the cursor is currently located.\"\n )\n .foregroundStyle(.secondary)\n .font(.callout)\n }\n\n Section {\n HStack {\n Text(\"Alternative Displays\")\n TextField(\"\", text: $settings.alternativeDisplays)\n .foregroundColor(.secondary)\n .standardPlaceholder(settings.alternativeDisplays.isEmpty)\n }\n\n Text(\n \"\"\"\n Example: DELL XYZ=Benq ABC;LG 123=DELL XYZ\n\n This setting is useful if you want to use the same configuration for different displays.\n You can tell FlashSpace which display should be used if the selected one is not connected.\n\n If only one display is connected, it will always act as the fallback.\n \"\"\"\n )\n .foregroundStyle(.secondary)\n .font(.callout)\n }\n .hidden(settings.displayMode == .dynamic)\n\n Section(\"Picture-in-Picture\") {\n Toggle(\"Enable Picture-in-Picture Support\", isOn: $settings.enablePictureInPictureSupport)\n Toggle(\"Switch Workspace When Picture-in-Picture Closes\", isOn: $settings.switchWorkspaceWhenPipCloses)\n\n HStack {\n Text(\"Screen Corner Offset\")\n Spacer()\n Text(\"\\(settings.pipScreenCornerOffset)\")\n Stepper(\n \"\",\n value: $settings.pipScreenCornerOffset,\n in: 1...50,\n step: 1\n ).labelsHidden()\n }\n\n Text(\n \"If a supported browser has Picture-in-Picture active, other \" +\n \"windows will be hidden in a screen corner to keep PiP visible.\"\n )\n .foregroundStyle(.secondary)\n .font(.callout)\n }\n\n Section(header: pipAppsHeader) {\n if settings.pipApps.isEmpty {\n Text(\"You can apply Picture-in-Picture behavior to any app by adding it here.\")\n .foregroundStyle(.secondary)\n .font(.callout)\n } else {\n pipAppsList\n }\n }\n .opacity(settings.enablePictureInPictureSupport ? 1 : 0.5)\n }\n .sheet(isPresented: $viewModel.isInputDialogPresented) {\n InputDialog(\n title: \"Enter PiP window title regex:\",\n placeholder: \"e.g. Meeting with.*\",\n userInput: $viewModel.windowTitleRegex,\n isPresented: $viewModel.isInputDialogPresented\n )\n }\n .formStyle(.grouped)\n .navigationTitle(\"Workspaces\")\n }\n\n private var pipAppsList: some View {\n VStack(alignment: .leading) {\n ForEach(settings.pipApps, id: \\.self) { app in\n HStack {\n Button {\n viewModel.deletePipApp(app)\n } label: {\n Image(systemName: \"x.circle.fill\").opacity(0.8)\n }.buttonStyle(.borderless)\n\n Text(app.name)\n Spacer()\n Text(app.pipWindowTitleRegex)\n .foregroundColor(.secondary)\n }\n }\n }\n }\n\n private var pipAppsHeader: some View {\n HStack {\n Text(\"Custom Picture-in-Picture Apps\")\n Spacer()\n Button {\n viewModel.addPipApp()\n } label: {\n Image(systemName: \"plus\")\n }\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/MainScreen/WorkspaceCell.swift", "//\n// WorkspaceCell.swift\n//\n// Created by Wojciech Kulik on 20/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\nimport UniformTypeIdentifiers\n\nstruct WorkspaceCell: View {\n @State var isTargeted = false\n @Binding var selectedApps: Set\n\n let workspaceManager: WorkspaceManager = AppDependencies.shared.workspaceManager\n let workspaceRepository: WorkspaceRepository = AppDependencies.shared.workspaceRepository\n\n let workspace: Workspace\n\n var body: some View {\n HStack {\n Image(systemName: workspace.symbolIconName ?? .defaultIconSymbol)\n .resizable()\n .scaledToFit()\n .frame(width: 15, height: 15)\n .foregroundStyle(Color.workspaceIcon)\n\n Text(workspace.name)\n .lineLimit(1)\n .foregroundColor(\n isTargeted || workspace.apps.contains(where: \\.bundleIdentifier.isEmpty)\n ? .errorRed\n : .primary\n )\n Spacer()\n }\n .contentShape(Rectangle())\n .dropDestination(for: MacAppWithWorkspace.self) { apps, _ in\n guard let sourceWorkspaceId = apps.first?.workspaceId else { return false }\n\n workspaceRepository.moveApps(\n apps.map(\\.app),\n from: sourceWorkspaceId,\n to: workspace.id\n )\n selectedApps = []\n\n workspaceManager.activateWorkspaceIfActive(sourceWorkspaceId)\n workspaceManager.activateWorkspaceIfActive(workspace.id)\n\n return true\n } isTargeted: {\n isTargeted = $0\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/SpaceControl/Views/SpaceControlViewModel.swift", "//\n// SpaceControlViewModel.swift\n//\n// Created by Wojciech Kulik on 11/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport SwiftUI\n\nstruct SpaceControlWorkspace {\n let index: Int\n let name: String\n let symbol: String\n let screenshotData: Data?\n let isActive: Bool\n let originalWorkspace: Workspace\n}\n\nfinal class SpaceControlViewModel: ObservableObject {\n @Published private(set) var workspaces: [SpaceControlWorkspace] = []\n @Published private(set) var numberOfRows = 0\n @Published private(set) var numberOfColumns = 0\n\n private var cancellables = Set()\n\n private let settings = AppDependencies.shared.spaceControlSettings\n private let workspaceRepository = AppDependencies.shared.workspaceRepository\n private let workspaceManager = AppDependencies.shared.workspaceManager\n private let screenshotManager = AppDependencies.shared.workspaceScreenshotManager\n private let displayManager = AppDependencies.shared.displayManager\n\n init() {\n refresh()\n\n NotificationCenter.default\n .publisher(for: .spaceControlArrowDown)\n .compactMap { $0.object as? RawKeyCode }\n .sink { [weak self] in self?.handleArrowKey($0) }\n .store(in: &cancellables)\n }\n\n func onWorkspaceTap(_ workspace: SpaceControlWorkspace) {\n workspaceManager.activateWorkspace(workspace.originalWorkspace, setFocus: true)\n }\n\n func refresh() {\n let activeWorkspaceIds = workspaceManager.activeWorkspace.map(\\.value.id).asSet\n let mainDisplay = NSScreen.main?.localizedName ?? \"\"\n\n workspaces = Array(\n workspaceRepository.workspaces\n .filter { !settings.spaceControlCurrentDisplayWorkspaces || $0.isOnTheCurrentScreen }\n .prefix(15)\n .enumerated()\n .map {\n let workspace = $0.element\n let displayName = settings.spaceControlCurrentDisplayWorkspaces\n ? mainDisplay\n : self.mainDisplay(for: workspace)\n let key = WorkspaceScreenshotManager.ScreenshotKey(\n displayName: displayName,\n workspaceID: workspace.id\n )\n return SpaceControlWorkspace(\n index: $0.offset,\n name: workspace.name,\n symbol: workspace.symbolIconName ?? .defaultIconSymbol,\n screenshotData: screenshotManager.screenshots[key],\n isActive: activeWorkspaceIds.contains(workspace.id),\n originalWorkspace: workspace\n )\n }\n )\n calculateColsAndRows(workspaces.count)\n }\n\n private func mainDisplay(for workspace: Workspace) -> DisplayName {\n let workspaceDisplays = workspace.displays\n\n return workspaceDisplays.count == 1\n ? workspaceDisplays.first!\n : displayManager.lastActiveDisplay(from: workspaceDisplays)\n }\n\n private func calculateColsAndRows(_ workspaceCount: Int) {\n let maxNumberOfRows = 3.0\n\n numberOfColumns = workspaceCount <= 3\n ? workspaceCount\n : max(3, Int(ceil(Double(workspaceCount) / maxNumberOfRows)))\n numberOfColumns = min(numberOfColumns, settings.spaceControlMaxColumns)\n\n numberOfRows = Int(ceil(Double(workspaceCount) / Double(numberOfColumns)))\n }\n\n private func handleArrowKey(_ keyCode: RawKeyCode) {\n let activeWorkspaceIndex = workspaces.firstIndex {\n $0.isActive && $0.originalWorkspace.isOnTheCurrentScreen\n }\n guard let activeWorkspaceIndex else { return }\n\n let workspace: Workspace? = switch KeyCodesMap.toString[keyCode] {\n case \"down\":\n workspaces[safe: activeWorkspaceIndex + numberOfColumns]?.originalWorkspace\n case \"up\":\n workspaces[safe: activeWorkspaceIndex - numberOfColumns]?.originalWorkspace\n case \"right\":\n workspaces[safe: (activeWorkspaceIndex + 1) % workspaces.count]?.originalWorkspace\n case \"left\":\n workspaces[\n safe: activeWorkspaceIndex == 0\n ? workspaces.count - 1\n : activeWorkspaceIndex - 1\n ]?.originalWorkspace\n default:\n nil\n }\n\n if let workspace {\n SpaceControl.hide()\n workspaceManager.activateWorkspace(workspace, setFocus: true)\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/SpaceControl/SpaceControlSettingsView.swift", "//\n// SpaceControlSettingsView.swift\n//\n// Created by Wojciech Kulik on 11/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct SpaceControlSettingsView: View {\n @StateObject var settings = AppDependencies.shared.spaceControlSettings\n @State var hasScreenRecordingPermissions = false\n\n var body: some View {\n Form {\n Section {\n Toggle(\"Enable Space Control\", isOn: $settings.enableSpaceControl)\n }\n\n Group {\n Section(\"Permissions\") {\n HStack {\n if hasScreenRecordingPermissions {\n Image(systemName: \"checkmark.circle.fill\")\n .foregroundColor(.green)\n Text(\"Screen Recording Permission\")\n Spacer()\n } else {\n Image(systemName: \"xmark.circle.fill\")\n .foregroundColor(.red)\n Text(\"Screen Recording Permission\")\n Spacer()\n Button(\"Open Privacy & Security\") {\n NSWorkspace.shared.open(\n URL(string: \"x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture\")!\n )\n }\n }\n }\n Text(\n \"FlashSpace requires screen recording access to show your workspaces in Space Control. \" +\n \"The preview will be displayed upon first activation of the workspace.\"\n )\n .foregroundColor(.secondary)\n .font(.callout)\n }\n\n Section(\"Shortcuts\") {\n hotkey(\"Toggle Space Control\", for: $settings.showSpaceControl)\n }\n\n Section(\"Appearance\") {\n Toggle(\"Enable Animations\", isOn: $settings.enableSpaceControlAnimations)\n Toggle(\n \"Show Workspaces For Current Display Only\",\n isOn: $settings.spaceControlCurrentDisplayWorkspaces\n )\n\n HStack {\n Text(\"Max Number Of Columns\")\n Spacer()\n Text(\"\\(settings.spaceControlMaxColumns)\")\n Stepper(\n \"\",\n value: $settings.spaceControlMaxColumns,\n in: 2...20,\n step: 1\n ).labelsHidden()\n }\n }\n }\n .disabled(!settings.enableSpaceControl)\n .opacity(settings.enableSpaceControl ? 1 : 0.5)\n }\n .onAppear {\n hasScreenRecordingPermissions = PermissionsManager.shared.checkForScreenRecordingPermissions()\n }\n .onReceive(NotificationCenter.default.publisher(for: NSApplication.didBecomeActiveNotification)) { _ in\n hasScreenRecordingPermissions = PermissionsManager.shared.checkForScreenRecordingPermissions()\n }\n .formStyle(.grouped)\n .navigationTitle(\"Space Control\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/MainScreen/AppCell.swift", "//\n// AppCell.swift\n//\n// Created by Wojciech Kulik on 20/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct AppCell: View {\n let workspaceId: WorkspaceID\n let app: MacApp\n\n var body: some View {\n HStack {\n if let iconPath = app.iconPath, let image = NSImage(byReferencingFile: iconPath) {\n Image(nsImage: image)\n .resizable()\n .scaledToFit()\n .frame(width: 20, height: 20)\n }\n Text(app.name)\n .foregroundColor(app.bundleIdentifier.isEmpty ? .errorRed : .primary)\n }\n .draggable(MacAppWithWorkspace(app: app, workspaceId: workspaceId))\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/SpaceControl/WorkspaceScreenshotManager.swift", "//\n// WorkspaceScreenshotManager.swift\n//\n// Created by Wojciech Kulik on 11/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Combine\nimport CoreGraphics\nimport ScreenCaptureKit\nimport SwiftUI\n\nfinal class WorkspaceScreenshotManager {\n typealias ImageData = Data\n\n struct ScreenshotKey: Hashable {\n let displayName: DisplayName\n let workspaceID: WorkspaceID\n }\n\n private(set) var screenshots: [ScreenshotKey: ImageData] = [:]\n private var cancellables = Set()\n\n private let lock = NSLock()\n\n init() {\n observe()\n }\n\n func captureWorkspace(_ workspace: Workspace, displayName: DisplayName) async {\n let shouldCapture = await MainActor.run {\n !SpaceControl.isVisible &&\n SpaceControl.isEnabled &&\n PermissionsManager.shared.checkForScreenRecordingPermissions()\n }\n\n guard shouldCapture else { return }\n\n do {\n let availableContent = try await SCShareableContent.excludingDesktopWindows(false, onScreenWindowsOnly: false)\n let display = await MainActor.run {\n availableContent.displays.first { $0.frame.getDisplay() == displayName }\n }\n\n guard let display else { return }\n\n let filter = SCContentFilter(display: display, excludingWindows: [])\n let config = SCStreamConfiguration()\n config.captureResolution = .best\n config.width = Int(display.frame.width)\n config.height = Int(display.frame.height)\n config.showsCursor = false\n\n let screenshot = try await SCScreenshotManager.captureSampleBuffer(\n contentFilter: filter,\n configuration: config\n )\n\n if let image = imageFromSampleBuffer(screenshot) {\n let key = ScreenshotKey(\n displayName: displayName,\n workspaceID: workspace.id\n )\n saveScreenshot(image, workspace: workspace, key: key)\n }\n } catch {\n Logger.log(error)\n }\n }\n\n private func imageFromSampleBuffer(_ buffer: CMSampleBuffer) -> NSImage? {\n guard let imageBuffer = CMSampleBufferGetImageBuffer(buffer) else { return nil }\n\n let ciImage = CIImage(cvImageBuffer: imageBuffer)\n let representation = NSCIImageRep(ciImage: ciImage)\n let nsImage = NSImage(size: representation.size)\n nsImage.addRepresentation(representation)\n\n return nsImage\n }\n\n private func saveScreenshot(_ image: NSImage, workspace: Workspace, key: ScreenshotKey) {\n let newSize = CGSize(\n width: 1400.0,\n height: (1400.0 / image.size.width) * image.size.height\n )\n let newImage = NSImage(size: newSize)\n let rect = NSRect(origin: .zero, size: newSize)\n\n newImage.lockFocus()\n image.draw(in: rect)\n newImage.unlockFocus()\n\n guard let resizedData = newImage.tiffRepresentation,\n let imageRepresentation = NSBitmapImageRep(data: resizedData),\n let jpegData = imageRepresentation.representation(using: .jpeg, properties: [:])\n else { return }\n\n lock.lock()\n screenshots[key] = jpegData\n lock.unlock()\n }\n\n private func observe() {\n NotificationCenter.default\n .publisher(for: .workspaceTransitionFinished)\n .compactMap { $0.object as? Workspace }\n .sink { [weak self] workspace in\n for display in workspace.displays {\n Task.detached { [weak self] in\n await self?.captureWorkspace(workspace, displayName: display)\n }\n }\n }\n .store(in: &cancellables)\n\n NotificationCenter.default\n .publisher(for: .profileChanged)\n .sink { [weak self] _ in\n self?.screenshots = [:]\n }\n .store(in: &cancellables)\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/TextField.swift", "//\n// TextField.swift\n//\n// Created by Wojciech Kulik on 08/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct PlaceholderModifier: ViewModifier {\n @FocusState private var isFocused: Bool\n @Environment(\\.isEnabled) private var isEnabled\n\n let placeholder: String\n let visible: Bool\n\n func body(content: Content) -> some View {\n ZStack(alignment: .leading) {\n if visible, !isFocused {\n Text(placeholder)\n .foregroundColor(.secondary)\n .allowsHitTesting(false)\n .frame(maxWidth: .infinity, alignment: .trailing)\n .opacity(isEnabled ? 1 : 0.5)\n }\n content\n .focused($isFocused)\n }\n }\n}\n\nextension View {\n func placeholder(_ placeholder: String, visible: Bool) -> some View {\n modifier(PlaceholderModifier(placeholder: placeholder, visible: visible))\n }\n\n func standardPlaceholder(_ visible: Bool) -> some View {\n placeholder(\"(type here)\", visible: visible)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/SettingsView.swift", "//\n// SettingsView.swift\n//\n// Created by Wojciech Kulik on 23/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct SettingsView: View {\n @State private var selectedTab = \"General\"\n\n var body: some View {\n NavigationSplitView(columnVisibility: .constant(.doubleColumn), sidebar: {\n sideMenu\n .frame(width: 200)\n .navigationSplitViewColumnWidth(200.0)\n }, detail: {\n details\n .frame(maxHeight: .infinity, alignment: .top)\n .navigationSplitViewColumnWidth(min: 440, ideal: 440)\n })\n .frame(width: 780, height: 490)\n }\n\n private var sideMenu: some View {\n VStack {\n List(selection: $selectedTab) {\n Label(\"General\", systemImage: \"gearshape\")\n .tag(\"General\")\n Label(\"Menu Bar\", systemImage: \"contextualmenu.and.cursorarrow\")\n .tag(\"MenuBar\")\n Label(\"Gestures\", systemImage: \"hand.draw\")\n .tag(\"Gestures\")\n Label(\"Workspaces\", systemImage: \"square.stack.3d.up\")\n .tag(\"Workspaces\")\n Label(\"Floating Apps\", systemImage: \"pip\")\n .tag(\"FloatingApps\")\n Label(\"Focus Manager\", systemImage: \"macwindow.on.rectangle\")\n .tag(\"Focus\")\n Label(\"Space Control\", systemImage: \"rectangle.split.2x2\")\n .tag(\"SpaceControl\")\n Label(\"Profiles\", systemImage: \"person.2\")\n .tag(\"Profiles\")\n Label(\"Integrations\", systemImage: \"link\")\n .tag(\"Integrations\")\n Label(\"Configuration File\", systemImage: \"doc.text\")\n .tag(\"Configuration\")\n Label(\"CLI\", systemImage: \"apple.terminal\")\n .tag(\"CLI\")\n Label(\"Acknowledgements\", systemImage: \"info.circle\")\n .tag(\"Acknowledgements\")\n Label(\"About\", systemImage: \"person\")\n .tag(\"About\")\n }\n .toolbar(removing: .sidebarToggle)\n .listStyle(.sidebar)\n\n Spacer()\n\n Text(\"FlashSpace v\\(AppConstants.version)\")\n .foregroundStyle(.secondary)\n .padding(.bottom)\n }\n }\n\n @ViewBuilder\n private var details: some View {\n switch selectedTab {\n case \"General\":\n GeneralSettingsView()\n case \"MenuBar\":\n MenuBarSettingsView()\n case \"Focus\":\n FocusSettingsView()\n case \"Gestures\":\n GesturesSettingsView()\n case \"Workspaces\":\n WorkspacesSettingsView()\n case \"FloatingApps\":\n FloatingAppsSettingsView()\n case \"SpaceControl\":\n SpaceControlSettingsView()\n case \"Integrations\":\n IntegrationsSettingsView()\n case \"Profiles\":\n ProfilesSettingsView()\n case \"Configuration\":\n ConfigurationFileSettingsView()\n case \"CLI\":\n CLISettingsView()\n case \"Acknowledgements\":\n AcknowledgementsSettingsView()\n case \"About\":\n AboutSettingsView()\n default:\n EmptyView()\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/FloatingApps/FloatingAppsSettingsView.swift", "//\n// FloatingAppsSettingsView.swift\n//\n// Created by Wojciech Kulik on 12/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct FloatingAppsSettingsView: View {\n @StateObject var viewModel = FloatingAppsSettingsViewModel()\n @StateObject var settings = AppDependencies.shared.floatingAppsSettings\n\n var body: some View {\n Form {\n Section(header: header) {\n if settings.floatingApps.contains(where: \\.bundleIdentifier.isEmpty) {\n Text(\"Could not migrate some apps. Please re-add them to fix the problem.\")\n .foregroundStyle(.errorRed)\n .font(.callout)\n }\n\n if settings.floatingApps.isEmpty {\n Text(\"(no floating apps added)\")\n .foregroundStyle(.secondary)\n .font(.callout)\n } else {\n appsList\n }\n\n Text(\"Floating applications remain visible across all workspaces.\")\n .foregroundStyle(.secondary)\n .font(.callout)\n }\n\n Section(\"Shortcuts\") {\n hotkey(\"Float Focused App\", for: $settings.floatTheFocusedApp)\n hotkey(\"Unfloat Focused App\", for: $settings.unfloatTheFocusedApp)\n hotkey(\"Toggle Focused App Floating\", for: $settings.toggleTheFocusedAppFloating)\n }\n }\n .formStyle(.grouped)\n .navigationTitle(\"Floating Apps\")\n }\n\n private var appsList: some View {\n VStack(alignment: .leading) {\n ForEach(settings.floatingApps, id: \\.self) { app in\n HStack {\n Button {\n viewModel.deleteFloatingApp(app: app)\n } label: {\n Image(systemName: \"x.circle.fill\").opacity(0.8)\n }.buttonStyle(.borderless)\n\n Text(app.name)\n .foregroundStyle(app.bundleIdentifier.isEmpty ? .errorRed : .primary)\n }\n }\n }\n }\n\n private var header: some View {\n HStack {\n Text(\"Floating Apps\")\n Spacer()\n Button(action: viewModel.addFloatingApp) {\n Image(systemName: \"plus\")\n }\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/MenuBar/FlashSpaceMenuBar.swift", "//\n// FlashSpaceMenuBar.swift\n//\n// Created by Wojciech Kulik on 13/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct FlashSpaceMenuBar: Scene {\n @Environment(\\.openWindow) private var openWindow\n\n @StateObject private var workspaceManager = AppDependencies.shared.workspaceManager\n @StateObject private var settingsRepository = AppDependencies.shared.settingsRepository\n @StateObject private var profilesRepository = AppDependencies.shared.profilesRepository\n @StateObject private var workspaceRepository = AppDependencies.shared.workspaceRepository\n\n var body: some Scene {\n MenuBarExtra {\n Text(\"FlashSpace v\\(AppConstants.version)\")\n\n Button(\"Open\") {\n openWindow(id: \"main\")\n NSApp.activate(ignoringOtherApps: true)\n }\n\n if settingsRepository.spaceControlSettings.enableSpaceControl {\n Button(\"Space Control\") {\n SpaceControl.show()\n }\n }\n\n Divider()\n\n Button(\"Settings\") {\n openWindow(id: \"settings\")\n NSApp.activate(ignoringOtherApps: true)\n }.keyboardShortcut(\",\")\n\n Menu(\"Profiles\") {\n ForEach(profilesRepository.profiles) { profile in\n Toggle(\n profile.name,\n isOn: .init(\n get: { profilesRepository.selectedProfile == profile },\n set: {\n if $0 { profilesRepository.selectedProfile = profile }\n }\n )\n )\n }\n }.hidden(profilesRepository.profiles.count < 2)\n\n Menu(\"Workspaces\") {\n ForEach(workspaceRepository.workspaces) { workspace in\n Button {\n if workspace.isDynamic, workspace.displays.isEmpty {\n Toast.showWith(\n icon: \"square.stack.3d.up\",\n message: \"\\(workspace.name) - No Running Apps To Show\",\n textColor: .gray\n )\n } else {\n workspaceManager.activateWorkspace(workspace, setFocus: true)\n }\n } label: {\n Text(workspace.name)\n }\n .keyboardShortcut(workspace.activateShortcut?.toKeyboardShortcut)\n }\n }.hidden(workspaceRepository.workspaces.count < 2)\n\n Divider()\n\n Button(\"Donate\") {\n if let url = URL(string: \"https://github.com/sponsors/wojciech-kulik\") {\n NSWorkspace.shared.open(url)\n }\n }\n\n Button(\"Project Website\") {\n if let url = URL(string: \"https://github.com/wojciech-kulik/FlashSpace\") {\n NSWorkspace.shared.open(url)\n }\n }\n\n Button(\"Check for Updates\") {\n UpdatesManager.shared.checkForUpdates()\n }\n\n Divider()\n\n Button(\"Quit\") {\n NSApp.terminate(nil)\n }.keyboardShortcut(\"q\")\n } label: {\n HStack {\n let title = MenuBarTitle.get()\n if title == nil || settingsRepository.menuBarSettings.showMenuBarIcon {\n Image(systemName: workspaceManager.activeWorkspaceDetails?.symbolIconName ?? .defaultIconSymbol)\n }\n if let title { Text(title) }\n }\n .id(settingsRepository.menuBarSettings.menuBarTitleTemplate)\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/UI/InputDialog.swift", "//\n// InputDialog.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct InputDialog: View {\n let title: String\n var placeholder = \"Type here...\"\n\n @Binding var userInput: String\n @Binding var isPresented: Bool\n\n var body: some View {\n VStack(alignment: .leading, spacing: 4.0) {\n Text(title)\n .font(.headline)\n\n TextField(placeholder, text: $userInput)\n .textFieldStyle(RoundedBorderTextFieldStyle())\n .padding(.vertical, 8.0)\n .onSubmit { isPresented = false }\n\n HStack {\n Spacer()\n Button(\"Cancel\") {\n userInput = \"\"\n isPresented = false\n }\n Button(\"OK\") { isPresented = false }\n }\n }\n .padding()\n .frame(width: 300, height: 110)\n .onKeyPress(.escape) {\n userInput = \"\"\n isPresented = false\n return .handled\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Profiles/ProfilesSettingsView.swift", "//\n// ProfilesSettingsView.swift\n//\n// Created by Wojciech Kulik on 26/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct ProfilesSettingsView: View {\n @StateObject var viewModel = ProfilesSettingsViewModel()\n @StateObject var profilesRepository = AppDependencies.shared.profilesRepository\n\n var body: some View {\n Form {\n Section(\n header: HStack {\n Text(\"Profiles\")\n Spacer()\n Button {\n viewModel.createNewProfile()\n } label: {\n Image(systemName: \"plus\")\n }\n }\n ) {\n VStack(alignment: .leading) {\n ForEach(profilesRepository.profiles) { profile in\n HStack {\n Button {\n viewModel.deleteProfile(profile)\n } label: {\n Image(systemName: \"x.circle.fill\").opacity(0.8)\n }\n .buttonStyle(.borderless)\n .hidden(viewModel.hideDeleteButton)\n\n Button {\n viewModel.renameProfile(profile)\n } label: {\n Text(profile.name)\n }\n .buttonStyle(.borderless)\n .tint(.primary)\n }\n }\n }\n }\n }\n .formStyle(.grouped)\n .sheet(isPresented: $viewModel.isInputDialogPresented) {\n InputDialog(\n title: \"Enter profile name:\",\n userInput: $viewModel.userInput,\n isPresented: $viewModel.isInputDialogPresented\n )\n }\n .alert(\n \"Are you sure you want to delete \\\"\\(viewModel.profileToDelete)\\\" profile?\",\n isPresented: $viewModel.isDeleteConfirmationPresented\n ) {\n Button(\"Delete\", role: .destructive) {\n viewModel.deleteConfirmed()\n }\n Button(\"Cancel\", role: .cancel) {}\n } message: {\n Text(\"This action cannot be undone.\")\n }\n .alert(\n \"Do you want to copy the current workspaces to the new profile?\",\n isPresented: $viewModel.isCopyChoicePresented\n ) {\n Button(\"Copy\") { viewModel.createNewProfile(copyWorkspaces: true) }\n Button(\"No\", role: .cancel) { viewModel.createNewProfile(copyWorkspaces: false) }\n }\n .onChange(of: viewModel.isInputDialogPresented) { _, isPresented in\n if !isPresented {\n viewModel.inputDialogDismissed()\n }\n }\n .navigationTitle(\"Profiles\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/CLI/CLISettingsView.swift", "//\n// CLISettingsView.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct CLISettingsView: View {\n @State var isInstalled = false\n @State var isRunning = false\n\n var body: some View {\n Form {\n Section(\"Status\") {\n HStack {\n if isRunning {\n Image(systemName: \"checkmark.circle.fill\")\n .foregroundColor(.green)\n Text(\"FlashSpace CLI Status\")\n Spacer()\n } else {\n Image(systemName: \"xmark.circle.fill\")\n .foregroundColor(.red)\n\n Text(\"FlashSpace CLI Status\")\n Spacer()\n Button(\"Restart\") {\n AppDependencies.shared.cliServer.restart()\n isRunning = AppDependencies.shared.cliServer.isRunning\n }\n }\n }\n\n HStack {\n if isInstalled {\n Image(systemName: \"checkmark.circle.fill\")\n .foregroundColor(.green)\n Text(\"FlashSpace CLI Installation\")\n Spacer()\n Button(\"Uninstall FlashSpace CLI\") {\n CLI.uninstall()\n isInstalled = CLI.isInstalled\n }\n } else {\n Image(systemName: \"xmark.circle.fill\")\n .foregroundColor(.red)\n Text(\"FlashSpace CLI Installation\")\n Spacer()\n Button(\"Install FlashSpace CLI\") {\n CLI.install()\n isInstalled = CLI.isInstalled\n }\n }\n }\n\n VStack(alignment: .leading) {\n Text(\n \"\"\"\n Tool will be installed in /usr/local/bin/flashspace.\n\n You can also access it directly from the app bundle at:\n \"\"\"\n )\n Text(CLI.cliPath)\n .lineLimit(1)\n .truncationMode(.middle)\n .help(CLI.cliPath)\n }\n .foregroundColor(.secondary)\n .font(.callout)\n }\n\n Section {\n Text(\"Run `flashspace --help` in the terminal to see the available commands.\")\n .foregroundStyle(.secondary)\n .font(.callout)\n }\n }\n .onAppear {\n isInstalled = CLI.isInstalled\n isRunning = AppDependencies.shared.cliServer.isRunning\n }\n .formStyle(.grouped)\n .navigationTitle(\"CLI\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/CornerRadius.swift", "//\n// CornerRadius.swift\n//\n// Created by Wojciech Kulik on 11/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport SwiftUI\n\nstruct RoundedCorners: Shape {\n var radius: CGFloat\n var corners: [Corner]\n\n enum Corner {\n case topLeft, topRight, bottomLeft, bottomRight\n }\n\n func path(in rect: CGRect) -> Path {\n var path = Path()\n\n let topLeft = corners.contains(.topLeft) ? radius : 0\n let topRight = corners.contains(.topRight) ? radius : 0\n let bottomLeft = corners.contains(.bottomLeft) ? radius : 0\n let bottomRight = corners.contains(.bottomRight) ? radius : 0\n\n path.move(to: CGPoint(x: rect.minX, y: rect.midY))\n\n path.addArc(\n center: CGPoint(x: rect.minX + topLeft, y: rect.minY + topLeft),\n radius: topLeft,\n startAngle: .degrees(180),\n endAngle: .degrees(270),\n clockwise: false\n )\n\n path.addArc(\n center: CGPoint(x: rect.maxX - topRight, y: rect.minY + topRight),\n radius: topRight,\n startAngle: .degrees(270),\n endAngle: .degrees(0),\n clockwise: false\n )\n\n path.addArc(\n center: CGPoint(x: rect.maxX - bottomRight, y: rect.maxY - bottomRight),\n radius: bottomRight,\n startAngle: .degrees(0),\n endAngle: .degrees(90),\n clockwise: false\n )\n\n path.addArc(\n center: CGPoint(x: rect.minX + bottomLeft, y: rect.maxY - bottomLeft),\n radius: bottomLeft,\n startAngle: .degrees(90),\n endAngle: .degrees(180),\n clockwise: false\n )\n\n path.closeSubpath()\n return path\n }\n}\n\nextension View {\n func cornerRadius(_ radius: CGFloat, corners: [RoundedCorners.Corner]) -> some View {\n clipShape(RoundedCorners(radius: radius, corners: corners))\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Gestures/SwipeManager.swift", "//\n// SwipeManager.swift\n//\n// Created by Wojciech Kulik on 22/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n// Based on: https://github.com/MediosZ/SwipeAeroSpace\n\nimport AppKit\nimport Combine\n\nfinal class SwipeManager {\n typealias TouchId = ObjectIdentifier\n\n enum Constants {\n static let minFingerCount = 3\n static let maxFingerCount = 4\n }\n\n enum GestureState {\n case idle\n case inProgress\n case ended\n }\n\n static let shared = SwipeManager()\n\n private var swipeThreshold: Double { gesturesSettings.swipeThreshold }\n\n private var eventTap: CFMachPort?\n private var xTouchDistance: [TouchId: CGFloat] = [:]\n private var yTouchDistance: [TouchId: CGFloat] = [:]\n private var prevTouchPositions: [TouchId: NSPoint] = [:]\n private var lastTouchDate = Date.distantPast\n private var state: GestureState = .ended\n private var systemWakeUpObserver: AnyCancellable?\n\n private lazy var gesturesSettings = AppDependencies.shared.gesturesSettings\n private lazy var workspaceSettings = AppDependencies.shared.workspaceSettings\n private lazy var workspaceManager = AppDependencies.shared.workspaceManager\n private lazy var workspaceRepository = AppDependencies.shared.workspaceRepository\n private lazy var focusManager = AppDependencies.shared.focusManager\n\n func start() {\n guard eventTap == nil else {\n return Logger.log(\"SwipeManager is already started\")\n }\n\n eventTap = CGEvent.tapCreate(\n tap: .cghidEventTap,\n place: .headInsertEventTap,\n options: .defaultTap,\n eventsOfInterest: NSEvent.EventTypeMask.gesture.rawValue,\n callback: { proxy, type, cgEvent, userInfo in\n SwipeManager.shared.eventHandler(\n proxy: proxy,\n eventType: type,\n cgEvent: cgEvent,\n userInfo: userInfo\n )\n },\n userInfo: nil\n )\n\n guard let eventTap else {\n return Logger.log(\"SwipeManager couldn't create event tap\")\n }\n\n Logger.log(\"SwipeManager started\")\n\n let runLoopSource = CFMachPortCreateRunLoopSource(nil, eventTap, 0)\n CFRunLoopAddSource(\n CFRunLoopGetCurrent(),\n runLoopSource,\n CFRunLoopMode.commonModes\n )\n CGEvent.tapEnable(tap: eventTap, enable: true)\n\n observeSystemWakeUp()\n }\n\n func stop() {\n guard let eventTap else { return }\n\n CGEvent.tapEnable(tap: eventTap, enable: false)\n CFRunLoopRemoveSource(\n CFRunLoopGetCurrent(),\n CFMachPortCreateRunLoopSource(nil, eventTap, 0),\n CFRunLoopMode.commonModes\n )\n CFMachPortInvalidate(eventTap)\n self.eventTap = nil\n\n systemWakeUpObserver?.cancel()\n systemWakeUpObserver = nil\n\n Logger.log(\"SwipeManager stopped\")\n }\n\n func eventHandler(\n proxy: CGEventTapProxy,\n eventType: CGEventType,\n cgEvent: CGEvent,\n userInfo: UnsafeMutableRawPointer?\n ) -> Unmanaged? {\n if eventType.rawValue == NSEvent.EventType.gesture.rawValue,\n let nsEvent = NSEvent(cgEvent: cgEvent) {\n handleGesture(nsEvent)\n } else if eventType == .tapDisabledByUserInput || eventType == .tapDisabledByTimeout {\n Logger.log(\"SwipeManager tap disabled \\(eventType)\")\n if let eventTap {\n CGEvent.tapEnable(tap: eventTap, enable: true)\n }\n }\n\n return Unmanaged.passUnretained(cgEvent)\n }\n\n private func handleGesture(_ nsEvent: NSEvent) {\n let touches = nsEvent.allTouches()\n .filter { !$0.isResting && $0.phase != .stationary }\n\n if touches.count == 0 || Date().timeIntervalSince(lastTouchDate) > 0.8 {\n state = .idle\n }\n\n guard touches.count >= Constants.minFingerCount,\n gesturesSettings.isHorizontalSwipeSet || gesturesSettings.isVerticalSwipeSet\n else { return }\n\n if state == .idle {\n state = .inProgress\n xTouchDistance = [:]\n yTouchDistance = [:]\n prevTouchPositions = [:]\n }\n if state == .inProgress {\n lastTouchDate = Date()\n handleSwipe(touches: touches)\n }\n }\n\n private func handleSwipe(touches: Set) {\n updateSwipeDistance(touches: touches)\n handleHorizontalSwipe()\n handleVerticalSwipe()\n }\n\n private func handleHorizontalSwipe() {\n guard state == .inProgress else { return }\n guard gesturesSettings.isHorizontalSwipeSet else { return }\n\n let swipes = xTouchDistance.values\n let allMovedRight = swipes.allSatisfy { $0 > 0 }\n let allMovedLeft = swipes.allSatisfy { $0 < 0 }\n let minFingerContribution = swipeThreshold / (CGFloat(swipes.count) + 2.0)\n\n guard (Constants.minFingerCount...Constants.maxFingerCount).contains(swipes.count),\n swipes.allSatisfy({ abs($0) > minFingerContribution }),\n abs(swipes.reduce(0.0, +)) >= swipeThreshold,\n allMovedLeft || allMovedRight else { return }\n\n let action = if allMovedRight {\n swipes.count == 3 ? gesturesSettings.swipeRight3FingerAction : gesturesSettings.swipeRight4FingerAction\n } else if allMovedLeft {\n swipes.count == 3 ? gesturesSettings.swipeLeft3FingerAction : gesturesSettings.swipeLeft4FingerAction\n } else {\n GestureAction.none\n }\n\n state = .ended\n callAction(action)\n Logger.log(\"Horizontal swipe detected\")\n }\n\n private func handleVerticalSwipe() {\n guard state == .inProgress else { return }\n guard gesturesSettings.isVerticalSwipeSet else { return }\n\n let swipes = yTouchDistance.values\n let allMovedUp = swipes.allSatisfy { $0 > 0 }\n let allMovedDown = swipes.allSatisfy { $0 < 0 }\n let minFingerContribution = swipeThreshold / (CGFloat(swipes.count) + 2.0)\n\n guard (Constants.minFingerCount...Constants.maxFingerCount).contains(swipes.count),\n swipes.allSatisfy({ abs($0) > minFingerContribution }),\n abs(swipes.reduce(0.0, +)) >= swipeThreshold,\n allMovedUp || allMovedDown else { return }\n\n let action = if allMovedUp {\n swipes.count == 3 ? gesturesSettings.swipeUp3FingerAction : gesturesSettings.swipeUp4FingerAction\n } else if allMovedDown {\n swipes.count == 3 ? gesturesSettings.swipeDown3FingerAction : gesturesSettings.swipeDown4FingerAction\n } else {\n GestureAction.none\n }\n\n state = .ended\n callAction(action)\n Logger.log(\"Vertical swipe detected\")\n }\n\n private func updateSwipeDistance(touches: Set) {\n for touch in touches {\n let (distanceX, distanceY) = touchDistance(touch)\n\n if abs(distanceX) > abs(distanceY) {\n xTouchDistance[ObjectIdentifier(touch.identity), default: 0.0] += distanceX\n } else {\n yTouchDistance[ObjectIdentifier(touch.identity), default: 0.0] += distanceY\n }\n\n prevTouchPositions[ObjectIdentifier(touch.identity)] = touch.normalizedPosition\n }\n }\n\n private func touchDistance(_ touch: NSTouch) -> (CGFloat, CGFloat) {\n guard let prevPosition = prevTouchPositions[ObjectIdentifier(touch.identity)] else {\n return (0.0, 0.0)\n }\n\n return (\n touch.normalizedPosition.x - prevPosition.x,\n touch.normalizedPosition.y - prevPosition.y\n )\n }\n\n // swiftlint:disable:next cyclomatic_complexity\n private func callAction(_ action: GestureAction) {\n let skipEmpty = workspaceSettings.skipEmptyWorkspacesOnSwitch\n let loop = workspaceSettings.loopWorkspaces\n\n switch action {\n case .none: break\n case .toggleSpaceControl: SpaceControl.toggle()\n case .showSpaceControl: SpaceControl.show()\n case .hideSpaceControl: SpaceControl.hide()\n case .nextWorkspace: workspaceManager.activateWorkspace(next: true, skipEmpty: skipEmpty, loop: loop)\n case .previousWorkspace: workspaceManager.activateWorkspace(next: false, skipEmpty: skipEmpty, loop: loop)\n case .mostRecentWorkspace: workspaceManager.activateRecentWorkspace()\n case .focusLeft: focusManager.focusLeft()\n case .focusRight: focusManager.focusRight()\n case .focusUp: focusManager.focusUp()\n case .focusDown: focusManager.focusDown()\n case .focusNextApp: focusManager.nextWorkspaceApp()\n case .focusPreviousApp: focusManager.previousWorkspaceApp()\n case .focusNextWindow: focusManager.nextWorkspaceWindow()\n case .focusPreviousWindow: focusManager.previousWorkspaceWindow()\n case .activateWorkspace(let workspaceName):\n if let workspace = workspaceRepository.workspaces.first(where: { $0.name == workspaceName }) {\n workspaceManager.activateWorkspace(workspace, setFocus: true)\n }\n }\n }\n}\n\nextension SwipeManager {\n func restartAppIfNeeded() {\n guard gesturesSettings.restartAppOnWakeUp else { return }\n\n let task = Process()\n task.launchPath = \"/bin/sh\"\n task.arguments = [\"-c\", \"sleep 1; open '\\(Bundle.main.bundlePath)'\"]\n task.launch()\n\n NSApp.terminate(self)\n exit(0)\n }\n\n private func observeSystemWakeUp() {\n systemWakeUpObserver = NSWorkspace.shared.notificationCenter\n .publisher(for: NSWorkspace.didWakeNotification)\n .sink { [weak self] _ in self?.restartAppIfNeeded() }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Acknowledgements/AcknowledgementsSettingsView.swift", "//\n// AcknowledgementsSettingsView.swift\n//\n// Created by Wojciech Kulik on 26/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct AcknowledgementsSettingsView: View {\n @State private var selectedDependency: String? = \"xnth97/SymbolPicker\"\n @State private var dependencies = [\n \"xnth97/SymbolPicker\",\n \"Kentzo/ShortcutRecorder\",\n \"LebJe/TOMLKit\",\n \"jpsim/Yams\",\n \"sparkle-project/Sparkle\",\n \"apple/swift-argument-parser\",\n \"SwiftFormat\",\n \"SwiftLint\"\n ]\n\n var body: some View {\n VStack(spacing: 0.0) {\n List(\n dependencies,\n id: \\.self,\n selection: $selectedDependency\n ) { dependency in\n Text(dependency)\n }.frame(height: 130)\n\n ScrollView([.vertical, .horizontal]) {\n VStack {\n Group {\n switch selectedDependency {\n case \"xnth97/SymbolPicker\":\n Text(Licenses.symbolPicker)\n case \"Kentzo/ShortcutRecorder\":\n Text(Licenses.shortcutRecorder)\n case \"LebJe/TOMLKit\":\n Text(Licenses.tomlKit)\n case \"jpsim/Yams\":\n Text(Licenses.yams)\n case \"sparkle-project/Sparkle\":\n Text(Licenses.sparkle)\n case \"apple/swift-argument-parser\":\n Text(Licenses.swiftArgumentParser)\n case \"SwiftFormat\":\n Text(Licenses.swiftFormat)\n case \"SwiftLint\":\n Text(Licenses.swiftLint)\n default:\n EmptyView()\n }\n }\n .frame(minHeight: 330, alignment: .top)\n .textSelection(.enabled)\n .padding()\n }\n }\n }\n .navigationTitle(\"Acknowledgements\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Gestures/GesturesSettingsView.swift", "//\n// GesturesSettingsView.swift\n//\n// Created by Wojciech Kulik on 21/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct GesturesSettingsView: View {\n @StateObject private var settings = AppDependencies.shared.gesturesSettings\n\n var body: some View {\n Form {\n Section {\n Toggle(\"Enable Swipe Gestures\", isOn: $settings.enableSwipeGestures)\n HStack {\n Text(\"Activation Threshold\")\n Spacer()\n Text(\"\\(settings.swipeThreshold, specifier: \"%.2f\")\")\n Stepper(\n \"\",\n value: $settings.swipeThreshold,\n in: 0.05...0.7,\n step: 0.05\n ).labelsHidden()\n }\n Text(\"Remember to disable system gestures in System Preferences > Trackpad > More Gestures.\")\n .font(.callout)\n .foregroundStyle(.secondary)\n Text(\n \"Keeping \\\"Swipe between full-screen apps\\\" enabled prevents from detecting swipe gesture as \" +\n \"a scroll action. However, you must keep only one macOS Space to avoid switching.\"\n )\n .font(.callout)\n .foregroundStyle(.secondary)\n }\n\n Section(\"Horizontal Swipes\") {\n Picker(\"3-Finger Left Swipe\", selection: $settings.swipeLeft3FingerAction) {\n ForEach(GestureAction.allCases) { action in\n Text(action.description).tag(action)\n }\n }\n Picker(\"3-Finger Right Swipe\", selection: $settings.swipeRight3FingerAction) {\n ForEach(GestureAction.allCases) { action in\n Text(action.description).tag(action)\n }\n }\n Picker(\"4-Finger Left Swipe\", selection: $settings.swipeLeft4FingerAction) {\n ForEach(GestureAction.allCases) { action in\n Text(action.description).tag(action)\n }\n }\n Picker(\"4-Finger Right Swipe\", selection: $settings.swipeRight4FingerAction) {\n ForEach(GestureAction.allCases) { action in\n Text(action.description).tag(action)\n }\n }\n }\n .disabled(!settings.enableSwipeGestures)\n .opacity(settings.enableSwipeGestures ? 1 : 0.5)\n\n Section(\"Vertical Swipes\") {\n Picker(\"3-Finger Up Swipe\", selection: $settings.swipeUp3FingerAction) {\n ForEach(GestureAction.allCases) { action in\n Text(action.description).tag(action)\n }\n }\n Picker(\"3-Finger Down Swipe\", selection: $settings.swipeDown3FingerAction) {\n ForEach(GestureAction.allCases) { action in\n Text(action.description).tag(action)\n }\n }\n Picker(\"4-Finger Up Swipe\", selection: $settings.swipeUp4FingerAction) {\n ForEach(GestureAction.allCases) { action in\n Text(action.description).tag(action)\n }\n }\n Picker(\"4-Finger Down Swipe\", selection: $settings.swipeDown4FingerAction) {\n ForEach(GestureAction.allCases) { action in\n Text(action.description).tag(action)\n }\n }\n }\n .disabled(!settings.enableSwipeGestures)\n .opacity(settings.enableSwipeGestures ? 1 : 0.5)\n\n Section(\"System\") {\n Toggle(\"Restart App On Wake Up\", isOn: $settings.restartAppOnWakeUp)\n Text(\n \"Restarts the app when your Mac wakes up from sleep. This can help with gesture recognition issues after waking.\"\n )\n .font(.callout)\n .foregroundStyle(.secondary)\n }\n .disabled(!settings.enableSwipeGestures)\n .opacity(settings.enableSwipeGestures ? 1 : 0.5)\n }\n .formStyle(.grouped)\n .navigationTitle(\"Gestures\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/General/GeneralSettingsView.swift", "//\n// GeneralSettingsView.swift\n//\n// Created by Wojciech Kulik on 23/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport SwiftUI\n\nstruct GeneralSettingsView: View {\n @StateObject var settings = AppDependencies.shared.generalSettings\n @State var isAutostartEnabled = false\n @State var hasAccessibilityPermissions = false\n\n var body: some View {\n Form {\n Section {\n Toggle(\"Launch at startup\", isOn: $isAutostartEnabled)\n Toggle(\"Check for updates automatically\", isOn: $settings.checkForUpdatesAutomatically)\n }\n\n Section(\"Permissions\") {\n HStack {\n if hasAccessibilityPermissions {\n Image(systemName: \"checkmark.circle.fill\")\n .foregroundColor(.green)\n Text(\"Accessibility Permissions\")\n Spacer()\n } else {\n Image(systemName: \"xmark.circle.fill\")\n .foregroundColor(.red)\n Text(\"Accessibility Permissions\")\n Spacer()\n Button(\"Open Privacy & Security\") {\n NSWorkspace.shared.open(\n URL(string: \"x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility\")!\n )\n }\n }\n }\n Text(\"FlashSpace requires accessibility access to manage applications.\")\n .foregroundColor(.secondary)\n .font(.callout)\n }\n\n Section(\"Shortcuts\") {\n hotkey(\"Toggle FlashSpace\", for: $settings.showFlashSpace)\n }\n\n Section(\"Notifications\") {\n Toggle(\"Enable Notifications\", isOn: $settings.showFloatingNotifications)\n Text(\"Some shortcuts will show a temporary notification.\")\n .foregroundStyle(.secondary)\n .font(.callout)\n }\n }\n .onAppear {\n isAutostartEnabled = AppDependencies.shared.autostartService.isLaunchAtLoginEnabled\n hasAccessibilityPermissions = PermissionsManager.shared.checkForAccessibilityPermissions()\n }\n .onChange(of: isAutostartEnabled) { _, enabled in\n if enabled {\n AppDependencies.shared.autostartService.enableLaunchAtLogin()\n } else {\n AppDependencies.shared.autostartService.disableLaunchAtLogin()\n }\n }\n .onReceive(NotificationCenter.default.publisher(for: NSApplication.didBecomeActiveNotification)) { _ in\n hasAccessibilityPermissions = PermissionsManager.shared.checkForAccessibilityPermissions()\n }\n .formStyle(.grouped)\n .navigationTitle(\"General\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/MenuBar/MenuBarSettingsView.swift", "//\n// MenuBarSettingsView.swift\n//\n// Created by Wojciech Kulik on 31/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct MenuBarSettingsView: View {\n @StateObject var settings = AppDependencies.shared.menuBarSettings\n\n var body: some View {\n Form {\n Section {\n Toggle(\"Show Title\", isOn: $settings.showMenuBarTitle)\n Toggle(\"Show Icon\", isOn: $settings.showMenuBarIcon)\n .disabled(!settings.showMenuBarTitle)\n\n HStack {\n Text(\"Title Template\")\n TextField(\"\", text: $settings.menuBarTitleTemplate)\n .foregroundColor(.secondary)\n .standardPlaceholder(settings.menuBarTitleTemplate.isEmpty)\n }\n .disabled(!settings.showMenuBarTitle)\n .opacity(settings.showMenuBarTitle ? 1 : 0.5)\n\n Text(\n \"\"\"\n $WORKSPACE will be replaced with the active workspace name\n $WORKSPACE_NUMBER will be replaced with the active workspace number\n $DISPLAY will be replaced with the corresponding display name\n $PROFILE will be replaced with the active profile name\n \"\"\"\n )\n .foregroundStyle(.secondary)\n .font(.callout)\n .opacity(settings.showMenuBarTitle ? 1 : 0.5)\n }\n\n Section {\n HStack {\n Text(\"Display Aliases\")\n TextField(\"\", text: $settings.menuBarDisplayAliases)\n .foregroundColor(.secondary)\n .standardPlaceholder(settings.menuBarDisplayAliases.isEmpty)\n }\n .disabled(!settings.showMenuBarTitle)\n .opacity(settings.showMenuBarTitle ? 1 : 0.5)\n\n Text(\"Example: DELL U2723QE=Secondary;Built-in Retina Display=Main\")\n .foregroundStyle(.secondary)\n .font(.callout)\n .opacity(settings.showMenuBarTitle ? 1 : 0.5)\n }\n }\n .formStyle(.grouped)\n .navigationTitle(\"Menu Bar\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Integrations/IntegrationsSettingsView.swift", "//\n// IntegrationsSettingsView.swift\n//\n// Created by Wojciech Kulik on 24/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct IntegrationsSettingsView: View {\n @StateObject var settings = AppDependencies.shared.integrationsSettings\n\n var body: some View {\n Form {\n Section {\n Toggle(\"Enable Integrations\", isOn: $settings.enableIntegrations)\n }\n\n Section(\"Scripts To Run\") {\n HStack {\n Text(\"On App Launch\")\n TextField(\"\", text: $settings.runScriptOnLaunch)\n .foregroundColor(.secondary)\n .standardPlaceholder(settings.runScriptOnLaunch.isEmpty)\n }\n\n HStack {\n Text(\"On Workspace Change\")\n TextField(\"\", text: $settings.runScriptOnWorkspaceChange)\n .foregroundColor(.secondary)\n .standardPlaceholder(settings.runScriptOnWorkspaceChange.isEmpty)\n }\n\n HStack {\n Text(\"On Profile Change\")\n TextField(\"\", text: $settings.runScriptOnProfileChange)\n .foregroundColor(.secondary)\n .standardPlaceholder(settings.runScriptOnProfileChange.isEmpty)\n }\n\n Text(\n \"\"\"\n $WORKSPACE will be replaced with the active workspace name\n $WORKSPACE_NUMBER will be replaced with the active workspace number\n $DISPLAY will be replaced with the corresponding display name\n $PROFILE will be replaced with the active profile name\n \"\"\"\n )\n .foregroundStyle(.secondary)\n .font(.callout)\n }\n .disabled(!settings.enableIntegrations)\n .opacity(settings.enableIntegrations ? 1 : 0.5)\n }\n .formStyle(.grouped)\n .navigationTitle(\"Integrations\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Workspaces/WorkspaceManager.swift", "//\n// WorkspaceManager.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Combine\n\ntypealias DisplayName = String\n\nstruct ActiveWorkspace {\n let id: WorkspaceID\n let name: String\n let number: String?\n let symbolIconName: String?\n let display: DisplayName\n}\n\nfinal class WorkspaceManager: ObservableObject {\n @Published private(set) var activeWorkspaceDetails: ActiveWorkspace?\n\n private(set) var lastFocusedApp: [WorkspaceID: MacApp] = [:]\n private(set) var activeWorkspace: [DisplayName: Workspace] = [:]\n private(set) var mostRecentWorkspace: [DisplayName: Workspace] = [:]\n private(set) var lastWorkspaceActivation = Date.distantPast\n\n private var cancellables = Set()\n private var observeFocusCancellable: AnyCancellable?\n private var appsHiddenManually: [WorkspaceID: [MacApp]] = [:]\n private let hideAgainSubject = PassthroughSubject()\n\n private let workspaceRepository: WorkspaceRepository\n private let workspaceSettings: WorkspaceSettings\n private let floatingAppsSettings: FloatingAppsSettings\n private let pictureInPictureManager: PictureInPictureManager\n private let workspaceTransitionManager: WorkspaceTransitionManager\n private let displayManager: DisplayManager\n\n init(\n workspaceRepository: WorkspaceRepository,\n settingsRepository: SettingsRepository,\n pictureInPictureManager: PictureInPictureManager,\n workspaceTransitionManager: WorkspaceTransitionManager,\n displayManager: DisplayManager\n ) {\n self.workspaceRepository = workspaceRepository\n self.workspaceSettings = settingsRepository.workspaceSettings\n self.floatingAppsSettings = settingsRepository.floatingAppsSettings\n self.pictureInPictureManager = pictureInPictureManager\n self.workspaceTransitionManager = workspaceTransitionManager\n self.displayManager = displayManager\n\n PermissionsManager.shared.askForAccessibilityPermissions()\n observe()\n }\n\n private func observe() {\n hideAgainSubject\n .debounce(for: 0.2, scheduler: RunLoop.main)\n .sink { [weak self] in self?.hideApps(in: $0) }\n .store(in: &cancellables)\n\n NotificationCenter.default\n .publisher(for: .profileChanged)\n .sink { [weak self] _ in\n self?.lastFocusedApp = [:]\n self?.activeWorkspace = [:]\n self?.mostRecentWorkspace = [:]\n self?.activeWorkspaceDetails = nil\n }\n .store(in: &cancellables)\n\n NotificationCenter.default\n .publisher(for: NSApplication.didChangeScreenParametersNotification)\n .sink { [weak self] _ in\n self?.activeWorkspace = [:]\n self?.mostRecentWorkspace = [:]\n self?.activeWorkspaceDetails = nil\n }\n .store(in: &cancellables)\n\n observeFocus()\n }\n\n private func observeFocus() {\n observeFocusCancellable = NSWorkspace.shared.notificationCenter\n .publisher(for: NSWorkspace.didActivateApplicationNotification)\n .compactMap { $0.userInfo?[NSWorkspace.applicationUserInfoKey] as? NSRunningApplication }\n .sink { [weak self] application in\n self?.rememberLastFocusedApp(application, retry: true)\n }\n }\n\n private func rememberLastFocusedApp(_ application: NSRunningApplication, retry: Bool) {\n guard application.display != nil else {\n if retry {\n Logger.log(\"Retrying to get display for \\(application.localizedName ?? \"\")\")\n return DispatchQueue.main.asyncAfter(deadline: .now() + 0.6) {\n if let frontmostApp = NSWorkspace.shared.frontmostApplication {\n self.rememberLastFocusedApp(frontmostApp, retry: false)\n }\n }\n } else {\n return Logger.log(\"Unable to get display for \\(application.localizedName ?? \"\")\")\n }\n }\n\n let focusedDisplay = NSScreen.main?.localizedName ?? \"\"\n\n if let activeWorkspace = activeWorkspace[focusedDisplay], activeWorkspace.apps.containsApp(application) {\n lastFocusedApp[activeWorkspace.id] = application.toMacApp\n updateActiveWorkspace(activeWorkspace, on: [focusedDisplay])\n }\n\n displayManager.trackDisplayFocus(on: focusedDisplay, for: application)\n }\n\n private func showApps(in workspace: Workspace, setFocus: Bool, on displays: Set) {\n let regularApps = NSWorkspace.shared.runningApplications\n .filter { $0.activationPolicy == .regular }\n let floatingApps = floatingAppsSettings.floatingApps\n let hiddenApps = appsHiddenManually[workspace.id] ?? []\n var appsToShow = regularApps\n .filter { !hiddenApps.containsApp($0) }\n .filter {\n workspace.apps.containsApp($0) ||\n floatingApps.containsApp($0) && $0.isOnAnyDisplay(displays)\n }\n\n observeFocusCancellable = nil\n defer { observeFocus() }\n\n if setFocus {\n let toFocus = findAppToFocus(in: workspace, apps: appsToShow)\n\n // Make sure to raise the app that should be focused\n // as the last one\n if let toFocus {\n appsToShow.removeAll { $0 == toFocus }\n appsToShow.append(toFocus)\n }\n\n for app in appsToShow {\n Logger.log(\"SHOW: \\(app.localizedName ?? \"\")\")\n\n if app == toFocus || app.isHidden || app.isMinimized {\n app.raise()\n }\n\n pictureInPictureManager.showPipAppIfNeeded(app: app)\n }\n\n Logger.log(\"FOCUS: \\(toFocus?.localizedName ?? \"\")\")\n toFocus?.activate()\n centerCursorIfNeeded(in: toFocus?.frame)\n } else {\n for app in appsToShow {\n Logger.log(\"SHOW: \\(app.localizedName ?? \"\")\")\n app.raise()\n }\n }\n }\n\n private func hideApps(in workspace: Workspace) {\n let regularApps = NSWorkspace.shared.runningApplications\n .filter { $0.activationPolicy == .regular }\n let workspaceApps = workspace.apps + floatingAppsSettings.floatingApps\n let isAnyWorkspaceAppRunning = regularApps\n .contains { workspaceApps.containsApp($0) }\n let allAssignedApps = workspaceRepository.workspaces\n .flatMap(\\.apps)\n .map(\\.bundleIdentifier)\n .asSet\n let displays = workspace.displays\n\n let appsToHide = regularApps\n .filter {\n !$0.isHidden && !workspaceApps.containsApp($0) &&\n (!workspaceSettings.keepUnassignedAppsOnSwitch || allAssignedApps.contains($0.bundleIdentifier ?? \"\"))\n }\n .filter { isAnyWorkspaceAppRunning || $0.bundleURL?.fileName != \"Finder\" }\n .filter { $0.isOnAnyDisplay(displays) }\n\n for app in appsToHide {\n Logger.log(\"HIDE: \\(app.localizedName ?? \"\")\")\n\n if !pictureInPictureManager.hidePipAppIfNeeded(app: app) {\n app.hide()\n }\n }\n }\n\n private func findAppToFocus(\n in workspace: Workspace,\n apps: [NSRunningApplication]\n ) -> NSRunningApplication? {\n if workspace.appToFocus == nil {\n let displays = workspace.displays\n if let floatingEntry = displayManager.lastFocusedDisplay(where: {\n let isFloating = floatingAppsSettings.floatingApps.contains($0.app)\n let isUnassigned = workspaceSettings.keepUnassignedAppsOnSwitch &&\n !workspaceRepository.workspaces.flatMap(\\.apps).contains($0.app)\n return (isFloating || isUnassigned) && displays.contains($0.display)\n }),\n let runningApp = NSWorkspace.shared.runningApplications.find(floatingEntry.app) {\n return runningApp\n }\n }\n\n var appToFocus: NSRunningApplication?\n\n if workspace.appToFocus == nil {\n appToFocus = apps.find(lastFocusedApp[workspace.id])\n } else {\n appToFocus = apps.find(workspace.appToFocus)\n }\n\n let fallbackToLastApp = apps.findFirstMatch(with: workspace.apps.reversed())\n let fallbackToFinder = NSWorkspace.shared.runningApplications.first(where: \\.isFinder)\n\n return appToFocus ?? fallbackToLastApp ?? fallbackToFinder\n }\n\n private func centerCursorIfNeeded(in frame: CGRect?) {\n guard workspaceSettings.centerCursorOnWorkspaceChange, let frame else { return }\n\n CGWarpMouseCursorPosition(CGPoint(x: frame.midX, y: frame.midY))\n }\n\n private func updateActiveWorkspace(_ workspace: Workspace, on displays: Set) {\n lastWorkspaceActivation = Date()\n\n // Save the most recent workspace if it's not the current one\n for display in displays {\n if activeWorkspace[display]?.id != workspace.id {\n mostRecentWorkspace[display] = activeWorkspace[display]\n }\n activeWorkspace[display] = workspace\n }\n\n activeWorkspaceDetails = .init(\n id: workspace.id,\n name: workspace.name,\n number: workspaceRepository.workspaces\n .firstIndex { $0.id == workspace.id }\n .map { \"\\($0 + 1)\" },\n symbolIconName: workspace.symbolIconName,\n display: workspace.displayForPrint\n )\n\n Integrations.runOnActivateIfNeeded(workspace: activeWorkspaceDetails!)\n }\n\n private func rememberHiddenApps(workspaceToActivate: Workspace) {\n guard !workspaceSettings.restoreHiddenAppsOnSwitch else {\n appsHiddenManually = [:]\n return\n }\n\n let hiddenApps = NSWorkspace.shared.runningApplications\n .filter { $0.activationPolicy == .regular }\n .filter { $0.isHidden || $0.isMinimized }\n\n for activeWorkspace in activeWorkspace.values {\n guard activeWorkspace.id != workspaceToActivate.id else { continue }\n\n appsHiddenManually[activeWorkspace.id] = []\n }\n\n for (display, activeWorkspace) in activeWorkspace {\n guard activeWorkspace.id != workspaceToActivate.id else { continue }\n\n let activeWorkspaceOtherDisplays = activeWorkspace.displays.subtracting([display])\n appsHiddenManually[activeWorkspace.id, default: []] += hiddenApps\n .filter {\n activeWorkspace.apps.containsApp($0) &&\n $0.isOnAnyDisplay([display]) && !$0.isOnAnyDisplay(activeWorkspaceOtherDisplays)\n }\n .map(\\.toMacApp)\n }\n }\n}\n\n// MARK: - Workspace Actions\nextension WorkspaceManager {\n func activateWorkspace(_ workspace: Workspace, setFocus: Bool) {\n let displays = workspace.displays\n\n Logger.log(\"\")\n Logger.log(\"\")\n Logger.log(\"WORKSPACE: \\(workspace.name)\")\n Logger.log(\"DISPLAYS: \\(displays.joined(separator: \", \"))\")\n Logger.log(\"----\")\n SpaceControl.hide()\n\n guard displays.isNotEmpty else {\n Logger.log(\"No displays found for workspace: \\(workspace.name) - skipping\")\n return\n }\n\n workspaceTransitionManager.showTransitionIfNeeded(for: workspace, on: displays)\n\n rememberHiddenApps(workspaceToActivate: workspace)\n updateActiveWorkspace(workspace, on: displays)\n showApps(in: workspace, setFocus: setFocus, on: displays)\n hideApps(in: workspace)\n\n // Some apps may not hide properly,\n // so we hide apps in the workspace after a short delay\n hideAgainSubject.send(workspace)\n\n NotificationCenter.default.post(name: .workspaceChanged, object: workspace)\n }\n\n func assignApps(_ apps: [MacApp], to workspace: Workspace) {\n for app in apps {\n workspaceRepository.deleteAppFromAllWorkspaces(app: app)\n workspaceRepository.addApp(to: workspace.id, app: app)\n }\n\n NotificationCenter.default.post(name: .appsListChanged, object: nil)\n }\n\n func assignApp(_ app: MacApp, to workspace: Workspace) {\n workspaceRepository.deleteAppFromAllWorkspaces(app: app)\n workspaceRepository.addApp(to: workspace.id, app: app)\n\n guard let targetWorkspace = workspaceRepository.workspaces\n .first(where: { $0.id == workspace.id }) else { return }\n\n let isTargetWorkspaceActive = activeWorkspace.values\n .contains(where: { $0.id == workspace.id })\n\n updateLastFocusedApp(app, in: targetWorkspace)\n\n if workspaceSettings.changeWorkspaceOnAppAssign {\n activateWorkspace(targetWorkspace, setFocus: true)\n } else if !isTargetWorkspaceActive {\n NSWorkspace.shared.runningApplications\n .find(app)?\n .hide()\n AppDependencies.shared.focusManager.nextWorkspaceApp()\n }\n\n NotificationCenter.default.post(name: .appsListChanged, object: nil)\n }\n\n func hideUnassignedApps() {\n let activeWorkspace = workspaceRepository.workspaces\n .first(where: { $0.id == activeWorkspaceDetails?.id })\n\n guard let activeWorkspace else { return }\n\n let appsToHide = NSWorkspace.shared.runningApplications\n .regularVisibleApps(onDisplays: activeWorkspace.displays, excluding: activeWorkspace.apps)\n\n for app in appsToHide {\n Logger.log(\"CLEAN UP: \\(app.localizedName ?? \"\")\")\n\n if !pictureInPictureManager.hidePipAppIfNeeded(app: app) {\n app.hide()\n }\n }\n }\n\n func activateWorkspace(next: Bool, skipEmpty: Bool, loop: Bool) {\n guard let screen = displayManager.getCursorScreen() else { return }\n\n var screenWorkspaces = workspaceRepository.workspaces\n .filter { $0.displays.contains(screen) }\n\n if !next {\n screenWorkspaces = screenWorkspaces.reversed()\n }\n\n guard let activeWorkspace = activeWorkspace[screen] ?? screenWorkspaces.first else { return }\n\n let nextWorkspaces = screenWorkspaces\n .drop(while: { $0.id != activeWorkspace.id })\n .dropFirst()\n\n var selectedWorkspace = nextWorkspaces.first ?? (loop ? screenWorkspaces.first : nil)\n\n if skipEmpty {\n let runningApps = NSWorkspace.shared.runningApplications\n .filter { $0.activationPolicy == .regular }\n .compactMap(\\.bundleIdentifier)\n .asSet\n\n selectedWorkspace = (nextWorkspaces + (loop ? screenWorkspaces : []))\n .drop(while: { $0.apps.allSatisfy { !runningApps.contains($0.bundleIdentifier) } })\n .first\n }\n\n guard let selectedWorkspace, selectedWorkspace.id != activeWorkspace.id else { return }\n\n activateWorkspace(selectedWorkspace, setFocus: true)\n }\n\n func activateRecentWorkspace() {\n guard let screen = displayManager.getCursorScreen(),\n let mostRecentWorkspace = mostRecentWorkspace[screen]\n else { return }\n\n activateWorkspace(mostRecentWorkspace, setFocus: true)\n }\n\n func activateWorkspaceIfActive(_ workspaceId: WorkspaceID) {\n guard activeWorkspace.values.contains(where: { $0.id == workspaceId }) else { return }\n guard let updatedWorkspace = workspaceRepository.workspaces.first(where: { $0.id == workspaceId }) else { return }\n\n activateWorkspace(updatedWorkspace, setFocus: false)\n }\n\n func updateLastFocusedApp(_ app: MacApp, in workspace: Workspace) {\n lastFocusedApp[workspace.id] = app\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/PictureInPicture/PictureInPictureManager.swift", "//\n// PictureInPictureManager.swift\n//\n// Created by Wojciech Kulik on 12/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Combine\n\nfinal class PictureInPictureManager {\n typealias AXWindow = AXUIElement\n\n private var hiddenWindows: [NSRunningApplication: [AXWindow]] = [:]\n private var capturedFrame: [AXWindow: CGRect] = [:]\n private var cancellables: Set = []\n private var windowFocusObserver: AXObserver?\n\n private let settings: WorkspaceSettings\n\n init(settingsRepository: SettingsRepository) {\n self.settings = settingsRepository.workspaceSettings\n setupSignalHandlers()\n observePipFocusChangeNotification()\n }\n\n func restoreAppIfNeeded(app: NSRunningApplication) {\n guard settings.enablePictureInPictureSupport else { return }\n\n if hiddenWindows.keys.contains(app) {\n restoreFromCornerNonPipWindows(app: app)\n }\n }\n\n func restoreAllWindows() {\n for app in hiddenWindows.keys {\n showPipAppIfNeeded(app: app)\n }\n }\n\n func showPipAppIfNeeded(app: NSRunningApplication) {\n guard settings.enablePictureInPictureSupport,\n app.supportsPictureInPicture else { return }\n\n restoreFromCornerNonPipWindows(app: app)\n }\n\n func hidePipAppIfNeeded(app: NSRunningApplication) -> Bool {\n guard settings.enablePictureInPictureSupport,\n app.supportsPictureInPicture,\n app.isPictureInPictureActive\n else { return false }\n\n guard hiddenWindows[app] == nil else { return true }\n\n guard settings.displayMode == .static || app.allDisplays.count <= 1 else {\n // pip is not supported for multi-display apps\n return false\n }\n\n return hideInCornerNonPipWindows(app: app)\n }\n\n private func observePipFocusChangeNotification() {\n NotificationCenter.default\n .publisher(for: .pipFocusChanged)\n .sink { [weak self] _ in self?.restorePipWorkspace() }\n .store(in: &cancellables)\n }\n\n private func restorePipWorkspace() {\n guard let app = hiddenWindows.keys.first(where: { !$0.isPictureInPictureActive }) else { return }\n\n restoreAllWindows()\n\n let workspaceRepository = AppDependencies.shared.workspaceRepository\n let workspaceManager = AppDependencies.shared.workspaceManager\n let workspace = workspaceRepository.workspaces.first { $0.apps.containsApp(app) }\n\n guard let workspace else { return }\n\n windowFocusObserver = nil\n workspaceManager.activateWorkspace(workspace, setFocus: false)\n }\n\n private func restoreFromCornerNonPipWindows(app: NSRunningApplication) {\n windowFocusObserver = nil\n\n app.runWithoutAnimations {\n for window in hiddenWindows[app] ?? [] {\n if let previousFrame = capturedFrame[window] {\n window.setPosition(previousFrame.origin)\n capturedFrame.removeValue(forKey: window)\n }\n }\n }\n\n hiddenWindows.removeValue(forKey: app)\n }\n\n private func hideInCornerNonPipWindows(app: NSRunningApplication) -> Bool {\n guard let screenCorner = findScreenCorner(app: app) else { return false }\n\n let nonPipWindows = app.allWindows\n .map(\\.window)\n .filter { !$0.isPictureInPicture(bundleId: app.bundleIdentifier) }\n\n if nonPipWindows.isNotEmpty { observePipApp(app) }\n\n app.runWithoutAnimations {\n for window in nonPipWindows {\n if let windowFrame = window.frame, screenCorner != windowFrame.origin {\n capturedFrame[window] = windowFrame\n window.setPosition(screenCorner)\n }\n }\n }\n hiddenWindows[app] = nonPipWindows\n\n return true\n }\n\n private func findScreenCorner(app: NSRunningApplication) -> CGPoint? {\n guard let appScreen = NSScreen.screen(app.display) else {\n return nil\n }\n\n // Screen origin (0,0) is in the bottom-left corner, y-axis is pointing up\n // Window origin (0,0) is in the top-left corner, y-axis is pointing down\n // E.g. To place a window in the bottom-right corner of the screen\n // we need to set window origin to:\n // (screen.maxX - window.width, screen.maxY - window.height).\n\n let testOffset: CGFloat = 30.0\n let cornerOffset = CGFloat(settings.pipScreenCornerOffset)\n let appFrame = app.frame\n let screenFrame = appScreen.frame\n let leftCorner = CGPoint(x: screenFrame.minX, y: screenFrame.minY)\n let rightCorner = CGPoint(x: screenFrame.maxX, y: screenFrame.minY)\n let leftSide = leftCorner.applying(\n CGAffineTransform(translationX: -testOffset, y: testOffset)\n )\n let leftBottomSide = leftCorner.applying(\n CGAffineTransform(translationX: testOffset, y: -testOffset)\n )\n let rightSide = rightCorner.applying(\n CGAffineTransform(translationX: testOffset, y: testOffset)\n )\n let rightBottomSide = rightCorner.applying(\n CGAffineTransform(translationX: -testOffset, y: -testOffset)\n )\n\n let allScreens = NSScreen.screens.map(\\.frame)\n let isLeftCornerUsed = allScreens.contains(where: { $0.contains(leftSide) || $0.contains(leftBottomSide) })\n let isRightCornerUsed = allScreens.contains(where: { $0.contains(rightSide) || $0.contains(rightBottomSide) })\n\n if isLeftCornerUsed || !isRightCornerUsed || appFrame == nil {\n // right corner (window coordinates)\n return CGPoint(\n x: screenFrame.maxX - cornerOffset,\n y: screenFrame.maxY - cornerOffset\n )\n } else {\n // left corner (window coordinates)\n let appFrame = appFrame ?? .zero\n return CGPoint(\n x: screenFrame.minX + cornerOffset - appFrame.width,\n y: screenFrame.maxY - cornerOffset\n )\n }\n }\n\n private func setupSignalHandlers() {\n for code in [SIGTERM, SIGINT] {\n signal(code) {\n AppDependencies.shared.pictureInPictureManager.restoreAllWindows()\n exit($0)\n }\n }\n }\n\n private func observePipApp(_ app: NSRunningApplication) {\n guard settings.switchWorkspaceWhenPipCloses else { return }\n\n let callback: AXObserverCallback = { _, _, _, _ in\n NotificationCenter.default.post(name: .pipFocusChanged, object: nil)\n }\n\n let result = AXObserverCreate(app.processIdentifier, callback, &windowFocusObserver)\n\n guard result == .success, let observer = windowFocusObserver else { return }\n\n let appRef = AXUIElementCreateApplication(app.processIdentifier)\n AXObserverAddNotification(observer, appRef, kAXFocusedWindowChangedNotification as CFString, nil)\n CFRunLoopAddSource(CFRunLoopGetCurrent(), AXObserverGetRunLoopSource(observer), .defaultMode)\n }\n\n // MARK: - Alternative solution by minimizing windows (animation)\n private func deminimizeAllWindows(app: NSRunningApplication) {\n for window in app.allWindows.map(\\.window) {\n window.minimize(false)\n }\n }\n\n private func minimizeNonPipWindows(app: NSRunningApplication) {\n app.allWindows\n .map(\\.window)\n .filter { !$0.isPictureInPicture(bundleId: app.bundleIdentifier) }\n .forEach { $0.minimize(true) }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/ConfigurationFile/ConfigurationFileSettingsView.swift", "//\n// ConfigurationFileSettingsView.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport SwiftUI\n\nstruct ConfigurationFileSettingsView: View {\n @State var configFormat: ConfigFormat = ConfigSerializer.format\n\n var body: some View {\n Form {\n Section {\n Picker(\"Format\", selection: $configFormat) {\n ForEach(ConfigFormat.allCases, id: \\.rawValue) { format in\n Text(format.displayName).tag(format)\n }\n }.onChange(of: configFormat) { _, newFormat in\n try? ConfigSerializer.convert(to: newFormat)\n }\n\n HStack {\n Text(\"Location: \\(ConfigSerializer.configDirectory.path)\")\n .foregroundStyle(.secondary)\n .font(.callout)\n Spacer()\n Button(\"Reveal\") {\n NSWorkspace.shared.open(ConfigSerializer.configDirectory)\n }\n }\n\n Text(\n \"If you manually edit the configuration file, make sure to restart FlashSpace.\\n\" +\n \"Custom formatting, order, comments, etc. will be overwritten if you change something in the app.\"\n )\n .foregroundStyle(.secondary)\n .font(.callout)\n }\n }\n .formStyle(.grouped)\n .navigationTitle(\"Configuration File\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Commands/ListCommands.swift", "//\n// ListCommands.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\n\nfinal class ListCommands: CommandExecutor {\n var workspaceRepository: WorkspaceRepository { AppDependencies.shared.workspaceRepository }\n var profilesRepository: ProfilesRepository { AppDependencies.shared.profilesRepository }\n var settingsRepository: SettingsRepository { AppDependencies.shared.settingsRepository }\n\n // swiftlint:disable:next function_body_length\n func execute(command: CommandRequest) -> CommandResponse? {\n switch command {\n case .listWorkspaces(let withDisplay, let profileName):\n let profile = profileName != nil\n ? profilesRepository.profiles.first { $0.name == profileName }\n : profilesRepository.selectedProfile\n\n if let profile {\n let result: String\n\n if withDisplay {\n result = profile.workspaces.map {\n let displays = $0.displays.joined(separator: \",\")\n return \"\\($0.name),\\(displays.isEmpty ? \"None\" : displays)\"\n }.joined(separator: \"\\n\")\n } else {\n result = profile.workspaces.map(\\.name).joined(separator: \"\\n\")\n }\n\n return CommandResponse(success: true, message: result)\n } else {\n return CommandResponse(success: false, error: \"Profile not found\")\n }\n\n case .listProfiles:\n let result = profilesRepository.profiles.map(\\.name).joined(separator: \"\\n\")\n return CommandResponse(success: true, message: result)\n\n case .listApps(let workspace, let profileName, let withBundleId, let withIcon, let onlyRunning):\n let profile = profileName != nil\n ? profilesRepository.profiles.first { $0.name == profileName }\n : profilesRepository.selectedProfile\n\n guard let profile else {\n return CommandResponse(success: false, error: \"Profile not found\")\n }\n\n guard let workspace = profile.workspaces.first(where: { $0.name == workspace }) else {\n return CommandResponse(success: false, error: \"Workspace not found\")\n }\n\n let runningApps = NSWorkspace.shared.runningApplications.map(\\.bundleIdentifier).asSet\n\n let result = workspace.apps\n .filter { !onlyRunning || runningApps.contains($0.bundleIdentifier) }\n .map { app in\n [\n app.name,\n withBundleId ? app.bundleIdentifier : nil,\n withIcon ? app.iconPath ?? \"\" : nil\n ].compactMap { $0 }.joined(separator: \",\")\n }\n .joined(separator: \"\\n\")\n\n return CommandResponse(success: true, message: result)\n\n case .listFloatingApps(let withBundleId):\n let floatingApps = settingsRepository.floatingAppsSettings.floatingApps\n .map { app in\n [\n app.name,\n withBundleId ? app.bundleIdentifier : nil\n ].compactMap { $0 }.joined(separator: \",\")\n }\n .joined(separator: \"\\n\")\n\n return CommandResponse(success: true, message: floatingApps)\n\n default:\n return nil\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/MainScreen/MainViewModel.swift", "//\n// MainViewModel.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Combine\nimport SwiftUI\n\nfinal class MainViewModel: ObservableObject {\n @Published var workspaces: [Workspace] = [] {\n didSet {\n guard workspaces.count == oldValue.count,\n workspaces.map(\\.id) != oldValue.map(\\.id) else { return }\n\n workspaceRepository.reorderWorkspaces(newOrder: workspaces.map(\\.id))\n }\n }\n\n @Published var workspaceApps: [MacApp]?\n\n @Published var workspaceName = \"\"\n @Published var workspaceShortcut: AppHotKey? {\n didSet { saveWorkspace() }\n }\n\n @Published var workspaceAssignShortcut: AppHotKey? {\n didSet { saveWorkspace() }\n }\n\n @Published var workspaceDisplay = \"\" {\n didSet { saveWorkspace() }\n }\n\n @Published var workspaceAppToFocus: MacApp? = AppConstants.lastFocusedOption {\n didSet { saveWorkspace() }\n }\n\n @Published var workspaceSymbolIconName: String? {\n didSet { saveWorkspace() }\n }\n\n @Published var isSymbolPickerPresented = false\n @Published var isInputDialogPresented = false\n @Published var userInput = \"\"\n\n var focusAppOptions: [MacApp] {\n [AppConstants.lastFocusedOption] + (workspaceApps ?? [])\n }\n\n var selectedApps: Set = [] {\n didSet {\n // To avoid warnings\n DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) { [self] in\n objectWillChange.send()\n }\n }\n }\n\n var selectedWorkspaces: Set = [] {\n didSet {\n selectedWorkspace = selectedWorkspaces.count == 1\n ? selectedWorkspaces.first\n : nil\n\n // To avoid warnings\n DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) { [self] in\n if selectedWorkspaces.count == 1,\n selectedWorkspaces.first?.id != oldValue.first?.id {\n selectedApps = []\n } else if selectedWorkspaces.count != 1 {\n selectedApps = []\n }\n objectWillChange.send()\n }\n }\n }\n\n private(set) var selectedWorkspace: Workspace? {\n didSet {\n guard selectedWorkspace != oldValue else { return }\n\n // To avoid warnings\n DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) {\n self.updateSelectedWorkspace()\n }\n }\n }\n\n var screens: [String] {\n let set = NSScreen.screens.compactMap(\\.localizedName).asSet\n let otherScreens = workspaces.map(\\.display)\n\n return Array(set.union(otherScreens))\n .filter(\\.isNotEmpty)\n .sorted()\n }\n\n var displayMode: DisplayMode { workspaceSettings.displayMode }\n\n private var cancellables: Set = []\n private var loadingWorkspace = false\n\n private let workspaceManager = AppDependencies.shared.workspaceManager\n private let workspaceRepository = AppDependencies.shared.workspaceRepository\n private let workspaceSettings = AppDependencies.shared.workspaceSettings\n\n init() {\n self.workspaces = workspaceRepository.workspaces\n self.workspaceDisplay = NSScreen.main?.localizedName ?? \"\"\n\n observe()\n }\n\n private func observe() {\n NotificationCenter.default\n .publisher(for: .appsListChanged)\n .sink { [weak self] _ in self?.reloadWorkspaces() }\n .store(in: &cancellables)\n\n NotificationCenter.default\n .publisher(for: .profileChanged)\n .sink { [weak self] _ in self?.reloadWorkspaces() }\n .store(in: &cancellables)\n\n workspaceSettings.updatePublisher\n .compactMap { [weak self] in self?.workspaceSettings.displayMode }\n .removeDuplicates()\n .sink { [weak self] _ in self?.objectWillChange.send() }\n .store(in: &cancellables)\n }\n\n private func updateSelectedWorkspace() {\n loadingWorkspace = true\n defer { loadingWorkspace = false }\n\n workspaceName = selectedWorkspace?.name ?? \"\"\n workspaceShortcut = selectedWorkspace?.activateShortcut\n workspaceAssignShortcut = selectedWorkspace?.assignAppShortcut\n workspaceDisplay = selectedWorkspace?.display ?? NSScreen.main?.localizedName ?? \"\"\n workspaceApps = selectedWorkspace?.apps\n workspaceAppToFocus = selectedWorkspace?.appToFocus ?? AppConstants.lastFocusedOption\n workspaceSymbolIconName = selectedWorkspace?.symbolIconName\n selectedWorkspace.flatMap { selectedWorkspaces = [$0] }\n }\n\n private func reloadWorkspaces() {\n workspaces = workspaceRepository.workspaces\n if let selectedWorkspace, let workspace = workspaces.first(where: { $0.id == selectedWorkspace.id }) {\n selectedWorkspaces = [workspace]\n } else {\n selectedWorkspaces = []\n }\n selectedApps = []\n }\n}\n\nextension MainViewModel {\n func saveWorkspace() {\n guard let selectedWorkspace, !loadingWorkspace else { return }\n\n if workspaceName.trimmingCharacters(in: .whitespaces).isEmpty {\n workspaceName = \"(empty)\"\n }\n\n let updatedWorkspace = Workspace(\n id: selectedWorkspace.id,\n name: workspaceName,\n display: workspaceDisplay,\n activateShortcut: workspaceShortcut,\n assignAppShortcut: workspaceAssignShortcut,\n apps: selectedWorkspace.apps,\n appToFocus: workspaceAppToFocus == AppConstants.lastFocusedOption ? nil : workspaceAppToFocus,\n symbolIconName: workspaceSymbolIconName\n )\n\n workspaceRepository.updateWorkspace(updatedWorkspace)\n workspaces = workspaceRepository.workspaces\n self.selectedWorkspace = workspaces.first { $0.id == selectedWorkspace.id }\n }\n\n func addWorkspace() {\n userInput = \"\"\n isInputDialogPresented = true\n\n $isInputDialogPresented\n .first { !$0 }\n .sink { [weak self] _ in\n guard let self, !self.userInput.isEmpty else { return }\n\n self.workspaceRepository.addWorkspace(name: self.userInput)\n self.workspaces = self.workspaceRepository.workspaces\n self.selectedWorkspace = self.workspaces.last\n }\n .store(in: &cancellables)\n }\n\n func deleteSelectedWorkspaces() {\n guard !selectedWorkspaces.isEmpty else { return }\n\n workspaceRepository.deleteWorkspaces(ids: selectedWorkspaces.map(\\.id).asSet)\n workspaces = workspaceRepository.workspaces\n selectedWorkspaces = []\n }\n\n func addApp() {\n guard let selectedWorkspace else { return }\n\n let fileChooser = FileChooser()\n let appUrl = fileChooser.runModalOpenPanel(\n allowedFileTypes: [.application],\n directoryURL: URL(filePath: \"/Applications\")\n )\n\n guard let appUrl else { return }\n\n let appName = appUrl.appName\n let appBundleId = appUrl.bundleIdentifier ?? \"\"\n let runningApp = NSWorkspace.shared.runningApplications.first { $0.bundleIdentifier == appBundleId }\n let isAgent = appUrl.bundle?.isAgent == true && (runningApp == nil || runningApp?.activationPolicy != .regular)\n\n guard !isAgent else {\n Alert.showOkAlert(\n title: appName,\n message: \"This application is an agent (runs in background) and cannot be managed by FlashSpace.\"\n )\n return\n }\n\n guard !selectedWorkspace.apps.containsApp(with: appBundleId) else { return }\n\n workspaceRepository.addApp(\n to: selectedWorkspace.id,\n app: .init(\n name: appName,\n bundleIdentifier: appBundleId,\n iconPath: appUrl.iconPath\n )\n )\n\n workspaces = workspaceRepository.workspaces\n self.selectedWorkspace = workspaces.first { $0.id == selectedWorkspace.id }\n\n workspaceManager.activateWorkspaceIfActive(selectedWorkspace.id)\n }\n\n func deleteSelectedApps() {\n guard let selectedWorkspace, !selectedApps.isEmpty else { return }\n\n let selectedApps = Array(selectedApps)\n\n for app in selectedApps {\n workspaceRepository.deleteApp(\n from: selectedWorkspace.id,\n app: app,\n notify: app == selectedApps.last\n )\n }\n\n workspaces = workspaceRepository.workspaces\n self.selectedWorkspace = workspaces.first { $0.id == selectedWorkspace.id }\n workspaceApps = self.selectedWorkspace?.apps\n self.selectedApps = []\n\n workspaceManager.activateWorkspaceIfActive(selectedWorkspace.id)\n }\n\n func resetWorkspaceSymbolIcon() {\n workspaceSymbolIconName = nil\n saveWorkspace()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/FocusManager/FocusManager.swift", "//\n// FocusManager.swift\n//\n// Created by Wojciech Kulik on 23/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\n\nfinal class FocusManager {\n var visibleApps: [NSRunningApplication] {\n NSWorkspace.shared.runningApplications\n .filter { $0.activationPolicy == .regular && !$0.isHidden }\n }\n\n var focusedApp: NSRunningApplication? { NSWorkspace.shared.frontmostApplication }\n var focusedAppFrame: CGRect? { focusedApp?.frame }\n\n private let workspaceRepository: WorkspaceRepository\n private let workspaceManager: WorkspaceManager\n private let settings: FocusManagerSettings\n private let floatingAppsSettings: FloatingAppsSettings\n\n init(\n workspaceRepository: WorkspaceRepository,\n workspaceManager: WorkspaceManager,\n focusManagerSettings: FocusManagerSettings,\n floatingAppsSettings: FloatingAppsSettings\n ) {\n self.workspaceRepository = workspaceRepository\n self.workspaceManager = workspaceManager\n self.settings = focusManagerSettings\n self.floatingAppsSettings = floatingAppsSettings\n }\n\n func getHotKeys() -> [(AppHotKey, () -> ())] {\n guard settings.enableFocusManagement else { return [] }\n\n return [\n settings.focusLeft.flatMap { ($0, focusLeft) },\n settings.focusRight.flatMap { ($0, focusRight) },\n settings.focusUp.flatMap { ($0, focusUp) },\n settings.focusDown.flatMap { ($0, focusDown) },\n settings.focusNextWorkspaceApp.flatMap { ($0, nextWorkspaceApp) },\n settings.focusPreviousWorkspaceApp.flatMap { ($0, previousWorkspaceApp) },\n settings.focusNextWorkspaceWindow.flatMap { ($0, nextWorkspaceWindow) },\n settings.focusPreviousWorkspaceWindow.flatMap { ($0, previousWorkspaceWindow) }\n ].compactMap { $0 }\n }\n\n func nextWorkspaceWindow() {\n guard let focusedApp else { return nextWorkspaceApp() }\n guard let (_, apps) = getFocusedAppIndex() else { return }\n\n let runningWorkspaceApps = getRunningAppsWithSortedWindows(apps: apps)\n let focusedAppWindows = runningWorkspaceApps\n .first { $0.bundleIdentifier == focusedApp.bundleIdentifier }?\n .windows ?? []\n let isLastWindowFocused = focusedAppWindows.last?.axWindow.isMain == true\n\n if isLastWindowFocused {\n let nextApps = runningWorkspaceApps.drop(while: { $0.bundleIdentifier != focusedApp.bundleIdentifier }).dropFirst() +\n runningWorkspaceApps.prefix(while: { $0.bundleIdentifier != focusedApp.bundleIdentifier })\n let nextApp = nextApps.first ?? MacAppWithWindows(app: focusedApp)\n\n nextApp.app.activate()\n nextApp\n .windows\n .first?\n .axWindow\n .focus()\n } else {\n focusedAppWindows\n .drop(while: { !$0.axWindow.isMain })\n .dropFirst()\n .first?\n .axWindow\n .focus()\n }\n }\n\n func previousWorkspaceWindow() {\n guard let focusedApp else { return previousWorkspaceApp() }\n guard let (_, apps) = getFocusedAppIndex() else { return }\n\n let runningWorkspaceApps = getRunningAppsWithSortedWindows(apps: apps)\n let focusedAppWindows = runningWorkspaceApps\n .first { $0.bundleIdentifier == focusedApp.bundleIdentifier }?\n .windows ?? []\n let isFirstWindowFocused = focusedAppWindows.first?.axWindow.isMain == true\n\n if isFirstWindowFocused {\n let prevApps = runningWorkspaceApps.drop(while: { $0.bundleIdentifier != focusedApp.bundleIdentifier }).dropFirst() +\n runningWorkspaceApps.prefix(while: { $0.bundleIdentifier != focusedApp.bundleIdentifier })\n let prevApp = prevApps.last ?? MacAppWithWindows(app: focusedApp)\n\n prevApp.app.activate()\n prevApp\n .windows\n .last?\n .axWindow\n .focus()\n } else {\n focusedAppWindows\n .prefix(while: { !$0.axWindow.isMain })\n .last?\n .axWindow\n .focus()\n }\n }\n\n func nextWorkspaceApp() {\n guard let (index, apps) = getFocusedAppIndex() else { return }\n\n let appsQueue = apps.dropFirst(index + 1) + apps.prefix(index)\n let runningApps = NSWorkspace.shared.runningApplications\n .excludeFloatingAppsOnDifferentScreen()\n .compactMap(\\.bundleIdentifier)\n .asSet\n let nextApp = appsQueue.first { app in runningApps.contains(app.bundleIdentifier) }\n\n NSWorkspace.shared.runningApplications\n .find(nextApp)?\n .activate()\n }\n\n func previousWorkspaceApp() {\n guard let (index, apps) = getFocusedAppIndex() else { return }\n\n let runningApps = NSWorkspace.shared.runningApplications\n .excludeFloatingAppsOnDifferentScreen()\n .compactMap(\\.bundleIdentifier)\n .asSet\n let prefixApps = apps.prefix(index).reversed()\n let suffixApps = apps.suffix(apps.count - index - 1).reversed()\n let appsQueue = prefixApps + Array(suffixApps)\n let previousApp = appsQueue.first { app in runningApps.contains(app.bundleIdentifier) }\n\n NSWorkspace.shared.runningApplications\n .find(previousApp)?\n .activate()\n }\n\n func focusRight() {\n focus { focusedAppFrame, other in\n other.maxX > focusedAppFrame.maxX &&\n other.verticalIntersect(with: focusedAppFrame)\n }\n }\n\n func focusLeft() {\n focus { focusedAppFrame, other in\n other.minX < focusedAppFrame.minX &&\n other.verticalIntersect(with: focusedAppFrame)\n }\n }\n\n func focusDown() {\n focus { focusedAppFrame, other in\n other.maxY > focusedAppFrame.maxY &&\n other.horizontalIntersect(with: focusedAppFrame)\n }\n }\n\n func focusUp() {\n focus { focusedAppFrame, other in\n other.minY < focusedAppFrame.minY &&\n other.horizontalIntersect(with: focusedAppFrame)\n }\n }\n\n /// Predicate compares two frames using window coordinates.\n /// (0,0) is top-left corner relative to the main screen.\n /// Y-axis is pointing down.\n private func focus(predicate: (CGRect, CGRect) -> Bool) {\n guard let focusedAppFrame else { return }\n\n let appsToCheck = visibleApps\n .flatMap { app in\n app.allWindows.map {\n (app: app, window: $0.window, frame: $0.frame)\n }\n }\n\n let toFocus = appsToCheck\n .filter { predicate(focusedAppFrame, $0.frame) && !$0.window.isMinimized }\n .sorted { $0.frame.distance(to: focusedAppFrame) < $1.frame.distance(to: focusedAppFrame) }\n .first { app in\n guard settings.focusFrontmostWindow else { return true }\n\n let otherWindows = appsToCheck\n .filter { $0.app != app.app && $0.app != focusedApp }\n .map(\\.window)\n return !app.window.isBelowAnyOf(otherWindows)\n }\n\n toFocus?.window.focus()\n toFocus?.app.activate()\n centerCursorIfNeeded(in: toFocus?.frame)\n }\n\n private func centerCursorIfNeeded(in frame: CGRect?) {\n guard settings.centerCursorOnFocusChange, let frame else { return }\n\n CGWarpMouseCursorPosition(CGPoint(x: frame.midX, y: frame.midY))\n }\n\n private func getFocusedAppIndex() -> (Int, [MacApp])? {\n guard let focusedApp else { return nil }\n\n let workspace = workspaceManager.activeWorkspace[NSScreen.main?.localizedName ?? \"\"]\n ?? workspaceRepository.workspaces.first { $0.apps.containsApp(focusedApp) }\n\n guard let workspace else { return nil }\n\n let apps = workspace.apps + floatingAppsSettings.floatingApps\n .filter { !$0.isFinder }\n\n let index = apps.firstIndex(of: focusedApp) ?? 0\n\n return (index, apps)\n }\n\n private func getRunningAppsWithSortedWindows(apps: [MacApp]) -> [MacAppWithWindows] {\n let order = apps\n .enumerated()\n .reduce(into: [String: Int]()) {\n $0[$1.element.bundleIdentifier] = $1.offset\n }\n\n return NSWorkspace.shared.runningApplications\n .filter { !$0.isHidden && apps.containsApp($0) }\n .excludeFloatingAppsOnDifferentScreen()\n .map { MacAppWithWindows(app: $0) }\n .sorted { order[$0.bundleIdentifier] ?? 0 < order[$1.bundleIdentifier] ?? 0 }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/FocusManager/FocusSettingsView.swift", "//\n// FocusSettingsView.swift\n//\n// Created by Wojciech Kulik on 23/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct FocusSettingsView: View {\n @StateObject private var settings = AppDependencies.shared.focusManagerSettings\n\n var body: some View {\n Form {\n Section {\n Toggle(\"Enable Focus Manager\", isOn: $settings.enableFocusManagement)\n }\n\n Group {\n Section(\"Trigger when focus is changed using shortcuts\") {\n Toggle(\"Center Cursor In Focused App\", isOn: $settings.centerCursorOnFocusChange)\n }\n\n Section(\"Shortcuts\") {\n hotkey(\"Focus Left\", for: $settings.focusLeft)\n hotkey(\"Focus Right\", for: $settings.focusRight)\n hotkey(\"Focus Up\", for: $settings.focusUp)\n hotkey(\"Focus Down\", for: $settings.focusDown)\n }\n\n Section {\n hotkey(\"Focus Next App\", for: $settings.focusNextWorkspaceApp)\n hotkey(\"Focus Previous App\", for: $settings.focusPreviousWorkspaceApp)\n }\n\n Section {\n hotkey(\"Focus Next Window\", for: $settings.focusNextWorkspaceWindow)\n hotkey(\"Focus Previous Window\", for: $settings.focusPreviousWorkspaceWindow)\n }\n\n Section(\"Experimental\") {\n Toggle(\"Focus Frontmost Window\", isOn: $settings.focusFrontmostWindow)\n Text(\n \"This is an experimental feature. It sets the focus to the frontmost window\" +\n \" if two or more windows are overlapping in the pointed direction.\\n\\n\" +\n \"It works only with directional focus shortcuts (left, right, up, down).\"\n )\n .foregroundStyle(.secondary)\n .font(.callout)\n }\n }\n .disabled(!settings.enableFocusManagement)\n .opacity(settings.enableFocusManagement ? 1 : 0.5)\n }\n .formStyle(.grouped)\n .navigationTitle(\"Focus Manager\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Workspaces/WorkspaceHotKeys.swift", "//\n// WorkspaceHotKeys.swift\n//\n// Created by Wojciech Kulik on 08/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nfinal class WorkspaceHotKeys {\n private let workspaceManager: WorkspaceManager\n private let workspaceRepository: WorkspaceRepository\n private let workspaceSettings: WorkspaceSettings\n private let floatingAppsSettings: FloatingAppsSettings\n\n init(\n workspaceManager: WorkspaceManager,\n workspaceRepository: WorkspaceRepository,\n settingsRepository: SettingsRepository\n ) {\n self.workspaceManager = workspaceManager\n self.workspaceRepository = workspaceRepository\n self.workspaceSettings = settingsRepository.workspaceSettings\n self.floatingAppsSettings = settingsRepository.floatingAppsSettings\n }\n\n func getHotKeys() -> [(AppHotKey, () -> ())] {\n let hotKeys = [\n getAssignVisibleAppsHotKey(),\n getAssignAppHotKey(for: nil),\n getUnassignAppHotKey(),\n getToggleAssignmentHotKey(),\n getHideUnassignedAppsHotKey(),\n getRecentWorkspaceHotKey(),\n getCycleWorkspacesHotKey(next: false),\n getCycleWorkspacesHotKey(next: true)\n ] +\n workspaceRepository.workspaces\n .flatMap { [getActivateHotKey(for: $0), getAssignAppHotKey(for: $0)] }\n\n return hotKeys.compactMap(\\.self)\n }\n\n private func getActivateHotKey(for workspace: Workspace) -> (AppHotKey, () -> ())? {\n guard let shortcut = workspace.activateShortcut else { return nil }\n\n let action = { [weak self] in\n guard let self, let updatedWorkspace = workspaceRepository.workspaces\n .first(where: { $0.id == workspace.id }) else { return }\n\n if updatedWorkspace.isDynamic, updatedWorkspace.displays.isEmpty {\n Toast.showWith(\n icon: \"square.stack.3d.up\",\n message: \"\\(workspace.name) - No Running Apps To Show\",\n textColor: .gray\n )\n return\n }\n\n workspaceManager.activateWorkspace(updatedWorkspace, setFocus: true)\n }\n\n return (shortcut, action)\n }\n\n private func getAssignVisibleAppsHotKey() -> (AppHotKey, () -> ())? {\n guard let shortcut = workspaceSettings.assignVisibleApps else { return nil }\n\n return (shortcut, { [weak self] in self?.assignVisibleApps() })\n }\n\n private func getAssignAppHotKey(for workspace: Workspace?) -> (AppHotKey, () -> ())? {\n let shortcut = workspace == nil\n ? workspaceSettings.assignFocusedApp\n : workspace?.assignAppShortcut\n\n guard let shortcut else { return nil }\n\n return (shortcut, { [weak self] in self?.assignApp(to: workspace) })\n }\n\n private func getUnassignAppHotKey() -> (AppHotKey, () -> ())? {\n guard let shortcut = workspaceSettings.unassignFocusedApp else { return nil }\n\n return (shortcut, { [weak self] in self?.unassignApp() })\n }\n\n private func getToggleAssignmentHotKey() -> (AppHotKey, () -> ())? {\n guard let shortcut = workspaceSettings.toggleFocusedAppAssignment else { return nil }\n\n let action = { [weak self] in\n guard let self, let activeApp = NSWorkspace.shared.frontmostApplication else { return }\n\n if workspaceRepository.workspaces.flatMap(\\.apps).containsApp(activeApp) {\n unassignApp()\n } else {\n assignApp(to: nil)\n }\n }\n\n return (shortcut, action)\n }\n\n private func getHideUnassignedAppsHotKey() -> (AppHotKey, () -> ())? {\n guard let shortcut = workspaceSettings.hideUnassignedApps else { return nil }\n\n let action = { [weak self] in\n guard let self else { return }\n\n workspaceManager.hideUnassignedApps()\n }\n\n return (shortcut, action)\n }\n\n private func getCycleWorkspacesHotKey(next: Bool) -> (AppHotKey, () -> ())? {\n guard let shortcut = next\n ? workspaceSettings.switchToNextWorkspace\n : workspaceSettings.switchToPreviousWorkspace\n else { return nil }\n\n let action: () -> () = { [weak self] in\n guard let self else { return }\n\n workspaceManager.activateWorkspace(\n next: next,\n skipEmpty: workspaceSettings.skipEmptyWorkspacesOnSwitch,\n loop: workspaceSettings.loopWorkspaces\n )\n }\n\n return (shortcut, action)\n }\n\n private func getRecentWorkspaceHotKey() -> (AppHotKey, () -> ())? {\n guard let shortcut = workspaceSettings.switchToRecentWorkspace else { return nil }\n\n let action: () -> () = { [weak self] in\n self?.workspaceManager.activateRecentWorkspace()\n }\n\n return (shortcut, action)\n }\n}\n\nextension WorkspaceHotKeys {\n private func assignApp(to workspace: Workspace?) {\n guard let activeApp = NSWorkspace.shared.frontmostApplication else { return }\n guard let appName = activeApp.localizedName else { return }\n guard activeApp.activationPolicy == .regular else {\n Alert.showOkAlert(\n title: appName,\n message: \"This application is an agent (runs in background) and cannot be managed by FlashSpace.\"\n )\n return\n }\n\n guard let workspace = workspace ?? workspaceManager.activeWorkspace[activeApp.display ?? \"\"] else {\n Alert.showOkAlert(\n title: \"Error\",\n message: \"No workspace is active on the current display.\"\n )\n return\n }\n\n guard let updatedWorkspace = workspaceRepository.workspaces\n .first(where: { $0.id == workspace.id }) else { return }\n\n workspaceManager.assignApp(activeApp.toMacApp, to: updatedWorkspace)\n\n if !workspace.isDynamic {\n activeApp.centerApp(display: workspace.display)\n }\n\n Toast.showWith(\n icon: \"square.stack.3d.up\",\n message: \"\\(appName) - Assigned To \\(workspace.name)\",\n textColor: .positive\n )\n }\n\n private func assignVisibleApps() {\n guard let display = NSScreen.main?.localizedName else { return }\n guard let workspace = workspaceManager.activeWorkspace[display] else {\n Alert.showOkAlert(\n title: \"Error\",\n message: \"No workspace is active on the current display.\"\n )\n return\n }\n\n let visibleApps = NSWorkspace.shared.runningApplications\n .regularVisibleApps(onDisplays: workspace.displays, excluding: floatingAppsSettings.floatingApps)\n\n workspaceManager.assignApps(visibleApps.map(\\.toMacApp), to: workspace)\n\n Toast.showWith(\n icon: \"square.stack.3d.up\",\n message: \"Assigned \\(visibleApps.count) App(s) To \\(workspace.name)\",\n textColor: .positive\n )\n }\n\n private func unassignApp() {\n guard let activeApp = NSWorkspace.shared.frontmostApplication else { return }\n guard let appName = activeApp.localizedName else { return }\n\n if workspaceRepository.workspaces.flatMap(\\.apps).containsApp(activeApp) == true {\n Toast.showWith(\n icon: \"square.stack.3d.up.slash\",\n message: \"\\(appName) - Removed From Workspaces\",\n textColor: .negative\n )\n }\n\n workspaceRepository.deleteAppFromAllWorkspaces(app: activeApp.toMacApp)\n activeApp.hide()\n NotificationCenter.default.post(name: .appsListChanged, object: nil)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Workspaces/WorkspaceTransitionManager.swift", "//\n// WorkspaceTransitionManager.swift\n//\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n// Contribution by Sergio Patino - https://github.com/sergiopatino\n//\n\nimport AppKit\n\nfinal class WorkspaceTransitionManager {\n private var windows: [NSWindow] = []\n private let settings: WorkspaceSettings\n\n init(workspaceSettings: WorkspaceSettings) {\n self.settings = workspaceSettings\n }\n\n func showTransitionIfNeeded(for workspace: Workspace, on displays: Set) {\n guard settings.enableWorkspaceTransitions else {\n // Small delay to allow workspace to be activated\n DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {\n NotificationCenter.default.post(name: .workspaceTransitionFinished, object: workspace)\n }\n return\n }\n guard windows.isEmpty, !SpaceControl.isVisible else { return }\n\n let screens = NSScreen.screens.filter { displays.contains($0.localizedName) }\n\n guard !screens.isEmpty else { return }\n\n for screen in screens {\n let window = NSWindow(\n contentRect: screen.frame,\n styleMask: [.borderless],\n backing: .buffered,\n defer: false\n )\n window.isOpaque = false\n window.backgroundColor = .clear\n window.level = .screenSaver\n window.alphaValue = CGFloat(settings.workspaceTransitionDimming)\n window.contentView?.wantsLayer = true\n window.contentView?.layer?.backgroundColor = NSColor.black.cgColor\n\n window.orderFrontRegardless()\n windows.append(window)\n }\n\n DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { [weak self] in\n self?.hideTransition(for: workspace)\n }\n }\n\n private func hideTransition(for workspace: Workspace) {\n guard !windows.isEmpty else { return }\n\n NSAnimationContext.runAnimationGroup({ [weak self] context in\n context.duration = self?.settings.workspaceTransitionDuration ?? 0.3\n context.timingFunction = CAMediaTimingFunction(name: .easeIn)\n self?.windows.forEach { window in\n window.animator().alphaValue = 0.0\n }\n }, completionHandler: { [weak self] in\n self?.windows.forEach { window in\n window.orderOut(nil)\n }\n self?.windows.removeAll()\n NotificationCenter.default.post(name: .workspaceTransitionFinished, object: workspace)\n })\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Commands/WorkspaceCommands.swift", "//\n// WorkspaceCommands.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\n\nfinal class WorkspaceCommands: CommandExecutor {\n var workspaceManager: WorkspaceManager { AppDependencies.shared.workspaceManager }\n var workspaceRepository: WorkspaceRepository { AppDependencies.shared.workspaceRepository }\n\n // swiftlint:disable:next cyclomatic_complexity function_body_length\n func execute(command: CommandRequest) -> CommandResponse? {\n switch command {\n case .activateWorkspace(.some(let name), _, let clean):\n let workspace = workspaceRepository.workspaces.first { $0.name == name }\n if let workspace {\n if workspace.isDynamic, workspace.displays.isEmpty {\n return CommandResponse(success: false, error: \"\\(workspace.name) - No Running Apps To Show\")\n }\n workspaceManager.activateWorkspace(workspace, setFocus: true)\n if clean { workspaceManager.hideUnassignedApps() }\n return CommandResponse(success: true)\n } else {\n return CommandResponse(success: false, error: \"Workspace not found\")\n }\n\n case .activateWorkspace(_, .some(let number), let clean):\n let workspace = workspaceRepository.workspaces[safe: number - 1]\n if let workspace {\n if workspace.isDynamic, workspace.displays.isEmpty {\n return CommandResponse(success: false, error: \"\\(workspace.name) - No Running Apps To Show\")\n }\n workspaceManager.activateWorkspace(workspace, setFocus: true)\n if clean { workspaceManager.hideUnassignedApps() }\n return CommandResponse(success: true)\n } else {\n return CommandResponse(success: false, error: \"Workspace not found\")\n }\n\n case .updateWorkspace(let request):\n return updateWorkspace(request)\n\n case .nextWorkspace(let skipEmpty, let clean, let loop):\n workspaceManager.activateWorkspace(next: true, skipEmpty: skipEmpty, loop: loop)\n if clean { workspaceManager.hideUnassignedApps() }\n return CommandResponse(success: true)\n\n case .previousWorkspace(let skipEmpty, let clean, let loop):\n workspaceManager.activateWorkspace(next: false, skipEmpty: skipEmpty, loop: loop)\n if clean { workspaceManager.hideUnassignedApps() }\n return CommandResponse(success: true)\n\n case .recentWorkspace(let clean):\n workspaceManager.activateRecentWorkspace()\n if clean { workspaceManager.hideUnassignedApps() }\n return CommandResponse(success: true)\n\n case .createWorkspace(let request):\n let workspace = request.toWorkspace\n workspaceRepository.addWorkspace(workspace)\n if request.activate {\n workspaceManager.activateWorkspace(workspace, setFocus: true)\n }\n NotificationCenter.default.post(name: .appsListChanged, object: nil)\n return CommandResponse(success: true)\n\n case .deleteWorkspace(let name):\n let workspace = workspaceRepository.workspaces.first { $0.name == name }\n if let workspace {\n workspaceRepository.deleteWorkspace(id: workspace.id)\n NotificationCenter.default.post(name: .appsListChanged, object: nil)\n return CommandResponse(success: true)\n } else {\n return CommandResponse(success: false, error: \"Workspace not found\")\n }\n\n default:\n return nil\n }\n }\n\n private func updateWorkspace(_ request: UpdateWorkspaceRequest) -> CommandResponse {\n var workspace: Workspace?\n if let workspaceName = request.name {\n workspace = workspaceRepository.workspaces.first { $0.name == workspaceName }\n } else if let workspaceId = workspaceManager.activeWorkspaceDetails?.id {\n workspace = workspaceRepository.workspaces.first { $0.id == workspaceId }\n } else {\n return CommandResponse(success: false, error: \"Workspace not found\")\n }\n\n guard var workspace else {\n return CommandResponse(success: false, error: \"Workspace not found\")\n }\n\n if let display = request.display {\n switch display {\n case .active:\n if let display = NSWorkspace.shared.frontmostApplication?.display {\n workspace.display = display\n } else {\n return CommandResponse(success: false, error: \"No active display found\")\n }\n case .name(let name):\n workspace.display = name\n }\n }\n\n workspaceRepository.updateWorkspace(workspace)\n NotificationCenter.default.post(name: .appsListChanged, object: nil)\n\n return CommandResponse(success: true)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/SpaceControl/Views/SpaceControlWindow.swift", "//\n// SpaceControlWindow.swift\n//\n// Created by Wojciech Kulik on 11/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport SwiftUI\n\nfinal class SpaceControlWindow: NSWindow, NSWindowDelegate {\n override var canBecomeKey: Bool { true }\n\n override func keyDown(with event: NSEvent) {\n if event.keyCode == KeyCodesMap[\"escape\"] {\n SpaceControl.hide(restoreFocus: true)\n return\n } else if [\"up\", \"down\", \"right\", \"left\"]\n .compactMap({ KeyCodesMap[$0] })\n .contains(event.keyCode) {\n NotificationCenter.default.post(name: .spaceControlArrowDown, object: event.keyCode)\n return\n }\n\n let settings = AppDependencies.shared.spaceControlSettings\n let workspaceManager = AppDependencies.shared.workspaceManager\n var workspaces = AppDependencies.shared.workspaceRepository.workspaces\n\n if settings.spaceControlCurrentDisplayWorkspaces {\n workspaces = workspaces.filter(\\.isOnTheCurrentScreen)\n }\n\n var digit = Int(event.charactersIgnoringModifiers ?? \"\") ?? -1\n if (0...9).contains(digit) {\n SpaceControl.hide()\n digit = digit == 0 ? 10 : digit\n\n if let workspace = workspaces[safe: digit - 1] {\n workspaceManager.activateWorkspace(workspace, setFocus: true)\n }\n return\n }\n\n super.keyDown(with: event)\n }\n\n override func resignFirstResponder() -> Bool {\n SpaceControl.hide()\n return super.resignFirstResponder()\n }\n\n func windowDidResignKey(_ notification: Notification) {\n SpaceControl.hide()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Commands/AppCommands.swift", "//\n// AppCommands.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\n\nfinal class AppCommands: CommandExecutor {\n var workspaceManager: WorkspaceManager { AppDependencies.shared.workspaceManager }\n var workspaceRepository: WorkspaceRepository { AppDependencies.shared.workspaceRepository }\n var settings: WorkspaceSettings { AppDependencies.shared.workspaceSettings }\n var floatingAppsSettings: FloatingAppsSettings { AppDependencies.shared.floatingAppsSettings }\n\n func execute(command: CommandRequest) -> CommandResponse? {\n switch command {\n case .assignVisibleApps(let workspaceName, let showNotification):\n return assignVisibleApps(workspaceName: workspaceName, showNotification: showNotification)\n\n case .assignApp(let app, let workspaceName, let activate, let showNotification):\n return assignApp(\n app: app,\n workspaceName: workspaceName,\n activate: activate,\n showNotification: showNotification\n )\n\n case .unassignApp(let app, let showNotification):\n return unassignApp(app: app, showNotification: showNotification)\n\n case .hideUnassignedApps:\n workspaceManager.hideUnassignedApps()\n return CommandResponse(success: true)\n\n case .floatApp(let app, let showNotification):\n return floatApp(app: app, showNotification: showNotification)\n\n case .unfloatApp(let app, let showNotification):\n return unfloatApp(app: app, showNotification: showNotification)\n\n case .toggleFloatApp(let app, let showNotification):\n return toggleFloatApp(app: app, showNotification: showNotification)\n\n default:\n return nil\n }\n }\n\n private func findApp(app: String?) -> MacApp? {\n guard let app else { return NSWorkspace.shared.frontmostApplication?.toMacApp }\n\n let foundApp = NSWorkspace.shared.runningApplications\n .first { $0.localizedName == app }?\n .toMacApp\n\n if foundApp == nil, let appUrl = NSWorkspace.shared.urlForApplication(withBundleIdentifier: app) {\n return MacApp(\n name: appUrl.bundle?.localizedAppName ?? \"\",\n bundleIdentifier: app,\n iconPath: appUrl.iconPath\n )\n }\n\n return foundApp\n }\n\n private func unassignApp(app: String?, showNotification: Bool) -> CommandResponse {\n guard let app = findApp(app: app) else {\n return CommandResponse(\n success: false,\n error: \"App not found or not running. For not running apps use `unassign-app --name `.\"\n )\n }\n\n workspaceRepository.deleteAppFromAllWorkspaces(app: app)\n NSWorkspace.shared.runningApplications.find(app)?.hide()\n NotificationCenter.default.post(name: .appsListChanged, object: nil)\n\n if showNotification {\n Toast.showWith(\n icon: \"square.stack.3d.up.slash\",\n message: \"\\(app.name) - Removed From Workspaces\",\n textColor: .negative\n )\n }\n\n return CommandResponse(success: true)\n }\n\n private func assignVisibleApps(workspaceName: String?, showNotification: Bool) -> CommandResponse {\n guard let workspaceName = workspaceName ?? workspaceManager.activeWorkspaceDetails?.name else {\n return CommandResponse(success: false, error: \"No workspace selected\")\n }\n\n guard let workspace = workspaceRepository.workspaces.first(where: { $0.name == workspaceName }) else {\n return CommandResponse(success: false, error: \"Workspace not found\")\n }\n\n let visibleApps = NSWorkspace.shared.runningApplications\n .regularVisibleApps(onDisplays: workspace.displays, excluding: floatingAppsSettings.floatingApps)\n\n guard !visibleApps.isEmpty else {\n return CommandResponse(\n success: false,\n error: \"No visible apps found on the current display\"\n )\n }\n\n workspaceManager.assignApps(visibleApps.map(\\.toMacApp), to: workspace)\n\n if showNotification {\n Toast.showWith(\n icon: \"square.stack.3d.up\",\n message: \"Assigned \\(visibleApps.count) Apps(s) To \\(workspace.name)\",\n textColor: .positive\n )\n }\n\n return CommandResponse(success: true)\n }\n\n private func assignApp(\n app: String?,\n workspaceName: String?,\n activate: Bool?,\n showNotification: Bool\n ) -> CommandResponse {\n guard let workspaceName = workspaceName ?? workspaceManager.activeWorkspaceDetails?.name else {\n return CommandResponse(success: false, error: \"No workspace selected\")\n }\n\n guard let workspace = workspaceRepository.workspaces.first(where: { $0.name == workspaceName }) else {\n return CommandResponse(success: false, error: \"Workspace not found\")\n }\n\n guard let app = findApp(app: app) else {\n return CommandResponse(\n success: false,\n error: \"App not found or not running. For not running apps use `assign-app --name `.\"\n )\n }\n\n let previousSetting = settings.changeWorkspaceOnAppAssign\n if let activate {\n settings.changeWorkspaceOnAppAssign = activate\n }\n workspaceManager.assignApp(app, to: workspace)\n if activate != nil {\n settings.changeWorkspaceOnAppAssign = previousSetting\n }\n\n if showNotification {\n Toast.showWith(\n icon: \"square.stack.3d.up\",\n message: \"\\(app.name) - Assigned To \\(workspace.name)\",\n textColor: .positive\n )\n }\n\n return CommandResponse(success: true)\n }\n\n private func floatApp(app: String?, showNotification: Bool) -> CommandResponse {\n guard let app = findApp(app: app) else {\n return CommandResponse(\n success: false,\n error: \"App not found or not running. For not running apps use `float-app --name `.\"\n )\n }\n\n floatingAppsSettings.addFloatingAppIfNeeded(app: app)\n\n if showNotification {\n Toast.showWith(\n icon: \"macwindow.on.rectangle\",\n message: \"\\(app.name) - Added To Floating Apps\",\n textColor: .positive\n )\n }\n\n return CommandResponse(success: true)\n }\n\n private func unfloatApp(app: String?, showNotification: Bool) -> CommandResponse {\n guard let app = findApp(app: app) else {\n return CommandResponse(\n success: false,\n error: \"App not found or not running. For not running apps use `unfloat-app --name `.\"\n )\n }\n\n guard floatingAppsSettings.floatingApps.containsApp(with: app.bundleIdentifier) else {\n return CommandResponse(success: true)\n }\n\n floatingAppsSettings.deleteFloatingApp(app: app)\n\n if let runningApp = NSWorkspace.shared.runningApplications.find(app),\n let screen = runningApp.display,\n workspaceManager.activeWorkspace[screen]?.apps.containsApp(runningApp) != true {\n runningApp.hide()\n }\n\n if showNotification {\n Toast.showWith(\n icon: \"macwindow\",\n message: \"\\(app.name) - Removed From Floating Apps\",\n textColor: .negative\n )\n }\n\n return CommandResponse(success: true)\n }\n\n private func toggleFloatApp(app: String?, showNotification: Bool) -> CommandResponse {\n guard let macApp = findApp(app: app) else {\n return CommandResponse(\n success: false,\n error: \"App not found or not running. For not running apps use `toggle-float-app --name `.\"\n )\n }\n\n let isFloating = floatingAppsSettings.floatingApps.containsApp(with: macApp.bundleIdentifier)\n\n return isFloating\n ? unfloatApp(app: app, showNotification: showNotification)\n : floatApp(app: app, showNotification: showNotification)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/SpaceControl/SpaceControl.swift", "//\n// SpaceControl.swift\n//\n// Created by Wojciech Kulik on 11/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport SwiftUI\n\nenum SpaceControl {\n static var isEnabled: Bool { settings.enableSpaceControl }\n static var isVisible: Bool { window != nil }\n static var window: NSWindow?\n\n private static var settings: SpaceControlSettings { AppDependencies.shared.spaceControlSettings }\n private static var focusedAppBeforeShow: NSRunningApplication?\n\n static func getHotKey() -> (AppHotKey, () -> ())? {\n guard isEnabled else { return nil }\n\n if let spaceControlHotKey = settings.showSpaceControl {\n return (spaceControlHotKey, toggle)\n }\n\n return nil\n }\n\n static func toggle() {\n if isVisible {\n hide(restoreFocus: true)\n } else {\n show()\n }\n }\n\n static func hide(restoreFocus: Bool = false) {\n window?.orderOut(nil)\n window = nil\n\n if restoreFocus {\n focusedAppBeforeShow?.activate()\n focusedAppBeforeShow = nil\n }\n }\n\n static func show() {\n guard validate() else { return }\n\n PermissionsManager.shared.askForScreenRecordingPermissions()\n\n if Self.window != nil { hide() }\n\n let contentView = NSHostingView(\n rootView: SpaceControlView()\n )\n\n // contentRect is in screen coordinates where (0,0) is bottom-left corner\n // and it is relative to the main screen.\n let window = SpaceControlWindow(\n contentRect: NSScreen.main!.frame,\n styleMask: [.borderless],\n backing: .buffered,\n defer: false\n )\n window.isOpaque = false\n window.backgroundColor = .clear\n window.level = .screenSaver\n window.delegate = window\n Self.window = window\n\n let animations = settings.enableSpaceControlAnimations\n\n window.contentView = contentView.addVisualEffect(material: .fullScreenUI)\n window.alphaValue = animations ? 0 : 1\n\n focusedAppBeforeShow = NSWorkspace.shared.frontmostApplication\n NSApp.activate(ignoringOtherApps: true)\n window.orderFrontRegardless()\n window.makeKeyAndOrderFront(nil)\n\n if animations {\n window.animator().alphaValue = 1\n }\n }\n\n private static func validate() -> Bool {\n let workspaces = AppDependencies.shared.workspaceRepository.workspaces\n let nonEmptyWorkspaces = workspaces\n .filter { !settings.spaceControlCurrentDisplayWorkspaces || $0.isOnTheCurrentScreen }\n\n if nonEmptyWorkspaces.count < 2 {\n Alert.showOkAlert(title: \"Space Control\", message: \"You need at least 2 workspaces to use Space Control.\")\n return false\n }\n\n return true\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/HotKeys/HotKeysManager.swift", "//\n// HotKeysManager.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Combine\nimport ShortcutRecorder\n\nfinal class HotKeysManager {\n private(set) var allHotKeys: [(scope: String, hotKey: AppHotKey)] = []\n\n private var cancellables = Set()\n\n private let hotKeysMonitor: HotKeysMonitorProtocol\n private let workspaceHotKeys: WorkspaceHotKeys\n private let floatingAppsHotKeys: FloatingAppsHotKeys\n private let focusManager: FocusManager\n private let settingsRepository: SettingsRepository\n\n init(\n hotKeysMonitor: HotKeysMonitorProtocol,\n workspaceHotKeys: WorkspaceHotKeys,\n floatingAppsHotKeys: FloatingAppsHotKeys,\n focusManager: FocusManager,\n settingsRepository: SettingsRepository\n ) {\n self.hotKeysMonitor = hotKeysMonitor\n self.workspaceHotKeys = workspaceHotKeys\n self.floatingAppsHotKeys = floatingAppsHotKeys\n self.focusManager = focusManager\n self.settingsRepository = settingsRepository\n\n observe()\n }\n\n func refresh() {\n disableAll()\n enableAll()\n }\n\n // swiftlint:disable:next function_body_length\n func enableAll() {\n allHotKeys.removeAll()\n let addShortcut = { (title: String, shortcut: Shortcut) in\n self.allHotKeys.append((title, .init(\n keyCode: shortcut.keyCode.rawValue,\n modifiers: shortcut.modifierFlags.rawValue\n )))\n }\n\n // Workspaces\n for (shortcut, action) in workspaceHotKeys.getHotKeys().toShortcutPairs() {\n let action = ShortcutAction(shortcut: shortcut) { _ in\n action()\n return true\n }\n\n hotKeysMonitor.addAction(action, forKeyEvent: .down)\n addShortcut(\"Workspace\", shortcut)\n }\n\n // Floating Apps\n for (shortcut, action) in floatingAppsHotKeys.getHotKeys().toShortcutPairs() {\n let action = ShortcutAction(shortcut: shortcut) { _ in\n action()\n return true\n }\n\n hotKeysMonitor.addAction(action, forKeyEvent: .down)\n addShortcut(\"Floating Apps\", shortcut)\n }\n\n // Focus Manager\n for (shortcut, action) in focusManager.getHotKeys().toShortcutPairs() {\n let action = ShortcutAction(shortcut: shortcut) { _ in\n action()\n return true\n }\n hotKeysMonitor.addAction(action, forKeyEvent: .down)\n addShortcut(\"Focus Manager\", shortcut)\n }\n\n // General\n if let showHotKey = settingsRepository.generalSettings.showFlashSpace?.toShortcut() {\n let action = ShortcutAction(shortcut: showHotKey) { _ in\n guard !SpaceControl.isVisible else { return true }\n\n let visibleAppWindows = NSApp.windows\n .filter(\\.isVisible)\n .filter { $0.identifier?.rawValue == \"main\" || $0.identifier?.rawValue == \"settings\" }\n\n if visibleAppWindows.isEmpty {\n NotificationCenter.default.post(name: .openMainWindow, object: nil)\n } else {\n visibleAppWindows.forEach { $0.close() }\n }\n return true\n }\n hotKeysMonitor.addAction(action, forKeyEvent: .down)\n addShortcut(\"General\", showHotKey)\n }\n\n // SpaceControl\n if let (hotKey, action) = SpaceControl.getHotKey(), let shortcut = hotKey.toShortcut() {\n let action = ShortcutAction(shortcut: shortcut) { _ in\n action()\n return true\n }\n hotKeysMonitor.addAction(action, forKeyEvent: .down)\n addShortcut(\"Space Control\", shortcut)\n }\n }\n\n func disableAll() {\n hotKeysMonitor.removeAllActions()\n }\n\n private func observe() {\n NotificationCenter.default\n .publisher(for: .profileChanged)\n .sink { [weak self] _ in self?.refresh() }\n .store(in: &cancellables)\n\n DistributedNotificationCenter.default()\n .publisher(for: .init(rawValue: kTISNotifySelectedKeyboardInputSourceChanged as String))\n .sink { [weak self] _ in\n KeyCodesMap.refresh()\n self?.disableAll()\n self?.enableAll()\n }\n .store(in: &cancellables)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/About/AboutSettingsView.swift", "//\n// AboutSettingsView.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct AboutSettingsView: View {\n var body: some View {\n Form {\n Section(\"FlashSpace\") {\n HStack {\n Text(\"Version \\(AppConstants.version)\")\n Spacer()\n Button(\"GitHub\") { openGitHub(\"wojciech-kulik/FlashSpace\") }\n Button(\"Check for Updates\") { UpdatesManager.shared.checkForUpdates() }\n }\n }\n\n Section(\"Author\") {\n HStack {\n Text(\"Wojciech Kulik (@wojciech-kulik)\")\n Spacer()\n Button(\"GitHub\") { openGitHub(\"wojciech-kulik\") }\n Button(\"X.com\") { openUrl(\"https://x.com/kulik_wojciech\") }\n Button(\"snippety.app\") { openUrl(\"https://snippety.app\") }\n }\n }\n\n Section(\"Contributors\") {\n HStack {\n Text(\"Kwangmin Bae / Shirou (@PangMo5)\")\n Spacer()\n Button(\"GitHub\") { openGitHub(\"PangMo5\") }\n }\n HStack {\n Text(\"Sergio (@sergiopatino)\")\n Spacer()\n Button(\"GitHub\") { openGitHub(\"sergiopatino\") }\n }\n HStack {\n Text(\"Moritz Brödel (@brodmo)\")\n Spacer()\n Button(\"GitHub\") { openGitHub(\"brodmo\") }\n }\n }\n }\n .buttonStyle(.accessoryBarAction)\n .formStyle(.grouped)\n .navigationTitle(\"About\")\n }\n\n private func openGitHub(_ login: String) {\n openUrl(\"https://github.com/\\(login)\")\n }\n\n private func openUrl(_ url: String) {\n if let url = URL(string: url) {\n NSWorkspace.shared.open(url)\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Displays/DisplayManager.swift", "//\n// DisplayManager.swift\n//\n// Created by Moritz Brödel on 19/06/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Combine\n\nfinal class DisplayManager: ObservableObject {\n struct Focus {\n let display: DisplayName\n let app: MacApp\n }\n\n private var focusHistory: [Focus] = []\n private let workspaceSettings: WorkspaceSettings\n\n init(settingsRepository: SettingsRepository) {\n self.workspaceSettings = settingsRepository.workspaceSettings\n }\n\n func lastFocusedDisplay(where condition: (Focus) -> Bool) -> Focus? {\n focusHistory.last(where: condition)\n }\n\n func trackDisplayFocus(on display: DisplayName, for application: NSRunningApplication) {\n guard !application.isFinder || application.allWindows.isNotEmpty else { return }\n\n focusHistory.removeAll { $0.display == display }\n focusHistory.append(.init(display: display, app: application.toMacApp))\n }\n\n func getCursorScreen() -> DisplayName? {\n let cursorLocation = NSEvent.mouseLocation\n return NSScreen.screens\n .first { NSMouseInRect(cursorLocation, $0.frame, false) }?\n .localizedName\n }\n\n func resolveDisplay(_ display: DisplayName) -> DisplayName {\n guard !NSScreen.isConnected(display) else { return display }\n\n let alternativeDisplays = workspaceSettings.alternativeDisplays\n .split(separator: \";\")\n .map { $0.split(separator: \"=\") }\n .compactMap { pair -> (source: String, target: String)? in\n guard pair.count == 2 else { return nil }\n return (String(pair[0]).trimmed, String(pair[1]).trimmed)\n }\n\n let alternative = alternativeDisplays\n .filter { $0.source == display }\n .map(\\.target)\n .first(where: NSScreen.isConnected)\n\n return alternative ?? NSScreen.main?.localizedName ?? \"\"\n }\n\n func lastActiveDisplay(from candidates: Set) -> DisplayName {\n if let recentDisplay = lastFocusedDisplay(where: { candidates.contains($0.display) })?.display {\n return recentDisplay\n }\n\n if let cursorDisplay = getCursorScreen(), candidates.contains(cursorDisplay) {\n return cursorDisplay\n }\n\n return candidates.first ?? NSScreen.main?.localizedName ?? \"\"\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Gestures/GestureAction.swift", "//\n// GestureAction.swift\n//\n// Created by Wojciech Kulik on 30/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nenum GestureAction {\n case none\n case toggleSpaceControl\n case showSpaceControl\n case hideSpaceControl\n case nextWorkspace\n case previousWorkspace\n case mostRecentWorkspace\n case focusLeft\n case focusRight\n case focusUp\n case focusDown\n case focusNextApp\n case focusPreviousApp\n case focusNextWindow\n case focusPreviousWindow\n case activateWorkspace(String)\n}\n\nextension GestureAction: CaseIterable, Equatable, Hashable, Identifiable {\n var id: String { description }\n\n var description: String {\n switch self {\n case .none: return \"None\"\n case .toggleSpaceControl: return \"Toggle Space Control\"\n case .showSpaceControl: return \"Show Space Control\"\n case .hideSpaceControl: return \"Hide Space Control\"\n case .nextWorkspace: return \"Next Workspace\"\n case .previousWorkspace: return \"Previous Workspace\"\n case .mostRecentWorkspace: return \"Most Recent Workspace\"\n case .focusLeft: return \"Focus Left\"\n case .focusRight: return \"Focus Right\"\n case .focusUp: return \"Focus Up\"\n case .focusDown: return \"Focus Down\"\n case .focusNextApp: return \"Focus Next App\"\n case .focusPreviousApp: return \"Focus Previous App\"\n case .focusNextWindow: return \"Focus Next Window\"\n case .focusPreviousWindow: return \"Focus Previous Window\"\n case .activateWorkspace(let workspaceName):\n return \"Activate Workspace: \\(workspaceName)\"\n }\n }\n\n static var allCases: [GestureAction] {\n let workspaces = AppDependencies.shared.workspaceRepository.workspaces\n return allCasesWithoutWorkspaces + workspaces.map { .activateWorkspace($0.name) }\n }\n\n static var allCasesWithoutWorkspaces: [GestureAction] {\n [\n .none,\n .toggleSpaceControl,\n .showSpaceControl,\n .hideSpaceControl,\n .nextWorkspace,\n .previousWorkspace,\n .mostRecentWorkspace,\n .focusLeft,\n .focusRight,\n .focusUp,\n .focusDown,\n .focusNextApp,\n .focusPreviousApp,\n .focusNextWindow,\n .focusPreviousWindow\n ]\n }\n}\n\nextension GestureAction: Codable {\n init(from decoder: Decoder) throws {\n let container = try decoder.singleValueContainer()\n let value = try container.decode(String.self)\n\n if value.hasPrefix(\"activateWorkspace:\") {\n let workspaceName = String(value.dropFirst(\"activateWorkspace:\".count))\n self = .activateWorkspace(workspaceName)\n } else if let action = GestureAction.allCasesWithoutWorkspaces.first(where: { $0.normalizedDescription == value }) {\n self = action\n } else {\n self = .none\n }\n }\n\n func encode(to encoder: Encoder) throws {\n var container = encoder.singleValueContainer()\n try container.encode(normalizedDescription)\n }\n\n private var normalizedDescription: String {\n if case .activateWorkspace(let workspaceName) = self {\n return \"activateWorkspace:\\(workspaceName)\"\n }\n\n let result = String(description.first?.lowercased() ?? \"\") + description.dropFirst()\n return result.replacingOccurrences(of: \" \", with: \"\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/FocusManager/FocusedWindowTracker.swift", "//\n// FocusedWindowTracker.swift\n//\n// Created by Wojciech Kulik on 20/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Combine\n\nfinal class FocusedWindowTracker {\n private var cancellables = Set()\n\n private let workspaceRepository: WorkspaceRepository\n private let workspaceManager: WorkspaceManager\n private let settingsRepository: SettingsRepository\n private let pictureInPictureManager: PictureInPictureManager\n\n init(\n workspaceRepository: WorkspaceRepository,\n workspaceManager: WorkspaceManager,\n settingsRepository: SettingsRepository,\n pictureInPictureManager: PictureInPictureManager\n ) {\n self.workspaceRepository = workspaceRepository\n self.workspaceManager = workspaceManager\n self.settingsRepository = settingsRepository\n self.pictureInPictureManager = pictureInPictureManager\n }\n\n func startTracking() {\n NSWorkspace.shared.notificationCenter\n .publisher(for: NSWorkspace.didActivateApplicationNotification)\n .compactMap { $0.userInfo?[NSWorkspace.applicationUserInfoKey] as? NSRunningApplication }\n .removeDuplicates()\n .sink { [weak self] app in self?.activeApplicationChanged(app) }\n .store(in: &cancellables)\n }\n\n func stopTracking() {\n cancellables.removeAll()\n }\n\n private func activeApplicationChanged(_ app: NSRunningApplication) {\n guard settingsRepository.workspaceSettings.activeWorkspaceOnFocusChange else { return }\n\n let activeWorkspaces = workspaceManager.activeWorkspace.values\n\n // Skip if the workspace was activated recently\n guard Date().timeIntervalSince(workspaceManager.lastWorkspaceActivation) > 0.2 else { return }\n\n // Skip if the app is floating\n guard !settingsRepository.floatingAppsSettings.floatingApps.containsApp(app) else { return }\n\n // Find the workspace that contains the app.\n // The same app can be in multiple workspaces, the highest priority has the one\n // from the active workspace.\n guard let workspace = (activeWorkspaces + workspaceRepository.workspaces)\n .first(where: { $0.apps.containsApp(app) }) else { return }\n\n // Skip if the workspace is already active\n guard activeWorkspaces.count(where: { $0.id == workspace.id }) < workspace.displays.count else { return }\n\n // Skip if the focused window is in Picture in Picture mode\n guard !settingsRepository.workspaceSettings.enablePictureInPictureSupport ||\n !app.supportsPictureInPicture ||\n app.focusedWindow?.isPictureInPicture(bundleId: app.bundleIdentifier) != true else { return }\n\n let activate = { [self] in\n Logger.log(\"\")\n Logger.log(\"\")\n Logger.log(\"Activating workspace for app: \\(workspace.name)\")\n workspaceManager.updateLastFocusedApp(app.toMacApp, in: workspace)\n workspaceManager.activateWorkspace(workspace, setFocus: false)\n app.activate()\n\n // Restore the app if it was hidden\n if settingsRepository.workspaceSettings.enablePictureInPictureSupport, app.supportsPictureInPicture {\n pictureInPictureManager.restoreAppIfNeeded(app: app)\n }\n }\n\n if workspace.isDynamic, workspace.displays.isEmpty {\n DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(500)) {\n activate()\n }\n } else {\n activate()\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Commands/GetCommands.swift", "//\n// GetCommands.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\n\nfinal class GetCommands: CommandExecutor {\n var workspaceManager: WorkspaceManager { AppDependencies.shared.workspaceManager }\n var profilesRepository: ProfilesRepository { AppDependencies.shared.profilesRepository }\n\n func execute(command: CommandRequest) -> CommandResponse? {\n switch command {\n case .getProfile:\n let result = profilesRepository.selectedProfile.name\n return CommandResponse(success: true, message: result)\n\n case .getWorkspace(let display):\n let workspace = workspaceManager.activeWorkspace[display ?? NSScreen.main?.localizedName ?? \"\"]\n if let workspace {\n let result = workspace.name\n return CommandResponse(success: true, message: result)\n } else {\n return CommandResponse(success: false, error: \"No active workspace\")\n }\n\n case .getApp(let withWindowsCount):\n if let app = NSWorkspace.shared.frontmostApplication, let appName = app.localizedName {\n if withWindowsCount {\n return CommandResponse(success: true, message: \"\\(appName)\\n\\(app.allWindows.count)\")\n } else {\n return CommandResponse(success: true, message: appName)\n }\n } else {\n return CommandResponse(success: false, error: \"No active app\")\n }\n\n case .getDisplay:\n if let display = NSScreen.main?.localizedName {\n return CommandResponse(success: true, message: display)\n } else {\n return CommandResponse(success: false, error: \"No display found\")\n }\n\n default:\n return nil\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/UI/HotKeyControl.swift", "//\n// HotKeyControl.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport ShortcutRecorder\nimport SwiftUI\n\nstruct HotKeyControl: NSViewRepresentable {\n @Binding var shortcut: AppHotKey?\n\n func makeNSView(context: Context) -> RecorderControl {\n let control = RecorderControl(frame: .zero)\n control.delegate = context.coordinator\n control.objectValue = shortcut.flatMap { $0.toShortcut() }\n control.set(\n allowedModifierFlags: [.command, .option, .control, .shift],\n requiredModifierFlags: [],\n allowsEmptyModifierFlags: true\n )\n\n return control\n }\n\n func updateNSView(_ nsView: RecorderControl, context: Context) {\n context.coordinator.parent = self\n nsView.objectValue = shortcut.flatMap { $0.toShortcut() }\n }\n\n func makeCoordinator() -> Coordinator { Coordinator(parent: self) }\n\n final class Coordinator: NSObject, RecorderControlDelegate {\n var parent: HotKeyControl\n\n private let hotKeysManager = AppDependencies.shared.hotKeysManager\n\n init(parent: HotKeyControl) {\n self.parent = parent\n }\n\n func recorderControlDidBeginRecording(_ aControl: RecorderControl) {\n hotKeysManager.disableAll()\n }\n\n func recorderControl(_ aControl: RecorderControl, canRecord aShortcut: Shortcut) -> Bool {\n if let conflict = hotKeysManager.allHotKeys.first(where: { $0.hotKey.toShortcut() == aShortcut })?.scope {\n Alert.showOkAlert(\n title: \"Conflict\",\n message: \"This shortcut is already assigned within the \\(conflict) scope.\"\n )\n return false\n }\n\n return true\n }\n\n func recorderControlDidEndRecording(_ aControl: RecorderControl) {\n guard let shortcut = aControl.objectValue else {\n parent.shortcut = nil\n hotKeysManager.enableAll()\n return\n }\n\n parent.shortcut = .init(\n keyCode: shortcut.keyCode.rawValue,\n modifiers: shortcut.modifierFlags.rawValue\n )\n hotKeysManager.enableAll()\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/CLIServer.swift", "//\n// CLIServer.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\nimport Network\n\nfinal class CLIServer {\n var isRunning: Bool {\n switch listener?.state ?? .cancelled {\n case .cancelled, .failed: return false\n default: return true\n }\n }\n\n private var listener: NWListener?\n private let socketPath = \"/tmp/flashspace.socket\"\n private let executors: [CommandExecutor] = [\n ProfileCommands(),\n WorkspaceCommands(),\n AppCommands(),\n FocusCommands(),\n SpaceControlCommands(),\n ListCommands(),\n GetCommands()\n ]\n\n init() { startServer() }\n\n func restart() {\n listener?.cancel()\n startServer()\n }\n\n private func startServer() {\n try? FileManager.default.removeItem(atPath: socketPath)\n\n do {\n let params = NWParameters(tls: nil, tcp: .init())\n params.allowLocalEndpointReuse = true\n params.requiredLocalEndpoint = .unix(path: socketPath)\n\n listener = try NWListener(using: params)\n listener?.newConnectionHandler = handleNewConnection\n listener?.start(queue: .global(qos: .userInitiated))\n Logger.log(\"🟢 Server started at \\(socketPath)\")\n } catch {\n Logger.log(\"❌ Failed to start server: \\(error)\")\n }\n }\n\n private func handleNewConnection(_ connection: NWConnection) {\n connection.start(queue: .global(qos: .userInitiated))\n Logger.log(\"✅ New client connected\")\n\n let buffer = BufferWrapper()\n receiveData(connection: connection, buffer: buffer)\n }\n\n private func receiveData(connection: NWConnection, buffer: BufferWrapper) {\n connection.receive(minimumIncompleteLength: 1, maximumLength: 10000) { data, _, isComplete, error in\n if let error {\n connection.cancel()\n return Logger.log(\"❌ Receive error: \\(error)\")\n }\n\n if let data { buffer.data.append(data) }\n\n // Check if complete or EOF at the end\n guard isComplete || data?.last == 0 else {\n return self.receiveData(connection: connection, buffer: buffer)\n }\n\n guard !buffer.data.isEmpty else {\n connection.cancel()\n return Logger.log(\"❌ Received empty data\")\n }\n\n do {\n let command = try buffer.data.decodeSocketData(CommandRequest.self)\n DispatchQueue.main.async {\n self.handleCommand(command, connection: connection)\n }\n } catch {\n connection.cancel()\n Logger.log(\"❌ Failed to decode command: \\(error)\")\n }\n }\n }\n\n private func handleCommand(_ command: CommandRequest, connection: NWConnection) {\n var result: CommandResponse?\n for executor in executors {\n result = executor.execute(command: command)\n if result != nil { break }\n }\n\n DispatchQueue.global(qos: .userInitiated).async {\n if let response = result?.encodeSocketData() {\n connection.send(content: response, completion: .contentProcessed { _ in connection.cancel() })\n } else {\n connection.cancel()\n Logger.log(\"❌ Failed to encode response\")\n }\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Workspaces/WorkspaceRepository.swift", "//\n// WorkspaceRepository.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Combine\nimport Foundation\n\nfinal class WorkspaceRepository: ObservableObject {\n @Published private(set) var workspaces: [Workspace] = []\n\n private let profilesRepository: ProfilesRepository\n\n init(profilesRepository: ProfilesRepository) {\n self.profilesRepository = profilesRepository\n self.workspaces = profilesRepository.selectedProfile.workspaces\n\n profilesRepository.onProfileChange = { [weak self] profile in\n self?.workspaces = profile.workspaces\n }\n }\n\n func addWorkspace(name: String) {\n let workspace = Workspace(\n id: .init(),\n name: name,\n display: NSScreen.main?.localizedName ?? \"\",\n activateShortcut: nil,\n assignAppShortcut: nil,\n apps: []\n )\n workspaces.append(workspace)\n notifyAboutChanges()\n }\n\n func addWorkspace(_ workspace: Workspace) {\n workspaces.append(workspace)\n notifyAboutChanges()\n }\n\n func updateWorkspace(_ workspace: Workspace) {\n guard let workspaceIndex = workspaces.firstIndex(where: { $0.id == workspace.id }) else { return }\n\n workspaces[workspaceIndex] = workspace\n notifyAboutChanges()\n AppDependencies.shared.hotKeysManager.refresh()\n }\n\n func deleteWorkspace(id: WorkspaceID) {\n workspaces.removeAll { $0.id == id }\n notifyAboutChanges()\n }\n\n func deleteWorkspaces(ids: Set) {\n workspaces.removeAll { ids.contains($0.id) }\n notifyAboutChanges()\n }\n\n func addApp(to workspaceId: WorkspaceID, app: MacApp) {\n guard let workspaceIndex = workspaces.firstIndex(where: { $0.id == workspaceId }) else { return }\n guard !workspaces[workspaceIndex].apps.contains(app) else { return }\n\n workspaces[workspaceIndex].apps.append(app)\n notifyAboutChanges()\n }\n\n func deleteApp(from workspaceId: WorkspaceID, app: MacApp, notify: Bool = true) {\n guard let workspaceIndex = workspaces.firstIndex(where: { $0.id == workspaceId }) else { return }\n\n if workspaces[workspaceIndex].appToFocus == app {\n workspaces[workspaceIndex].appToFocus = nil\n }\n\n workspaces[workspaceIndex].apps.removeAll { $0 == app }\n if notify { notifyAboutChanges() }\n }\n\n func deleteAppFromAllWorkspaces(app: MacApp) {\n for (index, var workspace) in workspaces.enumerated() {\n workspace.apps.removeAll { $0 == app }\n if workspace.appToFocus == app {\n workspace.appToFocus = nil\n }\n\n workspaces[index] = workspace\n }\n notifyAboutChanges()\n }\n\n func reorderWorkspaces(newOrder: [WorkspaceID]) {\n let map = newOrder.enumerated().reduce(into: [WorkspaceID: Int]()) { $0[$1.element] = $1.offset }\n workspaces = workspaces.sorted { map[$0.id] ?? 0 < map[$1.id] ?? 0 }\n notifyAboutChanges()\n }\n\n func moveApps(_ apps: [MacApp], from sourceWorkspaceId: WorkspaceID, to targetWorkspaceId: WorkspaceID) {\n guard let sourceWorkspaceIndex = workspaces.firstIndex(where: { $0.id == sourceWorkspaceId }),\n let targetWorkspaceIndex = workspaces.firstIndex(where: { $0.id == targetWorkspaceId }) else { return }\n\n if let appToFocus = workspaces[sourceWorkspaceIndex].appToFocus, apps.contains(appToFocus) {\n workspaces[sourceWorkspaceIndex].appToFocus = nil\n }\n\n let targetAppBundleIds = workspaces[targetWorkspaceIndex].apps.map(\\.bundleIdentifier).asSet\n let appsToAdd = apps.filter { !targetAppBundleIds.contains($0.bundleIdentifier) }\n\n workspaces[sourceWorkspaceIndex].apps.removeAll { apps.contains($0) }\n workspaces[targetWorkspaceIndex].apps.append(contentsOf: appsToAdd)\n\n notifyAboutChanges()\n NotificationCenter.default.post(name: .appsListChanged, object: nil)\n }\n\n private func notifyAboutChanges() {\n profilesRepository.updateWorkspaces(workspaces)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Workspaces/Models/Workspace.swift", "//\n// Workspace.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\n\ntypealias WorkspaceID = UUID\n\nstruct Workspace: Identifiable, Codable, Hashable {\n enum CodingKeys: String, CodingKey {\n case id\n case name\n case display\n case activateShortcut = \"shortcut\"\n case assignAppShortcut\n case apps\n case appToFocus\n case symbolIconName\n }\n\n var id: WorkspaceID\n var name: String\n var display: DisplayName\n var activateShortcut: AppHotKey?\n var assignAppShortcut: AppHotKey?\n var apps: [MacApp]\n var appToFocus: MacApp?\n var symbolIconName: String?\n}\n\nextension Workspace {\n var displays: Set {\n if NSScreen.screens.count == 1 {\n return [NSScreen.main?.localizedName ?? \"\"]\n } else if isDynamic {\n // TODO: After disconnecting a display, the detection may not work correctly.\n // The app will have the old coordinates until it is shown again, which\n // prevents from detecting the correct display.\n //\n // The workaround is to activate the app manually to update its frame.\n return NSWorkspace.shared.runningApplications\n .filter { $0.activationPolicy == .regular && apps.containsApp($0) }\n .flatMap(\\.allDisplays)\n .asSet\n } else {\n return [displayManager.resolveDisplay(display)]\n }\n }\n\n var displayForPrint: DisplayName {\n if isDynamic,\n let mainDisplay = NSScreen.main?.localizedName,\n displays.contains(mainDisplay) {\n return mainDisplay\n }\n\n return isDynamic\n ? displayManager.lastActiveDisplay(from: displays)\n : displayManager.resolveDisplay(display)\n }\n\n var isOnTheCurrentScreen: Bool {\n guard let currentScreen = NSScreen.main?.localizedName else { return false }\n return displays.contains(currentScreen)\n }\n\n var isDynamic: Bool {\n AppDependencies.shared.workspaceSettings.displayMode == .dynamic\n }\n\n private var displayManager: DisplayManager {\n AppDependencies.shared.displayManager\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Profiles/ProfilesRepository.swift", "//\n// ProfilesRepository.swift\n//\n// Created by Wojciech Kulik on 26/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nfinal class ProfilesRepository: ObservableObject {\n @Published var profiles: [Profile] = [.default]\n @Published var selectedProfile: Profile = .default {\n didSet {\n guard shouldTrackProfileChange else { return }\n guard oldValue.id != selectedProfile.id else { return }\n setProfile(id: selectedProfile.id)\n }\n }\n\n var onProfileChange: ((Profile) -> ())?\n\n private var selectedProfileId: ProfileId? {\n get {\n UserDefaults.standard.string(forKey: AppConstants.UserDefaultsKey.selectedProfileId)\n .flatMap { UUID(uuidString: $0) }\n }\n set {\n if let newValue {\n UserDefaults.standard.set(newValue.uuidString, forKey: AppConstants.UserDefaultsKey.selectedProfileId)\n } else {\n UserDefaults.standard.removeObject(forKey: AppConstants.UserDefaultsKey.selectedProfileId)\n }\n }\n }\n\n private var shouldTrackProfileChange = true\n\n init() {\n loadFromDisk()\n }\n\n private func loadFromDisk() {\n shouldTrackProfileChange = false\n defer { shouldTrackProfileChange = true }\n\n guard let config = try? ConfigSerializer.deserialize(ProfilesConfig.self, filename: \"profiles\"),\n !config.profiles.isEmpty else {\n return createDefaultProfile()\n }\n\n let migrated = migrateOldConfigIfNeeded()\n profiles = config.profiles\n\n let selectedProfileId = selectedProfileId\n selectedProfile = profiles.first { $0.id == selectedProfileId } ?? profiles.first ?? .default\n\n if migrated { saveToDisk() }\n }\n\n private func migrateOldConfigIfNeeded() -> Bool {\n struct OldProfilesConfig: Codable {\n let selectedProfileId: ProfileId?\n }\n\n if let oldConfig = try? ConfigSerializer.deserialize(OldProfilesConfig.self, filename: \"profiles\"),\n let profileId = oldConfig.selectedProfileId {\n selectedProfileId = profileId\n Logger.log(\"Migrated old profile config to new format. Profile ID: \\(profileId)\")\n\n return true\n }\n\n return false\n }\n\n private func createDefaultProfile() {\n profiles = [.init(\n id: UUID(),\n name: \"Default\",\n workspaces: []\n )]\n selectedProfile = profiles[0]\n saveToDisk()\n }\n\n private func setProfile(id: ProfileId) {\n guard let profile = profiles.first(where: { $0.id == id }) else { return }\n\n saveToDisk()\n\n onProfileChange?(profile)\n NotificationCenter.default.post(name: .profileChanged, object: nil)\n Integrations.runOnProfileChangeIfNeeded(profile: profile.name)\n }\n}\n\nextension ProfilesRepository {\n func createProfile(name: String, keepWorkspaces: Bool) {\n var workspaces = [Workspace]()\n\n if keepWorkspaces {\n workspaces = selectedProfile.workspaces.map { workspace in\n var newWorkspace = workspace\n newWorkspace.id = UUID()\n return newWorkspace\n }\n }\n\n let newProfile = Profile(id: UUID(), name: name, workspaces: workspaces)\n profiles.append(newProfile)\n profiles.sort { $0.name < $1.name }\n\n saveToDisk()\n }\n\n func renameProfile(id: ProfileId, to newName: String) {\n guard let index = profiles.firstIndex(where: { $0.id == id }) else { return }\n\n profiles[index].name = newName\n profiles.sort { $0.name < $1.name }\n\n shouldTrackProfileChange = false\n selectedProfile = profiles.first { $0.id == id } ?? .default\n shouldTrackProfileChange = true\n\n saveToDisk()\n }\n\n func deleteProfile(id: ProfileId) {\n guard profiles.count > 1 else { return }\n\n profiles.removeAll { $0.id == id }\n\n if selectedProfile.id == id {\n shouldTrackProfileChange = false\n selectedProfile = profiles.first ?? .default\n shouldTrackProfileChange = true\n\n saveToDisk()\n setProfile(id: selectedProfile.id)\n } else {\n saveToDisk()\n }\n }\n\n func updateWorkspaces(_ workspaces: [Workspace]) {\n guard let profileIndex = profiles.firstIndex(where: { $0.id == selectedProfile.id }) else { return }\n\n profiles[profileIndex].workspaces = workspaces\n selectedProfile = profiles[profileIndex]\n saveToDisk()\n }\n\n func saveToDisk() {\n let config = ProfilesConfig(profiles: profiles)\n try? ConfigSerializer.serialize(filename: \"profiles\", config)\n\n selectedProfileId = selectedProfile.id\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/FloatingApps/FloatingAppsHotKeys.swift", "//\n// FloatingAppsHotKeys.swift\n//\n// Created by Wojciech Kulik on 16/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nfinal class FloatingAppsHotKeys {\n private let workspaceManager: WorkspaceManager\n private let floatingAppsSettings: FloatingAppsSettings\n\n init(\n workspaceManager: WorkspaceManager,\n settingsRepository: SettingsRepository\n ) {\n self.workspaceManager = workspaceManager\n self.floatingAppsSettings = settingsRepository.floatingAppsSettings\n }\n\n func getHotKeys() -> [(AppHotKey, () -> ())] {\n let hotKeys = [\n getFloatTheFocusedAppHotKey(),\n getUnfloatTheFocusedAppHotKey(),\n getToggleTheFocusedAppFloatingHotKey()\n ]\n\n return hotKeys.compactMap(\\.self)\n }\n\n private func getFloatTheFocusedAppHotKey() -> (AppHotKey, () -> ())? {\n guard let shortcut = floatingAppsSettings.floatTheFocusedApp else { return nil }\n\n return (shortcut, { [weak self] in self?.floatApp() })\n }\n\n private func getUnfloatTheFocusedAppHotKey() -> (AppHotKey, () -> ())? {\n guard let shortcut = floatingAppsSettings.unfloatTheFocusedApp else { return nil }\n\n return (shortcut, { [weak self] in self?.unfloatApp() })\n }\n\n private func getToggleTheFocusedAppFloatingHotKey() -> (AppHotKey, () -> ())? {\n guard let shortcut = floatingAppsSettings.toggleTheFocusedAppFloating else { return nil }\n\n let action = { [weak self] in\n guard let self, let activeApp = NSWorkspace.shared.frontmostApplication else { return }\n\n if floatingAppsSettings.floatingApps.containsApp(activeApp) {\n unfloatApp()\n } else {\n floatApp()\n }\n }\n return (shortcut, action)\n }\n}\n\nextension FloatingAppsHotKeys {\n private func floatApp() {\n guard let activeApp = NSWorkspace.shared.frontmostApplication,\n let appName = activeApp.localizedName else { return }\n\n floatingAppsSettings.addFloatingAppIfNeeded(app: activeApp.toMacApp)\n Toast.showWith(\n icon: \"macwindow.on.rectangle\",\n message: \"\\(appName) - Added To Floating Apps\",\n textColor: .positive\n )\n }\n\n private func unfloatApp() {\n guard let activeApp = NSWorkspace.shared.frontmostApplication,\n let appName = activeApp.localizedName else { return }\n\n if floatingAppsSettings.floatingApps.containsApp(activeApp) {\n Toast.showWith(\n icon: \"macwindow\",\n message: \"\\(appName) - Removed From Floating Apps\",\n textColor: .negative\n )\n }\n\n floatingAppsSettings.deleteFloatingApp(app: activeApp.toMacApp)\n\n guard let screen = activeApp.display else { return }\n\n if workspaceManager.activeWorkspace[screen]?.apps.containsApp(activeApp) != true {\n activeApp.hide()\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Accessibility/NSRunningApplication+Properties.swift", "//\n// NSRunningApplication+Properties.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension NSRunningApplication {\n var frame: CGRect? { mainWindow?.frame }\n var isMinimized: Bool { mainWindow?.isMinimized == true }\n\n var display: DisplayName? {\n // HACK: Workaround for Orion Browser which puts\n // the main window on the main screen with size (1,1)\n if isOrion {\n allWindows\n .first { $0.frame.width > 10 && $0.frame.height > 10 }?\n .frame\n .getDisplay()\n } else {\n frame?.getDisplay()\n }\n }\n\n var allDisplays: Set {\n allWindows\n .compactMap { $0.frame.getDisplay() }\n .asSet\n }\n\n var mainWindow: AXUIElement? {\n // HACK: Python app with running pygame module is causing\n // huge lags when other apps attempt to access its window\n // through the accessibility API.\n // A workaround is to simply skip this app.\n guard !isPython else { return nil }\n\n let appElement = AXUIElementCreateApplication(processIdentifier)\n return appElement.getAttribute(.mainWindow)\n }\n\n var focusedWindow: AXUIElement? {\n guard !isPython else { return nil }\n\n let appElement = AXUIElementCreateApplication(processIdentifier)\n return appElement.getAttribute(.focusedWindow)\n }\n\n var allWindows: [(window: AXUIElement, frame: CGRect)] {\n guard !isPython else { return [] }\n\n let appElement = AXUIElementCreateApplication(processIdentifier)\n let windows: [AXUIElement]? = appElement.getAttribute(.windows)\n\n return windows?\n .filter { $0.role == \"AXWindow\" }\n .compactMap { window in window.frame.flatMap { (window, $0) } }\n ?? []\n }\n\n func isOnAnyDisplay(_ displays: Set) -> Bool {\n !allDisplays.isDisjoint(with: displays)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Config/ConfigSerializer.swift", "//\n// ConfigSerializer.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\nimport TOMLKit\nimport Yams\n\nenum ConfigSerializer {\n static let configDirectory = FileManager.default\n .homeDirectoryForCurrentUser\n .appendingPathComponent(\".config/flashspace\")\n\n private(set) static var format: ConfigFormat = detectFormat()\n\n static func serialize(filename: String, _ value: some Encodable) throws {\n let url = getUrl(for: filename)\n let data = try encoder.encode(value)\n try? url.createIntermediateDirectories()\n try data.write(to: url)\n }\n\n static func deserialize(_ type: T.Type, filename: String) throws -> T? where T: Decodable {\n let url = getUrl(for: filename)\n\n guard FileManager.default.fileExists(atPath: url.path) else { return nil }\n\n do {\n let data = try Data(contentsOf: url)\n\n return try decoder.decode(type, from: data)\n } catch {\n Logger.log(\"Failed to deserialize \\(filename): \\(error)\")\n throw error\n }\n }\n\n static func convert(to: ConfigFormat) throws {\n guard format != to else { return }\n\n let settingsUrl = getUrl(for: \"settings\", ext: format.rawValue)\n let profilesUrl = getUrl(for: \"profiles\", ext: format.rawValue)\n let timestamp = Int(Date().timeIntervalSince1970)\n\n try? FileManager.default.moveItem(\n at: settingsUrl,\n to: configDirectory.appendingPathComponent(\"settings-backup-\\(timestamp).\\(format.rawValue)\")\n )\n try? FileManager.default.moveItem(\n at: profilesUrl,\n to: configDirectory.appendingPathComponent(\"profiles-backup-\\(timestamp).\\(format.rawValue)\")\n )\n\n format = to\n AppDependencies.shared.settingsRepository.saveToDisk()\n AppDependencies.shared.profilesRepository.saveToDisk()\n\n Logger.log(\"Converted config format to \\(to.displayName)\")\n }\n}\n\nprivate extension ConfigSerializer {\n static var encoder: ConfigEncoder {\n switch format {\n case .json: return jsonEncoder\n case .toml: return tomlEncoder\n case .yaml: return yamlEncoder\n }\n }\n\n static var decoder: ConfigDecoder {\n switch format {\n case .json: return jsonDecoder\n case .toml: return tomlDecoder\n case .yaml: return yamlDecoder\n }\n }\n\n static let jsonDecoder = JSONDecoder()\n static let jsonEncoder = {\n let encoder = JSONEncoder()\n encoder.outputFormatting = [\n .prettyPrinted,\n .withoutEscapingSlashes,\n .sortedKeys\n ]\n return encoder\n }()\n\n static let tomlDecoder = TOMLDecoder()\n static let tomlEncoder = TOMLEncoder()\n static let yamlEncoder = YAMLEncoder()\n static let yamlDecoder = YAMLDecoder()\n\n static func getUrl(for filename: String, ext: String? = nil) -> URL {\n configDirectory\n .appendingPathComponent(filename)\n .appendingPathExtension(ext ?? ConfigSerializer.format.extensionName)\n }\n\n static func detectFormat() -> ConfigFormat {\n for format in ConfigFormat.allCases {\n let url = getUrl(for: \"profiles\", ext: format.rawValue)\n if FileManager.default.fileExists(atPath: url.path) {\n Logger.log(\"Detected config format \\(format.displayName) at \\(url.path)\")\n return format\n }\n }\n\n return .json\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/HotKeys/Models/AppHotKey.swift", "//\n// AppHotKey.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\ntypealias RawKeyCode = UInt16\ntypealias RawKeyModifiers = UInt\n\nstruct AppHotKey: Codable, Hashable {\n let value: String\n\n init(value: String) { self.value = value }\n\n init(keyCode: RawKeyCode, modifiers: RawKeyModifiers) {\n let keyEquivalent = KeyCodesMap.toString[keyCode] ?? \"\"\n let modifiers = KeyModifiersMap.toString(modifiers)\n let result = [modifiers, keyEquivalent].filter { !$0.isEmpty }.joined(separator: \"+\")\n\n self.init(value: result)\n }\n\n init(from decoder: Decoder) throws {\n enum CodingKeys: String, CodingKey { case keyCode, modifiers }\n\n if let container = try? decoder.container(keyedBy: CodingKeys.self) {\n // v1 -> v2 Migration\n let keyCode = try container.decodeIfPresent(RawKeyCode.self, forKey: .keyCode)\n let modifiers = try container.decodeIfPresent(RawKeyModifiers.self, forKey: .modifiers)\n\n if let keyCode, let modifiers {\n Migrations.hotKeysMigrated = true\n self.init(keyCode: keyCode, modifiers: modifiers)\n } else {\n throw DecodingError.dataCorruptedError(\n forKey: .keyCode,\n in: container,\n debugDescription: \"Invalid key code or modifiers\"\n )\n }\n } else {\n // v2\n let container = try decoder.singleValueContainer()\n try self.init(value: container.decode(String.self))\n }\n }\n\n func encode(to encoder: any Encoder) throws {\n var container = encoder.singleValueContainer()\n try container.encode(value)\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/NSView.swift", "//\n// NSView.swift\n//\n// Created by Wojciech Kulik on 11/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension NSView {\n func addVisualEffect(material: NSVisualEffectView.Material, border: Bool = false) -> NSView {\n let visualEffectView = NSVisualEffectView()\n visualEffectView.material = material\n visualEffectView.blendingMode = .behindWindow\n visualEffectView.state = .active\n\n if border {\n visualEffectView.wantsLayer = true\n visualEffectView.layer?.cornerRadius = 24\n visualEffectView.layer?.borderWidth = 0.8\n visualEffectView.layer?.borderColor = NSColor.darkGray.cgColor\n visualEffectView.layer?.masksToBounds = true\n }\n\n visualEffectView.addSubview(self)\n translatesAutoresizingMaskIntoConstraints = false\n\n NSLayoutConstraint.activate([\n leadingAnchor.constraint(equalTo: visualEffectView.leadingAnchor),\n trailingAnchor.constraint(equalTo: visualEffectView.trailingAnchor),\n topAnchor.constraint(equalTo: visualEffectView.topAnchor),\n bottomAnchor.constraint(equalTo: visualEffectView.bottomAnchor)\n ])\n\n return visualEffectView\n }\n}\n"], ["/FlashSpace/FlashSpace/Accessibility/AXUIElement+Properties.swift", "//\n// AXUIElement+Properties.swift\n//\n// Created by Wojciech Kulik on 24/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension AXUIElement {\n var id: String? { getAttribute(.identifier) }\n var title: String? { getAttribute(.title) }\n var isMain: Bool { getAttribute(.main) == true }\n var isMinimized: Bool { getAttribute(.minimized) == true }\n var role: String? { getAttribute(.role) }\n var subrole: String? { getAttribute(.subrole) }\n var enhancedUserInterface: Bool {\n get { getAttribute(.enchancedUserInterface) == true }\n set { setAttribute(.enchancedUserInterface, value: newValue) }\n }\n\n var processId: pid_t? {\n var pid: pid_t = 0\n AXUIElementGetPid(self, &pid)\n return pid\n }\n\n /// Frame is in window coordinates where (0,0) is top-left corner\n /// and it is relative to the main screen.\n var frame: CGRect? {\n var positionValue: CFTypeRef?\n var sizeValue: CFTypeRef?\n\n guard AXUIElementCopyAttributeValue(\n self,\n NSAccessibility.Attribute.position as CFString,\n &positionValue\n ) == .success else { return nil }\n\n guard AXUIElementCopyAttributeValue(\n self,\n NSAccessibility.Attribute.size as CFString,\n &sizeValue\n ) == .success else { return nil }\n\n var windowBounds: CGRect = .zero\n\n // swiftlint:disable force_cast\n if let position = positionValue, AXValueGetType(position as! AXValue) == .cgPoint {\n AXValueGetValue(position as! AXValue, .cgPoint, &windowBounds.origin)\n }\n\n if let size = sizeValue, AXValueGetType(size as! AXValue) == .cgSize {\n AXValueGetValue(size as! AXValue, .cgSize, &windowBounds.size)\n }\n // swiftlint:enable force_cast\n\n return windowBounds.isEmpty ? nil : windowBounds\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/CGRect.swift", "//\n// CGRect.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension CGRect {\n func getDisplay() -> String? {\n NSScreen.screens\n .first { $0.normalizedFrame.contains(.init(x: self.midX, y: self.midY)) }?\n .localizedName\n }\n\n func verticalIntersect(with rect: CGRect) -> Bool {\n var rect = rect\n rect.origin.x = origin.x\n\n return intersects(rect)\n }\n\n func horizontalIntersect(with rect: CGRect) -> Bool {\n var rect = rect\n rect.origin.y = origin.y\n\n return intersects(rect)\n }\n\n func distance(to rect: CGRect) -> CGFloat {\n let x = midX - rect.midX\n let y = midY - rect.midY\n\n return sqrt(x * x + y * y)\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/NSScreen.swift", "//\n// NSScreen.swift\n//\n// Created by Wojciech Kulik on 18/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension NSScreen {\n /// Returns the screen's frame where (x,y) is top-left corner relative\n /// to the main screen's top-left corner.\n var normalizedFrame: CGRect {\n let mainScreen = NSScreen.screens[0]\n return NSRect(\n x: frame.origin.x,\n y: mainScreen.frame.height - frame.origin.y - frame.height,\n width: frame.width,\n height: frame.height\n )\n }\n\n static func isConnected(_ display: DisplayName) -> Bool {\n NSScreen.screens.contains { $0.localizedName == display }\n }\n\n static func screen(_ display: DisplayName?) -> NSScreen? {\n NSScreen.screens.first { $0.localizedName == display }\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/SocketClient.swift", "//\n// SocketClient.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\nimport Network\n\nfinal class SocketClient {\n static let shared = SocketClient()\n\n private let socketPath = \"/tmp/flashspace.socket\"\n private var buffer = Data()\n private let jsonEncoder = JSONEncoder()\n\n private init() {}\n\n func sendCommand(_ command: CommandRequest) {\n let connection = NWConnection(to: .unix(path: socketPath), using: .tcp)\n connection.start(queue: .main)\n\n let messageData = command.encodeSocketData()\n connection.send(content: messageData, completion: .contentProcessed { error in\n if let error {\n connection.cancel()\n FlashSpaceCLI.exit(withError: CommandError.connectionError(error))\n }\n\n self.receiveData(connection: connection)\n })\n }\n\n private func receiveData(connection: NWConnection) {\n connection.receive(minimumIncompleteLength: 1, maximumLength: 10000) { data, _, isComplete, error in\n if let error {\n connection.cancel()\n FlashSpaceCLI.exit(withError: CommandError.connectionError(error))\n }\n\n if let data { self.buffer.append(data) }\n\n // Check if the message is complete or EOF is reached\n guard isComplete || data?.last == 0 else {\n return self.receiveData(connection: connection)\n }\n\n if self.buffer.isEmpty {\n connection.cancel()\n FlashSpaceCLI.exit(withError: CommandError.emptyResponse)\n }\n\n if let response = try? self.buffer.decodeSocketData(CommandResponse.self) {\n self.handleResponse(response, connection: connection)\n } else {\n FlashSpaceCLI.exit(withError: CommandError.operationFailed(\"Could not decode the response\"))\n }\n }\n }\n\n private func handleResponse(_ response: CommandResponse, connection: NWConnection) {\n if response.success {\n response.message.flatMap { print($0) }\n connection.cancel()\n FlashSpaceCLI.exit()\n } else {\n connection.cancel()\n FlashSpaceCLI.exit(withError: CommandError.operationFailed(response.error ?? \"Operation Failed\"))\n }\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Workspace/UpdateWorkspaceCommand.swift", "//\n// UpdateWorkspaceCommand.swift\n//\n// Created by Wojciech Kulik on 02/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport ArgumentParser\nimport Foundation\n\nstruct UpdateWorkspaceRequest: Codable {\n enum Display: Codable {\n case active\n case name(String)\n }\n\n let name: String?\n let display: Display?\n}\n\nstruct UpdateWorkspaceCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"update-workspace\",\n abstract: \"Update a workspace\"\n )\n\n @Option(help: \"The name of the workspace to update.\")\n var workspace: String?\n\n @Flag(help: \"Update active workspace.\")\n var activeWorkspace = false\n\n @Option(help: \"The name of the display to be assigned.\")\n var display: String?\n\n @Flag(help: \"Assign active display.\")\n var activeDisplay = false\n\n func run() throws {\n if let display {\n sendCommand(.updateWorkspace(.init(name: workspace, display: .name(display))))\n } else if activeDisplay {\n sendCommand(.updateWorkspace(.init(name: workspace, display: .active)))\n } else {\n throw CommandError.operationFailed(\"Invalid command\")\n }\n\n runWithTimeout()\n }\n\n func validate() throws {\n if workspace != nil, activeWorkspace {\n throw CommandError.operationFailed(\"You cannot provide both a workspace name and use the --active-workspace flag\")\n }\n\n if display != nil, activeDisplay {\n throw CommandError.operationFailed(\"You cannot provide both a display name and use the --active-display flag\")\n }\n\n if workspace == nil, !activeWorkspace {\n throw CommandError.operationFailed(\"You must provide either a workspace name or use the --active-workspace flag\")\n }\n\n if display == nil, !activeDisplay {\n throw CommandError.operationFailed(\"You must provide either a display name or use the --active-display flag\")\n }\n\n if let display, !NSScreen.screens.contains(where: { $0.localizedName == display }) {\n throw CommandError.operationFailed(\"Display \\\"\\(display)\\\" not found\")\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/HotKeys/Models/KeyCodesMap.swift", "//\n// KeyCodesMap.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Carbon\n\nenum KeyCodesMap {\n private(set) static var toKeyCode = create()\n\n static let toString = toKeyCode.reduce(into: [RawKeyCode: String]()) { result, pair in\n result[pair.value] = pair.key\n\n for (alias, keyCode) in getAliases() {\n result[keyCode] = alias\n }\n }\n\n static subscript(key: String) -> RawKeyCode? { toKeyCode[key] }\n\n static func refresh() {\n toKeyCode = create()\n }\n\n private static func create() -> [String: RawKeyCode] {\n var stringToKeyCodes: [String: RawKeyCode] = [:]\n var currentKeyboard = TISCopyCurrentKeyboardInputSource().takeRetainedValue()\n var rawLayoutData = TISGetInputSourceProperty(currentKeyboard, kTISPropertyUnicodeKeyLayoutData)\n if rawLayoutData == nil {\n currentKeyboard = TISCopyCurrentASCIICapableKeyboardLayoutInputSource().takeUnretainedValue()\n rawLayoutData = TISGetInputSourceProperty(currentKeyboard, kTISPropertyUnicodeKeyLayoutData)\n }\n\n let layoutData = unsafeBitCast(rawLayoutData, to: CFData.self)\n let layout: UnsafePointer = unsafeBitCast(\n CFDataGetBytePtr(layoutData),\n to: UnsafePointer.self\n )\n\n var keysDown: UInt32 = 0\n var chars: [UniChar] = [0, 0, 0, 0]\n var realLength = 0\n\n for keyCode in 0..<128 {\n switch keyCode {\n case kVK_ANSI_Keypad0, kVK_ANSI_Keypad1, kVK_ANSI_Keypad2, kVK_ANSI_Keypad3,\n kVK_ANSI_Keypad4, kVK_ANSI_Keypad5, kVK_ANSI_Keypad6, kVK_ANSI_Keypad7,\n kVK_ANSI_Keypad8, kVK_ANSI_Keypad9,\n kVK_ANSI_KeypadMinus, kVK_ANSI_KeypadMultiply, kVK_ANSI_KeypadDivide,\n kVK_ANSI_KeypadDecimal, kVK_ANSI_KeypadClear, kVK_ANSI_KeypadEnter,\n kVK_ANSI_KeypadEquals, kVK_ANSI_KeypadPlus:\n continue\n default: break\n }\n\n UCKeyTranslate(\n layout,\n UInt16(keyCode),\n UInt16(kUCKeyActionDisplay),\n 0,\n UInt32(LMGetKbdType()),\n UInt32(kUCKeyTranslateNoDeadKeysBit),\n &keysDown,\n chars.count,\n &realLength,\n &chars\n )\n\n let string = CFStringCreateWithCharacters(kCFAllocatorDefault, chars, realLength) as String\n if !stringToKeyCodes.keys.contains(string) {\n stringToKeyCodes[string] = UInt16(keyCode)\n }\n }\n\n let aliases = getAliases()\n for (alias, keyCode) in aliases {\n stringToKeyCodes[alias] = keyCode\n }\n\n return stringToKeyCodes\n }\n\n private static func getAliases() -> [String: RawKeyCode] {\n [\n \"space\": UInt16(kVK_Space),\n \"enter\": UInt16(kVK_Return),\n \"up\": UInt16(kVK_UpArrow),\n \"right\": UInt16(kVK_RightArrow),\n \"down\": UInt16(kVK_DownArrow),\n \"left\": UInt16(kVK_LeftArrow),\n \"delete\": UInt16(kVK_Delete),\n \"forward-delete\": UInt16(kVK_ForwardDelete),\n \"escape\": UInt16(kVK_Escape),\n \"tab\": UInt16(kVK_Tab),\n \"capslock\": UInt16(kVK_CapsLock),\n \"f1\": UInt16(kVK_F1),\n \"f2\": UInt16(kVK_F2),\n \"f3\": UInt16(kVK_F3),\n \"f4\": UInt16(kVK_F4),\n \"f5\": UInt16(kVK_F5),\n \"f6\": UInt16(kVK_F6),\n \"f7\": UInt16(kVK_F7),\n \"f8\": UInt16(kVK_F8),\n \"f9\": UInt16(kVK_F9),\n \"f10\": UInt16(kVK_F10),\n \"f11\": UInt16(kVK_F11),\n \"f12\": UInt16(kVK_F12),\n \"num0\": UInt16(kVK_ANSI_Keypad0),\n \"num1\": UInt16(kVK_ANSI_Keypad1),\n \"num2\": UInt16(kVK_ANSI_Keypad2),\n \"num3\": UInt16(kVK_ANSI_Keypad3),\n \"num4\": UInt16(kVK_ANSI_Keypad4),\n \"num5\": UInt16(kVK_ANSI_Keypad5),\n \"num6\": UInt16(kVK_ANSI_Keypad6),\n \"num7\": UInt16(kVK_ANSI_Keypad7),\n \"num8\": UInt16(kVK_ANSI_Keypad8),\n \"num9\": UInt16(kVK_ANSI_Keypad9),\n \"num-plus\": UInt16(kVK_ANSI_KeypadPlus),\n \"num-minus\": UInt16(kVK_ANSI_KeypadMinus),\n \"num-multiply\": UInt16(kVK_ANSI_KeypadMultiply),\n \"num-divide\": UInt16(kVK_ANSI_KeypadDivide),\n \"num-clear\": UInt16(kVK_ANSI_KeypadClear),\n \"num-enter\": UInt16(kVK_ANSI_KeypadEnter),\n \"num-equals\": UInt16(kVK_ANSI_KeypadEquals),\n \"num-decimal\": UInt16(kVK_ANSI_KeypadDecimal)\n ]\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/MenuBar/MenuBarTitle.swift", "//\n// MenuBarTitle.swift\n//\n// Created by Wojciech Kulik on 31/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nenum MenuBarTitle {\n static let settings = AppDependencies.shared.menuBarSettings\n static let workspaceManager = AppDependencies.shared.workspaceManager\n static let profilesRepository = AppDependencies.shared.profilesRepository\n\n static func get() -> String? {\n let template = settings.menuBarTitleTemplate.trimmingCharacters(in: .whitespaces)\n\n guard settings.showMenuBarTitle, !template.isEmpty else { return nil }\n guard let activeWorkspace = workspaceManager.activeWorkspaceDetails else { return nil }\n\n return template\n .replacingOccurrences(of: \"$WORKSPACE_NUMBER\", with: activeWorkspace.number ?? \"\")\n .replacingOccurrences(of: \"$WORKSPACE\", with: activeWorkspace.name)\n .replacingOccurrences(of: \"$DISPLAY\", with: getDisplayName())\n .replacingOccurrences(of: \"$PROFILE\", with: profilesRepository.selectedProfile.name)\n }\n\n private static func getDisplayName() -> String {\n let aliases = settings.menuBarDisplayAliases\n .split(separator: \";\")\n .map { $0.split(separator: \"=\") }\n .reduce(into: [String: String]()) { result, pair in\n guard pair.count == 2 else { return }\n\n result[String(pair[0]).lowercased()] = String(pair[1])\n }\n\n let display = workspaceManager.activeWorkspaceDetails?.display ?? \"\"\n\n return aliases[display.lowercased()] ?? display\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Workspace/WorkspaceCommand.swift", "//\n// WorkspaceCommand.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct WorkspaceCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"workspace\",\n abstract: \"Activate a workspace\"\n )\n\n @Option(help: .init(\"The name of the workspace\"))\n var name: String?\n\n @Option(help: .init(\n \"The number of the workspace to activate. Starting from 1.\",\n valueName: \"number\"\n ))\n var number: Int?\n\n @Flag(help: \"Activate the next workspace\")\n var next = false\n\n @Flag(help: \"Activate the previous workspace\")\n var prev = false\n\n @Flag(help: \"Activate the most recently used workspace\")\n var recent = false\n\n @Flag(help: \"Skip empty workspaces (works only with --next or --prev)\")\n var skipEmpty = false\n\n @Flag(help: \"Loop back to the first workspace when reaching the last one and vice versa (works only with --next or --prev)\")\n var loop = false\n\n @Flag(help: \"Hide all apps that are not assigned to the selected workspace\")\n var clean = false\n\n func run() throws {\n if let name {\n sendCommand(.activateWorkspace(name: name, number: nil, clean: clean))\n } else if let number {\n sendCommand(.activateWorkspace(name: nil, number: number, clean: clean))\n } else if next {\n sendCommand(.nextWorkspace(skipEmpty: skipEmpty, clean: clean, loop: loop))\n } else if prev {\n sendCommand(.previousWorkspace(skipEmpty: skipEmpty, clean: clean, loop: loop))\n } else if recent {\n sendCommand(.recentWorkspace(clean: clean))\n } else {\n fallbackToHelp()\n }\n\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/List/ListRunningAppsCommand.swift", "//\n// ListRunningAppsCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport ArgumentParser\nimport Foundation\n\nstruct ListRunningAppsCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"list-running-apps\",\n abstract: \"List running apps\"\n )\n\n @Flag(help: \"Include bundle id\")\n var withBundleId = false\n\n func run() throws {\n let apps = NSWorkspace.shared.runningApplications\n .filter { $0.activationPolicy == .regular }\n\n let result = Set(apps)\n .filter { $0.localizedName != nil }\n .map { (bundleId: $0.bundleIdentifier ?? \"-\", name: $0.localizedName ?? \"-\") }\n .sorted { $0.name.lowercased() < $1.name.lowercased() }\n .map { app in\n if withBundleId {\n return [app.name, app.bundleId].joined(separator: \",\")\n } else {\n return app.name\n }\n }\n .joined(separator: \"\\n\")\n print(result)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Commands/ProfileCommands.swift", "//\n// ProfileCommands.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\n\nfinal class ProfileCommands: CommandExecutor {\n var profilesRepository: ProfilesRepository { AppDependencies.shared.profilesRepository }\n\n func execute(command: CommandRequest) -> CommandResponse? {\n switch command {\n case .activateProfile(let name):\n let profile = profilesRepository.profiles.first { $0.name == name }\n\n if let profile {\n profilesRepository.selectedProfile = profile\n return CommandResponse(success: true)\n } else {\n return CommandResponse(success: false, error: \"Profile not found\")\n }\n\n case .createProfile(let name, let copy, let activate):\n profilesRepository.createProfile(name: name, keepWorkspaces: copy)\n if activate {\n profilesRepository.profiles\n .first { $0.name == name }\n .flatMap { profilesRepository.selectedProfile = $0 }\n }\n return CommandResponse(success: true)\n\n case .deleteProfile(let name):\n let profile = profilesRepository.profiles.first { $0.name == name }\n if let profile {\n profilesRepository.deleteProfile(id: profile.id)\n return CommandResponse(success: true)\n } else {\n return CommandResponse(success: false, error: \"Profile not found\")\n }\n\n default:\n return nil\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Workspaces/Models/MacApp.swift", "//\n// MacApp.swift\n//\n// Created by Wojciech Kulik on 06/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\ntypealias BundleId = String\n\nstruct MacApp: Codable, Hashable, Equatable {\n var name: String\n var bundleIdentifier: BundleId\n var iconPath: String?\n\n init(\n name: String,\n bundleIdentifier: BundleId,\n iconPath: String?\n ) {\n self.name = name\n self.bundleIdentifier = bundleIdentifier\n self.iconPath = iconPath\n }\n\n init(app: NSRunningApplication) {\n self.name = app.localizedName ?? \"\"\n self.bundleIdentifier = app.bundleIdentifier ?? \"\"\n self.iconPath = app.iconPath\n }\n\n init(from decoder: any Decoder) throws {\n if let app = try? decoder.singleValueContainer().decode(String.self) {\n // V1 - migration\n let runningApp = NSWorkspace.shared.runningApplications\n .first { $0.localizedName == app }\n\n self.name = app\n\n if let runningApp {\n self.bundleIdentifier = runningApp.bundleIdentifier ?? \"\"\n self.iconPath = runningApp.iconPath\n } else if let bundle = Bundle(path: \"/Applications/\\(app).app\") {\n self.bundleIdentifier = bundle.bundleIdentifier ?? \"\"\n self.iconPath = bundle.iconPath\n } else if let bundle = Bundle(path: \"/System/Applications/\\(app).app\") {\n self.bundleIdentifier = bundle.bundleIdentifier ?? \"\"\n self.iconPath = bundle.iconPath\n } else {\n self.bundleIdentifier = \"\"\n self.iconPath = nil\n }\n\n Migrations.appsMigrated = true\n } else {\n // V2\n let container = try decoder.container(keyedBy: CodingKeys.self)\n self.name = try container.decode(String.self, forKey: .name)\n self.bundleIdentifier = try container.decode(String.self, forKey: .bundleIdentifier)\n self.iconPath = try container.decodeIfPresent(String.self, forKey: .iconPath)\n }\n }\n\n static func == (lhs: MacApp, rhs: MacApp) -> Bool {\n if lhs.bundleIdentifier.isEmpty || rhs.bundleIdentifier.isEmpty {\n return lhs.name == rhs.name\n } else {\n return lhs.bundleIdentifier == rhs.bundleIdentifier\n }\n }\n}\n\nextension MacApp {\n var isFinder: Bool {\n bundleIdentifier == \"com.apple.finder\"\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Integrations/Integrations.swift", "//\n// Integrations.swift\n//\n// Created by Wojciech Kulik on 24/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nenum Integrations {\n private static let settings = AppDependencies.shared.integrationsSettings\n private static let profilesRepository = AppDependencies.shared.profilesRepository\n\n static func runOnActivateIfNeeded(workspace: ActiveWorkspace) {\n let script = settings.runScriptOnWorkspaceChange.trimmingCharacters(in: .whitespaces)\n .replacingOccurrences(of: \"$WORKSPACE_NUMBER\", with: workspace.number ?? \"\")\n .replacingOccurrences(of: \"$WORKSPACE\", with: workspace.name)\n .replacingOccurrences(of: \"$DISPLAY\", with: workspace.display)\n .replacingOccurrences(of: \"$PROFILE\", with: profilesRepository.selectedProfile.name)\n runScript(script)\n }\n\n static func runOnAppLaunchIfNeeded() {\n let script = settings.runScriptOnLaunch.trimmingCharacters(in: .whitespaces)\n .replacingOccurrences(of: \"$PROFILE\", with: profilesRepository.selectedProfile.name)\n runScript(script)\n }\n\n static func runOnProfileChangeIfNeeded(profile: String) {\n let script = settings.runScriptOnProfileChange.trimmingCharacters(in: .whitespaces)\n .replacingOccurrences(of: \"$PROFILE\", with: profile)\n runScript(script)\n }\n\n private static func runScript(_ script: String) {\n guard settings.enableIntegrations, !script.isEmpty else { return }\n\n let shell = ProcessInfo.processInfo.environment[\"SHELL\"] ?? \"/bin/sh\"\n let task = Process()\n task.launchPath = shell\n task.arguments = [\"-c\", script]\n task.launch()\n }\n}\n"], ["/FlashSpace/FlashSpace/Accessibility/NSRunningApplication+Actions.swift", "//\n// NSRunningApplication+Actions.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension NSRunningApplication {\n func raise() {\n guard let mainWindow else {\n unhide()\n return\n }\n\n AXUIElementPerformAction(mainWindow, NSAccessibility.Action.raise as CFString)\n }\n\n /// Position is in window coordinates where (0,0) is top-left corner\n /// and it is relative to the main screen.\n func setPosition(_ position: CGPoint) {\n mainWindow?.setPosition(position)\n }\n\n func centerApp(display: DisplayName) {\n guard let appFrame = frame else {\n return Logger.log(\"Could not get frame for app: \\(localizedName ?? \"\")\")\n }\n\n guard let nsScreen = NSScreen.screen(display) else { return }\n guard appFrame.getDisplay() != nsScreen.localizedName else { return }\n\n let normalizedScreenFrame = nsScreen.normalizedFrame\n\n let origin = CGPoint(\n x: normalizedScreenFrame.midX - appFrame.width / 2.0,\n y: normalizedScreenFrame.midY - appFrame.height / 2.0\n )\n\n setPosition(origin)\n }\n\n func runWithoutAnimations(action: () -> ()) {\n let appElement = AXUIElementCreateApplication(processIdentifier)\n let wasEnabled = appElement.enhancedUserInterface\n\n if wasEnabled { appElement.setAttribute(.enchancedUserInterface, value: false) }\n\n action()\n\n if wasEnabled { appElement.setAttribute(.enchancedUserInterface, value: true) }\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/Color.swift", "//\n// Color.swift\n//\n// Created by Wojciech Kulik on 04/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\npublic extension Color {\n init?(hex: String?) {\n guard let hex else { return nil }\n var hexValue = hex.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines).uppercased()\n\n if hexValue.hasPrefix(\"#\") {\n hexValue.remove(at: hexValue.startIndex)\n }\n\n var rgbValue: UInt64 = 0\n Scanner(string: hexValue).scanHexInt64(&rgbValue)\n\n let red = CGFloat((rgbValue & 0xFF0000) >> 16) / 255.0\n let green = CGFloat((rgbValue & 0x00FF00) >> 8) / 255.0\n let blue = CGFloat(rgbValue & 0x0000FF) / 255.0\n\n self.init(red: red, green: green, blue: blue, opacity: 1)\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/App/FocusCommand.swift", "//\n// FocusCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct FocusCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"focus\",\n abstract: \"Focus window\"\n )\n\n @Option(\n name: .customLong(\"direction\"),\n help: .init(\"Focus a window in a specific direction\", valueName: \"up|down|left|right\")\n )\n var focusDirection: FocusDirection?\n\n @Flag(help: \"Focus the next workspace app\")\n var nextApp = false\n\n @Flag(help: \"Focus the previous workspace app\")\n var prevApp = false\n\n @Flag(help: \"Focus the next workspace window\")\n var nextWindow = false\n\n @Flag(help: \"Focus the previous workspace window\")\n var prevWindow = false\n\n func run() throws {\n if let focusDirection {\n sendCommand(.focusWindow(direction: focusDirection))\n } else if nextApp {\n sendCommand(.focusNextApp)\n } else if prevApp {\n sendCommand(.focusPreviousApp)\n } else if nextWindow {\n sendCommand(.focusNextWindow)\n } else if prevWindow {\n sendCommand(.focusPreviousWindow)\n } else {\n fallbackToHelp()\n }\n\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/App/AppDelegate.swift", "//\n// AppDelegate.swift\n//\n// Created by Wojciech Kulik on 13/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Combine\nimport SwiftUI\n\nfinal class AppDelegate: NSObject, NSApplicationDelegate {\n @Environment(\\.openWindow) private var openWindow\n @Environment(\\.dismissWindow) private var dismissWindow\n\n private var cancellables = Set()\n\n func applicationDidFinishLaunching(_ notification: Notification) {\n AppDependencies.shared.hotKeysManager.enableAll()\n\n NotificationCenter.default\n .publisher(for: .openMainWindow)\n .sink { [weak self] _ in\n self?.openWindow(id: \"main\")\n NSApp.activate(ignoringOtherApps: true)\n }\n .store(in: &cancellables)\n\n #if DEBUG\n dismissWindow(id: \"main\")\n #endif\n }\n\n func applicationWillTerminate(_ notification: Notification) {\n AppDependencies.shared.pictureInPictureManager.restoreAllWindows()\n }\n}\n"], ["/FlashSpace/FlashSpace/Accessibility/AXUIElement+CoreGraphics.swift", "//\n// AXUIElement+CoreGraphics.swift\n//\n// Created by Wojciech Kulik on 21/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension AXUIElement {\n var cgWindowId: CGWindowID? {\n let title = title\n let pid = processId\n\n if let windowList = CGWindowListCopyWindowInfo(.optionOnScreenOnly, kCGNullWindowID) as? [[String: Any]] {\n for window in windowList {\n let windowOwnerPID = window[kCGWindowOwnerPID as String] as? pid_t\n let windowName = window[kCGWindowName as String] as? String\n let windowNumber = window[kCGWindowNumber as String] as? CGWindowID\n\n if title == windowName, windowOwnerPID == pid {\n return windowNumber\n }\n }\n }\n\n return nil\n }\n\n func isBelowAnyOf(_ windows: [AXUIElement]) -> Bool {\n guard let cgWindowId, let frame else { return false }\n\n let otherWindows = windows.map { (id: $0.cgWindowId, window: $0) }\n let windowsAbove = CGWindowListCopyWindowInfo(.optionOnScreenAboveWindow, cgWindowId) as? [[String: Any]] ?? [[:]]\n let windowsAboveIds = Set(\n windowsAbove.compactMap { $0[kCGWindowNumber as String] as? CGWindowID }\n )\n\n return otherWindows.contains { otherWindowId, otherWindow in\n if let otherWindowId,\n windowsAboveIds.contains(otherWindowId),\n let otherWindowFrame = otherWindow.frame,\n frame.intersects(otherWindowFrame) {\n Logger.log(\"💡 Window \\\"\\(title ?? \"unknown\")\\\" is below \\\"\\(otherWindow.title ?? \"unknown\")\\\"\")\n return true\n }\n\n return false\n }\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/App/AssignAppCommand.swift", "//\n// AssignAppCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct AssignAppCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"assign-app\",\n abstract: \"Assign an app to a workspace\"\n )\n\n @Option(help: .init(\n \"The name of the app or bundle id. If not provided, the active app will be assigned. Default: active app.\",\n valueName: \"name|bundle id\"\n ))\n var name: String?\n\n @Option(\n name: .customLong(\"workspace\"),\n help: .init(\"The name of the workspace to assign the app to. Default: active workspace.\", valueName: \"name\")\n )\n var workspace: String?\n\n @Option(help: .init(\n \"Activate the workspace. Default: from app settings.\",\n valueName: \"true|false\"\n ))\n var activate: Bool?\n\n @Flag(help: \"Show toast notification\")\n var showNotification = false\n\n func run() throws {\n sendCommand(\n .assignApp(\n app: name,\n workspaceName: workspace,\n activate: activate,\n showNotification: showNotification\n )\n )\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/SpaceControl/SpaceControlSettings.swift", "//\n// SpaceControlSettings.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nfinal class SpaceControlSettings: ObservableObject {\n @Published var enableSpaceControl = false\n @Published var showSpaceControl: AppHotKey?\n @Published var enableSpaceControlAnimations = true\n @Published var spaceControlCurrentDisplayWorkspaces = false\n @Published var spaceControlMaxColumns = 6\n\n private var observer: AnyCancellable?\n private let updateSubject = PassthroughSubject<(), Never>()\n\n init() { observe() }\n\n private func observe() {\n observer = Publishers.MergeMany(\n $enableSpaceControl.settingsPublisher(),\n $showSpaceControl.settingsPublisher(),\n $enableSpaceControlAnimations.settingsPublisher(),\n $spaceControlCurrentDisplayWorkspaces.settingsPublisher(),\n $spaceControlMaxColumns.settingsPublisher(debounce: true)\n )\n .receive(on: DispatchQueue.main)\n .sink { [weak self] in self?.updateSubject.send() }\n }\n}\n\nextension SpaceControlSettings: SettingsProtocol {\n var updatePublisher: AnyPublisher<(), Never> {\n updateSubject.eraseToAnyPublisher()\n }\n\n func load(from appSettings: AppSettings) {\n observer = nil\n enableSpaceControl = appSettings.enableSpaceControl ?? false\n showSpaceControl = appSettings.showSpaceControl\n enableSpaceControlAnimations = appSettings.enableSpaceControlAnimations ?? true\n spaceControlCurrentDisplayWorkspaces = appSettings.spaceControlCurrentDisplayWorkspaces ?? false\n spaceControlMaxColumns = appSettings.spaceControlMaxColumns ?? 6\n observe()\n }\n\n func update(_ appSettings: inout AppSettings) {\n appSettings.enableSpaceControl = enableSpaceControl\n appSettings.showSpaceControl = showSpaceControl\n appSettings.enableSpaceControlAnimations = enableSpaceControlAnimations\n appSettings.spaceControlCurrentDisplayWorkspaces = spaceControlCurrentDisplayWorkspaces\n appSettings.spaceControlMaxColumns = spaceControlMaxColumns\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/App/AssignVisibleAppsCommand.swift", "//\n// AssignVisibleAppsCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct AssignVisibleAppsCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"assign-visible-apps\",\n abstract: \"Assign visible apps to a workspace\"\n )\n\n @Option(\n name: .customLong(\"workspace\"),\n help: .init(\"The name of the workspace to assign apps to. Default: active workspace.\", valueName: \"name\")\n )\n var workspace: String?\n\n @Flag(help: \"Show toast notification\")\n var showNotification = false\n\n func run() throws {\n sendCommand(\n .assignVisibleApps(workspaceName: workspace, showNotification: showNotification)\n )\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/SettingsRepository.swift", "//\n// SettingsRepository.swift\n//\n// Created by Wojciech Kulik on 23/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nfinal class SettingsRepository: ObservableObject {\n private(set) var generalSettings: GeneralSettings\n private(set) var menuBarSettings: MenuBarSettings\n private(set) var gesturesSettings: GesturesSettings\n private(set) var focusManagerSettings: FocusManagerSettings\n private(set) var workspaceSettings: WorkspaceSettings\n private(set) var floatingAppsSettings: FloatingAppsSettings\n private(set) var spaceControlSettings: SpaceControlSettings\n private(set) var integrationsSettings: IntegrationsSettings\n\n private lazy var allSettings: [SettingsProtocol] = [\n generalSettings,\n menuBarSettings,\n gesturesSettings,\n focusManagerSettings,\n workspaceSettings,\n floatingAppsSettings,\n spaceControlSettings,\n integrationsSettings\n ]\n\n private var currentSettings = AppSettings()\n private var cancellables = Set()\n private var shouldUpdate = false\n\n init(\n generalSettings: GeneralSettings,\n menuBarSettings: MenuBarSettings,\n gesturesSettings: GesturesSettings,\n focusManagerSettings: FocusManagerSettings,\n workspaceSettings: WorkspaceSettings,\n floatingAppsSettings: FloatingAppsSettings,\n spaceControlSettings: SpaceControlSettings,\n integrationsSettings: IntegrationsSettings\n ) {\n self.generalSettings = generalSettings\n self.menuBarSettings = menuBarSettings\n self.gesturesSettings = gesturesSettings\n self.focusManagerSettings = focusManagerSettings\n self.workspaceSettings = workspaceSettings\n self.floatingAppsSettings = floatingAppsSettings\n self.spaceControlSettings = spaceControlSettings\n self.integrationsSettings = integrationsSettings\n\n loadFromDisk()\n\n Publishers.MergeMany(allSettings.map(\\.updatePublisher))\n .sink { [weak self] in self?.updateSettings() }\n .store(in: &cancellables)\n }\n\n func saveToDisk() {\n Logger.log(\"Saving settings to disk\")\n try? ConfigSerializer.serialize(filename: \"settings\", currentSettings)\n }\n\n private func updateSettings() {\n guard shouldUpdate else { return }\n\n var settings = AppSettings()\n allSettings.forEach { $0.update(&settings) }\n currentSettings = settings\n saveToDisk()\n\n AppDependencies.shared.hotKeysManager.refresh()\n objectWillChange.send()\n }\n\n private func loadFromDisk() {\n Logger.log(\"Loading settings from disk\")\n\n shouldUpdate = false\n defer { shouldUpdate = true }\n\n guard let settings = try? ConfigSerializer.deserialize(\n AppSettings.self,\n filename: \"settings\"\n ) else { return }\n\n currentSettings = settings\n allSettings.forEach { $0.load(from: settings) }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Workspaces/WorkspaceSettings.swift", "//\n// WorkspaceSettings.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nfinal class WorkspaceSettings: ObservableObject {\n @Published var displayMode: DisplayMode = .static\n\n @Published var centerCursorOnWorkspaceChange = false\n @Published var changeWorkspaceOnAppAssign = true\n @Published var activeWorkspaceOnFocusChange = true\n @Published var skipEmptyWorkspacesOnSwitch = false\n @Published var keepUnassignedAppsOnSwitch = false\n @Published var restoreHiddenAppsOnSwitch = true\n @Published var enableWorkspaceTransitions = false\n @Published var workspaceTransitionDuration = 0.3\n @Published var workspaceTransitionDimming = 0.2\n\n @Published var assignFocusedApp: AppHotKey?\n @Published var unassignFocusedApp: AppHotKey?\n @Published var toggleFocusedAppAssignment: AppHotKey?\n @Published var assignVisibleApps: AppHotKey?\n @Published var hideUnassignedApps: AppHotKey?\n\n @Published var loopWorkspaces = true\n @Published var switchToRecentWorkspace: AppHotKey?\n @Published var switchToPreviousWorkspace: AppHotKey?\n @Published var switchToNextWorkspace: AppHotKey?\n\n @Published var alternativeDisplays = \"\"\n\n @Published var enablePictureInPictureSupport = true\n @Published var switchWorkspaceWhenPipCloses = true\n @Published var pipScreenCornerOffset = 15\n @Published var pipApps: [PipApp] = []\n\n private var observer: AnyCancellable?\n private let updateSubject = PassthroughSubject<(), Never>()\n\n init() { observe() }\n\n func addPipApp(_ app: PipApp) {\n pipApps.append(app)\n }\n\n func deletePipApp(_ app: PipApp) {\n pipApps.removeAll { $0 == app }\n }\n\n private func observe() {\n observer = Publishers.MergeMany(\n $displayMode.settingsPublisher(),\n\n $centerCursorOnWorkspaceChange.settingsPublisher(),\n $changeWorkspaceOnAppAssign.settingsPublisher(),\n $activeWorkspaceOnFocusChange.settingsPublisher(),\n $skipEmptyWorkspacesOnSwitch.settingsPublisher(),\n $keepUnassignedAppsOnSwitch.settingsPublisher(),\n $restoreHiddenAppsOnSwitch.settingsPublisher(),\n $enableWorkspaceTransitions.settingsPublisher(),\n $workspaceTransitionDuration.settingsPublisher(debounce: true),\n $workspaceTransitionDimming.settingsPublisher(debounce: true),\n\n $assignFocusedApp.settingsPublisher(),\n $unassignFocusedApp.settingsPublisher(),\n $toggleFocusedAppAssignment.settingsPublisher(),\n $assignVisibleApps.settingsPublisher(),\n $hideUnassignedApps.settingsPublisher(),\n\n $loopWorkspaces.settingsPublisher(),\n $switchToRecentWorkspace.settingsPublisher(),\n $switchToPreviousWorkspace.settingsPublisher(),\n $switchToNextWorkspace.settingsPublisher(),\n\n $alternativeDisplays.settingsPublisher(debounce: true),\n $enablePictureInPictureSupport.settingsPublisher(),\n $switchWorkspaceWhenPipCloses.settingsPublisher(),\n $pipApps.settingsPublisher(),\n $pipScreenCornerOffset.settingsPublisher(debounce: true)\n )\n .receive(on: DispatchQueue.main)\n .sink { [weak self] in self?.updateSubject.send() }\n }\n}\n\nextension WorkspaceSettings: SettingsProtocol {\n var updatePublisher: AnyPublisher<(), Never> {\n updateSubject.eraseToAnyPublisher()\n }\n\n func load(from appSettings: AppSettings) {\n observer = nil\n displayMode = appSettings.displayMode ?? .static\n\n centerCursorOnWorkspaceChange = appSettings.centerCursorOnWorkspaceChange ?? false\n changeWorkspaceOnAppAssign = appSettings.changeWorkspaceOnAppAssign ?? true\n activeWorkspaceOnFocusChange = appSettings.activeWorkspaceOnFocusChange ?? true\n skipEmptyWorkspacesOnSwitch = appSettings.skipEmptyWorkspacesOnSwitch ?? false\n keepUnassignedAppsOnSwitch = appSettings.keepUnassignedAppsOnSwitch ?? false\n restoreHiddenAppsOnSwitch = appSettings.restoreHiddenAppsOnSwitch ?? true\n enableWorkspaceTransitions = appSettings.enableWorkspaceTransitions ?? false\n workspaceTransitionDuration = min(appSettings.workspaceTransitionDuration ?? 0.3, 0.5)\n workspaceTransitionDimming = min(appSettings.workspaceTransitionDimming ?? 0.2, 0.5)\n\n assignFocusedApp = appSettings.assignFocusedApp\n unassignFocusedApp = appSettings.unassignFocusedApp\n toggleFocusedAppAssignment = appSettings.toggleFocusedAppAssignment\n assignVisibleApps = appSettings.assignVisibleApps\n hideUnassignedApps = appSettings.hideUnassignedApps\n\n loopWorkspaces = appSettings.loopWorkspaces ?? true\n switchToRecentWorkspace = appSettings.switchToRecentWorkspace\n switchToPreviousWorkspace = appSettings.switchToPreviousWorkspace\n switchToNextWorkspace = appSettings.switchToNextWorkspace\n\n alternativeDisplays = appSettings.alternativeDisplays ?? \"\"\n enablePictureInPictureSupport = appSettings.enablePictureInPictureSupport ?? true\n switchWorkspaceWhenPipCloses = appSettings.switchWorkspaceWhenPipCloses ?? true\n pipApps = appSettings.pipApps ?? []\n pipScreenCornerOffset = appSettings.pipScreenCornerOffset ?? 15\n observe()\n }\n\n func update(_ appSettings: inout AppSettings) {\n appSettings.displayMode = displayMode\n\n appSettings.centerCursorOnWorkspaceChange = centerCursorOnWorkspaceChange\n appSettings.changeWorkspaceOnAppAssign = changeWorkspaceOnAppAssign\n appSettings.activeWorkspaceOnFocusChange = activeWorkspaceOnFocusChange\n appSettings.skipEmptyWorkspacesOnSwitch = skipEmptyWorkspacesOnSwitch\n appSettings.keepUnassignedAppsOnSwitch = keepUnassignedAppsOnSwitch\n appSettings.restoreHiddenAppsOnSwitch = restoreHiddenAppsOnSwitch\n appSettings.enableWorkspaceTransitions = enableWorkspaceTransitions\n appSettings.workspaceTransitionDuration = workspaceTransitionDuration\n appSettings.workspaceTransitionDimming = workspaceTransitionDimming\n\n appSettings.assignFocusedApp = assignFocusedApp\n appSettings.unassignFocusedApp = unassignFocusedApp\n appSettings.toggleFocusedAppAssignment = toggleFocusedAppAssignment\n appSettings.assignVisibleApps = assignVisibleApps\n appSettings.hideUnassignedApps = hideUnassignedApps\n\n appSettings.loopWorkspaces = loopWorkspaces\n appSettings.switchToRecentWorkspace = switchToRecentWorkspace\n appSettings.switchToPreviousWorkspace = switchToPreviousWorkspace\n appSettings.switchToNextWorkspace = switchToNextWorkspace\n\n appSettings.alternativeDisplays = alternativeDisplays\n appSettings.enablePictureInPictureSupport = enablePictureInPictureSupport\n appSettings.switchWorkspaceWhenPipCloses = switchWorkspaceWhenPipCloses\n appSettings.pipApps = pipApps\n appSettings.pipScreenCornerOffset = pipScreenCornerOffset\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Commands/SpaceControlCommands.swift", "//\n// SpaceControlCommands.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\n\nfinal class SpaceControlCommands: CommandExecutor {\n func execute(command: CommandRequest) -> CommandResponse? {\n switch command {\n case .openSpaceControl:\n if SpaceControl.isEnabled {\n SpaceControl.show()\n return CommandResponse(success: true)\n } else {\n return CommandResponse(success: false, error: \"Space Control is not enabled\")\n }\n\n default:\n return nil\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/HotKeys/Extensions/AppHotKey+Shortcut.swift", "//\n// AppHotKey+Shortcut.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ShortcutRecorder\n\nextension [(AppHotKey, () -> ())] {\n func toShortcutPairs() -> [(Shortcut, () -> ())] {\n map { ($0.0.toShortcut(), $0.1) }\n .compactMap {\n guard let shortcut = $0.0 else { return nil }\n return (shortcut, $0.1)\n }\n }\n}\n\nextension AppHotKey {\n func toShortcut() -> Shortcut? {\n let components = value.components(separatedBy: \"+\")\n let modifiers = KeyModifiersMap.toModifiers(value)\n\n guard let keyEquivalent = components.last,\n let rawKeyCode = KeyCodesMap[keyEquivalent],\n let keyCode = KeyCode(rawValue: rawKeyCode) else { return nil }\n\n return Shortcut(\n code: keyCode,\n modifierFlags: NSEvent.ModifierFlags(rawValue: modifiers),\n characters: nil,\n charactersIgnoringModifiers: nil\n )\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Workspaces/WorkspaceSettingsViewModel.swift", "//\n// WorkspaceSettingsViewModel.swift\n//\n// Created by Wojciech Kulik on 22/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nfinal class WorkspaceSettingsViewModel: ObservableObject {\n @Published var windowTitleRegex = \"\"\n @Published var isInputDialogPresented = false {\n didSet {\n if !isInputDialogPresented, windowTitleRegex.isNotEmpty {\n addPendingPipApp()\n windowTitleRegex = \"\"\n }\n }\n }\n\n private var pendingApp: PipApp?\n private let settings = AppDependencies.shared.workspaceSettings\n\n func addPipApp() {\n let fileChooser = FileChooser()\n let appUrl = fileChooser.runModalOpenPanel(\n allowedFileTypes: [.application],\n directoryURL: URL(filePath: \"/Applications\")\n )\n\n guard let bundle = appUrl?.bundle else { return }\n\n pendingApp = PipApp(\n name: bundle.localizedAppName,\n bundleIdentifier: bundle.bundleIdentifier ?? \"\",\n pipWindowTitleRegex: \"\"\n )\n isInputDialogPresented = true\n }\n\n func deletePipApp(_ app: PipApp) {\n settings.deletePipApp(app)\n }\n\n private func addPendingPipApp() {\n guard let pendingApp else { return }\n\n settings.addPipApp(\n .init(\n name: pendingApp.name,\n bundleIdentifier: pendingApp.bundleIdentifier,\n pipWindowTitleRegex: windowTitleRegex\n )\n )\n self.pendingApp = nil\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/FlashSpaceCLI.swift", "//\n// FlashSpaceCLI.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\n@main\nstruct FlashSpaceCLI: ParsableCommand {\n static let configuration: CommandConfiguration = .init(\n commandName: \"flashspace\",\n abstract: \"FlashSpace CLI\",\n version: \"1.0.0\",\n groupedSubcommands: [\n .init(\n name: \"Profile\",\n subcommands: [\n CreateProfileCommand.self,\n DeleteProfileCommand.self,\n ProfileCommand.self\n ]\n ),\n .init(\n name: \"Workspace\",\n subcommands: [\n CreateWorkspaceCommand.self,\n DeleteWorkspaceCommand.self,\n UpdateWorkspaceCommand.self,\n WorkspaceCommand.self\n ]\n ),\n .init(\n name: \"App\",\n subcommands: [\n AssignVisibleAppsCommand.self,\n AssignAppCommand.self,\n UnassignAppCommand.self,\n HideUnassignedAppsCommand.self,\n FocusCommand.self,\n FloatingAppsCommand.self\n ]\n ),\n .init(\n name: \"List\",\n subcommands: [\n ListProfilesCommand.self,\n ListWorkspacesCommand.self,\n ListAppsCommand.self,\n ListFloatingAppsCommand.self,\n ListRunningAppsCommand.self,\n ListDisplaysCommand.self\n ]\n ),\n .init(\n name: \"Get\",\n subcommands: [\n GetProfileCommand.self,\n GetWorkspaceCommand.self,\n GetAppCommand.self,\n GetDisplayCommand.self\n ]\n ),\n .init(\n name: \"Open\",\n subcommands: [\n OpenAppCommand.self,\n OpenSpaceControlCommand.self\n ]\n )\n ]\n )\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Profiles/ProfilesSettingsViewModel.swift", "//\n// ProfilesSettingsViewModel.swift\n//\n// Created by Wojciech Kulik on 26/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nfinal class ProfilesSettingsViewModel: ObservableObject {\n enum Action {\n case createProfile\n case renameProfile(ProfileId)\n case deleteProfile(ProfileId)\n }\n\n @Published var isInputDialogPresented = false\n @Published var isDeleteConfirmationPresented = false\n @Published var isCopyChoicePresented = false\n @Published var profileToDelete = \"\"\n @Published var userInput = \"\"\n\n var hideDeleteButton: Bool { profilesRepository.profiles.count == 1 }\n\n private var action: Action?\n\n private let profilesRepository = AppDependencies.shared.profilesRepository\n\n func createNewProfile() {\n action = .createProfile\n userInput = \"\"\n isInputDialogPresented = true\n }\n\n func createNewProfile(copyWorkspaces: Bool) {\n let input = userInput.trimmingCharacters(in: .whitespacesAndNewlines)\n guard !input.isEmpty else { return }\n\n profilesRepository.createProfile(name: input, keepWorkspaces: copyWorkspaces)\n }\n\n func renameProfile(_ profile: Profile) {\n action = .renameProfile(profile.id)\n userInput = profile.name\n isInputDialogPresented = true\n }\n\n func deleteProfile(_ profile: Profile) {\n action = .deleteProfile(profile.id)\n profileToDelete = profile.name\n isDeleteConfirmationPresented = true\n }\n\n func inputDialogDismissed() {\n let input = userInput.trimmingCharacters(in: .whitespacesAndNewlines)\n guard let action, !input.isEmpty else { return }\n\n switch action {\n case .createProfile:\n isCopyChoicePresented = true\n case .renameProfile(let id):\n profilesRepository.renameProfile(id: id, to: input)\n case .deleteProfile:\n break\n }\n }\n\n func deleteConfirmed() {\n guard let action else { return }\n\n switch action {\n case .deleteProfile(let id):\n profilesRepository.deleteProfile(id: id)\n default:\n break\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Utils/FileChooser.swift", "//\n// FileChooser.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\nimport UniformTypeIdentifiers\n\nfinal class FileChooser {\n func runModalOpenPanel(allowedFileTypes: [UTType]?, directoryURL: URL?) -> URL? {\n let openPanel = NSOpenPanel()\n openPanel.canChooseFiles = true\n openPanel.allowedContentTypes = allowedFileTypes ?? []\n openPanel.directoryURL = directoryURL\n\n return openPanel.runModal() == .OK ? openPanel.url : nil\n }\n\n func runModalSavePanel(allowedFileTypes: [UTType]?, defaultFileName: String?) -> URL? {\n let savePanel = NSSavePanel()\n savePanel.allowsOtherFileTypes = false\n savePanel.canCreateDirectories = true\n savePanel.allowedContentTypes = allowedFileTypes ?? []\n savePanel.nameFieldStringValue = defaultFileName ?? \"\"\n\n return savePanel.runModal() == .OK ? savePanel.url : nil\n }\n\n @MainActor\n func runSheetModalOpenPanel(window: NSWindow, allowedFileTypes: [UTType]?, directoryURL: URL?) async -> URL? {\n let openPanel = NSOpenPanel()\n openPanel.canChooseFiles = true\n openPanel.allowedContentTypes = allowedFileTypes ?? []\n openPanel.directoryURL = directoryURL\n\n return await openPanel.beginSheetModal(for: window) == .OK ? openPanel.url : nil\n }\n\n @MainActor\n func runSheetModalSavePanel(window: NSWindow, allowedFileTypes: [UTType]?, defaultFileName: String?) async -> URL? {\n let savePanel = NSSavePanel()\n savePanel.allowsOtherFileTypes = false\n savePanel.canCreateDirectories = true\n savePanel.allowedContentTypes = allowedFileTypes ?? []\n savePanel.nameFieldStringValue = defaultFileName ?? \"\"\n\n return await savePanel.beginSheetModal(for: window) == .OK ? savePanel.url : nil\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/NSRunningApplication.swift", "//\n// NSRunningApplication.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension NSRunningApplication {\n var toMacApp: MacApp { .init(app: self) }\n var iconPath: String? { bundleURL?.iconPath }\n}\n\nextension [NSRunningApplication] {\n func find(_ app: MacApp?) -> NSRunningApplication? {\n guard let app else { return nil }\n\n return first { $0.bundleIdentifier == app.bundleIdentifier }\n }\n\n func findFirstMatch(with apps: [MacApp]) -> NSRunningApplication? {\n let bundleIdentifiers = apps.map(\\.bundleIdentifier).asSet\n\n return first { bundleIdentifiers.contains($0.bundleIdentifier ?? \"\") }\n }\n\n func excludeFloatingAppsOnDifferentScreen() -> [NSRunningApplication] {\n let activeWorkspace = AppDependencies.shared.workspaceManager.activeWorkspace[NSScreen.main?.localizedName ?? \"\"]\n let floatingApps = AppDependencies.shared.floatingAppsSettings.floatingApps\n\n guard let activeWorkspace else { return self }\n\n return filter { app in\n !floatingApps.containsApp(app) || app.isOnAnyDisplay(activeWorkspace.displays)\n }\n }\n\n func regularVisibleApps(onDisplays displays: Set, excluding apps: [MacApp]) -> [NSRunningApplication] {\n filter { app in\n app.activationPolicy == .regular &&\n !app.isHidden &&\n !apps.containsApp(app) &&\n app.isOnAnyDisplay(displays)\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Gestures/GesturesSettings.swift", "//\n// GesturesSettings.swift\n//\n// Created by Wojciech Kulik on 22/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nfinal class GesturesSettings: ObservableObject {\n @Published var swipeThreshold: Double = 0.2\n @Published var enableSwipeGestures = false {\n didSet { updateSwipeManager() }\n }\n\n @Published var restartAppOnWakeUp = false\n\n @Published var swipeRight3FingerAction: GestureAction = .nextWorkspace\n @Published var swipeLeft3FingerAction: GestureAction = .previousWorkspace\n @Published var swipeRight4FingerAction: GestureAction = .none\n @Published var swipeLeft4FingerAction: GestureAction = .none\n\n @Published var swipeUp3FingerAction: GestureAction = .none\n @Published var swipeDown3FingerAction: GestureAction = .none\n @Published var swipeUp4FingerAction: GestureAction = .none\n @Published var swipeDown4FingerAction: GestureAction = .none\n\n var isVerticalSwipeSet: Bool {\n swipeUp3FingerAction != .none || swipeDown3FingerAction != .none ||\n swipeUp4FingerAction != .none || swipeDown4FingerAction != .none\n }\n\n var isHorizontalSwipeSet: Bool {\n swipeLeft3FingerAction != .none || swipeRight3FingerAction != .none ||\n swipeLeft4FingerAction != .none || swipeRight4FingerAction != .none\n }\n\n private var observer: AnyCancellable?\n private let updateSubject = PassthroughSubject<(), Never>()\n\n init() {\n observe()\n updateSwipeManager()\n }\n\n private func observe() {\n observer = Publishers.MergeMany(\n $enableSwipeGestures.settingsPublisher(),\n $swipeThreshold.settingsPublisher(),\n $restartAppOnWakeUp.settingsPublisher(),\n\n $swipeLeft3FingerAction.settingsPublisher(),\n $swipeRight3FingerAction.settingsPublisher(),\n $swipeLeft4FingerAction.settingsPublisher(),\n $swipeRight4FingerAction.settingsPublisher(),\n\n $swipeUp3FingerAction.settingsPublisher(),\n $swipeDown3FingerAction.settingsPublisher(),\n $swipeUp4FingerAction.settingsPublisher(),\n $swipeDown4FingerAction.settingsPublisher()\n )\n .receive(on: DispatchQueue.main)\n .sink { [weak self] in self?.updateSubject.send() }\n }\n\n private func updateSwipeManager() {\n if enableSwipeGestures {\n SwipeManager.shared.start()\n } else {\n SwipeManager.shared.stop()\n }\n }\n}\n\nextension GesturesSettings: SettingsProtocol {\n var updatePublisher: AnyPublisher<(), Never> {\n updateSubject.eraseToAnyPublisher()\n }\n\n func load(from appSettings: AppSettings) {\n observer = nil\n enableSwipeGestures = appSettings.enableSwipeGestures ?? false\n swipeThreshold = appSettings.swipeThreshold ?? 0.2\n restartAppOnWakeUp = appSettings.restartAppOnWakeUp ?? false\n\n swipeLeft3FingerAction = appSettings.swipeLeft3FingerAction ?? .previousWorkspace\n swipeRight3FingerAction = appSettings.swipeRight3FingerAction ?? .nextWorkspace\n swipeLeft4FingerAction = appSettings.swipeLeft4FingerAction ?? .none\n swipeRight4FingerAction = appSettings.swipeRight4FingerAction ?? .none\n\n swipeUp3FingerAction = appSettings.swipeUp3FingerAction ?? .none\n swipeDown3FingerAction = appSettings.swipeDown3FingerAction ?? .none\n swipeUp4FingerAction = appSettings.swipeUp4FingerAction ?? .none\n swipeDown4FingerAction = appSettings.swipeDown4FingerAction ?? .none\n\n observe()\n }\n\n func update(_ appSettings: inout AppSettings) {\n appSettings.enableSwipeGestures = enableSwipeGestures\n appSettings.swipeThreshold = swipeThreshold\n appSettings.restartAppOnWakeUp = restartAppOnWakeUp\n\n appSettings.swipeLeft3FingerAction = swipeLeft3FingerAction\n appSettings.swipeRight3FingerAction = swipeRight3FingerAction\n appSettings.swipeLeft4FingerAction = swipeLeft4FingerAction\n appSettings.swipeRight4FingerAction = swipeRight4FingerAction\n\n appSettings.swipeUp3FingerAction = swipeUp3FingerAction\n appSettings.swipeDown3FingerAction = swipeDown3FingerAction\n appSettings.swipeUp4FingerAction = swipeUp4FingerAction\n appSettings.swipeDown4FingerAction = swipeDown4FingerAction\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/_Extensions/Publisher.swift", "//\n// Publisher.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nextension Publisher where Output: Equatable {\n func settingsPublisher() -> AnyPublisher<(), Failure> {\n removeDuplicates()\n .map { _ in }\n .dropFirst()\n .eraseToAnyPublisher()\n }\n\n func settingsPublisher(debounce: Bool) -> AnyPublisher<(), Failure> {\n if debounce {\n self.debounce(for: .seconds(1), scheduler: DispatchQueue.main)\n .settingsPublisher()\n } else {\n settingsPublisher()\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/FloatingApps/FloatingAppsSettings.swift", "//\n// FloatingAppsSettings.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nfinal class FloatingAppsSettings: ObservableObject {\n @Published var floatingApps: [MacApp] = []\n @Published var floatTheFocusedApp: AppHotKey?\n @Published var unfloatTheFocusedApp: AppHotKey?\n @Published var toggleTheFocusedAppFloating: AppHotKey?\n\n private var observer: AnyCancellable?\n private let updateSubject = PassthroughSubject<(), Never>()\n\n init() { observe() }\n\n func addFloatingAppIfNeeded(app: MacApp) {\n guard !floatingApps.contains(app) else { return }\n floatingApps.append(app)\n }\n\n func deleteFloatingApp(app: MacApp) {\n floatingApps.removeAll { $0 == app }\n }\n\n private func observe() {\n observer = Publishers.MergeMany(\n $floatingApps.settingsPublisher(),\n $floatTheFocusedApp.settingsPublisher(),\n $unfloatTheFocusedApp.settingsPublisher(),\n $toggleTheFocusedAppFloating.settingsPublisher()\n )\n .receive(on: DispatchQueue.main)\n .sink { [weak self] in self?.updateSubject.send() }\n }\n}\n\nextension FloatingAppsSettings: SettingsProtocol {\n var updatePublisher: AnyPublisher<(), Never> {\n updateSubject.eraseToAnyPublisher()\n }\n\n func load(from appSettings: AppSettings) {\n observer = nil\n floatingApps = appSettings.floatingApps ?? []\n floatTheFocusedApp = appSettings.floatTheFocusedApp\n unfloatTheFocusedApp = appSettings.unfloatTheFocusedApp\n toggleTheFocusedAppFloating = appSettings.toggleTheFocusedAppFloating\n observe()\n }\n\n func update(_ appSettings: inout AppSettings) {\n appSettings.floatingApps = floatingApps.isEmpty ? nil : floatingApps\n appSettings.floatTheFocusedApp = floatTheFocusedApp\n appSettings.unfloatTheFocusedApp = unfloatTheFocusedApp\n appSettings.toggleTheFocusedAppFloating = toggleTheFocusedAppFloating\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Workspace/CreateWorkspaceCommand.swift", "//\n// CreateWorkspaceCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct CreateWorkspaceRequest: Codable {\n let name: String\n let display: String?\n let icon: String?\n let activateKey: String?\n let assignKey: String?\n let activate: Bool\n}\n\nstruct CreateWorkspaceCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"create-workspace\",\n abstract: \"Create a workspace\"\n )\n\n @Argument(help: \"The name of the workspace to create.\")\n var name: String\n\n @Option(help: .init(\"The name of the display\", valueName: \"name\"))\n var display: String?\n\n @Option(help: \"The name of the icon to use for the workspace. Must match SF Symbols.\")\n var icon: String?\n\n @Option(help: \"The hotkey to activate the workspace\")\n var activateKey: String?\n\n @Option(help: \"The hotkey to assign the app\")\n var assignKey: String?\n\n @Flag(help: \"Activate the new workspace\")\n var activate = false\n\n func run() throws {\n let request = CreateWorkspaceRequest(\n name: name,\n display: display,\n icon: icon,\n activateKey: activateKey,\n assignKey: assignKey,\n activate: activate\n )\n sendCommand(.createWorkspace(request))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/CLI.swift", "//\n// CLI.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nenum CLI {\n static var cliPath: String { Bundle.main.bundlePath + \"/Contents/Resources/flashspace\" }\n static var symlinkPath: String { \"/usr/local/bin/flashspace\" }\n static var isInstalled: Bool { FileManager.default.fileExists(atPath: symlinkPath) }\n\n static func install() {\n guard !isInstalled else {\n return print(\"✅ CLI already installed at \\(symlinkPath)\")\n }\n\n if runSudoScript(\"ln -s '\\(cliPath)' '\\(symlinkPath)'\") {\n Logger.log(\"✅ CLI installed from \\(symlinkPath)\")\n }\n }\n\n static func uninstall() {\n guard isInstalled else { return print(\"✅ CLI already uninstalled\") }\n\n if runSudoScript(\"rm '\\(symlinkPath)'\") {\n Logger.log(\"✅ CLI uninstalled from \\(symlinkPath)\")\n }\n }\n\n private static func runSudoScript(_ script: String) -> Bool {\n let appleScript =\n \"do shell script \\\"sudo \\(script)\\\" with administrator privileges\"\n\n guard let scriptObject = NSAppleScript(source: appleScript) else {\n Logger.log(\"❌ Error: Failed to create AppleScript object\")\n Alert.showOkAlert(title: \"Error\", message: \"Could not run script\")\n return false\n }\n\n var error: NSDictionary?\n scriptObject.executeAndReturnError(&error)\n\n if let error {\n Logger.log(\"❌ Error: \\(error)\")\n if let errorNumber = error[\"NSAppleScriptErrorNumber\"],\n errorNumber as? NSNumber != -128,\n let errorMessage = error[\"NSAppleScriptErrorMessage\"] as? String {\n Alert.showOkAlert(title: \"Error\", message: errorMessage)\n }\n return false\n }\n\n return true\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/View.swift", "//\n// View.swift\n//\n// Created by Wojciech Kulik on 25/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nextension View {\n func hotkey(_ title: String, for hotKey: Binding) -> some View {\n HStack {\n Text(title)\n Spacer()\n HotKeyControl(shortcut: hotKey).fixedSize()\n }\n }\n\n @ViewBuilder\n func hidden(_ isHidden: Bool) -> some View {\n if !isHidden {\n self\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/App/Migrations.swift", "//\n// Migrations.swift\n//\n// Created by Wojciech Kulik on 08/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nenum Migrations {\n static var appsMigrated = false\n static var hotKeysMigrated = false\n\n static func migrateIfNeeded(\n settingsRepository: SettingsRepository,\n profilesRepository: ProfilesRepository\n ) {\n if Migrations.appsMigrated {\n Logger.log(\"Migrated apps\")\n\n let workspacesJsonUrl = FileManager.default\n .homeDirectoryForCurrentUser\n .appendingPathComponent(\".config/flashspace/workspaces.json\")\n try? FileManager.default.moveItem(\n at: workspacesJsonUrl,\n to: workspacesJsonUrl.deletingLastPathComponent()\n .appendingPathComponent(\"workspaces.json.bak\")\n )\n\n settingsRepository.saveToDisk()\n profilesRepository.saveToDisk()\n } else if Migrations.hotKeysMigrated {\n Logger.log(\"Migrated hot keys\")\n settingsRepository.saveToDisk()\n profilesRepository.saveToDisk()\n }\n\n Migrations.appsMigrated = false\n Migrations.hotKeysMigrated = false\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/FloatingApps/FloatingAppsSettingsViewModel.swift", "import Foundation\nimport SwiftUI\n\nfinal class FloatingAppsSettingsViewModel: ObservableObject {\n private let settings = AppDependencies.shared.floatingAppsSettings\n\n func addFloatingApp() {\n let fileChooser = FileChooser()\n let appUrl = fileChooser.runModalOpenPanel(\n allowedFileTypes: [.application],\n directoryURL: URL(filePath: \"/Applications\")\n )\n\n guard let bundle = appUrl?.bundle else { return }\n\n settings.addFloatingAppIfNeeded(\n app: .init(\n name: bundle.localizedAppName,\n bundleIdentifier: bundle.bundleIdentifier ?? \"\",\n iconPath: bundle.iconPath\n )\n )\n }\n\n func deleteFloatingApp(app: MacApp) {\n settings.deleteFloatingApp(app: app)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Config/Models/TOMLCoding.swift", "//\n// TOMLCoding.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\nimport TOMLKit\n\nextension TOMLEncoder: ConfigEncoder {\n func encode(_ value: some Encodable) throws -> Data {\n let toml: String = try encode(value)\n return toml.data(using: .utf8) ?? Data()\n }\n}\n\nextension TOMLDecoder: ConfigDecoder {\n func decode(_ type: T.Type, from data: Data) throws -> T where T: Decodable {\n let toml = String(data: data, encoding: .utf8) ?? \"\"\n return try decode(T.self, from: toml)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Models/CreateWorkspaceRequest.swift", "//\n// CreateWorkspaceRequest.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\n\nstruct CreateWorkspaceRequest: Codable {\n let name: String\n let display: String?\n let icon: String?\n let activateKey: String?\n let assignKey: String?\n let activate: Bool\n}\n\nextension CreateWorkspaceRequest {\n var toWorkspace: Workspace {\n Workspace(\n id: .init(),\n name: name,\n display: display ?? NSScreen.main?.localizedName ?? \"\",\n activateShortcut: activateKey.flatMap { .init(value: $0) },\n assignAppShortcut: assignKey.flatMap { .init(value: $0) },\n apps: [],\n appToFocus: nil,\n symbolIconName: icon\n )\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/App/FloatingAppsCommand.swift", "//\n// FloatingAppsCommand.swift\n//\n// Created by Wojciech Kulik on 03/05/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct FloatingAppsCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"floating-apps\",\n abstract: \"Manage floating apps\"\n )\n\n enum Action: String, CaseIterable, ExpressibleByArgument {\n case float\n case unfloat\n case toggle\n }\n\n @Argument(help: \"The action to perform\")\n var action: Action\n\n @Option(help: .init(\n \"The name of the app or bundle id. If not provided, the active app will be used. Default: active app.\",\n valueName: \"name|bundle id\"\n ))\n var name: String?\n\n @Flag(help: \"Show toast notification\")\n var showNotification = false\n\n func run() throws {\n switch action {\n case .float:\n sendCommand(.floatApp(app: name, showNotification: showNotification))\n case .unfloat:\n sendCommand(.unfloatApp(app: name, showNotification: showNotification))\n case .toggle:\n sendCommand(.toggleFloatApp(app: name, showNotification: showNotification))\n }\n\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Integrations/IntegrationsSettings.swift", "//\n// IntegrationsSettings.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nfinal class IntegrationsSettings: ObservableObject {\n static let defaultWorkspaceChangeScript = \"sketchybar --trigger flashspace_workspace_change WORKSPACE=\\\"$WORKSPACE\\\" DISPLAY=\\\"$DISPLAY\\\"\"\n static let defaultProfileChangeScript = \"sketchybar --reload\"\n\n @Published var enableIntegrations = false\n @Published var runScriptOnLaunch = \"\"\n @Published var runScriptOnWorkspaceChange = IntegrationsSettings.defaultWorkspaceChangeScript\n @Published var runScriptOnProfileChange = IntegrationsSettings.defaultProfileChangeScript\n\n private var observer: AnyCancellable?\n private let updateSubject = PassthroughSubject<(), Never>()\n\n init() {\n observe()\n\n DispatchQueue.main.async {\n Integrations.runOnAppLaunchIfNeeded()\n }\n }\n\n private func observe() {\n observer = Publishers.MergeMany(\n $enableIntegrations.settingsPublisher(),\n $runScriptOnWorkspaceChange.settingsPublisher(debounce: true),\n $runScriptOnLaunch.settingsPublisher(debounce: true),\n $runScriptOnProfileChange.settingsPublisher(debounce: true)\n )\n .receive(on: DispatchQueue.main)\n .sink { [weak self] in self?.updateSubject.send() }\n }\n}\n\nextension IntegrationsSettings: SettingsProtocol {\n var updatePublisher: AnyPublisher<(), Never> {\n updateSubject.eraseToAnyPublisher()\n }\n\n func load(from appSettings: AppSettings) {\n observer = nil\n enableIntegrations = appSettings.enableIntegrations ?? false\n runScriptOnLaunch = appSettings.runScriptOnLaunch ?? \"\"\n runScriptOnWorkspaceChange = appSettings.runScriptOnWorkspaceChange ?? Self.defaultWorkspaceChangeScript\n runScriptOnProfileChange = appSettings.runScriptOnProfileChange ?? Self.defaultProfileChangeScript\n observe()\n }\n\n func update(_ appSettings: inout AppSettings) {\n appSettings.enableIntegrations = enableIntegrations\n appSettings.runScriptOnLaunch = runScriptOnLaunch\n appSettings.runScriptOnWorkspaceChange = runScriptOnWorkspaceChange\n appSettings.runScriptOnProfileChange = runScriptOnProfileChange\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/MenuBar/MenuBarSettings.swift", "//\n// MenuBarSettings.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nfinal class MenuBarSettings: ObservableObject {\n static let defaultMenuBarTitleTemplate = \"$WORKSPACE\"\n\n @Published var showMenuBarTitle = true\n @Published var showMenuBarIcon = true\n @Published var menuBarTitleTemplate = MenuBarSettings.defaultMenuBarTitleTemplate\n @Published var menuBarDisplayAliases = \"\"\n\n private var observer: AnyCancellable?\n private let updateSubject = PassthroughSubject<(), Never>()\n\n init() { observe() }\n\n private func observe() {\n observer = Publishers.MergeMany(\n $showMenuBarTitle.settingsPublisher(),\n $showMenuBarIcon.settingsPublisher(),\n $menuBarTitleTemplate.settingsPublisher(debounce: true),\n $menuBarDisplayAliases.settingsPublisher(debounce: true)\n )\n .receive(on: DispatchQueue.main)\n .sink { [weak self] in self?.updateSubject.send() }\n }\n}\n\nextension MenuBarSettings: SettingsProtocol {\n var updatePublisher: AnyPublisher<(), Never> {\n updateSubject.eraseToAnyPublisher()\n }\n\n func load(from appSettings: AppSettings) {\n observer = nil\n showMenuBarTitle = appSettings.showMenuBarTitle ?? true\n showMenuBarIcon = appSettings.showMenuBarIcon ?? true\n menuBarTitleTemplate = appSettings.menuBarTitleTemplate ?? Self.defaultMenuBarTitleTemplate\n menuBarDisplayAliases = appSettings.menuBarDisplayAliases ?? \"\"\n observe()\n }\n\n func update(_ appSettings: inout AppSettings) {\n appSettings.showMenuBarTitle = showMenuBarTitle\n appSettings.showMenuBarIcon = showMenuBarIcon\n appSettings.menuBarTitleTemplate = menuBarTitleTemplate\n appSettings.menuBarDisplayAliases = menuBarDisplayAliases\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/Bundle.swift", "//\n// Bundle.swift\n//\n// Created by Wojciech Kulik on 26/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nextension Bundle {\n var localizedAppName: String {\n localizedInfoDictionary?[\"CFBundleDisplayName\"] as? String\n ?? infoDictionary?[\"CFBundleDisplayName\"] as? String\n ?? infoDictionary?[\"CFBundleName\"] as? String\n ?? bundleURL.fileName\n }\n\n var isAgent: Bool {\n infoDictionary?[\"LSUIElement\"] as? String == \"1\" ||\n infoDictionary?[\"LSUIElement\"] as? Bool == true\n }\n\n var iconPath: String {\n let iconFile = infoDictionary?[\"CFBundleIconFile\"] as? String\n ?? infoDictionary?[\"CFBundleIconName\"] as? String\n ?? \"AppIcon\"\n\n return bundleURL\n .appendingPathComponent(\"Contents\")\n .appendingPathComponent(\"Resources\")\n .appendingPathComponent(iconFile.hasSuffix(\".icns\") ? iconFile : \"\\(iconFile).icns\")\n .path(percentEncoded: false)\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Open/OpenAppCommand.swift", "//\n// OpenAppCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport ArgumentParser\nimport Foundation\n\nstruct OpenAppCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"open\",\n abstract: \"Open FlashSpace\"\n )\n\n func run() throws {\n let url = NSWorkspace.shared.urlForApplication(withBundleIdentifier: \"pl.wojciechkulik.FlashSpace.dev\")\n ?? NSWorkspace.shared.urlForApplication(withBundleIdentifier: \"pl.wojciechkulik.FlashSpace\")\n\n if let url {\n let config = NSWorkspace.OpenConfiguration()\n config.activates = true\n NSWorkspace.shared.openApplication(at: url, configuration: config) { _, error in\n if let error {\n Self.exit(withError: CommandError.operationFailed(\"Failed to open FlashSpace: \\(error.localizedDescription)\"))\n } else {\n Self.exit()\n }\n }\n runWithTimeout()\n } else {\n throw CommandError.operationFailed(\"FlashSpace is not installed.\")\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/App/FlashSpaceApp.swift", "//\n// FlashSpaceApp.swift\n// FlashSpace\n//\n// Created by Wojciech Kulik on 19/01/2025.\n//\n\nimport SwiftUI\n\n@main\nstruct FlashSpaceApp: App {\n @NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate\n\n var body: some Scene {\n Window(\"⚡ FlashSpace v\\(AppConstants.version)\", id: \"main\") {\n MainView()\n }\n .windowResizability(.contentSize)\n\n Window(\"Settings\", id: \"settings\") {\n SettingsView()\n }\n .windowResizability(.contentSize)\n\n FlashSpaceMenuBar()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Models/CommandRequest.swift", "//\n// CommandRequest.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nenum CommandRequest: Codable {\n case createWorkspace(CreateWorkspaceRequest)\n case deleteWorkspace(name: String)\n case updateWorkspace(UpdateWorkspaceRequest)\n case activateWorkspace(name: String?, number: Int?, clean: Bool)\n case nextWorkspace(skipEmpty: Bool, clean: Bool, loop: Bool)\n case previousWorkspace(skipEmpty: Bool, clean: Bool, loop: Bool)\n case hideUnassignedApps\n case recentWorkspace(clean: Bool)\n\n case assignVisibleApps(workspaceName: String?, showNotification: Bool)\n case assignApp(app: String?, workspaceName: String?, activate: Bool?, showNotification: Bool)\n case unassignApp(app: String?, showNotification: Bool)\n\n case floatApp(app: String?, showNotification: Bool)\n case unfloatApp(app: String?, showNotification: Bool)\n case toggleFloatApp(app: String?, showNotification: Bool)\n\n case focusWindow(direction: FocusDirection)\n case focusNextWindow\n case focusPreviousWindow\n case focusNextApp\n case focusPreviousApp\n\n case createProfile(name: String, copy: Bool, activate: Bool)\n case deleteProfile(name: String)\n case activateProfile(name: String)\n\n case openSpaceControl\n\n case listProfiles\n case listWorkspaces(withDisplay: Bool, profile: String?)\n case listApps(\n workspace: String,\n profile: String?,\n withBundleId: Bool,\n withIcon: Bool,\n onlyRunning: Bool\n )\n case listFloatingApps(withBundleId: Bool)\n\n case getProfile\n case getWorkspace(display: String?)\n case getApp(withWindowsCount: Bool)\n case getDisplay\n}\n\nenum FocusDirection: String, Codable, ExpressibleByArgument, CaseIterable {\n case left, right, up, down\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/General/GeneralSettings.swift", "//\n// GeneralSettings.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nfinal class GeneralSettings: ObservableObject {\n @Published var showFlashSpace: AppHotKey?\n @Published var showFloatingNotifications = true\n @Published var checkForUpdatesAutomatically = false {\n didSet { UpdatesManager.shared.autoCheckForUpdates = checkForUpdatesAutomatically }\n }\n\n private var observer: AnyCancellable?\n private let updateSubject = PassthroughSubject<(), Never>()\n\n init() { observe() }\n\n private func observe() {\n observer = Publishers.MergeMany(\n $showFlashSpace.settingsPublisher(),\n $checkForUpdatesAutomatically.settingsPublisher(),\n $showFloatingNotifications.settingsPublisher()\n )\n .receive(on: DispatchQueue.main)\n .sink { [weak self] in self?.updateSubject.send() }\n }\n}\n\nextension GeneralSettings: SettingsProtocol {\n var updatePublisher: AnyPublisher<(), Never> {\n updateSubject.eraseToAnyPublisher()\n }\n\n func load(from appSettings: AppSettings) {\n observer = nil\n showFlashSpace = appSettings.showFlashSpace\n checkForUpdatesAutomatically = appSettings.checkForUpdatesAutomatically ?? false\n showFloatingNotifications = appSettings.showFloatingNotifications ?? true\n observe()\n }\n\n func update(_ appSettings: inout AppSettings) {\n appSettings.showFlashSpace = showFlashSpace\n appSettings.checkForUpdatesAutomatically = checkForUpdatesAutomatically\n appSettings.showFloatingNotifications = showFloatingNotifications\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Models/CommandRequest.swift", "//\n// CommandRequest.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nenum CommandRequest: Codable {\n case createWorkspace(CreateWorkspaceRequest)\n case deleteWorkspace(name: String)\n case updateWorkspace(UpdateWorkspaceRequest)\n case activateWorkspace(name: String?, number: Int?, clean: Bool)\n case nextWorkspace(skipEmpty: Bool, clean: Bool, loop: Bool)\n case previousWorkspace(skipEmpty: Bool, clean: Bool, loop: Bool)\n case recentWorkspace(clean: Bool)\n\n case assignVisibleApps(workspaceName: String?, showNotification: Bool)\n case assignApp(app: String?, workspaceName: String?, activate: Bool?, showNotification: Bool)\n case unassignApp(app: String?, showNotification: Bool)\n case hideUnassignedApps\n\n case floatApp(app: String?, showNotification: Bool)\n case unfloatApp(app: String?, showNotification: Bool)\n case toggleFloatApp(app: String?, showNotification: Bool)\n\n case focusWindow(direction: FocusDirection)\n case focusNextWindow\n case focusPreviousWindow\n case focusNextApp\n case focusPreviousApp\n\n case createProfile(name: String, copy: Bool, activate: Bool)\n case deleteProfile(name: String)\n case activateProfile(name: String)\n\n case openSpaceControl\n\n case listProfiles\n case listWorkspaces(withDisplay: Bool, profile: String?)\n case listApps(\n workspace: String,\n profile: String?,\n withBundleId: Bool,\n withIcon: Bool,\n onlyRunning: Bool\n )\n case listFloatingApps(withBundleId: Bool)\n\n case getProfile\n case getWorkspace(display: String?)\n case getApp(withWindowsCount: Bool)\n case getDisplay\n}\n\nenum FocusDirection: String, Codable {\n case left, right, up, down\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/FocusManager/FocusManagerSettings.swift", "//\n// FocusManagerSettings.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nfinal class FocusManagerSettings: ObservableObject {\n @Published var enableFocusManagement = false\n @Published var centerCursorOnFocusChange = false\n\n @Published var focusLeft: AppHotKey?\n @Published var focusRight: AppHotKey?\n @Published var focusUp: AppHotKey?\n @Published var focusDown: AppHotKey?\n @Published var focusNextWorkspaceApp: AppHotKey?\n @Published var focusPreviousWorkspaceApp: AppHotKey?\n @Published var focusNextWorkspaceWindow: AppHotKey?\n @Published var focusPreviousWorkspaceWindow: AppHotKey?\n @Published var focusFrontmostWindow = false\n\n private var observer: AnyCancellable?\n private let updateSubject = PassthroughSubject<(), Never>()\n\n init() { observe() }\n\n private func observe() {\n observer = Publishers.MergeMany(\n $enableFocusManagement.settingsPublisher(),\n $centerCursorOnFocusChange.settingsPublisher(),\n $focusLeft.settingsPublisher(),\n $focusRight.settingsPublisher(),\n $focusUp.settingsPublisher(),\n $focusDown.settingsPublisher(),\n $focusNextWorkspaceApp.settingsPublisher(),\n $focusPreviousWorkspaceApp.settingsPublisher(),\n $focusNextWorkspaceWindow.settingsPublisher(),\n $focusPreviousWorkspaceWindow.settingsPublisher(),\n $focusFrontmostWindow.settingsPublisher()\n )\n .receive(on: DispatchQueue.main)\n .sink { [weak self] in self?.updateSubject.send() }\n }\n}\n\nextension FocusManagerSettings: SettingsProtocol {\n var updatePublisher: AnyPublisher<(), Never> {\n updateSubject.eraseToAnyPublisher()\n }\n\n func load(from appSettings: AppSettings) {\n observer = nil\n enableFocusManagement = appSettings.enableFocusManagement ?? false\n centerCursorOnFocusChange = appSettings.centerCursorOnFocusChange ?? false\n focusLeft = appSettings.focusLeft\n focusRight = appSettings.focusRight\n focusUp = appSettings.focusUp\n focusDown = appSettings.focusDown\n focusNextWorkspaceApp = appSettings.focusNextWorkspaceApp\n focusPreviousWorkspaceApp = appSettings.focusPreviousWorkspaceApp\n focusNextWorkspaceWindow = appSettings.focusNextWorkspaceWindow\n focusPreviousWorkspaceWindow = appSettings.focusPreviousWorkspaceWindow\n focusFrontmostWindow = appSettings.focusFrontmostWindow ?? false\n observe()\n }\n\n func update(_ appSettings: inout AppSettings) {\n appSettings.enableFocusManagement = enableFocusManagement\n appSettings.centerCursorOnFocusChange = centerCursorOnFocusChange\n appSettings.focusLeft = focusLeft\n appSettings.focusRight = focusRight\n appSettings.focusUp = focusUp\n appSettings.focusDown = focusDown\n appSettings.focusNextWorkspaceApp = focusNextWorkspaceApp\n appSettings.focusPreviousWorkspaceApp = focusPreviousWorkspaceApp\n appSettings.focusNextWorkspaceWindow = focusNextWorkspaceWindow\n appSettings.focusPreviousWorkspaceWindow = focusPreviousWorkspaceWindow\n appSettings.focusFrontmostWindow = focusFrontmostWindow\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Commands/FocusCommands.swift", "//\n// FocusCommands.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nfinal class FocusCommands: CommandExecutor {\n var focusManager: FocusManager { AppDependencies.shared.focusManager }\n\n func execute(command: CommandRequest) -> CommandResponse? {\n switch command {\n case .focusWindow(let direction):\n switch direction {\n case .left: focusManager.focusLeft()\n case .right: focusManager.focusRight()\n case .up: focusManager.focusUp()\n case .down: focusManager.focusDown()\n }\n return CommandResponse(success: true)\n\n case .focusNextApp:\n focusManager.nextWorkspaceApp()\n return CommandResponse(success: true)\n\n case .focusPreviousApp:\n focusManager.previousWorkspaceApp()\n return CommandResponse(success: true)\n\n case .focusNextWindow:\n focusManager.nextWorkspaceWindow()\n return CommandResponse(success: true)\n\n case .focusPreviousWindow:\n focusManager.previousWorkspaceWindow()\n return CommandResponse(success: true)\n\n default:\n return nil\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/App/AppDependencies.swift", "//\n// AppDependencies.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ShortcutRecorder\n\nstruct AppDependencies {\n static let shared = AppDependencies()\n\n let displayManager: DisplayManager\n let workspaceRepository: WorkspaceRepository\n let workspaceManager: WorkspaceManager\n let workspaceHotKeys: WorkspaceHotKeys\n let workspaceScreenshotManager = WorkspaceScreenshotManager()\n let workspaceTransitionManager: WorkspaceTransitionManager\n let pictureInPictureManager: PictureInPictureManager\n\n let floatingAppsHotKeys: FloatingAppsHotKeys\n\n let hotKeysMonitor: HotKeysMonitorProtocol = GlobalShortcutMonitor.shared\n let hotKeysManager: HotKeysManager\n\n let focusManager: FocusManager\n let focusedWindowTracker: FocusedWindowTracker\n\n let settingsRepository: SettingsRepository\n let generalSettings = GeneralSettings()\n let menuBarSettings = MenuBarSettings()\n let gesturesSettings = GesturesSettings()\n let focusManagerSettings = FocusManagerSettings()\n let workspaceSettings = WorkspaceSettings()\n let floatingAppsSettings = FloatingAppsSettings()\n let spaceControlSettings = SpaceControlSettings()\n let integrationsSettings = IntegrationsSettings()\n\n let profilesRepository: ProfilesRepository\n let autostartService = AutostartService()\n let cliServer = CLIServer()\n\n // swiftlint:disable:next function_body_length\n private init() {\n self.settingsRepository = SettingsRepository(\n generalSettings: generalSettings,\n menuBarSettings: menuBarSettings,\n gesturesSettings: gesturesSettings,\n focusManagerSettings: focusManagerSettings,\n workspaceSettings: workspaceSettings,\n floatingAppsSettings: floatingAppsSettings,\n spaceControlSettings: spaceControlSettings,\n integrationsSettings: integrationsSettings\n )\n self.displayManager = DisplayManager(settingsRepository: settingsRepository)\n self.workspaceTransitionManager = WorkspaceTransitionManager(\n workspaceSettings: workspaceSettings\n )\n self.pictureInPictureManager = PictureInPictureManager(\n settingsRepository: settingsRepository\n )\n self.profilesRepository = ProfilesRepository()\n self.workspaceRepository = WorkspaceRepository(\n profilesRepository: profilesRepository\n )\n self.workspaceManager = WorkspaceManager(\n workspaceRepository: workspaceRepository,\n settingsRepository: settingsRepository,\n pictureInPictureManager: pictureInPictureManager,\n workspaceTransitionManager: workspaceTransitionManager,\n displayManager: displayManager\n )\n self.workspaceHotKeys = WorkspaceHotKeys(\n workspaceManager: workspaceManager,\n workspaceRepository: workspaceRepository,\n settingsRepository: settingsRepository\n )\n self.floatingAppsHotKeys = FloatingAppsHotKeys(\n workspaceManager: workspaceManager,\n settingsRepository: settingsRepository\n )\n self.focusManager = FocusManager(\n workspaceRepository: workspaceRepository,\n workspaceManager: workspaceManager,\n focusManagerSettings: focusManagerSettings,\n floatingAppsSettings: floatingAppsSettings\n )\n self.hotKeysManager = HotKeysManager(\n hotKeysMonitor: GlobalShortcutMonitor.shared,\n workspaceHotKeys: workspaceHotKeys,\n floatingAppsHotKeys: floatingAppsHotKeys,\n focusManager: focusManager,\n settingsRepository: settingsRepository\n )\n self.focusedWindowTracker = FocusedWindowTracker(\n workspaceRepository: workspaceRepository,\n workspaceManager: workspaceManager,\n settingsRepository: settingsRepository,\n pictureInPictureManager: pictureInPictureManager\n )\n\n Migrations.migrateIfNeeded(\n settingsRepository: settingsRepository,\n profilesRepository: profilesRepository\n )\n\n focusedWindowTracker.startTracking()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/PictureInPicture/Extensions/AXUIElement+PiP.swift", "//\n// AXUIElement+PiP.swift\n//\n// Created by Wojciech Kulik on 12/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension AXUIElement {\n private var pipApps: [PipApp] {\n AppDependencies.shared.workspaceSettings.pipApps\n }\n\n func isPictureInPicture(bundleId: String?) -> Bool {\n if let browser = PipBrowser(rawValue: bundleId ?? \"\") {\n if let partialTitle = browser.partialTitle,\n title?.contains(partialTitle) == true {\n return true\n }\n\n if let pipWindowTitle = browser.title {\n return title == pipWindowTitle\n } else if let pipWindowSubrole = browser.subrole {\n return subrole == pipWindowSubrole\n }\n } else if let pipApp = pipApps.first(where: { $0.bundleIdentifier == bundleId }) {\n let result = title?.range(\n of: pipApp.pipWindowTitleRegex,\n options: .regularExpression\n ) != nil\n\n return result\n }\n\n return false\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/PictureInPicture/Models/PipBrowser.swift", "//\n// PipBrowser.swift\n//\n// Created by Wojciech Kulik on 12/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\n/// Browser apps that support Picture in Picture\nenum PipBrowser: String, CaseIterable {\n case chrome = \"com.google.Chrome\"\n case vivaldi = \"com.vivaldi.Vivaldi\"\n case brave = \"com.brave.Browser\"\n case opera = \"com.operasoftware.Opera\"\n case firefox = \"org.mozilla.firefox\"\n case zen = \"app.zen-browser.zen\"\n case arc = \"company.thebrowser.Browser\"\n case dia = \"company.thebrowser.dia\"\n case comet = \"ai.perplexity.comet\"\n\n var bundleId: String { rawValue }\n\n var title: String? {\n switch self {\n case .chrome, .vivaldi, .brave, .opera, .comet:\n return \"Picture in Picture\"\n case .zen, .firefox:\n return \"Picture-in-Picture\"\n case .arc, .dia:\n return nil\n }\n }\n\n var partialTitle: String? {\n switch self {\n case .chrome:\n return \"about:blank \"\n default:\n return nil\n }\n }\n\n var subrole: String? {\n switch self {\n case .arc, .dia:\n return (NSAccessibility.Subrole.systemDialog as CFString) as String\n default:\n return nil\n }\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/List/ListAppsCommand.swift", "//\n// ListAppsCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct ListAppsCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"list-apps\",\n abstract: \"List workspace apps\"\n )\n\n @Argument(help: \"Workspace name\")\n var workspace: String\n\n @Option(help: \"Profile name\")\n var profile: String?\n\n @Flag(help: \"Include bundle id\")\n var withBundleId = false\n\n @Flag(help: \"Include icon\")\n var withIcon = false\n\n @Flag(help: \"Only running apps\")\n var onlyRunning = false\n\n func run() throws {\n sendCommand(.listApps(\n workspace: workspace,\n profile: profile,\n withBundleId: withBundleId,\n withIcon: withIcon,\n onlyRunning: onlyRunning\n ))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/App/UnassignAppCommand.swift", "//\n// UnassignAppCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct UnassignAppCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"unassign-app\",\n abstract: \"Unassign an app from all workspaces\"\n )\n @Option(help: .init(\n \"The name of the app or bundle id. If not provided, the active app will be unassigned. Default: active app.\",\n valueName: \"name|bundle id\"\n ))\n var name: String?\n\n @Flag(help: \"Show toast notification\")\n var showNotification = false\n\n func run() throws {\n sendCommand(.unassignApp(app: name, showNotification: showNotification))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/FocusManager/Models/MacAppWithWindows.swift", "//\n// MacAppWithWindows.swift\n//\n// Created by Wojciech Kulik on 04/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport CoreGraphics\n\nstruct MacAppWithWindows {\n struct MacAppWindow {\n let frame: CGRect\n let title: String\n let axWindow: AXUIElement\n }\n\n let app: NSRunningApplication\n let bundleIdentifier: BundleId\n\n /// Sorted by title and then by x position\n let windows: [MacAppWindow]\n\n init(app: NSRunningApplication) {\n self.app = app\n self.bundleIdentifier = app.bundleIdentifier ?? \"\"\n self.windows = app.allWindows\n .map { MacAppWindow(frame: $0.frame, title: $0.window.title ?? \"\", axWindow: $0.window) }\n .sorted { $0.title < $1.title || $0.title == $1.title && $0.frame.minX < $1.frame.minX }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Config/Models/YAMLCoding.swift", "//\n// YAMLCoding.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\nimport Yams\n\nextension YAMLEncoder: ConfigEncoder {\n func encode(_ value: some Encodable) throws -> Data {\n let yaml: String = try encode(value)\n return yaml.data(using: .utf8) ?? Data()\n }\n}\n\nextension YAMLDecoder: ConfigDecoder {}\n"], ["/FlashSpace/FlashSpace/Accessibility/System.swift", "//\n// System.swift\n//\n// Created by Wojciech Kulik on 01/05/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nstruct AppWindow {\n let name: String\n let pid: pid_t\n}\n\nenum System {\n static var orderedWindows: [AppWindow] {\n let list = CGWindowListCopyWindowInfo(.optionOnScreenOnly, kCGNullWindowID) as? [[String: Any]]\n guard let list else { return [] }\n\n return list.compactMap {\n let windowName = $0[kCGWindowName as String] as? String\n let windowOwnerPID = $0[kCGWindowOwnerPID as String] as? pid_t\n if let windowOwnerPID {\n return AppWindow(name: windowName ?? \"-\", pid: windowOwnerPID)\n } else {\n return nil\n }\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Workspaces/Models/MacAppWithWorkspace.swift", "//\n// MacAppWithWorkspace.swift\n//\n// Created by Wojciech Kulik on 20/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\nimport SwiftUI\n\nstruct MacAppWithWorkspace: Hashable, Codable {\n var app: MacApp\n var workspaceId: WorkspaceID\n}\n\nextension MacAppWithWorkspace: Transferable {\n static var transferRepresentation: some TransferRepresentation {\n CodableRepresentation(for: MacAppWithWorkspace.self, contentType: .json)\n }\n}\n"], ["/FlashSpace/FlashSpace/Utils/AutostartService.swift", "//\n// AutostartService.swift\n//\n// Created by Wojciech Kulik on 20/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ServiceManagement\n\nfinal class AutostartService {\n var isLaunchAtLoginEnabled: Bool { SMAppService.mainApp.status == .enabled }\n\n func enableLaunchAtLogin() {\n do {\n if SMAppService.mainApp.status == .enabled {\n try SMAppService.mainApp.unregister()\n }\n\n try SMAppService.mainApp.register()\n } catch {\n Logger.log(\"Failed to enable launch at login: \\(error)\")\n }\n }\n\n func disableLaunchAtLogin() {\n do {\n try SMAppService.mainApp.unregister()\n } catch {\n Logger.log(\"Failed to disable launch at login: \\(error)\")\n }\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Models/CommandError.swift", "//\n// CommandError.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nenum CommandError: Error, LocalizedError {\n case timeout\n case connectionError(Error)\n case emptyResponse\n case couldNotEncode(Error)\n case operationFailed(String)\n case missingArgument\n case other\n\n var errorDescription: String? {\n switch self {\n case .timeout:\n return \"Timeout. Please check if FlashSpace is running.\"\n case .connectionError(let error):\n return \"Connection error. Please check if FlashSpace is running.\\n\\(error)\"\n case .emptyResponse:\n return \"Empty response. Please check if FlashSpace is running.\"\n case .couldNotEncode(let error):\n return \"Could not encode the message. Please try again.\\n\\(error)\"\n case .operationFailed(let message):\n return message\n case .missingArgument:\n return \"Missing argument(s). Please provide the required argument(s).\"\n case .other:\n return \"\"\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/HotKeys/Extensions/AppHotKey+KeyboardShortcut.swift", "//\n// AppHotKey+KeyboardShortcut.swift\n//\n// Created by Wojciech Kulik on 31/05/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nextension AppHotKey {\n var toKeyboardShortcut: KeyboardShortcut? {\n let components = value.components(separatedBy: \"+\")\n let modifiers = toEventModifiers(value)\n\n guard let key = components.last,\n let keyEquivalent = stringToKeyEquivalent(key) else { return nil }\n\n return KeyboardShortcut(\n keyEquivalent,\n modifiers: modifiers\n )\n }\n\n // swiftlint:disable:next cyclomatic_complexity\n private func stringToKeyEquivalent(_ value: String) -> KeyEquivalent? {\n guard value.count > 1 else { return KeyEquivalent(Character(value)) }\n\n switch value {\n case \"esc\", \"escape\": return KeyEquivalent.escape\n case \"return\", \"enter\": return KeyEquivalent.return\n case \"tab\": return KeyEquivalent.tab\n case \"space\": return KeyEquivalent.space\n case \"delete\", \"backspace\": return KeyEquivalent.delete\n case \"up\": return KeyEquivalent.upArrow\n case \"down\": return KeyEquivalent.downArrow\n case \"left\": return KeyEquivalent.leftArrow\n case \"right\": return KeyEquivalent.rightArrow\n case \"home\": return KeyEquivalent.home\n case \"end\": return KeyEquivalent.end\n default: return nil\n }\n }\n\n private func toEventModifiers(_ value: String) -> EventModifiers {\n let flags = value.lowercased().split(separator: \"+\").map { String($0) }\n var result: EventModifiers = []\n\n if flags.contains(\"cmd\") { result.insert(.command) }\n if flags.contains(\"ctrl\") { result.insert(.control) }\n if flags.contains(\"opt\") { result.insert(.option) }\n if flags.contains(\"shift\") { result.insert(.shift) }\n\n return result\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Acknowledgements/Licenses.swift", "//\n// Licenses.swift\n//\n// Created by Wojciech Kulik on 26/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nenum Licenses {\n static let swiftFormat = \"\"\"\n SwiftFormat\n\n Authors: Nick Lockwood\n Project URL: https://github.com/nicklockwood/SwiftFormat\n License URL: https://github.com/nicklockwood/SwiftFormat/blob/main/LICENSE.md\n\n MIT License\n\n Copyright (c) 2016 Nick Lockwood\n\n Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n \"\"\"\n\n static let swiftLint = \"\"\"\n SwiftLint\n\n Authors: The SwiftLint Contributors\n Project URL: https://github.com/realm/SwiftLint/\n License URL: https://github.com/realm/SwiftLint/blob/master/LICENSE\n\n The MIT License (MIT)\n\n Copyright (c) 2025 The SwiftLint Contributors.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n \"\"\"\n\n static let symbolPicker = \"\"\"\n SymbolPicker\n\n Authors: Yubo Qin & Lakr Aream\n Project URL: https://github.com/xnth97/SymbolPicker\n License URL: https://github.com/xnth97/SymbolPicker/blob/main/LICENSE\n\n MIT License\n\n Copyright (c) 2022 Yubo Qin & Lakr Aream\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n \"\"\"\n\n static let shortcutRecorder = \"\"\"\n ShortcutRecorder\n\n Authors: Contributors\n Project URL: https://github.com/Kentzo/ShortcutRecorder\n License URL: https://github.com/Kentzo/ShortcutRecorder/blob/master/LICENSE.txt\n\n Creative Commons Attribution 4.0 International Public License\n\n By exercising the Licensed Rights (defined below), You accept and agree\n to be bound by the terms and conditions of this Creative Commons\n Attribution 4.0 International Public License (\"Public License\"). To the\n extent this Public License may be interpreted as a contract, You are\n granted the Licensed Rights in consideration of Your acceptance of\n these terms and conditions, and the Licensor grants You such rights in\n consideration of benefits the Licensor receives from making the\n Licensed Material available under these terms and conditions.\n\n\n Section 1 -- Definitions.\n\n a. Adapted Material means material subject to Copyright and Similar\n Rights that is derived from or based upon the Licensed Material\n and in which the Licensed Material is translated, altered,\n arranged, transformed, or otherwise modified in a manner requiring\n permission under the Copyright and Similar Rights held by the\n Licensor. For purposes of this Public License, where the Licensed\n Material is a musical work, performance, or sound recording,\n Adapted Material is always produced where the Licensed Material is\n synched in timed relation with a moving image.\n\n b. Adapter's License means the license You apply to Your Copyright\n and Similar Rights in Your contributions to Adapted Material in\n accordance with the terms and conditions of this Public License.\n\n c. Copyright and Similar Rights means copyright and/or similar rights\n closely related to copyright including, without limitation,\n performance, broadcast, sound recording, and Sui Generis Database\n Rights, without regard to how the rights are labeled or\n categorized. For purposes of this Public License, the rights\n specified in Section 2(b)(1)-(2) are not Copyright and Similar\n Rights.\n\n d. Effective Technological Measures means those measures that, in the\n absence of proper authority, may not be circumvented under laws\n fulfilling obligations under Article 11 of the WIPO Copyright\n Treaty adopted on December 20, 1996, and/or similar international\n agreements.\n\n e. Exceptions and Limitations means fair use, fair dealing, and/or\n any other exception or limitation to Copyright and Similar Rights\n that applies to Your use of the Licensed Material.\n\n f. Licensed Material means the artistic or literary work, database,\n or other material to which the Licensor applied this Public\n License.\n\n g. Licensed Rights means the rights granted to You subject to the\n terms and conditions of this Public License, which are limited to\n all Copyright and Similar Rights that apply to Your use of the\n Licensed Material and that the Licensor has authority to license.\n\n h. Licensor means the individual(s) or entity(ies) granting rights\n under this Public License.\n\n i. Share means to provide material to the public by any means or\n process that requires permission under the Licensed Rights, such\n as reproduction, public display, public performance, distribution,\n dissemination, communication, or importation, and to make material\n available to the public including in ways that members of the\n public may access the material from a place and at a time\n individually chosen by them.\n\n j. Sui Generis Database Rights means rights other than copyright\n resulting from Directive 96/9/EC of the European Parliament and of\n the Council of 11 March 1996 on the legal protection of databases,\n as amended and/or succeeded, as well as other essentially\n equivalent rights anywhere in the world.\n\n k. You means the individual or entity exercising the Licensed Rights\n under this Public License. Your has a corresponding meaning.\n\n\n Section 2 -- Scope.\n\n a. License grant.\n\n 1. Subject to the terms and conditions of this Public License,\n the Licensor hereby grants You a worldwide, royalty-free,\n non-sublicensable, non-exclusive, irrevocable license to\n exercise the Licensed Rights in the Licensed Material to:\n\n a. reproduce and Share the Licensed Material, in whole or\n in part; and\n\n b. produce, reproduce, and Share Adapted Material.\n\n 2. Exceptions and Limitations. For the avoidance of doubt, where\n Exceptions and Limitations apply to Your use, this Public\n License does not apply, and You do not need to comply with\n its terms and conditions.\n\n 3. Term. The term of this Public License is specified in Section\n 6(a).\n\n 4. Media and formats; technical modifications allowed. The\n Licensor authorizes You to exercise the Licensed Rights in\n all media and formats whether now known or hereafter created,\n and to make technical modifications necessary to do so. The\n Licensor waives and/or agrees not to assert any right or\n authority to forbid You from making technical modifications\n necessary to exercise the Licensed Rights, including\n technical modifications necessary to circumvent Effective\n Technological Measures. For purposes of this Public License,\n simply making modifications authorized by this Section 2(a)\n (4) never produces Adapted Material.\n\n 5. Downstream recipients.\n\n a. Offer from the Licensor -- Licensed Material. Every\n recipient of the Licensed Material automatically\n receives an offer from the Licensor to exercise the\n Licensed Rights under the terms and conditions of this\n Public License.\n\n b. No downstream restrictions. You may not offer or impose\n any additional or different terms or conditions on, or\n apply any Effective Technological Measures to, the\n Licensed Material if doing so restricts exercise of the\n Licensed Rights by any recipient of the Licensed\n Material.\n\n 6. No endorsement. Nothing in this Public License constitutes or\n may be construed as permission to assert or imply that You\n are, or that Your use of the Licensed Material is, connected\n with, or sponsored, endorsed, or granted official status by,\n the Licensor or others designated to receive attribution as\n provided in Section 3(a)(1)(A)(i).\n\n b. Other rights.\n\n 1. Moral rights, such as the right of integrity, are not\n licensed under this Public License, nor are publicity,\n privacy, and/or other similar personality rights; however, to\n the extent possible, the Licensor waives and/or agrees not to\n assert any such rights held by the Licensor to the limited\n extent necessary to allow You to exercise the Licensed\n Rights, but not otherwise.\n\n 2. Patent and trademark rights are not licensed under this\n Public License.\n\n 3. To the extent possible, the Licensor waives any right to\n collect royalties from You for the exercise of the Licensed\n Rights, whether directly or through a collecting society\n under any voluntary or waivable statutory or compulsory\n licensing scheme. In all other cases the Licensor expressly\n reserves any right to collect such royalties.\n\n\n Section 3 -- License Conditions.\n\n Your exercise of the Licensed Rights is expressly made subject to the\n following conditions.\n\n a. Attribution.\n\n 1. If You Share the Licensed Material (including in modified\n form), You must:\n\n a. retain the following if it is supplied by the Licensor\n with the Licensed Material:\n\n i. identification of the creator(s) of the Licensed\n Material and any others designated to receive\n attribution, in any reasonable manner requested by\n the Licensor (including by pseudonym if\n designated);\n\n ii. a copyright notice;\n\n iii. a notice that refers to this Public License;\n\n iv. a notice that refers to the disclaimer of\n warranties;\n\n v. a URI or hyperlink to the Licensed Material to the\n extent reasonably practicable;\n\n b. indicate if You modified the Licensed Material and\n retain an indication of any previous modifications; and\n\n c. indicate the Licensed Material is licensed under this\n Public License, and include the text of, or the URI or\n hyperlink to, this Public License.\n\n 2. You may satisfy the conditions in Section 3(a)(1) in any\n reasonable manner based on the medium, means, and context in\n which You Share the Licensed Material. For example, it may be\n reasonable to satisfy the conditions by providing a URI or\n hyperlink to a resource that includes the required\n information.\n\n 3. If requested by the Licensor, You must remove any of the\n information required by Section 3(a)(1)(A) to the extent\n reasonably practicable.\n\n 4. If You Share Adapted Material You produce, the Adapter's\n License You apply must not prevent recipients of the Adapted\n Material from complying with this Public License.\n\n\n Section 4 -- Sui Generis Database Rights.\n\n Where the Licensed Rights include Sui Generis Database Rights that\n apply to Your use of the Licensed Material:\n\n a. for the avoidance of doubt, Section 2(a)(1) grants You the right\n to extract, reuse, reproduce, and Share all or a substantial\n portion of the contents of the database;\n\n b. if You include all or a substantial portion of the database\n contents in a database in which You have Sui Generis Database\n Rights, then the database in which You have Sui Generis Database\n Rights (but not its individual contents) is Adapted Material; and\n\n c. You must comply with the conditions in Section 3(a) if You Share\n all or a substantial portion of the contents of the database.\n\n For the avoidance of doubt, this Section 4 supplements and does not\n replace Your obligations under this Public License where the Licensed\n Rights include other Copyright and Similar Rights.\n\n\n Section 5 -- Disclaimer of Warranties and Limitation of Liability.\n\n a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE\n EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS\n AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF\n ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,\n IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,\n WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR\n PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,\n ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT\n KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT\n ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.\n\n b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE\n TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,\n NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,\n INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,\n COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR\n USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN\n ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR\n DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR\n IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.\n\n c. The disclaimer of warranties and limitation of liability provided\n above shall be interpreted in a manner that, to the extent\n possible, most closely approximates an absolute disclaimer and\n waiver of all liability.\n\n\n Section 6 -- Term and Termination.\n\n a. This Public License applies for the term of the Copyright and\n Similar Rights licensed here. However, if You fail to comply with\n this Public License, then Your rights under this Public License\n terminate automatically.\n\n b. Where Your right to use the Licensed Material has terminated under\n Section 6(a), it reinstates:\n\n 1. automatically as of the date the violation is cured, provided\n it is cured within 30 days of Your discovery of the\n violation; or\n\n 2. upon express reinstatement by the Licensor.\n\n For the avoidance of doubt, this Section 6(b) does not affect any\n right the Licensor may have to seek remedies for Your violations\n of this Public License.\n\n c. For the avoidance of doubt, the Licensor may also offer the\n Licensed Material under separate terms or conditions or stop\n distributing the Licensed Material at any time; however, doing so\n will not terminate this Public License.\n\n d. Sections 1, 5, 6, 7, and 8 survive termination of this Public\n License.\n\n\n Section 7 -- Other Terms and Conditions.\n\n a. The Licensor shall not be bound by any additional or different\n terms or conditions communicated by You unless expressly agreed.\n\n b. Any arrangements, understandings, or agreements regarding the\n Licensed Material not stated herein are separate from and\n independent of the terms and conditions of this Public License.\n\n\n Section 8 -- Interpretation.\n\n a. For the avoidance of doubt, this Public License does not, and\n shall not be interpreted to, reduce, limit, restrict, or impose\n conditions on any use of the Licensed Material that could lawfully\n be made without permission under this Public License.\n\n b. To the extent possible, if any provision of this Public License is\n deemed unenforceable, it shall be automatically reformed to the\n minimum extent necessary to make it enforceable. If the provision\n cannot be reformed, it shall be severed from this Public License\n without affecting the enforceability of the remaining terms and\n conditions.\n\n c. No term or condition of this Public License will be waived and no\n failure to comply consented to unless expressly agreed to by the\n Licensor.\n\n d. Nothing in this Public License constitutes or may be interpreted\n as a limitation upon, or waiver of, any privileges and immunities\n that apply to the Licensor or You, including from the legal\n processes of any jurisdiction or authority.\n\n\n =======================================================================\n\n Creative Commons is not a party to its public\n licenses. Notwithstanding, Creative Commons may elect to apply one of\n its public licenses to material it publishes and in those instances\n will be considered the “Licensor.” The text of the Creative Commons\n public licenses is dedicated to the public domain under the CC0 Public\n Domain Dedication. Except for the limited purpose of indicating that\n material is shared under a Creative Commons public license or as\n otherwise permitted by the Creative Commons policies published at\n creativecommons.org/policies, Creative Commons does not authorize the\n use of the trademark \"Creative Commons\" or any other trademark or logo\n of Creative Commons without its prior written consent including,\n without limitation, in connection with any unauthorized modifications\n to any of its public licenses or any other arrangements,\n understandings, or agreements concerning use of licensed material. For\n the avoidance of doubt, this paragraph does not form part of the\n public licenses.\n \"\"\"\n\n static let yams = \"\"\"\n Yams\n\n Authors: JP Simard\n Project URL: https://github.com/jpsim/Yams\n License URL: https://github.com/jpsim/Yams/blob/main/LICENSE\n\n The MIT License (MIT)\n\n Copyright (c) 2016 JP Simard.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n \"\"\"\n\n static let tomlKit = \"\"\"\n TOMLKit\n\n Authors: Jeff Lebrun\n Project URL: https://github.com/LebJe/TOMLKit\n License URL: https://github.com/LebJe/TOMLKit/blob/main/LICENSE\n\n MIT License\n\n Copyright (c) 2024 Jeff Lebrun\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n \"\"\"\n\n static let swiftArgumentParser = \"\"\"\n Swift Argument Parser\n\n Authors: Apple\n Project URL: https://github.com/apple/swift-argument-parser\n License URL: https://github.com/apple/swift-argument-parser/blob/main/LICENSE.txt\n\n Apache License\n Version 2.0, January 2004\n http://www.apache.org/licenses/\n\n TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n 1. Definitions.\n\n \"License\" shall mean the terms and conditions for use, reproduction,\n and distribution as defined by Sections 1 through 9 of this document.\n\n \"Licensor\" shall mean the copyright owner or entity authorized by\n the copyright owner that is granting the License.\n\n \"Legal Entity\" shall mean the union of the acting entity and all\n other entities that control, are controlled by, or are under common\n control with that entity. For the purposes of this definition,\n \"control\" means (i) the power, direct or indirect, to cause the\n direction or management of such entity, whether by contract or\n otherwise, or (ii) ownership of fifty percent (50%) or more of the\n outstanding shares, or (iii) beneficial ownership of such entity.\n\n \"You\" (or \"Your\") shall mean an individual or Legal Entity\n exercising permissions granted by this License.\n\n \"Source\" form shall mean the preferred form for making modifications,\n including but not limited to software source code, documentation\n source, and configuration files.\n\n \"Object\" form shall mean any form resulting from mechanical\n transformation or translation of a Source form, including but\n not limited to compiled object code, generated documentation,\n and conversions to other media types.\n\n \"Work\" shall mean the work of authorship, whether in Source or\n Object form, made available under the License, as indicated by a\n copyright notice that is included in or attached to the work\n (an example is provided in the Appendix below).\n\n \"Derivative Works\" shall mean any work, whether in Source or Object\n form, that is based on (or derived from) the Work and for which the\n editorial revisions, annotations, elaborations, or other modifications\n represent, as a whole, an original work of authorship. For the purposes\n of this License, Derivative Works shall not include works that remain\n separable from, or merely link (or bind by name) to the interfaces of,\n the Work and Derivative Works thereof.\n\n \"Contribution\" shall mean any work of authorship, including\n the original version of the Work and any modifications or additions\n to that Work or Derivative Works thereof, that is intentionally\n submitted to Licensor for inclusion in the Work by the copyright owner\n or by an individual or Legal Entity authorized to submit on behalf of\n the copyright owner. For the purposes of this definition, \"submitted\"\n means any form of electronic, verbal, or written communication sent\n to the Licensor or its representatives, including but not limited to\n communication on electronic mailing lists, source code control systems,\n and issue tracking systems that are managed by, or on behalf of, the\n Licensor for the purpose of discussing and improving the Work, but\n excluding communication that is conspicuously marked or otherwise\n designated in writing by the copyright owner as \"Not a Contribution.\"\n\n \"Contributor\" shall mean Licensor and any individual or Legal Entity\n on behalf of whom a Contribution has been received by Licensor and\n subsequently incorporated within the Work.\n\n 2. Grant of Copyright License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n copyright license to reproduce, prepare Derivative Works of,\n publicly display, publicly perform, sublicense, and distribute the\n Work and such Derivative Works in Source or Object form.\n\n 3. Grant of Patent License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n (except as stated in this section) patent license to make, have made,\n use, offer to sell, sell, import, and otherwise transfer the Work,\n where such license applies only to those patent claims licensable\n by such Contributor that are necessarily infringed by their\n Contribution(s) alone or by combination of their Contribution(s)\n with the Work to which such Contribution(s) was submitted. If You\n institute patent litigation against any entity (including a\n cross-claim or counterclaim in a lawsuit) alleging that the Work\n or a Contribution incorporated within the Work constitutes direct\n or contributory patent infringement, then any patent licenses\n granted to You under this License for that Work shall terminate\n as of the date such litigation is filed.\n\n 4. Redistribution. You may reproduce and distribute copies of the\n Work or Derivative Works thereof in any medium, with or without\n modifications, and in Source or Object form, provided that You\n meet the following conditions:\n\n (a) You must give any other recipients of the Work or\n Derivative Works a copy of this License; and\n\n (b) You must cause any modified files to carry prominent notices\n stating that You changed the files; and\n\n (c) You must retain, in the Source form of any Derivative Works\n that You distribute, all copyright, patent, trademark, and\n attribution notices from the Source form of the Work,\n excluding those notices that do not pertain to any part of\n the Derivative Works; and\n\n (d) If the Work includes a \"NOTICE\" text file as part of its\n distribution, then any Derivative Works that You distribute must\n include a readable copy of the attribution notices contained\n within such NOTICE file, excluding those notices that do not\n pertain to any part of the Derivative Works, in at least one\n of the following places: within a NOTICE text file distributed\n as part of the Derivative Works; within the Source form or\n documentation, if provided along with the Derivative Works; or,\n within a display generated by the Derivative Works, if and\n wherever such third-party notices normally appear. The contents\n of the NOTICE file are for informational purposes only and\n do not modify the License. You may add Your own attribution\n notices within Derivative Works that You distribute, alongside\n or as an addendum to the NOTICE text from the Work, provided\n that such additional attribution notices cannot be construed\n as modifying the License.\n\n You may add Your own copyright statement to Your modifications and\n may provide additional or different license terms and conditions\n for use, reproduction, or distribution of Your modifications, or\n for any such Derivative Works as a whole, provided Your use,\n reproduction, and distribution of the Work otherwise complies with\n the conditions stated in this License.\n\n 5. Submission of Contributions. Unless You explicitly state otherwise,\n any Contribution intentionally submitted for inclusion in the Work\n by You to the Licensor shall be under the terms and conditions of\n this License, without any additional terms or conditions.\n Notwithstanding the above, nothing herein shall supersede or modify\n the terms of any separate license agreement you may have executed\n with Licensor regarding such Contributions.\n\n 6. Trademarks. This License does not grant permission to use the trade\n names, trademarks, service marks, or product names of the Licensor,\n except as required for reasonable and customary use in describing the\n origin of the Work and reproducing the content of the NOTICE file.\n\n 7. Disclaimer of Warranty. Unless required by applicable law or\n agreed to in writing, Licensor provides the Work (and each\n Contributor provides its Contributions) on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n implied, including, without limitation, any warranties or conditions\n of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n PARTICULAR PURPOSE. You are solely responsible for determining the\n appropriateness of using or redistributing the Work and assume any\n risks associated with Your exercise of permissions under this License.\n\n 8. Limitation of Liability. In no event and under no legal theory,\n whether in tort (including negligence), contract, or otherwise,\n unless required by applicable law (such as deliberate and grossly\n negligent acts) or agreed to in writing, shall any Contributor be\n liable to You for damages, including any direct, indirect, special,\n incidental, or consequential damages of any character arising as a\n result of this License or out of the use or inability to use the\n Work (including but not limited to damages for loss of goodwill,\n work stoppage, computer failure or malfunction, or any and all\n other commercial damages or losses), even if such Contributor\n has been advised of the possibility of such damages.\n\n 9. Accepting Warranty or Additional Liability. While redistributing\n the Work or Derivative Works thereof, You may choose to offer,\n and charge a fee for, acceptance of support, warranty, indemnity,\n or other liability obligations and/or rights consistent with this\n License. However, in accepting such obligations, You may act only\n on Your own behalf and on Your sole responsibility, not on behalf\n of any other Contributor, and only if You agree to indemnify,\n defend, and hold each Contributor harmless for any liability\n incurred by, or claims asserted against, such Contributor by reason\n of your accepting any such warranty or additional liability.\n\n END OF TERMS AND CONDITIONS\n\n APPENDIX: How to apply the Apache License to your work.\n\n To apply the Apache License to your work, attach the following\n boilerplate notice, with the fields enclosed by brackets \"[]\"\n replaced with your own identifying information. (Don't include\n the brackets!) The text should be enclosed in the appropriate\n comment syntax for the file format. We also recommend that a\n file or class name and description of purpose be included on the\n same \"printed page\" as the copyright notice for easier\n identification within third-party archives.\n\n Copyright [yyyy] [name of copyright owner]\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n\n\n ## Runtime Library Exception to the Apache 2.0 License: ##\n\n\n As an exception, if you use this Software to compile your source code and\n portions of this Software are embedded into the binary product as a result,\n you may redistribute such product without providing attribution as would\n otherwise be required by Sections 4(a), 4(b) and 4(d) of the License.\n \"\"\"\n\n static let sparkle = \"\"\"\n Sparkle\n\n Copyright (c) 2006-2013 Andy Matuschak.\n Copyright (c) 2009-2013 Elgato Systems GmbH.\n Copyright (c) 2011-2014 Kornel Lesiński.\n Copyright (c) 2015-2017 Mayur Pawashe.\n Copyright (c) 2014 C.W. Betts.\n Copyright (c) 2014 Petroules Corporation.\n Copyright (c) 2014 Big Nerd Ranch.\n All rights reserved.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy of\n this software and associated documentation files (the \"Software\"), to deal in\n the Software without restriction, including without limitation the rights to\n use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\n the Software, and to permit persons to whom the Software is furnished to do so,\n subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\n FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\n COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\n IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n =================\n EXTERNAL LICENSES\n =================\n\n bspatch.c and bsdiff.c, from bsdiff 4.3 :\n\n Copyright 2003-2005 Colin Percival\n All rights reserved\n\n Redistribution and use in source and binary forms, with or without\n modification, are permitted providing that the following conditions \n are met:\n 1. Redistributions of source code must retain the above copyright\n notice, this list of conditions and the following disclaimer.\n 2. Redistributions in binary form must reproduce the above copyright\n notice, this list of conditions and the following disclaimer in the\n documentation and/or other materials provided with the distribution.\n\n THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR\n IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY\n DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING\n IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n POSSIBILITY OF SUCH DAMAGE.\n\n --\n\n sais.c and sais.h, from sais-lite (2010/08/07) :\n\n The sais-lite copyright is as follows:\n\n Copyright (c) 2008-2010 Yuta Mori All Rights Reserved.\n\n Permission is hereby granted, free of charge, to any person\n obtaining a copy of this software and associated documentation\n files (the \"Software\"), to deal in the Software without\n restriction, including without limitation the rights to use,\n copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the\n Software is furnished to do so, subject to the following\n conditions:\n\n The above copyright notice and this permission notice shall be\n included in all copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n OTHER DEALINGS IN THE SOFTWARE.\n\n --\n\n Portable C implementation of Ed25519, from https://github.com/orlp/ed25519\n\n Copyright (c) 2015 Orson Peters \n\n This software is provided 'as-is', without any express or implied warranty. In no event will the\n authors be held liable for any damages arising from the use of this software.\n\n Permission is granted to anyone to use this software for any purpose, including commercial\n applications, and to alter it and redistribute it freely, subject to the following restrictions:\n\n 1. The origin of this software must not be misrepresented; you must not claim that you wrote the\n original software. If you use this software in a product, an acknowledgment in the product\n documentation would be appreciated but is not required.\n\n 2. Altered source versions must be plainly marked as such, and must not be misrepresented as\n being the original software.\n\n 3. This notice may not be removed or altered from any source distribution.\n\n --\n\n SUSignatureVerifier.m:\n\n Copyright (c) 2011 Mark Hamlin.\n\n All rights reserved.\n\n Redistribution and use in source and binary forms, with or without\n modification, are permitted providing that the following conditions\n are met:\n 1. Redistributions of source code must retain the above copyright\n notice, this list of conditions and the following disclaimer.\n 2. Redistributions in binary form must reproduce the above copyright\n notice, this list of conditions and the following disclaimer in the\n documentation and/or other materials provided with the distribution.\n\n THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR\n IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY\n DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING\n IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n POSSIBILITY OF SUCH DAMAGE.\n \"\"\"\n}\n"], ["/FlashSpace/FlashSpace/Accessibility/AXUIElement+Actions.swift", "//\n// AXUIElement+Actions.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension AXUIElement {\n /// Position is in window coordinates where (0,0) is top-left corner\n /// and it is relative to the main screen.\n func setPosition(_ position: CGPoint) {\n var position = position\n let positionRef = AXValueCreate(.cgPoint, &position)\n setAttribute(.position, value: positionRef)\n }\n\n func focus() {\n AXUIElementPerformAction(self, NSAccessibility.Action.raise as CFString)\n }\n\n func minimize(_ minimized: Bool) {\n setAttribute(.minimized, value: minimized)\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Workspace/DeleteWorkspaceCommand.swift", "//\n// DeleteWorkspaceCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct DeleteWorkspaceCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"delete-workspace\",\n abstract: \"Delete a workspace\"\n )\n\n @Argument(help: \"The name of the workspace to delete.\")\n var name: String\n\n func run() throws {\n sendCommand(.deleteWorkspace(name: name))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Extensions/SocketDataSerialization.swift", "//\n// SocketDataSerialization.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nextension Data {\n func decodeSocketData(_ type: T.Type) throws -> T {\n var data = self\n data.removeLast()\n return try JSONDecoder().decode(T.self, from: data)\n }\n}\n\nextension Encodable {\n func encodeSocketData() -> Data? {\n var result = try? JSONEncoder().encode(self)\n result?.append(0)\n return result\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Extensions/SocketDataSerialization.swift", "//\n// SocketDataSerialization.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nextension Data {\n func decodeSocketData(_ type: T.Type) throws -> T {\n var data = self\n data.removeLast()\n return try JSONDecoder().decode(T.self, from: data)\n }\n}\n\nextension Encodable {\n func encodeSocketData() -> Data? {\n var result = try? JSONEncoder().encode(self)\n result?.append(0)\n return result\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Open/OpenSpaceControlCommand.swift", "//\n// OpenSpaceControlCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct OpenSpaceControlCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"open-space-control\",\n abstract: \"Open Space Control\"\n )\n\n func run() throws {\n sendCommand(.openSpaceControl)\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Get/GetWorkspaceCommand.swift", "//\n// GetWorkspaceCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport ArgumentParser\nimport Foundation\n\nstruct GetWorkspaceCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"get-workspace\",\n abstract: \"Get active workspace\"\n )\n\n @Option(help: \"Display name\")\n var display: String?\n\n func run() throws {\n sendCommand(.getWorkspace(display: display))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/String.swift", "//\n// String.swift\n//\n// Created by Wojciech Kulik on 13/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nextension String {\n static let defaultIconSymbol = \"bolt.fill\"\n\n var isNotEmpty: Bool { !isEmpty }\n var nilIfEmpty: String? { isEmpty ? nil : self }\n var trimmed: String { trimmingCharacters(in: .whitespacesAndNewlines) }\n}\n"], ["/FlashSpace/FlashSpace/UI/Alerts.swift", "//\n// Alerts.swift\n//\n// Created by Wojciech Kulik on 25/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nenum Alert {\n static func showOkAlert(title: String, message: String) {\n let alert = NSAlert()\n alert.messageText = title\n alert.informativeText = message\n alert.alertStyle = .informational\n alert.addButton(withTitle: \"OK\")\n alert.runModal()\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/Array.swift", "//\n// Array.swift\n//\n// Created by Wojciech Kulik on 27/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nextension Array {\n subscript(safe index: Index) -> Element? {\n get {\n indices.contains(index) ? self[index] : nil\n }\n set {\n guard indices.contains(index), let newValue else { return }\n self[index] = newValue\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Accessibility/AXUIElement+GetSet.swift", "//\n// AXUIElement+GetSet.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension AXUIElement {\n func getAttribute(_ attribute: NSAccessibility.Attribute) -> T? {\n var value: CFTypeRef?\n AXUIElementCopyAttributeValue(self, attribute as CFString, &value)\n\n return value as? T\n }\n\n func setAttribute(_ attribute: NSAccessibility.Attribute, value: some Any) {\n AXUIElementSetAttributeValue(self, attribute as CFString, value as CFTypeRef)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/_Models/AppSettings.swift", "//\n// AppSettings.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nstruct AppSettings: Codable {\n // General\n var checkForUpdatesAutomatically: Bool?\n var showFlashSpace: AppHotKey?\n var showFloatingNotifications: Bool?\n\n // Menu Bar\n var showMenuBarTitle: Bool?\n var showMenuBarIcon: Bool?\n var menuBarTitleTemplate: String?\n var menuBarDisplayAliases: String?\n\n // Focus Manager\n var enableFocusManagement: Bool?\n var centerCursorOnFocusChange: Bool?\n var focusLeft: AppHotKey?\n var focusRight: AppHotKey?\n var focusUp: AppHotKey?\n var focusDown: AppHotKey?\n var focusNextWorkspaceApp: AppHotKey?\n var focusPreviousWorkspaceApp: AppHotKey?\n var focusNextWorkspaceWindow: AppHotKey?\n var focusPreviousWorkspaceWindow: AppHotKey?\n var focusFrontmostWindow: Bool?\n\n // Gestures\n var enableSwipeGestures: Bool?\n var swipeThreshold: Double?\n var restartAppOnWakeUp: Bool?\n var swipeLeft3FingerAction: GestureAction?\n var swipeRight3FingerAction: GestureAction?\n var swipeUp3FingerAction: GestureAction?\n var swipeDown3FingerAction: GestureAction?\n var swipeLeft4FingerAction: GestureAction?\n var swipeRight4FingerAction: GestureAction?\n var swipeUp4FingerAction: GestureAction?\n var swipeDown4FingerAction: GestureAction?\n\n // Workspaces\n var displayMode: DisplayMode?\n var centerCursorOnWorkspaceChange: Bool?\n var changeWorkspaceOnAppAssign: Bool?\n var activeWorkspaceOnFocusChange: Bool?\n var skipEmptyWorkspacesOnSwitch: Bool?\n var keepUnassignedAppsOnSwitch: Bool?\n var restoreHiddenAppsOnSwitch: Bool?\n var loopWorkspaces: Bool?\n var switchToPreviousWorkspace: AppHotKey?\n var switchToNextWorkspace: AppHotKey?\n var switchToRecentWorkspace: AppHotKey?\n var assignFocusedApp: AppHotKey?\n var unassignFocusedApp: AppHotKey?\n var toggleFocusedAppAssignment: AppHotKey?\n var assignVisibleApps: AppHotKey?\n var hideUnassignedApps: AppHotKey?\n var alternativeDisplays: String?\n var enablePictureInPictureSupport: Bool?\n var switchWorkspaceWhenPipCloses: Bool?\n var pipApps: [PipApp]?\n var pipScreenCornerOffset: Int?\n\n // Floating apps\n var floatingApps: [MacApp]?\n var floatTheFocusedApp: AppHotKey?\n var unfloatTheFocusedApp: AppHotKey?\n var toggleTheFocusedAppFloating: AppHotKey?\n\n // Space Control\n var enableSpaceControl: Bool?\n var showSpaceControl: AppHotKey?\n var enableSpaceControlAnimations: Bool?\n var spaceControlCurrentDisplayWorkspaces: Bool?\n var spaceControlMaxColumns: Int?\n var enableWorkspaceTransitions: Bool?\n var workspaceTransitionDuration: Double?\n var workspaceTransitionDimming: Double?\n\n // Integrations\n var enableIntegrations: Bool?\n var runScriptOnLaunch: String?\n var runScriptOnWorkspaceChange: String?\n var runScriptOnProfileChange: String?\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Workspaces/DisplayMode.swift", "//\n// DisplayMode.swift\n//\n// Created by Wojciech Kulik on 12/07/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nenum DisplayMode: String, Codable, CaseIterable {\n case `static`\n case dynamic\n}\n\nextension DisplayMode: Identifiable {\n var id: String { rawValue }\n\n var description: String {\n switch self {\n case .static: return \"Static\"\n case .dynamic: return \"Dynamic\"\n }\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Profile/CreateProfileCommand.swift", "//\n// CreateProfileCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct CreateProfileCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"create-profile\",\n abstract: \"Create a profile\"\n )\n\n @Argument(help: \"The name of the profile to create.\")\n var name: String\n\n @Flag(help: \"Copy the current profile\")\n var copy = false\n\n @Flag(help: \"Activate the new profile\")\n var activate = false\n\n func run() throws {\n sendCommand(.createProfile(name: name, copy: copy, activate: activate))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Extensions/ParsableCommand.swift", "//\n// ParsableCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nextension ParsableCommand {\n func sendCommand(_ command: CommandRequest) {\n SocketClient.shared.sendCommand(command)\n }\n\n func fallbackToHelp() {\n print(Self.helpMessage(for: Self.self))\n Self.exit(withError: CommandError.other)\n }\n\n func runWithTimeout() {\n RunLoop.current.run(until: Date().addingTimeInterval(5.0))\n Self.exit(withError: CommandError.timeout)\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/List/ListWorkspacesCommand.swift", "//\n// ListWorkspacesCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct ListWorkspacesCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"list-workspaces\",\n abstract: \"List workspaces\"\n )\n\n @Flag(help: \"Include assigned display name\")\n var withDisplay = false\n\n @Option(help: \"Profile name\")\n var profile: String?\n\n func run() throws {\n sendCommand(.listWorkspaces(withDisplay: withDisplay, profile: profile))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/HotKeys/Models/KeyModifiersMap.swift", "//\n// KeyModifiersMap.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nenum KeyModifiersMap {\n static func toString(_ value: RawKeyModifiers) -> String {\n let flags = NSEvent.ModifierFlags(rawValue: value)\n var result: [String] = []\n\n if flags.contains(.command) { result.append(\"cmd\") }\n if flags.contains(.control) { result.append(\"ctrl\") }\n if flags.contains(.option) { result.append(\"opt\") }\n if flags.contains(.shift) { result.append(\"shift\") }\n\n return result.joined(separator: \"+\")\n }\n\n static func toModifiers(_ value: String) -> RawKeyModifiers {\n let flags = value.lowercased().split(separator: \"+\").map { String($0) }\n var result: RawKeyModifiers = 0\n\n if flags.contains(\"cmd\") { result |= NSEvent.ModifierFlags.command.rawValue }\n if flags.contains(\"ctrl\") { result |= NSEvent.ModifierFlags.control.rawValue }\n if flags.contains(\"opt\") { result |= NSEvent.ModifierFlags.option.rawValue }\n if flags.contains(\"shift\") { result |= NSEvent.ModifierFlags.shift.rawValue }\n\n return result\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/List/ListDisplays.swift", "//\n// ListDisplays.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport ArgumentParser\nimport Foundation\n\nstruct ListDisplaysCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"list-displays\",\n abstract: \"List displays\"\n )\n\n func run() throws {\n for screen in NSScreen.screens {\n print(screen.localizedName)\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Config/Models/ConfigFormat.swift", "//\n// ConfigFormat.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nenum ConfigFormat: String, CaseIterable {\n case json\n case toml\n case yaml\n\n var displayName: String {\n switch self {\n case .json: return \"JSON\"\n case .toml: return \"TOML\"\n case .yaml: return \"YAML\"\n }\n }\n\n var extensionName: String {\n switch self {\n case .json: return \"json\"\n case .toml: return \"toml\"\n case .yaml: return \"yaml\"\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Utils/UpdatesManager.swift", "//\n// UpdatesManager.swift\n//\n// Created by Wojciech Kulik on 25/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\nimport Sparkle\n\nfinal class UpdatesManager {\n static let shared = UpdatesManager()\n\n var autoCheckForUpdates: Bool {\n get { updaterController.updater.automaticallyChecksForUpdates }\n set { updaterController.updater.automaticallyChecksForUpdates = newValue }\n }\n\n private var lastCheckDate = Date.distantPast\n private var detectedNewRelease = false\n\n private let updaterController = SPUStandardUpdaterController(\n startingUpdater: true,\n updaterDelegate: nil,\n userDriverDelegate: nil\n )\n\n private init() {\n updaterController.updater.updateCheckInterval = 30 * 60\n\n DispatchQueue.main.async {\n self.autoCheckForUpdates = AppDependencies.shared.generalSettings.checkForUpdatesAutomatically\n }\n }\n\n func checkForUpdates() {\n updaterController.updater.checkForUpdates()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Get/GetAppCommand.swift", "//\n// GetAppCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport ArgumentParser\nimport Foundation\n\nstruct GetAppCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"get-app\",\n abstract: \"Get active app\"\n )\n\n @Flag(help: \"Include windows count\")\n var withWindowsCount = false\n\n func run() throws {\n sendCommand(.getApp(withWindowsCount: withWindowsCount))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/List/ListProfilesCommand.swift", "//\n// ListProfilesCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct ListProfilesCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"list-profiles\",\n abstract: \"List profiles\"\n )\n\n func run() throws {\n sendCommand(.listProfiles)\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Get/GetDisplayCommand.swift", "//\n// GetDisplayCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport ArgumentParser\nimport Foundation\n\nstruct GetDisplayCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"get-display\",\n abstract: \"Get active display\"\n )\n\n func run() throws {\n sendCommand(.getDisplay)\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Get/GetProfileCommand.swift", "//\n// GetProfileCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport ArgumentParser\nimport Foundation\n\nstruct GetProfileCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"get-profile\",\n abstract: \"Get active profile\"\n )\n\n func run() throws {\n sendCommand(.getProfile)\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Profile/DeleteProfileCommand.swift", "//\n// DeleteProfileCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct DeleteProfileCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"delete-profile\",\n abstract: \"Delete a profile\"\n )\n\n @Argument(help: \"The name of the profile to delete.\")\n var name: String\n\n func run() throws {\n sendCommand(.deleteProfile(name: name))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Profile/ProfileCommand.swift", "//\n// ProfileCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct ProfileCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"profile\",\n abstract: \"Activate a profile\"\n )\n\n @Argument(help: \"Profile name.\")\n var name: String\n\n func run() throws {\n sendCommand(.activateProfile(name: name))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/URL.swift", "//\n// URL.swift\n//\n// Created by Wojciech Kulik on 26/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nextension URL {\n var bundle: Bundle? { Bundle(url: self) }\n var fileName: String { lastPathComponent.replacingOccurrences(of: \".app\", with: \"\") }\n var appName: String { bundle?.localizedAppName ?? fileName }\n var bundleIdentifier: BundleId? { bundle?.bundleIdentifier }\n var iconPath: String? { bundle?.iconPath }\n\n func createIntermediateDirectories() throws {\n try FileManager.default.createDirectory(\n at: deletingLastPathComponent(),\n withIntermediateDirectories: true\n )\n }\n}\n"], ["/FlashSpace/FlashSpace/Utils/PermissionsManager.swift", "//\n// PermissionsManager.swift\n//\n// Created by Wojciech Kulik on 25/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nfinal class PermissionsManager {\n static let shared = PermissionsManager()\n\n private init() {}\n\n func askForAccessibilityPermissions() {\n let options: NSDictionary = [kAXTrustedCheckOptionPrompt.takeRetainedValue() as NSString: true]\n _ = AXIsProcessTrustedWithOptions(options)\n }\n\n func checkForAccessibilityPermissions() -> Bool {\n AXIsProcessTrusted()\n }\n\n func askForScreenRecordingPermissions() {\n CGRequestScreenCaptureAccess()\n }\n\n func checkForScreenRecordingPermissions() -> Bool {\n CGPreflightScreenCaptureAccess()\n }\n}\n"], ["/FlashSpace/FlashSpace/Utils/Logger.swift", "//\n// Logger.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nenum Logger {\n static let dateFormatter: DateFormatter = {\n let formatter = DateFormatter()\n formatter.dateFormat = \"HH:mm:ss.SSS\"\n return formatter\n }()\n\n static func log(_ message: String) {\n #if DEBUG\n let dateString = dateFormatter.string(from: Date())\n print(\"\\(dateString): \\(message)\")\n #endif\n }\n\n static func log(_ error: Error) {\n log(\"\\(error)\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/HotKeys/Models/HotKeysMonitor.swift", "//\n// HotKeysMonitor.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ShortcutRecorder\n\nprotocol HotKeysMonitorProtocol: AnyObject {\n var actions: [ShortcutAction] { get }\n\n func addAction(_ anAction: ShortcutAction, forKeyEvent aKeyEvent: KeyEventType)\n func removeAction(_ anAction: ShortcutAction)\n func removeAllActions()\n}\n\nextension GlobalShortcutMonitor: HotKeysMonitorProtocol {}\n"], ["/FlashSpace/FlashSpace/Extensions/MacAppArray.swift", "//\n// MacAppArray.swift\n//\n// Created by Wojciech Kulik on 06/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension [MacApp] {\n func firstIndex(ofAppWith bundleIdentifier: BundleId) -> Int? {\n firstIndex { $0.bundleIdentifier == bundleIdentifier }\n }\n\n func firstIndex(of app: NSRunningApplication) -> Int? {\n firstIndex { $0.bundleIdentifier == app.bundleIdentifier }\n }\n\n func containsApp(with bundleIdentifier: BundleId?) -> Bool {\n contains { $0.bundleIdentifier == bundleIdentifier }\n }\n\n func containsApp(_ app: NSRunningApplication) -> Bool {\n contains { $0.bundleIdentifier == app.bundleIdentifier }\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/NotificationName.swift", "//\n// NotificationName.swift\n//\n// Created by Wojciech Kulik on 22/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nextension Notification.Name {\n static let appsListChanged = Notification.Name(\"appsListChanged\")\n static let openMainWindow = Notification.Name(\"openMainWindow\")\n static let profileChanged = Notification.Name(\"profileChanged\")\n static let workspaceChanged = Notification.Name(\"workspaceChanged\")\n static let workspaceTransitionFinished = Notification.Name(\"workspaceTransitionFinished\")\n static let spaceControlArrowDown = Notification.Name(\"spaceControlArrowDown\")\n static let pipFocusChanged = Notification.Name(\"pipFocusChanged\")\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/App/HideUnassignedAppsCommand.swift", "//\n// HideUnassignedAppsCommand.swift\n//\n// Created by Wojciech Kulik on 07/05/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct HideUnassignedAppsCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"hide-unassigned-apps\",\n abstract: \"Hide all unassigned apps\"\n )\n\n func run() throws {\n sendCommand(.hideUnassignedApps)\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Profiles/Models/Profile.swift", "//\n// Profile.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\ntypealias ProfileId = UUID\n\nstruct ProfilesConfig: Codable {\n let profiles: [Profile]\n}\n\nstruct Profile: Identifiable, Codable, Hashable {\n let id: ProfileId\n var name: String\n var workspaces: [Workspace]\n}\n\nextension Profile {\n static let `default` = Profile(\n id: UUID(),\n name: \"Default\",\n workspaces: []\n )\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/List/ListFloatingAppsCommand.swift", "//\n// ListFloatingAppsCommand.swift\n//\n// Created by Wojciech Kulik on 03/05/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct ListFloatingAppsCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"list-floating-apps\",\n abstract: \"List floating apps\"\n )\n\n @Flag(help: \"Include bundle id\")\n var withBundleId = false\n\n func run() throws {\n sendCommand(.listFloatingApps(withBundleId: withBundleId))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Accessibility/NSAccessibility+Attributes.swift", "//\n// NSAccessibility+Attributes.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension NSAccessibility.Attribute {\n static let enchancedUserInterface: NSAccessibility.Attribute = .init(rawValue: \"AXEnhancedUserInterface\")\n}\n"], ["/FlashSpace/FlashSpace/Features/PictureInPicture/Extensions/NSRunningApplication+PiP.swift", "//\n// NSRunningApplication+PiP.swift\n//\n// Created by Wojciech Kulik on 12/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension NSRunningApplication {\n var supportsPictureInPicture: Bool {\n PipBrowser.allCases.contains { $0.bundleId == bundleIdentifier } ||\n pipApps.contains { $0.bundleIdentifier == bundleIdentifier }\n }\n\n var isPictureInPictureActive: Bool {\n allWindows.map(\\.window).contains { $0.isPictureInPicture(bundleId: bundleIdentifier) }\n }\n\n private var pipApps: [PipApp] {\n AppDependencies.shared.workspaceSettings.pipApps\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Config/Models/ConfigCoder.swift", "//\n// ConfigCoder.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nprotocol ConfigEncoder {\n func encode(_ value: some Encodable) throws -> Data\n}\n\nprotocol ConfigDecoder {\n func decode(_ type: T.Type, from data: Data) throws -> T where T: Decodable\n}\n"], ["/FlashSpace/FlashSpace/App/AppConstants.swift", "//\n// AppConstants.swift\n//\n// Created by Wojciech Kulik on 23/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nenum AppConstants {\n enum UserDefaultsKey {\n static let selectedProfileId = \"selectedProfileId\"\n }\n\n static let lastFocusedOption = MacApp(\n name: \"(Last Focused)\",\n bundleIdentifier: \"flashspace.last-focused\",\n iconPath: nil\n )\n\n static var version: String {\n guard let version = Bundle.main.infoDictionary?[\"CFBundleShortVersionString\"] as? String else {\n return \"Unknown\"\n }\n\n #if DEBUG\n return version + \" (debug)\"\n #else\n return version\n #endif\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/_Models/SettingsProtocol.swift", "//\n// SettingsProtocol.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\n\nprotocol SettingsProtocol {\n var updatePublisher: AnyPublisher<(), Never> { get }\n\n func load(from appSettings: AppSettings)\n func update(_ appSettings: inout AppSettings)\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Models/CommandExecutor.swift", "//\n// CommandExecutor.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nprotocol CommandExecutor {\n func execute(command: CommandRequest) -> CommandResponse?\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Models/UpdateWorkspaceRequest.swift", "//\n// UpdateWorkspaceRequest.swift\n//\n// Created by Wojciech Kulik on 02/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nstruct UpdateWorkspaceRequest: Codable {\n enum Display: Codable {\n case active\n case name(String)\n }\n\n let name: String?\n let display: Display?\n}\n"], ["/FlashSpace/FlashSpace/Accessibility/NSRunningApplication+Apps.swift", "//\n// NSRunningApplication+Apps.swift\n//\n// Created by Wojciech Kulik on 12/07/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension NSRunningApplication {\n var isFinder: Bool { bundleIdentifier == \"com.apple.finder\" }\n var isPython: Bool { bundleIdentifier == \"org.python.python\" }\n var isOrion: Bool { bundleIdentifier == \"com.kagi.kagimacOS\" }\n}\n"], ["/FlashSpace/FlashSpace/Features/PictureInPicture/Models/PipApp.swift", "//\n// PipApp.swift\n//\n// Created by Wojciech Kulik on 22/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nstruct PipApp: Codable, Equatable, Hashable {\n let name: String\n let bundleIdentifier: BundleId\n let pipWindowTitleRegex: String\n}\n"], ["/FlashSpace/FlashSpace/Extensions/Collection.swift", "//\n// Collection.swift\n//\n// Created by Wojciech Kulik on 12/07/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nextension Collection {\n var isNotEmpty: Bool { !isEmpty }\n}\n\nextension Collection where Element: Hashable {\n var asSet: Set { Set(self) }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Models/BufferWrapper.swift", "//\n// BufferWrapper.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nfinal class BufferWrapper {\n var data = Data()\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Models/CommandResponse.swift", "//\n// CommandResponse.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nstruct CommandResponse: Codable {\n let success: Bool\n let message: String?\n let error: String?\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Models/CommandResponse.swift", "//\n// CommandResponse.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nstruct CommandResponse: Codable {\n var success: Bool\n var message: String?\n var error: String?\n}\n"], ["/FlashSpace/FlashSpace/Features/Config/Models/JSONCoding.swift", "//\n// JSONCoding.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nextension JSONEncoder: ConfigEncoder {}\nextension JSONDecoder: ConfigDecoder {}\n"]], "task_instance_info": {"created_time": "2025-08-21 03:16:11", "created_task_model": "DeepSeek-R1", "function_skeleton": "private func workspacePlaceholder ( width: CGFloat , height: CGFloat ) -> some View { }", "code_description": "This code segment functions to: Display a styled placeholder interface element with consistent dimensions and aspect ratio when visual content is unavailable, including a prominently centered status message and maintaining structural alignment with other components."}, "inference_content": {"inference_model": "DeepSeek-R1", "inference_result": "```swift\n[TASK_BEGIN]\nprivate func workspacePlaceholder(width: CGFloat, height: CGFloat) -> some View {\n VStack {\n Image(systemName: \"photo\")\n .resizable()\n .scaledToFit()\n .frame(height: 40)\n .foregroundColor(.white.opacity(0.8))\n Text(\"No preview\")\n .foregroundColor(.white)\n .font(.subheadline)\n }\n .frame(maxWidth: width, maxHeight: height)\n .aspectRatio(16.0/9.0, contentMode: .fit)\n .background(\n LinearGradient(\n gradient: Gradient(colors: [Color.gray.opacity(0.6), Color.gray.opacity(0.4)]),\n startPoint: .top,\n endPoint: .bottom\n )\n )\n .clipShape(RoundedRectangle(cornerRadius: 18.0))\n}\n[TASK_END]\n```", "inference_time": "2025-08-21 03-16-31"}, "editdistance_info": {"edit_distance": 35.6322, "calculate_time": "2025-08-21 03:16:31", "true_code_clean": "private func workspacePlaceholder(width: CGFloat, height: CGFloat) -> some View {\n RoundedRectangle(cornerRadius: 18.0)\n .fill(Color.black.opacity(0.5))\n .frame(maxWidth: width, maxHeight: height)\n .aspectRatio(16.0 / 9.0, contentMode: .fit)\n .overlay {\n Text(\"Preview Not Available\")\n .font(.title)\n .foregroundColor(.white)\n .padding()\n .frame(maxWidth: .infinity, maxHeight: .infinity)\n }\n .clipped()\n }", "predict_code_clean": "private func workspacePlaceholder(width: CGFloat, height: CGFloat) -> some View {\n VStack {\n Image(systemName: \"photo\")\n .resizable()\n .scaledToFit()\n .frame(height: 40)\n .foregroundColor(.white.opacity(0.8))\n Text(\"No preview\")\n .foregroundColor(.white)\n .font(.subheadline)\n }\n .frame(maxWidth: width, maxHeight: height)\n .aspectRatio(16.0/9.0, contentMode: .fit)\n .background(\n LinearGradient(\n gradient: Gradient(colors: [Color.gray.opacity(0.6), Color.gray.opacity(0.4)]),\n startPoint: .top,\n endPoint: .bottom\n )\n )\n .clipShape(RoundedRectangle(cornerRadius: 18.0))\n}"}} {"repo_name": "FlashSpace", "file_name": "/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Workspace/UpdateWorkspaceCommand.swift", "inference_info": {"prefix_code": "//\n// UpdateWorkspaceCommand.swift\n//\n// Created by Wojciech Kulik on 02/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport ArgumentParser\nimport Foundation\n\nstruct UpdateWorkspaceRequest: Codable {\n enum Display: Codable {\n case active\n case name(String)\n }\n\n let name: String?\n let display: Display?\n}\n\nstruct UpdateWorkspaceCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"update-workspace\",\n abstract: \"Update a workspace\"\n )\n\n @Option(help: \"The name of the workspace to update.\")\n var workspace: String?\n\n @Flag(help: \"Update active workspace.\")\n var activeWorkspace = false\n\n @Option(help: \"The name of the display to be assigned.\")\n var display: String?\n\n @Flag(help: \"Assign active display.\")\n var activeDisplay = false\n\n func run() throws {\n if let display {\n sendCommand(.updateWorkspace(.init(name: workspace, display: .name(display))))\n } else if activeDisplay {\n sendCommand(.updateWorkspace(.init(name: workspace, display: .active)))\n } else {\n throw CommandError.operationFailed(\"Invalid command\")\n }\n\n runWithTimeout()\n }\n\n ", "suffix_code": "\n}\n", "middle_code": "func validate() throws {\n if workspace != nil, activeWorkspace {\n throw CommandError.operationFailed(\"You cannot provide both a workspace name and use the --active-workspace flag\")\n }\n if display != nil, activeDisplay {\n throw CommandError.operationFailed(\"You cannot provide both a display name and use the --active-display flag\")\n }\n if workspace == nil, !activeWorkspace {\n throw CommandError.operationFailed(\"You must provide either a workspace name or use the --active-workspace flag\")\n }\n if display == nil, !activeDisplay {\n throw CommandError.operationFailed(\"You must provide either a display name or use the --active-display flag\")\n }\n if let display, !NSScreen.screens.contains(where: { $0.localizedName == display }) {\n throw CommandError.operationFailed(\"Display \\\"\\(display)\\\" not found\")\n }\n }", "code_description": null, "fill_type": "FUNCTION_TYPE", "language_type": "swift", "sub_task_type": null}, "context_code": [["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Workspace/CreateWorkspaceCommand.swift", "//\n// CreateWorkspaceCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct CreateWorkspaceRequest: Codable {\n let name: String\n let display: String?\n let icon: String?\n let activateKey: String?\n let assignKey: String?\n let activate: Bool\n}\n\nstruct CreateWorkspaceCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"create-workspace\",\n abstract: \"Create a workspace\"\n )\n\n @Argument(help: \"The name of the workspace to create.\")\n var name: String\n\n @Option(help: .init(\"The name of the display\", valueName: \"name\"))\n var display: String?\n\n @Option(help: \"The name of the icon to use for the workspace. Must match SF Symbols.\")\n var icon: String?\n\n @Option(help: \"The hotkey to activate the workspace\")\n var activateKey: String?\n\n @Option(help: \"The hotkey to assign the app\")\n var assignKey: String?\n\n @Flag(help: \"Activate the new workspace\")\n var activate = false\n\n func run() throws {\n let request = CreateWorkspaceRequest(\n name: name,\n display: display,\n icon: icon,\n activateKey: activateKey,\n assignKey: assignKey,\n activate: activate\n )\n sendCommand(.createWorkspace(request))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Workspace/WorkspaceCommand.swift", "//\n// WorkspaceCommand.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct WorkspaceCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"workspace\",\n abstract: \"Activate a workspace\"\n )\n\n @Option(help: .init(\"The name of the workspace\"))\n var name: String?\n\n @Option(help: .init(\n \"The number of the workspace to activate. Starting from 1.\",\n valueName: \"number\"\n ))\n var number: Int?\n\n @Flag(help: \"Activate the next workspace\")\n var next = false\n\n @Flag(help: \"Activate the previous workspace\")\n var prev = false\n\n @Flag(help: \"Activate the most recently used workspace\")\n var recent = false\n\n @Flag(help: \"Skip empty workspaces (works only with --next or --prev)\")\n var skipEmpty = false\n\n @Flag(help: \"Loop back to the first workspace when reaching the last one and vice versa (works only with --next or --prev)\")\n var loop = false\n\n @Flag(help: \"Hide all apps that are not assigned to the selected workspace\")\n var clean = false\n\n func run() throws {\n if let name {\n sendCommand(.activateWorkspace(name: name, number: nil, clean: clean))\n } else if let number {\n sendCommand(.activateWorkspace(name: nil, number: number, clean: clean))\n } else if next {\n sendCommand(.nextWorkspace(skipEmpty: skipEmpty, clean: clean, loop: loop))\n } else if prev {\n sendCommand(.previousWorkspace(skipEmpty: skipEmpty, clean: clean, loop: loop))\n } else if recent {\n sendCommand(.recentWorkspace(clean: clean))\n } else {\n fallbackToHelp()\n }\n\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/App/AssignAppCommand.swift", "//\n// AssignAppCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct AssignAppCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"assign-app\",\n abstract: \"Assign an app to a workspace\"\n )\n\n @Option(help: .init(\n \"The name of the app or bundle id. If not provided, the active app will be assigned. Default: active app.\",\n valueName: \"name|bundle id\"\n ))\n var name: String?\n\n @Option(\n name: .customLong(\"workspace\"),\n help: .init(\"The name of the workspace to assign the app to. Default: active workspace.\", valueName: \"name\")\n )\n var workspace: String?\n\n @Option(help: .init(\n \"Activate the workspace. Default: from app settings.\",\n valueName: \"true|false\"\n ))\n var activate: Bool?\n\n @Flag(help: \"Show toast notification\")\n var showNotification = false\n\n func run() throws {\n sendCommand(\n .assignApp(\n app: name,\n workspaceName: workspace,\n activate: activate,\n showNotification: showNotification\n )\n )\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Open/OpenAppCommand.swift", "//\n// OpenAppCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport ArgumentParser\nimport Foundation\n\nstruct OpenAppCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"open\",\n abstract: \"Open FlashSpace\"\n )\n\n func run() throws {\n let url = NSWorkspace.shared.urlForApplication(withBundleIdentifier: \"pl.wojciechkulik.FlashSpace.dev\")\n ?? NSWorkspace.shared.urlForApplication(withBundleIdentifier: \"pl.wojciechkulik.FlashSpace\")\n\n if let url {\n let config = NSWorkspace.OpenConfiguration()\n config.activates = true\n NSWorkspace.shared.openApplication(at: url, configuration: config) { _, error in\n if let error {\n Self.exit(withError: CommandError.operationFailed(\"Failed to open FlashSpace: \\(error.localizedDescription)\"))\n } else {\n Self.exit()\n }\n }\n runWithTimeout()\n } else {\n throw CommandError.operationFailed(\"FlashSpace is not installed.\")\n }\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Get/GetWorkspaceCommand.swift", "//\n// GetWorkspaceCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport ArgumentParser\nimport Foundation\n\nstruct GetWorkspaceCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"get-workspace\",\n abstract: \"Get active workspace\"\n )\n\n @Option(help: \"Display name\")\n var display: String?\n\n func run() throws {\n sendCommand(.getWorkspace(display: display))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/App/AssignVisibleAppsCommand.swift", "//\n// AssignVisibleAppsCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct AssignVisibleAppsCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"assign-visible-apps\",\n abstract: \"Assign visible apps to a workspace\"\n )\n\n @Option(\n name: .customLong(\"workspace\"),\n help: .init(\"The name of the workspace to assign apps to. Default: active workspace.\", valueName: \"name\")\n )\n var workspace: String?\n\n @Flag(help: \"Show toast notification\")\n var showNotification = false\n\n func run() throws {\n sendCommand(\n .assignVisibleApps(workspaceName: workspace, showNotification: showNotification)\n )\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Workspaces/WorkspaceManager.swift", "//\n// WorkspaceManager.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Combine\n\ntypealias DisplayName = String\n\nstruct ActiveWorkspace {\n let id: WorkspaceID\n let name: String\n let number: String?\n let symbolIconName: String?\n let display: DisplayName\n}\n\nfinal class WorkspaceManager: ObservableObject {\n @Published private(set) var activeWorkspaceDetails: ActiveWorkspace?\n\n private(set) var lastFocusedApp: [WorkspaceID: MacApp] = [:]\n private(set) var activeWorkspace: [DisplayName: Workspace] = [:]\n private(set) var mostRecentWorkspace: [DisplayName: Workspace] = [:]\n private(set) var lastWorkspaceActivation = Date.distantPast\n\n private var cancellables = Set()\n private var observeFocusCancellable: AnyCancellable?\n private var appsHiddenManually: [WorkspaceID: [MacApp]] = [:]\n private let hideAgainSubject = PassthroughSubject()\n\n private let workspaceRepository: WorkspaceRepository\n private let workspaceSettings: WorkspaceSettings\n private let floatingAppsSettings: FloatingAppsSettings\n private let pictureInPictureManager: PictureInPictureManager\n private let workspaceTransitionManager: WorkspaceTransitionManager\n private let displayManager: DisplayManager\n\n init(\n workspaceRepository: WorkspaceRepository,\n settingsRepository: SettingsRepository,\n pictureInPictureManager: PictureInPictureManager,\n workspaceTransitionManager: WorkspaceTransitionManager,\n displayManager: DisplayManager\n ) {\n self.workspaceRepository = workspaceRepository\n self.workspaceSettings = settingsRepository.workspaceSettings\n self.floatingAppsSettings = settingsRepository.floatingAppsSettings\n self.pictureInPictureManager = pictureInPictureManager\n self.workspaceTransitionManager = workspaceTransitionManager\n self.displayManager = displayManager\n\n PermissionsManager.shared.askForAccessibilityPermissions()\n observe()\n }\n\n private func observe() {\n hideAgainSubject\n .debounce(for: 0.2, scheduler: RunLoop.main)\n .sink { [weak self] in self?.hideApps(in: $0) }\n .store(in: &cancellables)\n\n NotificationCenter.default\n .publisher(for: .profileChanged)\n .sink { [weak self] _ in\n self?.lastFocusedApp = [:]\n self?.activeWorkspace = [:]\n self?.mostRecentWorkspace = [:]\n self?.activeWorkspaceDetails = nil\n }\n .store(in: &cancellables)\n\n NotificationCenter.default\n .publisher(for: NSApplication.didChangeScreenParametersNotification)\n .sink { [weak self] _ in\n self?.activeWorkspace = [:]\n self?.mostRecentWorkspace = [:]\n self?.activeWorkspaceDetails = nil\n }\n .store(in: &cancellables)\n\n observeFocus()\n }\n\n private func observeFocus() {\n observeFocusCancellable = NSWorkspace.shared.notificationCenter\n .publisher(for: NSWorkspace.didActivateApplicationNotification)\n .compactMap { $0.userInfo?[NSWorkspace.applicationUserInfoKey] as? NSRunningApplication }\n .sink { [weak self] application in\n self?.rememberLastFocusedApp(application, retry: true)\n }\n }\n\n private func rememberLastFocusedApp(_ application: NSRunningApplication, retry: Bool) {\n guard application.display != nil else {\n if retry {\n Logger.log(\"Retrying to get display for \\(application.localizedName ?? \"\")\")\n return DispatchQueue.main.asyncAfter(deadline: .now() + 0.6) {\n if let frontmostApp = NSWorkspace.shared.frontmostApplication {\n self.rememberLastFocusedApp(frontmostApp, retry: false)\n }\n }\n } else {\n return Logger.log(\"Unable to get display for \\(application.localizedName ?? \"\")\")\n }\n }\n\n let focusedDisplay = NSScreen.main?.localizedName ?? \"\"\n\n if let activeWorkspace = activeWorkspace[focusedDisplay], activeWorkspace.apps.containsApp(application) {\n lastFocusedApp[activeWorkspace.id] = application.toMacApp\n updateActiveWorkspace(activeWorkspace, on: [focusedDisplay])\n }\n\n displayManager.trackDisplayFocus(on: focusedDisplay, for: application)\n }\n\n private func showApps(in workspace: Workspace, setFocus: Bool, on displays: Set) {\n let regularApps = NSWorkspace.shared.runningApplications\n .filter { $0.activationPolicy == .regular }\n let floatingApps = floatingAppsSettings.floatingApps\n let hiddenApps = appsHiddenManually[workspace.id] ?? []\n var appsToShow = regularApps\n .filter { !hiddenApps.containsApp($0) }\n .filter {\n workspace.apps.containsApp($0) ||\n floatingApps.containsApp($0) && $0.isOnAnyDisplay(displays)\n }\n\n observeFocusCancellable = nil\n defer { observeFocus() }\n\n if setFocus {\n let toFocus = findAppToFocus(in: workspace, apps: appsToShow)\n\n // Make sure to raise the app that should be focused\n // as the last one\n if let toFocus {\n appsToShow.removeAll { $0 == toFocus }\n appsToShow.append(toFocus)\n }\n\n for app in appsToShow {\n Logger.log(\"SHOW: \\(app.localizedName ?? \"\")\")\n\n if app == toFocus || app.isHidden || app.isMinimized {\n app.raise()\n }\n\n pictureInPictureManager.showPipAppIfNeeded(app: app)\n }\n\n Logger.log(\"FOCUS: \\(toFocus?.localizedName ?? \"\")\")\n toFocus?.activate()\n centerCursorIfNeeded(in: toFocus?.frame)\n } else {\n for app in appsToShow {\n Logger.log(\"SHOW: \\(app.localizedName ?? \"\")\")\n app.raise()\n }\n }\n }\n\n private func hideApps(in workspace: Workspace) {\n let regularApps = NSWorkspace.shared.runningApplications\n .filter { $0.activationPolicy == .regular }\n let workspaceApps = workspace.apps + floatingAppsSettings.floatingApps\n let isAnyWorkspaceAppRunning = regularApps\n .contains { workspaceApps.containsApp($0) }\n let allAssignedApps = workspaceRepository.workspaces\n .flatMap(\\.apps)\n .map(\\.bundleIdentifier)\n .asSet\n let displays = workspace.displays\n\n let appsToHide = regularApps\n .filter {\n !$0.isHidden && !workspaceApps.containsApp($0) &&\n (!workspaceSettings.keepUnassignedAppsOnSwitch || allAssignedApps.contains($0.bundleIdentifier ?? \"\"))\n }\n .filter { isAnyWorkspaceAppRunning || $0.bundleURL?.fileName != \"Finder\" }\n .filter { $0.isOnAnyDisplay(displays) }\n\n for app in appsToHide {\n Logger.log(\"HIDE: \\(app.localizedName ?? \"\")\")\n\n if !pictureInPictureManager.hidePipAppIfNeeded(app: app) {\n app.hide()\n }\n }\n }\n\n private func findAppToFocus(\n in workspace: Workspace,\n apps: [NSRunningApplication]\n ) -> NSRunningApplication? {\n if workspace.appToFocus == nil {\n let displays = workspace.displays\n if let floatingEntry = displayManager.lastFocusedDisplay(where: {\n let isFloating = floatingAppsSettings.floatingApps.contains($0.app)\n let isUnassigned = workspaceSettings.keepUnassignedAppsOnSwitch &&\n !workspaceRepository.workspaces.flatMap(\\.apps).contains($0.app)\n return (isFloating || isUnassigned) && displays.contains($0.display)\n }),\n let runningApp = NSWorkspace.shared.runningApplications.find(floatingEntry.app) {\n return runningApp\n }\n }\n\n var appToFocus: NSRunningApplication?\n\n if workspace.appToFocus == nil {\n appToFocus = apps.find(lastFocusedApp[workspace.id])\n } else {\n appToFocus = apps.find(workspace.appToFocus)\n }\n\n let fallbackToLastApp = apps.findFirstMatch(with: workspace.apps.reversed())\n let fallbackToFinder = NSWorkspace.shared.runningApplications.first(where: \\.isFinder)\n\n return appToFocus ?? fallbackToLastApp ?? fallbackToFinder\n }\n\n private func centerCursorIfNeeded(in frame: CGRect?) {\n guard workspaceSettings.centerCursorOnWorkspaceChange, let frame else { return }\n\n CGWarpMouseCursorPosition(CGPoint(x: frame.midX, y: frame.midY))\n }\n\n private func updateActiveWorkspace(_ workspace: Workspace, on displays: Set) {\n lastWorkspaceActivation = Date()\n\n // Save the most recent workspace if it's not the current one\n for display in displays {\n if activeWorkspace[display]?.id != workspace.id {\n mostRecentWorkspace[display] = activeWorkspace[display]\n }\n activeWorkspace[display] = workspace\n }\n\n activeWorkspaceDetails = .init(\n id: workspace.id,\n name: workspace.name,\n number: workspaceRepository.workspaces\n .firstIndex { $0.id == workspace.id }\n .map { \"\\($0 + 1)\" },\n symbolIconName: workspace.symbolIconName,\n display: workspace.displayForPrint\n )\n\n Integrations.runOnActivateIfNeeded(workspace: activeWorkspaceDetails!)\n }\n\n private func rememberHiddenApps(workspaceToActivate: Workspace) {\n guard !workspaceSettings.restoreHiddenAppsOnSwitch else {\n appsHiddenManually = [:]\n return\n }\n\n let hiddenApps = NSWorkspace.shared.runningApplications\n .filter { $0.activationPolicy == .regular }\n .filter { $0.isHidden || $0.isMinimized }\n\n for activeWorkspace in activeWorkspace.values {\n guard activeWorkspace.id != workspaceToActivate.id else { continue }\n\n appsHiddenManually[activeWorkspace.id] = []\n }\n\n for (display, activeWorkspace) in activeWorkspace {\n guard activeWorkspace.id != workspaceToActivate.id else { continue }\n\n let activeWorkspaceOtherDisplays = activeWorkspace.displays.subtracting([display])\n appsHiddenManually[activeWorkspace.id, default: []] += hiddenApps\n .filter {\n activeWorkspace.apps.containsApp($0) &&\n $0.isOnAnyDisplay([display]) && !$0.isOnAnyDisplay(activeWorkspaceOtherDisplays)\n }\n .map(\\.toMacApp)\n }\n }\n}\n\n// MARK: - Workspace Actions\nextension WorkspaceManager {\n func activateWorkspace(_ workspace: Workspace, setFocus: Bool) {\n let displays = workspace.displays\n\n Logger.log(\"\")\n Logger.log(\"\")\n Logger.log(\"WORKSPACE: \\(workspace.name)\")\n Logger.log(\"DISPLAYS: \\(displays.joined(separator: \", \"))\")\n Logger.log(\"----\")\n SpaceControl.hide()\n\n guard displays.isNotEmpty else {\n Logger.log(\"No displays found for workspace: \\(workspace.name) - skipping\")\n return\n }\n\n workspaceTransitionManager.showTransitionIfNeeded(for: workspace, on: displays)\n\n rememberHiddenApps(workspaceToActivate: workspace)\n updateActiveWorkspace(workspace, on: displays)\n showApps(in: workspace, setFocus: setFocus, on: displays)\n hideApps(in: workspace)\n\n // Some apps may not hide properly,\n // so we hide apps in the workspace after a short delay\n hideAgainSubject.send(workspace)\n\n NotificationCenter.default.post(name: .workspaceChanged, object: workspace)\n }\n\n func assignApps(_ apps: [MacApp], to workspace: Workspace) {\n for app in apps {\n workspaceRepository.deleteAppFromAllWorkspaces(app: app)\n workspaceRepository.addApp(to: workspace.id, app: app)\n }\n\n NotificationCenter.default.post(name: .appsListChanged, object: nil)\n }\n\n func assignApp(_ app: MacApp, to workspace: Workspace) {\n workspaceRepository.deleteAppFromAllWorkspaces(app: app)\n workspaceRepository.addApp(to: workspace.id, app: app)\n\n guard let targetWorkspace = workspaceRepository.workspaces\n .first(where: { $0.id == workspace.id }) else { return }\n\n let isTargetWorkspaceActive = activeWorkspace.values\n .contains(where: { $0.id == workspace.id })\n\n updateLastFocusedApp(app, in: targetWorkspace)\n\n if workspaceSettings.changeWorkspaceOnAppAssign {\n activateWorkspace(targetWorkspace, setFocus: true)\n } else if !isTargetWorkspaceActive {\n NSWorkspace.shared.runningApplications\n .find(app)?\n .hide()\n AppDependencies.shared.focusManager.nextWorkspaceApp()\n }\n\n NotificationCenter.default.post(name: .appsListChanged, object: nil)\n }\n\n func hideUnassignedApps() {\n let activeWorkspace = workspaceRepository.workspaces\n .first(where: { $0.id == activeWorkspaceDetails?.id })\n\n guard let activeWorkspace else { return }\n\n let appsToHide = NSWorkspace.shared.runningApplications\n .regularVisibleApps(onDisplays: activeWorkspace.displays, excluding: activeWorkspace.apps)\n\n for app in appsToHide {\n Logger.log(\"CLEAN UP: \\(app.localizedName ?? \"\")\")\n\n if !pictureInPictureManager.hidePipAppIfNeeded(app: app) {\n app.hide()\n }\n }\n }\n\n func activateWorkspace(next: Bool, skipEmpty: Bool, loop: Bool) {\n guard let screen = displayManager.getCursorScreen() else { return }\n\n var screenWorkspaces = workspaceRepository.workspaces\n .filter { $0.displays.contains(screen) }\n\n if !next {\n screenWorkspaces = screenWorkspaces.reversed()\n }\n\n guard let activeWorkspace = activeWorkspace[screen] ?? screenWorkspaces.first else { return }\n\n let nextWorkspaces = screenWorkspaces\n .drop(while: { $0.id != activeWorkspace.id })\n .dropFirst()\n\n var selectedWorkspace = nextWorkspaces.first ?? (loop ? screenWorkspaces.first : nil)\n\n if skipEmpty {\n let runningApps = NSWorkspace.shared.runningApplications\n .filter { $0.activationPolicy == .regular }\n .compactMap(\\.bundleIdentifier)\n .asSet\n\n selectedWorkspace = (nextWorkspaces + (loop ? screenWorkspaces : []))\n .drop(while: { $0.apps.allSatisfy { !runningApps.contains($0.bundleIdentifier) } })\n .first\n }\n\n guard let selectedWorkspace, selectedWorkspace.id != activeWorkspace.id else { return }\n\n activateWorkspace(selectedWorkspace, setFocus: true)\n }\n\n func activateRecentWorkspace() {\n guard let screen = displayManager.getCursorScreen(),\n let mostRecentWorkspace = mostRecentWorkspace[screen]\n else { return }\n\n activateWorkspace(mostRecentWorkspace, setFocus: true)\n }\n\n func activateWorkspaceIfActive(_ workspaceId: WorkspaceID) {\n guard activeWorkspace.values.contains(where: { $0.id == workspaceId }) else { return }\n guard let updatedWorkspace = workspaceRepository.workspaces.first(where: { $0.id == workspaceId }) else { return }\n\n activateWorkspace(updatedWorkspace, setFocus: false)\n }\n\n func updateLastFocusedApp(_ app: MacApp, in workspace: Workspace) {\n lastFocusedApp[workspace.id] = app\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Commands/WorkspaceCommands.swift", "//\n// WorkspaceCommands.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\n\nfinal class WorkspaceCommands: CommandExecutor {\n var workspaceManager: WorkspaceManager { AppDependencies.shared.workspaceManager }\n var workspaceRepository: WorkspaceRepository { AppDependencies.shared.workspaceRepository }\n\n // swiftlint:disable:next cyclomatic_complexity function_body_length\n func execute(command: CommandRequest) -> CommandResponse? {\n switch command {\n case .activateWorkspace(.some(let name), _, let clean):\n let workspace = workspaceRepository.workspaces.first { $0.name == name }\n if let workspace {\n if workspace.isDynamic, workspace.displays.isEmpty {\n return CommandResponse(success: false, error: \"\\(workspace.name) - No Running Apps To Show\")\n }\n workspaceManager.activateWorkspace(workspace, setFocus: true)\n if clean { workspaceManager.hideUnassignedApps() }\n return CommandResponse(success: true)\n } else {\n return CommandResponse(success: false, error: \"Workspace not found\")\n }\n\n case .activateWorkspace(_, .some(let number), let clean):\n let workspace = workspaceRepository.workspaces[safe: number - 1]\n if let workspace {\n if workspace.isDynamic, workspace.displays.isEmpty {\n return CommandResponse(success: false, error: \"\\(workspace.name) - No Running Apps To Show\")\n }\n workspaceManager.activateWorkspace(workspace, setFocus: true)\n if clean { workspaceManager.hideUnassignedApps() }\n return CommandResponse(success: true)\n } else {\n return CommandResponse(success: false, error: \"Workspace not found\")\n }\n\n case .updateWorkspace(let request):\n return updateWorkspace(request)\n\n case .nextWorkspace(let skipEmpty, let clean, let loop):\n workspaceManager.activateWorkspace(next: true, skipEmpty: skipEmpty, loop: loop)\n if clean { workspaceManager.hideUnassignedApps() }\n return CommandResponse(success: true)\n\n case .previousWorkspace(let skipEmpty, let clean, let loop):\n workspaceManager.activateWorkspace(next: false, skipEmpty: skipEmpty, loop: loop)\n if clean { workspaceManager.hideUnassignedApps() }\n return CommandResponse(success: true)\n\n case .recentWorkspace(let clean):\n workspaceManager.activateRecentWorkspace()\n if clean { workspaceManager.hideUnassignedApps() }\n return CommandResponse(success: true)\n\n case .createWorkspace(let request):\n let workspace = request.toWorkspace\n workspaceRepository.addWorkspace(workspace)\n if request.activate {\n workspaceManager.activateWorkspace(workspace, setFocus: true)\n }\n NotificationCenter.default.post(name: .appsListChanged, object: nil)\n return CommandResponse(success: true)\n\n case .deleteWorkspace(let name):\n let workspace = workspaceRepository.workspaces.first { $0.name == name }\n if let workspace {\n workspaceRepository.deleteWorkspace(id: workspace.id)\n NotificationCenter.default.post(name: .appsListChanged, object: nil)\n return CommandResponse(success: true)\n } else {\n return CommandResponse(success: false, error: \"Workspace not found\")\n }\n\n default:\n return nil\n }\n }\n\n private func updateWorkspace(_ request: UpdateWorkspaceRequest) -> CommandResponse {\n var workspace: Workspace?\n if let workspaceName = request.name {\n workspace = workspaceRepository.workspaces.first { $0.name == workspaceName }\n } else if let workspaceId = workspaceManager.activeWorkspaceDetails?.id {\n workspace = workspaceRepository.workspaces.first { $0.id == workspaceId }\n } else {\n return CommandResponse(success: false, error: \"Workspace not found\")\n }\n\n guard var workspace else {\n return CommandResponse(success: false, error: \"Workspace not found\")\n }\n\n if let display = request.display {\n switch display {\n case .active:\n if let display = NSWorkspace.shared.frontmostApplication?.display {\n workspace.display = display\n } else {\n return CommandResponse(success: false, error: \"No active display found\")\n }\n case .name(let name):\n workspace.display = name\n }\n }\n\n workspaceRepository.updateWorkspace(workspace)\n NotificationCenter.default.post(name: .appsListChanged, object: nil)\n\n return CommandResponse(success: true)\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/App/FocusCommand.swift", "//\n// FocusCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct FocusCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"focus\",\n abstract: \"Focus window\"\n )\n\n @Option(\n name: .customLong(\"direction\"),\n help: .init(\"Focus a window in a specific direction\", valueName: \"up|down|left|right\")\n )\n var focusDirection: FocusDirection?\n\n @Flag(help: \"Focus the next workspace app\")\n var nextApp = false\n\n @Flag(help: \"Focus the previous workspace app\")\n var prevApp = false\n\n @Flag(help: \"Focus the next workspace window\")\n var nextWindow = false\n\n @Flag(help: \"Focus the previous workspace window\")\n var prevWindow = false\n\n func run() throws {\n if let focusDirection {\n sendCommand(.focusWindow(direction: focusDirection))\n } else if nextApp {\n sendCommand(.focusNextApp)\n } else if prevApp {\n sendCommand(.focusPreviousApp)\n } else if nextWindow {\n sendCommand(.focusNextWindow)\n } else if prevWindow {\n sendCommand(.focusPreviousWindow)\n } else {\n fallbackToHelp()\n }\n\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/App/FloatingAppsCommand.swift", "//\n// FloatingAppsCommand.swift\n//\n// Created by Wojciech Kulik on 03/05/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct FloatingAppsCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"floating-apps\",\n abstract: \"Manage floating apps\"\n )\n\n enum Action: String, CaseIterable, ExpressibleByArgument {\n case float\n case unfloat\n case toggle\n }\n\n @Argument(help: \"The action to perform\")\n var action: Action\n\n @Option(help: .init(\n \"The name of the app or bundle id. If not provided, the active app will be used. Default: active app.\",\n valueName: \"name|bundle id\"\n ))\n var name: String?\n\n @Flag(help: \"Show toast notification\")\n var showNotification = false\n\n func run() throws {\n switch action {\n case .float:\n sendCommand(.floatApp(app: name, showNotification: showNotification))\n case .unfloat:\n sendCommand(.unfloatApp(app: name, showNotification: showNotification))\n case .toggle:\n sendCommand(.toggleFloatApp(app: name, showNotification: showNotification))\n }\n\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Workspace/DeleteWorkspaceCommand.swift", "//\n// DeleteWorkspaceCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct DeleteWorkspaceCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"delete-workspace\",\n abstract: \"Delete a workspace\"\n )\n\n @Argument(help: \"The name of the workspace to delete.\")\n var name: String\n\n func run() throws {\n sendCommand(.deleteWorkspace(name: name))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/List/ListWorkspacesCommand.swift", "//\n// ListWorkspacesCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct ListWorkspacesCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"list-workspaces\",\n abstract: \"List workspaces\"\n )\n\n @Flag(help: \"Include assigned display name\")\n var withDisplay = false\n\n @Option(help: \"Profile name\")\n var profile: String?\n\n func run() throws {\n sendCommand(.listWorkspaces(withDisplay: withDisplay, profile: profile))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/App/UnassignAppCommand.swift", "//\n// UnassignAppCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct UnassignAppCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"unassign-app\",\n abstract: \"Unassign an app from all workspaces\"\n )\n @Option(help: .init(\n \"The name of the app or bundle id. If not provided, the active app will be unassigned. Default: active app.\",\n valueName: \"name|bundle id\"\n ))\n var name: String?\n\n @Flag(help: \"Show toast notification\")\n var showNotification = false\n\n func run() throws {\n sendCommand(.unassignApp(app: name, showNotification: showNotification))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Commands/AppCommands.swift", "//\n// AppCommands.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\n\nfinal class AppCommands: CommandExecutor {\n var workspaceManager: WorkspaceManager { AppDependencies.shared.workspaceManager }\n var workspaceRepository: WorkspaceRepository { AppDependencies.shared.workspaceRepository }\n var settings: WorkspaceSettings { AppDependencies.shared.workspaceSettings }\n var floatingAppsSettings: FloatingAppsSettings { AppDependencies.shared.floatingAppsSettings }\n\n func execute(command: CommandRequest) -> CommandResponse? {\n switch command {\n case .assignVisibleApps(let workspaceName, let showNotification):\n return assignVisibleApps(workspaceName: workspaceName, showNotification: showNotification)\n\n case .assignApp(let app, let workspaceName, let activate, let showNotification):\n return assignApp(\n app: app,\n workspaceName: workspaceName,\n activate: activate,\n showNotification: showNotification\n )\n\n case .unassignApp(let app, let showNotification):\n return unassignApp(app: app, showNotification: showNotification)\n\n case .hideUnassignedApps:\n workspaceManager.hideUnassignedApps()\n return CommandResponse(success: true)\n\n case .floatApp(let app, let showNotification):\n return floatApp(app: app, showNotification: showNotification)\n\n case .unfloatApp(let app, let showNotification):\n return unfloatApp(app: app, showNotification: showNotification)\n\n case .toggleFloatApp(let app, let showNotification):\n return toggleFloatApp(app: app, showNotification: showNotification)\n\n default:\n return nil\n }\n }\n\n private func findApp(app: String?) -> MacApp? {\n guard let app else { return NSWorkspace.shared.frontmostApplication?.toMacApp }\n\n let foundApp = NSWorkspace.shared.runningApplications\n .first { $0.localizedName == app }?\n .toMacApp\n\n if foundApp == nil, let appUrl = NSWorkspace.shared.urlForApplication(withBundleIdentifier: app) {\n return MacApp(\n name: appUrl.bundle?.localizedAppName ?? \"\",\n bundleIdentifier: app,\n iconPath: appUrl.iconPath\n )\n }\n\n return foundApp\n }\n\n private func unassignApp(app: String?, showNotification: Bool) -> CommandResponse {\n guard let app = findApp(app: app) else {\n return CommandResponse(\n success: false,\n error: \"App not found or not running. For not running apps use `unassign-app --name `.\"\n )\n }\n\n workspaceRepository.deleteAppFromAllWorkspaces(app: app)\n NSWorkspace.shared.runningApplications.find(app)?.hide()\n NotificationCenter.default.post(name: .appsListChanged, object: nil)\n\n if showNotification {\n Toast.showWith(\n icon: \"square.stack.3d.up.slash\",\n message: \"\\(app.name) - Removed From Workspaces\",\n textColor: .negative\n )\n }\n\n return CommandResponse(success: true)\n }\n\n private func assignVisibleApps(workspaceName: String?, showNotification: Bool) -> CommandResponse {\n guard let workspaceName = workspaceName ?? workspaceManager.activeWorkspaceDetails?.name else {\n return CommandResponse(success: false, error: \"No workspace selected\")\n }\n\n guard let workspace = workspaceRepository.workspaces.first(where: { $0.name == workspaceName }) else {\n return CommandResponse(success: false, error: \"Workspace not found\")\n }\n\n let visibleApps = NSWorkspace.shared.runningApplications\n .regularVisibleApps(onDisplays: workspace.displays, excluding: floatingAppsSettings.floatingApps)\n\n guard !visibleApps.isEmpty else {\n return CommandResponse(\n success: false,\n error: \"No visible apps found on the current display\"\n )\n }\n\n workspaceManager.assignApps(visibleApps.map(\\.toMacApp), to: workspace)\n\n if showNotification {\n Toast.showWith(\n icon: \"square.stack.3d.up\",\n message: \"Assigned \\(visibleApps.count) Apps(s) To \\(workspace.name)\",\n textColor: .positive\n )\n }\n\n return CommandResponse(success: true)\n }\n\n private func assignApp(\n app: String?,\n workspaceName: String?,\n activate: Bool?,\n showNotification: Bool\n ) -> CommandResponse {\n guard let workspaceName = workspaceName ?? workspaceManager.activeWorkspaceDetails?.name else {\n return CommandResponse(success: false, error: \"No workspace selected\")\n }\n\n guard let workspace = workspaceRepository.workspaces.first(where: { $0.name == workspaceName }) else {\n return CommandResponse(success: false, error: \"Workspace not found\")\n }\n\n guard let app = findApp(app: app) else {\n return CommandResponse(\n success: false,\n error: \"App not found or not running. For not running apps use `assign-app --name `.\"\n )\n }\n\n let previousSetting = settings.changeWorkspaceOnAppAssign\n if let activate {\n settings.changeWorkspaceOnAppAssign = activate\n }\n workspaceManager.assignApp(app, to: workspace)\n if activate != nil {\n settings.changeWorkspaceOnAppAssign = previousSetting\n }\n\n if showNotification {\n Toast.showWith(\n icon: \"square.stack.3d.up\",\n message: \"\\(app.name) - Assigned To \\(workspace.name)\",\n textColor: .positive\n )\n }\n\n return CommandResponse(success: true)\n }\n\n private func floatApp(app: String?, showNotification: Bool) -> CommandResponse {\n guard let app = findApp(app: app) else {\n return CommandResponse(\n success: false,\n error: \"App not found or not running. For not running apps use `float-app --name `.\"\n )\n }\n\n floatingAppsSettings.addFloatingAppIfNeeded(app: app)\n\n if showNotification {\n Toast.showWith(\n icon: \"macwindow.on.rectangle\",\n message: \"\\(app.name) - Added To Floating Apps\",\n textColor: .positive\n )\n }\n\n return CommandResponse(success: true)\n }\n\n private func unfloatApp(app: String?, showNotification: Bool) -> CommandResponse {\n guard let app = findApp(app: app) else {\n return CommandResponse(\n success: false,\n error: \"App not found or not running. For not running apps use `unfloat-app --name `.\"\n )\n }\n\n guard floatingAppsSettings.floatingApps.containsApp(with: app.bundleIdentifier) else {\n return CommandResponse(success: true)\n }\n\n floatingAppsSettings.deleteFloatingApp(app: app)\n\n if let runningApp = NSWorkspace.shared.runningApplications.find(app),\n let screen = runningApp.display,\n workspaceManager.activeWorkspace[screen]?.apps.containsApp(runningApp) != true {\n runningApp.hide()\n }\n\n if showNotification {\n Toast.showWith(\n icon: \"macwindow\",\n message: \"\\(app.name) - Removed From Floating Apps\",\n textColor: .negative\n )\n }\n\n return CommandResponse(success: true)\n }\n\n private func toggleFloatApp(app: String?, showNotification: Bool) -> CommandResponse {\n guard let macApp = findApp(app: app) else {\n return CommandResponse(\n success: false,\n error: \"App not found or not running. For not running apps use `toggle-float-app --name `.\"\n )\n }\n\n let isFloating = floatingAppsSettings.floatingApps.containsApp(with: macApp.bundleIdentifier)\n\n return isFloating\n ? unfloatApp(app: app, showNotification: showNotification)\n : floatApp(app: app, showNotification: showNotification)\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Profile/CreateProfileCommand.swift", "//\n// CreateProfileCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct CreateProfileCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"create-profile\",\n abstract: \"Create a profile\"\n )\n\n @Argument(help: \"The name of the profile to create.\")\n var name: String\n\n @Flag(help: \"Copy the current profile\")\n var copy = false\n\n @Flag(help: \"Activate the new profile\")\n var activate = false\n\n func run() throws {\n sendCommand(.createProfile(name: name, copy: copy, activate: activate))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Workspaces/Models/Workspace.swift", "//\n// Workspace.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\n\ntypealias WorkspaceID = UUID\n\nstruct Workspace: Identifiable, Codable, Hashable {\n enum CodingKeys: String, CodingKey {\n case id\n case name\n case display\n case activateShortcut = \"shortcut\"\n case assignAppShortcut\n case apps\n case appToFocus\n case symbolIconName\n }\n\n var id: WorkspaceID\n var name: String\n var display: DisplayName\n var activateShortcut: AppHotKey?\n var assignAppShortcut: AppHotKey?\n var apps: [MacApp]\n var appToFocus: MacApp?\n var symbolIconName: String?\n}\n\nextension Workspace {\n var displays: Set {\n if NSScreen.screens.count == 1 {\n return [NSScreen.main?.localizedName ?? \"\"]\n } else if isDynamic {\n // TODO: After disconnecting a display, the detection may not work correctly.\n // The app will have the old coordinates until it is shown again, which\n // prevents from detecting the correct display.\n //\n // The workaround is to activate the app manually to update its frame.\n return NSWorkspace.shared.runningApplications\n .filter { $0.activationPolicy == .regular && apps.containsApp($0) }\n .flatMap(\\.allDisplays)\n .asSet\n } else {\n return [displayManager.resolveDisplay(display)]\n }\n }\n\n var displayForPrint: DisplayName {\n if isDynamic,\n let mainDisplay = NSScreen.main?.localizedName,\n displays.contains(mainDisplay) {\n return mainDisplay\n }\n\n return isDynamic\n ? displayManager.lastActiveDisplay(from: displays)\n : displayManager.resolveDisplay(display)\n }\n\n var isOnTheCurrentScreen: Bool {\n guard let currentScreen = NSScreen.main?.localizedName else { return false }\n return displays.contains(currentScreen)\n }\n\n var isDynamic: Bool {\n AppDependencies.shared.workspaceSettings.displayMode == .dynamic\n }\n\n private var displayManager: DisplayManager {\n AppDependencies.shared.displayManager\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/SpaceControl/Views/SpaceControlViewModel.swift", "//\n// SpaceControlViewModel.swift\n//\n// Created by Wojciech Kulik on 11/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport SwiftUI\n\nstruct SpaceControlWorkspace {\n let index: Int\n let name: String\n let symbol: String\n let screenshotData: Data?\n let isActive: Bool\n let originalWorkspace: Workspace\n}\n\nfinal class SpaceControlViewModel: ObservableObject {\n @Published private(set) var workspaces: [SpaceControlWorkspace] = []\n @Published private(set) var numberOfRows = 0\n @Published private(set) var numberOfColumns = 0\n\n private var cancellables = Set()\n\n private let settings = AppDependencies.shared.spaceControlSettings\n private let workspaceRepository = AppDependencies.shared.workspaceRepository\n private let workspaceManager = AppDependencies.shared.workspaceManager\n private let screenshotManager = AppDependencies.shared.workspaceScreenshotManager\n private let displayManager = AppDependencies.shared.displayManager\n\n init() {\n refresh()\n\n NotificationCenter.default\n .publisher(for: .spaceControlArrowDown)\n .compactMap { $0.object as? RawKeyCode }\n .sink { [weak self] in self?.handleArrowKey($0) }\n .store(in: &cancellables)\n }\n\n func onWorkspaceTap(_ workspace: SpaceControlWorkspace) {\n workspaceManager.activateWorkspace(workspace.originalWorkspace, setFocus: true)\n }\n\n func refresh() {\n let activeWorkspaceIds = workspaceManager.activeWorkspace.map(\\.value.id).asSet\n let mainDisplay = NSScreen.main?.localizedName ?? \"\"\n\n workspaces = Array(\n workspaceRepository.workspaces\n .filter { !settings.spaceControlCurrentDisplayWorkspaces || $0.isOnTheCurrentScreen }\n .prefix(15)\n .enumerated()\n .map {\n let workspace = $0.element\n let displayName = settings.spaceControlCurrentDisplayWorkspaces\n ? mainDisplay\n : self.mainDisplay(for: workspace)\n let key = WorkspaceScreenshotManager.ScreenshotKey(\n displayName: displayName,\n workspaceID: workspace.id\n )\n return SpaceControlWorkspace(\n index: $0.offset,\n name: workspace.name,\n symbol: workspace.symbolIconName ?? .defaultIconSymbol,\n screenshotData: screenshotManager.screenshots[key],\n isActive: activeWorkspaceIds.contains(workspace.id),\n originalWorkspace: workspace\n )\n }\n )\n calculateColsAndRows(workspaces.count)\n }\n\n private func mainDisplay(for workspace: Workspace) -> DisplayName {\n let workspaceDisplays = workspace.displays\n\n return workspaceDisplays.count == 1\n ? workspaceDisplays.first!\n : displayManager.lastActiveDisplay(from: workspaceDisplays)\n }\n\n private func calculateColsAndRows(_ workspaceCount: Int) {\n let maxNumberOfRows = 3.0\n\n numberOfColumns = workspaceCount <= 3\n ? workspaceCount\n : max(3, Int(ceil(Double(workspaceCount) / maxNumberOfRows)))\n numberOfColumns = min(numberOfColumns, settings.spaceControlMaxColumns)\n\n numberOfRows = Int(ceil(Double(workspaceCount) / Double(numberOfColumns)))\n }\n\n private func handleArrowKey(_ keyCode: RawKeyCode) {\n let activeWorkspaceIndex = workspaces.firstIndex {\n $0.isActive && $0.originalWorkspace.isOnTheCurrentScreen\n }\n guard let activeWorkspaceIndex else { return }\n\n let workspace: Workspace? = switch KeyCodesMap.toString[keyCode] {\n case \"down\":\n workspaces[safe: activeWorkspaceIndex + numberOfColumns]?.originalWorkspace\n case \"up\":\n workspaces[safe: activeWorkspaceIndex - numberOfColumns]?.originalWorkspace\n case \"right\":\n workspaces[safe: (activeWorkspaceIndex + 1) % workspaces.count]?.originalWorkspace\n case \"left\":\n workspaces[\n safe: activeWorkspaceIndex == 0\n ? workspaces.count - 1\n : activeWorkspaceIndex - 1\n ]?.originalWorkspace\n default:\n nil\n }\n\n if let workspace {\n SpaceControl.hide()\n workspaceManager.activateWorkspace(workspace, setFocus: true)\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Commands/GetCommands.swift", "//\n// GetCommands.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\n\nfinal class GetCommands: CommandExecutor {\n var workspaceManager: WorkspaceManager { AppDependencies.shared.workspaceManager }\n var profilesRepository: ProfilesRepository { AppDependencies.shared.profilesRepository }\n\n func execute(command: CommandRequest) -> CommandResponse? {\n switch command {\n case .getProfile:\n let result = profilesRepository.selectedProfile.name\n return CommandResponse(success: true, message: result)\n\n case .getWorkspace(let display):\n let workspace = workspaceManager.activeWorkspace[display ?? NSScreen.main?.localizedName ?? \"\"]\n if let workspace {\n let result = workspace.name\n return CommandResponse(success: true, message: result)\n } else {\n return CommandResponse(success: false, error: \"No active workspace\")\n }\n\n case .getApp(let withWindowsCount):\n if let app = NSWorkspace.shared.frontmostApplication, let appName = app.localizedName {\n if withWindowsCount {\n return CommandResponse(success: true, message: \"\\(appName)\\n\\(app.allWindows.count)\")\n } else {\n return CommandResponse(success: true, message: appName)\n }\n } else {\n return CommandResponse(success: false, error: \"No active app\")\n }\n\n case .getDisplay:\n if let display = NSScreen.main?.localizedName {\n return CommandResponse(success: true, message: display)\n } else {\n return CommandResponse(success: false, error: \"No display found\")\n }\n\n default:\n return nil\n }\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/SocketClient.swift", "//\n// SocketClient.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\nimport Network\n\nfinal class SocketClient {\n static let shared = SocketClient()\n\n private let socketPath = \"/tmp/flashspace.socket\"\n private var buffer = Data()\n private let jsonEncoder = JSONEncoder()\n\n private init() {}\n\n func sendCommand(_ command: CommandRequest) {\n let connection = NWConnection(to: .unix(path: socketPath), using: .tcp)\n connection.start(queue: .main)\n\n let messageData = command.encodeSocketData()\n connection.send(content: messageData, completion: .contentProcessed { error in\n if let error {\n connection.cancel()\n FlashSpaceCLI.exit(withError: CommandError.connectionError(error))\n }\n\n self.receiveData(connection: connection)\n })\n }\n\n private func receiveData(connection: NWConnection) {\n connection.receive(minimumIncompleteLength: 1, maximumLength: 10000) { data, _, isComplete, error in\n if let error {\n connection.cancel()\n FlashSpaceCLI.exit(withError: CommandError.connectionError(error))\n }\n\n if let data { self.buffer.append(data) }\n\n // Check if the message is complete or EOF is reached\n guard isComplete || data?.last == 0 else {\n return self.receiveData(connection: connection)\n }\n\n if self.buffer.isEmpty {\n connection.cancel()\n FlashSpaceCLI.exit(withError: CommandError.emptyResponse)\n }\n\n if let response = try? self.buffer.decodeSocketData(CommandResponse.self) {\n self.handleResponse(response, connection: connection)\n } else {\n FlashSpaceCLI.exit(withError: CommandError.operationFailed(\"Could not decode the response\"))\n }\n }\n }\n\n private func handleResponse(_ response: CommandResponse, connection: NWConnection) {\n if response.success {\n response.message.flatMap { print($0) }\n connection.cancel()\n FlashSpaceCLI.exit()\n } else {\n connection.cancel()\n FlashSpaceCLI.exit(withError: CommandError.operationFailed(response.error ?? \"Operation Failed\"))\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Workspaces/WorkspaceHotKeys.swift", "//\n// WorkspaceHotKeys.swift\n//\n// Created by Wojciech Kulik on 08/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nfinal class WorkspaceHotKeys {\n private let workspaceManager: WorkspaceManager\n private let workspaceRepository: WorkspaceRepository\n private let workspaceSettings: WorkspaceSettings\n private let floatingAppsSettings: FloatingAppsSettings\n\n init(\n workspaceManager: WorkspaceManager,\n workspaceRepository: WorkspaceRepository,\n settingsRepository: SettingsRepository\n ) {\n self.workspaceManager = workspaceManager\n self.workspaceRepository = workspaceRepository\n self.workspaceSettings = settingsRepository.workspaceSettings\n self.floatingAppsSettings = settingsRepository.floatingAppsSettings\n }\n\n func getHotKeys() -> [(AppHotKey, () -> ())] {\n let hotKeys = [\n getAssignVisibleAppsHotKey(),\n getAssignAppHotKey(for: nil),\n getUnassignAppHotKey(),\n getToggleAssignmentHotKey(),\n getHideUnassignedAppsHotKey(),\n getRecentWorkspaceHotKey(),\n getCycleWorkspacesHotKey(next: false),\n getCycleWorkspacesHotKey(next: true)\n ] +\n workspaceRepository.workspaces\n .flatMap { [getActivateHotKey(for: $0), getAssignAppHotKey(for: $0)] }\n\n return hotKeys.compactMap(\\.self)\n }\n\n private func getActivateHotKey(for workspace: Workspace) -> (AppHotKey, () -> ())? {\n guard let shortcut = workspace.activateShortcut else { return nil }\n\n let action = { [weak self] in\n guard let self, let updatedWorkspace = workspaceRepository.workspaces\n .first(where: { $0.id == workspace.id }) else { return }\n\n if updatedWorkspace.isDynamic, updatedWorkspace.displays.isEmpty {\n Toast.showWith(\n icon: \"square.stack.3d.up\",\n message: \"\\(workspace.name) - No Running Apps To Show\",\n textColor: .gray\n )\n return\n }\n\n workspaceManager.activateWorkspace(updatedWorkspace, setFocus: true)\n }\n\n return (shortcut, action)\n }\n\n private func getAssignVisibleAppsHotKey() -> (AppHotKey, () -> ())? {\n guard let shortcut = workspaceSettings.assignVisibleApps else { return nil }\n\n return (shortcut, { [weak self] in self?.assignVisibleApps() })\n }\n\n private func getAssignAppHotKey(for workspace: Workspace?) -> (AppHotKey, () -> ())? {\n let shortcut = workspace == nil\n ? workspaceSettings.assignFocusedApp\n : workspace?.assignAppShortcut\n\n guard let shortcut else { return nil }\n\n return (shortcut, { [weak self] in self?.assignApp(to: workspace) })\n }\n\n private func getUnassignAppHotKey() -> (AppHotKey, () -> ())? {\n guard let shortcut = workspaceSettings.unassignFocusedApp else { return nil }\n\n return (shortcut, { [weak self] in self?.unassignApp() })\n }\n\n private func getToggleAssignmentHotKey() -> (AppHotKey, () -> ())? {\n guard let shortcut = workspaceSettings.toggleFocusedAppAssignment else { return nil }\n\n let action = { [weak self] in\n guard let self, let activeApp = NSWorkspace.shared.frontmostApplication else { return }\n\n if workspaceRepository.workspaces.flatMap(\\.apps).containsApp(activeApp) {\n unassignApp()\n } else {\n assignApp(to: nil)\n }\n }\n\n return (shortcut, action)\n }\n\n private func getHideUnassignedAppsHotKey() -> (AppHotKey, () -> ())? {\n guard let shortcut = workspaceSettings.hideUnassignedApps else { return nil }\n\n let action = { [weak self] in\n guard let self else { return }\n\n workspaceManager.hideUnassignedApps()\n }\n\n return (shortcut, action)\n }\n\n private func getCycleWorkspacesHotKey(next: Bool) -> (AppHotKey, () -> ())? {\n guard let shortcut = next\n ? workspaceSettings.switchToNextWorkspace\n : workspaceSettings.switchToPreviousWorkspace\n else { return nil }\n\n let action: () -> () = { [weak self] in\n guard let self else { return }\n\n workspaceManager.activateWorkspace(\n next: next,\n skipEmpty: workspaceSettings.skipEmptyWorkspacesOnSwitch,\n loop: workspaceSettings.loopWorkspaces\n )\n }\n\n return (shortcut, action)\n }\n\n private func getRecentWorkspaceHotKey() -> (AppHotKey, () -> ())? {\n guard let shortcut = workspaceSettings.switchToRecentWorkspace else { return nil }\n\n let action: () -> () = { [weak self] in\n self?.workspaceManager.activateRecentWorkspace()\n }\n\n return (shortcut, action)\n }\n}\n\nextension WorkspaceHotKeys {\n private func assignApp(to workspace: Workspace?) {\n guard let activeApp = NSWorkspace.shared.frontmostApplication else { return }\n guard let appName = activeApp.localizedName else { return }\n guard activeApp.activationPolicy == .regular else {\n Alert.showOkAlert(\n title: appName,\n message: \"This application is an agent (runs in background) and cannot be managed by FlashSpace.\"\n )\n return\n }\n\n guard let workspace = workspace ?? workspaceManager.activeWorkspace[activeApp.display ?? \"\"] else {\n Alert.showOkAlert(\n title: \"Error\",\n message: \"No workspace is active on the current display.\"\n )\n return\n }\n\n guard let updatedWorkspace = workspaceRepository.workspaces\n .first(where: { $0.id == workspace.id }) else { return }\n\n workspaceManager.assignApp(activeApp.toMacApp, to: updatedWorkspace)\n\n if !workspace.isDynamic {\n activeApp.centerApp(display: workspace.display)\n }\n\n Toast.showWith(\n icon: \"square.stack.3d.up\",\n message: \"\\(appName) - Assigned To \\(workspace.name)\",\n textColor: .positive\n )\n }\n\n private func assignVisibleApps() {\n guard let display = NSScreen.main?.localizedName else { return }\n guard let workspace = workspaceManager.activeWorkspace[display] else {\n Alert.showOkAlert(\n title: \"Error\",\n message: \"No workspace is active on the current display.\"\n )\n return\n }\n\n let visibleApps = NSWorkspace.shared.runningApplications\n .regularVisibleApps(onDisplays: workspace.displays, excluding: floatingAppsSettings.floatingApps)\n\n workspaceManager.assignApps(visibleApps.map(\\.toMacApp), to: workspace)\n\n Toast.showWith(\n icon: \"square.stack.3d.up\",\n message: \"Assigned \\(visibleApps.count) App(s) To \\(workspace.name)\",\n textColor: .positive\n )\n }\n\n private func unassignApp() {\n guard let activeApp = NSWorkspace.shared.frontmostApplication else { return }\n guard let appName = activeApp.localizedName else { return }\n\n if workspaceRepository.workspaces.flatMap(\\.apps).containsApp(activeApp) == true {\n Toast.showWith(\n icon: \"square.stack.3d.up.slash\",\n message: \"\\(appName) - Removed From Workspaces\",\n textColor: .negative\n )\n }\n\n workspaceRepository.deleteAppFromAllWorkspaces(app: activeApp.toMacApp)\n activeApp.hide()\n NotificationCenter.default.post(name: .appsListChanged, object: nil)\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/List/ListAppsCommand.swift", "//\n// ListAppsCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct ListAppsCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"list-apps\",\n abstract: \"List workspace apps\"\n )\n\n @Argument(help: \"Workspace name\")\n var workspace: String\n\n @Option(help: \"Profile name\")\n var profile: String?\n\n @Flag(help: \"Include bundle id\")\n var withBundleId = false\n\n @Flag(help: \"Include icon\")\n var withIcon = false\n\n @Flag(help: \"Only running apps\")\n var onlyRunning = false\n\n func run() throws {\n sendCommand(.listApps(\n workspace: workspace,\n profile: profile,\n withBundleId: withBundleId,\n withIcon: withIcon,\n onlyRunning: onlyRunning\n ))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Profile/DeleteProfileCommand.swift", "//\n// DeleteProfileCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct DeleteProfileCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"delete-profile\",\n abstract: \"Delete a profile\"\n )\n\n @Argument(help: \"The name of the profile to delete.\")\n var name: String\n\n func run() throws {\n sendCommand(.deleteProfile(name: name))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Workspaces/WorkspacesSettingsView.swift", "//\n// WorkspacesSettingsView.swift\n//\n// Created by Wojciech Kulik on 24/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct WorkspacesSettingsView: View {\n @StateObject var settings = AppDependencies.shared.workspaceSettings\n @StateObject var viewModel = WorkspaceSettingsViewModel()\n\n var body: some View {\n Form {\n Section(\"Displays\") {\n Picker(\"Display Assignment Mode\", selection: $settings.displayMode) {\n ForEach(DisplayMode.allCases) { action in\n Text(action.description).tag(action)\n }\n }\n\n Text(\"Static Mode requires you to manually assign workspaces to displays.\\n\\n\" +\n \"Dynamic Mode automatically assigns workspaces to displays \" +\n \"based on where your applications are located. In this mode, a single workspace can span across multiple displays.\"\n )\n .font(.callout)\n .foregroundStyle(.secondary)\n }\n\n Section(\"Behaviors\") {\n Toggle(\"Activate Workspace On Focus Change\", isOn: $settings.activeWorkspaceOnFocusChange)\n Toggle(\"Center Cursor In Focused App On Workspace Change\", isOn: $settings.centerCursorOnWorkspaceChange)\n Toggle(\"Automatically Change Workspace On App Assignment\", isOn: $settings.changeWorkspaceOnAppAssign)\n Toggle(\"Keep Unassigned Apps On Workspace Change\", isOn: $settings.keepUnassignedAppsOnSwitch)\n Toggle(\"Show Hidden Apps On Workspace Activation\", isOn: $settings.restoreHiddenAppsOnSwitch)\n .help(\"Restores hidden apps, even if they were hidden manually\")\n Toggle(\"Enable Workspace Transition Animation\", isOn: $settings.enableWorkspaceTransitions)\n .help(\"Show a brief visual transition effect when switching between workspaces\")\n\n if settings.enableWorkspaceTransitions {\n HStack {\n VStack(alignment: .leading) {\n Text(\"Transition Duration\")\n Text(\"Controls how long the transition animation lasts when switching workspaces\")\n .font(.caption)\n .foregroundStyle(.secondary)\n }\n Spacer()\n Slider(value: $settings.workspaceTransitionDuration, in: 0.1...0.5, step: 0.05)\n .frame(width: 150)\n Text(\"\\(settings.workspaceTransitionDuration, specifier: \"%.2f\")s\")\n .foregroundStyle(.secondary)\n .frame(width: 45.0, alignment: .trailing)\n }\n .padding(.leading, 16)\n\n HStack {\n VStack(alignment: .leading) {\n Text(\"Transition Dimming\")\n Text(\"Adjusts how dark the screen becomes during workspace transitions\")\n .font(.caption)\n .foregroundStyle(.secondary)\n }\n Spacer()\n Slider(value: $settings.workspaceTransitionDimming, in: 0.05...0.5, step: 0.05)\n .frame(width: 150)\n Text(\"\\(Int(settings.workspaceTransitionDimming * 100))%\")\n .foregroundStyle(.secondary)\n .frame(width: 45.0, alignment: .trailing)\n }\n .padding(.leading, 16)\n }\n }\n\n Section(\"Shortcuts\") {\n hotkey(\"Assign Visible Apps (to active workspace)\", for: $settings.assignVisibleApps)\n hotkey(\"Assign Focused App (to active workspace)\", for: $settings.assignFocusedApp)\n hotkey(\"Unassign Focused App\", for: $settings.unassignFocusedApp)\n hotkey(\"Toggle Focused App Assignment\", for: $settings.toggleFocusedAppAssignment)\n hotkey(\"Hide Unassigned Apps\", for: $settings.hideUnassignedApps)\n }\n\n Section {\n hotkey(\"Recent Workspace\", for: $settings.switchToRecentWorkspace)\n hotkey(\"Previous Workspace\", for: $settings.switchToPreviousWorkspace)\n hotkey(\"Next Workspace\", for: $settings.switchToNextWorkspace)\n Toggle(\"Loop Workspaces\", isOn: $settings.loopWorkspaces)\n Toggle(\"Skip Empty Workspaces On Switch\", isOn: $settings.skipEmptyWorkspacesOnSwitch)\n Text(\n \"These shortcuts allow you to cycle through workspaces on the display where the cursor is currently located.\"\n )\n .foregroundStyle(.secondary)\n .font(.callout)\n }\n\n Section {\n HStack {\n Text(\"Alternative Displays\")\n TextField(\"\", text: $settings.alternativeDisplays)\n .foregroundColor(.secondary)\n .standardPlaceholder(settings.alternativeDisplays.isEmpty)\n }\n\n Text(\n \"\"\"\n Example: DELL XYZ=Benq ABC;LG 123=DELL XYZ\n\n This setting is useful if you want to use the same configuration for different displays.\n You can tell FlashSpace which display should be used if the selected one is not connected.\n\n If only one display is connected, it will always act as the fallback.\n \"\"\"\n )\n .foregroundStyle(.secondary)\n .font(.callout)\n }\n .hidden(settings.displayMode == .dynamic)\n\n Section(\"Picture-in-Picture\") {\n Toggle(\"Enable Picture-in-Picture Support\", isOn: $settings.enablePictureInPictureSupport)\n Toggle(\"Switch Workspace When Picture-in-Picture Closes\", isOn: $settings.switchWorkspaceWhenPipCloses)\n\n HStack {\n Text(\"Screen Corner Offset\")\n Spacer()\n Text(\"\\(settings.pipScreenCornerOffset)\")\n Stepper(\n \"\",\n value: $settings.pipScreenCornerOffset,\n in: 1...50,\n step: 1\n ).labelsHidden()\n }\n\n Text(\n \"If a supported browser has Picture-in-Picture active, other \" +\n \"windows will be hidden in a screen corner to keep PiP visible.\"\n )\n .foregroundStyle(.secondary)\n .font(.callout)\n }\n\n Section(header: pipAppsHeader) {\n if settings.pipApps.isEmpty {\n Text(\"You can apply Picture-in-Picture behavior to any app by adding it here.\")\n .foregroundStyle(.secondary)\n .font(.callout)\n } else {\n pipAppsList\n }\n }\n .opacity(settings.enablePictureInPictureSupport ? 1 : 0.5)\n }\n .sheet(isPresented: $viewModel.isInputDialogPresented) {\n InputDialog(\n title: \"Enter PiP window title regex:\",\n placeholder: \"e.g. Meeting with.*\",\n userInput: $viewModel.windowTitleRegex,\n isPresented: $viewModel.isInputDialogPresented\n )\n }\n .formStyle(.grouped)\n .navigationTitle(\"Workspaces\")\n }\n\n private var pipAppsList: some View {\n VStack(alignment: .leading) {\n ForEach(settings.pipApps, id: \\.self) { app in\n HStack {\n Button {\n viewModel.deletePipApp(app)\n } label: {\n Image(systemName: \"x.circle.fill\").opacity(0.8)\n }.buttonStyle(.borderless)\n\n Text(app.name)\n Spacer()\n Text(app.pipWindowTitleRegex)\n .foregroundColor(.secondary)\n }\n }\n }\n }\n\n private var pipAppsHeader: some View {\n HStack {\n Text(\"Custom Picture-in-Picture Apps\")\n Spacer()\n Button {\n viewModel.addPipApp()\n } label: {\n Image(systemName: \"plus\")\n }\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Displays/DisplayManager.swift", "//\n// DisplayManager.swift\n//\n// Created by Moritz Brödel on 19/06/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Combine\n\nfinal class DisplayManager: ObservableObject {\n struct Focus {\n let display: DisplayName\n let app: MacApp\n }\n\n private var focusHistory: [Focus] = []\n private let workspaceSettings: WorkspaceSettings\n\n init(settingsRepository: SettingsRepository) {\n self.workspaceSettings = settingsRepository.workspaceSettings\n }\n\n func lastFocusedDisplay(where condition: (Focus) -> Bool) -> Focus? {\n focusHistory.last(where: condition)\n }\n\n func trackDisplayFocus(on display: DisplayName, for application: NSRunningApplication) {\n guard !application.isFinder || application.allWindows.isNotEmpty else { return }\n\n focusHistory.removeAll { $0.display == display }\n focusHistory.append(.init(display: display, app: application.toMacApp))\n }\n\n func getCursorScreen() -> DisplayName? {\n let cursorLocation = NSEvent.mouseLocation\n return NSScreen.screens\n .first { NSMouseInRect(cursorLocation, $0.frame, false) }?\n .localizedName\n }\n\n func resolveDisplay(_ display: DisplayName) -> DisplayName {\n guard !NSScreen.isConnected(display) else { return display }\n\n let alternativeDisplays = workspaceSettings.alternativeDisplays\n .split(separator: \";\")\n .map { $0.split(separator: \"=\") }\n .compactMap { pair -> (source: String, target: String)? in\n guard pair.count == 2 else { return nil }\n return (String(pair[0]).trimmed, String(pair[1]).trimmed)\n }\n\n let alternative = alternativeDisplays\n .filter { $0.source == display }\n .map(\\.target)\n .first(where: NSScreen.isConnected)\n\n return alternative ?? NSScreen.main?.localizedName ?? \"\"\n }\n\n func lastActiveDisplay(from candidates: Set) -> DisplayName {\n if let recentDisplay = lastFocusedDisplay(where: { candidates.contains($0.display) })?.display {\n return recentDisplay\n }\n\n if let cursorDisplay = getCursorScreen(), candidates.contains(cursorDisplay) {\n return cursorDisplay\n }\n\n return candidates.first ?? NSScreen.main?.localizedName ?? \"\"\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/MainScreen/MainViewModel.swift", "//\n// MainViewModel.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Combine\nimport SwiftUI\n\nfinal class MainViewModel: ObservableObject {\n @Published var workspaces: [Workspace] = [] {\n didSet {\n guard workspaces.count == oldValue.count,\n workspaces.map(\\.id) != oldValue.map(\\.id) else { return }\n\n workspaceRepository.reorderWorkspaces(newOrder: workspaces.map(\\.id))\n }\n }\n\n @Published var workspaceApps: [MacApp]?\n\n @Published var workspaceName = \"\"\n @Published var workspaceShortcut: AppHotKey? {\n didSet { saveWorkspace() }\n }\n\n @Published var workspaceAssignShortcut: AppHotKey? {\n didSet { saveWorkspace() }\n }\n\n @Published var workspaceDisplay = \"\" {\n didSet { saveWorkspace() }\n }\n\n @Published var workspaceAppToFocus: MacApp? = AppConstants.lastFocusedOption {\n didSet { saveWorkspace() }\n }\n\n @Published var workspaceSymbolIconName: String? {\n didSet { saveWorkspace() }\n }\n\n @Published var isSymbolPickerPresented = false\n @Published var isInputDialogPresented = false\n @Published var userInput = \"\"\n\n var focusAppOptions: [MacApp] {\n [AppConstants.lastFocusedOption] + (workspaceApps ?? [])\n }\n\n var selectedApps: Set = [] {\n didSet {\n // To avoid warnings\n DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) { [self] in\n objectWillChange.send()\n }\n }\n }\n\n var selectedWorkspaces: Set = [] {\n didSet {\n selectedWorkspace = selectedWorkspaces.count == 1\n ? selectedWorkspaces.first\n : nil\n\n // To avoid warnings\n DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) { [self] in\n if selectedWorkspaces.count == 1,\n selectedWorkspaces.first?.id != oldValue.first?.id {\n selectedApps = []\n } else if selectedWorkspaces.count != 1 {\n selectedApps = []\n }\n objectWillChange.send()\n }\n }\n }\n\n private(set) var selectedWorkspace: Workspace? {\n didSet {\n guard selectedWorkspace != oldValue else { return }\n\n // To avoid warnings\n DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) {\n self.updateSelectedWorkspace()\n }\n }\n }\n\n var screens: [String] {\n let set = NSScreen.screens.compactMap(\\.localizedName).asSet\n let otherScreens = workspaces.map(\\.display)\n\n return Array(set.union(otherScreens))\n .filter(\\.isNotEmpty)\n .sorted()\n }\n\n var displayMode: DisplayMode { workspaceSettings.displayMode }\n\n private var cancellables: Set = []\n private var loadingWorkspace = false\n\n private let workspaceManager = AppDependencies.shared.workspaceManager\n private let workspaceRepository = AppDependencies.shared.workspaceRepository\n private let workspaceSettings = AppDependencies.shared.workspaceSettings\n\n init() {\n self.workspaces = workspaceRepository.workspaces\n self.workspaceDisplay = NSScreen.main?.localizedName ?? \"\"\n\n observe()\n }\n\n private func observe() {\n NotificationCenter.default\n .publisher(for: .appsListChanged)\n .sink { [weak self] _ in self?.reloadWorkspaces() }\n .store(in: &cancellables)\n\n NotificationCenter.default\n .publisher(for: .profileChanged)\n .sink { [weak self] _ in self?.reloadWorkspaces() }\n .store(in: &cancellables)\n\n workspaceSettings.updatePublisher\n .compactMap { [weak self] in self?.workspaceSettings.displayMode }\n .removeDuplicates()\n .sink { [weak self] _ in self?.objectWillChange.send() }\n .store(in: &cancellables)\n }\n\n private func updateSelectedWorkspace() {\n loadingWorkspace = true\n defer { loadingWorkspace = false }\n\n workspaceName = selectedWorkspace?.name ?? \"\"\n workspaceShortcut = selectedWorkspace?.activateShortcut\n workspaceAssignShortcut = selectedWorkspace?.assignAppShortcut\n workspaceDisplay = selectedWorkspace?.display ?? NSScreen.main?.localizedName ?? \"\"\n workspaceApps = selectedWorkspace?.apps\n workspaceAppToFocus = selectedWorkspace?.appToFocus ?? AppConstants.lastFocusedOption\n workspaceSymbolIconName = selectedWorkspace?.symbolIconName\n selectedWorkspace.flatMap { selectedWorkspaces = [$0] }\n }\n\n private func reloadWorkspaces() {\n workspaces = workspaceRepository.workspaces\n if let selectedWorkspace, let workspace = workspaces.first(where: { $0.id == selectedWorkspace.id }) {\n selectedWorkspaces = [workspace]\n } else {\n selectedWorkspaces = []\n }\n selectedApps = []\n }\n}\n\nextension MainViewModel {\n func saveWorkspace() {\n guard let selectedWorkspace, !loadingWorkspace else { return }\n\n if workspaceName.trimmingCharacters(in: .whitespaces).isEmpty {\n workspaceName = \"(empty)\"\n }\n\n let updatedWorkspace = Workspace(\n id: selectedWorkspace.id,\n name: workspaceName,\n display: workspaceDisplay,\n activateShortcut: workspaceShortcut,\n assignAppShortcut: workspaceAssignShortcut,\n apps: selectedWorkspace.apps,\n appToFocus: workspaceAppToFocus == AppConstants.lastFocusedOption ? nil : workspaceAppToFocus,\n symbolIconName: workspaceSymbolIconName\n )\n\n workspaceRepository.updateWorkspace(updatedWorkspace)\n workspaces = workspaceRepository.workspaces\n self.selectedWorkspace = workspaces.first { $0.id == selectedWorkspace.id }\n }\n\n func addWorkspace() {\n userInput = \"\"\n isInputDialogPresented = true\n\n $isInputDialogPresented\n .first { !$0 }\n .sink { [weak self] _ in\n guard let self, !self.userInput.isEmpty else { return }\n\n self.workspaceRepository.addWorkspace(name: self.userInput)\n self.workspaces = self.workspaceRepository.workspaces\n self.selectedWorkspace = self.workspaces.last\n }\n .store(in: &cancellables)\n }\n\n func deleteSelectedWorkspaces() {\n guard !selectedWorkspaces.isEmpty else { return }\n\n workspaceRepository.deleteWorkspaces(ids: selectedWorkspaces.map(\\.id).asSet)\n workspaces = workspaceRepository.workspaces\n selectedWorkspaces = []\n }\n\n func addApp() {\n guard let selectedWorkspace else { return }\n\n let fileChooser = FileChooser()\n let appUrl = fileChooser.runModalOpenPanel(\n allowedFileTypes: [.application],\n directoryURL: URL(filePath: \"/Applications\")\n )\n\n guard let appUrl else { return }\n\n let appName = appUrl.appName\n let appBundleId = appUrl.bundleIdentifier ?? \"\"\n let runningApp = NSWorkspace.shared.runningApplications.first { $0.bundleIdentifier == appBundleId }\n let isAgent = appUrl.bundle?.isAgent == true && (runningApp == nil || runningApp?.activationPolicy != .regular)\n\n guard !isAgent else {\n Alert.showOkAlert(\n title: appName,\n message: \"This application is an agent (runs in background) and cannot be managed by FlashSpace.\"\n )\n return\n }\n\n guard !selectedWorkspace.apps.containsApp(with: appBundleId) else { return }\n\n workspaceRepository.addApp(\n to: selectedWorkspace.id,\n app: .init(\n name: appName,\n bundleIdentifier: appBundleId,\n iconPath: appUrl.iconPath\n )\n )\n\n workspaces = workspaceRepository.workspaces\n self.selectedWorkspace = workspaces.first { $0.id == selectedWorkspace.id }\n\n workspaceManager.activateWorkspaceIfActive(selectedWorkspace.id)\n }\n\n func deleteSelectedApps() {\n guard let selectedWorkspace, !selectedApps.isEmpty else { return }\n\n let selectedApps = Array(selectedApps)\n\n for app in selectedApps {\n workspaceRepository.deleteApp(\n from: selectedWorkspace.id,\n app: app,\n notify: app == selectedApps.last\n )\n }\n\n workspaces = workspaceRepository.workspaces\n self.selectedWorkspace = workspaces.first { $0.id == selectedWorkspace.id }\n workspaceApps = self.selectedWorkspace?.apps\n self.selectedApps = []\n\n workspaceManager.activateWorkspaceIfActive(selectedWorkspace.id)\n }\n\n func resetWorkspaceSymbolIcon() {\n workspaceSymbolIconName = nil\n saveWorkspace()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Get/GetDisplayCommand.swift", "//\n// GetDisplayCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport ArgumentParser\nimport Foundation\n\nstruct GetDisplayCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"get-display\",\n abstract: \"Get active display\"\n )\n\n func run() throws {\n sendCommand(.getDisplay)\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/List/ListRunningAppsCommand.swift", "//\n// ListRunningAppsCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport ArgumentParser\nimport Foundation\n\nstruct ListRunningAppsCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"list-running-apps\",\n abstract: \"List running apps\"\n )\n\n @Flag(help: \"Include bundle id\")\n var withBundleId = false\n\n func run() throws {\n let apps = NSWorkspace.shared.runningApplications\n .filter { $0.activationPolicy == .regular }\n\n let result = Set(apps)\n .filter { $0.localizedName != nil }\n .map { (bundleId: $0.bundleIdentifier ?? \"-\", name: $0.localizedName ?? \"-\") }\n .sorted { $0.name.lowercased() < $1.name.lowercased() }\n .map { app in\n if withBundleId {\n return [app.name, app.bundleId].joined(separator: \",\")\n } else {\n return app.name\n }\n }\n .joined(separator: \"\\n\")\n print(result)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/FocusManager/FocusedWindowTracker.swift", "//\n// FocusedWindowTracker.swift\n//\n// Created by Wojciech Kulik on 20/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Combine\n\nfinal class FocusedWindowTracker {\n private var cancellables = Set()\n\n private let workspaceRepository: WorkspaceRepository\n private let workspaceManager: WorkspaceManager\n private let settingsRepository: SettingsRepository\n private let pictureInPictureManager: PictureInPictureManager\n\n init(\n workspaceRepository: WorkspaceRepository,\n workspaceManager: WorkspaceManager,\n settingsRepository: SettingsRepository,\n pictureInPictureManager: PictureInPictureManager\n ) {\n self.workspaceRepository = workspaceRepository\n self.workspaceManager = workspaceManager\n self.settingsRepository = settingsRepository\n self.pictureInPictureManager = pictureInPictureManager\n }\n\n func startTracking() {\n NSWorkspace.shared.notificationCenter\n .publisher(for: NSWorkspace.didActivateApplicationNotification)\n .compactMap { $0.userInfo?[NSWorkspace.applicationUserInfoKey] as? NSRunningApplication }\n .removeDuplicates()\n .sink { [weak self] app in self?.activeApplicationChanged(app) }\n .store(in: &cancellables)\n }\n\n func stopTracking() {\n cancellables.removeAll()\n }\n\n private func activeApplicationChanged(_ app: NSRunningApplication) {\n guard settingsRepository.workspaceSettings.activeWorkspaceOnFocusChange else { return }\n\n let activeWorkspaces = workspaceManager.activeWorkspace.values\n\n // Skip if the workspace was activated recently\n guard Date().timeIntervalSince(workspaceManager.lastWorkspaceActivation) > 0.2 else { return }\n\n // Skip if the app is floating\n guard !settingsRepository.floatingAppsSettings.floatingApps.containsApp(app) else { return }\n\n // Find the workspace that contains the app.\n // The same app can be in multiple workspaces, the highest priority has the one\n // from the active workspace.\n guard let workspace = (activeWorkspaces + workspaceRepository.workspaces)\n .first(where: { $0.apps.containsApp(app) }) else { return }\n\n // Skip if the workspace is already active\n guard activeWorkspaces.count(where: { $0.id == workspace.id }) < workspace.displays.count else { return }\n\n // Skip if the focused window is in Picture in Picture mode\n guard !settingsRepository.workspaceSettings.enablePictureInPictureSupport ||\n !app.supportsPictureInPicture ||\n app.focusedWindow?.isPictureInPicture(bundleId: app.bundleIdentifier) != true else { return }\n\n let activate = { [self] in\n Logger.log(\"\")\n Logger.log(\"\")\n Logger.log(\"Activating workspace for app: \\(workspace.name)\")\n workspaceManager.updateLastFocusedApp(app.toMacApp, in: workspace)\n workspaceManager.activateWorkspace(workspace, setFocus: false)\n app.activate()\n\n // Restore the app if it was hidden\n if settingsRepository.workspaceSettings.enablePictureInPictureSupport, app.supportsPictureInPicture {\n pictureInPictureManager.restoreAppIfNeeded(app: app)\n }\n }\n\n if workspace.isDynamic, workspace.displays.isEmpty {\n DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(500)) {\n activate()\n }\n } else {\n activate()\n }\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Profile/ProfileCommand.swift", "//\n// ProfileCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct ProfileCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"profile\",\n abstract: \"Activate a profile\"\n )\n\n @Argument(help: \"Profile name.\")\n var name: String\n\n func run() throws {\n sendCommand(.activateProfile(name: name))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Commands/ListCommands.swift", "//\n// ListCommands.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\n\nfinal class ListCommands: CommandExecutor {\n var workspaceRepository: WorkspaceRepository { AppDependencies.shared.workspaceRepository }\n var profilesRepository: ProfilesRepository { AppDependencies.shared.profilesRepository }\n var settingsRepository: SettingsRepository { AppDependencies.shared.settingsRepository }\n\n // swiftlint:disable:next function_body_length\n func execute(command: CommandRequest) -> CommandResponse? {\n switch command {\n case .listWorkspaces(let withDisplay, let profileName):\n let profile = profileName != nil\n ? profilesRepository.profiles.first { $0.name == profileName }\n : profilesRepository.selectedProfile\n\n if let profile {\n let result: String\n\n if withDisplay {\n result = profile.workspaces.map {\n let displays = $0.displays.joined(separator: \",\")\n return \"\\($0.name),\\(displays.isEmpty ? \"None\" : displays)\"\n }.joined(separator: \"\\n\")\n } else {\n result = profile.workspaces.map(\\.name).joined(separator: \"\\n\")\n }\n\n return CommandResponse(success: true, message: result)\n } else {\n return CommandResponse(success: false, error: \"Profile not found\")\n }\n\n case .listProfiles:\n let result = profilesRepository.profiles.map(\\.name).joined(separator: \"\\n\")\n return CommandResponse(success: true, message: result)\n\n case .listApps(let workspace, let profileName, let withBundleId, let withIcon, let onlyRunning):\n let profile = profileName != nil\n ? profilesRepository.profiles.first { $0.name == profileName }\n : profilesRepository.selectedProfile\n\n guard let profile else {\n return CommandResponse(success: false, error: \"Profile not found\")\n }\n\n guard let workspace = profile.workspaces.first(where: { $0.name == workspace }) else {\n return CommandResponse(success: false, error: \"Workspace not found\")\n }\n\n let runningApps = NSWorkspace.shared.runningApplications.map(\\.bundleIdentifier).asSet\n\n let result = workspace.apps\n .filter { !onlyRunning || runningApps.contains($0.bundleIdentifier) }\n .map { app in\n [\n app.name,\n withBundleId ? app.bundleIdentifier : nil,\n withIcon ? app.iconPath ?? \"\" : nil\n ].compactMap { $0 }.joined(separator: \",\")\n }\n .joined(separator: \"\\n\")\n\n return CommandResponse(success: true, message: result)\n\n case .listFloatingApps(let withBundleId):\n let floatingApps = settingsRepository.floatingAppsSettings.floatingApps\n .map { app in\n [\n app.name,\n withBundleId ? app.bundleIdentifier : nil\n ].compactMap { $0 }.joined(separator: \",\")\n }\n .joined(separator: \"\\n\")\n\n return CommandResponse(success: true, message: floatingApps)\n\n default:\n return nil\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/MenuBar/MenuBarSettingsView.swift", "//\n// MenuBarSettingsView.swift\n//\n// Created by Wojciech Kulik on 31/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct MenuBarSettingsView: View {\n @StateObject var settings = AppDependencies.shared.menuBarSettings\n\n var body: some View {\n Form {\n Section {\n Toggle(\"Show Title\", isOn: $settings.showMenuBarTitle)\n Toggle(\"Show Icon\", isOn: $settings.showMenuBarIcon)\n .disabled(!settings.showMenuBarTitle)\n\n HStack {\n Text(\"Title Template\")\n TextField(\"\", text: $settings.menuBarTitleTemplate)\n .foregroundColor(.secondary)\n .standardPlaceholder(settings.menuBarTitleTemplate.isEmpty)\n }\n .disabled(!settings.showMenuBarTitle)\n .opacity(settings.showMenuBarTitle ? 1 : 0.5)\n\n Text(\n \"\"\"\n $WORKSPACE will be replaced with the active workspace name\n $WORKSPACE_NUMBER will be replaced with the active workspace number\n $DISPLAY will be replaced with the corresponding display name\n $PROFILE will be replaced with the active profile name\n \"\"\"\n )\n .foregroundStyle(.secondary)\n .font(.callout)\n .opacity(settings.showMenuBarTitle ? 1 : 0.5)\n }\n\n Section {\n HStack {\n Text(\"Display Aliases\")\n TextField(\"\", text: $settings.menuBarDisplayAliases)\n .foregroundColor(.secondary)\n .standardPlaceholder(settings.menuBarDisplayAliases.isEmpty)\n }\n .disabled(!settings.showMenuBarTitle)\n .opacity(settings.showMenuBarTitle ? 1 : 0.5)\n\n Text(\"Example: DELL U2723QE=Secondary;Built-in Retina Display=Main\")\n .foregroundStyle(.secondary)\n .font(.callout)\n .opacity(settings.showMenuBarTitle ? 1 : 0.5)\n }\n }\n .formStyle(.grouped)\n .navigationTitle(\"Menu Bar\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Integrations/IntegrationsSettingsView.swift", "//\n// IntegrationsSettingsView.swift\n//\n// Created by Wojciech Kulik on 24/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct IntegrationsSettingsView: View {\n @StateObject var settings = AppDependencies.shared.integrationsSettings\n\n var body: some View {\n Form {\n Section {\n Toggle(\"Enable Integrations\", isOn: $settings.enableIntegrations)\n }\n\n Section(\"Scripts To Run\") {\n HStack {\n Text(\"On App Launch\")\n TextField(\"\", text: $settings.runScriptOnLaunch)\n .foregroundColor(.secondary)\n .standardPlaceholder(settings.runScriptOnLaunch.isEmpty)\n }\n\n HStack {\n Text(\"On Workspace Change\")\n TextField(\"\", text: $settings.runScriptOnWorkspaceChange)\n .foregroundColor(.secondary)\n .standardPlaceholder(settings.runScriptOnWorkspaceChange.isEmpty)\n }\n\n HStack {\n Text(\"On Profile Change\")\n TextField(\"\", text: $settings.runScriptOnProfileChange)\n .foregroundColor(.secondary)\n .standardPlaceholder(settings.runScriptOnProfileChange.isEmpty)\n }\n\n Text(\n \"\"\"\n $WORKSPACE will be replaced with the active workspace name\n $WORKSPACE_NUMBER will be replaced with the active workspace number\n $DISPLAY will be replaced with the corresponding display name\n $PROFILE will be replaced with the active profile name\n \"\"\"\n )\n .foregroundStyle(.secondary)\n .font(.callout)\n }\n .disabled(!settings.enableIntegrations)\n .opacity(settings.enableIntegrations ? 1 : 0.5)\n }\n .formStyle(.grouped)\n .navigationTitle(\"Integrations\")\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Models/CommandError.swift", "//\n// CommandError.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nenum CommandError: Error, LocalizedError {\n case timeout\n case connectionError(Error)\n case emptyResponse\n case couldNotEncode(Error)\n case operationFailed(String)\n case missingArgument\n case other\n\n var errorDescription: String? {\n switch self {\n case .timeout:\n return \"Timeout. Please check if FlashSpace is running.\"\n case .connectionError(let error):\n return \"Connection error. Please check if FlashSpace is running.\\n\\(error)\"\n case .emptyResponse:\n return \"Empty response. Please check if FlashSpace is running.\"\n case .couldNotEncode(let error):\n return \"Could not encode the message. Please try again.\\n\\(error)\"\n case .operationFailed(let message):\n return message\n case .missingArgument:\n return \"Missing argument(s). Please provide the required argument(s).\"\n case .other:\n return \"\"\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/MenuBar/MenuBarTitle.swift", "//\n// MenuBarTitle.swift\n//\n// Created by Wojciech Kulik on 31/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nenum MenuBarTitle {\n static let settings = AppDependencies.shared.menuBarSettings\n static let workspaceManager = AppDependencies.shared.workspaceManager\n static let profilesRepository = AppDependencies.shared.profilesRepository\n\n static func get() -> String? {\n let template = settings.menuBarTitleTemplate.trimmingCharacters(in: .whitespaces)\n\n guard settings.showMenuBarTitle, !template.isEmpty else { return nil }\n guard let activeWorkspace = workspaceManager.activeWorkspaceDetails else { return nil }\n\n return template\n .replacingOccurrences(of: \"$WORKSPACE_NUMBER\", with: activeWorkspace.number ?? \"\")\n .replacingOccurrences(of: \"$WORKSPACE\", with: activeWorkspace.name)\n .replacingOccurrences(of: \"$DISPLAY\", with: getDisplayName())\n .replacingOccurrences(of: \"$PROFILE\", with: profilesRepository.selectedProfile.name)\n }\n\n private static func getDisplayName() -> String {\n let aliases = settings.menuBarDisplayAliases\n .split(separator: \";\")\n .map { $0.split(separator: \"=\") }\n .reduce(into: [String: String]()) { result, pair in\n guard pair.count == 2 else { return }\n\n result[String(pair[0]).lowercased()] = String(pair[1])\n }\n\n let display = workspaceManager.activeWorkspaceDetails?.display ?? \"\"\n\n return aliases[display.lowercased()] ?? display\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Models/UpdateWorkspaceRequest.swift", "//\n// UpdateWorkspaceRequest.swift\n//\n// Created by Wojciech Kulik on 02/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nstruct UpdateWorkspaceRequest: Codable {\n enum Display: Codable {\n case active\n case name(String)\n }\n\n let name: String?\n let display: Display?\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Get/GetAppCommand.swift", "//\n// GetAppCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport ArgumentParser\nimport Foundation\n\nstruct GetAppCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"get-app\",\n abstract: \"Get active app\"\n )\n\n @Flag(help: \"Include windows count\")\n var withWindowsCount = false\n\n func run() throws {\n sendCommand(.getApp(withWindowsCount: withWindowsCount))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Workspaces/WorkspaceRepository.swift", "//\n// WorkspaceRepository.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Combine\nimport Foundation\n\nfinal class WorkspaceRepository: ObservableObject {\n @Published private(set) var workspaces: [Workspace] = []\n\n private let profilesRepository: ProfilesRepository\n\n init(profilesRepository: ProfilesRepository) {\n self.profilesRepository = profilesRepository\n self.workspaces = profilesRepository.selectedProfile.workspaces\n\n profilesRepository.onProfileChange = { [weak self] profile in\n self?.workspaces = profile.workspaces\n }\n }\n\n func addWorkspace(name: String) {\n let workspace = Workspace(\n id: .init(),\n name: name,\n display: NSScreen.main?.localizedName ?? \"\",\n activateShortcut: nil,\n assignAppShortcut: nil,\n apps: []\n )\n workspaces.append(workspace)\n notifyAboutChanges()\n }\n\n func addWorkspace(_ workspace: Workspace) {\n workspaces.append(workspace)\n notifyAboutChanges()\n }\n\n func updateWorkspace(_ workspace: Workspace) {\n guard let workspaceIndex = workspaces.firstIndex(where: { $0.id == workspace.id }) else { return }\n\n workspaces[workspaceIndex] = workspace\n notifyAboutChanges()\n AppDependencies.shared.hotKeysManager.refresh()\n }\n\n func deleteWorkspace(id: WorkspaceID) {\n workspaces.removeAll { $0.id == id }\n notifyAboutChanges()\n }\n\n func deleteWorkspaces(ids: Set) {\n workspaces.removeAll { ids.contains($0.id) }\n notifyAboutChanges()\n }\n\n func addApp(to workspaceId: WorkspaceID, app: MacApp) {\n guard let workspaceIndex = workspaces.firstIndex(where: { $0.id == workspaceId }) else { return }\n guard !workspaces[workspaceIndex].apps.contains(app) else { return }\n\n workspaces[workspaceIndex].apps.append(app)\n notifyAboutChanges()\n }\n\n func deleteApp(from workspaceId: WorkspaceID, app: MacApp, notify: Bool = true) {\n guard let workspaceIndex = workspaces.firstIndex(where: { $0.id == workspaceId }) else { return }\n\n if workspaces[workspaceIndex].appToFocus == app {\n workspaces[workspaceIndex].appToFocus = nil\n }\n\n workspaces[workspaceIndex].apps.removeAll { $0 == app }\n if notify { notifyAboutChanges() }\n }\n\n func deleteAppFromAllWorkspaces(app: MacApp) {\n for (index, var workspace) in workspaces.enumerated() {\n workspace.apps.removeAll { $0 == app }\n if workspace.appToFocus == app {\n workspace.appToFocus = nil\n }\n\n workspaces[index] = workspace\n }\n notifyAboutChanges()\n }\n\n func reorderWorkspaces(newOrder: [WorkspaceID]) {\n let map = newOrder.enumerated().reduce(into: [WorkspaceID: Int]()) { $0[$1.element] = $1.offset }\n workspaces = workspaces.sorted { map[$0.id] ?? 0 < map[$1.id] ?? 0 }\n notifyAboutChanges()\n }\n\n func moveApps(_ apps: [MacApp], from sourceWorkspaceId: WorkspaceID, to targetWorkspaceId: WorkspaceID) {\n guard let sourceWorkspaceIndex = workspaces.firstIndex(where: { $0.id == sourceWorkspaceId }),\n let targetWorkspaceIndex = workspaces.firstIndex(where: { $0.id == targetWorkspaceId }) else { return }\n\n if let appToFocus = workspaces[sourceWorkspaceIndex].appToFocus, apps.contains(appToFocus) {\n workspaces[sourceWorkspaceIndex].appToFocus = nil\n }\n\n let targetAppBundleIds = workspaces[targetWorkspaceIndex].apps.map(\\.bundleIdentifier).asSet\n let appsToAdd = apps.filter { !targetAppBundleIds.contains($0.bundleIdentifier) }\n\n workspaces[sourceWorkspaceIndex].apps.removeAll { apps.contains($0) }\n workspaces[targetWorkspaceIndex].apps.append(contentsOf: appsToAdd)\n\n notifyAboutChanges()\n NotificationCenter.default.post(name: .appsListChanged, object: nil)\n }\n\n private func notifyAboutChanges() {\n profilesRepository.updateWorkspaces(workspaces)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/SpaceControl/SpaceControl.swift", "//\n// SpaceControl.swift\n//\n// Created by Wojciech Kulik on 11/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport SwiftUI\n\nenum SpaceControl {\n static var isEnabled: Bool { settings.enableSpaceControl }\n static var isVisible: Bool { window != nil }\n static var window: NSWindow?\n\n private static var settings: SpaceControlSettings { AppDependencies.shared.spaceControlSettings }\n private static var focusedAppBeforeShow: NSRunningApplication?\n\n static func getHotKey() -> (AppHotKey, () -> ())? {\n guard isEnabled else { return nil }\n\n if let spaceControlHotKey = settings.showSpaceControl {\n return (spaceControlHotKey, toggle)\n }\n\n return nil\n }\n\n static func toggle() {\n if isVisible {\n hide(restoreFocus: true)\n } else {\n show()\n }\n }\n\n static func hide(restoreFocus: Bool = false) {\n window?.orderOut(nil)\n window = nil\n\n if restoreFocus {\n focusedAppBeforeShow?.activate()\n focusedAppBeforeShow = nil\n }\n }\n\n static func show() {\n guard validate() else { return }\n\n PermissionsManager.shared.askForScreenRecordingPermissions()\n\n if Self.window != nil { hide() }\n\n let contentView = NSHostingView(\n rootView: SpaceControlView()\n )\n\n // contentRect is in screen coordinates where (0,0) is bottom-left corner\n // and it is relative to the main screen.\n let window = SpaceControlWindow(\n contentRect: NSScreen.main!.frame,\n styleMask: [.borderless],\n backing: .buffered,\n defer: false\n )\n window.isOpaque = false\n window.backgroundColor = .clear\n window.level = .screenSaver\n window.delegate = window\n Self.window = window\n\n let animations = settings.enableSpaceControlAnimations\n\n window.contentView = contentView.addVisualEffect(material: .fullScreenUI)\n window.alphaValue = animations ? 0 : 1\n\n focusedAppBeforeShow = NSWorkspace.shared.frontmostApplication\n NSApp.activate(ignoringOtherApps: true)\n window.orderFrontRegardless()\n window.makeKeyAndOrderFront(nil)\n\n if animations {\n window.animator().alphaValue = 1\n }\n }\n\n private static func validate() -> Bool {\n let workspaces = AppDependencies.shared.workspaceRepository.workspaces\n let nonEmptyWorkspaces = workspaces\n .filter { !settings.spaceControlCurrentDisplayWorkspaces || $0.isOnTheCurrentScreen }\n\n if nonEmptyWorkspaces.count < 2 {\n Alert.showOkAlert(title: \"Space Control\", message: \"You need at least 2 workspaces to use Space Control.\")\n return false\n }\n\n return true\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Acknowledgements/Licenses.swift", "//\n// Licenses.swift\n//\n// Created by Wojciech Kulik on 26/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nenum Licenses {\n static let swiftFormat = \"\"\"\n SwiftFormat\n\n Authors: Nick Lockwood\n Project URL: https://github.com/nicklockwood/SwiftFormat\n License URL: https://github.com/nicklockwood/SwiftFormat/blob/main/LICENSE.md\n\n MIT License\n\n Copyright (c) 2016 Nick Lockwood\n\n Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n \"\"\"\n\n static let swiftLint = \"\"\"\n SwiftLint\n\n Authors: The SwiftLint Contributors\n Project URL: https://github.com/realm/SwiftLint/\n License URL: https://github.com/realm/SwiftLint/blob/master/LICENSE\n\n The MIT License (MIT)\n\n Copyright (c) 2025 The SwiftLint Contributors.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n \"\"\"\n\n static let symbolPicker = \"\"\"\n SymbolPicker\n\n Authors: Yubo Qin & Lakr Aream\n Project URL: https://github.com/xnth97/SymbolPicker\n License URL: https://github.com/xnth97/SymbolPicker/blob/main/LICENSE\n\n MIT License\n\n Copyright (c) 2022 Yubo Qin & Lakr Aream\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n \"\"\"\n\n static let shortcutRecorder = \"\"\"\n ShortcutRecorder\n\n Authors: Contributors\n Project URL: https://github.com/Kentzo/ShortcutRecorder\n License URL: https://github.com/Kentzo/ShortcutRecorder/blob/master/LICENSE.txt\n\n Creative Commons Attribution 4.0 International Public License\n\n By exercising the Licensed Rights (defined below), You accept and agree\n to be bound by the terms and conditions of this Creative Commons\n Attribution 4.0 International Public License (\"Public License\"). To the\n extent this Public License may be interpreted as a contract, You are\n granted the Licensed Rights in consideration of Your acceptance of\n these terms and conditions, and the Licensor grants You such rights in\n consideration of benefits the Licensor receives from making the\n Licensed Material available under these terms and conditions.\n\n\n Section 1 -- Definitions.\n\n a. Adapted Material means material subject to Copyright and Similar\n Rights that is derived from or based upon the Licensed Material\n and in which the Licensed Material is translated, altered,\n arranged, transformed, or otherwise modified in a manner requiring\n permission under the Copyright and Similar Rights held by the\n Licensor. For purposes of this Public License, where the Licensed\n Material is a musical work, performance, or sound recording,\n Adapted Material is always produced where the Licensed Material is\n synched in timed relation with a moving image.\n\n b. Adapter's License means the license You apply to Your Copyright\n and Similar Rights in Your contributions to Adapted Material in\n accordance with the terms and conditions of this Public License.\n\n c. Copyright and Similar Rights means copyright and/or similar rights\n closely related to copyright including, without limitation,\n performance, broadcast, sound recording, and Sui Generis Database\n Rights, without regard to how the rights are labeled or\n categorized. For purposes of this Public License, the rights\n specified in Section 2(b)(1)-(2) are not Copyright and Similar\n Rights.\n\n d. Effective Technological Measures means those measures that, in the\n absence of proper authority, may not be circumvented under laws\n fulfilling obligations under Article 11 of the WIPO Copyright\n Treaty adopted on December 20, 1996, and/or similar international\n agreements.\n\n e. Exceptions and Limitations means fair use, fair dealing, and/or\n any other exception or limitation to Copyright and Similar Rights\n that applies to Your use of the Licensed Material.\n\n f. Licensed Material means the artistic or literary work, database,\n or other material to which the Licensor applied this Public\n License.\n\n g. Licensed Rights means the rights granted to You subject to the\n terms and conditions of this Public License, which are limited to\n all Copyright and Similar Rights that apply to Your use of the\n Licensed Material and that the Licensor has authority to license.\n\n h. Licensor means the individual(s) or entity(ies) granting rights\n under this Public License.\n\n i. Share means to provide material to the public by any means or\n process that requires permission under the Licensed Rights, such\n as reproduction, public display, public performance, distribution,\n dissemination, communication, or importation, and to make material\n available to the public including in ways that members of the\n public may access the material from a place and at a time\n individually chosen by them.\n\n j. Sui Generis Database Rights means rights other than copyright\n resulting from Directive 96/9/EC of the European Parliament and of\n the Council of 11 March 1996 on the legal protection of databases,\n as amended and/or succeeded, as well as other essentially\n equivalent rights anywhere in the world.\n\n k. You means the individual or entity exercising the Licensed Rights\n under this Public License. Your has a corresponding meaning.\n\n\n Section 2 -- Scope.\n\n a. License grant.\n\n 1. Subject to the terms and conditions of this Public License,\n the Licensor hereby grants You a worldwide, royalty-free,\n non-sublicensable, non-exclusive, irrevocable license to\n exercise the Licensed Rights in the Licensed Material to:\n\n a. reproduce and Share the Licensed Material, in whole or\n in part; and\n\n b. produce, reproduce, and Share Adapted Material.\n\n 2. Exceptions and Limitations. For the avoidance of doubt, where\n Exceptions and Limitations apply to Your use, this Public\n License does not apply, and You do not need to comply with\n its terms and conditions.\n\n 3. Term. The term of this Public License is specified in Section\n 6(a).\n\n 4. Media and formats; technical modifications allowed. The\n Licensor authorizes You to exercise the Licensed Rights in\n all media and formats whether now known or hereafter created,\n and to make technical modifications necessary to do so. The\n Licensor waives and/or agrees not to assert any right or\n authority to forbid You from making technical modifications\n necessary to exercise the Licensed Rights, including\n technical modifications necessary to circumvent Effective\n Technological Measures. For purposes of this Public License,\n simply making modifications authorized by this Section 2(a)\n (4) never produces Adapted Material.\n\n 5. Downstream recipients.\n\n a. Offer from the Licensor -- Licensed Material. Every\n recipient of the Licensed Material automatically\n receives an offer from the Licensor to exercise the\n Licensed Rights under the terms and conditions of this\n Public License.\n\n b. No downstream restrictions. You may not offer or impose\n any additional or different terms or conditions on, or\n apply any Effective Technological Measures to, the\n Licensed Material if doing so restricts exercise of the\n Licensed Rights by any recipient of the Licensed\n Material.\n\n 6. No endorsement. Nothing in this Public License constitutes or\n may be construed as permission to assert or imply that You\n are, or that Your use of the Licensed Material is, connected\n with, or sponsored, endorsed, or granted official status by,\n the Licensor or others designated to receive attribution as\n provided in Section 3(a)(1)(A)(i).\n\n b. Other rights.\n\n 1. Moral rights, such as the right of integrity, are not\n licensed under this Public License, nor are publicity,\n privacy, and/or other similar personality rights; however, to\n the extent possible, the Licensor waives and/or agrees not to\n assert any such rights held by the Licensor to the limited\n extent necessary to allow You to exercise the Licensed\n Rights, but not otherwise.\n\n 2. Patent and trademark rights are not licensed under this\n Public License.\n\n 3. To the extent possible, the Licensor waives any right to\n collect royalties from You for the exercise of the Licensed\n Rights, whether directly or through a collecting society\n under any voluntary or waivable statutory or compulsory\n licensing scheme. In all other cases the Licensor expressly\n reserves any right to collect such royalties.\n\n\n Section 3 -- License Conditions.\n\n Your exercise of the Licensed Rights is expressly made subject to the\n following conditions.\n\n a. Attribution.\n\n 1. If You Share the Licensed Material (including in modified\n form), You must:\n\n a. retain the following if it is supplied by the Licensor\n with the Licensed Material:\n\n i. identification of the creator(s) of the Licensed\n Material and any others designated to receive\n attribution, in any reasonable manner requested by\n the Licensor (including by pseudonym if\n designated);\n\n ii. a copyright notice;\n\n iii. a notice that refers to this Public License;\n\n iv. a notice that refers to the disclaimer of\n warranties;\n\n v. a URI or hyperlink to the Licensed Material to the\n extent reasonably practicable;\n\n b. indicate if You modified the Licensed Material and\n retain an indication of any previous modifications; and\n\n c. indicate the Licensed Material is licensed under this\n Public License, and include the text of, or the URI or\n hyperlink to, this Public License.\n\n 2. You may satisfy the conditions in Section 3(a)(1) in any\n reasonable manner based on the medium, means, and context in\n which You Share the Licensed Material. For example, it may be\n reasonable to satisfy the conditions by providing a URI or\n hyperlink to a resource that includes the required\n information.\n\n 3. If requested by the Licensor, You must remove any of the\n information required by Section 3(a)(1)(A) to the extent\n reasonably practicable.\n\n 4. If You Share Adapted Material You produce, the Adapter's\n License You apply must not prevent recipients of the Adapted\n Material from complying with this Public License.\n\n\n Section 4 -- Sui Generis Database Rights.\n\n Where the Licensed Rights include Sui Generis Database Rights that\n apply to Your use of the Licensed Material:\n\n a. for the avoidance of doubt, Section 2(a)(1) grants You the right\n to extract, reuse, reproduce, and Share all or a substantial\n portion of the contents of the database;\n\n b. if You include all or a substantial portion of the database\n contents in a database in which You have Sui Generis Database\n Rights, then the database in which You have Sui Generis Database\n Rights (but not its individual contents) is Adapted Material; and\n\n c. You must comply with the conditions in Section 3(a) if You Share\n all or a substantial portion of the contents of the database.\n\n For the avoidance of doubt, this Section 4 supplements and does not\n replace Your obligations under this Public License where the Licensed\n Rights include other Copyright and Similar Rights.\n\n\n Section 5 -- Disclaimer of Warranties and Limitation of Liability.\n\n a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE\n EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS\n AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF\n ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,\n IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,\n WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR\n PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,\n ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT\n KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT\n ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.\n\n b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE\n TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,\n NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,\n INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,\n COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR\n USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN\n ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR\n DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR\n IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.\n\n c. The disclaimer of warranties and limitation of liability provided\n above shall be interpreted in a manner that, to the extent\n possible, most closely approximates an absolute disclaimer and\n waiver of all liability.\n\n\n Section 6 -- Term and Termination.\n\n a. This Public License applies for the term of the Copyright and\n Similar Rights licensed here. However, if You fail to comply with\n this Public License, then Your rights under this Public License\n terminate automatically.\n\n b. Where Your right to use the Licensed Material has terminated under\n Section 6(a), it reinstates:\n\n 1. automatically as of the date the violation is cured, provided\n it is cured within 30 days of Your discovery of the\n violation; or\n\n 2. upon express reinstatement by the Licensor.\n\n For the avoidance of doubt, this Section 6(b) does not affect any\n right the Licensor may have to seek remedies for Your violations\n of this Public License.\n\n c. For the avoidance of doubt, the Licensor may also offer the\n Licensed Material under separate terms or conditions or stop\n distributing the Licensed Material at any time; however, doing so\n will not terminate this Public License.\n\n d. Sections 1, 5, 6, 7, and 8 survive termination of this Public\n License.\n\n\n Section 7 -- Other Terms and Conditions.\n\n a. The Licensor shall not be bound by any additional or different\n terms or conditions communicated by You unless expressly agreed.\n\n b. Any arrangements, understandings, or agreements regarding the\n Licensed Material not stated herein are separate from and\n independent of the terms and conditions of this Public License.\n\n\n Section 8 -- Interpretation.\n\n a. For the avoidance of doubt, this Public License does not, and\n shall not be interpreted to, reduce, limit, restrict, or impose\n conditions on any use of the Licensed Material that could lawfully\n be made without permission under this Public License.\n\n b. To the extent possible, if any provision of this Public License is\n deemed unenforceable, it shall be automatically reformed to the\n minimum extent necessary to make it enforceable. If the provision\n cannot be reformed, it shall be severed from this Public License\n without affecting the enforceability of the remaining terms and\n conditions.\n\n c. No term or condition of this Public License will be waived and no\n failure to comply consented to unless expressly agreed to by the\n Licensor.\n\n d. Nothing in this Public License constitutes or may be interpreted\n as a limitation upon, or waiver of, any privileges and immunities\n that apply to the Licensor or You, including from the legal\n processes of any jurisdiction or authority.\n\n\n =======================================================================\n\n Creative Commons is not a party to its public\n licenses. Notwithstanding, Creative Commons may elect to apply one of\n its public licenses to material it publishes and in those instances\n will be considered the “Licensor.” The text of the Creative Commons\n public licenses is dedicated to the public domain under the CC0 Public\n Domain Dedication. Except for the limited purpose of indicating that\n material is shared under a Creative Commons public license or as\n otherwise permitted by the Creative Commons policies published at\n creativecommons.org/policies, Creative Commons does not authorize the\n use of the trademark \"Creative Commons\" or any other trademark or logo\n of Creative Commons without its prior written consent including,\n without limitation, in connection with any unauthorized modifications\n to any of its public licenses or any other arrangements,\n understandings, or agreements concerning use of licensed material. For\n the avoidance of doubt, this paragraph does not form part of the\n public licenses.\n \"\"\"\n\n static let yams = \"\"\"\n Yams\n\n Authors: JP Simard\n Project URL: https://github.com/jpsim/Yams\n License URL: https://github.com/jpsim/Yams/blob/main/LICENSE\n\n The MIT License (MIT)\n\n Copyright (c) 2016 JP Simard.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n \"\"\"\n\n static let tomlKit = \"\"\"\n TOMLKit\n\n Authors: Jeff Lebrun\n Project URL: https://github.com/LebJe/TOMLKit\n License URL: https://github.com/LebJe/TOMLKit/blob/main/LICENSE\n\n MIT License\n\n Copyright (c) 2024 Jeff Lebrun\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n \"\"\"\n\n static let swiftArgumentParser = \"\"\"\n Swift Argument Parser\n\n Authors: Apple\n Project URL: https://github.com/apple/swift-argument-parser\n License URL: https://github.com/apple/swift-argument-parser/blob/main/LICENSE.txt\n\n Apache License\n Version 2.0, January 2004\n http://www.apache.org/licenses/\n\n TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n 1. Definitions.\n\n \"License\" shall mean the terms and conditions for use, reproduction,\n and distribution as defined by Sections 1 through 9 of this document.\n\n \"Licensor\" shall mean the copyright owner or entity authorized by\n the copyright owner that is granting the License.\n\n \"Legal Entity\" shall mean the union of the acting entity and all\n other entities that control, are controlled by, or are under common\n control with that entity. For the purposes of this definition,\n \"control\" means (i) the power, direct or indirect, to cause the\n direction or management of such entity, whether by contract or\n otherwise, or (ii) ownership of fifty percent (50%) or more of the\n outstanding shares, or (iii) beneficial ownership of such entity.\n\n \"You\" (or \"Your\") shall mean an individual or Legal Entity\n exercising permissions granted by this License.\n\n \"Source\" form shall mean the preferred form for making modifications,\n including but not limited to software source code, documentation\n source, and configuration files.\n\n \"Object\" form shall mean any form resulting from mechanical\n transformation or translation of a Source form, including but\n not limited to compiled object code, generated documentation,\n and conversions to other media types.\n\n \"Work\" shall mean the work of authorship, whether in Source or\n Object form, made available under the License, as indicated by a\n copyright notice that is included in or attached to the work\n (an example is provided in the Appendix below).\n\n \"Derivative Works\" shall mean any work, whether in Source or Object\n form, that is based on (or derived from) the Work and for which the\n editorial revisions, annotations, elaborations, or other modifications\n represent, as a whole, an original work of authorship. For the purposes\n of this License, Derivative Works shall not include works that remain\n separable from, or merely link (or bind by name) to the interfaces of,\n the Work and Derivative Works thereof.\n\n \"Contribution\" shall mean any work of authorship, including\n the original version of the Work and any modifications or additions\n to that Work or Derivative Works thereof, that is intentionally\n submitted to Licensor for inclusion in the Work by the copyright owner\n or by an individual or Legal Entity authorized to submit on behalf of\n the copyright owner. For the purposes of this definition, \"submitted\"\n means any form of electronic, verbal, or written communication sent\n to the Licensor or its representatives, including but not limited to\n communication on electronic mailing lists, source code control systems,\n and issue tracking systems that are managed by, or on behalf of, the\n Licensor for the purpose of discussing and improving the Work, but\n excluding communication that is conspicuously marked or otherwise\n designated in writing by the copyright owner as \"Not a Contribution.\"\n\n \"Contributor\" shall mean Licensor and any individual or Legal Entity\n on behalf of whom a Contribution has been received by Licensor and\n subsequently incorporated within the Work.\n\n 2. Grant of Copyright License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n copyright license to reproduce, prepare Derivative Works of,\n publicly display, publicly perform, sublicense, and distribute the\n Work and such Derivative Works in Source or Object form.\n\n 3. Grant of Patent License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n (except as stated in this section) patent license to make, have made,\n use, offer to sell, sell, import, and otherwise transfer the Work,\n where such license applies only to those patent claims licensable\n by such Contributor that are necessarily infringed by their\n Contribution(s) alone or by combination of their Contribution(s)\n with the Work to which such Contribution(s) was submitted. If You\n institute patent litigation against any entity (including a\n cross-claim or counterclaim in a lawsuit) alleging that the Work\n or a Contribution incorporated within the Work constitutes direct\n or contributory patent infringement, then any patent licenses\n granted to You under this License for that Work shall terminate\n as of the date such litigation is filed.\n\n 4. Redistribution. You may reproduce and distribute copies of the\n Work or Derivative Works thereof in any medium, with or without\n modifications, and in Source or Object form, provided that You\n meet the following conditions:\n\n (a) You must give any other recipients of the Work or\n Derivative Works a copy of this License; and\n\n (b) You must cause any modified files to carry prominent notices\n stating that You changed the files; and\n\n (c) You must retain, in the Source form of any Derivative Works\n that You distribute, all copyright, patent, trademark, and\n attribution notices from the Source form of the Work,\n excluding those notices that do not pertain to any part of\n the Derivative Works; and\n\n (d) If the Work includes a \"NOTICE\" text file as part of its\n distribution, then any Derivative Works that You distribute must\n include a readable copy of the attribution notices contained\n within such NOTICE file, excluding those notices that do not\n pertain to any part of the Derivative Works, in at least one\n of the following places: within a NOTICE text file distributed\n as part of the Derivative Works; within the Source form or\n documentation, if provided along with the Derivative Works; or,\n within a display generated by the Derivative Works, if and\n wherever such third-party notices normally appear. The contents\n of the NOTICE file are for informational purposes only and\n do not modify the License. You may add Your own attribution\n notices within Derivative Works that You distribute, alongside\n or as an addendum to the NOTICE text from the Work, provided\n that such additional attribution notices cannot be construed\n as modifying the License.\n\n You may add Your own copyright statement to Your modifications and\n may provide additional or different license terms and conditions\n for use, reproduction, or distribution of Your modifications, or\n for any such Derivative Works as a whole, provided Your use,\n reproduction, and distribution of the Work otherwise complies with\n the conditions stated in this License.\n\n 5. Submission of Contributions. Unless You explicitly state otherwise,\n any Contribution intentionally submitted for inclusion in the Work\n by You to the Licensor shall be under the terms and conditions of\n this License, without any additional terms or conditions.\n Notwithstanding the above, nothing herein shall supersede or modify\n the terms of any separate license agreement you may have executed\n with Licensor regarding such Contributions.\n\n 6. Trademarks. This License does not grant permission to use the trade\n names, trademarks, service marks, or product names of the Licensor,\n except as required for reasonable and customary use in describing the\n origin of the Work and reproducing the content of the NOTICE file.\n\n 7. Disclaimer of Warranty. Unless required by applicable law or\n agreed to in writing, Licensor provides the Work (and each\n Contributor provides its Contributions) on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n implied, including, without limitation, any warranties or conditions\n of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n PARTICULAR PURPOSE. You are solely responsible for determining the\n appropriateness of using or redistributing the Work and assume any\n risks associated with Your exercise of permissions under this License.\n\n 8. Limitation of Liability. In no event and under no legal theory,\n whether in tort (including negligence), contract, or otherwise,\n unless required by applicable law (such as deliberate and grossly\n negligent acts) or agreed to in writing, shall any Contributor be\n liable to You for damages, including any direct, indirect, special,\n incidental, or consequential damages of any character arising as a\n result of this License or out of the use or inability to use the\n Work (including but not limited to damages for loss of goodwill,\n work stoppage, computer failure or malfunction, or any and all\n other commercial damages or losses), even if such Contributor\n has been advised of the possibility of such damages.\n\n 9. Accepting Warranty or Additional Liability. While redistributing\n the Work or Derivative Works thereof, You may choose to offer,\n and charge a fee for, acceptance of support, warranty, indemnity,\n or other liability obligations and/or rights consistent with this\n License. However, in accepting such obligations, You may act only\n on Your own behalf and on Your sole responsibility, not on behalf\n of any other Contributor, and only if You agree to indemnify,\n defend, and hold each Contributor harmless for any liability\n incurred by, or claims asserted against, such Contributor by reason\n of your accepting any such warranty or additional liability.\n\n END OF TERMS AND CONDITIONS\n\n APPENDIX: How to apply the Apache License to your work.\n\n To apply the Apache License to your work, attach the following\n boilerplate notice, with the fields enclosed by brackets \"[]\"\n replaced with your own identifying information. (Don't include\n the brackets!) The text should be enclosed in the appropriate\n comment syntax for the file format. We also recommend that a\n file or class name and description of purpose be included on the\n same \"printed page\" as the copyright notice for easier\n identification within third-party archives.\n\n Copyright [yyyy] [name of copyright owner]\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n\n\n ## Runtime Library Exception to the Apache 2.0 License: ##\n\n\n As an exception, if you use this Software to compile your source code and\n portions of this Software are embedded into the binary product as a result,\n you may redistribute such product without providing attribution as would\n otherwise be required by Sections 4(a), 4(b) and 4(d) of the License.\n \"\"\"\n\n static let sparkle = \"\"\"\n Sparkle\n\n Copyright (c) 2006-2013 Andy Matuschak.\n Copyright (c) 2009-2013 Elgato Systems GmbH.\n Copyright (c) 2011-2014 Kornel Lesiński.\n Copyright (c) 2015-2017 Mayur Pawashe.\n Copyright (c) 2014 C.W. Betts.\n Copyright (c) 2014 Petroules Corporation.\n Copyright (c) 2014 Big Nerd Ranch.\n All rights reserved.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy of\n this software and associated documentation files (the \"Software\"), to deal in\n the Software without restriction, including without limitation the rights to\n use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\n the Software, and to permit persons to whom the Software is furnished to do so,\n subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\n FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\n COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\n IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n =================\n EXTERNAL LICENSES\n =================\n\n bspatch.c and bsdiff.c, from bsdiff 4.3 :\n\n Copyright 2003-2005 Colin Percival\n All rights reserved\n\n Redistribution and use in source and binary forms, with or without\n modification, are permitted providing that the following conditions \n are met:\n 1. Redistributions of source code must retain the above copyright\n notice, this list of conditions and the following disclaimer.\n 2. Redistributions in binary form must reproduce the above copyright\n notice, this list of conditions and the following disclaimer in the\n documentation and/or other materials provided with the distribution.\n\n THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR\n IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY\n DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING\n IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n POSSIBILITY OF SUCH DAMAGE.\n\n --\n\n sais.c and sais.h, from sais-lite (2010/08/07) :\n\n The sais-lite copyright is as follows:\n\n Copyright (c) 2008-2010 Yuta Mori All Rights Reserved.\n\n Permission is hereby granted, free of charge, to any person\n obtaining a copy of this software and associated documentation\n files (the \"Software\"), to deal in the Software without\n restriction, including without limitation the rights to use,\n copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the\n Software is furnished to do so, subject to the following\n conditions:\n\n The above copyright notice and this permission notice shall be\n included in all copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n OTHER DEALINGS IN THE SOFTWARE.\n\n --\n\n Portable C implementation of Ed25519, from https://github.com/orlp/ed25519\n\n Copyright (c) 2015 Orson Peters \n\n This software is provided 'as-is', without any express or implied warranty. In no event will the\n authors be held liable for any damages arising from the use of this software.\n\n Permission is granted to anyone to use this software for any purpose, including commercial\n applications, and to alter it and redistribute it freely, subject to the following restrictions:\n\n 1. The origin of this software must not be misrepresented; you must not claim that you wrote the\n original software. If you use this software in a product, an acknowledgment in the product\n documentation would be appreciated but is not required.\n\n 2. Altered source versions must be plainly marked as such, and must not be misrepresented as\n being the original software.\n\n 3. This notice may not be removed or altered from any source distribution.\n\n --\n\n SUSignatureVerifier.m:\n\n Copyright (c) 2011 Mark Hamlin.\n\n All rights reserved.\n\n Redistribution and use in source and binary forms, with or without\n modification, are permitted providing that the following conditions\n are met:\n 1. Redistributions of source code must retain the above copyright\n notice, this list of conditions and the following disclaimer.\n 2. Redistributions in binary form must reproduce the above copyright\n notice, this list of conditions and the following disclaimer in the\n documentation and/or other materials provided with the distribution.\n\n THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR\n IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY\n DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING\n IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n POSSIBILITY OF SUCH DAMAGE.\n \"\"\"\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Workspaces/WorkspaceSettings.swift", "//\n// WorkspaceSettings.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nfinal class WorkspaceSettings: ObservableObject {\n @Published var displayMode: DisplayMode = .static\n\n @Published var centerCursorOnWorkspaceChange = false\n @Published var changeWorkspaceOnAppAssign = true\n @Published var activeWorkspaceOnFocusChange = true\n @Published var skipEmptyWorkspacesOnSwitch = false\n @Published var keepUnassignedAppsOnSwitch = false\n @Published var restoreHiddenAppsOnSwitch = true\n @Published var enableWorkspaceTransitions = false\n @Published var workspaceTransitionDuration = 0.3\n @Published var workspaceTransitionDimming = 0.2\n\n @Published var assignFocusedApp: AppHotKey?\n @Published var unassignFocusedApp: AppHotKey?\n @Published var toggleFocusedAppAssignment: AppHotKey?\n @Published var assignVisibleApps: AppHotKey?\n @Published var hideUnassignedApps: AppHotKey?\n\n @Published var loopWorkspaces = true\n @Published var switchToRecentWorkspace: AppHotKey?\n @Published var switchToPreviousWorkspace: AppHotKey?\n @Published var switchToNextWorkspace: AppHotKey?\n\n @Published var alternativeDisplays = \"\"\n\n @Published var enablePictureInPictureSupport = true\n @Published var switchWorkspaceWhenPipCloses = true\n @Published var pipScreenCornerOffset = 15\n @Published var pipApps: [PipApp] = []\n\n private var observer: AnyCancellable?\n private let updateSubject = PassthroughSubject<(), Never>()\n\n init() { observe() }\n\n func addPipApp(_ app: PipApp) {\n pipApps.append(app)\n }\n\n func deletePipApp(_ app: PipApp) {\n pipApps.removeAll { $0 == app }\n }\n\n private func observe() {\n observer = Publishers.MergeMany(\n $displayMode.settingsPublisher(),\n\n $centerCursorOnWorkspaceChange.settingsPublisher(),\n $changeWorkspaceOnAppAssign.settingsPublisher(),\n $activeWorkspaceOnFocusChange.settingsPublisher(),\n $skipEmptyWorkspacesOnSwitch.settingsPublisher(),\n $keepUnassignedAppsOnSwitch.settingsPublisher(),\n $restoreHiddenAppsOnSwitch.settingsPublisher(),\n $enableWorkspaceTransitions.settingsPublisher(),\n $workspaceTransitionDuration.settingsPublisher(debounce: true),\n $workspaceTransitionDimming.settingsPublisher(debounce: true),\n\n $assignFocusedApp.settingsPublisher(),\n $unassignFocusedApp.settingsPublisher(),\n $toggleFocusedAppAssignment.settingsPublisher(),\n $assignVisibleApps.settingsPublisher(),\n $hideUnassignedApps.settingsPublisher(),\n\n $loopWorkspaces.settingsPublisher(),\n $switchToRecentWorkspace.settingsPublisher(),\n $switchToPreviousWorkspace.settingsPublisher(),\n $switchToNextWorkspace.settingsPublisher(),\n\n $alternativeDisplays.settingsPublisher(debounce: true),\n $enablePictureInPictureSupport.settingsPublisher(),\n $switchWorkspaceWhenPipCloses.settingsPublisher(),\n $pipApps.settingsPublisher(),\n $pipScreenCornerOffset.settingsPublisher(debounce: true)\n )\n .receive(on: DispatchQueue.main)\n .sink { [weak self] in self?.updateSubject.send() }\n }\n}\n\nextension WorkspaceSettings: SettingsProtocol {\n var updatePublisher: AnyPublisher<(), Never> {\n updateSubject.eraseToAnyPublisher()\n }\n\n func load(from appSettings: AppSettings) {\n observer = nil\n displayMode = appSettings.displayMode ?? .static\n\n centerCursorOnWorkspaceChange = appSettings.centerCursorOnWorkspaceChange ?? false\n changeWorkspaceOnAppAssign = appSettings.changeWorkspaceOnAppAssign ?? true\n activeWorkspaceOnFocusChange = appSettings.activeWorkspaceOnFocusChange ?? true\n skipEmptyWorkspacesOnSwitch = appSettings.skipEmptyWorkspacesOnSwitch ?? false\n keepUnassignedAppsOnSwitch = appSettings.keepUnassignedAppsOnSwitch ?? false\n restoreHiddenAppsOnSwitch = appSettings.restoreHiddenAppsOnSwitch ?? true\n enableWorkspaceTransitions = appSettings.enableWorkspaceTransitions ?? false\n workspaceTransitionDuration = min(appSettings.workspaceTransitionDuration ?? 0.3, 0.5)\n workspaceTransitionDimming = min(appSettings.workspaceTransitionDimming ?? 0.2, 0.5)\n\n assignFocusedApp = appSettings.assignFocusedApp\n unassignFocusedApp = appSettings.unassignFocusedApp\n toggleFocusedAppAssignment = appSettings.toggleFocusedAppAssignment\n assignVisibleApps = appSettings.assignVisibleApps\n hideUnassignedApps = appSettings.hideUnassignedApps\n\n loopWorkspaces = appSettings.loopWorkspaces ?? true\n switchToRecentWorkspace = appSettings.switchToRecentWorkspace\n switchToPreviousWorkspace = appSettings.switchToPreviousWorkspace\n switchToNextWorkspace = appSettings.switchToNextWorkspace\n\n alternativeDisplays = appSettings.alternativeDisplays ?? \"\"\n enablePictureInPictureSupport = appSettings.enablePictureInPictureSupport ?? true\n switchWorkspaceWhenPipCloses = appSettings.switchWorkspaceWhenPipCloses ?? true\n pipApps = appSettings.pipApps ?? []\n pipScreenCornerOffset = appSettings.pipScreenCornerOffset ?? 15\n observe()\n }\n\n func update(_ appSettings: inout AppSettings) {\n appSettings.displayMode = displayMode\n\n appSettings.centerCursorOnWorkspaceChange = centerCursorOnWorkspaceChange\n appSettings.changeWorkspaceOnAppAssign = changeWorkspaceOnAppAssign\n appSettings.activeWorkspaceOnFocusChange = activeWorkspaceOnFocusChange\n appSettings.skipEmptyWorkspacesOnSwitch = skipEmptyWorkspacesOnSwitch\n appSettings.keepUnassignedAppsOnSwitch = keepUnassignedAppsOnSwitch\n appSettings.restoreHiddenAppsOnSwitch = restoreHiddenAppsOnSwitch\n appSettings.enableWorkspaceTransitions = enableWorkspaceTransitions\n appSettings.workspaceTransitionDuration = workspaceTransitionDuration\n appSettings.workspaceTransitionDimming = workspaceTransitionDimming\n\n appSettings.assignFocusedApp = assignFocusedApp\n appSettings.unassignFocusedApp = unassignFocusedApp\n appSettings.toggleFocusedAppAssignment = toggleFocusedAppAssignment\n appSettings.assignVisibleApps = assignVisibleApps\n appSettings.hideUnassignedApps = hideUnassignedApps\n\n appSettings.loopWorkspaces = loopWorkspaces\n appSettings.switchToRecentWorkspace = switchToRecentWorkspace\n appSettings.switchToPreviousWorkspace = switchToPreviousWorkspace\n appSettings.switchToNextWorkspace = switchToNextWorkspace\n\n appSettings.alternativeDisplays = alternativeDisplays\n appSettings.enablePictureInPictureSupport = enablePictureInPictureSupport\n appSettings.switchWorkspaceWhenPipCloses = switchWorkspaceWhenPipCloses\n appSettings.pipApps = pipApps\n appSettings.pipScreenCornerOffset = pipScreenCornerOffset\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Profiles/ProfilesRepository.swift", "//\n// ProfilesRepository.swift\n//\n// Created by Wojciech Kulik on 26/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nfinal class ProfilesRepository: ObservableObject {\n @Published var profiles: [Profile] = [.default]\n @Published var selectedProfile: Profile = .default {\n didSet {\n guard shouldTrackProfileChange else { return }\n guard oldValue.id != selectedProfile.id else { return }\n setProfile(id: selectedProfile.id)\n }\n }\n\n var onProfileChange: ((Profile) -> ())?\n\n private var selectedProfileId: ProfileId? {\n get {\n UserDefaults.standard.string(forKey: AppConstants.UserDefaultsKey.selectedProfileId)\n .flatMap { UUID(uuidString: $0) }\n }\n set {\n if let newValue {\n UserDefaults.standard.set(newValue.uuidString, forKey: AppConstants.UserDefaultsKey.selectedProfileId)\n } else {\n UserDefaults.standard.removeObject(forKey: AppConstants.UserDefaultsKey.selectedProfileId)\n }\n }\n }\n\n private var shouldTrackProfileChange = true\n\n init() {\n loadFromDisk()\n }\n\n private func loadFromDisk() {\n shouldTrackProfileChange = false\n defer { shouldTrackProfileChange = true }\n\n guard let config = try? ConfigSerializer.deserialize(ProfilesConfig.self, filename: \"profiles\"),\n !config.profiles.isEmpty else {\n return createDefaultProfile()\n }\n\n let migrated = migrateOldConfigIfNeeded()\n profiles = config.profiles\n\n let selectedProfileId = selectedProfileId\n selectedProfile = profiles.first { $0.id == selectedProfileId } ?? profiles.first ?? .default\n\n if migrated { saveToDisk() }\n }\n\n private func migrateOldConfigIfNeeded() -> Bool {\n struct OldProfilesConfig: Codable {\n let selectedProfileId: ProfileId?\n }\n\n if let oldConfig = try? ConfigSerializer.deserialize(OldProfilesConfig.self, filename: \"profiles\"),\n let profileId = oldConfig.selectedProfileId {\n selectedProfileId = profileId\n Logger.log(\"Migrated old profile config to new format. Profile ID: \\(profileId)\")\n\n return true\n }\n\n return false\n }\n\n private func createDefaultProfile() {\n profiles = [.init(\n id: UUID(),\n name: \"Default\",\n workspaces: []\n )]\n selectedProfile = profiles[0]\n saveToDisk()\n }\n\n private func setProfile(id: ProfileId) {\n guard let profile = profiles.first(where: { $0.id == id }) else { return }\n\n saveToDisk()\n\n onProfileChange?(profile)\n NotificationCenter.default.post(name: .profileChanged, object: nil)\n Integrations.runOnProfileChangeIfNeeded(profile: profile.name)\n }\n}\n\nextension ProfilesRepository {\n func createProfile(name: String, keepWorkspaces: Bool) {\n var workspaces = [Workspace]()\n\n if keepWorkspaces {\n workspaces = selectedProfile.workspaces.map { workspace in\n var newWorkspace = workspace\n newWorkspace.id = UUID()\n return newWorkspace\n }\n }\n\n let newProfile = Profile(id: UUID(), name: name, workspaces: workspaces)\n profiles.append(newProfile)\n profiles.sort { $0.name < $1.name }\n\n saveToDisk()\n }\n\n func renameProfile(id: ProfileId, to newName: String) {\n guard let index = profiles.firstIndex(where: { $0.id == id }) else { return }\n\n profiles[index].name = newName\n profiles.sort { $0.name < $1.name }\n\n shouldTrackProfileChange = false\n selectedProfile = profiles.first { $0.id == id } ?? .default\n shouldTrackProfileChange = true\n\n saveToDisk()\n }\n\n func deleteProfile(id: ProfileId) {\n guard profiles.count > 1 else { return }\n\n profiles.removeAll { $0.id == id }\n\n if selectedProfile.id == id {\n shouldTrackProfileChange = false\n selectedProfile = profiles.first ?? .default\n shouldTrackProfileChange = true\n\n saveToDisk()\n setProfile(id: selectedProfile.id)\n } else {\n saveToDisk()\n }\n }\n\n func updateWorkspaces(_ workspaces: [Workspace]) {\n guard let profileIndex = profiles.firstIndex(where: { $0.id == selectedProfile.id }) else { return }\n\n profiles[profileIndex].workspaces = workspaces\n selectedProfile = profiles[profileIndex]\n saveToDisk()\n }\n\n func saveToDisk() {\n let config = ProfilesConfig(profiles: profiles)\n try? ConfigSerializer.serialize(filename: \"profiles\", config)\n\n selectedProfileId = selectedProfile.id\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/CLIServer.swift", "//\n// CLIServer.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\nimport Network\n\nfinal class CLIServer {\n var isRunning: Bool {\n switch listener?.state ?? .cancelled {\n case .cancelled, .failed: return false\n default: return true\n }\n }\n\n private var listener: NWListener?\n private let socketPath = \"/tmp/flashspace.socket\"\n private let executors: [CommandExecutor] = [\n ProfileCommands(),\n WorkspaceCommands(),\n AppCommands(),\n FocusCommands(),\n SpaceControlCommands(),\n ListCommands(),\n GetCommands()\n ]\n\n init() { startServer() }\n\n func restart() {\n listener?.cancel()\n startServer()\n }\n\n private func startServer() {\n try? FileManager.default.removeItem(atPath: socketPath)\n\n do {\n let params = NWParameters(tls: nil, tcp: .init())\n params.allowLocalEndpointReuse = true\n params.requiredLocalEndpoint = .unix(path: socketPath)\n\n listener = try NWListener(using: params)\n listener?.newConnectionHandler = handleNewConnection\n listener?.start(queue: .global(qos: .userInitiated))\n Logger.log(\"🟢 Server started at \\(socketPath)\")\n } catch {\n Logger.log(\"❌ Failed to start server: \\(error)\")\n }\n }\n\n private func handleNewConnection(_ connection: NWConnection) {\n connection.start(queue: .global(qos: .userInitiated))\n Logger.log(\"✅ New client connected\")\n\n let buffer = BufferWrapper()\n receiveData(connection: connection, buffer: buffer)\n }\n\n private func receiveData(connection: NWConnection, buffer: BufferWrapper) {\n connection.receive(minimumIncompleteLength: 1, maximumLength: 10000) { data, _, isComplete, error in\n if let error {\n connection.cancel()\n return Logger.log(\"❌ Receive error: \\(error)\")\n }\n\n if let data { buffer.data.append(data) }\n\n // Check if complete or EOF at the end\n guard isComplete || data?.last == 0 else {\n return self.receiveData(connection: connection, buffer: buffer)\n }\n\n guard !buffer.data.isEmpty else {\n connection.cancel()\n return Logger.log(\"❌ Received empty data\")\n }\n\n do {\n let command = try buffer.data.decodeSocketData(CommandRequest.self)\n DispatchQueue.main.async {\n self.handleCommand(command, connection: connection)\n }\n } catch {\n connection.cancel()\n Logger.log(\"❌ Failed to decode command: \\(error)\")\n }\n }\n }\n\n private func handleCommand(_ command: CommandRequest, connection: NWConnection) {\n var result: CommandResponse?\n for executor in executors {\n result = executor.execute(command: command)\n if result != nil { break }\n }\n\n DispatchQueue.global(qos: .userInitiated).async {\n if let response = result?.encodeSocketData() {\n connection.send(content: response, completion: .contentProcessed { _ in connection.cancel() })\n } else {\n connection.cancel()\n Logger.log(\"❌ Failed to encode response\")\n }\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/MainScreen/WorkspaceConfigurationView.swift", "//\n// WorkspaceConfigurationView.swift\n//\n// Created by Wojciech Kulik on 20/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct WorkspaceConfigurationView: View {\n @Environment(\\.openWindow) var openWindow\n\n @ObservedObject var viewModel: MainViewModel\n @StateObject var profilesRepository = AppDependencies.shared.profilesRepository\n\n var body: some View {\n VStack(alignment: .leading, spacing: 0.0) {\n configuration\n\n if viewModel.workspaces.contains(where: { $0.apps.contains(where: \\.bundleIdentifier.isEmpty) }) {\n Text(\"Could not migrate some apps. Please re-add them to fix the problem. Please also check floating apps.\")\n .foregroundColor(.errorRed)\n }\n\n Spacer()\n profileAndSettings\n }\n }\n\n private var configuration: some View {\n VStack(alignment: .leading, spacing: 1.0) {\n Text(\"Workspace Configuration:\")\n .padding(.bottom, 16.0)\n .fixedSize()\n\n Text(\"Name:\")\n TextField(\"Name\", text: $viewModel.workspaceName)\n .onSubmit(viewModel.saveWorkspace)\n .padding(.bottom)\n\n Picker(\"Display:\", selection: $viewModel.workspaceDisplay) {\n ForEach(viewModel.screens, id: \\.self) {\n Text($0).tag($0)\n }\n }\n .padding(.bottom)\n .hidden(viewModel.displayMode == .dynamic)\n\n Picker(\"Focus App:\", selection: $viewModel.workspaceAppToFocus) {\n ForEach(viewModel.focusAppOptions, id: \\.self) {\n Text($0.name).tag($0)\n }\n }.padding(.bottom)\n\n HStack {\n Text(\"Menu Bar Icon:\")\n Button {\n viewModel.isSymbolPickerPresented = true\n } label: {\n Image(systemName: viewModel.workspaceSymbolIconName ?? .defaultIconSymbol)\n .frame(maxWidth: .infinity)\n }\n }.padding(.bottom)\n\n Text(\"Activate Shortcut:\")\n HotKeyControl(shortcut: $viewModel.workspaceShortcut).padding(.bottom)\n\n Text(\"Assign App Shortcut:\")\n HotKeyControl(shortcut: $viewModel.workspaceAssignShortcut).padding(.bottom)\n }\n .disabled(viewModel.selectedWorkspace == nil)\n }\n\n private var profileAndSettings: some View {\n HStack {\n Picker(\"Profile:\", selection: $profilesRepository.selectedProfile) {\n ForEach(profilesRepository.profiles) {\n Text($0.name).tag($0)\n }\n }\n\n Button(action: {\n openWindow(id: \"settings\")\n }, label: {\n Image(systemName: \"gearshape\")\n .foregroundColor(.primary)\n }).keyboardShortcut(\",\")\n }.frame(maxWidth: .infinity, alignment: .trailing)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Models/CreateWorkspaceRequest.swift", "//\n// CreateWorkspaceRequest.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\n\nstruct CreateWorkspaceRequest: Codable {\n let name: String\n let display: String?\n let icon: String?\n let activateKey: String?\n let assignKey: String?\n let activate: Bool\n}\n\nextension CreateWorkspaceRequest {\n var toWorkspace: Workspace {\n Workspace(\n id: .init(),\n name: name,\n display: display ?? NSScreen.main?.localizedName ?? \"\",\n activateShortcut: activateKey.flatMap { .init(value: $0) },\n assignAppShortcut: assignKey.flatMap { .init(value: $0) },\n apps: [],\n appToFocus: nil,\n symbolIconName: icon\n )\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/FloatingApps/FloatingAppsHotKeys.swift", "//\n// FloatingAppsHotKeys.swift\n//\n// Created by Wojciech Kulik on 16/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nfinal class FloatingAppsHotKeys {\n private let workspaceManager: WorkspaceManager\n private let floatingAppsSettings: FloatingAppsSettings\n\n init(\n workspaceManager: WorkspaceManager,\n settingsRepository: SettingsRepository\n ) {\n self.workspaceManager = workspaceManager\n self.floatingAppsSettings = settingsRepository.floatingAppsSettings\n }\n\n func getHotKeys() -> [(AppHotKey, () -> ())] {\n let hotKeys = [\n getFloatTheFocusedAppHotKey(),\n getUnfloatTheFocusedAppHotKey(),\n getToggleTheFocusedAppFloatingHotKey()\n ]\n\n return hotKeys.compactMap(\\.self)\n }\n\n private func getFloatTheFocusedAppHotKey() -> (AppHotKey, () -> ())? {\n guard let shortcut = floatingAppsSettings.floatTheFocusedApp else { return nil }\n\n return (shortcut, { [weak self] in self?.floatApp() })\n }\n\n private func getUnfloatTheFocusedAppHotKey() -> (AppHotKey, () -> ())? {\n guard let shortcut = floatingAppsSettings.unfloatTheFocusedApp else { return nil }\n\n return (shortcut, { [weak self] in self?.unfloatApp() })\n }\n\n private func getToggleTheFocusedAppFloatingHotKey() -> (AppHotKey, () -> ())? {\n guard let shortcut = floatingAppsSettings.toggleTheFocusedAppFloating else { return nil }\n\n let action = { [weak self] in\n guard let self, let activeApp = NSWorkspace.shared.frontmostApplication else { return }\n\n if floatingAppsSettings.floatingApps.containsApp(activeApp) {\n unfloatApp()\n } else {\n floatApp()\n }\n }\n return (shortcut, action)\n }\n}\n\nextension FloatingAppsHotKeys {\n private func floatApp() {\n guard let activeApp = NSWorkspace.shared.frontmostApplication,\n let appName = activeApp.localizedName else { return }\n\n floatingAppsSettings.addFloatingAppIfNeeded(app: activeApp.toMacApp)\n Toast.showWith(\n icon: \"macwindow.on.rectangle\",\n message: \"\\(appName) - Added To Floating Apps\",\n textColor: .positive\n )\n }\n\n private func unfloatApp() {\n guard let activeApp = NSWorkspace.shared.frontmostApplication,\n let appName = activeApp.localizedName else { return }\n\n if floatingAppsSettings.floatingApps.containsApp(activeApp) {\n Toast.showWith(\n icon: \"macwindow\",\n message: \"\\(appName) - Removed From Floating Apps\",\n textColor: .negative\n )\n }\n\n floatingAppsSettings.deleteFloatingApp(app: activeApp.toMacApp)\n\n guard let screen = activeApp.display else { return }\n\n if workspaceManager.activeWorkspace[screen]?.apps.containsApp(activeApp) != true {\n activeApp.hide()\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/CLI.swift", "//\n// CLI.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nenum CLI {\n static var cliPath: String { Bundle.main.bundlePath + \"/Contents/Resources/flashspace\" }\n static var symlinkPath: String { \"/usr/local/bin/flashspace\" }\n static var isInstalled: Bool { FileManager.default.fileExists(atPath: symlinkPath) }\n\n static func install() {\n guard !isInstalled else {\n return print(\"✅ CLI already installed at \\(symlinkPath)\")\n }\n\n if runSudoScript(\"ln -s '\\(cliPath)' '\\(symlinkPath)'\") {\n Logger.log(\"✅ CLI installed from \\(symlinkPath)\")\n }\n }\n\n static func uninstall() {\n guard isInstalled else { return print(\"✅ CLI already uninstalled\") }\n\n if runSudoScript(\"rm '\\(symlinkPath)'\") {\n Logger.log(\"✅ CLI uninstalled from \\(symlinkPath)\")\n }\n }\n\n private static func runSudoScript(_ script: String) -> Bool {\n let appleScript =\n \"do shell script \\\"sudo \\(script)\\\" with administrator privileges\"\n\n guard let scriptObject = NSAppleScript(source: appleScript) else {\n Logger.log(\"❌ Error: Failed to create AppleScript object\")\n Alert.showOkAlert(title: \"Error\", message: \"Could not run script\")\n return false\n }\n\n var error: NSDictionary?\n scriptObject.executeAndReturnError(&error)\n\n if let error {\n Logger.log(\"❌ Error: \\(error)\")\n if let errorNumber = error[\"NSAppleScriptErrorNumber\"],\n errorNumber as? NSNumber != -128,\n let errorMessage = error[\"NSAppleScriptErrorMessage\"] as? String {\n Alert.showOkAlert(title: \"Error\", message: errorMessage)\n }\n return false\n }\n\n return true\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Commands/ProfileCommands.swift", "//\n// ProfileCommands.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\n\nfinal class ProfileCommands: CommandExecutor {\n var profilesRepository: ProfilesRepository { AppDependencies.shared.profilesRepository }\n\n func execute(command: CommandRequest) -> CommandResponse? {\n switch command {\n case .activateProfile(let name):\n let profile = profilesRepository.profiles.first { $0.name == name }\n\n if let profile {\n profilesRepository.selectedProfile = profile\n return CommandResponse(success: true)\n } else {\n return CommandResponse(success: false, error: \"Profile not found\")\n }\n\n case .createProfile(let name, let copy, let activate):\n profilesRepository.createProfile(name: name, keepWorkspaces: copy)\n if activate {\n profilesRepository.profiles\n .first { $0.name == name }\n .flatMap { profilesRepository.selectedProfile = $0 }\n }\n return CommandResponse(success: true)\n\n case .deleteProfile(let name):\n let profile = profilesRepository.profiles.first { $0.name == name }\n if let profile {\n profilesRepository.deleteProfile(id: profile.id)\n return CommandResponse(success: true)\n } else {\n return CommandResponse(success: false, error: \"Profile not found\")\n }\n\n default:\n return nil\n }\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/FlashSpaceCLI.swift", "//\n// FlashSpaceCLI.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\n@main\nstruct FlashSpaceCLI: ParsableCommand {\n static let configuration: CommandConfiguration = .init(\n commandName: \"flashspace\",\n abstract: \"FlashSpace CLI\",\n version: \"1.0.0\",\n groupedSubcommands: [\n .init(\n name: \"Profile\",\n subcommands: [\n CreateProfileCommand.self,\n DeleteProfileCommand.self,\n ProfileCommand.self\n ]\n ),\n .init(\n name: \"Workspace\",\n subcommands: [\n CreateWorkspaceCommand.self,\n DeleteWorkspaceCommand.self,\n UpdateWorkspaceCommand.self,\n WorkspaceCommand.self\n ]\n ),\n .init(\n name: \"App\",\n subcommands: [\n AssignVisibleAppsCommand.self,\n AssignAppCommand.self,\n UnassignAppCommand.self,\n HideUnassignedAppsCommand.self,\n FocusCommand.self,\n FloatingAppsCommand.self\n ]\n ),\n .init(\n name: \"List\",\n subcommands: [\n ListProfilesCommand.self,\n ListWorkspacesCommand.self,\n ListAppsCommand.self,\n ListFloatingAppsCommand.self,\n ListRunningAppsCommand.self,\n ListDisplaysCommand.self\n ]\n ),\n .init(\n name: \"Get\",\n subcommands: [\n GetProfileCommand.self,\n GetWorkspaceCommand.self,\n GetAppCommand.self,\n GetDisplayCommand.self\n ]\n ),\n .init(\n name: \"Open\",\n subcommands: [\n OpenAppCommand.self,\n OpenSpaceControlCommand.self\n ]\n )\n ]\n )\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/List/ListFloatingAppsCommand.swift", "//\n// ListFloatingAppsCommand.swift\n//\n// Created by Wojciech Kulik on 03/05/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct ListFloatingAppsCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"list-floating-apps\",\n abstract: \"List floating apps\"\n )\n\n @Flag(help: \"Include bundle id\")\n var withBundleId = false\n\n func run() throws {\n sendCommand(.listFloatingApps(withBundleId: withBundleId))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/SpaceControl/WorkspaceScreenshotManager.swift", "//\n// WorkspaceScreenshotManager.swift\n//\n// Created by Wojciech Kulik on 11/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Combine\nimport CoreGraphics\nimport ScreenCaptureKit\nimport SwiftUI\n\nfinal class WorkspaceScreenshotManager {\n typealias ImageData = Data\n\n struct ScreenshotKey: Hashable {\n let displayName: DisplayName\n let workspaceID: WorkspaceID\n }\n\n private(set) var screenshots: [ScreenshotKey: ImageData] = [:]\n private var cancellables = Set()\n\n private let lock = NSLock()\n\n init() {\n observe()\n }\n\n func captureWorkspace(_ workspace: Workspace, displayName: DisplayName) async {\n let shouldCapture = await MainActor.run {\n !SpaceControl.isVisible &&\n SpaceControl.isEnabled &&\n PermissionsManager.shared.checkForScreenRecordingPermissions()\n }\n\n guard shouldCapture else { return }\n\n do {\n let availableContent = try await SCShareableContent.excludingDesktopWindows(false, onScreenWindowsOnly: false)\n let display = await MainActor.run {\n availableContent.displays.first { $0.frame.getDisplay() == displayName }\n }\n\n guard let display else { return }\n\n let filter = SCContentFilter(display: display, excludingWindows: [])\n let config = SCStreamConfiguration()\n config.captureResolution = .best\n config.width = Int(display.frame.width)\n config.height = Int(display.frame.height)\n config.showsCursor = false\n\n let screenshot = try await SCScreenshotManager.captureSampleBuffer(\n contentFilter: filter,\n configuration: config\n )\n\n if let image = imageFromSampleBuffer(screenshot) {\n let key = ScreenshotKey(\n displayName: displayName,\n workspaceID: workspace.id\n )\n saveScreenshot(image, workspace: workspace, key: key)\n }\n } catch {\n Logger.log(error)\n }\n }\n\n private func imageFromSampleBuffer(_ buffer: CMSampleBuffer) -> NSImage? {\n guard let imageBuffer = CMSampleBufferGetImageBuffer(buffer) else { return nil }\n\n let ciImage = CIImage(cvImageBuffer: imageBuffer)\n let representation = NSCIImageRep(ciImage: ciImage)\n let nsImage = NSImage(size: representation.size)\n nsImage.addRepresentation(representation)\n\n return nsImage\n }\n\n private func saveScreenshot(_ image: NSImage, workspace: Workspace, key: ScreenshotKey) {\n let newSize = CGSize(\n width: 1400.0,\n height: (1400.0 / image.size.width) * image.size.height\n )\n let newImage = NSImage(size: newSize)\n let rect = NSRect(origin: .zero, size: newSize)\n\n newImage.lockFocus()\n image.draw(in: rect)\n newImage.unlockFocus()\n\n guard let resizedData = newImage.tiffRepresentation,\n let imageRepresentation = NSBitmapImageRep(data: resizedData),\n let jpegData = imageRepresentation.representation(using: .jpeg, properties: [:])\n else { return }\n\n lock.lock()\n screenshots[key] = jpegData\n lock.unlock()\n }\n\n private func observe() {\n NotificationCenter.default\n .publisher(for: .workspaceTransitionFinished)\n .compactMap { $0.object as? Workspace }\n .sink { [weak self] workspace in\n for display in workspace.displays {\n Task.detached { [weak self] in\n await self?.captureWorkspace(workspace, displayName: display)\n }\n }\n }\n .store(in: &cancellables)\n\n NotificationCenter.default\n .publisher(for: .profileChanged)\n .sink { [weak self] _ in\n self?.screenshots = [:]\n }\n .store(in: &cancellables)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Gestures/SwipeManager.swift", "//\n// SwipeManager.swift\n//\n// Created by Wojciech Kulik on 22/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n// Based on: https://github.com/MediosZ/SwipeAeroSpace\n\nimport AppKit\nimport Combine\n\nfinal class SwipeManager {\n typealias TouchId = ObjectIdentifier\n\n enum Constants {\n static let minFingerCount = 3\n static let maxFingerCount = 4\n }\n\n enum GestureState {\n case idle\n case inProgress\n case ended\n }\n\n static let shared = SwipeManager()\n\n private var swipeThreshold: Double { gesturesSettings.swipeThreshold }\n\n private var eventTap: CFMachPort?\n private var xTouchDistance: [TouchId: CGFloat] = [:]\n private var yTouchDistance: [TouchId: CGFloat] = [:]\n private var prevTouchPositions: [TouchId: NSPoint] = [:]\n private var lastTouchDate = Date.distantPast\n private var state: GestureState = .ended\n private var systemWakeUpObserver: AnyCancellable?\n\n private lazy var gesturesSettings = AppDependencies.shared.gesturesSettings\n private lazy var workspaceSettings = AppDependencies.shared.workspaceSettings\n private lazy var workspaceManager = AppDependencies.shared.workspaceManager\n private lazy var workspaceRepository = AppDependencies.shared.workspaceRepository\n private lazy var focusManager = AppDependencies.shared.focusManager\n\n func start() {\n guard eventTap == nil else {\n return Logger.log(\"SwipeManager is already started\")\n }\n\n eventTap = CGEvent.tapCreate(\n tap: .cghidEventTap,\n place: .headInsertEventTap,\n options: .defaultTap,\n eventsOfInterest: NSEvent.EventTypeMask.gesture.rawValue,\n callback: { proxy, type, cgEvent, userInfo in\n SwipeManager.shared.eventHandler(\n proxy: proxy,\n eventType: type,\n cgEvent: cgEvent,\n userInfo: userInfo\n )\n },\n userInfo: nil\n )\n\n guard let eventTap else {\n return Logger.log(\"SwipeManager couldn't create event tap\")\n }\n\n Logger.log(\"SwipeManager started\")\n\n let runLoopSource = CFMachPortCreateRunLoopSource(nil, eventTap, 0)\n CFRunLoopAddSource(\n CFRunLoopGetCurrent(),\n runLoopSource,\n CFRunLoopMode.commonModes\n )\n CGEvent.tapEnable(tap: eventTap, enable: true)\n\n observeSystemWakeUp()\n }\n\n func stop() {\n guard let eventTap else { return }\n\n CGEvent.tapEnable(tap: eventTap, enable: false)\n CFRunLoopRemoveSource(\n CFRunLoopGetCurrent(),\n CFMachPortCreateRunLoopSource(nil, eventTap, 0),\n CFRunLoopMode.commonModes\n )\n CFMachPortInvalidate(eventTap)\n self.eventTap = nil\n\n systemWakeUpObserver?.cancel()\n systemWakeUpObserver = nil\n\n Logger.log(\"SwipeManager stopped\")\n }\n\n func eventHandler(\n proxy: CGEventTapProxy,\n eventType: CGEventType,\n cgEvent: CGEvent,\n userInfo: UnsafeMutableRawPointer?\n ) -> Unmanaged? {\n if eventType.rawValue == NSEvent.EventType.gesture.rawValue,\n let nsEvent = NSEvent(cgEvent: cgEvent) {\n handleGesture(nsEvent)\n } else if eventType == .tapDisabledByUserInput || eventType == .tapDisabledByTimeout {\n Logger.log(\"SwipeManager tap disabled \\(eventType)\")\n if let eventTap {\n CGEvent.tapEnable(tap: eventTap, enable: true)\n }\n }\n\n return Unmanaged.passUnretained(cgEvent)\n }\n\n private func handleGesture(_ nsEvent: NSEvent) {\n let touches = nsEvent.allTouches()\n .filter { !$0.isResting && $0.phase != .stationary }\n\n if touches.count == 0 || Date().timeIntervalSince(lastTouchDate) > 0.8 {\n state = .idle\n }\n\n guard touches.count >= Constants.minFingerCount,\n gesturesSettings.isHorizontalSwipeSet || gesturesSettings.isVerticalSwipeSet\n else { return }\n\n if state == .idle {\n state = .inProgress\n xTouchDistance = [:]\n yTouchDistance = [:]\n prevTouchPositions = [:]\n }\n if state == .inProgress {\n lastTouchDate = Date()\n handleSwipe(touches: touches)\n }\n }\n\n private func handleSwipe(touches: Set) {\n updateSwipeDistance(touches: touches)\n handleHorizontalSwipe()\n handleVerticalSwipe()\n }\n\n private func handleHorizontalSwipe() {\n guard state == .inProgress else { return }\n guard gesturesSettings.isHorizontalSwipeSet else { return }\n\n let swipes = xTouchDistance.values\n let allMovedRight = swipes.allSatisfy { $0 > 0 }\n let allMovedLeft = swipes.allSatisfy { $0 < 0 }\n let minFingerContribution = swipeThreshold / (CGFloat(swipes.count) + 2.0)\n\n guard (Constants.minFingerCount...Constants.maxFingerCount).contains(swipes.count),\n swipes.allSatisfy({ abs($0) > minFingerContribution }),\n abs(swipes.reduce(0.0, +)) >= swipeThreshold,\n allMovedLeft || allMovedRight else { return }\n\n let action = if allMovedRight {\n swipes.count == 3 ? gesturesSettings.swipeRight3FingerAction : gesturesSettings.swipeRight4FingerAction\n } else if allMovedLeft {\n swipes.count == 3 ? gesturesSettings.swipeLeft3FingerAction : gesturesSettings.swipeLeft4FingerAction\n } else {\n GestureAction.none\n }\n\n state = .ended\n callAction(action)\n Logger.log(\"Horizontal swipe detected\")\n }\n\n private func handleVerticalSwipe() {\n guard state == .inProgress else { return }\n guard gesturesSettings.isVerticalSwipeSet else { return }\n\n let swipes = yTouchDistance.values\n let allMovedUp = swipes.allSatisfy { $0 > 0 }\n let allMovedDown = swipes.allSatisfy { $0 < 0 }\n let minFingerContribution = swipeThreshold / (CGFloat(swipes.count) + 2.0)\n\n guard (Constants.minFingerCount...Constants.maxFingerCount).contains(swipes.count),\n swipes.allSatisfy({ abs($0) > minFingerContribution }),\n abs(swipes.reduce(0.0, +)) >= swipeThreshold,\n allMovedUp || allMovedDown else { return }\n\n let action = if allMovedUp {\n swipes.count == 3 ? gesturesSettings.swipeUp3FingerAction : gesturesSettings.swipeUp4FingerAction\n } else if allMovedDown {\n swipes.count == 3 ? gesturesSettings.swipeDown3FingerAction : gesturesSettings.swipeDown4FingerAction\n } else {\n GestureAction.none\n }\n\n state = .ended\n callAction(action)\n Logger.log(\"Vertical swipe detected\")\n }\n\n private func updateSwipeDistance(touches: Set) {\n for touch in touches {\n let (distanceX, distanceY) = touchDistance(touch)\n\n if abs(distanceX) > abs(distanceY) {\n xTouchDistance[ObjectIdentifier(touch.identity), default: 0.0] += distanceX\n } else {\n yTouchDistance[ObjectIdentifier(touch.identity), default: 0.0] += distanceY\n }\n\n prevTouchPositions[ObjectIdentifier(touch.identity)] = touch.normalizedPosition\n }\n }\n\n private func touchDistance(_ touch: NSTouch) -> (CGFloat, CGFloat) {\n guard let prevPosition = prevTouchPositions[ObjectIdentifier(touch.identity)] else {\n return (0.0, 0.0)\n }\n\n return (\n touch.normalizedPosition.x - prevPosition.x,\n touch.normalizedPosition.y - prevPosition.y\n )\n }\n\n // swiftlint:disable:next cyclomatic_complexity\n private func callAction(_ action: GestureAction) {\n let skipEmpty = workspaceSettings.skipEmptyWorkspacesOnSwitch\n let loop = workspaceSettings.loopWorkspaces\n\n switch action {\n case .none: break\n case .toggleSpaceControl: SpaceControl.toggle()\n case .showSpaceControl: SpaceControl.show()\n case .hideSpaceControl: SpaceControl.hide()\n case .nextWorkspace: workspaceManager.activateWorkspace(next: true, skipEmpty: skipEmpty, loop: loop)\n case .previousWorkspace: workspaceManager.activateWorkspace(next: false, skipEmpty: skipEmpty, loop: loop)\n case .mostRecentWorkspace: workspaceManager.activateRecentWorkspace()\n case .focusLeft: focusManager.focusLeft()\n case .focusRight: focusManager.focusRight()\n case .focusUp: focusManager.focusUp()\n case .focusDown: focusManager.focusDown()\n case .focusNextApp: focusManager.nextWorkspaceApp()\n case .focusPreviousApp: focusManager.previousWorkspaceApp()\n case .focusNextWindow: focusManager.nextWorkspaceWindow()\n case .focusPreviousWindow: focusManager.previousWorkspaceWindow()\n case .activateWorkspace(let workspaceName):\n if let workspace = workspaceRepository.workspaces.first(where: { $0.name == workspaceName }) {\n workspaceManager.activateWorkspace(workspace, setFocus: true)\n }\n }\n }\n}\n\nextension SwipeManager {\n func restartAppIfNeeded() {\n guard gesturesSettings.restartAppOnWakeUp else { return }\n\n let task = Process()\n task.launchPath = \"/bin/sh\"\n task.arguments = [\"-c\", \"sleep 1; open '\\(Bundle.main.bundlePath)'\"]\n task.launch()\n\n NSApp.terminate(self)\n exit(0)\n }\n\n private func observeSystemWakeUp() {\n systemWakeUpObserver = NSWorkspace.shared.notificationCenter\n .publisher(for: NSWorkspace.didWakeNotification)\n .sink { [weak self] _ in self?.restartAppIfNeeded() }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/HotKeys/Models/AppHotKey.swift", "//\n// AppHotKey.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\ntypealias RawKeyCode = UInt16\ntypealias RawKeyModifiers = UInt\n\nstruct AppHotKey: Codable, Hashable {\n let value: String\n\n init(value: String) { self.value = value }\n\n init(keyCode: RawKeyCode, modifiers: RawKeyModifiers) {\n let keyEquivalent = KeyCodesMap.toString[keyCode] ?? \"\"\n let modifiers = KeyModifiersMap.toString(modifiers)\n let result = [modifiers, keyEquivalent].filter { !$0.isEmpty }.joined(separator: \"+\")\n\n self.init(value: result)\n }\n\n init(from decoder: Decoder) throws {\n enum CodingKeys: String, CodingKey { case keyCode, modifiers }\n\n if let container = try? decoder.container(keyedBy: CodingKeys.self) {\n // v1 -> v2 Migration\n let keyCode = try container.decodeIfPresent(RawKeyCode.self, forKey: .keyCode)\n let modifiers = try container.decodeIfPresent(RawKeyModifiers.self, forKey: .modifiers)\n\n if let keyCode, let modifiers {\n Migrations.hotKeysMigrated = true\n self.init(keyCode: keyCode, modifiers: modifiers)\n } else {\n throw DecodingError.dataCorruptedError(\n forKey: .keyCode,\n in: container,\n debugDescription: \"Invalid key code or modifiers\"\n )\n }\n } else {\n // v2\n let container = try decoder.singleValueContainer()\n try self.init(value: container.decode(String.self))\n }\n }\n\n func encode(to encoder: any Encoder) throws {\n var container = encoder.singleValueContainer()\n try container.encode(value)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/MenuBar/FlashSpaceMenuBar.swift", "//\n// FlashSpaceMenuBar.swift\n//\n// Created by Wojciech Kulik on 13/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct FlashSpaceMenuBar: Scene {\n @Environment(\\.openWindow) private var openWindow\n\n @StateObject private var workspaceManager = AppDependencies.shared.workspaceManager\n @StateObject private var settingsRepository = AppDependencies.shared.settingsRepository\n @StateObject private var profilesRepository = AppDependencies.shared.profilesRepository\n @StateObject private var workspaceRepository = AppDependencies.shared.workspaceRepository\n\n var body: some Scene {\n MenuBarExtra {\n Text(\"FlashSpace v\\(AppConstants.version)\")\n\n Button(\"Open\") {\n openWindow(id: \"main\")\n NSApp.activate(ignoringOtherApps: true)\n }\n\n if settingsRepository.spaceControlSettings.enableSpaceControl {\n Button(\"Space Control\") {\n SpaceControl.show()\n }\n }\n\n Divider()\n\n Button(\"Settings\") {\n openWindow(id: \"settings\")\n NSApp.activate(ignoringOtherApps: true)\n }.keyboardShortcut(\",\")\n\n Menu(\"Profiles\") {\n ForEach(profilesRepository.profiles) { profile in\n Toggle(\n profile.name,\n isOn: .init(\n get: { profilesRepository.selectedProfile == profile },\n set: {\n if $0 { profilesRepository.selectedProfile = profile }\n }\n )\n )\n }\n }.hidden(profilesRepository.profiles.count < 2)\n\n Menu(\"Workspaces\") {\n ForEach(workspaceRepository.workspaces) { workspace in\n Button {\n if workspace.isDynamic, workspace.displays.isEmpty {\n Toast.showWith(\n icon: \"square.stack.3d.up\",\n message: \"\\(workspace.name) - No Running Apps To Show\",\n textColor: .gray\n )\n } else {\n workspaceManager.activateWorkspace(workspace, setFocus: true)\n }\n } label: {\n Text(workspace.name)\n }\n .keyboardShortcut(workspace.activateShortcut?.toKeyboardShortcut)\n }\n }.hidden(workspaceRepository.workspaces.count < 2)\n\n Divider()\n\n Button(\"Donate\") {\n if let url = URL(string: \"https://github.com/sponsors/wojciech-kulik\") {\n NSWorkspace.shared.open(url)\n }\n }\n\n Button(\"Project Website\") {\n if let url = URL(string: \"https://github.com/wojciech-kulik/FlashSpace\") {\n NSWorkspace.shared.open(url)\n }\n }\n\n Button(\"Check for Updates\") {\n UpdatesManager.shared.checkForUpdates()\n }\n\n Divider()\n\n Button(\"Quit\") {\n NSApp.terminate(nil)\n }.keyboardShortcut(\"q\")\n } label: {\n HStack {\n let title = MenuBarTitle.get()\n if title == nil || settingsRepository.menuBarSettings.showMenuBarIcon {\n Image(systemName: workspaceManager.activeWorkspaceDetails?.symbolIconName ?? .defaultIconSymbol)\n }\n if let title { Text(title) }\n }\n .id(settingsRepository.menuBarSettings.menuBarTitleTemplate)\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/SpaceControl/SpaceControlSettingsView.swift", "//\n// SpaceControlSettingsView.swift\n//\n// Created by Wojciech Kulik on 11/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct SpaceControlSettingsView: View {\n @StateObject var settings = AppDependencies.shared.spaceControlSettings\n @State var hasScreenRecordingPermissions = false\n\n var body: some View {\n Form {\n Section {\n Toggle(\"Enable Space Control\", isOn: $settings.enableSpaceControl)\n }\n\n Group {\n Section(\"Permissions\") {\n HStack {\n if hasScreenRecordingPermissions {\n Image(systemName: \"checkmark.circle.fill\")\n .foregroundColor(.green)\n Text(\"Screen Recording Permission\")\n Spacer()\n } else {\n Image(systemName: \"xmark.circle.fill\")\n .foregroundColor(.red)\n Text(\"Screen Recording Permission\")\n Spacer()\n Button(\"Open Privacy & Security\") {\n NSWorkspace.shared.open(\n URL(string: \"x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture\")!\n )\n }\n }\n }\n Text(\n \"FlashSpace requires screen recording access to show your workspaces in Space Control. \" +\n \"The preview will be displayed upon first activation of the workspace.\"\n )\n .foregroundColor(.secondary)\n .font(.callout)\n }\n\n Section(\"Shortcuts\") {\n hotkey(\"Toggle Space Control\", for: $settings.showSpaceControl)\n }\n\n Section(\"Appearance\") {\n Toggle(\"Enable Animations\", isOn: $settings.enableSpaceControlAnimations)\n Toggle(\n \"Show Workspaces For Current Display Only\",\n isOn: $settings.spaceControlCurrentDisplayWorkspaces\n )\n\n HStack {\n Text(\"Max Number Of Columns\")\n Spacer()\n Text(\"\\(settings.spaceControlMaxColumns)\")\n Stepper(\n \"\",\n value: $settings.spaceControlMaxColumns,\n in: 2...20,\n step: 1\n ).labelsHidden()\n }\n }\n }\n .disabled(!settings.enableSpaceControl)\n .opacity(settings.enableSpaceControl ? 1 : 0.5)\n }\n .onAppear {\n hasScreenRecordingPermissions = PermissionsManager.shared.checkForScreenRecordingPermissions()\n }\n .onReceive(NotificationCenter.default.publisher(for: NSApplication.didBecomeActiveNotification)) { _ in\n hasScreenRecordingPermissions = PermissionsManager.shared.checkForScreenRecordingPermissions()\n }\n .formStyle(.grouped)\n .navigationTitle(\"Space Control\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Gestures/GestureAction.swift", "//\n// GestureAction.swift\n//\n// Created by Wojciech Kulik on 30/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nenum GestureAction {\n case none\n case toggleSpaceControl\n case showSpaceControl\n case hideSpaceControl\n case nextWorkspace\n case previousWorkspace\n case mostRecentWorkspace\n case focusLeft\n case focusRight\n case focusUp\n case focusDown\n case focusNextApp\n case focusPreviousApp\n case focusNextWindow\n case focusPreviousWindow\n case activateWorkspace(String)\n}\n\nextension GestureAction: CaseIterable, Equatable, Hashable, Identifiable {\n var id: String { description }\n\n var description: String {\n switch self {\n case .none: return \"None\"\n case .toggleSpaceControl: return \"Toggle Space Control\"\n case .showSpaceControl: return \"Show Space Control\"\n case .hideSpaceControl: return \"Hide Space Control\"\n case .nextWorkspace: return \"Next Workspace\"\n case .previousWorkspace: return \"Previous Workspace\"\n case .mostRecentWorkspace: return \"Most Recent Workspace\"\n case .focusLeft: return \"Focus Left\"\n case .focusRight: return \"Focus Right\"\n case .focusUp: return \"Focus Up\"\n case .focusDown: return \"Focus Down\"\n case .focusNextApp: return \"Focus Next App\"\n case .focusPreviousApp: return \"Focus Previous App\"\n case .focusNextWindow: return \"Focus Next Window\"\n case .focusPreviousWindow: return \"Focus Previous Window\"\n case .activateWorkspace(let workspaceName):\n return \"Activate Workspace: \\(workspaceName)\"\n }\n }\n\n static var allCases: [GestureAction] {\n let workspaces = AppDependencies.shared.workspaceRepository.workspaces\n return allCasesWithoutWorkspaces + workspaces.map { .activateWorkspace($0.name) }\n }\n\n static var allCasesWithoutWorkspaces: [GestureAction] {\n [\n .none,\n .toggleSpaceControl,\n .showSpaceControl,\n .hideSpaceControl,\n .nextWorkspace,\n .previousWorkspace,\n .mostRecentWorkspace,\n .focusLeft,\n .focusRight,\n .focusUp,\n .focusDown,\n .focusNextApp,\n .focusPreviousApp,\n .focusNextWindow,\n .focusPreviousWindow\n ]\n }\n}\n\nextension GestureAction: Codable {\n init(from decoder: Decoder) throws {\n let container = try decoder.singleValueContainer()\n let value = try container.decode(String.self)\n\n if value.hasPrefix(\"activateWorkspace:\") {\n let workspaceName = String(value.dropFirst(\"activateWorkspace:\".count))\n self = .activateWorkspace(workspaceName)\n } else if let action = GestureAction.allCasesWithoutWorkspaces.first(where: { $0.normalizedDescription == value }) {\n self = action\n } else {\n self = .none\n }\n }\n\n func encode(to encoder: Encoder) throws {\n var container = encoder.singleValueContainer()\n try container.encode(normalizedDescription)\n }\n\n private var normalizedDescription: String {\n if case .activateWorkspace(let workspaceName) = self {\n return \"activateWorkspace:\\(workspaceName)\"\n }\n\n let result = String(description.first?.lowercased() ?? \"\") + description.dropFirst()\n return result.replacingOccurrences(of: \" \", with: \"\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/CLI/CLISettingsView.swift", "//\n// CLISettingsView.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct CLISettingsView: View {\n @State var isInstalled = false\n @State var isRunning = false\n\n var body: some View {\n Form {\n Section(\"Status\") {\n HStack {\n if isRunning {\n Image(systemName: \"checkmark.circle.fill\")\n .foregroundColor(.green)\n Text(\"FlashSpace CLI Status\")\n Spacer()\n } else {\n Image(systemName: \"xmark.circle.fill\")\n .foregroundColor(.red)\n\n Text(\"FlashSpace CLI Status\")\n Spacer()\n Button(\"Restart\") {\n AppDependencies.shared.cliServer.restart()\n isRunning = AppDependencies.shared.cliServer.isRunning\n }\n }\n }\n\n HStack {\n if isInstalled {\n Image(systemName: \"checkmark.circle.fill\")\n .foregroundColor(.green)\n Text(\"FlashSpace CLI Installation\")\n Spacer()\n Button(\"Uninstall FlashSpace CLI\") {\n CLI.uninstall()\n isInstalled = CLI.isInstalled\n }\n } else {\n Image(systemName: \"xmark.circle.fill\")\n .foregroundColor(.red)\n Text(\"FlashSpace CLI Installation\")\n Spacer()\n Button(\"Install FlashSpace CLI\") {\n CLI.install()\n isInstalled = CLI.isInstalled\n }\n }\n }\n\n VStack(alignment: .leading) {\n Text(\n \"\"\"\n Tool will be installed in /usr/local/bin/flashspace.\n\n You can also access it directly from the app bundle at:\n \"\"\"\n )\n Text(CLI.cliPath)\n .lineLimit(1)\n .truncationMode(.middle)\n .help(CLI.cliPath)\n }\n .foregroundColor(.secondary)\n .font(.callout)\n }\n\n Section {\n Text(\"Run `flashspace --help` in the terminal to see the available commands.\")\n .foregroundStyle(.secondary)\n .font(.callout)\n }\n }\n .onAppear {\n isInstalled = CLI.isInstalled\n isRunning = AppDependencies.shared.cliServer.isRunning\n }\n .formStyle(.grouped)\n .navigationTitle(\"CLI\")\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Get/GetProfileCommand.swift", "//\n// GetProfileCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport ArgumentParser\nimport Foundation\n\nstruct GetProfileCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"get-profile\",\n abstract: \"Get active profile\"\n )\n\n func run() throws {\n sendCommand(.getProfile)\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Profiles/ProfilesSettingsView.swift", "//\n// ProfilesSettingsView.swift\n//\n// Created by Wojciech Kulik on 26/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct ProfilesSettingsView: View {\n @StateObject var viewModel = ProfilesSettingsViewModel()\n @StateObject var profilesRepository = AppDependencies.shared.profilesRepository\n\n var body: some View {\n Form {\n Section(\n header: HStack {\n Text(\"Profiles\")\n Spacer()\n Button {\n viewModel.createNewProfile()\n } label: {\n Image(systemName: \"plus\")\n }\n }\n ) {\n VStack(alignment: .leading) {\n ForEach(profilesRepository.profiles) { profile in\n HStack {\n Button {\n viewModel.deleteProfile(profile)\n } label: {\n Image(systemName: \"x.circle.fill\").opacity(0.8)\n }\n .buttonStyle(.borderless)\n .hidden(viewModel.hideDeleteButton)\n\n Button {\n viewModel.renameProfile(profile)\n } label: {\n Text(profile.name)\n }\n .buttonStyle(.borderless)\n .tint(.primary)\n }\n }\n }\n }\n }\n .formStyle(.grouped)\n .sheet(isPresented: $viewModel.isInputDialogPresented) {\n InputDialog(\n title: \"Enter profile name:\",\n userInput: $viewModel.userInput,\n isPresented: $viewModel.isInputDialogPresented\n )\n }\n .alert(\n \"Are you sure you want to delete \\\"\\(viewModel.profileToDelete)\\\" profile?\",\n isPresented: $viewModel.isDeleteConfirmationPresented\n ) {\n Button(\"Delete\", role: .destructive) {\n viewModel.deleteConfirmed()\n }\n Button(\"Cancel\", role: .cancel) {}\n } message: {\n Text(\"This action cannot be undone.\")\n }\n .alert(\n \"Do you want to copy the current workspaces to the new profile?\",\n isPresented: $viewModel.isCopyChoicePresented\n ) {\n Button(\"Copy\") { viewModel.createNewProfile(copyWorkspaces: true) }\n Button(\"No\", role: .cancel) { viewModel.createNewProfile(copyWorkspaces: false) }\n }\n .onChange(of: viewModel.isInputDialogPresented) { _, isPresented in\n if !isPresented {\n viewModel.inputDialogDismissed()\n }\n }\n .navigationTitle(\"Profiles\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Config/ConfigSerializer.swift", "//\n// ConfigSerializer.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\nimport TOMLKit\nimport Yams\n\nenum ConfigSerializer {\n static let configDirectory = FileManager.default\n .homeDirectoryForCurrentUser\n .appendingPathComponent(\".config/flashspace\")\n\n private(set) static var format: ConfigFormat = detectFormat()\n\n static func serialize(filename: String, _ value: some Encodable) throws {\n let url = getUrl(for: filename)\n let data = try encoder.encode(value)\n try? url.createIntermediateDirectories()\n try data.write(to: url)\n }\n\n static func deserialize(_ type: T.Type, filename: String) throws -> T? where T: Decodable {\n let url = getUrl(for: filename)\n\n guard FileManager.default.fileExists(atPath: url.path) else { return nil }\n\n do {\n let data = try Data(contentsOf: url)\n\n return try decoder.decode(type, from: data)\n } catch {\n Logger.log(\"Failed to deserialize \\(filename): \\(error)\")\n throw error\n }\n }\n\n static func convert(to: ConfigFormat) throws {\n guard format != to else { return }\n\n let settingsUrl = getUrl(for: \"settings\", ext: format.rawValue)\n let profilesUrl = getUrl(for: \"profiles\", ext: format.rawValue)\n let timestamp = Int(Date().timeIntervalSince1970)\n\n try? FileManager.default.moveItem(\n at: settingsUrl,\n to: configDirectory.appendingPathComponent(\"settings-backup-\\(timestamp).\\(format.rawValue)\")\n )\n try? FileManager.default.moveItem(\n at: profilesUrl,\n to: configDirectory.appendingPathComponent(\"profiles-backup-\\(timestamp).\\(format.rawValue)\")\n )\n\n format = to\n AppDependencies.shared.settingsRepository.saveToDisk()\n AppDependencies.shared.profilesRepository.saveToDisk()\n\n Logger.log(\"Converted config format to \\(to.displayName)\")\n }\n}\n\nprivate extension ConfigSerializer {\n static var encoder: ConfigEncoder {\n switch format {\n case .json: return jsonEncoder\n case .toml: return tomlEncoder\n case .yaml: return yamlEncoder\n }\n }\n\n static var decoder: ConfigDecoder {\n switch format {\n case .json: return jsonDecoder\n case .toml: return tomlDecoder\n case .yaml: return yamlDecoder\n }\n }\n\n static let jsonDecoder = JSONDecoder()\n static let jsonEncoder = {\n let encoder = JSONEncoder()\n encoder.outputFormatting = [\n .prettyPrinted,\n .withoutEscapingSlashes,\n .sortedKeys\n ]\n return encoder\n }()\n\n static let tomlDecoder = TOMLDecoder()\n static let tomlEncoder = TOMLEncoder()\n static let yamlEncoder = YAMLEncoder()\n static let yamlDecoder = YAMLDecoder()\n\n static func getUrl(for filename: String, ext: String? = nil) -> URL {\n configDirectory\n .appendingPathComponent(filename)\n .appendingPathExtension(ext ?? ConfigSerializer.format.extensionName)\n }\n\n static func detectFormat() -> ConfigFormat {\n for format in ConfigFormat.allCases {\n let url = getUrl(for: \"profiles\", ext: format.rawValue)\n if FileManager.default.fileExists(atPath: url.path) {\n Logger.log(\"Detected config format \\(format.displayName) at \\(url.path)\")\n return format\n }\n }\n\n return .json\n }\n}\n"], ["/FlashSpace/FlashSpace/Accessibility/NSRunningApplication+Properties.swift", "//\n// NSRunningApplication+Properties.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension NSRunningApplication {\n var frame: CGRect? { mainWindow?.frame }\n var isMinimized: Bool { mainWindow?.isMinimized == true }\n\n var display: DisplayName? {\n // HACK: Workaround for Orion Browser which puts\n // the main window on the main screen with size (1,1)\n if isOrion {\n allWindows\n .first { $0.frame.width > 10 && $0.frame.height > 10 }?\n .frame\n .getDisplay()\n } else {\n frame?.getDisplay()\n }\n }\n\n var allDisplays: Set {\n allWindows\n .compactMap { $0.frame.getDisplay() }\n .asSet\n }\n\n var mainWindow: AXUIElement? {\n // HACK: Python app with running pygame module is causing\n // huge lags when other apps attempt to access its window\n // through the accessibility API.\n // A workaround is to simply skip this app.\n guard !isPython else { return nil }\n\n let appElement = AXUIElementCreateApplication(processIdentifier)\n return appElement.getAttribute(.mainWindow)\n }\n\n var focusedWindow: AXUIElement? {\n guard !isPython else { return nil }\n\n let appElement = AXUIElementCreateApplication(processIdentifier)\n return appElement.getAttribute(.focusedWindow)\n }\n\n var allWindows: [(window: AXUIElement, frame: CGRect)] {\n guard !isPython else { return [] }\n\n let appElement = AXUIElementCreateApplication(processIdentifier)\n let windows: [AXUIElement]? = appElement.getAttribute(.windows)\n\n return windows?\n .filter { $0.role == \"AXWindow\" }\n .compactMap { window in window.frame.flatMap { (window, $0) } }\n ?? []\n }\n\n func isOnAnyDisplay(_ displays: Set) -> Bool {\n !allDisplays.isDisjoint(with: displays)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/PictureInPicture/PictureInPictureManager.swift", "//\n// PictureInPictureManager.swift\n//\n// Created by Wojciech Kulik on 12/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Combine\n\nfinal class PictureInPictureManager {\n typealias AXWindow = AXUIElement\n\n private var hiddenWindows: [NSRunningApplication: [AXWindow]] = [:]\n private var capturedFrame: [AXWindow: CGRect] = [:]\n private var cancellables: Set = []\n private var windowFocusObserver: AXObserver?\n\n private let settings: WorkspaceSettings\n\n init(settingsRepository: SettingsRepository) {\n self.settings = settingsRepository.workspaceSettings\n setupSignalHandlers()\n observePipFocusChangeNotification()\n }\n\n func restoreAppIfNeeded(app: NSRunningApplication) {\n guard settings.enablePictureInPictureSupport else { return }\n\n if hiddenWindows.keys.contains(app) {\n restoreFromCornerNonPipWindows(app: app)\n }\n }\n\n func restoreAllWindows() {\n for app in hiddenWindows.keys {\n showPipAppIfNeeded(app: app)\n }\n }\n\n func showPipAppIfNeeded(app: NSRunningApplication) {\n guard settings.enablePictureInPictureSupport,\n app.supportsPictureInPicture else { return }\n\n restoreFromCornerNonPipWindows(app: app)\n }\n\n func hidePipAppIfNeeded(app: NSRunningApplication) -> Bool {\n guard settings.enablePictureInPictureSupport,\n app.supportsPictureInPicture,\n app.isPictureInPictureActive\n else { return false }\n\n guard hiddenWindows[app] == nil else { return true }\n\n guard settings.displayMode == .static || app.allDisplays.count <= 1 else {\n // pip is not supported for multi-display apps\n return false\n }\n\n return hideInCornerNonPipWindows(app: app)\n }\n\n private func observePipFocusChangeNotification() {\n NotificationCenter.default\n .publisher(for: .pipFocusChanged)\n .sink { [weak self] _ in self?.restorePipWorkspace() }\n .store(in: &cancellables)\n }\n\n private func restorePipWorkspace() {\n guard let app = hiddenWindows.keys.first(where: { !$0.isPictureInPictureActive }) else { return }\n\n restoreAllWindows()\n\n let workspaceRepository = AppDependencies.shared.workspaceRepository\n let workspaceManager = AppDependencies.shared.workspaceManager\n let workspace = workspaceRepository.workspaces.first { $0.apps.containsApp(app) }\n\n guard let workspace else { return }\n\n windowFocusObserver = nil\n workspaceManager.activateWorkspace(workspace, setFocus: false)\n }\n\n private func restoreFromCornerNonPipWindows(app: NSRunningApplication) {\n windowFocusObserver = nil\n\n app.runWithoutAnimations {\n for window in hiddenWindows[app] ?? [] {\n if let previousFrame = capturedFrame[window] {\n window.setPosition(previousFrame.origin)\n capturedFrame.removeValue(forKey: window)\n }\n }\n }\n\n hiddenWindows.removeValue(forKey: app)\n }\n\n private func hideInCornerNonPipWindows(app: NSRunningApplication) -> Bool {\n guard let screenCorner = findScreenCorner(app: app) else { return false }\n\n let nonPipWindows = app.allWindows\n .map(\\.window)\n .filter { !$0.isPictureInPicture(bundleId: app.bundleIdentifier) }\n\n if nonPipWindows.isNotEmpty { observePipApp(app) }\n\n app.runWithoutAnimations {\n for window in nonPipWindows {\n if let windowFrame = window.frame, screenCorner != windowFrame.origin {\n capturedFrame[window] = windowFrame\n window.setPosition(screenCorner)\n }\n }\n }\n hiddenWindows[app] = nonPipWindows\n\n return true\n }\n\n private func findScreenCorner(app: NSRunningApplication) -> CGPoint? {\n guard let appScreen = NSScreen.screen(app.display) else {\n return nil\n }\n\n // Screen origin (0,0) is in the bottom-left corner, y-axis is pointing up\n // Window origin (0,0) is in the top-left corner, y-axis is pointing down\n // E.g. To place a window in the bottom-right corner of the screen\n // we need to set window origin to:\n // (screen.maxX - window.width, screen.maxY - window.height).\n\n let testOffset: CGFloat = 30.0\n let cornerOffset = CGFloat(settings.pipScreenCornerOffset)\n let appFrame = app.frame\n let screenFrame = appScreen.frame\n let leftCorner = CGPoint(x: screenFrame.minX, y: screenFrame.minY)\n let rightCorner = CGPoint(x: screenFrame.maxX, y: screenFrame.minY)\n let leftSide = leftCorner.applying(\n CGAffineTransform(translationX: -testOffset, y: testOffset)\n )\n let leftBottomSide = leftCorner.applying(\n CGAffineTransform(translationX: testOffset, y: -testOffset)\n )\n let rightSide = rightCorner.applying(\n CGAffineTransform(translationX: testOffset, y: testOffset)\n )\n let rightBottomSide = rightCorner.applying(\n CGAffineTransform(translationX: -testOffset, y: -testOffset)\n )\n\n let allScreens = NSScreen.screens.map(\\.frame)\n let isLeftCornerUsed = allScreens.contains(where: { $0.contains(leftSide) || $0.contains(leftBottomSide) })\n let isRightCornerUsed = allScreens.contains(where: { $0.contains(rightSide) || $0.contains(rightBottomSide) })\n\n if isLeftCornerUsed || !isRightCornerUsed || appFrame == nil {\n // right corner (window coordinates)\n return CGPoint(\n x: screenFrame.maxX - cornerOffset,\n y: screenFrame.maxY - cornerOffset\n )\n } else {\n // left corner (window coordinates)\n let appFrame = appFrame ?? .zero\n return CGPoint(\n x: screenFrame.minX + cornerOffset - appFrame.width,\n y: screenFrame.maxY - cornerOffset\n )\n }\n }\n\n private func setupSignalHandlers() {\n for code in [SIGTERM, SIGINT] {\n signal(code) {\n AppDependencies.shared.pictureInPictureManager.restoreAllWindows()\n exit($0)\n }\n }\n }\n\n private func observePipApp(_ app: NSRunningApplication) {\n guard settings.switchWorkspaceWhenPipCloses else { return }\n\n let callback: AXObserverCallback = { _, _, _, _ in\n NotificationCenter.default.post(name: .pipFocusChanged, object: nil)\n }\n\n let result = AXObserverCreate(app.processIdentifier, callback, &windowFocusObserver)\n\n guard result == .success, let observer = windowFocusObserver else { return }\n\n let appRef = AXUIElementCreateApplication(app.processIdentifier)\n AXObserverAddNotification(observer, appRef, kAXFocusedWindowChangedNotification as CFString, nil)\n CFRunLoopAddSource(CFRunLoopGetCurrent(), AXObserverGetRunLoopSource(observer), .defaultMode)\n }\n\n // MARK: - Alternative solution by minimizing windows (animation)\n private func deminimizeAllWindows(app: NSRunningApplication) {\n for window in app.allWindows.map(\\.window) {\n window.minimize(false)\n }\n }\n\n private func minimizeNonPipWindows(app: NSRunningApplication) {\n app.allWindows\n .map(\\.window)\n .filter { !$0.isPictureInPicture(bundleId: app.bundleIdentifier) }\n .forEach { $0.minimize(true) }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Workspaces/Models/MacApp.swift", "//\n// MacApp.swift\n//\n// Created by Wojciech Kulik on 06/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\ntypealias BundleId = String\n\nstruct MacApp: Codable, Hashable, Equatable {\n var name: String\n var bundleIdentifier: BundleId\n var iconPath: String?\n\n init(\n name: String,\n bundleIdentifier: BundleId,\n iconPath: String?\n ) {\n self.name = name\n self.bundleIdentifier = bundleIdentifier\n self.iconPath = iconPath\n }\n\n init(app: NSRunningApplication) {\n self.name = app.localizedName ?? \"\"\n self.bundleIdentifier = app.bundleIdentifier ?? \"\"\n self.iconPath = app.iconPath\n }\n\n init(from decoder: any Decoder) throws {\n if let app = try? decoder.singleValueContainer().decode(String.self) {\n // V1 - migration\n let runningApp = NSWorkspace.shared.runningApplications\n .first { $0.localizedName == app }\n\n self.name = app\n\n if let runningApp {\n self.bundleIdentifier = runningApp.bundleIdentifier ?? \"\"\n self.iconPath = runningApp.iconPath\n } else if let bundle = Bundle(path: \"/Applications/\\(app).app\") {\n self.bundleIdentifier = bundle.bundleIdentifier ?? \"\"\n self.iconPath = bundle.iconPath\n } else if let bundle = Bundle(path: \"/System/Applications/\\(app).app\") {\n self.bundleIdentifier = bundle.bundleIdentifier ?? \"\"\n self.iconPath = bundle.iconPath\n } else {\n self.bundleIdentifier = \"\"\n self.iconPath = nil\n }\n\n Migrations.appsMigrated = true\n } else {\n // V2\n let container = try decoder.container(keyedBy: CodingKeys.self)\n self.name = try container.decode(String.self, forKey: .name)\n self.bundleIdentifier = try container.decode(String.self, forKey: .bundleIdentifier)\n self.iconPath = try container.decodeIfPresent(String.self, forKey: .iconPath)\n }\n }\n\n static func == (lhs: MacApp, rhs: MacApp) -> Bool {\n if lhs.bundleIdentifier.isEmpty || rhs.bundleIdentifier.isEmpty {\n return lhs.name == rhs.name\n } else {\n return lhs.bundleIdentifier == rhs.bundleIdentifier\n }\n }\n}\n\nextension MacApp {\n var isFinder: Bool {\n bundleIdentifier == \"com.apple.finder\"\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/General/GeneralSettingsView.swift", "//\n// GeneralSettingsView.swift\n//\n// Created by Wojciech Kulik on 23/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport SwiftUI\n\nstruct GeneralSettingsView: View {\n @StateObject var settings = AppDependencies.shared.generalSettings\n @State var isAutostartEnabled = false\n @State var hasAccessibilityPermissions = false\n\n var body: some View {\n Form {\n Section {\n Toggle(\"Launch at startup\", isOn: $isAutostartEnabled)\n Toggle(\"Check for updates automatically\", isOn: $settings.checkForUpdatesAutomatically)\n }\n\n Section(\"Permissions\") {\n HStack {\n if hasAccessibilityPermissions {\n Image(systemName: \"checkmark.circle.fill\")\n .foregroundColor(.green)\n Text(\"Accessibility Permissions\")\n Spacer()\n } else {\n Image(systemName: \"xmark.circle.fill\")\n .foregroundColor(.red)\n Text(\"Accessibility Permissions\")\n Spacer()\n Button(\"Open Privacy & Security\") {\n NSWorkspace.shared.open(\n URL(string: \"x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility\")!\n )\n }\n }\n }\n Text(\"FlashSpace requires accessibility access to manage applications.\")\n .foregroundColor(.secondary)\n .font(.callout)\n }\n\n Section(\"Shortcuts\") {\n hotkey(\"Toggle FlashSpace\", for: $settings.showFlashSpace)\n }\n\n Section(\"Notifications\") {\n Toggle(\"Enable Notifications\", isOn: $settings.showFloatingNotifications)\n Text(\"Some shortcuts will show a temporary notification.\")\n .foregroundStyle(.secondary)\n .font(.callout)\n }\n }\n .onAppear {\n isAutostartEnabled = AppDependencies.shared.autostartService.isLaunchAtLoginEnabled\n hasAccessibilityPermissions = PermissionsManager.shared.checkForAccessibilityPermissions()\n }\n .onChange(of: isAutostartEnabled) { _, enabled in\n if enabled {\n AppDependencies.shared.autostartService.enableLaunchAtLogin()\n } else {\n AppDependencies.shared.autostartService.disableLaunchAtLogin()\n }\n }\n .onReceive(NotificationCenter.default.publisher(for: NSApplication.didBecomeActiveNotification)) { _ in\n hasAccessibilityPermissions = PermissionsManager.shared.checkForAccessibilityPermissions()\n }\n .formStyle(.grouped)\n .navigationTitle(\"General\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/MainScreen/MainView.swift", "//\n// MainView.swift\n// FlashSpace\n//\n// Created by Wojciech Kulik on 19/01/2025.\n//\n\nimport AppKit\nimport SwiftUI\nimport SymbolPicker\n\nstruct MainView: View {\n @StateObject var viewModel = MainViewModel()\n\n var body: some View {\n HStack(spacing: 16.0) {\n workspaces\n assignedApps\n WorkspaceConfigurationView(viewModel: viewModel)\n .frame(maxWidth: 230)\n }\n .padding()\n .fixedSize()\n .sheet(isPresented: $viewModel.isInputDialogPresented) {\n InputDialog(\n title: \"Enter workspace name:\",\n userInput: $viewModel.userInput,\n isPresented: $viewModel.isInputDialogPresented\n )\n }\n .sheet(isPresented: $viewModel.isSymbolPickerPresented) {\n SymbolPicker(symbol: $viewModel.workspaceSymbolIconName)\n }\n }\n\n private var workspaces: some View {\n VStack(alignment: .leading) {\n Text(\"Workspaces:\")\n\n List(\n $viewModel.workspaces,\n id: \\.self,\n editActions: .move,\n selection: $viewModel.selectedWorkspaces\n ) { binding in\n WorkspaceCell(\n selectedApps: $viewModel.selectedApps,\n workspace: binding.wrappedValue\n )\n }\n .frame(width: 200, height: 350)\n\n HStack {\n Button(action: viewModel.addWorkspace) {\n Image(systemName: \"plus\")\n }\n\n Button(action: viewModel.deleteSelectedWorkspaces) {\n Image(systemName: \"trash\")\n }.disabled(viewModel.selectedWorkspaces.isEmpty)\n\n Spacer()\n }\n }\n }\n\n private var assignedApps: some View {\n VStack(alignment: .leading) {\n Text(\"Assigned Apps:\")\n\n List(\n viewModel.workspaceApps ?? [],\n id: \\.self,\n selection: $viewModel.selectedApps\n ) { app in\n AppCell(\n workspaceId: viewModel.selectedWorkspace?.id ?? UUID(),\n app: app\n )\n }\n .frame(width: 200, height: 350)\n\n HStack {\n Button(action: viewModel.addApp) {\n Image(systemName: \"plus\")\n }.disabled(viewModel.selectedWorkspace == nil)\n\n Button(action: viewModel.deleteSelectedApps) {\n Image(systemName: \"trash\")\n }\n .disabled(viewModel.selectedApps.isEmpty)\n .keyboardShortcut(.delete)\n }\n }\n }\n}\n\n#Preview {\n MainView()\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/FloatingApps/FloatingAppsSettingsView.swift", "//\n// FloatingAppsSettingsView.swift\n//\n// Created by Wojciech Kulik on 12/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct FloatingAppsSettingsView: View {\n @StateObject var viewModel = FloatingAppsSettingsViewModel()\n @StateObject var settings = AppDependencies.shared.floatingAppsSettings\n\n var body: some View {\n Form {\n Section(header: header) {\n if settings.floatingApps.contains(where: \\.bundleIdentifier.isEmpty) {\n Text(\"Could not migrate some apps. Please re-add them to fix the problem.\")\n .foregroundStyle(.errorRed)\n .font(.callout)\n }\n\n if settings.floatingApps.isEmpty {\n Text(\"(no floating apps added)\")\n .foregroundStyle(.secondary)\n .font(.callout)\n } else {\n appsList\n }\n\n Text(\"Floating applications remain visible across all workspaces.\")\n .foregroundStyle(.secondary)\n .font(.callout)\n }\n\n Section(\"Shortcuts\") {\n hotkey(\"Float Focused App\", for: $settings.floatTheFocusedApp)\n hotkey(\"Unfloat Focused App\", for: $settings.unfloatTheFocusedApp)\n hotkey(\"Toggle Focused App Floating\", for: $settings.toggleTheFocusedAppFloating)\n }\n }\n .formStyle(.grouped)\n .navigationTitle(\"Floating Apps\")\n }\n\n private var appsList: some View {\n VStack(alignment: .leading) {\n ForEach(settings.floatingApps, id: \\.self) { app in\n HStack {\n Button {\n viewModel.deleteFloatingApp(app: app)\n } label: {\n Image(systemName: \"x.circle.fill\").opacity(0.8)\n }.buttonStyle(.borderless)\n\n Text(app.name)\n .foregroundStyle(app.bundleIdentifier.isEmpty ? .errorRed : .primary)\n }\n }\n }\n }\n\n private var header: some View {\n HStack {\n Text(\"Floating Apps\")\n Spacer()\n Button(action: viewModel.addFloatingApp) {\n Image(systemName: \"plus\")\n }\n }\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Models/CommandRequest.swift", "//\n// CommandRequest.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nenum CommandRequest: Codable {\n case createWorkspace(CreateWorkspaceRequest)\n case deleteWorkspace(name: String)\n case updateWorkspace(UpdateWorkspaceRequest)\n case activateWorkspace(name: String?, number: Int?, clean: Bool)\n case nextWorkspace(skipEmpty: Bool, clean: Bool, loop: Bool)\n case previousWorkspace(skipEmpty: Bool, clean: Bool, loop: Bool)\n case hideUnassignedApps\n case recentWorkspace(clean: Bool)\n\n case assignVisibleApps(workspaceName: String?, showNotification: Bool)\n case assignApp(app: String?, workspaceName: String?, activate: Bool?, showNotification: Bool)\n case unassignApp(app: String?, showNotification: Bool)\n\n case floatApp(app: String?, showNotification: Bool)\n case unfloatApp(app: String?, showNotification: Bool)\n case toggleFloatApp(app: String?, showNotification: Bool)\n\n case focusWindow(direction: FocusDirection)\n case focusNextWindow\n case focusPreviousWindow\n case focusNextApp\n case focusPreviousApp\n\n case createProfile(name: String, copy: Bool, activate: Bool)\n case deleteProfile(name: String)\n case activateProfile(name: String)\n\n case openSpaceControl\n\n case listProfiles\n case listWorkspaces(withDisplay: Bool, profile: String?)\n case listApps(\n workspace: String,\n profile: String?,\n withBundleId: Bool,\n withIcon: Bool,\n onlyRunning: Bool\n )\n case listFloatingApps(withBundleId: Bool)\n\n case getProfile\n case getWorkspace(display: String?)\n case getApp(withWindowsCount: Bool)\n case getDisplay\n}\n\nenum FocusDirection: String, Codable, ExpressibleByArgument, CaseIterable {\n case left, right, up, down\n}\n"], ["/FlashSpace/FlashSpace/Features/SpaceControl/Views/SpaceControlView.swift", "//\n// SpaceControlView.swift\n//\n// Created by Wojciech Kulik on 11/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct SpaceControlView: View {\n @Environment(\\.colorScheme) var colorScheme\n @StateObject var viewModel = SpaceControlViewModel()\n\n var body: some View {\n let columns = Array(repeating: GridItem(.flexible()), count: viewModel.numberOfColumns)\n let width = (NSScreen.main?.frame.width ?? 1200) / CGFloat(viewModel.numberOfColumns) - 70.0\n let height = (NSScreen.main?.frame.height ?? 800) / CGFloat(viewModel.numberOfRows) - 120.0\n\n LazyVGrid(columns: columns, spacing: viewModel.numberOfRows == 2 ? 90.0 : 60.0) {\n ForEach(viewModel.workspaces, id: \\.index) { workspace in\n VStack(alignment: .leading, spacing: 16.0) {\n workspaceName(workspace)\n\n Group {\n if let image = workspace.screenshotData.flatMap(NSImage.init(data:)) {\n workspacePreview(image: image, width: width, height: height)\n } else {\n workspacePlaceholder(width: width, height: height)\n }\n }\n .overlay(alignment: .topTrailing) { workspaceNumber(workspace.index + 1) }\n .overlay(\n RoundedRectangle(cornerRadius: 18.0)\n .stroke(\n workspace.isActive\n ? workspace.originalWorkspace.isOnTheCurrentScreen\n ? Color.positive\n : Color.teal\n : Color.black.opacity(0.8),\n lineWidth: 3.0\n )\n )\n .compositingGroup()\n .shadow(\n color: .black.opacity(workspace.screenshotData != nil ? 0.8 : 0.0),\n radius: 20.0,\n x: 0.0,\n y: 0.0\n )\n }\n .onTapGesture { viewModel.onWorkspaceTap(workspace) }\n }\n }\n .multilineTextAlignment(.center)\n .padding()\n .frame(maxWidth: .infinity, maxHeight: .infinity)\n }\n\n private func workspacePreview(image: NSImage, width: CGFloat, height: CGFloat) -> some View {\n Image(nsImage: image)\n .resizable()\n .scaledToFit()\n .frame(maxWidth: width, maxHeight: height)\n .aspectRatio(16.0 / 9.0, contentMode: .fit)\n .background(Color.black.opacity(0.4))\n .clipShape(RoundedRectangle(cornerRadius: 18.0))\n }\n\n private func workspacePlaceholder(width: CGFloat, height: CGFloat) -> some View {\n RoundedRectangle(cornerRadius: 18.0)\n .fill(Color.black.opacity(0.5))\n .frame(maxWidth: width, maxHeight: height)\n .aspectRatio(16.0 / 9.0, contentMode: .fit)\n .overlay {\n Text(\"Preview Not Available\")\n .font(.title)\n .foregroundColor(.white)\n .padding()\n .frame(maxWidth: .infinity, maxHeight: .infinity)\n }\n .clipped()\n }\n\n private func workspaceName(_ workspace: SpaceControlWorkspace) -> some View {\n HStack(spacing: 16.0) {\n Image(systemName: workspace.symbol)\n .resizable()\n .scaledToFit()\n .frame(height: 17.0)\n .foregroundColor(colorScheme == .dark ? .workspaceIcon : .primary)\n\n Text(workspace.name)\n .foregroundColor(.primary)\n .font(.title2)\n }\n .fontWeight(.semibold)\n .lineLimit(1)\n .compositingGroup()\n .shadow(\n color: .black.opacity(colorScheme == .dark ? 0.8 : 0.25),\n radius: 4.0,\n x: 0.0,\n y: 0.0\n )\n }\n\n private func workspaceNumber(_ number: Int) -> some View {\n Text(\"\\(number)\")\n .foregroundColor(.white)\n .font(.title3)\n .frame(width: 40.0)\n .padding(.vertical, 8.0)\n .background(Color.black)\n .cornerRadius(18.0, corners: [.topRight])\n .cornerRadius(8.0, corners: [.bottomLeft])\n }\n}\n"], ["/FlashSpace/FlashSpace/Accessibility/NSRunningApplication+Actions.swift", "//\n// NSRunningApplication+Actions.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension NSRunningApplication {\n func raise() {\n guard let mainWindow else {\n unhide()\n return\n }\n\n AXUIElementPerformAction(mainWindow, NSAccessibility.Action.raise as CFString)\n }\n\n /// Position is in window coordinates where (0,0) is top-left corner\n /// and it is relative to the main screen.\n func setPosition(_ position: CGPoint) {\n mainWindow?.setPosition(position)\n }\n\n func centerApp(display: DisplayName) {\n guard let appFrame = frame else {\n return Logger.log(\"Could not get frame for app: \\(localizedName ?? \"\")\")\n }\n\n guard let nsScreen = NSScreen.screen(display) else { return }\n guard appFrame.getDisplay() != nsScreen.localizedName else { return }\n\n let normalizedScreenFrame = nsScreen.normalizedFrame\n\n let origin = CGPoint(\n x: normalizedScreenFrame.midX - appFrame.width / 2.0,\n y: normalizedScreenFrame.midY - appFrame.height / 2.0\n )\n\n setPosition(origin)\n }\n\n func runWithoutAnimations(action: () -> ()) {\n let appElement = AXUIElementCreateApplication(processIdentifier)\n let wasEnabled = appElement.enhancedUserInterface\n\n if wasEnabled { appElement.setAttribute(.enchancedUserInterface, value: false) }\n\n action()\n\n if wasEnabled { appElement.setAttribute(.enchancedUserInterface, value: true) }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Models/CommandRequest.swift", "//\n// CommandRequest.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nenum CommandRequest: Codable {\n case createWorkspace(CreateWorkspaceRequest)\n case deleteWorkspace(name: String)\n case updateWorkspace(UpdateWorkspaceRequest)\n case activateWorkspace(name: String?, number: Int?, clean: Bool)\n case nextWorkspace(skipEmpty: Bool, clean: Bool, loop: Bool)\n case previousWorkspace(skipEmpty: Bool, clean: Bool, loop: Bool)\n case recentWorkspace(clean: Bool)\n\n case assignVisibleApps(workspaceName: String?, showNotification: Bool)\n case assignApp(app: String?, workspaceName: String?, activate: Bool?, showNotification: Bool)\n case unassignApp(app: String?, showNotification: Bool)\n case hideUnassignedApps\n\n case floatApp(app: String?, showNotification: Bool)\n case unfloatApp(app: String?, showNotification: Bool)\n case toggleFloatApp(app: String?, showNotification: Bool)\n\n case focusWindow(direction: FocusDirection)\n case focusNextWindow\n case focusPreviousWindow\n case focusNextApp\n case focusPreviousApp\n\n case createProfile(name: String, copy: Bool, activate: Bool)\n case deleteProfile(name: String)\n case activateProfile(name: String)\n\n case openSpaceControl\n\n case listProfiles\n case listWorkspaces(withDisplay: Bool, profile: String?)\n case listApps(\n workspace: String,\n profile: String?,\n withBundleId: Bool,\n withIcon: Bool,\n onlyRunning: Bool\n )\n case listFloatingApps(withBundleId: Bool)\n\n case getProfile\n case getWorkspace(display: String?)\n case getApp(withWindowsCount: Bool)\n case getDisplay\n}\n\nenum FocusDirection: String, Codable {\n case left, right, up, down\n}\n"], ["/FlashSpace/FlashSpace/Extensions/NSScreen.swift", "//\n// NSScreen.swift\n//\n// Created by Wojciech Kulik on 18/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension NSScreen {\n /// Returns the screen's frame where (x,y) is top-left corner relative\n /// to the main screen's top-left corner.\n var normalizedFrame: CGRect {\n let mainScreen = NSScreen.screens[0]\n return NSRect(\n x: frame.origin.x,\n y: mainScreen.frame.height - frame.origin.y - frame.height,\n width: frame.width,\n height: frame.height\n )\n }\n\n static func isConnected(_ display: DisplayName) -> Bool {\n NSScreen.screens.contains { $0.localizedName == display }\n }\n\n static func screen(_ display: DisplayName?) -> NSScreen? {\n NSScreen.screens.first { $0.localizedName == display }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/FocusManager/FocusManager.swift", "//\n// FocusManager.swift\n//\n// Created by Wojciech Kulik on 23/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\n\nfinal class FocusManager {\n var visibleApps: [NSRunningApplication] {\n NSWorkspace.shared.runningApplications\n .filter { $0.activationPolicy == .regular && !$0.isHidden }\n }\n\n var focusedApp: NSRunningApplication? { NSWorkspace.shared.frontmostApplication }\n var focusedAppFrame: CGRect? { focusedApp?.frame }\n\n private let workspaceRepository: WorkspaceRepository\n private let workspaceManager: WorkspaceManager\n private let settings: FocusManagerSettings\n private let floatingAppsSettings: FloatingAppsSettings\n\n init(\n workspaceRepository: WorkspaceRepository,\n workspaceManager: WorkspaceManager,\n focusManagerSettings: FocusManagerSettings,\n floatingAppsSettings: FloatingAppsSettings\n ) {\n self.workspaceRepository = workspaceRepository\n self.workspaceManager = workspaceManager\n self.settings = focusManagerSettings\n self.floatingAppsSettings = floatingAppsSettings\n }\n\n func getHotKeys() -> [(AppHotKey, () -> ())] {\n guard settings.enableFocusManagement else { return [] }\n\n return [\n settings.focusLeft.flatMap { ($0, focusLeft) },\n settings.focusRight.flatMap { ($0, focusRight) },\n settings.focusUp.flatMap { ($0, focusUp) },\n settings.focusDown.flatMap { ($0, focusDown) },\n settings.focusNextWorkspaceApp.flatMap { ($0, nextWorkspaceApp) },\n settings.focusPreviousWorkspaceApp.flatMap { ($0, previousWorkspaceApp) },\n settings.focusNextWorkspaceWindow.flatMap { ($0, nextWorkspaceWindow) },\n settings.focusPreviousWorkspaceWindow.flatMap { ($0, previousWorkspaceWindow) }\n ].compactMap { $0 }\n }\n\n func nextWorkspaceWindow() {\n guard let focusedApp else { return nextWorkspaceApp() }\n guard let (_, apps) = getFocusedAppIndex() else { return }\n\n let runningWorkspaceApps = getRunningAppsWithSortedWindows(apps: apps)\n let focusedAppWindows = runningWorkspaceApps\n .first { $0.bundleIdentifier == focusedApp.bundleIdentifier }?\n .windows ?? []\n let isLastWindowFocused = focusedAppWindows.last?.axWindow.isMain == true\n\n if isLastWindowFocused {\n let nextApps = runningWorkspaceApps.drop(while: { $0.bundleIdentifier != focusedApp.bundleIdentifier }).dropFirst() +\n runningWorkspaceApps.prefix(while: { $0.bundleIdentifier != focusedApp.bundleIdentifier })\n let nextApp = nextApps.first ?? MacAppWithWindows(app: focusedApp)\n\n nextApp.app.activate()\n nextApp\n .windows\n .first?\n .axWindow\n .focus()\n } else {\n focusedAppWindows\n .drop(while: { !$0.axWindow.isMain })\n .dropFirst()\n .first?\n .axWindow\n .focus()\n }\n }\n\n func previousWorkspaceWindow() {\n guard let focusedApp else { return previousWorkspaceApp() }\n guard let (_, apps) = getFocusedAppIndex() else { return }\n\n let runningWorkspaceApps = getRunningAppsWithSortedWindows(apps: apps)\n let focusedAppWindows = runningWorkspaceApps\n .first { $0.bundleIdentifier == focusedApp.bundleIdentifier }?\n .windows ?? []\n let isFirstWindowFocused = focusedAppWindows.first?.axWindow.isMain == true\n\n if isFirstWindowFocused {\n let prevApps = runningWorkspaceApps.drop(while: { $0.bundleIdentifier != focusedApp.bundleIdentifier }).dropFirst() +\n runningWorkspaceApps.prefix(while: { $0.bundleIdentifier != focusedApp.bundleIdentifier })\n let prevApp = prevApps.last ?? MacAppWithWindows(app: focusedApp)\n\n prevApp.app.activate()\n prevApp\n .windows\n .last?\n .axWindow\n .focus()\n } else {\n focusedAppWindows\n .prefix(while: { !$0.axWindow.isMain })\n .last?\n .axWindow\n .focus()\n }\n }\n\n func nextWorkspaceApp() {\n guard let (index, apps) = getFocusedAppIndex() else { return }\n\n let appsQueue = apps.dropFirst(index + 1) + apps.prefix(index)\n let runningApps = NSWorkspace.shared.runningApplications\n .excludeFloatingAppsOnDifferentScreen()\n .compactMap(\\.bundleIdentifier)\n .asSet\n let nextApp = appsQueue.first { app in runningApps.contains(app.bundleIdentifier) }\n\n NSWorkspace.shared.runningApplications\n .find(nextApp)?\n .activate()\n }\n\n func previousWorkspaceApp() {\n guard let (index, apps) = getFocusedAppIndex() else { return }\n\n let runningApps = NSWorkspace.shared.runningApplications\n .excludeFloatingAppsOnDifferentScreen()\n .compactMap(\\.bundleIdentifier)\n .asSet\n let prefixApps = apps.prefix(index).reversed()\n let suffixApps = apps.suffix(apps.count - index - 1).reversed()\n let appsQueue = prefixApps + Array(suffixApps)\n let previousApp = appsQueue.first { app in runningApps.contains(app.bundleIdentifier) }\n\n NSWorkspace.shared.runningApplications\n .find(previousApp)?\n .activate()\n }\n\n func focusRight() {\n focus { focusedAppFrame, other in\n other.maxX > focusedAppFrame.maxX &&\n other.verticalIntersect(with: focusedAppFrame)\n }\n }\n\n func focusLeft() {\n focus { focusedAppFrame, other in\n other.minX < focusedAppFrame.minX &&\n other.verticalIntersect(with: focusedAppFrame)\n }\n }\n\n func focusDown() {\n focus { focusedAppFrame, other in\n other.maxY > focusedAppFrame.maxY &&\n other.horizontalIntersect(with: focusedAppFrame)\n }\n }\n\n func focusUp() {\n focus { focusedAppFrame, other in\n other.minY < focusedAppFrame.minY &&\n other.horizontalIntersect(with: focusedAppFrame)\n }\n }\n\n /// Predicate compares two frames using window coordinates.\n /// (0,0) is top-left corner relative to the main screen.\n /// Y-axis is pointing down.\n private func focus(predicate: (CGRect, CGRect) -> Bool) {\n guard let focusedAppFrame else { return }\n\n let appsToCheck = visibleApps\n .flatMap { app in\n app.allWindows.map {\n (app: app, window: $0.window, frame: $0.frame)\n }\n }\n\n let toFocus = appsToCheck\n .filter { predicate(focusedAppFrame, $0.frame) && !$0.window.isMinimized }\n .sorted { $0.frame.distance(to: focusedAppFrame) < $1.frame.distance(to: focusedAppFrame) }\n .first { app in\n guard settings.focusFrontmostWindow else { return true }\n\n let otherWindows = appsToCheck\n .filter { $0.app != app.app && $0.app != focusedApp }\n .map(\\.window)\n return !app.window.isBelowAnyOf(otherWindows)\n }\n\n toFocus?.window.focus()\n toFocus?.app.activate()\n centerCursorIfNeeded(in: toFocus?.frame)\n }\n\n private func centerCursorIfNeeded(in frame: CGRect?) {\n guard settings.centerCursorOnFocusChange, let frame else { return }\n\n CGWarpMouseCursorPosition(CGPoint(x: frame.midX, y: frame.midY))\n }\n\n private func getFocusedAppIndex() -> (Int, [MacApp])? {\n guard let focusedApp else { return nil }\n\n let workspace = workspaceManager.activeWorkspace[NSScreen.main?.localizedName ?? \"\"]\n ?? workspaceRepository.workspaces.first { $0.apps.containsApp(focusedApp) }\n\n guard let workspace else { return nil }\n\n let apps = workspace.apps + floatingAppsSettings.floatingApps\n .filter { !$0.isFinder }\n\n let index = apps.firstIndex(of: focusedApp) ?? 0\n\n return (index, apps)\n }\n\n private func getRunningAppsWithSortedWindows(apps: [MacApp]) -> [MacAppWithWindows] {\n let order = apps\n .enumerated()\n .reduce(into: [String: Int]()) {\n $0[$1.element.bundleIdentifier] = $1.offset\n }\n\n return NSWorkspace.shared.runningApplications\n .filter { !$0.isHidden && apps.containsApp($0) }\n .excludeFloatingAppsOnDifferentScreen()\n .map { MacAppWithWindows(app: $0) }\n .sorted { order[$0.bundleIdentifier] ?? 0 < order[$1.bundleIdentifier] ?? 0 }\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/NSRunningApplication.swift", "//\n// NSRunningApplication.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension NSRunningApplication {\n var toMacApp: MacApp { .init(app: self) }\n var iconPath: String? { bundleURL?.iconPath }\n}\n\nextension [NSRunningApplication] {\n func find(_ app: MacApp?) -> NSRunningApplication? {\n guard let app else { return nil }\n\n return first { $0.bundleIdentifier == app.bundleIdentifier }\n }\n\n func findFirstMatch(with apps: [MacApp]) -> NSRunningApplication? {\n let bundleIdentifiers = apps.map(\\.bundleIdentifier).asSet\n\n return first { bundleIdentifiers.contains($0.bundleIdentifier ?? \"\") }\n }\n\n func excludeFloatingAppsOnDifferentScreen() -> [NSRunningApplication] {\n let activeWorkspace = AppDependencies.shared.workspaceManager.activeWorkspace[NSScreen.main?.localizedName ?? \"\"]\n let floatingApps = AppDependencies.shared.floatingAppsSettings.floatingApps\n\n guard let activeWorkspace else { return self }\n\n return filter { app in\n !floatingApps.containsApp(app) || app.isOnAnyDisplay(activeWorkspace.displays)\n }\n }\n\n func regularVisibleApps(onDisplays displays: Set, excluding apps: [MacApp]) -> [NSRunningApplication] {\n filter { app in\n app.activationPolicy == .regular &&\n !app.isHidden &&\n !apps.containsApp(app) &&\n app.isOnAnyDisplay(displays)\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/UI/HotKeyControl.swift", "//\n// HotKeyControl.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport ShortcutRecorder\nimport SwiftUI\n\nstruct HotKeyControl: NSViewRepresentable {\n @Binding var shortcut: AppHotKey?\n\n func makeNSView(context: Context) -> RecorderControl {\n let control = RecorderControl(frame: .zero)\n control.delegate = context.coordinator\n control.objectValue = shortcut.flatMap { $0.toShortcut() }\n control.set(\n allowedModifierFlags: [.command, .option, .control, .shift],\n requiredModifierFlags: [],\n allowsEmptyModifierFlags: true\n )\n\n return control\n }\n\n func updateNSView(_ nsView: RecorderControl, context: Context) {\n context.coordinator.parent = self\n nsView.objectValue = shortcut.flatMap { $0.toShortcut() }\n }\n\n func makeCoordinator() -> Coordinator { Coordinator(parent: self) }\n\n final class Coordinator: NSObject, RecorderControlDelegate {\n var parent: HotKeyControl\n\n private let hotKeysManager = AppDependencies.shared.hotKeysManager\n\n init(parent: HotKeyControl) {\n self.parent = parent\n }\n\n func recorderControlDidBeginRecording(_ aControl: RecorderControl) {\n hotKeysManager.disableAll()\n }\n\n func recorderControl(_ aControl: RecorderControl, canRecord aShortcut: Shortcut) -> Bool {\n if let conflict = hotKeysManager.allHotKeys.first(where: { $0.hotKey.toShortcut() == aShortcut })?.scope {\n Alert.showOkAlert(\n title: \"Conflict\",\n message: \"This shortcut is already assigned within the \\(conflict) scope.\"\n )\n return false\n }\n\n return true\n }\n\n func recorderControlDidEndRecording(_ aControl: RecorderControl) {\n guard let shortcut = aControl.objectValue else {\n parent.shortcut = nil\n hotKeysManager.enableAll()\n return\n }\n\n parent.shortcut = .init(\n keyCode: shortcut.keyCode.rawValue,\n modifiers: shortcut.modifierFlags.rawValue\n )\n hotKeysManager.enableAll()\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Integrations/IntegrationsSettings.swift", "//\n// IntegrationsSettings.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nfinal class IntegrationsSettings: ObservableObject {\n static let defaultWorkspaceChangeScript = \"sketchybar --trigger flashspace_workspace_change WORKSPACE=\\\"$WORKSPACE\\\" DISPLAY=\\\"$DISPLAY\\\"\"\n static let defaultProfileChangeScript = \"sketchybar --reload\"\n\n @Published var enableIntegrations = false\n @Published var runScriptOnLaunch = \"\"\n @Published var runScriptOnWorkspaceChange = IntegrationsSettings.defaultWorkspaceChangeScript\n @Published var runScriptOnProfileChange = IntegrationsSettings.defaultProfileChangeScript\n\n private var observer: AnyCancellable?\n private let updateSubject = PassthroughSubject<(), Never>()\n\n init() {\n observe()\n\n DispatchQueue.main.async {\n Integrations.runOnAppLaunchIfNeeded()\n }\n }\n\n private func observe() {\n observer = Publishers.MergeMany(\n $enableIntegrations.settingsPublisher(),\n $runScriptOnWorkspaceChange.settingsPublisher(debounce: true),\n $runScriptOnLaunch.settingsPublisher(debounce: true),\n $runScriptOnProfileChange.settingsPublisher(debounce: true)\n )\n .receive(on: DispatchQueue.main)\n .sink { [weak self] in self?.updateSubject.send() }\n }\n}\n\nextension IntegrationsSettings: SettingsProtocol {\n var updatePublisher: AnyPublisher<(), Never> {\n updateSubject.eraseToAnyPublisher()\n }\n\n func load(from appSettings: AppSettings) {\n observer = nil\n enableIntegrations = appSettings.enableIntegrations ?? false\n runScriptOnLaunch = appSettings.runScriptOnLaunch ?? \"\"\n runScriptOnWorkspaceChange = appSettings.runScriptOnWorkspaceChange ?? Self.defaultWorkspaceChangeScript\n runScriptOnProfileChange = appSettings.runScriptOnProfileChange ?? Self.defaultProfileChangeScript\n observe()\n }\n\n func update(_ appSettings: inout AppSettings) {\n appSettings.enableIntegrations = enableIntegrations\n appSettings.runScriptOnLaunch = runScriptOnLaunch\n appSettings.runScriptOnWorkspaceChange = runScriptOnWorkspaceChange\n appSettings.runScriptOnProfileChange = runScriptOnProfileChange\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/SpaceControl/Views/SpaceControlWindow.swift", "//\n// SpaceControlWindow.swift\n//\n// Created by Wojciech Kulik on 11/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport SwiftUI\n\nfinal class SpaceControlWindow: NSWindow, NSWindowDelegate {\n override var canBecomeKey: Bool { true }\n\n override func keyDown(with event: NSEvent) {\n if event.keyCode == KeyCodesMap[\"escape\"] {\n SpaceControl.hide(restoreFocus: true)\n return\n } else if [\"up\", \"down\", \"right\", \"left\"]\n .compactMap({ KeyCodesMap[$0] })\n .contains(event.keyCode) {\n NotificationCenter.default.post(name: .spaceControlArrowDown, object: event.keyCode)\n return\n }\n\n let settings = AppDependencies.shared.spaceControlSettings\n let workspaceManager = AppDependencies.shared.workspaceManager\n var workspaces = AppDependencies.shared.workspaceRepository.workspaces\n\n if settings.spaceControlCurrentDisplayWorkspaces {\n workspaces = workspaces.filter(\\.isOnTheCurrentScreen)\n }\n\n var digit = Int(event.charactersIgnoringModifiers ?? \"\") ?? -1\n if (0...9).contains(digit) {\n SpaceControl.hide()\n digit = digit == 0 ? 10 : digit\n\n if let workspace = workspaces[safe: digit - 1] {\n workspaceManager.activateWorkspace(workspace, setFocus: true)\n }\n return\n }\n\n super.keyDown(with: event)\n }\n\n override func resignFirstResponder() -> Bool {\n SpaceControl.hide()\n return super.resignFirstResponder()\n }\n\n func windowDidResignKey(_ notification: Notification) {\n SpaceControl.hide()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Extensions/ParsableCommand.swift", "//\n// ParsableCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nextension ParsableCommand {\n func sendCommand(_ command: CommandRequest) {\n SocketClient.shared.sendCommand(command)\n }\n\n func fallbackToHelp() {\n print(Self.helpMessage(for: Self.self))\n Self.exit(withError: CommandError.other)\n }\n\n func runWithTimeout() {\n RunLoop.current.run(until: Date().addingTimeInterval(5.0))\n Self.exit(withError: CommandError.timeout)\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/List/ListDisplays.swift", "//\n// ListDisplays.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport ArgumentParser\nimport Foundation\n\nstruct ListDisplaysCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"list-displays\",\n abstract: \"List displays\"\n )\n\n func run() throws {\n for screen in NSScreen.screens {\n print(screen.localizedName)\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/_Models/AppSettings.swift", "//\n// AppSettings.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nstruct AppSettings: Codable {\n // General\n var checkForUpdatesAutomatically: Bool?\n var showFlashSpace: AppHotKey?\n var showFloatingNotifications: Bool?\n\n // Menu Bar\n var showMenuBarTitle: Bool?\n var showMenuBarIcon: Bool?\n var menuBarTitleTemplate: String?\n var menuBarDisplayAliases: String?\n\n // Focus Manager\n var enableFocusManagement: Bool?\n var centerCursorOnFocusChange: Bool?\n var focusLeft: AppHotKey?\n var focusRight: AppHotKey?\n var focusUp: AppHotKey?\n var focusDown: AppHotKey?\n var focusNextWorkspaceApp: AppHotKey?\n var focusPreviousWorkspaceApp: AppHotKey?\n var focusNextWorkspaceWindow: AppHotKey?\n var focusPreviousWorkspaceWindow: AppHotKey?\n var focusFrontmostWindow: Bool?\n\n // Gestures\n var enableSwipeGestures: Bool?\n var swipeThreshold: Double?\n var restartAppOnWakeUp: Bool?\n var swipeLeft3FingerAction: GestureAction?\n var swipeRight3FingerAction: GestureAction?\n var swipeUp3FingerAction: GestureAction?\n var swipeDown3FingerAction: GestureAction?\n var swipeLeft4FingerAction: GestureAction?\n var swipeRight4FingerAction: GestureAction?\n var swipeUp4FingerAction: GestureAction?\n var swipeDown4FingerAction: GestureAction?\n\n // Workspaces\n var displayMode: DisplayMode?\n var centerCursorOnWorkspaceChange: Bool?\n var changeWorkspaceOnAppAssign: Bool?\n var activeWorkspaceOnFocusChange: Bool?\n var skipEmptyWorkspacesOnSwitch: Bool?\n var keepUnassignedAppsOnSwitch: Bool?\n var restoreHiddenAppsOnSwitch: Bool?\n var loopWorkspaces: Bool?\n var switchToPreviousWorkspace: AppHotKey?\n var switchToNextWorkspace: AppHotKey?\n var switchToRecentWorkspace: AppHotKey?\n var assignFocusedApp: AppHotKey?\n var unassignFocusedApp: AppHotKey?\n var toggleFocusedAppAssignment: AppHotKey?\n var assignVisibleApps: AppHotKey?\n var hideUnassignedApps: AppHotKey?\n var alternativeDisplays: String?\n var enablePictureInPictureSupport: Bool?\n var switchWorkspaceWhenPipCloses: Bool?\n var pipApps: [PipApp]?\n var pipScreenCornerOffset: Int?\n\n // Floating apps\n var floatingApps: [MacApp]?\n var floatTheFocusedApp: AppHotKey?\n var unfloatTheFocusedApp: AppHotKey?\n var toggleTheFocusedAppFloating: AppHotKey?\n\n // Space Control\n var enableSpaceControl: Bool?\n var showSpaceControl: AppHotKey?\n var enableSpaceControlAnimations: Bool?\n var spaceControlCurrentDisplayWorkspaces: Bool?\n var spaceControlMaxColumns: Int?\n var enableWorkspaceTransitions: Bool?\n var workspaceTransitionDuration: Double?\n var workspaceTransitionDimming: Double?\n\n // Integrations\n var enableIntegrations: Bool?\n var runScriptOnLaunch: String?\n var runScriptOnWorkspaceChange: String?\n var runScriptOnProfileChange: String?\n}\n"], ["/FlashSpace/FlashSpace/Features/HotKeys/HotKeysManager.swift", "//\n// HotKeysManager.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Combine\nimport ShortcutRecorder\n\nfinal class HotKeysManager {\n private(set) var allHotKeys: [(scope: String, hotKey: AppHotKey)] = []\n\n private var cancellables = Set()\n\n private let hotKeysMonitor: HotKeysMonitorProtocol\n private let workspaceHotKeys: WorkspaceHotKeys\n private let floatingAppsHotKeys: FloatingAppsHotKeys\n private let focusManager: FocusManager\n private let settingsRepository: SettingsRepository\n\n init(\n hotKeysMonitor: HotKeysMonitorProtocol,\n workspaceHotKeys: WorkspaceHotKeys,\n floatingAppsHotKeys: FloatingAppsHotKeys,\n focusManager: FocusManager,\n settingsRepository: SettingsRepository\n ) {\n self.hotKeysMonitor = hotKeysMonitor\n self.workspaceHotKeys = workspaceHotKeys\n self.floatingAppsHotKeys = floatingAppsHotKeys\n self.focusManager = focusManager\n self.settingsRepository = settingsRepository\n\n observe()\n }\n\n func refresh() {\n disableAll()\n enableAll()\n }\n\n // swiftlint:disable:next function_body_length\n func enableAll() {\n allHotKeys.removeAll()\n let addShortcut = { (title: String, shortcut: Shortcut) in\n self.allHotKeys.append((title, .init(\n keyCode: shortcut.keyCode.rawValue,\n modifiers: shortcut.modifierFlags.rawValue\n )))\n }\n\n // Workspaces\n for (shortcut, action) in workspaceHotKeys.getHotKeys().toShortcutPairs() {\n let action = ShortcutAction(shortcut: shortcut) { _ in\n action()\n return true\n }\n\n hotKeysMonitor.addAction(action, forKeyEvent: .down)\n addShortcut(\"Workspace\", shortcut)\n }\n\n // Floating Apps\n for (shortcut, action) in floatingAppsHotKeys.getHotKeys().toShortcutPairs() {\n let action = ShortcutAction(shortcut: shortcut) { _ in\n action()\n return true\n }\n\n hotKeysMonitor.addAction(action, forKeyEvent: .down)\n addShortcut(\"Floating Apps\", shortcut)\n }\n\n // Focus Manager\n for (shortcut, action) in focusManager.getHotKeys().toShortcutPairs() {\n let action = ShortcutAction(shortcut: shortcut) { _ in\n action()\n return true\n }\n hotKeysMonitor.addAction(action, forKeyEvent: .down)\n addShortcut(\"Focus Manager\", shortcut)\n }\n\n // General\n if let showHotKey = settingsRepository.generalSettings.showFlashSpace?.toShortcut() {\n let action = ShortcutAction(shortcut: showHotKey) { _ in\n guard !SpaceControl.isVisible else { return true }\n\n let visibleAppWindows = NSApp.windows\n .filter(\\.isVisible)\n .filter { $0.identifier?.rawValue == \"main\" || $0.identifier?.rawValue == \"settings\" }\n\n if visibleAppWindows.isEmpty {\n NotificationCenter.default.post(name: .openMainWindow, object: nil)\n } else {\n visibleAppWindows.forEach { $0.close() }\n }\n return true\n }\n hotKeysMonitor.addAction(action, forKeyEvent: .down)\n addShortcut(\"General\", showHotKey)\n }\n\n // SpaceControl\n if let (hotKey, action) = SpaceControl.getHotKey(), let shortcut = hotKey.toShortcut() {\n let action = ShortcutAction(shortcut: shortcut) { _ in\n action()\n return true\n }\n hotKeysMonitor.addAction(action, forKeyEvent: .down)\n addShortcut(\"Space Control\", shortcut)\n }\n }\n\n func disableAll() {\n hotKeysMonitor.removeAllActions()\n }\n\n private func observe() {\n NotificationCenter.default\n .publisher(for: .profileChanged)\n .sink { [weak self] _ in self?.refresh() }\n .store(in: &cancellables)\n\n DistributedNotificationCenter.default()\n .publisher(for: .init(rawValue: kTISNotifySelectedKeyboardInputSourceChanged as String))\n .sink { [weak self] _ in\n KeyCodesMap.refresh()\n self?.disableAll()\n self?.enableAll()\n }\n .store(in: &cancellables)\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/List/ListProfilesCommand.swift", "//\n// ListProfilesCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct ListProfilesCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"list-profiles\",\n abstract: \"List profiles\"\n )\n\n func run() throws {\n sendCommand(.listProfiles)\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/FocusManager/FocusSettingsView.swift", "//\n// FocusSettingsView.swift\n//\n// Created by Wojciech Kulik on 23/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct FocusSettingsView: View {\n @StateObject private var settings = AppDependencies.shared.focusManagerSettings\n\n var body: some View {\n Form {\n Section {\n Toggle(\"Enable Focus Manager\", isOn: $settings.enableFocusManagement)\n }\n\n Group {\n Section(\"Trigger when focus is changed using shortcuts\") {\n Toggle(\"Center Cursor In Focused App\", isOn: $settings.centerCursorOnFocusChange)\n }\n\n Section(\"Shortcuts\") {\n hotkey(\"Focus Left\", for: $settings.focusLeft)\n hotkey(\"Focus Right\", for: $settings.focusRight)\n hotkey(\"Focus Up\", for: $settings.focusUp)\n hotkey(\"Focus Down\", for: $settings.focusDown)\n }\n\n Section {\n hotkey(\"Focus Next App\", for: $settings.focusNextWorkspaceApp)\n hotkey(\"Focus Previous App\", for: $settings.focusPreviousWorkspaceApp)\n }\n\n Section {\n hotkey(\"Focus Next Window\", for: $settings.focusNextWorkspaceWindow)\n hotkey(\"Focus Previous Window\", for: $settings.focusPreviousWorkspaceWindow)\n }\n\n Section(\"Experimental\") {\n Toggle(\"Focus Frontmost Window\", isOn: $settings.focusFrontmostWindow)\n Text(\n \"This is an experimental feature. It sets the focus to the frontmost window\" +\n \" if two or more windows are overlapping in the pointed direction.\\n\\n\" +\n \"It works only with directional focus shortcuts (left, right, up, down).\"\n )\n .foregroundStyle(.secondary)\n .font(.callout)\n }\n }\n .disabled(!settings.enableFocusManagement)\n .opacity(settings.enableFocusManagement ? 1 : 0.5)\n }\n .formStyle(.grouped)\n .navigationTitle(\"Focus Manager\")\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Open/OpenSpaceControlCommand.swift", "//\n// OpenSpaceControlCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct OpenSpaceControlCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"open-space-control\",\n abstract: \"Open Space Control\"\n )\n\n func run() throws {\n sendCommand(.openSpaceControl)\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/App/HideUnassignedAppsCommand.swift", "//\n// HideUnassignedAppsCommand.swift\n//\n// Created by Wojciech Kulik on 07/05/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct HideUnassignedAppsCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"hide-unassigned-apps\",\n abstract: \"Hide all unassigned apps\"\n )\n\n func run() throws {\n sendCommand(.hideUnassignedApps)\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/ConfigurationFile/ConfigurationFileSettingsView.swift", "//\n// ConfigurationFileSettingsView.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport SwiftUI\n\nstruct ConfigurationFileSettingsView: View {\n @State var configFormat: ConfigFormat = ConfigSerializer.format\n\n var body: some View {\n Form {\n Section {\n Picker(\"Format\", selection: $configFormat) {\n ForEach(ConfigFormat.allCases, id: \\.rawValue) { format in\n Text(format.displayName).tag(format)\n }\n }.onChange(of: configFormat) { _, newFormat in\n try? ConfigSerializer.convert(to: newFormat)\n }\n\n HStack {\n Text(\"Location: \\(ConfigSerializer.configDirectory.path)\")\n .foregroundStyle(.secondary)\n .font(.callout)\n Spacer()\n Button(\"Reveal\") {\n NSWorkspace.shared.open(ConfigSerializer.configDirectory)\n }\n }\n\n Text(\n \"If you manually edit the configuration file, make sure to restart FlashSpace.\\n\" +\n \"Custom formatting, order, comments, etc. will be overwritten if you change something in the app.\"\n )\n .foregroundStyle(.secondary)\n .font(.callout)\n }\n }\n .formStyle(.grouped)\n .navigationTitle(\"Configuration File\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Accessibility/AXUIElement+CoreGraphics.swift", "//\n// AXUIElement+CoreGraphics.swift\n//\n// Created by Wojciech Kulik on 21/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension AXUIElement {\n var cgWindowId: CGWindowID? {\n let title = title\n let pid = processId\n\n if let windowList = CGWindowListCopyWindowInfo(.optionOnScreenOnly, kCGNullWindowID) as? [[String: Any]] {\n for window in windowList {\n let windowOwnerPID = window[kCGWindowOwnerPID as String] as? pid_t\n let windowName = window[kCGWindowName as String] as? String\n let windowNumber = window[kCGWindowNumber as String] as? CGWindowID\n\n if title == windowName, windowOwnerPID == pid {\n return windowNumber\n }\n }\n }\n\n return nil\n }\n\n func isBelowAnyOf(_ windows: [AXUIElement]) -> Bool {\n guard let cgWindowId, let frame else { return false }\n\n let otherWindows = windows.map { (id: $0.cgWindowId, window: $0) }\n let windowsAbove = CGWindowListCopyWindowInfo(.optionOnScreenAboveWindow, cgWindowId) as? [[String: Any]] ?? [[:]]\n let windowsAboveIds = Set(\n windowsAbove.compactMap { $0[kCGWindowNumber as String] as? CGWindowID }\n )\n\n return otherWindows.contains { otherWindowId, otherWindow in\n if let otherWindowId,\n windowsAboveIds.contains(otherWindowId),\n let otherWindowFrame = otherWindow.frame,\n frame.intersects(otherWindowFrame) {\n Logger.log(\"💡 Window \\\"\\(title ?? \"unknown\")\\\" is below \\\"\\(otherWindow.title ?? \"unknown\")\\\"\")\n return true\n }\n\n return false\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/HotKeys/Extensions/AppHotKey+KeyboardShortcut.swift", "//\n// AppHotKey+KeyboardShortcut.swift\n//\n// Created by Wojciech Kulik on 31/05/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nextension AppHotKey {\n var toKeyboardShortcut: KeyboardShortcut? {\n let components = value.components(separatedBy: \"+\")\n let modifiers = toEventModifiers(value)\n\n guard let key = components.last,\n let keyEquivalent = stringToKeyEquivalent(key) else { return nil }\n\n return KeyboardShortcut(\n keyEquivalent,\n modifiers: modifiers\n )\n }\n\n // swiftlint:disable:next cyclomatic_complexity\n private func stringToKeyEquivalent(_ value: String) -> KeyEquivalent? {\n guard value.count > 1 else { return KeyEquivalent(Character(value)) }\n\n switch value {\n case \"esc\", \"escape\": return KeyEquivalent.escape\n case \"return\", \"enter\": return KeyEquivalent.return\n case \"tab\": return KeyEquivalent.tab\n case \"space\": return KeyEquivalent.space\n case \"delete\", \"backspace\": return KeyEquivalent.delete\n case \"up\": return KeyEquivalent.upArrow\n case \"down\": return KeyEquivalent.downArrow\n case \"left\": return KeyEquivalent.leftArrow\n case \"right\": return KeyEquivalent.rightArrow\n case \"home\": return KeyEquivalent.home\n case \"end\": return KeyEquivalent.end\n default: return nil\n }\n }\n\n private func toEventModifiers(_ value: String) -> EventModifiers {\n let flags = value.lowercased().split(separator: \"+\").map { String($0) }\n var result: EventModifiers = []\n\n if flags.contains(\"cmd\") { result.insert(.command) }\n if flags.contains(\"ctrl\") { result.insert(.control) }\n if flags.contains(\"opt\") { result.insert(.option) }\n if flags.contains(\"shift\") { result.insert(.shift) }\n\n return result\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Workspaces/WorkspaceTransitionManager.swift", "//\n// WorkspaceTransitionManager.swift\n//\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n// Contribution by Sergio Patino - https://github.com/sergiopatino\n//\n\nimport AppKit\n\nfinal class WorkspaceTransitionManager {\n private var windows: [NSWindow] = []\n private let settings: WorkspaceSettings\n\n init(workspaceSettings: WorkspaceSettings) {\n self.settings = workspaceSettings\n }\n\n func showTransitionIfNeeded(for workspace: Workspace, on displays: Set) {\n guard settings.enableWorkspaceTransitions else {\n // Small delay to allow workspace to be activated\n DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {\n NotificationCenter.default.post(name: .workspaceTransitionFinished, object: workspace)\n }\n return\n }\n guard windows.isEmpty, !SpaceControl.isVisible else { return }\n\n let screens = NSScreen.screens.filter { displays.contains($0.localizedName) }\n\n guard !screens.isEmpty else { return }\n\n for screen in screens {\n let window = NSWindow(\n contentRect: screen.frame,\n styleMask: [.borderless],\n backing: .buffered,\n defer: false\n )\n window.isOpaque = false\n window.backgroundColor = .clear\n window.level = .screenSaver\n window.alphaValue = CGFloat(settings.workspaceTransitionDimming)\n window.contentView?.wantsLayer = true\n window.contentView?.layer?.backgroundColor = NSColor.black.cgColor\n\n window.orderFrontRegardless()\n windows.append(window)\n }\n\n DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { [weak self] in\n self?.hideTransition(for: workspace)\n }\n }\n\n private func hideTransition(for workspace: Workspace) {\n guard !windows.isEmpty else { return }\n\n NSAnimationContext.runAnimationGroup({ [weak self] context in\n context.duration = self?.settings.workspaceTransitionDuration ?? 0.3\n context.timingFunction = CAMediaTimingFunction(name: .easeIn)\n self?.windows.forEach { window in\n window.animator().alphaValue = 0.0\n }\n }, completionHandler: { [weak self] in\n self?.windows.forEach { window in\n window.orderOut(nil)\n }\n self?.windows.removeAll()\n NotificationCenter.default.post(name: .workspaceTransitionFinished, object: workspace)\n })\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/SettingsRepository.swift", "//\n// SettingsRepository.swift\n//\n// Created by Wojciech Kulik on 23/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nfinal class SettingsRepository: ObservableObject {\n private(set) var generalSettings: GeneralSettings\n private(set) var menuBarSettings: MenuBarSettings\n private(set) var gesturesSettings: GesturesSettings\n private(set) var focusManagerSettings: FocusManagerSettings\n private(set) var workspaceSettings: WorkspaceSettings\n private(set) var floatingAppsSettings: FloatingAppsSettings\n private(set) var spaceControlSettings: SpaceControlSettings\n private(set) var integrationsSettings: IntegrationsSettings\n\n private lazy var allSettings: [SettingsProtocol] = [\n generalSettings,\n menuBarSettings,\n gesturesSettings,\n focusManagerSettings,\n workspaceSettings,\n floatingAppsSettings,\n spaceControlSettings,\n integrationsSettings\n ]\n\n private var currentSettings = AppSettings()\n private var cancellables = Set()\n private var shouldUpdate = false\n\n init(\n generalSettings: GeneralSettings,\n menuBarSettings: MenuBarSettings,\n gesturesSettings: GesturesSettings,\n focusManagerSettings: FocusManagerSettings,\n workspaceSettings: WorkspaceSettings,\n floatingAppsSettings: FloatingAppsSettings,\n spaceControlSettings: SpaceControlSettings,\n integrationsSettings: IntegrationsSettings\n ) {\n self.generalSettings = generalSettings\n self.menuBarSettings = menuBarSettings\n self.gesturesSettings = gesturesSettings\n self.focusManagerSettings = focusManagerSettings\n self.workspaceSettings = workspaceSettings\n self.floatingAppsSettings = floatingAppsSettings\n self.spaceControlSettings = spaceControlSettings\n self.integrationsSettings = integrationsSettings\n\n loadFromDisk()\n\n Publishers.MergeMany(allSettings.map(\\.updatePublisher))\n .sink { [weak self] in self?.updateSettings() }\n .store(in: &cancellables)\n }\n\n func saveToDisk() {\n Logger.log(\"Saving settings to disk\")\n try? ConfigSerializer.serialize(filename: \"settings\", currentSettings)\n }\n\n private func updateSettings() {\n guard shouldUpdate else { return }\n\n var settings = AppSettings()\n allSettings.forEach { $0.update(&settings) }\n currentSettings = settings\n saveToDisk()\n\n AppDependencies.shared.hotKeysManager.refresh()\n objectWillChange.send()\n }\n\n private func loadFromDisk() {\n Logger.log(\"Loading settings from disk\")\n\n shouldUpdate = false\n defer { shouldUpdate = true }\n\n guard let settings = try? ConfigSerializer.deserialize(\n AppSettings.self,\n filename: \"settings\"\n ) else { return }\n\n currentSettings = settings\n allSettings.forEach { $0.load(from: settings) }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/MainScreen/WorkspaceCell.swift", "//\n// WorkspaceCell.swift\n//\n// Created by Wojciech Kulik on 20/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\nimport UniformTypeIdentifiers\n\nstruct WorkspaceCell: View {\n @State var isTargeted = false\n @Binding var selectedApps: Set\n\n let workspaceManager: WorkspaceManager = AppDependencies.shared.workspaceManager\n let workspaceRepository: WorkspaceRepository = AppDependencies.shared.workspaceRepository\n\n let workspace: Workspace\n\n var body: some View {\n HStack {\n Image(systemName: workspace.symbolIconName ?? .defaultIconSymbol)\n .resizable()\n .scaledToFit()\n .frame(width: 15, height: 15)\n .foregroundStyle(Color.workspaceIcon)\n\n Text(workspace.name)\n .lineLimit(1)\n .foregroundColor(\n isTargeted || workspace.apps.contains(where: \\.bundleIdentifier.isEmpty)\n ? .errorRed\n : .primary\n )\n Spacer()\n }\n .contentShape(Rectangle())\n .dropDestination(for: MacAppWithWorkspace.self) { apps, _ in\n guard let sourceWorkspaceId = apps.first?.workspaceId else { return false }\n\n workspaceRepository.moveApps(\n apps.map(\\.app),\n from: sourceWorkspaceId,\n to: workspace.id\n )\n selectedApps = []\n\n workspaceManager.activateWorkspaceIfActive(sourceWorkspaceId)\n workspaceManager.activateWorkspaceIfActive(workspace.id)\n\n return true\n } isTargeted: {\n isTargeted = $0\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Workspaces/WorkspaceSettingsViewModel.swift", "//\n// WorkspaceSettingsViewModel.swift\n//\n// Created by Wojciech Kulik on 22/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nfinal class WorkspaceSettingsViewModel: ObservableObject {\n @Published var windowTitleRegex = \"\"\n @Published var isInputDialogPresented = false {\n didSet {\n if !isInputDialogPresented, windowTitleRegex.isNotEmpty {\n addPendingPipApp()\n windowTitleRegex = \"\"\n }\n }\n }\n\n private var pendingApp: PipApp?\n private let settings = AppDependencies.shared.workspaceSettings\n\n func addPipApp() {\n let fileChooser = FileChooser()\n let appUrl = fileChooser.runModalOpenPanel(\n allowedFileTypes: [.application],\n directoryURL: URL(filePath: \"/Applications\")\n )\n\n guard let bundle = appUrl?.bundle else { return }\n\n pendingApp = PipApp(\n name: bundle.localizedAppName,\n bundleIdentifier: bundle.bundleIdentifier ?? \"\",\n pipWindowTitleRegex: \"\"\n )\n isInputDialogPresented = true\n }\n\n func deletePipApp(_ app: PipApp) {\n settings.deletePipApp(app)\n }\n\n private func addPendingPipApp() {\n guard let pendingApp else { return }\n\n settings.addPipApp(\n .init(\n name: pendingApp.name,\n bundleIdentifier: pendingApp.bundleIdentifier,\n pipWindowTitleRegex: windowTitleRegex\n )\n )\n self.pendingApp = nil\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Commands/SpaceControlCommands.swift", "//\n// SpaceControlCommands.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\n\nfinal class SpaceControlCommands: CommandExecutor {\n func execute(command: CommandRequest) -> CommandResponse? {\n switch command {\n case .openSpaceControl:\n if SpaceControl.isEnabled {\n SpaceControl.show()\n return CommandResponse(success: true)\n } else {\n return CommandResponse(success: false, error: \"Space Control is not enabled\")\n }\n\n default:\n return nil\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Gestures/GesturesSettingsView.swift", "//\n// GesturesSettingsView.swift\n//\n// Created by Wojciech Kulik on 21/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct GesturesSettingsView: View {\n @StateObject private var settings = AppDependencies.shared.gesturesSettings\n\n var body: some View {\n Form {\n Section {\n Toggle(\"Enable Swipe Gestures\", isOn: $settings.enableSwipeGestures)\n HStack {\n Text(\"Activation Threshold\")\n Spacer()\n Text(\"\\(settings.swipeThreshold, specifier: \"%.2f\")\")\n Stepper(\n \"\",\n value: $settings.swipeThreshold,\n in: 0.05...0.7,\n step: 0.05\n ).labelsHidden()\n }\n Text(\"Remember to disable system gestures in System Preferences > Trackpad > More Gestures.\")\n .font(.callout)\n .foregroundStyle(.secondary)\n Text(\n \"Keeping \\\"Swipe between full-screen apps\\\" enabled prevents from detecting swipe gesture as \" +\n \"a scroll action. However, you must keep only one macOS Space to avoid switching.\"\n )\n .font(.callout)\n .foregroundStyle(.secondary)\n }\n\n Section(\"Horizontal Swipes\") {\n Picker(\"3-Finger Left Swipe\", selection: $settings.swipeLeft3FingerAction) {\n ForEach(GestureAction.allCases) { action in\n Text(action.description).tag(action)\n }\n }\n Picker(\"3-Finger Right Swipe\", selection: $settings.swipeRight3FingerAction) {\n ForEach(GestureAction.allCases) { action in\n Text(action.description).tag(action)\n }\n }\n Picker(\"4-Finger Left Swipe\", selection: $settings.swipeLeft4FingerAction) {\n ForEach(GestureAction.allCases) { action in\n Text(action.description).tag(action)\n }\n }\n Picker(\"4-Finger Right Swipe\", selection: $settings.swipeRight4FingerAction) {\n ForEach(GestureAction.allCases) { action in\n Text(action.description).tag(action)\n }\n }\n }\n .disabled(!settings.enableSwipeGestures)\n .opacity(settings.enableSwipeGestures ? 1 : 0.5)\n\n Section(\"Vertical Swipes\") {\n Picker(\"3-Finger Up Swipe\", selection: $settings.swipeUp3FingerAction) {\n ForEach(GestureAction.allCases) { action in\n Text(action.description).tag(action)\n }\n }\n Picker(\"3-Finger Down Swipe\", selection: $settings.swipeDown3FingerAction) {\n ForEach(GestureAction.allCases) { action in\n Text(action.description).tag(action)\n }\n }\n Picker(\"4-Finger Up Swipe\", selection: $settings.swipeUp4FingerAction) {\n ForEach(GestureAction.allCases) { action in\n Text(action.description).tag(action)\n }\n }\n Picker(\"4-Finger Down Swipe\", selection: $settings.swipeDown4FingerAction) {\n ForEach(GestureAction.allCases) { action in\n Text(action.description).tag(action)\n }\n }\n }\n .disabled(!settings.enableSwipeGestures)\n .opacity(settings.enableSwipeGestures ? 1 : 0.5)\n\n Section(\"System\") {\n Toggle(\"Restart App On Wake Up\", isOn: $settings.restartAppOnWakeUp)\n Text(\n \"Restarts the app when your Mac wakes up from sleep. This can help with gesture recognition issues after waking.\"\n )\n .font(.callout)\n .foregroundStyle(.secondary)\n }\n .disabled(!settings.enableSwipeGestures)\n .opacity(settings.enableSwipeGestures ? 1 : 0.5)\n }\n .formStyle(.grouped)\n .navigationTitle(\"Gestures\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Accessibility/AXUIElement+Properties.swift", "//\n// AXUIElement+Properties.swift\n//\n// Created by Wojciech Kulik on 24/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension AXUIElement {\n var id: String? { getAttribute(.identifier) }\n var title: String? { getAttribute(.title) }\n var isMain: Bool { getAttribute(.main) == true }\n var isMinimized: Bool { getAttribute(.minimized) == true }\n var role: String? { getAttribute(.role) }\n var subrole: String? { getAttribute(.subrole) }\n var enhancedUserInterface: Bool {\n get { getAttribute(.enchancedUserInterface) == true }\n set { setAttribute(.enchancedUserInterface, value: newValue) }\n }\n\n var processId: pid_t? {\n var pid: pid_t = 0\n AXUIElementGetPid(self, &pid)\n return pid\n }\n\n /// Frame is in window coordinates where (0,0) is top-left corner\n /// and it is relative to the main screen.\n var frame: CGRect? {\n var positionValue: CFTypeRef?\n var sizeValue: CFTypeRef?\n\n guard AXUIElementCopyAttributeValue(\n self,\n NSAccessibility.Attribute.position as CFString,\n &positionValue\n ) == .success else { return nil }\n\n guard AXUIElementCopyAttributeValue(\n self,\n NSAccessibility.Attribute.size as CFString,\n &sizeValue\n ) == .success else { return nil }\n\n var windowBounds: CGRect = .zero\n\n // swiftlint:disable force_cast\n if let position = positionValue, AXValueGetType(position as! AXValue) == .cgPoint {\n AXValueGetValue(position as! AXValue, .cgPoint, &windowBounds.origin)\n }\n\n if let size = sizeValue, AXValueGetType(size as! AXValue) == .cgSize {\n AXValueGetValue(size as! AXValue, .cgSize, &windowBounds.size)\n }\n // swiftlint:enable force_cast\n\n return windowBounds.isEmpty ? nil : windowBounds\n }\n}\n"], ["/FlashSpace/FlashSpace/UI/Toast.swift", "//\n// Toast.swift\n//\n// Created by Wojciech Kulik on 28/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport SwiftUI\n\nenum Toast {\n weak static var toastWindow: NSWindow?\n\n static func showWith(icon: String, message: String, textColor: Color) {\n guard AppDependencies.shared.generalSettings.showFloatingNotifications else { return }\n\n if let window = toastWindow {\n window.orderOut(nil)\n toastWindow = nil\n }\n\n let contentView = NSHostingView(\n rootView: ToastView(\n icon: icon,\n message: message,\n textColor: textColor\n )\n )\n let size = contentView.fittingSize\n\n // contentRect is in screen coordinates where (0,0) is bottom-left corner\n // and it is relative to the main screen.\n let window = NSWindow(\n contentRect: NSRect(\n x: (NSScreen.main?.frame.midX ?? 200.0) - size.width / 2.0,\n y: (NSScreen.main?.frame.minY ?? 0.0) + (NSScreen.main?.frame.height ?? 0.0) * 0.07,\n width: size.width,\n height: size.height\n ),\n styleMask: [.borderless],\n backing: .buffered,\n defer: false\n )\n window.isOpaque = false\n window.backgroundColor = .clear\n window.level = .screenSaver\n toastWindow = window\n\n let visualEffectView = contentView.addVisualEffect(material: .sidebar, border: true)\n window.contentView = visualEffectView\n window.orderFrontRegardless()\n\n DispatchQueue.main.asyncAfter(deadline: .now() + 2.0) {\n NSAnimationContext.runAnimationGroup({ context in\n context.duration = 0.3\n window.animator().alphaValue = 0.0\n }, completionHandler: {\n window.orderOut(nil)\n })\n }\n }\n}\n\nstruct ToastView: View {\n let icon: String\n let message: String\n let textColor: Color\n\n var body: some View {\n HStack {\n Image(systemName: icon)\n .resizable()\n .scaledToFit()\n .frame(width: 26)\n\n Text(message)\n .font(.title)\n }\n .opacity(0.9)\n .padding()\n .padding(.horizontal)\n .fontWeight(.semibold)\n .foregroundStyle(textColor)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/SettingsView.swift", "//\n// SettingsView.swift\n//\n// Created by Wojciech Kulik on 23/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct SettingsView: View {\n @State private var selectedTab = \"General\"\n\n var body: some View {\n NavigationSplitView(columnVisibility: .constant(.doubleColumn), sidebar: {\n sideMenu\n .frame(width: 200)\n .navigationSplitViewColumnWidth(200.0)\n }, detail: {\n details\n .frame(maxHeight: .infinity, alignment: .top)\n .navigationSplitViewColumnWidth(min: 440, ideal: 440)\n })\n .frame(width: 780, height: 490)\n }\n\n private var sideMenu: some View {\n VStack {\n List(selection: $selectedTab) {\n Label(\"General\", systemImage: \"gearshape\")\n .tag(\"General\")\n Label(\"Menu Bar\", systemImage: \"contextualmenu.and.cursorarrow\")\n .tag(\"MenuBar\")\n Label(\"Gestures\", systemImage: \"hand.draw\")\n .tag(\"Gestures\")\n Label(\"Workspaces\", systemImage: \"square.stack.3d.up\")\n .tag(\"Workspaces\")\n Label(\"Floating Apps\", systemImage: \"pip\")\n .tag(\"FloatingApps\")\n Label(\"Focus Manager\", systemImage: \"macwindow.on.rectangle\")\n .tag(\"Focus\")\n Label(\"Space Control\", systemImage: \"rectangle.split.2x2\")\n .tag(\"SpaceControl\")\n Label(\"Profiles\", systemImage: \"person.2\")\n .tag(\"Profiles\")\n Label(\"Integrations\", systemImage: \"link\")\n .tag(\"Integrations\")\n Label(\"Configuration File\", systemImage: \"doc.text\")\n .tag(\"Configuration\")\n Label(\"CLI\", systemImage: \"apple.terminal\")\n .tag(\"CLI\")\n Label(\"Acknowledgements\", systemImage: \"info.circle\")\n .tag(\"Acknowledgements\")\n Label(\"About\", systemImage: \"person\")\n .tag(\"About\")\n }\n .toolbar(removing: .sidebarToggle)\n .listStyle(.sidebar)\n\n Spacer()\n\n Text(\"FlashSpace v\\(AppConstants.version)\")\n .foregroundStyle(.secondary)\n .padding(.bottom)\n }\n }\n\n @ViewBuilder\n private var details: some View {\n switch selectedTab {\n case \"General\":\n GeneralSettingsView()\n case \"MenuBar\":\n MenuBarSettingsView()\n case \"Focus\":\n FocusSettingsView()\n case \"Gestures\":\n GesturesSettingsView()\n case \"Workspaces\":\n WorkspacesSettingsView()\n case \"FloatingApps\":\n FloatingAppsSettingsView()\n case \"SpaceControl\":\n SpaceControlSettingsView()\n case \"Integrations\":\n IntegrationsSettingsView()\n case \"Profiles\":\n ProfilesSettingsView()\n case \"Configuration\":\n ConfigurationFileSettingsView()\n case \"CLI\":\n CLISettingsView()\n case \"Acknowledgements\":\n AcknowledgementsSettingsView()\n case \"About\":\n AboutSettingsView()\n default:\n EmptyView()\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/App/AppDependencies.swift", "//\n// AppDependencies.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ShortcutRecorder\n\nstruct AppDependencies {\n static let shared = AppDependencies()\n\n let displayManager: DisplayManager\n let workspaceRepository: WorkspaceRepository\n let workspaceManager: WorkspaceManager\n let workspaceHotKeys: WorkspaceHotKeys\n let workspaceScreenshotManager = WorkspaceScreenshotManager()\n let workspaceTransitionManager: WorkspaceTransitionManager\n let pictureInPictureManager: PictureInPictureManager\n\n let floatingAppsHotKeys: FloatingAppsHotKeys\n\n let hotKeysMonitor: HotKeysMonitorProtocol = GlobalShortcutMonitor.shared\n let hotKeysManager: HotKeysManager\n\n let focusManager: FocusManager\n let focusedWindowTracker: FocusedWindowTracker\n\n let settingsRepository: SettingsRepository\n let generalSettings = GeneralSettings()\n let menuBarSettings = MenuBarSettings()\n let gesturesSettings = GesturesSettings()\n let focusManagerSettings = FocusManagerSettings()\n let workspaceSettings = WorkspaceSettings()\n let floatingAppsSettings = FloatingAppsSettings()\n let spaceControlSettings = SpaceControlSettings()\n let integrationsSettings = IntegrationsSettings()\n\n let profilesRepository: ProfilesRepository\n let autostartService = AutostartService()\n let cliServer = CLIServer()\n\n // swiftlint:disable:next function_body_length\n private init() {\n self.settingsRepository = SettingsRepository(\n generalSettings: generalSettings,\n menuBarSettings: menuBarSettings,\n gesturesSettings: gesturesSettings,\n focusManagerSettings: focusManagerSettings,\n workspaceSettings: workspaceSettings,\n floatingAppsSettings: floatingAppsSettings,\n spaceControlSettings: spaceControlSettings,\n integrationsSettings: integrationsSettings\n )\n self.displayManager = DisplayManager(settingsRepository: settingsRepository)\n self.workspaceTransitionManager = WorkspaceTransitionManager(\n workspaceSettings: workspaceSettings\n )\n self.pictureInPictureManager = PictureInPictureManager(\n settingsRepository: settingsRepository\n )\n self.profilesRepository = ProfilesRepository()\n self.workspaceRepository = WorkspaceRepository(\n profilesRepository: profilesRepository\n )\n self.workspaceManager = WorkspaceManager(\n workspaceRepository: workspaceRepository,\n settingsRepository: settingsRepository,\n pictureInPictureManager: pictureInPictureManager,\n workspaceTransitionManager: workspaceTransitionManager,\n displayManager: displayManager\n )\n self.workspaceHotKeys = WorkspaceHotKeys(\n workspaceManager: workspaceManager,\n workspaceRepository: workspaceRepository,\n settingsRepository: settingsRepository\n )\n self.floatingAppsHotKeys = FloatingAppsHotKeys(\n workspaceManager: workspaceManager,\n settingsRepository: settingsRepository\n )\n self.focusManager = FocusManager(\n workspaceRepository: workspaceRepository,\n workspaceManager: workspaceManager,\n focusManagerSettings: focusManagerSettings,\n floatingAppsSettings: floatingAppsSettings\n )\n self.hotKeysManager = HotKeysManager(\n hotKeysMonitor: GlobalShortcutMonitor.shared,\n workspaceHotKeys: workspaceHotKeys,\n floatingAppsHotKeys: floatingAppsHotKeys,\n focusManager: focusManager,\n settingsRepository: settingsRepository\n )\n self.focusedWindowTracker = FocusedWindowTracker(\n workspaceRepository: workspaceRepository,\n workspaceManager: workspaceManager,\n settingsRepository: settingsRepository,\n pictureInPictureManager: pictureInPictureManager\n )\n\n Migrations.migrateIfNeeded(\n settingsRepository: settingsRepository,\n profilesRepository: profilesRepository\n )\n\n focusedWindowTracker.startTracking()\n }\n}\n"], ["/FlashSpace/FlashSpace/Utils/AutostartService.swift", "//\n// AutostartService.swift\n//\n// Created by Wojciech Kulik on 20/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ServiceManagement\n\nfinal class AutostartService {\n var isLaunchAtLoginEnabled: Bool { SMAppService.mainApp.status == .enabled }\n\n func enableLaunchAtLogin() {\n do {\n if SMAppService.mainApp.status == .enabled {\n try SMAppService.mainApp.unregister()\n }\n\n try SMAppService.mainApp.register()\n } catch {\n Logger.log(\"Failed to enable launch at login: \\(error)\")\n }\n }\n\n func disableLaunchAtLogin() {\n do {\n try SMAppService.mainApp.unregister()\n } catch {\n Logger.log(\"Failed to disable launch at login: \\(error)\")\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/SpaceControl/SpaceControlSettings.swift", "//\n// SpaceControlSettings.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nfinal class SpaceControlSettings: ObservableObject {\n @Published var enableSpaceControl = false\n @Published var showSpaceControl: AppHotKey?\n @Published var enableSpaceControlAnimations = true\n @Published var spaceControlCurrentDisplayWorkspaces = false\n @Published var spaceControlMaxColumns = 6\n\n private var observer: AnyCancellable?\n private let updateSubject = PassthroughSubject<(), Never>()\n\n init() { observe() }\n\n private func observe() {\n observer = Publishers.MergeMany(\n $enableSpaceControl.settingsPublisher(),\n $showSpaceControl.settingsPublisher(),\n $enableSpaceControlAnimations.settingsPublisher(),\n $spaceControlCurrentDisplayWorkspaces.settingsPublisher(),\n $spaceControlMaxColumns.settingsPublisher(debounce: true)\n )\n .receive(on: DispatchQueue.main)\n .sink { [weak self] in self?.updateSubject.send() }\n }\n}\n\nextension SpaceControlSettings: SettingsProtocol {\n var updatePublisher: AnyPublisher<(), Never> {\n updateSubject.eraseToAnyPublisher()\n }\n\n func load(from appSettings: AppSettings) {\n observer = nil\n enableSpaceControl = appSettings.enableSpaceControl ?? false\n showSpaceControl = appSettings.showSpaceControl\n enableSpaceControlAnimations = appSettings.enableSpaceControlAnimations ?? true\n spaceControlCurrentDisplayWorkspaces = appSettings.spaceControlCurrentDisplayWorkspaces ?? false\n spaceControlMaxColumns = appSettings.spaceControlMaxColumns ?? 6\n observe()\n }\n\n func update(_ appSettings: inout AppSettings) {\n appSettings.enableSpaceControl = enableSpaceControl\n appSettings.showSpaceControl = showSpaceControl\n appSettings.enableSpaceControlAnimations = enableSpaceControlAnimations\n appSettings.spaceControlCurrentDisplayWorkspaces = spaceControlCurrentDisplayWorkspaces\n appSettings.spaceControlMaxColumns = spaceControlMaxColumns\n }\n}\n"], ["/FlashSpace/FlashSpace/Accessibility/System.swift", "//\n// System.swift\n//\n// Created by Wojciech Kulik on 01/05/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nstruct AppWindow {\n let name: String\n let pid: pid_t\n}\n\nenum System {\n static var orderedWindows: [AppWindow] {\n let list = CGWindowListCopyWindowInfo(.optionOnScreenOnly, kCGNullWindowID) as? [[String: Any]]\n guard let list else { return [] }\n\n return list.compactMap {\n let windowName = $0[kCGWindowName as String] as? String\n let windowOwnerPID = $0[kCGWindowOwnerPID as String] as? pid_t\n if let windowOwnerPID {\n return AppWindow(name: windowName ?? \"-\", pid: windowOwnerPID)\n } else {\n return nil\n }\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/FloatingApps/FloatingAppsSettings.swift", "//\n// FloatingAppsSettings.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nfinal class FloatingAppsSettings: ObservableObject {\n @Published var floatingApps: [MacApp] = []\n @Published var floatTheFocusedApp: AppHotKey?\n @Published var unfloatTheFocusedApp: AppHotKey?\n @Published var toggleTheFocusedAppFloating: AppHotKey?\n\n private var observer: AnyCancellable?\n private let updateSubject = PassthroughSubject<(), Never>()\n\n init() { observe() }\n\n func addFloatingAppIfNeeded(app: MacApp) {\n guard !floatingApps.contains(app) else { return }\n floatingApps.append(app)\n }\n\n func deleteFloatingApp(app: MacApp) {\n floatingApps.removeAll { $0 == app }\n }\n\n private func observe() {\n observer = Publishers.MergeMany(\n $floatingApps.settingsPublisher(),\n $floatTheFocusedApp.settingsPublisher(),\n $unfloatTheFocusedApp.settingsPublisher(),\n $toggleTheFocusedAppFloating.settingsPublisher()\n )\n .receive(on: DispatchQueue.main)\n .sink { [weak self] in self?.updateSubject.send() }\n }\n}\n\nextension FloatingAppsSettings: SettingsProtocol {\n var updatePublisher: AnyPublisher<(), Never> {\n updateSubject.eraseToAnyPublisher()\n }\n\n func load(from appSettings: AppSettings) {\n observer = nil\n floatingApps = appSettings.floatingApps ?? []\n floatTheFocusedApp = appSettings.floatTheFocusedApp\n unfloatTheFocusedApp = appSettings.unfloatTheFocusedApp\n toggleTheFocusedAppFloating = appSettings.toggleTheFocusedAppFloating\n observe()\n }\n\n func update(_ appSettings: inout AppSettings) {\n appSettings.floatingApps = floatingApps.isEmpty ? nil : floatingApps\n appSettings.floatTheFocusedApp = floatTheFocusedApp\n appSettings.unfloatTheFocusedApp = unfloatTheFocusedApp\n appSettings.toggleTheFocusedAppFloating = toggleTheFocusedAppFloating\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Integrations/Integrations.swift", "//\n// Integrations.swift\n//\n// Created by Wojciech Kulik on 24/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nenum Integrations {\n private static let settings = AppDependencies.shared.integrationsSettings\n private static let profilesRepository = AppDependencies.shared.profilesRepository\n\n static func runOnActivateIfNeeded(workspace: ActiveWorkspace) {\n let script = settings.runScriptOnWorkspaceChange.trimmingCharacters(in: .whitespaces)\n .replacingOccurrences(of: \"$WORKSPACE_NUMBER\", with: workspace.number ?? \"\")\n .replacingOccurrences(of: \"$WORKSPACE\", with: workspace.name)\n .replacingOccurrences(of: \"$DISPLAY\", with: workspace.display)\n .replacingOccurrences(of: \"$PROFILE\", with: profilesRepository.selectedProfile.name)\n runScript(script)\n }\n\n static func runOnAppLaunchIfNeeded() {\n let script = settings.runScriptOnLaunch.trimmingCharacters(in: .whitespaces)\n .replacingOccurrences(of: \"$PROFILE\", with: profilesRepository.selectedProfile.name)\n runScript(script)\n }\n\n static func runOnProfileChangeIfNeeded(profile: String) {\n let script = settings.runScriptOnProfileChange.trimmingCharacters(in: .whitespaces)\n .replacingOccurrences(of: \"$PROFILE\", with: profile)\n runScript(script)\n }\n\n private static func runScript(_ script: String) {\n guard settings.enableIntegrations, !script.isEmpty else { return }\n\n let shell = ProcessInfo.processInfo.environment[\"SHELL\"] ?? \"/bin/sh\"\n let task = Process()\n task.launchPath = shell\n task.arguments = [\"-c\", script]\n task.launch()\n }\n}\n"], ["/FlashSpace/FlashSpace/App/AppConstants.swift", "//\n// AppConstants.swift\n//\n// Created by Wojciech Kulik on 23/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nenum AppConstants {\n enum UserDefaultsKey {\n static let selectedProfileId = \"selectedProfileId\"\n }\n\n static let lastFocusedOption = MacApp(\n name: \"(Last Focused)\",\n bundleIdentifier: \"flashspace.last-focused\",\n iconPath: nil\n )\n\n static var version: String {\n guard let version = Bundle.main.infoDictionary?[\"CFBundleShortVersionString\"] as? String else {\n return \"Unknown\"\n }\n\n #if DEBUG\n return version + \" (debug)\"\n #else\n return version\n #endif\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Gestures/GesturesSettings.swift", "//\n// GesturesSettings.swift\n//\n// Created by Wojciech Kulik on 22/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nfinal class GesturesSettings: ObservableObject {\n @Published var swipeThreshold: Double = 0.2\n @Published var enableSwipeGestures = false {\n didSet { updateSwipeManager() }\n }\n\n @Published var restartAppOnWakeUp = false\n\n @Published var swipeRight3FingerAction: GestureAction = .nextWorkspace\n @Published var swipeLeft3FingerAction: GestureAction = .previousWorkspace\n @Published var swipeRight4FingerAction: GestureAction = .none\n @Published var swipeLeft4FingerAction: GestureAction = .none\n\n @Published var swipeUp3FingerAction: GestureAction = .none\n @Published var swipeDown3FingerAction: GestureAction = .none\n @Published var swipeUp4FingerAction: GestureAction = .none\n @Published var swipeDown4FingerAction: GestureAction = .none\n\n var isVerticalSwipeSet: Bool {\n swipeUp3FingerAction != .none || swipeDown3FingerAction != .none ||\n swipeUp4FingerAction != .none || swipeDown4FingerAction != .none\n }\n\n var isHorizontalSwipeSet: Bool {\n swipeLeft3FingerAction != .none || swipeRight3FingerAction != .none ||\n swipeLeft4FingerAction != .none || swipeRight4FingerAction != .none\n }\n\n private var observer: AnyCancellable?\n private let updateSubject = PassthroughSubject<(), Never>()\n\n init() {\n observe()\n updateSwipeManager()\n }\n\n private func observe() {\n observer = Publishers.MergeMany(\n $enableSwipeGestures.settingsPublisher(),\n $swipeThreshold.settingsPublisher(),\n $restartAppOnWakeUp.settingsPublisher(),\n\n $swipeLeft3FingerAction.settingsPublisher(),\n $swipeRight3FingerAction.settingsPublisher(),\n $swipeLeft4FingerAction.settingsPublisher(),\n $swipeRight4FingerAction.settingsPublisher(),\n\n $swipeUp3FingerAction.settingsPublisher(),\n $swipeDown3FingerAction.settingsPublisher(),\n $swipeUp4FingerAction.settingsPublisher(),\n $swipeDown4FingerAction.settingsPublisher()\n )\n .receive(on: DispatchQueue.main)\n .sink { [weak self] in self?.updateSubject.send() }\n }\n\n private func updateSwipeManager() {\n if enableSwipeGestures {\n SwipeManager.shared.start()\n } else {\n SwipeManager.shared.stop()\n }\n }\n}\n\nextension GesturesSettings: SettingsProtocol {\n var updatePublisher: AnyPublisher<(), Never> {\n updateSubject.eraseToAnyPublisher()\n }\n\n func load(from appSettings: AppSettings) {\n observer = nil\n enableSwipeGestures = appSettings.enableSwipeGestures ?? false\n swipeThreshold = appSettings.swipeThreshold ?? 0.2\n restartAppOnWakeUp = appSettings.restartAppOnWakeUp ?? false\n\n swipeLeft3FingerAction = appSettings.swipeLeft3FingerAction ?? .previousWorkspace\n swipeRight3FingerAction = appSettings.swipeRight3FingerAction ?? .nextWorkspace\n swipeLeft4FingerAction = appSettings.swipeLeft4FingerAction ?? .none\n swipeRight4FingerAction = appSettings.swipeRight4FingerAction ?? .none\n\n swipeUp3FingerAction = appSettings.swipeUp3FingerAction ?? .none\n swipeDown3FingerAction = appSettings.swipeDown3FingerAction ?? .none\n swipeUp4FingerAction = appSettings.swipeUp4FingerAction ?? .none\n swipeDown4FingerAction = appSettings.swipeDown4FingerAction ?? .none\n\n observe()\n }\n\n func update(_ appSettings: inout AppSettings) {\n appSettings.enableSwipeGestures = enableSwipeGestures\n appSettings.swipeThreshold = swipeThreshold\n appSettings.restartAppOnWakeUp = restartAppOnWakeUp\n\n appSettings.swipeLeft3FingerAction = swipeLeft3FingerAction\n appSettings.swipeRight3FingerAction = swipeRight3FingerAction\n appSettings.swipeLeft4FingerAction = swipeLeft4FingerAction\n appSettings.swipeRight4FingerAction = swipeRight4FingerAction\n\n appSettings.swipeUp3FingerAction = swipeUp3FingerAction\n appSettings.swipeDown3FingerAction = swipeDown3FingerAction\n appSettings.swipeUp4FingerAction = swipeUp4FingerAction\n appSettings.swipeDown4FingerAction = swipeDown4FingerAction\n }\n}\n"], ["/FlashSpace/FlashSpace/App/Migrations.swift", "//\n// Migrations.swift\n//\n// Created by Wojciech Kulik on 08/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nenum Migrations {\n static var appsMigrated = false\n static var hotKeysMigrated = false\n\n static func migrateIfNeeded(\n settingsRepository: SettingsRepository,\n profilesRepository: ProfilesRepository\n ) {\n if Migrations.appsMigrated {\n Logger.log(\"Migrated apps\")\n\n let workspacesJsonUrl = FileManager.default\n .homeDirectoryForCurrentUser\n .appendingPathComponent(\".config/flashspace/workspaces.json\")\n try? FileManager.default.moveItem(\n at: workspacesJsonUrl,\n to: workspacesJsonUrl.deletingLastPathComponent()\n .appendingPathComponent(\"workspaces.json.bak\")\n )\n\n settingsRepository.saveToDisk()\n profilesRepository.saveToDisk()\n } else if Migrations.hotKeysMigrated {\n Logger.log(\"Migrated hot keys\")\n settingsRepository.saveToDisk()\n profilesRepository.saveToDisk()\n }\n\n Migrations.appsMigrated = false\n Migrations.hotKeysMigrated = false\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/PictureInPicture/Extensions/AXUIElement+PiP.swift", "//\n// AXUIElement+PiP.swift\n//\n// Created by Wojciech Kulik on 12/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension AXUIElement {\n private var pipApps: [PipApp] {\n AppDependencies.shared.workspaceSettings.pipApps\n }\n\n func isPictureInPicture(bundleId: String?) -> Bool {\n if let browser = PipBrowser(rawValue: bundleId ?? \"\") {\n if let partialTitle = browser.partialTitle,\n title?.contains(partialTitle) == true {\n return true\n }\n\n if let pipWindowTitle = browser.title {\n return title == pipWindowTitle\n } else if let pipWindowSubrole = browser.subrole {\n return subrole == pipWindowSubrole\n }\n } else if let pipApp = pipApps.first(where: { $0.bundleIdentifier == bundleId }) {\n let result = title?.range(\n of: pipApp.pipWindowTitleRegex,\n options: .regularExpression\n ) != nil\n\n return result\n }\n\n return false\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/CGRect.swift", "//\n// CGRect.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension CGRect {\n func getDisplay() -> String? {\n NSScreen.screens\n .first { $0.normalizedFrame.contains(.init(x: self.midX, y: self.midY)) }?\n .localizedName\n }\n\n func verticalIntersect(with rect: CGRect) -> Bool {\n var rect = rect\n rect.origin.x = origin.x\n\n return intersects(rect)\n }\n\n func horizontalIntersect(with rect: CGRect) -> Bool {\n var rect = rect\n rect.origin.y = origin.y\n\n return intersects(rect)\n }\n\n func distance(to rect: CGRect) -> CGFloat {\n let x = midX - rect.midX\n let y = midY - rect.midY\n\n return sqrt(x * x + y * y)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Profiles/ProfilesSettingsViewModel.swift", "//\n// ProfilesSettingsViewModel.swift\n//\n// Created by Wojciech Kulik on 26/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nfinal class ProfilesSettingsViewModel: ObservableObject {\n enum Action {\n case createProfile\n case renameProfile(ProfileId)\n case deleteProfile(ProfileId)\n }\n\n @Published var isInputDialogPresented = false\n @Published var isDeleteConfirmationPresented = false\n @Published var isCopyChoicePresented = false\n @Published var profileToDelete = \"\"\n @Published var userInput = \"\"\n\n var hideDeleteButton: Bool { profilesRepository.profiles.count == 1 }\n\n private var action: Action?\n\n private let profilesRepository = AppDependencies.shared.profilesRepository\n\n func createNewProfile() {\n action = .createProfile\n userInput = \"\"\n isInputDialogPresented = true\n }\n\n func createNewProfile(copyWorkspaces: Bool) {\n let input = userInput.trimmingCharacters(in: .whitespacesAndNewlines)\n guard !input.isEmpty else { return }\n\n profilesRepository.createProfile(name: input, keepWorkspaces: copyWorkspaces)\n }\n\n func renameProfile(_ profile: Profile) {\n action = .renameProfile(profile.id)\n userInput = profile.name\n isInputDialogPresented = true\n }\n\n func deleteProfile(_ profile: Profile) {\n action = .deleteProfile(profile.id)\n profileToDelete = profile.name\n isDeleteConfirmationPresented = true\n }\n\n func inputDialogDismissed() {\n let input = userInput.trimmingCharacters(in: .whitespacesAndNewlines)\n guard let action, !input.isEmpty else { return }\n\n switch action {\n case .createProfile:\n isCopyChoicePresented = true\n case .renameProfile(let id):\n profilesRepository.renameProfile(id: id, to: input)\n case .deleteProfile:\n break\n }\n }\n\n func deleteConfirmed() {\n guard let action else { return }\n\n switch action {\n case .deleteProfile(let id):\n profilesRepository.deleteProfile(id: id)\n default:\n break\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Profiles/Models/Profile.swift", "//\n// Profile.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\ntypealias ProfileId = UUID\n\nstruct ProfilesConfig: Codable {\n let profiles: [Profile]\n}\n\nstruct Profile: Identifiable, Codable, Hashable {\n let id: ProfileId\n var name: String\n var workspaces: [Workspace]\n}\n\nextension Profile {\n static let `default` = Profile(\n id: UUID(),\n name: \"Default\",\n workspaces: []\n )\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Acknowledgements/AcknowledgementsSettingsView.swift", "//\n// AcknowledgementsSettingsView.swift\n//\n// Created by Wojciech Kulik on 26/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct AcknowledgementsSettingsView: View {\n @State private var selectedDependency: String? = \"xnth97/SymbolPicker\"\n @State private var dependencies = [\n \"xnth97/SymbolPicker\",\n \"Kentzo/ShortcutRecorder\",\n \"LebJe/TOMLKit\",\n \"jpsim/Yams\",\n \"sparkle-project/Sparkle\",\n \"apple/swift-argument-parser\",\n \"SwiftFormat\",\n \"SwiftLint\"\n ]\n\n var body: some View {\n VStack(spacing: 0.0) {\n List(\n dependencies,\n id: \\.self,\n selection: $selectedDependency\n ) { dependency in\n Text(dependency)\n }.frame(height: 130)\n\n ScrollView([.vertical, .horizontal]) {\n VStack {\n Group {\n switch selectedDependency {\n case \"xnth97/SymbolPicker\":\n Text(Licenses.symbolPicker)\n case \"Kentzo/ShortcutRecorder\":\n Text(Licenses.shortcutRecorder)\n case \"LebJe/TOMLKit\":\n Text(Licenses.tomlKit)\n case \"jpsim/Yams\":\n Text(Licenses.yams)\n case \"sparkle-project/Sparkle\":\n Text(Licenses.sparkle)\n case \"apple/swift-argument-parser\":\n Text(Licenses.swiftArgumentParser)\n case \"SwiftFormat\":\n Text(Licenses.swiftFormat)\n case \"SwiftLint\":\n Text(Licenses.swiftLint)\n default:\n EmptyView()\n }\n }\n .frame(minHeight: 330, alignment: .top)\n .textSelection(.enabled)\n .padding()\n }\n }\n }\n .navigationTitle(\"Acknowledgements\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/FocusManager/FocusManagerSettings.swift", "//\n// FocusManagerSettings.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nfinal class FocusManagerSettings: ObservableObject {\n @Published var enableFocusManagement = false\n @Published var centerCursorOnFocusChange = false\n\n @Published var focusLeft: AppHotKey?\n @Published var focusRight: AppHotKey?\n @Published var focusUp: AppHotKey?\n @Published var focusDown: AppHotKey?\n @Published var focusNextWorkspaceApp: AppHotKey?\n @Published var focusPreviousWorkspaceApp: AppHotKey?\n @Published var focusNextWorkspaceWindow: AppHotKey?\n @Published var focusPreviousWorkspaceWindow: AppHotKey?\n @Published var focusFrontmostWindow = false\n\n private var observer: AnyCancellable?\n private let updateSubject = PassthroughSubject<(), Never>()\n\n init() { observe() }\n\n private func observe() {\n observer = Publishers.MergeMany(\n $enableFocusManagement.settingsPublisher(),\n $centerCursorOnFocusChange.settingsPublisher(),\n $focusLeft.settingsPublisher(),\n $focusRight.settingsPublisher(),\n $focusUp.settingsPublisher(),\n $focusDown.settingsPublisher(),\n $focusNextWorkspaceApp.settingsPublisher(),\n $focusPreviousWorkspaceApp.settingsPublisher(),\n $focusNextWorkspaceWindow.settingsPublisher(),\n $focusPreviousWorkspaceWindow.settingsPublisher(),\n $focusFrontmostWindow.settingsPublisher()\n )\n .receive(on: DispatchQueue.main)\n .sink { [weak self] in self?.updateSubject.send() }\n }\n}\n\nextension FocusManagerSettings: SettingsProtocol {\n var updatePublisher: AnyPublisher<(), Never> {\n updateSubject.eraseToAnyPublisher()\n }\n\n func load(from appSettings: AppSettings) {\n observer = nil\n enableFocusManagement = appSettings.enableFocusManagement ?? false\n centerCursorOnFocusChange = appSettings.centerCursorOnFocusChange ?? false\n focusLeft = appSettings.focusLeft\n focusRight = appSettings.focusRight\n focusUp = appSettings.focusUp\n focusDown = appSettings.focusDown\n focusNextWorkspaceApp = appSettings.focusNextWorkspaceApp\n focusPreviousWorkspaceApp = appSettings.focusPreviousWorkspaceApp\n focusNextWorkspaceWindow = appSettings.focusNextWorkspaceWindow\n focusPreviousWorkspaceWindow = appSettings.focusPreviousWorkspaceWindow\n focusFrontmostWindow = appSettings.focusFrontmostWindow ?? false\n observe()\n }\n\n func update(_ appSettings: inout AppSettings) {\n appSettings.enableFocusManagement = enableFocusManagement\n appSettings.centerCursorOnFocusChange = centerCursorOnFocusChange\n appSettings.focusLeft = focusLeft\n appSettings.focusRight = focusRight\n appSettings.focusUp = focusUp\n appSettings.focusDown = focusDown\n appSettings.focusNextWorkspaceApp = focusNextWorkspaceApp\n appSettings.focusPreviousWorkspaceApp = focusPreviousWorkspaceApp\n appSettings.focusNextWorkspaceWindow = focusNextWorkspaceWindow\n appSettings.focusPreviousWorkspaceWindow = focusPreviousWorkspaceWindow\n appSettings.focusFrontmostWindow = focusFrontmostWindow\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/MenuBar/MenuBarSettings.swift", "//\n// MenuBarSettings.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nfinal class MenuBarSettings: ObservableObject {\n static let defaultMenuBarTitleTemplate = \"$WORKSPACE\"\n\n @Published var showMenuBarTitle = true\n @Published var showMenuBarIcon = true\n @Published var menuBarTitleTemplate = MenuBarSettings.defaultMenuBarTitleTemplate\n @Published var menuBarDisplayAliases = \"\"\n\n private var observer: AnyCancellable?\n private let updateSubject = PassthroughSubject<(), Never>()\n\n init() { observe() }\n\n private func observe() {\n observer = Publishers.MergeMany(\n $showMenuBarTitle.settingsPublisher(),\n $showMenuBarIcon.settingsPublisher(),\n $menuBarTitleTemplate.settingsPublisher(debounce: true),\n $menuBarDisplayAliases.settingsPublisher(debounce: true)\n )\n .receive(on: DispatchQueue.main)\n .sink { [weak self] in self?.updateSubject.send() }\n }\n}\n\nextension MenuBarSettings: SettingsProtocol {\n var updatePublisher: AnyPublisher<(), Never> {\n updateSubject.eraseToAnyPublisher()\n }\n\n func load(from appSettings: AppSettings) {\n observer = nil\n showMenuBarTitle = appSettings.showMenuBarTitle ?? true\n showMenuBarIcon = appSettings.showMenuBarIcon ?? true\n menuBarTitleTemplate = appSettings.menuBarTitleTemplate ?? Self.defaultMenuBarTitleTemplate\n menuBarDisplayAliases = appSettings.menuBarDisplayAliases ?? \"\"\n observe()\n }\n\n func update(_ appSettings: inout AppSettings) {\n appSettings.showMenuBarTitle = showMenuBarTitle\n appSettings.showMenuBarIcon = showMenuBarIcon\n appSettings.menuBarTitleTemplate = menuBarTitleTemplate\n appSettings.menuBarDisplayAliases = menuBarDisplayAliases\n }\n}\n"], ["/FlashSpace/FlashSpace/UI/InputDialog.swift", "//\n// InputDialog.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct InputDialog: View {\n let title: String\n var placeholder = \"Type here...\"\n\n @Binding var userInput: String\n @Binding var isPresented: Bool\n\n var body: some View {\n VStack(alignment: .leading, spacing: 4.0) {\n Text(title)\n .font(.headline)\n\n TextField(placeholder, text: $userInput)\n .textFieldStyle(RoundedBorderTextFieldStyle())\n .padding(.vertical, 8.0)\n .onSubmit { isPresented = false }\n\n HStack {\n Spacer()\n Button(\"Cancel\") {\n userInput = \"\"\n isPresented = false\n }\n Button(\"OK\") { isPresented = false }\n }\n }\n .padding()\n .frame(width: 300, height: 110)\n .onKeyPress(.escape) {\n userInput = \"\"\n isPresented = false\n return .handled\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/HotKeys/Models/KeyModifiersMap.swift", "//\n// KeyModifiersMap.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nenum KeyModifiersMap {\n static func toString(_ value: RawKeyModifiers) -> String {\n let flags = NSEvent.ModifierFlags(rawValue: value)\n var result: [String] = []\n\n if flags.contains(.command) { result.append(\"cmd\") }\n if flags.contains(.control) { result.append(\"ctrl\") }\n if flags.contains(.option) { result.append(\"opt\") }\n if flags.contains(.shift) { result.append(\"shift\") }\n\n return result.joined(separator: \"+\")\n }\n\n static func toModifiers(_ value: String) -> RawKeyModifiers {\n let flags = value.lowercased().split(separator: \"+\").map { String($0) }\n var result: RawKeyModifiers = 0\n\n if flags.contains(\"cmd\") { result |= NSEvent.ModifierFlags.command.rawValue }\n if flags.contains(\"ctrl\") { result |= NSEvent.ModifierFlags.control.rawValue }\n if flags.contains(\"opt\") { result |= NSEvent.ModifierFlags.option.rawValue }\n if flags.contains(\"shift\") { result |= NSEvent.ModifierFlags.shift.rawValue }\n\n return result\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Commands/FocusCommands.swift", "//\n// FocusCommands.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nfinal class FocusCommands: CommandExecutor {\n var focusManager: FocusManager { AppDependencies.shared.focusManager }\n\n func execute(command: CommandRequest) -> CommandResponse? {\n switch command {\n case .focusWindow(let direction):\n switch direction {\n case .left: focusManager.focusLeft()\n case .right: focusManager.focusRight()\n case .up: focusManager.focusUp()\n case .down: focusManager.focusDown()\n }\n return CommandResponse(success: true)\n\n case .focusNextApp:\n focusManager.nextWorkspaceApp()\n return CommandResponse(success: true)\n\n case .focusPreviousApp:\n focusManager.previousWorkspaceApp()\n return CommandResponse(success: true)\n\n case .focusNextWindow:\n focusManager.nextWorkspaceWindow()\n return CommandResponse(success: true)\n\n case .focusPreviousWindow:\n focusManager.previousWorkspaceWindow()\n return CommandResponse(success: true)\n\n default:\n return nil\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/HotKeys/Models/KeyCodesMap.swift", "//\n// KeyCodesMap.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Carbon\n\nenum KeyCodesMap {\n private(set) static var toKeyCode = create()\n\n static let toString = toKeyCode.reduce(into: [RawKeyCode: String]()) { result, pair in\n result[pair.value] = pair.key\n\n for (alias, keyCode) in getAliases() {\n result[keyCode] = alias\n }\n }\n\n static subscript(key: String) -> RawKeyCode? { toKeyCode[key] }\n\n static func refresh() {\n toKeyCode = create()\n }\n\n private static func create() -> [String: RawKeyCode] {\n var stringToKeyCodes: [String: RawKeyCode] = [:]\n var currentKeyboard = TISCopyCurrentKeyboardInputSource().takeRetainedValue()\n var rawLayoutData = TISGetInputSourceProperty(currentKeyboard, kTISPropertyUnicodeKeyLayoutData)\n if rawLayoutData == nil {\n currentKeyboard = TISCopyCurrentASCIICapableKeyboardLayoutInputSource().takeUnretainedValue()\n rawLayoutData = TISGetInputSourceProperty(currentKeyboard, kTISPropertyUnicodeKeyLayoutData)\n }\n\n let layoutData = unsafeBitCast(rawLayoutData, to: CFData.self)\n let layout: UnsafePointer = unsafeBitCast(\n CFDataGetBytePtr(layoutData),\n to: UnsafePointer.self\n )\n\n var keysDown: UInt32 = 0\n var chars: [UniChar] = [0, 0, 0, 0]\n var realLength = 0\n\n for keyCode in 0..<128 {\n switch keyCode {\n case kVK_ANSI_Keypad0, kVK_ANSI_Keypad1, kVK_ANSI_Keypad2, kVK_ANSI_Keypad3,\n kVK_ANSI_Keypad4, kVK_ANSI_Keypad5, kVK_ANSI_Keypad6, kVK_ANSI_Keypad7,\n kVK_ANSI_Keypad8, kVK_ANSI_Keypad9,\n kVK_ANSI_KeypadMinus, kVK_ANSI_KeypadMultiply, kVK_ANSI_KeypadDivide,\n kVK_ANSI_KeypadDecimal, kVK_ANSI_KeypadClear, kVK_ANSI_KeypadEnter,\n kVK_ANSI_KeypadEquals, kVK_ANSI_KeypadPlus:\n continue\n default: break\n }\n\n UCKeyTranslate(\n layout,\n UInt16(keyCode),\n UInt16(kUCKeyActionDisplay),\n 0,\n UInt32(LMGetKbdType()),\n UInt32(kUCKeyTranslateNoDeadKeysBit),\n &keysDown,\n chars.count,\n &realLength,\n &chars\n )\n\n let string = CFStringCreateWithCharacters(kCFAllocatorDefault, chars, realLength) as String\n if !stringToKeyCodes.keys.contains(string) {\n stringToKeyCodes[string] = UInt16(keyCode)\n }\n }\n\n let aliases = getAliases()\n for (alias, keyCode) in aliases {\n stringToKeyCodes[alias] = keyCode\n }\n\n return stringToKeyCodes\n }\n\n private static func getAliases() -> [String: RawKeyCode] {\n [\n \"space\": UInt16(kVK_Space),\n \"enter\": UInt16(kVK_Return),\n \"up\": UInt16(kVK_UpArrow),\n \"right\": UInt16(kVK_RightArrow),\n \"down\": UInt16(kVK_DownArrow),\n \"left\": UInt16(kVK_LeftArrow),\n \"delete\": UInt16(kVK_Delete),\n \"forward-delete\": UInt16(kVK_ForwardDelete),\n \"escape\": UInt16(kVK_Escape),\n \"tab\": UInt16(kVK_Tab),\n \"capslock\": UInt16(kVK_CapsLock),\n \"f1\": UInt16(kVK_F1),\n \"f2\": UInt16(kVK_F2),\n \"f3\": UInt16(kVK_F3),\n \"f4\": UInt16(kVK_F4),\n \"f5\": UInt16(kVK_F5),\n \"f6\": UInt16(kVK_F6),\n \"f7\": UInt16(kVK_F7),\n \"f8\": UInt16(kVK_F8),\n \"f9\": UInt16(kVK_F9),\n \"f10\": UInt16(kVK_F10),\n \"f11\": UInt16(kVK_F11),\n \"f12\": UInt16(kVK_F12),\n \"num0\": UInt16(kVK_ANSI_Keypad0),\n \"num1\": UInt16(kVK_ANSI_Keypad1),\n \"num2\": UInt16(kVK_ANSI_Keypad2),\n \"num3\": UInt16(kVK_ANSI_Keypad3),\n \"num4\": UInt16(kVK_ANSI_Keypad4),\n \"num5\": UInt16(kVK_ANSI_Keypad5),\n \"num6\": UInt16(kVK_ANSI_Keypad6),\n \"num7\": UInt16(kVK_ANSI_Keypad7),\n \"num8\": UInt16(kVK_ANSI_Keypad8),\n \"num9\": UInt16(kVK_ANSI_Keypad9),\n \"num-plus\": UInt16(kVK_ANSI_KeypadPlus),\n \"num-minus\": UInt16(kVK_ANSI_KeypadMinus),\n \"num-multiply\": UInt16(kVK_ANSI_KeypadMultiply),\n \"num-divide\": UInt16(kVK_ANSI_KeypadDivide),\n \"num-clear\": UInt16(kVK_ANSI_KeypadClear),\n \"num-enter\": UInt16(kVK_ANSI_KeypadEnter),\n \"num-equals\": UInt16(kVK_ANSI_KeypadEquals),\n \"num-decimal\": UInt16(kVK_ANSI_KeypadDecimal)\n ]\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/MainScreen/AppCell.swift", "//\n// AppCell.swift\n//\n// Created by Wojciech Kulik on 20/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct AppCell: View {\n let workspaceId: WorkspaceID\n let app: MacApp\n\n var body: some View {\n HStack {\n if let iconPath = app.iconPath, let image = NSImage(byReferencingFile: iconPath) {\n Image(nsImage: image)\n .resizable()\n .scaledToFit()\n .frame(width: 20, height: 20)\n }\n Text(app.name)\n .foregroundColor(app.bundleIdentifier.isEmpty ? .errorRed : .primary)\n }\n .draggable(MacAppWithWorkspace(app: app, workspaceId: workspaceId))\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/About/AboutSettingsView.swift", "//\n// AboutSettingsView.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct AboutSettingsView: View {\n var body: some View {\n Form {\n Section(\"FlashSpace\") {\n HStack {\n Text(\"Version \\(AppConstants.version)\")\n Spacer()\n Button(\"GitHub\") { openGitHub(\"wojciech-kulik/FlashSpace\") }\n Button(\"Check for Updates\") { UpdatesManager.shared.checkForUpdates() }\n }\n }\n\n Section(\"Author\") {\n HStack {\n Text(\"Wojciech Kulik (@wojciech-kulik)\")\n Spacer()\n Button(\"GitHub\") { openGitHub(\"wojciech-kulik\") }\n Button(\"X.com\") { openUrl(\"https://x.com/kulik_wojciech\") }\n Button(\"snippety.app\") { openUrl(\"https://snippety.app\") }\n }\n }\n\n Section(\"Contributors\") {\n HStack {\n Text(\"Kwangmin Bae / Shirou (@PangMo5)\")\n Spacer()\n Button(\"GitHub\") { openGitHub(\"PangMo5\") }\n }\n HStack {\n Text(\"Sergio (@sergiopatino)\")\n Spacer()\n Button(\"GitHub\") { openGitHub(\"sergiopatino\") }\n }\n HStack {\n Text(\"Moritz Brödel (@brodmo)\")\n Spacer()\n Button(\"GitHub\") { openGitHub(\"brodmo\") }\n }\n }\n }\n .buttonStyle(.accessoryBarAction)\n .formStyle(.grouped)\n .navigationTitle(\"About\")\n }\n\n private func openGitHub(_ login: String) {\n openUrl(\"https://github.com/\\(login)\")\n }\n\n private func openUrl(_ url: String) {\n if let url = URL(string: url) {\n NSWorkspace.shared.open(url)\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Workspaces/Models/MacAppWithWorkspace.swift", "//\n// MacAppWithWorkspace.swift\n//\n// Created by Wojciech Kulik on 20/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\nimport SwiftUI\n\nstruct MacAppWithWorkspace: Hashable, Codable {\n var app: MacApp\n var workspaceId: WorkspaceID\n}\n\nextension MacAppWithWorkspace: Transferable {\n static var transferRepresentation: some TransferRepresentation {\n CodableRepresentation(for: MacAppWithWorkspace.self, contentType: .json)\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/NotificationName.swift", "//\n// NotificationName.swift\n//\n// Created by Wojciech Kulik on 22/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nextension Notification.Name {\n static let appsListChanged = Notification.Name(\"appsListChanged\")\n static let openMainWindow = Notification.Name(\"openMainWindow\")\n static let profileChanged = Notification.Name(\"profileChanged\")\n static let workspaceChanged = Notification.Name(\"workspaceChanged\")\n static let workspaceTransitionFinished = Notification.Name(\"workspaceTransitionFinished\")\n static let spaceControlArrowDown = Notification.Name(\"spaceControlArrowDown\")\n static let pipFocusChanged = Notification.Name(\"pipFocusChanged\")\n}\n"], ["/FlashSpace/FlashSpace/Extensions/Bundle.swift", "//\n// Bundle.swift\n//\n// Created by Wojciech Kulik on 26/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nextension Bundle {\n var localizedAppName: String {\n localizedInfoDictionary?[\"CFBundleDisplayName\"] as? String\n ?? infoDictionary?[\"CFBundleDisplayName\"] as? String\n ?? infoDictionary?[\"CFBundleName\"] as? String\n ?? bundleURL.fileName\n }\n\n var isAgent: Bool {\n infoDictionary?[\"LSUIElement\"] as? String == \"1\" ||\n infoDictionary?[\"LSUIElement\"] as? Bool == true\n }\n\n var iconPath: String {\n let iconFile = infoDictionary?[\"CFBundleIconFile\"] as? String\n ?? infoDictionary?[\"CFBundleIconName\"] as? String\n ?? \"AppIcon\"\n\n return bundleURL\n .appendingPathComponent(\"Contents\")\n .appendingPathComponent(\"Resources\")\n .appendingPathComponent(iconFile.hasSuffix(\".icns\") ? iconFile : \"\\(iconFile).icns\")\n .path(percentEncoded: false)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/General/GeneralSettings.swift", "//\n// GeneralSettings.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nfinal class GeneralSettings: ObservableObject {\n @Published var showFlashSpace: AppHotKey?\n @Published var showFloatingNotifications = true\n @Published var checkForUpdatesAutomatically = false {\n didSet { UpdatesManager.shared.autoCheckForUpdates = checkForUpdatesAutomatically }\n }\n\n private var observer: AnyCancellable?\n private let updateSubject = PassthroughSubject<(), Never>()\n\n init() { observe() }\n\n private func observe() {\n observer = Publishers.MergeMany(\n $showFlashSpace.settingsPublisher(),\n $checkForUpdatesAutomatically.settingsPublisher(),\n $showFloatingNotifications.settingsPublisher()\n )\n .receive(on: DispatchQueue.main)\n .sink { [weak self] in self?.updateSubject.send() }\n }\n}\n\nextension GeneralSettings: SettingsProtocol {\n var updatePublisher: AnyPublisher<(), Never> {\n updateSubject.eraseToAnyPublisher()\n }\n\n func load(from appSettings: AppSettings) {\n observer = nil\n showFlashSpace = appSettings.showFlashSpace\n checkForUpdatesAutomatically = appSettings.checkForUpdatesAutomatically ?? false\n showFloatingNotifications = appSettings.showFloatingNotifications ?? true\n observe()\n }\n\n func update(_ appSettings: inout AppSettings) {\n appSettings.showFlashSpace = showFlashSpace\n appSettings.checkForUpdatesAutomatically = checkForUpdatesAutomatically\n appSettings.showFloatingNotifications = showFloatingNotifications\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/TextField.swift", "//\n// TextField.swift\n//\n// Created by Wojciech Kulik on 08/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct PlaceholderModifier: ViewModifier {\n @FocusState private var isFocused: Bool\n @Environment(\\.isEnabled) private var isEnabled\n\n let placeholder: String\n let visible: Bool\n\n func body(content: Content) -> some View {\n ZStack(alignment: .leading) {\n if visible, !isFocused {\n Text(placeholder)\n .foregroundColor(.secondary)\n .allowsHitTesting(false)\n .frame(maxWidth: .infinity, alignment: .trailing)\n .opacity(isEnabled ? 1 : 0.5)\n }\n content\n .focused($isFocused)\n }\n }\n}\n\nextension View {\n func placeholder(_ placeholder: String, visible: Bool) -> some View {\n modifier(PlaceholderModifier(placeholder: placeholder, visible: visible))\n }\n\n func standardPlaceholder(_ visible: Bool) -> some View {\n placeholder(\"(type here)\", visible: visible)\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/NSView.swift", "//\n// NSView.swift\n//\n// Created by Wojciech Kulik on 11/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension NSView {\n func addVisualEffect(material: NSVisualEffectView.Material, border: Bool = false) -> NSView {\n let visualEffectView = NSVisualEffectView()\n visualEffectView.material = material\n visualEffectView.blendingMode = .behindWindow\n visualEffectView.state = .active\n\n if border {\n visualEffectView.wantsLayer = true\n visualEffectView.layer?.cornerRadius = 24\n visualEffectView.layer?.borderWidth = 0.8\n visualEffectView.layer?.borderColor = NSColor.darkGray.cgColor\n visualEffectView.layer?.masksToBounds = true\n }\n\n visualEffectView.addSubview(self)\n translatesAutoresizingMaskIntoConstraints = false\n\n NSLayoutConstraint.activate([\n leadingAnchor.constraint(equalTo: visualEffectView.leadingAnchor),\n trailingAnchor.constraint(equalTo: visualEffectView.trailingAnchor),\n topAnchor.constraint(equalTo: visualEffectView.topAnchor),\n bottomAnchor.constraint(equalTo: visualEffectView.bottomAnchor)\n ])\n\n return visualEffectView\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/FloatingApps/FloatingAppsSettingsViewModel.swift", "import Foundation\nimport SwiftUI\n\nfinal class FloatingAppsSettingsViewModel: ObservableObject {\n private let settings = AppDependencies.shared.floatingAppsSettings\n\n func addFloatingApp() {\n let fileChooser = FileChooser()\n let appUrl = fileChooser.runModalOpenPanel(\n allowedFileTypes: [.application],\n directoryURL: URL(filePath: \"/Applications\")\n )\n\n guard let bundle = appUrl?.bundle else { return }\n\n settings.addFloatingAppIfNeeded(\n app: .init(\n name: bundle.localizedAppName,\n bundleIdentifier: bundle.bundleIdentifier ?? \"\",\n iconPath: bundle.iconPath\n )\n )\n }\n\n func deleteFloatingApp(app: MacApp) {\n settings.deleteFloatingApp(app: app)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/PictureInPicture/Models/PipBrowser.swift", "//\n// PipBrowser.swift\n//\n// Created by Wojciech Kulik on 12/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\n/// Browser apps that support Picture in Picture\nenum PipBrowser: String, CaseIterable {\n case chrome = \"com.google.Chrome\"\n case vivaldi = \"com.vivaldi.Vivaldi\"\n case brave = \"com.brave.Browser\"\n case opera = \"com.operasoftware.Opera\"\n case firefox = \"org.mozilla.firefox\"\n case zen = \"app.zen-browser.zen\"\n case arc = \"company.thebrowser.Browser\"\n case dia = \"company.thebrowser.dia\"\n case comet = \"ai.perplexity.comet\"\n\n var bundleId: String { rawValue }\n\n var title: String? {\n switch self {\n case .chrome, .vivaldi, .brave, .opera, .comet:\n return \"Picture in Picture\"\n case .zen, .firefox:\n return \"Picture-in-Picture\"\n case .arc, .dia:\n return nil\n }\n }\n\n var partialTitle: String? {\n switch self {\n case .chrome:\n return \"about:blank \"\n default:\n return nil\n }\n }\n\n var subrole: String? {\n switch self {\n case .arc, .dia:\n return (NSAccessibility.Subrole.systemDialog as CFString) as String\n default:\n return nil\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/CornerRadius.swift", "//\n// CornerRadius.swift\n//\n// Created by Wojciech Kulik on 11/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport SwiftUI\n\nstruct RoundedCorners: Shape {\n var radius: CGFloat\n var corners: [Corner]\n\n enum Corner {\n case topLeft, topRight, bottomLeft, bottomRight\n }\n\n func path(in rect: CGRect) -> Path {\n var path = Path()\n\n let topLeft = corners.contains(.topLeft) ? radius : 0\n let topRight = corners.contains(.topRight) ? radius : 0\n let bottomLeft = corners.contains(.bottomLeft) ? radius : 0\n let bottomRight = corners.contains(.bottomRight) ? radius : 0\n\n path.move(to: CGPoint(x: rect.minX, y: rect.midY))\n\n path.addArc(\n center: CGPoint(x: rect.minX + topLeft, y: rect.minY + topLeft),\n radius: topLeft,\n startAngle: .degrees(180),\n endAngle: .degrees(270),\n clockwise: false\n )\n\n path.addArc(\n center: CGPoint(x: rect.maxX - topRight, y: rect.minY + topRight),\n radius: topRight,\n startAngle: .degrees(270),\n endAngle: .degrees(0),\n clockwise: false\n )\n\n path.addArc(\n center: CGPoint(x: rect.maxX - bottomRight, y: rect.maxY - bottomRight),\n radius: bottomRight,\n startAngle: .degrees(0),\n endAngle: .degrees(90),\n clockwise: false\n )\n\n path.addArc(\n center: CGPoint(x: rect.minX + bottomLeft, y: rect.maxY - bottomLeft),\n radius: bottomLeft,\n startAngle: .degrees(90),\n endAngle: .degrees(180),\n clockwise: false\n )\n\n path.closeSubpath()\n return path\n }\n}\n\nextension View {\n func cornerRadius(_ radius: CGFloat, corners: [RoundedCorners.Corner]) -> some View {\n clipShape(RoundedCorners(radius: radius, corners: corners))\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/HotKeys/Extensions/AppHotKey+Shortcut.swift", "//\n// AppHotKey+Shortcut.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ShortcutRecorder\n\nextension [(AppHotKey, () -> ())] {\n func toShortcutPairs() -> [(Shortcut, () -> ())] {\n map { ($0.0.toShortcut(), $0.1) }\n .compactMap {\n guard let shortcut = $0.0 else { return nil }\n return (shortcut, $0.1)\n }\n }\n}\n\nextension AppHotKey {\n func toShortcut() -> Shortcut? {\n let components = value.components(separatedBy: \"+\")\n let modifiers = KeyModifiersMap.toModifiers(value)\n\n guard let keyEquivalent = components.last,\n let rawKeyCode = KeyCodesMap[keyEquivalent],\n let keyCode = KeyCode(rawValue: rawKeyCode) else { return nil }\n\n return Shortcut(\n code: keyCode,\n modifierFlags: NSEvent.ModifierFlags(rawValue: modifiers),\n characters: nil,\n charactersIgnoringModifiers: nil\n )\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Workspaces/DisplayMode.swift", "//\n// DisplayMode.swift\n//\n// Created by Wojciech Kulik on 12/07/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nenum DisplayMode: String, Codable, CaseIterable {\n case `static`\n case dynamic\n}\n\nextension DisplayMode: Identifiable {\n var id: String { rawValue }\n\n var description: String {\n switch self {\n case .static: return \"Static\"\n case .dynamic: return \"Dynamic\"\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/App/FlashSpaceApp.swift", "//\n// FlashSpaceApp.swift\n// FlashSpace\n//\n// Created by Wojciech Kulik on 19/01/2025.\n//\n\nimport SwiftUI\n\n@main\nstruct FlashSpaceApp: App {\n @NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate\n\n var body: some Scene {\n Window(\"⚡ FlashSpace v\\(AppConstants.version)\", id: \"main\") {\n MainView()\n }\n .windowResizability(.contentSize)\n\n Window(\"Settings\", id: \"settings\") {\n SettingsView()\n }\n .windowResizability(.contentSize)\n\n FlashSpaceMenuBar()\n }\n}\n"], ["/FlashSpace/FlashSpace/Accessibility/AXUIElement+Actions.swift", "//\n// AXUIElement+Actions.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension AXUIElement {\n /// Position is in window coordinates where (0,0) is top-left corner\n /// and it is relative to the main screen.\n func setPosition(_ position: CGPoint) {\n var position = position\n let positionRef = AXValueCreate(.cgPoint, &position)\n setAttribute(.position, value: positionRef)\n }\n\n func focus() {\n AXUIElementPerformAction(self, NSAccessibility.Action.raise as CFString)\n }\n\n func minimize(_ minimized: Bool) {\n setAttribute(.minimized, value: minimized)\n }\n}\n"], ["/FlashSpace/FlashSpace/Utils/FileChooser.swift", "//\n// FileChooser.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\nimport UniformTypeIdentifiers\n\nfinal class FileChooser {\n func runModalOpenPanel(allowedFileTypes: [UTType]?, directoryURL: URL?) -> URL? {\n let openPanel = NSOpenPanel()\n openPanel.canChooseFiles = true\n openPanel.allowedContentTypes = allowedFileTypes ?? []\n openPanel.directoryURL = directoryURL\n\n return openPanel.runModal() == .OK ? openPanel.url : nil\n }\n\n func runModalSavePanel(allowedFileTypes: [UTType]?, defaultFileName: String?) -> URL? {\n let savePanel = NSSavePanel()\n savePanel.allowsOtherFileTypes = false\n savePanel.canCreateDirectories = true\n savePanel.allowedContentTypes = allowedFileTypes ?? []\n savePanel.nameFieldStringValue = defaultFileName ?? \"\"\n\n return savePanel.runModal() == .OK ? savePanel.url : nil\n }\n\n @MainActor\n func runSheetModalOpenPanel(window: NSWindow, allowedFileTypes: [UTType]?, directoryURL: URL?) async -> URL? {\n let openPanel = NSOpenPanel()\n openPanel.canChooseFiles = true\n openPanel.allowedContentTypes = allowedFileTypes ?? []\n openPanel.directoryURL = directoryURL\n\n return await openPanel.beginSheetModal(for: window) == .OK ? openPanel.url : nil\n }\n\n @MainActor\n func runSheetModalSavePanel(window: NSWindow, allowedFileTypes: [UTType]?, defaultFileName: String?) async -> URL? {\n let savePanel = NSSavePanel()\n savePanel.allowsOtherFileTypes = false\n savePanel.canCreateDirectories = true\n savePanel.allowedContentTypes = allowedFileTypes ?? []\n savePanel.nameFieldStringValue = defaultFileName ?? \"\"\n\n return await savePanel.beginSheetModal(for: window) == .OK ? savePanel.url : nil\n }\n}\n"], ["/FlashSpace/FlashSpace/App/AppDelegate.swift", "//\n// AppDelegate.swift\n//\n// Created by Wojciech Kulik on 13/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Combine\nimport SwiftUI\n\nfinal class AppDelegate: NSObject, NSApplicationDelegate {\n @Environment(\\.openWindow) private var openWindow\n @Environment(\\.dismissWindow) private var dismissWindow\n\n private var cancellables = Set()\n\n func applicationDidFinishLaunching(_ notification: Notification) {\n AppDependencies.shared.hotKeysManager.enableAll()\n\n NotificationCenter.default\n .publisher(for: .openMainWindow)\n .sink { [weak self] _ in\n self?.openWindow(id: \"main\")\n NSApp.activate(ignoringOtherApps: true)\n }\n .store(in: &cancellables)\n\n #if DEBUG\n dismissWindow(id: \"main\")\n #endif\n }\n\n func applicationWillTerminate(_ notification: Notification) {\n AppDependencies.shared.pictureInPictureManager.restoreAllWindows()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/FocusManager/Models/MacAppWithWindows.swift", "//\n// MacAppWithWindows.swift\n//\n// Created by Wojciech Kulik on 04/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport CoreGraphics\n\nstruct MacAppWithWindows {\n struct MacAppWindow {\n let frame: CGRect\n let title: String\n let axWindow: AXUIElement\n }\n\n let app: NSRunningApplication\n let bundleIdentifier: BundleId\n\n /// Sorted by title and then by x position\n let windows: [MacAppWindow]\n\n init(app: NSRunningApplication) {\n self.app = app\n self.bundleIdentifier = app.bundleIdentifier ?? \"\"\n self.windows = app.allWindows\n .map { MacAppWindow(frame: $0.frame, title: $0.window.title ?? \"\", axWindow: $0.window) }\n .sorted { $0.title < $1.title || $0.title == $1.title && $0.frame.minX < $1.frame.minX }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/PictureInPicture/Models/PipApp.swift", "//\n// PipApp.swift\n//\n// Created by Wojciech Kulik on 22/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nstruct PipApp: Codable, Equatable, Hashable {\n let name: String\n let bundleIdentifier: BundleId\n let pipWindowTitleRegex: String\n}\n"], ["/FlashSpace/FlashSpace/Extensions/View.swift", "//\n// View.swift\n//\n// Created by Wojciech Kulik on 25/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nextension View {\n func hotkey(_ title: String, for hotKey: Binding) -> some View {\n HStack {\n Text(title)\n Spacer()\n HotKeyControl(shortcut: hotKey).fixedSize()\n }\n }\n\n @ViewBuilder\n func hidden(_ isHidden: Bool) -> some View {\n if !isHidden {\n self\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Config/Models/ConfigFormat.swift", "//\n// ConfigFormat.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nenum ConfigFormat: String, CaseIterable {\n case json\n case toml\n case yaml\n\n var displayName: String {\n switch self {\n case .json: return \"JSON\"\n case .toml: return \"TOML\"\n case .yaml: return \"YAML\"\n }\n }\n\n var extensionName: String {\n switch self {\n case .json: return \"json\"\n case .toml: return \"toml\"\n case .yaml: return \"yaml\"\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/Color.swift", "//\n// Color.swift\n//\n// Created by Wojciech Kulik on 04/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\npublic extension Color {\n init?(hex: String?) {\n guard let hex else { return nil }\n var hexValue = hex.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines).uppercased()\n\n if hexValue.hasPrefix(\"#\") {\n hexValue.remove(at: hexValue.startIndex)\n }\n\n var rgbValue: UInt64 = 0\n Scanner(string: hexValue).scanHexInt64(&rgbValue)\n\n let red = CGFloat((rgbValue & 0xFF0000) >> 16) / 255.0\n let green = CGFloat((rgbValue & 0x00FF00) >> 8) / 255.0\n let blue = CGFloat(rgbValue & 0x0000FF) / 255.0\n\n self.init(red: red, green: green, blue: blue, opacity: 1)\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Models/CommandResponse.swift", "//\n// CommandResponse.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nstruct CommandResponse: Codable {\n let success: Bool\n let message: String?\n let error: String?\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Models/CommandResponse.swift", "//\n// CommandResponse.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nstruct CommandResponse: Codable {\n var success: Bool\n var message: String?\n var error: String?\n}\n"], ["/FlashSpace/FlashSpace/UI/Alerts.swift", "//\n// Alerts.swift\n//\n// Created by Wojciech Kulik on 25/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nenum Alert {\n static func showOkAlert(title: String, message: String) {\n let alert = NSAlert()\n alert.messageText = title\n alert.informativeText = message\n alert.alertStyle = .informational\n alert.addButton(withTitle: \"OK\")\n alert.runModal()\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/String.swift", "//\n// String.swift\n//\n// Created by Wojciech Kulik on 13/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nextension String {\n static let defaultIconSymbol = \"bolt.fill\"\n\n var isNotEmpty: Bool { !isEmpty }\n var nilIfEmpty: String? { isEmpty ? nil : self }\n var trimmed: String { trimmingCharacters(in: .whitespacesAndNewlines) }\n}\n"], ["/FlashSpace/FlashSpace/Features/Config/Models/TOMLCoding.swift", "//\n// TOMLCoding.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\nimport TOMLKit\n\nextension TOMLEncoder: ConfigEncoder {\n func encode(_ value: some Encodable) throws -> Data {\n let toml: String = try encode(value)\n return toml.data(using: .utf8) ?? Data()\n }\n}\n\nextension TOMLDecoder: ConfigDecoder {\n func decode(_ type: T.Type, from data: Data) throws -> T where T: Decodable {\n let toml = String(data: data, encoding: .utf8) ?? \"\"\n return try decode(T.self, from: toml)\n }\n}\n"], ["/FlashSpace/FlashSpace/Utils/UpdatesManager.swift", "//\n// UpdatesManager.swift\n//\n// Created by Wojciech Kulik on 25/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\nimport Sparkle\n\nfinal class UpdatesManager {\n static let shared = UpdatesManager()\n\n var autoCheckForUpdates: Bool {\n get { updaterController.updater.automaticallyChecksForUpdates }\n set { updaterController.updater.automaticallyChecksForUpdates = newValue }\n }\n\n private var lastCheckDate = Date.distantPast\n private var detectedNewRelease = false\n\n private let updaterController = SPUStandardUpdaterController(\n startingUpdater: true,\n updaterDelegate: nil,\n userDriverDelegate: nil\n )\n\n private init() {\n updaterController.updater.updateCheckInterval = 30 * 60\n\n DispatchQueue.main.async {\n self.autoCheckForUpdates = AppDependencies.shared.generalSettings.checkForUpdatesAutomatically\n }\n }\n\n func checkForUpdates() {\n updaterController.updater.checkForUpdates()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/_Extensions/Publisher.swift", "//\n// Publisher.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nextension Publisher where Output: Equatable {\n func settingsPublisher() -> AnyPublisher<(), Failure> {\n removeDuplicates()\n .map { _ in }\n .dropFirst()\n .eraseToAnyPublisher()\n }\n\n func settingsPublisher(debounce: Bool) -> AnyPublisher<(), Failure> {\n if debounce {\n self.debounce(for: .seconds(1), scheduler: DispatchQueue.main)\n .settingsPublisher()\n } else {\n settingsPublisher()\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Utils/Logger.swift", "//\n// Logger.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nenum Logger {\n static let dateFormatter: DateFormatter = {\n let formatter = DateFormatter()\n formatter.dateFormat = \"HH:mm:ss.SSS\"\n return formatter\n }()\n\n static func log(_ message: String) {\n #if DEBUG\n let dateString = dateFormatter.string(from: Date())\n print(\"\\(dateString): \\(message)\")\n #endif\n }\n\n static func log(_ error: Error) {\n log(\"\\(error)\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/PictureInPicture/Extensions/NSRunningApplication+PiP.swift", "//\n// NSRunningApplication+PiP.swift\n//\n// Created by Wojciech Kulik on 12/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension NSRunningApplication {\n var supportsPictureInPicture: Bool {\n PipBrowser.allCases.contains { $0.bundleId == bundleIdentifier } ||\n pipApps.contains { $0.bundleIdentifier == bundleIdentifier }\n }\n\n var isPictureInPictureActive: Bool {\n allWindows.map(\\.window).contains { $0.isPictureInPicture(bundleId: bundleIdentifier) }\n }\n\n private var pipApps: [PipApp] {\n AppDependencies.shared.workspaceSettings.pipApps\n }\n}\n"], ["/FlashSpace/FlashSpace/Utils/PermissionsManager.swift", "//\n// PermissionsManager.swift\n//\n// Created by Wojciech Kulik on 25/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nfinal class PermissionsManager {\n static let shared = PermissionsManager()\n\n private init() {}\n\n func askForAccessibilityPermissions() {\n let options: NSDictionary = [kAXTrustedCheckOptionPrompt.takeRetainedValue() as NSString: true]\n _ = AXIsProcessTrustedWithOptions(options)\n }\n\n func checkForAccessibilityPermissions() -> Bool {\n AXIsProcessTrusted()\n }\n\n func askForScreenRecordingPermissions() {\n CGRequestScreenCaptureAccess()\n }\n\n func checkForScreenRecordingPermissions() -> Bool {\n CGPreflightScreenCaptureAccess()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/HotKeys/Models/HotKeysMonitor.swift", "//\n// HotKeysMonitor.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ShortcutRecorder\n\nprotocol HotKeysMonitorProtocol: AnyObject {\n var actions: [ShortcutAction] { get }\n\n func addAction(_ anAction: ShortcutAction, forKeyEvent aKeyEvent: KeyEventType)\n func removeAction(_ anAction: ShortcutAction)\n func removeAllActions()\n}\n\nextension GlobalShortcutMonitor: HotKeysMonitorProtocol {}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Models/CommandExecutor.swift", "//\n// CommandExecutor.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nprotocol CommandExecutor {\n func execute(command: CommandRequest) -> CommandResponse?\n}\n"], ["/FlashSpace/FlashSpace/Accessibility/NSAccessibility+Attributes.swift", "//\n// NSAccessibility+Attributes.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension NSAccessibility.Attribute {\n static let enchancedUserInterface: NSAccessibility.Attribute = .init(rawValue: \"AXEnhancedUserInterface\")\n}\n"], ["/FlashSpace/FlashSpace/Extensions/URL.swift", "//\n// URL.swift\n//\n// Created by Wojciech Kulik on 26/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nextension URL {\n var bundle: Bundle? { Bundle(url: self) }\n var fileName: String { lastPathComponent.replacingOccurrences(of: \".app\", with: \"\") }\n var appName: String { bundle?.localizedAppName ?? fileName }\n var bundleIdentifier: BundleId? { bundle?.bundleIdentifier }\n var iconPath: String? { bundle?.iconPath }\n\n func createIntermediateDirectories() throws {\n try FileManager.default.createDirectory(\n at: deletingLastPathComponent(),\n withIntermediateDirectories: true\n )\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/Array.swift", "//\n// Array.swift\n//\n// Created by Wojciech Kulik on 27/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nextension Array {\n subscript(safe index: Index) -> Element? {\n get {\n indices.contains(index) ? self[index] : nil\n }\n set {\n guard indices.contains(index), let newValue else { return }\n self[index] = newValue\n }\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Extensions/SocketDataSerialization.swift", "//\n// SocketDataSerialization.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nextension Data {\n func decodeSocketData(_ type: T.Type) throws -> T {\n var data = self\n data.removeLast()\n return try JSONDecoder().decode(T.self, from: data)\n }\n}\n\nextension Encodable {\n func encodeSocketData() -> Data? {\n var result = try? JSONEncoder().encode(self)\n result?.append(0)\n return result\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Extensions/SocketDataSerialization.swift", "//\n// SocketDataSerialization.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nextension Data {\n func decodeSocketData(_ type: T.Type) throws -> T {\n var data = self\n data.removeLast()\n return try JSONDecoder().decode(T.self, from: data)\n }\n}\n\nextension Encodable {\n func encodeSocketData() -> Data? {\n var result = try? JSONEncoder().encode(self)\n result?.append(0)\n return result\n }\n}\n"], ["/FlashSpace/FlashSpace/Accessibility/AXUIElement+GetSet.swift", "//\n// AXUIElement+GetSet.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension AXUIElement {\n func getAttribute(_ attribute: NSAccessibility.Attribute) -> T? {\n var value: CFTypeRef?\n AXUIElementCopyAttributeValue(self, attribute as CFString, &value)\n\n return value as? T\n }\n\n func setAttribute(_ attribute: NSAccessibility.Attribute, value: some Any) {\n AXUIElementSetAttributeValue(self, attribute as CFString, value as CFTypeRef)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Config/Models/YAMLCoding.swift", "//\n// YAMLCoding.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\nimport Yams\n\nextension YAMLEncoder: ConfigEncoder {\n func encode(_ value: some Encodable) throws -> Data {\n let yaml: String = try encode(value)\n return yaml.data(using: .utf8) ?? Data()\n }\n}\n\nextension YAMLDecoder: ConfigDecoder {}\n"], ["/FlashSpace/FlashSpace/Extensions/MacAppArray.swift", "//\n// MacAppArray.swift\n//\n// Created by Wojciech Kulik on 06/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension [MacApp] {\n func firstIndex(ofAppWith bundleIdentifier: BundleId) -> Int? {\n firstIndex { $0.bundleIdentifier == bundleIdentifier }\n }\n\n func firstIndex(of app: NSRunningApplication) -> Int? {\n firstIndex { $0.bundleIdentifier == app.bundleIdentifier }\n }\n\n func containsApp(with bundleIdentifier: BundleId?) -> Bool {\n contains { $0.bundleIdentifier == bundleIdentifier }\n }\n\n func containsApp(_ app: NSRunningApplication) -> Bool {\n contains { $0.bundleIdentifier == app.bundleIdentifier }\n }\n}\n"], ["/FlashSpace/FlashSpace/Accessibility/NSRunningApplication+Apps.swift", "//\n// NSRunningApplication+Apps.swift\n//\n// Created by Wojciech Kulik on 12/07/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension NSRunningApplication {\n var isFinder: Bool { bundleIdentifier == \"com.apple.finder\" }\n var isPython: Bool { bundleIdentifier == \"org.python.python\" }\n var isOrion: Bool { bundleIdentifier == \"com.kagi.kagimacOS\" }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/Collection.swift", "//\n// Collection.swift\n//\n// Created by Wojciech Kulik on 12/07/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nextension Collection {\n var isNotEmpty: Bool { !isEmpty }\n}\n\nextension Collection where Element: Hashable {\n var asSet: Set { Set(self) }\n}\n"], ["/FlashSpace/FlashSpace/Features/Config/Models/ConfigCoder.swift", "//\n// ConfigCoder.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nprotocol ConfigEncoder {\n func encode(_ value: some Encodable) throws -> Data\n}\n\nprotocol ConfigDecoder {\n func decode(_ type: T.Type, from data: Data) throws -> T where T: Decodable\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/_Models/SettingsProtocol.swift", "//\n// SettingsProtocol.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\n\nprotocol SettingsProtocol {\n var updatePublisher: AnyPublisher<(), Never> { get }\n\n func load(from appSettings: AppSettings)\n func update(_ appSettings: inout AppSettings)\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Models/BufferWrapper.swift", "//\n// BufferWrapper.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nfinal class BufferWrapper {\n var data = Data()\n}\n"], ["/FlashSpace/FlashSpace/Features/Config/Models/JSONCoding.swift", "//\n// JSONCoding.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nextension JSONEncoder: ConfigEncoder {}\nextension JSONDecoder: ConfigDecoder {}\n"]], "task_instance_info": {"created_time": "2025-08-21 03:16:11", "created_task_model": "DeepSeek-R1", "function_skeleton": "func validate ( ) throws { }", "code_description": "This code segment functions to: Enforce mutual exclusivity between optional parameters and required parameter presence checks while validating the existence of specified system resources."}, "inference_content": {"inference_model": "DeepSeek-R1", "inference_result": "```swift\n[TASK_START]\n func validate() throws {\n guard (workspace != nil) != activeWorkspace else {\n throw CommandError.operationFailed(\"Must provide either --workspace or --active-workspace, but not both\")\n }\n \n guard (display != nil) != activeDisplay else {\n throw CommandError.operationFailed(\"Must provide either --display or --active-display, but not both\")\n }\n }\n[TASK_END]\n```", "inference_time": "2025-08-21 03-16-38"}, "editdistance_info": {"edit_distance": 20.2186, "calculate_time": "2025-08-21 03:16:38", "true_code_clean": "func validate() throws {\n if workspace != nil, activeWorkspace {\n throw CommandError.operationFailed(\"You cannot provide both a workspace name and use the --active-workspace flag\")\n }\n if display != nil, activeDisplay {\n throw CommandError.operationFailed(\"You cannot provide both a display name and use the --active-display flag\")\n }\n if workspace == nil, !activeWorkspace {\n throw CommandError.operationFailed(\"You must provide either a workspace name or use the --active-workspace flag\")\n }\n if display == nil, !activeDisplay {\n throw CommandError.operationFailed(\"You must provide either a display name or use the --active-display flag\")\n }\n if let display, !NSScreen.screens.contains(where: { $0.localizedName == display }) {\n throw CommandError.operationFailed(\"Display \\\"\\(display)\\\" not found\")\n }\n }", "predict_code_clean": "[TASK_START]\n func validate() throws {\n guard (workspace != nil) != activeWorkspace else {\n throw CommandError.operationFailed(\"Must provide either --workspace or --active-workspace, but not both\")\n }\n guard (display != nil) != activeDisplay else {\n throw CommandError.operationFailed(\"Must provide either --display or --active-display, but not both\")\n }\n }\n[TASK_END]"}} {"repo_name": "FlashSpace", "file_name": "/FlashSpace/FlashSpaceCLI/Sources/Subcommands/List/ListAppsCommand.swift", "inference_info": {"prefix_code": "//\n// ListAppsCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct ListAppsCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"list-apps\",\n abstract: \"List workspace apps\"\n )\n\n @Argument(help: \"Workspace name\")\n var workspace: String\n\n @Option(help: \"Profile name\")\n var profile: String?\n\n @Flag(help: \"Include bundle id\")\n var withBundleId = false\n\n @Flag(help: \"Include icon\")\n var withIcon = false\n\n @Flag(help: \"Only running apps\")\n var onlyRunning = false\n\n ", "suffix_code": "\n}\n", "middle_code": "func run() throws {\n sendCommand(.listApps(\n workspace: workspace,\n profile: profile,\n withBundleId: withBundleId,\n withIcon: withIcon,\n onlyRunning: onlyRunning\n ))\n runWithTimeout()\n }", "code_description": null, "fill_type": "FUNCTION_TYPE", "language_type": "swift", "sub_task_type": null}, "context_code": [["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/List/ListFloatingAppsCommand.swift", "//\n// ListFloatingAppsCommand.swift\n//\n// Created by Wojciech Kulik on 03/05/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct ListFloatingAppsCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"list-floating-apps\",\n abstract: \"List floating apps\"\n )\n\n @Flag(help: \"Include bundle id\")\n var withBundleId = false\n\n func run() throws {\n sendCommand(.listFloatingApps(withBundleId: withBundleId))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/List/ListRunningAppsCommand.swift", "//\n// ListRunningAppsCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport ArgumentParser\nimport Foundation\n\nstruct ListRunningAppsCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"list-running-apps\",\n abstract: \"List running apps\"\n )\n\n @Flag(help: \"Include bundle id\")\n var withBundleId = false\n\n func run() throws {\n let apps = NSWorkspace.shared.runningApplications\n .filter { $0.activationPolicy == .regular }\n\n let result = Set(apps)\n .filter { $0.localizedName != nil }\n .map { (bundleId: $0.bundleIdentifier ?? \"-\", name: $0.localizedName ?? \"-\") }\n .sorted { $0.name.lowercased() < $1.name.lowercased() }\n .map { app in\n if withBundleId {\n return [app.name, app.bundleId].joined(separator: \",\")\n } else {\n return app.name\n }\n }\n .joined(separator: \"\\n\")\n print(result)\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/List/ListWorkspacesCommand.swift", "//\n// ListWorkspacesCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct ListWorkspacesCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"list-workspaces\",\n abstract: \"List workspaces\"\n )\n\n @Flag(help: \"Include assigned display name\")\n var withDisplay = false\n\n @Option(help: \"Profile name\")\n var profile: String?\n\n func run() throws {\n sendCommand(.listWorkspaces(withDisplay: withDisplay, profile: profile))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Workspace/WorkspaceCommand.swift", "//\n// WorkspaceCommand.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct WorkspaceCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"workspace\",\n abstract: \"Activate a workspace\"\n )\n\n @Option(help: .init(\"The name of the workspace\"))\n var name: String?\n\n @Option(help: .init(\n \"The number of the workspace to activate. Starting from 1.\",\n valueName: \"number\"\n ))\n var number: Int?\n\n @Flag(help: \"Activate the next workspace\")\n var next = false\n\n @Flag(help: \"Activate the previous workspace\")\n var prev = false\n\n @Flag(help: \"Activate the most recently used workspace\")\n var recent = false\n\n @Flag(help: \"Skip empty workspaces (works only with --next or --prev)\")\n var skipEmpty = false\n\n @Flag(help: \"Loop back to the first workspace when reaching the last one and vice versa (works only with --next or --prev)\")\n var loop = false\n\n @Flag(help: \"Hide all apps that are not assigned to the selected workspace\")\n var clean = false\n\n func run() throws {\n if let name {\n sendCommand(.activateWorkspace(name: name, number: nil, clean: clean))\n } else if let number {\n sendCommand(.activateWorkspace(name: nil, number: number, clean: clean))\n } else if next {\n sendCommand(.nextWorkspace(skipEmpty: skipEmpty, clean: clean, loop: loop))\n } else if prev {\n sendCommand(.previousWorkspace(skipEmpty: skipEmpty, clean: clean, loop: loop))\n } else if recent {\n sendCommand(.recentWorkspace(clean: clean))\n } else {\n fallbackToHelp()\n }\n\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Workspace/CreateWorkspaceCommand.swift", "//\n// CreateWorkspaceCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct CreateWorkspaceRequest: Codable {\n let name: String\n let display: String?\n let icon: String?\n let activateKey: String?\n let assignKey: String?\n let activate: Bool\n}\n\nstruct CreateWorkspaceCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"create-workspace\",\n abstract: \"Create a workspace\"\n )\n\n @Argument(help: \"The name of the workspace to create.\")\n var name: String\n\n @Option(help: .init(\"The name of the display\", valueName: \"name\"))\n var display: String?\n\n @Option(help: \"The name of the icon to use for the workspace. Must match SF Symbols.\")\n var icon: String?\n\n @Option(help: \"The hotkey to activate the workspace\")\n var activateKey: String?\n\n @Option(help: \"The hotkey to assign the app\")\n var assignKey: String?\n\n @Flag(help: \"Activate the new workspace\")\n var activate = false\n\n func run() throws {\n let request = CreateWorkspaceRequest(\n name: name,\n display: display,\n icon: icon,\n activateKey: activateKey,\n assignKey: assignKey,\n activate: activate\n )\n sendCommand(.createWorkspace(request))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/App/AssignAppCommand.swift", "//\n// AssignAppCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct AssignAppCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"assign-app\",\n abstract: \"Assign an app to a workspace\"\n )\n\n @Option(help: .init(\n \"The name of the app or bundle id. If not provided, the active app will be assigned. Default: active app.\",\n valueName: \"name|bundle id\"\n ))\n var name: String?\n\n @Option(\n name: .customLong(\"workspace\"),\n help: .init(\"The name of the workspace to assign the app to. Default: active workspace.\", valueName: \"name\")\n )\n var workspace: String?\n\n @Option(help: .init(\n \"Activate the workspace. Default: from app settings.\",\n valueName: \"true|false\"\n ))\n var activate: Bool?\n\n @Flag(help: \"Show toast notification\")\n var showNotification = false\n\n func run() throws {\n sendCommand(\n .assignApp(\n app: name,\n workspaceName: workspace,\n activate: activate,\n showNotification: showNotification\n )\n )\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/App/FloatingAppsCommand.swift", "//\n// FloatingAppsCommand.swift\n//\n// Created by Wojciech Kulik on 03/05/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct FloatingAppsCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"floating-apps\",\n abstract: \"Manage floating apps\"\n )\n\n enum Action: String, CaseIterable, ExpressibleByArgument {\n case float\n case unfloat\n case toggle\n }\n\n @Argument(help: \"The action to perform\")\n var action: Action\n\n @Option(help: .init(\n \"The name of the app or bundle id. If not provided, the active app will be used. Default: active app.\",\n valueName: \"name|bundle id\"\n ))\n var name: String?\n\n @Flag(help: \"Show toast notification\")\n var showNotification = false\n\n func run() throws {\n switch action {\n case .float:\n sendCommand(.floatApp(app: name, showNotification: showNotification))\n case .unfloat:\n sendCommand(.unfloatApp(app: name, showNotification: showNotification))\n case .toggle:\n sendCommand(.toggleFloatApp(app: name, showNotification: showNotification))\n }\n\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/App/AssignVisibleAppsCommand.swift", "//\n// AssignVisibleAppsCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct AssignVisibleAppsCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"assign-visible-apps\",\n abstract: \"Assign visible apps to a workspace\"\n )\n\n @Option(\n name: .customLong(\"workspace\"),\n help: .init(\"The name of the workspace to assign apps to. Default: active workspace.\", valueName: \"name\")\n )\n var workspace: String?\n\n @Flag(help: \"Show toast notification\")\n var showNotification = false\n\n func run() throws {\n sendCommand(\n .assignVisibleApps(workspaceName: workspace, showNotification: showNotification)\n )\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Commands/ListCommands.swift", "//\n// ListCommands.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\n\nfinal class ListCommands: CommandExecutor {\n var workspaceRepository: WorkspaceRepository { AppDependencies.shared.workspaceRepository }\n var profilesRepository: ProfilesRepository { AppDependencies.shared.profilesRepository }\n var settingsRepository: SettingsRepository { AppDependencies.shared.settingsRepository }\n\n // swiftlint:disable:next function_body_length\n func execute(command: CommandRequest) -> CommandResponse? {\n switch command {\n case .listWorkspaces(let withDisplay, let profileName):\n let profile = profileName != nil\n ? profilesRepository.profiles.first { $0.name == profileName }\n : profilesRepository.selectedProfile\n\n if let profile {\n let result: String\n\n if withDisplay {\n result = profile.workspaces.map {\n let displays = $0.displays.joined(separator: \",\")\n return \"\\($0.name),\\(displays.isEmpty ? \"None\" : displays)\"\n }.joined(separator: \"\\n\")\n } else {\n result = profile.workspaces.map(\\.name).joined(separator: \"\\n\")\n }\n\n return CommandResponse(success: true, message: result)\n } else {\n return CommandResponse(success: false, error: \"Profile not found\")\n }\n\n case .listProfiles:\n let result = profilesRepository.profiles.map(\\.name).joined(separator: \"\\n\")\n return CommandResponse(success: true, message: result)\n\n case .listApps(let workspace, let profileName, let withBundleId, let withIcon, let onlyRunning):\n let profile = profileName != nil\n ? profilesRepository.profiles.first { $0.name == profileName }\n : profilesRepository.selectedProfile\n\n guard let profile else {\n return CommandResponse(success: false, error: \"Profile not found\")\n }\n\n guard let workspace = profile.workspaces.first(where: { $0.name == workspace }) else {\n return CommandResponse(success: false, error: \"Workspace not found\")\n }\n\n let runningApps = NSWorkspace.shared.runningApplications.map(\\.bundleIdentifier).asSet\n\n let result = workspace.apps\n .filter { !onlyRunning || runningApps.contains($0.bundleIdentifier) }\n .map { app in\n [\n app.name,\n withBundleId ? app.bundleIdentifier : nil,\n withIcon ? app.iconPath ?? \"\" : nil\n ].compactMap { $0 }.joined(separator: \",\")\n }\n .joined(separator: \"\\n\")\n\n return CommandResponse(success: true, message: result)\n\n case .listFloatingApps(let withBundleId):\n let floatingApps = settingsRepository.floatingAppsSettings.floatingApps\n .map { app in\n [\n app.name,\n withBundleId ? app.bundleIdentifier : nil\n ].compactMap { $0 }.joined(separator: \",\")\n }\n .joined(separator: \"\\n\")\n\n return CommandResponse(success: true, message: floatingApps)\n\n default:\n return nil\n }\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Profile/CreateProfileCommand.swift", "//\n// CreateProfileCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct CreateProfileCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"create-profile\",\n abstract: \"Create a profile\"\n )\n\n @Argument(help: \"The name of the profile to create.\")\n var name: String\n\n @Flag(help: \"Copy the current profile\")\n var copy = false\n\n @Flag(help: \"Activate the new profile\")\n var activate = false\n\n func run() throws {\n sendCommand(.createProfile(name: name, copy: copy, activate: activate))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Get/GetAppCommand.swift", "//\n// GetAppCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport ArgumentParser\nimport Foundation\n\nstruct GetAppCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"get-app\",\n abstract: \"Get active app\"\n )\n\n @Flag(help: \"Include windows count\")\n var withWindowsCount = false\n\n func run() throws {\n sendCommand(.getApp(withWindowsCount: withWindowsCount))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/App/FocusCommand.swift", "//\n// FocusCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct FocusCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"focus\",\n abstract: \"Focus window\"\n )\n\n @Option(\n name: .customLong(\"direction\"),\n help: .init(\"Focus a window in a specific direction\", valueName: \"up|down|left|right\")\n )\n var focusDirection: FocusDirection?\n\n @Flag(help: \"Focus the next workspace app\")\n var nextApp = false\n\n @Flag(help: \"Focus the previous workspace app\")\n var prevApp = false\n\n @Flag(help: \"Focus the next workspace window\")\n var nextWindow = false\n\n @Flag(help: \"Focus the previous workspace window\")\n var prevWindow = false\n\n func run() throws {\n if let focusDirection {\n sendCommand(.focusWindow(direction: focusDirection))\n } else if nextApp {\n sendCommand(.focusNextApp)\n } else if prevApp {\n sendCommand(.focusPreviousApp)\n } else if nextWindow {\n sendCommand(.focusNextWindow)\n } else if prevWindow {\n sendCommand(.focusPreviousWindow)\n } else {\n fallbackToHelp()\n }\n\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/App/UnassignAppCommand.swift", "//\n// UnassignAppCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct UnassignAppCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"unassign-app\",\n abstract: \"Unassign an app from all workspaces\"\n )\n @Option(help: .init(\n \"The name of the app or bundle id. If not provided, the active app will be unassigned. Default: active app.\",\n valueName: \"name|bundle id\"\n ))\n var name: String?\n\n @Flag(help: \"Show toast notification\")\n var showNotification = false\n\n func run() throws {\n sendCommand(.unassignApp(app: name, showNotification: showNotification))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Workspace/UpdateWorkspaceCommand.swift", "//\n// UpdateWorkspaceCommand.swift\n//\n// Created by Wojciech Kulik on 02/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport ArgumentParser\nimport Foundation\n\nstruct UpdateWorkspaceRequest: Codable {\n enum Display: Codable {\n case active\n case name(String)\n }\n\n let name: String?\n let display: Display?\n}\n\nstruct UpdateWorkspaceCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"update-workspace\",\n abstract: \"Update a workspace\"\n )\n\n @Option(help: \"The name of the workspace to update.\")\n var workspace: String?\n\n @Flag(help: \"Update active workspace.\")\n var activeWorkspace = false\n\n @Option(help: \"The name of the display to be assigned.\")\n var display: String?\n\n @Flag(help: \"Assign active display.\")\n var activeDisplay = false\n\n func run() throws {\n if let display {\n sendCommand(.updateWorkspace(.init(name: workspace, display: .name(display))))\n } else if activeDisplay {\n sendCommand(.updateWorkspace(.init(name: workspace, display: .active)))\n } else {\n throw CommandError.operationFailed(\"Invalid command\")\n }\n\n runWithTimeout()\n }\n\n func validate() throws {\n if workspace != nil, activeWorkspace {\n throw CommandError.operationFailed(\"You cannot provide both a workspace name and use the --active-workspace flag\")\n }\n\n if display != nil, activeDisplay {\n throw CommandError.operationFailed(\"You cannot provide both a display name and use the --active-display flag\")\n }\n\n if workspace == nil, !activeWorkspace {\n throw CommandError.operationFailed(\"You must provide either a workspace name or use the --active-workspace flag\")\n }\n\n if display == nil, !activeDisplay {\n throw CommandError.operationFailed(\"You must provide either a display name or use the --active-display flag\")\n }\n\n if let display, !NSScreen.screens.contains(where: { $0.localizedName == display }) {\n throw CommandError.operationFailed(\"Display \\\"\\(display)\\\" not found\")\n }\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Get/GetWorkspaceCommand.swift", "//\n// GetWorkspaceCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport ArgumentParser\nimport Foundation\n\nstruct GetWorkspaceCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"get-workspace\",\n abstract: \"Get active workspace\"\n )\n\n @Option(help: \"Display name\")\n var display: String?\n\n func run() throws {\n sendCommand(.getWorkspace(display: display))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Profile/DeleteProfileCommand.swift", "//\n// DeleteProfileCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct DeleteProfileCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"delete-profile\",\n abstract: \"Delete a profile\"\n )\n\n @Argument(help: \"The name of the profile to delete.\")\n var name: String\n\n func run() throws {\n sendCommand(.deleteProfile(name: name))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Profile/ProfileCommand.swift", "//\n// ProfileCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct ProfileCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"profile\",\n abstract: \"Activate a profile\"\n )\n\n @Argument(help: \"Profile name.\")\n var name: String\n\n func run() throws {\n sendCommand(.activateProfile(name: name))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Workspace/DeleteWorkspaceCommand.swift", "//\n// DeleteWorkspaceCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct DeleteWorkspaceCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"delete-workspace\",\n abstract: \"Delete a workspace\"\n )\n\n @Argument(help: \"The name of the workspace to delete.\")\n var name: String\n\n func run() throws {\n sendCommand(.deleteWorkspace(name: name))\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/List/ListProfilesCommand.swift", "//\n// ListProfilesCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct ListProfilesCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"list-profiles\",\n abstract: \"List profiles\"\n )\n\n func run() throws {\n sendCommand(.listProfiles)\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Models/CommandRequest.swift", "//\n// CommandRequest.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nenum CommandRequest: Codable {\n case createWorkspace(CreateWorkspaceRequest)\n case deleteWorkspace(name: String)\n case updateWorkspace(UpdateWorkspaceRequest)\n case activateWorkspace(name: String?, number: Int?, clean: Bool)\n case nextWorkspace(skipEmpty: Bool, clean: Bool, loop: Bool)\n case previousWorkspace(skipEmpty: Bool, clean: Bool, loop: Bool)\n case hideUnassignedApps\n case recentWorkspace(clean: Bool)\n\n case assignVisibleApps(workspaceName: String?, showNotification: Bool)\n case assignApp(app: String?, workspaceName: String?, activate: Bool?, showNotification: Bool)\n case unassignApp(app: String?, showNotification: Bool)\n\n case floatApp(app: String?, showNotification: Bool)\n case unfloatApp(app: String?, showNotification: Bool)\n case toggleFloatApp(app: String?, showNotification: Bool)\n\n case focusWindow(direction: FocusDirection)\n case focusNextWindow\n case focusPreviousWindow\n case focusNextApp\n case focusPreviousApp\n\n case createProfile(name: String, copy: Bool, activate: Bool)\n case deleteProfile(name: String)\n case activateProfile(name: String)\n\n case openSpaceControl\n\n case listProfiles\n case listWorkspaces(withDisplay: Bool, profile: String?)\n case listApps(\n workspace: String,\n profile: String?,\n withBundleId: Bool,\n withIcon: Bool,\n onlyRunning: Bool\n )\n case listFloatingApps(withBundleId: Bool)\n\n case getProfile\n case getWorkspace(display: String?)\n case getApp(withWindowsCount: Bool)\n case getDisplay\n}\n\nenum FocusDirection: String, Codable, ExpressibleByArgument, CaseIterable {\n case left, right, up, down\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/FlashSpaceCLI.swift", "//\n// FlashSpaceCLI.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\n@main\nstruct FlashSpaceCLI: ParsableCommand {\n static let configuration: CommandConfiguration = .init(\n commandName: \"flashspace\",\n abstract: \"FlashSpace CLI\",\n version: \"1.0.0\",\n groupedSubcommands: [\n .init(\n name: \"Profile\",\n subcommands: [\n CreateProfileCommand.self,\n DeleteProfileCommand.self,\n ProfileCommand.self\n ]\n ),\n .init(\n name: \"Workspace\",\n subcommands: [\n CreateWorkspaceCommand.self,\n DeleteWorkspaceCommand.self,\n UpdateWorkspaceCommand.self,\n WorkspaceCommand.self\n ]\n ),\n .init(\n name: \"App\",\n subcommands: [\n AssignVisibleAppsCommand.self,\n AssignAppCommand.self,\n UnassignAppCommand.self,\n HideUnassignedAppsCommand.self,\n FocusCommand.self,\n FloatingAppsCommand.self\n ]\n ),\n .init(\n name: \"List\",\n subcommands: [\n ListProfilesCommand.self,\n ListWorkspacesCommand.self,\n ListAppsCommand.self,\n ListFloatingAppsCommand.self,\n ListRunningAppsCommand.self,\n ListDisplaysCommand.self\n ]\n ),\n .init(\n name: \"Get\",\n subcommands: [\n GetProfileCommand.self,\n GetWorkspaceCommand.self,\n GetAppCommand.self,\n GetDisplayCommand.self\n ]\n ),\n .init(\n name: \"Open\",\n subcommands: [\n OpenAppCommand.self,\n OpenSpaceControlCommand.self\n ]\n )\n ]\n )\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Models/CommandRequest.swift", "//\n// CommandRequest.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nenum CommandRequest: Codable {\n case createWorkspace(CreateWorkspaceRequest)\n case deleteWorkspace(name: String)\n case updateWorkspace(UpdateWorkspaceRequest)\n case activateWorkspace(name: String?, number: Int?, clean: Bool)\n case nextWorkspace(skipEmpty: Bool, clean: Bool, loop: Bool)\n case previousWorkspace(skipEmpty: Bool, clean: Bool, loop: Bool)\n case recentWorkspace(clean: Bool)\n\n case assignVisibleApps(workspaceName: String?, showNotification: Bool)\n case assignApp(app: String?, workspaceName: String?, activate: Bool?, showNotification: Bool)\n case unassignApp(app: String?, showNotification: Bool)\n case hideUnassignedApps\n\n case floatApp(app: String?, showNotification: Bool)\n case unfloatApp(app: String?, showNotification: Bool)\n case toggleFloatApp(app: String?, showNotification: Bool)\n\n case focusWindow(direction: FocusDirection)\n case focusNextWindow\n case focusPreviousWindow\n case focusNextApp\n case focusPreviousApp\n\n case createProfile(name: String, copy: Bool, activate: Bool)\n case deleteProfile(name: String)\n case activateProfile(name: String)\n\n case openSpaceControl\n\n case listProfiles\n case listWorkspaces(withDisplay: Bool, profile: String?)\n case listApps(\n workspace: String,\n profile: String?,\n withBundleId: Bool,\n withIcon: Bool,\n onlyRunning: Bool\n )\n case listFloatingApps(withBundleId: Bool)\n\n case getProfile\n case getWorkspace(display: String?)\n case getApp(withWindowsCount: Bool)\n case getDisplay\n}\n\nenum FocusDirection: String, Codable {\n case left, right, up, down\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/App/HideUnassignedAppsCommand.swift", "//\n// HideUnassignedAppsCommand.swift\n//\n// Created by Wojciech Kulik on 07/05/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct HideUnassignedAppsCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"hide-unassigned-apps\",\n abstract: \"Hide all unassigned apps\"\n )\n\n func run() throws {\n sendCommand(.hideUnassignedApps)\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Commands/AppCommands.swift", "//\n// AppCommands.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\n\nfinal class AppCommands: CommandExecutor {\n var workspaceManager: WorkspaceManager { AppDependencies.shared.workspaceManager }\n var workspaceRepository: WorkspaceRepository { AppDependencies.shared.workspaceRepository }\n var settings: WorkspaceSettings { AppDependencies.shared.workspaceSettings }\n var floatingAppsSettings: FloatingAppsSettings { AppDependencies.shared.floatingAppsSettings }\n\n func execute(command: CommandRequest) -> CommandResponse? {\n switch command {\n case .assignVisibleApps(let workspaceName, let showNotification):\n return assignVisibleApps(workspaceName: workspaceName, showNotification: showNotification)\n\n case .assignApp(let app, let workspaceName, let activate, let showNotification):\n return assignApp(\n app: app,\n workspaceName: workspaceName,\n activate: activate,\n showNotification: showNotification\n )\n\n case .unassignApp(let app, let showNotification):\n return unassignApp(app: app, showNotification: showNotification)\n\n case .hideUnassignedApps:\n workspaceManager.hideUnassignedApps()\n return CommandResponse(success: true)\n\n case .floatApp(let app, let showNotification):\n return floatApp(app: app, showNotification: showNotification)\n\n case .unfloatApp(let app, let showNotification):\n return unfloatApp(app: app, showNotification: showNotification)\n\n case .toggleFloatApp(let app, let showNotification):\n return toggleFloatApp(app: app, showNotification: showNotification)\n\n default:\n return nil\n }\n }\n\n private func findApp(app: String?) -> MacApp? {\n guard let app else { return NSWorkspace.shared.frontmostApplication?.toMacApp }\n\n let foundApp = NSWorkspace.shared.runningApplications\n .first { $0.localizedName == app }?\n .toMacApp\n\n if foundApp == nil, let appUrl = NSWorkspace.shared.urlForApplication(withBundleIdentifier: app) {\n return MacApp(\n name: appUrl.bundle?.localizedAppName ?? \"\",\n bundleIdentifier: app,\n iconPath: appUrl.iconPath\n )\n }\n\n return foundApp\n }\n\n private func unassignApp(app: String?, showNotification: Bool) -> CommandResponse {\n guard let app = findApp(app: app) else {\n return CommandResponse(\n success: false,\n error: \"App not found or not running. For not running apps use `unassign-app --name `.\"\n )\n }\n\n workspaceRepository.deleteAppFromAllWorkspaces(app: app)\n NSWorkspace.shared.runningApplications.find(app)?.hide()\n NotificationCenter.default.post(name: .appsListChanged, object: nil)\n\n if showNotification {\n Toast.showWith(\n icon: \"square.stack.3d.up.slash\",\n message: \"\\(app.name) - Removed From Workspaces\",\n textColor: .negative\n )\n }\n\n return CommandResponse(success: true)\n }\n\n private func assignVisibleApps(workspaceName: String?, showNotification: Bool) -> CommandResponse {\n guard let workspaceName = workspaceName ?? workspaceManager.activeWorkspaceDetails?.name else {\n return CommandResponse(success: false, error: \"No workspace selected\")\n }\n\n guard let workspace = workspaceRepository.workspaces.first(where: { $0.name == workspaceName }) else {\n return CommandResponse(success: false, error: \"Workspace not found\")\n }\n\n let visibleApps = NSWorkspace.shared.runningApplications\n .regularVisibleApps(onDisplays: workspace.displays, excluding: floatingAppsSettings.floatingApps)\n\n guard !visibleApps.isEmpty else {\n return CommandResponse(\n success: false,\n error: \"No visible apps found on the current display\"\n )\n }\n\n workspaceManager.assignApps(visibleApps.map(\\.toMacApp), to: workspace)\n\n if showNotification {\n Toast.showWith(\n icon: \"square.stack.3d.up\",\n message: \"Assigned \\(visibleApps.count) Apps(s) To \\(workspace.name)\",\n textColor: .positive\n )\n }\n\n return CommandResponse(success: true)\n }\n\n private func assignApp(\n app: String?,\n workspaceName: String?,\n activate: Bool?,\n showNotification: Bool\n ) -> CommandResponse {\n guard let workspaceName = workspaceName ?? workspaceManager.activeWorkspaceDetails?.name else {\n return CommandResponse(success: false, error: \"No workspace selected\")\n }\n\n guard let workspace = workspaceRepository.workspaces.first(where: { $0.name == workspaceName }) else {\n return CommandResponse(success: false, error: \"Workspace not found\")\n }\n\n guard let app = findApp(app: app) else {\n return CommandResponse(\n success: false,\n error: \"App not found or not running. For not running apps use `assign-app --name `.\"\n )\n }\n\n let previousSetting = settings.changeWorkspaceOnAppAssign\n if let activate {\n settings.changeWorkspaceOnAppAssign = activate\n }\n workspaceManager.assignApp(app, to: workspace)\n if activate != nil {\n settings.changeWorkspaceOnAppAssign = previousSetting\n }\n\n if showNotification {\n Toast.showWith(\n icon: \"square.stack.3d.up\",\n message: \"\\(app.name) - Assigned To \\(workspace.name)\",\n textColor: .positive\n )\n }\n\n return CommandResponse(success: true)\n }\n\n private func floatApp(app: String?, showNotification: Bool) -> CommandResponse {\n guard let app = findApp(app: app) else {\n return CommandResponse(\n success: false,\n error: \"App not found or not running. For not running apps use `float-app --name `.\"\n )\n }\n\n floatingAppsSettings.addFloatingAppIfNeeded(app: app)\n\n if showNotification {\n Toast.showWith(\n icon: \"macwindow.on.rectangle\",\n message: \"\\(app.name) - Added To Floating Apps\",\n textColor: .positive\n )\n }\n\n return CommandResponse(success: true)\n }\n\n private func unfloatApp(app: String?, showNotification: Bool) -> CommandResponse {\n guard let app = findApp(app: app) else {\n return CommandResponse(\n success: false,\n error: \"App not found or not running. For not running apps use `unfloat-app --name `.\"\n )\n }\n\n guard floatingAppsSettings.floatingApps.containsApp(with: app.bundleIdentifier) else {\n return CommandResponse(success: true)\n }\n\n floatingAppsSettings.deleteFloatingApp(app: app)\n\n if let runningApp = NSWorkspace.shared.runningApplications.find(app),\n let screen = runningApp.display,\n workspaceManager.activeWorkspace[screen]?.apps.containsApp(runningApp) != true {\n runningApp.hide()\n }\n\n if showNotification {\n Toast.showWith(\n icon: \"macwindow\",\n message: \"\\(app.name) - Removed From Floating Apps\",\n textColor: .negative\n )\n }\n\n return CommandResponse(success: true)\n }\n\n private func toggleFloatApp(app: String?, showNotification: Bool) -> CommandResponse {\n guard let macApp = findApp(app: app) else {\n return CommandResponse(\n success: false,\n error: \"App not found or not running. For not running apps use `toggle-float-app --name `.\"\n )\n }\n\n let isFloating = floatingAppsSettings.floatingApps.containsApp(with: macApp.bundleIdentifier)\n\n return isFloating\n ? unfloatApp(app: app, showNotification: showNotification)\n : floatApp(app: app, showNotification: showNotification)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/MainScreen/MainViewModel.swift", "//\n// MainViewModel.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Combine\nimport SwiftUI\n\nfinal class MainViewModel: ObservableObject {\n @Published var workspaces: [Workspace] = [] {\n didSet {\n guard workspaces.count == oldValue.count,\n workspaces.map(\\.id) != oldValue.map(\\.id) else { return }\n\n workspaceRepository.reorderWorkspaces(newOrder: workspaces.map(\\.id))\n }\n }\n\n @Published var workspaceApps: [MacApp]?\n\n @Published var workspaceName = \"\"\n @Published var workspaceShortcut: AppHotKey? {\n didSet { saveWorkspace() }\n }\n\n @Published var workspaceAssignShortcut: AppHotKey? {\n didSet { saveWorkspace() }\n }\n\n @Published var workspaceDisplay = \"\" {\n didSet { saveWorkspace() }\n }\n\n @Published var workspaceAppToFocus: MacApp? = AppConstants.lastFocusedOption {\n didSet { saveWorkspace() }\n }\n\n @Published var workspaceSymbolIconName: String? {\n didSet { saveWorkspace() }\n }\n\n @Published var isSymbolPickerPresented = false\n @Published var isInputDialogPresented = false\n @Published var userInput = \"\"\n\n var focusAppOptions: [MacApp] {\n [AppConstants.lastFocusedOption] + (workspaceApps ?? [])\n }\n\n var selectedApps: Set = [] {\n didSet {\n // To avoid warnings\n DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) { [self] in\n objectWillChange.send()\n }\n }\n }\n\n var selectedWorkspaces: Set = [] {\n didSet {\n selectedWorkspace = selectedWorkspaces.count == 1\n ? selectedWorkspaces.first\n : nil\n\n // To avoid warnings\n DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) { [self] in\n if selectedWorkspaces.count == 1,\n selectedWorkspaces.first?.id != oldValue.first?.id {\n selectedApps = []\n } else if selectedWorkspaces.count != 1 {\n selectedApps = []\n }\n objectWillChange.send()\n }\n }\n }\n\n private(set) var selectedWorkspace: Workspace? {\n didSet {\n guard selectedWorkspace != oldValue else { return }\n\n // To avoid warnings\n DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) {\n self.updateSelectedWorkspace()\n }\n }\n }\n\n var screens: [String] {\n let set = NSScreen.screens.compactMap(\\.localizedName).asSet\n let otherScreens = workspaces.map(\\.display)\n\n return Array(set.union(otherScreens))\n .filter(\\.isNotEmpty)\n .sorted()\n }\n\n var displayMode: DisplayMode { workspaceSettings.displayMode }\n\n private var cancellables: Set = []\n private var loadingWorkspace = false\n\n private let workspaceManager = AppDependencies.shared.workspaceManager\n private let workspaceRepository = AppDependencies.shared.workspaceRepository\n private let workspaceSettings = AppDependencies.shared.workspaceSettings\n\n init() {\n self.workspaces = workspaceRepository.workspaces\n self.workspaceDisplay = NSScreen.main?.localizedName ?? \"\"\n\n observe()\n }\n\n private func observe() {\n NotificationCenter.default\n .publisher(for: .appsListChanged)\n .sink { [weak self] _ in self?.reloadWorkspaces() }\n .store(in: &cancellables)\n\n NotificationCenter.default\n .publisher(for: .profileChanged)\n .sink { [weak self] _ in self?.reloadWorkspaces() }\n .store(in: &cancellables)\n\n workspaceSettings.updatePublisher\n .compactMap { [weak self] in self?.workspaceSettings.displayMode }\n .removeDuplicates()\n .sink { [weak self] _ in self?.objectWillChange.send() }\n .store(in: &cancellables)\n }\n\n private func updateSelectedWorkspace() {\n loadingWorkspace = true\n defer { loadingWorkspace = false }\n\n workspaceName = selectedWorkspace?.name ?? \"\"\n workspaceShortcut = selectedWorkspace?.activateShortcut\n workspaceAssignShortcut = selectedWorkspace?.assignAppShortcut\n workspaceDisplay = selectedWorkspace?.display ?? NSScreen.main?.localizedName ?? \"\"\n workspaceApps = selectedWorkspace?.apps\n workspaceAppToFocus = selectedWorkspace?.appToFocus ?? AppConstants.lastFocusedOption\n workspaceSymbolIconName = selectedWorkspace?.symbolIconName\n selectedWorkspace.flatMap { selectedWorkspaces = [$0] }\n }\n\n private func reloadWorkspaces() {\n workspaces = workspaceRepository.workspaces\n if let selectedWorkspace, let workspace = workspaces.first(where: { $0.id == selectedWorkspace.id }) {\n selectedWorkspaces = [workspace]\n } else {\n selectedWorkspaces = []\n }\n selectedApps = []\n }\n}\n\nextension MainViewModel {\n func saveWorkspace() {\n guard let selectedWorkspace, !loadingWorkspace else { return }\n\n if workspaceName.trimmingCharacters(in: .whitespaces).isEmpty {\n workspaceName = \"(empty)\"\n }\n\n let updatedWorkspace = Workspace(\n id: selectedWorkspace.id,\n name: workspaceName,\n display: workspaceDisplay,\n activateShortcut: workspaceShortcut,\n assignAppShortcut: workspaceAssignShortcut,\n apps: selectedWorkspace.apps,\n appToFocus: workspaceAppToFocus == AppConstants.lastFocusedOption ? nil : workspaceAppToFocus,\n symbolIconName: workspaceSymbolIconName\n )\n\n workspaceRepository.updateWorkspace(updatedWorkspace)\n workspaces = workspaceRepository.workspaces\n self.selectedWorkspace = workspaces.first { $0.id == selectedWorkspace.id }\n }\n\n func addWorkspace() {\n userInput = \"\"\n isInputDialogPresented = true\n\n $isInputDialogPresented\n .first { !$0 }\n .sink { [weak self] _ in\n guard let self, !self.userInput.isEmpty else { return }\n\n self.workspaceRepository.addWorkspace(name: self.userInput)\n self.workspaces = self.workspaceRepository.workspaces\n self.selectedWorkspace = self.workspaces.last\n }\n .store(in: &cancellables)\n }\n\n func deleteSelectedWorkspaces() {\n guard !selectedWorkspaces.isEmpty else { return }\n\n workspaceRepository.deleteWorkspaces(ids: selectedWorkspaces.map(\\.id).asSet)\n workspaces = workspaceRepository.workspaces\n selectedWorkspaces = []\n }\n\n func addApp() {\n guard let selectedWorkspace else { return }\n\n let fileChooser = FileChooser()\n let appUrl = fileChooser.runModalOpenPanel(\n allowedFileTypes: [.application],\n directoryURL: URL(filePath: \"/Applications\")\n )\n\n guard let appUrl else { return }\n\n let appName = appUrl.appName\n let appBundleId = appUrl.bundleIdentifier ?? \"\"\n let runningApp = NSWorkspace.shared.runningApplications.first { $0.bundleIdentifier == appBundleId }\n let isAgent = appUrl.bundle?.isAgent == true && (runningApp == nil || runningApp?.activationPolicy != .regular)\n\n guard !isAgent else {\n Alert.showOkAlert(\n title: appName,\n message: \"This application is an agent (runs in background) and cannot be managed by FlashSpace.\"\n )\n return\n }\n\n guard !selectedWorkspace.apps.containsApp(with: appBundleId) else { return }\n\n workspaceRepository.addApp(\n to: selectedWorkspace.id,\n app: .init(\n name: appName,\n bundleIdentifier: appBundleId,\n iconPath: appUrl.iconPath\n )\n )\n\n workspaces = workspaceRepository.workspaces\n self.selectedWorkspace = workspaces.first { $0.id == selectedWorkspace.id }\n\n workspaceManager.activateWorkspaceIfActive(selectedWorkspace.id)\n }\n\n func deleteSelectedApps() {\n guard let selectedWorkspace, !selectedApps.isEmpty else { return }\n\n let selectedApps = Array(selectedApps)\n\n for app in selectedApps {\n workspaceRepository.deleteApp(\n from: selectedWorkspace.id,\n app: app,\n notify: app == selectedApps.last\n )\n }\n\n workspaces = workspaceRepository.workspaces\n self.selectedWorkspace = workspaces.first { $0.id == selectedWorkspace.id }\n workspaceApps = self.selectedWorkspace?.apps\n self.selectedApps = []\n\n workspaceManager.activateWorkspaceIfActive(selectedWorkspace.id)\n }\n\n func resetWorkspaceSymbolIcon() {\n workspaceSymbolIconName = nil\n saveWorkspace()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Get/GetProfileCommand.swift", "//\n// GetProfileCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport ArgumentParser\nimport Foundation\n\nstruct GetProfileCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"get-profile\",\n abstract: \"Get active profile\"\n )\n\n func run() throws {\n sendCommand(.getProfile)\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Open/OpenAppCommand.swift", "//\n// OpenAppCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport ArgumentParser\nimport Foundation\n\nstruct OpenAppCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"open\",\n abstract: \"Open FlashSpace\"\n )\n\n func run() throws {\n let url = NSWorkspace.shared.urlForApplication(withBundleIdentifier: \"pl.wojciechkulik.FlashSpace.dev\")\n ?? NSWorkspace.shared.urlForApplication(withBundleIdentifier: \"pl.wojciechkulik.FlashSpace\")\n\n if let url {\n let config = NSWorkspace.OpenConfiguration()\n config.activates = true\n NSWorkspace.shared.openApplication(at: url, configuration: config) { _, error in\n if let error {\n Self.exit(withError: CommandError.operationFailed(\"Failed to open FlashSpace: \\(error.localizedDescription)\"))\n } else {\n Self.exit()\n }\n }\n runWithTimeout()\n } else {\n throw CommandError.operationFailed(\"FlashSpace is not installed.\")\n }\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/List/ListDisplays.swift", "//\n// ListDisplays.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport ArgumentParser\nimport Foundation\n\nstruct ListDisplaysCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"list-displays\",\n abstract: \"List displays\"\n )\n\n func run() throws {\n for screen in NSScreen.screens {\n print(screen.localizedName)\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/MenuBar/FlashSpaceMenuBar.swift", "//\n// FlashSpaceMenuBar.swift\n//\n// Created by Wojciech Kulik on 13/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct FlashSpaceMenuBar: Scene {\n @Environment(\\.openWindow) private var openWindow\n\n @StateObject private var workspaceManager = AppDependencies.shared.workspaceManager\n @StateObject private var settingsRepository = AppDependencies.shared.settingsRepository\n @StateObject private var profilesRepository = AppDependencies.shared.profilesRepository\n @StateObject private var workspaceRepository = AppDependencies.shared.workspaceRepository\n\n var body: some Scene {\n MenuBarExtra {\n Text(\"FlashSpace v\\(AppConstants.version)\")\n\n Button(\"Open\") {\n openWindow(id: \"main\")\n NSApp.activate(ignoringOtherApps: true)\n }\n\n if settingsRepository.spaceControlSettings.enableSpaceControl {\n Button(\"Space Control\") {\n SpaceControl.show()\n }\n }\n\n Divider()\n\n Button(\"Settings\") {\n openWindow(id: \"settings\")\n NSApp.activate(ignoringOtherApps: true)\n }.keyboardShortcut(\",\")\n\n Menu(\"Profiles\") {\n ForEach(profilesRepository.profiles) { profile in\n Toggle(\n profile.name,\n isOn: .init(\n get: { profilesRepository.selectedProfile == profile },\n set: {\n if $0 { profilesRepository.selectedProfile = profile }\n }\n )\n )\n }\n }.hidden(profilesRepository.profiles.count < 2)\n\n Menu(\"Workspaces\") {\n ForEach(workspaceRepository.workspaces) { workspace in\n Button {\n if workspace.isDynamic, workspace.displays.isEmpty {\n Toast.showWith(\n icon: \"square.stack.3d.up\",\n message: \"\\(workspace.name) - No Running Apps To Show\",\n textColor: .gray\n )\n } else {\n workspaceManager.activateWorkspace(workspace, setFocus: true)\n }\n } label: {\n Text(workspace.name)\n }\n .keyboardShortcut(workspace.activateShortcut?.toKeyboardShortcut)\n }\n }.hidden(workspaceRepository.workspaces.count < 2)\n\n Divider()\n\n Button(\"Donate\") {\n if let url = URL(string: \"https://github.com/sponsors/wojciech-kulik\") {\n NSWorkspace.shared.open(url)\n }\n }\n\n Button(\"Project Website\") {\n if let url = URL(string: \"https://github.com/wojciech-kulik/FlashSpace\") {\n NSWorkspace.shared.open(url)\n }\n }\n\n Button(\"Check for Updates\") {\n UpdatesManager.shared.checkForUpdates()\n }\n\n Divider()\n\n Button(\"Quit\") {\n NSApp.terminate(nil)\n }.keyboardShortcut(\"q\")\n } label: {\n HStack {\n let title = MenuBarTitle.get()\n if title == nil || settingsRepository.menuBarSettings.showMenuBarIcon {\n Image(systemName: workspaceManager.activeWorkspaceDetails?.symbolIconName ?? .defaultIconSymbol)\n }\n if let title { Text(title) }\n }\n .id(settingsRepository.menuBarSettings.menuBarTitleTemplate)\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/MainScreen/MainView.swift", "//\n// MainView.swift\n// FlashSpace\n//\n// Created by Wojciech Kulik on 19/01/2025.\n//\n\nimport AppKit\nimport SwiftUI\nimport SymbolPicker\n\nstruct MainView: View {\n @StateObject var viewModel = MainViewModel()\n\n var body: some View {\n HStack(spacing: 16.0) {\n workspaces\n assignedApps\n WorkspaceConfigurationView(viewModel: viewModel)\n .frame(maxWidth: 230)\n }\n .padding()\n .fixedSize()\n .sheet(isPresented: $viewModel.isInputDialogPresented) {\n InputDialog(\n title: \"Enter workspace name:\",\n userInput: $viewModel.userInput,\n isPresented: $viewModel.isInputDialogPresented\n )\n }\n .sheet(isPresented: $viewModel.isSymbolPickerPresented) {\n SymbolPicker(symbol: $viewModel.workspaceSymbolIconName)\n }\n }\n\n private var workspaces: some View {\n VStack(alignment: .leading) {\n Text(\"Workspaces:\")\n\n List(\n $viewModel.workspaces,\n id: \\.self,\n editActions: .move,\n selection: $viewModel.selectedWorkspaces\n ) { binding in\n WorkspaceCell(\n selectedApps: $viewModel.selectedApps,\n workspace: binding.wrappedValue\n )\n }\n .frame(width: 200, height: 350)\n\n HStack {\n Button(action: viewModel.addWorkspace) {\n Image(systemName: \"plus\")\n }\n\n Button(action: viewModel.deleteSelectedWorkspaces) {\n Image(systemName: \"trash\")\n }.disabled(viewModel.selectedWorkspaces.isEmpty)\n\n Spacer()\n }\n }\n }\n\n private var assignedApps: some View {\n VStack(alignment: .leading) {\n Text(\"Assigned Apps:\")\n\n List(\n viewModel.workspaceApps ?? [],\n id: \\.self,\n selection: $viewModel.selectedApps\n ) { app in\n AppCell(\n workspaceId: viewModel.selectedWorkspace?.id ?? UUID(),\n app: app\n )\n }\n .frame(width: 200, height: 350)\n\n HStack {\n Button(action: viewModel.addApp) {\n Image(systemName: \"plus\")\n }.disabled(viewModel.selectedWorkspace == nil)\n\n Button(action: viewModel.deleteSelectedApps) {\n Image(systemName: \"trash\")\n }\n .disabled(viewModel.selectedApps.isEmpty)\n .keyboardShortcut(.delete)\n }\n }\n }\n}\n\n#Preview {\n MainView()\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Get/GetDisplayCommand.swift", "//\n// GetDisplayCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport ArgumentParser\nimport Foundation\n\nstruct GetDisplayCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"get-display\",\n abstract: \"Get active display\"\n )\n\n func run() throws {\n sendCommand(.getDisplay)\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Subcommands/Open/OpenSpaceControlCommand.swift", "//\n// OpenSpaceControlCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nstruct OpenSpaceControlCommand: ParsableCommand {\n static var configuration = CommandConfiguration(\n commandName: \"open-space-control\",\n abstract: \"Open Space Control\"\n )\n\n func run() throws {\n sendCommand(.openSpaceControl)\n runWithTimeout()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/MainScreen/WorkspaceCell.swift", "//\n// WorkspaceCell.swift\n//\n// Created by Wojciech Kulik on 20/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\nimport UniformTypeIdentifiers\n\nstruct WorkspaceCell: View {\n @State var isTargeted = false\n @Binding var selectedApps: Set\n\n let workspaceManager: WorkspaceManager = AppDependencies.shared.workspaceManager\n let workspaceRepository: WorkspaceRepository = AppDependencies.shared.workspaceRepository\n\n let workspace: Workspace\n\n var body: some View {\n HStack {\n Image(systemName: workspace.symbolIconName ?? .defaultIconSymbol)\n .resizable()\n .scaledToFit()\n .frame(width: 15, height: 15)\n .foregroundStyle(Color.workspaceIcon)\n\n Text(workspace.name)\n .lineLimit(1)\n .foregroundColor(\n isTargeted || workspace.apps.contains(where: \\.bundleIdentifier.isEmpty)\n ? .errorRed\n : .primary\n )\n Spacer()\n }\n .contentShape(Rectangle())\n .dropDestination(for: MacAppWithWorkspace.self) { apps, _ in\n guard let sourceWorkspaceId = apps.first?.workspaceId else { return false }\n\n workspaceRepository.moveApps(\n apps.map(\\.app),\n from: sourceWorkspaceId,\n to: workspace.id\n )\n selectedApps = []\n\n workspaceManager.activateWorkspaceIfActive(sourceWorkspaceId)\n workspaceManager.activateWorkspaceIfActive(workspace.id)\n\n return true\n } isTargeted: {\n isTargeted = $0\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Workspaces/WorkspaceManager.swift", "//\n// WorkspaceManager.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Combine\n\ntypealias DisplayName = String\n\nstruct ActiveWorkspace {\n let id: WorkspaceID\n let name: String\n let number: String?\n let symbolIconName: String?\n let display: DisplayName\n}\n\nfinal class WorkspaceManager: ObservableObject {\n @Published private(set) var activeWorkspaceDetails: ActiveWorkspace?\n\n private(set) var lastFocusedApp: [WorkspaceID: MacApp] = [:]\n private(set) var activeWorkspace: [DisplayName: Workspace] = [:]\n private(set) var mostRecentWorkspace: [DisplayName: Workspace] = [:]\n private(set) var lastWorkspaceActivation = Date.distantPast\n\n private var cancellables = Set()\n private var observeFocusCancellable: AnyCancellable?\n private var appsHiddenManually: [WorkspaceID: [MacApp]] = [:]\n private let hideAgainSubject = PassthroughSubject()\n\n private let workspaceRepository: WorkspaceRepository\n private let workspaceSettings: WorkspaceSettings\n private let floatingAppsSettings: FloatingAppsSettings\n private let pictureInPictureManager: PictureInPictureManager\n private let workspaceTransitionManager: WorkspaceTransitionManager\n private let displayManager: DisplayManager\n\n init(\n workspaceRepository: WorkspaceRepository,\n settingsRepository: SettingsRepository,\n pictureInPictureManager: PictureInPictureManager,\n workspaceTransitionManager: WorkspaceTransitionManager,\n displayManager: DisplayManager\n ) {\n self.workspaceRepository = workspaceRepository\n self.workspaceSettings = settingsRepository.workspaceSettings\n self.floatingAppsSettings = settingsRepository.floatingAppsSettings\n self.pictureInPictureManager = pictureInPictureManager\n self.workspaceTransitionManager = workspaceTransitionManager\n self.displayManager = displayManager\n\n PermissionsManager.shared.askForAccessibilityPermissions()\n observe()\n }\n\n private func observe() {\n hideAgainSubject\n .debounce(for: 0.2, scheduler: RunLoop.main)\n .sink { [weak self] in self?.hideApps(in: $0) }\n .store(in: &cancellables)\n\n NotificationCenter.default\n .publisher(for: .profileChanged)\n .sink { [weak self] _ in\n self?.lastFocusedApp = [:]\n self?.activeWorkspace = [:]\n self?.mostRecentWorkspace = [:]\n self?.activeWorkspaceDetails = nil\n }\n .store(in: &cancellables)\n\n NotificationCenter.default\n .publisher(for: NSApplication.didChangeScreenParametersNotification)\n .sink { [weak self] _ in\n self?.activeWorkspace = [:]\n self?.mostRecentWorkspace = [:]\n self?.activeWorkspaceDetails = nil\n }\n .store(in: &cancellables)\n\n observeFocus()\n }\n\n private func observeFocus() {\n observeFocusCancellable = NSWorkspace.shared.notificationCenter\n .publisher(for: NSWorkspace.didActivateApplicationNotification)\n .compactMap { $0.userInfo?[NSWorkspace.applicationUserInfoKey] as? NSRunningApplication }\n .sink { [weak self] application in\n self?.rememberLastFocusedApp(application, retry: true)\n }\n }\n\n private func rememberLastFocusedApp(_ application: NSRunningApplication, retry: Bool) {\n guard application.display != nil else {\n if retry {\n Logger.log(\"Retrying to get display for \\(application.localizedName ?? \"\")\")\n return DispatchQueue.main.asyncAfter(deadline: .now() + 0.6) {\n if let frontmostApp = NSWorkspace.shared.frontmostApplication {\n self.rememberLastFocusedApp(frontmostApp, retry: false)\n }\n }\n } else {\n return Logger.log(\"Unable to get display for \\(application.localizedName ?? \"\")\")\n }\n }\n\n let focusedDisplay = NSScreen.main?.localizedName ?? \"\"\n\n if let activeWorkspace = activeWorkspace[focusedDisplay], activeWorkspace.apps.containsApp(application) {\n lastFocusedApp[activeWorkspace.id] = application.toMacApp\n updateActiveWorkspace(activeWorkspace, on: [focusedDisplay])\n }\n\n displayManager.trackDisplayFocus(on: focusedDisplay, for: application)\n }\n\n private func showApps(in workspace: Workspace, setFocus: Bool, on displays: Set) {\n let regularApps = NSWorkspace.shared.runningApplications\n .filter { $0.activationPolicy == .regular }\n let floatingApps = floatingAppsSettings.floatingApps\n let hiddenApps = appsHiddenManually[workspace.id] ?? []\n var appsToShow = regularApps\n .filter { !hiddenApps.containsApp($0) }\n .filter {\n workspace.apps.containsApp($0) ||\n floatingApps.containsApp($0) && $0.isOnAnyDisplay(displays)\n }\n\n observeFocusCancellable = nil\n defer { observeFocus() }\n\n if setFocus {\n let toFocus = findAppToFocus(in: workspace, apps: appsToShow)\n\n // Make sure to raise the app that should be focused\n // as the last one\n if let toFocus {\n appsToShow.removeAll { $0 == toFocus }\n appsToShow.append(toFocus)\n }\n\n for app in appsToShow {\n Logger.log(\"SHOW: \\(app.localizedName ?? \"\")\")\n\n if app == toFocus || app.isHidden || app.isMinimized {\n app.raise()\n }\n\n pictureInPictureManager.showPipAppIfNeeded(app: app)\n }\n\n Logger.log(\"FOCUS: \\(toFocus?.localizedName ?? \"\")\")\n toFocus?.activate()\n centerCursorIfNeeded(in: toFocus?.frame)\n } else {\n for app in appsToShow {\n Logger.log(\"SHOW: \\(app.localizedName ?? \"\")\")\n app.raise()\n }\n }\n }\n\n private func hideApps(in workspace: Workspace) {\n let regularApps = NSWorkspace.shared.runningApplications\n .filter { $0.activationPolicy == .regular }\n let workspaceApps = workspace.apps + floatingAppsSettings.floatingApps\n let isAnyWorkspaceAppRunning = regularApps\n .contains { workspaceApps.containsApp($0) }\n let allAssignedApps = workspaceRepository.workspaces\n .flatMap(\\.apps)\n .map(\\.bundleIdentifier)\n .asSet\n let displays = workspace.displays\n\n let appsToHide = regularApps\n .filter {\n !$0.isHidden && !workspaceApps.containsApp($0) &&\n (!workspaceSettings.keepUnassignedAppsOnSwitch || allAssignedApps.contains($0.bundleIdentifier ?? \"\"))\n }\n .filter { isAnyWorkspaceAppRunning || $0.bundleURL?.fileName != \"Finder\" }\n .filter { $0.isOnAnyDisplay(displays) }\n\n for app in appsToHide {\n Logger.log(\"HIDE: \\(app.localizedName ?? \"\")\")\n\n if !pictureInPictureManager.hidePipAppIfNeeded(app: app) {\n app.hide()\n }\n }\n }\n\n private func findAppToFocus(\n in workspace: Workspace,\n apps: [NSRunningApplication]\n ) -> NSRunningApplication? {\n if workspace.appToFocus == nil {\n let displays = workspace.displays\n if let floatingEntry = displayManager.lastFocusedDisplay(where: {\n let isFloating = floatingAppsSettings.floatingApps.contains($0.app)\n let isUnassigned = workspaceSettings.keepUnassignedAppsOnSwitch &&\n !workspaceRepository.workspaces.flatMap(\\.apps).contains($0.app)\n return (isFloating || isUnassigned) && displays.contains($0.display)\n }),\n let runningApp = NSWorkspace.shared.runningApplications.find(floatingEntry.app) {\n return runningApp\n }\n }\n\n var appToFocus: NSRunningApplication?\n\n if workspace.appToFocus == nil {\n appToFocus = apps.find(lastFocusedApp[workspace.id])\n } else {\n appToFocus = apps.find(workspace.appToFocus)\n }\n\n let fallbackToLastApp = apps.findFirstMatch(with: workspace.apps.reversed())\n let fallbackToFinder = NSWorkspace.shared.runningApplications.first(where: \\.isFinder)\n\n return appToFocus ?? fallbackToLastApp ?? fallbackToFinder\n }\n\n private func centerCursorIfNeeded(in frame: CGRect?) {\n guard workspaceSettings.centerCursorOnWorkspaceChange, let frame else { return }\n\n CGWarpMouseCursorPosition(CGPoint(x: frame.midX, y: frame.midY))\n }\n\n private func updateActiveWorkspace(_ workspace: Workspace, on displays: Set) {\n lastWorkspaceActivation = Date()\n\n // Save the most recent workspace if it's not the current one\n for display in displays {\n if activeWorkspace[display]?.id != workspace.id {\n mostRecentWorkspace[display] = activeWorkspace[display]\n }\n activeWorkspace[display] = workspace\n }\n\n activeWorkspaceDetails = .init(\n id: workspace.id,\n name: workspace.name,\n number: workspaceRepository.workspaces\n .firstIndex { $0.id == workspace.id }\n .map { \"\\($0 + 1)\" },\n symbolIconName: workspace.symbolIconName,\n display: workspace.displayForPrint\n )\n\n Integrations.runOnActivateIfNeeded(workspace: activeWorkspaceDetails!)\n }\n\n private func rememberHiddenApps(workspaceToActivate: Workspace) {\n guard !workspaceSettings.restoreHiddenAppsOnSwitch else {\n appsHiddenManually = [:]\n return\n }\n\n let hiddenApps = NSWorkspace.shared.runningApplications\n .filter { $0.activationPolicy == .regular }\n .filter { $0.isHidden || $0.isMinimized }\n\n for activeWorkspace in activeWorkspace.values {\n guard activeWorkspace.id != workspaceToActivate.id else { continue }\n\n appsHiddenManually[activeWorkspace.id] = []\n }\n\n for (display, activeWorkspace) in activeWorkspace {\n guard activeWorkspace.id != workspaceToActivate.id else { continue }\n\n let activeWorkspaceOtherDisplays = activeWorkspace.displays.subtracting([display])\n appsHiddenManually[activeWorkspace.id, default: []] += hiddenApps\n .filter {\n activeWorkspace.apps.containsApp($0) &&\n $0.isOnAnyDisplay([display]) && !$0.isOnAnyDisplay(activeWorkspaceOtherDisplays)\n }\n .map(\\.toMacApp)\n }\n }\n}\n\n// MARK: - Workspace Actions\nextension WorkspaceManager {\n func activateWorkspace(_ workspace: Workspace, setFocus: Bool) {\n let displays = workspace.displays\n\n Logger.log(\"\")\n Logger.log(\"\")\n Logger.log(\"WORKSPACE: \\(workspace.name)\")\n Logger.log(\"DISPLAYS: \\(displays.joined(separator: \", \"))\")\n Logger.log(\"----\")\n SpaceControl.hide()\n\n guard displays.isNotEmpty else {\n Logger.log(\"No displays found for workspace: \\(workspace.name) - skipping\")\n return\n }\n\n workspaceTransitionManager.showTransitionIfNeeded(for: workspace, on: displays)\n\n rememberHiddenApps(workspaceToActivate: workspace)\n updateActiveWorkspace(workspace, on: displays)\n showApps(in: workspace, setFocus: setFocus, on: displays)\n hideApps(in: workspace)\n\n // Some apps may not hide properly,\n // so we hide apps in the workspace after a short delay\n hideAgainSubject.send(workspace)\n\n NotificationCenter.default.post(name: .workspaceChanged, object: workspace)\n }\n\n func assignApps(_ apps: [MacApp], to workspace: Workspace) {\n for app in apps {\n workspaceRepository.deleteAppFromAllWorkspaces(app: app)\n workspaceRepository.addApp(to: workspace.id, app: app)\n }\n\n NotificationCenter.default.post(name: .appsListChanged, object: nil)\n }\n\n func assignApp(_ app: MacApp, to workspace: Workspace) {\n workspaceRepository.deleteAppFromAllWorkspaces(app: app)\n workspaceRepository.addApp(to: workspace.id, app: app)\n\n guard let targetWorkspace = workspaceRepository.workspaces\n .first(where: { $0.id == workspace.id }) else { return }\n\n let isTargetWorkspaceActive = activeWorkspace.values\n .contains(where: { $0.id == workspace.id })\n\n updateLastFocusedApp(app, in: targetWorkspace)\n\n if workspaceSettings.changeWorkspaceOnAppAssign {\n activateWorkspace(targetWorkspace, setFocus: true)\n } else if !isTargetWorkspaceActive {\n NSWorkspace.shared.runningApplications\n .find(app)?\n .hide()\n AppDependencies.shared.focusManager.nextWorkspaceApp()\n }\n\n NotificationCenter.default.post(name: .appsListChanged, object: nil)\n }\n\n func hideUnassignedApps() {\n let activeWorkspace = workspaceRepository.workspaces\n .first(where: { $0.id == activeWorkspaceDetails?.id })\n\n guard let activeWorkspace else { return }\n\n let appsToHide = NSWorkspace.shared.runningApplications\n .regularVisibleApps(onDisplays: activeWorkspace.displays, excluding: activeWorkspace.apps)\n\n for app in appsToHide {\n Logger.log(\"CLEAN UP: \\(app.localizedName ?? \"\")\")\n\n if !pictureInPictureManager.hidePipAppIfNeeded(app: app) {\n app.hide()\n }\n }\n }\n\n func activateWorkspace(next: Bool, skipEmpty: Bool, loop: Bool) {\n guard let screen = displayManager.getCursorScreen() else { return }\n\n var screenWorkspaces = workspaceRepository.workspaces\n .filter { $0.displays.contains(screen) }\n\n if !next {\n screenWorkspaces = screenWorkspaces.reversed()\n }\n\n guard let activeWorkspace = activeWorkspace[screen] ?? screenWorkspaces.first else { return }\n\n let nextWorkspaces = screenWorkspaces\n .drop(while: { $0.id != activeWorkspace.id })\n .dropFirst()\n\n var selectedWorkspace = nextWorkspaces.first ?? (loop ? screenWorkspaces.first : nil)\n\n if skipEmpty {\n let runningApps = NSWorkspace.shared.runningApplications\n .filter { $0.activationPolicy == .regular }\n .compactMap(\\.bundleIdentifier)\n .asSet\n\n selectedWorkspace = (nextWorkspaces + (loop ? screenWorkspaces : []))\n .drop(while: { $0.apps.allSatisfy { !runningApps.contains($0.bundleIdentifier) } })\n .first\n }\n\n guard let selectedWorkspace, selectedWorkspace.id != activeWorkspace.id else { return }\n\n activateWorkspace(selectedWorkspace, setFocus: true)\n }\n\n func activateRecentWorkspace() {\n guard let screen = displayManager.getCursorScreen(),\n let mostRecentWorkspace = mostRecentWorkspace[screen]\n else { return }\n\n activateWorkspace(mostRecentWorkspace, setFocus: true)\n }\n\n func activateWorkspaceIfActive(_ workspaceId: WorkspaceID) {\n guard activeWorkspace.values.contains(where: { $0.id == workspaceId }) else { return }\n guard let updatedWorkspace = workspaceRepository.workspaces.first(where: { $0.id == workspaceId }) else { return }\n\n activateWorkspace(updatedWorkspace, setFocus: false)\n }\n\n func updateLastFocusedApp(_ app: MacApp, in workspace: Workspace) {\n lastFocusedApp[workspace.id] = app\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Commands/WorkspaceCommands.swift", "//\n// WorkspaceCommands.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\n\nfinal class WorkspaceCommands: CommandExecutor {\n var workspaceManager: WorkspaceManager { AppDependencies.shared.workspaceManager }\n var workspaceRepository: WorkspaceRepository { AppDependencies.shared.workspaceRepository }\n\n // swiftlint:disable:next cyclomatic_complexity function_body_length\n func execute(command: CommandRequest) -> CommandResponse? {\n switch command {\n case .activateWorkspace(.some(let name), _, let clean):\n let workspace = workspaceRepository.workspaces.first { $0.name == name }\n if let workspace {\n if workspace.isDynamic, workspace.displays.isEmpty {\n return CommandResponse(success: false, error: \"\\(workspace.name) - No Running Apps To Show\")\n }\n workspaceManager.activateWorkspace(workspace, setFocus: true)\n if clean { workspaceManager.hideUnassignedApps() }\n return CommandResponse(success: true)\n } else {\n return CommandResponse(success: false, error: \"Workspace not found\")\n }\n\n case .activateWorkspace(_, .some(let number), let clean):\n let workspace = workspaceRepository.workspaces[safe: number - 1]\n if let workspace {\n if workspace.isDynamic, workspace.displays.isEmpty {\n return CommandResponse(success: false, error: \"\\(workspace.name) - No Running Apps To Show\")\n }\n workspaceManager.activateWorkspace(workspace, setFocus: true)\n if clean { workspaceManager.hideUnassignedApps() }\n return CommandResponse(success: true)\n } else {\n return CommandResponse(success: false, error: \"Workspace not found\")\n }\n\n case .updateWorkspace(let request):\n return updateWorkspace(request)\n\n case .nextWorkspace(let skipEmpty, let clean, let loop):\n workspaceManager.activateWorkspace(next: true, skipEmpty: skipEmpty, loop: loop)\n if clean { workspaceManager.hideUnassignedApps() }\n return CommandResponse(success: true)\n\n case .previousWorkspace(let skipEmpty, let clean, let loop):\n workspaceManager.activateWorkspace(next: false, skipEmpty: skipEmpty, loop: loop)\n if clean { workspaceManager.hideUnassignedApps() }\n return CommandResponse(success: true)\n\n case .recentWorkspace(let clean):\n workspaceManager.activateRecentWorkspace()\n if clean { workspaceManager.hideUnassignedApps() }\n return CommandResponse(success: true)\n\n case .createWorkspace(let request):\n let workspace = request.toWorkspace\n workspaceRepository.addWorkspace(workspace)\n if request.activate {\n workspaceManager.activateWorkspace(workspace, setFocus: true)\n }\n NotificationCenter.default.post(name: .appsListChanged, object: nil)\n return CommandResponse(success: true)\n\n case .deleteWorkspace(let name):\n let workspace = workspaceRepository.workspaces.first { $0.name == name }\n if let workspace {\n workspaceRepository.deleteWorkspace(id: workspace.id)\n NotificationCenter.default.post(name: .appsListChanged, object: nil)\n return CommandResponse(success: true)\n } else {\n return CommandResponse(success: false, error: \"Workspace not found\")\n }\n\n default:\n return nil\n }\n }\n\n private func updateWorkspace(_ request: UpdateWorkspaceRequest) -> CommandResponse {\n var workspace: Workspace?\n if let workspaceName = request.name {\n workspace = workspaceRepository.workspaces.first { $0.name == workspaceName }\n } else if let workspaceId = workspaceManager.activeWorkspaceDetails?.id {\n workspace = workspaceRepository.workspaces.first { $0.id == workspaceId }\n } else {\n return CommandResponse(success: false, error: \"Workspace not found\")\n }\n\n guard var workspace else {\n return CommandResponse(success: false, error: \"Workspace not found\")\n }\n\n if let display = request.display {\n switch display {\n case .active:\n if let display = NSWorkspace.shared.frontmostApplication?.display {\n workspace.display = display\n } else {\n return CommandResponse(success: false, error: \"No active display found\")\n }\n case .name(let name):\n workspace.display = name\n }\n }\n\n workspaceRepository.updateWorkspace(workspace)\n NotificationCenter.default.post(name: .appsListChanged, object: nil)\n\n return CommandResponse(success: true)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Profiles/ProfilesRepository.swift", "//\n// ProfilesRepository.swift\n//\n// Created by Wojciech Kulik on 26/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nfinal class ProfilesRepository: ObservableObject {\n @Published var profiles: [Profile] = [.default]\n @Published var selectedProfile: Profile = .default {\n didSet {\n guard shouldTrackProfileChange else { return }\n guard oldValue.id != selectedProfile.id else { return }\n setProfile(id: selectedProfile.id)\n }\n }\n\n var onProfileChange: ((Profile) -> ())?\n\n private var selectedProfileId: ProfileId? {\n get {\n UserDefaults.standard.string(forKey: AppConstants.UserDefaultsKey.selectedProfileId)\n .flatMap { UUID(uuidString: $0) }\n }\n set {\n if let newValue {\n UserDefaults.standard.set(newValue.uuidString, forKey: AppConstants.UserDefaultsKey.selectedProfileId)\n } else {\n UserDefaults.standard.removeObject(forKey: AppConstants.UserDefaultsKey.selectedProfileId)\n }\n }\n }\n\n private var shouldTrackProfileChange = true\n\n init() {\n loadFromDisk()\n }\n\n private func loadFromDisk() {\n shouldTrackProfileChange = false\n defer { shouldTrackProfileChange = true }\n\n guard let config = try? ConfigSerializer.deserialize(ProfilesConfig.self, filename: \"profiles\"),\n !config.profiles.isEmpty else {\n return createDefaultProfile()\n }\n\n let migrated = migrateOldConfigIfNeeded()\n profiles = config.profiles\n\n let selectedProfileId = selectedProfileId\n selectedProfile = profiles.first { $0.id == selectedProfileId } ?? profiles.first ?? .default\n\n if migrated { saveToDisk() }\n }\n\n private func migrateOldConfigIfNeeded() -> Bool {\n struct OldProfilesConfig: Codable {\n let selectedProfileId: ProfileId?\n }\n\n if let oldConfig = try? ConfigSerializer.deserialize(OldProfilesConfig.self, filename: \"profiles\"),\n let profileId = oldConfig.selectedProfileId {\n selectedProfileId = profileId\n Logger.log(\"Migrated old profile config to new format. Profile ID: \\(profileId)\")\n\n return true\n }\n\n return false\n }\n\n private func createDefaultProfile() {\n profiles = [.init(\n id: UUID(),\n name: \"Default\",\n workspaces: []\n )]\n selectedProfile = profiles[0]\n saveToDisk()\n }\n\n private func setProfile(id: ProfileId) {\n guard let profile = profiles.first(where: { $0.id == id }) else { return }\n\n saveToDisk()\n\n onProfileChange?(profile)\n NotificationCenter.default.post(name: .profileChanged, object: nil)\n Integrations.runOnProfileChangeIfNeeded(profile: profile.name)\n }\n}\n\nextension ProfilesRepository {\n func createProfile(name: String, keepWorkspaces: Bool) {\n var workspaces = [Workspace]()\n\n if keepWorkspaces {\n workspaces = selectedProfile.workspaces.map { workspace in\n var newWorkspace = workspace\n newWorkspace.id = UUID()\n return newWorkspace\n }\n }\n\n let newProfile = Profile(id: UUID(), name: name, workspaces: workspaces)\n profiles.append(newProfile)\n profiles.sort { $0.name < $1.name }\n\n saveToDisk()\n }\n\n func renameProfile(id: ProfileId, to newName: String) {\n guard let index = profiles.firstIndex(where: { $0.id == id }) else { return }\n\n profiles[index].name = newName\n profiles.sort { $0.name < $1.name }\n\n shouldTrackProfileChange = false\n selectedProfile = profiles.first { $0.id == id } ?? .default\n shouldTrackProfileChange = true\n\n saveToDisk()\n }\n\n func deleteProfile(id: ProfileId) {\n guard profiles.count > 1 else { return }\n\n profiles.removeAll { $0.id == id }\n\n if selectedProfile.id == id {\n shouldTrackProfileChange = false\n selectedProfile = profiles.first ?? .default\n shouldTrackProfileChange = true\n\n saveToDisk()\n setProfile(id: selectedProfile.id)\n } else {\n saveToDisk()\n }\n }\n\n func updateWorkspaces(_ workspaces: [Workspace]) {\n guard let profileIndex = profiles.firstIndex(where: { $0.id == selectedProfile.id }) else { return }\n\n profiles[profileIndex].workspaces = workspaces\n selectedProfile = profiles[profileIndex]\n saveToDisk()\n }\n\n func saveToDisk() {\n let config = ProfilesConfig(profiles: profiles)\n try? ConfigSerializer.serialize(filename: \"profiles\", config)\n\n selectedProfileId = selectedProfile.id\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Integrations/IntegrationsSettingsView.swift", "//\n// IntegrationsSettingsView.swift\n//\n// Created by Wojciech Kulik on 24/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct IntegrationsSettingsView: View {\n @StateObject var settings = AppDependencies.shared.integrationsSettings\n\n var body: some View {\n Form {\n Section {\n Toggle(\"Enable Integrations\", isOn: $settings.enableIntegrations)\n }\n\n Section(\"Scripts To Run\") {\n HStack {\n Text(\"On App Launch\")\n TextField(\"\", text: $settings.runScriptOnLaunch)\n .foregroundColor(.secondary)\n .standardPlaceholder(settings.runScriptOnLaunch.isEmpty)\n }\n\n HStack {\n Text(\"On Workspace Change\")\n TextField(\"\", text: $settings.runScriptOnWorkspaceChange)\n .foregroundColor(.secondary)\n .standardPlaceholder(settings.runScriptOnWorkspaceChange.isEmpty)\n }\n\n HStack {\n Text(\"On Profile Change\")\n TextField(\"\", text: $settings.runScriptOnProfileChange)\n .foregroundColor(.secondary)\n .standardPlaceholder(settings.runScriptOnProfileChange.isEmpty)\n }\n\n Text(\n \"\"\"\n $WORKSPACE will be replaced with the active workspace name\n $WORKSPACE_NUMBER will be replaced with the active workspace number\n $DISPLAY will be replaced with the corresponding display name\n $PROFILE will be replaced with the active profile name\n \"\"\"\n )\n .foregroundStyle(.secondary)\n .font(.callout)\n }\n .disabled(!settings.enableIntegrations)\n .opacity(settings.enableIntegrations ? 1 : 0.5)\n }\n .formStyle(.grouped)\n .navigationTitle(\"Integrations\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/MenuBar/MenuBarSettingsView.swift", "//\n// MenuBarSettingsView.swift\n//\n// Created by Wojciech Kulik on 31/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct MenuBarSettingsView: View {\n @StateObject var settings = AppDependencies.shared.menuBarSettings\n\n var body: some View {\n Form {\n Section {\n Toggle(\"Show Title\", isOn: $settings.showMenuBarTitle)\n Toggle(\"Show Icon\", isOn: $settings.showMenuBarIcon)\n .disabled(!settings.showMenuBarTitle)\n\n HStack {\n Text(\"Title Template\")\n TextField(\"\", text: $settings.menuBarTitleTemplate)\n .foregroundColor(.secondary)\n .standardPlaceholder(settings.menuBarTitleTemplate.isEmpty)\n }\n .disabled(!settings.showMenuBarTitle)\n .opacity(settings.showMenuBarTitle ? 1 : 0.5)\n\n Text(\n \"\"\"\n $WORKSPACE will be replaced with the active workspace name\n $WORKSPACE_NUMBER will be replaced with the active workspace number\n $DISPLAY will be replaced with the corresponding display name\n $PROFILE will be replaced with the active profile name\n \"\"\"\n )\n .foregroundStyle(.secondary)\n .font(.callout)\n .opacity(settings.showMenuBarTitle ? 1 : 0.5)\n }\n\n Section {\n HStack {\n Text(\"Display Aliases\")\n TextField(\"\", text: $settings.menuBarDisplayAliases)\n .foregroundColor(.secondary)\n .standardPlaceholder(settings.menuBarDisplayAliases.isEmpty)\n }\n .disabled(!settings.showMenuBarTitle)\n .opacity(settings.showMenuBarTitle ? 1 : 0.5)\n\n Text(\"Example: DELL U2723QE=Secondary;Built-in Retina Display=Main\")\n .foregroundStyle(.secondary)\n .font(.callout)\n .opacity(settings.showMenuBarTitle ? 1 : 0.5)\n }\n }\n .formStyle(.grouped)\n .navigationTitle(\"Menu Bar\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Workspaces/WorkspacesSettingsView.swift", "//\n// WorkspacesSettingsView.swift\n//\n// Created by Wojciech Kulik on 24/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct WorkspacesSettingsView: View {\n @StateObject var settings = AppDependencies.shared.workspaceSettings\n @StateObject var viewModel = WorkspaceSettingsViewModel()\n\n var body: some View {\n Form {\n Section(\"Displays\") {\n Picker(\"Display Assignment Mode\", selection: $settings.displayMode) {\n ForEach(DisplayMode.allCases) { action in\n Text(action.description).tag(action)\n }\n }\n\n Text(\"Static Mode requires you to manually assign workspaces to displays.\\n\\n\" +\n \"Dynamic Mode automatically assigns workspaces to displays \" +\n \"based on where your applications are located. In this mode, a single workspace can span across multiple displays.\"\n )\n .font(.callout)\n .foregroundStyle(.secondary)\n }\n\n Section(\"Behaviors\") {\n Toggle(\"Activate Workspace On Focus Change\", isOn: $settings.activeWorkspaceOnFocusChange)\n Toggle(\"Center Cursor In Focused App On Workspace Change\", isOn: $settings.centerCursorOnWorkspaceChange)\n Toggle(\"Automatically Change Workspace On App Assignment\", isOn: $settings.changeWorkspaceOnAppAssign)\n Toggle(\"Keep Unassigned Apps On Workspace Change\", isOn: $settings.keepUnassignedAppsOnSwitch)\n Toggle(\"Show Hidden Apps On Workspace Activation\", isOn: $settings.restoreHiddenAppsOnSwitch)\n .help(\"Restores hidden apps, even if they were hidden manually\")\n Toggle(\"Enable Workspace Transition Animation\", isOn: $settings.enableWorkspaceTransitions)\n .help(\"Show a brief visual transition effect when switching between workspaces\")\n\n if settings.enableWorkspaceTransitions {\n HStack {\n VStack(alignment: .leading) {\n Text(\"Transition Duration\")\n Text(\"Controls how long the transition animation lasts when switching workspaces\")\n .font(.caption)\n .foregroundStyle(.secondary)\n }\n Spacer()\n Slider(value: $settings.workspaceTransitionDuration, in: 0.1...0.5, step: 0.05)\n .frame(width: 150)\n Text(\"\\(settings.workspaceTransitionDuration, specifier: \"%.2f\")s\")\n .foregroundStyle(.secondary)\n .frame(width: 45.0, alignment: .trailing)\n }\n .padding(.leading, 16)\n\n HStack {\n VStack(alignment: .leading) {\n Text(\"Transition Dimming\")\n Text(\"Adjusts how dark the screen becomes during workspace transitions\")\n .font(.caption)\n .foregroundStyle(.secondary)\n }\n Spacer()\n Slider(value: $settings.workspaceTransitionDimming, in: 0.05...0.5, step: 0.05)\n .frame(width: 150)\n Text(\"\\(Int(settings.workspaceTransitionDimming * 100))%\")\n .foregroundStyle(.secondary)\n .frame(width: 45.0, alignment: .trailing)\n }\n .padding(.leading, 16)\n }\n }\n\n Section(\"Shortcuts\") {\n hotkey(\"Assign Visible Apps (to active workspace)\", for: $settings.assignVisibleApps)\n hotkey(\"Assign Focused App (to active workspace)\", for: $settings.assignFocusedApp)\n hotkey(\"Unassign Focused App\", for: $settings.unassignFocusedApp)\n hotkey(\"Toggle Focused App Assignment\", for: $settings.toggleFocusedAppAssignment)\n hotkey(\"Hide Unassigned Apps\", for: $settings.hideUnassignedApps)\n }\n\n Section {\n hotkey(\"Recent Workspace\", for: $settings.switchToRecentWorkspace)\n hotkey(\"Previous Workspace\", for: $settings.switchToPreviousWorkspace)\n hotkey(\"Next Workspace\", for: $settings.switchToNextWorkspace)\n Toggle(\"Loop Workspaces\", isOn: $settings.loopWorkspaces)\n Toggle(\"Skip Empty Workspaces On Switch\", isOn: $settings.skipEmptyWorkspacesOnSwitch)\n Text(\n \"These shortcuts allow you to cycle through workspaces on the display where the cursor is currently located.\"\n )\n .foregroundStyle(.secondary)\n .font(.callout)\n }\n\n Section {\n HStack {\n Text(\"Alternative Displays\")\n TextField(\"\", text: $settings.alternativeDisplays)\n .foregroundColor(.secondary)\n .standardPlaceholder(settings.alternativeDisplays.isEmpty)\n }\n\n Text(\n \"\"\"\n Example: DELL XYZ=Benq ABC;LG 123=DELL XYZ\n\n This setting is useful if you want to use the same configuration for different displays.\n You can tell FlashSpace which display should be used if the selected one is not connected.\n\n If only one display is connected, it will always act as the fallback.\n \"\"\"\n )\n .foregroundStyle(.secondary)\n .font(.callout)\n }\n .hidden(settings.displayMode == .dynamic)\n\n Section(\"Picture-in-Picture\") {\n Toggle(\"Enable Picture-in-Picture Support\", isOn: $settings.enablePictureInPictureSupport)\n Toggle(\"Switch Workspace When Picture-in-Picture Closes\", isOn: $settings.switchWorkspaceWhenPipCloses)\n\n HStack {\n Text(\"Screen Corner Offset\")\n Spacer()\n Text(\"\\(settings.pipScreenCornerOffset)\")\n Stepper(\n \"\",\n value: $settings.pipScreenCornerOffset,\n in: 1...50,\n step: 1\n ).labelsHidden()\n }\n\n Text(\n \"If a supported browser has Picture-in-Picture active, other \" +\n \"windows will be hidden in a screen corner to keep PiP visible.\"\n )\n .foregroundStyle(.secondary)\n .font(.callout)\n }\n\n Section(header: pipAppsHeader) {\n if settings.pipApps.isEmpty {\n Text(\"You can apply Picture-in-Picture behavior to any app by adding it here.\")\n .foregroundStyle(.secondary)\n .font(.callout)\n } else {\n pipAppsList\n }\n }\n .opacity(settings.enablePictureInPictureSupport ? 1 : 0.5)\n }\n .sheet(isPresented: $viewModel.isInputDialogPresented) {\n InputDialog(\n title: \"Enter PiP window title regex:\",\n placeholder: \"e.g. Meeting with.*\",\n userInput: $viewModel.windowTitleRegex,\n isPresented: $viewModel.isInputDialogPresented\n )\n }\n .formStyle(.grouped)\n .navigationTitle(\"Workspaces\")\n }\n\n private var pipAppsList: some View {\n VStack(alignment: .leading) {\n ForEach(settings.pipApps, id: \\.self) { app in\n HStack {\n Button {\n viewModel.deletePipApp(app)\n } label: {\n Image(systemName: \"x.circle.fill\").opacity(0.8)\n }.buttonStyle(.borderless)\n\n Text(app.name)\n Spacer()\n Text(app.pipWindowTitleRegex)\n .foregroundColor(.secondary)\n }\n }\n }\n }\n\n private var pipAppsHeader: some View {\n HStack {\n Text(\"Custom Picture-in-Picture Apps\")\n Spacer()\n Button {\n viewModel.addPipApp()\n } label: {\n Image(systemName: \"plus\")\n }\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Workspaces/WorkspaceRepository.swift", "//\n// WorkspaceRepository.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Combine\nimport Foundation\n\nfinal class WorkspaceRepository: ObservableObject {\n @Published private(set) var workspaces: [Workspace] = []\n\n private let profilesRepository: ProfilesRepository\n\n init(profilesRepository: ProfilesRepository) {\n self.profilesRepository = profilesRepository\n self.workspaces = profilesRepository.selectedProfile.workspaces\n\n profilesRepository.onProfileChange = { [weak self] profile in\n self?.workspaces = profile.workspaces\n }\n }\n\n func addWorkspace(name: String) {\n let workspace = Workspace(\n id: .init(),\n name: name,\n display: NSScreen.main?.localizedName ?? \"\",\n activateShortcut: nil,\n assignAppShortcut: nil,\n apps: []\n )\n workspaces.append(workspace)\n notifyAboutChanges()\n }\n\n func addWorkspace(_ workspace: Workspace) {\n workspaces.append(workspace)\n notifyAboutChanges()\n }\n\n func updateWorkspace(_ workspace: Workspace) {\n guard let workspaceIndex = workspaces.firstIndex(where: { $0.id == workspace.id }) else { return }\n\n workspaces[workspaceIndex] = workspace\n notifyAboutChanges()\n AppDependencies.shared.hotKeysManager.refresh()\n }\n\n func deleteWorkspace(id: WorkspaceID) {\n workspaces.removeAll { $0.id == id }\n notifyAboutChanges()\n }\n\n func deleteWorkspaces(ids: Set) {\n workspaces.removeAll { ids.contains($0.id) }\n notifyAboutChanges()\n }\n\n func addApp(to workspaceId: WorkspaceID, app: MacApp) {\n guard let workspaceIndex = workspaces.firstIndex(where: { $0.id == workspaceId }) else { return }\n guard !workspaces[workspaceIndex].apps.contains(app) else { return }\n\n workspaces[workspaceIndex].apps.append(app)\n notifyAboutChanges()\n }\n\n func deleteApp(from workspaceId: WorkspaceID, app: MacApp, notify: Bool = true) {\n guard let workspaceIndex = workspaces.firstIndex(where: { $0.id == workspaceId }) else { return }\n\n if workspaces[workspaceIndex].appToFocus == app {\n workspaces[workspaceIndex].appToFocus = nil\n }\n\n workspaces[workspaceIndex].apps.removeAll { $0 == app }\n if notify { notifyAboutChanges() }\n }\n\n func deleteAppFromAllWorkspaces(app: MacApp) {\n for (index, var workspace) in workspaces.enumerated() {\n workspace.apps.removeAll { $0 == app }\n if workspace.appToFocus == app {\n workspace.appToFocus = nil\n }\n\n workspaces[index] = workspace\n }\n notifyAboutChanges()\n }\n\n func reorderWorkspaces(newOrder: [WorkspaceID]) {\n let map = newOrder.enumerated().reduce(into: [WorkspaceID: Int]()) { $0[$1.element] = $1.offset }\n workspaces = workspaces.sorted { map[$0.id] ?? 0 < map[$1.id] ?? 0 }\n notifyAboutChanges()\n }\n\n func moveApps(_ apps: [MacApp], from sourceWorkspaceId: WorkspaceID, to targetWorkspaceId: WorkspaceID) {\n guard let sourceWorkspaceIndex = workspaces.firstIndex(where: { $0.id == sourceWorkspaceId }),\n let targetWorkspaceIndex = workspaces.firstIndex(where: { $0.id == targetWorkspaceId }) else { return }\n\n if let appToFocus = workspaces[sourceWorkspaceIndex].appToFocus, apps.contains(appToFocus) {\n workspaces[sourceWorkspaceIndex].appToFocus = nil\n }\n\n let targetAppBundleIds = workspaces[targetWorkspaceIndex].apps.map(\\.bundleIdentifier).asSet\n let appsToAdd = apps.filter { !targetAppBundleIds.contains($0.bundleIdentifier) }\n\n workspaces[sourceWorkspaceIndex].apps.removeAll { apps.contains($0) }\n workspaces[targetWorkspaceIndex].apps.append(contentsOf: appsToAdd)\n\n notifyAboutChanges()\n NotificationCenter.default.post(name: .appsListChanged, object: nil)\n }\n\n private func notifyAboutChanges() {\n profilesRepository.updateWorkspaces(workspaces)\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/Bundle.swift", "//\n// Bundle.swift\n//\n// Created by Wojciech Kulik on 26/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nextension Bundle {\n var localizedAppName: String {\n localizedInfoDictionary?[\"CFBundleDisplayName\"] as? String\n ?? infoDictionary?[\"CFBundleDisplayName\"] as? String\n ?? infoDictionary?[\"CFBundleName\"] as? String\n ?? bundleURL.fileName\n }\n\n var isAgent: Bool {\n infoDictionary?[\"LSUIElement\"] as? String == \"1\" ||\n infoDictionary?[\"LSUIElement\"] as? Bool == true\n }\n\n var iconPath: String {\n let iconFile = infoDictionary?[\"CFBundleIconFile\"] as? String\n ?? infoDictionary?[\"CFBundleIconName\"] as? String\n ?? \"AppIcon\"\n\n return bundleURL\n .appendingPathComponent(\"Contents\")\n .appendingPathComponent(\"Resources\")\n .appendingPathComponent(iconFile.hasSuffix(\".icns\") ? iconFile : \"\\(iconFile).icns\")\n .path(percentEncoded: false)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Commands/GetCommands.swift", "//\n// GetCommands.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\n\nfinal class GetCommands: CommandExecutor {\n var workspaceManager: WorkspaceManager { AppDependencies.shared.workspaceManager }\n var profilesRepository: ProfilesRepository { AppDependencies.shared.profilesRepository }\n\n func execute(command: CommandRequest) -> CommandResponse? {\n switch command {\n case .getProfile:\n let result = profilesRepository.selectedProfile.name\n return CommandResponse(success: true, message: result)\n\n case .getWorkspace(let display):\n let workspace = workspaceManager.activeWorkspace[display ?? NSScreen.main?.localizedName ?? \"\"]\n if let workspace {\n let result = workspace.name\n return CommandResponse(success: true, message: result)\n } else {\n return CommandResponse(success: false, error: \"No active workspace\")\n }\n\n case .getApp(let withWindowsCount):\n if let app = NSWorkspace.shared.frontmostApplication, let appName = app.localizedName {\n if withWindowsCount {\n return CommandResponse(success: true, message: \"\\(appName)\\n\\(app.allWindows.count)\")\n } else {\n return CommandResponse(success: true, message: appName)\n }\n } else {\n return CommandResponse(success: false, error: \"No active app\")\n }\n\n case .getDisplay:\n if let display = NSScreen.main?.localizedName {\n return CommandResponse(success: true, message: display)\n } else {\n return CommandResponse(success: false, error: \"No display found\")\n }\n\n default:\n return nil\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/MainScreen/WorkspaceConfigurationView.swift", "//\n// WorkspaceConfigurationView.swift\n//\n// Created by Wojciech Kulik on 20/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct WorkspaceConfigurationView: View {\n @Environment(\\.openWindow) var openWindow\n\n @ObservedObject var viewModel: MainViewModel\n @StateObject var profilesRepository = AppDependencies.shared.profilesRepository\n\n var body: some View {\n VStack(alignment: .leading, spacing: 0.0) {\n configuration\n\n if viewModel.workspaces.contains(where: { $0.apps.contains(where: \\.bundleIdentifier.isEmpty) }) {\n Text(\"Could not migrate some apps. Please re-add them to fix the problem. Please also check floating apps.\")\n .foregroundColor(.errorRed)\n }\n\n Spacer()\n profileAndSettings\n }\n }\n\n private var configuration: some View {\n VStack(alignment: .leading, spacing: 1.0) {\n Text(\"Workspace Configuration:\")\n .padding(.bottom, 16.0)\n .fixedSize()\n\n Text(\"Name:\")\n TextField(\"Name\", text: $viewModel.workspaceName)\n .onSubmit(viewModel.saveWorkspace)\n .padding(.bottom)\n\n Picker(\"Display:\", selection: $viewModel.workspaceDisplay) {\n ForEach(viewModel.screens, id: \\.self) {\n Text($0).tag($0)\n }\n }\n .padding(.bottom)\n .hidden(viewModel.displayMode == .dynamic)\n\n Picker(\"Focus App:\", selection: $viewModel.workspaceAppToFocus) {\n ForEach(viewModel.focusAppOptions, id: \\.self) {\n Text($0.name).tag($0)\n }\n }.padding(.bottom)\n\n HStack {\n Text(\"Menu Bar Icon:\")\n Button {\n viewModel.isSymbolPickerPresented = true\n } label: {\n Image(systemName: viewModel.workspaceSymbolIconName ?? .defaultIconSymbol)\n .frame(maxWidth: .infinity)\n }\n }.padding(.bottom)\n\n Text(\"Activate Shortcut:\")\n HotKeyControl(shortcut: $viewModel.workspaceShortcut).padding(.bottom)\n\n Text(\"Assign App Shortcut:\")\n HotKeyControl(shortcut: $viewModel.workspaceAssignShortcut).padding(.bottom)\n }\n .disabled(viewModel.selectedWorkspace == nil)\n }\n\n private var profileAndSettings: some View {\n HStack {\n Picker(\"Profile:\", selection: $profilesRepository.selectedProfile) {\n ForEach(profilesRepository.profiles) {\n Text($0.name).tag($0)\n }\n }\n\n Button(action: {\n openWindow(id: \"settings\")\n }, label: {\n Image(systemName: \"gearshape\")\n .foregroundColor(.primary)\n }).keyboardShortcut(\",\")\n }.frame(maxWidth: .infinity, alignment: .trailing)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Integrations/Integrations.swift", "//\n// Integrations.swift\n//\n// Created by Wojciech Kulik on 24/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nenum Integrations {\n private static let settings = AppDependencies.shared.integrationsSettings\n private static let profilesRepository = AppDependencies.shared.profilesRepository\n\n static func runOnActivateIfNeeded(workspace: ActiveWorkspace) {\n let script = settings.runScriptOnWorkspaceChange.trimmingCharacters(in: .whitespaces)\n .replacingOccurrences(of: \"$WORKSPACE_NUMBER\", with: workspace.number ?? \"\")\n .replacingOccurrences(of: \"$WORKSPACE\", with: workspace.name)\n .replacingOccurrences(of: \"$DISPLAY\", with: workspace.display)\n .replacingOccurrences(of: \"$PROFILE\", with: profilesRepository.selectedProfile.name)\n runScript(script)\n }\n\n static func runOnAppLaunchIfNeeded() {\n let script = settings.runScriptOnLaunch.trimmingCharacters(in: .whitespaces)\n .replacingOccurrences(of: \"$PROFILE\", with: profilesRepository.selectedProfile.name)\n runScript(script)\n }\n\n static func runOnProfileChangeIfNeeded(profile: String) {\n let script = settings.runScriptOnProfileChange.trimmingCharacters(in: .whitespaces)\n .replacingOccurrences(of: \"$PROFILE\", with: profile)\n runScript(script)\n }\n\n private static func runScript(_ script: String) {\n guard settings.enableIntegrations, !script.isEmpty else { return }\n\n let shell = ProcessInfo.processInfo.environment[\"SHELL\"] ?? \"/bin/sh\"\n let task = Process()\n task.launchPath = shell\n task.arguments = [\"-c\", script]\n task.launch()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Profiles/ProfilesSettingsView.swift", "//\n// ProfilesSettingsView.swift\n//\n// Created by Wojciech Kulik on 26/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct ProfilesSettingsView: View {\n @StateObject var viewModel = ProfilesSettingsViewModel()\n @StateObject var profilesRepository = AppDependencies.shared.profilesRepository\n\n var body: some View {\n Form {\n Section(\n header: HStack {\n Text(\"Profiles\")\n Spacer()\n Button {\n viewModel.createNewProfile()\n } label: {\n Image(systemName: \"plus\")\n }\n }\n ) {\n VStack(alignment: .leading) {\n ForEach(profilesRepository.profiles) { profile in\n HStack {\n Button {\n viewModel.deleteProfile(profile)\n } label: {\n Image(systemName: \"x.circle.fill\").opacity(0.8)\n }\n .buttonStyle(.borderless)\n .hidden(viewModel.hideDeleteButton)\n\n Button {\n viewModel.renameProfile(profile)\n } label: {\n Text(profile.name)\n }\n .buttonStyle(.borderless)\n .tint(.primary)\n }\n }\n }\n }\n }\n .formStyle(.grouped)\n .sheet(isPresented: $viewModel.isInputDialogPresented) {\n InputDialog(\n title: \"Enter profile name:\",\n userInput: $viewModel.userInput,\n isPresented: $viewModel.isInputDialogPresented\n )\n }\n .alert(\n \"Are you sure you want to delete \\\"\\(viewModel.profileToDelete)\\\" profile?\",\n isPresented: $viewModel.isDeleteConfirmationPresented\n ) {\n Button(\"Delete\", role: .destructive) {\n viewModel.deleteConfirmed()\n }\n Button(\"Cancel\", role: .cancel) {}\n } message: {\n Text(\"This action cannot be undone.\")\n }\n .alert(\n \"Do you want to copy the current workspaces to the new profile?\",\n isPresented: $viewModel.isCopyChoicePresented\n ) {\n Button(\"Copy\") { viewModel.createNewProfile(copyWorkspaces: true) }\n Button(\"No\", role: .cancel) { viewModel.createNewProfile(copyWorkspaces: false) }\n }\n .onChange(of: viewModel.isInputDialogPresented) { _, isPresented in\n if !isPresented {\n viewModel.inputDialogDismissed()\n }\n }\n .navigationTitle(\"Profiles\")\n }\n}\n"], ["/FlashSpace/FlashSpace/App/AppConstants.swift", "//\n// AppConstants.swift\n//\n// Created by Wojciech Kulik on 23/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nenum AppConstants {\n enum UserDefaultsKey {\n static let selectedProfileId = \"selectedProfileId\"\n }\n\n static let lastFocusedOption = MacApp(\n name: \"(Last Focused)\",\n bundleIdentifier: \"flashspace.last-focused\",\n iconPath: nil\n )\n\n static var version: String {\n guard let version = Bundle.main.infoDictionary?[\"CFBundleShortVersionString\"] as? String else {\n return \"Unknown\"\n }\n\n #if DEBUG\n return version + \" (debug)\"\n #else\n return version\n #endif\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Workspaces/Models/MacApp.swift", "//\n// MacApp.swift\n//\n// Created by Wojciech Kulik on 06/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\ntypealias BundleId = String\n\nstruct MacApp: Codable, Hashable, Equatable {\n var name: String\n var bundleIdentifier: BundleId\n var iconPath: String?\n\n init(\n name: String,\n bundleIdentifier: BundleId,\n iconPath: String?\n ) {\n self.name = name\n self.bundleIdentifier = bundleIdentifier\n self.iconPath = iconPath\n }\n\n init(app: NSRunningApplication) {\n self.name = app.localizedName ?? \"\"\n self.bundleIdentifier = app.bundleIdentifier ?? \"\"\n self.iconPath = app.iconPath\n }\n\n init(from decoder: any Decoder) throws {\n if let app = try? decoder.singleValueContainer().decode(String.self) {\n // V1 - migration\n let runningApp = NSWorkspace.shared.runningApplications\n .first { $0.localizedName == app }\n\n self.name = app\n\n if let runningApp {\n self.bundleIdentifier = runningApp.bundleIdentifier ?? \"\"\n self.iconPath = runningApp.iconPath\n } else if let bundle = Bundle(path: \"/Applications/\\(app).app\") {\n self.bundleIdentifier = bundle.bundleIdentifier ?? \"\"\n self.iconPath = bundle.iconPath\n } else if let bundle = Bundle(path: \"/System/Applications/\\(app).app\") {\n self.bundleIdentifier = bundle.bundleIdentifier ?? \"\"\n self.iconPath = bundle.iconPath\n } else {\n self.bundleIdentifier = \"\"\n self.iconPath = nil\n }\n\n Migrations.appsMigrated = true\n } else {\n // V2\n let container = try decoder.container(keyedBy: CodingKeys.self)\n self.name = try container.decode(String.self, forKey: .name)\n self.bundleIdentifier = try container.decode(String.self, forKey: .bundleIdentifier)\n self.iconPath = try container.decodeIfPresent(String.self, forKey: .iconPath)\n }\n }\n\n static func == (lhs: MacApp, rhs: MacApp) -> Bool {\n if lhs.bundleIdentifier.isEmpty || rhs.bundleIdentifier.isEmpty {\n return lhs.name == rhs.name\n } else {\n return lhs.bundleIdentifier == rhs.bundleIdentifier\n }\n }\n}\n\nextension MacApp {\n var isFinder: Bool {\n bundleIdentifier == \"com.apple.finder\"\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/CLI.swift", "//\n// CLI.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nenum CLI {\n static var cliPath: String { Bundle.main.bundlePath + \"/Contents/Resources/flashspace\" }\n static var symlinkPath: String { \"/usr/local/bin/flashspace\" }\n static var isInstalled: Bool { FileManager.default.fileExists(atPath: symlinkPath) }\n\n static func install() {\n guard !isInstalled else {\n return print(\"✅ CLI already installed at \\(symlinkPath)\")\n }\n\n if runSudoScript(\"ln -s '\\(cliPath)' '\\(symlinkPath)'\") {\n Logger.log(\"✅ CLI installed from \\(symlinkPath)\")\n }\n }\n\n static func uninstall() {\n guard isInstalled else { return print(\"✅ CLI already uninstalled\") }\n\n if runSudoScript(\"rm '\\(symlinkPath)'\") {\n Logger.log(\"✅ CLI uninstalled from \\(symlinkPath)\")\n }\n }\n\n private static func runSudoScript(_ script: String) -> Bool {\n let appleScript =\n \"do shell script \\\"sudo \\(script)\\\" with administrator privileges\"\n\n guard let scriptObject = NSAppleScript(source: appleScript) else {\n Logger.log(\"❌ Error: Failed to create AppleScript object\")\n Alert.showOkAlert(title: \"Error\", message: \"Could not run script\")\n return false\n }\n\n var error: NSDictionary?\n scriptObject.executeAndReturnError(&error)\n\n if let error {\n Logger.log(\"❌ Error: \\(error)\")\n if let errorNumber = error[\"NSAppleScriptErrorNumber\"],\n errorNumber as? NSNumber != -128,\n let errorMessage = error[\"NSAppleScriptErrorMessage\"] as? String {\n Alert.showOkAlert(title: \"Error\", message: errorMessage)\n }\n return false\n }\n\n return true\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Gestures/GestureAction.swift", "//\n// GestureAction.swift\n//\n// Created by Wojciech Kulik on 30/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nenum GestureAction {\n case none\n case toggleSpaceControl\n case showSpaceControl\n case hideSpaceControl\n case nextWorkspace\n case previousWorkspace\n case mostRecentWorkspace\n case focusLeft\n case focusRight\n case focusUp\n case focusDown\n case focusNextApp\n case focusPreviousApp\n case focusNextWindow\n case focusPreviousWindow\n case activateWorkspace(String)\n}\n\nextension GestureAction: CaseIterable, Equatable, Hashable, Identifiable {\n var id: String { description }\n\n var description: String {\n switch self {\n case .none: return \"None\"\n case .toggleSpaceControl: return \"Toggle Space Control\"\n case .showSpaceControl: return \"Show Space Control\"\n case .hideSpaceControl: return \"Hide Space Control\"\n case .nextWorkspace: return \"Next Workspace\"\n case .previousWorkspace: return \"Previous Workspace\"\n case .mostRecentWorkspace: return \"Most Recent Workspace\"\n case .focusLeft: return \"Focus Left\"\n case .focusRight: return \"Focus Right\"\n case .focusUp: return \"Focus Up\"\n case .focusDown: return \"Focus Down\"\n case .focusNextApp: return \"Focus Next App\"\n case .focusPreviousApp: return \"Focus Previous App\"\n case .focusNextWindow: return \"Focus Next Window\"\n case .focusPreviousWindow: return \"Focus Previous Window\"\n case .activateWorkspace(let workspaceName):\n return \"Activate Workspace: \\(workspaceName)\"\n }\n }\n\n static var allCases: [GestureAction] {\n let workspaces = AppDependencies.shared.workspaceRepository.workspaces\n return allCasesWithoutWorkspaces + workspaces.map { .activateWorkspace($0.name) }\n }\n\n static var allCasesWithoutWorkspaces: [GestureAction] {\n [\n .none,\n .toggleSpaceControl,\n .showSpaceControl,\n .hideSpaceControl,\n .nextWorkspace,\n .previousWorkspace,\n .mostRecentWorkspace,\n .focusLeft,\n .focusRight,\n .focusUp,\n .focusDown,\n .focusNextApp,\n .focusPreviousApp,\n .focusNextWindow,\n .focusPreviousWindow\n ]\n }\n}\n\nextension GestureAction: Codable {\n init(from decoder: Decoder) throws {\n let container = try decoder.singleValueContainer()\n let value = try container.decode(String.self)\n\n if value.hasPrefix(\"activateWorkspace:\") {\n let workspaceName = String(value.dropFirst(\"activateWorkspace:\".count))\n self = .activateWorkspace(workspaceName)\n } else if let action = GestureAction.allCasesWithoutWorkspaces.first(where: { $0.normalizedDescription == value }) {\n self = action\n } else {\n self = .none\n }\n }\n\n func encode(to encoder: Encoder) throws {\n var container = encoder.singleValueContainer()\n try container.encode(normalizedDescription)\n }\n\n private var normalizedDescription: String {\n if case .activateWorkspace(let workspaceName) = self {\n return \"activateWorkspace:\\(workspaceName)\"\n }\n\n let result = String(description.first?.lowercased() ?? \"\") + description.dropFirst()\n return result.replacingOccurrences(of: \" \", with: \"\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/SpaceControl/SpaceControlSettingsView.swift", "//\n// SpaceControlSettingsView.swift\n//\n// Created by Wojciech Kulik on 11/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct SpaceControlSettingsView: View {\n @StateObject var settings = AppDependencies.shared.spaceControlSettings\n @State var hasScreenRecordingPermissions = false\n\n var body: some View {\n Form {\n Section {\n Toggle(\"Enable Space Control\", isOn: $settings.enableSpaceControl)\n }\n\n Group {\n Section(\"Permissions\") {\n HStack {\n if hasScreenRecordingPermissions {\n Image(systemName: \"checkmark.circle.fill\")\n .foregroundColor(.green)\n Text(\"Screen Recording Permission\")\n Spacer()\n } else {\n Image(systemName: \"xmark.circle.fill\")\n .foregroundColor(.red)\n Text(\"Screen Recording Permission\")\n Spacer()\n Button(\"Open Privacy & Security\") {\n NSWorkspace.shared.open(\n URL(string: \"x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture\")!\n )\n }\n }\n }\n Text(\n \"FlashSpace requires screen recording access to show your workspaces in Space Control. \" +\n \"The preview will be displayed upon first activation of the workspace.\"\n )\n .foregroundColor(.secondary)\n .font(.callout)\n }\n\n Section(\"Shortcuts\") {\n hotkey(\"Toggle Space Control\", for: $settings.showSpaceControl)\n }\n\n Section(\"Appearance\") {\n Toggle(\"Enable Animations\", isOn: $settings.enableSpaceControlAnimations)\n Toggle(\n \"Show Workspaces For Current Display Only\",\n isOn: $settings.spaceControlCurrentDisplayWorkspaces\n )\n\n HStack {\n Text(\"Max Number Of Columns\")\n Spacer()\n Text(\"\\(settings.spaceControlMaxColumns)\")\n Stepper(\n \"\",\n value: $settings.spaceControlMaxColumns,\n in: 2...20,\n step: 1\n ).labelsHidden()\n }\n }\n }\n .disabled(!settings.enableSpaceControl)\n .opacity(settings.enableSpaceControl ? 1 : 0.5)\n }\n .onAppear {\n hasScreenRecordingPermissions = PermissionsManager.shared.checkForScreenRecordingPermissions()\n }\n .onReceive(NotificationCenter.default.publisher(for: NSApplication.didBecomeActiveNotification)) { _ in\n hasScreenRecordingPermissions = PermissionsManager.shared.checkForScreenRecordingPermissions()\n }\n .formStyle(.grouped)\n .navigationTitle(\"Space Control\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/CLI/CLISettingsView.swift", "//\n// CLISettingsView.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct CLISettingsView: View {\n @State var isInstalled = false\n @State var isRunning = false\n\n var body: some View {\n Form {\n Section(\"Status\") {\n HStack {\n if isRunning {\n Image(systemName: \"checkmark.circle.fill\")\n .foregroundColor(.green)\n Text(\"FlashSpace CLI Status\")\n Spacer()\n } else {\n Image(systemName: \"xmark.circle.fill\")\n .foregroundColor(.red)\n\n Text(\"FlashSpace CLI Status\")\n Spacer()\n Button(\"Restart\") {\n AppDependencies.shared.cliServer.restart()\n isRunning = AppDependencies.shared.cliServer.isRunning\n }\n }\n }\n\n HStack {\n if isInstalled {\n Image(systemName: \"checkmark.circle.fill\")\n .foregroundColor(.green)\n Text(\"FlashSpace CLI Installation\")\n Spacer()\n Button(\"Uninstall FlashSpace CLI\") {\n CLI.uninstall()\n isInstalled = CLI.isInstalled\n }\n } else {\n Image(systemName: \"xmark.circle.fill\")\n .foregroundColor(.red)\n Text(\"FlashSpace CLI Installation\")\n Spacer()\n Button(\"Install FlashSpace CLI\") {\n CLI.install()\n isInstalled = CLI.isInstalled\n }\n }\n }\n\n VStack(alignment: .leading) {\n Text(\n \"\"\"\n Tool will be installed in /usr/local/bin/flashspace.\n\n You can also access it directly from the app bundle at:\n \"\"\"\n )\n Text(CLI.cliPath)\n .lineLimit(1)\n .truncationMode(.middle)\n .help(CLI.cliPath)\n }\n .foregroundColor(.secondary)\n .font(.callout)\n }\n\n Section {\n Text(\"Run `flashspace --help` in the terminal to see the available commands.\")\n .foregroundStyle(.secondary)\n .font(.callout)\n }\n }\n .onAppear {\n isInstalled = CLI.isInstalled\n isRunning = AppDependencies.shared.cliServer.isRunning\n }\n .formStyle(.grouped)\n .navigationTitle(\"CLI\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/FocusManager/FocusManager.swift", "//\n// FocusManager.swift\n//\n// Created by Wojciech Kulik on 23/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\n\nfinal class FocusManager {\n var visibleApps: [NSRunningApplication] {\n NSWorkspace.shared.runningApplications\n .filter { $0.activationPolicy == .regular && !$0.isHidden }\n }\n\n var focusedApp: NSRunningApplication? { NSWorkspace.shared.frontmostApplication }\n var focusedAppFrame: CGRect? { focusedApp?.frame }\n\n private let workspaceRepository: WorkspaceRepository\n private let workspaceManager: WorkspaceManager\n private let settings: FocusManagerSettings\n private let floatingAppsSettings: FloatingAppsSettings\n\n init(\n workspaceRepository: WorkspaceRepository,\n workspaceManager: WorkspaceManager,\n focusManagerSettings: FocusManagerSettings,\n floatingAppsSettings: FloatingAppsSettings\n ) {\n self.workspaceRepository = workspaceRepository\n self.workspaceManager = workspaceManager\n self.settings = focusManagerSettings\n self.floatingAppsSettings = floatingAppsSettings\n }\n\n func getHotKeys() -> [(AppHotKey, () -> ())] {\n guard settings.enableFocusManagement else { return [] }\n\n return [\n settings.focusLeft.flatMap { ($0, focusLeft) },\n settings.focusRight.flatMap { ($0, focusRight) },\n settings.focusUp.flatMap { ($0, focusUp) },\n settings.focusDown.flatMap { ($0, focusDown) },\n settings.focusNextWorkspaceApp.flatMap { ($0, nextWorkspaceApp) },\n settings.focusPreviousWorkspaceApp.flatMap { ($0, previousWorkspaceApp) },\n settings.focusNextWorkspaceWindow.flatMap { ($0, nextWorkspaceWindow) },\n settings.focusPreviousWorkspaceWindow.flatMap { ($0, previousWorkspaceWindow) }\n ].compactMap { $0 }\n }\n\n func nextWorkspaceWindow() {\n guard let focusedApp else { return nextWorkspaceApp() }\n guard let (_, apps) = getFocusedAppIndex() else { return }\n\n let runningWorkspaceApps = getRunningAppsWithSortedWindows(apps: apps)\n let focusedAppWindows = runningWorkspaceApps\n .first { $0.bundleIdentifier == focusedApp.bundleIdentifier }?\n .windows ?? []\n let isLastWindowFocused = focusedAppWindows.last?.axWindow.isMain == true\n\n if isLastWindowFocused {\n let nextApps = runningWorkspaceApps.drop(while: { $0.bundleIdentifier != focusedApp.bundleIdentifier }).dropFirst() +\n runningWorkspaceApps.prefix(while: { $0.bundleIdentifier != focusedApp.bundleIdentifier })\n let nextApp = nextApps.first ?? MacAppWithWindows(app: focusedApp)\n\n nextApp.app.activate()\n nextApp\n .windows\n .first?\n .axWindow\n .focus()\n } else {\n focusedAppWindows\n .drop(while: { !$0.axWindow.isMain })\n .dropFirst()\n .first?\n .axWindow\n .focus()\n }\n }\n\n func previousWorkspaceWindow() {\n guard let focusedApp else { return previousWorkspaceApp() }\n guard let (_, apps) = getFocusedAppIndex() else { return }\n\n let runningWorkspaceApps = getRunningAppsWithSortedWindows(apps: apps)\n let focusedAppWindows = runningWorkspaceApps\n .first { $0.bundleIdentifier == focusedApp.bundleIdentifier }?\n .windows ?? []\n let isFirstWindowFocused = focusedAppWindows.first?.axWindow.isMain == true\n\n if isFirstWindowFocused {\n let prevApps = runningWorkspaceApps.drop(while: { $0.bundleIdentifier != focusedApp.bundleIdentifier }).dropFirst() +\n runningWorkspaceApps.prefix(while: { $0.bundleIdentifier != focusedApp.bundleIdentifier })\n let prevApp = prevApps.last ?? MacAppWithWindows(app: focusedApp)\n\n prevApp.app.activate()\n prevApp\n .windows\n .last?\n .axWindow\n .focus()\n } else {\n focusedAppWindows\n .prefix(while: { !$0.axWindow.isMain })\n .last?\n .axWindow\n .focus()\n }\n }\n\n func nextWorkspaceApp() {\n guard let (index, apps) = getFocusedAppIndex() else { return }\n\n let appsQueue = apps.dropFirst(index + 1) + apps.prefix(index)\n let runningApps = NSWorkspace.shared.runningApplications\n .excludeFloatingAppsOnDifferentScreen()\n .compactMap(\\.bundleIdentifier)\n .asSet\n let nextApp = appsQueue.first { app in runningApps.contains(app.bundleIdentifier) }\n\n NSWorkspace.shared.runningApplications\n .find(nextApp)?\n .activate()\n }\n\n func previousWorkspaceApp() {\n guard let (index, apps) = getFocusedAppIndex() else { return }\n\n let runningApps = NSWorkspace.shared.runningApplications\n .excludeFloatingAppsOnDifferentScreen()\n .compactMap(\\.bundleIdentifier)\n .asSet\n let prefixApps = apps.prefix(index).reversed()\n let suffixApps = apps.suffix(apps.count - index - 1).reversed()\n let appsQueue = prefixApps + Array(suffixApps)\n let previousApp = appsQueue.first { app in runningApps.contains(app.bundleIdentifier) }\n\n NSWorkspace.shared.runningApplications\n .find(previousApp)?\n .activate()\n }\n\n func focusRight() {\n focus { focusedAppFrame, other in\n other.maxX > focusedAppFrame.maxX &&\n other.verticalIntersect(with: focusedAppFrame)\n }\n }\n\n func focusLeft() {\n focus { focusedAppFrame, other in\n other.minX < focusedAppFrame.minX &&\n other.verticalIntersect(with: focusedAppFrame)\n }\n }\n\n func focusDown() {\n focus { focusedAppFrame, other in\n other.maxY > focusedAppFrame.maxY &&\n other.horizontalIntersect(with: focusedAppFrame)\n }\n }\n\n func focusUp() {\n focus { focusedAppFrame, other in\n other.minY < focusedAppFrame.minY &&\n other.horizontalIntersect(with: focusedAppFrame)\n }\n }\n\n /// Predicate compares two frames using window coordinates.\n /// (0,0) is top-left corner relative to the main screen.\n /// Y-axis is pointing down.\n private func focus(predicate: (CGRect, CGRect) -> Bool) {\n guard let focusedAppFrame else { return }\n\n let appsToCheck = visibleApps\n .flatMap { app in\n app.allWindows.map {\n (app: app, window: $0.window, frame: $0.frame)\n }\n }\n\n let toFocus = appsToCheck\n .filter { predicate(focusedAppFrame, $0.frame) && !$0.window.isMinimized }\n .sorted { $0.frame.distance(to: focusedAppFrame) < $1.frame.distance(to: focusedAppFrame) }\n .first { app in\n guard settings.focusFrontmostWindow else { return true }\n\n let otherWindows = appsToCheck\n .filter { $0.app != app.app && $0.app != focusedApp }\n .map(\\.window)\n return !app.window.isBelowAnyOf(otherWindows)\n }\n\n toFocus?.window.focus()\n toFocus?.app.activate()\n centerCursorIfNeeded(in: toFocus?.frame)\n }\n\n private func centerCursorIfNeeded(in frame: CGRect?) {\n guard settings.centerCursorOnFocusChange, let frame else { return }\n\n CGWarpMouseCursorPosition(CGPoint(x: frame.midX, y: frame.midY))\n }\n\n private func getFocusedAppIndex() -> (Int, [MacApp])? {\n guard let focusedApp else { return nil }\n\n let workspace = workspaceManager.activeWorkspace[NSScreen.main?.localizedName ?? \"\"]\n ?? workspaceRepository.workspaces.first { $0.apps.containsApp(focusedApp) }\n\n guard let workspace else { return nil }\n\n let apps = workspace.apps + floatingAppsSettings.floatingApps\n .filter { !$0.isFinder }\n\n let index = apps.firstIndex(of: focusedApp) ?? 0\n\n return (index, apps)\n }\n\n private func getRunningAppsWithSortedWindows(apps: [MacApp]) -> [MacAppWithWindows] {\n let order = apps\n .enumerated()\n .reduce(into: [String: Int]()) {\n $0[$1.element.bundleIdentifier] = $1.offset\n }\n\n return NSWorkspace.shared.runningApplications\n .filter { !$0.isHidden && apps.containsApp($0) }\n .excludeFloatingAppsOnDifferentScreen()\n .map { MacAppWithWindows(app: $0) }\n .sorted { order[$0.bundleIdentifier] ?? 0 < order[$1.bundleIdentifier] ?? 0 }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Acknowledgements/AcknowledgementsSettingsView.swift", "//\n// AcknowledgementsSettingsView.swift\n//\n// Created by Wojciech Kulik on 26/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct AcknowledgementsSettingsView: View {\n @State private var selectedDependency: String? = \"xnth97/SymbolPicker\"\n @State private var dependencies = [\n \"xnth97/SymbolPicker\",\n \"Kentzo/ShortcutRecorder\",\n \"LebJe/TOMLKit\",\n \"jpsim/Yams\",\n \"sparkle-project/Sparkle\",\n \"apple/swift-argument-parser\",\n \"SwiftFormat\",\n \"SwiftLint\"\n ]\n\n var body: some View {\n VStack(spacing: 0.0) {\n List(\n dependencies,\n id: \\.self,\n selection: $selectedDependency\n ) { dependency in\n Text(dependency)\n }.frame(height: 130)\n\n ScrollView([.vertical, .horizontal]) {\n VStack {\n Group {\n switch selectedDependency {\n case \"xnth97/SymbolPicker\":\n Text(Licenses.symbolPicker)\n case \"Kentzo/ShortcutRecorder\":\n Text(Licenses.shortcutRecorder)\n case \"LebJe/TOMLKit\":\n Text(Licenses.tomlKit)\n case \"jpsim/Yams\":\n Text(Licenses.yams)\n case \"sparkle-project/Sparkle\":\n Text(Licenses.sparkle)\n case \"apple/swift-argument-parser\":\n Text(Licenses.swiftArgumentParser)\n case \"SwiftFormat\":\n Text(Licenses.swiftFormat)\n case \"SwiftLint\":\n Text(Licenses.swiftLint)\n default:\n EmptyView()\n }\n }\n .frame(minHeight: 330, alignment: .top)\n .textSelection(.enabled)\n .padding()\n }\n }\n }\n .navigationTitle(\"Acknowledgements\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/SpaceControl/Views/SpaceControlViewModel.swift", "//\n// SpaceControlViewModel.swift\n//\n// Created by Wojciech Kulik on 11/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport SwiftUI\n\nstruct SpaceControlWorkspace {\n let index: Int\n let name: String\n let symbol: String\n let screenshotData: Data?\n let isActive: Bool\n let originalWorkspace: Workspace\n}\n\nfinal class SpaceControlViewModel: ObservableObject {\n @Published private(set) var workspaces: [SpaceControlWorkspace] = []\n @Published private(set) var numberOfRows = 0\n @Published private(set) var numberOfColumns = 0\n\n private var cancellables = Set()\n\n private let settings = AppDependencies.shared.spaceControlSettings\n private let workspaceRepository = AppDependencies.shared.workspaceRepository\n private let workspaceManager = AppDependencies.shared.workspaceManager\n private let screenshotManager = AppDependencies.shared.workspaceScreenshotManager\n private let displayManager = AppDependencies.shared.displayManager\n\n init() {\n refresh()\n\n NotificationCenter.default\n .publisher(for: .spaceControlArrowDown)\n .compactMap { $0.object as? RawKeyCode }\n .sink { [weak self] in self?.handleArrowKey($0) }\n .store(in: &cancellables)\n }\n\n func onWorkspaceTap(_ workspace: SpaceControlWorkspace) {\n workspaceManager.activateWorkspace(workspace.originalWorkspace, setFocus: true)\n }\n\n func refresh() {\n let activeWorkspaceIds = workspaceManager.activeWorkspace.map(\\.value.id).asSet\n let mainDisplay = NSScreen.main?.localizedName ?? \"\"\n\n workspaces = Array(\n workspaceRepository.workspaces\n .filter { !settings.spaceControlCurrentDisplayWorkspaces || $0.isOnTheCurrentScreen }\n .prefix(15)\n .enumerated()\n .map {\n let workspace = $0.element\n let displayName = settings.spaceControlCurrentDisplayWorkspaces\n ? mainDisplay\n : self.mainDisplay(for: workspace)\n let key = WorkspaceScreenshotManager.ScreenshotKey(\n displayName: displayName,\n workspaceID: workspace.id\n )\n return SpaceControlWorkspace(\n index: $0.offset,\n name: workspace.name,\n symbol: workspace.symbolIconName ?? .defaultIconSymbol,\n screenshotData: screenshotManager.screenshots[key],\n isActive: activeWorkspaceIds.contains(workspace.id),\n originalWorkspace: workspace\n )\n }\n )\n calculateColsAndRows(workspaces.count)\n }\n\n private func mainDisplay(for workspace: Workspace) -> DisplayName {\n let workspaceDisplays = workspace.displays\n\n return workspaceDisplays.count == 1\n ? workspaceDisplays.first!\n : displayManager.lastActiveDisplay(from: workspaceDisplays)\n }\n\n private func calculateColsAndRows(_ workspaceCount: Int) {\n let maxNumberOfRows = 3.0\n\n numberOfColumns = workspaceCount <= 3\n ? workspaceCount\n : max(3, Int(ceil(Double(workspaceCount) / maxNumberOfRows)))\n numberOfColumns = min(numberOfColumns, settings.spaceControlMaxColumns)\n\n numberOfRows = Int(ceil(Double(workspaceCount) / Double(numberOfColumns)))\n }\n\n private func handleArrowKey(_ keyCode: RawKeyCode) {\n let activeWorkspaceIndex = workspaces.firstIndex {\n $0.isActive && $0.originalWorkspace.isOnTheCurrentScreen\n }\n guard let activeWorkspaceIndex else { return }\n\n let workspace: Workspace? = switch KeyCodesMap.toString[keyCode] {\n case \"down\":\n workspaces[safe: activeWorkspaceIndex + numberOfColumns]?.originalWorkspace\n case \"up\":\n workspaces[safe: activeWorkspaceIndex - numberOfColumns]?.originalWorkspace\n case \"right\":\n workspaces[safe: (activeWorkspaceIndex + 1) % workspaces.count]?.originalWorkspace\n case \"left\":\n workspaces[\n safe: activeWorkspaceIndex == 0\n ? workspaces.count - 1\n : activeWorkspaceIndex - 1\n ]?.originalWorkspace\n default:\n nil\n }\n\n if let workspace {\n SpaceControl.hide()\n workspaceManager.activateWorkspace(workspace, setFocus: true)\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Commands/ProfileCommands.swift", "//\n// ProfileCommands.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\n\nfinal class ProfileCommands: CommandExecutor {\n var profilesRepository: ProfilesRepository { AppDependencies.shared.profilesRepository }\n\n func execute(command: CommandRequest) -> CommandResponse? {\n switch command {\n case .activateProfile(let name):\n let profile = profilesRepository.profiles.first { $0.name == name }\n\n if let profile {\n profilesRepository.selectedProfile = profile\n return CommandResponse(success: true)\n } else {\n return CommandResponse(success: false, error: \"Profile not found\")\n }\n\n case .createProfile(let name, let copy, let activate):\n profilesRepository.createProfile(name: name, keepWorkspaces: copy)\n if activate {\n profilesRepository.profiles\n .first { $0.name == name }\n .flatMap { profilesRepository.selectedProfile = $0 }\n }\n return CommandResponse(success: true)\n\n case .deleteProfile(let name):\n let profile = profilesRepository.profiles.first { $0.name == name }\n if let profile {\n profilesRepository.deleteProfile(id: profile.id)\n return CommandResponse(success: true)\n } else {\n return CommandResponse(success: false, error: \"Profile not found\")\n }\n\n default:\n return nil\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Accessibility/AXUIElement+CoreGraphics.swift", "//\n// AXUIElement+CoreGraphics.swift\n//\n// Created by Wojciech Kulik on 21/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension AXUIElement {\n var cgWindowId: CGWindowID? {\n let title = title\n let pid = processId\n\n if let windowList = CGWindowListCopyWindowInfo(.optionOnScreenOnly, kCGNullWindowID) as? [[String: Any]] {\n for window in windowList {\n let windowOwnerPID = window[kCGWindowOwnerPID as String] as? pid_t\n let windowName = window[kCGWindowName as String] as? String\n let windowNumber = window[kCGWindowNumber as String] as? CGWindowID\n\n if title == windowName, windowOwnerPID == pid {\n return windowNumber\n }\n }\n }\n\n return nil\n }\n\n func isBelowAnyOf(_ windows: [AXUIElement]) -> Bool {\n guard let cgWindowId, let frame else { return false }\n\n let otherWindows = windows.map { (id: $0.cgWindowId, window: $0) }\n let windowsAbove = CGWindowListCopyWindowInfo(.optionOnScreenAboveWindow, cgWindowId) as? [[String: Any]] ?? [[:]]\n let windowsAboveIds = Set(\n windowsAbove.compactMap { $0[kCGWindowNumber as String] as? CGWindowID }\n )\n\n return otherWindows.contains { otherWindowId, otherWindow in\n if let otherWindowId,\n windowsAboveIds.contains(otherWindowId),\n let otherWindowFrame = otherWindow.frame,\n frame.intersects(otherWindowFrame) {\n Logger.log(\"💡 Window \\\"\\(title ?? \"unknown\")\\\" is below \\\"\\(otherWindow.title ?? \"unknown\")\\\"\")\n return true\n }\n\n return false\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/SettingsView.swift", "//\n// SettingsView.swift\n//\n// Created by Wojciech Kulik on 23/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct SettingsView: View {\n @State private var selectedTab = \"General\"\n\n var body: some View {\n NavigationSplitView(columnVisibility: .constant(.doubleColumn), sidebar: {\n sideMenu\n .frame(width: 200)\n .navigationSplitViewColumnWidth(200.0)\n }, detail: {\n details\n .frame(maxHeight: .infinity, alignment: .top)\n .navigationSplitViewColumnWidth(min: 440, ideal: 440)\n })\n .frame(width: 780, height: 490)\n }\n\n private var sideMenu: some View {\n VStack {\n List(selection: $selectedTab) {\n Label(\"General\", systemImage: \"gearshape\")\n .tag(\"General\")\n Label(\"Menu Bar\", systemImage: \"contextualmenu.and.cursorarrow\")\n .tag(\"MenuBar\")\n Label(\"Gestures\", systemImage: \"hand.draw\")\n .tag(\"Gestures\")\n Label(\"Workspaces\", systemImage: \"square.stack.3d.up\")\n .tag(\"Workspaces\")\n Label(\"Floating Apps\", systemImage: \"pip\")\n .tag(\"FloatingApps\")\n Label(\"Focus Manager\", systemImage: \"macwindow.on.rectangle\")\n .tag(\"Focus\")\n Label(\"Space Control\", systemImage: \"rectangle.split.2x2\")\n .tag(\"SpaceControl\")\n Label(\"Profiles\", systemImage: \"person.2\")\n .tag(\"Profiles\")\n Label(\"Integrations\", systemImage: \"link\")\n .tag(\"Integrations\")\n Label(\"Configuration File\", systemImage: \"doc.text\")\n .tag(\"Configuration\")\n Label(\"CLI\", systemImage: \"apple.terminal\")\n .tag(\"CLI\")\n Label(\"Acknowledgements\", systemImage: \"info.circle\")\n .tag(\"Acknowledgements\")\n Label(\"About\", systemImage: \"person\")\n .tag(\"About\")\n }\n .toolbar(removing: .sidebarToggle)\n .listStyle(.sidebar)\n\n Spacer()\n\n Text(\"FlashSpace v\\(AppConstants.version)\")\n .foregroundStyle(.secondary)\n .padding(.bottom)\n }\n }\n\n @ViewBuilder\n private var details: some View {\n switch selectedTab {\n case \"General\":\n GeneralSettingsView()\n case \"MenuBar\":\n MenuBarSettingsView()\n case \"Focus\":\n FocusSettingsView()\n case \"Gestures\":\n GesturesSettingsView()\n case \"Workspaces\":\n WorkspacesSettingsView()\n case \"FloatingApps\":\n FloatingAppsSettingsView()\n case \"SpaceControl\":\n SpaceControlSettingsView()\n case \"Integrations\":\n IntegrationsSettingsView()\n case \"Profiles\":\n ProfilesSettingsView()\n case \"Configuration\":\n ConfigurationFileSettingsView()\n case \"CLI\":\n CLISettingsView()\n case \"Acknowledgements\":\n AcknowledgementsSettingsView()\n case \"About\":\n AboutSettingsView()\n default:\n EmptyView()\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/FloatingApps/FloatingAppsSettingsView.swift", "//\n// FloatingAppsSettingsView.swift\n//\n// Created by Wojciech Kulik on 12/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct FloatingAppsSettingsView: View {\n @StateObject var viewModel = FloatingAppsSettingsViewModel()\n @StateObject var settings = AppDependencies.shared.floatingAppsSettings\n\n var body: some View {\n Form {\n Section(header: header) {\n if settings.floatingApps.contains(where: \\.bundleIdentifier.isEmpty) {\n Text(\"Could not migrate some apps. Please re-add them to fix the problem.\")\n .foregroundStyle(.errorRed)\n .font(.callout)\n }\n\n if settings.floatingApps.isEmpty {\n Text(\"(no floating apps added)\")\n .foregroundStyle(.secondary)\n .font(.callout)\n } else {\n appsList\n }\n\n Text(\"Floating applications remain visible across all workspaces.\")\n .foregroundStyle(.secondary)\n .font(.callout)\n }\n\n Section(\"Shortcuts\") {\n hotkey(\"Float Focused App\", for: $settings.floatTheFocusedApp)\n hotkey(\"Unfloat Focused App\", for: $settings.unfloatTheFocusedApp)\n hotkey(\"Toggle Focused App Floating\", for: $settings.toggleTheFocusedAppFloating)\n }\n }\n .formStyle(.grouped)\n .navigationTitle(\"Floating Apps\")\n }\n\n private var appsList: some View {\n VStack(alignment: .leading) {\n ForEach(settings.floatingApps, id: \\.self) { app in\n HStack {\n Button {\n viewModel.deleteFloatingApp(app: app)\n } label: {\n Image(systemName: \"x.circle.fill\").opacity(0.8)\n }.buttonStyle(.borderless)\n\n Text(app.name)\n .foregroundStyle(app.bundleIdentifier.isEmpty ? .errorRed : .primary)\n }\n }\n }\n }\n\n private var header: some View {\n HStack {\n Text(\"Floating Apps\")\n Spacer()\n Button(action: viewModel.addFloatingApp) {\n Image(systemName: \"plus\")\n }\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Workspaces/WorkspaceHotKeys.swift", "//\n// WorkspaceHotKeys.swift\n//\n// Created by Wojciech Kulik on 08/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nfinal class WorkspaceHotKeys {\n private let workspaceManager: WorkspaceManager\n private let workspaceRepository: WorkspaceRepository\n private let workspaceSettings: WorkspaceSettings\n private let floatingAppsSettings: FloatingAppsSettings\n\n init(\n workspaceManager: WorkspaceManager,\n workspaceRepository: WorkspaceRepository,\n settingsRepository: SettingsRepository\n ) {\n self.workspaceManager = workspaceManager\n self.workspaceRepository = workspaceRepository\n self.workspaceSettings = settingsRepository.workspaceSettings\n self.floatingAppsSettings = settingsRepository.floatingAppsSettings\n }\n\n func getHotKeys() -> [(AppHotKey, () -> ())] {\n let hotKeys = [\n getAssignVisibleAppsHotKey(),\n getAssignAppHotKey(for: nil),\n getUnassignAppHotKey(),\n getToggleAssignmentHotKey(),\n getHideUnassignedAppsHotKey(),\n getRecentWorkspaceHotKey(),\n getCycleWorkspacesHotKey(next: false),\n getCycleWorkspacesHotKey(next: true)\n ] +\n workspaceRepository.workspaces\n .flatMap { [getActivateHotKey(for: $0), getAssignAppHotKey(for: $0)] }\n\n return hotKeys.compactMap(\\.self)\n }\n\n private func getActivateHotKey(for workspace: Workspace) -> (AppHotKey, () -> ())? {\n guard let shortcut = workspace.activateShortcut else { return nil }\n\n let action = { [weak self] in\n guard let self, let updatedWorkspace = workspaceRepository.workspaces\n .first(where: { $0.id == workspace.id }) else { return }\n\n if updatedWorkspace.isDynamic, updatedWorkspace.displays.isEmpty {\n Toast.showWith(\n icon: \"square.stack.3d.up\",\n message: \"\\(workspace.name) - No Running Apps To Show\",\n textColor: .gray\n )\n return\n }\n\n workspaceManager.activateWorkspace(updatedWorkspace, setFocus: true)\n }\n\n return (shortcut, action)\n }\n\n private func getAssignVisibleAppsHotKey() -> (AppHotKey, () -> ())? {\n guard let shortcut = workspaceSettings.assignVisibleApps else { return nil }\n\n return (shortcut, { [weak self] in self?.assignVisibleApps() })\n }\n\n private func getAssignAppHotKey(for workspace: Workspace?) -> (AppHotKey, () -> ())? {\n let shortcut = workspace == nil\n ? workspaceSettings.assignFocusedApp\n : workspace?.assignAppShortcut\n\n guard let shortcut else { return nil }\n\n return (shortcut, { [weak self] in self?.assignApp(to: workspace) })\n }\n\n private func getUnassignAppHotKey() -> (AppHotKey, () -> ())? {\n guard let shortcut = workspaceSettings.unassignFocusedApp else { return nil }\n\n return (shortcut, { [weak self] in self?.unassignApp() })\n }\n\n private func getToggleAssignmentHotKey() -> (AppHotKey, () -> ())? {\n guard let shortcut = workspaceSettings.toggleFocusedAppAssignment else { return nil }\n\n let action = { [weak self] in\n guard let self, let activeApp = NSWorkspace.shared.frontmostApplication else { return }\n\n if workspaceRepository.workspaces.flatMap(\\.apps).containsApp(activeApp) {\n unassignApp()\n } else {\n assignApp(to: nil)\n }\n }\n\n return (shortcut, action)\n }\n\n private func getHideUnassignedAppsHotKey() -> (AppHotKey, () -> ())? {\n guard let shortcut = workspaceSettings.hideUnassignedApps else { return nil }\n\n let action = { [weak self] in\n guard let self else { return }\n\n workspaceManager.hideUnassignedApps()\n }\n\n return (shortcut, action)\n }\n\n private func getCycleWorkspacesHotKey(next: Bool) -> (AppHotKey, () -> ())? {\n guard let shortcut = next\n ? workspaceSettings.switchToNextWorkspace\n : workspaceSettings.switchToPreviousWorkspace\n else { return nil }\n\n let action: () -> () = { [weak self] in\n guard let self else { return }\n\n workspaceManager.activateWorkspace(\n next: next,\n skipEmpty: workspaceSettings.skipEmptyWorkspacesOnSwitch,\n loop: workspaceSettings.loopWorkspaces\n )\n }\n\n return (shortcut, action)\n }\n\n private func getRecentWorkspaceHotKey() -> (AppHotKey, () -> ())? {\n guard let shortcut = workspaceSettings.switchToRecentWorkspace else { return nil }\n\n let action: () -> () = { [weak self] in\n self?.workspaceManager.activateRecentWorkspace()\n }\n\n return (shortcut, action)\n }\n}\n\nextension WorkspaceHotKeys {\n private func assignApp(to workspace: Workspace?) {\n guard let activeApp = NSWorkspace.shared.frontmostApplication else { return }\n guard let appName = activeApp.localizedName else { return }\n guard activeApp.activationPolicy == .regular else {\n Alert.showOkAlert(\n title: appName,\n message: \"This application is an agent (runs in background) and cannot be managed by FlashSpace.\"\n )\n return\n }\n\n guard let workspace = workspace ?? workspaceManager.activeWorkspace[activeApp.display ?? \"\"] else {\n Alert.showOkAlert(\n title: \"Error\",\n message: \"No workspace is active on the current display.\"\n )\n return\n }\n\n guard let updatedWorkspace = workspaceRepository.workspaces\n .first(where: { $0.id == workspace.id }) else { return }\n\n workspaceManager.assignApp(activeApp.toMacApp, to: updatedWorkspace)\n\n if !workspace.isDynamic {\n activeApp.centerApp(display: workspace.display)\n }\n\n Toast.showWith(\n icon: \"square.stack.3d.up\",\n message: \"\\(appName) - Assigned To \\(workspace.name)\",\n textColor: .positive\n )\n }\n\n private func assignVisibleApps() {\n guard let display = NSScreen.main?.localizedName else { return }\n guard let workspace = workspaceManager.activeWorkspace[display] else {\n Alert.showOkAlert(\n title: \"Error\",\n message: \"No workspace is active on the current display.\"\n )\n return\n }\n\n let visibleApps = NSWorkspace.shared.runningApplications\n .regularVisibleApps(onDisplays: workspace.displays, excluding: floatingAppsSettings.floatingApps)\n\n workspaceManager.assignApps(visibleApps.map(\\.toMacApp), to: workspace)\n\n Toast.showWith(\n icon: \"square.stack.3d.up\",\n message: \"Assigned \\(visibleApps.count) App(s) To \\(workspace.name)\",\n textColor: .positive\n )\n }\n\n private func unassignApp() {\n guard let activeApp = NSWorkspace.shared.frontmostApplication else { return }\n guard let appName = activeApp.localizedName else { return }\n\n if workspaceRepository.workspaces.flatMap(\\.apps).containsApp(activeApp) == true {\n Toast.showWith(\n icon: \"square.stack.3d.up.slash\",\n message: \"\\(appName) - Removed From Workspaces\",\n textColor: .negative\n )\n }\n\n workspaceRepository.deleteAppFromAllWorkspaces(app: activeApp.toMacApp)\n activeApp.hide()\n NotificationCenter.default.post(name: .appsListChanged, object: nil)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Profiles/ProfilesSettingsViewModel.swift", "//\n// ProfilesSettingsViewModel.swift\n//\n// Created by Wojciech Kulik on 26/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nfinal class ProfilesSettingsViewModel: ObservableObject {\n enum Action {\n case createProfile\n case renameProfile(ProfileId)\n case deleteProfile(ProfileId)\n }\n\n @Published var isInputDialogPresented = false\n @Published var isDeleteConfirmationPresented = false\n @Published var isCopyChoicePresented = false\n @Published var profileToDelete = \"\"\n @Published var userInput = \"\"\n\n var hideDeleteButton: Bool { profilesRepository.profiles.count == 1 }\n\n private var action: Action?\n\n private let profilesRepository = AppDependencies.shared.profilesRepository\n\n func createNewProfile() {\n action = .createProfile\n userInput = \"\"\n isInputDialogPresented = true\n }\n\n func createNewProfile(copyWorkspaces: Bool) {\n let input = userInput.trimmingCharacters(in: .whitespacesAndNewlines)\n guard !input.isEmpty else { return }\n\n profilesRepository.createProfile(name: input, keepWorkspaces: copyWorkspaces)\n }\n\n func renameProfile(_ profile: Profile) {\n action = .renameProfile(profile.id)\n userInput = profile.name\n isInputDialogPresented = true\n }\n\n func deleteProfile(_ profile: Profile) {\n action = .deleteProfile(profile.id)\n profileToDelete = profile.name\n isDeleteConfirmationPresented = true\n }\n\n func inputDialogDismissed() {\n let input = userInput.trimmingCharacters(in: .whitespacesAndNewlines)\n guard let action, !input.isEmpty else { return }\n\n switch action {\n case .createProfile:\n isCopyChoicePresented = true\n case .renameProfile(let id):\n profilesRepository.renameProfile(id: id, to: input)\n case .deleteProfile:\n break\n }\n }\n\n func deleteConfirmed() {\n guard let action else { return }\n\n switch action {\n case .deleteProfile(let id):\n profilesRepository.deleteProfile(id: id)\n default:\n break\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Gestures/SwipeManager.swift", "//\n// SwipeManager.swift\n//\n// Created by Wojciech Kulik on 22/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n// Based on: https://github.com/MediosZ/SwipeAeroSpace\n\nimport AppKit\nimport Combine\n\nfinal class SwipeManager {\n typealias TouchId = ObjectIdentifier\n\n enum Constants {\n static let minFingerCount = 3\n static let maxFingerCount = 4\n }\n\n enum GestureState {\n case idle\n case inProgress\n case ended\n }\n\n static let shared = SwipeManager()\n\n private var swipeThreshold: Double { gesturesSettings.swipeThreshold }\n\n private var eventTap: CFMachPort?\n private var xTouchDistance: [TouchId: CGFloat] = [:]\n private var yTouchDistance: [TouchId: CGFloat] = [:]\n private var prevTouchPositions: [TouchId: NSPoint] = [:]\n private var lastTouchDate = Date.distantPast\n private var state: GestureState = .ended\n private var systemWakeUpObserver: AnyCancellable?\n\n private lazy var gesturesSettings = AppDependencies.shared.gesturesSettings\n private lazy var workspaceSettings = AppDependencies.shared.workspaceSettings\n private lazy var workspaceManager = AppDependencies.shared.workspaceManager\n private lazy var workspaceRepository = AppDependencies.shared.workspaceRepository\n private lazy var focusManager = AppDependencies.shared.focusManager\n\n func start() {\n guard eventTap == nil else {\n return Logger.log(\"SwipeManager is already started\")\n }\n\n eventTap = CGEvent.tapCreate(\n tap: .cghidEventTap,\n place: .headInsertEventTap,\n options: .defaultTap,\n eventsOfInterest: NSEvent.EventTypeMask.gesture.rawValue,\n callback: { proxy, type, cgEvent, userInfo in\n SwipeManager.shared.eventHandler(\n proxy: proxy,\n eventType: type,\n cgEvent: cgEvent,\n userInfo: userInfo\n )\n },\n userInfo: nil\n )\n\n guard let eventTap else {\n return Logger.log(\"SwipeManager couldn't create event tap\")\n }\n\n Logger.log(\"SwipeManager started\")\n\n let runLoopSource = CFMachPortCreateRunLoopSource(nil, eventTap, 0)\n CFRunLoopAddSource(\n CFRunLoopGetCurrent(),\n runLoopSource,\n CFRunLoopMode.commonModes\n )\n CGEvent.tapEnable(tap: eventTap, enable: true)\n\n observeSystemWakeUp()\n }\n\n func stop() {\n guard let eventTap else { return }\n\n CGEvent.tapEnable(tap: eventTap, enable: false)\n CFRunLoopRemoveSource(\n CFRunLoopGetCurrent(),\n CFMachPortCreateRunLoopSource(nil, eventTap, 0),\n CFRunLoopMode.commonModes\n )\n CFMachPortInvalidate(eventTap)\n self.eventTap = nil\n\n systemWakeUpObserver?.cancel()\n systemWakeUpObserver = nil\n\n Logger.log(\"SwipeManager stopped\")\n }\n\n func eventHandler(\n proxy: CGEventTapProxy,\n eventType: CGEventType,\n cgEvent: CGEvent,\n userInfo: UnsafeMutableRawPointer?\n ) -> Unmanaged? {\n if eventType.rawValue == NSEvent.EventType.gesture.rawValue,\n let nsEvent = NSEvent(cgEvent: cgEvent) {\n handleGesture(nsEvent)\n } else if eventType == .tapDisabledByUserInput || eventType == .tapDisabledByTimeout {\n Logger.log(\"SwipeManager tap disabled \\(eventType)\")\n if let eventTap {\n CGEvent.tapEnable(tap: eventTap, enable: true)\n }\n }\n\n return Unmanaged.passUnretained(cgEvent)\n }\n\n private func handleGesture(_ nsEvent: NSEvent) {\n let touches = nsEvent.allTouches()\n .filter { !$0.isResting && $0.phase != .stationary }\n\n if touches.count == 0 || Date().timeIntervalSince(lastTouchDate) > 0.8 {\n state = .idle\n }\n\n guard touches.count >= Constants.minFingerCount,\n gesturesSettings.isHorizontalSwipeSet || gesturesSettings.isVerticalSwipeSet\n else { return }\n\n if state == .idle {\n state = .inProgress\n xTouchDistance = [:]\n yTouchDistance = [:]\n prevTouchPositions = [:]\n }\n if state == .inProgress {\n lastTouchDate = Date()\n handleSwipe(touches: touches)\n }\n }\n\n private func handleSwipe(touches: Set) {\n updateSwipeDistance(touches: touches)\n handleHorizontalSwipe()\n handleVerticalSwipe()\n }\n\n private func handleHorizontalSwipe() {\n guard state == .inProgress else { return }\n guard gesturesSettings.isHorizontalSwipeSet else { return }\n\n let swipes = xTouchDistance.values\n let allMovedRight = swipes.allSatisfy { $0 > 0 }\n let allMovedLeft = swipes.allSatisfy { $0 < 0 }\n let minFingerContribution = swipeThreshold / (CGFloat(swipes.count) + 2.0)\n\n guard (Constants.minFingerCount...Constants.maxFingerCount).contains(swipes.count),\n swipes.allSatisfy({ abs($0) > minFingerContribution }),\n abs(swipes.reduce(0.0, +)) >= swipeThreshold,\n allMovedLeft || allMovedRight else { return }\n\n let action = if allMovedRight {\n swipes.count == 3 ? gesturesSettings.swipeRight3FingerAction : gesturesSettings.swipeRight4FingerAction\n } else if allMovedLeft {\n swipes.count == 3 ? gesturesSettings.swipeLeft3FingerAction : gesturesSettings.swipeLeft4FingerAction\n } else {\n GestureAction.none\n }\n\n state = .ended\n callAction(action)\n Logger.log(\"Horizontal swipe detected\")\n }\n\n private func handleVerticalSwipe() {\n guard state == .inProgress else { return }\n guard gesturesSettings.isVerticalSwipeSet else { return }\n\n let swipes = yTouchDistance.values\n let allMovedUp = swipes.allSatisfy { $0 > 0 }\n let allMovedDown = swipes.allSatisfy { $0 < 0 }\n let minFingerContribution = swipeThreshold / (CGFloat(swipes.count) + 2.0)\n\n guard (Constants.minFingerCount...Constants.maxFingerCount).contains(swipes.count),\n swipes.allSatisfy({ abs($0) > minFingerContribution }),\n abs(swipes.reduce(0.0, +)) >= swipeThreshold,\n allMovedUp || allMovedDown else { return }\n\n let action = if allMovedUp {\n swipes.count == 3 ? gesturesSettings.swipeUp3FingerAction : gesturesSettings.swipeUp4FingerAction\n } else if allMovedDown {\n swipes.count == 3 ? gesturesSettings.swipeDown3FingerAction : gesturesSettings.swipeDown4FingerAction\n } else {\n GestureAction.none\n }\n\n state = .ended\n callAction(action)\n Logger.log(\"Vertical swipe detected\")\n }\n\n private func updateSwipeDistance(touches: Set) {\n for touch in touches {\n let (distanceX, distanceY) = touchDistance(touch)\n\n if abs(distanceX) > abs(distanceY) {\n xTouchDistance[ObjectIdentifier(touch.identity), default: 0.0] += distanceX\n } else {\n yTouchDistance[ObjectIdentifier(touch.identity), default: 0.0] += distanceY\n }\n\n prevTouchPositions[ObjectIdentifier(touch.identity)] = touch.normalizedPosition\n }\n }\n\n private func touchDistance(_ touch: NSTouch) -> (CGFloat, CGFloat) {\n guard let prevPosition = prevTouchPositions[ObjectIdentifier(touch.identity)] else {\n return (0.0, 0.0)\n }\n\n return (\n touch.normalizedPosition.x - prevPosition.x,\n touch.normalizedPosition.y - prevPosition.y\n )\n }\n\n // swiftlint:disable:next cyclomatic_complexity\n private func callAction(_ action: GestureAction) {\n let skipEmpty = workspaceSettings.skipEmptyWorkspacesOnSwitch\n let loop = workspaceSettings.loopWorkspaces\n\n switch action {\n case .none: break\n case .toggleSpaceControl: SpaceControl.toggle()\n case .showSpaceControl: SpaceControl.show()\n case .hideSpaceControl: SpaceControl.hide()\n case .nextWorkspace: workspaceManager.activateWorkspace(next: true, skipEmpty: skipEmpty, loop: loop)\n case .previousWorkspace: workspaceManager.activateWorkspace(next: false, skipEmpty: skipEmpty, loop: loop)\n case .mostRecentWorkspace: workspaceManager.activateRecentWorkspace()\n case .focusLeft: focusManager.focusLeft()\n case .focusRight: focusManager.focusRight()\n case .focusUp: focusManager.focusUp()\n case .focusDown: focusManager.focusDown()\n case .focusNextApp: focusManager.nextWorkspaceApp()\n case .focusPreviousApp: focusManager.previousWorkspaceApp()\n case .focusNextWindow: focusManager.nextWorkspaceWindow()\n case .focusPreviousWindow: focusManager.previousWorkspaceWindow()\n case .activateWorkspace(let workspaceName):\n if let workspace = workspaceRepository.workspaces.first(where: { $0.name == workspaceName }) {\n workspaceManager.activateWorkspace(workspace, setFocus: true)\n }\n }\n }\n}\n\nextension SwipeManager {\n func restartAppIfNeeded() {\n guard gesturesSettings.restartAppOnWakeUp else { return }\n\n let task = Process()\n task.launchPath = \"/bin/sh\"\n task.arguments = [\"-c\", \"sleep 1; open '\\(Bundle.main.bundlePath)'\"]\n task.launch()\n\n NSApp.terminate(self)\n exit(0)\n }\n\n private func observeSystemWakeUp() {\n systemWakeUpObserver = NSWorkspace.shared.notificationCenter\n .publisher(for: NSWorkspace.didWakeNotification)\n .sink { [weak self] _ in self?.restartAppIfNeeded() }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/SettingsRepository.swift", "//\n// SettingsRepository.swift\n//\n// Created by Wojciech Kulik on 23/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nfinal class SettingsRepository: ObservableObject {\n private(set) var generalSettings: GeneralSettings\n private(set) var menuBarSettings: MenuBarSettings\n private(set) var gesturesSettings: GesturesSettings\n private(set) var focusManagerSettings: FocusManagerSettings\n private(set) var workspaceSettings: WorkspaceSettings\n private(set) var floatingAppsSettings: FloatingAppsSettings\n private(set) var spaceControlSettings: SpaceControlSettings\n private(set) var integrationsSettings: IntegrationsSettings\n\n private lazy var allSettings: [SettingsProtocol] = [\n generalSettings,\n menuBarSettings,\n gesturesSettings,\n focusManagerSettings,\n workspaceSettings,\n floatingAppsSettings,\n spaceControlSettings,\n integrationsSettings\n ]\n\n private var currentSettings = AppSettings()\n private var cancellables = Set()\n private var shouldUpdate = false\n\n init(\n generalSettings: GeneralSettings,\n menuBarSettings: MenuBarSettings,\n gesturesSettings: GesturesSettings,\n focusManagerSettings: FocusManagerSettings,\n workspaceSettings: WorkspaceSettings,\n floatingAppsSettings: FloatingAppsSettings,\n spaceControlSettings: SpaceControlSettings,\n integrationsSettings: IntegrationsSettings\n ) {\n self.generalSettings = generalSettings\n self.menuBarSettings = menuBarSettings\n self.gesturesSettings = gesturesSettings\n self.focusManagerSettings = focusManagerSettings\n self.workspaceSettings = workspaceSettings\n self.floatingAppsSettings = floatingAppsSettings\n self.spaceControlSettings = spaceControlSettings\n self.integrationsSettings = integrationsSettings\n\n loadFromDisk()\n\n Publishers.MergeMany(allSettings.map(\\.updatePublisher))\n .sink { [weak self] in self?.updateSettings() }\n .store(in: &cancellables)\n }\n\n func saveToDisk() {\n Logger.log(\"Saving settings to disk\")\n try? ConfigSerializer.serialize(filename: \"settings\", currentSettings)\n }\n\n private func updateSettings() {\n guard shouldUpdate else { return }\n\n var settings = AppSettings()\n allSettings.forEach { $0.update(&settings) }\n currentSettings = settings\n saveToDisk()\n\n AppDependencies.shared.hotKeysManager.refresh()\n objectWillChange.send()\n }\n\n private func loadFromDisk() {\n Logger.log(\"Loading settings from disk\")\n\n shouldUpdate = false\n defer { shouldUpdate = true }\n\n guard let settings = try? ConfigSerializer.deserialize(\n AppSettings.self,\n filename: \"settings\"\n ) else { return }\n\n currentSettings = settings\n allSettings.forEach { $0.load(from: settings) }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/MenuBar/MenuBarTitle.swift", "//\n// MenuBarTitle.swift\n//\n// Created by Wojciech Kulik on 31/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nenum MenuBarTitle {\n static let settings = AppDependencies.shared.menuBarSettings\n static let workspaceManager = AppDependencies.shared.workspaceManager\n static let profilesRepository = AppDependencies.shared.profilesRepository\n\n static func get() -> String? {\n let template = settings.menuBarTitleTemplate.trimmingCharacters(in: .whitespaces)\n\n guard settings.showMenuBarTitle, !template.isEmpty else { return nil }\n guard let activeWorkspace = workspaceManager.activeWorkspaceDetails else { return nil }\n\n return template\n .replacingOccurrences(of: \"$WORKSPACE_NUMBER\", with: activeWorkspace.number ?? \"\")\n .replacingOccurrences(of: \"$WORKSPACE\", with: activeWorkspace.name)\n .replacingOccurrences(of: \"$DISPLAY\", with: getDisplayName())\n .replacingOccurrences(of: \"$PROFILE\", with: profilesRepository.selectedProfile.name)\n }\n\n private static func getDisplayName() -> String {\n let aliases = settings.menuBarDisplayAliases\n .split(separator: \";\")\n .map { $0.split(separator: \"=\") }\n .reduce(into: [String: String]()) { result, pair in\n guard pair.count == 2 else { return }\n\n result[String(pair[0]).lowercased()] = String(pair[1])\n }\n\n let display = workspaceManager.activeWorkspaceDetails?.display ?? \"\"\n\n return aliases[display.lowercased()] ?? display\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Workspaces/Models/Workspace.swift", "//\n// Workspace.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\n\ntypealias WorkspaceID = UUID\n\nstruct Workspace: Identifiable, Codable, Hashable {\n enum CodingKeys: String, CodingKey {\n case id\n case name\n case display\n case activateShortcut = \"shortcut\"\n case assignAppShortcut\n case apps\n case appToFocus\n case symbolIconName\n }\n\n var id: WorkspaceID\n var name: String\n var display: DisplayName\n var activateShortcut: AppHotKey?\n var assignAppShortcut: AppHotKey?\n var apps: [MacApp]\n var appToFocus: MacApp?\n var symbolIconName: String?\n}\n\nextension Workspace {\n var displays: Set {\n if NSScreen.screens.count == 1 {\n return [NSScreen.main?.localizedName ?? \"\"]\n } else if isDynamic {\n // TODO: After disconnecting a display, the detection may not work correctly.\n // The app will have the old coordinates until it is shown again, which\n // prevents from detecting the correct display.\n //\n // The workaround is to activate the app manually to update its frame.\n return NSWorkspace.shared.runningApplications\n .filter { $0.activationPolicy == .regular && apps.containsApp($0) }\n .flatMap(\\.allDisplays)\n .asSet\n } else {\n return [displayManager.resolveDisplay(display)]\n }\n }\n\n var displayForPrint: DisplayName {\n if isDynamic,\n let mainDisplay = NSScreen.main?.localizedName,\n displays.contains(mainDisplay) {\n return mainDisplay\n }\n\n return isDynamic\n ? displayManager.lastActiveDisplay(from: displays)\n : displayManager.resolveDisplay(display)\n }\n\n var isOnTheCurrentScreen: Bool {\n guard let currentScreen = NSScreen.main?.localizedName else { return false }\n return displays.contains(currentScreen)\n }\n\n var isDynamic: Bool {\n AppDependencies.shared.workspaceSettings.displayMode == .dynamic\n }\n\n private var displayManager: DisplayManager {\n AppDependencies.shared.displayManager\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/FocusManager/FocusSettingsView.swift", "//\n// FocusSettingsView.swift\n//\n// Created by Wojciech Kulik on 23/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct FocusSettingsView: View {\n @StateObject private var settings = AppDependencies.shared.focusManagerSettings\n\n var body: some View {\n Form {\n Section {\n Toggle(\"Enable Focus Manager\", isOn: $settings.enableFocusManagement)\n }\n\n Group {\n Section(\"Trigger when focus is changed using shortcuts\") {\n Toggle(\"Center Cursor In Focused App\", isOn: $settings.centerCursorOnFocusChange)\n }\n\n Section(\"Shortcuts\") {\n hotkey(\"Focus Left\", for: $settings.focusLeft)\n hotkey(\"Focus Right\", for: $settings.focusRight)\n hotkey(\"Focus Up\", for: $settings.focusUp)\n hotkey(\"Focus Down\", for: $settings.focusDown)\n }\n\n Section {\n hotkey(\"Focus Next App\", for: $settings.focusNextWorkspaceApp)\n hotkey(\"Focus Previous App\", for: $settings.focusPreviousWorkspaceApp)\n }\n\n Section {\n hotkey(\"Focus Next Window\", for: $settings.focusNextWorkspaceWindow)\n hotkey(\"Focus Previous Window\", for: $settings.focusPreviousWorkspaceWindow)\n }\n\n Section(\"Experimental\") {\n Toggle(\"Focus Frontmost Window\", isOn: $settings.focusFrontmostWindow)\n Text(\n \"This is an experimental feature. It sets the focus to the frontmost window\" +\n \" if two or more windows are overlapping in the pointed direction.\\n\\n\" +\n \"It works only with directional focus shortcuts (left, right, up, down).\"\n )\n .foregroundStyle(.secondary)\n .font(.callout)\n }\n }\n .disabled(!settings.enableFocusManagement)\n .opacity(settings.enableFocusManagement ? 1 : 0.5)\n }\n .formStyle(.grouped)\n .navigationTitle(\"Focus Manager\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/URL.swift", "//\n// URL.swift\n//\n// Created by Wojciech Kulik on 26/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nextension URL {\n var bundle: Bundle? { Bundle(url: self) }\n var fileName: String { lastPathComponent.replacingOccurrences(of: \".app\", with: \"\") }\n var appName: String { bundle?.localizedAppName ?? fileName }\n var bundleIdentifier: BundleId? { bundle?.bundleIdentifier }\n var iconPath: String? { bundle?.iconPath }\n\n func createIntermediateDirectories() throws {\n try FileManager.default.createDirectory(\n at: deletingLastPathComponent(),\n withIntermediateDirectories: true\n )\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/FocusManager/FocusedWindowTracker.swift", "//\n// FocusedWindowTracker.swift\n//\n// Created by Wojciech Kulik on 20/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Combine\n\nfinal class FocusedWindowTracker {\n private var cancellables = Set()\n\n private let workspaceRepository: WorkspaceRepository\n private let workspaceManager: WorkspaceManager\n private let settingsRepository: SettingsRepository\n private let pictureInPictureManager: PictureInPictureManager\n\n init(\n workspaceRepository: WorkspaceRepository,\n workspaceManager: WorkspaceManager,\n settingsRepository: SettingsRepository,\n pictureInPictureManager: PictureInPictureManager\n ) {\n self.workspaceRepository = workspaceRepository\n self.workspaceManager = workspaceManager\n self.settingsRepository = settingsRepository\n self.pictureInPictureManager = pictureInPictureManager\n }\n\n func startTracking() {\n NSWorkspace.shared.notificationCenter\n .publisher(for: NSWorkspace.didActivateApplicationNotification)\n .compactMap { $0.userInfo?[NSWorkspace.applicationUserInfoKey] as? NSRunningApplication }\n .removeDuplicates()\n .sink { [weak self] app in self?.activeApplicationChanged(app) }\n .store(in: &cancellables)\n }\n\n func stopTracking() {\n cancellables.removeAll()\n }\n\n private func activeApplicationChanged(_ app: NSRunningApplication) {\n guard settingsRepository.workspaceSettings.activeWorkspaceOnFocusChange else { return }\n\n let activeWorkspaces = workspaceManager.activeWorkspace.values\n\n // Skip if the workspace was activated recently\n guard Date().timeIntervalSince(workspaceManager.lastWorkspaceActivation) > 0.2 else { return }\n\n // Skip if the app is floating\n guard !settingsRepository.floatingAppsSettings.floatingApps.containsApp(app) else { return }\n\n // Find the workspace that contains the app.\n // The same app can be in multiple workspaces, the highest priority has the one\n // from the active workspace.\n guard let workspace = (activeWorkspaces + workspaceRepository.workspaces)\n .first(where: { $0.apps.containsApp(app) }) else { return }\n\n // Skip if the workspace is already active\n guard activeWorkspaces.count(where: { $0.id == workspace.id }) < workspace.displays.count else { return }\n\n // Skip if the focused window is in Picture in Picture mode\n guard !settingsRepository.workspaceSettings.enablePictureInPictureSupport ||\n !app.supportsPictureInPicture ||\n app.focusedWindow?.isPictureInPicture(bundleId: app.bundleIdentifier) != true else { return }\n\n let activate = { [self] in\n Logger.log(\"\")\n Logger.log(\"\")\n Logger.log(\"Activating workspace for app: \\(workspace.name)\")\n workspaceManager.updateLastFocusedApp(app.toMacApp, in: workspace)\n workspaceManager.activateWorkspace(workspace, setFocus: false)\n app.activate()\n\n // Restore the app if it was hidden\n if settingsRepository.workspaceSettings.enablePictureInPictureSupport, app.supportsPictureInPicture {\n pictureInPictureManager.restoreAppIfNeeded(app: app)\n }\n }\n\n if workspace.isDynamic, workspace.displays.isEmpty {\n DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(500)) {\n activate()\n }\n } else {\n activate()\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Models/CreateWorkspaceRequest.swift", "//\n// CreateWorkspaceRequest.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\n\nstruct CreateWorkspaceRequest: Codable {\n let name: String\n let display: String?\n let icon: String?\n let activateKey: String?\n let assignKey: String?\n let activate: Bool\n}\n\nextension CreateWorkspaceRequest {\n var toWorkspace: Workspace {\n Workspace(\n id: .init(),\n name: name,\n display: display ?? NSScreen.main?.localizedName ?? \"\",\n activateShortcut: activateKey.flatMap { .init(value: $0) },\n assignAppShortcut: assignKey.flatMap { .init(value: $0) },\n apps: [],\n appToFocus: nil,\n symbolIconName: icon\n )\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Gestures/GesturesSettingsView.swift", "//\n// GesturesSettingsView.swift\n//\n// Created by Wojciech Kulik on 21/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct GesturesSettingsView: View {\n @StateObject private var settings = AppDependencies.shared.gesturesSettings\n\n var body: some View {\n Form {\n Section {\n Toggle(\"Enable Swipe Gestures\", isOn: $settings.enableSwipeGestures)\n HStack {\n Text(\"Activation Threshold\")\n Spacer()\n Text(\"\\(settings.swipeThreshold, specifier: \"%.2f\")\")\n Stepper(\n \"\",\n value: $settings.swipeThreshold,\n in: 0.05...0.7,\n step: 0.05\n ).labelsHidden()\n }\n Text(\"Remember to disable system gestures in System Preferences > Trackpad > More Gestures.\")\n .font(.callout)\n .foregroundStyle(.secondary)\n Text(\n \"Keeping \\\"Swipe between full-screen apps\\\" enabled prevents from detecting swipe gesture as \" +\n \"a scroll action. However, you must keep only one macOS Space to avoid switching.\"\n )\n .font(.callout)\n .foregroundStyle(.secondary)\n }\n\n Section(\"Horizontal Swipes\") {\n Picker(\"3-Finger Left Swipe\", selection: $settings.swipeLeft3FingerAction) {\n ForEach(GestureAction.allCases) { action in\n Text(action.description).tag(action)\n }\n }\n Picker(\"3-Finger Right Swipe\", selection: $settings.swipeRight3FingerAction) {\n ForEach(GestureAction.allCases) { action in\n Text(action.description).tag(action)\n }\n }\n Picker(\"4-Finger Left Swipe\", selection: $settings.swipeLeft4FingerAction) {\n ForEach(GestureAction.allCases) { action in\n Text(action.description).tag(action)\n }\n }\n Picker(\"4-Finger Right Swipe\", selection: $settings.swipeRight4FingerAction) {\n ForEach(GestureAction.allCases) { action in\n Text(action.description).tag(action)\n }\n }\n }\n .disabled(!settings.enableSwipeGestures)\n .opacity(settings.enableSwipeGestures ? 1 : 0.5)\n\n Section(\"Vertical Swipes\") {\n Picker(\"3-Finger Up Swipe\", selection: $settings.swipeUp3FingerAction) {\n ForEach(GestureAction.allCases) { action in\n Text(action.description).tag(action)\n }\n }\n Picker(\"3-Finger Down Swipe\", selection: $settings.swipeDown3FingerAction) {\n ForEach(GestureAction.allCases) { action in\n Text(action.description).tag(action)\n }\n }\n Picker(\"4-Finger Up Swipe\", selection: $settings.swipeUp4FingerAction) {\n ForEach(GestureAction.allCases) { action in\n Text(action.description).tag(action)\n }\n }\n Picker(\"4-Finger Down Swipe\", selection: $settings.swipeDown4FingerAction) {\n ForEach(GestureAction.allCases) { action in\n Text(action.description).tag(action)\n }\n }\n }\n .disabled(!settings.enableSwipeGestures)\n .opacity(settings.enableSwipeGestures ? 1 : 0.5)\n\n Section(\"System\") {\n Toggle(\"Restart App On Wake Up\", isOn: $settings.restartAppOnWakeUp)\n Text(\n \"Restarts the app when your Mac wakes up from sleep. This can help with gesture recognition issues after waking.\"\n )\n .font(.callout)\n .foregroundStyle(.secondary)\n }\n .disabled(!settings.enableSwipeGestures)\n .opacity(settings.enableSwipeGestures ? 1 : 0.5)\n }\n .formStyle(.grouped)\n .navigationTitle(\"Gestures\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/FloatingApps/FloatingAppsHotKeys.swift", "//\n// FloatingAppsHotKeys.swift\n//\n// Created by Wojciech Kulik on 16/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nfinal class FloatingAppsHotKeys {\n private let workspaceManager: WorkspaceManager\n private let floatingAppsSettings: FloatingAppsSettings\n\n init(\n workspaceManager: WorkspaceManager,\n settingsRepository: SettingsRepository\n ) {\n self.workspaceManager = workspaceManager\n self.floatingAppsSettings = settingsRepository.floatingAppsSettings\n }\n\n func getHotKeys() -> [(AppHotKey, () -> ())] {\n let hotKeys = [\n getFloatTheFocusedAppHotKey(),\n getUnfloatTheFocusedAppHotKey(),\n getToggleTheFocusedAppFloatingHotKey()\n ]\n\n return hotKeys.compactMap(\\.self)\n }\n\n private func getFloatTheFocusedAppHotKey() -> (AppHotKey, () -> ())? {\n guard let shortcut = floatingAppsSettings.floatTheFocusedApp else { return nil }\n\n return (shortcut, { [weak self] in self?.floatApp() })\n }\n\n private func getUnfloatTheFocusedAppHotKey() -> (AppHotKey, () -> ())? {\n guard let shortcut = floatingAppsSettings.unfloatTheFocusedApp else { return nil }\n\n return (shortcut, { [weak self] in self?.unfloatApp() })\n }\n\n private func getToggleTheFocusedAppFloatingHotKey() -> (AppHotKey, () -> ())? {\n guard let shortcut = floatingAppsSettings.toggleTheFocusedAppFloating else { return nil }\n\n let action = { [weak self] in\n guard let self, let activeApp = NSWorkspace.shared.frontmostApplication else { return }\n\n if floatingAppsSettings.floatingApps.containsApp(activeApp) {\n unfloatApp()\n } else {\n floatApp()\n }\n }\n return (shortcut, action)\n }\n}\n\nextension FloatingAppsHotKeys {\n private func floatApp() {\n guard let activeApp = NSWorkspace.shared.frontmostApplication,\n let appName = activeApp.localizedName else { return }\n\n floatingAppsSettings.addFloatingAppIfNeeded(app: activeApp.toMacApp)\n Toast.showWith(\n icon: \"macwindow.on.rectangle\",\n message: \"\\(appName) - Added To Floating Apps\",\n textColor: .positive\n )\n }\n\n private func unfloatApp() {\n guard let activeApp = NSWorkspace.shared.frontmostApplication,\n let appName = activeApp.localizedName else { return }\n\n if floatingAppsSettings.floatingApps.containsApp(activeApp) {\n Toast.showWith(\n icon: \"macwindow\",\n message: \"\\(appName) - Removed From Floating Apps\",\n textColor: .negative\n )\n }\n\n floatingAppsSettings.deleteFloatingApp(app: activeApp.toMacApp)\n\n guard let screen = activeApp.display else { return }\n\n if workspaceManager.activeWorkspace[screen]?.apps.containsApp(activeApp) != true {\n activeApp.hide()\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/SpaceControl/Views/SpaceControlView.swift", "//\n// SpaceControlView.swift\n//\n// Created by Wojciech Kulik on 11/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct SpaceControlView: View {\n @Environment(\\.colorScheme) var colorScheme\n @StateObject var viewModel = SpaceControlViewModel()\n\n var body: some View {\n let columns = Array(repeating: GridItem(.flexible()), count: viewModel.numberOfColumns)\n let width = (NSScreen.main?.frame.width ?? 1200) / CGFloat(viewModel.numberOfColumns) - 70.0\n let height = (NSScreen.main?.frame.height ?? 800) / CGFloat(viewModel.numberOfRows) - 120.0\n\n LazyVGrid(columns: columns, spacing: viewModel.numberOfRows == 2 ? 90.0 : 60.0) {\n ForEach(viewModel.workspaces, id: \\.index) { workspace in\n VStack(alignment: .leading, spacing: 16.0) {\n workspaceName(workspace)\n\n Group {\n if let image = workspace.screenshotData.flatMap(NSImage.init(data:)) {\n workspacePreview(image: image, width: width, height: height)\n } else {\n workspacePlaceholder(width: width, height: height)\n }\n }\n .overlay(alignment: .topTrailing) { workspaceNumber(workspace.index + 1) }\n .overlay(\n RoundedRectangle(cornerRadius: 18.0)\n .stroke(\n workspace.isActive\n ? workspace.originalWorkspace.isOnTheCurrentScreen\n ? Color.positive\n : Color.teal\n : Color.black.opacity(0.8),\n lineWidth: 3.0\n )\n )\n .compositingGroup()\n .shadow(\n color: .black.opacity(workspace.screenshotData != nil ? 0.8 : 0.0),\n radius: 20.0,\n x: 0.0,\n y: 0.0\n )\n }\n .onTapGesture { viewModel.onWorkspaceTap(workspace) }\n }\n }\n .multilineTextAlignment(.center)\n .padding()\n .frame(maxWidth: .infinity, maxHeight: .infinity)\n }\n\n private func workspacePreview(image: NSImage, width: CGFloat, height: CGFloat) -> some View {\n Image(nsImage: image)\n .resizable()\n .scaledToFit()\n .frame(maxWidth: width, maxHeight: height)\n .aspectRatio(16.0 / 9.0, contentMode: .fit)\n .background(Color.black.opacity(0.4))\n .clipShape(RoundedRectangle(cornerRadius: 18.0))\n }\n\n private func workspacePlaceholder(width: CGFloat, height: CGFloat) -> some View {\n RoundedRectangle(cornerRadius: 18.0)\n .fill(Color.black.opacity(0.5))\n .frame(maxWidth: width, maxHeight: height)\n .aspectRatio(16.0 / 9.0, contentMode: .fit)\n .overlay {\n Text(\"Preview Not Available\")\n .font(.title)\n .foregroundColor(.white)\n .padding()\n .frame(maxWidth: .infinity, maxHeight: .infinity)\n }\n .clipped()\n }\n\n private func workspaceName(_ workspace: SpaceControlWorkspace) -> some View {\n HStack(spacing: 16.0) {\n Image(systemName: workspace.symbol)\n .resizable()\n .scaledToFit()\n .frame(height: 17.0)\n .foregroundColor(colorScheme == .dark ? .workspaceIcon : .primary)\n\n Text(workspace.name)\n .foregroundColor(.primary)\n .font(.title2)\n }\n .fontWeight(.semibold)\n .lineLimit(1)\n .compositingGroup()\n .shadow(\n color: .black.opacity(colorScheme == .dark ? 0.8 : 0.25),\n radius: 4.0,\n x: 0.0,\n y: 0.0\n )\n }\n\n private func workspaceNumber(_ number: Int) -> some View {\n Text(\"\\(number)\")\n .foregroundColor(.white)\n .font(.title3)\n .frame(width: 40.0)\n .padding(.vertical, 8.0)\n .background(Color.black)\n .cornerRadius(18.0, corners: [.topRight])\n .cornerRadius(8.0, corners: [.bottomLeft])\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Workspaces/WorkspaceSettingsViewModel.swift", "//\n// WorkspaceSettingsViewModel.swift\n//\n// Created by Wojciech Kulik on 22/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nfinal class WorkspaceSettingsViewModel: ObservableObject {\n @Published var windowTitleRegex = \"\"\n @Published var isInputDialogPresented = false {\n didSet {\n if !isInputDialogPresented, windowTitleRegex.isNotEmpty {\n addPendingPipApp()\n windowTitleRegex = \"\"\n }\n }\n }\n\n private var pendingApp: PipApp?\n private let settings = AppDependencies.shared.workspaceSettings\n\n func addPipApp() {\n let fileChooser = FileChooser()\n let appUrl = fileChooser.runModalOpenPanel(\n allowedFileTypes: [.application],\n directoryURL: URL(filePath: \"/Applications\")\n )\n\n guard let bundle = appUrl?.bundle else { return }\n\n pendingApp = PipApp(\n name: bundle.localizedAppName,\n bundleIdentifier: bundle.bundleIdentifier ?? \"\",\n pipWindowTitleRegex: \"\"\n )\n isInputDialogPresented = true\n }\n\n func deletePipApp(_ app: PipApp) {\n settings.deletePipApp(app)\n }\n\n private func addPendingPipApp() {\n guard let pendingApp else { return }\n\n settings.addPipApp(\n .init(\n name: pendingApp.name,\n bundleIdentifier: pendingApp.bundleIdentifier,\n pipWindowTitleRegex: windowTitleRegex\n )\n )\n self.pendingApp = nil\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Workspaces/WorkspaceSettings.swift", "//\n// WorkspaceSettings.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nfinal class WorkspaceSettings: ObservableObject {\n @Published var displayMode: DisplayMode = .static\n\n @Published var centerCursorOnWorkspaceChange = false\n @Published var changeWorkspaceOnAppAssign = true\n @Published var activeWorkspaceOnFocusChange = true\n @Published var skipEmptyWorkspacesOnSwitch = false\n @Published var keepUnassignedAppsOnSwitch = false\n @Published var restoreHiddenAppsOnSwitch = true\n @Published var enableWorkspaceTransitions = false\n @Published var workspaceTransitionDuration = 0.3\n @Published var workspaceTransitionDimming = 0.2\n\n @Published var assignFocusedApp: AppHotKey?\n @Published var unassignFocusedApp: AppHotKey?\n @Published var toggleFocusedAppAssignment: AppHotKey?\n @Published var assignVisibleApps: AppHotKey?\n @Published var hideUnassignedApps: AppHotKey?\n\n @Published var loopWorkspaces = true\n @Published var switchToRecentWorkspace: AppHotKey?\n @Published var switchToPreviousWorkspace: AppHotKey?\n @Published var switchToNextWorkspace: AppHotKey?\n\n @Published var alternativeDisplays = \"\"\n\n @Published var enablePictureInPictureSupport = true\n @Published var switchWorkspaceWhenPipCloses = true\n @Published var pipScreenCornerOffset = 15\n @Published var pipApps: [PipApp] = []\n\n private var observer: AnyCancellable?\n private let updateSubject = PassthroughSubject<(), Never>()\n\n init() { observe() }\n\n func addPipApp(_ app: PipApp) {\n pipApps.append(app)\n }\n\n func deletePipApp(_ app: PipApp) {\n pipApps.removeAll { $0 == app }\n }\n\n private func observe() {\n observer = Publishers.MergeMany(\n $displayMode.settingsPublisher(),\n\n $centerCursorOnWorkspaceChange.settingsPublisher(),\n $changeWorkspaceOnAppAssign.settingsPublisher(),\n $activeWorkspaceOnFocusChange.settingsPublisher(),\n $skipEmptyWorkspacesOnSwitch.settingsPublisher(),\n $keepUnassignedAppsOnSwitch.settingsPublisher(),\n $restoreHiddenAppsOnSwitch.settingsPublisher(),\n $enableWorkspaceTransitions.settingsPublisher(),\n $workspaceTransitionDuration.settingsPublisher(debounce: true),\n $workspaceTransitionDimming.settingsPublisher(debounce: true),\n\n $assignFocusedApp.settingsPublisher(),\n $unassignFocusedApp.settingsPublisher(),\n $toggleFocusedAppAssignment.settingsPublisher(),\n $assignVisibleApps.settingsPublisher(),\n $hideUnassignedApps.settingsPublisher(),\n\n $loopWorkspaces.settingsPublisher(),\n $switchToRecentWorkspace.settingsPublisher(),\n $switchToPreviousWorkspace.settingsPublisher(),\n $switchToNextWorkspace.settingsPublisher(),\n\n $alternativeDisplays.settingsPublisher(debounce: true),\n $enablePictureInPictureSupport.settingsPublisher(),\n $switchWorkspaceWhenPipCloses.settingsPublisher(),\n $pipApps.settingsPublisher(),\n $pipScreenCornerOffset.settingsPublisher(debounce: true)\n )\n .receive(on: DispatchQueue.main)\n .sink { [weak self] in self?.updateSubject.send() }\n }\n}\n\nextension WorkspaceSettings: SettingsProtocol {\n var updatePublisher: AnyPublisher<(), Never> {\n updateSubject.eraseToAnyPublisher()\n }\n\n func load(from appSettings: AppSettings) {\n observer = nil\n displayMode = appSettings.displayMode ?? .static\n\n centerCursorOnWorkspaceChange = appSettings.centerCursorOnWorkspaceChange ?? false\n changeWorkspaceOnAppAssign = appSettings.changeWorkspaceOnAppAssign ?? true\n activeWorkspaceOnFocusChange = appSettings.activeWorkspaceOnFocusChange ?? true\n skipEmptyWorkspacesOnSwitch = appSettings.skipEmptyWorkspacesOnSwitch ?? false\n keepUnassignedAppsOnSwitch = appSettings.keepUnassignedAppsOnSwitch ?? false\n restoreHiddenAppsOnSwitch = appSettings.restoreHiddenAppsOnSwitch ?? true\n enableWorkspaceTransitions = appSettings.enableWorkspaceTransitions ?? false\n workspaceTransitionDuration = min(appSettings.workspaceTransitionDuration ?? 0.3, 0.5)\n workspaceTransitionDimming = min(appSettings.workspaceTransitionDimming ?? 0.2, 0.5)\n\n assignFocusedApp = appSettings.assignFocusedApp\n unassignFocusedApp = appSettings.unassignFocusedApp\n toggleFocusedAppAssignment = appSettings.toggleFocusedAppAssignment\n assignVisibleApps = appSettings.assignVisibleApps\n hideUnassignedApps = appSettings.hideUnassignedApps\n\n loopWorkspaces = appSettings.loopWorkspaces ?? true\n switchToRecentWorkspace = appSettings.switchToRecentWorkspace\n switchToPreviousWorkspace = appSettings.switchToPreviousWorkspace\n switchToNextWorkspace = appSettings.switchToNextWorkspace\n\n alternativeDisplays = appSettings.alternativeDisplays ?? \"\"\n enablePictureInPictureSupport = appSettings.enablePictureInPictureSupport ?? true\n switchWorkspaceWhenPipCloses = appSettings.switchWorkspaceWhenPipCloses ?? true\n pipApps = appSettings.pipApps ?? []\n pipScreenCornerOffset = appSettings.pipScreenCornerOffset ?? 15\n observe()\n }\n\n func update(_ appSettings: inout AppSettings) {\n appSettings.displayMode = displayMode\n\n appSettings.centerCursorOnWorkspaceChange = centerCursorOnWorkspaceChange\n appSettings.changeWorkspaceOnAppAssign = changeWorkspaceOnAppAssign\n appSettings.activeWorkspaceOnFocusChange = activeWorkspaceOnFocusChange\n appSettings.skipEmptyWorkspacesOnSwitch = skipEmptyWorkspacesOnSwitch\n appSettings.keepUnassignedAppsOnSwitch = keepUnassignedAppsOnSwitch\n appSettings.restoreHiddenAppsOnSwitch = restoreHiddenAppsOnSwitch\n appSettings.enableWorkspaceTransitions = enableWorkspaceTransitions\n appSettings.workspaceTransitionDuration = workspaceTransitionDuration\n appSettings.workspaceTransitionDimming = workspaceTransitionDimming\n\n appSettings.assignFocusedApp = assignFocusedApp\n appSettings.unassignFocusedApp = unassignFocusedApp\n appSettings.toggleFocusedAppAssignment = toggleFocusedAppAssignment\n appSettings.assignVisibleApps = assignVisibleApps\n appSettings.hideUnassignedApps = hideUnassignedApps\n\n appSettings.loopWorkspaces = loopWorkspaces\n appSettings.switchToRecentWorkspace = switchToRecentWorkspace\n appSettings.switchToPreviousWorkspace = switchToPreviousWorkspace\n appSettings.switchToNextWorkspace = switchToNextWorkspace\n\n appSettings.alternativeDisplays = alternativeDisplays\n appSettings.enablePictureInPictureSupport = enablePictureInPictureSupport\n appSettings.switchWorkspaceWhenPipCloses = switchWorkspaceWhenPipCloses\n appSettings.pipApps = pipApps\n appSettings.pipScreenCornerOffset = pipScreenCornerOffset\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/PictureInPicture/PictureInPictureManager.swift", "//\n// PictureInPictureManager.swift\n//\n// Created by Wojciech Kulik on 12/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Combine\n\nfinal class PictureInPictureManager {\n typealias AXWindow = AXUIElement\n\n private var hiddenWindows: [NSRunningApplication: [AXWindow]] = [:]\n private var capturedFrame: [AXWindow: CGRect] = [:]\n private var cancellables: Set = []\n private var windowFocusObserver: AXObserver?\n\n private let settings: WorkspaceSettings\n\n init(settingsRepository: SettingsRepository) {\n self.settings = settingsRepository.workspaceSettings\n setupSignalHandlers()\n observePipFocusChangeNotification()\n }\n\n func restoreAppIfNeeded(app: NSRunningApplication) {\n guard settings.enablePictureInPictureSupport else { return }\n\n if hiddenWindows.keys.contains(app) {\n restoreFromCornerNonPipWindows(app: app)\n }\n }\n\n func restoreAllWindows() {\n for app in hiddenWindows.keys {\n showPipAppIfNeeded(app: app)\n }\n }\n\n func showPipAppIfNeeded(app: NSRunningApplication) {\n guard settings.enablePictureInPictureSupport,\n app.supportsPictureInPicture else { return }\n\n restoreFromCornerNonPipWindows(app: app)\n }\n\n func hidePipAppIfNeeded(app: NSRunningApplication) -> Bool {\n guard settings.enablePictureInPictureSupport,\n app.supportsPictureInPicture,\n app.isPictureInPictureActive\n else { return false }\n\n guard hiddenWindows[app] == nil else { return true }\n\n guard settings.displayMode == .static || app.allDisplays.count <= 1 else {\n // pip is not supported for multi-display apps\n return false\n }\n\n return hideInCornerNonPipWindows(app: app)\n }\n\n private func observePipFocusChangeNotification() {\n NotificationCenter.default\n .publisher(for: .pipFocusChanged)\n .sink { [weak self] _ in self?.restorePipWorkspace() }\n .store(in: &cancellables)\n }\n\n private func restorePipWorkspace() {\n guard let app = hiddenWindows.keys.first(where: { !$0.isPictureInPictureActive }) else { return }\n\n restoreAllWindows()\n\n let workspaceRepository = AppDependencies.shared.workspaceRepository\n let workspaceManager = AppDependencies.shared.workspaceManager\n let workspace = workspaceRepository.workspaces.first { $0.apps.containsApp(app) }\n\n guard let workspace else { return }\n\n windowFocusObserver = nil\n workspaceManager.activateWorkspace(workspace, setFocus: false)\n }\n\n private func restoreFromCornerNonPipWindows(app: NSRunningApplication) {\n windowFocusObserver = nil\n\n app.runWithoutAnimations {\n for window in hiddenWindows[app] ?? [] {\n if let previousFrame = capturedFrame[window] {\n window.setPosition(previousFrame.origin)\n capturedFrame.removeValue(forKey: window)\n }\n }\n }\n\n hiddenWindows.removeValue(forKey: app)\n }\n\n private func hideInCornerNonPipWindows(app: NSRunningApplication) -> Bool {\n guard let screenCorner = findScreenCorner(app: app) else { return false }\n\n let nonPipWindows = app.allWindows\n .map(\\.window)\n .filter { !$0.isPictureInPicture(bundleId: app.bundleIdentifier) }\n\n if nonPipWindows.isNotEmpty { observePipApp(app) }\n\n app.runWithoutAnimations {\n for window in nonPipWindows {\n if let windowFrame = window.frame, screenCorner != windowFrame.origin {\n capturedFrame[window] = windowFrame\n window.setPosition(screenCorner)\n }\n }\n }\n hiddenWindows[app] = nonPipWindows\n\n return true\n }\n\n private func findScreenCorner(app: NSRunningApplication) -> CGPoint? {\n guard let appScreen = NSScreen.screen(app.display) else {\n return nil\n }\n\n // Screen origin (0,0) is in the bottom-left corner, y-axis is pointing up\n // Window origin (0,0) is in the top-left corner, y-axis is pointing down\n // E.g. To place a window in the bottom-right corner of the screen\n // we need to set window origin to:\n // (screen.maxX - window.width, screen.maxY - window.height).\n\n let testOffset: CGFloat = 30.0\n let cornerOffset = CGFloat(settings.pipScreenCornerOffset)\n let appFrame = app.frame\n let screenFrame = appScreen.frame\n let leftCorner = CGPoint(x: screenFrame.minX, y: screenFrame.minY)\n let rightCorner = CGPoint(x: screenFrame.maxX, y: screenFrame.minY)\n let leftSide = leftCorner.applying(\n CGAffineTransform(translationX: -testOffset, y: testOffset)\n )\n let leftBottomSide = leftCorner.applying(\n CGAffineTransform(translationX: testOffset, y: -testOffset)\n )\n let rightSide = rightCorner.applying(\n CGAffineTransform(translationX: testOffset, y: testOffset)\n )\n let rightBottomSide = rightCorner.applying(\n CGAffineTransform(translationX: -testOffset, y: -testOffset)\n )\n\n let allScreens = NSScreen.screens.map(\\.frame)\n let isLeftCornerUsed = allScreens.contains(where: { $0.contains(leftSide) || $0.contains(leftBottomSide) })\n let isRightCornerUsed = allScreens.contains(where: { $0.contains(rightSide) || $0.contains(rightBottomSide) })\n\n if isLeftCornerUsed || !isRightCornerUsed || appFrame == nil {\n // right corner (window coordinates)\n return CGPoint(\n x: screenFrame.maxX - cornerOffset,\n y: screenFrame.maxY - cornerOffset\n )\n } else {\n // left corner (window coordinates)\n let appFrame = appFrame ?? .zero\n return CGPoint(\n x: screenFrame.minX + cornerOffset - appFrame.width,\n y: screenFrame.maxY - cornerOffset\n )\n }\n }\n\n private func setupSignalHandlers() {\n for code in [SIGTERM, SIGINT] {\n signal(code) {\n AppDependencies.shared.pictureInPictureManager.restoreAllWindows()\n exit($0)\n }\n }\n }\n\n private func observePipApp(_ app: NSRunningApplication) {\n guard settings.switchWorkspaceWhenPipCloses else { return }\n\n let callback: AXObserverCallback = { _, _, _, _ in\n NotificationCenter.default.post(name: .pipFocusChanged, object: nil)\n }\n\n let result = AXObserverCreate(app.processIdentifier, callback, &windowFocusObserver)\n\n guard result == .success, let observer = windowFocusObserver else { return }\n\n let appRef = AXUIElementCreateApplication(app.processIdentifier)\n AXObserverAddNotification(observer, appRef, kAXFocusedWindowChangedNotification as CFString, nil)\n CFRunLoopAddSource(CFRunLoopGetCurrent(), AXObserverGetRunLoopSource(observer), .defaultMode)\n }\n\n // MARK: - Alternative solution by minimizing windows (animation)\n private func deminimizeAllWindows(app: NSRunningApplication) {\n for window in app.allWindows.map(\\.window) {\n window.minimize(false)\n }\n }\n\n private func minimizeNonPipWindows(app: NSRunningApplication) {\n app.allWindows\n .map(\\.window)\n .filter { !$0.isPictureInPicture(bundleId: app.bundleIdentifier) }\n .forEach { $0.minimize(true) }\n }\n}\n"], ["/FlashSpace/FlashSpace/Accessibility/NSRunningApplication+Properties.swift", "//\n// NSRunningApplication+Properties.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension NSRunningApplication {\n var frame: CGRect? { mainWindow?.frame }\n var isMinimized: Bool { mainWindow?.isMinimized == true }\n\n var display: DisplayName? {\n // HACK: Workaround for Orion Browser which puts\n // the main window on the main screen with size (1,1)\n if isOrion {\n allWindows\n .first { $0.frame.width > 10 && $0.frame.height > 10 }?\n .frame\n .getDisplay()\n } else {\n frame?.getDisplay()\n }\n }\n\n var allDisplays: Set {\n allWindows\n .compactMap { $0.frame.getDisplay() }\n .asSet\n }\n\n var mainWindow: AXUIElement? {\n // HACK: Python app with running pygame module is causing\n // huge lags when other apps attempt to access its window\n // through the accessibility API.\n // A workaround is to simply skip this app.\n guard !isPython else { return nil }\n\n let appElement = AXUIElementCreateApplication(processIdentifier)\n return appElement.getAttribute(.mainWindow)\n }\n\n var focusedWindow: AXUIElement? {\n guard !isPython else { return nil }\n\n let appElement = AXUIElementCreateApplication(processIdentifier)\n return appElement.getAttribute(.focusedWindow)\n }\n\n var allWindows: [(window: AXUIElement, frame: CGRect)] {\n guard !isPython else { return [] }\n\n let appElement = AXUIElementCreateApplication(processIdentifier)\n let windows: [AXUIElement]? = appElement.getAttribute(.windows)\n\n return windows?\n .filter { $0.role == \"AXWindow\" }\n .compactMap { window in window.frame.flatMap { (window, $0) } }\n ?? []\n }\n\n func isOnAnyDisplay(_ displays: Set) -> Bool {\n !allDisplays.isDisjoint(with: displays)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Integrations/IntegrationsSettings.swift", "//\n// IntegrationsSettings.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nfinal class IntegrationsSettings: ObservableObject {\n static let defaultWorkspaceChangeScript = \"sketchybar --trigger flashspace_workspace_change WORKSPACE=\\\"$WORKSPACE\\\" DISPLAY=\\\"$DISPLAY\\\"\"\n static let defaultProfileChangeScript = \"sketchybar --reload\"\n\n @Published var enableIntegrations = false\n @Published var runScriptOnLaunch = \"\"\n @Published var runScriptOnWorkspaceChange = IntegrationsSettings.defaultWorkspaceChangeScript\n @Published var runScriptOnProfileChange = IntegrationsSettings.defaultProfileChangeScript\n\n private var observer: AnyCancellable?\n private let updateSubject = PassthroughSubject<(), Never>()\n\n init() {\n observe()\n\n DispatchQueue.main.async {\n Integrations.runOnAppLaunchIfNeeded()\n }\n }\n\n private func observe() {\n observer = Publishers.MergeMany(\n $enableIntegrations.settingsPublisher(),\n $runScriptOnWorkspaceChange.settingsPublisher(debounce: true),\n $runScriptOnLaunch.settingsPublisher(debounce: true),\n $runScriptOnProfileChange.settingsPublisher(debounce: true)\n )\n .receive(on: DispatchQueue.main)\n .sink { [weak self] in self?.updateSubject.send() }\n }\n}\n\nextension IntegrationsSettings: SettingsProtocol {\n var updatePublisher: AnyPublisher<(), Never> {\n updateSubject.eraseToAnyPublisher()\n }\n\n func load(from appSettings: AppSettings) {\n observer = nil\n enableIntegrations = appSettings.enableIntegrations ?? false\n runScriptOnLaunch = appSettings.runScriptOnLaunch ?? \"\"\n runScriptOnWorkspaceChange = appSettings.runScriptOnWorkspaceChange ?? Self.defaultWorkspaceChangeScript\n runScriptOnProfileChange = appSettings.runScriptOnProfileChange ?? Self.defaultProfileChangeScript\n observe()\n }\n\n func update(_ appSettings: inout AppSettings) {\n appSettings.enableIntegrations = enableIntegrations\n appSettings.runScriptOnLaunch = runScriptOnLaunch\n appSettings.runScriptOnWorkspaceChange = runScriptOnWorkspaceChange\n appSettings.runScriptOnProfileChange = runScriptOnProfileChange\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/General/GeneralSettingsView.swift", "//\n// GeneralSettingsView.swift\n//\n// Created by Wojciech Kulik on 23/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport SwiftUI\n\nstruct GeneralSettingsView: View {\n @StateObject var settings = AppDependencies.shared.generalSettings\n @State var isAutostartEnabled = false\n @State var hasAccessibilityPermissions = false\n\n var body: some View {\n Form {\n Section {\n Toggle(\"Launch at startup\", isOn: $isAutostartEnabled)\n Toggle(\"Check for updates automatically\", isOn: $settings.checkForUpdatesAutomatically)\n }\n\n Section(\"Permissions\") {\n HStack {\n if hasAccessibilityPermissions {\n Image(systemName: \"checkmark.circle.fill\")\n .foregroundColor(.green)\n Text(\"Accessibility Permissions\")\n Spacer()\n } else {\n Image(systemName: \"xmark.circle.fill\")\n .foregroundColor(.red)\n Text(\"Accessibility Permissions\")\n Spacer()\n Button(\"Open Privacy & Security\") {\n NSWorkspace.shared.open(\n URL(string: \"x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility\")!\n )\n }\n }\n }\n Text(\"FlashSpace requires accessibility access to manage applications.\")\n .foregroundColor(.secondary)\n .font(.callout)\n }\n\n Section(\"Shortcuts\") {\n hotkey(\"Toggle FlashSpace\", for: $settings.showFlashSpace)\n }\n\n Section(\"Notifications\") {\n Toggle(\"Enable Notifications\", isOn: $settings.showFloatingNotifications)\n Text(\"Some shortcuts will show a temporary notification.\")\n .foregroundStyle(.secondary)\n .font(.callout)\n }\n }\n .onAppear {\n isAutostartEnabled = AppDependencies.shared.autostartService.isLaunchAtLoginEnabled\n hasAccessibilityPermissions = PermissionsManager.shared.checkForAccessibilityPermissions()\n }\n .onChange(of: isAutostartEnabled) { _, enabled in\n if enabled {\n AppDependencies.shared.autostartService.enableLaunchAtLogin()\n } else {\n AppDependencies.shared.autostartService.disableLaunchAtLogin()\n }\n }\n .onReceive(NotificationCenter.default.publisher(for: NSApplication.didBecomeActiveNotification)) { _ in\n hasAccessibilityPermissions = PermissionsManager.shared.checkForAccessibilityPermissions()\n }\n .formStyle(.grouped)\n .navigationTitle(\"General\")\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Extensions/ParsableCommand.swift", "//\n// ParsableCommand.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ArgumentParser\nimport Foundation\n\nextension ParsableCommand {\n func sendCommand(_ command: CommandRequest) {\n SocketClient.shared.sendCommand(command)\n }\n\n func fallbackToHelp() {\n print(Self.helpMessage(for: Self.self))\n Self.exit(withError: CommandError.other)\n }\n\n func runWithTimeout() {\n RunLoop.current.run(until: Date().addingTimeInterval(5.0))\n Self.exit(withError: CommandError.timeout)\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/NSRunningApplication.swift", "//\n// NSRunningApplication.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension NSRunningApplication {\n var toMacApp: MacApp { .init(app: self) }\n var iconPath: String? { bundleURL?.iconPath }\n}\n\nextension [NSRunningApplication] {\n func find(_ app: MacApp?) -> NSRunningApplication? {\n guard let app else { return nil }\n\n return first { $0.bundleIdentifier == app.bundleIdentifier }\n }\n\n func findFirstMatch(with apps: [MacApp]) -> NSRunningApplication? {\n let bundleIdentifiers = apps.map(\\.bundleIdentifier).asSet\n\n return first { bundleIdentifiers.contains($0.bundleIdentifier ?? \"\") }\n }\n\n func excludeFloatingAppsOnDifferentScreen() -> [NSRunningApplication] {\n let activeWorkspace = AppDependencies.shared.workspaceManager.activeWorkspace[NSScreen.main?.localizedName ?? \"\"]\n let floatingApps = AppDependencies.shared.floatingAppsSettings.floatingApps\n\n guard let activeWorkspace else { return self }\n\n return filter { app in\n !floatingApps.containsApp(app) || app.isOnAnyDisplay(activeWorkspace.displays)\n }\n }\n\n func regularVisibleApps(onDisplays displays: Set, excluding apps: [MacApp]) -> [NSRunningApplication] {\n filter { app in\n app.activationPolicy == .regular &&\n !app.isHidden &&\n !apps.containsApp(app) &&\n app.isOnAnyDisplay(displays)\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/App/Migrations.swift", "//\n// Migrations.swift\n//\n// Created by Wojciech Kulik on 08/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nenum Migrations {\n static var appsMigrated = false\n static var hotKeysMigrated = false\n\n static func migrateIfNeeded(\n settingsRepository: SettingsRepository,\n profilesRepository: ProfilesRepository\n ) {\n if Migrations.appsMigrated {\n Logger.log(\"Migrated apps\")\n\n let workspacesJsonUrl = FileManager.default\n .homeDirectoryForCurrentUser\n .appendingPathComponent(\".config/flashspace/workspaces.json\")\n try? FileManager.default.moveItem(\n at: workspacesJsonUrl,\n to: workspacesJsonUrl.deletingLastPathComponent()\n .appendingPathComponent(\"workspaces.json.bak\")\n )\n\n settingsRepository.saveToDisk()\n profilesRepository.saveToDisk()\n } else if Migrations.hotKeysMigrated {\n Logger.log(\"Migrated hot keys\")\n settingsRepository.saveToDisk()\n profilesRepository.saveToDisk()\n }\n\n Migrations.appsMigrated = false\n Migrations.hotKeysMigrated = false\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/SpaceControl/SpaceControl.swift", "//\n// SpaceControl.swift\n//\n// Created by Wojciech Kulik on 11/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport SwiftUI\n\nenum SpaceControl {\n static var isEnabled: Bool { settings.enableSpaceControl }\n static var isVisible: Bool { window != nil }\n static var window: NSWindow?\n\n private static var settings: SpaceControlSettings { AppDependencies.shared.spaceControlSettings }\n private static var focusedAppBeforeShow: NSRunningApplication?\n\n static func getHotKey() -> (AppHotKey, () -> ())? {\n guard isEnabled else { return nil }\n\n if let spaceControlHotKey = settings.showSpaceControl {\n return (spaceControlHotKey, toggle)\n }\n\n return nil\n }\n\n static func toggle() {\n if isVisible {\n hide(restoreFocus: true)\n } else {\n show()\n }\n }\n\n static func hide(restoreFocus: Bool = false) {\n window?.orderOut(nil)\n window = nil\n\n if restoreFocus {\n focusedAppBeforeShow?.activate()\n focusedAppBeforeShow = nil\n }\n }\n\n static func show() {\n guard validate() else { return }\n\n PermissionsManager.shared.askForScreenRecordingPermissions()\n\n if Self.window != nil { hide() }\n\n let contentView = NSHostingView(\n rootView: SpaceControlView()\n )\n\n // contentRect is in screen coordinates where (0,0) is bottom-left corner\n // and it is relative to the main screen.\n let window = SpaceControlWindow(\n contentRect: NSScreen.main!.frame,\n styleMask: [.borderless],\n backing: .buffered,\n defer: false\n )\n window.isOpaque = false\n window.backgroundColor = .clear\n window.level = .screenSaver\n window.delegate = window\n Self.window = window\n\n let animations = settings.enableSpaceControlAnimations\n\n window.contentView = contentView.addVisualEffect(material: .fullScreenUI)\n window.alphaValue = animations ? 0 : 1\n\n focusedAppBeforeShow = NSWorkspace.shared.frontmostApplication\n NSApp.activate(ignoringOtherApps: true)\n window.orderFrontRegardless()\n window.makeKeyAndOrderFront(nil)\n\n if animations {\n window.animator().alphaValue = 1\n }\n }\n\n private static func validate() -> Bool {\n let workspaces = AppDependencies.shared.workspaceRepository.workspaces\n let nonEmptyWorkspaces = workspaces\n .filter { !settings.spaceControlCurrentDisplayWorkspaces || $0.isOnTheCurrentScreen }\n\n if nonEmptyWorkspaces.count < 2 {\n Alert.showOkAlert(title: \"Space Control\", message: \"You need at least 2 workspaces to use Space Control.\")\n return false\n }\n\n return true\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Profiles/Models/Profile.swift", "//\n// Profile.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\ntypealias ProfileId = UUID\n\nstruct ProfilesConfig: Codable {\n let profiles: [Profile]\n}\n\nstruct Profile: Identifiable, Codable, Hashable {\n let id: ProfileId\n var name: String\n var workspaces: [Workspace]\n}\n\nextension Profile {\n static let `default` = Profile(\n id: UUID(),\n name: \"Default\",\n workspaces: []\n )\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/FloatingApps/FloatingAppsSettingsViewModel.swift", "import Foundation\nimport SwiftUI\n\nfinal class FloatingAppsSettingsViewModel: ObservableObject {\n private let settings = AppDependencies.shared.floatingAppsSettings\n\n func addFloatingApp() {\n let fileChooser = FileChooser()\n let appUrl = fileChooser.runModalOpenPanel(\n allowedFileTypes: [.application],\n directoryURL: URL(filePath: \"/Applications\")\n )\n\n guard let bundle = appUrl?.bundle else { return }\n\n settings.addFloatingAppIfNeeded(\n app: .init(\n name: bundle.localizedAppName,\n bundleIdentifier: bundle.bundleIdentifier ?? \"\",\n iconPath: bundle.iconPath\n )\n )\n }\n\n func deleteFloatingApp(app: MacApp) {\n settings.deleteFloatingApp(app: app)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/CLIServer.swift", "//\n// CLIServer.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\nimport Network\n\nfinal class CLIServer {\n var isRunning: Bool {\n switch listener?.state ?? .cancelled {\n case .cancelled, .failed: return false\n default: return true\n }\n }\n\n private var listener: NWListener?\n private let socketPath = \"/tmp/flashspace.socket\"\n private let executors: [CommandExecutor] = [\n ProfileCommands(),\n WorkspaceCommands(),\n AppCommands(),\n FocusCommands(),\n SpaceControlCommands(),\n ListCommands(),\n GetCommands()\n ]\n\n init() { startServer() }\n\n func restart() {\n listener?.cancel()\n startServer()\n }\n\n private func startServer() {\n try? FileManager.default.removeItem(atPath: socketPath)\n\n do {\n let params = NWParameters(tls: nil, tcp: .init())\n params.allowLocalEndpointReuse = true\n params.requiredLocalEndpoint = .unix(path: socketPath)\n\n listener = try NWListener(using: params)\n listener?.newConnectionHandler = handleNewConnection\n listener?.start(queue: .global(qos: .userInitiated))\n Logger.log(\"🟢 Server started at \\(socketPath)\")\n } catch {\n Logger.log(\"❌ Failed to start server: \\(error)\")\n }\n }\n\n private func handleNewConnection(_ connection: NWConnection) {\n connection.start(queue: .global(qos: .userInitiated))\n Logger.log(\"✅ New client connected\")\n\n let buffer = BufferWrapper()\n receiveData(connection: connection, buffer: buffer)\n }\n\n private func receiveData(connection: NWConnection, buffer: BufferWrapper) {\n connection.receive(minimumIncompleteLength: 1, maximumLength: 10000) { data, _, isComplete, error in\n if let error {\n connection.cancel()\n return Logger.log(\"❌ Receive error: \\(error)\")\n }\n\n if let data { buffer.data.append(data) }\n\n // Check if complete or EOF at the end\n guard isComplete || data?.last == 0 else {\n return self.receiveData(connection: connection, buffer: buffer)\n }\n\n guard !buffer.data.isEmpty else {\n connection.cancel()\n return Logger.log(\"❌ Received empty data\")\n }\n\n do {\n let command = try buffer.data.decodeSocketData(CommandRequest.self)\n DispatchQueue.main.async {\n self.handleCommand(command, connection: connection)\n }\n } catch {\n connection.cancel()\n Logger.log(\"❌ Failed to decode command: \\(error)\")\n }\n }\n }\n\n private func handleCommand(_ command: CommandRequest, connection: NWConnection) {\n var result: CommandResponse?\n for executor in executors {\n result = executor.execute(command: command)\n if result != nil { break }\n }\n\n DispatchQueue.global(qos: .userInitiated).async {\n if let response = result?.encodeSocketData() {\n connection.send(content: response, completion: .contentProcessed { _ in connection.cancel() })\n } else {\n connection.cancel()\n Logger.log(\"❌ Failed to encode response\")\n }\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/PictureInPicture/Extensions/AXUIElement+PiP.swift", "//\n// AXUIElement+PiP.swift\n//\n// Created by Wojciech Kulik on 12/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension AXUIElement {\n private var pipApps: [PipApp] {\n AppDependencies.shared.workspaceSettings.pipApps\n }\n\n func isPictureInPicture(bundleId: String?) -> Bool {\n if let browser = PipBrowser(rawValue: bundleId ?? \"\") {\n if let partialTitle = browser.partialTitle,\n title?.contains(partialTitle) == true {\n return true\n }\n\n if let pipWindowTitle = browser.title {\n return title == pipWindowTitle\n } else if let pipWindowSubrole = browser.subrole {\n return subrole == pipWindowSubrole\n }\n } else if let pipApp = pipApps.first(where: { $0.bundleIdentifier == bundleId }) {\n let result = title?.range(\n of: pipApp.pipWindowTitleRegex,\n options: .regularExpression\n ) != nil\n\n return result\n }\n\n return false\n }\n}\n"], ["/FlashSpace/FlashSpace/App/AppDependencies.swift", "//\n// AppDependencies.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ShortcutRecorder\n\nstruct AppDependencies {\n static let shared = AppDependencies()\n\n let displayManager: DisplayManager\n let workspaceRepository: WorkspaceRepository\n let workspaceManager: WorkspaceManager\n let workspaceHotKeys: WorkspaceHotKeys\n let workspaceScreenshotManager = WorkspaceScreenshotManager()\n let workspaceTransitionManager: WorkspaceTransitionManager\n let pictureInPictureManager: PictureInPictureManager\n\n let floatingAppsHotKeys: FloatingAppsHotKeys\n\n let hotKeysMonitor: HotKeysMonitorProtocol = GlobalShortcutMonitor.shared\n let hotKeysManager: HotKeysManager\n\n let focusManager: FocusManager\n let focusedWindowTracker: FocusedWindowTracker\n\n let settingsRepository: SettingsRepository\n let generalSettings = GeneralSettings()\n let menuBarSettings = MenuBarSettings()\n let gesturesSettings = GesturesSettings()\n let focusManagerSettings = FocusManagerSettings()\n let workspaceSettings = WorkspaceSettings()\n let floatingAppsSettings = FloatingAppsSettings()\n let spaceControlSettings = SpaceControlSettings()\n let integrationsSettings = IntegrationsSettings()\n\n let profilesRepository: ProfilesRepository\n let autostartService = AutostartService()\n let cliServer = CLIServer()\n\n // swiftlint:disable:next function_body_length\n private init() {\n self.settingsRepository = SettingsRepository(\n generalSettings: generalSettings,\n menuBarSettings: menuBarSettings,\n gesturesSettings: gesturesSettings,\n focusManagerSettings: focusManagerSettings,\n workspaceSettings: workspaceSettings,\n floatingAppsSettings: floatingAppsSettings,\n spaceControlSettings: spaceControlSettings,\n integrationsSettings: integrationsSettings\n )\n self.displayManager = DisplayManager(settingsRepository: settingsRepository)\n self.workspaceTransitionManager = WorkspaceTransitionManager(\n workspaceSettings: workspaceSettings\n )\n self.pictureInPictureManager = PictureInPictureManager(\n settingsRepository: settingsRepository\n )\n self.profilesRepository = ProfilesRepository()\n self.workspaceRepository = WorkspaceRepository(\n profilesRepository: profilesRepository\n )\n self.workspaceManager = WorkspaceManager(\n workspaceRepository: workspaceRepository,\n settingsRepository: settingsRepository,\n pictureInPictureManager: pictureInPictureManager,\n workspaceTransitionManager: workspaceTransitionManager,\n displayManager: displayManager\n )\n self.workspaceHotKeys = WorkspaceHotKeys(\n workspaceManager: workspaceManager,\n workspaceRepository: workspaceRepository,\n settingsRepository: settingsRepository\n )\n self.floatingAppsHotKeys = FloatingAppsHotKeys(\n workspaceManager: workspaceManager,\n settingsRepository: settingsRepository\n )\n self.focusManager = FocusManager(\n workspaceRepository: workspaceRepository,\n workspaceManager: workspaceManager,\n focusManagerSettings: focusManagerSettings,\n floatingAppsSettings: floatingAppsSettings\n )\n self.hotKeysManager = HotKeysManager(\n hotKeysMonitor: GlobalShortcutMonitor.shared,\n workspaceHotKeys: workspaceHotKeys,\n floatingAppsHotKeys: floatingAppsHotKeys,\n focusManager: focusManager,\n settingsRepository: settingsRepository\n )\n self.focusedWindowTracker = FocusedWindowTracker(\n workspaceRepository: workspaceRepository,\n workspaceManager: workspaceManager,\n settingsRepository: settingsRepository,\n pictureInPictureManager: pictureInPictureManager\n )\n\n Migrations.migrateIfNeeded(\n settingsRepository: settingsRepository,\n profilesRepository: profilesRepository\n )\n\n focusedWindowTracker.startTracking()\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/NotificationName.swift", "//\n// NotificationName.swift\n//\n// Created by Wojciech Kulik on 22/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nextension Notification.Name {\n static let appsListChanged = Notification.Name(\"appsListChanged\")\n static let openMainWindow = Notification.Name(\"openMainWindow\")\n static let profileChanged = Notification.Name(\"profileChanged\")\n static let workspaceChanged = Notification.Name(\"workspaceChanged\")\n static let workspaceTransitionFinished = Notification.Name(\"workspaceTransitionFinished\")\n static let spaceControlArrowDown = Notification.Name(\"spaceControlArrowDown\")\n static let pipFocusChanged = Notification.Name(\"pipFocusChanged\")\n}\n"], ["/FlashSpace/FlashSpace/Features/HotKeys/HotKeysManager.swift", "//\n// HotKeysManager.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Combine\nimport ShortcutRecorder\n\nfinal class HotKeysManager {\n private(set) var allHotKeys: [(scope: String, hotKey: AppHotKey)] = []\n\n private var cancellables = Set()\n\n private let hotKeysMonitor: HotKeysMonitorProtocol\n private let workspaceHotKeys: WorkspaceHotKeys\n private let floatingAppsHotKeys: FloatingAppsHotKeys\n private let focusManager: FocusManager\n private let settingsRepository: SettingsRepository\n\n init(\n hotKeysMonitor: HotKeysMonitorProtocol,\n workspaceHotKeys: WorkspaceHotKeys,\n floatingAppsHotKeys: FloatingAppsHotKeys,\n focusManager: FocusManager,\n settingsRepository: SettingsRepository\n ) {\n self.hotKeysMonitor = hotKeysMonitor\n self.workspaceHotKeys = workspaceHotKeys\n self.floatingAppsHotKeys = floatingAppsHotKeys\n self.focusManager = focusManager\n self.settingsRepository = settingsRepository\n\n observe()\n }\n\n func refresh() {\n disableAll()\n enableAll()\n }\n\n // swiftlint:disable:next function_body_length\n func enableAll() {\n allHotKeys.removeAll()\n let addShortcut = { (title: String, shortcut: Shortcut) in\n self.allHotKeys.append((title, .init(\n keyCode: shortcut.keyCode.rawValue,\n modifiers: shortcut.modifierFlags.rawValue\n )))\n }\n\n // Workspaces\n for (shortcut, action) in workspaceHotKeys.getHotKeys().toShortcutPairs() {\n let action = ShortcutAction(shortcut: shortcut) { _ in\n action()\n return true\n }\n\n hotKeysMonitor.addAction(action, forKeyEvent: .down)\n addShortcut(\"Workspace\", shortcut)\n }\n\n // Floating Apps\n for (shortcut, action) in floatingAppsHotKeys.getHotKeys().toShortcutPairs() {\n let action = ShortcutAction(shortcut: shortcut) { _ in\n action()\n return true\n }\n\n hotKeysMonitor.addAction(action, forKeyEvent: .down)\n addShortcut(\"Floating Apps\", shortcut)\n }\n\n // Focus Manager\n for (shortcut, action) in focusManager.getHotKeys().toShortcutPairs() {\n let action = ShortcutAction(shortcut: shortcut) { _ in\n action()\n return true\n }\n hotKeysMonitor.addAction(action, forKeyEvent: .down)\n addShortcut(\"Focus Manager\", shortcut)\n }\n\n // General\n if let showHotKey = settingsRepository.generalSettings.showFlashSpace?.toShortcut() {\n let action = ShortcutAction(shortcut: showHotKey) { _ in\n guard !SpaceControl.isVisible else { return true }\n\n let visibleAppWindows = NSApp.windows\n .filter(\\.isVisible)\n .filter { $0.identifier?.rawValue == \"main\" || $0.identifier?.rawValue == \"settings\" }\n\n if visibleAppWindows.isEmpty {\n NotificationCenter.default.post(name: .openMainWindow, object: nil)\n } else {\n visibleAppWindows.forEach { $0.close() }\n }\n return true\n }\n hotKeysMonitor.addAction(action, forKeyEvent: .down)\n addShortcut(\"General\", showHotKey)\n }\n\n // SpaceControl\n if let (hotKey, action) = SpaceControl.getHotKey(), let shortcut = hotKey.toShortcut() {\n let action = ShortcutAction(shortcut: shortcut) { _ in\n action()\n return true\n }\n hotKeysMonitor.addAction(action, forKeyEvent: .down)\n addShortcut(\"Space Control\", shortcut)\n }\n }\n\n func disableAll() {\n hotKeysMonitor.removeAllActions()\n }\n\n private func observe() {\n NotificationCenter.default\n .publisher(for: .profileChanged)\n .sink { [weak self] _ in self?.refresh() }\n .store(in: &cancellables)\n\n DistributedNotificationCenter.default()\n .publisher(for: .init(rawValue: kTISNotifySelectedKeyboardInputSourceChanged as String))\n .sink { [weak self] _ in\n KeyCodesMap.refresh()\n self?.disableAll()\n self?.enableAll()\n }\n .store(in: &cancellables)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/SpaceControl/WorkspaceScreenshotManager.swift", "//\n// WorkspaceScreenshotManager.swift\n//\n// Created by Wojciech Kulik on 11/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Combine\nimport CoreGraphics\nimport ScreenCaptureKit\nimport SwiftUI\n\nfinal class WorkspaceScreenshotManager {\n typealias ImageData = Data\n\n struct ScreenshotKey: Hashable {\n let displayName: DisplayName\n let workspaceID: WorkspaceID\n }\n\n private(set) var screenshots: [ScreenshotKey: ImageData] = [:]\n private var cancellables = Set()\n\n private let lock = NSLock()\n\n init() {\n observe()\n }\n\n func captureWorkspace(_ workspace: Workspace, displayName: DisplayName) async {\n let shouldCapture = await MainActor.run {\n !SpaceControl.isVisible &&\n SpaceControl.isEnabled &&\n PermissionsManager.shared.checkForScreenRecordingPermissions()\n }\n\n guard shouldCapture else { return }\n\n do {\n let availableContent = try await SCShareableContent.excludingDesktopWindows(false, onScreenWindowsOnly: false)\n let display = await MainActor.run {\n availableContent.displays.first { $0.frame.getDisplay() == displayName }\n }\n\n guard let display else { return }\n\n let filter = SCContentFilter(display: display, excludingWindows: [])\n let config = SCStreamConfiguration()\n config.captureResolution = .best\n config.width = Int(display.frame.width)\n config.height = Int(display.frame.height)\n config.showsCursor = false\n\n let screenshot = try await SCScreenshotManager.captureSampleBuffer(\n contentFilter: filter,\n configuration: config\n )\n\n if let image = imageFromSampleBuffer(screenshot) {\n let key = ScreenshotKey(\n displayName: displayName,\n workspaceID: workspace.id\n )\n saveScreenshot(image, workspace: workspace, key: key)\n }\n } catch {\n Logger.log(error)\n }\n }\n\n private func imageFromSampleBuffer(_ buffer: CMSampleBuffer) -> NSImage? {\n guard let imageBuffer = CMSampleBufferGetImageBuffer(buffer) else { return nil }\n\n let ciImage = CIImage(cvImageBuffer: imageBuffer)\n let representation = NSCIImageRep(ciImage: ciImage)\n let nsImage = NSImage(size: representation.size)\n nsImage.addRepresentation(representation)\n\n return nsImage\n }\n\n private func saveScreenshot(_ image: NSImage, workspace: Workspace, key: ScreenshotKey) {\n let newSize = CGSize(\n width: 1400.0,\n height: (1400.0 / image.size.width) * image.size.height\n )\n let newImage = NSImage(size: newSize)\n let rect = NSRect(origin: .zero, size: newSize)\n\n newImage.lockFocus()\n image.draw(in: rect)\n newImage.unlockFocus()\n\n guard let resizedData = newImage.tiffRepresentation,\n let imageRepresentation = NSBitmapImageRep(data: resizedData),\n let jpegData = imageRepresentation.representation(using: .jpeg, properties: [:])\n else { return }\n\n lock.lock()\n screenshots[key] = jpegData\n lock.unlock()\n }\n\n private func observe() {\n NotificationCenter.default\n .publisher(for: .workspaceTransitionFinished)\n .compactMap { $0.object as? Workspace }\n .sink { [weak self] workspace in\n for display in workspace.displays {\n Task.detached { [weak self] in\n await self?.captureWorkspace(workspace, displayName: display)\n }\n }\n }\n .store(in: &cancellables)\n\n NotificationCenter.default\n .publisher(for: .profileChanged)\n .sink { [weak self] _ in\n self?.screenshots = [:]\n }\n .store(in: &cancellables)\n }\n}\n"], ["/FlashSpace/FlashSpace/UI/Toast.swift", "//\n// Toast.swift\n//\n// Created by Wojciech Kulik on 28/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport SwiftUI\n\nenum Toast {\n weak static var toastWindow: NSWindow?\n\n static func showWith(icon: String, message: String, textColor: Color) {\n guard AppDependencies.shared.generalSettings.showFloatingNotifications else { return }\n\n if let window = toastWindow {\n window.orderOut(nil)\n toastWindow = nil\n }\n\n let contentView = NSHostingView(\n rootView: ToastView(\n icon: icon,\n message: message,\n textColor: textColor\n )\n )\n let size = contentView.fittingSize\n\n // contentRect is in screen coordinates where (0,0) is bottom-left corner\n // and it is relative to the main screen.\n let window = NSWindow(\n contentRect: NSRect(\n x: (NSScreen.main?.frame.midX ?? 200.0) - size.width / 2.0,\n y: (NSScreen.main?.frame.minY ?? 0.0) + (NSScreen.main?.frame.height ?? 0.0) * 0.07,\n width: size.width,\n height: size.height\n ),\n styleMask: [.borderless],\n backing: .buffered,\n defer: false\n )\n window.isOpaque = false\n window.backgroundColor = .clear\n window.level = .screenSaver\n toastWindow = window\n\n let visualEffectView = contentView.addVisualEffect(material: .sidebar, border: true)\n window.contentView = visualEffectView\n window.orderFrontRegardless()\n\n DispatchQueue.main.asyncAfter(deadline: .now() + 2.0) {\n NSAnimationContext.runAnimationGroup({ context in\n context.duration = 0.3\n window.animator().alphaValue = 0.0\n }, completionHandler: {\n window.orderOut(nil)\n })\n }\n }\n}\n\nstruct ToastView: View {\n let icon: String\n let message: String\n let textColor: Color\n\n var body: some View {\n HStack {\n Image(systemName: icon)\n .resizable()\n .scaledToFit()\n .frame(width: 26)\n\n Text(message)\n .font(.title)\n }\n .opacity(0.9)\n .padding()\n .padding(.horizontal)\n .fontWeight(.semibold)\n .foregroundStyle(textColor)\n }\n}\n"], ["/FlashSpace/FlashSpace/App/AppDelegate.swift", "//\n// AppDelegate.swift\n//\n// Created by Wojciech Kulik on 13/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Combine\nimport SwiftUI\n\nfinal class AppDelegate: NSObject, NSApplicationDelegate {\n @Environment(\\.openWindow) private var openWindow\n @Environment(\\.dismissWindow) private var dismissWindow\n\n private var cancellables = Set()\n\n func applicationDidFinishLaunching(_ notification: Notification) {\n AppDependencies.shared.hotKeysManager.enableAll()\n\n NotificationCenter.default\n .publisher(for: .openMainWindow)\n .sink { [weak self] _ in\n self?.openWindow(id: \"main\")\n NSApp.activate(ignoringOtherApps: true)\n }\n .store(in: &cancellables)\n\n #if DEBUG\n dismissWindow(id: \"main\")\n #endif\n }\n\n func applicationWillTerminate(_ notification: Notification) {\n AppDependencies.shared.pictureInPictureManager.restoreAllWindows()\n }\n}\n"], ["/FlashSpace/FlashSpace/Accessibility/NSRunningApplication+Actions.swift", "//\n// NSRunningApplication+Actions.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension NSRunningApplication {\n func raise() {\n guard let mainWindow else {\n unhide()\n return\n }\n\n AXUIElementPerformAction(mainWindow, NSAccessibility.Action.raise as CFString)\n }\n\n /// Position is in window coordinates where (0,0) is top-left corner\n /// and it is relative to the main screen.\n func setPosition(_ position: CGPoint) {\n mainWindow?.setPosition(position)\n }\n\n func centerApp(display: DisplayName) {\n guard let appFrame = frame else {\n return Logger.log(\"Could not get frame for app: \\(localizedName ?? \"\")\")\n }\n\n guard let nsScreen = NSScreen.screen(display) else { return }\n guard appFrame.getDisplay() != nsScreen.localizedName else { return }\n\n let normalizedScreenFrame = nsScreen.normalizedFrame\n\n let origin = CGPoint(\n x: normalizedScreenFrame.midX - appFrame.width / 2.0,\n y: normalizedScreenFrame.midY - appFrame.height / 2.0\n )\n\n setPosition(origin)\n }\n\n func runWithoutAnimations(action: () -> ()) {\n let appElement = AXUIElementCreateApplication(processIdentifier)\n let wasEnabled = appElement.enhancedUserInterface\n\n if wasEnabled { appElement.setAttribute(.enchancedUserInterface, value: false) }\n\n action()\n\n if wasEnabled { appElement.setAttribute(.enchancedUserInterface, value: true) }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/_Models/AppSettings.swift", "//\n// AppSettings.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nstruct AppSettings: Codable {\n // General\n var checkForUpdatesAutomatically: Bool?\n var showFlashSpace: AppHotKey?\n var showFloatingNotifications: Bool?\n\n // Menu Bar\n var showMenuBarTitle: Bool?\n var showMenuBarIcon: Bool?\n var menuBarTitleTemplate: String?\n var menuBarDisplayAliases: String?\n\n // Focus Manager\n var enableFocusManagement: Bool?\n var centerCursorOnFocusChange: Bool?\n var focusLeft: AppHotKey?\n var focusRight: AppHotKey?\n var focusUp: AppHotKey?\n var focusDown: AppHotKey?\n var focusNextWorkspaceApp: AppHotKey?\n var focusPreviousWorkspaceApp: AppHotKey?\n var focusNextWorkspaceWindow: AppHotKey?\n var focusPreviousWorkspaceWindow: AppHotKey?\n var focusFrontmostWindow: Bool?\n\n // Gestures\n var enableSwipeGestures: Bool?\n var swipeThreshold: Double?\n var restartAppOnWakeUp: Bool?\n var swipeLeft3FingerAction: GestureAction?\n var swipeRight3FingerAction: GestureAction?\n var swipeUp3FingerAction: GestureAction?\n var swipeDown3FingerAction: GestureAction?\n var swipeLeft4FingerAction: GestureAction?\n var swipeRight4FingerAction: GestureAction?\n var swipeUp4FingerAction: GestureAction?\n var swipeDown4FingerAction: GestureAction?\n\n // Workspaces\n var displayMode: DisplayMode?\n var centerCursorOnWorkspaceChange: Bool?\n var changeWorkspaceOnAppAssign: Bool?\n var activeWorkspaceOnFocusChange: Bool?\n var skipEmptyWorkspacesOnSwitch: Bool?\n var keepUnassignedAppsOnSwitch: Bool?\n var restoreHiddenAppsOnSwitch: Bool?\n var loopWorkspaces: Bool?\n var switchToPreviousWorkspace: AppHotKey?\n var switchToNextWorkspace: AppHotKey?\n var switchToRecentWorkspace: AppHotKey?\n var assignFocusedApp: AppHotKey?\n var unassignFocusedApp: AppHotKey?\n var toggleFocusedAppAssignment: AppHotKey?\n var assignVisibleApps: AppHotKey?\n var hideUnassignedApps: AppHotKey?\n var alternativeDisplays: String?\n var enablePictureInPictureSupport: Bool?\n var switchWorkspaceWhenPipCloses: Bool?\n var pipApps: [PipApp]?\n var pipScreenCornerOffset: Int?\n\n // Floating apps\n var floatingApps: [MacApp]?\n var floatTheFocusedApp: AppHotKey?\n var unfloatTheFocusedApp: AppHotKey?\n var toggleTheFocusedAppFloating: AppHotKey?\n\n // Space Control\n var enableSpaceControl: Bool?\n var showSpaceControl: AppHotKey?\n var enableSpaceControlAnimations: Bool?\n var spaceControlCurrentDisplayWorkspaces: Bool?\n var spaceControlMaxColumns: Int?\n var enableWorkspaceTransitions: Bool?\n var workspaceTransitionDuration: Double?\n var workspaceTransitionDimming: Double?\n\n // Integrations\n var enableIntegrations: Bool?\n var runScriptOnLaunch: String?\n var runScriptOnWorkspaceChange: String?\n var runScriptOnProfileChange: String?\n}\n"], ["/FlashSpace/FlashSpace/UI/HotKeyControl.swift", "//\n// HotKeyControl.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport ShortcutRecorder\nimport SwiftUI\n\nstruct HotKeyControl: NSViewRepresentable {\n @Binding var shortcut: AppHotKey?\n\n func makeNSView(context: Context) -> RecorderControl {\n let control = RecorderControl(frame: .zero)\n control.delegate = context.coordinator\n control.objectValue = shortcut.flatMap { $0.toShortcut() }\n control.set(\n allowedModifierFlags: [.command, .option, .control, .shift],\n requiredModifierFlags: [],\n allowsEmptyModifierFlags: true\n )\n\n return control\n }\n\n func updateNSView(_ nsView: RecorderControl, context: Context) {\n context.coordinator.parent = self\n nsView.objectValue = shortcut.flatMap { $0.toShortcut() }\n }\n\n func makeCoordinator() -> Coordinator { Coordinator(parent: self) }\n\n final class Coordinator: NSObject, RecorderControlDelegate {\n var parent: HotKeyControl\n\n private let hotKeysManager = AppDependencies.shared.hotKeysManager\n\n init(parent: HotKeyControl) {\n self.parent = parent\n }\n\n func recorderControlDidBeginRecording(_ aControl: RecorderControl) {\n hotKeysManager.disableAll()\n }\n\n func recorderControl(_ aControl: RecorderControl, canRecord aShortcut: Shortcut) -> Bool {\n if let conflict = hotKeysManager.allHotKeys.first(where: { $0.hotKey.toShortcut() == aShortcut })?.scope {\n Alert.showOkAlert(\n title: \"Conflict\",\n message: \"This shortcut is already assigned within the \\(conflict) scope.\"\n )\n return false\n }\n\n return true\n }\n\n func recorderControlDidEndRecording(_ aControl: RecorderControl) {\n guard let shortcut = aControl.objectValue else {\n parent.shortcut = nil\n hotKeysManager.enableAll()\n return\n }\n\n parent.shortcut = .init(\n keyCode: shortcut.keyCode.rawValue,\n modifiers: shortcut.modifierFlags.rawValue\n )\n hotKeysManager.enableAll()\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/ConfigurationFile/ConfigurationFileSettingsView.swift", "//\n// ConfigurationFileSettingsView.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport SwiftUI\n\nstruct ConfigurationFileSettingsView: View {\n @State var configFormat: ConfigFormat = ConfigSerializer.format\n\n var body: some View {\n Form {\n Section {\n Picker(\"Format\", selection: $configFormat) {\n ForEach(ConfigFormat.allCases, id: \\.rawValue) { format in\n Text(format.displayName).tag(format)\n }\n }.onChange(of: configFormat) { _, newFormat in\n try? ConfigSerializer.convert(to: newFormat)\n }\n\n HStack {\n Text(\"Location: \\(ConfigSerializer.configDirectory.path)\")\n .foregroundStyle(.secondary)\n .font(.callout)\n Spacer()\n Button(\"Reveal\") {\n NSWorkspace.shared.open(ConfigSerializer.configDirectory)\n }\n }\n\n Text(\n \"If you manually edit the configuration file, make sure to restart FlashSpace.\\n\" +\n \"Custom formatting, order, comments, etc. will be overwritten if you change something in the app.\"\n )\n .foregroundStyle(.secondary)\n .font(.callout)\n }\n }\n .formStyle(.grouped)\n .navigationTitle(\"Configuration File\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/PictureInPicture/Extensions/NSRunningApplication+PiP.swift", "//\n// NSRunningApplication+PiP.swift\n//\n// Created by Wojciech Kulik on 12/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension NSRunningApplication {\n var supportsPictureInPicture: Bool {\n PipBrowser.allCases.contains { $0.bundleId == bundleIdentifier } ||\n pipApps.contains { $0.bundleIdentifier == bundleIdentifier }\n }\n\n var isPictureInPictureActive: Bool {\n allWindows.map(\\.window).contains { $0.isPictureInPicture(bundleId: bundleIdentifier) }\n }\n\n private var pipApps: [PipApp] {\n AppDependencies.shared.workspaceSettings.pipApps\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Acknowledgements/Licenses.swift", "//\n// Licenses.swift\n//\n// Created by Wojciech Kulik on 26/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nenum Licenses {\n static let swiftFormat = \"\"\"\n SwiftFormat\n\n Authors: Nick Lockwood\n Project URL: https://github.com/nicklockwood/SwiftFormat\n License URL: https://github.com/nicklockwood/SwiftFormat/blob/main/LICENSE.md\n\n MIT License\n\n Copyright (c) 2016 Nick Lockwood\n\n Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n \"\"\"\n\n static let swiftLint = \"\"\"\n SwiftLint\n\n Authors: The SwiftLint Contributors\n Project URL: https://github.com/realm/SwiftLint/\n License URL: https://github.com/realm/SwiftLint/blob/master/LICENSE\n\n The MIT License (MIT)\n\n Copyright (c) 2025 The SwiftLint Contributors.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n \"\"\"\n\n static let symbolPicker = \"\"\"\n SymbolPicker\n\n Authors: Yubo Qin & Lakr Aream\n Project URL: https://github.com/xnth97/SymbolPicker\n License URL: https://github.com/xnth97/SymbolPicker/blob/main/LICENSE\n\n MIT License\n\n Copyright (c) 2022 Yubo Qin & Lakr Aream\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n \"\"\"\n\n static let shortcutRecorder = \"\"\"\n ShortcutRecorder\n\n Authors: Contributors\n Project URL: https://github.com/Kentzo/ShortcutRecorder\n License URL: https://github.com/Kentzo/ShortcutRecorder/blob/master/LICENSE.txt\n\n Creative Commons Attribution 4.0 International Public License\n\n By exercising the Licensed Rights (defined below), You accept and agree\n to be bound by the terms and conditions of this Creative Commons\n Attribution 4.0 International Public License (\"Public License\"). To the\n extent this Public License may be interpreted as a contract, You are\n granted the Licensed Rights in consideration of Your acceptance of\n these terms and conditions, and the Licensor grants You such rights in\n consideration of benefits the Licensor receives from making the\n Licensed Material available under these terms and conditions.\n\n\n Section 1 -- Definitions.\n\n a. Adapted Material means material subject to Copyright and Similar\n Rights that is derived from or based upon the Licensed Material\n and in which the Licensed Material is translated, altered,\n arranged, transformed, or otherwise modified in a manner requiring\n permission under the Copyright and Similar Rights held by the\n Licensor. For purposes of this Public License, where the Licensed\n Material is a musical work, performance, or sound recording,\n Adapted Material is always produced where the Licensed Material is\n synched in timed relation with a moving image.\n\n b. Adapter's License means the license You apply to Your Copyright\n and Similar Rights in Your contributions to Adapted Material in\n accordance with the terms and conditions of this Public License.\n\n c. Copyright and Similar Rights means copyright and/or similar rights\n closely related to copyright including, without limitation,\n performance, broadcast, sound recording, and Sui Generis Database\n Rights, without regard to how the rights are labeled or\n categorized. For purposes of this Public License, the rights\n specified in Section 2(b)(1)-(2) are not Copyright and Similar\n Rights.\n\n d. Effective Technological Measures means those measures that, in the\n absence of proper authority, may not be circumvented under laws\n fulfilling obligations under Article 11 of the WIPO Copyright\n Treaty adopted on December 20, 1996, and/or similar international\n agreements.\n\n e. Exceptions and Limitations means fair use, fair dealing, and/or\n any other exception or limitation to Copyright and Similar Rights\n that applies to Your use of the Licensed Material.\n\n f. Licensed Material means the artistic or literary work, database,\n or other material to which the Licensor applied this Public\n License.\n\n g. Licensed Rights means the rights granted to You subject to the\n terms and conditions of this Public License, which are limited to\n all Copyright and Similar Rights that apply to Your use of the\n Licensed Material and that the Licensor has authority to license.\n\n h. Licensor means the individual(s) or entity(ies) granting rights\n under this Public License.\n\n i. Share means to provide material to the public by any means or\n process that requires permission under the Licensed Rights, such\n as reproduction, public display, public performance, distribution,\n dissemination, communication, or importation, and to make material\n available to the public including in ways that members of the\n public may access the material from a place and at a time\n individually chosen by them.\n\n j. Sui Generis Database Rights means rights other than copyright\n resulting from Directive 96/9/EC of the European Parliament and of\n the Council of 11 March 1996 on the legal protection of databases,\n as amended and/or succeeded, as well as other essentially\n equivalent rights anywhere in the world.\n\n k. You means the individual or entity exercising the Licensed Rights\n under this Public License. Your has a corresponding meaning.\n\n\n Section 2 -- Scope.\n\n a. License grant.\n\n 1. Subject to the terms and conditions of this Public License,\n the Licensor hereby grants You a worldwide, royalty-free,\n non-sublicensable, non-exclusive, irrevocable license to\n exercise the Licensed Rights in the Licensed Material to:\n\n a. reproduce and Share the Licensed Material, in whole or\n in part; and\n\n b. produce, reproduce, and Share Adapted Material.\n\n 2. Exceptions and Limitations. For the avoidance of doubt, where\n Exceptions and Limitations apply to Your use, this Public\n License does not apply, and You do not need to comply with\n its terms and conditions.\n\n 3. Term. The term of this Public License is specified in Section\n 6(a).\n\n 4. Media and formats; technical modifications allowed. The\n Licensor authorizes You to exercise the Licensed Rights in\n all media and formats whether now known or hereafter created,\n and to make technical modifications necessary to do so. The\n Licensor waives and/or agrees not to assert any right or\n authority to forbid You from making technical modifications\n necessary to exercise the Licensed Rights, including\n technical modifications necessary to circumvent Effective\n Technological Measures. For purposes of this Public License,\n simply making modifications authorized by this Section 2(a)\n (4) never produces Adapted Material.\n\n 5. Downstream recipients.\n\n a. Offer from the Licensor -- Licensed Material. Every\n recipient of the Licensed Material automatically\n receives an offer from the Licensor to exercise the\n Licensed Rights under the terms and conditions of this\n Public License.\n\n b. No downstream restrictions. You may not offer or impose\n any additional or different terms or conditions on, or\n apply any Effective Technological Measures to, the\n Licensed Material if doing so restricts exercise of the\n Licensed Rights by any recipient of the Licensed\n Material.\n\n 6. No endorsement. Nothing in this Public License constitutes or\n may be construed as permission to assert or imply that You\n are, or that Your use of the Licensed Material is, connected\n with, or sponsored, endorsed, or granted official status by,\n the Licensor or others designated to receive attribution as\n provided in Section 3(a)(1)(A)(i).\n\n b. Other rights.\n\n 1. Moral rights, such as the right of integrity, are not\n licensed under this Public License, nor are publicity,\n privacy, and/or other similar personality rights; however, to\n the extent possible, the Licensor waives and/or agrees not to\n assert any such rights held by the Licensor to the limited\n extent necessary to allow You to exercise the Licensed\n Rights, but not otherwise.\n\n 2. Patent and trademark rights are not licensed under this\n Public License.\n\n 3. To the extent possible, the Licensor waives any right to\n collect royalties from You for the exercise of the Licensed\n Rights, whether directly or through a collecting society\n under any voluntary or waivable statutory or compulsory\n licensing scheme. In all other cases the Licensor expressly\n reserves any right to collect such royalties.\n\n\n Section 3 -- License Conditions.\n\n Your exercise of the Licensed Rights is expressly made subject to the\n following conditions.\n\n a. Attribution.\n\n 1. If You Share the Licensed Material (including in modified\n form), You must:\n\n a. retain the following if it is supplied by the Licensor\n with the Licensed Material:\n\n i. identification of the creator(s) of the Licensed\n Material and any others designated to receive\n attribution, in any reasonable manner requested by\n the Licensor (including by pseudonym if\n designated);\n\n ii. a copyright notice;\n\n iii. a notice that refers to this Public License;\n\n iv. a notice that refers to the disclaimer of\n warranties;\n\n v. a URI or hyperlink to the Licensed Material to the\n extent reasonably practicable;\n\n b. indicate if You modified the Licensed Material and\n retain an indication of any previous modifications; and\n\n c. indicate the Licensed Material is licensed under this\n Public License, and include the text of, or the URI or\n hyperlink to, this Public License.\n\n 2. You may satisfy the conditions in Section 3(a)(1) in any\n reasonable manner based on the medium, means, and context in\n which You Share the Licensed Material. For example, it may be\n reasonable to satisfy the conditions by providing a URI or\n hyperlink to a resource that includes the required\n information.\n\n 3. If requested by the Licensor, You must remove any of the\n information required by Section 3(a)(1)(A) to the extent\n reasonably practicable.\n\n 4. If You Share Adapted Material You produce, the Adapter's\n License You apply must not prevent recipients of the Adapted\n Material from complying with this Public License.\n\n\n Section 4 -- Sui Generis Database Rights.\n\n Where the Licensed Rights include Sui Generis Database Rights that\n apply to Your use of the Licensed Material:\n\n a. for the avoidance of doubt, Section 2(a)(1) grants You the right\n to extract, reuse, reproduce, and Share all or a substantial\n portion of the contents of the database;\n\n b. if You include all or a substantial portion of the database\n contents in a database in which You have Sui Generis Database\n Rights, then the database in which You have Sui Generis Database\n Rights (but not its individual contents) is Adapted Material; and\n\n c. You must comply with the conditions in Section 3(a) if You Share\n all or a substantial portion of the contents of the database.\n\n For the avoidance of doubt, this Section 4 supplements and does not\n replace Your obligations under this Public License where the Licensed\n Rights include other Copyright and Similar Rights.\n\n\n Section 5 -- Disclaimer of Warranties and Limitation of Liability.\n\n a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE\n EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS\n AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF\n ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,\n IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,\n WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR\n PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,\n ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT\n KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT\n ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.\n\n b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE\n TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,\n NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,\n INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,\n COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR\n USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN\n ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR\n DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR\n IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.\n\n c. The disclaimer of warranties and limitation of liability provided\n above shall be interpreted in a manner that, to the extent\n possible, most closely approximates an absolute disclaimer and\n waiver of all liability.\n\n\n Section 6 -- Term and Termination.\n\n a. This Public License applies for the term of the Copyright and\n Similar Rights licensed here. However, if You fail to comply with\n this Public License, then Your rights under this Public License\n terminate automatically.\n\n b. Where Your right to use the Licensed Material has terminated under\n Section 6(a), it reinstates:\n\n 1. automatically as of the date the violation is cured, provided\n it is cured within 30 days of Your discovery of the\n violation; or\n\n 2. upon express reinstatement by the Licensor.\n\n For the avoidance of doubt, this Section 6(b) does not affect any\n right the Licensor may have to seek remedies for Your violations\n of this Public License.\n\n c. For the avoidance of doubt, the Licensor may also offer the\n Licensed Material under separate terms or conditions or stop\n distributing the Licensed Material at any time; however, doing so\n will not terminate this Public License.\n\n d. Sections 1, 5, 6, 7, and 8 survive termination of this Public\n License.\n\n\n Section 7 -- Other Terms and Conditions.\n\n a. The Licensor shall not be bound by any additional or different\n terms or conditions communicated by You unless expressly agreed.\n\n b. Any arrangements, understandings, or agreements regarding the\n Licensed Material not stated herein are separate from and\n independent of the terms and conditions of this Public License.\n\n\n Section 8 -- Interpretation.\n\n a. For the avoidance of doubt, this Public License does not, and\n shall not be interpreted to, reduce, limit, restrict, or impose\n conditions on any use of the Licensed Material that could lawfully\n be made without permission under this Public License.\n\n b. To the extent possible, if any provision of this Public License is\n deemed unenforceable, it shall be automatically reformed to the\n minimum extent necessary to make it enforceable. If the provision\n cannot be reformed, it shall be severed from this Public License\n without affecting the enforceability of the remaining terms and\n conditions.\n\n c. No term or condition of this Public License will be waived and no\n failure to comply consented to unless expressly agreed to by the\n Licensor.\n\n d. Nothing in this Public License constitutes or may be interpreted\n as a limitation upon, or waiver of, any privileges and immunities\n that apply to the Licensor or You, including from the legal\n processes of any jurisdiction or authority.\n\n\n =======================================================================\n\n Creative Commons is not a party to its public\n licenses. Notwithstanding, Creative Commons may elect to apply one of\n its public licenses to material it publishes and in those instances\n will be considered the “Licensor.” The text of the Creative Commons\n public licenses is dedicated to the public domain under the CC0 Public\n Domain Dedication. Except for the limited purpose of indicating that\n material is shared under a Creative Commons public license or as\n otherwise permitted by the Creative Commons policies published at\n creativecommons.org/policies, Creative Commons does not authorize the\n use of the trademark \"Creative Commons\" or any other trademark or logo\n of Creative Commons without its prior written consent including,\n without limitation, in connection with any unauthorized modifications\n to any of its public licenses or any other arrangements,\n understandings, or agreements concerning use of licensed material. For\n the avoidance of doubt, this paragraph does not form part of the\n public licenses.\n \"\"\"\n\n static let yams = \"\"\"\n Yams\n\n Authors: JP Simard\n Project URL: https://github.com/jpsim/Yams\n License URL: https://github.com/jpsim/Yams/blob/main/LICENSE\n\n The MIT License (MIT)\n\n Copyright (c) 2016 JP Simard.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n \"\"\"\n\n static let tomlKit = \"\"\"\n TOMLKit\n\n Authors: Jeff Lebrun\n Project URL: https://github.com/LebJe/TOMLKit\n License URL: https://github.com/LebJe/TOMLKit/blob/main/LICENSE\n\n MIT License\n\n Copyright (c) 2024 Jeff Lebrun\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n \"\"\"\n\n static let swiftArgumentParser = \"\"\"\n Swift Argument Parser\n\n Authors: Apple\n Project URL: https://github.com/apple/swift-argument-parser\n License URL: https://github.com/apple/swift-argument-parser/blob/main/LICENSE.txt\n\n Apache License\n Version 2.0, January 2004\n http://www.apache.org/licenses/\n\n TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n 1. Definitions.\n\n \"License\" shall mean the terms and conditions for use, reproduction,\n and distribution as defined by Sections 1 through 9 of this document.\n\n \"Licensor\" shall mean the copyright owner or entity authorized by\n the copyright owner that is granting the License.\n\n \"Legal Entity\" shall mean the union of the acting entity and all\n other entities that control, are controlled by, or are under common\n control with that entity. For the purposes of this definition,\n \"control\" means (i) the power, direct or indirect, to cause the\n direction or management of such entity, whether by contract or\n otherwise, or (ii) ownership of fifty percent (50%) or more of the\n outstanding shares, or (iii) beneficial ownership of such entity.\n\n \"You\" (or \"Your\") shall mean an individual or Legal Entity\n exercising permissions granted by this License.\n\n \"Source\" form shall mean the preferred form for making modifications,\n including but not limited to software source code, documentation\n source, and configuration files.\n\n \"Object\" form shall mean any form resulting from mechanical\n transformation or translation of a Source form, including but\n not limited to compiled object code, generated documentation,\n and conversions to other media types.\n\n \"Work\" shall mean the work of authorship, whether in Source or\n Object form, made available under the License, as indicated by a\n copyright notice that is included in or attached to the work\n (an example is provided in the Appendix below).\n\n \"Derivative Works\" shall mean any work, whether in Source or Object\n form, that is based on (or derived from) the Work and for which the\n editorial revisions, annotations, elaborations, or other modifications\n represent, as a whole, an original work of authorship. For the purposes\n of this License, Derivative Works shall not include works that remain\n separable from, or merely link (or bind by name) to the interfaces of,\n the Work and Derivative Works thereof.\n\n \"Contribution\" shall mean any work of authorship, including\n the original version of the Work and any modifications or additions\n to that Work or Derivative Works thereof, that is intentionally\n submitted to Licensor for inclusion in the Work by the copyright owner\n or by an individual or Legal Entity authorized to submit on behalf of\n the copyright owner. For the purposes of this definition, \"submitted\"\n means any form of electronic, verbal, or written communication sent\n to the Licensor or its representatives, including but not limited to\n communication on electronic mailing lists, source code control systems,\n and issue tracking systems that are managed by, or on behalf of, the\n Licensor for the purpose of discussing and improving the Work, but\n excluding communication that is conspicuously marked or otherwise\n designated in writing by the copyright owner as \"Not a Contribution.\"\n\n \"Contributor\" shall mean Licensor and any individual or Legal Entity\n on behalf of whom a Contribution has been received by Licensor and\n subsequently incorporated within the Work.\n\n 2. Grant of Copyright License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n copyright license to reproduce, prepare Derivative Works of,\n publicly display, publicly perform, sublicense, and distribute the\n Work and such Derivative Works in Source or Object form.\n\n 3. Grant of Patent License. Subject to the terms and conditions of\n this License, each Contributor hereby grants to You a perpetual,\n worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n (except as stated in this section) patent license to make, have made,\n use, offer to sell, sell, import, and otherwise transfer the Work,\n where such license applies only to those patent claims licensable\n by such Contributor that are necessarily infringed by their\n Contribution(s) alone or by combination of their Contribution(s)\n with the Work to which such Contribution(s) was submitted. If You\n institute patent litigation against any entity (including a\n cross-claim or counterclaim in a lawsuit) alleging that the Work\n or a Contribution incorporated within the Work constitutes direct\n or contributory patent infringement, then any patent licenses\n granted to You under this License for that Work shall terminate\n as of the date such litigation is filed.\n\n 4. Redistribution. You may reproduce and distribute copies of the\n Work or Derivative Works thereof in any medium, with or without\n modifications, and in Source or Object form, provided that You\n meet the following conditions:\n\n (a) You must give any other recipients of the Work or\n Derivative Works a copy of this License; and\n\n (b) You must cause any modified files to carry prominent notices\n stating that You changed the files; and\n\n (c) You must retain, in the Source form of any Derivative Works\n that You distribute, all copyright, patent, trademark, and\n attribution notices from the Source form of the Work,\n excluding those notices that do not pertain to any part of\n the Derivative Works; and\n\n (d) If the Work includes a \"NOTICE\" text file as part of its\n distribution, then any Derivative Works that You distribute must\n include a readable copy of the attribution notices contained\n within such NOTICE file, excluding those notices that do not\n pertain to any part of the Derivative Works, in at least one\n of the following places: within a NOTICE text file distributed\n as part of the Derivative Works; within the Source form or\n documentation, if provided along with the Derivative Works; or,\n within a display generated by the Derivative Works, if and\n wherever such third-party notices normally appear. The contents\n of the NOTICE file are for informational purposes only and\n do not modify the License. You may add Your own attribution\n notices within Derivative Works that You distribute, alongside\n or as an addendum to the NOTICE text from the Work, provided\n that such additional attribution notices cannot be construed\n as modifying the License.\n\n You may add Your own copyright statement to Your modifications and\n may provide additional or different license terms and conditions\n for use, reproduction, or distribution of Your modifications, or\n for any such Derivative Works as a whole, provided Your use,\n reproduction, and distribution of the Work otherwise complies with\n the conditions stated in this License.\n\n 5. Submission of Contributions. Unless You explicitly state otherwise,\n any Contribution intentionally submitted for inclusion in the Work\n by You to the Licensor shall be under the terms and conditions of\n this License, without any additional terms or conditions.\n Notwithstanding the above, nothing herein shall supersede or modify\n the terms of any separate license agreement you may have executed\n with Licensor regarding such Contributions.\n\n 6. Trademarks. This License does not grant permission to use the trade\n names, trademarks, service marks, or product names of the Licensor,\n except as required for reasonable and customary use in describing the\n origin of the Work and reproducing the content of the NOTICE file.\n\n 7. Disclaimer of Warranty. Unless required by applicable law or\n agreed to in writing, Licensor provides the Work (and each\n Contributor provides its Contributions) on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n implied, including, without limitation, any warranties or conditions\n of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n PARTICULAR PURPOSE. You are solely responsible for determining the\n appropriateness of using or redistributing the Work and assume any\n risks associated with Your exercise of permissions under this License.\n\n 8. Limitation of Liability. In no event and under no legal theory,\n whether in tort (including negligence), contract, or otherwise,\n unless required by applicable law (such as deliberate and grossly\n negligent acts) or agreed to in writing, shall any Contributor be\n liable to You for damages, including any direct, indirect, special,\n incidental, or consequential damages of any character arising as a\n result of this License or out of the use or inability to use the\n Work (including but not limited to damages for loss of goodwill,\n work stoppage, computer failure or malfunction, or any and all\n other commercial damages or losses), even if such Contributor\n has been advised of the possibility of such damages.\n\n 9. Accepting Warranty or Additional Liability. While redistributing\n the Work or Derivative Works thereof, You may choose to offer,\n and charge a fee for, acceptance of support, warranty, indemnity,\n or other liability obligations and/or rights consistent with this\n License. However, in accepting such obligations, You may act only\n on Your own behalf and on Your sole responsibility, not on behalf\n of any other Contributor, and only if You agree to indemnify,\n defend, and hold each Contributor harmless for any liability\n incurred by, or claims asserted against, such Contributor by reason\n of your accepting any such warranty or additional liability.\n\n END OF TERMS AND CONDITIONS\n\n APPENDIX: How to apply the Apache License to your work.\n\n To apply the Apache License to your work, attach the following\n boilerplate notice, with the fields enclosed by brackets \"[]\"\n replaced with your own identifying information. (Don't include\n the brackets!) The text should be enclosed in the appropriate\n comment syntax for the file format. We also recommend that a\n file or class name and description of purpose be included on the\n same \"printed page\" as the copyright notice for easier\n identification within third-party archives.\n\n Copyright [yyyy] [name of copyright owner]\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n\n\n ## Runtime Library Exception to the Apache 2.0 License: ##\n\n\n As an exception, if you use this Software to compile your source code and\n portions of this Software are embedded into the binary product as a result,\n you may redistribute such product without providing attribution as would\n otherwise be required by Sections 4(a), 4(b) and 4(d) of the License.\n \"\"\"\n\n static let sparkle = \"\"\"\n Sparkle\n\n Copyright (c) 2006-2013 Andy Matuschak.\n Copyright (c) 2009-2013 Elgato Systems GmbH.\n Copyright (c) 2011-2014 Kornel Lesiński.\n Copyright (c) 2015-2017 Mayur Pawashe.\n Copyright (c) 2014 C.W. Betts.\n Copyright (c) 2014 Petroules Corporation.\n Copyright (c) 2014 Big Nerd Ranch.\n All rights reserved.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy of\n this software and associated documentation files (the \"Software\"), to deal in\n the Software without restriction, including without limitation the rights to\n use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\n the Software, and to permit persons to whom the Software is furnished to do so,\n subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\n FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\n COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\n IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n =================\n EXTERNAL LICENSES\n =================\n\n bspatch.c and bsdiff.c, from bsdiff 4.3 :\n\n Copyright 2003-2005 Colin Percival\n All rights reserved\n\n Redistribution and use in source and binary forms, with or without\n modification, are permitted providing that the following conditions \n are met:\n 1. Redistributions of source code must retain the above copyright\n notice, this list of conditions and the following disclaimer.\n 2. Redistributions in binary form must reproduce the above copyright\n notice, this list of conditions and the following disclaimer in the\n documentation and/or other materials provided with the distribution.\n\n THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR\n IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY\n DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING\n IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n POSSIBILITY OF SUCH DAMAGE.\n\n --\n\n sais.c and sais.h, from sais-lite (2010/08/07) :\n\n The sais-lite copyright is as follows:\n\n Copyright (c) 2008-2010 Yuta Mori All Rights Reserved.\n\n Permission is hereby granted, free of charge, to any person\n obtaining a copy of this software and associated documentation\n files (the \"Software\"), to deal in the Software without\n restriction, including without limitation the rights to use,\n copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the\n Software is furnished to do so, subject to the following\n conditions:\n\n The above copyright notice and this permission notice shall be\n included in all copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n OTHER DEALINGS IN THE SOFTWARE.\n\n --\n\n Portable C implementation of Ed25519, from https://github.com/orlp/ed25519\n\n Copyright (c) 2015 Orson Peters \n\n This software is provided 'as-is', without any express or implied warranty. In no event will the\n authors be held liable for any damages arising from the use of this software.\n\n Permission is granted to anyone to use this software for any purpose, including commercial\n applications, and to alter it and redistribute it freely, subject to the following restrictions:\n\n 1. The origin of this software must not be misrepresented; you must not claim that you wrote the\n original software. If you use this software in a product, an acknowledgment in the product\n documentation would be appreciated but is not required.\n\n 2. Altered source versions must be plainly marked as such, and must not be misrepresented as\n being the original software.\n\n 3. This notice may not be removed or altered from any source distribution.\n\n --\n\n SUSignatureVerifier.m:\n\n Copyright (c) 2011 Mark Hamlin.\n\n All rights reserved.\n\n Redistribution and use in source and binary forms, with or without\n modification, are permitted providing that the following conditions\n are met:\n 1. Redistributions of source code must retain the above copyright\n notice, this list of conditions and the following disclaimer.\n 2. Redistributions in binary form must reproduce the above copyright\n notice, this list of conditions and the following disclaimer in the\n documentation and/or other materials provided with the distribution.\n\n THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR\n IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY\n DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING\n IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n POSSIBILITY OF SUCH DAMAGE.\n \"\"\"\n}\n"], ["/FlashSpace/FlashSpace/UI/InputDialog.swift", "//\n// InputDialog.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct InputDialog: View {\n let title: String\n var placeholder = \"Type here...\"\n\n @Binding var userInput: String\n @Binding var isPresented: Bool\n\n var body: some View {\n VStack(alignment: .leading, spacing: 4.0) {\n Text(title)\n .font(.headline)\n\n TextField(placeholder, text: $userInput)\n .textFieldStyle(RoundedBorderTextFieldStyle())\n .padding(.vertical, 8.0)\n .onSubmit { isPresented = false }\n\n HStack {\n Spacer()\n Button(\"Cancel\") {\n userInput = \"\"\n isPresented = false\n }\n Button(\"OK\") { isPresented = false }\n }\n }\n .padding()\n .frame(width: 300, height: 110)\n .onKeyPress(.escape) {\n userInput = \"\"\n isPresented = false\n return .handled\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/HotKeys/Models/KeyCodesMap.swift", "//\n// KeyCodesMap.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Carbon\n\nenum KeyCodesMap {\n private(set) static var toKeyCode = create()\n\n static let toString = toKeyCode.reduce(into: [RawKeyCode: String]()) { result, pair in\n result[pair.value] = pair.key\n\n for (alias, keyCode) in getAliases() {\n result[keyCode] = alias\n }\n }\n\n static subscript(key: String) -> RawKeyCode? { toKeyCode[key] }\n\n static func refresh() {\n toKeyCode = create()\n }\n\n private static func create() -> [String: RawKeyCode] {\n var stringToKeyCodes: [String: RawKeyCode] = [:]\n var currentKeyboard = TISCopyCurrentKeyboardInputSource().takeRetainedValue()\n var rawLayoutData = TISGetInputSourceProperty(currentKeyboard, kTISPropertyUnicodeKeyLayoutData)\n if rawLayoutData == nil {\n currentKeyboard = TISCopyCurrentASCIICapableKeyboardLayoutInputSource().takeUnretainedValue()\n rawLayoutData = TISGetInputSourceProperty(currentKeyboard, kTISPropertyUnicodeKeyLayoutData)\n }\n\n let layoutData = unsafeBitCast(rawLayoutData, to: CFData.self)\n let layout: UnsafePointer = unsafeBitCast(\n CFDataGetBytePtr(layoutData),\n to: UnsafePointer.self\n )\n\n var keysDown: UInt32 = 0\n var chars: [UniChar] = [0, 0, 0, 0]\n var realLength = 0\n\n for keyCode in 0..<128 {\n switch keyCode {\n case kVK_ANSI_Keypad0, kVK_ANSI_Keypad1, kVK_ANSI_Keypad2, kVK_ANSI_Keypad3,\n kVK_ANSI_Keypad4, kVK_ANSI_Keypad5, kVK_ANSI_Keypad6, kVK_ANSI_Keypad7,\n kVK_ANSI_Keypad8, kVK_ANSI_Keypad9,\n kVK_ANSI_KeypadMinus, kVK_ANSI_KeypadMultiply, kVK_ANSI_KeypadDivide,\n kVK_ANSI_KeypadDecimal, kVK_ANSI_KeypadClear, kVK_ANSI_KeypadEnter,\n kVK_ANSI_KeypadEquals, kVK_ANSI_KeypadPlus:\n continue\n default: break\n }\n\n UCKeyTranslate(\n layout,\n UInt16(keyCode),\n UInt16(kUCKeyActionDisplay),\n 0,\n UInt32(LMGetKbdType()),\n UInt32(kUCKeyTranslateNoDeadKeysBit),\n &keysDown,\n chars.count,\n &realLength,\n &chars\n )\n\n let string = CFStringCreateWithCharacters(kCFAllocatorDefault, chars, realLength) as String\n if !stringToKeyCodes.keys.contains(string) {\n stringToKeyCodes[string] = UInt16(keyCode)\n }\n }\n\n let aliases = getAliases()\n for (alias, keyCode) in aliases {\n stringToKeyCodes[alias] = keyCode\n }\n\n return stringToKeyCodes\n }\n\n private static func getAliases() -> [String: RawKeyCode] {\n [\n \"space\": UInt16(kVK_Space),\n \"enter\": UInt16(kVK_Return),\n \"up\": UInt16(kVK_UpArrow),\n \"right\": UInt16(kVK_RightArrow),\n \"down\": UInt16(kVK_DownArrow),\n \"left\": UInt16(kVK_LeftArrow),\n \"delete\": UInt16(kVK_Delete),\n \"forward-delete\": UInt16(kVK_ForwardDelete),\n \"escape\": UInt16(kVK_Escape),\n \"tab\": UInt16(kVK_Tab),\n \"capslock\": UInt16(kVK_CapsLock),\n \"f1\": UInt16(kVK_F1),\n \"f2\": UInt16(kVK_F2),\n \"f3\": UInt16(kVK_F3),\n \"f4\": UInt16(kVK_F4),\n \"f5\": UInt16(kVK_F5),\n \"f6\": UInt16(kVK_F6),\n \"f7\": UInt16(kVK_F7),\n \"f8\": UInt16(kVK_F8),\n \"f9\": UInt16(kVK_F9),\n \"f10\": UInt16(kVK_F10),\n \"f11\": UInt16(kVK_F11),\n \"f12\": UInt16(kVK_F12),\n \"num0\": UInt16(kVK_ANSI_Keypad0),\n \"num1\": UInt16(kVK_ANSI_Keypad1),\n \"num2\": UInt16(kVK_ANSI_Keypad2),\n \"num3\": UInt16(kVK_ANSI_Keypad3),\n \"num4\": UInt16(kVK_ANSI_Keypad4),\n \"num5\": UInt16(kVK_ANSI_Keypad5),\n \"num6\": UInt16(kVK_ANSI_Keypad6),\n \"num7\": UInt16(kVK_ANSI_Keypad7),\n \"num8\": UInt16(kVK_ANSI_Keypad8),\n \"num9\": UInt16(kVK_ANSI_Keypad9),\n \"num-plus\": UInt16(kVK_ANSI_KeypadPlus),\n \"num-minus\": UInt16(kVK_ANSI_KeypadMinus),\n \"num-multiply\": UInt16(kVK_ANSI_KeypadMultiply),\n \"num-divide\": UInt16(kVK_ANSI_KeypadDivide),\n \"num-clear\": UInt16(kVK_ANSI_KeypadClear),\n \"num-enter\": UInt16(kVK_ANSI_KeypadEnter),\n \"num-equals\": UInt16(kVK_ANSI_KeypadEquals),\n \"num-decimal\": UInt16(kVK_ANSI_KeypadDecimal)\n ]\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/PictureInPicture/Models/PipBrowser.swift", "//\n// PipBrowser.swift\n//\n// Created by Wojciech Kulik on 12/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\n/// Browser apps that support Picture in Picture\nenum PipBrowser: String, CaseIterable {\n case chrome = \"com.google.Chrome\"\n case vivaldi = \"com.vivaldi.Vivaldi\"\n case brave = \"com.brave.Browser\"\n case opera = \"com.operasoftware.Opera\"\n case firefox = \"org.mozilla.firefox\"\n case zen = \"app.zen-browser.zen\"\n case arc = \"company.thebrowser.Browser\"\n case dia = \"company.thebrowser.dia\"\n case comet = \"ai.perplexity.comet\"\n\n var bundleId: String { rawValue }\n\n var title: String? {\n switch self {\n case .chrome, .vivaldi, .brave, .opera, .comet:\n return \"Picture in Picture\"\n case .zen, .firefox:\n return \"Picture-in-Picture\"\n case .arc, .dia:\n return nil\n }\n }\n\n var partialTitle: String? {\n switch self {\n case .chrome:\n return \"about:blank \"\n default:\n return nil\n }\n }\n\n var subrole: String? {\n switch self {\n case .arc, .dia:\n return (NSAccessibility.Subrole.systemDialog as CFString) as String\n default:\n return nil\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/MenuBar/MenuBarSettings.swift", "//\n// MenuBarSettings.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nfinal class MenuBarSettings: ObservableObject {\n static let defaultMenuBarTitleTemplate = \"$WORKSPACE\"\n\n @Published var showMenuBarTitle = true\n @Published var showMenuBarIcon = true\n @Published var menuBarTitleTemplate = MenuBarSettings.defaultMenuBarTitleTemplate\n @Published var menuBarDisplayAliases = \"\"\n\n private var observer: AnyCancellable?\n private let updateSubject = PassthroughSubject<(), Never>()\n\n init() { observe() }\n\n private func observe() {\n observer = Publishers.MergeMany(\n $showMenuBarTitle.settingsPublisher(),\n $showMenuBarIcon.settingsPublisher(),\n $menuBarTitleTemplate.settingsPublisher(debounce: true),\n $menuBarDisplayAliases.settingsPublisher(debounce: true)\n )\n .receive(on: DispatchQueue.main)\n .sink { [weak self] in self?.updateSubject.send() }\n }\n}\n\nextension MenuBarSettings: SettingsProtocol {\n var updatePublisher: AnyPublisher<(), Never> {\n updateSubject.eraseToAnyPublisher()\n }\n\n func load(from appSettings: AppSettings) {\n observer = nil\n showMenuBarTitle = appSettings.showMenuBarTitle ?? true\n showMenuBarIcon = appSettings.showMenuBarIcon ?? true\n menuBarTitleTemplate = appSettings.menuBarTitleTemplate ?? Self.defaultMenuBarTitleTemplate\n menuBarDisplayAliases = appSettings.menuBarDisplayAliases ?? \"\"\n observe()\n }\n\n func update(_ appSettings: inout AppSettings) {\n appSettings.showMenuBarTitle = showMenuBarTitle\n appSettings.showMenuBarIcon = showMenuBarIcon\n appSettings.menuBarTitleTemplate = menuBarTitleTemplate\n appSettings.menuBarDisplayAliases = menuBarDisplayAliases\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/MainScreen/AppCell.swift", "//\n// AppCell.swift\n//\n// Created by Wojciech Kulik on 20/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct AppCell: View {\n let workspaceId: WorkspaceID\n let app: MacApp\n\n var body: some View {\n HStack {\n if let iconPath = app.iconPath, let image = NSImage(byReferencingFile: iconPath) {\n Image(nsImage: image)\n .resizable()\n .scaledToFit()\n .frame(width: 20, height: 20)\n }\n Text(app.name)\n .foregroundColor(app.bundleIdentifier.isEmpty ? .errorRed : .primary)\n }\n .draggable(MacAppWithWorkspace(app: app, workspaceId: workspaceId))\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/HotKeys/Extensions/AppHotKey+KeyboardShortcut.swift", "//\n// AppHotKey+KeyboardShortcut.swift\n//\n// Created by Wojciech Kulik on 31/05/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nextension AppHotKey {\n var toKeyboardShortcut: KeyboardShortcut? {\n let components = value.components(separatedBy: \"+\")\n let modifiers = toEventModifiers(value)\n\n guard let key = components.last,\n let keyEquivalent = stringToKeyEquivalent(key) else { return nil }\n\n return KeyboardShortcut(\n keyEquivalent,\n modifiers: modifiers\n )\n }\n\n // swiftlint:disable:next cyclomatic_complexity\n private func stringToKeyEquivalent(_ value: String) -> KeyEquivalent? {\n guard value.count > 1 else { return KeyEquivalent(Character(value)) }\n\n switch value {\n case \"esc\", \"escape\": return KeyEquivalent.escape\n case \"return\", \"enter\": return KeyEquivalent.return\n case \"tab\": return KeyEquivalent.tab\n case \"space\": return KeyEquivalent.space\n case \"delete\", \"backspace\": return KeyEquivalent.delete\n case \"up\": return KeyEquivalent.upArrow\n case \"down\": return KeyEquivalent.downArrow\n case \"left\": return KeyEquivalent.leftArrow\n case \"right\": return KeyEquivalent.rightArrow\n case \"home\": return KeyEquivalent.home\n case \"end\": return KeyEquivalent.end\n default: return nil\n }\n }\n\n private func toEventModifiers(_ value: String) -> EventModifiers {\n let flags = value.lowercased().split(separator: \"+\").map { String($0) }\n var result: EventModifiers = []\n\n if flags.contains(\"cmd\") { result.insert(.command) }\n if flags.contains(\"ctrl\") { result.insert(.control) }\n if flags.contains(\"opt\") { result.insert(.option) }\n if flags.contains(\"shift\") { result.insert(.shift) }\n\n return result\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Config/ConfigSerializer.swift", "//\n// ConfigSerializer.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\nimport TOMLKit\nimport Yams\n\nenum ConfigSerializer {\n static let configDirectory = FileManager.default\n .homeDirectoryForCurrentUser\n .appendingPathComponent(\".config/flashspace\")\n\n private(set) static var format: ConfigFormat = detectFormat()\n\n static func serialize(filename: String, _ value: some Encodable) throws {\n let url = getUrl(for: filename)\n let data = try encoder.encode(value)\n try? url.createIntermediateDirectories()\n try data.write(to: url)\n }\n\n static func deserialize(_ type: T.Type, filename: String) throws -> T? where T: Decodable {\n let url = getUrl(for: filename)\n\n guard FileManager.default.fileExists(atPath: url.path) else { return nil }\n\n do {\n let data = try Data(contentsOf: url)\n\n return try decoder.decode(type, from: data)\n } catch {\n Logger.log(\"Failed to deserialize \\(filename): \\(error)\")\n throw error\n }\n }\n\n static func convert(to: ConfigFormat) throws {\n guard format != to else { return }\n\n let settingsUrl = getUrl(for: \"settings\", ext: format.rawValue)\n let profilesUrl = getUrl(for: \"profiles\", ext: format.rawValue)\n let timestamp = Int(Date().timeIntervalSince1970)\n\n try? FileManager.default.moveItem(\n at: settingsUrl,\n to: configDirectory.appendingPathComponent(\"settings-backup-\\(timestamp).\\(format.rawValue)\")\n )\n try? FileManager.default.moveItem(\n at: profilesUrl,\n to: configDirectory.appendingPathComponent(\"profiles-backup-\\(timestamp).\\(format.rawValue)\")\n )\n\n format = to\n AppDependencies.shared.settingsRepository.saveToDisk()\n AppDependencies.shared.profilesRepository.saveToDisk()\n\n Logger.log(\"Converted config format to \\(to.displayName)\")\n }\n}\n\nprivate extension ConfigSerializer {\n static var encoder: ConfigEncoder {\n switch format {\n case .json: return jsonEncoder\n case .toml: return tomlEncoder\n case .yaml: return yamlEncoder\n }\n }\n\n static var decoder: ConfigDecoder {\n switch format {\n case .json: return jsonDecoder\n case .toml: return tomlDecoder\n case .yaml: return yamlDecoder\n }\n }\n\n static let jsonDecoder = JSONDecoder()\n static let jsonEncoder = {\n let encoder = JSONEncoder()\n encoder.outputFormatting = [\n .prettyPrinted,\n .withoutEscapingSlashes,\n .sortedKeys\n ]\n return encoder\n }()\n\n static let tomlDecoder = TOMLDecoder()\n static let tomlEncoder = TOMLEncoder()\n static let yamlEncoder = YAMLEncoder()\n static let yamlDecoder = YAMLDecoder()\n\n static func getUrl(for filename: String, ext: String? = nil) -> URL {\n configDirectory\n .appendingPathComponent(filename)\n .appendingPathExtension(ext ?? ConfigSerializer.format.extensionName)\n }\n\n static func detectFormat() -> ConfigFormat {\n for format in ConfigFormat.allCases {\n let url = getUrl(for: \"profiles\", ext: format.rawValue)\n if FileManager.default.fileExists(atPath: url.path) {\n Logger.log(\"Detected config format \\(format.displayName) at \\(url.path)\")\n return format\n }\n }\n\n return .json\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Models/CommandError.swift", "//\n// CommandError.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nenum CommandError: Error, LocalizedError {\n case timeout\n case connectionError(Error)\n case emptyResponse\n case couldNotEncode(Error)\n case operationFailed(String)\n case missingArgument\n case other\n\n var errorDescription: String? {\n switch self {\n case .timeout:\n return \"Timeout. Please check if FlashSpace is running.\"\n case .connectionError(let error):\n return \"Connection error. Please check if FlashSpace is running.\\n\\(error)\"\n case .emptyResponse:\n return \"Empty response. Please check if FlashSpace is running.\"\n case .couldNotEncode(let error):\n return \"Could not encode the message. Please try again.\\n\\(error)\"\n case .operationFailed(let message):\n return message\n case .missingArgument:\n return \"Missing argument(s). Please provide the required argument(s).\"\n case .other:\n return \"\"\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/FloatingApps/FloatingAppsSettings.swift", "//\n// FloatingAppsSettings.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nfinal class FloatingAppsSettings: ObservableObject {\n @Published var floatingApps: [MacApp] = []\n @Published var floatTheFocusedApp: AppHotKey?\n @Published var unfloatTheFocusedApp: AppHotKey?\n @Published var toggleTheFocusedAppFloating: AppHotKey?\n\n private var observer: AnyCancellable?\n private let updateSubject = PassthroughSubject<(), Never>()\n\n init() { observe() }\n\n func addFloatingAppIfNeeded(app: MacApp) {\n guard !floatingApps.contains(app) else { return }\n floatingApps.append(app)\n }\n\n func deleteFloatingApp(app: MacApp) {\n floatingApps.removeAll { $0 == app }\n }\n\n private func observe() {\n observer = Publishers.MergeMany(\n $floatingApps.settingsPublisher(),\n $floatTheFocusedApp.settingsPublisher(),\n $unfloatTheFocusedApp.settingsPublisher(),\n $toggleTheFocusedAppFloating.settingsPublisher()\n )\n .receive(on: DispatchQueue.main)\n .sink { [weak self] in self?.updateSubject.send() }\n }\n}\n\nextension FloatingAppsSettings: SettingsProtocol {\n var updatePublisher: AnyPublisher<(), Never> {\n updateSubject.eraseToAnyPublisher()\n }\n\n func load(from appSettings: AppSettings) {\n observer = nil\n floatingApps = appSettings.floatingApps ?? []\n floatTheFocusedApp = appSettings.floatTheFocusedApp\n unfloatTheFocusedApp = appSettings.unfloatTheFocusedApp\n toggleTheFocusedAppFloating = appSettings.toggleTheFocusedAppFloating\n observe()\n }\n\n func update(_ appSettings: inout AppSettings) {\n appSettings.floatingApps = floatingApps.isEmpty ? nil : floatingApps\n appSettings.floatTheFocusedApp = floatTheFocusedApp\n appSettings.unfloatTheFocusedApp = unfloatTheFocusedApp\n appSettings.toggleTheFocusedAppFloating = toggleTheFocusedAppFloating\n }\n}\n"], ["/FlashSpace/FlashSpace/Accessibility/NSRunningApplication+Apps.swift", "//\n// NSRunningApplication+Apps.swift\n//\n// Created by Wojciech Kulik on 12/07/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension NSRunningApplication {\n var isFinder: Bool { bundleIdentifier == \"com.apple.finder\" }\n var isPython: Bool { bundleIdentifier == \"org.python.python\" }\n var isOrion: Bool { bundleIdentifier == \"com.kagi.kagimacOS\" }\n}\n"], ["/FlashSpace/FlashSpace/Features/Displays/DisplayManager.swift", "//\n// DisplayManager.swift\n//\n// Created by Moritz Brödel on 19/06/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Combine\n\nfinal class DisplayManager: ObservableObject {\n struct Focus {\n let display: DisplayName\n let app: MacApp\n }\n\n private var focusHistory: [Focus] = []\n private let workspaceSettings: WorkspaceSettings\n\n init(settingsRepository: SettingsRepository) {\n self.workspaceSettings = settingsRepository.workspaceSettings\n }\n\n func lastFocusedDisplay(where condition: (Focus) -> Bool) -> Focus? {\n focusHistory.last(where: condition)\n }\n\n func trackDisplayFocus(on display: DisplayName, for application: NSRunningApplication) {\n guard !application.isFinder || application.allWindows.isNotEmpty else { return }\n\n focusHistory.removeAll { $0.display == display }\n focusHistory.append(.init(display: display, app: application.toMacApp))\n }\n\n func getCursorScreen() -> DisplayName? {\n let cursorLocation = NSEvent.mouseLocation\n return NSScreen.screens\n .first { NSMouseInRect(cursorLocation, $0.frame, false) }?\n .localizedName\n }\n\n func resolveDisplay(_ display: DisplayName) -> DisplayName {\n guard !NSScreen.isConnected(display) else { return display }\n\n let alternativeDisplays = workspaceSettings.alternativeDisplays\n .split(separator: \";\")\n .map { $0.split(separator: \"=\") }\n .compactMap { pair -> (source: String, target: String)? in\n guard pair.count == 2 else { return nil }\n return (String(pair[0]).trimmed, String(pair[1]).trimmed)\n }\n\n let alternative = alternativeDisplays\n .filter { $0.source == display }\n .map(\\.target)\n .first(where: NSScreen.isConnected)\n\n return alternative ?? NSScreen.main?.localizedName ?? \"\"\n }\n\n func lastActiveDisplay(from candidates: Set) -> DisplayName {\n if let recentDisplay = lastFocusedDisplay(where: { candidates.contains($0.display) })?.display {\n return recentDisplay\n }\n\n if let cursorDisplay = getCursorScreen(), candidates.contains(cursorDisplay) {\n return cursorDisplay\n }\n\n return candidates.first ?? NSScreen.main?.localizedName ?? \"\"\n }\n}\n"], ["/FlashSpace/FlashSpace/Accessibility/AXUIElement+Properties.swift", "//\n// AXUIElement+Properties.swift\n//\n// Created by Wojciech Kulik on 24/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension AXUIElement {\n var id: String? { getAttribute(.identifier) }\n var title: String? { getAttribute(.title) }\n var isMain: Bool { getAttribute(.main) == true }\n var isMinimized: Bool { getAttribute(.minimized) == true }\n var role: String? { getAttribute(.role) }\n var subrole: String? { getAttribute(.subrole) }\n var enhancedUserInterface: Bool {\n get { getAttribute(.enchancedUserInterface) == true }\n set { setAttribute(.enchancedUserInterface, value: newValue) }\n }\n\n var processId: pid_t? {\n var pid: pid_t = 0\n AXUIElementGetPid(self, &pid)\n return pid\n }\n\n /// Frame is in window coordinates where (0,0) is top-left corner\n /// and it is relative to the main screen.\n var frame: CGRect? {\n var positionValue: CFTypeRef?\n var sizeValue: CFTypeRef?\n\n guard AXUIElementCopyAttributeValue(\n self,\n NSAccessibility.Attribute.position as CFString,\n &positionValue\n ) == .success else { return nil }\n\n guard AXUIElementCopyAttributeValue(\n self,\n NSAccessibility.Attribute.size as CFString,\n &sizeValue\n ) == .success else { return nil }\n\n var windowBounds: CGRect = .zero\n\n // swiftlint:disable force_cast\n if let position = positionValue, AXValueGetType(position as! AXValue) == .cgPoint {\n AXValueGetValue(position as! AXValue, .cgPoint, &windowBounds.origin)\n }\n\n if let size = sizeValue, AXValueGetType(size as! AXValue) == .cgSize {\n AXValueGetValue(size as! AXValue, .cgSize, &windowBounds.size)\n }\n // swiftlint:enable force_cast\n\n return windowBounds.isEmpty ? nil : windowBounds\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Workspaces/WorkspaceTransitionManager.swift", "//\n// WorkspaceTransitionManager.swift\n//\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n// Contribution by Sergio Patino - https://github.com/sergiopatino\n//\n\nimport AppKit\n\nfinal class WorkspaceTransitionManager {\n private var windows: [NSWindow] = []\n private let settings: WorkspaceSettings\n\n init(workspaceSettings: WorkspaceSettings) {\n self.settings = workspaceSettings\n }\n\n func showTransitionIfNeeded(for workspace: Workspace, on displays: Set) {\n guard settings.enableWorkspaceTransitions else {\n // Small delay to allow workspace to be activated\n DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {\n NotificationCenter.default.post(name: .workspaceTransitionFinished, object: workspace)\n }\n return\n }\n guard windows.isEmpty, !SpaceControl.isVisible else { return }\n\n let screens = NSScreen.screens.filter { displays.contains($0.localizedName) }\n\n guard !screens.isEmpty else { return }\n\n for screen in screens {\n let window = NSWindow(\n contentRect: screen.frame,\n styleMask: [.borderless],\n backing: .buffered,\n defer: false\n )\n window.isOpaque = false\n window.backgroundColor = .clear\n window.level = .screenSaver\n window.alphaValue = CGFloat(settings.workspaceTransitionDimming)\n window.contentView?.wantsLayer = true\n window.contentView?.layer?.backgroundColor = NSColor.black.cgColor\n\n window.orderFrontRegardless()\n windows.append(window)\n }\n\n DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { [weak self] in\n self?.hideTransition(for: workspace)\n }\n }\n\n private func hideTransition(for workspace: Workspace) {\n guard !windows.isEmpty else { return }\n\n NSAnimationContext.runAnimationGroup({ [weak self] context in\n context.duration = self?.settings.workspaceTransitionDuration ?? 0.3\n context.timingFunction = CAMediaTimingFunction(name: .easeIn)\n self?.windows.forEach { window in\n window.animator().alphaValue = 0.0\n }\n }, completionHandler: { [weak self] in\n self?.windows.forEach { window in\n window.orderOut(nil)\n }\n self?.windows.removeAll()\n NotificationCenter.default.post(name: .workspaceTransitionFinished, object: workspace)\n })\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/FocusManager/FocusManagerSettings.swift", "//\n// FocusManagerSettings.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nfinal class FocusManagerSettings: ObservableObject {\n @Published var enableFocusManagement = false\n @Published var centerCursorOnFocusChange = false\n\n @Published var focusLeft: AppHotKey?\n @Published var focusRight: AppHotKey?\n @Published var focusUp: AppHotKey?\n @Published var focusDown: AppHotKey?\n @Published var focusNextWorkspaceApp: AppHotKey?\n @Published var focusPreviousWorkspaceApp: AppHotKey?\n @Published var focusNextWorkspaceWindow: AppHotKey?\n @Published var focusPreviousWorkspaceWindow: AppHotKey?\n @Published var focusFrontmostWindow = false\n\n private var observer: AnyCancellable?\n private let updateSubject = PassthroughSubject<(), Never>()\n\n init() { observe() }\n\n private func observe() {\n observer = Publishers.MergeMany(\n $enableFocusManagement.settingsPublisher(),\n $centerCursorOnFocusChange.settingsPublisher(),\n $focusLeft.settingsPublisher(),\n $focusRight.settingsPublisher(),\n $focusUp.settingsPublisher(),\n $focusDown.settingsPublisher(),\n $focusNextWorkspaceApp.settingsPublisher(),\n $focusPreviousWorkspaceApp.settingsPublisher(),\n $focusNextWorkspaceWindow.settingsPublisher(),\n $focusPreviousWorkspaceWindow.settingsPublisher(),\n $focusFrontmostWindow.settingsPublisher()\n )\n .receive(on: DispatchQueue.main)\n .sink { [weak self] in self?.updateSubject.send() }\n }\n}\n\nextension FocusManagerSettings: SettingsProtocol {\n var updatePublisher: AnyPublisher<(), Never> {\n updateSubject.eraseToAnyPublisher()\n }\n\n func load(from appSettings: AppSettings) {\n observer = nil\n enableFocusManagement = appSettings.enableFocusManagement ?? false\n centerCursorOnFocusChange = appSettings.centerCursorOnFocusChange ?? false\n focusLeft = appSettings.focusLeft\n focusRight = appSettings.focusRight\n focusUp = appSettings.focusUp\n focusDown = appSettings.focusDown\n focusNextWorkspaceApp = appSettings.focusNextWorkspaceApp\n focusPreviousWorkspaceApp = appSettings.focusPreviousWorkspaceApp\n focusNextWorkspaceWindow = appSettings.focusNextWorkspaceWindow\n focusPreviousWorkspaceWindow = appSettings.focusPreviousWorkspaceWindow\n focusFrontmostWindow = appSettings.focusFrontmostWindow ?? false\n observe()\n }\n\n func update(_ appSettings: inout AppSettings) {\n appSettings.enableFocusManagement = enableFocusManagement\n appSettings.centerCursorOnFocusChange = centerCursorOnFocusChange\n appSettings.focusLeft = focusLeft\n appSettings.focusRight = focusRight\n appSettings.focusUp = focusUp\n appSettings.focusDown = focusDown\n appSettings.focusNextWorkspaceApp = focusNextWorkspaceApp\n appSettings.focusPreviousWorkspaceApp = focusPreviousWorkspaceApp\n appSettings.focusNextWorkspaceWindow = focusNextWorkspaceWindow\n appSettings.focusPreviousWorkspaceWindow = focusPreviousWorkspaceWindow\n appSettings.focusFrontmostWindow = focusFrontmostWindow\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/CornerRadius.swift", "//\n// CornerRadius.swift\n//\n// Created by Wojciech Kulik on 11/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport SwiftUI\n\nstruct RoundedCorners: Shape {\n var radius: CGFloat\n var corners: [Corner]\n\n enum Corner {\n case topLeft, topRight, bottomLeft, bottomRight\n }\n\n func path(in rect: CGRect) -> Path {\n var path = Path()\n\n let topLeft = corners.contains(.topLeft) ? radius : 0\n let topRight = corners.contains(.topRight) ? radius : 0\n let bottomLeft = corners.contains(.bottomLeft) ? radius : 0\n let bottomRight = corners.contains(.bottomRight) ? radius : 0\n\n path.move(to: CGPoint(x: rect.minX, y: rect.midY))\n\n path.addArc(\n center: CGPoint(x: rect.minX + topLeft, y: rect.minY + topLeft),\n radius: topLeft,\n startAngle: .degrees(180),\n endAngle: .degrees(270),\n clockwise: false\n )\n\n path.addArc(\n center: CGPoint(x: rect.maxX - topRight, y: rect.minY + topRight),\n radius: topRight,\n startAngle: .degrees(270),\n endAngle: .degrees(0),\n clockwise: false\n )\n\n path.addArc(\n center: CGPoint(x: rect.maxX - bottomRight, y: rect.maxY - bottomRight),\n radius: bottomRight,\n startAngle: .degrees(0),\n endAngle: .degrees(90),\n clockwise: false\n )\n\n path.addArc(\n center: CGPoint(x: rect.minX + bottomLeft, y: rect.maxY - bottomLeft),\n radius: bottomLeft,\n startAngle: .degrees(90),\n endAngle: .degrees(180),\n clockwise: false\n )\n\n path.closeSubpath()\n return path\n }\n}\n\nextension View {\n func cornerRadius(_ radius: CGFloat, corners: [RoundedCorners.Corner]) -> some View {\n clipShape(RoundedCorners(radius: radius, corners: corners))\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/HotKeys/Models/AppHotKey.swift", "//\n// AppHotKey.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\ntypealias RawKeyCode = UInt16\ntypealias RawKeyModifiers = UInt\n\nstruct AppHotKey: Codable, Hashable {\n let value: String\n\n init(value: String) { self.value = value }\n\n init(keyCode: RawKeyCode, modifiers: RawKeyModifiers) {\n let keyEquivalent = KeyCodesMap.toString[keyCode] ?? \"\"\n let modifiers = KeyModifiersMap.toString(modifiers)\n let result = [modifiers, keyEquivalent].filter { !$0.isEmpty }.joined(separator: \"+\")\n\n self.init(value: result)\n }\n\n init(from decoder: Decoder) throws {\n enum CodingKeys: String, CodingKey { case keyCode, modifiers }\n\n if let container = try? decoder.container(keyedBy: CodingKeys.self) {\n // v1 -> v2 Migration\n let keyCode = try container.decodeIfPresent(RawKeyCode.self, forKey: .keyCode)\n let modifiers = try container.decodeIfPresent(RawKeyModifiers.self, forKey: .modifiers)\n\n if let keyCode, let modifiers {\n Migrations.hotKeysMigrated = true\n self.init(keyCode: keyCode, modifiers: modifiers)\n } else {\n throw DecodingError.dataCorruptedError(\n forKey: .keyCode,\n in: container,\n debugDescription: \"Invalid key code or modifiers\"\n )\n }\n } else {\n // v2\n let container = try decoder.singleValueContainer()\n try self.init(value: container.decode(String.self))\n }\n }\n\n func encode(to encoder: any Encoder) throws {\n var container = encoder.singleValueContainer()\n try container.encode(value)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Commands/SpaceControlCommands.swift", "//\n// SpaceControlCommands.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\n\nfinal class SpaceControlCommands: CommandExecutor {\n func execute(command: CommandRequest) -> CommandResponse? {\n switch command {\n case .openSpaceControl:\n if SpaceControl.isEnabled {\n SpaceControl.show()\n return CommandResponse(success: true)\n } else {\n return CommandResponse(success: false, error: \"Space Control is not enabled\")\n }\n\n default:\n return nil\n }\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/SocketClient.swift", "//\n// SocketClient.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\nimport Network\n\nfinal class SocketClient {\n static let shared = SocketClient()\n\n private let socketPath = \"/tmp/flashspace.socket\"\n private var buffer = Data()\n private let jsonEncoder = JSONEncoder()\n\n private init() {}\n\n func sendCommand(_ command: CommandRequest) {\n let connection = NWConnection(to: .unix(path: socketPath), using: .tcp)\n connection.start(queue: .main)\n\n let messageData = command.encodeSocketData()\n connection.send(content: messageData, completion: .contentProcessed { error in\n if let error {\n connection.cancel()\n FlashSpaceCLI.exit(withError: CommandError.connectionError(error))\n }\n\n self.receiveData(connection: connection)\n })\n }\n\n private func receiveData(connection: NWConnection) {\n connection.receive(minimumIncompleteLength: 1, maximumLength: 10000) { data, _, isComplete, error in\n if let error {\n connection.cancel()\n FlashSpaceCLI.exit(withError: CommandError.connectionError(error))\n }\n\n if let data { self.buffer.append(data) }\n\n // Check if the message is complete or EOF is reached\n guard isComplete || data?.last == 0 else {\n return self.receiveData(connection: connection)\n }\n\n if self.buffer.isEmpty {\n connection.cancel()\n FlashSpaceCLI.exit(withError: CommandError.emptyResponse)\n }\n\n if let response = try? self.buffer.decodeSocketData(CommandResponse.self) {\n self.handleResponse(response, connection: connection)\n } else {\n FlashSpaceCLI.exit(withError: CommandError.operationFailed(\"Could not decode the response\"))\n }\n }\n }\n\n private func handleResponse(_ response: CommandResponse, connection: NWConnection) {\n if response.success {\n response.message.flatMap { print($0) }\n connection.cancel()\n FlashSpaceCLI.exit()\n } else {\n connection.cancel()\n FlashSpaceCLI.exit(withError: CommandError.operationFailed(response.error ?? \"Operation Failed\"))\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/FocusManager/Models/MacAppWithWindows.swift", "//\n// MacAppWithWindows.swift\n//\n// Created by Wojciech Kulik on 04/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport CoreGraphics\n\nstruct MacAppWithWindows {\n struct MacAppWindow {\n let frame: CGRect\n let title: String\n let axWindow: AXUIElement\n }\n\n let app: NSRunningApplication\n let bundleIdentifier: BundleId\n\n /// Sorted by title and then by x position\n let windows: [MacAppWindow]\n\n init(app: NSRunningApplication) {\n self.app = app\n self.bundleIdentifier = app.bundleIdentifier ?? \"\"\n self.windows = app.allWindows\n .map { MacAppWindow(frame: $0.frame, title: $0.window.title ?? \"\", axWindow: $0.window) }\n .sorted { $0.title < $1.title || $0.title == $1.title && $0.frame.minX < $1.frame.minX }\n }\n}\n"], ["/FlashSpace/FlashSpace/App/FlashSpaceApp.swift", "//\n// FlashSpaceApp.swift\n// FlashSpace\n//\n// Created by Wojciech Kulik on 19/01/2025.\n//\n\nimport SwiftUI\n\n@main\nstruct FlashSpaceApp: App {\n @NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate\n\n var body: some Scene {\n Window(\"⚡ FlashSpace v\\(AppConstants.version)\", id: \"main\") {\n MainView()\n }\n .windowResizability(.contentSize)\n\n Window(\"Settings\", id: \"settings\") {\n SettingsView()\n }\n .windowResizability(.contentSize)\n\n FlashSpaceMenuBar()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Workspaces/Models/MacAppWithWorkspace.swift", "//\n// MacAppWithWorkspace.swift\n//\n// Created by Wojciech Kulik on 20/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\nimport SwiftUI\n\nstruct MacAppWithWorkspace: Hashable, Codable {\n var app: MacApp\n var workspaceId: WorkspaceID\n}\n\nextension MacAppWithWorkspace: Transferable {\n static var transferRepresentation: some TransferRepresentation {\n CodableRepresentation(for: MacAppWithWorkspace.self, contentType: .json)\n }\n}\n"], ["/FlashSpace/FlashSpace/Accessibility/System.swift", "//\n// System.swift\n//\n// Created by Wojciech Kulik on 01/05/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nstruct AppWindow {\n let name: String\n let pid: pid_t\n}\n\nenum System {\n static var orderedWindows: [AppWindow] {\n let list = CGWindowListCopyWindowInfo(.optionOnScreenOnly, kCGNullWindowID) as? [[String: Any]]\n guard let list else { return [] }\n\n return list.compactMap {\n let windowName = $0[kCGWindowName as String] as? String\n let windowOwnerPID = $0[kCGWindowOwnerPID as String] as? pid_t\n if let windowOwnerPID {\n return AppWindow(name: windowName ?? \"-\", pid: windowOwnerPID)\n } else {\n return nil\n }\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/SpaceControl/SpaceControlSettings.swift", "//\n// SpaceControlSettings.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nfinal class SpaceControlSettings: ObservableObject {\n @Published var enableSpaceControl = false\n @Published var showSpaceControl: AppHotKey?\n @Published var enableSpaceControlAnimations = true\n @Published var spaceControlCurrentDisplayWorkspaces = false\n @Published var spaceControlMaxColumns = 6\n\n private var observer: AnyCancellable?\n private let updateSubject = PassthroughSubject<(), Never>()\n\n init() { observe() }\n\n private func observe() {\n observer = Publishers.MergeMany(\n $enableSpaceControl.settingsPublisher(),\n $showSpaceControl.settingsPublisher(),\n $enableSpaceControlAnimations.settingsPublisher(),\n $spaceControlCurrentDisplayWorkspaces.settingsPublisher(),\n $spaceControlMaxColumns.settingsPublisher(debounce: true)\n )\n .receive(on: DispatchQueue.main)\n .sink { [weak self] in self?.updateSubject.send() }\n }\n}\n\nextension SpaceControlSettings: SettingsProtocol {\n var updatePublisher: AnyPublisher<(), Never> {\n updateSubject.eraseToAnyPublisher()\n }\n\n func load(from appSettings: AppSettings) {\n observer = nil\n enableSpaceControl = appSettings.enableSpaceControl ?? false\n showSpaceControl = appSettings.showSpaceControl\n enableSpaceControlAnimations = appSettings.enableSpaceControlAnimations ?? true\n spaceControlCurrentDisplayWorkspaces = appSettings.spaceControlCurrentDisplayWorkspaces ?? false\n spaceControlMaxColumns = appSettings.spaceControlMaxColumns ?? 6\n observe()\n }\n\n func update(_ appSettings: inout AppSettings) {\n appSettings.enableSpaceControl = enableSpaceControl\n appSettings.showSpaceControl = showSpaceControl\n appSettings.enableSpaceControlAnimations = enableSpaceControlAnimations\n appSettings.spaceControlCurrentDisplayWorkspaces = spaceControlCurrentDisplayWorkspaces\n appSettings.spaceControlMaxColumns = spaceControlMaxColumns\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/SpaceControl/Views/SpaceControlWindow.swift", "//\n// SpaceControlWindow.swift\n//\n// Created by Wojciech Kulik on 11/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport SwiftUI\n\nfinal class SpaceControlWindow: NSWindow, NSWindowDelegate {\n override var canBecomeKey: Bool { true }\n\n override func keyDown(with event: NSEvent) {\n if event.keyCode == KeyCodesMap[\"escape\"] {\n SpaceControl.hide(restoreFocus: true)\n return\n } else if [\"up\", \"down\", \"right\", \"left\"]\n .compactMap({ KeyCodesMap[$0] })\n .contains(event.keyCode) {\n NotificationCenter.default.post(name: .spaceControlArrowDown, object: event.keyCode)\n return\n }\n\n let settings = AppDependencies.shared.spaceControlSettings\n let workspaceManager = AppDependencies.shared.workspaceManager\n var workspaces = AppDependencies.shared.workspaceRepository.workspaces\n\n if settings.spaceControlCurrentDisplayWorkspaces {\n workspaces = workspaces.filter(\\.isOnTheCurrentScreen)\n }\n\n var digit = Int(event.charactersIgnoringModifiers ?? \"\") ?? -1\n if (0...9).contains(digit) {\n SpaceControl.hide()\n digit = digit == 0 ? 10 : digit\n\n if let workspace = workspaces[safe: digit - 1] {\n workspaceManager.activateWorkspace(workspace, setFocus: true)\n }\n return\n }\n\n super.keyDown(with: event)\n }\n\n override func resignFirstResponder() -> Bool {\n SpaceControl.hide()\n return super.resignFirstResponder()\n }\n\n func windowDidResignKey(_ notification: Notification) {\n SpaceControl.hide()\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Gestures/GesturesSettings.swift", "//\n// GesturesSettings.swift\n//\n// Created by Wojciech Kulik on 22/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nfinal class GesturesSettings: ObservableObject {\n @Published var swipeThreshold: Double = 0.2\n @Published var enableSwipeGestures = false {\n didSet { updateSwipeManager() }\n }\n\n @Published var restartAppOnWakeUp = false\n\n @Published var swipeRight3FingerAction: GestureAction = .nextWorkspace\n @Published var swipeLeft3FingerAction: GestureAction = .previousWorkspace\n @Published var swipeRight4FingerAction: GestureAction = .none\n @Published var swipeLeft4FingerAction: GestureAction = .none\n\n @Published var swipeUp3FingerAction: GestureAction = .none\n @Published var swipeDown3FingerAction: GestureAction = .none\n @Published var swipeUp4FingerAction: GestureAction = .none\n @Published var swipeDown4FingerAction: GestureAction = .none\n\n var isVerticalSwipeSet: Bool {\n swipeUp3FingerAction != .none || swipeDown3FingerAction != .none ||\n swipeUp4FingerAction != .none || swipeDown4FingerAction != .none\n }\n\n var isHorizontalSwipeSet: Bool {\n swipeLeft3FingerAction != .none || swipeRight3FingerAction != .none ||\n swipeLeft4FingerAction != .none || swipeRight4FingerAction != .none\n }\n\n private var observer: AnyCancellable?\n private let updateSubject = PassthroughSubject<(), Never>()\n\n init() {\n observe()\n updateSwipeManager()\n }\n\n private func observe() {\n observer = Publishers.MergeMany(\n $enableSwipeGestures.settingsPublisher(),\n $swipeThreshold.settingsPublisher(),\n $restartAppOnWakeUp.settingsPublisher(),\n\n $swipeLeft3FingerAction.settingsPublisher(),\n $swipeRight3FingerAction.settingsPublisher(),\n $swipeLeft4FingerAction.settingsPublisher(),\n $swipeRight4FingerAction.settingsPublisher(),\n\n $swipeUp3FingerAction.settingsPublisher(),\n $swipeDown3FingerAction.settingsPublisher(),\n $swipeUp4FingerAction.settingsPublisher(),\n $swipeDown4FingerAction.settingsPublisher()\n )\n .receive(on: DispatchQueue.main)\n .sink { [weak self] in self?.updateSubject.send() }\n }\n\n private func updateSwipeManager() {\n if enableSwipeGestures {\n SwipeManager.shared.start()\n } else {\n SwipeManager.shared.stop()\n }\n }\n}\n\nextension GesturesSettings: SettingsProtocol {\n var updatePublisher: AnyPublisher<(), Never> {\n updateSubject.eraseToAnyPublisher()\n }\n\n func load(from appSettings: AppSettings) {\n observer = nil\n enableSwipeGestures = appSettings.enableSwipeGestures ?? false\n swipeThreshold = appSettings.swipeThreshold ?? 0.2\n restartAppOnWakeUp = appSettings.restartAppOnWakeUp ?? false\n\n swipeLeft3FingerAction = appSettings.swipeLeft3FingerAction ?? .previousWorkspace\n swipeRight3FingerAction = appSettings.swipeRight3FingerAction ?? .nextWorkspace\n swipeLeft4FingerAction = appSettings.swipeLeft4FingerAction ?? .none\n swipeRight4FingerAction = appSettings.swipeRight4FingerAction ?? .none\n\n swipeUp3FingerAction = appSettings.swipeUp3FingerAction ?? .none\n swipeDown3FingerAction = appSettings.swipeDown3FingerAction ?? .none\n swipeUp4FingerAction = appSettings.swipeUp4FingerAction ?? .none\n swipeDown4FingerAction = appSettings.swipeDown4FingerAction ?? .none\n\n observe()\n }\n\n func update(_ appSettings: inout AppSettings) {\n appSettings.enableSwipeGestures = enableSwipeGestures\n appSettings.swipeThreshold = swipeThreshold\n appSettings.restartAppOnWakeUp = restartAppOnWakeUp\n\n appSettings.swipeLeft3FingerAction = swipeLeft3FingerAction\n appSettings.swipeRight3FingerAction = swipeRight3FingerAction\n appSettings.swipeLeft4FingerAction = swipeLeft4FingerAction\n appSettings.swipeRight4FingerAction = swipeRight4FingerAction\n\n appSettings.swipeUp3FingerAction = swipeUp3FingerAction\n appSettings.swipeDown3FingerAction = swipeDown3FingerAction\n appSettings.swipeUp4FingerAction = swipeUp4FingerAction\n appSettings.swipeDown4FingerAction = swipeDown4FingerAction\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/General/GeneralSettings.swift", "//\n// GeneralSettings.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nfinal class GeneralSettings: ObservableObject {\n @Published var showFlashSpace: AppHotKey?\n @Published var showFloatingNotifications = true\n @Published var checkForUpdatesAutomatically = false {\n didSet { UpdatesManager.shared.autoCheckForUpdates = checkForUpdatesAutomatically }\n }\n\n private var observer: AnyCancellable?\n private let updateSubject = PassthroughSubject<(), Never>()\n\n init() { observe() }\n\n private func observe() {\n observer = Publishers.MergeMany(\n $showFlashSpace.settingsPublisher(),\n $checkForUpdatesAutomatically.settingsPublisher(),\n $showFloatingNotifications.settingsPublisher()\n )\n .receive(on: DispatchQueue.main)\n .sink { [weak self] in self?.updateSubject.send() }\n }\n}\n\nextension GeneralSettings: SettingsProtocol {\n var updatePublisher: AnyPublisher<(), Never> {\n updateSubject.eraseToAnyPublisher()\n }\n\n func load(from appSettings: AppSettings) {\n observer = nil\n showFlashSpace = appSettings.showFlashSpace\n checkForUpdatesAutomatically = appSettings.checkForUpdatesAutomatically ?? false\n showFloatingNotifications = appSettings.showFloatingNotifications ?? true\n observe()\n }\n\n func update(_ appSettings: inout AppSettings) {\n appSettings.showFlashSpace = showFlashSpace\n appSettings.checkForUpdatesAutomatically = checkForUpdatesAutomatically\n appSettings.showFloatingNotifications = showFloatingNotifications\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/MacAppArray.swift", "//\n// MacAppArray.swift\n//\n// Created by Wojciech Kulik on 06/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension [MacApp] {\n func firstIndex(ofAppWith bundleIdentifier: BundleId) -> Int? {\n firstIndex { $0.bundleIdentifier == bundleIdentifier }\n }\n\n func firstIndex(of app: NSRunningApplication) -> Int? {\n firstIndex { $0.bundleIdentifier == app.bundleIdentifier }\n }\n\n func containsApp(with bundleIdentifier: BundleId?) -> Bool {\n contains { $0.bundleIdentifier == bundleIdentifier }\n }\n\n func containsApp(_ app: NSRunningApplication) -> Bool {\n contains { $0.bundleIdentifier == app.bundleIdentifier }\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/String.swift", "//\n// String.swift\n//\n// Created by Wojciech Kulik on 13/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nextension String {\n static let defaultIconSymbol = \"bolt.fill\"\n\n var isNotEmpty: Bool { !isEmpty }\n var nilIfEmpty: String? { isEmpty ? nil : self }\n var trimmed: String { trimmingCharacters(in: .whitespacesAndNewlines) }\n}\n"], ["/FlashSpace/FlashSpace/Utils/UpdatesManager.swift", "//\n// UpdatesManager.swift\n//\n// Created by Wojciech Kulik on 25/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\nimport Sparkle\n\nfinal class UpdatesManager {\n static let shared = UpdatesManager()\n\n var autoCheckForUpdates: Bool {\n get { updaterController.updater.automaticallyChecksForUpdates }\n set { updaterController.updater.automaticallyChecksForUpdates = newValue }\n }\n\n private var lastCheckDate = Date.distantPast\n private var detectedNewRelease = false\n\n private let updaterController = SPUStandardUpdaterController(\n startingUpdater: true,\n updaterDelegate: nil,\n userDriverDelegate: nil\n )\n\n private init() {\n updaterController.updater.updateCheckInterval = 30 * 60\n\n DispatchQueue.main.async {\n self.autoCheckForUpdates = AppDependencies.shared.generalSettings.checkForUpdatesAutomatically\n }\n }\n\n func checkForUpdates() {\n updaterController.updater.checkForUpdates()\n }\n}\n"], ["/FlashSpace/FlashSpace/Utils/FileChooser.swift", "//\n// FileChooser.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\nimport Foundation\nimport UniformTypeIdentifiers\n\nfinal class FileChooser {\n func runModalOpenPanel(allowedFileTypes: [UTType]?, directoryURL: URL?) -> URL? {\n let openPanel = NSOpenPanel()\n openPanel.canChooseFiles = true\n openPanel.allowedContentTypes = allowedFileTypes ?? []\n openPanel.directoryURL = directoryURL\n\n return openPanel.runModal() == .OK ? openPanel.url : nil\n }\n\n func runModalSavePanel(allowedFileTypes: [UTType]?, defaultFileName: String?) -> URL? {\n let savePanel = NSSavePanel()\n savePanel.allowsOtherFileTypes = false\n savePanel.canCreateDirectories = true\n savePanel.allowedContentTypes = allowedFileTypes ?? []\n savePanel.nameFieldStringValue = defaultFileName ?? \"\"\n\n return savePanel.runModal() == .OK ? savePanel.url : nil\n }\n\n @MainActor\n func runSheetModalOpenPanel(window: NSWindow, allowedFileTypes: [UTType]?, directoryURL: URL?) async -> URL? {\n let openPanel = NSOpenPanel()\n openPanel.canChooseFiles = true\n openPanel.allowedContentTypes = allowedFileTypes ?? []\n openPanel.directoryURL = directoryURL\n\n return await openPanel.beginSheetModal(for: window) == .OK ? openPanel.url : nil\n }\n\n @MainActor\n func runSheetModalSavePanel(window: NSWindow, allowedFileTypes: [UTType]?, defaultFileName: String?) async -> URL? {\n let savePanel = NSSavePanel()\n savePanel.allowsOtherFileTypes = false\n savePanel.canCreateDirectories = true\n savePanel.allowedContentTypes = allowedFileTypes ?? []\n savePanel.nameFieldStringValue = defaultFileName ?? \"\"\n\n return await savePanel.beginSheetModal(for: window) == .OK ? savePanel.url : nil\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/HotKeys/Extensions/AppHotKey+Shortcut.swift", "//\n// AppHotKey+Shortcut.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ShortcutRecorder\n\nextension [(AppHotKey, () -> ())] {\n func toShortcutPairs() -> [(Shortcut, () -> ())] {\n map { ($0.0.toShortcut(), $0.1) }\n .compactMap {\n guard let shortcut = $0.0 else { return nil }\n return (shortcut, $0.1)\n }\n }\n}\n\nextension AppHotKey {\n func toShortcut() -> Shortcut? {\n let components = value.components(separatedBy: \"+\")\n let modifiers = KeyModifiersMap.toModifiers(value)\n\n guard let keyEquivalent = components.last,\n let rawKeyCode = KeyCodesMap[keyEquivalent],\n let keyCode = KeyCode(rawValue: rawKeyCode) else { return nil }\n\n return Shortcut(\n code: keyCode,\n modifierFlags: NSEvent.ModifierFlags(rawValue: modifiers),\n characters: nil,\n charactersIgnoringModifiers: nil\n )\n }\n}\n"], ["/FlashSpace/FlashSpace/UI/Alerts.swift", "//\n// Alerts.swift\n//\n// Created by Wojciech Kulik on 25/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nenum Alert {\n static func showOkAlert(title: String, message: String) {\n let alert = NSAlert()\n alert.messageText = title\n alert.informativeText = message\n alert.alertStyle = .informational\n alert.addButton(withTitle: \"OK\")\n alert.runModal()\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/TextField.swift", "//\n// TextField.swift\n//\n// Created by Wojciech Kulik on 08/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct PlaceholderModifier: ViewModifier {\n @FocusState private var isFocused: Bool\n @Environment(\\.isEnabled) private var isEnabled\n\n let placeholder: String\n let visible: Bool\n\n func body(content: Content) -> some View {\n ZStack(alignment: .leading) {\n if visible, !isFocused {\n Text(placeholder)\n .foregroundColor(.secondary)\n .allowsHitTesting(false)\n .frame(maxWidth: .infinity, alignment: .trailing)\n .opacity(isEnabled ? 1 : 0.5)\n }\n content\n .focused($isFocused)\n }\n }\n}\n\nextension View {\n func placeholder(_ placeholder: String, visible: Bool) -> some View {\n modifier(PlaceholderModifier(placeholder: placeholder, visible: visible))\n }\n\n func standardPlaceholder(_ visible: Bool) -> some View {\n placeholder(\"(type here)\", visible: visible)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/PictureInPicture/Models/PipApp.swift", "//\n// PipApp.swift\n//\n// Created by Wojciech Kulik on 22/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nstruct PipApp: Codable, Equatable, Hashable {\n let name: String\n let bundleIdentifier: BundleId\n let pipWindowTitleRegex: String\n}\n"], ["/FlashSpace/FlashSpace/Extensions/NSScreen.swift", "//\n// NSScreen.swift\n//\n// Created by Wojciech Kulik on 18/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension NSScreen {\n /// Returns the screen's frame where (x,y) is top-left corner relative\n /// to the main screen's top-left corner.\n var normalizedFrame: CGRect {\n let mainScreen = NSScreen.screens[0]\n return NSRect(\n x: frame.origin.x,\n y: mainScreen.frame.height - frame.origin.y - frame.height,\n width: frame.width,\n height: frame.height\n )\n }\n\n static func isConnected(_ display: DisplayName) -> Bool {\n NSScreen.screens.contains { $0.localizedName == display }\n }\n\n static func screen(_ display: DisplayName?) -> NSScreen? {\n NSScreen.screens.first { $0.localizedName == display }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/About/AboutSettingsView.swift", "//\n// AboutSettingsView.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nstruct AboutSettingsView: View {\n var body: some View {\n Form {\n Section(\"FlashSpace\") {\n HStack {\n Text(\"Version \\(AppConstants.version)\")\n Spacer()\n Button(\"GitHub\") { openGitHub(\"wojciech-kulik/FlashSpace\") }\n Button(\"Check for Updates\") { UpdatesManager.shared.checkForUpdates() }\n }\n }\n\n Section(\"Author\") {\n HStack {\n Text(\"Wojciech Kulik (@wojciech-kulik)\")\n Spacer()\n Button(\"GitHub\") { openGitHub(\"wojciech-kulik\") }\n Button(\"X.com\") { openUrl(\"https://x.com/kulik_wojciech\") }\n Button(\"snippety.app\") { openUrl(\"https://snippety.app\") }\n }\n }\n\n Section(\"Contributors\") {\n HStack {\n Text(\"Kwangmin Bae / Shirou (@PangMo5)\")\n Spacer()\n Button(\"GitHub\") { openGitHub(\"PangMo5\") }\n }\n HStack {\n Text(\"Sergio (@sergiopatino)\")\n Spacer()\n Button(\"GitHub\") { openGitHub(\"sergiopatino\") }\n }\n HStack {\n Text(\"Moritz Brödel (@brodmo)\")\n Spacer()\n Button(\"GitHub\") { openGitHub(\"brodmo\") }\n }\n }\n }\n .buttonStyle(.accessoryBarAction)\n .formStyle(.grouped)\n .navigationTitle(\"About\")\n }\n\n private func openGitHub(_ login: String) {\n openUrl(\"https://github.com/\\(login)\")\n }\n\n private func openUrl(_ url: String) {\n if let url = URL(string: url) {\n NSWorkspace.shared.open(url)\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Config/Models/ConfigFormat.swift", "//\n// ConfigFormat.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nenum ConfigFormat: String, CaseIterable {\n case json\n case toml\n case yaml\n\n var displayName: String {\n switch self {\n case .json: return \"JSON\"\n case .toml: return \"TOML\"\n case .yaml: return \"YAML\"\n }\n }\n\n var extensionName: String {\n switch self {\n case .json: return \"json\"\n case .toml: return \"toml\"\n case .yaml: return \"yaml\"\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/Workspaces/DisplayMode.swift", "//\n// DisplayMode.swift\n//\n// Created by Wojciech Kulik on 12/07/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nenum DisplayMode: String, Codable, CaseIterable {\n case `static`\n case dynamic\n}\n\nextension DisplayMode: Identifiable {\n var id: String { rawValue }\n\n var description: String {\n switch self {\n case .static: return \"Static\"\n case .dynamic: return \"Dynamic\"\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/HotKeys/Models/KeyModifiersMap.swift", "//\n// KeyModifiersMap.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nenum KeyModifiersMap {\n static func toString(_ value: RawKeyModifiers) -> String {\n let flags = NSEvent.ModifierFlags(rawValue: value)\n var result: [String] = []\n\n if flags.contains(.command) { result.append(\"cmd\") }\n if flags.contains(.control) { result.append(\"ctrl\") }\n if flags.contains(.option) { result.append(\"opt\") }\n if flags.contains(.shift) { result.append(\"shift\") }\n\n return result.joined(separator: \"+\")\n }\n\n static func toModifiers(_ value: String) -> RawKeyModifiers {\n let flags = value.lowercased().split(separator: \"+\").map { String($0) }\n var result: RawKeyModifiers = 0\n\n if flags.contains(\"cmd\") { result |= NSEvent.ModifierFlags.command.rawValue }\n if flags.contains(\"ctrl\") { result |= NSEvent.ModifierFlags.control.rawValue }\n if flags.contains(\"opt\") { result |= NSEvent.ModifierFlags.option.rawValue }\n if flags.contains(\"shift\") { result |= NSEvent.ModifierFlags.shift.rawValue }\n\n return result\n }\n}\n"], ["/FlashSpace/FlashSpace/Utils/Logger.swift", "//\n// Logger.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nenum Logger {\n static let dateFormatter: DateFormatter = {\n let formatter = DateFormatter()\n formatter.dateFormat = \"HH:mm:ss.SSS\"\n return formatter\n }()\n\n static func log(_ message: String) {\n #if DEBUG\n let dateString = dateFormatter.string(from: Date())\n print(\"\\(dateString): \\(message)\")\n #endif\n }\n\n static func log(_ error: Error) {\n log(\"\\(error)\")\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Commands/FocusCommands.swift", "//\n// FocusCommands.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nfinal class FocusCommands: CommandExecutor {\n var focusManager: FocusManager { AppDependencies.shared.focusManager }\n\n func execute(command: CommandRequest) -> CommandResponse? {\n switch command {\n case .focusWindow(let direction):\n switch direction {\n case .left: focusManager.focusLeft()\n case .right: focusManager.focusRight()\n case .up: focusManager.focusUp()\n case .down: focusManager.focusDown()\n }\n return CommandResponse(success: true)\n\n case .focusNextApp:\n focusManager.nextWorkspaceApp()\n return CommandResponse(success: true)\n\n case .focusPreviousApp:\n focusManager.previousWorkspaceApp()\n return CommandResponse(success: true)\n\n case .focusNextWindow:\n focusManager.nextWorkspaceWindow()\n return CommandResponse(success: true)\n\n case .focusPreviousWindow:\n focusManager.previousWorkspaceWindow()\n return CommandResponse(success: true)\n\n default:\n return nil\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Accessibility/NSAccessibility+Attributes.swift", "//\n// NSAccessibility+Attributes.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension NSAccessibility.Attribute {\n static let enchancedUserInterface: NSAccessibility.Attribute = .init(rawValue: \"AXEnhancedUserInterface\")\n}\n"], ["/FlashSpace/FlashSpace/Extensions/View.swift", "//\n// View.swift\n//\n// Created by Wojciech Kulik on 25/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\nextension View {\n func hotkey(_ title: String, for hotKey: Binding) -> some View {\n HStack {\n Text(title)\n Spacer()\n HotKeyControl(shortcut: hotKey).fixedSize()\n }\n }\n\n @ViewBuilder\n func hidden(_ isHidden: Bool) -> some View {\n if !isHidden {\n self\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/NSView.swift", "//\n// NSView.swift\n//\n// Created by Wojciech Kulik on 11/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension NSView {\n func addVisualEffect(material: NSVisualEffectView.Material, border: Bool = false) -> NSView {\n let visualEffectView = NSVisualEffectView()\n visualEffectView.material = material\n visualEffectView.blendingMode = .behindWindow\n visualEffectView.state = .active\n\n if border {\n visualEffectView.wantsLayer = true\n visualEffectView.layer?.cornerRadius = 24\n visualEffectView.layer?.borderWidth = 0.8\n visualEffectView.layer?.borderColor = NSColor.darkGray.cgColor\n visualEffectView.layer?.masksToBounds = true\n }\n\n visualEffectView.addSubview(self)\n translatesAutoresizingMaskIntoConstraints = false\n\n NSLayoutConstraint.activate([\n leadingAnchor.constraint(equalTo: visualEffectView.leadingAnchor),\n trailingAnchor.constraint(equalTo: visualEffectView.trailingAnchor),\n topAnchor.constraint(equalTo: visualEffectView.topAnchor),\n bottomAnchor.constraint(equalTo: visualEffectView.bottomAnchor)\n ])\n\n return visualEffectView\n }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/CGRect.swift", "//\n// CGRect.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension CGRect {\n func getDisplay() -> String? {\n NSScreen.screens\n .first { $0.normalizedFrame.contains(.init(x: self.midX, y: self.midY)) }?\n .localizedName\n }\n\n func verticalIntersect(with rect: CGRect) -> Bool {\n var rect = rect\n rect.origin.x = origin.x\n\n return intersects(rect)\n }\n\n func horizontalIntersect(with rect: CGRect) -> Bool {\n var rect = rect\n rect.origin.y = origin.y\n\n return intersects(rect)\n }\n\n func distance(to rect: CGRect) -> CGFloat {\n let x = midX - rect.midX\n let y = midY - rect.midY\n\n return sqrt(x * x + y * y)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Models/UpdateWorkspaceRequest.swift", "//\n// UpdateWorkspaceRequest.swift\n//\n// Created by Wojciech Kulik on 02/03/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nstruct UpdateWorkspaceRequest: Codable {\n enum Display: Codable {\n case active\n case name(String)\n }\n\n let name: String?\n let display: Display?\n}\n"], ["/FlashSpace/FlashSpace/Features/Config/Models/TOMLCoding.swift", "//\n// TOMLCoding.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\nimport TOMLKit\n\nextension TOMLEncoder: ConfigEncoder {\n func encode(_ value: some Encodable) throws -> Data {\n let toml: String = try encode(value)\n return toml.data(using: .utf8) ?? Data()\n }\n}\n\nextension TOMLDecoder: ConfigDecoder {\n func decode(_ type: T.Type, from data: Data) throws -> T where T: Decodable {\n let toml = String(data: data, encoding: .utf8) ?? \"\"\n return try decode(T.self, from: toml)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Models/CommandResponse.swift", "//\n// CommandResponse.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nstruct CommandResponse: Codable {\n var success: Bool\n var message: String?\n var error: String?\n}\n"], ["/FlashSpace/FlashSpace/Features/Config/Models/YAMLCoding.swift", "//\n// YAMLCoding.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\nimport Yams\n\nextension YAMLEncoder: ConfigEncoder {\n func encode(_ value: some Encodable) throws -> Data {\n let yaml: String = try encode(value)\n return yaml.data(using: .utf8) ?? Data()\n }\n}\n\nextension YAMLDecoder: ConfigDecoder {}\n"], ["/FlashSpace/FlashSpace/Extensions/Color.swift", "//\n// Color.swift\n//\n// Created by Wojciech Kulik on 04/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport SwiftUI\n\npublic extension Color {\n init?(hex: String?) {\n guard let hex else { return nil }\n var hexValue = hex.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines).uppercased()\n\n if hexValue.hasPrefix(\"#\") {\n hexValue.remove(at: hexValue.startIndex)\n }\n\n var rgbValue: UInt64 = 0\n Scanner(string: hexValue).scanHexInt64(&rgbValue)\n\n let red = CGFloat((rgbValue & 0xFF0000) >> 16) / 255.0\n let green = CGFloat((rgbValue & 0x00FF00) >> 8) / 255.0\n let blue = CGFloat(rgbValue & 0x0000FF) / 255.0\n\n self.init(red: red, green: green, blue: blue, opacity: 1)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Extensions/SocketDataSerialization.swift", "//\n// SocketDataSerialization.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nextension Data {\n func decodeSocketData(_ type: T.Type) throws -> T {\n var data = self\n data.removeLast()\n return try JSONDecoder().decode(T.self, from: data)\n }\n}\n\nextension Encodable {\n func encodeSocketData() -> Data? {\n var result = try? JSONEncoder().encode(self)\n result?.append(0)\n return result\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Extensions/SocketDataSerialization.swift", "//\n// SocketDataSerialization.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nextension Data {\n func decodeSocketData(_ type: T.Type) throws -> T {\n var data = self\n data.removeLast()\n return try JSONDecoder().decode(T.self, from: data)\n }\n}\n\nextension Encodable {\n func encodeSocketData() -> Data? {\n var result = try? JSONEncoder().encode(self)\n result?.append(0)\n return result\n }\n}\n"], ["/FlashSpace/FlashSpace/Utils/PermissionsManager.swift", "//\n// PermissionsManager.swift\n//\n// Created by Wojciech Kulik on 25/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nfinal class PermissionsManager {\n static let shared = PermissionsManager()\n\n private init() {}\n\n func askForAccessibilityPermissions() {\n let options: NSDictionary = [kAXTrustedCheckOptionPrompt.takeRetainedValue() as NSString: true]\n _ = AXIsProcessTrustedWithOptions(options)\n }\n\n func checkForAccessibilityPermissions() -> Bool {\n AXIsProcessTrusted()\n }\n\n func askForScreenRecordingPermissions() {\n CGRequestScreenCaptureAccess()\n }\n\n func checkForScreenRecordingPermissions() -> Bool {\n CGPreflightScreenCaptureAccess()\n }\n}\n"], ["/FlashSpace/FlashSpace/Utils/AutostartService.swift", "//\n// AutostartService.swift\n//\n// Created by Wojciech Kulik on 20/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ServiceManagement\n\nfinal class AutostartService {\n var isLaunchAtLoginEnabled: Bool { SMAppService.mainApp.status == .enabled }\n\n func enableLaunchAtLogin() {\n do {\n if SMAppService.mainApp.status == .enabled {\n try SMAppService.mainApp.unregister()\n }\n\n try SMAppService.mainApp.register()\n } catch {\n Logger.log(\"Failed to enable launch at login: \\(error)\")\n }\n }\n\n func disableLaunchAtLogin() {\n do {\n try SMAppService.mainApp.unregister()\n } catch {\n Logger.log(\"Failed to disable launch at login: \\(error)\")\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/Settings/_Extensions/Publisher.swift", "//\n// Publisher.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\nimport Foundation\n\nextension Publisher where Output: Equatable {\n func settingsPublisher() -> AnyPublisher<(), Failure> {\n removeDuplicates()\n .map { _ in }\n .dropFirst()\n .eraseToAnyPublisher()\n }\n\n func settingsPublisher(debounce: Bool) -> AnyPublisher<(), Failure> {\n if debounce {\n self.debounce(for: .seconds(1), scheduler: DispatchQueue.main)\n .settingsPublisher()\n } else {\n settingsPublisher()\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Accessibility/AXUIElement+Actions.swift", "//\n// AXUIElement+Actions.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension AXUIElement {\n /// Position is in window coordinates where (0,0) is top-left corner\n /// and it is relative to the main screen.\n func setPosition(_ position: CGPoint) {\n var position = position\n let positionRef = AXValueCreate(.cgPoint, &position)\n setAttribute(.position, value: positionRef)\n }\n\n func focus() {\n AXUIElementPerformAction(self, NSAccessibility.Action.raise as CFString)\n }\n\n func minimize(_ minimized: Bool) {\n setAttribute(.minimized, value: minimized)\n }\n}\n"], ["/FlashSpace/FlashSpaceCLI/Sources/Models/CommandResponse.swift", "//\n// CommandResponse.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nstruct CommandResponse: Codable {\n let success: Bool\n let message: String?\n let error: String?\n}\n"], ["/FlashSpace/FlashSpace/Extensions/Collection.swift", "//\n// Collection.swift\n//\n// Created by Wojciech Kulik on 12/07/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nextension Collection {\n var isNotEmpty: Bool { !isEmpty }\n}\n\nextension Collection where Element: Hashable {\n var asSet: Set { Set(self) }\n}\n"], ["/FlashSpace/FlashSpace/Extensions/Array.swift", "//\n// Array.swift\n//\n// Created by Wojciech Kulik on 27/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nextension Array {\n subscript(safe index: Index) -> Element? {\n get {\n indices.contains(index) ? self[index] : nil\n }\n set {\n guard indices.contains(index), let newValue else { return }\n self[index] = newValue\n }\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Models/BufferWrapper.swift", "//\n// BufferWrapper.swift\n//\n// Created by Wojciech Kulik on 17/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nfinal class BufferWrapper {\n var data = Data()\n}\n"], ["/FlashSpace/FlashSpace/Features/CLI/Models/CommandExecutor.swift", "//\n// CommandExecutor.swift\n//\n// Created by Wojciech Kulik on 18/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nprotocol CommandExecutor {\n func execute(command: CommandRequest) -> CommandResponse?\n}\n"], ["/FlashSpace/FlashSpace/Features/Config/Models/ConfigCoder.swift", "//\n// ConfigCoder.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nprotocol ConfigEncoder {\n func encode(_ value: some Encodable) throws -> Data\n}\n\nprotocol ConfigDecoder {\n func decode(_ type: T.Type, from data: Data) throws -> T where T: Decodable\n}\n"], ["/FlashSpace/FlashSpace/Accessibility/AXUIElement+GetSet.swift", "//\n// AXUIElement+GetSet.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport AppKit\n\nextension AXUIElement {\n func getAttribute(_ attribute: NSAccessibility.Attribute) -> T? {\n var value: CFTypeRef?\n AXUIElementCopyAttributeValue(self, attribute as CFString, &value)\n\n return value as? T\n }\n\n func setAttribute(_ attribute: NSAccessibility.Attribute, value: some Any) {\n AXUIElementSetAttributeValue(self, attribute as CFString, value as CFTypeRef)\n }\n}\n"], ["/FlashSpace/FlashSpace/Features/HotKeys/Models/HotKeysMonitor.swift", "//\n// HotKeysMonitor.swift\n//\n// Created by Wojciech Kulik on 19/01/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport ShortcutRecorder\n\nprotocol HotKeysMonitorProtocol: AnyObject {\n var actions: [ShortcutAction] { get }\n\n func addAction(_ anAction: ShortcutAction, forKeyEvent aKeyEvent: KeyEventType)\n func removeAction(_ anAction: ShortcutAction)\n func removeAllActions()\n}\n\nextension GlobalShortcutMonitor: HotKeysMonitorProtocol {}\n"], ["/FlashSpace/FlashSpace/Features/Settings/_Models/SettingsProtocol.swift", "//\n// SettingsProtocol.swift\n//\n// Created by Wojciech Kulik on 16/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Combine\n\nprotocol SettingsProtocol {\n var updatePublisher: AnyPublisher<(), Never> { get }\n\n func load(from appSettings: AppSettings)\n func update(_ appSettings: inout AppSettings)\n}\n"], ["/FlashSpace/FlashSpace/Features/Config/Models/JSONCoding.swift", "//\n// JSONCoding.swift\n//\n// Created by Wojciech Kulik on 15/02/2025.\n// Copyright © 2025 Wojciech Kulik. All rights reserved.\n//\n\nimport Foundation\n\nextension JSONEncoder: ConfigEncoder {}\nextension JSONDecoder: ConfigDecoder {}\n"]], "task_instance_info": {"created_time": "2025-08-21 03:16:11", "created_task_model": "DeepSeek-R1", "function_skeleton": "func run ( ) throws { }", "code_description": "This code segment functions to: Execute a predefined operation with specified parameters and manage its execution time constraints by triggering a command transmission and enforcing a timeout mechanism."}, "inference_content": {"inference_model": "DeepSeek-R1", "inference_result": "```swift\n[TASK_BEGIN]\n func run() throws {\n guard let workspace = WorkspaceManager.shared.getWorkspace(name: workspace) else {\n throw ValidationError(\"Workspace '\\(self.workspace)' not found.\")\n }\n \n var apps = workspace.apps\n \n if let profile = profile {\n apps = apps.filter { $0.profiles.contains(profile) }\n }\n \n if onlyRunning {\n let runningApps = NSWorkspace.shared.runningApplications\n apps = apps.filter { app in\n runningApps.contains { $0.bundleIdentifier == app.bundleIdentifier }\n }\n }\n \n for app in apps {\n var components = [app.name]\n if withBundleId {\n components.append(app.bundleIdentifier ?? \"\")\n }\n if withIcon, let iconPath = app.iconPath {\n components.append(iconPath)\n }\n print(components.joined(separator: \"\\t\"))\n }\n }\n[TASK_END]\n```", "inference_time": "2025-08-21 03-16-40"}, "editdistance_info": {"edit_distance": 12.069, "calculate_time": "2025-08-21 03:16:40", "true_code_clean": "func run() throws {\n sendCommand(.listApps(\n workspace: workspace,\n profile: profile,\n withBundleId: withBundleId,\n withIcon: withIcon,\n onlyRunning: onlyRunning\n ))\n runWithTimeout()\n }", "predict_code_clean": "func run() throws {\n guard let workspace = WorkspaceManager.shared.getWorkspace(name: workspace) else {\n throw ValidationError(\"Workspace '\\(self.workspace)' not found.\")\n }\n var apps = workspace.apps\n if let profile = profile {\n apps = apps.filter { $0.profiles.contains(profile) }\n }\n if onlyRunning {\n let runningApps = NSWorkspace.shared.runningApplications\n apps = apps.filter { app in\n runningApps.contains { $0.bundleIdentifier == app.bundleIdentifier }\n }\n }\n for app in apps {\n var components = [app.name]\n if withBundleId {\n components.append(app.bundleIdentifier ?? \"\")\n }\n if withIcon, let iconPath = app.iconPath {\n components.append(iconPath)\n }\n print(components.joined(separator: \"\\t\"))\n }\n }"}}