{#if item}
{#snippet children()}
{#key item?.id ?? position}
viewDetails()}
>

{#if ctx?.canEdit() && item?.id}
{/if}
{/key}
{/snippet}
{#snippet menu()}
{#if ctx?.canEdit()}
{/if}
{/snippet}
{:else}
{#key `empty-${position}`}
ctx?.canEdit() && ctx?.openPicker && ctx.openPicker({ type: 'character', position, item })}
>

{#if ctx?.canEdit()}
{/if}
{/key}
{/if}
{#if item}
{
if (!item?.id || !ctx) return
try {
const editKey = ctx.getEditKey()
const updated = await ctx.services.gridService.updateCharacterUncap(item.id, level, undefined, editKey || undefined)
if (updated) {
ctx.updateParty(updated)
}
} catch (err) {
console.error('Failed to update character uncap:', err)
// TODO: Show user-friendly error notification
}
}}
updateTranscendence={async (stage) => {
if (!item?.id || !ctx) return
try {
const editKey = ctx.getEditKey()
// When setting transcendence > 0, also set uncap to max (6)
const maxUncap = stage > 0 ? 6 : undefined
const updated = await ctx.services.gridService.updateCharacterUncap(item.id, maxUncap, stage, editKey || undefined)
if (updated) {
ctx.updateParty(updated)
}
} catch (err) {
console.error('Failed to update character transcendence:', err)
// TODO: Show user-friendly error notification
}
}}
/>
{/if}
{item ? displayName(item?.character) : ''}