import { Host, h } from "@stencil/core";
import dayjs from "dayjs";
import { ZButton } from "../internal-component/z-button";
import { Icon } from "../internal-component/icon";
import { useTranslation } from "../../utils/utils";
import { selectedChatStore } from "../../store/store";
import { handleError, openDialog, closeDialog } from "../../store/dialog";
import { getZrmzShopUrl, sendMessage, getZwizUserProfile, getZrmzCustomerInfo, getZrmzPointHistory, updateZrmzCustomer, getZrmzShopProfile, createZrmzCustomer, disconnectZrmzCustomer, getZrmzCondition, adjustZrmzCustomerPoint, adjustZrmzCustomerPointByCondition } from "../../api";
import { ZRMZ_API_URL } from "../../utils/constant";
import { displayDateTime } from "../../utils/dayjs";
import { getConnectionId, getConnectionItem, getZwizPackageData, openWindow } from "../../utils/func";
export class ProfileZrmz {
    profile = null;
    shopProfile = null;
    customerInfo = null;
    pointHistory = null;
    zrmzCondition = null;
    isLoading = false;
    isGeneratingShopUrl = false;
    activeTab = 'info';
    isExpand = false;
    isEditPopupOpen = false;
    editFormData = {
        firstName: '',
        lastName: '',
        phoneNumber: '',
        email: '',
        callingCode: '66',
    };
    isCustomerInfoLoading = false;
    isPointEditPopupOpen = false;
    isPointUpdateLoading = false;
    isShareMenuOpen = false;
    isLoadingShareMenu = false;
    pointEditFormData = {
        action: 'add',
        amount: '',
        pointType: '',
        note: '',
        conditionId: '',
    };
    isAdminRegisterPopupOpen = false;
    adminRegisterFormData = {
        phoneNumber: '',
        email: '',
        callingCode: '66',
        isSendLoginLink: true,
        buttonTitle: '',
        buttonName: '',
        buttonLink: '',
    };
    isExpired = false;
    isLimitReach = false;
    handleCheckPackage = () => {
        let maxUser = 10;
        if (this.shopProfile?.remaining_days_of_platinum_package) {
            maxUser = 100000;
        }
        else if (this.shopProfile?.remaining_days_of_gold_package) {
            maxUser = 50000;
        }
        else if (this.shopProfile?.remaining_days_of_premium_package) {
            maxUser = 10000;
        }
        else if (this.shopProfile?.remaining_days_of_bronze_package) {
            maxUser = 5000;
        }
        const isFree = Boolean(!this.shopProfile?.remaining_days_of_gold_package &&
            !this.shopProfile?.remaining_days_of_platinum_package &&
            !this.shopProfile?.remaining_days_of_premium_package &&
            !this.shopProfile?.remaining_days_of_bronze_package);
        if (isFree && this.shopProfile?.total_customers > maxUser) {
            this.isExpired = true;
        }
        else if (this.shopProfile?.total_customers >= maxUser) {
            this.isLimitReach = true;
        }
        else {
            this.isExpired = false;
            this.isLimitReach = false;
        }
    };
    handlePointEditClick = () => {
        this.pointEditFormData = {
            action: 'add',
            amount: '',
            pointType: '',
            conditionId: '',
            note: '',
        };
        this.isPointEditPopupOpen = true;
    };
    handleShareClick = () => {
        this.isShareMenuOpen = !this.isShareMenuOpen;
    };
    handleSaveImage = async () => {
        this.isShareMenuOpen = false;
        this.isLoadingShareMenu = true;
        try {
            const url = this.getImgProfile();
            const response = await fetch(url);
            const blob = await response.blob();
            const blobUrl = window.URL.createObjectURL(blob);
            const link = document.createElement('a');
            link.href = blobUrl;
            link.download = `zrmz-card-${this.customerInfo?.id || 'unknown'}.png`;
            document.body.appendChild(link);
            link.click();
            document.body.removeChild(link);
            window.URL.revokeObjectURL(blobUrl);
        }
        catch (error) {
            handleError(error);
        }
        finally {
            this.isLoadingShareMenu = false;
        }
    };
    handleSendToChat = async () => {
        this.isShareMenuOpen = false;
        this.isLoadingShareMenu = true;
        const selectedChat = selectedChatStore.get('selectedChat');
        await sendMessage({
            sessionId: selectedChat.id,
            messages: [{
                    type: 'image',
                    url: this.getImgProfile(),
                }],
        });
        this.isLoadingShareMenu = false;
    };
    getImgProfile() {
        const zwizPackageData = getZwizPackageData();
        if (zwizPackageData?.zrmz?.business_id && this.customerInfo?.id) {
            const timestamp = dayjs().format('x');
            const baseUrl = ZRMZ_API_URL();
            return `${baseUrl}/api/business/${zwizPackageData.zrmz?.business_id}/customer/${this.customerInfo.id}/card?${timestamp}&scale=2`;
        }
        return 'https://zwizai-platform.s3.ap-southeast-1.amazonaws.com/zignal-package/zrmz_card.png';
    }
    handlePointEditClose = () => {
        this.isPointEditPopupOpen = false;
    };
    handlePointEditSave = async (event) => {
        const formData = event.detail;
        const connectionId = getConnectionId();
        if (!connectionId || !this.profile?.zrm_customer_id) {
            handleError(new Error('Missing connection ID or customer ID'));
            return;
        }
        try {
            this.isPointUpdateLoading = true;
            if (formData.action === 'condition') {
                await adjustZrmzCustomerPointByCondition({
                    connectionId,
                    customer_id: this.profile.zrm_customer_id,
                    condition_id: formData.conditionId,
                    value: parseInt(formData.amount),
                });
            }
            else {
                await adjustZrmzCustomerPoint({
                    connectionId,
                    customer_id: this.profile.zrm_customer_id,
                    point_type: formData.pointType,
                    amount: parseInt(formData.amount),
                    action: formData.action,
                    remark: formData.note || undefined,
                });
            }
            await Promise.all([
                this.fetchCustomerInfo(connectionId, this.profile.zrm_customer_id),
                this.fetchPointHistory(connectionId, this.profile.zrm_customer_id),
            ]);
            this.isPointEditPopupOpen = false;
        }
        catch (error) {
            handleError(error, 'Failed to adjust customer points');
        }
        finally {
            this.isPointUpdateLoading = false;
        }
    };
    handleDisconnectClick = () => {
        const t = useTranslation();
        openDialog({
            open: true,
            title: t('chat_profile_view.zrmz.disconnect_confirm_title'),
            contentCustom: t('chat_profile_view.zrmz.disconnect_confirm_message'),
            type: "WARNING" /* DIALOG_TYPE.WARNING */,
            buttonName: t('confirm'),
            cancelButtonName: t('cancel'),
            onSubmitDialog: async () => {
                const selectedChat = selectedChatStore.get('selectedChat');
                const connectionId = getConnectionId();
                if (!connectionId || !this.profile?.zrm_customer_id) {
                    handleError(new Error('Missing connection ID or customer ID'));
                    closeDialog();
                    return;
                }
                try {
                    const response = await disconnectZrmzCustomer({
                        connectionId,
                        channel: selectedChat.channel,
                        user_id: selectedChat.user.id,
                        customer_id: this.profile.zrm_customer_id,
                    });
                    if (response.success) {
                        // Clear customer info and refresh profile
                        this.customerInfo = null;
                        this.lastZrmCustomerId = null;
                        await this.fetchProfile();
                        closeDialog();
                    }
                    else {
                        handleError(new Error(response.message || 'Failed to disconnect customer'));
                    }
                }
                catch (error) {
                    handleError(error, 'Failed to disconnect customer');
                }
            },
            onCloseDialog: () => closeDialog(),
        });
    };
    handleEditClick = () => {
        this.editFormData = {
            firstName: this.customerInfo?.first_name || '',
            lastName: this.customerInfo?.last_name || '',
            phoneNumber: this.customerInfo?.phone_number || '',
            email: this.customerInfo?.email || '',
            callingCode: this.customerInfo?.phone_number_country_code || '66',
        };
        this.isEditPopupOpen = true;
    };
    handleEditClose = () => {
        this.isEditPopupOpen = false;
    };
    handleEditSave = async () => {
        const connectionId = getConnectionId();
        if (!connectionId || !this.customerInfo?.id) {
            handleError(new Error('Missing connection ID or customer ID'));
            return;
        }
        try {
            this.isCustomerInfoLoading = true;
            const response = await updateZrmzCustomer({
                connectionId,
                customer_id: this.customerInfo.id,
                first_name: this.editFormData.firstName || undefined,
                last_name: this.editFormData.lastName || undefined,
                email: this.editFormData.email || undefined,
                phone_number: this.editFormData.phoneNumber || undefined,
                phone_number_country_code: this.editFormData.phoneNumber ? this.editFormData.callingCode : undefined,
            });
            if (response.success) {
                // Update local customer info with response data
                this.customerInfo = response.result;
                this.isEditPopupOpen = false;
            }
            else {
                handleError(new Error(response.message || 'Failed to update customer'));
            }
        }
        catch (error) {
            handleError(error, 'Failed to update customer information');
        }
        finally {
            this.isCustomerInfoLoading = false;
        }
    };
    hasFormChanged = () => {
        if (!this.customerInfo)
            return false;
        return (this.editFormData.firstName !== (this.customerInfo.first_name || '') ||
            this.editFormData.lastName !== (this.customerInfo.last_name || '') ||
            this.editFormData.phoneNumber !== (this.customerInfo.phone_number || '') ||
            this.editFormData.email !== (this.customerInfo.email || '') ||
            this.editFormData.callingCode !== (this.customerInfo.phone_number_country_code || '66'));
    };
    isHistoryLoading = false;
    lastConnectionId = null;
    lastZrmCustomerId = null;
    async componentWillLoad() {
        await this.fetchProfile();
    }
    async fetchProfile() {
        const selectedChat = selectedChatStore.get('selectedChat');
        const connectionId = getConnectionId();
        const connectionItem = getConnectionItem();
        if (connectionItem?.type !== 'zwiz' || connectionItem?.platform !== 'sme' || selectedChat.type !== 'user') {
            this.profile = null;
            this.shopProfile = null;
            this.customerInfo = null;
            this.pointHistory = null;
            return;
        }
        if (connectionId) {
            this.lastConnectionId = connectionId;
            try {
                this.isLoading = true;
                const [profile, shopProfile] = await Promise.all([
                    getZwizUserProfile(connectionId, selectedChat.channel, selectedChat.user.id),
                    getZrmzShopProfile(connectionId)
                ]);
                this.profile = profile;
                this.shopProfile = shopProfile.result;
                this.handleCheckPackage();
                // Fetch customer info if zrm_customer_id exists and has changed
                if (profile?.zrm_customer_id && profile.zrm_customer_id !== this.lastZrmCustomerId) {
                    await Promise.all([
                        this.fetchCustomerInfo(connectionId, profile.zrm_customer_id),
                        this.fetchPointHistory(connectionId, profile.zrm_customer_id),
                        this.fetchZrmzCondition(connectionId),
                    ]);
                }
            }
            catch (error) {
                handleError(error, 'Failed to get ZRMZ Profile');
            }
            finally {
                this.isLoading = false;
            }
        }
    }
    async fetchCustomerInfo(connectionId, zrmCustomerId) {
        try {
            const response = await getZrmzCustomerInfo(connectionId, zrmCustomerId);
            this.customerInfo = response.result;
            this.lastZrmCustomerId = zrmCustomerId;
        }
        catch (error) {
            handleError(error, 'Failed to get ZRMZ Customer Info');
        }
    }
    async fetchZrmzCondition(connectionId) {
        try {
            const response = await getZrmzCondition({ connectionId });
            this.zrmzCondition = response;
        }
        catch (error) {
            handleError(error, 'Failed to get ZRMZ Condition');
        }
    }
    async fetchPointHistory(connectionId, zrmCustomerId, loadMore = false) {
        if (this.isHistoryLoading)
            return;
        try {
            this.isHistoryLoading = true;
            const offset = loadMore && this.pointHistory ? this.pointHistory.transactions.length : 0;
            const response = await getZrmzPointHistory({ connectionId, customerId: zrmCustomerId, limit: 10, offset });
            if (loadMore && this.pointHistory) {
                this.pointHistory = {
                    ...response.result, // Update total
                    transactions: [...(this.pointHistory.transactions || []), ...(response.result.transactions || [])],
                };
            }
            else {
                this.pointHistory = response.result;
            }
        }
        catch (error) {
            handleError(error, 'Failed to get ZRMZ Point History');
        }
        finally {
            this.isHistoryLoading = false;
        }
    }
    async handleSendRegistrationLink() {
        const selectedChat = selectedChatStore.get('selectedChat');
        const connectionId = getConnectionId();
        const connectionItem = getConnectionItem();
        const t = useTranslation();
        if (!connectionId || !this.profile || !connectionItem) {
            return;
        }
        if (connectionItem.type !== 'zwiz' || connectionItem.platform !== 'sme' || !connectionItem.zwiz_package_data.zrmz?.shop_id) {
            return;
        }
        try {
            this.isGeneratingShopUrl = true;
            const response = await getZrmzShopUrl(connectionId, {
                channel: selectedChat.channel,
                user_id: selectedChat.user.id,
                zrmz_shop_profile_id: connectionItem.zwiz_package_data.zrmz?.shop_id,
                url_type: 'register',
            });
            if (response.url) {
                await sendMessage({
                    sessionId: selectedChat.id,
                    messages: [{
                            type: 'button',
                            text: t('chat_profile_view.zrmz.register_message'),
                            buttons: [
                                {
                                    id: 'zrmz-register-button',
                                    action_type: 'url',
                                    text: t('chat_profile_view.zrmz.register_button'),
                                    action: response.url,
                                }
                            ],
                        }],
                });
            }
        }
        catch (error) {
            const errorMessage = 'Failed to generate registration link';
            handleError(error, errorMessage);
        }
        finally {
            this.isGeneratingShopUrl = false;
        }
    }
    handleAdminRegistration = async () => {
        const t = useTranslation();
        const selectedChat = selectedChatStore.get('selectedChat');
        const connectionId = getConnectionId();
        const connectionItem = getConnectionItem();
        if (!connectionId || !connectionItem)
            return;
        if (connectionItem.type !== 'zwiz' || connectionItem.platform !== 'sme' || !connectionItem.zwiz_package_data.zrmz?.shop_id) {
            return;
        }
        try {
            this.isGeneratingShopUrl = true;
            const shopUrlResponse = await getZrmzShopUrl(connectionId, {
                channel: selectedChat.channel,
                user_id: selectedChat.user.id,
                zrmz_shop_profile_id: connectionItem.zwiz_package_data.zrmz?.shop_id,
                url_type: 'login',
            });
            this.adminRegisterFormData = {
                phoneNumber: '',
                email: '',
                callingCode: '66',
                isSendLoginLink: true,
                buttonTitle: t('chat_profile_view.zrmz.login_info'),
                buttonName: t('chat_profile_view.zrmz.login'),
                buttonLink: shopUrlResponse.url,
            };
            this.isAdminRegisterPopupOpen = true;
        }
        catch (error) {
            handleError(error, 'Failed to get ZRMZ Shop URL');
        }
        finally {
            this.isGeneratingShopUrl = false;
        }
    };
    handleAdminRegisterClose = () => {
        this.isAdminRegisterPopupOpen = false;
    };
    handleAdminRegisterSave = async (event) => {
        const formData = event.detail;
        const selectedChat = selectedChatStore.get('selectedChat');
        const connectionId = getConnectionId();
        const connectionItem = getConnectionItem();
        if (!connectionId || !connectionItem)
            return;
        try {
            this.isLoading = true;
            // Call API to create customer
            await createZrmzCustomer({
                connectionId,
                channel: selectedChat.channel,
                user_id: selectedChat.user.id,
                phone_number: formData.phoneNumber || undefined,
                phone_number_country_code: formData.phoneNumber ? (formData.callingCode || undefined) : undefined,
                email: formData.email || undefined,
            });
            // Send login link if selected
            if (formData.isSendLoginLink && formData.buttonLink) {
                await sendMessage({
                    sessionId: selectedChat.id,
                    messages: [{
                            type: 'button',
                            text: formData.buttonTitle,
                            buttons: [{
                                    id: 'login-btn',
                                    action_type: 'url',
                                    text: formData.buttonName,
                                    action: formData.buttonLink
                                }]
                        }]
                });
            }
            this.isAdminRegisterPopupOpen = false;
            this.adminRegisterFormData = formData;
            // Refresh profile to update UI
            await this.fetchProfile();
        }
        catch (error) {
            handleError(error, 'Failed to register admin');
        }
        finally {
            this.isLoading = false;
        }
    };
    getPoints() {
        const points = [];
        this.shopProfile?.membership_format_value?.forEach(point => {
            points.push({
                point_type: point,
                amount: this.customerInfo?.points?.find(p => p.point_type === point)?.amount || 0,
            });
        });
        return points;
    }
    renderAdminRegisterPopup() {
        return (h("admin-register-popup", { isOpen: this.isAdminRegisterPopupOpen, data: this.adminRegisterFormData, registerType: this.shopProfile?.register_type, onPopupClose: () => this.isAdminRegisterPopupOpen = false, onPopupSave: this.handleAdminRegisterSave, onFormDataChange: (e) => this.adminRegisterFormData = e.detail }));
    }
    renderMemberView() {
        const t = useTranslation();
        const pointOptions = this.shopProfile?.membership_format_value?.map(p => ({ label: p, value: p })) || [];
        const pointConditionOptions = this.zrmzCondition?.result.conditions?.filter(c => c.is_active).map(c => ({ label: c.name, value: c.id })) || [];
        return (h("div", null, h("customer-info-edit-popup", { isOpen: this.isEditPopupOpen, data: this.editFormData, saveEnabled: this.hasFormChanged(), isLoading: this.isCustomerInfoLoading, onPopupClose: this.handleEditClose, onPopupSave: this.handleEditSave, onFormDataChange: (e) => this.editFormData = e.detail }), h("div", { class: "zrmz-card relative" }, h("img", { src: this.getImgProfile(), alt: "ZRMZ Card", class: "zrmz-card-image", loading: "lazy" }), h("div", { class: "zrmz-icon-button", onClick: () => this.handleShareClick() }, this.isLoadingShareMenu ? h(Icon, { name: "Loader2", addClass: "text-primary size-5 animate-spin" }) : h(Icon, { name: "Share2", addClass: "text-primary size-5" })), this.isShareMenuOpen && (h("div", { class: "zrmz-share-menu-wrapper" }, h("div", { class: "zrmz-share-menu-backdrop", onClick: () => (this.isShareMenuOpen = false) }), h("div", { class: "zrmz-share-menu" }, h("div", { class: "zrmz-share-menu-item", onClick: () => this.handleSaveImage() }, t('chat_profile_view.zrmz.save_image')), h("div", { class: "zrmz-share-menu-item", onClick: () => this.handleSendToChat() }, t('chat_profile_view.zrmz.send_to_chat')))))), h("div", { class: "zrmz-point-section" }, h("point-update-popup", { isOpen: this.isPointEditPopupOpen, data: this.pointEditFormData, pointOptions: pointOptions, pointConditionOptions: pointConditionOptions, isLoading: this.isPointUpdateLoading, onPopupClose: this.handlePointEditClose, onPopupSave: this.handlePointEditSave, onFormDataChange: (e) => this.pointEditFormData = e.detail }), h("div", { class: "zrmz-point-edit-link underline cursor-pointer", onClick: () => this.handlePointEditClick() }, t('chat_profile_view.zrmz.update_point')), this.getPoints().map((point) => (h("div", { class: "zrmz-point-content" }, h("div", { class: "zrmz-point-label" }, point.point_type), h("div", { class: "zrmz-point-value" }, point.amount))))), h("div", { class: "zrmz-tabs" }, h("div", { class: `zrmz-tab ${this.activeTab === 'info' ? 'active' : ''}`, onClick: () => this.activeTab = 'info' }, t('chat_profile_view.zrmz.customer_info')), h("div", { class: `zrmz-tab ${this.activeTab === 'history' ? 'active' : ''}`, onClick: () => this.activeTab = 'history' }, t('chat_profile_view.zrmz.point_history'))), h("div", { class: "zrmz-tab-content" }, this.activeTab === 'info' ? (h("div", { class: "zrmz-info-content" }, h("div", { class: "zrmz-info-edit-icon", onClick: () => this.handleEditClick() }, h(Icon, { name: "Edit", addClass: "text-primary size-5" })), h("div", { class: "zrmz-info-content-inner" }, h("div", { class: "zrmz-info-item" }, h("div", { class: "zrmz-info-label" }, t('chat_profile_view.zrmz.name_surname')), h("div", { class: "zrmz-info-value" }, [this.customerInfo?.first_name, this.customerInfo?.last_name].filter(Boolean).join(' ') || '-')), h("div", { class: "zrmz-info-item" }, h("div", { class: "zrmz-info-label" }, t('chat_profile_view.zrmz.phone_number')), h("div", { class: "zrmz-info-value" }, this.customerInfo?.phone_number ? `+${this.customerInfo?.phone_number_country_code || ''}${this.customerInfo?.phone_number}` : '-')), h("div", { class: "zrmz-info-item" }, h("div", { class: "zrmz-info-label" }, t('chat_profile_view.zrmz.email')), h("div", { class: "zrmz-info-value" }, this.customerInfo?.email || '-'))), h("div", { class: "zrmz-expand-icon" }, h("div", { class: "zrmz-expand-circle", onClick: () => this.isExpand = !this.isExpand }, h(Icon, { name: this.isExpand ? 'ChevronUp' : 'ChevronDown', addClass: "text-white size-5" }))), this.isExpand && h("div", { class: "zrmz-disconnect-wrapper" }, h(ZButton, { variant: "outlined", fullWidth: true, onClick: () => this.handleDisconnectClick(), label: h("span", { class: "text-primary" }, t('chat_profile_view.zrmz.disconnect_member')) })))) : (h("div", { class: "zrmz-history-content" }, this.pointHistory?.transactions?.map((transaction) => (h("div", { class: "zrmz-history-item" }, h("div", { class: "zrmz-history-row" }, h("div", { class: "zrmz-history-action" }, transaction.action === 'add' ? t('add') : t('chat_profile_view.zrmz.remove')), h("div", { class: "zrmz-history-point" }, transaction.amount, " ", transaction.point_type)), h("p", { class: "zrmz-history-remark" }, transaction.remark), h("div", { class: "zrmz-history-date" }, displayDateTime(new Date(transaction.created_at)))))), this.pointHistory && (this.pointHistory.transactions?.length || 0) < this.pointHistory.total && (h("div", { class: "zrmz-load-more", onClick: () => this.fetchPointHistory(this.lastConnectionId, this.lastZrmCustomerId, true) }, this.isHistoryLoading ? t('chat_profile_view.zrmz.loading') : t('chat_profile_view.zrmz.load_more'))), !this.pointHistory?.transactions?.length && !this.isHistoryLoading && (h("div", { class: "text-center text-gray-500 py-4" }, t('chat_profile_view.zrmz.no_history'))))))));
    }
    renderLockOverlay() {
        const t = useTranslation();
        if (!this.isExpired && (!this.isLimitReach || this.getIsMember()))
            return null;
        return (h("div", { class: "zrmz-lock-overlay" }, h("div", { class: "zrmz-lock-content" }, h("div", { class: "zrmz-lock-icon" }, h(Icon, { name: "AlertCircle", addClass: "text-red-500 w-16 h-16" })), h("div", { class: "zrmz-lock-title" }, this.isExpired ? t('chat_profile_view.zrmz.package_expired') : t('chat_profile_view.zrmz.package_limit_reach')), h("div", { class: "zrmz-lock-desc", innerHTML: this.isExpired ? t('chat_profile_view.zrmz.upgrade_package_description') : t('chat_profile_view.zrmz.upgrade_package_description') }), h(ZButton, { variant: "primary", label: h("span", { class: "text-white" }, this.isExpired ? t('chat_profile_view.zrmz.upgrade_package') : t('chat_profile_view.zrmz.upgrade_package')), fullWidth: true, onClick: () => openWindow('https://zwiz.app/login') }))));
    }
    getIsMember() {
        return this.profile?.zrm_customer_id != null;
    }
    render() {
        const t = useTranslation();
        if (this.isLoading) {
            return (h(Host, null, h("div", { class: "flex justify-center items-center h-40" }, h(Icon, { name: "Loader2", addClass: "text-primary size-5 animate-spin" }))));
        }
        if (!this.profile) {
            return h(Host, null);
        }
        if (this.getIsMember()) {
            return (h(Host, null, h("div", { class: "zrmz-container" }, this.renderMemberView(), this.renderLockOverlay())));
        }
        return (h(Host, null, h("div", { class: "zrmz-container" }, this.renderLockOverlay(), this.renderAdminRegisterPopup(), h("div", { class: "zrmz-card" }, h("img", { src: "https://zwizai-platform.s3.ap-southeast-1.amazonaws.com/zignal-package/zrmz_card.png", alt: "ZRMZ Card", class: "zrmz-card-image", loading: "lazy" }), h("div", { class: "zrmz-icon-button", onClick: () => this.fetchProfile() }, h(Icon, { name: "RotateCw", addClass: "text-primary size-5" }))), h("div", { class: "zrmz-content" }, h("div", { class: "zrmz-status-text" }, t('chat_profile_view.zrmz.not_member')), h("div", { class: "zrmz-actions" }, h(ZButton, { variant: "outlined", disabled: this.isGeneratingShopUrl, label: h("span", { class: "text-primary" }, t('chat_profile_view.zrmz.send_registration_link')), fullWidth: true, onClick: () => this.handleSendRegistrationLink() }), h(ZButton, { variant: "outlined", disabled: this.isGeneratingShopUrl, label: h("span", { class: "text-primary" }, t('chat_profile_view.zrmz.admin_register')), fullWidth: true, onClick: () => this.handleAdminRegistration() }))))));
    }
    static get is() { return "profile-zrmz"; }
    static get originalStyleUrls() {
        return {
            "$": ["profile-zrmz.css"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["profile-zrmz.css"]
        };
    }
    static get states() {
        return {
            "profile": {},
            "shopProfile": {},
            "customerInfo": {},
            "pointHistory": {},
            "zrmzCondition": {},
            "isLoading": {},
            "isGeneratingShopUrl": {},
            "activeTab": {},
            "isExpand": {},
            "isEditPopupOpen": {},
            "editFormData": {},
            "isCustomerInfoLoading": {},
            "isPointEditPopupOpen": {},
            "isPointUpdateLoading": {},
            "isShareMenuOpen": {},
            "isLoadingShareMenu": {},
            "pointEditFormData": {},
            "isAdminRegisterPopupOpen": {},
            "adminRegisterFormData": {},
            "isExpired": {},
            "isLimitReach": {},
            "isHistoryLoading": {}
        };
    }
}
