@drghaliasri/butex 6.1.5 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,7 +28,7 @@ __export(react_document_entry_exports, {
28
28
  module.exports = __toCommonJS(react_document_entry_exports);
29
29
 
30
30
  // src/react-document/ButexDocumentEditor.tsx
31
- var import_react2 = require("react");
31
+ var import_react5 = require("react");
32
32
 
33
33
  // src/ast/commands/index.ts
34
34
  function renderCommandCore(context) {
@@ -3447,7 +3447,22 @@ var EQUATION_EDITOR_MESSAGES = {
3447
3447
  matrixBrackets: "\u0645\u0635\u0641\u0648\u0641\u0629 \u0628\u064A\u0646 \u0645\u0639\u0642\u0648\u0641\u064A\u0646",
3448
3448
  matrixBraces: "\u0645\u0635\u0641\u0648\u0641\u0629 \u0628\u064A\u0646 \u062D\u0627\u0635\u0631\u062A\u064A\u0646",
3449
3449
  matrixBars: "\u0645\u0635\u0641\u0648\u0641\u0629 \u0628\u064A\u0646 \u062E\u0637\u064A\u0646",
3450
- matrixDoubleBars: "\u0645\u0635\u0641\u0648\u0641\u0629 \u0628\u064A\u0646 \u062E\u0637\u064A\u0646 \u0645\u0632\u062F\u0648\u062C\u064A\u0646"
3450
+ matrixDoubleBars: "\u0645\u0635\u0641\u0648\u0641\u0629 \u0628\u064A\u0646 \u062E\u0637\u064A\u0646 \u0645\u0632\u062F\u0648\u062C\u064A\u0646",
3451
+ compactToolbar: "\u0634\u0631\u064A\u0637 \u0623\u0648\u0627\u0645\u0631 \u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629",
3452
+ moreActions: "\u0627\u0644\u0645\u0632\u064A\u062F",
3453
+ commandCategories: "\u0641\u0626\u0627\u062A \u0627\u0644\u0623\u0648\u0627\u0645\u0631",
3454
+ back: "\u0631\u062C\u0648\u0639",
3455
+ closeActions: "\u0625\u063A\u0644\u0627\u0642 \u0627\u0644\u0623\u0648\u0627\u0645\u0631",
3456
+ matrices: "\u0627\u0644\u0645\u0635\u0641\u0648\u0641\u0627\u062A",
3457
+ typography: "\u0627\u0644\u062E\u0637 \u0648\u0627\u0644\u0625\u062F\u062E\u0627\u0644",
3458
+ digitForms: "\u0623\u0634\u0643\u0627\u0644 \u0627\u0644\u0623\u0631\u0642\u0627\u0645",
3459
+ commonMatrixSizes: "\u0623\u062D\u062C\u0627\u0645 \u0634\u0627\u0626\u0639\u0629",
3460
+ decreaseRows: "\u062A\u0642\u0644\u064A\u0644 \u0627\u0644\u0635\u0641\u0648\u0641",
3461
+ increaseRows: "\u0632\u064A\u0627\u062F\u0629 \u0627\u0644\u0635\u0641\u0648\u0641",
3462
+ decreaseColumns: "\u062A\u0642\u0644\u064A\u0644 \u0627\u0644\u0623\u0639\u0645\u062F\u0629",
3463
+ increaseColumns: "\u0632\u064A\u0627\u062F\u0629 \u0627\u0644\u0623\u0639\u0645\u062F\u0629",
3464
+ showPreview: "\u0625\u0638\u0647\u0627\u0631 \u0627\u0644\u0645\u0639\u0627\u064A\u0646\u0629",
3465
+ hidePreview: "\u0625\u062E\u0641\u0627\u0621 \u0627\u0644\u0645\u0639\u0627\u064A\u0646\u0629"
3451
3466
  },
3452
3467
  en: {
3453
3468
  undoRedo: "Undo and redo",
@@ -3559,7 +3574,22 @@ var EQUATION_EDITOR_MESSAGES = {
3559
3574
  matrixBrackets: "Matrix in brackets",
3560
3575
  matrixBraces: "Matrix in braces",
3561
3576
  matrixBars: "Matrix between bars",
3562
- matrixDoubleBars: "Matrix between double bars"
3577
+ matrixDoubleBars: "Matrix between double bars",
3578
+ compactToolbar: "Equation command toolbar",
3579
+ moreActions: "More",
3580
+ commandCategories: "Command categories",
3581
+ back: "Back",
3582
+ closeActions: "Close actions",
3583
+ matrices: "Matrices",
3584
+ typography: "Typography and input",
3585
+ digitForms: "Digit forms",
3586
+ commonMatrixSizes: "Common sizes",
3587
+ decreaseRows: "Decrease rows",
3588
+ increaseRows: "Increase rows",
3589
+ decreaseColumns: "Decrease columns",
3590
+ increaseColumns: "Increase columns",
3591
+ showPreview: "Show preview",
3592
+ hidePreview: "Hide preview"
3563
3593
  }
3564
3594
  };
3565
3595
  function equationEditorMessages(locale) {
@@ -5870,14 +5900,20 @@ var BUTEX_EDITOR_CSS = `
5870
5900
  ${BUTEX_FONT_FACE_CSS}
5871
5901
 
5872
5902
  .surface {
5903
+ background: var(--butex-surface-bg, linear-gradient(180deg, #ffffff 0%, #fafbfc 100%));
5873
5904
  border: 1px solid var(--butex-border, #e2e8f0);
5874
5905
  border-radius: 12px;
5875
- min-height: 100px;
5876
- padding: 8px 10px;
5877
- background: var(--butex-surface-bg, linear-gradient(180deg, #ffffff 0%, #fafbfc 100%));
5878
5906
  color: var(--butex-surface-fg, #0f172a);
5879
- outline: none;
5880
5907
  cursor: text;
5908
+ max-width: 100%;
5909
+ min-height: 100px;
5910
+ min-width: 0;
5911
+ outline: none;
5912
+ overflow-x: auto;
5913
+ overflow-y: hidden;
5914
+ overscroll-behavior-inline: contain;
5915
+ padding: 8px 10px;
5916
+ touch-action: pan-x pan-y;
5881
5917
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
5882
5918
  }
5883
5919
 
@@ -5942,6 +5978,17 @@ ${CHARACTER_FONT_CSS}
5942
5978
  50% { opacity: 0; }
5943
5979
  }
5944
5980
 
5981
+ @media (prefers-reduced-motion: reduce) {
5982
+ .surface {
5983
+ scroll-behavior: auto;
5984
+ transition: none;
5985
+ }
5986
+
5987
+ .caret {
5988
+ animation: none;
5989
+ }
5990
+ }
5991
+
5945
5992
  .node {
5946
5993
  display: inline-flex;
5947
5994
  align-items: stretch;
@@ -6073,6 +6120,42 @@ function injectBuTeXEditorStyles(doc) {
6073
6120
  }
6074
6121
 
6075
6122
  // src/editor/runtime.ts
6123
+ var CARET_REVEAL_GUTTER_PX = 8;
6124
+ function revealCaretInSurface(surfaceEl, caretEl) {
6125
+ const activeTarget = caretEl ?? surfaceEl.querySelector(".caret") ?? surfaceEl.querySelector(".node.selected");
6126
+ if (!activeTarget) {
6127
+ return;
6128
+ }
6129
+ const surfaceRect = surfaceEl.getBoundingClientRect();
6130
+ const targetRect = activeTarget.getBoundingClientRect();
6131
+ if (surfaceRect.width <= 0) {
6132
+ return;
6133
+ }
6134
+ const gutter = Math.min(CARET_REVEAL_GUTTER_PX, surfaceRect.width / 4);
6135
+ const visibleLeft = surfaceRect.left + gutter;
6136
+ const visibleRight = surfaceRect.right - gutter;
6137
+ const visibleWidth = visibleRight - visibleLeft;
6138
+ let delta = 0;
6139
+ if (targetRect.width > visibleWidth) {
6140
+ if (targetRect.right < visibleLeft) {
6141
+ delta = targetRect.right - visibleLeft;
6142
+ } else if (targetRect.left > visibleRight) {
6143
+ delta = targetRect.left - visibleRight;
6144
+ }
6145
+ } else if (targetRect.left < visibleLeft) {
6146
+ delta = targetRect.left - visibleLeft;
6147
+ } else if (targetRect.right > visibleRight) {
6148
+ delta = targetRect.right - visibleRight;
6149
+ }
6150
+ if (delta === 0) {
6151
+ return;
6152
+ }
6153
+ if (typeof surfaceEl.scrollBy === "function") {
6154
+ surfaceEl.scrollBy({ left: delta, behavior: "auto" });
6155
+ } else {
6156
+ surfaceEl.scrollLeft += delta;
6157
+ }
6158
+ }
6076
6159
  function createEditorRuntime(options) {
6077
6160
  const { surfaceEl, inputEl } = options;
6078
6161
  const buttonElements = options.buttonElements ?? {};
@@ -6090,6 +6173,16 @@ function createEditorRuntime(options) {
6090
6173
  let dragChanged = false;
6091
6174
  let composingInput = false;
6092
6175
  let pendingCompositionText = null;
6176
+ let caretRevealFrame = null;
6177
+ function scheduleCaretReveal() {
6178
+ if (caretRevealFrame !== null) {
6179
+ cancelAnimationFrame(caretRevealFrame);
6180
+ }
6181
+ caretRevealFrame = requestAnimationFrame(() => {
6182
+ caretRevealFrame = null;
6183
+ revealCaretInSurface(surfaceEl);
6184
+ });
6185
+ }
6093
6186
  function resetInputElement() {
6094
6187
  if (!inputEl) {
6095
6188
  return;
@@ -6456,6 +6549,7 @@ function createEditorRuntime(options) {
6456
6549
  surfaceEl.innerHTML = "";
6457
6550
  const activeTree = session[activeTreeKey(session.activeSide)];
6458
6551
  surfaceEl.appendChild(buildChain(activeTree));
6552
+ scheduleCaretReveal();
6459
6553
  if (initialKeyboardFocusPending) {
6460
6554
  requestAnimationFrame(focusInput);
6461
6555
  initialKeyboardFocusPending = false;
@@ -6771,6 +6865,10 @@ function createEditorRuntime(options) {
6771
6865
  const api = {
6772
6866
  render,
6773
6867
  destroy: () => {
6868
+ if (caretRevealFrame !== null) {
6869
+ cancelAnimationFrame(caretRevealFrame);
6870
+ caretRevealFrame = null;
6871
+ }
6774
6872
  surfaceEl.removeEventListener("keydown", onKeyDown);
6775
6873
  inputEl?.removeEventListener("keydown", onKeyDown);
6776
6874
  inputEl?.removeEventListener("beforeinput", onBeforeInput);
@@ -8394,7 +8492,211 @@ async function mountBuTeXMathIsland(host, tex, options = {}) {
8394
8492
  }
8395
8493
 
8396
8494
  // src/react/ButexEditor.tsx
8397
- var import_react = require("react");
8495
+ var import_react4 = require("react");
8496
+
8497
+ // src/react/matrixPickerCss.ts
8498
+ var MATRIX_PICKER_CSS = `
8499
+ .butex-widget .matrix-grid-picker,
8500
+ .butex-widget .matrix-grid-cell {
8501
+ box-sizing: border-box;
8502
+ }
8503
+
8504
+ .butex-widget .matrix-command-menu {
8505
+ position: relative;
8506
+ display: inline-flex;
8507
+ }
8508
+
8509
+ .butex-widget .matrix-command-btn::after {
8510
+ content: "";
8511
+ width: 0;
8512
+ height: 0;
8513
+ margin-inline-start: 3px;
8514
+ border-inline: 3px solid transparent;
8515
+ border-block-start: 4px solid currentColor;
8516
+ opacity: 0.72;
8517
+ }
8518
+
8519
+ .butex-widget .toolbar-matrix-icon {
8520
+ width: 14px;
8521
+ height: 14px;
8522
+ display: grid;
8523
+ grid-template-columns: repeat(2, 1fr);
8524
+ gap: 2px;
8525
+ }
8526
+
8527
+ .butex-widget .toolbar-matrix-icon span {
8528
+ border: 1px solid currentColor;
8529
+ border-radius: 2px;
8530
+ }
8531
+
8532
+ .butex-widget .matrix-command-popover {
8533
+ position: absolute;
8534
+ z-index: var(--butex-z-popover);
8535
+ top: calc(100% + 5px);
8536
+ right: 0;
8537
+ width: 252px;
8538
+ padding: 8px;
8539
+ border: 1px solid var(--butex-border);
8540
+ border-radius: 9px;
8541
+ background: var(--butex-panel);
8542
+ color: var(--butex-fg);
8543
+ box-shadow: var(--butex-shadow-md);
8544
+ }
8545
+
8546
+ .butex-widget .matrix-command-popover[hidden] {
8547
+ display: none;
8548
+ }
8549
+
8550
+ .butex-widget .matrix-style-options,
8551
+ .butex-widget .matrix-edit-actions,
8552
+ .butex-widget .matrix-custom-size {
8553
+ display: flex;
8554
+ gap: 5px;
8555
+ align-items: center;
8556
+ flex-wrap: wrap;
8557
+ }
8558
+
8559
+ .butex-widget .toolbar .matrix-style-option,
8560
+ .butex-widget .toolbar .matrix-edit-actions button,
8561
+ .butex-widget .toolbar .matrix-insert-custom {
8562
+ height: 26px;
8563
+ min-width: 30px;
8564
+ padding: 0 6px;
8565
+ border-radius: 7px;
8566
+ }
8567
+
8568
+ .butex-widget .toolbar .matrix-style-option[aria-selected="true"] {
8569
+ border-color: var(--butex-toolbar-hover-border);
8570
+ background: var(--butex-toolbar-hover-bg);
8571
+ }
8572
+
8573
+ .butex-widget .matrix-size-readout {
8574
+ margin: 7px 0 5px;
8575
+ font-size: 12px;
8576
+ color: var(--butex-muted);
8577
+ text-align: center;
8578
+ direction: ltr;
8579
+ }
8580
+
8581
+ .butex-widget .matrix-grid-picker {
8582
+ display: grid;
8583
+ grid-template-columns: repeat(8, 16px);
8584
+ grid-auto-rows: 16px;
8585
+ gap: 3px;
8586
+ justify-content: center;
8587
+ margin-bottom: 7px;
8588
+ }
8589
+
8590
+ .butex-widget .toolbar .matrix-grid-cell {
8591
+ width: 16px;
8592
+ height: 16px;
8593
+ min-width: 0;
8594
+ padding: 0;
8595
+ border-radius: 3px;
8596
+ border-color: var(--butex-border);
8597
+ }
8598
+
8599
+ .butex-widget .toolbar .matrix-grid-cell.active {
8600
+ border-color: var(--butex-toolbar-hover-border);
8601
+ background: var(--butex-toolbar-hover-bg);
8602
+ }
8603
+
8604
+ .butex-widget .matrix-custom-size {
8605
+ justify-content: center;
8606
+ margin-bottom: 7px;
8607
+ }
8608
+
8609
+ .butex-widget .matrix-custom-size label {
8610
+ display: inline-flex;
8611
+ align-items: center;
8612
+ gap: 3px;
8613
+ font-size: 11px;
8614
+ color: var(--butex-muted);
8615
+ }
8616
+
8617
+ .butex-widget .matrix-custom-size input {
8618
+ width: 42px;
8619
+ height: 24px;
8620
+ border: 1px solid var(--butex-border);
8621
+ border-radius: 6px;
8622
+ padding: 0 4px;
8623
+ direction: ltr;
8624
+ }
8625
+
8626
+ .butex-widget .matrix-edit-actions {
8627
+ justify-content: center;
8628
+ border-top: 1px solid var(--butex-border);
8629
+ padding-top: 7px;
8630
+ }
8631
+
8632
+ .butex-widget .butex-widget__mobile-matrix-picker {
8633
+ display: grid;
8634
+ gap: 14px;
8635
+ min-width: 0;
8636
+ }
8637
+
8638
+ .butex-widget .butex-widget__matrix-presets {
8639
+ display: grid;
8640
+ gap: 8px;
8641
+ grid-template-columns: repeat(4, minmax(44px, 1fr));
8642
+ }
8643
+
8644
+ .butex-widget .butex-widget__matrix-stepper-row {
8645
+ align-items: center;
8646
+ display: flex;
8647
+ gap: 12px;
8648
+ justify-content: space-between;
8649
+ }
8650
+
8651
+ .butex-widget .butex-widget__matrix-stepper {
8652
+ align-items: center;
8653
+ direction: ltr;
8654
+ display: grid;
8655
+ gap: 8px;
8656
+ grid-template-columns: 44px minmax(42px, auto) 44px;
8657
+ }
8658
+
8659
+ .butex-widget .butex-widget__matrix-stepper output {
8660
+ font-variant-numeric: tabular-nums;
8661
+ font-weight: 700;
8662
+ text-align: center;
8663
+ }
8664
+
8665
+ .butex-widget .butex-widget__matrix-size-summary {
8666
+ color: var(--butex-muted);
8667
+ direction: ltr;
8668
+ margin: 0;
8669
+ text-align: center;
8670
+ }
8671
+
8672
+ .butex-widget .butex-widget__matrix-insert {
8673
+ background: var(--butex-accent-hover);
8674
+ border-color: var(--butex-accent-hover);
8675
+ color: var(--butex-on-accent);
8676
+ width: 100%;
8677
+ }
8678
+
8679
+ .butex-widget .butex-widget__matrix-alignment {
8680
+ align-items: center;
8681
+ display: flex;
8682
+ flex-wrap: wrap;
8683
+ gap: 8px;
8684
+ }
8685
+
8686
+ .butex-widget .butex-widget__matrix-alignment label {
8687
+ align-items: center;
8688
+ display: inline-flex;
8689
+ gap: 6px;
8690
+ }
8691
+
8692
+ .butex-widget .butex-widget__matrix-alignment input {
8693
+ border: 1px solid var(--butex-border);
8694
+ border-radius: 8px;
8695
+ min-height: 44px;
8696
+ padding-inline: 8px;
8697
+ width: 70px;
8698
+ }
8699
+ `.trim();
8398
8700
 
8399
8701
  // src/react/widgetChromeCss.ts
8400
8702
  var WIDGET_CHROME_CSS = `
@@ -8442,9 +8744,22 @@ var WIDGET_CHROME_CSS = `
8442
8744
  --butex-script-color: #475569;
8443
8745
  --butex-delim-color: #475569;
8444
8746
  --butex-frac-bar: currentColor;
8747
+ --butex-z-popover: 10;
8748
+ box-sizing: border-box;
8445
8749
  font-family: ui-sans-serif, system-ui, "Segoe UI", Tahoma, Arial, sans-serif;
8446
8750
  color: var(--butex-fg);
8751
+ container-name: butex-equation;
8752
+ container-type: inline-size;
8447
8753
  line-height: 1.45;
8754
+ max-width: 100%;
8755
+ min-width: 0;
8756
+ width: 100%;
8757
+ }
8758
+
8759
+ .butex-widget *,
8760
+ .butex-widget *::before,
8761
+ .butex-widget *::after {
8762
+ box-sizing: inherit;
8448
8763
  }
8449
8764
 
8450
8765
  .butex-widget .butex-widget-layout {
@@ -8453,12 +8768,16 @@ var WIDGET_CHROME_CSS = `
8453
8768
  gap: 8px;
8454
8769
  max-width: 920px;
8455
8770
  margin: 0 auto;
8771
+ min-width: 0;
8772
+ width: 100%;
8456
8773
  }
8457
8774
 
8458
8775
  .butex-widget .panel {
8459
8776
  background: var(--butex-panel);
8460
8777
  border: 1px solid var(--butex-border);
8461
8778
  border-radius: 14px;
8779
+ max-width: 100%;
8780
+ min-width: 0;
8462
8781
  padding: 12px 14px;
8463
8782
  box-shadow: var(--butex-shadow-md);
8464
8783
  }
@@ -8491,30 +8810,200 @@ var WIDGET_CHROME_CSS = `
8491
8810
  margin-bottom: 8px;
8492
8811
  align-items: center;
8493
8812
  align-content: flex-start;
8813
+ min-width: 0;
8814
+ position: relative;
8494
8815
  }
8495
8816
 
8496
- .butex-widget .toolbar button {
8817
+ .butex-widget .butex-widget__mobile-toolbar,
8818
+ .butex-widget .butex-widget__mobile-preview-toggle,
8819
+ .butex-widget .butex-widget__command-sheet-backdrop {
8820
+ display: none;
8821
+ }
8822
+
8823
+ .butex-widget .butex-widget__mobile-toolbar {
8824
+ background: var(--butex-panel);
8825
+ gap: 4px;
8826
+ grid-template-columns: repeat(8, minmax(44px, 1fr));
8827
+ margin-bottom: 8px;
8828
+ min-width: 0;
8829
+ position: sticky;
8830
+ top: 0;
8831
+ z-index: 1;
8832
+ }
8833
+
8834
+ .butex-widget .butex-widget__mobile-toolbar button,
8835
+ .butex-widget .butex-widget__mobile-preview-toggle,
8836
+ .butex-widget .butex-widget__command-sheet button {
8837
+ align-items: center;
8838
+ background: var(--butex-panel);
8497
8839
  border: 1px solid var(--butex-border);
8498
8840
  border-radius: 9px;
8499
- background: var(--butex-panel);
8500
8841
  color: var(--butex-fg);
8501
- min-width: 30px;
8502
- height: 30px;
8503
- padding: 0 7px;
8504
- font-size: 12px;
8505
- font-weight: 600;
8506
8842
  cursor: pointer;
8507
8843
  display: inline-flex;
8508
- align-items: center;
8844
+ font: inherit;
8845
+ font-size: 13px;
8846
+ font-weight: 600;
8509
8847
  justify-content: center;
8510
- line-height: 1;
8511
- transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease, color 0.14s ease;
8848
+ min-height: 44px;
8849
+ min-width: 44px;
8850
+ padding: 6px 9px;
8512
8851
  }
8513
8852
 
8514
- .butex-widget .toolbar button:hover {
8515
- border-color: var(--butex-toolbar-hover-border);
8516
- background: var(--butex-toolbar-hover-bg);
8517
- transform: translateY(-1px);
8853
+ .butex-widget .butex-widget__mobile-preview-toggle {
8854
+ display: none;
8855
+ }
8856
+
8857
+ .butex-widget .butex-widget__mobile-toolbar button:disabled,
8858
+ .butex-widget .butex-widget__command-sheet button:disabled {
8859
+ cursor: not-allowed;
8860
+ opacity: 0.42;
8861
+ }
8862
+
8863
+ .butex-widget .butex-widget__mobile-toolbar button:focus-visible,
8864
+ .butex-widget .butex-widget__mobile-preview-toggle:focus-visible,
8865
+ .butex-widget .butex-widget__command-sheet button:focus-visible {
8866
+ border-color: var(--butex-accent);
8867
+ box-shadow: 0 0 0 3px var(--butex-focus-shadow);
8868
+ outline: none;
8869
+ }
8870
+
8871
+ .butex-widget .butex-widget__mobile-toolbar button[aria-expanded="true"],
8872
+ .butex-widget .butex-widget__mobile-preview-toggle[aria-expanded="true"],
8873
+ .butex-widget .butex-widget__command-sheet button[aria-pressed="true"],
8874
+ .butex-widget .butex-widget__command-sheet button[aria-selected="true"] {
8875
+ background: var(--butex-toolbar-hover-bg);
8876
+ border-color: var(--butex-toolbar-hover-border);
8877
+ box-shadow: 0 0 0 2px var(--butex-focus-shadow);
8878
+ }
8879
+
8880
+ .butex-widget .butex-widget__mobile-danger {
8881
+ color: var(--butex-danger);
8882
+ }
8883
+
8884
+ .butex-widget .butex-widget__mobile-preview-toggle {
8885
+ align-self: flex-start;
8886
+ margin-top: 8px;
8887
+ }
8888
+
8889
+ .butex-widget .butex-widget__command-sheet-backdrop {
8890
+ align-items: flex-end;
8891
+ background: rgba(15, 23, 42, 0.38);
8892
+ inset: 0;
8893
+ justify-content: center;
8894
+ padding-bottom: var(--butex-safe-area-bottom, env(safe-area-inset-bottom, 0px));
8895
+ padding-left: max(12px, var(--butex-safe-area-left, env(safe-area-inset-left, 0px)));
8896
+ padding-right: max(12px, var(--butex-safe-area-right, env(safe-area-inset-right, 0px)));
8897
+ padding-top: max(12px, var(--butex-safe-area-top, env(safe-area-inset-top, 0px)));
8898
+ position: fixed;
8899
+ z-index: var(--butex-z-popover);
8900
+ }
8901
+
8902
+ .butex-widget .butex-widget__command-sheet {
8903
+ background: var(--butex-panel);
8904
+ border: 1px solid var(--butex-border);
8905
+ border-radius: 16px 16px 0 0;
8906
+ box-shadow: 0 -18px 48px rgba(15, 23, 42, 0.22);
8907
+ display: grid;
8908
+ grid-template-rows: auto minmax(0, 1fr);
8909
+ max-height: min(78vh, 720px);
8910
+ 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))));
8911
+ max-width: 640px;
8912
+ min-width: 0;
8913
+ overflow: hidden;
8914
+ width: 100%;
8915
+ }
8916
+
8917
+ .butex-widget .butex-widget__command-sheet-header {
8918
+ align-items: center;
8919
+ border-bottom: 1px solid var(--butex-border);
8920
+ display: grid;
8921
+ gap: 8px;
8922
+ grid-template-columns: minmax(44px, auto) minmax(0, 1fr) minmax(44px, auto);
8923
+ padding: 10px 12px;
8924
+ text-align: center;
8925
+ }
8926
+
8927
+ .butex-widget .butex-widget__command-sheet-header strong {
8928
+ overflow-wrap: anywhere;
8929
+ }
8930
+
8931
+ .butex-widget .butex-widget__command-sheet-body {
8932
+ display: grid;
8933
+ gap: 14px;
8934
+ min-height: 0;
8935
+ min-width: 0;
8936
+ overflow-y: auto;
8937
+ overscroll-behavior: contain;
8938
+ padding: 12px;
8939
+ }
8940
+
8941
+ .butex-widget .butex-widget__sheet-section {
8942
+ display: grid;
8943
+ gap: 8px;
8944
+ min-width: 0;
8945
+ }
8946
+
8947
+ .butex-widget .butex-widget__sheet-section h4 {
8948
+ font-size: 13px;
8949
+ margin: 0;
8950
+ }
8951
+
8952
+ .butex-widget .butex-widget__sheet-categories,
8953
+ .butex-widget .butex-widget__sheet-command-grid,
8954
+ .butex-widget .butex-widget__sheet-command-list,
8955
+ .butex-widget .butex-widget__sheet-choice-row {
8956
+ display: grid;
8957
+ gap: 8px;
8958
+ min-width: 0;
8959
+ }
8960
+
8961
+ .butex-widget .butex-widget__sheet-categories,
8962
+ .butex-widget .butex-widget__sheet-command-grid {
8963
+ grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
8964
+ }
8965
+
8966
+ .butex-widget .butex-widget__sheet-command-grid--three,
8967
+ .butex-widget .butex-widget__sheet-choice-row {
8968
+ grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
8969
+ }
8970
+
8971
+ .butex-widget .butex-widget__sheet-categories button,
8972
+ .butex-widget .butex-widget__sheet-command-list button {
8973
+ justify-content: flex-start;
8974
+ overflow-wrap: anywhere;
8975
+ text-align: start;
8976
+ }
8977
+
8978
+ .butex-widget .butex-widget__command-sheet .operator-command-svg-label {
8979
+ background-color: currentColor;
8980
+ display: inline-block;
8981
+ height: 22px;
8982
+ width: 22px;
8983
+ }
8984
+
8985
+ .butex-widget .toolbar button {
8986
+ border: 1px solid var(--butex-border);
8987
+ border-radius: 9px;
8988
+ background: var(--butex-panel);
8989
+ color: var(--butex-fg);
8990
+ min-width: 30px;
8991
+ height: 30px;
8992
+ padding: 0 7px;
8993
+ font-size: 12px;
8994
+ font-weight: 600;
8995
+ cursor: pointer;
8996
+ display: inline-flex;
8997
+ align-items: center;
8998
+ justify-content: center;
8999
+ line-height: 1;
9000
+ transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease, color 0.14s ease;
9001
+ }
9002
+
9003
+ .butex-widget .toolbar button:hover {
9004
+ border-color: var(--butex-toolbar-hover-border);
9005
+ background: var(--butex-toolbar-hover-bg);
9006
+ transform: translateY(-1px);
8518
9007
  }
8519
9008
 
8520
9009
  .butex-widget .toolbar button:disabled {
@@ -8558,7 +9047,7 @@ var WIDGET_CHROME_CSS = `
8558
9047
 
8559
9048
  .butex-widget .delimiter-command-options {
8560
9049
  position: absolute;
8561
- z-index: 10;
9050
+ z-index: var(--butex-z-popover);
8562
9051
  top: calc(100% + 5px);
8563
9052
  right: 0;
8564
9053
  left: auto;
@@ -8637,133 +9126,7 @@ var WIDGET_CHROME_CSS = `
8637
9126
  opacity: 0.85;
8638
9127
  }
8639
9128
 
8640
- .butex-widget .matrix-command-menu {
8641
- position: relative;
8642
- display: inline-flex;
8643
- }
8644
-
8645
- .butex-widget .matrix-command-btn::after {
8646
- content: "";
8647
- width: 0;
8648
- height: 0;
8649
- margin-inline-start: 3px;
8650
- border-inline: 3px solid transparent;
8651
- border-block-start: 4px solid currentColor;
8652
- opacity: 0.72;
8653
- }
8654
-
8655
- .butex-widget .toolbar-matrix-icon {
8656
- width: 14px;
8657
- height: 14px;
8658
- display: grid;
8659
- grid-template-columns: repeat(2, 1fr);
8660
- gap: 2px;
8661
- }
8662
-
8663
- .butex-widget .toolbar-matrix-icon span {
8664
- border: 1px solid currentColor;
8665
- border-radius: 2px;
8666
- }
8667
-
8668
- .butex-widget .matrix-command-popover {
8669
- position: absolute;
8670
- z-index: 12;
8671
- top: calc(100% + 5px);
8672
- right: 0;
8673
- width: 252px;
8674
- padding: 8px;
8675
- border: 1px solid var(--butex-border);
8676
- border-radius: 9px;
8677
- background: var(--butex-panel);
8678
- color: var(--butex-fg);
8679
- box-shadow: var(--butex-shadow-md);
8680
- }
8681
-
8682
- .butex-widget .matrix-command-popover[hidden] {
8683
- display: none;
8684
- }
8685
-
8686
- .butex-widget .matrix-style-options,
8687
- .butex-widget .matrix-edit-actions,
8688
- .butex-widget .matrix-custom-size {
8689
- display: flex;
8690
- gap: 5px;
8691
- align-items: center;
8692
- flex-wrap: wrap;
8693
- }
8694
-
8695
- .butex-widget .toolbar .matrix-style-option,
8696
- .butex-widget .toolbar .matrix-edit-actions button,
8697
- .butex-widget .toolbar .matrix-insert-custom {
8698
- height: 26px;
8699
- min-width: 30px;
8700
- padding: 0 6px;
8701
- border-radius: 7px;
8702
- }
8703
-
8704
- .butex-widget .toolbar .matrix-style-option[aria-selected="true"] {
8705
- border-color: var(--butex-toolbar-hover-border);
8706
- background: var(--butex-toolbar-hover-bg);
8707
- }
8708
-
8709
- .butex-widget .matrix-size-readout {
8710
- margin: 7px 0 5px;
8711
- font-size: 12px;
8712
- color: var(--butex-muted);
8713
- text-align: center;
8714
- direction: ltr;
8715
- }
8716
-
8717
- .butex-widget .matrix-grid-picker {
8718
- display: grid;
8719
- grid-template-columns: repeat(8, 16px);
8720
- grid-auto-rows: 16px;
8721
- gap: 3px;
8722
- justify-content: center;
8723
- margin-bottom: 7px;
8724
- }
8725
-
8726
- .butex-widget .toolbar .matrix-grid-cell {
8727
- width: 16px;
8728
- height: 16px;
8729
- min-width: 0;
8730
- padding: 0;
8731
- border-radius: 3px;
8732
- border-color: var(--butex-border);
8733
- }
8734
-
8735
- .butex-widget .toolbar .matrix-grid-cell.active {
8736
- border-color: var(--butex-toolbar-hover-border);
8737
- background: var(--butex-toolbar-hover-bg);
8738
- }
8739
-
8740
- .butex-widget .matrix-custom-size {
8741
- justify-content: center;
8742
- margin-bottom: 7px;
8743
- }
8744
-
8745
- .butex-widget .matrix-custom-size label {
8746
- display: inline-flex;
8747
- align-items: center;
8748
- gap: 3px;
8749
- font-size: 11px;
8750
- color: var(--butex-muted);
8751
- }
8752
-
8753
- .butex-widget .matrix-custom-size input {
8754
- width: 42px;
8755
- height: 24px;
8756
- border: 1px solid var(--butex-border);
8757
- border-radius: 6px;
8758
- padding: 0 4px;
8759
- direction: ltr;
8760
- }
8761
-
8762
- .butex-widget .matrix-edit-actions {
8763
- justify-content: center;
8764
- border-top: 1px solid var(--butex-border);
8765
- padding-top: 7px;
8766
- }
9129
+ ${MATRIX_PICKER_CSS}
8767
9130
 
8768
9131
  .butex-widget .script-icon-btn {
8769
9132
  min-width: 32px;
@@ -8799,28 +9162,32 @@ var WIDGET_CHROME_CSS = `
8799
9162
  }
8800
9163
 
8801
9164
  .butex-widget .font-mode-btn--takween,
8802
- .butex-widget .character-font-option--takween {
9165
+ .butex-widget .character-font-option--takween,
9166
+ .butex-widget .butex-widget__command-sheet .character-font-option--takween {
8803
9167
  font-family: ${BUTEX_TAKWEEN_FONT_STACK};
8804
9168
  }
8805
9169
 
8806
9170
  .butex-widget .font-mode-btn--diwani,
8807
- .butex-widget .character-font-option--diwani {
9171
+ .butex-widget .character-font-option--diwani,
9172
+ .butex-widget .butex-widget__command-sheet .character-font-option--diwani {
8808
9173
  font-family: ${BUTEX_DIWANI_FONT_STACK};
8809
9174
  }
8810
9175
 
8811
9176
  .butex-widget .font-mode-btn--diwaniOutline,
8812
- .butex-widget .character-font-option--diwaniOutline {
9177
+ .butex-widget .character-font-option--diwaniOutline,
9178
+ .butex-widget .butex-widget__command-sheet .character-font-option--diwaniOutline {
8813
9179
  font-family: ${BUTEX_DIWANI_OUTLINE_FONT_STACK};
8814
9180
  }
8815
9181
 
8816
9182
  .butex-widget .font-mode-btn--maghribi,
8817
- .butex-widget .character-font-option--maghribi {
9183
+ .butex-widget .character-font-option--maghribi,
9184
+ .butex-widget .butex-widget__command-sheet .character-font-option--maghribi {
8818
9185
  font-family: ${BUTEX_MAGHRIBI_FONT_STACK};
8819
9186
  }
8820
9187
 
8821
9188
  .butex-widget .character-font-options {
8822
9189
  position: absolute;
8823
- z-index: 10;
9190
+ z-index: var(--butex-z-popover);
8824
9191
  top: calc(100% + 5px);
8825
9192
  right: 0;
8826
9193
  left: auto;
@@ -8857,8 +9224,9 @@ var WIDGET_CHROME_CSS = `
8857
9224
  }
8858
9225
 
8859
9226
  .butex-widget .toolbar .character-font-option[aria-selected="true"] {
8860
- background: linear-gradient(180deg, var(--butex-accent) 0%, var(--butex-accent-hover) 100%);
9227
+ background: var(--butex-accent-hover);
8861
9228
  color: var(--butex-on-accent);
9229
+ box-shadow: inset 0 0 0 2px currentColor;
8862
9230
  }
8863
9231
 
8864
9232
  .butex-widget .toolbar-script-icon {
@@ -8948,6 +9316,16 @@ var WIDGET_CHROME_CSS = `
8948
9316
  font-family: ${BUTEX_DIWANI_OUTLINE_FONT_STACK};
8949
9317
  }
8950
9318
 
9319
+ .butex-widget .butex-widget__command-sheet .function-command-option {
9320
+ direction: rtl;
9321
+ font-family: ${BUTEX_DIWANI_FONT_STACK};
9322
+ font-size: 17px;
9323
+ }
9324
+
9325
+ .butex-widget .butex-widget__command-sheet .function-command-option--outline {
9326
+ font-family: ${BUTEX_DIWANI_OUTLINE_FONT_STACK};
9327
+ }
9328
+
8951
9329
  .butex-widget .function-command-btn::after {
8952
9330
  content: "";
8953
9331
  width: 0;
@@ -8966,7 +9344,7 @@ var WIDGET_CHROME_CSS = `
8966
9344
 
8967
9345
  .butex-widget .function-command-options {
8968
9346
  position: absolute;
8969
- z-index: 10;
9347
+ z-index: var(--butex-z-popover);
8970
9348
  top: calc(100% + 5px);
8971
9349
  right: 0;
8972
9350
  left: auto;
@@ -9028,6 +9406,11 @@ var WIDGET_CHROME_CSS = `
9028
9406
  font-family: "Cambria Math", "Times New Roman", serif;
9029
9407
  }
9030
9408
 
9409
+ .butex-widget .butex-widget__command-sheet .operator-command-option {
9410
+ font-family: "Cambria Math", "Times New Roman", serif;
9411
+ font-size: 17px;
9412
+ }
9413
+
9031
9414
  .butex-widget .operator-command-label {
9032
9415
  display: inline-flex;
9033
9416
  align-items: center;
@@ -9063,7 +9446,7 @@ var WIDGET_CHROME_CSS = `
9063
9446
 
9064
9447
  .butex-widget .spacing-command-options {
9065
9448
  position: absolute;
9066
- z-index: 10;
9449
+ z-index: var(--butex-z-popover);
9067
9450
  top: calc(100% + 5px);
9068
9451
  right: 0;
9069
9452
  left: auto;
@@ -9179,7 +9562,7 @@ var WIDGET_CHROME_CSS = `
9179
9562
 
9180
9563
  .butex-widget .digit-form-options {
9181
9564
  position: absolute;
9182
- z-index: 10;
9565
+ z-index: var(--butex-z-popover);
9183
9566
  top: calc(100% + 5px);
9184
9567
  right: 0;
9185
9568
  left: auto;
@@ -9216,8 +9599,9 @@ var WIDGET_CHROME_CSS = `
9216
9599
  }
9217
9600
 
9218
9601
  .butex-widget .toolbar .digit-form-option[aria-selected="true"] {
9219
- background: linear-gradient(180deg, var(--butex-accent) 0%, var(--butex-accent-hover) 100%);
9602
+ background: var(--butex-accent-hover);
9220
9603
  color: var(--butex-on-accent);
9604
+ box-shadow: inset 0 0 0 2px currentColor;
9221
9605
  }
9222
9606
 
9223
9607
  .butex-widget .delete-node-btn,
@@ -9245,6 +9629,8 @@ var WIDGET_CHROME_CSS = `
9245
9629
  border: 1px solid var(--butex-border);
9246
9630
  border-radius: 10px;
9247
9631
  background: rgba(248, 250, 252, 0.72);
9632
+ max-width: 100%;
9633
+ min-width: 0;
9248
9634
  }
9249
9635
 
9250
9636
  .butex-widget .toolbar-functions,
@@ -9253,9 +9639,10 @@ var WIDGET_CHROME_CSS = `
9253
9639
  }
9254
9640
 
9255
9641
  .butex-widget .toolbar .accent {
9256
- background: linear-gradient(180deg, var(--butex-accent) 0%, var(--butex-accent-hover) 100%);
9642
+ background: var(--butex-accent-hover);
9257
9643
  color: var(--butex-on-accent);
9258
9644
  border-color: transparent;
9645
+ box-shadow: inset 0 0 0 2px currentColor;
9259
9646
  }
9260
9647
 
9261
9648
  .butex-widget .preview-box {
@@ -9264,7 +9651,13 @@ var WIDGET_CHROME_CSS = `
9264
9651
  padding: 10px 12px;
9265
9652
  background: var(--butex-preview-bg);
9266
9653
  color: var(--butex-preview-fg);
9654
+ max-width: 100%;
9267
9655
  min-height: 48px;
9656
+ min-width: 0;
9657
+ overflow-x: auto;
9658
+ overflow-y: hidden;
9659
+ overscroll-behavior-inline: contain;
9660
+ touch-action: pan-x pan-y;
9268
9661
  }
9269
9662
 
9270
9663
  .butex-widget .error {
@@ -9372,80 +9765,1053 @@ var WIDGET_CHROME_CSS = `
9372
9765
  background: var(--butex-dev-inset-bg);
9373
9766
  color: var(--butex-dev-inset-fg);
9374
9767
  }
9375
-
9376
- .butex-widget .debug-json-error {
9377
- margin: 0;
9378
- border: 1px solid rgba(220, 38, 38, 0.45);
9379
- background: rgba(254, 226, 226, 0.9);
9380
- color: #991b1b;
9381
- border-radius: 8px;
9382
- padding: 8px 10px;
9383
- white-space: pre-wrap;
9768
+
9769
+ .butex-widget .debug-json-error {
9770
+ margin: 0;
9771
+ border: 1px solid rgba(220, 38, 38, 0.45);
9772
+ background: rgba(254, 226, 226, 0.9);
9773
+ color: #991b1b;
9774
+ border-radius: 8px;
9775
+ padding: 8px 10px;
9776
+ white-space: pre-wrap;
9777
+ }
9778
+
9779
+ .butex-widget .delimiter-command-options,
9780
+ .butex-widget .matrix-command-popover,
9781
+ .butex-widget .character-font-options,
9782
+ .butex-widget .function-command-options,
9783
+ .butex-widget .spacing-command-options,
9784
+ .butex-widget .digit-form-options {
9785
+ max-height: min(70vh, 24rem);
9786
+ max-height: min(70dvh, 24rem);
9787
+ max-width: calc(100vw - 24px);
9788
+ max-width: calc(100cqw - 16px);
9789
+ overflow: auto;
9790
+ overscroll-behavior: contain;
9791
+ }
9792
+
9793
+ .butex-widget[data-responsive-mode="compact"] .butex-widget__desktop-toolbar {
9794
+ display: none;
9795
+ }
9796
+
9797
+ .butex-widget[data-responsive-mode="compact"] .butex-widget__mobile-toolbar {
9798
+ display: grid;
9799
+ }
9800
+
9801
+ .butex-widget[data-responsive-mode="compact"] .butex-widget__mobile-preview-toggle {
9802
+ display: inline-flex;
9803
+ }
9804
+
9805
+ .butex-widget[data-responsive-mode="compact"] .butex-widget__command-sheet-backdrop {
9806
+ display: flex;
9807
+ }
9808
+
9809
+ .butex-widget[data-responsive-mode="compact"] .panel-editor {
9810
+ display: flex;
9811
+ flex-direction: column;
9812
+ min-height: min(60dvh, 520px);
9813
+ }
9814
+
9815
+ .butex-widget[data-responsive-mode="compact"] .surface {
9816
+ flex: 1 1 auto;
9817
+ min-height: clamp(180px, 38dvh, 380px);
9818
+ }
9819
+
9820
+ .butex-widget[data-responsive-mode="compact"][data-compact-preview="closed"] .panel-preview {
9821
+ display: none;
9822
+ }
9823
+
9824
+ @media (max-width: 768px) {
9825
+ .butex-widget:not([data-responsive-mode="desktop"]) .butex-widget__desktop-toolbar {
9826
+ display: none;
9827
+ }
9828
+
9829
+ .butex-widget:not([data-responsive-mode="desktop"]) .butex-widget__mobile-toolbar {
9830
+ display: grid;
9831
+ }
9832
+
9833
+ .butex-widget:not([data-responsive-mode="desktop"]) .butex-widget__mobile-preview-toggle {
9834
+ display: inline-flex;
9835
+ }
9836
+
9837
+ .butex-widget:not([data-responsive-mode="desktop"]) .butex-widget__command-sheet-backdrop {
9838
+ display: flex;
9839
+ }
9840
+
9841
+ .butex-widget:not([data-responsive-mode="desktop"]) .panel-editor {
9842
+ display: flex;
9843
+ flex-direction: column;
9844
+ min-height: min(60dvh, 520px);
9845
+ }
9846
+
9847
+ .butex-widget:not([data-responsive-mode="desktop"]) .surface {
9848
+ flex: 1 1 auto;
9849
+ min-height: clamp(180px, 38dvh, 380px);
9850
+ }
9851
+
9852
+ .butex-widget:not([data-responsive-mode="desktop"])[data-compact-preview="closed"] .panel-preview {
9853
+ display: none;
9854
+ }
9855
+ }
9856
+
9857
+ @media (max-width: 430px) {
9858
+ .butex-widget-layout {
9859
+ gap: 6px;
9860
+ }
9861
+
9862
+ .butex-widget .panel {
9863
+ border-radius: 10px;
9864
+ padding: 8px;
9865
+ }
9866
+
9867
+ .butex-widget .toolbar {
9868
+ gap: 4px;
9869
+ }
9870
+
9871
+ .butex-widget:not([data-responsive-mode="desktop"]) .butex-widget__mobile-toolbar {
9872
+ grid-template-columns: repeat(4, minmax(44px, 1fr));
9873
+ }
9874
+
9875
+ .butex-widget:not([data-responsive-mode="desktop"]) .butex-widget__command-sheet-backdrop {
9876
+ padding-bottom: var(--butex-safe-area-bottom, env(safe-area-inset-bottom, 0px));
9877
+ padding-left: var(--butex-safe-area-left, env(safe-area-inset-left, 0px));
9878
+ padding-right: var(--butex-safe-area-right, env(safe-area-inset-right, 0px));
9879
+ padding-top: max(8px, var(--butex-safe-area-top, env(safe-area-inset-top, 0px)));
9880
+ }
9881
+
9882
+ .butex-widget:not([data-responsive-mode="desktop"]) .butex-widget__command-sheet {
9883
+ border-bottom: 0;
9884
+ 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)));
9885
+ max-width: none;
9886
+ }
9887
+
9888
+ .butex-widget:not([data-responsive-mode="desktop"]) .delimiter-command-menu,
9889
+ .butex-widget:not([data-responsive-mode="desktop"]) .matrix-command-menu,
9890
+ .butex-widget:not([data-responsive-mode="desktop"]) .character-font-menu,
9891
+ .butex-widget:not([data-responsive-mode="desktop"]) .function-command-menu,
9892
+ .butex-widget:not([data-responsive-mode="desktop"]) .spacing-command-menu,
9893
+ .butex-widget:not([data-responsive-mode="desktop"]) .digit-form-menu {
9894
+ position: static;
9895
+ }
9896
+
9897
+ .butex-widget:not([data-responsive-mode="desktop"]) .delimiter-command-options,
9898
+ .butex-widget:not([data-responsive-mode="desktop"]) .matrix-command-popover,
9899
+ .butex-widget:not([data-responsive-mode="desktop"]) .character-font-options,
9900
+ .butex-widget:not([data-responsive-mode="desktop"]) .function-command-options,
9901
+ .butex-widget:not([data-responsive-mode="desktop"]) .spacing-command-options,
9902
+ .butex-widget:not([data-responsive-mode="desktop"]) .digit-form-options {
9903
+ left: 8px;
9904
+ max-width: none;
9905
+ min-width: 0;
9906
+ right: 8px;
9907
+ width: auto;
9908
+ }
9909
+ }
9910
+
9911
+ @media (prefers-reduced-motion: reduce) {
9912
+ .butex-widget .toolbar button,
9913
+ .butex-widget .butex-widget__mobile-toolbar button,
9914
+ .butex-widget .butex-widget__mobile-preview-toggle,
9915
+ .butex-widget .butex-widget__command-sheet,
9916
+ .butex-widget .butex-widget__command-sheet button {
9917
+ animation: none;
9918
+ scroll-behavior: auto;
9919
+ transition: none;
9920
+ }
9921
+ }
9922
+ `.trim();
9923
+ var CHROME_STYLE_ID = "butex-widget-chrome-css";
9924
+ function injectWidgetChromeCss(doc) {
9925
+ const d = doc ?? (typeof document !== "undefined" ? document : void 0);
9926
+ if (!d || d.getElementById(CHROME_STYLE_ID)) {
9927
+ return;
9928
+ }
9929
+ const style = d.createElement("style");
9930
+ style.id = CHROME_STYLE_ID;
9931
+ style.textContent = WIDGET_CHROME_CSS;
9932
+ d.head.appendChild(style);
9933
+ }
9934
+
9935
+ // src/uiLocale.ts
9936
+ function uiLocaleDirection(locale) {
9937
+ return locale === "ar" ? "rtl" : "ltr";
9938
+ }
9939
+
9940
+ // src/debugJson.ts
9941
+ function lineColumnForPosition(text, position) {
9942
+ const before = text.slice(0, Math.max(0, position));
9943
+ const lines = before.split("\n");
9944
+ return {
9945
+ line: lines.length,
9946
+ column: (lines[lines.length - 1]?.length ?? 0) + 1
9947
+ };
9948
+ }
9949
+ function parseJsonDebugInput(text) {
9950
+ try {
9951
+ return { ok: true, value: JSON.parse(text) };
9952
+ } catch (error) {
9953
+ const message = error instanceof Error ? error.message : String(error);
9954
+ const positionMatch = message.match(/position\s+(\d+)/i);
9955
+ if (positionMatch) {
9956
+ const position = Number(positionMatch[1]);
9957
+ if (Number.isFinite(position)) {
9958
+ const location = lineColumnForPosition(text, position);
9959
+ return { ok: false, error: `Invalid JSON at line ${String(location.line)}, column ${String(location.column)}: ${message}` };
9960
+ }
9961
+ }
9962
+ return { ok: false, error: `Invalid JSON: ${message}` };
9963
+ }
9964
+ }
9965
+
9966
+ // src/react/EquationMobileToolbar.tsx
9967
+ var import_react2 = require("react");
9968
+
9969
+ // src/react/dialogFocus.ts
9970
+ var import_react = require("react");
9971
+ var FOCUSABLE_SELECTOR = [
9972
+ 'a[href]:not([tabindex="-1"])',
9973
+ 'button:not([disabled]):not([tabindex="-1"])',
9974
+ 'input:not([disabled]):not([tabindex="-1"])',
9975
+ 'select:not([disabled]):not([tabindex="-1"])',
9976
+ 'textarea:not([disabled]):not([tabindex="-1"])',
9977
+ '[tabindex]:not([tabindex="-1"])'
9978
+ ].join(",");
9979
+ var dialogStateByDocument = /* @__PURE__ */ new WeakMap();
9980
+ function focusableElements(dialog) {
9981
+ return Array.from(dialog.querySelectorAll(FOCUSABLE_SELECTOR)).filter(
9982
+ (element) => {
9983
+ if (element.hidden || element.closest('[hidden], [aria-hidden="true"], [inert]') || typeof element.checkVisibility === "function" && !element.checkVisibility()) {
9984
+ return false;
9985
+ }
9986
+ return true;
9987
+ }
9988
+ );
9989
+ }
9990
+ function useDialogFocus({ open, dialogRef, onClose, triggerRef }) {
9991
+ const closeRef = (0, import_react.useRef)(onClose);
9992
+ closeRef.current = onClose;
9993
+ (0, import_react.useEffect)(() => {
9994
+ if (!open) {
9995
+ return;
9996
+ }
9997
+ const doc = dialogRef.current?.ownerDocument ?? document;
9998
+ const view = doc.defaultView ?? window;
9999
+ const registration = /* @__PURE__ */ Symbol("butex-dialog");
10000
+ const previouslyFocused = doc.activeElement instanceof HTMLElement ? doc.activeElement : null;
10001
+ const documentState = dialogStateByDocument.get(doc) ?? { stack: [], origin: null };
10002
+ if (documentState.stack.length === 0 && documentState.origin === null) {
10003
+ documentState.origin = triggerRef?.current ?? previouslyFocused;
10004
+ }
10005
+ documentState.stack.push(registration);
10006
+ dialogStateByDocument.set(doc, documentState);
10007
+ const focusTimer = view.setTimeout(() => {
10008
+ const initialFocus = dialogRef.current?.querySelector("[data-dialog-initial-focus]") ?? (dialogRef.current ? focusableElements(dialogRef.current)[0] : null) ?? dialogRef.current;
10009
+ initialFocus?.focus();
10010
+ }, 0);
10011
+ const onKeyDown = (event) => {
10012
+ if (documentState.stack.at(-1) !== registration) {
10013
+ return;
10014
+ }
10015
+ if (event.key === "Escape") {
10016
+ event.preventDefault();
10017
+ closeRef.current();
10018
+ return;
10019
+ }
10020
+ if (event.key !== "Tab" || !dialogRef.current) {
10021
+ return;
10022
+ }
10023
+ const focusable = focusableElements(dialogRef.current);
10024
+ if (focusable.length === 0) {
10025
+ event.preventDefault();
10026
+ dialogRef.current.focus();
10027
+ return;
10028
+ }
10029
+ const first = focusable[0];
10030
+ const last = focusable[focusable.length - 1];
10031
+ if (event.shiftKey && (doc.activeElement === first || !dialogRef.current.contains(doc.activeElement))) {
10032
+ event.preventDefault();
10033
+ last?.focus();
10034
+ } else if (!event.shiftKey && doc.activeElement === last) {
10035
+ event.preventDefault();
10036
+ first?.focus();
10037
+ }
10038
+ };
10039
+ const onFocusIn = (event) => {
10040
+ if (documentState.stack.at(-1) !== registration || !dialogRef.current || dialogRef.current.contains(event.target)) {
10041
+ return;
10042
+ }
10043
+ (focusableElements(dialogRef.current)[0] ?? dialogRef.current).focus();
10044
+ };
10045
+ doc.addEventListener("keydown", onKeyDown);
10046
+ doc.addEventListener("focusin", onFocusIn);
10047
+ return () => {
10048
+ view.clearTimeout(focusTimer);
10049
+ doc.removeEventListener("keydown", onKeyDown);
10050
+ doc.removeEventListener("focusin", onFocusIn);
10051
+ const index = documentState.stack.lastIndexOf(registration);
10052
+ const hadParentDialog = index > 0;
10053
+ if (index >= 0) {
10054
+ documentState.stack.splice(index, 1);
10055
+ }
10056
+ view.setTimeout(() => {
10057
+ if (documentState.stack.length > 0 && !hadParentDialog) {
10058
+ return;
10059
+ }
10060
+ const restoreTarget = [triggerRef?.current, previouslyFocused, documentState.origin].find(
10061
+ (candidate) => Boolean(candidate?.isConnected)
10062
+ );
10063
+ if (restoreTarget) {
10064
+ restoreTarget.focus();
10065
+ }
10066
+ if (documentState.stack.length === 0) {
10067
+ view.setTimeout(() => {
10068
+ if (documentState.stack.length === 0 && dialogStateByDocument.get(doc) === documentState) {
10069
+ dialogStateByDocument.delete(doc);
10070
+ }
10071
+ }, 0);
10072
+ }
10073
+ }, 0);
10074
+ };
10075
+ }, [dialogRef, open, triggerRef]);
10076
+ }
10077
+
10078
+ // src/react/EquationMobileToolbar.tsx
10079
+ var import_jsx_runtime = require("react/jsx-runtime");
10080
+ var ACCENT_COMMANDS2 = accentCommandsList();
10081
+ var FUNCTION_COMMANDS = atomicCommandsByCategory("function");
10082
+ var LIMITS_SERIES_COMMANDS = atomicCommandsByCategory("limits_series");
10083
+ var FUNCTION2_COMMANDS = atomicCommandsByCategory("function2");
10084
+ var DERIVATIVE_COMMANDS = atomicCommandsByCategory("derivative");
10085
+ var GROUP_COMMANDS = atomicCommandsByCategory("groups");
10086
+ var SPACING_COMMANDS = atomicCommandsByCategory("spacing").filter(isSpacingCommandSpec);
10087
+ var OPERATOR_GROUPS = [
10088
+ atomicOperatorCommandsByCategory("operators1"),
10089
+ atomicOperatorCommandsByCategory("operators2"),
10090
+ atomicOperatorCommandsByCategory("operators3"),
10091
+ atomicOperatorCommandsByCategory("dots"),
10092
+ atomicOperatorCommandsByCategory("integrals")
10093
+ ];
10094
+ var MATRIX_STYLES = [
10095
+ { id: "matrix", label: "\u25A1" },
10096
+ { id: "pmatrix", label: "(\u25A1)" },
10097
+ { id: "bmatrix", label: "[\u25A1]" },
10098
+ { id: "Bmatrix", label: "{\u25A1}" },
10099
+ { id: "vmatrix", label: "|\u25A1|" },
10100
+ { id: "Vmatrix", label: "||\u25A1||" }
10101
+ ];
10102
+ var MATRIX_PRESETS = [
10103
+ { rows: 2, columns: 2 },
10104
+ { rows: 2, columns: 3 },
10105
+ { rows: 3, columns: 2 },
10106
+ { rows: 3, columns: 3 }
10107
+ ];
10108
+ var ARRAY_ALIGNMENTS = ["l", "c", "r"];
10109
+ function clampMatrixSize(value) {
10110
+ return Math.max(1, Math.min(12, Math.trunc(value)));
10111
+ }
10112
+ function matrixSizeLabel(rows, columns, messages) {
10113
+ const rowLabel = rows === 1 ? messages.row : messages.rows;
10114
+ const columnLabel = columns === 1 ? messages.column : messages.columns;
10115
+ return `${String(rows)} ${rowLabel} \xD7 ${String(columns)} ${columnLabel}`;
10116
+ }
10117
+ function matrixStyleTitle(style, messages) {
10118
+ if (style === "pmatrix") return messages.matrixParentheses;
10119
+ if (style === "bmatrix") return messages.matrixBrackets;
10120
+ if (style === "Bmatrix") return messages.matrixBraces;
10121
+ if (style === "vmatrix") return messages.matrixBars;
10122
+ if (style === "Vmatrix") return messages.matrixDoubleBars;
10123
+ return messages.matrixNoDelimiters;
10124
+ }
10125
+ function alignmentLabel(alignment, messages) {
10126
+ if (alignment === "l") return messages.alignLeft;
10127
+ if (alignment === "r") return messages.alignRight;
10128
+ return messages.alignCenter;
10129
+ }
10130
+ function alignmentTitle(alignment, messages) {
10131
+ if (alignment === "l") return messages.alignColumnLeft;
10132
+ if (alignment === "r") return messages.alignColumnRight;
10133
+ return messages.alignColumnCenter;
10134
+ }
10135
+ function characterFontTitle(fontId, messages) {
10136
+ const key = characterFontSpec(fontId).titleKey;
10137
+ return messages[key] ?? messages.defaultFont;
10138
+ }
10139
+ function digitTitle(digitForm, messages) {
10140
+ if (digitForm === "arabicIndic") return messages.arabicIndicDigits;
10141
+ if (digitForm === "persianIndic") return messages.persianIndicDigits;
10142
+ return messages.westernDigits;
10143
+ }
10144
+ function spacingArrow(command, side) {
10145
+ const pointsWithFlow = command.spacing.direction === "positive";
10146
+ if (pointsWithFlow) {
10147
+ return side === "arabic" ? "\u2190" : "\u2192";
10148
+ }
10149
+ return side === "arabic" ? "\u2192" : "\u2190";
10150
+ }
10151
+ function functionLabel(command) {
10152
+ if (command.id !== "ln") {
10153
+ return command.arabicLabel;
10154
+ }
10155
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "function-command-label-with-sub", "aria-hidden": "true", children: [
10156
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "function-command-label-with-sub__base", children: command.arabicLabel }),
10157
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "function-command-label-with-sub__sub", children: "\u0647\u0640" })
10158
+ ] });
9384
10159
  }
9385
- `.trim();
9386
- var CHROME_STYLE_ID = "butex-widget-chrome-css";
9387
- function injectWidgetChromeCss(doc) {
9388
- const d = doc ?? (typeof document !== "undefined" ? document : void 0);
9389
- if (!d || d.getElementById(CHROME_STYLE_ID)) {
9390
- return;
10160
+ function operatorLabel(command) {
10161
+ const label = command.svg_path ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
10162
+ "span",
10163
+ {
10164
+ className: "operator-command-svg-label",
10165
+ "aria-hidden": "true",
10166
+ style: {
10167
+ mask: `url("${command.svg_path}") center / contain no-repeat`,
10168
+ WebkitMask: `url("${command.svg_path}") center / contain no-repeat`
10169
+ }
10170
+ }
10171
+ ) : command.Label;
10172
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: label });
10173
+ }
10174
+ function categoryTitle(view, messages) {
10175
+ if (view === "delimiters") return messages.insertDelimiters;
10176
+ if (view === "structures") return messages.structures;
10177
+ if (view === "functions") return messages.functions;
10178
+ if (view === "operators") return messages.operations;
10179
+ if (view === "matrices") return messages.matrices;
10180
+ if (view === "typography") return messages.typography;
10181
+ if (view === "spacing") return messages.spaces;
10182
+ if (view === "digits") return messages.digitForms;
10183
+ return messages.moreActions;
10184
+ }
10185
+ function EquationMobileToolbar({
10186
+ uiLocale,
10187
+ messages,
10188
+ state,
10189
+ showSideSwitcher,
10190
+ inputRef,
10191
+ getRuntime
10192
+ }) {
10193
+ const [sheetView, setSheetView] = (0, import_react2.useState)("closed");
10194
+ const [envMode, setEnvMode] = (0, import_react2.useState)("matrix");
10195
+ const [matrixStyle, setMatrixStyle] = (0, import_react2.useState)("pmatrix");
10196
+ const [matrixRows, setMatrixRows] = (0, import_react2.useState)(2);
10197
+ const [matrixColumns, setMatrixColumns] = (0, import_react2.useState)(2);
10198
+ const [alignmentColumn, setAlignmentColumn] = (0, import_react2.useState)(1);
10199
+ const dialogRef = (0, import_react2.useRef)(null);
10200
+ const moreButtonRef = (0, import_react2.useRef)(null);
10201
+ const delimiterButtonRef = (0, import_react2.useRef)(null);
10202
+ const backButtonRef = (0, import_react2.useRef)(null);
10203
+ const restoreFocusRef = (0, import_react2.useRef)(null);
10204
+ const sheetTitleId = (0, import_react2.useId)();
10205
+ const sheetOpen = sheetView !== "closed";
10206
+ function dismissSheet() {
10207
+ setSheetView("closed");
10208
+ }
10209
+ useDialogFocus({ open: sheetOpen, dialogRef, onClose: dismissSheet, triggerRef: restoreFocusRef });
10210
+ (0, import_react2.useEffect)(() => {
10211
+ if (sheetView !== "closed" && sheetView !== "root" && sheetView !== "delimiters") {
10212
+ const timer = window.setTimeout(() => backButtonRef.current?.focus(), 0);
10213
+ return () => window.clearTimeout(timer);
10214
+ }
10215
+ }, [sheetView]);
10216
+ function focusInputAfterClose() {
10217
+ restoreFocusRef.current = inputRef.current;
10218
+ setSheetView("closed");
10219
+ window.requestAnimationFrame(() => getRuntime()?.focusInput());
10220
+ }
10221
+ function runAndClose(action) {
10222
+ const runtime = getRuntime();
10223
+ if (runtime) {
10224
+ action(runtime);
10225
+ }
10226
+ focusInputAfterClose();
10227
+ }
10228
+ function runAndKeepFocus(button, action) {
10229
+ const runtime = getRuntime();
10230
+ if (runtime) {
10231
+ action(runtime);
10232
+ }
10233
+ window.requestAnimationFrame(() => button.focus());
10234
+ }
10235
+ function openMore() {
10236
+ restoreFocusRef.current = moreButtonRef.current;
10237
+ setSheetView("root");
10238
+ }
10239
+ function openDelimiters() {
10240
+ restoreFocusRef.current = delimiterButtonRef.current;
10241
+ setSheetView("delimiters");
10242
+ }
10243
+ function setMatrixDimension(kind, value) {
10244
+ const next = clampMatrixSize(value);
10245
+ if (kind === "rows") {
10246
+ setMatrixRows(next);
10247
+ } else {
10248
+ setMatrixColumns(envMode === "aligned" ? 2 : next);
10249
+ }
9391
10250
  }
9392
- const style = d.createElement("style");
9393
- style.id = CHROME_STYLE_ID;
9394
- style.textContent = WIDGET_CHROME_CSS;
9395
- d.head.appendChild(style);
10251
+ function insertEnvironment() {
10252
+ runAndClose((runtime) => {
10253
+ if (envMode === "array") {
10254
+ runtime.insertArrayEnv(matrixRows, matrixColumns);
10255
+ } else if (envMode === "aligned") {
10256
+ runtime.insertAlignedEnv(matrixRows, 2);
10257
+ } else {
10258
+ runtime.insertMatrixEnv(matrixStyle, matrixRows, matrixColumns);
10259
+ }
10260
+ });
10261
+ }
10262
+ const directButtonMouseDown = (event) => event.preventDefault();
10263
+ const undoArrow = state.activeSide === "arabic" ? "\u21B7" : "\u21B6";
10264
+ const redoArrow = state.activeSide === "arabic" ? "\u21B6" : "\u21B7";
10265
+ const renderFunctionGroup = (label, commands, limits = false, outline = false) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "butex-widget__sheet-section", children: [
10266
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h4", { children: label }),
10267
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "butex-widget__sheet-command-grid", children: commands.map((command) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
10268
+ "button",
10269
+ {
10270
+ className: `function-command-option${outline ? " function-command-option--outline" : ""}`,
10271
+ type: "button",
10272
+ title: atomicCommandTitle(command, uiLocale),
10273
+ "aria-label": atomicCommandTitle(command, uiLocale),
10274
+ onClick: () => runAndClose((runtime) => {
10275
+ if (limits) runtime.insertLimitsSeriesTemplate(command.id);
10276
+ else runtime.insertAtomicCommand(command.id);
10277
+ }),
10278
+ children: functionLabel(command)
10279
+ },
10280
+ command.id
10281
+ )) })
10282
+ ] }, label);
10283
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
10284
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "butex-widget__mobile-toolbar", role: "toolbar", "aria-label": messages.compactToolbar, children: [
10285
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", disabled: !state.canUndo, title: messages.undo, "aria-label": messages.undo, onMouseDown: directButtonMouseDown, onClick: () => getRuntime()?.performUndo(), children: undoArrow }),
10286
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", disabled: !state.canRedo, title: messages.redo, "aria-label": messages.redo, onMouseDown: directButtonMouseDown, onClick: () => getRuntime()?.performRedo(), children: redoArrow }),
10287
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", title: messages.insertFraction, "aria-label": messages.insertFraction, onMouseDown: directButtonMouseDown, onClick: () => getRuntime()?.insertFraction(), children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "toolbar-frac-icon", "aria-hidden": "true", children: [
10288
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u0623" }),
10289
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u0628" })
10290
+ ] }) }),
10291
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", title: messages.addSuperscript, "aria-label": messages.addSuperscript, onMouseDown: directButtonMouseDown, onClick: () => getRuntime()?.addSup(), children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "toolbar-script-icon toolbar-script-icon--sup", "aria-hidden": "true", children: [
10292
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u0646" }),
10293
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u0633" })
10294
+ ] }) }),
10295
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", title: messages.addSubscript, "aria-label": messages.addSubscript, onMouseDown: directButtonMouseDown, onClick: () => getRuntime()?.addSub(), children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "toolbar-script-icon toolbar-script-icon--sub", "aria-hidden": "true", children: [
10296
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u0646" }),
10297
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u0633" })
10298
+ ] }) }),
10299
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { ref: delimiterButtonRef, type: "button", title: messages.insertDelimiters, "aria-label": messages.insertDelimiters, "aria-haspopup": "dialog", "aria-expanded": sheetView === "delimiters", onClick: openDelimiters, children: "()" }),
10300
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "butex-widget__mobile-danger", type: "button", title: messages.deleteSelectedStructure, "aria-label": messages.deleteSelectedStructure, onMouseDown: directButtonMouseDown, onClick: () => getRuntime()?.deleteStructure(), children: "\xD7" }),
10301
+ /* @__PURE__ */ (0, import_jsx_runtime.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" })
10302
+ ] }),
10303
+ sheetOpen ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
10304
+ "div",
10305
+ {
10306
+ className: "butex-widget__command-sheet-backdrop",
10307
+ role: "presentation",
10308
+ onClick: (event) => {
10309
+ if (event.target === event.currentTarget) dismissSheet();
10310
+ },
10311
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
10312
+ "div",
10313
+ {
10314
+ ref: dialogRef,
10315
+ className: "butex-widget__command-sheet",
10316
+ role: "dialog",
10317
+ "aria-modal": "true",
10318
+ "aria-labelledby": sheetTitleId,
10319
+ tabIndex: -1,
10320
+ children: [
10321
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "butex-widget__command-sheet-header", children: [
10322
+ sheetView !== "root" && sheetView !== "delimiters" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { ref: backButtonRef, type: "button", onClick: () => setSheetView("root"), children: messages.back }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {}),
10323
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { id: sheetTitleId, children: categoryTitle(sheetView, messages) }),
10324
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", "data-dialog-initial-focus": true, "aria-label": messages.closeActions, onClick: dismissSheet, children: "\xD7" })
10325
+ ] }),
10326
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "butex-widget__command-sheet-body", children: [
10327
+ sheetView === "root" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
10328
+ showSideSwitcher ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "butex-widget__sheet-section", children: [
10329
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h4", { children: messages.activeSide }),
10330
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "butex-widget__sheet-choice-row", children: [
10331
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
10332
+ "button",
10333
+ {
10334
+ type: "button",
10335
+ "aria-pressed": state.activeSide === "arabic",
10336
+ onClick: (event) => {
10337
+ if (state.activeSide !== "arabic") runAndKeepFocus(event.currentTarget, (runtime) => runtime.toggleSide());
10338
+ },
10339
+ children: messages.arabicSide
10340
+ }
10341
+ ),
10342
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
10343
+ "button",
10344
+ {
10345
+ type: "button",
10346
+ "aria-pressed": state.activeSide === "english",
10347
+ onClick: (event) => {
10348
+ if (state.activeSide !== "english") runAndKeepFocus(event.currentTarget, (runtime) => runtime.toggleSide());
10349
+ },
10350
+ children: messages.englishSide
10351
+ }
10352
+ )
10353
+ ] })
10354
+ ] }) : null,
10355
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "butex-widget__sheet-section", children: [
10356
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h4", { children: messages.clipboard }),
10357
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "butex-widget__sheet-choice-row", children: [
10358
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", disabled: !state.hasSelection, onClick: () => runAndClose((runtime) => {
10359
+ void runtime.performCopy();
10360
+ }), children: messages.copy }),
10361
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", disabled: !state.hasSelection, onClick: () => runAndClose((runtime) => {
10362
+ void runtime.performCut();
10363
+ }), children: messages.cut }),
10364
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", onClick: () => runAndClose((runtime) => {
10365
+ void runtime.performPaste();
10366
+ }), children: messages.paste })
10367
+ ] })
10368
+ ] }),
10369
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("nav", { className: "butex-widget__sheet-categories", "aria-label": messages.commandCategories, children: ["structures", "functions", "operators", "matrices", "typography", "spacing", "digits"].map((view) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", onClick: () => setSheetView(view), children: categoryTitle(view, messages) }, view)) })
10370
+ ] }) : null,
10371
+ sheetView === "delimiters" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "butex-widget__sheet-command-grid butex-widget__sheet-command-grid--three", children: [
10372
+ { kind: "paren", label: "()", title: messages.insertParentheses },
10373
+ { kind: "bracket", label: "[]", title: messages.insertBrackets },
10374
+ { kind: "brace", label: "{}", title: messages.insertBraces }
10375
+ ].map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", "aria-label": option.title, title: option.title, onClick: () => runAndClose((runtime) => runtime.insertDelimiterByKind(option.kind)), children: option.label }, option.kind)) }) : null,
10376
+ sheetView === "structures" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
10377
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "butex-widget__sheet-command-grid", children: [
10378
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", title: messages.insertRoot, "aria-label": messages.insertRoot, onClick: () => runAndClose((runtime) => runtime.insertSqrt()), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "toolbar-sqrt-icon", "aria-hidden": "true", children: "\u221A" }) }),
10379
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", title: messages.insertOverset, "aria-label": messages.insertOverset, onClick: () => runAndClose((runtime) => runtime.insertOverset()), children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "toolbar-accent-icon toolbar-accent-icon--over", "aria-hidden": "true", children: [
10380
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u2217" }),
10381
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u25A1" })
10382
+ ] }) }),
10383
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", title: messages.insertUnderset, "aria-label": messages.insertUnderset, onClick: () => runAndClose((runtime) => runtime.insertUnderset()), children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "toolbar-accent-icon toolbar-accent-icon--under", "aria-hidden": "true", children: [
10384
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u25A1" }),
10385
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u2217" })
10386
+ ] }) }),
10387
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", title: messages.insertAccentPair, "aria-label": messages.insertAccentPair, onClick: () => runAndClose((runtime) => runtime.insertAccentPair()), children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "toolbar-accent-icon toolbar-accent-icon--pair", "aria-hidden": "true", children: [
10388
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u2217" }),
10389
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u25A1" }),
10390
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u2217" })
10391
+ ] }) }),
10392
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", title: messages.removeSuperscript, "aria-label": messages.removeSuperscript, onClick: () => runAndClose((runtime) => runtime.removeSup()), children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "toolbar-remove-script-icon toolbar-remove-script-icon--sup", "aria-hidden": "true", children: [
10393
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\xD7" }),
10394
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u0646" })
10395
+ ] }) }),
10396
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", title: messages.removeSubscript, "aria-label": messages.removeSubscript, onClick: () => runAndClose((runtime) => runtime.removeSub()), children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "toolbar-remove-script-icon toolbar-remove-script-icon--sub", "aria-hidden": "true", children: [
10397
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\xD7" }),
10398
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u0646" })
10399
+ ] }) })
10400
+ ] }),
10401
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "butex-widget__sheet-section", children: [
10402
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h4", { children: messages.insertAccents }),
10403
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "butex-widget__sheet-command-grid", children: ACCENT_COMMANDS2.map((command) => /* @__PURE__ */ (0, import_jsx_runtime.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__ */ (0, import_jsx_runtime.jsx)("span", { className: "operator-command-label", "aria-hidden": "true", children: command.label }) }, command.id)) })
10404
+ ] })
10405
+ ] }) : null,
10406
+ sheetView === "functions" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
10407
+ renderFunctionGroup(messages.insertFunction, FUNCTION_COMMANDS),
10408
+ renderFunctionGroup(messages.insertLimitsSeries, LIMITS_SERIES_COMMANDS, true),
10409
+ renderFunctionGroup(messages.insertAdditionalFunctions, FUNCTION2_COMMANDS),
10410
+ renderFunctionGroup(messages.insertDerivative, DERIVATIVE_COMMANDS),
10411
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "butex-widget__sheet-command-grid", children: [
10412
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "function-command-option", type: "button", title: messages.insertFirstDerivative, "aria-label": messages.insertFirstDerivative, onClick: () => runAndClose((runtime) => runtime.insertFirstDerivative()), children: "\u0621/\u0633" }),
10413
+ /* @__PURE__ */ (0, import_jsx_runtime.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" })
10414
+ ] }),
10415
+ renderFunctionGroup(messages.insertNumberSets, GROUP_COMMANDS, false, true)
10416
+ ] }) : null,
10417
+ sheetView === "operators" ? OPERATOR_GROUPS.map((commands, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("section", { className: "butex-widget__sheet-section", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "butex-widget__sheet-command-grid", children: commands.map((command) => /* @__PURE__ */ (0, import_jsx_runtime.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,
10418
+ sheetView === "matrices" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "butex-widget__mobile-matrix-picker", children: [
10419
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "butex-widget__sheet-choice-row", role: "group", "aria-label": messages.environmentType, children: [
10420
+ { id: "matrix", label: messages.matrix },
10421
+ { id: "array", label: messages.array },
10422
+ { id: "aligned", label: messages.aligned }
10423
+ ].map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
10424
+ "button",
10425
+ {
10426
+ type: "button",
10427
+ "aria-pressed": envMode === option.id,
10428
+ onClick: () => {
10429
+ setEnvMode(option.id);
10430
+ if (option.id === "aligned") setMatrixColumns(2);
10431
+ },
10432
+ children: option.label
10433
+ },
10434
+ option.id
10435
+ )) }),
10436
+ envMode === "matrix" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "butex-widget__sheet-choice-row", role: "group", "aria-label": messages.matrixType, children: MATRIX_STYLES.map((style) => /* @__PURE__ */ (0, import_jsx_runtime.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,
10437
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "butex-widget__sheet-section", children: [
10438
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h4", { children: messages.commonMatrixSizes }),
10439
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "butex-widget__matrix-presets", children: (envMode === "aligned" ? MATRIX_PRESETS.filter((preset) => preset.columns === 2) : MATRIX_PRESETS).map((preset) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
10440
+ "button",
10441
+ {
10442
+ type: "button",
10443
+ "aria-pressed": matrixRows === preset.rows && matrixColumns === preset.columns,
10444
+ onClick: () => {
10445
+ setMatrixRows(preset.rows);
10446
+ setMatrixColumns(envMode === "aligned" ? 2 : preset.columns);
10447
+ },
10448
+ children: [
10449
+ preset.rows,
10450
+ "\xD7",
10451
+ envMode === "aligned" ? 2 : preset.columns
10452
+ ]
10453
+ },
10454
+ `${String(preset.rows)}-${String(preset.columns)}`
10455
+ )) })
10456
+ ] }),
10457
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "butex-widget__matrix-stepper-row", children: [
10458
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: messages.rows }),
10459
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "butex-widget__matrix-stepper", children: [
10460
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", disabled: matrixRows <= 1, "aria-label": messages.decreaseRows, onClick: () => setMatrixDimension("rows", matrixRows - 1), children: "\u2212" }),
10461
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("output", { "aria-live": "polite", children: matrixRows }),
10462
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", disabled: matrixRows >= 12, "aria-label": messages.increaseRows, onClick: () => setMatrixDimension("rows", matrixRows + 1), children: "+" })
10463
+ ] })
10464
+ ] }),
10465
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "butex-widget__matrix-stepper-row", children: [
10466
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: messages.columns }),
10467
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "butex-widget__matrix-stepper", children: [
10468
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", disabled: matrixColumns <= 1 || envMode === "aligned", "aria-label": messages.decreaseColumns, onClick: () => setMatrixDimension("columns", matrixColumns - 1), children: "\u2212" }),
10469
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("output", { "aria-live": "polite", children: envMode === "aligned" ? 2 : matrixColumns }),
10470
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", disabled: matrixColumns >= 12 || envMode === "aligned", "aria-label": messages.increaseColumns, onClick: () => setMatrixDimension("columns", matrixColumns + 1), children: "+" })
10471
+ ] })
10472
+ ] }),
10473
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "butex-widget__matrix-size-summary", "aria-live": "polite", children: matrixSizeLabel(matrixRows, envMode === "aligned" ? 2 : matrixColumns, messages) }),
10474
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "butex-widget__matrix-insert", onClick: insertEnvironment, children: messages.insert }),
10475
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "butex-widget__sheet-section", children: [
10476
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h4", { children: messages.editSelectedEnvironment }),
10477
+ envMode === "matrix" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", onClick: () => getRuntime()?.setMatrixEnvStyle(matrixStyle), children: messages.applyStyle }) : null,
10478
+ envMode === "array" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "butex-widget__matrix-alignment", children: [
10479
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: [
10480
+ messages.column,
10481
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "number", min: 1, max: 12, value: alignmentColumn, onChange: (event) => setAlignmentColumn(clampMatrixSize(Number(event.currentTarget.value) || 1)) })
10482
+ ] }),
10483
+ ARRAY_ALIGNMENTS.map((alignment) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", title: alignmentTitle(alignment, messages), onClick: () => getRuntime()?.setArrayColumnAlignment(alignmentColumn - 1, alignment), children: alignmentLabel(alignment, messages) }, alignment))
10484
+ ] }) : null,
10485
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "butex-widget__sheet-command-grid", children: [
10486
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", onClick: () => getRuntime()?.addMatrixRow(), children: [
10487
+ "+",
10488
+ messages.row
10489
+ ] }),
10490
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", onClick: () => getRuntime()?.removeMatrixRow(), children: [
10491
+ "\u2212",
10492
+ messages.row
10493
+ ] }),
10494
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", onClick: () => getRuntime()?.addMatrixColumn(), children: [
10495
+ "+",
10496
+ messages.column
10497
+ ] }),
10498
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", onClick: () => getRuntime()?.removeMatrixColumn(), children: [
10499
+ "\u2212",
10500
+ messages.column
10501
+ ] })
10502
+ ] })
10503
+ ] })
10504
+ ] }) : null,
10505
+ sheetView === "typography" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
10506
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "butex-widget__sheet-section", children: [
10507
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h4", { children: messages.chooseWritingFont }),
10508
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "butex-widget__sheet-choice-row", children: CHARACTER_FONT_OPTIONS.map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
10509
+ "button",
10510
+ {
10511
+ type: "button",
10512
+ className: `character-font-option--${option.id}`,
10513
+ "aria-pressed": state.characterFont === option.id,
10514
+ title: characterFontTitle(option.id, messages),
10515
+ onClick: (event) => runAndKeepFocus(event.currentTarget, (runtime) => runtime.setCurrentCharacterFont(option.id)),
10516
+ children: option.label
10517
+ },
10518
+ option.id
10519
+ )) })
10520
+ ] }),
10521
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
10522
+ "button",
10523
+ {
10524
+ className: "ligature-btn butex-widget__compact-ligature",
10525
+ type: "button",
10526
+ title: !state.splitLeafTyping ? messages.disableLetterMerging : messages.enableLetterMerging,
10527
+ "aria-label": !state.splitLeafTyping ? messages.disableLetterMerging : messages.enableLetterMerging,
10528
+ "aria-pressed": !state.splitLeafTyping,
10529
+ onClick: (event) => runAndKeepFocus(event.currentTarget, (runtime) => runtime.toggleSplitLeafTyping()),
10530
+ children: !state.splitLeafTyping ? "\u0633\u0635\u0639" : "\u0633 \u0635 \u0639"
10531
+ }
10532
+ )
10533
+ ] }) : null,
10534
+ sheetView === "spacing" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "butex-widget__sheet-command-list", children: SPACING_COMMANDS.map((command) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", title: atomicCommandTitle(command, uiLocale), "aria-label": atomicCommandTitle(command, uiLocale), onClick: () => runAndClose((runtime) => runtime.insertAtomicCommand(command.id)), children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
10535
+ "span",
10536
+ {
10537
+ className: `spacing-command-glyph spacing-command-glyph--${command.spacing.direction} spacing-command-glyph--level-${String(command.spacing.level)}`,
10538
+ "aria-hidden": "true",
10539
+ children: [
10540
+ command.spacing.direction === "negative" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "spacing-command-glyph__arrow", children: spacingArrow(command, state.activeSide) }) : null,
10541
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "spacing-command-glyph__bar" }),
10542
+ command.spacing.direction === "positive" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "spacing-command-glyph__arrow", children: spacingArrow(command, state.activeSide) }) : null
10543
+ ]
10544
+ }
10545
+ ) }, command.id)) }) : null,
10546
+ sheetView === "digits" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "butex-widget__sheet-choice-row", children: [
10547
+ { id: "western", label: "456" },
10548
+ { id: "arabicIndic", label: "\u0664\u0665\u0666" },
10549
+ { id: "persianIndic", label: "\u06F4\u06F5\u06F6" }
10550
+ ].map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
10551
+ "button",
10552
+ {
10553
+ type: "button",
10554
+ "aria-pressed": state.digitForm === option.id,
10555
+ title: digitTitle(option.id, messages),
10556
+ onClick: (event) => runAndKeepFocus(event.currentTarget, (runtime) => runtime.setCurrentDigitForm(option.id)),
10557
+ children: option.label
10558
+ },
10559
+ option.id
10560
+ )) }) : null
10561
+ ] })
10562
+ ]
10563
+ }
10564
+ )
10565
+ }
10566
+ ) : null
10567
+ ] });
9396
10568
  }
9397
10569
 
9398
- // src/uiLocale.ts
9399
- function uiLocaleDirection(locale) {
9400
- return locale === "ar" ? "rtl" : "ltr";
10570
+ // src/react/visibleViewport.ts
10571
+ function positiveFinite(value, fallback) {
10572
+ return Number.isFinite(value) && value > 0 ? value : fallback;
9401
10573
  }
9402
-
9403
- // src/debugJson.ts
9404
- function lineColumnForPosition(text, position) {
9405
- const before = text.slice(0, Math.max(0, position));
9406
- const lines = before.split("\n");
10574
+ function finiteOffset(value) {
10575
+ return Number.isFinite(value) ? value : 0;
10576
+ }
10577
+ function visibleViewportSnapshot(view) {
10578
+ const fallbackWidth = positiveFinite(view.innerWidth, 1);
10579
+ const fallbackHeight = positiveFinite(view.innerHeight, 1);
10580
+ const visualViewport = view.visualViewport;
10581
+ if (visualViewport && Number.isFinite(visualViewport.width) && visualViewport.width > 0 && Number.isFinite(visualViewport.height) && visualViewport.height > 0) {
10582
+ return {
10583
+ width: visualViewport.width,
10584
+ height: visualViewport.height,
10585
+ offsetLeft: finiteOffset(visualViewport.offsetLeft),
10586
+ offsetTop: finiteOffset(visualViewport.offsetTop),
10587
+ scale: positiveFinite(visualViewport.scale, 1),
10588
+ source: "visual-viewport"
10589
+ };
10590
+ }
9407
10591
  return {
9408
- line: lines.length,
9409
- column: (lines[lines.length - 1]?.length ?? 0) + 1
10592
+ width: fallbackWidth,
10593
+ height: fallbackHeight,
10594
+ offsetLeft: 0,
10595
+ offsetTop: 0,
10596
+ scale: 1,
10597
+ source: "layout-viewport"
9410
10598
  };
9411
10599
  }
9412
- function parseJsonDebugInput(text) {
9413
- try {
9414
- return { ok: true, value: JSON.parse(text) };
9415
- } catch (error) {
9416
- const message = error instanceof Error ? error.message : String(error);
9417
- const positionMatch = message.match(/position\s+(\d+)/i);
9418
- if (positionMatch) {
9419
- const position = Number(positionMatch[1]);
9420
- if (Number.isFinite(position)) {
9421
- const location = lineColumnForPosition(text, position);
9422
- return { ok: false, error: `Invalid JSON at line ${String(location.line)}, column ${String(location.column)}: ${message}` };
9423
- }
10600
+ function reasonPriority(reason) {
10601
+ if (reason === "orientation") return 3;
10602
+ if (reason === "resize") return 2;
10603
+ if (reason === "scroll") return 1;
10604
+ return 0;
10605
+ }
10606
+ function observeVisibleViewport(view, onChange) {
10607
+ let previous = visibleViewportSnapshot(view);
10608
+ let frame = null;
10609
+ let pendingReason = "scroll";
10610
+ onChange({
10611
+ snapshot: previous,
10612
+ initial: true,
10613
+ sizeChanged: false,
10614
+ offsetChanged: false,
10615
+ reason: "initial"
10616
+ });
10617
+ const emit = () => {
10618
+ frame = null;
10619
+ const next = visibleViewportSnapshot(view);
10620
+ const sizeChanged = next.width !== previous.width || next.height !== previous.height || next.scale !== previous.scale || next.source !== previous.source;
10621
+ const offsetChanged = next.offsetLeft !== previous.offsetLeft || next.offsetTop !== previous.offsetTop;
10622
+ const reason = pendingReason;
10623
+ pendingReason = "scroll";
10624
+ previous = next;
10625
+ onChange({ snapshot: next, initial: false, sizeChanged, offsetChanged, reason });
10626
+ };
10627
+ const schedule = (reason) => {
10628
+ if (reasonPriority(reason) > reasonPriority(pendingReason)) {
10629
+ pendingReason = reason;
9424
10630
  }
9425
- return { ok: false, error: `Invalid JSON: ${message}` };
10631
+ if (frame !== null) {
10632
+ return;
10633
+ }
10634
+ frame = view.requestAnimationFrame(emit);
10635
+ };
10636
+ const onResize = () => schedule("resize");
10637
+ const onScroll = () => schedule("scroll");
10638
+ const onOrientation = () => schedule("orientation");
10639
+ const visualViewport = view.visualViewport;
10640
+ visualViewport?.addEventListener("resize", onResize);
10641
+ visualViewport?.addEventListener("scroll", onScroll);
10642
+ view.addEventListener("resize", onResize);
10643
+ view.addEventListener("orientationchange", onOrientation);
10644
+ return () => {
10645
+ visualViewport?.removeEventListener("resize", onResize);
10646
+ visualViewport?.removeEventListener("scroll", onScroll);
10647
+ view.removeEventListener("resize", onResize);
10648
+ view.removeEventListener("orientationchange", onOrientation);
10649
+ if (frame !== null) {
10650
+ view.cancelAnimationFrame(frame);
10651
+ frame = null;
10652
+ }
10653
+ };
10654
+ }
10655
+
10656
+ // src/react/desktopPopover.ts
10657
+ var import_react3 = require("react");
10658
+ var POPOVER_GAP = 5;
10659
+ var VIEWPORT_MARGIN = 8;
10660
+ var MIN_USABLE_HEIGHT = 96;
10661
+ function clearPlacement(popover) {
10662
+ for (const property of ["position", "inset", "left", "top", "right", "bottom", "max-width", "max-height"]) {
10663
+ popover.style.removeProperty(property);
9426
10664
  }
10665
+ delete popover.dataset.placement;
10666
+ }
10667
+ function useDesktopPopoverPlacement(rootRef, active, onClose) {
10668
+ (0, import_react3.useEffect)(() => {
10669
+ if (!active || typeof window === "undefined") {
10670
+ return;
10671
+ }
10672
+ const root = rootRef.current;
10673
+ const trigger = root?.querySelector('.butex-widget__desktop-toolbar button[aria-expanded="true"]');
10674
+ const popover = trigger?.parentElement?.querySelector(
10675
+ ':scope > [role="menu"], :scope > [role="listbox"], :scope > [role="dialog"]'
10676
+ );
10677
+ if (!root || !trigger || !popover) {
10678
+ return;
10679
+ }
10680
+ let frame = null;
10681
+ const place = () => {
10682
+ frame = null;
10683
+ clearPlacement(popover);
10684
+ popover.style.position = "fixed";
10685
+ popover.style.inset = "auto";
10686
+ const rootRect = root.getBoundingClientRect();
10687
+ const scrollBoundary = root.closest(".butex-document2-widget__equation-modal-body");
10688
+ const scrollBoundaryRect = scrollBoundary?.getBoundingClientRect();
10689
+ const triggerRect = trigger.getBoundingClientRect();
10690
+ const boundaryLeft = Math.max(VIEWPORT_MARGIN, rootRect.left + VIEWPORT_MARGIN);
10691
+ const boundaryRight = Math.max(
10692
+ boundaryLeft + 1,
10693
+ Math.min(window.innerWidth - VIEWPORT_MARGIN, rootRect.right - VIEWPORT_MARGIN)
10694
+ );
10695
+ const boundaryTop = Math.max(VIEWPORT_MARGIN, (scrollBoundaryRect?.top ?? rootRect.top) + VIEWPORT_MARGIN);
10696
+ const boundaryBottom = Math.max(
10697
+ boundaryTop + 1,
10698
+ Math.min(window.innerHeight - VIEWPORT_MARGIN, (scrollBoundaryRect?.bottom ?? rootRect.bottom) - VIEWPORT_MARGIN)
10699
+ );
10700
+ const availableWidth = Math.max(1, boundaryRight - boundaryLeft);
10701
+ popover.style.maxWidth = `${availableWidth}px`;
10702
+ const naturalRect = popover.getBoundingClientRect();
10703
+ const popoverWidth = Math.min(Math.max(naturalRect.width, popover.scrollWidth), availableWidth);
10704
+ const preferredLeft = root.dir === "rtl" ? triggerRect.right - popoverWidth : triggerRect.left;
10705
+ const left = Math.min(Math.max(preferredLeft, boundaryLeft), boundaryRight - popoverWidth);
10706
+ const belowTop = triggerRect.bottom + POPOVER_GAP;
10707
+ const belowSpace = Math.max(0, boundaryBottom - belowTop);
10708
+ const aboveSpace = Math.max(0, triggerRect.top - boundaryTop - POPOVER_GAP);
10709
+ const naturalHeight = Math.max(naturalRect.height, popover.scrollHeight);
10710
+ const placeBelow = belowSpace >= Math.min(naturalHeight, MIN_USABLE_HEIGHT) || belowSpace >= aboveSpace;
10711
+ const availableHeight = placeBelow ? belowSpace : aboveSpace;
10712
+ const maxHeight = Math.max(1, availableHeight);
10713
+ const renderedHeight = Math.min(naturalHeight, maxHeight);
10714
+ const top = placeBelow ? belowTop : Math.max(boundaryTop, triggerRect.top - POPOVER_GAP - renderedHeight);
10715
+ popover.style.left = `${left}px`;
10716
+ popover.style.top = `${top}px`;
10717
+ popover.style.maxHeight = `${maxHeight}px`;
10718
+ popover.dataset.placement = placeBelow ? "below" : "above";
10719
+ };
10720
+ const schedulePlacement = () => {
10721
+ if (frame !== null) {
10722
+ window.cancelAnimationFrame(frame);
10723
+ }
10724
+ frame = window.requestAnimationFrame(place);
10725
+ };
10726
+ const handleKeyDown = (event) => {
10727
+ if (event.key === "Escape") {
10728
+ event.preventDefault();
10729
+ event.stopPropagation();
10730
+ onClose();
10731
+ window.requestAnimationFrame(() => trigger.focus());
10732
+ return;
10733
+ }
10734
+ if (!["ArrowDown", "ArrowUp", "ArrowLeft", "ArrowRight", "Home", "End"].includes(event.key)) {
10735
+ return;
10736
+ }
10737
+ if (popover.getAttribute("role") === "dialog") {
10738
+ return;
10739
+ }
10740
+ const items = Array.from(
10741
+ popover.querySelectorAll('[role="menuitem"]:not([disabled]), [role="option"]:not([disabled])')
10742
+ ).filter((item) => !item.hidden && item.getAttribute("aria-hidden") !== "true");
10743
+ if (items.length === 0 || event.target !== trigger && !popover.contains(event.target)) {
10744
+ return;
10745
+ }
10746
+ const currentIndex = items.indexOf(document.activeElement);
10747
+ let nextIndex;
10748
+ if (event.key === "Home") {
10749
+ nextIndex = 0;
10750
+ } else if (event.key === "End") {
10751
+ nextIndex = items.length - 1;
10752
+ } else if (event.key === "ArrowDown" || event.key === "ArrowRight") {
10753
+ nextIndex = currentIndex < 0 ? 0 : (currentIndex + 1) % items.length;
10754
+ } else {
10755
+ nextIndex = currentIndex < 0 ? items.length - 1 : (currentIndex - 1 + items.length) % items.length;
10756
+ }
10757
+ event.preventDefault();
10758
+ items[nextIndex]?.focus();
10759
+ };
10760
+ const closeOnOutsidePointer = (event) => {
10761
+ const target = event.target;
10762
+ if (target instanceof Node && !trigger.contains(target) && !popover.contains(target)) {
10763
+ onClose();
10764
+ }
10765
+ };
10766
+ const resizeObserver = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(schedulePlacement);
10767
+ resizeObserver?.observe(root);
10768
+ const toolbar = root.querySelector(".butex-widget__desktop-toolbar");
10769
+ if (toolbar) {
10770
+ resizeObserver?.observe(toolbar);
10771
+ }
10772
+ window.addEventListener("resize", schedulePlacement);
10773
+ window.addEventListener("scroll", schedulePlacement, true);
10774
+ window.visualViewport?.addEventListener("resize", schedulePlacement);
10775
+ window.visualViewport?.addEventListener("scroll", schedulePlacement);
10776
+ document.addEventListener("keydown", handleKeyDown, true);
10777
+ document.addEventListener("pointerdown", closeOnOutsidePointer, true);
10778
+ schedulePlacement();
10779
+ return () => {
10780
+ if (frame !== null) {
10781
+ window.cancelAnimationFrame(frame);
10782
+ }
10783
+ resizeObserver?.disconnect();
10784
+ window.removeEventListener("resize", schedulePlacement);
10785
+ window.removeEventListener("scroll", schedulePlacement, true);
10786
+ window.visualViewport?.removeEventListener("resize", schedulePlacement);
10787
+ window.visualViewport?.removeEventListener("scroll", schedulePlacement);
10788
+ document.removeEventListener("keydown", handleKeyDown, true);
10789
+ document.removeEventListener("pointerdown", closeOnOutsidePointer, true);
10790
+ clearPlacement(popover);
10791
+ };
10792
+ }, [active, onClose, rootRef]);
9427
10793
  }
9428
10794
 
9429
10795
  // src/react/ButexEditor.tsx
9430
- var import_jsx_runtime = require("react/jsx-runtime");
10796
+ var import_jsx_runtime2 = require("react/jsx-runtime");
9431
10797
  var DIGIT_FORM_OPTIONS = [
9432
10798
  { id: "western", label: "456" },
9433
10799
  { id: "arabicIndic", label: "\u0664\u0665\u0666" },
9434
10800
  { id: "persianIndic", label: "\u06F4\u06F5\u06F6" }
9435
10801
  ];
9436
10802
  var ACCENT_COMMANDS_LIST = accentCommandsList();
9437
- var FUNCTION_COMMANDS = atomicCommandsByCategory("function");
9438
- var LIMITS_SERIES_COMMANDS = atomicCommandsByCategory("limits_series");
9439
- var FUNCTION2_COMMANDS = atomicCommandsByCategory("function2");
9440
- var DERIVATIVE_COMMANDS = atomicCommandsByCategory("derivative");
9441
- var GROUP_COMMANDS = atomicCommandsByCategory("groups");
9442
- var SPACING_COMMANDS = atomicCommandsByCategory("spacing").filter(isSpacingCommandSpec);
10803
+ var FUNCTION_COMMANDS2 = atomicCommandsByCategory("function");
10804
+ var LIMITS_SERIES_COMMANDS2 = atomicCommandsByCategory("limits_series");
10805
+ var FUNCTION2_COMMANDS2 = atomicCommandsByCategory("function2");
10806
+ var DERIVATIVE_COMMANDS2 = atomicCommandsByCategory("derivative");
10807
+ var GROUP_COMMANDS2 = atomicCommandsByCategory("groups");
10808
+ var SPACING_COMMANDS2 = atomicCommandsByCategory("spacing").filter(isSpacingCommandSpec);
9443
10809
  var OPERATOR_COMMANDS = atomicOperatorCommandsByCategory("operators1");
9444
10810
  var OPERATOR2_COMMANDS = atomicOperatorCommandsByCategory("operators2");
9445
10811
  var OPERATOR3_COMMANDS = atomicOperatorCommandsByCategory("operators3");
9446
10812
  var DOT_COMMANDS = atomicOperatorCommandsByCategory("dots");
9447
10813
  var INTEGRAL_COMMANDS = atomicOperatorCommandsByCategory("integrals");
9448
- var MATRIX_STYLES = [
10814
+ var MATRIX_STYLES2 = [
9449
10815
  { id: "matrix", label: "\u25A1" },
9450
10816
  { id: "pmatrix", label: "(\u25A1)" },
9451
10817
  { id: "bmatrix", label: "[\u25A1]" },
@@ -9453,15 +10819,15 @@ var MATRIX_STYLES = [
9453
10819
  { id: "vmatrix", label: "|\u25A1|" },
9454
10820
  { id: "Vmatrix", label: "||\u25A1||" }
9455
10821
  ];
9456
- var ARRAY_ALIGNMENTS = [
10822
+ var ARRAY_ALIGNMENTS2 = [
9457
10823
  { id: "l" },
9458
10824
  { id: "c" },
9459
10825
  { id: "r" }
9460
10826
  ];
9461
- function matrixSizeLabel(rows, columns, messages) {
10827
+ function matrixSizeLabel2(rows, columns, messages) {
9462
10828
  return `${String(rows)} ${messages.row} \xD7 ${String(columns)} ${messages.column}`;
9463
10829
  }
9464
- function clampMatrixSize(value) {
10830
+ function clampMatrixSize2(value) {
9465
10831
  return Math.max(1, Math.min(12, Math.trunc(value)));
9466
10832
  }
9467
10833
  function digitFormLabel(digitForm) {
@@ -9470,7 +10836,7 @@ function digitFormLabel(digitForm) {
9470
10836
  function characterFontOption(fontId) {
9471
10837
  return CHARACTER_FONT_OPTIONS.find((option) => option.id === fontId) ?? CHARACTER_FONT_OPTIONS[0];
9472
10838
  }
9473
- function characterFontTitle(fontId, messages) {
10839
+ function characterFontTitle2(fontId, messages) {
9474
10840
  const key = characterFontSpec(fontId).titleKey;
9475
10841
  return messages[key] ?? messages.defaultFont;
9476
10842
  }
@@ -9479,7 +10845,7 @@ function digitFormTitle(digitForm, messages) {
9479
10845
  if (digitForm === "persianIndic") return messages.persianIndicDigits;
9480
10846
  return messages.westernDigits;
9481
10847
  }
9482
- function matrixStyleTitle(style, messages) {
10848
+ function matrixStyleTitle2(style, messages) {
9483
10849
  if (style === "pmatrix") return messages.matrixParentheses;
9484
10850
  if (style === "bmatrix") return messages.matrixBrackets;
9485
10851
  if (style === "Bmatrix") return messages.matrixBraces;
@@ -9492,7 +10858,7 @@ function alignmentCopy(alignment, messages) {
9492
10858
  if (alignment === "r") return { label: messages.alignRight, title: messages.alignColumnRight };
9493
10859
  return { label: messages.alignCenter, title: messages.alignColumnCenter };
9494
10860
  }
9495
- function spacingArrow(spec, side) {
10861
+ function spacingArrow2(spec, side) {
9496
10862
  const pointsWithFlow = spec.spacing.direction === "positive";
9497
10863
  if (pointsWithFlow) {
9498
10864
  return side === "arabic" ? "\u2190" : "\u2192";
@@ -9503,16 +10869,16 @@ function renderArabicCommandLabel(command) {
9503
10869
  if (command.id !== "ln") {
9504
10870
  return command.arabicLabel;
9505
10871
  }
9506
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "function-command-label-with-sub", "aria-hidden": "true", children: [
9507
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "function-command-label-with-sub__base", children: command.arabicLabel }),
9508
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "function-command-label-with-sub__sub", children: "\u0647\u0640" })
10872
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "function-command-label-with-sub", "aria-hidden": "true", children: [
10873
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "function-command-label-with-sub__base", children: command.arabicLabel }),
10874
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "function-command-label-with-sub__sub", children: "\u0647\u0640" })
9509
10875
  ] });
9510
10876
  }
9511
10877
  function renderOperatorCommandLabel(command) {
9512
10878
  if (!command.svg_path) {
9513
10879
  return command.Label;
9514
10880
  }
9515
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
10881
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9516
10882
  "span",
9517
10883
  {
9518
10884
  className: "operator-command-svg-label",
@@ -9528,7 +10894,7 @@ function renderOperatorMenuButtonLabel(command, fallback) {
9528
10894
  if (!command) {
9529
10895
  return fallback;
9530
10896
  }
9531
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) });
10897
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) });
9532
10898
  }
9533
10899
  function passiveTreeText(session, messages) {
9534
10900
  const passive = session.activeSide === "arabic" ? session.englishTree : session.arabicTree;
@@ -9538,67 +10904,104 @@ function passiveTreeText(session, messages) {
9538
10904
 
9539
10905
  ${latex || messages.empty}`;
9540
10906
  }
9541
- var ButexEditor = (0, import_react.forwardRef)(
9542
- function ButexEditor2({ className, debug = false, defaultSide, uiLocale = "ar", initialSession, onSessionChange }, ref) {
10907
+ var ButexEditor = (0, import_react4.forwardRef)(
10908
+ function ButexEditor2({ className, debug = false, defaultSide, uiLocale = "ar", initialSession, onSessionChange, responsiveMode = "auto", showSideSwitcher = true }, ref) {
9543
10909
  const messages = equationEditorMessages(uiLocale);
10910
+ const previewPanelId = (0, import_react4.useId)();
9544
10911
  const debugEnabled = debug || typeof window !== "undefined" && new URLSearchParams(window.location.search).get("debug") === "1";
9545
- const wrapperRef = (0, import_react.useRef)(null);
9546
- const surfaceRef = (0, import_react.useRef)(null);
9547
- const inputRef = (0, import_react.useRef)(null);
9548
- const mathOutputRef = (0, import_react.useRef)(null);
9549
- const renderErrorRef = (0, import_react.useRef)(null);
9550
- const latexLinesRef = (0, import_react.useRef)(null);
9551
- const passivePreviewRef = (0, import_react.useRef)(null);
9552
- const debugLogRef = (0, import_react.useRef)(null);
9553
- const undoBtnRef = (0, import_react.useRef)(null);
9554
- const redoBtnRef = (0, import_react.useRef)(null);
9555
- const copyBtnRef = (0, import_react.useRef)(null);
9556
- const cutBtnRef = (0, import_react.useRef)(null);
9557
- const splitTypingBtnRef = (0, import_react.useRef)(null);
9558
- const characterFontBtnRef = (0, import_react.useRef)(null);
9559
- const digitFormBtnRef = (0, import_react.useRef)(null);
9560
- const runtimeRef = (0, import_react.useRef)(null);
9561
- const debugRef = (0, import_react.useRef)(debug);
10912
+ const wrapperRef = (0, import_react4.useRef)(null);
10913
+ const surfaceRef = (0, import_react4.useRef)(null);
10914
+ const inputRef = (0, import_react4.useRef)(null);
10915
+ const mathOutputRef = (0, import_react4.useRef)(null);
10916
+ const renderErrorRef = (0, import_react4.useRef)(null);
10917
+ const latexLinesRef = (0, import_react4.useRef)(null);
10918
+ const passivePreviewRef = (0, import_react4.useRef)(null);
10919
+ const debugLogRef = (0, import_react4.useRef)(null);
10920
+ const undoBtnRef = (0, import_react4.useRef)(null);
10921
+ const redoBtnRef = (0, import_react4.useRef)(null);
10922
+ const copyBtnRef = (0, import_react4.useRef)(null);
10923
+ const cutBtnRef = (0, import_react4.useRef)(null);
10924
+ const splitTypingBtnRef = (0, import_react4.useRef)(null);
10925
+ const characterFontBtnRef = (0, import_react4.useRef)(null);
10926
+ const digitFormBtnRef = (0, import_react4.useRef)(null);
10927
+ const runtimeRef = (0, import_react4.useRef)(null);
10928
+ const debugRef = (0, import_react4.useRef)(debug);
9562
10929
  debugRef.current = debugEnabled;
9563
- const uiLocaleRef = (0, import_react.useRef)(uiLocale);
10930
+ const uiLocaleRef = (0, import_react4.useRef)(uiLocale);
9564
10931
  uiLocaleRef.current = uiLocale;
9565
- const onSessionChangeRef = (0, import_react.useRef)(onSessionChange);
10932
+ const onSessionChangeRef = (0, import_react4.useRef)(onSessionChange);
9566
10933
  onSessionChangeRef.current = onSessionChange;
9567
- const debugBodyHiddenRef = (0, import_react.useRef)(false);
9568
- const [debugBodyHidden, setDebugBodyHidden] = (0, import_react.useState)(false);
10934
+ const debugBodyHiddenRef = (0, import_react4.useRef)(false);
10935
+ const [debugBodyHidden, setDebugBodyHidden] = (0, import_react4.useState)(false);
9569
10936
  debugBodyHiddenRef.current = debugBodyHidden;
9570
- const [debugImportOpen, setDebugImportOpen] = (0, import_react.useState)(false);
9571
- const [debugImportText, setDebugImportText] = (0, import_react.useState)("");
9572
- const [debugImportError, setDebugImportError] = (0, import_react.useState)("");
9573
- const [digitMenuOpen, setDigitMenuOpen] = (0, import_react.useState)(false);
9574
- const [characterFontMenuOpen, setCharacterFontMenuOpen] = (0, import_react.useState)(false);
9575
- const [delimiterMenuOpen, setDelimiterMenuOpen] = (0, import_react.useState)(false);
9576
- const [matrixMenuOpen, setMatrixMenuOpen] = (0, import_react.useState)(false);
9577
- const [spacingMenuOpen, setSpacingMenuOpen] = (0, import_react.useState)(false);
9578
- const [functionMenuOpen, setFunctionMenuOpen] = (0, import_react.useState)(false);
9579
- const [limitsSeriesMenuOpen, setLimitsSeriesMenuOpen] = (0, import_react.useState)(false);
9580
- const [function2MenuOpen, setFunction2MenuOpen] = (0, import_react.useState)(false);
9581
- const [derivativeMenuOpen, setDerivativeMenuOpen] = (0, import_react.useState)(false);
9582
- const [groupMenuOpen, setGroupMenuOpen] = (0, import_react.useState)(false);
9583
- const [operatorMenuOpen, setOperatorMenuOpen] = (0, import_react.useState)(false);
9584
- const [operator2MenuOpen, setOperator2MenuOpen] = (0, import_react.useState)(false);
9585
- const [operator3MenuOpen, setOperator3MenuOpen] = (0, import_react.useState)(false);
9586
- const [dotMenuOpen, setDotMenuOpen] = (0, import_react.useState)(false);
9587
- const [accentMenuOpen, setAccentMenuOpen] = (0, import_react.useState)(false);
9588
- const [integralMenuOpen, setIntegralMenuOpen] = (0, import_react.useState)(false);
9589
- const [selectedDigitForm2, setSelectedDigitForm] = (0, import_react.useState)("western");
9590
- const [selectedCharacterFont, setSelectedCharacterFont] = (0, import_react.useState)("default");
9591
- const [activeEditorSide, setActiveEditorSide] = (0, import_react.useState)("arabic");
9592
- const [envPaletteMode, setEnvPaletteMode] = (0, import_react.useState)("matrix");
9593
- const [matrixStyle, setMatrixStyle] = (0, import_react.useState)("pmatrix");
9594
- const [matrixRows, setMatrixRows] = (0, import_react.useState)(2);
9595
- const [matrixColumns, setMatrixColumns] = (0, import_react.useState)(2);
9596
- const [matrixHover, setMatrixHover] = (0, import_react.useState)(null);
9597
- const [arrayAlignmentColumn, setArrayAlignmentColumn] = (0, import_react.useState)(1);
9598
- (0, import_react.useImperativeHandle)(ref, () => ({
10937
+ const [debugImportOpen, setDebugImportOpen] = (0, import_react4.useState)(false);
10938
+ const [debugImportText, setDebugImportText] = (0, import_react4.useState)("");
10939
+ const [debugImportError, setDebugImportError] = (0, import_react4.useState)("");
10940
+ const [openDesktopMenu, setOpenDesktopMenu] = (0, import_react4.useState)(null);
10941
+ const [selectedDigitForm2, setSelectedDigitForm] = (0, import_react4.useState)("western");
10942
+ const [selectedCharacterFont, setSelectedCharacterFont] = (0, import_react4.useState)("default");
10943
+ const [activeEditorSide, setActiveEditorSide] = (0, import_react4.useState)("arabic");
10944
+ const [compactPreviewOpen, setCompactPreviewOpen] = (0, import_react4.useState)(false);
10945
+ const [compactControlState, setCompactControlState] = (0, import_react4.useState)({
10946
+ canUndo: false,
10947
+ canRedo: false,
10948
+ hasSelection: false,
10949
+ splitLeafTyping: initialSession?.splitLeafTyping ?? true
10950
+ });
10951
+ const [envPaletteMode, setEnvPaletteMode] = (0, import_react4.useState)("matrix");
10952
+ const [matrixStyle, setMatrixStyle] = (0, import_react4.useState)("pmatrix");
10953
+ const [matrixRows, setMatrixRows] = (0, import_react4.useState)(2);
10954
+ const [matrixColumns, setMatrixColumns] = (0, import_react4.useState)(2);
10955
+ const [matrixHover, setMatrixHover] = (0, import_react4.useState)(null);
10956
+ const [arrayAlignmentColumn, setArrayAlignmentColumn] = (0, import_react4.useState)(1);
10957
+ const closeDesktopMenu = (0, import_react4.useCallback)(() => setOpenDesktopMenu(null), []);
10958
+ useDesktopPopoverPlacement(wrapperRef, openDesktopMenu !== null, closeDesktopMenu);
10959
+ function desktopMenuOpen(menu) {
10960
+ return openDesktopMenu === menu;
10961
+ }
10962
+ function setDesktopMenuOpen(menu, value) {
10963
+ setOpenDesktopMenu((current) => {
10964
+ const isOpen = current === menu;
10965
+ const shouldOpen = typeof value === "function" ? value(isOpen) : value;
10966
+ return shouldOpen ? menu : isOpen ? null : current;
10967
+ });
10968
+ }
10969
+ const delimiterMenuOpen = desktopMenuOpen("delimiters");
10970
+ const matrixMenuOpen = desktopMenuOpen("matrix");
10971
+ const spacingMenuOpen = desktopMenuOpen("spacing");
10972
+ const functionMenuOpen = desktopMenuOpen("functions");
10973
+ const limitsSeriesMenuOpen = desktopMenuOpen("limitsSeries");
10974
+ const function2MenuOpen = desktopMenuOpen("functions2");
10975
+ const derivativeMenuOpen = desktopMenuOpen("derivatives");
10976
+ const groupMenuOpen = desktopMenuOpen("groups");
10977
+ const operatorMenuOpen = desktopMenuOpen("operators1");
10978
+ const operator2MenuOpen = desktopMenuOpen("operators2");
10979
+ const operator3MenuOpen = desktopMenuOpen("operators3");
10980
+ const dotMenuOpen = desktopMenuOpen("dots");
10981
+ const accentMenuOpen = desktopMenuOpen("accents");
10982
+ const integralMenuOpen = desktopMenuOpen("integrals");
10983
+ const characterFontMenuOpen = desktopMenuOpen("font");
10984
+ const digitMenuOpen = desktopMenuOpen("digits");
10985
+ const setDelimiterMenuOpen = (value) => setDesktopMenuOpen("delimiters", value);
10986
+ const setMatrixMenuOpen = (value) => setDesktopMenuOpen("matrix", value);
10987
+ const setSpacingMenuOpen = (value) => setDesktopMenuOpen("spacing", value);
10988
+ const setFunctionMenuOpen = (value) => setDesktopMenuOpen("functions", value);
10989
+ const setLimitsSeriesMenuOpen = (value) => setDesktopMenuOpen("limitsSeries", value);
10990
+ const setFunction2MenuOpen = (value) => setDesktopMenuOpen("functions2", value);
10991
+ const setDerivativeMenuOpen = (value) => setDesktopMenuOpen("derivatives", value);
10992
+ const setGroupMenuOpen = (value) => setDesktopMenuOpen("groups", value);
10993
+ const setOperatorMenuOpen = (value) => setDesktopMenuOpen("operators1", value);
10994
+ const setOperator2MenuOpen = (value) => setDesktopMenuOpen("operators2", value);
10995
+ const setOperator3MenuOpen = (value) => setDesktopMenuOpen("operators3", value);
10996
+ const setDotMenuOpen = (value) => setDesktopMenuOpen("dots", value);
10997
+ const setAccentMenuOpen = (value) => setDesktopMenuOpen("accents", value);
10998
+ const setIntegralMenuOpen = (value) => setDesktopMenuOpen("integrals", value);
10999
+ const setCharacterFontMenuOpen = (value) => setDesktopMenuOpen("font", value);
11000
+ const setDigitMenuOpen = (value) => setDesktopMenuOpen("digits", value);
11001
+ (0, import_react4.useImperativeHandle)(ref, () => ({
9599
11002
  getRuntime: () => runtimeRef.current
9600
11003
  }));
9601
- const updatePreview = (0, import_react.useCallback)(async (session) => {
11004
+ const updatePreview = (0, import_react4.useCallback)(async (session) => {
9602
11005
  const mathOutputEl = mathOutputRef.current;
9603
11006
  const renderErrorEl = renderErrorRef.current;
9604
11007
  const latexLinesEl = latexLinesRef.current;
@@ -9648,7 +11051,7 @@ ${arabic || currentMessages.empty}`;
9648
11051
  }
9649
11052
  }
9650
11053
  }, []);
9651
- const updatePreviewRef = (0, import_react.useRef)(updatePreview);
11054
+ const updatePreviewRef = (0, import_react4.useRef)(updatePreview);
9652
11055
  updatePreviewRef.current = updatePreview;
9653
11056
  async function copyDebugText(text) {
9654
11057
  try {
@@ -9698,7 +11101,7 @@ ${arabic || currentMessages.empty}`;
9698
11101
  setDebugImportError(importError instanceof Error ? importError.message : String(importError));
9699
11102
  }
9700
11103
  }
9701
- (0, import_react.useEffect)(() => {
11104
+ (0, import_react4.useEffect)(() => {
9702
11105
  injectWidgetChromeCss();
9703
11106
  injectBuTeXEditorStyles(typeof document !== "undefined" ? document : void 0);
9704
11107
  const surfaceEl = surfaceRef.current;
@@ -9719,11 +11122,28 @@ ${arabic || currentMessages.empty}`;
9719
11122
  splitTypingBtn: splitTypingBtnRef.current,
9720
11123
  digitFormBtn: digitFormBtnRef.current
9721
11124
  },
9722
- outsidePointerIgnoreSelectors: [".butex-widget .toolbar", "#btn-copy", "#btn-cut", "#btn-paste"],
11125
+ outsidePointerIgnoreSelectors: [
11126
+ ".butex-widget .toolbar",
11127
+ ".butex-widget__mobile-toolbar",
11128
+ ".butex-widget__command-sheet-backdrop",
11129
+ "#btn-copy",
11130
+ "#btn-cut",
11131
+ "#btn-paste"
11132
+ ],
9723
11133
  onSessionChange: (session) => {
9724
11134
  setSelectedDigitForm(session.currentDigitForm ?? "western");
9725
11135
  setSelectedCharacterFont(session.currentCharacterFont ?? "default");
9726
11136
  setActiveEditorSide(session.activeSide);
11137
+ const hasSelection = Boolean(session.selection && session.selection.anchorIndex !== session.selection.focusIndex);
11138
+ const nextCompactState = {
11139
+ canUndo: undoBtnRef.current?.disabled === false,
11140
+ canRedo: redoBtnRef.current?.disabled === false,
11141
+ hasSelection,
11142
+ splitLeafTyping: session.splitLeafTyping
11143
+ };
11144
+ setCompactControlState(
11145
+ (current) => current.canUndo === nextCompactState.canUndo && current.canRedo === nextCompactState.canRedo && current.hasSelection === nextCompactState.hasSelection && current.splitLeafTyping === nextCompactState.splitLeafTyping ? current : nextCompactState
11146
+ );
9727
11147
  onSessionChangeRef.current?.(session);
9728
11148
  void updatePreviewRef.current(session).catch((err) => {
9729
11149
  const message = err instanceof Error ? err.message : String(err);
@@ -9736,6 +11156,19 @@ ${arabic || currentMessages.empty}`;
9736
11156
  }
9737
11157
  });
9738
11158
  runtimeRef.current = runtime;
11159
+ let viewportRevealFrame = null;
11160
+ const stopViewportObserver = observeVisibleViewport(window, (change) => {
11161
+ if (change.initial || !change.sizeChanged && change.reason !== "orientation") {
11162
+ return;
11163
+ }
11164
+ if (viewportRevealFrame !== null) {
11165
+ window.cancelAnimationFrame(viewportRevealFrame);
11166
+ }
11167
+ viewportRevealFrame = window.requestAnimationFrame(() => {
11168
+ viewportRevealFrame = null;
11169
+ revealCaretInSurface(surfaceEl);
11170
+ });
11171
+ });
9739
11172
  if (typeof window !== "undefined" && window.MathJax?.startup?.promise) {
9740
11173
  window.MathJax.startup.promise.then(() => {
9741
11174
  runtime.render();
@@ -9751,11 +11184,15 @@ ${arabic || currentMessages.empty}`;
9751
11184
  }
9752
11185
  runtime.focusInput();
9753
11186
  return () => {
11187
+ stopViewportObserver();
11188
+ if (viewportRevealFrame !== null) {
11189
+ window.cancelAnimationFrame(viewportRevealFrame);
11190
+ }
9754
11191
  runtime.destroy();
9755
11192
  runtimeRef.current = null;
9756
11193
  };
9757
11194
  }, []);
9758
- (0, import_react.useEffect)(() => {
11195
+ (0, import_react4.useEffect)(() => {
9759
11196
  runtimeRef.current?.setUiLocale(uiLocale);
9760
11197
  const session = runtimeRef.current?.getSession();
9761
11198
  if (session) {
@@ -9774,24 +11211,43 @@ ${arabic || currentMessages.empty}`;
9774
11211
  runtimeRef.current?.insertMatrixEnv(matrixStyle, rows, columns);
9775
11212
  }
9776
11213
  }
9777
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11214
+ const compactToolbarState = {
11215
+ ...compactControlState,
11216
+ activeSide: activeEditorSide,
11217
+ characterFont: selectedCharacterFont,
11218
+ digitForm: selectedDigitForm2
11219
+ };
11220
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9778
11221
  "div",
9779
11222
  {
9780
11223
  ref: wrapperRef,
9781
11224
  className: `butex-widget ${className ?? ""}`.trim(),
11225
+ "data-compact-preview": compactPreviewOpen ? "open" : "closed",
11226
+ "data-responsive-mode": responsiveMode,
9782
11227
  dir: uiLocaleDirection(uiLocale),
9783
11228
  lang: uiLocale,
9784
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "butex-widget-layout", children: [
9785
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "panel", children: [
9786
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "toolbar", children: [
9787
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "toolbar-group toolbar-history", role: "group", "aria-label": messages.undoRedo, children: [
9788
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { ref: undoBtnRef, id: "btn-undo", type: "button", className: "icon-btn", title: messages.undo, "aria-label": messages.undo, children: "\u21B7" }),
9789
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { ref: redoBtnRef, id: "btn-redo", type: "button", className: "icon-btn", title: messages.redo, "aria-label": messages.redo, children: "\u21B6" })
11229
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "butex-widget-layout", children: [
11230
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("section", { className: "panel panel-editor", children: [
11231
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
11232
+ EquationMobileToolbar,
11233
+ {
11234
+ uiLocale,
11235
+ messages,
11236
+ state: compactToolbarState,
11237
+ showSideSwitcher,
11238
+ inputRef,
11239
+ getRuntime: () => runtimeRef.current
11240
+ }
11241
+ ),
11242
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "toolbar butex-widget__desktop-toolbar", children: [
11243
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "toolbar-group toolbar-history", role: "group", "aria-label": messages.undoRedo, children: [
11244
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { ref: undoBtnRef, id: "btn-undo", type: "button", className: "icon-btn", title: messages.undo, "aria-label": messages.undo, children: "\u21B7" }),
11245
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { ref: redoBtnRef, id: "btn-redo", type: "button", className: "icon-btn", title: messages.redo, "aria-label": messages.redo, children: "\u21B6" })
9790
11246
  ] }),
9791
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "toolbar-group toolbar-clipboard", role: "group", "aria-label": messages.clipboard, children: [
9792
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { ref: copyBtnRef, id: "btn-copy", type: "button", className: "icon-btn", title: messages.copy, "aria-label": messages.copy, disabled: true, children: "\u29C9" }),
9793
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { ref: cutBtnRef, id: "btn-cut", type: "button", className: "icon-btn", title: messages.cut, "aria-label": messages.cut, disabled: true, children: "\u2702" }),
9794
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11247
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "toolbar-group toolbar-clipboard", role: "group", "aria-label": messages.clipboard, children: [
11248
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { ref: copyBtnRef, id: "btn-copy", type: "button", className: "icon-btn", title: messages.copy, "aria-label": messages.copy, disabled: true, children: "\u29C9" }),
11249
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { ref: cutBtnRef, id: "btn-cut", type: "button", className: "icon-btn", title: messages.cut, "aria-label": messages.cut, disabled: true, children: "\u2702" }),
11250
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9795
11251
  "button",
9796
11252
  {
9797
11253
  id: "btn-paste",
@@ -9808,9 +11264,9 @@ ${arabic || currentMessages.empty}`;
9808
11264
  }
9809
11265
  )
9810
11266
  ] }),
9811
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "toolbar-group toolbar-settings", role: "group", "aria-label": messages.editorSettings, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "icon-btn accent", type: "button", title: messages.toggleSide, "aria-label": messages.toggleSide, onClick: () => runtimeRef.current?.toggleSide(), children: "\u21C4" }) }),
9812
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "toolbar-group toolbar-structures", role: "group", "aria-label": messages.structures, children: [
9813
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
11267
+ showSideSwitcher ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "toolbar-group toolbar-settings", role: "group", "aria-label": messages.editorSettings, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "icon-btn accent", type: "button", title: messages.toggleSide, "aria-label": messages.toggleSide, onClick: () => runtimeRef.current?.toggleSide(), children: "\u21C4" }) }) : null,
11268
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "toolbar-group toolbar-structures", role: "group", "aria-label": messages.structures, children: [
11269
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
9814
11270
  "div",
9815
11271
  {
9816
11272
  className: "delimiter-command-menu",
@@ -9821,27 +11277,27 @@ ${arabic || currentMessages.empty}`;
9821
11277
  }
9822
11278
  },
9823
11279
  children: [
9824
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11280
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9825
11281
  "button",
9826
11282
  {
9827
11283
  className: "icon-btn delimiter-command-btn",
9828
11284
  type: "button",
9829
11285
  title: messages.insertDelimiters,
9830
11286
  "aria-label": messages.insertDelimiters,
9831
- "aria-haspopup": "listbox",
11287
+ "aria-haspopup": "menu",
9832
11288
  "aria-expanded": delimiterMenuOpen,
9833
11289
  onClick: () => setDelimiterMenuOpen((open) => !open),
9834
11290
  children: "()"
9835
11291
  }
9836
11292
  ),
9837
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "delimiter-command-options", role: "listbox", "aria-label": messages.insertDelimiters, hidden: !delimiterMenuOpen, children: [
9838
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11293
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "delimiter-command-options", role: "menu", "aria-label": messages.insertDelimiters, hidden: !delimiterMenuOpen, children: [
11294
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9839
11295
  "button",
9840
11296
  {
9841
11297
  className: "delimiter-command-option",
9842
11298
  "data-delim": "paren",
9843
11299
  type: "button",
9844
- role: "option",
11300
+ role: "menuitem",
9845
11301
  title: messages.insertParentheses,
9846
11302
  "aria-label": messages.insertParentheses,
9847
11303
  onMouseDown: (event) => event.preventDefault(),
@@ -9853,13 +11309,13 @@ ${arabic || currentMessages.empty}`;
9853
11309
  children: "()"
9854
11310
  }
9855
11311
  ),
9856
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11312
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9857
11313
  "button",
9858
11314
  {
9859
11315
  className: "delimiter-command-option",
9860
11316
  "data-delim": "bracket",
9861
11317
  type: "button",
9862
- role: "option",
11318
+ role: "menuitem",
9863
11319
  title: messages.insertBrackets,
9864
11320
  "aria-label": messages.insertBrackets,
9865
11321
  onMouseDown: (event) => event.preventDefault(),
@@ -9871,13 +11327,13 @@ ${arabic || currentMessages.empty}`;
9871
11327
  children: "[]"
9872
11328
  }
9873
11329
  ),
9874
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11330
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9875
11331
  "button",
9876
11332
  {
9877
11333
  className: "delimiter-command-option",
9878
11334
  "data-delim": "brace",
9879
11335
  type: "button",
9880
- role: "option",
11336
+ role: "menuitem",
9881
11337
  title: messages.insertBraces,
9882
11338
  "aria-label": messages.insertBraces,
9883
11339
  onMouseDown: (event) => event.preventDefault(),
@@ -9893,40 +11349,40 @@ ${arabic || currentMessages.empty}`;
9893
11349
  ]
9894
11350
  }
9895
11351
  ),
9896
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { id: "insert-frac", className: "icon-btn frac-icon-btn", type: "button", title: messages.insertFraction, "aria-label": messages.insertFraction, onClick: () => {
11352
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { id: "insert-frac", className: "icon-btn frac-icon-btn", type: "button", title: messages.insertFraction, "aria-label": messages.insertFraction, onClick: () => {
9897
11353
  runtimeRef.current?.insertFraction();
9898
11354
  focusSurface();
9899
- }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "toolbar-frac-icon", "aria-hidden": "true", children: [
9900
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u0623" }),
9901
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u0628" })
11355
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "toolbar-frac-icon", "aria-hidden": "true", children: [
11356
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u0623" }),
11357
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u0628" })
9902
11358
  ] }) }),
9903
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { id: "insert-sqrt", className: "icon-btn", type: "button", title: messages.insertRoot, "aria-label": messages.insertRoot, onClick: () => {
11359
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { id: "insert-sqrt", className: "icon-btn", type: "button", title: messages.insertRoot, "aria-label": messages.insertRoot, onClick: () => {
9904
11360
  runtimeRef.current?.insertSqrt();
9905
11361
  focusSurface();
9906
- }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "toolbar-sqrt-icon", "aria-hidden": "true", children: "\u221A" }) }),
9907
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { id: "insert-overset", className: "icon-btn", type: "button", title: messages.insertOverset, "aria-label": messages.insertOverset, onClick: () => {
11362
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "toolbar-sqrt-icon", "aria-hidden": "true", children: "\u221A" }) }),
11363
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { id: "insert-overset", className: "icon-btn", type: "button", title: messages.insertOverset, "aria-label": messages.insertOverset, onClick: () => {
9908
11364
  runtimeRef.current?.insertOverset();
9909
11365
  focusSurface();
9910
- }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "toolbar-accent-icon toolbar-accent-icon--over", "aria-hidden": "true", children: [
9911
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u2217" }),
9912
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u25A1" })
11366
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "toolbar-accent-icon toolbar-accent-icon--over", "aria-hidden": "true", children: [
11367
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u2217" }),
11368
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u25A1" })
9913
11369
  ] }) }),
9914
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { id: "insert-underset", className: "icon-btn", type: "button", title: messages.insertUnderset, "aria-label": messages.insertUnderset, onClick: () => {
11370
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { id: "insert-underset", className: "icon-btn", type: "button", title: messages.insertUnderset, "aria-label": messages.insertUnderset, onClick: () => {
9915
11371
  runtimeRef.current?.insertUnderset();
9916
11372
  focusSurface();
9917
- }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "toolbar-accent-icon toolbar-accent-icon--under", "aria-hidden": "true", children: [
9918
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u25A1" }),
9919
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u2217" })
11373
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "toolbar-accent-icon toolbar-accent-icon--under", "aria-hidden": "true", children: [
11374
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u25A1" }),
11375
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u2217" })
9920
11376
  ] }) }),
9921
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { id: "insert-accent-pair", className: "icon-btn", type: "button", title: messages.insertAccentPair, "aria-label": messages.insertAccentPair, onClick: () => {
11377
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { id: "insert-accent-pair", className: "icon-btn", type: "button", title: messages.insertAccentPair, "aria-label": messages.insertAccentPair, onClick: () => {
9922
11378
  runtimeRef.current?.insertAccentPair();
9923
11379
  focusSurface();
9924
- }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "toolbar-accent-icon toolbar-accent-icon--pair", "aria-hidden": "true", children: [
9925
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u2217" }),
9926
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u25A1" }),
9927
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u2217" })
11380
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "toolbar-accent-icon toolbar-accent-icon--pair", "aria-hidden": "true", children: [
11381
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u2217" }),
11382
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u25A1" }),
11383
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u2217" })
9928
11384
  ] }) }),
9929
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
11385
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
9930
11386
  "div",
9931
11387
  {
9932
11388
  className: "function-command-menu operator-command-menu",
@@ -9937,7 +11393,7 @@ ${arabic || currentMessages.empty}`;
9937
11393
  }
9938
11394
  },
9939
11395
  children: [
9940
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11396
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9941
11397
  "button",
9942
11398
  {
9943
11399
  id: "insert-accents",
@@ -9945,21 +11401,21 @@ ${arabic || currentMessages.empty}`;
9945
11401
  type: "button",
9946
11402
  title: messages.insertAccents,
9947
11403
  "aria-label": messages.insertAccents,
9948
- "aria-haspopup": "listbox",
11404
+ "aria-haspopup": "menu",
9949
11405
  "aria-expanded": accentMenuOpen,
9950
11406
  onClick: () => setAccentMenuOpen((open) => !open),
9951
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "toolbar-accent-icon toolbar-accent-icon--over", "aria-hidden": "true", children: [
9952
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u02C6" }),
9953
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u25A1" })
11407
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "toolbar-accent-icon toolbar-accent-icon--over", "aria-hidden": "true", children: [
11408
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u02C6" }),
11409
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u25A1" })
9954
11410
  ] })
9955
11411
  }
9956
11412
  ),
9957
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "function-command-options operator-command-options", role: "listbox", "aria-label": messages.insertAccents, hidden: !accentMenuOpen, children: ACCENT_COMMANDS_LIST.map((command) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11413
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "function-command-options operator-command-options", role: "menu", "aria-label": messages.insertAccents, hidden: !accentMenuOpen, children: ACCENT_COMMANDS_LIST.map((command) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9958
11414
  "button",
9959
11415
  {
9960
11416
  className: "function-command-option operator-command-option",
9961
11417
  type: "button",
9962
- role: "option",
11418
+ role: "menuitem",
9963
11419
  title: accentCommandTitle(command, uiLocale),
9964
11420
  "aria-label": accentCommandTitle(command, uiLocale),
9965
11421
  onMouseDown: (event) => event.preventDefault(),
@@ -9968,7 +11424,7 @@ ${arabic || currentMessages.empty}`;
9968
11424
  setAccentMenuOpen(false);
9969
11425
  focusSurface();
9970
11426
  },
9971
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "operator-command-label", children: command.label })
11427
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "operator-command-label", children: command.label })
9972
11428
  },
9973
11429
  command.id
9974
11430
  )) })
@@ -9976,7 +11432,7 @@ ${arabic || currentMessages.empty}`;
9976
11432
  }
9977
11433
  )
9978
11434
  ] }),
9979
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "toolbar-group toolbar-environments", role: "group", "aria-label": messages.environments, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
11435
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "toolbar-group toolbar-environments", role: "group", "aria-label": messages.environments, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
9980
11436
  "div",
9981
11437
  {
9982
11438
  className: "matrix-command-menu",
@@ -9987,7 +11443,7 @@ ${arabic || currentMessages.empty}`;
9987
11443
  }
9988
11444
  },
9989
11445
  children: [
9990
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11446
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
9991
11447
  "button",
9992
11448
  {
9993
11449
  className: "icon-btn matrix-command-btn",
@@ -9997,20 +11453,20 @@ ${arabic || currentMessages.empty}`;
9997
11453
  "aria-haspopup": "dialog",
9998
11454
  "aria-expanded": matrixMenuOpen,
9999
11455
  onClick: () => setMatrixMenuOpen((open) => !open),
10000
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "toolbar-matrix-icon", "aria-hidden": "true", children: [
10001
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {}),
10002
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {}),
10003
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {}),
10004
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {})
11456
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "toolbar-matrix-icon", "aria-hidden": "true", children: [
11457
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", {}),
11458
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", {}),
11459
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", {}),
11460
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", {})
10005
11461
  ] })
10006
11462
  }
10007
11463
  ),
10008
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "matrix-command-popover", role: "dialog", "aria-label": messages.insertEnvironment, hidden: !matrixMenuOpen, children: [
10009
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "matrix-style-options", role: "listbox", "aria-label": messages.environmentType, children: [
11464
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "matrix-command-popover", role: "dialog", "aria-label": messages.insertEnvironment, hidden: !matrixMenuOpen, children: [
11465
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "matrix-style-options", role: "listbox", "aria-label": messages.environmentType, children: [
10010
11466
  { id: "matrix", label: messages.matrix },
10011
11467
  { id: "array", label: messages.array },
10012
11468
  { id: "aligned", label: messages.aligned }
10013
- ].map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11469
+ ].map((option) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10014
11470
  "button",
10015
11471
  {
10016
11472
  type: "button",
@@ -10028,14 +11484,14 @@ ${arabic || currentMessages.empty}`;
10028
11484
  },
10029
11485
  option.id
10030
11486
  )) }),
