{#if attached && !open}
{t('attach.addedTo')}
{attached.title}
{t('attach.viewInProject')}
(attached = null)} >
{:else if !open}
{ itemName = defaultMiscName(path); open = true; }} > {t('attach.addToProject')}
{:else}
{t('attach.projectField')}
{t('attach.selectProject')}
{#each projectList as p}
{p.title}
{/each}
{#if !isVideo}
{t('attach.addAs')}
{t('attach.asCharacterSheet')}
{t('attach.asLocation')}
{t('attach.asItem')}
{#if target === 'character_sheet'}
{t('attach.characterField')}
{t('attach.selectCharacter')}
{#each characters as c}
{c.name}
{/each}
{#if projectId !== '' && !loadingTargets && characters.length === 0}
{t('attach.noCharacters')}
{/if}
{:else if target === 'location'}
{t('attach.locationField')}
{t('attach.selectLocation')}
{#each locations as loc}
{loc.name}
{/each}
{#if projectId !== '' && !loadingTargets && locations.length === 0}
{t('attach.noLocations')}
{/if}
{:else}
{t('attach.nameField')}
{t('attach.newItemHint')}
{/if} {:else}
{t('attach.sceneField')}
{t('attach.selectScene')}
{#each scenes as s}
#{s.order_index} {s.heading || t('attach.scene')}
{/each}
{#if projectId !== '' && !loadingTargets && scenes.length === 0}
{t('attach.noScenes')}
{/if}
{/if}
$attachMutation.mutate()} > {t('attach.addBtn')}
(open = false)}>{t('common.cancel')}
{#if message && $attachMutation.isError}
{message}
{/if}
{/if}