import { p as e, o as r } from "./antd-eb0b81b8.js";
import { c as o, A as i, a as t, b as s, H as a } from "./materialUtils-194218f3.js";
import { gu as n, cz as p, dW as m, fB as l, gv as c, fg as d, fm as f, fC as g, av as h, cr as j, fe as u, ff as x, fh as v, fw as b, fx as y, gw as w, gx as k, fn as C, fF as T, fv as _, gy as A } from "./index-6d97e67f.js";
import S, { useContext as z, useState as q, useMemo as M } from "react";
import { lA as $, lR as H, lS as O, ni as P, nj as R, nk as B } from "./ant-design-icons-a81e6d18.js";
import { d as D } from "./styled-components-b776227d.js";
import { b as E } from "./react-router-38313ddc.js";
import { g as I } from "./enterpriseSelectors-1897ddd8.js";
import "react-dom";
import "./dayjs-63343308.js";
import "./alasql-f59e855e.js";
import "./lodash-226cb5b1.js";
import "./crypto-js-8020edb5.js";
import "./customerService-e0e873e3.js";
import "./redux-saga-3b3a9c7b.js";
import "./folderSelector-82f1bcf3.js";
import "./loglevel-5e7e37fc.js";
import "./axios-0ffd51b8.js";
import "./redux-devtools-36ca30b8.js";
import "./fontawesome-7bcd29b1.js";
import "./dnd-kit-e0a0bf75.js";
import "./moment-d731d247.js";
import "./numbro-48e81844.js";
import "./papaparse-088c0adc.js";
import "./uuid-82f303b2.js";
import "./supabase-6aa220db.js";
import "./websockets-80729b50.js";
import "./fetch-03ca8116.js";
import "./react-draggable-1ced44e5.js";
import "./clsx-b06d39d3.js";
import "./remark-gfm-72b87c7d.js";
import "./buffer-f89d742d.js";
import "./rehype-raw-49057806.js";
import "./parse5-31d0cb5d.js";
import "./rehype-sanitize-38a120e4.js";
import "./simplebar-react-a37a9b2a.js";
import "./react-best-gradient-color-picker-2e7ff36d.js";
import "./ua-parser-js-1d18a3f8.js";
import "./codemirror-8fe65581.js";
import "./really-relaxed-json-e5391d6a.js";
import "./immer-c0428a8d.js";
import "./hotkeys-js-216206c9.js";
import "./cnchar-8c3eaa86.js";
import "./react-documents-a03b99c9.js";
import "./sql-formatter-69e8df59.js";
import "./rc-trigger-7d152aa4.js";
import "./react-json-view-364658b4.js";
import "./qrcode-react-417e3716.js";
import "./katex-05fb1c31.js";
import "./ecogis-maps-10e82de5.js";
import "./devextreme-be18bda8.js";
import "./exceljs-1678d36b.js";
import "./file-saver-es-c18fae8f.js";
const L = process.env.VNPT_APP_URL, U = D.div`
    font-weight: 500;
    font-size: 14px;
    color: ${(e2) => n(e2.$bgColor) ? "#ffffff" : "#000000"};
    font-style: normal;
    line-height: 24px;
    margin-right: 8px;
    margin-left: 20px;
    max-width: 264px;
    ${p};
`, V = D.a`
    display: flex;
    align-items: center;
`, F = D(T)`
    height: 28px;
    width: 28px;
`, N = D(_)`
    min-width: 60px;
    padding: 0;
    height: 28px;
    margin-right: 4px;
`, G = D(_)`
    min-width: 60px;
    height: 28px;
`, J = D(_)`
    &&& {
        color: #ffffff;
        background: #8b8fa34c;
        border: none;
        height: 28px;
        margin-right: 8px;
        min-width: 60px;
        padding: 0;
        cursor: pointer;

        &:hover {
            background: #666666;
            color: #ffffff;
            border: none;
        }

        &:focus {
            background: #666666;
            color: #ffffff;
            border: none;
        }
    }
`, K = D(A)`
    margin-right: 4px;

    g g {
        fill: #ffffff;
    }
`, W = D(_)`
    min-width: 60px;
    height: 28px;
    margin-right: 24px;
    padding: 0;
`, Q = D.div`
    display: inherit;
    @media screen and (max-width: 500px) {
        > div:nth-of-type(1),
        > button {
            display: none;
        }
    }
`, X = D.img`
    height: 28px;
`;
function Y(r2) {
  const { user: i2 } = r2, t2 = m(l), s2 = m(c), a2 = m(d);
  return t2 ? $(e.Avatar, { shape: "circle", size: 28 }) : $("div", { children: i2.isAnonymous ? s2 ? null : $(N, { buttonType: "primary", onClick: () => {
    var _a;
    a2 ? (_a = window.top) == null ? void 0 : _a.open(`${L}/user/auth/login`) : f.push(g);
  }, children: h("userAuth.login") }) : $(o, { user: i2, profileSide: 28, fontSize: 12 }) });
}
const Z = S.memo(() => {
  var _a, _b, _c, _d, _e;
  const e2 = E(), o2 = z(j), n2 = m(u), p2 = m(x), l2 = m(d), g2 = v(), T2 = m(c), _2 = m(I), [A2, S2] = q(false), D2 = "view_marketplace" === e2.viewMode || l2, L2 = H(O, { children: [$(V, { onClick: () => !l2 && f.push(C), children: ((_a = _2 == null ? void 0 : _2.config_set) == null ? void 0 : _a.logo) ? Boolean(_2 == null ? void 0 : _2.orgId) ? $(X, { src: s((_b = _2 == null ? void 0 : _2.config_set) == null ? void 0 : _b.logo) }) : $(X, { src: (_c = _2 == null ? void 0 : _2.config_set) == null ? void 0 : _c.logo }) : $(F, { branding: true }) }), D2 && $(a, { setEdit: () => {
  }, isViewMarketplaceMode: D2 }), !D2 && $(U, { $bgColor: ((_d = _2 == null ? void 0 : _2.config_set) == null ? void 0 : _d.appHeaderColor) ?? "#2c2c2c", children: p2 && p2.name })] }), N2 = H(Q, { children: [b(n2, p2) && !l2 && $(i, { applicationId: g2, visible: A2, onVisibleChange: (e3) => !e3 && S2(false) }), b(n2, p2) && !l2 && $(J, { onClick: () => S2(true), children: y }), w(n2, p2) && !l2 && H(W, { buttonType: "primary", onClick: () => window.open(k(g2, "edit")), children: [$(K, {}), h("edit")] }), !!T2 && $(G, { style: { marginRight: n2.isAnonymous ? "" : "24px" }, buttonType: "primary", onClick: () => {
    window.open(h("template.cloneUrl") + T2);
  }, children: h("header.clone") }), $(Y, { user: n2 })] }), Z2 = M(() => l2 ? null : H(O, { children: [$(r, { options: [{ value: "mobile", icon: $(P, {}) }, { value: "tablet", icon: $(R, {}) }, { value: "desktop", icon: $(B, {}) }], value: o2.deviceType, onChange: (e3) => {
    o2.setDeviceType(e3);
  } }), "desktop" !== o2.deviceType && $(r, { options: [{ value: "portrait", label: "Portrait" }, { value: "landscape", label: "Landscape" }], value: o2.deviceOrientation, onChange: (e3) => {
    o2.setDeviceOrientation(e3);
  } })] }), [l2, o2.deviceType, o2.deviceOrientation]);
  return $(t, { headerStart: L2, headerMiddle: Z2, headerEnd: N2, style: { backgroundColor: ((_e = _2 == null ? void 0 : _2.config_set) == null ? void 0 : _e.appHeaderColor) || "#0066b3" } });
});
export {
  Y as HeaderProfile,
  Z as PreviewHeader
};
