<party:>
    {#if _partyMembers}
        <div class='row-fluid'>
            <div class="span6 border-right">
                <h3>{{_party.name}}</h3>
                <table class="table table-striped">
                    {{#each _partyMembers as :member}}
                    <tr><td>{{username(:member.auth, :member.profile.name)}}</td><td>({{:member.id}})</td></tr>
                    {{/}}
                </table>
                <form class=form-inline x-bind="submit: partyInvite">
                    {#if _partyError}
                    <div class='alert alert-danger'>{_partyError}</div>
                    {/}
                    <div class='control-group'>
                        <input type="text" class="input-medium" placeholder="User Id" value="{_newPartyMember}">
                        <input type="submit" class="btn" value="Invite" />
                    </div>
                </form>
                <a class='btn btn-danger' x-bind="click: partyLeave">Leave</a>
            </div>
            <div class="span6">
               <h3>Chat</h3>
                <form x-bind='submit:partySendChat'>
                    <textarea class="span6" rows="3" x-bind='keyup:partyMessageKeyup'>{_chatMessage}</textarea><br/>
                    <input class=btn type=submit value=Submit />
                </form>
               <ul class='party-chat unstyled'>
               {#each _party.chat as :message}
                   <app:party:chat-message message={{:message}} />
               {/}
               </ul>
            </div>
        </div>

    {else if _user.party.invitation}
        <!-- TODO show by whom -->
        <h2>You're Invited To {_party.name}</h2>
        <a class='btn btn-success' x-bind="click: partyAccept">Accept</a>
        <a class='btn btn-danger' x-bind="click: partyReject">Reject</a>

    {else}
        <h2>Create A Party</h2>
        <!-- Not in a party , no invites - create a new one -->
        <p>You are not in a party. You can either create one and invite friends, or if you want to join an existing party, have them enter:</p>
        <pre class=prettyprint>{_user.id}</pre>
        <form class=form-inline x-bind="submit: partyCreate">
            {#if _partyError}
            <div class='alert alert-danger'>{_partyError}</div>
            {/}
            <div class=control-group>
                <input type="text" class="input-medium" placeholder="Party Name" value="{_newParty}" />
                <input type="submit" class="btn" value="Create" />
            </div>
        </form>

    {/}


<chat-message:>
    <li class="{{#if indexOf(:message.text, username(_user.auth, _user.profile.name))}}highlight{{/if}}">
        <span
            class="label {{#if @message.npc}}label-success{{else if @message.contributor}}label-inverse{{else if equal(@message.uuid,_user.id)}}label-info{{/}} chat-message"
            rel='tooltip' title="{{@message.contributor}}{{@message.npc}}">
            {{@message.user}}</span> {{@message.text}} - <span class='muted time'>{relativeDate(@message.timestamp, _currentTime)}
            {{#if or(_user.backer.admin,equal(@message.uuid,_user.id))}}{{#with @message}}<a x-bind="click:deleteChatMessage"><i rel=tooltip title=Delete class=icon-remove></i></a>{{/}}{{/}}
        </span>
    </li>
