@drghaliasri/butex 7.4.1 → 8.0.0

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.
Files changed (49) hide show
  1. package/README.md +49 -553
  2. package/dist/{document2-cli.js → document-cli.js} +332 -302
  3. package/dist/document-cli.js.map +1 -0
  4. package/dist/document.d.mts +1022 -186
  5. package/dist/document.d.ts +1022 -186
  6. package/dist/document.js +6068 -658
  7. package/dist/document.js.map +1 -1
  8. package/dist/document.mjs +5928 -618
  9. package/dist/document.mjs.map +1 -1
  10. package/dist/index.global.js +19 -7
  11. package/dist/index.global.js.map +1 -1
  12. package/dist/index.js +19 -7
  13. package/dist/index.js.map +1 -1
  14. package/dist/index.mjs +19 -7
  15. package/dist/index.mjs.map +1 -1
  16. package/dist/react-document-preview.d.mts +338 -0
  17. package/dist/react-document-preview.d.ts +338 -0
  18. package/dist/{react-document2-preview.js → react-document-preview.js} +783 -783
  19. package/dist/react-document-preview.js.map +1 -0
  20. package/dist/{react-document2-preview.mjs → react-document-preview.mjs} +776 -776
  21. package/dist/react-document-preview.mjs.map +1 -0
  22. package/dist/react-document.d.mts +634 -35
  23. package/dist/react-document.d.ts +634 -35
  24. package/dist/react-document.js +13259 -4282
  25. package/dist/react-document.js.map +1 -1
  26. package/dist/react-document.mjs +12617 -3648
  27. package/dist/react-document.mjs.map +1 -1
  28. package/dist/react.js +4 -4
  29. package/dist/react.js.map +1 -1
  30. package/dist/react.mjs +4 -4
  31. package/dist/react.mjs.map +1 -1
  32. package/package.json +7 -17
  33. package/dist/document2-cli.js.map +0 -1
  34. package/dist/document2.d.mts +0 -1156
  35. package/dist/document2.d.ts +0 -1156
  36. package/dist/document2.js +0 -9137
  37. package/dist/document2.js.map +0 -1
  38. package/dist/document2.mjs +0 -8972
  39. package/dist/document2.mjs.map +0 -1
  40. package/dist/react-document2-preview.d.mts +0 -338
  41. package/dist/react-document2-preview.d.ts +0 -338
  42. package/dist/react-document2-preview.js.map +0 -1
  43. package/dist/react-document2-preview.mjs.map +0 -1
  44. package/dist/react-document2.d.mts +0 -754
  45. package/dist/react-document2.d.ts +0 -754
  46. package/dist/react-document2.js +0 -23011
  47. package/dist/react-document2.js.map +0 -1
  48. package/dist/react-document2.mjs +0 -22981
  49. package/dist/react-document2.mjs.map +0 -1
@@ -1,5 +1,96 @@
1
+ import * as react from 'react';
2
+ import { ReactNode } from 'react';
1
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
4
 
