"use client";
"use client";
var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });

// src/generated/cfg_accounts/_utils/hooks/accounts__auth.ts
import { useSWRConfig } from "swr";

// src/generated/cfg_accounts/_utils/fetchers/accounts__auth.ts
import { consola as consola4 } from "consola";

// src/generated/cfg_accounts/_utils/schemas/TokenRefresh.schema.ts
import { z } from "zod";
var TokenRefreshSchema = z.object({
  access: z.string(),
  refresh: z.string()
});

// src/generated/cfg_accounts/accounts__auth/client.ts
var Auth = class {
  static {
    __name(this, "Auth");
  }
  constructor(client) {
    this.client = client;
  }
  /**
   * Refresh JWT token.
   */
  async accountsTokenRefreshCreate(data) {
    const response = await this.client.request("POST", "/cfg/accounts/token/refresh/", { body: data });
    return response;
  }
};

// src/generated/cfg_accounts/accounts__oauth/client.ts
var Oauth = class {
  static {
    __name(this, "Oauth");
  }
  constructor(client) {
    this.client = client;
  }
  /**
   * List OAuth connections
   * 
   * Get all OAuth connections for the current user.
   */
  async accountsOauthConnectionsList() {
    const response = await this.client.request("GET", "/cfg/accounts/oauth/connections/");
    return response;
  }
  /**
   * Disconnect OAuth provider
   * 
   * Remove OAuth connection for the specified provider.
   */
  async accountsOauthDisconnectCreate(data) {
    const response = await this.client.request("POST", "/cfg/accounts/oauth/disconnect/", { body: data });
    return response;
  }
  /**
   * Start GitHub OAuth
   * 
   * Generate GitHub OAuth authorization URL. Redirect user to this URL to
   * start authentication.
   */
  async accountsOauthGithubAuthorizeCreate(data) {
    const response = await this.client.request("POST", "/cfg/accounts/oauth/github/authorize/", { body: data });
    return response;
  }
  /**
   * Complete GitHub OAuth
   * 
   * Exchange authorization code for JWT tokens. Call this after GitHub
   * redirects back with code.
   */
  async accountsOauthGithubCallbackCreate(data) {
    const response = await this.client.request("POST", "/cfg/accounts/oauth/github/callback/", { body: data });
    return response;
  }
  /**
   * List OAuth providers
   * 
   * Get list of available OAuth providers for authentication.
   */
  async accountsOauthProvidersRetrieve() {
    const response = await this.client.request("GET", "/cfg/accounts/oauth/providers/");
    return response;
  }
};

// src/generated/cfg_accounts/accounts__user_profile/client.ts
var UserProfile = class {
  static {
    __name(this, "UserProfile");
  }
  constructor(client) {
    this.client = client;
  }
  /**
   * Get current user profile
   * 
   * Retrieve the current authenticated user's profile information.
   */
  async accountsProfileRetrieve() {
    const response = await this.client.request("GET", "/cfg/accounts/profile/");
    return response;
  }
  /**
   * Upload user avatar
   * 
   * Upload avatar image for the current authenticated user. Accepts
   * multipart/form-data with 'avatar' field.
   */
  async accountsProfileAvatarCreate(data) {
    const formData = new FormData();
    formData.append("avatar", data.avatar);
    const response = await this.client.request("POST", "/cfg/accounts/profile/avatar/", { formData });
    return response;
  }
  /**
   * Delete user account
   * 
   * Permanently delete the current user's account. This operation: -
   * Deactivates the account (user cannot log in) - Anonymizes personal data
   * (GDPR compliance) - Frees up the email address for re-registration -
   * Preserves audit trail The account can be restored by an administrator if
   * needed.
   */
  async accountsProfileDeleteCreate() {
    const response = await this.client.request("POST", "/cfg/accounts/profile/delete/");
    return response;
  }
  /**
   * Partial update user profile
   * 
   * Partially update the current authenticated user's profile information.
   * Supports avatar upload.
   */
  async accountsProfilePartialUpdate(data) {
    const response = await this.client.request("PUT", "/cfg/accounts/profile/partial/", { body: data });
    return response;
  }
  /**
   * Partial update user profile
   * 
   * Partially update the current authenticated user's profile information.
   * Supports avatar upload.
   */
  async accountsProfilePartialPartialUpdate(data) {
    const response = await this.client.request("PATCH", "/cfg/accounts/profile/partial/", { body: data });
    return response;
  }
  /**
   * Update user profile
   * 
   * Update the current authenticated user's profile information.
   */
  async accountsProfileUpdateUpdate(data) {
    const response = await this.client.request("PUT", "/cfg/accounts/profile/update/", { body: data });
    return response;
  }
  /**
   * Update user profile
   * 
   * Update the current authenticated user's profile information.
   */
  async accountsProfileUpdatePartialUpdate(data) {
    const response = await this.client.request("PATCH", "/cfg/accounts/profile/update/", { body: data });
    return response;
  }
};

// src/generated/cfg_accounts/accounts/client.ts
var Accounts = class {
  static {
    __name(this, "Accounts");
  }
  constructor(client) {
    this.client = client;
  }
  /**
   * Request OTP code to email or phone.
   */
  async otpRequestCreate(data) {
    const response = await this.client.request("POST", "/cfg/accounts/otp/request/", { body: data });
    return response;
  }
  /**
   * Verify OTP code and return JWT tokens or 2FA session. If user has 2FA
   * enabled: - Returns requires_2fa=True with session_id - Client must
   * complete 2FA verification at /cfg/totp/verify/ If user has no 2FA: -
   * Returns JWT tokens and user data directly
   */
  async otpVerifyCreate(data) {
    const response = await this.client.request("POST", "/cfg/accounts/otp/verify/", { body: data });
    return response;
  }
};

// src/generated/cfg_accounts/http.ts
var FetchAdapter = class {
  static {
    __name(this, "FetchAdapter");
  }
  async request(request) {
    const { method, url, headers, body, params, formData, binaryBody } = request;
    let finalUrl = url;
    if (params) {
      const searchParams = new URLSearchParams();
      Object.entries(params).forEach(([key, value]) => {
        if (value !== null && value !== void 0) {
          searchParams.append(key, String(value));
        }
      });
      const queryString = searchParams.toString();
      if (queryString) {
        finalUrl = url.includes("?") ? `${url}&${queryString}` : `${url}?${queryString}`;
      }
    }
    const finalHeaders = { ...headers };
    let requestBody;
    if (formData) {
      requestBody = formData;
    } else if (binaryBody) {
      finalHeaders["Content-Type"] = "application/octet-stream";
      requestBody = binaryBody;
    } else if (body) {
      finalHeaders["Content-Type"] = "application/json";
      requestBody = JSON.stringify(body);
    }
    const response = await fetch(finalUrl, {
      method,
      headers: finalHeaders,
      body: requestBody,
      credentials: "include"
      // Include Django session cookies
    });
    let data = null;
    const contentType = response.headers.get("content-type");
    if (response.status !== 204 && contentType?.includes("application/json")) {
      data = await response.json();
    } else if (response.status !== 204) {
      data = await response.text();
    }
    const responseHeaders = {};
    response.headers.forEach((value, key) => {
      responseHeaders[key] = value;
    });
    return {
      data,
      status: response.status,
      statusText: response.statusText,
      headers: responseHeaders
    };
  }
};

