{#if attachments.length > 0}
{#each attachments as attachment} {@const isPending = 'pending' in attachment && attachment.pending} {@const imgSrc = isPending ? attachment.path : `/api/notes/${noteId}/attachments?attachmentId=${attachment.id}`}
{ lightboxSrc = imgSrc; lightboxAlt = attachment.filename; }} data-testid="attachment-thumbnail" /> {#if isPending}
{:else if onToggleFeatured}
onToggleFeatured(attachment.id, !attachment.featured)} class="absolute bottom-0.5 right-0.5 rounded-full bg-black/50 p-0.5 transition-opacity {attachment.featured ? 'opacity-100' : 'max-md:opacity-100 md:opacity-0 md:group-hover:opacity-100'}" aria-label={attachment.featured ? 'Unfeature image' : 'Feature image'} data-testid="toggle-featured" >
{/if}
onRemove(attachment.id)} class="absolute -right-1 -top-1 rounded-full bg-[var(--destructive)] p-0.5 text-white transition-opacity max-md:opacity-100 md:opacity-0 md:group-hover:opacity-100" aria-label="Remove attachment" data-testid="remove-attachment" >
{/each}
{/if} {#if showDropZone}
(dragOver = false)} role="button" tabindex="0" data-testid="upload-dropzone" > {#if optimizing}
Optimizing...
{:else if uploading}
Uploading...
{:else}
Drop images here or
browse
handleFiles((e.target as HTMLInputElement).files)} data-testid="file-input" />
{/if}
{#if optimizing}
Optimizing...
{:else if uploading}
Uploading...
{:else}
Add images
handleFiles((e.target as HTMLInputElement).files)} data-testid="file-input-mobile" />
{/if}
{/if}
{#if lightboxSrc}
lightboxSrc = null} /> {/if}