@qfei-design/make-ai-assistant 0.2.2 → 0.2.4

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/PUBLIC_API.md CHANGED
@@ -40,15 +40,24 @@ Fetch SSE 实现时,从 `/sse` 入口导入 `createSseAssistantTransport`。
40
40
  - `MakeAiAssistant`:默认右侧居中浮动入口与右侧抽屉;支持受控开关、自定义 launcher,以及
41
41
  `brandName` 对默认“{品牌名} AI 助手”标题的覆盖。`title` 可覆盖完整标题;`assistantName` /
42
42
  `userName` / `userAvatarUrl` 可显示当前登录人的名称和头像;未传入时用户侧不显示身份信息。
43
- `privacyNotice` 可展示宿主传入的广播提示内容;未传入时不展示广播。浮动入口位置可通过
43
+ `subtitle` 用于显示宿主传入的当前对象(兼容移除旧接入中的“只读分析 ·”前缀);`privacyNotice`
44
+ 会在对象右侧的问号 Tooltip 中展示,并根据图标与可用视口选择相邻方向,而非单独的广播行。头栏默认高度为 50px,可通过 `headerHeight` 或
45
+ `--make-ai-header-height` 覆盖。浮动入口位置可通过
44
46
  `--make-ai-launcher-top`、`--make-ai-launcher-right` 和 `--make-ai-launcher-mobile-right` 覆盖。
47
+ 桌面端抽屉可从左边缘 12px 热区向左拖宽,初始计算宽度(默认 432px,或宿主的
48
+ `--make-ai-drawer-width`)同时作为拖拽下限;热区激活时展示 2px 纯紫色提示线,宿主可通过
49
+ `--make-ai-drawer-resize-line` 覆盖其颜色;手柄支持左右方向键微调。小于 560px 的视口保持全宽,
50
+ 不提供宽度调整。
51
+ 面板按自身容器宽度适配:达到 560px 时扩展内容区间距和阅读宽度,达到 760px 时 Markdown 表格
52
+ 优先按可用宽度分列并换行;宿主可使用 `--make-ai-panel-gutter-wide` 覆盖扩展状态内边距。
45
53
  首次打开后关闭抽屉只隐藏 Drawer,不卸载 `AssistantPanel`,不会中断正在进行的生成。
46
54
  重新打开时会恢复消息滚动意图;空闲时聚焦输入框,生成中聚焦停止按钮。
47
55
  省略 `suggestions` 时显示包内默认推荐问题,传入 `[]` 时隐藏推荐问题。
48
56
  - `AssistantPanel`:不带 Drawer 的嵌入式会话面板;支持 `brandName`、`title`、`assistantName` /
49
- `userName` / `userAvatarUrl` / `privacyNotice`。默认品牌为“Make”,默认显示“AI 助手”;
50
- 用户侧默认不展示名称或头像,广播提示默认不展示。这些字段只参与本地 React 渲染,不会进入 transport 请求。嵌入式面板包含图标化复制回答、
51
- 可选安全重新生成、图标化回到最新消息、可折叠处理步骤、错误重试、键盘提交与 reduced-motion 处理。
57
+ `subtitle` / `userName` / `userAvatarUrl` / `privacyNotice` / `headerHeight`。默认品牌为“Make”,
58
+ 默认显示“AI 助手”;用户侧默认不展示名称或头像,宿主提示默认不展示。这些字段只参与本地 React
59
+ 渲染,不会进入 transport 请求。嵌入式面板包含图标化复制回答、可选安全重新生成、图标化回到最新消息、
60
+ 仅在生成中显示的处理步骤、错误重试、键盘提交与 reduced-motion 处理。
52
61
  - `ArtifactRenderer`:注册表驱动的单 Artifact 渲染器。
53
62
  - `createPlatformArtifactRegistry`
54
63
  - `platformArtifactTemplates`