// src/generated/cfg_accounts/errors.ts
var APIError = class extends Error {
  constructor(statusCode, statusText, response, url, message) {
    super(message || `HTTP ${statusCode}: ${statusText}`);
    this.statusCode = statusCode;
    this.statusText = statusText;
    this.response = response;
    this.url = url;
    this.name = "APIError";
  }
  static {
    __name(this, "APIError");
  }
  /**
   * Get error details from response.
   * DRF typically returns: { "detail": "Error message" } or { "field": ["error1", "error2"] }
   */
  get details() {
    if (typeof this.response === "object" && this.response !== null) {
      return this.response;
    }
    return null;
  }
  /**
   * Get field-specific validation errors from DRF.
   * Returns: { "field_name": ["error1", "error2"], ... }
   */
  get fieldErrors() {
    const details = this.details;
    if (!details) return null;
    const fieldErrors = {};
    for (const [key, value] of Object.entries(details)) {
      if (Array.isArray(value)) {
        fieldErrors[key] = value;
      }
    }
    return Object.keys(fieldErrors).length > 0 ? fieldErrors : null;
  }
  /**
   * Get single error message from DRF.
   * Checks for "detail", "message", or first field error.
   */
  get errorMessage() {
    const details = this.details;
    if (!details) return this.message;
    if (details.detail) {
      return Array.isArray(details.detail) ? details.detail.join(", ") : String(details.detail);
    }
    if (details.message) {
      return String(details.message);
    }
    const fieldErrors = this.fieldErrors;
    if (fieldErrors) {
      const firstField = Object.keys(fieldErrors)[0];
      if (firstField) {
        return `${firstField}: ${fieldErrors[firstField]?.join(", ")}`;
      }
    }
    return this.message;
  }
  // Helper methods for common HTTP status codes
  get isValidationError() {
    return this.statusCode === 400;
  }
  get isAuthError() {
    return this.statusCode === 401;
  }
  get isPermissionError() {
    return this.statusCode === 403;
  }
  get isNotFoundError() {
    return this.statusCode === 404;
  }
  get isServerError() {
    return this.statusCode >= 500 && this.statusCode < 600;
  }
};
var NetworkError = class extends Error {
  constructor(message, url, originalError) {
    super(message);
    this.url = url;
    this.originalError = originalError;
    this.name = "NetworkError";
  }
  static {
    __name(this, "NetworkError");
  }
};

// src/generated/cfg_accounts/logger.ts
import { createConsola } from "consola";
var DEFAULT_CONFIG = {
  enabled: process.env.NODE_ENV !== "production",
  logRequests: true,
  logResponses: true,
  logErrors: true,
  logBodies: true,
  logHeaders: false
};
var SENSITIVE_HEADERS = [
  "authorization",
  "cookie",
  "set-cookie",
  "x-api-key",
  "x-csrf-token"
];
var APILogger = class {
  static {
    __name(this, "APILogger");
  }
  constructor(config = {}) {
    this.config = { ...DEFAULT_CONFIG, ...config };
    this.consola = config.consola || createConsola({
      level: this.config.enabled ? 4 : 0
    });
  }
  /**
   * Enable logging
   */
  enable() {
    this.config.enabled = true;
  }
  /**
   * Disable logging
   */
  disable() {
    this.config.enabled = false;
  }
  /**
   * Update configuration
   */
  setConfig(config) {
    this.config = { ...this.config, ...config };
  }
  /**
   * Filter sensitive headers
   */
  filterHeaders(headers) {
    if (!headers) return {};
    const filtered = {};
    Object.keys(headers).forEach((key) => {
      const lowerKey = key.toLowerCase();
      if (SENSITIVE_HEADERS.includes(lowerKey)) {
        filtered[key] = "***";
      } else {
        filtered[key] = headers[key] || "";
      }
    });
    return filtered;
  }
  /**
   * Log request
   */
  logRequest(request) {
    if (!this.config.enabled || !this.config.logRequests) return;
    const { method, url, headers, body } = request;
    this.consola.start(`${method} ${url}`);
    if (this.config.logHeaders && headers) {
      this.consola.debug("Headers:", this.filterHeaders(headers));
    }
    if (this.config.logBodies && body) {
      this.consola.debug("Body:", body);
    }
  }
  /**
   * Log response
   */
  logResponse(request, response) {
    if (!this.config.enabled || !this.config.logResponses) return;
    const { method, url } = request;
    const { status, statusText, data, duration } = response;
    const statusColor = status >= 500 ? "red" : status >= 400 ? "yellow" : status >= 300 ? "cyan" : "green";
    this.consola.success(
      `${method} ${url} ${status} ${statusText} (${duration}ms)`
    );
    if (this.config.logBodies && data) {
      this.consola.debug("Response:", data);
    }
  }
  /**
   * Log error
   */
  logError(request, error) {
    if (!this.config.enabled || !this.config.logErrors) return;
    const { method, url } = request;
    const { message, statusCode, fieldErrors, duration } = error;
    this.consola.error(
      `${method} ${url} ${statusCode || "Network"} Error (${duration}ms)`
    );
    this.consola.error("Message:", message);
    if (fieldErrors && Object.keys(fieldErrors).length > 0) {
      this.consola.error("Field Errors:");
      Object.entries(fieldErrors).forEach(([field, errors]) => {
        errors.forEach((err) => {
          this.consola.error(`  \u2022 ${field}: ${err}`);
        });
      });
    }
  }
  /**
   * Log general info
   */
  info(message, ...args) {
    if (!this.config.enabled) return;
    this.consola.info(message, ...args);
  }
  /**
   * Log warning
   */
  warn(message, ...args) {
    if (!this.config.enabled) return;
    this.consola.warn(message, ...args);
  }
  /**
   * Log error
   */
  error(message, ...args) {
    if (!this.config.enabled) return;
    this.consola.error(message, ...args);
  }
  /**
   * Log debug
   */
  debug(message, ...args) {
    if (!this.config.enabled) return;
    this.consola.debug(message, ...args);
  }
  /**
   * Log success
   */
  success(message, ...args) {
    if (!this.config.enabled) return;
    this.consola.success(message, ...args);
  }
  /**
   * Create a sub-logger with prefix
   */
  withTag(tag) {
    return this.consola.withTag(tag);
  }
};
var defaultLogger = new APILogger();

// src/generated/cfg_accounts/retry.ts
import pRetry, { AbortError } from "p-retry";
var DEFAULT_RETRY_CONFIG = {
  retries: 3,
  factor: 2,
  minTimeout: 1e3,
  maxTimeout: 6e4,
  randomize: true,
  onFailedAttempt: /* @__PURE__ */ __name(() => {
  }, "onFailedAttempt")
};
function shouldRetry(error) {
  if (error instanceof NetworkError) {
    return true;
  }
  if (error instanceof APIError) {
    const status = error.statusCode;
    if (status >= 500 && status < 600) {
      return true;
    }
    if (status === 429) {
      return true;
    }
    return false;
  }
  return true;
}
__name(shouldRetry, "shouldRetry");
async function withRetry(fn, config) {
  const finalConfig = { ...DEFAULT_RETRY_CONFIG, ...config };
  return pRetry(
    async () => {
      try {
        return await fn();
      } catch (error) {
        if (!shouldRetry(error)) {
          throw new AbortError(error);
        }
        throw error;
      }
    },
    {
      retries: finalConfig.retries,
      factor: finalConfig.factor,
      minTimeout: finalConfig.minTimeout,
      maxTimeout: finalConfig.maxTimeout,
      randomize: finalConfig.randomize,
      onFailedAttempt: finalConfig.onFailedAttempt ? (error) => {
        const pRetryError = error;
        finalConfig.onFailedAttempt({
          error: pRetryError,
          attemptNumber: pRetryError.attemptNumber,
          retriesLeft: pRetryError.retriesLeft
        });
      } : void 0
    }
  );
}
__name(withRetry, "withRetry");