10031
- envPaletteMode === "matrix" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "matrix-style-options", role: "listbox", "aria-label": messages.matrixType, children: MATRIX_STYLES.map((style) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11487
+ envPaletteMode === "matrix" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "matrix-style-options", role: "listbox", "aria-label": messages.matrixType, children: MATRIX_STYLES2.map((style) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10032
11488
  "button",
10033
11489
  {
10034
11490
  type: "button",
10035
11491
  role: "option",
10036
11492
  "aria-selected": matrixStyle === style.id,
10037
11493
  className: "matrix-style-option",
10038
- title: matrixStyleTitle(style.id, messages),
11494
+ title: matrixStyleTitle2(style.id, messages),
10039
11495
  onMouseDown: (event) => event.preventDefault(),
10040
11496
  onClick: () => {
10041
11497
  setMatrixStyle(style.id);
@@ -10044,21 +11500,21 @@ ${arabic || currentMessages.empty}`;
10044
11500
  },
10045
11501
  style.id
10046
11502
  )) }) : null,
10047
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "matrix-size-readout", children: matrixHover ? matrixSizeLabel(matrixHover.rows, matrixHover.columns, messages) : matrixSizeLabel(matrixRows, matrixColumns, messages) }),
10048
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "matrix-grid-picker", "aria-label": messages.chooseEnvironmentSize, children: Array.from(
11503
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "matrix-size-readout", children: matrixHover ? matrixSizeLabel2(matrixHover.rows, matrixHover.columns, messages) : matrixSizeLabel2(matrixRows, matrixColumns, messages) }),
11504
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "matrix-grid-picker", "aria-label": messages.chooseEnvironmentSize, children: Array.from(
10049
11505
  { length: 8 },
10050
11506
  (_, rowIndex) => Array.from({ length: 8 }, (_2, columnIndex) => {
10051
11507
  const rows = rowIndex + 1;
10052
11508
  const columns = columnIndex + 1;
10053
11509
  const activeRows = matrixHover?.rows ?? matrixRows;
10054
11510
  const activeColumns = matrixHover?.columns ?? matrixColumns;
10055
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11511
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10056
11512
  "button",
10057
11513
  {
10058
11514
  type: "button",
10059
11515
  className: rows <= activeRows && columns <= activeColumns ? "matrix-grid-cell active" : "matrix-grid-cell",
10060
- title: matrixSizeLabel(rows, columns, messages),
10061
- "aria-label": matrixSizeLabel(rows, columns, messages),
11516
+ title: matrixSizeLabel2(rows, columns, messages),
11517
+ "aria-label": matrixSizeLabel2(rows, columns, messages),
10062
11518
  onMouseEnter: () => setMatrixHover({ rows, columns }),
10063
11519
  onMouseDown: (event) => event.preventDefault(),
10064
11520
  onClick: () => {
@@ -10074,42 +11530,42 @@ ${arabic || currentMessages.empty}`;
10074
11530
  );
10075
11531
  })
10076
11532
  ) }),
