content: package kotlin.io;
  
  import java.io.BufferedReader;
  import java.io.BufferedWriter;
  import java.io.Reader;
  import java.io.StringReader;
  import java.io.StringWriter;
  import java.io.Writer;
  import java.net.URL;
  import java.nio.charset.Charset;
  import java.util.ArrayList;
  import java.util.List;
  import kotlin.Metadata;
  import kotlin.jvm.internal.Intrinsics;
  import kotlin.sequences.Sequence;
  import kotlin.sequences.SequencesKt;
  import kotlin.text.Charsets;
  import mt.Log1F380D;
  
  @Metadata(d1 = {"\u0000X\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\t\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0012\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010 \n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0006\u001a\u0017\u0010\u0000\u001a\u00020\u0001*\u00020\u00022\b\b\u0002\u0010\u0003\u001a\u00020\u0004H\b\u001a\u0017\u0010\u0000\u001a\u00020\u0005*\u00020\u00062\b\b\u0002\u0010\u0003\u001a\u00020\u0004H\b\u001a\u001c\u0010\u0007\u001a\u00020\b*\u00020\u00022\u0006\u0010\t\u001a\u00020\u00062\b\b\u0002\u0010\u0003\u001a\u00020\u0004\u001a\u001e\u0010\n\u001a\u00020\u000b*\u00020\u00022\u0012\u0010\f\u001a\u000e\u0012\u0004\u0012\u00020\u000e\u0012\u0004\u0012\u00020\u000b0\r\u001a\u0010\u0010\u000f\u001a\b\u0012\u0004\u0012\u00020\u000e0\u0010*\u00020\u0001\u001a\n\u0010\u0011\u001a\u00020\u0012*\u00020\u0013\u001a\u0010\u0010\u0014\u001a\b\u0012\u0004\u0012\u00020\u000e0\u0015*\u00020\u0002\u001a\n\u0010\u0016\u001a\u00020\u000e*\u00020\u0002\u001a\u0017\u0010\u0016\u001a\u00020\u000e*\u00020\u00132\b\b\u0002\u0010\u0017\u001a\u00020\u0018H\b\u001a\r\u0010\u0019\u001a\u00020\u001a*\u00020\u000eH\b\u001a8\u0010\u001b\u001a\u0002H\u001c\"\u0004\b\u0000\u0010\u001c*\u00020\u00022\u0018\u0010\u001d\u001a\u0014\u0012\n\u0012\b\u0012\u0004\u0012\u00020\u000e0\u0010\u0012\u0004\u0012\u0002H\u001c0\rH\bø\u0001\u0000ø\u0001\u0001¢\u0006\u0002\u0010\u001e\u0002\u000f\n\u0005\b20\u0001\n\u0006\b\u0011(\u001f0\u0001¨\u0006 "}, d2 = {"buffered", "Ljava/io/BufferedReader;", "Ljava/io/Reader;", "bufferSize", "", "Ljava/io/BufferedWriter;", "Ljava/io/Writer;", "copyTo", "", "out", "forEachLine", "", "action", "Lkotlin/Function1;", "", "lineSequence", "Lkotlin/sequences/Sequence;", "readBytes", "", "Ljava/net/URL;", "readLines", "", "readText", "charset", "Ljava/nio/charset/Charset;", "reader", "Ljava/io/StringReader;", "useLines", "T", "block", "(Ljava/io/Reader;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;", "Requires newer compiler version to be inlined correctly.", "kotlin-stdlib"}, k = 2, mv = {1, 7, 1}, xi = 48)
  /* compiled from: 0137 */
  public final class TextStreamsKt {
      private static final BufferedReader buffered(Reader $this$buffered, int bufferSize) {
          Intrinsics.checkNotNullParameter($this$buffered, "<this>");
          return $this$buffered instanceof BufferedReader ? (BufferedReader) $this$buffered : new BufferedReader($this$buffered, bufferSize);
      }
  
      private static final BufferedWriter buffered(Writer $this$buffered, int bufferSize) {
          Intrinsics.checkNotNullParameter($this$buffered, "<this>");
          return $this$buffered instanceof BufferedWriter ? (BufferedWriter) $this$buffered : new BufferedWriter($this$buffered, bufferSize);
      }
  
      static /* synthetic */ BufferedReader buffered$default(Reader $this$buffered_u24default, int bufferSize, int i, Object obj) {
          if ((i & 1) != 0) {
              bufferSize = 8192;
          }
          Intrinsics.checkNotNullParameter($this$buffered_u24default, "<this>");
          return $this$buffered_u24default instanceof BufferedReader ? (BufferedReader) $this$buffered_u24default : new BufferedReader($this$buffered_u24default, bufferSize);
      }
  
      static /* synthetic */ BufferedWriter buffered$default(Writer $this$buffered_u24default, int bufferSize, int i, Object obj) {
          if ((i & 1) != 0) {
              bufferSize = 8192;
          }
          Intrinsics.checkNotNullParameter($this$buffered_u24default, "<this>");
          return $this$buffered_u24default instanceof BufferedWriter ? (BufferedWriter) $this$buffered_u24default : new BufferedWriter($this$buffered_u24default, bufferSize);
      }
  
      public static final long copyTo(Reader $this$copyTo, Writer out, int bufferSize) {
          Intrinsics.checkNotNullParameter($this$copyTo, "<this>");
          Intrinsics.checkNotNullParameter(out, "out");
          long j = 0;
          char[] cArr = new char[bufferSize];
          int read = $this$copyTo.read(cArr);
          while (read >= 0) {
              out.write(cArr, 0, read);
              j += (long) read;
              read = $this$copyTo.read(cArr);
          }
          return j;
      }
  
      public static /* synthetic */ long copyTo$default(Reader reader, Writer writer, int i, int i2, Object obj) {
          if ((i2 & 2) != 0) {
              i = 8192;
          }
          return copyTo(reader, writer, i);
      }
  
      /* JADX WARNING: Code restructure failed: missing block: B:16:0x0045, code lost:
          r4 = move-exception;
       */
      /* JADX WARNING: Code restructure failed: missing block: B:17:0x0046, code lost:
          kotlin.io.CloseableKt.closeFinally(r2, r3);
       */
      /* JADX WARNING: Code restructure failed: missing block: B:18:0x0049, code lost:
          throw r4;
       */
      /* Code decompiled incorrectly, please refer to instructions dump. */
      public static final void forEachLine(java.io.Reader r12, kotlin.jvm.functions.Function1<? super java.lang.String, kotlin.Unit> r13) {
          /*
              java.lang.String r0 = "<this>"
              kotlin.jvm.internal.Intrinsics.checkNotNullParameter(r12, r0)
              java.lang.String r0 = "action"
              kotlin.jvm.internal.Intrinsics.checkNotNullParameter(r13, r0)
              r0 = r12
              r1 = 0
              boolean r2 = r0 instanceof java.io.BufferedReader
              if (r2 == 0) goto L_0x0014
              r2 = r0
              java.io.BufferedReader r2 = (java.io.BufferedReader) r2
              goto L_0x001b
          L_0x0014:
              java.io.BufferedReader r2 = new java.io.BufferedReader
              r3 = 8192(0x2000, float:1.14794E-41)
              r2.<init>(r0, r3)
          L_0x001b:
              java.io.Closeable r2 = (java.io.Closeable) r2
              r3 = 0
              r4 = r2
              java.io.BufferedReader r4 = (java.io.BufferedReader) r4     // Catch:{ all -> 0x0043 }
              r5 = 0
              kotlin.sequences.Sequence r6 = lineSequence(r4)     // Catch:{ all -> 0x0043 }
              r7 = 0
              r8 = r6
              r9 = 0
              java.util.Iterator r10 = r8.iterator()     // Catch:{ all -> 0x0043 }
          L_0x002d:
              boolean r11 = r10.hasNext()     // Catch:{ all -> 0x0043 }
              if (r11 == 0) goto L_0x003b
              java.lang.Object r11 = r10.next()     // Catch:{ all -> 0x0043 }
              r13.invoke(r11)     // Catch:{ all -> 0x0043 }
              goto L_0x002d
          L_0x003b:
              kotlin.Unit r6 = kotlin.Unit.INSTANCE     // Catch:{ all -> 0x0043 }
              kotlin.io.CloseableKt.closeFinally(r2, r3)
              return
          L_0x0043:
              r3 = move-exception
              throw r3     // Catch:{ all -> 0x0045 }
          L_0x0045:
              r4 = move-exception
              kotlin.io.CloseableKt.closeFinally(r2, r3)
              throw r4
          */
          throw new UnsupportedOperationException("Method not decompiled: kotlin.io.TextStreamsKt.forEachLine(java.io.Reader, kotlin.jvm.functions.Function1):void");
      }
  
      public static final Sequence<String> lineSequence(BufferedReader $this$lineSequence) {
          Intrinsics.checkNotNullParameter($this$lineSequence, "<this>");
          return SequencesKt.constrainOnce(new LinesSequence($this$lineSequence));
      }
  
      /* JADX WARNING: Code restructure failed: missing block: B:10:0x0023, code lost:
          throw r2;
       */
      /* JADX WARNING: Code restructure failed: missing block: B:8:0x001f, code lost:
          r2 = move-exception;
       */
      /* JADX WARNING: Code restructure failed: missing block: B:9:0x0020, code lost:
          kotlin.io.CloseableKt.closeFinally(r0, r1);
       */
      /* Code decompiled incorrectly, please refer to instructions dump. */
      public static final byte[] readBytes(java.net.URL r4) {
          /*
              java.lang.String r0 = "<this>"
              kotlin.jvm.internal.Intrinsics.checkNotNullParameter(r4, r0)
              java.io.InputStream r0 = r4.openStream()
              java.io.Closeable r0 = (java.io.Closeable) r0
              r1 = r0
              java.io.InputStream r1 = (java.io.InputStream) r1     // Catch:{ all -> 0x001d }
              r2 = 0
              java.lang.String r3 = "it"
              kotlin.jvm.internal.Intrinsics.checkNotNullExpressionValue(r1, r3)     // Catch:{ all -> 0x001d }
              byte[] r3 = kotlin.io.ByteStreamsKt.readBytes(r1)     // Catch:{ all -> 0x001d }
              r1 = 0
              kotlin.io.CloseableKt.closeFinally(r0, r1)
              return r3
          L_0x001d:
              r1 = move-exception
              throw r1     // Catch:{ all -> 0x001f }
          L_0x001f:
              r2 = move-exception
              kotlin.io.CloseableKt.closeFinally(r0, r1)
              throw r2
          */
          throw new UnsupportedOperationException("Method not decompiled: kotlin.io.TextStreamsKt.readBytes(java.net.URL):byte[]");
      }
  
      public static final List<String> readLines(Reader $this$readLines) {
          Intrinsics.checkNotNullParameter($this$readLines, "<this>");
          ArrayList arrayList = new ArrayList();
          forEachLine($this$readLines, new TextStreamsKt$readLines$1(arrayList));
          return arrayList;
      }
  
      public static final String readText(Reader $this$readText) {
          Intrinsics.checkNotNullParameter($this$readText, "<this>");
          StringWriter stringWriter = new StringWriter();
          copyTo$default($this$readText, stringWriter, 0, 2, (Object) null);
          String stringWriter2 = stringWriter.toString();
          Intrinsics.checkNotNullExpressionValue(stringWriter2, "buffer.toString()");
          return stringWriter2;
      }
  
      private static final String readText(URL $this$readText, Charset charset) {
          Intrinsics.checkNotNullParameter($this$readText, "<this>");
          Intrinsics.checkNotNullParameter(charset, "charset");
          String str = new String(readBytes($this$readText), charset);
          Log1F380D.a((Object) str);
          return str;
      }
  
      private static final StringReader reader(String $this$reader) {
          Intrinsics.checkNotNullParameter($this$reader, "<this>");
          return new StringReader($this$reader);
      }
  
      /* JADX WARNING: Code restructure failed: missing block: B:12:0x0036, code lost:
          r4 = move-exception;
       */
      /* JADX WARNING: Code restructure failed: missing block: B:13:0x0037, code lost:
          kotlin.jvm.internal.InlineMarker.finallyStart(1);
          kotlin.io.CloseableKt.closeFinally(r1, r2);
          kotlin.jvm.internal.InlineMarker.finallyEnd(1);
       */
      /* JADX WARNING: Code restructure failed: missing block: B:14:0x0040, code lost:
          throw r4;
       */
      /* Code decompiled incorrectly, please refer to instructions dump. */
      public static final <T> T useLines(java.io.Reader r7, kotlin.jvm.functions.Function1<? super kotlin.sequences.Sequence<java.lang.String>, ? extends T> r8) {
          /*
              java.lang.String r0 = "<this>"
              kotlin.jvm.internal.Intrinsics.checkNotNullParameter(r7, r0)
              java.lang.String r0 = "block"
              kotlin.jvm.internal.Intrinsics.checkNotNullParameter(r8, r0)
              r0 = 0
              boolean r1 = r7 instanceof java.io.BufferedReader
              if (r1 == 0) goto L_0x0013
              r1 = r7
              java.io.BufferedReader r1 = (java.io.BufferedReader) r1
              goto L_0x001a
          L_0x0013:
              java.io.BufferedReader r1 = new java.io.BufferedReader
              r2 = 8192(0x2000, float:1.14794E-41)
              r1.<init>(r7, r2)
          L_0x001a:
              java.io.Closeable r1 = (java.io.Closeable) r1
              r2 = 0
              r3 = 1
              r4 = r1
              java.io.BufferedReader r4 = (java.io.BufferedReader) r4     // Catch:{ all -> 0x0034 }
              r5 = 0
              kotlin.sequences.Sequence r6 = lineSequence(r4)     // Catch:{ all -> 0x0034 }
              java.lang.Object r6 = r8.invoke(r6)     // Catch:{ all -> 0x0034 }
              kotlin.jvm.internal.InlineMarker.finallyStart(r3)
              kotlin.io.CloseableKt.closeFinally(r1, r2)
              kotlin.jvm.internal.InlineMarker.finallyEnd(r3)
              return r6
          L_0x0034:
              r2 = move-exception
              throw r2     // Catch:{ all -> 0x0036 }
          L_0x0036:
              r4 = move-exception
              kotlin.jvm.internal.InlineMarker.finallyStart(r3)
              kotlin.io.CloseableKt.closeFinally(r1, r2)
              kotlin.jvm.internal.InlineMarker.finallyEnd(r3)
              throw r4
          */
          throw new UnsupportedOperationException("Method not decompiled: kotlin.io.TextStreamsKt.useLines(java.io.Reader, kotlin.jvm.functions.Function1):java.lang.Object");
      }
  
      static /* synthetic */ String readText$default(URL $this$readText_u24default, Charset charset, int i, Object obj) {
          if ((i & 1) != 0) {
              charset = Charsets.UTF_8;
          }
          Intrinsics.checkNotNullParameter($this$readText_u24default, "<this>");
          Intrinsics.checkNotNullParameter(charset, "charset");
          String str = new String(readBytes($this$readText_u24default), charset);
          Log1F380D.a((Object) str);
          return str;
      }
  }
  