// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: app.certified.location
//
// 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, open_union};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;

#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::org_hypercerts::SmallBlob;
use crate::org_hypercerts::Uri;
use crate::app_certified::location;
/// A location reference

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
    rename_all = "camelCase",
    rename = "app.certified.location",
    tag = "$type",
    bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Location<S: BosStr = DefaultStr> {
    ///Client-declared timestamp when this record was originally created
    pub created_at: Datetime,
    ///Additional context about this location, such as its significance to the work or specific boundaries
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<S>,
    ///The location of where the work was performed as a URI, blob, or inline string.
    pub location: LocationLocation<S>,
    ///An identifier for the format of the location data (e.g., coordinate-decimal, geojson-point). See the Location Protocol spec for the full registry: https://spec.decentralizedgeo.org/specification/location-types/#location-type-registry
    pub location_type: LocationLocationType<S>,
    ///The version of the Location Protocol
    pub lp_version: S,
    ///Human-readable name for this location (e.g. 'Golden Gate Park', 'San Francisco Bay Area')
    #[serde(skip_serializing_if = "Option::is_none")]
    pub name: Option<S>,
    ///The Spatial Reference System URI (e.g., http://www.opengis.net/def/crs/OGC/1.3/CRS84) that defines the coordinate system.
    pub srs: UriValue<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum LocationLocation<S: BosStr = DefaultStr> {
    #[serde(rename = "org.hypercerts.defs#uri")]
    Uri(Box<Uri<S>>),
    #[serde(rename = "org.hypercerts.defs#smallBlob")]
    SmallBlob(Box<SmallBlob<S>>),
    #[serde(rename = "app.certified.location#string")]
    String(Box<location::LocationString<S>>),
}

/// An identifier for the format of the location data (e.g., coordinate-decimal, geojson-point). See the Location Protocol spec for the full registry: https://spec.decentralizedgeo.org/specification/location-types/#location-type-registry

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum LocationLocationType<S: BosStr = DefaultStr> {
    CoordinateDecimal,
    GeojsonPoint,
    Geojson,
    H3,
    Geohash,
    Wkt,
    Address,
    ScaledCoordinates,
    Other(S),
}

impl<S: BosStr> LocationLocationType<S> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::CoordinateDecimal => "coordinate-decimal",
            Self::GeojsonPoint => "geojson-point",
            Self::Geojson => "geojson",
            Self::H3 => "h3",
            Self::Geohash => "geohash",
            Self::Wkt => "wkt",
            Self::Address => "address",
            Self::ScaledCoordinates => "scaledCoordinates",
            Self::Other(s) => s.as_ref(),
        }
    }
    /// Construct from a string-like value, matching known values.
    pub fn from_value(s: S) -> Self {
        match s.as_ref() {
            "coordinate-decimal" => Self::CoordinateDecimal,
            "geojson-point" => Self::GeojsonPoint,
            "geojson" => Self::Geojson,
            "h3" => Self::H3,
            "geohash" => Self::Geohash,
            "wkt" => Self::Wkt,
            "address" => Self::Address,
            "scaledCoordinates" => Self::ScaledCoordinates,
            _ => Self::Other(s),
        }
    }
}

impl<S: BosStr> core::fmt::Display for LocationLocationType<S> {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        write!(f, "{}", self.as_str())
    }
}

impl<S: BosStr> AsRef<str> for LocationLocationType<S> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

impl<S: BosStr> Serialize for LocationLocationType<S> {
    fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
    where
        Ser: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}

impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for LocationLocationType<S> {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = S::deserialize(deserializer)?;
        Ok(Self::from_value(s))
    }
}

impl<S: BosStr + Default> Default for LocationLocationType<S> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl<S: BosStr> jacquard_common::IntoStatic for LocationLocationType<S>
where
    S: BosStr + jacquard_common::IntoStatic,
    S::Output: BosStr,
{
    type Output = LocationLocationType<S::Output>;
    fn into_static(self) -> Self::Output {
        match self {
            LocationLocationType::CoordinateDecimal => {
                LocationLocationType::CoordinateDecimal
            }
            LocationLocationType::GeojsonPoint => LocationLocationType::GeojsonPoint,
            LocationLocationType::Geojson => LocationLocationType::Geojson,
            LocationLocationType::H3 => LocationLocationType::H3,
            LocationLocationType::Geohash => LocationLocationType::Geohash,
            LocationLocationType::Wkt => LocationLocationType::Wkt,
            LocationLocationType::Address => LocationLocationType::Address,
            LocationLocationType::ScaledCoordinates => {
                LocationLocationType::ScaledCoordinates
            }
            LocationLocationType::Other(v) => {
                LocationLocationType::Other(v.into_static())
            }
        }
    }
}

/// 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 LocationGetRecordOutput<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cid: Option<Cid<S>>,
    pub uri: AtUri<S>,
    pub value: Location<S>,
}

