{"version":3,"file":"match_image_snapshot_action.mjs","names":[],"sources":["../../../src/client/actions/match_image_snapshot_action.ts"],"sourcesContent":["import type { BrowserCommands } from 'vitest/browser'\nimport { assertSnapshotKeyWithoutDash } from '../../shared/asserts.ts'\nimport { isBase64String } from '../../shared/base64.ts'\nimport type {\n\tImageSnapshotNextIndexCommand,\n\tPrepareImageSnapshotComparisonCommand,\n} from '../../shared/commands.types.ts'\nimport type { ToMatchImageSnapshotOptions } from '../../shared/types.ts'\nimport { convertElementToCssSelector } from '../external/browser/selector.ts'\nimport { compareImageSnapshot } from '../snapshot/compare_image_snapshot.ts'\n\nexport async function matchImageSnapshotAction(\n\tcommands: BrowserCommands & PrepareImageSnapshotComparisonCommand & ImageSnapshotNextIndexCommand,\n\ttaskId: string,\n\tsubject: any,\n\toptions?: ToMatchImageSnapshotOptions<any>,\n) {\n\tassertSnapshotKeyWithoutDash(options?.snapshotKey)\n\n\tconst info = await commands.prepareImageSnapshotComparison(taskId, parseImageSnapshotSubject(subject), options)\n\n\treturn compareImageSnapshot(commands, taskId, info, options)\n}\n\nfunction parseImageSnapshotSubject(subject: any) {\n\tif (subject instanceof Element) return convertElementToCssSelector(subject)\n\tif (subject?.['selector']) return subject['selector']\n\tif (isBase64String(subject)) return subject\n\tthrow new Error(\n\t\t`'toMatchImageSnapshot()' expects the subject to be an element, locator, or image encoded in base64 string, but got: ${subject}`,\n\t)\n}\n"],"mappings":";;;;;;AAWA,eAAsB,yBACrB,UACA,QACA,SACA,SACC;AACD,8BAA6B,SAAS,YAAY;AAIlD,QAAO,qBAAqB,UAAU,QAFzB,MAAM,SAAS,+BAA+B,QAAQ,0BAA0B,QAAQ,EAAE,QAAQ,EAE3D,QAAQ;;AAG7D,SAAS,0BAA0B,SAAc;AAChD,KAAI,mBAAmB,QAAS,QAAO,4BAA4B,QAAQ;AAC3E,KAAI,UAAU,YAAa,QAAO,QAAQ;AAC1C,KAAI,eAAe,QAAQ,CAAE,QAAO;AACpC,OAAM,IAAI,MACT,uHAAuH,UACvH"}