import React from "react";
import { ToastAlertsProvider } from "@local-logic/design-system";
import { Content } from "./components/Content";
import { LeadCaptureProvider } from "./context";
import { schema } from "./schema";
import { TrackingProvider, initializeAnalytics } from "~/tracking";
// TODO Move this import to sdks/sdks-app/src/App.tsx once all SDKs are migrated
import "~/assets/styles/globals.css";
import ResizeWrapper from "~/components/ResizeWrapper";
import { ANALYTICS_SETTINGS } from "~/constants/analytics";
import { LocalLogicProvider } from "~/context/LocalLogicProvider";
import { useStateManagerContext } from "~/context/stateManager";
import { ValidateOptions } from "~/components/ValidateOptions";
import { ProductNames } from "~/types";
import useIsMobile from "~/hooks/useIsMobile";
initializeAnalytics(ANALYTICS_SETTINGS.leadCapture.key);
const LeadCapture = () => {
    var _a, _b, _c, _d, _e, _f, _g, _h, _j;
    const { sdkState } = useStateManagerContext();
    const isMobile = useIsMobile();
    const locale = ((_a = sdkState.globalOptions) === null || _a === void 0 ? void 0 : _a.locale) || "en";
    const location = ((_b = sdkState.options) === null || _b === void 0 ? void 0 : _b.geographyId)
        ? { geographyId: (_c = sdkState.options) === null || _c === void 0 ? void 0 : _c.geographyId }
        : { lat: (_d = sdkState.options) === null || _d === void 0 ? void 0 : _d.lat, lng: (_e = sdkState.options) === null || _e === void 0 ? void 0 : _e.lng };
    return (React.createElement(ResizeWrapper, null,
        React.createElement(ValidateOptions, { sdk: "Lead Capture", schema: schema, options: sdkState.options },
            React.createElement(LocalLogicProvider, { environment: (_g = (_f = sdkState.globalOptions) === null || _f === void 0 ? void 0 : _f.environment) === null || _g === void 0 ? void 0 : _g.api, apiKey: sdkState.apiKey, appearance: (_h = sdkState.globalOptions) === null || _h === void 0 ? void 0 : _h.appearance, locale: (_j = sdkState.globalOptions) === null || _j === void 0 ? void 0 : _j.locale, product: ProductNames.LEAD_CAPTURE },
                React.createElement(TrackingProvider, { trackingPipelineSettings: { apiKey: sdkState.apiKey || "" }, analyticsSettings: ANALYTICS_SETTINGS.leadCapture, meta: {
                        clientId: sdkState.clientId,
                        productName: ProductNames.LEAD_CAPTURE,
                        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(LeadCaptureProvider, null,
                        React.createElement(ToastAlertsProvider, null,
                            React.createElement(Content, null))))))));
};
export default LeadCapture;
//# sourceMappingURL=index.js.map