@noego/forge 0.1.10 → 0.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/client.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("./page.svelte-Dvj7306U.cjs"),zt=require("svelte/internal/client"),Wt=require("svelte"),Yt=require("../src/components/RecursiveRender.svelte");function Bt(t){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const n=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(r,e,n.get?n:{enumerable:!0,get:()=>t[e]})}}return r.default=t,Object.freeze(r)}const wt=Bt(zt);function Xt(t){const r=new _.path_to_regex(t);return e=>{const n=r.match(e);if(!n)return null;const o={};for(const[i,a]of Object.entries(n))o[i]=decodeURIComponent(a);return o}}function Jt(t){return t.map(r=>{const e=r.path,n=Xt(e);return{pattern:e,parser:n}})}function z(){return z=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var e=arguments[r];for(var n in e)({}).hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t},z.apply(null,arguments)}var j;(function(t){t.Pop="POP",t.Push="PUSH",t.Replace="REPLACE"})(j||(j={}));var ut=process.env.NODE_ENV!=="production"?function(t){return Object.freeze(t)}:function(t){return t};function Kt(t,r){{typeof console<"u"&&console.warn(r);try{throw new Error(r)}catch{}}}var lt="beforeunload",Qt="popstate";function Zt(t){t===void 0&&(t={});var r=t,e=r.window,n=e===void 0?document.defaultView:e,o=n.history;function i(){var p=n.location,m=p.pathname,O=p.search,A=p.hash,E=o.state||{};return[E.idx,ut({pathname:m,search:O,hash:A,state:E.usr||null,key:E.key||"default"})]}var a=null;function u(){if(a)f.call(a),a=null;else{var p=j.Pop,m=i(),O=m[0],A=m[1];if(f.length)if(O!=null){var E=l-O;E&&(a={action:p,location:A,retry:function(){U(E*-1)}},U(E))}else process.env.NODE_ENV!=="production"&&Kt(!1,"You are trying to block a POP navigation to a location that was not created by the history library. The block will fail silently in production, but in general you should do all navigation with the history library (instead of using window.history.pushState directly) to avoid this situation.");else y(p)}}n.addEventListener(Qt,u);var s=j.Pop,c=i(),l=c[0],h=c[1],d=dt(),f=dt();l==null&&(l=0,o.replaceState(z({},o.state,{idx:l}),""));function v(p){return typeof p=="string"?p:ee(p)}function w(p,m){return m===void 0&&(m=null),ut(z({pathname:h.pathname,hash:"",search:""},typeof p=="string"?re(p):p,{state:m,key:te()}))}function I(p,m){return[{usr:p.state,key:p.key,idx:m},v(p)]}function S(p,m,O){return!f.length||(f.call({action:p,location:m,retry:O}),!1)}function y(p){s=p;var m=i();l=m[0],h=m[1],d.call({action:s,location:h})}function st(p,m){var O=j.Push,A=w(p,m);function E(){st(p,m)}if(S(O,A,E)){var R=I(A,l+1),X=R[0],$=R[1];try{o.pushState(X,"",$)}catch{n.location.assign($)}y(O)}}function ct(p,m){var O=j.Replace,A=w(p,m);function E(){ct(p,m)}if(S(O,A,E)){var R=I(A,l),X=R[0],$=R[1];o.replaceState(X,"",$),y(O)}}function U(p){o.go(p)}var Ht={get action(){return s},get location(){return h},createHref:v,push:st,replace:ct,go:U,back:function(){U(-1)},forward:function(){U(1)},listen:function(m){return d.push(m)},block:function(m){var O=f.push(m);return f.length===1&&n.addEventListener(lt,ft),function(){O(),f.length||n.removeEventListener(lt,ft)}}};return Ht}function ft(t){t.preventDefault(),t.returnValue=""}function dt(){var t=[];return{get length(){return t.length},push:function(e){return t.push(e),function(){t=t.filter(function(n){return n!==e})}},call:function(e){t.forEach(function(n){return n&&n(e)})}}}function te(){return Math.random().toString(36).substr(2,8)}function ee(t){var r=t.pathname,e=r===void 0?"/":r,n=t.search,o=n===void 0?"":n,i=t.hash,a=i===void 0?"":i;return o&&o!=="?"&&(e+=o.charAt(0)==="?"?o:"?"+o),a&&a!=="#"&&(e+=a.charAt(0)==="#"?a:"#"+a),e}function re(t){var r={};if(t){var e=t.indexOf("#");e>=0&&(r.hash=t.substr(e),t=t.substr(0,e));var n=t.indexOf("?");n>=0&&(r.search=t.substr(n),t=t.substr(0,n)),t&&(r.pathname=t)}return r}var Z=function(t,r){return Z=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},Z(t,r)};function F(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");Z(t,r);function e(){this.constructor=t}t.prototype=r===null?Object.create(r):(e.prototype=r.prototype,new e)}function ne(t,r,e,n){function o(i){return i instanceof e?i:new e(function(a){a(i)})}return new(e||(e=Promise))(function(i,a){function u(l){try{c(n.next(l))}catch(h){a(h)}}function s(l){try{c(n.throw(l))}catch(h){a(h)}}function c(l){l.done?i(l.value):o(l.value).then(u,s)}c((n=n.apply(t,r||[])).next())})}function mt(t,r){var e={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},n,o,i,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(c){return function(l){return s([c,l])}}function s(c){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(e=0)),e;)try{if(n=1,o&&(i=c[0]&2?o.return:c[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,c[1])).done)return i;switch(o=0,i&&(c=[c[0]&2,i.value]),c[0]){case 0:case 1:i=c;break;case 4:return e.label++,{value:c[1],done:!1};case 5:e.label++,o=c[1],c=[0];continue;case 7:c=e.ops.pop(),e.trys.pop();continue;default:if(i=e.trys,!(i=i.length>0&&i[i.length-1])&&(c[0]===6||c[0]===2)){e=0;continue}if(c[0]===3&&(!i||c[1]>i[0]&&c[1]<i[3])){e.label=c[1];break}if(c[0]===6&&e.label<i[1]){e.label=i[1],i=c;break}if(i&&e.label<i[2]){e.label=i[2],e.ops.push(c);break}i[2]&&e.ops.pop(),e.trys.pop();continue}c=r.call(t,e)}catch(l){c=[6,l],o=0}finally{n=i=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function k(t){var r=typeof Symbol=="function"&&Symbol.iterator,e=r&&t[r],n=0;if(e)return e.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")}function tt(t,r){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var n=e.call(t),o,i=[],a;try{for(;(r===void 0||r-- >0)&&!(o=n.next()).done;)i.push(o.value)}catch(u){a={error:u}}finally{try{o&&!o.done&&(e=n.return)&&e.call(n)}finally{if(a)throw a.error}}return i}function et(t,r,e){if(e||arguments.length===2)for(var n=0,o=r.length,i;n<o;n++)(i||!(n in r))&&(i||(i=Array.prototype.slice.call(r,0,n)),i[n]=r[n]);return t.concat(i||Array.prototype.slice.call(r))}function N(t){return this instanceof N?(this.v=t,this):new N(t)}function oe(t,r,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=e.apply(t,r||[]),o,i=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),u("next"),u("throw"),u("return",a),o[Symbol.asyncIterator]=function(){return this},o;function a(f){return function(v){return Promise.resolve(v).then(f,h)}}function u(f,v){n[f]&&(o[f]=function(w){return new Promise(function(I,S){i.push([f,w,I,S])>1||s(f,w)})},v&&(o[f]=v(o[f])))}function s(f,v){try{c(n[f](v))}catch(w){d(i[0][3],w)}}function c(f){f.value instanceof N?Promise.resolve(f.value.v).then(l,h):d(i[0][2],f)}function l(f){s("next",f)}function h(f){s("throw",f)}function d(f,v){f(v),i.shift(),i.length&&s(i[0][0],i[0][1])}}function ie(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t[Symbol.asyncIterator],e;return r?r.call(t):(t=typeof k=="function"?k(t):t[Symbol.iterator](),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(i){e[i]=t[i]&&function(a){return new Promise(function(u,s){a=t[i](a),o(u,s,a.done,a.value)})}}function o(i,a,u,s){Promise.resolve(s).then(function(c){i({value:c,done:u})},a)}}function g(t){return typeof t=="function"}function bt(t){var r=function(n){Error.call(n),n.stack=new Error().stack},e=t(r);return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}var J=bt(function(t){return function(e){t(this),this.message=e?e.length+` errors occurred during unsubscription:
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("./page.svelte-Dvj7306U.cjs"),Dt=require("svelte/internal/client"),Ht=require("svelte"),Wt=require("../src/components/RecursiveRender.svelte");function zt(t){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const n=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(r,e,n.get?n:{enumerable:!0,get:()=>t[e]})}}return r.default=t,Object.freeze(r)}const yt=zt(Dt);function Yt(t){const r=new S.path_to_regex(t);return e=>{const n=r.match(e);if(!n)return null;const o={};for(const[i,a]of Object.entries(n))o[i]=decodeURIComponent(a);return o}}function Bt(t){return t.map(r=>{const e=r.path,n=Yt(e);return{pattern:e,parser:n}})}function W(){return W=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var e=arguments[r];for(var n in e)({}).hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t},W.apply(null,arguments)}var L;(function(t){t.Pop="POP",t.Push="PUSH",t.Replace="REPLACE"})(L||(L={}));var ct=process.env.NODE_ENV!=="production"?function(t){return Object.freeze(t)}:function(t){return t};function Xt(t,r){{typeof console<"u"&&console.warn(r);try{throw new Error(r)}catch{}}}var ut="beforeunload",Jt="popstate";function Kt(t){t===void 0&&(t={});var r=t,e=r.window,n=e===void 0?document.defaultView:e,o=n.history;function i(){var p=n.location,w=p.pathname,_=p.search,x=p.hash,P=o.state||{};return[P.idx,ct({pathname:w,search:_,hash:x,state:P.usr||null,key:P.key||"default"})]}var a=null;function c(){if(a)f.call(a),a=null;else{var p=L.Pop,w=i(),_=w[0],x=w[1];if(f.length)if(_!=null){var P=l-_;P&&(a={action:p,location:x,retry:function(){q(P*-1)}},q(P))}else process.env.NODE_ENV!=="production"&&Xt(!1,"You are trying to block a POP navigation to a location that was not created by the history library. The block will fail silently in production, but in general you should do all navigation with the history library (instead of using window.history.pushState directly) to avoid this situation.");else T(p)}}n.addEventListener(Jt,c);var s=L.Pop,u=i(),l=u[0],d=u[1],h=ft(),f=ft();l==null&&(l=0,o.replaceState(W({},o.state,{idx:l}),""));function v(p){return typeof p=="string"?p:Zt(p)}function m(p,w){return w===void 0&&(w=null),ct(W({pathname:d.pathname,hash:"",search:""},typeof p=="string"?te(p):p,{state:w,key:Qt()}))}function O(p,w){return[{usr:p.state,key:p.key,idx:w},v(p)]}function A(p,w,_){return!f.length||(f.call({action:p,location:w,retry:_}),!1)}function T(p){s=p;var w=i();l=w[0],d=w[1],h.call({action:s,location:d})}function E(p,w){var _=L.Push,x=m(p,w);function P(){E(p,w)}if(A(_,x,P)){var N=O(x,l+1),K=N[0],$=N[1];try{o.pushState(K,"",$)}catch{n.location.assign($)}T(_)}}function y(p,w){var _=L.Replace,x=m(p,w);function P(){y(p,w)}if(A(_,x,P)){var N=O(x,l),K=N[0],$=N[1];o.replaceState(K,"",$),T(_)}}function q(p){o.go(p)}var Mt={get action(){return s},get location(){return d},createHref:v,push:E,replace:y,go:q,back:function(){q(-1)},forward:function(){q(1)},listen:function(w){return h.push(w)},block:function(w){var _=f.push(w);return f.length===1&&n.addEventListener(ut,lt),function(){_(),f.length||n.removeEventListener(ut,lt)}}};return Mt}function lt(t){t.preventDefault(),t.returnValue=""}function ft(){var t=[];return{get length(){return t.length},push:function(e){return t.push(e),function(){t=t.filter(function(n){return n!==e})}},call:function(e){t.forEach(function(n){return n&&n(e)})}}}function Qt(){return Math.random().toString(36).substr(2,8)}function Zt(t){var r=t.pathname,e=r===void 0?"/":r,n=t.search,o=n===void 0?"":n,i=t.hash,a=i===void 0?"":i;return o&&o!=="?"&&(e+=o.charAt(0)==="?"?o:"?"+o),a&&a!=="#"&&(e+=a.charAt(0)==="#"?a:"#"+a),e}function te(t){var r={};if(t){var e=t.indexOf("#");e>=0&&(r.hash=t.substr(e),t=t.substr(0,e));var n=t.indexOf("?");n>=0&&(r.search=t.substr(n),t=t.substr(0,n)),t&&(r.pathname=t)}return r}var et=function(t,r){return et=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},et(t,r)};function F(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");et(t,r);function e(){this.constructor=t}t.prototype=r===null?Object.create(r):(e.prototype=r.prototype,new e)}function ee(t,r,e,n){function o(i){return i instanceof e?i:new e(function(a){a(i)})}return new(e||(e=Promise))(function(i,a){function c(l){try{u(n.next(l))}catch(d){a(d)}}function s(l){try{u(n.throw(l))}catch(d){a(d)}}function u(l){l.done?i(l.value):o(l.value).then(c,s)}u((n=n.apply(t,r||[])).next())})}function wt(t,r){var e={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},n,o,i,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=c(0),a.throw=c(1),a.return=c(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function c(u){return function(l){return s([u,l])}}function s(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(e=0)),e;)try{if(n=1,o&&(i=u[0]&2?o.return:u[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,u[1])).done)return i;switch(o=0,i&&(u=[u[0]&2,i.value]),u[0]){case 0:case 1:i=u;break;case 4:return e.label++,{value:u[1],done:!1};case 5:e.label++,o=u[1],u=[0];continue;case 7:u=e.ops.pop(),e.trys.pop();continue;default:if(i=e.trys,!(i=i.length>0&&i[i.length-1])&&(u[0]===6||u[0]===2)){e=0;continue}if(u[0]===3&&(!i||u[1]>i[0]&&u[1]<i[3])){e.label=u[1];break}if(u[0]===6&&e.label<i[1]){e.label=i[1],i=u;break}if(i&&e.label<i[2]){e.label=i[2],e.ops.push(u);break}i[2]&&e.ops.pop(),e.trys.pop();continue}u=r.call(t,e)}catch(l){u=[6,l],o=0}finally{n=i=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function C(t){var r=typeof Symbol=="function"&&Symbol.iterator,e=r&&t[r],n=0;if(e)return e.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")}function rt(t,r){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var n=e.call(t),o,i=[],a;try{for(;(r===void 0||r-- >0)&&!(o=n.next()).done;)i.push(o.value)}catch(c){a={error:c}}finally{try{o&&!o.done&&(e=n.return)&&e.call(n)}finally{if(a)throw a.error}}return i}function nt(t,r,e){if(e||arguments.length===2)for(var n=0,o=r.length,i;n<o;n++)(i||!(n in r))&&(i||(i=Array.prototype.slice.call(r,0,n)),i[n]=r[n]);return t.concat(i||Array.prototype.slice.call(r))}function U(t){return this instanceof U?(this.v=t,this):new U(t)}function re(t,r,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=e.apply(t,r||[]),o,i=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",a),o[Symbol.asyncIterator]=function(){return this},o;function a(f){return function(v){return Promise.resolve(v).then(f,d)}}function c(f,v){n[f]&&(o[f]=function(m){return new Promise(function(O,A){i.push([f,m,O,A])>1||s(f,m)})},v&&(o[f]=v(o[f])))}function s(f,v){try{u(n[f](v))}catch(m){h(i[0][3],m)}}function u(f){f.value instanceof U?Promise.resolve(f.value.v).then(l,d):h(i[0][2],f)}function l(f){s("next",f)}function d(f){s("throw",f)}function h(f,v){f(v),i.shift(),i.length&&s(i[0][0],i[0][1])}}function ne(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t[Symbol.asyncIterator],e;return r?r.call(t):(t=typeof C=="function"?C(t):t[Symbol.iterator](),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(i){e[i]=t[i]&&function(a){return new Promise(function(c,s){a=t[i](a),o(c,s,a.done,a.value)})}}function o(i,a,c,s){Promise.resolve(s).then(function(u){i({value:u,done:c})},a)}}function g(t){return typeof t=="function"}function mt(t){var r=function(n){Error.call(n),n.stack=new Error().stack},e=t(r);return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}var Q=mt(function(t){return function(e){t(this),this.message=e?e.length+` errors occurred during unsubscription:
2
2
  `+e.map(function(n,o){return o+1+") "+n.toString()}).join(`
3
- `):"",this.name="UnsubscriptionError",this.errors=e}});function rt(t,r){if(t){var e=t.indexOf(r);0<=e&&t.splice(e,1)}}var Y=(function(){function t(r){this.initialTeardown=r,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var r,e,n,o,i;if(!this.closed){this.closed=!0;var a=this._parentage;if(a)if(this._parentage=null,Array.isArray(a))try{for(var u=k(a),s=u.next();!s.done;s=u.next()){var c=s.value;c.remove(this)}}catch(w){r={error:w}}finally{try{s&&!s.done&&(e=u.return)&&e.call(u)}finally{if(r)throw r.error}}else a.remove(this);var l=this.initialTeardown;if(g(l))try{l()}catch(w){i=w instanceof J?w.errors:[w]}var h=this._finalizers;if(h){this._finalizers=null;try{for(var d=k(h),f=d.next();!f.done;f=d.next()){var v=f.value;try{ht(v)}catch(w){i=i??[],w instanceof J?i=et(et([],tt(i)),tt(w.errors)):i.push(w)}}}catch(w){n={error:w}}finally{try{f&&!f.done&&(o=d.return)&&o.call(d)}finally{if(n)throw n.error}}}if(i)throw new J(i)}},t.prototype.add=function(r){var e;if(r&&r!==this)if(this.closed)ht(r);else{if(r instanceof t){if(r.closed||r._hasParent(this))return;r._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(r)}},t.prototype._hasParent=function(r){var e=this._parentage;return e===r||Array.isArray(e)&&e.includes(r)},t.prototype._addParent=function(r){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(r),e):e?[e,r]:r},t.prototype._removeParent=function(r){var e=this._parentage;e===r?this._parentage=null:Array.isArray(e)&&rt(e,r)},t.prototype.remove=function(r){var e=this._finalizers;e&&rt(e,r),r instanceof t&&r._removeParent(this)},t.EMPTY=(function(){var r=new t;return r.closed=!0,r})(),t})(),gt=Y.EMPTY;function St(t){return t instanceof Y||t&&"closed"in t&&g(t.remove)&&g(t.add)&&g(t.unsubscribe)}function ht(t){g(t)?t():t.unsubscribe()}var ae={Promise:void 0},se={setTimeout:function(t,r){for(var e=[],n=2;n<arguments.length;n++)e[n-2]=arguments[n];return setTimeout.apply(void 0,et([t,r],tt(e)))},clearTimeout:function(t){return clearTimeout(t)},delegate:void 0};function _t(t){se.setTimeout(function(){throw t})}function pt(){}function M(t){t()}var ot=(function(t){F(r,t);function r(e){var n=t.call(this)||this;return n.isStopped=!1,e?(n.destination=e,St(e)&&e.add(n)):n.destination=le,n}return r.create=function(e,n,o){return new nt(e,n,o)},r.prototype.next=function(e){this.isStopped||this._next(e)},r.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},r.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},r.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},r.prototype._next=function(e){this.destination.next(e)},r.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},r.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},r})(Y),ce=(function(){function t(r){this.partialObserver=r}return t.prototype.next=function(r){var e=this.partialObserver;if(e.next)try{e.next(r)}catch(n){G(n)}},t.prototype.error=function(r){var e=this.partialObserver;if(e.error)try{e.error(r)}catch(n){G(n)}else G(r)},t.prototype.complete=function(){var r=this.partialObserver;if(r.complete)try{r.complete()}catch(e){G(e)}},t})(),nt=(function(t){F(r,t);function r(e,n,o){var i=t.call(this)||this,a;return g(e)||!e?a={next:e??void 0,error:n??void 0,complete:o??void 0}:a=e,i.destination=new ce(a),i}return r})(ot);function G(t){_t(t)}function ue(t){throw t}var le={closed:!0,next:pt,error:ue,complete:pt},it=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function Ot(t){return t}function fe(t){return t.length===0?Ot:t.length===1?t[0]:function(e){return t.reduce(function(n,o){return o(n)},e)}}var P=(function(){function t(r){r&&(this._subscribe=r)}return t.prototype.lift=function(r){var e=new t;return e.source=this,e.operator=r,e},t.prototype.subscribe=function(r,e,n){var o=this,i=he(r)?r:new nt(r,e,n);return M(function(){var a=o,u=a.operator,s=a.source;i.add(u?u.call(i,s):s?o._subscribe(i):o._trySubscribe(i))}),i},t.prototype._trySubscribe=function(r){try{return this._subscribe(r)}catch(e){r.error(e)}},t.prototype.forEach=function(r,e){var n=this;return e=vt(e),new e(function(o,i){var a=new nt({next:function(u){try{r(u)}catch(s){i(s),a.unsubscribe()}},error:i,complete:o});n.subscribe(a)})},t.prototype._subscribe=function(r){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(r)},t.prototype[it]=function(){return this},t.prototype.pipe=function(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];return fe(r)(this)},t.prototype.toPromise=function(r){var e=this;return r=vt(r),new r(function(n,o){var i;e.subscribe(function(a){return i=a},function(a){return o(a)},function(){return n(i)})})},t.create=function(r){return new t(r)},t})();function vt(t){var r;return(r=t??ae.Promise)!==null&&r!==void 0?r:Promise}function de(t){return t&&g(t.next)&&g(t.error)&&g(t.complete)}function he(t){return t&&t instanceof ot||de(t)&&St(t)}function pe(t){return g(t==null?void 0:t.lift)}function V(t){return function(r){if(pe(r))return r.lift(function(e){try{return t(e,this)}catch(n){this.error(n)}});throw new TypeError("Unable to lift unknown Observable type")}}function q(t,r,e,n,o){return new ve(t,r,e,n,o)}var ve=(function(t){F(r,t);function r(e,n,o,i,a,u){var s=t.call(this,e)||this;return s.onFinalize=a,s.shouldUnsubscribe=u,s._next=n?function(c){try{n(c)}catch(l){e.error(l)}}:t.prototype._next,s._error=i?function(c){try{i(c)}catch(l){e.error(l)}finally{this.unsubscribe()}}:t.prototype._error,s._complete=o?function(){try{o()}catch(c){e.error(c)}finally{this.unsubscribe()}}:t.prototype._complete,s}return r.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;t.prototype.unsubscribe.call(this),!n&&((e=this.onFinalize)===null||e===void 0||e.call(this))}},r})(ot),ye=bt(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Et=(function(t){F(r,t);function r(){var e=t.call(this)||this;return e.closed=!1,e.currentObservers=null,e.observers=[],e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return r.prototype.lift=function(e){var n=new yt(this,this);return n.operator=e,n},r.prototype._throwIfClosed=function(){if(this.closed)throw new ye},r.prototype.next=function(e){var n=this;M(function(){var o,i;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var a=k(n.currentObservers),u=a.next();!u.done;u=a.next()){var s=u.value;s.next(e)}}catch(c){o={error:c}}finally{try{u&&!u.done&&(i=a.return)&&i.call(a)}finally{if(o)throw o.error}}}})},r.prototype.error=function(e){var n=this;M(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=e;for(var o=n.observers;o.length;)o.shift().error(e)}})},r.prototype.complete=function(){var e=this;M(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var n=e.observers;n.length;)n.shift().complete()}})},r.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(r.prototype,"observed",{get:function(){var e;return((e=this.observers)===null||e===void 0?void 0:e.length)>0},enumerable:!1,configurable:!0}),r.prototype._trySubscribe=function(e){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,e)},r.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},r.prototype._innerSubscribe=function(e){var n=this,o=this,i=o.hasError,a=o.isStopped,u=o.observers;return i||a?gt:(this.currentObservers=null,u.push(e),new Y(function(){n.currentObservers=null,rt(u,e)}))},r.prototype._checkFinalizedStatuses=function(e){var n=this,o=n.hasError,i=n.thrownError,a=n.isStopped;o?e.error(i):a&&e.complete()},r.prototype.asObservable=function(){var e=new P;return e.source=this,e},r.create=function(e,n){return new yt(e,n)},r})(P),yt=(function(t){F(r,t);function r(e,n){var o=t.call(this)||this;return o.destination=e,o.source=n,o}return r.prototype.next=function(e){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.next)===null||o===void 0||o.call(n,e)},r.prototype.error=function(e){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.error)===null||o===void 0||o.call(n,e)},r.prototype.complete=function(){var e,n;(n=(e=this.destination)===null||e===void 0?void 0:e.complete)===null||n===void 0||n.call(e)},r.prototype._subscribe=function(e){var n,o;return(o=(n=this.source)===null||n===void 0?void 0:n.subscribe(e))!==null&&o!==void 0?o:gt},r})(Et),Pt=(function(t){return t&&typeof t.length=="number"&&typeof t!="function"});function It(t){return g(t==null?void 0:t.then)}function At(t){return g(t[it])}function Tt(t){return Symbol.asyncIterator&&g(t==null?void 0:t[Symbol.asyncIterator])}function xt(t){return new TypeError("You provided "+(t!==null&&typeof t=="object"?"an invalid object":"'"+t+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function we(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Rt=we();function jt(t){return g(t==null?void 0:t[Rt])}function Nt(t){return oe(this,arguments,function(){var e,n,o,i;return mt(this,function(a){switch(a.label){case 0:e=t.getReader(),a.label=1;case 1:a.trys.push([1,,9,10]),a.label=2;case 2:return[4,N(e.read())];case 3:return n=a.sent(),o=n.value,i=n.done,i?[4,N(void 0)]:[3,5];case 4:return[2,a.sent()];case 5:return[4,N(o)];case 6:return[4,a.sent()];case 7:return a.sent(),[3,2];case 8:return[3,10];case 9:return e.releaseLock(),[7];case 10:return[2]}})})}function kt(t){return g(t==null?void 0:t.getReader)}function B(t){if(t instanceof P)return t;if(t!=null){if(At(t))return me(t);if(Pt(t))return be(t);if(It(t))return ge(t);if(Tt(t))return Ut(t);if(jt(t))return Se(t);if(kt(t))return _e(t)}throw xt(t)}function me(t){return new P(function(r){var e=t[it]();if(g(e.subscribe))return e.subscribe(r);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function be(t){return new P(function(r){for(var e=0;e<t.length&&!r.closed;e++)r.next(t[e]);r.complete()})}function ge(t){return new P(function(r){t.then(function(e){r.closed||(r.next(e),r.complete())},function(e){return r.error(e)}).then(null,_t)})}function Se(t){return new P(function(r){var e,n;try{for(var o=k(t),i=o.next();!i.done;i=o.next()){var a=i.value;if(r.next(a),r.closed)return}}catch(u){e={error:u}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(e)throw e.error}}r.complete()})}function Ut(t){return new P(function(r){Oe(t,r).catch(function(e){return r.error(e)})})}function _e(t){return Ut(Nt(t))}function Oe(t,r){var e,n,o,i;return ne(this,void 0,void 0,function(){var a,u;return mt(this,function(s){switch(s.label){case 0:s.trys.push([0,5,6,11]),e=ie(t),s.label=1;case 1:return[4,e.next()];case 2:if(n=s.sent(),!!n.done)return[3,4];if(a=n.value,r.next(a),r.closed)return[2];s.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return u=s.sent(),o={error:u},[3,11];case 6:return s.trys.push([6,,9,10]),n&&!n.done&&(i=e.return)?[4,i.call(e)]:[3,8];case 7:s.sent(),s.label=8;case 8:return[3,10];case 9:if(o)throw o.error;return[7];case 10:return[7];case 11:return r.complete(),[2]}})})}function x(t,r,e,n,o){n===void 0&&(n=0),o===void 0&&(o=!1);var i=r.schedule(function(){e(),o?t.add(this.schedule(null,n)):this.unsubscribe()},n);if(t.add(i),!o)return i}function Lt(t,r){return r===void 0&&(r=0),V(function(e,n){e.subscribe(q(n,function(o){return x(n,t,function(){return n.next(o)},r)},function(){return x(n,t,function(){return n.complete()},r)},function(o){return x(n,t,function(){return n.error(o)},r)}))})}function Ct(t,r){return r===void 0&&(r=0),V(function(e,n){n.add(t.schedule(function(){return e.subscribe(n)},r))})}function Ee(t,r){return B(t).pipe(Ct(r),Lt(r))}function Pe(t,r){return B(t).pipe(Ct(r),Lt(r))}function Ie(t,r){return new P(function(e){var n=0;return r.schedule(function(){n===t.length?e.complete():(e.next(t[n++]),e.closed||this.schedule())})})}function Ae(t,r){return new P(function(e){var n;return x(e,r,function(){n=t[Rt](),x(e,r,function(){var o,i,a;try{o=n.next(),i=o.value,a=o.done}catch(u){e.error(u);return}a?e.complete():e.next(i)},0,!0)}),function(){return g(n==null?void 0:n.return)&&n.return()}})}function qt(t,r){if(!t)throw new Error("Iterable cannot be null");return new P(function(e){x(e,r,function(){var n=t[Symbol.asyncIterator]();x(e,r,function(){n.next().then(function(o){o.done?e.complete():e.next(o.value)})},0,!0)})})}function Te(t,r){return qt(Nt(t),r)}function xe(t,r){if(t!=null){if(At(t))return Ee(t,r);if(Pt(t))return Ie(t,r);if(It(t))return Pe(t,r);if(Tt(t))return qt(t,r);if(jt(t))return Ae(t,r);if(kt(t))return Te(t,r)}throw xt(t)}function Re(t,r){return r?xe(t,r):B(t)}function je(t,r){return V(function(e,n){var o=0;e.subscribe(q(n,function(i){return t.call(r,i,o++)&&n.next(i)}))})}function Ne(t,r){return V(function(e,n){var o=0,i=null,a=!1;e.subscribe(q(n,function(u){i||(i=q(n,void 0,function(){i=null,a&&n.complete()}),B(t(u,o++)).subscribe(i))},function(){a=!0,!i&&n.complete()}))})}function ke(t,r,e){var n=g(t)||r||e?{next:t,error:r,complete:e}:t;return n?V(function(o,i){var a;(a=n.subscribe)===null||a===void 0||a.call(n);var u=!0;o.subscribe(q(i,function(s){var c;(c=n.next)===null||c===void 0||c.call(n,s),i.next(s)},function(){var s;u=!1,(s=n.complete)===null||s===void 0||s.call(n),i.complete()},function(s){var c;u=!1,(c=n.error)===null||c===void 0||c.call(n,s),i.error(s)},function(){var s,c;u&&((s=n.unsubscribe)===null||s===void 0||s.call(n)),(c=n.finalize)===null||c===void 0||c.call(n)}))}):Ot}const Ue=Zt(),Le=1e4;function Ce(t,r,e){return Promise.race([t,new Promise((n,o)=>{setTimeout(()=>{e(),o(new Error(`Navigation timed out after ${r}ms`))},r)})])}const Ft=new Et;let at=null,D=null,C=!1;function qe(t){if(t&&t.redirectPath){console.log("[NAVIGATION] Handling deferred redirect to",t.redirectPath),setTimeout(()=>{window.dispatchEvent(new PopStateEvent("popstate",{state:null}))},0);return}if(D){const r=D;D=null,r.url!==at&&(console.log("[NAVIGATION] Processing queued navigation to",r.url),setTimeout(()=>Vt(r),0))}}Ft.pipe(je(t=>t.url===at&&!t.update?(console.log("[NAVIGATION] Skipping duplicate navigation to",t.url),!1):!0),ke(t=>{C&&(console.log("[NAVIGATION] Queueing navigation to",t.url,"(current navigation in progress)"),D=t)}),Ne(t=>Re(Ce(Fe(t),Le,()=>{console.error("[NAVIGATION] Navigation timed out, resetting state"),C=!1}).catch(r=>{console.error("[NAVIGATION] Navigation failed, recovering:",r)})))).subscribe({next:qe,error:t=>{console.error("[NAVIGATION] Stream error (recovering):",t),C=!1}});function Vt(t){Ft.next(t)}const b=wt.proxy({layouts:[],view:null,data:null,params:null,urlParams:null,query:null,page:_.page});function W(...t){let r=t.map((e,n)=>n===0?e.replace(/\/+$/,""):e.replace(/^\/+|\/+$/g,"")).join("/");return r.startsWith("/")||(r="/"+r),r.split("?")[0]}async function $t(t,r,e,n,o,i){try{const a=typeof r=="string"&&r.indexOf("assets")!==-1,u=(e.layout||[]).map(h=>{let d=W(r,h).toString();return a&&(d=d.endsWith(".svelte")?d.replace(/\.svelte$/,".js"):/[.][a-z]+$/.test(d)?d:d+".js"),d});let s=W(r,e.view).toString();a&&(s=s.endsWith(".svelte")?s.replace(/\.svelte$/,".js"):/[.][a-z]+$/.test(s)?s:s+".js");const c=await Promise.all(u.map(h=>import(h).then(d=>d.default)));s.startsWith("/")||(s="/"+s);const l=await import(s).then(h=>h.default);b.layouts=c,b.view=l,b.params=n,b.data=window.__INITIAL_DATA__,b.urlParams=o,b.query=i,Wt.hydrate(Yt,{target:t,props:b})}catch(a){console.error("Client-side route loading failed:",a)}}function L(t,r,e,n,o,i,a=!1,u=!0){Vt({url:t,base_path:r,route:e,params:n,urlParams:o,query:i,server_loading:a,update:u})}async function Fe(t){const{url:r,base_path:e,route:n,params:o,urlParams:i,query:a,server_loading:u,update:s}=t;C=!0,console.log("[NAVIGATION] updateRoute called",{url:r,server_loading:u,route_path:n.path,route_middleware:n.middleware});try{let c=null,l=!1,h=null;if(u){console.log("[NAVIGATION] Making server fetch FIRST for",r);const S={method:n.method,headers:{"Content-Type":"application/json",Accept:"application/json"}};if(S[Dt]=!0,await fetch(r,S).then(y=>{if(console.log("[NAVIGATION] Fetch response",{url:r,ok:y.ok,status:y.status,type:y.type,redirected:y.redirected,finalUrl:y.url}),y.redirected||y.headers.get("X-Forge-Redirect")==="true")return console.log("[NAVIGATION] Redirect detected, not loading components"),l=!0,h=y.headers.get("X-Forge-Redirect-Path"),null;if(y.ok)return y.json();throw new Error("Network response was not ok")}).then(y=>{c=y}),l)return console.log("[NAVIGATION] Exiting early due to redirect to",h),{redirectPath:h||void 0}}const d=typeof e=="string"&&e.indexOf("assets")!==-1,f=(n.layout||[]).map(S=>{let y=W(e,S).toString();return d&&(y=y.endsWith(".svelte")?y.replace(/\.svelte$/,".js"):/[.][a-z]+$/.test(y)?y:y+".js"),y});let v=W(e,n.view).toString();d&&(v=v.endsWith(".svelte")?v.replace(/\.svelte$/,".js"):/[.][a-z]+$/.test(v)?v:v+".js");const w=await Promise.all(f.map(S=>import(S).then(y=>y.default))),I=await import(v).then(S=>S.default);u?(b.data=c,b.params=o,b.layouts=w,b.view=I,b.urlParams=i,b.query=a):(console.log("[NAVIGATION] No server loading needed for",r),b.data={layout:[],view:{}},b.params=o,b.layouts=w,b.view=I,b.urlParams=i,b.query=a),window&&window.scroll(0,0),s&&Ue.push(r),at=r}catch(c){throw console.error("Client-side navigation failed for URL:",r,c),c}finally{C=!1}}const T=wt.proxy({});async function Gt(){Object.assign(T,window.__MANIFEST__)}function Mt(t,r,e){if(!document){console.error("Document not found");return}document.addEventListener("click",n=>{var a,u;const o=window.location.pathname,i=((a=n.target)==null?void 0:a.tagName)==="A"?n.target:(u=n.target)==null?void 0:u.closest("A");if(i){let s=i.getAttribute("href");if(o===s){n.preventDefault();return}if(s&&s.startsWith("/")||s.startsWith(".")){const c=s.split("?")[0],l=i.getAttribute("method")||"get",h=r.find(d=>d.method.toLowerCase()===l&&e.find(f=>f.parser(c)&&f.pattern===d.path));if(h){n.preventDefault();const d=e.find(y=>y.parser(c)&&y.pattern===h.path),f=(d==null?void 0:d.parser(c))||{},v=new URLSearchParams(s.split("?")[1]||""),w=Object.fromEntries(v.entries())||{},I={...f,...w},S=T[d==null?void 0:d.pattern];console.log("[EVENTS] Navigation to",s,{pattern:d==null?void 0:d.pattern,requires_server_data:S,manifest_store:T,middleware:h.middleware}),L(s,t,h,I,f,w,S)}else console.log("No matching route found for URL:",s,"- using fallback navigation")}}}),window.addEventListener("popstate",n=>{const o=window.location.pathname,i=window.location.pathname+window.location.search;_.page.url=i,_.page.pathname=window.location.pathname;const a="get",u=r.find(s=>s.method.toLowerCase()===a&&e.find(c=>c.parser(o)&&c.pattern===s.path));if(u){const s=e.find(v=>v.parser(o)&&v.pattern===u.path),c=(s==null?void 0:s.parser(o))||{},l=new URLSearchParams(window.location.search),h=Object.fromEntries(l.entries())||{};_.page.params=c,_.page.query=h;const d={...c,...h},f=T[s==null?void 0:s.pattern];L(i,t,u,d,c,h,f,!1)}else console.log("No matching route found for popstate navigation to:",o,"- using fallback navigation"),window.location.href=o}),(function(){const n=history.pushState,o=history.replaceState;history.pushState=function(...i){const a=n.apply(this,i),u=new Event("pushstate");return u.state=i[0],u.url=i[2],window.dispatchEvent(u),a},history.replaceState=function(...i){const a=o.apply(this,i),u=i[2],s=window.location.pathname;if((u?new URL(u,window.location.origin).pathname:s)!==s){const l=new Event("replacestate");l.state=i[0],l.url=i[2],window.dispatchEvent(l)}return a}})(),window.addEventListener("pushstate",n=>{const o=n.url||window.location.pathname+window.location.search,i=o.split("?")[0],a="get",u=r.find(s=>s.method.toLowerCase()===a&&e.find(c=>c.parser(i)&&c.pattern===s.path));if(u){const s=e.find(v=>v.parser(i)&&v.pattern===u.path),c=s==null?void 0:s.parser(i),l=new URLSearchParams(o.split("?")[1]||""),h=Object.fromEntries(l.entries());_.page.url=o,_.page.pathname=window.location.pathname,Object.assign(_.page.params,c),Object.assign(_.page.query,h);const d={...c,...h},f=T[s==null?void 0:s.pattern];L(o,t,u,d,c,h,f,!1)}else console.log("No matching route found for pushstate to:",i,"- using fallback navigation"),window.location.href=i}),window.addEventListener("replacestate",n=>{const o=n.url||window.location.pathname+window.location.search,i=o.split("?")[0];_.page.url=o,_.page.pathname=window.location.pathname,_.page.query=Object.fromEntries(new URLSearchParams(o.split("?")[1]||""));const a="get",u=r.find(s=>s.method.toLowerCase()===a&&e.find(c=>c.parser(i)&&c.pattern===s.path));if(u){const s=e.find(v=>v.parser(i)&&v.pattern===u.path),c=(s==null?void 0:s.parser(i))||{},l=new URLSearchParams(o.split("?")[1]||""),h=Object.fromEntries(l.entries())||{},d={...c,...h},f=T[s==null?void 0:s.pattern];L(o,t,u,d,c,h,f,!1)}else console.log("No matching route found for replacestate to:",i,"- using fallback navigation"),window.location.href=i})}const Dt=Symbol("forge-load-function");let H=[],K=null;function Ve(t){try{const r=new URL(t,window.location.origin);return r.origin===window.location.origin&&!r.pathname.startsWith("/api/")}catch{return!t.startsWith("/api/")}}function $e(){typeof window<"u"&&!K&&(K=window.fetch,window.fetch=async function(t,r={}){let e={...r};for(const i of H)try{if(i.length===2){const a=new Headers(e.headers),u=Object.fromEntries(a.entries());await new Promise((s,c)=>{try{i(u,l=>{if(l)c(l);else{const h=new Headers;Object.entries(u).forEach(([d,f])=>{f!==void 0&&h.set(d,f)}),e.headers=h,s()}})}catch(l){c(l)}})}else{const a=await i(e,t);a&&typeof a=="object"&&(e=a)}}catch(a){throw console.error("🔴 Middleware error:",a),a}const n=e==null?void 0:e[Dt];console.log("[FETCH OVERRIDE] Request",{url:t,hasForgeSymbol:n,headers:e==null?void 0:e.headers});const o=await K(t,e);if(console.log("[FETCH OVERRIDE] Response",{url:t,responseUrl:o.url,redirected:o.redirected,status:o.status,type:o.type,hasForgeSymbol:n}),n&&o.redirected){const i=typeof t=="string"?t:t.url,a=o.url;if(console.log("[FORGE REDIRECT] Detected redirect",{requested:i,final:a,redirected:o.redirected}),Ve(a)){const u=new URL(a),s=u.pathname+u.search;return console.log("[FORGE REDIRECT] Using pushState for SPA navigation to:",s,"from:",a),history.pushState(null,"",s),new Response(JSON.stringify({layout:[],view:{}}),{status:200,headers:{"Content-Type":"application/json","X-Forge-Redirect":"true","X-Forge-Redirect-Path":s}})}}return o})}$e();const Ge={configUpdate(t){if(typeof t!="function")throw new Error("Middleware must be a function");H.push(t)},reset(){H.length=0},getMiddlewareCount(){return H.length}};let Q;async function Me(t,r){let e=window.__COMPONENT_DIR__||r.component_dir;if(!e&&typeof e!="string")throw new Error("No component directory provided");let n=window.__ROUTING__;if(Q=Jt(n),window&&window.location){const o=(window.location.pathname||"/").split("?")[0],i=Q.find(u=>u.parser(o));let a=i?n.find(u=>u.path===i.pattern):null;if(i&&a){const u=i.parser(o)||{},s=new URLSearchParams(window.location.search),c=Object.fromEntries(s.entries())||{},l={...u,...c};Gt(),$t(t,e,a,l,u,c),Mt(e,n,Q)}else console.warn("No matching route found for:",o)}}exports.page=_.page;exports.shadowUrl=_.shadowUrl;exports.MANIFEST_STORE=T;exports.bootstrap_events=Mt;exports.createApp=Me;exports.fetch=Ge;exports.loadRoute=$t;exports.updateManifestStore=Gt;exports.updateRoute=L;
3
+ `):"",this.name="UnsubscriptionError",this.errors=e}});function ot(t,r){if(t){var e=t.indexOf(r);0<=e&&t.splice(e,1)}}var B=(function(){function t(r){this.initialTeardown=r,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var r,e,n,o,i;if(!this.closed){this.closed=!0;var a=this._parentage;if(a)if(this._parentage=null,Array.isArray(a))try{for(var c=C(a),s=c.next();!s.done;s=c.next()){var u=s.value;u.remove(this)}}catch(m){r={error:m}}finally{try{s&&!s.done&&(e=c.return)&&e.call(c)}finally{if(r)throw r.error}}else a.remove(this);var l=this.initialTeardown;if(g(l))try{l()}catch(m){i=m instanceof Q?m.errors:[m]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var h=C(d),f=h.next();!f.done;f=h.next()){var v=f.value;try{dt(v)}catch(m){i=i??[],m instanceof Q?i=nt(nt([],rt(i)),rt(m.errors)):i.push(m)}}}catch(m){n={error:m}}finally{try{f&&!f.done&&(o=h.return)&&o.call(h)}finally{if(n)throw n.error}}}if(i)throw new Q(i)}},t.prototype.add=function(r){var e;if(r&&r!==this)if(this.closed)dt(r);else{if(r instanceof t){if(r.closed||r._hasParent(this))return;r._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(r)}},t.prototype._hasParent=function(r){var e=this._parentage;return e===r||Array.isArray(e)&&e.includes(r)},t.prototype._addParent=function(r){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(r),e):e?[e,r]:r},t.prototype._removeParent=function(r){var e=this._parentage;e===r?this._parentage=null:Array.isArray(e)&&ot(e,r)},t.prototype.remove=function(r){var e=this._finalizers;e&&ot(e,r),r instanceof t&&r._removeParent(this)},t.EMPTY=(function(){var r=new t;return r.closed=!0,r})(),t})(),bt=B.EMPTY;function gt(t){return t instanceof B||t&&"closed"in t&&g(t.remove)&&g(t.add)&&g(t.unsubscribe)}function dt(t){g(t)?t():t.unsubscribe()}var oe={Promise:void 0},ie={setTimeout:function(t,r){for(var e=[],n=2;n<arguments.length;n++)e[n-2]=arguments[n];return setTimeout.apply(void 0,nt([t,r],rt(e)))},clearTimeout:function(t){return clearTimeout(t)},delegate:void 0};function St(t){ie.setTimeout(function(){throw t})}function ht(){}function G(t){t()}var at=(function(t){F(r,t);function r(e){var n=t.call(this)||this;return n.isStopped=!1,e?(n.destination=e,gt(e)&&e.add(n)):n.destination=ce,n}return r.create=function(e,n,o){return new it(e,n,o)},r.prototype.next=function(e){this.isStopped||this._next(e)},r.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},r.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},r.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},r.prototype._next=function(e){this.destination.next(e)},r.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},r.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},r})(B),ae=(function(){function t(r){this.partialObserver=r}return t.prototype.next=function(r){var e=this.partialObserver;if(e.next)try{e.next(r)}catch(n){V(n)}},t.prototype.error=function(r){var e=this.partialObserver;if(e.error)try{e.error(r)}catch(n){V(n)}else V(r)},t.prototype.complete=function(){var r=this.partialObserver;if(r.complete)try{r.complete()}catch(e){V(e)}},t})(),it=(function(t){F(r,t);function r(e,n,o){var i=t.call(this)||this,a;return g(e)||!e?a={next:e??void 0,error:n??void 0,complete:o??void 0}:a=e,i.destination=new ae(a),i}return r})(at);function V(t){St(t)}function se(t){throw t}var ce={closed:!0,next:ht,error:se,complete:ht},st=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function ue(t){return t}function le(t){return t.length===0?ue:t.length===1?t[0]:function(e){return t.reduce(function(n,o){return o(n)},e)}}var I=(function(){function t(r){r&&(this._subscribe=r)}return t.prototype.lift=function(r){var e=new t;return e.source=this,e.operator=r,e},t.prototype.subscribe=function(r,e,n){var o=this,i=de(r)?r:new it(r,e,n);return G(function(){var a=o,c=a.operator,s=a.source;i.add(c?c.call(i,s):s?o._subscribe(i):o._trySubscribe(i))}),i},t.prototype._trySubscribe=function(r){try{return this._subscribe(r)}catch(e){r.error(e)}},t.prototype.forEach=function(r,e){var n=this;return e=pt(e),new e(function(o,i){var a=new it({next:function(c){try{r(c)}catch(s){i(s),a.unsubscribe()}},error:i,complete:o});n.subscribe(a)})},t.prototype._subscribe=function(r){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(r)},t.prototype[st]=function(){return this},t.prototype.pipe=function(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];return le(r)(this)},t.prototype.toPromise=function(r){var e=this;return r=pt(r),new r(function(n,o){var i;e.subscribe(function(a){return i=a},function(a){return o(a)},function(){return n(i)})})},t.create=function(r){return new t(r)},t})();function pt(t){var r;return(r=t??oe.Promise)!==null&&r!==void 0?r:Promise}function fe(t){return t&&g(t.next)&&g(t.error)&&g(t.complete)}function de(t){return t&&t instanceof at||fe(t)&&gt(t)}function he(t){return g(t==null?void 0:t.lift)}function X(t){return function(r){if(he(r))return r.lift(function(e){try{return t(e,this)}catch(n){this.error(n)}});throw new TypeError("Unable to lift unknown Observable type")}}function z(t,r,e,n,o){return new pe(t,r,e,n,o)}var pe=(function(t){F(r,t);function r(e,n,o,i,a,c){var s=t.call(this,e)||this;return s.onFinalize=a,s.shouldUnsubscribe=c,s._next=n?function(u){try{n(u)}catch(l){e.error(l)}}:t.prototype._next,s._error=i?function(u){try{i(u)}catch(l){e.error(l)}finally{this.unsubscribe()}}:t.prototype._error,s._complete=o?function(){try{o()}catch(u){e.error(u)}finally{this.unsubscribe()}}:t.prototype._complete,s}return r.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;t.prototype.unsubscribe.call(this),!n&&((e=this.onFinalize)===null||e===void 0||e.call(this))}},r})(at),ve=mt(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Ot=(function(t){F(r,t);function r(){var e=t.call(this)||this;return e.closed=!1,e.currentObservers=null,e.observers=[],e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return r.prototype.lift=function(e){var n=new vt(this,this);return n.operator=e,n},r.prototype._throwIfClosed=function(){if(this.closed)throw new ve},r.prototype.next=function(e){var n=this;G(function(){var o,i;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var a=C(n.currentObservers),c=a.next();!c.done;c=a.next()){var s=c.value;s.next(e)}}catch(u){o={error:u}}finally{try{c&&!c.done&&(i=a.return)&&i.call(a)}finally{if(o)throw o.error}}}})},r.prototype.error=function(e){var n=this;G(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=e;for(var o=n.observers;o.length;)o.shift().error(e)}})},r.prototype.complete=function(){var e=this;G(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var n=e.observers;n.length;)n.shift().complete()}})},r.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(r.prototype,"observed",{get:function(){var e;return((e=this.observers)===null||e===void 0?void 0:e.length)>0},enumerable:!1,configurable:!0}),r.prototype._trySubscribe=function(e){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,e)},r.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},r.prototype._innerSubscribe=function(e){var n=this,o=this,i=o.hasError,a=o.isStopped,c=o.observers;return i||a?bt:(this.currentObservers=null,c.push(e),new B(function(){n.currentObservers=null,ot(c,e)}))},r.prototype._checkFinalizedStatuses=function(e){var n=this,o=n.hasError,i=n.thrownError,a=n.isStopped;o?e.error(i):a&&e.complete()},r.prototype.asObservable=function(){var e=new I;return e.source=this,e},r.create=function(e,n){return new vt(e,n)},r})(I),vt=(function(t){F(r,t);function r(e,n){var o=t.call(this)||this;return o.destination=e,o.source=n,o}return r.prototype.next=function(e){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.next)===null||o===void 0||o.call(n,e)},r.prototype.error=function(e){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.error)===null||o===void 0||o.call(n,e)},r.prototype.complete=function(){var e,n;(n=(e=this.destination)===null||e===void 0?void 0:e.complete)===null||n===void 0||n.call(e)},r.prototype._subscribe=function(e){var n,o;return(o=(n=this.source)===null||n===void 0?void 0:n.subscribe(e))!==null&&o!==void 0?o:bt},r})(Ot),_t=(function(t){return t&&typeof t.length=="number"&&typeof t!="function"});function Et(t){return g(t==null?void 0:t.then)}function Pt(t){return g(t[st])}function It(t){return Symbol.asyncIterator&&g(t==null?void 0:t[Symbol.asyncIterator])}function At(t){return new TypeError("You provided "+(t!==null&&typeof t=="object"?"an invalid object":"'"+t+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function ye(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Tt=ye();function xt(t){return g(t==null?void 0:t[Tt])}function Rt(t){return re(this,arguments,function(){var e,n,o,i;return wt(this,function(a){switch(a.label){case 0:e=t.getReader(),a.label=1;case 1:a.trys.push([1,,9,10]),a.label=2;case 2:return[4,U(e.read())];case 3:return n=a.sent(),o=n.value,i=n.done,i?[4,U(void 0)]:[3,5];case 4:return[2,a.sent()];case 5:return[4,U(o)];case 6:return[4,a.sent()];case 7:return a.sent(),[3,2];case 8:return[3,10];case 9:return e.releaseLock(),[7];case 10:return[2]}})})}function jt(t){return g(t==null?void 0:t.getReader)}function J(t){if(t instanceof I)return t;if(t!=null){if(Pt(t))return we(t);if(_t(t))return me(t);if(Et(t))return be(t);if(It(t))return Nt(t);if(xt(t))return ge(t);if(jt(t))return Se(t)}throw At(t)}function we(t){return new I(function(r){var e=t[st]();if(g(e.subscribe))return e.subscribe(r);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function me(t){return new I(function(r){for(var e=0;e<t.length&&!r.closed;e++)r.next(t[e]);r.complete()})}function be(t){return new I(function(r){t.then(function(e){r.closed||(r.next(e),r.complete())},function(e){return r.error(e)}).then(null,St)})}function ge(t){return new I(function(r){var e,n;try{for(var o=C(t),i=o.next();!i.done;i=o.next()){var a=i.value;if(r.next(a),r.closed)return}}catch(c){e={error:c}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(e)throw e.error}}r.complete()})}function Nt(t){return new I(function(r){Oe(t,r).catch(function(e){return r.error(e)})})}function Se(t){return Nt(Rt(t))}function Oe(t,r){var e,n,o,i;return ee(this,void 0,void 0,function(){var a,c;return wt(this,function(s){switch(s.label){case 0:s.trys.push([0,5,6,11]),e=ne(t),s.label=1;case 1:return[4,e.next()];case 2:if(n=s.sent(),!!n.done)return[3,4];if(a=n.value,r.next(a),r.closed)return[2];s.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return c=s.sent(),o={error:c},[3,11];case 6:return s.trys.push([6,,9,10]),n&&!n.done&&(i=e.return)?[4,i.call(e)]:[3,8];case 7:s.sent(),s.label=8;case 8:return[3,10];case 9:if(o)throw o.error;return[7];case 10:return[7];case 11:return r.complete(),[2]}})})}function j(t,r,e,n,o){n===void 0&&(n=0),o===void 0&&(o=!1);var i=r.schedule(function(){e(),o?t.add(this.schedule(null,n)):this.unsubscribe()},n);if(t.add(i),!o)return i}function kt(t,r){return r===void 0&&(r=0),X(function(e,n){e.subscribe(z(n,function(o){return j(n,t,function(){return n.next(o)},r)},function(){return j(n,t,function(){return n.complete()},r)},function(o){return j(n,t,function(){return n.error(o)},r)}))})}function Lt(t,r){return r===void 0&&(r=0),X(function(e,n){n.add(t.schedule(function(){return e.subscribe(n)},r))})}function _e(t,r){return J(t).pipe(Lt(r),kt(r))}function Ee(t,r){return J(t).pipe(Lt(r),kt(r))}function Pe(t,r){return new I(function(e){var n=0;return r.schedule(function(){n===t.length?e.complete():(e.next(t[n++]),e.closed||this.schedule())})})}function Ie(t,r){return new I(function(e){var n;return j(e,r,function(){n=t[Tt](),j(e,r,function(){var o,i,a;try{o=n.next(),i=o.value,a=o.done}catch(c){e.error(c);return}a?e.complete():e.next(i)},0,!0)}),function(){return g(n==null?void 0:n.return)&&n.return()}})}function Ut(t,r){if(!t)throw new Error("Iterable cannot be null");return new I(function(e){j(e,r,function(){var n=t[Symbol.asyncIterator]();j(e,r,function(){n.next().then(function(o){o.done?e.complete():e.next(o.value)})},0,!0)})})}function Ae(t,r){return Ut(Rt(t),r)}function Te(t,r){if(t!=null){if(Pt(t))return _e(t,r);if(_t(t))return Pe(t,r);if(Et(t))return Ee(t,r);if(It(t))return Ut(t,r);if(xt(t))return Ie(t,r);if(jt(t))return Ae(t,r)}throw At(t)}function xe(t,r){return r?Te(t,r):J(t)}function Re(t,r){return X(function(e,n){var o=0;e.subscribe(z(n,function(i){return t.call(r,i,o++)&&n.next(i)}))})}function je(t,r){return X(function(e,n){var o=null,i=0,a=!1,c=function(){return a&&!o&&n.complete()};e.subscribe(z(n,function(s){o==null||o.unsubscribe();var u=0,l=i++;J(t(s,l)).subscribe(o=z(n,function(d){return n.next(r?r(s,d,l,u++):d)},function(){o=null,c()}))},function(){a=!0,c()}))})}const Ne=Kt(),ke=1e4;function Le(t,r,e){return Promise.race([t,new Promise((n,o)=>{setTimeout(()=>{e(),o(new Error(`Navigation timed out after ${r}ms`))},r)})])}const Ct=new Ot;let qt=null,M=0,D=null;function Ue(t){t&&t.redirectPath&&(console.log("[NAVIGATION] Handling redirect to",t.redirectPath),setTimeout(()=>{window.dispatchEvent(new CustomEvent("forge-redirect",{detail:{path:t.redirectPath}}))},0))}Ct.pipe(Re(t=>t.url===qt&&!t.update?(console.log("[NAVIGATION] Skipping duplicate navigation to",t.url),!1):!0),je(t=>xe(Le(qe(t),ke,()=>{console.error("[NAVIGATION] Navigation timed out, invalidating and resetting"),M++,D&&(D.abort(),D=null)}).catch(r=>{console.error("[NAVIGATION] Navigation failed, recovering:",r)})))).subscribe({next:Ue,error:t=>{console.error("[NAVIGATION] Stream error (recovering):",t)}});function Ce(t){Ct.next(t)}const b=yt.proxy({layouts:[],view:null,data:null,params:null,urlParams:null,query:null,page:S.page});function Y(...t){let r=t.map((e,n)=>n===0?e.replace(/\/+$/,""):e.replace(/^\/+|\/+$/g,"")).join("/");return r.startsWith("/")||(r="/"+r),r.split("?")[0]}async function Ft(t,r,e,n,o,i){try{const a=typeof r=="string"&&r.indexOf("assets")!==-1,c=(e.layout||[]).map(d=>{let h=Y(r,d).toString();return a&&(h=h.endsWith(".svelte")?h.replace(/\.svelte$/,".js"):/[.][a-z]+$/.test(h)?h:h+".js"),h});let s=Y(r,e.view).toString();a&&(s=s.endsWith(".svelte")?s.replace(/\.svelte$/,".js"):/[.][a-z]+$/.test(s)?s:s+".js");const u=await Promise.all(c.map(d=>import(d).then(h=>h.default)));s.startsWith("/")||(s="/"+s);const l=await import(s).then(d=>d.default);b.layouts=u,b.view=l,b.params=n,b.data=window.__INITIAL_DATA__,b.urlParams=o,b.query=i,Ht.hydrate(Wt,{target:t,props:b})}catch(a){console.error("Client-side route loading failed:",a)}}function k(t,r,e,n,o,i,a=!1,c=!0){Ce({url:t,base_path:r,route:e,params:n,urlParams:o,query:i,server_loading:a,update:c})}async function qe(t){const{url:r,base_path:e,route:n,params:o,urlParams:i,query:a,server_loading:c,update:s}=t,u=++M,l=new AbortController;D=l,console.log("[NAVIGATION] Starting navigation",{navigationId:u,url:r,server_loading:c,route_path:n.path,route_middleware:n.middleware});try{let d=null,h=!1,f=null;if(c){console.log("[NAVIGATION] Making server fetch FIRST for",r);const E={method:n.method,headers:{"Content-Type":"application/json",Accept:"application/json"},signal:l.signal};if(E[Gt]=!0,await fetch(r,E).then(y=>{if(console.log("[NAVIGATION] Fetch response",{url:r,ok:y.ok,status:y.status,type:y.type,redirected:y.redirected,finalUrl:y.url}),y.redirected||y.headers.get("X-Forge-Redirect")==="true")return console.log("[NAVIGATION] Redirect detected, not loading components"),h=!0,f=y.headers.get("X-Forge-Redirect-Path"),null;if(y.ok)return y.json();throw new Error("Network response was not ok")}).then(y=>{d=y}),h)return console.log("[NAVIGATION] Exiting early due to redirect to",f),{redirectPath:f||void 0}}const v=typeof e=="string"&&e.indexOf("assets")!==-1,m=(n.layout||[]).map(E=>{let y=Y(e,E).toString();return v&&(y=y.endsWith(".svelte")?y.replace(/\.svelte$/,".js"):/[.][a-z]+$/.test(y)?y:y+".js"),y});let O=Y(e,n.view).toString();v&&(O=O.endsWith(".svelte")?O.replace(/\.svelte$/,".js"):/[.][a-z]+$/.test(O)?O:O+".js");const A=await Promise.all(m.map(E=>import(E).then(y=>y.default))),T=await import(O).then(E=>E.default);if(u!==M){console.log("[NAVIGATION] Stale navigation detected, skipping ROOT update",{navigationId:u,currentNavigationId:M,url:r});return}c?(b.data=d,b.params=o,b.layouts=A,b.view=T,b.urlParams=i,b.query=a):(console.log("[NAVIGATION] No server loading needed for",r),b.data={layout:[],view:{}},b.params=o,b.layouts=A,b.view=T,b.urlParams=i,b.query=a),window&&window.scroll(0,0),s&&Ne.push(r),qt=r}catch(d){throw console.error("Client-side navigation failed for URL:",r,d),d}finally{}}const R=yt.proxy({});async function $t(){Object.assign(R,window.__MANIFEST__)}function Vt(t,r,e){if(!document){console.error("Document not found");return}document.addEventListener("click",n=>{var a,c;const o=window.location.pathname,i=((a=n.target)==null?void 0:a.tagName)==="A"?n.target:(c=n.target)==null?void 0:c.closest("A");if(i){let s=i.getAttribute("href");if(o===s){n.preventDefault();return}if(s&&s.startsWith("/")||s.startsWith(".")){const u=s.split("?")[0],l=i.getAttribute("method")||"get",d=r.find(h=>h.method.toLowerCase()===l&&e.find(f=>f.parser(u)&&f.pattern===h.path));if(d){n.preventDefault();const h=e.find(T=>T.parser(u)&&T.pattern===d.path),f=(h==null?void 0:h.parser(u))||{},v=new URLSearchParams(s.split("?")[1]||""),m=Object.fromEntries(v.entries())||{},O={...f,...m},A=R[h==null?void 0:h.pattern];console.log("[EVENTS] Navigation to",s,{pattern:h==null?void 0:h.pattern,requires_server_data:A,manifest_store:R,middleware:d.middleware}),k(s,t,d,O,f,m,A)}else console.log("No matching route found for URL:",s,"- using fallback navigation")}}}),window.addEventListener("popstate",n=>{const o=window.location.pathname,i=window.location.pathname+window.location.search;S.page.url=i,S.page.pathname=window.location.pathname;const a="get",c=r.find(s=>s.method.toLowerCase()===a&&e.find(u=>u.parser(o)&&u.pattern===s.path));if(c){const s=e.find(v=>v.parser(o)&&v.pattern===c.path),u=(s==null?void 0:s.parser(o))||{},l=new URLSearchParams(window.location.search),d=Object.fromEntries(l.entries())||{};S.page.params=u,S.page.query=d;const h={...u,...d},f=R[s==null?void 0:s.pattern];k(i,t,c,h,u,d,f,!1)}else console.log("No matching route found for popstate navigation to:",o,"- using fallback navigation"),window.location.href=o}),(function(){const n=history.pushState,o=history.replaceState;history.pushState=function(...i){const a=n.apply(this,i),c=new Event("pushstate");return c.state=i[0],c.url=i[2],window.dispatchEvent(c),a},history.replaceState=function(...i){const a=o.apply(this,i),c=i[2],s=window.location.pathname;if((c?new URL(c,window.location.origin).pathname:s)!==s){const l=new Event("replacestate");l.state=i[0],l.url=i[2],window.dispatchEvent(l)}return a}})(),window.addEventListener("pushstate",n=>{const o=n.url||window.location.pathname+window.location.search,i=o.split("?")[0],a="get",c=r.find(s=>s.method.toLowerCase()===a&&e.find(u=>u.parser(i)&&u.pattern===s.path));if(c){const s=e.find(v=>v.parser(i)&&v.pattern===c.path),u=s==null?void 0:s.parser(i),l=new URLSearchParams(o.split("?")[1]||""),d=Object.fromEntries(l.entries());S.page.url=o,S.page.pathname=window.location.pathname,Object.assign(S.page.params,u),Object.assign(S.page.query,d);const h={...u,...d},f=R[s==null?void 0:s.pattern];k(o,t,c,h,u,d,f,!1)}else console.log("No matching route found for pushstate to:",i,"- using fallback navigation"),window.location.href=i}),window.addEventListener("replacestate",n=>{const o=n.url||window.location.pathname+window.location.search,i=o.split("?")[0];S.page.url=o,S.page.pathname=window.location.pathname,S.page.query=Object.fromEntries(new URLSearchParams(o.split("?")[1]||""));const a="get",c=r.find(s=>s.method.toLowerCase()===a&&e.find(u=>u.parser(i)&&u.pattern===s.path));if(c){const s=e.find(v=>v.parser(i)&&v.pattern===c.path),u=(s==null?void 0:s.parser(i))||{},l=new URLSearchParams(o.split("?")[1]||""),d=Object.fromEntries(l.entries())||{},h={...u,...d},f=R[s==null?void 0:s.pattern];k(o,t,c,h,u,d,f,!1)}else console.log("No matching route found for replacestate to:",i,"- using fallback navigation"),window.location.href=i}),window.addEventListener("forge-redirect",(n=>{const o=n.detail.path,i=o.split("?")[0];console.log("[EVENTS] Handling forge-redirect to:",o);const a="get",c=r.find(s=>s.method.toLowerCase()===a&&e.find(u=>u.parser(i)&&u.pattern===s.path));if(c){const s=e.find(v=>v.parser(i)&&v.pattern===c.path),u=(s==null?void 0:s.parser(i))||{},l=new URLSearchParams(o.split("?")[1]||""),d=Object.fromEntries(l.entries())||{},h={...u,...d},f=R[s==null?void 0:s.pattern];k(o,t,c,h,u,d,f,!0)}else console.log("No matching route found for redirect to:",i,"- using fallback navigation"),window.location.href=i}))}const Gt=Symbol("forge-load-function");let H=[],Z=null;function Fe(t){try{const r=new URL(t,window.location.origin);return r.origin===window.location.origin&&!r.pathname.startsWith("/api/")}catch{return!t.startsWith("/api/")}}function $e(){typeof window<"u"&&!Z&&(Z=window.fetch,window.fetch=async function(t,r={}){let e={...r};for(const i of H)try{if(i.length===2){const a=new Headers(e.headers),c=Object.fromEntries(a.entries());await new Promise((s,u)=>{try{i(c,l=>{if(l)u(l);else{const d=new Headers;Object.entries(c).forEach(([h,f])=>{f!==void 0&&d.set(h,f)}),e.headers=d,s()}})}catch(l){u(l)}})}else{const a=await i(e,t);a&&typeof a=="object"&&(e=a)}}catch(a){throw console.error("🔴 Middleware error:",a),a}const n=e==null?void 0:e[Gt];console.log("[FETCH OVERRIDE] Request",{url:t,hasForgeSymbol:n,headers:e==null?void 0:e.headers});const o=await Z(t,e);if(console.log("[FETCH OVERRIDE] Response",{url:t,responseUrl:o.url,redirected:o.redirected,status:o.status,type:o.type,hasForgeSymbol:n}),n&&o.redirected){const i=typeof t=="string"?t:t.url,a=o.url;if(console.log("[FORGE REDIRECT] Detected redirect",{requested:i,final:a,redirected:o.redirected}),Fe(a)){const c=new URL(a),s=c.pathname+c.search;return console.log("[FORGE REDIRECT] Detected redirect to:",s,"- will navigate after current request completes"),new Response(JSON.stringify({layout:[],view:{}}),{status:200,headers:{"Content-Type":"application/json","X-Forge-Redirect":"true","X-Forge-Redirect-Path":s}})}}return o})}$e();const Ve={configUpdate(t){if(typeof t!="function")throw new Error("Middleware must be a function");H.push(t)},reset(){H.length=0},getMiddlewareCount(){return H.length}};let tt;async function Ge(t,r){let e=window.__COMPONENT_DIR__||r.component_dir;if(!e&&typeof e!="string")throw new Error("No component directory provided");let n=window.__ROUTING__;if(tt=Bt(n),window&&window.location){const o=(window.location.pathname||"/").split("?")[0],i=tt.find(c=>c.parser(o));let a=i?n.find(c=>c.path===i.pattern):null;if(i&&a){const c=i.parser(o)||{},s=new URLSearchParams(window.location.search),u=Object.fromEntries(s.entries())||{},l={...c,...u};$t(),Ft(t,e,a,l,c,u),Vt(e,n,tt)}else console.warn("No matching route found for:",o)}}exports.page=S.page;exports.shadowUrl=S.shadowUrl;exports.MANIFEST_STORE=R;exports.bootstrap_events=Vt;exports.createApp=Ge;exports.fetch=Ve;exports.loadRoute=Ft;exports.updateManifestStore=$t;exports.updateRoute=k;
4
4
  //# sourceMappingURL=client.cjs.map