{"version":3,"file":"jsonParser.mjs","names":[],"sources":["../../../../src/init/utils/jsonParser.ts"],"sourcesContent":["/**\n * Helper to parse JSON that may contain comments (tsconfig allows comments)\n */\nexport const parseJSONWithComments = (jsonString: string) => {\n  // First, try parsing as-is (most tsconfig files don't have comments)\n  try {\n    return JSON.parse(jsonString);\n  } catch {\n    // If that fails, try stripping comments\n    // Note: This simple approach removes comments line by line to avoid\n    // matching glob patterns like /* and */ that appear in paths\n  }\n\n  // Process line by line to safely remove comments\n  const lines = jsonString.split('\\n');\n  const cleanedLines = lines.map((line) => {\n    // Track if we're inside a string\n    let inString = false;\n    let result = '';\n\n    for (let i = 0; i < line.length; i++) {\n      const char = line[i];\n      const nextChar = line[i + 1];\n\n      // Handle string boundaries (accounting for escaped quotes)\n      if (char === '\"' && (i === 0 || line[i - 1] !== '\\\\')) {\n        inString = !inString;\n        result += char;\n        continue;\n      }\n\n      // If we're inside a string, keep the character\n      if (inString) {\n        result += char;\n        continue;\n      }\n\n      // Check for single-line comment outside of strings\n      if (char === '/' && nextChar === '/') {\n        // Rest of line is a comment, stop here\n        break;\n      }\n\n      // Check for multi-line comment start (/* ... */)\n      // For simplicity, we only handle single-line /* */ comments here\n      if (char === '/' && nextChar === '*') {\n        const endIndex = line.indexOf('*/', i + 2);\n        if (endIndex !== -1) {\n          // Skip the comment\n          i = endIndex + 1;\n          continue;\n        }\n      }\n\n      result += char;\n    }\n\n    return result;\n  });\n\n  return JSON.parse(cleanedLines.join('\\n'));\n};\n"],"mappings":";;;;AAGA,MAAa,yBAAyB,eAAuB;CAE3D,IAAI;EACF,OAAO,KAAK,MAAM,UAAU;CAC9B,QAAQ,CAIR;CAIA,MAAM,eADQ,WAAW,MAAM,IACN,EAAE,KAAK,SAAS;EAEvC,IAAI,WAAW;EACf,IAAI,SAAS;EAEb,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;GACpC,MAAM,OAAO,KAAK;GAClB,MAAM,WAAW,KAAK,IAAI;GAG1B,IAAI,SAAS,SAAQ,MAAM,KAAK,KAAK,IAAI,OAAO,OAAO;IACrD,WAAW,CAAC;IACZ,UAAU;IACV;GACF;GAGA,IAAI,UAAU;IACZ,UAAU;IACV;GACF;GAGA,IAAI,SAAS,OAAO,aAAa,KAE/B;GAKF,IAAI,SAAS,OAAO,aAAa,KAAK;IACpC,MAAM,WAAW,KAAK,QAAQ,MAAM,IAAI,CAAC;IACzC,IAAI,aAAa,IAAI;KAEnB,IAAI,WAAW;KACf;IACF;GACF;GAEA,UAAU;EACZ;EAEA,OAAO;CACT,CAAC;CAED,OAAO,KAAK,MAAM,aAAa,KAAK,IAAI,CAAC;AAC3C"}