File size: 4,613 Bytes
c126239 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | <script lang="ts">
import {
wizards,
activeMethod,
setStage,
highestUnlocked,
downloadExport,
METHOD_META,
WATERMARKS,
type Stage,
} from '../lib/stores/app-state';
import KSplit from './stages/kirchenbauer/Split.svelte';
import KBias from './stages/kirchenbauer/Bias.svelte';
import KResult from './stages/kirchenbauer/Result.svelte';
import SClusters from './stages/ksemstamp/Clusters.svelte';
import SRejection from './stages/ksemstamp/Rejection.svelte';
import SResult from './stages/ksemstamp/Result.svelte';
import TRValues from './stages/textseal/RValues.svelte';
import TGumbel from './stages/textseal/Gumbel.svelte';
import TEvidence from './stages/textseal/Evidence.svelte';
import EditDetect from './stages/EditDetect.svelte';
const method = $derived($activeMethod);
const meta = $derived(METHOD_META[method]);
const wizard = $derived($wizards[method]);
const unlocked = $derived(highestUnlocked(wizard));
const STAGE_NUMS: Stage[] = [1, 2, 3, 4];
const NUM_LABEL = ['1', '2', '3', '4'];
function lockedReason(s: Stage): string {
if (s <= unlocked) return '';
if (s === 2) return 'Enter a seed in stage 1 first';
return 'Generate the watermarked text first';
}
</script>
<section class="panel wm">
<div class="methods">
{#each WATERMARKS as m}
<button class="method" class:active={m === method} onclick={() => activeMethod.set(m)}>
{METHOD_META[m].title}
<span class="badge">{METHOD_META[m].year}</span>
</button>
{/each}
<button
class="export"
title="Download seed, parameters, trace and scores as JSON"
disabled={!wizard.result}
onclick={() => downloadExport(method)}>export JSON</button
>
</div>
<p class="tagline dim small">{meta.tagline}</p>
<div class="stages">
{#each STAGE_NUMS as s, i}
{@const locked = s > unlocked}
<button
class="stage-tab"
class:active={wizard.stage === s}
class:locked
disabled={locked}
title={lockedReason(s)}
onclick={() => setStage(method, s)}
>
<span class="num">{NUM_LABEL[i]}</span>
{meta.stages[i]}
</button>
{/each}
</div>
<div class="body">
{#if wizard.error}
<p class="err small mono">{wizard.error}</p>
{/if}
{#if method === 'kirchenbauer'}
{#if wizard.stage === 1}
<KSplit {wizard} />
{:else if wizard.stage === 2}
<KBias {wizard} />
{:else if wizard.stage === 3}
<KResult {wizard} />
{:else}
<EditDetect {wizard} />
{/if}
{:else if method === 'ksemstamp'}
{#if wizard.stage === 1}
<SClusters {wizard} />
{:else if wizard.stage === 2}
<SRejection {wizard} />
{:else if wizard.stage === 3}
<SResult {wizard} />
{:else}
<EditDetect {wizard} />
{/if}
{:else if wizard.stage === 1}
<TRValues {wizard} />
{:else if wizard.stage === 2}
<TGumbel {wizard} />
{:else if wizard.stage === 3}
<TEvidence {wizard} />
{:else}
<EditDetect {wizard} />
{/if}
</div>
</section>
<style>
.wm {
display: flex;
flex-direction: column;
gap: 10px;
min-width: 0;
}
.methods {
display: flex;
gap: 6px;
align-items: center;
flex-wrap: wrap;
}
.method {
display: flex;
align-items: center;
gap: 6px;
font-weight: 550;
}
.method.active {
border-color: var(--accent);
background: var(--accent-soft);
color: var(--accent);
}
.export {
margin-left: auto;
font-size: 12.5px;
padding: 4px 10px;
}
.tagline {
margin: 0;
}
.stages {
display: flex;
gap: 4px;
border-bottom: 1px solid var(--border);
padding-bottom: 8px;
flex-wrap: wrap;
}
.stage-tab {
display: flex;
align-items: center;
gap: 6px;
font-size: 13px;
padding: 4px 10px;
border-color: transparent;
background: transparent;
}
.stage-tab .num {
display: inline-flex;
align-items: center;
justify-content: center;
width: 18px;
height: 18px;
border-radius: 50%;
background: var(--panel-3);
font-size: 11px;
font-weight: 700;
}
.stage-tab.active {
background: var(--accent-soft);
border-color: var(--accent);
color: var(--accent);
}
.stage-tab.active .num {
background: var(--accent);
color: #fff;
}
.stage-tab.locked {
opacity: 0.4;
}
.body {
min-height: 260px;
}
.err {
color: var(--red);
white-space: pre-wrap;
}
</style>
|