weifuwu 0.82.12 → 0.83.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/ui-dom/index.d.ts +4 -0
- package/dist/ui-dom/index.js +12 -12
- package/dist/ui-dom/router.d.ts +7 -0
- package/dist/ui-dom/testing.js +1 -1
- package/dist/ui-dom/vdom2/audit.d.ts +4 -1
- package/dist/ui-dom/vdom2/dom-trace.d.ts +4 -0
- package/dist/ui-dom/vdom2/events.d.ts +5 -1
- package/dist/ui-dom/vdom2/lifecycle.d.ts +4 -0
- package/dist/ui-dom/vdom2/mount.d.ts +14 -1
- package/dist/ui-dom/vdom2/patch.d.ts +2 -0
- package/dist/ui-dom/vdom3/README.d.ts +29 -0
- package/dist/ui-dom/vdom3/audit.d.ts +16 -0
- package/dist/ui-dom/vdom3/build.d.ts +16 -0
- package/dist/ui-dom/vdom3/commands.d.ts +11 -0
- package/dist/ui-dom/vdom3/compat.d.ts +20 -0
- package/dist/ui-dom/vdom3/events.d.ts +11 -0
- package/dist/ui-dom/vdom3/index.d.ts +40 -0
- package/dist/ui-dom/vdom3/jsx.d.ts +10 -0
- package/dist/ui-dom/vdom3/record.d.ts +13 -0
- package/dist/ui-dom/vdom3/registry.d.ts +30 -0
- package/dist/ui-dom/vdom3/render.d.ts +26 -0
- package/dist/ui-dom/vdom3/replay.d.ts +25 -0
- package/dist/ui-dom/vdom3/root.d.ts +28 -0
- package/dist/ui-dom/vdom3/router.d.ts +31 -0
- package/dist/ui-dom/vdom3/scheduler.d.ts +23 -0
- package/dist/ui-dom/vdom3/ssr.d.ts +27 -0
- package/dist/ui-dom/vdom3/sync.d.ts +22 -0
- package/dist/ui-dom/vdom3/types.d.ts +115 -0
- package/dist/ui-dom/vdom3/ui.d.ts +43 -0
- package/dist/ui-dom/vdom3.js +39 -0
- package/docs/frontend.md +5 -0
- package/package.json +6 -2
package/dist/ui-dom/index.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
function no(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}=no(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 to=vn;function oo(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 ro(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 io(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 so(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 lo(e){let n=so(e);return n?.exp?n.exp*1e3-3e4<Date.now():!0}function ao(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&&lo(l)&&a.refresh().catch(()=>{}),e?.onAuth?.(a),xe(s,{auth:a})}}function uo(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 co(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:fo(e?.components??{},t)}}function fo(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 po={route:"route",lifecycle:"lifecycle",x2y:"diff",keys:"diff",pos:"diff",render:"render",audit:"audit",build:"build",mount:"mount",diff:"diff"};function at(e){return po[e]}var Ve=new Set;function Qe(e){return Ve.add(e),()=>{Ve.delete(e)}}var Xe=[],mo=0;function Ze(e){let n=`R${++mo}${e?":"+e:""}`;return Xe.push(n),n}function Ae(){Xe.pop()}function yo(){return Xe[Xe.length-1]??""}function S(e){if(Ve.size!==0){e.session||(e.session=yo()),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 go(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 ho(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}${go(e.payload)}`)}Qe(ho);var vo=500,Re=[],lt=!1;function No(e){Re.push(e),Re.length>vo&&Re.shift()}function ut(){lt||(lt=!0,Qe(No))}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 wo={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,bo=50;function Co(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>bo&&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
|
|
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 _o=0;function ue(){return{idRegistry:new Map,unmountHooks:[],nextId:()=>`_wf_${_o++}`}}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 ko(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"&&ko(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 So(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(So(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 Po=/^on[A-Z]/,Ro=/^on[A-Z].*Capture$/;function _n(e){let n=Ro.test(e);return{type:(n?e.slice(2,-7):e.slice(2)).toLowerCase(),capture:n}}var kn=new Set(["draggable","contenteditable","spellcheck","translate"]),Ao=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":Po.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 Io={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"&&!Ao.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&&Io[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){Lo[U(n)](e,n,t)}var Lo={hole:()=>{},text:()=>{},arr:Mo,portal:()=>{},frag:Ho,comp:Oo,native:Uo};function Mo(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 Ho(e,n,t){rn(e,P(n.props?.children),t)}function Oo(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 Uo(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 $o(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 Do(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 jo[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 jo={hole:e=>e,text:e=>e,arr:Wo,comp:Fo,frag:Bo,native:Et,portal:Et};function Wo(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 Fo(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=$o(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 Do(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 Bo(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 Ko=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 er[U(e)](e,n,s,o,r,i)}function qo(e,n,t){return null}function Go(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 zo(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 Yo(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 Jo(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 Xo(e,n,t){let o=e,r=o._lifecycle??(typeof o._render=="function"?"built":"fresh");return Qo[r](o,n,t)}var Qo={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 Zo(e,n,t,o,r){let i=e,s=i,l=i.type,d=Ko.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||d instanceof HTMLInputElement)){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 er={hole:qo,text:Go,arr:zo,portal:Yo,frag:Jo,comp:Xo,native:Zo};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 nr(e){return Ie(e.oldInput,e.oldNode,e.parent,e.ctx),null}function tr(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 or(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 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=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 ir(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 sr(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 lr(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 ar(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:nr,portal:pe,...e}}var dr={text:Ne({text:or}),hole:Ne({text:ke,native:ke,frag:ke,comp:ke,arr:ke,portal:ke,hole:tr}),native:Ne({native:rr}),frag:Ne({frag:ir}),comp:Ne({comp:sr}),arr:Ne({arr:lr}),portal:Ne({portal:ar})};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()}),dr[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;ur[U(r)](r,n)}}var ur={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 cr[U(e)](e,n,t,o)}var cr={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 St={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 l=!0;for(let d=0;d<o.length;d++)if(o[d]!==r[d]||n[o[d]]!==t[o[d]]){l=!1;break}if(l)return}let i=new Set([...o,...r]),s=null;for(let l of i){if(l==="children"||l==="key")continue;let d=n[l],u=t[l];if(d!==u){if(l==="value"&&(e instanceof HTMLSelectElement||e instanceof HTMLInputElement)){s={ov:d,nv:u};continue}St[Sn(l)](e,l,d,u)}}s&&St.value(e,"value",s.ov,s.nv)}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 Pt(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=It(n,t,r,o,l);i.push(u),s(u);return}let d=Lt(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=At(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=Ht(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 At(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 It(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 Lt(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:Pt,multi:Pt},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 Rt(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=Ht(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)}Mt(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;Mt(d,s)}function Mt(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"?At(t,a,c,d,i):a&&typeof a=="object"&&!Array.isArray(a)&&typeof a.type=="function"?It(t,a,c,d,i):Lt(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 Ht(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:Rt,mixed:e=>(ln(e.newChildren),ln(e.oldChildren),Rt(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:Ot(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:Ot(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 Ot(e){return typeof e.type=="function"&&e.type.name?e.type.name:"anonymous"}function Ut(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 $t=V();function Dt(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=$t.viewportWidth(),a=$t.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 jt(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&&
|
|
5
|
-
\u975E\u53D7\u63A7\uFF1A\u53BB\u6389 open\uFF1B\u53D7\u63A7\uFF1A\u4F20\u5165 onOpenChange={(o) => setOpen(o)}`));let r=()=>o?!!
|
|
1
|
+
function uo(e){let t=[],n=(e||"/").replace(/:(\w+)/g,(o,r)=>(t.push(r),"([^/]+)")).replace(/\*/g,".*");return{re:new RegExp(`^${n}$`),keys:t}}function at(e,t){if(!t||t==="/")return e||"/";let n=e.endsWith("/")?e.slice(0,-1):e,o=t.startsWith("/")?t:"/"+t;return n+o}var bn=class{_routes=[];_middlewares=[];_injections=[];_injected=!1;_mode;_notFound;_children=[];constructor(t={}){this._mode=t.mode??"history"}get mode(){return this._mode}use(t,n){if(typeof t=="string"&&n){let o=this,r=t;this._children.push({prefix:t,sub:n});let i=async(s,l,d)=>{let c=l.__routePath??o.getPath(),a=null;return c===r?a="/":(r==="/"?c!=="/"&&c.startsWith("/"):c.startsWith(r+"/"))&&(a=c.slice(r.length)),a===null?d:async(u,f)=>{let p=await n._handle(a,u,f);return p===null?d(u,f):p}};return this._middlewares.push(i),this}return t.length<=1?(this._injections.push(t),this):(this._middlewares.push(t),this)}async _ensureInjected(t){if(!this._injected){this._injected=!0;for(let n of this._injections){let o=await n(t);o&&o!==t&&Object.assign(t,o)}}}get(t,n,o){return this._routes.push({path:t,handler:n,title:o?.title}),this}notFound(t){return this._notFound=t,this}getPath(){return this._getPath(void 0)}dumpRoutes(t=""){let n=this._routes.map(o=>({path:at(t,o.path),title:o.title}));for(let o of this._children)n.push(...o.sub.dumpRoutes(at(t,o.prefix)));return n}_getPath(t){let n=t?.location??(typeof window<"u"?window.location:null);return this._mode==="hash"?(n?.hash??"").replace(/^#/,"")||"/":n?.pathname??"/"}match(t){let n=null;for(let o of this._routes){let{re:r,keys:i}=uo(o.path),s=t.match(r);if(!s)continue;let l={};for(let d=0;d<i.length;d++)l[i[d]]=decodeURIComponent(s[d+1]);n={handler:o.handler,params:l,title:o.title};break}return n||(n={handler:this._notFound??(()=>null),params:{}}),n}async _handle(t,n,o){await this._ensureInjected(o);let r=this.match(t);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=t;try{for(let d=this._middlewares.length-1;d>=0;d--){let c=this._middlewares[d],a=s;s=await c(n,o,a)??a}return await s(n,o)}finally{o.__routePath=l}}async execute(t,n,o){await this._ensureInjected(n);let r=this.match(o);r.title&&typeof document<"u"&&(document.title=r.title),n.params=r.params,n.route&&(n.route.params=r.params);let s=r.handler;for(let l=this._middlewares.length-1;l>=0;l--){let d=this._middlewares[l],c=s;s=await d(t,n,c)??c}return await s(t,n)}};var Z=Symbol("Fragment"),z=Symbol("Portal");function Je(e){return e!=null&&typeof e=="object"&&typeof e.type=="string"}function oe(e){return e!=null&&typeof e=="object"&&e.type===Z}function R(e){return e!=null&&typeof e=="object"&&typeof e.type=="function"}function Y(e){return e!=null&&typeof e=="object"&&e.type===z}function Xe(e,t,n=null){return{type:e,props:t,key:n,_child:null,_parentNode:null,_refNode:null,_id:null,_customId:null,_parentVNode:null,_ctxVersion:null,_lifecycle:"fresh"}}function Le(e,t,n=null){return e===Z?{...Xe(e,t,n),type:e}:e===z?{...Xe(e,t,n),type:e,_remoteEl:null,_placement:"remote"}:typeof e=="function"?{...Xe(e,t,n),type:e,_render:null,_outputChild:null}:{...Xe(e,t,n),type:e,el:null}}function ve(e,t,...n){let o=dt(t??{});return n.length>0&&(o.children=n.length===1?n[0]:n),Le(e,o,t?.key??null)}function Cn(e,t,n){return Le(e,dt(t),n??null)}var co=Cn;function fo(e,t,n){return Cn(e,t,n)}function dt(e){if(!e)return{};let t={};for(let n of Object.keys(e))n!=="key"&&(t[n]=e[n]);return t}function A(e){return e==null||typeof e=="boolean"?[]:Array.isArray(e)?e:[e]}function Qe(e,t){let n=Le(z,{children:e,portalKey:t});return n.key=t??null,n}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,t)=>typeof document<"u"?document.createElementNS(e,t):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,t,n)=>{typeof window<"u"&&window.addEventListener(e,t,n)},removeEventListener:(e,t,n)=>{typeof window<"u"&&window.removeEventListener(e,t,n)},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,t)=>{let n=typeof window<"u"?window:null,o=t&&(t.key||t.code)?"KeyboardEvent":t&&(t.clientX!==void 0||t.clientY!==void 0||t.pointerId!==void 0)?"PointerEvent":"Event";try{return new n[o](e,t)}catch{return new n.Event(e,t)}},dispatchEvent:(e,t)=>typeof e<"u"?e.dispatchEvent(t):!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,t,n="text/plain")=>{try{if(typeof document>"u"||typeof URL>"u"||!URL.createObjectURL)return!1;let o=new Blob([t],{type:n}),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 t=typeof window<"u"?window:null;if(t?.navigator?.clipboard?.writeText)try{return await t.navigator.clipboard.writeText(e),!0}catch{}try{if(typeof document>"u")return!1;let n=document.createElement("textarea");n.value=e,n.style.position="fixed",n.style.opacity="0",document.body.appendChild(n),n.select();let o=document.execCommand("copy");return document.body.removeChild(n),o}catch{return!1}},execCommand:(e,t)=>typeof document<"u"?document.execCommand(e,!1,t):!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,t)=>typeof document<"u"?document.createTreeWalker(e,t??NodeFilter.SHOW_ALL):null,scrollTop:()=>{let e=typeof document<"u"?document:null,t=typeof window<"u"?window:null;return e?.scrollingElement?.scrollTop??t?.scrollY??0},hash:()=>typeof window<"u"?window.location?.hash??"":"",setHash:e=>{typeof window<"u"&&(window.location.hash=e)},timeout:(e,t)=>typeof window<"u"?window.setTimeout(e,t):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,t)=>{try{typeof window<"u"&&window.localStorage?.setItem(e,t)}catch{}}}}function po(e,t,n=400){let o=!1,r=()=>{o||(o=!0,e.removeEventListener("animationend",r),clearTimeout(i),t())};e.addEventListener("animationend",r);let i=setTimeout(r,n)}function Ee(e,t){return Object.assign(Object.create(e),t)}function mo(e){let t={baseURL:e?.baseURL??"",headers:{"Content-Type":"application/json",...e?.headers}},n=e?.onRequest,o=e?.onResponse,r=e?.timeout??0;async function i(s,l,d,c,a=!1){let u=t.baseURL+l,f={method:s,headers:{...t.headers,...c?.headers}},p=e?.token?.();p&&!f.headers.Authorization&&(f.headers.Authorization=`Bearer ${p}`);let m=r>0,g=!!c?.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&&c.signal.addEventListener("abort",()=>h.abort())),d!==void 0&&s!=="GET"&&s!=="HEAD"&&(f.body=JSON.stringify(d));let y={url:u,init:f};n&&(y=n(y));try{let N=await fetch(y.url,y.init);if(N.status===401&&await e?.onUnauthorized?.()&&!a)return i(s,l,d,c,!0);if(o)return o(N);if(!N.ok){let I=await N.text().catch(()=>"");throw new xn(N.status,I||N.statusText)}let b=N.headers.get("content-length");if(N.status===204||b==="0")return;let P=(N.headers.get("content-type")||"").toLowerCase();return P.includes("application/json")||P.includes("json")?N.json():N.text()}finally{w&&clearTimeout(w)}}return s=>Ee(s,{api:{get:(d,c)=>i("GET",d,void 0,c),post:(d,c,a)=>i("POST",d,c,a),put:(d,c,a)=>i("PUT",d,c,a),patch:(d,c,a)=>i("PATCH",d,c,a),delete:(d,c)=>i("DELETE",d,void 0,c)}})}var xn=class extends Error{status;body;constructor(t,n){super(`API Error ${t}: ${n}`),this.name="ApiError",this.status=t,this.body=n}};function yo(e){try{let t=e.split(".");if(t.length!==3)return null;let n=t[1].replace(/-/g,"+").replace(/_/g,"/");return JSON.parse(atob(n))}catch{return null}}function go(e){let t=yo(e);return t?.exp?t.exp*1e3-3e4<Date.now():!0}function ho(e){let t=e?.storage??localStorage,n=e?.tokenKey??"weifuwu_token",o=e?.userKey??"weifuwu_user",r=e?.refreshTokenKey??"weifuwu_refresh",i=e?.refreshEndpoint??"/api/auth/refresh";return s=>{let l=t.getItem(n),d=t.getItem(o),c=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,t.setItem(n,f),t.setItem(o,JSON.stringify(p)),m&&t.setItem(r,m)},logout(){a.token=null,a.user=null,t.removeItem(n),t.removeItem(o),t.removeItem(r)},setUser(f){a.user=f,t.setItem(o,JSON.stringify(f))},async refresh(){return c||(c=u().finally(()=>{c=null}),c)}};async function u(){let f=t.getItem(r);if(!f)return!1;let p=t.getItem(n);try{let m=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:f})});if(t.getItem(n)!==p)return!1;if(!m.ok)return a.logout(),!1;let g=await m.json();return t.getItem(n)!==p?!1:(a.token=g.token,t.setItem(n,g.token),g.refreshToken&&t.setItem(r,g.refreshToken),!0)}catch{return!1}}return l&&go(l)&&a.refresh().catch(()=>{}),e?.onAuth?.(a),Ee(s,{auth:a})}}function vo(e={}){let t=e.url??"/ws",n=e.reconnectInterval??3e3,o=e.maxReconnect??10,r=e.pingInterval??3e4,i=e.pingTimeout??1e4;return s=>{let l=new Set,d=null,c=0,a=null,u=null,f=null,p=!1,m=[],g={isConnected:!1,onMessage:b=>(l.add(b),()=>{l.delete(b)}),send:b=>{let P=JSON.stringify(b);d?.readyState===WebSocket.OPEN?d.send(P):m.push(P)},_connect:h,close:()=>{p=!0,N(),d?.close(),d=null,m=[],g.isConnected=!1}};async function h(){if(!p)try{d=new WebSocket(t),d.onopen=()=>{g.isConnected=!0,c=0;for(let b of m)d.send(b);m=[],w()},d.onmessage=b=>{try{let P=JSON.parse(b.data);for(let I of l)I(P)}catch{}y()},d.onclose=()=>{g.isConnected=!1,N(),!p&&c<o&&(c++,a=setTimeout(h,n*Math.min(c,5)))},d.onerror=()=>{d?.close()}}catch{p||(a=setTimeout(h,n))}}function w(){r<=0||(u=setInterval(()=>{d?.readyState===WebSocket.OPEN&&d.send(JSON.stringify({type:"ping"})),f=setTimeout(()=>{d?.close()},i)},r))}function y(){clearTimeout(f)}function N(){clearInterval(u),clearTimeout(f),clearTimeout(a)}return h(),Ee(s,{ws:g})}}var ut={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 ct={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 Ze={"zh-CN":ut,"en-US":ct};function ft(e){if(Ze[e])return e;let t=e.split("-")[0];return Object.keys(Ze).find(o=>o.startsWith(t))??"zh-CN"}function No(e={}){let{locale:t="zh-CN",messages:n={},components:o={}}=e,r=ft(t),i=Ze[r],s=pt(i,n,o),l={locale:r,t:(d,c)=>s.messages?.[d]??c??d,setLocale:()=>{},components:s.components};return d=>{let c=d;return c.i18n=l,l.setLocale=a=>{let u=ft(a),f=Ze[u];f&&(s=pt(f,n,o),l.locale=u,l.components=s.components,c.ui?.bumpCtxVersion?.(),c.ui?.render())},d}}function pt(e,t,n){return{messages:{...e?.messages,...t},components:wo(e?.components??{},n)}}function wo(e,t){let n={...e};for(let o of Object.keys(t))typeof t[o]=="object"&&t[o]!==null&&typeof n[o]=="object"?n[o]={...n[o],...t[o]}:n[o]=t[o];return n}var bo={route:"route",lifecycle:"lifecycle",x2y:"diff",keys:"diff",pos:"diff",render:"render",audit:"audit",build:"build",mount:"mount",diff:"diff",dom:"diff"};function yt(e){return bo[e]}var _e=new Set;function nn(e){return _e.add(e),()=>{_e.delete(e)}}var en=[],Co=0;function tn(e){let t=`R${++Co}${e?":"+e:""}`;return en.push(t),t}function Me(){en.pop()}function He(){return en[en.length-1]??""}function T(e){if(on(),_e.size!==0){e.session||(e.session=He()),typeof e.payload=="function"&&(_e.size>1||E(yt(e.machine),e.level??"debug"))&&(e.payload=e.payload());for(let t of _e)try{t(e)}catch{}}}function gt(){return _e.size>1}function xo(e){if(e==null)return"";if(typeof e=="string")return` ${e}`;if(typeof e=="object"){let t=e,n=[];for(let o of["path","i","key","mode","kind","insertedBefore","after","depth"])if(t[o]!==void 0){let r=t[o];n.push(`${o}=${typeof r=="object"?JSON.stringify(r):String(r)}`)}return n.length?" "+n.join(" "):""}return` ${String(e)}`}function Vo(e){let t=yt(e.machine);if(!E(t,e.level??"debug"))return;if(e.event==="TRACE"){console.log(`[vdom:${e.machine}] ${e.payload}`);return}let n=e.component?`${e.component}${e.nodeId?`(${e.nodeId})`:""}`:e.nodeId?`(${e.nodeId})`:"";console.log(`[vdom:${e.machine}] ${n?n+" ":""}${e.from} --${e.event}--> ${e.to}${xo(e.payload)}`)}nn(Vo);var Eo=Number(globalThis?.__WF_RING_MAX)||5e3,Ne=[],mt=!1;function _o(e){Ne.push(e),Ne.length>Eo&&Ne.shift()}function on(){mt||(mt=!0,nn(_o))}function ht(){on()}function vt(e=50,t){return on(),t?Ne.filter(n=>Object.entries(t).every(([o,r])=>n[o]===r)).slice(-e):Ne.slice(-e)}function Nt(e=100){return on(),Ne.filter(t=>t.event==="RENDER_REQUEST").slice(-e).map(t=>{let n=t.payload??{},o=Ne[0]?.ts??0,r=n.ts!=null?n.ts-o:0,i=t.component?`${t.component}${t.nodeId?`(${t.nodeId})`:""}`:t.from,s=n.ids?.length?`[${n.ids.join(",")}]`:"(\u65E0\u53C2\u2192self)";return`[t=+${r}ms] ${i} \u2192 ${s} ${n.detail?`(${n.detail})`:""}`})}var To={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 ee(e){let t=0,n=e._parentVNode??null;for(let o=0;o<10&&n;o++)t++,n=n._parentVNode??null;return{name:typeof e.type=="function"?e.type.name||"anonymous":String(e.type),id:e._id??null,depth:t}}var rn=new Map,So=50;function ko(e,t,n,o){if(!e?.id)return;let r=rn.get(e.id);r||(r={name:e.name??"?",events:[]},rn.set(e.id,r)),r.events.push(`${t}--${n}-->${o}`),r.events.length>So&&r.events.shift()}function wt(e){if(e){let t=rn.get(e);return t?`${t.name}(${e}): ${t.events.join(" \u2192 ")}`:`no timeline for ${e}`}return[...rn.entries()].map(([t,n])=>`${n.name}(${t}): ${n.events.join(" \u2192 ")}`).join(`
|
|
2
|
+
`)}function ne(e,t,n){let o=To[e]?.[t]??null;return o==null?(T({session:"",machine:"lifecycle",nodeId:n?.id??null,component:n?.name??null,from:e,event:t,to:"?",level:"warn",ts:Date.now()}),e):(ko(n,e,t,o),T({session:"",machine:"lifecycle",nodeId:n?.id??null,component:n?.name??null,from:e,event:t,to:o,payload:()=>({depth:n?.depth??0}),level:"debug",ts:Date.now()}),o)}function Se(e){return!e||e._lifecycle==="disposed"||e._child==null?!1:!Te(e._child)}function Te(e){if(e==null||typeof e!="object")return!1;if(Array.isArray(e)){for(let n of e)if(Te(n))return!0;return!1}let t=e;return!!(t._lifecycle==="disposed"||t._child!=null&&Te(t._child))}var Vn={error:0,warn:1,info:2,debug:3,trace:4},Ct=["mount","build","render","diff","lifecycle","route","audit"],re={enabled:!1,stages:new Set,level:"info",filter:null},En=!1;function Po(e){return e&&e in Vn?e:"info"}function bt(e){let t=new Set;if(!e)return t;for(let n of e.split(",")){let o=n.trim().split(":")[0];Ct.includes(o)&&t.add(o)}return t}function Tn(){if(En)return re;En=!0;try{let e=globalThis,t=new URLSearchParams(typeof e.location?.search=="string"?e.location.search:""),n=t.get("vdom_trace"),o=t.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")re={enabled:!0,stages:new Set(Ct),level:"debug",filter:null};else if(n||r||i){let s=new Set;if(n)for(let l of bt(n))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 bt(i))s.add(l);re={enabled:!0,stages:s,level:n?.includes(":")?Po(n.split(":")[1]):r?.level??"debug",filter:typeof r?.filter=="string"?r.filter:null}}}catch{}return re}function E(e,t="info"){return!re.enabled&&(En||Tn(),!re.enabled)||re.stages.size&&!re.stages.has(e)?!1:Vn[t]<=Vn[re.level]}function S(e,t,n,...o){if(!E(e,t)&&!gt())return;let r=re.filter;r&&!n.includes(r)||T({session:"",machine:e,nodeId:null,component:null,from:"",event:"TRACE",to:"",payload:()=>o.length?`${n} ${o.join(" ")}`:n,level:t,ts:Date.now()})}var Ro=0;function xt(e){return`R${++Ro}${e?`:${e}`:""}`}function X(e,t=12){if(!e)return"\u2205";if(typeof e=="string"||typeof e=="number")return`"${e}"`;if(!Array.isArray(e))return we(e);let n=e.slice(0,t).map(we);return e.length>t&&n.push(`\u2026+${e.length-t}`),`[${n.join(" | ")}]`}function Vt(e){return typeof e=="function"?"function":e===Z?"fragment":typeof e=="string"?"string":"other"}var Ao={function:e=>e.name||"Comp",fragment:()=>"Frag",string:e=>String(e),other:e=>String(e)},Io={function:e=>e.name||"anonymous",fragment:()=>"Fragment",string:e=>String(e),other:e=>e===z?"Portal":String(e)};function we(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 t=e,n=t.type,o=Ao[Vt(n)](n),r=t.props?.id?`#${t.props.id}`:t.key!=null?`@${t.key}`:"";return o+r}function J(e){if(!e)return"null";if(e.nodeType===1){let t=e;return`${t.tagName}${t.id?`#${t.id}`:""}${t.getAttribute?.("data-wf-key")?`@${t.getAttribute("data-wf-key")}`:""}`}return e.nodeType===3?`"${(e.textContent??"").slice(0,12)}"`:e.nodeType===8?`<!--${(e.nodeValue??"").slice(0,40)}-->`:`#${e.nodeType}`}function ce(e,t=12){if(!e)return"null";let o=Array.from(e.childNodes).slice(0,t).map(J);return e.childNodes.length>t&&o.push(`\u2026+${e.childNodes.length-t}`),`[${o.join(" | ")}]`}function _n(e,t=0){if(e==null||typeof e=="boolean")return[];if(typeof e=="string"||typeof e=="number")return[`${" ".repeat(t)}"${String(e).slice(0,20)}"`];if(Array.isArray(e))return e.flatMap(c=>_n(c,t));let n=e,o=n.type,r=Io[Vt(o)](o),i=n._lifecycle?`[${n._lifecycle}]`:"",s=n._id?`(${n._id})`:"",l=[`${" ".repeat(t)}${r}${s}${i}`],d=n._child;return d!=null&&l.push(..._n(d,t+1)),l}function Et(e){let t=globalThis;if(t.__vdom_dump==null&&(t.__vdom_dump=()=>_n(e()??null).join(`
|
|
3
|
+
`)),t.__vdom_lc==null&&(t.__vdom_lc=n=>wt(n)),t.__vdom_events==null){let n=vt;t.__vdom_events=(o,r)=>n(o,r)}t.__vdom_render_trace==null&&(t.__vdom_render_trace=n=>Nt(n))}function k(e){return typeof e=="function"&&e.name||"anonymous"}function sn(e){return e.ui?._ctxVersion??0}function Sn(e,t){e.ui?.setMounting?.(t)}var Lo=0;function fe(){return{idRegistry:new Map,unmountHooks:[],nextId:()=>`_wf_${Lo++}`}}function ln(e,t){return e.unmountHooks.push(t),()=>{let n=e.unmountHooks.indexOf(t);n>=0&&e.unmountHooks.splice(n,1)}}function _t(e,t){for(let n of[...e.unmountHooks])n(t);e.idRegistry.delete(t),e.idRegistry.delete(`custom:${t}`)}function Mo(e,t,n,o){try{e(t)}catch(r){console.error(`[weifuwu] ref ${n} error in <${o??"anonymous"}>`,r)}}function O(e,t){if(e==null||typeof e!="object")return;let n=e;if(n._lifecycle!=="disposed"){if(n._id){let o=ee(n);if(n._customId&&t.idRegistry.delete(n._customId),t.idRegistry.delete(n._id),t.unmountHooks.length>0){let r=[...t.unmountHooks];for(let i of r)i(n._id);if(n._customId)for(let i of r)i(n._customId)}n._id=null,n._customId=null,R(n)&&(n._render=null),n._parentNode=null,n._refNode=null,n._lifecycle=ne(n._lifecycle,"DISPOSE",o)}else(R(n)||n._child!=null)&&(n._lifecycle=ne(n._lifecycle,"DISPOSE",ee(n)));if(n._child!=null){if(Array.isArray(n._child))for(let o of n._child)o&&typeof o=="object"&&O(o,t);else O(n._child,t);n._child=null}if(n.props?.children&&typeof n.type=="string"){let o=Array.isArray(n.props.children)?n.props.children:[n.props.children];for(let r of o)r&&typeof r=="object"&&O(r,t)}if(typeof n.props?.ref=="function"&&Mo(n.props.ref,null,"cleanup"),Y(n)){let o=n._remoteEl;if(o){let r=n._child;if(r!=null)if(Array.isArray(r))for(let i of r)i&&typeof i=="object"&&O(i,t);else typeof r=="object"&&O(r,t);o.remove(),n._remoteEl=null}}}}function L(e,t){if(e==null||typeof e!="object")return null;if(Array.isArray(e)||oe(e)){let o=t;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 n=e;return R(n)?L(n._outputChild??n._child,t):null}function D(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 t=e;return oe(t)?"frag":Y(t)?"portal":R(t)?"comp":"native"}function kn(e){let t=!1,n=!1;for(let o of e){if(o==null||typeof o=="boolean"||typeof o=="string"||typeof o=="number")continue;if(Array.isArray(o)){n=!0;continue}let r=o;Y(r)||(r.key!=null?t=!0:n=!0)}return t&&n?"mixed":t?"keyed":"unkeyed"}function Ho(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 t=JSON.stringify(e);return`object ${t!=null&&t.length>80?t.slice(0,80)+"\u2026":t??""}`}catch{return`object ${Object.prototype.toString.call(e)}`}return`bad-vnode type=${typeof e}`}function an(e){return/[\s"=]/.test(e)?`"${e.replace(/"/g,"'")}"`:e}function K(e){let t=[`type=${e.type}`];return e.value!==void 0&&t.push(`value=${an(Ho(e.value))}`),e.key!=null&&t.push(`key=${an(e.key)}`),e.id!=null&&t.push(`id=${an(e.id)}`),e.fid!=null&&t.push(`fid=${an(e.fid)}`),`wf-hole: ${t.join(" ")}`}function St(e){return typeof e!="string"&&typeof e!="function"&&e!==Z&&e!==z}function kt(e){for(let t=0;t<e.length;t++){let n=e[t];if(n!=null&&typeof n=="object"&&!Array.isArray(n)){let o=n;o.key!==null&&(o.key=String(o.key))}}}var Oo=/^on[A-Z]/,$o=/^on[A-Z].*Capture$/;function Pn(e){let t=$o.test(e);return{type:(t?e.slice(2,-7):e.slice(2)).toLowerCase(),capture:t}}var Rn=new Set(["draggable","contenteditable","spellcheck","translate"]),Uo=new Set(["zIndex","opacity","lineHeight","fontWeight","fontSizeAdjust","flex","flexGrow","flexShrink","order","zoom","aspectRatio","gridRow","gridColumn","scale","rotate","animationIterationCount","columnCount","fillOpacity","strokeOpacity","stopOpacity","floodOpacity"]);function An(e){return Rn.has(e.toLowerCase())?"enumerated":e==="class"||e==="className"?"class":e==="style"?"style":e==="ref"?"ref":Oo.test(e)?"event":e==="value"?"value":e==="indeterminate"?"indeterminate":e==="innerHTML"?"innerHTML":e.startsWith("aria-")?"aria":"default"}function Tt(e,t,n){if(n!==!1){if(n===!0){e.setAttribute(t,"");return}try{e[t]=n,e.getAttribute(t)!==String(n)&&e.setAttribute(t,String(n))}catch{e.setAttribute(t,String(n))}}}var Do={enumerated:(e,t,n)=>{e.setAttribute(t,n?"true":"false")},class:(e,t,n)=>{if(n!==!1)if(typeof n=="object")for(let[o,r]of Object.entries(n))r&&e.classList.add(o);else e.setAttribute("class",String(n))},style:(e,t,n)=>{if(n!==!1)if(typeof n=="string")e.setAttribute("style",n);else{let o=e.style;for(let[r,i]of Object.entries(n))i==null?o[r]="":r.startsWith("--")?o.setProperty(r,String(i)):typeof i=="number"&&!Uo.has(r)?o[r]=`${i}px`:o[r]=String(i)}},ref:(e,t,n)=>{if(typeof n=="function")try{n(e)}catch(o){console.error("[weifuwu] ref error",o)}},event:(e,t,n)=>{if(n===!1)return;let{type:o,capture:r}=Pn(t);if(typeof n!="function"){console.warn(`[weifuwu] event prop ${t} expects a function, got ${typeof n} \u2014 ignored`);return}e.addEventListener(o,n,r?{capture:!0}:{})},value:(e,t,n)=>{n!==!1&&(e.value=n)},indeterminate:(e,t,n)=>{n!==!1&&(e.indeterminate=!!n)},innerHTML:(e,t,n)=>{n!==!1&&(e.innerHTML=String(n??""))},aria:(e,t,n)=>{if(n!==!1){if(typeof n=="boolean"){e.setAttribute(t,n?"true":"false");return}Tt(e,t,n)}},default:Tt};function ie(e,t,n){n!=null&&Do[An(t)](e,t,n)}function pe(e,t){return e.createComment(K({type:"hole",value:t,key:null,id:null,fid:null}))}function se(){let e=globalThis;return!(e.__WF_VDOM_AUDIT===0||e.__WF_VDOM_AUDIT==="0"||e.__WF_VDOM_AUDIT===!1)}var Pt=!1;function Rt(){Pt||(Pt=!0,nn(e=>{if(!(e.machine!=="render"||e.event!=="PARENT")&&se()&&e.to==="SKIP_DETACHED"){let t=e.payload;if(t.rendered===!1)return;console.error(`[vdom2/audit] \u6302\u8F7D\u4E0D\u53D8\u91CF\u8FDD\u53CD\uFF1A\u7EC4\u4EF6 ${e.component??"?"}${e.nodeId?`(${e.nodeId})`:""} \u72B6\u6001 ${String(t?.lifecycle)} \u4F46\u65E0 _parentNode/_refNode\uFF08rootEl \u53EA\u5C5E\u4E8E\u6839\u7EC4\u4EF6\uFF09\u2014\u2014\u6302\u8F7D\u4FE1\u606F\u65AD\u88C2\uFF08\u66FE\u6E32\u67D3\u540E\u5B9A\u4F4D\u4E22\u5931\uFF09\uFF0C\u6E32\u67D3\u88AB\u8DF3\u8FC7\uFF0C\u72B6\u6001\u66F4\u65B0\u5C06\u4E22\u5931`)}}))}function dn(e,t,n){if(t==null||t.length===0)return;let o=Array.from(e.childNodes);if(!t.some(i=>{if(i==null||typeof i!="object")return!1;if(Array.isArray(i))return!0;let s=i.type;return s===Z||s===z}))for(let i=0;i<t.length;i++){let s=t[i];if(s==null||typeof s=="boolean"){let l=o[i];(!l||l.nodeType!==8||!l.nodeValue?.includes("type=hole"))&&n(`[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&&n(`[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 ke(e,t,n){jo[D(t)](e,t,n)}var jo={hole:()=>{},text:()=>{},arr:Wo,portal:()=>{},frag:Fo,comp:Bo,native:Ko};function Wo(e,t,n){let o=t;dn(e,o,n);for(let r of o)if(r!=null&&typeof r=="object"&&Array.isArray(r))for(let i of r)ke(e,i,n);else r!=null&&typeof r=="object"&&!Array.isArray(r)&&oe(r)&&dn(e,A(r.props?.children),n)}function Fo(e,t,n){dn(e,A(t.props?.children),n)}function Bo(e,t,n){let o=t,r=o._refNode;r&&r.parentNode!==e&&n(`[audit] \u7EC4\u4EF6\u951A\u70B9\u9519\u4F4D\uFF1A${k(o.type)} _refNode \u4E0D\u5728\u7236\u8282\u70B9\u5185`),o._child!=null&&ke(e,o._child,n)}function Ko(e,t,n){let o=t;if(St(o.type))return;let r=o.el??o._refNode;if(r&&r.nodeType===1&&r.tagName.toLowerCase()!==String(o.type)&&n(`[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??{}))){dn(r,A(o.props?.children),n);for(let i of A(o.props?.children))i!=null&&typeof i=="object"&&!Array.isArray(i)&&R(i)&&ke(r,i,n)}}function qo(e,t){if(e===t)return!0;let n=Object.keys(e),o=Object.keys(t);if(n.length!==o.length)return!1;for(let r of n)if(e[r]!==t[r])return!1;return!0}async function Go(e,t,n,o){let r=e;r._id||(o?.reuse?._id?r._id=o.reuse._id:r._id=n.nextId(),n.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(t);i.ui=Object.create(t.ui);let s=i.ui;if(s._selfId=r._id??null,s._selfVNode=r,s.render=function(l){let d={source:"component",component:k(r.type),nodeId:r._id??null},c=i.ui,a=0;for(;c&&typeof c=="object"&&c._selfVNode&&a<10;)c=Object.getPrototypeOf(c),a++;return l==null&&r._id?c.render([r._id],d):c.render(l,d)},typeof r._render!="function"&&R(o?.reuse)&&typeof o.reuse._render=="function"&&(r._render=o.reuse._render),typeof r._render!="function"){Sn(t,!0);let l;try{l=await r.type(r.props??{},i)}finally{Sn(t,!1)}if(typeof l!="function")throw new Error(`Component ${k(e.type)} must return a render function. Use (init_props, ctx) => (props) => VNode pattern.`);r._render=l}return{renderFn:r._render,childCtx:i}}function In(e){return!!e&&typeof e.then=="function"}function q(e,t,n,o,r){return zo[D(e)](e,t,n,o,r)}function Ln(e,t){return e!=null&&typeof e=="object"&&!Array.isArray(e)&&e.type===t.type?e:null}var zo={hole:e=>e,text:e=>e,arr:Yo,comp:Xo,frag:Jo,native:At,portal:At};function Yo(e,t,n,o,r){let i=e;E("build")&&S("build","debug","",`array in kids=${X(i)}`);for(let a of i)if(a!=null&&typeof a=="object"&&!Array.isArray(a)&&a._lifecycle==="disposed"){let u=a;T({session:"",machine:"audit",nodeId:u._id??null,component:k(u.type),from:"disposed",event:"CONTRACT_VIOLATION",to:"new-tree",level:"error",ts:Date.now()}),se()&&console.error(`[vdom2/audit] \u4E24\u9636\u6BB5\u5951\u7EA6\u8FDD\u53CD\uFF1A\u7EC4\u4EF6 ${k(u.type)} \u7684 renderFn \u8FD4\u56DE\u4E86 disposed \u65E7 vnode${u._id?`(${u._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 u=i[a];if(u!=null&&typeof u=="object"&&!Array.isArray(u)){let f=u;f.key!==null&&(f.key=String(f.key))}}let s=Array.isArray(n)?n:[],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,u)=>{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[u]??null),q(a,t,f,o,r)});E("build")&&S("build","debug","",`array out kids=${X(i)}`);let c=!1;for(let a=0;a<d.length;a++)if(In(d[a])){c=!0;break}return c?Promise.all(d).then(()=>i):i}function Xo(e,t,n,o,r){let i=e,s=o??t.__registry??fe(),l=Ln(n,i);if(se()){let u=He(),f=i._sessionId;f!=null&&f!==u&&i._lifecycle==="building"&&console.error(`[vdom2/audit] I1 \u4F1A\u8BDD\u4E92\u65A5\u8FDD\u53CD\uFF1A${k(i.type)} \u88AB\u4F1A\u8BDD ${f} \u6784\u5EFA\u4E2D\u53C8\u88AB\u4F1A\u8BDD ${u} \u5904\u7406\u2014\u2014\u540C\u4E00 vnode \u591A\u4F1A\u8BDD\u5E76\u53D1\u6784\u5EFA\uFF08await \u70B9\u6E32\u67D3\u4EA4\u9519\u2014\u2014\u6784\u5EFA\u7ED3\u679C\u4E0D\u786E\u5B9A\uFF0C\u9700\u6392\u67E5\u6E32\u67D3\u89E6\u53D1\u6E90\uFF09`),i._sessionId=u}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),R(i)&&R(l)&&typeof l._render=="function"&&(i._render=l._render));let d=qo(l?.props??{},i.props??{}),c=sn(t),a=(l?._ctxVersion??-1)===c;if(!r?.force&&d&&a&&Se(l)&&typeof i._render=="function"){let u=l;return i._lifecycle=ne(i._lifecycle,"PRUNE",ee(i)),i._child=u._child,i._ctxVersion=u._ctxVersion,E("build")&&S("build","debug","",`prune comp=${we(i)} propsSame=${d} verSame=${a}`),i}return i._lifecycle=ne(i._lifecycle,"BUILD_START",ee(i)),E("build")&&S("build","debug","",`mount comp=${we(i)} propsSame=${d} verSame=${a} force=${!!r?.force} oldV=${l?(typeof l.type=="function"?l.type.name:String(l.type))+"/"+(l._lifecycle??"?"):"null"}`),(async()=>{let{childCtx:u}=await Go(i,t,s,{reuse:l??null}),f=await q(await i._render(i.props),u,l?._child,s,r);return i._child=f??null,i._ctxVersion=c,i._lifecycle=ne(i._lifecycle,"BUILD_DONE",ee(i)),i})()}function Jo(e,t,n,o,r){let i=e,s=o??t.__registry??fe(),l=Ln(n,i);E("build")&&S("build","debug","",`fragment kids=${X(A(i.props?.children))}`);let d=q(i.props?.children??null,t,l?._child??l?.props?.children,s,r);return In(d)?d.then(c=>(i._child=c??null,i._lifecycle=ne(i._lifecycle,"BUILD_DONE",ee(i)),i)):(i._child=d??null,i._lifecycle=ne(i._lifecycle,"BUILD_DONE",ee(i)),i)}function At(e,t,n,o,r){let i=e;if(typeof i.type!="string"&&typeof i.type!="symbol")return i;let s=o??t.__registry??fe(),l=Ln(n,i);E("build")&&S("build","trace","",`native <${String(i.type)}> kids=${X(A(i.props?.children))}`);let d=q(i.props?.children??null,t,l?.props?.children,s,r);return In(d)?d.then(c=>(i._child=c??null,i._lifecycle=ne(i._lifecycle,"BUILD_DONE",ee(i)),i)):(i._child=d??null,i._lifecycle=ne(i._lifecycle,"BUILD_DONE",ee(i)),i)}var Qo=new Set(["svg","path","circle","rect","line","polyline","polygon","g","text","defs","use","clipPath"]);function Pe(e,t){return pe(e,t)}function $(e,t,n,o=null,r=null,i=null){let s=t?.browser??n;if(!s)throw new Error("[vdom2] renderValue requires browser env (ctx.browser)");return lr[D(e)](e,t,s,o,r,i)}function Zo(e,t,n){return null}function er(e,t,n){return n.createTextNode(String(e))}function Mn(e,t,n,o,r){if(e==null||typeof e=="boolean")return Pe(n,e);let i=$(e,t,n,String(o),null,r);return i??Pe(n,null)}function nr(e,t,n,o=null,r=null,i=null){let s=e,l=n.createDocumentFragment();if(!l)return null;E("render")&&S("render","debug","",`array kids=${X(s)} fid=${i??"-"} key=${o??"-"}`);let d=n.createComment(K({type:"fragment-start",key:o,id:r,fid:i})),c=n.createComment(K({type:"fragment-end",key:o,id:r,fid:i}));d&&l.appendChild(d);for(let a=0;a<s.length;a++){let u=s[a],f=i!=null?`${i}-${a}`:String(a),p=Mn(u,t,n,a,f);p!=null&&l.appendChild(p)}return c&&l.appendChild(c),l}function tr(e,t,n){let o=e,r=o,i=n.bodyElement();if(!i)return null;let s=i.querySelector("#__wf_portal");s||(s=n.createElement("div"),s&&(s.id="__wf_portal",i.appendChild(s)));let l=n.createElement("div");if(l){l.setAttribute("data-portal",String(o.props?.portalKey??"wf"));let d=$(o.props?.children??null,t,n);d!=null&&l.appendChild(d),s&&s.appendChild(l),r._remoteEl=l;let c=A(o.props?.children);for(let a of c)a!=null&&typeof a=="object"&&!Array.isArray(a)&&(a._parentVNode=o)}return null}function or(e,t,n,o=null,r=null,i=null){let s=e,l=s,d=n.createDocumentFragment();if(!d)return null;let c=A(s.props?.children);E("render")&&S("render","debug","",`fragment kids=${X(c)} fid=${i??"-"}`);let a=n.createComment(K({type:"fragment-start",key:o,id:r,fid:i})),u=n.createComment(K({type:"fragment-end",key:o,id:r,fid:i}));a&&d.appendChild(a),l._refNode=a;for(let f=0;f<c.length;f++){let p=c[f],m=i!=null?`${i}-${f}`:String(f),g=Mn(p,t,n,f,m);g!=null&&d.appendChild(g)}return u&&d.appendChild(u),d}function rr(e,t,n){let o=e,r=o._lifecycle??(typeof o._render=="function"?"built":"fresh");return ir[r](o,t,n)}var ir={fresh:(e,t,n)=>{throw new Error(`[vdom2] component ${k(e.type)} not built (missing _render) \u2014 buildVNode must run before renderValue`)},building:(e,t,n)=>{throw new Error(`[vdom2] component ${k(e.type)} building in render \u2014 buildVNode must await before renderValue`)},disposed:(e,t,n)=>(console.warn(`[vdom2] disposed \u7EC4\u4EF6 ${k(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`),Pe(n,null)),built:It,pruned:It};function It(e,t,n){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,t,n);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 sr(e,t,n,o,r){let i=e,s=i,l=i.type,d=Qo.has(l)?n.createElementNS("http://www.w3.org/2000/svg",l):n.createElement(l);if(!d)return null;s.el=d,s._refNode=d,E("render")&&S("render","trace","",`native <${l}> key=${i.key??"-"} kids=${X(A(i.props?.children))}`),i.key!=null&&d.setAttribute("data-wf-key",i.key);let c=null;for(let[a,u]of Object.entries(i.props??{}))if(!(a==="children"||a==="key")){if(a==="value"&&(d instanceof HTMLSelectElement||d instanceof HTMLInputElement)){c=u;continue}ie(d,a,u)}if(!("innerHTML"in(i.props??{}))){let a=A(i.props?.children);for(let u=0;u<a.length;u++){let f=a[u],p=r!=null?`${r}-${u}`:String(u),m=Mn(f,t,n,u,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")&&S("render","trace","",`native <${l}> out=${ce(d)}`)}return c!==null&&(d.value=String(c)),d}var lr={hole:Zo,text:er,arr:nr,portal:tr,frag:or,comp:rr,native:sr};function me(e){let{parent:t,oldNode:n,oldInput:o,ctx:r}=e,i=$(e.newInput,r,r.browser??V());if(i==null)return null;if(n?.parentNode){let s=Oe(o,n,t,r);return s&&s.parentNode===t?t.insertBefore(i,s):t.appendChild(i),i}return t.appendChild(i),i}function ar(e){return Oe(e.oldInput,e.oldNode,e.parent,e.ctx),null}function dr(e){let t=e.oldNode;if(t?.nodeType===8){let n=Pe(e.ctx.browser??V(),e.newInput);return n&&t.nodeValue!==n.nodeValue&&(t.nodeValue=n.nodeValue),t}return null}function Re(e){let{parent:t,oldNode:n,ctx:o}=e,r=$(e.newInput,o,o.browser??V());return r==null?null:(n?.parentNode?n.parentNode.replaceChild(r,n):n?t.insertBefore(r,n):t.appendChild(r),r)}function ur(e){let{parent:t,oldNode:n,oldInput:o}=e,r=String(e.newInput);if(String(o)!==r){if(n&&n.nodeType===3)return n.nodeValue=r,n;let i=t.ownerDocument.createTextNode(r);return n?.parentNode?n.parentNode.replaceChild(i,n):t.appendChild(i),i}return n}function cr(e){let{parent:t,oldNode:n,oldInput:o,ctx:r}=e,i=e.newInput,s=o&&typeof o=="object"&&!Array.isArray(o)?o:null,l=i.type;if(n&&n.nodeType===1&&(s?.type??null)===l&&Je(i)){let d=n;return i.el=d,i._refNode=d,Mt(d,s?.props??{},i.props??{}),"innerHTML"in(i.props??{})||$e(d,s?._child??s?.props?.children??null,i._child??i.props?.children??null,r),d}return me(e)}function fr(e){let{parent:t,oldNode:n,oldInput:o,ctx:r}=e,i=e.newInput,s=o&&typeof o=="object"&&!Array.isArray(o)?o:null,l=oe(s)?L(s,n):null,d=Hn(t,s??o,i,r,l);return n?.parentNode?n:d[0]??null}function pr(e){let{parent:t,oldNode:n,oldInput:o,ctx:r}=e,i=e.newInput;if(!R(i)||typeof i._render!="function")throw new Error(`[vdom2] component ${k(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 me(e);let l=s?.type===i.type;if(!r.force&&s&&l&&Se(s)&&i._child===s._child)return n;s?.type===i.type&&s._id&&(i._id=s._id,r.registry.idRegistry.set(i._id,i)),i._parentNode=t,n&&(i._refNode=n);let d=i._child;if(d===null){i._outputChild=null,i._refNode=null;let a=n?.parentNode!=null,u=Oe(s?._child??null,n,t,r);s&&(s._child=null);let f=Pe(r.browser??V(),null);return a&&f?(u&&u.parentNode===t?t.insertBefore(f,u):t.appendChild(f),f):te(t,n,s?._child,null,r)}if(i._outputChild=d,d!=null&&Te(d)||s?._child!=null&&Te(s._child))return T({session:"",machine:"audit",nodeId:i._id??null,component:k(i.type),from:"PRUNED",event:"STALE_CACHE",to:"SKIP_DIFF",level:"warn",ts:Date.now()}),console.warn(`[vdom2] \u526A\u679D\u7F13\u5B58\u5931\u6548\uFF1A${k(i.type)} \u8F93\u51FA\u542B disposed \u7EC4\u4EF6\u2014\u2014\u5E76\u53D1\u6E32\u67D3\u4F1A\u8BDD dispose \u5171\u4EAB\u65E7\u6811\u2014\u2014\u8DF3\u8FC7 diff\uFF08\u4E0B\u4E00\u8F6E\u91CD\u5EFA\u6062\u590D\uFF09`),n;let c=te(t,n,s?._child,d,r);return c&&(i._refNode=c),c}function mr(e){let{parent:t,oldNode:n,oldInput:o,ctx:r}=e;if(o===e.newInput&&n?.parentNode)return n;let i=t.ownerDocument.createDocumentFragment(),s=$e(t,o,e.newInput,r,n?[n]:null);for(let l of s)l&&i.appendChild(l);return n?.parentNode?i.contains(n)?t.appendChild(i):n.parentNode.replaceChild(i,n):t.appendChild(i),i}function yr(e){let{ctx:t,oldInput:n}=e,o=e.newInput,r=n&&typeof n=="object"&&!Array.isArray(n)?n:null;if(Y(r)&&Y(o)){let i=r._remoteEl;if(i){let s=r._child??r.props?.children??null,l=o._child??o.props?.children??null;$e(i,s,l,t)}return o._remoteEl=r._remoteEl,null}return me(e)}function be(e){return{text:me,native:me,frag:me,comp:me,arr:me,hole:ar,portal:me,...e}}var gr={text:be({text:ur}),hole:be({text:Re,native:Re,frag:Re,comp:Re,arr:Re,portal:Re,hole:dr}),native:be({native:cr}),frag:be({frag:fr}),comp:be({comp:pr}),arr:be({arr:mr}),portal:be({portal:yr})};function Lt(e){let t=D(e.oldInput),n=D(e.newInput);return T({session:"",machine:"x2y",nodeId:null,component:null,from:t,event:"X2Y",to:n,level:"trace",ts:Date.now()}),gr[t][n](e)}function le(e,t){if(t&&typeof e.type=="function"&&e._id){try{O(e,t)}catch(n){console.error("[weifuwu] ref cleanup error",n)}_t(t,e._id)}}var Ht=new Set;function We(e){if(e==null||typeof e!="object"||Array.isArray(e))return null;let t=e;return Y(t)?typeof t.props?.portalKey=="string"?t.props.portalKey:null:t.key}function On(e,t){if(t&&e&&typeof e=="object"&&!Array.isArray(e)){let n=L(e,t);if(n&&n.length>1)return n}return[t]}function un(e,t){let n=A(e.props?.children);for(let o of n){if(o==null||typeof o!="object"||Array.isArray(o))continue;let r=o;hr[D(r)](r,t)}}var hr={comp:(e,t)=>{le(e,t)},frag:(e,t)=>{un(e,t)},native:(e,t)=>{un(e,t)},portal:(e,t)=>{un(e,t)},arr:()=>{},text:()=>{},hole:()=>{}};function Oe(e,t,n,o){return vr[D(e)](e,t,n,o)}var vr={arr:(e,t,n,o)=>{let r=L(e,t);if(r&&r.length){let i=(r[r.length-1]??t)?.nextSibling??null;for(let s of r)s.parentNode&&s.parentNode.removeChild(s);return i&&i.parentNode===n?i:null}return Ue(e,t,n,o)},frag:(e,t,n,o)=>{let r=e,s=L(r,t)??[],l=(s[s.length-1]??t)?.nextSibling??null;for(let d of s)d.parentNode&&d.parentNode.removeChild(d);return un(r,o.registry),l&&l.parentNode===n?l:null},portal:(e,t,n,o)=>{let r=e,i=r._remoteEl;try{O(r.props?.children,o.registry)}catch(s){console.error("[weifuwu] portal ref cleanup error",s)}return i?.parentNode?.removeChild(i),null},comp:(e,t,n,o)=>{let r=e,i=L(r,t);if(le(r,o.registry),i&&i.length>1){let s=(i[i.length-1]??t)?.nextSibling??null;for(let l of i)l.parentNode&&l.parentNode.removeChild(l);return s&&s.parentNode===n?s:null}return Ue(e,t,n,o)},native:(e,t,n,o)=>{try{O(e,o.registry)}catch(r){console.error("[weifuwu] ref cleanup error",r)}return Ue(e,t,n,o)},text:(e,t,n,o)=>Ue(e,t,n,o),hole:(e,t,n,o)=>Ue(e,t,n,o)};function Ue(e,t,n,o){let r=t?.nextSibling??null;return t?.parentNode&&t.parentNode.removeChild(t),r&&r.parentNode===n?r:null}function te(e,t,n,o,r){return Lt({parent:e,oldNode:t,oldInput:n,newInput:o,ctx:r})}var Ot={event:(e,t,n,o)=>{let{type:r,capture:i}=Pn(t);typeof n=="function"&&e.removeEventListener(r,n,i?{capture:!0}:{}),o!=null&&o!==!1&&(typeof o!="function"?console.warn(`[weifuwu] event prop ${t} expects a function, got ${typeof o} \u2014 ignored`):e.addEventListener(r,o,i?{capture:!0}:{}))},class:(e,t,n,o)=>{o==null||o===!1?e.removeAttribute("class"):(e.className="",ie(e,t,o))},ref:(e,t,n,o)=>{if(o==null||o===!1){if(typeof n=="function")try{n(null)}catch(r){console.error("[weifuwu] ref cleanup error",r)}}else ie(e,t,o)},value:(e,t,n,o)=>{o==null||o===!1?e.value="":ie(e,t,o)},indeterminate:(e,t,n,o)=>{o==null||o===!1?e.indeterminate=!1:ie(e,t,o)},enumerated:De,style:De,innerHTML:De,aria:De,default:De};function De(e,t,n,o){if(o==null||o===!1){e.removeAttribute(t);try{delete e[t]}catch{}}else ie(e,t,o)}function Mt(e,t,n){let o=Object.keys(t),r=Object.keys(n);if(o.length===r.length){let l=!0;for(let d=0;d<o.length;d++)if(o[d]!==r[d]||t[o[d]]!==n[o[d]]){l=!1;break}if(l)return}let i=new Set([...o,...r]),s=null;for(let l of i){if(l==="children"||l==="key")continue;let d=t[l],c=n[l];if(d!==c){if(l==="value"&&(e instanceof HTMLSelectElement||e instanceof HTMLInputElement)){s={ov:d,nv:c};continue}Ot[An(l)](e,l,d,c)}}s&&Ot.value(e,"value",s.ov,s.nv)}function Hn(e,t,n,o,r){let i=Array.isArray(t)?t:t?._child??t?.props?.children??null,s=Array.isArray(n)?n:n?._child??n?.props?.children??null;return $e(e,i,s,o,r)}function $e(e,t,n,o,r,i){let s=A(t),l=A(n),d=r??Array.from(e.childNodes);E("diff")&&S("diff","debug","",`patchChildren parent=${J(e)} old=${X(s)} new=${X(l)} dom=${ce(e)}`);let c=l.some(p=>Array.isArray(p))||s.some(p=>Array.isArray(p)),a=c?"unkeyed":kn(l);if(T({session:"",machine:"keys",nodeId:null,component:null,from:c?"unkeyed":kn(l),event:"SELECT",to:a,payload:()=>({len:l.length}),level:"trace",ts:Date.now()}),se()&&s.length!==l.length){let p=`${l.length}:${s.length}`;if(!Ht.has(p)){Ht.add(p);for(let m=0;m<l.length;m++){let g=l[m];g!=null&&typeof g=="object"&&!Array.isArray(g)&&R(g)&&g.key==null&&console.error(`[vdom2/audit] \u52A8\u6001\u6570\u7EC4\u4F4D\u7F6E ${m} \u7684\u7EC4\u4EF6\u7F3A\u5C11 key\uFF08${k(g.type)}\uFF09\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 u=r&&r.length?r[r.length-1]:null;a==="mixed"&&(cn(l),cn(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 N=p[g]??null;m.push(N);let b=L(w,N);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(Y(y)){m.push(y._remoteEl??null);continue}if(m.push(y._refNode??p[g]??null),typeof y.type=="function"||oe(y)){let N=L(y,y._refNode??p[g]??null);g+=N?.length??1}else g++}return m})();return $r[a]({parent:e,oldChildren:s,newChildren:l,oldNodes:f,ctx:o,arrEnd:u,anchorOut:i})}function je(e){return e==null||typeof e=="boolean"?"hole":Array.isArray(e)||e&&typeof e=="object"&&oe(e)?"multi":"real"}function Nr(e){let{parent:t,oldC:n,oldNode:o,oldNodes:r,i,ctx:s,out:l,pushA:d}=e;if(Array.isArray(n)){E("diff")&&S("diff","trace","",`remove-arr-item i=${i} range=[${(L(n,r[i])??[]).map(J).join(" | ")}] before=${ce(t)}`);let c=L(n,o);for(let a of c??[])a.parentNode?.removeChild(a);E("diff")&&S("diff","trace","",`remove-arr-item after=${ce(t)}`);for(let a of n)a!=null&&typeof a=="object"&&!Array.isArray(a)&&typeof a.type=="function"&&le(a,s.registry)}else if(n&&typeof n=="object"&&!Array.isArray(n)){if(typeof n.type=="function")le(n,s.registry);else try{O(n,s.registry)}catch(c){console.error("[weifuwu] ref cleanup error",c)}o?.parentNode&&o.parentNode.removeChild(o)}else o?.parentNode&&o.parentNode.removeChild(o);l.push(null),d(null)}function wr(e){let{parent:t,newC:n,oldNode:o,i:r,oldNodes:i,out:s,pushA:l,ctx:d}=e,c=pe(d.browser??V(),n);if(o?.nodeType===8){c&&o.nodeValue!==c.nodeValue&&(o.nodeValue=c.nodeValue),s.push(o),l(o);return}if(c&&o?.parentNode)o.parentNode.replaceChild(c,o);else if(c){let a=null;for(let u=r+1;u<i.length;u++){let f=i[u];if(f&&f.parentNode===t){a=f;break}}if(!a){let u=null;for(let f=s.length-1;f>=0;f--)if(s[f]){u=s[f];break}u&&u.parentNode===t&&(a=u.nextSibling)}a&&a.parentNode===t?t.insertBefore(c,a):t.appendChild(c),s.push(c),l(c)}else s.push(c),l(c)}function $t(e){let{parent:t,newC:n,oldNode:o,i:r,oldNodes:i,out:s,pushA:l,ctx:d}=e,c=$(n,d,d.browser??V(),String(r));if(c==null){s.push(null),l(null);return}if(o&&o.nodeType===8&&o.nodeValue?.includes("type=hole")){T({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(c,o),s.push(c),l(c);return}let a=null;for(let u=r+1;u<i.length;u++){let f=i[u];if(f&&f.parentNode===t){a=f;break}}if(a==null){let u=null;for(let f=s.length-1;f>=0;f--)if(s[f]){u=s[f];break}if(u&&u.parentNode===t)a=u.nextSibling;else{let f=i[i.length-1];f&&f.parentNode===t&&(a=f.nextSibling)}}a&&a.parentNode===t?t.insertBefore(c,a):t.appendChild(c),T({session:"",machine:"pos",nodeId:null,component:null,from:"hole",event:"INSERT",to:"real",payload:()=>({i:r,insertedBefore:a?J(a):"END",node:J(c)}),level:"trace",ts:Date.now()}),s.push(c),l(c)}function br(e){let{parent:t,oldC:n,newC:o,oldNode:r,out:i,pushA:s,ctx:l}=e;if(n&&typeof n=="object"&&!Array.isArray(n)&&typeof n.type=="function"){let c=jt(t,n,r,o,l);i.push(c),s(c);return}let d=Wt(t,n,r,o,l);i.push(d),s(d)}function Cr(e){let{parent:t,oldC:n,newC:o,oldNode:r,i,out:s,pushA:l,ctx:d}=e,c=d.browser??V(),a=$(o,d,c,String(i));if(a==null){s.push(null),l(null);return}let u=n&&typeof n=="object"?L(n,r):null;if(u&&u.length>1){let p=(u[u.length-1]??r)?.nextSibling??null;for(let m of u)m.parentNode&&m.parentNode.removeChild(m);if(n&&typeof n=="object"&&!Array.isArray(n))if(typeof n.type=="function")le(n,d.registry);else try{O(n,d.registry)}catch(m){console.error("[weifuwu] ref cleanup error",m)}p&&p.parentNode===t?t.insertBefore(a,p):t.appendChild(a)}else r?.parentNode?r.parentNode.replaceChild(a,r):t.appendChild(a);let f=a.nodeType===11?Array.from(a.childNodes):[a];s.push(...f),l(f[0]??a)}function xr(e){let{parent:t,oldC:n,newC:o,oldNode:r,out:i,pushA:s,ctx:l}=e,d=Dt(t,n,r,o,l);i.push(d),s(d)}function Vr(e){let{parent:t,oldC:n,newC:o,oldNode:r,i,oldNodes:s,out:l,pushA:d,ctx:c}=e,a=c.browser??V(),u=L(n,r);E("diff")&&S("diff","debug","",`multi-remove i=${i} range=${u?u.map(J).join(" | "):"null"}`);for(let m of u??[])m.parentNode?.removeChild(m);for(let m of A(n?.props?.children))m!=null&&typeof m=="object"&&!Array.isArray(m)&&typeof m.type=="function"&&le(m,c.registry);let f=$(o,c,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):t.appendChild(f),l.push(f),d(f)}function Er(e){let{parent:t,oldC:n,newC:o,oldNode:r,oldNodes:i,i:s,out:l,pushA:d,ctx:c}=e,a=L(n,r),u=Hn(t,n,o,c,a);l.push(...u),d(i[s]??u[0]??null)}function _r(e){let{parent:t,oldC:n,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 u=Bt(t,r,d,k(o.type));s.push(u),l(u);return}let c=te(t,r,n,o,d);E("diff")&&S("diff","trace","",`after-patch i=${i} new=${we(o)} node=${J(c)} dom=${ce(t)}`);let a=On(o,c);s.push(...a),l(a[0]??c??null)}function Dt(e,t,n,o,r){let i=pe(r.browser??V(),o),s=L(t,n),l=((s??[])[s?.length?s.length-1:0]??n)?.nextSibling??null;for(let d of s??[])d.parentNode?.removeChild(d);for(let d of A(t?.props?.children))d!=null&&typeof d=="object"&&!Array.isArray(d)&&typeof d.type=="function"&&le(d,r.registry);return i&&l&&l.parentNode===e?e.insertBefore(i,l):i&&e.appendChild(i),i}function jt(e,t,n,o,r){let i=pe(r.browser??V(),o),s=Oe(t,n,e,r);return i&&s?e.insertBefore(i,s):i&&e.appendChild(i),i}function Wt(e,t,n,o,r){let i=pe(r.browser??V(),o);if(t&&typeof t=="object"&&!Array.isArray(t))if(typeof t.type=="function")le(t,r.registry);else try{O(t,r.registry)}catch(s){console.error("[weifuwu] ref cleanup error",s)}return i&&n?.parentNode?n.parentNode.replaceChild(i,n):i&&e.appendChild(i),i}var Tr={hole:{hole:wr,real:$t,multi:$t},real:{hole:br,real:_r,multi:Cr},multi:{hole:xr,real:Vr,multi:Er}};function Sr(e){let{parent:t,oldChildren:n,newChildren:o,oldNodes:r,ctx:i,anchorOut:s}=e,l=Math.max(n.length,o.length),d=[],c=a=>{s&&s.push(a)};for(let a=0;a<l;a++){let u=a<n.length?n[a]:null,f=a<o.length?o[a]:null;if(a>=o.length){Nr({parent:t,oldC:u,newC:f,oldNode:r[a],i:a,oldNodes:r,newChildren:o,out:d,pushA:c,ctx:i});continue}if(u!=null&&typeof u=="object"&&!Array.isArray(u)&&f!=null&&typeof f=="object"&&!Array.isArray(f)&&f===u&&Se(u)){d.push(r[a]),c(r[a]);continue}let p=Tr[je(u)][je(f)];T({session:"",machine:"pos",nodeId:null,component:null,from:je(u),event:p.name,to:je(f),payload:()=>({i:a}),level:"trace",ts:Date.now()}),p({parent:t,oldC:u,newC:f,oldNode:r[a],i:a,oldNodes:r,newChildren:o,out:d,pushA:c,ctx:i})}return d}function Ut(e){let{parent:t,oldChildren:n,newChildren:o,oldNodes:r,ctx:i,anchorOut:s,arrEnd:l}=e,d=new Map;n.forEach((p,m)=>{let g=We(p);g!==null&&p&&typeof p=="object"&&!Array.isArray(p)&&d.set(g,{vnode:p,nodes:[r[m]??null].filter(Boolean),index:m})});let c=[],a=new Set,u=p=>{s&&s.push(p)},f=null;return o.forEach((p,m)=>{let g=We(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 j=Bt(t,y,i,k(h.type));c.push(j),u(j),j&&(f=j);return}let N=te(t,y,w.vnode,h,i),b=On(h,N),P=b[0]??N,I=b[b.length-1]??N;if(P&&P.parentNode===t&&f&&P.previousSibling!==f){E("diff")&&S("diff","debug","",`keyed-correct i=${m} k=${g} move=[${b.map(J).join(" | ")}] after=${J(f)} before=${ce(t)}`);let j=f.nextSibling;for(let C of b)C&&C.parentNode===t&&t.insertBefore(C,j);E("diff")&&S("diff","debug","",`keyed-correct after=${ce(t)}`)}c.push(...b),u(b[0]??N??null),I&&(f=I)}else{let w={current:f};Lr[Ir(p)]({parent:t,oldChildren:n,newChildren:o,oldNodes:r,ctx:i,out:c,pushA:u,arrEnd:l,c:p,i:m},w),f=w.current}}),n.forEach((p,m)=>{Pr[kr(We(p),a)](t,p,m,r,i,o.length)}),c}function kr(e,t){return e===null?"unkeyed":t.has(e)?"moved":"stale-keyed"}var Pr={moved:()=>{},"stale-keyed":Rr,unkeyed:Ar};function Rr(e,t,n,o,r){let i=t&&typeof t=="object"&&!Array.isArray(t)?L(t,o[n]):null;if(E("diff")&&S("diff","trace","",`keyed-delete i=${n} k=${We(t)} range=${i?.length??0} oldNode=${J(o[n])}`),t&&typeof t=="object"&&!Array.isArray(t))if(typeof t.type=="function")le(t,r.registry);else try{O(t,r.registry)}catch(s){console.error("[weifuwu] ref cleanup error",s)}Ft(i,o[n])}function Ar(e,t,n,o,r,i){let s=o[n];if(s?.nodeType===8&&s.nodeValue?.includes("type=hole")&&n<i)return;if(t&&typeof t=="object"&&!Array.isArray(t))if(typeof t.type=="function")le(t,r.registry);else try{O(t,r.registry)}catch(c){console.error("[weifuwu] ref cleanup error",c)}let d=t&&typeof t=="object"&&!Array.isArray(t)?L(t,s):null;Ft(d,s)}function Ft(e,t){if(e&&e.length>1)for(let n of e)n.parentNode&&n.parentNode.removeChild(n);else t?.parentNode&&t.parentNode.removeChild(t)}function Ir(e){return e==null||typeof e=="boolean"?"hole":e&&typeof e=="object"&&!Array.isArray(e)&&Y(e)?"portal":"real"}var Lr={hole:Mr,portal:Hr,real:Or};function Mr(e,t){let{parent:n,oldChildren:o,oldNodes:r,ctx:i,out:s,pushA:l,c:d,i:c}=e,a=o[c]??null,u=r[c]??null,f=je(a);if(f==="hole"){let m=pe(i.browser??V(),d);u?.nodeType===8?(m&&u.nodeValue!==m.nodeValue&&(u.nodeValue=m.nodeValue),s.push(u),l(u),u&&(t.current=u)):(m&&u?.parentNode?u.parentNode.replaceChild(m,u):m&&n.appendChild(m),s.push(m),l(m),m&&(t.current=m));return}let p=f==="multi"?Dt(n,a,u,d,i):a&&typeof a=="object"&&!Array.isArray(a)&&typeof a.type=="function"?jt(n,a,u,d,i):Wt(n,a,u,d,i);s.push(p),l(p),p&&(t.current=p)}function Hr(e,t){let{parent:n,oldChildren:o,oldNodes:r,ctx:i,out:s,pushA:l,c:d,i:c}=e,a=d,u=o[c]??null,f=te(n,r[c]??null,u,a,i),p=On(a,f);s.push(...p),l(p[0]??f??null);let m=p[p.length-1]??f;m&&(t.current=m)}function Or(e,t){let{parent:n,oldNodes:o,ctx:r,out:i,pushA:s,arrEnd:l,c:d,i:c}=e,u=$(d,r,r.browser??V());if(i.push(u),s(u??null),u!=null){let f=o[c];f&&f.nodeType===8&&f.nodeValue?.includes("type=hole")?(f.parentNode?.replaceChild(u,f),t.current=u):(t.current?n.insertBefore(u,t.current.nextSibling):l&&l.parentNode===n?n.insertBefore(u,l):n.insertBefore(u,n.firstChild),t.current=u)}}function cn(e){for(let t=0;t<e.length;t++){let n=e[t];n&&typeof n=="object"&&!Array.isArray(n)&&We(n)===null&&(n.key=`pos:${t}`)}}function Bt(e,t,n,o){se()?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=pe(n.browser??V(),null);if(r==null)return null;let i=t;if(i){let s=i.parentNode;s?s.replaceChild(r,i):e.appendChild(r)}else e.appendChild(r);return r}var $r={unkeyed:Sr,keyed:Ut,mixed:e=>(cn(e.newChildren),cn(e.oldChildren),Ut(e))};function Ur(e,t,n,o){T({session:o,machine:"render",nodeId:e?.nodeId??null,component:e?.component??null,from:e?.source??"external",event:"RENDER_REQUEST",to:n,payload:()=>({ids:t,source:e?.source??"external",detail:e?.detail??null,ts:Date.now()}),level:"info",ts:Date.now()})}function fn(e){let{registry:t,ctx:n}=e,o=new Map;function r(c,a){if(c==null||typeof c!="object")return!1;if(c===a)return!0;if(Array.isArray(c)){for(let f of c)if(r(f,a))return!0;return!1}let u=c;return!!(u._child!=null&&r(u._child,a)||typeof u.type=="string"&&u.props?.children!=null&&r(u.props.children,a))}async function i(c){let a=t.idRegistry.get(c);if(!a||!R(a)||typeof a._render!="function")return;let u=a,f=tn("render");try{if(u._lifecycle==="building"){s.add(c),T({session:f,machine:"render",nodeId:u._id??null,component:$n(u),from:"IDLE",event:"PARENT",to:"SKIP_BUILDING",payload:()=>({lifecycle:u._lifecycle}),level:"debug",ts:Date.now()});return}let p=n.ui?._rootVNodeId;if(p){let b=t.idRegistry.get(p);if(b&&!r(b,u)){t.idRegistry.delete(c),t.idRegistry.delete(`custom:${c}`),T({session:f,machine:"render",nodeId:c,component:$n(u),from:"IDLE",event:"PARENT",to:"SKIP_ORPHAN",payload:()=>({reason:"not in render tree (stale instance)"}),level:"warn",ts:Date.now()});return}}let m=await u._render(u.props),g=await q(m,n,u._child,t)??null,h=u._child;u._child=g;let w=u._id!=null&&u._id===n.ui?._rootVNodeId,y=u._parentNode??u._refNode?.parentNode??null;y==null&&w&&(y=e.rootEl??null);let N=y?w&&!u._parentNode?"ROOT":"MOUNTED":"SKIP_DETACHED";if(T({session:f,machine:"render",nodeId:u._id??null,component:$n(u),from:"IDLE",event:"PARENT",to:N,payload:()=>({lifecycle:u._lifecycle,rendered:u._outputChild!=null}),level:"debug",ts:Date.now()}),!y)return;if(y){let b={browser:n.browser??V(),registry:t,ctxVersion:sn(n)},P=te(y,u._refNode??null,h,g,b);if(u._refNode=P,se())try{let I=[];ke(y,g,j=>I.push(j)),I.length&&console.error("[vdom2/audit] "+I.join(" | "))}catch(I){console.error("[vdom2/audit] \u6821\u9A8C\u5F02\u5E38:",I)}}}catch(p){e.onError?e.onError(p):console.error("[vdom2] render error:",p?.stack??p)}finally{Me()}}let s=new Set;function l(){if(s.size===0)return Promise.resolve();let c=[...s];s.clear();let a=c.filter(u=>{let f=t.idRegistry.get(u);return f&&R(f)&&typeof f._render=="function"&&f._lifecycle!=="building"&&f._lifecycle!=="disposed"});if(a.length)return d(a,{source:"external",component:null,nodeId:null,detail:"pending-flush"});for(let u of c)s.add(u);return Promise.resolve()}function d(c,a){return c==null?Promise.resolve():(Ur(a??{source:"external",component:null,nodeId:null},c,"dispatch",""),Promise.all(c.map(u=>{let p=(o.get(u)??Promise.resolve()).then(()=>i(u));return o.set(u,p),p.finally(()=>{o.get(u)===p&&o.delete(u)})})).then(()=>l()))}return{render:d,flushPending:l}}function $n(e){return typeof e.type=="function"&&e.type.name?e.type.name:"anonymous"}function Kt(e){let{ctx:t,browser:n}=e,o=e.registry??fe(),r=e.renderer??fn({registry:o,ctx:t,rootEl:e.root,onError:e.onError}),i=t.ui,s=null,l=null,d={ctx:t,registry:o,renderer:r,async mount(c){s=c;let a=await q(c,t,null,o);e.root.innerHTML="";let u=$(a,t,n);if(u!=null&&e.root.appendChild(u),l=a?._child??a,i&&(i._rootVNodeId=a?._id??null),se())try{let f=[];ke(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 c=[];for(let[,a]of o.idRegistry)R(a)&&typeof a._render=="function"&&a._id&&c.push(a._id);await r.render(c)},unmount(){for(let[,c]of o.idRegistry)try{O(c,o)}catch{}e.root.innerHTML=""}};return d.close=()=>d.unmount(),d}function Dr(e,t,n,o){let r=n,i=r.__registry??fe(),s=r.browser??V();return Promise.resolve(q(t,r,null,i)).then(()=>{let l=$(t,r,s);if(l!=null&&e.appendChild(l),t._id&&i){let d=i.idRegistry.get(t._id);d&&(d._parentNode=e)}o?.onMounted?.()}).catch(l=>console.error("[vdom2] command mount error",l)),{id:t._id??""}}function jr(e,t,n){let o=n.__registry;if(o)for(let[,r]of o.idRegistry)try{O(r,o)}catch{}e.remove()}var qt=V();function Gt(e,t="bottom",n=6,o=!0){switch(t){case"bottom":return{top:e.bottom+n,left:o?e.left+e.width/2:e.left};case"top":return{top:e.top-n,left:o?e.left+e.width/2:e.left};case"left":return{top:o?e.top+e.height/2:e.top,left:e.left-n};case"right":return{top:o?e.top+e.height/2:e.top,left:e.right+n}}}function pn(e,t,n=8){if(!t)return e;let o=t.getBoundingClientRect();if(o.width===0&&o.height===0)return e;let r=Number.parseFloat(t.style.top)||o.top,i=Number.parseFloat(t.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},c=qt.viewportWidth(),a=qt.viewportHeight(),u=e.top,f=e.left;return d.bottom>a-n&&(u=Math.max(n,u-(d.bottom-(a-n)))),d.top<n&&(u=Math.max(n,u+(n-d.top))),d.right>c-n&&(f=Math.max(n,f-(d.right-(c-n)))),d.left<n&&(f=Math.max(n,f+(n-d.left))),{top:u,left:f,width:e.width}}var Ae=V();function zt(e){let t=new Map,n=new Map,o=!1,r=0;function i(){r||(r=requestAnimationFrame(()=>{r=0;let a=[];for(let[u,f]of t){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,pn(g,f.panel?.(),f.margin)),a.push(u)}for(let[u,f]of n){let p=f.getScroller(),m=p instanceof Window?Ae.scrollingElement()?.scrollTop??Ae.scrollTop():p.scrollTop??0;m!==f.handle.y&&(f.handle.y=m,a.push(u))}a.length>0&&e(a)}))}function s(){o||(o=!0,Ae.addEventListener("scroll",i,{capture:!0,passive:!0}),Ae.addEventListener("resize",i))}function l(){o&&(Ae.removeEventListener("scroll",i,{capture:!0}),Ae.removeEventListener("resize",i),o=!1)}function d(a){for(let u of[...t.keys()])(u.startsWith(`popup:${a}:`)||u===`popup:${a}`||u===a)&&t.delete(u);n.delete(a)}function c(){l(),r&&(cancelAnimationFrame(r),r=0),t.clear(),n.clear()}return{popupTrackers:t,scrollTrackers:n,schedulePopupRecompute:i,ensurePopupListeners:s,destroyPopupListeners:l,cleanupTrackers:d,destroy:c}}function Un(e,t,n){return r=>{r?t(r):n?.()}}function Fe(e){return typeof window<"u"&&!!window.matchMedia?.("(hover: hover)").matches}function mn(e){return typeof window<"u"&&!!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches}function Dn(e,t,n){let o=null,r=()=>{t(),n?.once&&o&&o.removeEventListener("animationend",r)};return s=>{s?(o=s,s.addEventListener("animationend",r)):o&&(o.removeEventListener("animationend",r),o=null)}}function jn(e,t){let{onLongPress:n,duration:o=500}=t,r,i=0,s=0,l=null,d=()=>{clearTimeout(r),r=void 0},c=e.selfId();if(c){let a=e.onUnmount(u=>{u===c&&(d(),a())})}return{onPointerDown:a=>{i=a.clientX??0,s=a.clientY??0,l=a,d(),r=setTimeout(()=>{r=void 0,l&&n(l)},o)},onPointerUp:d,onPointerLeave:d,onPointerMove:a=>{let u=Math.abs((a.clientX??0)-i),f=Math.abs((a.clientY??0)-s);(u>10||f>10)&&d()},onContextMenu:a=>{a.preventDefault(),n(a)}}}function Be(e,t){let n=e.selfId(),o="closed",r,i=()=>{o="closed",n?e.render([n]):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 Wn(e,t,n){let o=e.selfId(),r=mn(e),i=n?.duration??400,s=n?.ease==="linear"?f=>f:f=>1-Math.pow(1-f,3),l,d=t,c={value:r?t:0,reset:()=>{}},a=()=>{o?e.render([o]):e.render()},u=f=>{if(d=f,r){c.value=f,a();return}if(f===c.value)return;l&&cancelAnimationFrame(l);let p=c.value,m=performance.now(),g=h=>{let w=Math.min(1,(h-m)/i);c.value=Math.round(p+(f-p)*s(w)),w<1?(l=requestAnimationFrame(g),a()):(l=void 0,a())};l=requestAnimationFrame(g)};if(c.reset=f=>{f===d&&l||u(f)},o){let f=e.onUnmount(p=>{p===o&&(l&&(cancelAnimationFrame(l),l=void 0),f())})}return queueMicrotask(()=>u(t)),c}function Fn(e,t,n){let o=e.selfId(),r=e.browser,i=`media:${o}:${t}`;if(!e.mediaRegistry.has(i)){let s=r.matchMedia(t);n(s.matches);let l=c=>n(c.matches);s.addEventListener("change",l),e.mediaRegistry.set(i,{mql:s,handler:l});let d=e.onUnmount(c=>{if(c!==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 Bn(e,t,n){let o=e.browser,r=typeof t=="function"?{mobile:"(max-width: 639px)",tablet:"(min-width: 640px) and (max-width: 1023px)",desktop:"(min-width: 1024px)"}:t,i=typeof t=="function"?t:n,s=e.selfId(),l=`bp:${s}`;function d(){for(let[c,a]of Object.entries(r))if(o.matchMedia(a).matches)return c;return Object.keys(r)[0]??""}if(!e.mediaRegistry.has(l)){i(d());let c=[];for(let u of Object.values(r)){let f=o.matchMedia(u),p=()=>i(d());f.addEventListener("change",p),c.push({mql:f,handler:p})}e.mediaRegistry.set(l,{mqls:c});let a=e.onUnmount(u=>{if(u!==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 Kn(e){let t=e.selfId(),n=e.browser,o={height:n.viewportHeight(),offsetTop:0,keyboardOpen:!1},r=()=>{t?e.render([t]):e.render()},i=()=>{let l=n.visualViewport();o.height=l?.height??n.viewportHeight(),o.offsetTop=l?.offsetTop??0,o.keyboardOpen=o.height<n.viewportHeight()*.9,r()},s=n.visualViewport();if(s?.addEventListener?(s.addEventListener("resize",i),s.addEventListener("scroll",i)):n.addEventListener("resize",i),t){let l=e.onUnmount(d=>{d===t&&(s?.removeEventListener?(s.removeEventListener("resize",i),s.removeEventListener("scroll",i)):n.removeEventListener("resize",i),l())})}return o}function qn(e,t){let n=e.selfId(),o={isIn:!1,ready:!1,observe:d,refresh:c,disconnect:a},r=null,i=null,s=()=>{n?e.render([n]):e.render()};function l(){if(i?.disconnect(),i=null,!r)return;let u=typeof t.rootMargin=="function"?t.rootMargin():t.rootMargin,f=typeof t.threshold=="function"?t.threshold():t.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,t.onChange?.(m,g),(h||w)&&s()},{root:t.root?t.root():null,rootMargin:u??"0px",threshold:f??0}),i.observe(r)}function d(u){r=u,u?l():(i?.disconnect(),i=null,o.isIn=!1)}function c(){l()}function a(){i?.disconnect(),i=null}if(n){let u=e.onUnmount(f=>{f===n&&(a(),u())})}return o}function Gn(e,t){let n=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:t.getScroller??(()=>window)};if(!n)return r.refresh(),r;e.scrollTrackers.set(n,i),e.ensurePopupListeners(),r.refresh();let s=e.onUnmount(l=>{l===n&&(e.scrollTrackers.delete(n),s())});return r}function yn(e,t){let n=e.selfId(),o=t.value!==void 0;if(o&&!t.onChange&&t.name&&(e.warned.has(t.name)||(e.warned.add(t.name),console.warn(`[weifuwu/${t.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&&n&&!e.uncontrolledValues.has(n)){e.uncontrolledValues.set(n,t.value);let i=e.onUnmount(s=>{s===n&&(e.uncontrolledValues.delete(n),i())})}let r=i=>{if(o){t.onChange?.(i);return}n&&e.uncontrolledValues.set(n,i),n?e.render([n]):e.render()};return{value:o?t.value:n?e.uncontrolledValues.get(n):t.value,setValue:r,controlled:o}}function zn(e,t){let n=e.selfId(),o=yn(e,{value:t.value,onChange:t.onChange,name:t.name});if(n&&!e.inputStates.has(n)){e.inputStates.set(n,{keyword:"",selectedLabel:""});let s=e.onUnmount(l=>{l===n&&(e.inputStates.delete(n),s())})}let r=n?e.inputStates.get(n):{keyword:"",selectedLabel:""},i=()=>{n?e.render([n]):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 Yn(e,t){let n=e.selfId(),o=!1;if(n){let d=e.onUnmount(c=>{c===n&&(o=!0,d())})}let r=()=>{o||(n?e.render([n]):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(()=>t()).then(c=>{s===d&&(i.data=c,i.loading=!1,r())}).catch(c=>{s===d&&(i.error=c,i.loading=!1,r())})};return l(),i.reload=l,i}function Xn(e,t){let n=e.selfId(),o=e.browser;if(typeof window>"u")return()=>{};if(o.addEventListener("keydown",t),n){let r=e.onUnmount(i=>{i===n&&(o.removeEventListener("keydown",t),r())})}return()=>o.removeEventListener("keydown",t)}function Jn(e,t){let n=e.browser,o=0,r=0,i=!1,s=a=>{i&&t.onMove(a,{x:a.clientX-o,y:a.clientY-r})},l=a=>{i&&(i=!1,n.removeEventListener("pointermove",s),n.removeEventListener("pointerup",l),t.onEnd?.(a))},d=a=>{i||(a.preventDefault(),i=!0,o=a.clientX,r=a.clientY,n.addEventListener("pointermove",s),n.addEventListener("pointerup",l),t.onStart?.(a))},c=e.selfId();if(c){let a=e.onUnmount(u=>{u===c&&(i&&(n.removeEventListener("pointermove",s),n.removeEventListener("pointerup",l),i=!1),a())})}return{onPointerDown:d}}function Qn(e,t){let n={};t.onDrop&&(n.onDrop=r=>{r.preventDefault(),t.onDrop(r)}),t.onDragOver&&(n.onDragOver=r=>{r.preventDefault(),t.onDragOver(r)}),t.onDragLeave&&(n.onDragLeave=r=>t.onDragLeave(r));let o={draggable:!0};if(t.onDragStart){let r=t.onDragStart;o.onDragStart=i=>{typeof document<"u"&&document.body.classList.add("wf-dragging"),r(i)}}if(t.onDragEnd){let r=t.onDragEnd;o.onDragEnd=i=>{typeof document<"u"&&document.body.classList.remove("wf-dragging"),r(i)}}return{dropProps:n,dragProps:o}}function hn(e,t){let n=e.selfId(),o={top:0,left:0,refresh:()=>{}};if(!n)return o;let r={pos:o,getEl:t.el,isOpen:t.isOpen,compute:t.compute,panel:t.panel,margin:t.margin??8};e.popupTrackers.set(n,r),e.ensurePopupListeners();let i=e.onUnmount(s=>{s===n&&(e.popupTrackers.delete(n),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,pn(d,r.panel?.(),r.margin))},o}function Zn(e,t){let n=e.selfId(),o=e.browser,r=Fe(e),i=()=>typeof t.trigger=="function"?t.trigger():t.trigger??"manual",s=t.open!==void 0,l=()=>!!t.disabled?.(),d=()=>s?typeof t.open=="function"?!!t.open():!!t.open:t.isOpen(),c=t.presence?Be(e,{name:t.name}):null,a,u=!1,f=v=>{if(!c)return v?"open":"closed";let x=c.sync(v);return v&&t.lockScroll&&!u&&(Wr(),u=!0),x},p=v=>{l()||(s?t.onOpenChange?.(v):c?v?f(!0):d()&&f(!1):t.setOpen(v))},m=()=>{let v=t.placement;return typeof v=="function"?v():v??"bottom"},g=null,h=!1,w=hn(e,{el:t.el??(()=>null),isOpen:()=>d(),compute:v=>{if(t.position){let x=t.position();return{top:x.y,left:x.x,width:x.width}}return Gt(v,m(),t.gap??6,t.center!==!1)},panel:()=>g,margin:t.margin??8}),y=v=>{if(t.closeOnOutside===!1||t.mask||!d())return;let x=v.target;if(!(x instanceof Node))return;let B=t.el?.()??null;B&&B.contains(x)||g&&g.contains(x)||p(!1)},N=v=>{t.closeOnEscape!==!1&&(v.key!=="Escape"||!d()||p(!1))};if(o.addEventListener("mousedown",y),o.addEventListener("keydown",N),n){let v=e.onUnmount(x=>{x===n&&(o.removeEventListener("mousedown",y),o.removeEventListener("keydown",N),v())})}let b={},P=v=>typeof v=="function"?v():v??0,I=()=>P(t.openDelay),j=()=>P(t.closeDelay),C,_,U=()=>{clearTimeout(C),clearTimeout(_),C=void 0,_=void 0},W=v=>{if(l())return;let x=v.currentTarget,B=v.relatedTarget;x.contains(B)||(clearTimeout(_),_=void 0,C=setTimeout(()=>{C=void 0,p(!0)},I()))},M=v=>{if(l())return;let x=v.currentTarget,B=v.relatedTarget;x.contains(B)||(clearTimeout(C),C=void 0,_=setTimeout(()=>{_=void 0,p(!1)},j()))},F=()=>{l()||(clearTimeout(_),_=void 0,C=setTimeout(()=>{C=void 0,p(!0)},I()))},G=()=>{l()||(clearTimeout(C),C=void 0,_=setTimeout(()=>{_=void 0,p(!1)},j()))},ae=()=>i()==="hover";if(b.onMouseOver=v=>{ae()&&W(v)},b.onMouseOut=v=>{ae()&&M(v)},b.onClick=()=>{ae()?r||p(!d()):i()==="click"&&p(!0)},b.onFocus=()=>{ae()?F():i()==="focus"&&(clearTimeout(_),_=void 0,p(!0))},b.onBlur=()=>{ae()?G():i()==="focus"&&(clearTimeout(C),C=void 0,_=setTimeout(()=>{_=void 0,p(!1)},j()))},i()==="longpress"){let v,x=0,B=0,ge=()=>{clearTimeout(v),v=void 0};b.onPointerDown=H=>{l()||(x=H.clientX??0,B=H.clientY??0,ge(),v=setTimeout(()=>{v=void 0,t.onTrigger?.({clientX:x,clientY:B}),p(!0)},t.longPressDuration??500))},b.onPointerUp=ge,b.onPointerLeave=ge,b.onPointerMove=H=>{let Nn=Math.abs((H.clientX??0)-x),wn=Math.abs((H.clientY??0)-B);(Nn>10||wn>10)&&ge()},b.onContextMenu=H=>{H.preventDefault(),t.onTrigger?.({clientX:H.clientX??0,clientY:H.clientY??0}),p(!0)}}if(b.onKeyDown=v=>{v.key==="Escape"&&t.closeOnEscape!==!1&&p(!1)},n){let v=e.onUnmount(x=>{x===n&&(U(),v())})}let Ie=v=>{if(v){g=v;let x=()=>w.refresh();v.addEventListener("animationend",x,{once:!0})}else g=null},de=null,xe=null,he=v=>{Ie(v),xe&&xe(v),c?.ref(v),t.trapFocus&&(v?a=Kr(v):(a?.(),a=void 0)),t.lockScroll&&!v&&u&&(Fr(),u=!1)};return{get open(){return d()},setOpen:p,get phase(){return c?c.phase:d()?"open":"closed"},sync:f,wrapProps:b,portal:(v,x="popover")=>{if(l())return null;if(!(c?c.phase!=="closed":d()))return h=!1,de=null,null;let ge=t.el?.()??null;(!h||ge!==de)&&(ge?w.refresh():queueMicrotask(()=>{d()&&w.refresh()}),h=!0,de=ge);let H=v.props??{};xe=H.ref??null;let Nn=t.positioning==="none"?H.class??"":["wf-popup",H.class].filter(Boolean).join(" "),wn=t.positioning==="none"?{...H.style??{},position:"fixed"}:{...H.style??{},position:"fixed",top:`${w.top}px`,left:`${w.left}px`,...w.width!==void 0?{width:`${w.width}px`}:{},maxWidth:(()=>{let Ye=typeof t.width=="function"?t.width():t.width;return Ye!==void 0?`min(${Ye}px, calc(100vw - 32px))`:"calc(100vw - 32px)"})()},Ve={...v,props:{...H,class:Nn,style:wn,ref:he}};if(t.mask){let Ye=typeof t.mask=="object"?t.mask:ve("div",{class:"wf-popup-mask","data-portal-mask":x,onClick:t.maskClosable===!1?void 0:()=>p(!1)}),so=t.maskCentered?ve("div",{class:"wf-cover",style:{"--wf-z":"var(--wf-z-popover)",pointerEvents:"none"}},{...Ve,props:{...Ve.props,style:{...H.style??{},pointerEvents:"auto"},ref:he}}):null,lo=t.maskCentered?void 0:{...Ve.props?.style??{},zIndex:"var(--wf-z-popover)"},ao=t.maskCentered?so:{...Ve,props:{...Ve.props,style:lo}};return Qe([Ye,ao],x)}return Qe(Ve,x)},refresh:()=>w.refresh()}}function et(e,t){let n=e.selfId();if(n&&!e.openStates.has(n)){e.openStates.set(n,!1);let l=e.onUnmount(d=>{d===n&&(e.openStates.delete(n),l())})}let o=t.open!==void 0;o&&!t.onOpenChange&&t.name&&!e.warned.has(t.name)&&(e.warned.add(t.name),console.warn(`[weifuwu/${t.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?!!t.open:n?e.openStates.get(n)??!1:!1,i=()=>{n?e.render([n]):e.render()},s=l=>{if(o){t.onOpenChange?.(l);return}n&&e.openStates.set(n,l),i()};return{get open(){return r()},setOpen:s,triggerProps:{onClick:()=>s(!0),onFocus:()=>{t.openOnFocus&&s(!0)}}}}var Ce=V(),Ke=0,Yt="",Xt="",Jt="",Qt="",gn=0;function Zt(){return typeof window<"u"&&typeof document<"u"}function Wr(){if(Ke++,Ke>1||!Zt())return;gn=Ce.scrollTop();let e=Ce.bodyElement();Yt=e.style.overflow,Xt=e.style.position,Jt=e.style.top,Qt=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=`-${gn}px`,e.style.width="100%")}function Fr(){if(Ke===0||(Ke--,Ke>0)||!Zt())return;let e=Ce.bodyElement();e.style.overflow=Yt,e.style.position=Xt,e.style.top=Jt,e.style.width=Qt,gn>0&&Ce.scrollTo(gn)}var Br='a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function Kr(e){let t;return queueMicrotask(()=>{let n=e.querySelectorAll(Br);if(n.length===0)return;let o=n[0],r=n[n.length-1],i=l=>{l.key==="Tab"&&(l.shiftKey&&Ce.activeElement()===o?(l.preventDefault(),r.focus()):!l.shiftKey&&Ce.activeElement()===r&&(l.preventDefault(),o.focus()))},s=Ce.activeElement();o.focus(),e.addEventListener("keydown",i),t=()=>{e.removeEventListener("keydown",i),s?.focus()}}),()=>t?.()}function qr(e){return e.map(t=>{let n={role:t.role,content:t.content};return t.reasoning&&(n.reasoning_content=t.reasoning),n})}function nt(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`msg-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function eo(e,t,n,o){n.initialMessages?e.messages=structuredClone(n.initialMessages):e.messages===void 0&&(e.messages=[]),e.input===void 0&&(e.input=""),e.streaming===void 0&&(e.streaming=!1),e.error===void 0&&(e.error=null),e.usage===void 0&&(e.usage=null),e.step===void 0&&(e.step=null);let 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,N=w?.toolCalls?.find(b=>b.call.id===y.toolCallId);N&&(N.progress=y);break}case"wf:tool_result":{let y=g,N=w?.toolCalls?.find(b=>b.call.id===y.id);N&&(N.result=y,N.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=n.body?n.body(e.messages):{messages:qr(e.messages)};r=t(n.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,n.onEvent)},{signal:n.signal,headers:n.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:nt(),role:"user",content:m,status:"done"},{id:nt(),role:"assistant",content:"",status:"streaming",toolCalls:[]}),l(),o?.())}function c(){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:nt(),role:"assistant",content:"",status:"streaming",toolCalls:[]}),l(),o?.())}function u(){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?.(),!!n.approveUrl))try{await fetch(n.approveUrl,{method:"POST",headers:{"Content-Type":"application/json",...n.headers},body:JSON.stringify(h?{id:y.id,decision:m,note:g,modifiedArgs:h}:{id:y.id,decision:m,note:g}),signal:n.signal})}catch(N){if(n.signal?.aborted)return;e.error={code:"provider_error",message:N instanceof Error?N.message:String(N)},o?.()}}function p(){r?.abort(),r=null}return{send:d,stop:c,retry:a,clear:u,approve:f,dispose:p}}function no(e,t,n){let o=new AbortController,r=n?.signal;r&&(r.aborted?o.abort():r.addEventListener("abort",()=>o.abort(),{once:!0}));let i=n?.traceId??Jr(),s=n?.record!==!1,l=[],d=(async()=>{let c;try{c=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json","X-Trace-Id":i,Accept:"text/event-stream",...n?.headers},body:JSON.stringify(t),signal:o.signal})}catch(a){if(o.signal.aborted)return;n?.onError?.({code:"provider_error",message:a instanceof Error?a.message:String(a)});return}if(!c.ok){n?.onError?.({code:Xr(c.status),message:`HTTP ${c.status} ${c.statusText}`});return}try{for await(let{name:a,data:u}of zr(c.body)){if(o.signal.aborted)return;Yr(l,{name:a,data:u},s),Gr(a,u,n??{})}}catch(a){if(o.signal.aborted)return;n?.onError?.({code:"provider_error",message:a instanceof Error?a.message:String(a)})}})();return{abort:()=>o.abort(),done:d,traceId:i,events:l}}function Gr(e,t,n){switch(e){case"wf:token":return n.onToken?.(t.text);case"wf:tool_call":return n.onToolCall?.(t);case"wf:tool_result":return n.onToolResult?.(t);case"wf:tool_progress":return n.onToolProgress?.(t);case"wf:step":return n.onStep?.(t);case"wf:approval_request":return n.onApproval?.(t);case"wf:usage":return n.onUsage?.(t);case"wf:done":return n.onDone?.(t);case"wf:error":return n.onError?.(t);default:return n.onEvent?.(e,t)}}async function*zr(e){let t=e.getReader(),n=new TextDecoder,o="";try{for(;;){let{done:r,value:i}=await t.read();if(r)break;o+=n.decode(i,{stream:!0});let s=o.split(`
|
|
6
6
|
|
|
7
|
-
`);o=s.pop()??"";for(let l of s){let d="message",
|
|
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=Gt(t,zt,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=jt(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 Ut({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:Yt,frag:Yt,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 Yt(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 Jt(){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(
|
|
7
|
+
`);o=s.pop()??"";for(let l of s){let d="message",c="";for(let a of l.split(`
|
|
8
|
+
`))a.startsWith("event: ")?d=a.slice(7):a.startsWith("data: ")&&(c+=a.slice(6));if(c)try{yield{name:d,data:JSON.parse(c)}}catch{}}}}finally{t.releaseLock()}}function Yr(e,t,n){n&&(e.length>=1e3&&e.shift(),e.push(t))}function Xr(e){return e===401||e===403?"auth_failed":e===429?"rate_limited":e>=500?"provider_error":"invalid_request"}function Jr(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`trace-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function tt(e,t){let n={messages:[],input:"",streaming:!1,error:null,usage:null,step:null},o=new Set,i=eo(n,no,t,()=>{for(let l of[...o])l()});Object.assign(n,i),n.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 n}function ot(e,t){let n=e.selfId(),o;return n&&(o=t.subscribe(()=>e.render([n])),e.onUnmount(()=>o?.())),t}function vn(e){let t=e.registry??fe(),n={_selfId:"_wf_root",_mounting:!1,_ctxVersion:0,_rootVNodeId:null},o={browser:e.browser,__registry:t};o.app={navigate:y=>e.browser.navigate(y)};let r=e.renderer??fn({registry:t,ctx:o,rootEl:e.root,onError:e.onError}),i=zt(y=>{for(let N of y)r.render([N],{source:"external",component:null,nodeId:null,detail:"popup-tracker"})}),s=new Map,{popupTrackers:l,scrollTrackers:d,ensurePopupListeners:c,destroyPopupListeners:a,cleanupTrackers:u}=i;ln(t,y=>{u(y),l.has(y)&&l.delete(y)});let f=new Set,p=new Map,m=new Map,g=new Map,h=y=>({selfId:()=>{let N=y?._selfVNode?._id??y?._selfId;return typeof N=="string"?N:void 0},render:N=>{let b=y?._selfVNode;return r.render(N,{source:"component",component:b&&typeof b.type=="function"?b.type.name||"anonymous":null,nodeId:b?._id??null,detail:"hook"})},browser:e.browser,onUnmount:N=>ln(t,N),registry:t,mediaRegistry:s,popupTrackers:l,scrollTrackers:d,isMounting:()=>n._mounting===!0,warned:f,uncontrolledValues:p,inputStates:m,openStates:g,ensurePopupListeners:c}),w=!1;return n.render=function(y,N){let b=N??(this?._selfVNode?{source:"component",component:this._selfVNode&&typeof this._selfVNode.type=="function"?this._selfVNode.type.name||"anonymous":null,nodeId:this._selfVNode?._id??null}:{source:"root",component:null,nodeId:null});if(y==null){let P=this._selfId!=="_wf_root"&&this._selfId?this._selfId:n._rootVNodeId;return P?r.render([P],b):(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,b)},n.setMounting=y=>{n._mounting=y},n.endMounting=()=>{n._mounting=!1},n.bumpCtxVersion=()=>{n._ctxVersion=(n._ctxVersion??0)+1},n.selfId=function(y){if(typeof y!="string"||!y)throw new Error(`[weifuwu] selfId requires a non-empty string, got ${typeof y}`);if(t.idRegistry.has(y))throw new Error(`[weifuwu] Duplicate component ID: "${y}". Each component must have a unique custom ID.`);let N=this._selfVNode;N&&(N._customId=y,t.idRegistry.set(y,N))},n.onUnmount=function(y){let N=this?._selfVNode?._id??this?._selfId;if(N)return ln(t,b=>{b===N&&y()})},n.useChat=function(y){return tt(h(this),y)},n.useMedia=function(y,N){return Fn(h(this),y,N)},n.useBreakpoint=function(y,N){return Bn(h(this),y,N)},n.usePopupPosition=function(y){return hn(h(this),y)},n.useHoverCapable=function(){return Fe(h(this))},n.useStableRef=function(y,N){return Un(h(this),y,N)},n.useVisualViewport=function(){return Kn(h(this))},n.usePopup=function(y){return Zn(h(this),y)},n.useLongPress=function(y){return jn(h(this),y)},n.useInView=function(y){return qn(h(this),y)},n.useScrollPosition=function(y){return Gn(h(this),y)},n.useAsync=function(y){return Yn(h(this),y)},n.useControlled=function(y){return yn(h(this),y)},n.useControlledInput=function(y){return zn(h(this),y)},n.useOpen=function(y){return et(h(this),y)},n.usePresence=function(y){return Be(h(this),y)},n.useGlobalKey=function(y){return Xn(h(this),y)},n.useDrag=function(y){return Jn(h(this),y)},n.useDragDrop=function(y){return Qn(h(this),y)},n.useExternal=function(y){return ot(h(this),y)},n.useReducedMotion=function(){return mn(h(this))},n.useAnimationEnd=function(y,N){return Dn(h(this),y,N)},n.useTween=function(y,N){return Wn(h(this),y,N)},n.destroyPopupListeners=a,o.ui=n,{ctx:o,registry:t,renderer:r,rootUi:n,destroyPopupListeners:a}}function Qr(e){let{ctx:t,registry:n,renderer:o}=vn(e);return Kt({root:e.root,browser:e.browser,ctx:t,registry:n,renderer:o,onError:e.onError})}var Zr=new Set(["svg","path","circle","rect","line","polyline","polygon","g","text","defs","use","clipPath"]);function qe(e){e.node=e.node?e.node.nextSibling:null}function ei(e,t){e.node&&e.node.parentNode?e.node.parentNode.insertBefore(t,e.node):e.parent.appendChild(t)}function ni(e,t){e.node&&e.node.parentNode?(e.node.parentNode.replaceChild(t,e.node),qe(e)):e.parent.appendChild(t)}function ti(e,t){for(let[n,o]of Object.entries(t))n==="children"||n==="key"||n==="innerHTML"||ie(e,n,o)}function Ge(e,t,n){return oi[D(e)](e,t,n)}var oi={hole:()=>null,text:ri,arr:ii,portal:to,frag:to,comp:si,native:li};function ri(e,t,n){let o=t.browser??V(),r=String(e);if(n.node&&n.node.nodeType===3)return n.node.textContent!==r&&(n.node.textContent=r),qe(n),n.node;let i=o.createTextNode(r);return ei(n,i),i}function ii(e,t,n){let o=null;for(let r of e){let i=Ge(r,t,n);i!=null&&!o&&(o=i)}return o}function to(e,t,n){let r=e.props?.children,i=r==null?[]:Array.isArray(r)?r:[r],s=null;for(let l of i){let d=Ge(l,t,n);d!=null&&!s&&(s=d)}return s}function si(e,t,n){let o=e,r=o._child;if(r==null){if(typeof o._render!="function")throw new Error(`[vdom2] component ${k(o.type)} not built before hydration`);for(o._child=null;n.node&&n.node.nodeType===8&&n.node.nodeValue?.startsWith("wf-hole:");)qe(n);return null}let i=Ge(r,t,n);return o._refNode||(o._refNode=i),i}function li(e,t,n){let o=t.browser??V(),r=e,i=r.type,s=r.props??{};for(;n.node&&n.node.nodeType===8&&n.node.nodeValue?.startsWith("wf-hole:");)qe(n);let l;if(n.node&&n.node.nodeType===1&&n.node.tagName.toLowerCase()===i.toLowerCase()?(l=n.node,qe(n)):(l=Zr.has(i)?o.createElementNS("http://www.w3.org/2000/svg",i):o.createElement(i),ni(n,l)),r.el=l,ti(l,s),!("innerHTML"in s)){let d={parent:l,node:l.firstChild},c=(Array.isArray(s.children)?s.children:[s.children]).flat(1/0);for(let a of c){let u=Ge(a,t,d);if(u!=null&&u.parentNode!==l&&l.appendChild(u),a&&typeof a=="object"&&!Array.isArray(a)&&R(a)){let f=a;f._parentNode||(f._parentNode=l,f._refNode=u)}}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 rt(e,t,n){let o=n.__registry;await q(t,n,null,o);let r={parent:e,node:e.firstChild};for(Ge(t,n,r);r.node;){let i=r.node;r.node=i.nextSibling,i.parentNode?.removeChild(i)}}var ai={idle:{NAVIGATE_START:"navigating"},navigating:{NAVIGATE_DONE:"settled",NAVIGATE_ERROR:"idle"},settled:{NAVIGATE_START:"navigating"}};function oo(){let e="idle",t=(n,o)=>{let r=ai[e]?.[n]??null;return r==null?(T({session:"",machine:"route",nodeId:null,component:null,from:e,event:n,to:"?",payload:{path:o},level:"debug",ts:Date.now()}),e):(T({session:"",machine:"route",nodeId:null,component:null,from:e,event:n,to:r,payload:{path:o},level:"debug",ts:Date.now()}),e=r,r)};return{get state(){return e},navigateStart:n=>{t("NAVIGATE_START",n)},navigateDone:n=>{t("NAVIGATE_DONE",n)},navigateError:(n,o)=>{t("NAVIGATE_ERROR",n)}}}function Q(e,t=40){if(!e)return"null";if(e.nodeType===1){let n=e,o=[n.tagName.toLowerCase()];n.id&&o.push("#"+n.id);let r=String(n.className||"").split(" ").filter(Boolean).slice(0,2);r.length&&o.push("."+r.join("."));let i=n.getAttribute?.("data-wf-key");i&&o.push(`@${i}`);let s=n.getAttribute?.("data-wf-id");return s&&o.push(`(${s})`),o.join("").slice(0,t)}return e.nodeType===8?`<!--${(e.nodeValue??"").slice(0,20)}-->`:e.nodeType===3?`"${(e.textContent??"").slice(0,12)}"`:`#${e.nodeType}`}function st(){return!!globalThis?.__WF_DOM_TRACE}var it=!1;function ro(){if(it)return()=>{};it=!0;let e=[{proto:Node.prototype,name:"appendChild",describe:(n,o)=>({parent:Q(n),target:Q(o)})},{proto:Node.prototype,name:"insertBefore",describe:(n,o,r)=>({parent:Q(n),target:Q(o),ref:Q(r)})},{proto:Node.prototype,name:"removeChild",describe:(n,o)=>({parent:Q(n),target:Q(o)})},{proto:Node.prototype,name:"replaceChild",describe:(n,o,r)=>({parent:Q(n),target:Q(o),ref:"replace "+Q(r)})},{proto:Element.prototype,name:"setAttribute",describe:(n,o,r)=>({parent:Q(n),target:o,ref:`=${String(r).slice(0,30)}`})},{proto:Element.prototype,name:"removeAttribute",describe:(n,o)=>({parent:Q(n),target:o})}],t=new Map;for(let n of e){let o=n.proto[n.name];typeof o=="function"&&(t.set(n.name,o),n.proto[n.name]=function(...r){if(st())try{let i=n.describe(this,...r);T({session:He(),machine:"dom",nodeId:null,component:null,from:n.name,event:"WRITE",to:"",payload:()=>({...i,ts:Date.now()}),level:"trace",ts:Date.now()})}catch{}return o.apply(this,r)})}return()=>{it=!1;for(let[n,o]of t){let r=n.startsWith("set")||n.startsWith("remove")?Element.prototype:Node.prototype;r[n]=o}t.clear()}}function di(e,t){let n=V(),o=typeof t.root=="string"?n.query(t.root):t.root;if(!o)throw new Error(`uiServe: root not found: ${t.root}`);let r=o,i=!!t.hydrate;!i&&!t.loading&&(r.innerHTML="");try{if(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"),globalThis.__WF_DOM_TRACE=!0;try{let U=e.dumpRoutes?.()??[];console.log(`[weifuwu] routes (${U.length}):`);for(let W of U)console.log(`[weifuwu] ${W.path}${W.title?" \u2014 "+W.title:""}`)}catch{}}Tn()}catch{}try{st()&&ro()}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 U=(M,F)=>{let G=typeof document<"u"?document.styleSheets?.length??0:-1,ae=F?.tagName?`<${F.tagName}${F.id?"#"+F.id:""}${F.className?"."+String(F.className).split(" ")[0]:""}>`:"",Ie=(new Error().stack||"").split(`
|
|
9
|
+
`).slice(2,5).map(de=>de.trim().split("/").pop()?.slice(0,80)).join(" \u2190 ");console.log(`[wf-reflow] ${M}${ae} styles=${G}${G===0?" \u26A0\uFE0F\u6837\u5F0F\u672A\u52A0\u8F7D\uFF08\u5F3A\u5236\u6392\u7248\u573A\u666F\uFF09":""} :: ${Ie}`)},W=Element.prototype.getBoundingClientRect;Element.prototype.getBoundingClientRect=function(...M){return U("rect",this),W.apply(this,M)};for(let M of["offsetWidth","offsetHeight","offsetTop","offsetLeft","clientWidth","clientHeight","scrollTop","scrollHeight"]){let F=Object.getOwnPropertyDescriptor(Element.prototype,M);if(F?.get){let G=F.get;Object.defineProperty(Element.prototype,M,{configurable:!0,enumerable:!0,get(){return U(M,this),G.call(this)}})}}}}catch{}let{ctx:s,registry:l,renderer:d,rootUi:c,destroyPopupListeners:a}=vn({browser:n,root:r}),u=new Map,f=globalThis.__DATA__??window.__DATA__;if(f&&typeof f=="object")for(let[C,_]of Object.entries(f))u.set(C,{value:_});s.data={async get(C,_){let U=u.get(C);if(U&&"value"in U)return U.value;if(U?.promise)return U.promise;if(!_)return;let W=Promise.resolve().then(()=>_()).then(M=>(u.set(C,{value:M}),M));return u.set(C,{promise:W}),W},set(C,_){u.set(C,{value:_})},has(C){return u.has(C)}},s.route={params:{},query:{},path:""};let p=null,m="",g=0,h={},w,y=new Promise(C=>{w=C}),N=!1,b=oo();async function P(C,_){let U=++g,W=C.indexOf("?"),M=W>=0?C.slice(0,W):C,F=W>=0?C.slice(W):"",G={};if(F)for(let[v,x]of new URLSearchParams(F))G[v]=x;JSON.stringify(G)!==JSON.stringify(h)&&(s.ui.bumpCtxVersion?.(),h=G);let ae={pathname:M,search:F,query:G};s.route={params:{},query:G,path:M},b.navigateStart(M);let Ie=tn(_?"initial":"nav"),de;try{de=await e.execute(ae,s,M)}catch(v){b.navigateError(C,v),de=ve("div",{class:"ui-dom-error"},`\u9875\u9762\u6E32\u67D3\u5931\u8D25: ${v?.message??String(v)}`)}if(N||U!==g){Me();return}T({session:Ie,machine:"render",nodeId:null,component:null,from:"uiServe",event:"RENDER_REQUEST",to:_?"initial":"nav",payload:()=>({source:"uiServe",detail:_?"initial":"nav",path:C,ts:Date.now()}),level:"info",ts:Date.now()});let xe=E("mount"),he=xe?xt("nav"):"";xe&&S("mount","info",he,`route path=${C} initial=${_}`);let ue;try{ue=await q(de,s,p,l)}catch(v){ue=ve("div",{class:"ui-dom-error"},`\u7EC4\u4EF6\u6E32\u67D3\u5931\u8D25: ${v?.message??String(v)}`)}if(!(N||U!==g)){if(_)if(i)await rt(r,ue,s),E("mount")&&S("mount","debug",he,`hydrate done=${r.childNodes.length}`);else{r.innerHTML="";let v=$(ue,s,n);E("mount")&&S("mount","debug",he,`first-render node=${v?.nodeName??"null"} fragKids=${v?.nodeType===11?Array.from(v.childNodes).length:"-"}`),v!=null&&r.appendChild(v),E("mount")&&S("mount","debug",he,`root-fill done=${r.childNodes.length} first=${r.firstChild?.nodeName}`)}else if(p!==void 0){let v=p;p=ue;let x=v,B=Je(x)?x.el??x._refNode:x._refNode;te(r,B,v,ue,{browser:n,registry:l,ctxVersion:s?.ui?._ctxVersion??0})}p=ue,m=C,c._rootVNodeId=ue?._id,b.navigateDone(C),d.flushPending(),Me()}}let I=n.pathname();P(I,!0).finally(()=>{N||w()}),Et(()=>p),ht(),Rt();let j=()=>{let C=typeof window<"u"?window.location.pathname+window.location.search:n.pathname();P(C,!1)};return n.addEventListener("popstate",j),{close(){N=!0,n.removeEventListener("popstate",j),a(),l.idRegistry.clear()},ready:y,ctx:s}}function ze(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function ui(e){return typeof e=="string"?e:Array.isArray(e)?e.filter(Boolean).join(" "):e&&typeof e=="object"?Object.entries(e).filter(([,t])=>t).map(([t])=>t).join(" "):""}function ci(e){return Object.entries(e).filter(([,t])=>t!=null&&t!==!1).map(([t,n])=>`${t}:${typeof n=="number"?n:String(n)}`).join(";")}var fi=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),pi=new Set(["svg","path","circle","rect","line","polyline","polygon","g","text","defs","use","clipPath"]);async function ye(e,t){return xi[D(e)](e,t)}async function mi(e,t){return""}async function yi(e,t){return ze(String(e))}function gi(e){return e==null||typeof e=="boolean"?"hole":Array.isArray(e)?"arr":"vnode"}var hi={hole:e=>Promise.resolve(`<!--${K({type:"hole",value:e,key:null,id:null,fid:null})}-->`),arr:async(e,t,n,o)=>{let r=await ye(e,{...t,_fidPath:o});return`<!--${K({type:"fragment-start",key:String(n),id:null,fid:o})}-->${r}<!--${K({type:"fragment-end",key:String(n),id:null,fid:o})}-->`},vnode:async(e,t)=>{let n=await ye(e,t);return n===""?`<!--${K({type:"hole",value:null,key:null,id:null,fid:null})}-->`:n}};async function vi(e,t){let n=e;kt(n);let o=t._fidPath;return(await Promise.all(n.map(async(i,s)=>{let l=o!=null?`${o}-${s}`:String(s);return hi[gi(i)](i,t,s,l)}))).join("")}async function Ni(e,t){let n=e,o=t._fidPath??null,r=await ye(n.props?.children,{...t,_fidPath:o??void 0});return`<!--${K({type:"fragment-start",key:null,id:null,fid:o})}-->${r}<!--${K({type:"fragment-end",key:null,id:null,fid:o})}-->`}async function wi(e,t){return ye(e.props?.children,t)}async function bi(e,t){let n=e,o=Object.create(t);delete o._fidPath;let r=await n.type(n.props??{},o);if(typeof r!="function")throw new Error(`Component ${k(n.type)} must return a render function. Use (init_props, ctx) => (props) => VNode pattern.`);let i=await r(n.props??{});if(n.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=n.key);else i.key=n.key;return ye(i,o)}async function Ci(e,t){let n=e,o=n.type,r=n.props??{},i=[],s=null;n.key!=null&&i.push(` data-wf-key="${ze(String(n.key))}"`);for(let[a,u]of Object.entries(r))if(!(a==="children"||a==="key")&&a!=="ref"&&!(a.startsWith("on")&&typeof u=="function")){if(a==="innerHTML"){s=String(u??"");continue}if(a==="class"||a==="className"){let f=ui(u);f&&i.push(` class="${ze(f)}"`);continue}if(a==="style"&&u&&typeof u=="object"){i.push(` style="${ze(ci(u))}"`);continue}if(Rn.has(a)){i.push(` ${a}="${u?"true":"false"}"`);continue}if(u===!0){i.push(` ${a}`);continue}u===!1||u==null||i.push(` ${a}="${ze(String(u))}"`)}let l=i.join(""),d=pi.has(o);if(fi.has(o))return`<${o}${l}>`;if(s!==null)return`<${o}${l}>${s}</${o}>`;let c=await ye(r.children,t);return d?`<${o}${l}>${c}</${o}>`:`<${o}${l}>${c}</${o}>`}var xi={hole:mi,text:yi,arr:vi,portal:wi,frag:Ni,comp:bi,native:Ci};function io(e){return`<script>window.__DATA__=${JSON.stringify(Object.fromEntries(e)).replace(/</g,"\\u003c")};<\/script>`}function lt(e,t){let n={...e,browser:null,__registry:null,ui:{_rootVNodeId:null,render:()=>Promise.resolve(),setMounting:()=>{},endMounting:()=>{}}},o=new Map;return n.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}),t.set(r,d),d));return o.set(r,{promise:l}),l},set(r,i){o.set(r,{value:i}),t.set(r,i)},has(r){return o.has(r)}},n}async function Vi(e,t,n,o={}){let r=o.data??new Map,i=lt(n??{},r),s=Le(e,t??{});return ye(s,i)}async function Ei(e,t){let n=new Map,r=lt({params:{},query:{}},n),i=t.url.split("?")[0].split("#")[0],s=e.match(i);r.params=s.params,r.query=Object.fromEntries(new URLSearchParams(t.url.split("?")[1]??""));let l=new URL(t.url.startsWith("http")?t.url:`http://localhost${t.url.startsWith("/")?t.url:"/"+t.url}`),d=await e.execute(l,r,i),c=await ye(d,r),a=io(n),u=s.title??t.title??"",f=t.rootId??"root",p=(t.styles??[]).map(g=>` <link rel="stylesheet" href="${g}">`).join(`
|
|
10
10
|
`),m=`<!DOCTYPE html>
|
|
11
|
-
<html lang="${
|
|
11
|
+
<html lang="${t.lang??"zh-CN"}">
|
|
12
12
|
<head>
|
|
13
13
|
<meta charset="UTF-8">
|
|
14
14
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
15
|
-
${
|
|
15
|
+
${u?`<title>${u}</title>`:""}
|
|
16
16
|
${p}
|
|
17
17
|
</head>
|
|
18
18
|
<body>
|
|
19
|
-
<div id="${f}">${
|
|
19
|
+
<div id="${f}">${c}</div>
|
|
20
20
|
${a}
|
|
21
21
|
<script src="/app.js"><\/script>
|
|
22
22
|
</body>
|
|
23
|
-
</html>`;return{html:
|
|
23
|
+
</html>`;return{html:c,dataScript:a,page:m}}function _i(e){let t={...e},n=new Set,o=()=>{for(let r of[...n])r()};return{state:t,subscribe(r){return n.add(r),()=>{n.delete(r)}},set(r){Object.assign(t,r),o()},update(r){r(t),o()},notify:o}}export{Z as Fragment,z as Portal,bn as UIRouter,po as animateOut,mo as api,ho as auth,q as buildVNode,V as createClientBrowser,Qe as createPortal,fn as createRenderer,lt as createSsrContext,_i as createStore,vn as createVdomContext,ve as h,rt as hydrateVNode,No as i18n,Cn as jsx,fo as jsxDEV,co as jsxs,Dr as mountCommand,Qr as mountRoot,te as patchValue,$ as renderValue,io as serializeData,Ei as ssrPage,Vi as ssrToString,di as uiServe,jr as unmountCommand,vo as ws};
|