// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: app.gainforest.dwc.occurrence
//
// This file was automatically generated from Lexicon schemas.
// Any manual changes will be overwritten on the next regeneration.

#[allow(unused_imports)]
use alloc::collections::BTreeMap;

#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{CowStr, BosStr, DefaultStr, FromStaticStr};

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::collection::{Collection, RecordError};
use jacquard_common::types::string::{AtUri, Cid, Datetime, UriValue};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::types::value::Data;
use jacquard_common::xrpc::XrpcResp;
use jacquard_derive::{IntoStatic, lexicon};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;

#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
/// A biodiversity occurrence record following the Simple Darwin Core standard. Each record represents one occurrence of an organism at a location and time.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
    rename_all = "camelCase",
    rename = "app.gainforest.dwc.occurrence",
    tag = "$type",
    bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Occurrence<S: BosStr = DefaultStr> {
    ///Identifiers (URIs) of media associated with the occurrence. Pipe-delimited for multiple.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub associated_media: Option<S>,
    ///Identifiers of other occurrences associated with this one (e.g., parasite-host). Pipe-delimited.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub associated_occurrences: Option<S>,
    ///Identifiers (URIs) of literature associated with the occurrence. Pipe-delimited for multiple.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub associated_references: Option<S>,
    ///Identifiers (URIs) of genetic sequence information associated with the occurrence. Pipe-delimited for multiple.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub associated_sequences: Option<S>,
    ///Audio evidence (bioacoustics, soundscape, species call, field recording, etc.).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub audio_evidence: Option<Data<S>>,
    ///The specific nature of the data record. Must be one of the Darwin Core class names.
    pub basis_of_record: S,
    ///The behavior shown by the subject at the time of occurrence (e.g., 'foraging', 'nesting', 'roosting').
    #[serde(skip_serializing_if = "Option::is_none")]
    pub behavior: Option<S>,
    ///The full scientific name of the class.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub class: Option<S>,
    ///The name, acronym, or code identifying the collection or dataset from which the record was derived.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub collection_code: Option<S>,
    ///Horizontal distance (meters) from the given coordinates describing the smallest circle containing the whole location.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub coordinate_uncertainty_in_meters: Option<i64>,
    ///The name of the country or major administrative unit.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub country: Option<S>,
    ///The standard code for the country (ISO 3166-1 alpha-2).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub country_code: Option<S>,
    ///The full, unabbreviated name of the next smaller administrative region than stateProvince.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub county: Option<S>,
    ///Timestamp of record creation in the ATProto PDS.
    pub created_at: Datetime,
    ///A description of actions taken to make the data less specific or complete (e.g., 'coordinates rounded to nearest 0.1 degree').
    #[serde(skip_serializing_if = "Option::is_none")]
    pub data_generalizations: Option<S>,
    ///The name identifying the dataset from which the record was derived.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub dataset_name: Option<S>,
    ///The date on which the identification was made. ISO 8601 format.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub date_identified: Option<S>,
    ///The Dublin Core type class that best describes the resource (dc:type).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub dc_type: Option<S>,
    ///Geographic latitude in decimal degrees (WGS84). Positive values are north of the Equator. Range: -90 to 90.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub decimal_latitude: Option<S>,
    ///Geographic longitude in decimal degrees (WGS84). Positive values are east of the Greenwich Meridian. Range: -180 to 180.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub decimal_longitude: Option<S>,
    ///Additional structured data as a valid JSON string (per Simple DwC Section 7.1). Example: '{"iucnStatus":"vulnerable","canopyCover":"85%"}'. Should be flattened to a single line with no non-printing characters.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub dynamic_properties: Option<S>,
    ///The date or date-time (or interval) during which the occurrence was recorded. ISO 8601 format (e.g., '2024-03-15', '2024-03-15T10:30:00Z', '2024-03/2024-06').
    pub event_date: S,
    ///Identifier for the sampling event. Can be used to group occurrences from the same event.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub event_id: Option<S>,
    ///AT-URI reference to an app.gainforest.dwc.event record (for star-schema linkage).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub event_ref: Option<AtUri<S>>,
    ///The time of the event. ISO 8601 format (e.g., '14:30:00', '14:30:00+02:00').
    #[serde(skip_serializing_if = "Option::is_none")]
    pub event_time: Option<S>,
    ///The full scientific name of the family.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub family: Option<S>,
    ///Notes or reference to notes taken in the field about the event.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub field_notes: Option<S>,
    ///GBIF backbone taxonomy key for the identified taxon. Retained for backward compatibility with existing GainForest workflows.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub gbif_taxon_key: Option<S>,
    ///The full scientific name of the genus.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub genus: Option<S>,
    ///The spatial reference system for the coordinates. Recommended: 'EPSG:4326' (WGS84).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub geodetic_datum: Option<S>,
    ///A description of the habitat in which the event occurred (e.g., 'tropical rainforest', 'mangrove swamp', 'montane cloud forest').
    #[serde(skip_serializing_if = "Option::is_none")]
    pub habitat: Option<S>,
    ///A complete list of taxa names terminating at the rank immediately superior to the taxon. Pipe-delimited (e.g., 'Animalia|Chordata|Mammalia|Rodentia|Ctenomyidae|Ctenomys').
    #[serde(skip_serializing_if = "Option::is_none")]
    pub higher_classification: Option<S>,
    ///A brief phrase or standard term qualifying the identification (e.g., 'cf. agrestis', 'aff. agrestis').
    #[serde(skip_serializing_if = "Option::is_none")]
    pub identification_qualifier: Option<S>,
    ///Comments or notes about the identification.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub identification_remarks: Option<S>,
    ///Person(s) who assigned the taxon to the occurrence. Pipe-delimited for multiple.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub identified_by: Option<S>,
    ///Persistent identifier(s) (e.g., ORCID) of the person(s) who identified. Pipe-delimited.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub identified_by_id: Option<S>,
    ///Image evidence (photo, camera trap, drone still, scanned specimen, etc.).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub image_evidence: Option<Data<S>>,
    ///The number of individuals present at the time of the occurrence.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub individual_count: Option<i64>,
    ///A description of what information is withheld from this record and why (e.g., 'coordinates generalized to protect endangered species').
    #[serde(skip_serializing_if = "Option::is_none")]
    pub information_withheld: Option<S>,
    ///The name of the lowest or terminal infraspecific epithet.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub infraspecific_epithet: Option<S>,
    ///The name or acronym of the institution having custody of the object(s) or information in the record.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub institution_code: Option<S>,
    ///The full scientific name of the kingdom (e.g., 'Animalia', 'Plantae', 'Fungi').
    #[serde(skip_serializing_if = "Option::is_none")]
    pub kingdom: Option<S>,
    ///A legal document giving official permission to do something with the record. Recommended: a Creative Commons URI (e.g., 'http://creativecommons.org/licenses/by/4.0/').
    #[serde(skip_serializing_if = "Option::is_none")]
    pub license: Option<S>,
    ///The age class or life stage at the time of occurrence (e.g., 'adult', 'juvenile', 'larva', 'seedling', 'sapling').
    #[serde(skip_serializing_if = "Option::is_none")]
    pub life_stage: Option<S>,
    ///The specific description of the place (e.g., '500m upstream of bridge on Rio Pará').
    #[serde(skip_serializing_if = "Option::is_none")]
    pub locality: Option<S>,
    ///Identifier for the location (e.g., a reference to a named site).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub location_id: Option<S>,
    ///Comments about the location.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub location_remarks: Option<S>,
    ///The greater depth of a range of depth below the local surface (in meters).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub maximum_depth_in_meters: Option<i64>,
    ///The upper limit of the range of elevation (in meters above sea level).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub maximum_elevation_in_meters: Option<i64>,
    ///The lesser depth of a range of depth below the local surface (in meters).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub minimum_depth_in_meters: Option<i64>,
    ///The lower limit of the range of elevation (in meters above sea level).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub minimum_elevation_in_meters: Option<i64>,
    ///The full, unabbreviated name of the next smaller administrative region than county.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub municipality: Option<S>,
    ///The nomenclatural code under which the scientificName is constructed.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub nomenclatural_code: Option<S>,
    ///A globally unique identifier for the occurrence record. Recommended: a persistent URI (e.g., DOI, LSID, or UUID-based URI).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub occurrence_id: Option<S>,
    ///Comments or notes about the occurrence.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub occurrence_remarks: Option<S>,
    ///Statement about the presence or absence of a taxon at a location.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub occurrence_status: Option<S>,
    ///The full scientific name of the order.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub order: Option<S>,
    ///A number or enumeration value for the quantity of organisms (e.g., '27', '12.5', 'many').
    #[serde(skip_serializing_if = "Option::is_none")]
    pub organism_quantity: Option<S>,
    ///The type of quantification system used for organismQuantity (e.g., 'individuals', '% biomass', 'stems/ha').
    #[serde(skip_serializing_if = "Option::is_none")]
    pub organism_quantity_type: Option<S>,
    ///The full scientific name of the phylum or division.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub phylum: Option<S>,
    ///Previous assignments of names to the occurrence. Pipe-delimited.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub previous_identifications: Option<S>,
    ///Person(s) responsible for recording the occurrence in the field. Pipe-delimited for multiple (e.g., 'Jane Smith | John Doe').
    #[serde(skip_serializing_if = "Option::is_none")]
    pub recorded_by: Option<S>,
    ///Persistent identifier(s) (e.g., ORCID) of the person(s) who recorded. Pipe-delimited for multiple.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub recorded_by_id: Option<S>,
    ///A related resource that is referenced, cited, or otherwise pointed to by the record (URL).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub references: Option<UriValue<S>>,
    ///The reproductive condition at the time of occurrence (e.g., 'flowering', 'fruiting', 'budding', 'pregnant').
    #[serde(skip_serializing_if = "Option::is_none")]
    pub reproductive_condition: Option<S>,
    ///Person or organization owning or managing rights over the resource.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub rights_holder: Option<S>,
    ///The amount of effort expended during the event (e.g., '2 trap-nights', '30 minutes', '10 km transect').
    #[serde(skip_serializing_if = "Option::is_none")]
    pub sampling_effort: Option<S>,
    ///The method or protocol used during the event (e.g., 'camera trap', 'point count', 'mist net', '20m x 20m plot survey', 'acoustic monitoring').
    #[serde(skip_serializing_if = "Option::is_none")]
    pub sampling_protocol: Option<S>,
    ///The full scientific name, with authorship and date if known (e.g., 'Centropyge flavicauda Fraser-Brunner 1933').
    pub scientific_name: S,
    ///The authorship information for the scientific name (e.g., 'Fraser-Brunner 1933').
    #[serde(skip_serializing_if = "Option::is_none")]
    pub scientific_name_authorship: Option<S>,
    ///The sex of the biological individual(s).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub sex: Option<S>,
    ///The name of the species epithet of the scientificName.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub specific_epithet: Option<S>,
    ///Spectrogram image showing frequency analysis of audio recording.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub spectrogram_evidence: Option<Data<S>>,
    ///The name of the next smaller administrative region than country.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub state_province: Option<S>,
    ///The taxonomic rank of the most specific name in scientificName.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub taxon_rank: Option<S>,
    ///The status of the use of the scientificName (e.g., 'accepted', 'synonym', 'doubtful').
    #[serde(skip_serializing_if = "Option::is_none")]
    pub taxonomic_status: Option<S>,
    ///The original textual description of the place as provided by the recorder.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub verbatim_locality: Option<S>,
    ///A common or vernacular name for the taxon.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub vernacular_name: Option<S>,
    ///Video evidence (camera trap, drone footage, underwater video, behavioral observation, etc.).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub video_evidence: Option<Data<S>>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Typed wrapper for GetRecord response with this collection's record type.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct OccurrenceGetRecordOutput<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cid: Option<Cid<S>>,
    pub uri: AtUri<S>,
    pub value: Occurrence<S>,
}

