var Jt=Object.defineProperty;var w=(t,e,n)=>()=>{if(n)throw n[0];try{return t&&(e=t(t=0)),e}catch(r){throw n=[r],r}};var J=(t,e)=>{for(var n in e)Jt(t,n,{get:e[n],enumerable:!0})};function Q(){for(let t of Y)document.querySelectorAll(`[data-r-portal-slot="${CSS.escape(t)}"]`).forEach(e=>e.remove());Y=_,_=new Set}function I(t){return document.getElementById(t)??document.querySelector(`[data-r-portal-target="${CSS.escape(t)}"]`)}function P(t){let e=X.get(t);return e||(e=`p${++Xt}`,X.set(t,e)),_.add(e),e}function q(t,e){t.querySelectorAll(`[data-r-portal-slot="${CSS.escape(e)}"]`).forEach(n=>n.remove())}function Z(t,e,n){q(e,n);let r=document.createElement("div");r.dataset.rPortalSlot=n,r.appendChild(t.content.cloneNode(!0)),e.appendChild(r)}function tt(t){t.querySelectorAll("template[data-r-portal]").forEach(e=>{let n=e.closest("[data-r-show-if]");if(n?.closest("resuma-show")?.dataset.rPortalTarget||n?.hidden)return;let r=e.getAttribute("data-r-portal");if(!r)return;let o=I(r);o&&Z(e,o,P(e))})}function et(t,e,n){let r=t.querySelector("template[data-r-portal]");r&&Z(r,e,n)}var Xt,X,_,Y,O=w(()=>{"use strict";Xt=0,X=new WeakMap,_=new Set,Y=new Set});function p(t){F.push(t)}function nt(){for(;F.length;){let t=F.pop();try{t?.()}catch{}}}var F,b=w(()=>{"use strict";F=[]});function ct(t){let e=new Map;for(let n of t){let r=h(n.id);e.set(r,Yt(r,n.value))}return e}function h(t){return typeof t=="string"?t:typeof t=="number"?`s${t}`:`s${t[0]}`}function Yt(t,e){let n=e,r=new Set,o={id:t,get value(){return n},set value(i){o.set(i)},set(i){Object.is(i,n)||(n=i,r.forEach(a=>a(n)))},update(i){let a=i(n);a!==void 0&&o.set(a)},subscribe(i){return r.add(i),()=>r.delete(i)}};return o}function M(t,e){t.querySelectorAll(Qt.toLowerCase()).forEach(r=>{if(rt.has(r))return;let o=r.getAttribute("data-r-signal");if(!o)return;let i=e.get(o);i&&(r.textContent=E(i.value),p(i.subscribe(a=>{r.textContent=E(a)})),rt.add(r))})}function R(t,e){t.querySelectorAll("[data-r-bind]").forEach(r=>lt(r,e)),Zt(t,e)}function Zt(t,e){let n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT),r=n.currentNode;for(;r;)r instanceof HTMLElement&<(r,e),r=n.nextNode()}function te(t){let e=t.toLowerCase();return e.startsWith("on")||e==="style"}function ne(t){let e=t.replace(/[\u0000-\u0020]+/g,"");return/^(?:javascript|vbscript|data):/i.test(e)?"":t}function lt(t,e){if(ot.has(t))return;let n=!1;for(let r of Array.from(t.attributes)){let o=r.name;if(!o.startsWith("data-r-bind:"))continue;let i=o.slice(12);if(te(i))continue;let[a,s="{}"]=r.value.split("|"),c=e.get(a);if(!c)continue;let l=ee.has(i.toLowerCase()),u=f=>{let d=s.replace("{}",E(f));l&&(d=ne(d)),t.setAttribute(i,d)};u(c.value),p(c.subscribe(u)),n=!0}n&&ot.add(t)}function E(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);try{return JSON.stringify(t)}catch{return String(t)}}function re(t){if(t===void 0)return"";if(typeof t=="string")return t;try{let e=JSON.stringify(t);if(e===void 0)return"";let n=JSON.parse(e);return typeof n=="string"?n:e}catch{return E(t)}}function W(t,e){t.querySelectorAll("resuma-show").forEach(n=>{if(it.has(n))return;let r=n.getAttribute("data-r-show");if(!r)return;let o=n.getAttribute("data-r-inverted")==="true",i=n.querySelector("[data-r-show-if]"),a=n.querySelector("[data-r-show-else]"),s=e.get(r);if(!s||!i)return;let c=l=>{let u=o?!l:!!l;i.hidden=!u,a&&(a.hidden=u);let f=n.dataset.rPortalTarget,d=i.querySelector("template[data-r-portal]");if(!f&&d&&(f=d.getAttribute("data-r-portal")??void 0,f&&(n.dataset.rPortalTarget=f)),f){let m=I(f);if(m){let g=P(n);u?d&&et(i,m,g):q(m,g)}}};c(s.value),p(s.subscribe(c)),it.add(n)})}function v(t){if(t&&typeof t=="object")for(let e of["title","name","label","text"]){let n=t[e];if(typeof n=="string")return n}return E(t)}function ut(t){return t.hasAttribute("data-r-signal")}function oe(t,e){M(t,e),R(t,e)}function ie(t,e,n){if(n){let i=n.cloneNode(!0);if(i.setAttribute("data-r-for-key",e),i.removeAttribute("data-r-for-new"),i.querySelectorAll("resuma-dyn").forEach(a=>{ut(a)||(a.textContent=v(t))}),!i.querySelector("resuma-dyn")){let a=i.querySelector(".todo-title");a&&(a.textContent=v(t))}return i}let r=document.createElement("div");r.setAttribute("data-r-for-item",""),r.setAttribute("data-r-for-key",e);let o=document.createElement("span");return o.textContent=v(t),r.appendChild(o),r}function ae(t,e){if(t.querySelectorAll("resuma-dyn").forEach(n=>{ut(n)||(n.textContent=v(e))}),!t.querySelector("resuma-dyn")){let n=t.querySelector(".todo-title");n&&(n.textContent=v(e))}}function se(t,e,n){if(e&&t&&typeof t=="object"){let r=t[e];if(r!=null)return String(r)}return String(n)}function ce(t,e){let n=new Set;return t.map((r,o)=>{let i=se(r,e,o);return n.has(i)&&(i=`${i}:${o}`),n.add(i),i})}function N(t,e){t.querySelectorAll("resuma-for").forEach(n=>{if(at.has(n))return;let r=n.getAttribute("data-r-for");if(!r)return;let o=n.getAttribute("data-r-key"),i=n.querySelector("[data-r-for-list]"),a=e.get(r);if(!a||!i)return;let s=c=>{let l=Array.isArray(c)?c:[],u=new Map;i.querySelectorAll("[data-r-for-item]").forEach(g=>{let T=g.getAttribute("data-r-for-key");T&&u.set(T,g)});let f=document.createDocumentFragment(),d=i.querySelector("[data-r-for-item]:not([data-r-for-new])")??void 0,m=ce(l,o);l.forEach((g,T)=>{let H=m[T],S=u.get(H);S?(u.delete(H),ae(S,g)):(S=ie(g,H,d),S.setAttribute("data-r-for-new","true")),f.appendChild(S)}),i.replaceChildren(f),u.forEach(g=>g.remove()),oe(i,e)};s(a.value),p(a.subscribe(s)),at.add(n)})}function j(t,e){t.querySelectorAll("resuma-match").forEach(n=>{if(st.has(n))return;let r=n.getAttribute("data-r-match");if(!r)return;let o=e.get(r);if(!o)return;let i=n.querySelectorAll("[data-r-match-case]"),a=n.querySelector("[data-r-match-default]"),s=c=>{let l=re(c),u=!1;i.forEach(f=>{let m=(f.getAttribute("data-r-match-when")??"")===l;f.hidden=!m,m&&(u=!0)}),a&&(a.hidden=u)};s(o.value),p(o.subscribe(s)),st.add(n)})}var Qt,rt,ot,it,at,st,ee,C=w(()=>{"use strict";O();b();Qt="RESUMA-DYN",rt=new WeakSet,ot=new WeakSet,it=new WeakSet,at=new WeakSet,st=new WeakSet;ee=new Set(["href","src","action","formaction","xlink:href","poster","background","ping","data"])});function $(t,e){let n=t.querySelectorAll(le),r=[];n.forEach(o=>{let i=o.getAttribute("data-r-chunk");if(!i)return;if((o.getAttribute("data-r-load")??"eager")==="visible"&&"IntersectionObserver"in window){let s=new IntersectionObserver((c,l)=>{for(let u of c)u.isIntersecting&&(l.unobserve(u.target),dt(o,i,e))},{rootMargin:"100px"});r.push(s),s.observe(o);return}dt(o,i,e)}),r.length&&p(()=>{for(let o of r)o.disconnect()})}async function dt(t,e,n){let r=t.getAttribute("data-r-props")??"{}",o={};try{o=JSON.parse(r)}catch{}await ue(e,o,t,n)}async function ue(t,e,n,r){if(n.dataset.rHydrated!=="true")try{let o=await import(`/_resuma/island-chunk/${t}.js`);typeof o.resume=="function"&&(o.resume(e,r,n),n.dataset.rHydrated="true")}catch(o){console.debug("[r] island static",t,o)}}var le,ft=w(()=>{"use strict";b();le="resuma-island"});function de(t,e,n){let r=Object.create(n.state);if(!t)return r;for(let[o,i]of Object.entries(t)){let a=e.get(h(i));a&&(r[o]=a)}return r}function mt(){for(;k.length;){let t=k.pop();try{t?.()}catch{}}}function gt(t,e,n){for(let r of t)try{let o=de(r.captures,e,n),i=new Function(`return (${r.body});`)();if(r.kind==="debounce"){let s=i(o,n);typeof s=="function"&&k.push(s)}else{let s=r.target!=null?e.get(h(r.target)):void 0,c=()=>{try{let d=i(o,n);s&&d!==void 0&&s.set(d)}catch(d){console.error("[r] effect",r.id,d)}},l,u=()=>{let d=r.debounce_ms;if(d!=null&&d>0){l!==void 0&&clearTimeout(l),l=setTimeout(c,d);return}c()};u(),k.push(()=>{l!==void 0&&clearTimeout(l)});let f=new Set;for(let d of r.deps)f.add(h(d));if(r.captures)for(let d of Object.values(r.captures))f.add(h(d));for(let d of f){let g=e.get(d)?.subscribe(()=>u());g&&k.push(g)}}}catch(o){console.error("[r] effect init",r.id,o)}}var k,pt=w(()=>{"use strict";C();k=[]});function ht(t){let e=window.__resuma;e&&(e.loaded.has(t)||import(`/_resuma/handler/${t}.js`).then(n=>{e.loaded.set(t,n)}).catch(()=>{}))}function yt(t,e){e.querySelectorAll(`[${wt}]`).forEach(o=>o.remove());let n=[...new Set(t.filter(o=>o&&o!=="__page__"))];if(!n.length)return;if(!("IntersectionObserver"in window)){for(let o of n)ht(o);return}let r=new IntersectionObserver((o,i)=>{for(let a of o){if(!a.isIntersecting)continue;let s=a.target.dataset.rChunk;s&&ht(s),i.unobserve(a.target)}},{rootMargin:"120px"});p(()=>r.disconnect());for(let o of e.querySelectorAll("resuma-boundary[data-r-chunk]"))r.observe(o);for(let o of n){let i=document.createElement("resuma-boundary");i.hidden=!0,i.dataset.rChunk=o,i.setAttribute(wt,"true"),e.appendChild(i),r.observe(i)}}var wt,bt=w(()=>{"use strict";b();wt="data-r-lazy-chunk-marker"});function Et(){return window.__resuma}async function fe(t){let e=Et(),n=e.loaded.get(t);if(n)return n;let r=D.get(t);return r||(r=import(`/_resuma/handler/${t}.js`),D.set(t,r),r.finally(()=>D.delete(t))),n=await r,e.loaded.set(t,n),n}async function kt(t,e){if(e){let c=St.get(e);return c||(c=vt(e),St.set(e,c)),c}let n=t.indexOf("#"),r=n===-1?t:t.slice(0,n),o=n===-1?t:t.slice(n+1),i=Et();if(r==="__page__"){let c=i.handlers[r]?.[o];if(c)return vt(c)}let s=(await fe(r))[o];if(!s)throw new Error(`handler ${o} missing in ${r}`);return s}function vt(t){let e=t.trim(),r=e.startsWith("(")||e.startsWith("function")||e.startsWith("async")?`return (${t});`:`return (async (event, state, __resuma) => { ${t} });`;return new Function(r)()}var St,D,Tt=w(()=>{"use strict";St=new Map,D=new Map});var L=w(()=>{"use strict"});async function me(t){if(!(!t||V.has(t))&&!(t.startsWith("http")&&!t.startsWith(location.origin))){V.add(t);try{let e=await fetch(t,{headers:{Accept:"text/html"},credentials:"same-origin"});e.ok&&x.set(t,await e.text())}catch{}finally{V.delete(t)}}}function xt(t){U=t}function At(){return document.getElementById(Lt)??document.body}function ge(t){try{return new URL(t,location.origin).origin===location.origin}catch{return!1}}function pe(t,e){if(t===e)return!0;let n="http://resuma.local",r=new URL(t,n),o=new URL(e,n);if(r.search)return r.pathname+r.search===o.pathname+o.search;if(r.pathname===o.pathname)return!0;if(r.pathname!=="/"&&o.pathname.startsWith(r.pathname)){let i=o.pathname.charCodeAt(r.pathname.length);return i===void 0||i===47}return!1}function Rt(t){document.querySelectorAll("a[data-r-nav]").forEach(e=>{let n=e.getAttribute("href");if(!n)return;let r=e.getAttribute("data-r-active-class");if(!r)return;let o=(e.getAttribute("data-r-base-class")??e.className).split(/\s+/).filter(i=>i&&i!==r).join(" ");e.setAttribute("data-r-base-class",o),e.className=pe(n,t)?`${o} ${r}`.trim():o})}async function we(){if(!window.__resuma){window.location.reload();return}if(U){U(),Rt(location.pathname+location.search);return}try{(await Promise.resolve().then(()=>(qt(),Pt))).mountPage(),Rt(location.pathname+location.search)}catch{window.location.reload()}}function he(){let t=At(),e=t.querySelector("[autofocus]")??t.querySelector("h1, [role='heading'], main")??t;e.hasAttribute("tabindex")||e.setAttribute("tabindex","-1");try{e.focus({preventScroll:!0})}catch{e.focus()}}function A(t,e){let n=new URL(t,location.origin);if(e)for(let[r,o]of Object.entries(e))o!=null&&o!==""&&n.searchParams.set(r,o);return n.pathname+n.search}async function Ht(t,e){x.clear();let n=t?.split("?")[0]??location.pathname,r=String(Date.now());await y(A(n,{...e,_r:r}))}async function y(t,e=!0){if(!ge(t)){window.location.assign(t);return}let n=++B;Ct?.abort();let r=new AbortController;Ct=r;try{let o=x.get(t);if(o)x.delete(t);else{let l=await fetch(t,{headers:{Accept:"text/html"},credentials:"same-origin",signal:r.signal});if(n!==B)return;if(!l.ok){window.location.href=t;return}o=await l.text()}if(n!==B)return;let i=new DOMParser().parseFromString(o,"text/html"),a=i.getElementById(Lt),s=i.getElementById(Mt);if(!a||!s?.textContent){window.location.href=t;return}At().innerHTML=a.innerHTML;let c=document.getElementById(Mt);c&&(c.textContent=s.textContent),i.title&&(document.title=i.title),e&&history.pushState({resumaNav:!0},"",t),we(),e&&window.scrollTo(0,0),he(),document.dispatchEvent(new CustomEvent("resuma:navigate",{detail:{href:t}}))}catch(o){if(o instanceof DOMException&&o.name==="AbortError")return;console.error("[r] nav",o),window.location.href=t}}function G(t){if(t.startsWith("/")&&!t.startsWith("//")){y(t);return}try{let e=new URL(t,location.origin);if(e.origin===location.origin&&(e.protocol==="http:"||e.protocol==="https:")){y(e.pathname+e.search+e.hash);return}}catch{}console.warn("[r] bad redirect",t)}function ye(t,e){if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||t.target&&t.target!=="_self")return!1;let n=t.getAttribute("href");if(!n||n.startsWith("#")||n.startsWith("javascript:"))return!1;if(n.startsWith("http://")||n.startsWith("https://"))try{return new URL(n).origin===location.origin}catch{return!1}return!0}function _t(){document.addEventListener("mouseenter",t=>{let e=t.target;if(!(e instanceof Element))return;let r=e.closest("a[data-r-nav]")?.getAttribute("href");r&&me(r)},!0),document.addEventListener("click",t=>{let e=t.target;if(!(e instanceof Element))return;let n=e.closest("a[data-r-nav]");if(!n||!ye(n,t))return;let r=n.getAttribute("href");r&&(t.preventDefault(),y(r))}),window.addEventListener("popstate",()=>{y(location.pathname+location.search,!1)})}var Lt,Mt,x,V,U,B,Ct,It=w(()=>{"use strict";L();Lt="resuma-root",Mt="resuma-state",x=new Map,V=new Set;U=null;B=0,Ct=null});function be(t){return typeof t=="string"?{body:t}:t}function Se(t,e,n){let r=Object.create(n);if(!t)return r;for(let[o,i]of Object.entries(t)){let a=e.get(h(i));a&&(r[o]=a)}return r}function Ot(t,e,n,r){let o=Object.entries(t).map(([c,l])=>[c,be(l)]);if(!o.length)return;let i=async(c,l)=>{try{let u=l.body.trim();u.endsWith(")()")&&(u=u.slice(0,-2));let f=Se(l.captures,e,n),d=new Function("state","__resuma",`return (${u})(state, __resuma);`),m=await Promise.resolve(d(f,window.__resuma));typeof m=="function"&&p(m)}catch(u){console.error("[r] task",c,u)}},a=new Set(o.map(([c])=>c)),s=(c,l)=>{a.has(c)&&(a.delete(c),i(c,l))};if("IntersectionObserver"in window){let c=new IntersectionObserver((l,u)=>{for(let f of l){if(!f.isIntersecting)continue;let d=f.target.dataset.rVisibleTask,m=d?o.find(([g])=>g===d)?.[1]:void 0;d&&m&&s(d,m),u.unobserve(f.target)}},{rootMargin:"50px"});p(()=>c.disconnect()),r().querySelectorAll("[data-r-visible-task]").forEach(l=>l.remove());for(let[l]of o){let u=document.createElement("span");u.dataset.rVisibleTask=l,u.style.cssText="position:absolute;width:1px;height:1px;opacity:0;pointer-events:none;overflow:hidden",r().appendChild(u),c.observe(u)}}else for(let[c,l]of o)s(c,l)}var Ft=w(()=>{"use strict";L();C();b()});var Wt={};J(Wt,{initFlowWidgets:()=>ve});function ve(t){}var Nt=w(()=>{"use strict"});var Pt={};J(Pt,{bootstrap:()=>Ce,buildLocalState:()=>Ut,mountFlowWidgets:()=>ke,mountPage:()=>z,mutationHeaders:()=>K,runHandler:()=>Le});function Ee(t){return t instanceof Document||t instanceof Element?!!t.querySelector(jt):!1}async function Vt(t){if(Ee(t))try{(await Promise.resolve().then(()=>(Nt(),Wt))).initFlowWidgets(t)}catch(e){console.error("[r] flow load",e)}}function ke(t=document){Vt(t)}function Me(){let t=document.getElementById(Bt);if(!t?.textContent)return"";try{return JSON.parse(t.textContent).csrf_token??""}catch{return""}}function K(t={}){let e={...t},n=Me();return n&&(e["x-resuma-csrf"]=n),e}function Re(){let t=document.getElementById(Bt);if(!t||!t.textContent)return{signals:[],handlers:{},islands:[],actions:[]};try{let e=JSON.parse(t.textContent);return e.serialization_error&&console.error("[r] resumability payload failed to serialize on the server \u2014 page interactivity is broken"),e}catch(e){return console.error("[r] state",e),{signals:[],handlers:{},islands:[],actions:[]}}}function z(){mt(),nt(),Q();let t=Re(),e=ct(t.signals),n={};for(let[a,s]of e)n[a]=s;let r=window.__resuma,o={state:n,signals:e,handlers:t.handlers,contexts:t.contexts??{},loaded:r?.loaded??new Map,action:zt,safeAction:qe,refreshIsland:Kt,context:a=>o.contexts[a],navigate:y,buildUrl:A,invalidate:Ht};window.__resuma=o;let i=$t();M(i,e),R(i,e),W(i,e),N(i,e),j(i,e),$(i,e),_e(i),tt(i),Pe(i),Vt(i),Ot(t.visible_tasks??{},e,n,$t),gt(t.effects??[],e,o),yt(t.lazy_chunks??[],i)}async function Ce(){Dt||(Dt=!0,xt(z),z(),xe(),He(),_t(),Oe())}function Ut(t){let e=window.__resuma;if(!t.length)return e.state;let n={};for(let r of t){let o=r.indexOf(":"),i=o===-1?r:r.slice(0,o),a=o===-1?void 0:r.slice(o+1),s=a!=null?h(a):i,c=e.signals.get(s);c&&(n[i]=c)}return Object.assign(Object.create(e.state),n)}async function Le(t,e,n,r){let o=await kt(t,e),i=Ut(r);await o(n,i,window.__resuma)}function xe(){document.addEventListener("submit",async t=>{if(!(t.target instanceof HTMLFormElement))return;let e=t.target;if(!e.getAttribute("data-r-submit"))return;t.preventDefault();let n=e.getAttribute("data-r-submit"),r=new FormData(e),o={};r.forEach((a,s)=>{o[s]=String(a)});let i=new URLSearchParams(o);try{let a=await fetch(e.action||`/_resuma/submit/${encodeURIComponent(n)}`,{method:"POST",credentials:"same-origin",headers:K({"content-type":"application/x-www-form-urlencoded",accept:"application/json"}),body:i.toString()}),s=await a.json();if(!a.ok||s.ok===!1){Ae(e,s.field_errors??{}),(a.status>=500||!s.field_errors)&&console.error("[r] submit",s.error??n);return}Gt(e),s.redirect&&G(s.redirect)}catch(a){console.error("[r] submit",a)}},!0)}function Ae(t,e){Gt(t);for(let[n,r]of Object.entries(e)){let o=t.querySelector(`[name="${CSS.escape(n)}"]`);if(!o)continue;let i=document.createElement("span");i.className="resuma-field-error",i.setAttribute("data-r-field-error",n),i.textContent=r,o.insertAdjacentElement("afterend",i)}}function Gt(t){t.querySelectorAll("[data-r-field-error]").forEach(e=>e.remove())}function He(){document.addEventListener("submit",t=>{if(!(t.target instanceof HTMLFormElement))return;let e=t.target;if(!e.hasAttribute("data-r-loader-refresh")||e.getAttribute("data-r-on:submit")||e.querySelector("[data-r-on\\:submit]"))return;t.preventDefault();let n=new FormData(e),r={};n.forEach((i,a)=>{let s=String(i);s&&(r[a]=s)});let o=e.getAttribute("action")||location.pathname;window.__resuma?.navigate(A(o,r))},!0)}function _e(t){t.querySelectorAll("template[data-r-stream-chunk]").forEach(e=>{let n=e.getAttribute("data-r-stream-chunk");if(!n)return;let r=t.querySelector(`template[data-r-stream="${n}"]`);if(!r||!r.parentElement)return;let o=e.innerHTML,i=document.createRange().createContextualFragment(o);r.replaceWith(i),e.remove()})}function Ie(t){if(t.startsWith("/")&&!t.startsWith("//")){y(t);return}try{let e=new URL(t,location.origin);if(e.origin===location.origin&&(e.protocol==="http:"||e.protocol==="https:")){y(e.pathname+e.search+e.hash);return}}catch{}window.location.assign(t)}function Pe(t){"startViewTransition"in document&&t.querySelectorAll("[data-r-vt]").forEach(e=>{e.addEventListener("click",n=>{let r=n.target?.closest("a[href]");if(!r||r.getAttribute("target")==="_blank")return;let o=r.getAttribute("href");if(!o||o.startsWith("#")||o.startsWith("javascript:"))return;n.preventDefault();let i=()=>Ie(o);document.startViewTransition?.(i)??i()})})}async function zt(t,e){let n=await fetch(`/_resuma/action/${encodeURIComponent(t)}`,{method:"POST",credentials:"same-origin",headers:K({"content-type":"application/json"}),body:JSON.stringify({args:e})});if(!n.ok)throw new Error(`action ${t}: ${n.status}`);let r=await n.json();if(r.ok===!1)throw new Error(r.error??"action failed");return r.redirect&&G(r.redirect),r.value}async function qe(t,e){try{return{ok:!0,value:await zt(t,e)}}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}}async function Kt(t){let e=await fetch(`/_resuma/island/${encodeURIComponent(t)}`);if(!e.ok)return;let n=await e.text(),r=document.querySelector(`resuma-island[data-r-instance="${t}"]`);if(!r)return;r.outerHTML=n;let o=document.querySelector(`resuma-island[data-r-instance="${CSS.escape(t)}"]`),i=window.__resuma?.signals;!o||!i||(M(o,i),R(o,i),W(o,i),N(o,i),j(o,i),$(o,i))}function Oe(){if(!window.__resumaDev||typeof WebSocket>"u")return;let t=location.protocol==="https:"?"wss":"ws",e=!1,n=()=>{let r=new WebSocket(`${t}://${location.host}/_resuma/dev/ws`);r.addEventListener("open",()=>{if(e){location.reload();return}e=!0}),r.addEventListener("message",o=>{let i=String(o.data);if(i==="reload"){location.reload();return}i.startsWith("island:")&&Kt(i.slice(7))}),r.addEventListener("close",()=>{setTimeout(n,500)}),r.addEventListener("error",()=>{r.close()})};n()}var jt,Bt,Te,$t,Dt,qt=w(()=>{C();ft();pt();bt();Tt();It();Ft();b();O();L();jt="[data-r-flow-dashboard], [data-r-flow-graph], [data-r-event-stream], [data-r-worker-panel]";Bt="resuma-state",Te="resuma-root";$t=()=>document.getElementById(Te)??document.body;Dt=!1});qt();export{Ce as bootstrap,Ut as buildLocalState,ke as mountFlowWidgets,z as mountPage,K as mutationHeaders,Le as runHandler};