10077
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "matrix-custom-size", children: [
10078
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: [
11533
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "matrix-custom-size", children: [
11534
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { children: [
10079
11535
  messages.row,
10080
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11536
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10081
11537
  "input",
10082
11538
  {
10083
11539
  type: "number",
10084
11540
  min: 1,
10085
11541
  max: 12,
10086
11542
  value: matrixRows,
10087
- onChange: (event) => setMatrixRows(clampMatrixSize(Number(event.currentTarget.value) || 1))
11543
+ onChange: (event) => setMatrixRows(clampMatrixSize2(Number(event.currentTarget.value) || 1))
10088
11544
  }
10089
11545
  )
10090
11546
  ] }),
10091
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: [
11547
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { children: [
10092
11548
  messages.column,
10093
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11549
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10094
11550
  "input",
10095
11551
  {
10096
11552
  type: "number",
10097
11553
  min: 1,
10098
11554
  max: 12,
10099
11555
  value: matrixColumns,
10100
- onChange: (event) => setMatrixColumns(clampMatrixSize(Number(event.currentTarget.value) || 1))
11556
+ onChange: (event) => setMatrixColumns(clampMatrixSize2(Number(event.currentTarget.value) || 1))
10101
11557
  }
10102
11558
  )
10103
11559
  ] }),
