@myrmidon/cadmus-text-segment 0.0.0-stage → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1702 @@
1
+ import * as i0 from "@angular/core";
2
+ import { ChangeDetectionStrategy, Component, DOCUMENT, Injectable, InjectionToken, computed, effect, inject, input, linkedSignal, model, output, signal, untracked, viewChild } from "@angular/core";
3
+ import { NgComponentOutlet } from "@angular/common";
4
+ import { FormField, form } from "@angular/forms/signals";
5
+ import { CdkConnectedOverlay } from "@angular/cdk/overlay";
6
+ import { MatIconButton } from "@angular/material/button";
7
+ import { MatFormField, MatHint, MatPrefix, MatSuffix } from "@angular/material/form-field";
8
+ import { MatIcon } from "@angular/material/icon";
9
+ import { MatInput } from "@angular/material/input";
10
+ import { MatSlider, MatSliderThumb } from "@angular/material/slider";
11
+ import { MatTooltip } from "@angular/material/tooltip";
12
+ const DEFAULT_SEGMENTED_TEXT_SETTINGS = Object.freeze({
13
+ segmentOffset: 2,
14
+ lineOffset: 6,
15
+ blockOffset: 12,
16
+ showBlockNumbers: true,
17
+ wrapMode: "segment",
18
+ showIdBox: false,
19
+ showIndexBox: false,
20
+ showTipBox: false,
21
+ color: "var(--mat-sys-surface-container-low)",
22
+ textColor: "var(--mat-sys-on-surface)",
23
+ borderColor: "var(--mat-sys-outline-variant)",
24
+ selectionColor: "var(--mat-sys-primary)",
25
+ selectionTextColor: "var(--mat-sys-on-primary)",
26
+ resultColor: "var(--mat-sys-tertiary-container)",
27
+ resultTextColor: "var(--mat-sys-on-tertiary-container)",
28
+ caretColor: "var(--mat-sys-primary)",
29
+ fontFace: "Roboto, 'Helvetica Neue', Arial, sans-serif",
30
+ fontSize: "18px",
31
+ textRectHeight: 28,
32
+ textRectMinWidth: 10,
33
+ textRectPadding: 3,
34
+ textRectRadius: 4,
35
+ textRectStrokeWidth: 1,
36
+ infoFontFace: "'Roboto Mono', Consolas, monospace",
37
+ infoFontSize: "10px",
38
+ infoRectHeight: 14,
39
+ tipFontFace: "Roboto, 'Helvetica Neue', Arial, sans-serif",
40
+ tipFontSize: "10px",
41
+ tipRectHeight: 14,
42
+ tipMaxLength: 30,
43
+ tipPosition: "popup"
44
+ });
45
+ function resolveSegmentedTextSettings(settings) {
46
+ if (!settings) return DEFAULT_SEGMENTED_TEXT_SETTINGS;
47
+ const resolved = { ...DEFAULT_SEGMENTED_TEXT_SETTINGS };
48
+ for (const [key, value] of Object.entries(settings)) if (value !== void 0) resolved[key] = value;
49
+ return resolved;
50
+ }
51
+ const TEXT_SEGMENTER = new InjectionToken("TEXT_SEGMENTER");
52
+ const PLACEHOLDER_REGEX = /\{\{\s*([^{}]+?)\s*\}\}/g;
53
+ function resolvePath(obj, path) {
54
+ let current = obj;
55
+ for (const step of path.split(".")) {
56
+ if (current === null || current === void 0) return;
57
+ if (typeof current !== "object" && typeof current !== "function") return;
58
+ current = current[step];
59
+ }
60
+ return current;
61
+ }
62
+ function valueToString(value) {
63
+ if (value === null || value === void 0) return "";
64
+ if (typeof value === "object") try {
65
+ return JSON.stringify(value);
66
+ } catch {
67
+ return "";
68
+ }
69
+ return String(value);
70
+ }
71
+ function fillTipTemplate(template, segment) {
72
+ return template.replace(PLACEHOLDER_REGEX, (_, path) => {
73
+ switch (path) {
74
+ case "$id": return String(segment.id);
75
+ case "$index": return String(segment.index);
76
+ case "$value": return segment.value;
77
+ case "$label": return segment.label ?? segment.value;
78
+ default: return valueToString(resolvePath(segment.payload, path));
79
+ }
80
+ }).trim();
81
+ }
82
+ function truncateText(text, maxLength) {
83
+ if (!maxLength || maxLength < 1 || text.length <= maxLength) return text;
84
+ return text.substring(0, maxLength) + "…";
85
+ }
86
+ function resolveSegmentTip(segment, settings) {
87
+ let tip;
88
+ if (settings.tipFn) tip = settings.tipFn(segment);
89
+ else if (settings.tipTemplate) tip = fillTipTemplate(settings.tipTemplate, segment);
90
+ else tip = segment.tip;
91
+ return tip ? truncateText(tip, settings.tipMaxLength) : "";
92
+ }
93
+ function modeAt(segments, pos) {
94
+ return segments[pos]?.selectionMode ?? "allowed";
95
+ }
96
+ function isAttachedToAllowed(segments, pos) {
97
+ let p = pos;
98
+ while (p >= 0 && modeAt(segments, p) === "attached") p--;
99
+ return p >= 0 && modeAt(segments, p) === "allowed";
100
+ }
101
+ function clampFocus(segments, anchor, focus) {
102
+ focus = Math.max(0, Math.min(segments.length - 1, focus));
103
+ const dir = focus >= anchor ? 1 : -1;
104
+ let reached = anchor;
105
+ for (let p = anchor + dir; dir > 0 ? p <= focus : p >= focus; p += dir) {
106
+ if (modeAt(segments, p) === "blocked") break;
107
+ reached = p;
108
+ }
109
+ return reached;
110
+ }
111
+ function resolveSegmentRange(segments, anchor, focus) {
112
+ const n = segments.length;
113
+ if (anchor < 0 || anchor >= n || n === 0) return null;
114
+ if (modeAt(segments, anchor) === "blocked") return null;
115
+ const reached = clampFocus(segments, anchor, focus);
116
+ let start = Math.min(anchor, reached);
117
+ let end = Math.max(anchor, reached);
118
+ while (start > 0 && modeAt(segments, start) === "attached") start--;
119
+ while (end + 1 < n && modeAt(segments, end + 1) === "attached") end++;
120
+ while (start <= end && modeAt(segments, start) !== "allowed") start++;
121
+ while (end >= start && modeAt(segments, end) !== "allowed" && !(modeAt(segments, end) === "attached" && isAttachedToAllowed(segments, end))) end--;
122
+ return start <= end ? {
123
+ start,
124
+ end
125
+ } : null;
126
+ }
127
+ function findCaretPosition(segments, from, dir) {
128
+ for (let p = from + dir; p >= 0 && p < segments.length; p += dir) if (modeAt(segments, p) === "allowed") return p;
129
+ return -1;
130
+ }
131
+ function findExtendPosition(segments, from, dir) {
132
+ for (let p = from + dir; p >= 0 && p < segments.length; p += dir) {
133
+ const mode = modeAt(segments, p);
134
+ if (mode === "blocked") return -1;
135
+ if (mode === "allowed") return p;
136
+ }
137
+ return -1;
138
+ }
139
+ function findNearestAllowed(segments, pos, min, max) {
140
+ for (let p = pos; p <= max; p++) if (modeAt(segments, p) === "allowed") return p;
141
+ for (let p = pos - 1; p >= min; p--) if (modeAt(segments, p) === "allowed") return p;
142
+ return -1;
143
+ }
144
+ function findTextSegments(blocks, options) {
145
+ const query = options.caseSensitive ? options.query : options.query.toLowerCase();
146
+ if (!query) return [];
147
+ const norm = (s) => options.caseSensitive ? s : s.toLowerCase();
148
+ const matches = [];
149
+ for (const block of blocks) {
150
+ if (!options.crossSegments) {
151
+ for (const segment of block.segments) if (norm(segment.value).includes(query)) matches.push([segment.id]);
152
+ continue;
153
+ }
154
+ const starts = [];
155
+ const ends = [];
156
+ let text = "";
157
+ for (const segment of block.segments) {
158
+ starts.push(text.length);
159
+ text += norm(segment.value);
160
+ ends.push(text.length);
161
+ }
162
+ const n = block.segments.length;
163
+ let from = 0;
164
+ let at;
165
+ let i = 0;
166
+ while ((at = text.indexOf(query, from)) > -1) {
167
+ const end = at + query.length;
168
+ while (i < n && ends[i] <= at) i++;
169
+ const ids = [];
170
+ for (let j = i; j < n && starts[j] < end; j++) if (ends[j] > at) ids.push(block.segments[j].id);
171
+ matches.push(ids);
172
+ from = end;
173
+ }
174
+ }
175
+ return matches;
176
+ }
177
+ var TextMeasureService = class TextMeasureService {
178
+ _document = inject(DOCUMENT, { optional: true });
179
+ _context;
180
+ _cache = /* @__PURE__ */ new Map();
181
+ _version = signal(0, ...ngDevMode ? [{ debugName: "_version" }] : /* istanbul ignore next */ []);
182
+ version = this._version.asReadonly();
183
+ constructor() {
184
+ const fonts = this._document?.fonts;
185
+ if (fonts) {
186
+ const invalidate = () => this.invalidate();
187
+ if (fonts.status !== "loaded") fonts.ready?.then(invalidate).catch(() => void 0);
188
+ fonts.addEventListener?.("loadingdone", invalidate);
189
+ }
190
+ }
191
+ getContext() {
192
+ if (this._context === void 0) try {
193
+ this._context = typeof OffscreenCanvas !== "undefined" ? new OffscreenCanvas(1, 1).getContext("2d") : null;
194
+ } catch {
195
+ this._context = null;
196
+ }
197
+ return this._context;
198
+ }
199
+ invalidate() {
200
+ this._cache.clear();
201
+ this._version.update((v) => v + 1);
202
+ }
203
+ static estimate(text, fontSize) {
204
+ const m = /([\d.]+)\s*(px|pt|r?em)?/.exec(fontSize);
205
+ let px = m ? parseFloat(m[1]) : 16;
206
+ switch (m?.[2]) {
207
+ case "pt":
208
+ px = px * 4 / 3;
209
+ break;
210
+ case "em":
211
+ case "rem": px *= 16;
212
+ }
213
+ return [...text].length * px * .6;
214
+ }
215
+ measure(text, fontFace, fontSize) {
216
+ if (!text) return 0;
217
+ const font = `${fontSize} ${fontFace}`;
218
+ const key = font + "\0" + text;
219
+ let width = this._cache.get(key);
220
+ if (width === void 0) {
221
+ const ctx = this.getContext();
222
+ if (ctx) {
223
+ ctx.font = font;
224
+ width = ctx.measureText(text).width;
225
+ } else width = TextMeasureService.estimate(text, fontSize);
226
+ this._cache.set(key, width);
227
+ }
228
+ return width;
229
+ }
230
+ static ɵfac = i0.ɵɵngDeclareFactory({
231
+ minVersion: "12.0.0",
232
+ version: "22.2.6",
233
+ ngImport: i0,
234
+ type: TextMeasureService,
235
+ deps: [],
236
+ target: i0.ɵɵFactoryTarget.Injectable
237
+ });
238
+ static ɵprov = i0.ɵɵngDeclareInjectable({
239
+ minVersion: "12.0.0",
240
+ version: "22.2.6",
241
+ ngImport: i0,
242
+ type: TextMeasureService,
243
+ providedIn: "root"
244
+ });
245
+ };
246
+ i0.ɵɵngDeclareClassMetadata({
247
+ minVersion: "12.0.0",
248
+ version: "22.2.6",
249
+ ngImport: i0,
250
+ type: TextMeasureService,
251
+ decorators: [{
252
+ type: Injectable,
253
+ args: [{ providedIn: "root" }]
254
+ }],
255
+ ctorParameters: () => []
256
+ });
257
+ function sameIds$1(a, b) {
258
+ if (a === b) return true;
259
+ if (a.length !== b.length) return false;
260
+ for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;
261
+ return true;
262
+ }
263
+ var SegmentedTextStore = class SegmentedTextStore {
264
+ _anchorId = signal(null, ...ngDevMode ? [{ debugName: "_anchorId" }] : /* istanbul ignore next */ []);
265
+ _focusId = signal(null, ...ngDevMode ? [{ debugName: "_focusId" }] : /* istanbul ignore next */ []);
266
+ _selectedIds = signal([], ...ngDevMode ? [{ debugName: "_selectedIds" }] : /* istanbul ignore next */ []);
267
+ blocks = signal([], ...ngDevMode ? [{ debugName: "blocks" }] : /* istanbul ignore next */ []);
268
+ segments = computed(() => this.blocks().flatMap((b) => b.segments), ...ngDevMode ? [{ debugName: "segments" }] : /* istanbul ignore next */ []);
269
+ positions = computed(() => {
270
+ const map = /* @__PURE__ */ new Map();
271
+ this.segments().forEach((s, i) => map.set(s.id, i));
272
+ return map;
273
+ }, ...ngDevMode ? [{ debugName: "positions" }] : /* istanbul ignore next */ []);
274
+ _blockRanges = computed(() => {
275
+ let start = 0;
276
+ return this.blocks().map((b) => {
277
+ const range = {
278
+ start,
279
+ end: start + b.segments.length
280
+ };
281
+ start = range.end;
282
+ return range;
283
+ });
284
+ }, ...ngDevMode ? [{ debugName: "_blockRanges" }] : /* istanbul ignore next */ []);
285
+ selectedIds = this._selectedIds.asReadonly();
286
+ selectedSet = computed(() => new Set(this._selectedIds()), ...ngDevMode ? [{ debugName: "selectedSet" }] : /* istanbul ignore next */ []);
287
+ selectedSegments = computed(() => {
288
+ const segments = this.segments();
289
+ const positions = this.positions();
290
+ return this._selectedIds().map((id) => segments[positions.get(id)]).filter((s) => !!s);
291
+ }, ...ngDevMode ? [{ debugName: "selectedSegments" }] : /* istanbul ignore next */ []);
292
+ caretId = computed(() => {
293
+ const id = this._focusId();
294
+ return id !== null && this.positions().has(id) ? id : null;
295
+ }, ...ngDevMode ? [{ debugName: "caretId" }] : /* istanbul ignore next */ []);
296
+ find = signal({
297
+ query: "",
298
+ crossSegments: false,
299
+ caseSensitive: false
300
+ }, ...ngDevMode ? [{ debugName: "find" }] : /* istanbul ignore next */ []);
301
+ matches = computed(() => findTextSegments(this.blocks(), this.find()), ...ngDevMode ? [{ debugName: "matches" }] : /* istanbul ignore next */ []);
302
+ hitSet = computed(() => new Set(this.matches().flat()), ...ngDevMode ? [{ debugName: "hitSet" }] : /* istanbul ignore next */ []);
303
+ currentMatch = linkedSignal({
304
+ ...ngDevMode ? { debugName: "currentMatch" } : /* istanbul ignore next */ {},
305
+ source: this.matches,
306
+ computation: () => -1
307
+ });
308
+ posOf(id) {
309
+ return id === null ? -1 : this.positions().get(id) ?? -1;
310
+ }
311
+ blockIndexOf(pos) {
312
+ const ranges = this._blockRanges();
313
+ let lo = 0;
314
+ let hi = ranges.length - 1;
315
+ while (lo <= hi) {
316
+ const mid = lo + hi >> 1;
317
+ if (pos < ranges[mid].start) hi = mid - 1;
318
+ else if (pos >= ranges[mid].end) lo = mid + 1;
319
+ else return mid;
320
+ }
321
+ return -1;
322
+ }
323
+ setIds(ids) {
324
+ if (sameIds$1(ids, this._selectedIds())) return false;
325
+ this._selectedIds.set(ids);
326
+ return true;
327
+ }
328
+ applyRange(anchor, focus) {
329
+ const segments = this.segments();
330
+ if (anchor > -1 && segments[anchor]?.selectionMode !== "blocked") focus = clampFocus(segments, anchor, focus);
331
+ this._anchorId.set(segments[anchor]?.id ?? null);
332
+ this._focusId.set(segments[focus]?.id ?? null);
333
+ const range = resolveSegmentRange(segments, anchor, focus);
334
+ return this.setIds(range ? segments.slice(range.start, range.end + 1).map((s) => s.id) : []);
335
+ }
336
+ moveFocus(pos, extend) {
337
+ if (pos < 0) return false;
338
+ const anchor = this.posOf(this._anchorId());
339
+ return this.applyRange(extend && anchor > -1 ? anchor : pos, pos);
340
+ }
341
+ setBlocks(blocks) {
342
+ this.blocks.set(blocks);
343
+ const positions = this.positions();
344
+ if (this._anchorId() !== null && !positions.has(this._anchorId())) this._anchorId.set(null);
345
+ if (this._focusId() !== null && !positions.has(this._focusId())) this._focusId.set(null);
346
+ return this.setIds(this._selectedIds().filter((id) => positions.has(id)));
347
+ }
348
+ startAt(id, extend = false) {
349
+ return this.moveFocus(this.posOf(id), extend);
350
+ }
351
+ extendTo(id) {
352
+ if (id === this._focusId()) return false;
353
+ return this.moveFocus(this.posOf(id), true);
354
+ }
355
+ moveCaret(dir, extend = false) {
356
+ const segments = this.segments();
357
+ const focus = this.posOf(this._focusId());
358
+ if (focus < 0) return this.moveFocus(findCaretPosition(segments, dir > 0 ? -1 : segments.length, dir), false);
359
+ return this.moveFocus(extend ? findExtendPosition(segments, focus, dir) : findCaretPosition(segments, focus, dir), extend);
360
+ }
361
+ moveBlock(dir, extend = false) {
362
+ const focus = this.posOf(this._focusId());
363
+ if (focus < 0) return this.moveCaret(dir, extend);
364
+ const ranges = this._blockRanges();
365
+ const bi = this.blockIndexOf(focus);
366
+ const offset = focus - ranges[bi].start;
367
+ for (let b = bi + dir; b >= 0 && b < ranges.length; b += dir) {
368
+ const r = ranges[b];
369
+ if (r.end > r.start) {
370
+ const target = Math.min(r.start + offset, r.end - 1);
371
+ return this.moveFocus(findNearestAllowed(this.segments(), target, r.start, r.end - 1), extend);
372
+ }
373
+ }
374
+ return false;
375
+ }
376
+ moveToBlockEdge(edge, extend = false) {
377
+ const focus = this.posOf(this._focusId());
378
+ if (focus < 0) return this.moveToTextEdge(edge, extend);
379
+ const r = this._blockRanges()[this.blockIndexOf(focus)];
380
+ return this.moveToEdge(r.start, r.end - 1, edge, extend);
381
+ }
382
+ moveToTextEdge(edge, extend = false) {
383
+ return this.moveToEdge(0, this.segments().length - 1, edge, extend);
384
+ }
385
+ moveToEdge(min, max, edge, extend) {
386
+ const segments = this.segments();
387
+ let pos;
388
+ if (edge === "start") {
389
+ pos = findCaretPosition(segments, min - 1, 1);
390
+ if (pos > max) pos = -1;
391
+ } else {
392
+ pos = findCaretPosition(segments, max + 1, -1);
393
+ if (pos < min) pos = -1;
394
+ }
395
+ return this.moveFocus(pos, extend);
396
+ }
397
+ selectAll() {
398
+ const segments = this.segments();
399
+ const first = findCaretPosition(segments, -1, 1);
400
+ if (first < 0) return false;
401
+ return this.applyRange(first, segments.length - 1);
402
+ }
403
+ clear() {
404
+ this._anchorId.set(null);
405
+ this._focusId.set(null);
406
+ return this.setIds([]);
407
+ }
408
+ setSelectedIds(ids) {
409
+ const positions = this.positions();
410
+ const sorted = ids.filter((id) => positions.has(id)).sort((a, b) => positions.get(a) - positions.get(b));
411
+ const unique = sorted.filter((id, i) => i === 0 || sorted[i - 1] !== id);
412
+ this._anchorId.set(unique.length ? unique[0] : null);
413
+ this._focusId.set(unique.length ? unique[unique.length - 1] : null);
414
+ return this.setIds(unique);
415
+ }
416
+ goToMatch(dir) {
417
+ const matches = this.matches();
418
+ if (!matches.length) return null;
419
+ const current = this.currentMatch();
420
+ const next = current < 0 ? dir > 0 ? 0 : matches.length - 1 : (current + dir + matches.length) % matches.length;
421
+ this.currentMatch.set(next);
422
+ this.setSelectedIds(matches[next]);
423
+ return matches[next];
424
+ }
425
+ static ɵfac = i0.ɵɵngDeclareFactory({
426
+ minVersion: "12.0.0",
427
+ version: "22.2.6",
428
+ ngImport: i0,
429
+ type: SegmentedTextStore,
430
+ deps: [],
431
+ target: i0.ɵɵFactoryTarget.Injectable
432
+ });
433
+ static ɵprov = i0.ɵɵngDeclareInjectable({
434
+ minVersion: "12.0.0",
435
+ version: "22.2.6",
436
+ ngImport: i0,
437
+ type: SegmentedTextStore
438
+ });
439
+ };
440
+ i0.ɵɵngDeclareClassMetadata({
441
+ minVersion: "12.0.0",
442
+ version: "22.2.6",
443
+ ngImport: i0,
444
+ type: SegmentedTextStore,
445
+ decorators: [{ type: Injectable }]
446
+ });
447
+ const POINT_REGEX = /^(\d+)\.(\d+)(?:@(\d+)(?:x(\d+))?)?$/;
448
+ const WS_REGEX$1 = /^\s+$/u;
449
+ const COMBINING_REGEX = /^\p{M}+$/u;
450
+ var SpacedTextSegmenter = class SpacedTextSegmenter {
451
+ _options;
452
+ _indexes = /* @__PURE__ */ new WeakMap();
453
+ constructor(options) {
454
+ this._options = {
455
+ includeLf: options?.includeLf ?? false,
456
+ spaceLabel: options?.spaceLabel ?? "_",
457
+ combiningMode: options?.combiningMode ?? "wrapped",
458
+ payloadFactory: options?.payloadFactory
459
+ };
460
+ }
461
+ getLabel(char) {
462
+ const code = char.charCodeAt(0);
463
+ if (char.length === 1) {
464
+ if (code < 32) return String.fromCharCode(9216 + code);
465
+ if (code === 32) return this._options.spaceLabel;
466
+ if (code === 127) return "␡";
467
+ }
468
+ }
469
+ createSegment(char, id, index) {
470
+ const segment = {
471
+ id,
472
+ index,
473
+ value: char
474
+ };
475
+ const label = this.getLabel(char);
476
+ if (label !== void 0) segment.label = label;
477
+ if (WS_REGEX$1.test(char)) segment.selectionMode = "wrapped";
478
+ else if (COMBINING_REGEX.test(char)) segment.selectionMode = this._options.combiningMode;
479
+ const payload = this._options.payloadFactory?.(char, id, index);
480
+ if (payload !== void 0) segment.payload = payload;
481
+ return segment;
482
+ }
483
+ getBlocks(text) {
484
+ if (!text) return [];
485
+ const blocks = [{
486
+ index: 0,
487
+ segments: []
488
+ }];
489
+ let id = 0;
490
+ let index = 0;
491
+ for (const char of text) {
492
+ id++;
493
+ const at = index;
494
+ index += char.length;
495
+ if (char === "\r") continue;
496
+ const block = blocks[blocks.length - 1];
497
+ if (char === "\n") {
498
+ if (this._options.includeLf) block.segments.push(this.createSegment(char, id, at));
499
+ blocks.push({
500
+ index: blocks.length,
501
+ segments: []
502
+ });
503
+ continue;
504
+ }
505
+ block.segments.push(this.createSegment(char, id, at));
506
+ }
507
+ return blocks;
508
+ }
509
+ getIndex(blocks) {
510
+ let index = this._indexes.get(blocks);
511
+ if (index) return index;
512
+ index = {
513
+ tokens: [],
514
+ locations: /* @__PURE__ */ new Map(),
515
+ positions: /* @__PURE__ */ new Map(),
516
+ segments: []
517
+ };
518
+ for (const block of blocks) {
519
+ const tokens = [];
520
+ let token = null;
521
+ for (const segment of block.segments) {
522
+ index.positions.set(segment.id, index.segments.length);
523
+ index.segments.push(segment);
524
+ if (WS_REGEX$1.test(segment.value)) {
525
+ token = null;
526
+ continue;
527
+ }
528
+ if (!token) {
529
+ token = [];
530
+ tokens.push(token);
531
+ }
532
+ token.push(segment);
533
+ }
534
+ index.tokens.push(tokens);
535
+ }
536
+ index.tokens.forEach((tokens, yi) => tokens.forEach((token, xi) => token.forEach((segment, ai) => index.locations.set(segment.id, {
537
+ y: yi + 1,
538
+ x: xi + 1,
539
+ at: ai + 1,
540
+ length: token.length
541
+ }))));
542
+ this._indexes.set(blocks, index);
543
+ return index;
544
+ }
545
+ getSegmentCoords(blocks, segments) {
546
+ const index = this.getIndex(blocks);
547
+ const located = segments.map((s) => index.locations.get(s.id)).filter((l) => !!l);
548
+ if (!located.length) return "";
549
+ const first = located[0];
550
+ const last = located[located.length - 1];
551
+ const run = (r) => r > 1 ? `x${r}` : "";
552
+ if (first.y === last.y && first.x === last.x) {
553
+ if (first.at === 1 && last.at === last.length) return `${first.y}.${first.x}`;
554
+ return `${first.y}.${first.x}@${first.at}${run(last.at - first.at + 1)}`;
555
+ }
556
+ return `${first.at === 1 ? `${first.y}.${first.x}` : `${first.y}.${first.x}@${first.at}${run(first.length - first.at + 1)}`}-${last.at === last.length ? `${last.y}.${last.x}` : `${last.y}.${last.x}@1${run(last.at)}`}`;
557
+ }
558
+ static parsePoint(text) {
559
+ const m = POINT_REGEX.exec(text.trim());
560
+ if (!m) return null;
561
+ const point = {
562
+ y: +m[1],
563
+ x: +m[2]
564
+ };
565
+ if (m[3] !== void 0) point.at = +m[3];
566
+ if (m[4] !== void 0) point.run = +m[4];
567
+ if (point.y < 1 || point.x < 1 || point.at === 0 || point.run === 0) return null;
568
+ return point;
569
+ }
570
+ getCoordsSegments(blocks, coords) {
571
+ const parts = (coords || "").split("-");
572
+ if (parts.length > 2) return null;
573
+ const points = parts.map((p) => SpacedTextSegmenter.parsePoint(p));
574
+ if (points.some((p) => !p)) return null;
575
+ const index = this.getIndex(blocks);
576
+ const pick = (p, whole) => {
577
+ const token = index.tokens[p.y - 1]?.[p.x - 1];
578
+ if (!token) return null;
579
+ if (p.at === void 0) return token;
580
+ const run = p.run ?? 1;
581
+ const last = p.at + run - 1;
582
+ if (last > token.length) return null;
583
+ if (whole === "start") return token.slice(p.at - 1);
584
+ return token.slice(p.at - 1, last);
585
+ };
586
+ if (points.length === 1) return pick(points[0], "both");
587
+ const head = pick(points[0], "start");
588
+ const tail = pick(points[1], "end");
589
+ if (!head?.length || !tail?.length) return null;
590
+ const start = index.positions.get(head[0].id);
591
+ const end = index.positions.get(tail[tail.length - 1].id);
592
+ if (start > end) return null;
593
+ return index.segments.slice(start, end + 1);
594
+ }
595
+ };
596
+ const BOX_GAP = 2;
597
+ var TextSegmentView = class TextSegmentView {
598
+ _measure = inject(TextMeasureService);
599
+ segment = input.required(...ngDevMode ? [{ debugName: "segment" }] : /* istanbul ignore next */ []);
600
+ settings = input(DEFAULT_SEGMENTED_TEXT_SETTINGS, ...ngDevMode ? [{ debugName: "settings" }] : /* istanbul ignore next */ []);
601
+ selected = input(false, ...ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []);
602
+ hit = input(false, ...ngDevMode ? [{ debugName: "hit" }] : /* istanbul ignore next */ []);
603
+ caret = input(false, ...ngDevMode ? [{ debugName: "caret" }] : /* istanbul ignore next */ []);
604
+ label = computed(() => {
605
+ const segment = this.segment();
606
+ return segment.label ?? segment.value;
607
+ }, ...ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []);
608
+ hostClass = computed(() => {
609
+ const classes = ["cadmus-text-segment-view"];
610
+ if (this.selected()) classes.push("selected");
611
+ if (this.hit()) classes.push("hit");
612
+ if (this.caret()) classes.push("caret");
613
+ const mode = this.segment().selectionMode;
614
+ if (mode && mode !== "allowed") classes.push("mode-" + mode);
615
+ const css = this.segment().cssClass;
616
+ if (css) classes.push(css);
617
+ return classes.join(" ");
618
+ }, ...ngDevMode ? [{ debugName: "hostClass" }] : /* istanbul ignore next */ []);
619
+ tipBelow = computed(() => {
620
+ const s = this.settings();
621
+ return !!s.showTipBox && s.tipPosition === "below";
622
+ }, ...ngDevMode ? [{ debugName: "tipBelow" }] : /* istanbul ignore next */ []);
623
+ tipText = computed(() => {
624
+ const s = this.settings();
625
+ return this.tipBelow() && !s.tipComponent ? resolveSegmentTip(this.segment(), s) : "";
626
+ }, ...ngDevMode ? [{ debugName: "tipText" }] : /* istanbul ignore next */ []);
627
+ tipInputs = computed(() => ({ segment: this.segment() }), ...ngDevMode ? [{ debugName: "tipInputs" }] : /* istanbul ignore next */ []);
628
+ geometry = computed(() => {
629
+ const s = this.settings();
630
+ const segment = this.segment();
631
+ this._measure.version();
632
+ const strokeWidth = s.textRectStrokeWidth ?? 1;
633
+ const padding = s.textRectPadding ?? 0;
634
+ let width = Math.max(this._measure.measure(this.label(), s.fontFace, s.fontSize) + padding * 2, s.textRectMinWidth ?? 0);
635
+ const measureInfo = (text) => this._measure.measure(text, s.infoFontFace, s.infoFontSize) + 4;
636
+ if (s.showIdBox) width = Math.max(width, measureInfo(String(segment.id)));
637
+ if (s.showIndexBox) width = Math.max(width, measureInfo(String(segment.index)));
638
+ width = Math.ceil(width + strokeWidth);
639
+ const g = {
640
+ width,
641
+ height: s.textRectHeight,
642
+ strokeWidth,
643
+ radius: s.textRectRadius ?? 0,
644
+ text: {
645
+ y: 0,
646
+ height: s.textRectHeight
647
+ }
648
+ };
649
+ const stack = (height) => {
650
+ const box = {
651
+ y: g.height + BOX_GAP,
652
+ height
653
+ };
654
+ g.height = box.y + height;
655
+ return box;
656
+ };
657
+ if (s.showIdBox) g.id = stack(s.infoRectHeight);
658
+ if (s.showIndexBox) g.index = stack(s.infoRectHeight);
659
+ if (this.tipBelow()) g.tip = stack(s.tipRectHeight);
660
+ return g;
661
+ }, ...ngDevMode ? [{ debugName: "geometry" }] : /* istanbul ignore next */ []);
662
+ fill = computed(() => {
663
+ const s = this.settings();
664
+ if (this.selected()) return s.selectionColor;
665
+ if (this.hit()) return s.resultColor;
666
+ return this.segment().color ?? s.color;
667
+ }, ...ngDevMode ? [{ debugName: "fill" }] : /* istanbul ignore next */ []);
668
+ textFill = computed(() => {
669
+ const s = this.settings();
670
+ if (this.selected()) return s.selectionTextColor;
671
+ if (this.hit()) return s.resultTextColor;
672
+ return this.segment().textColor ?? s.textColor;
673
+ }, ...ngDevMode ? [{ debugName: "textFill" }] : /* istanbul ignore next */ []);
674
+ stroke = computed(() => this.segment().borderColor ?? this.settings().borderColor, ...ngDevMode ? [{ debugName: "stroke" }] : /* istanbul ignore next */ []);
675
+ static ɵfac = i0.ɵɵngDeclareFactory({
676
+ minVersion: "12.0.0",
677
+ version: "22.2.6",
678
+ ngImport: i0,
679
+ type: TextSegmentView,
680
+ deps: [],
681
+ target: i0.ɵɵFactoryTarget.Component
682
+ });
683
+ static ɵcmp = i0.ɵɵngDeclareComponent({
684
+ minVersion: "17.0.0",
685
+ version: "22.2.6",
686
+ type: TextSegmentView,
687
+ isStandalone: true,
688
+ selector: "cadmus-text-segment-view",
689
+ inputs: {
690
+ segment: {
691
+ classPropertyName: "segment",
692
+ publicName: "segment",
693
+ isSignal: true,
694
+ isRequired: true,
695
+ transformFunction: null
696
+ },
697
+ settings: {
698
+ classPropertyName: "settings",
699
+ publicName: "settings",
700
+ isSignal: true,
701
+ isRequired: false,
702
+ transformFunction: null
703
+ },
704
+ selected: {
705
+ classPropertyName: "selected",
706
+ publicName: "selected",
707
+ isSignal: true,
708
+ isRequired: false,
709
+ transformFunction: null
710
+ },
711
+ hit: {
712
+ classPropertyName: "hit",
713
+ publicName: "hit",
714
+ isSignal: true,
715
+ isRequired: false,
716
+ transformFunction: null
717
+ },
718
+ caret: {
719
+ classPropertyName: "caret",
720
+ publicName: "caret",
721
+ isSignal: true,
722
+ isRequired: false,
723
+ transformFunction: null
724
+ }
725
+ },
726
+ host: {
727
+ attributes: { "role": "option" },
728
+ properties: {
729
+ "attr.data-seg-id": "segment().id",
730
+ "attr.aria-selected": "selected()",
731
+ "attr.aria-label": "label()",
732
+ "class": "hostClass()"
733
+ }
734
+ },
735
+ ngImport: i0,
736
+ template: "@let g = geometry();\n@let s = settings();\n<svg\n [attr.width]=\"g.width\"\n [attr.height]=\"g.height\"\n [attr.viewBox]=\"'0 0 ' + g.width + ' ' + g.height\"\n aria-hidden=\"true\"\n focusable=\"false\"\n>\n <!-- text box -->\n <rect\n class=\"text-rect\"\n [attr.x]=\"g.strokeWidth / 2\"\n [attr.y]=\"g.strokeWidth / 2\"\n [attr.width]=\"g.width - g.strokeWidth\"\n [attr.height]=\"g.text.height - g.strokeWidth\"\n [attr.rx]=\"g.radius\"\n [attr.stroke-width]=\"g.strokeWidth\"\n [attr.stroke-dasharray]=\"s.textRectStrokeDasharray || null\"\n [style.fill]=\"fill()\"\n [style.stroke]=\"stroke()\"\n />\n <text\n class=\"text\"\n [attr.x]=\"g.width / 2\"\n [attr.y]=\"g.text.height / 2\"\n text-anchor=\"middle\"\n dominant-baseline=\"central\"\n [style.fill]=\"textFill()\"\n [style.font-family]=\"s.fontFace\"\n [style.font-size]=\"s.fontSize\"\n >{{ label() }}</text>\n\n <!-- ID box -->\n @if (g.id; as box) {\n <rect\n class=\"info-rect id-rect\"\n x=\"0\"\n [attr.y]=\"box.y\"\n [attr.width]=\"g.width\"\n [attr.height]=\"box.height\"\n [attr.rx]=\"g.radius\"\n />\n <text\n class=\"info-text id-text\"\n [attr.x]=\"g.width / 2\"\n [attr.y]=\"box.y + box.height / 2\"\n text-anchor=\"middle\"\n dominant-baseline=\"central\"\n [style.font-family]=\"s.infoFontFace\"\n [style.font-size]=\"s.infoFontSize\"\n >{{ segment().id }}</text>\n }\n\n <!-- index box -->\n @if (g.index; as box) {\n <rect\n class=\"info-rect index-rect\"\n x=\"0\"\n [attr.y]=\"box.y\"\n [attr.width]=\"g.width\"\n [attr.height]=\"box.height\"\n [attr.rx]=\"g.radius\"\n />\n <text\n class=\"info-text index-text\"\n [attr.x]=\"g.width / 2\"\n [attr.y]=\"box.y + box.height / 2\"\n text-anchor=\"middle\"\n dominant-baseline=\"central\"\n [style.font-family]=\"s.infoFontFace\"\n [style.font-size]=\"s.infoFontSize\"\n >{{ segment().index }}</text>\n }\n\n <!-- tip box -->\n @if (g.tip; as box) {\n @if (s.tipComponent; as tipComponent) {\n <foreignObject\n class=\"tip-html\"\n x=\"0\"\n [attr.y]=\"box.y\"\n [attr.width]=\"g.width\"\n [attr.height]=\"box.height\"\n >\n <div class=\"tip-html-content\">\n <ng-container\n *ngComponentOutlet=\"tipComponent; inputs: tipInputs()\"\n />\n </div>\n </foreignObject>\n } @else {\n <rect\n class=\"tip-rect\"\n x=\"0\"\n [attr.y]=\"box.y\"\n [attr.width]=\"g.width\"\n [attr.height]=\"box.height\"\n [attr.rx]=\"g.radius\"\n />\n <text\n class=\"tip-text\"\n x=\"2\"\n [attr.y]=\"box.y + box.height / 2\"\n dominant-baseline=\"central\"\n [style.font-family]=\"s.tipFontFace\"\n [style.font-size]=\"s.tipFontSize\"\n >{{ tipText() }}</text>\n }\n }\n</svg>\n",
737
+ styles: [":host{display:block;flex:0 0 auto;line-height:0;border-radius:4px;cursor:text}:host(.mode-wrapped),:host(.mode-attached){cursor:default}:host(.mode-blocked){cursor:not-allowed;opacity:.6}:host(.caret){outline:2px solid var(--cadmus-tseg-caret-color, var(--mat-sys-primary));outline-offset:1px}svg{display:block;overflow:hidden}rect,text{transition:fill 80ms linear,stroke 80ms linear}.text{white-space:pre}.info-rect{fill:var(--mat-sys-surface-container-high)}.info-text{fill:var(--mat-sys-on-surface-variant)}.tip-rect{fill:var(--mat-sys-secondary-container)}.tip-text{fill:var(--mat-sys-on-secondary-container)}.tip-html-content{width:100%;height:100%;overflow:hidden;line-height:normal}@media(prefers-reduced-motion:reduce){rect,text{transition:none}}\n"],
738
+ dependencies: [{
739
+ kind: "directive",
740
+ type: NgComponentOutlet,
741
+ selector: "[ngComponentOutlet]",
742
+ inputs: [
743
+ "ngComponentOutlet",
744
+ "ngComponentOutletInputs",
745
+ "ngComponentOutletInjector",
746
+ "ngComponentOutletEnvironmentInjector",
747
+ "ngComponentOutletContent",
748
+ "ngComponentOutletNgModule"
749
+ ],
750
+ exportAs: ["ngComponentOutlet"]
751
+ }],
752
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
753
+ });
754
+ };
755
+ i0.ɵɵngDeclareClassMetadata({
756
+ minVersion: "12.0.0",
757
+ version: "22.2.6",
758
+ ngImport: i0,
759
+ type: TextSegmentView,
760
+ decorators: [{
761
+ type: Component,
762
+ args: [{
763
+ selector: "cadmus-text-segment-view",
764
+ imports: [NgComponentOutlet],
765
+ changeDetection: ChangeDetectionStrategy.OnPush,
766
+ host: {
767
+ role: "option",
768
+ "[attr.data-seg-id]": "segment().id",
769
+ "[attr.aria-selected]": "selected()",
770
+ "[attr.aria-label]": "label()",
771
+ "[class]": "hostClass()"
772
+ },
773
+ template: "@let g = geometry();\n@let s = settings();\n<svg\n [attr.width]=\"g.width\"\n [attr.height]=\"g.height\"\n [attr.viewBox]=\"'0 0 ' + g.width + ' ' + g.height\"\n aria-hidden=\"true\"\n focusable=\"false\"\n>\n <!-- text box -->\n <rect\n class=\"text-rect\"\n [attr.x]=\"g.strokeWidth / 2\"\n [attr.y]=\"g.strokeWidth / 2\"\n [attr.width]=\"g.width - g.strokeWidth\"\n [attr.height]=\"g.text.height - g.strokeWidth\"\n [attr.rx]=\"g.radius\"\n [attr.stroke-width]=\"g.strokeWidth\"\n [attr.stroke-dasharray]=\"s.textRectStrokeDasharray || null\"\n [style.fill]=\"fill()\"\n [style.stroke]=\"stroke()\"\n />\n <text\n class=\"text\"\n [attr.x]=\"g.width / 2\"\n [attr.y]=\"g.text.height / 2\"\n text-anchor=\"middle\"\n dominant-baseline=\"central\"\n [style.fill]=\"textFill()\"\n [style.font-family]=\"s.fontFace\"\n [style.font-size]=\"s.fontSize\"\n >{{ label() }}</text>\n\n <!-- ID box -->\n @if (g.id; as box) {\n <rect\n class=\"info-rect id-rect\"\n x=\"0\"\n [attr.y]=\"box.y\"\n [attr.width]=\"g.width\"\n [attr.height]=\"box.height\"\n [attr.rx]=\"g.radius\"\n />\n <text\n class=\"info-text id-text\"\n [attr.x]=\"g.width / 2\"\n [attr.y]=\"box.y + box.height / 2\"\n text-anchor=\"middle\"\n dominant-baseline=\"central\"\n [style.font-family]=\"s.infoFontFace\"\n [style.font-size]=\"s.infoFontSize\"\n >{{ segment().id }}</text>\n }\n\n <!-- index box -->\n @if (g.index; as box) {\n <rect\n class=\"info-rect index-rect\"\n x=\"0\"\n [attr.y]=\"box.y\"\n [attr.width]=\"g.width\"\n [attr.height]=\"box.height\"\n [attr.rx]=\"g.radius\"\n />\n <text\n class=\"info-text index-text\"\n [attr.x]=\"g.width / 2\"\n [attr.y]=\"box.y + box.height / 2\"\n text-anchor=\"middle\"\n dominant-baseline=\"central\"\n [style.font-family]=\"s.infoFontFace\"\n [style.font-size]=\"s.infoFontSize\"\n >{{ segment().index }}</text>\n }\n\n <!-- tip box -->\n @if (g.tip; as box) {\n @if (s.tipComponent; as tipComponent) {\n <foreignObject\n class=\"tip-html\"\n x=\"0\"\n [attr.y]=\"box.y\"\n [attr.width]=\"g.width\"\n [attr.height]=\"box.height\"\n >\n <div class=\"tip-html-content\">\n <ng-container\n *ngComponentOutlet=\"tipComponent; inputs: tipInputs()\"\n />\n </div>\n </foreignObject>\n } @else {\n <rect\n class=\"tip-rect\"\n x=\"0\"\n [attr.y]=\"box.y\"\n [attr.width]=\"g.width\"\n [attr.height]=\"box.height\"\n [attr.rx]=\"g.radius\"\n />\n <text\n class=\"tip-text\"\n x=\"2\"\n [attr.y]=\"box.y + box.height / 2\"\n dominant-baseline=\"central\"\n [style.font-family]=\"s.tipFontFace\"\n [style.font-size]=\"s.tipFontSize\"\n >{{ tipText() }}</text>\n }\n }\n</svg>\n",
774
+ styles: [":host{display:block;flex:0 0 auto;line-height:0;border-radius:4px;cursor:text}:host(.mode-wrapped),:host(.mode-attached){cursor:default}:host(.mode-blocked){cursor:not-allowed;opacity:.6}:host(.caret){outline:2px solid var(--cadmus-tseg-caret-color, var(--mat-sys-primary));outline-offset:1px}svg{display:block;overflow:hidden}rect,text{transition:fill 80ms linear,stroke 80ms linear}.text{white-space:pre}.info-rect{fill:var(--mat-sys-surface-container-high)}.info-text{fill:var(--mat-sys-on-surface-variant)}.tip-rect{fill:var(--mat-sys-secondary-container)}.tip-text{fill:var(--mat-sys-on-secondary-container)}.tip-html-content{width:100%;height:100%;overflow:hidden;line-height:normal}@media(prefers-reduced-motion:reduce){rect,text{transition:none}}\n"]
775
+ }]
776
+ }],
777
+ propDecorators: {
778
+ segment: [{
779
+ type: i0.Input,
780
+ args: [{
781
+ isSignal: true,
782
+ alias: "segment",
783
+ required: true
784
+ }]
785
+ }],
786
+ settings: [{
787
+ type: i0.Input,
788
+ args: [{
789
+ isSignal: true,
790
+ alias: "settings",
791
+ required: false
792
+ }]
793
+ }],
794
+ selected: [{
795
+ type: i0.Input,
796
+ args: [{
797
+ isSignal: true,
798
+ alias: "selected",
799
+ required: false
800
+ }]
801
+ }],
802
+ hit: [{
803
+ type: i0.Input,
804
+ args: [{
805
+ isSignal: true,
806
+ alias: "hit",
807
+ required: false
808
+ }]
809
+ }],
810
+ caret: [{
811
+ type: i0.Input,
812
+ args: [{
813
+ isSignal: true,
814
+ alias: "caret",
815
+ required: false
816
+ }]
817
+ }]
818
+ }
819
+ });
820
+ const EMPTY_SET = /* @__PURE__ */ new Set();
821
+ const WS_REGEX = /^\s+$/u;
822
+ function getTextSegmentRuns(segments) {
823
+ const runs = [];
824
+ let run = [];
825
+ for (const segment of segments) {
826
+ run.push(segment);
827
+ if (WS_REGEX.test(segment.value)) {
828
+ runs.push(run);
829
+ run = [];
830
+ }
831
+ }
832
+ if (run.length) runs.push(run);
833
+ return runs;
834
+ }
835
+ var TextSegmentBlockView = class TextSegmentBlockView {
836
+ block = input.required(...ngDevMode ? [{ debugName: "block" }] : /* istanbul ignore next */ []);
837
+ settings = input(DEFAULT_SEGMENTED_TEXT_SETTINGS, ...ngDevMode ? [{ debugName: "settings" }] : /* istanbul ignore next */ []);
838
+ selectedIds = input(EMPTY_SET, ...ngDevMode ? [{ debugName: "selectedIds" }] : /* istanbul ignore next */ []);
839
+ hitIds = input(EMPTY_SET, ...ngDevMode ? [{ debugName: "hitIds" }] : /* istanbul ignore next */ []);
840
+ caretId = input(null, ...ngDevMode ? [{ debugName: "caretId" }] : /* istanbul ignore next */ []);
841
+ runs = computed(() => this.settings().wrapMode === "word" ? getTextSegmentRuns(this.block().segments) : null, ...ngDevMode ? [{ debugName: "runs" }] : /* istanbul ignore next */ []);
842
+ static ɵfac = i0.ɵɵngDeclareFactory({
843
+ minVersion: "12.0.0",
844
+ version: "22.2.6",
845
+ ngImport: i0,
846
+ type: TextSegmentBlockView,
847
+ deps: [],
848
+ target: i0.ɵɵFactoryTarget.Component
849
+ });
850
+ static ɵcmp = i0.ɵɵngDeclareComponent({
851
+ minVersion: "17.0.0",
852
+ version: "22.2.6",
853
+ type: TextSegmentBlockView,
854
+ isStandalone: true,
855
+ selector: "cadmus-text-segment-block-view",
856
+ inputs: {
857
+ block: {
858
+ classPropertyName: "block",
859
+ publicName: "block",
860
+ isSignal: true,
861
+ isRequired: true,
862
+ transformFunction: null
863
+ },
864
+ settings: {
865
+ classPropertyName: "settings",
866
+ publicName: "settings",
867
+ isSignal: true,
868
+ isRequired: false,
869
+ transformFunction: null
870
+ },
871
+ selectedIds: {
872
+ classPropertyName: "selectedIds",
873
+ publicName: "selectedIds",
874
+ isSignal: true,
875
+ isRequired: false,
876
+ transformFunction: null
877
+ },
878
+ hitIds: {
879
+ classPropertyName: "hitIds",
880
+ publicName: "hitIds",
881
+ isSignal: true,
882
+ isRequired: false,
883
+ transformFunction: null
884
+ },
885
+ caretId: {
886
+ classPropertyName: "caretId",
887
+ publicName: "caretId",
888
+ isSignal: true,
889
+ isRequired: false,
890
+ transformFunction: null
891
+ }
892
+ },
893
+ host: {
894
+ attributes: { "role": "group" },
895
+ properties: {
896
+ "attr.data-block-index": "block().index",
897
+ "attr.aria-label": "\"block \" + (block().index + 1)"
898
+ }
899
+ },
900
+ ngImport: i0,
901
+ template: "@let s = settings();\n@if (s.showBlockNumbers) {\n <div\n class=\"block-number\"\n aria-hidden=\"true\"\n [style.line-height.px]=\"s.textRectHeight\"\n >\n {{ block().index + 1 }}\n </div>\n}\n<div\n class=\"segments\"\n [style.column-gap.px]=\"s.segmentOffset\"\n [style.row-gap.px]=\"s.lineOffset\"\n [style.min-height.px]=\"s.textRectHeight\"\n>\n @if (runs(); as runs) {\n <!-- word wrap: each run (e.g. a word with its trailing space) stays\n together, unless it is wider than the whole line -->\n @for (run of runs; track run[0].id) {\n <div\n class=\"run\"\n [style.column-gap.px]=\"s.segmentOffset\"\n [style.row-gap.px]=\"s.lineOffset\"\n >\n @for (segment of run; track segment.id) {\n <cadmus-text-segment-view\n [segment]=\"segment\"\n [settings]=\"s\"\n [selected]=\"selectedIds().has(segment.id)\"\n [hit]=\"hitIds().has(segment.id)\"\n [caret]=\"caretId() === segment.id\"\n />\n }\n </div>\n }\n } @else {\n @for (segment of block().segments; track segment.id) {\n <cadmus-text-segment-view\n [segment]=\"segment\"\n [settings]=\"s\"\n [selected]=\"selectedIds().has(segment.id)\"\n [hit]=\"hitIds().has(segment.id)\"\n [caret]=\"caretId() === segment.id\"\n />\n }\n }\n</div>\n",
902
+ styles: [":host{display:flex;align-items:flex-start;min-width:0;padding:3px;content-visibility:auto;contain-intrinsic-size:auto 40px}.block-number{flex:0 0 auto;min-width:2.5em;padding-right:8px;box-sizing:border-box;text-align:right;font-family:var(--mat-sys-label-small-font, inherit);font-size:var(--mat-sys-label-small-size, 11px);color:var(--mat-sys-on-surface-variant);opacity:.8;-webkit-user-select:none;user-select:none;font-variant-numeric:tabular-nums}.segments{flex:1 1 auto;min-width:0;display:flex;flex-wrap:wrap;align-items:flex-start}.run{display:flex;flex-wrap:wrap;align-items:flex-start;min-width:0}\n"],
903
+ dependencies: [{
904
+ kind: "component",
905
+ type: TextSegmentView,
906
+ selector: "cadmus-text-segment-view",
907
+ inputs: [
908
+ "segment",
909
+ "settings",
910
+ "selected",
911
+ "hit",
912
+ "caret"
913
+ ]
914
+ }],
915
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
916
+ });
917
+ };
918
+ i0.ɵɵngDeclareClassMetadata({
919
+ minVersion: "12.0.0",
920
+ version: "22.2.6",
921
+ ngImport: i0,
922
+ type: TextSegmentBlockView,
923
+ decorators: [{
924
+ type: Component,
925
+ args: [{
926
+ selector: "cadmus-text-segment-block-view",
927
+ imports: [TextSegmentView],
928
+ changeDetection: ChangeDetectionStrategy.OnPush,
929
+ host: {
930
+ role: "group",
931
+ "[attr.data-block-index]": "block().index",
932
+ "[attr.aria-label]": "\"block \" + (block().index + 1)"
933
+ },
934
+ template: "@let s = settings();\n@if (s.showBlockNumbers) {\n <div\n class=\"block-number\"\n aria-hidden=\"true\"\n [style.line-height.px]=\"s.textRectHeight\"\n >\n {{ block().index + 1 }}\n </div>\n}\n<div\n class=\"segments\"\n [style.column-gap.px]=\"s.segmentOffset\"\n [style.row-gap.px]=\"s.lineOffset\"\n [style.min-height.px]=\"s.textRectHeight\"\n>\n @if (runs(); as runs) {\n <!-- word wrap: each run (e.g. a word with its trailing space) stays\n together, unless it is wider than the whole line -->\n @for (run of runs; track run[0].id) {\n <div\n class=\"run\"\n [style.column-gap.px]=\"s.segmentOffset\"\n [style.row-gap.px]=\"s.lineOffset\"\n >\n @for (segment of run; track segment.id) {\n <cadmus-text-segment-view\n [segment]=\"segment\"\n [settings]=\"s\"\n [selected]=\"selectedIds().has(segment.id)\"\n [hit]=\"hitIds().has(segment.id)\"\n [caret]=\"caretId() === segment.id\"\n />\n }\n </div>\n }\n } @else {\n @for (segment of block().segments; track segment.id) {\n <cadmus-text-segment-view\n [segment]=\"segment\"\n [settings]=\"s\"\n [selected]=\"selectedIds().has(segment.id)\"\n [hit]=\"hitIds().has(segment.id)\"\n [caret]=\"caretId() === segment.id\"\n />\n }\n }\n</div>\n",
935
+ styles: [":host{display:flex;align-items:flex-start;min-width:0;padding:3px;content-visibility:auto;contain-intrinsic-size:auto 40px}.block-number{flex:0 0 auto;min-width:2.5em;padding-right:8px;box-sizing:border-box;text-align:right;font-family:var(--mat-sys-label-small-font, inherit);font-size:var(--mat-sys-label-small-size, 11px);color:var(--mat-sys-on-surface-variant);opacity:.8;-webkit-user-select:none;user-select:none;font-variant-numeric:tabular-nums}.segments{flex:1 1 auto;min-width:0;display:flex;flex-wrap:wrap;align-items:flex-start}.run{display:flex;flex-wrap:wrap;align-items:flex-start;min-width:0}\n"]
936
+ }]
937
+ }],
938
+ propDecorators: {
939
+ block: [{
940
+ type: i0.Input,
941
+ args: [{
942
+ isSignal: true,
943
+ alias: "block",
944
+ required: true
945
+ }]
946
+ }],
947
+ settings: [{
948
+ type: i0.Input,
949
+ args: [{
950
+ isSignal: true,
951
+ alias: "settings",
952
+ required: false
953
+ }]
954
+ }],
955
+ selectedIds: [{
956
+ type: i0.Input,
957
+ args: [{
958
+ isSignal: true,
959
+ alias: "selectedIds",
960
+ required: false
961
+ }]
962
+ }],
963
+ hitIds: [{
964
+ type: i0.Input,
965
+ args: [{
966
+ isSignal: true,
967
+ alias: "hitIds",
968
+ required: false
969
+ }]
970
+ }],
971
+ caretId: [{
972
+ type: i0.Input,
973
+ args: [{
974
+ isSignal: true,
975
+ alias: "caretId",
976
+ required: false
977
+ }]
978
+ }]
979
+ }
980
+ });
981
+ const SEGMENTED_TEXT_COORDS_DEBOUNCE = 400;
982
+ const SEGMENTED_TEXT_MIN_ZOOM = .5;
983
+ const SEGMENTED_TEXT_MAX_ZOOM = 3;
984
+ const AUTO_SCROLL_EDGE = 24;
985
+ function sameIds(a, b) {
986
+ return a.length === b.length && a.every((id, i) => id === b[i]);
987
+ }
988
+ var SegmentedTextView = class SegmentedTextView {
989
+ _document = inject(DOCUMENT);
990
+ _injectedSegmenter = inject(TEXT_SEGMENTER, { optional: true });
991
+ _dragging = false;
992
+ _dragChanged = false;
993
+ _downId = null;
994
+ _lastCoords = "";
995
+ store = inject(SegmentedTextStore);
996
+ blocks = input([], ...ngDevMode ? [{ debugName: "blocks" }] : /* istanbul ignore next */ []);
997
+ settings = input(...ngDevMode ? [void 0, { debugName: "settings" }] : /* istanbul ignore next */ []);
998
+ segmenter = input(...ngDevMode ? [void 0, { debugName: "segmenter" }] : /* istanbul ignore next */ []);
999
+ showZoom = input(true, ...ngDevMode ? [{ debugName: "showZoom" }] : /* istanbul ignore next */ []);
1000
+ showFind = input(true, ...ngDevMode ? [{ debugName: "showFind" }] : /* istanbul ignore next */ []);
1001
+ showCoords = input(true, ...ngDevMode ? [{ debugName: "showCoords" }] : /* istanbul ignore next */ []);
1002
+ ariaLabel = input("segmented text", ...ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []);
1003
+ selectedIds = model([], ...ngDevMode ? [{ debugName: "selectedIds" }] : /* istanbul ignore next */ []);
1004
+ selectionChange = output();
1005
+ segmentClick = output();
1006
+ resolvedSettings = computed(() => resolveSegmentedTextSettings(this.settings()), ...ngDevMode ? [{ debugName: "resolvedSettings" }] : /* istanbul ignore next */ []);
1007
+ activeSegmenter = computed(() => this.segmenter() ?? this._injectedSegmenter ?? null, ...ngDevMode ? [{ debugName: "activeSegmenter" }] : /* istanbul ignore next */ []);
1008
+ minZoom = SEGMENTED_TEXT_MIN_ZOOM;
1009
+ maxZoom = 3;
1010
+ _view = signal({
1011
+ zoom: 1,
1012
+ coords: ""
1013
+ }, ...ngDevMode ? [{ debugName: "_view" }] : /* istanbul ignore next */ []);
1014
+ viewForm = form(this._view);
1015
+ findForm = form(this.store.find);
1016
+ coordsError = signal(false, ...ngDevMode ? [{ debugName: "coordsError" }] : /* istanbul ignore next */ []);
1017
+ viewport = viewChild.required("viewport", ...ngDevMode ? [{ debugName: "viewport" }] : /* istanbul ignore next */ []);
1018
+ _overlay = viewChild(CdkConnectedOverlay, ...ngDevMode ? [{ debugName: "_overlay" }] : /* istanbul ignore next */ []);
1019
+ hovered = signal(null, ...ngDevMode ? [{ debugName: "hovered" }] : /* istanbul ignore next */ []);
1020
+ popupEnabled = computed(() => {
1021
+ const s = this.resolvedSettings();
1022
+ return !!s.showTipBox && s.tipPosition === "popup";
1023
+ }, ...ngDevMode ? [{ debugName: "popupEnabled" }] : /* istanbul ignore next */ []);
1024
+ popupText = computed(() => {
1025
+ const hovered = this.hovered();
1026
+ const s = this.resolvedSettings();
1027
+ return hovered && !s.tipComponent ? resolveSegmentTip(hovered.segment, s) : "";
1028
+ }, ...ngDevMode ? [{ debugName: "popupText" }] : /* istanbul ignore next */ []);
1029
+ popupOpen = computed(() => this.popupEnabled() && !!this.hovered() && (!!this.resolvedSettings().tipComponent || !!this.popupText()), ...ngDevMode ? [{ debugName: "popupOpen" }] : /* istanbul ignore next */ []);
1030
+ popupInputs = computed(() => ({ segment: this.hovered()?.segment }), ...ngDevMode ? [{ debugName: "popupInputs" }] : /* istanbul ignore next */ []);
1031
+ popupOrigin = computed(() => this.hovered()?.element ?? this.viewport().nativeElement, ...ngDevMode ? [{ debugName: "popupOrigin" }] : /* istanbul ignore next */ []);
1032
+ popupPositions = [{
1033
+ originX: "center",
1034
+ originY: "bottom",
1035
+ overlayX: "center",
1036
+ overlayY: "top",
1037
+ offsetY: 6
1038
+ }, {
1039
+ originX: "center",
1040
+ originY: "top",
1041
+ overlayX: "center",
1042
+ overlayY: "bottom",
1043
+ offsetY: -6
1044
+ }];
1045
+ constructor() {
1046
+ effect(() => {
1047
+ const blocks = this.blocks();
1048
+ this.activeSegmenter();
1049
+ untracked(() => {
1050
+ if (this.store.setBlocks(blocks)) this.commit();
1051
+ else this.updateCoords();
1052
+ });
1053
+ });
1054
+ effect(() => {
1055
+ const ids = this.selectedIds();
1056
+ untracked(() => {
1057
+ if (!sameIds(ids, this.store.selectedIds())) {
1058
+ this.store.setSelectedIds(ids);
1059
+ this.updateCoords();
1060
+ }
1061
+ });
1062
+ });
1063
+ effect((onCleanup) => {
1064
+ const coords = this.viewForm.coords().value();
1065
+ if (coords === this._lastCoords) return;
1066
+ const handle = setTimeout(() => this.applyCoords(coords), 400);
1067
+ onCleanup(() => clearTimeout(handle));
1068
+ });
1069
+ effect(() => {
1070
+ if (this.popupOpen()) untracked(() => this.disablePopupPointer());
1071
+ });
1072
+ }
1073
+ updateCoords() {
1074
+ const segmenter = this.activeSegmenter();
1075
+ const coords = segmenter && this.store.selectedIds().length ? segmenter.getSegmentCoords(this.store.blocks(), this.store.selectedSegments()) : "";
1076
+ this._lastCoords = coords;
1077
+ this.coordsError.set(false);
1078
+ this._view.update((v) => ({
1079
+ ...v,
1080
+ coords
1081
+ }));
1082
+ return coords;
1083
+ }
1084
+ commit(writeCoords = true) {
1085
+ const ids = [...this.store.selectedIds()];
1086
+ this.selectedIds.set(ids);
1087
+ const segmenter = this.activeSegmenter();
1088
+ let coords;
1089
+ if (writeCoords) coords = this.updateCoords();
1090
+ else coords = segmenter && ids.length ? segmenter.getSegmentCoords(this.store.blocks(), this.store.selectedSegments()) : "";
1091
+ this.selectionChange.emit({
1092
+ ids,
1093
+ segments: this.store.selectedSegments(),
1094
+ coords: coords || void 0
1095
+ });
1096
+ }
1097
+ applyCoords(coords) {
1098
+ const segmenter = this.activeSegmenter();
1099
+ if (!segmenter) return;
1100
+ this._lastCoords = coords;
1101
+ const text = coords.trim();
1102
+ if (!text) {
1103
+ this.coordsError.set(false);
1104
+ if (this.store.clear()) this.commit(false);
1105
+ return;
1106
+ }
1107
+ const segments = segmenter.getCoordsSegments(this.store.blocks(), text);
1108
+ if (!segments) {
1109
+ this.coordsError.set(true);
1110
+ return;
1111
+ }
1112
+ this.coordsError.set(false);
1113
+ if (this.store.setSelectedIds(segments.map((s) => s.id))) {
1114
+ this.commit(false);
1115
+ if (segments.length) this.scrollToSegment(segments[0].id);
1116
+ }
1117
+ }
1118
+ scrollToSegment(id) {
1119
+ this.viewport().nativeElement.querySelector(`[data-seg-id="${id}"]`)?.scrollIntoView?.({
1120
+ block: "nearest",
1121
+ inline: "nearest"
1122
+ });
1123
+ }
1124
+ clearSelection() {
1125
+ if (this.store.clear()) this.commit();
1126
+ }
1127
+ goToMatch(dir) {
1128
+ const ids = this.store.goToMatch(dir);
1129
+ if (ids) {
1130
+ this.commit();
1131
+ this.scrollToSegment(ids[0]);
1132
+ }
1133
+ }
1134
+ formatZoom(value) {
1135
+ return Math.round(value * 100) + "%";
1136
+ }
1137
+ resetZoom() {
1138
+ this.viewForm.zoom().value.set(1);
1139
+ }
1140
+ clearFind() {
1141
+ this.findForm.query().value.set("");
1142
+ }
1143
+ toggleCrossSegments() {
1144
+ this.findForm.crossSegments().value.update((v) => !v);
1145
+ }
1146
+ toggleCaseSensitive() {
1147
+ this.findForm.caseSensitive().value.update((v) => !v);
1148
+ }
1149
+ onFindKeydown(event) {
1150
+ if (event.key === "Enter") {
1151
+ event.preventDefault();
1152
+ this.goToMatch(event.shiftKey ? -1 : 1);
1153
+ } else if (event.key === "Escape" && this.findForm.query().value()) {
1154
+ event.preventDefault();
1155
+ event.stopPropagation();
1156
+ this.clearFind();
1157
+ }
1158
+ }
1159
+ segmentIdAt(target) {
1160
+ const el = target?.closest?.("[data-seg-id]");
1161
+ if (!el || !this.viewport().nativeElement.contains(el)) return null;
1162
+ const id = Number(el.getAttribute("data-seg-id"));
1163
+ return Number.isNaN(id) ? null : id;
1164
+ }
1165
+ segmentById(id) {
1166
+ const pos = this.store.positions().get(id);
1167
+ return pos === void 0 ? void 0 : this.store.segments()[pos];
1168
+ }
1169
+ onPointerDown(event) {
1170
+ if (event.button !== 0) return;
1171
+ const id = this.segmentIdAt(event.target);
1172
+ if (id === null) return;
1173
+ event.preventDefault();
1174
+ const viewport = this.viewport().nativeElement;
1175
+ viewport.focus({ preventScroll: true });
1176
+ this.hovered.set(null);
1177
+ this._dragging = true;
1178
+ this._downId = id;
1179
+ this._dragChanged = this.store.startAt(id, event.shiftKey);
1180
+ try {
1181
+ viewport.setPointerCapture?.(event.pointerId);
1182
+ } catch {}
1183
+ }
1184
+ onPointerMove(event) {
1185
+ if (!this._dragging) return;
1186
+ const target = this._document.elementFromPoint?.(event.clientX, event.clientY) ?? event.target;
1187
+ const id = this.segmentIdAt(target);
1188
+ if (id !== null && this.store.extendTo(id)) this._dragChanged = true;
1189
+ this.autoScroll(event.clientY);
1190
+ }
1191
+ onPointerUp(event) {
1192
+ if (!this._dragging) return;
1193
+ this._dragging = false;
1194
+ try {
1195
+ this.viewport().nativeElement.releasePointerCapture?.(event.pointerId);
1196
+ } catch {}
1197
+ if (this._dragChanged) {
1198
+ this._dragChanged = false;
1199
+ this.commit();
1200
+ }
1201
+ const downId = this._downId;
1202
+ this._downId = null;
1203
+ if (downId === null || event.type === "pointercancel") return;
1204
+ const target = this._document.elementFromPoint?.(event.clientX, event.clientY) ?? event.target;
1205
+ if (this.segmentIdAt(target) === downId) {
1206
+ const segment = this.segmentById(downId);
1207
+ if (segment) this.segmentClick.emit({
1208
+ segment,
1209
+ event
1210
+ });
1211
+ }
1212
+ }
1213
+ autoScroll(clientY) {
1214
+ const viewport = this.viewport().nativeElement;
1215
+ const rect = viewport.getBoundingClientRect();
1216
+ if (clientY < rect.top + AUTO_SCROLL_EDGE) viewport.scrollTop -= rect.top + AUTO_SCROLL_EDGE - clientY;
1217
+ else if (clientY > rect.bottom - AUTO_SCROLL_EDGE) viewport.scrollTop += clientY - (rect.bottom - AUTO_SCROLL_EDGE);
1218
+ }
1219
+ onPointerOver(event) {
1220
+ if (this._dragging || !this.popupEnabled()) return;
1221
+ const el = event.target?.closest?.("[data-seg-id]");
1222
+ const id = this.segmentIdAt(el ?? null);
1223
+ const segment = id === null ? void 0 : this.segmentById(id);
1224
+ if (!el || !segment) this.hovered.set(null);
1225
+ else if (this.hovered()?.element !== el) this.hovered.set({
1226
+ element: el,
1227
+ segment
1228
+ });
1229
+ }
1230
+ onPointerLeave() {
1231
+ this.hovered.set(null);
1232
+ }
1233
+ disablePopupPointer() {
1234
+ const ref = this._overlay()?.overlayRef;
1235
+ if (ref) {
1236
+ ref.overlayElement.style.pointerEvents = "none";
1237
+ ref.hostElement.style.pointerEvents = "none";
1238
+ }
1239
+ }
1240
+ onPopupAttach() {
1241
+ this.disablePopupPointer();
1242
+ }
1243
+ onKeyDown(event) {
1244
+ const s = this.store;
1245
+ const extend = event.shiftKey;
1246
+ const ctrl = event.ctrlKey || event.metaKey;
1247
+ let changed = false;
1248
+ switch (event.key) {
1249
+ case "ArrowLeft":
1250
+ changed = s.moveCaret(-1, extend);
1251
+ break;
1252
+ case "ArrowRight":
1253
+ changed = s.moveCaret(1, extend);
1254
+ break;
1255
+ case "ArrowUp":
1256
+ changed = s.moveBlock(-1, extend);
1257
+ break;
1258
+ case "ArrowDown":
1259
+ changed = s.moveBlock(1, extend);
1260
+ break;
1261
+ case "Home":
1262
+ changed = ctrl ? s.moveToTextEdge("start", extend) : s.moveToBlockEdge("start", extend);
1263
+ break;
1264
+ case "End":
1265
+ changed = ctrl ? s.moveToTextEdge("end", extend) : s.moveToBlockEdge("end", extend);
1266
+ break;
1267
+ case "a":
1268
+ case "A":
1269
+ if (!ctrl) return;
1270
+ changed = s.selectAll();
1271
+ break;
1272
+ case "Escape":
1273
+ if (!s.selectedIds().length) return;
1274
+ changed = s.clear();
1275
+ break;
1276
+ default: return;
1277
+ }
1278
+ event.preventDefault();
1279
+ if (changed) {
1280
+ this.commit();
1281
+ const caret = s.caretId();
1282
+ if (caret !== null) this.scrollToSegment(caret);
1283
+ }
1284
+ }
1285
+ onWheel(event) {
1286
+ if (!event.ctrlKey || !this.showZoom()) return;
1287
+ event.preventDefault();
1288
+ const zoom = this.viewForm.zoom().value();
1289
+ const next = Math.round((zoom + (event.deltaY < 0 ? .1 : -.1)) * 10) / 10;
1290
+ this.viewForm.zoom().value.set(Math.max(this.minZoom, Math.min(this.maxZoom, next)));
1291
+ }
1292
+ static ɵfac = i0.ɵɵngDeclareFactory({
1293
+ minVersion: "12.0.0",
1294
+ version: "22.2.6",
1295
+ ngImport: i0,
1296
+ type: SegmentedTextView,
1297
+ deps: [],
1298
+ target: i0.ɵɵFactoryTarget.Component
1299
+ });
1300
+ static ɵcmp = i0.ɵɵngDeclareComponent({
1301
+ minVersion: "17.0.0",
1302
+ version: "22.2.6",
1303
+ type: SegmentedTextView,
1304
+ isStandalone: true,
1305
+ selector: "cadmus-segmented-text-view",
1306
+ inputs: {
1307
+ blocks: {
1308
+ classPropertyName: "blocks",
1309
+ publicName: "blocks",
1310
+ isSignal: true,
1311
+ isRequired: false,
1312
+ transformFunction: null
1313
+ },
1314
+ settings: {
1315
+ classPropertyName: "settings",
1316
+ publicName: "settings",
1317
+ isSignal: true,
1318
+ isRequired: false,
1319
+ transformFunction: null
1320
+ },
1321
+ segmenter: {
1322
+ classPropertyName: "segmenter",
1323
+ publicName: "segmenter",
1324
+ isSignal: true,
1325
+ isRequired: false,
1326
+ transformFunction: null
1327
+ },
1328
+ showZoom: {
1329
+ classPropertyName: "showZoom",
1330
+ publicName: "showZoom",
1331
+ isSignal: true,
1332
+ isRequired: false,
1333
+ transformFunction: null
1334
+ },
1335
+ showFind: {
1336
+ classPropertyName: "showFind",
1337
+ publicName: "showFind",
1338
+ isSignal: true,
1339
+ isRequired: false,
1340
+ transformFunction: null
1341
+ },
1342
+ showCoords: {
1343
+ classPropertyName: "showCoords",
1344
+ publicName: "showCoords",
1345
+ isSignal: true,
1346
+ isRequired: false,
1347
+ transformFunction: null
1348
+ },
1349
+ ariaLabel: {
1350
+ classPropertyName: "ariaLabel",
1351
+ publicName: "ariaLabel",
1352
+ isSignal: true,
1353
+ isRequired: false,
1354
+ transformFunction: null
1355
+ },
1356
+ selectedIds: {
1357
+ classPropertyName: "selectedIds",
1358
+ publicName: "selectedIds",
1359
+ isSignal: true,
1360
+ isRequired: false,
1361
+ transformFunction: null
1362
+ }
1363
+ },
1364
+ outputs: {
1365
+ selectedIds: "selectedIdsChange",
1366
+ selectionChange: "selectionChange",
1367
+ segmentClick: "segmentClick"
1368
+ },
1369
+ host: { properties: { "style.--cadmus-tseg-caret-color": "resolvedSettings().caretColor" } },
1370
+ providers: [SegmentedTextStore],
1371
+ viewQueries: [{
1372
+ propertyName: "viewport",
1373
+ first: true,
1374
+ predicate: ["viewport"],
1375
+ descendants: true,
1376
+ isSignal: true
1377
+ }, {
1378
+ propertyName: "_overlay",
1379
+ first: true,
1380
+ predicate: CdkConnectedOverlay,
1381
+ descendants: true,
1382
+ isSignal: true
1383
+ }],
1384
+ ngImport: i0,
1385
+ template: "@let s = resolvedSettings();\n<!-- text -->\n<div\n #viewport\n class=\"viewport\"\n tabindex=\"0\"\n role=\"listbox\"\n aria-multiselectable=\"true\"\n [attr.aria-label]=\"ariaLabel()\"\n (pointerdown)=\"onPointerDown($event)\"\n (pointermove)=\"onPointerMove($event)\"\n (pointerup)=\"onPointerUp($event)\"\n (pointercancel)=\"onPointerUp($event)\"\n (pointerover)=\"onPointerOver($event)\"\n (pointerleave)=\"onPointerLeave()\"\n (keydown)=\"onKeyDown($event)\"\n (wheel)=\"onWheel($event)\"\n>\n <div\n class=\"content\"\n [style.zoom]=\"viewForm.zoom().value()\"\n [style.row-gap.px]=\"s.blockOffset\"\n >\n @for (block of blocks(); track block.index) {\n <cadmus-text-segment-block-view\n [block]=\"block\"\n [settings]=\"s\"\n [selectedIds]=\"store.selectedSet()\"\n [hitIds]=\"store.hitSet()\"\n [caretId]=\"store.caretId()\"\n />\n } @empty {\n <div class=\"empty\">no text</div>\n }\n </div>\n</div>\n\n<!-- toolbar -->\n@if (showZoom() || showFind() || (showCoords() && activeSegmenter())) {\n <div class=\"toolbar\">\n <!-- zoom -->\n @if (showZoom()) {\n <div class=\"zoom\">\n <mat-icon class=\"muted\" aria-hidden=\"true\">zoom_in</mat-icon>\n <mat-slider\n [min]=\"minZoom\"\n [max]=\"maxZoom\"\n step=\"0.1\"\n discrete\n [displayWith]=\"formatZoom\"\n >\n <input matSliderThumb [formField]=\"viewForm.zoom\" aria-label=\"zoom\" />\n </mat-slider>\n <button\n type=\"button\"\n mat-icon-button\n class=\"dense\"\n matTooltip=\"Reset zoom\"\n aria-label=\"reset zoom\"\n [disabled]=\"viewForm.zoom().value() === 1\"\n (click)=\"resetZoom()\"\n >\n <mat-icon>restart_alt</mat-icon>\n </button>\n </div>\n }\n\n <!-- find -->\n @if (showFind()) {\n @let find = store.find();\n @let matchCount = store.matches().length;\n <div class=\"find\">\n <mat-form-field appearance=\"outline\" subscriptSizing=\"dynamic\">\n <mat-icon matPrefix class=\"muted\">search</mat-icon>\n <input\n matInput\n type=\"search\"\n placeholder=\"find\"\n aria-label=\"find\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n [formField]=\"findForm.query\"\n (keydown)=\"onFindKeydown($event)\"\n />\n @if (find.query) {\n <button\n type=\"button\"\n matSuffix\n mat-icon-button\n class=\"dense\"\n aria-label=\"clear find\"\n (click)=\"clearFind()\"\n >\n <mat-icon>close</mat-icon>\n </button>\n }\n </mat-form-field>\n <button\n type=\"button\"\n mat-icon-button\n class=\"dense toggle\"\n [class.on]=\"find.crossSegments\"\n [attr.aria-pressed]=\"find.crossSegments\"\n [matTooltip]=\"\n find.crossSegments\n ? 'Finding across segments'\n : 'Finding within each segment'\n \"\n aria-label=\"find across segments\"\n (click)=\"toggleCrossSegments()\"\n >\n <mat-icon>{{ find.crossSegments ? \"link\" : \"link_off\" }}</mat-icon>\n </button>\n <button\n type=\"button\"\n mat-icon-button\n class=\"dense toggle case\"\n [class.on]=\"find.caseSensitive\"\n [attr.aria-pressed]=\"find.caseSensitive\"\n matTooltip=\"Case sensitive\"\n aria-label=\"case sensitive\"\n (click)=\"toggleCaseSensitive()\"\n >\n Aa\n </button>\n @if (find.query) {\n <span class=\"match-count\" aria-live=\"polite\">\n @if (!matchCount) {\n no match\n } @else if (store.currentMatch() < 0) {\n {{ matchCount }} found\n } @else {\n {{ store.currentMatch() + 1 }}/{{ matchCount }}\n }\n </span>\n <button\n type=\"button\"\n mat-icon-button\n class=\"dense\"\n matTooltip=\"Previous match (Shift+Enter)\"\n aria-label=\"previous match\"\n [disabled]=\"!matchCount\"\n (click)=\"goToMatch(-1)\"\n >\n <mat-icon>keyboard_arrow_up</mat-icon>\n </button>\n <button\n type=\"button\"\n mat-icon-button\n class=\"dense\"\n matTooltip=\"Next match (Enter)\"\n aria-label=\"next match\"\n [disabled]=\"!matchCount\"\n (click)=\"goToMatch(1)\"\n >\n <mat-icon>keyboard_arrow_down</mat-icon>\n </button>\n }\n </div>\n }\n\n <!-- coordinates -->\n @if (showCoords() && activeSegmenter()) {\n <div class=\"coords\">\n <mat-form-field appearance=\"outline\" subscriptSizing=\"dynamic\">\n <mat-icon matPrefix class=\"muted\">my_location</mat-icon>\n <input\n matInput\n placeholder=\"coordinates\"\n aria-label=\"coordinates\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n [formField]=\"viewForm.coords\"\n />\n @if (coordsError()) {\n <mat-hint class=\"coords-error\">invalid coordinates</mat-hint>\n }\n </mat-form-field>\n </div>\n }\n </div>\n}\n\n<!-- tip popup -->\n<ng-template\n cdkConnectedOverlay\n [cdkConnectedOverlayOrigin]=\"popupOrigin()\"\n [cdkConnectedOverlayOpen]=\"popupOpen()\"\n [cdkConnectedOverlayPositions]=\"popupPositions\"\n (attach)=\"onPopupAttach()\"\n>\n <div\n class=\"tip-popup\"\n role=\"tooltip\"\n [style.font-family]=\"s.tipFontFace\"\n >\n @if (s.tipComponent; as tipComponent) {\n <ng-container *ngComponentOutlet=\"tipComponent; inputs: popupInputs()\" />\n } @else {\n {{ popupText() }}\n }\n </div>\n</ng-template>\n",
1386
+ styles: [":host{display:flex;flex-direction:column;box-sizing:border-box;width:100%;height:100%;min-width:0;min-height:0;background-color:var(--mat-sys-surface);color:var(--mat-sys-on-surface);border:1px solid var(--mat-sys-outline-variant);border-radius:var(--mat-sys-corner-small, 4px);overflow:hidden}.viewport{flex:1 1 auto;min-height:0;overflow-x:hidden;overflow-y:auto;overscroll-behavior:contain;padding:8px;outline:none;user-select:none;-webkit-user-select:none;touch-action:pan-y}.viewport:focus-visible{box-shadow:inset 0 0 0 2px var(--mat-sys-primary)}.content{display:flex;flex-direction:column}.empty{padding:16px;text-align:center;font:var(--mat-sys-body-medium);color:var(--mat-sys-on-surface-variant)}.toolbar{flex:0 0 auto;display:flex;flex-wrap:wrap;align-items:center;gap:4px 16px;padding:4px 8px;background-color:var(--mat-sys-surface-container);border-top:1px solid var(--mat-sys-outline-variant);--mat-form-field-container-height: 36px;--mat-form-field-container-vertical-padding: 6px;--mat-form-field-container-text-size: var(--mat-sys-body-medium-size)}.zoom,.find,.coords{display:flex;align-items:center;gap:2px;min-width:0}.zoom mat-slider{width:120px;min-width:80px}.find mat-form-field{width:200px}.coords{flex:1 1 180px}.coords mat-form-field{width:100%;min-width:140px;font-family:var(--mat-sys-body-medium-font)}.coords input{font-family:Roboto Mono,Consolas,monospace}.muted{color:var(--mat-sys-on-surface-variant)}.dense{--mat-icon-button-state-layer-size: 32px;--mat-icon-button-icon-size: 20px;padding:4px;width:32px;height:32px}.dense mat-icon{font-size:20px;width:20px;height:20px}.toggle{color:var(--mat-sys-on-surface-variant)}.toggle.on{color:var(--mat-sys-on-secondary-container);background-color:var(--mat-sys-secondary-container)}.toggle.case{font:var(--mat-sys-label-large)}.match-count{min-width:4em;text-align:center;font:var(--mat-sys-label-medium);font-variant-numeric:tabular-nums;color:var(--mat-sys-on-surface-variant)}.coords-error{color:var(--mat-sys-error)}.tip-popup{pointer-events:none;max-width:320px;padding:4px 8px;border-radius:var(--mat-sys-corner-extra-small, 4px);background-color:var(--mat-sys-inverse-surface);color:var(--mat-sys-inverse-on-surface);font-size:var(--mat-sys-body-small-size, 12px);line-height:var(--mat-sys-body-small-line-height, 16px);box-shadow:var(--mat-sys-level2);white-space:pre-wrap;word-break:break-word}\n"],
1387
+ dependencies: [
1388
+ {
1389
+ kind: "directive",
1390
+ type: CdkConnectedOverlay,
1391
+ selector: "[cdk-connected-overlay], [connected-overlay], [cdkConnectedOverlay]",
1392
+ inputs: [
1393
+ "cdkConnectedOverlayOrigin",
1394
+ "cdkConnectedOverlayPositions",
1395
+ "cdkConnectedOverlayPositionStrategy",
1396
+ "cdkConnectedOverlayOffsetX",
1397
+ "cdkConnectedOverlayOffsetY",
1398
+ "cdkConnectedOverlayWidth",
1399
+ "cdkConnectedOverlayHeight",
1400
+ "cdkConnectedOverlayMinWidth",
1401
+ "cdkConnectedOverlayMinHeight",
1402
+ "cdkConnectedOverlayBackdropClass",
1403
+ "cdkConnectedOverlayPanelClass",
1404
+ "cdkConnectedOverlayViewportMargin",
1405
+ "cdkConnectedOverlayScrollStrategy",
1406
+ "cdkConnectedOverlayOpen",
1407
+ "cdkConnectedOverlayDisableClose",
1408
+ "cdkConnectedOverlayTransformOriginOn",
1409
+ "cdkConnectedOverlayHasBackdrop",
1410
+ "cdkConnectedOverlayLockPosition",
1411
+ "cdkConnectedOverlayFlexibleDimensions",
1412
+ "cdkConnectedOverlayGrowAfterOpen",
1413
+ "cdkConnectedOverlayPush",
1414
+ "cdkConnectedOverlayDisposeOnNavigation",
1415
+ "cdkConnectedOverlayUsePopover",
1416
+ "cdkConnectedOverlayMatchWidth",
1417
+ "cdkConnectedOverlay"
1418
+ ],
1419
+ outputs: [
1420
+ "backdropClick",
1421
+ "positionChange",
1422
+ "attach",
1423
+ "detach",
1424
+ "overlayKeydown",
1425
+ "overlayOutsideClick"
1426
+ ],
1427
+ exportAs: ["cdkConnectedOverlay"]
1428
+ },
1429
+ {
1430
+ kind: "directive",
1431
+ type: FormField,
1432
+ selector: "[formField]",
1433
+ inputs: ["formField"],
1434
+ exportAs: ["formField"]
1435
+ },
1436
+ {
1437
+ kind: "component",
1438
+ type: MatFormField,
1439
+ selector: "mat-form-field",
1440
+ inputs: [
1441
+ "hideRequiredMarker",
1442
+ "color",
1443
+ "floatLabel",
1444
+ "appearance",
1445
+ "subscriptSizing",
1446
+ "hintLabel"
1447
+ ],
1448
+ exportAs: ["matFormField"]
1449
+ },
1450
+ {
1451
+ kind: "directive",
1452
+ type: MatHint,
1453
+ selector: "mat-hint",
1454
+ inputs: ["align", "id"]
1455
+ },
1456
+ {
1457
+ kind: "component",
1458
+ type: MatIcon,
1459
+ selector: "mat-icon",
1460
+ inputs: [
1461
+ "color",
1462
+ "inline",
1463
+ "svgIcon",
1464
+ "fontSet",
1465
+ "fontIcon"
1466
+ ],
1467
+ exportAs: ["matIcon"]
1468
+ },
1469
+ {
1470
+ kind: "component",
1471
+ type: MatIconButton,
1472
+ selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]",
1473
+ exportAs: ["matButton", "matAnchor"]
1474
+ },
1475
+ {
1476
+ kind: "directive",
1477
+ type: MatInput,
1478
+ selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]",
1479
+ inputs: [
1480
+ "disabled",
1481
+ "id",
1482
+ "placeholder",
1483
+ "name",
1484
+ "required",
1485
+ "type",
1486
+ "errorStateMatcher",
1487
+ "aria-describedby",
1488
+ "value",
1489
+ "readonly",
1490
+ "disabledInteractive"
1491
+ ],
1492
+ exportAs: ["matInput"]
1493
+ },
1494
+ {
1495
+ kind: "directive",
1496
+ type: MatPrefix,
1497
+ selector: "[matPrefix], [matIconPrefix], [matTextPrefix]",
1498
+ inputs: ["matTextPrefix"]
1499
+ },
1500
+ {
1501
+ kind: "component",
1502
+ type: MatSlider,
1503
+ selector: "mat-slider",
1504
+ inputs: [
1505
+ "disabled",
1506
+ "discrete",
1507
+ "showTickMarks",
1508
+ "min",
1509
+ "color",
1510
+ "disableRipple",
1511
+ "max",
1512
+ "step",
1513
+ "displayWith"
1514
+ ],
1515
+ exportAs: ["matSlider"]
1516
+ },
1517
+ {
1518
+ kind: "directive",
1519
+ type: MatSliderThumb,
1520
+ selector: "input[matSliderThumb]",
1521
+ inputs: ["value"],
1522
+ outputs: [
1523
+ "valueChange",
1524
+ "dragStart",
1525
+ "dragEnd"
1526
+ ],
1527
+ exportAs: ["matSliderThumb"]
1528
+ },
1529
+ {
1530
+ kind: "directive",
1531
+ type: MatSuffix,
1532
+ selector: "[matSuffix], [matIconSuffix], [matTextSuffix]",
1533
+ inputs: ["matTextSuffix"]
1534
+ },
1535
+ {
1536
+ kind: "directive",
1537
+ type: MatTooltip,
1538
+ selector: "[matTooltip]",
1539
+ inputs: [
1540
+ "matTooltipPosition",
1541
+ "matTooltipPositionAtOrigin",
1542
+ "matTooltipDisabled",
1543
+ "matTooltipShowDelay",
1544
+ "matTooltipHideDelay",
1545
+ "matTooltipTouchGestures",
1546
+ "matTooltip",
1547
+ "matTooltipClass"
1548
+ ],
1549
+ exportAs: ["matTooltip"]
1550
+ },
1551
+ {
1552
+ kind: "directive",
1553
+ type: NgComponentOutlet,
1554
+ selector: "[ngComponentOutlet]",
1555
+ inputs: [
1556
+ "ngComponentOutlet",
1557
+ "ngComponentOutletInputs",
1558
+ "ngComponentOutletInjector",
1559
+ "ngComponentOutletEnvironmentInjector",
1560
+ "ngComponentOutletContent",
1561
+ "ngComponentOutletNgModule"
1562
+ ],
1563
+ exportAs: ["ngComponentOutlet"]
1564
+ },
1565
+ {
1566
+ kind: "component",
1567
+ type: TextSegmentBlockView,
1568
+ selector: "cadmus-text-segment-block-view",
1569
+ inputs: [
1570
+ "block",
1571
+ "settings",
1572
+ "selectedIds",
1573
+ "hitIds",
1574
+ "caretId"
1575
+ ]
1576
+ }
1577
+ ],
1578
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
1579
+ });
1580
+ };
1581
+ i0.ɵɵngDeclareClassMetadata({
1582
+ minVersion: "12.0.0",
1583
+ version: "22.2.6",
1584
+ ngImport: i0,
1585
+ type: SegmentedTextView,
1586
+ decorators: [{
1587
+ type: Component,
1588
+ args: [{
1589
+ selector: "cadmus-segmented-text-view",
1590
+ imports: [
1591
+ CdkConnectedOverlay,
1592
+ FormField,
1593
+ MatFormField,
1594
+ MatHint,
1595
+ MatIcon,
1596
+ MatIconButton,
1597
+ MatInput,
1598
+ MatPrefix,
1599
+ MatSlider,
1600
+ MatSliderThumb,
1601
+ MatSuffix,
1602
+ MatTooltip,
1603
+ NgComponentOutlet,
1604
+ TextSegmentBlockView
1605
+ ],
1606
+ providers: [SegmentedTextStore],
1607
+ changeDetection: ChangeDetectionStrategy.OnPush,
1608
+ host: { "[style.--cadmus-tseg-caret-color]": "resolvedSettings().caretColor" },
1609
+ template: "@let s = resolvedSettings();\n<!-- text -->\n<div\n #viewport\n class=\"viewport\"\n tabindex=\"0\"\n role=\"listbox\"\n aria-multiselectable=\"true\"\n [attr.aria-label]=\"ariaLabel()\"\n (pointerdown)=\"onPointerDown($event)\"\n (pointermove)=\"onPointerMove($event)\"\n (pointerup)=\"onPointerUp($event)\"\n (pointercancel)=\"onPointerUp($event)\"\n (pointerover)=\"onPointerOver($event)\"\n (pointerleave)=\"onPointerLeave()\"\n (keydown)=\"onKeyDown($event)\"\n (wheel)=\"onWheel($event)\"\n>\n <div\n class=\"content\"\n [style.zoom]=\"viewForm.zoom().value()\"\n [style.row-gap.px]=\"s.blockOffset\"\n >\n @for (block of blocks(); track block.index) {\n <cadmus-text-segment-block-view\n [block]=\"block\"\n [settings]=\"s\"\n [selectedIds]=\"store.selectedSet()\"\n [hitIds]=\"store.hitSet()\"\n [caretId]=\"store.caretId()\"\n />\n } @empty {\n <div class=\"empty\">no text</div>\n }\n </div>\n</div>\n\n<!-- toolbar -->\n@if (showZoom() || showFind() || (showCoords() && activeSegmenter())) {\n <div class=\"toolbar\">\n <!-- zoom -->\n @if (showZoom()) {\n <div class=\"zoom\">\n <mat-icon class=\"muted\" aria-hidden=\"true\">zoom_in</mat-icon>\n <mat-slider\n [min]=\"minZoom\"\n [max]=\"maxZoom\"\n step=\"0.1\"\n discrete\n [displayWith]=\"formatZoom\"\n >\n <input matSliderThumb [formField]=\"viewForm.zoom\" aria-label=\"zoom\" />\n </mat-slider>\n <button\n type=\"button\"\n mat-icon-button\n class=\"dense\"\n matTooltip=\"Reset zoom\"\n aria-label=\"reset zoom\"\n [disabled]=\"viewForm.zoom().value() === 1\"\n (click)=\"resetZoom()\"\n >\n <mat-icon>restart_alt</mat-icon>\n </button>\n </div>\n }\n\n <!-- find -->\n @if (showFind()) {\n @let find = store.find();\n @let matchCount = store.matches().length;\n <div class=\"find\">\n <mat-form-field appearance=\"outline\" subscriptSizing=\"dynamic\">\n <mat-icon matPrefix class=\"muted\">search</mat-icon>\n <input\n matInput\n type=\"search\"\n placeholder=\"find\"\n aria-label=\"find\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n [formField]=\"findForm.query\"\n (keydown)=\"onFindKeydown($event)\"\n />\n @if (find.query) {\n <button\n type=\"button\"\n matSuffix\n mat-icon-button\n class=\"dense\"\n aria-label=\"clear find\"\n (click)=\"clearFind()\"\n >\n <mat-icon>close</mat-icon>\n </button>\n }\n </mat-form-field>\n <button\n type=\"button\"\n mat-icon-button\n class=\"dense toggle\"\n [class.on]=\"find.crossSegments\"\n [attr.aria-pressed]=\"find.crossSegments\"\n [matTooltip]=\"\n find.crossSegments\n ? 'Finding across segments'\n : 'Finding within each segment'\n \"\n aria-label=\"find across segments\"\n (click)=\"toggleCrossSegments()\"\n >\n <mat-icon>{{ find.crossSegments ? \"link\" : \"link_off\" }}</mat-icon>\n </button>\n <button\n type=\"button\"\n mat-icon-button\n class=\"dense toggle case\"\n [class.on]=\"find.caseSensitive\"\n [attr.aria-pressed]=\"find.caseSensitive\"\n matTooltip=\"Case sensitive\"\n aria-label=\"case sensitive\"\n (click)=\"toggleCaseSensitive()\"\n >\n Aa\n </button>\n @if (find.query) {\n <span class=\"match-count\" aria-live=\"polite\">\n @if (!matchCount) {\n no match\n } @else if (store.currentMatch() < 0) {\n {{ matchCount }} found\n } @else {\n {{ store.currentMatch() + 1 }}/{{ matchCount }}\n }\n </span>\n <button\n type=\"button\"\n mat-icon-button\n class=\"dense\"\n matTooltip=\"Previous match (Shift+Enter)\"\n aria-label=\"previous match\"\n [disabled]=\"!matchCount\"\n (click)=\"goToMatch(-1)\"\n >\n <mat-icon>keyboard_arrow_up</mat-icon>\n </button>\n <button\n type=\"button\"\n mat-icon-button\n class=\"dense\"\n matTooltip=\"Next match (Enter)\"\n aria-label=\"next match\"\n [disabled]=\"!matchCount\"\n (click)=\"goToMatch(1)\"\n >\n <mat-icon>keyboard_arrow_down</mat-icon>\n </button>\n }\n </div>\n }\n\n <!-- coordinates -->\n @if (showCoords() && activeSegmenter()) {\n <div class=\"coords\">\n <mat-form-field appearance=\"outline\" subscriptSizing=\"dynamic\">\n <mat-icon matPrefix class=\"muted\">my_location</mat-icon>\n <input\n matInput\n placeholder=\"coordinates\"\n aria-label=\"coordinates\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n [formField]=\"viewForm.coords\"\n />\n @if (coordsError()) {\n <mat-hint class=\"coords-error\">invalid coordinates</mat-hint>\n }\n </mat-form-field>\n </div>\n }\n </div>\n}\n\n<!-- tip popup -->\n<ng-template\n cdkConnectedOverlay\n [cdkConnectedOverlayOrigin]=\"popupOrigin()\"\n [cdkConnectedOverlayOpen]=\"popupOpen()\"\n [cdkConnectedOverlayPositions]=\"popupPositions\"\n (attach)=\"onPopupAttach()\"\n>\n <div\n class=\"tip-popup\"\n role=\"tooltip\"\n [style.font-family]=\"s.tipFontFace\"\n >\n @if (s.tipComponent; as tipComponent) {\n <ng-container *ngComponentOutlet=\"tipComponent; inputs: popupInputs()\" />\n } @else {\n {{ popupText() }}\n }\n </div>\n</ng-template>\n",
1610
+ styles: [":host{display:flex;flex-direction:column;box-sizing:border-box;width:100%;height:100%;min-width:0;min-height:0;background-color:var(--mat-sys-surface);color:var(--mat-sys-on-surface);border:1px solid var(--mat-sys-outline-variant);border-radius:var(--mat-sys-corner-small, 4px);overflow:hidden}.viewport{flex:1 1 auto;min-height:0;overflow-x:hidden;overflow-y:auto;overscroll-behavior:contain;padding:8px;outline:none;user-select:none;-webkit-user-select:none;touch-action:pan-y}.viewport:focus-visible{box-shadow:inset 0 0 0 2px var(--mat-sys-primary)}.content{display:flex;flex-direction:column}.empty{padding:16px;text-align:center;font:var(--mat-sys-body-medium);color:var(--mat-sys-on-surface-variant)}.toolbar{flex:0 0 auto;display:flex;flex-wrap:wrap;align-items:center;gap:4px 16px;padding:4px 8px;background-color:var(--mat-sys-surface-container);border-top:1px solid var(--mat-sys-outline-variant);--mat-form-field-container-height: 36px;--mat-form-field-container-vertical-padding: 6px;--mat-form-field-container-text-size: var(--mat-sys-body-medium-size)}.zoom,.find,.coords{display:flex;align-items:center;gap:2px;min-width:0}.zoom mat-slider{width:120px;min-width:80px}.find mat-form-field{width:200px}.coords{flex:1 1 180px}.coords mat-form-field{width:100%;min-width:140px;font-family:var(--mat-sys-body-medium-font)}.coords input{font-family:Roboto Mono,Consolas,monospace}.muted{color:var(--mat-sys-on-surface-variant)}.dense{--mat-icon-button-state-layer-size: 32px;--mat-icon-button-icon-size: 20px;padding:4px;width:32px;height:32px}.dense mat-icon{font-size:20px;width:20px;height:20px}.toggle{color:var(--mat-sys-on-surface-variant)}.toggle.on{color:var(--mat-sys-on-secondary-container);background-color:var(--mat-sys-secondary-container)}.toggle.case{font:var(--mat-sys-label-large)}.match-count{min-width:4em;text-align:center;font:var(--mat-sys-label-medium);font-variant-numeric:tabular-nums;color:var(--mat-sys-on-surface-variant)}.coords-error{color:var(--mat-sys-error)}.tip-popup{pointer-events:none;max-width:320px;padding:4px 8px;border-radius:var(--mat-sys-corner-extra-small, 4px);background-color:var(--mat-sys-inverse-surface);color:var(--mat-sys-inverse-on-surface);font-size:var(--mat-sys-body-small-size, 12px);line-height:var(--mat-sys-body-small-line-height, 16px);box-shadow:var(--mat-sys-level2);white-space:pre-wrap;word-break:break-word}\n"]
1611
+ }]
1612
+ }],
1613
+ ctorParameters: () => [],
1614
+ propDecorators: {
1615
+ blocks: [{
1616
+ type: i0.Input,
1617
+ args: [{
1618
+ isSignal: true,
1619
+ alias: "blocks",
1620
+ required: false
1621
+ }]
1622
+ }],
1623
+ settings: [{
1624
+ type: i0.Input,
1625
+ args: [{
1626
+ isSignal: true,
1627
+ alias: "settings",
1628
+ required: false
1629
+ }]
1630
+ }],
1631
+ segmenter: [{
1632
+ type: i0.Input,
1633
+ args: [{
1634
+ isSignal: true,
1635
+ alias: "segmenter",
1636
+ required: false
1637
+ }]
1638
+ }],
1639
+ showZoom: [{
1640
+ type: i0.Input,
1641
+ args: [{
1642
+ isSignal: true,
1643
+ alias: "showZoom",
1644
+ required: false
1645
+ }]
1646
+ }],
1647
+ showFind: [{
1648
+ type: i0.Input,
1649
+ args: [{
1650
+ isSignal: true,
1651
+ alias: "showFind",
1652
+ required: false
1653
+ }]
1654
+ }],
1655
+ showCoords: [{
1656
+ type: i0.Input,
1657
+ args: [{
1658
+ isSignal: true,
1659
+ alias: "showCoords",
1660
+ required: false
1661
+ }]
1662
+ }],
1663
+ ariaLabel: [{
1664
+ type: i0.Input,
1665
+ args: [{
1666
+ isSignal: true,
1667
+ alias: "ariaLabel",
1668
+ required: false
1669
+ }]
1670
+ }],
1671
+ selectedIds: [{
1672
+ type: i0.Input,
1673
+ args: [{
1674
+ isSignal: true,
1675
+ alias: "selectedIds",
1676
+ required: false
1677
+ }]
1678
+ }, {
1679
+ type: i0.Output,
1680
+ args: ["selectedIdsChange"]
1681
+ }],
1682
+ selectionChange: [{
1683
+ type: i0.Output,
1684
+ args: ["selectionChange"]
1685
+ }],
1686
+ segmentClick: [{
1687
+ type: i0.Output,
1688
+ args: ["segmentClick"]
1689
+ }],
1690
+ viewport: [{
1691
+ type: i0.ViewChild,
1692
+ args: ["viewport", { isSignal: true }]
1693
+ }],
1694
+ _overlay: [{
1695
+ type: i0.ViewChild,
1696
+ args: [i0.forwardRef(() => CdkConnectedOverlay), { isSignal: true }]
1697
+ }]
1698
+ }
1699
+ });
1700
+ export { DEFAULT_SEGMENTED_TEXT_SETTINGS, SEGMENTED_TEXT_COORDS_DEBOUNCE, SEGMENTED_TEXT_MAX_ZOOM, SEGMENTED_TEXT_MIN_ZOOM, SegmentedTextStore, SegmentedTextView, SpacedTextSegmenter, TEXT_SEGMENTER, TextMeasureService, TextSegmentBlockView, TextSegmentView, clampFocus, fillTipTemplate, findCaretPosition, findExtendPosition, findNearestAllowed, findTextSegments, getTextSegmentRuns, resolvePath, resolveSegmentRange, resolveSegmentTip, resolveSegmentedTextSettings, truncateText };
1701
+
1702
+ //# sourceMappingURL=myrmidon-cadmus-text-segment.mjs.map