{"version":3,"file":"pic-json-command.mjs","names":[],"sources":["../../src/commands/pic-json-command.ts"],"sourcesContent":["import type { Command } from 'commander';\n\nimport { decompress, parsePic } from '@4bitlabs/sci0';\nimport { cmdIntParser } from './cmd-int-parser.js';\nimport { getRootOptions } from '../actions/get-root-options.js';\nimport { loadContentFromMap } from '../actions/load-content-from-map.js';\nimport { picMatcher } from '../helpers/resource-matchers.js';\n\nexport function picJSONCommand(cmd: Command): Command {\n  cmd\n    .command('json', { hidden: true })\n    .argument('<num>', 'Picture resource number', cmdIntParser)\n    .action(async (id: number, _: unknown, command: Command) => {\n      const { root, engine } = getRootOptions(command);\n\n      const [header, compressed] = await loadContentFromMap(\n        root,\n        picMatcher(id),\n      );\n      const picData = decompress(engine, header.compression, compressed);\n      const pic = parsePic(picData);\n      console.log(JSON.stringify(pic));\n    })\n    .description('dump the pic data as JSON');\n\n  return cmd;\n}\n"],"mappings":";;;;;;AAQA,SAAgB,eAAe,KAAuB;CACpD,IACG,QAAQ,QAAQ,EAAE,QAAQ,KAAK,CAAC,CAAC,CACjC,SAAS,SAAS,2BAA2B,YAAY,CAAC,CAC1D,OAAO,OAAO,IAAY,GAAY,YAAqB;EAC1D,MAAM,EAAE,MAAM,WAAW,eAAe,OAAO;EAE/C,MAAM,CAAC,QAAQ,cAAc,MAAM,mBACjC,MACA,WAAW,EAAE,CACf;EACA,MAAM,UAAU,WAAW,QAAQ,OAAO,aAAa,UAAU;EACjE,MAAM,MAAM,SAAS,OAAO;EAC5B,QAAQ,IAAI,KAAK,UAAU,GAAG,CAAC;CACjC,CAAC,CAAC,CACD,YAAY,2BAA2B;CAE1C,OAAO;AACT"}