{
  "version": 3,
  "sources": ["../../../../src/utils/transactions/getDecodedDataField/getDecodedDataField.ts"],
  "sourcesContent": ["import { MAX_DECODE_TX_DATA_LENGTH } from 'constants/transactions.constants';\nimport {\n  DecodeMethodEnum,\n  DecodedDisplayType\n} from 'types/serverTransactions.types';\nimport { decodeByMethod } from './helpers/decodeByMethod';\nimport { decodeHighlight } from './helpers/decodeHighlight';\nimport { getDecodedParts } from './helpers/getDecodedParts';\nimport { getDisplayValueAndValidationWarnings } from './helpers/getDisplayValueAndValidationWarnings';\n\ninterface IDecodedDataField {\n  data: string;\n  decodeMethod: DecodeMethodEnum;\n  identifier?: string;\n  highlight?: string | null;\n}\n\nexport const getDecodedDataField = ({\n  data,\n  decodeMethod,\n  identifier,\n  highlight = null\n}: IDecodedDataField): DecodedDisplayType => {\n  const decodedData: DecodedDisplayType = {\n    displayValue: '',\n    validationWarnings: [],\n    highlight\n  };\n\n  if (\n    data.length > MAX_DECODE_TX_DATA_LENGTH &&\n    [DecodeMethodEnum.decimal, DecodeMethodEnum.smart].includes(decodeMethod)\n  ) {\n    return {\n      ...decodedData,\n      displayValue: data\n    };\n  }\n\n  const hasAt = data.includes('@');\n  const hasNewLine = data.includes('\\n');\n\n  if (!hasAt && !hasNewLine) {\n    return {\n      ...decodedData,\n      displayValue: decodeByMethod({ data, decodeMethod }),\n      highlight: highlight\n        ? decodeByMethod({ data: highlight, decodeMethod })\n        : highlight\n    };\n  }\n\n  if (hasAt) {\n    const parts = data.split('@');\n    const decodedParts = getDisplayValueAndValidationWarnings({\n      parts,\n      decodeMethod,\n      identifier,\n      decodedData\n    });\n\n    const decodedHighlight = highlight\n      ? decodeHighlight({\n          data: highlight,\n          identifier,\n          decodeMethod,\n          delimiter: '@'\n        })\n      : null;\n\n    return {\n      ...decodedData,\n      displayValue: decodedParts.join('@'),\n      highlight: decodedHighlight\n    };\n  }\n\n  if (hasNewLine) {\n    const parts = data.split('\\n');\n\n    const initialDecodedParts = parts.map((part) => {\n      if (decodeMethod === DecodeMethodEnum.raw) {\n        return part;\n      }\n\n      return decodeByMethod({\n        data: Buffer.from(part, 'base64').toString('hex'),\n        decodeMethod\n      });\n    });\n\n    const decodedParts = getDecodedParts({\n      parts,\n      initialDecodedParts,\n      identifier,\n      decodeMethod\n    });\n\n    const decodedHighlight = highlight\n      ? decodeHighlight({\n          data: highlight,\n          identifier,\n          decodeMethod,\n          delimiter: '\\n'\n        })\n      : null;\n\n    return {\n      ...decodedData,\n      displayValue: decodedParts.join('\\n'),\n      highlight: decodedHighlight\n    };\n  }\n\n  return decodedData;\n};\n"],
  "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,yBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA0C,4CAC1CC,EAGO,0CACPC,EAA+B,oCAC/BC,EAAgC,qCAChCC,EAAgC,qCAChCC,EAAqD,0DAS9C,MAAMP,EAAsB,CAAC,CAClC,KAAAQ,EACA,aAAAC,EACA,WAAAC,EACA,UAAAC,EAAY,IACd,IAA6C,CAC3C,MAAMC,EAAkC,CACtC,aAAc,GACd,mBAAoB,CAAC,EACrB,UAAAD,CACF,EAEA,GACEH,EAAK,OAAS,6BACd,CAAC,mBAAiB,QAAS,mBAAiB,KAAK,EAAE,SAASC,CAAY,EAExE,MAAO,CACL,GAAGG,EACH,aAAcJ,CAChB,EAGF,MAAMK,EAAQL,EAAK,SAAS,GAAG,EACzBM,EAAaN,EAAK,SAAS;AAAA,CAAI,EAErC,GAAI,CAACK,GAAS,CAACC,EACb,MAAO,CACL,GAAGF,EACH,gBAAc,kBAAe,CAAE,KAAAJ,EAAM,aAAAC,CAAa,CAAC,EACnD,UAAWE,MACP,kBAAe,CAAE,KAAMA,EAAW,aAAAF,CAAa,CAAC,CAEtD,EAGF,GAAII,EAAO,CACT,MAAME,EAAQP,EAAK,MAAM,GAAG,EACtBQ,KAAe,wCAAqC,CACxD,MAAAD,EACA,aAAAN,EACA,WAAAC,EACA,YAAAE,CACF,CAAC,EAEKK,EAAmBN,KACrB,mBAAgB,CACd,KAAMA,EACN,WAAAD,EACA,aAAAD,EACA,UAAW,GACb,CAAC,EACD,KAEJ,MAAO,CACL,GAAGG,EACH,aAAcI,EAAa,KAAK,GAAG,EACnC,UAAWC,CACb,CACF,CAEA,GAAIH,EAAY,CACd,MAAMC,EAAQP,EAAK,MAAM;AAAA,CAAI,EAEvBU,EAAsBH,EAAM,IAAKI,GACjCV,IAAiB,mBAAiB,IAC7BU,KAGF,kBAAe,CACpB,KAAM,OAAO,KAAKA,EAAM,QAAQ,EAAE,SAAS,KAAK,EAChD,aAAAV,CACF,CAAC,CACF,EAEKO,KAAe,mBAAgB,CACnC,MAAAD,EACA,oBAAAG,EACA,WAAAR,EACA,aAAAD,CACF,CAAC,EAEKQ,EAAmBN,KACrB,mBAAgB,CACd,KAAMA,EACN,WAAAD,EACA,aAAAD,EACA,UAAW;AAAA,CACb,CAAC,EACD,KAEJ,MAAO,CACL,GAAGG,EACH,aAAcI,EAAa,KAAK;AAAA,CAAI,EACpC,UAAWC,CACb,CACF,CAEA,OAAOL,CACT",
  "names": ["getDecodedDataField_exports", "__export", "getDecodedDataField", "__toCommonJS", "import_transactions", "import_serverTransactions", "import_decodeByMethod", "import_decodeHighlight", "import_getDecodedParts", "import_getDisplayValueAndValidationWarnings", "data", "decodeMethod", "identifier", "highlight", "decodedData", "hasAt", "hasNewLine", "parts", "decodedParts", "decodedHighlight", "initialDecodedParts", "part"]
}