// src/generated/cfg_accounts/client.ts
var APIClient = class {
  constructor(baseUrl, options) {
    this.logger = null;
    this.retryConfig = null;
    this.tokenGetter = null;
    this.baseUrl = baseUrl.replace(/\/$/, "");
    this.httpClient = options?.httpClient || new FetchAdapter();
    this.tokenGetter = options?.tokenGetter || null;
    if (options?.loggerConfig !== void 0) {
      this.logger = new APILogger(options.loggerConfig);
    }
    if (options?.retryConfig !== void 0) {
      this.retryConfig = options.retryConfig;
    }
    this.auth = new Auth(this);
    this.oauth = new Oauth(this);
    this.user_profile = new UserProfile(this);
    this.accounts = new Accounts(this);
  }
  static {
    __name(this, "APIClient");
  }
  /**
   * Get CSRF token from cookies (for SessionAuthentication).
   *
   * Returns null if cookie doesn't exist (JWT-only auth).
   */
  getCsrfToken() {
    const name = "csrftoken";
    const value = `; ${document.cookie}`;
    const parts = value.split(`; ${name}=`);
    if (parts.length === 2) {
      return parts.pop()?.split(";").shift() || null;
    }
    return null;
  }
  /**
   * Get the base URL for building streaming/download URLs.
   */
  getBaseUrl() {
    return this.baseUrl;
  }
  /**
   * Get JWT token for URL authentication (used in streaming endpoints).
   * Returns null if no token getter is configured or no token is available.
   */
  getToken() {
    return this.tokenGetter ? this.tokenGetter() : null;
  }
  /**
   * Make HTTP request with Django CSRF and session handling.
   * Automatically retries on network errors and 5xx server errors.
   */
  async request(method, path, options) {
    if (this.retryConfig) {
      return withRetry(() => this._makeRequest(method, path, options), {
        ...this.retryConfig,
        onFailedAttempt: /* @__PURE__ */ __name((info) => {
          if (this.logger) {
            this.logger.warn(
              `Retry attempt ${info.attemptNumber}/${info.retriesLeft + info.attemptNumber} for ${method} ${path}: ${info.error.message}`
            );
          }
          this.retryConfig?.onFailedAttempt?.(info);
        }, "onFailedAttempt")
      });
    }
    return this._makeRequest(method, path, options);
  }
  /**
   * Internal request method (without retry wrapper).
   * Used by request() method with optional retry logic.
   */
  async _makeRequest(method, path, options) {
    const url = this.baseUrl ? `${this.baseUrl}${path}` : path;
    const startTime = Date.now();
    const headers = {
      ...options?.headers || {}
    };
    if (!options?.formData && !options?.binaryBody && !headers["Content-Type"]) {
      headers["Content-Type"] = "application/json";
    }
    if (this.logger) {
      this.logger.logRequest({
        method,
        url,
        headers,
        body: options?.formData || options?.body,
        timestamp: startTime
      });
    }
    try {
      const response = await this.httpClient.request({
        method,
        url,
        headers,
        params: options?.params,
        body: options?.body,
        formData: options?.formData,
        binaryBody: options?.binaryBody
      });
      const duration = Date.now() - startTime;
      if (response.status >= 400) {
        const error = new APIError(
          response.status,
          response.statusText,
          response.data,
          url
        );
        if (this.logger) {
          this.logger.logError(
            {
              method,
              url,
              headers,
              body: options?.formData || options?.body,
              timestamp: startTime
            },
            {
              message: error.message,
              statusCode: response.status,
              duration,
              timestamp: Date.now()
            }
          );
        }
        throw error;
      }
      if (this.logger) {
        this.logger.logResponse(
          {
            method,
            url,
            headers,
            body: options?.formData || options?.body,
            timestamp: startTime
          },
          {
            status: response.status,
            statusText: response.statusText,
            data: response.data,
            duration,
            timestamp: Date.now()
          }
        );
      }
      return response.data;
    } catch (error) {
      const duration = Date.now() - startTime;
      if (error instanceof APIError) {
        throw error;
      }
      const isCORSError = error instanceof TypeError && (error.message.toLowerCase().includes("cors") || error.message.toLowerCase().includes("failed to fetch") || error.message.toLowerCase().includes("network request failed"));
      if (this.logger) {
        if (isCORSError) {
          this.logger.error(`\u{1F6AB} CORS Error: ${method} ${url}`);
          this.logger.error(`  \u2192 ${error instanceof Error ? error.message : String(error)}`);
          this.logger.error(`  \u2192 Configure security_domains parameter on the server`);
        } else {
          this.logger.error(`\u26A0\uFE0F  Network Error: ${method} ${url}`);
          this.logger.error(`  \u2192 ${error instanceof Error ? error.message : String(error)}`);
        }
      }
      if (typeof window !== "undefined") {
        try {
          if (isCORSError) {
            window.dispatchEvent(new CustomEvent("cors-error", {
              detail: {
                url,
                method,
                error: error instanceof Error ? error.message : String(error),
                timestamp: /* @__PURE__ */ new Date()
              },
              bubbles: true,
              cancelable: false
            }));
          } else {
            window.dispatchEvent(new CustomEvent("network-error", {
              detail: {
                url,
                method,
                error: error instanceof Error ? error.message : String(error),
                timestamp: /* @__PURE__ */ new Date()
              },
              bubbles: true,
              cancelable: false
            }));
          }
        } catch (eventError) {
        }
      }
      const networkError = error instanceof Error ? new NetworkError(error.message, url, error) : new NetworkError("Unknown error", url);
      if (this.logger) {
        this.logger.logError(
          {
            method,
            url,
            headers,
            body: options?.formData || options?.body,
            timestamp: startTime
          },
          {
            message: networkError.message,
            duration,
            timestamp: Date.now()
          }
        );
      }
      throw networkError;
    }
  }
};

// src/generated/cfg_accounts/storage.ts
var LocalStorageAdapter = class {
  static {
    __name(this, "LocalStorageAdapter");
  }
  constructor(logger) {
    this.logger = logger;
  }
  getItem(key) {
    try {
      if (typeof window !== "undefined" && window.localStorage) {
        const value = localStorage.getItem(key);
        this.logger?.debug(`LocalStorage.getItem("${key}"): ${value ? "found" : "not found"}`);
        return value;
      }
      this.logger?.warn("LocalStorage not available: window.localStorage is undefined");
    } catch (error) {
      this.logger?.error("LocalStorage.getItem failed:", error);
    }
    return null;
  }
  setItem(key, value) {
    try {
      if (typeof window !== "undefined" && window.localStorage) {
        localStorage.setItem(key, value);
        this.logger?.debug(`LocalStorage.setItem("${key}"): success`);
      } else {
        this.logger?.warn("LocalStorage not available: window.localStorage is undefined");
      }
    } catch (error) {
      this.logger?.error("LocalStorage.setItem failed:", error);
    }
  }
  removeItem(key) {
    try {
      if (typeof window !== "undefined" && window.localStorage) {
        localStorage.removeItem(key);
        this.logger?.debug(`LocalStorage.removeItem("${key}"): success`);
      } else {
        this.logger?.warn("LocalStorage not available: window.localStorage is undefined");
      }
    } catch (error) {
      this.logger?.error("LocalStorage.removeItem failed:", error);
    }
  }
};

// src/generated/cfg_accounts/enums.ts
var OAuthConnectionProvider = /* @__PURE__ */ ((OAuthConnectionProvider2) => {
  OAuthConnectionProvider2["GITHUB"] = "github";
  return OAuthConnectionProvider2;
})(OAuthConnectionProvider || {});
var OAuthDisconnectRequestRequestProvider = /* @__PURE__ */ ((OAuthDisconnectRequestRequestProvider2) => {
  OAuthDisconnectRequestRequestProvider2["GITHUB"] = "github";
  return OAuthDisconnectRequestRequestProvider2;
})(OAuthDisconnectRequestRequestProvider || {});
var OTPRequestRequestChannel = /* @__PURE__ */ ((OTPRequestRequestChannel2) => {
  OTPRequestRequestChannel2["EMAIL"] = "email";
  OTPRequestRequestChannel2["PHONE"] = "phone";
  return OTPRequestRequestChannel2;
})(OTPRequestRequestChannel || {});
var OTPVerifyRequestChannel = /* @__PURE__ */ ((OTPVerifyRequestChannel2) => {
  OTPVerifyRequestChannel2["EMAIL"] = "email";
  OTPVerifyRequestChannel2["PHONE"] = "phone";
  return OTPVerifyRequestChannel2;
})(OTPVerifyRequestChannel || {});

// src/generated/cfg_accounts/_utils/schemas/AccountDeleteResponse.schema.ts
import { z as z2 } from "zod";
var AccountDeleteResponseSchema = z2.object({
  success: z2.boolean(),
  message: z2.string()
});

// src/generated/cfg_accounts/_utils/schemas/CentrifugoToken.schema.ts
import { z as z3 } from "zod";
var CentrifugoTokenSchema = z3.object({
  token: z3.string(),
  centrifugo_url: z3.union([z3.url(), z3.literal("")]),
  expires_at: z3.iso.datetime(),
  channels: z3.array(z3.string())
});

