@maggioli-rd/aicore-agent-chat 1.2.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -18
- package/dist/aicore-agent-chat.js +164 -53
- package/dist/aicore-agent-chat.js.map +1 -1
- package/dist/bundle/a2ui-C-LAbJcp.js +87 -0
- package/dist/bundle/abnfDiagram-S7VZAUFO-DxkzIS8G.js +1 -0
- package/dist/bundle/architecture-WOLXFQ4H-BXMyXdT1.js +1 -0
- package/dist/bundle/architectureDiagram-YGSQEFNW-BmsDn6Ho.js +36 -0
- package/dist/bundle/backstage-Bfl3Tyo5.js +86 -0
- package/dist/bundle/blockDiagram-APKKGZFW-bG_MVPzT.js +140 -0
- package/dist/bundle/bpmnIcons-APHXDYXF-C0jbCElo.js +1 -0
- package/dist/bundle/c4Diagram-KJ2TOQU5-BVad-wQe.js +38 -0
- package/dist/bundle/chunk-2Q5K7J3B-C1jixKkw.js +1 -0
- package/dist/bundle/chunk-5VM5RSS4-CwNG0iBi.js +15 -0
- package/dist/bundle/chunk-6MUBBAK2-CeH4cZO-.js +2 -0
- package/dist/bundle/chunk-AXFCVDMN-D0Vqm50X.js +62 -0
- package/dist/bundle/chunk-BG4553SI-DUBI9JbR.js +127 -0
- package/dist/bundle/chunk-DQASFODM-DBWVlIjs.js +10 -0
- package/dist/bundle/chunk-DUW6YSOI-ChybIQ82.js +1 -0
- package/dist/bundle/chunk-HFQBQIA3-D2xPptW8.js +1 -0
- package/dist/bundle/chunk-J5ZVWO5B-DHB__t6z.js +1 -0
- package/dist/bundle/chunk-JWPE2WC7-DVXcaiue.js +1 -0
- package/dist/bundle/chunk-KQLB2F66-BRGnyo9e.js +1 -0
- package/dist/bundle/chunk-KS47KZWR-DV3Gxewa.js +1 -0
- package/dist/bundle/chunk-LEVMRMFU-BdDTT4pw.js +1 -0
- package/dist/bundle/chunk-M57EVK23-BRqFqW5o.js +1 -0
- package/dist/bundle/chunk-NGNAAXSQ-DreF1ykJ.js +214 -0
- package/dist/bundle/chunk-OY52VR5R-BamrP8d_.js +88 -0
- package/dist/bundle/chunk-QB3YPZ4I-BqUUL29j.js +213 -0
- package/dist/bundle/chunk-R3KSYZAL-gmtEjdKU.js +1 -0
- package/dist/bundle/chunk-STOXU5M4-DdqxXfKq.js +72 -0
- package/dist/bundle/chunk-TU62E6Q5-B4GgWjUW.js +1 -0
- package/dist/bundle/chunk-X4PVCEUW-BcN5Aq5G.js +1 -0
- package/dist/bundle/chunk-XXDRQBXY-BIvjAdC_.js +1 -0
- package/dist/bundle/chunk-Y2CYZVJY-DsF7k-Jl.js +1 -0
- package/dist/bundle/classDiagram-v2-L25IHNXF-Dw7so3mk.js +217 -0
- package/dist/bundle/cose-bilkent-JH36ORCC-DUvnuVrm.js +1 -0
- package/dist/bundle/cynefin-EF2NZ3EQ-CcVPiRLN.js +1 -0
- package/dist/bundle/cynefinDiagram-L36ESFBY-eO6Z3Kvn.js +62 -0
- package/dist/bundle/cytoscape.esm-CsT4DLSP.js +321 -0
- package/dist/bundle/d3-hierarchy-i5r04UUG.js +1 -0
- package/dist/bundle/d3-scale-BEO6F4Sh.js +1 -0
- package/dist/bundle/d3-scale-chromatic-DhHjp77O.js +1 -0
- package/dist/bundle/d3-selection-CBFxn8wf.js +1 -0
- package/dist/bundle/d3-shape-v1Y4qR5e.js +1 -0
- package/dist/bundle/dagre-SPEB5RXH-ByBZqBaT.js +4 -0
- package/dist/bundle/diagram-3B7GL73J-BkQkIpxz.js +200 -0
- package/dist/bundle/diagram-DNEMPZML-DYthXzRv.js +24 -0
- package/dist/bundle/diagram-L3MUGCDN-D4DIzfHH.js +41 -0
- package/dist/bundle/diagram-LA4NIPWU-C2P-hZD1.js +24 -0
- package/dist/bundle/diagram-MHCOC4E2-BwauFnTV.js +3 -0
- package/dist/bundle/diagram-XPFHEONP-DC_v3Llc.js +30 -0
- package/dist/bundle/dist-CwuaKeLF.js +1 -0
- package/dist/bundle/ebnfDiagram-UZSYDL2S-CmwGlC8L.js +1 -0
- package/dist/bundle/elk-XV6XMXQE-CTlty3p3.js +27 -0
- package/dist/bundle/erDiagram-EYBAPDEH-Bu6phvJH.js +99 -0
- package/dist/bundle/eventmodeling-K75KTNOO-B1q0nOJE.js +1 -0
- package/dist/bundle/flowDiagram-MALGAFMO-D9D_AzXh.js +1 -0
- package/dist/bundle/ganttDiagram-23REXITY-COK7rxO4.js +292 -0
- package/dist/bundle/gitGraph-VSP46ZUC-DS7S_jKI.js +1 -0
- package/dist/bundle/gitGraphDiagram-STJD7YCW-DhVK8Hqh.js +106 -0
- package/dist/bundle/graphlib-Bgy7WbC7.js +1 -0
- package/dist/bundle/info-OHQRW6UA-BjEWvFlW.js +1 -0
- package/dist/bundle/infoDiagram-KBXO4MBG-Dg3zWdHP.js +2 -0
- package/dist/bundle/ishikawaDiagram-M35NCXHK-C2g8ghrV.js +70 -0
- package/dist/bundle/journeyDiagram-OPLOXDXO-DMZkL-i1.js +139 -0
- package/dist/bundle/kanban-definition-BZKZHSQY-Dr43IiJD.js +89 -0
- package/dist/bundle/katex-rAoShGnF.js +257 -0
- package/dist/bundle/math-Cx-Q-b8s.js +262 -0
- package/dist/bundle/mermaid-DaDuEHir.js +43 -0
- package/dist/bundle/mermaid-parser.core-Bv_Zx_ZE.js +6 -0
- package/dist/bundle/mindmap-definition-I2QAS2VK-BXCWJ_1R.js +98 -0
- package/dist/bundle/packet-JDAUHWVQ-CgB2qE5t.js +1 -0
- package/dist/bundle/pegDiagram-FD4XPPHP-CR58gOgF.js +1 -0
- package/dist/bundle/pie-XZMESJXO-CvXWTfIG.js +1 -0
- package/dist/bundle/pieDiagram-J4AKIIQI-D0GhbNJg.js +39 -0
- package/dist/bundle/quadrantDiagram-XTYBLID2-BKBEdwvC.js +7 -0
- package/dist/bundle/radar-ABXABTNO-8V_xx_AB.js +1 -0
- package/dist/bundle/railroad-I3PHUGI6-Bvb0GUva.js +1 -0
- package/dist/bundle/railroad-abnf-LNEFI6M7-D8xGcObq.js +1 -0
- package/dist/bundle/railroad-ebnf-DWYD2UWJ-Ch8wBawI.js +1 -0
- package/dist/bundle/railroad-peg-JR7BVNR7-CGndbjed.js +1 -0
- package/dist/bundle/railroadDiagram-MRQ6NCDL-DvqHkO2C.js +1 -0
- package/dist/bundle/requirementDiagram-Y7LWUY3S-bCLAM9sl.js +84 -0
- package/dist/bundle/rolldown-runtime-BNaE-Ejt.js +1 -0
- package/dist/bundle/rough.esm-Dy-Kn_BL.js +1 -0
- package/dist/bundle/sankeyDiagram-WGJFYUXA-8ehuPvHQ.js +40 -0
- package/dist/bundle/sequenceDiagram-5NDRBG5M-Cdg1YzMw.js +169 -0
- package/dist/bundle/sizeCapture-INFHLROL-Ct7XApxm.js +1 -0
- package/dist/bundle/stateDiagram-v2-FJ4FJNEA-B69v2YYC.js +291 -0
- package/dist/bundle/swimlanes-UMQ2AFYF-C_qI6rnK.js +1 -0
- package/dist/bundle/swimlanesDiagram-OMPLPG4O-CS11qSCX.js +8 -0
- package/dist/bundle/timeline-definition-SEUHKTQE-BCU0-H8D.js +120 -0
- package/dist/bundle/treeView-D4JQ5SDB-CpjURS-c.js +1 -0
- package/dist/bundle/treemap-SAJKECNS-CFFTaiIN.js +1 -0
- package/dist/bundle/usecaseDiagram-AFA6YXN4-46V1jsea.js +476 -0
- package/dist/bundle/vega-eBn1AexV.js +33 -0
- package/dist/bundle/vennDiagram-NNMJR3RB-q4Q4x2Q6.js +34 -0
- package/dist/bundle/wardley-7MLQ67FV-DhnATL7b.js +1 -0
- package/dist/bundle/wardleyDiagram-S7YFUSEH-BHIufnZW.js +78 -0
- package/dist/bundle/xychartDiagram-GGNKY7IX-CxAjpN3O.js +7 -0
- package/dist/chunks/a2ui-Da_YceSP.js +961 -0
- package/dist/chunks/a2ui-Da_YceSP.js.map +1 -0
- package/dist/chunks/backstage-TkKENlNl.js +1008 -0
- package/dist/chunks/backstage-TkKENlNl.js.map +1 -0
- package/dist/chunks/{core-Db3hnKpM.js → core-4PRAI1Mt.js} +60 -5
- package/dist/chunks/core-4PRAI1Mt.js.map +1 -0
- package/dist/chunks/math-D5IXRTov.js +86 -0
- package/dist/chunks/math-D5IXRTov.js.map +1 -0
- package/dist/chunks/mermaid-j9RNkOnL.js +197 -0
- package/dist/chunks/mermaid-j9RNkOnL.js.map +1 -0
- package/dist/chunks/rich-CdNA4NuG.js +156 -0
- package/dist/chunks/rich-CdNA4NuG.js.map +1 -0
- package/dist/chunks/sanitize-COLQzplk.js +240 -0
- package/dist/chunks/sanitize-COLQzplk.js.map +1 -0
- package/dist/chunks/{src-CYXMXds2.js → src-PkQozp4M.js} +725 -146
- package/dist/chunks/src-PkQozp4M.js.map +1 -0
- package/dist/chunks/vega-B07F6TI4.js +301 -0
- package/dist/chunks/vega-B07F6TI4.js.map +1 -0
- package/dist/core.js +1 -1
- package/dist/define.js +3 -3
- package/dist/index.js +3 -3
- package/dist/types/core/session.d.ts +31 -0
- package/dist/types/element/backstage/index.d.ts +10 -0
- package/dist/types/element/backstage/log.d.ts +13 -0
- package/dist/types/element/backstage/map.d.ts +12 -0
- package/dist/types/element/backstage/timing.d.ts +51 -0
- package/dist/types/element/i18n.d.ts +69 -6
- package/dist/types/element/icons.d.ts +3 -0
- package/dist/types/element/index.d.ts +15 -5
- package/dist/types/element/markdown.d.ts +6 -3
- package/dist/types/element/rich/a2ui-format.d.ts +45 -0
- package/dist/types/element/rich/a2ui-icons.d.ts +1 -0
- package/dist/types/element/rich/a2ui-views.d.ts +37 -0
- package/dist/types/element/rich/a2ui.d.ts +2 -0
- package/dist/types/element/rich/index.d.ts +72 -0
- package/dist/types/element/rich/math.d.ts +4 -0
- package/dist/types/element/rich/mermaid.d.ts +2 -0
- package/dist/types/element/rich/vega.d.ts +2 -0
- package/dist/types/element/sanitize.d.ts +34 -0
- package/dist/types/element/styles.d.ts +1 -1
- package/dist/types/element/team.d.ts +14 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/jsx.d.ts +1 -1
- package/package.json +9 -3
- package/dist/chunks/core-Db3hnKpM.js.map +0 -1
- package/dist/chunks/src-CYXMXds2.js.map +0 -1
|
@@ -0,0 +1,961 @@
|
|
|
1
|
+
import { E as isRecord } from "./core-4PRAI1Mt.js";
|
|
2
|
+
import { t as adoptSheet } from "./sanitize-COLQzplk.js";
|
|
3
|
+
import { a as parseA2uiMessages, c as setMarkdown, i as formatA2uiAction, o as sentValuesOf, s as surfaceIdsOf } from "./src-PkQozp4M.js";
|
|
4
|
+
import { i as interfaces, n as disposers } from "./rich-CdNA4NuG.js";
|
|
5
|
+
import { Catalog, ComponentContext, GenericBinder, MessageProcessor } from "@a2ui/web_core/v0_9";
|
|
6
|
+
import { AudioPlayerApi, ButtonApi, CardApi, CheckBoxApi, ChoicePickerApi, ColumnApi, DateTimeInputApi, DividerApi, IconApi, ImageApi, ListApi, ModalApi, RowApi, SliderApi, TabsApi, TextApi, TextFieldApi, ThemeSchema, V09_SPEC_FUNCTIONS, VideoApi } from "@a2ui/web_core/v0_9/basic_catalog";
|
|
7
|
+
// src/element/rich/a2ui-icons.ts
|
|
8
|
+
var ICON_PATHS = {
|
|
9
|
+
accountCircle: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 4c1.93 0 3.5 1.57 3.5 3.5S13.93 13 12 13s-3.5-1.57-3.5-3.5S10.07 6 12 6zm0 14c-2.03 0-4.43-.82-6.14-2.88a9.947 9.947 0 0 1 12.28 0C16.43 19.18 14.03 20 12 20z",
|
|
10
|
+
add: "M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z",
|
|
11
|
+
arrowBack: "M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z",
|
|
12
|
+
arrowForward: "m12 4-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8z",
|
|
13
|
+
attachFile: "M16.5 6v11.5c0 2.21-1.79 4-4 4s-4-1.79-4-4V5a2.5 2.5 0 0 1 5 0v10.5c0 .55-.45 1-1 1s-1-.45-1-1V6H10v9.5a2.5 2.5 0 0 0 5 0V5c0-2.21-1.79-4-4-4S7 2.79 7 5v12.5c0 3.04 2.46 5.5 5.5 5.5s5.5-2.46 5.5-5.5V6h-1.5z",
|
|
14
|
+
calendarToday: "M20 3h-1V1h-2v2H7V1H5v2H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 18H4V8h16v13z",
|
|
15
|
+
call: "M20.01 15.38c-1.23 0-2.42-.2-3.53-.56a.977.977 0 0 0-1.01.24l-1.57 1.97c-2.83-1.35-5.48-3.9-6.89-6.83l1.95-1.66c.27-.28.35-.67.24-1.02-.37-1.11-.56-2.3-.56-3.53 0-.54-.45-.99-.99-.99H4.19C3.65 3 3 3.24 3 3.99 3 13.28 10.73 21 20.01 21c.71 0 .99-.63.99-1.18v-3.45c0-.54-.45-.99-.99-.99z",
|
|
16
|
+
camera: "M12 8.8a3.2 3.2 0 1 0 0 6.4 3.2 3.2 0 1 0 0-6.4z M9 2 7.17 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-3.17L15 2H9zm3 15c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z",
|
|
17
|
+
check: "M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z",
|
|
18
|
+
close: "M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z",
|
|
19
|
+
delete: "M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z",
|
|
20
|
+
download: "M5 20h14v-2H5v2zM19 9h-4V3H9v6H5l7 7 7-7z",
|
|
21
|
+
edit: "M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04a.996.996 0 0 0 0-1.41l-2.34-2.34a.996.996 0 0 0-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z",
|
|
22
|
+
error: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z",
|
|
23
|
+
event: "M17 12h-5v5h5v-5zM16 1v2H8V1H6v2H5c-1.11 0-1.99.9-1.99 2L3 19a2 2 0 0 0 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2h-1V1h-2zm3 18H5V8h14v11z",
|
|
24
|
+
fastForward: "m4 18 8.5-6L4 6v12zm9-12v12l8.5-6L13 6z",
|
|
25
|
+
favorite: "m12 21.35-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z",
|
|
26
|
+
favoriteOff: "M16.5 3c-1.74 0-3.41.81-4.5 2.09C10.91 3.81 9.24 3 7.5 3 4.42 3 2 5.42 2 8.5c0 3.78 3.4 6.86 8.55 11.54L12 21.35l1.45-1.32C18.6 15.36 22 12.28 22 8.5 22 5.42 19.58 3 16.5 3zm-4.4 15.55-.1.1-.1-.1C7.14 14.24 4 11.39 4 8.5 4 6.5 5.5 5 7.5 5c1.54 0 3.04.99 3.57 2.36h1.87C13.46 5.99 14.96 5 16.5 5c2 0 3.5 1.5 3.5 3.5 0 2.89-3.14 5.74-7.9 10.05z",
|
|
27
|
+
folder: "M10 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z",
|
|
28
|
+
help: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 17h-2v-2h2v2zm2.07-7.75-.9.92C13.45 12.9 13 13.5 13 15h-2v-.5c0-1.1.45-2.1 1.17-2.83l1.24-1.26c.37-.36.59-.86.59-1.41 0-1.1-.9-2-2-2s-2 .9-2 2H8c0-2.21 1.79-4 4-4s4 1.79 4 4c0 .88-.36 1.68-.93 2.25z",
|
|
29
|
+
home: "M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z",
|
|
30
|
+
info: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z",
|
|
31
|
+
locationOn: "M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5a2.5 2.5 0 0 1 0-5 2.5 2.5 0 0 1 0 5z",
|
|
32
|
+
lock: "M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1v2z",
|
|
33
|
+
lockOpen: "M12 17c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm6-9h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6h1.9c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm0 12H6V10h12v10z",
|
|
34
|
+
mail: "M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 4-8 5-8-5V6l8 5 8-5v2z",
|
|
35
|
+
menu: "M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z",
|
|
36
|
+
moreHoriz: "M6 10c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm12 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm-6 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z",
|
|
37
|
+
moreVert: "M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z",
|
|
38
|
+
notifications: "M12 22c1.1 0 2-.9 2-2h-4a2 2 0 0 0 2 2zm6-6v-5c0-3.07-1.64-5.64-4.5-6.32V4c0-.83-.67-1.5-1.5-1.5s-1.5.67-1.5 1.5v.68C7.63 5.36 6 7.92 6 11v5l-2 2v1h16v-1l-2-2z",
|
|
39
|
+
notificationsOff: "M20 18.69 7.84 6.14 5.27 3.49 4 4.76l2.8 2.8v.01c-.52.99-.8 2.16-.8 3.42v5l-2 2v1h13.73l2 2L21 19.72l-1-1.03zM12 22c1.11 0 2-.89 2-2h-4c0 1.11.89 2 2 2zm6-7.32V11c0-3.08-1.64-5.64-4.5-6.32V4c0-.83-.67-1.5-1.5-1.5s-1.5.67-1.5 1.5v.68c-.15.03-.29.08-.42.12-.1.03-.2.07-.3.11h-.01c-.01 0-.01 0-.02.01-.23.09-.46.2-.68.31 0 0-.01 0-.01.01L18 14.68z",
|
|
40
|
+
pause: "M6 19h4V5H6v14zm8-14v14h4V5h-4z",
|
|
41
|
+
payment: "M20 4H4c-1.11 0-1.99.89-1.99 2L2 18c0 1.11.89 2 2 2h16c1.11 0 2-.89 2-2V6c0-1.11-.89-2-2-2zm0 14H4v-6h16v6zm0-10H4V6h16v2z",
|
|
42
|
+
person: "M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z",
|
|
43
|
+
phone: "M6.62 10.79c1.44 2.83 3.76 5.14 6.59 6.59l2.2-2.2c.27-.27.67-.36 1.02-.24 1.12.37 2.33.57 3.57.57.55 0 1 .45 1 1V20c0 .55-.45 1-1 1-9.39 0-17-7.61-17-17 0-.55.45-1 1-1h3.5c.55 0 1 .45 1 1 0 1.25.2 2.45.57 3.57.11.35.03.74-.25 1.02l-2.2 2.2z",
|
|
44
|
+
photo: "M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z",
|
|
45
|
+
play: "M8 5v14l11-7z",
|
|
46
|
+
print: "M19 8H5c-1.66 0-3 1.34-3 3v6h4v4h12v-4h4v-6c0-1.66-1.34-3-3-3zm-3 11H8v-5h8v5zm3-7c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm-1-9H6v4h12V3z",
|
|
47
|
+
refresh: "M17.65 6.35A7.958 7.958 0 0 0 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08A5.99 5.99 0 0 1 12 18c-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z",
|
|
48
|
+
rewind: "M11 18V6l-8.5 6 8.5 6zm.5-6 8.5 6V6l-8.5 6z",
|
|
49
|
+
search: "M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z",
|
|
50
|
+
send: "M2.01 21 23 12 2.01 3 2 10l15 2-15 2z",
|
|
51
|
+
settings: "M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58a.49.49 0 0 0 .12-.61l-1.92-3.32a.488.488 0 0 0-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54a.484.484 0 0 0-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58a.49.49 0 0 0-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6z",
|
|
52
|
+
share: "M18 16.08c-.76 0-1.44.3-1.96.77L8.91 12.7c.05-.23.09-.46.09-.7s-.04-.47-.09-.7l7.05-4.11c.54.5 1.25.81 2.04.81 1.66 0 3-1.34 3-3s-1.34-3-3-3-3 1.34-3 3c0 .24.04.47.09.7L8.04 9.81C7.5 9.31 6.79 9 6 9c-1.66 0-3 1.34-3 3s1.34 3 3 3c.79 0 1.5-.31 2.04-.81l7.12 4.16c-.05.21-.08.43-.08.65 0 1.61 1.31 2.92 2.92 2.92 1.61 0 2.92-1.31 2.92-2.92s-1.31-2.92-2.92-2.92z",
|
|
53
|
+
shoppingCart: "M7 18c-1.1 0-1.99.9-1.99 2S5.9 22 7 22s2-.9 2-2-.9-2-2-2zM1 2v2h2l3.6 7.59-1.35 2.45c-.16.28-.25.61-.25.96 0 1.1.9 2 2 2h12v-2H7.42c-.14 0-.25-.11-.25-.25l.03-.12.9-1.63h7.45c.75 0 1.41-.41 1.75-1.03l3.58-6.49A1.003 1.003 0 0 0 20 4H5.21l-.94-2H1zm16 16c-1.1 0-1.99.9-1.99 2s.89 2 1.99 2 2-.9 2-2-.9-2-2-2z",
|
|
54
|
+
skipNext: "m6 18 8.5-6L6 6v12zM16 6v12h2V6h-2z",
|
|
55
|
+
skipPrevious: "M6 6h2v12H6zm3.5 6 8.5 6V6z",
|
|
56
|
+
star: "M12 17.27 18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z",
|
|
57
|
+
starHalf: "m22 9.24-7.19-.62L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21 12 17.27 18.18 21l-1.63-7.03L22 9.24zM12 15.4V6.1l1.71 4.04 4.38.38-3.32 2.88 1 4.28L12 15.4z",
|
|
58
|
+
starOff: "m22 9.24-7.19-.62L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21 12 17.27 18.18 21l-1.63-7.03L22 9.24zM12 15.4l-3.76 2.27 1-4.28-3.32-2.88 4.38-.38L12 6.1l1.71 4.04 4.38.38-3.32 2.88 1 4.28L12 15.4z",
|
|
59
|
+
stop: "M6 6h12v12H6z",
|
|
60
|
+
upload: "M5 20h14v-2H5v2zm0-10h4v6h6v-6h4l-7-7-7 7z",
|
|
61
|
+
visibility: "M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z",
|
|
62
|
+
visibilityOff: "M12 7c2.76 0 5 2.24 5 5 0 .65-.13 1.26-.36 1.83l2.92 2.92c1.51-1.26 2.7-2.89 3.43-4.75-1.73-4.39-6-7.5-11-7.5-1.4 0-2.74.25-3.98.7l2.16 2.16C10.74 7.13 11.35 7 12 7zM2 4.27l2.28 2.28.46.46A11.804 11.804 0 0 0 1 12c1.73 4.39 6 7.5 11 7.5 1.55 0 3.03-.3 4.38-.84l.42.42L19.73 22 21 20.73 3.27 3 2 4.27zM7.53 9.8l1.55 1.55c-.05.21-.08.43-.08.65 0 1.66 1.34 3 3 3 .22 0 .44-.03.65-.08l1.55 1.55c-.67.33-1.41.53-2.2.53-2.76 0-5-2.24-5-5 0-.79.2-1.53.53-2.2zm4.31-.78 3.15 3.15.02-.16c0-1.66-1.34-3-3-3l-.17.01z",
|
|
63
|
+
volumeDown: "M18.5 12A4.5 4.5 0 0 0 16 7.97v8.05c1.48-.73 2.5-2.25 2.5-4.02zM5 9v6h4l5 5V4L9 9H5z",
|
|
64
|
+
volumeMute: "M7 9v6h4l5 5V4l-5 5H7z",
|
|
65
|
+
volumeOff: "M16.5 12A4.5 4.5 0 0 0 14 7.97v2.21l2.45 2.45c.03-.2.05-.41.05-.63zm2.5 0c0 .94-.2 1.82-.54 2.64l1.51 1.51A8.796 8.796 0 0 0 21 12c0-4.28-2.99-7.86-7-8.77v2.06c2.89.86 5 3.54 5 6.71zM4.27 3 3 4.27 7.73 9H3v6h4l5 5v-6.73l4.25 4.25c-.67.52-1.42.93-2.25 1.18v2.06a8.99 8.99 0 0 0 3.69-1.81L19.73 21 21 19.73l-9-9L4.27 3zM12 4 9.91 6.09 12 8.18V4z",
|
|
66
|
+
volumeUp: "M3 9v6h4l5 5V4L7 9H3zm13.5 3A4.5 4.5 0 0 0 14 7.97v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z",
|
|
67
|
+
warning: "M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z"
|
|
68
|
+
};
|
|
69
|
+
// src/element/rich/a2ui-views.ts
|
|
70
|
+
function h(tag, className, text) {
|
|
71
|
+
const el = document.createElement(tag);
|
|
72
|
+
if (className) el.className = className;
|
|
73
|
+
if (text !== void 0) el.textContent = text;
|
|
74
|
+
return el;
|
|
75
|
+
}
|
|
76
|
+
/** A text prop the binder resolved: a string, a number from the data model,
|
|
77
|
+
* or nothing while a binding has no value yet. */
|
|
78
|
+
function asText(value) {
|
|
79
|
+
if (typeof value === "string") return value;
|
|
80
|
+
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
81
|
+
return "";
|
|
82
|
+
}
|
|
83
|
+
/** `weight` is the component's share of its row or column. */
|
|
84
|
+
function setWeight(el, weight) {
|
|
85
|
+
el.style.flex = typeof weight === "number" ? String(weight) : "";
|
|
86
|
+
}
|
|
87
|
+
function labelOf(props) {
|
|
88
|
+
const accessibility = props.accessibility;
|
|
89
|
+
if (!isRecord(accessibility) || typeof accessibility.label !== "string") return void 0;
|
|
90
|
+
return accessibility.label || void 0;
|
|
91
|
+
}
|
|
92
|
+
function setAttr(el, name, value) {
|
|
93
|
+
if (value === void 0) el.removeAttribute(name);
|
|
94
|
+
else el.setAttribute(name, value);
|
|
95
|
+
}
|
|
96
|
+
/** A container with an accessible label is a named group. */
|
|
97
|
+
function setGroup(el, props) {
|
|
98
|
+
const label = labelOf(props);
|
|
99
|
+
setAttr(el, "role", label === void 0 ? void 0 : "group");
|
|
100
|
+
setAttr(el, "aria-label", label);
|
|
101
|
+
}
|
|
102
|
+
function errorsOf(props) {
|
|
103
|
+
const errors = props.validationErrors;
|
|
104
|
+
return Array.isArray(errors) ? errors.map(asText).join(" ") : "";
|
|
105
|
+
}
|
|
106
|
+
/** The error line under a field, and the field's `aria-invalid`. */
|
|
107
|
+
function showErrors(line, field, props) {
|
|
108
|
+
const text = errorsOf(props);
|
|
109
|
+
line.textContent = text;
|
|
110
|
+
line.hidden = text === "";
|
|
111
|
+
setAttr(field, "aria-invalid", text === "" ? void 0 : "true");
|
|
112
|
+
}
|
|
113
|
+
function errorLine(ui, field) {
|
|
114
|
+
const line = h("p", "a2ui-error");
|
|
115
|
+
line.id = ui.uid();
|
|
116
|
+
line.hidden = true;
|
|
117
|
+
field.setAttribute("aria-describedby", line.id);
|
|
118
|
+
return line;
|
|
119
|
+
}
|
|
120
|
+
function safeUrl(value) {
|
|
121
|
+
const url = asText(value);
|
|
122
|
+
return /^https?:\/\//i.test(url) ? url : null;
|
|
123
|
+
}
|
|
124
|
+
function refOf(child, path) {
|
|
125
|
+
if (typeof child === "string") return {
|
|
126
|
+
id: child,
|
|
127
|
+
path
|
|
128
|
+
};
|
|
129
|
+
if (isRecord(child) && typeof child.id === "string") return {
|
|
130
|
+
id: child.id,
|
|
131
|
+
path: typeof child.basePath === "string" ? child.basePath : path
|
|
132
|
+
};
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
/** The children of a container, kept across updates by id and data scope. */
|
|
136
|
+
function children(ui, path) {
|
|
137
|
+
let mounted = /* @__PURE__ */ new Map();
|
|
138
|
+
return {
|
|
139
|
+
sync(parent, refs) {
|
|
140
|
+
const next = /* @__PURE__ */ new Map();
|
|
141
|
+
const nodes = [];
|
|
142
|
+
for (const child of Array.isArray(refs) ? refs : [refs]) {
|
|
143
|
+
const ref = refOf(child, path);
|
|
144
|
+
if (!ref) continue;
|
|
145
|
+
const key = `${ref.id}@${ref.path}`;
|
|
146
|
+
const node = next.get(key) ?? mounted.get(key) ?? ui.mount(ref.id, ref.path);
|
|
147
|
+
next.set(key, node);
|
|
148
|
+
nodes.push(node.el);
|
|
149
|
+
}
|
|
150
|
+
for (const [key, node] of mounted) if (!next.has(key)) node.dispose();
|
|
151
|
+
mounted = next;
|
|
152
|
+
const shown = parent.children;
|
|
153
|
+
if (nodes.length !== shown.length || nodes.some((node, i) => node !== shown[i])) parent.replaceChildren(...nodes);
|
|
154
|
+
},
|
|
155
|
+
dispose() {
|
|
156
|
+
for (const node of mounted.values()) node.dispose();
|
|
157
|
+
mounted.clear();
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
var TITLES = [
|
|
162
|
+
"h1",
|
|
163
|
+
"h2",
|
|
164
|
+
"h3",
|
|
165
|
+
"h4",
|
|
166
|
+
"h5"
|
|
167
|
+
];
|
|
168
|
+
var text = (ui) => {
|
|
169
|
+
const el = h("div", "a2ui-text");
|
|
170
|
+
let shown = null;
|
|
171
|
+
return {
|
|
172
|
+
el,
|
|
173
|
+
update(props) {
|
|
174
|
+
setWeight(el, props.weight);
|
|
175
|
+
const variant = asText(props.variant) || "body";
|
|
176
|
+
const value = asText(props.text);
|
|
177
|
+
const key = `${variant}\n${value}`;
|
|
178
|
+
if (key === shown) return;
|
|
179
|
+
shown = key;
|
|
180
|
+
const title = TITLES.find((tag) => tag === variant);
|
|
181
|
+
if (title) el.replaceChildren(h(title, "a2ui-title", value));
|
|
182
|
+
else if (variant === "caption") el.replaceChildren(h("span", "a2ui-caption", value));
|
|
183
|
+
else {
|
|
184
|
+
const body = h("div", "markdown");
|
|
185
|
+
setMarkdown(body, value, {
|
|
186
|
+
host: ui.env.host,
|
|
187
|
+
widgets: false,
|
|
188
|
+
lang: ui.env.lang,
|
|
189
|
+
strings: ui.strings
|
|
190
|
+
});
|
|
191
|
+
for (const link of body.querySelectorAll("a")) link.replaceWith(...link.childNodes);
|
|
192
|
+
el.replaceChildren(body);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
var SVG = "http://www.w3.org/2000/svg";
|
|
198
|
+
var icon = () => {
|
|
199
|
+
const el = h("span", "a2ui-icon");
|
|
200
|
+
return {
|
|
201
|
+
el,
|
|
202
|
+
update(props) {
|
|
203
|
+
const name = props.name;
|
|
204
|
+
const d = typeof name === "string" ? ICON_PATHS[name] : isRecord(name) && typeof name.svgPath === "string" ? name.svgPath : void 0;
|
|
205
|
+
if (d === void 0) {
|
|
206
|
+
el.replaceChildren();
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
const svg = document.createElementNS(SVG, "svg");
|
|
210
|
+
svg.setAttribute("viewBox", "0 0 24 24");
|
|
211
|
+
const path = document.createElementNS(SVG, "path");
|
|
212
|
+
path.setAttribute("d", d);
|
|
213
|
+
path.setAttribute("fill", "currentColor");
|
|
214
|
+
svg.append(path);
|
|
215
|
+
el.replaceChildren(svg);
|
|
216
|
+
const label = labelOf(props);
|
|
217
|
+
setAttr(el, "role", label === void 0 ? void 0 : "img");
|
|
218
|
+
setAttr(el, "aria-label", label);
|
|
219
|
+
setAttr(el, "aria-hidden", label === void 0 ? "true" : void 0);
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
};
|
|
223
|
+
/** Image, video, audio: their description (or address) as text. Never
|
|
224
|
+
* loaded by the page, and not a link either: the address can be built from
|
|
225
|
+
* what the user typed, and a link would carry it to another site. */
|
|
226
|
+
var media = (kind) => () => {
|
|
227
|
+
const el = h("span", `a2ui-media a2ui-${kind}`);
|
|
228
|
+
return {
|
|
229
|
+
el,
|
|
230
|
+
update(props) {
|
|
231
|
+
setWeight(el, props.weight);
|
|
232
|
+
el.textContent = asText(props.description) || (labelOf(props) ?? safeUrl(props.url) ?? "");
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
};
|
|
236
|
+
var flexBox = (kind) => (ui, path) => {
|
|
237
|
+
const el = h("div", `a2ui-${kind}`);
|
|
238
|
+
const list = children(ui, path);
|
|
239
|
+
return {
|
|
240
|
+
el,
|
|
241
|
+
update(props) {
|
|
242
|
+
setWeight(el, props.weight);
|
|
243
|
+
setGroup(el, props);
|
|
244
|
+
el.dataset.justify = asText(props.justify) || "start";
|
|
245
|
+
el.dataset.align = asText(props.align) || "stretch";
|
|
246
|
+
if (kind === "list") el.dataset.direction = asText(props.direction) || "vertical";
|
|
247
|
+
list.sync(el, props.children);
|
|
248
|
+
},
|
|
249
|
+
dispose: () => list.dispose()
|
|
250
|
+
};
|
|
251
|
+
};
|
|
252
|
+
var card = (ui, path) => {
|
|
253
|
+
const el = h("div", "a2ui-card");
|
|
254
|
+
const child = children(ui, path);
|
|
255
|
+
return {
|
|
256
|
+
el,
|
|
257
|
+
update(props) {
|
|
258
|
+
setWeight(el, props.weight);
|
|
259
|
+
setGroup(el, props);
|
|
260
|
+
child.sync(el, props.child);
|
|
261
|
+
},
|
|
262
|
+
dispose: () => child.dispose()
|
|
263
|
+
};
|
|
264
|
+
};
|
|
265
|
+
var divider = () => {
|
|
266
|
+
const el = h("hr", "a2ui-divider");
|
|
267
|
+
return {
|
|
268
|
+
el,
|
|
269
|
+
update(props) {
|
|
270
|
+
const vertical = props.axis === "vertical";
|
|
271
|
+
el.classList.toggle("vertical", vertical);
|
|
272
|
+
setAttr(el, "aria-orientation", vertical ? "vertical" : void 0);
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
};
|
|
276
|
+
var tabs = (ui, path) => {
|
|
277
|
+
const el = h("div", "a2ui-tabs");
|
|
278
|
+
const bar = h("div", "a2ui-tablist");
|
|
279
|
+
bar.setAttribute("role", "tablist");
|
|
280
|
+
bar.setAttribute("aria-label", ui.strings.a2uiTabs);
|
|
281
|
+
const panel = h("div", "a2ui-tabpanel");
|
|
282
|
+
panel.id = ui.uid();
|
|
283
|
+
panel.setAttribute("role", "tabpanel");
|
|
284
|
+
el.append(bar, panel);
|
|
285
|
+
const content = children(ui, path);
|
|
286
|
+
let selected = 0;
|
|
287
|
+
let last = {};
|
|
288
|
+
const draw = () => {
|
|
289
|
+
const list = Array.isArray(last.tabs) ? last.tabs.filter(isRecord) : [];
|
|
290
|
+
el.hidden = list.length === 0;
|
|
291
|
+
if (selected >= list.length) selected = 0;
|
|
292
|
+
bar.replaceChildren(...list.map((tab, index) => {
|
|
293
|
+
const button = h("button", "a2ui-tab", asText(tab.title));
|
|
294
|
+
button.type = "button";
|
|
295
|
+
button.setAttribute("role", "tab");
|
|
296
|
+
button.setAttribute("aria-selected", String(index === selected));
|
|
297
|
+
button.setAttribute("aria-controls", panel.id);
|
|
298
|
+
button.addEventListener("click", () => {
|
|
299
|
+
selected = index;
|
|
300
|
+
draw();
|
|
301
|
+
});
|
|
302
|
+
return button;
|
|
303
|
+
}));
|
|
304
|
+
content.sync(panel, list[selected]?.child);
|
|
305
|
+
};
|
|
306
|
+
return {
|
|
307
|
+
el,
|
|
308
|
+
update(props) {
|
|
309
|
+
setWeight(el, props.weight);
|
|
310
|
+
last = props;
|
|
311
|
+
draw();
|
|
312
|
+
},
|
|
313
|
+
dispose: () => content.dispose()
|
|
314
|
+
};
|
|
315
|
+
};
|
|
316
|
+
var modal = (ui, path) => {
|
|
317
|
+
const el = h("span", "a2ui-modal");
|
|
318
|
+
const trigger = h("span", "a2ui-modal-trigger");
|
|
319
|
+
const dialog = h("dialog", "a2ui-dialog");
|
|
320
|
+
const title = h("h2", "a2ui-title", ui.strings.a2uiDetails);
|
|
321
|
+
title.id = ui.uid();
|
|
322
|
+
dialog.setAttribute("aria-labelledby", title.id);
|
|
323
|
+
const body = h("div", "a2ui-dialog-body");
|
|
324
|
+
const close = h("button", "a2ui-button", ui.strings.close);
|
|
325
|
+
close.type = "button";
|
|
326
|
+
close.dataset.variant = "default";
|
|
327
|
+
const footer = h("div", "a2ui-dialog-footer");
|
|
328
|
+
footer.append(close);
|
|
329
|
+
dialog.append(title, body, footer);
|
|
330
|
+
el.append(trigger, dialog);
|
|
331
|
+
const opener = children(ui, path);
|
|
332
|
+
const content = children(ui, path);
|
|
333
|
+
let last = {};
|
|
334
|
+
trigger.addEventListener("click", () => {
|
|
335
|
+
content.sync(body, last.content);
|
|
336
|
+
dialog.showModal();
|
|
337
|
+
});
|
|
338
|
+
close.addEventListener("click", () => dialog.close());
|
|
339
|
+
dialog.addEventListener("close", () => content.sync(body, []));
|
|
340
|
+
return {
|
|
341
|
+
el,
|
|
342
|
+
update(props) {
|
|
343
|
+
last = props;
|
|
344
|
+
opener.sync(trigger, props.trigger);
|
|
345
|
+
if (dialog.open) content.sync(body, props.content);
|
|
346
|
+
},
|
|
347
|
+
dispose() {
|
|
348
|
+
opener.dispose();
|
|
349
|
+
content.dispose();
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
};
|
|
353
|
+
var button = (ui, path) => {
|
|
354
|
+
const el = h("button", "a2ui-button");
|
|
355
|
+
el.type = "button";
|
|
356
|
+
const child = children(ui, path);
|
|
357
|
+
let last = {};
|
|
358
|
+
ui.control(el, () => last.isValid === false);
|
|
359
|
+
el.addEventListener("click", () => {
|
|
360
|
+
const action = last.action;
|
|
361
|
+
if (typeof action === "function") action();
|
|
362
|
+
});
|
|
363
|
+
return {
|
|
364
|
+
el,
|
|
365
|
+
update(props) {
|
|
366
|
+
last = props;
|
|
367
|
+
setWeight(el, props.weight);
|
|
368
|
+
el.dataset.variant = asText(props.variant) || "default";
|
|
369
|
+
setAttr(el, "aria-label", labelOf(props));
|
|
370
|
+
child.sync(el, props.child);
|
|
371
|
+
ui.refresh(el);
|
|
372
|
+
},
|
|
373
|
+
dispose: () => child.dispose()
|
|
374
|
+
};
|
|
375
|
+
};
|
|
376
|
+
function setter(props, name = "setValue") {
|
|
377
|
+
const set = props[name];
|
|
378
|
+
return typeof set === "function" ? set : () => void 0;
|
|
379
|
+
}
|
|
380
|
+
/** A labelled field: the label, the control, the error line. */
|
|
381
|
+
function field(ui, control) {
|
|
382
|
+
const el = h("div", "a2ui-field");
|
|
383
|
+
const label = h("label", "a2ui-label");
|
|
384
|
+
control.id = ui.uid();
|
|
385
|
+
label.htmlFor = control.id;
|
|
386
|
+
const errors = errorLine(ui, control);
|
|
387
|
+
el.append(label, control, errors);
|
|
388
|
+
ui.control(control);
|
|
389
|
+
return {
|
|
390
|
+
el,
|
|
391
|
+
label,
|
|
392
|
+
errors
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
var textField = (ui) => {
|
|
396
|
+
let control = null;
|
|
397
|
+
let parts = null;
|
|
398
|
+
let kind = "";
|
|
399
|
+
let last = {};
|
|
400
|
+
const wrapper = h("div", "a2ui-field-wrapper");
|
|
401
|
+
return {
|
|
402
|
+
el: wrapper,
|
|
403
|
+
update(props) {
|
|
404
|
+
last = props;
|
|
405
|
+
const variant = asText(props.variant) || "shortText";
|
|
406
|
+
if (variant !== kind || !control || !parts) {
|
|
407
|
+
kind = variant;
|
|
408
|
+
if (variant === "longText") control = h("textarea", "a2ui-input");
|
|
409
|
+
else {
|
|
410
|
+
const input = h("input", "a2ui-input");
|
|
411
|
+
input.type = variant === "number" ? "number" : variant === "obscured" ? "password" : "text";
|
|
412
|
+
control = input;
|
|
413
|
+
}
|
|
414
|
+
control.addEventListener("input", (event) => {
|
|
415
|
+
setter(last)(event.target.value);
|
|
416
|
+
});
|
|
417
|
+
parts = field(ui, control);
|
|
418
|
+
wrapper.replaceChildren(parts.el);
|
|
419
|
+
}
|
|
420
|
+
setWeight(wrapper, props.weight);
|
|
421
|
+
parts.label.textContent = asText(props.label);
|
|
422
|
+
setAttr(control, "aria-label", labelOf(props));
|
|
423
|
+
const value = asText(props.value);
|
|
424
|
+
if (control.value !== value) control.value = value;
|
|
425
|
+
showErrors(parts.errors, control, props);
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
};
|
|
429
|
+
var checkBox = (ui) => {
|
|
430
|
+
const el = h("div", "a2ui-field");
|
|
431
|
+
const label = h("label", "a2ui-check");
|
|
432
|
+
const input = h("input");
|
|
433
|
+
input.type = "checkbox";
|
|
434
|
+
const caption = h("span");
|
|
435
|
+
label.append(input, caption);
|
|
436
|
+
const errors = errorLine(ui, input);
|
|
437
|
+
el.append(label, errors);
|
|
438
|
+
ui.control(input);
|
|
439
|
+
let last = {};
|
|
440
|
+
input.addEventListener("change", () => setter(last)(input.checked));
|
|
441
|
+
return {
|
|
442
|
+
el,
|
|
443
|
+
update(props) {
|
|
444
|
+
last = props;
|
|
445
|
+
setWeight(el, props.weight);
|
|
446
|
+
caption.textContent = asText(props.label);
|
|
447
|
+
input.checked = props.value === true;
|
|
448
|
+
showErrors(errors, input, props);
|
|
449
|
+
}
|
|
450
|
+
};
|
|
451
|
+
};
|
|
452
|
+
var choicePicker = (ui) => {
|
|
453
|
+
const el = h("fieldset", "a2ui-choices");
|
|
454
|
+
const legend = h("legend", "a2ui-label");
|
|
455
|
+
const options = h("div", "a2ui-options");
|
|
456
|
+
const errors = errorLine(ui, el);
|
|
457
|
+
el.append(legend, options, errors);
|
|
458
|
+
const name = ui.uid();
|
|
459
|
+
let last = {};
|
|
460
|
+
let drawn = "";
|
|
461
|
+
const selectedOf = (props) => {
|
|
462
|
+
const raw = props.value;
|
|
463
|
+
return Array.isArray(raw) ? raw.filter((value) => typeof value === "string") : typeof raw === "string" ? [raw] : [];
|
|
464
|
+
};
|
|
465
|
+
const choose = (value, on) => {
|
|
466
|
+
const multiple = last.variant === "multipleSelection";
|
|
467
|
+
const others = selectedOf(last).filter((other) => other !== value);
|
|
468
|
+
setter(last)(multiple ? on ? [...others, value] : others : on ? [value] : []);
|
|
469
|
+
};
|
|
470
|
+
return {
|
|
471
|
+
el,
|
|
472
|
+
update(props) {
|
|
473
|
+
last = props;
|
|
474
|
+
setWeight(el, props.weight);
|
|
475
|
+
legend.textContent = asText(props.label);
|
|
476
|
+
legend.hidden = legend.textContent === "";
|
|
477
|
+
setAttr(el, "aria-label", labelOf(props));
|
|
478
|
+
const list = (Array.isArray(props.options) ? props.options : []).filter(isRecord).map((option) => ({
|
|
479
|
+
value: asText(option.value),
|
|
480
|
+
label: asText(option.label)
|
|
481
|
+
}));
|
|
482
|
+
const style = asText(props.displayStyle);
|
|
483
|
+
const multiple = props.variant === "multipleSelection";
|
|
484
|
+
const shape = JSON.stringify([
|
|
485
|
+
style,
|
|
486
|
+
multiple,
|
|
487
|
+
list
|
|
488
|
+
]);
|
|
489
|
+
const selected = selectedOf(props);
|
|
490
|
+
if (shape !== drawn) {
|
|
491
|
+
drawn = shape;
|
|
492
|
+
options.dataset.style = style === "chips" ? "chips" : "list";
|
|
493
|
+
options.replaceChildren(...list.map((option) => {
|
|
494
|
+
if (style === "chips") {
|
|
495
|
+
const chip = h("button", "a2ui-chip", option.label);
|
|
496
|
+
chip.type = "button";
|
|
497
|
+
chip.dataset.value = option.value;
|
|
498
|
+
chip.addEventListener("click", () => choose(option.value, chip.getAttribute("aria-pressed") !== "true"));
|
|
499
|
+
ui.control(chip);
|
|
500
|
+
return chip;
|
|
501
|
+
}
|
|
502
|
+
const row = h("label", "a2ui-check");
|
|
503
|
+
const input = h("input");
|
|
504
|
+
input.type = multiple ? "checkbox" : "radio";
|
|
505
|
+
input.name = name;
|
|
506
|
+
input.dataset.value = option.value;
|
|
507
|
+
input.addEventListener("change", () => choose(option.value, input.checked));
|
|
508
|
+
ui.control(input);
|
|
509
|
+
row.append(input, h("span", void 0, option.label));
|
|
510
|
+
return row;
|
|
511
|
+
}));
|
|
512
|
+
}
|
|
513
|
+
for (const chip of options.querySelectorAll(".a2ui-chip")) chip.setAttribute("aria-pressed", String(selected.includes(chip.dataset.value ?? "")));
|
|
514
|
+
for (const input of options.querySelectorAll("input")) input.checked = selected.includes(input.dataset.value ?? "");
|
|
515
|
+
showErrors(errors, el, props);
|
|
516
|
+
}
|
|
517
|
+
};
|
|
518
|
+
};
|
|
519
|
+
var slider = (ui) => {
|
|
520
|
+
const input = h("input", "a2ui-range");
|
|
521
|
+
input.type = "range";
|
|
522
|
+
const parts = field(ui, input);
|
|
523
|
+
let last = {};
|
|
524
|
+
input.addEventListener("input", () => setter(last)(Number(input.value)));
|
|
525
|
+
return {
|
|
526
|
+
el: parts.el,
|
|
527
|
+
update(props) {
|
|
528
|
+
last = props;
|
|
529
|
+
setWeight(parts.el, props.weight);
|
|
530
|
+
const value = typeof props.value === "number" ? props.value : void 0;
|
|
531
|
+
const label = asText(props.label) || (labelOf(props) ?? "");
|
|
532
|
+
parts.label.textContent = value === void 0 ? label : label ? `${label}: ${value}` : String(value);
|
|
533
|
+
const min = typeof props.min === "number" ? props.min : 0;
|
|
534
|
+
input.min = String(min);
|
|
535
|
+
input.max = typeof props.max === "number" ? String(props.max) : "";
|
|
536
|
+
const shown = String(value ?? min);
|
|
537
|
+
if (input.value !== shown) input.value = shown;
|
|
538
|
+
showErrors(parts.errors, input, props);
|
|
539
|
+
}
|
|
540
|
+
};
|
|
541
|
+
};
|
|
542
|
+
/** What a date, time or datetime-local input accepts, from the ISO or partial
|
|
543
|
+
* value of the agent or the model: no seconds, no zone. */
|
|
544
|
+
function normalizeDateTime(value, kind) {
|
|
545
|
+
if (!value) return "";
|
|
546
|
+
const [datePart = "", timePart = ""] = value.includes("T") ? value.split("T", 2) : value.includes("-") ? [value, ""] : ["", value];
|
|
547
|
+
const date = datePart.slice(0, 10);
|
|
548
|
+
const time = timePart.includes(":") ? timePart.slice(0, 5) : "";
|
|
549
|
+
if (kind === "date") return date;
|
|
550
|
+
if (kind === "time") return time;
|
|
551
|
+
if (!date) return "";
|
|
552
|
+
return `${date}T${time || "00:00"}`;
|
|
553
|
+
}
|
|
554
|
+
var dateTime = (ui) => {
|
|
555
|
+
const input = h("input", "a2ui-input");
|
|
556
|
+
const parts = field(ui, input);
|
|
557
|
+
let last = {};
|
|
558
|
+
input.addEventListener("input", () => setter(last)(input.value));
|
|
559
|
+
return {
|
|
560
|
+
el: parts.el,
|
|
561
|
+
update(props) {
|
|
562
|
+
last = props;
|
|
563
|
+
setWeight(parts.el, props.weight);
|
|
564
|
+
const enableTime = props.enableTime === true;
|
|
565
|
+
const kind = (typeof props.enableDate === "boolean" ? props.enableDate : !enableTime) && enableTime ? "datetime-local" : enableTime ? "time" : "date";
|
|
566
|
+
if (input.type !== kind) input.type = kind;
|
|
567
|
+
parts.label.textContent = asText(props.label);
|
|
568
|
+
setAttr(input, "aria-label", labelOf(props));
|
|
569
|
+
const value = normalizeDateTime(asText(props.value), kind);
|
|
570
|
+
if (input.value !== value) input.value = value;
|
|
571
|
+
setAttr(input, "min", normalizeDateTime(asText(props.min), kind) || void 0);
|
|
572
|
+
setAttr(input, "max", normalizeDateTime(asText(props.max), kind) || void 0);
|
|
573
|
+
showErrors(parts.errors, input, props);
|
|
574
|
+
}
|
|
575
|
+
};
|
|
576
|
+
};
|
|
577
|
+
var VIEWS = {
|
|
578
|
+
Text: text,
|
|
579
|
+
Image: media("image"),
|
|
580
|
+
Icon: icon,
|
|
581
|
+
Video: media("video"),
|
|
582
|
+
AudioPlayer: media("audio"),
|
|
583
|
+
Row: flexBox("row"),
|
|
584
|
+
Column: flexBox("column"),
|
|
585
|
+
List: flexBox("list"),
|
|
586
|
+
Card: card,
|
|
587
|
+
Tabs: tabs,
|
|
588
|
+
Modal: modal,
|
|
589
|
+
Divider: divider,
|
|
590
|
+
Button: button,
|
|
591
|
+
TextField: textField,
|
|
592
|
+
CheckBox: checkBox,
|
|
593
|
+
ChoicePicker: choicePicker,
|
|
594
|
+
Slider: slider,
|
|
595
|
+
DateTimeInput: dateTime
|
|
596
|
+
};
|
|
597
|
+
// src/element/rich/a2ui.ts
|
|
598
|
+
var BASIC_CATALOG_ID = "https://a2ui.org/specification/v0_9/catalogs/basic/catalog.json";
|
|
599
|
+
/** The basic catalog's functions but `openUrl`: the others check and format
|
|
600
|
+
* values; `openUrl` would open an address the model chose, which can carry
|
|
601
|
+
* what the user typed in the form (`formatString` of `/email`) to another
|
|
602
|
+
* site at one click. A markdown link only carries what the model already
|
|
603
|
+
* knew. A button that calls it draws, and does nothing. */
|
|
604
|
+
var FUNCTIONS = V09_SPEC_FUNCTIONS.filter((fn) => fn.name !== "openUrl");
|
|
605
|
+
var catalog = new Catalog(BASIC_CATALOG_ID, "0.9", [
|
|
606
|
+
TextApi,
|
|
607
|
+
ImageApi,
|
|
608
|
+
IconApi,
|
|
609
|
+
VideoApi,
|
|
610
|
+
AudioPlayerApi,
|
|
611
|
+
RowApi,
|
|
612
|
+
ColumnApi,
|
|
613
|
+
ListApi,
|
|
614
|
+
CardApi,
|
|
615
|
+
TabsApi,
|
|
616
|
+
ModalApi,
|
|
617
|
+
DividerApi,
|
|
618
|
+
ButtonApi,
|
|
619
|
+
TextFieldApi,
|
|
620
|
+
CheckBoxApi,
|
|
621
|
+
ChoicePickerApi,
|
|
622
|
+
SliderApi,
|
|
623
|
+
DateTimeInputApi
|
|
624
|
+
], FUNCTIONS, { themeSchema: ThemeSchema });
|
|
625
|
+
/** Answers already in the history name the catalog .../v0_9_1/...: the same
|
|
626
|
+
* catalog, which the processor matches by exact id. */
|
|
627
|
+
var BASIC_CATALOG_IDS = /^https:\/\/a2ui\.org\/specification\/v0_9(?:_\d+)?\/catalogs\/basic\/catalog\.json$/;
|
|
628
|
+
function withKnownCatalog(messages) {
|
|
629
|
+
return messages.map((message) => {
|
|
630
|
+
const created = message.createSurface;
|
|
631
|
+
if (!isRecord(created) || typeof created.catalogId !== "string" || created.catalogId === BASIC_CATALOG_ID || !BASIC_CATALOG_IDS.test(created.catalogId)) return message;
|
|
632
|
+
return {
|
|
633
|
+
...message,
|
|
634
|
+
createSurface: {
|
|
635
|
+
...created,
|
|
636
|
+
catalogId: BASIC_CATALOG_ID
|
|
637
|
+
}
|
|
638
|
+
};
|
|
639
|
+
});
|
|
640
|
+
}
|
|
641
|
+
function mapComponents(messages, fix) {
|
|
642
|
+
return messages.map((message) => {
|
|
643
|
+
const update = message.updateComponents;
|
|
644
|
+
if (!isRecord(update) || !Array.isArray(update.components)) return message;
|
|
645
|
+
const given = update.components;
|
|
646
|
+
const components = given.map((component) => isRecord(component) ? fix(component) : component);
|
|
647
|
+
return components.some((component, i) => component !== given[i]) ? {
|
|
648
|
+
...message,
|
|
649
|
+
updateComponents: {
|
|
650
|
+
...update,
|
|
651
|
+
components
|
|
652
|
+
}
|
|
653
|
+
} : message;
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
/** An `Icon` whose name the catalog does not know makes the renderer refuse
|
|
657
|
+
* the whole surface: it becomes an empty `Text` with the same id. */
|
|
658
|
+
function withKnownIcons(messages) {
|
|
659
|
+
return mapComponents(messages, (component) => component.component === "Icon" && typeof component.name === "string" && !(component.name in ICON_PATHS) ? {
|
|
660
|
+
id: component.id,
|
|
661
|
+
component: "Text",
|
|
662
|
+
text: ""
|
|
663
|
+
} : component);
|
|
664
|
+
}
|
|
665
|
+
/** A zod schema under its optional, default, effect and lazy wrappers. */
|
|
666
|
+
function unwrap(schema) {
|
|
667
|
+
let current = schema;
|
|
668
|
+
for (let i = 0; i < 16 && current?._def; i++) {
|
|
669
|
+
const def = current._def;
|
|
670
|
+
const next = def.innerType ?? def.schema ?? (def.getter ? def.getter() : void 0);
|
|
671
|
+
if (!next) return current;
|
|
672
|
+
current = next;
|
|
673
|
+
}
|
|
674
|
+
return current;
|
|
675
|
+
}
|
|
676
|
+
var enumsCache = /* @__PURE__ */ new Map();
|
|
677
|
+
/** The enumerated properties of a component, with their options. */
|
|
678
|
+
function enumsOf(type) {
|
|
679
|
+
let enums = enumsCache.get(type);
|
|
680
|
+
if (enums) return enums;
|
|
681
|
+
enums = /* @__PURE__ */ new Map();
|
|
682
|
+
const shape = unwrap(catalog.components.get(type)?.schema)?._def?.shape?.() ?? {};
|
|
683
|
+
for (const [key, schema] of Object.entries(shape)) {
|
|
684
|
+
const inner = unwrap(schema)?._def;
|
|
685
|
+
if (inner?.typeName === "ZodEnum" && Array.isArray(inner.values)) enums.set(key, inner.values);
|
|
686
|
+
}
|
|
687
|
+
enumsCache.set(type, enums);
|
|
688
|
+
return enums;
|
|
689
|
+
}
|
|
690
|
+
var letters = (value) => value.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
691
|
+
/** The option `value` plainly means: the same letters, or the same without
|
|
692
|
+
* the `space` prefix (`between`) or with a `flex` one (`flex-start`). */
|
|
693
|
+
function meant(value, options) {
|
|
694
|
+
const given = letters(value);
|
|
695
|
+
return options.find((option) => {
|
|
696
|
+
const wanted = letters(option);
|
|
697
|
+
return wanted === given || wanted === `space${given}` || given === `flex${wanted}`;
|
|
698
|
+
});
|
|
699
|
+
}
|
|
700
|
+
/** `justify: "between"`, `align: "flex-start"`, a `variant` that does not
|
|
701
|
+
* exist: an enumerated value is brought back to the catalog's spelling, or
|
|
702
|
+
* dropped so the default applies, instead of the whole surface refused. */
|
|
703
|
+
function withKnownEnums(messages) {
|
|
704
|
+
return mapComponents(messages, (component) => {
|
|
705
|
+
if (typeof component.component !== "string") return component;
|
|
706
|
+
const enums = enumsOf(component.component);
|
|
707
|
+
let fixed;
|
|
708
|
+
for (const [key, value] of Object.entries(component)) {
|
|
709
|
+
const options = enums.get(key);
|
|
710
|
+
if (typeof value !== "string" || !options || options.includes(value)) continue;
|
|
711
|
+
fixed ??= { ...component };
|
|
712
|
+
const option = meant(value, options);
|
|
713
|
+
if (option === void 0) delete fixed[key];
|
|
714
|
+
else fixed[key] = option;
|
|
715
|
+
}
|
|
716
|
+
return fixed ?? component;
|
|
717
|
+
});
|
|
718
|
+
}
|
|
719
|
+
/** The renderer's reason, from its error envelope; `fallback` without one. */
|
|
720
|
+
function reasonOf(error, fallback) {
|
|
721
|
+
if (isRecord(error)) {
|
|
722
|
+
if (isRecord(error.error) && typeof error.error.message === "string") return error.error.message;
|
|
723
|
+
if (typeof error.message === "string") return error.message;
|
|
724
|
+
}
|
|
725
|
+
return fallback;
|
|
726
|
+
}
|
|
727
|
+
var CSS = `
|
|
728
|
+
.a2ui { display: flex; flex-direction: column; gap: 8px; margin-block: 0 0.75em; padding: 20px; border: 1px solid var(--_border); border-radius: var(--_radius-sm); background: var(--_bg); overflow-x: auto; }
|
|
729
|
+
.a2ui[data-disabled] .a2ui-surface { opacity: 0.75; }
|
|
730
|
+
.a2ui-surface { display: flex; flex-direction: column; gap: 8px; }
|
|
731
|
+
.a2ui-row, .a2ui-column, .a2ui-list { display: flex; gap: 8px; min-inline-size: 0; }
|
|
732
|
+
.a2ui-row { flex-direction: row; flex-wrap: wrap; }
|
|
733
|
+
.a2ui-column, .a2ui-list { flex-direction: column; }
|
|
734
|
+
.a2ui-list[data-direction="horizontal"] { flex-direction: row; overflow-x: auto; }
|
|
735
|
+
[data-justify="center"] { justify-content: center; }
|
|
736
|
+
[data-justify="end"] { justify-content: flex-end; }
|
|
737
|
+
[data-justify="spaceBetween"] { justify-content: space-between; }
|
|
738
|
+
[data-justify="spaceAround"] { justify-content: space-around; }
|
|
739
|
+
[data-justify="spaceEvenly"] { justify-content: space-evenly; }
|
|
740
|
+
[data-justify="stretch"] { justify-content: stretch; }
|
|
741
|
+
[data-align="start"] { align-items: flex-start; }
|
|
742
|
+
[data-align="center"] { align-items: center; }
|
|
743
|
+
[data-align="end"] { align-items: flex-end; }
|
|
744
|
+
[data-align="stretch"] { align-items: stretch; }
|
|
745
|
+
.a2ui-card { display: flex; flex-direction: column; gap: 12px; padding: 16px; border: 1px solid var(--_border); border-radius: var(--_radius-sm); background: var(--_bg); }
|
|
746
|
+
.a2ui-title { margin: 0; line-height: 1.3; }
|
|
747
|
+
h1.a2ui-title { font-size: 1.4em; } h2.a2ui-title { font-size: 1.25em; } h3.a2ui-title { font-size: 1.1em; }
|
|
748
|
+
h4.a2ui-title, h5.a2ui-title { font-size: 1em; }
|
|
749
|
+
.a2ui-caption { color: var(--_muted); font-size: 0.85em; }
|
|
750
|
+
.a2ui-icon { display: inline-flex; }
|
|
751
|
+
.a2ui-icon svg { inline-size: 24px; block-size: 24px; }
|
|
752
|
+
.a2ui-button .a2ui-icon svg { inline-size: 18px; block-size: 18px; }
|
|
753
|
+
.a2ui-divider { inline-size: 100%; margin: 4px 0; border: 0; border-block-start: 1px solid var(--_border); }
|
|
754
|
+
.a2ui-divider.vertical { inline-size: 1px; align-self: stretch; margin: 0; border: 0; background: var(--_border); }
|
|
755
|
+
.a2ui-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-block-size: 36px; padding: 0 14px; border: 1px solid transparent; border-radius: var(--_radius-sm); font-weight: 600; }
|
|
756
|
+
.a2ui-button[data-variant="primary"] { background: var(--_accent); color: var(--_on-accent); }
|
|
757
|
+
.a2ui-button[data-variant="primary"]:not(:disabled):hover { background: var(--_accent-hover); }
|
|
758
|
+
.a2ui-button[data-variant="default"] { background: var(--_accent-soft); color: var(--_accent-fg); }
|
|
759
|
+
.a2ui-button[data-variant="borderless"] { color: var(--_accent-fg); }
|
|
760
|
+
.a2ui-button[data-variant="borderless"]:not(:disabled):hover { background: var(--_raised); }
|
|
761
|
+
.a2ui-button .markdown p, .a2ui-button .a2ui-text { margin: 0; }
|
|
762
|
+
.a2ui-field, .a2ui-field-wrapper { display: flex; flex-direction: column; gap: 4px; min-inline-size: 0; }
|
|
763
|
+
.a2ui-label { font-weight: 600; font-size: 0.9em; padding: 0; }
|
|
764
|
+
.a2ui-input { font: inherit; color: inherit; padding: 8px 10px; border: 1px solid var(--_border); border-radius: var(--_radius-sm); background: var(--_bg); }
|
|
765
|
+
textarea.a2ui-input { min-block-size: 5em; resize: vertical; }
|
|
766
|
+
.a2ui-input:focus-visible, .a2ui-range:focus-visible, .a2ui-check input:focus-visible, .a2ui-chip:focus-visible, .a2ui-button:focus-visible, .a2ui-tab:focus-visible { outline: 2px solid var(--_accent); outline-offset: 2px; }
|
|
767
|
+
.a2ui-input[aria-invalid="true"] { border-color: var(--_danger); }
|
|
768
|
+
.a2ui-error { margin: 0; color: var(--_danger); font-size: 0.85em; }
|
|
769
|
+
.a2ui-check { display: inline-flex; align-items: center; gap: 8px; }
|
|
770
|
+
.a2ui-check input { accent-color: var(--_accent); margin: 0; }
|
|
771
|
+
.a2ui-range { accent-color: var(--_accent); }
|
|
772
|
+
.a2ui-choices { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; border: 0; min-inline-size: 0; }
|
|
773
|
+
.a2ui-options { display: flex; flex-direction: column; gap: 6px; }
|
|
774
|
+
.a2ui-options[data-style="chips"] { flex-direction: row; flex-wrap: wrap; gap: 8px; }
|
|
775
|
+
.a2ui-chip { padding: 4px 12px; border: 1px solid var(--_border); border-radius: 999px; }
|
|
776
|
+
.a2ui-chip[aria-pressed="true"] { background: var(--_accent-soft); border-color: var(--_accent); color: var(--_accent-fg); }
|
|
777
|
+
.a2ui-tabs { display: flex; flex-direction: column; gap: 12px; }
|
|
778
|
+
.a2ui-tablist { display: flex; gap: 4px; border-block-end: 1px solid var(--_border); }
|
|
779
|
+
.a2ui-tab { padding: 6px 12px; border-block-end: 2px solid transparent; color: var(--_muted); }
|
|
780
|
+
.a2ui-tab[aria-selected="true"] { color: var(--_fg); border-block-end-color: var(--_accent); }
|
|
781
|
+
.a2ui-modal-trigger { display: contents; }
|
|
782
|
+
.a2ui-dialog { max-inline-size: min(560px, 90vw); padding: 20px; border: 1px solid var(--_border); border-radius: var(--_radius); background: var(--_bg); color: var(--_fg); }
|
|
783
|
+
.a2ui-dialog::backdrop { background: rgb(0 0 0 / 0.3); }
|
|
784
|
+
.a2ui-dialog-body { display: flex; flex-direction: column; gap: 8px; margin-block: 12px; }
|
|
785
|
+
.a2ui-dialog-footer { display: flex; justify-content: flex-end; }
|
|
786
|
+
.a2ui-sent { margin: 0; color: var(--_accent-fg); font-size: 0.85em; font-weight: 600; }
|
|
787
|
+
.a2ui-refused { margin: 0 0 4px; color: var(--_danger); font-size: 0.85em; font-weight: 600; }
|
|
788
|
+
.a2ui-placeholder { display: flex; flex-direction: column; gap: 8px; }
|
|
789
|
+
.a2ui-placeholder span { block-size: 12px; border-radius: 4px; background: var(--_raised); }
|
|
790
|
+
.a2ui-placeholder span:nth-child(1) { inline-size: 40%; }
|
|
791
|
+
.a2ui-placeholder span:nth-child(2) { block-size: 48px; }
|
|
792
|
+
.a2ui-placeholder span:nth-child(3) { inline-size: 30%; }
|
|
793
|
+
.a2ui-placeholder p { margin: 0; color: var(--_muted); font-size: 0.85em; }
|
|
794
|
+
`;
|
|
795
|
+
var sheet;
|
|
796
|
+
function adoptStyles(env) {
|
|
797
|
+
if (sheet === void 0) try {
|
|
798
|
+
sheet = new CSSStyleSheet();
|
|
799
|
+
sheet.replaceSync(CSS);
|
|
800
|
+
} catch {
|
|
801
|
+
sheet = null;
|
|
802
|
+
}
|
|
803
|
+
if (sheet && env.root !== document) adoptSheet(env.root, sheet);
|
|
804
|
+
}
|
|
805
|
+
var uid = 0;
|
|
806
|
+
/** What shows while the block is still arriving. */
|
|
807
|
+
function placeholder(env) {
|
|
808
|
+
const box = document.createElement("div");
|
|
809
|
+
box.className = "a2ui a2ui-placeholder";
|
|
810
|
+
box.setAttribute("role", "status");
|
|
811
|
+
box.append(document.createElement("span"), document.createElement("span"), document.createElement("span"));
|
|
812
|
+
const note = document.createElement("p");
|
|
813
|
+
note.textContent = env.strings.a2uiPreparing;
|
|
814
|
+
box.append(note);
|
|
815
|
+
return box;
|
|
816
|
+
}
|
|
817
|
+
function sourceBlock(source) {
|
|
818
|
+
const pre = document.createElement("pre");
|
|
819
|
+
const code = document.createElement("code");
|
|
820
|
+
code.className = "language-a2ui";
|
|
821
|
+
code.textContent = `${source}\n`;
|
|
822
|
+
pre.append(code);
|
|
823
|
+
return pre;
|
|
824
|
+
}
|
|
825
|
+
function refused(source, reason, env) {
|
|
826
|
+
const box = document.createElement("div");
|
|
827
|
+
const line = document.createElement("p");
|
|
828
|
+
line.className = "a2ui-refused";
|
|
829
|
+
line.setAttribute("role", "alert");
|
|
830
|
+
line.textContent = env.strings.a2uiRefused(reason);
|
|
831
|
+
box.append(line, sourceBlock(source));
|
|
832
|
+
return box;
|
|
833
|
+
}
|
|
834
|
+
function draw(source, env) {
|
|
835
|
+
const messages = parseA2uiMessages(source);
|
|
836
|
+
if (!messages) return env.live ? placeholder(env) : null;
|
|
837
|
+
adoptStyles(env);
|
|
838
|
+
let state = env.interface ?? {
|
|
839
|
+
working: env.live,
|
|
840
|
+
sent: /* @__PURE__ */ new Map()
|
|
841
|
+
};
|
|
842
|
+
/** This block's form was sent from here, before the transcript says so. */
|
|
843
|
+
let sentHere = false;
|
|
844
|
+
const ids = surfaceIdsOf(messages);
|
|
845
|
+
const isSent = () => sentHere || ids.some((id) => state.sent.has(id));
|
|
846
|
+
const isDisabled = () => isSent() || state.working || !state.send;
|
|
847
|
+
const processor = new MessageProcessor([catalog], (action) => {
|
|
848
|
+
const send = state.send;
|
|
849
|
+
if (isDisabled() || !send) return;
|
|
850
|
+
if (!send(formatA2uiAction({
|
|
851
|
+
name: action.name,
|
|
852
|
+
surfaceId: action.surfaceId,
|
|
853
|
+
sourceComponentId: action.sourceComponentId,
|
|
854
|
+
timestamp: action.timestamp,
|
|
855
|
+
context: action.context
|
|
856
|
+
}))) return;
|
|
857
|
+
sentHere = true;
|
|
858
|
+
refresh();
|
|
859
|
+
});
|
|
860
|
+
let errors;
|
|
861
|
+
try {
|
|
862
|
+
errors = processor.processMessagesWithErrors(withKnownIcons(withKnownEnums(withKnownCatalog(messages))));
|
|
863
|
+
} catch (error) {
|
|
864
|
+
errors = [error];
|
|
865
|
+
}
|
|
866
|
+
if (errors.length > 0) {
|
|
867
|
+
processor.dispose();
|
|
868
|
+
return refused(source, reasonOf(errors[0], env.strings.a2uiInvalid), env);
|
|
869
|
+
}
|
|
870
|
+
const restore = ids.flatMap((id) => {
|
|
871
|
+
const action = state.sent.get(id);
|
|
872
|
+
return action ? sentValuesOf(messages, action) : [];
|
|
873
|
+
});
|
|
874
|
+
if (restore.length > 0) try {
|
|
875
|
+
processor.processMessagesWithErrors(restore);
|
|
876
|
+
} catch {}
|
|
877
|
+
const box = document.createElement("div");
|
|
878
|
+
box.className = "a2ui";
|
|
879
|
+
const controls = /* @__PURE__ */ new Map();
|
|
880
|
+
const setDisabled = (el, blocked) => {
|
|
881
|
+
el.disabled = isDisabled() || blocked();
|
|
882
|
+
};
|
|
883
|
+
const mounts = [];
|
|
884
|
+
for (const surface of processor.model.surfacesMap.values()) {
|
|
885
|
+
const root = makeUi(surface, env, {
|
|
886
|
+
control(el, blocked = () => false) {
|
|
887
|
+
controls.set(el, blocked);
|
|
888
|
+
setDisabled(el, blocked);
|
|
889
|
+
},
|
|
890
|
+
refresh(el) {
|
|
891
|
+
const blocked = controls.get(el);
|
|
892
|
+
if (blocked) setDisabled(el, blocked);
|
|
893
|
+
}
|
|
894
|
+
}).mount(surface.rootId, "/");
|
|
895
|
+
const wrapper = document.createElement("div");
|
|
896
|
+
wrapper.className = "a2ui-surface";
|
|
897
|
+
wrapper.append(root.el);
|
|
898
|
+
box.append(wrapper);
|
|
899
|
+
mounts.push(root);
|
|
900
|
+
}
|
|
901
|
+
const note = document.createElement("p");
|
|
902
|
+
note.className = "a2ui-sent";
|
|
903
|
+
note.textContent = env.strings.a2uiSent;
|
|
904
|
+
box.append(note);
|
|
905
|
+
function refresh() {
|
|
906
|
+
box.toggleAttribute("data-disabled", isDisabled());
|
|
907
|
+
note.hidden = !isSent();
|
|
908
|
+
for (const [el, blocked] of controls) if (!box.contains(el)) controls.delete(el);
|
|
909
|
+
else setDisabled(el, blocked);
|
|
910
|
+
}
|
|
911
|
+
refresh();
|
|
912
|
+
interfaces.set(box, (next) => {
|
|
913
|
+
state = next;
|
|
914
|
+
refresh();
|
|
915
|
+
});
|
|
916
|
+
disposers.set(box, () => {
|
|
917
|
+
for (const mount of mounts) mount.dispose();
|
|
918
|
+
processor.dispose();
|
|
919
|
+
interfaces.delete(box);
|
|
920
|
+
});
|
|
921
|
+
return box;
|
|
922
|
+
}
|
|
923
|
+
/** The `Ui` of one surface: builds its components with a binder each. */
|
|
924
|
+
function makeUi(surface, env, controls) {
|
|
925
|
+
const ui = {
|
|
926
|
+
env,
|
|
927
|
+
strings: env.strings,
|
|
928
|
+
...controls,
|
|
929
|
+
uid: () => `a2ui-${++uid}`,
|
|
930
|
+
mount(id, path) {
|
|
931
|
+
const model = surface.componentsModel.get(id);
|
|
932
|
+
const api = model && catalog.components.get(model.type);
|
|
933
|
+
const make = model && VIEWS[model.type];
|
|
934
|
+
if (!model || !api || !make) {
|
|
935
|
+
const empty = document.createElement("span");
|
|
936
|
+
empty.hidden = true;
|
|
937
|
+
return {
|
|
938
|
+
el: empty,
|
|
939
|
+
dispose: () => void 0
|
|
940
|
+
};
|
|
941
|
+
}
|
|
942
|
+
const context = new ComponentContext(surface, id, path);
|
|
943
|
+
const binder = new GenericBinder(context, api.schema);
|
|
944
|
+
const view = make(ui, context.dataContext.path);
|
|
945
|
+
view.update(binder.snapshot);
|
|
946
|
+
const subscription = binder.subscribe((props) => view.update(props));
|
|
947
|
+
return {
|
|
948
|
+
el: view.el,
|
|
949
|
+
dispose() {
|
|
950
|
+
subscription.unsubscribe();
|
|
951
|
+
binder.dispose();
|
|
952
|
+
view.dispose?.();
|
|
953
|
+
}
|
|
954
|
+
};
|
|
955
|
+
}
|
|
956
|
+
};
|
|
957
|
+
return ui;
|
|
958
|
+
}
|
|
959
|
+
export { draw };
|
|
960
|
+
|
|
961
|
+
//# sourceMappingURL=a2ui-Da_YceSP.js.map
|