10104
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11560
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10105
11561
  "button",
10106
11562
  {
10107
11563
  type: "button",
10108
11564
  className: "matrix-insert-custom",
10109
11565
  onMouseDown: (event) => event.preventDefault(),
10110
11566
  onClick: () => {
10111
- const rows = clampMatrixSize(matrixRows);
10112
- const columns = clampMatrixSize(matrixColumns);
11567
+ const rows = clampMatrixSize2(matrixRows);
11568
+ const columns = clampMatrixSize2(matrixColumns);
10113
11569
  insertSelectedEnvironment(rows, columns);
10114
11570
  setMatrixMenuOpen(false);
10115
11571
  setMatrixHover(null);
@@ -10119,23 +11575,23 @@ ${arabic || currentMessages.empty}`;
10119
11575
  }
10120
11576
  )
10121
11577
  ] }),
10122
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "matrix-edit-actions", "aria-label": messages.editSelectedEnvironment, children: [
10123
- envPaletteMode === "matrix" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", title: messages.applySelectedMatrixStyle, onMouseDown: (event) => event.preventDefault(), onClick: () => runtimeRef.current?.setMatrixEnvStyle(matrixStyle), children: messages.applyStyle }) : null,
10124
- envPaletteMode === "array" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
10125
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: [
11578
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "matrix-edit-actions", "aria-label": messages.editSelectedEnvironment, children: [
11579
+ envPaletteMode === "matrix" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", title: messages.applySelectedMatrixStyle, onMouseDown: (event) => event.preventDefault(), onClick: () => runtimeRef.current?.setMatrixEnvStyle(matrixStyle), children: messages.applyStyle }) : null,
11580
+ envPaletteMode === "array" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
11581
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { children: [
10126
11582
  messages.column,
10127
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11583
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10128
11584
  "input",
10129
11585
  {
10130
11586
  type: "number",
10131
11587
  min: 1,
10132
11588
  max: 12,
10133
11589
  value: arrayAlignmentColumn,
10134
- onChange: (event) => setArrayAlignmentColumn(clampMatrixSize(Number(event.currentTarget.value) || 1))
11590
+ onChange: (event) => setArrayAlignmentColumn(clampMatrixSize2(Number(event.currentTarget.value) || 1))
10135
11591
  }
10136
11592
  )
10137
11593
  ] }),
10138
- ARRAY_ALIGNMENTS.map((alignment) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11594
+ ARRAY_ALIGNMENTS2.map((alignment) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10139
11595
  "button",
10140
11596
  {
10141
11597
  type: "button",
@@ -10147,19 +11603,19 @@ ${arabic || currentMessages.empty}`;
10147
11603
  alignment.id
10148
11604
  ))