// src/generated/cfg_accounts/_utils/schemas/CfgAccountsProfileAvatarCreateRequest.schema.ts
import { z as z4 } from "zod";
var CfgAccountsProfileAvatarCreateRequestSchema = z4.object({
  avatar: z4.union([z4.instanceof(File), z4.instanceof(Blob)])
});

// src/generated/cfg_accounts/_utils/schemas/OAuthAuthorizeRequestRequest.schema.ts
import { z as z5 } from "zod";
var OAuthAuthorizeRequestRequestSchema = z5.object({
  redirect_uri: z5.union([z5.url(), z5.literal("")]).optional(),
  source_url: z5.union([z5.url(), z5.literal("")]).optional()
});

// src/generated/cfg_accounts/_utils/schemas/OAuthAuthorizeResponse.schema.ts
import { z as z6 } from "zod";
var OAuthAuthorizeResponseSchema = z6.object({
  authorization_url: z6.union([z6.url(), z6.literal("")]),
  state: z6.string()
});

// src/generated/cfg_accounts/_utils/schemas/OAuthCallbackRequestRequest.schema.ts
import { z as z7 } from "zod";
var OAuthCallbackRequestRequestSchema = z7.object({
  code: z7.string().min(10).max(500),
  state: z7.string().min(20).max(100),
  redirect_uri: z7.union([z7.url(), z7.literal("")]).optional()
});

// src/generated/cfg_accounts/_utils/schemas/OAuthConnection.schema.ts
import { z as z8 } from "zod";
var OAuthConnectionSchema = z8.object({
  id: z8.int(),
  provider: z8.nativeEnum(OAuthConnectionProvider),
  provider_display: z8.string(),
  provider_username: z8.string(),
  provider_email: z8.email(),
  provider_avatar_url: z8.union([z8.url(), z8.literal("")]),
  connected_at: z8.iso.datetime(),
  last_login_at: z8.iso.datetime()
});

// src/generated/cfg_accounts/_utils/schemas/OAuthDisconnectRequestRequest.schema.ts
import { z as z9 } from "zod";
var OAuthDisconnectRequestRequestSchema = z9.object({
  provider: z9.nativeEnum(OAuthDisconnectRequestRequestProvider)
});

// src/generated/cfg_accounts/_utils/schemas/OAuthError.schema.ts
import { z as z10 } from "zod";
var OAuthErrorSchema = z10.object({
  error: z10.string(),
  error_description: z10.string().optional()
});

// src/generated/cfg_accounts/_utils/schemas/OAuthProvidersResponse.schema.ts
import { z as z11 } from "zod";
var OAuthProvidersResponseSchema = z11.object({
  providers: z11.array(z11.record(z11.string(), z11.any()))
});

// src/generated/cfg_accounts/_utils/schemas/OAuthTokenResponse.schema.ts
import { z as z12 } from "zod";
var OAuthTokenResponseSchema = z12.object({
  requires_2fa: z12.boolean().optional(),
  session_id: z12.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i).nullable().optional(),
  access: z12.string().nullable().optional(),
  refresh: z12.string().nullable().optional(),
  user: z12.record(z12.string(), z12.any()).nullable().optional(),
  is_new_user: z12.boolean(),
  is_new_connection: z12.boolean(),
  should_prompt_2fa: z12.boolean().optional()
});

// src/generated/cfg_accounts/_utils/schemas/OTPErrorResponse.schema.ts
import { z as z13 } from "zod";
var OTPErrorResponseSchema = z13.object({
  error: z13.string()
});

// src/generated/cfg_accounts/_utils/schemas/OTPRequestRequest.schema.ts
import { z as z14 } from "zod";
var OTPRequestRequestSchema = z14.object({
  identifier: z14.string().min(1),
  channel: z14.nativeEnum(OTPRequestRequestChannel).optional(),
  source_url: z14.union([z14.url(), z14.literal("")]).optional()
});

// src/generated/cfg_accounts/_utils/schemas/OTPRequestResponse.schema.ts
import { z as z15 } from "zod";
var OTPRequestResponseSchema = z15.object({
  message: z15.string()
});

// src/generated/cfg_accounts/_utils/schemas/OTPVerifyRequest.schema.ts
import { z as z16 } from "zod";
var OTPVerifyRequestSchema = z16.object({
  identifier: z16.string().min(1),
  otp: z16.string().min(6).max(6),
  channel: z16.nativeEnum(OTPVerifyRequestChannel).optional(),
  source_url: z16.union([z16.url(), z16.literal("")]).optional()
});

// src/generated/cfg_accounts/_utils/schemas/OTPVerifyResponse.schema.ts
import { z as z18 } from "zod";

// src/generated/cfg_accounts/_utils/schemas/User.schema.ts
import { z as z17 } from "zod";
var UserSchema = z17.object({
  id: z17.int(),
  email: z17.email(),
  first_name: z17.string().max(50).optional(),
  last_name: z17.string().max(50).optional(),
  full_name: z17.string(),
  initials: z17.string(),
  display_username: z17.string(),
  company: z17.string().max(100).optional(),
  phone: z17.string().max(20).optional(),
  position: z17.string().max(100).optional(),
  avatar: z17.union([z17.url(), z17.literal("")]).nullable(),
  is_staff: z17.boolean(),
  is_superuser: z17.boolean(),
  date_joined: z17.iso.datetime(),
  last_login: z17.iso.datetime().nullable(),
  unanswered_messages_count: z17.int(),
  centrifugo: CentrifugoTokenSchema.nullable()
});

// src/generated/cfg_accounts/_utils/schemas/OTPVerifyResponse.schema.ts
var OTPVerifyResponseSchema = z18.object({
  requires_2fa: z18.boolean().optional(),
  session_id: z18.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i).nullable().optional(),
  refresh: z18.string().nullable().optional(),
  access: z18.string().nullable().optional(),
  user: UserSchema.nullable().optional(),
  should_prompt_2fa: z18.boolean().optional()
});

// src/generated/cfg_accounts/_utils/schemas/PatchedUserProfileUpdateRequest.schema.ts
import { z as z19 } from "zod";
var PatchedUserProfileUpdateRequestSchema = z19.object({
  first_name: z19.string().max(50).optional(),
  last_name: z19.string().max(50).optional(),
  company: z19.string().max(100).optional(),
  phone: z19.string().max(20).optional(),
  position: z19.string().max(100).optional()
});

// src/generated/cfg_accounts/_utils/schemas/TokenRefreshRequest.schema.ts
import { z as z20 } from "zod";
var TokenRefreshRequestSchema = z20.object({
  refresh: z20.string().min(1)
});

// src/generated/cfg_accounts/_utils/schemas/UserProfileUpdateRequest.schema.ts
import { z as z21 } from "zod";
var UserProfileUpdateRequestSchema = z21.object({
  first_name: z21.string().max(50).optional(),
  last_name: z21.string().max(50).optional(),
  company: z21.string().max(100).optional(),
  phone: z21.string().max(20).optional(),
  position: z21.string().max(100).optional()
});

