<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<title>MoneroSMS</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="vue.global.prod.js"></script>
<script src="main.js" defer></script>
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%2210 0 100 100%22><text y=%22.90em%22 font-size=%2290%22>📨</text></svg>">
<link rel="stylesheet" href="main.css">
<!--begin div hell-->
<body>
  <div id="app">
    <div class="main">
      <div v-if="userID">
      <div class="showUserID">
        <button v-if="! showUserID" @click="showUserID = userID">Show User ID (KEEP SAFE & SECRET)</button>
        <span v-else><input type="text" v-model="showUserID"></span>
      </div>

        <div><span v-if="! RegExp('Error|Getting').test(moneroAddress)">Monero Address: </span>{{ moneroAddress }}</div>
        <div><span v-if="! RegExp('Error|Getting').test(credits)">Credit Balance: </span>{{ credits }} <span v-if="credits === 0"></span></div>
<details>
<summary>Pricing information</summary>
<pre>
{{ pricingInfo }}
</pre>
</details>

        <span>
          <div v-if="RegExp('^[0-9]+$').test(ownedNumber)"><span>Phone Number: </span>{{ formatPhone(ownedNumber) }}</div>
          <div v-else><span>Phone Number: </span>{{ ownedNumber }}</div>
        </span>
        <div v-if="RegExp('No').test(ownedNumber)">
          <button @click="showNumbers()" v-if="! availableNumbers">Show Available Virtual Numbers</button>
          <div v-if="availableNumbers">
            <h1>Available Virtual Numbers</h1>
            <table class="table table-striped">
              <thead>
                <tr>
                  <th>Number</th>
                </tr>
              </thead>
              <tbody>
                <tr v-for="(number,i) in availableNumbers" :key="i">
                   <th scope="row" v-if="number">{{ formatPhone(number)  }}</th>
                   <td><button @click="buyNum" v-if="number" :data-number="number">Buy</button></td>
                </tr>
               </tbody>
            </table>
            <div v-if="availableNumbers.length === 0">No numbers available</div>
            <div v-if="numberPurchaseMessage">{{  numberPurchaseMessage  }}</div>
          </div>
        </div>

          <div v-else>
            <form class="draft" @submit="sendSMS" @submit.prevent="onSubmit">
              <label>
                Phone Number:
                <input type="tel" v-model="sendToNumber" placeholder="Phone Number" maxlength="10" minlength="10" size="10" pattern="^\d{10}$" required>
              </label>
              <label>
                Message:
                <textarea v-model="messageToSend" placeholder="Message" required></textarea>
              </label>
              <input type="submit" :disabled="disableSMSSend" value="Send">
              <div v-if="sendMsgErr">Error sending message: {{ sendMsgErr }}</div>
            </form>
            <div v-if="threads.length">
              <br>
              <span v-for="person in threads">
                <button @click="openThread(person)">{{ formatPhone(person) }} - Open Thread</button>
                <button @click="deleteThread(person)" class="danger">Delete Thread</button>
                <br><br>
              </span>
              <div v-if="showingThreadNum">
                <div v-for="message in threadMessages">
                  <div :class="message[1]">{{ message[0] }}</div>
                </div>
              </div>
            </div>
            <div v-else>
              No threads
            </div>

          </div>
</div>
<div v-else>
<pre class="desktopHeader">

__   __                                     _____ __   __   _____
|    |    __.  , __     ___  .___    __.   (      |    |   (
|\  /|  .'   \ |'  `. .'   ` /   \ .'   \   `--.  |\  /|    `--.
| \/ |  |    | |    | |----' |   ' |    |      |  | \/ |       |
/    /   `._.' /    | `.___, /      `._.' \___.'  /    /  \___.'

</pre>
  <h1 class="mobileHeader">MoneroSMS</h1>
          <form class="login">
            <input type="password" v-model="userIDInput" placeholder="Enter your account ID" required>

            <button @submit.prevent="onSubmit" @click="userID = userIDInput; userLogin()">Login</button>
            <button @submit.prevent="onSubmit" @click="userID = crypto.randomUUID(); userLogin()">Generate Account</button>
          </form>
</div>
      </div>
    </div>
<!--
  MoneroSMS Web Frontend
  Copyright (C) 2022  VoidNetwork LLC

  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU Affero General Public License as
  published by the Free Software Foundation, either version 3 of the
  License, or (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU Affero General Public License for more details.

  You should have received a copy of the GNU Affero General Public License
  along with this program.  If not, see <https://www.gnu.org/licenses/>.

-->
</body>