impl<S: BosStr> Occurrence<S> {
    pub fn uri(uri: S) -> Result<RecordUri<S, OccurrenceRecord>, UriError> {
        RecordUri::try_from_uri(AtUri::new(uri)?)
    }
}

/// Marker type for deserializing records from this collection.

#[derive(Debug, Serialize, Deserialize)]
pub struct OccurrenceRecord;
impl XrpcResp for OccurrenceRecord {
    const NSID: &'static str = "app.gainforest.dwc.occurrence";
    const ENCODING: &'static str = "application/json";
    type Output<S: BosStr> = OccurrenceGetRecordOutput<S>;
    type Err = RecordError;
}

impl<S: BosStr> From<OccurrenceGetRecordOutput<S>> for Occurrence<S> {
    fn from(output: OccurrenceGetRecordOutput<S>) -> Self {
        output.value
    }
}

impl<S: BosStr> Collection for Occurrence<S> {
    const NSID: &'static str = "app.gainforest.dwc.occurrence";
    type Record = OccurrenceRecord;
}

impl Collection for OccurrenceRecord {
    const NSID: &'static str = "app.gainforest.dwc.occurrence";
    type Record = OccurrenceRecord;
}

impl<S: BosStr> LexiconSchema for Occurrence<S> {
    fn nsid() -> &'static str {
        "app.gainforest.dwc.occurrence"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_gainforest_dwc_occurrence()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.associated_media {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 2048usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("associated_media"),
                        max: 2048usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.associated_occurrences {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 2048usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("associated_occurrences"),
                        max: 2048usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.associated_references {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 2048usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("associated_references"),
                        max: 2048usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.associated_sequences {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 2048usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("associated_sequences"),
                        max: 2048usize,
                        actual: count,
                    });
                }
            }
        }
        {
            let value = &self.basis_of_record;
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 64usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("basis_of_record"),
                        max: 64usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.behavior {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 256usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("behavior"),
                        max: 256usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.class {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 128usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("class"),
                        max: 128usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.collection_code {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 256usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("collection_code"),
                        max: 256usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.coordinate_uncertainty_in_meters {
            if *value < 1i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("coordinate_uncertainty_in_meters"),
                    min: 1i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.country {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 128usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("country"),
                        max: 128usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.country_code {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 2usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("country_code"),
                    max: 2usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.country_code {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) < 2usize {
                return Err(ConstraintError::MinLength {
                    path: ValidationPath::from_field("country_code"),
                    min: 2usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.county {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 256usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("county"),
                        max: 256usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.data_generalizations {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 1024usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("data_generalizations"),
                        max: 1024usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.dataset_name {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 256usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("dataset_name"),
                        max: 256usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.date_identified {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 64usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("date_identified"),
                        max: 64usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.dc_type {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 64usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("dc_type"),
                        max: 64usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.decimal_latitude {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 32usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("decimal_latitude"),
                        max: 32usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.decimal_longitude {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 32usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("decimal_longitude"),
                        max: 32usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.dynamic_properties {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 10000usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("dynamic_properties"),
                        max: 10000usize,
                        actual: count,
                    });
                }
            }
        }
        {
            let value = &self.event_date;
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 64usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("event_date"),
                        max: 64usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.event_id {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 256usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("event_id"),
                        max: 256usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.event_time {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 64usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("event_time"),
                        max: 64usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.family {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 128usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("family"),
                        max: 128usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.field_notes {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 10000usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("field_notes"),
                        max: 10000usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.gbif_taxon_key {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 64usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("gbif_taxon_key"),
                        max: 64usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.genus {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 128usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("genus"),
                        max: 128usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.geodetic_datum {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 64usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("geodetic_datum"),
                        max: 64usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.habitat {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 512usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("habitat"),
                        max: 512usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.higher_classification {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 1024usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("higher_classification"),
                        max: 1024usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.identification_qualifier {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 256usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("identification_qualifier"),
                        max: 256usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.identification_remarks {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 2048usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("identification_remarks"),
                        max: 2048usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.identified_by {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 512usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("identified_by"),
                        max: 512usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.identified_by_id {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 512usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("identified_by_id"),
                        max: 512usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.individual_count {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("individual_count"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.information_withheld {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 1024usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("information_withheld"),
                        max: 1024usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.infraspecific_epithet {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 128usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("infraspecific_epithet"),
                        max: 128usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.institution_code {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 256usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("institution_code"),
                        max: 256usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.kingdom {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 128usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("kingdom"),
                        max: 128usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.license {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 512usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("license"),
                        max: 512usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.life_stage {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 128usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("life_stage"),
                        max: 128usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.locality {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 1024usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("locality"),
                        max: 1024usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.location_id {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 256usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("location_id"),
                        max: 256usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.location_remarks {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 2048usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("location_remarks"),
                        max: 2048usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.maximum_depth_in_meters {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("maximum_depth_in_meters"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.minimum_depth_in_meters {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("minimum_depth_in_meters"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.municipality {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 256usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("municipality"),
                        max: 256usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.nomenclatural_code {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 64usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("nomenclatural_code"),
                        max: 64usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.occurrence_id {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 256usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("occurrence_id"),
                        max: 256usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.occurrence_remarks {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 5000usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("occurrence_remarks"),
                        max: 5000usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.occurrence_status {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 64usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("occurrence_status"),
                        max: 64usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.order {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 128usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("order"),
                        max: 128usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.organism_quantity {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 64usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("organism_quantity"),
                        max: 64usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.organism_quantity_type {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 128usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("organism_quantity_type"),
                        max: 128usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.phylum {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 128usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("phylum"),
                        max: 128usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.previous_identifications {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 2048usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("previous_identifications"),
                        max: 2048usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.recorded_by {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 512usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("recorded_by"),
                        max: 512usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.recorded_by_id {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 512usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("recorded_by_id"),
                        max: 512usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.reproductive_condition {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 128usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("reproductive_condition"),
                        max: 128usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.rights_holder {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 256usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("rights_holder"),
                        max: 256usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.sampling_effort {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 256usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("sampling_effort"),
                        max: 256usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.sampling_protocol {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 1024usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("sampling_protocol"),
                        max: 1024usize,
                        actual: count,
                    });
                }
            }
        }
        {
            let value = &self.scientific_name;
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 512usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("scientific_name"),
                        max: 512usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.scientific_name_authorship {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 256usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("scientific_name_authorship"),
                        max: 256usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.sex {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 64usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("sex"),
                        max: 64usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.specific_epithet {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 128usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("specific_epithet"),
                        max: 128usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.state_province {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 256usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("state_province"),
                        max: 256usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.taxon_rank {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 64usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("taxon_rank"),
                        max: 64usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.taxonomic_status {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 64usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("taxonomic_status"),
                        max: 64usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.verbatim_locality {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 1024usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("verbatim_locality"),
                        max: 1024usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.vernacular_name {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 256usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("vernacular_name"),
                        max: 256usize,
                        actual: count,
                    });
                }
            }
        }
        Ok(())
    }
}

pub mod occurrence_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type BasisOfRecord;
        type CreatedAt;
        type EventDate;
        type ScientificName;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type BasisOfRecord = Unset;
        type CreatedAt = Unset;
        type EventDate = Unset;
        type ScientificName = Unset;
    }
    ///State transition - sets the `basis_of_record` field to Set
    pub struct SetBasisOfRecord<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetBasisOfRecord<St> {}
    impl<St: State> State for SetBasisOfRecord<St> {
        type BasisOfRecord = Set<members::basis_of_record>;
        type CreatedAt = St::CreatedAt;
        type EventDate = St::EventDate;
        type ScientificName = St::ScientificName;
    }
    ///State transition - sets the `created_at` field to Set
    pub struct SetCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetCreatedAt<St> {}
    impl<St: State> State for SetCreatedAt<St> {
        type BasisOfRecord = St::BasisOfRecord;
        type CreatedAt = Set<members::created_at>;
        type EventDate = St::EventDate;
        type ScientificName = St::ScientificName;
    }
    ///State transition - sets the `event_date` field to Set
    pub struct SetEventDate<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetEventDate<St> {}
    impl<St: State> State for SetEventDate<St> {
        type BasisOfRecord = St::BasisOfRecord;
        type CreatedAt = St::CreatedAt;
        type EventDate = Set<members::event_date>;
        type ScientificName = St::ScientificName;
    }
    ///State transition - sets the `scientific_name` field to Set
    pub struct SetScientificName<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetScientificName<St> {}
    impl<St: State> State for SetScientificName<St> {
        type BasisOfRecord = St::BasisOfRecord;
        type CreatedAt = St::CreatedAt;
        type EventDate = St::EventDate;
        type ScientificName = Set<members::scientific_name>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `basis_of_record` field
        pub struct basis_of_record(());
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `event_date` field
        pub struct event_date(());
        ///Marker type for the `scientific_name` field
        pub struct scientific_name(());
    }
}

/// Builder for constructing an instance of this type.
pub struct OccurrenceBuilder<St: occurrence_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<Data<S>>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<i64>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<Datetime>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<AtUri<S>>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<Data<S>>,
        Option<i64>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<i64>,
        Option<i64>,
        Option<i64>,
        Option<i64>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<UriValue<S>>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<Data<S>>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<Data<S>>,
    ),
    _type: PhantomData<fn() -> S>,
}

impl Occurrence<DefaultStr> {
    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
    pub fn new() -> OccurrenceBuilder<occurrence_state::Empty, DefaultStr> {
        OccurrenceBuilder::new()
    }
}

impl<S: BosStr> Occurrence<S> {
    /// Create a new builder for this type
    pub fn builder() -> OccurrenceBuilder<occurrence_state::Empty, S> {
        OccurrenceBuilder::builder()
    }
}

impl OccurrenceBuilder<occurrence_state::Empty, DefaultStr> {
    /// Create a new builder with all fields unset, using the default string type, if needed
    pub fn new() -> Self {
        OccurrenceBuilder {
            _state: PhantomData,
            _fields: (
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
            ),
            _type: PhantomData,
        }
    }
}

impl<S: BosStr> OccurrenceBuilder<occurrence_state::Empty, S> {
    /// Create a new builder with all fields unset
    pub fn builder() -> Self {
        OccurrenceBuilder {
            _state: PhantomData,
            _fields: (
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
                None,
            ),
            _type: PhantomData,
        }
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `associatedMedia` field (optional)
    pub fn associated_media(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `associatedMedia` field to an Option value (optional)
    pub fn maybe_associated_media(mut self, value: Option<S>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `associatedOccurrences` field (optional)
    pub fn associated_occurrences(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `associatedOccurrences` field to an Option value (optional)
    pub fn maybe_associated_occurrences(mut self, value: Option<S>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `associatedReferences` field (optional)
    pub fn associated_references(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `associatedReferences` field to an Option value (optional)
    pub fn maybe_associated_references(mut self, value: Option<S>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `associatedSequences` field (optional)
    pub fn associated_sequences(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `associatedSequences` field to an Option value (optional)
    pub fn maybe_associated_sequences(mut self, value: Option<S>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `audioEvidence` field (optional)
    pub fn audio_evidence(mut self, value: impl Into<Option<Data<S>>>) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `audioEvidence` field to an Option value (optional)
    pub fn maybe_audio_evidence(mut self, value: Option<Data<S>>) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<St, S: BosStr> OccurrenceBuilder<St, S>
where
    St: occurrence_state::State,
    St::BasisOfRecord: occurrence_state::IsUnset,
{
    /// Set the `basisOfRecord` field (required)
    pub fn basis_of_record(
        mut self,
        value: impl Into<S>,
    ) -> OccurrenceBuilder<occurrence_state::SetBasisOfRecord<St>, S> {
        self._fields.5 = Option::Some(value.into());
        OccurrenceBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `behavior` field (optional)
    pub fn behavior(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.6 = value.into();
        self
    }
    /// Set the `behavior` field to an Option value (optional)
    pub fn maybe_behavior(mut self, value: Option<S>) -> Self {
        self._fields.6 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `class` field (optional)
    pub fn class(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.7 = value.into();
        self
    }
    /// Set the `class` field to an Option value (optional)
    pub fn maybe_class(mut self, value: Option<S>) -> Self {
        self._fields.7 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `collectionCode` field (optional)
    pub fn collection_code(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.8 = value.into();
        self
    }
    /// Set the `collectionCode` field to an Option value (optional)
    pub fn maybe_collection_code(mut self, value: Option<S>) -> Self {
        self._fields.8 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `coordinateUncertaintyInMeters` field (optional)
    pub fn coordinate_uncertainty_in_meters(
        mut self,
        value: impl Into<Option<i64>>,
    ) -> Self {
        self._fields.9 = value.into();
        self
    }
    /// Set the `coordinateUncertaintyInMeters` field to an Option value (optional)
    pub fn maybe_coordinate_uncertainty_in_meters(mut self, value: Option<i64>) -> Self {
        self._fields.9 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `country` field (optional)
    pub fn country(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.10 = value.into();
        self
    }
    /// Set the `country` field to an Option value (optional)
    pub fn maybe_country(mut self, value: Option<S>) -> Self {
        self._fields.10 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `countryCode` field (optional)
    pub fn country_code(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.11 = value.into();
        self
    }
    /// Set the `countryCode` field to an Option value (optional)
    pub fn maybe_country_code(mut self, value: Option<S>) -> Self {
        self._fields.11 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `county` field (optional)
    pub fn county(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.12 = value.into();
        self
    }
    /// Set the `county` field to an Option value (optional)
    pub fn maybe_county(mut self, value: Option<S>) -> Self {
        self._fields.12 = value;
        self
    }
}

impl<St, S: BosStr> OccurrenceBuilder<St, S>
where
    St: occurrence_state::State,
    St::CreatedAt: occurrence_state::IsUnset,
{
    /// Set the `createdAt` field (required)
    pub fn created_at(
        mut self,
        value: impl Into<Datetime>,
    ) -> OccurrenceBuilder<occurrence_state::SetCreatedAt<St>, S> {
        self._fields.13 = Option::Some(value.into());
        OccurrenceBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `dataGeneralizations` field (optional)
    pub fn data_generalizations(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.14 = value.into();
        self
    }
    /// Set the `dataGeneralizations` field to an Option value (optional)
    pub fn maybe_data_generalizations(mut self, value: Option<S>) -> Self {
        self._fields.14 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `datasetName` field (optional)
    pub fn dataset_name(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.15 = value.into();
        self
    }
    /// Set the `datasetName` field to an Option value (optional)
    pub fn maybe_dataset_name(mut self, value: Option<S>) -> Self {
        self._fields.15 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `dateIdentified` field (optional)
    pub fn date_identified(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.16 = value.into();
        self
    }
    /// Set the `dateIdentified` field to an Option value (optional)
    pub fn maybe_date_identified(mut self, value: Option<S>) -> Self {
        self._fields.16 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `dcType` field (optional)
    pub fn dc_type(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.17 = value.into();
        self
    }
    /// Set the `dcType` field to an Option value (optional)
    pub fn maybe_dc_type(mut self, value: Option<S>) -> Self {
        self._fields.17 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `decimalLatitude` field (optional)
    pub fn decimal_latitude(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.18 = value.into();
        self
    }
    /// Set the `decimalLatitude` field to an Option value (optional)
    pub fn maybe_decimal_latitude(mut self, value: Option<S>) -> Self {
        self._fields.18 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `decimalLongitude` field (optional)
    pub fn decimal_longitude(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.19 = value.into();
        self
    }
    /// Set the `decimalLongitude` field to an Option value (optional)
    pub fn maybe_decimal_longitude(mut self, value: Option<S>) -> Self {
        self._fields.19 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `dynamicProperties` field (optional)
    pub fn dynamic_properties(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.20 = value.into();
        self
    }
    /// Set the `dynamicProperties` field to an Option value (optional)
    pub fn maybe_dynamic_properties(mut self, value: Option<S>) -> Self {
        self._fields.20 = value;
        self
    }
}

impl<St, S: BosStr> OccurrenceBuilder<St, S>
where
    St: occurrence_state::State,
    St::EventDate: occurrence_state::IsUnset,
{
    /// Set the `eventDate` field (required)
    pub fn event_date(
        mut self,
        value: impl Into<S>,
    ) -> OccurrenceBuilder<occurrence_state::SetEventDate<St>, S> {
        self._fields.21 = Option::Some(value.into());
        OccurrenceBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `eventID` field (optional)
    pub fn event_id(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.22 = value.into();
        self
    }
    /// Set the `eventID` field to an Option value (optional)
    pub fn maybe_event_id(mut self, value: Option<S>) -> Self {
        self._fields.22 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `eventRef` field (optional)
    pub fn event_ref(mut self, value: impl Into<Option<AtUri<S>>>) -> Self {
        self._fields.23 = value.into();
        self
    }
    /// Set the `eventRef` field to an Option value (optional)
    pub fn maybe_event_ref(mut self, value: Option<AtUri<S>>) -> Self {
        self._fields.23 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `eventTime` field (optional)
    pub fn event_time(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.24 = value.into();
        self
    }
    /// Set the `eventTime` field to an Option value (optional)
    pub fn maybe_event_time(mut self, value: Option<S>) -> Self {
        self._fields.24 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `family` field (optional)
    pub fn family(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.25 = value.into();
        self
    }
    /// Set the `family` field to an Option value (optional)
    pub fn maybe_family(mut self, value: Option<S>) -> Self {
        self._fields.25 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `fieldNotes` field (optional)
    pub fn field_notes(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.26 = value.into();
        self
    }
    /// Set the `fieldNotes` field to an Option value (optional)
    pub fn maybe_field_notes(mut self, value: Option<S>) -> Self {
        self._fields.26 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `gbifTaxonKey` field (optional)
    pub fn gbif_taxon_key(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.27 = value.into();
        self
    }
    /// Set the `gbifTaxonKey` field to an Option value (optional)
    pub fn maybe_gbif_taxon_key(mut self, value: Option<S>) -> Self {
        self._fields.27 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `genus` field (optional)
    pub fn genus(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.28 = value.into();
        self
    }
    /// Set the `genus` field to an Option value (optional)
    pub fn maybe_genus(mut self, value: Option<S>) -> Self {
        self._fields.28 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `geodeticDatum` field (optional)
    pub fn geodetic_datum(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.29 = value.into();
        self
    }
    /// Set the `geodeticDatum` field to an Option value (optional)
    pub fn maybe_geodetic_datum(mut self, value: Option<S>) -> Self {
        self._fields.29 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `habitat` field (optional)
    pub fn habitat(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.30 = value.into();
        self
    }
    /// Set the `habitat` field to an Option value (optional)
    pub fn maybe_habitat(mut self, value: Option<S>) -> Self {
        self._fields.30 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `higherClassification` field (optional)
    pub fn higher_classification(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.31 = value.into();
        self
    }
    /// Set the `higherClassification` field to an Option value (optional)
    pub fn maybe_higher_classification(mut self, value: Option<S>) -> Self {
        self._fields.31 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `identificationQualifier` field (optional)
    pub fn identification_qualifier(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.32 = value.into();
        self
    }
    /// Set the `identificationQualifier` field to an Option value (optional)
    pub fn maybe_identification_qualifier(mut self, value: Option<S>) -> Self {
        self._fields.32 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `identificationRemarks` field (optional)
    pub fn identification_remarks(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.33 = value.into();
        self
    }
    /// Set the `identificationRemarks` field to an Option value (optional)
    pub fn maybe_identification_remarks(mut self, value: Option<S>) -> Self {
        self._fields.33 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `identifiedBy` field (optional)
    pub fn identified_by(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.34 = value.into();
        self
    }
    /// Set the `identifiedBy` field to an Option value (optional)
    pub fn maybe_identified_by(mut self, value: Option<S>) -> Self {
        self._fields.34 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `identifiedByID` field (optional)
    pub fn identified_by_id(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.35 = value.into();
        self
    }
    /// Set the `identifiedByID` field to an Option value (optional)
    pub fn maybe_identified_by_id(mut self, value: Option<S>) -> Self {
        self._fields.35 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `imageEvidence` field (optional)
    pub fn image_evidence(mut self, value: impl Into<Option<Data<S>>>) -> Self {
        self._fields.36 = value.into();
        self
    }
    /// Set the `imageEvidence` field to an Option value (optional)
    pub fn maybe_image_evidence(mut self, value: Option<Data<S>>) -> Self {
        self._fields.36 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `individualCount` field (optional)
    pub fn individual_count(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.37 = value.into();
        self
    }
    /// Set the `individualCount` field to an Option value (optional)
    pub fn maybe_individual_count(mut self, value: Option<i64>) -> Self {
        self._fields.37 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `informationWithheld` field (optional)
    pub fn information_withheld(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.38 = value.into();
        self
    }
    /// Set the `informationWithheld` field to an Option value (optional)
    pub fn maybe_information_withheld(mut self, value: Option<S>) -> Self {
        self._fields.38 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `infraspecificEpithet` field (optional)
    pub fn infraspecific_epithet(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.39 = value.into();
        self
    }
    /// Set the `infraspecificEpithet` field to an Option value (optional)
    pub fn maybe_infraspecific_epithet(mut self, value: Option<S>) -> Self {
        self._fields.39 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `institutionCode` field (optional)
    pub fn institution_code(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.40 = value.into();
        self
    }
    /// Set the `institutionCode` field to an Option value (optional)
    pub fn maybe_institution_code(mut self, value: Option<S>) -> Self {
        self._fields.40 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `kingdom` field (optional)
    pub fn kingdom(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.41 = value.into();
        self
    }
    /// Set the `kingdom` field to an Option value (optional)
    pub fn maybe_kingdom(mut self, value: Option<S>) -> Self {
        self._fields.41 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `license` field (optional)
    pub fn license(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.42 = value.into();
        self
    }
    /// Set the `license` field to an Option value (optional)
    pub fn maybe_license(mut self, value: Option<S>) -> Self {
        self._fields.42 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `lifeStage` field (optional)
    pub fn life_stage(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.43 = value.into();
        self
    }
    /// Set the `lifeStage` field to an Option value (optional)
    pub fn maybe_life_stage(mut self, value: Option<S>) -> Self {
        self._fields.43 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `locality` field (optional)
    pub fn locality(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.44 = value.into();
        self
    }
    /// Set the `locality` field to an Option value (optional)
    pub fn maybe_locality(mut self, value: Option<S>) -> Self {
        self._fields.44 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `locationID` field (optional)
    pub fn location_id(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.45 = value.into();
        self
    }
    /// Set the `locationID` field to an Option value (optional)
    pub fn maybe_location_id(mut self, value: Option<S>) -> Self {
        self._fields.45 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `locationRemarks` field (optional)
    pub fn location_remarks(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.46 = value.into();
        self
    }
    /// Set the `locationRemarks` field to an Option value (optional)
    pub fn maybe_location_remarks(mut self, value: Option<S>) -> Self {
        self._fields.46 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `maximumDepthInMeters` field (optional)
    pub fn maximum_depth_in_meters(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.47 = value.into();
        self
    }
    /// Set the `maximumDepthInMeters` field to an Option value (optional)
    pub fn maybe_maximum_depth_in_meters(mut self, value: Option<i64>) -> Self {
        self._fields.47 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `maximumElevationInMeters` field (optional)
    pub fn maximum_elevation_in_meters(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.48 = value.into();
        self
    }
    /// Set the `maximumElevationInMeters` field to an Option value (optional)
    pub fn maybe_maximum_elevation_in_meters(mut self, value: Option<i64>) -> Self {
        self._fields.48 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `minimumDepthInMeters` field (optional)
    pub fn minimum_depth_in_meters(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.49 = value.into();
        self
    }
    /// Set the `minimumDepthInMeters` field to an Option value (optional)
    pub fn maybe_minimum_depth_in_meters(mut self, value: Option<i64>) -> Self {
        self._fields.49 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `minimumElevationInMeters` field (optional)
    pub fn minimum_elevation_in_meters(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.50 = value.into();
        self
    }
    /// Set the `minimumElevationInMeters` field to an Option value (optional)
    pub fn maybe_minimum_elevation_in_meters(mut self, value: Option<i64>) -> Self {
        self._fields.50 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `municipality` field (optional)
    pub fn municipality(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.51 = value.into();
        self
    }
    /// Set the `municipality` field to an Option value (optional)
    pub fn maybe_municipality(mut self, value: Option<S>) -> Self {
        self._fields.51 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `nomenclaturalCode` field (optional)
    pub fn nomenclatural_code(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.52 = value.into();
        self
    }
    /// Set the `nomenclaturalCode` field to an Option value (optional)
    pub fn maybe_nomenclatural_code(mut self, value: Option<S>) -> Self {
        self._fields.52 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `occurrenceID` field (optional)
    pub fn occurrence_id(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.53 = value.into();
        self
    }
    /// Set the `occurrenceID` field to an Option value (optional)
    pub fn maybe_occurrence_id(mut self, value: Option<S>) -> Self {
        self._fields.53 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `occurrenceRemarks` field (optional)
    pub fn occurrence_remarks(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.54 = value.into();
        self
    }
    /// Set the `occurrenceRemarks` field to an Option value (optional)
    pub fn maybe_occurrence_remarks(mut self, value: Option<S>) -> Self {
        self._fields.54 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `occurrenceStatus` field (optional)
    pub fn occurrence_status(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.55 = value.into();
        self
    }
    /// Set the `occurrenceStatus` field to an Option value (optional)
    pub fn maybe_occurrence_status(mut self, value: Option<S>) -> Self {
        self._fields.55 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `order` field (optional)
    pub fn order(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.56 = value.into();
        self
    }
    /// Set the `order` field to an Option value (optional)
    pub fn maybe_order(mut self, value: Option<S>) -> Self {
        self._fields.56 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `organismQuantity` field (optional)
    pub fn organism_quantity(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.57 = value.into();
        self
    }
    /// Set the `organismQuantity` field to an Option value (optional)
    pub fn maybe_organism_quantity(mut self, value: Option<S>) -> Self {
        self._fields.57 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `organismQuantityType` field (optional)
    pub fn organism_quantity_type(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.58 = value.into();
        self
    }
    /// Set the `organismQuantityType` field to an Option value (optional)
    pub fn maybe_organism_quantity_type(mut self, value: Option<S>) -> Self {
        self._fields.58 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `phylum` field (optional)
    pub fn phylum(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.59 = value.into();
        self
    }
    /// Set the `phylum` field to an Option value (optional)
    pub fn maybe_phylum(mut self, value: Option<S>) -> Self {
        self._fields.59 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `previousIdentifications` field (optional)
    pub fn previous_identifications(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.60 = value.into();
        self
    }
    /// Set the `previousIdentifications` field to an Option value (optional)
    pub fn maybe_previous_identifications(mut self, value: Option<S>) -> Self {
        self._fields.60 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `recordedBy` field (optional)
    pub fn recorded_by(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.61 = value.into();
        self
    }
    /// Set the `recordedBy` field to an Option value (optional)
    pub fn maybe_recorded_by(mut self, value: Option<S>) -> Self {
        self._fields.61 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `recordedByID` field (optional)
    pub fn recorded_by_id(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.62 = value.into();
        self
    }
    /// Set the `recordedByID` field to an Option value (optional)
    pub fn maybe_recorded_by_id(mut self, value: Option<S>) -> Self {
        self._fields.62 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `references` field (optional)
    pub fn references(mut self, value: impl Into<Option<UriValue<S>>>) -> Self {
        self._fields.63 = value.into();
        self
    }
    /// Set the `references` field to an Option value (optional)
    pub fn maybe_references(mut self, value: Option<UriValue<S>>) -> Self {
        self._fields.63 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `reproductiveCondition` field (optional)
    pub fn reproductive_condition(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.64 = value.into();
        self
    }
    /// Set the `reproductiveCondition` field to an Option value (optional)
    pub fn maybe_reproductive_condition(mut self, value: Option<S>) -> Self {
        self._fields.64 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `rightsHolder` field (optional)
    pub fn rights_holder(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.65 = value.into();
        self
    }
    /// Set the `rightsHolder` field to an Option value (optional)
    pub fn maybe_rights_holder(mut self, value: Option<S>) -> Self {
        self._fields.65 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `samplingEffort` field (optional)
    pub fn sampling_effort(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.66 = value.into();
        self
    }
    /// Set the `samplingEffort` field to an Option value (optional)
    pub fn maybe_sampling_effort(mut self, value: Option<S>) -> Self {
        self._fields.66 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `samplingProtocol` field (optional)
    pub fn sampling_protocol(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.67 = value.into();
        self
    }
    /// Set the `samplingProtocol` field to an Option value (optional)
    pub fn maybe_sampling_protocol(mut self, value: Option<S>) -> Self {
        self._fields.67 = value;
        self
    }
}

impl<St, S: BosStr> OccurrenceBuilder<St, S>
where
    St: occurrence_state::State,
    St::ScientificName: occurrence_state::IsUnset,
{
    /// Set the `scientificName` field (required)
    pub fn scientific_name(
        mut self,
        value: impl Into<S>,
    ) -> OccurrenceBuilder<occurrence_state::SetScientificName<St>, S> {
        self._fields.68 = Option::Some(value.into());
        OccurrenceBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `scientificNameAuthorship` field (optional)
    pub fn scientific_name_authorship(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.69 = value.into();
        self
    }
    /// Set the `scientificNameAuthorship` field to an Option value (optional)
    pub fn maybe_scientific_name_authorship(mut self, value: Option<S>) -> Self {
        self._fields.69 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `sex` field (optional)
    pub fn sex(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.70 = value.into();
        self
    }
    /// Set the `sex` field to an Option value (optional)
    pub fn maybe_sex(mut self, value: Option<S>) -> Self {
        self._fields.70 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `specificEpithet` field (optional)
    pub fn specific_epithet(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.71 = value.into();
        self
    }
    /// Set the `specificEpithet` field to an Option value (optional)
    pub fn maybe_specific_epithet(mut self, value: Option<S>) -> Self {
        self._fields.71 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `spectrogramEvidence` field (optional)
    pub fn spectrogram_evidence(mut self, value: impl Into<Option<Data<S>>>) -> Self {
        self._fields.72 = value.into();
        self
    }
    /// Set the `spectrogramEvidence` field to an Option value (optional)
    pub fn maybe_spectrogram_evidence(mut self, value: Option<Data<S>>) -> Self {
        self._fields.72 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `stateProvince` field (optional)
    pub fn state_province(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.73 = value.into();
        self
    }
    /// Set the `stateProvince` field to an Option value (optional)
    pub fn maybe_state_province(mut self, value: Option<S>) -> Self {
        self._fields.73 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `taxonRank` field (optional)
    pub fn taxon_rank(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.74 = value.into();
        self
    }
    /// Set the `taxonRank` field to an Option value (optional)
    pub fn maybe_taxon_rank(mut self, value: Option<S>) -> Self {
        self._fields.74 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `taxonomicStatus` field (optional)
    pub fn taxonomic_status(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.75 = value.into();
        self
    }
    /// Set the `taxonomicStatus` field to an Option value (optional)
    pub fn maybe_taxonomic_status(mut self, value: Option<S>) -> Self {
        self._fields.75 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `verbatimLocality` field (optional)
    pub fn verbatim_locality(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.76 = value.into();
        self
    }
    /// Set the `verbatimLocality` field to an Option value (optional)
    pub fn maybe_verbatim_locality(mut self, value: Option<S>) -> Self {
        self._fields.76 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `vernacularName` field (optional)
    pub fn vernacular_name(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.77 = value.into();
        self
    }
    /// Set the `vernacularName` field to an Option value (optional)
    pub fn maybe_vernacular_name(mut self, value: Option<S>) -> Self {
        self._fields.77 = value;
        self
    }
}

impl<St: occurrence_state::State, S: BosStr> OccurrenceBuilder<St, S> {
    /// Set the `videoEvidence` field (optional)
    pub fn video_evidence(mut self, value: impl Into<Option<Data<S>>>) -> Self {
        self._fields.78 = value.into();
        self
    }
    /// Set the `videoEvidence` field to an Option value (optional)
    pub fn maybe_video_evidence(mut self, value: Option<Data<S>>) -> Self {
        self._fields.78 = value;
        self
    }
}

impl<St, S: BosStr> OccurrenceBuilder<St, S>
where
    St: occurrence_state::State,
    St::BasisOfRecord: occurrence_state::IsSet,
    St::CreatedAt: occurrence_state::IsSet,
    St::EventDate: occurrence_state::IsSet,
    St::ScientificName: occurrence_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Occurrence<S> {
        Occurrence {
            associated_media: self._fields.0,
            associated_occurrences: self._fields.1,
            associated_references: self._fields.2,
            associated_sequences: self._fields.3,
            audio_evidence: self._fields.4,
            basis_of_record: self._fields.5.unwrap(),
            behavior: self._fields.6,
            class: self._fields.7,
            collection_code: self._fields.8,
            coordinate_uncertainty_in_meters: self._fields.9,
            country: self._fields.10,
            country_code: self._fields.11,
            county: self._fields.12,
            created_at: self._fields.13.unwrap(),
            data_generalizations: self._fields.14,
            dataset_name: self._fields.15,
            date_identified: self._fields.16,
            dc_type: self._fields.17,
            decimal_latitude: self._fields.18,
            decimal_longitude: self._fields.19,
            dynamic_properties: self._fields.20,
            event_date: self._fields.21.unwrap(),
            event_id: self._fields.22,
            event_ref: self._fields.23,
            event_time: self._fields.24,
            family: self._fields.25,
            field_notes: self._fields.26,
            gbif_taxon_key: self._fields.27,
            genus: self._fields.28,
            geodetic_datum: self._fields.29,
            habitat: self._fields.30,
            higher_classification: self._fields.31,
            identification_qualifier: self._fields.32,
            identification_remarks: self._fields.33,
            identified_by: self._fields.34,
            identified_by_id: self._fields.35,
            image_evidence: self._fields.36,
            individual_count: self._fields.37,
            information_withheld: self._fields.38,
            infraspecific_epithet: self._fields.39,
            institution_code: self._fields.40,
            kingdom: self._fields.41,
            license: self._fields.42,
            life_stage: self._fields.43,
            locality: self._fields.44,
            location_id: self._fields.45,
            location_remarks: self._fields.46,
            maximum_depth_in_meters: self._fields.47,
            maximum_elevation_in_meters: self._fields.48,
            minimum_depth_in_meters: self._fields.49,
            minimum_elevation_in_meters: self._fields.50,
            municipality: self._fields.51,
            nomenclatural_code: self._fields.52,
            occurrence_id: self._fields.53,
            occurrence_remarks: self._fields.54,
            occurrence_status: self._fields.55,
            order: self._fields.56,
            organism_quantity: self._fields.57,
            organism_quantity_type: self._fields.58,
            phylum: self._fields.59,
            previous_identifications: self._fields.60,
            recorded_by: self._fields.61,
            recorded_by_id: self._fields.62,
            references: self._fields.63,
            reproductive_condition: self._fields.64,
            rights_holder: self._fields.65,
            sampling_effort: self._fields.66,
            sampling_protocol: self._fields.67,
            scientific_name: self._fields.68.unwrap(),
            scientific_name_authorship: self._fields.69,
            sex: self._fields.70,
            specific_epithet: self._fields.71,
            spectrogram_evidence: self._fields.72,
            state_province: self._fields.73,
            taxon_rank: self._fields.74,
            taxonomic_status: self._fields.75,
            verbatim_locality: self._fields.76,
            vernacular_name: self._fields.77,
            video_evidence: self._fields.78,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> Occurrence<S> {
        Occurrence {
            associated_media: self._fields.0,
            associated_occurrences: self._fields.1,
            associated_references: self._fields.2,
            associated_sequences: self._fields.3,
            audio_evidence: self._fields.4,
            basis_of_record: self._fields.5.unwrap(),
            behavior: self._fields.6,
            class: self._fields.7,
            collection_code: self._fields.8,
            coordinate_uncertainty_in_meters: self._fields.9,
            country: self._fields.10,
            country_code: self._fields.11,
            county: self._fields.12,
            created_at: self._fields.13.unwrap(),
            data_generalizations: self._fields.14,
            dataset_name: self._fields.15,
            date_identified: self._fields.16,
            dc_type: self._fields.17,
            decimal_latitude: self._fields.18,
            decimal_longitude: self._fields.19,
            dynamic_properties: self._fields.20,
            event_date: self._fields.21.unwrap(),
            event_id: self._fields.22,
            event_ref: self._fields.23,
            event_time: self._fields.24,
            family: self._fields.25,
            field_notes: self._fields.26,
            gbif_taxon_key: self._fields.27,
            genus: self._fields.28,
            geodetic_datum: self._fields.29,
            habitat: self._fields.30,
            higher_classification: self._fields.31,
            identification_qualifier: self._fields.32,
            identification_remarks: self._fields.33,
            identified_by: self._fields.34,
            identified_by_id: self._fields.35,
            image_evidence: self._fields.36,
            individual_count: self._fields.37,
            information_withheld: self._fields.38,
            infraspecific_epithet: self._fields.39,
            institution_code: self._fields.40,
            kingdom: self._fields.41,
            license: self._fields.42,
            life_stage: self._fields.43,
            locality: self._fields.44,
            location_id: self._fields.45,
            location_remarks: self._fields.46,
            maximum_depth_in_meters: self._fields.47,
            maximum_elevation_in_meters: self._fields.48,
            minimum_depth_in_meters: self._fields.49,
            minimum_elevation_in_meters: self._fields.50,
            municipality: self._fields.51,
            nomenclatural_code: self._fields.52,
            occurrence_id: self._fields.53,
            occurrence_remarks: self._fields.54,
            occurrence_status: self._fields.55,
            order: self._fields.56,
            organism_quantity: self._fields.57,
            organism_quantity_type: self._fields.58,
            phylum: self._fields.59,
            previous_identifications: self._fields.60,
            recorded_by: self._fields.61,
            recorded_by_id: self._fields.62,
            references: self._fields.63,
            reproductive_condition: self._fields.64,
            rights_holder: self._fields.65,
            sampling_effort: self._fields.66,
            sampling_protocol: self._fields.67,
            scientific_name: self._fields.68.unwrap(),
            scientific_name_authorship: self._fields.69,
            sex: self._fields.70,
            specific_epithet: self._fields.71,
            spectrogram_evidence: self._fields.72,
            state_province: self._fields.73,
            taxon_rank: self._fields.74,
            taxonomic_status: self._fields.75,
            verbatim_locality: self._fields.76,
            vernacular_name: self._fields.77,
            video_evidence: self._fields.78,
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_app_gainforest_dwc_occurrence() -> LexiconDoc<'static> {
    #[allow(unused_imports)]
    use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
    use jacquard_lexicon::lexicon::*;
    use alloc::collections::BTreeMap;
    LexiconDoc {
        lexicon: Lexicon::Lexicon1,
        id: CowStr::new_static("app.gainforest.dwc.occurrence"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Record(LexRecord {
                    description: Some(
                        CowStr::new_static(
                            "A biodiversity occurrence record following the Simple Darwin Core standard. Each record represents one occurrence of an organism at a location and time.",
                        ),
                    ),
                    key: Some(CowStr::new_static("tid")),
                    record: LexRecordRecord::Object(LexObject {
                        required: Some(
                            vec![
                                SmolStr::new_static("basisOfRecord"),
                                SmolStr::new_static("scientificName"),
                                SmolStr::new_static("eventDate"),
                                SmolStr::new_static("createdAt")
                            ],
                        ),
                        properties: {
                            #[allow(unused_mut)]
                            let mut map = BTreeMap::new();
                            map.insert(
                                SmolStr::new_static("associatedMedia"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Identifiers (URIs) of media associated with the occurrence. Pipe-delimited for multiple.",
                                        ),
                                    ),
                                    max_graphemes: Some(2048usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("associatedOccurrences"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Identifiers of other occurrences associated with this one (e.g., parasite-host). Pipe-delimited.",
                                        ),
                                    ),
                                    max_graphemes: Some(2048usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("associatedReferences"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Identifiers (URIs) of literature associated with the occurrence. Pipe-delimited for multiple.",
                                        ),
                                    ),
                                    max_graphemes: Some(2048usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("associatedSequences"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Identifiers (URIs) of genetic sequence information associated with the occurrence. Pipe-delimited for multiple.",
                                        ),
                                    ),
                                    max_graphemes: Some(2048usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("audioEvidence"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static(
                                        "app.gainforest.common.defs#audio",
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("basisOfRecord"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The specific nature of the data record. Must be one of the Darwin Core class names.",
                                        ),
                                    ),
                                    max_graphemes: Some(64usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("behavior"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The behavior shown by the subject at the time of occurrence (e.g., 'foraging', 'nesting', 'roosting').",
                                        ),
                                    ),
                                    max_graphemes: Some(256usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("class"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("The full scientific name of the class."),
                                    ),
                                    max_graphemes: Some(128usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("collectionCode"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The name, acronym, or code identifying the collection or dataset from which the record was derived.",
                                        ),
                                    ),
                                    max_graphemes: Some(256usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("coordinateUncertaintyInMeters"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(1i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("country"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The name of the country or major administrative unit.",
                                        ),
                                    ),
                                    max_graphemes: Some(128usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("countryCode"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The standard code for the country (ISO 3166-1 alpha-2).",
                                        ),
                                    ),
                                    min_length: Some(2usize),
                                    max_length: Some(2usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("county"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The full, unabbreviated name of the next smaller administrative region than stateProvince.",
                                        ),
                                    ),
                                    max_graphemes: Some(256usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("createdAt"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Timestamp of record creation in the ATProto PDS.",
                                        ),
                                    ),
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("dataGeneralizations"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "A description of actions taken to make the data less specific or complete (e.g., 'coordinates rounded to nearest 0.1 degree').",
                                        ),
                                    ),
                                    max_graphemes: Some(1024usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("datasetName"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The name identifying the dataset from which the record was derived.",
                                        ),
                                    ),
                                    max_graphemes: Some(256usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("dateIdentified"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The date on which the identification was made. ISO 8601 format.",
                                        ),
                                    ),
                                    max_graphemes: Some(64usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("dcType"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The Dublin Core type class that best describes the resource (dc:type).",
                                        ),
                                    ),
                                    max_graphemes: Some(64usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("decimalLatitude"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Geographic latitude in decimal degrees (WGS84). Positive values are north of the Equator. Range: -90 to 90.",
                                        ),
                                    ),
                                    max_graphemes: Some(32usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("decimalLongitude"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Geographic longitude in decimal degrees (WGS84). Positive values are east of the Greenwich Meridian. Range: -180 to 180.",
                                        ),
                                    ),
                                    max_graphemes: Some(32usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("dynamicProperties"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Additional structured data as a valid JSON string (per Simple DwC Section 7.1). Example: '{\"iucnStatus\":\"vulnerable\",\"canopyCover\":\"85%\"}'. Should be flattened to a single line with no non-printing characters.",
                                        ),
                                    ),
                                    max_graphemes: Some(10000usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("eventDate"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The date or date-time (or interval) during which the occurrence was recorded. ISO 8601 format (e.g., '2024-03-15', '2024-03-15T10:30:00Z', '2024-03/2024-06').",
                                        ),
                                    ),
                                    max_graphemes: Some(64usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("eventID"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Identifier for the sampling event. Can be used to group occurrences from the same event.",
                                        ),
                                    ),
                                    max_graphemes: Some(256usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("eventRef"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "AT-URI reference to an app.gainforest.dwc.event record (for star-schema linkage).",
                                        ),
                                    ),
                                    format: Some(LexStringFormat::AtUri),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("eventTime"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The time of the event. ISO 8601 format (e.g., '14:30:00', '14:30:00+02:00').",
                                        ),
                                    ),
                                    max_graphemes: Some(64usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("family"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The full scientific name of the family.",
                                        ),
                                    ),
                                    max_graphemes: Some(128usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("fieldNotes"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Notes or reference to notes taken in the field about the event.",
                                        ),
                                    ),
                                    max_graphemes: Some(10000usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("gbifTaxonKey"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "GBIF backbone taxonomy key for the identified taxon. Retained for backward compatibility with existing GainForest workflows.",
                                        ),
                                    ),
                                    max_graphemes: Some(64usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("genus"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("The full scientific name of the genus."),
                                    ),
                                    max_graphemes: Some(128usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("geodeticDatum"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The spatial reference system for the coordinates. Recommended: 'EPSG:4326' (WGS84).",
                                        ),
                                    ),
                                    max_graphemes: Some(64usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("habitat"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "A description of the habitat in which the event occurred (e.g., 'tropical rainforest', 'mangrove swamp', 'montane cloud forest').",
                                        ),
                                    ),
                                    max_graphemes: Some(512usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("higherClassification"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "A complete list of taxa names terminating at the rank immediately superior to the taxon. Pipe-delimited (e.g., 'Animalia|Chordata|Mammalia|Rodentia|Ctenomyidae|Ctenomys').",
                                        ),
                                    ),
                                    max_graphemes: Some(1024usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("identificationQualifier"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "A brief phrase or standard term qualifying the identification (e.g., 'cf. agrestis', 'aff. agrestis').",
                                        ),
                                    ),
                                    max_graphemes: Some(256usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("identificationRemarks"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Comments or notes about the identification.",
                                        ),
                                    ),
                                    max_graphemes: Some(2048usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("identifiedBy"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Person(s) who assigned the taxon to the occurrence. Pipe-delimited for multiple.",
                                        ),
                                    ),
                                    max_graphemes: Some(512usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("identifiedByID"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Persistent identifier(s) (e.g., ORCID) of the person(s) who identified. Pipe-delimited.",
                                        ),
                                    ),
                                    max_graphemes: Some(512usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("imageEvidence"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static(
                                        "app.gainforest.common.defs#image",
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("individualCount"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(0i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("informationWithheld"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "A description of what information is withheld from this record and why (e.g., 'coordinates generalized to protect endangered species').",
                                        ),
                                    ),
                                    max_graphemes: Some(1024usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("infraspecificEpithet"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The name of the lowest or terminal infraspecific epithet.",
                                        ),
                                    ),
                                    max_graphemes: Some(128usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("institutionCode"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The name or acronym of the institution having custody of the object(s) or information in the record.",
                                        ),
                                    ),
                                    max_graphemes: Some(256usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("kingdom"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The full scientific name of the kingdom (e.g., 'Animalia', 'Plantae', 'Fungi').",
                                        ),
                                    ),
                                    max_graphemes: Some(128usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("license"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "A legal document giving official permission to do something with the record. Recommended: a Creative Commons URI (e.g., 'http://creativecommons.org/licenses/by/4.0/').",
                                        ),
                                    ),
                                    max_graphemes: Some(512usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("lifeStage"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The age class or life stage at the time of occurrence (e.g., 'adult', 'juvenile', 'larva', 'seedling', 'sapling').",
                                        ),
                                    ),
                                    max_graphemes: Some(128usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("locality"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The specific description of the place (e.g., '500m upstream of bridge on Rio Pará').",
                                        ),
                                    ),
                                    max_graphemes: Some(1024usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("locationID"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Identifier for the location (e.g., a reference to a named site).",
                                        ),
                                    ),
                                    max_graphemes: Some(256usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("locationRemarks"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("Comments about the location."),
                                    ),
                                    max_graphemes: Some(2048usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("maximumDepthInMeters"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(0i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("maximumElevationInMeters"),
                                LexObjectProperty::Integer(LexInteger {
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("minimumDepthInMeters"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(0i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("minimumElevationInMeters"),
                                LexObjectProperty::Integer(LexInteger {
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("municipality"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The full, unabbreviated name of the next smaller administrative region than county.",
                                        ),
                                    ),
                                    max_graphemes: Some(256usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("nomenclaturalCode"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The nomenclatural code under which the scientificName is constructed.",
                                        ),
                                    ),
                                    max_graphemes: Some(64usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("occurrenceID"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "A globally unique identifier for the occurrence record. Recommended: a persistent URI (e.g., DOI, LSID, or UUID-based URI).",
                                        ),
                                    ),
                                    max_graphemes: Some(256usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("occurrenceRemarks"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Comments or notes about the occurrence.",
                                        ),
                                    ),
                                    max_graphemes: Some(5000usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("occurrenceStatus"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Statement about the presence or absence of a taxon at a location.",
                                        ),
                                    ),
                                    max_graphemes: Some(64usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("order"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("The full scientific name of the order."),
                                    ),
                                    max_graphemes: Some(128usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("organismQuantity"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "A number or enumeration value for the quantity of organisms (e.g., '27', '12.5', 'many').",
                                        ),
                                    ),
                                    max_graphemes: Some(64usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("organismQuantityType"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The type of quantification system used for organismQuantity (e.g., 'individuals', '% biomass', 'stems/ha').",
                                        ),
                                    ),
                                    max_graphemes: Some(128usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("phylum"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The full scientific name of the phylum or division.",
                                        ),
                                    ),
                                    max_graphemes: Some(128usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("previousIdentifications"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Previous assignments of names to the occurrence. Pipe-delimited.",
                                        ),
                                    ),
                                    max_graphemes: Some(2048usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("recordedBy"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Person(s) responsible for recording the occurrence in the field. Pipe-delimited for multiple (e.g., 'Jane Smith | John Doe').",
                                        ),
                                    ),
                                    max_graphemes: Some(512usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("recordedByID"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Persistent identifier(s) (e.g., ORCID) of the person(s) who recorded. Pipe-delimited for multiple.",
                                        ),
                                    ),
                                    max_graphemes: Some(512usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("references"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "A related resource that is referenced, cited, or otherwise pointed to by the record (URL).",
                                        ),
                                    ),
                                    format: Some(LexStringFormat::Uri),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("reproductiveCondition"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The reproductive condition at the time of occurrence (e.g., 'flowering', 'fruiting', 'budding', 'pregnant').",
                                        ),
                                    ),
                                    max_graphemes: Some(128usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("rightsHolder"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Person or organization owning or managing rights over the resource.",
                                        ),
                                    ),
                                    max_graphemes: Some(256usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("samplingEffort"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The amount of effort expended during the event (e.g., '2 trap-nights', '30 minutes', '10 km transect').",
                                        ),
                                    ),
                                    max_graphemes: Some(256usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("samplingProtocol"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The method or protocol used during the event (e.g., 'camera trap', 'point count', 'mist net', '20m x 20m plot survey', 'acoustic monitoring').",
                                        ),
                                    ),
                                    max_graphemes: Some(1024usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("scientificName"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The full scientific name, with authorship and date if known (e.g., 'Centropyge flavicauda Fraser-Brunner 1933').",
                                        ),
                                    ),
                                    max_graphemes: Some(512usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("scientificNameAuthorship"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The authorship information for the scientific name (e.g., 'Fraser-Brunner 1933').",
                                        ),
                                    ),
                                    max_graphemes: Some(256usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("sex"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The sex of the biological individual(s).",
                                        ),
                                    ),
                                    max_graphemes: Some(64usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("specificEpithet"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The name of the species epithet of the scientificName.",
                                        ),
                                    ),
                                    max_graphemes: Some(128usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("spectrogramEvidence"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static(
                                        "app.gainforest.common.defs#spectrogram",
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("stateProvince"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The name of the next smaller administrative region than country.",
                                        ),
                                    ),
                                    max_graphemes: Some(256usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("taxonRank"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The taxonomic rank of the most specific name in scientificName.",
                                        ),
                                    ),
                                    max_graphemes: Some(64usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("taxonomicStatus"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The status of the use of the scientificName (e.g., 'accepted', 'synonym', 'doubtful').",
                                        ),
                                    ),
                                    max_graphemes: Some(64usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("verbatimLocality"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The original textual description of the place as provided by the recorder.",
                                        ),
                                    ),
                                    max_graphemes: Some(1024usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("vernacularName"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "A common or vernacular name for the taxon.",
                                        ),
                                    ),
                                    max_graphemes: Some(256usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("videoEvidence"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static(
                                        "app.gainforest.common.defs#video",
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map
                        },
                        ..Default::default()
                    }),
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}