// src/generated/cfg_accounts/_utils/fetchers/accounts.ts
import { consola } from "consola";
async function createAccountsOtpRequestCreate(data, client) {
  const api = client || getAPIInstance();
  const response = await api.accounts.otpRequestCreate(data);
  try {
    return OTPRequestResponseSchema.parse(response);
  } catch (error) {
    consola.error("\u274C Zod Validation Failed");
    consola.box(`createAccountsOtpRequestCreate
Path: /cfg/accounts/otp/request/
Method: POST`);
    if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
      consola.error("Validation Issues:");
      error.issues.forEach((issue, index) => {
        consola.error(`  ${index + 1}. ${issue.path.join(".") || "root"}`);
        consola.error(`     \u251C\u2500 Message: ${issue.message}`);
        if (issue.expected) consola.error(`     \u251C\u2500 Expected: ${issue.expected}`);
        if (issue.received) consola.error(`     \u2514\u2500 Received: ${issue.received}`);
      });
    }
    consola.error("Response data:", response);
    if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
      try {
        const event = new CustomEvent("zod-validation-error", {
          detail: {
            operation: "createAccountsOtpRequestCreate",
            path: "/cfg/accounts/otp/request/",
            method: "POST",
            error,
            response,
            timestamp: /* @__PURE__ */ new Date()
          },
          bubbles: true,
          cancelable: false
        });
        window.dispatchEvent(event);
      } catch (eventError) {
        consola.warn("Failed to dispatch validation error event:", eventError);
      }
    }
    throw error;
  }
}
__name(createAccountsOtpRequestCreate, "createAccountsOtpRequestCreate");
async function createAccountsOtpVerifyCreate(data, client) {
  const api = client || getAPIInstance();
  const response = await api.accounts.otpVerifyCreate(data);
  try {
    return OTPVerifyResponseSchema.parse(response);
  } catch (error) {
    consola.error("\u274C Zod Validation Failed");
    consola.box(`createAccountsOtpVerifyCreate
Path: /cfg/accounts/otp/verify/
Method: POST`);
    if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
      consola.error("Validation Issues:");
      error.issues.forEach((issue, index) => {
        consola.error(`  ${index + 1}. ${issue.path.join(".") || "root"}`);
        consola.error(`     \u251C\u2500 Message: ${issue.message}`);
        if (issue.expected) consola.error(`     \u251C\u2500 Expected: ${issue.expected}`);
        if (issue.received) consola.error(`     \u2514\u2500 Received: ${issue.received}`);
      });
    }
    consola.error("Response data:", response);
    if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
      try {
        const event = new CustomEvent("zod-validation-error", {
          detail: {
            operation: "createAccountsOtpVerifyCreate",
            path: "/cfg/accounts/otp/verify/",
            method: "POST",
            error,
            response,
            timestamp: /* @__PURE__ */ new Date()
          },
          bubbles: true,
          cancelable: false
        });
        window.dispatchEvent(event);
      } catch (eventError) {
        consola.warn("Failed to dispatch validation error event:", eventError);
      }
    }
    throw error;
  }
}
__name(createAccountsOtpVerifyCreate, "createAccountsOtpVerifyCreate");

// src/generated/cfg_accounts/_utils/fetchers/accounts__oauth.ts
import { consola as consola2 } from "consola";
async function getAccountsOauthConnectionsList(client) {
  const api = client || getAPIInstance();
  const response = await api.oauth.accountsOauthConnectionsList();
  return response;
}
__name(getAccountsOauthConnectionsList, "getAccountsOauthConnectionsList");
async function createAccountsOauthDisconnectCreate(data, client) {
  const api = client || getAPIInstance();
  const response = await api.oauth.accountsOauthDisconnectCreate(data);
  return response;
}
__name(createAccountsOauthDisconnectCreate, "createAccountsOauthDisconnectCreate");
async function createAccountsOauthGithubAuthorizeCreate(data, client) {
  const api = client || getAPIInstance();
  const response = await api.oauth.accountsOauthGithubAuthorizeCreate(data);
  try {
    return OAuthAuthorizeResponseSchema.parse(response);
  } catch (error) {
    consola2.error("\u274C Zod Validation Failed");
    consola2.box(`createAccountsOauthGithubAuthorizeCreate
Path: /cfg/accounts/oauth/github/authorize/
Method: POST`);
    if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
      consola2.error("Validation Issues:");
      error.issues.forEach((issue, index) => {
        consola2.error(`  ${index + 1}. ${issue.path.join(".") || "root"}`);
        consola2.error(`     \u251C\u2500 Message: ${issue.message}`);
        if (issue.expected) consola2.error(`     \u251C\u2500 Expected: ${issue.expected}`);
        if (issue.received) consola2.error(`     \u2514\u2500 Received: ${issue.received}`);
      });
    }
    consola2.error("Response data:", response);
    if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
      try {
        const event = new CustomEvent("zod-validation-error", {
          detail: {
            operation: "createAccountsOauthGithubAuthorizeCreate",
            path: "/cfg/accounts/oauth/github/authorize/",
            method: "POST",
            error,
            response,
            timestamp: /* @__PURE__ */ new Date()
          },
          bubbles: true,
          cancelable: false
        });
        window.dispatchEvent(event);
      } catch (eventError) {
        consola2.warn("Failed to dispatch validation error event:", eventError);
      }
    }
    throw error;
  }
}
__name(createAccountsOauthGithubAuthorizeCreate, "createAccountsOauthGithubAuthorizeCreate");
async function createAccountsOauthGithubCallbackCreate(data, client) {
  const api = client || getAPIInstance();
  const response = await api.oauth.accountsOauthGithubCallbackCreate(data);
  try {
    return OAuthTokenResponseSchema.parse(response);
  } catch (error) {
    consola2.error("\u274C Zod Validation Failed");
    consola2.box(`createAccountsOauthGithubCallbackCreate
Path: /cfg/accounts/oauth/github/callback/
Method: POST`);
    if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
      consola2.error("Validation Issues:");
      error.issues.forEach((issue, index) => {
        consola2.error(`  ${index + 1}. ${issue.path.join(".") || "root"}`);
        consola2.error(`     \u251C\u2500 Message: ${issue.message}`);
        if (issue.expected) consola2.error(`     \u251C\u2500 Expected: ${issue.expected}`);
        if (issue.received) consola2.error(`     \u2514\u2500 Received: ${issue.received}`);
      });
    }
    consola2.error("Response data:", response);
    if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
      try {
        const event = new CustomEvent("zod-validation-error", {
          detail: {
            operation: "createAccountsOauthGithubCallbackCreate",
            path: "/cfg/accounts/oauth/github/callback/",
            method: "POST",
            error,
            response,
            timestamp: /* @__PURE__ */ new Date()
          },
          bubbles: true,
          cancelable: false
        });
        window.dispatchEvent(event);
      } catch (eventError) {
        consola2.warn("Failed to dispatch validation error event:", eventError);
      }
    }
    throw error;
  }
}
__name(createAccountsOauthGithubCallbackCreate, "createAccountsOauthGithubCallbackCreate");
async function getAccountsOauthProvidersRetrieve(client) {
  const api = client || getAPIInstance();
  const response = await api.oauth.accountsOauthProvidersRetrieve();
  try {
    return OAuthProvidersResponseSchema.parse(response);
  } catch (error) {
    consola2.error("\u274C Zod Validation Failed");
    consola2.box(`getAccountsOauthProvidersRetrieve
Path: /cfg/accounts/oauth/providers/
Method: GET`);
    if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
      consola2.error("Validation Issues:");
      error.issues.forEach((issue, index) => {
        consola2.error(`  ${index + 1}. ${issue.path.join(".") || "root"}`);
        consola2.error(`     \u251C\u2500 Message: ${issue.message}`);
        if (issue.expected) consola2.error(`     \u251C\u2500 Expected: ${issue.expected}`);
        if (issue.received) consola2.error(`     \u2514\u2500 Received: ${issue.received}`);
      });
    }
    consola2.error("Response data:", response);
    if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
      try {
        const event = new CustomEvent("zod-validation-error", {
          detail: {
            operation: "getAccountsOauthProvidersRetrieve",
            path: "/cfg/accounts/oauth/providers/",
            method: "GET",
            error,
            response,
            timestamp: /* @__PURE__ */ new Date()
          },
          bubbles: true,
          cancelable: false
        });
        window.dispatchEvent(event);
      } catch (eventError) {
        consola2.warn("Failed to dispatch validation error event:", eventError);
      }
    }
    throw error;
  }
}
__name(getAccountsOauthProvidersRetrieve, "getAccountsOauthProvidersRetrieve");

