ryugi-artifacts 1.108.6 → 1.108.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/dist/cli.cjs +8 -8
  2. package/dist/document-engine.cjs +1 -1
  3. package/dist/runtime/Figtree-OFL.txt +93 -0
  4. package/dist/runtime/ryugi-mockup.js +270 -2
  5. package/dist/runtime/ryugi-preview-bridge.js +2 -2
  6. package/dist/runtime/ryugi-ui.js +1 -1
  7. package/dist/server.cjs +93 -93
  8. package/dist/viewer/{AgentDock-BMyCZfOA.js → AgentDock-fdzdI0YU.js} +1 -1
  9. package/dist/viewer/{ArtboardLayout-Ca63S-ht.js → ArtboardLayout-CyP7z5iV.js} +1 -1
  10. package/dist/viewer/{ArtifactList-CyHqaLMU.js → ArtifactList-D1Cv2wcz.js} +1 -1
  11. package/dist/viewer/{ArtifactModal-CNcJ9SwG.js → ArtifactModal-BRPuHjh3.js} +1 -1
  12. package/dist/viewer/{BottomSheet-CPpAPNxv.js → BottomSheet-DksTxPPS.js} +1 -1
  13. package/dist/viewer/{Canvas-CZAIguUl.js → Canvas-DA9wKktu.js} +1 -1
  14. package/dist/viewer/{CommentPopover-SiWZ0XbH.js → CommentPopover-Bz3qXsBS.js} +1 -1
  15. package/dist/viewer/{DocumentExportMenu-D3KMkrvj.js → DocumentExportMenu-Cb03PJdE.js} +1 -1
  16. package/dist/viewer/DocumentLayout-16zcY3cg.js +2 -0
  17. package/dist/viewer/DocumentPage-B__O7sY3.js +3 -0
  18. package/dist/viewer/{DraggablePanel-GsMby8P2.js → DraggablePanel-BlNQ_JOj.js} +1 -1
  19. package/dist/viewer/{DropdownMenu-BXvqn_bX.js → DropdownMenu-DhVZ3e22.js} +1 -1
  20. package/dist/viewer/Figtree-OFL.txt +93 -0
  21. package/dist/viewer/{GroupVerdict-DWVpUZS_.js → GroupVerdict-DkOR7Neo.js} +1 -1
  22. package/dist/viewer/{HtmlLayout-DlU3MyPC.js → HtmlLayout-BQS68lEe.js} +1 -1
  23. package/dist/viewer/{Input-vV0jo5B6.js → Input-YumXWTse.js} +1 -1
  24. package/dist/viewer/{MenuSubmenuTrigger-BaYw4HuY.js → MenuSubmenuTrigger-DZ2Nb6Hm.js} +1 -1
  25. package/dist/viewer/{PhoneArtboardBar-DWHrTBZF.js → PhoneArtboardBar-CZKL18gK.js} +1 -1
  26. package/dist/viewer/{Popover-BRvZS1gZ.js → Popover-i0m3nwq7.js} +1 -1
  27. package/dist/viewer/{PreviewArtifactLayout-neL_d_3n.js → PreviewArtifactLayout-B4SZfLvw.js} +1 -1
  28. package/dist/viewer/PreviewLayout-DiIQthoy.js +2 -0
  29. package/dist/viewer/{ReportLayout-BLVLfLGU.js → ReportLayout-DPnqWYPZ.js} +1 -1
  30. package/dist/viewer/{RyugiMark-d0ZfdfP2.js → RyugiMark-Ch2tF00h.js} +1 -1
  31. package/dist/viewer/{Segmented-BIBgIkNi.js → Segmented-BV_iofkK.js} +1 -1
  32. package/dist/viewer/{SelectScrollUpArrow-DNQWHWMc.js → SelectScrollUpArrow-BNSyHMPX.js} +1 -1
  33. package/dist/viewer/{SlidesLayout-MGWpipwc.js → SlidesLayout-CSeSindR.js} +3 -3
  34. package/dist/viewer/{SnapshotDocument-DX9wLXWv.js → SnapshotDocument-TIzAsI0l.js} +1 -1
  35. package/dist/viewer/{SplitFrame-CiqjUPs6.js → SplitFrame-C3Mr0Ehv.js} +1 -1
  36. package/dist/viewer/{StoryboardLayout-BkntJIHV.js → StoryboardLayout-DZVJbnzc.js} +1 -1
  37. package/dist/viewer/{StoryboardRender-BniWnBGv.js → StoryboardRender-DORxY44d.js} +1 -1
  38. package/dist/viewer/{ThreadView-WZruOpTE.js → ThreadView-CbKzFwUf.js} +1 -1
  39. package/dist/viewer/{Tooltip-DKnMl1yQ.js → Tooltip-81DgA1Zr.js} +1 -1
  40. package/dist/viewer/{VerifyLayout-Bjh7Ddzn.js → VerifyLayout--deiRi4o.js} +1 -1
  41. package/dist/viewer/{VirtualizedEditor-uWe43zaI-DIyWJhFX.js → VirtualizedEditor-uWe43zaI-1EQ0fdB8.js} +1 -1
  42. package/dist/viewer/{VirtualizedRenderer-C_d95FXi-BkojOMeR.js → VirtualizedRenderer-C_d95FXi-CixG8E4F.js} +1 -1
  43. package/dist/viewer/{WarningsBadge-B0H-6XNv.js → WarningsBadge-fEXkyk3t.js} +1 -1
  44. package/dist/viewer/{WhiteboardEditor-cZ32fLqJ-DfASNG0e.js → WhiteboardEditor-cZ32fLqJ-BRt-wSEn.js} +2 -2
  45. package/dist/viewer/WhiteboardLayout-qGm-CExy.js +4 -0
  46. package/dist/viewer/{WritingCursor-B1KstzsM.js → WritingCursor-OdCSWg_M.js} +1 -1
  47. package/dist/viewer/{agentLook-DAbDap_r.js → agentLook-EhrjbD1n.js} +1 -1
  48. package/dist/viewer/{artifact-list-Dk7B04aS.js → artifact-list-D22lTyyh.js} +1 -1
  49. package/dist/viewer/{auto-publish-D0gnAgNH.js → auto-publish-BXmqx8BX.js} +1 -1
  50. package/dist/viewer/{channel-W8z1JRUp.js → channel-CaUFZV2H.js} +3 -3
  51. package/dist/viewer/{crop-encode-jcaJuFwz.js → crop-encode-Udgh8S7r.js} +1 -1
  52. package/dist/viewer/{dist-8GuhHKSd.js → dist-0JlH-iFk.js} +1 -1
  53. package/dist/viewer/{dist-DKWGY7vW.js → dist-B-RrlmaY.js} +1 -1
  54. package/dist/viewer/{dist-e32bsEFO.js → dist-BMJWStKC.js} +1 -1
  55. package/dist/viewer/{dist-hskNTNrk.js → dist-BNiHzkc8.js} +1 -1
  56. package/dist/viewer/{dist-D5w5f0nx.js → dist-C0Fbwkds.js} +1 -1
  57. package/dist/viewer/{dist-DdWP5O5Z.js → dist-C4fPBi1f.js} +1 -1
  58. package/dist/viewer/{dist-BLDdWa7l.js → dist-C81vCo2L.js} +1 -1
  59. package/dist/viewer/dist-CY11yEtD.js +1 -0
  60. package/dist/viewer/{dist-DzgE9d65.js → dist-CjVeWopx.js} +1 -1
  61. package/dist/viewer/{dist-BKKpgaMc.js → dist-CuWYFfBf.js} +1 -1
  62. package/dist/viewer/{dist-CilrySXL.js → dist-DBnvEq5g.js} +1 -1
  63. package/dist/viewer/{dist-IX2iT14j.js → dist-DD00JDtU.js} +1 -1
  64. package/dist/viewer/{dist-B6IVYls_.js → dist-DKWARfq1.js} +1 -1
  65. package/dist/viewer/{dist-BTzyPMeC.js → dist-DRUJxMS6.js} +1 -1
  66. package/dist/viewer/{dist-C6DCB_Rj.js → dist-DRmbQ1f0.js} +1 -1
  67. package/dist/viewer/{dist-EFdcYRKe.js → dist-DurHsNXj.js} +1 -1
  68. package/dist/viewer/{dist-DE-DH2i7.js → dist-DzmIJXNR.js} +1 -1
  69. package/dist/viewer/{dist-CqeeTfim.js → dist-G4Vj4mFX.js} +1 -1
  70. package/dist/viewer/{dist-DNO7AZoy.js → dist-R6N8uqUg.js} +1 -1
  71. package/dist/viewer/{dist-BC8nvFq2.js → dist-i-_vhfnL.js} +1 -1
  72. package/dist/viewer/{dist-Bpgppm6o.js → dist-kzNj8Wks.js} +1 -1
  73. package/dist/viewer/{dist-B2aqeAk-.js → dist-o-mpdm3Q.js} +1 -1
  74. package/dist/viewer/{dist-w08ese3i.js → dist-rs8SY6NP.js} +1 -1
  75. package/dist/viewer/{dist-BhE_JiAo.js → dist-vjczWTJX.js} +1 -1
  76. package/dist/viewer/{editor-IGV7cqIf.js → editor-BabkJ7hH.js} +6 -6
  77. package/dist/viewer/figtree-latin-ext-wght-normal-DCwSJGxG.woff2 +0 -0
  78. package/dist/viewer/figtree-latin-wght-normal-D_ZTVpCC.woff2 +0 -0
  79. package/dist/viewer/{fit-CwTJJcvD.js → fit-BJ0VxRML.js} +1 -1
  80. package/dist/viewer/{icons-Dwk8RW6i.js → icons-8mizjIXE.js} +1 -1
  81. package/dist/viewer/{imperative-9zI7cd1I.js → imperative-iclc26pT.js} +1 -1
  82. package/dist/viewer/index.css +1 -1
  83. package/dist/viewer/index.html +12 -12
  84. package/dist/viewer/index.js +2 -2
  85. package/dist/viewer/index2.css +1 -1
  86. package/dist/viewer/{local-BIV9Bn_B.js → local-DzHVL3fo.js} +1 -1
  87. package/dist/viewer/{local-split-host-DJJKo1Vj.js → local-split-host-DaeACaX5.js} +1 -1
  88. package/dist/viewer/plugin-_bGVeqI0-BkU-g6bb.js +2 -0
  89. package/dist/viewer/preview.html +3 -3
  90. package/dist/viewer/preview.js +1 -1
  91. package/dist/viewer/{printDocument-BbvYpCaV.js → printDocument-Bh1qUAf9.js} +1 -1
  92. package/dist/viewer/{ref-DcFpXWwa.js → ref-JbqCEGXp.js} +1 -1
  93. package/dist/viewer/{route-CAQRGuux.js → route-DdpUUY_w.js} +5 -5
  94. package/dist/viewer/{route-messages-AShIvXR0.js → route-messages-BMv2jmvl.js} +1 -1
  95. package/dist/viewer/{settings-CxJUVRn8.js → settings-wKTRexHi.js} +1 -1
  96. package/dist/viewer/{snap-Bp7A7-zR.js → snap-1DJNMR4r.js} +1 -1
  97. package/dist/viewer/{split-CeIplvJa.js → split-BJA_5Rtf.js} +2 -2
  98. package/dist/viewer/{stable-DVc3NRmV.js → stable-CZy_447C.js} +1 -1
  99. package/dist/viewer/{styles-BBTLo6nS.js → styles-BHI9FTnz.js} +1 -1
  100. package/dist/viewer/{transport-CazJfalj.js → transport-Djlo7-HU.js} +1 -1
  101. package/dist/viewer/{url-BS6kqcve.js → url-B_fuREEU.js} +1 -1
  102. package/dist/viewer/{useArtifactFeed-CymUjnz1.js → useArtifactFeed-B9RfhN8_.js} +1 -1
  103. package/dist/viewer/{useArtifactSocket-BOU81P_2.js → useArtifactSocket-ns9zjgVa.js} +1 -1
  104. package/dist/viewer/{useLayerZIndex-D5QVXpVc.js → useLayerZIndex-VAxAVO-V.js} +1 -1
  105. package/dist/viewer/{useStoryboardData-BbPOAS-Z.js → useStoryboardData-DCPDhUMO.js} +1 -1
  106. package/dist/viewer/{view-BatCe1Ci.js → view-DLrABahQ.js} +1 -1
  107. package/dist/viewer/{viewport-CFJHn_Y6-DuJwG-4n.js → viewport-CFJHn_Y6-B0Ka3uWP.js} +1 -1
  108. package/package.json +1 -1
  109. package/dist/viewer/DocumentLayout-Vo9s9zeJ.js +0 -2
  110. package/dist/viewer/DocumentPage-CIvaYNgp.js +0 -3
  111. package/dist/viewer/Goeist-DFcbbrZE.woff2 +0 -0
  112. package/dist/viewer/PreviewLayout-BuviWNGi.js +0 -2
  113. package/dist/viewer/WhiteboardLayout-CwmEBIBu.js +0 -4
  114. package/dist/viewer/dist-Cg7E0M7K.js +0 -1
  115. package/dist/viewer/plugin-_bGVeqI0-_v5JtKHd.js +0 -2
