/**
 * Wireguard interface helpers
 *
 * @since 1.0.0
 */
import * as ParseResult from "@effect/schema/ParseResult";
import * as Schema from "@effect/schema/Schema";
import * as Effect from "effect/Effect";
import * as Function from "effect/Function";
import * as internal from "./internal/wireguardInterface.js";
/**
 * A wireguard interface name.
 *
 * @since 1.0.0
 * @category Datatypes
 */
export class WireguardInterface extends Schema.Class("WireguardInterface")({
  /** Ensures the interface name matches the platform's interface name regex. */
  Name: Schema.transformOrFail(Schema.string, Schema.string, (s, _options, ast) => Function.pipe(internal.InterfaceRegExpForPlatform, Effect.mapError(error => new ParseResult.Type(ast, s, error.message)), Effect.flatMap(x => x.test(s) ? Effect.succeed(s) : Effect.fail(new ParseResult.Type(ast, s, `Expected interface name to match ${x}`)))), s => Effect.succeed(s))
}) {
  /**
   * @since 1.0.0
   * @category Constructors
   */
  static getNextAvailableInterface = internal.getNextAvailableInterface;
  /**
   * Starts a wireguard tunnel that will be gracefully shutdown and stop
   * serving traffic once the scope is closed. If no how options is specified,
   * then the interface will be brought up using the
   * bundled-wireguard-go+userspace-api method.
   *
   * @since 1.0.0
   * @category Wireguard
   * @param config - The wireguard configuration to use in INI format.
   * @param options - Options to control how the wireguard configuration is
   *   applied.
   */
  upScoped = (config, options) => internal.upScoped(config, options)(this);
  /**
   * Starts a wireguard tunnel that will continue to run and serve traffic
   * even after the nodejs process exits. If no how options is specified, then
   * the interface will be brought up using the
   * bundled-wireguard-go+userspace-api method.
   *
   * @since 1.0.0
   * @category Wireguard
   * @param config - The wireguard configuration to use in INI format.
   * @param options - Options to control how the wireguard configuration is
   *   applied.
   */
  up = (config, options) => internal.up(config, options)(this);
  /**
   * Stops a previously started wireguard tunnel.
   *
   * @since 1.0.0
   * @category Wireguard
   */
  down = options => internal.down(this, options);
}
export default WireguardInterface;
//# sourceMappingURL=WireguardInterface.js.map