package/README.md CHANGED
@@ -45,8 +45,14 @@ export function AppAssistant() {
45
45
  覆盖默认的 `Make` 品牌,面板会显示为“{品牌名} AI 助手”;传入 `title` 时则使用完整标题覆盖。
46
46
  `assistantName` 可覆盖 AI 消息显示名称。这些显示配置只用于 React UI,不会随会话上下文发送到
47
47
  AI transport;进度和可重试错误会显示在对应的 AI 回合中。
48
- 宿主传入 `privacyNotice` 时,面板会展示内置广播图标和该提示内容;不传入或传入空白内容时,
49
- 默认不展示广播提示。
48
+ `subtitle` 用于展示宿主传入的当前对象;未传入时回退为当前 App 名称,并兼容移除旧接入中的“只读分析 ·”前缀。宿主传入
49
+ `privacyNotice` 时,面板会在当前对象右侧显示可聚焦的问号图标,鼠标悬浮或键盘聚焦后会根据图标与可用视口选择相邻方向展示该提示;
50
+ 不传入或传入空白内容时不显示图标。标题右侧紧随标题展示“只读”状态标签,长标题会省略显示并保留原文
51
+ `title` 属性。头栏默认高度为 50px,可通过 `headerHeight` 属性或 `--make-ai-header-height` 主题变量覆盖。
52
+
53
+ 桌面端抽屉默认宽度为 432px,且该初始宽度是用户拖拽时的最小宽度。鼠标移至抽屉左边缘的 12px 热区时才会显示 2px 纯紫色拖拽提示线(可通过 `--make-ai-drawer-resize-line` 覆盖),可向左拖宽;获得焦点后也可用左、右方向键以 16px 调整宽度。小于 560px 的视口保持全宽展示,不显示拖拽手柄。
54
+
55
+ 面板使用容器查询而非页面视口响应宽度:抽屉达到 560px 时会增加内边距、正文可读宽度和结构化内容密度;达到 760px 时 Markdown 表格会优先按可用宽度分列并换行。宿主可通过 `--make-ai-panel-gutter-wide` 覆盖扩展抽屉的内边距。
50
56
 
51
57
  成功的 AI 回答会显示仅含图标的复制按钮,鼠标悬浮或键盘聚焦时显示“复制”提示,按钮保留
52
58
  “复制回答”的无障碍名称;复制只处理该回答的文本内容,失败时会在本地 UI 内提示,不会把回答正文写入日志。AI 回答正文会按标题、
@@ -8,6 +8,7 @@ export interface AssistantPanelProps {
8
8
  brandName?: string;
9
9
  assistantName?: string;
10
10
  privacyNotice?: string;
11
+ headerHeight?: number | string;
11
12
  userName?: string;
12
13
  userAvatarUrl?: string;
13
14
  title?: string;
package/dist/react.cjs CHANGED
@@ -1,5 +1,5 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),V=require("./index.cjs"),h=require("react"),d=require("./conversation-Cv1wdvCR.cjs");function qe({artifact:s,context:t,fallback:a,onAction:r,onActionError:n,registry:i}){const c=V.resolveArtifactTemplate(i,s,t);if(!c)return a?a(s):e.jsxs("section",{className:"make-ai-artifact make-ai-artifact--unsupported",role:"status",children:[e.jsx("strong",{children:"暂不支持展示此结果"}),e.jsxs("span",{children:["结果类型:",s.kind]})]});const u={context:t,onAction:r,onActionError:n};return c.template.render(s,t,u)}const O=(s,t,a)=>{if(s==null||s==="")return"—";if(typeof s=="boolean")return s?"是":"否";if(typeof s!="number")return`${s}${t?.unit??""}`;const r=t?.precision,n={maximumFractionDigits:r??2,minimumFractionDigits:r};t?.style==="currency"&&t.currency?(n.style="currency",n.currency=t.currency):t?.style==="percent"&&(n.style="percent");try{const i=t?.style==="percent"?s/100:s;return`${new Intl.NumberFormat(a,n).format(i)}${t?.unit??""}`}catch{return`${s}${t?.unit??""}`}},De=s=>{let t=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY;for(const r of s)t=Math.min(t,r),a=Math.max(a,r);return Number.isFinite(t)&&Number.isFinite(a)?{min:t,max:a}:{min:0,max:0}},Ue=(s,t,a)=>{if(!a.onAction)return;const r=i=>{console.error("[make-ai-assistant] host action error handler failed",{actionId:s.id,artifactId:t.artifact.id,errorType:i instanceof Error?i.name:typeof i,intent:s.intent})},n=i=>{if(a.onActionError){try{Promise.resolve(a.onActionError(i,s,t)).catch(r)}catch(c){r(c)}return}console.error("[make-ai-assistant] host action failed",{actionId:s.id,artifactId:t.artifact.id,errorType:i instanceof Error?i.name:typeof i,intent:s.intent})};try{Promise.resolve(a.onAction(s,t)).catch(n)}catch(i){n(i)}},Y=(s,t)=>s.actions?.length&&t.onAction?e.jsx("div",{className:"make-ai-artifact__actions",children:s.actions.map(a=>e.jsxs("button",{className:`make-ai-artifact__action make-ai-artifact__action--${a.appearance??"link"}`,type:"button",onClick:()=>Ue(a,{artifact:s,context:t.context},t),children:[a.label,e.jsx("span",{"aria-hidden":"true",children:"→"})]},a.id))}):null,J=(s,t,a="")=>e.jsxs("section",{"aria-label":s.title??`${s.kind} result`,className:`make-ai-artifact ${a}`.trim(),"data-artifact-density":s.presentation?.density,"data-artifact-kind":s.kind,children:[s.title?e.jsx("h4",{className:"make-ai-artifact__title",children:s.title}):null,s.summary?e.jsx("p",{className:"make-ai-artifact__summary",children:s.summary}):null,t]}),xs=({artifact:s,renderContext:t})=>{const a=s.data.delta,r=a?O(a.value,a.format==="percent"?{style:"percent"}:void 0,t.context.locale):void 0;return J(s,e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"make-ai-artifact__metric-value",children:O(s.data.value,s.data.format,t.context.locale)}),a?e.jsxs("div",{className:`make-ai-artifact__delta make-ai-artifact__delta--${a.direction??"flat"}`,children:[e.jsx("span",{"aria-hidden":"true",children:a.direction==="up"?"↗":a.direction==="down"?"↘":"→"}),e.jsx("span",{children:r}),a.label?e.jsx("span",{children:a.label}):null]}):null,s.data.context?e.jsx("p",{className:"make-ai-artifact__context",children:s.data.context}):null,Y(s,t)]}),"make-ai-artifact--metric")},_s=({artifact:s,renderContext:t})=>J(s,e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"make-ai-artifact__comparison",children:s.data.items.map(a=>e.jsxs("div",{className:"make-ai-artifact__comparison-item",children:[e.jsx("span",{children:a.label}),e.jsx("strong",{children:O(a.value,a.format,t.context.locale)}),a.hint?e.jsx("small",{children:a.hint}):null]},a.id))}),Y(s,t)]}),"make-ai-artifact--comparison"),js=({artifact:s,renderContext:t})=>{const a=s.data.series.flatMap(c=>c.points.map(u=>u.y)),{max:r,min:n}=De(a),i=r-n||1;return J(s,e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"make-ai-artifact__trend",children:s.data.series.map(c=>e.jsxs("div",{className:"make-ai-artifact__trend-series",children:[e.jsx("div",{className:"make-ai-artifact__trend-label",children:c.label}),e.jsx("div",{className:"make-ai-artifact__trend-bars",children:c.points.map((u,v)=>{const f=18+(u.y-n)/i*70;return e.jsxs("div",{className:"make-ai-artifact__trend-point",children:[e.jsx("span",{"aria-label":`${u.x}: ${O(u.y,c.format,t.context.locale)}`,className:"make-ai-artifact__trend-bar",role:"img",style:{height:`${f}%`},title:`${u.x}: ${O(u.y,c.format,t.context.locale)}`}),e.jsx("small",{children:u.x})]},`${u.x}-${v}`)})})]},c.id))}),Y(s,t)]}),"make-ai-artifact--trend")},vs=({artifact:s,renderContext:t})=>{const{max:a}=De(s.data.items.map(n=>Math.abs(n.value))),r=Math.max(a,1);return J(s,e.jsxs(e.Fragment,{children:[e.jsx("ol",{className:"make-ai-artifact__ranking",children:s.data.items.map((n,i)=>e.jsxs("li",{children:[e.jsx("span",{className:"make-ai-artifact__rank",children:i+1}),e.jsxs("span",{className:"make-ai-artifact__ranking-label",children:[e.jsx("span",{children:n.label}),n.description?e.jsx("small",{children:n.description}):null]}),e.jsx("span",{className:"make-ai-artifact__ranking-track","aria-hidden":"true",children:e.jsx("span",{style:{width:`${Math.abs(n.value)/r*100}%`}})}),e.jsx("strong",{children:O(n.value,n.format,t.context.locale)})]},n.id))}),Y(s,t)]}),"make-ai-artifact--ranking")},As=(s,t)=>t.action??{id:`open-${t.id}`,label:t.title??t.id,intent:"open-record",target:{entityKey:s.data.entity.key,recordId:t.id}},Is=({artifact:s,renderContext:t})=>J(s,e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"make-ai-artifact__record-list",children:s.data.records.length===0?e.jsx("p",{className:"make-ai-artifact__empty",children:"没有符合条件的记录"}):s.data.records.map(a=>{const r=As(s,a),n=e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:a.title??a.id}),e.jsx("span",{className:"make-ai-artifact__record-values",children:s.data.columns.map(i=>e.jsxs("span",{children:[e.jsx("small",{children:i.label}),O(a.values[i.key],i.format,t.context.locale)]},i.key))}),t.onAction?e.jsx("span",{"aria-hidden":"true",children:"›"}):null]});return t.onAction?e.jsx("button",{className:"make-ai-artifact__record",type:"button",onClick:()=>Ue(r,{artifact:s,context:t.context},t),children:n},a.id):e.jsx("div",{className:"make-ai-artifact__record",children:n},a.id)})}),s.data.total!==void 0?e.jsxs("p",{className:"make-ai-artifact__record-total",children:["共 ",s.data.total," 条"]}):null,Y(s,t)]}),"make-ai-artifact--record-list"),ys=({artifact:s,renderContext:t})=>J(s,e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`make-ai-artifact__notice make-ai-artifact__notice--${s.data.tone}`,children:[e.jsx("span",{"aria-hidden":"true",children:s.data.tone==="success"?"✓":s.data.tone==="warning"?"!":s.data.tone==="danger"?"×":"i"}),e.jsx("p",{children:s.data.body})]}),Y(s,t)]}),"make-ai-artifact--notice"),W=(s,t,a)=>({id:s,kinds:[t],priority:0,render:a}),ks=[W("platform.metric.default","metric",(s,t,a)=>e.jsx(xs,{artifact:s,renderContext:a})),W("platform.comparison.default","comparison",(s,t,a)=>e.jsx(_s,{artifact:s,renderContext:a})),W("platform.trend.default","trend",(s,t,a)=>e.jsx(js,{artifact:s,renderContext:a})),W("platform.ranking.default","ranking",(s,t,a)=>e.jsx(vs,{artifact:s,renderContext:a})),W("platform.record-list.default","record-list",(s,t,a)=>e.jsx(Is,{artifact:s,renderContext:a})),W("platform.notice.default","notice",(s,t,a)=>e.jsx(ys,{artifact:s,renderContext:a}))],He=V.createArtifactTemplateRegistry(ks).templates,ze=(s=He)=>V.createArtifactTemplateRegistry(s),bs=s=>`${s}-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,Ns="Make",Ms=["总结当前页面数据","找出需要关注的记录","列出我有权限查看的数据对象"],Ze=(s,t)=>t??`${s?.trim()||Ns} AI 助手`,Ts=s=>s??Ms;class j extends Error{}const me=(s,t)=>{if(!(typeof s!="object"||s===null))return s[t]},ws=s=>{const t=me(s,"status");return typeof t=="number"?t:me(me(s,"response"),"status")},Es=s=>{const t=me(s,"code"),a=ws(s),r=s instanceof Error?s.message:"",n=[t,r].filter(v=>typeof v=="string").join(" ").toLowerCase(),c=globalThis.navigator?.onLine===!1||/network|fetch|timeout|offline|connection|网络|连接|超时/.test(n),u=typeof a=="number"&&a>=500||/server|service|服务器|服务异常/.test(n);return c?{actionLabel:"重新连接",description:"请检查网络后再试。",kind:"network",label:"网络连接",title:"网络连接不可用"}:u?{actionLabel:"重新加载",description:"服务暂时未能响应,请稍后重试。",kind:"service",label:"服务异常",title:"服务暂时不可用"}:{actionLabel:"重新加载",description:"请稍后重试;若问题持续出现,请联系管理员。",kind:"unknown",label:"加载异常",title:"暂时无法加载对话"}},Ke=s=>{try{const t=s?.return?.();if(!t)return;Promise.resolve(t).catch(a=>{console.error("[make-ai-assistant] transport iterator close failed",{errorType:a instanceof Error?a.name:typeof a})})}catch(t){console.error("[make-ai-assistant] transport iterator close failed",{errorType:t instanceof Error?t.name:typeof t})}},Ss=async s=>{if(globalThis.navigator?.clipboard?.writeText){await globalThis.navigator.clipboard.writeText(s);return}if(typeof document>"u"||!document.body)throw new Error("Clipboard API is unavailable");const t=document.createElement("textarea");t.value=s,t.setAttribute("readonly",""),t.style.position="fixed",t.style.inset="0 auto auto 0",t.style.opacity="0",document.body.append(t),t.select();const a=document.execCommand("copy");if(t.remove(),!a)throw new Error("Clipboard copy failed")},Ge=()=>e.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",children:[e.jsx("path",{d:"M12 2.8c.5 4.4 2.8 6.8 7.2 7.2-4.4.5-6.8 2.8-7.2 7.2-.5-4.4-2.8-6.8-7.2-7.2 4.4-.5 6.8-2.8 7.2-7.2Z"}),e.jsx("path",{d:"M18.3 16.1c.2 1.8 1.2 2.8 3 3-1.8.2-2.8 1.2-3 3-.2-1.8-1.2-2.8-3-3 1.8-.2 2.8-1.2 3-3Z"})]}),Cs=()=>e.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",children:e.jsx("path",{d:"m6 6 12 12M18 6 6 18"})}),Rs=()=>e.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",children:[e.jsx("path",{d:"M8 8h10v12H8z"}),e.jsx("path",{d:"M6 16H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),$s=()=>e.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",children:[e.jsx("path",{d:"M20 11a8 8 0 0 0-14.7-4.4L4 8"}),e.jsx("path",{d:"M4 4v4h4"}),e.jsx("path",{d:"M4 13a8 8 0 0 0 14.7 4.4L20 16"}),e.jsx("path",{d:"M20 20v-4h-4"})]}),Ls=()=>e.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",children:[e.jsx("path",{d:"M5 10v4"}),e.jsx("path",{d:"M8 9v6l6 3V6L8 9Z"}),e.jsx("path",{d:"M17 9.2a4.2 4.2 0 0 1 0 5.6"}),e.jsx("path",{d:"M19.4 6.8a7.6 7.6 0 0 1 0 10.4"})]}),Fs=()=>e.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",children:[e.jsx("path",{d:"M12 4v11"}),e.jsx("path",{d:"m7 10 5 5 5-5"}),e.jsx("path",{d:"M5 20h14"})]}),Os=()=>e.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M12 5v14M5 12h14"})}),Vs=()=>e.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",children:[e.jsx("path",{d:"m4 4 17 8-17 8 3-8-3-8Z"}),e.jsx("path",{d:"M7 12h14"})]}),We=()=>e.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",children:[e.jsx("path",{d:"M20 11a8 8 0 0 0-14.7-4.4L4 8"}),e.jsx("path",{d:"M4 4v4h4"}),e.jsx("path",{d:"M4 13a8 8 0 0 0 14.7 4.4L20 16"}),e.jsx("path",{d:"M20 20v-4h-4"})]}),Ks=()=>e.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",children:[e.jsx("circle",{cx:"12",cy:"12",r:"8"}),e.jsx("path",{d:"M12 8v4.5"}),e.jsx("path",{d:"M12 16h.01"})]}),he=({className:s=""})=>e.jsx("span",{className:`make-ai-assistant__avatar ${s}`.trim(),"aria-hidden":"true",children:e.jsx(Ge,{})}),Ps=({src:s})=>s?e.jsx("span",{className:"make-ai-assistant__user-avatar","aria-hidden":"true",children:e.jsx("img",{alt:"",src:s})}):null,Bs=({userAvatarUrl:s,userName:t})=>{const a=t?.trim();return!a&&!s?null:e.jsxs("div",{className:"make-ai-assistant__message-identity",children:[a?e.jsx("span",{className:"make-ai-assistant__message-sender",children:a}):null,e.jsx(Ps,{src:s})]})},_e=s=>{const t=s.trim();if(!(!t.startsWith("|")||!t.endsWith("|")))return t.slice(1,-1).split("|").map(a=>a.trim())},qs=s=>s.length>0&&s.every(t=>/^:?-{3,}:?$/.test(t)),Ds=(s,t)=>{const a=_e(s[t]??""),r=_e(s[t+1]??"");if(!a||!r||a.length!==r.length||!qs(r))return;const n=[];let i=t+2;for(;i<s.length;){const c=_e(s[i]??"");if(!c||c.length!==a.length)break;n.push(c),i+=1}return{headers:a,lastIndex:i-1,rows:n}},Us=s=>{const t=[],a=[],r=[],n=[],i=s.replace(/\r\n?/g,`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),q=require("./index.cjs"),l=require("react"),u=require("./conversation-Cv1wdvCR.cjs");function lt({artifact:t,context:s,fallback:a,onAction:r,onActionError:n,registry:i}){const c=q.resolveArtifactTemplate(i,t,s);if(!c)return a?a(t):e.jsxs("section",{className:"make-ai-artifact make-ai-artifact--unsupported",role:"status",children:[e.jsx("strong",{children:"暂不支持展示此结果"}),e.jsxs("span",{children:["结果类型:",t.kind]})]});const m={context:s,onAction:r,onActionError:n};return c.template.render(t,s,m)}const U=(t,s,a)=>{if(t==null||t==="")return"—";if(typeof t=="boolean")return t?"是":"否";if(typeof t!="number")return`${t}${s?.unit??""}`;const r=s?.precision,n={maximumFractionDigits:r??2,minimumFractionDigits:r};s?.style==="currency"&&s.currency?(n.style="currency",n.currency=s.currency):s?.style==="percent"&&(n.style="percent");try{const i=s?.style==="percent"?t/100:t;return`${new Intl.NumberFormat(a,n).format(i)}${s?.unit??""}`}catch{return`${t}${s?.unit??""}`}},dt=t=>{let s=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY;for(const r of t)s=Math.min(s,r),a=Math.max(a,r);return Number.isFinite(s)&&Number.isFinite(a)?{min:s,max:a}:{min:0,max:0}},ut=(t,s,a)=>{if(!a.onAction)return;const r=i=>{console.error("[make-ai-assistant] host action error handler failed",{actionId:t.id,artifactId:s.artifact.id,errorType:i instanceof Error?i.name:typeof i,intent:t.intent})},n=i=>{if(a.onActionError){try{Promise.resolve(a.onActionError(i,t,s)).catch(r)}catch(c){r(c)}return}console.error("[make-ai-assistant] host action failed",{actionId:t.id,artifactId:s.artifact.id,errorType:i instanceof Error?i.name:typeof i,intent:t.intent})};try{Promise.resolve(a.onAction(t,s)).catch(n)}catch(i){n(i)}},re=(t,s)=>t.actions?.length&&s.onAction?e.jsx("div",{className:"make-ai-artifact__actions",children:t.actions.map(a=>e.jsxs("button",{className:`make-ai-artifact__action make-ai-artifact__action--${a.appearance??"link"}`,type:"button",onClick:()=>ut(a,{artifact:t,context:s.context},s),children:[a.label,e.jsx("span",{"aria-hidden":"true",children:"→"})]},a.id))}):null,ie=(t,s,a="")=>e.jsxs("section",{"aria-label":t.title??`${t.kind} result`,className:`make-ai-artifact ${a}`.trim(),"data-artifact-density":t.presentation?.density,"data-artifact-kind":t.kind,children:[t.title?e.jsx("h4",{className:"make-ai-artifact__title",children:t.title}):null,t.summary?e.jsx("p",{className:"make-ai-artifact__summary",children:t.summary}):null,s]}),Ft=({artifact:t,renderContext:s})=>{const a=t.data.delta,r=a?U(a.value,a.format==="percent"?{style:"percent"}:void 0,s.context.locale):void 0;return ie(t,e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"make-ai-artifact__metric-value",children:U(t.data.value,t.data.format,s.context.locale)}),a?e.jsxs("div",{className:`make-ai-artifact__delta make-ai-artifact__delta--${a.direction??"flat"}`,children:[e.jsx("span",{"aria-hidden":"true",children:a.direction==="up"?"↗":a.direction==="down"?"↘":"→"}),e.jsx("span",{children:r}),a.label?e.jsx("span",{children:a.label}):null]}):null,t.data.context?e.jsx("p",{className:"make-ai-artifact__context",children:t.data.context}):null,re(t,s)]}),"make-ai-artifact--metric")},Pt=({artifact:t,renderContext:s})=>ie(t,e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"make-ai-artifact__comparison",children:t.data.items.map(a=>e.jsxs("div",{className:"make-ai-artifact__comparison-item",children:[e.jsx("span",{children:a.label}),e.jsx("strong",{children:U(a.value,a.format,s.context.locale)}),a.hint?e.jsx("small",{children:a.hint}):null]},a.id))}),re(t,s)]}),"make-ai-artifact--comparison"),Dt=({artifact:t,renderContext:s})=>{const a=t.data.series.flatMap(c=>c.points.map(m=>m.y)),{max:r,min:n}=dt(a),i=r-n||1;return ie(t,e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"make-ai-artifact__trend",children:t.data.series.map(c=>e.jsxs("div",{className:"make-ai-artifact__trend-series",children:[e.jsx("div",{className:"make-ai-artifact__trend-label",children:c.label}),e.jsx("div",{className:"make-ai-artifact__trend-bars",children:c.points.map((m,y)=>{const g=18+(m.y-n)/i*70;return e.jsxs("div",{className:"make-ai-artifact__trend-point",children:[e.jsx("span",{"aria-label":`${m.x}: ${U(m.y,c.format,s.context.locale)}`,className:"make-ai-artifact__trend-bar",role:"img",style:{height:`${g}%`},title:`${m.x}: ${U(m.y,c.format,s.context.locale)}`}),e.jsx("small",{children:m.x})]},`${m.x}-${y}`)})})]},c.id))}),re(t,s)]}),"make-ai-artifact--trend")},Vt=({artifact:t,renderContext:s})=>{const{max:a}=dt(t.data.items.map(n=>Math.abs(n.value))),r=Math.max(a,1);return ie(t,e.jsxs(e.Fragment,{children:[e.jsx("ol",{className:"make-ai-artifact__ranking",children:t.data.items.map((n,i)=>e.jsxs("li",{children:[e.jsx("span",{className:"make-ai-artifact__rank",children:i+1}),e.jsxs("span",{className:"make-ai-artifact__ranking-label",children:[e.jsx("span",{children:n.label}),n.description?e.jsx("small",{children:n.description}):null]}),e.jsx("span",{className:"make-ai-artifact__ranking-track","aria-hidden":"true",children:e.jsx("span",{style:{width:`${Math.abs(n.value)/r*100}%`}})}),e.jsx("strong",{children:U(n.value,n.format,s.context.locale)})]},n.id))}),re(t,s)]}),"make-ai-artifact--ranking")},Kt=(t,s)=>s.action??{id:`open-${s.id}`,label:s.title??s.id,intent:"open-record",target:{entityKey:t.data.entity.key,recordId:s.id}},Ht=({artifact:t,renderContext:s})=>ie(t,e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"make-ai-artifact__record-list",children:t.data.records.length===0?e.jsx("p",{className:"make-ai-artifact__empty",children:"没有符合条件的记录"}):t.data.records.map(a=>{const r=Kt(t,a),n=e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:a.title??a.id}),e.jsx("span",{className:"make-ai-artifact__record-values",children:t.data.columns.map(i=>e.jsxs("span",{children:[e.jsx("small",{children:i.label}),U(a.values[i.key],i.format,s.context.locale)]},i.key))}),s.onAction?e.jsx("span",{"aria-hidden":"true",children:"›"}):null]});return s.onAction?e.jsx("button",{className:"make-ai-artifact__record",type:"button",onClick:()=>ut(r,{artifact:t,context:s.context},s),children:n},a.id):e.jsx("div",{className:"make-ai-artifact__record",children:n},a.id)})}),t.data.total!==void 0?e.jsxs("p",{className:"make-ai-artifact__record-total",children:["共 ",t.data.total," 条"]}):null,re(t,s)]}),"make-ai-artifact--record-list"),Bt=({artifact:t,renderContext:s})=>ie(t,e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`make-ai-artifact__notice make-ai-artifact__notice--${t.data.tone}`,children:[e.jsx("span",{"aria-hidden":"true",children:t.data.tone==="success"?"✓":t.data.tone==="warning"?"!":t.data.tone==="danger"?"×":"i"}),e.jsx("p",{children:t.data.body})]}),re(t,s)]}),"make-ai-artifact--notice"),ne=(t,s,a)=>({id:t,kinds:[s],priority:0,render:a}),Wt=[ne("platform.metric.default","metric",(t,s,a)=>e.jsx(Ft,{artifact:t,renderContext:a})),ne("platform.comparison.default","comparison",(t,s,a)=>e.jsx(Pt,{artifact:t,renderContext:a})),ne("platform.trend.default","trend",(t,s,a)=>e.jsx(Dt,{artifact:t,renderContext:a})),ne("platform.ranking.default","ranking",(t,s,a)=>e.jsx(Vt,{artifact:t,renderContext:a})),ne("platform.record-list.default","record-list",(t,s,a)=>e.jsx(Ht,{artifact:t,renderContext:a})),ne("platform.notice.default","notice",(t,s,a)=>e.jsx(Bt,{artifact:t,renderContext:a}))],mt=q.createArtifactTemplateRegistry(Wt).templates,pt=(t=mt)=>q.createArtifactTemplateRegistry(t),zt=t=>`${t}-${Date.now()}-${Math.random().toString(36).slice(2,9)}`,Ut="Make",qt=["总结当前页面数据","找出需要关注的记录","列出我有权限查看的数据对象"],ht=(t,s)=>s??`${t?.trim()||Ut} AI 助手`,Xt=t=>t??qt,Yt=/^只读分析\s*[·•]\s*/u,Gt=(t,s)=>t?.trim().replace(Yt,"").trim()||`当前对象:${s??"未命名应用"}`,Zt=432,at=16,D=16,he=8,nt=(t,s,a)=>Math.min(Math.max(t,Math.min(s,a)),a),rt=(t,s,a)=>Math.min(Math.max(t,s),Math.max(s,a)),Qt=(t,s,a,r)=>{const n=Math.min(Math.max(s.width,1),Math.max(1,r-D*2)),i=Math.min(Math.max(s.height,1),Math.max(1,a-D*2)),c=t.left+t.width/2,m=t.top+t.height/2,g=[{left:t.right+he,placement:"right",top:m-i/2},{left:t.left-he-n,placement:"left",top:m-i/2},{left:c-n/2,placement:"bottom",top:t.bottom+he},{left:c-n/2,placement:"top",top:t.top-he-i}].find(({left:E,top:w})=>E>=D&&w>=D&&E+n<=r-D&&w+i<=a-D);return g||{left:rt(c-n/2,D,r-D-n),placement:"bottom",top:rt(t.bottom+he,D,a-D-i)}},Jt=t=>typeof t=="number"?Number.isFinite(t)?`${t}px`:void 0:t?.trim()||void 0;class A extends Error{}const ye=(t,s)=>{if(!(typeof t!="object"||t===null))return t[s]},es=t=>{const s=ye(t,"status");return typeof s=="number"?s:ye(ye(t,"response"),"status")},ts=t=>{const s=ye(t,"code"),a=es(t),r=t instanceof Error?t.message:"",n=[s,r].filter(y=>typeof y=="string").join(" ").toLowerCase(),c=globalThis.navigator?.onLine===!1||/network|fetch|timeout|offline|connection|网络|连接|超时/.test(n),m=typeof a=="number"&&a>=500||/server|service|服务器|服务异常/.test(n);return c?{actionLabel:"重新连接",description:"请检查网络后再试。",kind:"network",label:"网络连接",title:"网络连接不可用"}:m?{actionLabel:"重新加载",description:"服务暂时未能响应,请稍后重试。",kind:"service",label:"服务异常",title:"服务暂时不可用"}:{actionLabel:"重新加载",description:"请稍后重试;若问题持续出现,请联系管理员。",kind:"unknown",label:"加载异常",title:"暂时无法加载对话"}},it=t=>{try{const s=t?.return?.();if(!s)return;Promise.resolve(s).catch(a=>{console.error("[make-ai-assistant] transport iterator close failed",{errorType:a instanceof Error?a.name:typeof a})})}catch(s){console.error("[make-ai-assistant] transport iterator close failed",{errorType:s instanceof Error?s.name:typeof s})}},ss=async t=>{if(globalThis.navigator?.clipboard?.writeText){await globalThis.navigator.clipboard.writeText(t);return}if(typeof document>"u"||!document.body)throw new Error("Clipboard API is unavailable");const s=document.createElement("textarea");s.value=t,s.setAttribute("readonly",""),s.style.position="fixed",s.style.inset="0 auto auto 0",s.style.opacity="0",document.body.append(s),s.select();const a=document.execCommand("copy");if(s.remove(),!a)throw new Error("Clipboard copy failed")},ft=()=>e.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",children:[e.jsx("path",{d:"M12 2.8c.5 4.4 2.8 6.8 7.2 7.2-4.4.5-6.8 2.8-7.2 7.2-.5-4.4-2.8-6.8-7.2-7.2 4.4-.5 6.8-2.8 7.2-7.2Z"}),e.jsx("path",{d:"M18.3 16.1c.2 1.8 1.2 2.8 3 3-1.8.2-2.8 1.2-3 3-.2-1.8-1.2-2.8-3-3 1.8-.2 2.8-1.2 3-3Z"})]}),as=()=>e.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",children:e.jsx("path",{d:"m6 6 12 12M18 6 6 18"})}),ns=()=>e.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",children:[e.jsx("path",{d:"M8 8h10v12H8z"}),e.jsx("path",{d:"M6 16H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),rs=()=>e.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",children:[e.jsx("path",{d:"M20 11a8 8 0 0 0-14.7-4.4L4 8"}),e.jsx("path",{d:"M4 4v4h4"}),e.jsx("path",{d:"M4 13a8 8 0 0 0 14.7 4.4L20 16"}),e.jsx("path",{d:"M20 20v-4h-4"})]}),is=()=>e.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",children:[e.jsx("circle",{cx:"12",cy:"12",r:"8"}),e.jsx("path",{d:"M9.8 9.4a2.35 2.35 0 1 1 3.93 1.73c-.96.86-1.73 1.42-1.73 2.87"}),e.jsx("path",{d:"M12 17h.01"})]}),os=()=>e.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",children:[e.jsx("path",{d:"M12 4v11"}),e.jsx("path",{d:"m7 10 5 5 5-5"}),e.jsx("path",{d:"M5 20h14"})]}),cs=()=>e.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M12 5v14M5 12h14"})}),ls=()=>e.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",children:[e.jsx("path",{d:"m4 4 17 8-17 8 3-8-3-8Z"}),e.jsx("path",{d:"M7 12h14"})]}),gt=()=>e.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",children:[e.jsx("path",{d:"M20 11a8 8 0 0 0-14.7-4.4L4 8"}),e.jsx("path",{d:"M4 4v4h4"}),e.jsx("path",{d:"M4 13a8 8 0 0 0 14.7 4.4L20 16"}),e.jsx("path",{d:"M20 20v-4h-4"})]}),ds=()=>e.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",children:[e.jsx("circle",{cx:"12",cy:"12",r:"8"}),e.jsx("path",{d:"M12 8v4.5"}),e.jsx("path",{d:"M12 16h.01"})]}),ke=({className:t=""})=>e.jsx("span",{className:`make-ai-assistant__avatar ${t}`.trim(),"aria-hidden":"true",children:e.jsx(ft,{})}),us=({src:t})=>t?e.jsx("span",{className:"make-ai-assistant__user-avatar","aria-hidden":"true",children:e.jsx("img",{alt:"",src:t})}):null,ms=({userAvatarUrl:t,userName:s})=>{const a=s?.trim();return!a&&!t?null:e.jsxs("div",{className:"make-ai-assistant__message-identity",children:[a?e.jsx("span",{className:"make-ai-assistant__message-sender",children:a}):null,e.jsx(us,{src:t})]})},Ne=t=>{const s=t.trim();if(!(!s.startsWith("|")||!s.endsWith("|")))return s.slice(1,-1).split("|").map(a=>a.trim())},ps=t=>t.length>0&&t.every(s=>/^:?-{3,}:?$/.test(s)),hs=(t,s)=>{const a=Ne(t[s]??""),r=Ne(t[s+1]??"");if(!a||!r||a.length!==r.length||!ps(r))return;const n=[];let i=s+2;for(;i<t.length;){const c=Ne(t[i]??"");if(!c||c.length!==a.length)break;n.push(c),i+=1}return{headers:a,lastIndex:i-1,rows:n}},fs=t=>{const s=[],a=[],r=[],n=[],i=t.replace(/\r\n?/g,`
2
2
  `).split(`