10149
11605
  ] }) : null,
10150
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", title: messages.addRow, onMouseDown: (event) => event.preventDefault(), onClick: () => runtimeRef.current?.addMatrixRow(), children: [
11606
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { type: "button", title: messages.addRow, onMouseDown: (event) => event.preventDefault(), onClick: () => runtimeRef.current?.addMatrixRow(), children: [
10151
11607
  "+",
10152
11608
  messages.row
10153
11609
  ] }),
10154
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", title: messages.removeRow, onMouseDown: (event) => event.preventDefault(), onClick: () => runtimeRef.current?.removeMatrixRow(), children: [
11610
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { type: "button", title: messages.removeRow, onMouseDown: (event) => event.preventDefault(), onClick: () => runtimeRef.current?.removeMatrixRow(), children: [
10155
11611
  "-",
10156
11612
  messages.row
10157
11613
  ] }),
10158
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", title: messages.addColumn, onMouseDown: (event) => event.preventDefault(), onClick: () => runtimeRef.current?.addMatrixColumn(), children: [
11614
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { type: "button", title: messages.addColumn, onMouseDown: (event) => event.preventDefault(), onClick: () => runtimeRef.current?.addMatrixColumn(), children: [
10159
11615
  "+",
10160
11616
  messages.column
10161
11617
  ] }),
