pywire 0.1.1__py3-none-any.whl → 0.1.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. pywire/__init__.py +2 -0
  2. pywire/cli/__init__.py +1 -0
  3. pywire/cli/generators.py +48 -0
  4. pywire/cli/main.py +309 -0
  5. pywire/cli/tui.py +563 -0
  6. pywire/cli/validate.py +26 -0
  7. pywire/client/.prettierignore +8 -0
  8. pywire/client/.prettierrc +7 -0
  9. pywire/client/build.mjs +73 -0
  10. pywire/client/eslint.config.js +46 -0
  11. pywire/client/package.json +39 -0
  12. pywire/client/pnpm-lock.yaml +2971 -0
  13. pywire/client/src/core/app.ts +263 -0
  14. pywire/client/src/core/dom-updater.test.ts +78 -0
  15. pywire/client/src/core/dom-updater.ts +321 -0
  16. pywire/client/src/core/index.ts +5 -0
  17. pywire/client/src/core/transport-manager.test.ts +179 -0
  18. pywire/client/src/core/transport-manager.ts +159 -0
  19. pywire/client/src/core/transports/base.ts +122 -0
  20. pywire/client/src/core/transports/http.ts +142 -0
  21. pywire/client/src/core/transports/index.ts +13 -0
  22. pywire/client/src/core/transports/websocket.ts +97 -0
  23. pywire/client/src/core/transports/webtransport.ts +149 -0
  24. pywire/client/src/dev/dev-app.ts +93 -0
  25. pywire/client/src/dev/error-trace.test.ts +97 -0
  26. pywire/client/src/dev/error-trace.ts +76 -0
  27. pywire/client/src/dev/index.ts +4 -0
  28. pywire/client/src/dev/status-overlay.ts +63 -0
  29. pywire/client/src/events/handler.test.ts +318 -0
  30. pywire/client/src/events/handler.ts +454 -0
  31. pywire/client/src/pywire.core.ts +22 -0
  32. pywire/client/src/pywire.dev.ts +27 -0
  33. pywire/client/tsconfig.json +17 -0
  34. pywire/client/vitest.config.ts +15 -0
  35. pywire/compiler/__init__.py +6 -0
  36. pywire/compiler/ast_nodes.py +304 -0
  37. pywire/compiler/attributes/__init__.py +6 -0
  38. pywire/compiler/attributes/base.py +24 -0
  39. pywire/compiler/attributes/conditional.py +37 -0
  40. pywire/compiler/attributes/events.py +55 -0
  41. pywire/compiler/attributes/form.py +37 -0
  42. pywire/compiler/attributes/loop.py +75 -0
  43. pywire/compiler/attributes/reactive.py +34 -0
  44. pywire/compiler/build.py +28 -0
  45. pywire/compiler/build_artifacts.py +342 -0
  46. pywire/compiler/codegen/__init__.py +5 -0
  47. pywire/compiler/codegen/attributes/__init__.py +6 -0
  48. pywire/compiler/codegen/attributes/base.py +19 -0
  49. pywire/compiler/codegen/attributes/events.py +35 -0
  50. pywire/compiler/codegen/directives/__init__.py +6 -0
  51. pywire/compiler/codegen/directives/base.py +16 -0
  52. pywire/compiler/codegen/directives/path.py +53 -0
  53. pywire/compiler/codegen/generator.py +2341 -0
  54. pywire/compiler/codegen/template.py +2178 -0
  55. pywire/compiler/directives/__init__.py +7 -0
  56. pywire/compiler/directives/base.py +20 -0
  57. pywire/compiler/directives/component.py +33 -0
  58. pywire/compiler/directives/context.py +93 -0
  59. pywire/compiler/directives/layout.py +49 -0
  60. pywire/compiler/directives/no_spa.py +24 -0
  61. pywire/compiler/directives/path.py +71 -0
  62. pywire/compiler/directives/props.py +88 -0
  63. pywire/compiler/exceptions.py +19 -0
  64. pywire/compiler/interpolation/__init__.py +6 -0
  65. pywire/compiler/interpolation/base.py +28 -0
  66. pywire/compiler/interpolation/jinja.py +272 -0
  67. pywire/compiler/parser.py +750 -0
  68. pywire/compiler/paths.py +29 -0
  69. pywire/compiler/preprocessor.py +43 -0
  70. pywire/core/wire.py +119 -0
  71. pywire/py.typed +0 -0
  72. pywire/runtime/__init__.py +7 -0
  73. pywire/runtime/aioquic_server.py +194 -0
  74. pywire/runtime/app.py +901 -0
  75. pywire/runtime/compile_error_page.py +195 -0
  76. pywire/runtime/debug.py +203 -0
  77. pywire/runtime/dev_server.py +433 -0
  78. pywire/runtime/dev_server.py.broken +268 -0
  79. pywire/runtime/error_page.py +64 -0
  80. pywire/runtime/error_renderer.py +23 -0
  81. pywire/runtime/escape.py +23 -0
  82. pywire/runtime/files.py +40 -0
  83. pywire/runtime/helpers.py +97 -0
  84. pywire/runtime/http_transport.py +253 -0
  85. pywire/runtime/loader.py +272 -0
  86. pywire/runtime/logging.py +72 -0
  87. pywire/runtime/page.py +384 -0
  88. pywire/runtime/pydantic_integration.py +52 -0
  89. pywire/runtime/router.py +229 -0
  90. pywire/runtime/server.py +25 -0
  91. pywire/runtime/style_collector.py +31 -0
  92. pywire/runtime/upload_manager.py +76 -0
  93. pywire/runtime/validation.py +449 -0
  94. pywire/runtime/websocket.py +665 -0
  95. pywire/runtime/webtransport_handler.py +195 -0
  96. pywire/static/pywire.core.min.js +3 -0
  97. pywire/static/pywire.dev.min.js +20 -0
  98. {pywire-0.1.1.dist-info → pywire-0.1.3.dist-info}/METADATA +1 -1
  99. pywire-0.1.3.dist-info/RECORD +106 -0
  100. pywire-0.1.1.dist-info/RECORD +0 -9
  101. {pywire-0.1.1.dist-info → pywire-0.1.3.dist-info}/WHEEL +0 -0
  102. {pywire-0.1.1.dist-info → pywire-0.1.3.dist-info}/entry_points.txt +0 -0
  103. {pywire-0.1.1.dist-info → pywire-0.1.3.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,195 @@
1
+ """WebTransport handler using ASGI standard.
2
+
3
+ Handles 'webtransport' scope type from Hypercorn.
4
+ """
5
+
6
+ import json
7
+ from typing import Any, Dict, Set
8
+
9
+ from pywire.runtime.page import BasePage
10
+
11
+
12
+ class WebTransportHandler:
13
+ """Handles WebTransport connections."""
14
+
15
+ def __init__(self, app: Any) -> None:
16
+ self.app = app
17
+ # Store active sessions/connections
18
+ # For WebTransport, the 'scope' is the connection identifier
19
+ self.active_connections: Set[Any] = set()
20
+
21
+ # Map connection -> current page instance
22
+ self.connection_pages: Dict[Any, BasePage] = {}
23
+
24
+ async def handle(self, scope: dict[str, Any], receive: Any, send: Any) -> None:
25
+ """Handle ASGI webtransport scope."""
26
+ print("DEBUG: WebTransport handler started")
27
+ # Active streams buffer: stream_id -> bytes
28
+ streams: Dict[int, bytearray] = {}
29
+
30
+ # 1. Wait for connection request
31
+ try:
32
+ message = await receive()
33
+ print(f"DEBUG: WebTransport received initial message: {message['type']}")
34
+ if message["type"] != "webtransport.connect":
35
+ print(f"DEBUG: Unexpected message type: {message['type']}")
36
+ return
37
+ except Exception as e:
38
+ print(f"DEBUG: Error receiving connect message: {e}")
39
+ return
40
+
41
+ # 2. Accept connection
42
+ await send({"type": "webtransport.accept"})
43
+ print("DEBUG: WebTransport connection accepted")
44
+
45
+ # Register connection (using the receive channel as ID or scope object)
46
+ # Since scope is mutable dictionary, we use its id() or just the object if stable
47
+ connection_id = id(scope)
48
+ self.active_connections.add(connection_id)
49
+
50
+ try:
51
+ while True:
52
+ message = await receive()
53
+ msg_type = message["type"]
54
+ # print(f"DEBUG: Received WT message: {msg_type}")
55
+
56
+ if msg_type == "webtransport.stream.connect":
57
+ # New bidirectional stream opened by client
58
+ stream_id = message["stream_id"]
59
+ streams[stream_id] = bytearray()
60
+ # print(f"DEBUG: Stream {stream_id} connected")
61
+
62
+ elif msg_type == "webtransport.stream.receive":
63
+ stream_id = message["stream_id"]
64
+ data = message.get("data", b"")
65
+
66
+ if stream_id not in streams:
67
+ # Stream might have been accepted implicitly or we missed connect
68
+ streams[stream_id] = bytearray()
69
+
70
+ streams[stream_id].extend(data)
71
+
72
+ # Check if stream is finished (some impls use 'more_body', others 'fin')
73
+ # Hypercorn uses 'more_body' (True if more coming)
74
+ more_body = message.get("more_body", False)
75
+
76
+ if not more_body:
77
+ # Full message received
78
+ payload = streams[stream_id]
79
+ del streams[stream_id] # Clear buffer
80
+
81
+ # Process message
82
+ try:
83
+ json_data = json.loads(payload.decode("utf-8"))
84
+ await self._handle_message(
85
+ json_data, scope, send, stream_id
86
+ )
87
+ except Exception as e:
88
+ print(f"WebTransport message error: {e}")
89
+
90
+ elif msg_type == "webtransport.disconnect":
91
+ break
92
+
93
+ except Exception as e:
94
+ print(f"WebTransport handler error: {e}")
95
+ finally:
96
+ self.active_connections.discard(connection_id)
97
+ if connection_id in self.connection_pages:
98
+ del self.connection_pages[connection_id]
99
+
100
+ async def _handle_message(
101
+ self, data: dict[str, Any], scope: dict[str, Any], send: Any, stream_id: int
102
+ ) -> None:
103
+ """Handle decoded JSON message."""
104
+ msg_type = data.get("type")
105
+ connection_id = id(scope)
106
+
107
+ if msg_type == "event":
108
+ # Handle event
109
+ if connection_id in self.connection_pages:
110
+ page = self.connection_pages[connection_id]
111
+ handler_name = data.get("handler")
112
+ event_data = data.get("data", {})
113
+
114
+ try:
115
+ if handler_name and isinstance(handler_name, str):
116
+ # Execute handler
117
+ response = await page.handle_event(handler_name, event_data)
118
+ else:
119
+ raise ValueError("Invalid handler name")
120
+
121
+ # If response is HTML, send update
122
+ if hasattr(response, "body"):
123
+ html = bytes(response.body).decode("utf-8")
124
+ response_data = {"type": "update", "html": html}
125
+ await self._send_response(send, stream_id, response_data)
126
+
127
+ except Exception as e:
128
+ # Send error response (no print - response is sufficient)
129
+ await self._send_response(
130
+ send, stream_id, {"type": "error", "error": str(e)}
131
+ )
132
+
133
+ elif msg_type == "init":
134
+ # Initialize page for this connection (similar to WS)
135
+ # Parse path and instantiate page
136
+ path = data.get("path", "/")
137
+ match = self.app.router.match(path)
138
+ if match:
139
+ page_class, params, variant_name = match
140
+ # Mock request object? Or extract from scope
141
+ # We need a Request-like object for Page init
142
+ from starlette.requests import Request
143
+
144
+ request = Request(scope)
145
+ query = dict(request.query_params)
146
+
147
+ # Build path info dict
148
+ path_info = {}
149
+ if hasattr(page_class, "__routes__"):
150
+ for name in page_class.__routes__.keys():
151
+ path_info[name] = name == variant_name
152
+ elif hasattr(page_class, "__route__"):
153
+ path_info["main"] = True
154
+
155
+ # Build URL helper
156
+ from pywire.runtime.router import URLHelper
157
+
158
+ url_helper = None
159
+ if hasattr(page_class, "__routes__"):
160
+ url_helper = URLHelper(page_class.__routes__)
161
+
162
+ page = page_class(
163
+ request, params, query, path=path_info, url=url_helper
164
+ )
165
+ if hasattr(self.app, "get_user"):
166
+ page.user = self.app.get_user(request)
167
+
168
+ self.connection_pages[connection_id] = page
169
+
170
+ async def _send_response(
171
+ self, send: Any, stream_id: int, data: dict[str, Any]
172
+ ) -> None:
173
+ """Send response back on the same stream."""
174
+ payload = json.dumps(data).encode("utf-8")
175
+ await send(
176
+ {
177
+ "type": "webtransport.stream.send",
178
+ "stream_id": stream_id,
179
+ "data": payload,
180
+ "finish": True, # Close the stream after sending
181
+ }
182
+ )
183
+
184
+ async def broadcast_reload(self) -> None:
185
+ """Broadcast reload to all active WebTransport connections."""
186
+ # For broadcast, we must initiate a NEW stream for each connection
187
+ # But we don't have reference to 'send' callable for each connection here!
188
+ # The 'send' is only available inside the 'handle' loop.
189
+
190
+ # This is a problem with the simple loop approach.
191
+ # We need a way to inject messages into the handle loops.
192
+ pass
193
+
194
+ # Solution: Use an asyncio.Queue for each connection, and have the handle loop
195
+ # wait for EITHER 'receive()' OR 'queue.get()'.
@@ -0,0 +1,3 @@
1
+ /* PyWire Client core v0.1.3 - https://github.com/pywire/pywire */
2
+ "use strict";var PyWireCore=(()=>{var ie=Object.defineProperty;var Ve=Object.getOwnPropertyDescriptor;var Xe=Object.getOwnPropertyNames;var Ge=Object.prototype.hasOwnProperty;var Ye=(s,e,t)=>e in s?ie(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var Je=(s,e)=>{for(var t in e)ie(s,t,{get:e[t],enumerable:!0})},qe=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Xe(e))!Ge.call(s,i)&&i!==t&&ie(s,i,{get:()=>e[i],enumerable:!(n=Ve(e,i))||n.enumerable});return s};var Ze=s=>qe(ie({},"__esModule",{value:!0}),s);var c=(s,e,t)=>(Ye(s,typeof e!="symbol"?e+"":e,t),t);var Rt={};Je(Rt,{DOMUpdater:()=>b,HTTPTransport:()=>F,PyWireApp:()=>O,TransportManager:()=>_,WebSocketTransport:()=>z,WebTransportTransport:()=>L,app:()=>Ee});var B=class{constructor(){this.messageHandlers=[];this.statusHandlers=[];this.connected=!1}onMessage(e){this.messageHandlers.push(e)}onStatusChange(e){this.statusHandlers.push(e)}isConnected(){return this.connected}notifyHandlers(e){for(let t of this.messageHandlers)try{t(e)}catch(n){console.error("PyWire: Error in message handler",n)}}notifyStatus(e){if(this.connected!==e){this.connected=e;for(let t of this.statusHandlers)try{t(e)}catch(n){console.error("PyWire: Error in status handler",n)}}}};var L=class s extends B{constructor(t){super();this.name="WebTransport";this.transport=null;this.writer=null;this.encoder=new TextEncoder;this.decoder=new TextDecoder;this.url=t||this.getDefaultUrl()}getDefaultUrl(){return`https://${window.location.host}/_pywire/webtransport`}static isSupported(){return typeof WebTransport<"u"}async connect(){if(!s.isSupported())throw new Error("WebTransport not supported in this browser");try{let t={},n=window.PYWIRE_CERT_HASH;n&&Array.isArray(n)&&(t.serverCertificateHashes=[{algorithm:"sha-256",value:new Uint8Array(n).buffer}],console.log("PyWire: Using explicit certificate hash for WebTransport")),this.transport=new WebTransport(this.url,t),await this.transport.ready,console.log("PyWire: WebTransport ready"),this.connected=!0,this.startReading()}catch(t){throw this.handleDisconnect(),t}}async startReading(){if(!this.transport)return;let t=this.transport.incomingBidirectionalStreams.getReader();try{for(;;){let{value:n,done:i}=await t.read();if(i)break;this.handleStream(n)}}catch(n){this.connected&&(console.error("PyWire: WebTransport read error",n),this.handleDisconnect())}}async handleStream(t){let n=t.readable.getReader();try{for(;;){let{value:i,done:r}=await n.read();if(r)break;if(i){let o=this.decoder.decode(i);try{let a=JSON.parse(o);this.notifyHandlers(a)}catch(a){console.error("PyWire: Error parsing WebTransport message",a)}}}}catch(i){console.error("PyWire: Stream read error",i)}}async send(t){if(!this.transport||!this.connected){console.warn("PyWire: Cannot send message, WebTransport not connected");return}try{let n=await this.transport.createBidirectionalStream(),i=n.writable.getWriter(),r=this.encoder.encode(JSON.stringify(t));await i.write(r),await i.close(),this.handleStream(n)}catch(n){console.error("PyWire: WebTransport send error",n)}}disconnect(){this.transport&&(this.transport.close(),this.transport=null),this.writer=null,this.connected=!1}handleDisconnect(){this.connected=!1,this.transport=null,this.writer=null}};function Pe(s){let e=s.length,t=0,n=0;for(;n<e;){let i=s.charCodeAt(n++);if(i&4294967168)if(!(i&4294965248))t+=2;else{if(i>=55296&&i<=56319&&n<e){let r=s.charCodeAt(n);(r&64512)===56320&&(++n,i=((i&1023)<<10)+(r&1023)+65536)}i&4294901760?t+=4:t+=3}else{t++;continue}}return t}function Qe(s,e,t){let n=s.length,i=t,r=0;for(;r<n;){let o=s.charCodeAt(r++);if(o&4294967168)if(!(o&4294965248))e[i++]=o>>6&31|192;else{if(o>=55296&&o<=56319&&r<n){let a=s.charCodeAt(r);(a&64512)===56320&&(++r,o=((o&1023)<<10)+(a&1023)+65536)}o&4294901760?(e[i++]=o>>18&7|240,e[i++]=o>>12&63|128,e[i++]=o>>6&63|128):(e[i++]=o>>12&15|224,e[i++]=o>>6&63|128)}else{e[i++]=o;continue}e[i++]=o&63|128}}var je=new TextEncoder,et=50;function tt(s,e,t){je.encodeInto(s,e.subarray(t))}function Be(s,e,t){s.length>et?tt(s,e,t):Qe(s,e,t)}var nt=4096;function xe(s,e,t){let n=e,i=n+t,r=[],o="";for(;n<i;){let a=s[n++];if(!(a&128))r.push(a);else if((a&224)===192){let d=s[n++]&63;r.push((a&31)<<6|d)}else if((a&240)===224){let d=s[n++]&63,w=s[n++]&63;r.push((a&31)<<12|d<<6|w)}else if((a&248)===240){let d=s[n++]&63,w=s[n++]&63,g=s[n++]&63,m=(a&7)<<18|d<<12|w<<6|g;m>65535&&(m-=65536,r.push(m>>>10&1023|55296),m=56320|m&1023),r.push(m)}else r.push(a);r.length>=nt&&(o+=String.fromCharCode(...r),r.length=0)}return r.length>0&&(o+=String.fromCharCode(...r)),o}var it=new TextDecoder,st=200;function rt(s,e,t){let n=s.subarray(e,e+t);return it.decode(n)}function Ie(s,e,t){return t>st?rt(s,e,t):xe(s,e,t)}var W=class{constructor(e,t){c(this,"type");c(this,"data");this.type=e,this.data=t}};var x=class s extends Error{constructor(e){super(e);let t=Object.create(s.prototype);Object.setPrototypeOf(this,t),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:s.name})}};function Le(s,e,t){let n=t/4294967296,i=t;s.setUint32(e,n),s.setUint32(e+4,i)}function se(s,e,t){let n=Math.floor(t/4294967296),i=t;s.setUint32(e,n),s.setUint32(e+4,i)}function re(s,e){let t=s.getInt32(e),n=s.getUint32(e+4);return t*4294967296+n}function We(s,e){let t=s.getUint32(e),n=s.getUint32(e+4);return t*4294967296+n}var ot=-1,at=4294967296-1,ct=17179869184-1;function dt({sec:s,nsec:e}){if(s>=0&&e>=0&&s<=ct)if(e===0&&s<=at){let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,s),t}else{let t=s/4294967296,n=s&4294967295,i=new Uint8Array(8),r=new DataView(i.buffer);return r.setUint32(0,e<<2|t&3),r.setUint32(4,n),i}else{let t=new Uint8Array(12),n=new DataView(t.buffer);return n.setUint32(0,e),se(n,4,s),t}}function lt(s){let e=s.getTime(),t=Math.floor(e/1e3),n=(e-t*1e3)*1e6,i=Math.floor(n/1e9);return{sec:t+i,nsec:n-i*1e9}}function ht(s){if(s instanceof Date){let e=lt(s);return dt(e)}else return null}function ft(s){let e=new DataView(s.buffer,s.byteOffset,s.byteLength);switch(s.byteLength){case 4:return{sec:e.getUint32(0),nsec:0};case 8:{let t=e.getUint32(0),n=e.getUint32(4),i=(t&3)*4294967296+n,r=t>>>2;return{sec:i,nsec:r}}case 12:{let t=re(e,4),n=e.getUint32(0);return{sec:t,nsec:n}}default:throw new x(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${s.length}`)}}function ut(s){let e=ft(s);return new Date(e.sec*1e3+e.nsec/1e6)}var Ce={type:ot,encode:ht,decode:ut};var oe=class oe{constructor(){c(this,"__brand");c(this,"builtInEncoders",[]);c(this,"builtInDecoders",[]);c(this,"encoders",[]);c(this,"decoders",[]);this.register(Ce)}register({type:e,encode:t,decode:n}){if(e>=0)this.encoders[e]=t,this.decoders[e]=n;else{let i=-1-e;this.builtInEncoders[i]=t,this.builtInDecoders[i]=n}}tryToEncode(e,t){for(let n=0;n<this.builtInEncoders.length;n++){let i=this.builtInEncoders[n];if(i!=null){let r=i(e,t);if(r!=null){let o=-1-n;return new W(o,r)}}}for(let n=0;n<this.encoders.length;n++){let i=this.encoders[n];if(i!=null){let r=i(e,t);if(r!=null){let o=n;return new W(o,r)}}}return e instanceof W?e:null}decode(e,t,n){let i=t<0?this.builtInDecoders[-1-t]:this.decoders[t];return i?i(e,t,n):new W(t,e)}};c(oe,"defaultCodec",new oe);var $=oe;function pt(s){return s instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&s instanceof SharedArrayBuffer}function G(s){return s instanceof Uint8Array?s:ArrayBuffer.isView(s)?new Uint8Array(s.buffer,s.byteOffset,s.byteLength):pt(s)?new Uint8Array(s):Uint8Array.from(s)}var gt=100,mt=2048,ae=class s{constructor(e){c(this,"extensionCodec");c(this,"context");c(this,"useBigInt64");c(this,"maxDepth");c(this,"initialBufferSize");c(this,"sortKeys");c(this,"forceFloat32");c(this,"ignoreUndefined");c(this,"forceIntegerToFloat");c(this,"pos");c(this,"view");c(this,"bytes");c(this,"entered",!1);this.extensionCodec=e?.extensionCodec??$.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.maxDepth=e?.maxDepth??gt,this.initialBufferSize=e?.initialBufferSize??mt,this.sortKeys=e?.sortKeys??!1,this.forceFloat32=e?.forceFloat32??!1,this.ignoreUndefined=e?.ignoreUndefined??!1,this.forceIntegerToFloat=e?.forceIntegerToFloat??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new s({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,maxDepth:this.maxDepth,initialBufferSize:this.initialBufferSize,sortKeys:this.sortKeys,forceFloat32:this.forceFloat32,ignoreUndefined:this.ignoreUndefined,forceIntegerToFloat:this.forceIntegerToFloat})}reinitializeState(){this.pos=0}encodeSharedRef(e){if(this.entered)return this.clone().encodeSharedRef(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode(e){if(this.entered)return this.clone().encode(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode(e,t){if(t>this.maxDepth)throw new Error(`Too deep objects in depth ${t}`);e==null?this.encodeNil():typeof e=="boolean"?this.encodeBoolean(e):typeof e=="number"?this.forceIntegerToFloat?this.encodeNumberAsFloat(e):this.encodeNumber(e):typeof e=="string"?this.encodeString(e):this.useBigInt64&&typeof e=="bigint"?this.encodeBigInt64(e):this.encodeObject(e,t)}ensureBufferSizeToWrite(e){let t=this.pos+e;this.view.byteLength<t&&this.resizeBuffer(t*2)}resizeBuffer(e){let t=new ArrayBuffer(e),n=new Uint8Array(t),i=new DataView(t);n.set(this.bytes),this.view=i,this.bytes=n}encodeNil(){this.writeU8(192)}encodeBoolean(e){e===!1?this.writeU8(194):this.writeU8(195)}encodeNumber(e){!this.forceIntegerToFloat&&Number.isSafeInteger(e)?e>=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(211),this.writeI64(e)):this.encodeNumberAsFloat(e)}encodeNumberAsFloat(e){this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))}encodeBigInt64(e){e>=BigInt(0)?(this.writeU8(207),this.writeBigUint64(e)):(this.writeU8(211),this.writeBigInt64(e))}writeStringHeader(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else if(e<4294967296)this.writeU8(219),this.writeU32(e);else throw new Error(`Too long string: ${e} bytes in UTF-8`)}encodeString(e){let n=Pe(e);this.ensureBufferSizeToWrite(5+n),this.writeStringHeader(n),Be(e,this.bytes,this.pos),this.pos+=n}encodeObject(e,t){let n=this.extensionCodec.tryToEncode(e,this.context);if(n!=null)this.encodeExtension(n);else if(Array.isArray(e))this.encodeArray(e,t);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else if(typeof e=="object")this.encodeMap(e,t);else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(e)}`)}encodeBinary(e){let t=e.byteLength;if(t<256)this.writeU8(196),this.writeU8(t);else if(t<65536)this.writeU8(197),this.writeU16(t);else if(t<4294967296)this.writeU8(198),this.writeU32(t);else throw new Error(`Too large binary: ${t}`);let n=G(e);this.writeU8a(n)}encodeArray(e,t){let n=e.length;if(n<16)this.writeU8(144+n);else if(n<65536)this.writeU8(220),this.writeU16(n);else if(n<4294967296)this.writeU8(221),this.writeU32(n);else throw new Error(`Too large array: ${n}`);for(let i of e)this.doEncode(i,t+1)}countWithoutUndefined(e,t){let n=0;for(let i of t)e[i]!==void 0&&n++;return n}encodeMap(e,t){let n=Object.keys(e);this.sortKeys&&n.sort();let i=this.ignoreUndefined?this.countWithoutUndefined(e,n):n.length;if(i<16)this.writeU8(128+i);else if(i<65536)this.writeU8(222),this.writeU16(i);else if(i<4294967296)this.writeU8(223),this.writeU32(i);else throw new Error(`Too large map object: ${i}`);for(let r of n){let o=e[r];this.ignoreUndefined&&o===void 0||(this.encodeString(r),this.doEncode(o,t+1))}}encodeExtension(e){if(typeof e.data=="function"){let n=e.data(this.pos+6),i=n.length;if(i>=4294967296)throw new Error(`Too large extension object: ${i}`);this.writeU8(201),this.writeU32(i),this.writeI8(e.type),this.writeU8a(n);return}let t=e.data.length;if(t===1)this.writeU8(212);else if(t===2)this.writeU8(213);else if(t===4)this.writeU8(214);else if(t===8)this.writeU8(215);else if(t===16)this.writeU8(216);else if(t<256)this.writeU8(199),this.writeU8(t);else if(t<65536)this.writeU8(200),this.writeU16(t);else if(t<4294967296)this.writeU8(201),this.writeU32(t);else throw new Error(`Too large extension object: ${t}`);this.writeI8(e.type),this.writeU8a(e.data)}writeU8(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++}writeU8a(e){let t=e.length;this.ensureBufferSizeToWrite(t),this.bytes.set(e,this.pos),this.pos+=t}writeI8(e){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,e),this.pos++}writeU16(e){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,e),this.pos+=2}writeI16(e){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,e),this.pos+=2}writeU32(e){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,e),this.pos+=4}writeI32(e){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,e),this.pos+=4}writeF32(e){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,e),this.pos+=4}writeF64(e){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,e),this.pos+=8}writeU64(e){this.ensureBufferSizeToWrite(8),Le(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),se(this.view,this.pos,e),this.pos+=8}writeBigUint64(e){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,e),this.pos+=8}writeBigInt64(e){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,e),this.pos+=8}};function N(s,e){return new ae(e).encodeSharedRef(s)}function ce(s){return`${s<0?"-":""}0x${Math.abs(s).toString(16).padStart(2,"0")}`}var wt=16,yt=16,de=class{constructor(e=wt,t=yt){c(this,"hit",0);c(this,"miss",0);c(this,"caches");c(this,"maxKeyLength");c(this,"maxLengthPerKey");this.maxKeyLength=e,this.maxLengthPerKey=t,this.caches=[];for(let n=0;n<this.maxKeyLength;n++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,t,n){let i=this.caches[n-1];e:for(let r of i){let o=r.bytes;for(let a=0;a<n;a++)if(o[a]!==e[t+a])continue e;return r.str}return null}store(e,t){let n=this.caches[e.length-1],i={bytes:e,str:t};n.length>=this.maxLengthPerKey?n[Math.random()*n.length|0]=i:n.push(i)}decode(e,t,n){let i=this.find(e,t,n);if(i!=null)return this.hit++,i;this.miss++;let r=xe(e,t,n),o=Uint8Array.prototype.slice.call(e,t,t+n);return this.store(o,r),r}};var ve="array",q="map_key",He="map_value",xt=s=>{if(typeof s=="string"||typeof s=="number")return s;throw new x("The type of key must be string or number but "+typeof s)},Se=class{constructor(){c(this,"stack",[]);c(this,"stackHeadPosition",-1)}get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){let t=this.getUninitializedStateFromPool();t.type=ve,t.position=0,t.size=e,t.array=new Array(e)}pushMapState(e){let t=this.getUninitializedStateFromPool();t.type=q,t.readCount=0,t.size=e,t.map={}}getUninitializedStateFromPool(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){let e={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push(e)}return this.stack[this.stackHeadPosition]}release(e){if(this.stack[this.stackHeadPosition]!==e)throw new Error("Invalid stack state. Released state is not on top of the stack.");if(e.type===ve){let n=e;n.size=0,n.array=void 0,n.position=0,n.type=void 0}if(e.type===q||e.type===He){let n=e;n.size=0,n.map=void 0,n.readCount=0,n.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}},J=-1,Te=new DataView(new ArrayBuffer(0)),vt=new Uint8Array(Te.buffer);try{Te.getInt8(0)}catch(s){if(!(s instanceof RangeError))throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}var De=new RangeError("Insufficient data"),St=new de,le=class s{constructor(e){c(this,"extensionCodec");c(this,"context");c(this,"useBigInt64");c(this,"rawStrings");c(this,"maxStrLength");c(this,"maxBinLength");c(this,"maxArrayLength");c(this,"maxMapLength");c(this,"maxExtLength");c(this,"keyDecoder");c(this,"mapKeyConverter");c(this,"totalPos",0);c(this,"pos",0);c(this,"view",Te);c(this,"bytes",vt);c(this,"headByte",J);c(this,"stack",new Se);c(this,"entered",!1);this.extensionCodec=e?.extensionCodec??$.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.rawStrings=e?.rawStrings??!1,this.maxStrLength=e?.maxStrLength??4294967295,this.maxBinLength=e?.maxBinLength??4294967295,this.maxArrayLength=e?.maxArrayLength??4294967295,this.maxMapLength=e?.maxMapLength??4294967295,this.maxExtLength=e?.maxExtLength??4294967295,this.keyDecoder=e?.keyDecoder!==void 0?e.keyDecoder:St,this.mapKeyConverter=e?.mapKeyConverter??xt}clone(){return new s({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,rawStrings:this.rawStrings,maxStrLength:this.maxStrLength,maxBinLength:this.maxBinLength,maxArrayLength:this.maxArrayLength,maxMapLength:this.maxMapLength,maxExtLength:this.maxExtLength,keyDecoder:this.keyDecoder})}reinitializeState(){this.totalPos=0,this.headByte=J,this.stack.reset()}setBuffer(e){let t=G(e);this.bytes=t,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===J&&!this.hasRemaining(1))this.setBuffer(e);else{let t=this.bytes.subarray(this.pos),n=G(e),i=new Uint8Array(t.length+n.length);i.set(t),i.set(n,t.length),this.setBuffer(i)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){let{view:t,pos:n}=this;return new RangeError(`Extra ${t.byteLength-n} of ${t.byteLength} byte(s) found at buffer[${e}]`)}decode(e){if(this.entered)return this.clone().decode(e);try{this.entered=!0,this.reinitializeState(),this.setBuffer(e);let t=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return t}finally{this.entered=!1}}*decodeMulti(e){if(this.entered){yield*this.clone().decodeMulti(e);return}try{for(this.entered=!0,this.reinitializeState(),this.setBuffer(e);this.hasRemaining(1);)yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(e){if(this.entered)return this.clone().decodeAsync(e);try{this.entered=!0;let t=!1,n;for await(let a of e){if(t)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(a);try{n=this.doDecodeSync(),t=!0}catch(d){if(!(d instanceof RangeError))throw d}this.totalPos+=this.pos}if(t){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return n}let{headByte:i,pos:r,totalPos:o}=this;throw new RangeError(`Insufficient data in parsing ${ce(i)} at ${o} (${r} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(e){return this.decodeMultiAsync(e,!0)}decodeStream(e){return this.decodeMultiAsync(e,!1)}async*decodeMultiAsync(e,t){if(this.entered){yield*this.clone().decodeMultiAsync(e,t);return}try{this.entered=!0;let n=t,i=-1;for await(let r of e){if(t&&i===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(r),n&&(i=this.readArraySize(),n=!1,this.complete());try{for(;yield this.doDecodeSync(),--i!==0;);}catch(o){if(!(o instanceof RangeError))throw o}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){e:for(;;){let e=this.readHeadByte(),t;if(e>=224)t=e-256;else if(e<192)if(e<128)t=e;else if(e<144){let i=e-128;if(i!==0){this.pushMapState(i),this.complete();continue e}else t={}}else if(e<160){let i=e-144;if(i!==0){this.pushArrayState(i),this.complete();continue e}else t=[]}else{let i=e-160;t=this.decodeString(i,0)}else if(e===192)t=null;else if(e===194)t=!1;else if(e===195)t=!0;else if(e===202)t=this.readF32();else if(e===203)t=this.readF64();else if(e===204)t=this.readU8();else if(e===205)t=this.readU16();else if(e===206)t=this.readU32();else if(e===207)this.useBigInt64?t=this.readU64AsBigInt():t=this.readU64();else if(e===208)t=this.readI8();else if(e===209)t=this.readI16();else if(e===210)t=this.readI32();else if(e===211)this.useBigInt64?t=this.readI64AsBigInt():t=this.readI64();else if(e===217){let i=this.lookU8();t=this.decodeString(i,1)}else if(e===218){let i=this.lookU16();t=this.decodeString(i,2)}else if(e===219){let i=this.lookU32();t=this.decodeString(i,4)}else if(e===220){let i=this.readU16();if(i!==0){this.pushArrayState(i),this.complete();continue e}else t=[]}else if(e===221){let i=this.readU32();if(i!==0){this.pushArrayState(i),this.complete();continue e}else t=[]}else if(e===222){let i=this.readU16();if(i!==0){this.pushMapState(i),this.complete();continue e}else t={}}else if(e===223){let i=this.readU32();if(i!==0){this.pushMapState(i),this.complete();continue e}else t={}}else if(e===196){let i=this.lookU8();t=this.decodeBinary(i,1)}else if(e===197){let i=this.lookU16();t=this.decodeBinary(i,2)}else if(e===198){let i=this.lookU32();t=this.decodeBinary(i,4)}else if(e===212)t=this.decodeExtension(1,0);else if(e===213)t=this.decodeExtension(2,0);else if(e===214)t=this.decodeExtension(4,0);else if(e===215)t=this.decodeExtension(8,0);else if(e===216)t=this.decodeExtension(16,0);else if(e===199){let i=this.lookU8();t=this.decodeExtension(i,1)}else if(e===200){let i=this.lookU16();t=this.decodeExtension(i,2)}else if(e===201){let i=this.lookU32();t=this.decodeExtension(i,4)}else throw new x(`Unrecognized type byte: ${ce(e)}`);this.complete();let n=this.stack;for(;n.length>0;){let i=n.top();if(i.type===ve)if(i.array[i.position]=t,i.position++,i.position===i.size)t=i.array,n.release(i);else continue e;else if(i.type===q){if(t==="__proto__")throw new x("The key __proto__ is not allowed");i.key=this.mapKeyConverter(t),i.type=He;continue e}else if(i.map[i.key]=t,i.readCount++,i.readCount===i.size)t=i.map,n.release(i);else{i.key=null,i.type=q;continue e}}return t}}readHeadByte(){return this.headByte===J&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=J}readArraySize(){let e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:{if(e<160)return e-144;throw new x(`Unrecognized array type byte: ${ce(e)}`)}}}pushMapState(e){if(e>this.maxMapLength)throw new x(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new x(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(e)}decodeString(e,t){return!this.rawStrings||this.stateIsMapKey()?this.decodeUtf8String(e,t):this.decodeBinary(e,t)}decodeUtf8String(e,t){if(e>this.maxStrLength)throw new x(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+t+e)throw De;let n=this.pos+t,i;return this.stateIsMapKey()&&this.keyDecoder?.canBeCached(e)?i=this.keyDecoder.decode(this.bytes,n,e):i=Ie(this.bytes,n,e),this.pos+=t+e,i}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===q:!1}decodeBinary(e,t){if(e>this.maxBinLength)throw new x(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+t))throw De;let n=this.pos+t,i=this.bytes.subarray(n,n+e);return this.pos+=t+e,i}decodeExtension(e,t){if(e>this.maxExtLength)throw new x(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);let n=this.view.getInt8(this.pos+t),i=this.decodeBinary(e,t+1);return this.extensionCodec.decode(i,n,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){let e=this.view.getUint8(this.pos);return this.pos++,e}readI8(){let e=this.view.getInt8(this.pos);return this.pos++,e}readU16(){let e=this.view.getUint16(this.pos);return this.pos+=2,e}readI16(){let e=this.view.getInt16(this.pos);return this.pos+=2,e}readU32(){let e=this.view.getUint32(this.pos);return this.pos+=4,e}readI32(){let e=this.view.getInt32(this.pos);return this.pos+=4,e}readU64(){let e=We(this.view,this.pos);return this.pos+=8,e}readI64(){let e=re(this.view,this.pos);return this.pos+=8,e}readU64AsBigInt(){let e=this.view.getBigUint64(this.pos);return this.pos+=8,e}readI64AsBigInt(){let e=this.view.getBigInt64(this.pos);return this.pos+=8,e}readF32(){let e=this.view.getFloat32(this.pos);return this.pos+=4,e}readF64(){let e=this.view.getFloat64(this.pos);return this.pos+=8,e}};function C(s,e){return new le(e).decode(s)}var z=class extends B{constructor(t){super();this.name="WebSocket";this.socket=null;this.reconnectAttempts=0;this.maxReconnectDelay=5e3;this.shouldReconnect=!0;this.url=t||this.getDefaultUrl()}getDefaultUrl(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/_pywire/ws`}connect(){return new Promise((t,n)=>{try{this.socket=new WebSocket(this.url),this.socket.binaryType="arraybuffer",this.socket.onopen=()=>{console.log("PyWire: WebSocket connected"),this.notifyStatus(!0),this.reconnectAttempts=0,t()},this.socket.onmessage=i=>{try{let r=C(i.data);this.notifyHandlers(r)}catch(r){console.error("PyWire: Error parsing WebSocket message",r)}},this.socket.onclose=()=>{console.log("PyWire: WebSocket disconnected"),this.notifyStatus(!1),this.shouldReconnect&&this.scheduleReconnect()},this.socket.onerror=i=>{console.error("PyWire: WebSocket error",i),this.connected||n(new Error("WebSocket connection failed"))}}catch(i){n(i)}})}send(t){this.socket&&this.socket.readyState===WebSocket.OPEN?this.socket.send(N(t)):console.warn("PyWire: Cannot send message, WebSocket not open")}disconnect(){this.shouldReconnect=!1,this.socket&&(this.socket.close(),this.socket=null),this.notifyStatus(!1)}scheduleReconnect(){let t=Math.min(1e3*Math.pow(2,this.reconnectAttempts),this.maxReconnectDelay);console.log(`PyWire: Reconnecting in ${t}ms...`),setTimeout(()=>{this.reconnectAttempts++,this.connect().catch(()=>{})},t)}};var F=class extends B{constructor(t){super();this.name="HTTP";this.polling=!1;this.pollAbortController=null;this.sessionId=null;this.baseUrl=t||`${window.location.origin}/_pywire`}async connect(){try{let t=await fetch(`${this.baseUrl}/session`,{method:"POST",headers:{"Content-Type":"application/x-msgpack",Accept:"application/x-msgpack"},body:N({path:window.location.pathname+window.location.search})});if(!t.ok)throw new Error(`HTTP session init failed: ${t.status}`);let n=await t.arrayBuffer(),i=C(n);this.sessionId=i.sessionId,console.log("PyWire: HTTP transport connected"),this.notifyStatus(!0),this.startPolling()}catch(t){throw console.error("PyWire: HTTP transport connection failed",t),t}}async startPolling(){if(!this.polling)for(this.polling=!0;this.polling&&this.connected;)try{this.pollAbortController=new AbortController;let t=await fetch(`${this.baseUrl}/poll?session=${this.sessionId}`,{method:"GET",signal:this.pollAbortController.signal,headers:{Accept:"application/x-msgpack"}});if(!t.ok){if(t.status===404){console.warn("PyWire: HTTP session expired, reconnecting..."),this.notifyStatus(!1),await this.connect();return}throw new Error(`Poll failed: ${t.status}`)}let n=await t.arrayBuffer(),i=C(n);for(let r of i)this.notifyHandlers(r)}catch(t){if(t instanceof Error&&t.name==="AbortError")break;console.error("PyWire: HTTP poll error",t),await this.sleep(1e3)}}async send(t){if(!this.connected||!this.sessionId){console.warn("PyWire: Cannot send message, HTTP transport not connected");return}try{let n=await fetch(`${this.baseUrl}/event`,{method:"POST",headers:{"Content-Type":"application/x-msgpack",Accept:"application/x-msgpack","X-PyWire-Session":this.sessionId},body:N(t)});if(!n.ok)throw new Error(`Event send failed: ${n.status}`);let i=await n.arrayBuffer(),r=C(i);this.notifyHandlers(r)}catch(n){console.error("PyWire: HTTP send error",n)}}disconnect(){this.polling=!1,this.notifyStatus(!1),this.pollAbortController&&(this.pollAbortController.abort(),this.pollAbortController=null),this.sessionId=null}sleep(t){return new Promise(n=>setTimeout(n,t))}};var Tt={enableWebTransport:!0,enableWebSocket:!0,enableHTTP:!0},_=class{constructor(e={}){this.transport=null;this.messageHandlers=[];this.statusHandlers=[];this.config={...Tt,...e}}async connect(){let e=this.getTransportPriority();for(let t of e)try{console.log(`PyWire: Trying ${t.name}...`),this.transport=new t;for(let n of this.messageHandlers)this.transport.onMessage(n);this.transport.onStatusChange(n=>{this.notifyStatusHandlers(n)}),await this.transport.connect(),console.log(`PyWire: Connected via ${this.transport.name}`);return}catch(n){console.warn(`PyWire: ${t.name} failed, trying next...`,n),this.transport=null}throw new Error("PyWire: All transports failed")}getTransportPriority(){let e=[];return this.config.enableWebTransport&&L.isSupported()&&window.location.protocol==="https:"&&e.push(L),this.config.enableWebSocket&&typeof WebSocket<"u"&&e.push(z),this.config.enableHTTP&&e.push(F),e}send(e){this.transport?this.transport.send(e):console.warn("PyWire: No active transport")}onMessage(e){this.messageHandlers.push(e),this.transport&&this.transport.onMessage(e)}onStatusChange(e){this.statusHandlers.push(e)}notifyStatusHandlers(e){for(let t of this.statusHandlers)t(e)}disconnect(){this.transport&&(this.transport.disconnect(),this.transport=null,this.notifyStatusHandlers(!1))}getActiveTransport(){return this.transport?.name||null}isConnected(){return this.transport?.isConnected()||!1}};var Re=11;function bt(s,e){var t=e.attributes,n,i,r,o,a;if(!(e.nodeType===Re||s.nodeType===Re)){for(var d=t.length-1;d>=0;d--)n=t[d],i=n.name,r=n.namespaceURI,o=n.value,r?(i=n.localName||i,a=s.getAttributeNS(r,i),a!==o&&(n.prefix==="xmlns"&&(i=n.name),s.setAttributeNS(r,i,o))):(a=s.getAttribute(i),a!==o&&s.setAttribute(i,o));for(var w=s.attributes,g=w.length-1;g>=0;g--)n=w[g],i=n.name,r=n.namespaceURI,r?(i=n.localName||i,e.hasAttributeNS(r,i)||s.removeAttributeNS(r,i)):e.hasAttribute(i)||s.removeAttribute(i)}}var he,Ut="http://www.w3.org/1999/xhtml",v=typeof document>"u"?void 0:document,Et=!!v&&"content"in v.createElement("template"),At=!!v&&v.createRange&&"createContextualFragment"in v.createRange();function Mt(s){var e=v.createElement("template");return e.innerHTML=s,e.content.childNodes[0]}function kt(s){he||(he=v.createRange(),he.selectNode(v.body));var e=he.createContextualFragment(s);return e.childNodes[0]}function Pt(s){var e=v.createElement("body");return e.innerHTML=s,e.childNodes[0]}function Bt(s){return s=s.trim(),Et?Mt(s):At?kt(s):Pt(s)}function fe(s,e){var t=s.nodeName,n=e.nodeName,i,r;return t===n?!0:(i=t.charCodeAt(0),r=n.charCodeAt(0),i<=90&&r>=97?t===n.toUpperCase():r<=90&&i>=97?n===t.toUpperCase():!1)}function It(s,e){return!e||e===Ut?v.createElement(s):v.createElementNS(e,s)}function Lt(s,e){for(var t=s.firstChild;t;){var n=t.nextSibling;e.appendChild(t),t=n}return e}function be(s,e,t){s[t]!==e[t]&&(s[t]=e[t],s[t]?s.setAttribute(t,""):s.removeAttribute(t))}var $e={OPTION:function(s,e){var t=s.parentNode;if(t){var n=t.nodeName.toUpperCase();n==="OPTGROUP"&&(t=t.parentNode,n=t&&t.nodeName.toUpperCase()),n==="SELECT"&&!t.hasAttribute("multiple")&&(s.hasAttribute("selected")&&!e.selected&&(s.setAttribute("selected","selected"),s.removeAttribute("selected")),t.selectedIndex=-1)}be(s,e,"selected")},INPUT:function(s,e){be(s,e,"checked"),be(s,e,"disabled"),s.value!==e.value&&(s.value=e.value),e.hasAttribute("value")||s.removeAttribute("value")},TEXTAREA:function(s,e){var t=e.value;s.value!==t&&(s.value=t);var n=s.firstChild;if(n){var i=n.nodeValue;if(i==t||!t&&i==s.placeholder)return;n.nodeValue=t}},SELECT:function(s,e){if(!e.hasAttribute("multiple")){for(var t=-1,n=0,i=s.firstChild,r,o;i;)if(o=i.nodeName&&i.nodeName.toUpperCase(),o==="OPTGROUP")r=i,i=r.firstChild,i||(i=r.nextSibling,r=null);else{if(o==="OPTION"){if(i.hasAttribute("selected")){t=n;break}n++}i=i.nextSibling,!i&&r&&(i=r.nextSibling,r=null)}s.selectedIndex=t}}},Z=1,Ne=11,ze=3,Fe=8;function I(){}function Wt(s){if(s)return s.getAttribute&&s.getAttribute("id")||s.id}function Ct(s){return function(t,n,i){if(i||(i={}),typeof n=="string")if(t.nodeName==="#document"||t.nodeName==="HTML"||t.nodeName==="BODY"){var r=n;n=v.createElement("html"),n.innerHTML=r}else n=Bt(n);else n.nodeType===Ne&&(n=n.firstElementChild);var o=i.getNodeKey||Wt,a=i.onBeforeNodeAdded||I,d=i.onNodeAdded||I,w=i.onBeforeElUpdated||I,g=i.onElUpdated||I,m=i.onBeforeNodeDiscarded||I,E=i.onNodeDiscarded||I,V=i.onBeforeElChildrenUpdated||I,S=i.skipFromChildren||I,X=i.addChild||function(l,h){return l.appendChild(h)},D=i.childrenOnly===!0,T=Object.create(null),A=[];function M(l){A.push(l)}function Ae(l,h){if(l.nodeType===Z)for(var p=l.firstChild;p;){var f=void 0;h&&(f=o(p))?M(f):(E(p),p.firstChild&&Ae(p,h)),p=p.nextSibling}}function Q(l,h,p){m(l)!==!1&&(h&&h.removeChild(l),E(l),Ae(l,p))}function pe(l){if(l.nodeType===Z||l.nodeType===Ne)for(var h=l.firstChild;h;){var p=o(h);p&&(T[p]=h),pe(h),h=h.nextSibling}}pe(t);function ge(l){d(l);for(var h=l.firstChild;h;){var p=h.nextSibling,f=o(h);if(f){var u=T[f];u&&fe(h,u)?(h.parentNode.replaceChild(u,h),j(u,h)):ge(h)}else ge(h);h=p}}function _e(l,h,p){for(;h;){var f=h.nextSibling;(p=o(h))?M(p):Q(h,l,!0),h=f}}function j(l,h,p){var f=o(h);if(f&&delete T[f],!p){var u=w(l,h);if(u===!1||(u instanceof HTMLElement&&(l=u,pe(l)),s(l,h),g(l),V(l,h)===!1))return}l.nodeName!=="TEXTAREA"?Ke(l,h):$e.TEXTAREA(l,h)}function Ke(l,h){var p=S(l,h),f=h.firstChild,u=l.firstChild,H,U,R,te,k;e:for(;f;){for(te=f.nextSibling,H=o(f);!p&&u;){if(R=u.nextSibling,f.isSameNode&&f.isSameNode(u)){f=te,u=R;continue e}U=o(u);var ne=u.nodeType,P=void 0;if(ne===f.nodeType&&(ne===Z?(H?H!==U&&((k=T[H])?R===k?P=!1:(l.insertBefore(k,u),U?M(U):Q(u,l,!0),u=k,U=o(u)):P=!1):U&&(P=!1),P=P!==!1&&fe(u,f),P&&j(u,f)):(ne===ze||ne==Fe)&&(P=!0,u.nodeValue!==f.nodeValue&&(u.nodeValue=f.nodeValue))),P){f=te,u=R;continue e}U?M(U):Q(u,l,!0),u=R}if(H&&(k=T[H])&&fe(k,f))p||X(l,k),j(k,f);else{var ye=a(f);ye!==!1&&(ye&&(f=ye),f.actualize&&(f=f.actualize(l.ownerDocument||v)),X(l,f),ge(f))}f=te,u=R}_e(l,u,U);var ke=$e[l.nodeName];ke&&ke(l,h)}var y=t,ee=y.nodeType,Me=n.nodeType;if(!D){if(ee===Z)Me===Z?fe(t,n)||(E(t),y=Lt(t,It(n.nodeName,n.namespaceURI))):y=n;else if(ee===ze||ee===Fe){if(Me===ee)return y.nodeValue!==n.nodeValue&&(y.nodeValue=n.nodeValue),y;y=n}}if(y===n)E(t);else{if(n.isSameNode&&n.isSameNode(y))return;if(j(y,n,D),A)for(var me=0,Oe=A.length;me<Oe;me++){var we=T[A[me]];we&&Q(we,we.parentNode,!1)}}return!D&&y!==t&&t.parentNode&&(y.actualize&&(y=y.actualize(t.ownerDocument||v)),t.parentNode.replaceChild(y,t)),y}}var Dt=Ct(bt),Ue=Dt;var K=class K{constructor(e=!1){this.debug=e}getNodeKey(e){if(e instanceof HTMLElement){for(let t of e.attributes)if(t.name.startsWith("data-on-"))return`${e.tagName}-${t.name}-${t.value}`;if(e.id&&!e.id.startsWith("pywire-uid-"))return e.id;if((e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement)&&e.name)return`${e.tagName}-name-${e.name}`}}getElementSelector(e){if(e.id)return`#${e.id}`;let t=[],n=e;for(;n&&n!==document.body&&t.length<5;){let i=n.tagName.toLowerCase();if(n.id){i=`#${n.id}`,t.unshift(i);break}(n instanceof HTMLInputElement||n instanceof HTMLSelectElement||n instanceof HTMLTextAreaElement)&&n.name&&(i+=`[name="${n.name}"]`);for(let r of n.attributes)if(r.name.startsWith("data-on-")){i+=`[${r.name}="${r.value}"]`;break}if(n.parentElement){let o=Array.from(n.parentElement.children).filter(a=>a.tagName===n.tagName);if(o.length>1){let a=o.indexOf(n)+1;i+=`:nth-of-type(${a})`}}t.unshift(i),n=n.parentElement}return t.join(" > ")}captureFocusState(){let e=document.activeElement;if(!e||e===document.body||e===document.documentElement)return null;let t={selector:this.getElementSelector(e),id:e.id||null,tagName:e.tagName,selectionStart:null,selectionEnd:null,scrollTop:0,scrollLeft:0,value:""};return(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&(t.selectionStart=e.selectionStart,t.selectionEnd=e.selectionEnd,t.scrollTop=e.scrollTop,t.scrollLeft=e.scrollLeft,t.value=e.value),t}restoreFocusState(e){if(!e)return;let t=null;if(e.id&&(t=document.getElementById(e.id)),!t&&e.selector)try{t=document.querySelector(e.selector)}catch{}if(t&&(t.focus(),t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)){if(e.value&&t.value!==e.value&&(t.value=e.value),e.selectionStart!==null&&e.selectionEnd!==null)try{t.setSelectionRange(e.selectionStart,e.selectionEnd)}catch{}t.scrollTop=e.scrollTop,t.scrollLeft=e.scrollLeft}}applyUpdate(e,t){K.isUpdating=!0,this.debug&&console.log("[DOMUpdater] Starting update, isUpdating =",K.isUpdating);try{let n=this.captureFocusState();if(Ue){try{Ue(e,t,{getNodeKey:i=>this.getNodeKey(i),onBeforeElUpdated:(i,r)=>{if(i instanceof HTMLInputElement&&r instanceof HTMLInputElement)if(i.type==="checkbox"||i.type==="radio")r.checked=i.checked;else{let o=r.value||"",a=i.value||"";(a.startsWith(o)||o.startsWith(a))&&(r.value=a)}if(i instanceof HTMLTextAreaElement&&r instanceof HTMLTextAreaElement){let o=r.value||"",a=i.value||"";(a.startsWith(o)||o.startsWith(a))&&(r.value=a)}return i instanceof HTMLSelectElement&&r instanceof HTMLSelectElement&&(i.value&&Array.from(r.options).some(o=>o.value===i.value)?r.value=i.value:i.selectedIndex>=0&&i.selectedIndex<r.options.length&&(r.selectedIndex=i.selectedIndex)),i.id&&i.id.startsWith("pywire-uid-")&&!r.id&&(r.id=i.id),!0},onBeforeNodeDiscarded:()=>!0})}catch(i){console.error("Morphdom failed:",i),e===document.documentElement&&(document.open(),document.write(t),document.close())}this.restoreFocusState(n)}else e===document.documentElement&&(document.open(),document.write(t),document.close())}finally{setTimeout(()=>{K.isUpdating=!1},0)}}update(e){let t=/<html[\s>]/i.test(e),n=/<body[\s>]/i.test(e);if(!t&&document.body){if(n){this.applyUpdate(document.body,e);return}let i=`<body>${e}</body>`;this.applyUpdate(document.body,i);return}this.applyUpdate(document.documentElement,e)}updateRegion(e,t){let n=document.querySelector(`[data-pw-region="${e}"]`);if(!n){this.debug&&console.warn("[DOMUpdater] Region not found:",e);return}this.applyUpdate(n,t),n.getAttribute("data-pw-region")||n.setAttribute("data-pw-region",e)}};K.isUpdating=!1;var b=K;var ue=class{constructor(e){this.debouncers=new Map;this.throttlers=new Map;this.supportedEvents=["click","submit","input","change","keydown","keyup","focus","blur","mouseenter","mouseleave","scroll","contextmenu"];this.suppressDuringUpdate=["focus","blur","mouseenter","mouseleave"];this.app=e}debugLog(...e){this.app.getConfig().debug&&console.log(...e)}init(){this.supportedEvents.forEach(e=>{let t=e==="mouseenter"||e==="mouseleave"||e==="focus"||e==="blur"||e==="scroll"?{capture:!0}:void 0;document.addEventListener(e,n=>this.handleEvent(n),t)})}getHandlers(e,t){let n=`data-on-${t}`,i=e.getAttribute(n);if(!i)return[];if(i.trim().startsWith("["))try{let r=JSON.parse(i);if(Array.isArray(r))return r.flatMap(o=>{if(!o||typeof o!="object")return[];let a="handler"in o&&typeof o.handler=="string"?o.handler:null;if(!a)return[];let d="modifiers"in o&&Array.isArray(o.modifiers)?o.modifiers.filter(g=>typeof g=="string"):[],w="args"in o&&Array.isArray(o.args)?o.args:void 0;return[{name:a,modifiers:d,args:w}]})}catch(r){console.error("Error parsing event handlers:",r)}else{let r=e.getAttribute(`data-modifiers-${t}`),o=r?r.split(" ").filter(a=>a):[];return[{name:i,modifiers:o,args:void 0}]}return[]}async handleEvent(e){let t=e.type;if(b.isUpdating&&this.suppressDuringUpdate.includes(t)){this.debugLog("[Handler] SUPPRESSING event during update:",t,"isUpdating=",b.isUpdating);return}this.debugLog("[Handler] Processing event:",t,"isUpdating=",b.isUpdating);let n=e.composedPath?e.composedPath():[],i=!1;for(let r of n){if(i)break;if(r instanceof HTMLElement){let o=r,a=this.getHandlers(o,t);if(a.length>0){this.debugLog("[handleEvent] Found handlers on",o.tagName,a);for(let d of a)!d.modifiers.includes("window")&&!d.modifiers.includes("outside")&&(this.processEvent(o,t,d.name,d.modifiers,e,d.args),e.cancelBubble&&(i=!0))}}}this.handleGlobalEvent(e)}handleGlobalEvent(e){let t=e.type,n=`[data-modifiers-${t}*="window"]`,i=`[data-modifiers-${t}*="outside"]`;document.querySelectorAll(`${n}, ${i}`).forEach(o=>{if(!(o instanceof HTMLElement))return;let a=this.getHandlers(o,t);for(let d of a)if(d.modifiers.includes("window")&&this.processEvent(o,t,d.name,d.modifiers,e,d.args),d.modifiers.includes("outside")){let w=e.target;w&&!o.contains(w)&&this.processEvent(o,t,d.name,d.modifiers,e,d.args)}})}processEvent(e,t,n,i,r,o){if(this.debugLog("[processEvent]",t,"handler:",n,"modifiers:",i),(i.includes("prevent")||t==="submit")&&(this.debugLog("[processEvent] Calling preventDefault"),r.preventDefault()),i.includes("stop")&&r.stopPropagation(),i.includes("self")&&r.target!==e||i.includes("shift")&&(!("shiftKey"in r)||!r.shiftKey)||i.includes("ctrl")&&(!("ctrlKey"in r)||!r.ctrlKey)||i.includes("alt")&&(!("altKey"in r)||!r.altKey)||i.includes("meta")&&(!("metaKey"in r)||!r.metaKey)||i.includes("cmd")&&(!("metaKey"in r)||!r.metaKey))return;if(r instanceof KeyboardEvent){let m=["enter","escape","space","tab","up","down","left","right"],E=["shift","ctrl","alt","meta","cmd","window","outside","prevent","stop","self","debounce","throttle"],V=i.filter(S=>E.includes(S)||S.startsWith("debounce")||S.startsWith("throttle")||S.endsWith("ms")?!1:m.includes(S)||S.length===1);if(V.length>0){let S=r.key.toLowerCase();this.debugLog("[processEvent] Key check. Pressed:",S,"Modifiers:",V);let X={escape:"escape",esc:"escape",enter:"enter",space:" ",spacebar:" "," ":" ",tab:"tab",up:"arrowup",arrowup:"arrowup",down:"arrowdown",arrowdown:"arrowdown",left:"arrowleft",arrowleft:"arrowleft",right:"arrowright",arrowright:"arrowright"},D=X[S]||S,T=!1;for(let A of V){let M=X[A]||A;if(this.debugLog("[processEvent] Comparing constraint:",A,"->",M,"vs",D,"code:",r.code),M===D){T=!0;break}if(r.code&&r.code.toLowerCase()===`key${M}`){T=!0;break}}if(!T){this.debugLog("[processEvent] No key match found.");return}}}let a=i.find(m=>m.startsWith("debounce")),d=i.find(m=>m.startsWith("throttle")),g=`${e.id||this.getUniqueId(e)}-${t}-${n}`;if(a){let m=this.parseDuration(i,250);this.debouncers.has(g)&&window.clearTimeout(this.debouncers.get(g));let E=window.setTimeout(()=>{this.debouncers.delete(g),this.dispatchEvent(e,t,n,r,o)},m);this.debouncers.set(g,E);return}if(d){let m=this.parseDuration(i,250);if(this.throttlers.has(g))return;this.throttlers.set(g,Date.now()),this.dispatchEvent(e,t,n,r,o),window.setTimeout(()=>{this.throttlers.delete(g)},m);return}this.dispatchEvent(e,t,n,r,o)}dispatchEvent(e,t,n,i,r){let o={};r&&r.length>0?r.forEach((d,w)=>{o[`arg${w}`]=d}):o=this.getArgs(e);let a={type:t,id:e.id,args:o};if(e instanceof HTMLInputElement?(a.value=e.value,(e.type==="checkbox"||e.type==="radio")&&(a.checked=e.checked)):(e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&(a.value=e.value),i instanceof KeyboardEvent&&(a.key=i.key,a.keyCode=i.keyCode),t==="submit"&&e instanceof HTMLFormElement){let d=new FormData(e),w={};d.forEach((g,m)=>{g instanceof File||(w[m]=g.toString())}),a.formData=w}this.app.sendEvent(n,a)}parseDuration(e,t){let n=e.findIndex(a=>a.startsWith("debounce")),i=e.findIndex(a=>a.startsWith("throttle")),r=n!==-1?n:i;if(r!==-1&&e[r+1]){let a=e[r+1];if(a.endsWith("ms")){let d=parseInt(a);if(!isNaN(d))return d}}let o=e[r];if(o&&o.includes("-")){let a=o.split("-"),d=parseInt(a[1]);if(!isNaN(d))return d}return t}getUniqueId(e){return e.id||(e.id="pywire-uid-"+Math.random().toString(36).substr(2,9)),e.id}getArgs(e){let t={};if(e instanceof HTMLElement){for(let n in e.dataset)if(n.startsWith("arg"))try{t[n]=JSON.parse(e.dataset[n]||"null")}catch{t[n]=e.dataset[n]}}return t}};var Ht={autoInit:!0,enableWebTransport:!0,enableWebSocket:!0,enableHTTP:!0,debug:!1},O=class{constructor(e={}){this.initialized=!1;this.siblingPaths=[];this.pathRegexes=[];this.pjaxEnabled=!1;this.isConnected=!1;this.config={...Ht,...e},this.transport=new _(this.config),this.updater=new b(this.config.debug),this.eventHandler=new ue(this)}getConfig(){return this.config}async init(){if(!this.initialized){this.initialized=!0,this.transport.onMessage(e=>this.handleMessage(e)),this.transport.onStatusChange(e=>this.handleStatusChange(e));try{await this.transport.connect()}catch(e){console.error("PyWire: Failed to connect:",e)}this.loadSPAMetadata(),this.setupSPANavigation(),this.eventHandler.init(),console.log(`PyWire: Initialized (transport: ${this.transport.getActiveTransport()}, spa_paths: ${this.siblingPaths.length}, pjax: ${this.pjaxEnabled})`)}}handleStatusChange(e){this.isConnected=e}loadSPAMetadata(){let e=document.getElementById("_pywire_spa_meta");if(e)try{let t=JSON.parse(e.textContent||"{}");this.siblingPaths=t.sibling_paths||[],this.pjaxEnabled=!!t.enable_pjax,t.debug!==void 0&&(this.config.debug=!!t.debug),this.pathRegexes=this.siblingPaths.map(n=>this.patternToRegex(n))}catch(t){console.warn("PyWire: Failed to parse SPA metadata",t)}}patternToRegex(e){let t=e.replace(/[.+?^${}()|[\]\\]/g,"\\$&");return t=t.replace(/:(\\w+)(:\\w+)?/g,"([^/]+)"),t=t.replace(/\\{(\\w+)(:\\w+)?\\}/g,"([^/]+)"),new RegExp(`^${t}$`)}isSiblingPath(e){return this.pathRegexes.some(t=>t.test(e))}setupSPANavigation(){window.addEventListener("popstate",()=>{this.sendRelocate(window.location.pathname+window.location.search)}),!(this.siblingPaths.length===0&&!this.pjaxEnabled)&&document.addEventListener("click",e=>{let t=e.target.closest("a[href]");if(!t||t.origin!==window.location.origin||t.hasAttribute("download")||t.target==="_blank")return;let n=!1;(this.pjaxEnabled||this.isSiblingPath(t.pathname))&&(n=!0),n&&(e.preventDefault(),this.navigateTo(t.pathname+t.search))})}navigateTo(e){if(!this.isConnected){console.warn("PyWire: Navigation blocked - Offline");return}history.pushState({},"",e),this.sendRelocate(e)}sendRelocate(e){let t={type:"relocate",path:e};this.transport.send(t)}sendEvent(e,t){let n={type:"event",handler:e,path:window.location.pathname+window.location.search,data:t};this.transport.send(n)}async handleMessage(e){switch(e.type){case"update":e.regions&&e.regions.length>0?e.regions.forEach(t=>{this.updater.updateRegion(t.region,t.html)}):e.html&&this.updater.update(e.html);break;case"reload":console.log("PyWire: Reloading..."),window.location.reload();break;case"error":console.error("PyWire: Server error:",e.error);break;case"error_trace":console.error("PyWire: Error:",e.error);break;case"console":if(e.lines&&e.lines.length>0){let t="PyWire Server:",n=e.lines.join(`
3
+ `);e.level==="error"?console.error(t,n):e.level==="warn"?console.warn(t,n):console.log(t,n)}break;default:console.warn("PyWire: Unknown message type",e)}}getTransport(){return this.transport.getActiveTransport()}disconnect(){this.transport.disconnect()}};var Ee=new O;document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>Ee.init()):Ee.init();return Ze(Rt);})();
@@ -0,0 +1,20 @@
1
+ /* PyWire Client dev v0.1.3 - https://github.com/pywire/pywire */
2
+ "use strict";var PyWire=(()=>{var oe=Object.defineProperty;var Ye=Object.getOwnPropertyDescriptor;var Je=Object.getOwnPropertyNames;var qe=Object.prototype.hasOwnProperty;var Ze=(i,e,t)=>e in i?oe(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var Qe=(i,e)=>{for(var t in e)oe(i,t,{get:e[t],enumerable:!0})},je=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Je(e))!qe.call(i,r)&&r!==t&&oe(i,r,{get:()=>e[r],enumerable:!(n=Ye(e,r))||n.enumerable});return i};var et=i=>je(oe({},"__esModule",{value:!0}),i);var c=(i,e,t)=>(Ze(i,typeof e!="symbol"?e+"":e,t),t);var Ft={};Qe(Ft,{DOMUpdater:()=>T,ErrorTraceHandler:()=>X,HTTPTransport:()=>z,PyWireApp:()=>O,PyWireDevApp:()=>G,StatusOverlay:()=>V,TransportManager:()=>_,WebSocketTransport:()=>F,WebTransportTransport:()=>C,app:()=>Me});var B=class{constructor(){this.messageHandlers=[];this.statusHandlers=[];this.connected=!1}onMessage(e){this.messageHandlers.push(e)}onStatusChange(e){this.statusHandlers.push(e)}isConnected(){return this.connected}notifyHandlers(e){for(let t of this.messageHandlers)try{t(e)}catch(n){console.error("PyWire: Error in message handler",n)}}notifyStatus(e){if(this.connected!==e){this.connected=e;for(let t of this.statusHandlers)try{t(e)}catch(n){console.error("PyWire: Error in status handler",n)}}}};var C=class i extends B{constructor(t){super();this.name="WebTransport";this.transport=null;this.writer=null;this.encoder=new TextEncoder;this.decoder=new TextDecoder;this.url=t||this.getDefaultUrl()}getDefaultUrl(){return`https://${window.location.host}/_pywire/webtransport`}static isSupported(){return typeof WebTransport<"u"}async connect(){if(!i.isSupported())throw new Error("WebTransport not supported in this browser");try{let t={},n=window.PYWIRE_CERT_HASH;n&&Array.isArray(n)&&(t.serverCertificateHashes=[{algorithm:"sha-256",value:new Uint8Array(n).buffer}],console.log("PyWire: Using explicit certificate hash for WebTransport")),this.transport=new WebTransport(this.url,t),await this.transport.ready,console.log("PyWire: WebTransport ready"),this.connected=!0,this.startReading()}catch(t){throw this.handleDisconnect(),t}}async startReading(){if(!this.transport)return;let t=this.transport.incomingBidirectionalStreams.getReader();try{for(;;){let{value:n,done:r}=await t.read();if(r)break;this.handleStream(n)}}catch(n){this.connected&&(console.error("PyWire: WebTransport read error",n),this.handleDisconnect())}}async handleStream(t){let n=t.readable.getReader();try{for(;;){let{value:r,done:s}=await n.read();if(s)break;if(r){let o=this.decoder.decode(r);try{let a=JSON.parse(o);this.notifyHandlers(a)}catch(a){console.error("PyWire: Error parsing WebTransport message",a)}}}}catch(r){console.error("PyWire: Stream read error",r)}}async send(t){if(!this.transport||!this.connected){console.warn("PyWire: Cannot send message, WebTransport not connected");return}try{let n=await this.transport.createBidirectionalStream(),r=n.writable.getWriter(),s=this.encoder.encode(JSON.stringify(t));await r.write(s),await r.close(),this.handleStream(n)}catch(n){console.error("PyWire: WebTransport send error",n)}}disconnect(){this.transport&&(this.transport.close(),this.transport=null),this.writer=null,this.connected=!1}handleDisconnect(){this.connected=!1,this.transport=null,this.writer=null}};function Ce(i){let e=i.length,t=0,n=0;for(;n<e;){let r=i.charCodeAt(n++);if(r&4294967168)if(!(r&4294965248))t+=2;else{if(r>=55296&&r<=56319&&n<e){let s=i.charCodeAt(n);(s&64512)===56320&&(++n,r=((r&1023)<<10)+(s&1023)+65536)}r&4294901760?t+=4:t+=3}else{t++;continue}}return t}function tt(i,e,t){let n=i.length,r=t,s=0;for(;s<n;){let o=i.charCodeAt(s++);if(o&4294967168)if(!(o&4294965248))e[r++]=o>>6&31|192;else{if(o>=55296&&o<=56319&&s<n){let a=i.charCodeAt(s);(a&64512)===56320&&(++s,o=((o&1023)<<10)+(a&1023)+65536)}o&4294901760?(e[r++]=o>>18&7|240,e[r++]=o>>12&63|128,e[r++]=o>>6&63|128):(e[r++]=o>>12&15|224,e[r++]=o>>6&63|128)}else{e[r++]=o;continue}e[r++]=o&63|128}}var nt=new TextEncoder,rt=50;function it(i,e,t){nt.encodeInto(i,e.subarray(t))}function Le(i,e,t){i.length>rt?it(i,e,t):tt(i,e,t)}var st=4096;function be(i,e,t){let n=e,r=n+t,s=[],o="";for(;n<r;){let a=i[n++];if(!(a&128))s.push(a);else if((a&224)===192){let l=i[n++]&63;s.push((a&31)<<6|l)}else if((a&240)===224){let l=i[n++]&63,p=i[n++]&63;s.push((a&31)<<12|l<<6|p)}else if((a&248)===240){let l=i[n++]&63,p=i[n++]&63,y=i[n++]&63,g=(a&7)<<18|l<<12|p<<6|y;g>65535&&(g-=65536,s.push(g>>>10&1023|55296),g=56320|g&1023),s.push(g)}else s.push(a);s.length>=st&&(o+=String.fromCharCode(...s),s.length=0)}return s.length>0&&(o+=String.fromCharCode(...s)),o}var ot=new TextDecoder,at=200;function ct(i,e,t){let n=i.subarray(e,e+t);return ot.decode(n)}function We(i,e,t){return t>at?ct(i,e,t):be(i,e,t)}var L=class{constructor(e,t){c(this,"type");c(this,"data");this.type=e,this.data=t}};var x=class i extends Error{constructor(e){super(e);let t=Object.create(i.prototype);Object.setPrototypeOf(this,t),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:i.name})}};function He(i,e,t){let n=t/4294967296,r=t;i.setUint32(e,n),i.setUint32(e+4,r)}function ae(i,e,t){let n=Math.floor(t/4294967296),r=t;i.setUint32(e,n),i.setUint32(e+4,r)}function ce(i,e){let t=i.getInt32(e),n=i.getUint32(e+4);return t*4294967296+n}function De(i,e){let t=i.getUint32(e),n=i.getUint32(e+4);return t*4294967296+n}var lt=-1,dt=4294967296-1,ht=17179869184-1;function ft({sec:i,nsec:e}){if(i>=0&&e>=0&&i<=ht)if(e===0&&i<=dt){let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,i),t}else{let t=i/4294967296,n=i&4294967295,r=new Uint8Array(8),s=new DataView(r.buffer);return s.setUint32(0,e<<2|t&3),s.setUint32(4,n),r}else{let t=new Uint8Array(12),n=new DataView(t.buffer);return n.setUint32(0,e),ae(n,4,i),t}}function ut(i){let e=i.getTime(),t=Math.floor(e/1e3),n=(e-t*1e3)*1e6,r=Math.floor(n/1e9);return{sec:t+r,nsec:n-r*1e9}}function pt(i){if(i instanceof Date){let e=ut(i);return ft(e)}else return null}function gt(i){let e=new DataView(i.buffer,i.byteOffset,i.byteLength);switch(i.byteLength){case 4:return{sec:e.getUint32(0),nsec:0};case 8:{let t=e.getUint32(0),n=e.getUint32(4),r=(t&3)*4294967296+n,s=t>>>2;return{sec:r,nsec:s}}case 12:{let t=ce(e,4),n=e.getUint32(0);return{sec:t,nsec:n}}default:throw new x(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${i.length}`)}}function mt(i){let e=gt(i);return new Date(e.sec*1e3+e.nsec/1e6)}var Re={type:lt,encode:pt,decode:mt};var le=class le{constructor(){c(this,"__brand");c(this,"builtInEncoders",[]);c(this,"builtInDecoders",[]);c(this,"encoders",[]);c(this,"decoders",[]);this.register(Re)}register({type:e,encode:t,decode:n}){if(e>=0)this.encoders[e]=t,this.decoders[e]=n;else{let r=-1-e;this.builtInEncoders[r]=t,this.builtInDecoders[r]=n}}tryToEncode(e,t){for(let n=0;n<this.builtInEncoders.length;n++){let r=this.builtInEncoders[n];if(r!=null){let s=r(e,t);if(s!=null){let o=-1-n;return new L(o,s)}}}for(let n=0;n<this.encoders.length;n++){let r=this.encoders[n];if(r!=null){let s=r(e,t);if(s!=null){let o=n;return new L(o,s)}}}return e instanceof L?e:null}decode(e,t,n){let r=t<0?this.builtInDecoders[-1-t]:this.decoders[t];return r?r(e,t,n):new L(t,e)}};c(le,"defaultCodec",new le);var $=le;function yt(i){return i instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&i instanceof SharedArrayBuffer}function q(i){return i instanceof Uint8Array?i:ArrayBuffer.isView(i)?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):yt(i)?new Uint8Array(i):Uint8Array.from(i)}var wt=100,xt=2048,de=class i{constructor(e){c(this,"extensionCodec");c(this,"context");c(this,"useBigInt64");c(this,"maxDepth");c(this,"initialBufferSize");c(this,"sortKeys");c(this,"forceFloat32");c(this,"ignoreUndefined");c(this,"forceIntegerToFloat");c(this,"pos");c(this,"view");c(this,"bytes");c(this,"entered",!1);this.extensionCodec=e?.extensionCodec??$.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.maxDepth=e?.maxDepth??wt,this.initialBufferSize=e?.initialBufferSize??xt,this.sortKeys=e?.sortKeys??!1,this.forceFloat32=e?.forceFloat32??!1,this.ignoreUndefined=e?.ignoreUndefined??!1,this.forceIntegerToFloat=e?.forceIntegerToFloat??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new i({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,maxDepth:this.maxDepth,initialBufferSize:this.initialBufferSize,sortKeys:this.sortKeys,forceFloat32:this.forceFloat32,ignoreUndefined:this.ignoreUndefined,forceIntegerToFloat:this.forceIntegerToFloat})}reinitializeState(){this.pos=0}encodeSharedRef(e){if(this.entered)return this.clone().encodeSharedRef(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode(e){if(this.entered)return this.clone().encode(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode(e,t){if(t>this.maxDepth)throw new Error(`Too deep objects in depth ${t}`);e==null?this.encodeNil():typeof e=="boolean"?this.encodeBoolean(e):typeof e=="number"?this.forceIntegerToFloat?this.encodeNumberAsFloat(e):this.encodeNumber(e):typeof e=="string"?this.encodeString(e):this.useBigInt64&&typeof e=="bigint"?this.encodeBigInt64(e):this.encodeObject(e,t)}ensureBufferSizeToWrite(e){let t=this.pos+e;this.view.byteLength<t&&this.resizeBuffer(t*2)}resizeBuffer(e){let t=new ArrayBuffer(e),n=new Uint8Array(t),r=new DataView(t);n.set(this.bytes),this.view=r,this.bytes=n}encodeNil(){this.writeU8(192)}encodeBoolean(e){e===!1?this.writeU8(194):this.writeU8(195)}encodeNumber(e){!this.forceIntegerToFloat&&Number.isSafeInteger(e)?e>=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(211),this.writeI64(e)):this.encodeNumberAsFloat(e)}encodeNumberAsFloat(e){this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))}encodeBigInt64(e){e>=BigInt(0)?(this.writeU8(207),this.writeBigUint64(e)):(this.writeU8(211),this.writeBigInt64(e))}writeStringHeader(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else if(e<4294967296)this.writeU8(219),this.writeU32(e);else throw new Error(`Too long string: ${e} bytes in UTF-8`)}encodeString(e){let n=Ce(e);this.ensureBufferSizeToWrite(5+n),this.writeStringHeader(n),Le(e,this.bytes,this.pos),this.pos+=n}encodeObject(e,t){let n=this.extensionCodec.tryToEncode(e,this.context);if(n!=null)this.encodeExtension(n);else if(Array.isArray(e))this.encodeArray(e,t);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else if(typeof e=="object")this.encodeMap(e,t);else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(e)}`)}encodeBinary(e){let t=e.byteLength;if(t<256)this.writeU8(196),this.writeU8(t);else if(t<65536)this.writeU8(197),this.writeU16(t);else if(t<4294967296)this.writeU8(198),this.writeU32(t);else throw new Error(`Too large binary: ${t}`);let n=q(e);this.writeU8a(n)}encodeArray(e,t){let n=e.length;if(n<16)this.writeU8(144+n);else if(n<65536)this.writeU8(220),this.writeU16(n);else if(n<4294967296)this.writeU8(221),this.writeU32(n);else throw new Error(`Too large array: ${n}`);for(let r of e)this.doEncode(r,t+1)}countWithoutUndefined(e,t){let n=0;for(let r of t)e[r]!==void 0&&n++;return n}encodeMap(e,t){let n=Object.keys(e);this.sortKeys&&n.sort();let r=this.ignoreUndefined?this.countWithoutUndefined(e,n):n.length;if(r<16)this.writeU8(128+r);else if(r<65536)this.writeU8(222),this.writeU16(r);else if(r<4294967296)this.writeU8(223),this.writeU32(r);else throw new Error(`Too large map object: ${r}`);for(let s of n){let o=e[s];this.ignoreUndefined&&o===void 0||(this.encodeString(s),this.doEncode(o,t+1))}}encodeExtension(e){if(typeof e.data=="function"){let n=e.data(this.pos+6),r=n.length;if(r>=4294967296)throw new Error(`Too large extension object: ${r}`);this.writeU8(201),this.writeU32(r),this.writeI8(e.type),this.writeU8a(n);return}let t=e.data.length;if(t===1)this.writeU8(212);else if(t===2)this.writeU8(213);else if(t===4)this.writeU8(214);else if(t===8)this.writeU8(215);else if(t===16)this.writeU8(216);else if(t<256)this.writeU8(199),this.writeU8(t);else if(t<65536)this.writeU8(200),this.writeU16(t);else if(t<4294967296)this.writeU8(201),this.writeU32(t);else throw new Error(`Too large extension object: ${t}`);this.writeI8(e.type),this.writeU8a(e.data)}writeU8(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++}writeU8a(e){let t=e.length;this.ensureBufferSizeToWrite(t),this.bytes.set(e,this.pos),this.pos+=t}writeI8(e){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,e),this.pos++}writeU16(e){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,e),this.pos+=2}writeI16(e){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,e),this.pos+=2}writeU32(e){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,e),this.pos+=4}writeI32(e){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,e),this.pos+=4}writeF32(e){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,e),this.pos+=4}writeF64(e){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,e),this.pos+=8}writeU64(e){this.ensureBufferSizeToWrite(8),He(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),ae(this.view,this.pos,e),this.pos+=8}writeBigUint64(e){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,e),this.pos+=8}writeBigInt64(e){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,e),this.pos+=8}};function N(i,e){return new de(e).encodeSharedRef(i)}function he(i){return`${i<0?"-":""}0x${Math.abs(i).toString(16).padStart(2,"0")}`}var vt=16,St=16,fe=class{constructor(e=vt,t=St){c(this,"hit",0);c(this,"miss",0);c(this,"caches");c(this,"maxKeyLength");c(this,"maxLengthPerKey");this.maxKeyLength=e,this.maxLengthPerKey=t,this.caches=[];for(let n=0;n<this.maxKeyLength;n++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,t,n){let r=this.caches[n-1];e:for(let s of r){let o=s.bytes;for(let a=0;a<n;a++)if(o[a]!==e[t+a])continue e;return s.str}return null}store(e,t){let n=this.caches[e.length-1],r={bytes:e,str:t};n.length>=this.maxLengthPerKey?n[Math.random()*n.length|0]=r:n.push(r)}decode(e,t,n){let r=this.find(e,t,n);if(r!=null)return this.hit++,r;this.miss++;let s=be(e,t,n),o=Uint8Array.prototype.slice.call(e,t,t+n);return this.store(o,s),s}};var Te="array",j="map_key",Ne="map_value",bt=i=>{if(typeof i=="string"||typeof i=="number")return i;throw new x("The type of key must be string or number but "+typeof i)},Ue=class{constructor(){c(this,"stack",[]);c(this,"stackHeadPosition",-1)}get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){let t=this.getUninitializedStateFromPool();t.type=Te,t.position=0,t.size=e,t.array=new Array(e)}pushMapState(e){let t=this.getUninitializedStateFromPool();t.type=j,t.readCount=0,t.size=e,t.map={}}getUninitializedStateFromPool(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){let e={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push(e)}return this.stack[this.stackHeadPosition]}release(e){if(this.stack[this.stackHeadPosition]!==e)throw new Error("Invalid stack state. Released state is not on top of the stack.");if(e.type===Te){let n=e;n.size=0,n.array=void 0,n.position=0,n.type=void 0}if(e.type===j||e.type===Ne){let n=e;n.size=0,n.map=void 0,n.readCount=0,n.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}},Q=-1,Ee=new DataView(new ArrayBuffer(0)),Tt=new Uint8Array(Ee.buffer);try{Ee.getInt8(0)}catch(i){if(!(i instanceof RangeError))throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}var $e=new RangeError("Insufficient data"),Ut=new fe,ue=class i{constructor(e){c(this,"extensionCodec");c(this,"context");c(this,"useBigInt64");c(this,"rawStrings");c(this,"maxStrLength");c(this,"maxBinLength");c(this,"maxArrayLength");c(this,"maxMapLength");c(this,"maxExtLength");c(this,"keyDecoder");c(this,"mapKeyConverter");c(this,"totalPos",0);c(this,"pos",0);c(this,"view",Ee);c(this,"bytes",Tt);c(this,"headByte",Q);c(this,"stack",new Ue);c(this,"entered",!1);this.extensionCodec=e?.extensionCodec??$.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.rawStrings=e?.rawStrings??!1,this.maxStrLength=e?.maxStrLength??4294967295,this.maxBinLength=e?.maxBinLength??4294967295,this.maxArrayLength=e?.maxArrayLength??4294967295,this.maxMapLength=e?.maxMapLength??4294967295,this.maxExtLength=e?.maxExtLength??4294967295,this.keyDecoder=e?.keyDecoder!==void 0?e.keyDecoder:Ut,this.mapKeyConverter=e?.mapKeyConverter??bt}clone(){return new i({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,rawStrings:this.rawStrings,maxStrLength:this.maxStrLength,maxBinLength:this.maxBinLength,maxArrayLength:this.maxArrayLength,maxMapLength:this.maxMapLength,maxExtLength:this.maxExtLength,keyDecoder:this.keyDecoder})}reinitializeState(){this.totalPos=0,this.headByte=Q,this.stack.reset()}setBuffer(e){let t=q(e);this.bytes=t,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===Q&&!this.hasRemaining(1))this.setBuffer(e);else{let t=this.bytes.subarray(this.pos),n=q(e),r=new Uint8Array(t.length+n.length);r.set(t),r.set(n,t.length),this.setBuffer(r)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){let{view:t,pos:n}=this;return new RangeError(`Extra ${t.byteLength-n} of ${t.byteLength} byte(s) found at buffer[${e}]`)}decode(e){if(this.entered)return this.clone().decode(e);try{this.entered=!0,this.reinitializeState(),this.setBuffer(e);let t=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return t}finally{this.entered=!1}}*decodeMulti(e){if(this.entered){yield*this.clone().decodeMulti(e);return}try{for(this.entered=!0,this.reinitializeState(),this.setBuffer(e);this.hasRemaining(1);)yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(e){if(this.entered)return this.clone().decodeAsync(e);try{this.entered=!0;let t=!1,n;for await(let a of e){if(t)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(a);try{n=this.doDecodeSync(),t=!0}catch(l){if(!(l instanceof RangeError))throw l}this.totalPos+=this.pos}if(t){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return n}let{headByte:r,pos:s,totalPos:o}=this;throw new RangeError(`Insufficient data in parsing ${he(r)} at ${o} (${s} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(e){return this.decodeMultiAsync(e,!0)}decodeStream(e){return this.decodeMultiAsync(e,!1)}async*decodeMultiAsync(e,t){if(this.entered){yield*this.clone().decodeMultiAsync(e,t);return}try{this.entered=!0;let n=t,r=-1;for await(let s of e){if(t&&r===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(s),n&&(r=this.readArraySize(),n=!1,this.complete());try{for(;yield this.doDecodeSync(),--r!==0;);}catch(o){if(!(o instanceof RangeError))throw o}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){e:for(;;){let e=this.readHeadByte(),t;if(e>=224)t=e-256;else if(e<192)if(e<128)t=e;else if(e<144){let r=e-128;if(r!==0){this.pushMapState(r),this.complete();continue e}else t={}}else if(e<160){let r=e-144;if(r!==0){this.pushArrayState(r),this.complete();continue e}else t=[]}else{let r=e-160;t=this.decodeString(r,0)}else if(e===192)t=null;else if(e===194)t=!1;else if(e===195)t=!0;else if(e===202)t=this.readF32();else if(e===203)t=this.readF64();else if(e===204)t=this.readU8();else if(e===205)t=this.readU16();else if(e===206)t=this.readU32();else if(e===207)this.useBigInt64?t=this.readU64AsBigInt():t=this.readU64();else if(e===208)t=this.readI8();else if(e===209)t=this.readI16();else if(e===210)t=this.readI32();else if(e===211)this.useBigInt64?t=this.readI64AsBigInt():t=this.readI64();else if(e===217){let r=this.lookU8();t=this.decodeString(r,1)}else if(e===218){let r=this.lookU16();t=this.decodeString(r,2)}else if(e===219){let r=this.lookU32();t=this.decodeString(r,4)}else if(e===220){let r=this.readU16();if(r!==0){this.pushArrayState(r),this.complete();continue e}else t=[]}else if(e===221){let r=this.readU32();if(r!==0){this.pushArrayState(r),this.complete();continue e}else t=[]}else if(e===222){let r=this.readU16();if(r!==0){this.pushMapState(r),this.complete();continue e}else t={}}else if(e===223){let r=this.readU32();if(r!==0){this.pushMapState(r),this.complete();continue e}else t={}}else if(e===196){let r=this.lookU8();t=this.decodeBinary(r,1)}else if(e===197){let r=this.lookU16();t=this.decodeBinary(r,2)}else if(e===198){let r=this.lookU32();t=this.decodeBinary(r,4)}else if(e===212)t=this.decodeExtension(1,0);else if(e===213)t=this.decodeExtension(2,0);else if(e===214)t=this.decodeExtension(4,0);else if(e===215)t=this.decodeExtension(8,0);else if(e===216)t=this.decodeExtension(16,0);else if(e===199){let r=this.lookU8();t=this.decodeExtension(r,1)}else if(e===200){let r=this.lookU16();t=this.decodeExtension(r,2)}else if(e===201){let r=this.lookU32();t=this.decodeExtension(r,4)}else throw new x(`Unrecognized type byte: ${he(e)}`);this.complete();let n=this.stack;for(;n.length>0;){let r=n.top();if(r.type===Te)if(r.array[r.position]=t,r.position++,r.position===r.size)t=r.array,n.release(r);else continue e;else if(r.type===j){if(t==="__proto__")throw new x("The key __proto__ is not allowed");r.key=this.mapKeyConverter(t),r.type=Ne;continue e}else if(r.map[r.key]=t,r.readCount++,r.readCount===r.size)t=r.map,n.release(r);else{r.key=null,r.type=j;continue e}}return t}}readHeadByte(){return this.headByte===Q&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=Q}readArraySize(){let e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:{if(e<160)return e-144;throw new x(`Unrecognized array type byte: ${he(e)}`)}}}pushMapState(e){if(e>this.maxMapLength)throw new x(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new x(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(e)}decodeString(e,t){return!this.rawStrings||this.stateIsMapKey()?this.decodeUtf8String(e,t):this.decodeBinary(e,t)}decodeUtf8String(e,t){if(e>this.maxStrLength)throw new x(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+t+e)throw $e;let n=this.pos+t,r;return this.stateIsMapKey()&&this.keyDecoder?.canBeCached(e)?r=this.keyDecoder.decode(this.bytes,n,e):r=We(this.bytes,n,e),this.pos+=t+e,r}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===j:!1}decodeBinary(e,t){if(e>this.maxBinLength)throw new x(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+t))throw $e;let n=this.pos+t,r=this.bytes.subarray(n,n+e);return this.pos+=t+e,r}decodeExtension(e,t){if(e>this.maxExtLength)throw new x(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);let n=this.view.getInt8(this.pos+t),r=this.decodeBinary(e,t+1);return this.extensionCodec.decode(r,n,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){let e=this.view.getUint8(this.pos);return this.pos++,e}readI8(){let e=this.view.getInt8(this.pos);return this.pos++,e}readU16(){let e=this.view.getUint16(this.pos);return this.pos+=2,e}readI16(){let e=this.view.getInt16(this.pos);return this.pos+=2,e}readU32(){let e=this.view.getUint32(this.pos);return this.pos+=4,e}readI32(){let e=this.view.getInt32(this.pos);return this.pos+=4,e}readU64(){let e=De(this.view,this.pos);return this.pos+=8,e}readI64(){let e=ce(this.view,this.pos);return this.pos+=8,e}readU64AsBigInt(){let e=this.view.getBigUint64(this.pos);return this.pos+=8,e}readI64AsBigInt(){let e=this.view.getBigInt64(this.pos);return this.pos+=8,e}readF32(){let e=this.view.getFloat32(this.pos);return this.pos+=4,e}readF64(){let e=this.view.getFloat64(this.pos);return this.pos+=8,e}};function W(i,e){return new ue(e).decode(i)}var F=class extends B{constructor(t){super();this.name="WebSocket";this.socket=null;this.reconnectAttempts=0;this.maxReconnectDelay=5e3;this.shouldReconnect=!0;this.url=t||this.getDefaultUrl()}getDefaultUrl(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/_pywire/ws`}connect(){return new Promise((t,n)=>{try{this.socket=new WebSocket(this.url),this.socket.binaryType="arraybuffer",this.socket.onopen=()=>{console.log("PyWire: WebSocket connected"),this.notifyStatus(!0),this.reconnectAttempts=0,t()},this.socket.onmessage=r=>{try{let s=W(r.data);this.notifyHandlers(s)}catch(s){console.error("PyWire: Error parsing WebSocket message",s)}},this.socket.onclose=()=>{console.log("PyWire: WebSocket disconnected"),this.notifyStatus(!1),this.shouldReconnect&&this.scheduleReconnect()},this.socket.onerror=r=>{console.error("PyWire: WebSocket error",r),this.connected||n(new Error("WebSocket connection failed"))}}catch(r){n(r)}})}send(t){this.socket&&this.socket.readyState===WebSocket.OPEN?this.socket.send(N(t)):console.warn("PyWire: Cannot send message, WebSocket not open")}disconnect(){this.shouldReconnect=!1,this.socket&&(this.socket.close(),this.socket=null),this.notifyStatus(!1)}scheduleReconnect(){let t=Math.min(1e3*Math.pow(2,this.reconnectAttempts),this.maxReconnectDelay);console.log(`PyWire: Reconnecting in ${t}ms...`),setTimeout(()=>{this.reconnectAttempts++,this.connect().catch(()=>{})},t)}};var z=class extends B{constructor(t){super();this.name="HTTP";this.polling=!1;this.pollAbortController=null;this.sessionId=null;this.baseUrl=t||`${window.location.origin}/_pywire`}async connect(){try{let t=await fetch(`${this.baseUrl}/session`,{method:"POST",headers:{"Content-Type":"application/x-msgpack",Accept:"application/x-msgpack"},body:N({path:window.location.pathname+window.location.search})});if(!t.ok)throw new Error(`HTTP session init failed: ${t.status}`);let n=await t.arrayBuffer(),r=W(n);this.sessionId=r.sessionId,console.log("PyWire: HTTP transport connected"),this.notifyStatus(!0),this.startPolling()}catch(t){throw console.error("PyWire: HTTP transport connection failed",t),t}}async startPolling(){if(!this.polling)for(this.polling=!0;this.polling&&this.connected;)try{this.pollAbortController=new AbortController;let t=await fetch(`${this.baseUrl}/poll?session=${this.sessionId}`,{method:"GET",signal:this.pollAbortController.signal,headers:{Accept:"application/x-msgpack"}});if(!t.ok){if(t.status===404){console.warn("PyWire: HTTP session expired, reconnecting..."),this.notifyStatus(!1),await this.connect();return}throw new Error(`Poll failed: ${t.status}`)}let n=await t.arrayBuffer(),r=W(n);for(let s of r)this.notifyHandlers(s)}catch(t){if(t instanceof Error&&t.name==="AbortError")break;console.error("PyWire: HTTP poll error",t),await this.sleep(1e3)}}async send(t){if(!this.connected||!this.sessionId){console.warn("PyWire: Cannot send message, HTTP transport not connected");return}try{let n=await fetch(`${this.baseUrl}/event`,{method:"POST",headers:{"Content-Type":"application/x-msgpack",Accept:"application/x-msgpack","X-PyWire-Session":this.sessionId},body:N(t)});if(!n.ok)throw new Error(`Event send failed: ${n.status}`);let r=await n.arrayBuffer(),s=W(r);this.notifyHandlers(s)}catch(n){console.error("PyWire: HTTP send error",n)}}disconnect(){this.polling=!1,this.notifyStatus(!1),this.pollAbortController&&(this.pollAbortController.abort(),this.pollAbortController=null),this.sessionId=null}sleep(t){return new Promise(n=>setTimeout(n,t))}};var Et={enableWebTransport:!0,enableWebSocket:!0,enableHTTP:!0},_=class{constructor(e={}){this.transport=null;this.messageHandlers=[];this.statusHandlers=[];this.config={...Et,...e}}async connect(){let e=this.getTransportPriority();for(let t of e)try{console.log(`PyWire: Trying ${t.name}...`),this.transport=new t;for(let n of this.messageHandlers)this.transport.onMessage(n);this.transport.onStatusChange(n=>{this.notifyStatusHandlers(n)}),await this.transport.connect(),console.log(`PyWire: Connected via ${this.transport.name}`);return}catch(n){console.warn(`PyWire: ${t.name} failed, trying next...`,n),this.transport=null}throw new Error("PyWire: All transports failed")}getTransportPriority(){let e=[];return this.config.enableWebTransport&&C.isSupported()&&window.location.protocol==="https:"&&e.push(C),this.config.enableWebSocket&&typeof WebSocket<"u"&&e.push(F),this.config.enableHTTP&&e.push(z),e}send(e){this.transport?this.transport.send(e):console.warn("PyWire: No active transport")}onMessage(e){this.messageHandlers.push(e),this.transport&&this.transport.onMessage(e)}onStatusChange(e){this.statusHandlers.push(e)}notifyStatusHandlers(e){for(let t of this.statusHandlers)t(e)}disconnect(){this.transport&&(this.transport.disconnect(),this.transport=null,this.notifyStatusHandlers(!1))}getActiveTransport(){return this.transport?.name||null}isConnected(){return this.transport?.isConnected()||!1}};var Fe=11;function At(i,e){var t=e.attributes,n,r,s,o,a;if(!(e.nodeType===Fe||i.nodeType===Fe)){for(var l=t.length-1;l>=0;l--)n=t[l],r=n.name,s=n.namespaceURI,o=n.value,s?(r=n.localName||r,a=i.getAttributeNS(s,r),a!==o&&(n.prefix==="xmlns"&&(r=n.name),i.setAttributeNS(s,r,o))):(a=i.getAttribute(r),a!==o&&i.setAttribute(r,o));for(var p=i.attributes,y=p.length-1;y>=0;y--)n=p[y],r=n.name,s=n.namespaceURI,s?(r=n.localName||r,e.hasAttributeNS(s,r)||i.removeAttributeNS(s,r)):e.hasAttribute(r)||i.removeAttribute(r)}}var pe,kt="http://www.w3.org/1999/xhtml",v=typeof document>"u"?void 0:document,Mt=!!v&&"content"in v.createElement("template"),Pt=!!v&&v.createRange&&"createContextualFragment"in v.createRange();function Bt(i){var e=v.createElement("template");return e.innerHTML=i,e.content.childNodes[0]}function It(i){pe||(pe=v.createRange(),pe.selectNode(v.body));var e=pe.createContextualFragment(i);return e.childNodes[0]}function Ct(i){var e=v.createElement("body");return e.innerHTML=i,e.childNodes[0]}function Lt(i){return i=i.trim(),Mt?Bt(i):Pt?It(i):Ct(i)}function ge(i,e){var t=i.nodeName,n=e.nodeName,r,s;return t===n?!0:(r=t.charCodeAt(0),s=n.charCodeAt(0),r<=90&&s>=97?t===n.toUpperCase():s<=90&&r>=97?n===t.toUpperCase():!1)}function Wt(i,e){return!e||e===kt?v.createElement(i):v.createElementNS(e,i)}function Ht(i,e){for(var t=i.firstChild;t;){var n=t.nextSibling;e.appendChild(t),t=n}return e}function Ae(i,e,t){i[t]!==e[t]&&(i[t]=e[t],i[t]?i.setAttribute(t,""):i.removeAttribute(t))}var ze={OPTION:function(i,e){var t=i.parentNode;if(t){var n=t.nodeName.toUpperCase();n==="OPTGROUP"&&(t=t.parentNode,n=t&&t.nodeName.toUpperCase()),n==="SELECT"&&!t.hasAttribute("multiple")&&(i.hasAttribute("selected")&&!e.selected&&(i.setAttribute("selected","selected"),i.removeAttribute("selected")),t.selectedIndex=-1)}Ae(i,e,"selected")},INPUT:function(i,e){Ae(i,e,"checked"),Ae(i,e,"disabled"),i.value!==e.value&&(i.value=e.value),e.hasAttribute("value")||i.removeAttribute("value")},TEXTAREA:function(i,e){var t=e.value;i.value!==t&&(i.value=t);var n=i.firstChild;if(n){var r=n.nodeValue;if(r==t||!t&&r==i.placeholder)return;n.nodeValue=t}},SELECT:function(i,e){if(!e.hasAttribute("multiple")){for(var t=-1,n=0,r=i.firstChild,s,o;r;)if(o=r.nodeName&&r.nodeName.toUpperCase(),o==="OPTGROUP")s=r,r=s.firstChild,r||(r=s.nextSibling,s=null);else{if(o==="OPTION"){if(r.hasAttribute("selected")){t=n;break}n++}r=r.nextSibling,!r&&s&&(r=s.nextSibling,s=null)}i.selectedIndex=t}}},ee=1,_e=11,Ke=3,Oe=8;function I(){}function Dt(i){if(i)return i.getAttribute&&i.getAttribute("id")||i.id}function Rt(i){return function(t,n,r){if(r||(r={}),typeof n=="string")if(t.nodeName==="#document"||t.nodeName==="HTML"||t.nodeName==="BODY"){var s=n;n=v.createElement("html"),n.innerHTML=s}else n=Lt(n);else n.nodeType===_e&&(n=n.firstElementChild);var o=r.getNodeKey||Dt,a=r.onBeforeNodeAdded||I,l=r.onNodeAdded||I,p=r.onBeforeElUpdated||I,y=r.onElUpdated||I,g=r.onBeforeNodeDiscarded||I,E=r.onNodeDiscarded||I,Y=r.onBeforeElChildrenUpdated||I,S=r.skipFromChildren||I,J=r.addChild||function(d,h){return d.appendChild(h)},H=r.childrenOnly===!0,b=Object.create(null),A=[];function k(d){A.push(d)}function Pe(d,h){if(d.nodeType===ee)for(var m=d.firstChild;m;){var f=void 0;h&&(f=o(m))?k(f):(E(m),m.firstChild&&Pe(m,h)),m=m.nextSibling}}function te(d,h,m){g(d)!==!1&&(h&&h.removeChild(d),E(d),Pe(d,m))}function ye(d){if(d.nodeType===ee||d.nodeType===_e)for(var h=d.firstChild;h;){var m=o(h);m&&(b[m]=h),ye(h),h=h.nextSibling}}ye(t);function we(d){l(d);for(var h=d.firstChild;h;){var m=h.nextSibling,f=o(h);if(f){var u=b[f];u&&ge(h,u)?(h.parentNode.replaceChild(u,h),ne(u,h)):we(h)}else we(h);h=m}}function Ve(d,h,m){for(;h;){var f=h.nextSibling;(m=o(h))?k(m):te(h,d,!0),h=f}}function ne(d,h,m){var f=o(h);if(f&&delete b[f],!m){var u=p(d,h);if(u===!1||(u instanceof HTMLElement&&(d=u,ye(d)),i(d,h),y(d),Y(d,h)===!1))return}d.nodeName!=="TEXTAREA"?Xe(d,h):ze.TEXTAREA(d,h)}function Xe(d,h){var m=S(d,h),f=h.firstChild,u=d.firstChild,D,U,R,ie,M;e:for(;f;){for(ie=f.nextSibling,D=o(f);!m&&u;){if(R=u.nextSibling,f.isSameNode&&f.isSameNode(u)){f=ie,u=R;continue e}U=o(u);var se=u.nodeType,P=void 0;if(se===f.nodeType&&(se===ee?(D?D!==U&&((M=b[D])?R===M?P=!1:(d.insertBefore(M,u),U?k(U):te(u,d,!0),u=M,U=o(u)):P=!1):U&&(P=!1),P=P!==!1&&ge(u,f),P&&ne(u,f)):(se===Ke||se==Oe)&&(P=!0,u.nodeValue!==f.nodeValue&&(u.nodeValue=f.nodeValue))),P){f=ie,u=R;continue e}U?k(U):te(u,d,!0),u=R}if(D&&(M=b[D])&&ge(M,f))m||J(d,M),ne(M,f);else{var Se=a(f);Se!==!1&&(Se&&(f=Se),f.actualize&&(f=f.actualize(d.ownerDocument||v)),J(d,f),we(f))}f=ie,u=R}Ve(d,u,U);var Ie=ze[d.nodeName];Ie&&Ie(d,h)}var w=t,re=w.nodeType,Be=n.nodeType;if(!H){if(re===ee)Be===ee?ge(t,n)||(E(t),w=Ht(t,Wt(n.nodeName,n.namespaceURI))):w=n;else if(re===Ke||re===Oe){if(Be===re)return w.nodeValue!==n.nodeValue&&(w.nodeValue=n.nodeValue),w;w=n}}if(w===n)E(t);else{if(n.isSameNode&&n.isSameNode(w))return;if(ne(w,n,H),A)for(var xe=0,Ge=A.length;xe<Ge;xe++){var ve=b[A[xe]];ve&&te(ve,ve.parentNode,!1)}}return!H&&w!==t&&t.parentNode&&(w.actualize&&(w=w.actualize(t.ownerDocument||v)),t.parentNode.replaceChild(w,t)),w}}var $t=Rt(At),ke=$t;var K=class K{constructor(e=!1){this.debug=e}getNodeKey(e){if(e instanceof HTMLElement){for(let t of e.attributes)if(t.name.startsWith("data-on-"))return`${e.tagName}-${t.name}-${t.value}`;if(e.id&&!e.id.startsWith("pywire-uid-"))return e.id;if((e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement)&&e.name)return`${e.tagName}-name-${e.name}`}}getElementSelector(e){if(e.id)return`#${e.id}`;let t=[],n=e;for(;n&&n!==document.body&&t.length<5;){let r=n.tagName.toLowerCase();if(n.id){r=`#${n.id}`,t.unshift(r);break}(n instanceof HTMLInputElement||n instanceof HTMLSelectElement||n instanceof HTMLTextAreaElement)&&n.name&&(r+=`[name="${n.name}"]`);for(let s of n.attributes)if(s.name.startsWith("data-on-")){r+=`[${s.name}="${s.value}"]`;break}if(n.parentElement){let o=Array.from(n.parentElement.children).filter(a=>a.tagName===n.tagName);if(o.length>1){let a=o.indexOf(n)+1;r+=`:nth-of-type(${a})`}}t.unshift(r),n=n.parentElement}return t.join(" > ")}captureFocusState(){let e=document.activeElement;if(!e||e===document.body||e===document.documentElement)return null;let t={selector:this.getElementSelector(e),id:e.id||null,tagName:e.tagName,selectionStart:null,selectionEnd:null,scrollTop:0,scrollLeft:0,value:""};return(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&(t.selectionStart=e.selectionStart,t.selectionEnd=e.selectionEnd,t.scrollTop=e.scrollTop,t.scrollLeft=e.scrollLeft,t.value=e.value),t}restoreFocusState(e){if(!e)return;let t=null;if(e.id&&(t=document.getElementById(e.id)),!t&&e.selector)try{t=document.querySelector(e.selector)}catch{}if(t&&(t.focus(),t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)){if(e.value&&t.value!==e.value&&(t.value=e.value),e.selectionStart!==null&&e.selectionEnd!==null)try{t.setSelectionRange(e.selectionStart,e.selectionEnd)}catch{}t.scrollTop=e.scrollTop,t.scrollLeft=e.scrollLeft}}applyUpdate(e,t){K.isUpdating=!0,this.debug&&console.log("[DOMUpdater] Starting update, isUpdating =",K.isUpdating);try{let n=this.captureFocusState();if(ke){try{ke(e,t,{getNodeKey:r=>this.getNodeKey(r),onBeforeElUpdated:(r,s)=>{if(r instanceof HTMLInputElement&&s instanceof HTMLInputElement)if(r.type==="checkbox"||r.type==="radio")s.checked=r.checked;else{let o=s.value||"",a=r.value||"";(a.startsWith(o)||o.startsWith(a))&&(s.value=a)}if(r instanceof HTMLTextAreaElement&&s instanceof HTMLTextAreaElement){let o=s.value||"",a=r.value||"";(a.startsWith(o)||o.startsWith(a))&&(s.value=a)}return r instanceof HTMLSelectElement&&s instanceof HTMLSelectElement&&(r.value&&Array.from(s.options).some(o=>o.value===r.value)?s.value=r.value:r.selectedIndex>=0&&r.selectedIndex<s.options.length&&(s.selectedIndex=r.selectedIndex)),r.id&&r.id.startsWith("pywire-uid-")&&!s.id&&(s.id=r.id),!0},onBeforeNodeDiscarded:()=>!0})}catch(r){console.error("Morphdom failed:",r),e===document.documentElement&&(document.open(),document.write(t),document.close())}this.restoreFocusState(n)}else e===document.documentElement&&(document.open(),document.write(t),document.close())}finally{setTimeout(()=>{K.isUpdating=!1},0)}}update(e){let t=/<html[\s>]/i.test(e),n=/<body[\s>]/i.test(e);if(!t&&document.body){if(n){this.applyUpdate(document.body,e);return}let r=`<body>${e}</body>`;this.applyUpdate(document.body,r);return}this.applyUpdate(document.documentElement,e)}updateRegion(e,t){let n=document.querySelector(`[data-pw-region="${e}"]`);if(!n){this.debug&&console.warn("[DOMUpdater] Region not found:",e);return}this.applyUpdate(n,t),n.getAttribute("data-pw-region")||n.setAttribute("data-pw-region",e)}};K.isUpdating=!1;var T=K;var me=class{constructor(e){this.debouncers=new Map;this.throttlers=new Map;this.supportedEvents=["click","submit","input","change","keydown","keyup","focus","blur","mouseenter","mouseleave","scroll","contextmenu"];this.suppressDuringUpdate=["focus","blur","mouseenter","mouseleave"];this.app=e}debugLog(...e){this.app.getConfig().debug&&console.log(...e)}init(){this.supportedEvents.forEach(e=>{let t=e==="mouseenter"||e==="mouseleave"||e==="focus"||e==="blur"||e==="scroll"?{capture:!0}:void 0;document.addEventListener(e,n=>this.handleEvent(n),t)})}getHandlers(e,t){let n=`data-on-${t}`,r=e.getAttribute(n);if(!r)return[];if(r.trim().startsWith("["))try{let s=JSON.parse(r);if(Array.isArray(s))return s.flatMap(o=>{if(!o||typeof o!="object")return[];let a="handler"in o&&typeof o.handler=="string"?o.handler:null;if(!a)return[];let l="modifiers"in o&&Array.isArray(o.modifiers)?o.modifiers.filter(y=>typeof y=="string"):[],p="args"in o&&Array.isArray(o.args)?o.args:void 0;return[{name:a,modifiers:l,args:p}]})}catch(s){console.error("Error parsing event handlers:",s)}else{let s=e.getAttribute(`data-modifiers-${t}`),o=s?s.split(" ").filter(a=>a):[];return[{name:r,modifiers:o,args:void 0}]}return[]}async handleEvent(e){let t=e.type;if(T.isUpdating&&this.suppressDuringUpdate.includes(t)){this.debugLog("[Handler] SUPPRESSING event during update:",t,"isUpdating=",T.isUpdating);return}this.debugLog("[Handler] Processing event:",t,"isUpdating=",T.isUpdating);let n=e.composedPath?e.composedPath():[],r=!1;for(let s of n){if(r)break;if(s instanceof HTMLElement){let o=s,a=this.getHandlers(o,t);if(a.length>0){this.debugLog("[handleEvent] Found handlers on",o.tagName,a);for(let l of a)!l.modifiers.includes("window")&&!l.modifiers.includes("outside")&&(this.processEvent(o,t,l.name,l.modifiers,e,l.args),e.cancelBubble&&(r=!0))}}}this.handleGlobalEvent(e)}handleGlobalEvent(e){let t=e.type,n=`[data-modifiers-${t}*="window"]`,r=`[data-modifiers-${t}*="outside"]`;document.querySelectorAll(`${n}, ${r}`).forEach(o=>{if(!(o instanceof HTMLElement))return;let a=this.getHandlers(o,t);for(let l of a)if(l.modifiers.includes("window")&&this.processEvent(o,t,l.name,l.modifiers,e,l.args),l.modifiers.includes("outside")){let p=e.target;p&&!o.contains(p)&&this.processEvent(o,t,l.name,l.modifiers,e,l.args)}})}processEvent(e,t,n,r,s,o){if(this.debugLog("[processEvent]",t,"handler:",n,"modifiers:",r),(r.includes("prevent")||t==="submit")&&(this.debugLog("[processEvent] Calling preventDefault"),s.preventDefault()),r.includes("stop")&&s.stopPropagation(),r.includes("self")&&s.target!==e||r.includes("shift")&&(!("shiftKey"in s)||!s.shiftKey)||r.includes("ctrl")&&(!("ctrlKey"in s)||!s.ctrlKey)||r.includes("alt")&&(!("altKey"in s)||!s.altKey)||r.includes("meta")&&(!("metaKey"in s)||!s.metaKey)||r.includes("cmd")&&(!("metaKey"in s)||!s.metaKey))return;if(s instanceof KeyboardEvent){let g=["enter","escape","space","tab","up","down","left","right"],E=["shift","ctrl","alt","meta","cmd","window","outside","prevent","stop","self","debounce","throttle"],Y=r.filter(S=>E.includes(S)||S.startsWith("debounce")||S.startsWith("throttle")||S.endsWith("ms")?!1:g.includes(S)||S.length===1);if(Y.length>0){let S=s.key.toLowerCase();this.debugLog("[processEvent] Key check. Pressed:",S,"Modifiers:",Y);let J={escape:"escape",esc:"escape",enter:"enter",space:" ",spacebar:" "," ":" ",tab:"tab",up:"arrowup",arrowup:"arrowup",down:"arrowdown",arrowdown:"arrowdown",left:"arrowleft",arrowleft:"arrowleft",right:"arrowright",arrowright:"arrowright"},H=J[S]||S,b=!1;for(let A of Y){let k=J[A]||A;if(this.debugLog("[processEvent] Comparing constraint:",A,"->",k,"vs",H,"code:",s.code),k===H){b=!0;break}if(s.code&&s.code.toLowerCase()===`key${k}`){b=!0;break}}if(!b){this.debugLog("[processEvent] No key match found.");return}}}let a=r.find(g=>g.startsWith("debounce")),l=r.find(g=>g.startsWith("throttle")),y=`${e.id||this.getUniqueId(e)}-${t}-${n}`;if(a){let g=this.parseDuration(r,250);this.debouncers.has(y)&&window.clearTimeout(this.debouncers.get(y));let E=window.setTimeout(()=>{this.debouncers.delete(y),this.dispatchEvent(e,t,n,s,o)},g);this.debouncers.set(y,E);return}if(l){let g=this.parseDuration(r,250);if(this.throttlers.has(y))return;this.throttlers.set(y,Date.now()),this.dispatchEvent(e,t,n,s,o),window.setTimeout(()=>{this.throttlers.delete(y)},g);return}this.dispatchEvent(e,t,n,s,o)}dispatchEvent(e,t,n,r,s){let o={};s&&s.length>0?s.forEach((l,p)=>{o[`arg${p}`]=l}):o=this.getArgs(e);let a={type:t,id:e.id,args:o};if(e instanceof HTMLInputElement?(a.value=e.value,(e.type==="checkbox"||e.type==="radio")&&(a.checked=e.checked)):(e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&(a.value=e.value),r instanceof KeyboardEvent&&(a.key=r.key,a.keyCode=r.keyCode),t==="submit"&&e instanceof HTMLFormElement){let l=new FormData(e),p={};l.forEach((y,g)=>{y instanceof File||(p[g]=y.toString())}),a.formData=p}this.app.sendEvent(n,a)}parseDuration(e,t){let n=e.findIndex(a=>a.startsWith("debounce")),r=e.findIndex(a=>a.startsWith("throttle")),s=n!==-1?n:r;if(s!==-1&&e[s+1]){let a=e[s+1];if(a.endsWith("ms")){let l=parseInt(a);if(!isNaN(l))return l}}let o=e[s];if(o&&o.includes("-")){let a=o.split("-"),l=parseInt(a[1]);if(!isNaN(l))return l}return t}getUniqueId(e){return e.id||(e.id="pywire-uid-"+Math.random().toString(36).substr(2,9)),e.id}getArgs(e){let t={};if(e instanceof HTMLElement){for(let n in e.dataset)if(n.startsWith("arg"))try{t[n]=JSON.parse(e.dataset[n]||"null")}catch{t[n]=e.dataset[n]}}return t}};var Nt={autoInit:!0,enableWebTransport:!0,enableWebSocket:!0,enableHTTP:!0,debug:!1},O=class{constructor(e={}){this.initialized=!1;this.siblingPaths=[];this.pathRegexes=[];this.pjaxEnabled=!1;this.isConnected=!1;this.config={...Nt,...e},this.transport=new _(this.config),this.updater=new T(this.config.debug),this.eventHandler=new me(this)}getConfig(){return this.config}async init(){if(!this.initialized){this.initialized=!0,this.transport.onMessage(e=>this.handleMessage(e)),this.transport.onStatusChange(e=>this.handleStatusChange(e));try{await this.transport.connect()}catch(e){console.error("PyWire: Failed to connect:",e)}this.loadSPAMetadata(),this.setupSPANavigation(),this.eventHandler.init(),console.log(`PyWire: Initialized (transport: ${this.transport.getActiveTransport()}, spa_paths: ${this.siblingPaths.length}, pjax: ${this.pjaxEnabled})`)}}handleStatusChange(e){this.isConnected=e}loadSPAMetadata(){let e=document.getElementById("_pywire_spa_meta");if(e)try{let t=JSON.parse(e.textContent||"{}");this.siblingPaths=t.sibling_paths||[],this.pjaxEnabled=!!t.enable_pjax,t.debug!==void 0&&(this.config.debug=!!t.debug),this.pathRegexes=this.siblingPaths.map(n=>this.patternToRegex(n))}catch(t){console.warn("PyWire: Failed to parse SPA metadata",t)}}patternToRegex(e){let t=e.replace(/[.+?^${}()|[\]\\]/g,"\\$&");return t=t.replace(/:(\\w+)(:\\w+)?/g,"([^/]+)"),t=t.replace(/\\{(\\w+)(:\\w+)?\\}/g,"([^/]+)"),new RegExp(`^${t}$`)}isSiblingPath(e){return this.pathRegexes.some(t=>t.test(e))}setupSPANavigation(){window.addEventListener("popstate",()=>{this.sendRelocate(window.location.pathname+window.location.search)}),!(this.siblingPaths.length===0&&!this.pjaxEnabled)&&document.addEventListener("click",e=>{let t=e.target.closest("a[href]");if(!t||t.origin!==window.location.origin||t.hasAttribute("download")||t.target==="_blank")return;let n=!1;(this.pjaxEnabled||this.isSiblingPath(t.pathname))&&(n=!0),n&&(e.preventDefault(),this.navigateTo(t.pathname+t.search))})}navigateTo(e){if(!this.isConnected){console.warn("PyWire: Navigation blocked - Offline");return}history.pushState({},"",e),this.sendRelocate(e)}sendRelocate(e){let t={type:"relocate",path:e};this.transport.send(t)}sendEvent(e,t){let n={type:"event",handler:e,path:window.location.pathname+window.location.search,data:t};this.transport.send(n)}async handleMessage(e){switch(e.type){case"update":e.regions&&e.regions.length>0?e.regions.forEach(t=>{this.updater.updateRegion(t.region,t.html)}):e.html&&this.updater.update(e.html);break;case"reload":console.log("PyWire: Reloading..."),window.location.reload();break;case"error":console.error("PyWire: Server error:",e.error);break;case"error_trace":console.error("PyWire: Error:",e.error);break;case"console":if(e.lines&&e.lines.length>0){let t="PyWire Server:",n=e.lines.join(`
3
+ `);e.level==="error"?console.error(t,n):e.level==="warn"?console.warn(t,n):console.log(t,n)}break;default:console.warn("PyWire: Unknown message type",e)}}getTransport(){return this.transport.getActiveTransport()}disconnect(){this.transport.disconnect()}};var V=class{constructor(){this.element=null;this.create()}create(){this.element=document.createElement("div"),this.element.style.cssText=`
4
+ position: fixed;
5
+ bottom: 20px;
6
+ right: 20px;
7
+ background: rgba(0, 0, 0, 0.8);
8
+ color: white;
9
+ padding: 10px 20px;
10
+ border-radius: 5px;
11
+ font-family: system-ui, -apple-system, sans-serif;
12
+ font-size: 14px;
13
+ z-index: 10000;
14
+ display: none;
15
+ transition: opacity 0.3s;
16
+ pointer-events: none;
17
+ `,document.body.appendChild(this.element)}update(e){this.element&&(e?this.element.style.display="none":(this.element.textContent="Connection Lost - Reconnecting...",this.element.style.display="block",this.element.style.backgroundColor="rgba(0, 0, 0, 0.8)"))}showNavigationBlocked(){this.element&&(this.element.style.backgroundColor="rgba(200, 0, 0, 0.9)",this.element.textContent="Cannot navigate - Offline",this.element.style.display="block",setTimeout(()=>{this.element&&(this.element.style.backgroundColor="rgba(0, 0, 0, 0.8)")},1500))}};var X=class{constructor(){this.loadedSources=new Set}getVirtualUrl(e){let t=btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),n=e.split(/[/\\]/).pop()||"unknown";return`${window.location.origin}/_pywire/file/${t}/${n}`}async handle(e,t){let n=new Set;for(let o of t)this.loadedSources.has(o.filename)||n.add(o.filename);await Promise.all(Array.from(n).map(async o=>{try{let a=this.getVirtualUrl(o),l=`/_pywire/source?path=${encodeURIComponent(o)}`,p=await fetch(l);if(p.ok){let g=`${await p.text()}
18
+ //# sourceURL=${a}`;try{(0,eval)(g)}catch{}this.loadedSources.add(o)}this.loadedSources.add(o)}catch(a){console.warn("PyWire: Failed to load source",o,a)}}));let r=new Error(e),s=[`${r.name}: ${r.message}`];for(let o of t){let a=o.name||"<module>",l=this.getVirtualUrl(o.filename),p=o.colno??1;s.push(` at ${a} (${l}:${o.lineno}:${p})`)}r.stack=s.join(`
19
+ `),console.error(r.stack)}};var G=class extends O{constructor(t={}){super(t);this.overlay=null;this.errorHandler=new X}async init(){this.overlay=new V,await super.init()}handleStatusChange(t){super.handleStatusChange(t),this.overlay&&this.overlay.update(t)}navigateTo(t){if(!this.isConnected){console.warn("PyWire: Navigation blocked - Offline"),this.overlay&&this.overlay.showNavigationBlocked();return}super.navigateTo(t)}async handleMessage(t){switch(t.type){case"error_trace":t.trace&&await this.errorHandler.handle(t.error||"Unknown Error",t.trace);return;case"console":if(t.lines&&t.lines.length>0){let n="PyWire Server:",r=t.lines.join(`
20
+ `);t.level==="error"?(console.group(n+" Error"),console.error(r),console.groupEnd()):t.level==="warn"?(console.groupCollapsed(n+" Warning"),console.warn(r),console.groupEnd()):t.lines.length===1?console.log(n,r):(console.groupCollapsed(n+" Log"),console.log(r),console.groupEnd())}return;default:await super.handleMessage(t)}}};var Me=new G;document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>Me.init()):Me.init();return et(Ft);})();
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pywire
3
- Version: 0.1.1
3
+ Version: 0.1.3
4
4
  Summary: HTML-over-the-wire Python web framework
5
5
  Author-email: Reece Holmdahl <reece@pywire.dev>
6
6
  License-File: LICENSE
@@ -0,0 +1,106 @@
1
+ pywire/__init__.py,sha256=Vnf8jVQs1hz9PGw9qtkvz_5SGhuLpasPeDFAuDixH7w,78
2
+ pywire/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ pywire/cli/__init__.py,sha256=SNDCMbWNEM6_UNFDVB666srR-6Ak_HKLAX2Umy2O85I,18
4
+ pywire/cli/generators.py,sha256=5tgXdhGJua9PhR8FkOxWaK9vHvOuFHdXOf3qamB7f3Q,1009
5
+ pywire/cli/main.py,sha256=n3OdvmJB_MUB3obejxqOsBoqSwKt13CetrICsDFoa0U,9082
6
+ pywire/cli/tui.py,sha256=USInBXWUUc8BpihqTdtnRrPJtW3U9c7hFBMRup0mkGs,21714
7
+ pywire/cli/validate.py,sha256=CPUQjFpoPcwpvAx3HvQ8Vq_w_suJ07n3oOhXKmKFwB4,769
8
+ pywire/client/.prettierignore,sha256=TKRNv7wugFj9ig2T6SdoCZxMi_l9X-ninE8j72JdFzM,87
9
+ pywire/client/.prettierrc,sha256=NwmnhqxkL9ATCDtQVOrgKBHtpN8L9niFT2j_SYmImzw,107
10
+ pywire/client/build.mjs,sha256=DWkD9icyrJYWJR4MkX7lWU9u3-Ywq4raw2hPWVGuNoI,1944
11
+ pywire/client/eslint.config.js,sha256=QxkvVaKeMnqSkPGDSjxQFvgfcyPWMbzct0zeMnpzQ4o,992
12
+ pywire/client/package.json,sha256=K4pQlex2QKefhkANWbpoBZhpOoveRACp6BkjmWKMPsk,1130
13
+ pywire/client/pnpm-lock.yaml,sha256=fPLYdbqVkvTTX6QheVLy0_32RHwWn90M9v6pAfondKw,78073
14
+ pywire/client/tsconfig.json,sha256=ZQkpS8rFm9HGjOrklve2YNuELCa4oqPnc5n02GoCuKQ,420
15
+ pywire/client/vitest.config.ts,sha256=8W1fK9f_o1_8k46oi223IlZlKSSkiyM_EdVHDxmNNRs,393
16
+ pywire/client/src/pywire.core.ts,sha256=iozCpa5g_N5xa7DNpUxW3M7Ov_NGNfxYnPdgmdisfMc,614
17
+ pywire/client/src/pywire.dev.ts,sha256=G0FOQOimUY-J8H_cFmYSoc9tSrv6TvwiDKD3EcUA-Q0,674
18
+ pywire/client/src/core/app.ts,sha256=WYfxWuSqVkA38VoPr8Cm59xXzW2tC_Bk62rgUopA36k,7401
19
+ pywire/client/src/core/dom-updater.test.ts,sha256=PsiK0EL3P2JYdCpjitZoZpPc2oOi0DJqjV-uOEw8FWo,2571
20
+ pywire/client/src/core/dom-updater.ts,sha256=rL80LVC__240bgU_PjpJDEnzmxx2wMDG_kqQK9Q6Q7A,9687
21
+ pywire/client/src/core/index.ts,sha256=tT_R-J_TtM_Fovm103J2w6cB-oiQZc9r1wViZ7wuV3A,215
22
+ pywire/client/src/core/transport-manager.test.ts,sha256=UbQrYgSXXj1j99mfCeO49rUU5U3grmNglfq28bQapbc,5534
23
+ pywire/client/src/core/transport-manager.ts,sha256=6_SLITzqnhGnwwvwYG5opd_y-1kVcpQEjMa_pUbAUhg,4433
24
+ pywire/client/src/core/transports/base.ts,sha256=fjgIUc1vQqPd3XHtbQ9S8rOKmDP8mrSg9fx4sIc_rqY,2825
25
+ pywire/client/src/core/transports/http.ts,sha256=4ySlDl7KXgyJbnWF6wB_yxyuvJRBfXeB16PbFucZ3RY,4070
26
+ pywire/client/src/core/transports/index.ts,sha256=CZZPHIOR7bRQmtrbDAvIXXR8O58VI38sEonCVubEkZQ,295
27
+ pywire/client/src/core/transports/websocket.ts,sha256=hVSykmEv2zCd1nITQfUHe1QhPiuIBOyYcB31iAH-r6c,2615
28
+ pywire/client/src/core/transports/webtransport.ts,sha256=PCsfC2DKWDPzlssjP4z6QmkfI44Tuuy3PVIeJQSF80M,4077
29
+ pywire/client/src/dev/dev-app.ts,sha256=8VvWzo9k7PH-rppn9VqEGNyn8uHVKDTY3w0NNFR7yjk,2494
30
+ pywire/client/src/dev/error-trace.test.ts,sha256=11zvMqrOpDrdQXYtqvffUPStPxQcUOYA-3jWNfMFcPE,3332
31
+ pywire/client/src/dev/error-trace.ts,sha256=g8mZmqG6jlIZ5lBFrBdC-c74dxcvkoUzDgZxesF2uqg,2465
32
+ pywire/client/src/dev/index.ts,sha256=-jQKnDjX_ANGlRrVuRRlwqocIMzUYNbN5aZIeo8SFhs,162
33
+ pywire/client/src/dev/status-overlay.ts,sha256=S6atJzQ7JqHXMBpuf2gIzXlOLyySV1vnJVXuhfp3jpU,1664
34
+ pywire/client/src/events/handler.test.ts,sha256=M8kmzf5cHY8NvlOaJR3B-2lMyNc96mwAYpgJH_DsEH0,10289
35
+ pywire/client/src/events/handler.ts,sha256=VxTjGQZ88tgdePJ6K3rwNbPgDptgi1On-tyQ1_uS4Tw,13788
36
+ pywire/compiler/__init__.py,sha256=7tIdJ8qi5lcj7R7scIwIiE-Tmi7YZknThZArIdo95MQ,177
37
+ pywire/compiler/ast_nodes.py,sha256=vdHtoJQvoxF_I0RmV6gs1_zd6AhyY4dCpHmqgh73Gi8,8276
38
+ pywire/compiler/build.py,sha256=OB-tmsSOtnNcteUvD01MSaeTI4_lBsUHVe4xITYWa_g,800
39
+ pywire/compiler/build_artifacts.py,sha256=OxYgooTzy95DRwaAC26s-noaevvVwVaix-KYAQOtDM0,11102
40
+ pywire/compiler/exceptions.py,sha256=KyvpMI17oiVSz3h2osDaa4uCMNPKSTCr1DhVYDVU85o,540
41
+ pywire/compiler/parser.py,sha256=VFgZs_YkyVlRuu-jzcXqKXfu_jHzN5-ZE6RBupGWbVE,29425
42
+ pywire/compiler/paths.py,sha256=9TLKH-xnTBmthdpQcCDJ7UrGlIyLAuGDaVrc4qI6TgA,739
43
+ pywire/compiler/preprocessor.py,sha256=AyMrfLpjFF-yvMYQn67sCe_G3OSeK4-Wrdh0I_0RAfU,1509
44
+ pywire/compiler/attributes/__init__.py,sha256=umzZ03Mmw-LrBBNue-itAVORKhcpG-f-LzKSVH4lCGs,208
45
+ pywire/compiler/attributes/base.py,sha256=3eJh7bmi2Y33VRPnD90-s9QMEdfbuNKIxv6F7AU_pK8,697
46
+ pywire/compiler/attributes/conditional.py,sha256=R746Sz-rz3-nLr-Yj71q8yNAz1-eF_5Eg8cjKXwWlAo,1328
47
+ pywire/compiler/attributes/events.py,sha256=o6m59fCPfcuCJJp6rPdIVFV4BFni8IVluhVa4c494Q4,1747
48
+ pywire/compiler/attributes/form.py,sha256=5NC8PsBP7xfSKvyV5ANLShgSl6Eszq_fHZ5NG-VCzcw,1100
49
+ pywire/compiler/attributes/loop.py,sha256=1UL_eBayJOxkDJrO1mhvNnA6UnVs7-riW51XFDqX6Tk,2621
50
+ pywire/compiler/attributes/reactive.py,sha256=vz0TXRsp_mA9iNh1WcWpiA5g6ZpHNMYiUZB-i9B_tJE,1273
51
+ pywire/compiler/codegen/__init__.py,sha256=RoW5xrX7mYycSxHPnS0-J46IwWGIiWF9EeJYkx1p4LI,121
52
+ pywire/compiler/codegen/generator.py,sha256=dZlXjarfNJ7xL3qvSK9XlnsiU6i-IYjyT1Tttt3uqHw,92851
53
+ pywire/compiler/codegen/template.py,sha256=jvhmY9zrMymnq44RsDRqjCeifxNz_Z3d91026Hfw3QM,90713
54
+ pywire/compiler/codegen/attributes/__init__.py,sha256=0wHMipg7PG2bpRjfmLkjIyYWwZTHbSJCevMoZSpmyFs,236
55
+ pywire/compiler/codegen/attributes/base.py,sha256=pGZHCEZ6d3NTWwQMZ_ZKxofz2aEWDw5Kwm_axL7Gi2g,577
56
+ pywire/compiler/codegen/attributes/events.py,sha256=OTIcvreDty4DVEGcuuqmpjD_QREZJe1imcdrB7Hl65o,1354
57
+ pywire/compiler/codegen/directives/__init__.py,sha256=4TD0QmOKduxkTWPuXb1GDcp8nPEzsVLvwWf__xvwp3E,232
58
+ pywire/compiler/codegen/directives/base.py,sha256=4QodSoVsxJvhZ4oO7Phk_jgy-AopZsMmxH8ixnhypiQ,392
59
+ pywire/compiler/codegen/directives/path.py,sha256=QmFJszBZvXTFOrpHrDwmAubfW7eoFFKNN5OAJ6yqMvs,1751
60
+ pywire/compiler/directives/__init__.py,sha256=6QioQwB0EMVlybvwZZFQO10Kayuc0SgZTs-mL_vnQMM,295
61
+ pywire/compiler/directives/base.py,sha256=luBrDyNPzkcFvhzlIIbfv66po7Ep0PuHQ_jMFNahXjo,581
62
+ pywire/compiler/directives/component.py,sha256=Ez2jT6L1yjWwy3_PVMeITgjplrCblozsh7XR2N-rm8U,1029
63
+ pywire/compiler/directives/context.py,sha256=OhZ1eDsiEU_d8jNbWhkIT5e4Jo245fQwnpaXwLr0Jzk,3453
64
+ pywire/compiler/directives/layout.py,sha256=MEF4IeV2x9QPcEyLfc6-MvKlVqq-BeBlzoWG9GuCPWA,1435
65
+ pywire/compiler/directives/no_spa.py,sha256=kuQPZr6IKWLYMgApNV8ruLmFIOvPUDEOdJuCdBKGFdU,749
66
+ pywire/compiler/directives/path.py,sha256=KGVPb4kgFWs4zXtHJ2PweYTnT27iw19bhZjMoksM0ok,2388
67
+ pywire/compiler/directives/props.py,sha256=loeXOtt1zYrtEIGBUtPah37DEbloiN5VAi2s98zOGvY,3440
68
+ pywire/compiler/interpolation/__init__.py,sha256=A-v9HVAIUB-QX6j5FFyGxkSVwNzzD49qHryKNLrIRuI,233
69
+ pywire/compiler/interpolation/base.py,sha256=33wIfZVMNpIl_ZPXzkWYdOiPX3jWzZ4xb0UGbjXEpyw,781
70
+ pywire/compiler/interpolation/jinja.py,sha256=HJEkRE0aB-YEiw7sZ6agS_zRUQlo19uj0bX21WOW8MQ,9831
71
+ pywire/core/wire.py,sha256=ZgjoALx_B8i4ibt8rdY0XjNLVrfZcHLQh0urWl-iwIE,3899
72
+ pywire/runtime/__init__.py,sha256=441hDvBWfYni7BtKlVXHEm2FWahK0MR3sIpkPkIE1zk,207
73
+ pywire/runtime/aioquic_server.py,sha256=n9GuK81xtc6PUT54uMhqMlGXn8NrH-ryZ6Rl9qQWt7M,6685
74
+ pywire/runtime/app.py,sha256=ebJ5SDDgJTk95R6AunWtJOi6RI4R4dJKCM31051hGy8,36217
75
+ pywire/runtime/compile_error_page.py,sha256=sqPTqG9dv_e2uBgYuAgOcDHx0D3Gwq2liFbBRrz4_iY,8205
76
+ pywire/runtime/debug.py,sha256=6U-Ot1defe7eDXaAxNip4NtRPQjtjS9LNCUnk_pmmeQ,7416
77
+ pywire/runtime/dev_server.py,sha256=DUVbktSBAujiwALxXG2iWLTdpjcAe80l44GPDJRdV6w,16018
78
+ pywire/runtime/dev_server.py.broken,sha256=cAPPLFNe6qJ-KouATG3FfIabGd-o3qCqlMGqQQF03sc,11030
79
+ pywire/runtime/error_page.py,sha256=fnE8Qjf1a7fjLOys6G2uDsK0VYGMZg2yGWgDagk39j0,2497
80
+ pywire/runtime/error_renderer.py,sha256=HNS9seD5gX4jE3L4GPsJsyxvpMTiiNo3E43trUNiuX0,701
81
+ pywire/runtime/escape.py,sha256=w-_TcFLG0heyenDaituVx2oir_80WjGBWnnHZe5I8Wk,517
82
+ pywire/runtime/files.py,sha256=RJjDhCaoKjk_x3B_71rA4EhqVjNLGU_fuwg4Cq894nY,1316
83
+ pywire/runtime/helpers.py,sha256=jY3bDE7hHjPaVlLmWrGvQPDEtCYFU9Alt8j0dvSZgNQ,3039
84
+ pywire/runtime/http_transport.py,sha256=uS3Or4uo581XSVqRB1VsEfa7Mbqr4RK5Rk0pGb-z4p8,9401
85
+ pywire/runtime/loader.py,sha256=rKsHYb8dx-WkxBYClHR4Gztoy1N88kLYt5CCnvA0gIg,9664
86
+ pywire/runtime/logging.py,sha256=wEdxro6YxvdnjwALwzMr60As2JMj_J4DIsSL8JZScvM,2286
87
+ pywire/runtime/page.py,sha256=tEKPUfQFQpw3T20sWsjlXLfmDr2TlNmesc_jDwcK748,14288
88
+ pywire/runtime/pydantic_integration.py,sha256=Fwu45Km5SHS10ZqIxCK-Ps8hBPlVY6rHzkkP7Mh8KEs,1800
89
+ pywire/runtime/router.py,sha256=wHr0iyAQ3_jGzMPpyxNKE9rLWD3oiQM-JAtkxX4h7SI,8172
90
+ pywire/runtime/server.py,sha256=hzG1NACfjasTmNZd-imORTLNxMCD-JYgkfjIRyQ3GJE,746
91
+ pywire/runtime/style_collector.py,sha256=H1Crk1DO1wfch2Ed4i4_sHANH5QX_HGGGlaJr7MRiIY,1147
92
+ pywire/runtime/upload_manager.py,sha256=n7WRwpzHqnW1CZsoshxq7YumNMFrG7Hs5CiEHP-0W4k,2346
93
+ pywire/runtime/validation.py,sha256=Y1_nI_dFKy3_7aXN-gCubUBhBlzgEtNEkdS1DH81tEI,16199
94
+ pywire/runtime/websocket.py,sha256=7sNawtxC0l_eJBEjI80DGnUqei7Ol0RX8Y7Yz3_wNxw,26949
95
+ pywire/runtime/webtransport_handler.py,sha256=GZIzTlv5IyEmIq2eumxFTu1XgWaPkiRFujG1vBjQNsE,7841
96
+ pywire/templates/error/404.html,sha256=cZavWjs-aXoSRpEy-8D0rulP7g5Sn31MsIXmkZUQnnA,256
97
+ pywire/templates/error/500.html,sha256=545CPh1XyhN-zdSAD8R-6Cuos6hLC--TXJy4EQHrpjM,1282
98
+ pywire/templates/error/base.html,sha256=nlBlBIg-VFAWtTLWky7c2igNVsFjj9M8Wyw3v3_4KGQ,4863
99
+ pywire/templates/error/compile_error.html,sha256=FMqU3HXYWMeiXG3eTAysNpAHH-AOPx2Apbz8f_HBvtw,837
100
+ pywire/static/pywire.core.min.js,sha256=SGZYyI_NgoUphlWWJ_WM9_S3Ix-2-6JykU3frlhW_6A,47482
101
+ pywire/static/pywire.dev.min.js,sha256=v7C7Gkh-0eernYfHGvqzTFdjCqiXLt4EQSvPl2l6-oM,50520
102
+ pywire-0.1.3.dist-info/METADATA,sha256=xotwogdm8P9eqUWNFqrPYrsQMUUeFkEVgkLBgerzpAo,2386
103
+ pywire-0.1.3.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
104
+ pywire-0.1.3.dist-info/entry_points.txt,sha256=L0n4cNLZIocOo6lG05uOoUN1GHgA_uQOHvapDAhULBI,47
105
+ pywire-0.1.3.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
106
+ pywire-0.1.3.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- pywire/templates/error/404.html,sha256=cZavWjs-aXoSRpEy-8D0rulP7g5Sn31MsIXmkZUQnnA,256
2
- pywire/templates/error/500.html,sha256=545CPh1XyhN-zdSAD8R-6Cuos6hLC--TXJy4EQHrpjM,1282
3
- pywire/templates/error/base.html,sha256=nlBlBIg-VFAWtTLWky7c2igNVsFjj9M8Wyw3v3_4KGQ,4863
4
- pywire/templates/error/compile_error.html,sha256=FMqU3HXYWMeiXG3eTAysNpAHH-AOPx2Apbz8f_HBvtw,837
5
- pywire-0.1.1.dist-info/METADATA,sha256=xWdhI55nsp-50ExXLdhjZ1SYNtju61tkkNTXaxSzALk,2386
6
- pywire-0.1.1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
7
- pywire-0.1.1.dist-info/entry_points.txt,sha256=L0n4cNLZIocOo6lG05uOoUN1GHgA_uQOHvapDAhULBI,47
8
- pywire-0.1.1.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
9
- pywire-0.1.1.dist-info/RECORD,,
File without changes