import React, { useMemo } from "react";
import "~/assets/styles/old-tailwind.css";
import { useTranslation } from "react-i18next";
import { NeighborhoodMarketTrendsProvider } from "./context";
import { Content } from "./components/Content";
import { Footer } from "./components/Footer";
import { schema } from "./schema";
import * as styles from "./styles";
import { TrackingProvider, initializeAnalytics } from "~/tracking";
import { TitleHeader } from "~/components/TitleHeader";
import ResizeWrapper from "~/components/ResizeWrapper";
import { ValidateOptions } from "~/components/ValidateOptions";
import { LocalLogicProvider } from "~/context/LocalLogicProvider";
import { useStateManagerContext } from "~/context/stateManager";
import useIsMobile from "~/hooks/useIsMobile";
import { ProductNames } from "~/types";
import { ANALYTICS_SETTINGS } from "~/constants/analytics";
initializeAnalytics(ANALYTICS_SETTINGS.neighborhoodWrap.key);
const NeighborhoodMarketTrends = () => {
    var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
    const { t } = useTranslation("neighborhoodMarketTrends");
    const { sdkState } = useStateManagerContext();
    const isMobile = useIsMobile();
    const locale = ((_a = sdkState.globalOptions) === null || _a === void 0 ? void 0 : _a.locale) || "en";
    const location = useMemo(() => {
        var _a, _b, _c, _d;
        if ((_a = sdkState.options) === null || _a === void 0 ? void 0 : _a.geographyId) {
            return {
                geographyId: (_b = sdkState.options) === null || _b === void 0 ? void 0 : _b.geographyId,
            };
        }
        return {
            lat: (_c = sdkState.options) === null || _c === void 0 ? void 0 : _c.lat,
            lng: (_d = sdkState.options) === null || _d === void 0 ? void 0 : _d.lng,
        };
    }, [
        (_b = sdkState.options) === null || _b === void 0 ? void 0 : _b.lat,
        (_c = sdkState.options) === null || _c === void 0 ? void 0 : _c.lng,
        (_d = sdkState.options) === null || _d === void 0 ? void 0 : _d.geographyId,
    ]);
    return (React.createElement(ResizeWrapper, null,
        React.createElement(ValidateOptions, { sdk: "Neighborhood Market Trends", schema: schema, options: sdkState.options },
            React.createElement(LocalLogicProvider, { environment: (_f = (_e = sdkState.globalOptions) === null || _e === void 0 ? void 0 : _e.environment) === null || _f === void 0 ? void 0 : _f.api, apiKey: sdkState.apiKey, appearance: (_g = sdkState.globalOptions) === null || _g === void 0 ? void 0 : _g.appearance, locale: (_h = sdkState.globalOptions) === null || _h === void 0 ? void 0 : _h.locale, product: ProductNames.NEIGHBORHOOD_MARKET_TRENDS },
                React.createElement(TrackingProvider, { trackingPipelineSettings: {
                        apiKey: sdkState.apiKey || "",
                    }, analyticsSettings: ANALYTICS_SETTINGS.neighborhoodWrap, meta: {
                        clientId: sdkState.clientId,
                        productName: ProductNames.NEIGHBORHOOD_MARKET_TRENDS,
                        productVersion: FULL_APP_VERSION,
                    }, attributes: {
                        location,
                        host: sdkState.location,
                        host_url: document.referrer,
                        locale,
                        isMobile,
                    }, flags: {
                        isDebugMode: import.meta.env.VITE_TRACKING_PIPELINE_DEBUG === "true",
                    } },
                    React.createElement(NeighborhoodMarketTrendsProvider, null,
                        React.createElement(TitleHeader, { title: typeof ((_j = sdkState.options) === null || _j === void 0 ? void 0 : _j.title) === "string" ||
                                ((_k = sdkState.options) === null || _k === void 0 ? void 0 : _k.title) === false
                                ? sdkState.options.title
                                : t("title") }),
                        React.createElement("p", { className: styles.disclaimer }, t("disclaimer.header")),
                        React.createElement(Content, { omitTabs: (_l = sdkState.options) === null || _l === void 0 ? void 0 : _l.omitTabs }),
                        React.createElement(Footer, { hideAttribution: (_m = sdkState.options) === null || _m === void 0 ? void 0 : _m.hideAttribution })))))));
};
export default NeighborhoodMarketTrends;
//# sourceMappingURL=index.js.map