var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var asset_spec_exports = {};
__export(asset_spec_exports, {
  ASSET_SPEC_CAPABILITY_VALUES: () => ASSET_SPEC_CAPABILITY_VALUES,
  ASSET_SPEC_CONTRACT_MAX_BYTES: () => ASSET_SPEC_CONTRACT_MAX_BYTES,
  ASSET_SPEC_CONTRACT_META_SCHEMA: () => ASSET_SPEC_CONTRACT_META_SCHEMA,
  ASSET_SPEC_LIST_SORT_VALUES: () => ASSET_SPEC_LIST_SORT_VALUES,
  ASSET_SPEC_NAME_REGEX: () => ASSET_SPEC_NAME_REGEX,
  ASSET_SPEC_REFERENCE_CARDINALITY_VALUES: () => ASSET_SPEC_REFERENCE_CARDINALITY_VALUES,
  ASSET_SPEC_REFERENCE_TARGET_KIND_VALUES: () => ASSET_SPEC_REFERENCE_TARGET_KIND_VALUES,
  ASSET_SPEC_ROLE_MODE_VALUES: () => ASSET_SPEC_ROLE_MODE_VALUES,
  ASSET_SPEC_STATUS_VALUES: () => ASSET_SPEC_STATUS_VALUES,
  ASSET_SPEC_VALIDATION_KIND_VALUES: () => ASSET_SPEC_VALIDATION_KIND_VALUES,
  ASSET_SPEC_VISIBILITY_VALUES: () => ASSET_SPEC_VISIBILITY_VALUES,
  ASSET_VALIDATION_STATUS_VALUES: () => ASSET_VALIDATION_STATUS_VALUES,
  formatAssetSpecFamilyRef: () => formatAssetSpecFamilyRef,
  formatAssetSpecVersionRef: () => formatAssetSpecVersionRef,
  isAssetSpecCapability: () => isAssetSpecCapability,
  isAssetSpecStatus: () => isAssetSpecStatus,
  isAssetSpecValidationKind: () => isAssetSpecValidationKind,
  isAssetSpecVisibility: () => isAssetSpecVisibility,
  isAssetValidationStatus: () => isAssetValidationStatus,
  isJsonLikeAssetSpecContentType: () => isJsonLikeAssetSpecContentType,
  isValidAssetSpecName: () => isValidAssetSpecName,
  parseAssetSpecFamilyRef: () => parseAssetSpecFamilyRef,
  parseAssetSpecVersionRef: () => parseAssetSpecVersionRef
});
module.exports = __toCommonJS(asset_spec_exports);
var import_version = require("./version.js");
var import_asset_spec_contract_meta_schema = __toESM(require("./asset-spec-contract-meta-schema.json"));
const ASSET_SPEC_NAME_REGEX = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
const ASSET_SPEC_CONTRACT_MAX_BYTES = 256 * 1024;
const ASSET_SPEC_VISIBILITY_VALUES = ["PRIVATE", "PUBLIC"];
const ASSET_SPEC_VALIDATION_KIND_VALUES = ["NONE", "JSON_SCHEMA"];
const ASSET_VALIDATION_STATUS_VALUES = ["NOT_RUN", "PASSED", "FAILED"];
const ASSET_SPEC_STATUS_VALUES = ["ACTIVE", "DEPRECATED", "RETRACTED"];
const ASSET_SPEC_CAPABILITY_VALUES = ["READ", "WRITE", "EDIT", "PREVIEW", "IMPORT"];
const ASSET_SPEC_ROLE_MODE_VALUES = ["TEXT", "BINARY"];
const ASSET_SPEC_REFERENCE_TARGET_KIND_VALUES = ["ASSET"];
const ASSET_SPEC_REFERENCE_CARDINALITY_VALUES = ["ONE", "MANY"];
const ASSET_SPEC_LIST_SORT_VALUES = ["recent", "assets", "apps", "alpha"];
const ASSET_SPEC_CONTRACT_META_SCHEMA = import_asset_spec_contract_meta_schema.default;
function isAssetSpecVisibility(value) {
  return typeof value === "string" && ASSET_SPEC_VISIBILITY_VALUES.includes(value);
}
function isAssetSpecValidationKind(value) {
  return typeof value === "string" && ASSET_SPEC_VALIDATION_KIND_VALUES.includes(value);
}
function isAssetValidationStatus(value) {
  return typeof value === "string" && ASSET_VALIDATION_STATUS_VALUES.includes(value);
}
function isAssetSpecStatus(value) {
  return typeof value === "string" && ASSET_SPEC_STATUS_VALUES.includes(value);
}
function isAssetSpecCapability(value) {
  return typeof value === "string" && ASSET_SPEC_CAPABILITY_VALUES.includes(value);
}
function isJsonLikeAssetSpecContentType(value) {
  const normalized = value.trim().toLowerCase();
  if (normalized === "application/json") {
    return true;
  }
  return /^application\/[a-z0-9!#$&^_.+-]+\+json$/i.test(normalized);
}
function isValidAssetSpecName(value) {
  return typeof value === "string" && ASSET_SPEC_NAME_REGEX.test(value.trim());
}
function parseAssetSpecFamilyRef(raw) {
  if (typeof raw !== "string") {
    return null;
  }
  const trimmed = raw.trim();
  if (!trimmed.length) {
    return null;
  }
  const match = /^asset-spec:([^/]+)\/([^@]+)$/i.exec(trimmed);
  if (!match) {
    return null;
  }
  const [, rawCreatorUsername, rawName] = match;
  if (!rawCreatorUsername || !rawName) {
    return null;
  }
  const creatorUsername = rawCreatorUsername.trim();
  const name = rawName.trim();
  if (!creatorUsername.length || !name.length) {
    return null;
  }
  return {
    kind: "asset-spec",
    creatorUsername,
    name
  };
}
function parseAssetSpecVersionRef(raw) {
  if (typeof raw !== "string") {
    return null;
  }
  const trimmed = raw.trim();
  if (!trimmed.length) {
    return null;
  }
  const match = /^asset-spec:([^/]+)\/([^@]+)@(.+)$/i.exec(trimmed);
  if (!match) {
    return null;
  }
  const [, rawCreatorUsername, rawName, rawVersion] = match;
  if (!rawCreatorUsername || !rawName || !rawVersion) {
    return null;
  }
  const creatorUsername = rawCreatorUsername.trim();
  const name = rawName.trim();
  const version = rawVersion.trim();
  if (!creatorUsername.length || !name.length || !version.length || !import_version.SEMVER_REGEX.test(version)) {
    return null;
  }
  return {
    kind: "asset-spec",
    creatorUsername,
    name,
    version
  };
}
function formatAssetSpecFamilyRef(ref) {
  return `asset-spec:${ref.creatorUsername}/${ref.name}`;
}
function formatAssetSpecVersionRef(ref) {
  return `asset-spec:${ref.creatorUsername}/${ref.name}@${ref.version}`;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  ASSET_SPEC_CAPABILITY_VALUES,
  ASSET_SPEC_CONTRACT_MAX_BYTES,
  ASSET_SPEC_CONTRACT_META_SCHEMA,
  ASSET_SPEC_LIST_SORT_VALUES,
  ASSET_SPEC_NAME_REGEX,
  ASSET_SPEC_REFERENCE_CARDINALITY_VALUES,
  ASSET_SPEC_REFERENCE_TARGET_KIND_VALUES,
  ASSET_SPEC_ROLE_MODE_VALUES,
  ASSET_SPEC_STATUS_VALUES,
  ASSET_SPEC_VALIDATION_KIND_VALUES,
  ASSET_SPEC_VISIBILITY_VALUES,
  ASSET_VALIDATION_STATUS_VALUES,
  formatAssetSpecFamilyRef,
  formatAssetSpecVersionRef,
  isAssetSpecCapability,
  isAssetSpecStatus,
  isAssetSpecValidationKind,
  isAssetSpecVisibility,
  isAssetValidationStatus,
  isJsonLikeAssetSpecContentType,
  isValidAssetSpecName,
  parseAssetSpecFamilyRef,
  parseAssetSpecVersionRef
});
