package com.google.zxing.oned; import com.google.zxing.BarcodeFormat; import com.google.zxing.common.BitMatrix; import java.util.Map; /* loaded from: classes3.dex */ public final class ITFWriter extends OneDimensionalCodeWriter { public static final int[] START_PATTERN = {1, 1, 1, 1}; public static final int[] END_PATTERN = {3, 1, 1}; public static final int[][] PATTERNS = {new int[]{1, 1, 3, 3, 1}, new int[]{3, 1, 1, 1, 3}, new int[]{1, 3, 1, 1, 3}, new int[]{3, 3, 1, 1, 1}, new int[]{1, 1, 3, 1, 3}, new int[]{3, 1, 3, 1, 1}, new int[]{1, 3, 3, 1, 1}, new int[]{1, 1, 1, 3, 3}, new int[]{3, 1, 1, 3, 1}, new int[]{1, 3, 1, 3, 1}}; @Override // com.google.zxing.oned.OneDimensionalCodeWriter, com.google.zxing.Writer public BitMatrix encode(String str, BarcodeFormat barcodeFormat, int i, int i2, Map map) { if (barcodeFormat != BarcodeFormat.ITF) { throw new IllegalArgumentException("Can only encode ITF, but got ".concat(String.valueOf(barcodeFormat))); } return super.encode(str, barcodeFormat, i, i2, map); } @Override // com.google.zxing.oned.OneDimensionalCodeWriter public boolean[] encode(String str) { int length = str.length(); if (length % 2 != 0) { throw new IllegalArgumentException("The length of the input should be even"); } if (length > 80) { throw new IllegalArgumentException("Requested contents should be less than 80 digits long, but got ".concat(String.valueOf(length))); } boolean[] zArr = new boolean[(length * 9) + 9]; int appendPattern = OneDimensionalCodeWriter.appendPattern(zArr, 0, START_PATTERN, true); for (int i = 0; i < length; i += 2) { int digit = Character.digit(str.charAt(i), 10); int digit2 = Character.digit(str.charAt(i + 1), 10); int[] iArr = new int[10]; for (int i2 = 0; i2 < 5; i2++) { int i3 = i2 * 2; int[][] iArr2 = PATTERNS; iArr[i3] = iArr2[digit][i2]; iArr[i3 + 1] = iArr2[digit2][i2]; } appendPattern += OneDimensionalCodeWriter.appendPattern(zArr, appendPattern, iArr, true); } OneDimensionalCodeWriter.appendPattern(zArr, appendPattern, END_PATTERN, true); return zArr; } }