weifuwu 0.62.0 → 0.63.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.
Files changed (43) hide show
  1. package/README.md +71 -4
  2. package/dist/client/index.js +3 -3
  3. package/dist/client/types.d.ts +59 -0
  4. package/dist/client/ui.d.ts +6 -0
  5. package/dist/components/Accordion/Accordion.d.ts +9 -0
  6. package/dist/components/Affix/Affix.d.ts +16 -0
  7. package/dist/components/AspectRatio/AspectRatio.d.ts +10 -0
  8. package/dist/components/BackTop/BackTop.d.ts +16 -0
  9. package/dist/components/Calendar/Calendar.d.ts +21 -0
  10. package/dist/components/Carousel/Carousel.d.ts +17 -0
  11. package/dist/components/Cascader/Cascader.d.ts +21 -0
  12. package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +23 -0
  13. package/dist/components/Collapse/Collapse.d.ts +28 -0
  14. package/dist/components/ColorPicker/ColorPicker.d.ts +16 -0
  15. package/dist/components/Command/Command.d.ts +22 -0
  16. package/dist/components/ContextMenu/ContextMenu.d.ts +17 -0
  17. package/dist/components/CopyButton/CopyButton.d.ts +18 -0
  18. package/dist/components/HoverCard/HoverCard.d.ts +16 -0
  19. package/dist/components/Icon/Icon.d.ts +1 -1
  20. package/dist/components/Img/Img.d.ts +4 -0
  21. package/dist/components/InView/InView.d.ts +1 -1
  22. package/dist/components/InfiniteScroll/InfiniteScroll.d.ts +15 -0
  23. package/dist/components/Label/Label.d.ts +11 -0
  24. package/dist/components/Mentions/Mentions.d.ts +19 -0
  25. package/dist/components/Menubar/Menubar.d.ts +22 -0
  26. package/dist/components/Notification/Notification.d.ts +70 -0
  27. package/dist/components/PinInput/PinInput.d.ts +18 -0
  28. package/dist/components/QRCode/QRCode.d.ts +20 -0
  29. package/dist/components/QRCode/qr.d.ts +15 -0
  30. package/dist/components/Rate/Rate.d.ts +16 -0
  31. package/dist/components/Resizable/Resizable.d.ts +18 -0
  32. package/dist/components/Select/Select.d.ts +4 -2
  33. package/dist/components/Table/Table.d.ts +10 -0
  34. package/dist/components/ToggleGroup/ToggleGroup.d.ts +33 -0
  35. package/dist/components/Transfer/Transfer.d.ts +18 -0
  36. package/dist/components/Tree/Tree.d.ts +27 -0
  37. package/dist/components/Typography/Typography.d.ts +39 -0
  38. package/dist/components/VirtualList/VirtualList.d.ts +21 -0
  39. package/dist/components/Watermark/Watermark.d.ts +19 -0
  40. package/dist/components/index.d.ts +58 -0
  41. package/dist/components/index.js +13 -6
  42. package/dist/components/style.css +4636 -2699
  43. package/package.json +1 -1
package/README.md CHANGED
@@ -10,7 +10,7 @@ npm install weifuwu
10
10
 
11
11
  > ⚠️ **注意:前后端都有 `ctx.ui`,但用途完全不同**
12
12
  > - **后端** `ctx.ui`(SSR/编译):`ctx.ui.html`(HTML 模板)、`ctx.ui.js`(TSX→JS 动态编译)、`ctx.ui.css`(CSS 编译)、`ctx.ui.ssr`(组件 SSR)、`ctx.ui.ssrData`(数据序列化)
13
- > - **前端** `ctx.ui`(渲染引擎):`ctx.ui.$()`(响应式状态)、`ctx.ui.render()` / `dirty()`(渲染控制)、`useMedia()` / `useBreakpoint()` / `usePopupPosition()`(浏览器事件监听)
13
+ > - **前端** `ctx.ui`(渲染引擎):`ctx.ui.$()`(响应式状态)、`ctx.ui.render()` / `dirty()`(渲染控制)、`useMedia()` / `useBreakpoint()` / `usePopupPosition()` / `useInView()` / `useScrollPosition()`(浏览器事件监听)
14
14
  > 后端的是「把页面和代码交给浏览器」,前端的是「在浏览器里驱动 UI」。
15
15
 
16
16
  ---
@@ -242,7 +242,7 @@ createApp().use(router({ routes })).mount('#root', RouteView, { hydrate: true })
242
242
  | 资源 | CDN 地址 | 说明 |
243
243
  |------|---------|------|
244
244
  | `weifuwu/client` | `https://unpkg.com/weifuwu@latest/dist/client/index.js` | 客户端核心(createApp, h, 路由, 状态管理等) |
245
- | `weifuwu/components` | `https://unpkg.com/weifuwu@latest/dist/components/index.js` | 61 个 UI 组件(Button, Card, Table, Modal, Icon 等) |
245
+ | `weifuwu/components` | `https://unpkg.com/weifuwu@latest/dist/components/index.js` | 91 个 UI 组件(Button, Card, Table, Modal, Icon 等) |
246
246
  | `weifuwu/components` | `https://unpkg.com/weifuwu@latest/dist/components/style.css` | 组件 CSS + 141 个主题 Token + 67 个布局原语 |
247
247
  | 独立布局系统 | `https://unpkg.com/weifuwu@latest/dist/layout/weifuwu-layout.css` | 仅 CSS 布局,不依赖 JS |
248
248
 
@@ -283,7 +283,7 @@ createApp().use(router({ routes })).mount('#root', RouteView, { hydrate: true })
283
283
  | `weifuwu/client` | **ErrorBoundary** | 错误边界组件 | createApp |
284
284
  | `weifuwu/client` | **lockScroll/trapFocus** | 滚动锁定 / 焦点陷阱工具 | — |
285
285
  | `weifuwu/client` | **popup** | 弹层 fixed 定位工具(`computeFixedPos` / `computeFixedPosRect`) | — |
286
- | `weifuwu/components` | **61 个组件** | Button/Table/Modal/Confirm/Toast/... + `confirm()` / `toast()` 命令式中间件 | weifuwu/client |
286
+ | `weifuwu/components` | **91 个组件** | Button/Table/Modal/Confirm/Toast/... + `confirm()` / `toast()` 命令式中间件 | weifuwu/client |
287
287
  | `weifuwu/layout` | **CSS 布局** | 67 个布局原语 + 141 个主题 Token(也支持 `weifuwu/layout/style.css`) | — |
288
288
 
289
289
  ---
@@ -1411,6 +1411,8 @@ ctx.ui.render(['name'])
1411
1411
  | `useMedia()` | `useMedia(query, cb)` | 响应式媒体查询,断点变化时自动回调 |
1412
1412
  | `useBreakpoint()` | `useBreakpoint(cb \| bps, cb?)` | 命名断点 mobile/tablet/desktop |
1413
1413
  | `usePopupPosition()` | `usePopupPosition(opts)` | 弹层坐标跟随:scroll/resize 时自动重算 fixed 坐标 |
1414
+ | `useInView()` | `useInView(opts)` | 可见性观察(IntersectionObserver 封装,替代组件自建 scroll 监听);`isIn` 响应式 + `ready` |
1415
+ | `useScrollPosition()` | `useScrollPosition({ getScroller? })` | 滚动位置跟踪(全局 scroll 监听 + rAF 节流);`y` 响应式,容器/视口通用 |
1414
1416
 
1415
1417
  > 每个方法的完整说明见下文对应章节。
1416
1418
 
@@ -1425,6 +1427,8 @@ ctx.ui.render(['name'])
1425
1427
  | `ctx.ui.useMedia()` | 注册监听 | 浏览器事件驱动 | 当前组件 | **响应式媒体查询** — 断点变化时自动 dirty |
1426
1428
  | `ctx.ui.useBreakpoint()` | 注册监听 | 浏览器事件驱动 | 当前组件 | **命名断点** — mobile/tablet/desktop 自动 dirty |
1427
1429
  | `ctx.ui.usePopupPosition()` | 注册监听 | 浏览器事件驱动 | 当前组件 | **弹层坐标跟随** — scroll/resize 时自动重算 fixed 坐标 |
1430
+ | `ctx.ui.useInView()` | 注册监听 | IO 合成器线程评估 | 当前组件 | **可见性观察**(IO 封装,无 scroll-linked 警告)— Affix/BackTop/InView 统一使用;rootMargin/threshold 支持函数 |
1431
+ | `ctx.ui.useScrollPosition()` | 注册监听 | 全局 scroll + rAF 节流 | 当前组件 | **滚动位置跟踪** — `y` 响应式(视口/内部容器通用),Affix/VirtualList 使用 |
1428
1432
 
1429
1433
  `render()` 和 `dirty()` 无参 = 当前组件,传参 = 指定组件列表。三套 API 同一 scope 机制。
1430
1434
 
@@ -2295,7 +2299,9 @@ import type { RouterOptions } from 'weifuwu/client'
2295
2299
 
2296
2300
  # 组件库 (`weifuwu/components`)
2297
2301
 
2298
- 61 个 HTML 原语组件。每个是 `(_init, ctx) => (props) => VNode`(两阶段组件,与前端框架同一模型),引用 `--wf-*` CSS 变量做主题。另含 `confirm()` / `toast()` 命令式中间件。
2302
+ 91 个 HTML 原语组件。每个是 `(_init, ctx) => (props) => VNode`(两阶段组件,与前端框架同一模型),引用 `--wf-*` CSS 变量做主题。另含 `confirm()` / `toast()` 命令式中间件。
2303
+
2304
+ > **组件速查(weifuwu 组件 ↔ antd / Element Plus / shadcn-ui 对应 + 迁移示例)**:见 [`docs/components-map.md`](./docs/components-map.md)——从其他组件库迁来的开发者按功能直接找对应组件。
2299
2305
 
2300
2306
  ```ts
2301
2307
  import { Button, Input, Table, Modal, Toast } from 'weifuwu/components'
@@ -2385,6 +2391,33 @@ import 'weifuwu/components/style.css' // 包含 Token + 67 布局原语 + 组
2385
2391
  </Field>
2386
2392
  <Button type="submit">登录</Button>
2387
2393
  </Form>
2394
+
2395
+ // ├─ 新增批次组件(全量实现)
2396
+ <Rate value={3} onChange={setRate} /> // 评分
2397
+ <ToggleGroup type="single" options={toolbar} value={fmt} /> // 工具栏切换
2398
+ <CheckboxGroup options={members} value={selected} onChange={setSelected} /> // 多选列表
2399
+ <PinInput length={6} value={code} onChange={setCode} /> // 验证码
2400
+ <CopyButton value="https://weifuwu.dev" label="复制" /> // 复制
2401
+ <ColorPicker value={color} showInput onChange={setColor} /> // 颜色
2402
+ <Notification /> + notification.success({ title, description }) // 队列通知
2403
+ <Collapse items={docs} active={open} /> // 行内折叠
2404
+ <Tree data={orgTree} checkable checkedKeys={keys} /> // 树形(父子联动)
2405
+ <Cascader options={regions} value={['zj','hz']} /> // 级联选择
2406
+ <Transfer data={members} targetKeys={selected} /> // 穿梭框
2407
+ <Command items={commands} open={open} onOpenChange={setOpen} /> // ⌘K 命令面板
2408
+ <Carousel autoplay>{slides}</Carousel> // 轮播
2409
+ <Resizable defaultSize={180}>…</Resizable> // 拖拽分割
2410
+ <Calendar month={5} year={2025} events={events} /> // 月历
2411
+ <Watermark text="内部资料">…</Watermark> // 水印
2412
+ <VirtualList height={400} itemHeight={36} items={rows} renderItem={render} /> // 虚拟列表
2413
+ <QRCode value="https://weifuwu.dev" size={128} /> // 二维码(自研编码)
2414
+ <Img src="photo.png" preview /> // 图片点击放大
2415
+ <BackTop /> <Affix offsetTop={64}>…</Affix> // 回顶 / 固定
2416
+ <HoverCard content={<UserCard />}>…</HoverCard> // 悬停富内容
2417
+ <Mentions options={users} value={text} /> // @提及
2418
+ <ContextMenu items={actions}>…</ContextMenu> // 右键菜单
2419
+ <Menubar menus={menus} /> // 水平菜单
2420
+ <InfiniteScroll hasMore onLoadMore>…</InfiniteScroll> // 无限滚动
2388
2421
  ```
2389
2422
 
2390
2423
  > 所有组件引用 `--wf-*` CSS 变量做主题,详见下文的「样式定制指南」。
@@ -2511,6 +2544,40 @@ props 变化 ──────────────────────
2511
2544
  | Steps | `Steps` | `items: StepItem[]`(`{ key, label }`), `current`, `active` | 步骤条 |
2512
2545
  | Accordion | `Accordion` | `items: AccordionItem[]`, `multiple` | 手风琴 |
2513
2546
 
2547
+ ### 新增批次(全量 91 组件)
2548
+
2549
+ | 组件 | 导入名 | 关键 Props | 说明 |
2550
+ |-----|--------|-----------|------|
2551
+ | Rate | `Rate` | `value`, `count`, `onChange`, `allowClear`, `readOnly`, `size` | 评分(键盘方向键/Home/End) |
2552
+ | Typography | `Title` `Text` `Paragraph` | `Title: level 1-5`;`Text: type/strong/underline/strike/mark/code`;`Paragraph: ellipsis` | 语义排版(Title/Text/Paragraph 三组件) |
2553
+ | Label | `Label` | `htmlFor`, `required` | 独立标签(必填星号) |
2554
+ | AspectRatio | `AspectRatio` | `ratio` | 宽高比容器(内容填满) |
2555
+ | Toggle | `Toggle` | `pressed`, `onPressedChange`, `variant`, `size` | 切换按钮(shadcn 对齐) |
2556
+ | ToggleGroup | `ToggleGroup` | `type: 'single'\|'multiple'`, `options`, `value`, `onChange` | 切换组 |
2557
+ | CheckboxGroup | `CheckboxGroup` | `options`, `value: string[]`, `onChange`, `cols` | 复选框组(栅格列数) |
2558
+ | PinInput | `PinInput` | `length`, `value`, `onChange`, `type` | 验证码输入(自动聚焦/粘贴分派/回退) |
2559
+ | CopyButton | `CopyButton` | `value`, `label`, `onCopy` | 复制按钮(clipboard + execCommand 降级) |
2560
+ | ColorPicker | `ColorPicker` | `value`, `onChange`, `showInput`, `preset` | 颜色选择(预设色板 + hex 输入) |
2561
+ | HoverCard | `HoverCard` | `content`, `position`, `openDelay`, `closeDelay` | 悬停富内容卡(shadcn) |
2562
+ | Notification | `Notification` | 命令式 `notification.success/error/warning/open` | 队列式通知(antd 对齐) |
2563
+ | BackTop | `BackTop` | `visibilityHeight`, `target`, `smooth` | 回到顶部(滚动超阈值显示) |
2564
+ | Affix | `Affix` | `offsetTop`, `target` | 固定定位(滚动超阈值钉住) |
2565
+ | ContextMenu | `ContextMenu` | `items: ContextMenuItem[]`(`{ label, onClick, variant: 'danger' }`) | 右键菜单(光标定位 + 方向键) |
2566
+ | Mentions | `Mentions` | `options: { value, label }[]`, `value`, `onChange`, `prefix` | @提及(composition 抑制) |
2567
+ | Collapse | `Collapse` | `items: CollapseItem[]`(`{ key, title, content, loading }`), `active`, `multiple` | 行内折叠(异步 loading) |
2568
+ | Tree | `Tree` | `data: TreeNode[]`, `expandedKeys`, `checkedKeys`, `checkable`, `selectedKeys`, `onCheck/onExpand/onSelect` | 树(递归 + 勾选父子联动 + 半选传播) |
2569
+ | Cascader | `Cascader` | `options: CascaderOption[]`, `value: string[]`, `onChange` | 级联选择(多列推进) |
2570
+ | Transfer | `Transfer` | `data: { key, label }[]`, `targetKeys`, `onChange`, `titles` | 穿梭框(选中 + 批量移动) |
2571
+ | Command | `Command` | `items: CommandItem[]`, `open`, `onOpenChange`, `shortcut` | 命令面板(⌘K 全局 + 键盘流) |
2572
+ | Menubar | `Menubar` | `menus: { key, label, items }[]` | 水平菜单栏(←→ 切换 + ↓ 展开) |
2573
+ | Carousel | `Carousel` | `children`, `autoplay`, `interval`, `loop`, `showArrows/Dots` | 轮播(箭头/圆点/循环/自动播放) |
2574
+ | Resizable | `Resizable` | `direction`, `defaultSize`, `min/maxSize` | 拖拽分割面板(pointer + 键盘方向键) |
2575
+ | Calendar | `Calendar` | `month`, `year`, `events`, `selectedDate`, `onMonthChange/onSelectDate` | 月历(事件点 + 月切换 + 选日) |
2576
+ | Watermark | `Watermark` | `text`, `fontSize`, `rotate`, `zIndex` | 水印(canvas 平铺) |
2577
+ | VirtualList | `VirtualList` | `items`, `height`, `itemHeight`, `renderItem`, `overscan` | 虚拟列表(spacer + 可见窗口,1000+ 条) |
2578
+ | InfiniteScroll | `InfiniteScroll` | `hasMore`, `loadMore`, `children`, `loader` | 触底加载(IntersectionObserver) |
2579
+ | QRCode | `QRCode` | `value`, `ecLevel`, `size`, `color`, `bgColor` | 二维码(自研 Reed-Solomon,版本 1-6) |
2580
+
2514
2581
  ### 图表
