@drghaliasri/butex 6.1.5 → 7.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  // src/react-document/ButexDocumentEditor.tsx
2
- import { memo, useEffect as useEffect2, useLayoutEffect, useMemo, useRef as useRef2, useState as useState2 } from "react";
2
+ import { memo, useEffect as useEffect5, useLayoutEffect, useMemo, useRef as useRef4, useState as useState3 } from "react";
3
3
 
4
4
  // src/ast/commands/index.ts
5
5
  function renderCommandCore(context) {
@@ -3418,7 +3418,22 @@ var EQUATION_EDITOR_MESSAGES = {
3418
3418
  matrixBrackets: "\u0645\u0635\u0641\u0648\u0641\u0629 \u0628\u064A\u0646 \u0645\u0639\u0642\u0648\u0641\u064A\u0646",
3419
3419
  matrixBraces: "\u0645\u0635\u0641\u0648\u0641\u0629 \u0628\u064A\u0646 \u062D\u0627\u0635\u0631\u062A\u064A\u0646",
3420
3420
  matrixBars: "\u0645\u0635\u0641\u0648\u0641\u0629 \u0628\u064A\u0646 \u062E\u0637\u064A\u0646",
3421
- matrixDoubleBars: "\u0645\u0635\u0641\u0648\u0641\u0629 \u0628\u064A\u0646 \u062E\u0637\u064A\u0646 \u0645\u0632\u062F\u0648\u062C\u064A\u0646"
3421
+ matrixDoubleBars: "\u0645\u0635\u0641\u0648\u0641\u0629 \u0628\u064A\u0646 \u062E\u0637\u064A\u0646 \u0645\u0632\u062F\u0648\u062C\u064A\u0646",
3422
+ compactToolbar: "\u0634\u0631\u064A\u0637 \u0623\u0648\u0627\u0645\u0631 \u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629",
3423
+ moreActions: "\u0627\u0644\u0645\u0632\u064A\u062F",
3424
+ commandCategories: "\u0641\u0626\u0627\u062A \u0627\u0644\u0623\u0648\u0627\u0645\u0631",
3425
+ back: "\u0631\u062C\u0648\u0639",
3426
+ closeActions: "\u0625\u063A\u0644\u0627\u0642 \u0627\u0644\u0623\u0648\u0627\u0645\u0631",
3427
+ matrices: "\u0627\u0644\u0645\u0635\u0641\u0648\u0641\u0627\u062A",
3428
+ typography: "\u0627\u0644\u062E\u0637 \u0648\u0627\u0644\u0625\u062F\u062E\u0627\u0644",
3429
+ digitForms: "\u0623\u0634\u0643\u0627\u0644 \u0627\u0644\u0623\u0631\u0642\u0627\u0645",
3430
+ commonMatrixSizes: "\u0623\u062D\u062C\u0627\u0645 \u0634\u0627\u0626\u0639\u0629",
3431
+ decreaseRows: "\u062A\u0642\u0644\u064A\u0644 \u0627\u0644\u0635\u0641\u0648\u0641",
3432
+ increaseRows: "\u0632\u064A\u0627\u062F\u0629 \u0627\u0644\u0635\u0641\u0648\u0641",
3433
+ decreaseColumns: "\u062A\u0642\u0644\u064A\u0644 \u0627\u0644\u0623\u0639\u0645\u062F\u0629",
3434
+ increaseColumns: "\u0632\u064A\u0627\u062F\u0629 \u0627\u0644\u0623\u0639\u0645\u062F\u0629",
3435
+ showPreview: "\u0625\u0638\u0647\u0627\u0631 \u0627\u0644\u0645\u0639\u0627\u064A\u0646\u0629",
3436
+ hidePreview: "\u0625\u062E\u0641\u0627\u0621 \u0627\u0644\u0645\u0639\u0627\u064A\u0646\u0629"
3422
3437
  },
3423
3438
  en: {
3424
3439
  undoRedo: "Undo and redo",
@@ -3530,7 +3545,22 @@ var EQUATION_EDITOR_MESSAGES = {
3530
3545
  matrixBrackets: "Matrix in brackets",
3531
3546
  matrixBraces: "Matrix in braces",
3532
3547
  matrixBars: "Matrix between bars",
3533
- matrixDoubleBars: "Matrix between double bars"
3548
+ matrixDoubleBars: "Matrix between double bars",
3549
+ compactToolbar: "Equation command toolbar",
3550
+ moreActions: "More",
3551
+ commandCategories: "Command categories",
3552
+ back: "Back",
3553
+ closeActions: "Close actions",
3554
+ matrices: "Matrices",
3555
+ typography: "Typography and input",
3556
+ digitForms: "Digit forms",
3557
+ commonMatrixSizes: "Common sizes",
3558
+ decreaseRows: "Decrease rows",
3559
+ increaseRows: "Increase rows",
3560
+ decreaseColumns: "Decrease columns",
3561
+ increaseColumns: "Increase columns",
3562
+ showPreview: "Show preview",
3563
+ hidePreview: "Hide preview"
3534
3564
  }
3535
3565
  };
3536
3566
  function equationEditorMessages(locale) {
@@ -5841,14 +5871,20 @@ var BUTEX_EDITOR_CSS = `
5841
5871
  ${BUTEX_FONT_FACE_CSS}
5842
5872
 
5843
5873
  .surface {
5874
+ background: var(--butex-surface-bg, linear-gradient(180deg, #ffffff 0%, #fafbfc 100%));
5844
5875
  border: 1px solid var(--butex-border, #e2e8f0);
5845
5876
  border-radius: 12px;
5846
- min-height: 100px;
5847
- padding: 8px 10px;
5848
- background: var(--butex-surface-bg, linear-gradient(180deg, #ffffff 0%, #fafbfc 100%));
5849
5877
  color: var(--butex-surface-fg, #0f172a);
5850
- outline: none;
5851
5878
  cursor: text;
5879
+ max-width: 100%;
5880
+ min-height: 100px;
5881
+ min-width: 0;
5882
+ outline: none;
5883
+ overflow-x: auto;
5884
+ overflow-y: hidden;
5885
+ overscroll-behavior-inline: contain;
5886
+ padding: 8px 10px;
5887
+ touch-action: pan-x pan-y;
5852
5888
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
5853
5889
  }
5854
5890
 
@@ -5913,6 +5949,17 @@ ${CHARACTER_FONT_CSS}
5913
5949
  50% { opacity: 0; }
5914
5950
  }
5915
5951
 
5952
+ @media (prefers-reduced-motion: reduce) {
5953
+ .surface {
5954
+ scroll-behavior: auto;
5955
+ transition: none;
5956
+ }
5957
+
5958
+ .caret {
5959
+ animation: none;
5960
+ }
5961
+ }
5962
+
5916
5963
  .node {
5917
5964
  display: inline-flex;
5918
5965
  align-items: stretch;
@@ -6044,6 +6091,42 @@ function injectBuTeXEditorStyles(doc) {
6044
6091
  }
6045
6092
 
6046
6093
  // src/editor/runtime.ts
6094
+ var CARET_REVEAL_GUTTER_PX = 8;
6095
+ function revealCaretInSurface(surfaceEl, caretEl) {
6096
+ const activeTarget = caretEl ?? surfaceEl.querySelector(".caret") ?? surfaceEl.querySelector(".node.selected");
6097
+ if (!activeTarget) {
6098
+ return;
6099
+ }
6100
+ const surfaceRect = surfaceEl.getBoundingClientRect();
6101
+ const targetRect = activeTarget.getBoundingClientRect();
6102
+ if (surfaceRect.width <= 0) {
6103
+ return;
6104
+ }
6105
+ const gutter = Math.min(CARET_REVEAL_GUTTER_PX, surfaceRect.width / 4);
6106
+ const visibleLeft = surfaceRect.left + gutter;
6107
+ const visibleRight = surfaceRect.right - gutter;
6108
+ const visibleWidth = visibleRight - visibleLeft;
6109
+ let delta = 0;
6110
+ if (targetRect.width > visibleWidth) {
6111
+ if (targetRect.right < visibleLeft) {
6112
+ delta = targetRect.right - visibleLeft;
6113
+ } else if (targetRect.left > visibleRight) {
6114
+ delta = targetRect.left - visibleRight;
6115
+ }
6116
+ } else if (targetRect.left < visibleLeft) {
6117
+ delta = targetRect.left - visibleLeft;
6118
+ } else if (targetRect.right > visibleRight) {
6119
+ delta = targetRect.right - visibleRight;
6120
+ }
6121
+ if (delta === 0) {
6122
+ return;
6123
+ }
6124
+ if (typeof surfaceEl.scrollBy === "function") {
6125
+ surfaceEl.scrollBy({ left: delta, behavior: "auto" });
6126
+ } else {
6127
+ surfaceEl.scrollLeft += delta;
6128
+ }
6129
+ }
6047
6130
  function createEditorRuntime(options) {
6048
6131
  const { surfaceEl, inputEl } = options;
6049
6132
  const buttonElements = options.buttonElements ?? {};
@@ -6061,6 +6144,16 @@ function createEditorRuntime(options) {
6061
6144
  let dragChanged = false;
6062
6145
  let composingInput = false;
6063
6146
  let pendingCompositionText = null;
6147
+ let caretRevealFrame = null;
6148
+ function scheduleCaretReveal() {
6149
+ if (caretRevealFrame !== null) {
6150
+ cancelAnimationFrame(caretRevealFrame);
6151
+ }
6152
+ caretRevealFrame = requestAnimationFrame(() => {
6153
+ caretRevealFrame = null;
6154
+ revealCaretInSurface(surfaceEl);
6155
+ });
6156
+ }
6064
6157
  function resetInputElement() {
6065
6158
  if (!inputEl) {
6066
6159
  return;
@@ -6427,6 +6520,7 @@ function createEditorRuntime(options) {
6427
6520
  surfaceEl.innerHTML = "";
6428
6521
  const activeTree = session[activeTreeKey(session.activeSide)];
6429
6522
  surfaceEl.appendChild(buildChain(activeTree));
6523
+ scheduleCaretReveal();
6430
6524
  if (initialKeyboardFocusPending) {
6431
6525
  requestAnimationFrame(focusInput);
6432
6526
  initialKeyboardFocusPending = false;
@@ -6742,6 +6836,10 @@ function createEditorRuntime(options) {
6742
6836
  const api = {
6743
6837
  render,
6744
6838
  destroy: () => {
6839
+ if (caretRevealFrame !== null) {
6840
+ cancelAnimationFrame(caretRevealFrame);
6841
+ caretRevealFrame = null;
6842
+ }
6745
6843
  surfaceEl.removeEventListener("keydown", onKeyDown);
6746
6844
  inputEl?.removeEventListener("keydown", onKeyDown);
6747
6845
  inputEl?.removeEventListener("beforeinput", onBeforeInput);
@@ -8368,12 +8466,217 @@ async function mountBuTeXMathIsland(host, tex, options = {}) {
8368
8466
  import {
8369
8467
  forwardRef,
8370
8468
  useCallback,
8371
- useEffect,
8469
+ useEffect as useEffect4,
8470
+ useId as useId2,
8372
8471
  useImperativeHandle,
8373
- useRef,
8374
- useState
8472
+ useRef as useRef3,
8473
+ useState as useState2
8375
8474
  } from "react";
8376
8475
 
8476
+ // src/react/matrixPickerCss.ts
8477
+ var MATRIX_PICKER_CSS = `
8478
+ .butex-widget .matrix-grid-picker,
8479
+ .butex-widget .matrix-grid-cell {
8480
+ box-sizing: border-box;
8481
+ }
8482
+
8483
+ .butex-widget .matrix-command-menu {
8484
+ position: relative;
8485
+ display: inline-flex;
8486
+ }
8487
+
8488
+ .butex-widget .matrix-command-btn::after {
8489
+ content: "";
8490
+ width: 0;
8491
+ height: 0;
8492
+ margin-inline-start: 3px;
8493
+ border-inline: 3px solid transparent;
8494
+ border-block-start: 4px solid currentColor;
8495
+ opacity: 0.72;
8496
+ }
8497
+
8498
+ .butex-widget .toolbar-matrix-icon {
8499
+ width: 14px;
8500
+ height: 14px;
8501
+ display: grid;
8502
+ grid-template-columns: repeat(2, 1fr);
8503
+ gap: 2px;
8504
+ }
8505
+
8506
+ .butex-widget .toolbar-matrix-icon span {
8507
+ border: 1px solid currentColor;
8508
+ border-radius: 2px;
8509
+ }
8510
+
8511
+ .butex-widget .matrix-command-popover {
8512
+ position: absolute;
8513
+ z-index: var(--butex-z-popover);
8514
+ top: calc(100% + 5px);
8515
+ right: 0;
8516
+ width: 252px;
8517
+ padding: 8px;
8518
+ border: 1px solid var(--butex-border);
8519
+ border-radius: 9px;
8520
+ background: var(--butex-panel);
8521
+ color: var(--butex-fg);
8522
+ box-shadow: var(--butex-shadow-md);
8523
+ }
8524
+
8525
+ .butex-widget .matrix-command-popover[hidden] {
8526
+ display: none;
8527
+ }
8528
+
8529
+ .butex-widget .matrix-style-options,
8530
+ .butex-widget .matrix-edit-actions,
8531
+ .butex-widget .matrix-custom-size {
8532
+ display: flex;
8533
+ gap: 5px;
8534
+ align-items: center;
8535
+ flex-wrap: wrap;
8536
+ }
8537
+
8538
+ .butex-widget .toolbar .matrix-style-option,
8539
+ .butex-widget .toolbar .matrix-edit-actions button,
8540
+ .butex-widget .toolbar .matrix-insert-custom {
8541
+ height: 26px;
8542
+ min-width: 30px;
8543
+ padding: 0 6px;
8544
+ border-radius: 7px;
8545
+ }
8546
+
8547
+ .butex-widget .toolbar .matrix-style-option[aria-selected="true"] {
8548
+ border-color: var(--butex-toolbar-hover-border);
8549
+ background: var(--butex-toolbar-hover-bg);
8550
+ }
8551
+
8552
+ .butex-widget .matrix-size-readout {
8553
+ margin: 7px 0 5px;
8554
+ font-size: 12px;
8555
+ color: var(--butex-muted);
8556
+ text-align: center;
8557
+ direction: ltr;
8558
+ }
8559
+
8560
+ .butex-widget .matrix-grid-picker {
8561
+ display: grid;
8562
+ grid-template-columns: repeat(8, 16px);
8563
+ grid-auto-rows: 16px;
8564
+ gap: 3px;
8565
+ justify-content: center;
8566
+ margin-bottom: 7px;
8567
+ }
8568
+
8569
+ .butex-widget .toolbar .matrix-grid-cell {
8570
+ width: 16px;
8571
+ height: 16px;
8572
+ min-width: 0;
8573
+ padding: 0;
8574
+ border-radius: 3px;
8575
+ border-color: var(--butex-border);
8576
+ }
8577
+
8578
+ .butex-widget .toolbar .matrix-grid-cell.active {
8579
+ border-color: var(--butex-toolbar-hover-border);
8580
+ background: var(--butex-toolbar-hover-bg);
8581
+ }
8582
+
8583
+ .butex-widget .matrix-custom-size {
8584
+ justify-content: center;
8585
+ margin-bottom: 7px;
8586
+ }
8587
+
8588
+ .butex-widget .matrix-custom-size label {
8589
+ display: inline-flex;
8590
+ align-items: center;
8591
+ gap: 3px;
8592
+ font-size: 11px;
8593
+ color: var(--butex-muted);
8594
+ }
8595
+
8596
+ .butex-widget .matrix-custom-size input {
8597
+ width: 42px;
8598
+ height: 24px;
8599
+ border: 1px solid var(--butex-border);
8600
+ border-radius: 6px;
8601
+ padding: 0 4px;
8602
+ direction: ltr;
8603
+ }
8604
+
8605
+ .butex-widget .matrix-edit-actions {
8606
+ justify-content: center;
8607
+ border-top: 1px solid var(--butex-border);
8608
+ padding-top: 7px;
8609
+ }
8610
+
8611
+ .butex-widget .butex-widget__mobile-matrix-picker {
8612
+ display: grid;
8613
+ gap: 14px;
8614
+ min-width: 0;
8615
+ }
8616
+
8617
+ .butex-widget .butex-widget__matrix-presets {
8618
+ display: grid;
8619
+ gap: 8px;
8620
+ grid-template-columns: repeat(4, minmax(44px, 1fr));
8621
+ }
8622
+
8623
+ .butex-widget .butex-widget__matrix-stepper-row {
8624
+ align-items: center;
8625
+ display: flex;
8626
+ gap: 12px;
8627
+ justify-content: space-between;
8628
+ }
8629
+
8630
+ .butex-widget .butex-widget__matrix-stepper {
8631
+ align-items: center;
8632
+ direction: ltr;
8633
+ display: grid;
8634
+ gap: 8px;
8635
+ grid-template-columns: 44px minmax(42px, auto) 44px;
8636
+ }
8637
+
8638
+ .butex-widget .butex-widget__matrix-stepper output {
8639
+ font-variant-numeric: tabular-nums;
8640
+ font-weight: 700;
8641
+ text-align: center;
8642
+ }
8643
+
8644
+ .butex-widget .butex-widget__matrix-size-summary {
8645
+ color: var(--butex-muted);
8646
+ direction: ltr;
8647
+ margin: 0;
8648
+ text-align: center;
8649
+ }
8650
+
8651
+ .butex-widget .butex-widget__matrix-insert {
8652
+ background: var(--butex-accent-hover);
8653
+ border-color: var(--butex-accent-hover);
8654
+ color: var(--butex-on-accent);
8655
+ width: 100%;
8656
+ }
8657
+
8658
+ .butex-widget .butex-widget__matrix-alignment {
8659
+ align-items: center;
8660
+ display: flex;
8661
+ flex-wrap: wrap;
8662
+ gap: 8px;
8663
+ }
8664
+
8665
+ .butex-widget .butex-widget__matrix-alignment label {
8666
+ align-items: center;
8667
+ display: inline-flex;
8668
+ gap: 6px;
8669
+ }
8670
+
8671
+ .butex-widget .butex-widget__matrix-alignment input {
8672
+ border: 1px solid var(--butex-border);
8673
+ border-radius: 8px;
8674
+ min-height: 44px;
8675
+ padding-inline: 8px;
8676
+ width: 70px;
8677
+ }
8678
+ `.trim();
8679
+
8377
8680
  // src/react/widgetChromeCss.ts
8378
8681
  var WIDGET_CHROME_CSS = `
8379
8682
  .butex-widget {
@@ -8420,9 +8723,22 @@ var WIDGET_CHROME_CSS = `
8420
8723
  --butex-script-color: #475569;
8421
8724
  --butex-delim-color: #475569;
8422
8725
  --butex-frac-bar: currentColor;
8726
+ --butex-z-popover: 10;
8727
+ box-sizing: border-box;
8423
8728
  font-family: ui-sans-serif, system-ui, "Segoe UI", Tahoma, Arial, sans-serif;
8424
8729
  color: var(--butex-fg);
8730
+ container-name: butex-equation;
8731
+ container-type: inline-size;
8425
8732
  line-height: 1.45;
8733
+ max-width: 100%;
8734
+ min-width: 0;
8735
+ width: 100%;
8736
+ }
8737
+
8738
+ .butex-widget *,
8739
+ .butex-widget *::before,
8740
+ .butex-widget *::after {
8741
+ box-sizing: inherit;
8426
8742
  }
8427
8743
 
8428
8744
  .butex-widget .butex-widget-layout {
@@ -8431,12 +8747,16 @@ var WIDGET_CHROME_CSS = `
8431
8747
  gap: 8px;
8432
8748
  max-width: 920px;
8433
8749
  margin: 0 auto;
8750
+ min-width: 0;
8751
+ width: 100%;
8434
8752
  }
8435
8753
 
8436
8754
  .butex-widget .panel {
8437
8755
  background: var(--butex-panel);
8438
8756
  border: 1px solid var(--butex-border);
8439
8757
  border-radius: 14px;
8758
+ max-width: 100%;
8759
+ min-width: 0;
8440
8760
  padding: 12px 14px;
8441
8761
  box-shadow: var(--butex-shadow-md);
8442
8762
  }
@@ -8469,34 +8789,204 @@ var WIDGET_CHROME_CSS = `
8469
8789
  margin-bottom: 8px;
8470
8790
  align-items: center;
8471
8791
  align-content: flex-start;
8792
+ min-width: 0;
8793
+ position: relative;
8472
8794
  }
8473
8795
 
8474
- .butex-widget .toolbar button {
8796
+ .butex-widget .butex-widget__mobile-toolbar,
8797
+ .butex-widget .butex-widget__mobile-preview-toggle,
8798
+ .butex-widget .butex-widget__command-sheet-backdrop {
8799
+ display: none;
8800
+ }
8801
+
8802
+ .butex-widget .butex-widget__mobile-toolbar {
8803
+ background: var(--butex-panel);
8804
+ gap: 4px;
8805
+ grid-template-columns: repeat(8, minmax(44px, 1fr));
8806
+ margin-bottom: 8px;
8807
+ min-width: 0;
8808
+ position: sticky;
8809
+ top: 0;
8810
+ z-index: 1;
8811
+ }
8812
+
8813
+ .butex-widget .butex-widget__mobile-toolbar button,
8814
+ .butex-widget .butex-widget__mobile-preview-toggle,
8815
+ .butex-widget .butex-widget__command-sheet button {
8816
+ align-items: center;
8817
+ background: var(--butex-panel);
8475
8818
  border: 1px solid var(--butex-border);
8476
8819
  border-radius: 9px;
8477
- background: var(--butex-panel);
8478
8820
  color: var(--butex-fg);
8479
- min-width: 30px;
8480
- height: 30px;
8481
- padding: 0 7px;
8482
- font-size: 12px;
8483
- font-weight: 600;
8484
8821
  cursor: pointer;
8485
8822
  display: inline-flex;
8486
- align-items: center;
8823
+ font: inherit;
8824
+ font-size: 13px;
8825
+ font-weight: 600;
8487
8826
  justify-content: center;
8488
- line-height: 1;
8489
- transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease, color 0.14s ease;
8827
+ min-height: 44px;
8828
+ min-width: 44px;
8829
+ padding: 6px 9px;
8490
8830
  }
8491
8831
 
8492
- .butex-widget .toolbar button:hover {
8493
- border-color: var(--butex-toolbar-hover-border);
8494
- background: var(--butex-toolbar-hover-bg);
8495
- transform: translateY(-1px);
8832
+ .butex-widget .butex-widget__mobile-preview-toggle {
8833
+ display: none;
8496
8834
  }
8497
8835
 
8498
- .butex-widget .toolbar button:disabled {
8499
- opacity: 0.42;
8836
+ .butex-widget .butex-widget__mobile-toolbar button:disabled,
8837
+ .butex-widget .butex-widget__command-sheet button:disabled {
8838
+ cursor: not-allowed;
8839
+ opacity: 0.42;
8840
+ }
8841
+
8842
+ .butex-widget .butex-widget__mobile-toolbar button:focus-visible,
8843
+ .butex-widget .butex-widget__mobile-preview-toggle:focus-visible,
8844
+ .butex-widget .butex-widget__command-sheet button:focus-visible {
8845
+ border-color: var(--butex-accent);
8846
+ box-shadow: 0 0 0 3px var(--butex-focus-shadow);
8847
+ outline: none;
8848
+ }
8849
+
8850
+ .butex-widget .butex-widget__mobile-toolbar button[aria-expanded="true"],
8851
+ .butex-widget .butex-widget__mobile-preview-toggle[aria-expanded="true"],
8852
+ .butex-widget .butex-widget__command-sheet button[aria-pressed="true"],
8853
+ .butex-widget .butex-widget__command-sheet button[aria-selected="true"] {
8854
+ background: var(--butex-toolbar-hover-bg);
8855
+ border-color: var(--butex-toolbar-hover-border);
8856
+ box-shadow: 0 0 0 2px var(--butex-focus-shadow);
8857
+ }
8858
+
8859
+ .butex-widget .butex-widget__mobile-danger {
8860
+ color: var(--butex-danger);
8861
+ }
8862
+
8863
+ .butex-widget .butex-widget__mobile-preview-toggle {
8864
+ align-self: flex-start;
8865
+ margin-top: 8px;
8866
+ }
8867
+
8868
+ .butex-widget .butex-widget__command-sheet-backdrop {
8869
+ align-items: flex-end;
8870
+ background: rgba(15, 23, 42, 0.38);
8871
+ inset: 0;
8872
+ justify-content: center;
8873
+ padding-bottom: var(--butex-safe-area-bottom, env(safe-area-inset-bottom, 0px));
8874
+ padding-left: max(12px, var(--butex-safe-area-left, env(safe-area-inset-left, 0px)));
8875
+ padding-right: max(12px, var(--butex-safe-area-right, env(safe-area-inset-right, 0px)));
8876
+ padding-top: max(12px, var(--butex-safe-area-top, env(safe-area-inset-top, 0px)));
8877
+ position: fixed;
8878
+ z-index: var(--butex-z-popover);
8879
+ }
8880
+
8881
+ .butex-widget .butex-widget__command-sheet {
8882
+ background: var(--butex-panel);
8883
+ border: 1px solid var(--butex-border);
8884
+ border-radius: 16px 16px 0 0;
8885
+ box-shadow: 0 -18px 48px rgba(15, 23, 42, 0.22);
8886
+ display: grid;
8887
+ grid-template-rows: auto minmax(0, 1fr);
8888
+ max-height: min(78vh, 720px);
8889
+ max-height: min(720px, calc(100dvh - max(12px, var(--butex-safe-area-top, env(safe-area-inset-top, 0px))) - var(--butex-safe-area-bottom, env(safe-area-inset-bottom, 0px))));
8890
+ max-width: 640px;
8891
+ min-width: 0;
8892
+ overflow: hidden;
8893
+ width: 100%;
8894
+ }
8895
+
8896
+ .butex-widget .butex-widget__command-sheet-header {
8897
+ align-items: center;
8898
+ border-bottom: 1px solid var(--butex-border);
8899
+ display: grid;
8900
+ gap: 8px;
8901
+ grid-template-columns: minmax(44px, auto) minmax(0, 1fr) minmax(44px, auto);
8902
+ padding: 10px 12px;
8903
+ text-align: center;
8904
+ }
8905
+
8906
+ .butex-widget .butex-widget__command-sheet-header strong {
8907
+ overflow-wrap: anywhere;
8908
+ }
8909
+
8910
+ .butex-widget .butex-widget__command-sheet-body {
8911
+ display: grid;
8912
+ gap: 14px;
8913
+ min-height: 0;
8914
+ min-width: 0;
8915
+ overflow-y: auto;
8916
+ overscroll-behavior: contain;
8917
+ padding: 12px;
8918
+ }
8919
+
8920
+ .butex-widget .butex-widget__sheet-section {
8921
+ display: grid;
8922
+ gap: 8px;
8923
+ min-width: 0;
8924
+ }
8925
+
8926
+ .butex-widget .butex-widget__sheet-section h4 {
8927
+ font-size: 13px;
8928
+ margin: 0;
8929
+ }
8930
+
8931
+ .butex-widget .butex-widget__sheet-categories,
8932
+ .butex-widget .butex-widget__sheet-command-grid,
8933
+ .butex-widget .butex-widget__sheet-command-list,
8934
+ .butex-widget .butex-widget__sheet-choice-row {
8935
+ display: grid;
8936
+ gap: 8px;
8937
+ min-width: 0;
8938
+ }
8939
+
8940
+ .butex-widget .butex-widget__sheet-categories,
8941
+ .butex-widget .butex-widget__sheet-command-grid {
8942
+ grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
8943
+ }
8944
+
8945
+ .butex-widget .butex-widget__sheet-command-grid--three,
8946
+ .butex-widget .butex-widget__sheet-choice-row {
8947
+ grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
8948
+ }
8949
+
8950
+ .butex-widget .butex-widget__sheet-categories button,
8951
+ .butex-widget .butex-widget__sheet-command-list button {
8952
+ justify-content: flex-start;
8953
+ overflow-wrap: anywhere;
8954
+ text-align: start;
8955
+ }
8956
+
8957
+ .butex-widget .butex-widget__command-sheet .operator-command-svg-label {
8958
+ background-color: currentColor;
8959
+ display: inline-block;
8960
+ height: 22px;
8961
+ width: 22px;
8962
+ }
8963
+
8964
+ .butex-widget .toolbar button {
8965
+ border: 1px solid var(--butex-border);
8966
+ border-radius: 9px;
8967
+ background: var(--butex-panel);
8968
+ color: var(--butex-fg);
8969
+ min-width: 30px;
8970
+ height: 30px;
8971
+ padding: 0 7px;
8972
+ font-size: 12px;
8973
+ font-weight: 600;
8974
+ cursor: pointer;
8975
+ display: inline-flex;
8976
+ align-items: center;
8977
+ justify-content: center;
8978
+ line-height: 1;
8979
+ transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease, color 0.14s ease;
8980
+ }
8981
+
8982
+ .butex-widget .toolbar button:hover {
8983
+ border-color: var(--butex-toolbar-hover-border);
8984
+ background: var(--butex-toolbar-hover-bg);
8985
+ transform: translateY(-1px);
8986
+ }
8987
+
8988
+ .butex-widget .toolbar button:disabled {
8989
+ opacity: 0.42;
8500
8990
  cursor: not-allowed;
8501
8991
  pointer-events: none;
8502
8992
  }
@@ -8536,7 +9026,7 @@ var WIDGET_CHROME_CSS = `
8536
9026
 
8537
9027
  .butex-widget .delimiter-command-options {
8538
9028
  position: absolute;
8539
- z-index: 10;
9029
+ z-index: var(--butex-z-popover);
8540
9030
  top: calc(100% + 5px);
8541
9031
  right: 0;
8542
9032
  left: auto;
@@ -8615,133 +9105,7 @@ var WIDGET_CHROME_CSS = `
8615
9105
  opacity: 0.85;
8616
9106
  }
8617
9107
 
8618
- .butex-widget .matrix-command-menu {
8619
- position: relative;
8620
- display: inline-flex;
8621
- }
8622
-
8623
- .butex-widget .matrix-command-btn::after {
8624
- content: "";
8625
- width: 0;
8626
- height: 0;
8627
- margin-inline-start: 3px;
8628
- border-inline: 3px solid transparent;
8629
- border-block-start: 4px solid currentColor;
8630
- opacity: 0.72;
8631
- }
8632
-
8633
- .butex-widget .toolbar-matrix-icon {
8634
- width: 14px;
8635
- height: 14px;
8636
- display: grid;
8637
- grid-template-columns: repeat(2, 1fr);
8638
- gap: 2px;
8639
- }
8640
-
8641
- .butex-widget .toolbar-matrix-icon span {
8642
- border: 1px solid currentColor;
8643
- border-radius: 2px;
8644
- }
8645
-
8646
- .butex-widget .matrix-command-popover {
8647
- position: absolute;
8648
- z-index: 12;
8649
- top: calc(100% + 5px);
8650
- right: 0;
8651
- width: 252px;
8652
- padding: 8px;
8653
- border: 1px solid var(--butex-border);
8654
- border-radius: 9px;
8655
- background: var(--butex-panel);
8656
- color: var(--butex-fg);
8657
- box-shadow: var(--butex-shadow-md);
8658
- }
8659
-
8660
- .butex-widget .matrix-command-popover[hidden] {
8661
- display: none;
8662
- }
8663
-
8664
- .butex-widget .matrix-style-options,
8665
- .butex-widget .matrix-edit-actions,
8666
- .butex-widget .matrix-custom-size {
8667
- display: flex;
8668
- gap: 5px;
8669
- align-items: center;
8670
- flex-wrap: wrap;
8671
- }
8672
-
8673
- .butex-widget .toolbar .matrix-style-option,
8674
- .butex-widget .toolbar .matrix-edit-actions button,
8675
- .butex-widget .toolbar .matrix-insert-custom {
8676
- height: 26px;
8677
- min-width: 30px;
8678
- padding: 0 6px;
8679
- border-radius: 7px;
8680
- }
8681
-
8682
- .butex-widget .toolbar .matrix-style-option[aria-selected="true"] {
8683
- border-color: var(--butex-toolbar-hover-border);
8684
- background: var(--butex-toolbar-hover-bg);
8685
- }
8686
-
8687
- .butex-widget .matrix-size-readout {
8688
- margin: 7px 0 5px;
8689
- font-size: 12px;
8690
- color: var(--butex-muted);
8691
- text-align: center;
8692
- direction: ltr;
8693
- }
8694
-
8695
- .butex-widget .matrix-grid-picker {
8696
- display: grid;
8697
- grid-template-columns: repeat(8, 16px);
8698
- grid-auto-rows: 16px;
8699
- gap: 3px;
8700
- justify-content: center;
8701
- margin-bottom: 7px;
8702
- }
8703
-
8704
- .butex-widget .toolbar .matrix-grid-cell {
8705
- width: 16px;
8706
- height: 16px;
8707
- min-width: 0;
8708
- padding: 0;
8709
- border-radius: 3px;
8710
- border-color: var(--butex-border);
8711
- }
8712
-
8713
- .butex-widget .toolbar .matrix-grid-cell.active {
8714
- border-color: var(--butex-toolbar-hover-border);
8715
- background: var(--butex-toolbar-hover-bg);
8716
- }
8717
-
8718
- .butex-widget .matrix-custom-size {
8719
- justify-content: center;
8720
- margin-bottom: 7px;
8721
- }
8722
-
8723
- .butex-widget .matrix-custom-size label {
8724
- display: inline-flex;
8725
- align-items: center;
8726
- gap: 3px;
8727
- font-size: 11px;
8728
- color: var(--butex-muted);
8729
- }
8730
-
8731
- .butex-widget .matrix-custom-size input {
8732
- width: 42px;
8733
- height: 24px;
8734
- border: 1px solid var(--butex-border);
8735
- border-radius: 6px;
8736
- padding: 0 4px;
8737
- direction: ltr;
8738
- }
8739
-
8740
- .butex-widget .matrix-edit-actions {
8741
- justify-content: center;
8742
- border-top: 1px solid var(--butex-border);
8743
- padding-top: 7px;
8744
- }
9108
+ ${MATRIX_PICKER_CSS}
8745
9109
 
8746
9110
  .butex-widget .script-icon-btn {
8747
9111
  min-width: 32px;
@@ -8777,28 +9141,32 @@ var WIDGET_CHROME_CSS = `
8777
9141
  }
8778
9142
 
8779
9143
  .butex-widget .font-mode-btn--takween,
8780
- .butex-widget .character-font-option--takween {
9144
+ .butex-widget .character-font-option--takween,
9145
+ .butex-widget .butex-widget__command-sheet .character-font-option--takween {
8781
9146
  font-family: ${BUTEX_TAKWEEN_FONT_STACK};
8782
9147
  }
8783
9148
 
8784
9149
  .butex-widget .font-mode-btn--diwani,
8785
- .butex-widget .character-font-option--diwani {
9150
+ .butex-widget .character-font-option--diwani,
9151
+ .butex-widget .butex-widget__command-sheet .character-font-option--diwani {
8786
9152
  font-family: ${BUTEX_DIWANI_FONT_STACK};
8787
9153
  }
8788
9154
 
8789
9155
  .butex-widget .font-mode-btn--diwaniOutline,
8790
- .butex-widget .character-font-option--diwaniOutline {
9156
+ .butex-widget .character-font-option--diwaniOutline,
9157
+ .butex-widget .butex-widget__command-sheet .character-font-option--diwaniOutline {
8791
9158
  font-family: ${BUTEX_DIWANI_OUTLINE_FONT_STACK};
8792
9159
  }
8793
9160
 
8794
9161
  .butex-widget .font-mode-btn--maghribi,
8795
- .butex-widget .character-font-option--maghribi {
9162
+ .butex-widget .character-font-option--maghribi,
9163
+ .butex-widget .butex-widget__command-sheet .character-font-option--maghribi {
8796
9164
  font-family: ${BUTEX_MAGHRIBI_FONT_STACK};
8797
9165
  }
8798
9166
 
8799
9167
  .butex-widget .character-font-options {
8800
9168
  position: absolute;
8801
- z-index: 10;
9169
+ z-index: var(--butex-z-popover);
8802
9170
  top: calc(100% + 5px);
8803
9171
  right: 0;
8804
9172
  left: auto;
@@ -8835,8 +9203,9 @@ var WIDGET_CHROME_CSS = `
8835
9203
  }
8836
9204
 
8837
9205
  .butex-widget .toolbar .character-font-option[aria-selected="true"] {
8838
- background: linear-gradient(180deg, var(--butex-accent) 0%, var(--butex-accent-hover) 100%);
9206
+ background: var(--butex-accent-hover);
8839
9207
  color: var(--butex-on-accent);
9208
+ box-shadow: inset 0 0 0 2px currentColor;
8840
9209
  }
8841
9210
 
8842
9211
  .butex-widget .toolbar-script-icon {
@@ -8926,6 +9295,16 @@ var WIDGET_CHROME_CSS = `
8926
9295
  font-family: ${BUTEX_DIWANI_OUTLINE_FONT_STACK};
8927
9296
  }
8928
9297
 
9298
+ .butex-widget .butex-widget__command-sheet .function-command-option {
9299
+ direction: rtl;
9300
+ font-family: ${BUTEX_DIWANI_FONT_STACK};
9301
+ font-size: 17px;
9302
+ }
9303
+
9304
+ .butex-widget .butex-widget__command-sheet .function-command-option--outline {
9305
+ font-family: ${BUTEX_DIWANI_OUTLINE_FONT_STACK};
9306
+ }
9307
+
8929
9308
  .butex-widget .function-command-btn::after {
8930
9309
  content: "";
8931
9310
  width: 0;
@@ -8944,7 +9323,7 @@ var WIDGET_CHROME_CSS = `
8944
9323
 
8945
9324
  .butex-widget .function-command-options {
8946
9325
  position: absolute;
8947
- z-index: 10;
9326
+ z-index: var(--butex-z-popover);
8948
9327
  top: calc(100% + 5px);
8949
9328
  right: 0;
8950
9329
  left: auto;
@@ -9006,6 +9385,11 @@ var WIDGET_CHROME_CSS = `
9006
9385
  font-family: "Cambria Math", "Times New Roman", serif;
9007
9386
  }
9008
9387
 
9388
+ .butex-widget .butex-widget__command-sheet .operator-command-option {
9389
+ font-family: "Cambria Math", "Times New Roman", serif;
9390
+ font-size: 17px;
9391
+ }
9392
+
9009
9393
  .butex-widget .operator-command-label {
9010
9394
  display: inline-flex;
9011
9395
  align-items: center;
@@ -9041,7 +9425,7 @@ var WIDGET_CHROME_CSS = `
9041
9425
 
9042
9426
  .butex-widget .spacing-command-options {
9043
9427
  position: absolute;
9044
- z-index: 10;
9428
+ z-index: var(--butex-z-popover);
9045
9429
  top: calc(100% + 5px);
9046
9430
  right: 0;
9047
9431
  left: auto;
@@ -9157,7 +9541,7 @@ var WIDGET_CHROME_CSS = `
9157
9541
 
9158
9542
  .butex-widget .digit-form-options {
9159
9543
  position: absolute;
9160
- z-index: 10;
9544
+ z-index: var(--butex-z-popover);
9161
9545
  top: calc(100% + 5px);
9162
9546
  right: 0;
9163
9547
  left: auto;
@@ -9194,8 +9578,9 @@ var WIDGET_CHROME_CSS = `
9194
9578
  }
9195
9579
 
9196
9580
  .butex-widget .toolbar .digit-form-option[aria-selected="true"] {
9197
- background: linear-gradient(180deg, var(--butex-accent) 0%, var(--butex-accent-hover) 100%);
9581
+ background: var(--butex-accent-hover);
9198
9582
  color: var(--butex-on-accent);
9583
+ box-shadow: inset 0 0 0 2px currentColor;
9199
9584
  }
9200
9585
 
9201
9586
  .butex-widget .delete-node-btn,
@@ -9223,6 +9608,8 @@ var WIDGET_CHROME_CSS = `
9223
9608
  border: 1px solid var(--butex-border);
9224
9609
  border-radius: 10px;
9225
9610
  background: rgba(248, 250, 252, 0.72);
9611
+ max-width: 100%;
9612
+ min-width: 0;
9226
9613
  }
9227
9614
 
9228
9615
  .butex-widget .toolbar-functions,
@@ -9231,9 +9618,10 @@ var WIDGET_CHROME_CSS = `
9231
9618
  }
9232
9619
 
9233
9620
  .butex-widget .toolbar .accent {
9234
- background: linear-gradient(180deg, var(--butex-accent) 0%, var(--butex-accent-hover) 100%);
9621
+ background: var(--butex-accent-hover);
9235
9622
  color: var(--butex-on-accent);
9236
9623
  border-color: transparent;
9624
+ box-shadow: inset 0 0 0 2px currentColor;
9237
9625
  }
9238
9626
 
9239
9627
  .butex-widget .preview-box {
@@ -9242,7 +9630,13 @@ var WIDGET_CHROME_CSS = `
9242
9630
  padding: 10px 12px;
9243
9631
  background: var(--butex-preview-bg);
9244
9632
  color: var(--butex-preview-fg);
9633
+ max-width: 100%;
9245
9634
  min-height: 48px;
9635
+ min-width: 0;
9636
+ overflow-x: auto;
9637
+ overflow-y: hidden;
9638
+ overscroll-behavior-inline: contain;
9639
+ touch-action: pan-x pan-y;
9246
9640
  }
9247
9641
 
9248
9642
  .butex-widget .error {
@@ -9350,80 +9744,1053 @@ var WIDGET_CHROME_CSS = `
9350
9744
  background: var(--butex-dev-inset-bg);
9351
9745
  color: var(--butex-dev-inset-fg);
9352
9746
  }
9353
-
9354
- .butex-widget .debug-json-error {
9355
- margin: 0;
9356
- border: 1px solid rgba(220, 38, 38, 0.45);
9357
- background: rgba(254, 226, 226, 0.9);
9358
- color: #991b1b;
9359
- border-radius: 8px;
9360
- padding: 8px 10px;
9361
- white-space: pre-wrap;
9747
+
9748
+ .butex-widget .debug-json-error {
9749
+ margin: 0;
9750
+ border: 1px solid rgba(220, 38, 38, 0.45);
9751
+ background: rgba(254, 226, 226, 0.9);
9752
+ color: #991b1b;
9753
+ border-radius: 8px;
9754
+ padding: 8px 10px;
9755
+ white-space: pre-wrap;
9756
+ }
9757
+
9758
+ .butex-widget .delimiter-command-options,
9759
+ .butex-widget .matrix-command-popover,
9760
+ .butex-widget .character-font-options,
9761
+ .butex-widget .function-command-options,
9762
+ .butex-widget .spacing-command-options,
9763
+ .butex-widget .digit-form-options {
9764
+ max-height: min(70vh, 24rem);
9765
+ max-height: min(70dvh, 24rem);
9766
+ max-width: calc(100vw - 24px);
9767
+ max-width: calc(100cqw - 16px);
9768
+ overflow: auto;
9769
+ overscroll-behavior: contain;
9770
+ }
9771
+
9772
+ .butex-widget[data-responsive-mode="compact"] .butex-widget__desktop-toolbar {
9773
+ display: none;
9774
+ }
9775
+
9776
+ .butex-widget[data-responsive-mode="compact"] .butex-widget__mobile-toolbar {
9777
+ display: grid;
9778
+ }
9779
+
9780
+ .butex-widget[data-responsive-mode="compact"] .butex-widget__mobile-preview-toggle {
9781
+ display: inline-flex;
9782
+ }
9783
+
9784
+ .butex-widget[data-responsive-mode="compact"] .butex-widget__command-sheet-backdrop {
9785
+ display: flex;
9786
+ }
9787
+
9788
+ .butex-widget[data-responsive-mode="compact"] .panel-editor {
9789
+ display: flex;
9790
+ flex-direction: column;
9791
+ min-height: min(60dvh, 520px);
9792
+ }
9793
+
9794
+ .butex-widget[data-responsive-mode="compact"] .surface {
9795
+ flex: 1 1 auto;
9796
+ min-height: clamp(180px, 38dvh, 380px);
9797
+ }
9798
+
9799
+ .butex-widget[data-responsive-mode="compact"][data-compact-preview="closed"] .panel-preview {
9800
+ display: none;
9801
+ }
9802
+
9803
+ @media (max-width: 768px) {
9804
+ .butex-widget:not([data-responsive-mode="desktop"]) .butex-widget__desktop-toolbar {
9805
+ display: none;
9806
+ }
9807
+
9808
+ .butex-widget:not([data-responsive-mode="desktop"]) .butex-widget__mobile-toolbar {
9809
+ display: grid;
9810
+ }
9811
+
9812
+ .butex-widget:not([data-responsive-mode="desktop"]) .butex-widget__mobile-preview-toggle {
9813
+ display: inline-flex;
9814
+ }
9815
+
9816
+ .butex-widget:not([data-responsive-mode="desktop"]) .butex-widget__command-sheet-backdrop {
9817
+ display: flex;
9818
+ }
9819
+
9820
+ .butex-widget:not([data-responsive-mode="desktop"]) .panel-editor {
9821
+ display: flex;
9822
+ flex-direction: column;
9823
+ min-height: min(60dvh, 520px);
9824
+ }
9825
+
9826
+ .butex-widget:not([data-responsive-mode="desktop"]) .surface {
9827
+ flex: 1 1 auto;
9828
+ min-height: clamp(180px, 38dvh, 380px);
9829
+ }
9830
+
9831
+ .butex-widget:not([data-responsive-mode="desktop"])[data-compact-preview="closed"] .panel-preview {
9832
+ display: none;
9833
+ }
9834
+ }
9835
+
9836
+ @media (max-width: 430px) {
9837
+ .butex-widget-layout {
9838
+ gap: 6px;
9839
+ }
9840
+
9841
+ .butex-widget .panel {
9842
+ border-radius: 10px;
9843
+ padding: 8px;
9844
+ }
9845
+
9846
+ .butex-widget .toolbar {
9847
+ gap: 4px;
9848
+ }
9849
+
9850
+ .butex-widget:not([data-responsive-mode="desktop"]) .butex-widget__mobile-toolbar {
9851
+ grid-template-columns: repeat(4, minmax(44px, 1fr));
9852
+ }
9853
+
9854
+ .butex-widget:not([data-responsive-mode="desktop"]) .butex-widget__command-sheet-backdrop {
9855
+ padding-bottom: var(--butex-safe-area-bottom, env(safe-area-inset-bottom, 0px));
9856
+ padding-left: var(--butex-safe-area-left, env(safe-area-inset-left, 0px));
9857
+ padding-right: var(--butex-safe-area-right, env(safe-area-inset-right, 0px));
9858
+ padding-top: max(8px, var(--butex-safe-area-top, env(safe-area-inset-top, 0px)));
9859
+ }
9860
+
9861
+ .butex-widget:not([data-responsive-mode="desktop"]) .butex-widget__command-sheet {
9862
+ border-bottom: 0;
9863
+ max-height: calc(100dvh - max(8px, var(--butex-safe-area-top, env(safe-area-inset-top, 0px))) - var(--butex-safe-area-bottom, env(safe-area-inset-bottom, 0px)));
9864
+ max-width: none;
9865
+ }
9866
+
9867
+ .butex-widget:not([data-responsive-mode="desktop"]) .delimiter-command-menu,
9868
+ .butex-widget:not([data-responsive-mode="desktop"]) .matrix-command-menu,
9869
+ .butex-widget:not([data-responsive-mode="desktop"]) .character-font-menu,
9870
+ .butex-widget:not([data-responsive-mode="desktop"]) .function-command-menu,
9871
+ .butex-widget:not([data-responsive-mode="desktop"]) .spacing-command-menu,
9872
+ .butex-widget:not([data-responsive-mode="desktop"]) .digit-form-menu {
9873
+ position: static;
9874
+ }
9875
+
9876
+ .butex-widget:not([data-responsive-mode="desktop"]) .delimiter-command-options,
9877
+ .butex-widget:not([data-responsive-mode="desktop"]) .matrix-command-popover,
9878
+ .butex-widget:not([data-responsive-mode="desktop"]) .character-font-options,
9879
+ .butex-widget:not([data-responsive-mode="desktop"]) .function-command-options,
9880
+ .butex-widget:not([data-responsive-mode="desktop"]) .spacing-command-options,
9881
+ .butex-widget:not([data-responsive-mode="desktop"]) .digit-form-options {
9882
+ left: 8px;
9883
+ max-width: none;
9884
+ min-width: 0;
9885
+ right: 8px;
9886
+ width: auto;
9887
+ }
9888
+ }
9889
+
9890
+ @media (prefers-reduced-motion: reduce) {
9891
+ .butex-widget .toolbar button,
9892
+ .butex-widget .butex-widget__mobile-toolbar button,
9893
+ .butex-widget .butex-widget__mobile-preview-toggle,
9894
+ .butex-widget .butex-widget__command-sheet,
9895
+ .butex-widget .butex-widget__command-sheet button {
9896
+ animation: none;
9897
+ scroll-behavior: auto;
9898
+ transition: none;
9899
+ }
9900
+ }
9901
+ `.trim();
9902
+ var CHROME_STYLE_ID = "butex-widget-chrome-css";
9903
+ function injectWidgetChromeCss(doc) {
9904
+ const d = doc ?? (typeof document !== "undefined" ? document : void 0);
9905
+ if (!d || d.getElementById(CHROME_STYLE_ID)) {
9906
+ return;
9907
+ }
9908
+ const style = d.createElement("style");
9909
+ style.id = CHROME_STYLE_ID;
9910
+ style.textContent = WIDGET_CHROME_CSS;
9911
+ d.head.appendChild(style);
9912
+ }
9913
+
9914
+ // src/uiLocale.ts
9915
+ function uiLocaleDirection(locale) {
9916
+ return locale === "ar" ? "rtl" : "ltr";
9917
+ }
9918
+
9919
+ // src/debugJson.ts
9920
+ function lineColumnForPosition(text, position) {
9921
+ const before = text.slice(0, Math.max(0, position));
9922
+ const lines = before.split("\n");
9923
+ return {
9924
+ line: lines.length,
9925
+ column: (lines[lines.length - 1]?.length ?? 0) + 1
9926
+ };
9927
+ }
9928
+ function parseJsonDebugInput(text) {
9929
+ try {
9930
+ return { ok: true, value: JSON.parse(text) };
9931
+ } catch (error) {
9932
+ const message = error instanceof Error ? error.message : String(error);
9933
+ const positionMatch = message.match(/position\s+(\d+)/i);
9934
+ if (positionMatch) {
9935
+ const position = Number(positionMatch[1]);
9936
+ if (Number.isFinite(position)) {
9937
+ const location = lineColumnForPosition(text, position);
9938
+ return { ok: false, error: `Invalid JSON at line ${String(location.line)}, column ${String(location.column)}: ${message}` };
9939
+ }
9940
+ }
9941
+ return { ok: false, error: `Invalid JSON: ${message}` };
9942
+ }
9943
+ }
9944
+
9945
+ // src/react/EquationMobileToolbar.tsx
9946
+ import { useEffect as useEffect2, useId, useRef as useRef2, useState } from "react";
9947
+
9948
+ // src/react/dialogFocus.ts
9949
+ import { useEffect, useRef } from "react";
9950
+ var FOCUSABLE_SELECTOR = [
9951
+ 'a[href]:not([tabindex="-1"])',
9952
+ 'button:not([disabled]):not([tabindex="-1"])',
9953
+ 'input:not([disabled]):not([tabindex="-1"])',
9954
+ 'select:not([disabled]):not([tabindex="-1"])',
9955
+ 'textarea:not([disabled]):not([tabindex="-1"])',
9956
+ '[tabindex]:not([tabindex="-1"])'
9957
+ ].join(",");
9958
+ var dialogStateByDocument = /* @__PURE__ */ new WeakMap();
9959
+ function focusableElements(dialog) {
9960
+ return Array.from(dialog.querySelectorAll(FOCUSABLE_SELECTOR)).filter(
9961
+ (element) => {
9962
+ if (element.hidden || element.closest('[hidden], [aria-hidden="true"], [inert]') || typeof element.checkVisibility === "function" && !element.checkVisibility()) {
9963
+ return false;
9964
+ }
9965
+ return true;
9966
+ }
9967
+ );
9968
+ }
9969
+ function useDialogFocus({ open, dialogRef, onClose, triggerRef }) {
9970
+ const closeRef = useRef(onClose);
9971
+ closeRef.current = onClose;
9972
+ useEffect(() => {
9973
+ if (!open) {
9974
+ return;
9975
+ }
9976
+ const doc = dialogRef.current?.ownerDocument ?? document;
9977
+ const view = doc.defaultView ?? window;
9978
+ const registration = /* @__PURE__ */ Symbol("butex-dialog");
9979
+ const previouslyFocused = doc.activeElement instanceof HTMLElement ? doc.activeElement : null;
9980
+ const documentState = dialogStateByDocument.get(doc) ?? { stack: [], origin: null };
9981
+ if (documentState.stack.length === 0 && documentState.origin === null) {
9982
+ documentState.origin = triggerRef?.current ?? previouslyFocused;
9983
+ }
9984
+ documentState.stack.push(registration);
9985
+ dialogStateByDocument.set(doc, documentState);
9986
+ const focusTimer = view.setTimeout(() => {
9987
+ const initialFocus = dialogRef.current?.querySelector("[data-dialog-initial-focus]") ?? (dialogRef.current ? focusableElements(dialogRef.current)[0] : null) ?? dialogRef.current;
9988
+ initialFocus?.focus();
9989
+ }, 0);
9990
+ const onKeyDown = (event) => {
9991
+ if (documentState.stack.at(-1) !== registration) {
9992
+ return;
9993
+ }
9994
+ if (event.key === "Escape") {
9995
+ event.preventDefault();
9996
+ closeRef.current();
9997
+ return;
9998
+ }
9999
+ if (event.key !== "Tab" || !dialogRef.current) {
10000
+ return;
10001
+ }
10002
+ const focusable = focusableElements(dialogRef.current);
10003
+ if (focusable.length === 0) {
10004
+ event.preventDefault();
10005
+ dialogRef.current.focus();
10006
+ return;
10007
+ }
10008
+ const first = focusable[0];
10009
+ const last = focusable[focusable.length - 1];
10010
+ if (event.shiftKey && (doc.activeElement === first || !dialogRef.current.contains(doc.activeElement))) {
10011
+ event.preventDefault();
10012
+ last?.focus();
10013
+ } else if (!event.shiftKey && doc.activeElement === last) {
10014
+ event.preventDefault();
10015
+ first?.focus();
10016
+ }
10017
+ };
10018
+ const onFocusIn = (event) => {
10019
+ if (documentState.stack.at(-1) !== registration || !dialogRef.current || dialogRef.current.contains(event.target)) {
10020
+ return;
10021
+ }
10022
+ (focusableElements(dialogRef.current)[0] ?? dialogRef.current).focus();
10023
+ };
10024
+ doc.addEventListener("keydown", onKeyDown);
10025
+ doc.addEventListener("focusin", onFocusIn);
10026
+ return () => {
10027
+ view.clearTimeout(focusTimer);
10028
+ doc.removeEventListener("keydown", onKeyDown);
10029
+ doc.removeEventListener("focusin", onFocusIn);
10030
+ const index = documentState.stack.lastIndexOf(registration);
10031
+ const hadParentDialog = index > 0;
10032
+ if (index >= 0) {
10033
+ documentState.stack.splice(index, 1);
10034
+ }
10035
+ view.setTimeout(() => {
10036
+ if (documentState.stack.length > 0 && !hadParentDialog) {
10037
+ return;
10038
+ }
10039
+ const restoreTarget = [triggerRef?.current, previouslyFocused, documentState.origin].find(
10040
+ (candidate) => Boolean(candidate?.isConnected)
10041
+ );
10042
+ if (restoreTarget) {
10043
+ restoreTarget.focus();
10044
+ }
10045
+ if (documentState.stack.length === 0) {
10046
+ view.setTimeout(() => {
10047
+ if (documentState.stack.length === 0 && dialogStateByDocument.get(doc) === documentState) {
10048
+ dialogStateByDocument.delete(doc);
10049
+ }
10050
+ }, 0);
10051
+ }
10052
+ }, 0);
10053
+ };
10054
+ }, [dialogRef, open, triggerRef]);
10055
+ }
10056
+
10057
+ // src/react/EquationMobileToolbar.tsx
10058
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
10059
+ var ACCENT_COMMANDS2 = accentCommandsList();
10060
+ var FUNCTION_COMMANDS = atomicCommandsByCategory("function");
10061
+ var LIMITS_SERIES_COMMANDS = atomicCommandsByCategory("limits_series");
10062
+ var FUNCTION2_COMMANDS = atomicCommandsByCategory("function2");
10063
+ var DERIVATIVE_COMMANDS = atomicCommandsByCategory("derivative");
10064
+ var GROUP_COMMANDS = atomicCommandsByCategory("groups");
10065
+ var SPACING_COMMANDS = atomicCommandsByCategory("spacing").filter(isSpacingCommandSpec);
10066
+ var OPERATOR_GROUPS = [
10067
+ atomicOperatorCommandsByCategory("operators1"),
10068
+ atomicOperatorCommandsByCategory("operators2"),
10069
+ atomicOperatorCommandsByCategory("operators3"),
10070
+ atomicOperatorCommandsByCategory("dots"),
10071
+ atomicOperatorCommandsByCategory("integrals")
10072
+ ];
10073
+ var MATRIX_STYLES = [
10074
+ { id: "matrix", label: "\u25A1" },
10075
+ { id: "pmatrix", label: "(\u25A1)" },
10076
+ { id: "bmatrix", label: "[\u25A1]" },
10077
+ { id: "Bmatrix", label: "{\u25A1}" },
10078
+ { id: "vmatrix", label: "|\u25A1|" },
10079
+ { id: "Vmatrix", label: "||\u25A1||" }
10080
+ ];
10081
+ var MATRIX_PRESETS = [
10082
+ { rows: 2, columns: 2 },
10083
+ { rows: 2, columns: 3 },
10084
+ { rows: 3, columns: 2 },
10085
+ { rows: 3, columns: 3 }
10086
+ ];
10087
+ var ARRAY_ALIGNMENTS = ["l", "c", "r"];
10088
+ function clampMatrixSize(value) {
10089
+ return Math.max(1, Math.min(12, Math.trunc(value)));
10090
+ }
10091
+ function matrixSizeLabel(rows, columns, messages) {
10092
+ const rowLabel = rows === 1 ? messages.row : messages.rows;
10093
+ const columnLabel = columns === 1 ? messages.column : messages.columns;
10094
+ return `${String(rows)} ${rowLabel} \xD7 ${String(columns)} ${columnLabel}`;
10095
+ }
10096
+ function matrixStyleTitle(style, messages) {
10097
+ if (style === "pmatrix") return messages.matrixParentheses;
10098
+ if (style === "bmatrix") return messages.matrixBrackets;
10099
+ if (style === "Bmatrix") return messages.matrixBraces;
10100
+ if (style === "vmatrix") return messages.matrixBars;
10101
+ if (style === "Vmatrix") return messages.matrixDoubleBars;
10102
+ return messages.matrixNoDelimiters;
10103
+ }
10104
+ function alignmentLabel(alignment, messages) {
10105
+ if (alignment === "l") return messages.alignLeft;
10106
+ if (alignment === "r") return messages.alignRight;
10107
+ return messages.alignCenter;
10108
+ }
10109
+ function alignmentTitle(alignment, messages) {
10110
+ if (alignment === "l") return messages.alignColumnLeft;
10111
+ if (alignment === "r") return messages.alignColumnRight;
10112
+ return messages.alignColumnCenter;
10113
+ }
10114
+ function characterFontTitle(fontId, messages) {
10115
+ const key = characterFontSpec(fontId).titleKey;
10116
+ return messages[key] ?? messages.defaultFont;
10117
+ }
10118
+ function digitTitle(digitForm, messages) {
10119
+ if (digitForm === "arabicIndic") return messages.arabicIndicDigits;
10120
+ if (digitForm === "persianIndic") return messages.persianIndicDigits;
10121
+ return messages.westernDigits;
10122
+ }
10123
+ function spacingArrow(command, side) {
10124
+ const pointsWithFlow = command.spacing.direction === "positive";
10125
+ if (pointsWithFlow) {
10126
+ return side === "arabic" ? "\u2190" : "\u2192";
10127
+ }
10128
+ return side === "arabic" ? "\u2192" : "\u2190";
10129
+ }
10130
+ function functionLabel(command) {
10131
+ if (command.id !== "ln") {
10132
+ return command.arabicLabel;
10133
+ }
10134
+ return /* @__PURE__ */ jsxs("span", { className: "function-command-label-with-sub", "aria-hidden": "true", children: [
10135
+ /* @__PURE__ */ jsx("span", { className: "function-command-label-with-sub__base", children: command.arabicLabel }),
10136
+ /* @__PURE__ */ jsx("span", { className: "function-command-label-with-sub__sub", children: "\u0647\u0640" })
10137
+ ] });
9362
10138
  }
9363
- `.trim();
9364
- var CHROME_STYLE_ID = "butex-widget-chrome-css";
9365
- function injectWidgetChromeCss(doc) {
9366
- const d = doc ?? (typeof document !== "undefined" ? document : void 0);
9367
- if (!d || d.getElementById(CHROME_STYLE_ID)) {
9368
- return;
10139
+ function operatorLabel(command) {
10140
+ const label = command.svg_path ? /* @__PURE__ */ jsx(
10141
+ "span",
10142
+ {
10143
+ className: "operator-command-svg-label",
10144
+ "aria-hidden": "true",
10145
+ style: {
10146
+ mask: `url("${command.svg_path}") center / contain no-repeat`,
10147
+ WebkitMask: `url("${command.svg_path}") center / contain no-repeat`
10148
+ }
10149
+ }
10150
+ ) : command.Label;
10151
+ return /* @__PURE__ */ jsx("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: label });
10152
+ }
10153
+ function categoryTitle(view, messages) {
10154
+ if (view === "delimiters") return messages.insertDelimiters;
10155
+ if (view === "structures") return messages.structures;
10156
+ if (view === "functions") return messages.functions;
10157
+ if (view === "operators") return messages.operations;
10158
+ if (view === "matrices") return messages.matrices;
10159
+ if (view === "typography") return messages.typography;
10160
+ if (view === "spacing") return messages.spaces;
10161
+ if (view === "digits") return messages.digitForms;
10162
+ return messages.moreActions;
10163
+ }
10164
+ function EquationMobileToolbar({
10165
+ uiLocale,
10166
+ messages,
10167
+ state,
10168
+ showSideSwitcher,
10169
+ inputRef,
10170
+ getRuntime
10171
+ }) {
10172
+ const [sheetView, setSheetView] = useState("closed");
10173
+ const [envMode, setEnvMode] = useState("matrix");
10174
+ const [matrixStyle, setMatrixStyle] = useState("pmatrix");
10175
+ const [matrixRows, setMatrixRows] = useState(2);
10176
+ const [matrixColumns, setMatrixColumns] = useState(2);
10177
+ const [alignmentColumn, setAlignmentColumn] = useState(1);
10178
+ const dialogRef = useRef2(null);
10179
+ const moreButtonRef = useRef2(null);
10180
+ const delimiterButtonRef = useRef2(null);
10181
+ const backButtonRef = useRef2(null);
10182
+ const restoreFocusRef = useRef2(null);
10183
+ const sheetTitleId = useId();
10184
+ const sheetOpen = sheetView !== "closed";
10185
+ function dismissSheet() {
10186
+ setSheetView("closed");
10187
+ }
10188
+ useDialogFocus({ open: sheetOpen, dialogRef, onClose: dismissSheet, triggerRef: restoreFocusRef });
10189
+ useEffect2(() => {
10190
+ if (sheetView !== "closed" && sheetView !== "root" && sheetView !== "delimiters") {
10191
+ const timer = window.setTimeout(() => backButtonRef.current?.focus(), 0);
10192
+ return () => window.clearTimeout(timer);
10193
+ }
10194
+ }, [sheetView]);
10195
+ function focusInputAfterClose() {
10196
+ restoreFocusRef.current = inputRef.current;
10197
+ setSheetView("closed");
10198
+ window.requestAnimationFrame(() => getRuntime()?.focusInput());
10199
+ }
10200
+ function runAndClose(action) {
10201
+ const runtime = getRuntime();
10202
+ if (runtime) {
10203
+ action(runtime);
10204
+ }
10205
+ focusInputAfterClose();
10206
+ }
10207
+ function runAndKeepFocus(button, action) {
10208
+ const runtime = getRuntime();
10209
+ if (runtime) {
10210
+ action(runtime);
10211
+ }
10212
+ window.requestAnimationFrame(() => button.focus());
10213
+ }
10214
+ function openMore() {
10215
+ restoreFocusRef.current = moreButtonRef.current;
10216
+ setSheetView("root");
10217
+ }
10218
+ function openDelimiters() {
10219
+ restoreFocusRef.current = delimiterButtonRef.current;
10220
+ setSheetView("delimiters");
10221
+ }
10222
+ function setMatrixDimension(kind, value) {
10223
+ const next = clampMatrixSize(value);
10224
+ if (kind === "rows") {
10225
+ setMatrixRows(next);
10226
+ } else {
10227
+ setMatrixColumns(envMode === "aligned" ? 2 : next);
10228
+ }
9369
10229
  }
9370
- const style = d.createElement("style");
9371
- style.id = CHROME_STYLE_ID;
9372
- style.textContent = WIDGET_CHROME_CSS;
9373
- d.head.appendChild(style);
10230
+ function insertEnvironment() {
10231
+ runAndClose((runtime) => {
10232
+ if (envMode === "array") {
10233
+ runtime.insertArrayEnv(matrixRows, matrixColumns);
10234
+ } else if (envMode === "aligned") {
10235
+ runtime.insertAlignedEnv(matrixRows, 2);
10236
+ } else {
10237
+ runtime.insertMatrixEnv(matrixStyle, matrixRows, matrixColumns);
10238
+ }
10239
+ });
10240
+ }
10241
+ const directButtonMouseDown = (event) => event.preventDefault();
10242
+ const undoArrow = state.activeSide === "arabic" ? "\u21B7" : "\u21B6";
10243
+ const redoArrow = state.activeSide === "arabic" ? "\u21B6" : "\u21B7";
10244
+ const renderFunctionGroup = (label, commands, limits = false, outline = false) => /* @__PURE__ */ jsxs("section", { className: "butex-widget__sheet-section", children: [
10245
+ /* @__PURE__ */ jsx("h4", { children: label }),
10246
+ /* @__PURE__ */ jsx("div", { className: "butex-widget__sheet-command-grid", children: commands.map((command) => /* @__PURE__ */ jsx(
10247
+ "button",
10248
+ {
10249
+ className: `function-command-option${outline ? " function-command-option--outline" : ""}`,
10250
+ type: "button",
10251
+ title: atomicCommandTitle(command, uiLocale),
10252
+ "aria-label": atomicCommandTitle(command, uiLocale),
10253
+ onClick: () => runAndClose((runtime) => {
10254
+ if (limits) runtime.insertLimitsSeriesTemplate(command.id);
10255
+ else runtime.insertAtomicCommand(command.id);
10256
+ }),
10257
+ children: functionLabel(command)
10258
+ },
10259
+ command.id
10260
+ )) })
10261
+ ] }, label);
10262
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
10263
+ /* @__PURE__ */ jsxs("div", { className: "butex-widget__mobile-toolbar", role: "toolbar", "aria-label": messages.compactToolbar, children: [
10264
+ /* @__PURE__ */ jsx("button", { type: "button", disabled: !state.canUndo, title: messages.undo, "aria-label": messages.undo, onMouseDown: directButtonMouseDown, onClick: () => getRuntime()?.performUndo(), children: undoArrow }),
10265
+ /* @__PURE__ */ jsx("button", { type: "button", disabled: !state.canRedo, title: messages.redo, "aria-label": messages.redo, onMouseDown: directButtonMouseDown, onClick: () => getRuntime()?.performRedo(), children: redoArrow }),
10266
+ /* @__PURE__ */ jsx("button", { type: "button", title: messages.insertFraction, "aria-label": messages.insertFraction, onMouseDown: directButtonMouseDown, onClick: () => getRuntime()?.insertFraction(), children: /* @__PURE__ */ jsxs("span", { className: "toolbar-frac-icon", "aria-hidden": "true", children: [
10267
+ /* @__PURE__ */ jsx("span", { children: "\u0623" }),
10268
+ /* @__PURE__ */ jsx("span", { children: "\u0628" })
10269
+ ] }) }),
10270
+ /* @__PURE__ */ jsx("button", { type: "button", title: messages.addSuperscript, "aria-label": messages.addSuperscript, onMouseDown: directButtonMouseDown, onClick: () => getRuntime()?.addSup(), children: /* @__PURE__ */ jsxs("span", { className: "toolbar-script-icon toolbar-script-icon--sup", "aria-hidden": "true", children: [
10271
+ /* @__PURE__ */ jsx("span", { children: "\u0646" }),
10272
+ /* @__PURE__ */ jsx("span", { children: "\u0633" })
10273
+ ] }) }),
10274
+ /* @__PURE__ */ jsx("button", { type: "button", title: messages.addSubscript, "aria-label": messages.addSubscript, onMouseDown: directButtonMouseDown, onClick: () => getRuntime()?.addSub(), children: /* @__PURE__ */ jsxs("span", { className: "toolbar-script-icon toolbar-script-icon--sub", "aria-hidden": "true", children: [
10275
+ /* @__PURE__ */ jsx("span", { children: "\u0646" }),
10276
+ /* @__PURE__ */ jsx("span", { children: "\u0633" })
10277
+ ] }) }),
10278
+ /* @__PURE__ */ jsx("button", { ref: delimiterButtonRef, type: "button", title: messages.insertDelimiters, "aria-label": messages.insertDelimiters, "aria-haspopup": "dialog", "aria-expanded": sheetView === "delimiters", onClick: openDelimiters, children: "()" }),
10279
+ /* @__PURE__ */ jsx("button", { className: "butex-widget__mobile-danger", type: "button", title: messages.deleteSelectedStructure, "aria-label": messages.deleteSelectedStructure, onMouseDown: directButtonMouseDown, onClick: () => getRuntime()?.deleteStructure(), children: "\xD7" }),
10280
+ /* @__PURE__ */ jsx("button", { ref: moreButtonRef, type: "button", title: messages.moreActions, "aria-label": messages.moreActions, "aria-haspopup": "dialog", "aria-expanded": sheetOpen && sheetView !== "delimiters", onClick: openMore, children: "\u22EF" })
10281
+ ] }),
10282
+ sheetOpen ? /* @__PURE__ */ jsx(
10283
+ "div",
10284
+ {
10285
+ className: "butex-widget__command-sheet-backdrop",
10286
+ role: "presentation",
10287
+ onClick: (event) => {
10288
+ if (event.target === event.currentTarget) dismissSheet();
10289
+ },
10290
+ children: /* @__PURE__ */ jsxs(
10291
+ "div",
10292
+ {
10293
+ ref: dialogRef,
10294
+ className: "butex-widget__command-sheet",
10295
+ role: "dialog",
10296
+ "aria-modal": "true",
10297
+ "aria-labelledby": sheetTitleId,
10298
+ tabIndex: -1,
10299
+ children: [
10300
+ /* @__PURE__ */ jsxs("div", { className: "butex-widget__command-sheet-header", children: [
10301
+ sheetView !== "root" && sheetView !== "delimiters" ? /* @__PURE__ */ jsx("button", { ref: backButtonRef, type: "button", onClick: () => setSheetView("root"), children: messages.back }) : /* @__PURE__ */ jsx("span", {}),
10302
+ /* @__PURE__ */ jsx("strong", { id: sheetTitleId, children: categoryTitle(sheetView, messages) }),
10303
+ /* @__PURE__ */ jsx("button", { type: "button", "data-dialog-initial-focus": true, "aria-label": messages.closeActions, onClick: dismissSheet, children: "\xD7" })
10304
+ ] }),
10305
+ /* @__PURE__ */ jsxs("div", { className: "butex-widget__command-sheet-body", children: [
10306
+ sheetView === "root" ? /* @__PURE__ */ jsxs(Fragment, { children: [
10307
+ showSideSwitcher ? /* @__PURE__ */ jsxs("section", { className: "butex-widget__sheet-section", children: [
10308
+ /* @__PURE__ */ jsx("h4", { children: messages.activeSide }),
10309
+ /* @__PURE__ */ jsxs("div", { className: "butex-widget__sheet-choice-row", children: [
10310
+ /* @__PURE__ */ jsx(
10311
+ "button",
10312
+ {
10313
+ type: "button",
10314
+ "aria-pressed": state.activeSide === "arabic",
10315
+ onClick: (event) => {
10316
+ if (state.activeSide !== "arabic") runAndKeepFocus(event.currentTarget, (runtime) => runtime.toggleSide());
10317
+ },
10318
+ children: messages.arabicSide
10319
+ }
10320
+ ),
10321
+ /* @__PURE__ */ jsx(
10322
+ "button",
10323
+ {
10324
+ type: "button",
10325
+ "aria-pressed": state.activeSide === "english",
10326
+ onClick: (event) => {
10327
+ if (state.activeSide !== "english") runAndKeepFocus(event.currentTarget, (runtime) => runtime.toggleSide());
10328
+ },
10329
+ children: messages.englishSide
10330
+ }
10331
+ )
10332
+ ] })
10333
+ ] }) : null,
10334
+ /* @__PURE__ */ jsxs("section", { className: "butex-widget__sheet-section", children: [
10335
+ /* @__PURE__ */ jsx("h4", { children: messages.clipboard }),
10336
+ /* @__PURE__ */ jsxs("div", { className: "butex-widget__sheet-choice-row", children: [
10337
+ /* @__PURE__ */ jsx("button", { type: "button", disabled: !state.hasSelection, onClick: () => runAndClose((runtime) => {
10338
+ void runtime.performCopy();
10339
+ }), children: messages.copy }),
10340
+ /* @__PURE__ */ jsx("button", { type: "button", disabled: !state.hasSelection, onClick: () => runAndClose((runtime) => {
10341
+ void runtime.performCut();
10342
+ }), children: messages.cut }),
10343
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: () => runAndClose((runtime) => {
10344
+ void runtime.performPaste();
10345
+ }), children: messages.paste })
10346
+ ] })
10347
+ ] }),
10348
+ /* @__PURE__ */ jsx("nav", { className: "butex-widget__sheet-categories", "aria-label": messages.commandCategories, children: ["structures", "functions", "operators", "matrices", "typography", "spacing", "digits"].map((view) => /* @__PURE__ */ jsx("button", { type: "button", onClick: () => setSheetView(view), children: categoryTitle(view, messages) }, view)) })
10349
+ ] }) : null,
10350
+ sheetView === "delimiters" ? /* @__PURE__ */ jsx("div", { className: "butex-widget__sheet-command-grid butex-widget__sheet-command-grid--three", children: [
10351
+ { kind: "paren", label: "()", title: messages.insertParentheses },
10352
+ { kind: "bracket", label: "[]", title: messages.insertBrackets },
10353
+ { kind: "brace", label: "{}", title: messages.insertBraces }
10354
+ ].map((option) => /* @__PURE__ */ jsx("button", { type: "button", "aria-label": option.title, title: option.title, onClick: () => runAndClose((runtime) => runtime.insertDelimiterByKind(option.kind)), children: option.label }, option.kind)) }) : null,
10355
+ sheetView === "structures" ? /* @__PURE__ */ jsxs(Fragment, { children: [
10356
+ /* @__PURE__ */ jsxs("div", { className: "butex-widget__sheet-command-grid", children: [
10357
+ /* @__PURE__ */ jsx("button", { type: "button", title: messages.insertRoot, "aria-label": messages.insertRoot, onClick: () => runAndClose((runtime) => runtime.insertSqrt()), children: /* @__PURE__ */ jsx("span", { className: "toolbar-sqrt-icon", "aria-hidden": "true", children: "\u221A" }) }),
10358
+ /* @__PURE__ */ jsx("button", { type: "button", title: messages.insertOverset, "aria-label": messages.insertOverset, onClick: () => runAndClose((runtime) => runtime.insertOverset()), children: /* @__PURE__ */ jsxs("span", { className: "toolbar-accent-icon toolbar-accent-icon--over", "aria-hidden": "true", children: [
10359
+ /* @__PURE__ */ jsx("span", { children: "\u2217" }),
10360
+ /* @__PURE__ */ jsx("span", { children: "\u25A1" })
10361
+ ] }) }),
10362
+ /* @__PURE__ */ jsx("button", { type: "button", title: messages.insertUnderset, "aria-label": messages.insertUnderset, onClick: () => runAndClose((runtime) => runtime.insertUnderset()), children: /* @__PURE__ */ jsxs("span", { className: "toolbar-accent-icon toolbar-accent-icon--under", "aria-hidden": "true", children: [
10363
+ /* @__PURE__ */ jsx("span", { children: "\u25A1" }),
10364
+ /* @__PURE__ */ jsx("span", { children: "\u2217" })
10365
+ ] }) }),
10366
+ /* @__PURE__ */ jsx("button", { type: "button", title: messages.insertAccentPair, "aria-label": messages.insertAccentPair, onClick: () => runAndClose((runtime) => runtime.insertAccentPair()), children: /* @__PURE__ */ jsxs("span", { className: "toolbar-accent-icon toolbar-accent-icon--pair", "aria-hidden": "true", children: [
10367
+ /* @__PURE__ */ jsx("span", { children: "\u2217" }),
10368
+ /* @__PURE__ */ jsx("span", { children: "\u25A1" }),
10369
+ /* @__PURE__ */ jsx("span", { children: "\u2217" })
10370
+ ] }) }),
10371
+ /* @__PURE__ */ jsx("button", { type: "button", title: messages.removeSuperscript, "aria-label": messages.removeSuperscript, onClick: () => runAndClose((runtime) => runtime.removeSup()), children: /* @__PURE__ */ jsxs("span", { className: "toolbar-remove-script-icon toolbar-remove-script-icon--sup", "aria-hidden": "true", children: [
10372
+ /* @__PURE__ */ jsx("span", { children: "\xD7" }),
10373
+ /* @__PURE__ */ jsx("span", { children: "\u0646" })
10374
+ ] }) }),
10375
+ /* @__PURE__ */ jsx("button", { type: "button", title: messages.removeSubscript, "aria-label": messages.removeSubscript, onClick: () => runAndClose((runtime) => runtime.removeSub()), children: /* @__PURE__ */ jsxs("span", { className: "toolbar-remove-script-icon toolbar-remove-script-icon--sub", "aria-hidden": "true", children: [
10376
+ /* @__PURE__ */ jsx("span", { children: "\xD7" }),
10377
+ /* @__PURE__ */ jsx("span", { children: "\u0646" })
10378
+ ] }) })
10379
+ ] }),
10380
+ /* @__PURE__ */ jsxs("section", { className: "butex-widget__sheet-section", children: [
10381
+ /* @__PURE__ */ jsx("h4", { children: messages.insertAccents }),
10382
+ /* @__PURE__ */ jsx("div", { className: "butex-widget__sheet-command-grid", children: ACCENT_COMMANDS2.map((command) => /* @__PURE__ */ jsx("button", { className: "operator-command-option", type: "button", title: accentCommandTitle(command, uiLocale), "aria-label": accentCommandTitle(command, uiLocale), onClick: () => runAndClose((runtime) => runtime.insertAccent(command.id)), children: /* @__PURE__ */ jsx("span", { className: "operator-command-label", "aria-hidden": "true", children: command.label }) }, command.id)) })
10383
+ ] })
10384
+ ] }) : null,
10385
+ sheetView === "functions" ? /* @__PURE__ */ jsxs(Fragment, { children: [
10386
+ renderFunctionGroup(messages.insertFunction, FUNCTION_COMMANDS),
10387
+ renderFunctionGroup(messages.insertLimitsSeries, LIMITS_SERIES_COMMANDS, true),
10388
+ renderFunctionGroup(messages.insertAdditionalFunctions, FUNCTION2_COMMANDS),
10389
+ renderFunctionGroup(messages.insertDerivative, DERIVATIVE_COMMANDS),
10390
+ /* @__PURE__ */ jsxs("div", { className: "butex-widget__sheet-command-grid", children: [
10391
+ /* @__PURE__ */ jsx("button", { className: "function-command-option", type: "button", title: messages.insertFirstDerivative, "aria-label": messages.insertFirstDerivative, onClick: () => runAndClose((runtime) => runtime.insertFirstDerivative()), children: "\u0621/\u0633" }),
10392
+ /* @__PURE__ */ jsx("button", { className: "function-command-option", type: "button", title: messages.insertSecondDerivative, "aria-label": messages.insertSecondDerivative, onClick: () => runAndClose((runtime) => runtime.insertSecondDerivative()), children: "\u0621\xB2/\u0633\xB2" })
10393
+ ] }),
10394
+ renderFunctionGroup(messages.insertNumberSets, GROUP_COMMANDS, false, true)
10395
+ ] }) : null,
10396
+ sheetView === "operators" ? OPERATOR_GROUPS.map((commands, index) => /* @__PURE__ */ jsx("section", { className: "butex-widget__sheet-section", children: /* @__PURE__ */ jsx("div", { className: "butex-widget__sheet-command-grid", children: commands.map((command) => /* @__PURE__ */ jsx("button", { className: "operator-command-option", type: "button", title: atomicOperatorCommandTitle(command, uiLocale), "aria-label": atomicOperatorCommandTitle(command, uiLocale), onClick: () => runAndClose((runtime) => runtime.insertAtomicOperatorCommand(command.id)), children: operatorLabel(command) }, command.id)) }) }, String(index))) : null,
10397
+ sheetView === "matrices" ? /* @__PURE__ */ jsxs("div", { className: "butex-widget__mobile-matrix-picker", children: [
10398
+ /* @__PURE__ */ jsx("div", { className: "butex-widget__sheet-choice-row", role: "group", "aria-label": messages.environmentType, children: [
10399
+ { id: "matrix", label: messages.matrix },
10400
+ { id: "array", label: messages.array },
10401
+ { id: "aligned", label: messages.aligned }
10402
+ ].map((option) => /* @__PURE__ */ jsx(
10403
+ "button",
10404
+ {
10405
+ type: "button",
10406
+ "aria-pressed": envMode === option.id,
10407
+ onClick: () => {
10408
+ setEnvMode(option.id);
10409
+ if (option.id === "aligned") setMatrixColumns(2);
10410
+ },
10411
+ children: option.label
10412
+ },
10413
+ option.id
10414
+ )) }),
10415
+ envMode === "matrix" ? /* @__PURE__ */ jsx("div", { className: "butex-widget__sheet-choice-row", role: "group", "aria-label": messages.matrixType, children: MATRIX_STYLES.map((style) => /* @__PURE__ */ jsx("button", { type: "button", title: matrixStyleTitle(style.id, messages), "aria-label": matrixStyleTitle(style.id, messages), "aria-pressed": matrixStyle === style.id, onClick: () => setMatrixStyle(style.id), children: style.label }, style.id)) }) : null,
10416
+ /* @__PURE__ */ jsxs("section", { className: "butex-widget__sheet-section", children: [
10417
+ /* @__PURE__ */ jsx("h4", { children: messages.commonMatrixSizes }),
10418
+ /* @__PURE__ */ jsx("div", { className: "butex-widget__matrix-presets", children: (envMode === "aligned" ? MATRIX_PRESETS.filter((preset) => preset.columns === 2) : MATRIX_PRESETS).map((preset) => /* @__PURE__ */ jsxs(
10419
+ "button",
10420
+ {
10421
+ type: "button",
10422
+ "aria-pressed": matrixRows === preset.rows && matrixColumns === preset.columns,
10423
+ onClick: () => {
10424
+ setMatrixRows(preset.rows);
10425
+ setMatrixColumns(envMode === "aligned" ? 2 : preset.columns);
10426
+ },
10427
+ children: [
10428
+ preset.rows,
10429
+ "\xD7",
10430
+ envMode === "aligned" ? 2 : preset.columns
10431
+ ]
10432
+ },
10433
+ `${String(preset.rows)}-${String(preset.columns)}`
10434
+ )) })
10435
+ ] }),
10436
+ /* @__PURE__ */ jsxs("div", { className: "butex-widget__matrix-stepper-row", children: [
10437
+ /* @__PURE__ */ jsx("span", { children: messages.rows }),
10438
+ /* @__PURE__ */ jsxs("div", { className: "butex-widget__matrix-stepper", children: [
10439
+ /* @__PURE__ */ jsx("button", { type: "button", disabled: matrixRows <= 1, "aria-label": messages.decreaseRows, onClick: () => setMatrixDimension("rows", matrixRows - 1), children: "\u2212" }),
10440
+ /* @__PURE__ */ jsx("output", { "aria-live": "polite", children: matrixRows }),
10441
+ /* @__PURE__ */ jsx("button", { type: "button", disabled: matrixRows >= 12, "aria-label": messages.increaseRows, onClick: () => setMatrixDimension("rows", matrixRows + 1), children: "+" })
10442
+ ] })
10443
+ ] }),
10444
+ /* @__PURE__ */ jsxs("div", { className: "butex-widget__matrix-stepper-row", children: [
10445
+ /* @__PURE__ */ jsx("span", { children: messages.columns }),
10446
+ /* @__PURE__ */ jsxs("div", { className: "butex-widget__matrix-stepper", children: [
10447
+ /* @__PURE__ */ jsx("button", { type: "button", disabled: matrixColumns <= 1 || envMode === "aligned", "aria-label": messages.decreaseColumns, onClick: () => setMatrixDimension("columns", matrixColumns - 1), children: "\u2212" }),
10448
+ /* @__PURE__ */ jsx("output", { "aria-live": "polite", children: envMode === "aligned" ? 2 : matrixColumns }),
10449
+ /* @__PURE__ */ jsx("button", { type: "button", disabled: matrixColumns >= 12 || envMode === "aligned", "aria-label": messages.increaseColumns, onClick: () => setMatrixDimension("columns", matrixColumns + 1), children: "+" })
10450
+ ] })
10451
+ ] }),
10452
+ /* @__PURE__ */ jsx("p", { className: "butex-widget__matrix-size-summary", "aria-live": "polite", children: matrixSizeLabel(matrixRows, envMode === "aligned" ? 2 : matrixColumns, messages) }),
10453
+ /* @__PURE__ */ jsx("button", { type: "button", className: "butex-widget__matrix-insert", onClick: insertEnvironment, children: messages.insert }),
10454
+ /* @__PURE__ */ jsxs("section", { className: "butex-widget__sheet-section", children: [
10455
+ /* @__PURE__ */ jsx("h4", { children: messages.editSelectedEnvironment }),
10456
+ envMode === "matrix" ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => getRuntime()?.setMatrixEnvStyle(matrixStyle), children: messages.applyStyle }) : null,
10457
+ envMode === "array" ? /* @__PURE__ */ jsxs("div", { className: "butex-widget__matrix-alignment", children: [
10458
+ /* @__PURE__ */ jsxs("label", { children: [
10459
+ messages.column,
10460
+ /* @__PURE__ */ jsx("input", { type: "number", min: 1, max: 12, value: alignmentColumn, onChange: (event) => setAlignmentColumn(clampMatrixSize(Number(event.currentTarget.value) || 1)) })
10461
+ ] }),
10462
+ ARRAY_ALIGNMENTS.map((alignment) => /* @__PURE__ */ jsx("button", { type: "button", title: alignmentTitle(alignment, messages), onClick: () => getRuntime()?.setArrayColumnAlignment(alignmentColumn - 1, alignment), children: alignmentLabel(alignment, messages) }, alignment))
10463
+ ] }) : null,
10464
+ /* @__PURE__ */ jsxs("div", { className: "butex-widget__sheet-command-grid", children: [
10465
+ /* @__PURE__ */ jsxs("button", { type: "button", onClick: () => getRuntime()?.addMatrixRow(), children: [
10466
+ "+",
10467
+ messages.row
10468
+ ] }),
10469
+ /* @__PURE__ */ jsxs("button", { type: "button", onClick: () => getRuntime()?.removeMatrixRow(), children: [
10470
+ "\u2212",
10471
+ messages.row
10472
+ ] }),
10473
+ /* @__PURE__ */ jsxs("button", { type: "button", onClick: () => getRuntime()?.addMatrixColumn(), children: [
10474
+ "+",
10475
+ messages.column
10476
+ ] }),
10477
+ /* @__PURE__ */ jsxs("button", { type: "button", onClick: () => getRuntime()?.removeMatrixColumn(), children: [
10478
+ "\u2212",
10479
+ messages.column
10480
+ ] })
10481
+ ] })
10482
+ ] })
10483
+ ] }) : null,
10484
+ sheetView === "typography" ? /* @__PURE__ */ jsxs(Fragment, { children: [
10485
+ /* @__PURE__ */ jsxs("section", { className: "butex-widget__sheet-section", children: [
10486
+ /* @__PURE__ */ jsx("h4", { children: messages.chooseWritingFont }),
10487
+ /* @__PURE__ */ jsx("div", { className: "butex-widget__sheet-choice-row", children: CHARACTER_FONT_OPTIONS.map((option) => /* @__PURE__ */ jsx(
10488
+ "button",
10489
+ {
10490
+ type: "button",
10491
+ className: `character-font-option--${option.id}`,
10492
+ "aria-pressed": state.characterFont === option.id,
10493
+ title: characterFontTitle(option.id, messages),
10494
+ onClick: (event) => runAndKeepFocus(event.currentTarget, (runtime) => runtime.setCurrentCharacterFont(option.id)),
10495
+ children: option.label
10496
+ },
10497
+ option.id
10498
+ )) })
10499
+ ] }),
10500
+ /* @__PURE__ */ jsx(
10501
+ "button",
10502
+ {
10503
+ className: "ligature-btn butex-widget__compact-ligature",
10504
+ type: "button",
10505
+ title: !state.splitLeafTyping ? messages.disableLetterMerging : messages.enableLetterMerging,
10506
+ "aria-label": !state.splitLeafTyping ? messages.disableLetterMerging : messages.enableLetterMerging,
10507
+ "aria-pressed": !state.splitLeafTyping,
10508
+ onClick: (event) => runAndKeepFocus(event.currentTarget, (runtime) => runtime.toggleSplitLeafTyping()),
10509
+ children: !state.splitLeafTyping ? "\u0633\u0635\u0639" : "\u0633 \u0635 \u0639"
10510
+ }
10511
+ )
10512
+ ] }) : null,
10513
+ sheetView === "spacing" ? /* @__PURE__ */ jsx("div", { className: "butex-widget__sheet-command-list", children: SPACING_COMMANDS.map((command) => /* @__PURE__ */ jsx("button", { type: "button", title: atomicCommandTitle(command, uiLocale), "aria-label": atomicCommandTitle(command, uiLocale), onClick: () => runAndClose((runtime) => runtime.insertAtomicCommand(command.id)), children: /* @__PURE__ */ jsxs(
10514
+ "span",
10515
+ {
10516
+ className: `spacing-command-glyph spacing-command-glyph--${command.spacing.direction} spacing-command-glyph--level-${String(command.spacing.level)}`,
10517
+ "aria-hidden": "true",
10518
+ children: [
10519
+ command.spacing.direction === "negative" ? /* @__PURE__ */ jsx("span", { className: "spacing-command-glyph__arrow", children: spacingArrow(command, state.activeSide) }) : null,
10520
+ /* @__PURE__ */ jsx("span", { className: "spacing-command-glyph__bar" }),
10521
+ command.spacing.direction === "positive" ? /* @__PURE__ */ jsx("span", { className: "spacing-command-glyph__arrow", children: spacingArrow(command, state.activeSide) }) : null
10522
+ ]
10523
+ }
10524
+ ) }, command.id)) }) : null,
10525
+ sheetView === "digits" ? /* @__PURE__ */ jsx("div", { className: "butex-widget__sheet-choice-row", children: [
10526
+ { id: "western", label: "456" },
10527
+ { id: "arabicIndic", label: "\u0664\u0665\u0666" },
10528
+ { id: "persianIndic", label: "\u06F4\u06F5\u06F6" }
10529
+ ].map((option) => /* @__PURE__ */ jsx(
10530
+ "button",
10531
+ {
10532
+ type: "button",
10533
+ "aria-pressed": state.digitForm === option.id,
10534
+ title: digitTitle(option.id, messages),
10535
+ onClick: (event) => runAndKeepFocus(event.currentTarget, (runtime) => runtime.setCurrentDigitForm(option.id)),
10536
+ children: option.label
10537
+ },
10538
+ option.id
10539
+ )) }) : null
10540
+ ] })
10541
+ ]
10542
+ }
10543
+ )
10544
+ }
10545
+ ) : null
10546
+ ] });
9374
10547
  }
9375
10548
 
9376
- // src/uiLocale.ts
9377
- function uiLocaleDirection(locale) {
9378
- return locale === "ar" ? "rtl" : "ltr";
10549
+ // src/react/visibleViewport.ts
10550
+ function positiveFinite(value, fallback) {
10551
+ return Number.isFinite(value) && value > 0 ? value : fallback;
9379
10552
  }
9380
-
9381
- // src/debugJson.ts
9382
- function lineColumnForPosition(text, position) {
9383
- const before = text.slice(0, Math.max(0, position));
9384
- const lines = before.split("\n");
10553
+ function finiteOffset(value) {
10554
+ return Number.isFinite(value) ? value : 0;
10555
+ }
10556
+ function visibleViewportSnapshot(view) {
10557
+ const fallbackWidth = positiveFinite(view.innerWidth, 1);
10558
+ const fallbackHeight = positiveFinite(view.innerHeight, 1);
10559
+ const visualViewport = view.visualViewport;
10560
+ if (visualViewport && Number.isFinite(visualViewport.width) && visualViewport.width > 0 && Number.isFinite(visualViewport.height) && visualViewport.height > 0) {
10561
+ return {
10562
+ width: visualViewport.width,
10563
+ height: visualViewport.height,
10564
+ offsetLeft: finiteOffset(visualViewport.offsetLeft),
10565
+ offsetTop: finiteOffset(visualViewport.offsetTop),
10566
+ scale: positiveFinite(visualViewport.scale, 1),
10567
+ source: "visual-viewport"
10568
+ };
10569
+ }
9385
10570
  return {
9386
- line: lines.length,
9387
- column: (lines[lines.length - 1]?.length ?? 0) + 1
10571
+ width: fallbackWidth,
10572
+ height: fallbackHeight,
10573
+ offsetLeft: 0,
10574
+ offsetTop: 0,
10575
+ scale: 1,
10576
+ source: "layout-viewport"
9388
10577
  };
9389
10578
  }
9390
- function parseJsonDebugInput(text) {
9391
- try {
9392
- return { ok: true, value: JSON.parse(text) };
9393
- } catch (error) {
9394
- const message = error instanceof Error ? error.message : String(error);
9395
- const positionMatch = message.match(/position\s+(\d+)/i);
9396
- if (positionMatch) {
9397
- const position = Number(positionMatch[1]);
9398
- if (Number.isFinite(position)) {
9399
- const location = lineColumnForPosition(text, position);
9400
- return { ok: false, error: `Invalid JSON at line ${String(location.line)}, column ${String(location.column)}: ${message}` };
9401
- }
10579
+ function reasonPriority(reason) {
10580
+ if (reason === "orientation") return 3;
10581
+ if (reason === "resize") return 2;
10582
+ if (reason === "scroll") return 1;
10583
+ return 0;
10584
+ }
10585
+ function observeVisibleViewport(view, onChange) {
10586
+ let previous = visibleViewportSnapshot(view);
10587
+ let frame = null;
10588
+ let pendingReason = "scroll";
10589
+ onChange({
10590
+ snapshot: previous,
10591
+ initial: true,
10592
+ sizeChanged: false,
10593
+ offsetChanged: false,
10594
+ reason: "initial"
10595
+ });
10596
+ const emit = () => {
10597
+ frame = null;
10598
+ const next = visibleViewportSnapshot(view);
10599
+ const sizeChanged = next.width !== previous.width || next.height !== previous.height || next.scale !== previous.scale || next.source !== previous.source;
10600
+ const offsetChanged = next.offsetLeft !== previous.offsetLeft || next.offsetTop !== previous.offsetTop;
10601
+ const reason = pendingReason;
10602
+ pendingReason = "scroll";
10603
+ previous = next;
10604
+ onChange({ snapshot: next, initial: false, sizeChanged, offsetChanged, reason });
10605
+ };
10606
+ const schedule = (reason) => {
10607
+ if (reasonPriority(reason) > reasonPriority(pendingReason)) {
10608
+ pendingReason = reason;
9402
10609
  }
9403
- return { ok: false, error: `Invalid JSON: ${message}` };
10610
+ if (frame !== null) {
10611
+ return;
10612
+ }
10613
+ frame = view.requestAnimationFrame(emit);
10614
+ };
10615
+ const onResize = () => schedule("resize");
10616
+ const onScroll = () => schedule("scroll");
10617
+ const onOrientation = () => schedule("orientation");
10618
+ const visualViewport = view.visualViewport;
10619
+ visualViewport?.addEventListener("resize", onResize);
10620
+ visualViewport?.addEventListener("scroll", onScroll);
10621
+ view.addEventListener("resize", onResize);
10622
+ view.addEventListener("orientationchange", onOrientation);
10623
+ return () => {
10624
+ visualViewport?.removeEventListener("resize", onResize);
10625
+ visualViewport?.removeEventListener("scroll", onScroll);
10626
+ view.removeEventListener("resize", onResize);
10627
+ view.removeEventListener("orientationchange", onOrientation);
10628
+ if (frame !== null) {
10629
+ view.cancelAnimationFrame(frame);
10630
+ frame = null;
10631
+ }
10632
+ };
10633
+ }
10634
+
10635
+ // src/react/desktopPopover.ts
10636
+ import { useEffect as useEffect3 } from "react";
10637
+ var POPOVER_GAP = 5;
10638
+ var VIEWPORT_MARGIN = 8;
10639
+ var MIN_USABLE_HEIGHT = 96;
10640
+ function clearPlacement(popover) {
10641
+ for (const property of ["position", "inset", "left", "top", "right", "bottom", "max-width", "max-height"]) {
10642
+ popover.style.removeProperty(property);
9404
10643
  }
10644
+ delete popover.dataset.placement;
10645
+ }
10646
+ function useDesktopPopoverPlacement(rootRef, active, onClose) {
10647
+ useEffect3(() => {
10648
+ if (!active || typeof window === "undefined") {
10649
+ return;
10650
+ }
10651
+ const root = rootRef.current;
10652
+ const trigger = root?.querySelector('.butex-widget__desktop-toolbar button[aria-expanded="true"]');
10653
+ const popover = trigger?.parentElement?.querySelector(
10654
+ ':scope > [role="menu"], :scope > [role="listbox"], :scope > [role="dialog"]'
10655
+ );
10656
+ if (!root || !trigger || !popover) {
10657
+ return;
10658
+ }
10659
+ let frame = null;
10660
+ const place = () => {
10661
+ frame = null;
10662
+ clearPlacement(popover);
10663
+ popover.style.position = "fixed";
10664
+ popover.style.inset = "auto";
10665
+ const rootRect = root.getBoundingClientRect();
10666
+ const scrollBoundary = root.closest(".butex-document2-widget__equation-modal-body");
10667
+ const scrollBoundaryRect = scrollBoundary?.getBoundingClientRect();
10668
+ const triggerRect = trigger.getBoundingClientRect();
10669
+ const boundaryLeft = Math.max(VIEWPORT_MARGIN, rootRect.left + VIEWPORT_MARGIN);
10670
+ const boundaryRight = Math.max(
10671
+ boundaryLeft + 1,
10672
+ Math.min(window.innerWidth - VIEWPORT_MARGIN, rootRect.right - VIEWPORT_MARGIN)
10673
+ );
10674
+ const boundaryTop = Math.max(VIEWPORT_MARGIN, (scrollBoundaryRect?.top ?? rootRect.top) + VIEWPORT_MARGIN);
10675
+ const boundaryBottom = Math.max(
10676
+ boundaryTop + 1,
10677
+ Math.min(window.innerHeight - VIEWPORT_MARGIN, (scrollBoundaryRect?.bottom ?? rootRect.bottom) - VIEWPORT_MARGIN)
10678
+ );
10679
+ const availableWidth = Math.max(1, boundaryRight - boundaryLeft);
10680
+ popover.style.maxWidth = `${availableWidth}px`;
10681
+ const naturalRect = popover.getBoundingClientRect();
10682
+ const popoverWidth = Math.min(Math.max(naturalRect.width, popover.scrollWidth), availableWidth);
10683
+ const preferredLeft = root.dir === "rtl" ? triggerRect.right - popoverWidth : triggerRect.left;
10684
+ const left = Math.min(Math.max(preferredLeft, boundaryLeft), boundaryRight - popoverWidth);
10685
+ const belowTop = triggerRect.bottom + POPOVER_GAP;
10686
+ const belowSpace = Math.max(0, boundaryBottom - belowTop);
10687
+ const aboveSpace = Math.max(0, triggerRect.top - boundaryTop - POPOVER_GAP);
10688
+ const naturalHeight = Math.max(naturalRect.height, popover.scrollHeight);
10689
+ const placeBelow = belowSpace >= Math.min(naturalHeight, MIN_USABLE_HEIGHT) || belowSpace >= aboveSpace;
10690
+ const availableHeight = placeBelow ? belowSpace : aboveSpace;
10691
+ const maxHeight = Math.max(1, availableHeight);
10692
+ const renderedHeight = Math.min(naturalHeight, maxHeight);
10693
+ const top = placeBelow ? belowTop : Math.max(boundaryTop, triggerRect.top - POPOVER_GAP - renderedHeight);
10694
+ popover.style.left = `${left}px`;
10695
+ popover.style.top = `${top}px`;
10696
+ popover.style.maxHeight = `${maxHeight}px`;
10697
+ popover.dataset.placement = placeBelow ? "below" : "above";
10698
+ };
10699
+ const schedulePlacement = () => {
10700
+ if (frame !== null) {
10701
+ window.cancelAnimationFrame(frame);
10702
+ }
10703
+ frame = window.requestAnimationFrame(place);
10704
+ };
10705
+ const handleKeyDown = (event) => {
10706
+ if (event.key === "Escape") {
10707
+ event.preventDefault();
10708
+ event.stopPropagation();
10709
+ onClose();
10710
+ window.requestAnimationFrame(() => trigger.focus());
10711
+ return;
10712
+ }
10713
+ if (!["ArrowDown", "ArrowUp", "ArrowLeft", "ArrowRight", "Home", "End"].includes(event.key)) {
10714
+ return;
10715
+ }
10716
+ if (popover.getAttribute("role") === "dialog") {
10717
+ return;
10718
+ }
10719
+ const items = Array.from(
10720
+ popover.querySelectorAll('[role="menuitem"]:not([disabled]), [role="option"]:not([disabled])')
10721
+ ).filter((item) => !item.hidden && item.getAttribute("aria-hidden") !== "true");
10722
+ if (items.length === 0 || event.target !== trigger && !popover.contains(event.target)) {
10723
+ return;
10724
+ }
10725
+ const currentIndex = items.indexOf(document.activeElement);
10726
+ let nextIndex;
10727
+ if (event.key === "Home") {
10728
+ nextIndex = 0;
10729
+ } else if (event.key === "End") {
10730
+ nextIndex = items.length - 1;
10731
+ } else if (event.key === "ArrowDown" || event.key === "ArrowRight") {
10732
+ nextIndex = currentIndex < 0 ? 0 : (currentIndex + 1) % items.length;
10733
+ } else {
10734
+ nextIndex = currentIndex < 0 ? items.length - 1 : (currentIndex - 1 + items.length) % items.length;
10735
+ }
10736
+ event.preventDefault();
10737
+ items[nextIndex]?.focus();
10738
+ };
10739
+ const closeOnOutsidePointer = (event) => {
10740
+ const target = event.target;
10741
+ if (target instanceof Node && !trigger.contains(target) && !popover.contains(target)) {
10742
+ onClose();
10743
+ }
10744
+ };
10745
+ const resizeObserver = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(schedulePlacement);
10746
+ resizeObserver?.observe(root);
10747
+ const toolbar = root.querySelector(".butex-widget__desktop-toolbar");
10748
+ if (toolbar) {
10749
+ resizeObserver?.observe(toolbar);
10750
+ }
10751
+ window.addEventListener("resize", schedulePlacement);
10752
+ window.addEventListener("scroll", schedulePlacement, true);
10753
+ window.visualViewport?.addEventListener("resize", schedulePlacement);
10754
+ window.visualViewport?.addEventListener("scroll", schedulePlacement);
10755
+ document.addEventListener("keydown", handleKeyDown, true);
10756
+ document.addEventListener("pointerdown", closeOnOutsidePointer, true);
10757
+ schedulePlacement();
10758
+ return () => {
10759
+ if (frame !== null) {
10760
+ window.cancelAnimationFrame(frame);
10761
+ }
10762
+ resizeObserver?.disconnect();
10763
+ window.removeEventListener("resize", schedulePlacement);
10764
+ window.removeEventListener("scroll", schedulePlacement, true);
10765
+ window.visualViewport?.removeEventListener("resize", schedulePlacement);
10766
+ window.visualViewport?.removeEventListener("scroll", schedulePlacement);
10767
+ document.removeEventListener("keydown", handleKeyDown, true);
10768
+ document.removeEventListener("pointerdown", closeOnOutsidePointer, true);
10769
+ clearPlacement(popover);
10770
+ };
10771
+ }, [active, onClose, rootRef]);
9405
10772
  }
9406
10773
 
9407
10774
  // src/react/ButexEditor.tsx
9408
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
10775
+ import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
9409
10776
  var DIGIT_FORM_OPTIONS = [
9410
10777
  { id: "western", label: "456" },
9411
10778
  { id: "arabicIndic", label: "\u0664\u0665\u0666" },
9412
10779
  { id: "persianIndic", label: "\u06F4\u06F5\u06F6" }
9413
10780
  ];
9414
10781
  var ACCENT_COMMANDS_LIST = accentCommandsList();
9415
- var FUNCTION_COMMANDS = atomicCommandsByCategory("function");
9416
- var LIMITS_SERIES_COMMANDS = atomicCommandsByCategory("limits_series");
9417
- var FUNCTION2_COMMANDS = atomicCommandsByCategory("function2");
9418
- var DERIVATIVE_COMMANDS = atomicCommandsByCategory("derivative");
9419
- var GROUP_COMMANDS = atomicCommandsByCategory("groups");
9420
- var SPACING_COMMANDS = atomicCommandsByCategory("spacing").filter(isSpacingCommandSpec);
10782
+ var FUNCTION_COMMANDS2 = atomicCommandsByCategory("function");
10783
+ var LIMITS_SERIES_COMMANDS2 = atomicCommandsByCategory("limits_series");
10784
+ var FUNCTION2_COMMANDS2 = atomicCommandsByCategory("function2");
10785
+ var DERIVATIVE_COMMANDS2 = atomicCommandsByCategory("derivative");
10786
+ var GROUP_COMMANDS2 = atomicCommandsByCategory("groups");
10787
+ var SPACING_COMMANDS2 = atomicCommandsByCategory("spacing").filter(isSpacingCommandSpec);
9421
10788
  var OPERATOR_COMMANDS = atomicOperatorCommandsByCategory("operators1");
9422
10789
  var OPERATOR2_COMMANDS = atomicOperatorCommandsByCategory("operators2");
9423
10790
  var OPERATOR3_COMMANDS = atomicOperatorCommandsByCategory("operators3");
9424
10791
  var DOT_COMMANDS = atomicOperatorCommandsByCategory("dots");
9425
10792
  var INTEGRAL_COMMANDS = atomicOperatorCommandsByCategory("integrals");
9426
- var MATRIX_STYLES = [
10793
+ var MATRIX_STYLES2 = [
9427
10794
  { id: "matrix", label: "\u25A1" },
9428
10795
  { id: "pmatrix", label: "(\u25A1)" },
9429
10796
  { id: "bmatrix", label: "[\u25A1]" },
@@ -9431,15 +10798,15 @@ var MATRIX_STYLES = [
9431
10798
  { id: "vmatrix", label: "|\u25A1|" },
9432
10799
  { id: "Vmatrix", label: "||\u25A1||" }
9433
10800
  ];
9434
- var ARRAY_ALIGNMENTS = [
10801
+ var ARRAY_ALIGNMENTS2 = [
9435
10802
  { id: "l" },
9436
10803
  { id: "c" },
9437
10804
  { id: "r" }
9438
10805
  ];
9439
- function matrixSizeLabel(rows, columns, messages) {
10806
+ function matrixSizeLabel2(rows, columns, messages) {
9440
10807
  return `${String(rows)} ${messages.row} \xD7 ${String(columns)} ${messages.column}`;
9441
10808
  }
9442
- function clampMatrixSize(value) {
10809
+ function clampMatrixSize2(value) {
9443
10810
  return Math.max(1, Math.min(12, Math.trunc(value)));
9444
10811
  }
9445
10812
  function digitFormLabel(digitForm) {
@@ -9448,7 +10815,7 @@ function digitFormLabel(digitForm) {
9448
10815
  function characterFontOption(fontId) {
9449
10816
  return CHARACTER_FONT_OPTIONS.find((option) => option.id === fontId) ?? CHARACTER_FONT_OPTIONS[0];
9450
10817
  }
9451
- function characterFontTitle(fontId, messages) {
10818
+ function characterFontTitle2(fontId, messages) {
9452
10819
  const key = characterFontSpec(fontId).titleKey;
9453
10820
  return messages[key] ?? messages.defaultFont;
9454
10821
  }
@@ -9457,7 +10824,7 @@ function digitFormTitle(digitForm, messages) {
9457
10824
  if (digitForm === "persianIndic") return messages.persianIndicDigits;
9458
10825
  return messages.westernDigits;
9459
10826
  }
9460
- function matrixStyleTitle(style, messages) {
10827
+ function matrixStyleTitle2(style, messages) {
9461
10828
  if (style === "pmatrix") return messages.matrixParentheses;
9462
10829
  if (style === "bmatrix") return messages.matrixBrackets;
9463
10830
  if (style === "Bmatrix") return messages.matrixBraces;
@@ -9470,7 +10837,7 @@ function alignmentCopy(alignment, messages) {
9470
10837
  if (alignment === "r") return { label: messages.alignRight, title: messages.alignColumnRight };
9471
10838
  return { label: messages.alignCenter, title: messages.alignColumnCenter };
9472
10839
  }
9473
- function spacingArrow(spec, side) {
10840
+ function spacingArrow2(spec, side) {
9474
10841
  const pointsWithFlow = spec.spacing.direction === "positive";
9475
10842
  if (pointsWithFlow) {
9476
10843
  return side === "arabic" ? "\u2190" : "\u2192";
@@ -9481,16 +10848,16 @@ function renderArabicCommandLabel(command) {
9481
10848
  if (command.id !== "ln") {
9482
10849
  return command.arabicLabel;
9483
10850
  }
9484
- return /* @__PURE__ */ jsxs("span", { className: "function-command-label-with-sub", "aria-hidden": "true", children: [
9485
- /* @__PURE__ */ jsx("span", { className: "function-command-label-with-sub__base", children: command.arabicLabel }),
9486
- /* @__PURE__ */ jsx("span", { className: "function-command-label-with-sub__sub", children: "\u0647\u0640" })
10851
+ return /* @__PURE__ */ jsxs2("span", { className: "function-command-label-with-sub", "aria-hidden": "true", children: [
10852
+ /* @__PURE__ */ jsx2("span", { className: "function-command-label-with-sub__base", children: command.arabicLabel }),
10853
+ /* @__PURE__ */ jsx2("span", { className: "function-command-label-with-sub__sub", children: "\u0647\u0640" })
9487
10854
  ] });
9488
10855
  }
9489
10856
  function renderOperatorCommandLabel(command) {
9490
10857
  if (!command.svg_path) {
9491
10858
  return command.Label;
9492
10859
  }
9493
- return /* @__PURE__ */ jsx(
10860
+ return /* @__PURE__ */ jsx2(
9494
10861
  "span",
9495
10862
  {
9496
10863
  className: "operator-command-svg-label",
@@ -9506,7 +10873,7 @@ function renderOperatorMenuButtonLabel(command, fallback) {
9506
10873
  if (!command) {
9507
10874
  return fallback;
9508
10875
  }
9509
- return /* @__PURE__ */ jsx("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) });
10876
+ return /* @__PURE__ */ jsx2("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) });
9510
10877
  }
9511
10878
  function passiveTreeText(session, messages) {
9512
10879
  const passive = session.activeSide === "arabic" ? session.englishTree : session.arabicTree;
@@ -9517,62 +10884,99 @@ function passiveTreeText(session, messages) {
9517
10884
  ${latex || messages.empty}`;
9518
10885
  }
9519
10886
  var ButexEditor = forwardRef(
9520
- function ButexEditor2({ className, debug = false, defaultSide, uiLocale = "ar", initialSession, onSessionChange }, ref) {
10887
+ function ButexEditor2({ className, debug = false, defaultSide, uiLocale = "ar", initialSession, onSessionChange, responsiveMode = "auto", showSideSwitcher = true }, ref) {
9521
10888
  const messages = equationEditorMessages(uiLocale);
10889
+ const previewPanelId = useId2();
9522
10890
  const debugEnabled = debug || typeof window !== "undefined" && new URLSearchParams(window.location.search).get("debug") === "1";
9523
- const wrapperRef = useRef(null);
9524
- const surfaceRef = useRef(null);
9525
- const inputRef = useRef(null);
9526
- const mathOutputRef = useRef(null);
9527
- const renderErrorRef = useRef(null);
9528
- const latexLinesRef = useRef(null);
9529
- const passivePreviewRef = useRef(null);
9530
- const debugLogRef = useRef(null);
9531
- const undoBtnRef = useRef(null);
9532
- const redoBtnRef = useRef(null);
9533
- const copyBtnRef = useRef(null);
9534
- const cutBtnRef = useRef(null);
9535
- const splitTypingBtnRef = useRef(null);
9536
- const characterFontBtnRef = useRef(null);
9537
- const digitFormBtnRef = useRef(null);
9538
- const runtimeRef = useRef(null);
9539
- const debugRef = useRef(debug);
10891
+ const wrapperRef = useRef3(null);
10892
+ const surfaceRef = useRef3(null);
10893
+ const inputRef = useRef3(null);
10894
+ const mathOutputRef = useRef3(null);
10895
+ const renderErrorRef = useRef3(null);
10896
+ const latexLinesRef = useRef3(null);
10897
+ const passivePreviewRef = useRef3(null);
10898
+ const debugLogRef = useRef3(null);
10899
+ const undoBtnRef = useRef3(null);
10900
+ const redoBtnRef = useRef3(null);
10901
+ const copyBtnRef = useRef3(null);
10902
+ const cutBtnRef = useRef3(null);
10903
+ const splitTypingBtnRef = useRef3(null);
10904
+ const characterFontBtnRef = useRef3(null);
10905
+ const digitFormBtnRef = useRef3(null);
10906
+ const runtimeRef = useRef3(null);
10907
+ const debugRef = useRef3(debug);
9540
10908
  debugRef.current = debugEnabled;
9541
- const uiLocaleRef = useRef(uiLocale);
10909
+ const uiLocaleRef = useRef3(uiLocale);
9542
10910
  uiLocaleRef.current = uiLocale;
9543
- const onSessionChangeRef = useRef(onSessionChange);
10911
+ const onSessionChangeRef = useRef3(onSessionChange);
9544
10912
  onSessionChangeRef.current = onSessionChange;
9545
- const debugBodyHiddenRef = useRef(false);
9546
- const [debugBodyHidden, setDebugBodyHidden] = useState(false);
10913
+ const debugBodyHiddenRef = useRef3(false);
10914
+ const [debugBodyHidden, setDebugBodyHidden] = useState2(false);
9547
10915
  debugBodyHiddenRef.current = debugBodyHidden;
9548
- const [debugImportOpen, setDebugImportOpen] = useState(false);
9549
- const [debugImportText, setDebugImportText] = useState("");
9550
- const [debugImportError, setDebugImportError] = useState("");
9551
- const [digitMenuOpen, setDigitMenuOpen] = useState(false);
9552
- const [characterFontMenuOpen, setCharacterFontMenuOpen] = useState(false);
9553
- const [delimiterMenuOpen, setDelimiterMenuOpen] = useState(false);
9554
- const [matrixMenuOpen, setMatrixMenuOpen] = useState(false);
9555
- const [spacingMenuOpen, setSpacingMenuOpen] = useState(false);
9556
- const [functionMenuOpen, setFunctionMenuOpen] = useState(false);
9557
- const [limitsSeriesMenuOpen, setLimitsSeriesMenuOpen] = useState(false);
9558
- const [function2MenuOpen, setFunction2MenuOpen] = useState(false);
9559
- const [derivativeMenuOpen, setDerivativeMenuOpen] = useState(false);
9560
- const [groupMenuOpen, setGroupMenuOpen] = useState(false);
9561
- const [operatorMenuOpen, setOperatorMenuOpen] = useState(false);
9562
- const [operator2MenuOpen, setOperator2MenuOpen] = useState(false);
9563
- const [operator3MenuOpen, setOperator3MenuOpen] = useState(false);
9564
- const [dotMenuOpen, setDotMenuOpen] = useState(false);
9565
- const [accentMenuOpen, setAccentMenuOpen] = useState(false);
9566
- const [integralMenuOpen, setIntegralMenuOpen] = useState(false);
9567
- const [selectedDigitForm2, setSelectedDigitForm] = useState("western");
9568
- const [selectedCharacterFont, setSelectedCharacterFont] = useState("default");
9569
- const [activeEditorSide, setActiveEditorSide] = useState("arabic");
9570
- const [envPaletteMode, setEnvPaletteMode] = useState("matrix");
9571
- const [matrixStyle, setMatrixStyle] = useState("pmatrix");
9572
- const [matrixRows, setMatrixRows] = useState(2);
9573
- const [matrixColumns, setMatrixColumns] = useState(2);
9574
- const [matrixHover, setMatrixHover] = useState(null);
9575
- const [arrayAlignmentColumn, setArrayAlignmentColumn] = useState(1);
10916
+ const [debugImportOpen, setDebugImportOpen] = useState2(false);
10917
+ const [debugImportText, setDebugImportText] = useState2("");
10918
+ const [debugImportError, setDebugImportError] = useState2("");
10919
+ const [openDesktopMenu, setOpenDesktopMenu] = useState2(null);
10920
+ const [selectedDigitForm2, setSelectedDigitForm] = useState2("western");
10921
+ const [selectedCharacterFont, setSelectedCharacterFont] = useState2("default");
10922
+ const [activeEditorSide, setActiveEditorSide] = useState2("arabic");
10923
+ const [compactPreviewOpen, setCompactPreviewOpen] = useState2(false);
10924
+ const [compactControlState, setCompactControlState] = useState2({
10925
+ canUndo: false,
10926
+ canRedo: false,
10927
+ hasSelection: false,
10928
+ splitLeafTyping: initialSession?.splitLeafTyping ?? true
10929
+ });
10930
+ const [envPaletteMode, setEnvPaletteMode] = useState2("matrix");
10931
+ const [matrixStyle, setMatrixStyle] = useState2("pmatrix");
10932
+ const [matrixRows, setMatrixRows] = useState2(2);
10933
+ const [matrixColumns, setMatrixColumns] = useState2(2);
10934
+ const [matrixHover, setMatrixHover] = useState2(null);
10935
+ const [arrayAlignmentColumn, setArrayAlignmentColumn] = useState2(1);
10936
+ const closeDesktopMenu = useCallback(() => setOpenDesktopMenu(null), []);
10937
+ useDesktopPopoverPlacement(wrapperRef, openDesktopMenu !== null, closeDesktopMenu);
10938
+ function desktopMenuOpen(menu) {
10939
+ return openDesktopMenu === menu;
10940
+ }
10941
+ function setDesktopMenuOpen(menu, value) {
10942
+ setOpenDesktopMenu((current) => {
10943
+ const isOpen = current === menu;
10944
+ const shouldOpen = typeof value === "function" ? value(isOpen) : value;
10945
+ return shouldOpen ? menu : isOpen ? null : current;
10946
+ });
10947
+ }
10948
+ const delimiterMenuOpen = desktopMenuOpen("delimiters");
10949
+ const matrixMenuOpen = desktopMenuOpen("matrix");
10950
+ const spacingMenuOpen = desktopMenuOpen("spacing");
10951
+ const functionMenuOpen = desktopMenuOpen("functions");
10952
+ const limitsSeriesMenuOpen = desktopMenuOpen("limitsSeries");
10953
+ const function2MenuOpen = desktopMenuOpen("functions2");
10954
+ const derivativeMenuOpen = desktopMenuOpen("derivatives");
10955
+ const groupMenuOpen = desktopMenuOpen("groups");
10956
+ const operatorMenuOpen = desktopMenuOpen("operators1");
10957
+ const operator2MenuOpen = desktopMenuOpen("operators2");
10958
+ const operator3MenuOpen = desktopMenuOpen("operators3");
10959
+ const dotMenuOpen = desktopMenuOpen("dots");
10960
+ const accentMenuOpen = desktopMenuOpen("accents");
10961
+ const integralMenuOpen = desktopMenuOpen("integrals");
10962
+ const characterFontMenuOpen = desktopMenuOpen("font");
10963
+ const digitMenuOpen = desktopMenuOpen("digits");
10964
+ const setDelimiterMenuOpen = (value) => setDesktopMenuOpen("delimiters", value);
10965
+ const setMatrixMenuOpen = (value) => setDesktopMenuOpen("matrix", value);
10966
+ const setSpacingMenuOpen = (value) => setDesktopMenuOpen("spacing", value);
10967
+ const setFunctionMenuOpen = (value) => setDesktopMenuOpen("functions", value);
10968
+ const setLimitsSeriesMenuOpen = (value) => setDesktopMenuOpen("limitsSeries", value);
10969
+ const setFunction2MenuOpen = (value) => setDesktopMenuOpen("functions2", value);
10970
+ const setDerivativeMenuOpen = (value) => setDesktopMenuOpen("derivatives", value);
10971
+ const setGroupMenuOpen = (value) => setDesktopMenuOpen("groups", value);
10972
+ const setOperatorMenuOpen = (value) => setDesktopMenuOpen("operators1", value);
10973
+ const setOperator2MenuOpen = (value) => setDesktopMenuOpen("operators2", value);
10974
+ const setOperator3MenuOpen = (value) => setDesktopMenuOpen("operators3", value);
10975
+ const setDotMenuOpen = (value) => setDesktopMenuOpen("dots", value);
10976
+ const setAccentMenuOpen = (value) => setDesktopMenuOpen("accents", value);
10977
+ const setIntegralMenuOpen = (value) => setDesktopMenuOpen("integrals", value);
10978
+ const setCharacterFontMenuOpen = (value) => setDesktopMenuOpen("font", value);
10979
+ const setDigitMenuOpen = (value) => setDesktopMenuOpen("digits", value);
9576
10980
  useImperativeHandle(ref, () => ({
9577
10981
  getRuntime: () => runtimeRef.current
9578
10982
  }));
@@ -9626,7 +11030,7 @@ ${arabic || currentMessages.empty}`;
9626
11030
  }
9627
11031
  }
9628
11032
  }, []);
9629
- const updatePreviewRef = useRef(updatePreview);
11033
+ const updatePreviewRef = useRef3(updatePreview);
9630
11034
  updatePreviewRef.current = updatePreview;
9631
11035
  async function copyDebugText(text) {
9632
11036
  try {
@@ -9676,7 +11080,7 @@ ${arabic || currentMessages.empty}`;
9676
11080
  setDebugImportError(importError instanceof Error ? importError.message : String(importError));
9677
11081
  }
9678
11082
  }
9679
- useEffect(() => {
11083
+ useEffect4(() => {
9680
11084
  injectWidgetChromeCss();
9681
11085
  injectBuTeXEditorStyles(typeof document !== "undefined" ? document : void 0);
9682
11086
  const surfaceEl = surfaceRef.current;
@@ -9697,11 +11101,28 @@ ${arabic || currentMessages.empty}`;
9697
11101
  splitTypingBtn: splitTypingBtnRef.current,
9698
11102
  digitFormBtn: digitFormBtnRef.current
9699
11103
  },
9700
- outsidePointerIgnoreSelectors: [".butex-widget .toolbar", "#btn-copy", "#btn-cut", "#btn-paste"],
11104
+ outsidePointerIgnoreSelectors: [
11105
+ ".butex-widget .toolbar",
11106
+ ".butex-widget__mobile-toolbar",
11107
+ ".butex-widget__command-sheet-backdrop",
11108
+ "#btn-copy",
11109
+ "#btn-cut",
11110
+ "#btn-paste"
11111
+ ],
9701
11112
  onSessionChange: (session) => {
9702
11113
  setSelectedDigitForm(session.currentDigitForm ?? "western");
9703
11114
  setSelectedCharacterFont(session.currentCharacterFont ?? "default");
9704
11115
  setActiveEditorSide(session.activeSide);
11116
+ const hasSelection = Boolean(session.selection && session.selection.anchorIndex !== session.selection.focusIndex);
11117
+ const nextCompactState = {
11118
+ canUndo: undoBtnRef.current?.disabled === false,
11119
+ canRedo: redoBtnRef.current?.disabled === false,
11120
+ hasSelection,
11121
+ splitLeafTyping: session.splitLeafTyping
11122
+ };
11123
+ setCompactControlState(
11124
+ (current) => current.canUndo === nextCompactState.canUndo && current.canRedo === nextCompactState.canRedo && current.hasSelection === nextCompactState.hasSelection && current.splitLeafTyping === nextCompactState.splitLeafTyping ? current : nextCompactState
11125
+ );
9705
11126
  onSessionChangeRef.current?.(session);
9706
11127
  void updatePreviewRef.current(session).catch((err) => {
9707
11128
  const message = err instanceof Error ? err.message : String(err);
@@ -9714,6 +11135,19 @@ ${arabic || currentMessages.empty}`;
9714
11135
  }
9715
11136
  });
9716
11137
  runtimeRef.current = runtime;
11138
+ let viewportRevealFrame = null;
11139
+ const stopViewportObserver = observeVisibleViewport(window, (change) => {
11140
+ if (change.initial || !change.sizeChanged && change.reason !== "orientation") {
11141
+ return;
11142
+ }
11143
+ if (viewportRevealFrame !== null) {
11144
+ window.cancelAnimationFrame(viewportRevealFrame);
11145
+ }
11146
+ viewportRevealFrame = window.requestAnimationFrame(() => {
11147
+ viewportRevealFrame = null;
11148
+ revealCaretInSurface(surfaceEl);
11149
+ });
11150
+ });
9717
11151
  if (typeof window !== "undefined" && window.MathJax?.startup?.promise) {
9718
11152
  window.MathJax.startup.promise.then(() => {
9719
11153
  runtime.render();
@@ -9729,11 +11163,15 @@ ${arabic || currentMessages.empty}`;
9729
11163
  }
9730
11164
  runtime.focusInput();
9731
11165
  return () => {
11166
+ stopViewportObserver();
11167
+ if (viewportRevealFrame !== null) {
11168
+ window.cancelAnimationFrame(viewportRevealFrame);
11169
+ }
9732
11170
  runtime.destroy();
9733
11171
  runtimeRef.current = null;
9734
11172
  };
9735
11173
  }, []);
9736
- useEffect(() => {
11174
+ useEffect4(() => {
9737
11175
  runtimeRef.current?.setUiLocale(uiLocale);
9738
11176
  const session = runtimeRef.current?.getSession();
9739
11177
  if (session) {
@@ -9752,24 +11190,43 @@ ${arabic || currentMessages.empty}`;
9752
11190
  runtimeRef.current?.insertMatrixEnv(matrixStyle, rows, columns);
9753
11191
  }
9754
11192
  }
9755
- return /* @__PURE__ */ jsx(
11193
+ const compactToolbarState = {
11194
+ ...compactControlState,
11195
+ activeSide: activeEditorSide,
11196
+ characterFont: selectedCharacterFont,
11197
+ digitForm: selectedDigitForm2
11198
+ };
11199
+ return /* @__PURE__ */ jsx2(
9756
11200
  "div",
9757
11201
  {
9758
11202
  ref: wrapperRef,
9759
11203
  className: `butex-widget ${className ?? ""}`.trim(),
11204
+ "data-compact-preview": compactPreviewOpen ? "open" : "closed",
11205
+ "data-responsive-mode": responsiveMode,
9760
11206
  dir: uiLocaleDirection(uiLocale),
9761
11207
  lang: uiLocale,
9762
- children: /* @__PURE__ */ jsxs("div", { className: "butex-widget-layout", children: [
9763
- /* @__PURE__ */ jsxs("section", { className: "panel", children: [
9764
- /* @__PURE__ */ jsxs("div", { className: "toolbar", children: [
9765
- /* @__PURE__ */ jsxs("div", { className: "toolbar-group toolbar-history", role: "group", "aria-label": messages.undoRedo, children: [
9766
- /* @__PURE__ */ jsx("button", { ref: undoBtnRef, id: "btn-undo", type: "button", className: "icon-btn", title: messages.undo, "aria-label": messages.undo, children: "\u21B7" }),
9767
- /* @__PURE__ */ jsx("button", { ref: redoBtnRef, id: "btn-redo", type: "button", className: "icon-btn", title: messages.redo, "aria-label": messages.redo, children: "\u21B6" })
11208
+ children: /* @__PURE__ */ jsxs2("div", { className: "butex-widget-layout", children: [
11209
+ /* @__PURE__ */ jsxs2("section", { className: "panel panel-editor", children: [
11210
+ /* @__PURE__ */ jsx2(
11211
+ EquationMobileToolbar,
11212
+ {
11213
+ uiLocale,
11214
+ messages,
11215
+ state: compactToolbarState,
11216
+ showSideSwitcher,
11217
+ inputRef,
11218
+ getRuntime: () => runtimeRef.current
11219
+ }
11220
+ ),
11221
+ /* @__PURE__ */ jsxs2("div", { className: "toolbar butex-widget__desktop-toolbar", children: [
11222
+ /* @__PURE__ */ jsxs2("div", { className: "toolbar-group toolbar-history", role: "group", "aria-label": messages.undoRedo, children: [
11223
+ /* @__PURE__ */ jsx2("button", { ref: undoBtnRef, id: "btn-undo", type: "button", className: "icon-btn", title: messages.undo, "aria-label": messages.undo, children: "\u21B7" }),
11224
+ /* @__PURE__ */ jsx2("button", { ref: redoBtnRef, id: "btn-redo", type: "button", className: "icon-btn", title: messages.redo, "aria-label": messages.redo, children: "\u21B6" })
9768
11225
  ] }),
9769
- /* @__PURE__ */ jsxs("div", { className: "toolbar-group toolbar-clipboard", role: "group", "aria-label": messages.clipboard, children: [
9770
- /* @__PURE__ */ jsx("button", { ref: copyBtnRef, id: "btn-copy", type: "button", className: "icon-btn", title: messages.copy, "aria-label": messages.copy, disabled: true, children: "\u29C9" }),
9771
- /* @__PURE__ */ jsx("button", { ref: cutBtnRef, id: "btn-cut", type: "button", className: "icon-btn", title: messages.cut, "aria-label": messages.cut, disabled: true, children: "\u2702" }),
9772
- /* @__PURE__ */ jsx(
11226
+ /* @__PURE__ */ jsxs2("div", { className: "toolbar-group toolbar-clipboard", role: "group", "aria-label": messages.clipboard, children: [
11227
+ /* @__PURE__ */ jsx2("button", { ref: copyBtnRef, id: "btn-copy", type: "button", className: "icon-btn", title: messages.copy, "aria-label": messages.copy, disabled: true, children: "\u29C9" }),
11228
+ /* @__PURE__ */ jsx2("button", { ref: cutBtnRef, id: "btn-cut", type: "button", className: "icon-btn", title: messages.cut, "aria-label": messages.cut, disabled: true, children: "\u2702" }),
11229
+ /* @__PURE__ */ jsx2(
9773
11230
  "button",
9774
11231
  {
9775
11232
  id: "btn-paste",
@@ -9786,9 +11243,9 @@ ${arabic || currentMessages.empty}`;
9786
11243
  }
9787
11244
  )
9788
11245
  ] }),
9789
- /* @__PURE__ */ jsx("div", { className: "toolbar-group toolbar-settings", role: "group", "aria-label": messages.editorSettings, children: /* @__PURE__ */ jsx("button", { className: "icon-btn accent", type: "button", title: messages.toggleSide, "aria-label": messages.toggleSide, onClick: () => runtimeRef.current?.toggleSide(), children: "\u21C4" }) }),
9790
- /* @__PURE__ */ jsxs("div", { className: "toolbar-group toolbar-structures", role: "group", "aria-label": messages.structures, children: [
9791
- /* @__PURE__ */ jsxs(
11246
+ showSideSwitcher ? /* @__PURE__ */ jsx2("div", { className: "toolbar-group toolbar-settings", role: "group", "aria-label": messages.editorSettings, children: /* @__PURE__ */ jsx2("button", { className: "icon-btn accent", type: "button", title: messages.toggleSide, "aria-label": messages.toggleSide, onClick: () => runtimeRef.current?.toggleSide(), children: "\u21C4" }) }) : null,
11247
+ /* @__PURE__ */ jsxs2("div", { className: "toolbar-group toolbar-structures", role: "group", "aria-label": messages.structures, children: [
11248
+ /* @__PURE__ */ jsxs2(
9792
11249
  "div",
9793
11250
  {
9794
11251
  className: "delimiter-command-menu",
@@ -9799,27 +11256,27 @@ ${arabic || currentMessages.empty}`;
9799
11256
  }
9800
11257
  },
9801
11258
  children: [
9802
- /* @__PURE__ */ jsx(
11259
+ /* @__PURE__ */ jsx2(
9803
11260
  "button",
9804
11261
  {
9805
11262
  className: "icon-btn delimiter-command-btn",
9806
11263
  type: "button",
9807
11264
  title: messages.insertDelimiters,
9808
11265
  "aria-label": messages.insertDelimiters,
9809
- "aria-haspopup": "listbox",
11266
+ "aria-haspopup": "menu",
9810
11267
  "aria-expanded": delimiterMenuOpen,
9811
11268
  onClick: () => setDelimiterMenuOpen((open) => !open),
9812
11269
  children: "()"
9813
11270
  }
9814
11271
  ),
9815
- /* @__PURE__ */ jsxs("div", { className: "delimiter-command-options", role: "listbox", "aria-label": messages.insertDelimiters, hidden: !delimiterMenuOpen, children: [
9816
- /* @__PURE__ */ jsx(
11272
+ /* @__PURE__ */ jsxs2("div", { className: "delimiter-command-options", role: "menu", "aria-label": messages.insertDelimiters, hidden: !delimiterMenuOpen, children: [
11273
+ /* @__PURE__ */ jsx2(
9817
11274
  "button",
9818
11275
  {
9819
11276
  className: "delimiter-command-option",
9820
11277
  "data-delim": "paren",
9821
11278
  type: "button",
9822
- role: "option",
11279
+ role: "menuitem",
9823
11280
  title: messages.insertParentheses,
9824
11281
  "aria-label": messages.insertParentheses,
9825
11282
  onMouseDown: (event) => event.preventDefault(),
@@ -9831,13 +11288,13 @@ ${arabic || currentMessages.empty}`;
9831
11288
  children: "()"
9832
11289
  }
9833
11290
  ),
9834
- /* @__PURE__ */ jsx(
11291
+ /* @__PURE__ */ jsx2(
9835
11292
  "button",
9836
11293
  {
9837
11294
  className: "delimiter-command-option",
9838
11295
  "data-delim": "bracket",
9839
11296
  type: "button",
9840
- role: "option",
11297
+ role: "menuitem",
9841
11298
  title: messages.insertBrackets,
9842
11299
  "aria-label": messages.insertBrackets,
9843
11300
  onMouseDown: (event) => event.preventDefault(),
@@ -9849,13 +11306,13 @@ ${arabic || currentMessages.empty}`;
9849
11306
  children: "[]"
9850
11307
  }
9851
11308
  ),
9852
- /* @__PURE__ */ jsx(
11309
+ /* @__PURE__ */ jsx2(
9853
11310
  "button",
9854
11311
  {
9855
11312
  className: "delimiter-command-option",
9856
11313
  "data-delim": "brace",
9857
11314
  type: "button",
9858
- role: "option",
11315
+ role: "menuitem",
9859
11316
  title: messages.insertBraces,
9860
11317
  "aria-label": messages.insertBraces,
9861
11318
  onMouseDown: (event) => event.preventDefault(),
@@ -9871,40 +11328,40 @@ ${arabic || currentMessages.empty}`;
9871
11328
  ]
9872
11329
  }
9873
11330
  ),
9874
- /* @__PURE__ */ jsx("button", { id: "insert-frac", className: "icon-btn frac-icon-btn", type: "button", title: messages.insertFraction, "aria-label": messages.insertFraction, onClick: () => {
11331
+ /* @__PURE__ */ jsx2("button", { id: "insert-frac", className: "icon-btn frac-icon-btn", type: "button", title: messages.insertFraction, "aria-label": messages.insertFraction, onClick: () => {
9875
11332
  runtimeRef.current?.insertFraction();
9876
11333
  focusSurface();
9877
- }, children: /* @__PURE__ */ jsxs("span", { className: "toolbar-frac-icon", "aria-hidden": "true", children: [
9878
- /* @__PURE__ */ jsx("span", { children: "\u0623" }),
9879
- /* @__PURE__ */ jsx("span", { children: "\u0628" })
11334
+ }, children: /* @__PURE__ */ jsxs2("span", { className: "toolbar-frac-icon", "aria-hidden": "true", children: [
11335
+ /* @__PURE__ */ jsx2("span", { children: "\u0623" }),
11336
+ /* @__PURE__ */ jsx2("span", { children: "\u0628" })
9880
11337
  ] }) }),
9881
- /* @__PURE__ */ jsx("button", { id: "insert-sqrt", className: "icon-btn", type: "button", title: messages.insertRoot, "aria-label": messages.insertRoot, onClick: () => {
11338
+ /* @__PURE__ */ jsx2("button", { id: "insert-sqrt", className: "icon-btn", type: "button", title: messages.insertRoot, "aria-label": messages.insertRoot, onClick: () => {
9882
11339
  runtimeRef.current?.insertSqrt();
9883
11340
  focusSurface();
9884
- }, children: /* @__PURE__ */ jsx("span", { className: "toolbar-sqrt-icon", "aria-hidden": "true", children: "\u221A" }) }),
9885
- /* @__PURE__ */ jsx("button", { id: "insert-overset", className: "icon-btn", type: "button", title: messages.insertOverset, "aria-label": messages.insertOverset, onClick: () => {
11341
+ }, children: /* @__PURE__ */ jsx2("span", { className: "toolbar-sqrt-icon", "aria-hidden": "true", children: "\u221A" }) }),
11342
+ /* @__PURE__ */ jsx2("button", { id: "insert-overset", className: "icon-btn", type: "button", title: messages.insertOverset, "aria-label": messages.insertOverset, onClick: () => {
9886
11343
  runtimeRef.current?.insertOverset();
9887
11344
  focusSurface();
9888
- }, children: /* @__PURE__ */ jsxs("span", { className: "toolbar-accent-icon toolbar-accent-icon--over", "aria-hidden": "true", children: [
9889
- /* @__PURE__ */ jsx("span", { children: "\u2217" }),
9890
- /* @__PURE__ */ jsx("span", { children: "\u25A1" })
11345
+ }, children: /* @__PURE__ */ jsxs2("span", { className: "toolbar-accent-icon toolbar-accent-icon--over", "aria-hidden": "true", children: [
11346
+ /* @__PURE__ */ jsx2("span", { children: "\u2217" }),
11347
+ /* @__PURE__ */ jsx2("span", { children: "\u25A1" })
9891
11348
  ] }) }),
9892
- /* @__PURE__ */ jsx("button", { id: "insert-underset", className: "icon-btn", type: "button", title: messages.insertUnderset, "aria-label": messages.insertUnderset, onClick: () => {
11349
+ /* @__PURE__ */ jsx2("button", { id: "insert-underset", className: "icon-btn", type: "button", title: messages.insertUnderset, "aria-label": messages.insertUnderset, onClick: () => {
9893
11350
  runtimeRef.current?.insertUnderset();
9894
11351
  focusSurface();
9895
- }, children: /* @__PURE__ */ jsxs("span", { className: "toolbar-accent-icon toolbar-accent-icon--under", "aria-hidden": "true", children: [
9896
- /* @__PURE__ */ jsx("span", { children: "\u25A1" }),
9897
- /* @__PURE__ */ jsx("span", { children: "\u2217" })
11352
+ }, children: /* @__PURE__ */ jsxs2("span", { className: "toolbar-accent-icon toolbar-accent-icon--under", "aria-hidden": "true", children: [
11353
+ /* @__PURE__ */ jsx2("span", { children: "\u25A1" }),
11354
+ /* @__PURE__ */ jsx2("span", { children: "\u2217" })
9898
11355
  ] }) }),
9899
- /* @__PURE__ */ jsx("button", { id: "insert-accent-pair", className: "icon-btn", type: "button", title: messages.insertAccentPair, "aria-label": messages.insertAccentPair, onClick: () => {
11356
+ /* @__PURE__ */ jsx2("button", { id: "insert-accent-pair", className: "icon-btn", type: "button", title: messages.insertAccentPair, "aria-label": messages.insertAccentPair, onClick: () => {
9900
11357
  runtimeRef.current?.insertAccentPair();
9901
11358
  focusSurface();
9902
- }, children: /* @__PURE__ */ jsxs("span", { className: "toolbar-accent-icon toolbar-accent-icon--pair", "aria-hidden": "true", children: [
9903
- /* @__PURE__ */ jsx("span", { children: "\u2217" }),
9904
- /* @__PURE__ */ jsx("span", { children: "\u25A1" }),
9905
- /* @__PURE__ */ jsx("span", { children: "\u2217" })
11359
+ }, children: /* @__PURE__ */ jsxs2("span", { className: "toolbar-accent-icon toolbar-accent-icon--pair", "aria-hidden": "true", children: [
11360
+ /* @__PURE__ */ jsx2("span", { children: "\u2217" }),
11361
+ /* @__PURE__ */ jsx2("span", { children: "\u25A1" }),
11362
+ /* @__PURE__ */ jsx2("span", { children: "\u2217" })
9906
11363
  ] }) }),
9907
- /* @__PURE__ */ jsxs(
11364
+ /* @__PURE__ */ jsxs2(
9908
11365
  "div",
9909
11366
  {
9910
11367
  className: "function-command-menu operator-command-menu",
@@ -9915,7 +11372,7 @@ ${arabic || currentMessages.empty}`;
9915
11372
  }
9916
11373
  },
9917
11374
  children: [
9918
- /* @__PURE__ */ jsx(
11375
+ /* @__PURE__ */ jsx2(
9919
11376
  "button",
9920
11377
  {
9921
11378
  id: "insert-accents",
@@ -9923,21 +11380,21 @@ ${arabic || currentMessages.empty}`;
9923
11380
  type: "button",
9924
11381
  title: messages.insertAccents,
9925
11382
  "aria-label": messages.insertAccents,
9926
- "aria-haspopup": "listbox",
11383
+ "aria-haspopup": "menu",
9927
11384
  "aria-expanded": accentMenuOpen,
9928
11385
  onClick: () => setAccentMenuOpen((open) => !open),
9929
- children: /* @__PURE__ */ jsxs("span", { className: "toolbar-accent-icon toolbar-accent-icon--over", "aria-hidden": "true", children: [
9930
- /* @__PURE__ */ jsx("span", { children: "\u02C6" }),
9931
- /* @__PURE__ */ jsx("span", { children: "\u25A1" })
11386
+ children: /* @__PURE__ */ jsxs2("span", { className: "toolbar-accent-icon toolbar-accent-icon--over", "aria-hidden": "true", children: [
11387
+ /* @__PURE__ */ jsx2("span", { children: "\u02C6" }),
11388
+ /* @__PURE__ */ jsx2("span", { children: "\u25A1" })
9932
11389
  ] })
9933
11390
  }
9934
11391
  ),
9935
- /* @__PURE__ */ jsx("div", { className: "function-command-options operator-command-options", role: "listbox", "aria-label": messages.insertAccents, hidden: !accentMenuOpen, children: ACCENT_COMMANDS_LIST.map((command) => /* @__PURE__ */ jsx(
11392
+ /* @__PURE__ */ jsx2("div", { className: "function-command-options operator-command-options", role: "menu", "aria-label": messages.insertAccents, hidden: !accentMenuOpen, children: ACCENT_COMMANDS_LIST.map((command) => /* @__PURE__ */ jsx2(
9936
11393
  "button",
9937
11394
  {
9938
11395
  className: "function-command-option operator-command-option",
9939
11396
  type: "button",
9940
- role: "option",
11397
+ role: "menuitem",
9941
11398
  title: accentCommandTitle(command, uiLocale),
9942
11399
  "aria-label": accentCommandTitle(command, uiLocale),
9943
11400
  onMouseDown: (event) => event.preventDefault(),
@@ -9946,7 +11403,7 @@ ${arabic || currentMessages.empty}`;
9946
11403
  setAccentMenuOpen(false);
9947
11404
  focusSurface();
9948
11405
  },
9949
- children: /* @__PURE__ */ jsx("span", { className: "operator-command-label", children: command.label })
11406
+ children: /* @__PURE__ */ jsx2("span", { className: "operator-command-label", children: command.label })
9950
11407
  },
9951
11408
  command.id
9952
11409
  )) })
@@ -9954,7 +11411,7 @@ ${arabic || currentMessages.empty}`;
9954
11411
  }
9955
11412
  )
9956
11413
  ] }),
9957
- /* @__PURE__ */ jsx("div", { className: "toolbar-group toolbar-environments", role: "group", "aria-label": messages.environments, children: /* @__PURE__ */ jsxs(
11414
+ /* @__PURE__ */ jsx2("div", { className: "toolbar-group toolbar-environments", role: "group", "aria-label": messages.environments, children: /* @__PURE__ */ jsxs2(
9958
11415
  "div",
9959
11416
  {
9960
11417
  className: "matrix-command-menu",
@@ -9965,7 +11422,7 @@ ${arabic || currentMessages.empty}`;
9965
11422
  }
9966
11423
  },
9967
11424
  children: [
9968
- /* @__PURE__ */ jsx(
11425
+ /* @__PURE__ */ jsx2(
9969
11426
  "button",
9970
11427
  {
9971
11428
  className: "icon-btn matrix-command-btn",
@@ -9975,20 +11432,20 @@ ${arabic || currentMessages.empty}`;
9975
11432
  "aria-haspopup": "dialog",
9976
11433
  "aria-expanded": matrixMenuOpen,
9977
11434
  onClick: () => setMatrixMenuOpen((open) => !open),
9978
- children: /* @__PURE__ */ jsxs("span", { className: "toolbar-matrix-icon", "aria-hidden": "true", children: [
9979
- /* @__PURE__ */ jsx("span", {}),
9980
- /* @__PURE__ */ jsx("span", {}),
9981
- /* @__PURE__ */ jsx("span", {}),
9982
- /* @__PURE__ */ jsx("span", {})
11435
+ children: /* @__PURE__ */ jsxs2("span", { className: "toolbar-matrix-icon", "aria-hidden": "true", children: [
11436
+ /* @__PURE__ */ jsx2("span", {}),
11437
+ /* @__PURE__ */ jsx2("span", {}),
11438
+ /* @__PURE__ */ jsx2("span", {}),
11439
+ /* @__PURE__ */ jsx2("span", {})
9983
11440
  ] })
9984
11441
  }
9985
11442
  ),
9986
- /* @__PURE__ */ jsxs("div", { className: "matrix-command-popover", role: "dialog", "aria-label": messages.insertEnvironment, hidden: !matrixMenuOpen, children: [
9987
- /* @__PURE__ */ jsx("div", { className: "matrix-style-options", role: "listbox", "aria-label": messages.environmentType, children: [
11443
+ /* @__PURE__ */ jsxs2("div", { className: "matrix-command-popover", role: "dialog", "aria-label": messages.insertEnvironment, hidden: !matrixMenuOpen, children: [
11444
+ /* @__PURE__ */ jsx2("div", { className: "matrix-style-options", role: "listbox", "aria-label": messages.environmentType, children: [
9988
11445
  { id: "matrix", label: messages.matrix },
9989
11446
  { id: "array", label: messages.array },
9990
11447
  { id: "aligned", label: messages.aligned }
9991
- ].map((option) => /* @__PURE__ */ jsx(
11448
+ ].map((option) => /* @__PURE__ */ jsx2(
9992
11449
  "button",
9993
11450
  {
9994
11451
  type: "button",
@@ -10006,14 +11463,14 @@ ${arabic || currentMessages.empty}`;
10006
11463
  },
10007
11464
  option.id
10008
11465
  )) }),
10009
- envPaletteMode === "matrix" ? /* @__PURE__ */ jsx("div", { className: "matrix-style-options", role: "listbox", "aria-label": messages.matrixType, children: MATRIX_STYLES.map((style) => /* @__PURE__ */ jsx(
11466
+ envPaletteMode === "matrix" ? /* @__PURE__ */ jsx2("div", { className: "matrix-style-options", role: "listbox", "aria-label": messages.matrixType, children: MATRIX_STYLES2.map((style) => /* @__PURE__ */ jsx2(
10010
11467
  "button",
10011
11468
  {
10012
11469
  type: "button",
10013
11470
  role: "option",
10014
11471
  "aria-selected": matrixStyle === style.id,
10015
11472
  className: "matrix-style-option",
10016
- title: matrixStyleTitle(style.id, messages),
11473
+ title: matrixStyleTitle2(style.id, messages),
10017
11474
  onMouseDown: (event) => event.preventDefault(),
10018
11475
  onClick: () => {
10019
11476
  setMatrixStyle(style.id);
@@ -10022,21 +11479,21 @@ ${arabic || currentMessages.empty}`;
10022
11479
  },
10023
11480
  style.id
10024
11481
  )) }) : null,
10025
- /* @__PURE__ */ jsx("div", { className: "matrix-size-readout", children: matrixHover ? matrixSizeLabel(matrixHover.rows, matrixHover.columns, messages) : matrixSizeLabel(matrixRows, matrixColumns, messages) }),
10026
- /* @__PURE__ */ jsx("div", { className: "matrix-grid-picker", "aria-label": messages.chooseEnvironmentSize, children: Array.from(
11482
+ /* @__PURE__ */ jsx2("div", { className: "matrix-size-readout", children: matrixHover ? matrixSizeLabel2(matrixHover.rows, matrixHover.columns, messages) : matrixSizeLabel2(matrixRows, matrixColumns, messages) }),
11483
+ /* @__PURE__ */ jsx2("div", { className: "matrix-grid-picker", "aria-label": messages.chooseEnvironmentSize, children: Array.from(
10027
11484
  { length: 8 },
10028
11485
  (_, rowIndex) => Array.from({ length: 8 }, (_2, columnIndex) => {
10029
11486
  const rows = rowIndex + 1;
10030
11487
  const columns = columnIndex + 1;
10031
11488
  const activeRows = matrixHover?.rows ?? matrixRows;
10032
11489
  const activeColumns = matrixHover?.columns ?? matrixColumns;
10033
- return /* @__PURE__ */ jsx(
11490
+ return /* @__PURE__ */ jsx2(
10034
11491
  "button",
10035
11492
  {
10036
11493
  type: "button",
10037
11494
  className: rows <= activeRows && columns <= activeColumns ? "matrix-grid-cell active" : "matrix-grid-cell",
10038
- title: matrixSizeLabel(rows, columns, messages),
10039
- "aria-label": matrixSizeLabel(rows, columns, messages),
11495
+ title: matrixSizeLabel2(rows, columns, messages),
11496
+ "aria-label": matrixSizeLabel2(rows, columns, messages),
10040
11497
  onMouseEnter: () => setMatrixHover({ rows, columns }),
10041
11498
  onMouseDown: (event) => event.preventDefault(),
10042
11499
  onClick: () => {
@@ -10052,42 +11509,42 @@ ${arabic || currentMessages.empty}`;
10052
11509
  );
10053
11510
  })
10054
11511
  ) }),
10055
- /* @__PURE__ */ jsxs("div", { className: "matrix-custom-size", children: [
10056
- /* @__PURE__ */ jsxs("label", { children: [
11512
+ /* @__PURE__ */ jsxs2("div", { className: "matrix-custom-size", children: [
11513
+ /* @__PURE__ */ jsxs2("label", { children: [
10057
11514
  messages.row,
10058
- /* @__PURE__ */ jsx(
11515
+ /* @__PURE__ */ jsx2(
10059
11516
  "input",
10060
11517
  {
10061
11518
  type: "number",
10062
11519
  min: 1,
10063
11520
  max: 12,
10064
11521
  value: matrixRows,
10065
- onChange: (event) => setMatrixRows(clampMatrixSize(Number(event.currentTarget.value) || 1))
11522
+ onChange: (event) => setMatrixRows(clampMatrixSize2(Number(event.currentTarget.value) || 1))
10066
11523
  }
10067
11524
  )
10068
11525
  ] }),
10069
- /* @__PURE__ */ jsxs("label", { children: [
11526
+ /* @__PURE__ */ jsxs2("label", { children: [
10070
11527
  messages.column,
10071
- /* @__PURE__ */ jsx(
11528
+ /* @__PURE__ */ jsx2(
10072
11529
  "input",
10073
11530
  {
10074
11531
  type: "number",
10075
11532
  min: 1,
10076
11533
  max: 12,
10077
11534
  value: matrixColumns,
10078
- onChange: (event) => setMatrixColumns(clampMatrixSize(Number(event.currentTarget.value) || 1))
11535
+ onChange: (event) => setMatrixColumns(clampMatrixSize2(Number(event.currentTarget.value) || 1))
10079
11536
  }
10080
11537
  )
10081
11538
  ] }),
10082
- /* @__PURE__ */ jsx(
11539
+ /* @__PURE__ */ jsx2(
10083
11540
  "button",
10084
11541
  {
10085
11542
  type: "button",
10086
11543
  className: "matrix-insert-custom",
10087
11544
  onMouseDown: (event) => event.preventDefault(),
10088
11545
  onClick: () => {
10089
- const rows = clampMatrixSize(matrixRows);
10090
- const columns = clampMatrixSize(matrixColumns);
11546
+ const rows = clampMatrixSize2(matrixRows);
11547
+ const columns = clampMatrixSize2(matrixColumns);
10091
11548
  insertSelectedEnvironment(rows, columns);
10092
11549
  setMatrixMenuOpen(false);
10093
11550
  setMatrixHover(null);
@@ -10097,23 +11554,23 @@ ${arabic || currentMessages.empty}`;
10097
11554
  }
10098
11555
  )
10099
11556
  ] }),
10100
- /* @__PURE__ */ jsxs("div", { className: "matrix-edit-actions", "aria-label": messages.editSelectedEnvironment, children: [
10101
- envPaletteMode === "matrix" ? /* @__PURE__ */ jsx("button", { type: "button", title: messages.applySelectedMatrixStyle, onMouseDown: (event) => event.preventDefault(), onClick: () => runtimeRef.current?.setMatrixEnvStyle(matrixStyle), children: messages.applyStyle }) : null,
10102
- envPaletteMode === "array" ? /* @__PURE__ */ jsxs(Fragment, { children: [
10103
- /* @__PURE__ */ jsxs("label", { children: [
11557
+ /* @__PURE__ */ jsxs2("div", { className: "matrix-edit-actions", "aria-label": messages.editSelectedEnvironment, children: [
11558
+ envPaletteMode === "matrix" ? /* @__PURE__ */ jsx2("button", { type: "button", title: messages.applySelectedMatrixStyle, onMouseDown: (event) => event.preventDefault(), onClick: () => runtimeRef.current?.setMatrixEnvStyle(matrixStyle), children: messages.applyStyle }) : null,
11559
+ envPaletteMode === "array" ? /* @__PURE__ */ jsxs2(Fragment2, { children: [
11560
+ /* @__PURE__ */ jsxs2("label", { children: [
10104
11561
  messages.column,
10105
- /* @__PURE__ */ jsx(
11562
+ /* @__PURE__ */ jsx2(
10106
11563
  "input",
10107
11564
  {
10108
11565
  type: "number",
10109
11566
  min: 1,
10110
11567
  max: 12,
10111
11568
  value: arrayAlignmentColumn,
10112
- onChange: (event) => setArrayAlignmentColumn(clampMatrixSize(Number(event.currentTarget.value) || 1))
11569
+ onChange: (event) => setArrayAlignmentColumn(clampMatrixSize2(Number(event.currentTarget.value) || 1))
10113
11570
  }
10114
11571
  )
10115
11572
  ] }),
10116
- ARRAY_ALIGNMENTS.map((alignment) => /* @__PURE__ */ jsx(
11573
+ ARRAY_ALIGNMENTS2.map((alignment) => /* @__PURE__ */ jsx2(
10117
11574
  "button",
10118
11575
  {
10119
11576
  type: "button",
@@ -10125,19 +11582,19 @@ ${arabic || currentMessages.empty}`;
10125
11582
  alignment.id
10126
11583
  ))
10127
11584
  ] }) : null,
10128
- /* @__PURE__ */ jsxs("button", { type: "button", title: messages.addRow, onMouseDown: (event) => event.preventDefault(), onClick: () => runtimeRef.current?.addMatrixRow(), children: [
11585
+ /* @__PURE__ */ jsxs2("button", { type: "button", title: messages.addRow, onMouseDown: (event) => event.preventDefault(), onClick: () => runtimeRef.current?.addMatrixRow(), children: [
10129
11586
  "+",
10130
11587
  messages.row
10131
11588
  ] }),
10132
- /* @__PURE__ */ jsxs("button", { type: "button", title: messages.removeRow, onMouseDown: (event) => event.preventDefault(), onClick: () => runtimeRef.current?.removeMatrixRow(), children: [
11589
+ /* @__PURE__ */ jsxs2("button", { type: "button", title: messages.removeRow, onMouseDown: (event) => event.preventDefault(), onClick: () => runtimeRef.current?.removeMatrixRow(), children: [
10133
11590
  "-",
10134
11591
  messages.row
10135
11592
  ] }),
10136
- /* @__PURE__ */ jsxs("button", { type: "button", title: messages.addColumn, onMouseDown: (event) => event.preventDefault(), onClick: () => runtimeRef.current?.addMatrixColumn(), children: [
11593
+ /* @__PURE__ */ jsxs2("button", { type: "button", title: messages.addColumn, onMouseDown: (event) => event.preventDefault(), onClick: () => runtimeRef.current?.addMatrixColumn(), children: [
10137
11594
  "+",
10138
11595
  messages.column
10139
11596
  ] }),
10140
- /* @__PURE__ */ jsxs("button", { type: "button", title: messages.removeColumn, onMouseDown: (event) => event.preventDefault(), onClick: () => runtimeRef.current?.removeMatrixColumn(), children: [
11597
+ /* @__PURE__ */ jsxs2("button", { type: "button", title: messages.removeColumn, onMouseDown: (event) => event.preventDefault(), onClick: () => runtimeRef.current?.removeMatrixColumn(), children: [
10141
11598
  "-",
10142
11599
  messages.column
10143
11600
  ] })
@@ -10146,7 +11603,7 @@ ${arabic || currentMessages.empty}`;
10146
11603
  ]
10147
11604
  }
10148
11605
  ) }),
10149
- /* @__PURE__ */ jsx("div", { className: "toolbar-group toolbar-settings", role: "group", "aria-label": messages.spaces, children: /* @__PURE__ */ jsxs(
11606
+ /* @__PURE__ */ jsx2("div", { className: "toolbar-group toolbar-settings", role: "group", "aria-label": messages.spaces, children: /* @__PURE__ */ jsxs2(
10150
11607
  "div",
10151
11608
  {
10152
11609
  className: `spacing-command-menu spacing-command-menu--${activeEditorSide}`,
@@ -10157,27 +11614,27 @@ ${arabic || currentMessages.empty}`;
10157
11614
  }
10158
11615
  },
10159
11616
  children: [
10160
- /* @__PURE__ */ jsx(
11617
+ /* @__PURE__ */ jsx2(
10161
11618
  "button",
10162
11619
  {
10163
11620
  className: "icon-btn spacing-command-btn",
10164
11621
  type: "button",
10165
11622
  title: messages.insertSpace,
10166
11623
  "aria-label": messages.insertSpace,
10167
- "aria-haspopup": "listbox",
11624
+ "aria-haspopup": "menu",
10168
11625
  "aria-expanded": spacingMenuOpen,
10169
11626
  onClick: () => setSpacingMenuOpen((open) => !open),
10170
- children: /* @__PURE__ */ jsxs("span", { className: "spacing-command-glyph spacing-command-glyph--positive spacing-command-glyph--level-2", "aria-hidden": "true", children: [
10171
- /* @__PURE__ */ jsx("span", { className: "spacing-command-glyph__bar" }),
10172
- /* @__PURE__ */ jsx("span", { className: "spacing-command-glyph__arrow", children: activeEditorSide === "arabic" ? "\u2190" : "\u2192" })
11627
+ children: /* @__PURE__ */ jsxs2("span", { className: "spacing-command-glyph spacing-command-glyph--positive spacing-command-glyph--level-2", "aria-hidden": "true", children: [
11628
+ /* @__PURE__ */ jsx2("span", { className: "spacing-command-glyph__bar" }),
11629
+ /* @__PURE__ */ jsx2("span", { className: "spacing-command-glyph__arrow", children: activeEditorSide === "arabic" ? "\u2190" : "\u2192" })
10173
11630
  ] })
10174
11631
  }
10175
11632
  ),
10176
- /* @__PURE__ */ jsx("div", { className: "spacing-command-options", role: "listbox", "aria-label": messages.insertSpace, hidden: !spacingMenuOpen, children: SPACING_COMMANDS.map((command) => /* @__PURE__ */ jsxs(
11633
+ /* @__PURE__ */ jsx2("div", { className: "spacing-command-options", role: "menu", "aria-label": messages.insertSpace, hidden: !spacingMenuOpen, children: SPACING_COMMANDS2.map((command) => /* @__PURE__ */ jsxs2(
10177
11634
  "button",
10178
11635
  {
10179
11636
  type: "button",
10180
- role: "option",
11637
+ role: "menuitem",
10181
11638
  className: `spacing-command-option spacing-command-option--${command.spacing.direction}`,
10182
11639
  title: atomicCommandTitle(command, uiLocale),
10183
11640
  onMouseDown: (event) => event.preventDefault(),
@@ -10187,12 +11644,12 @@ ${arabic || currentMessages.empty}`;
10187
11644
  focusSurface();
10188
11645
  },
10189
11646
  children: [
10190
- /* @__PURE__ */ jsxs("span", { className: `spacing-command-glyph spacing-command-glyph--${command.spacing.direction} spacing-command-glyph--level-${String(command.spacing.level)}`, "aria-hidden": "true", children: [
10191
- command.spacing.direction === "negative" ? /* @__PURE__ */ jsx("span", { className: "spacing-command-glyph__arrow", children: spacingArrow(command, activeEditorSide) }) : null,
10192
- /* @__PURE__ */ jsx("span", { className: "spacing-command-glyph__bar" }),
10193
- command.spacing.direction === "positive" ? /* @__PURE__ */ jsx("span", { className: "spacing-command-glyph__arrow", children: spacingArrow(command, activeEditorSide) }) : null
11647
+ /* @__PURE__ */ jsxs2("span", { className: `spacing-command-glyph spacing-command-glyph--${command.spacing.direction} spacing-command-glyph--level-${String(command.spacing.level)}`, "aria-hidden": "true", children: [
11648
+ command.spacing.direction === "negative" ? /* @__PURE__ */ jsx2("span", { className: "spacing-command-glyph__arrow", children: spacingArrow2(command, activeEditorSide) }) : null,
11649
+ /* @__PURE__ */ jsx2("span", { className: "spacing-command-glyph__bar" }),
11650
+ command.spacing.direction === "positive" ? /* @__PURE__ */ jsx2("span", { className: "spacing-command-glyph__arrow", children: spacingArrow2(command, activeEditorSide) }) : null
10194
11651
  ] }),
10195
- /* @__PURE__ */ jsx("span", { className: "spacing-command-option__name", children: atomicCommandTitle(command, uiLocale) })
11652
+ /* @__PURE__ */ jsx2("span", { className: "spacing-command-option__name", children: atomicCommandTitle(command, uiLocale) })
10196
11653
  ]
10197
11654
  },
10198
11655
  command.id
@@ -10200,8 +11657,8 @@ ${arabic || currentMessages.empty}`;
10200
11657
  ]
10201
11658
  }
10202
11659
  ) }),
10203
- /* @__PURE__ */ jsxs("div", { className: "toolbar-group toolbar-functions", role: "group", "aria-label": messages.functions, children: [
10204
- /* @__PURE__ */ jsxs(
11660
+ /* @__PURE__ */ jsxs2("div", { className: "toolbar-group toolbar-functions", role: "group", "aria-label": messages.functions, children: [
11661
+ /* @__PURE__ */ jsxs2(
10205
11662
  "div",
10206
11663
  {
10207
11664
  className: "function-command-menu",
@@ -10212,25 +11669,25 @@ ${arabic || currentMessages.empty}`;
10212
11669
  }
10213
11670
  },
10214
11671
  children: [
10215
- /* @__PURE__ */ jsx(
11672
+ /* @__PURE__ */ jsx2(
10216
11673
  "button",
10217
11674
  {
10218
11675
  className: "icon-btn function-command-btn",
10219
11676
  type: "button",
10220
11677
  title: messages.insertFunction,
10221
11678
  "aria-label": messages.insertFunction,
10222
- "aria-haspopup": "listbox",
11679
+ "aria-haspopup": "menu",
10223
11680
  "aria-expanded": functionMenuOpen,
10224
11681
  onClick: () => setFunctionMenuOpen((open) => !open),
10225
- children: FUNCTION_COMMANDS[0]?.arabicLabel ?? "\u062F"
11682
+ children: FUNCTION_COMMANDS2[0]?.arabicLabel ?? "\u062F"
10226
11683
  }
10227
11684
  ),
10228
- /* @__PURE__ */ jsx("div", { className: "function-command-options", role: "listbox", "aria-label": messages.insertFunction, hidden: !functionMenuOpen, children: FUNCTION_COMMANDS.map((command) => /* @__PURE__ */ jsx(
11685
+ /* @__PURE__ */ jsx2("div", { className: "function-command-options", role: "menu", "aria-label": messages.insertFunction, hidden: !functionMenuOpen, children: FUNCTION_COMMANDS2.map((command) => /* @__PURE__ */ jsx2(
10229
11686
  "button",
10230
11687
  {
10231
11688
  className: "function-command-option",
10232
11689
  type: "button",
10233
- role: "option",
11690
+ role: "menuitem",
10234
11691
  title: atomicCommandTitle(command, uiLocale),
10235
11692
  "aria-label": atomicCommandTitle(command, uiLocale),
10236
11693
  onMouseDown: (event) => event.preventDefault(),
@@ -10246,7 +11703,7 @@ ${arabic || currentMessages.empty}`;
10246
11703
  ]
10247
11704
  }
10248
11705
  ),
10249
- /* @__PURE__ */ jsxs(
11706
+ /* @__PURE__ */ jsxs2(
10250
11707
  "div",
10251
11708
  {
10252
11709
  className: "function-command-menu function-command-menu--limits-series",
@@ -10257,25 +11714,25 @@ ${arabic || currentMessages.empty}`;
10257
11714
  }
10258
11715
  },
10259
11716
  children: [
10260
- /* @__PURE__ */ jsx(
11717
+ /* @__PURE__ */ jsx2(
10261
11718
  "button",
10262
11719
  {
10263
11720
  className: "icon-btn function-command-btn",
10264
11721
  type: "button",
10265
11722
  title: messages.insertLimitsSeries,
10266
11723
  "aria-label": messages.insertLimitsSeries,
10267
- "aria-haspopup": "listbox",
11724
+ "aria-haspopup": "menu",
10268
11725
  "aria-expanded": limitsSeriesMenuOpen,
10269
11726
  onClick: () => setLimitsSeriesMenuOpen((open) => !open),
10270
- children: LIMITS_SERIES_COMMANDS[0]?.arabicLabel ?? "\u062D\u062F"
11727
+ children: LIMITS_SERIES_COMMANDS2[0]?.arabicLabel ?? "\u062D\u062F"
10271
11728
  }
10272
11729
  ),
10273
- /* @__PURE__ */ jsx("div", { className: "function-command-options", role: "listbox", "aria-label": messages.insertLimitsSeries, hidden: !limitsSeriesMenuOpen, children: LIMITS_SERIES_COMMANDS.map((command) => /* @__PURE__ */ jsx(
11730
+ /* @__PURE__ */ jsx2("div", { className: "function-command-options", role: "menu", "aria-label": messages.insertLimitsSeries, hidden: !limitsSeriesMenuOpen, children: LIMITS_SERIES_COMMANDS2.map((command) => /* @__PURE__ */ jsx2(
10274
11731
  "button",
10275
11732
  {
10276
11733
  className: "function-command-option",
10277
11734
  type: "button",
10278
- role: "option",
11735
+ role: "menuitem",
10279
11736
  title: atomicCommandTitle(command, uiLocale),
10280
11737
  "aria-label": atomicCommandTitle(command, uiLocale),
10281
11738
  onMouseDown: (event) => event.preventDefault(),
@@ -10291,7 +11748,7 @@ ${arabic || currentMessages.empty}`;
10291
11748
  ]
10292
11749
  }
10293
11750
  ),
10294
- /* @__PURE__ */ jsxs(
11751
+ /* @__PURE__ */ jsxs2(
10295
11752
  "div",
10296
11753
  {
10297
11754
  className: "function-command-menu function-command-menu--function2",
@@ -10302,25 +11759,25 @@ ${arabic || currentMessages.empty}`;
10302
11759
  }
10303
11760
  },
10304
11761
  children: [
10305
- /* @__PURE__ */ jsx(
11762
+ /* @__PURE__ */ jsx2(
10306
11763
  "button",
10307
11764
  {
10308
11765
  className: "icon-btn function-command-btn",
10309
11766
  type: "button",
10310
11767
  title: messages.insertAdditionalFunctions,
10311
11768
  "aria-label": messages.insertAdditionalFunctions,
10312
- "aria-haspopup": "listbox",
11769
+ "aria-haspopup": "menu",
10313
11770
  "aria-expanded": function2MenuOpen,
10314
11771
  onClick: () => setFunction2MenuOpen((open) => !open),
10315
- children: FUNCTION2_COMMANDS[0]?.arabicLabel ?? "\u062F"
11772
+ children: FUNCTION2_COMMANDS2[0]?.arabicLabel ?? "\u062F"
10316
11773
  }
10317
11774
  ),
10318
- /* @__PURE__ */ jsx("div", { className: "function-command-options", role: "listbox", "aria-label": messages.insertAdditionalFunctions, hidden: !function2MenuOpen, children: FUNCTION2_COMMANDS.map((command) => /* @__PURE__ */ jsx(
11775
+ /* @__PURE__ */ jsx2("div", { className: "function-command-options", role: "menu", "aria-label": messages.insertAdditionalFunctions, hidden: !function2MenuOpen, children: FUNCTION2_COMMANDS2.map((command) => /* @__PURE__ */ jsx2(
10319
11776
  "button",
10320
11777
  {
10321
11778
  className: "function-command-option",
10322
11779
  type: "button",
10323
- role: "option",
11780
+ role: "menuitem",
10324
11781
  title: atomicCommandTitle(command, uiLocale),
10325
11782
  "aria-label": atomicCommandTitle(command, uiLocale),
10326
11783
  onMouseDown: (event) => event.preventDefault(),
@@ -10336,7 +11793,7 @@ ${arabic || currentMessages.empty}`;
10336
11793
  ]
10337
11794
  }
10338
11795
  ),
10339
- /* @__PURE__ */ jsxs(
11796
+ /* @__PURE__ */ jsxs2(
10340
11797
  "div",
10341
11798
  {
10342
11799
  className: "function-command-menu function-command-menu--derivative",
@@ -10347,26 +11804,26 @@ ${arabic || currentMessages.empty}`;
10347
11804
  }
10348
11805
  },
10349
11806
  children: [
10350
- /* @__PURE__ */ jsx(
11807
+ /* @__PURE__ */ jsx2(
10351
11808
  "button",
10352
11809
  {
10353
11810
  className: "icon-btn function-command-btn",
10354
11811
  type: "button",
10355
11812
  title: messages.insertDerivative,
10356
11813
  "aria-label": messages.insertDerivative,
10357
- "aria-haspopup": "listbox",
11814
+ "aria-haspopup": "menu",
10358
11815
  "aria-expanded": derivativeMenuOpen,
10359
11816
  onClick: () => setDerivativeMenuOpen((open) => !open),
10360
- children: DERIVATIVE_COMMANDS[0]?.arabicLabel ?? "\u0621"
11817
+ children: DERIVATIVE_COMMANDS2[0]?.arabicLabel ?? "\u0621"
10361
11818
  }
10362
11819
  ),
10363
- /* @__PURE__ */ jsxs("div", { className: "function-command-options", role: "listbox", "aria-label": messages.insertDerivative, hidden: !derivativeMenuOpen, children: [
10364
- DERIVATIVE_COMMANDS.map((command) => /* @__PURE__ */ jsx(
11820
+ /* @__PURE__ */ jsxs2("div", { className: "function-command-options", role: "menu", "aria-label": messages.insertDerivative, hidden: !derivativeMenuOpen, children: [
11821
+ DERIVATIVE_COMMANDS2.map((command) => /* @__PURE__ */ jsx2(
10365
11822
  "button",
10366
11823
  {
10367
11824
  className: "function-command-option",
10368
11825
  type: "button",
10369
- role: "option",
11826
+ role: "menuitem",
10370
11827
  title: atomicCommandTitle(command, uiLocale),
10371
11828
  "aria-label": atomicCommandTitle(command, uiLocale),
10372
11829
  onMouseDown: (event) => event.preventDefault(),
@@ -10379,12 +11836,12 @@ ${arabic || currentMessages.empty}`;
10379
11836
  },
10380
11837
  command.id
10381
11838
  )),
10382
- /* @__PURE__ */ jsx(
11839
+ /* @__PURE__ */ jsx2(
10383
11840
  "button",
10384
11841
  {
10385
11842
  className: "function-command-option",
10386
11843
  type: "button",
10387
- role: "option",
11844
+ role: "menuitem",
10388
11845
  title: messages.insertFirstDerivative,
10389
11846
  "aria-label": messages.insertFirstDerivative,
10390
11847
  onMouseDown: (event) => event.preventDefault(),
@@ -10396,12 +11853,12 @@ ${arabic || currentMessages.empty}`;
10396
11853
  children: "\u0621/\u0633"
10397
11854
  }
10398
11855
  ),
10399
- /* @__PURE__ */ jsx(
11856
+ /* @__PURE__ */ jsx2(
10400
11857
  "button",
10401
11858
  {
10402
11859
  className: "function-command-option",
10403
11860
  type: "button",
10404
- role: "option",
11861
+ role: "menuitem",
10405
11862
  title: messages.insertSecondDerivative,
10406
11863
  "aria-label": messages.insertSecondDerivative,
10407
11864
  onMouseDown: (event) => event.preventDefault(),
@@ -10417,7 +11874,7 @@ ${arabic || currentMessages.empty}`;
10417
11874
  ]
10418
11875
  }
10419
11876
  ),
10420
- /* @__PURE__ */ jsxs(
11877
+ /* @__PURE__ */ jsxs2(
10421
11878
  "div",
10422
11879
  {
10423
11880
  className: "function-command-menu function-command-menu--groups",
@@ -10428,25 +11885,25 @@ ${arabic || currentMessages.empty}`;
10428
11885
  }
10429
11886
  },
10430
11887
  children: [
10431
- /* @__PURE__ */ jsx(
11888
+ /* @__PURE__ */ jsx2(
10432
11889
  "button",
10433
11890
  {
10434
11891
  className: "icon-btn function-command-btn",
10435
11892
  type: "button",
10436
11893
  title: messages.insertNumberSets,
10437
11894
  "aria-label": messages.insertNumberSets,
10438
- "aria-haspopup": "listbox",
11895
+ "aria-haspopup": "menu",
10439
11896
  "aria-expanded": groupMenuOpen,
10440
11897
  onClick: () => setGroupMenuOpen((open) => !open),
10441
- children: GROUP_COMMANDS[0]?.arabicLabel ?? "\u0645"
11898
+ children: GROUP_COMMANDS2[0]?.arabicLabel ?? "\u0645"
10442
11899
  }
10443
11900
  ),
10444
- /* @__PURE__ */ jsx("div", { className: "function-command-options", role: "listbox", "aria-label": messages.insertNumberSets, hidden: !groupMenuOpen, children: GROUP_COMMANDS.map((command) => /* @__PURE__ */ jsx(
11901
+ /* @__PURE__ */ jsx2("div", { className: "function-command-options", role: "menu", "aria-label": messages.insertNumberSets, hidden: !groupMenuOpen, children: GROUP_COMMANDS2.map((command) => /* @__PURE__ */ jsx2(
10445
11902
  "button",
10446
11903
  {
10447
11904
  className: "function-command-option",
10448
11905
  type: "button",
10449
- role: "option",
11906
+ role: "menuitem",
10450
11907
  title: atomicCommandTitle(command, uiLocale),
10451
11908
  "aria-label": atomicCommandTitle(command, uiLocale),
10452
11909
  onMouseDown: (event) => event.preventDefault(),
@@ -10463,8 +11920,8 @@ ${arabic || currentMessages.empty}`;
10463
11920
  }
10464
11921
  )
10465
11922
  ] }),
10466
- /* @__PURE__ */ jsxs("div", { className: "toolbar-group toolbar-operators", role: "group", "aria-label": messages.operations, children: [
10467
- /* @__PURE__ */ jsxs(
11923
+ /* @__PURE__ */ jsxs2("div", { className: "toolbar-group toolbar-operators", role: "group", "aria-label": messages.operations, children: [
11924
+ /* @__PURE__ */ jsxs2(
10468
11925
  "div",
10469
11926
  {
10470
11927
  className: "function-command-menu operator-command-menu",
@@ -10475,25 +11932,25 @@ ${arabic || currentMessages.empty}`;
10475
11932
  }
10476
11933
  },
10477
11934
  children: [
10478
- /* @__PURE__ */ jsx(
11935
+ /* @__PURE__ */ jsx2(
10479
11936
  "button",
10480
11937
  {
10481
11938
  className: "icon-btn function-command-btn operator-command-btn",
10482
11939
  type: "button",
10483
11940
  title: messages.insertOperation,
10484
11941
  "aria-label": messages.insertOperation,
10485
- "aria-haspopup": "listbox",
11942
+ "aria-haspopup": "menu",
10486
11943
  "aria-expanded": operatorMenuOpen,
10487
11944
  onClick: () => setOperatorMenuOpen((open) => !open),
10488
11945
  children: renderOperatorMenuButtonLabel(OPERATOR_COMMANDS[0], "\u2217")
10489
11946
  }
10490
11947
  ),
10491
- /* @__PURE__ */ jsx("div", { className: "function-command-options operator-command-options", role: "listbox", "aria-label": messages.insertOperation, hidden: !operatorMenuOpen, children: OPERATOR_COMMANDS.map((command) => /* @__PURE__ */ jsx(
11948
+ /* @__PURE__ */ jsx2("div", { className: "function-command-options operator-command-options", role: "menu", "aria-label": messages.insertOperation, hidden: !operatorMenuOpen, children: OPERATOR_COMMANDS.map((command) => /* @__PURE__ */ jsx2(
10492
11949
  "button",
10493
11950
  {
10494
11951
  className: "function-command-option operator-command-option",
10495
11952
  type: "button",
10496
- role: "option",
11953
+ role: "menuitem",
10497
11954
  title: atomicOperatorCommandTitle(command, uiLocale),
10498
11955
  "aria-label": atomicOperatorCommandTitle(command, uiLocale),
10499
11956
  onMouseDown: (event) => event.preventDefault(),
@@ -10502,14 +11959,14 @@ ${arabic || currentMessages.empty}`;
10502
11959
  setOperatorMenuOpen(false);
10503
11960
  focusSurface();
10504
11961
  },
10505
- children: /* @__PURE__ */ jsx("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) })
11962
+ children: /* @__PURE__ */ jsx2("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) })
10506
11963
  },
10507
11964
  command.id
10508
11965
  )) })
10509
11966
  ]
10510
11967
  }
10511
11968
  ),
10512
- /* @__PURE__ */ jsxs(
11969
+ /* @__PURE__ */ jsxs2(
10513
11970
  "div",
10514
11971
  {
10515
11972
  className: "function-command-menu operator-command-menu",
@@ -10520,25 +11977,25 @@ ${arabic || currentMessages.empty}`;
10520
11977
  }
10521
11978
  },
10522
11979
  children: [
10523
- /* @__PURE__ */ jsx(
11980
+ /* @__PURE__ */ jsx2(
10524
11981
  "button",
10525
11982
  {
10526
11983
  className: "icon-btn function-command-btn operator-command-btn",
10527
11984
  type: "button",
10528
11985
  title: messages.insertRelationsSets,
10529
11986
  "aria-label": messages.insertRelationsSets,
10530
- "aria-haspopup": "listbox",
11987
+ "aria-haspopup": "menu",
10531
11988
  "aria-expanded": operator2MenuOpen,
10532
11989
  onClick: () => setOperator2MenuOpen((open) => !open),
10533
11990
  children: "\u2229"
10534
11991
  }
10535
11992
  ),
10536
- /* @__PURE__ */ jsx("div", { className: "function-command-options operator-command-options", role: "listbox", "aria-label": messages.insertRelationsSets, hidden: !operator2MenuOpen, children: OPERATOR2_COMMANDS.map((command) => /* @__PURE__ */ jsx(
11993
+ /* @__PURE__ */ jsx2("div", { className: "function-command-options operator-command-options", role: "menu", "aria-label": messages.insertRelationsSets, hidden: !operator2MenuOpen, children: OPERATOR2_COMMANDS.map((command) => /* @__PURE__ */ jsx2(
10537
11994
  "button",
10538
11995
  {
10539
11996
  className: "function-command-option operator-command-option",
10540
11997
  type: "button",
10541
- role: "option",
11998
+ role: "menuitem",
10542
11999
  title: atomicOperatorCommandTitle(command, uiLocale),
10543
12000
  "aria-label": atomicOperatorCommandTitle(command, uiLocale),
10544
12001
  onMouseDown: (event) => event.preventDefault(),
@@ -10547,14 +12004,14 @@ ${arabic || currentMessages.empty}`;
10547
12004
  setOperator2MenuOpen(false);
10548
12005
  focusSurface();
10549
12006
  },
10550
- children: /* @__PURE__ */ jsx("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) })
12007
+ children: /* @__PURE__ */ jsx2("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) })
10551
12008
  },
10552
12009
  command.id
10553
12010
  )) })
10554
12011
  ]
10555
12012
  }
10556
12013
  ),
10557
- /* @__PURE__ */ jsxs(
12014
+ /* @__PURE__ */ jsxs2(
10558
12015
  "div",
10559
12016
  {
10560
12017
  className: "function-command-menu operator-command-menu",
@@ -10565,25 +12022,25 @@ ${arabic || currentMessages.empty}`;
10565
12022
  }
10566
12023
  },
10567
12024
  children: [
10568
- /* @__PURE__ */ jsx(
12025
+ /* @__PURE__ */ jsx2(
10569
12026
  "button",
10570
12027
  {
10571
12028
  className: "icon-btn function-command-btn operator-command-btn",
10572
12029
  type: "button",
10573
12030
  title: messages.insertArrows,
10574
12031
  "aria-label": messages.insertArrows,
10575
- "aria-haspopup": "listbox",
12032
+ "aria-haspopup": "menu",
10576
12033
  "aria-expanded": operator3MenuOpen,
10577
12034
  onClick: () => setOperator3MenuOpen((open) => !open),
10578
12035
  children: renderOperatorMenuButtonLabel(OPERATOR3_COMMANDS[0], "\u21D2")
10579
12036
  }
10580
12037
  ),
10581
- /* @__PURE__ */ jsx("div", { className: "function-command-options operator-command-options", role: "listbox", "aria-label": messages.insertArrows, hidden: !operator3MenuOpen, children: OPERATOR3_COMMANDS.map((command) => /* @__PURE__ */ jsx(
12038
+ /* @__PURE__ */ jsx2("div", { className: "function-command-options operator-command-options", role: "menu", "aria-label": messages.insertArrows, hidden: !operator3MenuOpen, children: OPERATOR3_COMMANDS.map((command) => /* @__PURE__ */ jsx2(
10582
12039
  "button",
10583
12040
  {
10584
12041
  className: "function-command-option operator-command-option",
10585
12042
  type: "button",
10586
- role: "option",
12043
+ role: "menuitem",
10587
12044
  title: atomicOperatorCommandTitle(command, uiLocale),
10588
12045
  "aria-label": atomicOperatorCommandTitle(command, uiLocale),
10589
12046
  onMouseDown: (event) => event.preventDefault(),
@@ -10592,14 +12049,14 @@ ${arabic || currentMessages.empty}`;
10592
12049
  setOperator3MenuOpen(false);
10593
12050
  focusSurface();
10594
12051
  },
10595
- children: /* @__PURE__ */ jsx("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) })
12052
+ children: /* @__PURE__ */ jsx2("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) })
10596
12053
  },
10597
12054
  command.id
10598
12055
  )) })
10599
12056
  ]
10600
12057
  }
10601
12058
  ),
10602
- /* @__PURE__ */ jsxs(
12059
+ /* @__PURE__ */ jsxs2(
10603
12060
  "div",
10604
12061
  {
10605
12062
  className: "function-command-menu operator-command-menu",
@@ -10610,25 +12067,25 @@ ${arabic || currentMessages.empty}`;
10610
12067
  }
10611
12068
  },
10612
12069
  children: [
10613
- /* @__PURE__ */ jsx(
12070
+ /* @__PURE__ */ jsx2(
10614
12071
  "button",
10615
12072
  {
10616
12073
  className: "icon-btn function-command-btn operator-command-btn",
10617
12074
  type: "button",
10618
12075
  title: messages.insertDots,
10619
12076
  "aria-label": messages.insertDots,
10620
- "aria-haspopup": "listbox",
12077
+ "aria-haspopup": "menu",
10621
12078
  "aria-expanded": dotMenuOpen,
10622
12079
  onClick: () => setDotMenuOpen((open) => !open),
10623
12080
  children: renderOperatorMenuButtonLabel(DOT_COMMANDS[0], "\u2026")
10624
12081
  }
10625
12082
  ),
10626
- /* @__PURE__ */ jsx("div", { className: "function-command-options operator-command-options", role: "listbox", "aria-label": messages.insertDots, hidden: !dotMenuOpen, children: DOT_COMMANDS.map((command) => /* @__PURE__ */ jsx(
12083
+ /* @__PURE__ */ jsx2("div", { className: "function-command-options operator-command-options", role: "menu", "aria-label": messages.insertDots, hidden: !dotMenuOpen, children: DOT_COMMANDS.map((command) => /* @__PURE__ */ jsx2(
10627
12084
  "button",
10628
12085
  {
10629
12086
  className: "function-command-option operator-command-option",
10630
12087
  type: "button",
10631
- role: "option",
12088
+ role: "menuitem",
10632
12089
  title: atomicOperatorCommandTitle(command, uiLocale),
10633
12090
  "aria-label": atomicOperatorCommandTitle(command, uiLocale),
10634
12091
  onMouseDown: (event) => event.preventDefault(),
@@ -10637,14 +12094,14 @@ ${arabic || currentMessages.empty}`;
10637
12094
  setDotMenuOpen(false);
10638
12095
  focusSurface();
10639
12096
  },
10640
- children: /* @__PURE__ */ jsx("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) })
12097
+ children: /* @__PURE__ */ jsx2("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) })
10641
12098
  },
10642
12099
  command.id
10643
12100
  )) })
10644
12101
  ]
10645
12102
  }
10646
12103
  ),
10647
- /* @__PURE__ */ jsxs(
12104
+ /* @__PURE__ */ jsxs2(
10648
12105
  "div",
10649
12106
  {
10650
12107
  className: "function-command-menu operator-command-menu",
@@ -10655,25 +12112,25 @@ ${arabic || currentMessages.empty}`;
10655
12112
  }
10656
12113
  },
10657
12114
  children: [
10658
- /* @__PURE__ */ jsx(
12115
+ /* @__PURE__ */ jsx2(
10659
12116
  "button",
10660
12117
  {
10661
12118
  className: "icon-btn function-command-btn operator-command-btn",
10662
12119
  type: "button",
10663
12120
  title: messages.insertIntegrals,
10664
12121
  "aria-label": messages.insertIntegrals,
10665
- "aria-haspopup": "listbox",
12122
+ "aria-haspopup": "menu",
10666
12123
  "aria-expanded": integralMenuOpen,
10667
12124
  onClick: () => setIntegralMenuOpen((open) => !open),
10668
12125
  children: renderOperatorMenuButtonLabel(INTEGRAL_COMMANDS[0], "\u222B")
10669
12126
  }
10670
12127
  ),
10671
- /* @__PURE__ */ jsx("div", { className: "function-command-options operator-command-options", role: "listbox", "aria-label": messages.insertIntegrals, hidden: !integralMenuOpen, children: INTEGRAL_COMMANDS.map((command) => /* @__PURE__ */ jsx(
12128
+ /* @__PURE__ */ jsx2("div", { className: "function-command-options operator-command-options", role: "menu", "aria-label": messages.insertIntegrals, hidden: !integralMenuOpen, children: INTEGRAL_COMMANDS.map((command) => /* @__PURE__ */ jsx2(
10672
12129
  "button",
10673
12130
  {
10674
12131
  className: "function-command-option operator-command-option",
10675
12132
  type: "button",
10676
- role: "option",
12133
+ role: "menuitem",
10677
12134
  title: atomicOperatorCommandTitle(command, uiLocale),
10678
12135
  "aria-label": atomicOperatorCommandTitle(command, uiLocale),
10679
12136
  onMouseDown: (event) => event.preventDefault(),
@@ -10682,7 +12139,7 @@ ${arabic || currentMessages.empty}`;
10682
12139
  setIntegralMenuOpen(false);
10683
12140
  focusSurface();
10684
12141
  },
10685
- children: /* @__PURE__ */ jsx("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) })
12142
+ children: /* @__PURE__ */ jsx2("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) })
10686
12143
  },
10687
12144
  command.id
10688
12145
  )) })
@@ -10690,28 +12147,28 @@ ${arabic || currentMessages.empty}`;
10690
12147
  }
10691
12148
  )
10692
12149
  ] }),
10693
- /* @__PURE__ */ jsxs("div", { className: "toolbar-group toolbar-scripts", role: "group", "aria-label": messages.scripts, children: [
10694
- /* @__PURE__ */ jsx("button", { className: "icon-btn script-icon-btn", type: "button", title: messages.addSuperscript, "aria-label": messages.addSuperscript, onClick: () => runtimeRef.current?.addSup(), children: /* @__PURE__ */ jsxs("span", { className: "toolbar-script-icon toolbar-script-icon--sup", "aria-hidden": "true", children: [
10695
- /* @__PURE__ */ jsx("span", { children: "\u0646" }),
10696
- /* @__PURE__ */ jsx("span", { children: "\u0633" })
12150
+ /* @__PURE__ */ jsxs2("div", { className: "toolbar-group toolbar-scripts", role: "group", "aria-label": messages.scripts, children: [
12151
+ /* @__PURE__ */ jsx2("button", { className: "icon-btn script-icon-btn", type: "button", title: messages.addSuperscript, "aria-label": messages.addSuperscript, onClick: () => runtimeRef.current?.addSup(), children: /* @__PURE__ */ jsxs2("span", { className: "toolbar-script-icon toolbar-script-icon--sup", "aria-hidden": "true", children: [
12152
+ /* @__PURE__ */ jsx2("span", { children: "\u0646" }),
12153
+ /* @__PURE__ */ jsx2("span", { children: "\u0633" })
10697
12154
  ] }) }),
10698
- /* @__PURE__ */ jsx("button", { className: "icon-btn script-icon-btn", type: "button", title: messages.addSubscript, "aria-label": messages.addSubscript, onClick: () => runtimeRef.current?.addSub(), children: /* @__PURE__ */ jsxs("span", { className: "toolbar-script-icon toolbar-script-icon--sub", "aria-hidden": "true", children: [
10699
- /* @__PURE__ */ jsx("span", { children: "\u0646" }),
10700
- /* @__PURE__ */ jsx("span", { children: "\u0633" })
12155
+ /* @__PURE__ */ jsx2("button", { className: "icon-btn script-icon-btn", type: "button", title: messages.addSubscript, "aria-label": messages.addSubscript, onClick: () => runtimeRef.current?.addSub(), children: /* @__PURE__ */ jsxs2("span", { className: "toolbar-script-icon toolbar-script-icon--sub", "aria-hidden": "true", children: [
12156
+ /* @__PURE__ */ jsx2("span", { children: "\u0646" }),
12157
+ /* @__PURE__ */ jsx2("span", { children: "\u0633" })
10701
12158
  ] }) }),
10702
- /* @__PURE__ */ jsx("button", { className: "icon-btn script-icon-btn remove-script-btn", type: "button", title: messages.removeSuperscript, "aria-label": messages.removeSuperscript, onClick: () => runtimeRef.current?.removeSup(), children: /* @__PURE__ */ jsxs("span", { className: "toolbar-remove-script-icon toolbar-remove-script-icon--sup", "aria-hidden": "true", children: [
10703
- /* @__PURE__ */ jsx("span", { children: "\u0646" }),
10704
- /* @__PURE__ */ jsx("span", { children: "\xD7" })
12159
+ /* @__PURE__ */ jsx2("button", { className: "icon-btn script-icon-btn remove-script-btn", type: "button", title: messages.removeSuperscript, "aria-label": messages.removeSuperscript, onClick: () => runtimeRef.current?.removeSup(), children: /* @__PURE__ */ jsxs2("span", { className: "toolbar-remove-script-icon toolbar-remove-script-icon--sup", "aria-hidden": "true", children: [
12160
+ /* @__PURE__ */ jsx2("span", { children: "\u0646" }),
12161
+ /* @__PURE__ */ jsx2("span", { children: "\xD7" })
10705
12162
  ] }) }),
10706
- /* @__PURE__ */ jsx("button", { className: "icon-btn script-icon-btn remove-script-btn", type: "button", title: messages.removeSubscript, "aria-label": messages.removeSubscript, onClick: () => runtimeRef.current?.removeSub(), children: /* @__PURE__ */ jsxs("span", { className: "toolbar-remove-script-icon toolbar-remove-script-icon--sub", "aria-hidden": "true", children: [
10707
- /* @__PURE__ */ jsx("span", { children: "\u0646" }),
10708
- /* @__PURE__ */ jsx("span", { children: "\xD7" })
12163
+ /* @__PURE__ */ jsx2("button", { className: "icon-btn script-icon-btn remove-script-btn", type: "button", title: messages.removeSubscript, "aria-label": messages.removeSubscript, onClick: () => runtimeRef.current?.removeSub(), children: /* @__PURE__ */ jsxs2("span", { className: "toolbar-remove-script-icon toolbar-remove-script-icon--sub", "aria-hidden": "true", children: [
12164
+ /* @__PURE__ */ jsx2("span", { children: "\u0646" }),
12165
+ /* @__PURE__ */ jsx2("span", { children: "\xD7" })
10709
12166
  ] }) })
10710
12167
  ] }),
10711
- /* @__PURE__ */ jsxs("div", { className: "toolbar-group toolbar-settings", role: "group", "aria-label": messages.inputStyles, children: [
10712
- /* @__PURE__ */ jsx("button", { className: "icon-btn delete-node-btn", type: "button", title: messages.deleteSelectedStructure, "aria-label": messages.deleteSelectedStructure, onClick: () => runtimeRef.current?.deleteStructure(), children: "\xD7" }),
10713
- /* @__PURE__ */ jsx("button", { ref: splitTypingBtnRef, id: "toggle-split-leaf-typing", className: "icon-btn ligature-btn", type: "button", title: messages.toggleLetterMerging, "aria-label": messages.toggleLetterMerging, onClick: () => runtimeRef.current?.toggleSplitLeafTyping(), children: "\u0633\u0635\u0639" }),
10714
- /* @__PURE__ */ jsxs(
12168
+ /* @__PURE__ */ jsxs2("div", { className: "toolbar-group toolbar-settings", role: "group", "aria-label": messages.inputStyles, children: [
12169
+ /* @__PURE__ */ jsx2("button", { className: "icon-btn delete-node-btn", type: "button", title: messages.deleteSelectedStructure, "aria-label": messages.deleteSelectedStructure, onClick: () => runtimeRef.current?.deleteStructure(), children: "\xD7" }),
12170
+ /* @__PURE__ */ jsx2("button", { ref: splitTypingBtnRef, id: "toggle-split-leaf-typing", className: "icon-btn ligature-btn", type: "button", title: messages.toggleLetterMerging, "aria-label": messages.toggleLetterMerging, onClick: () => runtimeRef.current?.toggleSplitLeafTyping(), children: "\u0633\u0635\u0639" }),
12171
+ /* @__PURE__ */ jsxs2(
10715
12172
  "div",
10716
12173
  {
10717
12174
  className: "character-font-menu",
@@ -10722,14 +12179,14 @@ ${arabic || currentMessages.empty}`;
10722
12179
  }
10723
12180
  },
10724
12181
  children: [
10725
- /* @__PURE__ */ jsx(
12182
+ /* @__PURE__ */ jsx2(
10726
12183
  "button",
10727
12184
  {
10728
12185
  ref: characterFontBtnRef,
10729
12186
  id: "select-character-font",
10730
12187
  className: `icon-btn font-mode-btn font-mode-btn--${selectedCharacterFont}`,
10731
12188
  type: "button",
10732
- title: characterFontTitle(selectedCharacterFont, messages),
12189
+ title: characterFontTitle2(selectedCharacterFont, messages),
10733
12190
  "aria-label": messages.chooseWritingFont,
10734
12191
  "aria-haspopup": "listbox",
10735
12192
  "aria-expanded": characterFontMenuOpen,
@@ -10737,14 +12194,14 @@ ${arabic || currentMessages.empty}`;
10737
12194
  children: characterFontOption(selectedCharacterFont).label
10738
12195
  }
10739
12196
  ),
10740
- /* @__PURE__ */ jsx("div", { className: "character-font-options", role: "listbox", "aria-label": messages.chooseWritingFont, hidden: !characterFontMenuOpen, children: CHARACTER_FONT_OPTIONS.map((option) => /* @__PURE__ */ jsx(
12197
+ /* @__PURE__ */ jsx2("div", { className: "character-font-options", role: "listbox", "aria-label": messages.chooseWritingFont, hidden: !characterFontMenuOpen, children: CHARACTER_FONT_OPTIONS.map((option) => /* @__PURE__ */ jsx2(
10741
12198
  "button",
10742
12199
  {
10743
12200
  type: "button",
10744
12201
  role: "option",
10745
12202
  "aria-selected": selectedCharacterFont === option.id,
10746
12203
  className: `character-font-option character-font-option--${option.id}`,
10747
- title: characterFontTitle(option.id, messages),
12204
+ title: characterFontTitle2(option.id, messages),
10748
12205
  onMouseDown: (event) => event.preventDefault(),
10749
12206
  onClick: () => {
10750
12207
  runtimeRef.current?.setCurrentCharacterFont(option.id);
@@ -10759,7 +12216,7 @@ ${arabic || currentMessages.empty}`;
10759
12216
  ]
10760
12217
  }
10761
12218
  ),
10762
- /* @__PURE__ */ jsxs(
12219
+ /* @__PURE__ */ jsxs2(
10763
12220
  "div",
10764
12221
  {
10765
12222
  className: "digit-form-menu",
@@ -10770,7 +12227,7 @@ ${arabic || currentMessages.empty}`;
10770
12227
  }
10771
12228
  },
10772
12229
  children: [
10773
- /* @__PURE__ */ jsx(
12230
+ /* @__PURE__ */ jsx2(
10774
12231
  "button",
10775
12232
  {
10776
12233
  ref: digitFormBtnRef,
@@ -10785,7 +12242,7 @@ ${arabic || currentMessages.empty}`;
10785
12242
  children: digitFormLabel(selectedDigitForm2)
10786
12243
  }
10787
12244
  ),
10788
- /* @__PURE__ */ jsx("div", { className: "digit-form-options", role: "listbox", "aria-label": messages.chooseDigitForm, hidden: !digitMenuOpen, children: DIGIT_FORM_OPTIONS.map((option) => /* @__PURE__ */ jsx(
12245
+ /* @__PURE__ */ jsx2("div", { className: "digit-form-options", role: "listbox", "aria-label": messages.chooseDigitForm, hidden: !digitMenuOpen, children: DIGIT_FORM_OPTIONS.map((option) => /* @__PURE__ */ jsx2(
10789
12246
  "button",
10790
12247
  {
10791
12248
  type: "button",
@@ -10809,7 +12266,7 @@ ${arabic || currentMessages.empty}`;
10809
12266
  )
10810
12267
  ] })
10811
12268
  ] }),
10812
- /* @__PURE__ */ jsx(
12269
+ /* @__PURE__ */ jsx2(
10813
12270
  "div",
10814
12271
  {
10815
12272
  ref: surfaceRef,
@@ -10819,7 +12276,7 @@ ${arabic || currentMessages.empty}`;
10819
12276
  "aria-label": messages.equationEditor
10820
12277
  }
10821
12278
  ),
10822
- /* @__PURE__ */ jsx(
12279
+ /* @__PURE__ */ jsx2(
10823
12280
  "textarea",
10824
12281
  {
10825
12282
  ref: inputRef,
@@ -10833,20 +12290,31 @@ ${arabic || currentMessages.empty}`;
10833
12290
  tabIndex: -1
10834
12291
  }
10835
12292
  ),
10836
- /* @__PURE__ */ jsx("div", { ref: renderErrorRef, className: "error", hidden: true })
12293
+ /* @__PURE__ */ jsx2("div", { ref: renderErrorRef, className: "error", hidden: true }),
12294
+ /* @__PURE__ */ jsx2(
12295
+ "button",
12296
+ {
12297
+ type: "button",
12298
+ className: "butex-widget__mobile-preview-toggle",
12299
+ "aria-controls": previewPanelId,
12300
+ "aria-expanded": compactPreviewOpen,
12301
+ onClick: () => setCompactPreviewOpen((open) => !open),
12302
+ children: compactPreviewOpen ? messages.hidePreview : messages.showPreview
12303
+ }
12304
+ )
10837
12305
  ] }),
10838
- /* @__PURE__ */ jsx("section", { className: "panel panel-preview", "aria-label": messages.renderPreview, children: /* @__PURE__ */ jsx("div", { ref: mathOutputRef, className: "preview-box" }) }),
10839
- debugEnabled ? /* @__PURE__ */ jsxs("section", { className: "panel", children: [
10840
- /* @__PURE__ */ jsxs("div", { className: "dev-strip", children: [
10841
- /* @__PURE__ */ jsx("span", { className: "dev-badge", children: messages.development }),
10842
- /* @__PURE__ */ jsx("div", { ref: latexLinesRef, className: "ascii" }),
10843
- /* @__PURE__ */ jsx("div", { ref: passivePreviewRef, className: "passive-preview-text" })
12306
+ /* @__PURE__ */ jsx2("section", { id: previewPanelId, className: "panel panel-preview", "aria-label": messages.renderPreview, children: /* @__PURE__ */ jsx2("div", { ref: mathOutputRef, className: "preview-box" }) }),
12307
+ debugEnabled ? /* @__PURE__ */ jsxs2("section", { className: "panel", children: [
12308
+ /* @__PURE__ */ jsxs2("div", { className: "dev-strip", children: [
12309
+ /* @__PURE__ */ jsx2("span", { className: "dev-badge", children: messages.development }),
12310
+ /* @__PURE__ */ jsx2("div", { ref: latexLinesRef, className: "ascii" }),
12311
+ /* @__PURE__ */ jsx2("div", { ref: passivePreviewRef, className: "passive-preview-text" })
10844
12312
  ] }),
10845
- /* @__PURE__ */ jsxs("div", { style: { marginTop: 12 }, children: [
10846
- /* @__PURE__ */ jsxs("div", { className: "debug-head", children: [
10847
- /* @__PURE__ */ jsx("button", { type: "button", onClick: () => void copyDebugText(currentMathObjectJsonText()), children: "Copy MathObject JSON" }),
10848
- /* @__PURE__ */ jsx("button", { type: "button", "aria-expanded": debugImportOpen, onClick: openDebugMathObjectImport, children: "Import MathObject JSON" }),
10849
- /* @__PURE__ */ jsx(
12313
+ /* @__PURE__ */ jsxs2("div", { style: { marginTop: 12 }, children: [
12314
+ /* @__PURE__ */ jsxs2("div", { className: "debug-head", children: [
12315
+ /* @__PURE__ */ jsx2("button", { type: "button", onClick: () => void copyDebugText(currentMathObjectJsonText()), children: "Copy MathObject JSON" }),
12316
+ /* @__PURE__ */ jsx2("button", { type: "button", "aria-expanded": debugImportOpen, onClick: openDebugMathObjectImport, children: "Import MathObject JSON" }),
12317
+ /* @__PURE__ */ jsx2(
10850
12318
  "button",
10851
12319
  {
10852
12320
  type: "button",
@@ -10866,7 +12334,7 @@ ${arabic || currentMessages.empty}`;
10866
12334
  children: debugBodyHidden ? messages.showDebugLog : messages.hideDebugLog
10867
12335
  }
10868
12336
  ),
10869
- /* @__PURE__ */ jsx(
12337
+ /* @__PURE__ */ jsx2(
10870
12338
  "button",
10871
12339
  {
10872
12340
  type: "button",
@@ -10881,8 +12349,8 @@ ${arabic || currentMessages.empty}`;
10881
12349
  }
10882
12350
  )
10883
12351
  ] }),
10884
- debugImportOpen ? /* @__PURE__ */ jsxs("div", { className: "debug-json-import", children: [
10885
- /* @__PURE__ */ jsx(
12352
+ debugImportOpen ? /* @__PURE__ */ jsxs2("div", { className: "debug-json-import", children: [
12353
+ /* @__PURE__ */ jsx2(
10886
12354
  "textarea",
10887
12355
  {
10888
12356
  value: debugImportText,
@@ -10894,9 +12362,9 @@ ${arabic || currentMessages.empty}`;
10894
12362
  }
10895
12363
  }
10896
12364
  ),
10897
- /* @__PURE__ */ jsxs("div", { className: "debug-head", children: [
10898
- /* @__PURE__ */ jsx("button", { type: "button", onClick: applyDebugMathObjectImport, children: "Apply" }),
10899
- /* @__PURE__ */ jsx(
12365
+ /* @__PURE__ */ jsxs2("div", { className: "debug-head", children: [
12366
+ /* @__PURE__ */ jsx2("button", { type: "button", onClick: applyDebugMathObjectImport, children: "Apply" }),
12367
+ /* @__PURE__ */ jsx2(
10900
12368
  "button",
10901
12369
  {
10902
12370
  type: "button",
@@ -10908,9 +12376,9 @@ ${arabic || currentMessages.empty}`;
10908
12376
  }
10909
12377
  )
10910
12378
  ] }),
10911
- debugImportError ? /* @__PURE__ */ jsx("p", { className: "debug-json-error", children: debugImportError }) : null
12379
+ debugImportError ? /* @__PURE__ */ jsx2("p", { className: "debug-json-error", children: debugImportError }) : null
10912
12380
  ] }) : null,
10913
- /* @__PURE__ */ jsx("div", { ref: debugLogRef, className: "debug-log" })
12381
+ /* @__PURE__ */ jsx2("div", { ref: debugLogRef, className: "debug-log" })
10914
12382
  ] })
10915
12383
  ] }) : null
10916
12384
  ] })
@@ -11402,14 +12870,14 @@ function injectBuTeXDocumentStyles(doc) {
11402
12870
  }
11403
12871
 
11404
12872
  // src/react-document/ButexDocumentEditor.tsx
11405
- import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
12873
+ import { Fragment as Fragment3, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
11406
12874
  var ButexDocumentPreviewPanel = memo(function ButexDocumentPreviewPanel2({
11407
12875
  preview,
11408
12876
  previewOpen,
11409
12877
  onPreviewMathError
11410
12878
  }) {
11411
- const previewRef = useRef2(null);
11412
- const renderVersionRef = useRef2(0);
12879
+ const previewRef = useRef4(null);
12880
+ const renderVersionRef = useRef4(0);
11413
12881
  useLayoutEffect(() => {
11414
12882
  let cancelled = false;
11415
12883
  let timer = null;
@@ -11531,7 +12999,7 @@ var ButexDocumentPreviewPanel = memo(function ButexDocumentPreviewPanel2({
11531
12999
  }
11532
13000
  };
11533
13001
  }, [preview, previewOpen, onPreviewMathError]);
11534
- return /* @__PURE__ */ jsx2("div", { ref: previewRef, className: "butex-document-widget__preview" });
13002
+ return /* @__PURE__ */ jsx3("div", { ref: previewRef, className: "butex-document-widget__preview" });
11535
13003
  });
11536
13004
  var BLOCK_CHOICES = [
11537
13005
  { kind: "section", label: "\u0642\u0633\u0645" },
@@ -11626,20 +13094,20 @@ function ButexDocumentEditor({
11626
13094
  onLatexChange
11627
13095
  }) {
11628
13096
  const initialState = useMemo(() => resolveInitialDocument(initialDocument), [initialDocument]);
11629
- const [documentNode, setDocumentNode] = useState2(initialState.document);
11630
- const [error, setError] = useState2(initialState.error);
11631
- const [editorOpen, setEditorOpen] = useState2(true);
11632
- const [previewOpen, setPreviewOpen] = useState2(true);
11633
- const [devOpen, setDevOpen] = useState2(debug);
11634
- const [debugLog, setDebugLog] = useState2([]);
11635
- const [selectedMath, setSelectedMath] = useState2(null);
11636
- const [previewMathError, setPreviewMathError] = useState2(null);
11637
- const [fieldCarets, setFieldCarets] = useState2({});
11638
- const latestEquationSessionRef = useRef2(null);
11639
- useEffect2(() => {
13097
+ const [documentNode, setDocumentNode] = useState3(initialState.document);
13098
+ const [error, setError] = useState3(initialState.error);
13099
+ const [editorOpen, setEditorOpen] = useState3(true);
13100
+ const [previewOpen, setPreviewOpen] = useState3(true);
13101
+ const [devOpen, setDevOpen] = useState3(debug);
13102
+ const [debugLog, setDebugLog] = useState3([]);
13103
+ const [selectedMath, setSelectedMath] = useState3(null);
13104
+ const [previewMathError, setPreviewMathError] = useState3(null);
13105
+ const [fieldCarets, setFieldCarets] = useState3({});
13106
+ const latestEquationSessionRef = useRef4(null);
13107
+ useEffect5(() => {
11640
13108
  injectBuTeXDocumentStyles();
11641
13109
  }, []);
11642
- useEffect2(() => {
13110
+ useEffect5(() => {
11643
13111
  const next = resolveInitialDocument(initialDocument);
11644
13112
  setDocumentNode(next.document);
11645
13113
  setError(next.error);
@@ -11648,13 +13116,13 @@ function ButexDocumentEditor({
11648
13116
  }, [initialDocument]);
11649
13117
  const latex = renderDocumentLatex(documentNode);
11650
13118
  const preview = useMemo(() => previewOrEmpty(documentNode), [documentNode]);
11651
- useEffect2(() => {
13119
+ useEffect5(() => {
11652
13120
  onDocumentChange?.(documentNode);
11653
13121
  }, [documentNode, onDocumentChange]);
11654
- useEffect2(() => {
13122
+ useEffect5(() => {
11655
13123
  onLatexChange?.(latex);
11656
13124
  }, [latex, onLatexChange]);
11657
- useEffect2(() => {
13125
+ useEffect5(() => {
11658
13126
  if (debug) {
11659
13127
  setDevOpen(true);
11660
13128
  }
@@ -11752,7 +13220,7 @@ function ButexDocumentEditor({
11752
13220
  return inlines.filter((inline) => inline.kind === "math").map((inline) => {
11753
13221
  const current = spanIndex;
11754
13222
  spanIndex += 1;
11755
- return /* @__PURE__ */ jsx2(
13223
+ return /* @__PURE__ */ jsx3(
11756
13224
  "button",
11757
13225
  {
11758
13226
  type: "button",
@@ -11767,9 +13235,9 @@ function ButexDocumentEditor({
11767
13235
  }
11768
13236
  function renderTextBlock(block, blockIndex) {
11769
13237
  const target = { scope: "block", blockIndex };
11770
- return /* @__PURE__ */ jsxs2("label", { className: "butex-document-widget__field", children: [
11771
- /* @__PURE__ */ jsx2("span", { children: textCommandLabel(block.command) }),
11772
- /* @__PURE__ */ jsx2(
13238
+ return /* @__PURE__ */ jsxs3("label", { className: "butex-document-widget__field", children: [
13239
+ /* @__PURE__ */ jsx3("span", { children: textCommandLabel(block.command) }),
13240
+ /* @__PURE__ */ jsx3(
11773
13241
  "textarea",
11774
13242
  {
11775
13243
  value: block.value,
@@ -11779,17 +13247,17 @@ function ButexDocumentEditor({
11779
13247
  onChange: (event) => updateDocument(updateTextBlockValue(documentNode, blockIndex, event.currentTarget.value), "updateTextBlock")
11780
13248
  }
11781
13249
  ),
11782
- /* @__PURE__ */ jsx2("span", { className: "butex-document-widget__row-actions", children: /* @__PURE__ */ jsx2("button", { type: "button", onClick: () => openNewMath(target, block.value.length), children: "\u0625\u062F\u0631\u0627\u062C \u0645\u0639\u0627\u062F\u0644\u0629" }) }),
11783
- /* @__PURE__ */ jsx2("span", { className: "butex-document-widget__chips", children: renderMathChips(block.inlines, (spanIndex) => ({ scope: "block", blockIndex, spanIndex })) })
13250
+ /* @__PURE__ */ jsx3("span", { className: "butex-document-widget__row-actions", children: /* @__PURE__ */ jsx3("button", { type: "button", onClick: () => openNewMath(target, block.value.length), children: "\u0625\u062F\u0631\u0627\u062C \u0645\u0639\u0627\u062F\u0644\u0629" }) }),
13251
+ /* @__PURE__ */ jsx3("span", { className: "butex-document-widget__chips", children: renderMathChips(block.inlines, (spanIndex) => ({ scope: "block", blockIndex, spanIndex })) })
11784
13252
  ] });
11785
13253
  }
11786
13254
  function renderListBlock(block, blockIndex) {
11787
- return /* @__PURE__ */ jsxs2("div", { className: "butex-document-widget__list-editor", children: [
11788
- /* @__PURE__ */ jsx2("div", { className: "butex-document-widget__row-actions", children: /* @__PURE__ */ jsx2("button", { type: "button", onClick: () => updateDocument(addListItem(documentNode, blockIndex), "addListItem"), children: "\u0625\u0636\u0627\u0641\u0629 \u0639\u0646\u0635\u0631" }) }),
11789
- block.items.map((item, itemIndex) => /* @__PURE__ */ jsxs2("div", { className: "butex-document-widget__list-item", children: [
11790
- /* @__PURE__ */ jsxs2("label", { className: "butex-document-widget__field", children: [
11791
- /* @__PURE__ */ jsx2("span", { children: block.command === "\\begin{enumerate}" ? `\u0639\u0646\u0635\u0631 ${String(itemIndex + 1)}` : "\u0639\u0646\u0635\u0631" }),
11792
- /* @__PURE__ */ jsx2(
13255
+ return /* @__PURE__ */ jsxs3("div", { className: "butex-document-widget__list-editor", children: [
13256
+ /* @__PURE__ */ jsx3("div", { className: "butex-document-widget__row-actions", children: /* @__PURE__ */ jsx3("button", { type: "button", onClick: () => updateDocument(addListItem(documentNode, blockIndex), "addListItem"), children: "\u0625\u0636\u0627\u0641\u0629 \u0639\u0646\u0635\u0631" }) }),
13257
+ block.items.map((item, itemIndex) => /* @__PURE__ */ jsxs3("div", { className: "butex-document-widget__list-item", children: [
13258
+ /* @__PURE__ */ jsxs3("label", { className: "butex-document-widget__field", children: [
13259
+ /* @__PURE__ */ jsx3("span", { children: block.command === "\\begin{enumerate}" ? `\u0639\u0646\u0635\u0631 ${String(itemIndex + 1)}` : "\u0639\u0646\u0635\u0631" }),
13260
+ /* @__PURE__ */ jsx3(
11793
13261
  "textarea",
11794
13262
  {
11795
13263
  value: item.value,
@@ -11799,7 +13267,7 @@ function ButexDocumentEditor({
11799
13267
  onChange: (event) => updateDocument(updateListItemValue(documentNode, blockIndex, itemIndex, event.currentTarget.value), "updateListItem")
11800
13268
  }
11801
13269
  ),
11802
- /* @__PURE__ */ jsx2("span", { className: "butex-document-widget__row-actions", children: /* @__PURE__ */ jsx2(
13270
+ /* @__PURE__ */ jsx3("span", { className: "butex-document-widget__row-actions", children: /* @__PURE__ */ jsx3(
11803
13271
  "button",
11804
13272
  {
11805
13273
  type: "button",
@@ -11807,22 +13275,22 @@ function ButexDocumentEditor({
11807
13275
  children: "\u0625\u062F\u0631\u0627\u062C \u0645\u0639\u0627\u062F\u0644\u0629"
11808
13276
  }
11809
13277
  ) }),
11810
- /* @__PURE__ */ jsx2("span", { className: "butex-document-widget__chips", children: renderMathChips(item.inlines, (spanIndex) => ({ scope: "listItem", blockIndex, itemIndex, spanIndex })) })
13278
+ /* @__PURE__ */ jsx3("span", { className: "butex-document-widget__chips", children: renderMathChips(item.inlines, (spanIndex) => ({ scope: "listItem", blockIndex, itemIndex, spanIndex })) })
11811
13279
  ] }),
11812
- /* @__PURE__ */ jsxs2("div", { className: "butex-document-widget__row-actions", children: [
11813
- /* @__PURE__ */ jsx2("button", { type: "button", onClick: () => updateDocument(removeListItem(documentNode, blockIndex, itemIndex), "removeListItem"), children: "\u062D\u0630\u0641 \u0627\u0644\u0639\u0646\u0635\u0631" }),
11814
- /* @__PURE__ */ jsx2("button", { type: "button", onClick: () => updateDocument(addNestedListBlock(documentNode, blockIndex, itemIndex, "itemize"), "addNestedList"), children: "\u0642\u0627\u0626\u0645\u0629 \u0641\u0631\u0639\u064A\u0629" }),
11815
- /* @__PURE__ */ jsx2("button", { type: "button", onClick: () => updateDocument(addNestedListBlock(documentNode, blockIndex, itemIndex, "enumerate"), "addNestedEnumerate"), children: "\u062A\u0631\u0642\u064A\u0645 \u0641\u0631\u0639\u064A" })
13280
+ /* @__PURE__ */ jsxs3("div", { className: "butex-document-widget__row-actions", children: [
13281
+ /* @__PURE__ */ jsx3("button", { type: "button", onClick: () => updateDocument(removeListItem(documentNode, blockIndex, itemIndex), "removeListItem"), children: "\u062D\u0630\u0641 \u0627\u0644\u0639\u0646\u0635\u0631" }),
13282
+ /* @__PURE__ */ jsx3("button", { type: "button", onClick: () => updateDocument(addNestedListBlock(documentNode, blockIndex, itemIndex, "itemize"), "addNestedList"), children: "\u0642\u0627\u0626\u0645\u0629 \u0641\u0631\u0639\u064A\u0629" }),
13283
+ /* @__PURE__ */ jsx3("button", { type: "button", onClick: () => updateDocument(addNestedListBlock(documentNode, blockIndex, itemIndex, "enumerate"), "addNestedEnumerate"), children: "\u062A\u0631\u0642\u064A\u0645 \u0641\u0631\u0639\u064A" })
11816
13284
  ] }),
11817
- item.blocks.length > 0 ? /* @__PURE__ */ jsx2("div", { className: "butex-document-widget__nested", children: item.blocks.map((child, childIndex) => /* @__PURE__ */ jsx2("div", { className: "butex-document-widget__nested-block", children: child.kind === "list" ? `${child.command === "\\begin{enumerate}" ? "\u062A\u0631\u0642\u064A\u0645 \u0641\u0631\u0639\u064A" : "\u0642\u0627\u0626\u0645\u0629 \u0641\u0631\u0639\u064A\u0629"} (${String(child.items.length)} \u0639\u0646\u0627\u0635\u0631)` : "\u0628\u0646\u064A\u0629 \u0641\u0631\u0639\u064A\u0629" }, childIndex)) }) : null
13285
+ item.blocks.length > 0 ? /* @__PURE__ */ jsx3("div", { className: "butex-document-widget__nested", children: item.blocks.map((child, childIndex) => /* @__PURE__ */ jsx3("div", { className: "butex-document-widget__nested-block", children: child.kind === "list" ? `${child.command === "\\begin{enumerate}" ? "\u062A\u0631\u0642\u064A\u0645 \u0641\u0631\u0639\u064A" : "\u0642\u0627\u0626\u0645\u0629 \u0641\u0631\u0639\u064A\u0629"} (${String(child.items.length)} \u0639\u0646\u0627\u0635\u0631)` : "\u0628\u0646\u064A\u0629 \u0641\u0631\u0639\u064A\u0629" }, childIndex)) }) : null
11818
13286
  ] }, itemIndex))
11819
13287
  ] });
11820
13288
  }
11821
13289
  function renderTableBlock(block, blockIndex) {
11822
- return /* @__PURE__ */ jsxs2("div", { className: "butex-document-widget__table-editor", children: [
11823
- /* @__PURE__ */ jsxs2("label", { className: "butex-document-widget__field butex-document-widget__field--short", children: [
11824
- /* @__PURE__ */ jsx2("span", { children: "\u0627\u0644\u0623\u0639\u0645\u062F\u0629" }),
11825
- /* @__PURE__ */ jsx2(
13290
+ return /* @__PURE__ */ jsxs3("div", { className: "butex-document-widget__table-editor", children: [
13291
+ /* @__PURE__ */ jsxs3("label", { className: "butex-document-widget__field butex-document-widget__field--short", children: [
13292
+ /* @__PURE__ */ jsx3("span", { children: "\u0627\u0644\u0623\u0639\u0645\u062F\u0629" }),
13293
+ /* @__PURE__ */ jsx3(
11826
13294
  "input",
11827
13295
  {
11828
13296
  value: block.columns,
@@ -11830,14 +13298,14 @@ function ButexDocumentEditor({
11830
13298
  }
11831
13299
  )
11832
13300
  ] }),
11833
- /* @__PURE__ */ jsxs2("div", { className: "butex-document-widget__row-actions", children: [
11834
- /* @__PURE__ */ jsx2("button", { type: "button", onClick: () => updateDocument(addTableRow(documentNode, blockIndex), "addTableRow"), children: "\u0625\u0636\u0627\u0641\u0629 \u0635\u0641" }),
11835
- /* @__PURE__ */ jsx2("button", { type: "button", onClick: () => updateDocument(removeTableRow(documentNode, blockIndex), "removeTableRow"), children: "\u062D\u0630\u0641 \u0635\u0641" }),
11836
- /* @__PURE__ */ jsx2("button", { type: "button", onClick: () => updateDocument(addTableColumn(documentNode, blockIndex), "addTableColumn"), children: "\u0625\u0636\u0627\u0641\u0629 \u0639\u0645\u0648\u062F" }),
11837
- /* @__PURE__ */ jsx2("button", { type: "button", onClick: () => updateDocument(removeTableColumn(documentNode, blockIndex), "removeTableColumn"), children: "\u062D\u0630\u0641 \u0639\u0645\u0648\u062F" })
13301
+ /* @__PURE__ */ jsxs3("div", { className: "butex-document-widget__row-actions", children: [
13302
+ /* @__PURE__ */ jsx3("button", { type: "button", onClick: () => updateDocument(addTableRow(documentNode, blockIndex), "addTableRow"), children: "\u0625\u0636\u0627\u0641\u0629 \u0635\u0641" }),
13303
+ /* @__PURE__ */ jsx3("button", { type: "button", onClick: () => updateDocument(removeTableRow(documentNode, blockIndex), "removeTableRow"), children: "\u062D\u0630\u0641 \u0635\u0641" }),
13304
+ /* @__PURE__ */ jsx3("button", { type: "button", onClick: () => updateDocument(addTableColumn(documentNode, blockIndex), "addTableColumn"), children: "\u0625\u0636\u0627\u0641\u0629 \u0639\u0645\u0648\u062F" }),
13305
+ /* @__PURE__ */ jsx3("button", { type: "button", onClick: () => updateDocument(removeTableColumn(documentNode, blockIndex), "removeTableColumn"), children: "\u062D\u0630\u0641 \u0639\u0645\u0648\u062F" })
11838
13306
  ] }),
11839
- /* @__PURE__ */ jsx2("div", { className: "butex-document-widget__table-grid", children: block.rows.map((row, rowIndex) => /* @__PURE__ */ jsx2("div", { className: "butex-document-widget__table-row", children: row.map((cell, columnIndex) => /* @__PURE__ */ jsxs2("label", { className: "butex-document-widget__table-cell", children: [
11840
- /* @__PURE__ */ jsx2(
13307
+ /* @__PURE__ */ jsx3("div", { className: "butex-document-widget__table-grid", children: block.rows.map((row, rowIndex) => /* @__PURE__ */ jsx3("div", { className: "butex-document-widget__table-row", children: row.map((cell, columnIndex) => /* @__PURE__ */ jsxs3("label", { className: "butex-document-widget__table-cell", children: [
13308
+ /* @__PURE__ */ jsx3(
11841
13309
  "input",
11842
13310
  {
11843
13311
  value: textFromInlines(cell),
@@ -11847,7 +13315,7 @@ function ButexDocumentEditor({
11847
13315
  onChange: (event) => updateDocument(updateTableCell(documentNode, blockIndex, rowIndex, columnIndex, event.currentTarget.value), "updateTableCell")
11848
13316
  }
11849
13317
  ),
11850
- /* @__PURE__ */ jsx2("span", { className: "butex-document-widget__row-actions", children: /* @__PURE__ */ jsx2(
13318
+ /* @__PURE__ */ jsx3("span", { className: "butex-document-widget__row-actions", children: /* @__PURE__ */ jsx3(
11851
13319
  "button",
11852
13320
  {
11853
13321
  type: "button",
@@ -11858,15 +13326,15 @@ function ButexDocumentEditor({
11858
13326
  children: "\u0625\u062F\u0631\u0627\u062C \u0645\u0639\u0627\u062F\u0644\u0629"
11859
13327
  }
11860
13328
  ) }),
11861
- /* @__PURE__ */ jsx2("span", { className: "butex-document-widget__chips", children: renderMathChips(cell, (spanIndex) => ({ scope: "tableCell", blockIndex, rowIndex, columnIndex, spanIndex })) })
13329
+ /* @__PURE__ */ jsx3("span", { className: "butex-document-widget__chips", children: renderMathChips(cell, (spanIndex) => ({ scope: "tableCell", blockIndex, rowIndex, columnIndex, spanIndex })) })
11862
13330
  ] }, `${rowIndex}-${columnIndex}`)) }, rowIndex)) })
11863
13331
  ] });
11864
13332
  }
11865
13333
  function renderImageBlock(block, blockIndex) {
11866
- return /* @__PURE__ */ jsxs2("div", { className: "butex-document-widget__image-editor", children: [
11867
- /* @__PURE__ */ jsxs2("label", { className: "butex-document-widget__field", children: [
11868
- /* @__PURE__ */ jsx2("span", { children: "\u0645\u0633\u0627\u0631 \u0627\u0644\u0635\u0648\u0631\u0629" }),
11869
- /* @__PURE__ */ jsx2(
13334
+ return /* @__PURE__ */ jsxs3("div", { className: "butex-document-widget__image-editor", children: [
13335
+ /* @__PURE__ */ jsxs3("label", { className: "butex-document-widget__field", children: [
13336
+ /* @__PURE__ */ jsx3("span", { children: "\u0645\u0633\u0627\u0631 \u0627\u0644\u0635\u0648\u0631\u0629" }),
13337
+ /* @__PURE__ */ jsx3(
11870
13338
  "input",
11871
13339
  {
11872
13340
  value: block.value,
@@ -11874,9 +13342,9 @@ function ButexDocumentEditor({
11874
13342
  }
11875
13343
  )
11876
13344
  ] }),
11877
- /* @__PURE__ */ jsxs2("label", { className: "butex-document-widget__field", children: [
11878
- /* @__PURE__ */ jsx2("span", { children: "\u0627\u0644\u062E\u064A\u0627\u0631\u0627\u062A" }),
11879
- /* @__PURE__ */ jsx2(
13345
+ /* @__PURE__ */ jsxs3("label", { className: "butex-document-widget__field", children: [
13346
+ /* @__PURE__ */ jsx3("span", { children: "\u0627\u0644\u062E\u064A\u0627\u0631\u0627\u062A" }),
13347
+ /* @__PURE__ */ jsx3(
11880
13348
  "input",
11881
13349
  {
11882
13350
  value: optionsToText(block.options),
@@ -11899,9 +13367,9 @@ function ButexDocumentEditor({
11899
13367
  if (block.kind === "image") {
11900
13368
  return renderImageBlock(block, blockIndex);
11901
13369
  }
11902
- return /* @__PURE__ */ jsxs2("label", { className: "butex-document-widget__field", children: [
11903
- /* @__PURE__ */ jsx2("span", { children: "\u062E\u0627\u0645" }),
11904
- /* @__PURE__ */ jsx2(
13370
+ return /* @__PURE__ */ jsxs3("label", { className: "butex-document-widget__field", children: [
13371
+ /* @__PURE__ */ jsx3("span", { children: "\u062E\u0627\u0645" }),
13372
+ /* @__PURE__ */ jsx3(
11905
13373
  "textarea",
11906
13374
  {
11907
13375
  value: block.value,
@@ -11910,30 +13378,30 @@ function ButexDocumentEditor({
11910
13378
  )
11911
13379
  ] });
11912
13380
  }
11913
- return /* @__PURE__ */ jsx2("div", { className: `butex-document-widget ${className ?? ""}`.trim(), dir: "rtl", lang: "ar", children: /* @__PURE__ */ jsxs2("div", { className: "butex-document-widget__shell", children: [
11914
- /* @__PURE__ */ jsxs2("div", { className: "butex-document-widget__toolbar", role: "toolbar", "aria-label": "\u0623\u062F\u0648\u0627\u062A \u0627\u0644\u0645\u0633\u062A\u0646\u062F", children: [
11915
- BLOCK_CHOICES.map((choice) => /* @__PURE__ */ jsx2("button", { type: "button", onClick: () => updateDocument(addDocumentBlock(documentNode, choice.kind), `addBlock:${choice.kind}`), children: choice.label }, choice.kind)),
11916
- /* @__PURE__ */ jsx2("button", { type: "button", "aria-pressed": editorOpen, onClick: toggleEditorPanel, children: editorOpen ? "\u0625\u062E\u0641\u0627\u0621 \u0627\u0644\u062A\u062D\u0631\u064A\u0631" : "\u0625\u0638\u0647\u0627\u0631 \u0627\u0644\u062A\u062D\u0631\u064A\u0631" }),
11917
- /* @__PURE__ */ jsx2("button", { type: "button", "aria-pressed": previewOpen, onClick: togglePreviewPanel, children: previewOpen ? "\u0625\u062E\u0641\u0627\u0621 \u0627\u0644\u0645\u0639\u0627\u064A\u0646\u0629" : "\u0625\u0638\u0647\u0627\u0631 \u0627\u0644\u0645\u0639\u0627\u064A\u0646\u0629" }),
11918
- /* @__PURE__ */ jsx2("button", { type: "button", "aria-pressed": devOpen, onClick: () => setDevOpen((open) => !open), children: devOpen ? "\u0625\u062E\u0641\u0627\u0621 \u0627\u0644\u062A\u0637\u0648\u064A\u0631" : "\u0625\u0638\u0647\u0627\u0631 \u0627\u0644\u062A\u0637\u0648\u064A\u0631" })
13381
+ return /* @__PURE__ */ jsx3("div", { className: `butex-document-widget ${className ?? ""}`.trim(), dir: "rtl", lang: "ar", children: /* @__PURE__ */ jsxs3("div", { className: "butex-document-widget__shell", children: [
13382
+ /* @__PURE__ */ jsxs3("div", { className: "butex-document-widget__toolbar", role: "toolbar", "aria-label": "\u0623\u062F\u0648\u0627\u062A \u0627\u0644\u0645\u0633\u062A\u0646\u062F", children: [
13383
+ BLOCK_CHOICES.map((choice) => /* @__PURE__ */ jsx3("button", { type: "button", onClick: () => updateDocument(addDocumentBlock(documentNode, choice.kind), `addBlock:${choice.kind}`), children: choice.label }, choice.kind)),
13384
+ /* @__PURE__ */ jsx3("button", { type: "button", "aria-pressed": editorOpen, onClick: toggleEditorPanel, children: editorOpen ? "\u0625\u062E\u0641\u0627\u0621 \u0627\u0644\u062A\u062D\u0631\u064A\u0631" : "\u0625\u0638\u0647\u0627\u0631 \u0627\u0644\u062A\u062D\u0631\u064A\u0631" }),
13385
+ /* @__PURE__ */ jsx3("button", { type: "button", "aria-pressed": previewOpen, onClick: togglePreviewPanel, children: previewOpen ? "\u0625\u062E\u0641\u0627\u0621 \u0627\u0644\u0645\u0639\u0627\u064A\u0646\u0629" : "\u0625\u0638\u0647\u0627\u0631 \u0627\u0644\u0645\u0639\u0627\u064A\u0646\u0629" }),
13386
+ /* @__PURE__ */ jsx3("button", { type: "button", "aria-pressed": devOpen, onClick: () => setDevOpen((open) => !open), children: devOpen ? "\u0625\u062E\u0641\u0627\u0621 \u0627\u0644\u062A\u0637\u0648\u064A\u0631" : "\u0625\u0638\u0647\u0627\u0631 \u0627\u0644\u062A\u0637\u0648\u064A\u0631" })
11919
13387
  ] }),
11920
- error ? /* @__PURE__ */ jsx2("p", { className: "butex-document-widget__error", children: error }) : null,
11921
- /* @__PURE__ */ jsxs2("div", { className: `butex-document-widget__layout butex-document-widget__layout--editor-${editorOpen ? "open" : "closed"} butex-document-widget__layout--preview-${previewOpen ? "open" : "closed"}`, children: [
11922
- /* @__PURE__ */ jsxs2(
13388
+ error ? /* @__PURE__ */ jsx3("p", { className: "butex-document-widget__error", children: error }) : null,
13389
+ /* @__PURE__ */ jsxs3("div", { className: `butex-document-widget__layout butex-document-widget__layout--editor-${editorOpen ? "open" : "closed"} butex-document-widget__layout--preview-${previewOpen ? "open" : "closed"}`, children: [
13390
+ /* @__PURE__ */ jsxs3(
11923
13391
  "section",
11924
13392
  {
11925
13393
  className: "butex-document-widget__panel butex-document-widget__editor-panel",
11926
13394
  "aria-label": "\u062A\u062D\u0631\u064A\u0631 \u0627\u0644\u0645\u0633\u062A\u0646\u062F",
11927
13395
  "aria-hidden": !editorOpen,
11928
13396
  children: [
11929
- documentNode.blocks.length === 0 ? /* @__PURE__ */ jsx2("p", { className: "butex-document-widget__placeholder", children: "\u0623\u0636\u0641 \u0628\u0646\u064A\u0629 \u0644\u0644\u0628\u062F\u0621" }) : null,
11930
- documentNode.blocks.map((block, blockIndex) => /* @__PURE__ */ jsxs2("article", { className: "butex-document-widget__block", children: [
11931
- /* @__PURE__ */ jsxs2("div", { className: "butex-document-widget__block-head", children: [
11932
- /* @__PURE__ */ jsx2("strong", { children: block.kind === "textBlock" ? textCommandLabel(block.command) : block.kind === "list" ? "\u0642\u0627\u0626\u0645\u0629" : block.kind === "table" ? "\u062C\u062F\u0648\u0644" : block.kind === "image" ? "\u0635\u0648\u0631\u0629" : "\u062E\u0627\u0645" }),
11933
- /* @__PURE__ */ jsxs2("span", { className: "butex-document-widget__row-actions", children: [
11934
- /* @__PURE__ */ jsx2("button", { type: "button", onClick: () => updateDocument(moveDocumentBlock(documentNode, blockIndex, -1), "moveBlockUp"), children: "\u2191" }),
11935
- /* @__PURE__ */ jsx2("button", { type: "button", onClick: () => updateDocument(moveDocumentBlock(documentNode, blockIndex, 1), "moveBlockDown"), children: "\u2193" }),
11936
- /* @__PURE__ */ jsx2("button", { type: "button", onClick: () => updateDocument(removeDocumentBlock(documentNode, blockIndex), "removeBlock"), children: "\u062D\u0630\u0641" })
13397
+ documentNode.blocks.length === 0 ? /* @__PURE__ */ jsx3("p", { className: "butex-document-widget__placeholder", children: "\u0623\u0636\u0641 \u0628\u0646\u064A\u0629 \u0644\u0644\u0628\u062F\u0621" }) : null,
13398
+ documentNode.blocks.map((block, blockIndex) => /* @__PURE__ */ jsxs3("article", { className: "butex-document-widget__block", children: [
13399
+ /* @__PURE__ */ jsxs3("div", { className: "butex-document-widget__block-head", children: [
13400
+ /* @__PURE__ */ jsx3("strong", { children: block.kind === "textBlock" ? textCommandLabel(block.command) : block.kind === "list" ? "\u0642\u0627\u0626\u0645\u0629" : block.kind === "table" ? "\u062C\u062F\u0648\u0644" : block.kind === "image" ? "\u0635\u0648\u0631\u0629" : "\u062E\u0627\u0645" }),
13401
+ /* @__PURE__ */ jsxs3("span", { className: "butex-document-widget__row-actions", children: [
13402
+ /* @__PURE__ */ jsx3("button", { type: "button", onClick: () => updateDocument(moveDocumentBlock(documentNode, blockIndex, -1), "moveBlockUp"), children: "\u2191" }),
13403
+ /* @__PURE__ */ jsx3("button", { type: "button", onClick: () => updateDocument(moveDocumentBlock(documentNode, blockIndex, 1), "moveBlockDown"), children: "\u2193" }),
13404
+ /* @__PURE__ */ jsx3("button", { type: "button", onClick: () => updateDocument(removeDocumentBlock(documentNode, blockIndex), "removeBlock"), children: "\u062D\u0630\u0641" })
11937
13405
  ] })
11938
13406
  ] }),
11939
13407
  renderBlockBody(block, blockIndex)
@@ -11941,44 +13409,44 @@ function ButexDocumentEditor({
11941
13409
  ]
11942
13410
  }
11943
13411
  ),
11944
- /* @__PURE__ */ jsxs2(
13412
+ /* @__PURE__ */ jsxs3(
11945
13413
  "section",
11946
13414
  {
11947
13415
  className: "butex-document-widget__panel butex-document-widget__preview-panel",
11948
13416
  "aria-label": "\u0645\u0639\u0627\u064A\u0646\u0629 \u0627\u0644\u0645\u0633\u062A\u0646\u062F",
11949
13417
  "aria-hidden": !previewOpen,
11950
13418
  children: [
11951
- /* @__PURE__ */ jsx2(ButexDocumentPreviewPanel, { preview, previewOpen, onPreviewMathError: setPreviewMathError }),
11952
- previewMathError ? /* @__PURE__ */ jsx2("p", { className: "butex-document-widget__preview-error", children: previewMathError }) : null
13419
+ /* @__PURE__ */ jsx3(ButexDocumentPreviewPanel, { preview, previewOpen, onPreviewMathError: setPreviewMathError }),
13420
+ previewMathError ? /* @__PURE__ */ jsx3("p", { className: "butex-document-widget__preview-error", children: previewMathError }) : null
11953
13421
  ]
11954
13422
  }
11955
13423
  )
11956
13424
  ] }),
11957
- devOpen ? /* @__PURE__ */ jsxs2("section", { className: "butex-document-widget__dev", "aria-label": "\u0644\u0648\u062D\u0629 \u0627\u0644\u062A\u0637\u0648\u064A\u0631", children: [
11958
- /* @__PURE__ */ jsxs2("div", { children: [
11959
- /* @__PURE__ */ jsx2("strong", { children: "LaTeX" }),
11960
- /* @__PURE__ */ jsx2("pre", { children: latex })
13425
+ devOpen ? /* @__PURE__ */ jsxs3("section", { className: "butex-document-widget__dev", "aria-label": "\u0644\u0648\u062D\u0629 \u0627\u0644\u062A\u0637\u0648\u064A\u0631", children: [
13426
+ /* @__PURE__ */ jsxs3("div", { children: [
13427
+ /* @__PURE__ */ jsx3("strong", { children: "LaTeX" }),
13428
+ /* @__PURE__ */ jsx3("pre", { children: latex })
11961
13429
  ] }),
11962
- /* @__PURE__ */ jsxs2("div", { children: [
11963
- /* @__PURE__ */ jsx2("strong", { children: "HTML" }),
11964
- /* @__PURE__ */ jsx2("pre", { children: preview.html })
13430
+ /* @__PURE__ */ jsxs3("div", { children: [
13431
+ /* @__PURE__ */ jsx3("strong", { children: "HTML" }),
13432
+ /* @__PURE__ */ jsx3("pre", { children: preview.html })
11965
13433
  ] }),
11966
- /* @__PURE__ */ jsxs2("div", { children: [
11967
- /* @__PURE__ */ jsx2("strong", { children: "AST" }),
11968
- /* @__PURE__ */ jsx2("pre", { children: JSON.stringify(documentNode, null, 2) })
13434
+ /* @__PURE__ */ jsxs3("div", { children: [
13435
+ /* @__PURE__ */ jsx3("strong", { children: "AST" }),
13436
+ /* @__PURE__ */ jsx3("pre", { children: JSON.stringify(documentNode, null, 2) })
11969
13437
  ] }),
11970
- /* @__PURE__ */ jsxs2("div", { children: [
11971
- /* @__PURE__ */ jsx2("strong", { children: "\u0627\u0644\u0633\u062C\u0644" }),
11972
- /* @__PURE__ */ jsx2("pre", { children: debugLog.join("\n") })
13438
+ /* @__PURE__ */ jsxs3("div", { children: [
13439
+ /* @__PURE__ */ jsx3("strong", { children: "\u0627\u0644\u0633\u062C\u0644" }),
13440
+ /* @__PURE__ */ jsx3("pre", { children: debugLog.join("\n") })
11973
13441
  ] })
11974
13442
  ] }) : null,
11975
- selectedMath ? /* @__PURE__ */ jsxs2("aside", { className: "butex-document-widget__drawer", "aria-label": "\u062A\u062D\u0631\u064A\u0631 \u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629", children: [
11976
- /* @__PURE__ */ jsxs2("div", { className: "butex-document-widget__drawer-head", children: [
11977
- /* @__PURE__ */ jsx2("strong", { children: "\u062A\u062D\u0631\u064A\u0631 \u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629" }),
11978
- /* @__PURE__ */ jsx2("button", { type: "button", onClick: () => setSelectedMath(null), children: "\u0625\u063A\u0644\u0627\u0642" })
13443
+ selectedMath ? /* @__PURE__ */ jsxs3("aside", { className: "butex-document-widget__drawer", "aria-label": "\u062A\u062D\u0631\u064A\u0631 \u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629", children: [
13444
+ /* @__PURE__ */ jsxs3("div", { className: "butex-document-widget__drawer-head", children: [
13445
+ /* @__PURE__ */ jsx3("strong", { children: "\u062A\u062D\u0631\u064A\u0631 \u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629" }),
13446
+ /* @__PURE__ */ jsx3("button", { type: "button", onClick: () => setSelectedMath(null), children: "\u0625\u063A\u0644\u0627\u0642" })
11979
13447
  ] }),
11980
- selectedMath.reason || !selectedMath.session ? /* @__PURE__ */ jsx2("p", { className: "butex-document-widget__error", children: selectedMath.reason ?? "\u062A\u0639\u0630\u0631 \u0641\u062A\u062D \u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629" }) : /* @__PURE__ */ jsxs2(Fragment2, { children: [
11981
- /* @__PURE__ */ jsx2(
13448
+ selectedMath.reason || !selectedMath.session ? /* @__PURE__ */ jsx3("p", { className: "butex-document-widget__error", children: selectedMath.reason ?? "\u062A\u0639\u0630\u0631 \u0641\u062A\u062D \u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629" }) : /* @__PURE__ */ jsxs3(Fragment3, { children: [
13449
+ /* @__PURE__ */ jsx3(
11982
13450
  ButexEditor,
11983
13451
  {
11984
13452
  initialSession: selectedMath.session,
@@ -11988,7 +13456,7 @@ function ButexDocumentEditor({
11988
13456
  },
11989
13457
  selectedMath.kind === "edit" ? selectedMath.inline.source : `insert-${targetKey(selectedMath.target)}-${String(selectedMath.insertAt)}`
11990
13458
  ),
11991
- /* @__PURE__ */ jsx2("div", { className: "butex-document-widget__row-actions", children: /* @__PURE__ */ jsx2("button", { type: "button", onClick: saveSelectedMath, children: "\u062D\u0641\u0638 \u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629" }) })
13459
+ /* @__PURE__ */ jsx3("div", { className: "butex-document-widget__row-actions", children: /* @__PURE__ */ jsx3("button", { type: "button", onClick: saveSelectedMath, children: "\u062D\u0641\u0638 \u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629" }) })
11992
13460
  ] })
11993
13461
  ] }) : null
11994
13462
  ] }) });