10162
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", title: messages.removeColumn, onMouseDown: (event) => event.preventDefault(), onClick: () => runtimeRef.current?.removeMatrixColumn(), children: [
11618
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { type: "button", title: messages.removeColumn, onMouseDown: (event) => event.preventDefault(), onClick: () => runtimeRef.current?.removeMatrixColumn(), children: [
10163
11619
  "-",
10164
11620
  messages.column
10165
11621
  ] })
@@ -10168,7 +11624,7 @@ ${arabic || currentMessages.empty}`;
10168
11624
  ]
10169
11625
  }
10170
11626
  ) }),
10171
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "toolbar-group toolbar-settings", role: "group", "aria-label": messages.spaces, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
11627
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "toolbar-group toolbar-settings", role: "group", "aria-label": messages.spaces, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
10172
11628
  "div",
10173
11629
  {
10174
11630
  className: `spacing-command-menu spacing-command-menu--${activeEditorSide}`,
@@ -10179,27 +11635,27 @@ ${arabic || currentMessages.empty}`;
10179
11635
  }
10180
11636
  },
10181
11637
  children: [
10182
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11638
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10183
11639
  "button",
10184
11640
  {
10185
11641
  className: "icon-btn spacing-command-btn",
10186
11642
  type: "button",
10187
11643
  title: messages.insertSpace,
10188
11644
  "aria-label": messages.insertSpace,
10189
- "aria-haspopup": "listbox",
11645
+ "aria-haspopup": "menu",
10190
11646
  "aria-expanded": spacingMenuOpen,
10191
11647
  onClick: () => setSpacingMenuOpen((open) => !open),
10192
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "spacing-command-glyph spacing-command-glyph--positive spacing-command-glyph--level-2", "aria-hidden": "true", children: [
10193
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "spacing-command-glyph__bar" }),
10194
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "spacing-command-glyph__arrow", children: activeEditorSide === "arabic" ? "\u2190" : "\u2192" })
11648
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "spacing-command-glyph spacing-command-glyph--positive spacing-command-glyph--level-2", "aria-hidden": "true", children: [
11649
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "spacing-command-glyph__bar" }),
11650
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "spacing-command-glyph__arrow", children: activeEditorSide === "arabic" ? "\u2190" : "\u2192" })
10195
11651
  ] })
10196
11652
  }
10197
11653
  ),
10198
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "spacing-command-options", role: "listbox", "aria-label": messages.insertSpace, hidden: !spacingMenuOpen, children: SPACING_COMMANDS.map((command) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
11654
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "spacing-command-options", role: "menu", "aria-label": messages.insertSpace, hidden: !spacingMenuOpen, children: SPACING_COMMANDS2.map((command) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
10199
11655
  "button",
10200
11656
  {
10201
11657
  type: "button",
10202
- role: "option",
11658
+ role: "menuitem",
10203
11659
  className: `spacing-command-option spacing-command-option--${command.spacing.direction}`,
10204
11660
  title: atomicCommandTitle(command, uiLocale),
10205
11661
  onMouseDown: (event) => event.preventDefault(),
@@ -10209,12 +11665,12 @@ ${arabic || currentMessages.empty}`;
10209
11665
  focusSurface();
10210
11666
  },
10211
11667
  children: [
10212
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: `spacing-command-glyph spacing-command-glyph--${command.spacing.direction} spacing-command-glyph--level-${String(command.spacing.level)}`, "aria-hidden": "true", children: [
10213
- command.spacing.direction === "negative" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "spacing-command-glyph__arrow", children: spacingArrow(command, activeEditorSide) }) : null,
10214
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "spacing-command-glyph__bar" }),
10215
- command.spacing.direction === "positive" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "spacing-command-glyph__arrow", children: spacingArrow(command, activeEditorSide) }) : null
11668
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: `spacing-command-glyph spacing-command-glyph--${command.spacing.direction} spacing-command-glyph--level-${String(command.spacing.level)}`, "aria-hidden": "true", children: [
11669
+ command.spacing.direction === "negative" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "spacing-command-glyph__arrow", children: spacingArrow2(command, activeEditorSide) }) : null,
11670
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "spacing-command-glyph__bar" }),
11671
+ command.spacing.direction === "positive" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "spacing-command-glyph__arrow", children: spacingArrow2(command, activeEditorSide) }) : null
10216
11672
  ] }),
10217
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "spacing-command-option__name", children: atomicCommandTitle(command, uiLocale) })
11673
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "spacing-command-option__name", children: atomicCommandTitle(command, uiLocale) })
10218
11674
  ]
10219
11675
  },
10220
11676
  command.id
@@ -10222,8 +11678,8 @@ ${arabic || currentMessages.empty}`;
10222
11678
  ]
10223
11679
  }
10224
11680
  ) }),
10225
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "toolbar-group toolbar-functions", role: "group", "aria-label": messages.functions, children: [
10226
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
11681
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "toolbar-group toolbar-functions", role: "group", "aria-label": messages.functions, children: [
11682
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
10227
11683
  "div",
10228
11684
  {
10229
11685
  className: "function-command-menu",
@@ -10234,25 +11690,25 @@ ${arabic || currentMessages.empty}`;
10234
11690
  }
10235
11691
  },
10236
11692
  children: [
10237
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11693
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10238
11694
  "button",
10239
11695
  {
10240
11696
  className: "icon-btn function-command-btn",
10241
11697
  type: "button",
10242
11698
  title: messages.insertFunction,
10243
11699
  "aria-label": messages.insertFunction,
10244
- "aria-haspopup": "listbox",
11700
+ "aria-haspopup": "menu",
10245
11701
  "aria-expanded": functionMenuOpen,
10246
11702
  onClick: () => setFunctionMenuOpen((open) => !open),
10247
- children: FUNCTION_COMMANDS[0]?.arabicLabel ?? "\u062F"
11703
+ children: FUNCTION_COMMANDS2[0]?.arabicLabel ?? "\u062F"
10248
11704
  }
10249
11705
  ),
10250
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "function-command-options", role: "listbox", "aria-label": messages.insertFunction, hidden: !functionMenuOpen, children: FUNCTION_COMMANDS.map((command) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11706
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "function-command-options", role: "menu", "aria-label": messages.insertFunction, hidden: !functionMenuOpen, children: FUNCTION_COMMANDS2.map((command) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10251
11707
  "button",
10252
11708
  {
10253
11709
  className: "function-command-option",
10254
11710
  type: "button",
10255
- role: "option",
11711
+ role: "menuitem",
10256
11712
  title: atomicCommandTitle(command, uiLocale),
10257
11713
  "aria-label": atomicCommandTitle(command, uiLocale),
10258
11714
  onMouseDown: (event) => event.preventDefault(),
@@ -10268,7 +11724,7 @@ ${arabic || currentMessages.empty}`;
10268
11724
  ]
10269
11725
  }
10270
11726
  ),
10271
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
11727
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
10272
11728
  "div",
10273
11729
  {
10274
11730
  className: "function-command-menu function-command-menu--limits-series",
@@ -10279,25 +11735,25 @@ ${arabic || currentMessages.empty}`;
10279
11735
  }
10280
11736
  },
10281
11737
  children: [
10282
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11738
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10283
11739
  "button",
10284
11740
  {
10285
11741
  className: "icon-btn function-command-btn",
10286
11742
  type: "button",
10287
11743
  title: messages.insertLimitsSeries,
10288
11744
  "aria-label": messages.insertLimitsSeries,
10289
- "aria-haspopup": "listbox",
11745
+ "aria-haspopup": "menu",
10290
11746
  "aria-expanded": limitsSeriesMenuOpen,
10291
11747
  onClick: () => setLimitsSeriesMenuOpen((open) => !open),
10292
- children: LIMITS_SERIES_COMMANDS[0]?.arabicLabel ?? "\u062D\u062F"
11748
+ children: LIMITS_SERIES_COMMANDS2[0]?.arabicLabel ?? "\u062D\u062F"
10293
11749
  }
10294
11750
  ),
10295
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "function-command-options", role: "listbox", "aria-label": messages.insertLimitsSeries, hidden: !limitsSeriesMenuOpen, children: LIMITS_SERIES_COMMANDS.map((command) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11751
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "function-command-options", role: "menu", "aria-label": messages.insertLimitsSeries, hidden: !limitsSeriesMenuOpen, children: LIMITS_SERIES_COMMANDS2.map((command) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10296
11752
  "button",
10297
11753
  {
10298
11754
  className: "function-command-option",
10299
11755
  type: "button",
10300
- role: "option",
11756
+ role: "menuitem",
10301
11757
  title: atomicCommandTitle(command, uiLocale),
10302
11758
  "aria-label": atomicCommandTitle(command, uiLocale),
10303
11759
  onMouseDown: (event) => event.preventDefault(),
@@ -10313,7 +11769,7 @@ ${arabic || currentMessages.empty}`;
10313
11769
  ]
10314
11770
  }
10315
11771
  ),
10316
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
11772
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
10317
11773
  "div",
10318
11774
  {
10319
11775
  className: "function-command-menu function-command-menu--function2",
@@ -10324,25 +11780,25 @@ ${arabic || currentMessages.empty}`;
10324
11780
  }
10325
11781
  },
10326
11782
  children: [
10327
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11783
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10328
11784
  "button",
10329
11785
  {
10330
11786
  className: "icon-btn function-command-btn",
10331
11787
  type: "button",
10332
11788
  title: messages.insertAdditionalFunctions,
10333
11789
  "aria-label": messages.insertAdditionalFunctions,
10334
- "aria-haspopup": "listbox",
11790
+ "aria-haspopup": "menu",
10335
11791
  "aria-expanded": function2MenuOpen,
10336
11792
  onClick: () => setFunction2MenuOpen((open) => !open),
10337
- children: FUNCTION2_COMMANDS[0]?.arabicLabel ?? "\u062F"
11793
+ children: FUNCTION2_COMMANDS2[0]?.arabicLabel ?? "\u062F"
10338
11794
  }
10339
11795
  ),
10340
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "function-command-options", role: "listbox", "aria-label": messages.insertAdditionalFunctions, hidden: !function2MenuOpen, children: FUNCTION2_COMMANDS.map((command) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11796
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "function-command-options", role: "menu", "aria-label": messages.insertAdditionalFunctions, hidden: !function2MenuOpen, children: FUNCTION2_COMMANDS2.map((command) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10341
11797
  "button",
10342
11798
  {
10343
11799
  className: "function-command-option",
10344
11800
  type: "button",
10345
- role: "option",
11801
+ role: "menuitem",
10346
11802
  title: atomicCommandTitle(command, uiLocale),
10347
11803
  "aria-label": atomicCommandTitle(command, uiLocale),
10348
11804
  onMouseDown: (event) => event.preventDefault(),
@@ -10358,7 +11814,7 @@ ${arabic || currentMessages.empty}`;
10358
11814
  ]
10359
11815
  }
10360
11816
  ),
10361
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
11817
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
10362
11818
  "div",
10363
11819
  {
10364
11820
  className: "function-command-menu function-command-menu--derivative",
@@ -10369,26 +11825,26 @@ ${arabic || currentMessages.empty}`;
10369
11825
  }
10370
11826
  },
10371
11827
  children: [
10372
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11828
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10373
11829
  "button",
10374
11830
  {
10375
11831
  className: "icon-btn function-command-btn",
10376
11832
  type: "button",
10377
11833
  title: messages.insertDerivative,
10378
11834
  "aria-label": messages.insertDerivative,
10379
- "aria-haspopup": "listbox",
11835
+ "aria-haspopup": "menu",
10380
11836
  "aria-expanded": derivativeMenuOpen,
10381
11837
  onClick: () => setDerivativeMenuOpen((open) => !open),
10382
- children: DERIVATIVE_COMMANDS[0]?.arabicLabel ?? "\u0621"
11838
+ children: DERIVATIVE_COMMANDS2[0]?.arabicLabel ?? "\u0621"
10383
11839
  }
10384
11840
  ),
10385
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "function-command-options", role: "listbox", "aria-label": messages.insertDerivative, hidden: !derivativeMenuOpen, children: [
10386
- DERIVATIVE_COMMANDS.map((command) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11841
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "function-command-options", role: "menu", "aria-label": messages.insertDerivative, hidden: !derivativeMenuOpen, children: [
11842
+ DERIVATIVE_COMMANDS2.map((command) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10387
11843
  "button",
10388
11844
  {
10389
11845
  className: "function-command-option",
10390
11846
  type: "button",
10391
- role: "option",
11847
+ role: "menuitem",
10392
11848
  title: atomicCommandTitle(command, uiLocale),
10393
11849
  "aria-label": atomicCommandTitle(command, uiLocale),
10394
11850
  onMouseDown: (event) => event.preventDefault(),
@@ -10401,12 +11857,12 @@ ${arabic || currentMessages.empty}`;
10401
11857
  },
