<form #form (ngSubmit)="submit()" [appApiAction]="formPromise">
    <div class="content">
        <div class="inner-content" *ngIf="send">
            <div class="box">
                <app-callout *ngIf="disableSend">
                    <span>{{'sendDisabledWarning' | i18n}}</span>
                </app-callout>
                <app-callout type="info" *ngIf="disableHideEmail && !disableSend">
                    {{'sendOptionsPolicyInEffect' | i18n}}
                </app-callout>
            </div>
            <div class="box">
                <div class="box-header">
                    {{title}}
                </div>
                <div class="box-content">
                    <div class="box-content-row" appBoxRow>
                        <label for="name">{{'name' | i18n}}</label>
                        <input id="name" type="text" name="Name" [(ngModel)]="send.name" appAutofocus [readOnly]="disableSend">
                    </div>
                    <div class="box-content-row box-content-row-radio" *ngIf="!editMode">
                        <label class="radio-header">{{'whatTypeOfSend' | i18n}}</label>
                        <div class="item" *ngFor="let o of typeOptions">
                            <input type="radio" class="radio" [(ngModel)]="send.type" name="Type_{{o.value}}"
                                id="type_{{o.value}}" [value]="o.value" (change)="typeChanged(o)"
                                [checked]="send.type === o.value" [disabled]="disableSend">
                            <label class="unstyled" for="type_{{o.value}}">
                                {{o.name}}
                            </label>
                        </div>
                    </div>
                    <div class="box-content-row" appBowRow *ngIf="!editMode && send.type === sendType.File">
                        <label for="file">{{'file' | i18n}}</label>
                        <input type="file" id="file" class="form-control-file" name="file" required [disabled]="disableSend">
                    </div>
                    <div class="box-content-row" appBowRow *ngIf="editMode && send.type === sendType.File">
                        <label for="file">{{'file' | i18n}}</label>
                        <div class="row-main">{{send.file.fileName}} ({{send.file.sizeName}})</div>
                    </div>
                    <div class="box-content-row" appBoxRow *ngIf="send.type === sendType.Text">
                        <label for="text">{{'text' | i18n}}</label>
                        <textarea id="text" name="text" [(ngModel)]="send.text.text" rows="6" [readOnly]="disableSend"></textarea>
                    </div>
                </div>
                <div class="box-footer" *ngIf="!editMode && send.type === sendType.File">
                    {{'sendFileDesc' | i18n}} {{'maxFileSize' | i18n}}
                </div>
                <div class="box-footer" *ngIf="send.type === sendType.Text">
                    {{'sendTextDesc' | i18n}}
                </div>
            </div>
            <div class="box" *ngIf="send.type === sendType.Text">
                <div class="box-content">
                    <div class="box-content-row box-content-row-checkbox" appBoxRow>
                        <label for="hideText">{{'textHiddenByDefault' | i18n}}</label>
                        <input id="hideText" name="hideText" type="checkbox" [(ngModel)]="send.text.hidden" [disabled]="disableSend">
                    </div>
                </div>
            </div>
            <div class="box">
                <div class="box-header">
                    {{'options' | i18n}}
                    <a class="toggle" href="#" appStopClick appBlurClick role="button" (click)="toggleOptions()">
                        <i class="fa fa-lg" aria-hidden="true" [ngClass]="{'fa-chevron-down': !showOptions, 'fa-chevron-up': showOptions}"></i>
                    </a>
                </div>
            </div>
            <div [hidden]="!showOptions">
                <div class="box">
                    <div class="box-content">
                        <div class="box-content-row" appBoxRow *ngIf="!editMode">
                            <label for="deletionDate">{{'deletionDate' | i18n}}</label>
                            <select id="deletionDate" name="DeletionDateSelect" [(ngModel)]="deletionDateSelect" required>
                                <option *ngFor="let o of deletionDateOptions" [ngValue]="o.value">{{o.name}}
                                </option>
                            </select>
                            <small class="help-block">{{'deletionDateDesc' | i18n}}</small>
                        </div>
                        <div class="box-content-row" *ngIf="deletionDateSelect === 0 || editMode">
                            <label *ngIf="editMode" for="deletionDateCustom">{{'deletionDate' | i18n}}</label>
                            <input id="deletionDateCustom" type="datetime-local" name="deletionDate" 
                                [(ngModel)]="deletionDate" required placeholder="MM/DD/YYYY HH:MM AM/PM">
                            <small class="help-block" *ngIf="editMode">{{'deletionDateDesc' | i18n}}</small>
                        </div>
                        <div class="box-content-row" appBoxRow *ngIf="!editMode">
                            <label for="expirationDate">{{'expirationDate' | i18n}}</label>
                            <select id="expirationDate" name="expirationDateSelect" [(ngModel)]="expirationDateSelect" required>
                                <option *ngFor="let o of expirationDateOptions" [ngValue]="o.value">{{o.name}}
                                </option>
                            </select>
                            <small class="help-block">{{'expirationDateDesc' | i18n}}</small>
                        </div>
                        <div class="box-content-row" *ngIf="expirationDateSelect === 0 || editMode">
                            <label *ngIf="editMode" for="expirationDateCustom">{{'expirationDate' | i18n}}</label>
                            <input id="expirationDateCustom" type="datetime-local" name="expirationDate" 
                                [(ngModel)]="expirationDate" required placeholder="MM/DD/YYYY HH:MM AM/PM" [readOnly]="disableSend">
                            <small *ngIf="editMode" class="help-block">{{'expirationDateDesc' | i18n}}</small>
                        </div>
                    </div>
                </div>
                <div class="box">
                    <div class="box-content">
                        <div class="box-content-row" appBoxRow>
                            <label for="maxAccessCount">{{'maxAccessCount' | i18n}}</label>
                            <input id="maxAccessCount" type="number" name="maxAccessCount" [(ngModel)]="send.maxAccessCount" [readOnly]="disableSend">
                        </div>
                    </div>
                    <div class="box-footer" *ngIf="!editMode">
                        {{'maxAccessCountDesc' | i18n}}
                    </div>
                    <div class="box-footer" *ngIf="editMode">
                        <p>{{'maxAccessCountDesc' | i18n}}</p>
                        {{'currentAccessCount' | i18n}}: <strong>{{send.accessCount}}</strong>
                    </div>
                </div>
                <div class="box">
                    <div class="box-content">
                        <div class="box-content-row box-content-row-flex" appBoxRow>
                            <div class="row-main">
                                <label for="password">{{(hasPassword ? 'newPassword' : 'password') | i18n}}</label>
                                <input id="password" name="password" type="{{showPassword ? 'text' : 'password'}}" [(ngModel)]="password" [readOnly]="disableSend">
                            </div>
                            <div class="action-buttons">
                                <a class="row-btn" href="#" appStopClick appBlurClick role="button"
                                    appA11yTitle="{{'toggleVisibility' | i18n}}" (click)="togglePasswordVisible()"  [disabled]="disableSend">
                                    <i class="fa fa-lg" aria-hidden="true"
                                        [ngClass]="{'fa-eye': !showPassword, 'fa-eye-slash': showPassword}"></i>
                                </a>
                            </div>
                        </div>
                    </div>
                    <div class="box-footer">
                        {{'sendPasswordDesc' | i18n}}
                    </div>
                </div>
                <div class="box">
                    <div class="box-header">
                        {{'notes' | i18n}}
                    </div>
                    <div class="box-content">
                        <div class="box-content-row" appBoxRow>
                            <textarea id="notes" name="notes" [(ngModel)]="send.notes" rows="6" [readOnly]="disableSend"></textarea>
                        </div>
                    </div>
                    <div class="box-footer">
                        {{'sendNotesDesc' | i18n}}
                    </div>
                </div>
                <div class="box">
                    <div class="box-content">
                        <div class="box-content-row box-content-row-checkbox" appBoxRow>
                            <label for="hideEmail">{{'hideEmail' | i18n}}</label>
                            <input id="hideEmail" type="checkbox" name="HideEmail" [(ngModel)]="send.hideEmail"
                                [disabled]="(disableHideEmail && !send.hideEmail) || disableSend">
                        </div>
                    </div>
                </div>
                <div class="box">
                    <div class="box-content">
                        <div class="box-content-row box-content-row-checkbox" appBoxRow>
                            <label for="disabled">{{'disableSend' | i18n}}</label>
                            <input id="disabled" type="checkbox" name="disabled" [(ngModel)]="send.disabled" [disabled]="disableSend">
                        </div>
                    </div>
                </div>
            </div>
            <div class="box">
                <div class="box-header">
                    {{'share' | i18n}}
                </div>
                <div class="box-content">
                    <div class="box-content-row" appBoxRow *ngIf="editMode">
                        <label for="link">{{'sendLinkLabel' | i18n}}</label>
                        <input id="link" name="link" [ngModel]="link" readonly>
                    </div>
                    <div class="box-content-row box-content-row-checkbox" appBoxRow>
                        <label for="copyLink">{{'copySendLinkOnSave' | i18n}}</label>
                        <input id="copyLink" name="copyLink" [(ngModel)]="copyLink" type="checkbox" [disabled]="disableSend">
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="footer">
        <button appBlurClick type="submit" class="primary btn-submit" appA11yTitle="{{'save' | i18n}}" [disabled]="form.loading" *ngIf="!disableSend">
            <i class="fa fa-spinner fa-spin" title="{{'loading' | i18n}}" aria-hidden="true"></i>
            <span><i class="fa fa-save fa-lg fa-fw" aria-hidden="true"></i></span>
        </button>
        <button appBlurClick type="button" (click)="cancel()" [disabled]="form.loading">
            {{'cancel' | i18n}}
        </button>
        <div class="right">
            <button appBlurClick type="button" (click)="copyLinkToClipboard(link)" appA11yTitle="{{'copySendLinkToClipboard' | i18n}}" *ngIf="editMode">
                <i class="fa fa-copy fa-lg fa-fw" aria-hidden="true"></i>
            </button>
            <button #deleteBtn appBlurClick type="button" (click)="delete()" class="danger"
                appA11yTitle="{{'delete' | i18n}}" *ngIf="editMode">
                <i class="fa fa-trash-o fa-lg fa-fw" [hidden]="deleteBtn.loading" aria-hidden="true"></i>
                <i class="fa fa-spinner fa-spin fa-lg fa-fw" [hidden]="!deleteBtn.loading" aria-hidden="true"></i>
            </button>
        </div>
    </div>
</form>
