{"version":3,"sources":["/home/mkabumattar/work/withrawi/rawi/dist/chunk-LSK3BZJV.cjs","../src/cli/commands/ask/actions/session-management.ts"],"names":["validateProfile","profile","options","isConfigured","chalk","handleSession","dbManager","sessionId"],"mappings":"AAAA;AACA,wDAA0C,wDAAyC,4ECDjE,IAKLA,CAAAA,CAAkB,CAACC,CAAAA,CAAiBC,CAAAA,CAAAA,EAAuB,CACjEC,iCAAAA,CAAoB,CAAA,EAAA,CACnBD,CAAAA,CAAQ,OAAA,EAAA,CACV,OAAA,CAAQ,KAAA,CACNE,eAAAA,CAAM,GAAA,CACJ,CAAA,gBAAA,EAAcH,CAAO,CAAA,+CAAA,CACvB,CACF,CAAA,CACA,OAAA,CAAQ,KAAA,CACNG,eAAAA,CAAM,MAAA,CACJ,CAAA,uBAAA,EAA0BH,CAAO,CAAA,yBAAA,CACnC,CACF,CAAA,CAAA,CAEF,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA,CAElB,CAAA,CAEaI,CAAAA,aAAgB,KAAA,CAC3BC,CAAAA,CACAL,CAAAA,CACAC,CAAAA,CAAAA,EACoB,CACpB,IAAIK,CAAAA,CAEJ,EAAA,CAAIL,CAAAA,CAAQ,UAAA,CACVK,CAAAA,CAAY,MAAMD,CAAAA,CAAU,aAAA,CAAcL,CAAO,CAAA,CAC7CC,CAAAA,CAAQ,OAAA,EACV,OAAA,CAAQ,GAAA,CAAIE,eAAAA,CAAM,GAAA,CAAI,CAAA,+BAAA,EAA2BG,CAAS,CAAA,CAAA;AD/B4Y","file":"/home/mkabumattar/work/withrawi/rawi/dist/chunk-LSK3BZJV.cjs","sourcesContent":[null,"import chalk from 'chalk';\nimport {getCredentials, isConfigured} from '../../../../core/configs/utils.js';\nimport type {DatabaseManager} from '../../../../core/database/manager.js';\nimport {spinnerManager} from '../../../../core/shared/spinner.js';\n\nexport const validateProfile = (profile: string, options: any): void => {\n  if (!isConfigured(profile)) {\n    if (options.verbose) {\n      console.error(\n        chalk.red(\n          `❌ Profile '${profile}' does not exist or is not properly configured.`,\n        ),\n      );\n      console.error(\n        chalk.yellow(\n          `Run 'rawi configure -p ${profile}' to set up this profile.`,\n        ),\n      );\n    }\n    process.exit(1);\n  }\n};\n\nexport const handleSession = async (\n  dbManager: DatabaseManager,\n  profile: string,\n  options: any,\n): Promise<string> => {\n  let sessionId: string;\n\n  if (options.newSession) {\n    sessionId = await dbManager.createSession(profile);\n    if (options.verbose) {\n      console.log(chalk.dim(`🆕 Started new session: ${sessionId}`));\n    }\n  } else if (options.session) {\n    sessionId = options.session;\n    const session = await dbManager.getSession(sessionId);\n    if (!session) {\n      if (options.verbose) {\n        console.error(chalk.red(`❌ Session '${sessionId}' not found.`));\n      }\n      process.exit(1);\n    }\n    if (session.profile !== profile) {\n      if (options.verbose) {\n        console.error(\n          chalk.red(\n            `❌ Session '${sessionId}' belongs to profile '${session.profile}', not '${profile}'.`,\n          ),\n        );\n      }\n      process.exit(1);\n    }\n    if (options.verbose) {\n      console.log(chalk.dim(`🔄 Continuing session: ${sessionId}`));\n    }\n  } else {\n    sessionId = await dbManager.getCurrentSession(profile);\n    if (options.verbose) {\n      console.log(chalk.dim(`📝 Using current session: ${sessionId}`));\n    }\n  }\n\n  return sessionId;\n};\n\nexport const validateCredentials = (profile: string, options: any): any => {\n  if (options.verbose) {\n    spinnerManager.start('validation', 'Validating configuration...');\n  }\n\n  const credentials = getCredentials(profile);\n\n  if (!credentials) {\n    if (options.verbose) {\n      spinnerManager.fail('validation', 'Configuration validation failed');\n      console.error(\n        chalk.red(`❌ Unable to load credentials for profile '${profile}'.`),\n      );\n    }\n    process.exit(1);\n  }\n\n  if (options.verbose) {\n    spinnerManager.succeed(\n      'validation',\n      'Configuration validated successfully',\n    );\n  }\n\n  return credentials;\n};\n\nexport const logProcessingInfo = (\n  profile: string,\n  filteredQuery: string,\n  options: any,\n): void => {\n  if (options.verbose) {\n    console.log(`Using profile: ${profile}`);\n    console.log(\n      `Processing query: ${filteredQuery.length > 100 ? `${filteredQuery.substring(0, 100)}...` : filteredQuery}`,\n    );\n  }\n};\n"]}