5
+ type EditorSide = 'english' | 'arabic';
6
+ type EditorNodeKind = 'char' | 'number' | 'operator' | 'delimiter' | 'boxed' | 'frac' | 'sqrt' | 'overset' | 'underset' | 'accent' | 'env' | 'atomicCommand' | 'atomicOperatorCommand' | 'standardCommand';
7
+ type MatrixEnvStyle = 'matrix' | 'pmatrix' | 'bmatrix' | 'Bmatrix' | 'vmatrix' | 'Vmatrix';
8
+ type GridEnvName = MatrixEnvStyle | 'array' | 'aligned';
9
+ type EnvColumnAlignment = 'l' | 'c' | 'r';
10
+ type CharacterFontId = 'default' | 'takween' | 'diwani' | 'diwaniOutline' | 'maghribi';
11
+ type DigitFormId = 'western' | 'arabicIndic' | 'persianIndic';
12
+ type EditorSyncState = 'synced' | 'diverged';
13
+ type EditorChain = {
14
+ id: string;
15
+ nodes: EditorNode[];
16
+ /** Complete script authored as \\mathnormal{ordered,index,atoms}. */
17
+ indexSequence?: boolean;
18
+ };
19
+ type EditorNode = {
20
+ id: string;
21
+ kind: EditorNodeKind;
22
+ expr: string;
23
+ characterFont?: CharacterFontId;
24
+ /** Minimal upstream source identity used only while the node remains unchanged. */
25
+ sourceLatex?: string;
26
+ /** Existing editor node reused for wrapper commands that need editable content. */
27
+ wrapperCommand?: '\\unit' | '\\mathtt' | '\\mathbf' | '\\boldarabic';
28
+ superscript: EditorChain | null;
29
+ subscript: EditorChain | null;
30
+ leftDelimExpr: string;
31
+ rightDelimExpr: string;
32
+ innerExpr: EditorChain | null;
33
+ numerator: EditorChain | null;
34
+ denominator: EditorChain | null;
35
+ radicand: EditorChain | null;
36
+ rootIndex: EditorChain | null;
37
+ overExpr: EditorChain | null;
38
+ underExpr: EditorChain | null;
39
+ baseExpr: EditorChain | null;
40
+ envName: GridEnvName | null;
41
+ matrixStyle: MatrixEnvStyle | null;
42
+ matrixRows: EditorChain[][] | null;
43
+ columnAlignments: EnvColumnAlignment[] | null;
44
+ };
45
+ type EditorCaret = {
46
+ chainId: string;
47
+ index: number;
48
+ };
49
+ type EditorSelectionRange = {
50
+ chainId: string;
51
+ anchorIndex: number;
52
+ focusIndex: number;
53
+ };
54
+ type EditorSyncMap = Record<string, {
55
+ expr: EditorSyncState;
56
+ }>;
57
+ type EditorDebugEntry = {
58
+ timestamp: string;
59
+ command: string;
60
+ activeSide: EditorSide;
61
+ englishLatex: string;
62
+ arabicLatex: string;
63
+ renderOk: boolean;
64
+ renderError: string | null;
65
+ note: string;
66
+ };
67
+ type EditorSession = {
68
+ englishTree: EditorChain;
69
+ arabicTree: EditorChain;
70
+ activeSide: EditorSide;
71
+ /** When true, each typed letter/digit inserts a new char/number leaf; when false, merge into adjacent same-kind leaves. */
72
+ splitLeafTyping: boolean;
73
+ /** One-shot: when true, the next insertChar/insertNumber bypasses leaf-merge (used by Space in merge mode). */
74
+ forceSplitNextLeaf: boolean;
75
+ /** When true and active side is Arabic, merged number typing prepends digits (RTL-style); still mirrored on EN/AR. */
76
+ arabicReverseNumberTyping: boolean;
77
+ /** Font applied to newly typed char nodes. */
78
+ currentCharacterFont: CharacterFontId;
79
+ /** Structured command wrapper applied to newly typed chars; kept separate from fonts. */
80
+ currentCharacterWrapper: '\\boldarabic' | null;
81
+ /** Digit glyph form used for editor display and LaTeX preview output. */
82
+ currentDigitForm: DigitFormId;
83
+ caret: EditorCaret;
84
+ /** Whole-node range selection inside a single chain (anchor==focus means no selection). */
85
+ selection: EditorSelectionRange | null;
86
+ selectedNodeId: string | null;
87
+ selectedStructureNodeId: string | null;
88
+ sync: EditorSyncMap;
89
+ debugLog: EditorDebugEntry[];
90
+ };
91
+
92
+ type ButexUiLocale = 'ar' | 'en';
93
+
3
94
  type ArabicNodeJson = {
4
95
  node_type: string;
5
96
  expr?: string;
@@ -50,106 +141,614 @@ declare class ChainNode {
50
141
  toArabicLatex(): string;
51
142
  }
52
143
 
53
- type MathObjectJson = {
144
+ type MathNode = {
145
+ nodeType: 'MathObject';
146
+ mathMode: string;
147
+ lines: ChainNode[];
148
+ closing: string;
149
+ };
150
+
151
+ type DocumentParseMode = 'english' | 'arabic';
152
+ type DocumentMathOutput = 'svg' | 'chtml';
153
+ type DocumentDirection = 'rtl' | 'ltr';
154
+ type MathObject2Json = {
54
155
  node_type: 'MathObject';
55
156
  math_mode: string;
56
157
  lines: ChainJson[];
57
158
  closing: string;
159
+ /** Side used by the delimited source stored in the containing value/cell. */
160
+ source_side?: DocumentParseMode;
161
+ /** Preserve whether LaTeX export should prefer imported AST rendering or editor source. */
162
+ source_owner?: 'imported-structured' | 'editor';
163
+ label_enabled?: boolean;
164
+ label?: string;
165
+ };
166
+ /** Positional metadata for a raw-only span that has no structured equation AST. */
167
+ type RawMathObject2Json = {
168
+ node_type: 'RawMathObject';
169
+ label_enabled?: boolean;
170
+ label?: string;
171
+ };
172
+ type DocumentMathObjectJson = MathObject2Json | RawMathObject2Json;
173
+ type ReferenceFieldSeparator = ',' | '،';
174
+ type Reference2Json = {
175
+ key: string;
176
+ authors?: string;
177
+ title?: string;
178
+ year?: string;
179
+ url?: string;
180
+ venue?: string;
181
+ /** Bibliography field join: LTR `,` or Arabic `،`. Defaults to `،` when omitted. */
182
+ field_separator?: ReferenceFieldSeparator;
183
+ };
184
+ type HijriMonthId = 'محرم' | 'صفر' | 'ربيع الأول' | 'ربيع الآخر' | 'جمادى الأولى' | 'جمادى الآخرة' | 'رجب' | 'شعبان' | 'رمضان' | 'شوال' | 'ذو القعدة' | 'ذو الحجة';
185
+ type DocumentHijriDate = {
186
+ day: number;
187
+ month: HijriMonthId;
188
+ year: number;
189
+ };
190
+ type DocumentMeta = {
191
+ title: string;
192
+ authors: string;
193
+ date: DocumentHijriDate;
194
+ abstract: string;
58
195
  };
59
196
  type DocumentJson = {
60
197
  node_type: 'DocumentObject';
198
+ meta?: DocumentMeta;
199
+ references?: Reference2Json[];
61
200
  blocks: DocumentBlockJson[];
62
201
  };
202
+ type DocumentInlineTokenIdJson = {
203
+ id: string;
204
+ kind: InlineToken2['kind'];
205
+ start: number;
206
+ end: number;
207
+ };
208
+ type DocumentInlineIdsJson = {
209
+ field_id: string;
210
+ tokens: DocumentInlineTokenIdJson[];
211
+ };
212
+ type DocumentBlockMetadata = {
213
+ source?: 'agent' | 'user';
214
+ };
63
215
  type DocumentBlockJson = {
216
+ /** Stable identity used by headless commands. Legacy JSON may omit it. */
217
+ id?: string;
64
218
  command: string;
65
219
  value?: string;
66
- math_objects?: Array<MathObjectJson | null>;
220
+ formats?: TextFormatSpan2Json[];
221
+ inline_ids?: DocumentInlineIdsJson;
222
+ metadata?: DocumentBlockMetadata;
223
+ /** Stable host asset identity (e.g. S3 key / UUID); optional for \\includegraphics. */
224
+ asset_id?: string;
225
+ math_objects?: Array<DocumentMathObjectJson | null>;
67
226
  options?: Record<string, string>;
68
227
  closing?: string;
69
228
  items?: DocumentListItemJson[];
70
229
  rows?: string[][];
230
+ cell_formats?: TextFormatSpan2Json[][][];
231
+ cell_inline_ids?: DocumentInlineIdsJson[][];
71
232
  columns?: string;
233
+ caption?: string;
234
+ /** Optional formatting sidecar for caption text spans. */
235
+ caption_formats?: TextFormatSpan2Json[];
236
+ /** Stable caption field/token identities; omitted by legacy documents. */
237
+ caption_inline_ids?: DocumentInlineIdsJson;
238
+ /** Caption-only structured math sidecar, independent from table cell math_objects. */
239
+ caption_math_objects?: Array<DocumentMathObjectJson | null>;
240
+ label?: string;
241
+ caption_enabled?: boolean;
242
+ label_enabled?: boolean;
243
+ centered?: boolean;
72
244
  };
73
245
  type DocumentListItemJson = {
246
+ id?: string;
74
247
  value: string;
75
- math_objects?: Array<MathObjectJson | null>;
248
+ formats?: TextFormatSpan2Json[];
249
+ inline_ids?: DocumentInlineIdsJson;
250
+ math_objects?: Array<DocumentMathObjectJson | null>;
76
251
  blocks?: DocumentBlockJson[];
77
252
  };
78
- type MathNode = {
79
- nodeType: 'MathObject';
80
- mathMode: string;
81
- lines: ChainNode[];
82
- closing: string;
253
+ type DocumentDiagnostic = {
254
+ code: string;
255
+ message: string;
256
+ path: string;
83
257
  };
84
- type TextInline = {
258
+ type Reference2 = {
259
+ id: string;
260
+ key: string;
261
+ authors: string;
262
+ title: string;
263
+ year: string;
264
+ url: string;
265
+ venue: string;
266
+ /** Joins authors/title/venue/year in bibliography display and export. */
267
+ fieldSeparator: ReferenceFieldSeparator;
268
+ };
269
+ type TextStyle2 = {
270
+ bold?: true;
271
+ italic?: true;
272
+ underline?: true;
273
+ };
274
+ type TextFormatSpan2Json = {
275
+ start: number;
276
+ end: number;
277
+ bold?: boolean;
278
+ italic?: boolean;
279
+ underline?: boolean;
280
+ };
281
+ type TextToken2 = {
282
+ id: string;
85
283
  kind: 'text';
86
284
  text: string;
285
+ style?: TextStyle2;
87
286
  };
88
- type MathInline = {
287
+ type MathToken2 = {
288
+ id: string;
89
289
  kind: 'math';
290
+ display: boolean;
291
+ opening: string;
292
+ closing: string;
90
293
  source: string;
294
+ sourceSide?: DocumentParseMode;
91
295
  math: MathNode | null;
296
+ editable: boolean;
297
+ reason?: string;
298
+ sourceOwner: 'imported-structured' | 'raw' | 'editor';
299
+ /** When true on display math, export as equation env with \\label. */
300
+ labelEnabled?: boolean;
301
+ label?: string;
302
+ };
303
+ type CiteToken2 = {
304
+ id: string;
305
+ kind: 'cite';
306
+ keys: string[];
92
307
  };
93
- type DocumentInline = TextInline | MathInline;
94
- type TextBlockNode = {
308
+ type RefToken2 = {
309
+ id: string;
310
+ kind: 'ref';
311
+ keys: string[];
312
+ refCommand: 'ref' | 'eqref';
313
+ };
314
+ type InlineToken2 = TextToken2 | MathToken2 | CiteToken2 | RefToken2;
315
+ type InlineField2 = {
316
+ id: string;
317
+ tokens: InlineToken2[];
318
+ };
319
+ type TextBlock2 = {
320
+ id: string;
95
321
  kind: 'textBlock';
96
322
  command: '\\section' | '\\subsection' | '\\subsubsection' | '\\paragraph';
97
- value: string;
98
- inlines: DocumentInline[];
323
+ field: InlineField2;
324
+ metadata?: DocumentBlockMetadata;
325
+ /** When true on \\paragraph, center in preview and LaTeX export. */
326
+ centered?: boolean;
99
327
  };
100
- type ListItemNode = {
101
- value: string;
102
- inlines: DocumentInline[];
103
- blocks: DocumentBlockNode[];
328
+ type ListItem2 = {
329
+ id: string;
330
+ field: InlineField2;
331
+ blocks: DocumentBlock[];
104
332
  };
105
- type ListBlockNode = {
333
+ type ListBlock2 = {
334
+ id: string;
106
335
  kind: 'list';
107
336
  command: '\\begin{itemize}' | '\\begin{enumerate}';
108
337
  closing: '\\end{itemize}' | '\\end{enumerate}';
109
- items: ListItemNode[];
338
+ items: ListItem2[];
339
+ metadata?: DocumentBlockMetadata;
340
+ };
341
+ type FloatMeta2 = {
342
+ centered: boolean;
343
+ captionEnabled: boolean;
344
+ /** Compatibility source string; captionField is the structured source of truth. */
345
+ caption: string;
346
+ /** Stable inline field used by the editor, commands, preview, and persistence. */
347
+ captionField: InlineField2;
348
+ labelEnabled: boolean;
349
+ label: string;
110
350
  };
111
- type TableBlockNode = {
351
+ type TableBlock2 = {
352
+ id: string;
112
353
  kind: 'table';
113
354
  command: '\\begin{tabular}';
114
355
  closing: '\\end{tabular}';
115
356
  columns: string;
116
- rows: DocumentInline[][][];
117
- };
118
- type ImageBlockNode = {
357
+ rows: InlineField2[][];
358
+ metadata?: DocumentBlockMetadata;
359
+ } & FloatMeta2;
360
+ type ImageBlock2 = {
361
+ id: string;
119
362
  kind: 'image';
120
363
  command: '\\includegraphics';
121
364
  value: string;
365
+ /** Host asset identity from wire `asset_id`; preserved across value edits. */
366
+ assetId?: string;
122
367
  options: Record<string, string>;
368
+ metadata?: DocumentBlockMetadata;
369
+ } & FloatMeta2;
370
+ type BibliographyBlock2 = {
371
+ id: string;
372
+ kind: 'bibliography';
373
+ command: '\\begin{thebibliography}';
374
+ closing: '\\end{thebibliography}';
375
+ metadata?: DocumentBlockMetadata;
123
376
  };
124
- type RawBlockNode = {
377
+ type RawBlock2 = {
378
+ id: string;
125
379
  kind: 'raw';
126
380
  command: '\\raw';
127
381
  value: string;
382
+ metadata?: DocumentBlockMetadata;
128
383
  };
129
- type DocumentBlockNode = TextBlockNode | ListBlockNode | TableBlockNode | ImageBlockNode | RawBlockNode;
384
+ type DocumentBlock = TextBlock2 | ListBlock2 | TableBlock2 | ImageBlock2 | BibliographyBlock2 | RawBlock2;
130
385
  type DocumentNode = {
131
386
  nodeType: 'DocumentObject';
132
- blocks: DocumentBlockNode[];
387
+ meta: DocumentMeta;
388
+ references: Reference2[];
389
+ blocks: DocumentBlock[];
390
+ diagnostics: DocumentDiagnostic[];
391
+ };
392
+ type PreviewInline2 = {
393
+ kind: 'text';
394
+ text: string;
395
+ style?: TextStyle2;
396
+ } | {
397
+ kind: 'math';
398
+ id: string;
399
+ tex: string;
400
+ display: boolean;
401
+ output: DocumentMathOutput;
402
+ editable: boolean;
403
+ } | {
404
+ kind: 'cite';
405
+ id: string;
406
+ keys: string[];
407
+ label: string;
408
+ } | {
409
+ kind: 'ref';
410
+ id: string;
411
+ keys: string[];
412
+ refCommand: 'ref' | 'eqref';
413
+ label: string;
414
+ };
415
+ type PreviewBlock2 = {
416
+ kind: 'basmala';
417
+ id: string;
418
+ text: string;
419
+ tex: string;
420
+ } | {
421
+ kind: 'titleBlock';
422
+ id: string;
423
+ title?: string;
424
+ authors?: string;
425
+ date?: string;
426
+ } | {
427
+ kind: 'abstract';
428
+ id: string;
429
+ text: string;
430
+ } | {
431
+ kind: 'closing';
432
+ id: string;
433
+ text: string;
434
+ tex: string;
435
+ } | {
436
+ kind: 'heading';
437
+ id: string;
438
+ level: 1 | 2 | 3;
439
+ inlines: PreviewInline2[];
440
+ metadata?: DocumentBlockMetadata;
441
+ } | {
442
+ kind: 'paragraph';
443
+ id: string;
444
+ inlines: PreviewInline2[];
445
+ centered?: boolean;
446
+ metadata?: DocumentBlockMetadata;
447
+ } | {
448
+ kind: 'list';
449
+ id: string;
450
+ ordered: boolean;
451
+ items: Array<{
452
+ id: string;
453
+ inlines: PreviewInline2[];
454
+ blocks: PreviewBlock2[];
455
+ }>;
456
+ metadata?: DocumentBlockMetadata;
457
+ } | {
458
+ kind: 'table';
459
+ id: string;
460
+ rows: PreviewInline2[][][];
461
+ /** Compatibility source string for hosts that still read caption directly. */
462
+ caption?: string;
463
+ /** Structured caption rendering path, including MathIsland tokens. */
464
+ captionInlines?: PreviewInline2[];
465
+ label?: string;
466
+ numberLabel?: string;
467
+ metadata?: DocumentBlockMetadata;
468
+ } | {
469
+ kind: 'image';
470
+ id: string;
471
+ src: string;
472
+ assetId?: string;
473
+ options: Record<string, string>;
474
+ centered?: boolean;
475
+ /** Compatibility source string for alt text/legacy hosts. */
476
+ caption?: string;
477
+ /** Structured caption rendering path, including MathIsland tokens. */
478
+ captionInlines?: PreviewInline2[];
479
+ label?: string;
480
+ numberLabel?: string;
481
+ metadata?: DocumentBlockMetadata;
482
+ } | {
483
+ kind: 'bibliography';
484
+ id: string;
485
+ items: Array<{
486
+ id: string;
487
+ numberLabel: string;
488
+ key: string;
489
+ authors: string;
490
+ title: string;
491
+ year: string;
492
+ url: string;
493
+ venue: string;
494
+ fieldSeparator: ReferenceFieldSeparator;
495
+ }>;
496
+ metadata?: DocumentBlockMetadata;
497
+ }
498
+ /** Preview-only: raw / unknown blocks are omitted from preview until we add proper rendering. */
499
+ | {
500
+ kind: 'omit';
501
+ id: string;
502
+ metadata?: DocumentBlockMetadata;
503
+ };
504
+
505
+ type DocumentLabelKind = 'fig' | 'tab' | 'eq';
506
+ type DocumentLabelEntry = {
507
+ key: string;
508
+ kind: DocumentLabelKind;
509
+ caption: string;
510
+ /** Block id for fig/tab, or math token id for eq. */
511
+ ownerId: string;
512
+ number: number;
513
+ };
514
+
515
+ type DocumentMetaProp = Partial<Omit<DocumentMeta, 'date'>> & {
516
+ date?: Partial<DocumentHijriDate>;
517
+ };
518
+
519
+ type ImageAssetRef = {
520
+ assetId: string;
521
+ value?: string;
522
+ label?: string;
523
+ thumbUrl?: string;
524
+ };
525
+ type ImageBlockEditorRenderContext = {
526
+ blockId: string;
527
+ assetId?: string;
528
+ value: string;
529
+ resolvedUrl: string;
530
+ uiLocale: ButexUiLocale;
531
+ onSelectAsset: (ref: ImageAssetRef) => void;
532
+ onClearAsset: () => void;
533
+ defaultUi: ReactNode;
133
534
  };
134
535
 
135
- type ButexDocumentEditorProps = {
536
+ /** Controls which responsive interaction workflow a React editor uses. */
537
+ type ButexResponsiveMode = 'auto' | 'desktop' | 'compact';
538
+
539
+ type ButexDocumentEditorProps$1 = {
136
540
  initialDocument?: DocumentJson | DocumentNode;
541
+ /** Seed article metadata when JSON/node omits fields (JSON wins when present). */
542
+ documentMeta?: DocumentMetaProp;
137
543
  className?: string;
138
544
  debug?: boolean;
545
+ documentDirection?: 'rtl' | 'ltr';
546
+ equationSide?: EditorSide;
547
+ editableEquations?: boolean;
548
+ /** When true, render only the read-only document preview (no toolbar, editor panel, or equation drawer). */
549
+ previewOnly?: boolean;
550
+ uiLocale?: ButexUiLocale;
551
+ /** Selects the responsive interaction workflow. Automatic mode follows the layout viewport. */
552
+ responsiveMode?: ButexResponsiveMode;
553
+ mathOutput?: DocumentMathOutput;
554
+ /** Digit shaping for citation and bibliography numbers (western / arabicIndic / persianIndic). */
555
+ digitForm?: DigitFormId;
556
+ onDigitFormChange?: (digitForm: DigitFormId) => void;
557
+ /** Host maps assetId / literal value to a browser-loadable image URL (S3, CDN, local). */
558
+ resolveImageUrl?: (ref: {
559
+ assetId?: string;
560
+ value: string;
561
+ }) => string;
562
+ onRequestImagePick?: (ctx: {
563
+ blockId: string;
564
+ current: ImageAssetRef | null;
565
+ }) => Promise<ImageAssetRef | null> | ImageAssetRef | null;
566
+ listImageAssets?: () => Promise<ImageAssetRef[]> | ImageAssetRef[];
567
+ renderImageBlockEditor?: (ctx: ImageBlockEditorRenderContext) => ReactNode;
139
568
  onDocumentChange?: (document: DocumentNode) => void;
569
+ /** Canonical JSON wire format for API/database persistence. */
570
+ onDocumentJsonChange?: (document: DocumentJson) => void;
140
571
  onLatexChange?: (latex: string) => void;
141
572
  };
142
573
  type DocumentInitialState = {
143
574
  document: DocumentNode;
144
575
  error: string | null;
145
576
  };
146
- declare function resolveInitialDocument(initialDocument: DocumentJson | DocumentNode | undefined): DocumentInitialState;
147
- declare function ButexDocumentEditor({ initialDocument, className, debug, onDocumentChange, onLatexChange, }: ButexDocumentEditorProps): react_jsx_runtime.JSX.Element;
148
- declare namespace ButexDocumentEditor {
149
- var displayName: string;
150
- }
577
+ /** Imperative host API — insert/update figures on the live document without remounting. */
578
+ type ButexDocumentEditorRef = {
579
+ /** Insert image block after focused block (same as toolbar figure button). */
580
+ insertImageBlock: (srcOrAsset?: string | ImageAssetRef) => void;
581
+ /** Set path on an existing image block. */
582
+ updateImageBlockValue: (blockId: string, value: string) => void;
583
+ /** Set host asset identity and includegraphics value on an existing image block. */
584
+ updateImageBlockAsset: (blockId: string, ref: ImageAssetRef) => void;
585
+ /** Canonical JSON without host-side AST mutation. */
586
+ getDocumentJson: () => DocumentJson;
587
+ };
588
+
589
+ declare function resolveInitialDocument(initialDocument: DocumentJson | DocumentNode | undefined, uiLocale?: ButexUiLocale, documentMeta?: DocumentMetaProp): DocumentInitialState;
590
+
591
+ type ButexDocumentEditorProps = ButexDocumentEditorProps$1 & {
592
+ /** Reports whether the current draft is safe for LaTeX compilation. */
593
+ onValidityChange?: (isValid: boolean) => void;
594
+ };
595
+ declare const ButexDocumentEditor: react.ForwardRefExoticComponent<ButexDocumentEditorProps$1 & {
596
+ /** Reports whether the current draft is safe for LaTeX compilation. */
597
+ onValidityChange?: (isValid: boolean) => void;
598
+ } & react.RefAttributes<ButexDocumentEditorRef>>;
599
+
600
+ type ResolveDocumentImageUrl = (ref: {
601
+ assetId?: string;
602
+ value: string;
603
+ }) => string | null | undefined;
604
+ declare function DocumentPreview({ blocks, output, documentDirection, uiLocale, digitForm, resolveImageUrl, }: {
605
+ blocks: PreviewBlock2[];
606
+ output: DocumentMathOutput;
607
+ documentDirection?: 'rtl' | 'ltr';
608
+ uiLocale?: ButexUiLocale;
609
+ digitForm?: DigitFormId;
610
+ resolveImageUrl?: ResolveDocumentImageUrl;
611
+ }): react_jsx_runtime.JSX.Element;
612
+
613
+ type ButexDocumentPreviewProps = {
614
+ /** Persisted wire JSON or an already-imported live Document node. */
615
+ document: DocumentJson | DocumentNode;
616
+ className?: string;
617
+ documentDirection?: DocumentDirection;
618
+ uiLocale?: ButexUiLocale;
619
+ digitForm?: DigitFormId;
620
+ equationSide?: EditorSide;
621
+ mathOutput?: DocumentMathOutput;
622
+ /** Host maps asset identity/value to a browser-loadable URL. Return null/undefined while unavailable. */
623
+ resolveImageUrl?: ResolveDocumentImageUrl;
624
+ };
625
+ type PreviewDocumentState = {
626
+ document: DocumentNode;
627
+ error: string | null;
628
+ };
629
+ declare function resolvePreviewDocument(input: DocumentJson | DocumentNode, uiLocale?: ButexUiLocale): PreviewDocumentState;
630
+ /**
631
+ * Dedicated read-only Document renderer. This intentionally bypasses the full
632
+ * editor component and derives only the runtime document plus preview model.
633
+ */
634
+ declare function ButexDocumentPreview({ document, className, documentDirection, uiLocale, digitForm, equationSide, mathOutput, resolveImageUrl, }: ButexDocumentPreviewProps): react_jsx_runtime.JSX.Element;
635
+
636
+ type DocumentInsertToolbarProps = {
637
+ canUndo: boolean;
638
+ canRedo: boolean;
639
+ editableEquations?: boolean;
640
+ uiLocale?: ButexUiLocale;
641
+ digitForm?: DigitFormId;
642
+ selectionCount?: number;
643
+ canMoveSelectionUp?: boolean;
644
+ canMoveSelectionDown?: boolean;
645
+ canFormatText?: boolean;
646
+ activeTextStyles?: TextStyle2;
647
+ onUndo: () => void;
648
+ onRedo: () => void;
649
+ onToggleTextStyle?: (styleName: keyof TextStyle2) => void;
650
+ onMoveSelectionUp?: () => void;
651
+ onMoveSelectionDown?: () => void;
652
+ onDeleteSelection?: () => void;
653
+ onAddSection: () => void;
654
+ onAddSubsection: () => void;
655
+ onAddSubsubsection: () => void;
656
+ onAddParagraph: () => void;
657
+ onAddInlineEquation: () => void;
658
+ onAddDisplayEquation: () => void;
659
+ onAddTable: (rowCount: number, colCount: number) => void;
660
+ onAddList: () => void;
661
+ onAddEnumerate: () => void;
662
+ onAddFigure: () => void;
663
+ onInsertCitation: () => void;
664
+ onInsertInternalRef: () => void;
665
+ onInsertBibliography: () => void;
666
+ onManageReferences: () => void;
667
+ onManageLabels: () => void;
668
+ onOpenArticleMeta?: () => void;
669
+ onDigitFormChange: (digitForm: DigitFormId) => void;
670
+ };
671
+ declare function DocumentInsertToolbar({ canUndo, canRedo, editableEquations, uiLocale, digitForm, selectionCount, canMoveSelectionUp, canMoveSelectionDown, canFormatText, activeTextStyles, onUndo, onRedo, onToggleTextStyle, onMoveSelectionUp, onMoveSelectionDown, onDeleteSelection, onAddSection, onAddSubsection, onAddSubsubsection, onAddParagraph, onAddInlineEquation, onAddDisplayEquation, onAddTable, onAddList, onAddEnumerate, onAddFigure, onInsertCitation, onInsertInternalRef, onInsertBibliography, onManageReferences, onManageLabels, onOpenArticleMeta, onDigitFormChange, }: DocumentInsertToolbarProps): react_jsx_runtime.JSX.Element;
672
+
673
+ type EquationMathMode = 'inline' | 'display';
674
+ type EquationDrawerProps = {
675
+ debug?: boolean;
676
+ session: EditorSession;
677
+ reason?: string | null;
678
+ mathMode: EquationMathMode;
679
+ canDelete?: boolean;
680
+ equationSide?: EditorSide;
681
+ uiLocale?: ButexUiLocale;
682
+ responsiveMode?: ButexResponsiveMode;
683
+ labelEnabled?: boolean;
684
+ label?: string;
685
+ labels?: DocumentLabelEntry[];
686
+ references?: Reference2[];
687
+ ownerId?: string;
688
+ onLabelEnabledChange?: (enabled: boolean) => void;
689
+ onLabelChange?: (label: string) => void;
690
+ onMathModeChange: (mode: EquationMathMode) => void;
691
+ onClose: () => void;
692
+ onSave: (session: EditorSession) => void;
693
+ onDelete?: () => void;
694
+ };
695
+ declare function EquationDrawer({ debug, session, reason, mathMode, canDelete, equationSide, uiLocale, responsiveMode, labelEnabled, label, labels, references, ownerId, onLabelEnabledChange, onLabelChange, onMathModeChange, onClose, onSave, onDelete, }: EquationDrawerProps): react_jsx_runtime.JSX.Element;
696
+
697
+ type InlineFieldProps = {
698
+ field: InlineField2;
699
+ blockId?: string;
700
+ references?: Reference2[];
701
+ documentNode?: DocumentNode;
702
+ documentDirection?: 'rtl' | 'ltr';
703
+ digitForm?: DigitFormId;
704
+ mathOutput?: DocumentMathOutput;
705
+ equationSide?: EditorSide;
706
+ editableEquations?: boolean;
707
+ editableCitations?: boolean;
708
+ uiLocale?: ButexUiLocale;
709
+ onTextChange: (fieldId: string, tokenId: string, text: string) => void;
710
+ onOpenMath: (token: MathToken2, origin: HTMLButtonElement) => void;
711
+ onDeleteMath?: (tokenId: string) => void;
712
+ onOpenCite?: (token: CiteToken2) => void;
713
+ onDeleteCite?: (tokenId: string) => void;
714
+ onOpenRef?: (token: RefToken2) => void;
715
+ onDeleteRef?: (tokenId: string) => void;
716
+ onFieldFocus?: (blockId: string, fieldId: string, textTokenId: string, caretOffset: number, selectionStart: number, selectionEnd: number) => void;
717
+ onMathFocus?: (blockId: string, fieldId: string, tokenId: string) => void;
718
+ onCiteFocus?: (blockId: string, fieldId: string, tokenId: string) => void;
719
+ onRefFocus?: (blockId: string, fieldId: string, tokenId: string) => void;
720
+ onFieldBlur?: () => void;
721
+ };
722
+ declare function InlineField({ field, blockId, references, documentNode, documentDirection, digitForm, mathOutput, equationSide, editableEquations, editableCitations, uiLocale, onTextChange, onOpenMath, onDeleteMath, onOpenCite, onDeleteCite, onOpenRef, onDeleteRef, onFieldFocus, onMathFocus, onCiteFocus, onRefFocus, onFieldBlur, }: InlineFieldProps): react_jsx_runtime.JSX.Element;
723
+
724
+ type MathChipProps = {
725
+ token: MathToken2;
726
+ output?: DocumentMathOutput;
727
+ documentDirection?: 'rtl' | 'ltr';
728
+ digitForm?: DigitFormId;
729
+ equationSide?: EditorSide;
730
+ editable?: boolean;
731
+ uiLocale?: ButexUiLocale;
732
+ buttonRef?: (element: HTMLButtonElement | null) => void;
733
+ onOpen: (token: MathToken2, origin: HTMLButtonElement) => void;
734
+ onDelete?: (tokenId: string) => void;
735
+ onFocus?: (tokenId: string) => void;
736
+ onRequestTextFocus?: (tokenId: string, direction: -1 | 1) => void;
737
+ onTextInputFromFocus?: (tokenId: string, text: string) => void;
738
+ };
739
+ declare function MathChip({ token, output, documentDirection, digitForm, equationSide, editable, uiLocale, buttonRef, onOpen, onDelete, onFocus, onRequestTextFocus, onTextInputFromFocus, }: MathChipProps): react_jsx_runtime.JSX.Element;
740
+
741
+ type BuTeXMathOutput = 'chtml' | 'svg';
742
+
743
+ type MathIslandProps = {
744
+ id: string;
745
+ tex: string;
746
+ display: boolean;
747
+ output?: BuTeXMathOutput;
748
+ };
749
+ declare function MathIsland({ id, tex, display, output }: MathIslandProps): react_jsx_runtime.JSX.Element;
151
750
 
152
- declare const DOCUMENT_WIDGET_CSS = "\n.butex-document-widget {\n --butex-document-bg: var(--butex-bg, #f8fafc);\n --butex-document-fg: var(--butex-fg, #0f172a);\n --butex-document-muted: var(--butex-muted, #64748b);\n --butex-document-panel: var(--butex-panel, #ffffff);\n --butex-document-border: var(--butex-border, #e2e8f0);\n --butex-document-accent: var(--butex-accent, #0d9488);\n --butex-document-accent-hover: var(--butex-accent-hover, #0f766e);\n --butex-document-accent-bg: var(--butex-toolbar-hover-bg, rgba(13, 148, 136, 0.08));\n --butex-document-focus-shadow: var(--butex-focus-shadow, rgba(13, 148, 136, 0.16));\n --butex-document-danger: var(--butex-danger, #dc2626);\n --butex-document-error: var(--butex-error, #b91c1c);\n --butex-document-error-bg: var(--butex-error-bg, #fef2f2);\n --butex-document-shadow: var(--butex-shadow-md, 0 4px 14px rgba(15, 23, 42, 0.08));\n --butex-document-preview-bg: var(--butex-preview-bg, #ffffff);\n --butex-document-preview-fg: var(--butex-preview-fg, var(--butex-document-fg));\n --butex-document-preview-font: \"Amiri\", \"Noto Serif Arabic\", Georgia, \"Times New Roman\", serif;\n --butex-document-drawer-bg: var(--butex-document-panel);\n --butex-document-input-bg: #ffffff;\n --butex-document-input-border: var(--butex-document-border);\n --butex-document-table-border: var(--butex-document-border);\n --butex-document-raw-bg: #f8fafc;\n --butex-document-math-bg: var(--butex-document-accent-bg);\n --butex-document-math-border: rgba(13, 148, 136, 0.35);\n --butex-document-dev-bg: var(--butex-dev-bg, #fffbeb);\n --butex-document-dev-border: var(--butex-dev-border, #fcd34d);\n --butex-document-dev-code-bg: var(--butex-dev-inset-bg, #ffffff);\n --butex-document-dev-code-fg: var(--butex-dev-inset-fg, var(--butex-document-fg));\n box-sizing: border-box;\n color: var(--butex-document-fg);\n direction: rtl;\n font-family: ui-sans-serif, system-ui, \"Segoe UI\", Tahoma, Arial, sans-serif;\n line-height: 1.45;\n}\n\n.butex-document-widget *,\n.butex-document-widget *::before,\n.butex-document-widget *::after {\n box-sizing: inherit;\n}\n\n.butex-document-widget__shell {\n display: grid;\n gap: 12px;\n}\n\n.butex-document-widget__toolbar,\n.butex-document-widget__panel {\n border: 1px solid var(--butex-document-border);\n border-radius: 10px;\n background: var(--butex-document-panel);\n box-shadow: var(--butex-document-shadow);\n}\n\n.butex-document-widget__toolbar {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n padding: 8px;\n}\n\n.butex-document-widget button {\n border: 1px solid var(--butex-document-border);\n border-radius: 8px;\n background: var(--butex-document-panel);\n color: var(--butex-document-fg);\n cursor: pointer;\n min-height: 32px;\n padding: 0 10px;\n transition: border-color 0.14s ease, background 0.14s ease, box-shadow 0.14s ease, color 0.14s ease;\n}\n\n.butex-document-widget button[aria-pressed=\"true\"],\n.butex-document-widget button:hover {\n border-color: var(--butex-document-accent);\n background: var(--butex-document-accent-bg);\n}\n\n.butex-document-widget button:focus-visible,\n.butex-document-widget input:focus-visible,\n.butex-document-widget textarea:focus-visible {\n border-color: var(--butex-document-accent);\n box-shadow: 0 0 0 3px var(--butex-document-focus-shadow);\n outline: none;\n}\n\n.butex-document-widget button:disabled {\n cursor: not-allowed;\n opacity: 0.5;\n}\n\n.butex-document-widget__panel {\n padding: 16px;\n}\n\n.butex-document-widget__layout {\n align-items: start;\n display: grid;\n gap: 12px;\n grid-template-columns: minmax(0, 1fr) minmax(280px, 0.9fr);\n transition: grid-template-columns 0.22s ease;\n}\n\n.butex-document-widget__layout--editor-open.butex-document-widget__layout--preview-open {\n grid-template-columns: minmax(0, 1fr) minmax(280px, 0.9fr);\n}\n\n.butex-document-widget__layout--editor-open.butex-document-widget__layout--preview-closed {\n grid-template-columns: minmax(0, 1fr) minmax(0, 0fr);\n}\n\n.butex-document-widget__layout--editor-closed.butex-document-widget__layout--preview-open {\n grid-template-columns: minmax(0, 0fr) minmax(0, 1fr);\n}\n\n.butex-document-widget__layout--editor-closed.butex-document-widget__layout--preview-closed {\n grid-template-columns: minmax(0, 1fr) minmax(0, 0fr);\n}\n\n.butex-document-widget__layout--preview-open {\n grid-template-columns: minmax(0, 1fr) minmax(280px, 0.9fr);\n}\n\n.butex-document-widget__layout--preview-closed {\n grid-template-columns: minmax(0, 1fr) minmax(0, 0fr);\n}\n\n.butex-document-widget__editor-panel,\n.butex-document-widget__preview-panel {\n min-width: 0;\n opacity: 1;\n overflow-x: hidden;\n overflow-y: auto;\n transform: translateX(0);\n transition:\n opacity 0.18s ease,\n transform 0.22s ease,\n padding 0.22s ease,\n border-width 0.22s ease,\n box-shadow 0.22s ease;\n}\n\n.butex-document-widget__layout--editor-closed .butex-document-widget__editor-panel {\n border-width: 0;\n box-shadow: none;\n opacity: 0;\n padding-inline: 0;\n pointer-events: none;\n transform: translateX(10px);\n visibility: hidden;\n}\n\n.butex-document-widget__layout--preview-closed .butex-document-widget__preview-panel {\n border-width: 0;\n box-shadow: none;\n opacity: 0;\n padding-inline: 0;\n pointer-events: none;\n transform: translateX(-10px);\n visibility: hidden;\n}\n\n.butex-document-widget__block {\n border: 1px solid var(--butex-document-border);\n border-radius: 9px;\n background: var(--butex-document-panel);\n display: grid;\n gap: 10px;\n margin-bottom: 12px;\n padding: 10px;\n}\n\n.butex-document-widget__block-head,\n.butex-document-widget__row-actions,\n.butex-document-widget__drawer-head {\n align-items: center;\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n justify-content: space-between;\n}\n\n.butex-document-widget__row-actions {\n justify-content: flex-start;\n}\n\n.butex-document-widget__field {\n display: grid;\n gap: 6px;\n}\n\n.butex-document-widget__field--short {\n max-width: 220px;\n}\n\n.butex-document-widget input,\n.butex-document-widget textarea {\n background: var(--butex-document-input-bg);\n border: 1px solid var(--butex-document-input-border);\n border-radius: 8px;\n color: var(--butex-document-fg);\n font: inherit;\n min-height: 34px;\n padding: 7px 9px;\n}\n\n.butex-document-widget textarea {\n min-height: 72px;\n resize: vertical;\n}\n\n.butex-document-widget__chips {\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n}\n\n.butex-document-widget .butex-document-widget__math-chip {\n background: var(--butex-document-math-bg);\n border-color: var(--butex-document-math-border);\n direction: ltr;\n font-family: ui-monospace, SFMono-Regular, Consolas, monospace;\n min-height: 28px;\n unicode-bidi: isolate;\n}\n\n.butex-document-widget__list-editor,\n.butex-document-widget__image-editor {\n display: grid;\n gap: 10px;\n}\n\n.butex-document-widget__list-item {\n border-inline-start: 3px solid var(--butex-document-border);\n display: grid;\n gap: 8px;\n padding-inline-start: 10px;\n}\n\n.butex-document-widget__nested {\n display: grid;\n gap: 6px;\n}\n\n.butex-document-widget__nested-block {\n border: 1px dashed var(--butex-document-border);\n border-radius: 8px;\n color: var(--butex-document-muted);\n background: var(--butex-document-bg);\n padding: 8px;\n}\n\n.butex-document-widget__table-editor {\n display: grid;\n gap: 10px;\n}\n\n.butex-document-widget__table-grid {\n display: grid;\n gap: 6px;\n overflow-x: auto;\n}\n\n.butex-document-widget__table-row {\n display: flex;\n gap: 6px;\n}\n\n.butex-document-widget__table-cell {\n display: grid;\n gap: 4px;\n min-width: 120px;\n}\n\n.butex-document-widget__placeholder,\n.butex-document-widget__error {\n margin: 0;\n color: var(--butex-document-muted);\n}\n\n.butex-document-widget__error {\n border: 1px solid var(--butex-document-error);\n border-radius: 8px;\n background: var(--butex-document-error-bg);\n color: var(--butex-document-error);\n padding: 10px;\n}\n\n.butex-document-widget__preview {\n background: var(--butex-document-preview-bg);\n color: var(--butex-document-preview-fg);\n direction: rtl;\n font-family: var(--butex-document-preview-font);\n font-size: 1.08rem;\n line-height: 1.9;\n}\n\n.butex-document-widget__preview h1,\n.butex-document-widget__preview h2,\n.butex-document-widget__preview h3,\n.butex-document-widget__preview p,\n.butex-document-widget__preview li,\n.butex-document-widget__preview td {\n overflow: visible;\n}\n\n.butex-document-widget__preview h1,\n.butex-document-widget__preview h2,\n.butex-document-widget__preview h3,\n.butex-document-widget__preview p {\n margin: 0 0 12px;\n}\n\n.butex-document-widget__preview h1 {\n font-size: 1.75rem;\n font-weight: 700;\n line-height: 1.35;\n}\n\n.butex-document-widget__preview h2 {\n font-size: 1.4rem;\n font-weight: 600;\n line-height: 1.4;\n}\n\n.butex-document-widget__preview h3 {\n font-size: 1.2rem;\n font-weight: 600;\n line-height: 1.45;\n}\n\n.butex-document-widget__preview ul,\n.butex-document-widget__preview ol {\n margin: 0 0 12px;\n padding-inline-start: 24px;\n}\n\n.butex-document-widget__preview img {\n display: block;\n height: auto;\n max-width: 100%;\n}\n\n.butex-document-widget__preview table {\n border-collapse: collapse;\n margin: 12px 0;\n width: 100%;\n}\n\n.butex-document-widget__preview td {\n border: 1px solid var(--butex-document-table-border);\n padding: 6px 8px;\n}\n\n.butex-document-widget .butex-document-math-island {\n direction: ltr;\n display: inline-block;\n line-height: normal;\n margin: 0 2px;\n overflow: visible;\n padding: 0;\n unicode-bidi: isolate;\n vertical-align: middle;\n}\n\n.butex-document-widget .butex-document-math-island mjx-container {\n display: inline-block !important;\n line-height: normal;\n margin: 0;\n overflow: visible;\n vertical-align: middle;\n}\n\n.butex-document-widget .butex-document-math-island[data-math-display=\"true\"] {\n display: block;\n margin: 10px 0;\n overflow: visible;\n text-align: center;\n}\n\n.butex-document-widget .butex-document-math-island[data-math-display=\"true\"] mjx-container {\n display: block !important;\n margin-inline: auto;\n}\n\n.butex-document-widget__preview-error {\n border: 1px solid var(--butex-document-error);\n border-radius: 8px;\n background: var(--butex-document-error-bg);\n color: var(--butex-document-error);\n margin: 12px 0 0;\n padding: 8px 10px;\n}\n\n.butex-document-widget__dev {\n border: 1px solid var(--butex-document-dev-border);\n border-radius: 10px;\n background: var(--butex-document-dev-bg);\n box-shadow: var(--butex-document-shadow);\n display: grid;\n gap: 10px;\n padding: 12px;\n}\n\n.butex-document-widget__dev pre {\n border: 1px solid var(--butex-document-dev-border);\n border-radius: 8px;\n background: var(--butex-document-dev-code-bg);\n color: var(--butex-document-dev-code-fg);\n direction: ltr;\n margin: 0;\n max-height: 220px;\n overflow: auto;\n padding: 10px;\n text-align: left;\n white-space: pre-wrap;\n}\n\n.butex-document-widget__drawer {\n background: var(--butex-document-drawer-bg);\n border-inline-start: 1px solid var(--butex-document-border);\n bottom: 0;\n box-shadow: -8px 0 22px rgba(15, 23, 42, 0.12);\n display: grid;\n gap: 12px;\n max-width: min(680px, 94vw);\n overflow: auto;\n padding: 14px;\n position: fixed;\n right: 0;\n top: 0;\n width: 640px;\n z-index: 30;\n}\n\n@media (max-width: 900px) {\n .butex-document-widget__layout {\n grid-template-columns: 1fr;\n }\n\n .butex-document-widget__layout--preview-closed .butex-document-widget__preview-panel {\n display: none;\n }\n\n .butex-document-widget__layout--editor-closed .butex-document-widget__editor-panel {\n display: none;\n }\n\n .butex-document-widget__drawer {\n border-inline-start: 0;\n left: 0;\n max-width: none;\n width: 100%;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .butex-document-widget__layout,\n .butex-document-widget__editor-panel,\n .butex-document-widget__preview-panel {\n transition: none;\n }\n}\n";
751
+ declare const DOCUMENT_WIDGET_CSS = "\n.butex-document-widget {\n --butex-document-bg: var(--butex-bg, #f8fafc);\n --butex-document-fg: var(--butex-fg, #0f172a);\n --butex-document-muted: var(--butex-muted, #64748b);\n --butex-document-panel: var(--butex-panel, #ffffff);\n --butex-document-border: var(--butex-border, #e2e8f0);\n --butex-document-accent: var(--butex-accent, #0d9488);\n --butex-document-accent-bg: var(--butex-toolbar-hover-bg, rgba(13, 148, 136, 0.08));\n --butex-document-focus-shadow: var(--butex-focus-shadow, rgba(13, 148, 136, 0.16));\n --butex-document-danger: var(--butex-danger, #dc2626);\n --butex-document-error: var(--butex-error, #b91c1c);\n --butex-document-error-bg: var(--butex-error-bg, #fef2f2);\n --butex-document-preview-bg: var(--butex-preview-bg, #ffffff);\n --butex-document-preview-fg: var(--butex-preview-fg, var(--butex-document-fg));\n --butex-document-preview-font: \"Amiri\", \"Noto Serif Arabic\", Georgia, \"Times New Roman\", serif;\n --butex-document-drawer-bg: var(--butex-document-panel);\n --butex-document-input-bg: #ffffff;\n --butex-document-raw-bg: #f8fafc;\n --butex-document-math-bg: var(--butex-document-accent-bg);\n --butex-document-math-border: rgba(13, 148, 136, 0.35);\n --butex-document-text-token-bg: var(--butex-text-token-bg, color-mix(in srgb, var(--butex-document-panel) 86%, var(--butex-document-bg)));\n --butex-document-text-token-border: var(--butex-text-token-border, color-mix(in srgb, var(--butex-document-border) 86%, var(--butex-document-muted)));\n --butex-document-math-inline-bg: var(--butex-math-inline-bg, color-mix(in srgb, var(--butex-document-accent) 10%, var(--butex-document-panel)));\n --butex-document-math-display-bg: var(--butex-math-display-bg, color-mix(in srgb, var(--butex-document-accent) 7%, var(--butex-document-bg)));\n --butex-document-collapse-bg: var(--butex-collapse-bg, color-mix(in srgb, var(--butex-document-muted) 8%, var(--butex-document-panel)));\n --butex-document-dev-bg: var(--butex-dev-bg, #fffbeb);\n --butex-document-dev-border: var(--butex-dev-border, #fcd34d);\n --butex-document-dev-code-bg: var(--butex-dev-inset-bg, #ffffff);\n --butex-document-dev-code-fg: var(--butex-dev-inset-fg, var(--butex-document-fg));\n --butex-safe-area-top: env(safe-area-inset-top, 0px);\n --butex-safe-area-right: env(safe-area-inset-right, 0px);\n --butex-safe-area-bottom: env(safe-area-inset-bottom, 0px);\n --butex-safe-area-left: env(safe-area-inset-left, 0px);\n --butex-document-sticky-top: var(--butex-safe-area-top);\n --butex-document-z-toolbar: 20;\n --butex-document-z-popover: 30;\n --butex-document-z-overlay: 40;\n --butex-document-z-equation: 50;\n box-sizing: border-box;\n color: var(--butex-document-fg);\n container-name: butex-document;\n container-type: inline-size;\n direction: rtl;\n font-family: ui-sans-serif, system-ui, \"Segoe UI\", Tahoma, Arial, sans-serif;\n line-height: 1.45;\n max-width: 100%;\n min-width: 0;\n width: 100%;\n}\n\n.butex-document-widget *,\n.butex-document-widget *::before,\n.butex-document-widget *::after {\n box-sizing: inherit;\n}\n\n.butex-document-widget__sr-only {\n border: 0;\n clip: rect(0 0 0 0);\n clip-path: inset(50%);\n height: 1px;\n margin: -1px;\n overflow: hidden;\n padding: 0;\n position: absolute;\n white-space: nowrap;\n width: 1px;\n}\n\n.butex-document-widget__shell,\n.butex-document-widget__editor-panel,\n.butex-document-widget__blocks,\n.butex-document-widget__dev,\n.butex-document-widget__field {\n display: grid;\n gap: 10px;\n max-width: 100%;\n min-width: 0;\n}\n\n.butex-document-widget__shell,\n.butex-document-widget__layout,\n.butex-document-widget__toolbar,\n.butex-document-widget__panel,\n.butex-document-widget__block,\n.butex-document-widget__row {\n max-width: 100%;\n min-width: 0;\n}\n\n.butex-document-widget__toolbar,\n.butex-document-widget__panel,\n.butex-document-widget__block,\n.butex-document-widget__dev {\n background: var(--butex-document-panel);\n border: 1px solid var(--butex-document-border);\n border-radius: 12px;\n min-width: 0;\n padding: 12px;\n}\n\n.butex-document-widget__toolbar {\n position: sticky;\n top: var(--butex-document-sticky-top);\n z-index: var(--butex-document-z-toolbar);\n box-shadow: 0 4px 16px color-mix(in srgb, var(--butex-document-fg) 6%, transparent);\n gap: 6px;\n}\n\n.butex-document-widget__toolbar-insert {\n align-items: center;\n display: flex;\n flex: 1 1 auto;\n flex-wrap: wrap;\n gap: 6px;\n min-width: 0;\n}\n\n.butex-document-widget__mobile-toolbar {\n display: none;\n min-width: 0;\n width: 100%;\n}\n\n.butex-document-widget__mobile-toolbar-primary {\n align-items: center;\n display: flex;\n flex-wrap: nowrap;\n gap: 6px;\n min-width: 0;\n}\n\n.butex-document-widget__mobile-view {\n background: var(--butex-document-bg);\n border: 1px solid var(--butex-document-border);\n border-radius: 10px;\n display: flex;\n flex: 1 1 auto;\n min-width: 0;\n padding: 2px;\n}\n\n.butex-document-widget__mobile-view button {\n border: 0;\n flex: 1 1 50%;\n min-width: 0;\n white-space: nowrap;\n}\n\n.butex-document-widget__mobile-view button[aria-pressed=\"true\"] {\n background: var(--butex-document-panel);\n box-shadow: 0 1px 4px color-mix(in srgb, var(--butex-document-fg) 12%, transparent);\n}\n\n.butex-document-widget__mobile-toolbar-actions {\n display: flex;\n flex: 0 0 auto;\n gap: 4px;\n}\n\n.butex-document-widget__mobile-toolbar button {\n min-height: 44px;\n}\n\n.butex-document-widget__mobile-toolbar .butex-document-widget__icon-btn {\n min-width: 44px;\n}\n\n.butex-document-widget__mobile-context {\n align-items: center;\n display: flex;\n flex-wrap: nowrap;\n gap: 6px;\n max-width: 100%;\n min-width: 0;\n overflow-x: auto;\n overscroll-behavior-inline: contain;\n padding-block-start: 6px;\n scrollbar-width: thin;\n}\n\n.butex-document-widget__command-sheet-backdrop {\n align-items: flex-end;\n background: color-mix(in srgb, #000 35%, transparent);\n display: flex;\n inset: 0;\n justify-content: center;\n padding-bottom: var(--butex-safe-area-bottom);\n padding-left: max(12px, var(--butex-safe-area-left));\n padding-right: max(12px, var(--butex-safe-area-right));\n padding-top: max(12px, var(--butex-safe-area-top));\n position: fixed;\n z-index: var(--butex-document-z-popover);\n}\n\n.butex-document-widget__command-sheet {\n background: var(--butex-document-panel);\n border: 1px solid var(--butex-document-border);\n border-radius: 16px 16px 0 0;\n box-shadow: 0 -16px 40px color-mix(in srgb, #000 22%, transparent);\n display: grid;\n grid-template-rows: auto minmax(0, 1fr);\n max-height: min(78vh, 720px);\n max-height: min(720px, calc(100dvh - max(12px, var(--butex-safe-area-top)) - var(--butex-safe-area-bottom)));\n max-width: 640px;\n min-width: 0;\n overflow: hidden;\n width: 100%;\n}\n\n.butex-document-widget__command-sheet-header {\n align-items: center;\n border-block-end: 1px solid var(--butex-document-border);\n display: flex;\n gap: 8px;\n justify-content: space-between;\n min-width: 0;\n padding: 10px 12px;\n}\n\n.butex-document-widget__command-sheet-body {\n display: grid;\n gap: 12px;\n min-height: 0;\n min-width: 0;\n overflow-y: auto;\n overscroll-behavior: contain;\n padding: 12px;\n}\n\n.butex-document-widget__command-group {\n border: 1px solid var(--butex-document-border);\n border-radius: 10px;\n display: grid;\n gap: 8px;\n min-width: 0;\n padding: 10px;\n}\n\n.butex-document-widget__command-group h3 {\n font-size: 0.88rem;\n margin: 0;\n}\n\n.butex-document-widget__command-grid {\n display: grid;\n gap: 6px;\n grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));\n min-width: 0;\n}\n\n.butex-document-widget__command-grid button {\n min-height: 44px;\n overflow-wrap: anywhere;\n text-align: start;\n}\n\n.butex-document-widget__command-grid--digits button {\n text-align: center;\n}\n\n.butex-document-widget__command-grid [aria-selected=\"true\"] {\n background: var(--butex-document-accent-bg);\n border-color: var(--butex-document-accent);\n}\n\n.butex-document-widget__command-subtitle {\n color: var(--butex-document-muted);\n font-size: 0.82rem;\n font-weight: 600;\n}\n\n.butex-document-widget__mobile-table-form label {\n display: grid;\n gap: 5px;\n}\n\n.butex-document-widget__mobile-table-form input,\n.butex-document-widget__mobile-table-form button {\n min-height: 44px;\n width: 100%;\n}\n\n.butex-document-widget__sheet-back {\n justify-self: start;\n width: auto !important;\n}\n\n.butex-document-widget__toolbar-group {\n align-items: center;\n border-inline-start: 1px solid color-mix(in srgb, var(--butex-document-border) 75%, transparent);\n display: flex;\n flex-wrap: wrap;\n gap: 4px;\n padding-inline-start: 6px;\n}\n\n.butex-document-widget__toolbar-group:first-child {\n border-inline-start: 0;\n padding-inline-start: 0;\n}\n\n.butex-document-widget__icon-btn {\n align-items: center;\n background: var(--butex-document-panel);\n border: 1px solid var(--butex-document-border);\n border-radius: 8px;\n color: var(--butex-document-fg);\n cursor: pointer;\n display: inline-flex;\n font-weight: 700;\n justify-content: center;\n line-height: 1;\n min-height: 30px;\n min-width: 30px;\n padding: 0 6px;\n}\n\n.butex-document-widget__icon-btn:hover:not(:disabled),\n.butex-document-widget__icon-btn[aria-pressed=\"true\"] {\n background: var(--butex-document-accent-bg);\n border-color: var(--butex-document-accent);\n}\n\n.butex-document-widget__icon-btn:disabled {\n cursor: not-allowed;\n opacity: 0.45;\n}\n\n.butex-document-widget__icon-btn--h1 {\n font-size: 1.15rem;\n}\n\n.butex-document-widget__icon-btn--h2 {\n font-size: 1rem;\n}\n\n.butex-document-widget__icon-btn--h3 {\n font-size: 0.88rem;\n}\n\n.butex-document-widget__icon-math-inline {\n font-family: ui-monospace, Consolas, monospace;\n font-size: 0.78rem;\n font-weight: 600;\n}\n\n.butex-document-widget__icon-math-display {\n font-size: 0.82rem;\n font-weight: 700;\n}\n\n.butex-document-widget__icon-bibliography {\n display: inline-flex;\n line-height: 0;\n}\n\n.butex-document-widget__icon-bibliography svg {\n display: block;\n}\n\n.butex-document-widget__format-btn {\n font-family: \"Amiri\", \"Noto Serif Arabic\", Georgia, serif;\n min-width: 36px;\n}\n\n.butex-document-widget__format-icon {\n direction: rtl;\n display: inline-block;\n font-size: 0.84rem;\n font-weight: 500;\n}\n\n.butex-document-widget__format-icon--bold {\n font-weight: 900;\n}\n\n.butex-document-widget__format-icon--italic {\n font-style: italic;\n transform: skewX(-7deg);\n}\n\n.butex-document-widget__format-icon--underline {\n text-decoration: underline;\n text-underline-offset: 0.12em;\n}\n\n.butex-document-widget__format-underline,\n.butex-document-widget__preview-underline {\n text-decoration: underline;\n text-underline-offset: 0.12em;\n}\n\n.butex-document-widget__references-menu {\n position: relative;\n}\n\n.butex-document-widget__references-trigger {\n gap: 5px;\n white-space: nowrap;\n}\n\n.butex-document-widget__menu-chevron {\n color: var(--butex-document-muted);\n font-size: 0.8rem;\n}\n\n.butex-document-widget__references-menu-options {\n background: var(--butex-document-panel);\n border: 1px solid var(--butex-document-border);\n border-radius: 8px;\n box-shadow: 0 8px 24px color-mix(in srgb, var(--butex-document-fg) 16%, transparent);\n display: grid;\n gap: 2px;\n inset-inline-start: 0;\n margin-top: 4px;\n max-width: calc(100vw - 24px);\n max-width: calc(100cqw - 16px);\n min-width: 0;\n overflow-x: auto;\n padding: 4px;\n position: absolute;\n top: 100%;\n width: max-content;\n z-index: var(--butex-document-z-popover);\n}\n\n.butex-document-widget__references-menu-options button {\n align-items: center;\n background: transparent;\n border: 0;\n border-radius: 6px;\n color: var(--butex-document-fg);\n cursor: pointer;\n display: grid;\n font: inherit;\n gap: 8px;\n grid-template-columns: 18px 1fr;\n padding: 7px 9px;\n text-align: start;\n}\n\n.butex-document-widget__references-menu-options button:hover,\n.butex-document-widget__references-menu-options button:focus-visible {\n background: var(--butex-document-accent-bg);\n outline: none;\n}\n\n.butex-document-widget__float-meta {\n display: grid;\n gap: 8px;\n margin-top: 8px;\n}\n\n.butex-document-widget__float-meta--compact {\n gap: 4px;\n}\n\n.butex-document-widget__float-meta-toggle {\n align-items: center;\n display: inline-flex;\n gap: 6px;\n font-size: 0.9rem;\n}\n\n.butex-document-widget__preview-paragraph--centered {\n text-align: center;\n}\n\n.butex-document-widget__labels-help {\n color: color-mix(in srgb, var(--butex-document-fg) 72%, transparent);\n font-size: 0.9rem;\n margin: 0 0 10px;\n}\n\n.butex-document-widget__preview-float {\n margin: 0.75rem 0;\n max-width: 100%;\n min-width: 0;\n text-align: center;\n}\n\n.butex-document-widget__preview-float--start,\n.butex-document-widget__preview-float--start figcaption {\n text-align: start;\n}\n\n.butex-document-widget__preview-float figcaption {\n color: color-mix(in srgb, var(--butex-document-fg) 80%, transparent);\n font-size: 0.92rem;\n margin-top: 0.4rem;\n text-align: center;\n}\n\n.butex-document-widget__preview-float-number {\n font-weight: 600;\n}\n\n.butex-document-widget__preview-ref {\n font-variant-numeric: tabular-nums;\n}\n\n.butex-document-widget__ref-chip {\n border-style: dashed;\n}\n\n.butex-document-widget__block-actions {\n align-items: center;\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n}\n\n.butex-document-widget button.butex-document-widget__block-collapse {\n align-items: center;\n background: var(--butex-document-collapse-bg);\n border-color: color-mix(in srgb, var(--butex-document-border) 70%, var(--butex-document-muted));\n display: inline-flex;\n font-weight: 800;\n justify-content: center;\n min-height: 26px;\n min-width: 26px;\n padding: 0;\n}\n\n.butex-document-widget__math-chip-wrap {\n align-items: center;\n display: inline-flex;\n gap: 2px;\n}\n\n.butex-document-widget__math-chip-wrap[data-display=\"true\"] {\n flex: 1 1 100%;\n justify-content: center;\n width: 100%;\n}\n\n.butex-document-widget__math-chip-delete {\n background: transparent;\n border: 1px solid color-mix(in srgb, var(--butex-document-danger) 35%, var(--butex-document-border));\n border-radius: 6px;\n color: var(--butex-document-danger);\n cursor: pointer;\n font-size: 0.85rem;\n line-height: 1;\n min-height: 24px;\n min-width: 24px;\n padding: 0;\n}\n\n.butex-document-widget__table-cell {\n flex: 1 0 8rem;\n min-width: 8rem;\n}\n\n.butex-document-widget__table-editor-scroll,\n.butex-document-widget__preview-table-scroll {\n max-width: 100%;\n min-width: 0;\n overflow-x: auto;\n overscroll-behavior-inline: contain;\n touch-action: pan-x pan-y;\n}\n\n.butex-document-widget__table-editor-scroll > .butex-document-widget__row {\n flex-wrap: nowrap;\n min-width: max-content;\n width: 100%;\n}\n\n.butex-document-widget__block--table .butex-document-widget__inline-text {\n min-height: 3.5em;\n min-width: min(12ch, 100%);\n}\n\n.butex-document-widget__table-popover {\n display: inline-block;\n position: relative;\n}\n\n.butex-document-widget__table-popover-panel {\n background: var(--butex-document-panel);\n border: 1px solid var(--butex-document-border);\n border-radius: 10px;\n box-shadow: 0 8px 24px color-mix(in srgb, var(--butex-document-fg) 12%, transparent);\n display: grid;\n gap: 8px;\n inset-inline-end: 0;\n padding: 10px;\n position: absolute;\n top: calc(100% + 6px);\n max-width: calc(100vw - 24px);\n max-width: calc(100cqw - 16px);\n overflow: auto;\n width: min(220px, calc(100vw - 24px));\n width: min(220px, calc(100cqw - 16px));\n z-index: var(--butex-document-z-popover);\n}\n\n.butex-document-widget__table-popover-panel label {\n color: var(--butex-document-muted);\n display: grid;\n font-size: 0.82rem;\n gap: 4px;\n}\n\n.butex-document-widget__toolbar-row {\n align-items: center;\n border-block-end: 1px solid color-mix(in srgb, var(--butex-document-border) 70%, transparent);\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n margin-block-end: 8px;\n padding-block-end: 8px;\n width: 100%;\n}\n\n.butex-document-widget__toolbar-row:last-child {\n border-block-end: 0;\n margin-block-end: 0;\n padding-block-end: 0;\n}\n\n.butex-document-widget__toolbar-label {\n color: var(--butex-document-muted);\n font-size: 0.78rem;\n font-weight: 600;\n margin-inline-end: 4px;\n white-space: nowrap;\n}\n\n.butex-document-widget__block-header {\n align-items: center;\n border-block-end: 1px solid color-mix(in srgb, var(--butex-document-border) 80%, transparent);\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n justify-content: space-between;\n margin-block-end: 10px;\n padding-block-end: 8px;\n}\n\n.butex-document-widget__block-select {\n accent-color: var(--butex-document-accent);\n cursor: pointer;\n flex: 0 0 auto;\n height: 1rem;\n margin: 0;\n width: 1rem;\n}\n\n.butex-document-widget__block--selected {\n background: var(--butex-document-accent-bg);\n box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--butex-document-accent) 45%, transparent);\n}\n\n.butex-document-widget__selection-count {\n color: var(--butex-document-muted);\n font-size: 0.78rem;\n font-weight: 600;\n padding-inline: 4px;\n white-space: nowrap;\n}\n\n.butex-document-widget__block-title {\n align-items: center;\n color: var(--butex-document-fg);\n display: inline-flex;\n gap: 8px;\n font-weight: 700;\n}\n\n.butex-document-widget__block--section .butex-document-widget__block-title {\n font-size: 1.12rem;\n}\n\n.butex-document-widget__block--subsection .butex-document-widget__block-title {\n font-size: 1.04rem;\n}\n\n.butex-document-widget__block--subsubsection .butex-document-widget__block-title {\n font-size: 0.98rem;\n}\n\n.butex-document-widget__block--paragraph .butex-document-widget__block-title {\n color: var(--butex-document-muted);\n font-size: 0.86rem;\n font-weight: 600;\n}\n\n.butex-document-widget__block--list .butex-document-widget__block-title,\n.butex-document-widget__block--table .butex-document-widget__block-title,\n.butex-document-widget__block--image .butex-document-widget__block-title,\n.butex-document-widget__block--raw .butex-document-widget__block-title {\n font-size: 0.9rem;\n}\n\n.butex-document-widget__block--section {\n background: color-mix(in srgb, var(--butex-document-accent) 9%, var(--butex-document-panel));\n border-inline-start: 4px solid var(--butex-document-accent);\n}\n\n.butex-document-widget__block--subsection {\n background: color-mix(in srgb, var(--butex-document-accent) 6%, var(--butex-document-panel));\n border-inline-start: 3px solid color-mix(in srgb, var(--butex-document-accent) 78%, var(--butex-document-border));\n}\n\n.butex-document-widget__block--subsubsection {\n background: color-mix(in srgb, var(--butex-document-accent) 4%, var(--butex-document-panel));\n border-inline-start: 3px solid var(--butex-document-border);\n}\n\n.butex-document-widget__block--paragraph {\n border-inline-start: 2px solid color-mix(in srgb, var(--butex-document-muted) 35%, transparent);\n}\n\n.butex-document-widget__block--list {\n background: color-mix(in srgb, var(--butex-document-bg) 55%, var(--butex-document-panel));\n border-inline-start: 3px solid color-mix(in srgb, var(--butex-document-accent) 55%, var(--butex-document-border));\n}\n\n.butex-document-widget__block--table {\n background: color-mix(in srgb, var(--butex-document-bg) 40%, var(--butex-document-panel));\n border-inline-start: 3px solid var(--butex-document-border);\n}\n\n.butex-document-widget__block--image {\n background: color-mix(in srgb, var(--butex-document-muted) 6%, var(--butex-document-panel));\n border-inline-start: 3px dashed color-mix(in srgb, var(--butex-document-muted) 45%, var(--butex-document-border));\n}\n\n.butex-document-widget__block--raw {\n background: color-mix(in srgb, var(--butex-document-muted) 8%, var(--butex-document-panel));\n border-inline-start: 3px dashed var(--butex-document-muted);\n}\n\n.butex-document-widget__block--collapsed {\n background: var(--butex-document-collapse-bg);\n}\n\n.butex-document-widget__block--collapsed .butex-document-widget__block-header {\n margin-block-end: 8px;\n}\n\n.butex-document-widget__block-summary {\n background: color-mix(in srgb, var(--butex-document-panel) 72%, transparent);\n border: 1px dashed color-mix(in srgb, var(--butex-document-border) 70%, var(--butex-document-muted));\n border-radius: 8px;\n color: var(--butex-document-muted);\n font-size: 0.86rem;\n line-height: 1.5;\n min-width: 0;\n overflow-wrap: anywhere;\n padding: 8px 10px;\n}\n\n.butex-document-widget__list-item-actions {\n align-items: center;\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n margin-block-start: 6px;\n}\n\n.butex-document-widget__list-item-content {\n display: grid;\n gap: 8px;\n min-width: 0;\n}\n\n.butex-document-widget__list-footer {\n border-block-start: 1px dashed color-mix(in srgb, var(--butex-document-border) 85%, transparent);\n margin-block-start: 10px;\n padding-block-start: 10px;\n}\n\n.butex-document-widget__button--danger:hover {\n border-color: var(--butex-document-danger);\n color: var(--butex-document-danger);\n}\n\n.butex-document-widget__image-src-label {\n color: var(--butex-document-muted);\n display: block;\n font-size: 0.82rem;\n margin-block-end: 4px;\n}\n\n.butex-document-widget__toolbar,\n.butex-document-widget__row {\n align-items: center;\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n}\n\n.butex-document-widget button {\n background: var(--butex-document-panel);\n border: 1px solid var(--butex-document-border);\n border-radius: 8px;\n color: var(--butex-document-fg);\n cursor: pointer;\n min-height: 32px;\n padding: 0 10px;\n}\n\n.butex-document-widget button:hover,\n.butex-document-widget button[aria-pressed=\"true\"] {\n background: var(--butex-document-accent-bg);\n border-color: var(--butex-document-accent);\n}\n\n.butex-document-widget button:focus-visible,\n.butex-document-widget input:focus-visible,\n.butex-document-widget textarea:focus-visible {\n border-color: var(--butex-document-accent);\n box-shadow: 0 0 0 3px var(--butex-document-focus-shadow);\n outline: none;\n}\n\n.butex-document-widget input {\n background: var(--butex-document-input-bg);\n border: 1px solid var(--butex-document-border);\n border-radius: 8px;\n color: var(--butex-document-fg);\n font: inherit;\n max-width: 100%;\n min-height: 34px;\n min-width: 0;\n padding: 7px 9px;\n}\n\n.butex-document-widget textarea {\n background: var(--butex-document-input-bg);\n border: 1px solid var(--butex-document-border);\n border-radius: 8px;\n color: var(--butex-document-fg);\n font: inherit;\n line-height: 1.45;\n max-width: 100%;\n min-width: 0;\n padding: 7px 9px;\n}\n\n.butex-document-widget select {\n max-width: 100%;\n min-width: 0;\n}\n\n.butex-document-widget__layout {\n align-items: start;\n display: grid;\n gap: 12px;\n grid-template-columns: minmax(0, 1fr) minmax(280px, 0.9fr);\n transition: grid-template-columns 0.22s ease;\n}\n\n.butex-document-widget__layout--editor-open.butex-document-widget__layout--preview-open {\n grid-template-columns: minmax(0, 1fr) minmax(280px, 0.9fr);\n}\n\n/* One visible panel: a single track so the panel fills the widget (previewOnly / hide editor / hide preview). */\n.butex-document-widget__layout--editor-open.butex-document-widget__layout--preview-closed,\n.butex-document-widget__layout--editor-closed.butex-document-widget__layout--preview-open,\n.butex-document-widget__layout--editor-closed.butex-document-widget__layout--preview-closed {\n grid-template-columns: minmax(0, 1fr);\n}\n\n.butex-document-widget__editor-panel,\n.butex-document-widget__preview-panel {\n max-width: 100%;\n min-width: 0;\n opacity: 1;\n overflow-x: auto;\n overflow-y: auto;\n transform: translateX(0);\n transition:\n opacity 0.18s ease,\n transform 0.22s ease,\n padding 0.22s ease,\n border-width 0.22s ease,\n box-shadow 0.22s ease;\n}\n\n/* When previewOnly (or display:none) leaves a lone panel, span the full grid. */\n.butex-document-widget__editor-panel:only-child,\n.butex-document-widget__preview-panel:only-child {\n grid-column: 1 / -1;\n width: 100%;\n}\n\n.butex-document-widget__layout--editor-closed .butex-document-widget__editor-panel,\n.butex-document-widget__layout--preview-closed .butex-document-widget__preview-panel {\n display: none;\n}\n\n.butex-document-widget__inline-field {\n align-items: center;\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n max-width: 100%;\n min-width: 0;\n width: 100%;\n}\n\n.butex-document-widget__inline-text {\n background: var(--butex-document-text-token-bg);\n border-color: var(--butex-document-text-token-border);\n box-sizing: border-box;\n flex: 0 1 auto;\n max-width: 100%;\n min-height: 2.75em;\n min-width: 3ch;\n overflow-wrap: break-word;\n overflow-y: hidden;\n resize: none;\n text-align: start;\n white-space: pre-wrap;\n width: auto;\n word-break: break-word;\n}\n\n.butex-document-widget__inline-text:hover {\n border-color: color-mix(in srgb, var(--butex-document-text-token-border) 55%, var(--butex-document-accent));\n}\n\n.butex-document-widget__inline-text[data-bold=\"true\"] {\n font-weight: 700;\n}\n\n.butex-document-widget__inline-text[data-italic=\"true\"] {\n font-style: italic;\n}\n\n.butex-document-widget__inline-text[data-underline=\"true\"] {\n text-decoration: underline;\n text-underline-offset: 0.12em;\n}\n\n.butex-document-widget__inline-field input {\n min-width: 12ch;\n}\n\n.butex-document-widget__math-chip {\n background: var(--butex-document-math-inline-bg);\n border-color: color-mix(in srgb, var(--butex-document-math-border) 70%, var(--butex-document-accent));\n border-width: 1.5px;\n direction: ltr;\n display: inline-flex;\n font-family: inherit;\n gap: 4px;\n max-width: 100%;\n min-height: 30px;\n overflow-x: auto;\n overflow-y: hidden;\n overscroll-behavior-inline: contain;\n padding: 3px 7px;\n touch-action: pan-x pan-y;\n unicode-bidi: isolate;\n}\n\n.butex-document-widget__math-chip:hover,\n.butex-document-widget__math-chip:focus-visible {\n background: color-mix(in srgb, var(--butex-document-accent) 12%, var(--butex-document-panel));\n border-color: var(--butex-document-accent);\n}\n\n.butex-document-widget__math-chip[data-editable=\"false\"] {\n border-style: dashed;\n color: var(--butex-document-muted);\n}\n\n.butex-document-widget__math-chip[data-display=\"true\"] {\n background: var(--butex-document-math-display-bg);\n border-color: color-mix(in srgb, var(--butex-document-accent) 50%, var(--butex-document-border));\n border-width: 1.5px;\n border-radius: 10px;\n box-shadow: 0 5px 16px color-mix(in srgb, var(--butex-document-fg) 8%, transparent);\n justify-content: center;\n margin-block: 4px;\n min-height: 54px;\n padding: 10px 12px;\n width: min(100%, 36rem);\n}\n\n.butex-document-widget__preview {\n background: var(--butex-document-preview-bg);\n color: var(--butex-document-preview-fg);\n font-family: var(--butex-document-preview-font);\n font-size: 1.08rem;\n line-height: 1.9;\n max-width: 100%;\n min-width: 0;\n overflow-wrap: break-word;\n text-align: start;\n word-break: break-word;\n}\n\n.butex-document-widget__preview h1,\n.butex-document-widget__preview h2,\n.butex-document-widget__preview h3,\n.butex-document-widget__preview p,\n.butex-document-widget__preview li {\n max-width: 100%;\n overflow-wrap: break-word;\n white-space: normal;\n word-break: break-word;\n}\n\n.butex-document-widget__preview h1 {\n font-size: 1.75rem;\n font-weight: 700;\n line-height: 1.35;\n margin: 0 0 14px;\n}\n\n.butex-document-widget__preview h2 {\n font-size: 1.4rem;\n font-weight: 600;\n line-height: 1.4;\n margin: 0 0 12px;\n}\n\n.butex-document-widget__preview h3 {\n font-size: 1.2rem;\n font-weight: 600;\n line-height: 1.45;\n margin: 0 0 10px;\n}\n\n.butex-document-widget__preview p {\n margin: 0 0 12px;\n}\n\n.butex-document-widget__preview ul,\n.butex-document-widget__preview ol {\n margin: 0 0 12px;\n padding-inline-start: 24px;\n}\n\n.butex-document-widget__preview ul {\n list-style-type: disc;\n}\n\n.butex-document-widget__preview ol {\n list-style-type: decimal;\n}\n\n.butex-document-widget__preview img {\n display: block;\n height: auto;\n max-width: 100%;\n}\n\n.butex-document-widget__preview table {\n border-collapse: collapse;\n border: 1px solid #000000;\n margin: 12px 0;\n min-width: 100%;\n table-layout: auto;\n width: 100%;\n}\n\n.butex-document-widget__preview td {\n border: 1px solid #000000;\n max-width: 100%;\n min-width: min(7rem, 70vw);\n min-width: min(7rem, 70cqw);\n overflow-wrap: break-word;\n padding: 6px 8px;\n white-space: normal;\n word-break: break-word;\n}\n\n.butex-document-widget__math-island {\n direction: ltr;\n display: inline-block;\n line-height: normal;\n margin: 0 2px;\n max-width: 100%;\n overflow-x: auto;\n overflow-y: hidden;\n overscroll-behavior-inline: contain;\n touch-action: pan-x pan-y;\n unicode-bidi: isolate;\n vertical-align: middle;\n}\n\n/* Guard against host CSS resets (e.g. Tailwind Preflight's `svg { display: block }`).\n * MathJax v4 inline line-breaking emits an equation as several sibling <svg> chunks;\n * a block-level svg reset stacks them vertically inside the island. */\n.butex-document-widget mjx-container svg {\n display: inline;\n}\n\n.butex-document-widget__math-chip .butex-document-widget__math-island {\n margin: 0;\n overflow: visible;\n}\n\n.butex-document-widget__math-island[data-render-state=\"loading\"] {\n opacity: 0.72;\n}\n\n.butex-document-widget__math-island[data-render-state=\"error\"] {\n color: var(--butex-document-error);\n font-family: ui-monospace, SFMono-Regular, Consolas, monospace;\n font-size: 0.88rem;\n max-width: 100%;\n overflow-wrap: anywhere;\n white-space: normal;\n}\n\n.butex-document-widget__math-island[data-display=\"true\"] {\n display: block;\n margin: 10px 0;\n text-align: center;\n}\n\n.butex-document-widget__math-chip .butex-document-widget__math-island[data-display=\"true\"] {\n margin: 0;\n}\n\n.butex-document-widget__raw {\n background: var(--butex-document-raw-bg);\n border-radius: 8px;\n direction: ltr;\n padding: 8px;\n text-align: left;\n white-space: pre-wrap;\n}\n\n.butex-document-widget__error {\n background: var(--butex-document-error-bg);\n border: 1px solid var(--butex-document-error);\n border-radius: 8px;\n color: var(--butex-document-error);\n padding: 10px;\n}\n\n.butex-document-widget__equation-modal {\n align-items: center;\n display: flex;\n inset: 0;\n justify-content: center;\n padding-bottom: max(16px, var(--butex-safe-area-bottom));\n padding-left: max(16px, var(--butex-safe-area-left));\n padding-right: max(16px, var(--butex-safe-area-right));\n padding-top: max(16px, var(--butex-safe-area-top));\n position: fixed;\n overscroll-behavior: none;\n touch-action: none;\n z-index: var(--butex-document-z-equation);\n}\n\n.butex-document-widget__equation-modal[data-visible-viewport=\"true\"] {\n bottom: auto;\n height: var(--butex-document-visible-viewport-height);\n left: var(--butex-document-visible-viewport-left);\n right: auto;\n top: var(--butex-document-visible-viewport-top);\n width: var(--butex-document-visible-viewport-width);\n}\n\n.butex-document-widget__equation-modal-backdrop {\n background: color-mix(in srgb, var(--butex-document-fg) 34%, transparent);\n border: 0;\n cursor: pointer;\n display: block;\n height: 100%;\n inset: 0;\n margin: 0;\n padding: 0;\n position: absolute;\n touch-action: none;\n width: 100%;\n}\n\n.butex-document-widget__equation-modal-panel {\n background: var(--butex-document-drawer-bg);\n border: 1px solid var(--butex-document-border);\n border-radius: 12px;\n box-shadow: 0 18px 48px color-mix(in srgb, var(--butex-document-fg) 18%, transparent);\n display: grid;\n gap: 12px;\n grid-template-rows: auto minmax(0, 1fr) auto;\n max-height: min(90vh, 900px);\n max-height: min(900px, calc(100dvh - max(16px, var(--butex-safe-area-top)) - max(16px, var(--butex-safe-area-bottom))));\n max-width: min(920px, 100%);\n overflow: hidden;\n overscroll-behavior: contain;\n padding: 14px;\n position: relative;\n touch-action: pan-y;\n width: min(920px, 100%);\n z-index: 1;\n}\n\n.butex-document-widget__equation-modal-body {\n display: grid;\n gap: 12px;\n min-height: 0;\n min-width: 0;\n overflow: auto;\n overscroll-behavior: contain;\n touch-action: pan-y;\n}\n\n.butex-document-widget__equation-modal-header,\n.butex-document-widget__equation-modal-actions {\n flex-wrap: nowrap;\n}\n\n/* Map document v2 tokens onto BuTeX equation editor chrome when embedded in this modal. */\n.butex-document-widget__equation-modal-panel .butex-widget {\n --butex-bg: var(--butex-document-bg);\n --butex-fg: var(--butex-document-fg);\n --butex-muted: var(--butex-document-muted);\n --butex-accent: var(--butex-document-accent);\n --butex-accent-hover: color-mix(in srgb, var(--butex-document-accent) 82%, #000000);\n --butex-toolbar-hover-bg: var(--butex-document-accent-bg);\n --butex-toolbar-hover-border: var(--butex-document-accent);\n --butex-danger: var(--butex-document-danger);\n --butex-danger-bg: color-mix(in srgb, var(--butex-document-danger) 12%, transparent);\n --butex-danger-border: color-mix(in srgb, var(--butex-document-danger) 48%, transparent);\n --butex-on-accent: #ffffff;\n --butex-border: var(--butex-document-border);\n --butex-panel: var(--butex-document-panel);\n --butex-preview-bg: var(--butex-document-preview-bg);\n --butex-preview-fg: var(--butex-document-preview-fg);\n --butex-error: var(--butex-document-error);\n --butex-error-bg: var(--butex-document-error-bg);\n --butex-error-border: color-mix(in srgb, var(--butex-document-error) 32%, var(--butex-document-panel));\n --butex-shadow-md: 0 4px 14px color-mix(in srgb, var(--butex-document-fg) 10%, transparent);\n --butex-dev-bg: var(--butex-document-dev-bg);\n --butex-dev-border: var(--butex-document-dev-border);\n --butex-dev-badge: var(--butex-dev-badge, #b45309);\n --butex-dev-badge-fg: var(--butex-dev-badge-fg, #ffffff);\n --butex-dev-muted: var(--butex-dev-muted, #92400e);\n --butex-dev-inset-bg: var(--butex-document-dev-code-bg);\n --butex-dev-inset-border: color-mix(in srgb, var(--butex-document-dev-border) 45%, transparent);\n --butex-dev-inset-fg: var(--butex-document-dev-code-fg);\n --butex-surface-bg: linear-gradient(\n 180deg,\n var(--butex-document-panel) 0%,\n color-mix(in srgb, var(--butex-document-panel) 88%, var(--butex-document-bg)) 100%\n );\n --butex-surface-fg: var(--butex-document-fg);\n --butex-focus-border: color-mix(in srgb, var(--butex-document-accent) 45%, transparent);\n --butex-focus-shadow: var(--butex-document-focus-shadow);\n --butex-slot-hover: var(--butex-document-accent-bg);\n --butex-selection-bg: color-mix(in srgb, var(--butex-document-accent) 34%, transparent);\n --butex-selection-border: color-mix(in srgb, var(--butex-document-accent) 90%, #0f172a);\n --butex-caret: var(--butex-document-fg);\n --butex-node-hover: color-mix(in srgb, var(--butex-document-muted) 14%, transparent);\n --butex-node-selected-bg: var(--butex-document-accent-bg);\n --butex-node-selected-border: color-mix(in srgb, var(--butex-document-accent) 45%, transparent);\n --butex-script-border: var(--butex-document-border);\n --butex-script-bg: color-mix(in srgb, var(--butex-document-bg) 35%, var(--butex-document-panel));\n --butex-script-color: var(--butex-document-muted);\n --butex-delim-color: var(--butex-document-muted);\n --butex-frac-bar: currentColor;\n --butex-z-popover: var(--butex-document-z-popover);\n max-width: 100%;\n min-width: 0;\n}\n\n.butex-document-widget__dev {\n background: var(--butex-document-dev-bg);\n border-color: var(--butex-document-dev-border);\n}\n\n.butex-document-widget__image-editor {\n display: grid;\n gap: 10px;\n min-width: 0;\n}\n\n.butex-document-widget__image-asset {\n align-items: center;\n border: 1px solid var(--butex-document-border);\n border-radius: 8px;\n display: flex;\n gap: 12px;\n max-width: 100%;\n min-height: 128px;\n min-width: 0;\n padding: 12px;\n}\n\n.butex-document-widget__image-asset--empty {\n border-style: dashed;\n justify-content: center;\n}\n\n.butex-document-widget__image-empty-content,\n.butex-document-widget__image-asset-main,\n.butex-document-widget__image-select,\n.butex-document-widget__image-advanced {\n display: grid;\n gap: 8px;\n min-width: 0;\n}\n\n.butex-document-widget__image-empty-content {\n justify-items: center;\n text-align: center;\n}\n\n.butex-document-widget__image-thumb {\n aspect-ratio: 4 / 3;\n background: var(--butex-document-bg);\n border: 1px solid var(--butex-document-border);\n border-radius: 8px;\n flex: 0 0 128px;\n height: auto;\n max-width: 38%;\n object-fit: cover;\n width: 128px;\n}\n\n.butex-document-widget__image-asset-title {\n color: var(--butex-document-muted);\n display: block;\n overflow: hidden;\n text-align: start;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.butex-document-widget__image-actions {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n}\n\n.butex-document-widget__image-select span,\n.butex-document-widget__image-src-label {\n color: var(--butex-document-muted);\n font-size: 0.86rem;\n}\n\n.butex-document-widget__image-select select {\n background: var(--butex-document-input-bg);\n border: 1px solid var(--butex-document-border);\n border-radius: 8px;\n color: var(--butex-document-fg);\n max-width: 100%;\n min-height: 36px;\n padding: 6px 8px;\n}\n\n.butex-document-widget__image-select select:disabled {\n cursor: not-allowed;\n opacity: 0.55;\n}\n\n.butex-document-widget__image-advanced summary {\n color: var(--butex-document-muted);\n cursor: pointer;\n font-size: 0.86rem;\n}\n\n.butex-document-widget__dev pre {\n background: var(--butex-document-dev-code-bg);\n color: var(--butex-document-dev-code-fg);\n direction: ltr;\n margin: 0;\n max-height: 220px;\n overflow: auto;\n padding: 10px;\n text-align: left;\n white-space: pre-wrap;\n}\n\n.butex-document-widget__dev-actions {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n margin: 0 0 10px;\n}\n\n.butex-document-widget__dev-import {\n display: grid;\n gap: 8px;\n margin-bottom: 12px;\n}\n\n.butex-document-widget__dev-import textarea {\n background: var(--butex-document-dev-code-bg);\n border: 1px solid var(--butex-document-dev-border);\n border-radius: 8px;\n color: var(--butex-document-dev-code-fg);\n direction: ltr;\n font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;\n min-height: 180px;\n padding: 10px;\n resize: vertical;\n text-align: left;\n}\n\n.butex-document-widget__dev-error {\n background: rgba(254, 226, 226, 0.9);\n border: 1px solid rgba(220, 38, 38, 0.45);\n border-radius: 8px;\n color: #991b1b;\n margin: 0;\n padding: 8px 10px;\n white-space: pre-wrap;\n}\n\n.butex-document-widget__dev-diagnostic {\n background: rgba(251, 191, 36, 0.18);\n border: 1px solid rgba(217, 119, 6, 0.4);\n border-radius: 8px;\n color: #92400e;\n margin: 0;\n padding: 8px 10px;\n}\n\n.butex-document-widget[data-responsive-mode=\"compact\"] .butex-document-widget__toolbar {\n display: block;\n}\n\n.butex-document-widget[data-responsive-mode=\"compact\"] .butex-document-widget__toolbar-insert,\n.butex-document-widget[data-responsive-mode=\"compact\"] .butex-document-widget__desktop-toolbar-control {\n display: none;\n}\n\n.butex-document-widget[data-responsive-mode=\"compact\"] .butex-document-widget__mobile-toolbar {\n display: grid;\n gap: 0;\n}\n\n.butex-document-widget[data-responsive-mode=\"compact\"] .butex-document-widget__layout,\n.butex-document-widget[data-responsive-mode=\"compact\"] .butex-document-widget__layout--editor-open.butex-document-widget__layout--preview-open,\n.butex-document-widget[data-responsive-mode=\"compact\"] .butex-document-widget__layout--editor-open.butex-document-widget__layout--preview-closed,\n.butex-document-widget[data-responsive-mode=\"compact\"] .butex-document-widget__layout--editor-closed.butex-document-widget__layout--preview-open,\n.butex-document-widget[data-responsive-mode=\"compact\"] .butex-document-widget__layout--editor-closed.butex-document-widget__layout--preview-closed {\n grid-template-columns: minmax(0, 1fr);\n}\n\n.butex-document-widget[data-responsive-mode=\"compact\"][data-mobile-view=\"editor\"] .butex-document-widget__editor-panel {\n display: grid;\n}\n\n.butex-document-widget[data-responsive-mode=\"compact\"][data-mobile-view=\"editor\"] .butex-document-widget__preview-panel,\n.butex-document-widget[data-responsive-mode=\"compact\"][data-mobile-view=\"preview\"] .butex-document-widget__editor-panel {\n display: none;\n}\n\n.butex-document-widget[data-responsive-mode=\"compact\"][data-mobile-view=\"preview\"] .butex-document-widget__preview-panel {\n display: block;\n}\n\n@media (max-width: 900px) {\n .butex-document-widget:not([data-responsive-mode=\"desktop\"]) .butex-document-widget__toolbar {\n display: block;\n }\n\n .butex-document-widget:not([data-responsive-mode=\"desktop\"]) .butex-document-widget__toolbar-insert,\n .butex-document-widget:not([data-responsive-mode=\"desktop\"]) .butex-document-widget__desktop-toolbar-control {\n display: none;\n }\n\n .butex-document-widget:not([data-responsive-mode=\"desktop\"]) .butex-document-widget__mobile-toolbar {\n display: grid;\n gap: 0;\n }\n\n .butex-document-widget:not([data-responsive-mode=\"desktop\"]) .butex-document-widget__layout,\n .butex-document-widget:not([data-responsive-mode=\"desktop\"]) .butex-document-widget__layout--editor-open.butex-document-widget__layout--preview-open,\n .butex-document-widget:not([data-responsive-mode=\"desktop\"]) .butex-document-widget__layout--editor-open.butex-document-widget__layout--preview-closed,\n .butex-document-widget:not([data-responsive-mode=\"desktop\"]) .butex-document-widget__layout--editor-closed.butex-document-widget__layout--preview-open,\n .butex-document-widget:not([data-responsive-mode=\"desktop\"]) .butex-document-widget__layout--editor-closed.butex-document-widget__layout--preview-closed {\n grid-template-columns: minmax(0, 1fr);\n }\n\n .butex-document-widget:not([data-responsive-mode=\"desktop\"])[data-mobile-view=\"editor\"] .butex-document-widget__editor-panel {\n display: grid;\n }\n\n .butex-document-widget:not([data-responsive-mode=\"desktop\"])[data-mobile-view=\"editor\"] .butex-document-widget__preview-panel,\n .butex-document-widget:not([data-responsive-mode=\"desktop\"])[data-mobile-view=\"preview\"] .butex-document-widget__editor-panel {\n display: none;\n }\n\n .butex-document-widget:not([data-responsive-mode=\"desktop\"])[data-mobile-view=\"preview\"] .butex-document-widget__preview-panel {\n display: block;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .butex-document-widget__layout,\n .butex-document-widget__editor-panel,\n .butex-document-widget__preview-panel,\n .butex-document-widget__equation-modal-panel,\n .butex-document-widget__command-sheet {\n animation: none;\n scroll-behavior: auto;\n transition: none;\n }\n}\n\n.butex-document-widget__cite-chip-wrap {\n align-items: center;\n display: inline-flex;\n gap: 2px;\n margin-inline: 2px;\n max-width: 100%;\n vertical-align: baseline;\n}\n\n.butex-document-widget__cite-chip {\n background: color-mix(in srgb, var(--butex-document-accent) 8%, var(--butex-document-panel));\n border: 1.5px solid color-mix(in srgb, var(--butex-document-accent) 45%, var(--butex-document-border));\n border-radius: 6px;\n color: inherit;\n cursor: pointer;\n display: inline-flex;\n font: inherit;\n font-variant-numeric: tabular-nums;\n line-height: 1.3;\n min-height: 28px;\n padding: 2px 8px;\n}\n\n.butex-document-widget__cite-chip[data-editable=\"false\"] {\n border-style: dashed;\n cursor: default;\n}\n\n.butex-document-widget__cite-chip:hover,\n.butex-document-widget__cite-chip:focus-visible {\n background: color-mix(in srgb, var(--butex-document-accent) 14%, var(--butex-document-panel));\n border-color: var(--butex-document-accent);\n}\n\n.butex-document-widget__cite-chip-delete {\n background: transparent;\n border: none;\n color: var(--butex-document-muted);\n cursor: pointer;\n font: inherit;\n line-height: 1;\n padding: 0 4px;\n}\n\n.butex-document-widget__preview-cite {\n color: inherit;\n font-variant-numeric: tabular-nums;\n white-space: nowrap;\n}\n\n.butex-document-widget__preview-bibliography,\n.butex-document-widget__bibliography-editor {\n display: grid;\n gap: 0.5rem;\n list-style: none;\n margin: 0;\n padding: 0;\n}\n\n.butex-document-widget__preview-bibliography li,\n.butex-document-widget__bibliography-editor li {\n display: grid;\n gap: 0.25rem;\n grid-template-columns: auto 1fr;\n max-width: 100%;\n min-width: 0;\n overflow-wrap: anywhere;\n}\n\n.butex-document-widget__preview-bibliography li > *,\n.butex-document-widget__bibliography-editor li > * {\n min-width: 0;\n}\n\n.butex-document-widget__preview-bibliography a,\n.butex-document-widget__bibliography-editor a {\n overflow-wrap: anywhere;\n word-break: break-word;\n}\n\n.butex-document-widget__preview-bib-number {\n font-variant-numeric: tabular-nums;\n}\n\n.butex-document-widget__block--bibliography {\n border-color: color-mix(in srgb, var(--butex-document-accent) 35%, var(--butex-document-border));\n}\n\n.butex-document-widget__digit-form-menu {\n position: relative;\n}\n\n.butex-document-widget__digit-form-options {\n background: var(--butex-document-panel);\n border: 1px solid var(--butex-document-border);\n border-radius: 8px;\n box-shadow: 0 8px 24px color-mix(in srgb, #000 16%, transparent);\n display: grid;\n gap: 2px;\n inset-inline-start: 0;\n margin-top: 4px;\n max-width: calc(100vw - 24px);\n max-width: calc(100cqw - 16px);\n overflow-x: auto;\n padding: 4px;\n position: absolute;\n top: 100%;\n z-index: var(--butex-document-z-popover);\n}\n\n.butex-document-widget__digit-form-option {\n background: transparent;\n border: none;\n border-radius: 6px;\n color: inherit;\n cursor: pointer;\n font: inherit;\n padding: 6px 10px;\n text-align: start;\n}\n\n.butex-document-widget__digit-form-option[aria-selected=\"true\"],\n.butex-document-widget__digit-form-option:hover {\n background: color-mix(in srgb, var(--butex-document-accent) 12%, var(--butex-document-panel));\n}\n\n.butex-document-widget__cite-picker-backdrop,\n.butex-document-widget__refs-backdrop {\n align-items: center;\n background: color-mix(in srgb, #000 35%, transparent);\n display: flex;\n inset: 0;\n justify-content: center;\n padding-bottom: max(1rem, var(--butex-safe-area-bottom));\n padding-left: max(1rem, var(--butex-safe-area-left));\n padding-right: max(1rem, var(--butex-safe-area-right));\n padding-top: max(1rem, var(--butex-safe-area-top));\n position: fixed;\n z-index: var(--butex-document-z-overlay);\n}\n\n.butex-document-widget__cite-picker,\n.butex-document-widget__refs-panel {\n background: var(--butex-document-panel);\n border: 1px solid var(--butex-document-border);\n border-radius: 12px;\n box-shadow: 0 16px 40px color-mix(in srgb, #000 22%, transparent);\n display: grid;\n gap: 0.75rem;\n grid-template-rows: auto minmax(0, 1fr) auto;\n max-height: min(80vh, 640px);\n max-height: min(640px, calc(100dvh - max(1rem, var(--butex-safe-area-top)) - max(1rem, var(--butex-safe-area-bottom))));\n max-width: 560px;\n overflow: hidden;\n overscroll-behavior: contain;\n padding: 1rem;\n width: min(100%, 560px);\n}\n\n.butex-document-widget__dialog-body {\n display: grid;\n gap: 0.75rem;\n min-height: 0;\n min-width: 0;\n overflow: auto;\n overscroll-behavior: contain;\n}\n\n.butex-document-widget__cite-picker-header,\n.butex-document-widget__refs-header,\n.butex-document-widget__cite-picker-footer,\n.butex-document-widget__refs-item-head {\n align-items: center;\n display: flex;\n gap: 0.5rem;\n justify-content: space-between;\n min-width: 0;\n}\n\n.butex-document-widget__cite-picker-header,\n.butex-document-widget__refs-header {\n border-block-end: 1px solid var(--butex-document-border);\n padding-block-end: 0.65rem;\n}\n\n.butex-document-widget__cite-picker-footer {\n border-block-start: 1px solid var(--butex-document-border);\n flex-wrap: wrap;\n padding-block-start: 0.65rem;\n}\n\n.butex-document-widget__cite-picker-list,\n.butex-document-widget__refs-list {\n display: grid;\n gap: 0.5rem;\n list-style: none;\n margin: 0;\n padding: 0;\n}\n\n.butex-document-widget__cite-picker-item,\n.butex-document-widget__refs-field {\n display: grid;\n gap: 0.25rem;\n min-width: 0;\n}\n\n.butex-document-widget__cite-picker-item {\n align-items: start;\n grid-template-columns: auto 1fr;\n}\n\n.butex-document-widget__cite-picker-meta,\n.butex-document-widget__cite-picker-empty {\n color: var(--butex-document-muted);\n display: block;\n font-size: 0.92em;\n}\n\n.butex-document-widget__refs-grid {\n display: grid;\n gap: 0.5rem;\n grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));\n min-width: 0;\n}\n\n.butex-document-widget__refs-field input {\n background: var(--butex-document-input-bg, var(--butex-document-panel));\n border: 1px solid var(--butex-document-border);\n border-radius: 6px;\n color: inherit;\n font: inherit;\n padding: 0.4rem 0.55rem;\n width: 100%;\n}\n\n.butex-document-widget__field-error {\n color: #b42318;\n font-size: 0.85em;\n line-height: 1.35;\n margin: 0;\n}\n\n.butex-document-widget__field-hint {\n color: var(--butex-document-muted);\n font-size: 0.82em;\n line-height: 1.35;\n margin: 0;\n}\n\n.butex-document-widget__refs-field input[aria-invalid='true'] {\n border-color: color-mix(in srgb, #b42318 55%, var(--butex-document-border));\n}\n\n.butex-document-widget__refs-item {\n border: 1px solid var(--butex-document-border);\n border-radius: 10px;\n display: grid;\n gap: 0.5rem;\n min-width: 0;\n overflow-wrap: anywhere;\n padding: 0.75rem;\n}\n\n.butex-document-widget__refs-item-key {\n color: var(--butex-document-muted);\n font-size: 0.9em;\n font-weight: 500;\n}\n\n.butex-document-widget__modal-preview {\n background: color-mix(in srgb, var(--butex-document-panel) 88%, var(--butex-document-accent-bg));\n border: 1px dashed color-mix(in srgb, var(--butex-document-accent) 30%, var(--butex-document-border));\n border-radius: 8px;\n color: inherit;\n font-size: 0.95em;\n line-height: 1.55;\n padding: 0.55rem 0.7rem;\n text-align: center;\n}\n\n.butex-document-widget__modal-preview-number {\n color: var(--butex-document-muted);\n font-weight: 600;\n}\n\n.butex-document-widget__modal-preview-url {\n color: var(--butex-document-accent);\n word-break: break-all;\n}\n\n.butex-document-widget__refs-separator-toggle {\n display: inline-flex;\n gap: 0.35rem;\n}\n\n.butex-document-widget__refs-separator-toggle button {\n background: var(--butex-document-input-bg, var(--butex-document-panel));\n border: 1px solid var(--butex-document-border);\n border-radius: 6px;\n color: inherit;\n cursor: pointer;\n font: inherit;\n font-size: 1.15em;\n line-height: 1;\n min-width: 2.25rem;\n padding: 0.35rem 0.55rem;\n}\n\n.butex-document-widget__refs-separator-toggle button.is-active {\n background: var(--butex-document-accent-bg);\n border-color: color-mix(in srgb, var(--butex-document-accent) 45%, var(--butex-document-border));\n color: var(--butex-document-accent);\n font-weight: 700;\n}\n\n.butex-document-widget__refs-item-actions {\n display: inline-flex;\n gap: 0.25rem;\n}\n\n.butex-document-widget__primary-btn {\n background: color-mix(in srgb, var(--butex-document-accent) 82%, #000000);\n border: none;\n border-radius: 8px;\n color: #fff;\n cursor: pointer;\n font: inherit;\n padding: 0.45rem 0.8rem;\n}\n\n.butex-document-widget__primary-btn:disabled {\n cursor: not-allowed;\n opacity: 0.55;\n}\n\n.butex-document-widget__article-meta {\n background: color-mix(in srgb, var(--butex-document-panel) 92%, var(--butex-document-accent-bg));\n border: 1px solid var(--butex-document-border);\n border-radius: 10px;\n display: grid;\n gap: 0.75rem;\n margin-bottom: 0.85rem;\n padding: 0.85rem 0.9rem;\n}\n\n.butex-document-widget__article-meta-header {\n align-items: center;\n display: flex;\n gap: 0.5rem;\n justify-content: space-between;\n}\n\n.butex-document-widget__article-meta-badge {\n background: var(--butex-document-accent-bg);\n border: 1px solid color-mix(in srgb, var(--butex-document-accent) 35%, var(--butex-document-border));\n border-radius: 999px;\n color: var(--butex-document-accent);\n font-size: 0.78rem;\n font-weight: 600;\n padding: 0.15rem 0.55rem;\n}\n\n.butex-document-widget__article-meta-date-preview {\n color: color-mix(in srgb, var(--butex-document-fg) 70%, transparent);\n font-size: 0.92rem;\n margin: 0.15rem 0 0;\n}\n\n.butex-document-widget__article-meta-fixed {\n color: color-mix(in srgb, var(--butex-document-fg) 78%, transparent);\n font-size: 0.95rem;\n line-height: 1.7;\n margin: 0;\n text-align: center;\n}\n\n.butex-document-widget__article-meta-grid {\n display: grid;\n gap: 0.65rem;\n}\n\n.butex-document-widget__article-meta-field {\n display: grid;\n gap: 0.3rem;\n font-size: 0.92rem;\n}\n\n.butex-document-widget__article-meta-field input,\n.butex-document-widget__article-meta-field textarea {\n background: var(--butex-document-input-bg, var(--butex-document-panel));\n border: 1px solid var(--butex-document-border);\n border-radius: 6px;\n color: inherit;\n font: inherit;\n padding: 0.4rem 0.55rem;\n width: 100%;\n}\n\n.butex-document-widget__article-meta-date {\n display: grid;\n gap: 0.45rem;\n grid-template-columns: minmax(4rem, 1fr) minmax(7rem, 2fr) minmax(5rem, 1.2fr);\n}\n\n.butex-document-widget__hijri-menu {\n position: relative;\n}\n\n.butex-document-widget__hijri-menu-trigger {\n appearance: none;\n background-color: var(--butex-document-input-bg, var(--butex-document-panel));\n background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7280' d='M1.2 1.3L6 6.1l4.8-4.8 1.2 1.2L6 8.5 0 2.5z'/%3E%3C/svg%3E\");\n background-position: left 0.65rem center;\n background-repeat: no-repeat;\n background-size: 0.7rem;\n border: 1px solid var(--butex-document-border);\n border-radius: 8px;\n color: inherit;\n cursor: pointer;\n font: inherit;\n min-height: 2.35rem;\n padding: 0.45rem 0.7rem 0.45rem 1.7rem;\n text-align: start;\n transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;\n width: 100%;\n}\n\n.butex-document-widget[dir=\"rtl\"] .butex-document-widget__hijri-menu-trigger {\n background-position: right 0.65rem center;\n padding: 0.45rem 1.7rem 0.45rem 0.7rem;\n}\n\n.butex-document-widget__hijri-menu-trigger:hover,\n.butex-document-widget__hijri-menu-trigger[aria-expanded=\"true\"] {\n background-color: color-mix(in srgb, var(--butex-document-accent-bg) 55%, var(--butex-document-panel));\n border-color: color-mix(in srgb, var(--butex-document-accent) 45%, var(--butex-document-border));\n}\n\n.butex-document-widget__hijri-menu-trigger:focus-visible {\n border-color: var(--butex-document-accent);\n box-shadow: 0 0 0 3px color-mix(in srgb, var(--butex-document-accent) 28%, transparent);\n outline: none;\n}\n\n.butex-document-widget__hijri-menu-list {\n background: var(--butex-document-panel);\n border: 1px solid var(--butex-document-border);\n border-radius: 10px;\n box-shadow: 0 12px 28px color-mix(in srgb, #000 18%, transparent);\n inset-inline-start: 0;\n list-style: none;\n margin: 0.3rem 0 0;\n max-height: 14rem;\n overflow-x: hidden;\n overflow-y: auto;\n padding: 0.35rem;\n position: absolute;\n scrollbar-color: color-mix(in srgb, var(--butex-document-muted) 55%, transparent) transparent;\n scrollbar-width: thin;\n top: 100%;\n width: 100%;\n z-index: var(--butex-document-z-popover);\n}\n\n.butex-document-widget__hijri-menu-list::-webkit-scrollbar {\n width: 0.55rem;\n}\n\n.butex-document-widget__hijri-menu-list::-webkit-scrollbar-track {\n background: transparent;\n margin: 0.35rem 0;\n}\n\n.butex-document-widget__hijri-menu-list::-webkit-scrollbar-thumb {\n background: color-mix(in srgb, var(--butex-document-muted) 45%, transparent);\n border: 2px solid transparent;\n border-radius: 999px;\n background-clip: padding-box;\n}\n\n.butex-document-widget__hijri-menu-list::-webkit-scrollbar-thumb:hover {\n background: color-mix(in srgb, var(--butex-document-accent) 55%, var(--butex-document-muted));\n background-clip: padding-box;\n border: 2px solid transparent;\n}\n\n.butex-document-widget__hijri-menu-option {\n background: transparent;\n border: none;\n border-radius: 7px;\n color: inherit;\n cursor: pointer;\n display: block;\n font: inherit;\n padding: 0.45rem 0.65rem;\n text-align: start;\n width: 100%;\n}\n\n.butex-document-widget__hijri-menu-option:hover,\n.butex-document-widget__hijri-menu-option[aria-selected=\"true\"] {\n background: color-mix(in srgb, var(--butex-document-accent) 14%, var(--butex-document-panel));\n}\n\n.butex-document-widget__hijri-menu-option:focus-visible {\n outline: 2px solid color-mix(in srgb, var(--butex-document-accent) 55%, transparent);\n outline-offset: -2px;\n}\n\n.butex-document-widget__visually-hidden {\n border: 0;\n clip: rect(0, 0, 0, 0);\n height: 1px;\n margin: -1px;\n overflow: hidden;\n padding: 0;\n position: absolute;\n white-space: nowrap;\n width: 1px;\n}\n\n.butex-document-widget__preview-basmala,\n.butex-document-widget__preview-closing {\n margin: 0.35rem 0 0.85rem;\n}\n\n.butex-document-widget__preview-basmala .butex-document-widget__math-island[data-display=\"true\"],\n.butex-document-widget__preview-closing .butex-document-widget__math-island[data-display=\"true\"] {\n margin: 0;\n}\n\n.butex-document-widget__preview-title-block {\n background: color-mix(in srgb, var(--butex-document-accent-bg) 55%, transparent);\n border: 1px solid color-mix(in srgb, var(--butex-document-border) 75%, transparent);\n border-radius: 10px;\n margin: 0.5rem 0 1rem;\n padding: 0.85rem 1rem;\n text-align: center;\n}\n\n.butex-document-widget__preview-article-title {\n font-size: 1.45rem;\n font-weight: 700;\n line-height: 1.35;\n margin: 0 0 0.45rem;\n}\n\n.butex-document-widget__preview-article-authors,\n.butex-document-widget__preview-article-date {\n margin: 0.2rem 0;\n}\n\n.butex-document-widget__preview-article-date {\n color: color-mix(in srgb, var(--butex-document-fg) 72%, transparent);\n font-size: 0.95rem;\n}\n\n.butex-document-widget__preview-abstract {\n background: color-mix(in srgb, var(--butex-document-panel) 88%, var(--butex-document-muted));\n border: 1px dashed color-mix(in srgb, var(--butex-document-border) 85%, transparent);\n border-radius: 8px;\n margin: 0.75rem 0 1rem;\n padding: 0.75rem 0.9rem;\n}\n\n.butex-document-widget__preview-abstract-label {\n font-size: 1rem;\n font-weight: 700;\n margin: 0 0 0.35rem;\n}\n\n.butex-document-widget__preview-abstract p {\n margin: 0;\n}\n\n.butex-document-widget__preview-empty-body {\n color: var(--butex-document-muted);\n font-style: italic;\n text-align: center;\n}\n\n@media (max-width: 768px) {\n .butex-document-widget__equation-modal {\n align-items: stretch;\n padding: 0;\n }\n\n .butex-document-widget__equation-modal-panel {\n border: 0;\n border-radius: 0;\n height: 100dvh;\n margin: 0;\n max-height: 100dvh;\n max-width: none;\n padding-bottom: max(8px, var(--butex-safe-area-bottom));\n padding-left: max(8px, var(--butex-safe-area-left));\n padding-right: max(8px, var(--butex-safe-area-right));\n padding-top: max(8px, var(--butex-safe-area-top));\n width: 100%;\n }\n\n .butex-document-widget__equation-modal[data-visible-viewport=\"true\"] .butex-document-widget__equation-modal-panel {\n height: 100%;\n max-height: 100%;\n }\n\n .butex-document-widget__equation-modal-body > .butex-widget,\n .butex-document-widget__equation-modal-body > .butex-widget > .butex-widget-layout {\n min-height: 0;\n width: 100%;\n }\n}\n\n@media (max-width: 430px) {\n .butex-document-widget__shell,\n .butex-document-widget__blocks,\n .butex-document-widget__editor-panel {\n gap: 8px;\n }\n\n .butex-document-widget__toolbar,\n .butex-document-widget__panel,\n .butex-document-widget__block,\n .butex-document-widget__dev {\n border-radius: 10px;\n padding: 8px;\n }\n\n .butex-document-widget__toolbar {\n gap: 4px;\n }\n\n .butex-document-widget__mobile-toolbar button,\n .butex-document-widget__cite-picker button,\n .butex-document-widget__refs-panel button,\n .butex-document-widget__equation-modal-panel button {\n min-height: 44px;\n }\n\n .butex-document-widget__command-sheet-backdrop {\n padding-bottom: var(--butex-safe-area-bottom);\n padding-left: var(--butex-safe-area-left);\n padding-right: var(--butex-safe-area-right);\n padding-top: max(8px, var(--butex-safe-area-top));\n }\n\n .butex-document-widget__command-sheet {\n border-block-end: 0;\n border-radius: 16px 16px 0 0;\n max-height: calc(100vh - 8px);\n max-height: calc(100dvh - max(8px, var(--butex-safe-area-top)) - var(--butex-safe-area-bottom));\n max-width: none;\n }\n\n .butex-document-widget__article-meta-date,\n .butex-document-widget__refs-grid {\n grid-template-columns: minmax(0, 1fr);\n }\n\n .butex-document-widget__image-asset {\n align-items: stretch;\n flex-direction: column;\n padding: 8px;\n }\n\n .butex-document-widget__image-thumb {\n align-self: center;\n flex-basis: auto;\n max-width: 100%;\n width: min(100%, 14rem);\n }\n\n .butex-document-widget__image-asset-main,\n .butex-document-widget__image-select,\n .butex-document-widget__image-actions {\n width: 100%;\n }\n\n .butex-document-widget__image-actions button {\n flex: 1 1 8rem;\n }\n\n .butex-document-widget__image-actions button,\n .butex-document-widget__image-select select,\n .butex-document-widget__list-item-actions button,\n .butex-document-widget__block-collapse,\n .butex-document-widget__hijri-menu-trigger {\n min-height: 44px;\n }\n\n .butex-document-widget__references-menu,\n .butex-document-widget__table-popover,\n .butex-document-widget__digit-form-menu {\n position: static;\n }\n\n .butex-document-widget__references-menu-options,\n .butex-document-widget__table-popover-panel,\n .butex-document-widget__digit-form-options {\n inset-inline: 8px;\n width: auto;\n }\n\n .butex-document-widget__equation-modal {\n align-items: stretch;\n padding: 0;\n }\n\n .butex-document-widget__cite-picker-backdrop,\n .butex-document-widget__refs-backdrop {\n align-items: stretch;\n padding-bottom: max(8px, var(--butex-safe-area-bottom));\n padding-left: max(8px, var(--butex-safe-area-left));\n padding-right: max(8px, var(--butex-safe-area-right));\n padding-top: max(8px, var(--butex-safe-area-top));\n }\n\n .butex-document-widget__cite-picker-backdrop,\n .butex-document-widget__refs-backdrop {\n align-items: flex-end;\n padding-bottom: var(--butex-safe-area-bottom);\n padding-left: var(--butex-safe-area-left);\n padding-right: var(--butex-safe-area-right);\n }\n\n .butex-document-widget__equation-modal-panel {\n border: 0;\n border-radius: 0;\n gap: 8px;\n height: 100dvh;\n max-height: 100dvh;\n padding-bottom: max(8px, var(--butex-safe-area-bottom));\n padding-left: max(8px, var(--butex-safe-area-left));\n padding-right: max(8px, var(--butex-safe-area-right));\n padding-top: max(8px, var(--butex-safe-area-top));\n }\n\n .butex-document-widget__cite-picker,\n .butex-document-widget__refs-panel {\n border-block-end: 0;\n border-radius: 16px 16px 0 0;\n max-height: calc(100vh - 8px);\n max-height: calc(100dvh - max(8px, var(--butex-safe-area-top)) - var(--butex-safe-area-bottom));\n max-width: none;\n padding: 0;\n width: 100%;\n }\n\n .butex-document-widget__cite-picker-header,\n .butex-document-widget__refs-header,\n .butex-document-widget__cite-picker-footer,\n .butex-document-widget__dialog-body {\n padding: 12px;\n }\n\n .butex-document-widget__cite-picker-item {\n min-height: 44px;\n padding: 8px;\n }\n}\n";
153
752
  declare function injectBuTeXDocumentStyles(doc?: Document): void;
154
753
 
155
- export { ButexDocumentEditor, type ButexDocumentEditorProps, DOCUMENT_WIDGET_CSS, type DocumentInitialState, injectBuTeXDocumentStyles, resolveInitialDocument };
754
+ export { ButexDocumentEditor, type ButexDocumentEditorProps, type ButexDocumentEditorRef, ButexDocumentPreview, type ButexDocumentPreviewProps, type ButexResponsiveMode, type ButexUiLocale, DOCUMENT_WIDGET_CSS, type DocumentInitialState, DocumentInsertToolbar, type DocumentInsertToolbarProps, DocumentPreview, EquationDrawer, type ImageAssetRef, InlineField, MathChip, MathIsland, type ResolveDocumentImageUrl, injectBuTeXDocumentStyles, resolveInitialDocument, resolvePreviewDocument };