const require_chunk = require('./chunk-DWy1uDak.cjs');
const zod = require_chunk.__toESM(require("zod"));

//#region src/utils/slug-validation.ts
/**
* Maximum reasonable length for a slug.
*/
const MAX_SLUG_LENGTH = 100;
/**
* Maximum reasonable length for a numeric ID.
*/
const MAX_ID_LENGTH = 20;
/**
* Helper to check if a string is a numeric ID.
*/
function isNumericId(value) {
	return /^\d+$/.test(value);
}
/**
* Valid slug pattern: alphanumeric, hyphens, underscores, and dots.
* Must start with alphanumeric character.
*/
const VALID_SLUG_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;
/**
* Validates a slug to prevent path traversal and injection attacks.
* Designed to be used with Zod's superRefine() method.
*
* @example
* ```typescript
* const OrganizationSlug = z.string()
*   .toLowerCase()
*   .trim()
*   .superRefine(validateSlug)
*   .describe("Organization slug");
*
* const TeamSlug = z.string()
*   .toLowerCase()
*   .trim()
*   .superRefine(validateSlug)
*   .describe("Team slug");
* ```
*/
function validateSlug(val, ctx) {
	if (val.length === 0) {
		ctx.addIssue({
			code: zod.z.ZodIssueCode.custom,
			message: "Slug cannot be empty"
		});
		return;
	}
	if (val.length > MAX_SLUG_LENGTH) {
		ctx.addIssue({
			code: zod.z.ZodIssueCode.custom,
			message: `Slug exceeds maximum length of ${MAX_SLUG_LENGTH} characters`
		});
		return;
	}
	if (!VALID_SLUG_PATTERN.test(val)) ctx.addIssue({
		code: zod.z.ZodIssueCode.custom,
		message: "Slug must contain only alphanumeric characters, hyphens, underscores, and dots, and must start with an alphanumeric character"
	});
}
/**
* Validates a parameter that can be either a slug or numeric ID.
* Designed to be used with Zod's superRefine() method.
*
* @example
* ```typescript
* const ProjectSlugOrId = z.string()
*   .toLowerCase()
*   .trim()
*   .superRefine(validateSlugOrId)
*   .describe("Project slug or numeric ID");
*
* const IssueSlugOrId = z.string()
*   .trim()
*   .superRefine(validateSlugOrId)
*   .describe("Issue slug or numeric ID");
* ```
*/
function validateSlugOrId(val, ctx) {
	if (isNumericId(val)) {
		if (val.length > MAX_ID_LENGTH) ctx.addIssue({
			code: zod.z.ZodIssueCode.custom,
			message: `Numeric ID exceeds maximum length of ${MAX_ID_LENGTH} characters`
		});
		return;
	}
	validateSlug(val, ctx);
}

//#endregion
Object.defineProperty(exports, 'isNumericId', {
  enumerable: true,
  get: function () {
    return isNumericId;
  }
});
Object.defineProperty(exports, 'validateSlug', {
  enumerable: true,
  get: function () {
    return validateSlug;
  }
});
Object.defineProperty(exports, 'validateSlugOrId', {
  enumerable: true,
  get: function () {
    return validateSlugOrId;
  }
});
//# sourceMappingURL=slug-validation-DMk8Dyuh.cjs.map