10402
11858
  command.id
10403
11859
  )),
10404
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11860
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10405
11861
  "button",
10406
11862
  {
10407
11863
  className: "function-command-option",
10408
11864
  type: "button",
10409
- role: "option",
11865
+ role: "menuitem",
10410
11866
  title: messages.insertFirstDerivative,
10411
11867
  "aria-label": messages.insertFirstDerivative,
10412
11868
  onMouseDown: (event) => event.preventDefault(),
@@ -10418,12 +11874,12 @@ ${arabic || currentMessages.empty}`;
10418
11874
  children: "\u0621/\u0633"
10419
11875
  }
10420
11876
  ),
10421
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11877
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10422
11878
  "button",
10423
11879
  {
10424
11880
  className: "function-command-option",
10425
11881
  type: "button",
10426
- role: "option",
11882
+ role: "menuitem",
10427
11883
  title: messages.insertSecondDerivative,
10428
11884
  "aria-label": messages.insertSecondDerivative,
10429
11885
  onMouseDown: (event) => event.preventDefault(),
@@ -10439,7 +11895,7 @@ ${arabic || currentMessages.empty}`;
10439
11895
  ]
10440
11896
  }
10441
11897
  ),
10442
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
11898
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
10443
11899
  "div",
10444
11900
  {
10445
11901
  className: "function-command-menu function-command-menu--groups",
@@ -10450,25 +11906,25 @@ ${arabic || currentMessages.empty}`;
10450
11906
  }
10451
11907
  },
10452
11908
  children: [
10453
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11909
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10454
11910
  "button",
10455
11911
  {
10456
11912
  className: "icon-btn function-command-btn",
10457
11913
  type: "button",
10458
11914
  title: messages.insertNumberSets,
10459
11915
  "aria-label": messages.insertNumberSets,
10460
- "aria-haspopup": "listbox",
11916
+ "aria-haspopup": "menu",
10461
11917
  "aria-expanded": groupMenuOpen,
10462
11918
  onClick: () => setGroupMenuOpen((open) => !open),
10463
- children: GROUP_COMMANDS[0]?.arabicLabel ?? "\u0645"
11919
+ children: GROUP_COMMANDS2[0]?.arabicLabel ?? "\u0645"
10464
11920
  }
10465
11921
  ),
10466
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "function-command-options", role: "listbox", "aria-label": messages.insertNumberSets, hidden: !groupMenuOpen, children: GROUP_COMMANDS.map((command) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11922
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "function-command-options", role: "menu", "aria-label": messages.insertNumberSets, hidden: !groupMenuOpen, children: GROUP_COMMANDS2.map((command) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10467
11923
  "button",
10468
11924
  {
10469
11925
  className: "function-command-option",
10470
11926
  type: "button",
10471
- role: "option",
11927
+ role: "menuitem",
10472
11928
  title: atomicCommandTitle(command, uiLocale),
10473
11929
  "aria-label": atomicCommandTitle(command, uiLocale),
10474
11930
  onMouseDown: (event) => event.preventDefault(),
@@ -10485,8 +11941,8 @@ ${arabic || currentMessages.empty}`;
10485
11941
  }
10486
11942
  )
10487
11943
  ] }),
10488
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "toolbar-group toolbar-operators", role: "group", "aria-label": messages.operations, children: [
10489
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
11944
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "toolbar-group toolbar-operators", role: "group", "aria-label": messages.operations, children: [
11945
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
10490
11946
  "div",
10491
11947
  {
10492
11948
  className: "function-command-menu operator-command-menu",
@@ -10497,25 +11953,25 @@ ${arabic || currentMessages.empty}`;
10497
11953
  }
10498
11954
  },
10499
11955
  children: [
10500
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11956
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10501
11957
  "button",
10502
11958
  {
10503
11959
  className: "icon-btn function-command-btn operator-command-btn",
10504
11960
  type: "button",
10505
11961
  title: messages.insertOperation,
10506
11962
  "aria-label": messages.insertOperation,
10507
- "aria-haspopup": "listbox",
11963
+ "aria-haspopup": "menu",
10508
11964
  "aria-expanded": operatorMenuOpen,
10509
11965
  onClick: () => setOperatorMenuOpen((open) => !open),
10510
11966
  children: renderOperatorMenuButtonLabel(OPERATOR_COMMANDS[0], "\u2217")
10511
11967
  }
10512
11968
  ),
10513
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "function-command-options operator-command-options", role: "listbox", "aria-label": messages.insertOperation, hidden: !operatorMenuOpen, children: OPERATOR_COMMANDS.map((command) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
11969
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "function-command-options operator-command-options", role: "menu", "aria-label": messages.insertOperation, hidden: !operatorMenuOpen, children: OPERATOR_COMMANDS.map((command) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10514
11970
  "button",
10515
11971
  {
10516
11972
  className: "function-command-option operator-command-option",
10517
11973
  type: "button",
10518
- role: "option",
11974
+ role: "menuitem",
10519
11975
  title: atomicOperatorCommandTitle(command, uiLocale),
10520
11976
  "aria-label": atomicOperatorCommandTitle(command, uiLocale),
10521
11977
  onMouseDown: (event) => event.preventDefault(),
@@ -10524,14 +11980,14 @@ ${arabic || currentMessages.empty}`;
10524
11980
  setOperatorMenuOpen(false);
10525
11981
  focusSurface();
10526
11982
  },
10527
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) })
11983
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) })
10528
11984
  },
10529
11985
  command.id
10530
11986
  )) })
10531
11987
  ]
10532
11988
  }
10533
11989
  ),
10534
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
11990
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
10535
11991
  "div",
10536
11992
  {
10537
11993
  className: "function-command-menu operator-command-menu",
@@ -10542,25 +11998,25 @@ ${arabic || currentMessages.empty}`;
10542
11998
  }
10543
11999
  },
10544
12000
  children: [
10545
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
12001
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10546
12002
  "button",
10547
12003
  {
10548
12004
  className: "icon-btn function-command-btn operator-command-btn",
10549
12005
  type: "button",
10550
12006
  title: messages.insertRelationsSets,
10551
12007
  "aria-label": messages.insertRelationsSets,
10552
- "aria-haspopup": "listbox",
12008
+ "aria-haspopup": "menu",
10553
12009
  "aria-expanded": operator2MenuOpen,
10554
12010
  onClick: () => setOperator2MenuOpen((open) => !open),
10555
12011
  children: "\u2229"
10556
12012
  }
10557
12013
  ),
10558
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "function-command-options operator-command-options", role: "listbox", "aria-label": messages.insertRelationsSets, hidden: !operator2MenuOpen, children: OPERATOR2_COMMANDS.map((command) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
12014
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "function-command-options operator-command-options", role: "menu", "aria-label": messages.insertRelationsSets, hidden: !operator2MenuOpen, children: OPERATOR2_COMMANDS.map((command) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10559
12015
  "button",
10560
12016
  {
10561
12017
  className: "function-command-option operator-command-option",
10562
12018
  type: "button",
10563
- role: "option",
12019
+ role: "menuitem",
10564
12020
  title: atomicOperatorCommandTitle(command, uiLocale),
10565
12021
  "aria-label": atomicOperatorCommandTitle(command, uiLocale),
10566
12022
  onMouseDown: (event) => event.preventDefault(),
@@ -10569,14 +12025,14 @@ ${arabic || currentMessages.empty}`;
10569
12025
  setOperator2MenuOpen(false);
10570
12026
  focusSurface();
10571
12027
  },
10572
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) })
12028
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) })
10573
12029
  },
10574
12030
  command.id
10575
12031
  )) })
10576
12032
  ]
10577
12033
  }
10578
12034
  ),
10579
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
12035
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
10580
12036
  "div",
10581
12037
  {
10582
12038
  className: "function-command-menu operator-command-menu",
@@ -10587,25 +12043,25 @@ ${arabic || currentMessages.empty}`;
10587
12043
  }
10588
12044
  },
10589
12045
  children: [
10590
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
12046
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10591
12047
  "button",
10592
12048
  {
10593
12049
  className: "icon-btn function-command-btn operator-command-btn",
10594
12050
  type: "button",
10595
12051
  title: messages.insertArrows,
10596
12052
  "aria-label": messages.insertArrows,
10597
- "aria-haspopup": "listbox",
12053
+ "aria-haspopup": "menu",
10598
12054
  "aria-expanded": operator3MenuOpen,
10599
12055
  onClick: () => setOperator3MenuOpen((open) => !open),
10600
12056
  children: renderOperatorMenuButtonLabel(OPERATOR3_COMMANDS[0], "\u21D2")
10601
12057
  }
10602
12058
  ),
10603
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "function-command-options operator-command-options", role: "listbox", "aria-label": messages.insertArrows, hidden: !operator3MenuOpen, children: OPERATOR3_COMMANDS.map((command) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
12059
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "function-command-options operator-command-options", role: "menu", "aria-label": messages.insertArrows, hidden: !operator3MenuOpen, children: OPERATOR3_COMMANDS.map((command) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10604
12060
  "button",
10605
12061
  {
10606
12062
  className: "function-command-option operator-command-option",
10607
12063
  type: "button",
10608
- role: "option",
12064
+ role: "menuitem",
10609
12065
  title: atomicOperatorCommandTitle(command, uiLocale),
10610
12066
  "aria-label": atomicOperatorCommandTitle(command, uiLocale),
10611
12067
  onMouseDown: (event) => event.preventDefault(),
@@ -10614,14 +12070,14 @@ ${arabic || currentMessages.empty}`;
10614
12070
  setOperator3MenuOpen(false);
10615
12071
  focusSurface();
10616
12072
  },
10617
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) })
12073
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) })
10618
12074
  },
10619
12075
  command.id
10620
12076
  )) })
10621
12077
  ]
10622
12078
  }
10623
12079
  ),
10624
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
12080
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
10625
12081
  "div",
10626
12082
  {
10627
12083
  className: "function-command-menu operator-command-menu",
@@ -10632,25 +12088,25 @@ ${arabic || currentMessages.empty}`;
10632
12088
  }
10633
12089
  },
10634
12090
  children: [
10635
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
12091
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10636
12092
  "button",
10637
12093
  {
10638
12094
  className: "icon-btn function-command-btn operator-command-btn",
10639
12095
  type: "button",
10640
12096
  title: messages.insertDots,
10641
12097
  "aria-label": messages.insertDots,
10642
- "aria-haspopup": "listbox",
12098
+ "aria-haspopup": "menu",
10643
12099
  "aria-expanded": dotMenuOpen,
10644
12100
  onClick: () => setDotMenuOpen((open) => !open),
10645
12101
  children: renderOperatorMenuButtonLabel(DOT_COMMANDS[0], "\u2026")
10646
12102
  }
10647
12103
  ),
10648
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "function-command-options operator-command-options", role: "listbox", "aria-label": messages.insertDots, hidden: !dotMenuOpen, children: DOT_COMMANDS.map((command) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
12104
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "function-command-options operator-command-options", role: "menu", "aria-label": messages.insertDots, hidden: !dotMenuOpen, children: DOT_COMMANDS.map((command) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10649
12105
  "button",
10650
12106
  {
10651
12107
  className: "function-command-option operator-command-option",
10652
12108
  type: "button",
10653
- role: "option",
12109
+ role: "menuitem",
10654
12110
  title: atomicOperatorCommandTitle(command, uiLocale),
10655
12111
  "aria-label": atomicOperatorCommandTitle(command, uiLocale),
10656
12112
  onMouseDown: (event) => event.preventDefault(),
@@ -10659,14 +12115,14 @@ ${arabic || currentMessages.empty}`;
10659
12115
  setDotMenuOpen(false);
10660
12116
  focusSurface();
10661
12117
  },
10662
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) })
12118
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) })
10663
12119
  },
10664
12120
  command.id
10665
12121
  )) })
10666
12122
  ]
10667
12123
  }
10668
12124
  ),
10669
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
12125
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
10670
12126
  "div",
10671
12127
  {
10672
12128
  className: "function-command-menu operator-command-menu",
@@ -10677,25 +12133,25 @@ ${arabic || currentMessages.empty}`;
10677
12133
  }
10678
12134
  },
10679
12135
  children: [
10680
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
12136
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10681
12137
  "button",
10682
12138
  {
10683
12139
  className: "icon-btn function-command-btn operator-command-btn",
10684
12140
  type: "button",
10685
12141
  title: messages.insertIntegrals,
10686
12142
  "aria-label": messages.insertIntegrals,
10687
- "aria-haspopup": "listbox",
12143
+ "aria-haspopup": "menu",
10688
12144
  "aria-expanded": integralMenuOpen,
10689
12145
  onClick: () => setIntegralMenuOpen((open) => !open),
10690
12146
  children: renderOperatorMenuButtonLabel(INTEGRAL_COMMANDS[0], "\u222B")
10691
12147
  }
10692
12148
  ),
10693
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "function-command-options operator-command-options", role: "listbox", "aria-label": messages.insertIntegrals, hidden: !integralMenuOpen, children: INTEGRAL_COMMANDS.map((command) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
12149
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "function-command-options operator-command-options", role: "menu", "aria-label": messages.insertIntegrals, hidden: !integralMenuOpen, children: INTEGRAL_COMMANDS.map((command) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10694
12150
  "button",
10695
12151
  {
10696
12152
  className: "function-command-option operator-command-option",
10697
12153
  type: "button",
10698
- role: "option",
12154
+ role: "menuitem",
10699
12155
  title: atomicOperatorCommandTitle(command, uiLocale),
10700
12156
  "aria-label": atomicOperatorCommandTitle(command, uiLocale),
10701
12157
  onMouseDown: (event) => event.preventDefault(),
@@ -10704,7 +12160,7 @@ ${arabic || currentMessages.empty}`;
10704
12160
  setIntegralMenuOpen(false);
10705
12161
  focusSurface();
10706
12162
  },
10707
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) })
12163
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: shouldMirrorOperatorDisplay(command) ? "operator-command-label operator-command-label--mirror" : "operator-command-label", children: renderOperatorCommandLabel(command) })
10708
12164
  },
10709
12165
  command.id
10710
12166
  )) })
@@ -10712,28 +12168,28 @@ ${arabic || currentMessages.empty}`;
10712
12168
  }
10713
12169
  )
10714
12170
  ] }),
10715
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "toolbar-group toolbar-scripts", role: "group", "aria-label": messages.scripts, children: [
10716
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "icon-btn script-icon-btn", type: "button", title: messages.addSuperscript, "aria-label": messages.addSuperscript, onClick: () => runtimeRef.current?.addSup(), children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "toolbar-script-icon toolbar-script-icon--sup", "aria-hidden": "true", children: [
10717
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u0646" }),
10718
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u0633" })
12171
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "toolbar-group toolbar-scripts", role: "group", "aria-label": messages.scripts, children: [
12172
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "icon-btn script-icon-btn", type: "button", title: messages.addSuperscript, "aria-label": messages.addSuperscript, onClick: () => runtimeRef.current?.addSup(), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "toolbar-script-icon toolbar-script-icon--sup", "aria-hidden": "true", children: [
12173
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u0646" }),
12174
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u0633" })
10719
12175
  ] }) }),
10720
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "icon-btn script-icon-btn", type: "button", title: messages.addSubscript, "aria-label": messages.addSubscript, onClick: () => runtimeRef.current?.addSub(), children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "toolbar-script-icon toolbar-script-icon--sub", "aria-hidden": "true", children: [
10721
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u0646" }),
10722
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u0633" })
12176
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "icon-btn script-icon-btn", type: "button", title: messages.addSubscript, "aria-label": messages.addSubscript, onClick: () => runtimeRef.current?.addSub(), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "toolbar-script-icon toolbar-script-icon--sub", "aria-hidden": "true", children: [
12177
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u0646" }),
12178
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u0633" })
10723
12179
  ] }) }),
10724
- /* @__PURE__ */ (0, import_jsx_runtime.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__ */ (0, import_jsx_runtime.jsxs)("span", { className: "toolbar-remove-script-icon toolbar-remove-script-icon--sup", "aria-hidden": "true", children: [
10725
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u0646" }),
10726
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\xD7" })
12180
+ /* @__PURE__ */ (0, import_jsx_runtime2.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__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "toolbar-remove-script-icon toolbar-remove-script-icon--sup", "aria-hidden": "true", children: [
12181
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u0646" }),
12182
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\xD7" })
10727
12183
  ] }) }),
10728
- /* @__PURE__ */ (0, import_jsx_runtime.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__ */ (0, import_jsx_runtime.jsxs)("span", { className: "toolbar-remove-script-icon toolbar-remove-script-icon--sub", "aria-hidden": "true", children: [
10729
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u0646" }),
10730
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\xD7" })
12184
+ /* @__PURE__ */ (0, import_jsx_runtime2.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__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "toolbar-remove-script-icon toolbar-remove-script-icon--sub", "aria-hidden": "true", children: [
12185
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u0646" }),
12186
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\xD7" })
10731
12187
  ] }) })
10732
12188
  ] }),
10733
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "toolbar-group toolbar-settings", role: "group", "aria-label": messages.inputStyles, children: [
10734
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "icon-btn delete-node-btn", type: "button", title: messages.deleteSelectedStructure, "aria-label": messages.deleteSelectedStructure, onClick: () => runtimeRef.current?.deleteStructure(), children: "\xD7" }),
10735
- /* @__PURE__ */ (0, import_jsx_runtime.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" }),
10736
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
12189
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "toolbar-group toolbar-settings", role: "group", "aria-label": messages.inputStyles, children: [
12190
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "icon-btn delete-node-btn", type: "button", title: messages.deleteSelectedStructure, "aria-label": messages.deleteSelectedStructure, onClick: () => runtimeRef.current?.deleteStructure(), children: "\xD7" }),
12191
+ /* @__PURE__ */ (0, import_jsx_runtime2.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" }),
12192
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
10737
12193
  "div",
10738
12194
  {
10739
12195
  className: "character-font-menu",
@@ -10744,14 +12200,14 @@ ${arabic || currentMessages.empty}`;
10744
12200
  }
10745
12201
  },
10746
12202
  children: [
10747
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
12203
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10748
12204
  "button",
10749
12205
  {
10750
12206
  ref: characterFontBtnRef,
10751
12207
  id: "select-character-font",
10752
12208
  className: `icon-btn font-mode-btn font-mode-btn--${selectedCharacterFont}`,
10753
12209
  type: "button",
10754
- title: characterFontTitle(selectedCharacterFont, messages),
12210
+ title: characterFontTitle2(selectedCharacterFont, messages),
10755
12211
  "aria-label": messages.chooseWritingFont,
10756
12212
  "aria-haspopup": "listbox",
10757
12213
  "aria-expanded": characterFontMenuOpen,
@@ -10759,14 +12215,14 @@ ${arabic || currentMessages.empty}`;
10759
12215
  children: characterFontOption(selectedCharacterFont).label
10760
12216
  }
10761
12217
  ),
10762
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "character-font-options", role: "listbox", "aria-label": messages.chooseWritingFont, hidden: !characterFontMenuOpen, children: CHARACTER_FONT_OPTIONS.map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
12218
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "character-font-options", role: "listbox", "aria-label": messages.chooseWritingFont, hidden: !characterFontMenuOpen, children: CHARACTER_FONT_OPTIONS.map((option) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10763
12219
  "button",
10764
12220
  {
10765
12221
  type: "button",
10766
12222
  role: "option",
10767
12223
  "aria-selected": selectedCharacterFont === option.id,
10768
12224
  className: `character-font-option character-font-option--${option.id}`,
10769
- title: characterFontTitle(option.id, messages),
12225
+ title: characterFontTitle2(option.id, messages),
10770
12226
  onMouseDown: (event) => event.preventDefault(),
10771
12227
  onClick: () => {
10772
12228
  runtimeRef.current?.setCurrentCharacterFont(option.id);
@@ -10781,7 +12237,7 @@ ${arabic || currentMessages.empty}`;
10781
12237
  ]
10782
12238
  }
10783
12239
  ),
10784
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
12240
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
10785
12241
  "div",
10786
12242
  {
10787
12243
  className: "digit-form-menu",
@@ -10792,7 +12248,7 @@ ${arabic || currentMessages.empty}`;
10792
12248
  }
10793
12249
  },
10794
12250
  children: [
10795
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
12251
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10796
12252
  "button",
10797
12253
  {
10798
12254
  ref: digitFormBtnRef,
@@ -10807,7 +12263,7 @@ ${arabic || currentMessages.empty}`;
10807
12263
  children: digitFormLabel(selectedDigitForm2)
10808
12264
  }
10809
12265
  ),
10810
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "digit-form-options", role: "listbox", "aria-label": messages.chooseDigitForm, hidden: !digitMenuOpen, children: DIGIT_FORM_OPTIONS.map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
12266
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "digit-form-options", role: "listbox", "aria-label": messages.chooseDigitForm, hidden: !digitMenuOpen, children: DIGIT_FORM_OPTIONS.map((option) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10811
12267
  "button",
10812
12268
  {
10813
12269
  type: "button",
@@ -10831,7 +12287,7 @@ ${arabic || currentMessages.empty}`;
10831
12287
  )
10832
12288
  ] })
10833
12289
  ] }),
10834
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
12290
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10835
12291
  "div",
10836
12292
  {
10837
12293
  ref: surfaceRef,
@@ -10841,7 +12297,7 @@ ${arabic || currentMessages.empty}`;
10841
12297
  "aria-label": messages.equationEditor
10842
12298
  }
10843
12299
  ),
10844
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
12300
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10845
12301
  "textarea",
10846
12302
  {
10847
12303
  ref: inputRef,
@@ -10855,20 +12311,31 @@ ${arabic || currentMessages.empty}`;
10855
12311
  tabIndex: -1
10856
12312
  }
10857
12313
  ),
10858
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: renderErrorRef, className: "error", hidden: true })
12314
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { ref: renderErrorRef, className: "error", hidden: true }),
12315
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
12316
+ "button",
12317
+ {
12318
+ type: "button",
12319
+ className: "butex-widget__mobile-preview-toggle",
12320
+ "aria-controls": previewPanelId,
12321
+ "aria-expanded": compactPreviewOpen,
12322
+ onClick: () => setCompactPreviewOpen((open) => !open),
12323
+ children: compactPreviewOpen ? messages.hidePreview : messages.showPreview
12324
+ }
12325
+ )
10859
12326
  ] }),
10860
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("section", { className: "panel panel-preview", "aria-label": messages.renderPreview, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: mathOutputRef, className: "preview-box" }) }),
10861
- debugEnabled ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "panel", children: [
10862
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dev-strip", children: [
10863
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dev-badge", children: messages.development }),
10864
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: latexLinesRef, className: "ascii" }),
10865
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: passivePreviewRef, className: "passive-preview-text" })
12327
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("section", { id: previewPanelId, className: "panel panel-preview", "aria-label": messages.renderPreview, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { ref: mathOutputRef, className: "preview-box" }) }),
12328
+ debugEnabled ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("section", { className: "panel", children: [
12329
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dev-strip", children: [
12330
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "dev-badge", children: messages.development }),
12331
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { ref: latexLinesRef, className: "ascii" }),
12332
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { ref: passivePreviewRef, className: "passive-preview-text" })
10866
12333
  ] }),
10867
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { marginTop: 12 }, children: [
10868
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "debug-head", children: [
10869
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", onClick: () => void copyDebugText(currentMathObjectJsonText()), children: "Copy MathObject JSON" }),
10870
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", "aria-expanded": debugImportOpen, onClick: openDebugMathObjectImport, children: "Import MathObject JSON" }),
10871
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
12334
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { marginTop: 12 }, children: [
12335
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "debug-head", children: [
12336
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", onClick: () => void copyDebugText(currentMathObjectJsonText()), children: "Copy MathObject JSON" }),
12337
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", "aria-expanded": debugImportOpen, onClick: openDebugMathObjectImport, children: "Import MathObject JSON" }),
12338
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10872
12339
  "button",
10873
12340
  {
10874
12341
  type: "button",
@@ -10888,7 +12355,7 @@ ${arabic || currentMessages.empty}`;
10888
12355
  children: debugBodyHidden ? messages.showDebugLog : messages.hideDebugLog
10889
12356
  }
10890
12357
  ),
10891
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
12358
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10892
12359
  "button",
10893
12360
  {
10894
12361
  type: "button",
@@ -10903,8 +12370,8 @@ ${arabic || currentMessages.empty}`;
10903
12370
  }
10904
12371
  )
10905
12372
  ] }),
10906
- debugImportOpen ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "debug-json-import", children: [
10907
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
12373
+ debugImportOpen ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "debug-json-import", children: [
12374
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10908
12375
  "textarea",
10909
12376
  {
10910
12377
  value: debugImportText,
@@ -10916,9 +12383,9 @@ ${arabic || currentMessages.empty}`;
10916
12383
  }
10917
12384
  }
10918
12385
  ),