// src/generated/cfg_accounts/_utils/fetchers/accounts__user_profile.ts
import { consola as consola3 } from "consola";
async function getAccountsProfileRetrieve(client) {
  const api = client || getAPIInstance();
  const response = await api.user_profile.accountsProfileRetrieve();
  try {
    return UserSchema.parse(response);
  } catch (error) {
    consola3.error("\u274C Zod Validation Failed");
    consola3.box(`getAccountsProfileRetrieve
Path: /cfg/accounts/profile/
Method: GET`);
    if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
      consola3.error("Validation Issues:");
      error.issues.forEach((issue, index) => {
        consola3.error(`  ${index + 1}. ${issue.path.join(".") || "root"}`);
        consola3.error(`     \u251C\u2500 Message: ${issue.message}`);
        if (issue.expected) consola3.error(`     \u251C\u2500 Expected: ${issue.expected}`);
        if (issue.received) consola3.error(`     \u2514\u2500 Received: ${issue.received}`);
      });
    }
    consola3.error("Response data:", response);
    if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
      try {
        const event = new CustomEvent("zod-validation-error", {
          detail: {
            operation: "getAccountsProfileRetrieve",
            path: "/cfg/accounts/profile/",
            method: "GET",
            error,
            response,
            timestamp: /* @__PURE__ */ new Date()
          },
          bubbles: true,
          cancelable: false
        });
        window.dispatchEvent(event);
      } catch (eventError) {
        consola3.warn("Failed to dispatch validation error event:", eventError);
      }
    }
    throw error;
  }
}
__name(getAccountsProfileRetrieve, "getAccountsProfileRetrieve");
async function createAccountsProfileAvatarCreate(data, client) {
  const api = client || getAPIInstance();
  const response = await api.user_profile.accountsProfileAvatarCreate(data);
  try {
    return UserSchema.parse(response);
  } catch (error) {
    consola3.error("\u274C Zod Validation Failed");
    consola3.box(`createAccountsProfileAvatarCreate
Path: /cfg/accounts/profile/avatar/
Method: POST`);
    if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
      consola3.error("Validation Issues:");
      error.issues.forEach((issue, index) => {
        consola3.error(`  ${index + 1}. ${issue.path.join(".") || "root"}`);
        consola3.error(`     \u251C\u2500 Message: ${issue.message}`);
        if (issue.expected) consola3.error(`     \u251C\u2500 Expected: ${issue.expected}`);
        if (issue.received) consola3.error(`     \u2514\u2500 Received: ${issue.received}`);
      });
    }
    consola3.error("Response data:", response);
    if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
      try {
        const event = new CustomEvent("zod-validation-error", {
          detail: {
            operation: "createAccountsProfileAvatarCreate",
            path: "/cfg/accounts/profile/avatar/",
            method: "POST",
            error,
            response,
            timestamp: /* @__PURE__ */ new Date()
          },
          bubbles: true,
          cancelable: false
        });
        window.dispatchEvent(event);
      } catch (eventError) {
        consola3.warn("Failed to dispatch validation error event:", eventError);
      }
    }
    throw error;
  }
}
__name(createAccountsProfileAvatarCreate, "createAccountsProfileAvatarCreate");
async function createAccountsProfileDeleteCreate(client) {
  const api = client || getAPIInstance();
  const response = await api.user_profile.accountsProfileDeleteCreate();
  try {
    return AccountDeleteResponseSchema.parse(response);
  } catch (error) {
    consola3.error("\u274C Zod Validation Failed");
    consola3.box(`createAccountsProfileDeleteCreate
Path: /cfg/accounts/profile/delete/
Method: POST`);
    if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
      consola3.error("Validation Issues:");
      error.issues.forEach((issue, index) => {
        consola3.error(`  ${index + 1}. ${issue.path.join(".") || "root"}`);
        consola3.error(`     \u251C\u2500 Message: ${issue.message}`);
        if (issue.expected) consola3.error(`     \u251C\u2500 Expected: ${issue.expected}`);
        if (issue.received) consola3.error(`     \u2514\u2500 Received: ${issue.received}`);
      });
    }
    consola3.error("Response data:", response);
    if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
      try {
        const event = new CustomEvent("zod-validation-error", {
          detail: {
            operation: "createAccountsProfileDeleteCreate",
            path: "/cfg/accounts/profile/delete/",
            method: "POST",
            error,
            response,
            timestamp: /* @__PURE__ */ new Date()
          },
          bubbles: true,
          cancelable: false
        });
        window.dispatchEvent(event);
      } catch (eventError) {
        consola3.warn("Failed to dispatch validation error event:", eventError);
      }
    }
    throw error;
  }
}
__name(createAccountsProfileDeleteCreate, "createAccountsProfileDeleteCreate");
async function partialUpdateAccountsProfilePartialUpdate(data, client) {
  const api = client || getAPIInstance();
  const response = await api.user_profile.accountsProfilePartialUpdate(data);
  try {
    return UserSchema.parse(response);
  } catch (error) {
    consola3.error("\u274C Zod Validation Failed");
    consola3.box(`partialUpdateAccountsProfilePartialUpdate
Path: /cfg/accounts/profile/partial/
Method: PUT`);
    if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
      consola3.error("Validation Issues:");
      error.issues.forEach((issue, index) => {
        consola3.error(`  ${index + 1}. ${issue.path.join(".") || "root"}`);
        consola3.error(`     \u251C\u2500 Message: ${issue.message}`);
        if (issue.expected) consola3.error(`     \u251C\u2500 Expected: ${issue.expected}`);
        if (issue.received) consola3.error(`     \u2514\u2500 Received: ${issue.received}`);
      });
    }
    consola3.error("Response data:", response);
    if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
      try {
        const event = new CustomEvent("zod-validation-error", {
          detail: {
            operation: "partialUpdateAccountsProfilePartialUpdate",
            path: "/cfg/accounts/profile/partial/",
            method: "PUT",
            error,
            response,
            timestamp: /* @__PURE__ */ new Date()
          },
          bubbles: true,
          cancelable: false
        });
        window.dispatchEvent(event);
      } catch (eventError) {
        consola3.warn("Failed to dispatch validation error event:", eventError);
      }
    }
    throw error;
  }
}
__name(partialUpdateAccountsProfilePartialUpdate, "partialUpdateAccountsProfilePartialUpdate");
async function partialUpdateAccountsProfilePartialPartialUpdate(data, client) {
  const api = client || getAPIInstance();
  const response = await api.user_profile.accountsProfilePartialPartialUpdate(data);
  try {
    return UserSchema.parse(response);
  } catch (error) {
    consola3.error("\u274C Zod Validation Failed");
    consola3.box(`partialUpdateAccountsProfilePartialPartialUpdate
Path: /cfg/accounts/profile/partial/
Method: PATCH`);
    if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
      consola3.error("Validation Issues:");
      error.issues.forEach((issue, index) => {
        consola3.error(`  ${index + 1}. ${issue.path.join(".") || "root"}`);
        consola3.error(`     \u251C\u2500 Message: ${issue.message}`);
        if (issue.expected) consola3.error(`     \u251C\u2500 Expected: ${issue.expected}`);
        if (issue.received) consola3.error(`     \u2514\u2500 Received: ${issue.received}`);
      });
    }
    consola3.error("Response data:", response);
    if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
      try {
        const event = new CustomEvent("zod-validation-error", {
          detail: {
            operation: "partialUpdateAccountsProfilePartialPartialUpdate",
            path: "/cfg/accounts/profile/partial/",
            method: "PATCH",
            error,
            response,
            timestamp: /* @__PURE__ */ new Date()
          },
          bubbles: true,
          cancelable: false
        });
        window.dispatchEvent(event);
      } catch (eventError) {
        consola3.warn("Failed to dispatch validation error event:", eventError);
      }
    }
    throw error;
  }
}
__name(partialUpdateAccountsProfilePartialPartialUpdate, "partialUpdateAccountsProfilePartialPartialUpdate");
async function updateAccountsProfileUpdateUpdate(data, client) {
  const api = client || getAPIInstance();
  const response = await api.user_profile.accountsProfileUpdateUpdate(data);
  try {
    return UserSchema.parse(response);
  } catch (error) {
    consola3.error("\u274C Zod Validation Failed");
    consola3.box(`updateAccountsProfileUpdateUpdate
Path: /cfg/accounts/profile/update/
Method: PUT`);
    if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
      consola3.error("Validation Issues:");
      error.issues.forEach((issue, index) => {
        consola3.error(`  ${index + 1}. ${issue.path.join(".") || "root"}`);
        consola3.error(`     \u251C\u2500 Message: ${issue.message}`);
        if (issue.expected) consola3.error(`     \u251C\u2500 Expected: ${issue.expected}`);
        if (issue.received) consola3.error(`     \u2514\u2500 Received: ${issue.received}`);
      });
    }
    consola3.error("Response data:", response);
    if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
      try {
        const event = new CustomEvent("zod-validation-error", {
          detail: {
            operation: "updateAccountsProfileUpdateUpdate",
            path: "/cfg/accounts/profile/update/",
            method: "PUT",
            error,
            response,
            timestamp: /* @__PURE__ */ new Date()
          },
          bubbles: true,
          cancelable: false
        });
        window.dispatchEvent(event);
      } catch (eventError) {
        consola3.warn("Failed to dispatch validation error event:", eventError);
      }
    }
    throw error;
  }
}
__name(updateAccountsProfileUpdateUpdate, "updateAccountsProfileUpdateUpdate");
async function partialUpdateAccountsProfileUpdatePartialUpdate(data, client) {
  const api = client || getAPIInstance();
  const response = await api.user_profile.accountsProfileUpdatePartialUpdate(data);
  try {
    return UserSchema.parse(response);
  } catch (error) {
    consola3.error("\u274C Zod Validation Failed");
    consola3.box(`partialUpdateAccountsProfileUpdatePartialUpdate
Path: /cfg/accounts/profile/update/
Method: PATCH`);
    if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
      consola3.error("Validation Issues:");
      error.issues.forEach((issue, index) => {
        consola3.error(`  ${index + 1}. ${issue.path.join(".") || "root"}`);
        consola3.error(`     \u251C\u2500 Message: ${issue.message}`);
        if (issue.expected) consola3.error(`     \u251C\u2500 Expected: ${issue.expected}`);
        if (issue.received) consola3.error(`     \u2514\u2500 Received: ${issue.received}`);
      });
    }
    consola3.error("Response data:", response);
    if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
      try {
        const event = new CustomEvent("zod-validation-error", {
          detail: {
            operation: "partialUpdateAccountsProfileUpdatePartialUpdate",
            path: "/cfg/accounts/profile/update/",
            method: "PATCH",
            error,
            response,
            timestamp: /* @__PURE__ */ new Date()
          },
          bubbles: true,
          cancelable: false
        });
        window.dispatchEvent(event);
      } catch (eventError) {
        consola3.warn("Failed to dispatch validation error event:", eventError);
      }
    }
    throw error;
  }
}
__name(partialUpdateAccountsProfileUpdatePartialUpdate, "partialUpdateAccountsProfileUpdatePartialUpdate");

