pulse-ui-client 0.0.13 → 0.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import{useEffect as E,useState as a,useMemo as t,createContext as AW,useContext as NW}from"react";import jW,{cloneElement as L,createElement as XW,lazy as BW,Suspense as KW}from"react";var QW="$$fragment",qW="$$";function zW(W){return typeof W==="object"&&W!==null}function JW(W){return typeof W==="object"&&W!==null&&W.tag.startsWith("$$")&&W.tag!=="$$fragment"}import{jsx as n,Fragment as YW}from"react/jsx-runtime";class h{client;path;components;callbackCache;constructor(W,Z,$){this.client=W;this.path=Z;this.components=$;this.callbackCache=new Map}getCallback(W){let Z=this.callbackCache.get(W);if(!Z)Z=(...$)=>this.client.invokeCallback(this.path,W,$),this.callbackCache.set(W,Z);return Z}renderNode(W){if(W==null||typeof W==="boolean"||typeof W==="number"||typeof W==="string")return W;if(zW(W)){let{tag:Z,props:$={},children:Q=[]}=W,q={};for(let[U,z]of Object.entries($))if(typeof z==="string"&&z.startsWith("$$fn:")){let V=z.substring(5);q[U]=this.getCallback(V)}else q[U]=z;if(W.key)q.key=W.key;let J=[];for(let U of Q)J.push(this.renderNode(U));if(JW(W)){let U=W.tag.slice(qW.length),z=this.components[U];return XW(z,q,...J)}return XW(Z===QW?jW.Fragment:Z,q,...J)}return null}}function g(W){let Z=W.props?.children;if(Z==null)return[];return Array.isArray(Z)?Z.slice():[Z]}function kW(W,Z){let $={};for(let[Q,q]of Object.entries(Z||{}))if(typeof q==="string"&&q.startsWith("$$fn:")){let J=q.substring(5);$[Q]=W.getCallback(J)}else $[Q]=q;return $}function HW(W,Z){return L(W,void 0,...Z)}function d(W,Z,$){let Q=W;for(let q of Z){let J=q.path.split(".").filter((z)=>z.length>0).map(Number),U=(z,V)=>{if(V<J.length){M(z,J,V),z=z;let X=J[V],P=g(z),C=P[X];return P[X]=U(C,V+1),HW(z,P)}switch(q.type){case"replace":return $.renderNode(q.data);case"update_props":{M(z,J,V),z=z;let P={...z.props??{}},C=q.data;if(C.remove&&C.remove.length>0){for(let D of C.remove)if(D in P)delete P[D]}if(C.set){let D=kW($,C.set);for(let[G,f]of Object.entries(D))P[G]=f}return L(z,P)}case"insert":{M(z,J,V),z=z;let X=g(z);return X.splice(q.idx,0,$.renderNode(q.data)),L(z,null,...X)}case"remove":{M(z,J,V),z=z;let X=g(z);return X.splice(q.idx,1),L(z,null,...X)}case"move":{M(z,J,V),z=z;let X=g(z),P=X.splice(q.data.from_index,1)[0];return X.splice(q.data.to_index,0,P),L(z,null,...X)}default:throw Error(`[Pulse renderer] Unknown update type: ${q.type}`)}};Q=U(Q,0)}return Q}function yW(W,Z){let $=BW(W);return({children:Q,...q})=>{return n(KW,{fallback:Z??n(YW,{}),children:n($,{...q,children:Q})})}}function M(W,Z,$){return!0}function B(){function W(Z,$){return(Q)=>{let q={};for(let J of Z)q[J]=Q[J];if($)for(let J in $){let U=$[J];q[J]=U(Q)}return q}}return W}var bW=(W)=>W.tagName.toLowerCase(),MW=["id","className","tagName","localName","clientHeight","clientLeft","clientTop","clientWidth","scrollHeight","scrollLeft","scrollTop","scrollWidth","slot"],LW=["autofocus","tabIndex","nonce"],SW=["accessKey","accessKeyLabel","autocapitalize","dir","draggable","hidden","inert","lang","offsetHeight","offsetLeft","offsetTop","offsetWidth","popover","spellcheck","title","translate","writingSuggestions","contentEditable","enterKeyHint","isContentEditable","inputMode"],TW=B()(MW,{tagName:bW}),_W=B()(LW),gW=B()(SW);function K(W){return{...TW(W),..._W(W),...gW(W)}}function F(W,Z){let $=B()(W,Z);return(Q)=>({...K(Q),...$(Q)})}var hW=["hash","host","hostname","href","origin","password","pathname","port","protocol","search","target","download","rel","hreflang","type","username","ping","referrerPolicy","text"],xW=F(hW),pW=["alt","coords","download","hash","host","hostname","href","origin","password","pathname","port","protocol","rel","search","shape","target","username","ping","referrerPolicy"],mW=F(pW),vW=["autoplay","controls","crossOrigin","currentSrc","currentTime","defaultMuted","defaultPlaybackRate","duration","ended","loop","muted","networkState","paused","playbackRate","preload","readyState","seeking","src","volume","preservesPitch"],DW=F(vW),uW=(W)=>DW(W),EW=["disabled","name","type","value","formAction","formEnctype","formMethod","formNoValidate","formTarget","popoverTargetAction"],iW=F(EW),cW=["value"],nW=F(cW),dW=["height","src","type","width","align","name"],lW=F(dW),oW=["disabled","name","type","validationMessage","willValidate"],sW=F(oW),rW=["acceptCharset","action","autocomplete","encoding","enctype","length","method","name","noValidate","target","rel"],aW=F(rW),tW=["allow","allowFullscreen","height","name","referrerPolicy","src","srcdoc","width","align","frameBorder","longDesc","marginHeight","marginWidth","scrolling","sandbox"],eW=F(tW),W1=["alt","crossOrigin","decoding","height","isMap","loading","naturalHeight","naturalWidth","referrerPolicy","sizes","src","srcset","useMap","width","align","border","complete","hspace","longDesc","lowsrc","name","vspace","x","y","fetchPriority"],Z1=F(W1),$1=["accept","alt","autocomplete","checked","defaultChecked","defaultValue","dirName","disabled","height","indeterminate","max","maxLength","min","minLength","multiple","name","pattern","placeholder","readOnly","required","selectionDirection","selectionEnd","selectionStart","size","src","step","type","value","valueAsNumber","width","align","capture","formAction","formEnctype","formMethod","formNoValidate","formTarget","useMap","validationMessage","willValidate","popoverTargetAction"],Q1=F($1),q1=["htmlFor"],z1=F(q1),J1=["value","type"],X1=F(J1),F1=["as","crossOrigin","disabled","fetchPriority","href","hreflang","imageSizes","imageSrcset","integrity","media","referrerPolicy","rel","type","charset","rev","target","sizes"],G1=F(F1),V1=["name"],U1=F(V1),D1=["high","low","max","min","optimum","value"],P1=F(D1),f1=["cite","dateTime"],FW=F(f1),C1=["reversed","start","type","compact"],A1=F(C1),N1=["data","height","name","type","useMap","width","validationMessage","willValidate","align","archive","border","code","codeBase","codeType","declare","hspace","standby","vspace"],O1=F(N1),R1=["disabled","label"],I1=F(R1),w1=["defaultSelected","disabled","index","label","selected","text","value"],j1=F(w1),B1=["defaultValue","name","type","value","htmlFor","validationMessage","willValidate"],K1=F(B1),k1=["max","position","value"],H1=F(k1),y1=["cite"],GW=F(y1),Y1=(W)=>K(W),b1=["async","crossOrigin","defer","fetchPriority","integrity","noModule","referrerPolicy","src","text","type","charset"],M1=B()(b1,{event:(W)=>W.event,htmlFor:(W)=>W.htmlFor}),L1=(W)=>({...K(W),...M1(W)}),S1=["autocomplete","disabled","length","multiple","name","required","selectedIndex","size","type","value","validationMessage","willValidate"],T1=F(S1),_1=["name"],g1=F(_1),h1=["height","media","sizes","src","srcset","type","width"],x1=F(h1),p1=["align"],m1=F(p1),v1=["abbr","cellIndex","colSpan","headers","rowSpan","scope","align","axis","bgColor","ch","chOff","height","noWrap","vAlign","width"],VW=F(v1),u1=["span","align","ch","chOff","vAlign","width"],UW=F(u1),E1=["align","bgColor","border","cellPadding","cellSpacing","frame","rules","summary","width"],i1=F(E1),c1=["rowIndex","sectionRowIndex","align","bgColor","ch","chOff","vAlign"],n1=F(c1),d1=["align","ch","chOff","vAlign"],l=F(d1),l1=(W)=>K(W),o1=["autocomplete","cols","defaultValue","dirName","disabled","maxLength","minLength","name","placeholder","readOnly","required","rows","selectionDirection","selectionEnd","selectionStart","value","wrap","textLength","validationMessage","willValidate"],s1=F(o1),r1=["dateTime"],a1=F(r1),t1=["default","kind","label","readyState","src","srclang"],e1=F(t1),W3=["height","poster","videoHeight","videoWidth","width","playsInline"],Z3=B()(W3),$3=(W)=>({...DW(W),...Z3(W)}),Q3=["clear"],q3=F(Q3),z3=["href","target"],J3=F(z3),X3=["aLink","background","bgColor","link","text","vLink"],F3=F(X3),G3=["compact"],V3=F(G3),U3=["open"],D3=F(U3),P3=["open","returnValue"],f3=F(P3),C3=["align"],A3=F(C3),N3=(W)=>K(W),O3=["align"],y=F(O3),R3=["align","color","noShade","size","width"],I3=F(R3),w3=["version"],j3=F(w3),B3=(W)=>K(W),K3=["content","httpEquiv","name","scheme"],k3=F(K3),H3=["align"],y3=F(H3),Y3=(W)=>K(W),b3=["width"],M3=F(b3),L3=(W)=>K(W),S3=["media","type","disabled"],T3=F(S3),_3=["text"],g3=F(_3),h3=["compact","type"],x3=F(h3),p3={A:xW,AREA:mW,AUDIO:uW,BASE:J3,BLOCKQUOTE:GW,Q:GW,BODY:F3,BR:q3,BUTTON:iW,CANVAS:K,CAPTION:m1,CITE:Y1,COL:UW,COLGROUP:UW,DATA:nW,DETAILS:D3,DIALOG:f3,DIV:A3,DL:V3,EMBED:lW,FIELDSET:sW,FORM:aW,H1:y,H2:y,H3:y,H4:y,H5:y,H6:y,HEAD:N3,HR:I3,HTML:j3,IFRAME:eW,IMG:Z1,INPUT:Q1,LABEL:z1,LI:X1,LINK:G1,MAP:U1,MENU:B3,META:k3,METER:P1,INS:FW,DEL:FW,OBJECT:O1,OL:A1,OPTGROUP:I1,OPTION:j1,OUTPUT:K1,P:y3,PICTURE:Y3,PRE:M3,PROGRESS:H1,SCRIPT:L1,SELECT:T1,SLOT:g1,SOURCE:x1,SPAN:L3,STYLE:T3,TABLE:i1,TBODY:l,THEAD:l,TFOOT:l,TD:VW,TH:VW,TEMPLATE:l1,TEXTAREA:s1,TIME:a1,TITLE:g3,TR:n1,TRACK:e1,UL:x3,VIDEO:$3};function x(W){let Z=W.tagName.toUpperCase(),$=p3[Z];if($)return $(W);throw Error(`Unexpected HTML element tag: ${W.tagName} (update .web/custom/serialize.ts)`)}var m3=(W)=>x(W.target),S=(W)=>W.relatedTarget?x(W.relatedTarget):null;function A(W,Z){return B()(W,{target:m3,...Z||{}})}var w=["target","bubbles","cancelable","defaultPrevented","eventPhase","isTrusted","timeStamp","type"],p=[...w,"detail"],m=[...p,"altKey","button","buttons","clientX","clientY","ctrlKey","metaKey","movementX","movementY","pageX","pageY","screenX","screenY","shiftKey"],v3=[...m,"pointerId","pressure","tangentialPressure","tiltX","tiltY","twist","width","height","pointerType","isPrimary"],u3=A(w),E3=A(p),i3=A(m,{relatedTarget:S}),c3=A(w,{clipboardData:(W)=>PW(W.clipboardData)}),n3=A([...w,"data"]),d3=A(m,{relatedTarget:S,dataTransfer:(W)=>PW(W.dataTransfer)}),l3=A(v3,{relatedTarget:S}),o3=A(w,{relatedTarget:S}),s3=A(w),r3=A(w),a3=A(w),t3=A([...p,"altKey","ctrlKey","code","key","locale","location","metaKey","repeat","shiftKey"]),e3=A([...p,"altKey","ctrlKey","metaKey","shiftKey","changedTouches","targetTouches","touches"],{changedTouches:(W)=>o(W.changedTouches),targetTouches:(W)=>o(W.targetTouches),touches:(W)=>o(W.touches)}),WZ=A([...m,"deltaMode","deltaX","deltaY","deltaZ"],{relatedTarget:S}),ZZ=A([...w,"animationName","elapsedTime","pseudoElement"]),$Z=A([...w,"oldState","newState"]),QZ=A([...w,"elapsedTime","propertyName","pseudoElement"]);function o(W){return Array.from(W).map((Z)=>({target:x(Z.target),identifier:Z.identifier,screenX:Z.screenX,screenY:Z.screenY,clientX:Z.clientX,clientY:Z.clientY,pageX:Z.pageX,pageY:Z.pageY}))}function PW(W){if(!W)return null;let Z=[];if(W.items)for(let $=0;$<W.items.length;$++){let Q=W.items[$];Z.push({kind:Q.kind,type:Q.type})}return{drop_effect:W.dropEffect,effect_allowed:W.effectAllowed,items:Z,types:Array.from(W.types||[])}}var N={};function R(W,Z,$){for(let Q of Z)W[Q]=$}R(N,["pointerdown","pointermove","pointerup","pointercancel","gotpointercapture","lostpointercapture","pointerenter","pointerleave","pointerover","pointerout"],l3);R(N,["click","contextmenu","dblclick","mousedown","mouseenter","mouseleave","mousemove","mouseout","mouseover","mouseup"],i3);R(N,["drag","dragend","dragenter","dragexit","dragleave","dragover","dragstart","drop"],d3);R(N,["keydown","keypress","keyup"],t3);R(N,["focus","blur"],o3);R(N,["change","input"],a3);R(N,["invalid"],r3);R(N,["reset","submit"],s3);R(N,["copy","cut","paste"],c3);R(N,["compositionend","compositionstart","compositionupdate"],n3);R(N,["touchcancel","touchend","touchmove","touchstart"],e3);R(N,["scroll"],E3);R(N,["wheel"],WZ);R(N,["animationstart","animationend","animationiteration"],ZZ);R(N,["transitionend"],QZ);R(N,["toggle"],$Z);function s(W){if(W&&typeof W==="object"&&"nativeEvent"in W&&typeof W.isDefaultPrevented==="function"){let Z=W;if(typeof Z.type!=="string")return W;let $=N[Z.type.toLowerCase()];if($)return $(Z);return u3(Z)}return W}function T(W){let Z=new Map,$=[],Q=[],q=[],J=[],U=0;function z(X){if(X==null||typeof X==="number"||typeof X==="string"||typeof X==="boolean")return X;let P=U++,C=Z.get(X);if(C!==void 0)return $.push(P),C;if(Z.set(X,P),X instanceof Date)return Q.push(P),X.getTime();if(Array.isArray(X)){let D=X.length,G=Array(D);for(let f=0;f<D;f++)G[f]=z(X[f]);return G}if(X instanceof Map){J.push(P);let D={};for(let[G,f]of X.entries())D[String(G)]=z(f);return D}if(X instanceof Set){q.push(P);let D=X.size,G=Array(D),f=0;for(let I of X)G[f]=z(I),f+=1;return G}if(typeof X==="object"){let D={},G=Object.keys(X);for(let f=0;f<G.length;f++){let I=G[f];D[I]=z(X[I])}return D}throw Error(`Unsupported value in serialization: ${X}`)}let V=z(W);return[[$,Q,q,J],V]}function r(W,Z){let[[$,Q,q,J],U]=W,z=new Set($),V=new Set(Q),X=new Set(q),P=new Set(J),C=[];function D(G){let f=C.length;if(z.has(f))return C.push(null),C[G];if(V.has(f)){let I=new Date(G);return C.push(I),I}if(G==null||typeof G==="number"||typeof G==="string"||typeof G==="boolean"){if(Z?.coerceNullsToUndefined)return G??void 0;return G}if(Array.isArray(G)){if(X.has(f)){let O=new Set;C.push(O);for(let j=0;j<G.length;j++)O.add(D(G[j]));return O}let I=G.length,H=Array(I);C.push(H);for(let O=0;O<I;O++)H[O]=D(G[O]);return H}if(typeof G==="object"){if(P.has(f)){let O=new Map;C.push(O);let j=Object.keys(G);for(let c=0;c<j.length;c++){let $W=j[c];O.set($W,D(G[$W]))}return O}let I={};C.push(I);let H=Object.keys(G);for(let O=0;O<H.length;O++){let j=H[O];I[j]=D(G[j])}return I}throw Error(`Unsupported value in deserialization: ${G}`)}return D(U)}import{io as FZ}from"socket.io-client";class k extends Error{constructor(W){super(W);this.name="PulseChannelResetError"}}function qZ(){if(typeof crypto<"u"&&typeof crypto.randomUUID==="function")return crypto.randomUUID().replace(/-/g,"");return Math.random().toString(16).slice(2)+Math.random().toString(16).slice(2)}function zZ(W){if(W instanceof Error)return W.message;if(typeof W==="string")return W;try{return JSON.stringify(W)}catch{return String(W)}}function JZ(W){return typeof W.responseTo==="string"}function XZ(W){return typeof W.event==="string"}class fW{client;id;handlers=new Map;pending=new Map;backlog=[];closed=!1;constructor(W,Z){this.client=W;this.id=Z}emit(W,Z){this.ensureOpen(),this.client.sendChannelMessage({type:"channel_message",channel:this.id,event:W,payload:Z})}async request(W,Z){this.ensureOpen();let $=qZ();return new Promise((Q,q)=>{this.pending.set($,{resolve:Q,reject:q}),this.client.sendChannelMessage({type:"channel_message",channel:this.id,event:W,payload:Z,requestId:$}).catch((J)=>{this.pending.delete($),q(J)})})}on(W,Z){this.ensureOpen();let $=this.handlers.get(W);if(!$)$=new Set,this.handlers.set(W,$);return $.add(Z),this.flushBacklog(W),()=>{let Q=this.handlers.get(W);if(!Q)return;if(Q.delete(Z),Q.size===0)this.handlers.delete(W)}}handleServerMessage(W){if(JZ(W))return this.resolvePending(W),this.closed;if(this.closed)return!0;if(!XZ(W))return this.closed;if(W.event==="__close__")return this.close(new k("Channel closed by server")),!0;if(W.requestId)this.dispatchRequest(W);else this.dispatchEvent(W);return this.closed}handleDisconnect(W){this.close(W)}dispose(W){this.close(W)}ensureOpen(){if(this.closed)throw new k("Channel is closed")}flushBacklog(W){if(this.backlog.length===0)return;let Z=[];for(let $ of this.backlog)if($.event===W)this.dispatchEvent($);else Z.push($);this.backlog=Z}dispatchEvent(W){let Z=this.handlers.get(W.event);if(!Z||Z.size===0){this.backlog.push(W);return}for(let $ of Z)try{let Q=$(W.payload);if(Q&&typeof Q.then==="function")Q.catch((q)=>{console.error("Pulse channel handler error",q)})}catch(Q){console.error("Pulse channel handler error",Q)}}async dispatchRequest(W){let Z=this.handlers.get(W.event),$,Q;if(Z&&Z.size>0)for(let q of Z)try{let J=q(W.payload);if($=await Promise.resolve(J),$!==void 0)break}catch(J){Q=J;break}if(Q){await this.client.sendChannelMessage({type:"channel_message",channel:this.id,event:void 0,responseTo:W.requestId,error:zZ(Q)});return}await this.client.sendChannelMessage({type:"channel_message",channel:this.id,event:void 0,responseTo:W.requestId,payload:$})}resolvePending(W){let Z=W.responseTo?this.pending.get(W.responseTo):void 0;if(!Z)return;if(this.pending.delete(W.responseTo),W.error!==void 0&&W.error!==null)Z.reject(new k(String(W.error)));else Z.resolve(W.payload)}close(W){if(this.closed)return;this.closed=!0;for(let Z of this.pending.values())Z.reject(W);this.pending.clear(),this.handlers.clear(),this.backlog=[]}}function CW(W,Z){return new fW(W,Z)}class v{url;renderId;frameworkNavigate;activeViews;socket=null;messageQueue;connectionListeners=new Set;serverErrors=new Map;serverErrorListeners=new Set;channels=new Map;constructor(W,Z,$){this.url=W;this.renderId=Z;this.frameworkNavigate=$;this.socket=null,this.activeViews=new Map,this.messageQueue=[]}isConnected(){return this.socket?.connected??!1}async connect(){if(this.socket)return;return new Promise((W,Z)=>{let $=FZ(this.url,{transports:["websocket","webtransport"],auth:{renderId:this.renderId}});this.socket=$,$.on("connect",()=>{console.log("[SocketIOTransport] Connected:",this.socket?.id);for(let[Q,q]of this.activeViews)$.emit("message",T({type:"mount",path:Q,routeInfo:q.routeInfo}));for(let Q of this.messageQueue){if(Q.type==="mount"&&this.activeViews.has(Q.path))continue;if(Q.type==="navigate")continue;$.emit("message",T(Q))}this.messageQueue=[],this.notifyConnectionListeners(!0),W()}),$.on("connect_error",(Q)=>{console.error("[SocketIOTransport] Connection failed:",Q),this.notifyConnectionListeners(!1),Z(Q)}),$.on("disconnect",()=>{console.log("[SocketIOTransport] Disconnected"),this.handleTransportDisconnect(),this.notifyConnectionListeners(!1)}),$.on("message",(Q)=>this.handleServerMessage(r(Q,{coerceNullsToUndefined:!0})))})}onConnectionChange(W){return this.connectionListeners.add(W),W(this.isConnected()),()=>{this.connectionListeners.delete(W)}}notifyConnectionListeners(W){for(let Z of this.connectionListeners)Z(W)}onServerError(W){this.serverErrorListeners.add(W);for(let[Z,$]of this.serverErrors)W(Z,$);return()=>{this.serverErrorListeners.delete(W)}}notifyServerError(W,Z){for(let $ of this.serverErrorListeners)$(W,Z)}async sendMessage(W){if(this.isConnected())this.socket.emit("message",T(W));else this.messageQueue.push(W)}async sendChannelMessage(W){await this.sendMessage(W)}mountView(W,Z){if(this.activeViews.has(W))throw Error(`Path ${W} is already mounted`);this.activeViews.set(W,Z),this.sendMessage({type:"mount",path:W,routeInfo:Z.routeInfo})}async navigate(W,Z){await this.sendMessage({type:"navigate",path:W,routeInfo:Z})}unmount(W){this.sendMessage({type:"unmount",path:W}),this.activeViews.delete(W)}disconnect(){this.socket?.disconnect(),this.socket=null,this.messageQueue=[],this.connectionListeners.clear(),this.activeViews.clear(),this.serverErrors.clear(),this.serverErrorListeners.clear();for(let{bridge:W}of this.channels.values())W.dispose(new k("Client disconnected"));this.channels.clear()}handleServerMessage(W){switch(W.type){case"vdom_init":{let Z=this.activeViews.get(W.path);if(!Z)return;if(Z)Z.onInit(W.vdom);if(this.serverErrors.has(W.path))this.serverErrors.delete(W.path),this.notifyServerError(W.path,null);break}case"vdom_update":{let Z=this.activeViews.get(W.path);if(!Z)return;if(Z.onUpdate(W.ops),this.serverErrors.has(W.path))this.serverErrors.delete(W.path),this.notifyServerError(W.path,null);break}case"server_error":{if(!this.activeViews.has(W.path))return;this.serverErrors.set(W.path,W.error),this.notifyServerError(W.path,W.error);break}case"api_call":{this.performApiCall(W);break}case"navigate_to":{let Z=!!W.replace,$=W.path||"";if($.startsWith("//"))$=`${window.location.protocol}${$}`;if(/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test($))if($.startsWith("http://")||$.startsWith("https://"))try{let q=new URL($);if(q.origin===window.location.origin){let J=`${q.pathname}${q.search}${q.hash}`;this.frameworkNavigate(J,{replace:Z})}else if(Z)window.location.replace($);else window.location.assign($)}catch{if(Z)window.location.replace($);else window.location.assign($)}else if(Z)window.location.replace($);else window.location.assign($);else this.frameworkNavigate($,{replace:Z});break}case"channel_message":{this.routeChannelMessage(W);break}default:console.error("Unexpected message:",W)}}async performApiCall(W){try{let Z=await fetch(W.url,{method:W.method||"GET",headers:{...W.headers||{},...W.body!=null&&!("content-type"in(W.headers||{}))?{"content-type":"application/json"}:{}},body:W.body!=null?typeof W.body==="string"?W.body:JSON.stringify(W.body):void 0,credentials:W.credentials||"include"}),$={};Z.headers.forEach((U,z)=>$[z]=U);let Q=null;if((Z.headers.get("content-type")||"").includes("application/json"))Q=await Z.json().catch(()=>null);else Q=await Z.text().catch(()=>null);let J={type:"api_result",id:W.id,ok:Z.ok,status:Z.status,headers:$,body:Q};await this.sendMessage(J)}catch(Z){let $={type:"api_result",id:W.id,ok:!1,status:0,headers:{},body:{error:String(Z)}};await this.sendMessage($)}}async invokeCallback(W,Z,$){await this.sendMessage({type:"callback",path:W,callback:Z,args:$.map(s)})}acquireChannel(W){let Z=this.ensureChannelEntry(W);return Z.refCount+=1,Z.bridge}releaseChannel(W){let Z=this.channels.get(W);if(!Z)return;if(Z.refCount=Math.max(0,Z.refCount-1),Z.refCount===0)Z.bridge.dispose(new k("Channel released")),this.channels.delete(W)}ensureChannelEntry(W){let Z=this.channels.get(W);if(!Z)Z={bridge:CW(this,W),refCount:0},this.channels.set(W,Z);return Z}routeChannelMessage(W){let Z=this.ensureChannelEntry(W.channel);if(Z.bridge.handleServerMessage(W)&&Z.refCount===0)this.channels.delete(W.channel)}handleTransportDisconnect(){for(let W of this.channels.values())W.bridge.handleDisconnect(new k("Connection lost"))}}import{useLocation as GZ,useParams as VZ,useNavigate as UZ}from"react-router";import{jsx as Y,jsxs as u}from"react/jsx-runtime";var OW=AW(null),RW=AW(null),i=()=>{let W=NW(OW);if(!W)throw Error("usePulseClient must be used within a PulseProvider");return W},DZ=(W)=>{let Z=NW(RW);if(!Z)throw Error("usePulsePrerender must be used within a PulseProvider");let $=Z.views[W];if(!$)throw Error(`No prerender found for '${W}'`);return $},e=typeof window<"u";function PZ({children:W,config:Z,prerender:$}){let[Q,q]=a(!0),J=UZ(),{renderId:U}=$,z=t(()=>new v(Z.serverAddress,U,J),[Z.serverAddress,J,U]);return E(()=>z.onConnectionChange(q),[z]),E(()=>{if(e)return z.connect(),()=>z.disconnect()},[z]),Y(OW.Provider,{value:z,children:u(RW.Provider,{value:$,children:[!Q&&Y("div",{style:{position:"fixed",bottom:"20px",right:"20px",backgroundColor:"red",color:"white",padding:"10px",borderRadius:"5px",zIndex:1000},children:"Failed to connect to the server."}),W]})})}function fZ({externalComponents:W,path:Z}){let $=i(),Q=DZ(Z),q=t(()=>new h($,Z,W),[$,Z,W]),[J,U]=a(()=>q.renderNode(Q)),[z,V]=a(null),X=GZ(),P=VZ(),C=t(()=>{let{"*":D="",...G}=P,f=new URLSearchParams(X.search);return{hash:X.hash,pathname:X.pathname,query:X.search,queryParams:Object.fromEntries(f.entries()),pathParams:G,catchall:D.length>0?D.split("/"):[]}},[X.hash,X.pathname,X.search,JSON.stringify(P)]);if(E(()=>{if(e){$.mountView(Z,{routeInfo:C,onInit:(G)=>{U(q.renderNode(G))},onUpdate:(G)=>{U((f)=>f==null?f:d(f,G,q))}});let D=$.onServerError((G,f)=>{if(G===Z)V(f)});return()=>{D(),$.unmount(Z)}}},[$]),E(()=>{if(e)$.navigate(Z,C)},[$,Z,C]),z)return Y(CZ,{error:z});return J}function CZ({error:W}){return u("div",{style:{padding:16,border:"1px solid #e00",background:"#fff5f5",color:"#900",fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',whiteSpace:"pre-wrap"},children:[u("div",{style:{fontWeight:700,marginBottom:8},children:["Server Error during ",W.phase]}),W.message&&Y("div",{children:W.message}),W.stack&&u("details",{open:!0,style:{marginTop:8},children:[Y("summary",{children:"Stack trace"}),Y("pre",{style:{margin:0},children:W.stack})]})]})}import{useEffect as AZ,useMemo as NZ}from"react";function OZ(W){let Z=i(),$=NZ(()=>{if(!W)throw Error("usePulseChannel requires a non-empty channelId");return Z.acquireChannel(W)},[Z,W]);return AZ(()=>{return()=>{Z.releaseChannel(W)}},[Z,W]),$}import{forwardRef as RZ,useCallback as IZ}from"react";import{jsx as jZ}from"react/jsx-runtime";var wZ=RZ(function({onSubmit:Z,action:$,...Q},q){return jZ("form",{...Q,action:$,ref:q,onSubmit:IZ((J)=>IW({event:J,action:$,onSubmit:Z}),[$,Z])})});async function IW({event:W,action:Z,onSubmit:$,formData:Q,force:q}){if($?.(W),!q&&W.defaultPrevented)return;let J=W.currentTarget;W.preventDefault();let U=W.nativeEvent;if(!Q)Q=new FormData(J,U.submitter);let z=new URL(Z,window.location.href);try{await fetch(z,{method:"POST",credentials:"include",body:Q})}catch(V){throw V}}import{io as BZ}from"socket.io-client";class wW{url;socket=null;listener=null;messageQueue=[];connectionListeners=new Set;constructor(W){this.url=W}connect(W){return this.listener=W,new Promise((Z,$)=>{this.socket=BZ(this.url,{transports:["websocket"]}),this.socket.on("connect",()=>{console.log("[SocketIOTransport] Connected:",this.socket?.id);for(let Q of this.messageQueue)this.socket?.emit("message",Q);this.messageQueue=[],this.notifyConnectionListeners(!0),Z()}),this.socket.on("connect_error",(Q)=>{console.error("[SocketIOTransport] Connection failed:",Q),this.notifyConnectionListeners(!1),$(Q)}),this.socket.on("disconnect",()=>{console.log("[SocketIOTransport] Disconnected"),this.notifyConnectionListeners(!1)}),this.socket.on("message",(Q)=>{this.listener?.(Q)})})}disconnect(){this.socket?.disconnect(),this.socket=null,this.listener=null,this.messageQueue=[],this.connectionListeners.clear()}async sendMessage(W){if(this.isConnected())this.socket.emit("message",W);else this.messageQueue.push(W)}isConnected(){return this.socket?.connected||!1}onConnectionChange(W){return this.connectionListeners.add(W),W(this.isConnected()),()=>{this.connectionListeners.delete(W)}}notifyConnectionListeners(W){for(let Z of this.connectionListeners)Z(W)}}function KZ({params:W,request:Z}){let{"*":$="",...Q}=W,q=new URL(Z.url);return{hash:q.hash,pathname:q.pathname,query:q.search,queryParams:Object.fromEntries(q.searchParams.entries()),pathParams:Q,catchall:$.length>1?$.split("/"):[]}}function kZ(W){if(W===null||typeof W!=="object")return!1;let Z=Object.getPrototypeOf(W);return Z===Object.prototype||Z===null}function WW(W){return typeof W==="function"||typeof W==="symbol"||typeof W>"u"}async function HZ(W){let Z=await W.arrayBuffer();return Array.from(new Uint8Array(Z))}async function yZ(W){return await _(W,{seen:new WeakMap,nextId:1})}function YZ(W,Z){if(W.seen.get(Z)!==void 0)return null;let Q=W.nextId++;return W.seen.set(Z,Q),Q}async function _(W,Z){if(W===null||typeof W!=="object")return W;if(W instanceof Date)return{__t:"datetime",timestamp:W.getTime()};if(W instanceof FormData){let z=YZ(Z,W);if(z===null)return{__t:"ref",id:Z.seen.get(W)};let V={};for(let[P,C]of W.entries()){let D=await _(C,Z);if(D===void 0)continue;if(Object.prototype.hasOwnProperty.call(V,P)){let G=V[P];if(Array.isArray(G))G.push(D);else V[P]=[G,D]}else V[P]=D}return{__t:"formdata",fields:V,__id:z}}if(W instanceof File){let z=W,V=await HZ(W);return{__t:"file",name:z.name,type:z.type,size:z.size,lastModified:z.lastModified,content:V}}let $=W,Q=Z.seen.get($);if(Q!==void 0)return{__t:"ref",id:Q};let q=Z.nextId++;if(Z.seen.set($,q),Array.isArray(W)){let V=(await Promise.all(W.map((P)=>_(P,Z)))).filter((P)=>P!==void 0);return{__t:"array",__id:q,items:V}}let J={};if(kZ(W))for(let z of Object.keys(W)){let V=W[z];if(WW(V))continue;let X=await _(V,Z);if(X!==void 0)J[z]=X}else for(let z in W){let V=W[z];if(WW(V))continue;let X=await _(V,Z);if(X!==void 0)J[z]=X}return{__t:"object",__id:q,props:J}}function bZ(W){return b(W)}function b(W){if(W===null||typeof W!=="object")return W;let Z=W,$=Z.__t;if($==="datetime"){let q=Z.timestamp;return new Date(q)}if($==="file"){let q=Z.content;if(Array.isArray(q))return{...Z,content:new Uint8Array(q)};return Z}if($==="formdata"){let q=Z.fields,J={};for(let U of Object.keys(q)){let z=q[U];if(Array.isArray(z))J[U]=z.map((V)=>b(V));else J[U]=b(z)}return{__t:"formdata",fields:J}}if($==="array")return Z.items.map((J)=>b(J));if($==="object"){let q=Z.props,J={};for(let U of Object.keys(q))J[U]=b(q[U]);return J}if($==="ref")return Z;let Q={};for(let q of Object.keys(Z))Q[q]=b(Z[q]);return Q}function MZ(W){return ZW(W,new WeakSet)}function ZW(W,Z){if(W===null||typeof W!=="object")return W;if(Z.has(W))return;if(Z.add(W),Array.isArray(W))return W.map((Q)=>ZW(Q,Z)).filter((Q)=>Q!==void 0);let $={};for(let Q in W){let q=W[Q];if(WW(q))continue;let J=ZW(q,Z);if(J!==void 0)$[Q]=J}return $}export{i as usePulseClient,OZ as usePulseChannel,IW as submitForm,T as serialize,KZ as extractServerRouteInfo,s as extractEvent,yZ as encodeForWire,r as deserialize,bZ as decodeFromWire,MZ as cleanForSerialization,d as applyReactTreeUpdates,h as VDOMRenderer,wW as SocketIOTransport,yW as RenderLazy,fZ as PulseView,v as PulseSocketIOClient,PZ as PulseProvider,wZ as PulseForm,k as PulseChannelResetError};
1
+ import{useEffect as p,useState as a,useMemo as t,createContext as NW,useContext as RW}from"react";import BW,{cloneElement as w,createElement as JW,isValidElement as KW,lazy as wW,Suspense as HW}from"react";var QW="$$fragment",qW="$$";function zW(W){return typeof W==="object"&&W!==null}function FW(W){return typeof W==="object"&&W!==null&&W.tag.startsWith("$$")&&W.tag!=="$$fragment"}import{jsx as d,Fragment as LW}from"react/jsx-runtime";class x{client;path;components;cssModules;callbackCache;callbackProps;renderPropKeys;cssProps;constructor(W,Z,$,Q,q=[],z=[],G=[]){this.client=W;this.path=Z;this.components=$;this.cssModules=Q;this.callbackCache=new Map,this.callbackProps=new Map,this.renderPropKeys=new Set(z),this.cssProps=new Set(G),this.setCallbacks(q)}setCallbacks(W){this.callbackProps.clear(),this.callbackCache.clear();for(let Z of W){let[$,Q]=this.splitPropPath(Z);if(!this.callbackProps.has($))this.callbackProps.set($,new Set);this.callbackProps.get($).add(Q)}}applyCallbackDelta(W,Z){let $=new Map,Q=(z)=>{if(!$.has(z))$.set(z,new Set(this.callbackProps.get(z)??[]))};if(W.remove)for(let z of W.remove){let[G,F]=this.splitPropPath(z);Q(G);let J=this.callbackProps.get(G);if(!J){this.callbackCache.delete(z);continue}if(this.callbackCache.delete(z),J.delete(F),J.size===0)this.callbackProps.delete(G)}if(W.add)for(let z of W.add){let[G,F]=this.splitPropPath(z);if(Q(G),!this.callbackProps.has(G))this.callbackProps.set(G,new Set);this.callbackProps.get(G).add(F)}let q=Z;for(let[z,G]of $.entries()){let F=new Set(this.callbackProps.get(z)??[]);if(this.setsEqual(G,F))continue;let J=z?z.split(".").filter((X)=>X.length>0):[];q=this.updateCallbacksOnTree(q,J,0,"",G,F)}return q}setRenderProps(W){this.renderPropKeys=new Set(W)}setCssRefs(W){this.cssProps=new Set(W)}applyRenderPropsDelta(W){if(W.remove)for(let Z of W.remove)this.renderPropKeys.delete(Z);if(W.add)for(let Z of W.add)this.renderPropKeys.add(Z)}applyCssRefsDelta(W){if(W.set)for(let Z of W.set)this.cssProps.add(Z);if(W.remove)for(let Z of W.remove)this.cssProps.delete(Z)}getCallback(W,Z){let $=this.propPath(W,Z),Q=this.callbackCache.get($);if(!Q)Q=(...q)=>this.client.invokeCallback(this.path,$,q),this.callbackCache.set($,Q);return Q}renderNode(W,Z=""){if(W==null||typeof W==="boolean"||typeof W==="number"||typeof W==="string")return W;if(zW(W)){let{tag:$,props:Q={},children:q=[]}=W,z={...Q};for(let F of this.getCallbackNames(Z))z[F]=this.getCallback(Z,F);for(let[F,J]of Object.entries(z)){let X=this.propPath(Z,F);if(this.cssProps.has(X))z[F]=this.resolveCssToken(J);if(this.renderPropKeys.has(X))z[F]=this.renderNode(J,X)}if(W.key)z.key=W.key;let G=[];for(let F=0;F<q.length;F+=1){let J=q[F],X=Z?`${Z}.${F}`:String(F);G.push(this.renderNode(J,X))}if(FW(W)){let F=W.tag.slice(qW.length),J=this.components[F];if(!J)throw Error(`Could not find component ${F}. This is a Pulse internal error.`);return JW(J,z,...G)}return JW($===QW?BW.Fragment:$,z,...G)}return null}splitPropPath(W){let Z=W.lastIndexOf(".");if(Z===-1)return["",W];return[W.slice(0,Z),W.slice(Z+1)]}propPath(W,Z){return W?`${W}.${Z}`:Z}getCallbackNames(W){let Z=this.callbackProps.get(W);return Z?Array.from(Z):[]}transformValue(W,Z,$){let Q=this.callbackProps.get(W),q=this.propPath(W,Z);if(Q&&Q.size>0&&Q.has(Z))return this.getCallback(W,Z);if(this.renderPropKeys.has(q))return this.renderNode($,q);if(this.cssProps.has(q))return this.resolveCssToken($);return $}resolveCssToken(W){let Z=W.indexOf(":");if(Z===-1)return W;let $=W.slice(0,Z),Q=W.slice(Z+1);if(!$||!Q)return W;let q=this.cssModules[$];if(!q)throw Error(`Received CSS reference for unknown module '${$}'`);let z=q[Q];if(typeof z!=="string")throw Error(`Received CSS reference for missing class '${Q}' in module '${$}'`);return z}updateCallbacksOnTree(W,Z,$,Q,q,z){if($<Z.length){M(W,Z,$);let D=W,O=Z[$],C=Number(O),V=Q?`${Q}.${O}`:O;if(!Number.isNaN(C)){let A=k(D),N=A[C],R=this.updateCallbacksOnTree(N,Z,$+1,V,q,z);if(R===N)return W;return A[C]=R,w(D,void 0,...A)}else{let A=D.props??{},N=A[O],R=this.updateCallbacksOnTree(N,Z,$+1,V,q,z);if(R===N)return W;return w(D,{...A,[O]:R})}}if(!KW(W))return W;let G=W,F=G.props??{},J=!1,X={...F};for(let D of q)if(!z.has(D)&&D in X)delete X[D],J=!0;for(let D of z){let O=this.getCallback(Q,D);if(X[D]!==O)X[D]=O,J=!0}if(!J)return W;return w(G,X)}setsEqual(W,Z){if(W.size!==Z.size)return!1;for(let $ of W)if(!Z.has($))return!1;return!0}}function k(W){let Z=W.props?.children;if(Z==null)return[];return Array.isArray(Z)?Z.slice():[Z]}function n(W,Z,$){let Q=W;for(let q of Z){if(q.type==="update_callbacks"){Q=$.applyCallbackDelta(q.data,Q);continue}if(q.type==="update_css_refs"){$.applyCssRefsDelta(q.data);continue}if(q.type==="update_render_props"){$.applyRenderPropsDelta(q.data);continue}let z=q.path.split(".").filter((F)=>F.length>0),G=(F,J,X)=>{if(J<z.length){M(F,z,J);let D=F,O=z[J],C=+O,V=X?`${X}.${O}`:O;if(!Number.isNaN(C)){let A=k(D),N=A[C];return A[C]=G(N,J+1,V),w(D,void 0,...A)}else{let A=D.props??{},N=A[O],R={...A,[O]:G(N,J+1,V)};return w(D,R)}}switch(q.type){case"replace":return $.renderNode(q.data,q.path);case"update_props":{M(F,z,J);let D=F,C={...D.props??{}},V=q.data;if(V.remove&&V.remove.length>0){for(let A of V.remove)if(A in C)delete C[A]}if(V.set)for(let[A,N]of Object.entries(V.set))C[A]=$.transformValue(X,A,N);return w(D,C)}case"insert":{M(F,z,J);let D=F,O=k(D),C=X?`${X}.${q.idx}`:String(q.idx);return O.splice(q.idx,0,$.renderNode(q.data,C)),w(D,null,...O)}case"remove":{M(F,z,J);let D=F,O=k(D);return O.splice(q.idx,1),w(D,null,...O)}case"move":{M(F,z,J);let D=F,O=k(D),C=O.splice(q.data.from_index,1)[0];return O.splice(q.data.to_index,0,C),w(D,null,...O)}default:throw Error(`[Pulse renderer] Unknown update type: ${q.type}`)}};Q=G(Q,0,"")}return Q}function YW(W,Z){let $=wW(W);return({children:Q,...q})=>{return d(HW,{fallback:Z??d(LW,{}),children:d($,{...q,children:Q})})}}function M(W,Z,$){return!0}function H(){function W(Z,$){return(Q)=>{let q={};for(let z of Z)q[z]=Q[z];if($)for(let z in $){let G=$[z];q[z]=G(Q)}return q}}return W}var MW=(W)=>W.tagName.toLowerCase(),bW=["id","className","tagName","localName","clientHeight","clientLeft","clientTop","clientWidth","scrollHeight","scrollLeft","scrollTop","scrollWidth","slot"],SW=["autofocus","tabIndex","nonce"],yW=["accessKey","accessKeyLabel","autocapitalize","dir","draggable","hidden","inert","lang","offsetHeight","offsetLeft","offsetTop","offsetWidth","popover","spellcheck","title","translate","writingSuggestions","contentEditable","enterKeyHint","isContentEditable","inputMode"],kW=H()(bW,{tagName:MW}),_W=H()(SW),TW=H()(yW);function Y(W){return{...kW(W),..._W(W),...TW(W)}}function U(W,Z){let $=H()(W,Z);return(Q)=>({...Y(Q),...$(Q)})}var gW=["hash","host","hostname","href","origin","password","pathname","port","protocol","search","target","download","rel","hreflang","type","username","ping","referrerPolicy","text"],xW=U(gW),vW=["alt","coords","download","hash","host","hostname","href","origin","password","pathname","port","protocol","rel","search","shape","target","username","ping","referrerPolicy"],mW=U(vW),hW=["autoplay","controls","crossOrigin","currentSrc","currentTime","defaultMuted","defaultPlaybackRate","duration","ended","loop","muted","networkState","paused","playbackRate","preload","readyState","seeking","src","volume","preservesPitch"],DW=U(hW),EW=(W)=>DW(W),uW=["disabled","name","type","value","formAction","formEnctype","formMethod","formNoValidate","formTarget","popoverTargetAction"],pW=U(uW),iW=["value"],cW=U(iW),dW=["height","src","type","width","align","name"],nW=U(dW),oW=["disabled","name","type","validationMessage","willValidate"],lW=U(oW),sW=["acceptCharset","action","autocomplete","encoding","enctype","length","method","name","noValidate","target","rel"],rW=U(sW),aW=["allow","allowFullscreen","height","name","referrerPolicy","src","srcdoc","width","align","frameBorder","longDesc","marginHeight","marginWidth","scrolling","sandbox"],tW=U(aW),eW=["alt","crossOrigin","decoding","height","isMap","loading","naturalHeight","naturalWidth","referrerPolicy","sizes","src","srcset","useMap","width","align","border","complete","hspace","longDesc","lowsrc","name","vspace","x","y","fetchPriority"],W1=U(eW),Z1=["accept","alt","autocomplete","checked","defaultChecked","defaultValue","dirName","disabled","height","indeterminate","max","maxLength","min","minLength","multiple","name","pattern","placeholder","readOnly","required","selectionDirection","selectionEnd","selectionStart","size","src","step","type","value","valueAsNumber","width","align","capture","formAction","formEnctype","formMethod","formNoValidate","formTarget","useMap","validationMessage","willValidate","popoverTargetAction"],$1=U(Z1),Q1=["htmlFor"],q1=U(Q1),z1=["value","type"],F1=U(z1),J1=["as","crossOrigin","disabled","fetchPriority","href","hreflang","imageSizes","imageSrcset","integrity","media","referrerPolicy","rel","type","charset","rev","target","sizes"],X1=U(J1),G1=["name"],U1=U(G1),V1=["high","low","max","min","optimum","value"],D1=U(V1),O1=["cite","dateTime"],XW=U(O1),A1=["reversed","start","type","compact"],C1=U(A1),N1=["data","height","name","type","useMap","width","validationMessage","willValidate","align","archive","border","code","codeBase","codeType","declare","hspace","standby","vspace"],R1=U(N1),f1=["disabled","label"],I1=U(f1),P1=["defaultSelected","disabled","index","label","selected","text","value"],j1=U(P1),B1=["defaultValue","name","type","value","htmlFor","validationMessage","willValidate"],K1=U(B1),w1=["max","position","value"],H1=U(w1),Y1=["cite"],GW=U(Y1),L1=(W)=>Y(W),M1=["async","crossOrigin","defer","fetchPriority","integrity","noModule","referrerPolicy","src","text","type","charset"],b1=H()(M1,{event:(W)=>W.event,htmlFor:(W)=>W.htmlFor}),S1=(W)=>({...Y(W),...b1(W)}),y1=["autocomplete","disabled","length","multiple","name","required","selectedIndex","size","type","value","validationMessage","willValidate"],k1=U(y1),_1=["name"],T1=U(_1),g1=["height","media","sizes","src","srcset","type","width"],x1=U(g1),v1=["align"],m1=U(v1),h1=["abbr","cellIndex","colSpan","headers","rowSpan","scope","align","axis","bgColor","ch","chOff","height","noWrap","vAlign","width"],UW=U(h1),E1=["span","align","ch","chOff","vAlign","width"],VW=U(E1),u1=["align","bgColor","border","cellPadding","cellSpacing","frame","rules","summary","width"],p1=U(u1),i1=["rowIndex","sectionRowIndex","align","bgColor","ch","chOff","vAlign"],c1=U(i1),d1=["align","ch","chOff","vAlign"],o=U(d1),n1=(W)=>Y(W),o1=["autocomplete","cols","defaultValue","dirName","disabled","maxLength","minLength","name","placeholder","readOnly","required","rows","selectionDirection","selectionEnd","selectionStart","value","wrap","textLength","validationMessage","willValidate"],l1=U(o1),s1=["dateTime"],r1=U(s1),a1=["default","kind","label","readyState","src","srclang"],t1=U(a1),e1=["height","poster","videoHeight","videoWidth","width","playsInline"],W3=H()(e1),Z3=(W)=>({...DW(W),...W3(W)}),$3=["clear"],Q3=U($3),q3=["href","target"],z3=U(q3),F3=["aLink","background","bgColor","link","text","vLink"],J3=U(F3),X3=["compact"],G3=U(X3),U3=["open"],V3=U(U3),D3=["open","returnValue"],O3=U(D3),A3=["align"],C3=U(A3),N3=(W)=>Y(W),R3=["align"],b=U(R3),f3=["align","color","noShade","size","width"],I3=U(f3),P3=["version"],j3=U(P3),B3=(W)=>Y(W),K3=["content","httpEquiv","name","scheme"],w3=U(K3),H3=["align"],Y3=U(H3),L3=(W)=>Y(W),M3=["width"],b3=U(M3),S3=(W)=>Y(W),y3=["media","type","disabled"],k3=U(y3),_3=["text"],T3=U(_3),g3=["compact","type"],x3=U(g3),v3={A:xW,AREA:mW,AUDIO:EW,BASE:z3,BLOCKQUOTE:GW,Q:GW,BODY:J3,BR:Q3,BUTTON:pW,CANVAS:Y,CAPTION:m1,CITE:L1,COL:VW,COLGROUP:VW,DATA:cW,DETAILS:V3,DIALOG:O3,DIV:C3,DL:G3,EMBED:nW,FIELDSET:lW,FORM:rW,H1:b,H2:b,H3:b,H4:b,H5:b,H6:b,HEAD:N3,HR:I3,HTML:j3,IFRAME:tW,IMG:W1,INPUT:$1,LABEL:q1,LI:F1,LINK:X1,MAP:U1,MENU:B3,META:w3,METER:D1,INS:XW,DEL:XW,OBJECT:R1,OL:C1,OPTGROUP:I1,OPTION:j1,OUTPUT:K1,P:Y3,PICTURE:L3,PRE:b3,PROGRESS:H1,SCRIPT:S1,SELECT:k1,SLOT:T1,SOURCE:x1,SPAN:S3,STYLE:k3,TABLE:p1,TBODY:o,THEAD:o,TFOOT:o,TD:UW,TH:UW,TEMPLATE:n1,TEXTAREA:l1,TIME:r1,TITLE:T3,TR:c1,TRACK:t1,UL:x3,VIDEO:Z3};function v(W){let Z=W.tagName.toUpperCase(),$=v3[Z];if($)return $(W);throw Error(`Unexpected HTML element tag: ${W.tagName} (update .web/custom/serialize.ts)`)}var m3=(W)=>v(W.target),_=(W)=>W.relatedTarget?v(W.relatedTarget):null;function I(W,Z){return H()(W,{target:m3,...Z||{}})}var K=["target","bubbles","cancelable","defaultPrevented","eventPhase","isTrusted","timeStamp","type"],m=[...K,"detail"],h=[...m,"altKey","button","buttons","clientX","clientY","ctrlKey","metaKey","movementX","movementY","pageX","pageY","screenX","screenY","shiftKey"],h3=[...h,"pointerId","pressure","tangentialPressure","tiltX","tiltY","twist","width","height","pointerType","isPrimary"],E3=I(K),u3=I(m),p3=I(h,{relatedTarget:_}),i3=I(K,{clipboardData:(W)=>OW(W.clipboardData)}),c3=I([...K,"data"]),d3=I(h,{relatedTarget:_,dataTransfer:(W)=>OW(W.dataTransfer)}),n3=I(h3,{relatedTarget:_}),o3=I(K,{relatedTarget:_}),l3=I(K),s3=I(K),r3=I(K),a3=I([...m,"altKey","ctrlKey","code","key","locale","location","metaKey","repeat","shiftKey"]),t3=I([...m,"altKey","ctrlKey","metaKey","shiftKey","changedTouches","targetTouches","touches"],{changedTouches:(W)=>l(W.changedTouches),targetTouches:(W)=>l(W.targetTouches),touches:(W)=>l(W.touches)}),e3=I([...h,"deltaMode","deltaX","deltaY","deltaZ"],{relatedTarget:_}),WZ=I([...K,"animationName","elapsedTime","pseudoElement"]),ZZ=I([...K,"oldState","newState"]),$Z=I([...K,"elapsedTime","propertyName","pseudoElement"]);function l(W){return Array.from(W).map((Z)=>({target:v(Z.target),identifier:Z.identifier,screenX:Z.screenX,screenY:Z.screenY,clientX:Z.clientX,clientY:Z.clientY,pageX:Z.pageX,pageY:Z.pageY}))}function OW(W){if(!W)return null;let Z=[];if(W.items)for(let $=0;$<W.items.length;$++){let Q=W.items[$];Z.push({kind:Q.kind,type:Q.type})}return{drop_effect:W.dropEffect,effect_allowed:W.effectAllowed,items:Z,types:Array.from(W.types||[])}}var P={};function j(W,Z,$){for(let Q of Z)W[Q]=$}j(P,["pointerdown","pointermove","pointerup","pointercancel","gotpointercapture","lostpointercapture","pointerenter","pointerleave","pointerover","pointerout"],n3);j(P,["click","contextmenu","dblclick","mousedown","mouseenter","mouseleave","mousemove","mouseout","mouseover","mouseup"],p3);j(P,["drag","dragend","dragenter","dragexit","dragleave","dragover","dragstart","drop"],d3);j(P,["keydown","keypress","keyup"],a3);j(P,["focus","blur"],o3);j(P,["change","input"],r3);j(P,["invalid"],s3);j(P,["reset","submit"],l3);j(P,["copy","cut","paste"],i3);j(P,["compositionend","compositionstart","compositionupdate"],c3);j(P,["touchcancel","touchend","touchmove","touchstart"],t3);j(P,["scroll"],u3);j(P,["wheel"],e3);j(P,["animationstart","animationend","animationiteration"],WZ);j(P,["transitionend"],$Z);j(P,["toggle"],ZZ);function s(W){if(W&&typeof W==="object"&&"nativeEvent"in W&&typeof W.isDefaultPrevented==="function"){let Z=W;if(typeof Z.type!=="string")return W;let $=P[Z.type.toLowerCase()];if($)return $(Z);return E3(Z)}return W}function T(W){let Z=new Map,$=[],Q=[],q=[],z=[],G=0;function F(X){if(X==null||typeof X==="number"||typeof X==="string"||typeof X==="boolean")return X;let D=G++,O=Z.get(X);if(O!==void 0)return $.push(D),O;if(Z.set(X,D),X instanceof Date)return Q.push(D),X.getTime();if(Array.isArray(X)){let C=X.length,V=Array(C);for(let A=0;A<C;A++)V[A]=F(X[A]);return V}if(X instanceof Map){z.push(D);let C={};for(let[V,A]of X.entries())C[String(V)]=F(A);return C}if(X instanceof Set){q.push(D);let C=X.size,V=Array(C),A=0;for(let N of X)V[A]=F(N),A+=1;return V}if(typeof X==="object"){let C={},V=Object.keys(X);for(let A=0;A<V.length;A++){let N=V[A];C[N]=F(X[N])}return C}throw Error(`Unsupported value in serialization: ${X}`)}let J=F(W);return[[$,Q,q,z],J]}function r(W,Z){let[[$,Q,q,z],G]=W,F=new Set($),J=new Set(Q),X=new Set(q),D=new Set(z),O=[];function C(V){let A=O.length;if(F.has(A))return O.push(null),O[V];if(J.has(A)){let N=new Date(V);return O.push(N),N}if(V==null||typeof V==="number"||typeof V==="string"||typeof V==="boolean"){if(Z?.coerceNullsToUndefined)return V??void 0;return V}if(Array.isArray(V)){if(X.has(A)){let f=new Set;O.push(f);for(let B=0;B<V.length;B++)f.add(C(V[B]));return f}let N=V.length,R=Array(N);O.push(R);for(let f=0;f<N;f++)R[f]=C(V[f]);return R}if(typeof V==="object"){if(D.has(A)){let f=new Map;O.push(f);let B=Object.keys(V);for(let c=0;c<B.length;c++){let $W=B[c];f.set($W,C(V[$W]))}return f}let N={};O.push(N);let R=Object.keys(V);for(let f=0;f<R.length;f++){let B=R[f];N[B]=C(V[B])}return N}throw Error(`Unsupported value in deserialization: ${V}`)}return C(G)}import{io as JZ}from"socket.io-client";class L extends Error{constructor(W){super(W);this.name="PulseChannelResetError"}}function QZ(){if(typeof crypto<"u"&&typeof crypto.randomUUID==="function")return crypto.randomUUID().replace(/-/g,"");return Math.random().toString(16).slice(2)+Math.random().toString(16).slice(2)}function qZ(W){if(W instanceof Error)return W.message;if(typeof W==="string")return W;try{return JSON.stringify(W)}catch{return String(W)}}function zZ(W){return typeof W.responseTo==="string"}function FZ(W){return typeof W.event==="string"}class AW{client;id;handlers=new Map;pending=new Map;backlog=[];closed=!1;constructor(W,Z){this.client=W;this.id=Z}emit(W,Z){this.ensureOpen(),this.client.sendChannelMessage({type:"channel_message",channel:this.id,event:W,payload:Z})}async request(W,Z){this.ensureOpen();let $=QZ();return new Promise((Q,q)=>{this.pending.set($,{resolve:Q,reject:q}),this.client.sendChannelMessage({type:"channel_message",channel:this.id,event:W,payload:Z,requestId:$}).catch((z)=>{this.pending.delete($),q(z)})})}on(W,Z){this.ensureOpen();let $=this.handlers.get(W);if(!$)$=new Set,this.handlers.set(W,$);return $.add(Z),this.flushBacklog(W),()=>{let Q=this.handlers.get(W);if(!Q)return;if(Q.delete(Z),Q.size===0)this.handlers.delete(W)}}handleServerMessage(W){if(zZ(W))return this.resolvePending(W),this.closed;if(this.closed)return!0;if(!FZ(W))return this.closed;if(W.event==="__close__")return this.close(new L("Channel closed by server")),!0;if(W.requestId)this.dispatchRequest(W);else this.dispatchEvent(W);return this.closed}handleDisconnect(W){this.close(W)}dispose(W){this.close(W)}ensureOpen(){if(this.closed)throw new L("Channel is closed")}flushBacklog(W){if(this.backlog.length===0)return;let Z=[];for(let $ of this.backlog)if($.event===W)this.dispatchEvent($);else Z.push($);this.backlog=Z}dispatchEvent(W){let Z=this.handlers.get(W.event);if(!Z||Z.size===0){this.backlog.push(W);return}for(let $ of Z)try{let Q=$(W.payload);if(Q&&typeof Q.then==="function")Q.catch((q)=>{console.error("Pulse channel handler error",q)})}catch(Q){console.error("Pulse channel handler error",Q)}}async dispatchRequest(W){let Z=this.handlers.get(W.event),$,Q;if(Z&&Z.size>0)for(let q of Z)try{let z=q(W.payload);if($=await Promise.resolve(z),$!==void 0)break}catch(z){Q=z;break}if(Q){await this.client.sendChannelMessage({type:"channel_message",channel:this.id,event:void 0,responseTo:W.requestId,error:qZ(Q)});return}await this.client.sendChannelMessage({type:"channel_message",channel:this.id,event:void 0,responseTo:W.requestId,payload:$})}resolvePending(W){let Z=W.responseTo?this.pending.get(W.responseTo):void 0;if(!Z)return;if(this.pending.delete(W.responseTo),W.error!==void 0&&W.error!==null)Z.reject(new L(String(W.error)));else Z.resolve(W.payload)}close(W){if(this.closed)return;this.closed=!0;for(let Z of this.pending.values())Z.reject(W);this.pending.clear(),this.handlers.clear(),this.backlog=[]}}function CW(W,Z){return new AW(W,Z)}class E{url;renderId;frameworkNavigate;activeViews;socket=null;messageQueue;connectionListeners=new Set;serverErrors=new Map;serverErrorListeners=new Set;channels=new Map;constructor(W,Z,$){this.url=W;this.renderId=Z;this.frameworkNavigate=$;this.socket=null,this.activeViews=new Map,this.messageQueue=[]}isConnected(){return this.socket?.connected??!1}async connect(){if(this.socket)return;return new Promise((W,Z)=>{let $=JZ(this.url,{transports:["websocket","webtransport"],auth:{renderId:this.renderId}});this.socket=$,$.on("connect",()=>{console.log("[SocketIOTransport] Connected:",this.socket?.id);for(let[Q,q]of this.activeViews)$.emit("message",T({type:"mount",path:Q,routeInfo:q.routeInfo}));for(let Q of this.messageQueue){if(Q.type==="mount"&&this.activeViews.has(Q.path))continue;if(Q.type==="navigate")continue;$.emit("message",T(Q))}this.messageQueue=[],this.notifyConnectionListeners(!0),W()}),$.on("connect_error",(Q)=>{console.error("[SocketIOTransport] Connection failed:",Q),this.notifyConnectionListeners(!1),Z(Q)}),$.on("disconnect",()=>{console.log("[SocketIOTransport] Disconnected"),this.handleTransportDisconnect(),this.notifyConnectionListeners(!1)}),$.on("message",(Q)=>this.handleServerMessage(r(Q,{coerceNullsToUndefined:!0})))})}onConnectionChange(W){return this.connectionListeners.add(W),W(this.isConnected()),()=>{this.connectionListeners.delete(W)}}notifyConnectionListeners(W){for(let Z of this.connectionListeners)Z(W)}onServerError(W){this.serverErrorListeners.add(W);for(let[Z,$]of this.serverErrors)W(Z,$);return()=>{this.serverErrorListeners.delete(W)}}notifyServerError(W,Z){for(let $ of this.serverErrorListeners)$(W,Z)}async sendMessage(W){if(this.isConnected())this.socket.emit("message",T(W));else this.messageQueue.push(W)}async sendChannelMessage(W){await this.sendMessage(W)}mountView(W,Z){if(this.activeViews.has(W))throw Error(`Path ${W} is already mounted`);this.activeViews.set(W,Z),this.sendMessage({type:"mount",path:W,routeInfo:Z.routeInfo})}async navigate(W,Z){await this.sendMessage({type:"navigate",path:W,routeInfo:Z})}unmount(W){this.sendMessage({type:"unmount",path:W}),this.activeViews.delete(W)}disconnect(){this.socket?.disconnect(),this.socket=null,this.messageQueue=[],this.connectionListeners.clear(),this.activeViews.clear(),this.serverErrors.clear(),this.serverErrorListeners.clear();for(let{bridge:W}of this.channels.values())W.dispose(new L("Client disconnected"));this.channels.clear()}handleServerMessage(W){switch(W.type){case"vdom_init":{let Z=this.activeViews.get(W.path);if(!Z)return;if(Z)Z.onInit(W.vdom,W.callbacks,W.render_props,W.css_refs);if(this.serverErrors.has(W.path))this.serverErrors.delete(W.path),this.notifyServerError(W.path,null);break}case"vdom_update":{let Z=this.activeViews.get(W.path);if(!Z)return;if(Z.onUpdate(W.ops),this.serverErrors.has(W.path))this.serverErrors.delete(W.path),this.notifyServerError(W.path,null);break}case"server_error":{if(!this.activeViews.has(W.path))return;this.serverErrors.set(W.path,W.error),this.notifyServerError(W.path,W.error);break}case"api_call":{this.performApiCall(W);break}case"navigate_to":{let Z=!!W.replace,$=W.path||"";if($.startsWith("//"))$=`${window.location.protocol}${$}`;if(/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test($))if($.startsWith("http://")||$.startsWith("https://"))try{let q=new URL($);if(q.origin===window.location.origin){let z=`${q.pathname}${q.search}${q.hash}`;this.frameworkNavigate(z,{replace:Z})}else if(Z)window.location.replace($);else window.location.assign($)}catch{if(Z)window.location.replace($);else window.location.assign($)}else if(Z)window.location.replace($);else window.location.assign($);else this.frameworkNavigate($,{replace:Z});break}case"channel_message":{this.routeChannelMessage(W);break}default:console.error("Unexpected message:",W)}}async performApiCall(W){try{let Z=await fetch(W.url,{method:W.method||"GET",headers:{...W.headers||{},...W.body!=null&&!("content-type"in(W.headers||{}))?{"content-type":"application/json"}:{}},body:W.body!=null?typeof W.body==="string"?W.body:JSON.stringify(W.body):void 0,credentials:W.credentials||"include"}),$={};Z.headers.forEach((G,F)=>$[F]=G);let Q=null;if((Z.headers.get("content-type")||"").includes("application/json"))Q=await Z.json().catch(()=>null);else Q=await Z.text().catch(()=>null);let z={type:"api_result",id:W.id,ok:Z.ok,status:Z.status,headers:$,body:Q};await this.sendMessage(z)}catch(Z){let $={type:"api_result",id:W.id,ok:!1,status:0,headers:{},body:{error:String(Z)}};await this.sendMessage($)}}async invokeCallback(W,Z,$){await this.sendMessage({type:"callback",path:W,callback:Z,args:$.map(s)})}acquireChannel(W){let Z=this.ensureChannelEntry(W);return Z.refCount+=1,Z.bridge}releaseChannel(W){let Z=this.channels.get(W);if(!Z)return;if(Z.refCount=Math.max(0,Z.refCount-1),Z.refCount===0)Z.bridge.dispose(new L("Channel released")),this.channels.delete(W)}ensureChannelEntry(W){let Z=this.channels.get(W);if(!Z)Z={bridge:CW(this,W),refCount:0},this.channels.set(W,Z);return Z}routeChannelMessage(W){let Z=this.ensureChannelEntry(W.channel);if(Z.bridge.handleServerMessage(W)&&Z.refCount===0)this.channels.delete(W.channel)}handleTransportDisconnect(){for(let W of this.channels.values())W.bridge.handleDisconnect(new L("Connection lost"))}}import{useLocation as XZ,useParams as GZ,useNavigate as UZ}from"react-router";import{jsx as S,jsxs as u}from"react/jsx-runtime";var fW=NW(null),IW=NW(null),i=()=>{let W=RW(fW);if(!W)throw Error("usePulseClient must be used within a PulseProvider");return W},VZ=(W)=>{let Z=RW(IW);if(!Z)throw Error("usePulsePrerender must be used within a PulseProvider");let $=Z.views[W];if(!$)throw Error(`No prerender found for '${W}'`);return $},e=typeof window<"u";function DZ({children:W,config:Z,prerender:$}){let[Q,q]=a(!0),z=UZ(),{renderId:G}=$,F=t(()=>new E(Z.serverAddress,G,z),[Z.serverAddress,z,G]);return p(()=>F.onConnectionChange(q),[F]),p(()=>{if(e)return F.connect(),()=>F.disconnect()},[F]),S(fW.Provider,{value:F,children:u(IW.Provider,{value:$,children:[!Q&&S("div",{style:{position:"fixed",bottom:"20px",right:"20px",backgroundColor:"red",color:"white",padding:"10px",borderRadius:"5px",zIndex:1000},children:"Failed to connect to the server."}),W]})})}function OZ({externalComponents:W,path:Z,cssModules:$}){let Q=i(),q=VZ(Z),z=q.vdom,G=t(()=>new x(Q,Z,W,$,q.callbacks,q.render_props,q.css_refs),[Q,Z,W,$,q]),[F,J]=a(()=>G.renderNode(z)),[X,D]=a(null),O=XZ(),C=GZ(),V=t(()=>{let{"*":A="",...N}=C,R=new URLSearchParams(O.search);return{hash:O.hash,pathname:O.pathname,query:O.search,queryParams:Object.fromEntries(R.entries()),pathParams:N,catchall:A.length>0?A.split("/"):[]}},[O.hash,O.pathname,O.search,JSON.stringify(C)]);if(p(()=>{if(e){Q.mountView(Z,{routeInfo:V,onInit:(N,R,f,B)=>{G.setCallbacks(R),G.setRenderProps(f),G.setCssRefs(B),J(G.renderNode(N))},onUpdate:(N)=>{J((R)=>R==null?R:n(R,N,G))}});let A=Q.onServerError((N,R)=>{if(N===Z)D(R)});return()=>{A(),Q.unmount(Z)}}},[Q]),p(()=>{if(e)Q.navigate(Z,V)},[Q,Z,V]),X)return S(AZ,{error:X});return F}function AZ({error:W}){return u("div",{style:{padding:16,border:"1px solid #e00",background:"#fff5f5",color:"#900",fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',whiteSpace:"pre-wrap"},children:[u("div",{style:{fontWeight:700,marginBottom:8},children:["Server Error during ",W.phase]}),W.message&&S("div",{children:W.message}),W.stack&&u("details",{open:!0,style:{marginTop:8},children:[S("summary",{children:"Stack trace"}),S("pre",{style:{margin:0},children:W.stack})]})]})}import{useEffect as CZ,useMemo as NZ}from"react";function RZ(W){let Z=i(),$=NZ(()=>{if(!W)throw Error("usePulseChannel requires a non-empty channelId");return Z.acquireChannel(W)},[Z,W]);return CZ(()=>{return()=>{Z.releaseChannel(W)}},[Z,W]),$}import{forwardRef as fZ,useCallback as IZ}from"react";import{jsx as jZ}from"react/jsx-runtime";var PZ=fZ(function({onSubmit:Z,action:$,...Q},q){return jZ("form",{...Q,action:$,ref:q,onSubmit:IZ((z)=>PW({event:z,action:$,onSubmit:Z}),[$,Z])})});async function PW({event:W,action:Z,onSubmit:$,formData:Q,force:q}){if($?.(W),!q&&W.defaultPrevented)return;let z=W.currentTarget;W.preventDefault();let G=W.nativeEvent;if(!Q)Q=new FormData(z,G.submitter);let F=new URL(Z,window.location.href);try{await fetch(F,{method:"POST",credentials:"include",body:Q})}catch(J){throw J}}import{io as BZ}from"socket.io-client";class jW{url;socket=null;listener=null;messageQueue=[];connectionListeners=new Set;constructor(W){this.url=W}connect(W){return this.listener=W,new Promise((Z,$)=>{this.socket=BZ(this.url,{transports:["websocket"]}),this.socket.on("connect",()=>{console.log("[SocketIOTransport] Connected:",this.socket?.id);for(let Q of this.messageQueue)this.socket?.emit("message",Q);this.messageQueue=[],this.notifyConnectionListeners(!0),Z()}),this.socket.on("connect_error",(Q)=>{console.error("[SocketIOTransport] Connection failed:",Q),this.notifyConnectionListeners(!1),$(Q)}),this.socket.on("disconnect",()=>{console.log("[SocketIOTransport] Disconnected"),this.notifyConnectionListeners(!1)}),this.socket.on("message",(Q)=>{this.listener?.(Q)})})}disconnect(){this.socket?.disconnect(),this.socket=null,this.listener=null,this.messageQueue=[],this.connectionListeners.clear()}async sendMessage(W){if(this.isConnected())this.socket.emit("message",W);else this.messageQueue.push(W)}isConnected(){return this.socket?.connected||!1}onConnectionChange(W){return this.connectionListeners.add(W),W(this.isConnected()),()=>{this.connectionListeners.delete(W)}}notifyConnectionListeners(W){for(let Z of this.connectionListeners)Z(W)}}function KZ({params:W,request:Z}){let{"*":$="",...Q}=W,q=new URL(Z.url);return{hash:q.hash,pathname:q.pathname,query:q.search,queryParams:Object.fromEntries(q.searchParams.entries()),pathParams:Q,catchall:$.length>1?$.split("/"):[]}}function wZ(W){if(W===null||typeof W!=="object")return!1;let Z=Object.getPrototypeOf(W);return Z===Object.prototype||Z===null}function WW(W){return typeof W==="function"||typeof W==="symbol"||typeof W>"u"}async function HZ(W){let Z=await W.arrayBuffer();return Array.from(new Uint8Array(Z))}async function YZ(W){return await g(W,{seen:new WeakMap,nextId:1})}function LZ(W,Z){if(W.seen.get(Z)!==void 0)return null;let Q=W.nextId++;return W.seen.set(Z,Q),Q}async function g(W,Z){if(W===null||typeof W!=="object")return W;if(W instanceof Date)return{__t:"datetime",timestamp:W.getTime()};if(W instanceof FormData){let F=LZ(Z,W);if(F===null)return{__t:"ref",id:Z.seen.get(W)};let J={};for(let[D,O]of W.entries()){let C=await g(O,Z);if(C===void 0)continue;if(Object.prototype.hasOwnProperty.call(J,D)){let V=J[D];if(Array.isArray(V))V.push(C);else J[D]=[V,C]}else J[D]=C}return{__t:"formdata",fields:J,__id:F}}if(W instanceof File){let F=W,J=await HZ(W);return{__t:"file",name:F.name,type:F.type,size:F.size,lastModified:F.lastModified,content:J}}let $=W,Q=Z.seen.get($);if(Q!==void 0)return{__t:"ref",id:Q};let q=Z.nextId++;if(Z.seen.set($,q),Array.isArray(W)){let J=(await Promise.all(W.map((D)=>g(D,Z)))).filter((D)=>D!==void 0);return{__t:"array",__id:q,items:J}}let z={};if(wZ(W))for(let F of Object.keys(W)){let J=W[F];if(WW(J))continue;let X=await g(J,Z);if(X!==void 0)z[F]=X}else for(let F in W){let J=W[F];if(WW(J))continue;let X=await g(J,Z);if(X!==void 0)z[F]=X}return{__t:"object",__id:q,props:z}}function MZ(W){return y(W)}function y(W){if(W===null||typeof W!=="object")return W;let Z=W,$=Z.__t;if($==="datetime"){let q=Z.timestamp;return new Date(q)}if($==="file"){let q=Z.content;if(Array.isArray(q))return{...Z,content:new Uint8Array(q)};return Z}if($==="formdata"){let q=Z.fields,z={};for(let G of Object.keys(q)){let F=q[G];if(Array.isArray(F))z[G]=F.map((J)=>y(J));else z[G]=y(F)}return{__t:"formdata",fields:z}}if($==="array")return Z.items.map((z)=>y(z));if($==="object"){let q=Z.props,z={};for(let G of Object.keys(q))z[G]=y(q[G]);return z}if($==="ref")return Z;let Q={};for(let q of Object.keys(Z))Q[q]=y(Z[q]);return Q}function bZ(W){return ZW(W,new WeakSet)}function ZW(W,Z){if(W===null||typeof W!=="object")return W;if(Z.has(W))return;if(Z.add(W),Array.isArray(W))return W.map((Q)=>ZW(Q,Z)).filter((Q)=>Q!==void 0);let $={};for(let Q in W){let q=W[Q];if(WW(q))continue;let z=ZW(q,Z);if(z!==void 0)$[Q]=z}return $}export{i as usePulseClient,RZ as usePulseChannel,PW as submitForm,T as serialize,KZ as extractServerRouteInfo,s as extractEvent,YZ as encodeForWire,r as deserialize,MZ as decodeFromWire,bZ as cleanForSerialization,n as applyReactTreeUpdates,x as VDOMRenderer,jW as SocketIOTransport,YW as RenderLazy,OZ as PulseView,E as PulseSocketIOClient,DZ as PulseProvider,PZ as PulseForm,L as PulseChannelResetError};
2
2
 
3
- //# debugId=618B63A0B4F1253264756E2164756E21
3
+ //# debugId=E15FD8696B30CE4A64756E2164756E21