-- Account managers (Sellers -> Account managers): the screen's texts, English and Arabic.
-- Safe to run more than once: a text that is already there is left alone.
-- Run after the migration 2026_11_01_000001_add_account_manager_permission, then: php artisan cache:clear

-- Arabic is stored under the code the database holds today: 'sa' until the migration
-- 2026_10_05_000001_convert_arabic_language_code_to_ar has run, 'ar' after it (App\Support\ArabicLanguageCode).
-- @ar is that code, so the Arabic texts below are read whichever side of the rename the server is on.
SET @ar := IF((SELECT COUNT(*) FROM `languages` WHERE `code` = 'sa') > 0, 'sa', 'ar');

INSERT INTO `translations` (`lang`, `lang_key`, `lang_value`, `created_at`, `updated_at`)
SELECT v.lang, v.k, v.val, NOW(), NOW() FROM (
  SELECT 'en' lang, 'account_managers' k, 'Account managers' val
  UNION ALL SELECT @ar, 'account_managers', 'مديرو الحسابات'
  UNION ALL SELECT 'en', 'staff_with_the_ecommerce_role_who_look_after_the_sellers_only_they_and_the_super_admin_can_log_in_as_a_seller', 'Staff with the E-commerce role who look after the sellers. Only they, and the Super Admin, can log in as a seller.'
  UNION ALL SELECT @ar, 'staff_with_the_ecommerce_role_who_look_after_the_sellers_only_they_and_the_super_admin_can_log_in_as_a_seller', 'موظفو دور التجارة الإلكترونية الذين يتولون متابعة التجّار. هم وحدهم، ومعهم المدير العام، يستطيعون الدخول إلى حساب تاجر.'
  UNION ALL SELECT 'en', 'add_account_manager', 'Add account manager'
  UNION ALL SELECT @ar, 'add_account_manager', 'إضافة مدير حساب'
  UNION ALL SELECT 'en', 'edit_account_manager', 'Edit account manager'
  UNION ALL SELECT @ar, 'edit_account_manager', 'تعديل مدير الحساب'
  UNION ALL SELECT 'en', 'the_ecommerce_role_does_not_exist_yet_create_it_under_staff_roles_first', 'The E-commerce role does not exist yet. Create it under Staff roles first.'
  UNION ALL SELECT @ar, 'the_ecommerce_role_does_not_exist_yet_create_it_under_staff_roles_first', 'دور التجارة الإلكترونية غير موجود بعد. أنشئه أولًا من أدوار الموظفين.'
  UNION ALL SELECT 'en', 'switched_off', 'Switched off'
  UNION ALL SELECT @ar, 'switched_off', 'متوقف'
  UNION ALL SELECT 'en', 'switch_on', 'Switch on'
  UNION ALL SELECT @ar, 'switch_on', 'تشغيل'
  UNION ALL SELECT 'en', 'switch_off', 'Switch off'
  UNION ALL SELECT @ar, 'switch_off', 'إيقاف'
  UNION ALL SELECT 'en', 'no_account_managers_yet', 'No account managers yet'
  UNION ALL SELECT @ar, 'no_account_managers_yet', 'لا يوجد مديرو حسابات بعد'
  UNION ALL SELECT 'en', 'the_account_manager_gets_the_ecommerce_role_they_can_manage_the_sellers_and_log_in_as_a_seller', 'The account manager gets the E-commerce role. They can manage the sellers and log in as a seller.'
  UNION ALL SELECT @ar, 'the_account_manager_gets_the_ecommerce_role_they_can_manage_the_sellers_and_log_in_as_a_seller', 'يحصل مدير الحساب على دور التجارة الإلكترونية، ويستطيع إدارة التجّار والدخول إلى حساب أي تاجر.'
  UNION ALL SELECT 'en', 'ecommerce', 'E-commerce'
  UNION ALL SELECT @ar, 'ecommerce', 'التجارة الإلكترونية'
  UNION ALL SELECT 'en', 'they_sign_in_to_the_dashboard_with_this_email', 'They sign in to the dashboard with this email.'
  UNION ALL SELECT @ar, 'they_sign_in_to_the_dashboard_with_this_email', 'يسجّل دخوله إلى لوحة التحكم بهذا البريد.'
  UNION ALL SELECT 'en', 'leave_empty_to_keep_the_current_password', 'Leave empty to keep the current password.'
  UNION ALL SELECT @ar, 'leave_empty_to_keep_the_current_password', 'اتركها فارغة للإبقاء على كلمة المرور الحالية.'
  UNION ALL SELECT 'en', 'account_manager_has_been_added_successfully', 'Account manager has been added successfully'
  UNION ALL SELECT @ar, 'account_manager_has_been_added_successfully', 'تمت إضافة مدير الحساب بنجاح'
  UNION ALL SELECT 'en', 'account_manager_has_been_updated_successfully', 'Account manager has been updated successfully'
  UNION ALL SELECT @ar, 'account_manager_has_been_updated_successfully', 'تم تحديث مدير الحساب بنجاح'
  UNION ALL SELECT 'en', 'account_manager_has_been_switched_on', 'Account manager has been switched on'
  UNION ALL SELECT @ar, 'account_manager_has_been_switched_on', 'تم تشغيل مدير الحساب'
  UNION ALL SELECT 'en', 'account_manager_has_been_switched_off', 'Account manager has been switched off'
  UNION ALL SELECT @ar, 'account_manager_has_been_switched_off', 'تم إيقاف مدير الحساب'
  UNION ALL SELECT 'en', 'you_cannot_switch_off_your_own_account', 'You cannot switch off your own account'
  UNION ALL SELECT @ar, 'you_cannot_switch_off_your_own_account', 'لا يمكنك إيقاف حسابك أنت'
  UNION ALL SELECT 'en', 'only_an_account_manager_can_log_in_as_a_seller', 'Only an account manager can log in as a seller'
  UNION ALL SELECT @ar, 'only_an_account_manager_can_log_in_as_a_seller', 'وحده مدير الحساب يستطيع الدخول إلى حساب تاجر'
  UNION ALL SELECT 'en', 'max_30_character', 'Max 30 Character'
  UNION ALL SELECT @ar, 'max_30_character', 'الحد الأقصى 30 حرفًا'
  UNION ALL SELECT 'en', 'password_is_required', 'Password is required'
  UNION ALL SELECT @ar, 'password_is_required', 'كلمة المرور مطلوبة'
  UNION ALL SELECT 'en', 'the_password_must_be_at_least_8_characters', 'The password must be at least 8 characters'
  UNION ALL SELECT @ar, 'the_password_must_be_at_least_8_characters', 'يجب ألا تقل كلمة المرور عن 8 أحرف'
) v
WHERE NOT EXISTS (SELECT 1 FROM `translations` t WHERE t.lang = v.lang AND t.lang_key = v.k);