@@ -925,4 +925,4 @@ l0,-`+(t+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
925
925
  ?)[ \r ]*`,V9=`[̀-ͯ]`,Fpt=RegExp(V9+`+$`),Ipt=`(`+Apt+`+)|`+(Ppt+`|`)+`([!-\\[\\]-‧‪-퟿豈-￿]`+(V9+`*`)+`|[\ud800-\udbff][\udc00-\udfff]`+(V9+`*`)+`|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5`+(`|`+Npt)+(`|`+Mpt+`)`),Lpt=class{constructor(e,t){this.input=void 0,this.settings=void 0,this.tokenRegex=void 0,this.catcodes=void 0,this.input=e,this.settings=t,this.tokenRegex=new RegExp(Ipt,`g`),this.catcodes={"%":14,"~":13}}setCatcode(e,t){this.catcodes[e]=t}lex(){var e=this.input,t=this.tokenRegex.lastIndex;if(t===e.length)return new j9(`EOF`,new A9(this,t,t));var n=this.tokenRegex.exec(e);if(n===null||n.index!==t)throw new l5(`Unexpected character: '`+e[t]+`'`,new j9(e[t],new A9(this,t,t+1)));var r=n[6]||n[3]||(n[2]?`\\ `:` `);if(this.catcodes[r]===14){var i=e.indexOf(`
926
926
  `,this.tokenRegex.lastIndex);return i===-1?(this.tokenRegex.lastIndex=e.length,x7({strict:this.settings.strict,errorCode:`commentAtEnd`,errorMsg:`% comment has no terminating newline; LaTeX would fail because of commenting the end of math mode (e.g. $)`,report:!0})):this.tokenRegex.lastIndex=i+1,this.lex()}return new j9(r,new A9(this,t,this.tokenRegex.lastIndex))}},Rpt=class{constructor(e,t){e===void 0&&(e={}),t===void 0&&(t={}),this.current=void 0,this.builtins=void 0,this.undefStack=void 0,this.current=t,this.builtins=e,this.undefStack=[]}beginGroup(){this.undefStack.push({})}endGroup(){if(this.undefStack.length===0)throw new l5(`Unbalanced namespace destruction: attempt to pop global namespace; please report this as a bug`);var e=this.undefStack.pop();for(var t of Object.keys(e))e[t]===void 0?delete this.current[t]:this.current[t]=e[t]}endGroups(){for(;this.undefStack.length>0;)this.endGroup()}has(e){return Object.prototype.hasOwnProperty.call(this.current,e)||Object.prototype.hasOwnProperty.call(this.builtins,e)}get(e){if(Object.prototype.hasOwnProperty.call(this.current,e))return this.current[e];if(Object.prototype.hasOwnProperty.call(this.builtins,e))return this.builtins[e]}set(e,t,n){if(n===void 0&&(n=!1),n){for(var r=0;r<this.undefStack.length;r++)delete this.undefStack[r][e];this.undefStack.length>0&&(this.undefStack[this.undefStack.length-1][e]=t)}else{var i=this.undefStack[this.undefStack.length-1];i&&!Object.prototype.hasOwnProperty.call(i,e)&&(i[e]=Object.prototype.hasOwnProperty.call(this.current,e)?this.current[e]:void 0)}t==null?delete this.current[e]:this.current[e]=t}},zpt=qft;$(`\\noexpand`,function(e){var t=e.popToken();return e.isExpandable(t.text)&&(t.noexpand=!0,t.treatAsRelax=!0),{tokens:[t],numArgs:0}}),$(`\\expandafter`,function(e){var t=e.popToken();return e.expandOnce(!0),{tokens:[t],numArgs:0}}),$(`\\@firstoftwo`,function(e){return{tokens:e.consumeArgs(2)[0],numArgs:0}}),$(`\\@secondoftwo`,function(e){return{tokens:e.consumeArgs(2)[1],numArgs:0}}),$(`\\@ifnextchar`,function(e){var t=e.consumeArgs(3);e.consumeSpaces();var n=e.future();return t[0].length===1&&t[0][0].text===n.text?{tokens:t[1],numArgs:0}:{tokens:t[2],numArgs:0}}),$(`\\@ifstar`,`\\@ifnextchar *{\\@firstoftwo{#1}}`),$(`\\TextOrMath`,function(e){var t=e.consumeArgs(2);return e.mode===`text`?{tokens:t[0],numArgs:0}:{tokens:t[1],numArgs:0}});var Bpt={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15};$(`\\char`,function(e){var t=e.popToken(),n,r=0;if(t.text===`'`)n=8,t=e.popToken();else if(t.text===`"`)n=16,t=e.popToken();else if(t.text==="`"){if(t=e.popToken(),t.text[0]===`\\`)r=t.text.charCodeAt(1);else if(t.text===`EOF`)throw new l5("\\char` missing argument");else r=t.text.charCodeAt(0)}else n=10;if(n){if(r=Bpt[t.text],r==null||r>=n)throw new l5(`Invalid base-`+n+` digit `+t.text);for(var i;(i=Bpt[e.future().text])!=null&&i<n;)r*=n,r+=i,e.popToken()}return`\\@char{`+r+`}`});var H9=(e,t,n,r)=>{var i=e.consumeArg().tokens;if(i.length!==1)throw new l5(`\\newcommand's first argument must be a macro name`);var a=i[0].text,o=e.isDefined(a);if(o&&!t)throw new l5(`\\newcommand{`+a+`} attempting to redefine `+(a+`; use \\renewcommand`));if(!o&&!n)throw new l5(`\\renewcommand{`+a+`} when command `+a+` does not yet exist; use \\newcommand`);var s=0;if(i=e.consumeArg().tokens,i.length===1&&i[0].text===`[`){for(var c=``,l=e.expandNextToken();l.text!==`]`&&l.text!==`EOF`;)c+=l.text,l=e.expandNextToken();if(!c.match(/^\s*[0-9]+\s*$/))throw new l5(`Invalid number of arguments: `+c);s=parseInt(c),i=e.consumeArg().tokens}return o&&r||e.macros.set(a,{tokens:i,numArgs:s}),``};$(`\\newcommand`,e=>H9(e,!1,!0,!1)),$(`\\renewcommand`,e=>H9(e,!0,!1,!1)),$(`\\providecommand`,e=>H9(e,!0,!0,!0)),$(`\\message`,e=>{var t=e.consumeArgs(1)[0];return console.log(t.reverse().map(e=>e.text).join(``)),``}),$(`\\errmessage`,e=>{var t=e.consumeArgs(1)[0];return console.error(t.reverse().map(e=>e.text).join(``)),``}),$(`\\show`,e=>{var t=e.popToken(),n=t.text;return console.log(t,e.macros.get(n),B9[n],K5.math[n],K5.text[n]),``}),$(`\\bgroup`,`{`),$(`\\egroup`,`}`),$(`~`,`\\nobreakspace`),$(`\\lq`,"`"),$(`\\rq`,`'`),$(`\\aa`,`\\r a`),$(`\\AA`,`\\r A`),$(`\\textcopyright`,"\\html@mathml{\\textcircled{c}}{\\char`©}"),$(`\\copyright`,`\\TextOrMath{\\textcopyright}{\\text{\\textcopyright}}`),$(`\\textregistered`,"\\html@mathml{\\textcircled{\\scriptsize R}}{\\char`®}"),$(`ℬ`,`\\mathscr{B}`),$(`ℰ`,`\\mathscr{E}`),$(`ℱ`,`\\mathscr{F}`),$(`ℋ`,`\\mathscr{H}`),$(`ℐ`,`\\mathscr{I}`),$(`ℒ`,`\\mathscr{L}`),$(`ℳ`,`\\mathscr{M}`),$(`ℛ`,`\\mathscr{R}`),$(`ℭ`,`\\mathfrak{C}`),$(`ℌ`,`\\mathfrak{H}`),$(`ℨ`,`\\mathfrak{Z}`),$(`\\Bbbk`,`\\Bbb{k}`),$(`\\llap`,`\\mathllap{\\textrm{#1}}`),$(`\\rlap`,`\\mathrlap{\\textrm{#1}}`),$(`\\clap`,`\\mathclap{\\textrm{#1}}`),$(`\\mathstrut`,`\\vphantom{(}`),$(`\\underbar`,`\\underline{\\text{#1}}`),$(`\\not`,`\\html@mathml{\\mathrel{\\mathrlap\\@not}\\nobreak}{\\char"338}`),$(`\\neq`,"\\html@mathml{\\mathrel{\\not=}}{\\mathrel{\\char`≠}}"),$(`\\ne`,`\\neq`),$(`≠`,`\\neq`),$(`\\notin`,"\\html@mathml{\\mathrel{{\\in}\\mathllap{/\\mskip1mu}}}{\\mathrel{\\char`∉}}"),$(`∉`,`\\notin`),$(`≘`,"\\html@mathml{\\mathrel{=\\kern{-1em}\\raisebox{0.4em}{$\\scriptsize\\frown$}}}{\\mathrel{\\char`≘}}"),$(`≙`,"\\html@mathml{\\stackrel{\\tiny\\wedge}{=}}{\\mathrel{\\char`≘}}"),$(`≚`,"\\html@mathml{\\stackrel{\\tiny\\vee}{=}}{\\mathrel{\\char`≚}}"),$(`≛`,"\\html@mathml{\\stackrel{\\scriptsize\\star}{=}}{\\mathrel{\\char`≛}}"),$(`≝`,"\\html@mathml{\\stackrel{\\tiny\\mathrm{def}}{=}}{\\mathrel{\\char`≝}}"),$(`≞`,"\\html@mathml{\\stackrel{\\tiny\\mathrm{m}}{=}}{\\mathrel{\\char`≞}}"),$(`≟`,"\\html@mathml{\\stackrel{\\tiny?}{=}}{\\mathrel{\\char`≟}}"),$(`⟂`,`\\perp`),$(`‼`,`\\mathclose{!\\mkern-0.8mu!}`),$(`∌`,`\\notni`),$(`⌜`,`\\ulcorner`),$(`⌝`,`\\urcorner`),$(`⌞`,`\\llcorner`),$(`⌟`,`\\lrcorner`),$(`©`,`\\copyright`),$(`®`,`\\textregistered`),$(`\\ulcorner`,`\\html@mathml{\\@ulcorner}{\\mathop{\\char"231c}}`),$(`\\urcorner`,`\\html@mathml{\\@urcorner}{\\mathop{\\char"231d}}`),$(`\\llcorner`,`\\html@mathml{\\@llcorner}{\\mathop{\\char"231e}}`),$(`\\lrcorner`,`\\html@mathml{\\@lrcorner}{\\mathop{\\char"231f}}`),$(`\\vdots`,`{\\varvdots\\rule{0pt}{15pt}}`),$(`⋮`,`\\vdots`),$(`\\varGamma`,`\\mathit{\\Gamma}`),$(`\\varDelta`,`\\mathit{\\Delta}`),$(`\\varTheta`,`\\mathit{\\Theta}`),$(`\\varLambda`,`\\mathit{\\Lambda}`),$(`\\varXi`,`\\mathit{\\Xi}`),$(`\\varPi`,`\\mathit{\\Pi}`),$(`\\varSigma`,`\\mathit{\\Sigma}`),$(`\\varUpsilon`,`\\mathit{\\Upsilon}`),$(`\\varPhi`,`\\mathit{\\Phi}`),$(`\\varPsi`,`\\mathit{\\Psi}`),$(`\\varOmega`,`\\mathit{\\Omega}`),$(`\\substack`,`\\begin{subarray}{c}#1\\end{subarray}`),$(`\\colon`,`\\nobreak\\mskip2mu\\mathpunct{}\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu\\relax`),$(`\\boxed`,`\\fbox{$\\displaystyle{#1}$}`),$(`\\iff`,`\\DOTSB\\;\\Longleftrightarrow\\;`),$(`\\implies`,`\\DOTSB\\;\\Longrightarrow\\;`),$(`\\impliedby`,`\\DOTSB\\;\\Longleftarrow\\;`),$(`\\dddot`,`{\\overset{\\raisebox{-0.1ex}{\\normalsize ...}}{#1}}`),$(`\\ddddot`,`{\\overset{\\raisebox{-0.1ex}{\\normalsize ....}}{#1}}`);var Vpt={",":`\\dotsc`,"\\not":`\\dotsb`,"+":`\\dotsb`,"=":`\\dotsb`,"<":`\\dotsb`,">":`\\dotsb`,"-":`\\dotsb`,"*":`\\dotsb`,":":`\\dotsb`,"\\DOTSB":`\\dotsb`,"\\coprod":`\\dotsb`,"\\bigvee":`\\dotsb`,"\\bigwedge":`\\dotsb`,"\\biguplus":`\\dotsb`,"\\bigcap":`\\dotsb`,"\\bigcup":`\\dotsb`,"\\prod":`\\dotsb`,"\\sum":`\\dotsb`,"\\bigotimes":`\\dotsb`,"\\bigoplus":`\\dotsb`,"\\bigodot":`\\dotsb`,"\\bigsqcup":`\\dotsb`,"\\And":`\\dotsb`,"\\longrightarrow":`\\dotsb`,"\\Longrightarrow":`\\dotsb`,"\\longleftarrow":`\\dotsb`,"\\Longleftarrow":`\\dotsb`,"\\longleftrightarrow":`\\dotsb`,"\\Longleftrightarrow":`\\dotsb`,"\\mapsto":`\\dotsb`,"\\longmapsto":`\\dotsb`,"\\hookrightarrow":`\\dotsb`,"\\doteq":`\\dotsb`,"\\mathbin":`\\dotsb`,"\\mathrel":`\\dotsb`,"\\relbar":`\\dotsb`,"\\Relbar":`\\dotsb`,"\\xrightarrow":`\\dotsb`,"\\xleftarrow":`\\dotsb`,"\\DOTSI":`\\dotsi`,"\\int":`\\dotsi`,"\\oint":`\\dotsi`,"\\iint":`\\dotsi`,"\\iiint":`\\dotsi`,"\\iiiint":`\\dotsi`,"\\idotsint":`\\dotsi`,"\\DOTSX":`\\dotsx`},Hpt=/* @__PURE__ */ new Set([`bin`,`rel`]);$(`\\dots`,function(e){var t=`\\dotso`,n=e.expandAfterFuture().text;return n in Vpt?t=Vpt[n]:(n.slice(0,4)===`\\not`||n in K5.math&&Hpt.has(K5.math[n].group))&&(t=`\\dotsb`),t});var U9={")":!0,"]":!0,"\\rbrack":!0,"\\}":!0,"\\rbrace":!0,"\\rangle":!0,"\\rceil":!0,"\\rfloor":!0,"\\rgroup":!0,"\\rmoustache":!0,"\\right":!0,"\\bigr":!0,"\\biggr":!0,"\\Bigr":!0,"\\Biggr":!0,$:!0,";":!0,".":!0,",":!0};$(`\\dotso`,function(e){return e.future().text in U9?`\\ldots\\,`:`\\ldots`}),$(`\\dotsc`,function(e){var t=e.future().text;return t in U9&&t!==`,`?`\\ldots\\,`:`\\ldots`}),$(`\\cdots`,function(e){return e.future().text in U9?`\\@cdots\\,`:`\\@cdots`}),$(`\\dotsb`,`\\cdots`),$(`\\dotsm`,`\\cdots`),$(`\\dotsi`,`\\!\\cdots`),$(`\\dotsx`,`\\ldots\\,`),$(`\\DOTSI`,`\\relax`),$(`\\DOTSB`,`\\relax`),$(`\\DOTSX`,`\\relax`),$(`\\tmspace`,`\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax`),$(`\\,`,`\\tmspace+{3mu}{.1667em}`),$(`\\thinspace`,`\\,`),$(`\\>`,`\\mskip{4mu}`),$(`\\:`,`\\tmspace+{4mu}{.2222em}`),$(`\\medspace`,`\\:`),$(`\\;`,`\\tmspace+{5mu}{.2777em}`),$(`\\thickspace`,`\\;`),$(`\\!`,`\\tmspace-{3mu}{.1667em}`),$(`\\negthinspace`,`\\!`),$(`\\negmedspace`,`\\tmspace-{4mu}{.2222em}`),$(`\\negthickspace`,`\\tmspace-{5mu}{.277em}`),$(`\\enspace`,`\\kern.5em `),$(`\\enskip`,`\\hskip.5em\\relax`),$(`\\quad`,`\\hskip1em\\relax`),$(`\\qquad`,`\\hskip2em\\relax`),$(`\\tag`,`\\@ifstar\\tag@literal\\tag@paren`),$(`\\tag@paren`,`\\tag@literal{({#1})}`),$(`\\tag@literal`,e=>{if(e.macros.get(`\\df@tag`))throw new l5(`Multiple \\tag`);return`\\gdef\\df@tag{\\text{#1}}`}),$(`\\bmod`,`\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}\\mathbin{\\rm mod}\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}`),$(`\\pod`,`\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)`),$(`\\pmod`,`\\pod{{\\rm mod}\\mkern6mu#1}`),$(`\\mod`,`\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}{\\rm mod}\\,\\,#1`),$(`\\newline`,`\\\\\\relax`),$(`\\TeX`,`\\textrm{\\html@mathml{T\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125emX}{TeX}}`);var Upt=N5(H5[`Main-Regular`][84][1]-.7*H5[`Main-Regular`][65][1]);$(`\\LaTeX`,`\\textrm{\\html@mathml{`+(`L\\kern-.36em\\raisebox{`+Upt+`}{\\scriptstyle A}`)+`\\kern-.15em\\TeX}{LaTeX}}`),$(`\\KaTeX`,`\\textrm{\\html@mathml{`+(`K\\kern-.17em\\raisebox{`+Upt+`}{\\scriptstyle A}`)+`\\kern-.15em\\TeX}{KaTeX}}`),$(`\\hspace`,`\\@ifstar\\@hspacer\\@hspace`),$(`\\@hspace`,`\\hskip #1\\relax`),$(`\\@hspacer`,`\\rule{0pt}{0pt}\\hskip #1\\relax`),$(`\\ordinarycolon`,`:`),$(`\\vcentcolon`,`\\mathrel{\\mathop\\ordinarycolon}`),$(`\\dblcolon`,`\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-.9mu}\\vcentcolon}}{\\mathop{\\char"2237}}`),$(`\\coloneqq`,`\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2254}}`),$(`\\Coloneqq`,`\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2237\\char"3d}}`),$(`\\coloneq`,`\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"3a\\char"2212}}`),$(`\\Coloneq`,`\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"2237\\char"2212}}`),$(`\\eqqcolon`,`\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2255}}`),$(`\\Eqqcolon`,`\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"3d\\char"2237}}`),$(`\\eqcolon`,`\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2239}}`),$(`\\Eqcolon`,`\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"2212\\char"2237}}`),$(`\\colonapprox`,`\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"3a\\char"2248}}`),$(`\\Colonapprox`,`\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"2237\\char"2248}}`),$(`\\colonsim`,`\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"3a\\char"223c}}`),$(`\\Colonsim`,`\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"2237\\char"223c}}`),$(`∷`,`\\dblcolon`),$(`∹`,`\\eqcolon`),$(`≔`,`\\coloneqq`),$(`≕`,`\\eqqcolon`),$(`⩴`,`\\Coloneqq`),$(`\\ratio`,`\\vcentcolon`),$(`\\coloncolon`,`\\dblcolon`),$(`\\colonequals`,`\\coloneqq`),$(`\\coloncolonequals`,`\\Coloneqq`),$(`\\equalscolon`,`\\eqqcolon`),$(`\\equalscoloncolon`,`\\Eqqcolon`),$(`\\colonminus`,`\\coloneq`),$(`\\coloncolonminus`,`\\Coloneq`),$(`\\minuscolon`,`\\eqcolon`),$(`\\minuscoloncolon`,`\\Eqcolon`),$(`\\coloncolonapprox`,`\\Colonapprox`),$(`\\coloncolonsim`,`\\Colonsim`),$(`\\simcolon`,`\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\vcentcolon}`),$(`\\simcoloncolon`,`\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\dblcolon}`),$(`\\approxcolon`,`\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\vcentcolon}`),$(`\\approxcoloncolon`,`\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon}`),$(`\\notni`,"\\html@mathml{\\not\\ni}{\\mathrel{\\char`∌}}"),$(`\\limsup`,`\\DOTSB\\operatorname*{lim\\,sup}`),$(`\\liminf`,`\\DOTSB\\operatorname*{lim\\,inf}`),$(`\\injlim`,`\\DOTSB\\operatorname*{inj\\,lim}`),$(`\\projlim`,`\\DOTSB\\operatorname*{proj\\,lim}`),$(`\\varlimsup`,`\\DOTSB\\operatorname*{\\overline{lim}}`),$(`\\varliminf`,`\\DOTSB\\operatorname*{\\underline{lim}}`),$(`\\varinjlim`,`\\DOTSB\\operatorname*{\\underrightarrow{lim}}`),$(`\\varprojlim`,`\\DOTSB\\operatorname*{\\underleftarrow{lim}}`),$(`\\gvertneqq`,`\\html@mathml{\\@gvertneqq}{≩}`),$(`\\lvertneqq`,`\\html@mathml{\\@lvertneqq}{≨}`),$(`\\ngeqq`,`\\html@mathml{\\@ngeqq}{≱}`),$(`\\ngeqslant`,`\\html@mathml{\\@ngeqslant}{≱}`),$(`\\nleqq`,`\\html@mathml{\\@nleqq}{≰}`),$(`\\nleqslant`,`\\html@mathml{\\@nleqslant}{≰}`),$(`\\nshortmid`,`\\html@mathml{\\@nshortmid}{∤}`),$(`\\nshortparallel`,`\\html@mathml{\\@nshortparallel}{∦}`),$(`\\nsubseteqq`,`\\html@mathml{\\@nsubseteqq}{⊈}`),$(`\\nsupseteqq`,`\\html@mathml{\\@nsupseteqq}{⊉}`),$(`\\varsubsetneq`,`\\html@mathml{\\@varsubsetneq}{⊊}`),$(`\\varsubsetneqq`,`\\html@mathml{\\@varsubsetneqq}{⫋}`),$(`\\varsupsetneq`,`\\html@mathml{\\@varsupsetneq}{⊋}`),$(`\\varsupsetneqq`,`\\html@mathml{\\@varsupsetneqq}{⫌}`),$(`\\imath`,`\\html@mathml{\\@imath}{ı}`),$(`\\jmath`,`\\html@mathml{\\@jmath}{ȷ}`),$(`\\llbracket`,"\\html@mathml{\\mathopen{[\\mkern-3.2mu[}}{\\mathopen{\\char`⟦}}"),$(`\\rrbracket`,"\\html@mathml{\\mathclose{]\\mkern-3.2mu]}}{\\mathclose{\\char`⟧}}"),$(`⟦`,`\\llbracket`),$(`⟧`,`\\rrbracket`),$(`\\lBrace`,"\\html@mathml{\\mathopen{\\{\\mkern-3.2mu[}}{\\mathopen{\\char`⦃}}"),$(`\\rBrace`,"\\html@mathml{\\mathclose{]\\mkern-3.2mu\\}}}{\\mathclose{\\char`⦄}}"),$(`↤`,`\\mapsfrom`),$(`\\mapsfrom`,"\\html@mathml{\\mathrel{\\mathreflectbox{\\mapsto}}}{\\mathrel{\\char`↤}}"),$(`⦃`,`\\lBrace`),$(`⦄`,`\\rBrace`),$(`\\minuso`,"\\mathbin{\\html@mathml{{\\mathrlap{\\mathchoice{\\kern{0.145em}}{\\kern{0.145em}}{\\kern{0.1015em}}{\\kern{0.0725em}}\\circ}{-}}}{\\char`⦵}}"),$(`⦵`,`\\minuso`),$(`\\darr`,`\\downarrow`),$(`\\dArr`,`\\Downarrow`),$(`\\Darr`,`\\Downarrow`),$(`\\lang`,`\\langle`),$(`\\rang`,`\\rangle`),$(`\\uarr`,`\\uparrow`),$(`\\uArr`,`\\Uparrow`),$(`\\Uarr`,`\\Uparrow`),$(`\\N`,`\\mathbb{N}`),$(`\\R`,`\\mathbb{R}`),$(`\\Z`,`\\mathbb{Z}`),$(`\\alef`,`\\aleph`),$(`\\alefsym`,`\\aleph`),$(`\\Alpha`,`\\mathrm{A}`),$(`\\Beta`,`\\mathrm{B}`),$(`\\bull`,`\\bullet`),$(`\\Chi`,`\\mathrm{X}`),$(`\\clubs`,`\\clubsuit`),$(`\\cnums`,`\\mathbb{C}`),$(`\\Complex`,`\\mathbb{C}`),$(`\\Dagger`,`\\ddagger`),$(`\\diamonds`,`\\diamondsuit`),$(`\\empty`,`\\emptyset`),$(`\\Epsilon`,`\\mathrm{E}`),$(`\\Eta`,`\\mathrm{H}`),$(`\\exist`,`\\exists`),$(`\\harr`,`\\leftrightarrow`),$(`\\hArr`,`\\Leftrightarrow`),$(`\\Harr`,`\\Leftrightarrow`),$(`\\hearts`,`\\heartsuit`),$(`\\image`,`\\Im`),$(`\\infin`,`\\infty`),$(`\\Iota`,`\\mathrm{I}`),$(`\\isin`,`\\in`),$(`\\Kappa`,`\\mathrm{K}`),$(`\\larr`,`\\leftarrow`),$(`\\lArr`,`\\Leftarrow`),$(`\\Larr`,`\\Leftarrow`),$(`\\lrarr`,`\\leftrightarrow`),$(`\\lrArr`,`\\Leftrightarrow`),$(`\\Lrarr`,`\\Leftrightarrow`),$(`\\Mu`,`\\mathrm{M}`),$(`\\natnums`,`\\mathbb{N}`),$(`\\Nu`,`\\mathrm{N}`),$(`\\Omicron`,`\\mathrm{O}`),$(`\\plusmn`,`\\pm`),$(`\\rarr`,`\\rightarrow`),$(`\\rArr`,`\\Rightarrow`),$(`\\Rarr`,`\\Rightarrow`),$(`\\real`,`\\Re`),$(`\\reals`,`\\mathbb{R}`),$(`\\Reals`,`\\mathbb{R}`),$(`\\Rho`,`\\mathrm{P}`),$(`\\sdot`,`\\cdot`),$(`\\sect`,`\\S`),$(`\\spades`,`\\spadesuit`),$(`\\sub`,`\\subset`),$(`\\sube`,`\\subseteq`),$(`\\supe`,`\\supseteq`),$(`\\Tau`,`\\mathrm{T}`),$(`\\thetasym`,`\\vartheta`),$(`\\weierp`,`\\wp`),$(`\\Zeta`,`\\mathrm{Z}`),$(`\\argmin`,`\\DOTSB\\operatorname*{arg\\,min}`),$(`\\argmax`,`\\DOTSB\\operatorname*{arg\\,max}`),$(`\\plim`,`\\DOTSB\\mathop{\\operatorname{plim}}\\limits`),$(`\\bra`,`\\mathinner{\\langle{#1}|}`),$(`\\ket`,`\\mathinner{|{#1}\\rangle}`),$(`\\braket`,`\\mathinner{\\langle{#1}\\rangle}`),$(`\\Bra`,`\\left\\langle#1\\right|`),$(`\\Ket`,`\\left|#1\\right\\rangle`);var Wpt=e=>t=>{var n=t.consumeArg().tokens,r=t.consumeArg().tokens,i=t.consumeArg().tokens,a=t.consumeArg().tokens,o=t.macros.get(`|`),s=t.macros.get(`\\|`);t.macros.beginGroup();var c=t=>n=>{e&&(n.macros.set(`|`,o),i.length&&n.macros.set(`\\|`,s));var a=t;return!t&&i.length&&n.future().text===`|`&&(n.popToken(),a=!0),{tokens:a?i:r,numArgs:0}};t.macros.set(`|`,c(!1)),i.length&&t.macros.set(`\\|`,c(!0));var l=t.consumeArg().tokens,u=t.expandTokens([...a,...l,...n]);return t.macros.endGroup(),{tokens:u.reverse(),numArgs:0}};$(`\\bra@ket`,Wpt(!1)),$(`\\bra@set`,Wpt(!0)),$(`\\Braket`,`\\bra@ket{\\left\\langle}{\\,\\middle\\vert\\,}{\\,\\middle\\vert\\,}{\\right\\rangle}`),$(`\\Set`,`\\bra@set{\\left\\{\\:}{\\;\\middle\\vert\\;}{\\;\\middle\\Vert\\;}{\\:\\right\\}}`),$(`\\set`,`\\bra@set{\\{\\,}{\\mid}{}{\\,\\}}`),$(`\\angln`,`{\\angl n}`),$(`\\blue`,`\\textcolor{##6495ed}{#1}`),$(`\\orange`,`\\textcolor{##ffa500}{#1}`),$(`\\pink`,`\\textcolor{##ff00af}{#1}`),$(`\\red`,`\\textcolor{##df0030}{#1}`),$(`\\green`,`\\textcolor{##28ae7b}{#1}`),$(`\\gray`,`\\textcolor{gray}{#1}`),$(`\\purple`,`\\textcolor{##9d38bd}{#1}`),$(`\\blueA`,`\\textcolor{##ccfaff}{#1}`),$(`\\blueB`,`\\textcolor{##80f6ff}{#1}`),$(`\\blueC`,`\\textcolor{##63d9ea}{#1}`),$(`\\blueD`,`\\textcolor{##11accd}{#1}`),$(`\\blueE`,`\\textcolor{##0c7f99}{#1}`),$(`\\tealA`,`\\textcolor{##94fff5}{#1}`),$(`\\tealB`,`\\textcolor{##26edd5}{#1}`),$(`\\tealC`,`\\textcolor{##01d1c1}{#1}`),$(`\\tealD`,`\\textcolor{##01a995}{#1}`),$(`\\tealE`,`\\textcolor{##208170}{#1}`),$(`\\greenA`,`\\textcolor{##b6ffb0}{#1}`),$(`\\greenB`,`\\textcolor{##8af281}{#1}`),$(`\\greenC`,`\\textcolor{##74cf70}{#1}`),$(`\\greenD`,`\\textcolor{##1fab54}{#1}`),$(`\\greenE`,`\\textcolor{##0d923f}{#1}`),$(`\\goldA`,`\\textcolor{##ffd0a9}{#1}`),$(`\\goldB`,`\\textcolor{##ffbb71}{#1}`),$(`\\goldC`,`\\textcolor{##ff9c39}{#1}`),$(`\\goldD`,`\\textcolor{##e07d10}{#1}`),$(`\\goldE`,`\\textcolor{##a75a05}{#1}`),$(`\\redA`,`\\textcolor{##fca9a9}{#1}`),$(`\\redB`,`\\textcolor{##ff8482}{#1}`),$(`\\redC`,`\\textcolor{##f9685d}{#1}`),$(`\\redD`,`\\textcolor{##e84d39}{#1}`),$(`\\redE`,`\\textcolor{##bc2612}{#1}`),$(`\\maroonA`,`\\textcolor{##ffbde0}{#1}`),$(`\\maroonB`,`\\textcolor{##ff92c6}{#1}`),$(`\\maroonC`,`\\textcolor{##ed5fa6}{#1}`),$(`\\maroonD`,`\\textcolor{##ca337c}{#1}`),$(`\\maroonE`,`\\textcolor{##9e034e}{#1}`),$(`\\purpleA`,`\\textcolor{##ddd7ff}{#1}`),$(`\\purpleB`,`\\textcolor{##c6b9fc}{#1}`),$(`\\purpleC`,`\\textcolor{##aa87ff}{#1}`),$(`\\purpleD`,`\\textcolor{##7854ab}{#1}`),$(`\\purpleE`,`\\textcolor{##543b78}{#1}`),$(`\\mintA`,`\\textcolor{##f5f9e8}{#1}`),$(`\\mintB`,`\\textcolor{##edf2df}{#1}`),$(`\\mintC`,`\\textcolor{##e0e5cc}{#1}`),$(`\\grayA`,`\\textcolor{##f6f7f7}{#1}`),$(`\\grayB`,`\\textcolor{##f0f1f2}{#1}`),$(`\\grayC`,`\\textcolor{##e3e5e6}{#1}`),$(`\\grayD`,`\\textcolor{##d6d8da}{#1}`),$(`\\grayE`,`\\textcolor{##babec2}{#1}`),$(`\\grayF`,`\\textcolor{##888d93}{#1}`),$(`\\grayG`,`\\textcolor{##626569}{#1}`),$(`\\grayH`,`\\textcolor{##3b3e40}{#1}`),$(`\\grayI`,`\\textcolor{##21242c}{#1}`),$(`\\kaBlue`,`\\textcolor{##314453}{#1}`),$(`\\kaGreen`,`\\textcolor{##71B307}{#1}`);var Gpt={"^":!0,_:!0,"\\limits":!0,"\\nolimits":!0},Kpt=class{constructor(e,t,n){this.settings=void 0,this.expansionCount=void 0,this.lexer=void 0,this.macros=void 0,this.stack=void 0,this.mode=void 0,this.settings=t,this.expansionCount=0,this.feed(e),this.macros=new Rpt(zpt,t.macros),this.mode=n,this.stack=[]}feed(e){this.lexer=new Lpt(e,this.settings)}switchMode(e){this.mode=e}beginGroup(){this.macros.beginGroup()}endGroup(){this.macros.endGroup()}endGroups(){this.macros.endGroups()}future(){return this.stack.length===0&&this.pushToken(this.lexer.lex()),this.stack[this.stack.length-1]}popToken(){return this.future(),this.stack.pop()}pushToken(e){this.stack.push(e)}pushTokens(e){this.stack.push(...e)}scanArgument(e){var t,n,r;if(e){if(this.consumeSpaces(),this.future().text!==`[`)return null;t=this.popToken();var i=this.consumeArg([`]`]);r=i.tokens,n=i.end}else{var a=this.consumeArg();r=a.tokens,t=a.start,n=a.end}return this.pushToken(new j9(`EOF`,n.loc)),this.pushTokens(r),new j9(``,A9.range(t,n))}consumeSpaces(){for(;this.future().text===` `;)this.stack.pop()}consumeArg(e){var t=[],n=e&&e.length>0;n||this.consumeSpaces();var r=this.future(),i,a=0,o=0;do{if(i=this.popToken(),t.push(i),i.text===`{`)++a;else if(i.text===`}`){if(--a,a===-1)throw new l5(`Extra }`,i)}else if(i.text===`EOF`)throw new l5(`Unexpected end of input in a macro argument, expected '`+(e&&n?e[o]:`}`)+`'`,i);if(e&&n){if((a===0||a===1&&e[o]===`{`)&&i.text===e[o]){if(++o,o===e.length){t.splice(-o,o);break}}else o=0}}while(a!==0||n);return r.text===`{`&&t[t.length-1].text===`}`&&(t.pop(),t.shift()),t.reverse(),{tokens:t,start:r,end:i}}consumeArgs(e,t){if(t){if(t.length!==e+1)throw new l5(`The length of delimiters doesn't match the number of args!`);for(var n=t[0],r=0;r<n.length;r++){var i=this.popToken();if(n[r]!==i.text)throw new l5(`Use of the macro doesn't match its definition`,i)}}for(var a=[],o=0;o<e;o++)a.push(this.consumeArg(t&&t[o+1]).tokens);return a}countExpansion(e){if(this.expansionCount+=e,this.expansionCount>this.settings.maxExpand)throw new l5(`Too many expansions: infinite loop or need to increase maxExpand setting`)}expandOnce(e){var t=this.popToken(),n=t.text,r=t.noexpand?null:this._getExpansion(n);if(r==null||e&&r.unexpandable){if(e&&r==null&&n[0]===`\\`&&!this.isDefined(n))throw new l5(`Undefined control sequence: `+n);return this.pushToken(t),!1}this.countExpansion(1);var i=r.tokens,a=this.consumeArgs(r.numArgs,r.delimiters);if(r.numArgs){i=i.slice();for(var o=i.length-1;o>=0;--o){var s=i[o];if(s.text===`#`){if(o===0)throw new l5(`Incomplete placeholder at end of macro body`,s);if(s=i[--o],s.text===`#`)i.splice(o+1,1);else if(/^[1-9]$/.test(s.text))i.splice(o,2,...a[s.text-1]);else throw new l5(`Not a valid argument number`,s)}}}return this.pushTokens(i),i.length}expandAfterFuture(){return this.expandOnce(),this.future()}expandNextToken(){for(;;)if(this.expandOnce()===!1){var e=this.stack.pop();return e.treatAsRelax&&(e.text=`\\relax`),e}}expandMacro(e){return this.macros.has(e)?this.expandTokens([new j9(e)]):void 0}expandTokens(e){var t=[],n=this.stack.length;for(this.pushTokens(e);this.stack.length>n;)if(this.expandOnce(!0)===!1){var r=this.stack.pop();r.treatAsRelax&&=(r.noexpand=!1,!1),t.push(r)}return this.countExpansion(t.length),t}expandMacroAsText(e){var t=this.expandMacro(e);return t&&t.map(e=>e.text).join(``)}_getExpansion(e){var t=this.macros.get(e);if(t==null)return t;if(e.length===1){var n=this.lexer.catcodes[e];if(n!=null&&n!==13)return}var r=typeof t==`function`?t(this):t;if(typeof r==`string`){var i=0;if(r.includes(`#`))for(var a=r.replace(/##/g,``);a.includes(`#`+(i+1));)++i;for(var o=new Lpt(r,this.settings),s=[],c=o.lex();c.text!==`EOF`;)s.push(c),c=o.lex();return s.reverse(),{tokens:s,numArgs:i}}return r}isDefined(e){return this.macros.has(e)||Object.prototype.hasOwnProperty.call(B9,e)||Object.prototype.hasOwnProperty.call(K5.math,e)||Object.prototype.hasOwnProperty.call(K5.text,e)||Object.prototype.hasOwnProperty.call(Gpt,e)}isExpandable(e){var t=this.macros.get(e);return t==null?Object.prototype.hasOwnProperty.call(B9,e)&&!B9[e].primitive:typeof t==`string`||typeof t==`function`||!t.unexpandable}},qpt=/^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/,W9=Object.freeze({"₊":`+`,"₋":`-`,"₌":`=`,"₍":`(`,"₎":`)`,"₀":`0`,"₁":`1`,"₂":`2`,"₃":`3`,"₄":`4`,"₅":`5`,"₆":`6`,"₇":`7`,"₈":`8`,"₉":`9`,ₐ:`a`,ₑ:`e`,ₕ:`h`,ᵢ:`i`,ⱼ:`j`,ₖ:`k`,ₗ:`l`,ₘ:`m`,ₙ:`n`,ₒ:`o`,ₚ:`p`,ᵣ:`r`,ₛ:`s`,ₜ:`t`,ᵤ:`u`,ᵥ:`v`,ₓ:`x`,ᵦ:`β`,ᵧ:`γ`,ᵨ:`ρ`,ᵩ:`ϕ`,ᵪ:`χ`,"⁺":`+`,"⁻":`-`,"⁼":`=`,"⁽":`(`,"⁾":`)`,"⁰":`0`,"¹":`1`,"²":`2`,"³":`3`,"⁴":`4`,"⁵":`5`,"⁶":`6`,"⁷":`7`,"⁸":`8`,"⁹":`9`,ᴬ:`A`,ᴮ:`B`,ᴰ:`D`,ᴱ:`E`,ᴳ:`G`,ᴴ:`H`,ᴵ:`I`,ᴶ:`J`,ᴷ:`K`,ᴸ:`L`,ᴹ:`M`,ᴺ:`N`,ᴼ:`O`,ᴾ:`P`,ᴿ:`R`,ᵀ:`T`,ᵁ:`U`,ⱽ:`V`,ᵂ:`W`,ᵃ:`a`,ᵇ:`b`,ᶜ:`c`,ᵈ:`d`,ᵉ:`e`,ᶠ:`f`,ᵍ:`g`,ʰ:`h`,ⁱ:`i`,ʲ:`j`,ᵏ:`k`,ˡ:`l`,ᵐ:`m`,ⁿ:`n`,ᵒ:`o`,ᵖ:`p`,ʳ:`r`,ˢ:`s`,ᵗ:`t`,ᵘ:`u`,ᵛ:`v`,ʷ:`w`,ˣ:`x`,ʸ:`y`,ᶻ:`z`,ᵝ:`β`,ᵞ:`γ`,ᵟ:`δ`,ᵠ:`ϕ`,ᵡ:`χ`,ᶿ:`θ`}),G9={"́":{text:`\\'`,math:`\\acute`},"̀":{text:"\\`",math:`\\grave`},"̈":{text:`\\"`,math:`\\ddot`},"̃":{text:`\\~`,math:`\\tilde`},"̄":{text:`\\=`,math:`\\bar`},"̆":{text:`\\u`,math:`\\breve`},"̌":{text:`\\v`,math:`\\check`},"̂":{text:`\\^`,math:`\\hat`},"̇":{text:`\\.`,math:`\\dot`},"̊":{text:`\\r`,math:`\\mathring`},"̋":{text:`\\H`},"̧":{text:`\\c`}},Jpt={á:`á`,à:`à`,ä:`ä`,ǟ:`ǟ`,ã:`ã`,ā:`ā`,ă:`ă`,ắ:`ắ`,ằ:`ằ`,ẵ:`ẵ`,ǎ:`ǎ`,â:`â`,ấ:`ấ`,ầ:`ầ`,ẫ:`ẫ`,ȧ:`ȧ`,ǡ:`ǡ`,å:`å`,ǻ:`ǻ`,ḃ:`ḃ`,ć:`ć`,ḉ:`ḉ`,č:`č`,ĉ:`ĉ`,ċ:`ċ`,ç:`ç`,ď:`ď`,ḋ:`ḋ`,ḑ:`ḑ`,é:`é`,è:`è`,ë:`ë`,ẽ:`ẽ`,ē:`ē`,ḗ:`ḗ`,ḕ:`ḕ`,ĕ:`ĕ`,ḝ:`ḝ`,ě:`ě`,ê:`ê`,ế:`ế`,ề:`ề`,ễ:`ễ`,ė:`ė`,ȩ:`ȩ`,ḟ:`ḟ`,ǵ:`ǵ`,ḡ:`ḡ`,ğ:`ğ`,ǧ:`ǧ`,ĝ:`ĝ`,ġ:`ġ`,ģ:`ģ`,ḧ:`ḧ`,ȟ:`ȟ`,ĥ:`ĥ`,ḣ:`ḣ`,ḩ:`ḩ`,í:`í`,ì:`ì`,ï:`ï`,ḯ:`ḯ`,ĩ:`ĩ`,ī:`ī`,ĭ:`ĭ`,ǐ:`ǐ`,î:`î`,ǰ:`ǰ`,ĵ:`ĵ`,ḱ:`ḱ`,ǩ:`ǩ`,ķ:`ķ`,ĺ:`ĺ`,ľ:`ľ`,ļ:`ļ`,ḿ:`ḿ`,ṁ:`ṁ`,ń:`ń`,ǹ:`ǹ`,ñ:`ñ`,ň:`ň`,ṅ:`ṅ`,ņ:`ņ`,ó:`ó`,ò:`ò`,ö:`ö`,ȫ:`ȫ`,õ:`õ`,ṍ:`ṍ`,ṏ:`ṏ`,ȭ:`ȭ`,ō:`ō`,ṓ:`ṓ`,ṑ:`ṑ`,ŏ:`ŏ`,ǒ:`ǒ`,ô:`ô`,ố:`ố`,ồ:`ồ`,ỗ:`ỗ`,ȯ:`ȯ`,ȱ:`ȱ`,ő:`ő`,ṕ:`ṕ`,ṗ:`ṗ`,ŕ:`ŕ`,ř:`ř`,ṙ:`ṙ`,ŗ:`ŗ`,ś:`ś`,ṥ:`ṥ`,š:`š`,ṧ:`ṧ`,ŝ:`ŝ`,ṡ:`ṡ`,ş:`ş`,ẗ:`ẗ`,ť:`ť`,ṫ:`ṫ`,ţ:`ţ`,ú:`ú`,ù:`ù`,ü:`ü`,ǘ:`ǘ`,ǜ:`ǜ`,ǖ:`ǖ`,ǚ:`ǚ`,ũ:`ũ`,ṹ:`ṹ`,ū:`ū`,ṻ:`ṻ`,ŭ:`ŭ`,ǔ:`ǔ`,û:`û`,ů:`ů`,ű:`ű`,ṽ:`ṽ`,ẃ:`ẃ`,ẁ:`ẁ`,ẅ:`ẅ`,ŵ:`ŵ`,ẇ:`ẇ`,ẘ:`ẘ`,ẍ:`ẍ`,ẋ:`ẋ`,ý:`ý`,ỳ:`ỳ`,ÿ:`ÿ`,ỹ:`ỹ`,ȳ:`ȳ`,ŷ:`ŷ`,ẏ:`ẏ`,ẙ:`ẙ`,ź:`ź`,ž:`ž`,ẑ:`ẑ`,ż:`ż`,Á:`Á`,À:`À`,Ä:`Ä`,Ǟ:`Ǟ`,Ã:`Ã`,Ā:`Ā`,Ă:`Ă`,Ắ:`Ắ`,Ằ:`Ằ`,Ẵ:`Ẵ`,Ǎ:`Ǎ`,Â:`Â`,Ấ:`Ấ`,Ầ:`Ầ`,Ẫ:`Ẫ`,Ȧ:`Ȧ`,Ǡ:`Ǡ`,Å:`Å`,Ǻ:`Ǻ`,Ḃ:`Ḃ`,Ć:`Ć`,Ḉ:`Ḉ`,Č:`Č`,Ĉ:`Ĉ`,Ċ:`Ċ`,Ç:`Ç`,Ď:`Ď`,Ḋ:`Ḋ`,Ḑ:`Ḑ`,É:`É`,È:`È`,Ë:`Ë`,Ẽ:`Ẽ`,Ē:`Ē`,Ḗ:`Ḗ`,Ḕ:`Ḕ`,Ĕ:`Ĕ`,Ḝ:`Ḝ`,Ě:`Ě`,Ê:`Ê`,Ế:`Ế`,Ề:`Ề`,Ễ:`Ễ`,Ė:`Ė`,Ȩ:`Ȩ`,Ḟ:`Ḟ`,Ǵ:`Ǵ`,Ḡ:`Ḡ`,Ğ:`Ğ`,Ǧ:`Ǧ`,Ĝ:`Ĝ`,Ġ:`Ġ`,Ģ:`Ģ`,Ḧ:`Ḧ`,Ȟ:`Ȟ`,Ĥ:`Ĥ`,Ḣ:`Ḣ`,Ḩ:`Ḩ`,Í:`Í`,Ì:`Ì`,Ï:`Ï`,Ḯ:`Ḯ`,Ĩ:`Ĩ`,Ī:`Ī`,Ĭ:`Ĭ`,Ǐ:`Ǐ`,Î:`Î`,İ:`İ`,Ĵ:`Ĵ`,Ḱ:`Ḱ`,Ǩ:`Ǩ`,Ķ:`Ķ`,Ĺ:`Ĺ`,Ľ:`Ľ`,Ļ:`Ļ`,Ḿ:`Ḿ`,Ṁ:`Ṁ`,Ń:`Ń`,Ǹ:`Ǹ`,Ñ:`Ñ`,Ň:`Ň`,Ṅ:`Ṅ`,Ņ:`Ņ`,Ó:`Ó`,Ò:`Ò`,Ö:`Ö`,Ȫ:`Ȫ`,Õ:`Õ`,Ṍ:`Ṍ`,Ṏ:`Ṏ`,Ȭ:`Ȭ`,Ō:`Ō`,Ṓ:`Ṓ`,Ṑ:`Ṑ`,Ŏ:`Ŏ`,Ǒ:`Ǒ`,Ô:`Ô`,Ố:`Ố`,Ồ:`Ồ`,Ỗ:`Ỗ`,Ȯ:`Ȯ`,Ȱ:`Ȱ`,Ő:`Ő`,Ṕ:`Ṕ`,Ṗ:`Ṗ`,Ŕ:`Ŕ`,Ř:`Ř`,Ṙ:`Ṙ`,Ŗ:`Ŗ`,Ś:`Ś`,Ṥ:`Ṥ`,Š:`Š`,Ṧ:`Ṧ`,Ŝ:`Ŝ`,Ṡ:`Ṡ`,Ş:`Ş`,Ť:`Ť`,Ṫ:`Ṫ`,Ţ:`Ţ`,Ú:`Ú`,Ù:`Ù`,Ü:`Ü`,Ǘ:`Ǘ`,Ǜ:`Ǜ`,Ǖ:`Ǖ`,Ǚ:`Ǚ`,Ũ:`Ũ`,Ṹ:`Ṹ`,Ū:`Ū`,Ṻ:`Ṻ`,Ŭ:`Ŭ`,Ǔ:`Ǔ`,Û:`Û`,Ů:`Ů`,Ű:`Ű`,Ṽ:`Ṽ`,Ẃ:`Ẃ`,Ẁ:`Ẁ`,Ẅ:`Ẅ`,Ŵ:`Ŵ`,Ẇ:`Ẇ`,Ẍ:`Ẍ`,Ẋ:`Ẋ`,Ý:`Ý`,Ỳ:`Ỳ`,Ÿ:`Ÿ`,Ỹ:`Ỹ`,Ȳ:`Ȳ`,Ŷ:`Ŷ`,Ẏ:`Ẏ`,Ź:`Ź`,Ž:`Ž`,Ẑ:`Ẑ`,Ż:`Ż`,ά:`ά`,ὰ:`ὰ`,ᾱ:`ᾱ`,ᾰ:`ᾰ`,έ:`έ`,ὲ:`ὲ`,ή:`ή`,ὴ:`ὴ`,ί:`ί`,ὶ:`ὶ`,ϊ:`ϊ`,ΐ:`ΐ`,ῒ:`ῒ`,ῑ:`ῑ`,ῐ:`ῐ`,ό:`ό`,ὸ:`ὸ`,ύ:`ύ`,ὺ:`ὺ`,ϋ:`ϋ`,ΰ:`ΰ`,ῢ:`ῢ`,ῡ:`ῡ`,ῠ:`ῠ`,ώ:`ώ`,ὼ:`ὼ`,Ύ:`Ύ`,Ὺ:`Ὺ`,Ϋ:`Ϋ`,Ῡ:`Ῡ`,Ῠ:`Ῠ`,Ώ:`Ώ`,Ὼ:`Ὼ`},Ypt=class e{constructor(e,t){this.mode=void 0,this.gullet=void 0,this.settings=void 0,this.leftrightDepth=void 0,this.nextToken=void 0,this.mode=`math`,this.gullet=new Kpt(e,t,this.mode),this.settings=t,this.leftrightDepth=0,this.nextToken=null}expect(e,t){if(t===void 0&&(t=!0),this.fetch().text!==e)throw new l5(`Expected '`+e+`', got '`+this.fetch().text+`'`,this.fetch());t&&this.consume()}consume(){this.nextToken=null}fetch(){return this.nextToken??=this.gullet.expandNextToken(),this.nextToken}switchMode(e){this.mode=e,this.gullet.switchMode(e)}parse(){this.settings.globalGroup||this.gullet.beginGroup(),this.settings.colorIsTextColor&&this.gullet.macros.set(`\\color`,`\\textcolor`);try{var e=this.parseExpression(!1);return this.expect(`EOF`),this.settings.globalGroup||this.gullet.endGroup(),e}finally{this.gullet.endGroups()}}subparse(e){var t=this.nextToken;this.consume(),this.gullet.pushToken(new j9(`}`)),this.gullet.pushTokens(e);var n=this.parseExpression(!1);return this.expect(`}`),this.nextToken=t,n}parseExpression(t,n){for(var r=[];;){this.mode===`math`&&this.consumeSpaces();var i=this.fetch();if(e.endOfExpression.has(i.text)||n&&i.text===n||t&&B9[i.text]&&B9[i.text].infix)break;var a=this.parseAtom(n);if(!a)break;a.type!==`internal`&&r.push(a)}return this.mode===`text`&&this.formLigatures(r),this.handleInfixNodes(r)}handleInfixNodes(e){for(var t=-1,n,r=0;r<e.length;r++){var i=e[r];if(i.type===`infix`){if(t!==-1)throw new l5(`only one infix operator per group`,i.token);t=r,n=i.replaceWith}}if(t!==-1&&n){var a,o,s=e.slice(0,t),c=e.slice(t+1);return a=s.length===1&&s[0].type===`ordgroup`?s[0]:{type:`ordgroup`,mode:this.mode,body:s},o=c.length===1&&c[0].type===`ordgroup`?c[0]:{type:`ordgroup`,mode:this.mode,body:c},[n===`\\\\abovefrac`?this.callFunction(n,[a,e[t],o],[]):this.callFunction(n,[a,o],[])]}return e}handleSupSubscript(e){var t=this.fetch(),n=t.text;this.consume(),this.consumeSpaces();var r;do r=this.parseGroup(e);while(r?.type===`internal`);if(!r)throw new l5(`Expected group after '`+n+`'`,t);return r}formatUnsupportedCmd(e){for(var t=[],n=0;n<e.length;n++)t.push({type:`textord`,mode:`text`,text:e[n]});var r={type:`text`,mode:this.mode,body:t};return{type:`color`,mode:this.mode,color:this.settings.errorColor,body:[r]}}parseAtom(e){var t=this.parseGroup(`atom`,e);if(t?.type===`internal`||this.mode===`text`)return t;for(var n,r;;){this.consumeSpaces();var i=this.fetch();if(i.text===`\\limits`||i.text===`\\nolimits`){if(t&&t.type===`op`)t.limits=i.text===`\\limits`,t.alwaysHandleSupSub=!0;else if(t&&t.type===`operatorname`)t.alwaysHandleSupSub&&(t.limits=i.text===`\\limits`);else throw new l5(`Limit controls must follow a math operator`,i);this.consume()}else if(i.text===`^`){if(n)throw new l5(`Double superscript`,i);n=this.handleSupSubscript(`superscript`)}else if(i.text===`_`){if(r)throw new l5(`Double subscript`,i);r=this.handleSupSubscript(`subscript`)}else if(i.text===`'`){if(n)throw new l5(`Double superscript`,i);var a={type:`textord`,mode:this.mode,text:`\\prime`},o=[a];for(this.consume();this.fetch().text===`'`;)o.push(a),this.consume();this.fetch().text===`^`&&o.push(this.handleSupSubscript(`superscript`)),n={type:`ordgroup`,mode:this.mode,body:o}}else if(W9[i.text]){var s=qpt.test(i.text),c=[];for(c.push(new j9(W9[i.text])),this.consume();;){var l=this.fetch().text;if(!W9[l]||qpt.test(l)!==s)break;c.unshift(new j9(W9[l])),this.consume()}var u=this.subparse(c);s?r={type:`ordgroup`,mode:`math`,body:u}:n={type:`ordgroup`,mode:`math`,body:u}}else break}return n&&r?{type:`supsub`,mode:this.mode,base:t,sup:n,sub:r}:n?{type:`supsub`,mode:this.mode,base:t,sup:n}:r?{type:`supsub`,mode:this.mode,base:t,sub:r}:t}parseFunction(e,t){var n=this.fetch(),r=n.text,i=B9[r];if(!i)return null;if(this.consume(),t&&t!==`atom`&&!i.allowedInArgument)throw new l5(`Got function '`+r+`' with no arguments`+(t?` as `+t:``),n);if(this.mode===`text`&&!i.allowedInText)throw new l5(`Can't use function '`+r+`' in text mode`,n);if(this.mode===`math`&&i.allowedInMath===!1)throw new l5(`Can't use function '`+r+`' in math mode`,n);var a=this.parseArguments(r,i),o=a.args,s=a.optArgs;return this.callFunction(r,o,s,n,e)}callFunction(e,t,n,r,i){var a={funcName:e,parser:this,token:r,breakOnTokenText:i},o=B9[e];if(o&&o.handler)return o.handler(a,t,n);throw new l5(`No function handler for `+e)}parseArguments(e,t){var n=t.numOptionalArgs??0,r=t.numArgs+n;if(r===0)return{args:[],optArgs:[]};for(var i=[],a=[],o=0;o<r;o++){var s=t.argTypes?.[o],c=o<n;(`primitive`in t&&t.primitive&&s==null||t.type===`sqrt`&&o===1&&a[0]==null)&&(s=`primitive`);var l=this.parseGroupOfType(`argument to '`+e+`'`,s,c);if(c)a.push(l);else if(l!=null)i.push(l);else throw new l5(`Null argument, please report this as a bug`)}return{args:i,optArgs:a}}parseGroupOfType(e,t,n){switch(t){case`color`:return this.parseColorGroup(n);case`size`:return this.parseSizeGroup(n);case`url`:return this.parseUrlGroup(n);case`math`:case`text`:return this.parseArgumentGroup(n,t);case`hbox`:var r=this.parseArgumentGroup(n,`text`);return r==null?null:{type:`styling`,mode:r.mode,body:[r],style:`text`,resetFont:!0};case`raw`:this.gullet.consumeSpaces();var i=this.gullet.lexer.catcodes[`%`];this.gullet.lexer.setCatcode(`%`,12);var a=this.parseStringGroup(n);return this.gullet.lexer.setCatcode(`%`,i),a==null?null:{type:`raw`,mode:`text`,string:a.text};case`primitive`:if(n)throw new l5(`A primitive argument cannot be optional`);var o=this.parseGroup(e);if(o==null)throw new l5(`Expected group as `+e,this.fetch());return o;case`original`:case void 0:return this.parseArgumentGroup(n);default:throw new l5(`Unknown group type as `+e,this.fetch())}}consumeSpaces(){for(;this.fetch().text===` `;)this.consume()}parseStringGroup(e){var t=this.gullet.scanArgument(e);if(t==null)return null;for(var n=``,r;(r=this.fetch()).text!==`EOF`;)n+=r.text,this.consume();return this.consume(),t.text=n,t}parseRegexGroup(e,t){for(var n=this.fetch(),r=n,i=``,a;(a=this.fetch()).text!==`EOF`&&e.test(i+a.text);)r=a,i+=r.text,this.consume();if(i===``)throw new l5(`Invalid `+t+`: '`+n.text+`'`,n);return n.range(r,i)}parseColorGroup(e){var t=this.parseStringGroup(e);if(t==null)return null;var n=/^(#[a-f0-9]{3,4}|#[a-f0-9]{6}|#[a-f0-9]{8}|[a-f0-9]{6}|[a-z]+)$/i.exec(t.text);if(!n)throw new l5(`Invalid color: '`+t.text+`'`,t);var r=n[0];return/^[0-9a-f]{6}$/i.test(r)&&(r=`#`+r),{type:`color-token`,mode:this.mode,color:r}}parseSizeGroup(e){var t,n=!1;if(this.gullet.consumeSpaces(),t=!e&&this.gullet.future().text!==`{`?this.parseRegexGroup(/^[-+]? *(?:$|\d+|\d+\.\d*|\.\d*) *[a-z]{0,2} *$/,`size`):this.parseStringGroup(e),!t)return null;!e&&t.text.length===0&&(t.text=`0pt`,n=!0);var r=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(t.text);if(!r)throw new l5(`Invalid size: '`+t.text+`'`,t);var i={number:+(r[1]+r[2]),unit:r[3]};if(!Zut(i))throw new l5(`Invalid unit: '`+i.unit+`'`,t);return{type:`size`,mode:this.mode,value:i,isBlank:n}}parseUrlGroup(e){var t=this.gullet.lexer.catcodes[`%`],n=this.gullet.lexer.catcodes[`~`];this.gullet.lexer.setCatcode(`%`,13),this.gullet.lexer.setCatcode(`~`,12);var r=this.parseStringGroup(e);if(this.gullet.lexer.setCatcode(`%`,t),this.gullet.lexer.setCatcode(`~`,n),r==null)return null;var i=r.text.replace(/\\([#$%&~_^{}])/g,`$1`);return{type:`url`,mode:this.mode,url:i}}parseArgumentGroup(e,t){var n=this.gullet.scanArgument(e);if(n==null)return null;var r=this.mode;t&&this.switchMode(t),this.gullet.beginGroup();var i=this.parseExpression(!1,`EOF`);this.expect(`EOF`),this.gullet.endGroup();var a={type:`ordgroup`,mode:this.mode,loc:n.loc,body:i};return t&&this.switchMode(r),a}parseGroup(e,t){var n=this.fetch(),r=n.text,i;if(r===`{`||r===`\\begingroup`){this.consume();var a=r===`{`?`}`:`\\endgroup`;this.gullet.beginGroup();var o=this.parseExpression(!1,a),s=this.fetch();this.expect(a),this.gullet.endGroup(),i={type:`ordgroup`,mode:this.mode,loc:A9.range(n,s),body:o,semisimple:r===`\\begingroup`||void 0}}else if(i=this.parseFunction(t,e)||this.parseSymbol(),i==null&&r[0]===`\\`&&!Object.prototype.hasOwnProperty.call(Gpt,r)){if(this.settings.throwOnError)throw new l5(`Undefined control sequence: `+r,n);i=this.formatUnsupportedCmd(r),this.consume()}return i}formLigatures(e){for(var t=e.length-1,n=0;n<t;++n){var r=e[n];if(r.type===`textord`){var i=r.text,a=e[n+1];if(a&&a.type===`textord`){if(i===`-`&&a.text===`-`){var o=e[n+2];n+1<t&&o&&o.type===`textord`&&o.text===`-`?(e.splice(n,3,{type:`textord`,mode:`text`,loc:A9.range(r,o),text:`---`}),t-=2):(e.splice(n,2,{type:`textord`,mode:`text`,loc:A9.range(r,a),text:`--`}),--t)}(i===`'`||i==="`")&&a.text===i&&(e.splice(n,2,{type:`textord`,mode:`text`,loc:A9.range(r,a),text:i+i}),--t)}}}}parseSymbol(){var e=this.fetch(),t=e.text;if(/^\\verb[^a-zA-Z]/.test(t)){this.consume();var n=t.slice(5),r=n.charAt(0)===`*`;if(r&&(n=n.slice(1)),n.length<2||n.charAt(0)!==n.slice(-1))throw new l5(`\\verb assertion failed --
927
927
  please report what input caused this bug`);return n=n.slice(1,-1),{type:`verb`,mode:`text`,body:n,star:r}}Object.prototype.hasOwnProperty.call(Jpt,t[0])&&!K5[this.mode][t[0]]&&(this.settings.strict&&this.mode===`math`&&x7({strict:this.settings.strict,errorCode:`unicodeTextInMathMode`,errorMsg:`Accented Unicode text character "`+t[0]+`" used in math mode`,report:!0,token:e}),t=Jpt[t[0]]+t.slice(1));var i=Fpt.exec(t);i&&(t=t.substring(0,i.index),t===`i`?t=`ı`:t===`j`&&(t=`ȷ`));var a;if(K5[this.mode][t]){this.settings.strict&&this.mode===`math`&&p7.includes(t)&&x7({strict:this.settings.strict,errorCode:`unicodeTextInMathMode`,errorMsg:`Latin-1/Unicode text character "`+t[0]+`" used in math mode`,report:!0,token:e});var o=K5[this.mode][t].group,s=A9.range(e);a=lft(o)?{type:`atom`,mode:this.mode,family:o,loc:s,text:t}:{type:o,mode:this.mode,loc:s,text:t}}else if(t.charCodeAt(0)>=128)this.settings.strict&&(Lut(t.charCodeAt(0))?this.mode===`math`&&x7({strict:this.settings.strict,errorCode:`unicodeTextInMathMode`,errorMsg:`Unicode text character "`+t[0]+`" used in math mode`,report:!0,token:e}):x7({strict:this.settings.strict,errorCode:`unknownSymbol`,errorMsg:`Unrecognized Unicode character "`+t[0]+`"`+(` (`+t.charCodeAt(0)+`)`),report:!0,token:e})),a={type:`textord`,mode:`text`,loc:A9.range(e),text:t};else return null;if(this.consume(),i)for(var c=0;c<i[0].length;c++){var l=i[0][c];if(!G9[l])throw new l5(`Unknown accent ' `+l+`'`,e);var u=G9[l][this.mode]||G9[l].text;if(!u)throw new l5(`Accent `+l+` unsupported in `+this.mode+` mode`,e);a={type:`accent`,mode:this.mode,loc:A9.range(e),label:u,isStretchy:!1,isShifty:!0,base:a}}return a}};Ypt.endOfExpression=/* @__PURE__ */ new Set([`}`,`\\endgroup`,`\\end`,`\\right`,`&`]);var K9=function(e,t){if(!(typeof e==`string`||e instanceof String))throw TypeError(`KaTeX can only parse string typed expression`);var n=new Ypt(e,t);delete n.gullet.macros.current[`\\df@tag`];var r=n.parse();if(delete n.gullet.macros.current[`\\current@color`],delete n.gullet.macros.current[`\\color`],n.gullet.macros.get(`\\df@tag`)){if(!t.displayMode)throw new l5(`\\tag works only in display equations`);r=[{type:`tag`,mode:`text`,body:r,tag:n.subparse([new j9(`\\df@tag`)])}]}return r},Xpt=function(e,t,n){t.textContent=``;var r=q9(e,n).toNode();t.appendChild(r)};typeof document<`u`&&document.compatMode!==`CSS1Compat`&&(typeof console<`u`&&console.warn(`Warning: KaTeX doesn't work in quirks mode. Make sure your website has a suitable doctype.`),Xpt=function(){throw new l5(`KaTeX doesn't work in quirks mode.`)});var Zpt=function(e,t){return q9(e,t).toMarkup()},Qpt=function(e,t){return K9(e,new m5(t))},$pt=function(e,t,n){if(n.throwOnError||!(e instanceof l5))throw e;var r=D7([`katex-error`],[new R5(t)]);return r.setAttribute(`title`,e.toString()),r.setAttribute(`style`,`color:`+n.errorColor),r},q9=function(e,t){var n=new m5(t);try{return $dt(K9(e,n),e,n)}catch(t){return $pt(t,e,n)}},emt={version:`0.19.1`,render:Xpt,renderToString:Zpt,ParseError:l5,SETTINGS_SCHEMA:p5,__parse:Qpt,__renderToDomTree:q9,__renderToHTMLTree:function(e,t){var n=new m5(t);try{return eft(K9(e,n),n)}catch(t){return $pt(t,e,n)}},__setFontMetrics:cdt,__defineSymbol:q,__defineFunction:B7,__defineMacro:$,__domTree:{Span:I5,Anchor:L5,SymbolNode:R5,SvgNode:z5,PathNode:B5,LineNode:V5}};const tmt=/̲/g,nmt=e=>e instanceof Error?e.message:String(e),rmt=e=>e.split(`
928
- `).map(e=>e.trim()).filter(e=>e&&!/^[-^]+$/.test(e)).join(` `);function imt(e){let t=nR(e);return t.ok?[]:t.issues.map(e=>({tag:`chart`,text:`shows an error instead of the chart: ${e.path===`(root)`?`the spec`:e.path} ${e.message}${e.hint?`. ${e.hint}`:``}`}))}function amt(e){if(!e.trim())return[];try{return but(e),[]}catch(e){return[{tag:`mermaid`,text:`shows an error instead of the diagram: ${rmt(nmt(e))}`}]}}function omt(e,t){try{return emt.renderToString(e,{displayMode:t,throwOnError:!0,strict:`ignore`}),[]}catch(e){return[{tag:`math`,text:`shows a red error instead of the formula: ${nmt(e).replaceAll(tmt,``)}`}]}}function smt(e){return[...e.type===`chart`?imt(e.spec??``):e.type===`mermaid`?amt(e.diagram??``):e.type===`katex-block`||e.type===`katex-inline`?omt(e.equation??``,e.type===`katex-block`):[],...(e.children??[]).flatMap(smt)]}function cmt(e){return e.root.children.flatMap(e=>{let t=e.$?.blockId;if(!t)return[];let n=smt(e),r=n.slice(0,3).map(e=>`block ${t}: <${e.tag}> ${e.text}`),i=n.slice(3);return i.length&&r.push(`block ${t}: <${i[0].tag}> has ${i.length} more problems; fix these first and run check again`),r})}const lmt=e=>IXe(e).map(e=>`block ${e} draws a diagram with box-drawing characters; this document is rendered, not Markdown, so draw it as <mermaid>`),J9=e=>[...lmt(e),...cmt(e)];function umt(e,t=J9(e)){let n=e.root.children.flatMap(e=>e.$?.blockId?[e.$.blockId]:[]);return{title:LXe(e),refs:oXe(e),asks:KYe(e),blocks:n,warnings:t}}async function dmt(e,t){let n=await p.default.readFile(e,`utf8`);try{return{summary:umt(ZQe(Iq(n),{idOf:(e,n=`artboard`)=>w(t,n,e)}))}}catch(e){return{error:e instanceof Error?e.message:String(e)}}}function fmt(e){let t=J9(e.state()),n=``,r=()=>umt(e.state(),t);return{current:r,recheck:()=>{t=J9(e.state())},changed:()=>{let e=r(),t=JSON.stringify(e);if(t!==n)return n=t,e}}}const Y9=({session:e,summary:t})=>{let n=t.changed();return{agentActiveAt:e.agentActiveAt(),lineage:e.lineage(),outcome:e.outcome(),streaming:e.streaming(),...n?{summary:n}:{}}},pmt=/* @__PURE__ */ new Set([`flush`,`settled`]),mmt=e=>({name:e instanceof NX?`OutdatedClient`:`Error`,message:e instanceof Error?e.message:String(e)});function hmt(e){let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map,r=e=>{let t=n.get(e);return t||(t={idOf:(t,n=`artboard`)=>w(e,n,t)},n.set(e,t)),t},i=(t,n)=>e.send({op:`reply`,rid:t,ok:!1,error:mmt(n)}),a=async n=>{if(n.op===`open`){try{let i=r(n.root),a=await XQe({file:n.file,snapshotFile:n.snapshotFile,writeDelayMs:n.writeDelayMs,snapshotIntervalMs:n.snapshotIntervalMs,fillRefs:e=>ZQe(e,i),log:t=>e.send({op:`log`,sid:n.sid,line:t})}),o={session:a,summary:fmt(a)};t.set(n.sid,o),a.subscribe(t=>{t.type!==`update`&&o.summary.recheck(),e.send({op:`event`,sid:n.sid,event:t,mirror:Y9(o)})}),e.send({op:`reply`,rid:n.rid,ok:!0,value:null,mirror:Y9(o)})}catch(e){i(n.rid,e)}return}if(n.op===`read`){try{e.send({op:`reply`,rid:n.rid,ok:!0,value:await dmt(n.file,n.root)})}catch(e){i(n.rid,e)}return}if(n.op===`trees`||n.op===`taskPrompt`||n.op===`charts`){try{let t=n.op===`trees`?_$e(n.xmls):n.op===`charts`?JBe(n.sources):g$e(n.input);e.send({op:`reply`,rid:n.rid,ok:!0,value:t})}catch(e){i(n.rid,e)}return}if(n.op===`shutdown`){await Promise.all([...t.values()].map(({session:e})=>e.close().catch(()=>void 0))),t.clear(),e.send({op:`reply`,rid:n.rid,ok:!0,value:null});return}let a=t.get(n.sid),o=a?.session;if(n.op===`cast`)n.method===`onFileText`?o?.onFileText(n.args[0]):o?.refreshRefs();else if(!a||!o)i(n.rid,/* @__PURE__ */ Error(`this document was closed; reload the page`));else try{let r=await o[n.method](...n.args);n.method===`close`?(t.delete(n.sid),e.send({op:`reply`,rid:n.rid,ok:!0,value:null})):(pmt.has(n.method)&&a.summary.recheck(),e.send({op:`reply`,rid:n.rid,ok:!0,value:r,mirror:Y9(a)}))}catch(e){i(n.rid,e)}};return e.on(`message`,e=>void a(e)),{sessions:()=>t.size,shutdown:async()=>{await Promise.all([...t.values()].map(({session:e})=>e.close().catch(()=>void 0))),t.clear()}}}function gmt(e,t){let n=Buffer.from(JSON.stringify(e),`utf8`),r=t?.length??0,i=Buffer.allocUnsafe(8+n.length+r);return i.writeUInt32BE(4+n.length+r,0),i.writeUInt32BE(n.length,4),n.copy(i,8),t?.length&&i.set(t,8+n.length),i}function _mt(e,t={}){let n=t.maxFrameBytes??268435456,r=Buffer.alloc(0);return t=>{for(r=r.length?Buffer.concat([r,t]):t;r.length>=4;){let t=r.readUInt32BE(0);if(t>n)throw Error(`frame of ${t} bytes is too large`);if(r.length<4+t)return;let i=r.readUInt32BE(4);if(i>t-4)throw Error(`frame header is longer than its frame`);let a=JSON.parse(r.toString(`utf8`,8,8+i)),o=t-4-i?new Uint8Array(r.subarray(8+i,4+t)):null;r=r.subarray(4+t),e(a,o)}}}const vmt=`$tail`;function X9(e,t){if(e instanceof Uint8Array){if(t.bytes)throw Error(`a message can carry one binary value`);return t.bytes=e,{[vmt]:!0}}if(Array.isArray(e))return e.map(e=>X9(e,t));if(e&&typeof e==`object`){let n={};for(let[r,i]of Object.entries(e))n[r]=X9(i,t);return n}return e}function Z9(e,t){if(Array.isArray(e))return e.map(e=>Z9(e,t));if(e&&typeof e==`object`){if(e[vmt]===!0)return t;let n={};for(let[r,i]of Object.entries(e))n[r]=Z9(i,t);return n}return e}function ymt(e){let t={bytes:null},n=X9(e,t);return t.bytes?{header:n,tail:t.bytes}:{header:n}}function bmt(e,t){return t?Z9(e,t):e}function xmt(e){let t=u.default.lstatSync(e),n=process.getuid?.();if(!t.isDirectory()||n!==void 0&&t.uid!==n||t.mode&18)throw Error(`the document engine socket directory ${e} is not private`)}const Q9=e=>e.startsWith(`\\\\`);function Smt(e){return new Promise(t=>{let n=d.default.connect(e);n.once(`connect`,()=>{n.destroy(),t(!0)}),n.once(`error`,()=>t(!1))})}function Cmt(e,t){return new Promise((n,r)=>{let i=t=>{e.off(`listening`,a),r(t)},a=()=>{e.off(`error`,i),n()};e.once(`error`,i).once(`listening`,a),e.listen(t)})}async function wmt(e){let{socketPath:t,version:n}=e,r=e.idleMs??6e4,i=/* @__PURE__ */ new Map,a=d.default.createServer(),o=null,s,c=(e,t)=>{if(e.destroyed)return;let{header:n,tail:r}=ymt(t);e.write(gmt(n,r))},l=()=>(o??=(async()=>{clearTimeout(s),await Promise.all([...i].map(async([e,t])=>{await t.shutdown(),e.end()})),await new Promise(e=>a.close(()=>e())),Q9(t)||u.default.rmSync(t,{force:!0}),e.onExit?.()})(),o),p=()=>{clearTimeout(s),i.size>0||o||(s=setTimeout(()=>{i.size===0&&l()},r))};a.on(`connection`,e=>{clearTimeout(s);let t=/* @__PURE__ */ new Set,r=hmt({on:(e,n)=>t.add(n),send:t=>c(e,t)});i.set(e,r);let a=_mt((r,i)=>{let a=bmt(r,i);a.op===`hello`?c(e,{op:`reply`,rid:a.rid,ok:!0,value:{version:n,pid:process.pid}}):a.op===`shutdown`?(c(e,{op:`reply`,rid:a.rid,ok:!0,value:null}),l()):t.forEach(e=>e(a))});e.on(`data`,t=>{try{a(t)}catch{e.destroy()}}),e.on(`error`,()=>void 0),e.on(`close`,()=>{r.shutdown().finally(()=>{i.delete(e),p()})})}),Q9(t)||(u.default.mkdirSync(f.default.dirname(t),{recursive:!0,mode:448}),xmt(f.default.dirname(t)));try{await Cmt(a,t)}catch(e){if(e.code!==`EADDRINUSE`||Q9(t))throw e;if(await Smt(t))throw Error(`a document engine is already running at ${t}`,{cause:e});u.default.rmSync(t,{force:!0}),await Cmt(a,t)}return Q9(t)||u.default.chmodSync(t,384),p(),{close:l,connections:()=>i.size}}var Tmt=`1.108.6`;const Emt=e=>{let t=process.env.RYUGI_PROCESS_TAG?.trim();return`Ryugi ${e} (${Tmt}${t?` · ${t}`:``})`},Dmt=process.platform!==`win32`;function Omt(e,...t){Dmt&&(process.title=[Emt(e),...t].join(` `))}const $9=e=>{let t=process.argv.indexOf(e);return t===-1?void 0:process.argv[t+1]},kmt=$9(`--socket`),Amt=$9(`--version`);kmt&&Amt||(console.error(`usage: document-engine --socket <path> --version <version>`),process.exit(2)),Omt(`document-engine`);for(let e of[`SIGINT`,`SIGHUP`,`SIGTERM`])process.on(e,()=>{});const jmt=$9(`--idle-ms`);wmt({socketPath:kmt,version:Amt,...jmt?{idleMs:Number(jmt)}:{},onExit:()=>process.exit(0)}).catch(e=>{console.error(e.message),process.exit(+!e.message.includes(`already running`))});
928
+ `).map(e=>e.trim()).filter(e=>e&&!/^[-^]+$/.test(e)).join(` `);function imt(e){let t=nR(e);return t.ok?[]:t.issues.map(e=>({tag:`chart`,text:`shows an error instead of the chart: ${e.path===`(root)`?`the spec`:e.path} ${e.message}${e.hint?`. ${e.hint}`:``}`}))}function amt(e){if(!e.trim())return[];try{return but(e),[]}catch(e){return[{tag:`mermaid`,text:`shows an error instead of the diagram: ${rmt(nmt(e))}`}]}}function omt(e,t){try{return emt.renderToString(e,{displayMode:t,throwOnError:!0,strict:`ignore`}),[]}catch(e){return[{tag:`math`,text:`shows a red error instead of the formula: ${nmt(e).replaceAll(tmt,``)}`}]}}function smt(e){return[...e.type===`chart`?imt(e.spec??``):e.type===`mermaid`?amt(e.diagram??``):e.type===`katex-block`||e.type===`katex-inline`?omt(e.equation??``,e.type===`katex-block`):[],...(e.children??[]).flatMap(smt)]}function cmt(e){return e.root.children.flatMap(e=>{let t=e.$?.blockId;if(!t)return[];let n=smt(e),r=n.slice(0,3).map(e=>`block ${t}: <${e.tag}> ${e.text}`),i=n.slice(3);return i.length&&r.push(`block ${t}: <${i[0].tag}> has ${i.length} more problems; fix these first and run check again`),r})}const lmt=e=>IXe(e).map(e=>`block ${e} draws a diagram with box-drawing characters; this document is rendered, not Markdown, so draw it as <mermaid>`),J9=e=>[...lmt(e),...cmt(e)];function umt(e,t=J9(e)){let n=e.root.children.flatMap(e=>e.$?.blockId?[e.$.blockId]:[]);return{title:LXe(e),refs:oXe(e),asks:KYe(e),blocks:n,warnings:t}}async function dmt(e,t){let n=await p.default.readFile(e,`utf8`);try{return{summary:umt(ZQe(Iq(n),{idOf:(e,n=`artboard`)=>w(t,n,e)}))}}catch(e){return{error:e instanceof Error?e.message:String(e)}}}function fmt(e){let t=J9(e.state()),n=``,r=()=>umt(e.state(),t);return{current:r,recheck:()=>{t=J9(e.state())},changed:()=>{let e=r(),t=JSON.stringify(e);if(t!==n)return n=t,e}}}const Y9=({session:e,summary:t})=>{let n=t.changed();return{agentActiveAt:e.agentActiveAt(),lineage:e.lineage(),outcome:e.outcome(),streaming:e.streaming(),...n?{summary:n}:{}}},pmt=/* @__PURE__ */ new Set([`flush`,`settled`]),mmt=e=>({name:e instanceof NX?`OutdatedClient`:`Error`,message:e instanceof Error?e.message:String(e)});function hmt(e){let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map,r=e=>{let t=n.get(e);return t||(t={idOf:(t,n=`artboard`)=>w(e,n,t)},n.set(e,t)),t},i=(t,n)=>e.send({op:`reply`,rid:t,ok:!1,error:mmt(n)}),a=async n=>{if(n.op===`open`){try{let i=r(n.root),a=await XQe({file:n.file,snapshotFile:n.snapshotFile,writeDelayMs:n.writeDelayMs,snapshotIntervalMs:n.snapshotIntervalMs,fillRefs:e=>ZQe(e,i),log:t=>e.send({op:`log`,sid:n.sid,line:t})}),o={session:a,summary:fmt(a)};t.set(n.sid,o),a.subscribe(t=>{t.type!==`update`&&o.summary.recheck(),e.send({op:`event`,sid:n.sid,event:t,mirror:Y9(o)})}),e.send({op:`reply`,rid:n.rid,ok:!0,value:null,mirror:Y9(o)})}catch(e){i(n.rid,e)}return}if(n.op===`read`){try{e.send({op:`reply`,rid:n.rid,ok:!0,value:await dmt(n.file,n.root)})}catch(e){i(n.rid,e)}return}if(n.op===`trees`||n.op===`taskPrompt`||n.op===`charts`){try{let t=n.op===`trees`?_$e(n.xmls):n.op===`charts`?JBe(n.sources):g$e(n.input);e.send({op:`reply`,rid:n.rid,ok:!0,value:t})}catch(e){i(n.rid,e)}return}if(n.op===`shutdown`){await Promise.all([...t.values()].map(({session:e})=>e.close().catch(()=>void 0))),t.clear(),e.send({op:`reply`,rid:n.rid,ok:!0,value:null});return}let a=t.get(n.sid),o=a?.session;if(n.op===`cast`)n.method===`onFileText`?o?.onFileText(n.args[0]):o?.refreshRefs();else if(!a||!o)i(n.rid,/* @__PURE__ */ Error(`this document was closed; reload the page`));else try{let r=await o[n.method](...n.args);n.method===`close`?(t.delete(n.sid),e.send({op:`reply`,rid:n.rid,ok:!0,value:null})):(pmt.has(n.method)&&a.summary.recheck(),e.send({op:`reply`,rid:n.rid,ok:!0,value:r,mirror:Y9(a)}))}catch(e){i(n.rid,e)}};return e.on(`message`,e=>void a(e)),{sessions:()=>t.size,shutdown:async()=>{await Promise.all([...t.values()].map(({session:e})=>e.close().catch(()=>void 0))),t.clear()}}}function gmt(e,t){let n=Buffer.from(JSON.stringify(e),`utf8`),r=t?.length??0,i=Buffer.allocUnsafe(8+n.length+r);return i.writeUInt32BE(4+n.length+r,0),i.writeUInt32BE(n.length,4),n.copy(i,8),t?.length&&i.set(t,8+n.length),i}function _mt(e,t={}){let n=t.maxFrameBytes??268435456,r=Buffer.alloc(0);return t=>{for(r=r.length?Buffer.concat([r,t]):t;r.length>=4;){let t=r.readUInt32BE(0);if(t>n)throw Error(`frame of ${t} bytes is too large`);if(r.length<4+t)return;let i=r.readUInt32BE(4);if(i>t-4)throw Error(`frame header is longer than its frame`);let a=JSON.parse(r.toString(`utf8`,8,8+i)),o=t-4-i?new Uint8Array(r.subarray(8+i,4+t)):null;r=r.subarray(4+t),e(a,o)}}}const vmt=`$tail`;function X9(e,t){if(e instanceof Uint8Array){if(t.bytes)throw Error(`a message can carry one binary value`);return t.bytes=e,{[vmt]:!0}}if(Array.isArray(e))return e.map(e=>X9(e,t));if(e&&typeof e==`object`){let n={};for(let[r,i]of Object.entries(e))n[r]=X9(i,t);return n}return e}function Z9(e,t){if(Array.isArray(e))return e.map(e=>Z9(e,t));if(e&&typeof e==`object`){if(e[vmt]===!0)return t;let n={};for(let[r,i]of Object.entries(e))n[r]=Z9(i,t);return n}return e}function ymt(e){let t={bytes:null},n=X9(e,t);return t.bytes?{header:n,tail:t.bytes}:{header:n}}function bmt(e,t){return t?Z9(e,t):e}function xmt(e){let t=u.default.lstatSync(e),n=process.getuid?.();if(!t.isDirectory()||n!==void 0&&t.uid!==n||t.mode&18)throw Error(`the document engine socket directory ${e} is not private`)}const Q9=e=>e.startsWith(`\\\\`);function Smt(e){return new Promise(t=>{let n=d.default.connect(e);n.once(`connect`,()=>{n.destroy(),t(!0)}),n.once(`error`,()=>t(!1))})}function Cmt(e,t){return new Promise((n,r)=>{let i=t=>{e.off(`listening`,a),r(t)},a=()=>{e.off(`error`,i),n()};e.once(`error`,i).once(`listening`,a),e.listen(t)})}async function wmt(e){let{socketPath:t,version:n}=e,r=e.idleMs??6e4,i=/* @__PURE__ */ new Map,a=d.default.createServer(),o=null,s,c=(e,t)=>{if(e.destroyed)return;let{header:n,tail:r}=ymt(t);e.write(gmt(n,r))},l=()=>(o??=(async()=>{clearTimeout(s),await Promise.all([...i].map(async([e,t])=>{await t.shutdown(),e.end()})),await new Promise(e=>a.close(()=>e())),Q9(t)||u.default.rmSync(t,{force:!0}),e.onExit?.()})(),o),p=()=>{clearTimeout(s),i.size>0||o||(s=setTimeout(()=>{i.size===0&&l()},r))};a.on(`connection`,e=>{clearTimeout(s);let t=/* @__PURE__ */ new Set,r=hmt({on:(e,n)=>t.add(n),send:t=>c(e,t)});i.set(e,r);let a=_mt((r,i)=>{let a=bmt(r,i);a.op===`hello`?c(e,{op:`reply`,rid:a.rid,ok:!0,value:{version:n,pid:process.pid}}):a.op===`shutdown`?(c(e,{op:`reply`,rid:a.rid,ok:!0,value:null}),l()):t.forEach(e=>e(a))});e.on(`data`,t=>{try{a(t)}catch{e.destroy()}}),e.on(`error`,()=>void 0),e.on(`close`,()=>{r.shutdown().finally(()=>{i.delete(e),p()})})}),Q9(t)||(u.default.mkdirSync(f.default.dirname(t),{recursive:!0,mode:448}),xmt(f.default.dirname(t)));try{await Cmt(a,t)}catch(e){if(e.code!==`EADDRINUSE`||Q9(t))throw e;if(await Smt(t))throw Error(`a document engine is already running at ${t}`,{cause:e});u.default.rmSync(t,{force:!0}),await Cmt(a,t)}return Q9(t)||u.default.chmodSync(t,384),p(),{close:l,connections:()=>i.size}}var Tmt=`1.108.7`;const Emt=e=>{let t=process.env.RYUGI_PROCESS_TAG?.trim();return`Ryugi ${e} (${Tmt}${t?` · ${t}`:``})`},Dmt=process.platform!==`win32`;function Omt(e,...t){Dmt&&(process.title=[Emt(e),...t].join(` `))}const $9=e=>{let t=process.argv.indexOf(e);return t===-1?void 0:process.argv[t+1]},kmt=$9(`--socket`),Amt=$9(`--version`);kmt&&Amt||(console.error(`usage: document-engine --socket <path> --version <version>`),process.exit(2)),Omt(`document-engine`);for(let e of[`SIGINT`,`SIGHUP`,`SIGTERM`])process.on(e,()=>{});const jmt=$9(`--idle-ms`);wmt({socketPath:kmt,version:Amt,...jmt?{idleMs:Number(jmt)}:{},onExit:()=>process.exit(0)}).catch(e=>{console.error(e.message),process.exit(+!e.message.includes(`already running`))});
@@ -0,0 +1,93 @@
1
+ Copyright 2022 The Figtree Project Authors (https://github.com/erikdkennedy/figtree)
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+ This license is copied below, and is also available with a FAQ at:
5
+ http://scripts.sil.org/OFL
6
+
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting -- in part or in whole -- any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION & CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.
@@ -1,4 +1,4 @@
1
- (function(){function e(e,t={},...n){let r=document.createElement(e);for(let[e,n]of Object.entries(t))n!=null&&n!==!1&&r.setAttribute(e,n===!0?``:String(n));for(let e of n)e!=null&&e!==!1&&r.append(typeof e==`string`?document.createTextNode(e):e);return r}function t(e){console.warn(`[ryugi-mockup] ${e}`),window.dispatchEvent(new ErrorEvent(`error`,{message:`[ryugi-mockup] ${e}`}))}var n=class e extends HTMLElement{static base=[`appearance`];static attrs=[];static get observedAttributes(){let t=this;return[...e.base,...t.attrs]}source=null;#e=!1;connectedCallback(){this.source||=[...this.childNodes],this.render()}attributeChangedCallback(e,t,n){t!==n&&this.source&&this.isConnected&&this.render()}authored(e){return(this.source??[]).filter(t=>t instanceof Element&&(!e||t.localName===e))}attr(e,t=``){return this.getAttribute(e)??t}flag(e){let t=this.getAttribute(e);return t!==null&&t!==`false`}appearance(){let e=this.getAttribute(`appearance`);if(e===`light`||e===`dark`)return e;let t=(this.parentElement?.closest(`[data-appearance]`))?.getAttribute(`data-appearance`);return t===`light`||t===`dark`?t:typeof matchMedia==`function`&&matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}render(){if(!this.#e){this.#e=!0;try{let e=this.appearance();this.classList.add(`ryugi-mockup`),this.dataset.appearance=e;let t=this.build();this.replaceChildren(...Array.isArray(t)?t:[t])}finally{this.#e=!1}}}};let r={signal:`<svg width="18" height="12" viewBox="0 0 18 12" fill="currentColor"><rect y="7.8" width="3.2" height="3.6" rx="1"/><rect x="4.8" y="5.6" width="3.2" height="5.8" rx="1"/><rect x="9.6" y="3.2" width="3.2" height="8.2" rx="1"/><rect x="14.4" y=".4" width="3.2" height="11" rx="1"/></svg>`,wifi:`<svg width="17" height="12" viewBox="0 0 17 12" fill="currentColor"><path d="M8.5 11.4L6.31 9.21A3.1 3.1 0 0 1 10.69 9.21ZM3.69 6.59A6.8 6.8 0 0 1 13.31 6.59L12.25 7.65A5.3 5.3 0 0 0 4.75 7.65ZM1.08 3.98A10.5 10.5 0 0 1 15.92 3.98L14.86 5.04A9 9 0 0 0 2.14 5.04Z" stroke="currentColor" stroke-linejoin="round"/></svg>`,battery:`<svg width="27" height="13" viewBox="0 0 27 13"><rect x=".5" y=".5" width="23.5" height="12" rx="3.8" fill="none" stroke="currentColor" stroke-opacity=".35"/><rect x="2" y="2" width="20.5" height="9" rx="2.4" fill="currentColor"/><path d="M25.5 4.4v4.2c.9-.3 1.5-1.1 1.5-2.1s-.6-1.8-1.5-2.1z" fill="currentColor" fill-opacity=".4"/></svg>`};function i(e){let t=document.createElement(`template`);t.innerHTML=r[e];let n=t.content.firstElementChild;return n.classList.add(`ryugi-glyph`),n.dataset.glyph=e,n.setAttribute(`aria-hidden`,`true`),n}let a=[`status`,`island`,`home`];var o=class extends n{static attrs=[`bezel`,`time`,`hide`];hiddenParts(){let e=this.attr(`hide`),n=e.split(/\s+/).filter(Boolean),r=n.filter(e=>e!==`all`&&!a.includes(e));return r.length&&t(`<${this.localName}> hide="${e}": ${r.join(`, `)} is not one of ${a.join(`, `)}, all; ignored`),new Set(n.includes(`all`)?a:n.filter(e=>!r.includes(e)))}build(){let t=this.hiddenParts(),n=e(`div`,{class:`ryugi-screen`},e(`div`,{class:`ryugi-screen-content`},...this.source??[]),!t.has(`status`)&&e(`div`,{class:`ryugi-status`},e(`span`,{class:`ryugi-status-time`},this.attr(`time`,`9:41`)),e(`span`),e(`span`,{class:`ryugi-status-icons`},i(`signal`),i(`wifi`),i(`battery`))),!t.has(`island`)&&e(`div`,{class:`ryugi-island`}),!t.has(`home`)&&e(`div`,{class:`ryugi-home-indicator`}));return this.flag(`bezel`)?e(`div`,{class:`ryugi-bezel`},n):n}};let s={r:255,g:255,b:255,a:1};function c(e){let t=e.trim().toLowerCase();if(t===`transparent`)return{r:0,g:0,b:0,a:0};let n=/^#([0-9a-f]{3,8})$/.exec(t)?.[1];if(n){let e=n.length<=4?[...n].map(e=>e+e).join(``):n;if(e.length!==6&&e.length!==8)return null;let t=t=>Number.parseInt(e.slice(t,t+2),16);return{r:t(0),g:t(2),b:t(4),a:e.length===8?t(6)/255:1}}let r=/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)\s*(?:[,/]\s*([\d.]+)(%?))?\s*\)$/.exec(t);if(!r)return null;let i=r[4]===void 0?1:Number(r[4])/(r[5]?100:1);return{r:Number(r[1]),g:Number(r[2]),b:Number(r[3]),a:i}}function l(e){let t=c(e);if(t||typeof document>`u`)return t;let n=document.createElement(`canvas`).getContext?.(`2d`,{willReadFrequently:!0});if(!n)return null;n.fillStyle=`#000`,n.fillStyle=e;let r=n.fillStyle;if(n.fillStyle=`#fff`,n.fillStyle=e,r!==n.fillStyle)return null;n.clearRect(0,0,1,1),n.fillRect(0,0,1,1);let[i=0,a=0,o=0,s=0]=n.getImageData(0,0,1,1).data;return{r:i,g:a,b:o,a:s/255}}function u(e,t){let n=(t,n)=>t*e.a+n*(1-e.a);return{r:n(e.r,t.r),g:n(e.g,t.g),b:n(e.b,t.b),a:1}}function d({r:e,g:t,b:n}){let r=e=>{let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4};return .2126*r(e)+.7152*r(t)+.0722*r(n)}function f(e,t,n=s){let r=typeof e==`string`?l(e):e,i=typeof t==`string`?l(t):t;if(!r||!i)return null;let a=u(i,u(n,s)),[o,c]=[d(u(r,a)),d(a)].sort((e,t)=>t-e);return(o+.05)/(c+.05)}function p(e,t){return e>=(t?3:4.5)}let m=[`color`,`type`,`space`,`radius`,`size`,`shadow`,`motion`],h={light:{r:255,g:255,b:255,a:1},dark:{r:0,g:0,b:0,a:1}},g=t=>e(`div`,{class:`ryugi-token-error`},t),_=t=>e(`code`,{class:`ryugi-token-value`},t);var v=class{#e=/* @__PURE__ */ new Map;constructor(t){for(let n of t){let t=e(`div`,{"data-appearance":n,style:`position:absolute;visibility:hidden;pointer-events:none`});document.body.append(t),this.#e.set(n,t)}}get(e,t){let n=this.#e.get(t);return n?getComputedStyle(n).getPropertyValue(e).trim():``}font(t,n){let r=this.#e.get(n);if(!r)return null;let i=e(`span`);if(i.style.font=t,!i.style.font)return null;r.append(i);let a=getComputedStyle(i),o=a.lineHeight===`normal`?`normal`:`${Number.parseFloat(a.lineHeight)}`,s=`${Number.parseFloat(a.fontSize)} / ${o} · ${a.fontWeight}`;return i.remove(),s}dispose(){for(let e of this.#e.values())e.remove()}};let y=[[`ryugi-ios-shell`,o],[`ryugi-token-sheet`,class extends n{constructor(){super(),this.addEventListener(`click`,e=>{e.target.closest(`.ryugi-token-track`)?.classList.toggle(`ryugi-token-moved`)})}build(){let t;try{let e=JSON.parse(this.authored(`script`)[0]?.textContent??``);if(!Array.isArray(e?.groups))throw Error(`expected an object with a "groups" array`);t=e.groups}catch(e){return g(`Token sheet JSON: ${e.message}`)}let n=this.hasAttribute(`appearance`)?[this.appearance()]:[`light`,`dark`],r=new v(n);try{return e(`div`,{class:`ryugi-tokens`},...t.map(t=>e(`section`,{class:`ryugi-token-group`},e(`h3`,{},t.name),...m.includes(t.kind)?(t.tokens??[]).map(e=>this.row(t.kind,e,n,r)):[g(`Unknown kind "${t.kind}"; use one of ${m.join(`, `)}`)])))}finally{r.dispose()}}row(t,n,r,i){let a=e(`div`,{class:`ryugi-token-name`},e(`code`,{},n.name),n.use&&e(`div`,{class:`ryugi-token-use`},n.use),n.board&&e(`div`,{class:`ryugi-token-board`},`← ${n.board}`)),o=r.map(e=>i.get(n.name,e));return o.some(e=>!e)?e(`div`,{class:`ryugi-token-row`},a,g(`${n.name} is not set in pages/tokens.css`)):e(`div`,{class:`ryugi-token-row`},a,e(`div`,{class:`ryugi-token-cells`},...t===`color`?r.map((e,t)=>this.color(n,o[t]??``,e,i)):[this.preview(t,n,o,r,i)]))}color(t,n,r,i){let a=t.on?i.get(t.on,r):``,o=e=>`background-image:linear-gradient(${e},${e})`,s=t.on?e(`div`,{class:`ryugi-token-swatch`,style:`${o(a)};color:${n}`},`Aa`):e(`div`,{class:`ryugi-token-swatch`,style:o(n)}),c=!1;if(t.on){let i=a?f(n,a,h[r]):null;c=i===null?g(a?`cannot read ${n} on ${a}`:`${t.on} is not set in pages/tokens.css`):e(`span`,{class:`ryugi-token-contrast${p(i,!!t.large)?``:` ryugi-token-fail`}`},`${i.toFixed(2)}:1`)}return e(`div`,{class:`ryugi-token-cell ryugi-token-${r}`},s,e(`div`,{class:`ryugi-token-meta`},e(`span`,{class:`ryugi-token-mode`},r),_(n),c))}preview(t,n,r,i,a){let[o=``,...s]=r,c=s.some(e=>e!==o)?r.join(` / `):o,l=i[0]??`light`;if(t===`type`){let t=a.font(o,l);return t?e(`div`,{class:`ryugi-token-cell ryugi-token-type`},e(`div`,{class:`ryugi-token-sample`,style:`font:${o}`},n.sample??n.use??n.name),e(`div`,{class:`ryugi-token-meta`},e(`span`,{},t),_(c))):g(`${n.name}: "${o}" is not a font shorthand`)}return e(`div`,{class:`ryugi-token-cell`},{space:e(`div`,{class:`ryugi-token-bar`,style:`width:${o}`}),radius:e(`div`,{class:`ryugi-token-radius`,style:`border-radius:${o}`}),size:e(`div`,{class:`ryugi-token-size`,style:`width:${o};height:${o}`}),shadow:e(`div`,{class:`ryugi-token-shadow`,style:`box-shadow:${o}`}),motion:e(`div`,{class:`ryugi-token-track`,title:`Click to play`},e(`div`,{class:`ryugi-token-dot`,style:`transition:transform ${o}`}))}[t]??!1,e(`div`,{class:`ryugi-token-meta`},_(c)))}}]];if(typeof window<`u`&&!document.querySelector(`style[data-ryugi-mockup]`)){let e=document.createElement(`style`);e.dataset.ryugiMockup=``,e.textContent=`@scope (.ryugi-mockup) {
1
+ (function(){function e(e,t={},...n){let r=document.createElement(e);for(let[e,n]of Object.entries(t))n!=null&&n!==!1&&r.setAttribute(e,n===!0?``:String(n));for(let e of n)e!=null&&e!==!1&&r.append(typeof e==`string`?document.createTextNode(e):e);return r}function t(e){console.warn(`[ryugi-mockup] ${e}`),window.dispatchEvent(new ErrorEvent(`error`,{message:`[ryugi-mockup] ${e}`}))}var n=class e extends HTMLElement{static base=[`appearance`];static attrs=[];static get observedAttributes(){let t=this;return[...e.base,...t.attrs]}source=null;#e=!1;connectedCallback(){this.source||=[...this.childNodes],this.render()}attributeChangedCallback(e,t,n){t!==n&&this.source&&this.isConnected&&this.render()}authored(e){return(this.source??[]).filter(t=>t instanceof Element&&(!e||t.localName===e))}attr(e,t=``){return this.getAttribute(e)??t}flag(e){let t=this.getAttribute(e);return t!==null&&t!==`false`}appearance(){let e=this.getAttribute(`appearance`);if(e===`light`||e===`dark`)return e;let t=(this.parentElement?.closest(`[data-appearance]`))?.getAttribute(`data-appearance`);return t===`light`||t===`dark`?t:typeof matchMedia==`function`&&matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}render(){if(!this.#e){this.#e=!0;try{let e=this.appearance();this.classList.add(`ryugi-mockup`),this.dataset.appearance=e;let t=this.build();this.replaceChildren(...Array.isArray(t)?t:[t])}finally{this.#e=!1}}}};let r=(e,t,n)=>Math.max(t,Math.min(n,e)),i=e=>r(e,0,1),a=(e,t,n)=>e+(t-e)*n;function o(e,t,n,r,i){let a=e.x-t;if(r>.9995){let r=e.v+n*a,o=Math.exp(-n*i);e.x=t+(a+r*i)*o,e.v=(e.v-n*r*i)*o}else{let o=n*Math.sqrt(1-r*r),s=(e.v+r*n*a)/o,c=Math.exp(-r*n*i),l=Math.cos(o*i),u=Math.sin(o*i),d=(a*l+s*u)*c;e.x=t+d,e.v=c*o*(s*l-a*u)-r*n*d}let o=Math.abs(e.x-t)<5e-4*Math.max(1,Math.abs(t))&&Math.abs(e.v)<.005;return o&&(e.x=t,e.v=0),!o}let s={omega:16,zeta:.6};function c(){return typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches}function l(e){let t=0,n=null,r=i=>{let a=n===null?0:Math.min(.032,(i-n)/1e3);n=i,e(a)?t=requestAnimationFrame(r):(t=0,n=null)};return()=>{!t&&typeof requestAnimationFrame==`function`&&(t=requestAnimationFrame(r))}}function u(e,n,r,i){let a=e.getAttribute(n);return a===null?i:r.includes(a)?a:(t(`<${e.localName}> ${n}="${a}" is not one of ${r.join(`, `)}; using ${i}`),i)}function d(){let t={root:e(`div`,{class:`ryugi-ios-lens`,"aria-hidden":`true`,inert:!0}),glass:e(`div`,{class:`ryugi-ios-lens-glass`}),frost:e(`div`,{class:`ryugi-ios-lens-frost`}),view:e(`div`,{class:`ryugi-ios-lens-view`}),rim:e(`div`,{class:`ryugi-ios-lens-rim`})};return t.root.append(t.glass,t.frost,t.view,t.rim),t}function f(e,t){let n=t.cx-t.w/2+(t.shiftX??0),r=t.cy-t.h/2,i=t.clear,a=e.root.style;a.width=`${t.w}px`,a.height=`${t.h}px`,a.borderRadius=`${Math.min(t.w,t.h)/2}px`,a.transform=`translate(${n}px, ${r}px)`;let o=t.restShadow===!1?0:1-i;a.boxShadow=[`0 ${6*i}px ${18*i}px rgba(0, 0, 0, ${.18*i})`,`0 0 0 0.5px rgba(0, 0, 0, ${.06*o})`,`0 1px 3px rgba(0, 0, 0, ${.2*o})`,`0 3px 8px rgba(0, 0, 0, ${.1*o})`].join(`, `),e.frost.style.opacity=String(1-i),e.glass.style.opacity=String(i),e.rim.style.opacity=String(i),e.view.style.opacity=String(t.viewOpacity??i),e.view.style.transformOrigin=`${t.cx-(t.shiftX??0)}px ${t.cy}px`,e.view.style.transform=`translate(${-n}px, ${-r}px) scale(${t.magnify})`}function p(e,t,n,r,i){let a=e.offsetWidth,o=e.offsetHeight;if(!a||!o||r<=0||i<=0)return``;let s=Math.min(r,i)/2,c=t+r,l=n+i;return`path(evenodd, "${`M-8 -8H${a+8}V${o+8}H-8Z`}${`M${t+s} ${n}H${c-s}A${s} ${s} 0 0 1 ${c} ${n+s}V${l-s}A${s} ${s} 0 0 1 ${c-s} ${l}H${t+s}A${s} ${s} 0 0 1 ${t} ${l-s}V${n+s}A${s} ${s} 0 0 1 ${t+s} ${n}Z`}")`}var m=class extends n{static attrs=[`value`,`size`,`block`];#e=``;#t=null;#n=[];#r=null;#i=null;#a={x:0,v:0};#o={x:0,v:0};#s={x:0,v:0};#c=!1;#l=null;#u=null;#d=!1;#f=null;#p=l(e=>this.#x(e));attributeChangedCallback(e,t,n){e===`value`?this.#t&&n!==null&&this.#h(n,!1):super.attributeChangedCallback(e,t,n)}disconnectedCallback(){this.#f?.disconnect(),this.#f=null}build(){let n=u(this,`size`,[`sm`,`md`,`lg`],`md`),r=this.authored(`ryugi-ios-segment`),i=r.map(e=>e.getAttribute(`value`)??``),a=this.getAttribute(`value`);a!==null&&!i.includes(a)&&t(`<${this.localName}> value="${a}" names no <ryugi-ios-segment>; selecting the first`),this.#e=a!==null&&i.includes(a)?a:i[0]??``,this.#n=r.map((t,n)=>e(`button`,{type:`button`,class:`ryugi-ios-segment`,role:`radio`,"data-value":i[n]},...[...t.childNodes].map(e=>e.cloneNode(!0)))),this.#r=d(),this.#r.frost.classList.add(`ryugi-ios-segmented-highlight`),this.#i=e(`div`,{class:`ryugi-ios-segmented-copy-bg`});let o=e(`div`,{class:`ryugi-ios-segmented-options`,role:`radiogroup`,"data-size":n},...this.#n),s=e(`div`,{class:`ryugi-ios-segmented`},this.#r.root,o);return this.#t=o,this.#s={x:0,v:0},this.#m(s,o),this.#g(),this.#f?.disconnect(),this.#f=typeof ResizeObserver==`function`?new ResizeObserver(()=>this.#b()):null,this.#f?.observe(o),typeof requestAnimationFrame==`function`&&requestAnimationFrame(()=>this.#b()),s}#m(e,t){let n=t=>t===e?this.#n.find(e=>e.dataset.value===this.#e)??null:t?.closest?.(`[role="radio"]`)??null;e.addEventListener(`click`,e=>{if(this.#d){this.#d=!1;return}let t=n(e.target);t&&this.#h(t.dataset.value??``,!0)}),e.addEventListener(`pointerdown`,t=>{let r=n(t.target);t.button===0&&r&&r.dataset.value===this.#e&&(e.setPointerCapture?.(t.pointerId),this.#u={x:t.clientX,moved:!1},this.#c=!0,this.#p())}),e.addEventListener(`pointermove`,e=>{let n=this.#u;n&&(!n.moved&&Math.abs(e.clientX-n.x)<3||(n.moved=!0,this.#l=e.clientX-t.getBoundingClientRect().left,this.#p()))});let r=()=>{let e=this.#u;if(this.#u=null,this.#c=!1,e?.moved&&this.#l!==null){let e=this.#y(this.#l);this.#l=null,this.#d=!0,e&&this.#h(e,!0)}this.#p()};e.addEventListener(`pointerup`,r),e.addEventListener(`pointercancel`,r),t.addEventListener(`keydown`,e=>{let t={ArrowRight:1,ArrowDown:1,ArrowLeft:-1,ArrowUp:-1}[e.key];if(!t||!this.#n.length)return;e.preventDefault();let n=this.#n.findIndex(e=>e.dataset.value===this.#e),r=this.#n[(n+t+this.#n.length)%this.#n.length];this.#h(r.dataset.value??``,!0),r.focus()})}#h(e,t){e!==this.#e&&this.#n.some(t=>t.dataset.value===e)&&(this.#e=e,this.getAttribute(`value`)!==e&&this.setAttribute(`value`,e),this.#g(),c()?this.#b():this.#p(),t&&this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:{value:e}})))}#g(){for(let e of this.#n){let t=e.dataset.value===this.#e;e.setAttribute(`aria-checked`,String(t)),e.tabIndex=t?0:-1}this.#_()}#_(){let e=this.#t;if(!e||!this.#r||!this.#i)return;let t=e.cloneNode(!0);t.removeAttribute(`role`),t.style.clipPath=``,t.classList.add(`ryugi-ios-segmented-copy`);for(let e of t.querySelectorAll(`[role="radio"]`))e.removeAttribute(`role`),e.removeAttribute(`aria-checked`),e.setAttribute(`tabindex`,`-1`);let n=`${e.offsetWidth}px`;t.style.width=n,this.#i.style.width=n,this.#i.style.height=`${e.offsetHeight}px`,this.#r.view.replaceChildren(this.#i,t)}#v(e){let t=this.#n.find(t=>t.dataset.value===e);if(!t||!this.#t)return null;let n=this.#t.getBoundingClientRect(),r=t.getBoundingClientRect();return{x:r.left-n.left+r.width/2,y:r.top-n.top+r.height/2,w:r.width,h:r.height}}#y(e){let t=null,n=1/0;for(let r of this.#n){let i=this.#v(r.dataset.value??``);i&&Math.abs(i.x-e)<n&&(n=Math.abs(i.x-e),t=r.dataset.value??null)}return t}#b(){let e=this.#v(this.#e);e&&(this.#a={x:e.x,v:0},this.#o={x:e.w,v:0},this.#_(),this.#S())}#x(e){let t=this.#v(this.#e);if(!t)return!1;let n=t.x,i=this.#l!==null;if(i){let e=this.#v(this.#n[0]?.dataset.value??``),t=this.#v(this.#n.at(-1)?.dataset.value??``);e&&t&&(n=r(this.#l,e.x,t.x))}if(c())return this.#a={x:n,v:0},this.#o={x:t.w,v:0},this.#s={x:+!!this.#c,v:0},this.#S(),!1;let a=!i&&Math.abs(this.#a.x-n)>1.5,l=o(this.#a,n,i?40:16,i?1:.74,e),u=o(this.#o,t.w,16,.8,e),d=o(this.#s,this.#c||a?1:0,s.omega,s.zeta,e);return this.#S(),l||u||d}#S(){let e=this.#v(this.#e);if(!e||!this.#r||!this.#t||!this.#i)return;let t=r(this.#s.x,-.12,1.15),n=i(this.#s.x);this.#t.toggleAttribute(`data-traveling`,n>.05),this.#i.style.opacity=String(n);let a=this.#o.x*(1+.12*t),o=e.h*(1+.35*t);this.#t.style.clipPath=p(this.#t,this.#a.x-a/2,e.y-o/2,a,o),f(this.#r,{cx:this.#a.x,cy:e.y,w:a,h:o,clear:n,magnify:1+.14*n,viewOpacity:1,restShadow:!1})}};let h={w:132,h:68},g={w:245,h:120},_={sm:8,md:12,lg:18,xl:26};var v=class extends n{static attrs=[`value`,`min`,`max`,`step`,`size`,`color`,`label`,`hide-value`,`start-icon`,`end-icon`];#e=0;#t=100;#n=1;#r=50;#i=12;#a=12/32;#o={x:0,v:0};#s={x:0,v:0};#c=0;#l=!1;#u=null;#d=null;#f=null;#p=null;#m=null;#h=null;#g=l(e=>this.#w(e));attributeChangedCallback(e,t,n){e===`value`?this.#d&&n!==null&&this.#x(Number(n),null):super.attributeChangedCallback(e,t,n)}disconnectedCallback(){this.#h?.disconnect(),this.#h=null}build(){let t=(e,t)=>{let n=Number(this.getAttribute(e)??NaN);return Number.isFinite(n)?n:t};this.#e=t(`min`,0),this.#t=Math.max(this.#e,t(`max`,100)),this.#n=t(`step`,1)>0?t(`step`,1):1,this.#i=_[u(this,`size`,[`sm`,`md`,`lg`,`xl`],`md`)],this.#a=this.#i/32,this.#r=this.#b(t(`value`,50)),this.#o={x:this.#v(),v:0},this.#s={x:0,v:0},this.#c=0;let n=this.getAttribute(`color`);n?this.style.setProperty(`--ryugi-ios-on`,n):this.style.removeProperty(`--ryugi-ios-on`);let r=`height:${this.#i}px`;this.#p={track:e(`div`,{class:`ryugi-ios-slider-track`,style:r}),fill:e(`div`,{class:`ryugi-ios-slider-fill`,style:r}),viewTrack:e(`div`,{class:`ryugi-ios-slider-track`,style:r}),viewFill:e(`div`,{class:`ryugi-ios-slider-fill`,style:r})},this.#m=d(),this.#m.view.append(this.#p.viewTrack,this.#p.viewFill);let i=this.attr(`label`),a=e(`div`,{class:`ryugi-ios-slider-area`,role:`slider`,tabindex:0,"aria-label":i||null,"aria-valuemin":this.#e,"aria-valuemax":this.#t,"aria-valuenow":this.#r,style:`height:${h.h*this.#a+8}px`},this.#p.track,this.#p.fill,this.#m.root);this.#d=a,this.#f=e(`span`,{class:`ryugi-ios-slider-value`},String(this.#r)),this.#_(a),this.#h?.disconnect(),this.#h=typeof ResizeObserver==`function`?new ResizeObserver(()=>this.#T()):null,this.#h?.observe(a),this.#T();let o=t=>t?e(`ryugi-icon`,{name:t,size:Math.max(14,this.#i+4),class:`ryugi-ios-slider-icon`}):null,s=e(`div`,{class:`ryugi-ios-slider-row`},o(this.attr(`start-icon`)),a,o(this.attr(`end-icon`)));return i?[e(`div`,{class:`ryugi-ios-slider-head`},e(`span`,{class:`ryugi-ios-slider-label`},i),!this.flag(`hide-value`)&&this.#f),s]:s}#_(e){let t=t=>t.clientX-e.getBoundingClientRect().left;e.addEventListener(`pointerdown`,n=>{if(n.button!==0)return;e.setPointerCapture?.(n.pointerId),n.preventDefault(),e.focus(),this.#l=!0;let r=t(n),i=this.#C(),a=this.#r,o=this.#v();Math.abs(r-i.x)>i.hx+8*this.#a&&(o=r/Math.max(e.clientWidth,1),this.#x(this.#y(o),`input`)),this.#u={startX:r,start:o,from:a},this.#g()}),e.addEventListener(`pointermove`,n=>{let r=this.#u;if(!r)return;let i=r.start+(t(n)-r.startX)/Math.max(e.clientWidth,1);this.#x(this.#y(i),`input`)});let n=()=>{let e=this.#u;this.#u=null,this.#l=!1,e&&e.from!==this.#r&&this.#S(`change`),this.#g()};e.addEventListener(`pointerup`,n),e.addEventListener(`pointercancel`,n),e.addEventListener(`keydown`,e=>{let t=(this.#t-this.#e)/10,n={ArrowRight:this.#n,ArrowUp:this.#n,ArrowLeft:-this.#n,ArrowDown:-this.#n,PageUp:t,PageDown:-t}[e.key],r=n===void 0?e.key===`Home`?this.#e:e.key===`End`?this.#t:null:this.#r+n;r!==null&&(e.preventDefault(),this.#x(r,`change`))})}#v(){return this.#t>this.#e?i((this.#r-this.#e)/(this.#t-this.#e)):0}#y(e){return this.#e+i(e)*(this.#t-this.#e)}#b(e){let t=(String(this.#n).split(`.`)[1]??``).length,n=this.#e+Math.round((e-this.#e)/this.#n)*this.#n;return Number(r(n,this.#e,this.#t).toFixed(t))}#x(e,t){if(!Number.isFinite(e))return;let n=this.#b(e);n!==this.#r&&(this.#r=n,this.#d?.setAttribute(`aria-valuenow`,String(n)),this.#f&&(this.#f.textContent=String(n)),this.getAttribute(`value`)!==String(n)&&this.setAttribute(`value`,String(n)),this.#g(),t&&this.#S(t))}#S(e){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:{value:this.#r}}))}#C(){let e=this.#d?.clientWidth??0,t=this.#a,n=r(this.#s.x,-.12,1.15),o=i(this.#s.x),s=a(h.w/2,g.w/2,n)*t,c=a(h.h/2,g.h/2,n)*t,l=s*(1-.44*o);return{hx:s,hy:c,pressed:o,x:r(this.#o.x*e-22*t*o,l,Math.max(l,e-l))}}#w(e){let t=this.#v(),n=+!!this.#l;if(c())return this.#o={x:t,v:0},this.#s={x:n,v:0},this.#c=0,this.#T(),!1;let i=o(this.#o,t,30,1,e),a=this.#o.v*((this.#d?.clientWidth??0)/this.#a),l=r(a*9e-5,-.04,.04);this.#c+=(l-this.#c)*Math.min(1,e*18);let u=o(this.#s,n,s.omega,s.zeta,e);return this.#T(),i||u||Math.abs(this.#c)>1e-4}#T(){let e=this.#d,t=this.#p;if(!e||!t||!this.#m)return;let n=e.clientWidth,r=e.clientHeight,i=`${(r-this.#i)/2}px`,a=this.#o.x<=0?0:Math.max(this.#i,this.#o.x*n);for(let e of[t.track,t.fill,t.viewTrack,t.viewFill])e.style.top=i;t.viewTrack.style.width=`${n}px`,t.fill.style.width=`${a}px`,t.viewFill.style.width=`${a}px`;let o=this.#C(),s=Math.abs(this.#c);f(this.#m,{cx:o.x,cy:r/2,w:o.hx*2*(1+s),h:o.hy*2*(1-s*.45),shiftX:this.#c*-60*this.#a,clear:o.pressed,magnify:1+.12*o.pressed})}};let y={w:137,h:60},b={w:81,h:51},x=(y.h-b.h)/2,S=y.w-b.w-x*2,C=1.55,w={sm:22,md:28,lg:36},T=0;var E=class extends n{static attrs=[`checked`,`disabled`,`size`,`color`,`label`,`description`,`label-side`];#e=!1;#t=1;#n={x:0,v:0};#r={x:0,v:0};#i=!1;#a=null;#o=null;#s=!1;#c=null;#l=null;#u=null;#d=null;#f=l(e=>this.#h(e));attributeChangedCallback(e,t,n){e===`checked`?this.#c&&this.#m(this.flag(`checked`),!1):super.attributeChangedCallback(e,t,n)}build(){let t=u(this,`size`,[`sm`,`md`,`lg`],`md`),n=w[t];this.#t=n/y.h;let r=y.w*this.#t;this.#e=this.flag(`checked`),this.#n={x:+!!this.#e,v:0},this.#r={x:0,v:0};let i=this.getAttribute(`color`);i?this.style.setProperty(`--ryugi-ios-on`,i):this.style.removeProperty(`--ryugi-ios-on`);let a=`width:${r}px;height:${n}px`;this.#l=e(`div`,{class:`ryugi-ios-switch-fill`}),this.#u=e(`div`,{class:`ryugi-ios-switch-fill`,style:a}),this.#d=d(),this.#d.view.append(e(`div`,{class:`ryugi-ios-switch-track`,style:a}),this.#u);let o=e(`button`,{type:`button`,class:`ryugi-ios-switch`,role:`switch`,id:`ryugi-ios-switch-${++T}`,"aria-checked":String(this.#e),disabled:this.flag(`disabled`)},e(`div`,{class:`ryugi-ios-switch-track`}),this.#l,this.#d.root);o.style.width=`${r}px`,o.style.height=`${n}px`,this.#c=o,this.#p(o),this.#g();let s=this.attr(`label`);if(!s)return o;let c=this.attr(`description`),l=e(`label`,{class:`ryugi-ios-switch-label`,for:o.id},e(`span`,{class:`ryugi-ios-switch-title`},s),c&&e(`span`,{class:`ryugi-ios-switch-description`},c));return this.attr(`label-side`)===`left`?[l,o]:[o,l]}#p(e){let t=t=>t.clientX-e.getBoundingClientRect().left;e.addEventListener(`pointerdown`,n=>{e.disabled||n.button!==0||(e.setPointerCapture?.(n.pointerId),this.#i=!0,this.#o={startX:t(n),startPos:+!!this.#e,moved:!1},this.#f())}),e.addEventListener(`pointermove`,e=>{let n=this.#o;if(!n)return;let r=t(e)-n.startX;!n.moved&&Math.abs(r)<3||(n.moved=!0,this.#a=i(n.startPos+r/(S*this.#t)),this.#f())});let n=e=>{let t=this.#o;if(this.#o=null,this.#i=!1,!t)return;let n=t.moved?(this.#a??0)>.5:!this.#e;this.#a=null,this.#s=e.type===`pointerup`,this.#m(n,!0),this.#f()};e.addEventListener(`pointerup`,n),e.addEventListener(`pointercancel`,n),e.addEventListener(`click`,()=>{this.#s?this.#s=!1:this.#m(!this.#e,!0)})}#m(e,t){e!==this.#e&&(this.#e=e,this.#c?.setAttribute(`aria-checked`,String(e)),this.flag(`checked`)!==e&&this.toggleAttribute(`checked`,e),this.#f(),t&&this.dispatchEvent(new CustomEvent(`change`,{bubbles:!0,detail:{checked:e}})))}#h(e){let t=this.#a??+!!this.#e;if(c())return this.#n={x:t,v:0},this.#r={x:+!!this.#i,v:0},this.#g(),!1;let n=this.#a===null&&Math.abs(this.#n.x-t)>.08,r=this.#a===null?o(this.#n,t,15,.7,e):o(this.#n,t,40,1,e),i=o(this.#r,this.#i||n?1:0,s.omega,s.zeta,e);return this.#g(),r||i}#g(){if(!this.#d||!this.#l||!this.#u)return;let e=this.#t,t=String(i(this.#n.x));this.#l.style.opacity=t,this.#u.style.opacity=t;let n=r(this.#r.x,-.12,1.15),o=i(this.#r.x);f(this.#d,{cx:(x+b.w/2+this.#n.x*S)*e,cy:y.h/2*e,w:a(b.w,b.w*C,n)*e,h:a(b.h,b.h*C,n)*e,clear:o,magnify:1+.16*o})}};let D={signal:`<svg width="18" height="12" viewBox="0 0 18 12" fill="currentColor"><rect y="7.8" width="3.2" height="3.6" rx="1"/><rect x="4.8" y="5.6" width="3.2" height="5.8" rx="1"/><rect x="9.6" y="3.2" width="3.2" height="8.2" rx="1"/><rect x="14.4" y=".4" width="3.2" height="11" rx="1"/></svg>`,wifi:`<svg width="17" height="12" viewBox="0 0 17 12" fill="currentColor"><path d="M8.5 11.4L6.31 9.21A3.1 3.1 0 0 1 10.69 9.21ZM3.69 6.59A6.8 6.8 0 0 1 13.31 6.59L12.25 7.65A5.3 5.3 0 0 0 4.75 7.65ZM1.08 3.98A10.5 10.5 0 0 1 15.92 3.98L14.86 5.04A9 9 0 0 0 2.14 5.04Z" stroke="currentColor" stroke-linejoin="round"/></svg>`,battery:`<svg width="27" height="13" viewBox="0 0 27 13"><rect x=".5" y=".5" width="23.5" height="12" rx="3.8" fill="none" stroke="currentColor" stroke-opacity=".35"/><rect x="2" y="2" width="20.5" height="9" rx="2.4" fill="currentColor"/><path d="M25.5 4.4v4.2c.9-.3 1.5-1.1 1.5-2.1s-.6-1.8-1.5-2.1z" fill="currentColor" fill-opacity=".4"/></svg>`};function O(e){let t=document.createElement(`template`);t.innerHTML=D[e];let n=t.content.firstElementChild;return n.classList.add(`ryugi-glyph`),n.dataset.glyph=e,n.setAttribute(`aria-hidden`,`true`),n}let k=[`status`,`island`,`home`];var A=class extends n{static attrs=[`bezel`,`time`,`hide`];hiddenParts(){let e=this.attr(`hide`),n=e.split(/\s+/).filter(Boolean),r=n.filter(e=>e!==`all`&&!k.includes(e));return r.length&&t(`<${this.localName}> hide="${e}": ${r.join(`, `)} is not one of ${k.join(`, `)}, all; ignored`),new Set(n.includes(`all`)?k:n.filter(e=>!r.includes(e)))}build(){let t=this.hiddenParts(),n=e(`div`,{class:`ryugi-screen`},e(`div`,{class:`ryugi-screen-content`},...this.source??[]),!t.has(`status`)&&e(`div`,{class:`ryugi-status`},e(`span`,{class:`ryugi-status-time`},this.attr(`time`,`9:41`)),e(`span`),e(`span`,{class:`ryugi-status-icons`},O(`signal`),O(`wifi`),O(`battery`))),!t.has(`island`)&&e(`div`,{class:`ryugi-island`}),!t.has(`home`)&&e(`div`,{class:`ryugi-home-indicator`}));return this.flag(`bezel`)?e(`div`,{class:`ryugi-bezel`},n):n}};let j={r:255,g:255,b:255,a:1};function M(e){let t=e.trim().toLowerCase();if(t===`transparent`)return{r:0,g:0,b:0,a:0};let n=/^#([0-9a-f]{3,8})$/.exec(t)?.[1];if(n){let e=n.length<=4?[...n].map(e=>e+e).join(``):n;if(e.length!==6&&e.length!==8)return null;let t=t=>Number.parseInt(e.slice(t,t+2),16);return{r:t(0),g:t(2),b:t(4),a:e.length===8?t(6)/255:1}}let r=/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)\s*(?:[,/]\s*([\d.]+)(%?))?\s*\)$/.exec(t);if(!r)return null;let i=r[4]===void 0?1:Number(r[4])/(r[5]?100:1);return{r:Number(r[1]),g:Number(r[2]),b:Number(r[3]),a:i}}function N(e){let t=M(e);if(t||typeof document>`u`)return t;let n=document.createElement(`canvas`).getContext?.(`2d`,{willReadFrequently:!0});if(!n)return null;n.fillStyle=`#000`,n.fillStyle=e;let r=n.fillStyle;if(n.fillStyle=`#fff`,n.fillStyle=e,r!==n.fillStyle)return null;n.clearRect(0,0,1,1),n.fillRect(0,0,1,1);let[i=0,a=0,o=0,s=0]=n.getImageData(0,0,1,1).data;return{r:i,g:a,b:o,a:s/255}}function P(e,t){let n=(t,n)=>t*e.a+n*(1-e.a);return{r:n(e.r,t.r),g:n(e.g,t.g),b:n(e.b,t.b),a:1}}function F({r:e,g:t,b:n}){let r=e=>{let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4};return .2126*r(e)+.7152*r(t)+.0722*r(n)}function I(e,t,n=j){let r=typeof e==`string`?N(e):e,i=typeof t==`string`?N(t):t;if(!r||!i)return null;let a=P(i,P(n,j)),[o,s]=[F(P(r,a)),F(a)].sort((e,t)=>t-e);return(o+.05)/(s+.05)}function L(e,t){return e>=(t?3:4.5)}let R=[`color`,`type`,`space`,`radius`,`size`,`shadow`,`motion`],z={light:{r:255,g:255,b:255,a:1},dark:{r:0,g:0,b:0,a:1}},B=t=>e(`div`,{class:`ryugi-token-error`},t),V=t=>e(`code`,{class:`ryugi-token-value`},t);var H=class{#e=/* @__PURE__ */ new Map;constructor(t){for(let n of t){let t=e(`div`,{"data-appearance":n,style:`position:absolute;visibility:hidden;pointer-events:none`});document.body.append(t),this.#e.set(n,t)}}get(e,t){let n=this.#e.get(t);return n?getComputedStyle(n).getPropertyValue(e).trim():``}font(t,n){let r=this.#e.get(n);if(!r)return null;let i=e(`span`);if(i.style.font=t,!i.style.font)return null;r.append(i);let a=getComputedStyle(i),o=a.lineHeight===`normal`?`normal`:`${Number.parseFloat(a.lineHeight)}`,s=`${Number.parseFloat(a.fontSize)} / ${o} · ${a.fontWeight}`;return i.remove(),s}dispose(){for(let e of this.#e.values())e.remove()}};let U=[[`ryugi-ios-shell`,A],[`ryugi-token-sheet`,class extends n{constructor(){super(),this.addEventListener(`click`,e=>{e.target.closest(`.ryugi-token-track`)?.classList.toggle(`ryugi-token-moved`)})}build(){let t;try{let e=JSON.parse(this.authored(`script`)[0]?.textContent??``);if(!Array.isArray(e?.groups))throw Error(`expected an object with a "groups" array`);t=e.groups}catch(e){return B(`Token sheet JSON: ${e.message}`)}let n=this.hasAttribute(`appearance`)?[this.appearance()]:[`light`,`dark`],r=new H(n);try{return e(`div`,{class:`ryugi-tokens`},...t.map(t=>e(`section`,{class:`ryugi-token-group`},e(`h3`,{},t.name),...R.includes(t.kind)?(t.tokens??[]).map(e=>this.row(t.kind,e,n,r)):[B(`Unknown kind "${t.kind}"; use one of ${R.join(`, `)}`)])))}finally{r.dispose()}}row(t,n,r,i){let a=e(`div`,{class:`ryugi-token-name`},e(`code`,{},n.name),n.use&&e(`div`,{class:`ryugi-token-use`},n.use),n.board&&e(`div`,{class:`ryugi-token-board`},`← ${n.board}`)),o=r.map(e=>i.get(n.name,e));return o.some(e=>!e)?e(`div`,{class:`ryugi-token-row`},a,B(`${n.name} is not set in pages/tokens.css`)):e(`div`,{class:`ryugi-token-row`},a,e(`div`,{class:`ryugi-token-cells`},...t===`color`?r.map((e,t)=>this.color(n,o[t]??``,e,i)):[this.preview(t,n,o,r,i)]))}color(t,n,r,i){let a=t.on?i.get(t.on,r):``,o=e=>`background-image:linear-gradient(${e},${e})`,s=t.on?e(`div`,{class:`ryugi-token-swatch`,style:`${o(a)};color:${n}`},`Aa`):e(`div`,{class:`ryugi-token-swatch`,style:o(n)}),c=!1;if(t.on){let i=a?I(n,a,z[r]):null;c=i===null?B(a?`cannot read ${n} on ${a}`:`${t.on} is not set in pages/tokens.css`):e(`span`,{class:`ryugi-token-contrast${L(i,!!t.large)?``:` ryugi-token-fail`}`},`${i.toFixed(2)}:1`)}return e(`div`,{class:`ryugi-token-cell ryugi-token-${r}`},s,e(`div`,{class:`ryugi-token-meta`},e(`span`,{class:`ryugi-token-mode`},r),V(n),c))}preview(t,n,r,i,a){let[o=``,...s]=r,c=s.some(e=>e!==o)?r.join(` / `):o,l=i[0]??`light`;if(t===`type`){let t=a.font(o,l);return t?e(`div`,{class:`ryugi-token-cell ryugi-token-type`},e(`div`,{class:`ryugi-token-sample`,style:`font:${o}`},n.sample??n.use??n.name),e(`div`,{class:`ryugi-token-meta`},e(`span`,{},t),V(c))):B(`${n.name}: "${o}" is not a font shorthand`)}return e(`div`,{class:`ryugi-token-cell`},{space:e(`div`,{class:`ryugi-token-bar`,style:`width:${o}`}),radius:e(`div`,{class:`ryugi-token-radius`,style:`border-radius:${o}`}),size:e(`div`,{class:`ryugi-token-size`,style:`width:${o};height:${o}`}),shadow:e(`div`,{class:`ryugi-token-shadow`,style:`box-shadow:${o}`}),motion:e(`div`,{class:`ryugi-token-track`,title:`Click to play`},e(`div`,{class:`ryugi-token-dot`,style:`transition:transform ${o}`}))}[t]??!1,e(`div`,{class:`ryugi-token-meta`},V(c)))}}],[`ryugi-ios-switch`,E],[`ryugi-ios-segmented`,m],[`ryugi-ios-slider`,v]];if(typeof window<`u`&&!document.querySelector(`style[data-ryugi-mockup]`)){let e=document.createElement(`style`);e.dataset.ryugiMockup=``,e.textContent=`@scope (.ryugi-mockup) {
2
2
  /* The device around a mockup and the token sheet. Scoped to .ryugi-mockup at build time, so
3
3
  :scope is each element's root. Everything on the screen is the product's own CSS. */
4
4
 
@@ -286,5 +286,273 @@
286
286
  .ryugi-token-moved .ryugi-token-dot {
287
287
  transform: translateX(132px);
288
288
  }
289
+
290
+ /* iOS controls: the switch, segmented control and slider iOS draws itself, so a mockup does not
291
+ hand-draw them. At rest the knob is a frosted pill; pressed, dragged or travelling it opens
292
+ into clear glass that magnifies what lies beneath. */
293
+ :scope:is(ryugi-ios-switch, ryugi-ios-segmented, ryugi-ios-slider) {
294
+ --ryugi-ios-track: #c6c5c9;
295
+ --ryugi-ios-segmented-bg: rgba(0, 0, 0, 0.05);
296
+ --ryugi-ios-segmented-highlight: #fff;
297
+ }
298
+ :scope:is(ryugi-ios-switch, ryugi-ios-segmented, ryugi-ios-slider)[data-appearance='dark'] {
299
+ --ryugi-ios-track: #34353b;
300
+ --ryugi-ios-segmented-bg: rgba(255, 255, 255, 0.08);
301
+ --ryugi-ios-segmented-highlight: #404040;
302
+ }
303
+ .ryugi-ios-lens {
304
+ position: absolute;
305
+ left: 0;
306
+ top: 0;
307
+ z-index: 2;
308
+ overflow: hidden;
309
+ isolation: isolate;
310
+ pointer-events: none;
311
+ }
312
+ .ryugi-ios-lens > * {
313
+ position: absolute;
314
+ border-radius: inherit;
315
+ }
316
+ .ryugi-ios-lens-glass,
317
+ .ryugi-ios-lens-frost,
318
+ .ryugi-ios-lens-rim {
319
+ inset: 0;
320
+ }
321
+ .ryugi-ios-lens-glass {
322
+ background: rgba(255, 255, 255, 0.02);
323
+ -webkit-backdrop-filter: blur(0.6px) saturate(1.8) brightness(1.06);
324
+ backdrop-filter: blur(0.6px) saturate(1.8) brightness(1.06);
325
+ }
326
+ .ryugi-ios-lens-frost {
327
+ background: radial-gradient(110% 130% at 50% 35%, #fff 52%, #e9ebef 100%);
328
+ }
329
+ .ryugi-ios-lens-view {
330
+ left: 0;
331
+ top: 0;
332
+ border-radius: 0;
333
+ }
334
+ .ryugi-ios-lens-rim {
335
+ box-shadow:
336
+ inset 0 0 0 0.5px rgba(255, 255, 255, 0.6),
337
+ inset 1.5px 2px 1.5px -1px rgba(255, 255, 255, 0.95),
338
+ inset -1.5px -2px 1.5px -1px rgba(255, 255, 255, 0.55),
339
+ inset 0 0 6px rgba(255, 255, 255, 0.18),
340
+ inset 0 -8px 12px -10px rgba(0, 0, 0, 0.22);
341
+ }
342
+
343
+ :scope:is(ryugi-ios-switch) {
344
+ display: inline-flex;
345
+ align-items: center;
346
+ gap: 12px;
347
+ vertical-align: middle;
348
+ }
349
+ :scope:is(ryugi-ios-switch)[disabled] {
350
+ opacity: 0.4;
351
+ }
352
+ .ryugi-ios-switch {
353
+ position: relative;
354
+ flex: none;
355
+ padding: 0;
356
+ border: 0;
357
+ border-radius: 999px;
358
+ background: none;
359
+ cursor: pointer;
360
+ touch-action: none;
361
+ outline: none;
362
+ }
363
+ .ryugi-ios-switch:disabled {
364
+ cursor: not-allowed;
365
+ }
366
+ .ryugi-ios-switch:focus-visible {
367
+ outline: 2px solid var(--ryugi-accent);
368
+ outline-offset: 2px;
369
+ }
370
+ .ryugi-ios-switch-track,
371
+ .ryugi-ios-switch-fill {
372
+ position: absolute;
373
+ inset: 0;
374
+ border-radius: 999px;
375
+ }
376
+ .ryugi-ios-lens-view > .ryugi-ios-switch-track,
377
+ .ryugi-ios-lens-view > .ryugi-ios-switch-fill {
378
+ inset: 0 auto auto 0;
379
+ }
380
+ .ryugi-ios-switch-track {
381
+ background: var(--ryugi-ios-track);
382
+ }
383
+ .ryugi-ios-switch-fill {
384
+ background: var(--ryugi-ios-on, var(--ryugi-accent));
385
+ }
386
+ .ryugi-ios-switch-label {
387
+ display: grid;
388
+ cursor: pointer;
389
+ user-select: none;
390
+ }
391
+ .ryugi-ios-switch-title {
392
+ font-size: 15px;
393
+ line-height: 20px;
394
+ font-weight: 500;
395
+ }
396
+ .ryugi-ios-switch-description {
397
+ font-size: 13px;
398
+ line-height: 18px;
399
+ color: var(--ryugi-secondary);
400
+ }
401
+
402
+ :scope:is(ryugi-ios-segmented) {
403
+ display: inline-block;
404
+ vertical-align: middle;
405
+ }
406
+ :scope:is(ryugi-ios-segmented)[block] {
407
+ display: block;
408
+ }
409
+ .ryugi-ios-segmented {
410
+ position: relative;
411
+ isolation: isolate;
412
+ display: inline-block;
413
+ vertical-align: middle;
414
+ border-radius: 999px;
415
+ }
416
+ .ryugi-ios-segmented-options {
417
+ display: inline-flex;
418
+ align-items: center;
419
+ gap: 4px;
420
+ padding: 4px;
421
+ border-radius: 999px;
422
+ background: var(--ryugi-ios-segmented-bg);
423
+ touch-action: none;
424
+ }
425
+ :scope[block] .ryugi-ios-segmented {
426
+ display: block;
427
+ }
428
+ :scope[block] .ryugi-ios-segmented-options {
429
+ display: flex;
430
+ }
431
+ :scope[block] .ryugi-ios-segment {
432
+ flex: 1;
433
+ }
434
+ .ryugi-ios-segment {
435
+ position: relative;
436
+ z-index: 1;
437
+ display: inline-flex;
438
+ align-items: center;
439
+ justify-content: center;
440
+ gap: 6px;
441
+ border: 0;
442
+ border-radius: 999px;
443
+ background: none;
444
+ font: inherit;
445
+ font-weight: 600;
446
+ white-space: nowrap;
447
+ color: var(--ryugi-secondary);
448
+ cursor: pointer;
449
+ outline: none;
450
+ user-select: none;
451
+ transition: color 0.2s;
452
+ }
453
+ .ryugi-ios-segment[aria-checked='true'],
454
+ .ryugi-ios-segment:hover {
455
+ color: var(--ryugi-text);
456
+ }
457
+ .ryugi-ios-segmented-options[data-traveling] .ryugi-ios-segment[aria-checked='true'] {
458
+ color: var(--ryugi-secondary);
459
+ }
460
+ .ryugi-ios-segment:focus-visible {
461
+ box-shadow: 0 0 0 2px var(--ryugi-accent);
462
+ }
463
+ .ryugi-ios-segmented:has(.ryugi-ios-segment[aria-checked='true']:focus-visible) .ryugi-ios-lens {
464
+ outline: 2px solid var(--ryugi-accent);
465
+ }
466
+ .ryugi-ios-segmented-options[data-size='sm'] .ryugi-ios-segment {
467
+ height: 28px;
468
+ padding: 0 12px;
469
+ font-size: 12px;
470
+ }
471
+ .ryugi-ios-segmented-options[data-size='md'] .ryugi-ios-segment {
472
+ height: 32px;
473
+ padding: 0 14px;
474
+ font-size: 13px;
475
+ }
476
+ .ryugi-ios-segmented-options[data-size='lg'] .ryugi-ios-segment {
477
+ height: 40px;
478
+ padding: 0 16px;
479
+ font-size: 14px;
480
+ }
481
+ .ryugi-ios-segmented-highlight {
482
+ background: var(--ryugi-ios-segmented-highlight);
483
+ }
484
+ .ryugi-ios-segmented-copy {
485
+ position: absolute;
486
+ left: 0;
487
+ top: 0;
488
+ margin: 0;
489
+ background: none;
490
+ pointer-events: none;
491
+ }
492
+ .ryugi-ios-segmented-copy .ryugi-ios-segment {
493
+ color: var(--ryugi-text);
494
+ transition: none;
495
+ }
496
+ .ryugi-ios-segmented-copy-bg {
497
+ left: 0;
498
+ top: 0;
499
+ border-radius: 999px;
500
+ background: var(--ryugi-ios-segmented-bg);
501
+ }
502
+
503
+ :scope:is(ryugi-ios-slider) {
504
+ display: grid;
505
+ gap: 8px;
506
+ }
507
+ .ryugi-ios-slider-head {
508
+ display: flex;
509
+ justify-content: space-between;
510
+ padding: 0 4px;
511
+ font-size: 13px;
512
+ line-height: 18px;
513
+ font-weight: 500;
514
+ }
515
+ .ryugi-ios-slider-value {
516
+ color: var(--ryugi-secondary);
517
+ font-variant-numeric: tabular-nums;
518
+ }
519
+ .ryugi-ios-slider-row {
520
+ display: flex;
521
+ align-items: center;
522
+ gap: 14px;
523
+ color: var(--ryugi-secondary);
524
+ }
525
+ .ryugi-ios-slider-area {
526
+ position: relative;
527
+ flex: 1;
528
+ min-width: 0;
529
+ border-radius: 999px;
530
+ cursor: grab;
531
+ touch-action: none;
532
+ user-select: none;
533
+ outline: none;
534
+ }
535
+ .ryugi-ios-slider-area:active {
536
+ cursor: grabbing;
537
+ }
538
+ .ryugi-ios-slider-area:focus-visible {
539
+ outline: 2px solid var(--ryugi-accent);
540
+ outline-offset: 4px;
541
+ }
542
+ .ryugi-ios-slider-track,
543
+ .ryugi-ios-slider-fill {
544
+ position: absolute;
545
+ left: 0;
546
+ border-radius: 999px;
547
+ }
548
+ .ryugi-ios-slider-area > .ryugi-ios-slider-track {
549
+ right: 0;
550
+ }
551
+ .ryugi-ios-slider-track {
552
+ background: var(--ryugi-ios-track);
553
+ }
554
+ .ryugi-ios-slider-fill {
555
+ background: var(--ryugi-ios-on, var(--ryugi-accent));
556
+ }
289
557
  }
290
- `,(document.head??document.documentElement).append(e);for(let[e,t]of y)customElements.get(e)||customElements.define(e,t);document.dispatchEvent(new CustomEvent(`ryugi-mockup:ready`))}})();
558
+ `,(document.head??document.documentElement).append(e);for(let[e,t]of U)customElements.get(e)||customElements.define(e,t);document.dispatchEvent(new CustomEvent(`ryugi-mockup:ready`))}})();