3
- `),c=()=>{const f=a.join(`
4
- `).trim();a.length=0,f&&t.push({type:"paragraph",text:f})},u=()=>{r.length&&t.push({type:"list",items:r.splice(0)})},v=()=>{const f=n.join(`
5
- `).trim();n.length=0,f&&t.push({type:"pre",text:f})};for(let f=0;f<i.length;f+=1){const b=i[f]??"",N=b.trim();if(!N){c(),u(),v();continue}const m=Ds(i,f);if(m){c(),u(),v(),t.push({headers:m.headers,rows:m.rows,type:"table"}),f=m.lastIndex;continue}const M=/^(#{1,6})\s+(.+)$/.exec(N);if(M){c(),u(),v();const A=(M[2]??"").replace(/\s+#+\s*$/,"").trim();A&&t.push({type:"heading",level:M[1]?.length,text:A});continue}if(/^\s*\|.+\|\s*$/.test(b)){c(),u(),n.push(b.trim());continue}const S=/^\s*[-*]\s+(.+)$/.exec(b);if(S){c(),v(),r.push(S[1]?.trim()??"");continue}u(),v(),a.push(N)}return c(),u(),v(),t},ae=s=>{const t=[],a=/(\*\*[^*]+\*\*|`[^`]+`)/g;let r=0;for(const n of s.matchAll(a)){const i=n[0],c=n.index??0;c>r&&t.push(s.slice(r,c)),i.startsWith("**")?t.push(e.jsx("strong",{children:i.slice(2,-2)},`${c}-strong`)):t.push(e.jsx("code",{children:i.slice(1,-1)},`${c}-code`)),r=c+i.length}return r<s.length&&t.push(s.slice(r)),t},Hs=({content:s})=>{const t=Us(s);return t.length?e.jsx("div",{className:"make-ai-assistant__bubble make-ai-assistant__assistant-text",children:t.map((a,r)=>{if(a.type==="heading"){const n=a.level<=2?"h3":"h4";return e.jsx(n,{className:`make-ai-assistant__markdown-heading make-ai-assistant__markdown-heading--${a.level}`,children:ae(a.text)},`${r}-heading`)}return a.type==="paragraph"?e.jsx("p",{children:ae(a.text)},`${r}-paragraph`):a.type==="pre"?e.jsx("pre",{children:e.jsx("code",{children:a.text})},`${r}-pre`):a.type==="table"?e.jsx("div",{"aria-label":"表格内容,可横向滚动",className:"make-ai-assistant__markdown-table-scroll",role:"region",tabIndex:0,children:e.jsxs("table",{className:"make-ai-assistant__markdown-table",children:[e.jsx("thead",{children:e.jsx("tr",{children:a.headers.map((n,i)=>e.jsx("th",{scope:"col",children:ae(n)},`${i}-${n}`))})}),e.jsx("tbody",{children:a.rows.map((n,i)=>e.jsx("tr",{children:n.map((c,u)=>e.jsx("td",{children:ae(c)},`${u}-${c}`))},`${i}-${n.join("|")}`))})]})},`${r}-table`):e.jsx("ul",{children:a.items.map((n,i)=>e.jsx("li",{children:ae(n)},`${i}-${n}`))},`${r}-list`)})}):null},Ye=({assistantName:s})=>e.jsxs("div",{className:"make-ai-assistant__message-identity",children:[e.jsx(he,{className:"make-ai-assistant__avatar--message"}),e.jsx("span",{className:"make-ai-assistant__message-sender",children:s})]}),Je=s=>{for(let t=s.messages.length-1;t>=0;t-=1){const a=s.messages[t];if(a.role==="assistant"&&a.status==="streaming")return a.id}},zs=s=>{for(let t=s.messages.length-1;t>=0;t-=1)if(s.messages[t].role==="user")return t;return-1},Qe=s=>{const t=zs(s);if(!(t<0))for(let a=s.messages.length-1;a>t;a-=1){const r=s.messages[a];if(r.role==="assistant")return r.id}},Zs=s=>{if(s.status==="idle")for(let t=s.messages.length-1;t>=0;t-=1){const a=s.messages[t];if(a.role==="assistant"&&a.status==="complete")return a.id}},Gs=s=>{for(let t=s.messages.length-1;t>=0;t-=1){const a=s.messages[t];if(a.role==="user")return a}},Ws=(s,t)=>{const a=s.messages.findIndex(r=>r.id===t&&r.role==="user");return{...s,error:void 0,progress:void 0,status:"streaming",messages:a<0?s.messages:s.messages.slice(0,a+1)}},Ys=s=>s.scrollHeight-s.scrollTop-s.clientHeight<=48,Pe=(s="smooth")=>globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches?"auto":s,je=(s,t)=>{typeof s.scrollTo=="function"?s.scrollTo({top:s.scrollHeight,behavior:t}):s.scrollTop=s.scrollHeight},Xe=({error:s,onRetry:t})=>e.jsxs("div",{className:"make-ai-assistant__message-status make-ai-assistant__message-status--error","data-error-presentation":"request-failed",role:"alert",children:[e.jsxs("div",{className:"make-ai-assistant__message-status-header",children:[e.jsx("span",{className:"make-ai-assistant__message-status-icon","aria-hidden":"true",children:e.jsx(Ks,{})}),e.jsx("strong",{children:"请求未完成"})]}),e.jsx("span",{className:"make-ai-assistant__message-status-message",children:s.message}),s.retryable&&t?e.jsxs("button",{className:"make-ai-assistant__retry",type:"button",onClick:t,children:[e.jsx(We,{}),"重新发送"]}):null]}),Js=({error:s,onRetry:t})=>{const a=Es(s);return e.jsxs("section",{"aria-live":"assertive",className:"make-ai-assistant__load-failure","data-load-failure-kind":a.kind,role:"alert",children:[e.jsx("span",{className:"make-ai-assistant__load-failure-icon","aria-hidden":"true",children:e.jsxs("svg",{viewBox:"0 0 24 24",children:[e.jsx("path",{d:"M5 12a7 7 0 0 1 13.4-2.8A4.5 4.5 0 0 1 18 18H7.5A4.5 4.5 0 0 1 5 12Z"}),e.jsx("path",{d:"m9.2 14.8 5.6-5.6M9.2 9.2l5.6 5.6"})]})}),e.jsxs("div",{className:"make-ai-assistant__load-failure-copy",children:[e.jsx("span",{className:"make-ai-assistant__load-failure-label",children:a.label}),e.jsx("h3",{children:a.title}),e.jsx("p",{children:a.description})]}),e.jsxs("button",{className:"make-ai-assistant__retry make-ai-assistant__retry--primary",type:"button",onClick:t,children:[e.jsx(We,{}),a.actionLabel]})]})},es=({active:s,steps:t})=>{if(!s||!t?.length)return null;const a=t[t.length-1]??"处理中";return e.jsxs("details",{className:"make-ai-assistant__process",open:!0,children:[e.jsxs("summary",{children:[e.jsxs("span",{className:"make-ai-assistant__progress",role:"status",children:[e.jsx("span",{"aria-hidden":"true"}),e.jsx("span",{children:a})]}),e.jsxs("span",{className:"make-ai-assistant__process-count",children:[t.length," 步"]})]}),e.jsx("ol",{children:t.map((r,n)=>e.jsxs("li",{"data-step-active":n===t.length-1?!0:void 0,children:[e.jsx("span",{"aria-hidden":"true"}),e.jsx("span",{children:r})]},`${n}-${r}`))})]})},Qs=({copyFeedback:s,onCopy:t,onRegenerate:a})=>!t&&!a?null:e.jsxs("div",{className:"make-ai-assistant__reply-actions","aria-label":"回复操作",children:[t?e.jsx("button",{"aria-label":"复制回答",className:"make-ai-assistant__reply-action make-ai-assistant__reply-copy","data-tooltip":"复制",type:"button",onClick:t,children:e.jsx(Rs,{})}):null,a?e.jsx("button",{"aria-label":"重新生成",className:"make-ai-assistant__reply-action make-ai-assistant__reply-regenerate","data-tooltip":"重新生成",type:"button",onClick:a,children:e.jsx($s,{})}):null,s?e.jsx("span",{className:"make-ai-assistant__reply-feedback","data-copy-status":s.status,role:"status",children:s.message}):null]}),Be=({assistantName:s,error:t,onRetry:a,progress:r})=>{const n=t?"error":"progress";return t?.message??r?.message?e.jsx("article",{"aria-label":`${s}的${n==="error"?"错误消息":"状态消息"}`,className:`make-ai-assistant__message make-ai-assistant__message--assistant make-ai-assistant__message--${n}`,"data-message-role":"assistant","data-message-state":n,children:e.jsxs("div",{className:"make-ai-assistant__message-turn",children:[e.jsx(Ye,{assistantName:s}),e.jsx("div",{className:"make-ai-assistant__message-stack",children:t?e.jsx(Xe,{error:t,onRetry:a}):e.jsx(es,{active:!0,steps:r?.steps})})]})}):null},Xs=(s,t,a,r,n,i,c,u,v,f,b,N,m)=>{const M=Qe(s),S=Je(s),A=Zs(s);let K;return s.messages.map(p=>{const k=p.role==="assistant",P=K;k||(K=p);const _=p.id===S,T=p.id===M?s.error:void 0,E=p.error??T,B=!k&&!!(u?.trim()||v),q=k?i:u?.trim()||"用户",pe=k&&p.status==="complete"&&!E&&(p.content.trim()||p.id===A);return e.jsx("article",{"aria-label":`${q}的消息`,className:`make-ai-assistant__message make-ai-assistant__message--${p.role}`,"data-message-role":p.role,"data-message-state":E?"error":void 0,"data-message-status":p.status,"data-message-has-identity":k||B?!0:void 0,children:e.jsxs("div",{className:"make-ai-assistant__message-turn",children:[k?e.jsx(Ye,{assistantName:i}):B?e.jsx(Bs,{userAvatarUrl:v,userName:u}):null,e.jsxs("div",{className:"make-ai-assistant__message-stack",children:[p.content?k?e.jsx(Hs,{content:p.content}):e.jsx("div",{className:"make-ai-assistant__bubble",children:p.content}):p.status==="streaming"?e.jsxs("div",{className:"make-ai-assistant__typing","aria-label":`${i}正在思考`,children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}):null,k?e.jsx(es,{active:_&&s.status==="streaming",steps:p.progressSteps}):null,E?e.jsx(Xe,{error:E,onRetry:T?c:void 0}):null,p.artifacts.map(R=>e.jsx(qe,{artifact:R,context:t,onAction:r,onActionError:n,registry:a},R.id)),pe?e.jsx(Qs,{copyFeedback:f?.messageId===p.id?{message:f.message,status:f.status}:void 0,onCopy:p.content.trim()?()=>N(p.id,p.content):void 0,onRegenerate:b&&p.id===A&&P?()=>m({userMessage:P,assistantMessage:p}):void 0}):null]})]})},p.id)})};function ss({assistantName:s="AI 助手",brandName:t,context:a,onAction:r,onActionError:n,onClose:i,onNewConversation:c,privacyNotice:u,registry:v,subtitle:f,suggestions:b,title:N,transport:m,userAvatarUrl:M,userName:S,visible:A}){const K=Ze(t,N),p=u?.trim(),[k,P]=h.useState(""),[_,T]=h.useState(d.createAssistantConversationState),E=h.useRef(_);E.current=_;const[B,q]=h.useState(void 0),[pe,R]=h.useState(void 0),[ts,as]=h.useState(0),[D,ne]=h.useState(()=>m.loadConversation?"loading":"ready"),[ns,fe]=h.useState(void 0),[rs,$]=h.useState(!1),U=h.useRef(void 0),H=h.useRef(void 0),z=h.useRef(0),ve=h.useRef(null),Q=h.useRef(null),Ae=h.useRef(null),Ie=h.useRef(null),L=h.useRef(!0),ye=h.useRef(a.app.id),ke=h.useRef(A),be=h.useMemo(()=>v??ze(),[v]),Ne=h.useMemo(()=>Ts(b),[b]),re=o=>{const g=U.current,x=H.current?.iterator;return!g&&!x?!1:(z.current+=1,U.current=void 0,H.current=void 0,console.info("[make-ai-assistant] local run cancellation requested",{reason:o}),g?.abort(),Ke(x),!0)};h.useEffect(()=>()=>{re("unmount")},[]),h.useEffect(()=>{const o=m.loadConversation,g=ye.current!==a.app.id;if(ye.current=a.app.id,re("reinitialize"),g&&(P(""),L.current=!0),q(void 0),R(void 0),$(!1),T(d.createAssistantConversationState()),!o){fe(void 0),ne("ready");return}const x=new AbortController;return fe(void 0),ne("loading"),console.info("[make-ai-assistant] conversation load start",{appId:a.app.id}),o.call(m,a,{signal:x.signal}).then(I=>{x.signal.aborted||(T(d.createAssistantConversationState(I)),ne("ready"),console.info("[make-ai-assistant] conversation load success",{appId:a.app.id,messageCount:I.messages.length}))}).catch(I=>{x.signal.aborted||(console.error("[make-ai-assistant] conversation load failed",{appId:a.app.id,errorType:I instanceof Error?I.name:typeof I}),fe(I),ne("error"))}),()=>x.abort()},[a.app.id,ts,m]),h.useEffect(()=>{const o=Q.current;if(!o||!L.current)return;$(!1);const g=requestAnimationFrame(()=>{if(!L.current)return;const x=_.status==="streaming"||globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches?"auto":"smooth";je(o,x)});return()=>cancelAnimationFrame(g)},[_.messages,_.progress,_.status]),h.useEffect(()=>{const o=A&&!ke.current;if(ke.current=A,!o)return;const g=requestAnimationFrame(()=>{const x=Q.current;if(x&&L.current){$(!1);const X=E.current.status==="streaming"?"auto":Pe();je(x,X)}else x&&$(E.current.messages.length>0);const I=Ae.current;(I&&!I.disabled?I:Ie.current??ve.current?.querySelector("button:not(:disabled)"))?.focus()});return()=>cancelAnimationFrame(g)},[A]);const is=()=>{const o=Q.current;if(!o)return;const g=Ys(o);L.current=g,$(!g&&E.current.messages.length>0)},os=()=>{const o=Q.current;if(!o)return;L.current=!0,$(!1);const g=Pe();je(o,g)},Me=async(o,g)=>{const x=o.trim(),I=E.current,C=g?.regenerateFrom,X=m.regenerate;if(!x||D!=="ready"||I.status==="streaming"||U.current||C&&!X)return;if(d.countCodePointsUpTo(x,d.MAKE_AI_CONVERSATION_LIMITS.messageCharacters)>d.MAKE_AI_CONVERSATION_LIMITS.messageCharacters){q(`输入内容过长,请控制在 ${d.MAKE_AI_CONVERSATION_LIMITS.messageCharacters} 个字符以内`);return}const ce={id:C?.userMessage.id??bs("user"),content:x},le=C?Ws(I,C.userMessage.id):d.appendUserMessage(I,ce),de=new AbortController,Z=z.current+1;z.current=Z,U.current=de,q(void 0),R(void 0),$(!L.current&&I.messages.length>0),C||P(""),T(le);try{let F=!1,y,Ee=0,Se=0,Ce=0,ge=0,ee=0;const se=new Map,Re=new Set,$e=new Set([...le.messages.map(ue=>ue.id),ce.id]),te=new Set,Le=V.createArtifactCapabilities(be),Fe={signal:de.signal};let xe;if(C){if(!X)throw new j("当前 AI 助手不支持重新生成");xe=X({threadId:le.threadId,message:ce,assistantMessage:{id:C.assistantMessage.id,content:C.assistantMessage.content},context:a,capabilities:Le},Fe)}else xe=m.run({threadId:le.threadId,message:ce,context:a,capabilities:Le},Fe);const Oe=xe[Symbol.asyncIterator]();for(H.current={iterator:Oe,requestVersion:Z};;){const ue=await Oe.next();if(z.current!==Z||ue.done)break;let l;try{l=d.parseAssistantEvent(ue.value)}catch(w){throw new j(w instanceof Error?w.message:"Invalid assistant event")}if(l.type==="message.start"){if(y!==void 0&&y!==l.runId)throw new j("AI 助手响应 run id 不一致");if(y??=l.runId,Se+=1,Se>d.MAKE_AI_CONVERSATION_LIMITS.assistantMessagesPerRun)throw new j("AI 助手单次响应消息数量超过限制");if($e.has(l.messageId))throw new j("AI 助手响应包含重复的 message id");$e.add(l.messageId),te.add(l.messageId),se.set(l.messageId,0)}if(l.type==="message.delta"){if(!te.has(l.messageId))throw new j("AI 助手响应事件顺序无效");const w=se.get(l.messageId)??0,G=d.countCodePointsUpTo(l.delta,d.MAKE_AI_CONVERSATION_LIMITS.messageCharacters-ee);if(ee+G>d.MAKE_AI_CONVERSATION_LIMITS.messageCharacters)throw new j("AI 助手响应文本超过大小限制");ee+=G,se.set(l.messageId,w+G)}if(l.type==="message.replace"){if(!te.has(l.messageId))throw new j("AI 助手响应事件顺序无效");const w=se.get(l.messageId)??0,G=d.countCodePointsUpTo(l.content,d.MAKE_AI_CONVERSATION_LIMITS.messageCharacters),Ve=ee-w+G;if(Ve>d.MAKE_AI_CONVERSATION_LIMITS.messageCharacters)throw new j("AI 助手响应文本超过大小限制");ee=Ve,se.set(l.messageId,G)}if(l.type==="run.progress"){if(y!==void 0&&y!==l.runId)throw new j("AI 助手响应 run id 不一致");if(y??=l.runId,Ce+=1,Ce>d.MAKE_AI_CONVERSATION_LIMITS.progressStepsPerRun)throw new j("AI 助手处理过程数量超过限制");const w=d.countCodePointsUpTo(l.message,d.MAKE_AI_CONVERSATION_LIMITS.progressCharactersPerRun-ge);if(ge+w>d.MAKE_AI_CONVERSATION_LIMITS.progressCharactersPerRun)throw new j("AI 助手处理过程文本超过大小限制");ge+=w}if(l.type==="artifact"){if(!te.has(l.messageId))throw new j("AI 助手响应事件顺序无效");if(Ee+=1,Ee>d.MAKE_AI_CONVERSATION_LIMITS.artifactsPerRun)throw new j("AI 助手单次响应 Artifact 数量超过限制");if(Re.has(l.artifact.id))throw new j("AI 助手响应包含重复的 Artifact id");Re.add(l.artifact.id)}if(l.type==="message.complete"&&!te.delete(l.messageId))throw new j("AI 助手响应事件顺序无效");if(l.type==="run.complete"&&y!==void 0&&y!==l.runId)throw new j("AI 助手响应 run id 不一致");if(l.type==="run.cancelled"&&l.runId!==void 0&&y!==void 0&&y!==l.runId)throw new j("AI 助手响应 run id 不一致");if(T(w=>d.reduceAssistantEvent(w,l)),l.type==="error"||l.type==="run.cancelled"||l.type==="run.complete"){F=!0;break}}if(!F)throw new j("AI 助手流式响应在终止事件前结束")}catch(F){if(z.current!==Z)return;if(de.signal.aborted){T(y=>d.reduceAssistantEvent(y,{type:"run.cancelled"}));return}console.error("[make-ai-assistant] assistant run failed",{appId:a.app.id,errorType:F instanceof Error?F.name:typeof F}),T(y=>d.reduceAssistantEvent(y,{type:"error",code:"TRANSPORT_ERROR",message:F instanceof j?F.message:"连接失败,请重试",retryable:!0}))}finally{z.current===Z&&U.current===de&&(U.current=void 0),H.current?.requestVersion===Z&&(Ke(H.current.iterator),H.current=void 0)}},ie=o=>Me(o),cs=o=>Me(o.userMessage.content,{regenerateFrom:o}),ls=async(o,g)=>{try{await Ss(g),R({messageId:o,message:"已复制",status:"success"})}catch(x){console.error("[make-ai-assistant] copy answer failed",{errorType:x instanceof Error?x.name:typeof x}),R({messageId:o,message:"复制失败",status:"error"})}},ds=o=>{o.preventDefault(),ie(k)},us=o=>{o.key==="Enter"&&!o.shiftKey&&!o.nativeEvent.isComposing&&(o.preventDefault(),ie(k))},ms=()=>{re("stop")&&T(o=>d.reduceAssistantEvent(o,{type:"run.cancelled"}))},hs=()=>{re("new-conversation"),P(""),q(void 0),R(void 0),$(!1),L.current=!0,T(d.createAssistantConversationState()),c?.()},Te=m.features?.remoteCancellation===!1?"停止接收":"停止生成",ps=Je(_),fs=Qe(_),oe=Gs(_),gs=typeof m.regenerate=="function"&&m.features?.regeneration!==!1,we=()=>{oe&&ie(oe.content)};return e.jsxs("section",{className:"make-ai-assistant make-ai-assistant__panel",ref:ve,children:[e.jsxs("header",{className:"make-ai-assistant__header",children:[e.jsx(he,{}),e.jsxs("div",{children:[e.jsx("h2",{children:K}),e.jsx("p",{children:f??`当前应用:${a.app.name??"未命名应用"}`})]}),e.jsxs("div",{className:"make-ai-assistant__header-actions",children:[m.features?.newConversation!==!1?e.jsx("button",{"aria-label":"新建对话",className:"make-ai-assistant__icon-button",type:"button",onClick:hs,children:e.jsx(Os,{})}):null,i?e.jsx("button",{"aria-label":`关闭 ${K}`,className:"make-ai-assistant__icon-button",type:"button",onClick:i,children:e.jsx(Cs,{})}):null]})]}),p?e.jsx("div",{className:"make-ai-assistant__notice-region",children:e.jsxs("div",{className:"make-ai-assistant__privacy-note",role:"note",children:[e.jsx("span",{className:"make-ai-assistant__privacy-icon","aria-hidden":"true",children:e.jsx(Ls,{})}),e.jsx("span",{children:p})]})}):null,e.jsxs("div",{className:`make-ai-assistant__body${p?" make-ai-assistant__body--with-notice":""}`,"aria-live":"polite","aria-relevant":"additions text",ref:Q,role:"log",onScroll:is,children:[D==="loading"?e.jsxs("div",{className:"make-ai-assistant__empty",role:"status",children:[e.jsx(he,{}),e.jsx("h3",{children:"正在恢复对话"}),e.jsx("p",{children:"正在读取当前 App 的历史消息…"})]}):D==="error"?e.jsx("div",{className:"make-ai-assistant__empty",children:e.jsx(Js,{error:ns,onRetry:()=>as(o=>o+1)})}):_.messages.length===0?e.jsxs("div",{className:"make-ai-assistant__empty",children:[e.jsx(he,{}),e.jsx("h3",{children:"有什么可以帮你?"}),e.jsx("p",{children:"我会结合当前 App、页面位置和宿主允许的上下文回答,并把过程与结果分开展示。"})]}):Xs(_,a,be,r,n,s,oe?we:void 0,S,M,pe,gs,(o,g)=>{ls(o,g)},o=>{cs(o)}),_.progress&&!ps?e.jsx(Be,{assistantName:s,progress:_.progress}):null,_.error&&!fs?e.jsx(Be,{assistantName:s,error:_.error,onRetry:oe?we:void 0}):null]}),rs?e.jsx("button",{"aria-label":"回到最新消息",className:"make-ai-assistant__back-to-latest",type:"button",onClick:os,children:e.jsx(Fs,{})}):null,e.jsxs("footer",{className:"make-ai-assistant__composer-region",children:[D==="ready"&&Ne.length>0&&_.messages.length===0?e.jsx("div",{className:"make-ai-assistant__suggestions","aria-label":"推荐问题",children:Ne.map((o,g)=>e.jsx("button",{type:"button",onClick:()=>{ie(o)},children:o},`${g}-${o}`))}):null,e.jsxs("form",{className:"make-ai-assistant__composer",onSubmit:ds,children:[e.jsx("textarea",{"aria-label":`向 ${s} 提问`,"aria-describedby":B?"make-ai-composer-error":void 0,"aria-invalid":B?!0:void 0,autoFocus:!0,disabled:D!=="ready"||_.status==="streaming",placeholder:`询问当前 ${a.app.name??"App"} 中的数据…`,ref:Ae,rows:2,value:k,onChange:o=>{P(o.currentTarget.value),q(void 0)},onKeyDown:us}),_.status==="streaming"?e.jsx("button",{"aria-label":Te,className:"make-ai-assistant__send make-ai-assistant__send--stop","data-tooltip":Te,ref:Ie,type:"button",onClick:ms,children:e.jsx("span",{"aria-hidden":"true"})}):e.jsx("button",{"aria-label":"发送",className:"make-ai-assistant__send",disabled:D!=="ready"||!k.trim(),type:"submit",children:e.jsx(Vs,{})})]}),B?e.jsx("p",{id:"make-ai-composer-error",role:"alert",children:B}):null,e.jsx("p",{children:"AI 生成的结果可能存在偏差,重要数据请核对明细。"})]})]})}function et(s){return e.jsx(ss,{...s,visible:!0})}function st({defaultOpen:s=!1,hideLauncher:t=!1,launcher:a,onOpenChange:r,open:n,...i}){const c=Ze(i.brandName,i.title),[u,v]=h.useState(s),[f,b]=h.useState(()=>s||n===!0),N=h.useRef(null),m=n??u,M=A=>{n===void 0&&v(A),r?.(A),A||requestAnimationFrame(()=>N.current?.focus())},S=()=>M(!m);return h.useEffect(()=>{m&&b(!0)},[m]),h.useEffect(()=>{if(!m)return;const A=K=>{K.key==="Escape"&&(M(!1),requestAnimationFrame(()=>N.current?.focus()))};return document.addEventListener("keydown",A),()=>document.removeEventListener("keydown",A)},[r,m]),e.jsxs("div",{className:"make-ai-assistant","data-open":m||void 0,children:[!t&&(!m||a)?a?a({open:m,toggle:S}):e.jsxs("button",{"aria-label":m?`关闭 ${c}`:`打开 ${c}`,"aria-expanded":m,className:"make-ai-assistant__launcher",ref:N,type:"button",onClick:S,children:[e.jsx("span",{className:"make-ai-assistant__launcher-orbit","aria-hidden":"true"}),e.jsx(Ge,{})]}):null,f?e.jsx("aside",{"aria-label":c,"aria-modal":"false",className:"make-ai-assistant__drawer",hidden:!m,role:"dialog",children:e.jsx(ss,{...i,onClose:()=>M(!1),visible:m})}):null]})}exports.createArtifactCapabilities=V.createArtifactCapabilities;exports.createArtifactTemplateRegistry=V.createArtifactTemplateRegistry;exports.extendArtifactTemplateRegistry=V.extendArtifactTemplateRegistry;exports.resolveArtifactTemplate=V.resolveArtifactTemplate;exports.MAKE_AI_ARTIFACT_KINDS=d.MAKE_AI_ARTIFACT_KINDS;exports.MAKE_AI_ARTIFACT_LIMITS=d.MAKE_AI_ARTIFACT_LIMITS;exports.MAKE_AI_ARTIFACT_SCHEMA_VERSION=d.MAKE_AI_ARTIFACT_SCHEMA_VERSION;exports.MAKE_AI_CONVERSATION_LIMITS=d.MAKE_AI_CONVERSATION_LIMITS;exports.appendUserMessage=d.appendUserMessage;exports.createAssistantConversationState=d.createAssistantConversationState;exports.parseArtifact=d.parseArtifact;exports.parseAssistantEvent=d.parseAssistantEvent;exports.reduceAssistantEvent=d.reduceAssistantEvent;exports.validateArtifact=d.validateArtifact;exports.ArtifactRenderer=qe;exports.AssistantPanel=et;exports.MakeAiAssistant=st;exports.createPlatformArtifactRegistry=ze;exports.formatArtifactValue=O;exports.platformArtifactTemplates=He;
3
+ `),c=()=>{const g=a.join(`
4
+ `).trim();a.length=0,g&&s.push({type:"paragraph",text:g})},m=()=>{r.length&&s.push({type:"list",items:r.splice(0)})},y=()=>{const g=n.join(`
5
+ `).trim();n.length=0,g&&s.push({type:"pre",text:g})};for(let g=0;g<i.length;g+=1){const E=i[g]??"",w=E.trim();if(!w){c(),m(),y();continue}const C=hs(i,g);if(C){c(),m(),y(),s.push({headers:C.headers,rows:C.rows,type:"table"}),g=C.lastIndex;continue}const v=/^(#{1,6})\s+(.+)$/.exec(w);if(v){c(),m(),y();const O=(v[2]??"").replace(/\s+#+\s*$/,"").trim();O&&s.push({type:"heading",level:v[1]?.length,text:O});continue}if(/^\s*\|.+\|\s*$/.test(E)){c(),m(),n.push(E.trim());continue}const T=/^\s*[-*]\s+(.+)$/.exec(E);if(T){c(),y(),r.push(T[1]?.trim()??"");continue}m(),y(),a.push(w)}return c(),m(),y(),s},fe=t=>{const s=[],a=/(\*\*[^*]+\*\*|`[^`]+`)/g;let r=0;for(const n of t.matchAll(a)){const i=n[0],c=n.index??0;c>r&&s.push(t.slice(r,c)),i.startsWith("**")?s.push(e.jsx("strong",{children:i.slice(2,-2)},`${c}-strong`)):s.push(e.jsx("code",{children:i.slice(1,-1)},`${c}-code`)),r=c+i.length}return r<t.length&&s.push(t.slice(r)),s},gs=({content:t})=>{const s=fs(t);return s.length?e.jsx("div",{className:"make-ai-assistant__bubble make-ai-assistant__assistant-text",children:s.map((a,r)=>{if(a.type==="heading"){const n=a.level<=2?"h3":"h4";return e.jsx(n,{className:`make-ai-assistant__markdown-heading make-ai-assistant__markdown-heading--${a.level}`,children:fe(a.text)},`${r}-heading`)}return a.type==="paragraph"?e.jsx("p",{children:fe(a.text)},`${r}-paragraph`):a.type==="pre"?e.jsx("pre",{children:e.jsx("code",{children:a.text})},`${r}-pre`):a.type==="table"?e.jsx("div",{"aria-label":"表格内容,可横向滚动",className:"make-ai-assistant__markdown-table-scroll",role:"region",tabIndex:0,children:e.jsxs("table",{className:"make-ai-assistant__markdown-table",children:[e.jsx("thead",{children:e.jsx("tr",{children:a.headers.map((n,i)=>e.jsx("th",{scope:"col",children:fe(n)},`${i}-${n}`))})}),e.jsx("tbody",{children:a.rows.map((n,i)=>e.jsx("tr",{children:n.map((c,m)=>e.jsx("td",{children:fe(c)},`${m}-${c}`))},`${i}-${n.join("|")}`))})]})},`${r}-table`):e.jsx("ul",{children:a.items.map((n,i)=>e.jsx("li",{children:fe(n)},`${i}-${n}`))},`${r}-list`)})}):null},xt=({assistantName:t})=>e.jsxs("div",{className:"make-ai-assistant__message-identity",children:[e.jsx(ke,{className:"make-ai-assistant__avatar--message"}),e.jsx("span",{className:"make-ai-assistant__message-sender",children:t})]}),_t=t=>{for(let s=t.messages.length-1;s>=0;s-=1){const a=t.messages[s];if(a.role==="assistant"&&a.status==="streaming")return a.id}},xs=t=>{for(let s=t.messages.length-1;s>=0;s-=1)if(t.messages[s].role==="user")return s;return-1},vt=t=>{const s=xs(t);if(!(s<0))for(let a=t.messages.length-1;a>s;a-=1){const r=t.messages[a];if(r.role==="assistant")return r.id}},_s=t=>{if(t.status==="idle")for(let s=t.messages.length-1;s>=0;s-=1){const a=t.messages[s];if(a.role==="assistant"&&a.status==="complete")return a.id}},vs=t=>{for(let s=t.messages.length-1;s>=0;s-=1){const a=t.messages[s];if(a.role==="user")return a}},js=(t,s)=>{const a=t.messages.findIndex(r=>r.id===s&&r.role==="user");return{...t,error:void 0,progress:void 0,status:"streaming",messages:a<0?t.messages:t.messages.slice(0,a+1)}},As=t=>t.scrollHeight-t.scrollTop-t.clientHeight<=48,ot=(t="smooth")=>globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches?"auto":t,Me=(t,s)=>{typeof t.scrollTo=="function"?t.scrollTo({top:t.scrollHeight,behavior:s}):t.scrollTop=t.scrollHeight},jt=({error:t,onRetry:s})=>e.jsxs("div",{className:"make-ai-assistant__message-status make-ai-assistant__message-status--error","data-error-presentation":"request-failed",role:"alert",children:[e.jsxs("div",{className:"make-ai-assistant__message-status-header",children:[e.jsx("span",{className:"make-ai-assistant__message-status-icon","aria-hidden":"true",children:e.jsx(ds,{})}),e.jsx("strong",{children:"请求未完成"})]}),e.jsx("span",{className:"make-ai-assistant__message-status-message",children:t.message}),t.retryable&&s?e.jsxs("button",{className:"make-ai-assistant__retry",type:"button",onClick:s,children:[e.jsx(gt,{}),"重新发送"]}):null]}),Is=({error:t,onRetry:s})=>{const a=ts(t);return e.jsxs("section",{"aria-live":"assertive",className:"make-ai-assistant__load-failure","data-load-failure-kind":a.kind,role:"alert",children:[e.jsx("span",{className:"make-ai-assistant__load-failure-icon","aria-hidden":"true",children:e.jsxs("svg",{viewBox:"0 0 24 24",children:[e.jsx("path",{d:"M5 12a7 7 0 0 1 13.4-2.8A4.5 4.5 0 0 1 18 18H7.5A4.5 4.5 0 0 1 5 12Z"}),e.jsx("path",{d:"m9.2 14.8 5.6-5.6M9.2 9.2l5.6 5.6"})]})}),e.jsxs("div",{className:"make-ai-assistant__load-failure-copy",children:[e.jsx("span",{className:"make-ai-assistant__load-failure-label",children:a.label}),e.jsx("h3",{children:a.title}),e.jsx("p",{children:a.description})]}),e.jsxs("button",{className:"make-ai-assistant__retry make-ai-assistant__retry--primary",type:"button",onClick:s,children:[e.jsx(gt,{}),a.actionLabel]})]})},At=({active:t,steps:s})=>{if(!t||!s?.length)return null;const a=s[s.length-1]??"处理中";return e.jsxs("details",{className:"make-ai-assistant__process",open:!0,children:[e.jsxs("summary",{children:[e.jsxs("span",{className:"make-ai-assistant__progress",role:"status",children:[e.jsx("span",{"aria-hidden":"true"}),e.jsx("span",{children:a})]}),e.jsxs("span",{className:"make-ai-assistant__process-count",children:[s.length," 步"]})]}),e.jsx("ol",{children:s.map((r,n)=>e.jsxs("li",{"data-step-active":n===s.length-1?!0:void 0,children:[e.jsx("span",{"aria-hidden":"true"}),e.jsx("span",{children:r})]},`${n}-${r}`))})]})},ys=({copyFeedback:t,onCopy:s,onRegenerate:a})=>!s&&!a?null:e.jsxs("div",{className:"make-ai-assistant__reply-actions","aria-label":"回复操作",children:[s?e.jsx("button",{"aria-label":"复制回答",className:"make-ai-assistant__reply-action make-ai-assistant__reply-copy","data-tooltip":"复制",type:"button",onClick:s,children:e.jsx(ns,{})}):null,a?e.jsx("button",{"aria-label":"重新生成",className:"make-ai-assistant__reply-action make-ai-assistant__reply-regenerate","data-tooltip":"重新生成",type:"button",onClick:a,children:e.jsx(rs,{})}):null,t?e.jsx("span",{className:"make-ai-assistant__reply-feedback","data-copy-status":t.status,role:"status",children:t.message}):null]}),ct=({assistantName:t,error:s,onRetry:a,progress:r})=>{const n=s?"error":"progress";return s?.message??r?.message?e.jsx("article",{"aria-label":`${t}的${n==="error"?"错误消息":"状态消息"}`,className:`make-ai-assistant__message make-ai-assistant__message--assistant make-ai-assistant__message--${n}`,"data-message-role":"assistant","data-message-state":n,children:e.jsxs("div",{className:"make-ai-assistant__message-turn",children:[e.jsx(xt,{assistantName:t}),e.jsx("div",{className:"make-ai-assistant__message-stack",children:s?e.jsx(jt,{error:s,onRetry:a}):e.jsx(At,{active:!0,steps:r?.steps})})]})}):null},ks=(t,s,a,r,n,i,c,m,y,g,E,w,C)=>{const v=vt(t),T=_t(t),O=_s(t);let S;return t.messages.map(p=>{const I=p.role==="assistant",K=S;I||(S=p);const b=p.id===T,Z=p.id===v?t.error:void 0,$=p.error??Z,F=!I&&!!(m?.trim()||y),_=I?i:m?.trim()||"用户",R=I&&p.status==="complete"&&!$&&(p.content.trim()||p.id===O);return e.jsx("article",{"aria-label":`${_}的消息`,className:`make-ai-assistant__message make-ai-assistant__message--${p.role}`,"data-message-role":p.role,"data-message-state":$?"error":void 0,"data-message-status":p.status,"data-message-has-identity":I||F?!0:void 0,children:e.jsxs("div",{className:"make-ai-assistant__message-turn",children:[I?e.jsx(xt,{assistantName:i}):F?e.jsx(ms,{userAvatarUrl:y,userName:m}):null,e.jsxs("div",{className:"make-ai-assistant__message-stack",children:[p.content?I?e.jsx(gs,{content:p.content}):e.jsx("div",{className:"make-ai-assistant__bubble",children:p.content}):p.status==="streaming"?e.jsxs("div",{className:"make-ai-assistant__typing","aria-label":`${i}正在思考`,children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}):null,I?e.jsx(At,{active:b&&t.status==="streaming",steps:p.progressSteps}):null,$?e.jsx(jt,{error:$,onRetry:Z?c:void 0}):null,p.artifacts.map(P=>e.jsx(lt,{artifact:P,context:s,onAction:r,onActionError:n,registry:a},P.id)),R?e.jsx(ys,{copyFeedback:g?.messageId===p.id?{message:g.message,status:g.status}:void 0,onCopy:p.content.trim()?()=>w(p.id,p.content):void 0,onRegenerate:E&&p.id===O&&K?()=>C({userMessage:K,assistantMessage:p}):void 0}):null]})]})},p.id)})};function It({assistantName:t="AI 助手",brandName:s,context:a,onAction:r,onActionError:n,onClose:i,onNewConversation:c,headerHeight:m,privacyNotice:y,registry:g,subtitle:E,suggestions:w,title:C,transport:v,userAvatarUrl:T,userName:O,visible:S}){const p=ht(s,C),I=y?.trim(),K=Gt(E,a.app.name),b=Jt(m),Z=b?{"--make-ai-internal-header-height":b}:void 0,[$,F]=l.useState(""),[_,R]=l.useState(u.createAssistantConversationState),P=l.useRef(_);P.current=_;const[X,Y]=l.useState(void 0),[oe,H]=l.useState(void 0),[h,k]=l.useState(0),[N,G]=l.useState(()=>v.loadConversation?"loading":"ready"),[yt,be]=l.useState(void 0),[kt,B]=l.useState(!1),[Q,Ee]=l.useState(!1),[ce,Se]=l.useState(void 0),J=l.useRef(void 0),ee=l.useRef(void 0),te=l.useRef(0),Re=l.useRef(null),le=l.useRef(null),Ce=l.useRef(null),$e=l.useRef(null),Le=l.useRef(null),Oe=l.useRef(null),W=l.useRef(!0),Fe=l.useRef(a.app.id),Pe=l.useRef(S),De=l.useId(),Ve=l.useMemo(()=>g??pt(),[g]),Ke=l.useMemo(()=>Xt(w),[w]),He=()=>{const o=$e.current,x=Le.current;if(!o||!x||typeof window>"u")return;const f=Qt(o.getBoundingClientRect(),x.getBoundingClientRect(),window.innerHeight,window.innerWidth);Se(j=>j?.left===f.left&&j.top===f.top&&j.placement===f.placement?j:f)},Be=()=>Ee(!0),We=()=>Ee(!1),bt=ce?{left:`${ce.left}px`,top:`${ce.top}px`}:void 0;l.useLayoutEffect(()=>{if(!Q||!I){Se(void 0);return}He()},[Q,I]),l.useEffect(()=>{if(!Q||!I)return;const o=()=>He();return window.addEventListener("resize",o),window.addEventListener("scroll",o,!0),()=>{window.removeEventListener("resize",o),window.removeEventListener("scroll",o,!0)}},[Q,I]);const ge=o=>{const x=J.current,f=ee.current?.iterator;return!x&&!f?!1:(te.current+=1,J.current=void 0,ee.current=void 0,console.info("[make-ai-assistant] local run cancellation requested",{reason:o}),x?.abort(),it(f),!0)};l.useEffect(()=>()=>{ge("unmount")},[]),l.useEffect(()=>{const o=v.loadConversation,x=Fe.current!==a.app.id;if(Fe.current=a.app.id,ge("reinitialize"),x&&(F(""),W.current=!0),Y(void 0),H(void 0),B(!1),R(u.createAssistantConversationState()),!o){be(void 0),G("ready");return}const f=new AbortController;return be(void 0),G("loading"),console.info("[make-ai-assistant] conversation load start",{appId:a.app.id}),o.call(v,a,{signal:f.signal}).then(j=>{f.signal.aborted||(R(u.createAssistantConversationState(j)),G("ready"),console.info("[make-ai-assistant] conversation load success",{appId:a.app.id,messageCount:j.messages.length}))}).catch(j=>{f.signal.aborted||(console.error("[make-ai-assistant] conversation load failed",{appId:a.app.id,errorType:j instanceof Error?j.name:typeof j}),be(j),G("error"))}),()=>f.abort()},[a.app.id,h,v]),l.useEffect(()=>{const o=le.current;if(!o||!W.current)return;B(!1);const x=requestAnimationFrame(()=>{if(!W.current)return;const f=_.status==="streaming"||globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches?"auto":"smooth";Me(o,f)});return()=>cancelAnimationFrame(x)},[_.messages,_.progress,_.status]),l.useEffect(()=>{const o=S&&!Pe.current;if(Pe.current=S,!o)return;const x=requestAnimationFrame(()=>{const f=le.current;if(f&&W.current){B(!1);const de=P.current.status==="streaming"?"auto":ot();Me(f,de)}else f&&B(P.current.messages.length>0);const j=Ce.current;(j&&!j.disabled?j:Oe.current??Re.current?.querySelector("button:not(:disabled)"))?.focus()});return()=>cancelAnimationFrame(x)},[S]);const wt=()=>{const o=le.current;if(!o)return;const x=As(o);W.current=x,B(!x&&P.current.messages.length>0)},Tt=()=>{const o=le.current;if(!o)return;W.current=!0,B(!1);const x=ot();Me(o,x)},ze=async(o,x)=>{const f=o.trim(),j=P.current,V=x?.regenerateFrom,de=v.regenerate;if(!f||N!=="ready"||j.status==="streaming"||J.current||V&&!de)return;if(u.countCodePointsUpTo(f,u.MAKE_AI_CONVERSATION_LIMITS.messageCharacters)>u.MAKE_AI_CONVERSATION_LIMITS.messageCharacters){Y(`输入内容过长,请控制在 ${u.MAKE_AI_CONVERSATION_LIMITS.messageCharacters} 个字符以内`);return}const ve={id:V?.userMessage.id??zt("user"),content:f},je=V?js(j,V.userMessage.id):u.appendUserMessage(j,ve),Ae=new AbortController,se=te.current+1;te.current=se,J.current=Ae,Y(void 0),H(void 0),B(!W.current&&j.messages.length>0),V||F(""),R(je);try{let z=!1,M,Xe=0,Ye=0,Ge=0,we=0,ue=0;const me=new Map,Ze=new Set,Qe=new Set([...je.messages.map(Ie=>Ie.id),ve.id]),pe=new Set,Je=q.createArtifactCapabilities(Ve),et={signal:Ae.signal};let Te;if(V){if(!de)throw new A("当前 AI 助手不支持重新生成");Te=de({threadId:je.threadId,message:ve,assistantMessage:{id:V.assistantMessage.id,content:V.assistantMessage.content},context:a,capabilities:Je},et)}else Te=v.run({threadId:je.threadId,message:ve,context:a,capabilities:Je},et);const tt=Te[Symbol.asyncIterator]();for(ee.current={iterator:tt,requestVersion:se};;){const Ie=await tt.next();if(te.current!==se||Ie.done)break;let d;try{d=u.parseAssistantEvent(Ie.value)}catch(L){throw new A(L instanceof Error?L.message:"Invalid assistant event")}if(d.type==="message.start"){if(M!==void 0&&M!==d.runId)throw new A("AI 助手响应 run id 不一致");if(M??=d.runId,Ye+=1,Ye>u.MAKE_AI_CONVERSATION_LIMITS.assistantMessagesPerRun)throw new A("AI 助手单次响应消息数量超过限制");if(Qe.has(d.messageId))throw new A("AI 助手响应包含重复的 message id");Qe.add(d.messageId),pe.add(d.messageId),me.set(d.messageId,0)}if(d.type==="message.delta"){if(!pe.has(d.messageId))throw new A("AI 助手响应事件顺序无效");const L=me.get(d.messageId)??0,ae=u.countCodePointsUpTo(d.delta,u.MAKE_AI_CONVERSATION_LIMITS.messageCharacters-ue);if(ue+ae>u.MAKE_AI_CONVERSATION_LIMITS.messageCharacters)throw new A("AI 助手响应文本超过大小限制");ue+=ae,me.set(d.messageId,L+ae)}if(d.type==="message.replace"){if(!pe.has(d.messageId))throw new A("AI 助手响应事件顺序无效");const L=me.get(d.messageId)??0,ae=u.countCodePointsUpTo(d.content,u.MAKE_AI_CONVERSATION_LIMITS.messageCharacters),st=ue-L+ae;if(st>u.MAKE_AI_CONVERSATION_LIMITS.messageCharacters)throw new A("AI 助手响应文本超过大小限制");ue=st,me.set(d.messageId,ae)}if(d.type==="run.progress"){if(M!==void 0&&M!==d.runId)throw new A("AI 助手响应 run id 不一致");if(M??=d.runId,Ge+=1,Ge>u.MAKE_AI_CONVERSATION_LIMITS.progressStepsPerRun)throw new A("AI 助手处理过程数量超过限制");const L=u.countCodePointsUpTo(d.message,u.MAKE_AI_CONVERSATION_LIMITS.progressCharactersPerRun-we);if(we+L>u.MAKE_AI_CONVERSATION_LIMITS.progressCharactersPerRun)throw new A("AI 助手处理过程文本超过大小限制");we+=L}if(d.type==="artifact"){if(!pe.has(d.messageId))throw new A("AI 助手响应事件顺序无效");if(Xe+=1,Xe>u.MAKE_AI_CONVERSATION_LIMITS.artifactsPerRun)throw new A("AI 助手单次响应 Artifact 数量超过限制");if(Ze.has(d.artifact.id))throw new A("AI 助手响应包含重复的 Artifact id");Ze.add(d.artifact.id)}if(d.type==="message.complete"&&!pe.delete(d.messageId))throw new A("AI 助手响应事件顺序无效");if(d.type==="run.complete"&&M!==void 0&&M!==d.runId)throw new A("AI 助手响应 run id 不一致");if(d.type==="run.cancelled"&&d.runId!==void 0&&M!==void 0&&M!==d.runId)throw new A("AI 助手响应 run id 不一致");if(R(L=>u.reduceAssistantEvent(L,d)),d.type==="error"||d.type==="run.cancelled"||d.type==="run.complete"){z=!0;break}}if(!z)throw new A("AI 助手流式响应在终止事件前结束")}catch(z){if(te.current!==se)return;if(Ae.signal.aborted){R(M=>u.reduceAssistantEvent(M,{type:"run.cancelled"}));return}console.error("[make-ai-assistant] assistant run failed",{appId:a.app.id,errorType:z instanceof Error?z.name:typeof z}),R(M=>u.reduceAssistantEvent(M,{type:"error",code:"TRANSPORT_ERROR",message:z instanceof A?z.message:"连接失败,请重试",retryable:!0}))}finally{te.current===se&&J.current===Ae&&(J.current=void 0),ee.current?.requestVersion===se&&(it(ee.current.iterator),ee.current=void 0)}},xe=o=>ze(o),Nt=o=>ze(o.userMessage.content,{regenerateFrom:o}),Mt=async(o,x)=>{try{await ss(x),H({messageId:o,message:"已复制",status:"success"})}catch(f){console.error("[make-ai-assistant] copy answer failed",{errorType:f instanceof Error?f.name:typeof f}),H({messageId:o,message:"复制失败",status:"error"})}},Et=o=>{o.preventDefault(),xe($)},St=o=>{o.key==="Enter"&&!o.shiftKey&&!o.nativeEvent.isComposing&&(o.preventDefault(),xe($))},Rt=()=>{ge("stop")&&R(o=>u.reduceAssistantEvent(o,{type:"run.cancelled"}))},Ct=()=>{ge("new-conversation"),F(""),Y(void 0),H(void 0),B(!1),W.current=!0,R(u.createAssistantConversationState()),c?.()},Ue=v.features?.remoteCancellation===!1?"停止接收":"停止生成",$t=_t(_),Lt=vt(_),_e=vs(_),Ot=typeof v.regenerate=="function"&&v.features?.regeneration!==!1,qe=()=>{_e&&xe(_e.content)};return e.jsxs("section",{className:"make-ai-assistant make-ai-assistant__panel",ref:Re,style:Z,children:[e.jsxs("header",{className:"make-ai-assistant__header",children:[e.jsx(ke,{}),e.jsxs("div",{className:"make-ai-assistant__header-content",children:[e.jsxs("div",{className:"make-ai-assistant__header-title-row",children:[e.jsx("h2",{className:"make-ai-assistant__header-title",title:p,children:p}),e.jsx("span",{className:"make-ai-assistant__read-only-tag",children:"只读"})]}),e.jsxs("div",{className:"make-ai-assistant__header-context",children:[e.jsx("p",{title:K,children:K}),I?e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-describedby":De,"aria-label":`使用提示:${I}`,className:"make-ai-assistant__header-context-help","data-tooltip":I,ref:$e,role:"note",tabIndex:0,onBlur:We,onFocus:Be,onPointerEnter:Be,onPointerLeave:We,children:e.jsx(is,{})}),e.jsx("span",{"aria-hidden":!Q,className:"make-ai-assistant__header-context-tooltip","data-placement":ce?.placement,"data-positioned":ce?!0:void 0,"data-visible":Q||void 0,id:De,ref:Le,role:"tooltip",style:bt,children:I})]}):null]})]}),e.jsxs("div",{className:"make-ai-assistant__header-actions",children:[v.features?.newConversation!==!1?e.jsx("button",{"aria-label":"新建对话",className:"make-ai-assistant__icon-button",type:"button",onClick:Ct,children:e.jsx(cs,{})}):null,i?e.jsx("button",{"aria-label":`关闭 ${p}`,className:"make-ai-assistant__icon-button",type:"button",onClick:i,children:e.jsx(as,{})}):null]})]}),e.jsxs("div",{className:"make-ai-assistant__body","aria-live":"polite","aria-relevant":"additions text",ref:le,role:"log",onScroll:wt,children:[N==="loading"?e.jsxs("div",{className:"make-ai-assistant__empty",role:"status",children:[e.jsx(ke,{}),e.jsx("h3",{children:"正在恢复对话"}),e.jsx("p",{children:"正在读取当前 App 的历史消息…"})]}):N==="error"?e.jsx("div",{className:"make-ai-assistant__empty",children:e.jsx(Is,{error:yt,onRetry:()=>k(o=>o+1)})}):_.messages.length===0?e.jsxs("div",{className:"make-ai-assistant__empty",children:[e.jsx(ke,{}),e.jsx("h3",{children:"有什么可以帮你?"}),e.jsx("p",{children:"我会结合当前 App、页面位置和宿主允许的上下文回答,并把过程与结果分开展示。"})]}):ks(_,a,Ve,r,n,t,_e?qe:void 0,O,T,oe,Ot,(o,x)=>{Mt(o,x)},o=>{Nt(o)}),_.progress&&!$t?e.jsx(ct,{assistantName:t,progress:_.progress}):null,_.error&&!Lt?e.jsx(ct,{assistantName:t,error:_.error,onRetry:_e?qe:void 0}):null]}),kt?e.jsx("button",{"aria-label":"回到最新消息",className:"make-ai-assistant__back-to-latest",type:"button",onClick:Tt,children:e.jsx(os,{})}):null,e.jsxs("footer",{className:"make-ai-assistant__composer-region",children:[N==="ready"&&Ke.length>0&&_.messages.length===0?e.jsx("div",{className:"make-ai-assistant__suggestions","aria-label":"推荐问题",children:Ke.map((o,x)=>e.jsx("button",{type:"button",onClick:()=>{xe(o)},children:o},`${x}-${o}`))}):null,e.jsxs("form",{className:"make-ai-assistant__composer",onSubmit:Et,children:[e.jsx("textarea",{"aria-label":`向 ${t} 提问`,"aria-describedby":X?"make-ai-composer-error":void 0,"aria-invalid":X?!0:void 0,autoFocus:!0,disabled:N!=="ready"||_.status==="streaming",placeholder:`询问当前 ${a.app.name??"App"} 中的数据…`,ref:Ce,rows:2,value:$,onChange:o=>{F(o.currentTarget.value),Y(void 0)},onKeyDown:St}),_.status==="streaming"?e.jsx("button",{"aria-label":Ue,className:"make-ai-assistant__send make-ai-assistant__send--stop","data-tooltip":Ue,ref:Oe,type:"button",onClick:Rt,children:e.jsx("span",{"aria-hidden":"true"})}):e.jsx("button",{"aria-label":"发送",className:"make-ai-assistant__send",disabled:N!=="ready"||!$.trim(),type:"submit",children:e.jsx(ls,{})})]}),X?e.jsx("p",{id:"make-ai-composer-error",role:"alert",children:X}):null,e.jsx("p",{children:"AI 生成的结果可能存在偏差,重要数据请核对明细。"})]})]})}function bs(t){return e.jsx(It,{...t,visible:!0})}function ws({defaultOpen:t=!1,hideLauncher:s=!1,launcher:a,onOpenChange:r,open:n,...i}){const c=ht(i.brandName,i.title),[m,y]=l.useState(t),[g,E]=l.useState(()=>t||n===!0),w=l.useRef(null),C=l.useRef(null),v=l.useRef(void 0),[T,O]=l.useState(),[S,p]=l.useState(Zt),[I,K]=l.useState(!1),b=n??m,Z=typeof window>"u"?void 0:window.innerWidth,$=T===void 0?void 0:{"--make-ai-internal-drawer-width":`${T}px`},F=()=>{if(T!==void 0)return T;const h=C.current?.getBoundingClientRect().width;return h&&Number.isFinite(h)&&h>0?h:S},_=()=>typeof window>"u"?Number.POSITIVE_INFINITY:window.innerWidth,R=h=>{if(h.button!==0)return;const k=F(),N=T===void 0?k:S;p(N),v.current={minimumWidth:N,pointerId:h.pointerId,startWidth:k,startX:h.clientX},K(!0),typeof h.currentTarget.setPointerCapture=="function"&&h.currentTarget.setPointerCapture(h.pointerId),h.preventDefault()},P=h=>{const k=v.current;if(!k||k.pointerId!==h.pointerId)return;const N=nt(k.startWidth+k.startX-h.clientX,k.minimumWidth,_());O(N)},X=h=>{const k=v.current;!k||k.pointerId!==h.pointerId||(v.current=void 0,K(!1))},Y=h=>{const k=h.key==="ArrowLeft"?at:h.key==="ArrowRight"?-at:void 0;if(k===void 0)return;h.preventDefault();const N=F(),G=T===void 0?N:S;p(G),O(nt(N+k,G,_()))},oe=h=>{n===void 0&&y(h),r?.(h),h||requestAnimationFrame(()=>w.current?.focus())},H=()=>oe(!b);return l.useEffect(()=>{b&&E(!0)},[b]),l.useEffect(()=>{if(!b)return;const h=k=>{k.key==="Escape"&&(oe(!1),requestAnimationFrame(()=>w.current?.focus()))};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[r,b]),e.jsxs("div",{className:"make-ai-assistant","data-open":b||void 0,children:[!s&&(!b||a)?a?a({open:b,toggle:H}):e.jsxs("button",{"aria-label":b?`关闭 ${c}`:`打开 ${c}`,"aria-expanded":b,className:"make-ai-assistant__launcher",ref:w,type:"button",onClick:H,children:[e.jsx("span",{className:"make-ai-assistant__launcher-orbit","aria-hidden":"true"}),e.jsx(ft,{})]}):null,g?e.jsxs("aside",{"aria-label":c,"aria-modal":"false",className:"make-ai-assistant__drawer","data-resizing":I||void 0,hidden:!b,ref:C,role:"dialog",style:$,children:[e.jsx("div",{"aria-label":"调整对话框宽度","aria-orientation":"vertical","aria-valuemax":Z,"aria-valuemin":S,"aria-valuenow":T??S,className:"make-ai-assistant__drawer-resize-handle",role:"separator",tabIndex:0,onKeyDown:Y,onPointerCancel:X,onPointerDown:R,onPointerMove:P,onPointerUp:X}),e.jsx(It,{...i,onClose:()=>oe(!1),visible:b})]}):null]})}exports.createArtifactCapabilities=q.createArtifactCapabilities;exports.createArtifactTemplateRegistry=q.createArtifactTemplateRegistry;exports.extendArtifactTemplateRegistry=q.extendArtifactTemplateRegistry;exports.resolveArtifactTemplate=q.resolveArtifactTemplate;exports.MAKE_AI_ARTIFACT_KINDS=u.MAKE_AI_ARTIFACT_KINDS;exports.MAKE_AI_ARTIFACT_LIMITS=u.MAKE_AI_ARTIFACT_LIMITS;exports.MAKE_AI_ARTIFACT_SCHEMA_VERSION=u.MAKE_AI_ARTIFACT_SCHEMA_VERSION;exports.MAKE_AI_CONVERSATION_LIMITS=u.MAKE_AI_CONVERSATION_LIMITS;exports.appendUserMessage=u.appendUserMessage;exports.createAssistantConversationState=u.createAssistantConversationState;exports.parseArtifact=u.parseArtifact;exports.parseAssistantEvent=u.parseAssistantEvent;exports.reduceAssistantEvent=u.reduceAssistantEvent;exports.validateArtifact=u.validateArtifact;exports.ArtifactRenderer=lt;exports.AssistantPanel=bs;exports.MakeAiAssistant=ws;exports.createPlatformArtifactRegistry=pt;exports.formatArtifactValue=U;exports.platformArtifactTemplates=mt;