// src/generated/cfg_accounts/index.ts
var TOKEN_KEY = "auth_token";
var REFRESH_TOKEN_KEY = "refresh_token";
var API = class {
  constructor(baseUrl, options) {
    this._token = null;
    this._refreshToken = null;
    this.baseUrl = baseUrl;
    this.options = options;
    const logger = options?.loggerConfig ? new APILogger(options.loggerConfig) : void 0;
    this.storage = options?.storage || new LocalStorageAdapter(logger);
    this._loadTokensFromStorage();
    this._client = new APIClient(this.baseUrl, {
      retryConfig: this.options?.retryConfig,
      loggerConfig: this.options?.loggerConfig,
      tokenGetter: /* @__PURE__ */ __name(() => this.getToken(), "tokenGetter")
    });
    this._injectAuthHeader();
    this.auth = this._client.auth;
    this.oauth = this._client.oauth;
    this.user_profile = this._client.user_profile;
    this.accounts = this._client.accounts;
  }
  static {
    __name(this, "API");
  }
  _loadTokensFromStorage() {
    this._token = this.storage.getItem(TOKEN_KEY);
    this._refreshToken = this.storage.getItem(REFRESH_TOKEN_KEY);
  }
  _reinitClients() {
    this._client = new APIClient(this.baseUrl, {
      retryConfig: this.options?.retryConfig,
      loggerConfig: this.options?.loggerConfig,
      tokenGetter: /* @__PURE__ */ __name(() => this.getToken(), "tokenGetter")
    });
    this._injectAuthHeader();
    this.auth = this._client.auth;
    this.oauth = this._client.oauth;
    this.user_profile = this._client.user_profile;
    this.accounts = this._client.accounts;
  }
  _injectAuthHeader() {
    const originalRequest = this._client.request.bind(this._client);
    this._client.request = async (method, path, options) => {
      const token = this.getToken();
      const mergedOptions = {
        ...options,
        headers: {
          ...options?.headers || {},
          ...token ? { "Authorization": `Bearer ${token}` } : {}
        }
      };
      return originalRequest(method, path, mergedOptions);
    };
  }
  /**
   * Get current JWT token
   */
  getToken() {
    return this.storage.getItem(TOKEN_KEY);
  }
  /**
   * Get current refresh token
   */
  getRefreshToken() {
    return this.storage.getItem(REFRESH_TOKEN_KEY);
  }
  /**
   * Set JWT token and refresh token
   * @param token - JWT access token
   * @param refreshToken - JWT refresh token (optional)
   */
  setToken(token, refreshToken) {
    this._token = token;
    this.storage.setItem(TOKEN_KEY, token);
    if (refreshToken) {
      this._refreshToken = refreshToken;
      this.storage.setItem(REFRESH_TOKEN_KEY, refreshToken);
    }
    this._reinitClients();
  }
  /**
   * Clear all tokens
   */
  clearTokens() {
    this._token = null;
    this._refreshToken = null;
    this.storage.removeItem(TOKEN_KEY);
    this.storage.removeItem(REFRESH_TOKEN_KEY);
    this._reinitClients();
  }
  /**
   * Check if user is authenticated
   */
  isAuthenticated() {
    return !!this.getToken();
  }
  /**
   * Update base URL and reinitialize clients
   * @param url - New base URL
   */
  setBaseUrl(url) {
    this.baseUrl = url;
    this._reinitClients();
  }
  /**
   * Get current base URL
   */
  getBaseUrl() {
    return this.baseUrl;
  }
  /**
   * Get OpenAPI schema path
   * @returns Path to the OpenAPI schema JSON file
   *
   * Note: The OpenAPI schema is available in the schema.json file.
   * You can load it dynamically using:
   * ```typescript
   * const schema = await fetch('./schema.json').then(r => r.json());
   * // or using fs in Node.js:
   * // const schema = JSON.parse(fs.readFileSync('./schema.json', 'utf-8'));
   * ```
   */
  getSchemaPath() {
    return "./schema.json";
  }
};

// src/generated/cfg_accounts/api-instance.ts
var globalAPI = null;
var autoConfigAttempted = false;
function tryAutoConfigureFromEnv() {
  if (autoConfigAttempted) return;
  autoConfigAttempted = true;
  if (globalAPI) return;
  if (typeof process === "undefined" || !process.env) return;
  const baseUrl = process.env.NEXT_PUBLIC_API_URL || process.env.VITE_API_URL || process.env.REACT_APP_API_URL || process.env.API_URL;
  if (baseUrl) {
    globalAPI = new API(baseUrl);
  }
}
__name(tryAutoConfigureFromEnv, "tryAutoConfigureFromEnv");
function getAPIInstance() {
  tryAutoConfigureFromEnv();
  if (!globalAPI) {
    throw new Error(
      'API not configured. Call configureAPI() with your base URL before using fetchers or hooks.\n\nExample:\n  import { configureAPI } from "./api-instance"\n  configureAPI({ baseUrl: "https://api.example.com" })\n\nOr set environment variable: NEXT_PUBLIC_API_URL, VITE_API_URL, or REACT_APP_API_URL'
    );
  }
  return globalAPI;
}
__name(getAPIInstance, "getAPIInstance");

