'use strict';
import { anyRoleExists } from '../auth/role-db.js';
import { seedRolesDirectlyInDb } from '../auth/role-master-data.js';
import { seedPermissionsDirectlyInDb } from '../auth/permission-master-data.js';
import { seedContacts } from '../demo/contacts/contact-master-data.js';
import { seedLeads } from '../leads/lead-master-data.js';
import { seedLeadEmails } from '../leads/lead-email-master-data.js';
import { seedLeadToLeadCategories } from '../leads/lead-to-lead-category-master-data.js';
import { seedLeadCategories } from '../leads/lead-category-master-data.js';
import { seedLeadGroups } from '../leads/lead-group-master-data.js';
import { seedLeadToLeadGroups } from '../leads/lead-to-lead-group-master-data.js';
import { seedDeals } from '../demo/deals/deal-master-data.js';
import { seedTickets } from '../demo/tickets/ticket-master-data.js';
import { workspaceConstants } from '../../../fd-toolbox/server/constants/workspace-constants.js';
import { setCurrentWorkspaceId } from '../../meta/server/providers/current-workspace-id-provider.js';
import { getBooleanEnvSetting } from '../../../fd-toolbox/infra/env-functions.js';
import { seedReports } from '../reports/report-master-data.js';
import { seedComments } from '../comments/comment-master-data.js';
import { seedCompanies } from '../demo/companies/company-master-data.js';
import { seedJobs } from '../dev/jobs/job-master-data.js';
import { seedPaperPlanes } from '../dev/paper-planes/paper-plane-master-data.js';
import { seedPersons } from '../dev/persons/person-master-data.js';
import { seedPersonToJobs } from '../dev/persons/person-to-job-master-data.js';
import { seedPersonToPersons } from '../dev/persons/person-to-person-master-data.js';
import { seedPhoneBrands } from '../dev/phone-brands/phone-brand-master-data.js';
import { logInfo } from '../../../fd-toolbox/server/logging/logger.js';
import { seedNotifications } from '../fd/fd-toolbox-web/seeding/notification-master-data.js';
import { seedResourcesDirectlyInDb } from '../fd/fd-toolbox-web/seeding/resource-master-data.js';
import { seedResourcePropertiesDirectlyInDb } from '../fd/fd-toolbox-web/seeding/resource-property-master-data.js';
import { seedWorkspaces, seedDefaultWorkspaceDirectlyInDb } from '../fd/fd-toolbox-web/seeding/workspace-master-data.js';
import { seedFeatures, seedBasicPlanFeatures, seedPremiumPlanFeatures, seedEnterprisePlanFeatures } from '../features/feature-master-data.js';
import { seedFeedEntries } from '../feeds/feed-entry-data.js';
import { seedPaymentPlans, seedDemoPaymentPlans } from '../payments/payments/payment-plan-master-data.js';
import { seedSystemSettings } from '../system-settings/system-master-data.js';
import { seedUsers, seedOtherUsersInfo, seedWorkerBotDirectlyInDb } from '../users/user-master-data.js';
import { seedStatusBoards } from '../features/status-board-master-data.js';
import { seedStores } from '../store/store-master-data.js';
import { seedProducts } from '../products/product-master-data.js';
import { seedCustomers } from '../customers/customer-master-data.js';
import { seedOrders } from '../orders/order-master-data.js';
import { getDotenvConfig } from '../../../fd-toolbox/infra/env-config.js';
import { seedCountries } from '../addresses/country-master-data.js';
import { seedAddresses } from '../addresses/address-master-data.js';
import { seedShipments } from '../shipment/shipment-master-data.js';
import { seedProductMedias } from '../products/product-media/product-media-master-data.js';
import { seedDashboardReports } from '../dashboards/dashboard-report-master-data.js';
import { seedPings } from '../dev/pings/ping-master-data.js';
import { seedDevGreetings } from '../dev/dev-greeting/dev-greeting-master-data.js';
import { seedAiAssistants } from '../dev/ai-assistant/ai-assistant-master-data.js';
import { seedDashboards } from '../dashboards/dashboard-master-data.js';
import { seedFriends } from '../dev/friends/friend-master-data.js';
import { isTemporaryDisabled } from '../../../fd-toolbox/functions/condition-check-functions.js';
import { syncPaymentPlansAndPricesAfterSeeding } from '../payments/stripe/stripe-sync.js';
import { setCurrentUserId } from '../../meta/server/auth/users/current-user-id-provider.js';
import { toolboxUserConstants } from '../../meta/constants/toolbox-users.js';
import { seedReportChartSeries } from '../reports/report-chart-series-master-data.js';
import { toolboxEnvSettingKeys } from '../../../fd-toolbox/infra/toolbox-env-setting-keys.js';
import { seedLanguages } from '../fd/fd-toolbox-web/localization/language/language-master-data.js';
import { configureResourcePermissions, addPermissionIds, seedPermissionPackageToPermissionIfNotExist } from '../fd/fd-toolbox-web/permissions/fd-permission-master-data.js';
import { permissionPackages } from '../../common/auth/permissions/permission-constants.js';
import { permissionActions } from '../../meta/core/resources/enums/permission-enums.js';

