import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
import { useMemo } from 'react';
import { useAppSelector } from 'src/app/redux/store';
import MainDetails from '../MainDetails';
import Detail from './Detail';
import css from '../ProfilePage.module.scss';
import { _cx } from 'src/utility/class';
import DetailWithModal from 'src/components/Modal/DetailModal/DetailWithModal';
var cx = _cx(css);
export default function DocDetails(_a) {
    var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1;
    var t = _a.t, data = _a.data, profileId = _a.profileId, selectedDsoId = _a.selectedDsoId, isMobile = _a.isMobile;
    var _2 = useAppSelector(function (state) { return state.config.config; }), features = _2.features, useDocLoc3O = _2.useDocLoc3O, hidePaymentMethods = _2.hidePaymentMethods;
    var showLendCare = useMemo(function () { return !!(features === null || features === void 0 ? void 0 : features.showLendCare); }, [features]);
    var educations = useMemo(function () {
        var _a, _b, _c;
        if (data.bio && Object.keys(data.bio).length !== 0) {
            return data.is_dso
                ? (_b = (_a = data.dso_practice_info) === null || _a === void 0 ? void 0 : _a.find(function (info) { return info.location_id === selectedDsoId; })) === null || _b === void 0 ? void 0 : _b.education
                : (_c = data.bio) === null || _c === void 0 ? void 0 : _c.educations;
        }
        return undefined;
    }, [data, selectedDsoId]);
    var extendedHours = useMemo(function () {
        var _a, _b, _c;
        if (data.bio && Object.keys(data.bio).length !== 0) {
            return (_c = (_b = (_a = data.bio) === null || _a === void 0 ? void 0 : _a.offices) === null || _b === void 0 ? void 0 : _b.find(function (office) { return office.location_id === profileId; })) === null || _c === void 0 ? void 0 : _c.extend_office_hours;
        }
        return undefined;
    }, [(_b = data.bio) === null || _b === void 0 ? void 0 : _b.offices, profileId]);
    return (_jsx(_Fragment, { children: useDocLoc3O ? (_jsxs("div", { className: cx('container-doc-details', { isMobile: isMobile }), children: [_jsxs("div", { className: cx('details-left'), children: [_jsx(Detail, { isMobile: isMobile, label: t.treatments_offered, id: "treatments_offered", children: _jsx(MainDetails, { t: t, data: data }) }), data.bio &&
                            (extendedHours || ((_d = (_c = data.bio) === null || _c === void 0 ? void 0 : _c.payment_methods) === null || _d === void 0 ? void 0 : _d.length) > 0) &&
                            !hidePaymentMethods && (_jsx(Detail, { isMobile: isMobile, label: ((_f = (_e = data.bio) === null || _e === void 0 ? void 0 : _e.payment_methods) === null || _f === void 0 ? void 0 : _f.includes('HFD Financing')) ||
                                ((_h = (_g = data.bio) === null || _g === void 0 ? void 0 : _g.payment_methods) === null || _h === void 0 ? void 0 : _h.includes('Patient Financing')) ||
                                ((_k = (_j = data.bio) === null || _j === void 0 ? void 0 : _j.payment_methods) === null || _k === void 0 ? void 0 : _k.includes('Financing options with no down payment')) ||
                                ((_m = (_l = data.bio) === null || _l === void 0 ? void 0 : _l.payment_methods) === null || _m === void 0 ? void 0 : _m.includes('Complementary consultation')) ||
                                extendedHours
                                ? t.doctor_detail_payment
                                : '', id: "doctor_detail_payment", children: _jsxs("ul", { className: cx('details-list'), children: [(_p = (_o = data.bio) === null || _o === void 0 ? void 0 : _o.payment_methods) === null || _p === void 0 ? void 0 : _p.map(function (paymentType) {
                                        if (paymentType === 'HFD Financing') {
                                            return (_jsx("li", { children: _jsx(DetailWithModal, { label: t.hfd_financing, modalId: "hfd_financing" }) }, "".concat(paymentType)));
                                        }
                                        else if (paymentType === 'Patient Financing') {
                                            return _jsx("li", { children: t.patient_financing }, "".concat(paymentType));
                                        }
                                        else if (paymentType === 'Financing options with no down payment') {
                                            return _jsx("li", { children: t.financing_no_down_payment }, "".concat(paymentType));
                                        }
                                        else if (paymentType === 'Complementary consultation') {
                                            return _jsx("li", { children: t.complimentary_consultation }, "".concat(paymentType));
                                        }
                                    }), extendedHours && _jsx("li", { children: t.extended_hours }, "".concat(t.extended_hours))] }) })), data.bio && ((_r = (_q = data.bio) === null || _q === void 0 ? void 0 : _q.insurance_types) === null || _r === void 0 ? void 0 : _r.length) > 0 && (_jsx(Detail, { isMobile: isMobile, label: t.doctor_detail_insurance, id: "doctor_detail_insurance", children: _jsx("ul", { className: cx('details-list'), children: data.bio.insurance_types.map(function (item) { return (_jsx("li", { className: cx('text-small'), children: item }, "".concat(item))); }) }) }))] }), _jsxs("div", { className: cx('details-right'), children: [data.bio && ((_t = (_s = data.bio) === null || _s === void 0 ? void 0 : _s.languages) === null || _t === void 0 ? void 0 : _t.length) > 0 && (_jsx(Detail, { isMobile: isMobile, label: t.doctor_detail_languages_spoken, id: "doctor_detail_languages_spoken", children: _jsx("ul", { className: cx('details-list'), children: data.bio.languages.map(function (lang) { return (_jsx("li", { children: lang }, "".concat(lang))); }) }) })), !!(educations === null || educations === void 0 ? void 0 : educations.length) && (_jsx(Detail, { isMobile: isMobile, label: t.doctor_detail_education, id: "doctor_detail_education", children: _jsx("ul", { className: cx('details-list'), children: educations.map(function (education) { return (_jsx("li", { className: cx('text-small'), children: 
                                    //@ts-ignore
                                    "".concat(education.major ? education.major + ' ' : '').concat(education.name ? education.name + ' ' : ''
                                    //@ts-ignore
                                    ).concat(education.year ? '(' + education.year + ')' : '') }, "".concat(education.id, "-").concat(education.name))); }) }) })), data.bio && ((_v = (_u = data.bio) === null || _u === void 0 ? void 0 : _u.associations) === null || _v === void 0 ? void 0 : _v.length) > 0 && (_jsx(Detail, { isMobile: isMobile, label: t.doctor_detail_associations, id: "doctor_detail_associations", children: _jsx("ul", { className: cx('details-list'), children: data.bio.associations.map(function (association) { return (_jsx("li", { children: association }, "".concat(association))); }) }) }))] })] })) : (_jsxs("div", { className: cx('container-doc-details', { isMobile: isMobile }), children: [_jsxs("div", { className: cx('details-left'), children: [_jsx(Detail, { isMobile: isMobile, label: t.treatments_offered, id: "treatments_offered", children: _jsx(MainDetails, { t: t, data: data }) }), ((_x = (_w = data.bio) === null || _w === void 0 ? void 0 : _w.insurance_types) === null || _x === void 0 ? void 0 : _x.length) > 0 && (_jsx(Detail, { isMobile: isMobile, label: t.doctor_detail_insurance, id: "doctor_detail_insurance", children: _jsx("ul", { className: cx('details-list'), children: data.bio.insurance_types.map(function (insuranceType) { return (_jsx("li", { className: cx('text-small'), children: insuranceType.name }, "".concat(insuranceType.name))); }) }) })), !isMobile && (_jsx(Detail, { isMobile: isMobile, label: t.notes, children: _jsx("ul", { className: cx('details-list'), children: _jsx("li", { className: cx('text-small'), children: t.default_note }) }) }))] }), _jsxs("div", { className: cx('details-right'), children: [((_z = (_y = data.bio) === null || _y === void 0 ? void 0 : _y.payment_methods) === null || _z === void 0 ? void 0 : _z.length) > 0 && !hidePaymentMethods && (_jsx(Detail, { isMobile: isMobile, label: t.doctor_detail_payment, id: "doctor_detail_payment", children: _jsxs("ul", { className: cx('details-list'), children: [showLendCare && data.is_lendcare && _jsx("li", { children: t.result_lend_care_doc_title }), data.bio.payment_methods.map(function (paymentType) { return (_jsx("li", { children: paymentType.name }, "".concat(paymentType.name))); })] }) })), !!(educations === null || educations === void 0 ? void 0 : educations.length) && (_jsx(Detail, { isMobile: isMobile, label: t.doctor_detail_education, id: "doctor_detail_education", children: _jsx("ul", { className: cx('details-list'), children: educations.map(function (education) { return (_jsx("li", { className: cx('text-small'), children: education.name }, "".concat(education.id, "-").concat(education.name))); }) }) })), ((_1 = (_0 = data.bio) === null || _0 === void 0 ? void 0 : _0.associations) === null || _1 === void 0 ? void 0 : _1.length) > 0 && (_jsx(Detail, { isMobile: isMobile, label: t.doctor_detail_associations, id: "doctor_detail_associations", children: _jsx("ul", { className: cx('details-list'), children: data.bio.associations.map(function (association) { return (_jsx("li", { children: association.name }, "".concat(association.name))); }) }) }))] })] })) }));
}