10919
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "debug-head", children: [
10920
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", onClick: applyDebugMathObjectImport, children: "Apply" }),
10921
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
12386
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "debug-head", children: [
12387
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", onClick: applyDebugMathObjectImport, children: "Apply" }),
12388
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
10922
12389
  "button",
10923
12390
  {
10924
12391
  type: "button",
@@ -10930,9 +12397,9 @@ ${arabic || currentMessages.empty}`;
10930
12397
  }
10931
12398
  )
10932
12399
  ] }),
10933
- debugImportError ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "debug-json-error", children: debugImportError }) : null
12400
+ debugImportError ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "debug-json-error", children: debugImportError }) : null
10934
12401
  ] }) : null,
10935
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: debugLogRef, className: "debug-log" })
12402
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { ref: debugLogRef, className: "debug-log" })
10936
12403
  ] })
10937
12404
  ] }) : null
10938
12405
  ] })
@@ -11424,15 +12891,15 @@ function injectBuTeXDocumentStyles(doc) {
11424
12891
  }
11425
12892
 
11426
12893
  // src/react-document/ButexDocumentEditor.tsx
11427
- var import_jsx_runtime2 = require("react/jsx-runtime");
11428
- var ButexDocumentPreviewPanel = (0, import_react2.memo)(function ButexDocumentPreviewPanel2({
12894
+ var import_jsx_runtime3 = require("react/jsx-runtime");
12895
+ var ButexDocumentPreviewPanel = (0, import_react5.memo)(function ButexDocumentPreviewPanel2({
11429
12896
  preview,
11430
12897
  previewOpen,
11431
12898
  onPreviewMathError
11432
12899
  }) {
11433
- const previewRef = (0, import_react2.useRef)(null);
11434
- const renderVersionRef = (0, import_react2.useRef)(0);
11435
- (0, import_react2.useLayoutEffect)(() => {
12900
+ const previewRef = (0, import_react5.useRef)(null);
12901
+ const renderVersionRef = (0, import_react5.useRef)(0);
12902
+ (0, import_react5.useLayoutEffect)(() => {
11436
12903
  let cancelled = false;
11437
12904
  let timer = null;
11438
12905
  renderVersionRef.current += 1;
@@ -11553,7 +13020,7 @@ var ButexDocumentPreviewPanel = (0, import_react2.memo)(function ButexDocumentPr
11553
13020
  }
11554
13021
  };
11555
13022
  }, [preview, previewOpen, onPreviewMathError]);
11556
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { ref: previewRef, className: "butex-document-widget__preview" });
13023
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { ref: previewRef, className: "butex-document-widget__preview" });
11557
13024
  });
11558
13025
  var BLOCK_CHOICES = [
11559
13026
  { kind: "section", label: "\u0642\u0633\u0645" },
@@ -11647,21 +13114,21 @@ function ButexDocumentEditor({
11647
13114
  onDocumentChange,
11648
13115
  onLatexChange
11649
13116
  }) {
11650
- const initialState = (0, import_react2.useMemo)(() => resolveInitialDocument(initialDocument), [initialDocument]);
11651
- const [documentNode, setDocumentNode] = (0, import_react2.useState)(initialState.document);
11652
- const [error, setError] = (0, import_react2.useState)(initialState.error);
11653
- const [editorOpen, setEditorOpen] = (0, import_react2.useState)(true);
11654
- const [previewOpen, setPreviewOpen] = (0, import_react2.useState)(true);
11655
- const [devOpen, setDevOpen] = (0, import_react2.useState)(debug);
11656
- const [debugLog, setDebugLog] = (0, import_react2.useState)([]);
11657
- const [selectedMath, setSelectedMath] = (0, import_react2.useState)(null);
11658
- const [previewMathError, setPreviewMathError] = (0, import_react2.useState)(null);
11659
- const [fieldCarets, setFieldCarets] = (0, import_react2.useState)({});
11660
- const latestEquationSessionRef = (0, import_react2.useRef)(null);
11661
- (0, import_react2.useEffect)(() => {
13117
+ const initialState = (0, import_react5.useMemo)(() => resolveInitialDocument(initialDocument), [initialDocument]);
13118
+ const [documentNode, setDocumentNode] = (0, import_react5.useState)(initialState.document);
13119
+ const [error, setError] = (0, import_react5.useState)(initialState.error);
13120
+ const [editorOpen, setEditorOpen] = (0, import_react5.useState)(true);
13121
+ const [previewOpen, setPreviewOpen] = (0, import_react5.useState)(true);
13122
+ const [devOpen, setDevOpen] = (0, import_react5.useState)(debug);
13123
+ const [debugLog, setDebugLog] = (0, import_react5.useState)([]);
13124
+ const [selectedMath, setSelectedMath] = (0, import_react5.useState)(null);
13125
+ const [previewMathError, setPreviewMathError] = (0, import_react5.useState)(null);
13126
+ const [fieldCarets, setFieldCarets] = (0, import_react5.useState)({});
13127
+ const latestEquationSessionRef = (0, import_react5.useRef)(null);
13128
+ (0, import_react5.useEffect)(() => {
11662
13129
  injectBuTeXDocumentStyles();
11663
13130
  }, []);
11664
- (0, import_react2.useEffect)(() => {
13131
+ (0, import_react5.useEffect)(() => {
11665
13132
  const next = resolveInitialDocument(initialDocument);
11666
13133
  setDocumentNode(next.document);
11667
13134
  setError(next.error);
@@ -11669,14 +13136,14 @@ function ButexDocumentEditor({
11669
13136
  setSelectedMath(null);
11670
13137
  }, [initialDocument]);
11671
13138
  const latex = renderDocumentLatex(documentNode);
11672
- const preview = (0, import_react2.useMemo)(() => previewOrEmpty(documentNode), [documentNode]);
11673
- (0, import_react2.useEffect)(() => {
13139
+ const preview = (0, import_react5.useMemo)(() => previewOrEmpty(documentNode), [documentNode]);
13140
+ (0, import_react5.useEffect)(() => {
11674
13141
  onDocumentChange?.(documentNode);
11675
13142
  }, [documentNode, onDocumentChange]);
11676
- (0, import_react2.useEffect)(() => {
13143
+ (0, import_react5.useEffect)(() => {
11677
13144
  onLatexChange?.(latex);
11678
13145
  }, [latex, onLatexChange]);
11679
- (0, import_react2.useEffect)(() => {
13146
+ (0, import_react5.useEffect)(() => {
11680
13147
  if (debug) {
11681
13148
  setDevOpen(true);
11682
13149
  }
@@ -11774,7 +13241,7 @@ function ButexDocumentEditor({
11774
13241
  return inlines.filter((inline) => inline.kind === "math").map((inline) => {
11775
13242
  const current = spanIndex;
11776
13243
  spanIndex += 1;
11777
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
13244
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
11778
13245
  "button",
11779
13246
  {
11780
13247
  type: "button",
@@ -11789,9 +13256,9 @@ function ButexDocumentEditor({
11789
13256
  }
11790
13257
  function renderTextBlock(block, blockIndex) {
11791
13258
  const target = { scope: "block", blockIndex };
11792
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "butex-document-widget__field", children: [
11793
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: textCommandLabel(block.command) }),
11794
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
13259
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("label", { className: "butex-document-widget__field", children: [
13260
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: textCommandLabel(block.command) }),
13261
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
11795
13262
  "textarea",
11796
13263
  {
11797
13264
  value: block.value,
@@ -11801,17 +13268,17 @@ function ButexDocumentEditor({
11801
13268
  onChange: (event) => updateDocument(updateTextBlockValue(documentNode, blockIndex, event.currentTarget.value), "updateTextBlock")
11802
13269
  }
11803
13270
  ),
11804
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "butex-document-widget__row-actions", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", onClick: () => openNewMath(target, block.value.length), children: "\u0625\u062F\u0631\u0627\u062C \u0645\u0639\u0627\u062F\u0644\u0629" }) }),
11805
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "butex-document-widget__chips", children: renderMathChips(block.inlines, (spanIndex) => ({ scope: "block", blockIndex, spanIndex })) })
13271
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "butex-document-widget__row-actions", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", onClick: () => openNewMath(target, block.value.length), children: "\u0625\u062F\u0631\u0627\u062C \u0645\u0639\u0627\u062F\u0644\u0629" }) }),
13272
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "butex-document-widget__chips", children: renderMathChips(block.inlines, (spanIndex) => ({ scope: "block", blockIndex, spanIndex })) })
11806
13273
  ] });
11807
13274
  }
11808
13275
  function renderListBlock(block, blockIndex) {
11809
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "butex-document-widget__list-editor", children: [
11810
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "butex-document-widget__row-actions", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", onClick: () => updateDocument(addListItem(documentNode, blockIndex), "addListItem"), children: "\u0625\u0636\u0627\u0641\u0629 \u0639\u0646\u0635\u0631" }) }),
11811
- block.items.map((item, itemIndex) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "butex-document-widget__list-item", children: [
11812
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "butex-document-widget__field", children: [
11813
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: block.command === "\\begin{enumerate}" ? `\u0639\u0646\u0635\u0631 ${String(itemIndex + 1)}` : "\u0639\u0646\u0635\u0631" }),
11814
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
13276
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "butex-document-widget__list-editor", children: [
13277
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "butex-document-widget__row-actions", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", onClick: () => updateDocument(addListItem(documentNode, blockIndex), "addListItem"), children: "\u0625\u0636\u0627\u0641\u0629 \u0639\u0646\u0635\u0631" }) }),
13278
+ block.items.map((item, itemIndex) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "butex-document-widget__list-item", children: [
13279
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("label", { className: "butex-document-widget__field", children: [
13280
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: block.command === "\\begin{enumerate}" ? `\u0639\u0646\u0635\u0631 ${String(itemIndex + 1)}` : "\u0639\u0646\u0635\u0631" }),
13281
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
11815
13282
  "textarea",
11816
13283
  {
11817
13284
  value: item.value,
@@ -11821,7 +13288,7 @@ function ButexDocumentEditor({
11821
13288
  onChange: (event) => updateDocument(updateListItemValue(documentNode, blockIndex, itemIndex, event.currentTarget.value), "updateListItem")
11822
13289
  }
11823
13290
  ),
11824
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "butex-document-widget__row-actions", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
13291
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "butex-document-widget__row-actions", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
11825
13292
  "button",
11826
13293
  {
11827
13294
  type: "button",
@@ -11829,22 +13296,22 @@ function ButexDocumentEditor({
11829
13296
  children: "\u0625\u062F\u0631\u0627\u062C \u0645\u0639\u0627\u062F\u0644\u0629"
11830
13297
  }
11831
13298
  ) }),
11832
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "butex-document-widget__chips", children: renderMathChips(item.inlines, (spanIndex) => ({ scope: "listItem", blockIndex, itemIndex, spanIndex })) })
13299
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "butex-document-widget__chips", children: renderMathChips(item.inlines, (spanIndex) => ({ scope: "listItem", blockIndex, itemIndex, spanIndex })) })
11833
13300
  ] }),
11834
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "butex-document-widget__row-actions", children: [
11835
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", onClick: () => updateDocument(removeListItem(documentNode, blockIndex, itemIndex), "removeListItem"), children: "\u062D\u0630\u0641 \u0627\u0644\u0639\u0646\u0635\u0631" }),
11836
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", onClick: () => updateDocument(addNestedListBlock(documentNode, blockIndex, itemIndex, "itemize"), "addNestedList"), children: "\u0642\u0627\u0626\u0645\u0629 \u0641\u0631\u0639\u064A\u0629" }),
11837
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", onClick: () => updateDocument(addNestedListBlock(documentNode, blockIndex, itemIndex, "enumerate"), "addNestedEnumerate"), children: "\u062A\u0631\u0642\u064A\u0645 \u0641\u0631\u0639\u064A" })
13301
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "butex-document-widget__row-actions", children: [
13302
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", onClick: () => updateDocument(removeListItem(documentNode, blockIndex, itemIndex), "removeListItem"), children: "\u062D\u0630\u0641 \u0627\u0644\u0639\u0646\u0635\u0631" }),
13303
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", onClick: () => updateDocument(addNestedListBlock(documentNode, blockIndex, itemIndex, "itemize"), "addNestedList"), children: "\u0642\u0627\u0626\u0645\u0629 \u0641\u0631\u0639\u064A\u0629" }),
13304
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", onClick: () => updateDocument(addNestedListBlock(documentNode, blockIndex, itemIndex, "enumerate"), "addNestedEnumerate"), children: "\u062A\u0631\u0642\u064A\u0645 \u0641\u0631\u0639\u064A" })
11838
13305
  ] }),
11839
- item.blocks.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "butex-document-widget__nested", children: item.blocks.map((child, childIndex) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("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
13306
+ item.blocks.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "butex-document-widget__nested", children: item.blocks.map((child, childIndex) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("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
11840
13307
  ] }, itemIndex))
11841
13308
  ] });
11842
13309
  }
11843
13310
  function renderTableBlock(block, blockIndex) {
11844
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "butex-document-widget__table-editor", children: [
11845
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "butex-document-widget__field butex-document-widget__field--short", children: [
11846
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u0627\u0644\u0623\u0639\u0645\u062F\u0629" }),
11847
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
13311
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "butex-document-widget__table-editor", children: [
13312
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("label", { className: "butex-document-widget__field butex-document-widget__field--short", children: [
13313
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "\u0627\u0644\u0623\u0639\u0645\u062F\u0629" }),
13314
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
11848
13315
  "input",
11849
13316
  {
11850
13317
  value: block.columns,
@@ -11852,14 +13319,14 @@ function ButexDocumentEditor({
11852
13319
  }
11853
13320
  )
11854
13321
  ] }),
11855
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "butex-document-widget__row-actions", children: [
11856
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", onClick: () => updateDocument(addTableRow(documentNode, blockIndex), "addTableRow"), children: "\u0625\u0636\u0627\u0641\u0629 \u0635\u0641" }),
11857
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", onClick: () => updateDocument(removeTableRow(documentNode, blockIndex), "removeTableRow"), children: "\u062D\u0630\u0641 \u0635\u0641" }),
11858
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", onClick: () => updateDocument(addTableColumn(documentNode, blockIndex), "addTableColumn"), children: "\u0625\u0636\u0627\u0641\u0629 \u0639\u0645\u0648\u062F" }),
11859
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", onClick: () => updateDocument(removeTableColumn(documentNode, blockIndex), "removeTableColumn"), children: "\u062D\u0630\u0641 \u0639\u0645\u0648\u062F" })
13322
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "butex-document-widget__row-actions", children: [
13323
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", onClick: () => updateDocument(addTableRow(documentNode, blockIndex), "addTableRow"), children: "\u0625\u0636\u0627\u0641\u0629 \u0635\u0641" }),
13324
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", onClick: () => updateDocument(removeTableRow(documentNode, blockIndex), "removeTableRow"), children: "\u062D\u0630\u0641 \u0635\u0641" }),
13325
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", onClick: () => updateDocument(addTableColumn(documentNode, blockIndex), "addTableColumn"), children: "\u0625\u0636\u0627\u0641\u0629 \u0639\u0645\u0648\u062F" }),
13326
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", onClick: () => updateDocument(removeTableColumn(documentNode, blockIndex), "removeTableColumn"), children: "\u062D\u0630\u0641 \u0639\u0645\u0648\u062F" })
11860
13327
  ] }),
11861
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "butex-document-widget__table-grid", children: block.rows.map((row, rowIndex) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "butex-document-widget__table-row", children: row.map((cell, columnIndex) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "butex-document-widget__table-cell", children: [
11862
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
13328
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "butex-document-widget__table-grid", children: block.rows.map((row, rowIndex) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "butex-document-widget__table-row", children: row.map((cell, columnIndex) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("label", { className: "butex-document-widget__table-cell", children: [
13329
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
11863
13330
  "input",
11864
13331
  {
11865
13332
  value: textFromInlines(cell),
@@ -11869,7 +13336,7 @@ function ButexDocumentEditor({
11869
13336
  onChange: (event) => updateDocument(updateTableCell(documentNode, blockIndex, rowIndex, columnIndex, event.currentTarget.value), "updateTableCell")
11870
13337
  }
11871
13338
  ),
11872
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "butex-document-widget__row-actions", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
13339
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "butex-document-widget__row-actions", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
11873
13340
  "button",
11874
13341
  {
11875
13342
  type: "button",
@@ -11880,15 +13347,15 @@ function ButexDocumentEditor({
11880
13347
  children: "\u0625\u062F\u0631\u0627\u062C \u0645\u0639\u0627\u062F\u0644\u0629"
11881
13348
  }
11882
13349
  ) }),
11883
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "butex-document-widget__chips", children: renderMathChips(cell, (spanIndex) => ({ scope: "tableCell", blockIndex, rowIndex, columnIndex, spanIndex })) })
13350
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "butex-document-widget__chips", children: renderMathChips(cell, (spanIndex) => ({ scope: "tableCell", blockIndex, rowIndex, columnIndex, spanIndex })) })
11884
13351
  ] }, `${rowIndex}-${columnIndex}`)) }, rowIndex)) })
11885
13352
  ] });
11886
13353
  }
11887
13354
  function renderImageBlock(block, blockIndex) {
11888
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "butex-document-widget__image-editor", children: [
11889
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "butex-document-widget__field", children: [
11890
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u0645\u0633\u0627\u0631 \u0627\u0644\u0635\u0648\u0631\u0629" }),
11891
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
13355
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "butex-document-widget__image-editor", children: [
13356
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("label", { className: "butex-document-widget__field", children: [
13357
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "\u0645\u0633\u0627\u0631 \u0627\u0644\u0635\u0648\u0631\u0629" }),
13358
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
11892
13359
  "input",
11893
13360
  {
11894
13361
  value: block.value,
@@ -11896,9 +13363,9 @@ function ButexDocumentEditor({
11896
13363
  }
11897
13364
  )
11898
13365
  ] }),
11899
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "butex-document-widget__field", children: [
11900
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u0627\u0644\u062E\u064A\u0627\u0631\u0627\u062A" }),
11901
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
13366
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("label", { className: "butex-document-widget__field", children: [
13367
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "\u0627\u0644\u062E\u064A\u0627\u0631\u0627\u062A" }),
13368
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
11902
13369
  "input",
11903
13370
  {
11904
13371
  value: optionsToText(block.options),
@@ -11921,9 +13388,9 @@ function ButexDocumentEditor({
11921
13388
  if (block.kind === "image") {
11922
13389
  return renderImageBlock(block, blockIndex);
11923
13390
  }
11924
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "butex-document-widget__field", children: [
11925
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "\u062E\u0627\u0645" }),
11926
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
13391
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("label", { className: "butex-document-widget__field", children: [
13392
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "\u062E\u0627\u0645" }),
13393
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
11927
13394
  "textarea",
11928
13395
  {
11929
13396
  value: block.value,
@@ -11932,30 +13399,30 @@ function ButexDocumentEditor({
11932
13399
  )
11933
13400
  ] });
11934
13401
  }
11935
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: `butex-document-widget ${className ?? ""}`.trim(), dir: "rtl", lang: "ar", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "butex-document-widget__shell", children: [
11936
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "butex-document-widget__toolbar", role: "toolbar", "aria-label": "\u0623\u062F\u0648\u0627\u062A \u0627\u0644\u0645\u0633\u062A\u0646\u062F", children: [
11937
- BLOCK_CHOICES.map((choice) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", onClick: () => updateDocument(addDocumentBlock(documentNode, choice.kind), `addBlock:${choice.kind}`), children: choice.label }, choice.kind)),
11938
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("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" }),
11939
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("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" }),
11940
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("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" })
13402
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: `butex-document-widget ${className ?? ""}`.trim(), dir: "rtl", lang: "ar", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "butex-document-widget__shell", children: [
13403
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "butex-document-widget__toolbar", role: "toolbar", "aria-label": "\u0623\u062F\u0648\u0627\u062A \u0627\u0644\u0645\u0633\u062A\u0646\u062F", children: [
13404
+ BLOCK_CHOICES.map((choice) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", onClick: () => updateDocument(addDocumentBlock(documentNode, choice.kind), `addBlock:${choice.kind}`), children: choice.label }, choice.kind)),
13405
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("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" }),
13406
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("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" }),
13407
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("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" })
11941
13408
  ] }),
11942
- error ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "butex-document-widget__error", children: error }) : null,
11943
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: `butex-document-widget__layout butex-document-widget__layout--editor-${editorOpen ? "open" : "closed"} butex-document-widget__layout--preview-${previewOpen ? "open" : "closed"}`, children: [
11944
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
13409
+ error ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "butex-document-widget__error", children: error }) : null,
13410
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: `butex-document-widget__layout butex-document-widget__layout--editor-${editorOpen ? "open" : "closed"} butex-document-widget__layout--preview-${previewOpen ? "open" : "closed"}`, children: [
13411
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
11945
13412
  "section",
11946
13413
  {
11947
13414
  className: "butex-document-widget__panel butex-document-widget__editor-panel",
11948
13415
  "aria-label": "\u062A\u062D\u0631\u064A\u0631 \u0627\u0644\u0645\u0633\u062A\u0646\u062F",
11949
13416
  "aria-hidden": !editorOpen,
11950
13417
  children: [
11951
- documentNode.blocks.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "butex-document-widget__placeholder", children: "\u0623\u0636\u0641 \u0628\u0646\u064A\u0629 \u0644\u0644\u0628\u062F\u0621" }) : null,
11952
- documentNode.blocks.map((block, blockIndex) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("article", { className: "butex-document-widget__block", children: [
11953
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "butex-document-widget__block-head", children: [
11954
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("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" }),
11955
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "butex-document-widget__row-actions", children: [
11956
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", onClick: () => updateDocument(moveDocumentBlock(documentNode, blockIndex, -1), "moveBlockUp"), children: "\u2191" }),
11957
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", onClick: () => updateDocument(moveDocumentBlock(documentNode, blockIndex, 1), "moveBlockDown"), children: "\u2193" }),
11958
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", onClick: () => updateDocument(removeDocumentBlock(documentNode, blockIndex), "removeBlock"), children: "\u062D\u0630\u0641" })
13418
+ documentNode.blocks.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "butex-document-widget__placeholder", children: "\u0623\u0636\u0641 \u0628\u0646\u064A\u0629 \u0644\u0644\u0628\u062F\u0621" }) : null,
13419
+ documentNode.blocks.map((block, blockIndex) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("article", { className: "butex-document-widget__block", children: [
13420
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "butex-document-widget__block-head", children: [
13421
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("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" }),
13422
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "butex-document-widget__row-actions", children: [
13423
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", onClick: () => updateDocument(moveDocumentBlock(documentNode, blockIndex, -1), "moveBlockUp"), children: "\u2191" }),
13424
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", onClick: () => updateDocument(moveDocumentBlock(documentNode, blockIndex, 1), "moveBlockDown"), children: "\u2193" }),
13425
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", onClick: () => updateDocument(removeDocumentBlock(documentNode, blockIndex), "removeBlock"), children: "\u062D\u0630\u0641" })
11959
13426
  ] })
11960
13427
  ] }),
11961
13428
  renderBlockBody(block, blockIndex)
@@ -11963,44 +13430,44 @@ function ButexDocumentEditor({
11963
13430
  ]
11964
13431
  }
11965
13432
  ),
11966
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
13433
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
11967
13434
  "section",
11968
13435
  {
11969
13436
  className: "butex-document-widget__panel butex-document-widget__preview-panel",
11970
13437
  "aria-label": "\u0645\u0639\u0627\u064A\u0646\u0629 \u0627\u0644\u0645\u0633\u062A\u0646\u062F",
11971
13438
  "aria-hidden": !previewOpen,
11972
13439
  children: [
11973
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ButexDocumentPreviewPanel, { preview, previewOpen, onPreviewMathError: setPreviewMathError }),
11974
- previewMathError ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "butex-document-widget__preview-error", children: previewMathError }) : null
13440
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ButexDocumentPreviewPanel, { preview, previewOpen, onPreviewMathError: setPreviewMathError }),
13441
+ previewMathError ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "butex-document-widget__preview-error", children: previewMathError }) : null
11975
13442
  ]
11976
13443
  }
11977
13444
  )
11978
13445
  ] }),
11979
- devOpen ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("section", { className: "butex-document-widget__dev", "aria-label": "\u0644\u0648\u062D\u0629 \u0627\u0644\u062A\u0637\u0648\u064A\u0631", children: [
11980
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
11981
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: "LaTeX" }),
11982
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("pre", { children: latex })
13446
+ devOpen ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("section", { className: "butex-document-widget__dev", "aria-label": "\u0644\u0648\u062D\u0629 \u0627\u0644\u062A\u0637\u0648\u064A\u0631", children: [
13447
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { children: [
13448
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("strong", { children: "LaTeX" }),
13449
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("pre", { children: latex })
11983
13450
  ] }),
11984
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
11985
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: "HTML" }),
11986
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("pre", { children: preview.html })
13451
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { children: [
13452
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("strong", { children: "HTML" }),
13453
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("pre", { children: preview.html })
11987
13454
  ] }),
11988
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
11989
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: "AST" }),
11990
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("pre", { children: JSON.stringify(documentNode, null, 2) })
13455
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { children: [
13456
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("strong", { children: "AST" }),
13457
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("pre", { children: JSON.stringify(documentNode, null, 2) })
11991
13458
  ] }),
11992
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
11993
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: "\u0627\u0644\u0633\u062C\u0644" }),
11994
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("pre", { children: debugLog.join("\n") })
13459
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { children: [
13460
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("strong", { children: "\u0627\u0644\u0633\u062C\u0644" }),
13461
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("pre", { children: debugLog.join("\n") })
11995
13462
  ] })
11996
13463
  ] }) : null,
11997
- selectedMath ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("aside", { className: "butex-document-widget__drawer", "aria-label": "\u062A\u062D\u0631\u064A\u0631 \u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629", children: [
11998
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "butex-document-widget__drawer-head", children: [
11999
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: "\u062A\u062D\u0631\u064A\u0631 \u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629" }),
12000
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", onClick: () => setSelectedMath(null), children: "\u0625\u063A\u0644\u0627\u0642" })
13464
+ selectedMath ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("aside", { className: "butex-document-widget__drawer", "aria-label": "\u062A\u062D\u0631\u064A\u0631 \u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629", children: [
13465
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "butex-document-widget__drawer-head", children: [
13466
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("strong", { children: "\u062A\u062D\u0631\u064A\u0631 \u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629" }),
13467
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", onClick: () => setSelectedMath(null), children: "\u0625\u063A\u0644\u0627\u0642" })
12001
13468
  ] }),
12002
- selectedMath.reason || !selectedMath.session ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("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__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
12003
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
13469
+ selectedMath.reason || !selectedMath.session ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("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__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
13470
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
12004
13471
  ButexEditor,
12005
13472
  {
12006
13473
  initialSession: selectedMath.session,
@@ -12010,7 +13477,7 @@ function ButexDocumentEditor({
12010
13477
  },
12011
13478
  selectedMath.kind === "edit" ? selectedMath.inline.source : `insert-${targetKey(selectedMath.target)}-${String(selectedMath.insertAt)}`
12012
13479
  ),
12013
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "butex-document-widget__row-actions", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", onClick: saveSelectedMath, children: "\u062D\u0641\u0638 \u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629" }) })
13480
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "butex-document-widget__row-actions", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", onClick: saveSelectedMath, children: "\u062D\u0641\u0638 \u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629" }) })
12014
13481
  ] })
12015
13482
  ] }) : null
12016
13483
  ] }) });