import { parseBooleanWithDefault } from "@open-mercato/shared/lib/boolean";
const CRUDFORM_EXTENSION_TESTS_DISABLED_ENV = "OM_INTEGRATION_CRUDFORM_EXTENSION_TESTS_DISABLED";
function crudFormExtensionTestsDisabled(env = process.env) {
  return parseBooleanWithDefault(env[CRUDFORM_EXTENSION_TESTS_DISABLED_ENV], false);
}
function getCustomFieldValue(record, fieldName) {
  const customValues = record.customValues;
  if (customValues && typeof customValues === "object" && fieldName in customValues) {
    return customValues[fieldName];
  }
  const prefixedUnderscore = record[`cf_${fieldName}`];
  if (prefixedUnderscore !== void 0) return prefixedUnderscore;
  const prefixedColon = record[`cf:${fieldName}`];
  if (prefixedColon !== void 0) return prefixedColon;
  const customFields = record.customFields;
  if (Array.isArray(customFields)) {
    const match = customFields.find((entry) => {
      if (!entry || typeof entry !== "object") return false;
      const candidate = entry;
      return candidate.key === fieldName || candidate.id === fieldName || candidate.name === fieldName;
    });
    if (match && typeof match === "object") {
      return match.value;
    }
  }
  return void 0;
}
export {
  CRUDFORM_EXTENSION_TESTS_DISABLED_ENV,
  crudFormExtensionTestsDisabled,
  getCustomFieldValue
};
//# sourceMappingURL=crudFormFields.js.map
