{"version":3,"file":"mock-speech-model.mjs","names":[],"sources":["../../../../../../../ai/src/mock/mock-speech-model.ts"],"sourcesContent":["import type {\n  GeneratedAudio,\n  SpeechGenerationResponse,\n  SpeechModelContract,\n  SpeechModelPricing,\n  SpeechOptions,\n} from \"../contracts/speech-model.contract\";\nimport type { Usage } from \"../contracts/result/usage.type\";\n\n/** One scripted response for a {@link MockSpeechModel}. */\nexport type MockSpeechResponse = {\n  audio?: GeneratedAudio;\n  usage?: Usage;\n  /** Characters synthesized; defaults to the input text length. */\n  characters?: number;\n  error?: Error;\n  delay?: number;\n};\n\n/** One recorded `generate()` invocation, for test assertions. */\nexport type MockSpeechCall = { text: string; options: SpeechOptions | undefined };\n\n/** Deterministic {@link SpeechModelContract} double for tests — no HTTP. */\nexport class MockSpeechModel implements SpeechModelContract {\n  public readonly provider = \"mock\";\n  public readonly calls: MockSpeechCall[] = [];\n\n  private callIndex = 0;\n\n  public constructor(\n    public readonly name: string,\n    private readonly responses: MockSpeechResponse[],\n    public readonly pricing?: SpeechModelPricing,\n  ) {}\n\n  public async generate(text: string, options?: SpeechOptions): Promise<SpeechGenerationResponse> {\n    this.calls.push({ text, options });\n\n    const response = this.responses[Math.min(this.callIndex, this.responses.length - 1)] ?? {};\n    this.callIndex += 1;\n\n    if (response.delay) {\n      await new Promise((resolve) => setTimeout(resolve, response.delay));\n    }\n    if (response.error) {\n      throw response.error;\n    }\n\n    return {\n      audio: response.audio ?? { type: \"base64\", base64: \"AAAA\", mediaType: \"audio/mpeg\" },\n      usage: response.usage ?? { input: 0, output: 0, total: 0 },\n      characters: response.characters ?? text.length,\n    };\n  }\n}\n"],"mappings":";;AAuBA,IAAa,kBAAb,MAA4D;CAM1D,AAAO,YACL,AAAgB,MAChB,AAAiB,WACjB,AAAgB,SAChB;EAHgB;EACC;EACD;kBARS;eACe,CAAC;mBAEvB;CAMjB;CAEH,MAAa,SAAS,MAAc,SAA4D;EAC9F,KAAK,MAAM,KAAK;GAAE;GAAM;EAAQ,CAAC;EAEjC,MAAM,WAAW,KAAK,UAAU,KAAK,IAAI,KAAK,WAAW,KAAK,UAAU,SAAS,CAAC,MAAM,CAAC;EACzF,KAAK,aAAa;EAElB,IAAI,SAAS,OACX,MAAM,IAAI,SAAS,YAAY,WAAW,SAAS,SAAS,KAAK,CAAC;EAEpE,IAAI,SAAS,OACX,MAAM,SAAS;EAGjB,OAAO;GACL,OAAO,SAAS,SAAS;IAAE,MAAM;IAAU,QAAQ;IAAQ,WAAW;GAAa;GACnF,OAAO,SAAS,SAAS;IAAE,OAAO;IAAG,QAAQ;IAAG,OAAO;GAAE;GACzD,YAAY,SAAS,cAAc,KAAK;EAC1C;CACF;AACF"}