weifuwu 0.81.4 → 0.81.6

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.
@@ -1,6 +1,6 @@
1
1
  import type { Component } from '../../ui-dom/vnode.ts';
2
2
  export interface ButtonProps {
3
- variant?: 'primary' | 'secondary' | 'ghost' | 'danger';
3
+ variant?: 'primary' | 'secondary' | 'ghost' | 'danger' | 'danger-ghost';
4
4
  size?: 'sm' | 'md' | 'lg';
5
5
  block?: boolean;
6
6
  loading?: boolean;
@@ -2318,6 +2318,8 @@ body.wf-dragging {
2318
2318
 
2319
2319
  .wf-btn--danger { background: var(--wf-color-error); color: var(--wf-color-on-brand); border-color: var(--wf-color-error); }
2320
2320
  .wf-btn--danger:hover { opacity: 0.9; }
2321
+ .wf-btn--danger-ghost { background: transparent; color: var(--wf-color-error-text); border-color: transparent; }
2322
+ .wf-btn--danger-ghost:hover { background: var(--wf-color-error); color: var(--wf-color-on-brand); border-color: var(--wf-color-error); }
2321
2323
 
2322
2324
  .wf-btn--sm { padding: var(--wf-space-xs) var(--wf-space-sm); font-size: var(--wf-font-size-xs); min-height: 28px; }
2323
2325
  .wf-btn--lg { padding: var(--wf-space) var(--wf-space-lg); font-size: var(--wf-font-size-base); min-height: 40px; }
package/dist/dev/index.js CHANGED
@@ -3,7 +3,29 @@ import { registerHooks } from "node:module";
3
3
  import { readFileSync } from "node:fs";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import { transformSync } from "esbuild";
6
+ var SRC_ROOT = new URL("..", import.meta.url).pathname;
7
+ var BARE_ALIASES = {
8
+ "weifuwu/ui-dom/jsx-runtime": SRC_ROOT + "ui-dom/jsx-runtime.ts",
9
+ "weifuwu/ui-dom/testing": SRC_ROOT + "ui-dom/testing.ts",
10
+ "weifuwu/ui-dom": SRC_ROOT + "ui-dom/index.ts",
11
+ "weifuwu/components": SRC_ROOT + "components/index.ts",
12
+ "weifuwu": SRC_ROOT + "index.ts"
13
+ };
6
14
  registerHooks({
15
+ // 相对路径无扩展名自动补 .ts/.tsx(node ESM 要求显式扩展——页面内部 import 惯例省略)
16
+ resolve(specifier, context, next) {
17
+ const alias = BARE_ALIASES[specifier];
18
+ if (alias) return next(alias, context);
19
+ if ((specifier.startsWith("./") || specifier.startsWith("../")) && !/\.[a-z]+$/.test(specifier)) {
20
+ for (const ext of [".ts", ".tsx"]) {
21
+ try {
22
+ return next(specifier + ext, context);
23
+ } catch {
24
+ }
25
+ }
26
+ }
27
+ return next(specifier, context);
28
+ },
7
29
  load(url, context, next) {
8
30
  if (url.startsWith("file:") && (url.endsWith(".ts") || url.endsWith(".tsx"))) {
9
31
  const file = fileURLToPath(url);
@@ -20,6 +20,8 @@ export type { ApiClient, ApiOptions, ApiRequestOptions, ApiInjected } from './mi
20
20
  export { auth } from './middleware/auth.ts';
21
21
  export type { AuthClient, AuthInjected } from './middleware/auth.ts';
22
22
  export { ws } from './middleware/ws.ts';
23
+ export { i18n } from './i18n.ts';
24
+ export type { I18nState, I18nInjected, I18nOptions } from './i18n.ts';
23
25
  export type { WsClient, WsInjected } from './middleware/ws.ts';
24
26
  export type { UIRequest, UIResponse, UIHandler, UIMiddleware, UIRouteDef, WfuiContext, } from './types.ts';
25
27
  export { uiServe } from './middleware/serve.ts';
@@ -30,6 +32,7 @@ export { ssrPage, ssrToString, serializeData, createSsrContext } from './vdom2/s
30
32
  export { buildVNode } from './vdom2/build.ts';
31
33
  export { renderValue } from './vdom2/render.ts';
32
34
  export { createRenderer, type Renderer } from './vdom2/mount.ts';
35
+ export { mountCommand, unmountCommand } from './vdom2/mount.ts';
33
36
  export { createStore } from './store.ts';
34
37
  export { createVdomContext, mountRoot } from './context.ts';
35
38
  export type { ExternalStore } from './store.ts';
@@ -1,12 +1,12 @@
1
- function Yt(e){let n=[],t=(e||"/").replace(/:(\w+)/g,(o,r)=>(n.push(r),"([^/]+)")).replace(/\*/g,".*");return{re:new RegExp(`^${t}$`),keys:n}}var gn=class{_routes=[];_middlewares=[];_injections=[];_injected=!1;_mode;_notFound;constructor(n={}){this._mode=n.mode??"history"}get mode(){return this._mode}use(n,t){if(typeof n=="string"&&t){let o=this,r=n,i=async(s,l,d)=>{let u=l.__routePath??o.getPath(),a=null;return u===r?a="/":(r==="/"?u!=="/"&&u.startsWith("/"):u.startsWith(r+"/"))&&(a=u.slice(r.length)),a===null?d:async(c,f)=>{let p=await t._handle(a,c,f);return p===null?d(c,f):p}};return this._middlewares.push(i),this}return n.length<=1?(this._injections.push(n),this):(this._middlewares.push(n),this)}async _ensureInjected(n){if(!this._injected){this._injected=!0;for(let t of this._injections){let o=await t(n);o&&o!==n&&Object.assign(n,o)}}}get(n,t,o){return this._routes.push({path:n,handler:t,title:o?.title}),this}notFound(n){return this._notFound=n,this}getPath(){return this._getPath(void 0)}_getPath(n){let t=n?.location??(typeof window<"u"?window.location:null);return this._mode==="hash"?(t?.hash??"").replace(/^#/,"")||"/":t?.pathname??"/"}match(n){let t=null;for(let o of this._routes){let{re:r,keys:i}=Yt(o.path),s=n.match(r);if(!s)continue;let l={};for(let d=0;d<i.length;d++)l[i[d]]=decodeURIComponent(s[d+1]);t={handler:o.handler,params:l,title:o.title};break}return t||(t={handler:this._notFound??(()=>null),params:{}}),t}async _handle(n,t,o){await this._ensureInjected(o);let r=this.match(n);r.title&&typeof document<"u"&&(document.title=r.title),o.params=r.params,o.route&&(o.route.params=r.params);let s=r.handler,l=o.__routePath;o.__routePath=n;try{for(let d=this._middlewares.length-1;d>=0;d--){let u=this._middlewares[d],a=s;s=await u(t,o,a)??a}return await s(t,o)}finally{o.__routePath=l}}async execute(n,t,o){await this._ensureInjected(t);let r=this.match(o);r.title&&typeof document<"u"&&(document.title=r.title),t.params=r.params,t.route&&(t.route.params=r.params);let s=r.handler;for(let l=this._middlewares.length-1;l>=0;l--){let d=this._middlewares[l],u=s;s=await d(n,t,u)??u}return await s(n,t)}};var Q=Symbol("Fragment"),q=Symbol("Portal");function ze(e){return e!=null&&typeof e=="object"&&typeof e.type=="string"}function te(e){return e!=null&&typeof e=="object"&&e.type===Q}function k(e){return e!=null&&typeof e=="object"&&typeof e.type=="function"}function G(e){return e!=null&&typeof e=="object"&&e.type===q}function Ge(e,n,t=null){return{type:e,props:n,key:t,_child:null,_parentNode:null,_refNode:null,_id:null,_customId:null,_parentVNode:null,_ctxVersion:null,_lifecycle:"fresh"}}function Se(e,n,t=null){return e===Q?{...Ge(e,n,t),type:e}:e===q?{...Ge(e,n,t),type:e,_remoteEl:null,_placement:"remote"}:typeof e=="function"?{...Ge(e,n,t),type:e,_render:null,_outputChild:null}:{...Ge(e,n,t),type:e,el:null}}function he(e,n,...t){let o=nt(n??{});return t.length>0&&(o.children=t.length===1?t[0]:t),Se(e,o,n?.key??null)}function hn(e,n,t){return Se(e,nt(n),t??null)}var Jt=hn;function Xt(e,n,t){return hn(e,n,t)}function nt(e){if(!e)return{};let n={};for(let t of Object.keys(e))t!=="key"&&(n[t]=e[t]);return n}function S(e){return e==null||typeof e=="boolean"?[]:Array.isArray(e)?e:[e]}function Ye(e,n){let t=Se(q,{children:e,portalKey:n});return t.key=n??null,t}function x(){return{activeElement:()=>typeof document<"u"?document.activeElement:null,byId:e=>typeof document<"u"?document.getElementById(e):null,query:e=>typeof document<"u"?document.querySelector(e):null,queryAll:e=>typeof document<"u"?document.querySelectorAll(e):null,createElement:e=>typeof document<"u"?document.createElement(e):null,createElementNS:(e,n)=>typeof document<"u"?document.createElementNS(e,n):null,createDocumentFragment:()=>typeof document<"u"?document.createDocumentFragment():null,createComment:e=>typeof document<"u"?document.createComment(e):null,createTextNode:e=>typeof document<"u"?document.createTextNode(e):null,addEventListener:(e,n,t)=>{typeof window<"u"&&window.addEventListener(e,n,t)},removeEventListener:(e,n,t)=>{typeof window<"u"&&window.removeEventListener(e,n,t)},scrollTo:e=>{typeof window<"u"&&window.scrollTo(0,e)},matchMedia:e=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia(e):null,visualViewport:()=>(typeof window<"u"?window:null)?.visualViewport??null,scrollingElement:()=>typeof document<"u"?document.scrollingElement:null,bodyElement:()=>typeof document<"u"?document.body:null,bodyAppend:e=>{typeof document<"u"&&document.body.appendChild(e)},bodyRemove:e=>{typeof document<"u"&&e.parentNode&&document.body.removeChild(e)},clearBody:()=>{typeof document<"u"&&(document.body.innerHTML="")},event:(e,n)=>{let t=typeof window<"u"?window:null,o=n&&(n.key||n.code)?"KeyboardEvent":n&&(n.clientX!==void 0||n.clientY!==void 0||n.pointerId!==void 0)?"PointerEvent":"Event";try{return new t[o](e,n)}catch{return new t.Event(e,n)}},dispatchEvent:(e,n)=>typeof e<"u"?e.dispatchEvent(n):!1,navigate:e=>{typeof window>"u"||(window.history.pushState(null,"",e),window.dispatchEvent(new PopStateEvent("popstate",{state:null})))},copyText:async e=>{let n=typeof window<"u"?window:null;if(n?.navigator?.clipboard?.writeText)try{return await n.navigator.clipboard.writeText(e),!0}catch{}try{if(typeof document>"u")return!1;let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();let o=document.execCommand("copy");return document.body.removeChild(t),o}catch{return!1}},execCommand:(e,n)=>typeof document<"u"?document.execCommand(e,!1,n):!1,queryCommandState:e=>typeof document<"u"?document.queryCommandState(e):!1,queryCommandValue:e=>typeof document<"u"?document.queryCommandValue(e):"",selectionText:()=>typeof window<"u"?window.getSelection?.()?.toString()??null:null,getSelection:()=>typeof window<"u"?window.getSelection():null,viewportHeight:()=>typeof window<"u"?window.innerHeight:0,viewportWidth:()=>typeof window<"u"?window.innerWidth:0,pathname:()=>typeof window<"u"?window.location.pathname:"",createTreeWalker:(e,n)=>typeof document<"u"?document.createTreeWalker(e,n??NodeFilter.SHOW_ALL):null,scrollTop:()=>{let e=typeof document<"u"?document:null,n=typeof window<"u"?window:null;return e?.scrollingElement?.scrollTop??n?.scrollY??0},hash:()=>typeof window<"u"?window.location?.hash??"":"",setHash:e=>{typeof window<"u"&&(window.location.hash=e)},timeout:(e,n)=>typeof window<"u"?window.setTimeout(e,n):0,rootElement:()=>typeof document<"u"?document.documentElement:null,storageGet:e=>{try{return typeof window<"u"?window.localStorage?.getItem(e)??null:null}catch{return null}},storageSet:(e,n)=>{try{typeof window<"u"&&window.localStorage?.setItem(e,n)}catch{}}}}function Qt(e,n,t=400){let o=!1,r=()=>{o||(o=!0,e.removeEventListener("animationend",r),clearTimeout(i),n())};e.addEventListener("animationend",r);let i=setTimeout(r,t)}function Ve(e,n){return Object.assign(Object.create(e),n)}function Zt(e){let n={baseURL:e?.baseURL??"",headers:{"Content-Type":"application/json",...e?.headers}},t=e?.onRequest,o=e?.onResponse,r=e?.timeout??0;async function i(s,l,d,u,a=!1){let c=n.baseURL+l,f={method:s,headers:{...n.headers,...u?.headers}},p=e?.token?.();p&&!f.headers.Authorization&&(f.headers.Authorization=`Bearer ${p}`);let m=r>0,g=!!u?.signal,h=null,w=null;(m||g)&&(h=new AbortController,f.signal=h.signal,m&&(w=setTimeout(()=>h.abort(new Error("Request timed out")),r)),g&&u.signal.addEventListener("abort",()=>h.abort())),d!==void 0&&s!=="GET"&&s!=="HEAD"&&(f.body=JSON.stringify(d));let y={url:c,init:f};t&&(y=t(y));try{let v=await fetch(y.url,y.init);if(v.status===401&&await e?.onUnauthorized?.()&&!a)return i(s,l,d,u,!0);if(o)return o(v);if(!v.ok){let B=await v.text().catch(()=>"");throw new vn(v.status,B||v.statusText)}let b=v.headers.get("content-length");if(v.status===204||b==="0")return;let I=(v.headers.get("content-type")||"").toLowerCase();return I.includes("application/json")||I.includes("json")?v.json():v.text()}finally{w&&clearTimeout(w)}}return s=>Ve(s,{api:{get:(d,u)=>i("GET",d,void 0,u),post:(d,u,a)=>i("POST",d,u,a),put:(d,u,a)=>i("PUT",d,u,a),patch:(d,u,a)=>i("PATCH",d,u,a),delete:(d,u)=>i("DELETE",d,void 0,u)}})}var vn=class extends Error{status;body;constructor(n,t){super(`API Error ${n}: ${t}`),this.name="ApiError",this.status=n,this.body=t}};function eo(e){try{let n=e.split(".");if(n.length!==3)return null;let t=n[1].replace(/-/g,"+").replace(/_/g,"/");return JSON.parse(atob(t))}catch{return null}}function no(e){let n=eo(e);return n?.exp?n.exp*1e3-3e4<Date.now():!0}function to(e){let n=e?.storage??localStorage,t=e?.tokenKey??"weifuwu_token",o=e?.userKey??"weifuwu_user",r=e?.refreshTokenKey??"weifuwu_refresh",i=e?.refreshEndpoint??"/api/auth/refresh";return s=>{let l=n.getItem(t),d=n.getItem(o),u=null,a={token:l,user:d?JSON.parse(d):null,get isLoggedIn(){return this.token!==null},login(f,p,m){a.token=f,a.user=p,n.setItem(t,f),n.setItem(o,JSON.stringify(p)),m&&n.setItem(r,m)},logout(){a.token=null,a.user=null,n.removeItem(t),n.removeItem(o),n.removeItem(r)},setUser(f){a.user=f,n.setItem(o,JSON.stringify(f))},async refresh(){return u||(u=c().finally(()=>{u=null}),u)}};async function c(){let f=n.getItem(r);if(!f)return!1;let p=n.getItem(t);try{let m=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:f})});if(n.getItem(t)!==p)return!1;if(!m.ok)return a.logout(),!1;let g=await m.json();return n.getItem(t)!==p?!1:(a.token=g.token,n.setItem(t,g.token),g.refreshToken&&n.setItem(r,g.refreshToken),!0)}catch{return!1}}return l&&no(l)&&a.refresh().catch(()=>{}),e?.onAuth?.(a),Ve(s,{auth:a})}}function oo(e={}){let n=e.url??"/ws",t=e.reconnectInterval??3e3,o=e.maxReconnect??10,r=e.pingInterval??3e4,i=e.pingTimeout??1e4;return s=>{let l=new Set,d=null,u=0,a=null,c=null,f=null,p=!1,m=[],g={isConnected:!1,onMessage:b=>(l.add(b),()=>{l.delete(b)}),send:b=>{let I=JSON.stringify(b);d?.readyState===WebSocket.OPEN?d.send(I):m.push(I)},_connect:h,close:()=>{p=!0,v(),d?.close(),d=null,m=[],g.isConnected=!1}};async function h(){if(!p)try{d=new WebSocket(n),d.onopen=()=>{g.isConnected=!0,u=0;for(let b of m)d.send(b);m=[],w()},d.onmessage=b=>{try{let I=JSON.parse(b.data);for(let B of l)B(I)}catch{}y()},d.onclose=()=>{g.isConnected=!1,v(),!p&&u<o&&(u++,a=setTimeout(h,t*Math.min(u,5)))},d.onerror=()=>{d?.close()}}catch{p||(a=setTimeout(h,t))}}function w(){r<=0||(c=setInterval(()=>{d?.readyState===WebSocket.OPEN&&d.send(JSON.stringify({type:"ping"})),f=setTimeout(()=>{d?.close()},i)},r))}function y(){clearTimeout(f)}function v(){clearInterval(c),clearTimeout(f),clearTimeout(a)}return h(),Ve(s,{ws:g})}}var ro={route:"route",lifecycle:"lifecycle",x2y:"diff",keys:"diff",pos:"diff",render:"render",audit:"audit",build:"build",mount:"mount",diff:"diff"};function ot(e){return ro[e]}var xe=new Set;function Xe(e){return xe.add(e),()=>{xe.delete(e)}}var Je=[],io=0;function Qe(e){let n=`R${++io}${e?":"+e:""}`;return Je.push(n),n}function Ae(){Je.pop()}function so(){return Je[Je.length-1]??""}function P(e){if(xe.size!==0){e.session||(e.session=so()),typeof e.payload=="function"&&(xe.size>1||E(ot(e.machine),e.level??"debug"))&&(e.payload=e.payload());for(let n of xe)try{n(e)}catch{}}}function rt(){return xe.size>1}function lo(e){if(e==null)return"";if(typeof e=="string")return` ${e}`;if(typeof e=="object"){let n=e,t=[];for(let o of["path","i","key","mode","kind","insertedBefore","after","depth"])if(n[o]!==void 0){let r=n[o];t.push(`${o}=${typeof r=="object"?JSON.stringify(r):String(r)}`)}return t.length?" "+t.join(" "):""}return` ${String(e)}`}function ao(e){let n=ot(e.machine);if(!E(n,e.level??"debug"))return;if(e.event==="TRACE"){console.log(`[vdom:${e.machine}] ${e.payload}`);return}let t=e.component?`${e.component}${e.nodeId?`(${e.nodeId})`:""}`:e.nodeId?`(${e.nodeId})`:"";console.log(`[vdom:${e.machine}] ${t?t+" ":""}${e.from} --${e.event}--> ${e.to}${lo(e.payload)}`)}Xe(ao);var uo=500,Re=[],tt=!1;function co(e){Re.push(e),Re.length>uo&&Re.shift()}function it(){tt||(tt=!0,Xe(co))}function st(){it()}function lt(e=50,n){return it(),n?Re.filter(t=>Object.entries(n).every(([o,r])=>t[o]===r)).slice(-e):Re.slice(-e)}var fo={fresh:{BUILD_START:"building",BUILD_DONE:"built",PRUNE:"pruned",DISPOSE:"disposed"},building:{BUILD_DONE:"built",DISPOSE:"disposed"},built:{BUILD_START:"building",PRUNE:"pruned",DISPOSE:"disposed"},pruned:{BUILD_START:"building",PRUNE:"pruned",DISPOSE:"disposed"},disposed:{BUILD_START:"building"}};function Z(e){let n=0,t=e._parentVNode??null;for(let o=0;o<10&&t;o++)n++,t=t._parentVNode??null;return{name:typeof e.type=="function"?e.type.name||"anonymous":String(e.type),id:e._id??null,depth:n}}var Ze=new Map,po=50;function mo(e,n,t,o){if(!e?.id)return;let r=Ze.get(e.id);r||(r={name:e.name??"?",events:[]},Ze.set(e.id,r)),r.events.push(`${n}--${t}-->${o}`),r.events.length>po&&r.events.shift()}function at(e){if(e){let n=Ze.get(e);return n?`${n.name}(${e}): ${n.events.join(" \u2192 ")}`:`no timeline for ${e}`}return[...Ze.entries()].map(([n,t])=>`${t.name}(${n}): ${t.events.join(" \u2192 ")}`).join(`
2
- `)}function ee(e,n,t){let o=fo[e]?.[n]??null;return o==null?(P({session:"",machine:"lifecycle",nodeId:t?.id??null,component:t?.name??null,from:e,event:n,to:"?",level:"warn",ts:Date.now()}),e):(mo(t,e,n,o),P({session:"",machine:"lifecycle",nodeId:t?.id??null,component:t?.name??null,from:e,event:n,to:o,payload:()=>({depth:t?.depth??0}),level:"debug",ts:Date.now()}),o)}function Ee(e){return!e||e._lifecycle==="disposed"||e._child==null?!1:!Nn(e._child)}function Nn(e){if(e==null||typeof e!="object")return!1;if(Array.isArray(e)){for(let t of e)if(Nn(t))return!0;return!1}let n=e;return!!(n._lifecycle==="disposed"||n._child!=null&&Nn(n._child))}var wn={error:0,warn:1,info:2,debug:3,trace:4},ut=["mount","build","render","diff","lifecycle","route","audit"],oe={enabled:!1,stages:new Set,level:"info",filter:null},bn=!1;function yo(e){return e&&e in wn?e:"info"}function dt(e){let n=new Set;if(!e)return n;for(let t of e.split(",")){let o=t.trim().split(":")[0];ut.includes(o)&&n.add(o)}return n}function Vn(){if(bn)return oe;bn=!0;try{let e=globalThis,n=new URLSearchParams(typeof e.location?.search=="string"?e.location.search:""),t=n.get("vdom_trace"),o=n.get("vdom_debug"),r=e.__vdom_trace__,i=typeof e.localStorage?.getItem=="function"?e.localStorage.getItem("vdom_trace"):null;if(o==="1"||e?.localStorage?.getItem?.("__WF_VDOM_DEBUG")==="1")oe={enabled:!0,stages:new Set(ut),level:"debug",filter:null};else if(t||r||i){let s=new Set;if(t)for(let l of dt(t))s.add(l);if(r?.stages){let l=Array.isArray(r.stages)?r.stages:[...r.stages];for(let d of l)s.add(d)}if(i)for(let l of dt(i))s.add(l);oe={enabled:!0,stages:s,level:t?.includes(":")?yo(t.split(":")[1]):r?.level??"debug",filter:typeof r?.filter=="string"?r.filter:null}}}catch{}return oe}function E(e,n="info"){return!oe.enabled&&(bn||Vn(),!oe.enabled)||oe.stages.size&&!oe.stages.has(e)?!1:wn[n]<=wn[oe.level]}function _(e,n,t,...o){if(!E(e,n)&&!rt())return;let r=oe.filter;r&&!t.includes(r)||P({session:"",machine:e,nodeId:null,component:null,from:"",event:"TRACE",to:"",payload:()=>o.length?`${t} ${o.join(" ")}`:t,level:n,ts:Date.now()})}var go=0;function ct(e){return`R${++go}${e?`:${e}`:""}`}function z(e,n=12){if(!e)return"\u2205";if(typeof e=="string"||typeof e=="number")return`"${e}"`;if(!Array.isArray(e))return ve(e);let t=e.slice(0,n).map(ve);return e.length>n&&t.push(`\u2026+${e.length-n}`),`[${t.join(" | ")}]`}function ft(e){return typeof e=="function"?"function":e===Q?"fragment":typeof e=="string"?"string":"other"}var ho={function:e=>e.name||"Comp",fragment:()=>"Frag",string:e=>String(e),other:e=>String(e)},vo={function:e=>e.name||"anonymous",fragment:()=>"Fragment",string:e=>String(e),other:e=>e===q?"Portal":String(e)};function ve(e){if(e==null||typeof e=="boolean")return String(e);if(typeof e=="string")return`"${e.slice(0,16)}"`;if(typeof e=="number")return String(e);if(Array.isArray(e))return`ARR(${e.length})`;let n=e,t=n.type,o=ho[ft(t)](t),r=n.props?.id?`#${n.props.id}`:n.key!=null?`@${n.key}`:"";return o+r}function Y(e){if(!e)return"null";if(e.nodeType===1){let n=e;return`${n.tagName}${n.id?`#${n.id}`:""}${n.getAttribute?.("data-wf-key")?`@${n.getAttribute("data-wf-key")}`:""}`}return e.nodeType===3?`"${(e.textContent??"").slice(0,12)}"`:e.nodeType===8?`<!--${(e.nodeValue??"").slice(0,40)}-->`:`#${e.nodeType}`}function de(e,n=12){if(!e)return"null";let o=Array.from(e.childNodes).slice(0,n).map(Y);return e.childNodes.length>n&&o.push(`\u2026+${e.childNodes.length-n}`),`[${o.join(" | ")}]`}function Cn(e,n=0){if(e==null||typeof e=="boolean")return[];if(typeof e=="string"||typeof e=="number")return[`${" ".repeat(n)}"${String(e).slice(0,20)}"`];if(Array.isArray(e))return e.flatMap(u=>Cn(u,n));let t=e,o=t.type,r=vo[ft(o)](o),i=t._lifecycle?`[${t._lifecycle}]`:"",s=t._id?`(${t._id})`:"",l=[`${" ".repeat(n)}${r}${s}${i}`],d=t._child;return d!=null&&l.push(...Cn(d,n+1)),l}function pt(e){let n=globalThis;if(n.__vdom_dump==null&&(n.__vdom_dump=()=>Cn(e()??null).join(`
3
- `)),n.__vdom_lc==null&&(n.__vdom_lc=t=>at(t)),n.__vdom_events==null){let t=lt;n.__vdom_events=(o,r)=>t(o,r)}}function R(e){return typeof e=="function"&&e.name||"anonymous"}function en(e){return e.ui?._ctxVersion??0}function xn(e,n){e.ui?.setMounting?.(n)}var No=0;function ye(){return{idRegistry:new Map,unmountHooks:[],nextId:()=>`_wf_${No++}`}}function nn(e,n){return e.unmountHooks.push(n),()=>{let t=e.unmountHooks.indexOf(n);t>=0&&e.unmountHooks.splice(t,1)}}function mt(e,n){for(let t of[...e.unmountHooks])t(n);e.idRegistry.delete(n),e.idRegistry.delete(`custom:${n}`)}function wo(e,n,t,o){try{e(n)}catch(r){console.error(`[weifuwu] ref ${t} error in <${o??"anonymous"}>`,r)}}function H(e,n){if(e==null||typeof e!="object")return;let t=e;if(t._id){let o=Z(t);if(t._customId&&n.idRegistry.delete(t._customId),n.idRegistry.delete(t._id),n.unmountHooks.length>0){let r=[...n.unmountHooks];for(let i of r)i(t._id);if(t._customId)for(let i of r)i(t._customId)}t._id=null,t._customId=null,k(t)&&(t._render=null),t._parentNode=null,t._refNode=null,t._lifecycle=ee(t._lifecycle,"DISPOSE",o)}else(k(t)||t._child!=null)&&(t._lifecycle=ee(t._lifecycle,"DISPOSE",Z(t)));if(t._child!=null){if(Array.isArray(t._child))for(let o of t._child)o&&typeof o=="object"&&H(o,n);else H(t._child,n);t._child=null}if(t.props?.children&&typeof t.type=="string"){let o=Array.isArray(t.props.children)?t.props.children:[t.props.children];for(let r of o)r&&typeof r=="object"&&H(r,n)}if(typeof t.props?.ref=="function"&&wo(t.props.ref,null,"cleanup"),G(t)){let o=t._remoteEl;if(o){let r=t._child;if(r!=null)if(Array.isArray(r))for(let i of r)i&&typeof i=="object"&&H(i,n);else typeof r=="object"&&H(r,n);o.remove(),t._remoteEl=null}}}function A(e,n){if(e==null||typeof e!="object")return null;if(Array.isArray(e)||te(e)){let o=n;if(o&&o.nodeType===8&&o.nodeValue?.includes("type=fragment-start")){let r=[o],i=/fid=([^\s"]+)/.exec(o.nodeValue)?.[1]??"",s=o.nextSibling;for(;s&&(r.push(s),!(s.nodeType===8&&s.nodeValue?.includes("type=fragment-end")&&(/fid=([^\s"]+)/.exec(s.nodeValue)?.[1]??i)===i));)s=s.nextSibling;return r}return null}let t=e;return k(t)?A(t._outputChild??t._child,n):null}function O(e){if(e==null||typeof e=="boolean")return"hole";if(typeof e=="string"||typeof e=="number")return"text";if(Array.isArray(e))return"arr";let n=e;return te(n)?"frag":G(n)?"portal":k(n)?"comp":"native"}function En(e){let n=!1,t=!1;for(let o of e){if(o==null||typeof o=="boolean"||typeof o=="string"||typeof o=="number")continue;if(Array.isArray(o)){t=!0;continue}let r=o;G(r)||(r.key!=null?n=!0:t=!0)}return n&&t?"mixed":n?"keyed":"unkeyed"}function bo(e){if(e===!1)return"false";if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0)return"true";if(typeof e=="object")try{let n=JSON.stringify(e);return`object ${n!=null&&n.length>80?n.slice(0,80)+"\u2026":n??""}`}catch{return`object ${Object.prototype.toString.call(e)}`}return`bad-vnode type=${typeof e}`}function tn(e){return/[\s"=]/.test(e)?`"${e.replace(/"/g,"'")}"`:e}function F(e){let n=[`type=${e.type}`];return e.value!==void 0&&n.push(`value=${tn(bo(e.value))}`),e.key!=null&&n.push(`key=${tn(e.key)}`),e.id!=null&&n.push(`id=${tn(e.id)}`),e.fid!=null&&n.push(`fid=${tn(e.fid)}`),`wf-hole: ${n.join(" ")}`}function gt(e){return typeof e!="string"&&typeof e!="function"&&e!==Q&&e!==q}function ht(e){for(let n=0;n<e.length;n++){let t=e[n];if(t!=null&&typeof t=="object"&&!Array.isArray(t)){let o=t;o.key!==null&&(o.key=String(o.key))}}}var Co=/^on[A-Z]/,Vo=/^on[A-Z].*Capture$/;function Tn(e){let n=Vo.test(e);return{type:(n?e.slice(2,-7):e.slice(2)).toLowerCase(),capture:n}}var _n=new Set(["draggable","contenteditable","spellcheck","translate"]),xo=new Set(["zIndex","opacity","lineHeight","fontWeight","fontSizeAdjust","flex","flexGrow","flexShrink","order","zoom","aspectRatio","gridRow","gridColumn","scale","rotate","animationIterationCount","columnCount","fillOpacity","strokeOpacity","stopOpacity","floodOpacity"]);function kn(e){return _n.has(e.toLowerCase())?"enumerated":e==="class"||e==="className"?"class":e==="style"?"style":e==="ref"?"ref":Co.test(e)?"event":e==="value"?"value":e==="indeterminate"?"indeterminate":e==="innerHTML"?"innerHTML":e.startsWith("aria-")?"aria":"default"}function yt(e,n,t){if(t!==!1){if(t===!0){e.setAttribute(n,"");return}try{e[n]=t,e.getAttribute(n)!==String(t)&&e.setAttribute(n,String(t))}catch{e.setAttribute(n,String(t))}}}var Eo={enumerated:(e,n,t)=>{e.setAttribute(n,t?"true":"false")},class:(e,n,t)=>{if(t!==!1)if(typeof t=="object")for(let[o,r]of Object.entries(t))r&&e.classList.add(o);else e.setAttribute("class",String(t))},style:(e,n,t)=>{if(t!==!1)if(typeof t=="string")e.setAttribute("style",t);else{let o=e.style;for(let[r,i]of Object.entries(t))i==null?o[r]="":r.startsWith("--")?o.setProperty(r,String(i)):typeof i=="number"&&!xo.has(r)?o[r]=`${i}px`:o[r]=String(i)}},ref:(e,n,t)=>{if(typeof t=="function")try{t(e)}catch(o){console.error("[weifuwu] ref error",o)}},event:(e,n,t)=>{if(t===!1)return;let{type:o,capture:r}=Tn(n);if(typeof t!="function"){console.warn(`[weifuwu] event prop ${n} expects a function, got ${typeof t} \u2014 ignored`);return}e.addEventListener(o,t,r?{capture:!0}:{})},value:(e,n,t)=>{t!==!1&&(e.value=t)},indeterminate:(e,n,t)=>{t!==!1&&(e.indeterminate=!!t)},innerHTML:(e,n,t)=>{t!==!1&&(e.innerHTML=String(t??""))},aria:(e,n,t)=>{if(t!==!1){if(typeof t=="boolean"){e.setAttribute(n,t?"true":"false");return}yt(e,n,t)}},default:yt};function re(e,n,t){t!=null&&Eo[kn(n)](e,n,t)}function ue(e,n){return e.createComment(F({type:"hole",value:n,key:null,id:null,fid:null}))}function ce(){return!!globalThis?.__WF_VDOM_AUDIT}var vt=!1;function Nt(){vt||(vt=!0,Xe(e=>{e.machine!=="render"||e.event!=="PARENT"||ce()&&e.to==="SKIP_DETACHED"&&console.error(`[vdom2/audit] \u6302\u8F7D\u4E0D\u53D8\u91CF\u8FDD\u53CD\uFF1A\u7EC4\u4EF6 ${e.component??"?"}${e.nodeId?`(${e.nodeId})`:""} \u72B6\u6001 ${String(e.payload?.lifecycle)} \u4F46\u65E0 _parentNode/_refNode\uFF08rootEl \u53EA\u5C5E\u4E8E\u6839\u7EC4\u4EF6\uFF09\u2014\u2014\u6302\u8F7D\u4FE1\u606F\u65AD\u88C2\uFF0C\u6E32\u67D3\u88AB\u8DF3\u8FC7\uFF0C\u72B6\u6001\u66F4\u65B0\u5C06\u4E22\u5931`)}))}function on(e,n,t){if(n==null||n.length===0)return;let o=Array.from(e.childNodes);if(!n.some(i=>{if(i==null||typeof i!="object")return!1;if(Array.isArray(i))return!0;let s=i.type;return s===Q||s===q}))for(let i=0;i<n.length;i++){let s=n[i];if(s==null||typeof s=="boolean"){let l=o[i];(!l||l.nodeType!==8||!l.nodeValue?.includes("type=hole"))&&t(`[audit] \u5360\u4F4D\u9519\u4F4D\uFF1A\u4F4D\u7F6E ${i} \u671F\u671B\u6CE8\u91CA(wf-hole)\uFF0C\u5B9E\u9645 ${l?.nodeName??"null"}\uFF08${e.nodeName}\uFF09`)}else if(typeof s=="string"||typeof s=="number"){let l=o[i];l&&l.nodeType!==3&&t(`[audit] \u6587\u672C\u9519\u4F4D\uFF1A\u4F4D\u7F6E ${i} \u671F\u671B\u6587\u672C\u8282\u70B9\uFF0C\u5B9E\u9645 ${l.nodeName}\uFF08${e.nodeName}\uFF09`)}}}function Te(e,n,t){To[O(n)](e,n,t)}var To={hole:()=>{},text:()=>{},arr:_o,portal:()=>{},frag:ko,comp:Po,native:So};function _o(e,n,t){let o=n;on(e,o,t);for(let r of o)if(r!=null&&typeof r=="object"&&Array.isArray(r))for(let i of r)Te(e,i,t);else r!=null&&typeof r=="object"&&!Array.isArray(r)&&te(r)&&on(e,S(r.props?.children),t)}function ko(e,n,t){on(e,S(n.props?.children),t)}function Po(e,n,t){let o=n,r=o._refNode;r&&r.parentNode!==e&&t(`[audit] \u7EC4\u4EF6\u951A\u70B9\u9519\u4F4D\uFF1A${R(o.type)} _refNode \u4E0D\u5728\u7236\u8282\u70B9\u5185`),o._child!=null&&Te(e,o._child,t)}function So(e,n,t){let o=n;if(gt(o.type))return;let r=o.el??o._refNode;if(r&&r.nodeType===1&&r.tagName.toLowerCase()!==String(o.type)&&t(`[audit] \u5143\u7D20\u7C7B\u578B\u9519\u4F4D\uFF1A\u671F\u671B <${String(o.type)}>\uFF0C\u5B9E\u9645 ${r.tagName}`),r&&r.nodeType===1&&!("innerHTML"in(o.props??{}))){on(r,S(o.props?.children),t);for(let i of S(o.props?.children))i!=null&&typeof i=="object"&&!Array.isArray(i)&&k(i)&&Te(r,i,t)}}function Ro(e,n){if(e===n)return!0;let t=Object.keys(e),o=Object.keys(n);if(t.length!==o.length)return!1;for(let r of t)if(e[r]!==n[r])return!1;return!0}async function Ao(e,n,t,o){let r=e;r._id||(o?.reuse?._id?r._id=o.reuse._id:r._id=t.nextId(),t.idRegistry.set(r._id,r)),o?.reuse&&(o.reuse._parentNode&&(r._parentNode=o.reuse._parentNode),o.reuse._refNode&&(r._refNode=o.reuse._refNode),o.reuse._ctxVersion!=null&&(r._ctxVersion=o.reuse._ctxVersion));let i=Object.create(n);i.ui=Object.create(n.ui);let s=i.ui;if(s._selfId=r._id??null,s._selfVNode=r,s.render=function(l){let d=n.ui;return l==null&&r._id?d.render([r._id]):d.render(l)},typeof r._render!="function"&&k(o?.reuse)&&typeof o.reuse._render=="function"&&(r._render=o.reuse._render),typeof r._render!="function"){xn(n,!0);let l;try{l=await r.type(r.props??{},i)}finally{xn(n,!1)}if(typeof l!="function")throw new Error(`Component ${R(e.type)} must return a render function. Use (init_props, ctx) => (props) => VNode pattern.`);r._render=l}return{renderFn:r._render,childCtx:i}}function Pn(e){return!!e&&typeof e.then=="function"}function J(e,n,t,o,r){return Io[O(e)](e,n,t,o,r)}function Sn(e,n){return e!=null&&typeof e=="object"&&!Array.isArray(e)&&e.type===n.type?e:null}var Io={hole:e=>e,text:e=>e,arr:Lo,comp:Mo,frag:Ho,native:wt,portal:wt};function Lo(e,n,t,o,r){let i=e;E("build")&&_("build","debug","",`array in kids=${z(i)}`);for(let a of i)if(a!=null&&typeof a=="object"&&!Array.isArray(a)&&a._lifecycle==="disposed"){let c=a;P({session:"",machine:"audit",nodeId:c._id??null,component:R(c.type),from:"disposed",event:"CONTRACT_VIOLATION",to:"new-tree",level:"error",ts:Date.now()}),ce()&&console.error(`[vdom2/audit] \u4E24\u9636\u6BB5\u5951\u7EA6\u8FDD\u53CD\uFF1A\u7EC4\u4EF6 ${R(c.type)} \u7684 renderFn \u8FD4\u56DE\u4E86 disposed \u65E7 vnode${c._id?`(${c._id})`:""}\u2014\u2014\u590D\u7528\u65E7\u6811\u5BF9\u8C61\uFF08\u5E94\u4E3A\u6BCF\u6B21\u6E32\u67D3\u751F\u6210\u65B0 vnode\uFF09\u3002\u540C\u4E00\u5BF9\u8C61\u65E2\u662F\u65E7\u6811\u53C8\u88AB dispose \u2192 diff \u81EA dispose \u2192 \u5361\u7247\u9519\u4F4D/\u6D88\u5931\uFF08demo \u641C\u7D22\u6062\u590D\u4E8B\u6545\uFF09`);break}for(let a=0;a<i.length;a++){let c=i[a];if(c!=null&&typeof c=="object"&&!Array.isArray(c)){let f=c;f.key!==null&&(f.key=String(f.key))}}let s=Array.isArray(t)?t:[],l=new Map;for(let a of s)a!=null&&typeof a=="object"&&!Array.isArray(a)&&a.key!=null&&l.set(a.key,a);let d=i.map((a,c)=>{let f=null;return a!=null&&typeof a=="object"&&!Array.isArray(a)&&a.key!=null&&(f=l.get(a.key)??null),f==null&&(f=s[c]??null),J(a,n,f,o,r)});E("build")&&_("build","debug","",`array out kids=${z(i)}`);let u=!1;for(let a=0;a<d.length;a++)if(Pn(d[a])){u=!0;break}return u?Promise.all(d).then(()=>i):i}function Mo(e,n,t,o,r){let i=e,s=o??n.__registry??ye(),l=Sn(t,i);i._id||(i._id=l?._id??s.nextId(),s.idRegistry.set(i._id,i)),l&&(l._parentNode&&(i._parentNode=l._parentNode),l._refNode&&(i._refNode=l._refNode),l._ctxVersion!=null&&(i._ctxVersion=l._ctxVersion),k(i)&&k(l)&&typeof l._render=="function"&&(i._render=l._render));let d=Ro(l?.props??{},i.props??{}),u=en(n),a=(l?._ctxVersion??-1)===u;if(!r?.force&&d&&a&&Ee(l)&&typeof i._render=="function"){let c=l;return i._lifecycle=ee(i._lifecycle,"PRUNE",Z(i)),i._child=c._child,i._ctxVersion=c._ctxVersion,E("build")&&_("build","debug","",`prune comp=${ve(i)} propsSame=${d} verSame=${a}`),i}return i._lifecycle=ee(i._lifecycle,"BUILD_START",Z(i)),E("build")&&_("build","debug","",`mount comp=${ve(i)} propsSame=${d} verSame=${a} force=${!!r?.force}`),(async()=>{let{childCtx:c}=await Ao(i,n,s,{reuse:l??null}),f=await J(await i._render(i.props),c,l?._child,s,r);return i._child=f??null,i._ctxVersion=u,i._lifecycle=ee(i._lifecycle,"BUILD_DONE",Z(i)),i})()}function Ho(e,n,t,o,r){let i=e,s=o??n.__registry??ye(),l=Sn(t,i);E("build")&&_("build","debug","",`fragment kids=${z(S(i.props?.children))}`);let d=J(i.props?.children??null,n,l?._child??l?.props?.children,s,r);return Pn(d)?d.then(u=>(i._child=u??null,i._lifecycle=ee(i._lifecycle,"BUILD_DONE",Z(i)),i)):(i._child=d??null,i._lifecycle=ee(i._lifecycle,"BUILD_DONE",Z(i)),i)}function wt(e,n,t,o,r){let i=e;if(typeof i.type!="string"&&typeof i.type!="symbol")return i;let s=o??n.__registry??ye(),l=Sn(t,i);E("build")&&_("build","trace","",`native <${String(i.type)}> kids=${z(S(i.props?.children))}`);let d=J(i.props?.children??null,n,l?.props?.children,s,r);return Pn(d)?d.then(u=>(i._child=u??null,i._lifecycle=ee(i._lifecycle,"BUILD_DONE",Z(i)),i)):(i._child=d??null,i._lifecycle=ee(i._lifecycle,"BUILD_DONE",Z(i)),i)}var Oo=new Set(["svg","path","circle","rect","line","polyline","polygon","g","text","defs","use","clipPath"]);function _e(e,n){return ue(e,n)}function U(e,n,t,o=null,r=null,i=null){let s=n?.browser??t;if(!s)throw new Error("[vdom2] renderValue requires browser env (ctx.browser)");return qo[O(e)](e,n,s,o,r,i)}function Uo(e,n,t){return null}function $o(e,n,t){return t.createTextNode(String(e))}function Rn(e,n,t,o,r){if(e==null||typeof e=="boolean")return _e(t,e);let i=U(e,n,t,String(o),null,r);return i??_e(t,null)}function Do(e,n,t,o=null,r=null,i=null){let s=e,l=t.createDocumentFragment();if(!l)return null;E("render")&&_("render","debug","",`array kids=${z(s)} fid=${i??"-"} key=${o??"-"}`);let d=t.createComment(F({type:"fragment-start",key:o,id:r,fid:i})),u=t.createComment(F({type:"fragment-end",key:o,id:r,fid:i}));d&&l.appendChild(d);for(let a=0;a<s.length;a++){let c=s[a],f=i!=null?`${i}-${a}`:String(a),p=Rn(c,n,t,a,f);p!=null&&l.appendChild(p)}return u&&l.appendChild(u),l}function jo(e,n,t){let o=e,r=o,i=t.bodyElement();if(!i)return null;let s=i.querySelector("#__wf_portal");s||(s=t.createElement("div"),s&&(s.id="__wf_portal",i.appendChild(s)));let l=t.createElement("div");if(l){l.setAttribute("data-portal",String(o.props?.portalKey??"wf"));let d=U(o.props?.children??null,n,t);d!=null&&l.appendChild(d),s&&s.appendChild(l),r._remoteEl=l;let u=S(o.props?.children);for(let a of u)a!=null&&typeof a=="object"&&!Array.isArray(a)&&(a._parentVNode=o)}return null}function Wo(e,n,t,o=null,r=null,i=null){let s=e,l=s,d=t.createDocumentFragment();if(!d)return null;let u=S(s.props?.children);E("render")&&_("render","debug","",`fragment kids=${z(u)} fid=${i??"-"}`);let a=t.createComment(F({type:"fragment-start",key:o,id:r,fid:i})),c=t.createComment(F({type:"fragment-end",key:o,id:r,fid:i}));a&&d.appendChild(a),l._refNode=a;for(let f=0;f<u.length;f++){let p=u[f],m=i!=null?`${i}-${f}`:String(f),g=Rn(p,n,t,f,m);g!=null&&d.appendChild(g)}return c&&d.appendChild(c),d}function Fo(e,n,t){let o=e,r=o._lifecycle??(typeof o._render=="function"?"built":"fresh");return Bo[r](o,n,t)}var Bo={fresh:(e,n,t)=>{throw new Error(`[vdom2] component ${R(e.type)} not built (missing _render) \u2014 buildVNode must run before renderValue`)},building:(e,n,t)=>{throw new Error(`[vdom2] component ${R(e.type)} building in render \u2014 buildVNode must await before renderValue`)},disposed:(e,n,t)=>(console.warn(`[vdom2] disposed \u7EC4\u4EF6 ${R(e.type)} \u5728\u6E32\u67D3\u2014\u2014\u526A\u679D\u7F13\u5B58\u5931\u6548\u2014\u2014\u7236\u6811\u91CD\u5EFA\u4E2D\uFF08\u5360\u4F4D\u515C\u5E95\uFF09`),_e(t,null)),built:bt,pruned:bt};function bt(e,n,t){let o=e._child;if(o==null)return e._child=null,null;e._child=o,e._outputChild=o,typeof o=="object"&&!Array.isArray(o)&&(o._parentVNode=e);let r=U(o,n,t);if(r){if(e._refNode=r.nodeType===11?r.firstChild:r,e._id)if(r.nodeType===11)for(let i of Array.from(r.childNodes))i.nodeType===1&&i.setAttribute("data-wf-id",e._id);else r.nodeType===1&&r.setAttribute("data-wf-id",e._id);if(e.key!=null)if(r.nodeType===11)for(let i of Array.from(r.childNodes))i.nodeType===1&&i.setAttribute("data-wf-key",e.key);else r.nodeType===1&&r.setAttribute("data-wf-key",e.key)}return r}function Ko(e,n,t,o,r){let i=e,s=i,l=i.type,d=Oo.has(l)?t.createElementNS("http://www.w3.org/2000/svg",l):t.createElement(l);if(!d)return null;s.el=d,s._refNode=d,E("render")&&_("render","trace","",`native <${l}> key=${i.key??"-"} kids=${z(S(i.props?.children))}`),i.key!=null&&d.setAttribute("data-wf-key",i.key);let u=null;for(let[a,c]of Object.entries(i.props??{}))if(!(a==="children"||a==="key")){if(a==="value"&&d instanceof HTMLSelectElement){u=c;continue}re(d,a,c)}if(!("innerHTML"in(i.props??{}))){let a=S(i.props?.children);for(let c=0;c<a.length;c++){let f=a[c],p=r!=null?`${r}-${c}`:String(c),m=Rn(f,n,t,c,p);if(m!=null&&(d.appendChild(m),f&&typeof f=="object"&&!Array.isArray(f)&&typeof f.type=="function")){let g=f;g._parentNode||(g._parentNode=d)}}E("render")&&_("render","trace","",`native <${l}> out=${de(d)}`)}return u!==null&&(d.value=String(u)),d}var qo={hole:Uo,text:$o,arr:Do,portal:jo,frag:Wo,comp:Fo,native:Ko};function fe(e){let{parent:n,oldNode:t,oldInput:o,ctx:r}=e,i=U(e.newInput,r,r.browser??x());if(i==null)return null;if(t?.parentNode){let s=Ie(o,t,n,r);return s&&s.parentNode===n?n.insertBefore(i,s):n.appendChild(i),i}return n.appendChild(i),i}function Go(e){return Ie(e.oldInput,e.oldNode,e.parent,e.ctx),null}function zo(e){let n=e.oldNode;if(n?.nodeType===8){let t=_e(e.ctx.browser??x(),e.newInput);return t&&n.nodeValue!==t.nodeValue&&(n.nodeValue=t.nodeValue),n}return null}function ke(e){let{parent:n,oldNode:t,ctx:o}=e,r=U(e.newInput,o,o.browser??x());return r==null?null:(t?.parentNode?t.parentNode.replaceChild(r,t):t?n.insertBefore(r,t):n.appendChild(r),r)}function Yo(e){let{parent:n,oldNode:t,oldInput:o}=e,r=String(e.newInput);if(String(o)!==r){if(t&&t.nodeType===3)return t.nodeValue=r,t;let i=n.ownerDocument.createTextNode(r);return t?.parentNode?t.parentNode.replaceChild(i,t):n.appendChild(i),i}return t}function Jo(e){let{parent:n,oldNode:t,oldInput:o,ctx:r}=e,i=e.newInput,s=o&&typeof o=="object"&&!Array.isArray(o)?o:null,l=i.type;if(t&&t.nodeType===1&&(s?.type??null)===l&&ze(i)){let d=t;return i.el=d,i._refNode=d,Vt(d,s?.props??{},i.props??{}),"innerHTML"in(i.props??{})||Le(d,s?._child??s?.props?.children??null,i._child??i.props?.children??null,r),d}return fe(e)}function Xo(e){let{parent:n,oldNode:t,oldInput:o,ctx:r}=e,i=e.newInput,s=o&&typeof o=="object"&&!Array.isArray(o)?o:null,l=te(s)?A(s,t):null,d=An(n,s??o,i,r,l);return t?.parentNode?t:d[0]??null}function Qo(e){let{parent:n,oldNode:t,oldInput:o,ctx:r}=e,i=e.newInput;if(!k(i)||typeof i._render!="function")throw new Error(`[vdom2] component ${R(i.type)} not built in diff \u2014 buildVNode must run before patchValue`);let s=o&&typeof o=="object"&&!Array.isArray(o)?o:null;if(s?.type!=null&&s.type!==i.type)return fe(e);let l=s?.type===i.type;if(!r.force&&s&&l&&Ee(s)&&i._child===s._child)return t;s?.type===i.type&&s._id&&(i._id=s._id,r.registry.idRegistry.set(i._id,i)),i._parentNode=n,t&&(i._refNode=t);let d=i._child;if(d===null){i._outputChild=null,i._refNode=null;let a=t?.parentNode!=null,c=Ie(s?._child??null,t,n,r);s&&(s._child=null);let f=_e(r.browser??x(),null);return a&&f?(c&&c.parentNode===n?n.insertBefore(f,c):n.appendChild(f),f):ne(n,t,s?._child,null,r)}i._outputChild=d;let u=ne(n,t,s?._child,d,r);return u&&(i._refNode=u),u}function Zo(e){let{parent:n,oldNode:t,oldInput:o,ctx:r}=e;if(o===e.newInput&&t?.parentNode)return t;let i=n.ownerDocument.createDocumentFragment(),s=Le(n,o,e.newInput,r,t?[t]:null);for(let l of s)l&&i.appendChild(l);return t?.parentNode?i.contains(t)?n.appendChild(i):t.parentNode.replaceChild(i,t):n.appendChild(i),i}function er(e){let{ctx:n,oldInput:t}=e,o=e.newInput,r=t&&typeof t=="object"&&!Array.isArray(t)?t:null;if(G(r)&&G(o)){let i=r._remoteEl;if(i){let s=r._child??r.props?.children??null,l=o._child??o.props?.children??null;Le(i,s,l,n)}return o._remoteEl=r._remoteEl,null}return fe(e)}function Ne(e){return{text:fe,native:fe,frag:fe,comp:fe,arr:fe,hole:Go,portal:fe,...e}}var nr={text:Ne({text:Yo}),hole:Ne({text:ke,native:ke,frag:ke,comp:ke,arr:ke,portal:ke,hole:zo}),native:Ne({native:Jo}),frag:Ne({frag:Xo}),comp:Ne({comp:Qo}),arr:Ne({arr:Zo}),portal:Ne({portal:er})};function Ct(e){let n=O(e.oldInput),t=O(e.newInput);return P({session:"",machine:"x2y",nodeId:null,component:null,from:n,event:"X2Y",to:t,level:"trace",ts:Date.now()}),nr[n][t](e)}function ie(e,n){if(n&&typeof e.type=="function"&&e._id){try{H(e,n)}catch(t){console.error("[weifuwu] ref cleanup error",t)}mt(n,e._id)}}function Ue(e){if(e==null||typeof e!="object"||Array.isArray(e))return null;let n=e;return G(n)?typeof n.props?.portalKey=="string"?n.props.portalKey:null:n.key}function In(e,n){if(n&&e&&typeof e=="object"&&!Array.isArray(e)){let t=A(e,n);if(t&&t.length>1)return t}return[n]}function rn(e,n){let t=S(e.props?.children);for(let o of t){if(o==null||typeof o!="object"||Array.isArray(o))continue;let r=o;tr[O(r)](r,n)}}var tr={comp:(e,n)=>{ie(e,n)},frag:(e,n)=>{rn(e,n)},native:(e,n)=>{rn(e,n)},portal:(e,n)=>{rn(e,n)},arr:()=>{},text:()=>{},hole:()=>{}};function Ie(e,n,t,o){return or[O(e)](e,n,t,o)}var or={arr:(e,n,t,o)=>{let r=A(e,n);if(r&&r.length){let i=(r[r.length-1]??n)?.nextSibling??null;for(let s of r)s.parentNode&&s.parentNode.removeChild(s);return i&&i.parentNode===t?i:null}return Me(e,n,t,o)},frag:(e,n,t,o)=>{let r=e,s=A(r,n)??[],l=(s[s.length-1]??n)?.nextSibling??null;for(let d of s)d.parentNode&&d.parentNode.removeChild(d);return rn(r,o.registry),l&&l.parentNode===t?l:null},portal:(e,n,t,o)=>{let r=e,i=r._remoteEl;try{H(r.props?.children,o.registry)}catch(s){console.error("[weifuwu] portal ref cleanup error",s)}return i?.parentNode?.removeChild(i),null},comp:(e,n,t,o)=>{let r=e,i=A(r,n);if(ie(r,o.registry),i&&i.length>1){let s=(i[i.length-1]??n)?.nextSibling??null;for(let l of i)l.parentNode&&l.parentNode.removeChild(l);return s&&s.parentNode===t?s:null}return Me(e,n,t,o)},native:(e,n,t,o)=>{try{H(e,o.registry)}catch(r){console.error("[weifuwu] ref cleanup error",r)}return Me(e,n,t,o)},text:(e,n,t,o)=>Me(e,n,t,o),hole:(e,n,t,o)=>Me(e,n,t,o)};function Me(e,n,t,o){let r=n?.nextSibling??null;return n?.parentNode&&n.parentNode.removeChild(n),r&&r.parentNode===t?r:null}function ne(e,n,t,o,r){return Ct({parent:e,oldNode:n,oldInput:t,newInput:o,ctx:r})}var rr={event:(e,n,t,o)=>{let{type:r,capture:i}=Tn(n);typeof t=="function"&&e.removeEventListener(r,t,i?{capture:!0}:{}),o!=null&&o!==!1&&(typeof o!="function"?console.warn(`[weifuwu] event prop ${n} expects a function, got ${typeof o} \u2014 ignored`):e.addEventListener(r,o,i?{capture:!0}:{}))},class:(e,n,t,o)=>{o==null||o===!1?e.removeAttribute("class"):(e.className="",re(e,n,o))},ref:(e,n,t,o)=>{if(o==null||o===!1){if(typeof t=="function")try{t(null)}catch(r){console.error("[weifuwu] ref cleanup error",r)}}else re(e,n,o)},value:(e,n,t,o)=>{o==null||o===!1?e.value="":re(e,n,o)},indeterminate:(e,n,t,o)=>{o==null||o===!1?e.indeterminate=!1:re(e,n,o)},enumerated:He,style:He,innerHTML:He,aria:He,default:He};function He(e,n,t,o){if(o==null||o===!1){e.removeAttribute(n);try{delete e[n]}catch{}}else re(e,n,o)}function Vt(e,n,t){let o=Object.keys(n),r=Object.keys(t);if(o.length===r.length){let s=!0;for(let l=0;l<o.length;l++)if(o[l]!==r[l]||n[o[l]]!==t[o[l]]){s=!1;break}if(s)return}let i=new Set([...o,...r]);for(let s of i){if(s==="children"||s==="key")continue;let l=n[s],d=t[s];l!==d&&rr[kn(s)](e,s,l,d)}}function An(e,n,t,o,r){let i=Array.isArray(n)?n:n?._child??n?.props?.children??null,s=Array.isArray(t)?t:t?._child??t?.props?.children??null;return Le(e,i,s,o,r)}function Le(e,n,t,o,r,i){let s=S(n),l=S(t),d=r??Array.from(e.childNodes);E("diff")&&_("diff","debug","",`patchChildren parent=${Y(e)} old=${z(s)} new=${z(l)} dom=${de(e)}`);let u=l.some(p=>Array.isArray(p))||s.some(p=>Array.isArray(p)),a=u?"unkeyed":En(l);if(P({session:"",machine:"keys",nodeId:null,component:null,from:u?"unkeyed":En(l),event:"SELECT",to:a,payload:()=>({len:l.length}),level:"trace",ts:Date.now()}),ce()&&s.length!==l.length)for(let p=0;p<l.length;p++){let m=l[p];m!=null&&typeof m=="object"&&!Array.isArray(m)&&k(m)&&m.key==null&&console.error(`[vdom2/audit] \u52A8\u6001\u6570\u7EC4\u4F4D\u7F6E ${p} \u7684\u7EC4\u4EF6\u7F3A\u5C11 key\u2014\u2014\u5217\u8868\u589E\u5220/\u91CD\u6392\u4F1A\u9519\u4F4D\u7EC4\u4EF6\u5B9E\u4F8B\u72B6\u6001\u3002\u8BF7\u63D0\u4F9B\u4E1A\u52A1\u8EAB\u4EFD key\uFF08\u5982 key={item.id}\uFF09\uFF1B\u65E0\u72B6\u6001 native \u9879\u8C41\u514D\u3002`)}let c=r&&r.length?r[r.length-1]:null;a==="mixed"&&(sn(l),sn(s));let f=(()=>{let p=d;p.length>=2&&p[0]?.nodeType===8&&p[0].nodeValue?.includes("fragment-start")&&p[p.length-1]?.nodeType===8&&p[p.length-1].nodeValue?.includes("fragment-end")&&(p=p.slice(1,-1));let m=[],g=0;for(let h=0;h<s.length;h++){let w=s[h];if(Array.isArray(w)){let v=p[g]??null;m.push(v);let b=A(w,v);g+=b?.length??1;continue}if(w==null||typeof w=="boolean"||typeof w=="string"||typeof w=="number"){m.push(p[g]??null),g++;continue}let y=w;if(G(y)){m.push(y._remoteEl??null);continue}if(m.push(y._refNode??p[g]??null),typeof y.type=="function"||te(y)){let v=A(y,y._refNode??p[g]??null);g+=v?.length??1}else g++}return m})();return xr[a]({parent:e,oldChildren:s,newChildren:l,oldNodes:f,ctx:o,arrEnd:c,anchorOut:i})}function Oe(e){return e==null||typeof e=="boolean"?"hole":Array.isArray(e)||e&&typeof e=="object"&&te(e)?"multi":"real"}function ir(e){let{parent:n,oldC:t,oldNode:o,oldNodes:r,i,ctx:s,out:l,pushA:d}=e;if(Array.isArray(t)){E("diff")&&_("diff","trace","",`remove-arr-item i=${i} range=[${(A(t,r[i])??[]).map(Y).join(" | ")}] before=${de(n)}`);let u=A(t,o);for(let a of u??[])a.parentNode?.removeChild(a);E("diff")&&_("diff","trace","",`remove-arr-item after=${de(n)}`);for(let a of t)a!=null&&typeof a=="object"&&!Array.isArray(a)&&typeof a.type=="function"&&ie(a,s.registry)}else if(t&&typeof t=="object"&&!Array.isArray(t)){if(typeof t.type=="function")ie(t,s.registry);else try{H(t,s.registry)}catch(u){console.error("[weifuwu] ref cleanup error",u)}o?.parentNode&&o.parentNode.removeChild(o)}else o?.parentNode&&o.parentNode.removeChild(o);l.push(null),d(null)}function sr(e){let{parent:n,newC:t,oldNode:o,i:r,oldNodes:i,out:s,pushA:l,ctx:d}=e,u=ue(d.browser??x(),t);if(o?.nodeType===8){u&&o.nodeValue!==u.nodeValue&&(o.nodeValue=u.nodeValue),s.push(o),l(o);return}if(u&&o?.parentNode)o.parentNode.replaceChild(u,o);else if(u){let a=null;for(let c=r+1;c<i.length;c++){let f=i[c];if(f&&f.parentNode===n){a=f;break}}if(!a){let c=null;for(let f=s.length-1;f>=0;f--)if(s[f]){c=s[f];break}c&&c.parentNode===n&&(a=c.nextSibling)}a&&a.parentNode===n?n.insertBefore(u,a):n.appendChild(u),s.push(u),l(u)}else s.push(u),l(u)}function xt(e){let{parent:n,newC:t,oldNode:o,i:r,oldNodes:i,out:s,pushA:l,ctx:d}=e,u=U(t,d,d.browser??x(),String(r));if(u==null){s.push(null),l(null);return}if(o&&o.nodeType===8&&o.nodeValue?.includes("type=hole")){P({session:"",machine:"pos",nodeId:null,component:null,from:"hole",event:"HOLE_FILL",to:"real",payload:()=>({i:r,replaced:Y(o)}),level:"trace",ts:Date.now()}),o.parentNode?.replaceChild(u,o),s.push(u),l(u);return}let a=null;for(let c=r+1;c<i.length;c++){let f=i[c];if(f&&f.parentNode===n){a=f;break}}if(a==null){let c=null;for(let f=s.length-1;f>=0;f--)if(s[f]){c=s[f];break}if(c&&c.parentNode===n)a=c.nextSibling;else{let f=i[i.length-1];f&&f.parentNode===n&&(a=f.nextSibling)}}a&&a.parentNode===n?n.insertBefore(u,a):n.appendChild(u),P({session:"",machine:"pos",nodeId:null,component:null,from:"hole",event:"INSERT",to:"real",payload:()=>({i:r,insertedBefore:a?Y(a):"END",node:Y(u)}),level:"trace",ts:Date.now()}),s.push(u),l(u)}function lr(e){let{parent:n,oldC:t,newC:o,oldNode:r,out:i,pushA:s,ctx:l}=e;if(t&&typeof t=="object"&&!Array.isArray(t)&&typeof t.type=="function"){let u=_t(n,t,r,o,l);i.push(u),s(u);return}let d=kt(n,t,r,o,l);i.push(d),s(d)}function ar(e){let{parent:n,oldC:t,newC:o,oldNode:r,i,out:s,pushA:l,ctx:d}=e,u=d.browser??x(),a=U(o,d,u,String(i));if(a==null){s.push(null),l(null);return}let c=t&&typeof t=="object"?A(t,r):null;if(c&&c.length>1){let p=(c[c.length-1]??r)?.nextSibling??null;for(let m of c)m.parentNode&&m.parentNode.removeChild(m);if(t&&typeof t=="object"&&!Array.isArray(t))if(typeof t.type=="function")ie(t,d.registry);else try{H(t,d.registry)}catch(m){console.error("[weifuwu] ref cleanup error",m)}p&&p.parentNode===n?n.insertBefore(a,p):n.appendChild(a)}else r?.parentNode?r.parentNode.replaceChild(a,r):n.appendChild(a);let f=a.nodeType===11?Array.from(a.childNodes):[a];s.push(...f),l(f[0]??a)}function dr(e){let{parent:n,oldC:t,newC:o,oldNode:r,out:i,pushA:s,ctx:l}=e,d=Tt(n,t,r,o,l);i.push(d),s(d)}function ur(e){let{parent:n,oldC:t,newC:o,oldNode:r,i,oldNodes:s,out:l,pushA:d,ctx:u}=e,a=u.browser??x(),c=A(t,r);E("diff")&&_("diff","debug","",`multi-remove i=${i} range=${c?c.map(Y).join(" | "):"null"}`);for(let m of c??[])m.parentNode?.removeChild(m);for(let m of S(t?.props?.children))m!=null&&typeof m=="object"&&!Array.isArray(m)&&typeof m.type=="function"&&ie(m,u.registry);let f=U(o,u,a,String(i));if(f==null){l.push(null),d(null);return}let p=s[i+1]??null;p?.parentNode?p.parentNode.insertBefore(f,p):n.appendChild(f),l.push(f),d(f)}function cr(e){let{parent:n,oldC:t,newC:o,oldNode:r,oldNodes:i,i:s,out:l,pushA:d,ctx:u}=e,a=A(t,r),c=An(n,t,o,u,a);l.push(...c),d(i[s]??c[0]??null)}function fr(e){let{parent:n,oldC:t,newC:o,oldNode:r,i,out:s,pushA:l,ctx:d}=e;if(o&&typeof o=="object"&&!Array.isArray(o)&&typeof o.type=="function"&&o._lifecycle==="disposed"){let c=St(n,r,d,R(o.type));s.push(c),l(c);return}let u=ne(n,r,t,o,d);E("diff")&&_("diff","trace","",`after-patch i=${i} new=${ve(o)} node=${Y(u)} dom=${de(n)}`);let a=In(o,u);s.push(...a),l(a[0]??u??null)}function Tt(e,n,t,o,r){let i=ue(r.browser??x(),o),s=A(n,t),l=((s??[])[s?.length?s.length-1:0]??t)?.nextSibling??null;for(let d of s??[])d.parentNode?.removeChild(d);for(let d of S(n?.props?.children))d!=null&&typeof d=="object"&&!Array.isArray(d)&&typeof d.type=="function"&&ie(d,r.registry);return i&&l&&l.parentNode===e?e.insertBefore(i,l):i&&e.appendChild(i),i}function _t(e,n,t,o,r){let i=ue(r.browser??x(),o),s=Ie(n,t,e,r);return i&&s?e.insertBefore(i,s):i&&e.appendChild(i),i}function kt(e,n,t,o,r){let i=ue(r.browser??x(),o);if(n&&typeof n=="object"&&!Array.isArray(n))if(typeof n.type=="function")ie(n,r.registry);else try{H(n,r.registry)}catch(s){console.error("[weifuwu] ref cleanup error",s)}return i&&t?.parentNode?t.parentNode.replaceChild(i,t):i&&e.appendChild(i),i}var pr={hole:{hole:sr,real:xt,multi:xt},real:{hole:lr,real:fr,multi:ar},multi:{hole:dr,real:ur,multi:cr}};function mr(e){let{parent:n,oldChildren:t,newChildren:o,oldNodes:r,ctx:i,anchorOut:s}=e,l=Math.max(t.length,o.length),d=[],u=a=>{s&&s.push(a)};for(let a=0;a<l;a++){let c=a<t.length?t[a]:null,f=a<o.length?o[a]:null;if(a>=o.length){ir({parent:n,oldC:c,newC:f,oldNode:r[a],i:a,oldNodes:r,newChildren:o,out:d,pushA:u,ctx:i});continue}if(c!=null&&typeof c=="object"&&!Array.isArray(c)&&f!=null&&typeof f=="object"&&!Array.isArray(f)&&f===c&&Ee(c)){d.push(r[a]),u(r[a]);continue}let p=pr[Oe(c)][Oe(f)];P({session:"",machine:"pos",nodeId:null,component:null,from:Oe(c),event:p.name,to:Oe(f),payload:()=>({i:a}),level:"trace",ts:Date.now()}),p({parent:n,oldC:c,newC:f,oldNode:r[a],i:a,oldNodes:r,newChildren:o,out:d,pushA:u,ctx:i})}return d}function Et(e){let{parent:n,oldChildren:t,newChildren:o,oldNodes:r,ctx:i,anchorOut:s,arrEnd:l}=e,d=new Map;t.forEach((p,m)=>{let g=Ue(p);g!==null&&p&&typeof p=="object"&&!Array.isArray(p)&&d.set(g,{vnode:p,nodes:[r[m]??null].filter(Boolean),index:m})});let u=[],a=new Set,c=p=>{s&&s.push(p)},f=null;return o.forEach((p,m)=>{let g=Ue(p),h=p;if(g!==null&&d.has(g)){let w=d.get(g),y=w.nodes[0]??null;if(a.add(g),h&&typeof h=="object"&&typeof h.type=="function"&&h._lifecycle==="disposed"){let D=St(n,y,i,R(h.type));u.push(D),c(D),D&&(f=D);return}let v=ne(n,y,w.vnode,h,i),b=In(h,v),I=b[0]??v,B=b[b.length-1]??v;if(I&&I.parentNode===n&&f&&I.previousSibling!==f){E("diff")&&_("diff","debug","",`keyed-correct i=${m} k=${g} move=[${b.map(Y).join(" | ")}] after=${Y(f)} before=${de(n)}`);let D=f.nextSibling;for(let C of b)C&&C.parentNode===n&&n.insertBefore(C,D);E("diff")&&_("diff","debug","",`keyed-correct after=${de(n)}`)}u.push(...b),c(b[0]??v??null),B&&(f=B)}else{let w={current:f};wr[Nr(p)]({parent:n,oldChildren:t,newChildren:o,oldNodes:r,ctx:i,out:u,pushA:c,arrEnd:l,c:p,i:m},w),f=w.current}}),t.forEach((p,m)=>{gr[yr(Ue(p),a)](n,p,m,r,i,o.length)}),u}function yr(e,n){return e===null?"unkeyed":n.has(e)?"moved":"stale-keyed"}var gr={moved:()=>{},"stale-keyed":hr,unkeyed:vr};function hr(e,n,t,o,r){let i=n&&typeof n=="object"&&!Array.isArray(n)?A(n,o[t]):null;if(E("diff")&&_("diff","trace","",`keyed-delete i=${t} k=${Ue(n)} range=${i?.length??0} oldNode=${Y(o[t])}`),n&&typeof n=="object"&&!Array.isArray(n))if(typeof n.type=="function")ie(n,r.registry);else try{H(n,r.registry)}catch(s){console.error("[weifuwu] ref cleanup error",s)}Pt(i,o[t])}function vr(e,n,t,o,r,i){let s=o[t];if(s?.nodeType===8&&s.nodeValue?.includes("type=hole")&&t<i)return;if(n&&typeof n=="object"&&!Array.isArray(n))if(typeof n.type=="function")ie(n,r.registry);else try{H(n,r.registry)}catch(u){console.error("[weifuwu] ref cleanup error",u)}let d=n&&typeof n=="object"&&!Array.isArray(n)?A(n,s):null;Pt(d,s)}function Pt(e,n){if(e&&e.length>1)for(let t of e)t.parentNode&&t.parentNode.removeChild(t);else n?.parentNode&&n.parentNode.removeChild(n)}function Nr(e){return e==null||typeof e=="boolean"?"hole":e&&typeof e=="object"&&!Array.isArray(e)&&G(e)?"portal":"real"}var wr={hole:br,portal:Cr,real:Vr};function br(e,n){let{parent:t,oldChildren:o,oldNodes:r,ctx:i,out:s,pushA:l,c:d,i:u}=e,a=o[u]??null,c=r[u]??null,f=Oe(a);if(f==="hole"){let m=ue(i.browser??x(),d);c?.nodeType===8?(m&&c.nodeValue!==m.nodeValue&&(c.nodeValue=m.nodeValue),s.push(c),l(c),c&&(n.current=c)):(m&&c?.parentNode?c.parentNode.replaceChild(m,c):m&&t.appendChild(m),s.push(m),l(m),m&&(n.current=m));return}let p=f==="multi"?Tt(t,a,c,d,i):a&&typeof a=="object"&&!Array.isArray(a)&&typeof a.type=="function"?_t(t,a,c,d,i):kt(t,a,c,d,i);s.push(p),l(p),p&&(n.current=p)}function Cr(e,n){let{parent:t,oldChildren:o,oldNodes:r,ctx:i,out:s,pushA:l,c:d,i:u}=e,a=d,c=o[u]??null,f=ne(t,r[u]??null,c,a,i),p=In(a,f);s.push(...p),l(p[0]??f??null);let m=p[p.length-1]??f;m&&(n.current=m)}function Vr(e,n){let{parent:t,oldNodes:o,ctx:r,out:i,pushA:s,arrEnd:l,c:d,i:u}=e,c=U(d,r,r.browser??x());if(i.push(c),s(c??null),c!=null){let f=o[u];f&&f.nodeType===8&&f.nodeValue?.includes("type=hole")?(f.parentNode?.replaceChild(c,f),n.current=c):(n.current?t.insertBefore(c,n.current.nextSibling):l&&l.parentNode===t?t.insertBefore(c,l):t.insertBefore(c,t.firstChild),n.current=c)}}function sn(e){for(let n=0;n<e.length;n++){let t=e[n];t&&typeof t=="object"&&!Array.isArray(t)&&Ue(t)===null&&(t.key=`pos:${n}`)}}function St(e,n,t,o){ce()?console.error(`[vdom2/audit] I1 \u8FDD\u53CD\uFF1Adiff \u6536\u5230 disposed \u7EC4\u4EF6 ${o}\u2014\u2014\u526A\u679D\u7F13\u5B58\u5931\u6548\uFF08portal \u5185\u5BB9\u72EC\u7ACB dispose\uFF09\u2014\u2014\u7236\u6811\u5C06\u91CD\u5EFA`):console.warn(`[vdom2] disposed \u7EC4\u4EF6 ${o} \u5728 diff\u2014\u2014\u526A\u679D\u7F13\u5B58\u5931\u6548\u2014\u2014\u7236\u6811\u91CD\u5EFA\u4E2D\uFF08\u5360\u4F4D\u515C\u5E95\uFF09`);let r=ue(t.browser??x(),null);if(r==null)return null;let i=n;if(i){let s=i.parentNode;s?s.replaceChild(r,i):e.appendChild(r)}else e.appendChild(r);return r}var xr={unkeyed:mr,keyed:Et,mixed:e=>(sn(e.newChildren),sn(e.oldChildren),Et(e))};function ln(e){let{registry:n,ctx:t}=e,o=new Map;async function r(s){let l=n.idRegistry.get(s);if(!l||!k(l)||typeof l._render!="function")return;let d=l,u=Qe("render");try{let a=await d._render(d.props),c=await J(a,t,d._child,n)??null,f=d._child;if(d._child=c,d._lifecycle==="building"){P({session:u,machine:"render",nodeId:d._id??null,component:Rt(d),from:"IDLE",event:"PARENT",to:"SKIP_BUILDING",payload:()=>({lifecycle:d._lifecycle}),level:"debug",ts:Date.now()});return}let p=d._id!=null&&d._id===t.ui?._rootVNodeId,m=d._parentNode??d._refNode?.parentNode??null;m==null&&p&&(m=e.rootEl??null);let g=m?p&&!d._parentNode?"ROOT":"MOUNTED":"SKIP_DETACHED";if(P({session:u,machine:"render",nodeId:d._id??null,component:Rt(d),from:"IDLE",event:"PARENT",to:g,payload:()=>({lifecycle:d._lifecycle}),level:"debug",ts:Date.now()}),m){let h={browser:t.browser??x(),registry:n,ctxVersion:en(t)},w=ne(m,d._refNode??null,f,c,h);if(d._refNode=w,ce())try{let y=[];Te(m,c,v=>y.push(v)),y.length&&console.error("[vdom2/audit] "+y.join(" | "))}catch(y){console.error("[vdom2/audit] \u6821\u9A8C\u5F02\u5E38:",y)}}}catch(a){e.onError?e.onError(a):console.error("[vdom2] render error:",a?.stack??a)}finally{Ae()}}function i(s){return s==null?Promise.resolve():Promise.all(s.map(l=>{let u=(o.get(l)??Promise.resolve()).then(()=>r(l));return o.set(l,u),u.finally(()=>{o.get(l)===u&&o.delete(l)})})).then(()=>{})}return{render:i}}function Rt(e){return typeof e.type=="function"&&e.type.name?e.type.name:"anonymous"}function At(e){let{ctx:n,browser:t}=e,o=e.registry??ye(),r=e.renderer??ln({registry:o,ctx:n,rootEl:e.root,onError:e.onError}),i=n.ui,s=null,l=null,d={ctx:n,registry:o,renderer:r,async mount(u){s=u;let a=await J(u,n,null,o);e.root.innerHTML="";let c=U(a,n,t);if(c!=null&&e.root.appendChild(c),l=a?._child??a,i&&(i._rootVNodeId=a?._id??null),ce())try{let f=[];Te(e.root,a,p=>f.push(p)),f.length&&console.error("[vdom2/audit] "+f.join(" | "))}catch(f){console.error("[vdom2/audit] \u6821\u9A8C\u5F02\u5E38:",f)}},async rerender(){if(s==null)return;let u=[];for(let[,a]of o.idRegistry)k(a)&&typeof a._render=="function"&&a._id&&u.push(a._id);await r.render(u)},unmount(){for(let[,u]of o.idRegistry)try{H(u,o)}catch{}e.root.innerHTML=""}};return d.close=()=>d.unmount(),d}var It=x();function Lt(e,n="bottom",t=6,o=!0){switch(n){case"bottom":return{top:e.bottom+t,left:o?e.left+e.width/2:e.left};case"top":return{top:e.top-t,left:o?e.left+e.width/2:e.left};case"left":return{top:o?e.top+e.height/2:e.top,left:e.left-t};case"right":return{top:o?e.top+e.height/2:e.top,left:e.right+t}}}function an(e,n,t=8){if(!n)return e;let o=n.getBoundingClientRect();if(o.width===0&&o.height===0)return e;let r=Number.parseFloat(n.style.top)||o.top,i=Number.parseFloat(n.style.left)||o.left,s=e.top-r,l=e.left-i,d={top:o.top+s,bottom:o.bottom+s,left:o.left+l,right:o.right+l},u=It.viewportWidth(),a=It.viewportHeight(),c=e.top,f=e.left;return d.bottom>a-t&&(c=Math.max(t,c-(d.bottom-(a-t)))),d.top<t&&(c=Math.max(t,c+(t-d.top))),d.right>u-t&&(f=Math.max(t,f-(d.right-(u-t)))),d.left<t&&(f=Math.max(t,f+(t-d.left))),{top:c,left:f,width:e.width}}var Pe=x();function Mt(e){let n=new Map,t=new Map,o=!1,r=0;function i(){r||(r=requestAnimationFrame(()=>{r=0;let a=[];for(let[c,f]of n){if(!f.isOpen())continue;let p=f.getEl();if(!p)continue;let m=p.getBoundingClientRect();if(m.width===0&&m.height===0)continue;let g=f.compute(m);Object.assign(f.pos,an(g,f.panel?.(),f.margin)),a.push(c)}for(let[c,f]of t){let p=f.getScroller(),m=p instanceof Window?Pe.scrollingElement()?.scrollTop??Pe.scrollTop():p.scrollTop??0;m!==f.handle.y&&(f.handle.y=m,a.push(c))}a.length>0&&e(a)}))}function s(){o||(o=!0,Pe.addEventListener("scroll",i,{capture:!0,passive:!0}),Pe.addEventListener("resize",i))}function l(){o&&(Pe.removeEventListener("scroll",i,{capture:!0}),Pe.removeEventListener("resize",i),o=!1)}function d(a){for(let c of[...n.keys()])(c.startsWith(`popup:${a}:`)||c===`popup:${a}`||c===a)&&n.delete(c);t.delete(a)}function u(){l(),r&&(cancelAnimationFrame(r),r=0),n.clear(),t.clear()}return{popupTrackers:n,scrollTrackers:t,schedulePopupRecompute:i,ensurePopupListeners:s,destroyPopupListeners:l,cleanupTrackers:d,destroy:u}}function Ln(e,n,t){return r=>{r?n(r):t?.()}}function $e(e){return typeof window<"u"&&!!window.matchMedia?.("(hover: hover)").matches}function dn(e){return typeof window<"u"&&!!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches}function Mn(e,n,t){let o=null,r=()=>{n(),t?.once&&o&&o.removeEventListener("animationend",r)};return s=>{s?(o=s,s.addEventListener("animationend",r)):o&&(o.removeEventListener("animationend",r),o=null)}}function Hn(e,n){let{onLongPress:t,duration:o=500}=n,r,i=0,s=0,l=null,d=()=>{clearTimeout(r),r=void 0},u=e.selfId();if(u){let a=e.onUnmount(c=>{c===u&&(d(),a())})}return{onPointerDown:a=>{i=a.clientX??0,s=a.clientY??0,l=a,d(),r=setTimeout(()=>{r=void 0,l&&t(l)},o)},onPointerUp:d,onPointerLeave:d,onPointerMove:a=>{let c=Math.abs((a.clientX??0)-i),f=Math.abs((a.clientY??0)-s);(c>10||f>10)&&d()},onContextMenu:a=>{a.preventDefault(),t(a)}}}function De(e,n){let t=e.selfId(),o="closed",r,i=()=>{o="closed",t?e.render([t]):e.render()};return{get phase(){return o},ref:l=>{l?r||(r=()=>{o==="exit"&&i()},l.addEventListener("animationend",r)):r=void 0},sync:l=>(l?o="open":o==="open"&&(o="exit"),o)}}function On(e,n,t){let o=e.selfId(),r=dn(e),i=t?.duration??400,s=t?.ease==="linear"?f=>f:f=>1-Math.pow(1-f,3),l,d=n,u={value:r?n:0,reset:()=>{}},a=()=>{o?e.render([o]):e.render()},c=f=>{if(d=f,r){u.value=f,a();return}if(f===u.value)return;l&&cancelAnimationFrame(l);let p=u.value,m=performance.now(),g=h=>{let w=Math.min(1,(h-m)/i);u.value=Math.round(p+(f-p)*s(w)),w<1?(l=requestAnimationFrame(g),a()):(l=void 0,a())};l=requestAnimationFrame(g)};if(u.reset=f=>{f===d&&l||c(f)},o){let f=e.onUnmount(p=>{p===o&&(l&&(cancelAnimationFrame(l),l=void 0),f())})}return queueMicrotask(()=>c(n)),u}function Un(e,n,t){let o=e.selfId(),r=e.browser,i=`media:${o}:${n}`;if(!e.mediaRegistry.has(i)){let s=r.matchMedia(n);t(s.matches);let l=u=>t(u.matches);s.addEventListener("change",l),e.mediaRegistry.set(i,{mql:s,handler:l});let d=e.onUnmount(u=>{if(u!==o)return;let a=e.mediaRegistry.get(i);if(a?.mql&&a.handler)try{a.mql.removeEventListener("change",a.handler)}catch{}e.mediaRegistry.delete(i),d()})}}function $n(e,n,t){let o=e.browser,r=typeof n=="function"?{mobile:"(max-width: 639px)",tablet:"(min-width: 640px) and (max-width: 1023px)",desktop:"(min-width: 1024px)"}:n,i=typeof n=="function"?n:t,s=e.selfId(),l=`bp:${s}`;function d(){for(let[u,a]of Object.entries(r))if(o.matchMedia(a).matches)return u;return Object.keys(r)[0]??""}if(!e.mediaRegistry.has(l)){i(d());let u=[];for(let c of Object.values(r)){let f=o.matchMedia(c),p=()=>i(d());f.addEventListener("change",p),u.push({mql:f,handler:p})}e.mediaRegistry.set(l,{mqls:u});let a=e.onUnmount(c=>{if(c!==s)return;let f=e.mediaRegistry.get(l);if(f?.mqls)for(let p of f.mqls)try{p.mql.removeEventListener("change",p.handler)}catch{}e.mediaRegistry.delete(l),a()})}}function Dn(e){let n=e.selfId(),t=e.browser,o={height:t.viewportHeight(),offsetTop:0,keyboardOpen:!1},r=()=>{n?e.render([n]):e.render()},i=()=>{let l=t.visualViewport();o.height=l?.height??t.viewportHeight(),o.offsetTop=l?.offsetTop??0,o.keyboardOpen=o.height<t.viewportHeight()*.9,r()},s=t.visualViewport();if(s?.addEventListener?(s.addEventListener("resize",i),s.addEventListener("scroll",i)):t.addEventListener("resize",i),n){let l=e.onUnmount(d=>{d===n&&(s?.removeEventListener?(s.removeEventListener("resize",i),s.removeEventListener("scroll",i)):t.removeEventListener("resize",i),l())})}return o}function jn(e,n){let t=e.selfId(),o={isIn:!1,ready:!1,observe:d,refresh:u,disconnect:a},r=null,i=null,s=()=>{t?e.render([t]):e.render()};function l(){if(i?.disconnect(),i=null,!r)return;let c=typeof n.rootMargin=="function"?n.rootMargin():n.rootMargin,f=typeof n.threshold=="function"?n.threshold():n.threshold;i=new IntersectionObserver(p=>{let m=p[p.length-1];if(!m)return;let g=m.isIntersecting,h=g!==o.isIn,w=!o.ready;o.isIn=g,o.ready=!0,n.onChange?.(m,g),(h||w)&&s()},{root:n.root?n.root():null,rootMargin:c??"0px",threshold:f??0}),i.observe(r)}function d(c){r=c,c?l():(i?.disconnect(),i=null,o.isIn=!1)}function u(){l()}function a(){i?.disconnect(),i=null}if(t){let c=e.onUnmount(f=>{f===t&&(a(),c())})}return o}function Wn(e,n){let t=e.selfId(),o=e.browser,r={y:0,refresh(){let l=i.getScroller();r.y=l instanceof Window?o.scrollingElement()?.scrollTop??o.scrollTop():l.scrollTop??0}},i={handle:r,getScroller:n.getScroller??(()=>window)};if(!t)return r.refresh(),r;e.scrollTrackers.set(t,i),e.ensurePopupListeners(),r.refresh();let s=e.onUnmount(l=>{l===t&&(e.scrollTrackers.delete(t),s())});return r}function un(e,n){let t=e.selfId(),o=n.value!==void 0;if(o&&!n.onChange&&n.name&&(e.warned.has(n.name)||(e.warned.add(n.name),console.warn(`[weifuwu/${n.name}] \u53D7\u63A7\u6A21\u5F0F\uFF08value \u5DF2\u4F20\uFF09\u4F46\u672A\u63D0\u4F9B onChange\uFF0C\u4EA4\u4E92\u65E0\u6CD5\u751F\u6548\u3002
4
- \u975E\u53D7\u63A7\uFF1A\u53BB\u6389 value\uFF1B\u53D7\u63A7\uFF1A\u4F20\u5165 onChange={(v) => setValue(v)}`))),!o&&t&&!e.uncontrolledValues.has(t)){e.uncontrolledValues.set(t,n.value);let i=e.onUnmount(s=>{s===t&&(e.uncontrolledValues.delete(t),i())})}let r=i=>{if(o){n.onChange?.(i);return}t&&e.uncontrolledValues.set(t,i),t?e.render([t]):e.render()};return{value:o?n.value:t?e.uncontrolledValues.get(t):n.value,setValue:r,controlled:o}}function Fn(e,n){let t=e.selfId(),o=un(e,{value:n.value,onChange:n.onChange,name:n.name});if(t&&!e.inputStates.has(t)){e.inputStates.set(t,{keyword:"",selectedLabel:""});let s=e.onUnmount(l=>{l===t&&(e.inputStates.delete(t),s())})}let r=t?e.inputStates.get(t):{keyword:"",selectedLabel:""},i=()=>{t?e.render([t]):e.render()};return{...o,get keyword(){return r.keyword},setKeyword(s){r.keyword=s,i()},get selectedLabel(){return r.selectedLabel},setSelectedLabel(s){r.selectedLabel=s,i()}}}function Bn(e,n){let t=e.selfId(),o=!1;if(t){let d=e.onUnmount(u=>{u===t&&(o=!0,d())})}let r=()=>{o||(t?e.render([t]):e.render())},i={data:void 0,loading:!1,error:void 0},s=0,l=()=>{let d=++s;i.loading=!0,i.error=null,r(),Promise.resolve().then(()=>n()).then(u=>{s===d&&(i.data=u,i.loading=!1,r())}).catch(u=>{s===d&&(i.error=u,i.loading=!1,r())})};return l(),i.reload=l,i}function Kn(e,n){let t=e.selfId(),o=e.browser;if(typeof window>"u")return()=>{};if(o.addEventListener("keydown",n),t){let r=e.onUnmount(i=>{i===t&&(o.removeEventListener("keydown",n),r())})}return()=>o.removeEventListener("keydown",n)}function qn(e,n){let t=e.browser,o=0,r=0,i=!1,s=a=>{i&&n.onMove(a,{x:a.clientX-o,y:a.clientY-r})},l=a=>{i&&(i=!1,t.removeEventListener("pointermove",s),t.removeEventListener("pointerup",l),n.onEnd?.(a))},d=a=>{i||(a.preventDefault(),i=!0,o=a.clientX,r=a.clientY,t.addEventListener("pointermove",s),t.addEventListener("pointerup",l),n.onStart?.(a))},u=e.selfId();if(u){let a=e.onUnmount(c=>{c===u&&(i&&(t.removeEventListener("pointermove",s),t.removeEventListener("pointerup",l),i=!1),a())})}return{onPointerDown:d}}function Gn(e,n){let t={};n.onDrop&&(t.onDrop=r=>{r.preventDefault(),n.onDrop(r)}),n.onDragOver&&(t.onDragOver=r=>{r.preventDefault(),n.onDragOver(r)}),n.onDragLeave&&(t.onDragLeave=r=>n.onDragLeave(r));let o={draggable:!0};if(n.onDragStart){let r=n.onDragStart;o.onDragStart=i=>{typeof document<"u"&&document.body.classList.add("wf-dragging"),r(i)}}if(n.onDragEnd){let r=n.onDragEnd;o.onDragEnd=i=>{typeof document<"u"&&document.body.classList.remove("wf-dragging"),r(i)}}return{dropProps:t,dragProps:o}}function fn(e,n){let t=e.selfId(),o={top:0,left:0,refresh:()=>{}};if(!t)return o;let r={pos:o,getEl:n.el,isOpen:n.isOpen,compute:n.compute,panel:n.panel,margin:n.margin??8};e.popupTrackers.set(t,r),e.ensurePopupListeners();let i=e.onUnmount(s=>{s===t&&(e.popupTrackers.delete(t),i())});return o.refresh=()=>{let s=r.getEl();if(!s)return;let l=s.getBoundingClientRect();if(l.width===0&&l.height===0)return;let d=r.compute(l);Object.assign(o,an(d,r.panel?.(),r.margin))},o}function zn(e,n){let t=e.selfId(),o=e.browser,r=$e(e),i=()=>typeof n.trigger=="function"?n.trigger():n.trigger??"manual",s=n.open!==void 0,l=()=>!!n.disabled?.(),d=()=>s?typeof n.open=="function"?!!n.open():!!n.open:n.isOpen(),u=n.presence?De(e,{name:n.name}):null,a,c=!1,f=N=>{if(!u)return N?"open":"closed";let V=u.sync(N);return N&&n.lockScroll&&!c&&(Er(),c=!0),V},p=N=>{l()||(s?n.onOpenChange?.(N):u?N?f(!0):d()&&f(!1):n.setOpen(N))},m=()=>{let N=n.placement;return typeof N=="function"?N():N??"bottom"},g=null,h=!1,w=fn(e,{el:n.el??(()=>null),isOpen:()=>d(),compute:N=>{if(n.position){let V=n.position();return{top:V.y,left:V.x,width:V.width}}return Lt(N,m(),n.gap??6,n.center!==!1)},panel:()=>g,margin:n.margin??8}),y=N=>{if(n.closeOnOutside===!1||n.mask||!d())return;let V=N.target;if(!(V instanceof Node))return;let W=n.el?.()??null;W&&W.contains(V)||g&&g.contains(V)||p(!1)},v=N=>{n.closeOnEscape!==!1&&(N.key!=="Escape"||!d()||p(!1))};if(o.addEventListener("mousedown",y),o.addEventListener("keydown",v),t){let N=e.onUnmount(V=>{V===t&&(o.removeEventListener("mousedown",y),o.removeEventListener("keydown",v),N())})}let b={},I=N=>typeof N=="function"?N():N??0,B=()=>I(n.openDelay),D=()=>I(n.closeDelay),C,T,j=()=>{clearTimeout(C),clearTimeout(T),C=void 0,T=void 0},X=N=>{if(l())return;let V=N.currentTarget,W=N.relatedTarget;V.contains(W)||(clearTimeout(T),T=void 0,C=setTimeout(()=>{C=void 0,p(!0)},B()))},L=N=>{if(l())return;let V=N.currentTarget,W=N.relatedTarget;V.contains(W)||(clearTimeout(C),C=void 0,T=setTimeout(()=>{T=void 0,p(!1)},D()))},$=()=>{l()||(clearTimeout(T),T=void 0,C=setTimeout(()=>{C=void 0,p(!0)},B()))},K=()=>{l()||(clearTimeout(C),C=void 0,T=setTimeout(()=>{T=void 0,p(!1)},D()))},se=()=>i()==="hover";if(b.onMouseOver=N=>{se()&&X(N)},b.onMouseOut=N=>{se()&&L(N)},b.onClick=()=>{se()?r||p(!d()):i()==="click"&&p(!0)},b.onFocus=()=>{se()?$():i()==="focus"&&(clearTimeout(T),T=void 0,p(!0))},b.onBlur=()=>{se()?K():i()==="focus"&&(clearTimeout(C),C=void 0,T=setTimeout(()=>{T=void 0,p(!1)},D()))},i()==="longpress"){let N,V=0,W=0,me=()=>{clearTimeout(N),N=void 0};b.onPointerDown=M=>{l()||(V=M.clientX??0,W=M.clientY??0,me(),N=setTimeout(()=>{N=void 0,n.onTrigger?.({clientX:V,clientY:W}),p(!0)},n.longPressDuration??500))},b.onPointerUp=me,b.onPointerLeave=me,b.onPointerMove=M=>{let mn=Math.abs((M.clientX??0)-V),yn=Math.abs((M.clientY??0)-W);(mn>10||yn>10)&&me()},b.onContextMenu=M=>{M.preventDefault(),n.onTrigger?.({clientX:M.clientX??0,clientY:M.clientY??0}),p(!0)}}if(b.onKeyDown=N=>{N.key==="Escape"&&n.closeOnEscape!==!1&&p(!1)},t){let N=e.onUnmount(V=>{V===t&&(j(),N())})}let Ke=N=>{if(N){g=N;let V=()=>w.refresh();N.addEventListener("animationend",V,{once:!0})}else g=null},le=null,be=null,ge=N=>{Ke(N),be&&be(N),u?.ref(N),n.trapFocus&&(N?a=kr(N):(a?.(),a=void 0)),n.lockScroll&&!N&&c&&(Tr(),c=!1)};return{get open(){return d()},setOpen:p,get phase(){return u?u.phase:d()?"open":"closed"},sync:f,wrapProps:b,portal:(N,V="popover")=>{if(l())return null;if(!(u?u.phase!=="closed":d()))return h=!1,le=null,null;let me=n.el?.()??null;(!h||me!==le)&&(me?w.refresh():queueMicrotask(()=>{d()&&w.refresh()}),h=!0,le=me);let M=N.props??{};be=M.ref??null;let mn=n.positioning==="none"?M.class??"":["wf-popup",M.class].filter(Boolean).join(" "),yn=n.positioning==="none"?{...M.style??{},position:"fixed"}:{...M.style??{},position:"fixed",top:`${w.top}px`,left:`${w.left}px`,...w.width!==void 0?{width:`${w.width}px`}:{},maxWidth:(()=>{let qe=typeof n.width=="function"?n.width():n.width;return qe!==void 0?`min(${qe}px, calc(100vw - 32px))`:"calc(100vw - 32px)"})()},Ce={...N,props:{...M,class:mn,style:yn,ref:ge}};if(n.mask){let qe=typeof n.mask=="object"?n.mask:he("div",{class:"wf-popup-mask","data-portal-mask":V,onClick:n.maskClosable===!1?void 0:()=>p(!1)}),qt=n.maskCentered?he("div",{class:"wf-cover",style:{"--wf-z":"var(--wf-z-popover)",pointerEvents:"none"}},{...Ce,props:{...Ce.props,style:{...M.style??{},pointerEvents:"auto"},ref:ge}}):null,Gt=n.maskCentered?void 0:{...Ce.props?.style??{},zIndex:"var(--wf-z-popover)"},zt=n.maskCentered?qt:{...Ce,props:{...Ce.props,style:Gt}};return Ye([qe,zt],V)}return Ye(Ce,V)},refresh:()=>w.refresh()}}function Yn(e,n){let t=e.selfId();if(t&&!e.openStates.has(t)){e.openStates.set(t,!1);let l=e.onUnmount(d=>{d===t&&(e.openStates.delete(t),l())})}let o=n.open!==void 0;o&&!n.onOpenChange&&n.name&&!e.warned.has(n.name)&&(e.warned.add(n.name),console.warn(`[weifuwu/${n.name}] \u53D7\u63A7\u6A21\u5F0F\uFF08open \u5DF2\u4F20\uFF09\u4F46\u672A\u63D0\u4F9B onOpenChange\uFF0C\u4EA4\u4E92\u65E0\u6CD5\u751F\u6548\u3002
5
- \u975E\u53D7\u63A7\uFF1A\u53BB\u6389 open\uFF1B\u53D7\u63A7\uFF1A\u4F20\u5165 onOpenChange={(o) => setOpen(o)}`));let r=()=>o?!!n.open:t?e.openStates.get(t)??!1:!1,i=()=>{t?e.render([t]):e.render()},s=l=>{if(o){n.onOpenChange?.(l);return}t&&e.openStates.set(t,l),i()};return{get open(){return r()},setOpen:s,triggerProps:{onClick:()=>s(!0),onFocus:()=>{n.openOnFocus&&s(!0)}}}}var we=x(),je=0,Ht="",Ot="",Ut="",$t="",cn=0;function Dt(){return typeof window<"u"&&typeof document<"u"}function Er(){if(je++,je>1||!Dt())return;cn=we.scrollTop();let e=we.bodyElement();Ht=e.style.overflow,Ot=e.style.position,Ut=e.style.top,$t=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=`-${cn}px`,e.style.width="100%")}function Tr(){if(je===0||(je--,je>0)||!Dt())return;let e=we.bodyElement();e.style.overflow=Ht,e.style.position=Ot,e.style.top=Ut,e.style.width=$t,cn>0&&we.scrollTo(cn)}var _r='a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function kr(e){let n;return queueMicrotask(()=>{let t=e.querySelectorAll(_r);if(t.length===0)return;let o=t[0],r=t[t.length-1],i=l=>{l.key==="Tab"&&(l.shiftKey&&we.activeElement()===o?(l.preventDefault(),r.focus()):!l.shiftKey&&we.activeElement()===r&&(l.preventDefault(),o.focus()))},s=we.activeElement();o.focus(),e.addEventListener("keydown",i),n=()=>{e.removeEventListener("keydown",i),s?.focus()}}),()=>n?.()}function Pr(e){return e.map(n=>{let t={role:n.role,content:n.content};return n.reasoning&&(t.reasoning_content=n.reasoning),t})}function Jn(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`msg-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function jt(e,n,t,o){t.initialMessages?e.messages=structuredClone(t.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 r=null;function i(){if(!e.streaming)return;let m=e.messages[e.messages.length-1];return m&&m.role==="assistant"&&m.status==="streaming"?m:void 0}function s(m,g,h){let w=i();switch(m){case"wf:token":w&&(w.content+=g.text);break;case"wf:tool_call":{w&&(w.toolCalls||(w.toolCalls=[]),w.toolCalls.push({call:g,status:"running"}));break}case"wf:tool_progress":{let y=g,v=w?.toolCalls?.find(b=>b.call.id===y.toolCallId);v&&(v.progress=y);break}case"wf:tool_result":{let y=g,v=w?.toolCalls?.find(b=>b.call.id===y.id);v&&(v.result=y,v.status=y.ok?"ok":"error");break}case"wf:approval_request":w&&(w.approval=g);break;case"wf:usage":w&&(w.usage=g);break;case"wf:step":e.step=g;break;case"wf:done":if(w){w.status="done",w.approval=void 0;let y=g;y.reasoning&&(w.reasoning=y.reasoning)}e.streaming=!1,e.step=null;break;case"wf:error":w&&(w.status="error",w.error=g,w.approval=void 0),e.error=g,e.streaming=!1,e.step=null;break;default:h?.(m,g);break}o?.()}function l(){let m=t.body?t.body(e.messages):{messages:Pr(e.messages)};r=n(t.url,m,{onToken:h=>s("wf:token",{text:h}),onToolCall:h=>s("wf:tool_call",h),onToolProgress:h=>s("wf:tool_progress",h),onToolResult:h=>s("wf:tool_result",h),onApproval:h=>s("wf:approval_request",h),onUsage:h=>s("wf:usage",h),onStep:h=>s("wf:step",h),onDone:h=>s("wf:done",h),onError:h=>s("wf:error",h),onEvent:(h,w)=>s(h,w,t.onEvent)},{signal:t.signal,headers:t.headers}),e.streaming=!0;let g=i();g&&r?.traceId&&(g.id=r.traceId)}function d(){if(e.streaming)return;let m=String(e.input??"").trim();m&&(e.input="",e.error=null,e.usage=null,e.step=null,e.messages.push({id:Jn(),role:"user",content:m,status:"done"},{id:Jn(),role:"assistant",content:"",status:"streaming",toolCalls:[]}),l(),o?.())}function u(){r?.abort(),e.streaming=!1,e.step=null;let m=e.messages[e.messages.length-1];m&&m.role==="assistant"&&m.status==="streaming"&&(!m.content&&(!m.toolCalls||m.toolCalls.length===0)?e.messages.pop():m.status="done"),o?.()}function a(){if(e.streaming)return;let m=-1;for(let g=e.messages.length-1;g>=0;g--)if(e.messages[g].role==="user"){m=g;break}m!==-1&&(e.messages.splice(m+1),e.error=null,e.usage=null,e.step=null,e.messages.push({id:Jn(),role:"assistant",content:"",status:"streaming",toolCalls:[]}),l(),o?.())}function c(){r?.abort(),e.messages=[],e.input="",e.streaming=!1,e.error=null,e.usage=null,e.step=null,o?.()}async function f(m,g,h){let w=e.messages[e.messages.length-1],y=w?.role==="assistant"?w.approval:void 0;if(y&&(w.approval=void 0,o?.(),!!t.approveUrl))try{await fetch(t.approveUrl,{method:"POST",headers:{"Content-Type":"application/json",...t.headers},body:JSON.stringify(h?{id:y.id,decision:m,note:g,modifiedArgs:h}:{id:y.id,decision:m,note:g}),signal:t.signal})}catch(v){if(t.signal?.aborted)return;e.error={code:"provider_error",message:v instanceof Error?v.message:String(v)},o?.()}}function p(){r?.abort(),r=null}return{send:d,stop:u,retry:a,clear:c,approve:f,dispose:p}}function Wt(e,n,t){let o=new AbortController,r=t?.signal;r&&(r.aborted?o.abort():r.addEventListener("abort",()=>o.abort(),{once:!0}));let i=t?.traceId??Lr(),s=t?.record!==!1,l=[],d=(async()=>{let u;try{u=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json","X-Trace-Id":i,Accept:"text/event-stream",...t?.headers},body:JSON.stringify(n),signal:o.signal})}catch(a){if(o.signal.aborted)return;t?.onError?.({code:"provider_error",message:a instanceof Error?a.message:String(a)});return}if(!u.ok){t?.onError?.({code:Ir(u.status),message:`HTTP ${u.status} ${u.statusText}`});return}try{for await(let{name:a,data:c}of Rr(u.body)){if(o.signal.aborted)return;Ar(l,{name:a,data:c},s),Sr(a,c,t??{})}}catch(a){if(o.signal.aborted)return;t?.onError?.({code:"provider_error",message:a instanceof Error?a.message:String(a)})}})();return{abort:()=>o.abort(),done:d,traceId:i,events:l}}function Sr(e,n,t){switch(e){case"wf:token":return t.onToken?.(n.text);case"wf:tool_call":return t.onToolCall?.(n);case"wf:tool_result":return t.onToolResult?.(n);case"wf:tool_progress":return t.onToolProgress?.(n);case"wf:step":return t.onStep?.(n);case"wf:approval_request":return t.onApproval?.(n);case"wf:usage":return t.onUsage?.(n);case"wf:done":return t.onDone?.(n);case"wf:error":return t.onError?.(n);default:return t.onEvent?.(e,n)}}async function*Rr(e){let n=e.getReader(),t=new TextDecoder,o="";try{for(;;){let{done:r,value:i}=await n.read();if(r)break;o+=t.decode(i,{stream:!0});let s=o.split(`
1
+ function eo(e){let n=[],t=(e||"/").replace(/:(\w+)/g,(o,r)=>(n.push(r),"([^/]+)")).replace(/\*/g,".*");return{re:new RegExp(`^${t}$`),keys:n}}var hn=class{_routes=[];_middlewares=[];_injections=[];_injected=!1;_mode;_notFound;constructor(n={}){this._mode=n.mode??"history"}get mode(){return this._mode}use(n,t){if(typeof n=="string"&&t){let o=this,r=n,i=async(s,l,d)=>{let u=l.__routePath??o.getPath(),a=null;return u===r?a="/":(r==="/"?u!=="/"&&u.startsWith("/"):u.startsWith(r+"/"))&&(a=u.slice(r.length)),a===null?d:async(c,f)=>{let p=await t._handle(a,c,f);return p===null?d(c,f):p}};return this._middlewares.push(i),this}return n.length<=1?(this._injections.push(n),this):(this._middlewares.push(n),this)}async _ensureInjected(n){if(!this._injected){this._injected=!0;for(let t of this._injections){let o=await t(n);o&&o!==n&&Object.assign(n,o)}}}get(n,t,o){return this._routes.push({path:n,handler:t,title:o?.title}),this}notFound(n){return this._notFound=n,this}getPath(){return this._getPath(void 0)}_getPath(n){let t=n?.location??(typeof window<"u"?window.location:null);return this._mode==="hash"?(t?.hash??"").replace(/^#/,"")||"/":t?.pathname??"/"}match(n){let t=null;for(let o of this._routes){let{re:r,keys:i}=eo(o.path),s=n.match(r);if(!s)continue;let l={};for(let d=0;d<i.length;d++)l[i[d]]=decodeURIComponent(s[d+1]);t={handler:o.handler,params:l,title:o.title};break}return t||(t={handler:this._notFound??(()=>null),params:{}}),t}async _handle(n,t,o){await this._ensureInjected(o);let r=this.match(n);r.title&&typeof document<"u"&&(document.title=r.title),o.params=r.params,o.route&&(o.route.params=r.params);let s=r.handler,l=o.__routePath;o.__routePath=n;try{for(let d=this._middlewares.length-1;d>=0;d--){let u=this._middlewares[d],a=s;s=await u(t,o,a)??a}return await s(t,o)}finally{o.__routePath=l}}async execute(n,t,o){await this._ensureInjected(t);let r=this.match(o);r.title&&typeof document<"u"&&(document.title=r.title),t.params=r.params,t.route&&(t.route.params=r.params);let s=r.handler;for(let l=this._middlewares.length-1;l>=0;l--){let d=this._middlewares[l],u=s;s=await d(n,t,u)??u}return await s(n,t)}};var Q=Symbol("Fragment"),G=Symbol("Portal");function ze(e){return e!=null&&typeof e=="object"&&typeof e.type=="string"}function te(e){return e!=null&&typeof e=="object"&&e.type===Q}function k(e){return e!=null&&typeof e=="object"&&typeof e.type=="function"}function z(e){return e!=null&&typeof e=="object"&&e.type===G}function Ge(e,n,t=null){return{type:e,props:n,key:t,_child:null,_parentNode:null,_refNode:null,_id:null,_customId:null,_parentVNode:null,_ctxVersion:null,_lifecycle:"fresh"}}function Pe(e,n,t=null){return e===Q?{...Ge(e,n,t),type:e}:e===G?{...Ge(e,n,t),type:e,_remoteEl:null,_placement:"remote"}:typeof e=="function"?{...Ge(e,n,t),type:e,_render:null,_outputChild:null}:{...Ge(e,n,t),type:e,el:null}}function he(e,n,...t){let o=tt(n??{});return t.length>0&&(o.children=t.length===1?t[0]:t),Pe(e,o,n?.key??null)}function vn(e,n,t){return Pe(e,tt(n),t??null)}var no=vn;function to(e,n,t){return vn(e,n,t)}function tt(e){if(!e)return{};let n={};for(let t of Object.keys(e))t!=="key"&&(n[t]=e[t]);return n}function P(e){return e==null||typeof e=="boolean"?[]:Array.isArray(e)?e:[e]}function Ye(e,n){let t=Pe(G,{children:e,portalKey:n});return t.key=n??null,t}function V(){return{activeElement:()=>typeof document<"u"?document.activeElement:null,byId:e=>typeof document<"u"?document.getElementById(e):null,query:e=>typeof document<"u"?document.querySelector(e):null,queryAll:e=>typeof document<"u"?document.querySelectorAll(e):null,createElement:e=>typeof document<"u"?document.createElement(e):null,createElementNS:(e,n)=>typeof document<"u"?document.createElementNS(e,n):null,createDocumentFragment:()=>typeof document<"u"?document.createDocumentFragment():null,createComment:e=>typeof document<"u"?document.createComment(e):null,createTextNode:e=>typeof document<"u"?document.createTextNode(e):null,addEventListener:(e,n,t)=>{typeof window<"u"&&window.addEventListener(e,n,t)},removeEventListener:(e,n,t)=>{typeof window<"u"&&window.removeEventListener(e,n,t)},scrollTo:e=>{typeof window<"u"&&window.scrollTo(0,e)},matchMedia:e=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia(e):null,visualViewport:()=>(typeof window<"u"?window:null)?.visualViewport??null,scrollingElement:()=>typeof document<"u"?document.scrollingElement:null,bodyElement:()=>typeof document<"u"?document.body:null,bodyAppend:e=>{typeof document<"u"&&document.body.appendChild(e)},bodyRemove:e=>{typeof document<"u"&&e.parentNode&&document.body.removeChild(e)},clearBody:()=>{typeof document<"u"&&(document.body.innerHTML="")},event:(e,n)=>{let t=typeof window<"u"?window:null,o=n&&(n.key||n.code)?"KeyboardEvent":n&&(n.clientX!==void 0||n.clientY!==void 0||n.pointerId!==void 0)?"PointerEvent":"Event";try{return new t[o](e,n)}catch{return new t.Event(e,n)}},dispatchEvent:(e,n)=>typeof e<"u"?e.dispatchEvent(n):!1,reload:()=>{typeof window<"u"&&window.location.reload()},navigate:e=>{typeof window>"u"||(window.history.pushState(null,"",e),window.dispatchEvent(new PopStateEvent("popstate",{state:null})))},downloadFile:(e,n,t="text/plain")=>{try{if(typeof document>"u"||typeof URL>"u"||!URL.createObjectURL)return!1;let o=new Blob([n],{type:t}),r=URL.createObjectURL(o),i=document.createElement("a");return i.href=r,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i),setTimeout(()=>URL.revokeObjectURL(r),1e3),!0}catch{return!1}},copyText:async e=>{let n=typeof window<"u"?window:null;if(n?.navigator?.clipboard?.writeText)try{return await n.navigator.clipboard.writeText(e),!0}catch{}try{if(typeof document>"u")return!1;let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();let o=document.execCommand("copy");return document.body.removeChild(t),o}catch{return!1}},execCommand:(e,n)=>typeof document<"u"?document.execCommand(e,!1,n):!1,queryCommandState:e=>typeof document<"u"?document.queryCommandState(e):!1,queryCommandValue:e=>typeof document<"u"?document.queryCommandValue(e):"",selectionText:()=>typeof window<"u"?window.getSelection?.()?.toString()??null:null,getSelection:()=>typeof window<"u"?window.getSelection():null,viewportHeight:()=>typeof window<"u"?window.innerHeight:0,viewportWidth:()=>typeof window<"u"?window.innerWidth:0,pathname:()=>typeof window<"u"?window.location.pathname:"",createTreeWalker:(e,n)=>typeof document<"u"?document.createTreeWalker(e,n??NodeFilter.SHOW_ALL):null,scrollTop:()=>{let e=typeof document<"u"?document:null,n=typeof window<"u"?window:null;return e?.scrollingElement?.scrollTop??n?.scrollY??0},hash:()=>typeof window<"u"?window.location?.hash??"":"",setHash:e=>{typeof window<"u"&&(window.location.hash=e)},timeout:(e,n)=>typeof window<"u"?window.setTimeout(e,n):0,rootElement:()=>typeof document<"u"?document.documentElement:null,storageGet:e=>{try{return typeof window<"u"?window.localStorage?.getItem(e)??null:null}catch{return null}},storageSet:(e,n)=>{try{typeof window<"u"&&window.localStorage?.setItem(e,n)}catch{}}}}function oo(e,n,t=400){let o=!1,r=()=>{o||(o=!0,e.removeEventListener("animationend",r),clearTimeout(i),n())};e.addEventListener("animationend",r);let i=setTimeout(r,t)}function xe(e,n){return Object.assign(Object.create(e),n)}function ro(e){let n={baseURL:e?.baseURL??"",headers:{"Content-Type":"application/json",...e?.headers}},t=e?.onRequest,o=e?.onResponse,r=e?.timeout??0;async function i(s,l,d,u,a=!1){let c=n.baseURL+l,f={method:s,headers:{...n.headers,...u?.headers}},p=e?.token?.();p&&!f.headers.Authorization&&(f.headers.Authorization=`Bearer ${p}`);let m=r>0,g=!!u?.signal,h=null,w=null;(m||g)&&(h=new AbortController,f.signal=h.signal,m&&(w=setTimeout(()=>h.abort(new Error("Request timed out")),r)),g&&u.signal.addEventListener("abort",()=>h.abort())),d!==void 0&&s!=="GET"&&s!=="HEAD"&&(f.body=JSON.stringify(d));let y={url:c,init:f};t&&(y=t(y));try{let v=await fetch(y.url,y.init);if(v.status===401&&await e?.onUnauthorized?.()&&!a)return i(s,l,d,u,!0);if(o)return o(v);if(!v.ok){let K=await v.text().catch(()=>"");throw new Nn(v.status,K||v.statusText)}let b=v.headers.get("content-length");if(v.status===204||b==="0")return;let I=(v.headers.get("content-type")||"").toLowerCase();return I.includes("application/json")||I.includes("json")?v.json():v.text()}finally{w&&clearTimeout(w)}}return s=>xe(s,{api:{get:(d,u)=>i("GET",d,void 0,u),post:(d,u,a)=>i("POST",d,u,a),put:(d,u,a)=>i("PUT",d,u,a),patch:(d,u,a)=>i("PATCH",d,u,a),delete:(d,u)=>i("DELETE",d,void 0,u)}})}var Nn=class extends Error{status;body;constructor(n,t){super(`API Error ${n}: ${t}`),this.name="ApiError",this.status=n,this.body=t}};function io(e){try{let n=e.split(".");if(n.length!==3)return null;let t=n[1].replace(/-/g,"+").replace(/_/g,"/");return JSON.parse(atob(t))}catch{return null}}function so(e){let n=io(e);return n?.exp?n.exp*1e3-3e4<Date.now():!0}function lo(e){let n=e?.storage??localStorage,t=e?.tokenKey??"weifuwu_token",o=e?.userKey??"weifuwu_user",r=e?.refreshTokenKey??"weifuwu_refresh",i=e?.refreshEndpoint??"/api/auth/refresh";return s=>{let l=n.getItem(t),d=n.getItem(o),u=null,a={token:l,user:d?JSON.parse(d):null,get isLoggedIn(){return this.token!==null},login(f,p,m){a.token=f,a.user=p,n.setItem(t,f),n.setItem(o,JSON.stringify(p)),m&&n.setItem(r,m)},logout(){a.token=null,a.user=null,n.removeItem(t),n.removeItem(o),n.removeItem(r)},setUser(f){a.user=f,n.setItem(o,JSON.stringify(f))},async refresh(){return u||(u=c().finally(()=>{u=null}),u)}};async function c(){let f=n.getItem(r);if(!f)return!1;let p=n.getItem(t);try{let m=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:f})});if(n.getItem(t)!==p)return!1;if(!m.ok)return a.logout(),!1;let g=await m.json();return n.getItem(t)!==p?!1:(a.token=g.token,n.setItem(t,g.token),g.refreshToken&&n.setItem(r,g.refreshToken),!0)}catch{return!1}}return l&&so(l)&&a.refresh().catch(()=>{}),e?.onAuth?.(a),xe(s,{auth:a})}}function ao(e={}){let n=e.url??"/ws",t=e.reconnectInterval??3e3,o=e.maxReconnect??10,r=e.pingInterval??3e4,i=e.pingTimeout??1e4;return s=>{let l=new Set,d=null,u=0,a=null,c=null,f=null,p=!1,m=[],g={isConnected:!1,onMessage:b=>(l.add(b),()=>{l.delete(b)}),send:b=>{let I=JSON.stringify(b);d?.readyState===WebSocket.OPEN?d.send(I):m.push(I)},_connect:h,close:()=>{p=!0,v(),d?.close(),d=null,m=[],g.isConnected=!1}};async function h(){if(!p)try{d=new WebSocket(n),d.onopen=()=>{g.isConnected=!0,u=0;for(let b of m)d.send(b);m=[],w()},d.onmessage=b=>{try{let I=JSON.parse(b.data);for(let K of l)K(I)}catch{}y()},d.onclose=()=>{g.isConnected=!1,v(),!p&&u<o&&(u++,a=setTimeout(h,t*Math.min(u,5)))},d.onerror=()=>{d?.close()}}catch{p||(a=setTimeout(h,t))}}function w(){r<=0||(c=setInterval(()=>{d?.readyState===WebSocket.OPEN&&d.send(JSON.stringify({type:"ping"})),f=setTimeout(()=>{d?.close()},i)},r))}function y(){clearTimeout(f)}function v(){clearInterval(c),clearTimeout(f),clearTimeout(a)}return h(),xe(s,{ws:g})}}var ot={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",closeAria:"\u5173\u95ED"},Confirm:{confirmText:"\u786E\u5B9A",cancelText:"\u53D6\u6D88"},Drawer:{ariaLabel:"\u4FA7\u8FB9\u9762\u677F",closeAria:"\u5173\u95ED"},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 rt={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",closeAria:"Close"},Confirm:{confirmText:"OK",cancelText:"Cancel"},Drawer:{ariaLabel:"Panel",closeAria:"Close"},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 Je={"zh-CN":ot,"en-US":rt};function it(e){if(Je[e])return e;let n=e.split("-")[0];return Object.keys(Je).find(o=>o.startsWith(n))??"zh-CN"}function uo(e={}){let{locale:n="zh-CN",messages:t={},components:o={}}=e,r=it(n),i=Je[r],s=st(i,t,o),l={locale:r,t:(d,u)=>s.messages?.[d]??u??d,setLocale:()=>{},components:s.components};return d=>{let u=d;return u.i18n=l,l.setLocale=a=>{let c=it(a),f=Je[c];f&&(s=st(f,t,o),l.locale=c,l.components=s.components,u.ui?.bumpCtxVersion?.(),u.ui?.render())},d}}function st(e,n,t){return{messages:{...e?.messages,...n},components:co(e?.components??{},t)}}function co(e,n){let t={...e};for(let o of Object.keys(n))typeof n[o]=="object"&&n[o]!==null&&typeof t[o]=="object"?t[o]={...t[o],...n[o]}:t[o]=n[o];return t}var fo={route:"route",lifecycle:"lifecycle",x2y:"diff",keys:"diff",pos:"diff",render:"render",audit:"audit",build:"build",mount:"mount",diff:"diff"};function at(e){return fo[e]}var Ve=new Set;function Qe(e){return Ve.add(e),()=>{Ve.delete(e)}}var Xe=[],po=0;function Ze(e){let n=`R${++po}${e?":"+e:""}`;return Xe.push(n),n}function Ae(){Xe.pop()}function mo(){return Xe[Xe.length-1]??""}function S(e){if(Ve.size!==0){e.session||(e.session=mo()),typeof e.payload=="function"&&(Ve.size>1||E(at(e.machine),e.level??"debug"))&&(e.payload=e.payload());for(let n of Ve)try{n(e)}catch{}}}function dt(){return Ve.size>1}function yo(e){if(e==null)return"";if(typeof e=="string")return` ${e}`;if(typeof e=="object"){let n=e,t=[];for(let o of["path","i","key","mode","kind","insertedBefore","after","depth"])if(n[o]!==void 0){let r=n[o];t.push(`${o}=${typeof r=="object"?JSON.stringify(r):String(r)}`)}return t.length?" "+t.join(" "):""}return` ${String(e)}`}function go(e){let n=at(e.machine);if(!E(n,e.level??"debug"))return;if(e.event==="TRACE"){console.log(`[vdom:${e.machine}] ${e.payload}`);return}let t=e.component?`${e.component}${e.nodeId?`(${e.nodeId})`:""}`:e.nodeId?`(${e.nodeId})`:"";console.log(`[vdom:${e.machine}] ${t?t+" ":""}${e.from} --${e.event}--> ${e.to}${yo(e.payload)}`)}Qe(go);var ho=500,Re=[],lt=!1;function vo(e){Re.push(e),Re.length>ho&&Re.shift()}function ut(){lt||(lt=!0,Qe(vo))}function ct(){ut()}function ft(e=50,n){return ut(),n?Re.filter(t=>Object.entries(n).every(([o,r])=>t[o]===r)).slice(-e):Re.slice(-e)}var No={fresh:{BUILD_START:"building",BUILD_DONE:"built",PRUNE:"pruned",DISPOSE:"disposed"},building:{BUILD_DONE:"built",DISPOSE:"disposed"},built:{BUILD_START:"building",PRUNE:"pruned",DISPOSE:"disposed"},pruned:{BUILD_START:"building",PRUNE:"pruned",DISPOSE:"disposed"},disposed:{BUILD_START:"building"}};function Z(e){let n=0,t=e._parentVNode??null;for(let o=0;o<10&&t;o++)n++,t=t._parentVNode??null;return{name:typeof e.type=="function"?e.type.name||"anonymous":String(e.type),id:e._id??null,depth:n}}var en=new Map,wo=50;function bo(e,n,t,o){if(!e?.id)return;let r=en.get(e.id);r||(r={name:e.name??"?",events:[]},en.set(e.id,r)),r.events.push(`${n}--${t}-->${o}`),r.events.length>wo&&r.events.shift()}function pt(e){if(e){let n=en.get(e);return n?`${n.name}(${e}): ${n.events.join(" \u2192 ")}`:`no timeline for ${e}`}return[...en.entries()].map(([n,t])=>`${t.name}(${n}): ${t.events.join(" \u2192 ")}`).join(`
2
+ `)}function ee(e,n,t){let o=No[e]?.[n]??null;return o==null?(S({session:"",machine:"lifecycle",nodeId:t?.id??null,component:t?.name??null,from:e,event:n,to:"?",level:"warn",ts:Date.now()}),e):(bo(t,e,n,o),S({session:"",machine:"lifecycle",nodeId:t?.id??null,component:t?.name??null,from:e,event:n,to:o,payload:()=>({depth:t?.depth??0}),level:"debug",ts:Date.now()}),o)}function Ee(e){return!e||e._lifecycle==="disposed"||e._child==null?!1:!wn(e._child)}function wn(e){if(e==null||typeof e!="object")return!1;if(Array.isArray(e)){for(let t of e)if(wn(t))return!0;return!1}let n=e;return!!(n._lifecycle==="disposed"||n._child!=null&&wn(n._child))}var bn={error:0,warn:1,info:2,debug:3,trace:4},yt=["mount","build","render","diff","lifecycle","route","audit"],oe={enabled:!1,stages:new Set,level:"info",filter:null},Cn=!1;function Co(e){return e&&e in bn?e:"info"}function mt(e){let n=new Set;if(!e)return n;for(let t of e.split(",")){let o=t.trim().split(":")[0];yt.includes(o)&&n.add(o)}return n}function Vn(){if(Cn)return oe;Cn=!0;try{let e=globalThis,n=new URLSearchParams(typeof e.location?.search=="string"?e.location.search:""),t=n.get("vdom_trace"),o=n.get("vdom_debug"),r=e.__vdom_trace__,i=typeof e.localStorage?.getItem=="function"?e.localStorage.getItem("vdom_trace"):null;if(o==="1"||e?.localStorage?.getItem?.("__WF_VDOM_DEBUG")==="1")oe={enabled:!0,stages:new Set(yt),level:"debug",filter:null};else if(t||r||i){let s=new Set;if(t)for(let l of mt(t))s.add(l);if(r?.stages){let l=Array.isArray(r.stages)?r.stages:[...r.stages];for(let d of l)s.add(d)}if(i)for(let l of mt(i))s.add(l);oe={enabled:!0,stages:s,level:t?.includes(":")?Co(t.split(":")[1]):r?.level??"debug",filter:typeof r?.filter=="string"?r.filter:null}}}catch{}return oe}function E(e,n="info"){return!oe.enabled&&(Cn||Vn(),!oe.enabled)||oe.stages.size&&!oe.stages.has(e)?!1:bn[n]<=bn[oe.level]}function _(e,n,t,...o){if(!E(e,n)&&!dt())return;let r=oe.filter;r&&!t.includes(r)||S({session:"",machine:e,nodeId:null,component:null,from:"",event:"TRACE",to:"",payload:()=>o.length?`${t} ${o.join(" ")}`:t,level:n,ts:Date.now()})}var xo=0;function gt(e){return`R${++xo}${e?`:${e}`:""}`}function Y(e,n=12){if(!e)return"\u2205";if(typeof e=="string"||typeof e=="number")return`"${e}"`;if(!Array.isArray(e))return ve(e);let t=e.slice(0,n).map(ve);return e.length>n&&t.push(`\u2026+${e.length-n}`),`[${t.join(" | ")}]`}function ht(e){return typeof e=="function"?"function":e===Q?"fragment":typeof e=="string"?"string":"other"}var Vo={function:e=>e.name||"Comp",fragment:()=>"Frag",string:e=>String(e),other:e=>String(e)},Eo={function:e=>e.name||"anonymous",fragment:()=>"Fragment",string:e=>String(e),other:e=>e===G?"Portal":String(e)};function ve(e){if(e==null||typeof e=="boolean")return String(e);if(typeof e=="string")return`"${e.slice(0,16)}"`;if(typeof e=="number")return String(e);if(Array.isArray(e))return`ARR(${e.length})`;let n=e,t=n.type,o=Vo[ht(t)](t),r=n.props?.id?`#${n.props.id}`:n.key!=null?`@${n.key}`:"";return o+r}function J(e){if(!e)return"null";if(e.nodeType===1){let n=e;return`${n.tagName}${n.id?`#${n.id}`:""}${n.getAttribute?.("data-wf-key")?`@${n.getAttribute("data-wf-key")}`:""}`}return e.nodeType===3?`"${(e.textContent??"").slice(0,12)}"`:e.nodeType===8?`<!--${(e.nodeValue??"").slice(0,40)}-->`:`#${e.nodeType}`}function de(e,n=12){if(!e)return"null";let o=Array.from(e.childNodes).slice(0,n).map(J);return e.childNodes.length>n&&o.push(`\u2026+${e.childNodes.length-n}`),`[${o.join(" | ")}]`}function xn(e,n=0){if(e==null||typeof e=="boolean")return[];if(typeof e=="string"||typeof e=="number")return[`${" ".repeat(n)}"${String(e).slice(0,20)}"`];if(Array.isArray(e))return e.flatMap(u=>xn(u,n));let t=e,o=t.type,r=Eo[ht(o)](o),i=t._lifecycle?`[${t._lifecycle}]`:"",s=t._id?`(${t._id})`:"",l=[`${" ".repeat(n)}${r}${s}${i}`],d=t._child;return d!=null&&l.push(...xn(d,n+1)),l}function vt(e){let n=globalThis;if(n.__vdom_dump==null&&(n.__vdom_dump=()=>xn(e()??null).join(`
3
+ `)),n.__vdom_lc==null&&(n.__vdom_lc=t=>pt(t)),n.__vdom_events==null){let t=ft;n.__vdom_events=(o,r)=>t(o,r)}}function R(e){return typeof e=="function"&&e.name||"anonymous"}function nn(e){return e.ui?._ctxVersion??0}function En(e,n){e.ui?.setMounting?.(n)}var To=0;function ue(){return{idRegistry:new Map,unmountHooks:[],nextId:()=>`_wf_${To++}`}}function tn(e,n){return e.unmountHooks.push(n),()=>{let t=e.unmountHooks.indexOf(n);t>=0&&e.unmountHooks.splice(t,1)}}function Nt(e,n){for(let t of[...e.unmountHooks])t(n);e.idRegistry.delete(n),e.idRegistry.delete(`custom:${n}`)}function _o(e,n,t,o){try{e(n)}catch(r){console.error(`[weifuwu] ref ${t} error in <${o??"anonymous"}>`,r)}}function H(e,n){if(e==null||typeof e!="object")return;let t=e;if(t._id){let o=Z(t);if(t._customId&&n.idRegistry.delete(t._customId),n.idRegistry.delete(t._id),n.unmountHooks.length>0){let r=[...n.unmountHooks];for(let i of r)i(t._id);if(t._customId)for(let i of r)i(t._customId)}t._id=null,t._customId=null,k(t)&&(t._render=null),t._parentNode=null,t._refNode=null,t._lifecycle=ee(t._lifecycle,"DISPOSE",o)}else(k(t)||t._child!=null)&&(t._lifecycle=ee(t._lifecycle,"DISPOSE",Z(t)));if(t._child!=null){if(Array.isArray(t._child))for(let o of t._child)o&&typeof o=="object"&&H(o,n);else H(t._child,n);t._child=null}if(t.props?.children&&typeof t.type=="string"){let o=Array.isArray(t.props.children)?t.props.children:[t.props.children];for(let r of o)r&&typeof r=="object"&&H(r,n)}if(typeof t.props?.ref=="function"&&_o(t.props.ref,null,"cleanup"),z(t)){let o=t._remoteEl;if(o){let r=t._child;if(r!=null)if(Array.isArray(r))for(let i of r)i&&typeof i=="object"&&H(i,n);else typeof r=="object"&&H(r,n);o.remove(),t._remoteEl=null}}}function A(e,n){if(e==null||typeof e!="object")return null;if(Array.isArray(e)||te(e)){let o=n;if(o&&o.nodeType===8&&o.nodeValue?.includes("type=fragment-start")){let r=[o],i=/fid=([^\s"]+)/.exec(o.nodeValue)?.[1]??"",s=o.nextSibling;for(;s&&(r.push(s),!(s.nodeType===8&&s.nodeValue?.includes("type=fragment-end")&&(/fid=([^\s"]+)/.exec(s.nodeValue)?.[1]??i)===i));)s=s.nextSibling;return r}return null}let t=e;return k(t)?A(t._outputChild??t._child,n):null}function U(e){if(e==null||typeof e=="boolean")return"hole";if(typeof e=="string"||typeof e=="number")return"text";if(Array.isArray(e))return"arr";let n=e;return te(n)?"frag":z(n)?"portal":k(n)?"comp":"native"}function Tn(e){let n=!1,t=!1;for(let o of e){if(o==null||typeof o=="boolean"||typeof o=="string"||typeof o=="number")continue;if(Array.isArray(o)){t=!0;continue}let r=o;z(r)||(r.key!=null?n=!0:t=!0)}return n&&t?"mixed":n?"keyed":"unkeyed"}function ko(e){if(e===!1)return"false";if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0)return"true";if(typeof e=="object")try{let n=JSON.stringify(e);return`object ${n!=null&&n.length>80?n.slice(0,80)+"\u2026":n??""}`}catch{return`object ${Object.prototype.toString.call(e)}`}return`bad-vnode type=${typeof e}`}function on(e){return/[\s"=]/.test(e)?`"${e.replace(/"/g,"'")}"`:e}function F(e){let n=[`type=${e.type}`];return e.value!==void 0&&n.push(`value=${on(ko(e.value))}`),e.key!=null&&n.push(`key=${on(e.key)}`),e.id!=null&&n.push(`id=${on(e.id)}`),e.fid!=null&&n.push(`fid=${on(e.fid)}`),`wf-hole: ${n.join(" ")}`}function bt(e){return typeof e!="string"&&typeof e!="function"&&e!==Q&&e!==G}function Ct(e){for(let n=0;n<e.length;n++){let t=e[n];if(t!=null&&typeof t=="object"&&!Array.isArray(t)){let o=t;o.key!==null&&(o.key=String(o.key))}}}var So=/^on[A-Z]/,Po=/^on[A-Z].*Capture$/;function _n(e){let n=Po.test(e);return{type:(n?e.slice(2,-7):e.slice(2)).toLowerCase(),capture:n}}var kn=new Set(["draggable","contenteditable","spellcheck","translate"]),Ro=new Set(["zIndex","opacity","lineHeight","fontWeight","fontSizeAdjust","flex","flexGrow","flexShrink","order","zoom","aspectRatio","gridRow","gridColumn","scale","rotate","animationIterationCount","columnCount","fillOpacity","strokeOpacity","stopOpacity","floodOpacity"]);function Sn(e){return kn.has(e.toLowerCase())?"enumerated":e==="class"||e==="className"?"class":e==="style"?"style":e==="ref"?"ref":So.test(e)?"event":e==="value"?"value":e==="indeterminate"?"indeterminate":e==="innerHTML"?"innerHTML":e.startsWith("aria-")?"aria":"default"}function wt(e,n,t){if(t!==!1){if(t===!0){e.setAttribute(n,"");return}try{e[n]=t,e.getAttribute(n)!==String(t)&&e.setAttribute(n,String(t))}catch{e.setAttribute(n,String(t))}}}var Ao={enumerated:(e,n,t)=>{e.setAttribute(n,t?"true":"false")},class:(e,n,t)=>{if(t!==!1)if(typeof t=="object")for(let[o,r]of Object.entries(t))r&&e.classList.add(o);else e.setAttribute("class",String(t))},style:(e,n,t)=>{if(t!==!1)if(typeof t=="string")e.setAttribute("style",t);else{let o=e.style;for(let[r,i]of Object.entries(t))i==null?o[r]="":r.startsWith("--")?o.setProperty(r,String(i)):typeof i=="number"&&!Ro.has(r)?o[r]=`${i}px`:o[r]=String(i)}},ref:(e,n,t)=>{if(typeof t=="function")try{t(e)}catch(o){console.error("[weifuwu] ref error",o)}},event:(e,n,t)=>{if(t===!1)return;let{type:o,capture:r}=_n(n);if(typeof t!="function"){console.warn(`[weifuwu] event prop ${n} expects a function, got ${typeof t} \u2014 ignored`);return}e.addEventListener(o,t,r?{capture:!0}:{})},value:(e,n,t)=>{t!==!1&&(e.value=t)},indeterminate:(e,n,t)=>{t!==!1&&(e.indeterminate=!!t)},innerHTML:(e,n,t)=>{t!==!1&&(e.innerHTML=String(t??""))},aria:(e,n,t)=>{if(t!==!1){if(typeof t=="boolean"){e.setAttribute(n,t?"true":"false");return}wt(e,n,t)}},default:wt};function re(e,n,t){t!=null&&Ao[Sn(n)](e,n,t)}function ce(e,n){return e.createComment(F({type:"hole",value:n,key:null,id:null,fid:null}))}function fe(){return!!globalThis?.__WF_VDOM_AUDIT}var xt=!1;function Vt(){xt||(xt=!0,Qe(e=>{e.machine!=="render"||e.event!=="PARENT"||fe()&&e.to==="SKIP_DETACHED"&&console.error(`[vdom2/audit] \u6302\u8F7D\u4E0D\u53D8\u91CF\u8FDD\u53CD\uFF1A\u7EC4\u4EF6 ${e.component??"?"}${e.nodeId?`(${e.nodeId})`:""} \u72B6\u6001 ${String(e.payload?.lifecycle)} \u4F46\u65E0 _parentNode/_refNode\uFF08rootEl \u53EA\u5C5E\u4E8E\u6839\u7EC4\u4EF6\uFF09\u2014\u2014\u6302\u8F7D\u4FE1\u606F\u65AD\u88C2\uFF0C\u6E32\u67D3\u88AB\u8DF3\u8FC7\uFF0C\u72B6\u6001\u66F4\u65B0\u5C06\u4E22\u5931`)}))}function rn(e,n,t){if(n==null||n.length===0)return;let o=Array.from(e.childNodes);if(!n.some(i=>{if(i==null||typeof i!="object")return!1;if(Array.isArray(i))return!0;let s=i.type;return s===Q||s===G}))for(let i=0;i<n.length;i++){let s=n[i];if(s==null||typeof s=="boolean"){let l=o[i];(!l||l.nodeType!==8||!l.nodeValue?.includes("type=hole"))&&t(`[audit] \u5360\u4F4D\u9519\u4F4D\uFF1A\u4F4D\u7F6E ${i} \u671F\u671B\u6CE8\u91CA(wf-hole)\uFF0C\u5B9E\u9645 ${l?.nodeName??"null"}\uFF08${e.nodeName}\uFF09`)}else if(typeof s=="string"||typeof s=="number"){let l=o[i];l&&l.nodeType!==3&&t(`[audit] \u6587\u672C\u9519\u4F4D\uFF1A\u4F4D\u7F6E ${i} \u671F\u671B\u6587\u672C\u8282\u70B9\uFF0C\u5B9E\u9645 ${l.nodeName}\uFF08${e.nodeName}\uFF09`)}}}function Te(e,n,t){Io[U(n)](e,n,t)}var Io={hole:()=>{},text:()=>{},arr:Lo,portal:()=>{},frag:Mo,comp:Ho,native:Oo};function Lo(e,n,t){let o=n;rn(e,o,t);for(let r of o)if(r!=null&&typeof r=="object"&&Array.isArray(r))for(let i of r)Te(e,i,t);else r!=null&&typeof r=="object"&&!Array.isArray(r)&&te(r)&&rn(e,P(r.props?.children),t)}function Mo(e,n,t){rn(e,P(n.props?.children),t)}function Ho(e,n,t){let o=n,r=o._refNode;r&&r.parentNode!==e&&t(`[audit] \u7EC4\u4EF6\u951A\u70B9\u9519\u4F4D\uFF1A${R(o.type)} _refNode \u4E0D\u5728\u7236\u8282\u70B9\u5185`),o._child!=null&&Te(e,o._child,t)}function Oo(e,n,t){let o=n;if(bt(o.type))return;let r=o.el??o._refNode;if(r&&r.nodeType===1&&r.tagName.toLowerCase()!==String(o.type)&&t(`[audit] \u5143\u7D20\u7C7B\u578B\u9519\u4F4D\uFF1A\u671F\u671B <${String(o.type)}>\uFF0C\u5B9E\u9645 ${r.tagName}`),r&&r.nodeType===1&&!("innerHTML"in(o.props??{}))){rn(r,P(o.props?.children),t);for(let i of P(o.props?.children))i!=null&&typeof i=="object"&&!Array.isArray(i)&&k(i)&&Te(r,i,t)}}function Uo(e,n){if(e===n)return!0;let t=Object.keys(e),o=Object.keys(n);if(t.length!==o.length)return!1;for(let r of t)if(e[r]!==n[r])return!1;return!0}async function $o(e,n,t,o){let r=e;r._id||(o?.reuse?._id?r._id=o.reuse._id:r._id=t.nextId(),t.idRegistry.set(r._id,r)),o?.reuse&&(o.reuse._parentNode&&(r._parentNode=o.reuse._parentNode),o.reuse._refNode&&(r._refNode=o.reuse._refNode),o.reuse._ctxVersion!=null&&(r._ctxVersion=o.reuse._ctxVersion));let i=Object.create(n);i.ui=Object.create(n.ui);let s=i.ui;if(s._selfId=r._id??null,s._selfVNode=r,s.render=function(l){let d=n.ui;return l==null&&r._id?d.render([r._id]):d.render(l)},typeof r._render!="function"&&k(o?.reuse)&&typeof o.reuse._render=="function"&&(r._render=o.reuse._render),typeof r._render!="function"){En(n,!0);let l;try{l=await r.type(r.props??{},i)}finally{En(n,!1)}if(typeof l!="function")throw new Error(`Component ${R(e.type)} must return a render function. Use (init_props, ctx) => (props) => VNode pattern.`);r._render=l}return{renderFn:r._render,childCtx:i}}function Pn(e){return!!e&&typeof e.then=="function"}function B(e,n,t,o,r){return Do[U(e)](e,n,t,o,r)}function Rn(e,n){return e!=null&&typeof e=="object"&&!Array.isArray(e)&&e.type===n.type?e:null}var Do={hole:e=>e,text:e=>e,arr:jo,comp:Wo,frag:Fo,native:Et,portal:Et};function jo(e,n,t,o,r){let i=e;E("build")&&_("build","debug","",`array in kids=${Y(i)}`);for(let a of i)if(a!=null&&typeof a=="object"&&!Array.isArray(a)&&a._lifecycle==="disposed"){let c=a;S({session:"",machine:"audit",nodeId:c._id??null,component:R(c.type),from:"disposed",event:"CONTRACT_VIOLATION",to:"new-tree",level:"error",ts:Date.now()}),fe()&&console.error(`[vdom2/audit] \u4E24\u9636\u6BB5\u5951\u7EA6\u8FDD\u53CD\uFF1A\u7EC4\u4EF6 ${R(c.type)} \u7684 renderFn \u8FD4\u56DE\u4E86 disposed \u65E7 vnode${c._id?`(${c._id})`:""}\u2014\u2014\u590D\u7528\u65E7\u6811\u5BF9\u8C61\uFF08\u5E94\u4E3A\u6BCF\u6B21\u6E32\u67D3\u751F\u6210\u65B0 vnode\uFF09\u3002\u540C\u4E00\u5BF9\u8C61\u65E2\u662F\u65E7\u6811\u53C8\u88AB dispose \u2192 diff \u81EA dispose \u2192 \u5361\u7247\u9519\u4F4D/\u6D88\u5931\uFF08demo \u641C\u7D22\u6062\u590D\u4E8B\u6545\uFF09`);break}for(let a=0;a<i.length;a++){let c=i[a];if(c!=null&&typeof c=="object"&&!Array.isArray(c)){let f=c;f.key!==null&&(f.key=String(f.key))}}let s=Array.isArray(t)?t:[],l=new Map;for(let a of s)a!=null&&typeof a=="object"&&!Array.isArray(a)&&a.key!=null&&l.set(a.key,a);let d=i.map((a,c)=>{let f=null;return a!=null&&typeof a=="object"&&!Array.isArray(a)&&a.key!=null&&(f=l.get(a.key)??null),f==null&&(f=s[c]??null),B(a,n,f,o,r)});E("build")&&_("build","debug","",`array out kids=${Y(i)}`);let u=!1;for(let a=0;a<d.length;a++)if(Pn(d[a])){u=!0;break}return u?Promise.all(d).then(()=>i):i}function Wo(e,n,t,o,r){let i=e,s=o??n.__registry??ue(),l=Rn(t,i);i._id||(i._id=l?._id??s.nextId(),s.idRegistry.set(i._id,i)),l&&(l._parentNode&&(i._parentNode=l._parentNode),l._refNode&&(i._refNode=l._refNode),l._ctxVersion!=null&&(i._ctxVersion=l._ctxVersion),k(i)&&k(l)&&typeof l._render=="function"&&(i._render=l._render));let d=Uo(l?.props??{},i.props??{}),u=nn(n),a=(l?._ctxVersion??-1)===u;if(!r?.force&&d&&a&&Ee(l)&&typeof i._render=="function"){let c=l;return i._lifecycle=ee(i._lifecycle,"PRUNE",Z(i)),i._child=c._child,i._ctxVersion=c._ctxVersion,E("build")&&_("build","debug","",`prune comp=${ve(i)} propsSame=${d} verSame=${a}`),i}return i._lifecycle=ee(i._lifecycle,"BUILD_START",Z(i)),E("build")&&_("build","debug","",`mount comp=${ve(i)} propsSame=${d} verSame=${a} force=${!!r?.force}`),(async()=>{let{childCtx:c}=await $o(i,n,s,{reuse:l??null}),f=await B(await i._render(i.props),c,l?._child,s,r);return i._child=f??null,i._ctxVersion=u,i._lifecycle=ee(i._lifecycle,"BUILD_DONE",Z(i)),i})()}function Fo(e,n,t,o,r){let i=e,s=o??n.__registry??ue(),l=Rn(t,i);E("build")&&_("build","debug","",`fragment kids=${Y(P(i.props?.children))}`);let d=B(i.props?.children??null,n,l?._child??l?.props?.children,s,r);return Pn(d)?d.then(u=>(i._child=u??null,i._lifecycle=ee(i._lifecycle,"BUILD_DONE",Z(i)),i)):(i._child=d??null,i._lifecycle=ee(i._lifecycle,"BUILD_DONE",Z(i)),i)}function Et(e,n,t,o,r){let i=e;if(typeof i.type!="string"&&typeof i.type!="symbol")return i;let s=o??n.__registry??ue(),l=Rn(t,i);E("build")&&_("build","trace","",`native <${String(i.type)}> kids=${Y(P(i.props?.children))}`);let d=B(i.props?.children??null,n,l?.props?.children,s,r);return Pn(d)?d.then(u=>(i._child=u??null,i._lifecycle=ee(i._lifecycle,"BUILD_DONE",Z(i)),i)):(i._child=d??null,i._lifecycle=ee(i._lifecycle,"BUILD_DONE",Z(i)),i)}var Bo=new Set(["svg","path","circle","rect","line","polyline","polygon","g","text","defs","use","clipPath"]);function _e(e,n){return ce(e,n)}function O(e,n,t,o=null,r=null,i=null){let s=n?.browser??t;if(!s)throw new Error("[vdom2] renderValue requires browser env (ctx.browser)");return Zo[U(e)](e,n,s,o,r,i)}function Ko(e,n,t){return null}function qo(e,n,t){return t.createTextNode(String(e))}function An(e,n,t,o,r){if(e==null||typeof e=="boolean")return _e(t,e);let i=O(e,n,t,String(o),null,r);return i??_e(t,null)}function Go(e,n,t,o=null,r=null,i=null){let s=e,l=t.createDocumentFragment();if(!l)return null;E("render")&&_("render","debug","",`array kids=${Y(s)} fid=${i??"-"} key=${o??"-"}`);let d=t.createComment(F({type:"fragment-start",key:o,id:r,fid:i})),u=t.createComment(F({type:"fragment-end",key:o,id:r,fid:i}));d&&l.appendChild(d);for(let a=0;a<s.length;a++){let c=s[a],f=i!=null?`${i}-${a}`:String(a),p=An(c,n,t,a,f);p!=null&&l.appendChild(p)}return u&&l.appendChild(u),l}function zo(e,n,t){let o=e,r=o,i=t.bodyElement();if(!i)return null;let s=i.querySelector("#__wf_portal");s||(s=t.createElement("div"),s&&(s.id="__wf_portal",i.appendChild(s)));let l=t.createElement("div");if(l){l.setAttribute("data-portal",String(o.props?.portalKey??"wf"));let d=O(o.props?.children??null,n,t);d!=null&&l.appendChild(d),s&&s.appendChild(l),r._remoteEl=l;let u=P(o.props?.children);for(let a of u)a!=null&&typeof a=="object"&&!Array.isArray(a)&&(a._parentVNode=o)}return null}function Yo(e,n,t,o=null,r=null,i=null){let s=e,l=s,d=t.createDocumentFragment();if(!d)return null;let u=P(s.props?.children);E("render")&&_("render","debug","",`fragment kids=${Y(u)} fid=${i??"-"}`);let a=t.createComment(F({type:"fragment-start",key:o,id:r,fid:i})),c=t.createComment(F({type:"fragment-end",key:o,id:r,fid:i}));a&&d.appendChild(a),l._refNode=a;for(let f=0;f<u.length;f++){let p=u[f],m=i!=null?`${i}-${f}`:String(f),g=An(p,n,t,f,m);g!=null&&d.appendChild(g)}return c&&d.appendChild(c),d}function Jo(e,n,t){let o=e,r=o._lifecycle??(typeof o._render=="function"?"built":"fresh");return Xo[r](o,n,t)}var Xo={fresh:(e,n,t)=>{throw new Error(`[vdom2] component ${R(e.type)} not built (missing _render) \u2014 buildVNode must run before renderValue`)},building:(e,n,t)=>{throw new Error(`[vdom2] component ${R(e.type)} building in render \u2014 buildVNode must await before renderValue`)},disposed:(e,n,t)=>(console.warn(`[vdom2] disposed \u7EC4\u4EF6 ${R(e.type)} \u5728\u6E32\u67D3\u2014\u2014\u526A\u679D\u7F13\u5B58\u5931\u6548\u2014\u2014\u7236\u6811\u91CD\u5EFA\u4E2D\uFF08\u5360\u4F4D\u515C\u5E95\uFF09`),_e(t,null)),built:Tt,pruned:Tt};function Tt(e,n,t){let o=e._child;if(o==null)return e._child=null,null;e._child=o,e._outputChild=o,typeof o=="object"&&!Array.isArray(o)&&(o._parentVNode=e);let r=O(o,n,t);if(r){if(e._refNode=r.nodeType===11?r.firstChild:r,e._id)if(r.nodeType===11)for(let i of Array.from(r.childNodes))i.nodeType===1&&i.setAttribute("data-wf-id",e._id);else r.nodeType===1&&r.setAttribute("data-wf-id",e._id);if(e.key!=null)if(r.nodeType===11)for(let i of Array.from(r.childNodes))i.nodeType===1&&i.setAttribute("data-wf-key",e.key);else r.nodeType===1&&r.setAttribute("data-wf-key",e.key)}return r}function Qo(e,n,t,o,r){let i=e,s=i,l=i.type,d=Bo.has(l)?t.createElementNS("http://www.w3.org/2000/svg",l):t.createElement(l);if(!d)return null;s.el=d,s._refNode=d,E("render")&&_("render","trace","",`native <${l}> key=${i.key??"-"} kids=${Y(P(i.props?.children))}`),i.key!=null&&d.setAttribute("data-wf-key",i.key);let u=null;for(let[a,c]of Object.entries(i.props??{}))if(!(a==="children"||a==="key")){if(a==="value"&&d instanceof HTMLSelectElement){u=c;continue}re(d,a,c)}if(!("innerHTML"in(i.props??{}))){let a=P(i.props?.children);for(let c=0;c<a.length;c++){let f=a[c],p=r!=null?`${r}-${c}`:String(c),m=An(f,n,t,c,p);if(m!=null&&(d.appendChild(m),f&&typeof f=="object"&&!Array.isArray(f)&&typeof f.type=="function")){let g=f;g._parentNode||(g._parentNode=d)}}E("render")&&_("render","trace","",`native <${l}> out=${de(d)}`)}return u!==null&&(d.value=String(u)),d}var Zo={hole:Ko,text:qo,arr:Go,portal:zo,frag:Yo,comp:Jo,native:Qo};function pe(e){let{parent:n,oldNode:t,oldInput:o,ctx:r}=e,i=O(e.newInput,r,r.browser??V());if(i==null)return null;if(t?.parentNode){let s=Ie(o,t,n,r);return s&&s.parentNode===n?n.insertBefore(i,s):n.appendChild(i),i}return n.appendChild(i),i}function er(e){return Ie(e.oldInput,e.oldNode,e.parent,e.ctx),null}function nr(e){let n=e.oldNode;if(n?.nodeType===8){let t=_e(e.ctx.browser??V(),e.newInput);return t&&n.nodeValue!==t.nodeValue&&(n.nodeValue=t.nodeValue),n}return null}function ke(e){let{parent:n,oldNode:t,ctx:o}=e,r=O(e.newInput,o,o.browser??V());return r==null?null:(t?.parentNode?t.parentNode.replaceChild(r,t):t?n.insertBefore(r,t):n.appendChild(r),r)}function tr(e){let{parent:n,oldNode:t,oldInput:o}=e,r=String(e.newInput);if(String(o)!==r){if(t&&t.nodeType===3)return t.nodeValue=r,t;let i=n.ownerDocument.createTextNode(r);return t?.parentNode?t.parentNode.replaceChild(i,t):n.appendChild(i),i}return t}function or(e){let{parent:n,oldNode:t,oldInput:o,ctx:r}=e,i=e.newInput,s=o&&typeof o=="object"&&!Array.isArray(o)?o:null,l=i.type;if(t&&t.nodeType===1&&(s?.type??null)===l&&ze(i)){let d=t;return i.el=d,i._refNode=d,kt(d,s?.props??{},i.props??{}),"innerHTML"in(i.props??{})||Le(d,s?._child??s?.props?.children??null,i._child??i.props?.children??null,r),d}return pe(e)}function rr(e){let{parent:n,oldNode:t,oldInput:o,ctx:r}=e,i=e.newInput,s=o&&typeof o=="object"&&!Array.isArray(o)?o:null,l=te(s)?A(s,t):null,d=In(n,s??o,i,r,l);return t?.parentNode?t:d[0]??null}function ir(e){let{parent:n,oldNode:t,oldInput:o,ctx:r}=e,i=e.newInput;if(!k(i)||typeof i._render!="function")throw new Error(`[vdom2] component ${R(i.type)} not built in diff \u2014 buildVNode must run before patchValue`);let s=o&&typeof o=="object"&&!Array.isArray(o)?o:null;if(s?.type!=null&&s.type!==i.type)return pe(e);let l=s?.type===i.type;if(!r.force&&s&&l&&Ee(s)&&i._child===s._child)return t;s?.type===i.type&&s._id&&(i._id=s._id,r.registry.idRegistry.set(i._id,i)),i._parentNode=n,t&&(i._refNode=t);let d=i._child;if(d===null){i._outputChild=null,i._refNode=null;let a=t?.parentNode!=null,c=Ie(s?._child??null,t,n,r);s&&(s._child=null);let f=_e(r.browser??V(),null);return a&&f?(c&&c.parentNode===n?n.insertBefore(f,c):n.appendChild(f),f):ne(n,t,s?._child,null,r)}i._outputChild=d;let u=ne(n,t,s?._child,d,r);return u&&(i._refNode=u),u}function sr(e){let{parent:n,oldNode:t,oldInput:o,ctx:r}=e;if(o===e.newInput&&t?.parentNode)return t;let i=n.ownerDocument.createDocumentFragment(),s=Le(n,o,e.newInput,r,t?[t]:null);for(let l of s)l&&i.appendChild(l);return t?.parentNode?i.contains(t)?n.appendChild(i):t.parentNode.replaceChild(i,t):n.appendChild(i),i}function lr(e){let{ctx:n,oldInput:t}=e,o=e.newInput,r=t&&typeof t=="object"&&!Array.isArray(t)?t:null;if(z(r)&&z(o)){let i=r._remoteEl;if(i){let s=r._child??r.props?.children??null,l=o._child??o.props?.children??null;Le(i,s,l,n)}return o._remoteEl=r._remoteEl,null}return pe(e)}function Ne(e){return{text:pe,native:pe,frag:pe,comp:pe,arr:pe,hole:er,portal:pe,...e}}var ar={text:Ne({text:tr}),hole:Ne({text:ke,native:ke,frag:ke,comp:ke,arr:ke,portal:ke,hole:nr}),native:Ne({native:or}),frag:Ne({frag:rr}),comp:Ne({comp:ir}),arr:Ne({arr:sr}),portal:Ne({portal:lr})};function _t(e){let n=U(e.oldInput),t=U(e.newInput);return S({session:"",machine:"x2y",nodeId:null,component:null,from:n,event:"X2Y",to:t,level:"trace",ts:Date.now()}),ar[n][t](e)}function ie(e,n){if(n&&typeof e.type=="function"&&e._id){try{H(e,n)}catch(t){console.error("[weifuwu] ref cleanup error",t)}Nt(n,e._id)}}function Ue(e){if(e==null||typeof e!="object"||Array.isArray(e))return null;let n=e;return z(n)?typeof n.props?.portalKey=="string"?n.props.portalKey:null:n.key}function Ln(e,n){if(n&&e&&typeof e=="object"&&!Array.isArray(e)){let t=A(e,n);if(t&&t.length>1)return t}return[n]}function sn(e,n){let t=P(e.props?.children);for(let o of t){if(o==null||typeof o!="object"||Array.isArray(o))continue;let r=o;dr[U(r)](r,n)}}var dr={comp:(e,n)=>{ie(e,n)},frag:(e,n)=>{sn(e,n)},native:(e,n)=>{sn(e,n)},portal:(e,n)=>{sn(e,n)},arr:()=>{},text:()=>{},hole:()=>{}};function Ie(e,n,t,o){return ur[U(e)](e,n,t,o)}var ur={arr:(e,n,t,o)=>{let r=A(e,n);if(r&&r.length){let i=(r[r.length-1]??n)?.nextSibling??null;for(let s of r)s.parentNode&&s.parentNode.removeChild(s);return i&&i.parentNode===t?i:null}return Me(e,n,t,o)},frag:(e,n,t,o)=>{let r=e,s=A(r,n)??[],l=(s[s.length-1]??n)?.nextSibling??null;for(let d of s)d.parentNode&&d.parentNode.removeChild(d);return sn(r,o.registry),l&&l.parentNode===t?l:null},portal:(e,n,t,o)=>{let r=e,i=r._remoteEl;try{H(r.props?.children,o.registry)}catch(s){console.error("[weifuwu] portal ref cleanup error",s)}return i?.parentNode?.removeChild(i),null},comp:(e,n,t,o)=>{let r=e,i=A(r,n);if(ie(r,o.registry),i&&i.length>1){let s=(i[i.length-1]??n)?.nextSibling??null;for(let l of i)l.parentNode&&l.parentNode.removeChild(l);return s&&s.parentNode===t?s:null}return Me(e,n,t,o)},native:(e,n,t,o)=>{try{H(e,o.registry)}catch(r){console.error("[weifuwu] ref cleanup error",r)}return Me(e,n,t,o)},text:(e,n,t,o)=>Me(e,n,t,o),hole:(e,n,t,o)=>Me(e,n,t,o)};function Me(e,n,t,o){let r=n?.nextSibling??null;return n?.parentNode&&n.parentNode.removeChild(n),r&&r.parentNode===t?r:null}function ne(e,n,t,o,r){return _t({parent:e,oldNode:n,oldInput:t,newInput:o,ctx:r})}var cr={event:(e,n,t,o)=>{let{type:r,capture:i}=_n(n);typeof t=="function"&&e.removeEventListener(r,t,i?{capture:!0}:{}),o!=null&&o!==!1&&(typeof o!="function"?console.warn(`[weifuwu] event prop ${n} expects a function, got ${typeof o} \u2014 ignored`):e.addEventListener(r,o,i?{capture:!0}:{}))},class:(e,n,t,o)=>{o==null||o===!1?e.removeAttribute("class"):(e.className="",re(e,n,o))},ref:(e,n,t,o)=>{if(o==null||o===!1){if(typeof t=="function")try{t(null)}catch(r){console.error("[weifuwu] ref cleanup error",r)}}else re(e,n,o)},value:(e,n,t,o)=>{o==null||o===!1?e.value="":re(e,n,o)},indeterminate:(e,n,t,o)=>{o==null||o===!1?e.indeterminate=!1:re(e,n,o)},enumerated:He,style:He,innerHTML:He,aria:He,default:He};function He(e,n,t,o){if(o==null||o===!1){e.removeAttribute(n);try{delete e[n]}catch{}}else re(e,n,o)}function kt(e,n,t){let o=Object.keys(n),r=Object.keys(t);if(o.length===r.length){let s=!0;for(let l=0;l<o.length;l++)if(o[l]!==r[l]||n[o[l]]!==t[o[l]]){s=!1;break}if(s)return}let i=new Set([...o,...r]);for(let s of i){if(s==="children"||s==="key")continue;let l=n[s],d=t[s];l!==d&&cr[Sn(s)](e,s,l,d)}}function In(e,n,t,o,r){let i=Array.isArray(n)?n:n?._child??n?.props?.children??null,s=Array.isArray(t)?t:t?._child??t?.props?.children??null;return Le(e,i,s,o,r)}function Le(e,n,t,o,r,i){let s=P(n),l=P(t),d=r??Array.from(e.childNodes);E("diff")&&_("diff","debug","",`patchChildren parent=${J(e)} old=${Y(s)} new=${Y(l)} dom=${de(e)}`);let u=l.some(p=>Array.isArray(p))||s.some(p=>Array.isArray(p)),a=u?"unkeyed":Tn(l);if(S({session:"",machine:"keys",nodeId:null,component:null,from:u?"unkeyed":Tn(l),event:"SELECT",to:a,payload:()=>({len:l.length}),level:"trace",ts:Date.now()}),fe()&&s.length!==l.length)for(let p=0;p<l.length;p++){let m=l[p];m!=null&&typeof m=="object"&&!Array.isArray(m)&&k(m)&&m.key==null&&console.error(`[vdom2/audit] \u52A8\u6001\u6570\u7EC4\u4F4D\u7F6E ${p} \u7684\u7EC4\u4EF6\u7F3A\u5C11 key\u2014\u2014\u5217\u8868\u589E\u5220/\u91CD\u6392\u4F1A\u9519\u4F4D\u7EC4\u4EF6\u5B9E\u4F8B\u72B6\u6001\u3002\u8BF7\u63D0\u4F9B\u4E1A\u52A1\u8EAB\u4EFD key\uFF08\u5982 key={item.id}\uFF09\uFF1B\u65E0\u72B6\u6001 native \u9879\u8C41\u514D\u3002`)}let c=r&&r.length?r[r.length-1]:null;a==="mixed"&&(ln(l),ln(s));let f=(()=>{let p=d;p.length>=2&&p[0]?.nodeType===8&&p[0].nodeValue?.includes("fragment-start")&&p[p.length-1]?.nodeType===8&&p[p.length-1].nodeValue?.includes("fragment-end")&&(p=p.slice(1,-1));let m=[],g=0;for(let h=0;h<s.length;h++){let w=s[h];if(Array.isArray(w)){let v=p[g]??null;m.push(v);let b=A(w,v);g+=b?.length??1;continue}if(w==null||typeof w=="boolean"||typeof w=="string"||typeof w=="number"){m.push(p[g]??null),g++;continue}let y=w;if(z(y)){m.push(y._remoteEl??null);continue}if(m.push(y._refNode??p[g]??null),typeof y.type=="function"||te(y)){let v=A(y,y._refNode??p[g]??null);g+=v?.length??1}else g++}return m})();return Rr[a]({parent:e,oldChildren:s,newChildren:l,oldNodes:f,ctx:o,arrEnd:c,anchorOut:i})}function Oe(e){return e==null||typeof e=="boolean"?"hole":Array.isArray(e)||e&&typeof e=="object"&&te(e)?"multi":"real"}function fr(e){let{parent:n,oldC:t,oldNode:o,oldNodes:r,i,ctx:s,out:l,pushA:d}=e;if(Array.isArray(t)){E("diff")&&_("diff","trace","",`remove-arr-item i=${i} range=[${(A(t,r[i])??[]).map(J).join(" | ")}] before=${de(n)}`);let u=A(t,o);for(let a of u??[])a.parentNode?.removeChild(a);E("diff")&&_("diff","trace","",`remove-arr-item after=${de(n)}`);for(let a of t)a!=null&&typeof a=="object"&&!Array.isArray(a)&&typeof a.type=="function"&&ie(a,s.registry)}else if(t&&typeof t=="object"&&!Array.isArray(t)){if(typeof t.type=="function")ie(t,s.registry);else try{H(t,s.registry)}catch(u){console.error("[weifuwu] ref cleanup error",u)}o?.parentNode&&o.parentNode.removeChild(o)}else o?.parentNode&&o.parentNode.removeChild(o);l.push(null),d(null)}function pr(e){let{parent:n,newC:t,oldNode:o,i:r,oldNodes:i,out:s,pushA:l,ctx:d}=e,u=ce(d.browser??V(),t);if(o?.nodeType===8){u&&o.nodeValue!==u.nodeValue&&(o.nodeValue=u.nodeValue),s.push(o),l(o);return}if(u&&o?.parentNode)o.parentNode.replaceChild(u,o);else if(u){let a=null;for(let c=r+1;c<i.length;c++){let f=i[c];if(f&&f.parentNode===n){a=f;break}}if(!a){let c=null;for(let f=s.length-1;f>=0;f--)if(s[f]){c=s[f];break}c&&c.parentNode===n&&(a=c.nextSibling)}a&&a.parentNode===n?n.insertBefore(u,a):n.appendChild(u),s.push(u),l(u)}else s.push(u),l(u)}function St(e){let{parent:n,newC:t,oldNode:o,i:r,oldNodes:i,out:s,pushA:l,ctx:d}=e,u=O(t,d,d.browser??V(),String(r));if(u==null){s.push(null),l(null);return}if(o&&o.nodeType===8&&o.nodeValue?.includes("type=hole")){S({session:"",machine:"pos",nodeId:null,component:null,from:"hole",event:"HOLE_FILL",to:"real",payload:()=>({i:r,replaced:J(o)}),level:"trace",ts:Date.now()}),o.parentNode?.replaceChild(u,o),s.push(u),l(u);return}let a=null;for(let c=r+1;c<i.length;c++){let f=i[c];if(f&&f.parentNode===n){a=f;break}}if(a==null){let c=null;for(let f=s.length-1;f>=0;f--)if(s[f]){c=s[f];break}if(c&&c.parentNode===n)a=c.nextSibling;else{let f=i[i.length-1];f&&f.parentNode===n&&(a=f.nextSibling)}}a&&a.parentNode===n?n.insertBefore(u,a):n.appendChild(u),S({session:"",machine:"pos",nodeId:null,component:null,from:"hole",event:"INSERT",to:"real",payload:()=>({i:r,insertedBefore:a?J(a):"END",node:J(u)}),level:"trace",ts:Date.now()}),s.push(u),l(u)}function mr(e){let{parent:n,oldC:t,newC:o,oldNode:r,out:i,pushA:s,ctx:l}=e;if(t&&typeof t=="object"&&!Array.isArray(t)&&typeof t.type=="function"){let u=At(n,t,r,o,l);i.push(u),s(u);return}let d=It(n,t,r,o,l);i.push(d),s(d)}function yr(e){let{parent:n,oldC:t,newC:o,oldNode:r,i,out:s,pushA:l,ctx:d}=e,u=d.browser??V(),a=O(o,d,u,String(i));if(a==null){s.push(null),l(null);return}let c=t&&typeof t=="object"?A(t,r):null;if(c&&c.length>1){let p=(c[c.length-1]??r)?.nextSibling??null;for(let m of c)m.parentNode&&m.parentNode.removeChild(m);if(t&&typeof t=="object"&&!Array.isArray(t))if(typeof t.type=="function")ie(t,d.registry);else try{H(t,d.registry)}catch(m){console.error("[weifuwu] ref cleanup error",m)}p&&p.parentNode===n?n.insertBefore(a,p):n.appendChild(a)}else r?.parentNode?r.parentNode.replaceChild(a,r):n.appendChild(a);let f=a.nodeType===11?Array.from(a.childNodes):[a];s.push(...f),l(f[0]??a)}function gr(e){let{parent:n,oldC:t,newC:o,oldNode:r,out:i,pushA:s,ctx:l}=e,d=Rt(n,t,r,o,l);i.push(d),s(d)}function hr(e){let{parent:n,oldC:t,newC:o,oldNode:r,i,oldNodes:s,out:l,pushA:d,ctx:u}=e,a=u.browser??V(),c=A(t,r);E("diff")&&_("diff","debug","",`multi-remove i=${i} range=${c?c.map(J).join(" | "):"null"}`);for(let m of c??[])m.parentNode?.removeChild(m);for(let m of P(t?.props?.children))m!=null&&typeof m=="object"&&!Array.isArray(m)&&typeof m.type=="function"&&ie(m,u.registry);let f=O(o,u,a,String(i));if(f==null){l.push(null),d(null);return}let p=s[i+1]??null;p?.parentNode?p.parentNode.insertBefore(f,p):n.appendChild(f),l.push(f),d(f)}function vr(e){let{parent:n,oldC:t,newC:o,oldNode:r,oldNodes:i,i:s,out:l,pushA:d,ctx:u}=e,a=A(t,r),c=In(n,t,o,u,a);l.push(...c),d(i[s]??c[0]??null)}function Nr(e){let{parent:n,oldC:t,newC:o,oldNode:r,i,out:s,pushA:l,ctx:d}=e;if(o&&typeof o=="object"&&!Array.isArray(o)&&typeof o.type=="function"&&o._lifecycle==="disposed"){let c=Mt(n,r,d,R(o.type));s.push(c),l(c);return}let u=ne(n,r,t,o,d);E("diff")&&_("diff","trace","",`after-patch i=${i} new=${ve(o)} node=${J(u)} dom=${de(n)}`);let a=Ln(o,u);s.push(...a),l(a[0]??u??null)}function Rt(e,n,t,o,r){let i=ce(r.browser??V(),o),s=A(n,t),l=((s??[])[s?.length?s.length-1:0]??t)?.nextSibling??null;for(let d of s??[])d.parentNode?.removeChild(d);for(let d of P(n?.props?.children))d!=null&&typeof d=="object"&&!Array.isArray(d)&&typeof d.type=="function"&&ie(d,r.registry);return i&&l&&l.parentNode===e?e.insertBefore(i,l):i&&e.appendChild(i),i}function At(e,n,t,o,r){let i=ce(r.browser??V(),o),s=Ie(n,t,e,r);return i&&s?e.insertBefore(i,s):i&&e.appendChild(i),i}function It(e,n,t,o,r){let i=ce(r.browser??V(),o);if(n&&typeof n=="object"&&!Array.isArray(n))if(typeof n.type=="function")ie(n,r.registry);else try{H(n,r.registry)}catch(s){console.error("[weifuwu] ref cleanup error",s)}return i&&t?.parentNode?t.parentNode.replaceChild(i,t):i&&e.appendChild(i),i}var wr={hole:{hole:pr,real:St,multi:St},real:{hole:mr,real:Nr,multi:yr},multi:{hole:gr,real:hr,multi:vr}};function br(e){let{parent:n,oldChildren:t,newChildren:o,oldNodes:r,ctx:i,anchorOut:s}=e,l=Math.max(t.length,o.length),d=[],u=a=>{s&&s.push(a)};for(let a=0;a<l;a++){let c=a<t.length?t[a]:null,f=a<o.length?o[a]:null;if(a>=o.length){fr({parent:n,oldC:c,newC:f,oldNode:r[a],i:a,oldNodes:r,newChildren:o,out:d,pushA:u,ctx:i});continue}if(c!=null&&typeof c=="object"&&!Array.isArray(c)&&f!=null&&typeof f=="object"&&!Array.isArray(f)&&f===c&&Ee(c)){d.push(r[a]),u(r[a]);continue}let p=wr[Oe(c)][Oe(f)];S({session:"",machine:"pos",nodeId:null,component:null,from:Oe(c),event:p.name,to:Oe(f),payload:()=>({i:a}),level:"trace",ts:Date.now()}),p({parent:n,oldC:c,newC:f,oldNode:r[a],i:a,oldNodes:r,newChildren:o,out:d,pushA:u,ctx:i})}return d}function Pt(e){let{parent:n,oldChildren:t,newChildren:o,oldNodes:r,ctx:i,anchorOut:s,arrEnd:l}=e,d=new Map;t.forEach((p,m)=>{let g=Ue(p);g!==null&&p&&typeof p=="object"&&!Array.isArray(p)&&d.set(g,{vnode:p,nodes:[r[m]??null].filter(Boolean),index:m})});let u=[],a=new Set,c=p=>{s&&s.push(p)},f=null;return o.forEach((p,m)=>{let g=Ue(p),h=p;if(g!==null&&d.has(g)){let w=d.get(g),y=w.nodes[0]??null;if(a.add(g),h&&typeof h=="object"&&typeof h.type=="function"&&h._lifecycle==="disposed"){let D=Mt(n,y,i,R(h.type));u.push(D),c(D),D&&(f=D);return}let v=ne(n,y,w.vnode,h,i),b=Ln(h,v),I=b[0]??v,K=b[b.length-1]??v;if(I&&I.parentNode===n&&f&&I.previousSibling!==f){E("diff")&&_("diff","debug","",`keyed-correct i=${m} k=${g} move=[${b.map(J).join(" | ")}] after=${J(f)} before=${de(n)}`);let D=f.nextSibling;for(let C of b)C&&C.parentNode===n&&n.insertBefore(C,D);E("diff")&&_("diff","debug","",`keyed-correct after=${de(n)}`)}u.push(...b),c(b[0]??v??null),K&&(f=K)}else{let w={current:f};_r[Tr(p)]({parent:n,oldChildren:t,newChildren:o,oldNodes:r,ctx:i,out:u,pushA:c,arrEnd:l,c:p,i:m},w),f=w.current}}),t.forEach((p,m)=>{xr[Cr(Ue(p),a)](n,p,m,r,i,o.length)}),u}function Cr(e,n){return e===null?"unkeyed":n.has(e)?"moved":"stale-keyed"}var xr={moved:()=>{},"stale-keyed":Vr,unkeyed:Er};function Vr(e,n,t,o,r){let i=n&&typeof n=="object"&&!Array.isArray(n)?A(n,o[t]):null;if(E("diff")&&_("diff","trace","",`keyed-delete i=${t} k=${Ue(n)} range=${i?.length??0} oldNode=${J(o[t])}`),n&&typeof n=="object"&&!Array.isArray(n))if(typeof n.type=="function")ie(n,r.registry);else try{H(n,r.registry)}catch(s){console.error("[weifuwu] ref cleanup error",s)}Lt(i,o[t])}function Er(e,n,t,o,r,i){let s=o[t];if(s?.nodeType===8&&s.nodeValue?.includes("type=hole")&&t<i)return;if(n&&typeof n=="object"&&!Array.isArray(n))if(typeof n.type=="function")ie(n,r.registry);else try{H(n,r.registry)}catch(u){console.error("[weifuwu] ref cleanup error",u)}let d=n&&typeof n=="object"&&!Array.isArray(n)?A(n,s):null;Lt(d,s)}function Lt(e,n){if(e&&e.length>1)for(let t of e)t.parentNode&&t.parentNode.removeChild(t);else n?.parentNode&&n.parentNode.removeChild(n)}function Tr(e){return e==null||typeof e=="boolean"?"hole":e&&typeof e=="object"&&!Array.isArray(e)&&z(e)?"portal":"real"}var _r={hole:kr,portal:Sr,real:Pr};function kr(e,n){let{parent:t,oldChildren:o,oldNodes:r,ctx:i,out:s,pushA:l,c:d,i:u}=e,a=o[u]??null,c=r[u]??null,f=Oe(a);if(f==="hole"){let m=ce(i.browser??V(),d);c?.nodeType===8?(m&&c.nodeValue!==m.nodeValue&&(c.nodeValue=m.nodeValue),s.push(c),l(c),c&&(n.current=c)):(m&&c?.parentNode?c.parentNode.replaceChild(m,c):m&&t.appendChild(m),s.push(m),l(m),m&&(n.current=m));return}let p=f==="multi"?Rt(t,a,c,d,i):a&&typeof a=="object"&&!Array.isArray(a)&&typeof a.type=="function"?At(t,a,c,d,i):It(t,a,c,d,i);s.push(p),l(p),p&&(n.current=p)}function Sr(e,n){let{parent:t,oldChildren:o,oldNodes:r,ctx:i,out:s,pushA:l,c:d,i:u}=e,a=d,c=o[u]??null,f=ne(t,r[u]??null,c,a,i),p=Ln(a,f);s.push(...p),l(p[0]??f??null);let m=p[p.length-1]??f;m&&(n.current=m)}function Pr(e,n){let{parent:t,oldNodes:o,ctx:r,out:i,pushA:s,arrEnd:l,c:d,i:u}=e,c=O(d,r,r.browser??V());if(i.push(c),s(c??null),c!=null){let f=o[u];f&&f.nodeType===8&&f.nodeValue?.includes("type=hole")?(f.parentNode?.replaceChild(c,f),n.current=c):(n.current?t.insertBefore(c,n.current.nextSibling):l&&l.parentNode===t?t.insertBefore(c,l):t.insertBefore(c,t.firstChild),n.current=c)}}function ln(e){for(let n=0;n<e.length;n++){let t=e[n];t&&typeof t=="object"&&!Array.isArray(t)&&Ue(t)===null&&(t.key=`pos:${n}`)}}function Mt(e,n,t,o){fe()?console.error(`[vdom2/audit] I1 \u8FDD\u53CD\uFF1Adiff \u6536\u5230 disposed \u7EC4\u4EF6 ${o}\u2014\u2014\u526A\u679D\u7F13\u5B58\u5931\u6548\uFF08portal \u5185\u5BB9\u72EC\u7ACB dispose\uFF09\u2014\u2014\u7236\u6811\u5C06\u91CD\u5EFA`):console.warn(`[vdom2] disposed \u7EC4\u4EF6 ${o} \u5728 diff\u2014\u2014\u526A\u679D\u7F13\u5B58\u5931\u6548\u2014\u2014\u7236\u6811\u91CD\u5EFA\u4E2D\uFF08\u5360\u4F4D\u515C\u5E95\uFF09`);let r=ce(t.browser??V(),null);if(r==null)return null;let i=n;if(i){let s=i.parentNode;s?s.replaceChild(r,i):e.appendChild(r)}else e.appendChild(r);return r}var Rr={unkeyed:br,keyed:Pt,mixed:e=>(ln(e.newChildren),ln(e.oldChildren),Pt(e))};function an(e){let{registry:n,ctx:t}=e,o=new Map;async function r(s){let l=n.idRegistry.get(s);if(!l||!k(l)||typeof l._render!="function")return;let d=l,u=Ze("render");try{let a=await d._render(d.props),c=await B(a,t,d._child,n)??null,f=d._child;if(d._child=c,d._lifecycle==="building"){S({session:u,machine:"render",nodeId:d._id??null,component:Ht(d),from:"IDLE",event:"PARENT",to:"SKIP_BUILDING",payload:()=>({lifecycle:d._lifecycle}),level:"debug",ts:Date.now()});return}let p=d._id!=null&&d._id===t.ui?._rootVNodeId,m=d._parentNode??d._refNode?.parentNode??null;m==null&&p&&(m=e.rootEl??null);let g=m?p&&!d._parentNode?"ROOT":"MOUNTED":"SKIP_DETACHED";if(S({session:u,machine:"render",nodeId:d._id??null,component:Ht(d),from:"IDLE",event:"PARENT",to:g,payload:()=>({lifecycle:d._lifecycle}),level:"debug",ts:Date.now()}),m){let h={browser:t.browser??V(),registry:n,ctxVersion:nn(t)},w=ne(m,d._refNode??null,f,c,h);if(d._refNode=w,fe())try{let y=[];Te(m,c,v=>y.push(v)),y.length&&console.error("[vdom2/audit] "+y.join(" | "))}catch(y){console.error("[vdom2/audit] \u6821\u9A8C\u5F02\u5E38:",y)}}}catch(a){e.onError?e.onError(a):console.error("[vdom2] render error:",a?.stack??a)}finally{Ae()}}function i(s){return s==null?Promise.resolve():Promise.all(s.map(l=>{let u=(o.get(l)??Promise.resolve()).then(()=>r(l));return o.set(l,u),u.finally(()=>{o.get(l)===u&&o.delete(l)})})).then(()=>{})}return{render:i}}function Ht(e){return typeof e.type=="function"&&e.type.name?e.type.name:"anonymous"}function Ot(e){let{ctx:n,browser:t}=e,o=e.registry??ue(),r=e.renderer??an({registry:o,ctx:n,rootEl:e.root,onError:e.onError}),i=n.ui,s=null,l=null,d={ctx:n,registry:o,renderer:r,async mount(u){s=u;let a=await B(u,n,null,o);e.root.innerHTML="";let c=O(a,n,t);if(c!=null&&e.root.appendChild(c),l=a?._child??a,i&&(i._rootVNodeId=a?._id??null),fe())try{let f=[];Te(e.root,a,p=>f.push(p)),f.length&&console.error("[vdom2/audit] "+f.join(" | "))}catch(f){console.error("[vdom2/audit] \u6821\u9A8C\u5F02\u5E38:",f)}},async rerender(){if(s==null)return;let u=[];for(let[,a]of o.idRegistry)k(a)&&typeof a._render=="function"&&a._id&&u.push(a._id);await r.render(u)},unmount(){for(let[,u]of o.idRegistry)try{H(u,o)}catch{}e.root.innerHTML=""}};return d.close=()=>d.unmount(),d}function Ar(e,n,t,o){let r=t,i=r.__registry??ue(),s=r.browser??V();return Promise.resolve(B(n,r,null,i)).then(()=>{let l=O(n,r,s);if(l!=null&&e.appendChild(l),n._id&&i){let d=i.idRegistry.get(n._id);d&&(d._parentNode=e)}o?.onMounted?.()}).catch(l=>console.error("[vdom2] command mount error",l)),{id:n._id??""}}function Ir(e,n,t){let o=t.__registry;if(o)for(let[,r]of o.idRegistry)try{H(r,o)}catch{}e.remove()}var Ut=V();function $t(e,n="bottom",t=6,o=!0){switch(n){case"bottom":return{top:e.bottom+t,left:o?e.left+e.width/2:e.left};case"top":return{top:e.top-t,left:o?e.left+e.width/2:e.left};case"left":return{top:o?e.top+e.height/2:e.top,left:e.left-t};case"right":return{top:o?e.top+e.height/2:e.top,left:e.right+t}}}function dn(e,n,t=8){if(!n)return e;let o=n.getBoundingClientRect();if(o.width===0&&o.height===0)return e;let r=Number.parseFloat(n.style.top)||o.top,i=Number.parseFloat(n.style.left)||o.left,s=e.top-r,l=e.left-i,d={top:o.top+s,bottom:o.bottom+s,left:o.left+l,right:o.right+l},u=Ut.viewportWidth(),a=Ut.viewportHeight(),c=e.top,f=e.left;return d.bottom>a-t&&(c=Math.max(t,c-(d.bottom-(a-t)))),d.top<t&&(c=Math.max(t,c+(t-d.top))),d.right>u-t&&(f=Math.max(t,f-(d.right-(u-t)))),d.left<t&&(f=Math.max(t,f+(t-d.left))),{top:c,left:f,width:e.width}}var Se=V();function Dt(e){let n=new Map,t=new Map,o=!1,r=0;function i(){r||(r=requestAnimationFrame(()=>{r=0;let a=[];for(let[c,f]of n){if(!f.isOpen())continue;let p=f.getEl();if(!p)continue;let m=p.getBoundingClientRect();if(m.width===0&&m.height===0)continue;let g=f.compute(m);Object.assign(f.pos,dn(g,f.panel?.(),f.margin)),a.push(c)}for(let[c,f]of t){let p=f.getScroller(),m=p instanceof Window?Se.scrollingElement()?.scrollTop??Se.scrollTop():p.scrollTop??0;m!==f.handle.y&&(f.handle.y=m,a.push(c))}a.length>0&&e(a)}))}function s(){o||(o=!0,Se.addEventListener("scroll",i,{capture:!0,passive:!0}),Se.addEventListener("resize",i))}function l(){o&&(Se.removeEventListener("scroll",i,{capture:!0}),Se.removeEventListener("resize",i),o=!1)}function d(a){for(let c of[...n.keys()])(c.startsWith(`popup:${a}:`)||c===`popup:${a}`||c===a)&&n.delete(c);t.delete(a)}function u(){l(),r&&(cancelAnimationFrame(r),r=0),n.clear(),t.clear()}return{popupTrackers:n,scrollTrackers:t,schedulePopupRecompute:i,ensurePopupListeners:s,destroyPopupListeners:l,cleanupTrackers:d,destroy:u}}function Mn(e,n,t){return r=>{r?n(r):t?.()}}function $e(e){return typeof window<"u"&&!!window.matchMedia?.("(hover: hover)").matches}function un(e){return typeof window<"u"&&!!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches}function Hn(e,n,t){let o=null,r=()=>{n(),t?.once&&o&&o.removeEventListener("animationend",r)};return s=>{s?(o=s,s.addEventListener("animationend",r)):o&&(o.removeEventListener("animationend",r),o=null)}}function On(e,n){let{onLongPress:t,duration:o=500}=n,r,i=0,s=0,l=null,d=()=>{clearTimeout(r),r=void 0},u=e.selfId();if(u){let a=e.onUnmount(c=>{c===u&&(d(),a())})}return{onPointerDown:a=>{i=a.clientX??0,s=a.clientY??0,l=a,d(),r=setTimeout(()=>{r=void 0,l&&t(l)},o)},onPointerUp:d,onPointerLeave:d,onPointerMove:a=>{let c=Math.abs((a.clientX??0)-i),f=Math.abs((a.clientY??0)-s);(c>10||f>10)&&d()},onContextMenu:a=>{a.preventDefault(),t(a)}}}function De(e,n){let t=e.selfId(),o="closed",r,i=()=>{o="closed",t?e.render([t]):e.render()};return{get phase(){return o},ref:l=>{l?r||(r=()=>{o==="exit"&&i()},l.addEventListener("animationend",r)):r=void 0},sync:l=>(l?o="open":o==="open"&&(o="exit"),o)}}function Un(e,n,t){let o=e.selfId(),r=un(e),i=t?.duration??400,s=t?.ease==="linear"?f=>f:f=>1-Math.pow(1-f,3),l,d=n,u={value:r?n:0,reset:()=>{}},a=()=>{o?e.render([o]):e.render()},c=f=>{if(d=f,r){u.value=f,a();return}if(f===u.value)return;l&&cancelAnimationFrame(l);let p=u.value,m=performance.now(),g=h=>{let w=Math.min(1,(h-m)/i);u.value=Math.round(p+(f-p)*s(w)),w<1?(l=requestAnimationFrame(g),a()):(l=void 0,a())};l=requestAnimationFrame(g)};if(u.reset=f=>{f===d&&l||c(f)},o){let f=e.onUnmount(p=>{p===o&&(l&&(cancelAnimationFrame(l),l=void 0),f())})}return queueMicrotask(()=>c(n)),u}function $n(e,n,t){let o=e.selfId(),r=e.browser,i=`media:${o}:${n}`;if(!e.mediaRegistry.has(i)){let s=r.matchMedia(n);t(s.matches);let l=u=>t(u.matches);s.addEventListener("change",l),e.mediaRegistry.set(i,{mql:s,handler:l});let d=e.onUnmount(u=>{if(u!==o)return;let a=e.mediaRegistry.get(i);if(a?.mql&&a.handler)try{a.mql.removeEventListener("change",a.handler)}catch{}e.mediaRegistry.delete(i),d()})}}function Dn(e,n,t){let o=e.browser,r=typeof n=="function"?{mobile:"(max-width: 639px)",tablet:"(min-width: 640px) and (max-width: 1023px)",desktop:"(min-width: 1024px)"}:n,i=typeof n=="function"?n:t,s=e.selfId(),l=`bp:${s}`;function d(){for(let[u,a]of Object.entries(r))if(o.matchMedia(a).matches)return u;return Object.keys(r)[0]??""}if(!e.mediaRegistry.has(l)){i(d());let u=[];for(let c of Object.values(r)){let f=o.matchMedia(c),p=()=>i(d());f.addEventListener("change",p),u.push({mql:f,handler:p})}e.mediaRegistry.set(l,{mqls:u});let a=e.onUnmount(c=>{if(c!==s)return;let f=e.mediaRegistry.get(l);if(f?.mqls)for(let p of f.mqls)try{p.mql.removeEventListener("change",p.handler)}catch{}e.mediaRegistry.delete(l),a()})}}function jn(e){let n=e.selfId(),t=e.browser,o={height:t.viewportHeight(),offsetTop:0,keyboardOpen:!1},r=()=>{n?e.render([n]):e.render()},i=()=>{let l=t.visualViewport();o.height=l?.height??t.viewportHeight(),o.offsetTop=l?.offsetTop??0,o.keyboardOpen=o.height<t.viewportHeight()*.9,r()},s=t.visualViewport();if(s?.addEventListener?(s.addEventListener("resize",i),s.addEventListener("scroll",i)):t.addEventListener("resize",i),n){let l=e.onUnmount(d=>{d===n&&(s?.removeEventListener?(s.removeEventListener("resize",i),s.removeEventListener("scroll",i)):t.removeEventListener("resize",i),l())})}return o}function Wn(e,n){let t=e.selfId(),o={isIn:!1,ready:!1,observe:d,refresh:u,disconnect:a},r=null,i=null,s=()=>{t?e.render([t]):e.render()};function l(){if(i?.disconnect(),i=null,!r)return;let c=typeof n.rootMargin=="function"?n.rootMargin():n.rootMargin,f=typeof n.threshold=="function"?n.threshold():n.threshold;i=new IntersectionObserver(p=>{let m=p[p.length-1];if(!m)return;let g=m.isIntersecting,h=g!==o.isIn,w=!o.ready;o.isIn=g,o.ready=!0,n.onChange?.(m,g),(h||w)&&s()},{root:n.root?n.root():null,rootMargin:c??"0px",threshold:f??0}),i.observe(r)}function d(c){r=c,c?l():(i?.disconnect(),i=null,o.isIn=!1)}function u(){l()}function a(){i?.disconnect(),i=null}if(t){let c=e.onUnmount(f=>{f===t&&(a(),c())})}return o}function Fn(e,n){let t=e.selfId(),o=e.browser,r={y:0,refresh(){let l=i.getScroller();r.y=l instanceof Window?o.scrollingElement()?.scrollTop??o.scrollTop():l.scrollTop??0}},i={handle:r,getScroller:n.getScroller??(()=>window)};if(!t)return r.refresh(),r;e.scrollTrackers.set(t,i),e.ensurePopupListeners(),r.refresh();let s=e.onUnmount(l=>{l===t&&(e.scrollTrackers.delete(t),s())});return r}function cn(e,n){let t=e.selfId(),o=n.value!==void 0;if(o&&!n.onChange&&n.name&&(e.warned.has(n.name)||(e.warned.add(n.name),console.warn(`[weifuwu/${n.name}] \u53D7\u63A7\u6A21\u5F0F\uFF08value \u5DF2\u4F20\uFF09\u4F46\u672A\u63D0\u4F9B onChange\uFF0C\u4EA4\u4E92\u65E0\u6CD5\u751F\u6548\u3002
4
+ \u975E\u53D7\u63A7\uFF1A\u53BB\u6389 value\uFF1B\u53D7\u63A7\uFF1A\u4F20\u5165 onChange={(v) => setValue(v)}`))),!o&&t&&!e.uncontrolledValues.has(t)){e.uncontrolledValues.set(t,n.value);let i=e.onUnmount(s=>{s===t&&(e.uncontrolledValues.delete(t),i())})}let r=i=>{if(o){n.onChange?.(i);return}t&&e.uncontrolledValues.set(t,i),t?e.render([t]):e.render()};return{value:o?n.value:t?e.uncontrolledValues.get(t):n.value,setValue:r,controlled:o}}function Bn(e,n){let t=e.selfId(),o=cn(e,{value:n.value,onChange:n.onChange,name:n.name});if(t&&!e.inputStates.has(t)){e.inputStates.set(t,{keyword:"",selectedLabel:""});let s=e.onUnmount(l=>{l===t&&(e.inputStates.delete(t),s())})}let r=t?e.inputStates.get(t):{keyword:"",selectedLabel:""},i=()=>{t?e.render([t]):e.render()};return{...o,get keyword(){return r.keyword},setKeyword(s){r.keyword=s,i()},get selectedLabel(){return r.selectedLabel},setSelectedLabel(s){r.selectedLabel=s,i()}}}function Kn(e,n){let t=e.selfId(),o=!1;if(t){let d=e.onUnmount(u=>{u===t&&(o=!0,d())})}let r=()=>{o||(t?e.render([t]):e.render())},i={data:void 0,loading:!1,error:void 0},s=0,l=()=>{let d=++s;i.loading=!0,i.error=null,r(),Promise.resolve().then(()=>n()).then(u=>{s===d&&(i.data=u,i.loading=!1,r())}).catch(u=>{s===d&&(i.error=u,i.loading=!1,r())})};return l(),i.reload=l,i}function qn(e,n){let t=e.selfId(),o=e.browser;if(typeof window>"u")return()=>{};if(o.addEventListener("keydown",n),t){let r=e.onUnmount(i=>{i===t&&(o.removeEventListener("keydown",n),r())})}return()=>o.removeEventListener("keydown",n)}function Gn(e,n){let t=e.browser,o=0,r=0,i=!1,s=a=>{i&&n.onMove(a,{x:a.clientX-o,y:a.clientY-r})},l=a=>{i&&(i=!1,t.removeEventListener("pointermove",s),t.removeEventListener("pointerup",l),n.onEnd?.(a))},d=a=>{i||(a.preventDefault(),i=!0,o=a.clientX,r=a.clientY,t.addEventListener("pointermove",s),t.addEventListener("pointerup",l),n.onStart?.(a))},u=e.selfId();if(u){let a=e.onUnmount(c=>{c===u&&(i&&(t.removeEventListener("pointermove",s),t.removeEventListener("pointerup",l),i=!1),a())})}return{onPointerDown:d}}function zn(e,n){let t={};n.onDrop&&(t.onDrop=r=>{r.preventDefault(),n.onDrop(r)}),n.onDragOver&&(t.onDragOver=r=>{r.preventDefault(),n.onDragOver(r)}),n.onDragLeave&&(t.onDragLeave=r=>n.onDragLeave(r));let o={draggable:!0};if(n.onDragStart){let r=n.onDragStart;o.onDragStart=i=>{typeof document<"u"&&document.body.classList.add("wf-dragging"),r(i)}}if(n.onDragEnd){let r=n.onDragEnd;o.onDragEnd=i=>{typeof document<"u"&&document.body.classList.remove("wf-dragging"),r(i)}}return{dropProps:t,dragProps:o}}function pn(e,n){let t=e.selfId(),o={top:0,left:0,refresh:()=>{}};if(!t)return o;let r={pos:o,getEl:n.el,isOpen:n.isOpen,compute:n.compute,panel:n.panel,margin:n.margin??8};e.popupTrackers.set(t,r),e.ensurePopupListeners();let i=e.onUnmount(s=>{s===t&&(e.popupTrackers.delete(t),i())});return o.refresh=()=>{let s=r.getEl();if(!s)return;let l=s.getBoundingClientRect();if(l.width===0&&l.height===0)return;let d=r.compute(l);Object.assign(o,dn(d,r.panel?.(),r.margin))},o}function Yn(e,n){let t=e.selfId(),o=e.browser,r=$e(e),i=()=>typeof n.trigger=="function"?n.trigger():n.trigger??"manual",s=n.open!==void 0,l=()=>!!n.disabled?.(),d=()=>s?typeof n.open=="function"?!!n.open():!!n.open:n.isOpen(),u=n.presence?De(e,{name:n.name}):null,a,c=!1,f=N=>{if(!u)return N?"open":"closed";let x=u.sync(N);return N&&n.lockScroll&&!c&&(Lr(),c=!0),x},p=N=>{l()||(s?n.onOpenChange?.(N):u?N?f(!0):d()&&f(!1):n.setOpen(N))},m=()=>{let N=n.placement;return typeof N=="function"?N():N??"bottom"},g=null,h=!1,w=pn(e,{el:n.el??(()=>null),isOpen:()=>d(),compute:N=>{if(n.position){let x=n.position();return{top:x.y,left:x.x,width:x.width}}return $t(N,m(),n.gap??6,n.center!==!1)},panel:()=>g,margin:n.margin??8}),y=N=>{if(n.closeOnOutside===!1||n.mask||!d())return;let x=N.target;if(!(x instanceof Node))return;let W=n.el?.()??null;W&&W.contains(x)||g&&g.contains(x)||p(!1)},v=N=>{n.closeOnEscape!==!1&&(N.key!=="Escape"||!d()||p(!1))};if(o.addEventListener("mousedown",y),o.addEventListener("keydown",v),t){let N=e.onUnmount(x=>{x===t&&(o.removeEventListener("mousedown",y),o.removeEventListener("keydown",v),N())})}let b={},I=N=>typeof N=="function"?N():N??0,K=()=>I(n.openDelay),D=()=>I(n.closeDelay),C,T,j=()=>{clearTimeout(C),clearTimeout(T),C=void 0,T=void 0},X=N=>{if(l())return;let x=N.currentTarget,W=N.relatedTarget;x.contains(W)||(clearTimeout(T),T=void 0,C=setTimeout(()=>{C=void 0,p(!0)},K()))},L=N=>{if(l())return;let x=N.currentTarget,W=N.relatedTarget;x.contains(W)||(clearTimeout(C),C=void 0,T=setTimeout(()=>{T=void 0,p(!1)},D()))},$=()=>{l()||(clearTimeout(T),T=void 0,C=setTimeout(()=>{C=void 0,p(!0)},K()))},q=()=>{l()||(clearTimeout(C),C=void 0,T=setTimeout(()=>{T=void 0,p(!1)},D()))},se=()=>i()==="hover";if(b.onMouseOver=N=>{se()&&X(N)},b.onMouseOut=N=>{se()&&L(N)},b.onClick=()=>{se()?r||p(!d()):i()==="click"&&p(!0)},b.onFocus=()=>{se()?$():i()==="focus"&&(clearTimeout(T),T=void 0,p(!0))},b.onBlur=()=>{se()?q():i()==="focus"&&(clearTimeout(C),C=void 0,T=setTimeout(()=>{T=void 0,p(!1)},D()))},i()==="longpress"){let N,x=0,W=0,ye=()=>{clearTimeout(N),N=void 0};b.onPointerDown=M=>{l()||(x=M.clientX??0,W=M.clientY??0,ye(),N=setTimeout(()=>{N=void 0,n.onTrigger?.({clientX:x,clientY:W}),p(!0)},n.longPressDuration??500))},b.onPointerUp=ye,b.onPointerLeave=ye,b.onPointerMove=M=>{let yn=Math.abs((M.clientX??0)-x),gn=Math.abs((M.clientY??0)-W);(yn>10||gn>10)&&ye()},b.onContextMenu=M=>{M.preventDefault(),n.onTrigger?.({clientX:M.clientX??0,clientY:M.clientY??0}),p(!0)}}if(b.onKeyDown=N=>{N.key==="Escape"&&n.closeOnEscape!==!1&&p(!1)},t){let N=e.onUnmount(x=>{x===t&&(j(),N())})}let Ke=N=>{if(N){g=N;let x=()=>w.refresh();N.addEventListener("animationend",x,{once:!0})}else g=null},le=null,be=null,ge=N=>{Ke(N),be&&be(N),u?.ref(N),n.trapFocus&&(N?a=Or(N):(a?.(),a=void 0)),n.lockScroll&&!N&&c&&(Mr(),c=!1)};return{get open(){return d()},setOpen:p,get phase(){return u?u.phase:d()?"open":"closed"},sync:f,wrapProps:b,portal:(N,x="popover")=>{if(l())return null;if(!(u?u.phase!=="closed":d()))return h=!1,le=null,null;let ye=n.el?.()??null;(!h||ye!==le)&&(ye?w.refresh():queueMicrotask(()=>{d()&&w.refresh()}),h=!0,le=ye);let M=N.props??{};be=M.ref??null;let yn=n.positioning==="none"?M.class??"":["wf-popup",M.class].filter(Boolean).join(" "),gn=n.positioning==="none"?{...M.style??{},position:"fixed"}:{...M.style??{},position:"fixed",top:`${w.top}px`,left:`${w.left}px`,...w.width!==void 0?{width:`${w.width}px`}:{},maxWidth:(()=>{let qe=typeof n.width=="function"?n.width():n.width;return qe!==void 0?`min(${qe}px, calc(100vw - 32px))`:"calc(100vw - 32px)"})()},Ce={...N,props:{...M,class:yn,style:gn,ref:ge}};if(n.mask){let qe=typeof n.mask=="object"?n.mask:he("div",{class:"wf-popup-mask","data-portal-mask":x,onClick:n.maskClosable===!1?void 0:()=>p(!1)}),Xt=n.maskCentered?he("div",{class:"wf-cover",style:{"--wf-z":"var(--wf-z-popover)",pointerEvents:"none"}},{...Ce,props:{...Ce.props,style:{...M.style??{},pointerEvents:"auto"},ref:ge}}):null,Qt=n.maskCentered?void 0:{...Ce.props?.style??{},zIndex:"var(--wf-z-popover)"},Zt=n.maskCentered?Xt:{...Ce,props:{...Ce.props,style:Qt}};return Ye([qe,Zt],x)}return Ye(Ce,x)},refresh:()=>w.refresh()}}function Jn(e,n){let t=e.selfId();if(t&&!e.openStates.has(t)){e.openStates.set(t,!1);let l=e.onUnmount(d=>{d===t&&(e.openStates.delete(t),l())})}let o=n.open!==void 0;o&&!n.onOpenChange&&n.name&&!e.warned.has(n.name)&&(e.warned.add(n.name),console.warn(`[weifuwu/${n.name}] \u53D7\u63A7\u6A21\u5F0F\uFF08open \u5DF2\u4F20\uFF09\u4F46\u672A\u63D0\u4F9B onOpenChange\uFF0C\u4EA4\u4E92\u65E0\u6CD5\u751F\u6548\u3002
5
+ \u975E\u53D7\u63A7\uFF1A\u53BB\u6389 open\uFF1B\u53D7\u63A7\uFF1A\u4F20\u5165 onOpenChange={(o) => setOpen(o)}`));let r=()=>o?!!n.open:t?e.openStates.get(t)??!1:!1,i=()=>{t?e.render([t]):e.render()},s=l=>{if(o){n.onOpenChange?.(l);return}t&&e.openStates.set(t,l),i()};return{get open(){return r()},setOpen:s,triggerProps:{onClick:()=>s(!0),onFocus:()=>{n.openOnFocus&&s(!0)}}}}var we=V(),je=0,jt="",Wt="",Ft="",Bt="",fn=0;function Kt(){return typeof window<"u"&&typeof document<"u"}function Lr(){if(je++,je>1||!Kt())return;fn=we.scrollTop();let e=we.bodyElement();jt=e.style.overflow,Wt=e.style.position,Ft=e.style.top,Bt=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=`-${fn}px`,e.style.width="100%")}function Mr(){if(je===0||(je--,je>0)||!Kt())return;let e=we.bodyElement();e.style.overflow=jt,e.style.position=Wt,e.style.top=Ft,e.style.width=Bt,fn>0&&we.scrollTo(fn)}var Hr='a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function Or(e){let n;return queueMicrotask(()=>{let t=e.querySelectorAll(Hr);if(t.length===0)return;let o=t[0],r=t[t.length-1],i=l=>{l.key==="Tab"&&(l.shiftKey&&we.activeElement()===o?(l.preventDefault(),r.focus()):!l.shiftKey&&we.activeElement()===r&&(l.preventDefault(),o.focus()))},s=we.activeElement();o.focus(),e.addEventListener("keydown",i),n=()=>{e.removeEventListener("keydown",i),s?.focus()}}),()=>n?.()}function Ur(e){return e.map(n=>{let t={role:n.role,content:n.content};return n.reasoning&&(t.reasoning_content=n.reasoning),t})}function Xn(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`msg-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function qt(e,n,t,o){t.initialMessages?e.messages=structuredClone(t.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 r=null;function i(){if(!e.streaming)return;let m=e.messages[e.messages.length-1];return m&&m.role==="assistant"&&m.status==="streaming"?m:void 0}function s(m,g,h){let w=i();switch(m){case"wf:token":w&&(w.content+=g.text);break;case"wf:tool_call":{w&&(w.toolCalls||(w.toolCalls=[]),w.toolCalls.push({call:g,status:"running"}));break}case"wf:tool_progress":{let y=g,v=w?.toolCalls?.find(b=>b.call.id===y.toolCallId);v&&(v.progress=y);break}case"wf:tool_result":{let y=g,v=w?.toolCalls?.find(b=>b.call.id===y.id);v&&(v.result=y,v.status=y.ok?"ok":"error");break}case"wf:approval_request":w&&(w.approval=g);break;case"wf:usage":w&&(w.usage=g);break;case"wf:step":e.step=g;break;case"wf:done":if(w){w.status="done",w.approval=void 0;let y=g;y.reasoning&&(w.reasoning=y.reasoning)}e.streaming=!1,e.step=null;break;case"wf:error":w&&(w.status="error",w.error=g,w.approval=void 0),e.error=g,e.streaming=!1,e.step=null;break;default:h?.(m,g);break}o?.()}function l(){let m=t.body?t.body(e.messages):{messages:Ur(e.messages)};r=n(t.url,m,{onToken:h=>s("wf:token",{text:h}),onToolCall:h=>s("wf:tool_call",h),onToolProgress:h=>s("wf:tool_progress",h),onToolResult:h=>s("wf:tool_result",h),onApproval:h=>s("wf:approval_request",h),onUsage:h=>s("wf:usage",h),onStep:h=>s("wf:step",h),onDone:h=>s("wf:done",h),onError:h=>s("wf:error",h),onEvent:(h,w)=>s(h,w,t.onEvent)},{signal:t.signal,headers:t.headers}),e.streaming=!0;let g=i();g&&r?.traceId&&(g.id=r.traceId)}function d(){if(e.streaming)return;let m=String(e.input??"").trim();m&&(e.input="",e.error=null,e.usage=null,e.step=null,e.messages.push({id:Xn(),role:"user",content:m,status:"done"},{id:Xn(),role:"assistant",content:"",status:"streaming",toolCalls:[]}),l(),o?.())}function u(){r?.abort(),e.streaming=!1,e.step=null;let m=e.messages[e.messages.length-1];m&&m.role==="assistant"&&m.status==="streaming"&&(!m.content&&(!m.toolCalls||m.toolCalls.length===0)?e.messages.pop():m.status="done"),o?.()}function a(){if(e.streaming)return;let m=-1;for(let g=e.messages.length-1;g>=0;g--)if(e.messages[g].role==="user"){m=g;break}m!==-1&&(e.messages.splice(m+1),e.error=null,e.usage=null,e.step=null,e.messages.push({id:Xn(),role:"assistant",content:"",status:"streaming",toolCalls:[]}),l(),o?.())}function c(){r?.abort(),e.messages=[],e.input="",e.streaming=!1,e.error=null,e.usage=null,e.step=null,o?.()}async function f(m,g,h){let w=e.messages[e.messages.length-1],y=w?.role==="assistant"?w.approval:void 0;if(y&&(w.approval=void 0,o?.(),!!t.approveUrl))try{await fetch(t.approveUrl,{method:"POST",headers:{"Content-Type":"application/json",...t.headers},body:JSON.stringify(h?{id:y.id,decision:m,note:g,modifiedArgs:h}:{id:y.id,decision:m,note:g}),signal:t.signal})}catch(v){if(t.signal?.aborted)return;e.error={code:"provider_error",message:v instanceof Error?v.message:String(v)},o?.()}}function p(){r?.abort(),r=null}return{send:d,stop:u,retry:a,clear:c,approve:f,dispose:p}}function Gt(e,n,t){let o=new AbortController,r=t?.signal;r&&(r.aborted?o.abort():r.addEventListener("abort",()=>o.abort(),{once:!0}));let i=t?.traceId??Fr(),s=t?.record!==!1,l=[],d=(async()=>{let u;try{u=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json","X-Trace-Id":i,Accept:"text/event-stream",...t?.headers},body:JSON.stringify(n),signal:o.signal})}catch(a){if(o.signal.aborted)return;t?.onError?.({code:"provider_error",message:a instanceof Error?a.message:String(a)});return}if(!u.ok){t?.onError?.({code:Wr(u.status),message:`HTTP ${u.status} ${u.statusText}`});return}try{for await(let{name:a,data:c}of Dr(u.body)){if(o.signal.aborted)return;jr(l,{name:a,data:c},s),$r(a,c,t??{})}}catch(a){if(o.signal.aborted)return;t?.onError?.({code:"provider_error",message:a instanceof Error?a.message:String(a)})}})();return{abort:()=>o.abort(),done:d,traceId:i,events:l}}function $r(e,n,t){switch(e){case"wf:token":return t.onToken?.(n.text);case"wf:tool_call":return t.onToolCall?.(n);case"wf:tool_result":return t.onToolResult?.(n);case"wf:tool_progress":return t.onToolProgress?.(n);case"wf:step":return t.onStep?.(n);case"wf:approval_request":return t.onApproval?.(n);case"wf:usage":return t.onUsage?.(n);case"wf:done":return t.onDone?.(n);case"wf:error":return t.onError?.(n);default:return t.onEvent?.(e,n)}}async function*Dr(e){let n=e.getReader(),t=new TextDecoder,o="";try{for(;;){let{done:r,value:i}=await n.read();if(r)break;o+=t.decode(i,{stream:!0});let s=o.split(`
6
6
 
7
7
  `);o=s.pop()??"";for(let l of s){let d="message",u="";for(let a of l.split(`
8
- `))a.startsWith("event: ")?d=a.slice(7):a.startsWith("data: ")&&(u+=a.slice(6));if(u)try{yield{name:d,data:JSON.parse(u)}}catch{}}}}finally{n.releaseLock()}}function Ar(e,n,t){t&&(e.length>=1e3&&e.shift(),e.push(n))}function Ir(e){return e===401||e===403?"auth_failed":e===429?"rate_limited":e>=500?"provider_error":"invalid_request"}function Lr(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`trace-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function Xn(e,n){let t={messages:[],input:"",streaming:!1,error:null,usage:null,step:null},o=new Set,i=jt(t,Wt,n,()=>{for(let l of[...o])l()});Object.assign(t,i),t.subscribe=l=>(o.add(l),()=>{o.delete(l)});let s=e.selfId();if(s){let l=e.onUnmount(d=>{d===s&&(i.dispose(),l())})}return t}function Qn(e,n){let t=e.selfId(),o;return t&&(o=n.subscribe(()=>e.render([t])),e.onUnmount(()=>o?.())),n}function pn(e){let n=e.registry??ye(),t={_selfId:"_wf_root",_mounting:!1,_ctxVersion:0,_rootVNodeId:null},o={browser:e.browser,__registry:n};o.app={navigate:y=>e.browser.navigate(y)};let r=e.renderer??ln({registry:n,ctx:o,rootEl:e.root,onError:e.onError}),i=Mt(y=>{for(let v of y)r.render([v])}),s=new Map,{popupTrackers:l,scrollTrackers:d,ensurePopupListeners:u,destroyPopupListeners:a,cleanupTrackers:c}=i;nn(n,y=>{c(y),l.has(y)&&l.delete(y)});let f=new Set,p=new Map,m=new Map,g=new Map,h=y=>({selfId:()=>{let v=y?._selfVNode?._id??y?._selfId;return typeof v=="string"?v:void 0},render:v=>r.render(v),browser:e.browser,onUnmount:v=>nn(n,v),registry:n,mediaRegistry:s,popupTrackers:l,scrollTrackers:d,isMounting:()=>t._mounting===!0,warned:f,uncontrolledValues:p,inputStates:m,openStates:g,ensurePopupListeners:u}),w=!1;return t.render=function(y){if(y==null){let v=this._selfId!=="_wf_root"&&this._selfId?this._selfId:t._rootVNodeId;return v?r.render([v]):(w||(w=!0,console.warn("[weifuwu] render() \u65E0\u53C2\u4F46\u65E0\u6E32\u67D3\u76EE\u6807\uFF1A\u9875\u9762\u6839\u662F native vnode\uFF08UIHandler \u76F4\u63A5\u8FD4\u56DE vnode \u7684\u9875\u9762\u5F62\u6001\uFF09\u3002\u6539\u7528 async \u7EC4\u4EF6\u5F62\u6001\uFF08const Page: Component = async ... => (props) => ...\uFF09\u6216 createStore + useExternal \u5171\u4EAB\u72B6\u6001\u3002")),Promise.resolve())}return r.render(y)},t.setMounting=y=>{t._mounting=y},t.endMounting=()=>{t._mounting=!1},t.bumpCtxVersion=()=>{t._ctxVersion=(t._ctxVersion??0)+1},t.selfId=function(y){if(typeof y!="string"||!y)throw new Error(`[weifuwu] selfId requires a non-empty string, got ${typeof y}`);if(n.idRegistry.has(y))throw new Error(`[weifuwu] Duplicate component ID: "${y}". Each component must have a unique custom ID.`);let v=this._selfVNode;v&&(v._customId=y,n.idRegistry.set(y,v))},t.onUnmount=function(y){let v=this?._selfVNode?._id??this?._selfId;if(v)return nn(n,b=>{b===v&&y()})},t.useChat=function(y){return Xn(h(this),y)},t.useMedia=function(y,v){return Un(h(this),y,v)},t.useBreakpoint=function(y,v){return $n(h(this),y,v)},t.usePopupPosition=function(y){return fn(h(this),y)},t.useHoverCapable=function(){return $e(h(this))},t.useStableRef=function(y,v){return Ln(h(this),y,v)},t.useVisualViewport=function(){return Dn(h(this))},t.usePopup=function(y){return zn(h(this),y)},t.useLongPress=function(y){return Hn(h(this),y)},t.useInView=function(y){return jn(h(this),y)},t.useScrollPosition=function(y){return Wn(h(this),y)},t.useAsync=function(y){return Bn(h(this),y)},t.useControlled=function(y){return un(h(this),y)},t.useControlledInput=function(y){return Fn(h(this),y)},t.useOpen=function(y){return Yn(h(this),y)},t.usePresence=function(y){return De(h(this),y)},t.useGlobalKey=function(y){return Kn(h(this),y)},t.useDrag=function(y){return qn(h(this),y)},t.useDragDrop=function(y){return Gn(h(this),y)},t.useExternal=function(y){return Qn(h(this),y)},t.useReducedMotion=function(){return dn(h(this))},t.useAnimationEnd=function(y,v){return Mn(h(this),y,v)},t.useTween=function(y,v){return On(h(this),y,v)},t.destroyPopupListeners=a,o.ui=t,{ctx:o,registry:n,renderer:r,rootUi:t,destroyPopupListeners:a}}function Mr(e){let{ctx:n,registry:t,renderer:o}=pn(e);return At({root:e.root,browser:e.browser,ctx:n,registry:t,renderer:o,onError:e.onError})}var Hr=new Set(["svg","path","circle","rect","line","polyline","polygon","g","text","defs","use","clipPath"]);function We(e){e.node=e.node?e.node.nextSibling:null}function Or(e,n){e.node&&e.node.parentNode?e.node.parentNode.insertBefore(n,e.node):e.parent.appendChild(n)}function Ur(e,n){e.node&&e.node.parentNode?(e.node.parentNode.replaceChild(n,e.node),We(e)):e.parent.appendChild(n)}function $r(e,n){for(let[t,o]of Object.entries(n))t==="children"||t==="key"||t==="innerHTML"||re(e,t,o)}function Fe(e,n,t){return Dr[O(e)](e,n,t)}var Dr={hole:()=>null,text:jr,arr:Wr,portal:Ft,frag:Ft,comp:Fr,native:Br};function jr(e,n,t){let o=n.browser??x(),r=String(e);if(t.node&&t.node.nodeType===3)return t.node.textContent!==r&&(t.node.textContent=r),We(t),t.node;let i=o.createTextNode(r);return Or(t,i),i}function Wr(e,n,t){let o=null;for(let r of e){let i=Fe(r,n,t);i!=null&&!o&&(o=i)}return o}function Ft(e,n,t){let r=e.props?.children,i=r==null?[]:Array.isArray(r)?r:[r],s=null;for(let l of i){let d=Fe(l,n,t);d!=null&&!s&&(s=d)}return s}function Fr(e,n,t){let o=e,r=o._child;if(r==null){if(typeof o._render!="function")throw new Error(`[vdom2] component ${R(o.type)} not built before hydration`);for(o._child=null;t.node&&t.node.nodeType===8&&t.node.nodeValue?.startsWith("wf-hole:");)We(t);return null}let i=Fe(r,n,t);return o._refNode||(o._refNode=i),i}function Br(e,n,t){let o=n.browser??x(),r=e,i=r.type,s=r.props??{};for(;t.node&&t.node.nodeType===8&&t.node.nodeValue?.startsWith("wf-hole:");)We(t);let l;if(t.node&&t.node.nodeType===1&&t.node.tagName.toLowerCase()===i.toLowerCase()?(l=t.node,We(t)):(l=Hr.has(i)?o.createElementNS("http://www.w3.org/2000/svg",i):o.createElement(i),Ur(t,l)),r.el=l,$r(l,s),!("innerHTML"in s)){let d={parent:l,node:l.firstChild},u=(Array.isArray(s.children)?s.children:[s.children]).flat(1/0);for(let a of u){let c=Fe(a,n,d);if(c!=null&&c.parentNode!==l&&l.appendChild(c),a&&typeof a=="object"&&!Array.isArray(a)&&k(a)){let f=a;f._parentNode||(f._parentNode=l,f._refNode=c)}}for(;d.node;){let a=d.node;d.node=a.nextSibling,a.parentNode?.removeChild(a)}}return"value"in s&&l instanceof HTMLSelectElement&&(l.value=String(s.value??"")),l}async function Zn(e,n,t){let o=t.__registry;await J(n,t,null,o);let r={parent:e,node:e.firstChild};for(Fe(n,t,r);r.node;){let i=r.node;r.node=i.nextSibling,i.parentNode?.removeChild(i)}}var Kr={idle:{NAVIGATE_START:"navigating"},navigating:{NAVIGATE_DONE:"settled",NAVIGATE_ERROR:"idle"},settled:{NAVIGATE_START:"navigating"}};function Bt(){let e="idle",n=(t,o)=>{let r=Kr[e]?.[t]??null;return r==null?(P({session:"",machine:"route",nodeId:null,component:null,from:e,event:t,to:"?",payload:{path:o},level:"debug",ts:Date.now()}),e):(P({session:"",machine:"route",nodeId:null,component:null,from:e,event:t,to:r,payload:{path:o},level:"debug",ts:Date.now()}),e=r,r)};return{get state(){return e},navigateStart:t=>{n("NAVIGATE_START",t)},navigateDone:t=>{n("NAVIGATE_DONE",t)},navigateError:(t,o)=>{n("NAVIGATE_ERROR",t)}}}function qr(e,n){let t=x(),o=typeof n.root=="string"?t.query(n.root):n.root;if(!o)throw new Error(`uiServe: root not found: ${n.root}`);let r=o,i=!!n.hydrate;!i&&!n.loading&&(r.innerHTML="");try{(new URLSearchParams(globalThis?.location?.search??"").get("vdom_debug")==="1"||globalThis?.localStorage?.getItem?.("__WF_VDOM_DEBUG")==="1")&&(globalThis.__WF_VDOM_DEBUG=!0,console.log("[weifuwu] vdom debug \u5DF2\u5F00\u542F\uFF08?vdom_debug=1\uFF09")),Vn()}catch{}try{if(new URLSearchParams(globalThis?.location?.search??"").get("wf_reflow")==="1"||globalThis?.localStorage?.getItem?.("__WF_REFLOW_DEBUG")==="1"){globalThis.__WF_REFLOW_DEBUG=!0,console.log("[weifuwu] reflow debug \u5DF2\u5F00\u542F\uFF08?wf_reflow=1\u2014\u2014\u5E03\u5C40\u8BFB\u53D6\u8FFD\u8E2A\uFF09");let j=(L,$)=>{let K=typeof document<"u"?document.styleSheets?.length??0:-1,se=$?.tagName?`<${$.tagName}${$.id?"#"+$.id:""}${$.className?"."+String($.className).split(" ")[0]:""}>`:"",Ke=(new Error().stack||"").split(`
9
- `).slice(2,5).map(le=>le.trim().split("/").pop()?.slice(0,80)).join(" \u2190 ");console.log(`[wf-reflow] ${L}${se} styles=${K}${K===0?" \u26A0\uFE0F\u6837\u5F0F\u672A\u52A0\u8F7D\uFF08\u5F3A\u5236\u6392\u7248\u573A\u666F\uFF09":""} :: ${Ke}`)},X=Element.prototype.getBoundingClientRect;Element.prototype.getBoundingClientRect=function(...L){return j("rect",this),X.apply(this,L)};for(let L of["offsetWidth","offsetHeight","offsetTop","offsetLeft","clientWidth","clientHeight","scrollTop","scrollHeight"]){let $=Object.getOwnPropertyDescriptor(Element.prototype,L);if($?.get){let K=$.get;Object.defineProperty(Element.prototype,L,{configurable:!0,enumerable:!0,get(){return j(L,this),K.call(this)}})}}}}catch{}let{ctx:s,registry:l,renderer:d,rootUi:u,destroyPopupListeners:a}=pn({browser:t,root:r}),c=new Map,f=globalThis.__DATA__??window.__DATA__;if(f&&typeof f=="object")for(let[C,T]of Object.entries(f))c.set(C,{value:T});s.data={async get(C,T){let j=c.get(C);if(j&&"value"in j)return j.value;if(j?.promise)return j.promise;if(!T)return;let X=Promise.resolve().then(()=>T()).then(L=>(c.set(C,{value:L}),L));return c.set(C,{promise:X}),X},set(C,T){c.set(C,{value:T})},has(C){return c.has(C)}},s.route={params:{},query:{},path:""};let p=null,m="",g=0,h={},w,y=new Promise(C=>{w=C}),v=!1,b=Bt();async function I(C,T){let j=++g,X=C.indexOf("?"),L=X>=0?C.slice(0,X):C,$=X>=0?C.slice(X):"",K={};if($)for(let[N,V]of new URLSearchParams($))K[N]=V;JSON.stringify(K)!==JSON.stringify(h)&&(s.ui.bumpCtxVersion?.(),h=K);let se={pathname:L,search:$,query:K};s.route={params:{},query:K,path:L},b.navigateStart(L);let Ke=Qe(T?"initial":"nav"),le;try{le=await e.execute(se,s,L)}catch(N){b.navigateError(C,N),le=he("div",{class:"ui-dom-error"},`\u9875\u9762\u6E32\u67D3\u5931\u8D25: ${N?.message??String(N)}`)}if(v||j!==g){Ae();return}let be=E("mount"),ge=be?ct("nav"):"";be&&_("mount","info",ge,`route path=${C} initial=${T}`);let ae;try{ae=await J(le,s,p,l)}catch(N){ae=he("div",{class:"ui-dom-error"},`\u7EC4\u4EF6\u6E32\u67D3\u5931\u8D25: ${N?.message??String(N)}`)}if(!(v||j!==g)){if(T)if(i)await Zn(r,ae,s),E("mount")&&_("mount","debug",ge,`hydrate done=${r.childNodes.length}`);else{r.innerHTML="";let N=U(ae,s,t);E("mount")&&_("mount","debug",ge,`first-render node=${N?.nodeName??"null"} fragKids=${N?.nodeType===11?Array.from(N.childNodes).length:"-"}`),N!=null&&r.appendChild(N),E("mount")&&_("mount","debug",ge,`root-fill done=${r.childNodes.length} first=${r.firstChild?.nodeName}`)}else if(p!==void 0){let N=p;p=ae;let V=N,W=ze(V)?V.el??V._refNode:V._refNode;ne(r,W,N,ae,{browser:t,registry:l,ctxVersion:s?.ui?._ctxVersion??0})}p=ae,m=C,u._rootVNodeId=ae?._id,b.navigateDone(C),Ae()}}let B=t.pathname();I(B,!0).finally(()=>{v||w()}),pt(()=>p),st(),Nt();let D=()=>{let C=typeof window<"u"?window.location.pathname+window.location.search:t.pathname();I(C,!1)};return t.addEventListener("popstate",D),{close(){v=!0,t.removeEventListener("popstate",D),a(),l.idRegistry.clear()},ready:y,ctx:s}}function Be(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Gr(e){return typeof e=="string"?e:Array.isArray(e)?e.filter(Boolean).join(" "):e&&typeof e=="object"?Object.entries(e).filter(([,n])=>n).map(([n])=>n).join(" "):""}function zr(e){return Object.entries(e).filter(([,n])=>n!=null&&n!==!1).map(([n,t])=>`${n}:${typeof t=="number"?t:String(t)}`).join(";")}var Yr=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Jr=new Set(["svg","path","circle","rect","line","polyline","polygon","g","text","defs","use","clipPath"]);async function pe(e,n){return si[O(e)](e,n)}async function Xr(e,n){return""}async function Qr(e,n){return Be(String(e))}function Zr(e){return e==null||typeof e=="boolean"?"hole":Array.isArray(e)?"arr":"vnode"}var ei={hole:e=>Promise.resolve(`<!--${F({type:"hole",value:e,key:null,id:null,fid:null})}-->`),arr:async(e,n,t,o)=>{let r=await pe(e,{...n,_fidPath:o});return`<!--${F({type:"fragment-start",key:String(t),id:null,fid:o})}-->${r}<!--${F({type:"fragment-end",key:String(t),id:null,fid:o})}-->`},vnode:async(e,n)=>{let t=await pe(e,n);return t===""?`<!--${F({type:"hole",value:null,key:null,id:null,fid:null})}-->`:t}};async function ni(e,n){let t=e;ht(t);let o=n._fidPath;return(await Promise.all(t.map(async(i,s)=>{let l=o!=null?`${o}-${s}`:String(s);return ei[Zr(i)](i,n,s,l)}))).join("")}async function ti(e,n){let t=e,o=n._fidPath??null,r=await pe(t.props?.children,{...n,_fidPath:o??void 0});return`<!--${F({type:"fragment-start",key:null,id:null,fid:o})}-->${r}<!--${F({type:"fragment-end",key:null,id:null,fid:o})}-->`}async function oi(e,n){return pe(e.props?.children,n)}async function ri(e,n){let t=e,o=Object.create(n);delete o._fidPath;let r=await t.type(t.props??{},o);if(typeof r!="function")throw new Error(`Component ${R(t.type)} must return a render function. Use (init_props, ctx) => (props) => VNode pattern.`);let i=await r(t.props??{});if(t.key!=null&&i!=null&&typeof i=="object")if(Array.isArray(i))for(let s of i)s!=null&&typeof s=="object"&&!Array.isArray(s)&&(s.key=t.key);else i.key=t.key;return pe(i,o)}async function ii(e,n){let t=e,o=t.type,r=t.props??{},i=[],s=null;t.key!=null&&i.push(` data-wf-key="${Be(String(t.key))}"`);for(let[a,c]of Object.entries(r))if(!(a==="children"||a==="key")&&a!=="ref"&&!(a.startsWith("on")&&typeof c=="function")){if(a==="innerHTML"){s=String(c??"");continue}if(a==="class"||a==="className"){let f=Gr(c);f&&i.push(` class="${Be(f)}"`);continue}if(a==="style"&&c&&typeof c=="object"){i.push(` style="${Be(zr(c))}"`);continue}if(_n.has(a)){i.push(` ${a}="${c?"true":"false"}"`);continue}if(c===!0){i.push(` ${a}`);continue}c===!1||c==null||i.push(` ${a}="${Be(String(c))}"`)}let l=i.join(""),d=Jr.has(o);if(Yr.has(o))return`<${o}${l}>`;if(s!==null)return`<${o}${l}>${s}</${o}>`;let u=await pe(r.children,n);return d?`<${o}${l}>${u}</${o}>`:`<${o}${l}>${u}</${o}>`}var si={hole:Xr,text:Qr,arr:ni,portal:oi,frag:ti,comp:ri,native:ii};function Kt(e){return`<script>window.__DATA__=${JSON.stringify(Object.fromEntries(e)).replace(/</g,"\\u003c")};<\/script>`}function et(e,n){let t={...e,browser:null,__registry:null,ui:{_rootVNodeId:null,render:()=>Promise.resolve(),setMounting:()=>{},endMounting:()=>{}}},o=new Map;return t.data={async get(r,i){let s=o.get(r);if(s&&"value"in s)return s.value;if(s?.promise)return s.promise;if(!i)return;let l=Promise.resolve().then(()=>i()).then(d=>(o.set(r,{value:d}),n.set(r,d),d));return o.set(r,{promise:l}),l},set(r,i){o.set(r,{value:i}),n.set(r,i)},has(r){return o.has(r)}},t}async function li(e,n,t,o={}){let r=o.data??new Map,i=et(t??{},r),s=Se(e,n??{});return pe(s,i)}async function ai(e,n){let t=new Map,r=et({params:{},query:{}},t),i=n.url.split("?")[0].split("#")[0],s=e.match(i);r.params=s.params,r.query=Object.fromEntries(new URLSearchParams(n.url.split("?")[1]??""));let l=new URL(n.url.startsWith("http")?n.url:`http://localhost${n.url.startsWith("/")?n.url:"/"+n.url}`),d=await e.execute(l,r,i),u=await pe(d,r),a=Kt(t),c=s.title??n.title??"",f=n.rootId??"root",p=(n.styles??[]).map(g=>` <link rel="stylesheet" href="${g}">`).join(`
8
+ `))a.startsWith("event: ")?d=a.slice(7):a.startsWith("data: ")&&(u+=a.slice(6));if(u)try{yield{name:d,data:JSON.parse(u)}}catch{}}}}finally{n.releaseLock()}}function jr(e,n,t){t&&(e.length>=1e3&&e.shift(),e.push(n))}function Wr(e){return e===401||e===403?"auth_failed":e===429?"rate_limited":e>=500?"provider_error":"invalid_request"}function Fr(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`trace-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function Qn(e,n){let t={messages:[],input:"",streaming:!1,error:null,usage:null,step:null},o=new Set,i=qt(t,Gt,n,()=>{for(let l of[...o])l()});Object.assign(t,i),t.subscribe=l=>(o.add(l),()=>{o.delete(l)});let s=e.selfId();if(s){let l=e.onUnmount(d=>{d===s&&(i.dispose(),l())})}return t}function Zn(e,n){let t=e.selfId(),o;return t&&(o=n.subscribe(()=>e.render([t])),e.onUnmount(()=>o?.())),n}function mn(e){let n=e.registry??ue(),t={_selfId:"_wf_root",_mounting:!1,_ctxVersion:0,_rootVNodeId:null},o={browser:e.browser,__registry:n};o.app={navigate:y=>e.browser.navigate(y)};let r=e.renderer??an({registry:n,ctx:o,rootEl:e.root,onError:e.onError}),i=Dt(y=>{for(let v of y)r.render([v])}),s=new Map,{popupTrackers:l,scrollTrackers:d,ensurePopupListeners:u,destroyPopupListeners:a,cleanupTrackers:c}=i;tn(n,y=>{c(y),l.has(y)&&l.delete(y)});let f=new Set,p=new Map,m=new Map,g=new Map,h=y=>({selfId:()=>{let v=y?._selfVNode?._id??y?._selfId;return typeof v=="string"?v:void 0},render:v=>r.render(v),browser:e.browser,onUnmount:v=>tn(n,v),registry:n,mediaRegistry:s,popupTrackers:l,scrollTrackers:d,isMounting:()=>t._mounting===!0,warned:f,uncontrolledValues:p,inputStates:m,openStates:g,ensurePopupListeners:u}),w=!1;return t.render=function(y){if(y==null){let v=this._selfId!=="_wf_root"&&this._selfId?this._selfId:t._rootVNodeId;return v?r.render([v]):(w||(w=!0,console.warn("[weifuwu] render() \u65E0\u53C2\u4F46\u65E0\u6E32\u67D3\u76EE\u6807\uFF1A\u9875\u9762\u6839\u662F native vnode\uFF08UIHandler \u76F4\u63A5\u8FD4\u56DE vnode \u7684\u9875\u9762\u5F62\u6001\uFF09\u3002\u6539\u7528 async \u7EC4\u4EF6\u5F62\u6001\uFF08const Page: Component = async ... => (props) => ...\uFF09\u6216 createStore + useExternal \u5171\u4EAB\u72B6\u6001\u3002")),Promise.resolve())}return r.render(y)},t.setMounting=y=>{t._mounting=y},t.endMounting=()=>{t._mounting=!1},t.bumpCtxVersion=()=>{t._ctxVersion=(t._ctxVersion??0)+1},t.selfId=function(y){if(typeof y!="string"||!y)throw new Error(`[weifuwu] selfId requires a non-empty string, got ${typeof y}`);if(n.idRegistry.has(y))throw new Error(`[weifuwu] Duplicate component ID: "${y}". Each component must have a unique custom ID.`);let v=this._selfVNode;v&&(v._customId=y,n.idRegistry.set(y,v))},t.onUnmount=function(y){let v=this?._selfVNode?._id??this?._selfId;if(v)return tn(n,b=>{b===v&&y()})},t.useChat=function(y){return Qn(h(this),y)},t.useMedia=function(y,v){return $n(h(this),y,v)},t.useBreakpoint=function(y,v){return Dn(h(this),y,v)},t.usePopupPosition=function(y){return pn(h(this),y)},t.useHoverCapable=function(){return $e(h(this))},t.useStableRef=function(y,v){return Mn(h(this),y,v)},t.useVisualViewport=function(){return jn(h(this))},t.usePopup=function(y){return Yn(h(this),y)},t.useLongPress=function(y){return On(h(this),y)},t.useInView=function(y){return Wn(h(this),y)},t.useScrollPosition=function(y){return Fn(h(this),y)},t.useAsync=function(y){return Kn(h(this),y)},t.useControlled=function(y){return cn(h(this),y)},t.useControlledInput=function(y){return Bn(h(this),y)},t.useOpen=function(y){return Jn(h(this),y)},t.usePresence=function(y){return De(h(this),y)},t.useGlobalKey=function(y){return qn(h(this),y)},t.useDrag=function(y){return Gn(h(this),y)},t.useDragDrop=function(y){return zn(h(this),y)},t.useExternal=function(y){return Zn(h(this),y)},t.useReducedMotion=function(){return un(h(this))},t.useAnimationEnd=function(y,v){return Hn(h(this),y,v)},t.useTween=function(y,v){return Un(h(this),y,v)},t.destroyPopupListeners=a,o.ui=t,{ctx:o,registry:n,renderer:r,rootUi:t,destroyPopupListeners:a}}function Br(e){let{ctx:n,registry:t,renderer:o}=mn(e);return Ot({root:e.root,browser:e.browser,ctx:n,registry:t,renderer:o,onError:e.onError})}var Kr=new Set(["svg","path","circle","rect","line","polyline","polygon","g","text","defs","use","clipPath"]);function We(e){e.node=e.node?e.node.nextSibling:null}function qr(e,n){e.node&&e.node.parentNode?e.node.parentNode.insertBefore(n,e.node):e.parent.appendChild(n)}function Gr(e,n){e.node&&e.node.parentNode?(e.node.parentNode.replaceChild(n,e.node),We(e)):e.parent.appendChild(n)}function zr(e,n){for(let[t,o]of Object.entries(n))t==="children"||t==="key"||t==="innerHTML"||re(e,t,o)}function Fe(e,n,t){return Yr[U(e)](e,n,t)}var Yr={hole:()=>null,text:Jr,arr:Xr,portal:zt,frag:zt,comp:Qr,native:Zr};function Jr(e,n,t){let o=n.browser??V(),r=String(e);if(t.node&&t.node.nodeType===3)return t.node.textContent!==r&&(t.node.textContent=r),We(t),t.node;let i=o.createTextNode(r);return qr(t,i),i}function Xr(e,n,t){let o=null;for(let r of e){let i=Fe(r,n,t);i!=null&&!o&&(o=i)}return o}function zt(e,n,t){let r=e.props?.children,i=r==null?[]:Array.isArray(r)?r:[r],s=null;for(let l of i){let d=Fe(l,n,t);d!=null&&!s&&(s=d)}return s}function Qr(e,n,t){let o=e,r=o._child;if(r==null){if(typeof o._render!="function")throw new Error(`[vdom2] component ${R(o.type)} not built before hydration`);for(o._child=null;t.node&&t.node.nodeType===8&&t.node.nodeValue?.startsWith("wf-hole:");)We(t);return null}let i=Fe(r,n,t);return o._refNode||(o._refNode=i),i}function Zr(e,n,t){let o=n.browser??V(),r=e,i=r.type,s=r.props??{};for(;t.node&&t.node.nodeType===8&&t.node.nodeValue?.startsWith("wf-hole:");)We(t);let l;if(t.node&&t.node.nodeType===1&&t.node.tagName.toLowerCase()===i.toLowerCase()?(l=t.node,We(t)):(l=Kr.has(i)?o.createElementNS("http://www.w3.org/2000/svg",i):o.createElement(i),Gr(t,l)),r.el=l,zr(l,s),!("innerHTML"in s)){let d={parent:l,node:l.firstChild},u=(Array.isArray(s.children)?s.children:[s.children]).flat(1/0);for(let a of u){let c=Fe(a,n,d);if(c!=null&&c.parentNode!==l&&l.appendChild(c),a&&typeof a=="object"&&!Array.isArray(a)&&k(a)){let f=a;f._parentNode||(f._parentNode=l,f._refNode=c)}}for(;d.node;){let a=d.node;d.node=a.nextSibling,a.parentNode?.removeChild(a)}}return"value"in s&&l instanceof HTMLSelectElement&&(l.value=String(s.value??"")),l}async function et(e,n,t){let o=t.__registry;await B(n,t,null,o);let r={parent:e,node:e.firstChild};for(Fe(n,t,r);r.node;){let i=r.node;r.node=i.nextSibling,i.parentNode?.removeChild(i)}}var ei={idle:{NAVIGATE_START:"navigating"},navigating:{NAVIGATE_DONE:"settled",NAVIGATE_ERROR:"idle"},settled:{NAVIGATE_START:"navigating"}};function Yt(){let e="idle",n=(t,o)=>{let r=ei[e]?.[t]??null;return r==null?(S({session:"",machine:"route",nodeId:null,component:null,from:e,event:t,to:"?",payload:{path:o},level:"debug",ts:Date.now()}),e):(S({session:"",machine:"route",nodeId:null,component:null,from:e,event:t,to:r,payload:{path:o},level:"debug",ts:Date.now()}),e=r,r)};return{get state(){return e},navigateStart:t=>{n("NAVIGATE_START",t)},navigateDone:t=>{n("NAVIGATE_DONE",t)},navigateError:(t,o)=>{n("NAVIGATE_ERROR",t)}}}function ni(e,n){let t=V(),o=typeof n.root=="string"?t.query(n.root):n.root;if(!o)throw new Error(`uiServe: root not found: ${n.root}`);let r=o,i=!!n.hydrate;!i&&!n.loading&&(r.innerHTML="");try{(new URLSearchParams(globalThis?.location?.search??"").get("vdom_debug")==="1"||globalThis?.localStorage?.getItem?.("__WF_VDOM_DEBUG")==="1")&&(globalThis.__WF_VDOM_DEBUG=!0,console.log("[weifuwu] vdom debug \u5DF2\u5F00\u542F\uFF08?vdom_debug=1\uFF09")),Vn()}catch{}try{if(new URLSearchParams(globalThis?.location?.search??"").get("wf_reflow")==="1"||globalThis?.localStorage?.getItem?.("__WF_REFLOW_DEBUG")==="1"){globalThis.__WF_REFLOW_DEBUG=!0,console.log("[weifuwu] reflow debug \u5DF2\u5F00\u542F\uFF08?wf_reflow=1\u2014\u2014\u5E03\u5C40\u8BFB\u53D6\u8FFD\u8E2A\uFF09");let j=(L,$)=>{let q=typeof document<"u"?document.styleSheets?.length??0:-1,se=$?.tagName?`<${$.tagName}${$.id?"#"+$.id:""}${$.className?"."+String($.className).split(" ")[0]:""}>`:"",Ke=(new Error().stack||"").split(`
9
+ `).slice(2,5).map(le=>le.trim().split("/").pop()?.slice(0,80)).join(" \u2190 ");console.log(`[wf-reflow] ${L}${se} styles=${q}${q===0?" \u26A0\uFE0F\u6837\u5F0F\u672A\u52A0\u8F7D\uFF08\u5F3A\u5236\u6392\u7248\u573A\u666F\uFF09":""} :: ${Ke}`)},X=Element.prototype.getBoundingClientRect;Element.prototype.getBoundingClientRect=function(...L){return j("rect",this),X.apply(this,L)};for(let L of["offsetWidth","offsetHeight","offsetTop","offsetLeft","clientWidth","clientHeight","scrollTop","scrollHeight"]){let $=Object.getOwnPropertyDescriptor(Element.prototype,L);if($?.get){let q=$.get;Object.defineProperty(Element.prototype,L,{configurable:!0,enumerable:!0,get(){return j(L,this),q.call(this)}})}}}}catch{}let{ctx:s,registry:l,renderer:d,rootUi:u,destroyPopupListeners:a}=mn({browser:t,root:r}),c=new Map,f=globalThis.__DATA__??window.__DATA__;if(f&&typeof f=="object")for(let[C,T]of Object.entries(f))c.set(C,{value:T});s.data={async get(C,T){let j=c.get(C);if(j&&"value"in j)return j.value;if(j?.promise)return j.promise;if(!T)return;let X=Promise.resolve().then(()=>T()).then(L=>(c.set(C,{value:L}),L));return c.set(C,{promise:X}),X},set(C,T){c.set(C,{value:T})},has(C){return c.has(C)}},s.route={params:{},query:{},path:""};let p=null,m="",g=0,h={},w,y=new Promise(C=>{w=C}),v=!1,b=Yt();async function I(C,T){let j=++g,X=C.indexOf("?"),L=X>=0?C.slice(0,X):C,$=X>=0?C.slice(X):"",q={};if($)for(let[N,x]of new URLSearchParams($))q[N]=x;JSON.stringify(q)!==JSON.stringify(h)&&(s.ui.bumpCtxVersion?.(),h=q);let se={pathname:L,search:$,query:q};s.route={params:{},query:q,path:L},b.navigateStart(L);let Ke=Ze(T?"initial":"nav"),le;try{le=await e.execute(se,s,L)}catch(N){b.navigateError(C,N),le=he("div",{class:"ui-dom-error"},`\u9875\u9762\u6E32\u67D3\u5931\u8D25: ${N?.message??String(N)}`)}if(v||j!==g){Ae();return}let be=E("mount"),ge=be?gt("nav"):"";be&&_("mount","info",ge,`route path=${C} initial=${T}`);let ae;try{ae=await B(le,s,p,l)}catch(N){ae=he("div",{class:"ui-dom-error"},`\u7EC4\u4EF6\u6E32\u67D3\u5931\u8D25: ${N?.message??String(N)}`)}if(!(v||j!==g)){if(T)if(i)await et(r,ae,s),E("mount")&&_("mount","debug",ge,`hydrate done=${r.childNodes.length}`);else{r.innerHTML="";let N=O(ae,s,t);E("mount")&&_("mount","debug",ge,`first-render node=${N?.nodeName??"null"} fragKids=${N?.nodeType===11?Array.from(N.childNodes).length:"-"}`),N!=null&&r.appendChild(N),E("mount")&&_("mount","debug",ge,`root-fill done=${r.childNodes.length} first=${r.firstChild?.nodeName}`)}else if(p!==void 0){let N=p;p=ae;let x=N,W=ze(x)?x.el??x._refNode:x._refNode;ne(r,W,N,ae,{browser:t,registry:l,ctxVersion:s?.ui?._ctxVersion??0})}p=ae,m=C,u._rootVNodeId=ae?._id,b.navigateDone(C),Ae()}}let K=t.pathname();I(K,!0).finally(()=>{v||w()}),vt(()=>p),ct(),Vt();let D=()=>{let C=typeof window<"u"?window.location.pathname+window.location.search:t.pathname();I(C,!1)};return t.addEventListener("popstate",D),{close(){v=!0,t.removeEventListener("popstate",D),a(),l.idRegistry.clear()},ready:y,ctx:s}}function Be(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function ti(e){return typeof e=="string"?e:Array.isArray(e)?e.filter(Boolean).join(" "):e&&typeof e=="object"?Object.entries(e).filter(([,n])=>n).map(([n])=>n).join(" "):""}function oi(e){return Object.entries(e).filter(([,n])=>n!=null&&n!==!1).map(([n,t])=>`${n}:${typeof t=="number"?t:String(t)}`).join(";")}var ri=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),ii=new Set(["svg","path","circle","rect","line","polyline","polygon","g","text","defs","use","clipPath"]);async function me(e,n){return yi[U(e)](e,n)}async function si(e,n){return""}async function li(e,n){return Be(String(e))}function ai(e){return e==null||typeof e=="boolean"?"hole":Array.isArray(e)?"arr":"vnode"}var di={hole:e=>Promise.resolve(`<!--${F({type:"hole",value:e,key:null,id:null,fid:null})}-->`),arr:async(e,n,t,o)=>{let r=await me(e,{...n,_fidPath:o});return`<!--${F({type:"fragment-start",key:String(t),id:null,fid:o})}-->${r}<!--${F({type:"fragment-end",key:String(t),id:null,fid:o})}-->`},vnode:async(e,n)=>{let t=await me(e,n);return t===""?`<!--${F({type:"hole",value:null,key:null,id:null,fid:null})}-->`:t}};async function ui(e,n){let t=e;Ct(t);let o=n._fidPath;return(await Promise.all(t.map(async(i,s)=>{let l=o!=null?`${o}-${s}`:String(s);return di[ai(i)](i,n,s,l)}))).join("")}async function ci(e,n){let t=e,o=n._fidPath??null,r=await me(t.props?.children,{...n,_fidPath:o??void 0});return`<!--${F({type:"fragment-start",key:null,id:null,fid:o})}-->${r}<!--${F({type:"fragment-end",key:null,id:null,fid:o})}-->`}async function fi(e,n){return me(e.props?.children,n)}async function pi(e,n){let t=e,o=Object.create(n);delete o._fidPath;let r=await t.type(t.props??{},o);if(typeof r!="function")throw new Error(`Component ${R(t.type)} must return a render function. Use (init_props, ctx) => (props) => VNode pattern.`);let i=await r(t.props??{});if(t.key!=null&&i!=null&&typeof i=="object")if(Array.isArray(i))for(let s of i)s!=null&&typeof s=="object"&&!Array.isArray(s)&&(s.key=t.key);else i.key=t.key;return me(i,o)}async function mi(e,n){let t=e,o=t.type,r=t.props??{},i=[],s=null;t.key!=null&&i.push(` data-wf-key="${Be(String(t.key))}"`);for(let[a,c]of Object.entries(r))if(!(a==="children"||a==="key")&&a!=="ref"&&!(a.startsWith("on")&&typeof c=="function")){if(a==="innerHTML"){s=String(c??"");continue}if(a==="class"||a==="className"){let f=ti(c);f&&i.push(` class="${Be(f)}"`);continue}if(a==="style"&&c&&typeof c=="object"){i.push(` style="${Be(oi(c))}"`);continue}if(kn.has(a)){i.push(` ${a}="${c?"true":"false"}"`);continue}if(c===!0){i.push(` ${a}`);continue}c===!1||c==null||i.push(` ${a}="${Be(String(c))}"`)}let l=i.join(""),d=ii.has(o);if(ri.has(o))return`<${o}${l}>`;if(s!==null)return`<${o}${l}>${s}</${o}>`;let u=await me(r.children,n);return d?`<${o}${l}>${u}</${o}>`:`<${o}${l}>${u}</${o}>`}var yi={hole:si,text:li,arr:ui,portal:fi,frag:ci,comp:pi,native:mi};function Jt(e){return`<script>window.__DATA__=${JSON.stringify(Object.fromEntries(e)).replace(/</g,"\\u003c")};<\/script>`}function nt(e,n){let t={...e,browser:null,__registry:null,ui:{_rootVNodeId:null,render:()=>Promise.resolve(),setMounting:()=>{},endMounting:()=>{}}},o=new Map;return t.data={async get(r,i){let s=o.get(r);if(s&&"value"in s)return s.value;if(s?.promise)return s.promise;if(!i)return;let l=Promise.resolve().then(()=>i()).then(d=>(o.set(r,{value:d}),n.set(r,d),d));return o.set(r,{promise:l}),l},set(r,i){o.set(r,{value:i}),n.set(r,i)},has(r){return o.has(r)}},t}async function gi(e,n,t,o={}){let r=o.data??new Map,i=nt(t??{},r),s=Pe(e,n??{});return me(s,i)}async function hi(e,n){let t=new Map,r=nt({params:{},query:{}},t),i=n.url.split("?")[0].split("#")[0],s=e.match(i);r.params=s.params,r.query=Object.fromEntries(new URLSearchParams(n.url.split("?")[1]??""));let l=new URL(n.url.startsWith("http")?n.url:`http://localhost${n.url.startsWith("/")?n.url:"/"+n.url}`),d=await e.execute(l,r,i),u=await me(d,r),a=Jt(t),c=s.title??n.title??"",f=n.rootId??"root",p=(n.styles??[]).map(g=>` <link rel="stylesheet" href="${g}">`).join(`
10
10
  `),m=`<!DOCTYPE html>
11
11
  <html lang="${n.lang??"zh-CN"}">
12
12
  <head>
@@ -20,4 +20,4 @@ function Yt(e){let n=[],t=(e||"/").replace(/:(\w+)/g,(o,r)=>(n.push(r),"([^/]+)"
20
20
  ${a}
21
21
  <script src="/app.js"><\/script>
22
22
  </body>
23
- </html>`;return{html:u,dataScript:a,page:m}}function di(e){let n={...e},t=new Set,o=()=>{for(let r of[...t])r()};return{state:n,subscribe(r){return t.add(r),()=>{t.delete(r)}},set(r){Object.assign(n,r),o()},update(r){r(n),o()},notify:o}}export{Q as Fragment,q as Portal,gn as UIRouter,Qt as animateOut,Zt as api,to as auth,J as buildVNode,x as createClientBrowser,Ye as createPortal,ln as createRenderer,et as createSsrContext,di as createStore,pn as createVdomContext,he as h,Zn as hydrateVNode,hn as jsx,Xt as jsxDEV,Jt as jsxs,Mr as mountRoot,ne as patchValue,U as renderValue,Kt as serializeData,ai as ssrPage,li as ssrToString,qr as uiServe,oo as ws};
23
+ </html>`;return{html:u,dataScript:a,page:m}}function vi(e){let n={...e},t=new Set,o=()=>{for(let r of[...t])r()};return{state:n,subscribe(r){return t.add(r),()=>{t.delete(r)}},set(r){Object.assign(n,r),o()},update(r){r(n),o()},notify:o}}export{Q as Fragment,G as Portal,hn as UIRouter,oo as animateOut,ro as api,lo as auth,B as buildVNode,V as createClientBrowser,Ye as createPortal,an as createRenderer,nt as createSsrContext,vi as createStore,mn as createVdomContext,he as h,et as hydrateVNode,uo as i18n,vn as jsx,to as jsxDEV,no as jsxs,Ar as mountCommand,Br as mountRoot,ne as patchValue,O as renderValue,Jt as serializeData,hi as ssrPage,gi as ssrToString,ni as uiServe,Ir as unmountCommand,ao as ws};
@@ -1 +1 @@
1
- var ne=Symbol("Fragment"),ue=Symbol("Portal");function ke(e){return e!=null&&typeof e=="object"&&typeof e.type=="string"}function K(e){return e!=null&&typeof e=="object"&&e.type===ne}function C(e){return e!=null&&typeof e=="object"&&typeof e.type=="function"}function S(e){return e!=null&&typeof e=="object"&&e.type===ue}function w(e){return e==null||typeof e=="boolean"?[]:Array.isArray(e)?e:[e]}var Ne={error:0,warn:1,info:2,debug:3,trace:4},Re=["mount","build","render","diff","lifecycle","route","audit"],I={enabled:!1,stages:new Set,level:"info",filter:null},he=!1;function Je(e){return e&&e in Ne?e:"info"}function Te(e){let n=new Set;if(!e)return n;for(let t of e.split(",")){let o=t.trim().split(":")[0];Re.includes(o)&&n.add(o)}return n}function Ze(){if(he)return I;he=!0;try{let e=globalThis,n=new URLSearchParams(typeof e.location?.search=="string"?e.location.search:""),t=n.get("vdom_trace"),o=n.get("vdom_debug"),i=e.__vdom_trace__,r=typeof e.localStorage?.getItem=="function"?e.localStorage.getItem("vdom_trace"):null;if(o==="1"||e?.localStorage?.getItem?.("__WF_VDOM_DEBUG")==="1")I={enabled:!0,stages:new Set(Re),level:"debug",filter:null};else if(t||i||r){let l=new Set;if(t)for(let d of Te(t))l.add(d);if(i?.stages){let d=Array.isArray(i.stages)?i.stages:[...i.stages];for(let u of d)l.add(u)}if(r)for(let d of Te(r))l.add(d);I={enabled:!0,stages:l,level:t?.includes(":")?Je(t.split(":")[1]):i?.level??"debug",filter:typeof i?.filter=="string"?i.filter:null}}}catch{}return I}function m(e,n="info"){return!I.enabled&&(he||Ze(),!I.enabled)||I.stages.size&&!I.stages.has(e)?!1:Ne[n]<=Ne[I.level]}function h(e,n,t,...o){if(!m(e,n)&&!Pe())return;let i=I.filter;i&&!t.includes(i)||_({session:"",machine:e,nodeId:null,component:null,from:"",event:"TRACE",to:"",payload:()=>o.length?`${t} ${o.join(" ")}`:t,level:n,ts:Date.now()})}function A(e,n=12){if(!e)return"\u2205";if(typeof e=="string"||typeof e=="number")return`"${e}"`;if(!Array.isArray(e))return z(e);let t=e.slice(0,n).map(z);return e.length>n&&t.push(`\u2026+${e.length-n}`),`[${t.join(" | ")}]`}function Qe(e){return typeof e=="function"?"function":e===ne?"fragment":typeof e=="string"?"string":"other"}var en={function:e=>e.name||"Comp",fragment:()=>"Frag",string:e=>String(e),other:e=>String(e)};function z(e){if(e==null||typeof e=="boolean")return String(e);if(typeof e=="string")return`"${e.slice(0,16)}"`;if(typeof e=="number")return String(e);if(Array.isArray(e))return`ARR(${e.length})`;let n=e,t=n.type,o=en[Qe(t)](t),i=n.props?.id?`#${n.props.id}`:n.key!=null?`@${n.key}`:"";return o+i}function k(e){if(!e)return"null";if(e.nodeType===1){let n=e;return`${n.tagName}${n.id?`#${n.id}`:""}${n.getAttribute?.("data-wf-key")?`@${n.getAttribute("data-wf-key")}`:""}`}return e.nodeType===3?`"${(e.textContent??"").slice(0,12)}"`:e.nodeType===8?`<!--${(e.nodeValue??"").slice(0,40)}-->`:`#${e.nodeType}`}function O(e,n=12){if(!e)return"null";let o=Array.from(e.childNodes).slice(0,n).map(k);return e.childNodes.length>n&&o.push(`\u2026+${e.childNodes.length-n}`),`[${o.join(" | ")}]`}var nn={route:"route",lifecycle:"lifecycle",x2y:"diff",keys:"diff",pos:"diff",render:"render",audit:"audit",build:"build",mount:"mount",diff:"diff"};function Ie(e){return nn[e]}var Y=new Set;function tn(e){return Y.add(e),()=>{Y.delete(e)}}var $e=[];function on(){return $e[$e.length-1]??""}function _(e){if(Y.size!==0){e.session||(e.session=on()),typeof e.payload=="function"&&(Y.size>1||m(Ie(e.machine),e.level??"debug"))&&(e.payload=e.payload());for(let n of Y)try{n(e)}catch{}}}function Pe(){return Y.size>1}function rn(e){if(e==null)return"";if(typeof e=="string")return` ${e}`;if(typeof e=="object"){let n=e,t=[];for(let o of["path","i","key","mode","kind","insertedBefore","after","depth"])if(n[o]!==void 0){let i=n[o];t.push(`${o}=${typeof i=="object"?JSON.stringify(i):String(i)}`)}return t.length?" "+t.join(" "):""}return` ${String(e)}`}function ln(e){let n=Ie(e.machine);if(!m(n,e.level??"debug"))return;if(e.event==="TRACE"){console.log(`[vdom:${e.machine}] ${e.payload}`);return}let t=e.component?`${e.component}${e.nodeId?`(${e.nodeId})`:""}`:e.nodeId?`(${e.nodeId})`:"";console.log(`[vdom:${e.machine}] ${t?t+" ":""}${e.from} --${e.event}--> ${e.to}${rn(e.payload)}`)}tn(ln);var dn={fresh:{BUILD_START:"building",BUILD_DONE:"built",PRUNE:"pruned",DISPOSE:"disposed"},building:{BUILD_DONE:"built",DISPOSE:"disposed"},built:{BUILD_START:"building",PRUNE:"pruned",DISPOSE:"disposed"},pruned:{BUILD_START:"building",PRUNE:"pruned",DISPOSE:"disposed"},disposed:{BUILD_START:"building"}};function R(e){let n=0,t=e._parentVNode??null;for(let o=0;o<10&&t;o++)n++,t=t._parentVNode??null;return{name:typeof e.type=="function"?e.type.name||"anonymous":String(e.type),id:e._id??null,depth:n}}var Le=new Map,sn=50;function un(e,n,t,o){if(!e?.id)return;let i=Le.get(e.id);i||(i={name:e.name??"?",events:[]},Le.set(e.id,i)),i.events.push(`${n}--${t}-->${o}`),i.events.length>sn&&i.events.shift()}function P(e,n,t){let o=dn[e]?.[n]??null;return o==null?(_({session:"",machine:"lifecycle",nodeId:t?.id??null,component:t?.name??null,from:e,event:n,to:"?",level:"warn",ts:Date.now()}),e):(un(t,e,n,o),_({session:"",machine:"lifecycle",nodeId:t?.id??null,component:t?.name??null,from:e,event:n,to:o,payload:()=>({depth:t?.depth??0}),level:"debug",ts:Date.now()}),o)}function J(e){return!e||e._lifecycle==="disposed"||e._child==null?!1:!ge(e._child)}function ge(e){if(e==null||typeof e!="object")return!1;if(Array.isArray(e)){for(let t of e)if(ge(t))return!0;return!1}let n=e;return!!(n._lifecycle==="disposed"||n._child!=null&&ge(n._child))}var an=0;function U(){return{idRegistry:new Map,unmountHooks:[],nextId:()=>`_wf_${an++}`}}function Me(e,n){for(let t of[...e.unmountHooks])t(n);e.idRegistry.delete(n),e.idRegistry.delete(`custom:${n}`)}function cn(e,n,t,o){try{e(n)}catch(i){console.error(`[weifuwu] ref ${t} error in <${o??"anonymous"}>`,i)}}function b(e,n){if(e==null||typeof e!="object")return;let t=e;if(t._id){let o=R(t);if(t._customId&&n.idRegistry.delete(t._customId),n.idRegistry.delete(t._id),n.unmountHooks.length>0){let i=[...n.unmountHooks];for(let r of i)r(t._id);if(t._customId)for(let r of i)r(t._customId)}t._id=null,t._customId=null,C(t)&&(t._render=null),t._parentNode=null,t._refNode=null,t._lifecycle=P(t._lifecycle,"DISPOSE",o)}else(C(t)||t._child!=null)&&(t._lifecycle=P(t._lifecycle,"DISPOSE",R(t)));if(t._child!=null){if(Array.isArray(t._child))for(let o of t._child)o&&typeof o=="object"&&b(o,n);else b(t._child,n);t._child=null}if(t.props?.children&&typeof t.type=="string"){let o=Array.isArray(t.props.children)?t.props.children:[t.props.children];for(let i of o)i&&typeof i=="object"&&b(i,n)}if(typeof t.props?.ref=="function"&&cn(t.props.ref,null,"cleanup"),S(t)){let o=t._remoteEl;if(o){let i=t._child;if(i!=null)if(Array.isArray(i))for(let r of i)r&&typeof r=="object"&&b(r,n);else typeof i=="object"&&b(i,n);o.remove(),t._remoteEl=null}}}function v(e){return typeof e=="function"&&e.name||"anonymous"}function je(e){return e.ui?._ctxVersion??0}function Ve(e,n){e.ui?.setMounting?.(n)}function g(e,n){if(e==null||typeof e!="object")return null;if(Array.isArray(e)||K(e)){let o=n;if(o&&o.nodeType===8&&o.nodeValue?.includes("type=fragment-start")){let i=[o],r=/fid=([^\s"]+)/.exec(o.nodeValue)?.[1]??"",l=o.nextSibling;for(;l&&(i.push(l),!(l.nodeType===8&&l.nodeValue?.includes("type=fragment-end")&&(/fid=([^\s"]+)/.exec(l.nodeValue)?.[1]??r)===r));)l=l.nextSibling;return i}return null}let t=e;return C(t)?g(t._outputChild??t._child,n):null}function L(e){if(e==null||typeof e=="boolean")return"hole";if(typeof e=="string"||typeof e=="number")return"text";if(Array.isArray(e))return"arr";let n=e;return K(n)?"frag":S(n)?"portal":C(n)?"comp":"native"}function Ce(e){let n=!1,t=!1;for(let o of e){if(o==null||typeof o=="boolean"||typeof o=="string"||typeof o=="number")continue;if(Array.isArray(o)){t=!0;continue}let i=o;S(i)||(i.key!=null?n=!0:t=!0)}return n&&t?"mixed":n?"keyed":"unkeyed"}function fn(e){if(e===!1)return"false";if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0)return"true";if(typeof e=="object")try{let n=JSON.stringify(e);return`object ${n!=null&&n.length>80?n.slice(0,80)+"\u2026":n??""}`}catch{return`object ${Object.prototype.toString.call(e)}`}return`bad-vnode type=${typeof e}`}function ae(e){return/[\s"=]/.test(e)?`"${e.replace(/"/g,"'")}"`:e}function Z(e){let n=[`type=${e.type}`];return e.value!==void 0&&n.push(`value=${ae(fn(e.value))}`),e.key!=null&&n.push(`key=${ae(e.key)}`),e.id!=null&&n.push(`id=${ae(e.id)}`),e.fid!=null&&n.push(`fid=${ae(e.fid)}`),`wf-hole: ${n.join(" ")}`}var pn=/^on[A-Z]/,yn=/^on[A-Z].*Capture$/;function we(e){let n=yn.test(e);return{type:(n?e.slice(2,-7):e.slice(2)).toLowerCase(),capture:n}}var mn=new Set(["draggable","contenteditable","spellcheck","translate"]),Nn=new Set(["zIndex","opacity","lineHeight","fontWeight","fontSizeAdjust","flex","flexGrow","flexShrink","order","zoom","aspectRatio","gridRow","gridColumn","scale","rotate","animationIterationCount","columnCount","fillOpacity","strokeOpacity","stopOpacity","floodOpacity"]);function _e(e){return mn.has(e.toLowerCase())?"enumerated":e==="class"||e==="className"?"class":e==="style"?"style":e==="ref"?"ref":pn.test(e)?"event":e==="value"?"value":e==="indeterminate"?"indeterminate":e==="innerHTML"?"innerHTML":e.startsWith("aria-")?"aria":"default"}function De(e,n,t){if(t!==!1){if(t===!0){e.setAttribute(n,"");return}try{e[n]=t,e.getAttribute(n)!==String(t)&&e.setAttribute(n,String(t))}catch{e.setAttribute(n,String(t))}}}var hn={enumerated:(e,n,t)=>{e.setAttribute(n,t?"true":"false")},class:(e,n,t)=>{if(t!==!1)if(typeof t=="object")for(let[o,i]of Object.entries(t))i&&e.classList.add(o);else e.setAttribute("class",String(t))},style:(e,n,t)=>{if(t!==!1)if(typeof t=="string")e.setAttribute("style",t);else{let o=e.style;for(let[i,r]of Object.entries(t))r==null?o[i]="":i.startsWith("--")?o.setProperty(i,String(r)):typeof r=="number"&&!Nn.has(i)?o[i]=`${r}px`:o[i]=String(r)}},ref:(e,n,t)=>{if(typeof t=="function")try{t(e)}catch(o){console.error("[weifuwu] ref error",o)}},event:(e,n,t)=>{if(t===!1)return;let{type:o,capture:i}=we(n);if(typeof t!="function"){console.warn(`[weifuwu] event prop ${n} expects a function, got ${typeof t} \u2014 ignored`);return}e.addEventListener(o,t,i?{capture:!0}:{})},value:(e,n,t)=>{t!==!1&&(e.value=t)},indeterminate:(e,n,t)=>{t!==!1&&(e.indeterminate=!!t)},innerHTML:(e,n,t)=>{t!==!1&&(e.innerHTML=String(t??""))},aria:(e,n,t)=>{if(t!==!1){if(typeof t=="boolean"){e.setAttribute(n,t?"true":"false");return}De(e,n,t)}},default:De};function q(e,n,t){t!=null&&hn[_e(n)](e,n,t)}function H(e,n){return e.createComment(Z({type:"hole",value:n,key:null,id:null,fid:null}))}function te(){return!!globalThis?.__WF_VDOM_AUDIT}function gn(e,n){if(e===n)return!0;let t=Object.keys(e),o=Object.keys(n);if(t.length!==o.length)return!1;for(let i of t)if(e[i]!==n[i])return!1;return!0}async function Vn(e,n,t,o){let i=e;i._id||(o?.reuse?._id?i._id=o.reuse._id:i._id=t.nextId(),t.idRegistry.set(i._id,i)),o?.reuse&&(o.reuse._parentNode&&(i._parentNode=o.reuse._parentNode),o.reuse._refNode&&(i._refNode=o.reuse._refNode),o.reuse._ctxVersion!=null&&(i._ctxVersion=o.reuse._ctxVersion));let r=Object.create(n);r.ui=Object.create(n.ui);let l=r.ui;if(l._selfId=i._id??null,l._selfVNode=i,l.render=function(d){let u=n.ui;return d==null&&i._id?u.render([i._id]):u.render(d)},typeof i._render!="function"&&C(o?.reuse)&&typeof o.reuse._render=="function"&&(i._render=o.reuse._render),typeof i._render!="function"){Ve(n,!0);let d;try{d=await i.type(i.props??{},r)}finally{Ve(n,!1)}if(typeof d!="function")throw new Error(`Component ${v(e.type)} must return a render function. Use (init_props, ctx) => (props) => VNode pattern.`);i._render=d}return{renderFn:i._render,childCtx:r}}function be(e){return!!e&&typeof e.then=="function"}function B(e,n,t,o,i){return Cn[L(e)](e,n,t,o,i)}function xe(e,n){return e!=null&&typeof e=="object"&&!Array.isArray(e)&&e.type===n.type?e:null}var Cn={hole:e=>e,text:e=>e,arr:wn,comp:_n,frag:bn,native:Oe,portal:Oe};function wn(e,n,t,o,i){let r=e;m("build")&&h("build","debug","",`array in kids=${A(r)}`);for(let s of r)if(s!=null&&typeof s=="object"&&!Array.isArray(s)&&s._lifecycle==="disposed"){let a=s;_({session:"",machine:"audit",nodeId:a._id??null,component:v(a.type),from:"disposed",event:"CONTRACT_VIOLATION",to:"new-tree",level:"error",ts:Date.now()}),te()&&console.error(`[vdom2/audit] \u4E24\u9636\u6BB5\u5951\u7EA6\u8FDD\u53CD\uFF1A\u7EC4\u4EF6 ${v(a.type)} \u7684 renderFn \u8FD4\u56DE\u4E86 disposed \u65E7 vnode${a._id?`(${a._id})`:""}\u2014\u2014\u590D\u7528\u65E7\u6811\u5BF9\u8C61\uFF08\u5E94\u4E3A\u6BCF\u6B21\u6E32\u67D3\u751F\u6210\u65B0 vnode\uFF09\u3002\u540C\u4E00\u5BF9\u8C61\u65E2\u662F\u65E7\u6811\u53C8\u88AB dispose \u2192 diff \u81EA dispose \u2192 \u5361\u7247\u9519\u4F4D/\u6D88\u5931\uFF08demo \u641C\u7D22\u6062\u590D\u4E8B\u6545\uFF09`);break}for(let s=0;s<r.length;s++){let a=r[s];if(a!=null&&typeof a=="object"&&!Array.isArray(a)){let c=a;c.key!==null&&(c.key=String(c.key))}}let l=Array.isArray(t)?t:[],d=new Map;for(let s of l)s!=null&&typeof s=="object"&&!Array.isArray(s)&&s.key!=null&&d.set(s.key,s);let u=r.map((s,a)=>{let c=null;return s!=null&&typeof s=="object"&&!Array.isArray(s)&&s.key!=null&&(c=d.get(s.key)??null),c==null&&(c=l[a]??null),B(s,n,c,o,i)});m("build")&&h("build","debug","",`array out kids=${A(r)}`);let f=!1;for(let s=0;s<u.length;s++)if(be(u[s])){f=!0;break}return f?Promise.all(u).then(()=>r):r}function _n(e,n,t,o,i){let r=e,l=o??n.__registry??U(),d=xe(t,r);r._id||(r._id=d?._id??l.nextId(),l.idRegistry.set(r._id,r)),d&&(d._parentNode&&(r._parentNode=d._parentNode),d._refNode&&(r._refNode=d._refNode),d._ctxVersion!=null&&(r._ctxVersion=d._ctxVersion),C(r)&&C(d)&&typeof d._render=="function"&&(r._render=d._render));let u=gn(d?.props??{},r.props??{}),f=je(n),s=(d?._ctxVersion??-1)===f;if(!i?.force&&u&&s&&J(d)&&typeof r._render=="function"){let a=d;return r._lifecycle=P(r._lifecycle,"PRUNE",R(r)),r._child=a._child,r._ctxVersion=a._ctxVersion,m("build")&&h("build","debug","",`prune comp=${z(r)} propsSame=${u} verSame=${s}`),r}return r._lifecycle=P(r._lifecycle,"BUILD_START",R(r)),m("build")&&h("build","debug","",`mount comp=${z(r)} propsSame=${u} verSame=${s} force=${!!i?.force}`),(async()=>{let{childCtx:a}=await Vn(r,n,l,{reuse:d??null}),c=await B(await r._render(r.props),a,d?._child,l,i);return r._child=c??null,r._ctxVersion=f,r._lifecycle=P(r._lifecycle,"BUILD_DONE",R(r)),r})()}function bn(e,n,t,o,i){let r=e,l=o??n.__registry??U(),d=xe(t,r);m("build")&&h("build","debug","",`fragment kids=${A(w(r.props?.children))}`);let u=B(r.props?.children??null,n,d?._child??d?.props?.children,l,i);return be(u)?u.then(f=>(r._child=f??null,r._lifecycle=P(r._lifecycle,"BUILD_DONE",R(r)),r)):(r._child=u??null,r._lifecycle=P(r._lifecycle,"BUILD_DONE",R(r)),r)}function Oe(e,n,t,o,i){let r=e;if(typeof r.type!="string"&&typeof r.type!="symbol")return r;let l=o??n.__registry??U(),d=xe(t,r);m("build")&&h("build","trace","",`native <${String(r.type)}> kids=${A(w(r.props?.children))}`);let u=B(r.props?.children??null,n,d?.props?.children,l,i);return be(u)?u.then(f=>(r._child=f??null,r._lifecycle=P(r._lifecycle,"BUILD_DONE",R(r)),r)):(r._child=u??null,r._lifecycle=P(r._lifecycle,"BUILD_DONE",R(r)),r)}function V(){return{activeElement:()=>typeof document<"u"?document.activeElement:null,byId:e=>typeof document<"u"?document.getElementById(e):null,query:e=>typeof document<"u"?document.querySelector(e):null,queryAll:e=>typeof document<"u"?document.querySelectorAll(e):null,createElement:e=>typeof document<"u"?document.createElement(e):null,createElementNS:(e,n)=>typeof document<"u"?document.createElementNS(e,n):null,createDocumentFragment:()=>typeof document<"u"?document.createDocumentFragment():null,createComment:e=>typeof document<"u"?document.createComment(e):null,createTextNode:e=>typeof document<"u"?document.createTextNode(e):null,addEventListener:(e,n,t)=>{typeof window<"u"&&window.addEventListener(e,n,t)},removeEventListener:(e,n,t)=>{typeof window<"u"&&window.removeEventListener(e,n,t)},scrollTo:e=>{typeof window<"u"&&window.scrollTo(0,e)},matchMedia:e=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia(e):null,visualViewport:()=>(typeof window<"u"?window:null)?.visualViewport??null,scrollingElement:()=>typeof document<"u"?document.scrollingElement:null,bodyElement:()=>typeof document<"u"?document.body:null,bodyAppend:e=>{typeof document<"u"&&document.body.appendChild(e)},bodyRemove:e=>{typeof document<"u"&&e.parentNode&&document.body.removeChild(e)},clearBody:()=>{typeof document<"u"&&(document.body.innerHTML="")},event:(e,n)=>{let t=typeof window<"u"?window:null,o=n&&(n.key||n.code)?"KeyboardEvent":n&&(n.clientX!==void 0||n.clientY!==void 0||n.pointerId!==void 0)?"PointerEvent":"Event";try{return new t[o](e,n)}catch{return new t.Event(e,n)}},dispatchEvent:(e,n)=>typeof e<"u"?e.dispatchEvent(n):!1,navigate:e=>{typeof window>"u"||(window.history.pushState(null,"",e),window.dispatchEvent(new PopStateEvent("popstate",{state:null})))},copyText:async e=>{let n=typeof window<"u"?window:null;if(n?.navigator?.clipboard?.writeText)try{return await n.navigator.clipboard.writeText(e),!0}catch{}try{if(typeof document>"u")return!1;let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();let o=document.execCommand("copy");return document.body.removeChild(t),o}catch{return!1}},execCommand:(e,n)=>typeof document<"u"?document.execCommand(e,!1,n):!1,queryCommandState:e=>typeof document<"u"?document.queryCommandState(e):!1,queryCommandValue:e=>typeof document<"u"?document.queryCommandValue(e):"",selectionText:()=>typeof window<"u"?window.getSelection?.()?.toString()??null:null,getSelection:()=>typeof window<"u"?window.getSelection():null,viewportHeight:()=>typeof window<"u"?window.innerHeight:0,viewportWidth:()=>typeof window<"u"?window.innerWidth:0,pathname:()=>typeof window<"u"?window.location.pathname:"",createTreeWalker:(e,n)=>typeof document<"u"?document.createTreeWalker(e,n??NodeFilter.SHOW_ALL):null,scrollTop:()=>{let e=typeof document<"u"?document:null,n=typeof window<"u"?window:null;return e?.scrollingElement?.scrollTop??n?.scrollY??0},hash:()=>typeof window<"u"?window.location?.hash??"":"",setHash:e=>{typeof window<"u"&&(window.location.hash=e)},timeout:(e,n)=>typeof window<"u"?window.setTimeout(e,n):0,rootElement:()=>typeof document<"u"?document.documentElement:null,storageGet:e=>{try{return typeof window<"u"?window.localStorage?.getItem(e)??null:null}catch{return null}},storageSet:(e,n)=>{try{typeof window<"u"&&window.localStorage?.setItem(e,n)}catch{}}}}var xn=new Set(["svg","path","circle","rect","line","polyline","polygon","g","text","defs","use","clipPath"]);function Q(e,n){return H(e,n)}function E(e,n,t,o=null,i=null,r=null){let l=n?.browser??t;if(!l)throw new Error("[vdom2] renderValue requires browser env (ctx.browser)");return $n[L(e)](e,n,l,o,i,r)}function vn(e,n,t){return null}function En(e,n,t){return t.createTextNode(String(e))}function ve(e,n,t,o,i){if(e==null||typeof e=="boolean")return Q(t,e);let r=E(e,n,t,String(o),null,i);return r??Q(t,null)}function Sn(e,n,t,o=null,i=null,r=null){let l=e,d=t.createDocumentFragment();if(!d)return null;m("render")&&h("render","debug","",`array kids=${A(l)} fid=${r??"-"} key=${o??"-"}`);let u=t.createComment(Z({type:"fragment-start",key:o,id:i,fid:r})),f=t.createComment(Z({type:"fragment-end",key:o,id:i,fid:r}));u&&d.appendChild(u);for(let s=0;s<l.length;s++){let a=l[s],c=r!=null?`${r}-${s}`:String(s),p=ve(a,n,t,s,c);p!=null&&d.appendChild(p)}return f&&d.appendChild(f),d}function An(e,n,t){let o=e,i=o,r=t.bodyElement();if(!r)return null;let l=r.querySelector("#__wf_portal");l||(l=t.createElement("div"),l&&(l.id="__wf_portal",r.appendChild(l)));let d=t.createElement("div");if(d){d.setAttribute("data-portal",String(o.props?.portalKey??"wf"));let u=E(o.props?.children??null,n,t);u!=null&&d.appendChild(u),l&&l.appendChild(d),i._remoteEl=d;let f=w(o.props?.children);for(let s of f)s!=null&&typeof s=="object"&&!Array.isArray(s)&&(s._parentVNode=o)}return null}function kn(e,n,t,o=null,i=null,r=null){let l=e,d=l,u=t.createDocumentFragment();if(!u)return null;let f=w(l.props?.children);m("render")&&h("render","debug","",`fragment kids=${A(f)} fid=${r??"-"}`);let s=t.createComment(Z({type:"fragment-start",key:o,id:i,fid:r})),a=t.createComment(Z({type:"fragment-end",key:o,id:i,fid:r}));s&&u.appendChild(s),d._refNode=s;for(let c=0;c<f.length;c++){let p=f[c],y=r!=null?`${r}-${c}`:String(c),N=ve(p,n,t,c,y);N!=null&&u.appendChild(N)}return a&&u.appendChild(a),u}function Tn(e,n,t){let o=e,i=o._lifecycle??(typeof o._render=="function"?"built":"fresh");return Rn[i](o,n,t)}var Rn={fresh:(e,n,t)=>{throw new Error(`[vdom2] component ${v(e.type)} not built (missing _render) \u2014 buildVNode must run before renderValue`)},building:(e,n,t)=>{throw new Error(`[vdom2] component ${v(e.type)} building in render \u2014 buildVNode must await before renderValue`)},disposed:(e,n,t)=>(console.warn(`[vdom2] disposed \u7EC4\u4EF6 ${v(e.type)} \u5728\u6E32\u67D3\u2014\u2014\u526A\u679D\u7F13\u5B58\u5931\u6548\u2014\u2014\u7236\u6811\u91CD\u5EFA\u4E2D\uFF08\u5360\u4F4D\u515C\u5E95\uFF09`),Q(t,null)),built:He,pruned:He};function He(e,n,t){let o=e._child;if(o==null)return e._child=null,null;e._child=o,e._outputChild=o,typeof o=="object"&&!Array.isArray(o)&&(o._parentVNode=e);let i=E(o,n,t);if(i){if(e._refNode=i.nodeType===11?i.firstChild:i,e._id)if(i.nodeType===11)for(let r of Array.from(i.childNodes))r.nodeType===1&&r.setAttribute("data-wf-id",e._id);else i.nodeType===1&&i.setAttribute("data-wf-id",e._id);if(e.key!=null)if(i.nodeType===11)for(let r of Array.from(i.childNodes))r.nodeType===1&&r.setAttribute("data-wf-key",e.key);else i.nodeType===1&&i.setAttribute("data-wf-key",e.key)}return i}function Pn(e,n,t,o,i){let r=e,l=r,d=r.type,u=xn.has(d)?t.createElementNS("http://www.w3.org/2000/svg",d):t.createElement(d);if(!u)return null;l.el=u,l._refNode=u,m("render")&&h("render","trace","",`native <${d}> key=${r.key??"-"} kids=${A(w(r.props?.children))}`),r.key!=null&&u.setAttribute("data-wf-key",r.key);let f=null;for(let[s,a]of Object.entries(r.props??{}))if(!(s==="children"||s==="key")){if(s==="value"&&u instanceof HTMLSelectElement){f=a;continue}q(u,s,a)}if(!("innerHTML"in(r.props??{}))){let s=w(r.props?.children);for(let a=0;a<s.length;a++){let c=s[a],p=i!=null?`${i}-${a}`:String(a),y=ve(c,n,t,a,p);if(y!=null&&(u.appendChild(y),c&&typeof c=="object"&&!Array.isArray(c)&&typeof c.type=="function")){let N=c;N._parentNode||(N._parentNode=u)}}m("render")&&h("render","trace","",`native <${d}> out=${O(u)}`)}return f!==null&&(u.value=String(f)),u}var $n={hole:vn,text:En,arr:Sn,portal:An,frag:kn,comp:Tn,native:Pn};function F(e){let{parent:n,oldNode:t,oldInput:o,ctx:i}=e,r=E(e.newInput,i,i.browser??V());if(r==null)return null;if(t?.parentNode){let l=oe(o,t,n,i);return l&&l.parentNode===n?n.insertBefore(r,l):n.appendChild(r),r}return n.appendChild(r),r}function In(e){return oe(e.oldInput,e.oldNode,e.parent,e.ctx),null}function Ln(e){let n=e.oldNode;if(n?.nodeType===8){let t=Q(e.ctx.browser??V(),e.newInput);return t&&n.nodeValue!==t.nodeValue&&(n.nodeValue=t.nodeValue),n}return null}function ee(e){let{parent:n,oldNode:t,ctx:o}=e,i=E(e.newInput,o,o.browser??V());return i==null?null:(t?.parentNode?t.parentNode.replaceChild(i,t):t?n.insertBefore(i,t):n.appendChild(i),i)}function Mn(e){let{parent:n,oldNode:t,oldInput:o}=e,i=String(e.newInput);if(String(o)!==i){if(t&&t.nodeType===3)return t.nodeValue=i,t;let r=n.ownerDocument.createTextNode(i);return t?.parentNode?t.parentNode.replaceChild(r,t):n.appendChild(r),r}return t}function jn(e){let{parent:n,oldNode:t,oldInput:o,ctx:i}=e,r=e.newInput,l=o&&typeof o=="object"&&!Array.isArray(o)?o:null,d=r.type;if(t&&t.nodeType===1&&(l?.type??null)===d&&ke(r)){let u=t;return r.el=u,r._refNode=u,Fe(u,l?.props??{},r.props??{}),"innerHTML"in(r.props??{})||re(u,l?._child??l?.props?.children??null,r._child??r.props?.children??null,i),u}return F(e)}function Dn(e){let{parent:n,oldNode:t,oldInput:o,ctx:i}=e,r=e.newInput,l=o&&typeof o=="object"&&!Array.isArray(o)?o:null,d=K(l)?g(l,t):null,u=Ee(n,l??o,r,i,d);return t?.parentNode?t:u[0]??null}function On(e){let{parent:n,oldNode:t,oldInput:o,ctx:i}=e,r=e.newInput;if(!C(r)||typeof r._render!="function")throw new Error(`[vdom2] component ${v(r.type)} not built in diff \u2014 buildVNode must run before patchValue`);let l=o&&typeof o=="object"&&!Array.isArray(o)?o:null;if(l?.type!=null&&l.type!==r.type)return F(e);let d=l?.type===r.type;if(!i.force&&l&&d&&J(l)&&r._child===l._child)return t;l?.type===r.type&&l._id&&(r._id=l._id,i.registry.idRegistry.set(r._id,r)),r._parentNode=n,t&&(r._refNode=t);let u=r._child;if(u===null){r._outputChild=null,r._refNode=null;let s=t?.parentNode!=null,a=oe(l?._child??null,t,n,i);l&&(l._child=null);let c=Q(i.browser??V(),null);return s&&c?(a&&a.parentNode===n?n.insertBefore(c,a):n.appendChild(c),c):W(n,t,l?._child,null,i)}r._outputChild=u;let f=W(n,t,l?._child,u,i);return f&&(r._refNode=f),f}function Hn(e){let{parent:n,oldNode:t,oldInput:o,ctx:i}=e;if(o===e.newInput&&t?.parentNode)return t;let r=n.ownerDocument.createDocumentFragment(),l=re(n,o,e.newInput,i,t?[t]:null);for(let d of l)d&&r.appendChild(d);return t?.parentNode?r.contains(t)?n.appendChild(r):t.parentNode.replaceChild(r,t):n.appendChild(r),r}function Bn(e){let{ctx:n,oldInput:t}=e,o=e.newInput,i=t&&typeof t=="object"&&!Array.isArray(t)?t:null;if(S(i)&&S(o)){let r=i._remoteEl;if(r){let l=i._child??i.props?.children??null,d=o._child??o.props?.children??null;re(r,l,d,n)}return o._remoteEl=i._remoteEl,null}return F(e)}function G(e){return{text:F,native:F,frag:F,comp:F,arr:F,hole:In,portal:F,...e}}var Fn={text:G({text:Mn}),hole:G({text:ee,native:ee,frag:ee,comp:ee,arr:ee,portal:ee,hole:Ln}),native:G({native:jn}),frag:G({frag:Dn}),comp:G({comp:On}),arr:G({arr:Hn}),portal:G({portal:Bn})};function Be(e){let n=L(e.oldInput),t=L(e.newInput);return _({session:"",machine:"x2y",nodeId:null,component:null,from:n,event:"X2Y",to:t,level:"trace",ts:Date.now()}),Fn[n][t](e)}function M(e,n){if(n&&typeof e.type=="function"&&e._id){try{b(e,n)}catch(t){console.error("[weifuwu] ref cleanup error",t)}Me(n,e._id)}}function se(e){if(e==null||typeof e!="object"||Array.isArray(e))return null;let n=e;return S(n)?typeof n.props?.portalKey=="string"?n.props.portalKey:null:n.key}function Se(e,n){if(n&&e&&typeof e=="object"&&!Array.isArray(e)){let t=g(e,n);if(t&&t.length>1)return t}return[n]}function ce(e,n){let t=w(e.props?.children);for(let o of t){if(o==null||typeof o!="object"||Array.isArray(o))continue;let i=o;Kn[L(i)](i,n)}}var Kn={comp:(e,n)=>{M(e,n)},frag:(e,n)=>{ce(e,n)},native:(e,n)=>{ce(e,n)},portal:(e,n)=>{ce(e,n)},arr:()=>{},text:()=>{},hole:()=>{}};function oe(e,n,t,o){return Un[L(e)](e,n,t,o)}var Un={arr:(e,n,t,o)=>{let i=g(e,n);if(i&&i.length){let r=(i[i.length-1]??n)?.nextSibling??null;for(let l of i)l.parentNode&&l.parentNode.removeChild(l);return r&&r.parentNode===t?r:null}return ie(e,n,t,o)},frag:(e,n,t,o)=>{let i=e,l=g(i,n)??[],d=(l[l.length-1]??n)?.nextSibling??null;for(let u of l)u.parentNode&&u.parentNode.removeChild(u);return ce(i,o.registry),d&&d.parentNode===t?d:null},portal:(e,n,t,o)=>{let i=e,r=i._remoteEl;try{b(i.props?.children,o.registry)}catch(l){console.error("[weifuwu] portal ref cleanup error",l)}return r?.parentNode?.removeChild(r),null},comp:(e,n,t,o)=>{let i=e,r=g(i,n);if(M(i,o.registry),r&&r.length>1){let l=(r[r.length-1]??n)?.nextSibling??null;for(let d of r)d.parentNode&&d.parentNode.removeChild(d);return l&&l.parentNode===t?l:null}return ie(e,n,t,o)},native:(e,n,t,o)=>{try{b(e,o.registry)}catch(i){console.error("[weifuwu] ref cleanup error",i)}return ie(e,n,t,o)},text:(e,n,t,o)=>ie(e,n,t,o),hole:(e,n,t,o)=>ie(e,n,t,o)};function ie(e,n,t,o){let i=n?.nextSibling??null;return n?.parentNode&&n.parentNode.removeChild(n),i&&i.parentNode===t?i:null}function W(e,n,t,o,i){return Be({parent:e,oldNode:n,oldInput:t,newInput:o,ctx:i})}var qn={event:(e,n,t,o)=>{let{type:i,capture:r}=we(n);typeof t=="function"&&e.removeEventListener(i,t,r?{capture:!0}:{}),o!=null&&o!==!1&&(typeof o!="function"?console.warn(`[weifuwu] event prop ${n} expects a function, got ${typeof o} \u2014 ignored`):e.addEventListener(i,o,r?{capture:!0}:{}))},class:(e,n,t,o)=>{o==null||o===!1?e.removeAttribute("class"):(e.className="",q(e,n,o))},ref:(e,n,t,o)=>{if(o==null||o===!1){if(typeof t=="function")try{t(null)}catch(i){console.error("[weifuwu] ref cleanup error",i)}}else q(e,n,o)},value:(e,n,t,o)=>{o==null||o===!1?e.value="":q(e,n,o)},indeterminate:(e,n,t,o)=>{o==null||o===!1?e.indeterminate=!1:q(e,n,o)},enumerated:le,style:le,innerHTML:le,aria:le,default:le};function le(e,n,t,o){if(o==null||o===!1){e.removeAttribute(n);try{delete e[n]}catch{}}else q(e,n,o)}function Fe(e,n,t){let o=Object.keys(n),i=Object.keys(t);if(o.length===i.length){let l=!0;for(let d=0;d<o.length;d++)if(o[d]!==i[d]||n[o[d]]!==t[o[d]]){l=!1;break}if(l)return}let r=new Set([...o,...i]);for(let l of r){if(l==="children"||l==="key")continue;let d=n[l],u=t[l];d!==u&&qn[_e(l)](e,l,d,u)}}function Ee(e,n,t,o,i){let r=Array.isArray(n)?n:n?._child??n?.props?.children??null,l=Array.isArray(t)?t:t?._child??t?.props?.children??null;return re(e,r,l,o,i)}function re(e,n,t,o,i,r){let l=w(n),d=w(t),u=i??Array.from(e.childNodes);m("diff")&&h("diff","debug","",`patchChildren parent=${k(e)} old=${A(l)} new=${A(d)} dom=${O(e)}`);let f=d.some(p=>Array.isArray(p))||l.some(p=>Array.isArray(p)),s=f?"unkeyed":Ce(d);if(_({session:"",machine:"keys",nodeId:null,component:null,from:f?"unkeyed":Ce(d),event:"SELECT",to:s,payload:()=>({len:d.length}),level:"trace",ts:Date.now()}),te()&&l.length!==d.length)for(let p=0;p<d.length;p++){let y=d[p];y!=null&&typeof y=="object"&&!Array.isArray(y)&&C(y)&&y.key==null&&console.error(`[vdom2/audit] \u52A8\u6001\u6570\u7EC4\u4F4D\u7F6E ${p} \u7684\u7EC4\u4EF6\u7F3A\u5C11 key\u2014\u2014\u5217\u8868\u589E\u5220/\u91CD\u6392\u4F1A\u9519\u4F4D\u7EC4\u4EF6\u5B9E\u4F8B\u72B6\u6001\u3002\u8BF7\u63D0\u4F9B\u4E1A\u52A1\u8EAB\u4EFD key\uFF08\u5982 key={item.id}\uFF09\uFF1B\u65E0\u72B6\u6001 native \u9879\u8C41\u514D\u3002`)}let a=i&&i.length?i[i.length-1]:null;s==="mixed"&&(fe(d),fe(l));let c=(()=>{let p=u;p.length>=2&&p[0]?.nodeType===8&&p[0].nodeValue?.includes("fragment-start")&&p[p.length-1]?.nodeType===8&&p[p.length-1].nodeValue?.includes("fragment-end")&&(p=p.slice(1,-1));let y=[],N=0;for(let T=0;T<l.length;T++){let x=l[T];if(Array.isArray(x)){let j=p[N]??null;y.push(j);let D=g(x,j);N+=D?.length??1;continue}if(x==null||typeof x=="boolean"||typeof x=="string"||typeof x=="number"){y.push(p[N]??null),N++;continue}let $=x;if(S($)){y.push($._remoteEl??null);continue}if(y.push($._refNode??p[N]??null),typeof $.type=="function"||K($)){let j=g($,$._refNode??p[N]??null);N+=j?.length??1}else N++}return y})();return ct[s]({parent:e,oldChildren:l,newChildren:d,oldNodes:c,ctx:o,arrEnd:a,anchorOut:r})}function de(e){return e==null||typeof e=="boolean"?"hole":Array.isArray(e)||e&&typeof e=="object"&&K(e)?"multi":"real"}function Wn(e){let{parent:n,oldC:t,oldNode:o,oldNodes:i,i:r,ctx:l,out:d,pushA:u}=e;if(Array.isArray(t)){m("diff")&&h("diff","trace","",`remove-arr-item i=${r} range=[${(g(t,i[r])??[]).map(k).join(" | ")}] before=${O(n)}`);let f=g(t,o);for(let s of f??[])s.parentNode?.removeChild(s);m("diff")&&h("diff","trace","",`remove-arr-item after=${O(n)}`);for(let s of t)s!=null&&typeof s=="object"&&!Array.isArray(s)&&typeof s.type=="function"&&M(s,l.registry)}else if(t&&typeof t=="object"&&!Array.isArray(t)){if(typeof t.type=="function")M(t,l.registry);else try{b(t,l.registry)}catch(f){console.error("[weifuwu] ref cleanup error",f)}o?.parentNode&&o.parentNode.removeChild(o)}else o?.parentNode&&o.parentNode.removeChild(o);d.push(null),u(null)}function zn(e){let{parent:n,newC:t,oldNode:o,i,oldNodes:r,out:l,pushA:d,ctx:u}=e,f=H(u.browser??V(),t);if(o?.nodeType===8){f&&o.nodeValue!==f.nodeValue&&(o.nodeValue=f.nodeValue),l.push(o),d(o);return}if(f&&o?.parentNode)o.parentNode.replaceChild(f,o);else if(f){let s=null;for(let a=i+1;a<r.length;a++){let c=r[a];if(c&&c.parentNode===n){s=c;break}}if(!s){let a=null;for(let c=l.length-1;c>=0;c--)if(l[c]){a=l[c];break}a&&a.parentNode===n&&(s=a.nextSibling)}s&&s.parentNode===n?n.insertBefore(f,s):n.appendChild(f),l.push(f),d(f)}else l.push(f),d(f)}function Ke(e){let{parent:n,newC:t,oldNode:o,i,oldNodes:r,out:l,pushA:d,ctx:u}=e,f=E(t,u,u.browser??V(),String(i));if(f==null){l.push(null),d(null);return}if(o&&o.nodeType===8&&o.nodeValue?.includes("type=hole")){_({session:"",machine:"pos",nodeId:null,component:null,from:"hole",event:"HOLE_FILL",to:"real",payload:()=>({i,replaced:k(o)}),level:"trace",ts:Date.now()}),o.parentNode?.replaceChild(f,o),l.push(f),d(f);return}let s=null;for(let a=i+1;a<r.length;a++){let c=r[a];if(c&&c.parentNode===n){s=c;break}}if(s==null){let a=null;for(let c=l.length-1;c>=0;c--)if(l[c]){a=l[c];break}if(a&&a.parentNode===n)s=a.nextSibling;else{let c=r[r.length-1];c&&c.parentNode===n&&(s=c.nextSibling)}}s&&s.parentNode===n?n.insertBefore(f,s):n.appendChild(f),_({session:"",machine:"pos",nodeId:null,component:null,from:"hole",event:"INSERT",to:"real",payload:()=>({i,insertedBefore:s?k(s):"END",node:k(f)}),level:"trace",ts:Date.now()}),l.push(f),d(f)}function Gn(e){let{parent:n,oldC:t,newC:o,oldNode:i,out:r,pushA:l,ctx:d}=e;if(t&&typeof t=="object"&&!Array.isArray(t)&&typeof t.type=="function"){let f=We(n,t,i,o,d);r.push(f),l(f);return}let u=ze(n,t,i,o,d);r.push(u),l(u)}function Xn(e){let{parent:n,oldC:t,newC:o,oldNode:i,i:r,out:l,pushA:d,ctx:u}=e,f=u.browser??V(),s=E(o,u,f,String(r));if(s==null){l.push(null),d(null);return}let a=t&&typeof t=="object"?g(t,i):null;if(a&&a.length>1){let p=(a[a.length-1]??i)?.nextSibling??null;for(let y of a)y.parentNode&&y.parentNode.removeChild(y);if(t&&typeof t=="object"&&!Array.isArray(t))if(typeof t.type=="function")M(t,u.registry);else try{b(t,u.registry)}catch(y){console.error("[weifuwu] ref cleanup error",y)}p&&p.parentNode===n?n.insertBefore(s,p):n.appendChild(s)}else i?.parentNode?i.parentNode.replaceChild(s,i):n.appendChild(s);let c=s.nodeType===11?Array.from(s.childNodes):[s];l.push(...c),d(c[0]??s)}function Yn(e){let{parent:n,oldC:t,newC:o,oldNode:i,out:r,pushA:l,ctx:d}=e,u=qe(n,t,i,o,d);r.push(u),l(u)}function Jn(e){let{parent:n,oldC:t,newC:o,oldNode:i,i:r,oldNodes:l,out:d,pushA:u,ctx:f}=e,s=f.browser??V(),a=g(t,i);m("diff")&&h("diff","debug","",`multi-remove i=${r} range=${a?a.map(k).join(" | "):"null"}`);for(let y of a??[])y.parentNode?.removeChild(y);for(let y of w(t?.props?.children))y!=null&&typeof y=="object"&&!Array.isArray(y)&&typeof y.type=="function"&&M(y,f.registry);let c=E(o,f,s,String(r));if(c==null){d.push(null),u(null);return}let p=l[r+1]??null;p?.parentNode?p.parentNode.insertBefore(c,p):n.appendChild(c),d.push(c),u(c)}function Zn(e){let{parent:n,oldC:t,newC:o,oldNode:i,oldNodes:r,i:l,out:d,pushA:u,ctx:f}=e,s=g(t,i),a=Ee(n,t,o,f,s);d.push(...a),u(r[l]??a[0]??null)}function Qn(e){let{parent:n,oldC:t,newC:o,oldNode:i,i:r,out:l,pushA:d,ctx:u}=e;if(o&&typeof o=="object"&&!Array.isArray(o)&&typeof o.type=="function"&&o._lifecycle==="disposed"){let a=Xe(n,i,u,v(o.type));l.push(a),d(a);return}let f=W(n,i,t,o,u);m("diff")&&h("diff","trace","",`after-patch i=${r} new=${z(o)} node=${k(f)} dom=${O(n)}`);let s=Se(o,f);l.push(...s),d(s[0]??f??null)}function qe(e,n,t,o,i){let r=H(i.browser??V(),o),l=g(n,t),d=((l??[])[l?.length?l.length-1:0]??t)?.nextSibling??null;for(let u of l??[])u.parentNode?.removeChild(u);for(let u of w(n?.props?.children))u!=null&&typeof u=="object"&&!Array.isArray(u)&&typeof u.type=="function"&&M(u,i.registry);return r&&d&&d.parentNode===e?e.insertBefore(r,d):r&&e.appendChild(r),r}function We(e,n,t,o,i){let r=H(i.browser??V(),o),l=oe(n,t,e,i);return r&&l?e.insertBefore(r,l):r&&e.appendChild(r),r}function ze(e,n,t,o,i){let r=H(i.browser??V(),o);if(n&&typeof n=="object"&&!Array.isArray(n))if(typeof n.type=="function")M(n,i.registry);else try{b(n,i.registry)}catch(l){console.error("[weifuwu] ref cleanup error",l)}return r&&t?.parentNode?t.parentNode.replaceChild(r,t):r&&e.appendChild(r),r}var et={hole:{hole:zn,real:Ke,multi:Ke},real:{hole:Gn,real:Qn,multi:Xn},multi:{hole:Yn,real:Jn,multi:Zn}};function nt(e){let{parent:n,oldChildren:t,newChildren:o,oldNodes:i,ctx:r,anchorOut:l}=e,d=Math.max(t.length,o.length),u=[],f=s=>{l&&l.push(s)};for(let s=0;s<d;s++){let a=s<t.length?t[s]:null,c=s<o.length?o[s]:null;if(s>=o.length){Wn({parent:n,oldC:a,newC:c,oldNode:i[s],i:s,oldNodes:i,newChildren:o,out:u,pushA:f,ctx:r});continue}if(a!=null&&typeof a=="object"&&!Array.isArray(a)&&c!=null&&typeof c=="object"&&!Array.isArray(c)&&c===a&&J(a)){u.push(i[s]),f(i[s]);continue}let p=et[de(a)][de(c)];_({session:"",machine:"pos",nodeId:null,component:null,from:de(a),event:p.name,to:de(c),payload:()=>({i:s}),level:"trace",ts:Date.now()}),p({parent:n,oldC:a,newC:c,oldNode:i[s],i:s,oldNodes:i,newChildren:o,out:u,pushA:f,ctx:r})}return u}function Ue(e){let{parent:n,oldChildren:t,newChildren:o,oldNodes:i,ctx:r,anchorOut:l,arrEnd:d}=e,u=new Map;t.forEach((p,y)=>{let N=se(p);N!==null&&p&&typeof p=="object"&&!Array.isArray(p)&&u.set(N,{vnode:p,nodes:[i[y]??null].filter(Boolean),index:y})});let f=[],s=new Set,a=p=>{l&&l.push(p)},c=null;return o.forEach((p,y)=>{let N=se(p),T=p;if(N!==null&&u.has(N)){let x=u.get(N),$=x.nodes[0]??null;if(s.add(N),T&&typeof T=="object"&&typeof T.type=="function"&&T._lifecycle==="disposed"){let X=Xe(n,$,r,v(T.type));f.push(X),a(X),X&&(c=X);return}let j=W(n,$,x.vnode,T,r),D=Se(T,j),ye=D[0]??j,Ae=D[D.length-1]??j;if(ye&&ye.parentNode===n&&c&&ye.previousSibling!==c){m("diff")&&h("diff","debug","",`keyed-correct i=${y} k=${N} move=[${D.map(k).join(" | ")}] after=${k(c)} before=${O(n)}`);let X=c.nextSibling;for(let me of D)me&&me.parentNode===n&&n.insertBefore(me,X);m("diff")&&h("diff","debug","",`keyed-correct after=${O(n)}`)}f.push(...D),a(D[0]??j??null),Ae&&(c=Ae)}else{let x={current:c};dt[lt(p)]({parent:n,oldChildren:t,newChildren:o,oldNodes:i,ctx:r,out:f,pushA:a,arrEnd:d,c:p,i:y},x),c=x.current}}),t.forEach((p,y)=>{ot[tt(se(p),s)](n,p,y,i,r,o.length)}),f}function tt(e,n){return e===null?"unkeyed":n.has(e)?"moved":"stale-keyed"}var ot={moved:()=>{},"stale-keyed":rt,unkeyed:it};function rt(e,n,t,o,i){let r=n&&typeof n=="object"&&!Array.isArray(n)?g(n,o[t]):null;if(m("diff")&&h("diff","trace","",`keyed-delete i=${t} k=${se(n)} range=${r?.length??0} oldNode=${k(o[t])}`),n&&typeof n=="object"&&!Array.isArray(n))if(typeof n.type=="function")M(n,i.registry);else try{b(n,i.registry)}catch(l){console.error("[weifuwu] ref cleanup error",l)}Ge(r,o[t])}function it(e,n,t,o,i,r){let l=o[t];if(l?.nodeType===8&&l.nodeValue?.includes("type=hole")&&t<r)return;if(n&&typeof n=="object"&&!Array.isArray(n))if(typeof n.type=="function")M(n,i.registry);else try{b(n,i.registry)}catch(f){console.error("[weifuwu] ref cleanup error",f)}let u=n&&typeof n=="object"&&!Array.isArray(n)?g(n,l):null;Ge(u,l)}function Ge(e,n){if(e&&e.length>1)for(let t of e)t.parentNode&&t.parentNode.removeChild(t);else n?.parentNode&&n.parentNode.removeChild(n)}function lt(e){return e==null||typeof e=="boolean"?"hole":e&&typeof e=="object"&&!Array.isArray(e)&&S(e)?"portal":"real"}var dt={hole:st,portal:ut,real:at};function st(e,n){let{parent:t,oldChildren:o,oldNodes:i,ctx:r,out:l,pushA:d,c:u,i:f}=e,s=o[f]??null,a=i[f]??null,c=de(s);if(c==="hole"){let y=H(r.browser??V(),u);a?.nodeType===8?(y&&a.nodeValue!==y.nodeValue&&(a.nodeValue=y.nodeValue),l.push(a),d(a),a&&(n.current=a)):(y&&a?.parentNode?a.parentNode.replaceChild(y,a):y&&t.appendChild(y),l.push(y),d(y),y&&(n.current=y));return}let p=c==="multi"?qe(t,s,a,u,r):s&&typeof s=="object"&&!Array.isArray(s)&&typeof s.type=="function"?We(t,s,a,u,r):ze(t,s,a,u,r);l.push(p),d(p),p&&(n.current=p)}function ut(e,n){let{parent:t,oldChildren:o,oldNodes:i,ctx:r,out:l,pushA:d,c:u,i:f}=e,s=u,a=o[f]??null,c=W(t,i[f]??null,a,s,r),p=Se(s,c);l.push(...p),d(p[0]??c??null);let y=p[p.length-1]??c;y&&(n.current=y)}function at(e,n){let{parent:t,oldNodes:o,ctx:i,out:r,pushA:l,arrEnd:d,c:u,i:f}=e,a=E(u,i,i.browser??V());if(r.push(a),l(a??null),a!=null){let c=o[f];c&&c.nodeType===8&&c.nodeValue?.includes("type=hole")?(c.parentNode?.replaceChild(a,c),n.current=a):(n.current?t.insertBefore(a,n.current.nextSibling):d&&d.parentNode===t?t.insertBefore(a,d):t.insertBefore(a,t.firstChild),n.current=a)}}function fe(e){for(let n=0;n<e.length;n++){let t=e[n];t&&typeof t=="object"&&!Array.isArray(t)&&se(t)===null&&(t.key=`pos:${n}`)}}function Xe(e,n,t,o){te()?console.error(`[vdom2/audit] I1 \u8FDD\u53CD\uFF1Adiff \u6536\u5230 disposed \u7EC4\u4EF6 ${o}\u2014\u2014\u526A\u679D\u7F13\u5B58\u5931\u6548\uFF08portal \u5185\u5BB9\u72EC\u7ACB dispose\uFF09\u2014\u2014\u7236\u6811\u5C06\u91CD\u5EFA`):console.warn(`[vdom2] disposed \u7EC4\u4EF6 ${o} \u5728 diff\u2014\u2014\u526A\u679D\u7F13\u5B58\u5931\u6548\u2014\u2014\u7236\u6811\u91CD\u5EFA\u4E2D\uFF08\u5360\u4F4D\u515C\u5E95\uFF09`);let i=H(t.browser??V(),null);if(i==null)return null;let r=n;if(r){let l=r.parentNode;l?l.replaceChild(i,r):e.appendChild(i)}else e.appendChild(i);return i}var ct={unkeyed:nt,keyed:Ue,mixed:e=>(fe(e.newChildren),fe(e.oldChildren),Ue(e))};function Ye(e,n,t,o){let i=t,r=i.__registry??U(),l=i.browser??V();return Promise.resolve(B(n,i,null,r)).then(()=>{let d=E(n,i,l);if(d!=null&&e.appendChild(d),n._id&&r){let u=r.idRegistry.get(n._id);u&&(u._parentNode=e)}o?.onMounted?.()}).catch(d=>console.error("[vdom2] command mount error",d)),{id:n._id??""}}function jo(e,n,t){return new Promise(o=>{Ye(e,n,t,{onMounted:o})})}async function Do(e,n,t,o,i){return await B(o,i,t,i.__registry),W(e,n,t,o,{browser:i.browser??i.__browser,registry:i.__registry})}function Oo(e,n){let t=n.__registry??(n.__registry=U());return Promise.resolve(B(e,n,void 0,t))}async function Ho(e,n,t){let o=await e(n,t);return typeof o=="function"?o(n):o}async function Bo(e,n,t){let o=await e(n,t);return()=>typeof o=="function"?o(n):o}function pe(e,n){if(e==null||typeof e!="object")return;if(Array.isArray(e)){for(let o of e)pe(o,n);return}n(e);let t=e?.props?.children;t!=null&&pe(t,n)}function Fo(e,n){let t;return pe(e,o=>{!t&&n(o)&&(t=o)}),t}function Ko(e,n){let t=[];return pe(e,o=>{typeof o?.props?.class=="string"&&o.props.class.split(" ").includes(n)&&t.push(o)}),t}function Uo(e){let n={ui:{render:()=>{},ready:!0,useExternal:()=>{}}};return e?{ui:{...n.ui,...e.ui??{}},...e.browser?{browser:e.browser}:{}}:n}function qo(e=()=>!1,n){return{get open(){return e()},setOpen:n??(t=>{}),refresh:()=>{},portal:(t,o)=>e()?t:null,wrapProps:{}}}export{Oo as buildToDom,qo as createPopupMock,Uo as createTestCtx,Ko as findByClass,Fo as findVNode,Bo as mountComponent,jo as mountToDom,Do as patchToDom,Ho as renderVNode,pe as walkVNode};
1
+ var ne=Symbol("Fragment"),ue=Symbol("Portal");function ke(e){return e!=null&&typeof e=="object"&&typeof e.type=="string"}function K(e){return e!=null&&typeof e=="object"&&e.type===ne}function C(e){return e!=null&&typeof e=="object"&&typeof e.type=="function"}function S(e){return e!=null&&typeof e=="object"&&e.type===ue}function w(e){return e==null||typeof e=="boolean"?[]:Array.isArray(e)?e:[e]}var Ne={error:0,warn:1,info:2,debug:3,trace:4},Te=["mount","build","render","diff","lifecycle","route","audit"],I={enabled:!1,stages:new Set,level:"info",filter:null},he=!1;function Je(e){return e&&e in Ne?e:"info"}function Re(e){let n=new Set;if(!e)return n;for(let t of e.split(",")){let o=t.trim().split(":")[0];Te.includes(o)&&n.add(o)}return n}function Ze(){if(he)return I;he=!0;try{let e=globalThis,n=new URLSearchParams(typeof e.location?.search=="string"?e.location.search:""),t=n.get("vdom_trace"),o=n.get("vdom_debug"),i=e.__vdom_trace__,r=typeof e.localStorage?.getItem=="function"?e.localStorage.getItem("vdom_trace"):null;if(o==="1"||e?.localStorage?.getItem?.("__WF_VDOM_DEBUG")==="1")I={enabled:!0,stages:new Set(Te),level:"debug",filter:null};else if(t||i||r){let l=new Set;if(t)for(let d of Re(t))l.add(d);if(i?.stages){let d=Array.isArray(i.stages)?i.stages:[...i.stages];for(let u of d)l.add(u)}if(r)for(let d of Re(r))l.add(d);I={enabled:!0,stages:l,level:t?.includes(":")?Je(t.split(":")[1]):i?.level??"debug",filter:typeof i?.filter=="string"?i.filter:null}}}catch{}return I}function m(e,n="info"){return!I.enabled&&(he||Ze(),!I.enabled)||I.stages.size&&!I.stages.has(e)?!1:Ne[n]<=Ne[I.level]}function h(e,n,t,...o){if(!m(e,n)&&!Pe())return;let i=I.filter;i&&!t.includes(i)||_({session:"",machine:e,nodeId:null,component:null,from:"",event:"TRACE",to:"",payload:()=>o.length?`${t} ${o.join(" ")}`:t,level:n,ts:Date.now()})}function A(e,n=12){if(!e)return"\u2205";if(typeof e=="string"||typeof e=="number")return`"${e}"`;if(!Array.isArray(e))return z(e);let t=e.slice(0,n).map(z);return e.length>n&&t.push(`\u2026+${e.length-n}`),`[${t.join(" | ")}]`}function Qe(e){return typeof e=="function"?"function":e===ne?"fragment":typeof e=="string"?"string":"other"}var en={function:e=>e.name||"Comp",fragment:()=>"Frag",string:e=>String(e),other:e=>String(e)};function z(e){if(e==null||typeof e=="boolean")return String(e);if(typeof e=="string")return`"${e.slice(0,16)}"`;if(typeof e=="number")return String(e);if(Array.isArray(e))return`ARR(${e.length})`;let n=e,t=n.type,o=en[Qe(t)](t),i=n.props?.id?`#${n.props.id}`:n.key!=null?`@${n.key}`:"";return o+i}function k(e){if(!e)return"null";if(e.nodeType===1){let n=e;return`${n.tagName}${n.id?`#${n.id}`:""}${n.getAttribute?.("data-wf-key")?`@${n.getAttribute("data-wf-key")}`:""}`}return e.nodeType===3?`"${(e.textContent??"").slice(0,12)}"`:e.nodeType===8?`<!--${(e.nodeValue??"").slice(0,40)}-->`:`#${e.nodeType}`}function D(e,n=12){if(!e)return"null";let o=Array.from(e.childNodes).slice(0,n).map(k);return e.childNodes.length>n&&o.push(`\u2026+${e.childNodes.length-n}`),`[${o.join(" | ")}]`}var nn={route:"route",lifecycle:"lifecycle",x2y:"diff",keys:"diff",pos:"diff",render:"render",audit:"audit",build:"build",mount:"mount",diff:"diff"};function Ie(e){return nn[e]}var Y=new Set;function tn(e){return Y.add(e),()=>{Y.delete(e)}}var $e=[];function on(){return $e[$e.length-1]??""}function _(e){if(Y.size!==0){e.session||(e.session=on()),typeof e.payload=="function"&&(Y.size>1||m(Ie(e.machine),e.level??"debug"))&&(e.payload=e.payload());for(let n of Y)try{n(e)}catch{}}}function Pe(){return Y.size>1}function rn(e){if(e==null)return"";if(typeof e=="string")return` ${e}`;if(typeof e=="object"){let n=e,t=[];for(let o of["path","i","key","mode","kind","insertedBefore","after","depth"])if(n[o]!==void 0){let i=n[o];t.push(`${o}=${typeof i=="object"?JSON.stringify(i):String(i)}`)}return t.length?" "+t.join(" "):""}return` ${String(e)}`}function ln(e){let n=Ie(e.machine);if(!m(n,e.level??"debug"))return;if(e.event==="TRACE"){console.log(`[vdom:${e.machine}] ${e.payload}`);return}let t=e.component?`${e.component}${e.nodeId?`(${e.nodeId})`:""}`:e.nodeId?`(${e.nodeId})`:"";console.log(`[vdom:${e.machine}] ${t?t+" ":""}${e.from} --${e.event}--> ${e.to}${rn(e.payload)}`)}tn(ln);var dn={fresh:{BUILD_START:"building",BUILD_DONE:"built",PRUNE:"pruned",DISPOSE:"disposed"},building:{BUILD_DONE:"built",DISPOSE:"disposed"},built:{BUILD_START:"building",PRUNE:"pruned",DISPOSE:"disposed"},pruned:{BUILD_START:"building",PRUNE:"pruned",DISPOSE:"disposed"},disposed:{BUILD_START:"building"}};function T(e){let n=0,t=e._parentVNode??null;for(let o=0;o<10&&t;o++)n++,t=t._parentVNode??null;return{name:typeof e.type=="function"?e.type.name||"anonymous":String(e.type),id:e._id??null,depth:n}}var Le=new Map,sn=50;function un(e,n,t,o){if(!e?.id)return;let i=Le.get(e.id);i||(i={name:e.name??"?",events:[]},Le.set(e.id,i)),i.events.push(`${n}--${t}-->${o}`),i.events.length>sn&&i.events.shift()}function P(e,n,t){let o=dn[e]?.[n]??null;return o==null?(_({session:"",machine:"lifecycle",nodeId:t?.id??null,component:t?.name??null,from:e,event:n,to:"?",level:"warn",ts:Date.now()}),e):(un(t,e,n,o),_({session:"",machine:"lifecycle",nodeId:t?.id??null,component:t?.name??null,from:e,event:n,to:o,payload:()=>({depth:t?.depth??0}),level:"debug",ts:Date.now()}),o)}function J(e){return!e||e._lifecycle==="disposed"||e._child==null?!1:!ge(e._child)}function ge(e){if(e==null||typeof e!="object")return!1;if(Array.isArray(e)){for(let t of e)if(ge(t))return!0;return!1}let n=e;return!!(n._lifecycle==="disposed"||n._child!=null&&ge(n._child))}var an=0;function U(){return{idRegistry:new Map,unmountHooks:[],nextId:()=>`_wf_${an++}`}}function je(e,n){for(let t of[...e.unmountHooks])t(n);e.idRegistry.delete(n),e.idRegistry.delete(`custom:${n}`)}function cn(e,n,t,o){try{e(n)}catch(i){console.error(`[weifuwu] ref ${t} error in <${o??"anonymous"}>`,i)}}function b(e,n){if(e==null||typeof e!="object")return;let t=e;if(t._id){let o=T(t);if(t._customId&&n.idRegistry.delete(t._customId),n.idRegistry.delete(t._id),n.unmountHooks.length>0){let i=[...n.unmountHooks];for(let r of i)r(t._id);if(t._customId)for(let r of i)r(t._customId)}t._id=null,t._customId=null,C(t)&&(t._render=null),t._parentNode=null,t._refNode=null,t._lifecycle=P(t._lifecycle,"DISPOSE",o)}else(C(t)||t._child!=null)&&(t._lifecycle=P(t._lifecycle,"DISPOSE",T(t)));if(t._child!=null){if(Array.isArray(t._child))for(let o of t._child)o&&typeof o=="object"&&b(o,n);else b(t._child,n);t._child=null}if(t.props?.children&&typeof t.type=="string"){let o=Array.isArray(t.props.children)?t.props.children:[t.props.children];for(let i of o)i&&typeof i=="object"&&b(i,n)}if(typeof t.props?.ref=="function"&&cn(t.props.ref,null,"cleanup"),S(t)){let o=t._remoteEl;if(o){let i=t._child;if(i!=null)if(Array.isArray(i))for(let r of i)r&&typeof r=="object"&&b(r,n);else typeof i=="object"&&b(i,n);o.remove(),t._remoteEl=null}}}function v(e){return typeof e=="function"&&e.name||"anonymous"}function Me(e){return e.ui?._ctxVersion??0}function Ve(e,n){e.ui?.setMounting?.(n)}function g(e,n){if(e==null||typeof e!="object")return null;if(Array.isArray(e)||K(e)){let o=n;if(o&&o.nodeType===8&&o.nodeValue?.includes("type=fragment-start")){let i=[o],r=/fid=([^\s"]+)/.exec(o.nodeValue)?.[1]??"",l=o.nextSibling;for(;l&&(i.push(l),!(l.nodeType===8&&l.nodeValue?.includes("type=fragment-end")&&(/fid=([^\s"]+)/.exec(l.nodeValue)?.[1]??r)===r));)l=l.nextSibling;return i}return null}let t=e;return C(t)?g(t._outputChild??t._child,n):null}function L(e){if(e==null||typeof e=="boolean")return"hole";if(typeof e=="string"||typeof e=="number")return"text";if(Array.isArray(e))return"arr";let n=e;return K(n)?"frag":S(n)?"portal":C(n)?"comp":"native"}function Ce(e){let n=!1,t=!1;for(let o of e){if(o==null||typeof o=="boolean"||typeof o=="string"||typeof o=="number")continue;if(Array.isArray(o)){t=!0;continue}let i=o;S(i)||(i.key!=null?n=!0:t=!0)}return n&&t?"mixed":n?"keyed":"unkeyed"}function fn(e){if(e===!1)return"false";if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0)return"true";if(typeof e=="object")try{let n=JSON.stringify(e);return`object ${n!=null&&n.length>80?n.slice(0,80)+"\u2026":n??""}`}catch{return`object ${Object.prototype.toString.call(e)}`}return`bad-vnode type=${typeof e}`}function ae(e){return/[\s"=]/.test(e)?`"${e.replace(/"/g,"'")}"`:e}function Z(e){let n=[`type=${e.type}`];return e.value!==void 0&&n.push(`value=${ae(fn(e.value))}`),e.key!=null&&n.push(`key=${ae(e.key)}`),e.id!=null&&n.push(`id=${ae(e.id)}`),e.fid!=null&&n.push(`fid=${ae(e.fid)}`),`wf-hole: ${n.join(" ")}`}var pn=/^on[A-Z]/,yn=/^on[A-Z].*Capture$/;function we(e){let n=yn.test(e);return{type:(n?e.slice(2,-7):e.slice(2)).toLowerCase(),capture:n}}var mn=new Set(["draggable","contenteditable","spellcheck","translate"]),Nn=new Set(["zIndex","opacity","lineHeight","fontWeight","fontSizeAdjust","flex","flexGrow","flexShrink","order","zoom","aspectRatio","gridRow","gridColumn","scale","rotate","animationIterationCount","columnCount","fillOpacity","strokeOpacity","stopOpacity","floodOpacity"]);function _e(e){return mn.has(e.toLowerCase())?"enumerated":e==="class"||e==="className"?"class":e==="style"?"style":e==="ref"?"ref":pn.test(e)?"event":e==="value"?"value":e==="indeterminate"?"indeterminate":e==="innerHTML"?"innerHTML":e.startsWith("aria-")?"aria":"default"}function Oe(e,n,t){if(t!==!1){if(t===!0){e.setAttribute(n,"");return}try{e[n]=t,e.getAttribute(n)!==String(t)&&e.setAttribute(n,String(t))}catch{e.setAttribute(n,String(t))}}}var hn={enumerated:(e,n,t)=>{e.setAttribute(n,t?"true":"false")},class:(e,n,t)=>{if(t!==!1)if(typeof t=="object")for(let[o,i]of Object.entries(t))i&&e.classList.add(o);else e.setAttribute("class",String(t))},style:(e,n,t)=>{if(t!==!1)if(typeof t=="string")e.setAttribute("style",t);else{let o=e.style;for(let[i,r]of Object.entries(t))r==null?o[i]="":i.startsWith("--")?o.setProperty(i,String(r)):typeof r=="number"&&!Nn.has(i)?o[i]=`${r}px`:o[i]=String(r)}},ref:(e,n,t)=>{if(typeof t=="function")try{t(e)}catch(o){console.error("[weifuwu] ref error",o)}},event:(e,n,t)=>{if(t===!1)return;let{type:o,capture:i}=we(n);if(typeof t!="function"){console.warn(`[weifuwu] event prop ${n} expects a function, got ${typeof t} \u2014 ignored`);return}e.addEventListener(o,t,i?{capture:!0}:{})},value:(e,n,t)=>{t!==!1&&(e.value=t)},indeterminate:(e,n,t)=>{t!==!1&&(e.indeterminate=!!t)},innerHTML:(e,n,t)=>{t!==!1&&(e.innerHTML=String(t??""))},aria:(e,n,t)=>{if(t!==!1){if(typeof t=="boolean"){e.setAttribute(n,t?"true":"false");return}Oe(e,n,t)}},default:Oe};function q(e,n,t){t!=null&&hn[_e(n)](e,n,t)}function H(e,n){return e.createComment(Z({type:"hole",value:n,key:null,id:null,fid:null}))}function te(){return!!globalThis?.__WF_VDOM_AUDIT}function gn(e,n){if(e===n)return!0;let t=Object.keys(e),o=Object.keys(n);if(t.length!==o.length)return!1;for(let i of t)if(e[i]!==n[i])return!1;return!0}async function Vn(e,n,t,o){let i=e;i._id||(o?.reuse?._id?i._id=o.reuse._id:i._id=t.nextId(),t.idRegistry.set(i._id,i)),o?.reuse&&(o.reuse._parentNode&&(i._parentNode=o.reuse._parentNode),o.reuse._refNode&&(i._refNode=o.reuse._refNode),o.reuse._ctxVersion!=null&&(i._ctxVersion=o.reuse._ctxVersion));let r=Object.create(n);r.ui=Object.create(n.ui);let l=r.ui;if(l._selfId=i._id??null,l._selfVNode=i,l.render=function(d){let u=n.ui;return d==null&&i._id?u.render([i._id]):u.render(d)},typeof i._render!="function"&&C(o?.reuse)&&typeof o.reuse._render=="function"&&(i._render=o.reuse._render),typeof i._render!="function"){Ve(n,!0);let d;try{d=await i.type(i.props??{},r)}finally{Ve(n,!1)}if(typeof d!="function")throw new Error(`Component ${v(e.type)} must return a render function. Use (init_props, ctx) => (props) => VNode pattern.`);i._render=d}return{renderFn:i._render,childCtx:r}}function be(e){return!!e&&typeof e.then=="function"}function B(e,n,t,o,i){return Cn[L(e)](e,n,t,o,i)}function xe(e,n){return e!=null&&typeof e=="object"&&!Array.isArray(e)&&e.type===n.type?e:null}var Cn={hole:e=>e,text:e=>e,arr:wn,comp:_n,frag:bn,native:De,portal:De};function wn(e,n,t,o,i){let r=e;m("build")&&h("build","debug","",`array in kids=${A(r)}`);for(let s of r)if(s!=null&&typeof s=="object"&&!Array.isArray(s)&&s._lifecycle==="disposed"){let a=s;_({session:"",machine:"audit",nodeId:a._id??null,component:v(a.type),from:"disposed",event:"CONTRACT_VIOLATION",to:"new-tree",level:"error",ts:Date.now()}),te()&&console.error(`[vdom2/audit] \u4E24\u9636\u6BB5\u5951\u7EA6\u8FDD\u53CD\uFF1A\u7EC4\u4EF6 ${v(a.type)} \u7684 renderFn \u8FD4\u56DE\u4E86 disposed \u65E7 vnode${a._id?`(${a._id})`:""}\u2014\u2014\u590D\u7528\u65E7\u6811\u5BF9\u8C61\uFF08\u5E94\u4E3A\u6BCF\u6B21\u6E32\u67D3\u751F\u6210\u65B0 vnode\uFF09\u3002\u540C\u4E00\u5BF9\u8C61\u65E2\u662F\u65E7\u6811\u53C8\u88AB dispose \u2192 diff \u81EA dispose \u2192 \u5361\u7247\u9519\u4F4D/\u6D88\u5931\uFF08demo \u641C\u7D22\u6062\u590D\u4E8B\u6545\uFF09`);break}for(let s=0;s<r.length;s++){let a=r[s];if(a!=null&&typeof a=="object"&&!Array.isArray(a)){let c=a;c.key!==null&&(c.key=String(c.key))}}let l=Array.isArray(t)?t:[],d=new Map;for(let s of l)s!=null&&typeof s=="object"&&!Array.isArray(s)&&s.key!=null&&d.set(s.key,s);let u=r.map((s,a)=>{let c=null;return s!=null&&typeof s=="object"&&!Array.isArray(s)&&s.key!=null&&(c=d.get(s.key)??null),c==null&&(c=l[a]??null),B(s,n,c,o,i)});m("build")&&h("build","debug","",`array out kids=${A(r)}`);let f=!1;for(let s=0;s<u.length;s++)if(be(u[s])){f=!0;break}return f?Promise.all(u).then(()=>r):r}function _n(e,n,t,o,i){let r=e,l=o??n.__registry??U(),d=xe(t,r);r._id||(r._id=d?._id??l.nextId(),l.idRegistry.set(r._id,r)),d&&(d._parentNode&&(r._parentNode=d._parentNode),d._refNode&&(r._refNode=d._refNode),d._ctxVersion!=null&&(r._ctxVersion=d._ctxVersion),C(r)&&C(d)&&typeof d._render=="function"&&(r._render=d._render));let u=gn(d?.props??{},r.props??{}),f=Me(n),s=(d?._ctxVersion??-1)===f;if(!i?.force&&u&&s&&J(d)&&typeof r._render=="function"){let a=d;return r._lifecycle=P(r._lifecycle,"PRUNE",T(r)),r._child=a._child,r._ctxVersion=a._ctxVersion,m("build")&&h("build","debug","",`prune comp=${z(r)} propsSame=${u} verSame=${s}`),r}return r._lifecycle=P(r._lifecycle,"BUILD_START",T(r)),m("build")&&h("build","debug","",`mount comp=${z(r)} propsSame=${u} verSame=${s} force=${!!i?.force}`),(async()=>{let{childCtx:a}=await Vn(r,n,l,{reuse:d??null}),c=await B(await r._render(r.props),a,d?._child,l,i);return r._child=c??null,r._ctxVersion=f,r._lifecycle=P(r._lifecycle,"BUILD_DONE",T(r)),r})()}function bn(e,n,t,o,i){let r=e,l=o??n.__registry??U(),d=xe(t,r);m("build")&&h("build","debug","",`fragment kids=${A(w(r.props?.children))}`);let u=B(r.props?.children??null,n,d?._child??d?.props?.children,l,i);return be(u)?u.then(f=>(r._child=f??null,r._lifecycle=P(r._lifecycle,"BUILD_DONE",T(r)),r)):(r._child=u??null,r._lifecycle=P(r._lifecycle,"BUILD_DONE",T(r)),r)}function De(e,n,t,o,i){let r=e;if(typeof r.type!="string"&&typeof r.type!="symbol")return r;let l=o??n.__registry??U(),d=xe(t,r);m("build")&&h("build","trace","",`native <${String(r.type)}> kids=${A(w(r.props?.children))}`);let u=B(r.props?.children??null,n,d?.props?.children,l,i);return be(u)?u.then(f=>(r._child=f??null,r._lifecycle=P(r._lifecycle,"BUILD_DONE",T(r)),r)):(r._child=u??null,r._lifecycle=P(r._lifecycle,"BUILD_DONE",T(r)),r)}function V(){return{activeElement:()=>typeof document<"u"?document.activeElement:null,byId:e=>typeof document<"u"?document.getElementById(e):null,query:e=>typeof document<"u"?document.querySelector(e):null,queryAll:e=>typeof document<"u"?document.querySelectorAll(e):null,createElement:e=>typeof document<"u"?document.createElement(e):null,createElementNS:(e,n)=>typeof document<"u"?document.createElementNS(e,n):null,createDocumentFragment:()=>typeof document<"u"?document.createDocumentFragment():null,createComment:e=>typeof document<"u"?document.createComment(e):null,createTextNode:e=>typeof document<"u"?document.createTextNode(e):null,addEventListener:(e,n,t)=>{typeof window<"u"&&window.addEventListener(e,n,t)},removeEventListener:(e,n,t)=>{typeof window<"u"&&window.removeEventListener(e,n,t)},scrollTo:e=>{typeof window<"u"&&window.scrollTo(0,e)},matchMedia:e=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia(e):null,visualViewport:()=>(typeof window<"u"?window:null)?.visualViewport??null,scrollingElement:()=>typeof document<"u"?document.scrollingElement:null,bodyElement:()=>typeof document<"u"?document.body:null,bodyAppend:e=>{typeof document<"u"&&document.body.appendChild(e)},bodyRemove:e=>{typeof document<"u"&&e.parentNode&&document.body.removeChild(e)},clearBody:()=>{typeof document<"u"&&(document.body.innerHTML="")},event:(e,n)=>{let t=typeof window<"u"?window:null,o=n&&(n.key||n.code)?"KeyboardEvent":n&&(n.clientX!==void 0||n.clientY!==void 0||n.pointerId!==void 0)?"PointerEvent":"Event";try{return new t[o](e,n)}catch{return new t.Event(e,n)}},dispatchEvent:(e,n)=>typeof e<"u"?e.dispatchEvent(n):!1,reload:()=>{typeof window<"u"&&window.location.reload()},navigate:e=>{typeof window>"u"||(window.history.pushState(null,"",e),window.dispatchEvent(new PopStateEvent("popstate",{state:null})))},downloadFile:(e,n,t="text/plain")=>{try{if(typeof document>"u"||typeof URL>"u"||!URL.createObjectURL)return!1;let o=new Blob([n],{type:t}),i=URL.createObjectURL(o),r=document.createElement("a");return r.href=i,r.download=e,document.body.appendChild(r),r.click(),document.body.removeChild(r),setTimeout(()=>URL.revokeObjectURL(i),1e3),!0}catch{return!1}},copyText:async e=>{let n=typeof window<"u"?window:null;if(n?.navigator?.clipboard?.writeText)try{return await n.navigator.clipboard.writeText(e),!0}catch{}try{if(typeof document>"u")return!1;let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();let o=document.execCommand("copy");return document.body.removeChild(t),o}catch{return!1}},execCommand:(e,n)=>typeof document<"u"?document.execCommand(e,!1,n):!1,queryCommandState:e=>typeof document<"u"?document.queryCommandState(e):!1,queryCommandValue:e=>typeof document<"u"?document.queryCommandValue(e):"",selectionText:()=>typeof window<"u"?window.getSelection?.()?.toString()??null:null,getSelection:()=>typeof window<"u"?window.getSelection():null,viewportHeight:()=>typeof window<"u"?window.innerHeight:0,viewportWidth:()=>typeof window<"u"?window.innerWidth:0,pathname:()=>typeof window<"u"?window.location.pathname:"",createTreeWalker:(e,n)=>typeof document<"u"?document.createTreeWalker(e,n??NodeFilter.SHOW_ALL):null,scrollTop:()=>{let e=typeof document<"u"?document:null,n=typeof window<"u"?window:null;return e?.scrollingElement?.scrollTop??n?.scrollY??0},hash:()=>typeof window<"u"?window.location?.hash??"":"",setHash:e=>{typeof window<"u"&&(window.location.hash=e)},timeout:(e,n)=>typeof window<"u"?window.setTimeout(e,n):0,rootElement:()=>typeof document<"u"?document.documentElement:null,storageGet:e=>{try{return typeof window<"u"?window.localStorage?.getItem(e)??null:null}catch{return null}},storageSet:(e,n)=>{try{typeof window<"u"&&window.localStorage?.setItem(e,n)}catch{}}}}var xn=new Set(["svg","path","circle","rect","line","polyline","polygon","g","text","defs","use","clipPath"]);function Q(e,n){return H(e,n)}function E(e,n,t,o=null,i=null,r=null){let l=n?.browser??t;if(!l)throw new Error("[vdom2] renderValue requires browser env (ctx.browser)");return $n[L(e)](e,n,l,o,i,r)}function vn(e,n,t){return null}function En(e,n,t){return t.createTextNode(String(e))}function ve(e,n,t,o,i){if(e==null||typeof e=="boolean")return Q(t,e);let r=E(e,n,t,String(o),null,i);return r??Q(t,null)}function Sn(e,n,t,o=null,i=null,r=null){let l=e,d=t.createDocumentFragment();if(!d)return null;m("render")&&h("render","debug","",`array kids=${A(l)} fid=${r??"-"} key=${o??"-"}`);let u=t.createComment(Z({type:"fragment-start",key:o,id:i,fid:r})),f=t.createComment(Z({type:"fragment-end",key:o,id:i,fid:r}));u&&d.appendChild(u);for(let s=0;s<l.length;s++){let a=l[s],c=r!=null?`${r}-${s}`:String(s),p=ve(a,n,t,s,c);p!=null&&d.appendChild(p)}return f&&d.appendChild(f),d}function An(e,n,t){let o=e,i=o,r=t.bodyElement();if(!r)return null;let l=r.querySelector("#__wf_portal");l||(l=t.createElement("div"),l&&(l.id="__wf_portal",r.appendChild(l)));let d=t.createElement("div");if(d){d.setAttribute("data-portal",String(o.props?.portalKey??"wf"));let u=E(o.props?.children??null,n,t);u!=null&&d.appendChild(u),l&&l.appendChild(d),i._remoteEl=d;let f=w(o.props?.children);for(let s of f)s!=null&&typeof s=="object"&&!Array.isArray(s)&&(s._parentVNode=o)}return null}function kn(e,n,t,o=null,i=null,r=null){let l=e,d=l,u=t.createDocumentFragment();if(!u)return null;let f=w(l.props?.children);m("render")&&h("render","debug","",`fragment kids=${A(f)} fid=${r??"-"}`);let s=t.createComment(Z({type:"fragment-start",key:o,id:i,fid:r})),a=t.createComment(Z({type:"fragment-end",key:o,id:i,fid:r}));s&&u.appendChild(s),d._refNode=s;for(let c=0;c<f.length;c++){let p=f[c],y=r!=null?`${r}-${c}`:String(c),N=ve(p,n,t,c,y);N!=null&&u.appendChild(N)}return a&&u.appendChild(a),u}function Rn(e,n,t){let o=e,i=o._lifecycle??(typeof o._render=="function"?"built":"fresh");return Tn[i](o,n,t)}var Tn={fresh:(e,n,t)=>{throw new Error(`[vdom2] component ${v(e.type)} not built (missing _render) \u2014 buildVNode must run before renderValue`)},building:(e,n,t)=>{throw new Error(`[vdom2] component ${v(e.type)} building in render \u2014 buildVNode must await before renderValue`)},disposed:(e,n,t)=>(console.warn(`[vdom2] disposed \u7EC4\u4EF6 ${v(e.type)} \u5728\u6E32\u67D3\u2014\u2014\u526A\u679D\u7F13\u5B58\u5931\u6548\u2014\u2014\u7236\u6811\u91CD\u5EFA\u4E2D\uFF08\u5360\u4F4D\u515C\u5E95\uFF09`),Q(t,null)),built:He,pruned:He};function He(e,n,t){let o=e._child;if(o==null)return e._child=null,null;e._child=o,e._outputChild=o,typeof o=="object"&&!Array.isArray(o)&&(o._parentVNode=e);let i=E(o,n,t);if(i){if(e._refNode=i.nodeType===11?i.firstChild:i,e._id)if(i.nodeType===11)for(let r of Array.from(i.childNodes))r.nodeType===1&&r.setAttribute("data-wf-id",e._id);else i.nodeType===1&&i.setAttribute("data-wf-id",e._id);if(e.key!=null)if(i.nodeType===11)for(let r of Array.from(i.childNodes))r.nodeType===1&&r.setAttribute("data-wf-key",e.key);else i.nodeType===1&&i.setAttribute("data-wf-key",e.key)}return i}function Pn(e,n,t,o,i){let r=e,l=r,d=r.type,u=xn.has(d)?t.createElementNS("http://www.w3.org/2000/svg",d):t.createElement(d);if(!u)return null;l.el=u,l._refNode=u,m("render")&&h("render","trace","",`native <${d}> key=${r.key??"-"} kids=${A(w(r.props?.children))}`),r.key!=null&&u.setAttribute("data-wf-key",r.key);let f=null;for(let[s,a]of Object.entries(r.props??{}))if(!(s==="children"||s==="key")){if(s==="value"&&u instanceof HTMLSelectElement){f=a;continue}q(u,s,a)}if(!("innerHTML"in(r.props??{}))){let s=w(r.props?.children);for(let a=0;a<s.length;a++){let c=s[a],p=i!=null?`${i}-${a}`:String(a),y=ve(c,n,t,a,p);if(y!=null&&(u.appendChild(y),c&&typeof c=="object"&&!Array.isArray(c)&&typeof c.type=="function")){let N=c;N._parentNode||(N._parentNode=u)}}m("render")&&h("render","trace","",`native <${d}> out=${D(u)}`)}return f!==null&&(u.value=String(f)),u}var $n={hole:vn,text:En,arr:Sn,portal:An,frag:kn,comp:Rn,native:Pn};function F(e){let{parent:n,oldNode:t,oldInput:o,ctx:i}=e,r=E(e.newInput,i,i.browser??V());if(r==null)return null;if(t?.parentNode){let l=oe(o,t,n,i);return l&&l.parentNode===n?n.insertBefore(r,l):n.appendChild(r),r}return n.appendChild(r),r}function In(e){return oe(e.oldInput,e.oldNode,e.parent,e.ctx),null}function Ln(e){let n=e.oldNode;if(n?.nodeType===8){let t=Q(e.ctx.browser??V(),e.newInput);return t&&n.nodeValue!==t.nodeValue&&(n.nodeValue=t.nodeValue),n}return null}function ee(e){let{parent:n,oldNode:t,ctx:o}=e,i=E(e.newInput,o,o.browser??V());return i==null?null:(t?.parentNode?t.parentNode.replaceChild(i,t):t?n.insertBefore(i,t):n.appendChild(i),i)}function jn(e){let{parent:n,oldNode:t,oldInput:o}=e,i=String(e.newInput);if(String(o)!==i){if(t&&t.nodeType===3)return t.nodeValue=i,t;let r=n.ownerDocument.createTextNode(i);return t?.parentNode?t.parentNode.replaceChild(r,t):n.appendChild(r),r}return t}function Mn(e){let{parent:n,oldNode:t,oldInput:o,ctx:i}=e,r=e.newInput,l=o&&typeof o=="object"&&!Array.isArray(o)?o:null,d=r.type;if(t&&t.nodeType===1&&(l?.type??null)===d&&ke(r)){let u=t;return r.el=u,r._refNode=u,Fe(u,l?.props??{},r.props??{}),"innerHTML"in(r.props??{})||re(u,l?._child??l?.props?.children??null,r._child??r.props?.children??null,i),u}return F(e)}function On(e){let{parent:n,oldNode:t,oldInput:o,ctx:i}=e,r=e.newInput,l=o&&typeof o=="object"&&!Array.isArray(o)?o:null,d=K(l)?g(l,t):null,u=Ee(n,l??o,r,i,d);return t?.parentNode?t:u[0]??null}function Dn(e){let{parent:n,oldNode:t,oldInput:o,ctx:i}=e,r=e.newInput;if(!C(r)||typeof r._render!="function")throw new Error(`[vdom2] component ${v(r.type)} not built in diff \u2014 buildVNode must run before patchValue`);let l=o&&typeof o=="object"&&!Array.isArray(o)?o:null;if(l?.type!=null&&l.type!==r.type)return F(e);let d=l?.type===r.type;if(!i.force&&l&&d&&J(l)&&r._child===l._child)return t;l?.type===r.type&&l._id&&(r._id=l._id,i.registry.idRegistry.set(r._id,r)),r._parentNode=n,t&&(r._refNode=t);let u=r._child;if(u===null){r._outputChild=null,r._refNode=null;let s=t?.parentNode!=null,a=oe(l?._child??null,t,n,i);l&&(l._child=null);let c=Q(i.browser??V(),null);return s&&c?(a&&a.parentNode===n?n.insertBefore(c,a):n.appendChild(c),c):W(n,t,l?._child,null,i)}r._outputChild=u;let f=W(n,t,l?._child,u,i);return f&&(r._refNode=f),f}function Hn(e){let{parent:n,oldNode:t,oldInput:o,ctx:i}=e;if(o===e.newInput&&t?.parentNode)return t;let r=n.ownerDocument.createDocumentFragment(),l=re(n,o,e.newInput,i,t?[t]:null);for(let d of l)d&&r.appendChild(d);return t?.parentNode?r.contains(t)?n.appendChild(r):t.parentNode.replaceChild(r,t):n.appendChild(r),r}function Bn(e){let{ctx:n,oldInput:t}=e,o=e.newInput,i=t&&typeof t=="object"&&!Array.isArray(t)?t:null;if(S(i)&&S(o)){let r=i._remoteEl;if(r){let l=i._child??i.props?.children??null,d=o._child??o.props?.children??null;re(r,l,d,n)}return o._remoteEl=i._remoteEl,null}return F(e)}function G(e){return{text:F,native:F,frag:F,comp:F,arr:F,hole:In,portal:F,...e}}var Fn={text:G({text:jn}),hole:G({text:ee,native:ee,frag:ee,comp:ee,arr:ee,portal:ee,hole:Ln}),native:G({native:Mn}),frag:G({frag:On}),comp:G({comp:Dn}),arr:G({arr:Hn}),portal:G({portal:Bn})};function Be(e){let n=L(e.oldInput),t=L(e.newInput);return _({session:"",machine:"x2y",nodeId:null,component:null,from:n,event:"X2Y",to:t,level:"trace",ts:Date.now()}),Fn[n][t](e)}function j(e,n){if(n&&typeof e.type=="function"&&e._id){try{b(e,n)}catch(t){console.error("[weifuwu] ref cleanup error",t)}je(n,e._id)}}function se(e){if(e==null||typeof e!="object"||Array.isArray(e))return null;let n=e;return S(n)?typeof n.props?.portalKey=="string"?n.props.portalKey:null:n.key}function Se(e,n){if(n&&e&&typeof e=="object"&&!Array.isArray(e)){let t=g(e,n);if(t&&t.length>1)return t}return[n]}function ce(e,n){let t=w(e.props?.children);for(let o of t){if(o==null||typeof o!="object"||Array.isArray(o))continue;let i=o;Kn[L(i)](i,n)}}var Kn={comp:(e,n)=>{j(e,n)},frag:(e,n)=>{ce(e,n)},native:(e,n)=>{ce(e,n)},portal:(e,n)=>{ce(e,n)},arr:()=>{},text:()=>{},hole:()=>{}};function oe(e,n,t,o){return Un[L(e)](e,n,t,o)}var Un={arr:(e,n,t,o)=>{let i=g(e,n);if(i&&i.length){let r=(i[i.length-1]??n)?.nextSibling??null;for(let l of i)l.parentNode&&l.parentNode.removeChild(l);return r&&r.parentNode===t?r:null}return ie(e,n,t,o)},frag:(e,n,t,o)=>{let i=e,l=g(i,n)??[],d=(l[l.length-1]??n)?.nextSibling??null;for(let u of l)u.parentNode&&u.parentNode.removeChild(u);return ce(i,o.registry),d&&d.parentNode===t?d:null},portal:(e,n,t,o)=>{let i=e,r=i._remoteEl;try{b(i.props?.children,o.registry)}catch(l){console.error("[weifuwu] portal ref cleanup error",l)}return r?.parentNode?.removeChild(r),null},comp:(e,n,t,o)=>{let i=e,r=g(i,n);if(j(i,o.registry),r&&r.length>1){let l=(r[r.length-1]??n)?.nextSibling??null;for(let d of r)d.parentNode&&d.parentNode.removeChild(d);return l&&l.parentNode===t?l:null}return ie(e,n,t,o)},native:(e,n,t,o)=>{try{b(e,o.registry)}catch(i){console.error("[weifuwu] ref cleanup error",i)}return ie(e,n,t,o)},text:(e,n,t,o)=>ie(e,n,t,o),hole:(e,n,t,o)=>ie(e,n,t,o)};function ie(e,n,t,o){let i=n?.nextSibling??null;return n?.parentNode&&n.parentNode.removeChild(n),i&&i.parentNode===t?i:null}function W(e,n,t,o,i){return Be({parent:e,oldNode:n,oldInput:t,newInput:o,ctx:i})}var qn={event:(e,n,t,o)=>{let{type:i,capture:r}=we(n);typeof t=="function"&&e.removeEventListener(i,t,r?{capture:!0}:{}),o!=null&&o!==!1&&(typeof o!="function"?console.warn(`[weifuwu] event prop ${n} expects a function, got ${typeof o} \u2014 ignored`):e.addEventListener(i,o,r?{capture:!0}:{}))},class:(e,n,t,o)=>{o==null||o===!1?e.removeAttribute("class"):(e.className="",q(e,n,o))},ref:(e,n,t,o)=>{if(o==null||o===!1){if(typeof t=="function")try{t(null)}catch(i){console.error("[weifuwu] ref cleanup error",i)}}else q(e,n,o)},value:(e,n,t,o)=>{o==null||o===!1?e.value="":q(e,n,o)},indeterminate:(e,n,t,o)=>{o==null||o===!1?e.indeterminate=!1:q(e,n,o)},enumerated:le,style:le,innerHTML:le,aria:le,default:le};function le(e,n,t,o){if(o==null||o===!1){e.removeAttribute(n);try{delete e[n]}catch{}}else q(e,n,o)}function Fe(e,n,t){let o=Object.keys(n),i=Object.keys(t);if(o.length===i.length){let l=!0;for(let d=0;d<o.length;d++)if(o[d]!==i[d]||n[o[d]]!==t[o[d]]){l=!1;break}if(l)return}let r=new Set([...o,...i]);for(let l of r){if(l==="children"||l==="key")continue;let d=n[l],u=t[l];d!==u&&qn[_e(l)](e,l,d,u)}}function Ee(e,n,t,o,i){let r=Array.isArray(n)?n:n?._child??n?.props?.children??null,l=Array.isArray(t)?t:t?._child??t?.props?.children??null;return re(e,r,l,o,i)}function re(e,n,t,o,i,r){let l=w(n),d=w(t),u=i??Array.from(e.childNodes);m("diff")&&h("diff","debug","",`patchChildren parent=${k(e)} old=${A(l)} new=${A(d)} dom=${D(e)}`);let f=d.some(p=>Array.isArray(p))||l.some(p=>Array.isArray(p)),s=f?"unkeyed":Ce(d);if(_({session:"",machine:"keys",nodeId:null,component:null,from:f?"unkeyed":Ce(d),event:"SELECT",to:s,payload:()=>({len:d.length}),level:"trace",ts:Date.now()}),te()&&l.length!==d.length)for(let p=0;p<d.length;p++){let y=d[p];y!=null&&typeof y=="object"&&!Array.isArray(y)&&C(y)&&y.key==null&&console.error(`[vdom2/audit] \u52A8\u6001\u6570\u7EC4\u4F4D\u7F6E ${p} \u7684\u7EC4\u4EF6\u7F3A\u5C11 key\u2014\u2014\u5217\u8868\u589E\u5220/\u91CD\u6392\u4F1A\u9519\u4F4D\u7EC4\u4EF6\u5B9E\u4F8B\u72B6\u6001\u3002\u8BF7\u63D0\u4F9B\u4E1A\u52A1\u8EAB\u4EFD key\uFF08\u5982 key={item.id}\uFF09\uFF1B\u65E0\u72B6\u6001 native \u9879\u8C41\u514D\u3002`)}let a=i&&i.length?i[i.length-1]:null;s==="mixed"&&(fe(d),fe(l));let c=(()=>{let p=u;p.length>=2&&p[0]?.nodeType===8&&p[0].nodeValue?.includes("fragment-start")&&p[p.length-1]?.nodeType===8&&p[p.length-1].nodeValue?.includes("fragment-end")&&(p=p.slice(1,-1));let y=[],N=0;for(let R=0;R<l.length;R++){let x=l[R];if(Array.isArray(x)){let M=p[N]??null;y.push(M);let O=g(x,M);N+=O?.length??1;continue}if(x==null||typeof x=="boolean"||typeof x=="string"||typeof x=="number"){y.push(p[N]??null),N++;continue}let $=x;if(S($)){y.push($._remoteEl??null);continue}if(y.push($._refNode??p[N]??null),typeof $.type=="function"||K($)){let M=g($,$._refNode??p[N]??null);N+=M?.length??1}else N++}return y})();return ct[s]({parent:e,oldChildren:l,newChildren:d,oldNodes:c,ctx:o,arrEnd:a,anchorOut:r})}function de(e){return e==null||typeof e=="boolean"?"hole":Array.isArray(e)||e&&typeof e=="object"&&K(e)?"multi":"real"}function Wn(e){let{parent:n,oldC:t,oldNode:o,oldNodes:i,i:r,ctx:l,out:d,pushA:u}=e;if(Array.isArray(t)){m("diff")&&h("diff","trace","",`remove-arr-item i=${r} range=[${(g(t,i[r])??[]).map(k).join(" | ")}] before=${D(n)}`);let f=g(t,o);for(let s of f??[])s.parentNode?.removeChild(s);m("diff")&&h("diff","trace","",`remove-arr-item after=${D(n)}`);for(let s of t)s!=null&&typeof s=="object"&&!Array.isArray(s)&&typeof s.type=="function"&&j(s,l.registry)}else if(t&&typeof t=="object"&&!Array.isArray(t)){if(typeof t.type=="function")j(t,l.registry);else try{b(t,l.registry)}catch(f){console.error("[weifuwu] ref cleanup error",f)}o?.parentNode&&o.parentNode.removeChild(o)}else o?.parentNode&&o.parentNode.removeChild(o);d.push(null),u(null)}function zn(e){let{parent:n,newC:t,oldNode:o,i,oldNodes:r,out:l,pushA:d,ctx:u}=e,f=H(u.browser??V(),t);if(o?.nodeType===8){f&&o.nodeValue!==f.nodeValue&&(o.nodeValue=f.nodeValue),l.push(o),d(o);return}if(f&&o?.parentNode)o.parentNode.replaceChild(f,o);else if(f){let s=null;for(let a=i+1;a<r.length;a++){let c=r[a];if(c&&c.parentNode===n){s=c;break}}if(!s){let a=null;for(let c=l.length-1;c>=0;c--)if(l[c]){a=l[c];break}a&&a.parentNode===n&&(s=a.nextSibling)}s&&s.parentNode===n?n.insertBefore(f,s):n.appendChild(f),l.push(f),d(f)}else l.push(f),d(f)}function Ke(e){let{parent:n,newC:t,oldNode:o,i,oldNodes:r,out:l,pushA:d,ctx:u}=e,f=E(t,u,u.browser??V(),String(i));if(f==null){l.push(null),d(null);return}if(o&&o.nodeType===8&&o.nodeValue?.includes("type=hole")){_({session:"",machine:"pos",nodeId:null,component:null,from:"hole",event:"HOLE_FILL",to:"real",payload:()=>({i,replaced:k(o)}),level:"trace",ts:Date.now()}),o.parentNode?.replaceChild(f,o),l.push(f),d(f);return}let s=null;for(let a=i+1;a<r.length;a++){let c=r[a];if(c&&c.parentNode===n){s=c;break}}if(s==null){let a=null;for(let c=l.length-1;c>=0;c--)if(l[c]){a=l[c];break}if(a&&a.parentNode===n)s=a.nextSibling;else{let c=r[r.length-1];c&&c.parentNode===n&&(s=c.nextSibling)}}s&&s.parentNode===n?n.insertBefore(f,s):n.appendChild(f),_({session:"",machine:"pos",nodeId:null,component:null,from:"hole",event:"INSERT",to:"real",payload:()=>({i,insertedBefore:s?k(s):"END",node:k(f)}),level:"trace",ts:Date.now()}),l.push(f),d(f)}function Gn(e){let{parent:n,oldC:t,newC:o,oldNode:i,out:r,pushA:l,ctx:d}=e;if(t&&typeof t=="object"&&!Array.isArray(t)&&typeof t.type=="function"){let f=We(n,t,i,o,d);r.push(f),l(f);return}let u=ze(n,t,i,o,d);r.push(u),l(u)}function Xn(e){let{parent:n,oldC:t,newC:o,oldNode:i,i:r,out:l,pushA:d,ctx:u}=e,f=u.browser??V(),s=E(o,u,f,String(r));if(s==null){l.push(null),d(null);return}let a=t&&typeof t=="object"?g(t,i):null;if(a&&a.length>1){let p=(a[a.length-1]??i)?.nextSibling??null;for(let y of a)y.parentNode&&y.parentNode.removeChild(y);if(t&&typeof t=="object"&&!Array.isArray(t))if(typeof t.type=="function")j(t,u.registry);else try{b(t,u.registry)}catch(y){console.error("[weifuwu] ref cleanup error",y)}p&&p.parentNode===n?n.insertBefore(s,p):n.appendChild(s)}else i?.parentNode?i.parentNode.replaceChild(s,i):n.appendChild(s);let c=s.nodeType===11?Array.from(s.childNodes):[s];l.push(...c),d(c[0]??s)}function Yn(e){let{parent:n,oldC:t,newC:o,oldNode:i,out:r,pushA:l,ctx:d}=e,u=qe(n,t,i,o,d);r.push(u),l(u)}function Jn(e){let{parent:n,oldC:t,newC:o,oldNode:i,i:r,oldNodes:l,out:d,pushA:u,ctx:f}=e,s=f.browser??V(),a=g(t,i);m("diff")&&h("diff","debug","",`multi-remove i=${r} range=${a?a.map(k).join(" | "):"null"}`);for(let y of a??[])y.parentNode?.removeChild(y);for(let y of w(t?.props?.children))y!=null&&typeof y=="object"&&!Array.isArray(y)&&typeof y.type=="function"&&j(y,f.registry);let c=E(o,f,s,String(r));if(c==null){d.push(null),u(null);return}let p=l[r+1]??null;p?.parentNode?p.parentNode.insertBefore(c,p):n.appendChild(c),d.push(c),u(c)}function Zn(e){let{parent:n,oldC:t,newC:o,oldNode:i,oldNodes:r,i:l,out:d,pushA:u,ctx:f}=e,s=g(t,i),a=Ee(n,t,o,f,s);d.push(...a),u(r[l]??a[0]??null)}function Qn(e){let{parent:n,oldC:t,newC:o,oldNode:i,i:r,out:l,pushA:d,ctx:u}=e;if(o&&typeof o=="object"&&!Array.isArray(o)&&typeof o.type=="function"&&o._lifecycle==="disposed"){let a=Xe(n,i,u,v(o.type));l.push(a),d(a);return}let f=W(n,i,t,o,u);m("diff")&&h("diff","trace","",`after-patch i=${r} new=${z(o)} node=${k(f)} dom=${D(n)}`);let s=Se(o,f);l.push(...s),d(s[0]??f??null)}function qe(e,n,t,o,i){let r=H(i.browser??V(),o),l=g(n,t),d=((l??[])[l?.length?l.length-1:0]??t)?.nextSibling??null;for(let u of l??[])u.parentNode?.removeChild(u);for(let u of w(n?.props?.children))u!=null&&typeof u=="object"&&!Array.isArray(u)&&typeof u.type=="function"&&j(u,i.registry);return r&&d&&d.parentNode===e?e.insertBefore(r,d):r&&e.appendChild(r),r}function We(e,n,t,o,i){let r=H(i.browser??V(),o),l=oe(n,t,e,i);return r&&l?e.insertBefore(r,l):r&&e.appendChild(r),r}function ze(e,n,t,o,i){let r=H(i.browser??V(),o);if(n&&typeof n=="object"&&!Array.isArray(n))if(typeof n.type=="function")j(n,i.registry);else try{b(n,i.registry)}catch(l){console.error("[weifuwu] ref cleanup error",l)}return r&&t?.parentNode?t.parentNode.replaceChild(r,t):r&&e.appendChild(r),r}var et={hole:{hole:zn,real:Ke,multi:Ke},real:{hole:Gn,real:Qn,multi:Xn},multi:{hole:Yn,real:Jn,multi:Zn}};function nt(e){let{parent:n,oldChildren:t,newChildren:o,oldNodes:i,ctx:r,anchorOut:l}=e,d=Math.max(t.length,o.length),u=[],f=s=>{l&&l.push(s)};for(let s=0;s<d;s++){let a=s<t.length?t[s]:null,c=s<o.length?o[s]:null;if(s>=o.length){Wn({parent:n,oldC:a,newC:c,oldNode:i[s],i:s,oldNodes:i,newChildren:o,out:u,pushA:f,ctx:r});continue}if(a!=null&&typeof a=="object"&&!Array.isArray(a)&&c!=null&&typeof c=="object"&&!Array.isArray(c)&&c===a&&J(a)){u.push(i[s]),f(i[s]);continue}let p=et[de(a)][de(c)];_({session:"",machine:"pos",nodeId:null,component:null,from:de(a),event:p.name,to:de(c),payload:()=>({i:s}),level:"trace",ts:Date.now()}),p({parent:n,oldC:a,newC:c,oldNode:i[s],i:s,oldNodes:i,newChildren:o,out:u,pushA:f,ctx:r})}return u}function Ue(e){let{parent:n,oldChildren:t,newChildren:o,oldNodes:i,ctx:r,anchorOut:l,arrEnd:d}=e,u=new Map;t.forEach((p,y)=>{let N=se(p);N!==null&&p&&typeof p=="object"&&!Array.isArray(p)&&u.set(N,{vnode:p,nodes:[i[y]??null].filter(Boolean),index:y})});let f=[],s=new Set,a=p=>{l&&l.push(p)},c=null;return o.forEach((p,y)=>{let N=se(p),R=p;if(N!==null&&u.has(N)){let x=u.get(N),$=x.nodes[0]??null;if(s.add(N),R&&typeof R=="object"&&typeof R.type=="function"&&R._lifecycle==="disposed"){let X=Xe(n,$,r,v(R.type));f.push(X),a(X),X&&(c=X);return}let M=W(n,$,x.vnode,R,r),O=Se(R,M),ye=O[0]??M,Ae=O[O.length-1]??M;if(ye&&ye.parentNode===n&&c&&ye.previousSibling!==c){m("diff")&&h("diff","debug","",`keyed-correct i=${y} k=${N} move=[${O.map(k).join(" | ")}] after=${k(c)} before=${D(n)}`);let X=c.nextSibling;for(let me of O)me&&me.parentNode===n&&n.insertBefore(me,X);m("diff")&&h("diff","debug","",`keyed-correct after=${D(n)}`)}f.push(...O),a(O[0]??M??null),Ae&&(c=Ae)}else{let x={current:c};dt[lt(p)]({parent:n,oldChildren:t,newChildren:o,oldNodes:i,ctx:r,out:f,pushA:a,arrEnd:d,c:p,i:y},x),c=x.current}}),t.forEach((p,y)=>{ot[tt(se(p),s)](n,p,y,i,r,o.length)}),f}function tt(e,n){return e===null?"unkeyed":n.has(e)?"moved":"stale-keyed"}var ot={moved:()=>{},"stale-keyed":rt,unkeyed:it};function rt(e,n,t,o,i){let r=n&&typeof n=="object"&&!Array.isArray(n)?g(n,o[t]):null;if(m("diff")&&h("diff","trace","",`keyed-delete i=${t} k=${se(n)} range=${r?.length??0} oldNode=${k(o[t])}`),n&&typeof n=="object"&&!Array.isArray(n))if(typeof n.type=="function")j(n,i.registry);else try{b(n,i.registry)}catch(l){console.error("[weifuwu] ref cleanup error",l)}Ge(r,o[t])}function it(e,n,t,o,i,r){let l=o[t];if(l?.nodeType===8&&l.nodeValue?.includes("type=hole")&&t<r)return;if(n&&typeof n=="object"&&!Array.isArray(n))if(typeof n.type=="function")j(n,i.registry);else try{b(n,i.registry)}catch(f){console.error("[weifuwu] ref cleanup error",f)}let u=n&&typeof n=="object"&&!Array.isArray(n)?g(n,l):null;Ge(u,l)}function Ge(e,n){if(e&&e.length>1)for(let t of e)t.parentNode&&t.parentNode.removeChild(t);else n?.parentNode&&n.parentNode.removeChild(n)}function lt(e){return e==null||typeof e=="boolean"?"hole":e&&typeof e=="object"&&!Array.isArray(e)&&S(e)?"portal":"real"}var dt={hole:st,portal:ut,real:at};function st(e,n){let{parent:t,oldChildren:o,oldNodes:i,ctx:r,out:l,pushA:d,c:u,i:f}=e,s=o[f]??null,a=i[f]??null,c=de(s);if(c==="hole"){let y=H(r.browser??V(),u);a?.nodeType===8?(y&&a.nodeValue!==y.nodeValue&&(a.nodeValue=y.nodeValue),l.push(a),d(a),a&&(n.current=a)):(y&&a?.parentNode?a.parentNode.replaceChild(y,a):y&&t.appendChild(y),l.push(y),d(y),y&&(n.current=y));return}let p=c==="multi"?qe(t,s,a,u,r):s&&typeof s=="object"&&!Array.isArray(s)&&typeof s.type=="function"?We(t,s,a,u,r):ze(t,s,a,u,r);l.push(p),d(p),p&&(n.current=p)}function ut(e,n){let{parent:t,oldChildren:o,oldNodes:i,ctx:r,out:l,pushA:d,c:u,i:f}=e,s=u,a=o[f]??null,c=W(t,i[f]??null,a,s,r),p=Se(s,c);l.push(...p),d(p[0]??c??null);let y=p[p.length-1]??c;y&&(n.current=y)}function at(e,n){let{parent:t,oldNodes:o,ctx:i,out:r,pushA:l,arrEnd:d,c:u,i:f}=e,a=E(u,i,i.browser??V());if(r.push(a),l(a??null),a!=null){let c=o[f];c&&c.nodeType===8&&c.nodeValue?.includes("type=hole")?(c.parentNode?.replaceChild(a,c),n.current=a):(n.current?t.insertBefore(a,n.current.nextSibling):d&&d.parentNode===t?t.insertBefore(a,d):t.insertBefore(a,t.firstChild),n.current=a)}}function fe(e){for(let n=0;n<e.length;n++){let t=e[n];t&&typeof t=="object"&&!Array.isArray(t)&&se(t)===null&&(t.key=`pos:${n}`)}}function Xe(e,n,t,o){te()?console.error(`[vdom2/audit] I1 \u8FDD\u53CD\uFF1Adiff \u6536\u5230 disposed \u7EC4\u4EF6 ${o}\u2014\u2014\u526A\u679D\u7F13\u5B58\u5931\u6548\uFF08portal \u5185\u5BB9\u72EC\u7ACB dispose\uFF09\u2014\u2014\u7236\u6811\u5C06\u91CD\u5EFA`):console.warn(`[vdom2] disposed \u7EC4\u4EF6 ${o} \u5728 diff\u2014\u2014\u526A\u679D\u7F13\u5B58\u5931\u6548\u2014\u2014\u7236\u6811\u91CD\u5EFA\u4E2D\uFF08\u5360\u4F4D\u515C\u5E95\uFF09`);let i=H(t.browser??V(),null);if(i==null)return null;let r=n;if(r){let l=r.parentNode;l?l.replaceChild(i,r):e.appendChild(i)}else e.appendChild(i);return i}var ct={unkeyed:nt,keyed:Ue,mixed:e=>(fe(e.newChildren),fe(e.oldChildren),Ue(e))};function Ye(e,n,t,o){let i=t,r=i.__registry??U(),l=i.browser??V();return Promise.resolve(B(n,i,null,r)).then(()=>{let d=E(n,i,l);if(d!=null&&e.appendChild(d),n._id&&r){let u=r.idRegistry.get(n._id);u&&(u._parentNode=e)}o?.onMounted?.()}).catch(d=>console.error("[vdom2] command mount error",d)),{id:n._id??""}}function Mo(e,n,t){return new Promise(o=>{Ye(e,n,t,{onMounted:o})})}async function Oo(e,n,t,o,i){return await B(o,i,t,i.__registry),W(e,n,t,o,{browser:i.browser??i.__browser,registry:i.__registry})}function Do(e,n){let t=n.__registry??(n.__registry=U());return Promise.resolve(B(e,n,void 0,t))}async function Ho(e,n,t){let o=await e(n,t);return typeof o=="function"?o(n):o}async function Bo(e,n,t){let o=await e(n,t);return()=>typeof o=="function"?o(n):o}function pe(e,n){if(e==null||typeof e!="object")return;if(Array.isArray(e)){for(let o of e)pe(o,n);return}n(e);let t=e?.props?.children;t!=null&&pe(t,n)}function Fo(e,n){let t;return pe(e,o=>{!t&&n(o)&&(t=o)}),t}function Ko(e,n){let t=[];return pe(e,o=>{typeof o?.props?.class=="string"&&o.props.class.split(" ").includes(n)&&t.push(o)}),t}function Uo(e){let n={ui:{render:()=>{},ready:!0,useExternal:()=>{}}};return e?{ui:{...n.ui,...e.ui??{}},...e.browser?{browser:e.browser}:{}}:n}function qo(e=()=>!1,n){return{get open(){return e()},setOpen:n??(t=>{}),refresh:()=>{},portal:(t,o)=>e()?t:null,wrapProps:{}}}export{Do as buildToDom,qo as createPopupMock,Uo as createTestCtx,Ko as findByClass,Fo as findVNode,Bo as mountComponent,Mo as mountToDom,Oo as patchToDom,Ho as renderVNode,pe as walkVNode};
@@ -238,10 +238,14 @@ export interface BrowserEnv {
238
238
  dispatchEvent(target: EventTarget, evt: Event): boolean;
239
239
  /** 编程式导航(history.pushState + popstate——路由驱动) */
240
240
  navigate(url: string): void;
241
+ /** 整页重载(location.reload——SSR no-op;错误重试场景) */
242
+ reload(): void;
241
243
  /** 文本遍历(TreeWalker) */
242
244
  createTreeWalker(root: Node, whatToShow?: number): TreeWalker | null;
243
245
  /** 复制文本(clipboard API + execCommand 降级,统一组件重复实现) */
244
246
  copyText(text: string): Promise<boolean>;
247
+ /** 下载文本文件(Blob + a[download]——SSR no-op false;导出/报表用) */
248
+ downloadFile(filename: string, content: string, mime?: string): boolean;
245
249
  /** execCommand(富文本编辑器) */
246
250
  execCommand(cmd: string, value?: string): boolean;
247
251
  /** 编辑器选区文本 */
@@ -276,6 +280,8 @@ export interface WfuiContext {
276
280
  [key: string]: unknown;
277
281
  /** 浏览器环境抽象(SSR shim 安全默认)——组件禁直接 window/document */
278
282
  browser?: BrowserEnv;
283
+ /** i18n(i18n() 中间件注入——运行时语言切换 + 应用级文案) */
284
+ i18n?: import('./i18n.ts').I18nState;
279
285
  /** UI 框架能力(由 createApp.mount 注入) */
280
286
  ui: {
281
287
  /** 触发组件重渲染(同步,无参 = 当前组件) */
package/docs/frontend.md CHANGED
@@ -153,6 +153,7 @@ ctx.ui.render(['name'])
153
153
  | `byId(id)` / `query(sel)` | 元素查询(getElementById / querySelector) |
154
154
  | `createElement(tag)` / `bodyAppend(el)` / `bodyRemove(el)` | 动态创建/挂载容器 |
155
155
  | `copyText(text)` | **复制统一入口**(clipboard API + execCommand 降级) |
156
+ | `downloadFile(filename, content, mime?)` | 下载文本文件(Blob + a[download];SSR no-op)——导出/报表 |
156
157
  | `execCommand(cmd, value?)` | 富文本编辑器命令 |
157
158
  | `selectionText()` / `getSelection()` | 编辑器选区(文本 / 完整 Selection 对象) |
158
159
  | `viewportHeight()` / `scrollTop()` | 视口高度 / 滚动量(scrollingElement 优先) |
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "weifuwu",
3
3
  "type": "module",
4
- "version": "0.81.4",
4
+ "version": "0.81.6",
5
5
  "description": "AI SaaS framework — (req, ctx) => Response",
6
6
  "exports": {
7
7
  ".": {