/**
 * Copyright (c) 2020-present, Goldman Sachs
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import { hashArray, uuid, } from '@finos/legend-shared';
import { PackageableElement, } from '../packageableElements/PackageableElement.js';
import { CORE_HASH_STRUCTURE, hashObjectWithoutSourceInformation, } from '../../../Core_HashUtils.js';
import { AnnotatedElement } from '../packageableElements/domain/AnnotatedElement.js';
import { ConcreteFunctionDefinition } from '../packageableElements/function/ConcreteFunctionDefinition.js';
import { generateFunctionPrettyName } from '../../../helpers/PureLanguageHelper.js';
export class AccessPoint {
    id;
    title;
    description;
    stereotypes = [];
    constructor(id) {
        this.id = id;
    }
    get hashCode() {
        return hashArray([
            CORE_HASH_STRUCTURE.DATA_PRODUCT_ACCESS_POINT,
            this.id,
            this.title ?? '',
            this.description ?? '',
            hashArray(this.stereotypes.map((val) => val.pointerHashCode)),
        ]);
    }
}
export class FunctionAccessPoint extends AccessPoint {
    query;
    constructor(id, query) {
        super(id);
        this.query = query;
    }
    get hashCode() {
        return hashArray([
            super.hashCode,
            CORE_HASH_STRUCTURE.FUNCTION_ACCESS_POINT,
            this.query,
        ]);
    }
}
export var LakehouseTargetEnv;
(function (LakehouseTargetEnv) {
    LakehouseTargetEnv["Snowflake"] = "Snowflake";
    LakehouseTargetEnv["Databricks"] = "Databricks";
    LakehouseTargetEnv["BigQuery"] = "BigQuery";
    LakehouseTargetEnv["DuckDb"] = "DuckDb";
})(LakehouseTargetEnv || (LakehouseTargetEnv = {}));
export class LakehouseAccessPoint extends AccessPoint {
    targetEnvironment;
    classification;
    func;
    reproducible;
    constructor(id, targetEnv, func) {
        super(id);
        this.targetEnvironment = targetEnv;
        this.func = func;
    }
    get hashCode() {
        return hashArray([
            super.hashCode,
            CORE_HASH_STRUCTURE.LAKEHOUSE_ACCESS_POINT,
            this.targetEnvironment,
            this.classification ?? '',
            this.func,
            this.reproducible ?? '',
        ]);
    }
}
export class UnknownAccessPoint extends AccessPoint {
    content;
    get hashCode() {
        return hashArray([
            super.hashCode,
            CORE_HASH_STRUCTURE.UNKNOWN_ACCESS_POINT,
            hashObjectWithoutSourceInformation(this.content),
        ]);
    }
}
export class DataProductRuntimeInfo {
    id;
    description;
    runtime;
    get hashCode() {
        return hashArray([
            CORE_HASH_STRUCTURE.DATA_PRODUCT_RUNTIME_INFO,
            this.id,
            this.description ?? '',
            this.runtime.valueForSerialization ?? '',
        ]);
    }
}
export class DataProductElementScope {
    exclude;
    element;
    get hashCode() {
        return hashArray([
            CORE_HASH_STRUCTURE.DATA_PRODUCT_ELEMENT_SCOPE,
            this.exclude ?? '',
            this.element.valueForSerialization ?? '',
        ]);
    }
}
export class DataProductDiagram {
    title;
    description;
    diagram;
    get hashCode() {
        return hashArray([
            CORE_HASH_STRUCTURE.DATA_PRODUCT_DIAGRAM,
            this.title,
            this.description ?? '',
            this.diagram.path,
        ]);
    }
}
export class AccessPointGroup extends AnnotatedElement {
    id;
    title;
    description;
    accessPoints = [];
    get hashCode() {
        return hashArray([
            CORE_HASH_STRUCTURE.DATA_PRODUCT_ACCESS_POINT_GROUP,
            this.id,
            this.title ?? '',
            this.description ?? '',
            hashArray(this.accessPoints),
            hashArray(this.stereotypes.map((val) => val.pointerHashCode)),
        ]);
    }
}
export class ModelAccessPointGroup extends AccessPointGroup {
    mapping;
    featuredElements = [];
    diagrams = [];
    get hashCode() {
        return hashArray([
            super.hashCode,
            CORE_HASH_STRUCTURE.DATA_PRODUCT_MODEL_ACCESS_POINT_GROUP,
            this.mapping.valueForSerialization ?? '',
            hashArray(this.featuredElements),
            hashArray(this.diagrams),
        ]);
    }
}
export class NativeModelExecutionContext {
    key;
    mapping;
    runtime;
    get hashCode() {
        return hashArray([
            CORE_HASH_STRUCTURE.DATA_PRODUCT_NATIVE_MODEL_EXECUTION_CONTEXT,
            this.key,
            this.mapping.valueForSerialization ?? '',
            this.runtime?.valueForSerialization ?? '',
        ]);
    }
}
export class NativeModelAccess {
    featuredElements = [];
    nativeModelExecutionContexts = [];
    defaultExecutionContext;
    diagrams = [];
    sampleQueries = [];
    get hashCode() {
        return hashArray([
            CORE_HASH_STRUCTURE.DATA_PRODUCT_NATIVE_MODEL_ACCESS,
            hashArray(this.nativeModelExecutionContexts),
            hashArray(this.featuredElements),
            hashArray(this.diagrams),
            hashArray(this.sampleQueries),
            this.defaultExecutionContext.key,
        ]);
    }
}
export class SampleQuery {
    id;
    title;
    description;
    executionContextKey;
    get hashCode() {
        return hashArray([
            CORE_HASH_STRUCTURE.DATA_PRODUCT_SAMPLE_QUERY,
            this.id,
            this.title,
            this.description ?? '',
            this.executionContextKey,
        ]);
    }
}
export class InLineSampleQuery extends SampleQuery {
    query;
    get hashCode() {
        return hashArray([
            CORE_HASH_STRUCTURE.DATA_PRODUCT_INLINE_SAMPLE_QUERY,
            super.hashCode,
            this.query,
        ]);
    }
}
export class PackageableElementSampleQuery extends SampleQuery {
    query;
    get hashCode() {
        return hashArray([
            CORE_HASH_STRUCTURE.DATA_PRODUCT_PACKAGEABLE_ELEMENT_SAMPLE_QUERY,
            super.hashCode,
            this.query.value instanceof ConcreteFunctionDefinition
                ? generateFunctionPrettyName(this.query.value, {
                    fullPath: true,
                    spacing: false,
                    notIncludeParamName: true,
                })
                : (this.query.valueForSerialization ?? ''),
        ]);
    }
}
export class Email {
    title;
    address;
    constructor(address, title) {
        this.address = address;
        this.title = title;
    }
    get hashCode() {
        return hashArray([CORE_HASH_STRUCTURE.EMAIL, this.title, this.address]);
    }
}
export class DataProductLink {
    label;
    url;
    constructor(url, label) {
        this.url = url;
        this.label = label;
    }
    get hashCode() {
        return hashArray([
            CORE_HASH_STRUCTURE.DATA_PRODUCT_LINK,
            this.label ?? '',
            this.url,
        ]);
    }
}
export class SupportInfo {
    documentation;
    website;
    faqUrl;
    supportUrl;
    emails = [];
    expertise;
    get hashCode() {
        return hashArray([
            CORE_HASH_STRUCTURE.SUPPORT_INFO,
            this.documentation ?? '',
            this.website ?? '',
            this.faqUrl ?? '',
            this.supportUrl ?? '',
            hashArray(this.emails),
            hashArray(this.expertise ?? []),
        ]);
    }
}
export var DataProduct_DeliveryFrequency;
(function (DataProduct_DeliveryFrequency) {
    DataProduct_DeliveryFrequency["DAILY"] = "DAILY";
    DataProduct_DeliveryFrequency["WEEKLY"] = "WEEKLY";
    DataProduct_DeliveryFrequency["MONTHLY"] = "MONTHLY";
    DataProduct_DeliveryFrequency["QUARTERLY"] = "QUARTERLY";
    DataProduct_DeliveryFrequency["YEARLY"] = "YEARLY";
    DataProduct_DeliveryFrequency["ON_DEMAND"] = "ON_DEMAND";
    DataProduct_DeliveryFrequency["INTRA_DAY"] = "INTRADAY";
})(DataProduct_DeliveryFrequency || (DataProduct_DeliveryFrequency = {}));
export var DataProduct_Region;
(function (DataProduct_Region) {
    DataProduct_Region["APAC"] = "APAC";
    DataProduct_Region["EMEA"] = "EMEA";
    DataProduct_Region["LAMR"] = "LAMR";
    DataProduct_Region["NAMR"] = "NAMR";
})(DataProduct_Region || (DataProduct_Region = {}));
export class DataProductIcon {
}
export class DataProductLibraryIcon extends DataProductIcon {
    libraryId;
    iconId;
    constructor(libraryId, iconId) {
        super();
        this.libraryId = libraryId;
        this.iconId = iconId;
    }
    get hashCode() {
        return hashArray([
            CORE_HASH_STRUCTURE.DATA_PRODUCT_ICON_LIBRARY,
            this.libraryId,
            this.iconId,
        ]);
    }
}
export class DataProductEmbeddedImageIcon extends DataProductIcon {
    imageUrl;
    constructor(imageUrl) {
        super();
        this.imageUrl = imageUrl;
    }
    get hashCode() {
        return hashArray([
            CORE_HASH_STRUCTURE.DATA_PRODUCT_ICON_EMBEDDED_IMAGE,
            this.imageUrl,
        ]);
    }
}
// handle incoming icons not yet modeled
export class UnknownDataProductIcon extends DataProductIcon {
    content;
    constructor(content) {
        super();
        this.content = content;
    }
    get hashCode() {
        return hashArray([
            CORE_HASH_STRUCTURE.INTERNAL__UNKNOWN_DATA_PRODUCT_ICON,
            hashObjectWithoutSourceInformation(this.content),
        ]);
    }
}
export class DataProductType {
    get hashCode() {
        return hashArray([CORE_HASH_STRUCTURE.DATA_PRODUCT_TYPE]);
    }
}
export class InternalDataProductType extends DataProductType {
}
export class ExternalDataProductType extends DataProductType {
    link;
    get hashCode() {
        return hashArray([CORE_HASH_STRUCTURE.DATA_PRODUCT_TYPE, this.link]);
    }
}
export class Expertise {
    uuid = uuid();
    description;
    expertIds;
    get hashCode() {
        return hashArray([
            CORE_HASH_STRUCTURE.DATA_PRODUCT_EXPERTISE,
            this.description ?? '',
            hashArray(this.expertIds ?? []),
        ]);
    }
}
export class DataProductOperationalMetadata {
    coverageRegions;
    updateFrequency;
    get hashCode() {
        return hashArray([
            CORE_HASH_STRUCTURE.DATA_PRODUCT_OPERATIONAL_METADATA,
            hashArray(this.coverageRegions ?? []),
            this.updateFrequency ?? '',
        ]);
    }
}
export class DataProduct extends PackageableElement {
    title;
    description;
    icon;
    accessPointGroups = [];
    nativeModelAccess;
    supportInfo;
    type;
    sampleValues;
    operationalMetadata;
    accept_PackageableElementVisitor(visitor) {
        return visitor.visit_DataProduct(this);
    }
    get _elementHashCode() {
        return hashArray([
            CORE_HASH_STRUCTURE.DATA_PRODUCT,
            this.title ?? '',
            this.description ?? '',
            this.icon ?? '',
            hashArray(this.accessPointGroups),
            this.nativeModelAccess ?? '',
            this.supportInfo ?? '',
            this.type ?? '',
            hashArray(this.stereotypes.map((val) => val.pointerHashCode)),
            hashArray(this.taggedValues),
            hashArray(this.sampleValues ?? []),
            this.operationalMetadata ?? '',
        ]);
    }
}
//# sourceMappingURL=DataProduct.js.map