<commit_before><template lang="pug">
  section#submit
    p 以下でURLが生成できます。
    p.warning サイト閉鎖時にすべてのURL対応表を公開しますので、機密情報は入れないでください。
    transition-group(tag="div" appear)
      div.result(v-for="(item, i) in message" v-bind:key="item.key")
        div.uri
          span {{ item.uri }}
          | の短縮URLを作成しました。
          | クリックでコピーできます。
        div
          div.short.output
            label short URL
            input(type="text" v-model="item.short" readonly v-on:click="copy($event.toElement);")
          div.long.output
            label long URL
            input(type="text" v-model="item.long" readonly v-on:click="copy($event.toElement);")
        button(v-on:click="del(i);") 削除
    form(v-on:submit.prevent="send();")
      p
        label URL
        input(type="url" name="uri" v-model="uri" required)
      p
        input(type="checkbox" name="antenna" v-model="antenna")
        | 自動ジャンプせず警告ページを表示する。
      div#recaptcha
      button(type="submit" value="submit") 送信する
</template>

<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator';
import axios from 'axios';
import RecaptchaInit from './RecaptchaInit';

const recaptchaInit = new RecaptchaInit();

interface Msg {
  uri: string;
  antenna: boolean;
  key?: number;
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
(window as any).onloadCallback = () => {
  recaptchaInit.flag = true;
};

@Component({
  created() {
    Promise.all([
      this.$store.dispatch('getRecaptchaSitekeyAsync'),
      recaptchaInit.wait(),
    ]).then(() => {
      if (this.$store.state.Recaptcha.use) {
        // eslint-disable-next-line @typescript-eslint/no-explicit-any
        (window as any).grecaptcha.render('recaptcha', {
          sitekey: this.$store.state.Recaptcha.sitekey,
        });
      }
    });
  },
})
export default class Submit extends Vue {
  @Prop() private msg!: string;

  private uri = '';

  private antenna = false;

  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  private message: Msg[] = [];

  private key = 0;

  public send() {
    const { uri } = this;
    const { antenna } = this;
    const a: Msg = { uri, antenna };
    console.log(a);
    axios.post('/api/v1/accept/post', a).then((b) => {
      const d = b.data;
      Object.keys(d).forEach((v) => {
        d[v] = window.location.href + d[v];
      });
      Object.assign(a, d);
      a.key = this.key;
      this.key += 1;
      this.message.push(a);
      console.log(this.message);
    });
  }

  // eslint-disable-next-line class-methods-use-this<commit_msg>Recaptcha を正しく送る<commit_after><template lang="pug">
  section#submit
    p 以下でURLが生成できます。
    p.warning サイト閉鎖時にすべてのURL対応表を公開しますので、機密情報は入れないでください。
    transition-group(tag="div" appear)
      div.result(v-for="(item, i) in message" v-bind:key="item.key")
        div.uri
          span {{ item.uri }}
          | の短縮URLを作成しました。
          | クリックでコピーできます。
        div
          div.short.output
            label short URL
            input(type="text" v-model="item.short" readonly v-on:click="copy($event.toElement);")
          div.long.output
            label long URL
            input(type="text" v-model="item.long" readonly v-on:click="copy($event.toElement);")
        button(v-on:click="del(i);") 削除
    form(v-on:submit.prevent="send();")
      p
        label URL
        input(type="url" name="uri" v-model="uri" required)
      p
        input(type="checkbox" name="antenna" v-model="antenna")
        | 自動ジャンプせず警告ページを表示する。
      div#recaptcha
      button(type="submit" value="submit") 送信する
</template>

<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator';
import axios from 'axios';
import RecaptchaInit from './RecaptchaInit';

const recaptchaInit = new RecaptchaInit();

interface Msg {
  uri: string;
  antenna: boolean;
  'g-recaptcha-response'?: string;
  key?: number;
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
(window as any).onloadCallback = () => {
  recaptchaInit.flag = true;
};

@Component({
  created() {
    Promise.all([
      this.$store.dispatch('getRecaptchaSitekeyAsync'),
      recaptchaInit.wait(),
    ]).then(() => {
      if (this.$store.state.Recaptcha.use) {
        // eslint-disable-next-line @typescript-eslint/no-explicit-any
        (window as any).grecaptcha.render('recaptcha', {
          sitekey: this.$store.state.Recaptcha.sitekey,
          callback: (token: string) => {
            this.$data.token = token;
          },
        });
      }
    });
  },
})
export default class Submit extends Vue {
  @Prop() private msg!: string;

  private uri = '';

  private antenna = false;

  private token = '';

  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  private message: Msg[] = [];

  private key = 0;

  public send() {
    const { uri } = this;
    const { antenna } = this;
    const { token } = this;
    const a: Msg = (() => {
      if (this.$store.state.Recaptcha.use) {
        return { uri, antenna, 'g-recaptcha-response': token };
      }
      return { uri, antenna };
    })();
    console.log(a);
    axios.post('/api/v1/accept/post', a).then((b) => {
      const d = b.data;
      Object.keys(d).forEach((v) => {
        d[v] = window.location.href + d[v];
      });
      Object.assign(a, d);
      a.key = this.key;
      this.key += 1;
      this.message.push(a);
      console.log(this.message);
    });
  }

  // eslint-disable-next-line class-methods-use-this
{'fraction_non_alphanumeric': 0.16113138686131387, 'fraction_numerical': 0.0010948905109489052, 'mean_word_length': 2.5361290322580645, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3844710', 'n_tokens_mistral': 2003, 'n_tokens_neox': 1967, 'n_words': 344}