var __defProp=Object['defineProperty'],__name=(_0xefc3c5,_0x2cc9f1)=>__defProp(_0xefc3c5,'name',{'value':_0x2cc9f1,'configurable':!![]});async function seed(_0x30ceea,_0x1b36ab){getDotenvConfig(),setCurrentWorkspaceId(workspaceConstants['defaultWorkspaceId']);const _0x1b9b7b=!await anyRoleExists();if(_0x1b9b7b){await seedEarlyResourcesDirectlyInDb(),await seedResources(),await seedReports(),await seedReportChartSeries(),await seedDashboards(),await seedDashboardReports(),await seedSystemSettings(),await seedStatusBoards(),await seedDemoResources(),await seedDevResources(),await seedCountries(),await seedLanguages();if(_0x30ceea)for(const _0x3de95e of _0x30ceea){await _0x3de95e();}if(_0x1b36ab){const _0x6fcc75=new Map(),_0x3b6f53=_0x1b36ab['map'](([_0x3733a4])=>_0x3733a4);await seedResourcesDirectlyInDb(_0x1b36ab),await configureResourcePermissions(_0x3b6f53,_0x6fcc75);const _0x5bf645=[];addPermissionIds(_0x3b6f53,permissionActions['create'],_0x5bf645,_0x6fcc75),await seedPermissionPackageToPermissionIfNotExist(permissionPackages['generalId'],_0x5bf645);}await seedResourcePropertiesDirectlyInDb(),await seedPaymentPlans(),await syncPaymentPlansAndPricesAfterSeeding(),await seedComments();}}__name(seed,'seed');async function seedResources(){await seedWorkspaces(),await seedUsers();const _0x3dfbee=await seedFeatures();await seedOtherUsersInfo(_0x3dfbee);}__name(seedResources,'seedResources');async function seedEarlyResourcesDirectlyInDb(){await seedRolesDirectlyInDb(),await seedDefaultWorkspaceDirectlyInDb(),await seedWorkerBotDirectlyInDb(),setCurrentUserId(toolboxUserConstants['workerBotId']),await seedResourcesDirectlyInDb(),await seedResourcePropertiesDirectlyInDb(),await seedPermissionsDirectlyInDb();}__name(seedEarlyResourcesDirectlyInDb,'seedEarlyResourcesDirectlyInDb');async function seedDemoResources(){if(!getBooleanEnvSetting(toolboxEnvSettingKeys['seedDemoResources']))return;logInfo('Seeding\x20demo\x20resources'),await seedCompanies(),await seedContacts(),await seedDeals(),await seedTickets(),await seedFeatures(),await seedBasicPlanFeatures(),await seedPremiumPlanFeatures(),await seedEnterprisePlanFeatures(),await seedDemoPaymentPlans(),await seedNotifications(),await seedFeedEntries(),!isTemporaryDisabled()&&(await seedCustomers(),await seedStores(),await seedProducts(),await seedOrders(),await seedShipments(),await seedProductMedias(),await seedAddresses(),await seedLeads(),await seedLeadEmails(),await seedLeadCategories(),await seedLeadToLeadCategories(),await seedLeadGroups(),await seedLeadToLeadGroups());}__name(seedDemoResources,'seedDemoResources');async function seedDevResources(){if(!getBooleanEnvSetting(toolboxEnvSettingKeys['seedDevResources']))return;logInfo('Seeding\x20dev\x20resources'),await seedJobs(),await seedPings(),await seedDevGreetings(),await seedPaperPlanes(),await seedPhoneBrands(),await seedAiAssistants(),await seedPersons(),await seedPersonToPersons(),await seedPersonToJobs(),await seedFriends();}__name(seedDevResources,'seedDevResources');

export { seed, seedEarlyResourcesDirectlyInDb, seedResources };