/// A location represented as a string, e.g. coordinates or a small GeoJSON string.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct LocationString<S: BosStr = DefaultStr> {
    ///The location string value
    pub string: S,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

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

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

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

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

impl<S: BosStr> Collection for Location<S> {
    const NSID: &'static str = "app.certified.location";
    type Record = LocationRecord;
}

impl Collection for LocationRecord {
    const NSID: &'static str = "app.certified.location";
    type Record = LocationRecord;
}

impl<S: BosStr> LexiconSchema for Location<S> {
    fn nsid() -> &'static str {
        "app.certified.location"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_certified_location()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.description {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 2000usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("description"),
                    max: 2000usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.description {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 500usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("description"),
                        max: 500usize,
                        actual: count,
                    });
                }
            }
        }
        {
            let value = &self.location_type;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 20usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("location_type"),
                    max: 20usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.lp_version;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 10usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("lp_version"),
                    max: 10usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.name {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 1000usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("name"),
                    max: 1000usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.name {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 100usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("name"),
                        max: 100usize,
                        actual: count,
                    });
                }
            }
        }
        {
            let value = &self.srs;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 100usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("srs"),
                    max: 100usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for LocationString<S> {
    fn nsid() -> &'static str {
        "app.certified.location"
    }
    fn def_name() -> &'static str {
        "string"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_certified_location()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.string;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 10000usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("string"),
                    max: 10000usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.string;
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 1000usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("string"),
                        max: 1000usize,
                        actual: count,
                    });
                }
            }
        }
        Ok(())
    }
}

pub mod location_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 CreatedAt;
        type Location;
        type LocationType;
        type LpVersion;
        type Srs;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type CreatedAt = Unset;
        type Location = Unset;
        type LocationType = Unset;
        type LpVersion = Unset;
        type Srs = Unset;
    }
    ///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 CreatedAt = Set<members::created_at>;
        type Location = St::Location;
        type LocationType = St::LocationType;
        type LpVersion = St::LpVersion;
        type Srs = St::Srs;
    }
    ///State transition - sets the `location` field to Set
    pub struct SetLocation<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetLocation<St> {}
    impl<St: State> State for SetLocation<St> {
        type CreatedAt = St::CreatedAt;
        type Location = Set<members::location>;
        type LocationType = St::LocationType;
        type LpVersion = St::LpVersion;
        type Srs = St::Srs;
    }
    ///State transition - sets the `location_type` field to Set
    pub struct SetLocationType<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetLocationType<St> {}
    impl<St: State> State for SetLocationType<St> {
        type CreatedAt = St::CreatedAt;
        type Location = St::Location;
        type LocationType = Set<members::location_type>;
        type LpVersion = St::LpVersion;
        type Srs = St::Srs;
    }
    ///State transition - sets the `lp_version` field to Set
    pub struct SetLpVersion<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetLpVersion<St> {}
    impl<St: State> State for SetLpVersion<St> {
        type CreatedAt = St::CreatedAt;
        type Location = St::Location;
        type LocationType = St::LocationType;
        type LpVersion = Set<members::lp_version>;
        type Srs = St::Srs;
    }
    ///State transition - sets the `srs` field to Set
    pub struct SetSrs<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetSrs<St> {}
    impl<St: State> State for SetSrs<St> {
        type CreatedAt = St::CreatedAt;
        type Location = St::Location;
        type LocationType = St::LocationType;
        type LpVersion = St::LpVersion;
        type Srs = Set<members::srs>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `location` field
        pub struct location(());
        ///Marker type for the `location_type` field
        pub struct location_type(());
        ///Marker type for the `lp_version` field
        pub struct lp_version(());
        ///Marker type for the `srs` field
        pub struct srs(());
    }
}

/// Builder for constructing an instance of this type.
pub struct LocationBuilder<St: location_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<Datetime>,
        Option<S>,
        Option<LocationLocation<S>>,
        Option<LocationLocationType<S>>,
        Option<S>,
        Option<S>,
        Option<UriValue<S>>,
    ),
    _type: PhantomData<fn() -> S>,
}

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

impl<S: BosStr> Location<S> {
    /// Create a new builder for this type
    pub fn builder() -> LocationBuilder<location_state::Empty, S> {
        LocationBuilder::builder()
    }
}

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

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

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

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

