export type SettingSubsectionDef = { id: string title: string match: (key: string) => boolean } export type SettingGroupDef = { id: string title: string icon: string match: (key: string) => boolean /** زیربخش‌های داخل گروه (مثلاً روش‌های واریز) */ subsections?: SettingSubsectionDef[] } /** گروه‌های صفحه تنظیمات عادی (فقط can_edit=1) */ export const EDITABLE_SETTING_GROUPS: SettingGroupDef[] = [ { id: 'general', title: 'عمومی و برند', icon: 'vuesax-linear:home-2', match: (k) => /^(name_fa|name_en|bace_url|server_url|logo_|title_pwa|title_fav|open_register|auto_active_customer|store_status|key$)$/.test( k ) }, { id: 'customer_features', title: 'دسترسی مشتری به قابلیت‌ها', icon: 'vuesax-linear:people', match: (k) => /^(banner_enabled|tracking_systems_enabled|jibit_verification|register_jibit_verify|show_product_details|show_product_trade_status|show_product_card_meta|products_site_link_enabled|products_site_link_url|products_site_link_text|has_chat)$/.test(k) }, { id: 'trading_hours', title: 'ساعت کاری و نمایش قیمت', icon: 'vuesax-linear:clock', match: (k) => /^(close_price|startDay|endDay|show_last_price|show_home_price_when_closed|show_gold_ounce_price)$/.test( k ) }, { id: 'fees', title: 'کارمزدها', icon: 'vuesax-linear:dollar-circle', match: (k) => /^(fee_|buy_fee|sell_fee|up_price|down_price|price_extreme_date)/.test(k) || k.includes('charge_percentage') }, { id: 'limits', title: 'محدودیت‌ها', icon: 'vuesax-linear:lock', match: (k) => /^(min_|minimum_|balance_report_exclude)/.test(k) }, { id: 'price_source', title: 'منبع قیمت و تابلو', icon: 'vuesax-linear:chart-2', match: (k) => /^(price_provider|zaarbox_|main_product$)/.test(k) }, { id: 'content', title: 'متن‌های اپ', icon: 'vuesax-linear:document-text', match: (k) => /^text_/.test(k) }, { id: 'referral', title: 'معرف و پاداش', icon: 'vuesax-linear:people', match: (k) => /^(referral_|gift_for|register_referral|referral_bonus|invite_link_text)/.test( k ) }, { id: 'montzar', title: 'همکار Montzar', icon: 'vuesax-linear:link-2', match: (k) => (k.startsWith('montzar_') && !['montzar_base_url', 'montzar_closed'].includes(k)) || k === 'display_montzar' }, { id: 'store', title: 'سفارش خارجی', icon: 'vuesax-linear:shop', match: (k) => /^external_order/.test(k) }, { id: 'deposit_methods', title: 'روش‌های واریز', icon: 'vuesax-linear:card-send', match: (k) => k.startsWith('deposit_method_') || k === 'deposit_account_holder' || k === 'deposit_card_number' || k === 'deposit_account_number' || k === 'deposit_sheba', subsections: [ { id: 'card_to_card', title: 'کارت به کارت', match: (k) => k === 'deposit_method_card_to_card' || k === 'deposit_account_holder' || k === 'deposit_card_number' || k === 'deposit_account_number' || k === 'deposit_sheba', }, { id: 'gateway', title: 'درگاه پرداخت', match: (k) => k === 'deposit_method_gateway', }, { id: 'identified', title: 'شناسه واریز', match: (k) => k === 'deposit_method_identified', }, { id: 'shetab', title: 'شبکه شتابی', match: (k) => k === 'deposit_method_shetab', }, ], }, { id: 'support', title: 'پشتیبانی', icon: 'vuesax-linear:headphone', match: (k) => k === 'support_messengers' || k.startsWith('support_messenger_') || k === 'deposit_sms_support_number' || k === 'deposit_support_message_text', }, { id: 'bots', title: 'بات‌ها', icon: 'vuesax-linear:messages-2', match: (k) => /^(telegram_bot|bale_bot|rubika_bot)/.test(k) }, { id: 'price_channel', title: 'ارسال قیمت به کانال', icon: 'vuesax-linear:send-2', match: (k) => /^price_channel_/.test(k) || k === 'change_mesghal' }, { id: 'notifications', title: 'پیامک و اعلان', icon: 'vuesax-linear:notification', match: (k) => k === 'charge_notif' || k === 'register_referral_sms_to_referrer' || /^sms_notif_/.test(k) }, { id: 'features', title: 'قابلیت‌های سیستم', icon: 'vuesax-linear:setting-2', match: (k) => /^(product_|main_wallet_products|require_zero_main_gold_before_other_buy|profit_gold)/.test(k) }, { id: 'misc', title: 'سایر', icon: 'vuesax-linear:more-circle', match: () => true } ] /** گروه‌های صفحه دیپلوی — شامل تنظیمات can_edit=0 */ export const SYSTEM_SETTING_GROUPS: SettingGroupDef[] = [ { id: 'customer_features', title: 'دسترسی مشتری به قابلیت‌ها', icon: 'vuesax-linear:people', match: (k) => /^(enable_conditional_order|enable_product_funds|has_page_price_trigger|has_page_notification|has_page_gift_card|enable_customer_level_profit|banner_enabled|jibit_enabled|customer_direct_sms|has_page_earn_money|group_sms|tracking_systems_enabled|permision__enabled|show_to_users_chat)$/.test( k ) }, { id: 'support_chat', title: 'چت پشتیبانی', icon: 'vuesax-linear:messages-2', match: (k) => /^(chat_api|chat_api_key|chat_upload_url|chat_download_url)$/.test(k) }, { id: 'general', title: 'عمومی و برند', icon: 'vuesax-linear:home-2', match: (k) => /^(name_fa|name_en|app_url|admin_url|apk_download_link|bace_url|server_url|logo_|title_pwa|title_fav|metal_type|main_metal|unit$|open_register|auto_active_customer|store_status|key$|is_store|sms_panel|main_wallet_products)/.test( k ) }, { id: 'chart', title: 'نمودار قیمت', icon: 'vuesax-linear:chart-2', match: (k) => /^chart_/.test(k) }, { id: 'pricing', title: 'منبع قیمت و تابلو', icon: 'vuesax-linear:dollar-circle', match: (k) => /^(price_provider|zaarbox_|main_product$)/.test(k) || k.includes('charge_percentage') }, { id: 'montzar', title: 'Montzar', icon: 'vuesax-linear:link-2', match: (k) => /^montzar_/.test(k) || k === 'display_montzar' }, { id: 'store', title: 'اتصال فروشگاه', icon: 'vuesax-linear:shop', match: (k) => /^node_/.test(k) || k === 'montify_name' || k === 'external_order_api_enabled' }, { id: 'deposit_methods', title: 'روش‌های واریز', icon: 'vuesax-linear:card-send', match: (k) => k.startsWith('external_payment_') || k === 'wallet_payment_provider', subsections: [ { id: 'gateway', title: 'درگاه فروشگاه / پرداخت آنلاین', match: (k) => k.startsWith('external_payment_') || k === 'wallet_payment_provider', }, ], }, { id: 'payping', title: 'درگاه Payping', icon: 'vuesax-linear:card', match: (k) => k.startsWith('payping_') }, { id: 'accounting_provider', title: 'انتخاب سیستم حسابداری', icon: 'vuesax-linear:receipt-2', match: (k) => k === 'accounting_provider' }, { id: 'accounting_zarin', title: 'حسابداری زرین', icon: 'vuesax-linear:card-pos', match: (k) => k.startsWith('zarin_') }, { id: 'accounting_tahesab', title: 'حسابداری ته‌حساب', icon: 'vuesax-linear:calculator', match: (k) => k.startsWith('tahesab_') || k === 'send_to_tahesab' }, { id: 'accounting_pargar', title: 'حسابداری پرگار', icon: 'vuesax-linear:document-text', match: (k) => k.startsWith('pargar_') || k === 'send_to_pargar' }, { id: 'price_channel', title: 'ارسال قیمت به کانال', icon: 'vuesax-linear:send-2', match: (k) => /^price_channel_/.test(k) || /^(telegram_bot|bale_bot|rubika_bot)/.test(k) || k === 'change_mesghal' }, { id: 'infra', title: 'زیرساخت', icon: 'vuesax-linear:cpu', match: (k) => /^(wss_enabled|sse_path|profit_gold_api_enabled)$/.test(k) }, { id: 'misc', title: 'سایر', icon: 'vuesax-linear:more-circle', match: () => true } ] export function getSettingGroupId(key: string, groups: SettingGroupDef[]): string { for (const g of groups) { if (g.id === 'misc') continue if (g.match(key)) return g.id } return 'misc' } export function getSettingSubsectionId( key: string, group: SettingGroupDef | undefined ): string | null { if (!group?.subsections?.length) return null for (const sub of group.subsections) { if (sub.match(key)) return sub.id } return null }