weifuwu 0.81.0 → 0.81.2

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