impl<St, S: BosStr> LocationBuilder<St, S>
where
    St: location_state::State,
    St::Location: location_state::IsUnset,
{
    /// Set the `location` field (required)
    pub fn location(
        mut self,
        value: impl Into<LocationLocation<S>>,
    ) -> LocationBuilder<location_state::SetLocation<St>, S> {
        self._fields.2 = Option::Some(value.into());
        LocationBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> LocationBuilder<St, S>
where
    St: location_state::State,
    St::LocationType: location_state::IsUnset,
{
    /// Set the `locationType` field (required)
    pub fn location_type(
        mut self,
        value: impl Into<LocationLocationType<S>>,
    ) -> LocationBuilder<location_state::SetLocationType<St>, S> {
        self._fields.3 = Option::Some(value.into());
        LocationBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> LocationBuilder<St, S>
where
    St: location_state::State,
    St::LpVersion: location_state::IsUnset,
{
    /// Set the `lpVersion` field (required)
    pub fn lp_version(
        mut self,
        value: impl Into<S>,
    ) -> LocationBuilder<location_state::SetLpVersion<St>, S> {
        self._fields.4 = Option::Some(value.into());
        LocationBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: location_state::State, S: BosStr> LocationBuilder<St, S> {
    /// Set the `name` field (optional)
    pub fn name(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.5 = value.into();
        self
    }
    /// Set the `name` field to an Option value (optional)
    pub fn maybe_name(mut self, value: Option<S>) -> Self {
        self._fields.5 = value;
        self
    }
}

impl<St, S: BosStr> LocationBuilder<St, S>
where
    St: location_state::State,
    St::Srs: location_state::IsUnset,
{
    /// Set the `srs` field (required)
    pub fn srs(
        mut self,
        value: impl Into<UriValue<S>>,
    ) -> LocationBuilder<location_state::SetSrs<St>, S> {
        self._fields.6 = Option::Some(value.into());
        LocationBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> LocationBuilder<St, S>
where
    St: location_state::State,
    St::CreatedAt: location_state::IsSet,
    St::Location: location_state::IsSet,
    St::LocationType: location_state::IsSet,
    St::LpVersion: location_state::IsSet,
    St::Srs: location_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Location<S> {
        Location {
            created_at: self._fields.0.unwrap(),
            description: self._fields.1,
            location: self._fields.2.unwrap(),
            location_type: self._fields.3.unwrap(),
            lp_version: self._fields.4.unwrap(),
            name: self._fields.5,
            srs: self._fields.6.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Location<S> {
        Location {
            created_at: self._fields.0.unwrap(),
            description: self._fields.1,
            location: self._fields.2.unwrap(),
            location_type: self._fields.3.unwrap(),
            lp_version: self._fields.4.unwrap(),
            name: self._fields.5,
            srs: self._fields.6.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_app_certified_location() -> 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.certified.location"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Record(LexRecord {
                    description: Some(CowStr::new_static("A location reference")),
                    key: Some(CowStr::new_static("tid")),
                    record: LexRecordRecord::Object(LexObject {
                        required: Some(
                            vec![
                                SmolStr::new_static("lpVersion"),
                                SmolStr::new_static("srs"),
                                SmolStr::new_static("locationType"),
                                SmolStr::new_static("location"),
                                SmolStr::new_static("createdAt")
                            ],
                        ),
                        properties: {
                            #[allow(unused_mut)]
                            let mut map = BTreeMap::new();
                            map.insert(
                                SmolStr::new_static("createdAt"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Client-declared timestamp when this record was originally created",
                                        ),
                                    ),
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("description"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Additional context about this location, such as its significance to the work or specific boundaries",
                                        ),
                                    ),
                                    max_length: Some(2000usize),
                                    max_graphemes: Some(500usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("location"),
                                LexObjectProperty::Union(LexRefUnion {
                                    description: Some(
                                        CowStr::new_static(
                                            "The location of where the work was performed as a URI, blob, or inline string.",
                                        ),
                                    ),
                                    refs: vec![
                                        CowStr::new_static("org.hypercerts.defs#uri"),
                                        CowStr::new_static("org.hypercerts.defs#smallBlob"),
                                        CowStr::new_static("#string")
                                    ],
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("locationType"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "An identifier for the format of the location data (e.g., coordinate-decimal, geojson-point). See the Location Protocol spec for the full registry: https://spec.decentralizedgeo.org/specification/location-types/#location-type-registry",
                                        ),
                                    ),
                                    max_length: Some(20usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("lpVersion"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("The version of the Location Protocol"),
                                    ),
                                    max_length: Some(10usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("name"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Human-readable name for this location (e.g. 'Golden Gate Park', 'San Francisco Bay Area')",
                                        ),
                                    ),
                                    max_length: Some(1000usize),
                                    max_graphemes: Some(100usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("srs"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The Spatial Reference System URI (e.g., http://www.opengis.net/def/crs/OGC/1.3/CRS84) that defines the coordinate system.",
                                        ),
                                    ),
                                    format: Some(LexStringFormat::Uri),
                                    max_length: Some(100usize),
                                    ..Default::default()
                                }),
                            );
                            map
                        },
                        ..Default::default()
                    }),
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("string"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "A location represented as a string, e.g. coordinates or a small GeoJSON string.",
                        ),
                    ),
                    required: Some(vec![SmolStr::new_static("string")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("string"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("The location string value"),
                                ),
                                max_length: Some(10000usize),
                                max_graphemes: Some(1000usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}