2515
2582
 
2516
2583
  | 组件 | 导入名 | 关键 Props | 说明 |
@@ -1,4 +1,4 @@
1
- var Ce="__wfAsyncComponent";function $e(e){let t=e;return t[Ce]=!0,t}function I(e){return typeof e=="function"&&e?.[Ce]===!0}var W=Symbol("Fragment"),P=Symbol("Portal");function ee(e,t,n){return{type:e,props:xe(t),key:n??void 0}}var Be=ee;function Ke(e,t,n){return ee(e,t,n)}function ze(e,t,...n){let o=xe(t??{});return n.length>0&&(o.children=n.length===1?n[0]:n),{type:e,props:o,key:t?.key??void 0}}function xe(e){if(!e)return{};let t={};for(let n of Object.keys(e))n!=="key"&&(t[n]=e[n]);return t}function Ge(e,t){return{type:P,props:{children:e,portalKey:t},key:t??void 0,_placement:"remote"}}var Je=0,A=new Map,$=[];function we(e){$.push(e)}var B=new WeakMap;function U(){B=new WeakMap}function te(e,t){let n=B.get(e);if(n)return n;let o={promise:null};return o.promise=Promise.resolve().then(()=>e(t)).then(r=>{if(typeof r!="function")throw new Error(`asyncComponent factory <${e.name||"anonymous"}> must return a Component (initProps, ctx) => (props) => VNode.`);return o.resolved=r,r}),B.set(e,o),o}async function be(e,t){return te(e,t).promise}function ve(e){return B.get(e)?.resolved}function Qe(e){let t=e._child;if(t!=null)if(Array.isArray(t))for(let n of t)n&&typeof n=="object"&&_(n);else typeof t=="object"&&_(t)}function _(e){if(e==null||typeof e!="object")return;let t=e;if(t._id){if(t._customId&&A.delete(t._customId),A.delete(t._id),$.length>0){for(let n of $)n(t._id);if(t._customId)for(let n of $)n(t._customId)}t._id=void 0,t._customId=void 0,t._render=void 0,t._parentNode=void 0,t._refNode=void 0}if(t._child!=null){if(Array.isArray(t._child))for(let n of t._child)n&&typeof n=="object"&&_(n);else _(t._child);t._child=void 0}if(t.props?.children&&typeof t.type=="string"){let n=Array.isArray(t.props.children)?t.props.children:[t.props.children];for(let o of n)o&&typeof o=="object"&&_(o)}typeof t.props?.ref=="function"&&t.props.ref(null),t._remoteEl&&(Qe(t),t._remoteEl.remove(),t._remoteEl=void 0)}function j(){return`_wf_${Je++}`}var Te=new WeakMap;function Ye(e){let t=Te.get(e)??{count:0,warned:!1};t.count++,t.count>=3&&!t.warned&&(t.warned=!0,console.warn("[weifuwu] ref \u51FD\u6570\u6BCF\u6B21\u6E32\u67D3\u90FD\u53D8\u5316\uFF08\u5185\u8054 ref\uFF09\u2014\u2014ref \u56DE\u8C03\u5728\u6BCF\u6B21\u6E32\u67D3\u540E\u91CD\u65B0\u6267\u884C\uFF08\u6027\u80FD\u635F\u8017\uFF09\u3002\u628A ref \u5B9A\u4E49\u5230 mount \u4F5C\u7528\u57DF\uFF08\u7A33\u5B9A\u5F15\u7528\uFF09\uFF1Aconst listRef = (el) => {...}; return h('div', { ref: listRef })")),Te.set(e,t)}function M(e,t,n,o,r){if(n==null){if(o==null)return null;let l=k(o,r);return l==null?null:(t&&t.parentNode?t.parentNode.insertBefore(l,t):e.appendChild(l),l)}if(o==null)return t?(_(n),t.remove()):_(n),null;let s=Ae(n),i=Ae(o);if(s!==i){_(n);let l=k(o,r);return l==null?null:(t?.parentNode&&t.parentNode.replaceChild(l,t),l)}if(i==="text")return t&&t.textContent!==String(o)&&(t.textContent=String(o)),t;let u=o,a=n;if(typeof u.type=="function"){let l=u.type;a._render&&(u._render=a._render,u._id=a._id,u._id&&A.set(u._id,u)),u._parentNode=e,u._refNode=t;let f=Object.create(r);if(f.ui=Object.create(r.ui),f.ui._selfId=u._id,f.ui._selfVNode=u,u._ctxVersion=a._ctxVersion??f.ui._ctxVersion??0,a._render&&et(a.props,u.props)&&!f.ui._dirtySet?.has(a._id)&&u._ctxVersion===f.ui._ctxVersion)return u._child=a._child,t;f.ui._dirtySet?.delete(a._id);let m;try{typeof u._render=="function"?m=u._render(u.props):m=re(l,u.props,u,f)}catch(c){let p=r.ui?._errorHandler;p?(p(c),m=null):(console.error(`[weifuwu] Component render error in <${l?.name||"anonymous"}> (id: ${a._id??"?"}, phase: update)`,c),m=null)}let y=a._child;u._child=m;let d=M(e,t,y,m,f);return d||(u._refNode=null),d}if(u.type===W){let l=a._childNodes,f=Re(e,a,u,r,l);return u._childNodes=f,t}if(typeof u.type=="string"){if(t&&t.nodeType===1){let l=a.props?.ref,f=u.props?.ref;l!==f&&(typeof f=="function"&&f(t),typeof l=="function"&&typeof f=="function"&&Ye(t)),oe(t,a.props,u.props),Re(t,a,u,r)}else if(t){_(n);let l=k(o,r);return l==null?null:(t.parentNode?.replaceChild(l,t),l)}return t}if(u.type===P)return q(a,u,r),null;if(Array.isArray(o)){let l=Array.isArray(n)?n:[];K(l,o);let f=Array.from(e.childNodes),m=t?f.indexOf(t):-1,y=m>=0?H(f.slice(m),l):H(f,l);return z(e,l,o,r,y,t),t}return t}var _e=new Map;function Xe(e){let t=_e.get(e);return t||(t=`fn:${e.name||"anon"}`,_e.set(e,t)),t}function Ae(e){if(e==null||typeof e=="boolean")return"null";if(typeof e=="string"||typeof e=="number")return"text";if(Array.isArray(e))return"array";let t=e;return typeof t.type=="function"?Xe(t.type):t.type===W?"fragment":t.type===P?"portal":typeof t.type=="string"?"tag:"+t.type:"unknown"}function oe(e,t,n){let o=t?Object.keys(t).filter(i=>i!=="children"&&i!=="key"&&i!=="innerHTML"):[],r=n?Object.keys(n).filter(i=>i!=="children"&&i!=="key"&&i!=="innerHTML"):[],s=new Set(r);for(let i of o)if(!s.has(i)){if(i==="ref")continue;i.startsWith("on")&&typeof t[i]=="function"?e.removeEventListener(i.slice(2).toLowerCase(),t[i]):i==="value"&&(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)?e.value="":e.removeAttribute(i==="className"?"class":i)}for(let i of r){if(i==="ref")continue;let u=t?.[i],a=n?.[i];if(i==="innerHTML")a!==u&&(e.innerHTML=String(a??""));else if(a!==u)if(i==="class"||i==="className")e instanceof SVGElement?e.setAttribute("class",Ne(a)):e.className=Ne(a);else if(i==="style"&&typeof a=="object"){let l=e.style;for(let f of Object.keys(a)){let m=a[f];m!=null&&(l[f]=typeof m=="number"?m+"px":String(m))}}else if(i.startsWith("on")&&typeof a=="function"){let l=i.slice(2).toLowerCase();typeof u=="function"&&e.removeEventListener(l,u),e.addEventListener(l,a)}else i==="value"&&(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)?e.value=String(a??""):a===!0?e.setAttribute(i,""):a!=null&&a!==!1?e.setAttribute(i,String(a)):i==="value"&&(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)?e.value="":e.removeAttribute(i)}}function Ne(e){return typeof e=="string"?e:Array.isArray(e)?e.filter(Boolean).join(" "):e&&typeof e=="object"?Object.entries(e).filter(([,t])=>t).map(([t])=>t).join(" "):""}function ne(e){if(!(e==null||typeof e!="object"))return e.key}function K(e,t){if(!t.some(o=>o&&typeof o=="object"&&o.key!==void 0)){for(let o=0;o<t.length;o++){let r=t[o];r&&typeof r=="object"&&(r.key=o)}for(let o=0;o<e.length;o++){let r=e[o];r&&typeof r=="object"&&(r.key=o)}}}function H(e,t){let n=[],o=0;for(let r of t){if(r==null||typeof r=="boolean"){n.push(null);continue}let s=r;if(s.type===P){n.push(null);continue}if(s.type===W){let i=s._childNodes;Array.isArray(i)&&i.length>0?(n.push(i.slice()),o+=i.length):(n.push(e[o]?[e[o]]:null),o+=1)}else typeof process<"u"&&process.env.DBG&&console.error("[map] idx=",o,"type=",s.type,"sourceLen=",e.length,"hit=",!!e[o]),n.push(e[o]?[e[o]]:null),o+=1}return n}function Re(e,t,n,o,r){let s=D(t.props?.children),i=D(n.props?.children);K(s,i);let u=r??Array.from(e.childNodes),a=H(u,s),l=z(e,s,i,o,a,r?.[0]??null),f=[];for(let m of l)m&&m.length>0&&f.push(...m);return f}function D(e){if(e==null)return[];if(!Array.isArray(e))return[e];let t=[];for(let n of e)Array.isArray(n)?t.push(...n):t.push(n);return t}function ke(e){return e==null?[]:e instanceof DocumentFragment?Array.from(e.childNodes):[e]}function z(e,t,n,o,r=[],s=null){if(!n.some(c=>c&&typeof c=="object"&&c.key!==void 0)){let c=Math.max(t.length,n.length);for(let p=0;p<c;p++){let g=p<t.length?t[p]:null,h=p<n.length?n[p]:null;if(h==null){if(g!=null){_(g);for(let x of r[p]??[])x.remove()}}else if(g==null){let x=k(h,o);x!=null&&e.appendChild(x)}else{let x=r[p]?.[0]??null;M(e,x,g,h,o)}}return[]}for(let c=0;c<t.length;c++){let p=t[c];if(!(p==null||typeof p=="boolean")&&ne(p)===void 0)for(let g of r[c]??[])g.remove()}let u=new Map,a=0;for(let c=0;c<t.length;c++){let p=ne(t[c]);p!==void 0&&u.set(p,{vnode:t[c],nodes:r[c]??[],index:a++})}let l=n.map(c=>ne(c)),f=new Set(l);for(let c of[...u.keys()])if(!f.has(c)){let p=u.get(c);_(p.vnode);for(let g of p.nodes)g?.remove();u.delete(c)}let m=new Array(n.length).fill(null),y=-1,d=s&&s.parentNode===e?s:e.firstChild;for(let c=0;c<n.length;c++){let p=l[c],g=n[c],h=p!==void 0?u.get(p):void 0,x=g&&typeof g=="object"&&g._placement==="remote";if(h)if(h.nodes.length>0){if(h.index<y)for(let C of h.nodes)e.insertBefore(C,d);y=Math.max(y,h.index),M(e,h.nodes[0],h.vnode,g,o),m[c]=g._childNodes??h.nodes.filter(C=>C.parentNode===e),d=m[c][m[c].length-1]?.nextSibling??null}else if(x)q(h.vnode,g,o),m[c]=[];else{let v=M(e,null,h.vnode,g,o);m[c]=ke(v);for(let b of m[c])e.insertBefore(b,d);d=m[c][m[c].length-1]?.nextSibling??null}else if(x)V(g,o),m[c]=[];else{let v=k(g,o);m[c]=ke(v);for(let b of m[c])e.insertBefore(b,d);d=m[c][m[c].length-1]?.nextSibling??null}}return m}function Ze(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}return e===t}function et(e,t){if(e===t)return!0;if(!e||!t)return!1;let n=new Set([...Object.keys(e),...Object.keys(t)]);for(let o of n)if(o!=="key"){if(o==="children"){if(!Ze(e[o],t[o]))return!1}else if(e[o]!==t[o])return!1}return!0}var se="http://www.w3.org/2000/svg",ie=new Set(["svg","path","circle","line","rect","text","g","polyline","polygon","ellipse","defs","use","clipPath","mask","linearGradient","radialGradient","stop","tspan"]);function Se(e,t){return k(e,t)}function k(e,t){if(e==null||typeof e=="boolean")return null;if(typeof e=="string"||typeof e=="number")return document.createTextNode(String(e));if(Array.isArray(e))return ot(e,t);let n=e;if(n.type===P)return V(n,t),null;if(n.type===W){let i=document.createDocumentFragment(),u=n.props?.children==null?[]:Array.isArray(n.props.children)?n.props.children:[n.props.children];for(let a of u){let l=k(a,t);l!=null&&i.appendChild(l)}return n._childNodes=Array.from(i.childNodes),i}if(typeof n.type=="function")return nt(n.type,n.props,n,t);let o=n.type,r=ie.has(o)?document.createElementNS(se,o):document.createElement(o);n.el=r;let s;for(let[i,u]of Object.entries(n.props??{}))i==="children"||i==="key"||i==="value"||i==="innerHTML"||Ee(r,i,u);if("value"in(n.props??{})&&r instanceof HTMLSelectElement?s=n.props.value:"value"in(n.props??{})&&Ee(r,"value",n.props.value),"innerHTML"in(n.props??{}))r.innerHTML=String(n.props.innerHTML??"");else{let i=ae(n.props?.children);for(let u of i){let a=k(u,t);if(a!=null&&(r.appendChild(a),u&&typeof u=="object"&&typeof u.type=="function")){let l=u;l._parentNode||(l._parentNode=r,l._refNode=a)}}}return s!==void 0&&(r.value=String(s)),typeof n.props?.ref=="function"&&n.props.ref(r),r}function tt(e){let t=e.ui;t&&typeof t.render=="function"&&t.render(["_wf_root"])}function re(e,t,n,o){let r;if(I(e)){if(r=ve(e),!r)return te(e,o).promise.then(()=>tt(o),()=>{}),null}else r=e;let s=r(t,o);if(typeof s!="function")throw new Error(`Component ${e.name||"anonymous"} must return a render function. Use (init_props, ctx) => (props) => VNode pattern.`);return n._render=s,s(t)}function nt(e,t,n,o){o.ui=o.ui??{},n._id||(n._id=j(),A.set(n._id,n));let r=Object.create(o);r.ui=Object.create(o.ui),r.ui._selfId=n._id,r.ui._selfVNode=n,n._ctxVersion=r.ui._ctxVersion??0;let s;try{s=re(e,t,n,r)}catch(u){let a=o.ui?._errorHandler;a?(a(u),s=null):(console.error(`[weifuwu] Component render error in <${e.name||"anonymous"}> (id: ${n._id??"?"}, phase: mount)`,u),s=null)}if(s==null)return n._child=null,null;n._child=s;let i=k(s,r);return n._refNode||(n._refNode=i),i}function ot(e,t){let n=document.createDocumentFragment();for(let o of e){let r=k(o,t);r!=null&&n.appendChild(r)}return n}function rt(){let e=document.getElementById("__wf_portal");return e||(e=document.createElement("div"),e.id="__wf_portal",e.style.cssText="position:fixed;inset:0;pointer-events:none;z-index:9999",document.body.appendChild(e)),e}function V(e,t){let n=rt(),o=document.createElement("div");o.style.pointerEvents="auto",n.appendChild(o),e._remoteEl=o;let r=D(e.props?.children);e._child=r;for(let s of r){let i=k(s,t);i!=null&&o.appendChild(i)}}function q(e,t,n){let o=e?._remoteEl;if(t._remoteEl=o,!o){V(t,n);return}let r=D(t.props?.children),s=e._child||[];t._child=r,K(s,r);let i=H(Array.from(o.childNodes),s);z(o,s,r,n,i,i[0]?.[0]??null)}function ae(e){if(e==null)return[];if(!Array.isArray(e))return[e];let t=[];for(let n of e)Array.isArray(n)?t.push(...n):t.push(n);return t}function Ee(e,t,n){if(t==="class"||t==="className")e instanceof SVGElement?e.setAttribute("class",String(n??"")):e.className=String(n??"");else if(t==="style"&&typeof n=="object"&&n!==null){let o=e.style;for(let r of Object.keys(n)){let s=n[r];s!=null&&(o[r]=typeof s=="number"?s+"px":String(s))}}else t.startsWith("on")&&typeof n=="function"?e.addEventListener(t.slice(2).toLowerCase(),n):t==="value"&&(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)?e.value=String(n??""):n===!0?e.setAttribute(t,""):n!=null&&n!==!1&&e.setAttribute(t,String(n))}function st(e,t,n){e.innerHTML="";let o=k(t,n);o instanceof Node?e.appendChild(o):Array.isArray(o)&&o.forEach(r=>e.appendChild(r))}function le(e){e.node=e.node?e.node.nextSibling:null}function it(e,t){e.node&&e.node.parentNode?e.node.parentNode.insertBefore(t,e.node):e.parent.appendChild(t)}function at(e,t){e.node&&e.node.parentNode?(e.node.parentNode.replaceChild(t,e.node),le(e)):e.parent.appendChild(t)}async function F(e,t,n){if(e==null||typeof e=="boolean")return null;if(typeof e=="string"||typeof e=="number"){let u=String(e);if(n.node&&n.node.nodeType===3)return n.node.textContent!==u&&(n.node.textContent=u),le(n),n.node;let a=document.createTextNode(u);return it(n,a),a}if(Array.isArray(e)){let u=null;for(let a of e){let l=await F(a,t,n);l!=null&&!u&&(u=l)}return u}let o=e;if(o.type===P||o.type===W){let u=o.props?.children,a=u==null?[]:Array.isArray(u)?u:[u],l=null;for(let f of a){let m=await F(f,t,n);m!=null&&!l&&(l=m)}return l}if(typeof o.type=="function")return lt(o,t,n);let r=o.type,s=o.props??{},i;if(n.node&&n.node.nodeType===1&&n.node.tagName.toLowerCase()===r.toLowerCase()?(i=n.node,le(n)):(i=ie.has(r)?document.createElementNS(se,r):document.createElement(r),at(n,i)),o.el=i,oe(i,null,s),!("innerHTML"in s)){let u={parent:i,node:i.firstChild},a=ae(s.children);for(let l of a){let f=await F(l,t,u);if(f!=null&&f.parentNode!==i&&i.appendChild(f),l&&typeof l=="object"&&typeof l.type=="function"){let m=l;m._parentNode||(m._parentNode=i,m._refNode=f)}}for(;u.node;){let l=u.node;u.node=l.nextSibling,l.parentNode?.removeChild(l)}}return"value"in s&&i instanceof HTMLSelectElement&&(i.value=String(s.value??"")),typeof s.ref=="function"&&s.ref(i),i}async function lt(e,t,n){t.ui=t.ui??{},e._id||(e._id=j(),A.set(e._id,e));let o=Object.create(t);o.ui=Object.create(t.ui),o.ui._selfId=e._id,o.ui._selfVNode=e,e._ctxVersion=o.ui._ctxVersion??0;let r=e.type,s;try{let u;I(r)?u=await be(r,o):u=r;let a=u(e.props??{},o);if(typeof a!="function")throw new Error(`Component ${r.name||"anonymous"} must return a render function. Use (init_props, ctx) => (props) => VNode pattern.`);e._render=a,s=a(e.props??{})}catch(u){let a=t.ui?._errorHandler;a?(a(u),s=null):(console.error(`[weifuwu] Component hydration error in <${r.name||"anonymous"}> (id: ${e._id??"?"})`,u),s=null)}if(s==null)return e._child=null,null;e._child=s;let i=await F(s,o,n);return e._refNode||(e._refNode=i),i}async function ue(e,t,n){let o={parent:e,node:e.firstChild};for(await F(t,n,o);o.node;){let r=o.node;o.node=r.nextSibling,r.parentNode?.removeChild(r)}}function ce(e){let t=new WeakMap,n=new Set,o=s=>{if(s===null||typeof s!="object")return s;if(t.has(s))return t.get(s);let i=new Proxy(s,{set(u,a,l){if(Reflect.get(u,a)===l)return!0;Reflect.set(u,a,l),e();for(let m of n)m();return!0},get(u,a){let l=Reflect.get(u,a);return typeof l=="object"&&l!==null?o(l):l},deleteProperty(u,a){if(Reflect.has(u,a)){Reflect.deleteProperty(u,a),e();for(let l of n)l()}return!0}});return t.set(s,i),i},r=o({});return Object.defineProperty(r,"__watch",{value:s=>(n.add(s),()=>{n.delete(s)}),writable:!1,enumerable:!1}),r}function fe(e,t,n){let o=new AbortController,r=n?.signal;r&&(r.aborted?o.abort():r.addEventListener("abort",()=>o.abort(),{once:!0}));let s=n?.traceId??pt(),i=n?.record!==!1,u=[],a=(async()=>{let l;try{l=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json","X-Trace-Id":s,Accept:"text/event-stream",...n?.headers},body:JSON.stringify(t),signal:o.signal})}catch(f){if(o.signal.aborted)return;n?.onError?.({code:"provider_error",message:f instanceof Error?f.message:String(f)});return}if(!l.ok){n?.onError?.({code:dt(l.status),message:`HTTP ${l.status} ${l.statusText}`});return}try{for await(let{name:f,data:m}of ct(l.body)){if(o.signal.aborted)return;ft(u,{name:f,data:m},i),ut(f,m,n??{})}}catch(f){if(o.signal.aborted)return;n?.onError?.({code:"provider_error",message:f instanceof Error?f.message:String(f)})}})();return{abort:()=>o.abort(),done:a,traceId:s,events:u}}function ut(e,t,n){switch(e){case"wf:token":return n.onToken?.(t.text);case"wf:tool_call":return n.onToolCall?.(t);case"wf:tool_result":return n.onToolResult?.(t);case"wf:tool_progress":return n.onToolProgress?.(t);case"wf:step":return n.onStep?.(t);case"wf:approval_request":return n.onApproval?.(t);case"wf:usage":return n.onUsage?.(t);case"wf:done":return n.onDone?.(t);case"wf:error":return n.onError?.(t);default:return n.onEvent?.(e,t)}}async function*ct(e){let t=e.getReader(),n=new TextDecoder,o="";try{for(;;){let{done:r,value:s}=await t.read();if(r)break;o+=n.decode(s,{stream:!0});let i=o.split(`
1
+ var xe="__wfAsyncComponent";function Be(e){let t=e;return t[xe]=!0,t}function H(e){return typeof e=="function"&&e?.[xe]===!0}var M=Symbol("Fragment"),W=Symbol("Portal");function te(e,t,n){return{type:e,props:we(t),key:n??void 0}}var Ke=te;function ze(e,t,n){return te(e,t,n)}function Ge(e,t,...n){let o=we(t??{});return n.length>0&&(o.children=n.length===1?n[0]:n),{type:e,props:o,key:t?.key??void 0}}function we(e){if(!e)return{};let t={};for(let n of Object.keys(e))n!=="key"&&(t[n]=e[n]);return t}function Je(e,t){return{type:W,props:{children:e,portalKey:t},key:t??void 0,_placement:"remote"}}var Qe=0,N=new Map,K=[];function be(e){K.push(e)}var z=new WeakMap;function j(){z=new WeakMap}function ne(e,t){let n=z.get(e);if(n)return n;let o={promise:null};return o.promise=Promise.resolve().then(()=>e(t)).then(r=>{if(typeof r!="function")throw new Error(`asyncComponent factory <${e.name||"anonymous"}> must return a Component (initProps, ctx) => (props) => VNode.`);return o.resolved=r,r}),z.set(e,o),o}async function ve(e,t){return ne(e,t).promise}function Te(e){return z.get(e)?.resolved}function Ye(e){let t=e._child;if(t!=null)if(Array.isArray(t))for(let n of t)n&&typeof n=="object"&&E(n);else typeof t=="object"&&E(t)}function E(e){if(e==null||typeof e!="object")return;let t=e;if(t._id){if(t._customId&&N.delete(t._customId),N.delete(t._id),K.length>0){for(let n of K)n(t._id);if(t._customId)for(let n of K)n(t._customId)}t._id=void 0,t._customId=void 0,t._render=void 0,t._parentNode=void 0,t._refNode=void 0}if(t._child!=null){if(Array.isArray(t._child))for(let n of t._child)n&&typeof n=="object"&&E(n);else E(t._child);t._child=void 0}if(t.props?.children&&typeof t.type=="string"){let n=Array.isArray(t.props.children)?t.props.children:[t.props.children];for(let o of n)o&&typeof o=="object"&&E(o)}typeof t.props?.ref=="function"&&t.props.ref(null),t._remoteEl&&(Ye(t),t._remoteEl.remove(),t._remoteEl=void 0)}function D(){return`_wf_${Qe++}`}var _e=new WeakMap;function Xe(e){let t=_e.get(e)??{count:0,warned:!1};t.count++,t.count>=3&&!t.warned&&(t.warned=!0,console.warn("[weifuwu] ref \u51FD\u6570\u6BCF\u6B21\u6E32\u67D3\u90FD\u53D8\u5316\uFF08\u5185\u8054 ref\uFF09\u2014\u2014ref \u56DE\u8C03\u5728\u6BCF\u6B21\u6E32\u67D3\u540E\u91CD\u65B0\u6267\u884C\uFF08\u6027\u80FD\u635F\u8017\uFF09\u3002\u628A ref \u5B9A\u4E49\u5230 mount \u4F5C\u7528\u57DF\uFF08\u7A33\u5B9A\u5F15\u7528\uFF09\uFF1Aconst listRef = (el) => {...}; return h('div', { ref: listRef })")),_e.set(e,t)}function I(e,t,n,o,r){if(n==null){if(o==null)return null;let u=R(o,r);return u==null?null:(t&&t.parentNode?t.parentNode.insertBefore(u,t):e.appendChild(u),u)}if(o==null)return t?(E(n),t.remove()):E(n),null;let s=Se(n),i=Se(o);if(s!==i){E(n);let u=R(o,r);return u==null?null:(t?.parentNode&&t.parentNode.replaceChild(u,t),u)}if(i==="text")return t&&t.textContent!==String(o)&&(t.textContent=String(o)),t;let l=o,a=n;if(typeof l.type=="function"){let u=l.type;a._render&&(l._render=a._render,l._id=a._id,l._id&&N.set(l._id,l)),l._parentNode=e,l._refNode=t;let p=Object.create(r);if(p.ui=Object.create(r.ui),p.ui._selfId=l._id,p.ui._selfVNode=l,l._ctxVersion=a._ctxVersion??p.ui._ctxVersion??0,a._render&&tt(a.props,l.props)&&!p.ui._dirtySet?.has(a._id)&&l._ctxVersion===p.ui._ctxVersion)return l._child=a._child,t;p.ui._dirtySet?.delete(a._id);let m;try{typeof l._render=="function"?m=l._render(l.props):m=se(u,l.props,l,p)}catch(c){let f=r.ui?._errorHandler;f?(f(c),m=null):(console.error(`[weifuwu] Component render error in <${u?.name||"anonymous"}> (id: ${a._id??"?"}, phase: update)`,c),m=null)}let w=a._child;l._child=m;let d=I(e,t,w,m,p);return d||(l._refNode=null),d}if(l.type===M){let u=a._childNodes,p=Ne(e,a,l,r,u);return l._childNodes=p,t}if(typeof l.type=="string"){if(t&&t.nodeType===1){let u=a.props?.ref,p=l.props?.ref;u!==p&&(typeof p=="function"&&p(t),typeof u=="function"&&typeof p=="function"&&Xe(t)),re(t,a.props,l.props),Ne(t,a,l,r)}else if(t){E(n);let u=R(o,r);return u==null?null:(t.parentNode?.replaceChild(u,t),u)}return t}if(l.type===W)return $(a,l,r),null;if(Array.isArray(o)){let u=Array.isArray(n)?n:[];G(u,o);let p=Array.from(e.childNodes),m=t?p.indexOf(t):-1,w=m>=0?q(p.slice(m),u):q(p,u);return J(e,u,o,r,w,t),t}return t}var Ae=new Map;function Ze(e){let t=Ae.get(e);return t||(t=`fn:${e.name||"anon"}`,Ae.set(e,t)),t}function Se(e){if(e==null||typeof e=="boolean")return"null";if(typeof e=="string"||typeof e=="number")return"text";if(Array.isArray(e))return"array";let t=e;return typeof t.type=="function"?Ze(t.type):t.type===M?"fragment":t.type===W?"portal":typeof t.type=="string"?"tag:"+t.type:"unknown"}function re(e,t,n){let o=t?Object.keys(t).filter(i=>i!=="children"&&i!=="key"&&i!=="innerHTML"):[],r=n?Object.keys(n).filter(i=>i!=="children"&&i!=="key"&&i!=="innerHTML"):[],s=new Set(r);for(let i of o)if(!s.has(i)){if(i==="ref")continue;i.startsWith("on")&&typeof t[i]=="function"?e.removeEventListener(i.slice(2).toLowerCase(),t[i]):i==="value"&&(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)?e.value="":e.removeAttribute(i==="className"?"class":i)}for(let i of r){if(i==="ref")continue;let l=t?.[i],a=n?.[i];if(i==="innerHTML")a!==l&&(e.innerHTML=String(a??""));else if(a!==l)if(i==="class"||i==="className")e instanceof SVGElement?e.setAttribute("class",Ee(a)):e.className=Ee(a);else if(i==="style"&&typeof a=="object"){let u=e.style;for(let p of Object.keys(a)){let m=a[p];m!=null&&(u[p]=typeof m=="number"?m+"px":String(m))}}else if(i.startsWith("on")&&typeof a=="function"){let u=i.slice(2).toLowerCase();typeof l=="function"&&e.removeEventListener(u,l),e.addEventListener(u,a)}else i==="value"&&(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)?e.value=String(a??""):a===!0?e.setAttribute(i,""):a!=null&&a!==!1?e.setAttribute(i,String(a)):i==="value"&&(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)?e.value="":e.removeAttribute(i)}}function Ee(e){return typeof e=="string"?e:Array.isArray(e)?e.filter(Boolean).join(" "):e&&typeof e=="object"?Object.entries(e).filter(([,t])=>t).map(([t])=>t).join(" "):""}function oe(e){if(!(e==null||typeof e!="object"))return e.key}function G(e,t){if(!t.some(o=>o&&typeof o=="object"&&o.key!==void 0)){for(let o=0;o<t.length;o++){let r=t[o];r&&typeof r=="object"&&(r.key=o)}for(let o=0;o<e.length;o++){let r=e[o];r&&typeof r=="object"&&(r.key=o)}}}function q(e,t){let n=[],o=0;for(let r of t){if(r==null||typeof r=="boolean"){n.push(null);continue}let s=r;if(s.type===W){n.push(null);continue}if(s.type===M){let i=s._childNodes;Array.isArray(i)&&i.length>0?(n.push(i.slice()),o+=i.length):(n.push(e[o]?[e[o]]:null),o+=1)}else typeof process<"u"&&process.env.DBG&&console.error("[map] idx=",o,"type=",s.type,"sourceLen=",e.length,"hit=",!!e[o]),n.push(e[o]?[e[o]]:null),o+=1}return n}function Ne(e,t,n,o,r){let s=F(t.props?.children),i=F(n.props?.children);G(s,i);let l=r??Array.from(e.childNodes),a=q(l,s),u=J(e,s,i,o,a,r?.[0]??null),p=[];for(let m of u)m&&m.length>0&&p.push(...m);return p}function F(e){if(e==null)return[];if(!Array.isArray(e))return[e];let t=[];for(let n of e)Array.isArray(n)?t.push(...n):t.push(n);return t}function ke(e){return e==null?[]:e instanceof DocumentFragment?Array.from(e.childNodes):[e]}function J(e,t,n,o,r=[],s=null){if(!n.some(c=>c&&typeof c=="object"&&c.key!==void 0)){let c=Math.max(t.length,n.length);for(let f=0;f<c;f++){let y=f<t.length?t[f]:null,g=f<n.length?n[f]:null;if(g==null){if(y!=null){E(y);for(let h of r[f]??[])h.remove()}}else if(y==null){let h=R(g,o);h!=null&&e.appendChild(h)}else{let h=r[f]?.[0]??null;I(e,h,y,g,o)}}return[]}for(let c=0;c<t.length;c++){let f=t[c];if(!(f==null||typeof f=="boolean")&&oe(f)===void 0)for(let y of r[c]??[])y.remove()}let l=new Map,a=0;for(let c=0;c<t.length;c++){let f=oe(t[c]);f!==void 0&&l.set(f,{vnode:t[c],nodes:r[c]??[],index:a++})}let u=n.map(c=>oe(c)),p=new Set(u);for(let c of[...l.keys()])if(!p.has(c)){let f=l.get(c);E(f.vnode);for(let y of f.nodes)y?.remove();l.delete(c)}let m=new Array(n.length).fill(null),w=-1,d=s&&s.parentNode===e?s:e.firstChild;for(let c=0;c<n.length;c++){let f=u[c],y=n[c],g=f!==void 0?l.get(f):void 0,h=y&&typeof y=="object"&&y._placement==="remote";if(g)if(g.nodes.length>0){if(g.index<w)for(let A of g.nodes)e.insertBefore(A,d);w=Math.max(w,g.index),I(e,g.nodes[0],g.vnode,y,o),m[c]=y._childNodes??g.nodes.filter(A=>A.parentNode===e),d=m[c][m[c].length-1]?.nextSibling??null}else if(h)$(g.vnode,y,o),m[c]=[];else{let b=I(e,null,g.vnode,y,o);m[c]=ke(b);for(let x of m[c])e.insertBefore(x,d);d=m[c][m[c].length-1]?.nextSibling??null}else if(h)O(y,o),m[c]=[];else{let b=R(y,o);m[c]=ke(b);for(let x of m[c])e.insertBefore(x,d);d=m[c][m[c].length-1]?.nextSibling??null}}return m}function et(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}return e===t}function tt(e,t){if(e===t)return!0;if(!e||!t)return!1;let n=new Set([...Object.keys(e),...Object.keys(t)]);for(let o of n)if(o!=="key"){if(o==="children"){if(!et(e[o],t[o]))return!1}else if(e[o]!==t[o])return!1}return!0}var ie="http://www.w3.org/2000/svg",ae=new Set(["svg","path","circle","line","rect","text","g","polyline","polygon","ellipse","defs","use","clipPath","mask","linearGradient","radialGradient","stop","tspan"]);function Pe(e,t){return R(e,t)}function R(e,t){if(e==null||typeof e=="boolean")return null;if(typeof e=="string"||typeof e=="number")return document.createTextNode(String(e));if(Array.isArray(e))return rt(e,t);let n=e;if(n.type===W)return O(n,t),null;if(n.type===M){let i=document.createDocumentFragment(),l=n.props?.children==null?[]:Array.isArray(n.props.children)?n.props.children:[n.props.children];for(let a of l){let u=R(a,t);u!=null&&i.appendChild(u)}return n._childNodes=Array.from(i.childNodes),i}if(typeof n.type=="function")return ot(n.type,n.props,n,t);let o=n.type,r=ae.has(o)?document.createElementNS(ie,o):document.createElement(o);n.el=r;let s;for(let[i,l]of Object.entries(n.props??{}))i==="children"||i==="key"||i==="value"||i==="innerHTML"||Re(r,i,l);if("value"in(n.props??{})&&r instanceof HTMLSelectElement?s=n.props.value:"value"in(n.props??{})&&Re(r,"value",n.props.value),"innerHTML"in(n.props??{}))r.innerHTML=String(n.props.innerHTML??"");else{let i=le(n.props?.children);for(let l of i){let a=R(l,t);if(a!=null&&(r.appendChild(a),l&&typeof l=="object"&&typeof l.type=="function")){let u=l;u._parentNode||(u._parentNode=r,u._refNode=a)}}}return s!==void 0&&(r.value=String(s)),typeof n.props?.ref=="function"&&n.props.ref(r),r}function nt(e){let t=e.ui;t&&typeof t.render=="function"&&t.render(["_wf_root"])}function se(e,t,n,o){let r;if(H(e)){if(r=Te(e),!r)return ne(e,o).promise.then(()=>nt(o),()=>{}),null}else r=e;let s=r(t,o);if(typeof s!="function")throw new Error(`Component ${e.name||"anonymous"} must return a render function. Use (init_props, ctx) => (props) => VNode pattern.`);return n._render=s,s(t)}function ot(e,t,n,o){o.ui=o.ui??{},n._id||(n._id=D(),N.set(n._id,n));let r=Object.create(o);r.ui=Object.create(o.ui),r.ui._selfId=n._id,r.ui._selfVNode=n,n._ctxVersion=r.ui._ctxVersion??0;let s;try{s=se(e,t,n,r)}catch(l){let a=o.ui?._errorHandler;a?(a(l),s=null):(console.error(`[weifuwu] Component render error in <${e.name||"anonymous"}> (id: ${n._id??"?"}, phase: mount)`,l),s=null)}if(s==null)return n._child=null,null;n._child=s;let i=R(s,r);return n._refNode||(n._refNode=i),i}function rt(e,t){let n=document.createDocumentFragment();for(let o of e){let r=R(o,t);r!=null&&n.appendChild(r)}return n}function st(){let e=document.getElementById("__wf_portal");return e||(e=document.createElement("div"),e.id="__wf_portal",e.style.cssText="position:fixed;inset:0;pointer-events:none;z-index:9999",document.body.appendChild(e)),e}function O(e,t){let n=st(),o=document.createElement("div");o.style.pointerEvents="auto",n.appendChild(o),e._remoteEl=o;let r=F(e.props?.children);e._child=r;for(let s of r){let i=R(s,t);i!=null&&o.appendChild(i)}}function $(e,t,n){let o=e?._remoteEl;if(t._remoteEl=o,!o){O(t,n);return}let r=F(t.props?.children),s=e._child||[];t._child=r,G(s,r);let i=q(Array.from(o.childNodes),s);J(o,s,r,n,i,i[0]?.[0]??null)}function le(e){if(e==null)return[];if(!Array.isArray(e))return[e];let t=[];for(let n of e)Array.isArray(n)?t.push(...n):t.push(n);return t}function Re(e,t,n){if(t==="class"||t==="className")e instanceof SVGElement?e.setAttribute("class",String(n??"")):e.className=String(n??"");else if(t==="style"&&typeof n=="object"&&n!==null){let o=e.style;for(let r of Object.keys(n)){let s=n[r];s!=null&&(o[r]=typeof s=="number"?s+"px":String(s))}}else t.startsWith("on")&&typeof n=="function"?e.addEventListener(t.slice(2).toLowerCase(),n):t==="value"&&(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)?e.value=String(n??""):n===!0?e.setAttribute(t,""):n!=null&&n!==!1&&e.setAttribute(t,String(n))}function it(e,t,n){e.innerHTML="";let o=R(t,n);o instanceof Node?e.appendChild(o):Array.isArray(o)&&o.forEach(r=>e.appendChild(r))}function ue(e){e.node=e.node?e.node.nextSibling:null}function at(e,t){e.node&&e.node.parentNode?e.node.parentNode.insertBefore(t,e.node):e.parent.appendChild(t)}function lt(e,t){e.node&&e.node.parentNode?(e.node.parentNode.replaceChild(t,e.node),ue(e)):e.parent.appendChild(t)}async function B(e,t,n){if(e==null||typeof e=="boolean")return null;if(typeof e=="string"||typeof e=="number"){let l=String(e);if(n.node&&n.node.nodeType===3)return n.node.textContent!==l&&(n.node.textContent=l),ue(n),n.node;let a=document.createTextNode(l);return at(n,a),a}if(Array.isArray(e)){let l=null;for(let a of e){let u=await B(a,t,n);u!=null&&!l&&(l=u)}return l}let o=e;if(o.type===W||o.type===M){let l=o.props?.children,a=l==null?[]:Array.isArray(l)?l:[l],u=null;for(let p of a){let m=await B(p,t,n);m!=null&&!u&&(u=m)}return u}if(typeof o.type=="function")return ut(o,t,n);let r=o.type,s=o.props??{},i;if(n.node&&n.node.nodeType===1&&n.node.tagName.toLowerCase()===r.toLowerCase()?(i=n.node,ue(n)):(i=ae.has(r)?document.createElementNS(ie,r):document.createElement(r),lt(n,i)),o.el=i,re(i,null,s),!("innerHTML"in s)){let l={parent:i,node:i.firstChild},a=le(s.children);for(let u of a){let p=await B(u,t,l);if(p!=null&&p.parentNode!==i&&i.appendChild(p),u&&typeof u=="object"&&typeof u.type=="function"){let m=u;m._parentNode||(m._parentNode=i,m._refNode=p)}}for(;l.node;){let u=l.node;l.node=u.nextSibling,u.parentNode?.removeChild(u)}}return"value"in s&&i instanceof HTMLSelectElement&&(i.value=String(s.value??"")),typeof s.ref=="function"&&s.ref(i),i}async function ut(e,t,n){t.ui=t.ui??{},e._id||(e._id=D(),N.set(e._id,e));let o=Object.create(t);o.ui=Object.create(t.ui),o.ui._selfId=e._id,o.ui._selfVNode=e,e._ctxVersion=o.ui._ctxVersion??0;let r=e.type,s;try{let l;H(r)?l=await ve(r,o):l=r;let a=l(e.props??{},o);if(typeof a!="function")throw new Error(`Component ${r.name||"anonymous"} must return a render function. Use (init_props, ctx) => (props) => VNode pattern.`);e._render=a,s=a(e.props??{})}catch(l){let a=t.ui?._errorHandler;a?(a(l),s=null):(console.error(`[weifuwu] Component hydration error in <${r.name||"anonymous"}> (id: ${e._id??"?"})`,l),s=null)}if(s==null)return e._child=null,null;e._child=s;let i=await B(s,o,n);return e._refNode||(e._refNode=i),i}async function ce(e,t,n){let o={parent:e,node:e.firstChild};for(await B(t,n,o);o.node;){let r=o.node;o.node=r.nextSibling,r.parentNode?.removeChild(r)}}function fe(e){let t=new WeakMap,n=new Set,o=s=>{if(s===null||typeof s!="object")return s;if(t.has(s))return t.get(s);let i=new Proxy(s,{set(l,a,u){if(Reflect.get(l,a)===u)return!0;Reflect.set(l,a,u),e();for(let m of n)m();return!0},get(l,a){let u=Reflect.get(l,a);return typeof u=="object"&&u!==null?o(u):u},deleteProperty(l,a){if(Reflect.has(l,a)){Reflect.deleteProperty(l,a),e();for(let u of n)u()}return!0}});return t.set(s,i),i},r=o({});return Object.defineProperty(r,"__watch",{value:s=>(n.add(s),()=>{n.delete(s)}),writable:!1,enumerable:!1}),r}function de(e,t,n){let o=new AbortController,r=n?.signal;r&&(r.aborted?o.abort():r.addEventListener("abort",()=>o.abort(),{once:!0}));let s=n?.traceId??mt(),i=n?.record!==!1,l=[],a=(async()=>{let u;try{u=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json","X-Trace-Id":s,Accept:"text/event-stream",...n?.headers},body:JSON.stringify(t),signal:o.signal})}catch(p){if(o.signal.aborted)return;n?.onError?.({code:"provider_error",message:p instanceof Error?p.message:String(p)});return}if(!u.ok){n?.onError?.({code:pt(u.status),message:`HTTP ${u.status} ${u.statusText}`});return}try{for await(let{name:p,data:m}of ft(u.body)){if(o.signal.aborted)return;dt(l,{name:p,data:m},i),ct(p,m,n??{})}}catch(p){if(o.signal.aborted)return;n?.onError?.({code:"provider_error",message:p instanceof Error?p.message:String(p)})}})();return{abort:()=>o.abort(),done:a,traceId:s,events:l}}function ct(e,t,n){switch(e){case"wf:token":return n.onToken?.(t.text);case"wf:tool_call":return n.onToolCall?.(t);case"wf:tool_result":return n.onToolResult?.(t);case"wf:tool_progress":return n.onToolProgress?.(t);case"wf:step":return n.onStep?.(t);case"wf:approval_request":return n.onApproval?.(t);case"wf:usage":return n.onUsage?.(t);case"wf:done":return n.onDone?.(t);case"wf:error":return n.onError?.(t);default:return n.onEvent?.(e,t)}}async function*ft(e){let t=e.getReader(),n=new TextDecoder,o="";try{for(;;){let{done:r,value:s}=await t.read();if(r)break;o+=n.decode(s,{stream:!0});let i=o.split(`
2
2
 
3
- `);o=i.pop()??"";for(let u of i){let a="message",l="";for(let f of u.split(`
4
- `))f.startsWith("event: ")?a=f.slice(7):f.startsWith("data: ")&&(l+=f.slice(6));if(l)try{yield{name:a,data:JSON.parse(l)}}catch{}}}}finally{t.releaseLock()}}function ft(e,t,n){n&&(e.length>=1e3&&e.shift(),e.push(t))}function dt(e){return e===401||e===403?"auth_failed":e===429?"rate_limited":e>=500?"provider_error":"invalid_request"}function pt(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`trace-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function Pe(e){return e.map(t=>({role:t.role,content:t.content}))}function de(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`msg-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function We(e,t,n){n.initialMessages?e.messages=structuredClone(n.initialMessages):e.messages===void 0&&(e.messages=[]),e.input===void 0&&(e.input=""),e.streaming===void 0&&(e.streaming=!1),e.error===void 0&&(e.error=null),e.usage===void 0&&(e.usage=null),e.step===void 0&&(e.step=null);let o=null;function r(){if(!e.streaming)return;let d=e.messages[e.messages.length-1];return d&&d.role==="assistant"&&d.status==="streaming"?d:void 0}function s(d,c,p){let g=r();switch(d){case"wf:token":g&&(g.content+=c.text);break;case"wf:tool_call":{g&&(g.toolCalls||(g.toolCalls=[]),g.toolCalls.push({call:c,status:"running"}));break}case"wf:tool_progress":{let h=c,x=g?.toolCalls?.find(v=>v.call.id===h.toolCallId);x&&(x.progress=h);break}case"wf:tool_result":{let h=c,x=g?.toolCalls?.find(v=>v.call.id===h.id);x&&(x.result=h,x.status=h.ok?"ok":"error");break}case"wf:approval_request":g&&(g.approval=c);break;case"wf:usage":g&&(g.usage=c);break;case"wf:step":e.step=c;break;case"wf:done":g&&(g.status="done",g.approval=void 0),e.streaming=!1,e.step=null;break;case"wf:error":g&&(g.status="error",g.error=c,g.approval=void 0),e.error=c,e.streaming=!1,e.step=null;break;default:p?.(d,c);break}}function i(){let d=n.body?n.body(e.messages):{messages:Pe(e.messages)};o=t(n.url,d,{onToken:p=>s("wf:token",{text:p}),onToolCall:p=>s("wf:tool_call",p),onToolProgress:p=>s("wf:tool_progress",p),onToolResult:p=>s("wf:tool_result",p),onApproval:p=>s("wf:approval_request",p),onUsage:p=>s("wf:usage",p),onStep:p=>s("wf:step",p),onDone:p=>s("wf:done",p),onError:p=>s("wf:error",p),onEvent:(p,g)=>s(p,g,n.onEvent)},{signal:n.signal,headers:n.headers}),e.streaming=!0;let c=r();c&&o?.traceId&&(c.id=o.traceId)}function u(){if(e.streaming)return;let d=String(e.input??"").trim();d&&(e.input="",e.error=null,e.usage=null,e.step=null,e.messages.push({id:de(),role:"user",content:d,status:"done"},{id:de(),role:"assistant",content:"",status:"streaming",toolCalls:[]}),i())}function a(){o?.abort(),e.streaming=!1,e.step=null;let d=e.messages[e.messages.length-1];d&&d.role==="assistant"&&d.status==="streaming"&&(!d.content&&(!d.toolCalls||d.toolCalls.length===0)?e.messages.pop():d.status="done")}function l(){if(e.streaming)return;let d=-1;for(let c=e.messages.length-1;c>=0;c--)if(e.messages[c].role==="user"){d=c;break}d!==-1&&(e.messages.splice(d+1),e.error=null,e.usage=null,e.step=null,e.messages.push({id:de(),role:"assistant",content:"",status:"streaming",toolCalls:[]}),i())}function f(){o?.abort(),e.messages=[],e.input="",e.streaming=!1,e.error=null,e.usage=null,e.step=null}async function m(d,c){let p=e.messages[e.messages.length-1],g=p?.role==="assistant"?p.approval:void 0;if(g&&(p.approval=void 0,!!n.approveUrl))try{await fetch(n.approveUrl,{method:"POST",headers:{"Content-Type":"application/json",...n.headers},body:JSON.stringify({id:g.id,decision:d,note:c}),signal:n.signal})}catch(h){if(n.signal?.aborted)return;e.error={code:"provider_error",message:h instanceof Error?h.message:String(h)}}}function y(){o?.abort(),o=null}return{send:u,stop:a,retry:l,clear:f,approve:m,dispose:y}}function Me(e,t="bottom",n=6,o=!0){switch(t){case"bottom":return{top:e.bottom+n,left:o?e.left+e.width/2:e.left};case"top":return{top:e.top-n,left:o?e.left+e.width/2:e.left};case"left":return{top:o?e.top+e.height/2:e.top,left:e.left-n};case"right":return{top:o?e.top+e.height/2:e.top,left:e.right+n}}}function mt(e,t="bottom",n=6,o=!0){return Me(e.getBoundingClientRect(),t,n,o)}function G(e,t,n=8){if(!t)return e;let o=t.getBoundingClientRect();if(o.width===0&&o.height===0)return e;let r=Number.parseFloat(t.style.top)||o.top,s=Number.parseFloat(t.style.left)||o.left,i=e.top-r,u=e.left-s,a={top:o.top+i,bottom:o.bottom+i,left:o.left+u,right:o.right+u},l=window.innerWidth,f=window.innerHeight,m=e.top,y=e.left;return a.bottom>f-n&&(m=Math.max(n,m-(a.bottom-(f-n)))),a.top<n&&(m=Math.max(n,m+(n-a.top))),a.right>l-n&&(y=Math.max(n,y-(a.right-(l-n)))),a.left<n&&(y=Math.max(n,y+(n-a.left))),{top:m,left:y,width:e.width}}function Le(e){let{ctx:t,renderByIds:n,getSelfId:o,dirtyBatch:r,dirtySet:s,mediaRegistry:i,popupTrackers:u,schedulePopupRecompute:a,ensurePopupListeners:l,isRendering:f}=e;return{_selfId:"_wf_root",_ctxVersion:0,_dirtySet:s,bumpCtxVersion:function(){this._ctxVersion++},render:function(y){if(!y||y.length===0){let d=o(this);if(d)y=[d];else return}n(y)},dirty:function(y){if(!f()){if(!y||y.length===0){let d=o(this);if(d)y=[d];else return}for(let d of y)d&&(r.add(d),s.add(d));this._dirtyScheduled||(this._dirtyScheduled=!0,queueMicrotask(()=>{this._dirtyScheduled=!1;let d=[...r];r.clear(),d.length>0&&n(d)}))}},$:function(){let y=this;if(!y._$cache){let d=o(this);y._$cache=ce(()=>t.ui.dirty(d?[d]:void 0))}return y._$cache},useChat:function(y){let d=this.$(),c=We(d,fe,y);return Object.assign(d,{send:c.send,stop:c.stop,retry:c.retry,clear:c.clear,approve:c.approve,dispose:c.dispose}),d},useMedia:function(y,d){let p=`media:${o(this)}:${y}`;if(!i.has(p)){let g=window.matchMedia(y);d(g.matches);let h=x=>d(x.matches);g.addEventListener("change",h),i.set(p,{mql:g,handler:h})}},useBreakpoint:function(y,d){let c=typeof y=="function"?{mobile:"(max-width: 639px)",tablet:"(min-width: 640px) and (max-width: 1023px)",desktop:"(min-width: 1024px)"}:y,p=typeof y=="function"?y:d,h=`bp:${o(this)}`;function x(){for(let[v,C]of Object.entries(c))if(window.matchMedia(C).matches)return v;return Object.keys(c)[0]??""}if(!i.has(h)){p(x());let v=[];for(let C of Object.values(c)){let b=window.matchMedia(C),w=()=>p(x());b.addEventListener("change",w),v.push({mql:b,handler:w})}i.set(h,{mqls:v})}},usePopupPosition:function(y){let d=o(this),c={top:0,left:0,refresh:()=>{}};if(!d)return c;let p={pos:c,getEl:y.el,isOpen:y.isOpen,compute:y.compute,panel:y.panel,margin:y.margin??8};return u.set(d,p),l(),c.refresh=()=>{let g=p.getEl();if(!g)return;let h=p.compute(g.getBoundingClientRect());Object.assign(c,G(h,p.panel?.(),p.margin))},c},useAsync:function(y){let d=o(this),c=ce(()=>{t.ui&&t.ui.dirty(d?[d]:void 0)});c.loading=!0;let p=()=>{c.loading=!0,c.error=null,Promise.resolve().then(()=>y()).then(g=>{c.data=g,c.loading=!1}).catch(g=>{c.error=g,c.loading=!1})};return p(),c.reload=p,c},selfId:function(y){if(typeof y!="string"||!y)throw new Error(`[weifuwu] selfId requires a non-empty string, got ${typeof y}`);if(A.has(y))throw new Error(`[weifuwu] Duplicate component ID: "${y}". Each component must have a unique custom ID.`);let d=this._selfVNode;d&&(d._customId=y,A.set(y,d))}}}function yt(){let e=[],t={},n=null,o=null,r=null,s=!1,i=new Set,u=!1,a=new Map;function l(C){let b=a.get(C);b&&(b.mql&&b.handler&&b.mql.removeEventListener("change",b.handler),b.mqls?.forEach(({mql:w,handler:N})=>w.removeEventListener("change",N)),a.delete(C))}let f=new Map,m=!1,y=0;function d(){m||(m=!0,window.addEventListener("scroll",p,{capture:!0,passive:!0}),window.addEventListener("resize",p))}function c(){m&&(window.removeEventListener("scroll",p,{capture:!0}),window.removeEventListener("resize",p),m=!1)}function p(){y||(y=requestAnimationFrame(()=>{y=0;let C=[];for(let[b,w]of f){if(!w.isOpen())continue;let N=w.getEl();if(!N)continue;let R=w.compute(N.getBoundingClientRect());Object.assign(w.pos,G(R,w.panel?.(),w.margin)),C.push(b)}C.length>0&&t.ui.render(C)}))}function g(C){if(!s){s=!0;for(let b of C){let w=A.get(b);if(!w||!w._render)continue;t.ui._dirtySet?.delete(b);let N=w._child,R=w._render(w.props);if(w._child=R,N&&N._placement==="remote"||R&&R._placement==="remote"){N&&R?q(N,R,t):R?V(R,t):N&&_(N);continue}if(!w._parentNode&&w._refNode&&(w._parentNode=w._refNode.parentNode),w._parentNode){let E=M(w._parentNode,w._refNode??null,N,R,t);E&&E!==w._refNode?w._refNode=E:E||(w._refNode=null)}}s=!1,h()}}function h(){let C=t.ui;i.size>0&&!C._dirtyScheduled&&(C._dirtyScheduled=!0,queueMicrotask(()=>{C._dirtyScheduled=!1;let b=[...i];i.clear(),b.length>0&&g(b)}))}function x(C){return C?._selfId??t.ui?._selfId}let v={get ctx(){return t},use(C){return e.push(C),v},async mount(C,b,w){o=b;for(let T of e)t=await T(t);let N=typeof C=="string"?document.querySelector(C):C;if(!N)throw new Error(`mount target not found: ${C}`);n=N;let R=!!w?.hydrate;R||(n.innerHTML="");let E=new Map,Z=globalThis.__DATA__;if(Z&&typeof Z=="object")for(let[T,S]of Object.entries(Z))E.set(T,{value:S});if(t.data={async get(T,S){let O=E.get(T);if(O&&"value"in O)return O.value;if(O?.promise)return O.promise;if(!S)return;let ge=Promise.resolve().then(()=>S()).then(he=>(E.set(T,{value:he}),he));return E.set(T,{promise:ge}),ge},set(T,S){E.set(T,{value:S})},has(T){return E.has(T)}},we(T=>{for(let S of[...a.keys()])(S.startsWith(`media:${T}:`)||S===`bp:${T}`)&&l(S);f.delete(T)}),t.ui=Le({ctx:t,renderByIds:g,getSelfId:x,dirtyBatch:i,dirtySet:new Set,mediaRegistry:a,popupTrackers:f,schedulePopupRecompute:p,ensurePopupListeners:d,destroyPopupListeners:c,isRendering:()=>s}),s=!0,r=gt(b,t),r._id="_wf_root",r._parentNode=n,r._refNode=R?n.firstChild:null,A.set("_wf_root",r),R)await ue(n,r,t);else{let T=Se(r,t);T instanceof Node&&n.appendChild(T)}r._refNode=n.firstChild,s=!1,h()},destroy(){c(),f.clear();for(let C of[...a.keys()])l(C);A.clear(),n&&(n.innerHTML=""),n=null,t={}}};return v}function gt(e,t){return{type:e,props:{},key:void 0}}function ht(e,t){if(!t||t==="/")return e||"/";let n=e.endsWith("/")?e.slice(0,-1):e,o=t.startsWith("/")?t:"/"+t;return n+o}function Ct(e){let t=[],n=e.replace(/:(\w+)/g,(o,r)=>(t.push(r),"([^/]+)")).replace(/\*/g,".*");return{re:new RegExp(`^${n}$`),keys:t}}function pe(e,t="",n=[]){let o=[];for(let r of e){let s=ht(t,r.path),{re:i,keys:u}=Ct(s),a=[...n,r];o.push({re:i,keys:u,def:r,chain:a}),r.children&&o.push(...pe(r.children,s,a))}return o}function Ve(e,t){let n=null;for(let o of t)e.match(o.re)&&(!n||o.chain.length>n.chain.length)&&(n=o);return n}function Oe(e,t){let n={},o=e.match(t.re);if(o)for(let r=0;r<t.keys.length;r++)n[t.keys[r]]=decodeURIComponent(o[r+1]);return n}function xt(e){let t=pe(e.routes),n=e.mode||"history";function o(){return n==="hash"?window.location.hash.replace(/^#/,"")||"/":window.location.pathname}function r(s){let i=Ve(s,t);if(i){let u=i.chain[i.chain.length-1];return{path:i.def.path,params:Oe(s,i),query:Object.fromEntries(new URLSearchParams(window.location.search)),chain:i.chain,title:u?.title??""}}return{path:s,params:{},query:Object.fromEntries(new URLSearchParams(window.location.search)),chain:e.notFound?[{component:e.notFound,title:"Not Found"}]:[],title:""}}return s=>{let i=r(o());s.route=i,i.title&&(document.title=i.title),s.app||(s.app={}),s.app.navigate=a=>{if(U(),n==="hash"){window.location.hash="#"+a;let l=r(a);s.route=l}else{window.history.pushState({},"",a);let l=r(a);s.route=l}s.route?.title&&(document.title=s.route.title),s.ui?.bumpCtxVersion?.(),s.ui?.render()};let u=()=>{U();let a=r(o());s.route=a,s.route?.title&&(document.title=s.route.title),s.ui?.bumpCtxVersion?.(),s.ui?.render()};return window.addEventListener("popstate",u),n==="hash"&&window.addEventListener("hashchange",u),s}}function wt(e,t){let n=t.route?._rvDepth??0;return()=>{let o=t.route;if(!o?.chain?.length||n>=o.chain.length)return null;let r=o.chain[n],s=r.layout??r.component;return s?(r.layout&&(o._rvDepth=n+1),{type:s,props:{},key:void 0}):null}}function L(e,t){return Object.assign(Object.create(e),t)}function bt(e={}){let t=e.url??"/ws",n=e.reconnectInterval??3e3,o=e.maxReconnect??10,r=e.pingInterval??3e4,s=e.pingTimeout??1e4;return i=>{let u=new Set,a=null,l=0,f=null,m=null,y=null,d=!1,c={isConnected:!1,onMessage:v=>(u.add(v),()=>{u.delete(v)}),send:v=>{a?.readyState===WebSocket.OPEN&&a.send(JSON.stringify(v))},_connect:p,close:()=>{d=!0,x(),a?.close(),a=null,c.isConnected=!1}};async function p(){if(!d)try{a=new WebSocket(t),a.onopen=()=>{c.isConnected=!0,l=0,g()},a.onmessage=v=>{try{let C=JSON.parse(v.data);for(let b of u)b(C)}catch{}h()},a.onclose=()=>{c.isConnected=!1,x(),!d&&l<o&&(l++,f=setTimeout(p,n*Math.min(l,5)))},a.onerror=()=>{a?.close()}}catch{d||(f=setTimeout(p,n))}}function g(){r<=0||(m=setInterval(()=>{a?.readyState===WebSocket.OPEN&&a.send(JSON.stringify({type:"ping"})),y=setTimeout(()=>{a?.close()},s)},r))}function h(){clearTimeout(y)}function x(){clearInterval(m),clearTimeout(y),clearTimeout(f)}return p(),L(i,{ws:c})}}function vt(e){let t={baseURL:e?.baseURL??"",headers:{"Content-Type":"application/json",...e?.headers}},n=e?.onRequest,o=e?.onResponse,r=e?.timeout??0;async function s(i,u,a,l){let f=t.baseURL+u,m={method:i,headers:{...t.headers,...l?.headers}},y=e?.token?.();y&&!m.headers.Authorization&&(m.headers.Authorization=`Bearer ${y}`);let d=r>0,c=!!l?.signal,p=null,g=null;(d||c)&&(p=new AbortController,m.signal=p.signal,d&&(g=setTimeout(()=>p.abort(new Error("Request timed out")),r)),c&&l.signal.addEventListener("abort",()=>p.abort())),a!==void 0&&i!=="GET"&&i!=="HEAD"&&(m.body=JSON.stringify(a));let h={url:f,init:m};n&&(h=n(h));try{let x=await fetch(h.url,h.init);if(o)return o(x);if(!x.ok){let b=await x.text().catch(()=>"");throw new J(x.status,b||x.statusText)}let v=x.headers.get("content-length");if(x.status===204||v==="0")return;let C=(x.headers.get("content-type")||"").toLowerCase();return C.includes("application/json")||C.includes("json")?x.json():x.text()}finally{g&&clearTimeout(g)}}return i=>L(i,{api:{get:(a,l)=>s("GET",a,void 0,l),post:(a,l,f)=>s("POST",a,l,f),put:(a,l,f)=>s("PUT",a,l,f),patch:(a,l,f)=>s("PATCH",a,l,f),delete:(a,l)=>s("DELETE",a,void 0,l)}})}var J=class extends Error{status;body;constructor(t,n){super(`API Error ${t}: ${n}`),this.name="ApiError",this.status=t,this.body=n}};function Tt(e){try{let t=e.split(".");if(t.length!==3)return null;let n=t[1].replace(/-/g,"+").replace(/_/g,"/");return JSON.parse(atob(n))}catch{return null}}function _t(e){let t=Tt(e);return t?.exp?t.exp*1e3-3e4<Date.now():!0}function At(e){let t=e?.storage??localStorage,n=e?.tokenKey??"weifuwu_token",o=e?.userKey??"weifuwu_user",r=e?.refreshTokenKey??"weifuwu_refresh",s=e?.refreshEndpoint??"/api/auth/refresh";return i=>{let u=t.getItem(n),a=t.getItem(o),l={token:u,user:a?JSON.parse(a):null,get isLoggedIn(){return this.token!==null},login(f,m,y){l.token=f,l.user=m,t.setItem(n,f),t.setItem(o,JSON.stringify(m)),y&&t.setItem(r,y)},logout(){l.token=null,l.user=null,t.removeItem(n),t.removeItem(o),t.removeItem(r)},setUser(f){l.user=f,t.setItem(o,JSON.stringify(f))},async refresh(){let f=t.getItem(r);if(!f)return!1;try{let m=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:f})});if(!m.ok)return l.logout(),!1;let y=await m.json();return l.token=y.token,t.setItem(n,y.token),y.refreshToken&&t.setItem(r,y.refreshToken),!0}catch{return!1}}};return u&&_t(u)&&l.refresh().catch(()=>{}),L(i,{auth:l})}}function Nt(e,t){let n=null;return o=>{if(n){let s=o.fallback;return typeof s=="function"?s({error:n}):s??null}t.ui._errorHandler=s=>{n=s,t.ui.render()};let r=o.children;try{return r??null}catch(s){n=s;let i=o.fallback;return typeof i=="function"?i({error:s}):i??null}}}var me={components:{Button:{loading:"\u52A0\u8F7D\u4E2D..."},FileUpload:{placeholder:"\u70B9\u51FB\u6216\u62D6\u62FD\u4E0A\u4F20\u6587\u4EF6",supportedFormats:"\u652F\u6301\u683C\u5F0F: ",maxSize:"\u6700\u5927 ",remove:"\u5220\u9664"},Pagination:{ariaLabel:"\u5206\u9875"},ProgressBar:{ariaLabel:"\u8FDB\u5EA6"},Switch:{ariaLabel:"\u5207\u6362"},Breadcrumb:{ariaLabel:"\u9762\u5305\u5C51"},Modal:{ariaLabel:"\u5F39\u7A97"},Confirm:{confirmText:"\u786E\u5B9A",cancelText:"\u53D6\u6D88"},Drawer:{ariaLabel:"\u4FA7\u8FB9\u9762\u677F"},DatePicker:{w0:"\u65E5",w1:"\u4E00",w2:"\u4E8C",w3:"\u4E09",w4:"\u56DB",w5:"\u4E94",w6:"\u516D",hour:"\u65F6",minute:"\u5206",time:"\u65F6\u95F4",confirm:"\u786E\u5B9A",cancel:"\u53D6\u6D88",placeholder:"\u9009\u62E9\u65E5\u671F"}}};var ye={components:{Button:{loading:"Loading..."},FileUpload:{placeholder:"Click or drag to upload",supportedFormats:"Supported formats: ",maxSize:"Max size: ",remove:"Remove"},Pagination:{ariaLabel:"Pagination"},ProgressBar:{ariaLabel:"Progress"},Switch:{ariaLabel:"Toggle"},Breadcrumb:{ariaLabel:"Breadcrumb"},Modal:{ariaLabel:"Dialog"},Confirm:{confirmText:"OK",cancelText:"Cancel"},Drawer:{ariaLabel:"Panel"},DatePicker:{w0:"Su",w1:"Mo",w2:"Tu",w3:"We",w4:"Th",w5:"Fr",w6:"Sa",hour:"Hour",minute:"Min",time:"Time",confirm:"OK",cancel:"Cancel",placeholder:"Pick a date"}}};var Q={"zh-CN":me,"en-US":ye};function Ie(e){if(Q[e])return e;let t=e.split("-")[0];return Object.keys(Q).find(o=>o.startsWith(t))??"zh-CN"}function Rt(e={}){let{locale:t="zh-CN",messages:n={},components:o={}}=e,r=Ie(t),s=Q[r],i=Ue(s,n,o),u={locale:r,t:(a,l)=>i.messages?.[a]??l??a,setLocale:()=>{},components:i.components};return a=>(a.i18n=u,u.setLocale=l=>{let f=Ie(l),m=Q[f];m&&(i=Ue(m,n,o),u.locale=f,u.components=i.components,a?.ui?.bumpCtxVersion?.(),a?.ui?.render())},a)}function Ue(e,t,n){return{messages:{...e?.messages,...t},components:kt(e?.components??{},n)}}function kt(e,t){let n={...e};for(let o of Object.keys(t))typeof t[o]=="object"&&t[o]!==null&&typeof n[o]=="object"?n[o]={...n[o],...t[o]}:n[o]=t[o];return n}var Y=0,je="",He="",De="",qe="",X=0;function Fe(){return typeof window<"u"&&typeof document<"u"}function Et(){if(Y++,Y>1||!Fe())return;X=window.scrollY;let e=document.body;je=e.style.overflow,He=e.style.position,De=e.style.top,qe=e.style.width,e.style.overflow="hidden",(/iPhone|iPad|iPod/.test(navigator.platform)||/Mac/.test(navigator.platform)&&"ontouchend"in document)&&(e.style.position="fixed",e.style.top=`-${X}px`,e.style.width="100%")}function St(){if(Y--,Y>0||!Fe())return;let e=document.body;e.style.overflow=je,e.style.position=He,e.style.top=De,e.style.width=qe,X>0&&window.scrollTo(0,X)}var Pt='a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function Wt(e){let t=e.querySelectorAll(Pt);if(t.length===0)return()=>{};let n=t[0],o=t[t.length-1],r=i=>{i.key==="Tab"&&(i.shiftKey&&document.activeElement===n?(i.preventDefault(),o.focus()):!i.shiftKey&&document.activeElement===o&&(i.preventDefault(),n.focus()))},s=document.activeElement;return queueMicrotask(()=>{n.focus()}),e.addEventListener("keydown",r),()=>{e.removeEventListener("keydown",r),s?.focus()}}function Mt(e,t,n=400){let o=!1,r=()=>{o||(o=!0,e.removeEventListener("animationend",r),clearTimeout(s),t())};e.addEventListener("animationend",r);let s=setTimeout(r,n)}export{J as ApiError,Nt as ErrorBoundary,W as Fragment,P as Portal,wt as RouteView,fe as aiStream,Mt as animateOut,vt as api,$e as asyncComponent,At as auth,_ as callRefCleanup,U as clearAsyncComponentCache,mt as computeFixedPos,Me as computeFixedPosRect,yt as createApp,Ge as createPortal,ye as enUS,L as extendCtx,ze as h,ue as hydrateVNode,Rt as i18n,I as isAsyncComponent,ee as jsx,Ke as jsxDEV,Be as jsxs,Et as lockScroll,st as mountVNode,M as patchValue,xt as router,Pe as toChatMessages,Wt as trapFocus,St as unlockScroll,bt as ws,me as zhCN};
3
+ `);o=i.pop()??"";for(let l of i){let a="message",u="";for(let p of l.split(`
4
+ `))p.startsWith("event: ")?a=p.slice(7):p.startsWith("data: ")&&(u+=p.slice(6));if(u)try{yield{name:a,data:JSON.parse(u)}}catch{}}}}finally{t.releaseLock()}}function dt(e,t,n){n&&(e.length>=1e3&&e.shift(),e.push(t))}function pt(e){return e===401||e===403?"auth_failed":e===429?"rate_limited":e>=500?"provider_error":"invalid_request"}function mt(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`trace-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function We(e){return e.map(t=>({role:t.role,content:t.content}))}function pe(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`msg-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function Me(e,t,n){n.initialMessages?e.messages=structuredClone(n.initialMessages):e.messages===void 0&&(e.messages=[]),e.input===void 0&&(e.input=""),e.streaming===void 0&&(e.streaming=!1),e.error===void 0&&(e.error=null),e.usage===void 0&&(e.usage=null),e.step===void 0&&(e.step=null);let o=null;function r(){if(!e.streaming)return;let d=e.messages[e.messages.length-1];return d&&d.role==="assistant"&&d.status==="streaming"?d:void 0}function s(d,c,f){let y=r();switch(d){case"wf:token":y&&(y.content+=c.text);break;case"wf:tool_call":{y&&(y.toolCalls||(y.toolCalls=[]),y.toolCalls.push({call:c,status:"running"}));break}case"wf:tool_progress":{let g=c,h=y?.toolCalls?.find(b=>b.call.id===g.toolCallId);h&&(h.progress=g);break}case"wf:tool_result":{let g=c,h=y?.toolCalls?.find(b=>b.call.id===g.id);h&&(h.result=g,h.status=g.ok?"ok":"error");break}case"wf:approval_request":y&&(y.approval=c);break;case"wf:usage":y&&(y.usage=c);break;case"wf:step":e.step=c;break;case"wf:done":y&&(y.status="done",y.approval=void 0),e.streaming=!1,e.step=null;break;case"wf:error":y&&(y.status="error",y.error=c,y.approval=void 0),e.error=c,e.streaming=!1,e.step=null;break;default:f?.(d,c);break}}function i(){let d=n.body?n.body(e.messages):{messages:We(e.messages)};o=t(n.url,d,{onToken:f=>s("wf:token",{text:f}),onToolCall:f=>s("wf:tool_call",f),onToolProgress:f=>s("wf:tool_progress",f),onToolResult:f=>s("wf:tool_result",f),onApproval:f=>s("wf:approval_request",f),onUsage:f=>s("wf:usage",f),onStep:f=>s("wf:step",f),onDone:f=>s("wf:done",f),onError:f=>s("wf:error",f),onEvent:(f,y)=>s(f,y,n.onEvent)},{signal:n.signal,headers:n.headers}),e.streaming=!0;let c=r();c&&o?.traceId&&(c.id=o.traceId)}function l(){if(e.streaming)return;let d=String(e.input??"").trim();d&&(e.input="",e.error=null,e.usage=null,e.step=null,e.messages.push({id:pe(),role:"user",content:d,status:"done"},{id:pe(),role:"assistant",content:"",status:"streaming",toolCalls:[]}),i())}function a(){o?.abort(),e.streaming=!1,e.step=null;let d=e.messages[e.messages.length-1];d&&d.role==="assistant"&&d.status==="streaming"&&(!d.content&&(!d.toolCalls||d.toolCalls.length===0)?e.messages.pop():d.status="done")}function u(){if(e.streaming)return;let d=-1;for(let c=e.messages.length-1;c>=0;c--)if(e.messages[c].role==="user"){d=c;break}d!==-1&&(e.messages.splice(d+1),e.error=null,e.usage=null,e.step=null,e.messages.push({id:pe(),role:"assistant",content:"",status:"streaming",toolCalls:[]}),i())}function p(){o?.abort(),e.messages=[],e.input="",e.streaming=!1,e.error=null,e.usage=null,e.step=null}async function m(d,c){let f=e.messages[e.messages.length-1],y=f?.role==="assistant"?f.approval:void 0;if(y&&(f.approval=void 0,!!n.approveUrl))try{await fetch(n.approveUrl,{method:"POST",headers:{"Content-Type":"application/json",...n.headers},body:JSON.stringify({id:y.id,decision:d,note:c}),signal:n.signal})}catch(g){if(n.signal?.aborted)return;e.error={code:"provider_error",message:g instanceof Error?g.message:String(g)}}}function w(){o?.abort(),o=null}return{send:l,stop:a,retry:u,clear:p,approve:m,dispose:w}}function Le(e,t="bottom",n=6,o=!0){switch(t){case"bottom":return{top:e.bottom+n,left:o?e.left+e.width/2:e.left};case"top":return{top:e.top-n,left:o?e.left+e.width/2:e.left};case"left":return{top:o?e.top+e.height/2:e.top,left:e.left-n};case"right":return{top:o?e.top+e.height/2:e.top,left:e.right+n}}}function yt(e,t="bottom",n=6,o=!0){return Le(e.getBoundingClientRect(),t,n,o)}function Q(e,t,n=8){if(!t)return e;let o=t.getBoundingClientRect();if(o.width===0&&o.height===0)return e;let r=Number.parseFloat(t.style.top)||o.top,s=Number.parseFloat(t.style.left)||o.left,i=e.top-r,l=e.left-s,a={top:o.top+i,bottom:o.bottom+i,left:o.left+l,right:o.right+l},u=window.innerWidth,p=window.innerHeight,m=e.top,w=e.left;return a.bottom>p-n&&(m=Math.max(n,m-(a.bottom-(p-n)))),a.top<n&&(m=Math.max(n,m+(n-a.top))),a.right>u-n&&(w=Math.max(n,w-(a.right-(u-n)))),a.left<n&&(w=Math.max(n,w+(n-a.left))),{top:m,left:w,width:e.width}}function Ie(e){let{ctx:t,renderByIds:n,getSelfId:o,dirtyBatch:r,dirtySet:s,mediaRegistry:i,popupTrackers:l,scrollTrackers:a,schedulePopupRecompute:u,ensurePopupListeners:p,isRendering:m}=e;return{_selfId:"_wf_root",_ctxVersion:0,_dirtySet:s,bumpCtxVersion:function(){this._ctxVersion++},render:function(d){if(!d||d.length===0){let c=o(this);if(c)d=[c];else return}n(d)},dirty:function(d){if(!m()){if(!d||d.length===0){let c=o(this);if(c)d=[c];else return}for(let c of d)c&&(r.add(c),s.add(c));this._dirtyScheduled||(this._dirtyScheduled=!0,queueMicrotask(()=>{this._dirtyScheduled=!1;let c=[...r];r.clear(),c.length>0&&n(c)}))}},$:function(){let d=this;if(!d._$cache){let c=o(this);d._$cache=fe(()=>t.ui.dirty(c?[c]:void 0))}return d._$cache},useChat:function(d){let c=this.$(),f=Me(c,de,d);return Object.assign(c,{send:f.send,stop:f.stop,retry:f.retry,clear:f.clear,approve:f.approve,dispose:f.dispose}),c},useMedia:function(d,c){let y=`media:${o(this)}:${d}`;if(!i.has(y)){let g=window.matchMedia(d);c(g.matches);let h=b=>c(b.matches);g.addEventListener("change",h),i.set(y,{mql:g,handler:h})}},useBreakpoint:function(d,c){let f=typeof d=="function"?{mobile:"(max-width: 639px)",tablet:"(min-width: 640px) and (max-width: 1023px)",desktop:"(min-width: 1024px)"}:d,y=typeof d=="function"?d:c,h=`bp:${o(this)}`;function b(){for(let[A,x]of Object.entries(f))if(window.matchMedia(x).matches)return A;return Object.keys(f)[0]??""}if(!i.has(h)){y(b());let A=[];for(let x of Object.values(f)){let v=window.matchMedia(x),C=()=>y(b());v.addEventListener("change",C),A.push({mql:v,handler:C})}i.set(h,{mqls:A})}},usePopupPosition:function(d){let c=o(this),f={top:0,left:0,refresh:()=>{}};if(!c)return f;let y={pos:f,getEl:d.el,isOpen:d.isOpen,compute:d.compute,panel:d.panel,margin:d.margin??8};return l.set(c,y),p(),f.refresh=()=>{let g=y.getEl();if(!g)return;let h=y.compute(g.getBoundingClientRect());Object.assign(f,Q(h,y.panel?.(),y.margin))},f},useInView:function(d){let c=o(this),f={isIn:!1,ready:!1,observe:A,refresh:x,disconnect:v},y=null,g=null,h=()=>{t.ui&&t.ui.dirty(c?[c]:void 0)};function b(){if(g?.disconnect(),g=null,!y)return;let C=typeof d.rootMargin=="function"?d.rootMargin():d.rootMargin,T=typeof d.threshold=="function"?d.threshold():d.threshold;g=new IntersectionObserver(S=>{let k=S[S.length-1];if(!k)return;let L=k.isIntersecting,_=L!==f.isIn,P=!f.ready;f.isIn=L,f.ready=!0,d.onChange?.(k,L),(_||P)&&h()},{root:d.root?d.root():null,rootMargin:C??"0px",threshold:T??0}),g.observe(y)}function A(C){y=C,C?b():(g?.disconnect(),g=null,f.isIn=!1)}function x(){b()}function v(){g?.disconnect(),g=null}return f},useScrollPosition:function(d){let c=o(this),f={y:0,refresh(){let g=y.getScroller();f.y=g instanceof Window?document.scrollingElement?.scrollTop??g.scrollY??0:g.scrollTop??0}},y={handle:f,getScroller:d.getScroller??(()=>window)};return c?(a.set(c,y),p(),f.refresh(),f):(f.refresh(),f)},useAsync:function(d){let c=o(this),f=fe(()=>{t.ui&&t.ui.dirty(c?[c]:void 0)});f.loading=!0;let y=()=>{f.loading=!0,f.error=null,Promise.resolve().then(()=>d()).then(g=>{f.data=g,f.loading=!1}).catch(g=>{f.error=g,f.loading=!1})};return y(),f.reload=y,f},selfId:function(d){if(typeof d!="string"||!d)throw new Error(`[weifuwu] selfId requires a non-empty string, got ${typeof d}`);if(N.has(d))throw new Error(`[weifuwu] Duplicate component ID: "${d}". Each component must have a unique custom ID.`);let c=this._selfVNode;c&&(c._customId=d,N.set(d,c))}}}function gt(){let e=[],t={},n=null,o=null,r=null,s=!1,i=new Set,l=!1,a=new Map;function u(x){let v=a.get(x);v&&(v.mql&&v.handler&&v.mql.removeEventListener("change",v.handler),v.mqls?.forEach(({mql:C,handler:T})=>C.removeEventListener("change",T)),a.delete(x))}let p=new Map,m=!1,w=0;function d(){m||(m=!0,window.addEventListener("scroll",y,{capture:!0,passive:!0}),window.addEventListener("resize",y))}function c(){m&&(window.removeEventListener("scroll",y,{capture:!0}),window.removeEventListener("resize",y),m=!1)}let f=new Map;function y(){w||(w=requestAnimationFrame(()=>{w=0;let x=[];for(let[v,C]of p){if(!C.isOpen())continue;let T=C.getEl();if(!T)continue;let S=C.compute(T.getBoundingClientRect());Object.assign(C.pos,Q(S,C.panel?.(),C.margin)),x.push(v)}for(let[v,C]of f){let T=C.getScroller(),S=T instanceof Window?document.scrollingElement?.scrollTop??T.scrollY??0:T.scrollTop??0;S!==C.handle.y&&(C.handle.y=S,x.push(v))}x.length>0&&t.ui.render(x)}))}function g(x){if(!s){s=!0;for(let v of x){let C=N.get(v);if(!C||!C._render)continue;t.ui._dirtySet?.delete(v);let T=C._child,S=C._render(C.props);if(C._child=S,T&&T._placement==="remote"||S&&S._placement==="remote"){T&&S?$(T,S,t):S?O(S,t):T&&E(T);continue}if(!C._parentNode&&C._refNode&&(C._parentNode=C._refNode.parentNode),C._parentNode){let k=I(C._parentNode,C._refNode??null,T,S,t);k&&k!==C._refNode?C._refNode=k:k||(C._refNode=null)}}s=!1,h()}}function h(){let x=t.ui;i.size>0&&!x._dirtyScheduled&&(x._dirtyScheduled=!0,queueMicrotask(()=>{x._dirtyScheduled=!1;let v=[...i];i.clear(),v.length>0&&g(v)}))}function b(x){return x?._selfId??t.ui?._selfId}let A={get ctx(){return t},use(x){return e.push(x),A},async mount(x,v,C){o=v;for(let _ of e)t=await _(t);let T=typeof x=="string"?document.querySelector(x):x;if(!T)throw new Error(`mount target not found: ${x}`);n=T;let S=!!C?.hydrate;S||(n.innerHTML="");let k=new Map,L=globalThis.__DATA__;if(L&&typeof L=="object")for(let[_,P]of Object.entries(L))k.set(_,{value:P});if(t.data={async get(_,P){let U=k.get(_);if(U&&"value"in U)return U.value;if(U?.promise)return U.promise;if(!P)return;let he=Promise.resolve().then(()=>P()).then(Ce=>(k.set(_,{value:Ce}),Ce));return k.set(_,{promise:he}),he},set(_,P){k.set(_,{value:P})},has(_){return k.has(_)}},be(_=>{for(let P of[...a.keys()])(P.startsWith(`media:${_}:`)||P===`bp:${_}`)&&u(P);p.delete(_),f.delete(_)}),t.ui=Ie({ctx:t,renderByIds:g,getSelfId:b,dirtyBatch:i,dirtySet:new Set,mediaRegistry:a,popupTrackers:p,scrollTrackers:f,schedulePopupRecompute:y,ensurePopupListeners:d,destroyPopupListeners:c,isRendering:()=>s}),s=!0,r=ht(v,t),r._id="_wf_root",r._parentNode=n,r._refNode=S?n.firstChild:null,N.set("_wf_root",r),S)await ce(n,r,t);else{let _=Pe(r,t);_ instanceof Node&&n.appendChild(_)}r._refNode=n.firstChild,s=!1,h()},destroy(){c(),p.clear(),f.clear();for(let x of[...a.keys()])u(x);N.clear(),n&&(n.innerHTML=""),n=null,t={}}};return A}function ht(e,t){return{type:e,props:{},key:void 0}}function Ct(e,t){if(!t||t==="/")return e||"/";let n=e.endsWith("/")?e.slice(0,-1):e,o=t.startsWith("/")?t:"/"+t;return n+o}function xt(e){let t=[],n=e.replace(/:(\w+)/g,(o,r)=>(t.push(r),"([^/]+)")).replace(/\*/g,".*");return{re:new RegExp(`^${n}$`),keys:t}}function me(e,t="",n=[]){let o=[];for(let r of e){let s=Ct(t,r.path),{re:i,keys:l}=xt(s),a=[...n,r];o.push({re:i,keys:l,def:r,chain:a}),r.children&&o.push(...me(r.children,s,a))}return o}function Ve(e,t){let n=null;for(let o of t)e.match(o.re)&&(!n||o.chain.length>n.chain.length)&&(n=o);return n}function Oe(e,t){let n={},o=e.match(t.re);if(o)for(let r=0;r<t.keys.length;r++)n[t.keys[r]]=decodeURIComponent(o[r+1]);return n}function wt(e){let t=me(e.routes),n=e.mode||"history";function o(){return n==="hash"?window.location.hash.replace(/^#/,"")||"/":window.location.pathname}function r(s){let i=Ve(s,t);if(i){let l=i.chain[i.chain.length-1];return{path:i.def.path,params:Oe(s,i),query:Object.fromEntries(new URLSearchParams(window.location.search)),chain:i.chain,title:l?.title??""}}return{path:s,params:{},query:Object.fromEntries(new URLSearchParams(window.location.search)),chain:e.notFound?[{component:e.notFound,title:"Not Found"}]:[],title:""}}return s=>{let i=r(o());s.route=i,i.title&&(document.title=i.title),s.app||(s.app={}),s.app.navigate=a=>{if(j(),n==="hash"){window.location.hash="#"+a;let u=r(a);s.route=u}else{window.history.pushState({},"",a);let u=r(a);s.route=u}s.route?.title&&(document.title=s.route.title),s.ui?.bumpCtxVersion?.(),s.ui?.render()};let l=()=>{j();let a=r(o());s.route=a,s.route?.title&&(document.title=s.route.title),s.ui?.bumpCtxVersion?.(),s.ui?.render()};return window.addEventListener("popstate",l),n==="hash"&&window.addEventListener("hashchange",l),s}}function bt(e,t){let n=t.route?._rvDepth??0;return()=>{let o=t.route;if(!o?.chain?.length||n>=o.chain.length)return null;let r=o.chain[n],s=r.layout??r.component;return s?(r.layout&&(o._rvDepth=n+1),{type:s,props:{},key:void 0}):null}}function V(e,t){return Object.assign(Object.create(e),t)}function vt(e={}){let t=e.url??"/ws",n=e.reconnectInterval??3e3,o=e.maxReconnect??10,r=e.pingInterval??3e4,s=e.pingTimeout??1e4;return i=>{let l=new Set,a=null,u=0,p=null,m=null,w=null,d=!1,c={isConnected:!1,onMessage:b=>(l.add(b),()=>{l.delete(b)}),send:b=>{a?.readyState===WebSocket.OPEN&&a.send(JSON.stringify(b))},_connect:f,close:()=>{d=!0,h(),a?.close(),a=null,c.isConnected=!1}};async function f(){if(!d)try{a=new WebSocket(t),a.onopen=()=>{c.isConnected=!0,u=0,y()},a.onmessage=b=>{try{let A=JSON.parse(b.data);for(let x of l)x(A)}catch{}g()},a.onclose=()=>{c.isConnected=!1,h(),!d&&u<o&&(u++,p=setTimeout(f,n*Math.min(u,5)))},a.onerror=()=>{a?.close()}}catch{d||(p=setTimeout(f,n))}}function y(){r<=0||(m=setInterval(()=>{a?.readyState===WebSocket.OPEN&&a.send(JSON.stringify({type:"ping"})),w=setTimeout(()=>{a?.close()},s)},r))}function g(){clearTimeout(w)}function h(){clearInterval(m),clearTimeout(w),clearTimeout(p)}return f(),V(i,{ws:c})}}function Tt(e){let t={baseURL:e?.baseURL??"",headers:{"Content-Type":"application/json",...e?.headers}},n=e?.onRequest,o=e?.onResponse,r=e?.timeout??0;async function s(i,l,a,u){let p=t.baseURL+l,m={method:i,headers:{...t.headers,...u?.headers}},w=e?.token?.();w&&!m.headers.Authorization&&(m.headers.Authorization=`Bearer ${w}`);let d=r>0,c=!!u?.signal,f=null,y=null;(d||c)&&(f=new AbortController,m.signal=f.signal,d&&(y=setTimeout(()=>f.abort(new Error("Request timed out")),r)),c&&u.signal.addEventListener("abort",()=>f.abort())),a!==void 0&&i!=="GET"&&i!=="HEAD"&&(m.body=JSON.stringify(a));let g={url:p,init:m};n&&(g=n(g));try{let h=await fetch(g.url,g.init);if(o)return o(h);if(!h.ok){let x=await h.text().catch(()=>"");throw new Y(h.status,x||h.statusText)}let b=h.headers.get("content-length");if(h.status===204||b==="0")return;let A=(h.headers.get("content-type")||"").toLowerCase();return A.includes("application/json")||A.includes("json")?h.json():h.text()}finally{y&&clearTimeout(y)}}return i=>V(i,{api:{get:(a,u)=>s("GET",a,void 0,u),post:(a,u,p)=>s("POST",a,u,p),put:(a,u,p)=>s("PUT",a,u,p),patch:(a,u,p)=>s("PATCH",a,u,p),delete:(a,u)=>s("DELETE",a,void 0,u)}})}var Y=class extends Error{status;body;constructor(t,n){super(`API Error ${t}: ${n}`),this.name="ApiError",this.status=t,this.body=n}};function _t(e){try{let t=e.split(".");if(t.length!==3)return null;let n=t[1].replace(/-/g,"+").replace(/_/g,"/");return JSON.parse(atob(n))}catch{return null}}function At(e){let t=_t(e);return t?.exp?t.exp*1e3-3e4<Date.now():!0}function St(e){let t=e?.storage??localStorage,n=e?.tokenKey??"weifuwu_token",o=e?.userKey??"weifuwu_user",r=e?.refreshTokenKey??"weifuwu_refresh",s=e?.refreshEndpoint??"/api/auth/refresh";return i=>{let l=t.getItem(n),a=t.getItem(o),u={token:l,user:a?JSON.parse(a):null,get isLoggedIn(){return this.token!==null},login(p,m,w){u.token=p,u.user=m,t.setItem(n,p),t.setItem(o,JSON.stringify(m)),w&&t.setItem(r,w)},logout(){u.token=null,u.user=null,t.removeItem(n),t.removeItem(o),t.removeItem(r)},setUser(p){u.user=p,t.setItem(o,JSON.stringify(p))},async refresh(){let p=t.getItem(r);if(!p)return!1;try{let m=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:p})});if(!m.ok)return u.logout(),!1;let w=await m.json();return u.token=w.token,t.setItem(n,w.token),w.refreshToken&&t.setItem(r,w.refreshToken),!0}catch{return!1}}};return l&&At(l)&&u.refresh().catch(()=>{}),V(i,{auth:u})}}function Et(e,t){let n=null;return o=>{if(n){let s=o.fallback;return typeof s=="function"?s({error:n}):s??null}t.ui._errorHandler=s=>{n=s,t.ui.render()};let r=o.children;try{return r??null}catch(s){n=s;let i=o.fallback;return typeof i=="function"?i({error:s}):i??null}}}var ye={components:{Button:{loading:"\u52A0\u8F7D\u4E2D..."},FileUpload:{placeholder:"\u70B9\u51FB\u6216\u62D6\u62FD\u4E0A\u4F20\u6587\u4EF6",supportedFormats:"\u652F\u6301\u683C\u5F0F: ",maxSize:"\u6700\u5927 ",remove:"\u5220\u9664"},Pagination:{ariaLabel:"\u5206\u9875"},ProgressBar:{ariaLabel:"\u8FDB\u5EA6"},Switch:{ariaLabel:"\u5207\u6362"},Breadcrumb:{ariaLabel:"\u9762\u5305\u5C51"},Modal:{ariaLabel:"\u5F39\u7A97"},Confirm:{confirmText:"\u786E\u5B9A",cancelText:"\u53D6\u6D88"},Drawer:{ariaLabel:"\u4FA7\u8FB9\u9762\u677F"},DatePicker:{w0:"\u65E5",w1:"\u4E00",w2:"\u4E8C",w3:"\u4E09",w4:"\u56DB",w5:"\u4E94",w6:"\u516D",hour:"\u65F6",minute:"\u5206",time:"\u65F6\u95F4",confirm:"\u786E\u5B9A",cancel:"\u53D6\u6D88",placeholder:"\u9009\u62E9\u65E5\u671F"}}};var ge={components:{Button:{loading:"Loading..."},FileUpload:{placeholder:"Click or drag to upload",supportedFormats:"Supported formats: ",maxSize:"Max size: ",remove:"Remove"},Pagination:{ariaLabel:"Pagination"},ProgressBar:{ariaLabel:"Progress"},Switch:{ariaLabel:"Toggle"},Breadcrumb:{ariaLabel:"Breadcrumb"},Modal:{ariaLabel:"Dialog"},Confirm:{confirmText:"OK",cancelText:"Cancel"},Drawer:{ariaLabel:"Panel"},DatePicker:{w0:"Su",w1:"Mo",w2:"Tu",w3:"We",w4:"Th",w5:"Fr",w6:"Sa",hour:"Hour",minute:"Min",time:"Time",confirm:"OK",cancel:"Cancel",placeholder:"Pick a date"}}};var X={"zh-CN":ye,"en-US":ge};function Ue(e){if(X[e])return e;let t=e.split("-")[0];return Object.keys(X).find(o=>o.startsWith(t))??"zh-CN"}function Nt(e={}){let{locale:t="zh-CN",messages:n={},components:o={}}=e,r=Ue(t),s=X[r],i=He(s,n,o),l={locale:r,t:(a,u)=>i.messages?.[a]??u??a,setLocale:()=>{},components:i.components};return a=>(a.i18n=l,l.setLocale=u=>{let p=Ue(u),m=X[p];m&&(i=He(m,n,o),l.locale=p,l.components=i.components,a?.ui?.bumpCtxVersion?.(),a?.ui?.render())},a)}function He(e,t,n){return{messages:{...e?.messages,...t},components:kt(e?.components??{},n)}}function kt(e,t){let n={...e};for(let o of Object.keys(t))typeof t[o]=="object"&&t[o]!==null&&typeof n[o]=="object"?n[o]={...n[o],...t[o]}:n[o]=t[o];return n}var Z=0,je="",De="",qe="",Fe="",ee=0;function $e(){return typeof window<"u"&&typeof document<"u"}function Rt(){if(Z++,Z>1||!$e())return;ee=window.scrollY;let e=document.body;je=e.style.overflow,De=e.style.position,qe=e.style.top,Fe=e.style.width,e.style.overflow="hidden",(/iPhone|iPad|iPod/.test(navigator.platform)||/Mac/.test(navigator.platform)&&"ontouchend"in document)&&(e.style.position="fixed",e.style.top=`-${ee}px`,e.style.width="100%")}function Pt(){if(Z--,Z>0||!$e())return;let e=document.body;e.style.overflow=je,e.style.position=De,e.style.top=qe,e.style.width=Fe,ee>0&&window.scrollTo(0,ee)}var Wt='a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function Mt(e){let t=e.querySelectorAll(Wt);if(t.length===0)return()=>{};let n=t[0],o=t[t.length-1],r=i=>{i.key==="Tab"&&(i.shiftKey&&document.activeElement===n?(i.preventDefault(),o.focus()):!i.shiftKey&&document.activeElement===o&&(i.preventDefault(),n.focus()))},s=document.activeElement;return queueMicrotask(()=>{n.focus()}),e.addEventListener("keydown",r),()=>{e.removeEventListener("keydown",r),s?.focus()}}function Lt(e,t,n=400){let o=!1,r=()=>{o||(o=!0,e.removeEventListener("animationend",r),clearTimeout(s),t())};e.addEventListener("animationend",r);let s=setTimeout(r,n)}export{Y as ApiError,Et as ErrorBoundary,M as Fragment,W as Portal,bt as RouteView,de as aiStream,Lt as animateOut,Tt as api,Be as asyncComponent,St as auth,E as callRefCleanup,j as clearAsyncComponentCache,yt as computeFixedPos,Le as computeFixedPosRect,gt as createApp,Je as createPortal,ge as enUS,V as extendCtx,Ge as h,ce as hydrateVNode,Nt as i18n,H as isAsyncComponent,te as jsx,ze as jsxDEV,Ke as jsxs,Rt as lockScroll,it as mountVNode,I as patchValue,wt as router,We as toChatMessages,Mt as trapFocus,Pt as unlockScroll,vt as ws,ye as zhCN};
@@ -34,6 +34,42 @@ export interface PopupPosition {
34
34
  /** 立即重算一次坐标(不触发渲染,调用方负责 render) */
35
35
  refresh: () => void;
36
36
  }
37
+ /** 可见性观察配置 — 供 ctx.ui.useInView 使用(IntersectionObserver 封装,替代 scroll 监听) */
38
+ export interface UseInViewOptions {
39
+ /** IO 根元素 getter(默认视口;滚动容器场景传 target) */
40
+ root?: () => Element | null;
41
+ /** IO rootMargin(支持函数——动态读最新 props,observe 时求值) */
42
+ rootMargin?: string | (() => string);
43
+ /** IO threshold(默认 0;支持函数——动态读最新 props) */
44
+ threshold?: number | number[] | (() => number | number[]);
45
+ /** IO 触发回调(entry.boundingClientRect 读取安全,非 scroll handler) */
46
+ onChange?: (entry: IntersectionObserverEntry, isIn: boolean) => void;
47
+ }
48
+ /** 可见性观察器 — useInView 的返回值 */
49
+ export interface UseInViewHandle {
50
+ /** 是否在可见区(响应式:变化自动 dirty 当前组件) */
51
+ isIn: boolean;
52
+ /** 是否已就绪(首次 IO 回调完成;未就绪时 isIn 为初始 false,组件应保守处理) */
53
+ ready: boolean;
54
+ /** 观察元素(ref 挂载时调用;传 null 断开) */
55
+ observe(el: HTMLElement | null): void;
56
+ /** 重建观察(rootMargin 等配置变化后调用) */
57
+ refresh(): void;
58
+ /** 手动断开观察 */
59
+ disconnect(): void;
60
+ }
61
+ /** 滚动位置跟踪配置 — 供 ctx.ui.useScrollPosition 使用 */
62
+ export interface UseScrollPositionOptions {
63
+ /** 滚动容器 getter(默认 window;内部滚动容器传 ref 元素) */
64
+ getScroller?: () => HTMLElement | Window;
65
+ }
66
+ /** 滚动位置跟踪器 — useScrollPosition 的返回值(y 响应式,变化自动 dirty 当前组件) */
67
+ export interface UseScrollPositionHandle {
68
+ /** 滚动位置(px,scrollY/scrollTop) */
69
+ y: number;
70
+ /** 手动重读一次滚动位置(不触发渲染) */
71
+ refresh(): void;
72
+ }
37
73
  /** 应用上下文 */
38
74
  export interface WfuiContext {
39
75
  [key: string]: unknown;
@@ -61,6 +97,29 @@ export interface WfuiContext {
61
97
  useBreakpoint: (bpsOrCallback: Record<string, string> | ((vp: string) => void), callback?: (vp: string) => void) => void;
62
98
  /** 弹层位置跟踪:滚动/resize 时自动重算 fixed 坐标 */
63
99
  usePopupPosition: (options: PopupPositionOptions) => PopupPosition;
100
+ /**
101
+ * 可见性观察(IntersectionObserver 封装):替代组件自建 scroll 监听。
102
+ * IO 在合成器线程评估,滚动/尺寸变化自动触发,无 scroll-linked 定位警告。
103
+ *
104
+ * ```tsx
105
+ * const inView = ctx.ui.useInView({
106
+ * rootMargin: () => `-${propsRef.offsetTop ?? 0}px 0px 0px 0px`,
107
+ * })
108
+ * const ref = (el) => inView.observe(el)
109
+ * return () => h('div', { ref }, fixed = !inView.isIn ...)
110
+ * ```
111
+ */
112
+ useInView: (options: UseInViewOptions) => UseInViewHandle;
113
+ /**
114
+ * 滚动位置跟踪(全局 scroll 监听 + rAF 节流,仿 usePopupPosition):
115
+ * 返回响应式 scrollY/scrollTop,变化自动 dirty 当前组件。替代组件自建 scroll 监听。
116
+ *
117
+ * ```tsx
118
+ * const scroll = ctx.ui.useScrollPosition({ getScroller: () => wrapEl })
119
+ * return () => h('div', { ref }, fixed = scroll.y >= threshold)
120
+ * ```
121
+ */
122
+ useScrollPosition: (options: UseScrollPositionOptions) => UseScrollPositionHandle;
64
123
  /**
65
124
  * 异步取数工具(mount 阶段调用):loading/error 自动管理 + 数据就绪自动渲染。
66
125
  *
@@ -46,6 +46,12 @@ export interface UiDeps {
46
46
  width?: number;
47
47
  };
48
48
  }>;
49
+ scrollTrackers: Map<string, {
50
+ handle: {
51
+ y: number;
52
+ };
53
+ getScroller: () => HTMLElement | Window;
54
+ }>;
49
55
  schedulePopupRecompute: () => void;
50
56
  /** 惰性挂载全局 scroll/resize 监听(幂等) */
51
57
  ensurePopupListeners: () => void;
@@ -3,9 +3,18 @@ export interface AccordionItem {
3
3
  key: string;
4
4
  title: string;
5
5
  content?: any;
6
+ disabled?: boolean;
6
7
  }
7
8
  export interface AccordionProps {
8
9
  items?: AccordionItem[];
10
+ /** 受控展开 keys */
11
+ active?: string[];
12
+ onChange?: (keys: string[]) => void;
13
+ /** true = 多开;默认 false 手风琴互斥(antd 对齐) */
9
14
  multiple?: boolean;
10
15
  }
16
+ /**
17
+ * 手风琴折叠面板(对应 antd/EP Collapse 卡片面板语义):受控 active + 点击切换 +
18
+ * 方向键移动焦点 + aria-expanded 同步。与 Collapse 边界:Accordion = 整块卡片面板容器。
19
+ */
11
20
  export declare const Accordion: Component<AccordionProps>;
@@ -0,0 +1,16 @@
1
+ import type { Component } from '../../client/vnode.ts';
2
+ export interface AffixProps {
3
+ /** 距视口顶部偏移,滚动超过该值后固定(px),默认 0 */
4
+ offsetTop?: number;
5
+ /** 滚动容器(默认 window) */
6
+ target?: () => HTMLElement | Window;
7
+ children?: any;
8
+ className?: string;
9
+ [key: string]: any;
10
+ }
11
+ /** 固定定位(对应 antd/EP Affix):滚动超过阈值后固定元素,保持占位与宽度
12
+ * 实现:ctx.ui.useScrollPosition(全局 scroll 监听 + rAF 节流,内置方案)——
13
+ * mount 时算一次阈值(sentinel 文档位置 - offsetTop),滚动位置响应式驱动 fixed 判定。
14
+ * 不用 IO:IO 只在交叉状态变化时回调,瞬间滚动后 sentinel 从视口外下方到视口外上方
15
+ * isIntersecting 都是 false → 不回调(Affix 需要连续位置跟踪,IO 语义不匹配)。 */
16
+ export declare const Affix: Component<AffixProps>;
@@ -0,0 +1,10 @@
1
+ import type { Component } from '../../client/vnode.ts';
2
+ export interface AspectRatioProps {
3
+ /** 宽/高比,默认 16/9 */
4
+ ratio?: number;
5
+ children?: any;
6
+ className?: string;
7
+ [key: string]: any;
8
+ }
9
+ /** 宽高比容器(对应 shadcn AspectRatio):内容绝对定位填满,适合图片/视频/嵌入内容 */
10
+ export declare const AspectRatio: Component<AspectRatioProps>;
@@ -0,0 +1,16 @@
1
+ import type { Component } from '../../client/vnode.ts';
2
+ export interface BackTopProps {
3
+ /** 滚动超过此高度显示(px),默认 400 */
4
+ visibilityHeight?: number;
5
+ /** 滚动容器(默认 window) */
6
+ target?: () => HTMLElement | Window;
7
+ /** 平滑滚动,默认 true */
8
+ smooth?: boolean;
9
+ 'aria-label'?: string;
10
+ children?: any;
11
+ className?: string;
12
+ }
13
+ /** 回到顶部(对应 EP Backtop / antd FloatButton.BackTop):滚动超阈值显示,点击回顶
14
+ * 实现:ctx.ui.useInView(IO 封装)观察文档顶部哨兵——rootMargin 顶部向外扩展
15
+ * visibilityHeight,哨兵离开扩展区(= 滚动超阈值)→ 显示。无 scroll 监听、无警告。 */
16
+ export declare const BackTop: Component<BackTopProps>;
@@ -0,0 +1,21 @@
1
+ import type { Component } from '../../client/vnode.ts';
2
+ export interface CalendarEvent {
3
+ key: string;
4
+ /** 日期 'YYYY-MM-DD' */
5
+ date: string;
6
+ title: string;
7
+ color?: string;
8
+ }
9
+ export interface CalendarProps {
10
+ events?: CalendarEvent[];
11
+ /** 受控年月:month 0-11,year 四位数 */
12
+ month?: number;
13
+ year?: number;
14
+ onMonthChange?: (month: number, year: number) => void;
15
+ onSelectDate?: (date: string) => void;
16
+ selectedDate?: string;
17
+ 'aria-label'?: string;
18
+ }
19
+ /** 月历(对应 antd/EP Calendar):月视图网格 + 事件点 + 月切换 + 日期选择。
20
+ * 裁剪:周/日视图、拖拽创建事件、事件详情弹层。 */
21
+ export declare const Calendar: Component<CalendarProps>;
@@ -0,0 +1,17 @@
1
+ import type { Component } from '../../client/vnode.ts';
2
+ export interface CarouselProps {
3
+ children: any[];
4
+ /** 自动播放 */
5
+ autoplay?: boolean;
6
+ /** 自动播放间隔(ms),默认 3000 */
7
+ interval?: number;
8
+ showArrows?: boolean;
9
+ showDots?: boolean;
10
+ /** 循环播放(尾 → 头),默认 true */
11
+ loop?: boolean;
12
+ 'aria-label'?: string;
13
+ className?: string;
14
+ }
15
+ /** 轮播(对应 antd/EP/shadcn Carousel):横向滑动 + 箭头/圆点 + 自动播放 + 触摸滑动。
16
+ * 裁剪:垂直模式、多图联动、淡入淡出(fade 用 CSS 可配)。 */
17
+ export declare const Carousel: Component<CarouselProps>;
@@ -0,0 +1,21 @@
1
+ import type { Component } from '../../client/vnode.ts';
2
+ export interface CascaderOption {
3
+ value: string;
4
+ label: string;
5
+ children?: CascaderOption[];
6
+ disabled?: boolean;
7
+ }
8
+ export interface CascaderProps {
9
+ options?: CascaderOption[];
10
+ /** 选中路径(数组,如 ['zj','hz','xh']) */
11
+ value?: string[];
12
+ onChange?: (value: string[]) => void;
13
+ placeholder?: string;
14
+ disabled?: boolean;
15
+ error?: string;
16
+ label?: string;
17
+ 'aria-label'?: string;
18
+ }
19
+ /** 级联选择(对应 antd/EP Cascader):多列面板逐级选择,点击叶子完成。
20
+ * 裁剪:hover 展开、搜索、任意层级配置、异步加载。 */
21
+ export declare const Cascader: Component<CascaderProps>;
@@ -0,0 +1,23 @@
1
+ import type { Component } from '../../client/vnode.ts';
2
+ export interface CheckboxGroupOption {
3
+ value: string;
4
+ label: string;
5
+ desc?: string;
6
+ disabled?: boolean;
7
+ }
8
+ export interface CheckboxGroupProps {
9
+ options?: CheckboxGroupOption[];
10
+ /** 受控选中值 */
11
+ value?: string[];
12
+ onChange?: (value: string[]) => void;
13
+ /** 栅格列数(1-4) */
14
+ columns?: 1 | 2 | 3 | 4;
15
+ size?: 'sm' | 'md' | 'lg';
16
+ disabled?: boolean;
17
+ /** 组标题(可选) */
18
+ label?: string;
19
+ 'aria-label'?: string;
20
+ className?: string;
21
+ }
22
+ /** 复选框组/多选列表(对应 antd Checkbox.Group):成员选择、多值字段 */
23
+ export declare const CheckboxGroup: Component<CheckboxGroupProps>;
@@ -0,0 +1,28 @@
1
+ import type { Component } from '../../client/vnode.ts';
2
+ export interface CollapseItem {
3
+ key: string;
4
+ title: string;
5
+ /** 标题图标 */
6
+ icon?: any;
7
+ /** 标题右侧操作区 */
8
+ extra?: any;
9
+ /** 展开内容(惰性渲染:未展开不渲染) */
10
+ content?: any;
11
+ /** 异步加载态:展开时显示 loading 指示 */
12
+ loading?: boolean;
13
+ }
14
+ export interface CollapseProps {
15
+ items?: CollapseItem[];
16
+ /** 受控展开 keys */
17
+ active?: string[];
18
+ onChange?: (keys: string[]) => void;
19
+ /** false = 手风琴互斥(同一时间只开一个);默认 true 多开 */
20
+ multiple?: boolean;
21
+ className?: string;
22
+ }
23
+ /**
24
+ * 行内折叠面板(对应 antd/EP Collapse + shadcn Collapsible):
25
+ * 标题行 + 行内展开区(无卡片边框,适配列表行内展开),支持异步 loading。
26
+ * 与 Accordion 边界:Accordion = 整块卡片面板;Collapse = 行内展开。
27
+ */
28
+ export declare const Collapse: Component<CollapseProps>;