// src/generated/cfg_accounts/_utils/fetchers/accounts__auth.ts
async function createAccountsTokenRefreshCreate(data, client) {
  const api = client || getAPIInstance();
  const response = await api.auth.accountsTokenRefreshCreate(data);
  try {
    return TokenRefreshSchema.parse(response);
  } catch (error) {
    consola4.error("\u274C Zod Validation Failed");
    consola4.box(`createAccountsTokenRefreshCreate
Path: /cfg/accounts/token/refresh/
Method: POST`);
    if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
      consola4.error("Validation Issues:");
      error.issues.forEach((issue, index) => {
        consola4.error(`  ${index + 1}. ${issue.path.join(".") || "root"}`);
        consola4.error(`     \u251C\u2500 Message: ${issue.message}`);
        if (issue.expected) consola4.error(`     \u251C\u2500 Expected: ${issue.expected}`);
        if (issue.received) consola4.error(`     \u2514\u2500 Received: ${issue.received}`);
      });
    }
    consola4.error("Response data:", response);
    if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
      try {
        const event = new CustomEvent("zod-validation-error", {
          detail: {
            operation: "createAccountsTokenRefreshCreate",
            path: "/cfg/accounts/token/refresh/",
            method: "POST",
            error,
            response,
            timestamp: /* @__PURE__ */ new Date()
          },
          bubbles: true,
          cancelable: false
        });
        window.dispatchEvent(event);
      } catch (eventError) {
        consola4.warn("Failed to dispatch validation error event:", eventError);
      }
    }
    throw error;
  }
}
__name(createAccountsTokenRefreshCreate, "createAccountsTokenRefreshCreate");

// src/generated/cfg_accounts/_utils/hooks/accounts__auth.ts
function useCreateAccountsTokenRefreshCreate() {
  const { mutate } = useSWRConfig();
  return async (data, client) => {
    const result = await createAccountsTokenRefreshCreate(data, client);
    mutate("cfg-accounts-token-refresh");
    return result;
  };
}
__name(useCreateAccountsTokenRefreshCreate, "useCreateAccountsTokenRefreshCreate");

// src/generated/cfg_accounts/_utils/hooks/accounts__oauth.ts
import useSWR from "swr";
import { useSWRConfig as useSWRConfig2 } from "swr";
function useAccountsOauthConnectionsList(client) {
  return useSWR(
    "cfg-accounts-oauth-connections",
    () => getAccountsOauthConnectionsList(client)
  );
}
__name(useAccountsOauthConnectionsList, "useAccountsOauthConnectionsList");
function useCreateAccountsOauthDisconnectCreate() {
  const { mutate } = useSWRConfig2();
  return async (data, client) => {
    const result = await createAccountsOauthDisconnectCreate(data, client);
    mutate("cfg-accounts-oauth-disconnect");
    return result;
  };
}
__name(useCreateAccountsOauthDisconnectCreate, "useCreateAccountsOauthDisconnectCreate");
function useCreateAccountsOauthGithubAuthorizeCreate() {
  const { mutate } = useSWRConfig2();
  return async (data, client) => {
    const result = await createAccountsOauthGithubAuthorizeCreate(data, client);
    mutate("cfg-accounts-oauth-github-authorize");
    return result;
  };
}
__name(useCreateAccountsOauthGithubAuthorizeCreate, "useCreateAccountsOauthGithubAuthorizeCreate");
function useCreateAccountsOauthGithubCallbackCreate() {
  const { mutate } = useSWRConfig2();
  return async (data, client) => {
    const result = await createAccountsOauthGithubCallbackCreate(data, client);
    mutate("cfg-accounts-oauth-github-callback");
    return result;
  };
}
__name(useCreateAccountsOauthGithubCallbackCreate, "useCreateAccountsOauthGithubCallbackCreate");
function useAccountsOauthProvidersRetrieve(client) {
  return useSWR(
    "cfg-accounts-oauth-provider",
    () => getAccountsOauthProvidersRetrieve(client)
  );
}
__name(useAccountsOauthProvidersRetrieve, "useAccountsOauthProvidersRetrieve");

// src/generated/cfg_accounts/_utils/hooks/accounts__user_profile.ts
import useSWR2 from "swr";
import { useSWRConfig as useSWRConfig3 } from "swr";
function useAccountsProfileRetrieve(client) {
  return useSWR2(
    "cfg-accounts-profile",
    () => getAccountsProfileRetrieve(client)
  );
}
__name(useAccountsProfileRetrieve, "useAccountsProfileRetrieve");
function useCreateAccountsProfileAvatarCreate() {
  const { mutate } = useSWRConfig3();
  return async (data, client) => {
    const result = await createAccountsProfileAvatarCreate(data, client);
    mutate("cfg-accounts-profile-avatar");
    return result;
  };
}
__name(useCreateAccountsProfileAvatarCreate, "useCreateAccountsProfileAvatarCreate");
function useCreateAccountsProfileDeleteCreate() {
  const { mutate } = useSWRConfig3();
  return async (client) => {
    const result = await createAccountsProfileDeleteCreate(client);
    mutate("cfg-accounts-profile-delete");
    return result;
  };
}
__name(useCreateAccountsProfileDeleteCreate, "useCreateAccountsProfileDeleteCreate");
function usePartialUpdateAccountsProfilePartialUpdate() {
  const { mutate } = useSWRConfig3();
  return async (data, client) => {
    const result = await partialUpdateAccountsProfilePartialUpdate(data, client);
    mutate("cfg-accounts-profile-partial");
    return result;
  };
}
__name(usePartialUpdateAccountsProfilePartialUpdate, "usePartialUpdateAccountsProfilePartialUpdate");
function usePartialUpdateAccountsProfilePartialPartialUpdate() {
  const { mutate } = useSWRConfig3();
  return async (data, client) => {
    const result = await partialUpdateAccountsProfilePartialPartialUpdate(data, client);
    mutate("cfg-accounts-profile-partial-partial");
    return result;
  };
}
__name(usePartialUpdateAccountsProfilePartialPartialUpdate, "usePartialUpdateAccountsProfilePartialPartialUpdate");
function useUpdateAccountsProfileUpdateUpdate() {
  const { mutate } = useSWRConfig3();
  return async (data, client) => {
    const result = await updateAccountsProfileUpdateUpdate(data, client);
    mutate("cfg-accounts-profile");
    return result;
  };
}
__name(useUpdateAccountsProfileUpdateUpdate, "useUpdateAccountsProfileUpdateUpdate");
function usePartialUpdateAccountsProfileUpdatePartialUpdate() {
  const { mutate } = useSWRConfig3();
  return async (data, client) => {
    const result = await partialUpdateAccountsProfileUpdatePartialUpdate(data, client);
    mutate("cfg-accounts-profile-partial");
    return result;
  };
}
__name(usePartialUpdateAccountsProfileUpdatePartialUpdate, "usePartialUpdateAccountsProfileUpdatePartialUpdate");

// src/generated/cfg_accounts/_utils/hooks/accounts.ts
import { useSWRConfig as useSWRConfig4 } from "swr";
function useCreateAccountsOtpRequestCreate() {
  const { mutate } = useSWRConfig4();
  return async (data, client) => {
    const result = await createAccountsOtpRequestCreate(data, client);
    mutate("cfg-accounts-otp-request");
    return result;
  };
}
__name(useCreateAccountsOtpRequestCreate, "useCreateAccountsOtpRequestCreate");
function useCreateAccountsOtpVerifyCreate() {
  const { mutate } = useSWRConfig4();
  return async (data, client) => {
    const result = await createAccountsOtpVerifyCreate(data, client);
    mutate("cfg-accounts-otp-verify");
    return result;
  };
}
__name(useCreateAccountsOtpVerifyCreate, "useCreateAccountsOtpVerifyCreate");
export {
  useAccountsOauthConnectionsList,
  useAccountsOauthProvidersRetrieve,
  useAccountsProfileRetrieve,
  useCreateAccountsOauthDisconnectCreate,
  useCreateAccountsOauthGithubAuthorizeCreate,
  useCreateAccountsOauthGithubCallbackCreate,
  useCreateAccountsOtpRequestCreate,
  useCreateAccountsOtpVerifyCreate,
  useCreateAccountsProfileAvatarCreate,
  useCreateAccountsProfileDeleteCreate,
  useCreateAccountsTokenRefreshCreate,
  usePartialUpdateAccountsProfilePartialPartialUpdate,
  usePartialUpdateAccountsProfilePartialUpdate,
  usePartialUpdateAccountsProfileUpdatePartialUpdate,
  useUpdateAccountsProfileUpdateUpdate
};
//# sourceMappingURL=hooks.mjs.map