(function () {
  'use strict';

  // Generated by @auroraview/sdk

  // src/inject/plugins/utils.ts
  async function invokePlugin(plugin, command, args) {
    if (!window.auroraview || !window.auroraview.invoke) {
      throw new Error("AuroraView bridge not available");
    }
    const result = await window.auroraview.invoke(
      `plugin:${plugin}|${command}`,
      args || {}
    );
    if (result && result.success === false) {
      const error = new Error(result.error || "Unknown error");
      error.code = result.code || "UNKNOWN";
      throw error;
    }
    return result;
  }
  function attachPlugin(name, api) {
    if (window.auroraview) {
      window.auroraview[name] = api;
      console.log(`[AuroraView] ${name.charAt(0).toUpperCase() + name.slice(1)} plugin initialized`);
    }
  }
  function initPlugin(name, api) {
    if (window.auroraview) {
      attachPlugin(name, api);
    } else {
      const observer = setInterval(function() {
        if (window.auroraview) {
          clearInterval(observer);
          attachPlugin(name, api);
        }
      }, 10);
      setTimeout(function() {
        clearInterval(observer);
      }, 5e3);
    }
  }

  // src/inject/plugins/shell.ts
  (function() {
    const shell = {
      /**
       * Open a URL in the default browser
       */
      async open(url) {
        return invokePlugin("shell", "open", { path: url });
      },
      /**
       * Open a file/folder with the default application
       */
      async openPath(path) {
        return invokePlugin("shell", "open_path", { path });
      },
      /**
       * Show a file in its parent folder (reveal in file manager)
       */
      async showInFolder(path) {
        return invokePlugin("shell", "show_in_folder", { path });
      },
      /**
       * Execute a command and wait for result
       */
      async execute(command, args, options) {
        return invokePlugin("shell", "execute", {
          command,
          args: args || [],
          cwd: options?.cwd,
          env: options?.env
        });
      },
      /**
       * Spawn a detached process (doesn't wait for completion)
       */
      async spawn(command, args, options) {
        return invokePlugin("shell", "spawn", {
          command,
          args: args || [],
          cwd: options?.cwd,
          env: options?.env
        });
      },
      /**
       * Find an executable in PATH
       */
      async which(command) {
        const result = await invokePlugin("shell", "which", { command });
        return result.path || null;
      },
      /**
       * Get environment variable
       */
      async getEnv(name) {
        const result = await invokePlugin("shell", "get_env", { name });
        return result.value || null;
      },
      /**
       * Get all environment variables
       */
      async getEnvAll() {
        const result = await invokePlugin("shell", "get_env_all", {});
        return result.env || {};
      }
    };
    initPlugin("shell", shell);
  })();

})();
