<a href="<%= channel.relative_url %>">channel</a>
<a href="<%= channel.relative_url %>/feed/inbound/endpoints">all endpoints</a>
<a href="<%= channel.relative_url %>/feed/inbound/payloads">payloads</a>

<h2>Create Endpoint</h2>

<form action="<%= channel.relative_url %>/feed/inbound/endpoints" method="POST" class="f1">
  <div class="form-group">
    <label for="channel_id">channel</label>
    <input type="hidden" name="channel_id" value="<%= channel.id.to_b62 %>">
    <a href="<%= channel.relative_url %>"><%= channel.dname %></a>
    <%= ctx.errors.form_group_p "channel_id" -%>
  </div>
  <div class="form-group">
    <label for="url">url</label>
    <input class="form-control <%= ctx.errors.form_input_class "url" %>"
      type="text" name="url" value="<%= ctx.old["url"].e %>" />
    <%= ctx.errors.form_group_p "url" -%>
    <p>
      Examples:
      <ul>
        <li class="text-monospace">https://www.youtube.com/feed/videos.xml?channel_id=UCZFipeZtQM5CKUjx6grh54g</li>
      </ul>
      <details>
        <summary>get youtube RSS feed URL from Chrome Dev Console</summary>
        <code class="text-monospace"><pre>[...document.querySelectorAll('link[title=RSS]')].map(n => n.getAttribute('href'))</pre></code>
      </details>
  </div>
  <div class="form-group">
    <label for="bio">memo</label>
    <textarea class="form-control <%= ctx.errors.form_input_class "bio" %>" name="bio" rows=3><%= ctx.old["bio"] %></textarea>
    <%= ctx.errors.form_group_p "bio" -%>
  </div>
  <div class="form-group">
    <label for="mask">Mask</label>
    <select class="form-control a-select <%= ctx.errors.form_input_class "mask" %>" name="mask">
      <option value="0">post as myself</option>
      <%- default_mask = Kpbb::Mask::Mask::Channel -%>
      <%- Kpbb::Mask::Mask.each do |mask| -%>
        <%- mask_s = mask.to_s -%>
        <option value="<%= mask_s %>" <%= "selected" if mask_s == ctx.old["mask"]? || (ctx.old["mask"].presence.nil? && mask == default_mask) %>>
          <%= mask.dname %>
        </option>
      <%- end -%>
    </select>
    <%= ctx.errors.form_group_p "mask" -%>
  </div>
  <div class="form-group">
    <label for="default_body">default body (yaml)</label>
    <textarea class="form-control <%= ctx.errors.form_input_class "default_body" %>" name="default_body_yaml" rows=3><%= ctx.old("default_body_yaml", ({
      :draft => "0",
      :posted => "1",
    }).to_yaml).e %></textarea>
    <%= ctx.errors.form_group_p "default_body" -%>
  </div>
  <div class="form-group">
    <input type="submit" value="Save" class="btn btn-primary" />
  </div>
</form>
