ignotum 0.0.16 → 0.0.18

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 (126) hide show
  1. package/README.md +6 -6
  2. package/dist/cli/bin.mjs +13263 -2689
  3. package/dist/cli/bin.mjs.map +1 -1
  4. package/dist/platform/_headers +3 -0
  5. package/dist/platform/_ignotum/v1.0/client.js +12 -0
  6. package/dist/runtime/{api-B4fwp5a2.d.ts → api-BnUKx9cj-D49Tf0rX.d.ts} +4 -3
  7. package/dist/runtime/api-C-tltz6s.js +31 -0
  8. package/dist/runtime/api-C-tltz6s.js.map +1 -0
  9. package/dist/runtime/artifact-BB5qzoa6.js +42 -0
  10. package/dist/runtime/artifact-BB5qzoa6.js.map +1 -0
  11. package/dist/runtime/{bootstrap-BTFScKAc.d.ts → bootstrap-DjTwGJao-DBx5zdFI.d.ts} +64 -64
  12. package/dist/runtime/{bootstrap-BISQSn_O.js → bootstrap-DlNIfH-r.js} +9 -9
  13. package/dist/runtime/bootstrap-DlNIfH-r.js.map +1 -0
  14. package/dist/runtime/client.d.ts +24 -20
  15. package/dist/runtime/client.js +9 -9
  16. package/dist/runtime/client.js.map +1 -1
  17. package/dist/runtime/id-BI08JkmR.d.ts +1 -0
  18. package/dist/runtime/{id--1m0NuUL.js → id-BrEnxY-r.js} +118 -53
  19. package/dist/runtime/id-BrEnxY-r.js.map +1 -0
  20. package/dist/runtime/{image-Djtjy4Z8.js → image-gofzZeCm.js} +2 -2
  21. package/dist/runtime/image-gofzZeCm.js.map +1 -0
  22. package/dist/runtime/{index-D4seNHlX.d.ts → index-Biaw5vdF.d.ts} +2 -2
  23. package/dist/runtime/internal/api.d.ts +1 -1
  24. package/dist/runtime/internal/api.js +1 -30
  25. package/dist/runtime/internal/bootstrap.d.ts +1 -1
  26. package/dist/runtime/internal/bootstrap.js +1 -1
  27. package/dist/runtime/internal/client.d.ts +2 -2
  28. package/dist/runtime/internal/client.js +4 -4
  29. package/dist/runtime/internal/client.js.map +1 -1
  30. package/dist/runtime/internal/host.d.ts +4 -4
  31. package/dist/runtime/internal/host.js +4 -4
  32. package/dist/runtime/internal/routes.d.ts +1 -1
  33. package/dist/runtime/internal/routes.js +1 -1
  34. package/dist/runtime/internal/server.d.ts +3 -2
  35. package/dist/runtime/internal/server.js +2 -2
  36. package/dist/runtime/internal/server.js.map +1 -1
  37. package/dist/runtime/internal/types.d.ts +2 -2
  38. package/dist/runtime/internal/types.js +1 -1
  39. package/dist/runtime/{pagination-D3qd6s9N.js → pagination--f4kMKf6.js} +2 -2
  40. package/dist/runtime/{pagination-D3qd6s9N.js.map → pagination--f4kMKf6.js.map} +1 -1
  41. package/dist/runtime/pagination-BI08JkmR.d.ts +1 -0
  42. package/dist/runtime/{router-BSBI1oN1.js → router-C1eC9yy5.js} +462 -419
  43. package/dist/runtime/router-C1eC9yy5.js.map +1 -0
  44. package/dist/runtime/routes-DnU39R7c.js +152 -0
  45. package/dist/runtime/routes-DnU39R7c.js.map +1 -0
  46. package/dist/runtime/{schema-D1wOqiNH.js → schema-BSjepoNF.js} +271 -6
  47. package/dist/runtime/schema-BSjepoNF.js.map +1 -0
  48. package/dist/runtime/server.d.ts +5 -4
  49. package/dist/runtime/server.js +3 -3
  50. package/dist/runtime/server.js.map +1 -1
  51. package/dist/runtime/{sync-DzUwA8W9.js → sync-BwgS19Xy.js} +4 -16
  52. package/dist/runtime/sync-BwgS19Xy.js.map +1 -0
  53. package/dist/runtime/{sync-D-GK2sv9.d.ts → sync-By2hX5ev.d.ts} +1 -2
  54. package/dist/runtime/{types-DeCCyqLU-BIm7rU-0.d.ts → types-DeCCyqLU-CHx7KFtx.d.ts} +2 -2
  55. package/package.json +7 -1
  56. package/src/cli/agent-files.ts +2 -0
  57. package/src/cli/build/asset-names.ts +190 -0
  58. package/src/cli/build/managed-client.ts +151 -81
  59. package/src/cli/build/managed-server.ts +4 -4
  60. package/src/cli/build/managed.ts +5 -6
  61. package/src/cli/command.ts +7 -15
  62. package/src/cli/control-client.ts +7 -9
  63. package/src/cli/deploy.ts +45 -15
  64. package/src/cli/dev.ts +50 -99
  65. package/src/cli/image-assets.ts +5 -2
  66. package/src/cli/managed-client-boundaries.ts +6 -6
  67. package/src/cli/managed-dev-platform.ts +52 -66
  68. package/src/cli/managed-exports.ts +5 -66
  69. package/src/cli/new-app.ts +7 -2
  70. package/src/cli/path.ts +11 -0
  71. package/src/cli/route-codegen.ts +2 -1
  72. package/src/cli/route-static.ts +3 -2
  73. package/src/cli/upload-journal.ts +130 -0
  74. package/src/client/bootstrap.ts +1 -110
  75. package/src/client/errors.ts +1 -70
  76. package/src/client/files.ts +1 -233
  77. package/src/client/hooks.ts +1 -367
  78. package/src/client/id.ts +1 -263
  79. package/src/client/image.ts +1 -28
  80. package/src/client/index.ts +1 -126
  81. package/src/client/jsx-dev-runtime.ts +1 -2
  82. package/src/client/jsx-runtime.ts +1 -2
  83. package/src/client/managed-client.ts +1 -729
  84. package/src/client/managed-upgrade.ts +1 -283
  85. package/src/client/page-observers.ts +1 -77
  86. package/src/client/query.ts +1 -17
  87. package/src/client/recovery-journal.ts +1 -195
  88. package/src/client/route-boundaries.ts +1 -184
  89. package/src/client/router-history.ts +1 -152
  90. package/src/client/router-store.ts +1 -644
  91. package/src/client/router.ts +1 -324
  92. package/src/client/routes.ts +1 -28
  93. package/src/client/sync.ts +1 -286
  94. package/src/dev-runtime/id.ts +1 -1
  95. package/src/dev-runtime/managed-functions.ts +10 -18
  96. package/src/dev-runtime/managed-sync.ts +16 -16
  97. package/src/dev-runtime/sync.ts +6 -4
  98. package/src/internal/api.ts +1 -156
  99. package/src/internal/client.ts +1 -186
  100. package/src/internal/host.ts +1 -1
  101. package/src/internal/http-paths.ts +1 -4
  102. package/src/internal/routes.ts +1 -45
  103. package/src/internal/server.ts +1 -3
  104. package/src/internal/types.ts +1 -2
  105. package/src/server/index.ts +1 -27
  106. package/dist/cli/managed-release-WHYLZwaS.mjs +0 -10902
  107. package/dist/cli/managed-release-WHYLZwaS.mjs.map +0 -1
  108. package/dist/cli/managed-release.d.mts +0 -1
  109. package/dist/cli/managed-release.mjs +0 -14
  110. package/dist/cli/managed-release.mjs.map +0 -1
  111. package/dist/runtime/bootstrap-BISQSn_O.js.map +0 -1
  112. package/dist/runtime/descriptor-CTY4mtwS-cS43EbwS.js +0 -269
  113. package/dist/runtime/descriptor-CTY4mtwS-cS43EbwS.js.map +0 -1
  114. package/dist/runtime/id--1m0NuUL.js.map +0 -1
  115. package/dist/runtime/id-CBOt2kDo.d.ts +0 -1
  116. package/dist/runtime/identity-QjtJRxBD.d.ts +0 -2
  117. package/dist/runtime/image-Djtjy4Z8.js.map +0 -1
  118. package/dist/runtime/internal/api.js.map +0 -1
  119. package/dist/runtime/pagination-CBOt2kDo.d.ts +0 -1
  120. package/dist/runtime/router-BSBI1oN1.js.map +0 -1
  121. package/dist/runtime/routes-Ce8TVP-T.js +0 -690
  122. package/dist/runtime/routes-Ce8TVP-T.js.map +0 -1
  123. package/dist/runtime/schema-D1wOqiNH.js.map +0 -1
  124. package/dist/runtime/sync-DzUwA8W9.js.map +0 -1
  125. package/src/cli/managed-release-bin.ts +0 -13
  126. package/src/cli/managed-release.ts +0 -260
@@ -0,0 +1,12 @@
1
+ var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r},n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v={},y=[],b=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,ee=Array.isArray;function x(e,t){for(var n in t)e[n]=t[n];return e}function te(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function S(e,t,r){var i,a,o,s={};for(o in t)o==`key`?i=t[o]:o==`ref`?a=t[o]:s[o]=t[o];if(arguments.length>2&&(s.children=arguments.length>3?n.call(arguments,2):r),typeof e==`function`&&e.defaultProps!=null)for(o in e.defaultProps)s[o]===void 0&&(s[o]=e.defaultProps[o]);return ne(e,s,i,a,null)}function ne(e,t,n,a,o){var s={type:e,props:t,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++i,__i:-1,__u:0};return o==null&&r.vnode!=null&&r.vnode(s),s}function re(){return{current:null}}function ie(e){return e.children}function ae(e,t){this.props=e,this.context=t}function oe(e,t){if(t==null)return e.__?oe(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==`function`?oe(e):null}function se(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,i=[],a=[],o=x({},t);o.__v=t.__v+1,r.vnode&&r.vnode(o),ye(e.__P,o,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,i,n??oe(t),!!(32&t.__u),a),o.__v=t.__v,o.__.__k[o.__i]=o,xe(i,o,a),t.__e=t.__=null,o.__e!=n&&ce(o)}}function ce(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),ce(e)}function le(e){(!e.__d&&(e.__d=!0)&&o.push(e)&&!ue.__r++||s!=r.debounceRendering)&&((s=r.debounceRendering)||c)(ue)}function ue(){try{for(var e,t=1;o.length;)o.length>t&&o.sort(l),e=o.shift(),t=o.length,se(e)}finally{o.length=ue.__r=0}}function de(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,_=r&&r.__k||y,b=t.length;for(c=fe(n,t,_,c,b),d=0;d<b;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&_[p.__i]||v,p.__i=d,g=ye(e,p,f,i,a,o,s,c,l,u),m=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&we(f.ref,null,p),u.push(p.ref,p.__c||m,p)),h==null&&m!=null&&(h=m),4&p.__u?(c=pe(p,c,e),f.__e&&(f.__e=null)):typeof p.type==`function`&&g!==void 0?c=g:m&&(c=m.nextSibling),p.__u&=-7);return n.__e=h,c}function fe(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?o=e.__k[a]=ne(null,o,null,null,null):ee(o)?o=e.__k[a]=ne(ie,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=ne(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=he(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=oe(s)),Te(s,s));return r}function pe(e,t,n){var r,i;if(typeof e.type==`function`){for(r=e.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=e,t=pe(r[i],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=oe(e)),t=n.insertBefore(e.__e,t||null));do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function me(e,t){return t||=[],e==null||typeof e==`boolean`||(ee(e)?e.some(function(e){me(e,t)}):t.push(e)),t}function he(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&!(2&l.__u);if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function ge(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||b.test(t)?n:n+`px`}function _e(e,t,n,r,i){var a,o;n:if(t==`style`){if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||ge(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||ge(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(p,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||={},e.l[t+a]=n,n?r?n[f]=r[f]:(n[f]=m,e.addEventListener(t,a?g:h,a)):e.removeEventListener(t,a?g:h,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function ve(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[d]==null)t[d]=m++;else if(t[d]<n[f])return;return n(r.event?r.event(t):t)}}}function ye(e,t,n,i,a,o,s,c,l,u){var d,f,p,m,h,g,_,v,b,S,ne,re,se,ce,le,ue,fe=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(l=!!(32&n.__u),o=[c=t.__e=n.__e]),(d=r.__b)&&d(t);n:if(typeof fe==`function`){f=s.length;try{if(b=t.props,S=fe.prototype&&fe.prototype.render,ne=(d=fe.contextType)&&i[d.__c],re=d?ne?ne.props.value:d.__:i,n.__c?v=(p=t.__c=n.__c).__=p.__E:(S?t.__c=p=new fe(b,re):(t.__c=p=new ae(b,re),p.constructor=fe,p.render=Ee),ne&&ne.sub(p),p.state||(p.state={}),p.__n=i,m=p.__d=!0,p.__h=[],p._sb=[]),S&&p.__s==null&&(p.__s=p.state),S&&fe.getDerivedStateFromProps!=null&&(p.__s==p.state&&(p.__s=x({},p.__s)),x(p.__s,fe.getDerivedStateFromProps(b,p.__s))),h=p.props,g=p.state,p.__v=t,m)S&&fe.getDerivedStateFromProps==null&&p.componentWillMount!=null&&p.componentWillMount(),S&&p.componentDidMount!=null&&p.__h.push(p.componentDidMount);else{if(S&&fe.getDerivedStateFromProps==null&&b!==h&&p.componentWillReceiveProps!=null&&p.componentWillReceiveProps(b,re),t.__v==n.__v||!p.__e&&p.shouldComponentUpdate!=null&&!1===p.shouldComponentUpdate(b,p.__s,re)){t.__v!=n.__v&&(p.props=b,p.state=p.__s,p.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),y.push.apply(p.__h,p._sb),p._sb=[],p.__h.length&&s.push(p),c=oe(n);break n}p.componentWillUpdate!=null&&p.componentWillUpdate(b,p.__s,re),S&&p.componentDidUpdate!=null&&p.__h.push(function(){p.componentDidUpdate(h,g,_)})}if(p.context=re,p.props=b,p.__P=e,p.__e=!1,se=r.__r,ce=0,S)p.state=p.__s,p.__d=!1,se&&se(t),d=p.render(p.props,p.state,p.context),y.push.apply(p.__h,p._sb),p._sb=[];else do p.__d=!1,se&&se(t),d=p.render(p.props,p.state,p.context),p.state=p.__s;while(p.__d&&++ce<25);p.state=p.__s,p.getChildContext!=null&&(i=x(x({},i),p.getChildContext())),S&&!m&&p.getSnapshotBeforeUpdate!=null&&(_=p.getSnapshotBeforeUpdate(h,g)),le=d!=null&&d.type===ie&&d.key==null?Se(d.props.children):d,c=de(e,ee(le)?le:[le],t,n,i,a,o,s,c,l,u),p.base=t.__e,t.__u&=-161,p.__h.length&&s.push(p),v&&(p.__E=p.__=null)}catch(e){if(s.length=f,t.__v=null,l||o!=null){if(e.then){for(t.__u|=l?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;o!=null&&(o[o.indexOf(c)]=null),t.__e=c}else if(o!=null)for(ue=o.length;ue--;)te(o[ue])}else t.__e=n.__e;t.__k??=n.__k||[],e.then||be(t),r.__e(e,t,n)}}else o==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):c=t.__e=Ce(n.__e,t,n,i,a,o,s,l,u);return(d=r.diffed)&&d(t),128&t.__u?void 0:c}function be(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(be))}function xe(e,t,n){for(var i=0;i<n.length;i++)we(n[i],n[++i],n[++i]);r.__c&&r.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){r.__e(e,t.__v)}})}function Se(e){return typeof e!=`object`||!e||e.__b>0?e:ee(e)?e.map(Se):e.constructor===void 0?x({},e):null}function Ce(e,t,i,a,o,s,c,l,u){var d,f,p,m,h,g,_,y=i.props||v,b=t.props,x=t.type;if(x==`svg`?o=`http://www.w3.org/2000/svg`:x==`math`?o=`http://www.w3.org/1998/Math/MathML`:o||=`http://www.w3.org/1999/xhtml`,s!=null){for(d=0;d<s.length;d++)if((h=s[d])&&`setAttribute`in h==!!x&&(x?h.localName==x:h.nodeType==3)){e=h,s[d]=null;break}}if(e==null){if(x==null)return document.createTextNode(b);e=document.createElementNS(o,x,b.is&&b),l&&=(r.__m&&r.__m(t,s),!1),s=null}if(x==null)y===b||l&&e.data==b||(e.data=b);else{if(s=x==`textarea`&&b.defaultValue!=null?null:s&&n.call(e.childNodes),!l&&s!=null)for(y={},d=0;d<e.attributes.length;d++)y[(h=e.attributes[d]).name]=h.value;for(d in y)h=y[d],d==`dangerouslySetInnerHTML`?p=h:d==`children`||d in b||d==`value`&&`defaultValue`in b||d==`checked`&&`defaultChecked`in b||_e(e,d,null,h,o);for(d in b)h=b[d],d==`children`?m=h:d==`dangerouslySetInnerHTML`?f=h:d==`value`?g=h:d==`checked`?_=h:l&&typeof h!=`function`||y[d]===h||_e(e,d,h,y[d],o);if(f)l||p&&(f.__html==p.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),t.__k=[];else if(p&&(e.innerHTML=``),de(t.type==`template`?e.content:e,ee(m)?m:[m],t,i,a,x==`foreignObject`?`http://www.w3.org/1999/xhtml`:o,s,c,s?s[0]:i.__k&&oe(i,0),l,u),s!=null)for(d=s.length;d--;)te(s[d]);l&&x!=`textarea`||(d=`value`,x==`progress`&&g==null?e.removeAttribute(`value`):g!=null&&(g!==e[d]||x==`progress`&&!g||x==`option`&&g!=y[d])&&_e(e,d,g,y[d],o),d=`checked`,_!=null&&_!=e[d]&&_e(e,d,_,y[d],o))}return e}function we(e,t,n){try{if(typeof e==`function`){var i=typeof e.__u==`function`;i&&e.__u(),i&&t==null||(e.__u=e(t))}else e.current=t}catch(e){r.__e(e,n)}}function Te(e,t,n){var i,a;if(r.unmount&&r.unmount(e),(i=e.ref)&&(i.current&&i.current!=e.__e||we(i,null,t)),(i=e.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(e){r.__e(e,t)}i.base=i.__P=i.__n=null}if(i=e.__k)for(a=0;a<i.length;a++)i[a]&&Te(i[a],t,n||typeof e.type!=`function`);n||te(e.__e),e.__c=e.__=e.__e=void 0}function Ee(e,t,n){return this.constructor(e,n)}function De(e,t,i){var a,o,s,c;t==document&&(t=document.documentElement),r.__&&r.__(e,t),o=(a=typeof i==`function`)?null:i&&i.__k||t.__k,s=[],c=[],ye(t,e=(!a&&i||t).__k=S(ie,null,[e]),o||v,v,t.namespaceURI,!a&&i?[i]:o?null:t.firstChild?n.call(t.childNodes):null,s,!a&&i?i:o?o.__e:t.firstChild,a,c),xe(s,e,c),e.props.children=null}function Oe(e,t,r){var i,a,o,s,c=x({},e.props);for(o in e.type&&e.type.defaultProps&&(s=e.type.defaultProps),t)o==`key`?i=t[o]:o==`ref`?a=t[o]:c[o]=t[o]===void 0&&s!=null?s[o]:t[o];return arguments.length>2&&(c.children=arguments.length>3?n.call(arguments,2):r),ne(e.type,c,i||e.key,a||e.ref,null)}function ke(e){function t(e){var n,r;return this.getChildContext||(n=new Set,(r={})[t.__c]=this,this.getChildContext=function(){return r},this.componentWillUnmount=function(){n=null},this.shouldComponentUpdate=function(e){this.props.value!=e.value&&n.forEach(function(e){e.__e=!0,le(e)})},this.sub=function(e){n.add(e);var t=e.componentWillUnmount;e.componentWillUnmount=function(){n&&n.delete(e),t&&t.call(e)}}),e.children}return t.__c=`__cC`+_++,t.__=e,t.Provider=t.__l=(t.Consumer=function(e,t){return e.children(t)}).contextType=t,t}n=y.slice,r={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(t){e=t}throw e}},i=0,a=function(e){return e!=null&&e.constructor===void 0},ae.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=x({},this.state);typeof e==`function`&&(e=e(x({},n),this.props)),e&&x(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),le(this))},ae.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),le(this))},ae.prototype.render=ie,o=[],c=typeof Promise==`function`?Promise.prototype.then.bind(Promise.resolve()):setTimeout,l=function(e,t){return e.__v.__b-t.__v.__b},ue.__r=0,u=Math.random().toString(8),d=`__d`+u,f=`__a`+u,p=/(PointerCapture)$|Capture$/i,m=0,h=ve(!1),g=ve(!0),_=0;var Ae,C,je,Me,Ne=0,Pe=[],w=r,Fe=w.__b,Ie=w.__r,Le=w.diffed,Re=w.__c,ze=w.unmount,Be=w.__;function Ve(e,t){w.__h&&w.__h(C,e,Ne||t),Ne=0;var n=C.__H||(C.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function He(e){return Ne=1,Ue(ot,e)}function Ue(e,t,n){var r=Ve(Ae++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):ot(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=C,!C.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=!1,o=r.__c.props!==e;if(r.__c.__H.__.some(function(e){if(e.__N){i=!0;var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),a){var s=a.call(this,e,t,n);return i?s||o:s}return!i||o};C.__f=!0;var a=C.shouldComponentUpdate,o=C.componentWillUpdate;C.componentWillUpdate=function(e,t,n){if(this.__e){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},C.shouldComponentUpdate=i}return r.__N||r.__}function We(e,t){var n=Ve(Ae++,3);!w.__s&&at(n.__H,t)&&(n.__=e,n.u=t,C.__H.__h.push(n))}function Ge(e,t){var n=Ve(Ae++,4);!w.__s&&at(n.__H,t)&&(n.__=e,n.u=t,C.__h.push(n))}function Ke(e){return Ne=5,Je(function(){return{current:e}},[])}function qe(e,t,n){Ne=6,Ge(function(){if(typeof e==`function`){var n=e(t());return function(){e(null),n&&typeof n==`function`&&n()}}if(e)return e.current=t(),function(){return e.current=null}},n==null?n:n.concat(e))}function Je(e,t){var n=Ve(Ae++,7);return at(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Ye(e,t){return Ne=8,Je(function(){return e},t)}function Xe(e){var t=C.context[e.__c],n=Ve(Ae++,9);return n.c=e,t?(n.__??(n.__=!0,t.sub(C)),t.props.value):e.__}function Ze(e,t){w.useDebugValue&&w.useDebugValue(t?t(e):e)}function Qe(e){var t=Ve(Ae++,10),n=He();return t.__=e,C.componentDidCatch||(C.componentDidCatch=function(e,r){t.__&&t.__(e,r),n[1](e)}),[n[0],function(){n[1](void 0)}]}function $e(){var e=Ve(Ae++,11);if(!e.__){for(var t=C.__v;t!==null&&!t.__m&&t.__!==null;)t=t.__;var n=t.__m||(t.__m=[0,0]);e.__=`P`+n[0]+`-`+n[1]++}return e.__}function et(){for(var e;e=Pe.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(rt),t.__h.some(it),t.__h=[]}catch(n){t.__h=[],w.__e(n,e.__v)}}}w.__b=function(e){C=null,Fe&&Fe(e)},w.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Be&&Be(e,t)},w.__r=function(e){Ie&&Ie(e),Ae=0;var t=(C=e.__c).__H;t&&(je===C?(t.__h=[],C.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(rt),t.__h.some(it),t.__h=[],Ae=0)),je=C},w.diffed=function(e){Le&&Le(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Pe.push(t)!==1&&Me===w.requestAnimationFrame||((Me=w.requestAnimationFrame)||nt)(et)),t.__H.__.some(function(e){e.u&&=(e.__H=e.u,void 0)})),je=C=null},w.__c=function(e,t){t.some(function(e){try{e.__h.some(rt),e.__h=e.__h.filter(function(e){return!e.__||it(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],w.__e(n,e.__v)}}),Re&&Re(e,t)},w.unmount=function(e){ze&&ze(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{rt(e)}catch(e){t=e}}),n.__H=void 0,t&&w.__e(t,n.__v))};var tt=typeof requestAnimationFrame==`function`;function nt(e){var t,n=function(){clearTimeout(r),tt&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);tt&&(t=requestAnimationFrame(n))}function rt(e){var t=C,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),C=t}function it(e){var t=C;e.__c=e.__(),C=t}function at(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function ot(e,t){return typeof t==`function`?t(e):t}var st=(e,t)=>{switch(t.length){case 0:return e;case 1:return t[0](e);case 2:return t[1](t[0](e));case 3:return t[2](t[1](t[0](e)));case 4:return t[3](t[2](t[1](t[0](e))));case 5:return t[4](t[3](t[2](t[1](t[0](e)))));case 6:return t[5](t[4](t[3](t[2](t[1](t[0](e))))));case 7:return t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))));case 8:return t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e))))))));case 9:return t[8](t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))))));default:{let n=e;for(let e=0,r=t.length;e<r;e++)n=t[e](n);return n}}},ct={pipe(){return st(this,arguments)}},lt=function(){function e(){}return e.prototype=ct,e}(),T=function(e,t){if(typeof e==`function`)return function(){return e(arguments)?t.apply(this,arguments):e=>t(e,...arguments)};switch(e){case 0:case 1:throw RangeError(`Invalid arity ${e}`);case 2:return function(e,n){return arguments.length>=2?t(e,n):function(n){return t(n,e)}};case 3:return function(e,n,r){return arguments.length>=3?t(e,n,r):function(r){return t(r,e,n)}};default:return function(){if(arguments.length>=e)return t.apply(this,arguments);let n=arguments;return function(e){return t(e,...n)}}}},E=e=>e,ut=e=>()=>e,dt=ut(!0),ft=ut(!1),pt=ut(void 0),mt=pt;function ht(e){let t=new WeakMap;return n=>{let r=t.get(n);if(r!==void 0)return r;let i=e(n);return t.set(n,i),i}}function gt(e){let t=new WeakMap;return n=>{let r=t.get(n);if(r!==void 0)return r;let i=e(n);return t.set(n,i),t.set(i,i),i}}var _t=e=>{let t=new Set(Reflect.ownKeys(e));if(e.constructor===Object)return t;e instanceof Error&&t.delete(`stack`);let n=Object.getPrototypeOf(e),r=n;for(;r!==null&&r!==Object.prototype;){let e=Reflect.ownKeys(r);for(let n=0;n<e.length;n++)t.add(e[n]);r=Object.getPrototypeOf(r)}return t.has(`constructor`)&&typeof e.constructor==`function`&&n===e.constructor.prototype&&t.delete(`constructor`),t},vt=new WeakSet;function yt(e){return typeof e==`string`}function bt(e){return typeof e==`number`}function xt(e){return typeof e==`boolean`}function St(e){return typeof e==`symbol`}function Ct(e){return yt(e)||bt(e)||St(e)}function wt(e){return typeof e==`function`}function Tt(e){return e!==void 0}function Et(e){return e===null}function Dt(e){return e!=null}function Ot(e){return!0}function kt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function At(e){return typeof e==`object`&&!!e||wt(e)}var D=T(2,(e,t)=>At(e)&&t in e);function jt(e){return e instanceof Error}function Mt(e){return e instanceof Date}var Nt=`~effect/interfaces/Hash`,O=e=>{switch(typeof e){case`number`:return Rt(e);case`bigint`:return zt(e.toString(10));case`boolean`:return zt(String(e));case`symbol`:return zt(String(e));case`string`:return zt(e);case`undefined`:return zt(`undefined`);case`function`:case`object`:if(e===null)return zt(`null`);if(e instanceof Date)return Number.isNaN(e.getTime())?zt(`Invalid Date`):zt(e.toISOString());if(e instanceof RegExp)return zt(e.toString());{if(vt.has(e))return Pt(e);if(qt.has(e))return qt.get(e);let t=Yt(e,()=>Lt(e)?e[Nt]():typeof e==`function`?Pt(e):e instanceof DataView?Ut(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)):Array.isArray(e)||ArrayBuffer.isView(e)?Ut(e):e instanceof Map?Wt(e):e instanceof Set?Gt(e):Vt(e));return qt.set(e,t),t}default:throw Error(`BUG: unhandled typeof ${typeof e} - please report an issue at https://github.com/Effect-TS/effect/issues`)}},Pt=e=>(Kt.has(e)||Kt.set(e,Rt(Math.floor(Math.random()*(2**53-1)))),Kt.get(e)),Ft=T(2,(e,t)=>e*53^t),It=e=>e&3221225471|e>>>1&1073741824,Lt=e=>D(e,Nt),Rt=e=>{if(e!==e)return zt(`NaN`);if(e===1/0)return zt(`Infinity`);if(e===-1/0)return zt(`-Infinity`);let t=e|0;for(t!==e&&(t^=e*4294967295);e>4294967295;)t^=e/=4294967295;return It(t)},zt=e=>{let t=5381,n=e.length;for(;n;)t=t*33^e.charCodeAt(--n);return It(t)},Bt=(e,t)=>{let n=12289;for(let r of t)n^=Ft(O(r),O(e[r]));return It(n)},Vt=e=>Bt(e,_t(e)),Ht=(e,t)=>n=>{let r=e;for(let e of n)r^=t(e);return It(r)},Ut=Ht(6151,O),Wt=Ht(zt(`Map`),([e,t])=>Ft(O(e),O(t))),Gt=Ht(zt(`Set`),O),Kt=new WeakMap,qt=new WeakMap,Jt=new WeakSet;function Yt(e,t){if(Jt.has(e))return zt(`[Circular]`);Jt.add(e);let n=t();return Jt.delete(e),n}var Xt=`~effect/interfaces/Equal`;function Zt(){return arguments.length===1?e=>Qt(e,arguments[0]):Qt(arguments[0],arguments[1])}function Qt(e,t){if(e===t)return!0;if(e==null||t==null)return!1;let n=typeof e;return n===typeof t?n===`number`&&e!==e&&t!==t?!0:n!==`object`&&n!==`function`||vt.has(e)||vt.has(t)?!1:rn(e,t,nn):!1}function $t(e,t,n){let r=en.has(e),i=tn.has(t);if(r&&i)return!0;if(r||i)return!1;en.add(e),tn.add(t);let a=n();return en.delete(e),tn.delete(t),a}var en=new WeakSet,tn=new WeakSet;function nn(e,t){if(O(e)!==O(t))return!1;if(e instanceof Date){if(!(t instanceof Date))return!1;let n=e.getTime(),r=t.getTime();return n===r||Number.isNaN(n)&&Number.isNaN(r)}if(e instanceof RegExp)return t instanceof RegExp&&e.toString()===t.toString();let n=pn(e),r=pn(t);if(n!==r)return!1;let i=n&&r;return typeof e==`function`&&!i?!1:$t(e,t,()=>{if(i)return e[Xt](t);if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:on(e,t);if(ArrayBuffer.isView(e)){let n=e instanceof DataView;if(!ArrayBuffer.isView(t)||e.byteLength!==t.byteLength||n!==t instanceof DataView)return!1;if(n){let n=t;return sn(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(n.buffer,n.byteOffset,n.byteLength))}return sn(e,t)}return e instanceof Map?!(t instanceof Map)||e.size!==t.size?!1:un(e,t):e instanceof Set?!(t instanceof Set)||e.size!==t.size?!1:fn(e,t):cn(e,t)})}function rn(e,t,n){let r=an.get(e);if(!r)r=new WeakMap,an.set(e,r);else if(r.has(t))return r.get(t);let i=n(e,t);r.set(t,i);let a=an.get(t);return a||(a=new WeakMap,an.set(t,a)),a.set(e,i),i}var an=new WeakMap;function on(e,t){for(let n=0;n<e.length;n++)if(!Qt(e[n],t[n]))return!1;return!0}function sn(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function cn(e,t){let n=_t(e),r=_t(t);if(n.size!==r.size)return!1;for(let i of n)if(!r.has(i)||!Qt(e[i],t[i]))return!1;return!0}function ln(e,t){return function(n,r){let i=Array.from(r);for(let[r,a]of n){let n=!1;for(let o=0;o<i.length;o++){let[s,c]=i[o];if(e(r,s)&&t(a,c)){i[o]=i[i.length-1],i.pop(),n=!0;break}}if(!n)return!1}return!0}}var un=ln(Qt,Qt);function dn(e){return function(t,n){let r=Array.from(n);for(let n of t){let t=!1;for(let i=0;i<r.length;i++){let a=r[i];if(e(n,a)){r[i]=r[r.length-1],r.pop(),t=!0;break}}if(!t)return!1}return!0}}var fn=dn(Qt),pn=e=>D(e,Xt),mn=e=>(t,n)=>t===n||e(t,n),hn=(e,t)=>e===t,gn=()=>hn;function _n(e){return mn((t,n)=>{if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(!e[r](t[r],n[r]))return!1;return!0})}function vn(e){return mn((t,n)=>{if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(!e(t[r],n[r]))return!1;return!0})}var yn=e=>e.length>0;function bn(e,t,n){t===`__proto__`?Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0}):e[t]=n}function xn(e,t){for(let n of Reflect.ownKeys(t))Object.prototype.propertyIsEnumerable.call(t,n)&&bn(e,n,t[n])}var Sn=Symbol.for(`~effect/Redactable`),Cn=e=>D(e,Sn);function wn(e){return Cn(e)?Tn(e):e}function Tn(e){return e[Sn](globalThis[`~effect/Fiber/currentFiber`]?.context??On)}var En=`~effect/Fiber/currentFiber`,Dn=new Map,On={"~effect/Context":{},base:Dn,depth:0,mapUnsafe:Dn,pipe(){return st(this,arguments)}};function k(e,t){let n=t?.space??0,r=new WeakSet,i=n?typeof n==`number`?` `.repeat(n):n:``,a=e=>i.repeat(e),o=(e,t)=>{let n=e?.constructor;return n&&n!==Object.prototype.constructor&&n.name?`${n.name}(${t})`:t},s=e=>{try{return Reflect.ownKeys(e)}catch{return[`[ownKeys threw]`]}};function c(e,n=0){if(typeof e==`string`)return JSON.stringify(e);if(typeof e==`number`||e==null||typeof e==`boolean`||typeof e==`symbol`)return String(e);if(typeof e==`bigint`)return String(e)+`n`;if(typeof e==`object`||typeof e==`function`){if(r.has(e))return kn;r.add(e);let l;if(Sn in e)l=c(Tn(e),n);else if(Array.isArray(e))l=!i||e.length<=1?`[${e.map(e=>c(e,n)).join(`,`)}]`:`[\n${a(n+1)}${e.map(e=>c(e,n+1)).join(`,
2
+ `+a(n+1))}\n${a(n)}]`;else if(e instanceof Date)l=Mn(e);else if(!t?.ignoreToString&&D(e,`toString`)&&typeof e.toString==`function`&&e.toString!==Object.prototype.toString&&e.toString!==Array.prototype.toString){let t=Nn(e);l=e instanceof Error&&e.cause?`${t} (cause: ${c(e.cause,n)})`:t}else if(Symbol.iterator in e)l=`${e.constructor.name}(${c(Array.from(e),n)})`;else{let t=s(e);if(!i||t.length<=1){let r=`{${t.map(t=>`${An(t)}:${c(e[t],n)}`).join(`,`)}}`;l=o(e,r)}else{let r=`{\n${t.map(t=>`${a(n+1)}${An(t)}: ${c(e[t],n+1)}`).join(`,
3
+ `)}\n${a(n)}}`;l=o(e,r)}}return r.delete(e),l}return String(e)}return c(e,0)}var kn=`[Circular]`;function An(e){return typeof e==`string`?JSON.stringify(e):String(e)}function jn(e){return e.map(e=>`[${An(e)}]`).join(``)}function Mn(e){try{return e.toISOString()}catch{return`Invalid Date`}}function Nn(e){try{let t=e.toString();return typeof t==`string`?t:String(t)}catch{return`[toString threw]`}}function Pn(e,t){let n=[];return JSON.stringify(e,function(e,t){let r=Object.getOwnPropertyDescriptor(this,e)?.value,i=D(r,Sn)?wn(r):wn(t);if(typeof i==`bigint`)return k(i);if(typeof i!=`object`||!i)return i;for(;n.length>0&&n[n.length-1]!==this;)n.pop();if(!n.includes(i))return n.push(i),i},t?.space)??`null`}var Fn=Symbol.for(`nodejs.util.inspect.custom`),In=e=>{try{return e=wn(e),D(e,`toJSON`)&&wt(e.toJSON)&&e.toJSON.length===0?e.toJSON():Array.isArray(e)?e.map(In):e}catch{return`[toJSON threw]`}},Ln={toJSON(){return In(this)},[Fn](){return this.toJSON()},toString(){return k(this.toJSON())}},Rn=class{[Fn](){return this.toJSON()}toString(){return k(this.toJSON())}},zn=class e{called=!1;self;constructor(e){this.self=e}next(e){return this.called?{value:e,done:!0}:(this.called=!0,{value:this.self,done:!1})}[Symbol.iterator](){return new e(this.self)}},Bn=(()=>{let e=`~effect/Utils/internal`,t={[e]:e=>e()},n={[e]:e=>{try{return e()}finally{}}};return t[e](()=>Error().stack)?.includes(e)===!0?t[e]:n[e]})(),Vn=`~effect/Effect`,Hn=`~effect/Exit`,Un={_A:E,_E:E,_R:E},Wn=`${Vn}/identifier`,A=`${Vn}/args`,Gn=`${Vn}/evaluate`,Kn=`${Vn}/successCont`,qn=`${Vn}/failureCont`,Jn=`${Vn}/ensureCont`,Yn=Symbol.for(`effect/Effect/Yield`),Xn={pipe(){return st(this,arguments)},toJSON(){return{...this}},toString(){return k(this.toJSON(),{ignoreToString:!0,space:2})},[Fn](){return this.toJSON()}},Zn={[Vn]:Un,...Xn,[Symbol.iterator](){return new zn(this)},toJSON(){return{_id:`Effect`,op:this[Wn],...A in this?{args:this[A]}:void 0}}},Qn=e=>D(e,Vn),$n=e=>D(e,Hn),er=`~effect/Cause`,tr=`~effect/Cause/Reason`,nr=e=>D(e,er),rr=class{[er];reasons;constructor(e){this[er]=er,this.reasons=e}pipe(){return st(this,arguments)}toJSON(){return{_id:`Cause`,failures:this.reasons.map(e=>e.toJSON())}}toString(){return`Cause(${k(this.reasons)})`}[Fn](){return this.toJSON()}[Xt](e){return nr(e)&&this.reasons.length===e.reasons.length&&this.reasons.every((t,n)=>Zt(t,e.reasons[n]))}[Nt](){return Ut(this.reasons)}},ir=new WeakMap,ar=class{[tr];annotations;_tag;constructor(e,t,n){if(this[tr]=tr,this._tag=e,t!==or&&typeof n==`object`&&n&&t.size>0){let e=ir.get(n);e&&(t=new Map([...e,...t])),ir.set(n,t)}this.annotations=t}annotate(e,t){if(e.mapUnsafe.size===0)return this;let n=new Map(this.annotations);e.mapUnsafe.forEach((e,r)=>{t?.overwrite!==!0&&n.has(r)||n.set(r,e)});let r=Object.assign(Object.create(Object.getPrototypeOf(this)),this);return r.annotations=n,r}pipe(){return st(this,arguments)}toString(){return k(this)}[Fn](){return this.toString()}},or=new Map,sr=class extends ar{error;constructor(e,t=or){super(`Fail`,t,e),this.error=e}toString(){return`Fail(${k(this.error)})`}toJSON(){return{_tag:`Fail`,error:this.error}}[Xt](e){return pr(e)&&Zt(this.error,e.error)&&Zt(this.annotations,e.annotations)}[Nt](){return Ft(zt(this._tag))(Ft(O(this.error))(O(this.annotations)))}},cr=e=>new rr(e),lr=e=>new rr([new sr(e)]),ur=class extends ar{defect;constructor(e,t=or){super(`Die`,t,e),this.defect=e}toString(){return`Die(${k(this.defect)})`}toJSON(){return{_tag:`Die`,defect:this.defect}}[Xt](e){return mr(e)&&Zt(this.defect,e.defect)&&Zt(this.annotations,e.annotations)}[Nt](){return Ft(zt(this._tag))(Ft(O(this.defect))(O(this.annotations)))}},dr=e=>new rr([new ur(e)]),fr=T(e=>nr(e[0]),(e,t,n)=>t.mapUnsafe.size===0?e:new rr(e.reasons.map(e=>e.annotate(t,n)))),pr=e=>e._tag===`Fail`,mr=e=>e._tag===`Die`,hr=e=>e._tag===`Interrupt`;function gr(e){return Tr(`Effect.evaluate: Not implemented`)}var _r=e=>({...Zn,[Wn]:e.op,[Gn]:e[Gn]??gr,[Kn]:e[Kn],[qn]:e[qn],[Jn]:e[Jn]}),vr=e=>{let t=_r(e);return function(){let n=Object.create(t);return n[A]=e.single===!1?arguments:arguments[0],n}},yr=e=>{let t={[Hn]:Hn,_tag:e.op,get[e.prop](){return this[A]},..._r(e),toString(){return`${e.op}(${k(this[A])})`},toJSON(){return{_id:`Exit`,_tag:e.op,[e.prop]:this[A]}},[Xt](e){return $n(e)&&e._tag===this._tag&&Zt(this[A],e[A])},[Nt](){return Ft(zt(e.op),O(this[A]))}};return function(e){let n=Object.create(t);return n[A]=e,n}},br=yr({op:`Success`,prop:`value`,[Gn](e){let t=e.getCont(Kn);return t?t[Kn](this[A],e,this):e.yieldWith(this)}}),xr={key:`effect/Cause/StackTrace`},Sr={key:`effect/Cause/InterruptorStackTrace`},Cr=yr({op:`Failure`,prop:`cause`,[Gn](e){let t=this[A],n=!1;e.currentStackFrame&&(t=fr(t,{mapUnsafe:new Map([[xr.key,e.currentStackFrame]])}),n=!0);let r=e.getCont(qn);for(;e.interruptible&&e._interruptedCause&&r;)r=e.getCont(qn);return r?r[qn](t,e,n?void 0:this):e.yieldWith(n?Cr(t):this)}}),wr=e=>Cr(lr(e)),Tr=e=>Cr(dr(e)),Er=vr({op:`WithFiber`,[Gn](e){return this[A](e)}}),Dr=function(){class e extends globalThis.Error{}let t=_r({op:`YieldableError`,[Gn](){return wr(this)}});return delete t.toString,Object.assign(e.prototype,t),e}(),Or=function(){let e=Symbol.for(`effect/Data/Error/plainArgs`);return class extends Dr{constructor(t){super(t?.message,t?.cause?{cause:t.cause}:void 0),t&&(xn(this,t),Object.defineProperty(this,e,{value:t,enumerable:!1}))}toJSON(){return{...this[e],...this}}}}(),kr=e=>{class t extends Or{_tag=e}return t.prototype.name=e,t};kr(`NoSuchElementError`);var Ar=`~effect/Cause/Done`,jr=e=>D(e,Ar),Mr={[Ar]:Ar,_tag:`Done`,value:void 0},Nr=e=>e===void 0?Mr:{[Ar]:Ar,_tag:`Done`,value:e},Pr=wr(Mr),Fr=e=>e===void 0?Pr:wr(Nr(e)),Ir=`~effect/data/Option`,Lr={[Ir]:{_A:e=>e},...Xn,[Symbol.iterator](){return new zn(this)}},Rr=Object.defineProperty(Object.assign(Object.create(Lr),{_tag:`Some`,_op:`Some`,[Xt](e){return Vr(e)&&Ur(e)&&Zt(this.value,e.value)},[Nt](){return Ft(O(this._tag))(O(this.value))},toString(){return`some(${k(this.value)})`},toJSON(){return{_id:`Option`,_tag:this._tag,value:In(this.value)}}}),"valueOrUndefined",{get(){return this.value}}),zr=O(`None`),Br=Object.assign(Object.create(Lr),{_tag:`None`,_op:`None`,valueOrUndefined:void 0,[Xt](e){return Vr(e)&&Hr(e)},[Nt](){return zr},toString(){return`none()`},toJSON(){return{_id:`Option`,_tag:this._tag}}}),Vr=e=>D(e,Ir),Hr=e=>e._tag===`None`,Ur=e=>e._tag===`Some`,Wr=Object.create(Br),Gr=e=>{let t=Object.create(Rr);return t.value=e,t},Kr=`~effect/data/Result`,qr={[Kr]:{_A:e=>e,_E:e=>e},...Xn,[Symbol.iterator](){return new zn(this)}},Jr=Object.assign(Object.create(qr),{_tag:`Success`,_op:`Success`,[Xt](e){return Xr(e)&&Qr(e)&&Zt(this.success,e.success)},[Nt](){return Ft(O(this._tag))(O(this.success))},toString(){return`success(${k(this.success)})`},toJSON(){return{_id:`Result`,_tag:this._tag,value:In(this.success)}}}),Yr=Object.assign(Object.create(qr),{_tag:`Failure`,_op:`Failure`,[Xt](e){return Xr(e)&&Zr(e)&&Zt(this.failure,e.failure)},[Nt](){return Ft(O(this._tag))(O(this.failure))},toString(){return`failure(${k(this.failure)})`},toJSON(){return{_id:`Result`,_tag:this._tag,failure:In(this.failure)}}}),Xr=e=>D(e,Kr),Zr=e=>e._tag===`Failure`,Qr=e=>e._tag===`Success`,$r=e=>{let t=Object.create(Yr);return t.failure=e,t},ei=e=>{let t=Object.create(Jr);return t.success=e,t};function ti(e){return(t,n)=>t===n?0:e(t,n)}var ni=ti((e,t)=>e<t?-1:1),ri=ti((e,t)=>globalThis.Number.isNaN(e)&&globalThis.Number.isNaN(t)?0:globalThis.Number.isNaN(e)?-1:globalThis.Number.isNaN(t)?1:e<t?-1:1),ii=T(2,(e,t)=>ti((n,r)=>e(t(n),t(r)))),ai=ii(ri,e=>e.getTime()),oi=e=>T(2,(t,n)=>e(t,n)===-1),si=e=>T(2,(t,n)=>e(t,n)===1),ci=e=>T(2,(t,n)=>e(t,n)!==1),li=e=>T(2,(t,n)=>e(t,n)!==-1),ui=()=>Wr,di=Gr,fi=Hr,pi=Ur,mi=T(2,(e,{onNone:t,onSome:n})=>fi(e)?t():n(e.value)),hi=T(2,(e,t)=>fi(e)?t():e.value),gi=e=>e==null?ui():di(e),_i=hi(pt),vi=T(2,(e,t)=>fi(e)?ui():di(t(e.value))),yi=T(2,(e,t)=>fi(e)?ui():t(e.value)?di(e.value):ui()),bi=ei,xi=$r,Si=e=>{if(wt(e))try{return bi(e())}catch(e){return xi(e)}try{return bi(e.try())}catch(t){return xi(e.catch(t))}},Ci=Zr,wi=_n,Ti=T(2,(e,t)=>Object.hasOwn(e,t)),Ei=T(2,(e,t)=>{let n={...e};for(let r of Di(e))bn(n,r,t(e[r],r));return n}),Di=e=>Object.keys(e),Oi=e=>T(2,(t,n)=>{for(let r of Di(t))if(!Ti(n,r)||!e(t[r],n[r]))return!1;return!0}),ki=e=>{let t=Oi(e);return(e,n)=>t(e,n)&&t(n,e)},Ai=globalThis.Array,ji=e=>Ai.isArray(e)?e:Ai.from(e),Mi=e=>Ai.isArray(e)?e:[e],Ni=T(2,(e,t)=>[...e,t]),Pi=T(2,(e,t)=>ji(e).concat(ji(t))),Fi=Ai.isArray,Ii=yn,Li=yn,Ri=T(3,(e,t,n)=>Ai.from(e).map(e=>[e,t(e)]).sort(([,e],[,t])=>n(e,t)).map(([e])=>e)),zi=(e,t)=>{let n=O(t),r=e.get(n);if(r===void 0)return e.set(n,[t]),!0;for(let e of r)if(Zt(e,t))return!1;return r.push(t),!0},Bi=T(2,(e,t)=>{let n=ji(e),r=ji(t);return Li(n)?Li(r)?Gi(Pi(n,r)):n:r}),Vi=()=>[],Hi=e=>[e],Ui=T(2,(e,t)=>e.map(t)),Wi=vn,Gi=e=>{let t=ji(e);if(t.length<2)return[...t];let n=new Map,r=[];for(let e of t)zi(n,e)&&r.push(e);return r},Ki=`~effect/BigDecimal`,qi={[Ki]:Ki,[Nt](){let e=ea(this);return Ft(O(e.value),Rt(e.scale))},[Xt](e){return Ji(e)&&ia(this,e)},toString(){return`BigDecimal(${aa(this)})`},toJSON(){return{_id:`BigDecimal`,value:String(this.value),scale:this.scale}},[Fn](){return this.toJSON()},pipe(){return st(this,arguments)}},Ji=e=>D(e,Ki),Yi=(e,t)=>{let n=Object.create(qi);return n.value=e,n.scale=t,n},Xi=(e,t)=>{if(e!==Zi&&e%Qi===Zi)throw RangeError(`Value must be normalized`);let n=Yi(e,t);return n.normalized=n,n},Zi=BigInt(0),Qi=BigInt(10),$i=Xi(Zi,0),ea=e=>{if(e.normalized===void 0){if(e.value===Zi)e.normalized=$i;else{let t=`${e.value}`,n=0;for(let e=t.length-1;e>=0&&t[e]===`0`;e--)n++;n===0&&(e.normalized=e),e.normalized=Xi(BigInt(t.substring(0,t.length-n)),e.scale-n)}}return e.normalized},ta=T(2,(e,t)=>t>e.scale?Yi(e.value*Qi**BigInt(t-e.scale),t):t<e.scale?Yi(e.value/Qi**BigInt(e.scale-t),t):e),na=e=>e.value<Zi?Yi(-e.value,e.scale):e,ra=mn((e,t)=>e.scale>t.scale?ta(t,e.scale).value===e.value:e.scale<t.scale?ta(e,t.scale).value===t.value:e.value===t.value),ia=T(2,(e,t)=>ra(e,t)),aa=e=>{let t=ea(e);if(Math.abs(t.scale)>=16)return oa(t);let n=t.value<Zi,r=n?`${t.value}`.substring(1):`${t.value}`,i,a;if(t.scale>=r.length)i=`0`,a=`0`.repeat(t.scale-r.length)+r;else{let e=r.length-t.scale;if(e>r.length){let t=e-r.length;i=`${r}${`0`.repeat(t)}`,a=``}else a=r.slice(e),i=r.slice(0,e)}let o=a===``?i:`${i}.${a}`;return n?`-${o}`:o},oa=e=>{if(sa(e))return`0e+0`;let t=ea(e),n=`${na(t).value}`,r=n.slice(0,1),i=n.slice(1),a=`${ca(t)?`-`:``}${r}`;i!==``&&(a+=`.${i}`);let o=i.length-t.scale;return`${a}e${o>=0?`+`:``}${o}`},sa=e=>e.value===Zi,ca=e=>e.value<Zi,la=e=>_r({op:e.label,[Gn]:e.evaluate}),ua=`~effect/Context/Service`,da=function(){function e(){}let t=e;Object.setPrototypeOf(t,fa);let n=(e,n)=>(t.key=e,n?.defaultValue&&(t[ma]=ma,t.defaultValue=n.defaultValue),n?.make&&(t.make=n.make),n?.fiberCached&&pa.add(e),t);return arguments.length>0?n(arguments[0],arguments[1]):n},fa={[ua]:ua,...la({label:`Service`,evaluate(e){return br(La(e.context,this))}}),toJSON(){return{_id:`Service`,key:this.key}},of(e){return e},context(e){return ja(this,e)},use(e){return Er(t=>e(La(t.context,this)))},useSync(e){return Er(t=>br(e(La(t.context,this))))}},pa=new Set,ma=`~effect/Context/Reference`,ha=`~effect/Context`,ga=8,_a=8,va=(e,t,n,r)=>{let i=Object.create(Ta);return i.cacheRoot=e??i,i.base=t,i.overlay=n,i.depth=r,i._flat=void 0,i.baseHits=0,i},ya=(e,t)=>{t&&(ya(e,t.parent),e.set(t.key,t.value))},ba=e=>{if(e._flat)return e._flat;if(!e.overlay)return e._flat=e.base;let t=new Map(e.base);return ya(t,e.overlay),e._flat=t},xa=(e,t)=>{let n=new Map(e.mapUnsafe);return t(n),wa(n)},Sa=Symbol(),Ca=(e,t)=>{let n=e;for(let e=n.overlay;e;e=e.parent)if(e.key===t)return e.value;let r=n.base.get(t);return r===void 0&&!n.base.has(t)?Sa:(n.overlay&&++n.baseHits>=_a&&(n.base=ba(n),n.overlay=void 0,n.depth=0),r)},wa=e=>va(void 0,e,void 0,0),Ta={get mapUnsafe(){return ba(this)},...Xn,[ha]:{_Services:e=>e},toJSON(){return{_id:`Context`,services:Array.from(this.mapUnsafe).map(([e,t])=>({key:e,value:t}))}},[Xt](e){if(!Da(e))return!1;let t=this.mapUnsafe,n=e.mapUnsafe;if(t.size!==n.size)return!1;for(let[e,r]of t)if(!n.has(e)||!Zt(r,n.get(e)))return!1;return!0},[Nt](){return Rt(this.mapUnsafe.size)}},Ea=(e,t)=>e.cacheRoot===t.cacheRoot,Da=e=>D(e,ha),Oa=e=>!!e[ma],ka=()=>Aa,Aa=wa(new Map),ja=(e,t)=>wa(new Map([[e.key,t]])),Ma=T(3,(e,t,n)=>Na(e,t.key,n)),Na=(e,t,n)=>{let r=e,i=pa.has(t)?void 0:r.cacheRoot;if(r.depth>=ga){let e=new Map(r.mapUnsafe);return e.set(t,n),va(i,e,void 0,0)}return va(i,r.base,{key:t,value:n,parent:r.overlay},r.depth+1)},Pa=T(2,(e,t)=>Fa(e,t.key)),Fa=(e,t)=>{let n=Ca(e,t);return n===Sa?void 0:n},Ia=T(2,(e,t)=>{let n=Ca(e,t.key);if(n===Sa){if(Oa(t))return za(t);throw Ba(t)}return n}),La=Ia,Ra=`~effect/Context/defaultValue`,za=e=>Ra in e?e[Ra]:e[Ra]=e.defaultValue(),Ba=e=>{let t=Error(`Service not found${e.key?`: ${String(e.key)}`:``}`);if(t.stack){let e=t.stack.split(`
4
+ `);e.splice(1,3),t.stack=e.join(`
5
+ `)}return t},Va=T(2,(e,t)=>e.mapUnsafe.size===0?t:t.mapUnsafe.size===0?e:xa(e,e=>t.mapUnsafe.forEach((t,n)=>e.set(n,t)))),Ha=(...e)=>{let t=new Map;for(let n=0;n<e.length;n++)e[n].mapUnsafe.forEach((e,n)=>{t.set(n,e)});return wa(t)},Ua=da,Wa=`~effect/time/Duration`,Ga=BigInt(0),Ka=BigInt(1),qa=BigInt(2),Ja=BigInt(10),Ya=BigInt(1e3),Xa=e=>BigInt(e<0?Math.ceil(e-.5):Math.floor(e+.5)),Za=e=>Xa(e*1e6),Qa=(e,t)=>{let n=e.indexOf(`.`);if(n===-1)return BigInt(e)*t;let r=e[0]===`-`,i=e.slice(n+1),a=Ja**BigInt(i.length),o=(BigInt(e.slice(+!!r,n))*a+BigInt(i))*t,s=o/a+(o%a*qa>=a?Ka:Ga);return r?-s:s},$a=/^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/,eo=e=>{switch(typeof e){case`number`:return po(e);case`bigint`:return fo(e);case`string`:{if(e===`Infinity`)return lo;if(e===`-Infinity`)return uo;let t=$a.exec(e);if(!t)break;let[n,r,i]=t;if(i===`nano`||i===`nanos`)return fo(Qa(r,Ka));if(i===`micro`||i===`micros`)return fo(Qa(r,Ya));let a=Number(r);switch(i){case`milli`:case`millis`:return po(a);case`second`:case`seconds`:return mo(a);case`minute`:case`minutes`:return ho(a);case`hour`:case`hours`:return go(a);case`day`:case`days`:return _o(a);case`week`:case`weeks`:return vo(a)}break}case`object`:{if(e===null)break;if(Wa in e)return e;if(Array.isArray(e))return e.length!==2||!e.every(bt)?to(e):Number.isNaN(e[0])||Number.isNaN(e[1])?co:e[0]===-1/0||e[1]===-1/0?uo:e[0]===1/0||e[1]===1/0?lo:oo(Xa(e[0]*1e9+e[1]));let t=e,n=0;return t.weeks&&(n+=t.weeks*6048e5),t.days&&(n+=t.days*864e5),t.hours&&(n+=t.hours*36e5),t.minutes&&(n+=t.minutes*6e4),t.seconds&&(n+=t.seconds*1e3),t.milliseconds&&(n+=t.milliseconds),!t.microseconds&&!t.nanoseconds?oo(n):oo(Xa(n*1e6+(t.microseconds??0)*1e3+(t.nanoseconds??0)))}}return to(e)},to=e=>{throw Error(`Invalid Input: ${e}`)},no={_tag:`Millis`,millis:0},ro={_tag:`Infinity`},io={_tag:`NegativeInfinity`},ao={[Wa]:Wa,[Nt](){switch(this.value._tag){case`Millis`:{let e=this.value.millis*1e6;return Number.isFinite(e)?O(Xa(e)):Rt(this.value.millis)}case`Nanos`:return O(this.value.nanos);default:return Vt(this.value)}},[Xt](e){return so(e)&&wo(this,e)},toString(){switch(this.value._tag){case`Infinity`:return`Infinity`;case`NegativeInfinity`:return`-Infinity`;case`Nanos`:return`${this.value.nanos} nanos`;case`Millis`:return`${this.value.millis} millis`}},toJSON(){switch(this.value._tag){case`Millis`:return{_id:`Duration`,_tag:`Millis`,millis:this.value.millis};case`Nanos`:return{_id:`Duration`,_tag:`Nanos`,nanos:String(this.value.nanos)};case`Infinity`:return{_id:`Duration`,_tag:`Infinity`};case`NegativeInfinity`:return{_id:`Duration`,_tag:`NegativeInfinity`}}},[Fn](){return this.toJSON()},pipe(){return st(this,arguments)}},oo=e=>{let t=Object.create(ao);return t.value=typeof e==`number`?isNaN(e)||e===0||Object.is(e,-0)?no:Number.isFinite(e)?Number.isInteger(e)?{_tag:`Millis`,millis:e}:{_tag:`Nanos`,nanos:Za(e)}:e>0?ro:io:e===Ga?no:{_tag:`Nanos`,nanos:e},t},so=e=>D(e,Wa),co=oo(0),lo=oo(1/0),uo=oo(-1/0),fo=e=>oo(e),po=e=>oo(e),mo=e=>oo(e*1e3),ho=e=>oo(e*6e4),go=e=>oo(e*36e5),_o=e=>oo(e*864e5),vo=e=>oo(e*6048e5),yo=e=>xo(eo(e),{onMillis:E,onNanos:e=>Number(e)/1e6,onInfinity:()=>1/0,onNegativeInfinity:()=>-1/0}),bo=e=>{let t=eo(e);switch(t.value._tag){case`Infinity`:case`NegativeInfinity`:throw Error(`Cannot convert infinite duration to nanos`);case`Nanos`:return t.value.nanos;case`Millis`:return Za(t.value.millis)}},xo=T(2,(e,t)=>{switch(e.value._tag){case`Millis`:return t.onMillis(e.value.millis);case`Nanos`:return t.onNanos(e.value.nanos);case`Infinity`:return t.onInfinity();case`NegativeInfinity`:return(t.onNegativeInfinity??t.onInfinity)()}}),So=T(3,(e,t,n)=>e.value._tag===`Infinity`||e.value._tag===`NegativeInfinity`||t.value._tag===`Infinity`||t.value._tag===`NegativeInfinity`?n.onInfinity(e,t):e.value._tag===`Millis`?t.value._tag===`Millis`?n.onMillis(e.value.millis,t.value.millis):n.onNanos(bo(e),t.value.nanos):n.onNanos(e.value.nanos,bo(t))),Co=(e,t)=>So(e,t,{onMillis:(e,t)=>e===t,onNanos:(e,t)=>e===t,onInfinity:(e,t)=>e.value._tag===t.value._tag}),wo=T(2,(e,t)=>Co(e,t)),To=Ua(`effect/Scheduler`,{fiberCached:!0,defaultValue:()=>new ko}),Eo=`setImmediate`in globalThis?e=>{let t=globalThis.setImmediate(e);return()=>globalThis.clearImmediate(t)}:e=>{let t=setTimeout(e,0);return()=>clearTimeout(t)},Do=e=>{let t=!1;return Promise.resolve().then(()=>{t||e()}),()=>{t=!0}},Oo=class{buckets=[];scheduleTask(e,t){let n=this.buckets,r=n.length,i,a=0;for(;a<r&&!(n[a][0]>t);a++)i=n[a];i&&i[0]===t?i[1].push(e):a===r?n.push([t,[e]]):n.splice(a,0,[t,[e]])}drain(){let e=this.buckets;return this.buckets=[],e}},ko=class{executionMode;setImmediate;constructor(e=`async`,t){this.executionMode=e,this.setImmediate=t??(e===`sync`?Do:Eo)}shouldYield(e){return e.currentOpCount>=e.maxOpsBeforeYield}makeDispatcher(){return new Ao(this.setImmediate)}},Ao=class{tasks=new Oo;running=void 0;setImmediate;constructor(e=Eo){this.setImmediate=e}scheduleTask(e,t){this.tasks.scheduleTask(e,t),this.running===void 0&&(this.running=this.setImmediate(this.afterScheduled))}afterScheduled=()=>{this.running=void 0,this.runTasks()};runTasks(){let e=this.tasks.drain();for(let t=0;t<e.length;t++){let n=e[t][1];for(let e=0;e<n.length;e++)n[e]()}}flush(){for(;this.tasks.buckets.length>0;)this.running!==void 0&&(this.running(),this.running=void 0),this.runTasks()}},jo=Ua(`effect/Scheduler/MaxOpsBeforeYield`,{fiberCached:!0,defaultValue:()=>2048}),Mo=Ua(`effect/Scheduler/PreventSchedulerYield`,{fiberCached:!0,defaultValue:()=>!1}),No=kr;No(`EncodingError`);var Po=e=>{let t=``;for(let n=e>>>3;n>0;n--){let e=Math.random()*4294967296>>>0;t+=Fo[e>>>24]+Fo[e>>>16&255]+Fo[e>>>8&255]+Fo[e&255]}return t},Fo=[];for(let e=0;e<256;e++)Fo.push(e.toString(16).padStart(2,`0`));var Io=`effect/Tracer/ParentSpan`,Lo=class extends da()(Io,{fiberCached:!0}){},Ro=e=>e,zo=Ua(`effect/Tracer/DisablePropagation`,{defaultValue:ft}),Bo=Ua(`effect/Tracer/CurrentTraceLevel`,{defaultValue:()=>`Info`}),Vo=Ua(`effect/Tracer/MinimumTraceLevel`,{defaultValue:()=>`All`}),Ho=`effect/Tracer`,Uo=Ua(Ho,{fiberCached:!0,defaultValue:()=>Ro({span:e=>new Wo(e)})}),Wo=class{_tag=`Span`;spanId;traceId=`native`;sampled;name;parent;annotations;links;startTime;kind;status;attributes;events=[];constructor(e){this.name=e.name,this.parent=e.parent,this.annotations=e.annotations,this.links=e.links,this.startTime=e.startTime,this.kind=e.kind,this.sampled=e.sampled,this.status={_tag:`Started`,startTime:e.startTime},this.attributes=new Map,this.traceId=_i(e.parent)?.traceId??Po(32),this.spanId=Po(16)}end(e,t){this.status={_tag:`Ended`,endTime:e,exit:t,startTime:this.status.startTime}}attribute(e,t){this.attributes.set(e,t)}event(e,t,n){this.events.push([e,t,n??{}])}addLinks(e){this.links.push(...e)}},Go=`effect/observability/Metric/FiberRuntimeMetricsKey`,Ko=Ua(`effect/ErrorReporter/CurrentErrorReporters`,{defaultValue:()=>new Set}),qo=Ua(`effect/References/CurrentStackFrame`,{fiberCached:!0,defaultValue:pt}),Jo=Ua(`effect/References/TracerEnabled`,{defaultValue:dt}),Yo=Ua(`effect/References/TracerTimingEnabled`,{defaultValue:dt}),Xo=Ua(`effect/References/TracerSpanAnnotations`,{defaultValue:()=>({})}),Zo=Ua(`effect/References/TracerSpanLinks`,{defaultValue:()=>[]}),Qo=Ua(`effect/References/CurrentLogLevel`,{fiberCached:!0,defaultValue:()=>`Info`}),$o=Ua(`effect/References/MinimumLogLevel`,{fiberCached:!0,defaultValue:()=>`Info`}),es=(()=>{let e=Object.getOwnPropertyDescriptor(Error,`stackTraceLimit`);return e===void 0?Object.isExtensible(Error):Object.hasOwn(e,`writable`)?e.writable===!0:e.set!==void 0})(),ts=()=>Error.stackTraceLimit,ns=e=>{es&&(Error.stackTraceLimit=e)},rs=e=>{if(e?.captureStackTrace===!1||e?.captureStackTrace!==void 0&&typeof e.captureStackTrace!=`boolean`)return e;let t=ts();ns(3);let n=Error();return ns(t),{...e,captureStackTrace:as(()=>n.stack)}},is=e=>t=>{let n;return()=>{if(n!==void 0)return n;let r=t();if(!r)return;let i=r.split(`
6
+ `);if(i[e]!==void 0)return n=i[e].trim(),n}},as=is(3),os=class extends ar{fiberId;constructor(e,t=or){super(`Interrupt`,t,`Interrupted`),this.fiberId=e}toString(){return`Interrupt(${this.fiberId})`}toJSON(){return{_tag:`Interrupt`,fiberId:this.fiberId}}[Xt](e){return hr(e)&&this.fiberId===e.fiberId&&this.annotations===e.annotations}[Nt](){return Ft(zt(`${this._tag}:${this.fiberId}`))(Pt(this.annotations))}},ss=e=>new rr([new os(e)]),cs=e=>{for(let t=0;t<e.reasons.length;t++){let n=e.reasons[t];if(n._tag===`Fail`)return bi(n.error)}return xi(e)},ls=e=>e.reasons.some(mr),us=e=>e.reasons.some(hr),ds=e=>{let t;for(let n=0;n<e.reasons.length;n++){let r=e.reasons[n];r._tag===`Interrupt`&&(t??=new Set,r.fiberId!==void 0&&t.add(r.fiberId))}return t?bi(t):xi(e)},fs=T(2,(e,t)=>{if(e.reasons.length===0)return t;if(t.reasons.length===0)return e;let n=new rr(Bi(e.reasons,t.reasons));return Zt(e,n)?e:n}),ps=T(2,(e,t)=>{let n=!1,r=e.reasons.map(e=>pr(e)?(n=!0,new sr(t(e.error),e.annotations)):e);return n?cr(r):e}),ms=e=>{let t={Fail:[],Die:[],Interrupt:[]};for(let n=0;n<e.reasons.length;n++)t[e.reasons[n]._tag].push(e.reasons[n]);return t},hs=e=>{let t=ms(e);return t.Fail.length>0?t.Fail[0].error:t.Die.length>0?t.Die[0].defect:t.Interrupt.length>0?new globalThis.Error(`All fibers interrupted without error`):new globalThis.Error(`Empty cause`)},gs=(e,t,n)=>{let r=typeof e,i;if(e&&r===`object`){if(i=new globalThis.Error(_s(e),{cause:e.cause?gs(e.cause):void 0}),typeof e.name==`string`&&(i.name=e.name),typeof e.stack==`string`)i.stack=ys(e.stack,i,t);else{let e=`${i.name}: ${i.message}`;i.stack=t?bs(e,t):e}n?.includeCauseInStack&&(i.stack=Ss(i));for(let t of Object.keys(e))t in i||(i[t]=e[t])}else i=new globalThis.Error(e?r===`string`?e:Pn(e):`Unknown error: ${e}`);return i},_s=e=>{if(typeof e.message==`string`)return e.message;if(typeof e.toString==`function`&&e.toString!==Object.prototype.toString&&e.toString!==Array.prototype.toString)try{return e.toString()}catch{}return Pn(e)},vs=/\((.*)\)/g,ys=(e,t,n)=>{let r=`${t.name}: ${t.message}`,i=(e.startsWith(r)?e.slice(r.length):e).split(`
7
+ `),a=[r];for(let e=1;e<i.length&&!/(?:Generator\.next|~effect\/Effect)/.test(i[e]);e++)a.push(i[e]);return n?bs(a.join(`
8
+ `),n):a.join(`
9
+ `)},bs=(e,t)=>{let n=t?.get(xr.key);return n&&(e=`${e}\n${xs(n)}`),e},xs=e=>{let t=[],n=e,r=0;for(;n&&r<10;){let e=n.stack();if(e){let r=e.matchAll(vs),i=!1;for(let[,e]of r)i=!0,t.push(` at ${n.name} (${e})`);i||t.push(` at ${n.name} (${e.replace(/^at /,``)})`)}else t.push(` at ${n.name}`);n=n.parent,r++}return t.join(`
10
+ `)},Ss=e=>e.cause?`${e.stack} {\n${Cs(e.cause,` `)}\n}`:e.stack,Cs=(e,t)=>{let n=e.stack.split(`
11
+ `),r=`${t}[cause]: ${n[0]}`;for(let e=1,i=n.length;e<i;e++)r+=`\n${t}${n[e]}`;return e.cause&&(r+=` {\n${Cs(e.cause,`${t} `)}\n${t}}`),r},ws=`~effect/Fiber`,Ts={_A:E,_E:E},Es={id:0},Ds=()=>globalThis[En],Os=class{constructor(e,t=!0){this[ws]=Ts,this.setContext(e),this.id=++Es.id,this.currentOpCount=0,this.interruptible=t,this._stack=[],this._observers=[],this._exit=void 0,this._children=void 0,this._interruptedCause=void 0,this._yielded=void 0,this._running=!1,this._deferredInterrupt=!1,this.runtimeMetrics?.recordFiberStart(this.context)}[ws];id;interruptible;currentOpCount;_stack;_observers;_exit;_children;_interruptedCause;_yielded;_running;_deferredInterrupt;context;currentScheduler;currentTracerContext;currentSpan;currentLogLevel;minimumLogLevel;currentStackFrame;runtimeMetrics;maxOpsBeforeYield;currentPreventYield;_dispatcher=void 0;get currentDispatcher(){return this._dispatcher??=this.currentScheduler.makeDispatcher()}getRef(e){return La(this.context,e)}addObserver(e){return this._exit?(e(this._exit),mt):(this._observers.push(e),()=>{if(this._exit)return;let t=this._observers.indexOf(e);t>=0&&this._observers.splice(t,1)})}interruptUnsafe(e,t){if(this._exit)return;let n=ss(e);this.currentStackFrame&&(n=fr(n,ja(xr,this.currentStackFrame))),t&&(n=fr(n,t)),this._interruptedCause=this._interruptedCause?fs(this._interruptedCause,n):n,this.interruptible&&(this._running?this._deferredInterrupt=!0:this.evaluate(Ls(this._interruptedCause)))}pollUnsafe(){return this._exit}evaluate(e){if(this._exit)return;if(this._yielded!==void 0){let e=this._yielded;this._yielded=void 0,e()}let t=this.runLoop(e);if(t===Yn)return;let n=As.interruptChildren&&As.interruptChildren(this);if(n!==void 0)return this.evaluate(N(n,()=>t));this._exit=t,this.runtimeMetrics?.recordFiberEnd(this.context,this._exit);for(let e=0;e<this._observers.length;e++)this._observers[e](t);this._observers.length=0,this._stack.length=0,this._children=void 0,this.context=ka()}runLoop(e){let t=globalThis[En];globalThis[En]=this;let n=this._running;this._running=!0;let r=!1,i=e;this.currentOpCount=0;try{for(;;){if(this._deferredInterrupt&&(this._deferredInterrupt=!1,i=Ls(this._interruptedCause)),this.currentOpCount++,!r&&!this.currentPreventYield&&this.currentScheduler.shouldYield(this)){r=!0;let e=i;i=N(Bs,()=>e)}if(i=this.currentTracerContext?this.currentTracerContext(i,this):i[Gn](this),i===Yn){let e=this._yielded;if(Hn in e)return this._deferredInterrupt=!1,this._yielded=void 0,e;if(this._deferredInterrupt){this._yielded=void 0,e();continue}return Yn}}}catch(e){return D(i,Gn)?this.runLoop(Tr(e)):Tr(`Fiber.runLoop: Not a valid effect: ${String(i)}`)}finally{this._running=n,globalThis[En]=t}}getCont(e){if(this._deferredInterrupt)return this._deferredInterrupt=!1,ks;for(;;){let t=this._stack.pop();if(!t)return;let n=t[Jn]&&t[Jn](this);if(n)return n[e]=n,n;if(t[e])return t}}yieldWith(e){return this._yielded=e,Yn}children(){return this._children??=new Set}pipe(){return st(this,arguments)}setContext(e){let t=this.context;if(this.context=e,t!==void 0&&Ea(t,e))return;let n=this.getRef(To);n!==this.currentScheduler&&(this.currentScheduler=n,this._dispatcher=void 0),this.currentSpan=Fa(e,Io),this.currentLogLevel=this.getRef(Qo),this.minimumLogLevel=this.getRef($o),this.currentStackFrame=this.getRef(qo),this.maxOpsBeforeYield=this.getRef(jo),this.currentPreventYield=this.getRef(Mo),this.runtimeMetrics=Fa(e,Go);let r=Fa(e,Ho);this.currentTracerContext=r?r.context:void 0}get currentSpanLocal(){return this.currentSpan?._tag===`Span`?this.currentSpan:void 0}},ks={[Kn](e,t){return Ls(t._interruptedCause)},[qn](e,t){return Ls(t._interruptedCause)}},As={interruptChildren:void 0},js=e=>{if(!e.currentStackFrame)return;let t=new Map;return t.set(Sr.key,e.currentStackFrame),wa(t)},Ms=e=>{let t=e;return t._exit?j(t._exit):Zs(n=>t._exit?n(j(t._exit)):M(e.addObserver(e=>n(j(e)))))},Ns=e=>Zs(t=>{let n=e[Symbol.iterator](),r=[],i;function a(){let e=n.next();for(;!e.done;){if(e.value._exit){r.push(e.value._exit),e=n.next();continue}i=e.value.addObserver(e=>{r.push(e),a()});return}t(j(r))}return a(),M(()=>i?.())}),Ps=e=>Er(t=>Fs(e,t.id)),Fs=T(e=>D(e[0],ws),(e,t,n)=>Er(r=>{let i=js(r);return i=i&&n?Va(i,n):i??n,e.interruptUnsafe(t,i),fc(Ms(e))})),Is=e=>Er(t=>{let n=js(t),r=Vi();for(let i of e)i.interruptUnsafe(t.id,n),r.push(i);return fc(Ns(r))}),j=br,Ls=Cr,Rs=wr,M=vr({op:`Sync`,[Gn](e){let t=this[A](),n=e.getCont(Kn);return n?n[Kn](t,e):e.yieldWith(br(t))}}),zs=vr({op:`Suspend`,[Gn](e){return this[A]()}}),Bs=vr({op:`Yield`,[Gn](e){let t=!1;return e.currentDispatcher.scheduleTask(()=>{t||e.evaluate(Sc)},this[A]??0),e.yieldWith(()=>{t=!0})}})(0),Vs=j(ui()),Hs=e=>zs(()=>Ls(Bn(e))),Us=e=>Tr(e),Ws=e=>zs(()=>Rs(Bn(e))),Gs=j(void 0),Ks=e=>{let t=typeof e==`function`?e:e.try,n=typeof e==`function`?e=>new wu(e,`An error occurred in Effect.try`):e.catch;return zs(()=>{try{return j(Bn(t))}catch(e){return Rs(Bn(()=>n(e)))}})},qs=e=>Ys(function(t,n){Bn(()=>e(n)).then(e=>t(j(e)),e=>t(Us(e)))},e.length!==0),Js=e=>{let t=typeof e==`function`?e:e.try,n=typeof e==`function`?e=>new wu(e,`An error occurred in Effect.tryPromise`):e.catch;return Ys(function(e,r){let i=t=>{try{e(Rs(Bn(()=>n(t))))}catch(t){e(Us(t))}};try{Bn(()=>t(r)).then(t=>e(j(t)),i)}catch(e){i(e)}},t.length!==0)},Ys=vr({op:`Async`,single:!1,[Gn](e){let t=Bn(()=>this[A][0].bind(e.currentScheduler)),n=!1,r=!1,i=this[A][1]?new AbortController:void 0,a=t(t=>{n||(n=!0,r?e.evaluate(t):r=t)},i?.signal);return r===!1?(r=!0,e._yielded=()=>{n=!0},i===void 0&&a===void 0||e._stack.push(Xs(()=>(n=!0,i?.abort(),a??Sc))),Yn):r}}),Xs=vr({op:`AsyncFinalizer`,[Jn](e){e.interruptible&&(e.interruptible=!1,e._stack.push(Ol))},[qn](e,t){return us(e)?N(this[A](),()=>Ls(e)):Ls(e)}}),Zs=e=>Ys(e,e.length>=2),Qs=Zs(mt),$s=(...e)=>zs(()=>sc(e.length===1?e[0]():e[1].call(e[0].self))),ec=(e,...t)=>{let n=t.length===0?function(){return zs(()=>sc(e.apply(this,arguments)))}:function(){let n=zs(()=>sc(e.apply(this,arguments)));for(let e=0;e<t.length;e++)n=t[e](n,...arguments);return n};return tc(e.length,n)},tc=(e,t)=>Object.defineProperty(t,"length",{value:e,configurable:!0}),nc=is(2),rc=function(){let e=typeof arguments[0]==`string`,t=e?arguments[0]:`Effect.fn`,n=e?arguments[1]:void 0,r=ts();ns(2);let i=new globalThis.Error;return ns(r),e?(r,...a)=>ic(t,r,i,a,e,n):ic(t,arguments[0],i,Array.prototype.slice.call(arguments,1),e,n)},ic=(e,t,n,r,i,a)=>{let o=typeof t==`function`?t:r.shift().bind(t.self);return tc(o.length,function(...t){let s=zs(()=>{let e=o.apply(this,arguments);return Qn(e)?e:sc(e)});for(let e=0;e<r.length;e++)s=r[e](s,...t);if(!Qn(s))return s;let c=ts();ns(2);let l=new globalThis.Error;return ns(c),Dc(i?uu(e,a,e=>du(s,e)):s,qo,t=>({name:e,stack:nc(()=>l.stack),parent:{name:`${e} (definition)`,stack:nc(()=>n.stack),parent:t}}))})},ac=(e,...t)=>tc(e.length,t.length===0?function(){return oc(()=>e.apply(this,arguments))}:function(){let n=oc(()=>e.apply(this,arguments));for(let e of t)n=e(n);return n}),oc=e=>{try{let t=e(),n;for(;;){let r=t.next(n);if(r.done)return j(r.value);let i=r.value;if(i&&i._tag===`Success`){n=i.value;continue}if(i&&i._tag===`Failure`)return r.value;{let n=!0;return zs(()=>n?(n=!1,N(r.value,e=>sc(t,e))):zs(()=>sc(e())))}}}catch(e){return Us(e)}},sc=vr({op:`Iterator`,single:!1,[Kn](e,t){let n=this[A][0];for(;;){let r=n.next(e);if(r.done)return j(r.value);if(!mc(r.value))return t._stack.push(this),r.value;if(r.value._tag===`Failure`)return r.value;e=r.value.value}},[Gn](e){return this[Kn](this[A][1],e)}}),cc=T(2,(e,t)=>{let n=j(t);return N(e,e=>n)}),lc=e=>_c(e,di),uc=T(2,(e,t)=>N(e,e=>Qn(t)?t:Bn(()=>t(e)))),dc=T(2,(e,t)=>N(e,e=>cc(Qn(t)?t:Bn(()=>t(e)),e))),fc=e=>N(e,e=>Sc),N=T(2,(e,t)=>{let n=Object.create(pc);return n[A]=e,n[Kn]=t.length===1?t:e=>t(e),n}),pc=_r({op:`OnSuccess`,[Gn](e){return e._stack.push(this),this[A]}}),mc=e=>Hn in e,hc=T(2,(e,t)=>mc(e)?e._tag===`Success`?t(e.value):e:N(e,t)),gc=e=>N(e,E),_c=T(2,(e,t)=>N(e,e=>j(Bn(()=>t(e))))),vc=T(2,(e,t)=>mc(e)?Cc(e,t):_c(e,t)),yc=T(2,(e,t)=>mc(e)?wc(e,t):Wc(e,t)),bc=e=>e._tag===`Success`,xc=e=>e._tag===`Failure`?bi(e.cause):xi(e),Sc=br(void 0),Cc=T(2,(e,t)=>e._tag===`Success`?br(t(e.value)):e),wc=T(2,(e,t)=>{if(e._tag===`Success`)return br(t.onSuccess(e.value));let n=cs(e.cause);return Ci(n)?e:wr(t.onFailure(n.success))}),Tc=e=>{let t=[];for(let n of e)n._tag===`Failure`&&t.push(...n.cause.reasons);return t.length===0?Sc:Cr(cr(t))},Ec=T(2,(e,t)=>Er(n=>{let r=n.context,i=t(r);return r===i?e:(n.setContext(i),gl(e,()=>{n.setContext(r)}))})),Dc=T(3,(e,t,n)=>Ec(e,e=>{let r=Ia(e,t),i=n(r);return r===i?e:Ma(e,t,i)})),Oc=()=>kc,kc=Er(e=>j(e.context)),Ac=e=>Er(t=>e(t.context)),jc=T(2,(e,t)=>mc(e)?e:Ec(e,Va(t))),Mc=function(){return arguments.length===1?T(2,(e,t)=>Nc(e,arguments[0],t)):T(3,(e,t,n)=>Nc(e,t,n)).apply(this,arguments)},Nc=(e,t,n)=>Ec(e,Ma(t,n)),Pc=T(e=>Qn(e[0]),(e,t)=>Nl({while:dt,body:ut(t?.disableYield?e:N(e,e=>Bs)),step:mt})),Fc=T(2,(e,t)=>{let n=Object.create(Ic);return n[A]=e,n[qn]=t.length===1?t:e=>t(e),n}),Ic=_r({op:`OnFailure`,[Gn](e){return e._stack.push(this),this[A]}}),Lc=T(3,(e,t,n)=>Fc(e,e=>{let r=t(e);return Ci(r)?Ls(r.failure):Bn(()=>n(r.success,e))})),Rc=T(2,(e,t)=>Lc(e,cs,e=>t(e))),zc=T(3,(e,t,n)=>Fc(e,e=>{let r=t(e);return Ci(r)?Ls(e):uc(Bn(()=>n(r.success,e)),Ls(e))})),Bc=T(2,(e,t)=>zc(e,cs,e=>t(e))),Vc=T(e=>Qn(e[0]),(e,t,n,r)=>Fc(e,e=>{let i=cs(e);if(Ci(i))return Ls(i.failure);let a=t(i.success);return Ci(a)?r?Bn(()=>r(a.failure)):Ls(e):Bn(()=>n(a.success))})),Hc=T(e=>Qn(e[0]),(e,t,n)=>{let r;return Vc(e,e=>(r??=Object.keys(t),D(e,`_tag`)&&yt(e._tag)&&r.includes(e._tag)?bi(e):xi(e)),e=>Bn(()=>t[e._tag](e)),n)}),Uc=T(2,(e,t)=>Rc(e,e=>Ws(()=>t(e)))),Wc=T(2,(e,t)=>Jc(e,{onFailure:e=>Ws(()=>t.onFailure(e)),onSuccess:e=>M(()=>t.onSuccess(e))})),Gc=e=>Xc(e,{onFailure:xi,onSuccess:bi}),Kc=T(2,(e,t)=>{let n=Object.create(qc);return n[A]=e,n[Kn]=t.onSuccess.length===1?t.onSuccess:e=>t.onSuccess(e),n[qn]=t.onFailure.length===1?t.onFailure:e=>t.onFailure(e),n}),qc=_r({op:`OnSuccessAndFailure`,[Gn](e){return e._stack.push(this),this[A]}}),Jc=T(2,(e,t)=>Kc(e,{onFailure:e=>{let n=e.reasons.find(pr);return n?Bn(()=>t.onFailure(n.error)):Ls(e)},onSuccess:t.onSuccess})),Yc=T(2,(e,t)=>Jc(e,{onFailure:e=>M(()=>t.onFailure(e)),onSuccess:e=>M(()=>t.onSuccess(e))})),Xc=T(2,(e,t)=>{if(mc(e)){if(e._tag===`Success`)return br(t.onSuccess(e.value));let n=cs(e.cause);return Ci(n)?e:br(t.onFailure(n.success))}return Yc(e,t)}),Zc=e=>mc(e)?br(e):Qc(e),Qc=vr({op:`Exit`,[Gn](e){return e._stack.push(this),this[A]},[Kn](e,t,n){return j(n??br(e))},[qn](e,t,n){return j(n??Cr(e))}}),$c=`~effect/Scope`,el=`~effect/Scope/Closeable`,tl=da(`effect/Scope`),nl=(e,t)=>zs(()=>rl(e,t)??Gs),rl=(e,t)=>{if(e.state._tag===`Closed`)return;let n={_tag:`Closed`,exit:t};if(e.state._tag===`Empty`){e.state=n;return}let{finalizers:r}=e.state;if(e.state=n,r.size!==0)return r.size===1?r.values().next().value(t):al(e,r,t)},il=(e,t)=>bc(e)?t:Fc(t,t=>Ls(fs(e.cause,t))),al=ec(function*(e,t,n){let r=[],i=[],a=Array.from(t.values()),o=Ds();for(let t=a.length-1;t>=0;t--){let s=a[t];e.strategy===`sequential`?r.push(yield*Zc(s(n))):i.push(zl(o,s(n),!0,!0,`inherit`))}return i.length>0&&(r=yield*Ns(i)),yield*Tc(r)}),ol=(e,t)=>{let n=dl(t);if(e.state._tag===`Closed`)return n.state=e.state,n;let r={};return ll(e,r,e=>nl(n,e)),ll(n,r,t=>M(()=>ul(e,r))),n},sl=(e,t)=>zs(()=>e.state._tag===`Closed`?t(e.state.exit):(ll(e,{},t),Gs)),cl=(e,t)=>sl(e,ut(t)),ll=(e,t,n)=>{e.state._tag===`Empty`?e.state={_tag:`Open`,finalizers:new Map([[t,n]])}:e.state._tag===`Open`&&e.state.finalizers.set(t,n)},ul=(e,t)=>{e.state._tag===`Open`&&e.state.finalizers.delete(t)},dl=(e=`sequential`)=>({[el]:el,[$c]:$c,strategy:e,state:fl}),fl={_tag:`Empty`},pl=tl,ml=Mc(tl),hl=e=>N(pl,t=>Ac(n=>sl(t,t=>jc(e(t),n)))),gl=vr({op:`OnExit`,single:!1,[Gn](e){return e._stack.push(this),this[A][0]},[Jn](e){e.interruptible&&this[A][2]!==!0&&(e._stack.push(Ol),e.interruptible=!1)},[Kn](e,t,n){n??=br(e);let r=this[A][1](n);return r?N(r,e=>n):n},[qn](e,t,n){n??=Cr(e);let r=this[A][1](n);return r?N(il(n,r),e=>n):n}}),_l=T(2,gl),vl=T(2,(e,t)=>_l(e,e=>t)),yl=T(3,(e,t,n)=>_l(e,e=>{let r=t(e);return Ci(r)?Gs:n(r.success,e)})),bl=T(2,(e,t)=>yl(e,xc,t)),xl=T(3,(e,t,n)=>_l(e,e=>{if(e._tag!==`Failure`)return Gs;let r=t(e.cause);return Ci(r)?Gs:n(r.success,e.cause)})),Sl=T(2,(e,t)=>xl(ds,t)(e)),Cl=T(2,(e,t)=>M(()=>{let n=yo(eo(t)),r=Number.isFinite(n),i=nu(!1),a=0,o=!1,s,c=N(i.await,()=>s);return[Er(t=>{let l=t.getRef(pu),u=r?l.currentTimeMillisUnsafe():0;return o||u<a?s??c:(o=!0,i.closeUnsafe(),s=void 0,_l(e,e=>M(()=>{o=!1,a=l.currentTimeMillisUnsafe()+n,s=e,i.openUnsafe()})))}),M(()=>{a=0,i.closeUnsafe(),s=void 0})]})),wl=T(2,(e,t)=>_c(Cl(e,t),e=>e[0])),Tl=e=>wl(e,lo),El=e=>Er(t=>t.interruptible?(t.interruptible=!1,t._stack.push(Ol),e):e),Dl=vr({op:`SetInterruptible`,[Jn](e){if(e.interruptible=this[A],e._interruptedCause&&e.interruptible)return()=>Ls(e._interruptedCause)}}),Ol=Dl(!0),kl=Dl(!1),Al=e=>{if(e.interruptible=!0,e._stack.push(kl),e._interruptedCause)return Ls(e._interruptedCause)},jl=e=>Er(t=>t.interruptible?e:Al(t)??e),Ml=e=>Er(t=>t.interruptible?(t.interruptible=!1,t._stack.push(Ol),e(jl)):e(E)),Nl=vr({op:`While`,[Kn](e,t){return this[A].step(e),this[A].while()?(t._stack.push(this),this[A].body()):Sc},[Gn](e){return this[A].while()?(e._stack.push(this),this[A].body()):Sc}}),Pl=T(e=>typeof e[1]==`function`,(e,t,n)=>zs(()=>{let r=n?.concurrency??1,i=r===`unbounded`?1/0:Math.max(1,r);if(i===1)return Fl(e,t,n);let a=ji(e),o=a.length;if(o===0)return n?.discard?Gs:j([]);let s=n?.discard?void 0:Array(o),c=Rl({f:t,out:s},a,{concurrency:i});return c?cc(c,s):j(s)})),Fl=(e,t,n)=>zs(()=>{let r=n?.discard?void 0:[],i=e[Symbol.iterator](),a=i.next(),o=0;return cc(Nl({while:()=>!a.done,body:()=>t(a.value,o++),step:e=>{r&&r.push(e),a=i.next()}}),r)}),Il=e=>{let t=e.onItem,n=e.step,r=(e,i,a,o)=>{for(;a<o;a++){let s=i[a],c=t(e,s,a);if(!mc(c))return N(Zc(c),t=>n(e,s,t,a)??r(e,i,a+1,o)??Gs);let l=n(e,s,c,a);if(l)return l._tag===`Failure`?l:void 0}};return(e,i,a)=>{let o=0,s=a?.end??i.length,c=a?.concurrency??1;if(c===1)return r(e,i,0,s);let l=a?.orderedStep===!0&&c>1,u=!1,d,f,p,m=!1,h,g,_=o,v=l?Array(s):void 0,y=e=>{let t=Tr(e);return h=t,u=!0,m=!0,f&&f.size>0?N(El(Is(Array.from(f))),()=>t):t},b=(t,r,a)=>{if(!l)return n(e,t,r,a);if(h)return h;for(v[a]=r;_<s;){let t=v[_];if(t===void 0)return;v[_]=void 0;let r=_++,a=n(e,i[r],t,r);if(a)return a}},ee=()=>{let n=!1;for(;!h&&o<s;o++){let r=i[o],a=g??t(e,r,o);if(mc(a)){if(h=b(r,a,o),h)break}else if(d){g=void 0;let e=zl(d,a,!0,!0,`inherit`);if(e._exit){if(h=b(r,e._exit,o),h)break;continue}f.add(e);let t=o;if(e.addObserver(i=>{f.delete(e);try{if(h){if(!m&&i._tag===`Failure`)for(let e of i.cause.reasons)if(e._tag===`Interrupt`)continue;else h._tag===`Failure`?h.cause.reasons.push(e):h=Cr(cr([e]))}else{let e=b(r,i,t);e&&(h=e._tag===`Failure`?Cr(cr(e.cause.reasons.slice())):e,ee())}if(n){let e=ee();e&&p(e)}else u&&f.size===0&&p(h??Gs)}catch(e){p(y(e))}}),f.size<c)continue;n=!0,o++;return}else return Zs(e=>{d=Ds(),f=new Set,g=a,p=e;let t;try{t=ee()}catch(t){return e(y(t))}return t?e(t):zs(()=>(h=Sc,m=!0,f?Is(f):Gs))})}if(u=!0,h){if(f&&f.size>0){let e=js(d);f.forEach(t=>t.interruptUnsafe(d.id,e));return}if(p||h._tag===`Failure`)return h}else if(p){if(f)f.size===0&&p(Gs);else return Sc}};return ee()}},Ll=()=>Il,Rl=Il({onItem(e,t,n){return e.f(t,n)},step(e,t,n,r){if(n._tag===`Failure`)return n;e.out&&(e.out[r]=n.value)}}),zl=(e,t,n=!1,r=!1,i=!1)=>{let a=e,o=i===`inherit`?a.interruptible:!i,s=new Os(a.context,o);return n?s.evaluate(t):a.currentDispatcher.scheduleTask(()=>s.evaluate(t),0),!r&&!s._exit&&(a.children().add(s),s.addObserver(()=>a._children.delete(s))),s},Bl=e=>(t,n)=>{let r=new Os(n?.scheduler?Ma(e,To,n.scheduler):e,n?.uninterruptible!==!0);if(r.evaluate(t),r._exit)return r;if(n?.signal){if(n.signal.aborted)r.interruptUnsafe();else{let e=()=>r.interruptUnsafe();n.signal.addEventListener(`abort`,e,{once:!0}),r.addObserver(()=>n.signal.removeEventListener(`abort`,e))}}return n?.onFiberStart&&n.onFiberStart(r),r},Vl=T(2,(e,t)=>{if(e._exit)return e;if(t.state._tag===`Closed`)return e.interruptUnsafe(e.id),e;let n={};return ll(t,n,()=>Ps(e)),e.addObserver(()=>ul(t,n)),e}),Hl=Bl(ka()),Ul=e=>{let t=Bl(e);return(e,n)=>{let r=t(e,n);return n?.onExit&&r.addObserver(n.onExit),e=>r.interruptUnsafe(e)}},Wl=Ul(ka()),Gl=e=>{let t=Bl(e);return(e,n)=>{let r=t(e,n);return new Promise(e=>{r.addObserver(t=>e(t))})}},Kl=Gl(ka()),ql=e=>{let t=Gl(e);return(e,n)=>t(e,n).then(e=>{if(e._tag===`Failure`)throw hs(e.cause);return e.value})},Jl=ql(ka()),Yl=e=>{let t=Bl(e);return e=>{if(mc(e))return e;let n=new ko(`sync`),r=t(e,{scheduler:n});return r._dispatcher?.flush(),r._exit??Tr(new Su(r))}},Xl=Yl(ka()),Zl=e=>{let t=Yl(e);return e=>{let n=t(e);if(n._tag===`Failure`)throw hs(n.cause);return n.value}},Ql=Zl(ka()),$l=j(!0),eu=j(!1),tu=class{waiters=[];scheduled=void 0;_isOpen;constructor(e){this._isOpen=e}scheduleUnsafe(e){if(this.waiters.length===0)return $l;if(this.scheduled===void 0)this.scheduled=this.waiters,e.currentDispatcher.scheduleTask(this.flushScheduled,0);else for(let e=0;e<this.waiters.length;e++)this.scheduled.push(this.waiters[e]);return this.waiters=[],$l}flushScheduled=()=>{if(this.scheduled===void 0)return;let e=this.scheduled;this.scheduled=void 0;for(let t=0;t<e.length;t++)e[t](Sc)};flushWaiters(){let e=this.waiters;this.waiters=[],this.flushScheduled();for(let t=0;t<e.length;t++)e[t](Sc)}open=Er(e=>this._isOpen?eu:(this._isOpen=!0,this.scheduleUnsafe(e)));release=Er(e=>this._isOpen?eu:this.scheduleUnsafe(e));openUnsafe(){return!this._isOpen&&(this._isOpen=!0,this.flushWaiters(),!0)}await=Zs(e=>this._isOpen?e(Gs):(this.waiters.push(e),M(()=>{let t=this.waiters.indexOf(e);t===-1?this.scheduled!==void 0&&(t=this.scheduled.indexOf(e),t!==-1&&this.scheduled.splice(t,1)):this.waiters.splice(t,1)})));closeUnsafe(){return this._isOpen?(this._isOpen=!1,!0):!1}close=M(()=>this.closeUnsafe());whenOpen=e=>N(this.await,()=>e);isOpen(){return this._isOpen}},nu=e=>new tu(e??!1),ru=BigInt(0),iu={_tag:`Span`,spanId:`noop`,traceId:`noop`,sampled:!1,status:{_tag:`Ended`,startTime:ru,endTime:ru,exit:Sc},attributes:new Map,links:[],kind:`internal`,attribute(){},event(){},end(){},addLinks(){}},au=e=>Object.assign(Object.create(iu),e),ou=e=>e?La(e.annotations,zo)?e._tag===`Span`?ou(_i(e.parent)):ui():di(e):ui(),su=(e,t,n)=>{let r=!e.getRef(Jo)||n?.annotations&&La(n.annotations,zo),i=n?.parent===void 0?n?.root?ui():ou(e.currentSpan):di(n.parent),a;if(r)a=au({name:t,parent:i,annotations:Ma(n?.annotations??ka(),zo,!0)});else{let r=e.getRef(Uo),o=e.getRef(pu),s=e.getRef(Yo),c=e.getRef(Xo),l=e.getRef(Zo),u=n?.level??e.getRef(Bo),d=n?.links===void 0?l.length===0?[]:l.slice():[...l,...n.links];a=r.span({name:t,parent:i,annotations:n?.annotations??ka(),links:d,startTime:s?o.currentTimeNanosUnsafe():BigInt(0),kind:n?.kind??`internal`,root:n?.root??fi(i),sampled:n?.sampled??(pi(i)&&i.value.sampled===!1?!1:!Tu(e.getRef(Vo),u))});for(let e in c)a.attribute(e,c[e]);if(n?.attributes!==void 0)for(let e in n.attributes)a.attribute(e,n.attributes[e])}return a},cu=(e,t)=>(t=typeof t==`function`?t:pt,Dc(qo,n=>({name:e,stack:t,parent:n}))),lu=(e,t,n,r)=>M(()=>{e.status._tag!==`Ended`&&e.end(r?n.currentTimeNanosUnsafe():ru,t)}),uu=(e,...t)=>{let n=t.length===1?void 0:t[0],r=t[t.length-1];return Er(t=>{let i=su(t,e,n),a=t.getRef(pu),o=t.getRef(Yo);return _l(Bn(()=>r(i)),e=>lu(i,e,a,o))})},du=Mc(Lo),fu=function(){let e=Qn(arguments[0]),t=e?arguments[1]:arguments[0],n=e?arguments[2]:arguments[1],r=E;return t._tag===`Span`&&(n=rs(n),r=cu(t.name,n?.captureStackTrace)),e?du(r(arguments[0]),t):e=>du(r(e),t)},pu=Ua(`effect/Clock`,{defaultValue:()=>new hu}),mu=2**31-1,hu=class{currentTimeMillisUnsafe(){return Date.now()}currentTimeMillis=M(()=>this.currentTimeMillisUnsafe());currentTimeNanosUnsafe(){return vu()}currentTimeNanos=M(()=>this.currentTimeNanosUnsafe());monotonicTimeNanosUnsafe(){return _u()}monotonicTimeNanos=M(()=>this.monotonicTimeNanosUnsafe());sleep(e){return this.sleepMillis(yo(e))}sleepMillis(e){return e<=0?Bs:Number.isFinite(e)?Zs(t=>{let n=e>mu?this.sleepMillis(e-mu):Gs,r=setTimeout(()=>t(n),Math.min(e,mu));return M(()=>clearTimeout(r))}):Qs}},gu=BigInt(1e6),_u=function(){let e=globalThis.process?.hrtime;if(typeof e?.bigint==`function`)return()=>e.bigint();if(typeof performance<`u`&&typeof performance.now==`function`)return()=>BigInt(Math.round(performance.now()*1e6));let t=BigInt(0);return()=>{let e=BigInt(Date.now())*gu;return e>t&&(t=e),t}}(),vu=function(){let e=BigInt(1e9),t;return()=>{let n=_u(),r=BigInt(Date.now())*gu;if(t===void 0)t=r-n;else{let i=t+n;(r>i?r-i:i-r)>e&&(t=r-n)}return t+n}}(),yu=e=>Er(t=>e(t.getRef(pu))),bu=e=>yu(t=>t.sleep(eo(e)));kr(`TimeoutError`),kr(`IllegalArgumentError`),kr(`ExceededCapacityError`);var xu=`~effect/Cause/AsyncFiberError`,Su=class extends kr(`AsyncFiberError`){[xu]=xu;constructor(e){super({message:`An asynchronous Effect was executed with Effect.runSync`,fiber:e})}},Cu=`~effect/Cause/UnknownError`,wu=class extends kr(`UnknownError`){[Cu]=Cu;constructor(e,t){super({message:t,cause:e})}},Tu=si(ii(ri,e=>{switch(e){case`All`:return-(2**53-1);case`Fatal`:return 5e4;case`Error`:return 4e4;case`Warn`:return 3e4;case`Info`:return 2e4;case`Debug`:return 1e4;case`Trace`:return 0;case`None`:return 2**53-1}})),Eu={bold:`1`,red:`31`,green:`32`,yellow:`33`,blue:`34`,cyan:`36`,white:`37`,gray:`90`,black:`30`,bgBrightRed:`101`};Eu.gray,Eu.blue,Eu.green,Eu.yellow,Eu.red,Eu.bgBrightRed,Eu.black;var Du=(e,t,n)=>{let r=e.getRef(Ko);if(r.size===0||n&&!ls(t))return;let i={cause:t,fiber:e,timestamp:e.getRef(pu).currentTimeNanosUnsafe()};r.forEach(e=>e.report(i))},Ou=pr,ku=cr,Au=lr,ju=ps,Mu=hs,Nu=us,Pu=jr,Fu=Fr;da()(`effect/Cause/StackTrace`),da()(`effect/Cause/InterruptorStackTrace`);var Iu=br,Lu=Cr,Ru=wr,zu=Sc,Bu=bc,Vu={"~effect/Deferred":{_A:E,_E:E},pipe(){return st(this,arguments)}},Hu=()=>{let e=Object.create(Vu);return e.resumes=void 0,e.effect=void 0,e},Uu=()=>M(()=>Hu()),Wu=e=>Zs(t=>e.effect?t(e.effect):(e.resumes??=[],e.resumes.push(t),M(()=>{let n=e.resumes;if(n===void 0)return;let r=n.indexOf(t);r>=0&&n.splice(r,1)}))),Gu=T(2,(e,t)=>M(()=>qu(e,t))),Ku=T(2,(e,t)=>Gu(e,br(t))),qu=(e,t)=>{if(e.effect)return!1;if(e.effect=t,e.resumes){let n=e.resumes;e.resumes=void 0;for(let e=0;e<n.length;e++)n[e](t)}return!0},Ju=dl,Yu=ml,Xu=sl,Zu=cl,Qu=ol,$u=nl,ed=`~effect/Layer`,td=`~effect/Layer/MemoMap`,nd=(e,t)=>(e.observers++,uc(sl(t,t=>e.finalizer(t)),e.effect)),rd={[ed]:{_ROut:E,_E:E,_RIn:E},pipe(){return st(this,arguments)}},id=e=>{let t=Object.create(rd);return t.build=e,t},ad=e=>id((t,n)=>{let r=Qu(n);return _l(e(t,r),e=>e._tag===`Failure`?$u(r,e):Gs)}),od=e=>{let t=ad((n,r)=>n.getOrElseMemoize(t,r,e));return t},sd=(e,t,n,r)=>{let i=Ju(),a=Hu(),o={observers:1,effect:Wu(a),finalizer:n=>zs(()=>(o.observers--,o.observers===0?(e.map.delete(t),$u(i,n)):Gs))};return e.map.set(t,o),sl(n,o.finalizer).pipe(N(()=>r(e,i)),_l(e=>(o.effect=e,Gu(a,e))))},cd=class{get[td](){return td}parent;constructor(e){this.parent=e}map=new Map;get(e,t){let n=this.map.get(e);return n?nd(n,t):this.parent?.get(e,t)}getOrElseMemoize(e,t,n){return zs(()=>this.get(e,t)||sd(this,e,t,n))}},ld=()=>new cd,ud=e=>new cd(e),dd=class e extends da()(`effect/Layer/CurrentMemoMap`){static forkOrCreate(t){let n=Pa(t,e);return n?ud(n):ld()}},fd=T(3,(e,t,n)=>Mc(_c(e.build(t,n),Ma(dd,t)),dd,t)),pd=function(){return arguments.length===1?e=>md(ja(arguments[0],e)):md(ja(arguments[0],arguments[1]))},md=e=>id(ut(j(e))),hd=function(){return arguments.length===1?e=>gd(()=>ja(arguments[0],e())):gd(()=>ja(arguments[0],arguments[1]()))},gd=e=>od(ut(M(e))),_d=function(){return arguments.length===1?e=>vd(arguments[0],e):vd(arguments[0],arguments[1])},vd=(e,t)=>yd(_c(t,t=>ja(e,t))),yd=e=>od((t,n)=>Yu(e,n)),bd=(e,t,n)=>{let r=Qu(n,`parallel`);return Pl(e,e=>e.build(t,Qu(r,`sequential`)),{concurrency:e.length}).pipe(_c(e=>Ha(...e)))},xd=(e,t,n)=>ad((r,i)=>N(Array.isArray(t)?bd(t,r,i):t.build(r,i),t=>e.build(r,i).pipe(jc(t),_c(e=>n(e,t))))),Sd=T(2,(e,t)=>xd(e,t,E)),Cd=T(2,(e,t)=>xd(e,t,(e,t)=>Va(t,e))),wd=`~effect/time/DateTime`,Td=`~effect/time/DateTime/TimeZone`,Ed={[wd]:wd,pipe(){return st(this,arguments)},[Fn](){return this.toString()},toJSON(){return Md(this).toJSON()}},Dd={...Ed,_tag:`Utc`,[Nt](){return Rt(this.epochMilliseconds)},[Xt](e){return kd(e)&&e._tag===`Utc`&&this.epochMilliseconds===e.epochMilliseconds},toString(){return`DateTime.Utc(${Md(this).toJSON()})`}};({...Ed});var Od={[Td]:Td,[Fn](){return this.toString()}};({...Od}),{...Od};var kd=e=>D(e,wd),Ad=e=>{let t=Object.create(Dd);return t.epochMilliseconds=e,Object.defineProperty(t,"partsUtc",{value:void 0,enumerable:!1,writable:!0}),t},jd=()=>Ad(Date.now()),Md=e=>new Date(e.epochMilliseconds),Nd=e=>e.epochMilliseconds;globalThis.String;var Pd=ni,Fd=T(2,(e,t)=>Lc(e,Rd,e=>t(e))),Id=e=>e._tag===`Fail`&&Pu(e.error),Ld=e=>{let t,n=!1;for(let r of e.reasons)Id(r)?t??=r.error:r._tag!==`Interrupt`&&(n=!0);return t===void 0?xi(e):n?xi(ku(e.reasons.filter(e=>!Id(e)))):bi(t)},Rd=e=>{let t=Ld(e);return Ci(t)?t:bi(t.success.value)},zd=e=>{let t=Ld(e);return Ci(t)?Lu(t.failure):Iu(t.success.value)},Bd=Qn,Vd=Pl,Hd=qs,Ud=Js,P=j,Wd=Vs,Gd=zs,Kd=M,qd=Gs,Jd=Zs,Yd=$s,F=Rs,Xd=Ls,Zd=Hs,Qd=Us,$d=Ks,ef=Er,tf=N,nf=gc,rf=uc,af=dc,of=Gc,sf=Zc,cf=_c,lf=cc,uf=fc,df=Hc,ff=Fc,I=Uc,pf=Bc,mf=bu,hf=Kc,gf=Oc,_f=Ac,vf=jc,yf=Ec,bf=Mc,xf=hl,Sf=vl,Cf=bl,wf=_l,Tf=Tl,Ef=Sl,Df=Ml,Of=Pc,kf=uu,Af=fu,jf=Hl,Mf=Bl,Nf=Ul,Pf=Wl,Ff=Jl,If=ql,Lf=Kl,Rf=Gl,L=Ql,zf=Zl,Bf=Xl,Vf=Yl,Hf=ec,R=rc;da()(`effect/Effect/Transaction`);var Uf=vc,Wf=yc,Gf=hc,Kf=ac;function qf(e){return e.checks?e.checks[e.checks.length-1].annotations:e.annotations}function Jf(e){return t=>qf(t)?.[e]}var Yf=`~structural`,Xf=`~sentinels`,Zf=`~constructor`,Qf=Jf(`brands`),$f=ht(e=>{let t=qf(e)?.identifier;return typeof t==`string`?t:e.getExpected($f)}),z=Symbol(),ep=Iu,tp=ep(z),np=ep(z),rp=e=>e===z?ui():di(e),ip=e=>e._tag===`None`?tp:ep(e.value),ap=`~effect/SchemaIssue/Issue`;function op(e){return D(e,ap)&&e[ap]===ap}function sp(e){return Object.hasOwn(e,`input`)}var cp=class{[ap]=ap;constructor(e,t){t?.reportInput===!0&&e!==z&&(this.input=e)}},lp=class extends cp{_tag=`Filter`;filter;issue;constructor(e,t,n,r){super(n,r),this.filter=e,this.issue=t}},up=class extends cp{_tag=`Encoding`;ast;issue;constructor(e,t,n,r){super(n,r),this.ast=e,this.issue=t}},dp=class extends cp{_tag=`Pointer`;path;issue;constructor(e,t){super(),this.path=e,this.issue=t}},fp=class extends cp{_tag=`MissingKey`;annotations;constructor(e){super(),this.annotations=e}},pp=class extends cp{_tag=`UnexpectedKey`;ast;constructor(e,t,n){super(t,n),this.ast=e}},mp=class extends cp{_tag=`Composite`;ast;issues;constructor(e,t,n,r){super(n,r),this.ast=e,this.issues=t}},hp=class extends cp{_tag=`InvalidType`;ast;constructor(e,t,n){super(t,n),this.ast=e}},gp=class extends cp{_tag=`InvalidValue`;annotations;constructor(e,t,n){super(t,n),this.annotations=e}},_p=class extends cp{_tag=`AnyOf`;ast;issues;constructor(e,t,n,r){super(n,r),this.ast=e,this.issues=t}},vp=class extends cp{_tag=`OneOf`;ast;successes;constructor(e,t,n,r){super(n,r),this.ast=e,this.successes=t}};function yp(e,t,n){if(op(e))return e;if(typeof e==`string`)return new gp({message:e},t,n);let r=typeof e.issue==`string`?new gp({message:e.issue},t,n):e.issue;return new dp(e.path,r)}function bp(e,t,n){if(e!==void 0)return typeof e==`boolean`?e?void 0:new gp(void 0,t,n):yp(e,t,n)}function xp(e,t,n,r){return Array.isArray(t)?Li(t)?t.length===1?yp(t[0],n,r):new mp(e,Ui(t,e=>yp(e,n,r)),n,r):void 0:bp(t,n,r)}var Sp=e=>{let t=jp(e);if(t!==void 0)return t;switch(e._tag){case`InvalidType`:return Ep($f(e.ast),e);case`InvalidValue`:{let t=Tp(e);if(t!==void 0)return Ep(t,e);let n=wp(e);return n===void 0?`Expected a valid value`:`Invalid data ${n}`}case`MissingKey`:return`Missing key`;case`UnexpectedKey`:{let t=wp(e);return t===void 0?`Expected no excess property`:`Unexpected key with value ${t}`}case`Forbidden`:return`Forbidden operation`;case`OneOf`:{let t=wp(e);return t===void 0?`Expected exactly one member to match`:`Expected exactly one member to match the input ${t}`}}},Cp=e=>jp(e.issue)??jp(e);function wp(e){return sp(e)?k(e.input):void 0}function Tp(e){let t=e.annotations?.expected;return typeof t==`string`?t:void 0}function Ep(e,t){let n=wp(t);return n===void 0?`Expected ${e}`:`Expected ${e}, got ${n}`}function Dp(e){let t=e.annotations?.expected;if(typeof t==`string`)return t;switch(e._tag){case`Filter`:return`<filter>`;case`FilterGroup`:return e.checks.map(e=>Dp(e)).join(` & `)}}function Op(){return e=>Ap(e,``)}var kp=Op();function Ap(e,t){let n;switch(e._tag){case`Filter`:{let r=Cp(e);if(r!==void 0)n=r;else{if(e.issue._tag!==`InvalidValue`)return Ap(e.issue,t);let r=Tp(e.issue);n=r===void 0?Ep(Dp(e.filter),e):Ep(r,e.issue)}break}case`Encoding`:return Ap(e.issue,t);case`Pointer`:return Ap(e.issue,t+jn(e.path));case`Composite`:case`AnyOf`:if(e._tag===`Composite`||e.issues.length>0)return e.issues.map(e=>Ap(e,t)).join(`
12
+ `);n=jp(e)??Ep($f(e.ast),e);break;default:n=Sp(e)}return t?`${n}\n at ${t}`:n}function jp(e){if(e._tag===`Pointer`)return;if(e._tag===`Encoding`)return jp(e.issue);let t=(e._tag===`Filter`?e.filter.annotations:`annotations`in e?e.annotations:e.ast.annotations)?.[e._tag===`MissingKey`?`messageMissingKey`:e._tag===`UnexpectedKey`?`messageUnexpectedKey`:`message`];if(typeof t==`string`)return t}function Mp(e){let t;for(let n of e.reasons){if(!Ou(n)||!op(n.error))return;t??=n.error}return t}function Np(e,t){let n=Mp(e);if(n===void 0)throw Error(t,{cause:e});return n}var Pp=jd,Fp=Nd;da()(`effect/DateTime/CurrentTimeZone`);var Ip=class e extends lt{run;constructor(e){super(),this.run=e}map(t){return new e((e,n)=>this.run(e,n).pipe(Uf(vi(t))))}compose(t){return Rp(this)?t:Rp(t)?this:new e((e,n)=>this.run(e,n).pipe(Gf(e=>t.run(e,n))))}},Lp=new Ip(P);function Rp(e){return e.run===Lp.run}function zp(){return Lp}function Bp(e){return new Ip((t,n)=>fi(t)?Wd:e(t.value,n))}function Vp(e){return Up(vi(e))}function Hp(e){return Bp((t,n)=>e(t,n).pipe(Uf(di)))}function Up(e){return new Ip(t=>P(e(t)))}function Wp(e){return new Ip(t=>{let n=yi(t,Tt);return pi(n)?P(n):Uf(e,di)})}function Gp(){return Vp(globalThis.String)}function Kp(){return Vp(globalThis.Number)}function qp(){return Vp(e=>new globalThis.Date(e))}function Jp(e){return Bp((t,n)=>$d({try:()=>di(JSON.parse(t,e?.reviver)),catch:()=>new gp({expected:`a valid JSON string`},t,n)}))}function Yp(e){return Bp((t,n)=>$d({try:()=>{let n=JSON.stringify(t,e?.replacer,e?.space);if(n===void 0)throw TypeError(`Value cannot be represented as JSON`);return di(n)},catch:()=>new gp({expected:`a JSON-serializable value`},t,n)}))}var Xp=`~effect/SchemaTransformation/Transformation`,Zp=class e{[Xp]=Xp;_tag=`Transformation`;decode;encode;constructor(e,t){this.decode=e,this.encode=t}flip(){return new e(this.encode,this.decode)}compose(t){return new e(this.decode.compose(t.decode),t.encode.compose(this.encode))}};function Qp(e){return D(e,Xp)&&e[Xp]===Xp}var $p=e=>Qp(e)?e:new Zp(e.decode,e.encode);function em(e){return new Zp(Vp(e.decode),Vp(e.encode))}var tm=new Zp(zp(),zp());function nm(){return tm}var rm=new Zp(Kp(),Gp()),im=new Zp(qp(),Vp(Mn)),am=new Zp(qp(),Vp(e=>e.getTime())),om=e=>kt(e)&&typeof e.message==`string`,sm=e=>{let t=Object.hasOwn(e,`cause`)?Error(e.message,{cause:dm(e.cause)}):Error(e.message);return typeof e.name==`string`&&e.name!==`Error`&&(t.name=e.name),typeof e.stack==`string`&&(t.stack=e.stack),t},cm=e=>{try{let t=Pn(e);return t===void 0?k(e):JSON.parse(t)}catch{return k(e)}},lm=(e,t,n)=>{let r={name:e.name,message:typeof e.message==`string`?e.message:``};return t?.includeStack&&typeof e.stack==`string`&&(r.stack=e.stack),!t?.excludeCause&&e.cause!==void 0&&(r.cause=n(e.cause)),r},um=e=>{let t=new WeakSet,n=r=>{if(jt(r)){if(t.has(r))return`[Circular]`;t.add(r);let i=lm(r,e,n);return t.delete(r),i}return cm(r)};return n},dm=e=>om(e)?sm(e):e,fm=e=>em({decode:dm,encode:um(e)});function pm(e){return new Zp(Jp(e??{}),Yp(e))}function mm(e){return t=>t._tag===e}var hm=mm(`Declaration`),gm=mm(`Never`),_m=mm(`Literal`),vm=mm(`UniqueSymbol`),ym=mm(`Arrays`),bm=mm(`Objects`),xm=mm(`Suspend`),Sm=class{to;transformation;constructor(e,t){this.to=e,this.transformation=t}},Cm={},wm=class{isOptional;isMutable;constructorDefault;annotations;constructor(e,t,n=void 0,r=void 0){this.isOptional=e,this.isMutable=t,this.constructorDefault=n,this.annotations=r}},Tm=`~effect/Schema`,Em=class{[Tm]=Tm;annotations;checks;encoding;context;constructor(e=void 0,t=void 0,n=void 0,r=void 0){this.annotations=e,this.checks=t,this.encoding=n,this.context=r}toString(){return`<${this._tag}>`}},Dm=class e extends Em{_tag=`Declaration`;typeParameters;run;encodingChecks;constructor(e,t,n,r,i,a,o){super(n,r,i,a),this.typeParameters=e,this.run=t,this.encodingChecks=o}getParser(){let e;return(t,n)=>t===z?tp:(e??=this.run(this.typeParameters))(t,this,n)}_rebuild(t,n,r){let i=Wh(this.typeParameters,t);return i===this.typeParameters&&n===this.checks&&r===this.encodingChecks?this:new e(i,this.run,this.annotations,n,void 0,this.context,r)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}getExpected(){let e=this.annotations?.expected;return typeof e==`string`?e:`<Declaration>`}},Om=new class extends Em{_tag=`Null`;getParser(){return sg(this,null)}getExpected(){return`null`}},km=class extends Em{_tag=`Undefined`;getParser(){return sg(this,void 0)}toCodecJson(){return Mh(this,[Am])}getExpected(){return`undefined`}},Am=new Sm(Om,new Zp(Vp(()=>void 0),Vp(()=>null))),jm=new km,Mm=new class extends Em{_tag=`Unknown`;getParser(){return cg(this,Ot)}getExpected(){return`unknown`}},Nm=new class extends Em{_tag=`ObjectKeyword`;getParser(){return cg(this,At)}getExpected(){return`object | array | function`}};function Pm(e){switch(e._tag){case`String`:case`Number`:case`BigInt`:return!0;case`Literal`:case`TemplateLiteral`:return!e.checks;case`Union`:return!e.checks&&e.types.every(Pm);default:return!1}}var Fm=class extends Em{_tag=`TemplateLiteral`;parts;encodedParts;literals;suffixLengths;constructor(e,t,n,r,i){super(t,n,r,i);let a=[],o=[];for(let t of e){let e=rg(t);if(Pm(e))a.push(e),o.push(e._tag===`Literal`?globalThis.String(e.literal):void 0);else throw Error(`Invalid TemplateLiteral part ${e._tag}`)}let s=Array(a.length+1);s[a.length]=0;for(let e=a.length-1;e>=0;e--)s[e]=s[e+1]+(o[e]?.length??0);this.parts=e,this.encodedParts=a,this.literals=o,this.suffixLengths=s}getParser(e){let t=e(this.asTemplateLiteralParser());return(e,n)=>{if(e===z)return tp;let r=t(e,n);return r._tag===`Success`?np:Wf(r,{onSuccess:()=>e,onFailure:t=>new mp(this,[t],e,n)})}}getExpected(){return`string`}matchPart(e,t){return lg(this,e,t)===void 0?void 0:e}asTemplateLiteralParser(){return Xh(Rm,new Um(!1,this.parts.map(fg),[]),new Zp(Hp((e,t)=>{let n=lg(this,e,t);return n?P(n):F(new gp({expected:`a string matching template literal parts`},e,t))}),Vp(e=>e.join(``))))}},Im=class extends Em{_tag=`Literal`;literal;constructor(e,t,n,r,i){if(super(t,n,r,i),typeof e==`number`&&!globalThis.Number.isFinite(e))throw Error(`A numeric literal must be finite, got ${k(e)}`);this.literal=e}getParser(){return sg(this,this.literal)}matchPart(e,t){return e===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return typeof this.literal==`bigint`?Lm(this):this}toCodecStringTree(){return typeof this.literal==`string`?this:Lm(this)}getExpected(){return typeof this.literal==`string`?JSON.stringify(this.literal):globalThis.String(this.literal)}};function Lm(e){let t=globalThis.String(e.literal);return Mh(e,[new Sm(new Im(t),new Zp(Vp(()=>e.literal),Vp(()=>t)))])}var Rm=new class extends Em{_tag=`String`;getParser(){return cg(this,yt)}matchPart(e,t){let n=this.checks;return n&&!t.disableChecks&&yg(n,e,void 0,this,t)?void 0:e}getExpected(){return`string`}},zm=class extends Em{_tag=`Number`;getParser(){return cg(this,bt)}matchKey(e,t){return this._match(mg,e,t)}matchPart(e,t){return this._match(pg,e,t)}_match(e,t,n){if(!e.test(t))return;let r=globalThis.Number(t);return n.disableChecks||!this.checks?r:yg(this.checks,r,void 0,this,n)?void 0:r}toCodecJson(){return this.checks&&(Bm(this.checks,`effect/schema/isFinite`)||Bm(this.checks,`effect/schema/isInt`))?this:Mh(this,[Dh])}toCodecStringTree(){return this.toCodecJson()===this?Mh(this,[_g]):Mh(this,[vg])}getExpected(){return`number`}};function Bm(e,t){return e.some(e=>e.annotations?.representation?.id===t||e._tag===`FilterGroup`&&Bm(e.checks,t))}var Vm=new zm,Hm=new class extends Em{_tag=`Boolean`;getParser(){return cg(this,xt)}getExpected(){return`boolean`}},Um=class e extends Em{_tag=`Arrays`;isMutable;elements;rest;encodingChecks;constructor(e,t,n,r,i,a,o,s){super(r,i,a,o),this.isMutable=e,this.elements=t,this.rest=n,this.encodingChecks=s;let c=!1;for(let e=0;e<t.length;e++)if($h(t[e]))c=!0;else if(c)throw Error(`A required element cannot follow an optional element. ts(1257)`);if(c&&n.length>1)throw Error(`A required element cannot follow an optional element. ts(1257)`);for(let e=1;e<n.length;e++)if($h(n[e]))throw Error(`An optional element cannot follow a rest element. ts(1266)`)}getParser(e,t=e){let n=this,r,i,a=n.elements.length,o=Math.max(0,n.rest.length-1);function s(e,t){return t<a?r[t]:t>=e?i[t-e+1]:i[0]}return Kf(function*(e,c){if(e===z)return z;if(!Array.isArray(e))return yield*F(new hp(n,e,c));r||(r=n.elements.map(e=>({ast:e,parser:t(e)})),i=n.rest.map(e=>({ast:e,parser:t(e)})));let l=e.length,u={ast:n,getParser:s,input:e,len:l,tailThreshold:Math.max(a,l-o),output:new globalThis.Array(l),issues:void 0,options:c},d=Wm(u,e,{concurrency:Gm(c?.concurrency)?.concurrency,end:n.rest.length===0?a:Math.max(l,a+o)});if(d&&(yield*d),n.rest.length===0&&l>a)for(let t=a;t<=l-1;t++){let r=new pp(n,e[t],c),i=new dp([t],r);if(c.errors===`all`)u.issues?u.issues.push(i):u.issues=[i];else return yield*F(new mp(n,[i],e,c))}return u.issues?yield*F(new mp(n,u.issues,e,c)):u.output})}_rebuild(t,n,r){let i=Wh(this.elements,t),a=Wh(this.rest,t);return i===this.elements&&a===this.rest&&n===this.checks&&r===this.encodingChecks?this:new e(this.isMutable,i,a,this.annotations,n,void 0,this.context,r)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}getExpected(){return`array`}},Wm=Ll()({onItem(e,t,n){let r=n<e.len?t:z;return e.getParser(e.tailThreshold,n).parser(r,e.options)},step(e,t,n,r){if(n._tag===`Failure`)return Km(e,e.ast,r,n);let i=n===np?t:n[A];if(i!==z)e.output[r]=i;else{let t=e.getParser(e.tailThreshold,r);if($h(t.ast))return;let n=new dp([r],new fp(t.ast.context?.annotations));if(e.options.errors===`all`)e.issues?e.issues.push(n):e.issues=[n];else return Ru(new mp(e.ast,[n],e.input,e.options))}}}),Gm=e=>(e=e===`unbounded`?1/0:e??1,e>1?{concurrency:e}:void 0),Km=(e,t,n,r)=>{if(r.cause.reasons.length===0)return r;let i=Mp(r.cause);if(i===void 0)return Lu(ju(r.cause,r=>new mp(t,[new dp([n],r)],e.input,e.options)));let a=new dp([n],i);if(e.options.errors===`all`)e.issues?e.issues.push(a):e.issues=[a];else return Ru(new mp(t,[a],e.input,e.options))},qm=`[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?`;function Jm(e,t,n=Cm){let r,i;function a(t){switch(t._tag){case`String`:case`TemplateLiteral`:return(r??=Object.keys(e)).filter(e=>t.matchPart(e,n)!==void 0);case`Number`:return(r??=Object.keys(e)).filter(e=>t.matchKey(e,n)!==void 0);case`Symbol`:return(i??=Object.getOwnPropertySymbols(e)).filter(e=>t.matchKey(e,n)!==void 0);case`Union`:return[...new Set(t.types.flatMap(a))];default:return[]}}return a(ug(rg(t)))}var Ym=class{name;type;constructor(e,t){this.name=e,this.type=t}};function Xm(e){switch(e._tag){case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return!0;case`Union`:return e.types.every(Xm);default:return!1}}function Zm(e){return Xm(e)&&Xm(rg(e))}var Qm=class{parameter;type;constructor(e,t){if(!Zm(e))throw Error(`Invalid index signature parameter ${e._tag}`);if(this.parameter=e,this.type=t,$h(t)&&!og(t))throw Error("Cannot use `Schema.optionalKey` with index signatures, use `Schema.optional` instead.")}},$m=class e extends Em{_tag=`Objects`;propertySignatures;indexSignatures;encodingChecks;constructor(e,t,n,r,i,a,o){super(n,r,i,a),this.propertySignatures=e,this.indexSignatures=t,this.encodingChecks=o;let s=e.map(e=>e.name).filter((e,t,n)=>n.indexOf(e)!==t);if(s.length>0)throw Error(`Duplicate identifiers: ${JSON.stringify(s)}. ts(2300)`)}getParser(e,t=e){let n=this,r=[];for(let e of n.propertySignatures)r.push(e.name);let i=r.length,a=n.indexSignatures.length,o=i&&a?new Set(r):void 0;if(!i&&!a)return cg(n,Dt);let s,c,l=(e,t,r,a,s)=>{if(s._tag===`Failure`)return Km(e,n,t,s)??zu;let c=s===np?a:s[A];if(r!==z&&c!==z){if(i&&(o.has(t)||o.has(r)))return zu;bn(e.out,r,c)}return zu},u=(e,t,r,i)=>{if(!i){let n=r.parserKey(t,e.options);if(!mc(n))return tf(sf(n),n=>u(e,t,r,n));i=n}if(i._tag===`Failure`)return Km(e,n,t,i)??zu;let a=i===np?t:i[A],o=e.input[t],s=r.parserValue(o,e.options);return mc(s)?l(e,t,a,o,s):tf(sf(s),n=>l(e,t,a,o,n))},d=(e,t,n)=>{let r=e.input[t],i=n.parserValue(r,e.options);return mc(i)?l(e,t,t,r,i):tf(sf(i),n=>l(e,t,t,r,n))},f=a?Ll()({onItem:(e,[t,n])=>u(e,t,n),step:(e,t,n)=>n._tag===`Failure`?n:void 0}):void 0;return Kf(function*(l,p){if(l===z)return z;if(!(typeof l==`object`&&l&&!Array.isArray(l)))return yield*F(new hp(n,l,p));s||(s=n.propertySignatures.map(e=>({parser:t(e.type),name:e.name,type:e.type})),c=a?n.indexSignatures.map(n=>({is:n,parserKey:e(ug(n.parameter)),parserValue:t(n.type)})):void 0);let m=l,h={},g={ast:n,input:m,out:h,issues:void 0,options:p},_=p.errors===`all`,v=p.onExcessProperty===`error`,y=p.onExcessProperty===`preserve`,b;if(!a&&(v||y)){o??=new Set(r),b=Reflect.ownKeys(m);for(let e=0;e<b.length;e++){let t=b[e];if(!o.has(t)){if(v){let e=new pp(n,m[t],p),r=new dp([t],e);if(_){g.issues?g.issues.push(r):g.issues=[r];continue}return yield*F(new mp(n,[r],l,p))}bn(h,t,m[t])}}}let ee=Gm(p?.concurrency);if(i){let e=eh(g,s,ee);e&&(yield*e)}if(a&&!ee)for(let e=0;e<a;e++){let t=c[e],n=t.is.parameter===Rm?d:u,r=t.is.parameter===Rm?Object.keys(m):Jm(m,t.is.parameter,p);for(let e=0;e<r.length;e++){let i=n(g,r[e],t);if(!mc(i))yield*i;else if(i._tag===`Failure`)return yield*i}}else if(f){let e=Vi();for(let t=0;t<a;t++){let n=c[t],r=Jm(m,n.is.parameter,p);for(let t=0;t<r.length;t++)e.push([r[t],n])}let t=f(g,e,ee);t&&(yield*t)}if(g.issues)return yield*F(new mp(n,g.issues,l,p));if(p.propertyOrder===`original`){let e=(b??Reflect.ownKeys(m)).concat(r),t={};for(let n of e)Object.hasOwn(h,n)&&bn(t,n,h[n]);return t}return h})}_rebuild(t,n,r,i){let a=Wh(this.propertySignatures,e=>{let n=t(e.type);return n===e.type?e:new Ym(e.name,n)}),o=Wh(this.indexSignatures,e=>{let r=n(e.parameter),i=t(e.type);return r===e.parameter&&i===e.type?e:new Qm(r,i)});return a===this.propertySignatures&&o===this.indexSignatures&&r===this.checks&&i===this.encodingChecks?this:new e(a,o,this.annotations,r,void 0,this.context,i)}flip(e){return this._rebuild(e,e,this.encodingChecks,this.checks)}recur(e,t=e){return this._rebuild(e,t,this.checks,this.encodingChecks)}getExpected(){return this.propertySignatures.length===0&&this.indexSignatures.length===0?`object | array`:`object`}},eh=Ll()({onItem(e,t){if(!Object.hasOwn(e.input,t.name))return t.parser(z,e.options);let n=e.input[t.name];return bn(e.out,t.name,n),t.parser(n,e.options)},step(e,t,n){if(n._tag===`Failure`)return Km(e,e.ast,t.name,n);if(n===np)return;let r=n[A];if(r!==z){bn(e.out,t.name,r);return}if(delete e.out[t.name],!$h(t.type)){let n=new dp([t.name],new fp(t.type.context?.annotations));if(e.options.errors===`all`){e.issues?e.issues.push(n):e.issues=[n];return}return Ru(new mp(e.ast,[n],e.input,e.options))}}});function th(e,t){return e?t?[...e,...t]:e:t}function nh(e,t,n){return new $m(Reflect.ownKeys(e).map(t=>new Ym(t,e[t].ast)),[],n,t)}function rh(e){return e.ast}function ih(e,t,n){return new mh(e.map(rh),t,void 0,n)}function ah(e,t){if(e.encoding||t.some(e=>e.encoding))throw Error(`StructWithRest does not support encodings`);let n=e.propertySignatures,r=e.indexSignatures,i=e.checks;for(let e of t)n=n.concat(e.propertySignatures),r=r.concat(e.indexSignatures),i=th(i,e.checks);return new $m(n,r,void 0,i)}var oh=gt(e=>{for(;;){if(xm(e))return Mm;let t=e.encoding;if(!t)return e.recur?.(oh,E)??e;if(t.some(e=>e.transformation._tag===`Middleware`&&e.transformation.decode!==E))return Mm;e=t[t.length-1].to}});function sh(e){switch(e._tag){case`Null`:return[`null`];case`Undefined`:return[`undefined`];case`String`:case`TemplateLiteral`:return[`string`];case`Number`:return[`number`];case`Boolean`:return[`boolean`];case`Symbol`:case`UniqueSymbol`:return[`symbol`];case`BigInt`:return[`bigint`];case`Arrays`:return[`array`];case`ObjectKeyword`:return[`object`,`array`,`function`];case`Objects`:return e.propertySignatures.length||e.indexSignatures.length?[`object`]:[`string`,`number`,`boolean`,`symbol`,`bigint`,`object`,`array`,`function`];case`Enum`:return Array.from(new Set(e.enums.map(([,e])=>typeof e)));case`Literal`:return[typeof e.literal];case`Union`:return Array.from(new Set(e.types.flatMap(sh)));default:return[`null`,`undefined`,`string`,`number`,`boolean`,`symbol`,`bigint`,`object`,`array`,`function`]}}function ch(e){switch(e._tag){default:return[];case`Declaration`:{let t=e.annotations?.[Xf];return Array.isArray(t)?t:[]}case`Objects`:return e.propertySignatures.flatMap(e=>{let t=e.type;if(!$h(t)){if(_m(t))return[{key:e.name,literal:t.literal}];if(vm(t))return[{key:e.name,literal:t.symbol}]}return[]});case`Arrays`:return e.elements.flatMap((e,t)=>{if(!$h(e)){if(_m(e))return[{key:t,literal:e.literal}];if(vm(e))return[{key:t,literal:e.symbol}]}return[]});case`Union`:{if(e.types.length===0)return[];let t=e.types.map(e=>ch(oh(e)));return t[0].filter(e=>t.every(t=>t.some(t=>t.key===e.key&&t.literal===e.literal)))}case`Suspend`:return ch(e.thunk())}}var lh=new WeakMap,uh=Object.freeze([]);function dh(e){let t=lh.get(e);if(t)return t;let n,r=0,i,a,o=!0;for(let t=0;t<e.length;t++){let s=e[t],c=oh(s);if(gm(c))continue;if(o){if(_m(c)||vm(c)){a??=new Map;let e=_m(c)?c.literal:c.symbol,t=a.get(e);t||a.set(e,t=[]),t.push(s)}else o=!1}let l=ch(c);if(l.length){n??=new Map,r++;for(let{key:e,literal:r}of l){let i=n.get(e);i||n.set(e,i=[new Map,new Set]),i[1].add(t);let a=i[0].get(r);a||i[0].set(r,a=new Set),a.add(t)}}else{i??={};let e=sh(c);for(let n of e)(i[n]??=[]).push(t)}}if(o&&a)a.forEach(Object.freeze),t=e=>a.get(e)??uh;else if(n?.size===1&&!i){let[r,[i]]=n.entries().next().value,a=i;for(let[t,n]of i)a.set(t,Object.freeze(Array.from(n,t=>e[t])));t=(t,n)=>{if(At(t)){let i=Object.hasOwn(t,r)?t[r]:void 0;if(i!==void 0)return a.get(i)??uh;if(n)return e}return uh}}else if(n){let a;for(let e of n)(!a||e[1][0].size>a[1][0].size)&&e[1][1].size===r&&(a=e);t=(t,r)=>{let o=i?.[t===null?`null`:Array.isArray(t)?`array`:typeof t]??uh;if(!At(t))return o.map(t=>e[t]);let s=new Set(o),c;if(a){let[n,[i]]=a,l=Object.hasOwn(t,n),u=l?t[n]:void 0;if(l&&(!r||u!==void 0)){let t=i.get(u);if(!t)return o.map(t=>e[t]);for(let e of t)s.add(e);c=n}}if(c===void 0)for(let[e,[i,a]]of n){let n=Object.hasOwn(t,e),o=n?t[e]:void 0;if(n&&(!r||o!==void 0)){let e=i.get(o);if(e)for(let t of e)s.add(t)}else if(r)for(let e of a)s.add(e)}for(let[e,[i,a]]of n){if(e===c)continue;let n=Object.hasOwn(t,e),o=n?t[e]:void 0;if(n&&(!r||o!==void 0)){let e=i.get(o);for(let t of s)a.has(t)&&!e?.has(t)&&s.delete(t)}}return Array.from(s).sort((e,t)=>e-t).map(t=>e[t])}}else t=t=>(i?.[t===null?`null`:Array.isArray(t)?`array`:typeof t]??uh).map(t=>e[t]).filter(fh(t));return lh.set(e,t),t}function fh(e){return t=>{let n=oh(t);return n._tag===`Literal`?n.literal===e:n._tag!==`UniqueSymbol`||n.symbol===e}}function ph(e,t,n=!1){return dh(t)(e,n)}var mh=class e extends Em{_tag=`Union`;types;mode;encodingChecks;constructor(e,t,n,r,i,a,o){super(n,r,i,a),this.types=e,this.mode=t,this.encodingChecks=o}getParser(e,t){let n=this;return(r,i)=>{if(r===z)return tp;let a=ph(r,n.types,t!==void 0);if(a.length===1){let t=e(a[0])(r,i);return t._tag===`Success`?t:mc(t)?hh(n,t.cause,r,i):ff(t,e=>hh(n,e,r,i))}let o={ast:n,compile:e,input:r,out:void 0,successes:n.mode===`oneOf`?[]:void 0,issues:void 0,options:i},s=Gm(i?.concurrency),c=gh(o,a,s?{...s,orderedStep:!0}:void 0);return c?Gf(c,e=>o.out===np?P(r):o.out?o.out:F(new _p(n,o.issues??[],r,i))):o.out?o.out:F(new _p(n,o.issues??[],r,i))}}_rebuild(t,n,r){let i=Wh(this.types,t);return i===this.types&&n===this.checks&&r===this.encodingChecks?this:new e(i,this.mode,this.annotations,n,void 0,this.context,r)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}matchPart(e,t){for(let n of this.types){let r=n.matchPart(e,t);if(r!==void 0)return r}}getExpected(e){let t=this.annotations?.expected;if(typeof t==`string`)return t;if(this.types.length===0)return`never`;let n=this.types.map(t=>{let n=rg(t);switch(n._tag){case`Arrays`:{let t=n.elements.filter(_m);if(t.length>0)return`${vh(n.isMutable)}[ ${t.map(t=>e(t)+yh(t.context?.isOptional)).join(`, `)}, ... ]`;break}case`Objects`:{let t=n.propertySignatures.filter(e=>_m(e.type));if(t.length>0)return`{ ${t.map(t=>`${vh(t.type.context?.isMutable)}${An(t.name)}${yh(t.type.context?.isOptional)}: ${e(t.type)}`).join(`, `)}, ... }`;break}}return e(n)});return Array.from(new Set(n)).join(` | `)}};function hh(e,t,n,r){let i=Mp(t);return i?Ru(new _p(e,[i],n,r)):Lu(t)}var gh=Ll()({onItem(e,t){return e.compile(t)(e.input,e.options)},step(e,t,n){if(n._tag===`Failure`){let t=Mp(n.cause);if(t===void 0)return n;e.issues?e.issues.push(t):e.issues=[t]}else{if(e.out&&e.successes)return e.successes.push(t),Ru(new vp(e.ast,e.successes,e.input,e.options));if(e.out=n,e.successes)e.successes.push(t);else return zu}}}),_h=new mh([new Im(`Infinity`),new Im(`-Infinity`),new Im(`NaN`)],`anyOf`);function vh(e){return e?``:`readonly `}function yh(e){return e?`?`:``}function bh(e){let t=!1,n;return()=>t?n:(n=e(),t=!0,n)}var xh=class e extends Em{_tag=`Suspend`;thunk;constructor(e,t,n,r,i){if(n)throw Error(`Cannot add checks to Suspend`);super(t,void 0,r,i),this.thunk=bh(e)}getParser(e){let t;return(n,r)=>(t??=e(this.thunk()))(n,r)}recur(t){return new e(()=>t(this.thunk()),this.annotations,void 0,void 0,this.context)}getExpected(e){return e(this.thunk())}},Sh=class e extends lt{_tag=`Filter`;run;annotations;aborted;constructor(e,t=void 0,n=!1){super(),this.run=e,this.annotations=t,this.aborted=n}annotate(t){return new e(this.run,{...this.annotations,...t},this.aborted)}abort(){return new e(this.run,this.annotations,!0)}and(e,t){return new Ch([this,e],t)}},Ch=class e extends lt{_tag=`FilterGroup`;checks;annotations;constructor(e,t=void 0){super(),this.checks=e,this.annotations=t}annotate(t){return new e(this.checks,{...this.annotations,...t})}and(t,n){return new e([this,t],n)}};function wh(e,t,n=!1){return new Sh((t,n,r)=>xp(n,e(t,n,r),t,r),t,n)}function Th(e){return wh(e=>globalThis.Number.isFinite(e),{expected:`a finite number`,representation:{id:`effect/schema/isFinite`,payload:null},toJsonSchema:()=>({type:`number`}),toCode:()=>({runtime:`Schema.isFinite()`}),arbitrary:{constraint:{noInfinity:!0,noNaN:!0}},...e})}var Eh=Ih(Vm,[Th()]),Dh=new Sm(new mh([Eh,_h],`anyOf`),new Zp(Kp(),Vp(e=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function Oh(e,t){let n=e.source,r=new globalThis.RegExp(n,e.flags);return wh(e=>(r.lastIndex=0,r.test(e)),{expected:`a string matching the RegExp ${n}`,representation:{id:`effect/schema/isPattern`,payload:{source:n,flags:e.flags}},toJsonSchema:()=>({pattern:n}),arbitrary:{constraint:{patterns:[e.source]}},...t})}function kh(e,t){let n=Object.getOwnPropertyDescriptors(e);return t(n),Object.create(Object.getPrototypeOf(e),n)}var Ah=new WeakMap;function jh(e){return Ah.get(e)??e}function Mh(e,t){return e.encoding===t?e:kh(e,e=>{e.encoding.value=t})}function Nh(e,t){if(e.context===t)return e;let n=jh(e);if(n.context===t)return n;let r=kh(e,e=>{e.context.value=t});return Ah.set(r,n),r}function Ph(e,t){if(e.checks){let n=e.checks[e.checks.length-1];return Fh(e,Ni(e.checks.slice(0,-1),n.annotate(t)))}return kh(e,e=>{e.annotations.value={...e.annotations.value,...t}})}function Fh(e,t){if(e._tag===`Suspend`&&t)throw Error(`Cannot add checks to Suspend`);return e.checks===t?e:kh(e,e=>{e.checks.value=t})}function Ih(e,t){return Fh(e,th(e.checks,t))}function Lh(e,t){let n=t(e.to);return n===e.to?e:new Sm(n,e.transformation)}function Rh(e,t){let n=e,r=n[n.length-1],i=Lh(r,t);return i===r?e:Ni(e.slice(0,e.length-1),i)}function zh(e){return t=>t.encoding?Mh(t,Rh(t.encoding,e)):t}function Bh(e,t){return zh(e=>Nh(e,t))(e)}function Vh(e,t){function n(r){if(r.encoding){let e=r.encoding[r.encoding.length-1];return t?.stopAt?.(e)?r:Mh(r,Rh(r.encoding,n))}return e(r)}return gt(n)}function Hh(e,t,n){let r=new Sm(e,t);return Mh(n,n.encoding?[...n.encoding,r]:[r])}function Uh(e,t){let n=Qf(e);return Ph(e,{brands:n?[...n,t]:[t]})}function Wh(e,t){let n=!1,r=Array(e.length);for(let i=0;i<e.length;i++){let a=e[i],o=t(a);o!==a&&(n=!0),r[i]=o}return n?r:e}function Gh(e,t){return Nh(e,e.context?new wm(e.context.isOptional,e.context.isMutable,e.context.constructorDefault,{...e.context.annotations,...t}):new wm(!1,!1,void 0,t))}var Kh=gt(e=>qh(Nh(e,e.context?e.context.isOptional===!1?new wm(!0,e.context.isMutable,e.context.constructorDefault,e.context.annotations):e.context:new wm(!0,!1)))),qh=zh(Kh),Jh=ht(e=>Kh(new mh([e,jm],`anyOf`)));function Yh(e,t){let n=new Sm(Mm,new Zp(Wp(t),zp()));return Nh(e,e.context?new wm(e.context.isOptional,e.context.isMutable,n,e.context.annotations):new wm(!1,!1,n))}function Xh(e,t,n){return Hh(e,n,t)}function Zh(e){let t=[],n=[];function r(e){switch(e._tag){case`Literal`:Ct(e.literal)&&t.push(e.literal);return;case`UniqueSymbol`:t.push(e.symbol);return;case`Never`:return;case`Union`:for(let t=0;t<e.types.length;t++)r(e.types[t]);return;default:n.push(e)}}return r(e),{literals:t,parameters:n}}function Qh(e,t){let{literals:n,parameters:r}=Zh(e);return new $m(n.map(e=>new Ym(e,t)),r.map(e=>new Qm(e,t)))}function $h(e){return e.context?.isOptional??!1}function eg(e){return e.annotations?.[`~structural`]===!0||e._tag===`FilterGroup`&&e.checks.every(eg)}function tg(e){function t(e){return eg(e)?[e]:e._tag===`FilterGroup`?e.checks.flatMap(t):[]}let n=e.flatMap(t);return Ii(n)?n:void 0}var ng=gt(e=>{if(e.encoding)return ng(Mh(e,void 0));let t=e,n=t.recur?.(ng)??t,r=n.encodingChecks;if(r){let t=n===e?r:ym(n)||bm(n)||hm(n)&&n.typeParameters.length>0?tg(r):void 0;return kh(n,e=>{e.encodingChecks.value=void 0,e.checks.value=th(n.checks,t)})}return n}),rg=gt(e=>ng(ag(e)));function ig(e,t){let n=t,r=n.length,i=n[r-1],a=[new Sm(ag(Mh(e,void 0)),n[0].transformation.flip())];for(let e=1;e<r;e++)a.unshift(new Sm(ag(n[e-1].to),n[e].transformation.flip()));let o=ag(i.to);return o.encoding?Mh(o,[...o.encoding,...a]):Mh(o,a)}var ag=ht(e=>{if(e.encoding)return ig(e,e.encoding);let t=e;return t.flip?.(ag)??t.recur?.(ag)??t});function og(e){switch(e._tag){case`Undefined`:return!0;case`Union`:return e.types.some(og);default:return!1}}function sg(e,t){let n=ep(t);return(r,i)=>r===z?tp:r===t?n:F(new hp(e,r,i))}function cg(e,t){return(n,r)=>n===z?tp:t(n)?np:F(new hp(e,n,r))}function lg(e,t,n){let r=e.encodedParts,i=e.literals,a=t.length;for(let e=0;e<i.length;e++){let n=i[e];if(n&&!t.includes(n))return}if(e.suffixLengths[0]>a)return;let o=Array(r.length),s;function c(l,u){if(l===r.length)return u===a;if(s?.has(l*(a+1)+u))return!1;let d=r[l];if(l===r.length-1){let e=t.slice(u);if(d.matchPart(e,n)!==void 0)return o[l]=e,!0}else if(d._tag===`Literal`){let e=i[l];if(t.startsWith(e,u)&&c(l+1,u+e.length))return o[l]=e,!0}else{let r=a-e.suffixLengths[l+1],s=i[l+1],f=s===void 0?r:t.lastIndexOf(s,r);for(;f>=u;){let e=t.slice(u,f);if(d.matchPart(e,n)!==void 0&&c(l+1,f))return o[l]=e,!0;if(f===0)break;f=s===void 0?f-1:t.lastIndexOf(s,f-1)}}return s??=new Set,s.add(l*(a+1)+u),!1}return c(0,0)?o:void 0}var ug=Vh(e=>{switch(e._tag){default:return e;case`Number`:return e.toCodecStringTree();case`Union`:return e.recur(ug)}}),dg=Vh(e=>{switch(e._tag){default:return e;case`Symbol`:case`UniqueSymbol`:return e.toCodecStringTree();case`Union`:return e.recur(dg)}}),fg=Vh(e=>{switch(e._tag){default:return e;case`Number`:case`Literal`:case`BigInt`:return e.toCodecStringTree();case`Union`:return e.recur(fg)}}),pg=new globalThis.RegExp(`^${qm}$`),mg=new globalThis.RegExp(`^(?:${qm}|Infinity|-Infinity|NaN)$`);function hg(e){return Oh(pg,{expected:`a string representing a finite number`,representation:{id:`effect/schema/isStringFinite`,payload:null},toJsonSchema:()=>({pattern:pg.source}),...e})}var gg=Ih(Rm,[hg()]),_g=new Sm(gg,rm),vg=new Sm(new mh([gg,_h],`anyOf`),rm);function yg(e,t,n,r,i){for(let a=0;a<e.length;a++){let o=e[a];if(o._tag===`FilterGroup`){if(n=yg(o.checks,t,n,r,i),n&&(i.errors!==`all`||n[n.length-1].filter.aborted))return n}else{let e=o.run(t,r,i);if(e){let r=new lp(o,e,t,i);if(n?n.push(r):n=[r],i.errors!==`all`||o.aborted)return n}}}return n}function bg(e){if(!hm(e))return;let t=e.annotations?.[Zf];return wt(t)?t(e.typeParameters):void 0}function xg(e){return e===null||typeof e==`string`||typeof e==`boolean`||typeof e==`number`&&globalThis.Number.isFinite(e)}function Sg(e){return e===void 0||typeof e==`string`}function Cg(e,t){let n=new WeakMap,r=[];outer:for(;;){if(typeof e!=`object`||!e){if(!t(e))return!1}else{let t=e,i=n.get(t);if(i===!1)return!1;if(i===void 0){let e=Array.isArray(t);if(!e){let e=Object.getPrototypeOf(t);if(e!==null&&e!==Object.prototype&&Object.getPrototypeOf(e)!==null)return!1}n.set(t,!1),r.push({value:t,keys:e?t.length:Object.keys(t),index:0})}}for(;r.length>0;){let t=r[r.length-1],i=t.keys;if(typeof i==`number`){if(t.index<i){e=t.value[t.index++];continue outer}}else if(t.index<i.length){e=t.value[i[t.index++]];continue outer}n.set(t.value,!0),r.pop()}return!0}}function wg(e){return Cg(e,xg)}var Tg=new Dm([],()=>(e,t,n)=>wg(e)?np:F(new hp(t,e,n)),{representation:{id:`effect/schema/Json`,payload:null},expected:`JSON value`,toCodecJson:()=>void 0,toCodecStringTree:()=>kg,toArbitrary:()=>e=>e.jsonValue()}),Eg=new Sm(Tg,nm()),Dg=new Sm(new mh([new Um(!1,[],[Tg]),new $m([],[new Qm(Rm,Tg)])],`anyOf`),nm());function Og(e){return Cg(e,Sg)}var kg=new Sm(new Dm([],()=>(e,t,n)=>Og(e)?np:F(new hp(t,e,n)),{expected:`StringTree`,toCodecStringTree:()=>void 0}),nm());function Ag(){return Object.assign(e=>e,{option:e=>di(e),result:e=>bi(e),is:e=>!0})}var jg=Ms,Mg=Ps,Ng=Vl,Pg=nu,Fg=`~effect/MutableRef`,Ig={[Fg]:Fg,...Xn,toJSON(){return{_id:`MutableRef`,current:In(this.current)}}},Lg=e=>{let t=Object.create(Ig);return t.current=e,t},Rg=(e,t,n)=>Zs(r=>{if(e.free>=t)return r(n);let i=()=>{e.free<t||(e.waiters.delete(i),r(n))};return e.waiters.add(i),M(()=>{e.waiters.delete(i)})}),zg=class{waiters=new Set;taken=0;permits;constructor(e){this.permits=e}get free(){return this.permits-this.taken}take(e){let t=zs(()=>this.free<e?Rg(this,e,t):(this.taken+=e,j(e)));return t}takeIfAvailable(e){return zs(()=>this.free<e?j(!1):(this.taken+=e,j(!0)))}releaseUnsafe(e,t){return this.taken-=t,this.waiters.size>0&&e.currentDispatcher.scheduleTask(()=>{for(let e of this.waiters){if(this.free<=0)break;e()}},0),this.free}resize(e){return Er(t=>(this.permits=e,this.free<0||this.releaseUnsafe(t,0),Gs))}release(e){return Er(t=>j(this.releaseUnsafe(t,e)))}get releaseAll(){return Er(e=>j(this.releaseUnsafe(e,this.taken)))}withPermits(e){return t=>Ml(n=>{let r=zs(()=>this.free<e?N(n(Rg(this,e,Gs)),()=>r):(this.taken+=e,gl(n(t),()=>{this.releaseUnsafe(Ds(),e)},!0)));return r})}withPermit=this.withPermits(1);withPermitsIfAvailable(e){return t=>Ml(n=>this.free<e?Vs:(this.taken+=e,gl(n(lc(t)),()=>{this.releaseUnsafe(Ds(),e)},!0)))}},Bg=e=>M(()=>new zg(e)),Vg={"~effect/Channel":{_Env:E,_InErr:E,_InElem:E,_OutErr:E,_OutElem:E},pipe(){return st(this,arguments)}},Hg=e=>{let t=Object.create(Vg);return t.transform=(t,n)=>ff(e(t,n),e=>P(Xd(e))),t},Ug=e=>Hg((t,n)=>e),Wg=e=>Hg(Hf(function*(t,n){let r=Qu(n),i=e=>$u(r,zd(e));return Cf(yield*Cf(e(t,n,r),i),i)})),Gg=e=>e.transform,Kg=e=>Hg((t,n)=>Gd(()=>Gg(e())(t,n))),qg=e=>Ug(P(F(e))),Jg=e=>Hg((t,n)=>Yg({scope:n,readable:e.evaluate(),onError:e.onError,releaseLockOnEnd:e.releaseLockOnEnd})),Yg=e=>{let t=e.readable.getReader(),n=e.exit??Lg(void 0),r=Gd(()=>n.current?n.current:hf(Ud({try:()=>t.read(),catch:e.onError}),{onFailure:e=>n.current??Xd(e),onSuccess:({done:e,value:t})=>n.current?n.current:e?Fu():P(Hi(t))}));return lf(Zu(e.scope,e.releaseLockOnEnd?Kd(()=>t.releaseLock()):Hd(()=>t.cancel().catch(mt))),r)},Xg=T(2,(e,t)=>Wg((n,r,i)=>Xu(i,t).pipe(rf(Gg(e)(n,r))))),Zg=T(2,(e,t)=>Xg(e,e=>t)),Qg=(e,t,n)=>Gd(()=>{let r=Ju();return Fd(tf(Gg(e)(Fu(),r),t),n||P).pipe(wf(e=>$u(r,e)))}),$g=T(2,(e,t)=>Qg(e,e=>Of(tf(e,t),{disableYield:!0})));function e_(e){let t=m_(v_,ng(e.ast));return(e,n)=>t(e,n?.disableChecks?n?.parseOptions?{...n.parseOptions,disableChecks:!0}:{disableChecks:!0}:n?.parseOptions)}function t_(e){let t=e_(e);return(e,n)=>{let r=Bf(t(e,n));return Bu(r)?di(r.value):(Np(r.cause,`Option adapter can only return none for schema issues`),ui())}}function n_(e){let t=e_(e);return(e,n)=>{let r=Bf(t(e,n));if(Bu(r))return r.value;let i=Np(r.cause,`Constructor adapter can only throw schema issues`);throw Error(`Schema validation failed`,{cause:i})}}function r_(e){return i_(e.ast)}function i_(e){let t=h_(p_(ng(e)));return e=>{let n=t(e,Cm);return Bu(n)?!0:(Np(n.cause,`Type guard adapter can only return false for schema issues`),!1)}}function a_(e,t){let n=p_(e.ast);return t===void 0?n:(e,r)=>n(e,d_(t,r))}function o_(e,t){return g_(a_(e,t))}var s_=o_;function c_(e,t){let n=p_(ag(e.ast));return t===void 0?n:(e,r)=>n(e,d_(t,r))}function l_(e,t){return g_(c_(e,t))}var u_=l_,d_=(e,t)=>t?{...e,...t}:e,f_=e=>e===z?F(new gp):P(e);function p_(e){return m_(__,e)}function m_(e,t){let n;return(r,i)=>{let a=(n??=e(t))(r,i??Cm);return a===np?P(r):mc(a)?a[A]===z?f_(z):a:Gf(a,f_)}}function h_(e){return(t,n)=>Bf(e(t,n))}function g_(e){let t=h_(e);return(e,n)=>{let r=t(e,n);return Bu(r)?di(r.value):(Np(r.cause,`Option adapter can only return none for schema issues`),ui())}}var __=ht(e=>C_(e,__)),v_=ht(e=>C_(e,v_,b_)),y_=ht(e=>C_(e,v_,b_,e.context?.constructorDefault));function b_(e){return e.context?.constructorDefault?y_(e):v_(e)}function x_(e,t,n,r){let i;if(mc(e)&&e._tag===`Success`){let a=rp(e===np?t:e[A]);i=n._tag===`Transformation`?n.decode.run(a,r):n.decode(ep(a),r)}else i=n._tag===`Transformation`?Gf(e,e=>n.decode.run(rp(e),r)):n.decode(Uf(e,rp),r);return mc(i)&&i._tag===`Success`?ip(i[A]):Gf(i,ip)}function S_(e,t){let n;return(r,i)=>r===z?tp:e.isConstructed(r)?np:x_((n??=t(e.link.to))(r,i),r,e.link.transformation,i)}function C_(e,t,n,r){let i=n?bg(e):void 0,a=i?S_(i,t):e.getParser(t,n),o=e.checks,s=r?e.encoding?[...e.encoding,r]:[r]:e.encoding,c=e.encodingChecks,l=(o?o[o.length-1].annotations:e.annotations)?.parseOptions;if(!s&&!o&&!c)return l?(e,t)=>a(e,d_(t,l)):a;let u,d=(t,n)=>{let r=a(t,n);if(c&&!n.disableChecks){if(mc(r)){if(r._tag===`Success`){let i=r===np?t:r[A];if(t!==z&&i!==z){let i=yg(c,t,void 0,e,n);i&&(r=F(new mp(e,i,t,n)))}}}else r=tf(r,r=>{if(t!==z&&r!==z){let r=yg(c,t,void 0,e,n);if(r)return F(new mp(e,r,t,n))}return P(r)})}if(o&&!n.disableChecks){if(mc(r)){if(r._tag===`Success`){let i=r===np?t:r[A];if(i===z)return r;let a=yg(o,i,void 0,e,n);a&&(r=F(new mp(e,a,i,n)))}}else r=tf(r,t=>{if(t!==z){let r=yg(o,t,void 0,e,n);if(r)return F(new mp(e,r,t,n))}return P(t)})}return r};return s?(n,r)=>{l&&(r=d_(r,l));let i=u??=s.map(e=>t(e.to)),a=n,o=i[i.length-1](n,r);for(let e=s.length-1;e>=0;e--)if(o=x_(o,a,s[e].transformation,r),e!==0){let t=i[e-1];o._tag===`Success`?(a=o[A],o=t(a,r)):o=Gf(o,e=>{let n=t(e,r);return n===np?ep(e):n})}if(o._tag===`Success`){let e=o[A],t=d(e,r);return t===np?o:t}return o=ff(o,t=>Zd(()=>ju(t,t=>new up(e,t,n,r)))),Gf(o,e=>{let t=d(e,r);return t===np?ep(e):t})}:l?(e,t)=>d(e,d_(t,l)):d}var w_=`~effect/Schema/Schema`,T_={[w_]:w_,pipe(){return st(this,arguments)},annotate(e){return this.rebuild(Ph(this.ast,e))},annotateKey(e){return this.rebuild(Gh(this.ast,e))},check(...e){return this.rebuild(Ih(this.ast,e))}};function E_(e,t){function n(){}let r=Object.defineProperties(Object.setPrototypeOf(n,T_),Object.getOwnPropertyDescriptors({...t}));return r.ast=e,r.rebuild=e=>E_(e,t),r.makeEffect=e_(r),r.make=n_(r),r.makeOption=t_(r),r}var D_=e=>e,O_=new WeakMap,k_=`~effect/data/Redacted`,A_=e=>D(e,k_),j_=(e,t)=>{let n=Object.create(M_);return t?.label&&(n.label=t.label),O_.set(n,e),n},M_={[k_]:{_A:e=>e},label:void 0,...Xn,toJSON(){return this.toString()},toString(){return`<redacted${yt(this.label)?`:`+this.label:``}>`},[Nt](){return O(O_.get(this))},[Xt](e){return A_(e)&&Zt(O_.get(this),O_.get(e))}},N_=w_;function P_(){return(e,t,n)=>B(new Dm(e.map(rh),e=>t(e.map(e=>B(e))),n))}function F_(e,t){return P_()([],()=>(t,n,r)=>e(t)?P(t):F(new hp(n,t,r)),t)}var I_=`~effect/SchemaError/SchemaError`,L_=class extends No(`SchemaError`){[I_]=I_;constructor(e){super({issue:e})}get message(){return kp(this.issue)}toString(){return`SchemaError(${this.message})`}};function R_(e){return D(e,I_)&&e[I_]===I_}var z_=r_;function B_(e,t){let n=a_(e,t);return(e,t)=>V_(n(e,t))}function V_(e){return ff(e,e=>Zd(()=>ju(e,e=>new L_(e))))}var H_=B_;function U_(e,t){let n;for(let r of e.reasons){if(!Ou(r)||!R_(r.error))throw new globalThis.Error(t,{cause:e});n??=r.error}if(n===void 0)throw new globalThis.Error(t,{cause:e});return n}function W_(e){let t=Bf(e);if(Bu(t))return t.value;throw U_(t.cause,`Sync adapter can only throw schema errors`)}var G_=o_,K_=s_;function q_(e,t){let n=B_(e,t);return(e,t)=>W_(n(e,t))}var J_=q_;function Y_(e,t){let n=c_(e,t);return(e,t)=>V_(n(e,t))}var X_=u_;function Z_(e,t){let n=Y_(e,t);return(e,t)=>W_(n(e,t))}var Q_=Z_,B=E_;function $_(e){return D(e,N_)&&e[N_]===N_}var V=D_(e=>{let t=hv(e);return B(Jh(e.ast),{schema:t})}),ev=D_(e=>B(ng(e.ast),{schema:e}));function H(e){let t=B(new Im(e),{literal:e,transform(n){return t.pipe(vv(H(n),{decode:Vp(()=>n),encode:Vp(()=>e)}))}});return t}function tv(e){return new Fm(e.map(e=>$_(e)?e.ast:new Im(e)))}function nv(e){return B(tv(e),{parts:e})}function rv(e){return B(tv(e).asTemplateLiteralParser(),{parts:e})}var iv=B(Mm),av=B(Om),ov=B(jm),U=B(Rm),sv=B(Vm),cv=B(Hm),lv=B(Nm);function uv(e,t){return B(e,{fields:t,mapFields(e,t){let n=e(this.fields);return uv(nh(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function W(e){return uv(nh(e,void 0),e)}function dv(e,t){return B(Qh(e.ast,t.ast),{key:e,value:t})}function fv(e,t){return B(ah(e.ast,t.map(rh)),{schema:e,records:t})}var G=D_(e=>B(new Um(!1,[],[e.ast]),{value:e}));function pv(e,t){return B(e,{members:t,mapMembers(e,t){let n=e(this.members);return pv(ih(n,this.ast.mode,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function K(e,t){return pv(ih(e,t?.mode??`anyOf`,void 0),e)}function q(e){let t=e.map(H);return B(ih(t,`anyOf`,void 0),{literals:e,members:t,mapMembers(e){return K(e(this.members))},pick(e){return q(e)},transform(e){return K(t.map((t,n)=>t.transform(e[n])))}})}var mv=D_(e=>K([e,av])),hv=D_(e=>K([e,ov]));function gv(e){return B(new xh(()=>e().ast))}function _v(...e){return t=>t.check(...e)}function J(e){return t=>B(Uh(t.ast,e),{schema:t,identifier:e})}function vv(e,t){return n=>B(Xh(n.ast,e.ast,t?$p(t):nm()),{from:n,to:e})}function yv(e){return t=>B(Yh(t.ast,e),{schema:t})}function bv(e){return H(e).pipe(yv(P(e)))}function xv(e,t){return W({_tag:bv(e),...t})}function Sv(){return(e,t)=>new Sm(e.ast,$p(t))}var Y=wh,Cv=`^\\S[\\s\\S]*\\S$|^\\S$|^$`;function wv(e){let t=new globalThis.RegExp(Cv);return Y(e=>e.trim()===e,{expected:`a string with no leading or trailing whitespace`,representation:{id:`effect/schema/isTrimmed`,payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:`Schema.isTrimmed()`}),arbitrary:{constraint:{patterns:[Cv]}},...e})}function Tv(e,t){let n=e.source,r=e.flags,i=r===``?`new RegExp(${k(n)})`:`new RegExp(${k(n)}, ${k(r)})`;return Oh(e,{toCode:()=>({runtime:`Schema.isPattern(${i})`}),...t})}function Ev(e){let t=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;return Tv(t,{expected:`a base64url encoded string`,representation:{id:`effect/schema/isBase64Url`,payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:`Schema.isBase64Url()`}),...e})}var Dv=B(Eh);function Ov(e){let t=si(e.order),n=e.formatter??k;return(r,i)=>Y(e=>t(e,r),{expected:`a value greater than ${n(r)}`,arbitrary:{constraint:{ordered:{order:e.order,minimum:r,exclusiveMinimum:!0}}},...e.annotate?.(r),...i})}function kv(e){let t=li(e.order),n=e.formatter??k;return(r,i)=>Y(e=>t(e,r),{expected:`a value greater than or equal to ${n(r)}`,arbitrary:{constraint:{ordered:{order:e.order,minimum:r}}},...e.annotate?.(r),...i})}function Av(e){let t=ci(e.order),n=e.formatter??k;return(r,i)=>Y(e=>t(e,r),{expected:`a value less than or equal to ${n(r)}`,arbitrary:{constraint:{ordered:{order:e.order,maximum:r}}},...e.annotate?.(r),...i})}function jv(e){let t=li(e.order),n=si(e.order),r=ci(e.order),i=oi(e.order),a=e.formatter??k;return(o,s)=>{let c=o.exclusiveMinimum?n:t,l=o.exclusiveMaximum?i:r;return Y(e=>c(e,o.minimum)&&l(e,o.maximum),{expected:`a value between ${a(o.minimum)}${o.exclusiveMinimum?` (excluded)`:``} and ${a(o.maximum)}${o.exclusiveMaximum?` (excluded)`:``}`,arbitrary:{constraint:{ordered:{order:e.order,minimum:o.minimum,maximum:o.maximum,...o.exclusiveMinimum&&{exclusiveMinimum:!0},...o.exclusiveMaximum&&{exclusiveMaximum:!0}}}},...e.annotate?.(o),...s})}}function Mv(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${k(e)}`);return e}var Nv=Ov({order:ri,annotate:e=>({representation:{id:`effect/schema/isGreaterThan`,payload:{exclusiveMinimum:Mv(e)}},toJsonSchema:()=>({exclusiveMinimum:e}),toCode:()=>({runtime:`Schema.isGreaterThan(${k(e)})`})})}),Pv=kv({order:ri,annotate:e=>({representation:{id:`effect/schema/isGreaterThanOrEqualTo`,payload:{minimum:Mv(e)}},toJsonSchema:()=>({minimum:e}),toCode:()=>({runtime:`Schema.isGreaterThanOrEqualTo(${k(e)})`})})}),Fv=Av({order:ri,annotate:e=>({representation:{id:`effect/schema/isLessThanOrEqualTo`,payload:{maximum:Mv(e)}},toJsonSchema:()=>({maximum:e}),toCode:()=>({runtime:`Schema.isLessThanOrEqualTo(${k(e)})`})})}),Iv=jv({order:ri,annotate:e=>{let t=e.exclusiveMinimum?!0:void 0,n=e.exclusiveMaximum?!0:void 0;return{representation:{id:`effect/schema/isBetween`,payload:{minimum:Mv(e.minimum),maximum:Mv(e.maximum),...t&&{exclusiveMinimum:t},...n&&{exclusiveMaximum:n}}},toJsonSchema:()=>({[t?`exclusiveMinimum`:`minimum`]:e.minimum,[n?`exclusiveMaximum`:`maximum`]:e.maximum}),toCode:()=>({runtime:`Schema.isBetween({ minimum: ${k(e.minimum)}, maximum: ${k(e.maximum)}, exclusiveMinimum: ${k(t)}, exclusiveMaximum: ${k(n)} })`})}}});function Lv(e){return Y(e=>globalThis.Number.isSafeInteger(e),{expected:`an integer`,representation:{id:`effect/schema/isInt`,payload:null},toJsonSchema:()=>({type:`integer`}),toCode:()=>({runtime:`Schema.isInt()`}),arbitrary:{constraint:{integer:!0}},...e})}var Rv=sv.check(Lv()),zv=Rv.check(Pv(0));function Bv(e,t){return e=Math.max(0,Math.floor(e)),Y(t=>t.length>=e,{expected:`a value with a length of at least ${e}`,representation:{id:`effect/schema/isMinLength`,payload:{minLength:e}},toJsonSchema:({type:t})=>t===`array`?{minItems:e}:{minLength:e},toCode:()=>({runtime:`Schema.isMinLength(${e})`}),[Yf]:!0,arbitrary:{constraint:{minLength:e}},...t})}function Vv(e){return Bv(1,e)}function Hv(e,t){return e=Math.max(0,Math.floor(e)),Y(t=>t.length<=e,{expected:`a value with a length of at most ${e}`,representation:{id:`effect/schema/isMaxLength`,payload:{maxLength:e}},toJsonSchema:({type:t})=>t===`array`?{maxItems:e}:{maxLength:e},toCode:()=>({runtime:`Schema.isMaxLength(${e})`}),[Yf]:!0,arbitrary:{constraint:{maxLength:e}},...t})}function Uv(e){return Y(e=>Gi(e).length===e.length,{expected:`an array with unique items`,representation:{id:`effect/schema/isUnique`,payload:null},toJsonSchema:()=>({uniqueItems:!0}),toCode:()=>({runtime:`Schema.isUnique()`}),arbitrary:{constraint:{unique:!0}},...e})}var Wv=U.check(Vv()),Gv=e=>e?.includeStack===!0|(e?.excludeCause===!0?2:0),Kv=e=>{switch(e){case 0:return;case 1:return{includeStack:!0};case 2:return{excludeCause:!0};case 3:return{includeStack:!0,excludeCause:!0}}},qv=[];function Jv(e){let t=Gv(e),n=qv[t];if(n!==void 0)return n;let r=_y.pipe(vv(iv,fm(Kv(t))));return qv[t]=r,r}globalThis.RegExp,globalThis.URL;function Yv(e,t,n){let r={...t};if(e?.minimum!==void 0){let t=n===void 0?e.minimum:n(e.minimum),i=e.exclusiveMinimum?new globalThis.Date(t.getTime()+1):t;(r.min===void 0||i.getTime()>r.min.getTime())&&(r.min=i)}if(e?.maximum!==void 0){let t=n===void 0?e.maximum:n(e.maximum),i=e.exclusiveMaximum?new globalThis.Date(t.getTime()-1):t;(r.max===void 0||i.getTime()<r.max.getTime())&&(r.max=i)}return r}var Xv=U.annotate({expected:`a string that will be decoded as a Date`}),Zv=F_(e=>e instanceof globalThis.Date&&!globalThis.Number.isNaN(e.getTime()),{representation:{id:`effect/schema/Date`,payload:null},toCode:()=>({runtime:`Schema.Date`,Type:`globalThis.Date`}),expected:`a valid Date`,toCodecJson:()=>Sv()(Xv,im),toArbitrary:()=>(e,t)=>e.date(Yv(t?.constraint?.ordered?.order===ai?t.constraint.ordered:void 0,{noInvalidDate:!0}))}),Qv=Rv.pipe(vv(Zv,am)),$v=U.annotate({expected:`a string that will be decoded as JSON`,contentMediaType:`application/json`});function ey(e,t){return $v.pipe(vv(e,pm(t)))}globalThis.File,globalThis.FormData,globalThis.URLSearchParams,globalThis.Uint8Array;var ty=globalThis.Symbol.for(`immer-draftable`),ny={};function ry(e,t,n,r,i){let a=oy(n,t,r),o=ay(t),s=class extends e{constructor(...[e,t]){let r=t?.[`~payload`],i=r?.token===ny?r.value:n.make(e??{},t);super(i,{...t,disableChecks:!0,"~payload":{token:ny,value:i}})}static[N_]=N_;get[o](){return o}static[ty]=!0;static identifier=t;static fields=n.fields;static get ast(){return a(this).ast}static pipe(){return st(this,arguments)}static rebuild(e){return a(this).rebuild(e)}static make(e,t){return new this(e,t)}static makeOption(e,t){return t_(a(this))(e??{},t)}static makeEffect(e,t){return a(this).makeEffect(e??{},t)}static annotate(e){return this.rebuild(Ph(this.ast,e))}static annotateKey(e){return this.rebuild(Gh(this.ast,e))}static check(...e){return this.rebuild(Ih(this.ast,e))}static extend(e){return(t,r)=>{let a=sy(t)?t:W(t),o={...n.fields,...a.fields},s=nh(o,n.ast.checks,{identifier:e});return ry(this,e,uv(Ih(s,a.ast.checks),o),r,i)}}static mapFields(e,t){return n.mapFields(e,t)}};return i!==void 0&&Object.assign(s.prototype,i(t)),s}function iy(e){return new Zp(Vp(t=>new e(t,{"~payload":{token:ny,value:t}})),zp())}function ay(e){return`~effect/Schema/Class/${e}`}function oy(e,t,n){let r;return i=>{if(r!==void 0)return r;let a=ay(t),o=e=>e instanceof i||D(e,a),s=iy(i);return r=vv(B(new Dm([e.ast],()=>(e,t,n)=>o(e)?P(e):F(new hp(t,e,n)),{identifier:t,[Zf]:([e])=>({isConstructed:o,link:new Sm(e,s)}),toCodec:([e])=>new Sm(e.ast,s),toArbitrary:([e])=>()=>({arbitrary:e.arbitrary.map(e=>new i(e)),terminal:e.terminal?.map(e=>new i(e))}),toFormatter:([e])=>t=>`${i.identifier}(${e(t)})`,[Xf]:ch(e.ast),...n})),s)(e)}}function sy(e){return $_(e)}var cy=e=>(t,n)=>ry(Or,e,sy(t)?t:W(t),n,e=>({name:e})),ly=e=>(t,n,r)=>{let i=sy(n)?n.mapFields(e=>({_tag:bv(t),...e}),{unsafePreserveChecks:!0}):xv(t,n);return cy(e??t)(i,r)};function uy(e){return B(dy(e.ast),{schema:e})}var dy=Vh(e=>{let t=gy(e,dy),n=e.context;return t===e||n===void 0?t:Bh(t,fy(n))});function fy(e){return e.constructorDefault===void 0?e:new wm(e.isOptional,e.isMutable,void 0,e.annotations)}function py(e){if(e.propertySignatures.some(e=>typeof e.name!=`string`))throw new globalThis.Error(`Objects property names must be strings`,{cause:e})}function my(e){return t=>{let n=new Map;for(let e=0;e<t.length;e++)n.set(rg(t[e]),e);let r=[...t].sort((t,r)=>{t=rg(t),r=rg(r);let i=e(t),a=e(r);return i===a?n.get(t)-n.get(r):i-a});return r.some((e,n)=>e!==t[n])?r:t}}var hy=my(e=>{switch(e._tag){case`BigInt`:case`Symbol`:case`UniqueSymbol`:return 0;default:return 1}});function gy(e,t){switch(e._tag){case`Declaration`:{let n=e.annotations?.toCodecJson??e.annotations?.toCodec;if(!wt(n))return Mh(e,[Eg]);let r=n(e.typeParameters.map(e=>E_(rg(e))));return r===void 0?e:Mh(e,[Lh(r,t)])}case`Unknown`:return Mh(e,[Eg]);case`ObjectKeyword`:return Mh(e,[Dg]);case`Undefined`:case`Void`:case`Literal`:case`Number`:return e.toCodecJson();case`UniqueSymbol`:case`Symbol`:case`BigInt`:return e.toCodecStringTree();case`Objects`:return py(e),e.recur(t,dg);case`Union`:{let n=hy(e.types);return n===e.types?e.recur(t):new mh(n,e.mode,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t)}case`Arrays`:case`Suspend`:return e.recur(t)}return e}var _y=B(Ph(Tg,{toCode:()=>({runtime:`Schema.Json`,Type:`Schema.Json`})})),vy=dv(U,_y),yy=`~effect/Stream`,by={_R:E,_E:E,_A:E},xy={[yy]:by,pipe(){return st(this,arguments)}},Sy=e=>{let t=Object.create(xy);return t.channel=e,t},Cy=`~effect/Stream`,wy=e=>D(e,Cy),Ty=Sy,Ey=e=>Ty(Kg(()=>e().channel)),Dy=e=>Ty(qg(e)),Oy=e=>Ty(Jg(e)),ky=T(2,(e,t)=>Ty(Zg(e.channel,t))),Ay=T(2,(e,t)=>$g(e.channel,t)),jy=T(e=>wy(e[0]),(e,t,n)=>{let r,i,a=Pg(!1);return new ReadableStream({start(n){i=jf(vf(Ay(e,e=>a.whenOpen(Kd(()=>{a.closeUnsafe();for(let t=0;t<e.length;t++)n.enqueue(e[t]);r(),r=void 0}))),t)),i.addObserver(e=>{e._tag===`Failure`?n.error(Mu(e.cause)):n.close()})},pull(){return new Promise(e=>{r=e,a.openUnsafe()})},cancel(){if(i)return Ff(uf(Mg(i)))}},n?.strategy)}),My=T(e=>wy(e[0]),(e,t)=>cf(gf(),n=>jy(e,n,t))),Ny=[`All`,`Fatal`,`Error`,`Warn`,`Info`,`Debug`,`Trace`,`None`],Py=`~effect/ErrorReporter`,Fy=e=>{let t=new WeakSet;return{[Py]:Py,report(n){if(!t.has(n.cause)){t.add(n.cause);for(let r=0;r<n.cause.reasons.length;r++){let i=n.cause.reasons[r];if(i._tag===`Interrupt`)continue;let a=i._tag===`Fail`?i.error:i.defect,o=typeof a==`object`&&!!a;if(o){if(t.has(a))continue;t.add(a)}if(zy(a))continue;let s=gs(a,i.annotations);e({...n,error:s,severity:o?Vy(a):`Info`,attributes:o?Uy(a):Wy})}}}}},Iy=Ko,Ly=(e,t)=>_d(Iy,ef(Hf(function*(n){let r=new Set(t?.mergeWithExisting===!0?n.getRef(Ko):[]);for(let t of e)r.add(Bd(t)?yield*t:t);return r}))),Ry=e=>ef(t=>(Du(t,e),qd)),zy=e=>typeof e==`object`&&!!e&&`~effect/ErrorReporter/ignore`in e&&e[`~effect/ErrorReporter/ignore`]===!0,By=`~effect/ErrorReporter/severity`,Vy=e=>`~effect/ErrorReporter/severity`in e&&Ny.includes(e[`~effect/ErrorReporter/severity`])?e[By]:`Info`,Hy=`~effect/ErrorReporter/attributes`,Uy=e=>`~effect/ErrorReporter/attributes`in e?e[Hy]:Wy,Wy={},Gy=`~effect/ManagedRuntime`,Ky=(e,t)=>{let n=t?.memoMap??ld(),r=Ju(`parallel`),i=Qu(r,`sequential`),a={onFiberStart:Ng(r)},o=e=>e?{...e,onFiberStart:e.onFiberStart?t=>{a.onFiberStart(t),e.onFiberStart(t)}:a.onFiberStart}:a,s,c=ef(t=>(s||=jf(af(fd(e,n,i),e=>Kd(()=>{l.cachedContext=e})),{...a,scheduler:t.currentScheduler}),nf(jg(s)))),l={[Gy]:Gy,memoMap:n,scope:r,contextEffect:c,cachedContext:void 0,context(){return l.cachedContext===void 0?Ff(l.contextEffect):Promise.resolve(l.cachedContext)},dispose(){return Ff(l.disposeEffect)},[Symbol.asyncDispose](){return l.dispose()},disposeEffect:Gd(()=>(l.contextEffect=Qd(`ManagedRuntime disposed`),l.cachedContext=void 0,$u(l.scope,zu))),runFork(e,t){return l.cachedContext===void 0?jf(qy(l,e),o(t)):Mf(l.cachedContext)(e,o(t))},runCallback(e,t){return l.cachedContext===void 0?Pf(qy(l,e),o(t)):Nf(l.cachedContext)(e,o(t))},runSyncExit(e){return l.cachedContext===void 0?Bf(qy(l,e)):Vf(l.cachedContext)(e)},runSync(e){return l.cachedContext===void 0?L(qy(l,e)):zf(l.cachedContext)(e)},runPromiseExit(e,t){return l.cachedContext===void 0?Lf(qy(l,e),o(t)):Rf(l.cachedContext)(e,o(t))},runPromise(e,t){return l.cachedContext===void 0?Ff(qy(l,e),o(t)):If(l.cachedContext)(e,o(t))}};return l};function qy(e,t){return tf(e.contextEffect,e=>vf(t,e))}var Jy=`~effect/http/Cookies`,Yy=`~effect/http/Cookies/Cookie`;No(`CookieError`);var Xy={[Jy]:Jy,...Ln,toJSON(){return{_id:`effect/Cookies`,cookies:Ei(this.cookies,e=>e.toJSON())}},pipe(){return st(this,arguments)}},Zy=e=>{let t=Object.create(Xy);return t.cookies=e,t},Qy=e=>{let t={};for(let n of e)bn(t,n.name,n);return Zy(t)},$y=e=>{let t=typeof e==`string`?[e]:e,n=[];for(let e of t){let t=eb(e.trim());t&&n.push(t)}return Qy(n)};function eb(e){let t=e.split(`;`).map(e=>e.trim()).filter(e=>e!==``);if(t.length===0)return;let n=t[0].indexOf(`=`);if(n===-1)return;let r=t[0].slice(0,n);if(!tb.test(r))return;let i=t[0].slice(n+1),a=rb(i);if(t.length===1)return Object.assign(Object.create(nb),{name:r,value:a,valueEncoded:i});let o={};for(let e=1;e<t.length;e++){let n=t[e],r=n.indexOf(`=`),i=r===-1?n:n.slice(0,r).trim(),a=r===-1?void 0:n.slice(r+1).trim();switch(i.toLowerCase()){case`domain`:{if(a===void 0)break;let e=a.trim().replace(/^\./,``);e&&(o.domain=e);break}case`expires`:{if(a===void 0)break;let e=new Date(a);isNaN(e.getTime())||(o.expires=e);break}case`max-age`:{if(a===void 0)break;let e=parseInt(a,10);isNaN(e)||(o.maxAge=mo(e));break}case`path`:if(a===void 0)break;a[0]===`/`&&(o.path=a);break;case`priority`:if(a===void 0)break;switch(a.toLowerCase()){case`low`:o.priority=`low`;break;case`medium`:o.priority=`medium`;break;case`high`:o.priority=`high`}break;case`httponly`:o.httpOnly=!0;break;case`secure`:o.secure=!0;break;case`partitioned`:o.partitioned=!0;break;case`samesite`:if(a===void 0)break;switch(a.toLowerCase()){case`lax`:o.sameSite=`lax`;break;case`strict`:o.sameSite=`strict`;break;case`none`:o.sameSite=`none`}}}return Object.assign(Object.create(nb),{name:r,value:a,valueEncoded:i,options:Object.keys(o).length>0?o:void 0})}var tb=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,nb={[Yy]:Yy,...Ln,toJSON(){return{_id:`effect/Cookies/Cookie`,name:this.name,value:this.value,options:this.options}}},rb=e=>{try{return decodeURIComponent(e)}catch{return e}},ib=Symbol.for(`~effect/http/Headers`),ab=Object.defineProperties(Object.create(null),{[ib]:{value:ib},[Sn]:{value(e){return hb(this,La(e,_b))}},toJSON:{value(){return wn(this)}},[Xt]:{value(e){return sb(this,e)}},[Nt]:{value(){return Vt(this)}},toString:{value:Ln.toString},[Fn]:{value:Ln[Fn]}}),ob=e=>Object.assign(Object.create(ab),e),sb=ki(gn()),cb=Object.create(ab),lb=e=>{if(e===void 0)return cb;if(Symbol.iterator in e){let t=Object.create(ab);for(let[n,r]of e)t[n.toLowerCase()]=r;return t}let t=Object.create(ab);for(let[n,r]of Object.entries(e))Array.isArray(r)?t[n.toLowerCase()]=r.join(`, `):r!==void 0&&(t[n.toLowerCase()]=r);return t},ub=e=>Object.setPrototypeOf(e,ab),db=T(3,(e,t,n)=>{let r=ob(e);return r[t.toLowerCase()]=n,r}),fb=T(2,(e,t)=>ob({...e,...lb(t)})),pb=T(2,(e,t)=>{let n=ob(e);return Object.assign(n,t),n}),mb=T(2,(e,t)=>{let n=ob(e);return delete n[t.toLowerCase()],n}),hb=T(2,(e,t)=>{let n={...e},r=t=>{if(typeof t==`string`){let r=t.toLowerCase();r in e&&(n[r]=j_(e[r]))}else for(let r in e)t.test(r)&&(n[r]=j_(e[r]))};if(Array.isArray(t))for(let e=0;e<t.length;e++)r(t[e]);else r(t);return n}),gb=(e,t)=>{for(let n=0;n<t.length;n++){let r=t[n];if(typeof r==`string`){if(r.toLowerCase()===e)return!0}else if(r.test(e))return!0}return!1},_b=Ua(`effect/Headers/CurrentRedactedNames`,{defaultValue:()=>[`authorization`,`cookie`,`set-cookie`,`x-api-key`]}),vb=`~effect/http/UrlParams`,yb=e=>D(e,vb),bb={...Xn,[vb]:vb,[Symbol.iterator](){return this.params[Symbol.iterator]()},toJSON(){return{_id:`UrlParams`,params:Object.fromEntries(this.params)}},[Xt](e){return wb(this,e)},[Nt](){return Ut(this.params.flat())}},xb=e=>{let t=Object.create(bb);return t.params=e,t},Sb=e=>{if(yb(e))return e;let t=Cb(e),n=[];for(let e=0;e<t.length;e++)if(Array.isArray(t[e][0])){let[r,i]=t[e];n.push([`${r[0]}[${r.slice(1).join(`][`)}]`,i])}else n.push(t[e]);return xb(n)},Cb=e=>{let t=typeof e[Symbol.iterator]==`function`?ji(e):Object.entries(e),n=[];for(let[e,r]of t)if(Array.isArray(r))for(let t=0;t<r.length;t++)r[t]!==void 0&&n.push([e,String(r[t])]);else if(typeof r==`object`){let t=Cb(r);for(let[r,i]of t)n.push([[e,...typeof r==`string`?[r]:r],i])}else r!==void 0&&n.push([e,String(r)]);return n},wb=mn((e,t)=>Tb(e.params,t.params)),Tb=Wi(wi([gn(),gn()])),Eb=xb([]),Db=T(2,(e,t)=>{let n=Sb(t),r=n.params,i=new Set;for(let e=0;e<r.length;e++)i.add(r[e][0]);for(let t=0;t<e.params.length;t++)i.has(e.params[t][0])||r.push(e.params[t]);return n}),Ob=`~effect/http/HttpBody`;No(`HttpBodyError`);var kb=class{[Ob];constructor(){this[Ob]=Ob}[Fn](){return this.toJSON()}toString(){return k(this,{ignoreToString:!0})}},Ab=new class extends kb{_tag=`Empty`;toJSON(){return{_id:`effect/HttpBody`,_tag:`Empty`}}},jb=class extends kb{_tag=`Uint8Array`;body;contentType;contentLength;constructor(e,t,n){super(),this.body=e,this.contentType=t,this.contentLength=n}toJSON(){return{_id:`effect/HttpBody`,_tag:`Uint8Array`,body:this.contentType.startsWith(`text/`)||this.contentType.endsWith(`json`)?new TextDecoder().decode(this.body):`Uint8Array(${this.body.length})`,contentType:this.contentType,contentLength:this.contentLength}}},Mb=(e,t)=>new jb(e,t??`application/octet-stream`,e.length),Nb=new TextEncoder,Pb=(e,t)=>Mb(Nb.encode(e),t??`text/plain`),Fb=(e,t)=>Pb(JSON.stringify(e),t??`application/json`),Ib=`~effect/http/HttpClientError`,Lb=class extends No(`HttpClientError`){constructor(e){`cause`in e.reason?super({...e,cause:e.reason.cause}):super(e)}[Ib]=Ib;get request(){return this.reason.request}get response(){return`response`in this.reason?this.reason.response:void 0}get message(){return this.reason.message}},Rb=e=>e.endsWith(`Error`)?e.slice(0,-5):e,zb=(e,t,n)=>t?`${e}: ${t} (${n})`:`${e} error (${n})`,Bb=class extends No(`TransportError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return zb(Rb(this._tag),this.description,this.methodAndUrl)}};No(`EncodeError`);var Vb=class extends No(`InvalidUrlError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return zb(Rb(this._tag),this.description,this.methodAndUrl)}},Hb=class extends No(`StatusCodeError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return zb(Rb(this._tag),this.description,e)}},Ub=class extends No(`DecodeError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return zb(Rb(this._tag),this.description,e)}},Wb=class extends No(`EmptyBodyError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return zb(Rb(this._tag),this.description,e)}};cy(Ib)({_tag:bv(`HttpError`),kind:q([`EncodeError`,`DecodeError`,`TransportError`,`InvalidUrlError`,`StatusCodeError`,`EmptyBodyError`]),cause:V(Jv())});var Gb=[[`GET`,`get`],[`POST`,`post`],[`PUT`,`put`],[`DELETE`,`del`],[`PATCH`,`patch`],[`HEAD`,`head`],[`OPTIONS`,`options`],[`TRACE`,`trace`]],Kb=(e,t)=>t._tag===`Empty`||t._tag===`FormData`?mb(mb(e,`content-type`),`content-length`):(e=t.contentType===void 0?mb(e,`content-type`):db(e,`content-type`,t.contentType),t.contentLength===void 0?mb(e,`content-length`):db(e,`content-length`,t.contentLength.toString())),qb=class extends No(`UrlError`){},Jb=(e,t,n)=>Si({try:()=>{let r=new URL(e,Yb());for(let e=0;e<t.params.length;e++){let[n,i]=t.params[e];i!==void 0&&r.searchParams.append(n,i)}return n!==void 0&&(r.hash=n),r},catch:e=>new qb({cause:e})}),Yb=()=>{if(`location`in globalThis&&globalThis.location!==void 0&&globalThis.location.origin!==void 0&&globalThis.location.pathname!==void 0)return location.origin+location.pathname},Xb=`~effect/http/HttpClientRequest`,Zb={[Xb]:Xb,...Ln,toJSON(){return{_id:`HttpClientRequest`,method:this.method,url:this.url,urlParams:this.urlParams,hash:this.hash,headers:wn(this.headers),body:this.body.toJSON()}},pipe(){return st(this,arguments)}};function Qb(e,t,n,r,i,a){let o=Object.create(Zb);return o.method=e,o.url=t,o.urlParams=n,o.hash=r,o.headers=i,o.body=a,o}var $b=Qb(`GET`,``,Eb,ui(),cb,Ab),ex=e=>(t,n)=>rx($b,{method:e,url:t,...n??void 0}),tx=ex(`POST`),nx=ex(`DELETE`),rx=T(2,(e,t)=>{let n=e;return t.method&&(n=ix(n,t.method)),t.url&&(n=lx(n,t.url)),t.headers&&(n=ox(n,t.headers)),t.urlParams&&(n=ux(n,t.urlParams)),t.hash&&(n=dx(n,t.hash)),t.body&&(n=fx(n,t.body)),t.accept&&(n=sx(n,t.accept)),t.acceptJson&&(n=cx(n)),n}),ix=T(2,(e,t)=>Qb(t,e.url,e.urlParams,e.hash,e.headers,e.body)),ax=T(3,(e,t,n)=>Qb(e.method,e.url,e.urlParams,e.hash,db(e.headers,t,n),e.body)),ox=T(2,(e,t)=>Qb(e.method,e.url,e.urlParams,e.hash,fb(e.headers,t),e.body)),sx=T(2,(e,t)=>ax(e,`Accept`,t)),cx=sx(`application/json`),lx=T(2,(e,t)=>{if(typeof t==`string`)return Qb(e.method,t,e.urlParams,e.hash,e.headers,e.body);let n=new URL(t.toString()),r=Sb(n.searchParams),i=gi(n.hash===``?void 0:n.hash.slice(1));return n.search=``,n.hash=``,Qb(e.method,n.toString(),r,i,e.headers,e.body)}),ux=T(2,(e,t)=>Qb(e.method,e.url,Db(e.urlParams,t),e.hash,e.headers,e.body)),dx=T(2,(e,t)=>Qb(e.method,e.url,e.urlParams,di(t),e.headers,e.body)),fx=T(2,(e,t)=>Qb(e.method,e.url,e.urlParams,e.hash,Kb(e.headers,t),t)),px=T(2,(e,t)=>fx(e,Fb(t))),mx=`~effect/http/HttpIncomingMessage`,hx=(e,t)=>{let n=H_(uy(e)),r=t?.reviver===void 0?void 0:H_(ey(uy(e),t));return e=>r===void 0?tf(e.json,e=>n(e,t)):tf(e.text,i=>i===``?tf(e.json,e=>n(e,t)):r(i,t))},gx=(e,t)=>{let n=e.headers[`content-type`]??``,r;if(n.includes(`application/json`))try{r=L(e.json)}catch{}else if(n.includes(`text/`)||n.includes(`urlencoded`))try{r=L(e.text)}catch{}let i={...t,headers:wn(e.headers),remoteAddress:e.remoteAddress};return r!==void 0&&(i.body=r),i},_x=`~effect/http/HttpClientResponse`,vx=(e,t)=>new bx(e,t),yx=e=>e.status>=200&&e.status<300?P(e):F(new Lb({reason:new Hb({response:e,request:e.request,description:`non 2xx status code`})})),bx=class extends Rn{[mx];[_x];request;source;constructor(e,t){super(),this.request=e,this.source=t,this[mx]=mx,this[_x]=_x}toJSON(){return gx(this,{_id:`HttpClientResponse`,request:this.request.toJSON(),status:this.status})}get status(){return this.source.status}get headers(){return lb(this.source.headers)}cachedCookies;get cookies(){return this.cachedCookies?this.cachedCookies:this.cachedCookies=$y(this.source.headers.getSetCookie())}get remoteAddress(){return ui()}get stream(){return this.source.body?Oy({evaluate:()=>this.source.body,onError:e=>new Lb({reason:new Ub({request:this.request,response:this,cause:e})})}):Dy(new Lb({reason:new Wb({request:this.request,response:this,description:`can not create stream from empty body`})}))}get json(){return tf(this.text,e=>$d({try:()=>e===``?null:JSON.parse(e),catch:e=>new Lb({reason:new Ub({request:this.request,response:this,cause:e})})}))}textBody;get text(){return this.textBody??=cf(this.arrayBuffer,e=>new TextDecoder().decode(e))}get urlParamsBody(){return tf(this.text,e=>$d({try:()=>Sb(new URLSearchParams(e)),catch:e=>new Lb({reason:new Ub({request:this.request,response:this,cause:e})})}))}formDataBody;get formData(){return this.formDataBody??=Ud({try:()=>this.source.formData(),catch:e=>new Lb({reason:new Ub({request:this.request,response:this,cause:e})})}).pipe(Tf,L)}arrayBufferBody;get arrayBuffer(){return this.arrayBufferBody||=Ud({try:()=>this.source.arrayBuffer(),catch:e=>new Lb({reason:new Ub({request:this.request,response:this,cause:e})})}).pipe(Tf,L),this.arrayBufferBody}pipe(){return st(this,arguments)}},xx=e=>ub({b3:`${e.traceId}-${e.spanId}-${e.sampled?`1`:`0`}${mi(e.parent,{onNone:()=>``,onSome:e=>`-${e.spanId}`})}`,traceparent:`00-${e.traceId}-${e.spanId}-${e.sampled?`01`:`00`}`}),Sx=`~effect/http/HttpClient`,Cx=da(`effect/HttpClient`),wx=T(2,(e,t)=>Ex(n=>t(e.postprocess(n)),e.preprocess)),Tx=wx(tf(yx)),Ex=(e,t)=>{let n=Object.create(Dx);return n.preprocess=t,n.postprocess=e,n.execute=function(n){return e(t(n))},n},Dx={[Sx]:Sx,pipe(){return st(this,arguments)},...Ln,toJSON(){return{_id:`effect/HttpClient`}},...Object.fromEntries(Gb.map(([e,t])=>[t,function(t,n){return this.execute(ex(e)(t,n))}]))},Ox=e=>Ex(t=>tf(t,t=>ef(n=>{let r=Fx.get(t),i=r??new AbortController,a=Jb(t.url,t.urlParams,_i(t.hash));if(Ci(a))return F(new Lb({reason:new Vb({request:t,cause:a.failure})}));let o=a.success;if(n.getRef(zo)||n.getRef(kx)(t)){let a=e(t,o,i.signal,n);return r?a:Df(e=>hf(e(a),{onSuccess(e){return Px.register(e,i),P(new Ix(e,i))},onFailure(e){return Nu(e)&&i.abort(),Xd(e)}}))}return kf(n.getRef(Mx)(t),{kind:`client`},a=>{a.attribute(`http.request.method`,t.method),a.attribute(`server.address`,o.origin),o.port!==``&&a.attribute(`server.port`,+o.port),a.attribute(`url.full`,o.toString()),a.attribute(`url.path`,o.pathname),a.attribute(`url.scheme`,o.protocol.slice(0,-1));let s=o.search.slice(1);s!==``&&a.attribute(`url.query`,s);let c=n.getRef(_b),l=n.getRef(Ax);for(let e in t.headers)l(e,`request`)&&a.attribute(`http.request.header.${e}`,gb(e,c)?`<redacted>`:t.headers[e]);return t=n.getRef(jx)?ox(t,xx(a)):t,Df(s=>s(e(t,o,i.signal,n)).pipe(Af(a,{captureStackTrace:!1}),hf({onSuccess:e=>{a.attribute(`http.response.status_code`,e.status);for(let t in e.headers)l(t,`response`)&&a.attribute(`http.response.header.${t}`,gb(t,c)?`<redacted>`:e.headers[t]);return r?P(e):(Px.register(e,i),P(new Ix(e,i)))},onFailure(e){return!r&&Nu(e)&&i.abort(),Xd(e)}})))})})),P),kx=Ua(`effect/http/HttpClient/TracerDisabledWhen`,{defaultValue:()=>ft}),Ax=Ua(`effect/http/HttpClient/TracerHeaderFilter`,{defaultValue:()=>dt}),jx=Ua(`effect/HttpClient/TracerPropagationEnabled`,{defaultValue:dt}),Mx=Ua(`effect/http/HttpClient/SpanNameGenerator`,{defaultValue:()=>e=>`http.client ${e.method}`}),Nx=e=>_d(Cx)(_f(t=>cf(e,e=>wx(e,yf(e=>Va(t,e)))))),Px=(()=>{if(`FinalizationRegistry`in globalThis&&globalThis.FinalizationRegistry){let e=new FinalizationRegistry(e=>{e.abort()});return{register(t,n){e.register(t,n,t)},unregister(t){e.unregister(t)}}}let e=new Map;return{register(t,n){e.set(t,setTimeout(()=>n.abort(),5e3))},unregister(t){let n=e.get(t);n!==void 0&&(clearTimeout(n),e.delete(t))}}})(),Fx=new WeakMap,Ix=class{original;controller;constructor(e,t){this.original=e,this.controller=t}[_x]=_x;[mx]=mx;applyInterrupt(e){return Gd(()=>(Px.unregister(this.original),Ef(e,()=>Kd(()=>{this.controller.abort()}))))}get request(){return this.original.request}get status(){return this.original.status}get headers(){return this.original.headers}get cookies(){return this.original.cookies}get remoteAddress(){return this.original.remoteAddress}get formData(){return this.applyInterrupt(this.original.formData)}get text(){return this.applyInterrupt(this.original.text)}get json(){return this.applyInterrupt(this.original.json)}get urlParamsBody(){return this.applyInterrupt(this.original.urlParamsBody)}get arrayBuffer(){return this.applyInterrupt(this.original.arrayBuffer)}get stream(){return Ey(()=>(Px.unregister(this.original),ky(this.original.stream,Kd(()=>{this.controller.abort()}))))}toJSON(){return this.original.toJSON()}[Fn](){return this.original[Fn]()}pipe(){return st(this,arguments)}},Lx=Ua(`effect/http/FetchHttpClient/Fetch`,{defaultValue:()=>globalThis.fetch}),Rx=class extends da()(`effect/http/FetchHttpClient/RequestInit`){},zx=Nx(P(Ox((e,t,n,r)=>{let i=r.getRef(Lx),a=Pa(r.context,Rx)??{},o=a.headers?pb(lb(a.headers),e.headers):e.headers;o[`content-length`]&&(o=mb(o,`content-length`));let s=r=>cf(Ud({try:()=>i(t,{...a,method:e.method,headers:o,body:r,duplex:e.body._tag===`Stream`?`half`:void 0,signal:n}),catch:t=>new Lb({reason:new Bb({request:e,cause:t})})}),t=>vx(e,t));switch(e.body._tag){case`Raw`:case`Uint8Array`:return s(e.body.body);case`FormData`:return s(e.body.formData);case`Stream`:return tf(My(e.body.stream),s)}return s(void 0)}))),Bx=e=>e,Vx=(e,t,n)=>{let r=K([e,t]),i=z_(t);return r.pipe(vv(ev(t),{decode:Vp(e=>i(e)?e:n(e)),encode:Vp(e=>e)}))},Hx=e=>Fi(e)?`[${e.map(Hx).join(`,`)}]`:e===null||yt(e)||bt(e)||xt(e)?JSON.stringify(e):`{${Ri(Object.entries(e),([e])=>e,Pd).map(([e,t])=>`${JSON.stringify(e)}:${Hx(t)}`).join(`,`)}}`,Ux=e=>Hx(J_(_y)(e)),Wx=`0123456789abcdefghijklmnopqrstuvwxyz`,Gx=U.check(Tv(/^[a-z]+$/)),Kx=/^[0-9a-z]{24}$/,qx=(e,t)=>Object.assign(e,{idPrefix:t}),X=(e,t)=>{let n=J_(Gx)(e);return qx(U.check(Tv(RegExp(`^${n}_[0-9a-z]{24}$`))).pipe(J(t)),n)},Jx=qx(U.check(Tv(Kx)).pipe(J(`ignotum/id`)),void 0),Yx=X(`app`,`ignotum/hosted/AppId`),Xx=X(`dep`,`ignotum/hosted/VersionId`);X(`team`,`ignotum/hosted/TeamId`);var Zx=X(`table`,`ignotum/runtime/TableId`);X(`prn`,`ignotum/control/PlatformPrincipalId`),X(`ses`,`ignotum/auth/SessionId`),X(`acct`,`ignotum/auth/AccountId`),X(`ver`,`ignotum/auth/VerificationId`),X(`mbr`,`ignotum/auth/MemberId`),X(`invt`,`ignotum/auth/InvitationId`),X(`dvc`,`ignotum/auth/DeviceCodeId`),X(`auth`,`ignotum/auth/InternalId`);var Qx=X(`inv`,`ignotum/sync/InvocationId`),$x=X(`sub`,`ignotum/sync/SubscriptionId`);X(`conn`,`ignotum/gateway/ConnectionId`),X(`nonce`,`ignotum/runtime/RequestNonce`);var eS=X(`req`,`ignotum/runtime/RequestId`);X(`lock`,`ignotum/dev/DatabaseLockId`),X(`iid`,`ignotum/id/AppUserId`),X(`idu`,`ignotum/id/GlobalUserId`),X(`ids`,`ignotum/id/SessionId`),X(`idr`,`ignotum/id/RequestId`);var tS=X(`epoch`,`ignotum/id/SessionEpoch`),nS=[`jpeg`,`png`,`webp`,`avif`,`gif`],rS=q(nS),iS={avif:`image/avif`,gif:`image/gif`,jpeg:`image/jpeg`,png:`image/png`,webp:`image/webp`},aS={activeGrantsPerConnection:1024,distinctFilesPerQuerySnapshot:256,fileBytes:10485760,filesPerMutation:8,filenameBytes:255,mutationBytes:26214400,preparationLifetimeMillis:9e5,stagedBytesPerApp:104857600},oS=Object.assign(U.pipe(_v(Tv(/^file_[0-9A-Za-z_-]{20,128}$/)),J(`ignotum/file/FileId`)),{idPrefix:`file`});X(`upload`,`ignotum/file/FileUploadToken`),X(`grant`,`ignotum/file/FileGrantToken`);var sS=Symbol.for(`ignotum/file/FileValue`),cS=Symbol.for(`ignotum/file/FileGrant`),lS=e=>kt(e)&&D(e,sS)&&kt(e[sS])&&D(e[sS],`id`)&&z_(oS)(e[sS].id)&&D(e,`format`)&&z_(rS)(e.format)&&D(e,`name`)&&yt(e.name)&&D(e,`size`)&&bt(e.size)&&D(e,`mimeType`)&&e.mimeType===iS[e.format],uS=(e,t,n)=>{let r={format:t.format,mimeType:iS[t.format],name:t.name,size:t.size};return Object.defineProperty(r,sS,{configurable:!1,enumerable:!1,value:Object.freeze({id:e}),writable:!1}),n!==void 0&&Object.defineProperty(r,cS,{configurable:!1,enumerable:!1,value:n,writable:!1}),Object.freeze(r)},dS=(e,t)=>uS(e,t),fS=e=>e[sS].id,pS=(e,t)=>uS(fS(e),e,t),mS=e=>e[cS],hS=W({$ignotum:H(`file`),id:oS,format:rS,name:U,size:Rv.check(Iv({minimum:0,maximum:aS.fileBytes}))}),gS=W({id:oS,format:rS,name:U,size:Rv.check(Iv({minimum:0,maximum:aS.fileBytes}))}),_S=W({path:G(K([U,zv])),file:gS}),vS=F_(lS,{title:`FileValue`}),yS=hS.pipe(vv(vS,{decode:Vp(e=>dS(e.id,{format:e.format,name:e.name,size:e.size})),encode:Vp(e=>({$ignotum:`file`,format:e.format,id:fS(e),name:e.name,size:e.size}))})),bS=gv(()=>K([av,cv,Dv,U,Zv,yS,G(bS),dv(U,hv(bS))])),xS=dv(U,hv(ev(bS))),SS=e=>Mt(e)?Q_(Qv)(e):lS(e)?Q_(yS)(e):globalThis.Array.isArray(e)?e.map(SS):bt(e)?J_(Dv)(e):Et(e)||yt(e)||xt(e)?e:Object.fromEntries(Object.entries(e).flatMap(([e,t])=>t===void 0?[]:[[e,SS(t)]])),CS=e=>q_(vy)(SS(q_(xS)(e))),wS=e=>JSON.stringify(e),TS=(e,t,n)=>n.has(wS(t))?q_(Qv)(e):z_(hS)(e)?J_(yS)(e):globalThis.Array.isArray(e)?e.map((e,r)=>TS(e,[...t,r],n)):Et(e)||yt(e)||bt(e)||xt(e)?e:Object.fromEntries(Object.entries(e).map(([e,r])=>[e,TS(r,[...t,e],n)])),ES=(e,t)=>TS(e,[],new Set(t.map(wS))),DS=(e,t)=>{let n=new Set(t.map(wS));return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,TS(t,[e],n)]))},OS=Symbol.for(`ignotum/runtime/result/Result`),kS=Symbol.for(`ignotum/runtime/result/Completed`),AS=Symbol.for(`ignotum/runtime/result/Pending`),jS=`ignotum/error`,MS=Ag(),NS=fv(W({_tag:U}),[dv(U,_y)]).pipe(J(jS)),PS=class extends ly()(`InternalServerError`,{requestId:eS}){}.pipe(J(jS)),FS=e=>D(e,OS)?e[OS]:P(e);function IS(){let e=function(){};return e.prototype=la({label:`IgnotumResult`,evaluate(){return this[OS]}}),e}var LS=IS(),RS=class e extends LS{[OS];constructor(e,t){super(),this[OS]=e,t!==void 0&&Object.defineProperty(this,kS,{value:t})}catch(t){let n={};for(let[e,r]of Object.entries(t))wt(r)&&(n[e]=e=>FS(r(e)));let r=this[OS],i=df(r,n);return new e(i)}},zS=class{[AS]=AS},BS=e=>{if(D(e,kS))return e[kS]},VS=e=>D(e,kS)&&kt(e[kS])&&D(e[kS],`type`)&&e[kS].type===`Failure`,HS=e=>new RS(P(e),{type:`Success`,value:e}),US=e=>new RS(F(e),{type:`Failure`,error:e}),WS=e=>new RS(Yd(e)),GS=T(2,(e,t)=>{if(e instanceof zS){if(t.pending===void 0)throw Error(`A pending Result requires a pending matcher.`);return t.pending()}if(!D(e,OS))throw Error(`Unknown Result implementation.`);let n=BS(e);if(n?.type===`Success`){let e=n.value;return t.value(e)}if(!VS(e))throw Error(`Unknown or incomplete Result operation.`);let r=e[kS].error;if(r._tag===`InternalServerError`){let e=q_(PS)(r),n=t.internalError;if(n===void 0)throw e;return n(e)}let i=t.error;if(i===void 0)throw Error(`No matcher was provided for ${r._tag}.`);if(wt(i))return i(r);let a=i,o=Object.hasOwn(a,r._tag)?a[r._tag]:void 0;if(o===void 0)throw Error(`No matcher was provided for ${r._tag}.`);return o(r)}),KS=()=>new zS,qS=(e,t=[])=>{let n=G_(PS)(e);if(pi(n))return US(n.value);let r=G_(NS)(e);if(fi(r))throw Error(`The server returned an invalid application error.`);return US(MS({...DS(r.value,t),_tag:r.value._tag}))},JS={fail:US,match:GS,succeed:HS,try:WS},YS=U.check(Tv(/^(?!\/)(?![A-Za-z]:\/)(?!.*(?:^|\/)\.\.(?:\/|$))(?!.*(?:^|\/)\.(?:\/|$))(?!.*\/\/)[^\\\0]+$/)).pipe(J(`ignotum/version/ArtifactPath`)),XS=U.check(Tv(/^[0-9a-f]{64}$/)).pipe(J(`ignotum/version/Sha256`)),ZS=U.pipe(J(`ignotum/hosted/InvocationKey`)),QS=zv.pipe(J(`ignotum/hosted/ActivationGeneration`)),$S=zv.pipe(J(`ignotum/hosted/AppStateRevision`)),eC=Rv.check(Nv(0)).pipe(J(`ignotum/hosted/VersionNumber`));Rv.check(Nv(0)).pipe(J(`ignotum/platform/ClientApiVersion`)),Rv.check(Nv(0)).pipe(J(`ignotum/platform/ServerApiVersion`)),U.check(wv(),Tv(/^[a-z][a-z0-9]*(?:[./-][a-z0-9]+)*$/),Hv(128)).pipe(J(`ignotum/platform/CapabilityId`)),Rv.check(Nv(0)).pipe(J(`ignotum/platform/ProtocolVersion`));var tC=X(`hist`,`ignotum/hosted/DataHistoryId`),nC=e=>W(e).annotate({parseOptions:{onExcessProperty:`error`}}),rC=Rv.check(Pv(0),Fv(2**53-1)),iC=rC.check(Nv(0)),aC=nC({major:iC,minor:rC});nC({major:iC,minimumMinor:rC});var oC=(e,t)=>e.major-t.major||e.minor-t.minor,sC=e=>`/_ignotum/v${e.major}.${e.minor}`;q([`client.js`,`selection`,`sync`,`session`,`session/requests`,`session/callback`]);var cC=(e,t)=>`${sC(e)}/${t}`;U.check(Tv(/^v[1-9][0-9]*\.(?:0|[1-9][0-9]*)$/));var lC=Bx(nC({formatVersion:H(1),appId:Yx,versionNumber:eC.check(Fv(2**53-1)),platform:aC,activationGeneration:QS.check(Nv(0),Fv(2**53-1)),deploymentEpoch:iC,dataHistoryId:tC})),uC=(e,t)=>e.appId===t.appId&&e.versionNumber===t.versionNumber&&oC(e.platform,t.platform)===0&&e.activationGeneration===t.activationGeneration&&e.deploymentEpoch===t.deploymentEpoch&&e.dataHistoryId===t.dataHistoryId;nC({deploymentProtocol:H(3),selection:lC}),nC({formatVersion:H(1),operationId:Wv,source:mv(lC),target:lC,phase:q([`Closing`,`Preparing`,`Committed`,`Opening`,`Complete`,`Aborting`,`Aborted`])}).check(Y(e=>{if(e.source!==null){if(e.source.appId!==e.target.appId)return`A transition belongs to one app`;if(e.target.activationGeneration<=e.source.activationGeneration)return`A transition must advance the activation generation, including rollback`}})).annotate({parseOptions:{onExcessProperty:`error`}});var dC=G(aC).check(Y(e=>new Set(e.map(e=>e.major)).size===e.length?void 0:`Select exactly one minor for each supported major`));nC({formatVersion:H(1),operationId:Wv,deploymentEpoch:iC,phase:q([`Closing`,`Deploying`,`Verifying`,`Resuming`,`Complete`]),expectedBuild:U.check(Tv(/^[a-f0-9]{64}$/)),previousBuild:mv(U.check(Tv(/^[a-f0-9]{64}$/))),aborted:cv,previous:dC,target:dC,diagnostic:mv(U.check(Hv(4096))),cursor:mv(Wv)}).check(Y(e=>e.aborted&&e.previousBuild===null?`Bootstrap has no previous build to restore`:void 0)),W({buildSha256:XS,revisions:G(aC)});var fC=U.check(Tv(/^[a-z][a-z0-9_-]{0,63}$/)),pC=W({id:fC.pipe(J(`ignotum/id/UserId`)),name:V(U),email:V(U),image:V(U)}),mC=G(q([`name`,`email`,`image`])).check(Uv());xv(`IdRequired`,{}).pipe(J(jS));var hC=W({sessionEpoch:U,viewRevision:zv,user:mv(pC),validUntil:Dv}),gC=W({development:V(H(!0)),outcome:V(q([`SignedIn`,`ProfileUpdated`,`Cancelled`])),...hC.fields,serverTime:Dv,expiresAt:Dv}),_C=U.check(Y(e=>{if(!e.startsWith(`/`)||e.startsWith(`//`)||e.includes(`\\`))return!1;let t=new URL(e,`https://app.ignotum.invalid`);return t.origin===`https://app.ignotum.invalid`&&t.pathname!==`/_ignotum`&&!t.pathname.startsWith(`/_ignotum/`)},{message:`Return to a path within this app.`})),vC=W({intent:q([`signIn`,`requestProfile`]),profile:mC,returnTo:_C,sessionEpoch:U}),yC=W({redirectUrl:U,expiresAt:Dv}),bC=q([`SignedIn`,`ProfileUpdated`,`Cancelled`]),xC={major:1,minor:0},SC=cC(xC,`session`),CC=cC(xC,`session/requests`);cC(xC,`session/callback`);var wC=Bx(W({formatVersion:H(1),username:mv(fC),epoch:U})),TC=`ignotum.id.development`,EC=e=>crypto.getRandomValues(new Uint8Array(e)),DC=(e,t,n)=>{let r=256-256%e.length;if(r===256){let r=e.length-1;return(i=t)=>{if(!i)return``;let a=``;for(;;){let t=n(i),o=i;for(;o--;)if(a+=e[t[o]&r],a.length>=i)return a}}}let i=Math.ceil(409.6*t/r);return(a=t)=>{if(!a)return``;let o=``;for(;;){let t=n(i),s=i;for(;s--;)if(t[s]<r&&(o+=e[t[s]%e.length],o.length>=a))return o}}},OC=(e,t=21)=>DC(e,t|0,EC),kC=(e,t)=>J_(e)(e.idPrefix===void 0?t:`${e.idPrefix}_${t}`),AC=class e extends da()(`@ignotum/shared/id/IdGenerator`){static layer=hd(e,()=>{let t=OC(Wx,24);return e.of({generate:e=>Kd(()=>kC(e,t()))})});static deterministic=(t=1)=>hd(e,()=>{let n=new Map;return e.of({generate:e=>Kd(()=>{let r=(n.get(e.idPrefix)??t-1)+1;return n.set(e.idPrefix,r),kC(e,r.toString(36).padStart(24,`0`))})})})},jC=class extends ly()(`IdRequestError`,{message:U}){},MC=`ignotum.id.outcome`,NC=ey(wC),PC=class e extends da()(`ignotum/client/id/BrowserSession`){static layer=_d(e,Yd(function*(){let t=(yield*Cx).pipe(Tx),n=yield*AC,r=yield*Bg(1),i=new Set,a={status:`pending`},o,s=0,c=1/0,l=!1,u,d,f=()=>{for(let e of i)e()},p=e=>{s+=1,c=1/0,d!==void 0&&clearTimeout(d),o=void 0,a=e===void 0?{status:`pending`,outcome:a.outcome}:{status:`error`,error:e,outcome:a.outcome},f()},m=(e,t)=>{s+=1,d!==void 0&&clearTimeout(d),o=e,a=e.user===null?{status:`signedOut`,outcome:a.outcome}:{status:`signedIn`,user:e.user,outcome:a.outcome};let n=Math.max(0,e.validUntil-t);c=performance.now()+n,n<2147483647&&(d=setTimeout(()=>p(),n)),f()},h=()=>{o!==void 0&&performance.now()>=c&&p()};globalThis.addEventListener?.(`focus`,h),globalThis.document?.addEventListener(`visibilitychange`,h),yield*xf(()=>Kd(()=>{d!==void 0&&clearTimeout(d),i.clear(),globalThis.removeEventListener?.(`focus`,h),globalThis.document?.removeEventListener(`visibilitychange`,h)}));let g=()=>{try{let e=globalThis.sessionStorage.getItem(MC);if(e!==null){let t=G_(bC)(e);pi(t)&&(a={...a,outcome:t.value}),globalThis.sessionStorage.removeItem(MC)}}catch{}},_=()=>{if(!l||u===void 0)return``;let e=new URLSearchParams({epoch:u.epoch});return u.username!==null&&e.set(`username`,u.username),`?${e}`},v=R(`BrowserSession.read`)(function*(){return yield*t.get(`${SC}${_()}`,{headers:{"x-ignotum-request":`1`}}).pipe(tf(hx(gC)))}),y=0,b=r.withPermits(1)(Yd(function*(){let e=s;y=e;let t=performance.now(),r=yield*v();if(l=r.development===!0,l&&u===void 0){let e=globalThis.sessionStorage.getItem(TC);u=hi(e===null?ui():K_(NC)(e),()=>({formatVersion:1,username:null,epoch:``})),u.epoch===``&&(u={...u,epoch:yield*n.generate(tS)}),globalThis.sessionStorage.setItem(TC,Q_(NC)(u)),r=yield*v()}return s===e?(g(),r.outcome!==void 0&&(a={...a,outcome:r.outcome}),m(r,r.serverTime+performance.now()-t),r):o===void 0?yield*jC.make({message:`Your ID session changed while loading.`}):o})).pipe(I(()=>jC.make({message:`Could not load your ID session.`})),pf(e=>Kd(()=>{s===y&&p(e.message)}))),ee=R(`BrowserSession.start`)(function*(e,n,r){let i=o??(yield*b);if(e===`requestProfile`&&i.user===null)return yield*jC.make({message:`Sign in before requesting profile information.`});let a=yield*B_(vC)({intent:e,profile:n,sessionEpoch:i.sessionEpoch,returnTo:r??`${globalThis.location.pathname}${globalThis.location.search}${globalThis.location.hash}`}).pipe(I(()=>jC.make({message:`The ID request is invalid.`}))),s=yield*tx(CC).pipe(ax(`x-ignotum-request`,`1`),px(a),t.execute,tf(hx(yC)),I(()=>jC.make({message:`Could not start the ID request.`})));if(o?.sessionEpoch!==i.sessionEpoch)return yield*jC.make({message:`Your ID session changed. Try again.`});globalThis.location.assign(s.redirectUrl)}),x=Yd(function*(){let e=o??(yield*b);yield*nx(SC).pipe(ax(`x-ignotum-request`,`1`),px({sessionEpoch:e.sessionEpoch}),t.execute,I(()=>jC.make({message:`Could not sign out.`}))),p(),l&&(u={formatVersion:1,username:null,epoch:yield*n.generate(tS)},globalThis.sessionStorage.setItem(TC,Q_(NC)(u))),globalThis.location.reload()});return e.of({snapshot:()=>(h(),a),current:()=>(h(),o),subscribe:e=>(i.add(e),()=>{i.delete(e)}),accept:m,suspend:p,bootstrap:b,start:ee,signOut:x,socketParameters:_})})).pipe(Sd(zx))},FC=e=>W(e).annotate({parseOptions:{onExcessProperty:`error`}}),IC=X(`rec`,`ignotum/platform/RecoverySessionId`),LC=FC({invocationId:Qx,originalSelection:lC}),RC={maxOperations:1024,maxRetentionMs:6048e5};FC({formatVersion:H(1),appId:Yx,clientSessionId:IC,recordedAt:zv,expiresAt:zv,operations:G(LC).check(Hv(RC.maxOperations))}).check(Y(e=>{let t=[];(e.expiresAt<=e.recordedAt||e.expiresAt-e.recordedAt>RC.maxRetentionMs)&&t.push({path:[`expiresAt`],issue:`Recovery retention must be positive and bounded`}),e.operations.some(t=>t.originalSelection.appId!==e.appId)&&t.push({path:[`operations`],issue:`Recovery operations must belong to the record's app`});let n=e.operations.map(e=>`${e.originalSelection.dataHistoryId}/${e.invocationId}`);return new Set(n).size!==n.length&&t.push({path:[`operations`],issue:`Recovery operation identities must be unique within a data history`}),t})).annotate({parseOptions:{onExcessProperty:`error`}});var zC=U.check(Ev()).pipe(J(`ignotum/runtime/PaginationCursor`)),BC=Rv.check(Iv({minimum:1,maximum:1e3})).pipe(J(`ignotum/runtime/PaginationPageSize`));W({cursor:mv(zC),pageSize:BC});var VC=K([W({type:H(`Table`),createdAt:Rv,id:U}),W({type:H(`Index`),key:U.check(Tv(/^(?:[0-9a-f]{2})*$/)).pipe(J(`ignotum/runtime/EncodedIndexKey`))})]);ey(Bx(W({version:H(1),query:U,position:VC})));var HC=U.pipe(J(`ignotum/runtime/IndexIdentity`)),UC=U.check(Tv(/^(?:[0-9a-f]{2})*$/)).pipe(J(`ignotum/runtime/EncodedIndexKey`));K([cv,Dv,U]);var WC=U.check(Tv(/^[A-Za-z_$][A-Za-z0-9_$]*$/));rv([`api.`,WC,`.`,WC]);var GC=nv([`api.`,WC,`.`,WC]),KC=W({type:H(`Subscribe`),id:$x,function:GC,args:_y}),qC=W({type:H(`Unsubscribe`),id:$x}),JC=W({type:H(`Invoke`),id:Qx,kind:H(`Mutation`),function:GC,args:_y}),YC=K([KC,qC,W({type:H(`Prepare`),id:Qx,kind:H(`Mutation`),function:GC,args:_y,files:G(oS)}),JC]),XC=K([W({type:H(`Subscription`),id:$x}),W({type:H(`Invocation`),id:Qx})]),ZC=G(G(K([U,zv]))),QC=W({type:H(`Success`),value:V(_y),dates:V(ZC)}),$C=W({type:H(`Failure`),error:_y,dates:V(ZC)}),ew=K([QC,$C]),tw=W({session:V(hC),serverTime:V(Dv),type:H(`Handshake`),appId:Yx,versionId:Xx,generation:QS}),nw=W({identity:V(W({sessionEpoch:U,viewRevision:zv,dependsOnId:cv})),type:H(`Snapshot`),id:$x,result:ew,revision:$S,files:V(G(W({id:oS,url:U})))}),rw=W({sessionEpoch:V(U),type:H(`Preparation`),id:Qx,kind:H(`Mutation`),uploads:G(W({id:oS,url:V(U)}))}),iw=W({sessionEpoch:V(U),type:H(`Result`),id:Qx,result:QC,committedRevision:$S}),aw=W({sessionEpoch:V(U),type:H(`Result`),id:Qx,result:$C}),ow=q([`SessionChanged`,`SessionExpired`,`DuplicateOperationId`,`FunctionUnavailable`,`InvalidArguments`,`InvalidMessage`,`InvocationIdConflict`,`ResourceLimitExceeded`,`UnknownFunction`,`WrongFunctionKind`]),sw=W({sessionEpoch:V(U),type:H(`Error`),operation:V(XC),code:ow,message:U}),cw=W({type:H(`Version`),versionId:Xx,generation:QS}),lw=K([K([W({type:H(`Session`),event:H(`Updated`),serverTime:Dv,session:hC}),W({type:H(`Session`),event:q([`SignedOut`,`Revoked`,`Expired`,`Unavailable`,`Replaced`]),sessionEpoch:U})]),W({type:H(`Invalidate`),sessionEpoch:U,ids:G($x)}),tw,nw,rw,iw,aw,sw,cw]);ey(YC),ey(lw),U.pipe(J(`ignotum/hosted/QueryKey`));var uw=W({type:H(`Table`),tableId:Zx}),dw=W({type:H(`Document`),tableId:Zx,id:Jx}),fw=W({type:H(`IndexRange`),tableId:Zx,index:HC,lower:V(UC),upper:V(UC)}),pw=W({type:H(`IndexPoint`),tableId:Zx,index:HC,key:UC}),mw=K([W({type:H(`Id`)}),uw,dw,fw]),hw=K([uw,dw,pw]);K([mw,pw]);var gw=G(mw),_w=G(hw),vw=W({type:H(`Query`),result:ew,dependencies:gw,observedRevision:$S,files:V(G(_S))}),yw=K([W({type:H(`AddReference`),file:gS,tableId:Zx,documentId:Jx}),W({type:H(`RemoveReference`),fileId:oS,tableId:Zx,documentId:Jx})]),bw=W({id:Qx,dataHistoryId:V(tC),committedRevision:$S,effects:G(yw)});W({appId:Yx}),W({batches:G(bw)}),W({appId:Yx,invocationId:Qx,acknowledgedAt:Rv,dataHistoryId:tC}),W({completed:H(!0)});var xw=K([W({type:H(`Mutation`),result:QC,invalidations:_w,committedRevision:$S,fileEffects:V(bw)}),W({type:H(`Mutation`),result:$C})]);K([vw,xw]);var Sw=W({clientSessionId:IC,sessionEpoch:mv(U)});W({appId:Yx,identity:LC,owner:Sw});var Cw=K([W({type:H(`Settled`),result:xw}),W({type:H(`Interrupted`)}),W({type:H(`Pending`)}),W({type:H(`Uncertain`)})]),ww={appId:Yx,versionId:Xx,generation:QS,selection:V(lC),invocationKey:ZS,function:GC,args:_y,identity:V(hC)};K([W({...ww,type:H(`Query`)}),W({...ww,type:H(`Mutation`),invocationId:Qx,recoveryOwner:V(Sw),files:V(G(_S))})]),W({appId:Yx,expectedRevision:$S}),W({currentRevision:$S});var Tw=class extends ly()(`RuntimeVersionUnavailable`,{versionId:Xx,message:U}){},Ew=q([`SessionExpired`,`FunctionUnavailable`,`InvalidArguments`,`InvocationIdConflict`,`ResourceLimitExceeded`,`UnknownFunction`,`WrongFunctionKind`]),Dw=class extends ly()(`RuntimeInvocationRejected`,{code:Ew,invocationKey:ZS,message:U}){},Ow=class extends ly()(`RuntimeInvocationUnavailable`,{invocationKey:ZS,message:U}){};ly()(`RuntimeRevisionRejected`,{appId:Yx,message:U}),K([Tw,Dw,Ow]);var kw={major:1,minor:0},Aw=cC(kw,`sync`),jw=cC(kw,`selection`),Mw=W({protocolVersion:H(1),selection:lC}),Nw=K([W({type:H(`Connect`),protocolVersion:zv,selection:lC,clientSessionId:IC}),W({type:H(`Prepare`),invocationId:Qx,function:GC,args:_y,files:G(oS).check(Hv(aS.filesPerMutation))}),W({type:H(`Invoke`),invocationId:Qx,function:GC,args:_y}),W({type:H(`RecoverMutation`),id:U.check(Hv(128)),identity:LC}),W({type:H(`Subscribe`),id:$x,function:GC,args:_y}),W({type:H(`Unsubscribe`),id:$x})]),Pw=W({type:H(`UpgradeRequired`),selection:lC}),Fw=K([Pw,W({type:H(`Handshake`),protocolVersion:H(1),selection:lC,session:hC,serverTime:Dv}),W({type:H(`Preparation`),invocationId:Qx,uploads:G(W({id:oS,url:V(U)}))}),W({type:H(`MutationOutcome`),id:U,identity:LC,outcome:Cw}),W({type:H(`QuerySnapshot`),selection:lC,id:$x,result:vw,files:V(G(W({id:oS,url:U})))}),W({type:H(`Error`),id:V(U),code:q([`PlatformUpgrading`,`SessionExpired`,`InvalidMessage`,`Unavailable`,`InvalidArguments`,`InvocationIdConflict`,`ResourceLimitExceeded`]),message:U})]),Iw=class extends ly()(`ConnectionUnavailable`,{cause:V(Jv()),message:U}){},Lw=class extends ly()(`PlatformUpgrading`,{message:U}){},Rw=class extends ly()(`InvalidMutationArguments`,{cause:Jv(),function:GC,message:U}){},zw=class extends ly()(`InvalidServerMessage`,{cause:Jv(),message:U}){},Bw=class extends ly()(`ServerError`,{code:q([`PlatformUpgrading`,`SessionExpired`,`InvalidMessage`,`Unavailable`,`InvalidArguments`,`InvocationIdConflict`,`ResourceLimitExceeded`]),message:U}){},Vw=K([Lw,Iw,Rw,zw,Bw]),Hw=Ly([Fy(({attributes:e,error:t})=>{globalThis.console.error(`Ignotum infrastructure error`,t,e)})]);R(`ClientErrorReporter.report`)(function*(e){yield*Ry(Au(e))});var Uw=Bx(W({formatVersion:H(1),appId:Yx,clientSessionId:IC,attempts:zv.check(Fv(3)),attemptedAt:zv,target:mv(lC),uncertainStorage:cv}).annotate({parseOptions:{onExcessProperty:`error`}})),Ww=ey(Uw),Gw=class{selection;browser;callbacks;clientSessionId;key;tab;snapshot={phase:`connecting`,recovery:[]};listeners=new Set;target;attempt;disposed=!1;storageAvailable=!0;readyTimer;constructor(e,t,n){this.selection=e,this.browser=t,this.callbacks=n,this.key=`ignotum.v3.tab.${e.appId}`,this.tab={formatVersion:1,appId:e.appId,clientSessionId:IC.make(`rec_${t.crypto.randomUUID().replaceAll(`-`,``).slice(0,24)}`),attempts:0,attemptedAt:0,target:null,uncertainStorage:!1};try{let n=t.sessionStorage.getItem(this.key);if(n!==null){let t=K_(Ww)(n);pi(t)&&t.value.appId===e.appId&&(t.value.target===null||t.value.target.appId===e.appId)?this.tab=t.value:this.reportRecovery(`Saved update information could not be read. Previous mutation outcomes may be unknown.`)}}catch{this.storageAvailable=!1}let r=G_(W({__ignotumUpdate:Uw}))(t.history.state);pi(r)&&r.value.__ignotumUpdate.appId===e.appId&&r.value.__ignotumUpdate.attemptedAt>=this.tab.attemptedAt&&(r.value.__ignotumUpdate.target===null||r.value.__ignotumUpdate.target.appId===e.appId)&&(this.tab=r.value.__ignotumUpdate),this.tab.uncertainStorage&&this.reportRecovery(`Some previous mutation outcomes could not be saved in browser storage and remain unknown.`),this.clientSessionId=this.tab.clientSessionId,this.save()}getSnapshot=()=>this.snapshot;subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));update(e){if(!this.disposed){this.snapshot=e;for(let e of this.listeners)e()}}reportRecovery(e){this.snapshot.recovery.includes(e)||this.update({...this.snapshot,recovery:[...this.snapshot.recovery,e].slice(-100)})}dismissRecovery=()=>{this.tab={...this.tab,uncertainStorage:!1},this.save(),this.update({...this.snapshot,recovery:[]})};save(){let e=!1;try{this.browser.sessionStorage.setItem(this.key,Q_(Ww)(this.tab)),this.storageAvailable=!0,e=!0}catch{this.storageAvailable=!1}try{let t=G_(dv(U,iv))(this.browser.history.state);this.browser.history.replaceState({...hi(t,()=>({})),__ignotumUpdate:Q_(Uw)(this.tab)},``),e=!0}catch{}return e}get obsolete(){return this.target!==void 0||this.attempt!==void 0}get ready(){return this.snapshot.phase===`ready`&&!this.obsolete}connecting(){this.readyTimer!==void 0&&clearTimeout(this.readyTimer),this.obsolete||this.update({...this.snapshot,phase:`connecting`,message:void 0})}accepted(){this.obsolete||(this.update({...this.snapshot,phase:`ready`,message:void 0}),this.readyTimer!==void 0&&clearTimeout(this.readyTimer),this.readyTimer=setTimeout(()=>{this.tab={...this.tab,attempts:0,attemptedAt:0,target:null},this.save()},6e4))}unavailable(e=`The app could not check for updates. Reconnect and try again.`){this.readyTimer!==void 0&&clearTimeout(this.readyTimer),this.obsolete||this.update({...this.snapshot,phase:`error`,message:e})}require(e){return this.disposed?Promise.resolve():(e!==void 0&&(this.target=e),this.callbacks.stopAdmission(),this.attempt!==void 0&&this.snapshot.phase!==`error`?this.attempt:(this.readyTimer!==void 0&&clearTimeout(this.readyTimer),this.update({...this.snapshot,phase:`settling`,message:`Updating the app. Waiting briefly for pending changes…`}),this.attempt=this.run(),this.attempt))}async run(){let e=Date.now()+2e3;for(;!this.disposed&&this.callbacks.unresolved()>0&&Date.now()<e;)await new Promise(e=>setTimeout(e,25));if(!this.disposed)try{let e=this.callbacks.persist();for(let t of e)this.reportRecovery(t);e.length>0&&(this.tab={...this.tab,uncertainStorage:!0},await new Promise(e=>setTimeout(e,1e3)));let t=await this.callbacks.freshSelection();if(t!==void 0&&t.appId!==this.selection.appId)throw Error(`The app address now refers to a different app.`);this.target=t??this.target;let n=await this.browser.fetch(this.browser.location.href,{cache:`no-store`,credentials:`same-origin`,headers:{accept:`text/html`},signal:AbortSignal.timeout(1e4)});if(!n.ok)throw Error(`The updated app document is temporarily unavailable.`);if(await n.body?.cancel(),this.disposed)return;let r=t!==void 0&&this.tab.target!==null&&!uC(this.tab.target,t)?0:this.tab.attempts;if(r>=2)throw Error(`The app update could not load a consistent release. Try again when the connection or release is available.`);if(this.tab={...this.tab,attempts:r+1,attemptedAt:Date.now(),target:t??this.target??this.selection},!this.save())throw Error(`Browser storage is unavailable. Pending changes may have unknown outcomes. Use Reload app to continue the update.`);this.update({...this.snapshot,phase:`reloading`,message:`Loading the updated app…`}),this.callbacks.reload()}catch(e){this.update({...this.snapshot,phase:`error`,message:e instanceof Error?e.message:`The app update could not be loaded. Try again.`})}}retry=()=>{if(!this.disposed){if(!this.storageAvailable){this.callbacks.persist(),this.callbacks.reload();return}this.tab={...this.tab,attempts:0,attemptedAt:0},this.save(),this.attempt=void 0,this.require(this.target)}};async check(){if(this.obsolete||this.disposed)return!1;try{let e=await this.callbacks.freshSelection();return e===void 0||!uC(this.selection,e)?(this.require(e),!1):!this.obsolete&&!this.disposed}catch{return this.unavailable(),!1}}dispose(){this.disposed=!0,this.readyTimer!==void 0&&clearTimeout(this.readyTimer),this.listeners.clear()}},Kw={maxEntries:100,retentionMs:864e5,maxBytes:65536},qw=W({identity:LC,recordedAt:zv,expiresAt:zv,state:q([`pending`,`settled`,`interrupted`,`uncertain`])}),Jw=Bx(W({formatVersion:H(1),appId:Yx,sessionEpoch:U,clientSessionId:IC,entries:G(qw).check(Hv(Kw.maxEntries))}).check(Y(e=>{let t=e.entries.map(e=>Yw(e.identity));return new Set(t).size===t.length&&e.entries.every(t=>t.identity.originalSelection.appId===e.appId&&t.expiresAt>t.recordedAt&&t.expiresAt-t.recordedAt<=Kw.retentionMs)})).annotate({parseOptions:{onExcessProperty:`error`}})),Yw=e=>`${e.originalSelection.dataHistoryId}/${e.invocationId}`,Xw=e=>new TextEncoder().encode(e).byteLength,Zw=class{options;storageKey;clientSessionId;constructor(e){this.options=e,this.storageKey=`ignotum:recovery:${e.appId}`,this.clientSessionId=e.clientSessionId}storage(){let e=this.options.storage;return e===void 0?globalThis.sessionStorage:wt(e)?e():e}now(){return this.options.now?.()??Fp(Pp())}snapshot(e,t){return{clientSessionId:this.clientSessionId,entries:e,issues:t}}read(){let e;try{e=this.storage().getItem(this.storageKey)}catch{return this.snapshot([],[`denied`])}if(e===null)return this.snapshot([],[]);if(Xw(e)>Kw.maxBytes)return this.discard(`full`);let t=G_(ey(Jw))(e);if(t._tag===`None`||t.value.appId!==this.options.appId)return this.discard(`corrupt`);if(t.value.sessionEpoch!==this.options.sessionEpoch)return this.discard(`session-changed`);this.clientSessionId=t.value.clientSessionId;let n=this.now(),r=t.value.entries.filter(e=>e.expiresAt>n&&e.recordedAt<=n),i=r.length===t.value.entries.length?[]:[`expired`];return i.length===0?this.snapshot(r,i):this.persist(r,i)}discard(e){try{return this.storage().removeItem(this.storageKey),this.snapshot([],[e])}catch{return this.snapshot([],[e,`denied`])}}persist(e,t){let n={formatVersion:1,appId:this.options.appId,sessionEpoch:this.options.sessionEpoch,clientSessionId:this.clientSessionId,entries:e},r=X_(ey(Jw))(n);if(r._tag===`None`)return this.snapshot(e,[...t,`corrupt`]);if(Xw(r.value)>Kw.maxBytes)return this.snapshot(e,[...t,`full`]);try{return this.storage().setItem(this.storageKey,r.value),this.snapshot(e,t)}catch(n){return this.snapshot(e,[...t,n instanceof DOMException&&n.name===`QuotaExceededError`?`full`:`denied`])}}write(e){let t=this.read();if(t.issues.includes(`denied`))return t;let n=new Map(t.entries.map(e=>[Yw(e.identity),e])),r=this.now();for(let i of e){if(i.originalSelection.appId!==this.options.appId)return this.snapshot(t.entries,[...t.issues,`corrupt`]);let e=Yw(i);n.has(e)||n.set(e,{identity:{invocationId:i.invocationId,originalSelection:i.originalSelection},recordedAt:r,expiresAt:r+Kw.retentionMs,state:`pending`})}return n.size>Kw.maxEntries?this.snapshot(t.entries,[...t.issues,`full`]):this.persist([...n.values()],t.issues)}reconcile(e,t){let n=this.read();return n.issues.includes(`denied`)?n:this.persist(n.entries.map(n=>Yw(n.identity)===Yw(e)?{...n,state:t}:n),n.issues)}remove(e){let t=this.read();return t.issues.includes(`denied`)?t:this.persist(t.entries.filter(t=>Yw(t.identity)!==Yw(e)),t.issues)}clear(){try{return this.storage().removeItem(this.storageKey),this.snapshot([],[])}catch{return this.snapshot([],[`denied`])}}},Qw={url:e=>{let t=mS(e);if(t===void 0)throw Error(`This FileValue has no active query grant.`);return t}},$w={};for(let e of nS)$w[iS[e]]=e;var eT=lv.check(Y(e=>Object.prototype.toString.call(e)===`[object Object]`,{message:`Mutation objects must contain ordinary fields; built-in collections are unsupported.`})),tT=(e,t)=>{if(e instanceof File){t.add(e);return}if(!(lS(e)||Mt(e))){if(globalThis.Array.isArray(e)){for(let n of e)tT(n,t);return}if(kt(e))for(let n of Object.values(J_(eT)(e)))tT(n,t)}},nT=(e,t)=>e instanceof File?t.get(e):lS(e)||Mt(e)?e:globalThis.Array.isArray(e)?e.map(e=>nT(e,t)):kt(e)?Object.fromEntries(Object.entries(e).map(([e,n])=>[e,nT(n,t)])):e,rT=R(`SyncClient.prepareMutationArguments`)(function*(e){let t=yield*AC,n=yield*$d(()=>{let t=new Set;if(tT(e,t),t.size>aS.filesPerMutation)throw Error(`A mutation may upload at most ${aS.filesPerMutation} files.`);if([...t].reduce((e,t)=>e+t.size,0)>aS.mutationBytes)throw Error(`Mutation uploads may total at most ${aS.mutationBytes} bytes.`);return t}),r=new Map,i=new Map;for(let e of n){let n=yield*$d(()=>{let t=$w[e.type.toLowerCase()];if(t===void 0)throw Error(`File '${e.name}' has unsupported media type '${e.type||`unknown`}'.`);if(e.size===0||e.size>aS.fileBytes)throw Error(`File '${e.name}' must be between 1 and ${aS.fileBytes} bytes.`);if(new TextEncoder().encode(e.name).byteLength>aS.filenameBytes)throw Error(`File '${e.name}' has a filename that is too long.`);return t}),a=yield*t.generate(oS);r.set(e,dS(a,{format:n,name:e.name,size:e.size})),i.set(a,e)}return{value:n.size===0?e:yield*$d(()=>nT(e,r)),nativeFiles:i,fileIds:Array.from(i.keys())}}),iT=(e,t)=>{if(t.length===0)return e;let n=new Map;for(let e of t){if(n.has(e.id))throw Error(`A query file grant ID is duplicated.`);n.set(e.id,e.url)}let r=new Set,i=e=>{if(lS(e)){let t=fS(e),i=n.get(t);return i===void 0?e:(r.add(t),pS(e,i))}return globalThis.Array.isArray(e)?e.map(i):!kt(e)||Mt(e)?e:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,i(t)]))},a=i(e);if(r.size!==n.size)throw Error(`A query file grant has no result value.`);return a},aT=R(`uploadPreparedFiles`)(function*(e,t,n){let r=new Set(e.keys()),i=new Set,a=[];for(let n of t){if(!r.has(n.id)||i.has(n.id))return yield*zw.make({cause:Error(`Unexpected prepared file '${n.id}'.`),message:`The server returned invalid application file preparation data.`});i.add(n.id);let t=e.get(n.id);if(t===void 0)return yield*zw.make({cause:Error(`Missing native file '${n.id}'.`),message:`The server prepared an unknown application file.`});n.url!==void 0&&a.push({file:t,url:n.url})}if(i.size!==r.size)return yield*zw.make({cause:Error(`The server omitted a prepared file.`),message:`The server returned incomplete application file preparation data.`});yield*Vd(a,R(`SyncClient.uploadFile`)(function*({file:e,url:t}){let r=yield*Ud({try:n=>fetch(t,{method:`PUT`,body:e,headers:{"content-type":e.type},signal:n}),catch:t=>Iw.make({cause:t,message:`File '${e.name}' could not be uploaded.`})});if(!r.ok){let t=yield*Hd(()=>r.text());return yield*Rw.make({cause:Error(t),function:n,message:`File '${e.name}' was rejected by application storage.`})}}),{concurrency:3,discard:!0})}),oT=e=>{switch(e){case`denied`:return`Browser storage is unavailable. Some previous mutation outcomes may be unknown.`;case`full`:return`Browser recovery storage is full. Some mutation outcomes could not be saved.`;case`corrupt`:return`Saved mutation information could not be read. Its outcomes remain unknown.`;case`expired`:return`Some saved mutation information expired. Its outcomes remain unknown.`;case`session-changed`:return`The browser session changed. Previous mutation outcomes cannot be retrieved in this session.`}},sT=class{selection;browser;helpers;upgrade;queries;socket;acceptedSocket;session;ids;sessionEpoch;sessionViewRevision;unsubscribeSession;sessionDeadline=0;clientSessionId;journal;pending=new Map;recovery=new Map;recoveryDeadlines=new Map;recoveryTimeouts=new Map;recoveryTimers=new Set;reconnectTimer;handshakeTimer;sessionTimer;heartbeat;reconnectDelay=250;disposed=!1;readyWaiters=new Set;suspended=!0;lastActivity=Date.now();validation;connectionGeneration=0;constructor(e,t,n,r){this.selection=e,this.browser=t,this.helpers=n,this.upgrade=new Gw(e,t,{stopAdmission:()=>{this.suspended=!0;for(let e of this.pending.values())e.preparation!==void 0&&qu(e.prepared,F(Lw.make({message:`The app is updating. This upload was interrupted before its mutation ran.`})));r.stopAdmission()},unresolved:()=>this.pending.size,persist:()=>this.persistPending(),reload:r.reload,freshSelection:this.freshSelection}),this.clientSessionId=this.upgrade.clientSessionId,this.queries=n.makeQueryCache(Gd(()=>this.ids===void 0?Qd(`The client identity service is not ready.`):this.ids.generate($x)),e=>Kd(()=>{this.canSend()&&this.send(e)}))}attachSession(e,t){this.disposed||(this.unsubscribeSession?.(),this.session=e,this.ids=t,this.unsubscribeSession=e.subscribe(()=>{let t=e.current();(t===void 0||this.sessionEpoch!==void 0&&(t.sessionEpoch!==this.sessionEpoch||t.viewRevision!==this.sessionViewRevision))&&(this.queries.invalidatePrivate(),this.suspended=!0,this.acceptedSocket=void 0,this.socket?.close())}))}whenReady(){return this.upgrade.ready?Promise.resolve(!0):this.upgrade.obsolete||this.disposed?Promise.resolve(!1):new Promise(e=>{let t=r=>{n(),this.readyWaiters.delete(t),e(r)},n=this.upgrade.subscribe(()=>{(this.upgrade.ready||this.upgrade.obsolete||this.disposed)&&t(this.upgrade.ready)});this.readyWaiters.add(t)})}retry=()=>{this.upgrade.obsolete?this.upgrade.retry():this.resume()};recoverLoad=async()=>{await this.upgrade.check()};freshSelection=async()=>{let e=await this.browser.fetch(jw,{cache:`no-store`,credentials:`same-origin`,signal:AbortSignal.timeout(1e4)});if(!e.ok)throw Error(`The current app selection is unavailable.`);return _i(G_(Mw)(await e.json()))?.selection};start(){this.disposed||(this.browser.addEventListener(`pageshow`,this.resume),this.browser.addEventListener(`pagehide`,this.hide),this.browser.addEventListener(`online`,this.resume),this.browser.addEventListener(`offline`,this.offline),this.browser.addEventListener(`focus`,this.resume),this.browser.document.addEventListener(`visibilitychange`,this.visibility),this.heartbeat=setInterval(()=>{let e=Date.now();e-this.lastActivity>15e3&&this.resume(),this.lastActivity=e},5e3),this.connect())}canSend(){return!this.disposed&&!this.suspended&&!this.upgrade.obsolete&&this.acceptedSocket!==void 0&&this.acceptedSocket===this.socket&&this.socket.readyState===1&&Date.now()<this.sessionDeadline}send(e){this.socket?.readyState===1&&this.socket.send(Q_(ey(Nw))(e))}connect(){if(this.disposed||this.upgrade.obsolete)return;this.suspended=!0,this.upgrade.connecting(),this.acceptedSocket=void 0,this.recovery.clear();for(let e of this.recoveryTimers)clearTimeout(e);this.recoveryTimers.clear(),this.recoveryTimeouts.clear(),this.reconnectTimer!==void 0&&clearTimeout(this.reconnectTimer),this.handshakeTimer!==void 0&&clearTimeout(this.handshakeTimer),this.socket?.close(),this.socket=void 0;let e=++this.connectionGeneration;this.session!==void 0&&Ff(this.session.bootstrap).then(()=>{this.disposed||this.upgrade.obsolete||e!==this.connectionGeneration||this.openSocket()},()=>{this.disposed||this.upgrade.obsolete||e!==this.connectionGeneration||(this.upgrade.unavailable(`The browser session could not be verified. Reconnecting…`),this.reconnectTimer=setTimeout(()=>this.connect(),1e3))})}openSocket(){let e=new URL(Aw,this.browser.location.href);e.protocol=e.protocol===`https:`?`wss:`:`ws:`;let t=new WebSocket(e);this.socket=t,t.onopen=()=>{this.socket!==t||this.disposed||this.send({type:`Connect`,protocolVersion:1,selection:this.selection,clientSessionId:this.clientSessionId})},this.handshakeTimer=setTimeout(()=>{this.socket===t&&this.acceptedSocket!==t&&t.close()},1e4),t.onmessage=e=>{if(this.socket!==t||this.disposed)return;let n=G_(ey(Pw))(e.data);if(pi(n)){this.upgrade.require(n.value.selection);return}let r=G_(ey(Fw))(e.data);if(fi(r)){this.upgrade.require();return}this.message(t,r.value)},t.onerror=()=>t.close(),t.onclose=e=>{this.socket!==t||this.disposed||((e.code===1012||e.code===1008)&&this.queries.invalidatePrivate(),this.acceptedSocket=void 0,this.suspended=!0,this.handshakeTimer!==void 0&&clearTimeout(this.handshakeTimer),!this.upgrade.obsolete&&(this.upgrade.unavailable(`The connection was lost. Checking for updates before resuming…`),this.reconnectTimer=setTimeout(()=>this.connect(),this.reconnectDelay),this.reconnectDelay=Math.min(this.reconnectDelay*2,5e3)))}}message(e,t){if(t.type===`UpgradeRequired`){this.upgrade.require(t.selection);return}if(t.type===`Handshake`){if(!uC(this.selection,t.selection)){this.upgrade.require(t.selection);return}if(this.upgrade.obsolete)return;this.handshakeTimer!==void 0&&clearTimeout(this.handshakeTimer);let n=this.sessionEpoch;n!==void 0&&(n!==t.session.sessionEpoch||this.sessionViewRevision!==t.session.viewRevision)&&this.queries.invalidatePrivate(),this.sessionEpoch=t.session.sessionEpoch,this.sessionViewRevision=t.session.viewRevision,this.sessionDeadline=Date.now()+Math.max(0,t.session.validUntil-t.serverTime),this.sessionTimer!==void 0&&clearTimeout(this.sessionTimer),this.sessionTimer=setTimeout(()=>{this.session?.suspend(),this.queries.invalidatePrivate(),this.resume()},Math.min(2147483647,Math.max(0,this.sessionDeadline-Date.now()))),this.session?.accept(t.session,t.serverTime),this.journal=new Zw({appId:this.selection.appId,sessionEpoch:t.session.sessionEpoch,clientSessionId:this.clientSessionId,storage:()=>this.browser.sessionStorage});let r=this.journal.read();for(let e of r.issues)this.upgrade.reportRecovery(oT(e));if(r.clientSessionId!==this.clientSessionId){this.clientSessionId=r.clientSessionId,this.connect();return}if(n!==void 0&&n!==this.sessionEpoch){for(let[e,t]of this.pending)qu(t.prepared,F(Iw.make({message:`The session changed before file preparation completed.`}))),this.upgrade.reportRecovery(`Mutation ${e} has an unknown outcome because the session changed.`),qu(t.done,F(Iw.make({message:`The session changed. This mutation may already have completed.`})));this.pending.clear()}this.acceptedSocket=e,this.suspended=!1,this.reconnectDelay=250,this.upgrade.accepted();for(let e of this.queries.entries())this.send({type:`Subscribe`,id:e.subscriptionId,function:e.function,args:e.args});for(let e of r.entries)e.state===`pending`?this.pending.has(e.identity.invocationId)||this.recover(e.identity):(this.upgrade.reportRecovery(`Mutation ${e.identity.invocationId}: ${e.state}.`),this.journal.remove(e.identity));for(let e of this.pending.values())e.preparation===void 0?this.recover(e.identity):this.send(e.preparation);this.journal.write([]);return}if(this.acceptedSocket!==e){e.close();return}switch(t.type){case`Preparation`:{if(!this.canSend())return;let e=this.pending.get(t.invocationId);e?.preparation!==void 0&&qu(e.prepared,P(t.uploads));return}case`QuerySnapshot`:{if(!this.canSend())return;if(!uC(this.selection,t.selection)){this.upgrade.require(t.selection);return}let e=L(this.helpers.resultFromWire(t.result.result,t.files).pipe(df({InvalidServerMessage:e=>P(e)})));this.queries.setResult(t.id,e,t.result.observedRevision);return}case`MutationOutcome`:if(!uC(t.identity.originalSelection,this.selection)&&!this.recovery.has(t.id))return;this.outcome(t.id,t.identity,t.outcome);return;case`Error`:if(t.code===`PlatformUpgrading`){this.upgrade.require();return}if(t.code===`SessionExpired`){this.suspended=!0,this.session?.suspend(),this.queries.invalidatePrivate(),e.close();return}if(t.code===`InvalidArguments`||t.code===`InvocationIdConflict`||t.code===`ResourceLimitExceeded`){for(let[e,n]of this.pending){if(e!==t.id)continue;let r=F(Bw.make({code:t.code,message:t.message}));qu(n.prepared,r),qu(n.done,r),this.pending.delete(e),this.journal?.remove(n.identity);return}for(let e of this.queries.entries())if(e.subscriptionId===t.id){this.queries.setResult(e.subscriptionId,Bw.make({code:t.code,message:t.message}));return}return}this.upgrade.unavailable(t.message),e.close();return}}recover(e){if(!this.canSend())return;let t=`recovery:${e.originalSelection.dataHistoryId}:${e.invocationId}`;if(this.recovery.has(t))return;this.recovery.set(t,e);let n=this.recoveryDeadlines.get(t)??Date.now()+3e4;if(this.recoveryDeadlines.set(t,n),Date.now()>=n){this.outcome(t,e,{type:`Uncertain`});return}this.send({type:`RecoverMutation`,id:t,identity:e});let r=setTimeout(()=>{this.recoveryTimers.delete(r),this.recoveryTimeouts.delete(t),this.recovery.has(t)&&(this.recovery.delete(t),this.recover(e))},5e3);this.recoveryTimers.add(r),this.recoveryTimeouts.set(t,r)}outcome(e,t,n){let r=this.recovery.get(e),i=this.pending.get(t.invocationId);if(r===void 0&&i===void 0)return;let a=r??i.identity;if(a.invocationId!==t.invocationId||!uC(a.originalSelection,t.originalSelection))return;this.recovery.delete(e);let o=this.recoveryTimeouts.get(e);if(o!==void 0&&(clearTimeout(o),this.recoveryTimers.delete(o),this.recoveryTimeouts.delete(e)),n.type===`Pending`){let e=setTimeout(()=>{this.recoveryTimers.delete(e),this.recover(t)},1e3);this.recoveryTimers.add(e);return}let s=`recovery:${t.originalSelection.dataHistoryId}:${t.invocationId}`;this.recovery.delete(s),this.recoveryDeadlines.delete(s),i!==void 0&&(this.pending.delete(t.invocationId),n.type===`Settled`?qu(i.done,this.helpers.resultFromWire(n.result.result)):qu(i.done,F(Iw.make({message:n.type===`Interrupted`?`The mutation was interrupted before it committed.`:`The mutation outcome is unknown. Check the app before trying it again.`}))));let c=n.type===`Settled`?`settled`:n.type===`Interrupted`?`interrupted`:`uncertain`;if(r!==void 0||n.type!==`Settled`){let e=n.type===`Settled`?n.result.result.type===`Success`?`completed`:`completed with an error`:c;this.upgrade.reportRecovery(`Mutation ${t.invocationId}: ${e}.`)}for(let e of this.journal?.reconcile(t,c).issues??[])this.upgrade.reportRecovery(oT(e));for(let e of this.journal?.remove(t).issues??[])this.upgrade.reportRecovery(oT(e))}persistPending(){return this.pending.size===0?[]:this.journal===void 0?[`Pending mutation outcomes could not be saved and remain unknown.`]:this.journal.write([...this.pending.values()].map(e=>e.identity)).issues.map(oT)}observe=R(`ManagedBrowserClient.observe`)((e,t)=>this.queries.observe(e,t));mutate=R(`ManagedBrowserClient.mutate`)(function*(e,t){if(this.upgrade.obsolete)return yield*Lw.make({message:`The platform is updating. Try again after the app reloads.`});let n=yield*Hd(()=>this.validate());if(this.upgrade.obsolete)return yield*Lw.make({message:`The platform is updating. Try again after the app reloads.`});if(!n||!this.canSend()||this.sessionEpoch===void 0)return yield*Iw.make({message:`The app must reconnect and verify its selection before accepting a mutation.`});if(this.pending.size>=Kw.maxEntries)return yield*Iw.make({message:`Too many mutations are waiting for outcomes. Wait for them to settle before trying again.`});let r=this.ids;if(r===void 0)return yield*Iw.make({message:`The client is not ready.`});let i=yield*rT(t).pipe(bf(AC,r),I(t=>Rw.make({cause:t,function:e,message:`The mutation arguments cannot be sent.`}))),a=yield*$d({try:()=>CS(i.value),catch:t=>Rw.make({cause:t,function:e,message:`The mutation arguments cannot be sent.`})});if(!this.canSend())return yield*Lw.make({message:`The app is reconnecting or updating. Try again when it is ready.`});let o=yield*r.generate(Qx),s=yield*Uu(),c={invocationId:o,originalSelection:this.selection},l=yield*Uu(),u=i.fileIds.length===0?void 0:{type:`Prepare`,invocationId:o,function:e,args:a,files:i.fileIds};this.pending.set(o,{identity:c,sessionEpoch:this.sessionEpoch,done:s,prepared:l,preparation:u});for(let e of this.persistPending())this.upgrade.reportRecovery(e);if(u!==void 0){this.send(u),yield*Yd({self:this},function*(){let t=yield*Wu(l);if(yield*aT(i.nativeFiles,t,e),!this.canSend())return yield*Lw.make({message:`The app is reconnecting or updating. Try again when it is ready.`})}).pipe(pf(()=>Kd(()=>{this.pending.delete(o),this.journal?.remove(c)})));let t=this.pending.get(o);if(t===void 0)return yield*Wu(s);this.pending.set(o,{...t,preparation:void 0})}this.send({type:`Invoke`,invocationId:o,function:e,args:a});let d=setTimeout(()=>{this.recoveryTimers.delete(d),this.pending.has(o)&&this.recover(c)},5e3);return this.recoveryTimers.add(d),yield*Wu(s)}).bind(this);validate=()=>this.upgrade.obsolete||this.disposed?Promise.resolve(!1):(this.validation===void 0&&(this.validation=this.upgrade.check().then(e=>{let t=e&&this.canSend();return t&&this.upgrade.getSnapshot().phase!==`ready`&&this.upgrade.accepted(),t}).finally(()=>{this.validation=void 0})),this.validation);resume=()=>{this.disposed||this.upgrade.obsolete||(this.suspended=!0,this.acceptedSocket=void 0,this.recovery.clear(),this.queries.invalidate(void 0),this.connect())};offline=()=>{this.suspended=!0,this.acceptedSocket=void 0,this.upgrade.unavailable(`The app is offline. Reconnect to check for updates and mutation outcomes.`),this.socket?.close()};hide=()=>{for(let e of this.persistPending())this.upgrade.reportRecovery(e);this.suspended=!0,this.acceptedSocket=void 0,this.socket?.close()};visibility=()=>{this.browser.document.visibilityState===`visible`?this.resume():this.hide()};dispose(){if(!this.disposed){this.disposed=!0;for(let e of this.readyWaiters)e(!1);this.unsubscribeSession?.(),this.persistPending(),this.socket?.close(),this.reconnectTimer!==void 0&&clearTimeout(this.reconnectTimer),this.handshakeTimer!==void 0&&clearTimeout(this.handshakeTimer),this.sessionTimer!==void 0&&clearTimeout(this.sessionTimer),this.heartbeat!==void 0&&clearInterval(this.heartbeat);for(let e of this.recoveryTimers)clearTimeout(e);this.browser.removeEventListener(`pageshow`,this.resume),this.browser.removeEventListener(`pagehide`,this.hide),this.browser.removeEventListener(`online`,this.resume),this.browser.removeEventListener(`offline`,this.offline),this.browser.removeEventListener(`focus`,this.resume),this.browser.document.removeEventListener(`visibilitychange`,this.visibility),this.upgrade.dispose()}}},cT=(e,t)=>Ux([e,t]),lT=e=>({type:`Subscribe`,id:e.subscriptionId,function:e.function,args:e.args}),uT={makeQueryCache:(e,t)=>{let n=new Map,r=new Map,i=R(`SyncClient.QueryCache.observe`)(function*(i,a){let o=cT(i,a),s=n.get(o);if(s===void 0){let c={args:a,function:i,generation:0,listeners:new Set,revision:void 0,references:0,result:KS(),subscriptionId:yield*e};n.set(o,c),r.set(c.subscriptionId,c),yield*t(lT(c)),s=c}let c=s;c.references+=1,c.generation+=1;let l=!1;return{getSnapshot:()=>c.result,subscribe:e=>(c.listeners.add(e),()=>c.listeners.delete(e)),release:Yd(function*(){if(l||(l=!0,--c.references,c.references!==0))return;let e=++c.generation;yield*mf(`25 millis`),c.references===0&&c.generation===e&&n.get(o)===c&&(n.delete(o),r.delete(c.subscriptionId),yield*t({type:`Unsubscribe`,id:c.subscriptionId}))})}}),a=e=>{e.result=KS(),e.revision=void 0;for(let t of e.listeners)t()};return{invalidate:e=>{for(let t of n.values())(e===void 0||e.includes(t.subscriptionId))&&a(t)},invalidatePrivate:()=>{for(let e of n.values())e.dependsOnId!==!1&&a(e)},entries:()=>n.values(),getById:e=>r.get(e),observe:i,setResult:(e,t,n)=>{let i=r.get(e);if(i!==void 0){if(n!==void 0){if(i.revision!==void 0&&n<i.revision)return;i.revision=n}i.result=t;for(let e of i.listeners)e()}}}},queryIdentity:cT,resultFromWire:R(`SyncClient.resultFromWire`)((e,t=[])=>$d({try:()=>e.type===`Success`?JS.succeed(e.value===void 0?void 0:iT(ES(e.value,e.dates??[]),t)):qS(e.error,e.dates),catch:e=>zw.make({cause:e,message:`The server returned an invalid function result.`})}))},dT=class extends da()(`ignotum/client/sync/SyncClient`){},fT=()=>Ky(pd(dT)({observe:()=>F(Iw.make({message:`The application has not mounted.`})),mutate:()=>F(Iw.make({message:`The application has not mounted.`}))}).pipe(Cd(PC.layer),Cd(Hw),Cd(AC.layer))),pT=fT(),mT=(e,t,n)=>{let r=new sT(e,t,uT,n);pT.dispose(),pT=Ky(_d(dT,Yd(function*(){return r.attachSession(yield*PC,yield*AC),dT.of({observe:r.observe,mutate:r.mutate})})).pipe(Cd(PC.layer),Cd(Hw),Cd(AC.layer)));let i=pT;return i.runPromise(dT).then(()=>r.start(),()=>r.dispose()),{client:r,dispose:()=>{r.dispose(),i.dispose(),pT===i&&(pT=fT())}}},hT={declarationBytes:1048576,artifactBytes:16777216,totalArtifactBytes:134217728,serverArtifactBytes:67108864,artifacts:512,modules:512,importsPerModule:256,routes:512,layouts:128,functions:512,conversions:512,urlFields:64,literalValues:64,textLength:4096,configurationDepth:96,configurationNodes:65536,descriptorDepth:32,descriptorNodes:8192,graphDepth:64,moduleTokens:1e5},gT=e=>W(e).annotate({parseOptions:{onExcessProperty:`error`}}),_T=U.check(Bv(1),Hv(256)),vT=U.check(Hv(hT.textLength)),yT=U.check(Tv(/^[A-Za-z_$][A-Za-z0-9_$]*$/),wv());YS.check(wv(),Hv(512),Tv(/^(?:[A-Za-z0-9_-][A-Za-z0-9_.-]*\/)*[A-Za-z0-9_-][A-Za-z0-9_.-]*$/));var bT=U.check(wv(),Hv(512),Tv(/^app\/(?:client|server)\/(?:[A-Za-z0-9_-][A-Za-z0-9_.-]*\/)*[A-Za-z0-9_-][A-Za-z0-9_.-]*$/)).pipe(J(`ignotum/app-definition/AppModuleId`)),xT=_T.pipe(J(`ignotum/app-definition/RouteId`)),ST=_T.pipe(J(`ignotum/app-definition/LayoutId`)),CT=gT({module:bT,exportName:yT}),wT=K([vT,Dv,cv]),TT=K([gT({type:H(`string`)}),gT({type:H(`id`),table:_T}),gT({type:H(`number`)}),gT({type:H(`integer`)}),gT({type:H(`boolean`)}),gT({type:H(`literal`),value:wT}),gT({type:H(`literals`),values:G(wT).check(Bv(1),Hv(hT.literalValues),Y(e=>new Set(e.map(String)).size===e.length||`URL literal encodings must be unique`))})]),ET=e=>{switch(e.type){case`string`:return vT;case`id`:return Jx;case`number`:return Dv;case`integer`:return Rv;case`boolean`:return cv;case`literal`:return H(e.value);case`literals`:return q(e.values)}},DT=K([TT,gT({type:H(`array`),value:TT})]),OT=K([wT,G(wT).check(Hv(256))]),kT=K([DT,gT({type:H(`optional`),value:DT}),gT({type:H(`default`),value:DT,default:OT}).check(Y(e=>z_(e.value.type===`array`?G(ET(e.value.value)):ET(e.value))(e.default)||`The URL default must satisfy its value descriptor`)).annotate({parseOptions:{onExcessProperty:`error`}})]),AT=gT({name:_T,value:kT}),jT=gT({name:_T,value:K([TT,gT({type:H(`array`),value:gT({type:H(`string`)})})])}),MT=gT({description:V(vT),robots:V(vT)}),NT=gT({title:V(vT),meta:V(MT)}),PT=gT({title:V(vT),titleTemplate:V(vT.check(Y(e=>e.split(`%s`).length===2||`A title template must contain exactly one %s placeholder`))),meta:V(MT)}),FT=U.check(Hv(2048),Tv(/^\/(?!_ignotum(?:\/|$))[^?#\\\0]*$/)),IT=gT({id:xT,pattern:FT,directoryScope:V(FT),precedence:G(zv).check(Hv(128)),params:G(jT).check(Hv(hT.urlFields)),searchParams:G(AT).check(Hv(hT.urlFields)),page:CT,layouts:G(ST).check(Hv(hT.layouts)),metadata:NT,boundaries:gT({error:cv,invalid:cv})}),LT=gT({id:ST,scope:FT,parent:V(ST),module:CT,metadata:PT,boundaries:gT({error:cv,invalid:cv,notFound:cv})}),RT=class extends ly()(`RoutingDefinitionError`,{message:U,pattern:V(U)}){},zT=new Set(`await.break.case.catch.class.const.continue.debugger.default.delete.do.else.enum.export.extends.false.finally.for.function.if.implements.import.in.instanceof.interface.let.new.null.package.private.protected.public.return.static.super.switch.this.throw.true.try.typeof.var.void.while.with.yield`.split(`.`)),BT=U.check(Tv(/^[$_\p{ID_Start}][$\u200C\u200D\p{ID_Continue}]*$/u),Y(e=>!zT.has(e)||`Parameter names must be TypeScript identifiers`)),VT=IT.fields.pattern.check(Y(e=>e===`/`||!e.endsWith(`/`)&&!e.includes(`//`)||`Patterns must not contain empty segments or trailing slashes`),Y(e=>!/[[\]()\u0000-\u001F\u007F\uD800-\uDFFF]/u.test(e)||`Patterns must use decoded literal segments and supported parameter syntax`)),HT=(e,t)=>new RT({message:e,pattern:t}),UT=e=>e.kind===`Literal`?3:e.kind===`Parameter`?2:1,WT=e=>e.kind===`Literal`?e.value:`${e.kind===`Parameter`?`:`:`*`}${e.name}`,GT=e=>({pattern:`/${e.map(WT).join(`/`)}`,segments:e,precedence:e.map(UT)}),KT=e=>JSON.stringify(e.segments.map(e=>e.kind===`Literal`?[e.kind,e.value]:[e.kind])),qT=(e,t)=>{for(let n=0;n<Math.max(e.precedence.length,t.precedence.length);n++){let r=(t.precedence[n]??0)-(e.precedence[n]??0);if(r!==0)return r}return 0},JT=(e,t)=>e.segments.length<=t.segments.length&&e.segments.every((e,n)=>WT(e)===WT(t.segments[n])),YT=R(`Routing.parsePattern`)(function*(e){let t=yield*B_(VT)(e).pipe(I(()=>HT(`Route patterns must be canonical absolute paths outside /_ignotum.`,e)));if(t===`/`)return GT([]);let n=t.slice(1).split(`/`);if(n.length>128)return yield*HT(`Route patterns exceed the segment limit.`,t);let r=[],i=new Set;for(let[e,a]of n.entries())if(a.startsWith(`:`)||a.startsWith(`*`)){let o=yield*B_(BT)(a.slice(1)).pipe(I(()=>HT(`Route parameter names must be valid TypeScript identifiers.`,t)));if(i.has(o))return yield*HT(`Repeated route parameter '${o}'.`,t);if(i.add(o),a.startsWith(`*`)){if(e!==n.length-1)return yield*HT(`A catch-all must be the final segment.`,t);r.push({kind:`CatchAll`,name:o})}else r.push({kind:`Parameter`,name:o})}else{if(a===`.`||a===`..`||/[:*]/.test(a))return yield*HT(`Route literals must not contain dot segments or parameter syntax.`,t);r.push({kind:`Literal`,value:a})}return GT(r)}),XT=R(`Routing.compileRoute`)(function*(e){let t=yield*B_(IT)(e).pipe(I(()=>HT(`The route definition is invalid.`))),n=yield*YT(t.pattern),r=yield*YT(t.directoryScope??t.pattern);if(!JT(r,n)||r.segments.length<n.segments.length-1)return yield*HT(`A route directory must be its full pattern for an index page or its immediate parent for a page file.`,t.pattern);if(t.precedence.length!==n.precedence.length||t.precedence.some((e,t)=>e!==n.precedence[t]))return yield*HT(`Stored route precedence does not match its pattern.`,t.pattern);let i=n.segments.filter(e=>e.kind!==`Literal`);if(t.params.length!==i.length||new Set(t.params.map(e=>e.name)).size!==t.params.length)return yield*HT(`Route parameters must describe each dynamic name exactly once.`,t.pattern);for(let e of i){let n=t.params.find(t=>t.name===e.name);if(n===void 0||(e.kind===`CatchAll`?n.value.type!==`array`:n.value.type===`array`))return yield*HT(`Single parameters require scalar values and catch-alls require string arrays.`,t.pattern)}return new Set(t.searchParams.map(e=>e.name)).size===t.searchParams.length?{pattern:n,directory:r}:yield*HT(`Search parameter names must be unique.`,t.pattern)}),ZT=R(`Routing.validateRoutePattern`)(function*(e){return(yield*XT(e)).pattern}),QT=R(`Routing.compilePatterns`)(function*(e,t){let n=yield*B_(G(IT).check(Hv(hT.routes)))(e).pipe(I(()=>HT(`Route definitions are invalid or exceed the route limit.`))),r=yield*B_(G(LT).check(Hv(hT.layouts)))(t).pipe(I(()=>HT(`Layout definitions are invalid or exceed the layout limit.`)));if(new Set(n.map(e=>e.id)).size!==n.length)return yield*HT(`Route identities must be unique.`);if(new Set(r.map(e=>e.id)).size!==r.length)return yield*HT(`Layout identities must be unique.`);let i=yield*Vd(n,e=>XT(e)),a=yield*Vd(r,e=>YT(e.scope));if(new Set(i.map(e=>KT(e.pattern))).size!==n.length)return yield*HT(`Duplicate or structurally ambiguous route patterns.`);if(new Set(a.map(KT)).size!==r.length)return yield*HT(`Duplicate or structurally ambiguous layout scopes.`);let o=r.map((e,t)=>({layout:e,pattern:a[t]})),s=e=>o.filter(t=>JT(t.pattern,e)).sort((e,t)=>e.pattern.segments.length-t.pattern.segments.length).map(e=>e.layout);for(let{layout:e,pattern:t}of o){let n=s(t).filter(t=>t.id!==e.id);if(e.parent!==n.at(-1)?.id)return yield*HT(`Layout '${e.id}' must name its nearest directory layout as parent.`,e.scope)}let c=new Map,l=R(`Routing.addDirectory`)(function*(e){let t=KT(e),n=c.get(t);if(n!==void 0&&n.pattern!==e.pattern)return yield*HT(`Dynamic directory parameter names are structurally ambiguous.`,e.pattern);c.set(t,e)});yield*l(GT([]));for(let e of a)for(let t=1;t<=e.segments.length;t++)yield*l(GT(e.segments.slice(0,t)));let u=[];for(let[e,t]of n.entries()){let{pattern:n,directory:r}=i[e],a=s(r);if(t.layouts.length!==a.length||t.layouts.some((e,t)=>e!==a[t]?.id))return yield*HT(`Route '${t.id}' must include its complete directory layout branch.`,t.pattern);for(let e=1;e<=r.segments.length;e++)yield*l(GT(r.segments.slice(0,e)));u.push({route:t,pattern:n,layouts:a})}return{routes:u.sort((e,t)=>qT(e.pattern,t.pattern)),directories:[...c.values()].map(e=>({pattern:e,layouts:s(e)})).sort((e,t)=>qT(e.pattern,t.pattern))}}),$T=(e,t,n)=>{let r=[];for(let[n,i]of e.segments.entries()){let e=t[n];if(e===void 0||e.length===0)return;if(i.kind===`Literal`){if(i.value!==e)return}else if(i.kind===`Parameter`)r.push([i.name,e]);else return r.push([i.name,t.slice(n)]),Object.fromEntries(r)}if(!(!n&&t.length!==e.segments.length))return Object.fromEntries(r)},eE=(e,t)=>{if(t[0]===`_ignotum`)return{route:void 0,layouts:[],params:{}};for(let n of e.directories){let e=$T(n.pattern,t,!0);if(e!==void 0)return{route:void 0,layouts:n.layouts,params:e}}return{route:void 0,layouts:[],params:{}}},tE=(e,t)=>{if(t[0]===`_ignotum`)return{route:void 0,layouts:[],params:{}};for(let n of e.routes){let e=$T(n.pattern,t,!1);if(e!==void 0)return{route:n.route,layouts:n.layouts,params:e}}return eE(e,t)},nE=W({source:q([`params`,`searchParams`]),field:V(U),message:U}),rE=W({...W({segments:G(U),pathname:U,search:U,hash:U,canonicalUrl:U}).fields,pathComplete:cv}),iE=class extends ly()(`InvalidUrl`,{issues:G(nE),partial:V(rE)}){},aE=(e,t,n,r)=>iE.make({issues:[{source:e,field:n,message:t}],partial:r}),oE=(e,t)=>aE(e,`The URL field '${t}' does not match its declaration.`,t),sE=U.check(Bv(1),Tv(/^[^/\\\u0000-\u001f\u007f]+$/u),Y(e=>e!==`.`&&e!==`..`||`Dot segments are not allowed`)),cE=U.check(Tv(/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/)),lE=dv(U,iv),uE=W({params:V(iv),searchParams:V(iv),hash:V(U.check(Y(e=>!e.startsWith(`#`)||`Hash input must omit the leading #`)))}).annotate({parseOptions:{onExcessProperty:`error`}}),dE=R(`Routing.decodeComponent`)(function*(e,t,n,r){return yield*$d({try:()=>decodeURIComponent(e),catch:()=>aE(t,`The URL contains malformed escapes or Unicode.`,n,r)})}),fE=R(`Routing.encodeComponent`)(function*(e,t,n){return yield*$d({try:()=>encodeURIComponent(e),catch:()=>aE(t,`The URL contains malformed Unicode.`,n)})}),pE=R(`Routing.searchEntries`)(function*(e,t){yield*B_(U)(e).pipe(I(()=>aE(`searchParams`,`Search parameters must be URL query text.`,void 0,t)));let n=e.startsWith(`?`)?e.slice(1):e,r=[];for(let e of n.split(`&`)){if(e===``)continue;let n=e.indexOf(`=`),i=n<0?e:e.slice(0,n),a=n<0?``:e.slice(n+1),o=yield*dE(i.replaceAll(`+`,` `),`searchParams`,void 0,t);r.push([o,yield*dE(a.replaceAll(`+`,` `),`searchParams`,o,t)])}return r}),mE=R(`Routing.parseLocation`)(function*(e){yield*B_(U)(e).pipe(I(()=>aE(`params`,`A location must be URL text.`)));let t=e.indexOf(`#`),n=t<0?``:e.slice(t),r=t<0?e:e.slice(0,t),i=r.indexOf(`?`),a=i<0?``:r.slice(i),o=i<0?r:r.slice(0,i),s=o.length>1&&o.endsWith(`/`)?o.slice(0,-1):o,c=[],l=e=>({segments:[...c],pathname:s,search:a,hash:n,canonicalUrl:`${s}${a}${n}`,pathComplete:e});if(!o.startsWith(`/`)||o.startsWith(`//`))return yield*aE(`params`,`A location must start with exactly one application-root slash.`,void 0,l(!1));if(s!==`/`)for(let e of s.slice(1).split(`/`)){let t=yield*dE(e,`params`,void 0,l(!1));yield*H_(sE)(t).pipe(I(()=>aE(`params`,`Path segments must be nonempty and cannot contain slashes, dot navigation or control characters.`,void 0,l(!1)))),c.push(t)}return yield*pE(a,l(!0)),yield*dE(n.slice(1),`params`,void 0,l(!0)),{segments:c,pathname:s,search:a,hash:n,canonicalUrl:`${s}${a}${n}`}}),hE=e=>{switch(e.type){case`string`:return U;case`id`:return Jx;case`number`:return Dv;case`integer`:return Rv;case`boolean`:return cv;case`literal`:return H(e.value);case`literals`:return q(e.values)}},gE=R(`Routing.scalarText`)(function*(e,t,n,r){switch(e.type){case`number`:case`integer`:return yield*H_(cE)(t).pipe(I(()=>oE(n,r))),yield*B_(hE(e))(Number(t)).pipe(I(()=>oE(n,r)));case`boolean`:return(yield*B_(q([`true`,`false`]))(t).pipe(I(()=>oE(n,r))))===`true`;case`literal`:return yield*H_(H(String(e.value)))(t).pipe(I(()=>oE(n,r))),e.value;case`literals`:return yield*H_(q(e.values.map(String)))(t).pipe(I(()=>oE(n,r))),e.values.find(e=>String(e)===t);default:return yield*B_(hE(e))(t).pipe(I(()=>oE(n,r)))}}),_E=R(`Routing.suppliedValue`)(function*(e,t,n,r){let i=yield*B_(e.type===`array`?G(hE(e.value)):hE(e))(t).pipe(I(()=>oE(n,r)));for(let e of Mi(i))yield*fE(String(e),n,r);return i}),vE=R(`Routing.validateUrlDefinition`)(function*(e){let t=yield*B_(IT)(e).pipe(I(()=>aE(`params`,`The route's URL declaration is invalid.`))),n=yield*ZT(t).pipe(I(e=>aE(`params`,e.message)));for(let e of t.searchParams)yield*fE(e.name,`searchParams`,e.name),e.value.type==="default"&&(yield*_E(e.value.value,e.value.default,`searchParams`,e.name));return{route:t,pattern:n}}),yE=R(`Routing.inputRecord`)(function*(e,t,n){let r=yield*B_(lE)(e===void 0?{}:e).pipe(I(()=>aE(n,`The ${n} input must be an object.`)));for(let e of Object.keys(r))if(!t.some(t=>t.name===e))return yield*aE(n,`The URL field '${e}' is not declared.`,e);return r}),bE=(e,t)=>Object.hasOwn(e,t)?e[t]:void 0,xE=R(`Routing.pathValue`)(function*(e,t){let n=String(e);return yield*H_(sE)(n).pipe(I(()=>oE(`params`,t))),yield*fE(n,`params`,t),n}),SE=R(`Routing.decodeRouteInputs`)(function*(e,t,n){let{route:r}=yield*vE(e),i=yield*yE(t,r.params,`params`),a=[];for(let e of r.params){let t=bE(i,e.name);if(e.value.type===`array`){let n=yield*B_(G(U).check(Bv(1)))(t).pipe(I(()=>oE(`params`,e.name)));a.push([e.name,yield*Vd(n,t=>xE(t,e.name))])}else{let n=yield*B_(U)(t).pipe(I(()=>oE(`params`,e.name)));yield*xE(n,e.name),a.push([e.name,yield*gE(e.value,n,`params`,e.name)])}}let o=yield*pE(n),s=[];for(let e of r.searchParams){let t=o.filter(([t])=>t===e.name).map(([,e])=>e),n=e.value;if(t.length===0){if(n.type===`optional`){s.push([e.name,void 0]);continue}if(n.type==="default"){s.push([e.name,yield*_E(n.value,n.default,`searchParams`,e.name)]);continue}return yield*aE(`searchParams`,`The required URL field '${e.name}' is missing.`,e.name)}let r=n.type===`optional`||n.type==="default"?n.value:n;if(r.type===`array`)s.push([e.name,yield*Vd(t,t=>gE(r.value,t,`searchParams`,e.name))]);else{if(t.length!==1)return yield*aE(`searchParams`,`The scalar URL field '${e.name}' occurs more than once.`,e.name);s.push([e.name,yield*gE(r,t[0],`searchParams`,e.name)])}}return{params:Object.fromEntries(a),searchParams:Object.fromEntries(s)}}),CE=(e,t)=>Fi(e)&&Fi(t)?e.length===t.length&&e.every((e,n)=>e===t[n]):e===t,wE=R(`Routing.buildUrl`)(function*(e,t={}){let{route:n,pattern:r}=yield*vE(e),i=yield*B_(uE)(t).pipe(I(()=>aE(`params`,`The URL navigation input is invalid.`))),a=yield*yE(i.params,n.params,`params`),o=yield*yE(i.searchParams,n.searchParams,`searchParams`),s=[];for(let e of r.segments){if(e.kind===`Literal`){s.push(yield*fE(e.value,`params`));continue}let t=n.params.find(t=>t.name===e.name),r=Mi(yield*_E(t.value,bE(a,t.name),`params`,t.name));if(r.length===0)return yield*aE(`params`,`Catch-all parameters must contain at least one segment.`,t.name);for(let e of r)s.push(yield*fE(yield*xE(e,t.name),`params`,t.name))}if(s[0]===`_ignotum`){let e=r.segments[0];return yield*aE(`params`,`The /_ignotum path is reserved for the platform.`,e?.kind===`Parameter`||e?.kind===`CatchAll`?e.name:void 0)}let c=new URLSearchParams;for(let e of n.searchParams){let t=bE(o,e.name),n=e.value;if(t===void 0){if(n.type===`optional`||n.type==="default")continue;return yield*aE(`searchParams`,`The required URL field '${e.name}' is missing.`,e.name)}let r=yield*_E(n.type===`optional`||n.type==="default"?n.value:n,t,`searchParams`,e.name);if(n.type==="default"&&CE(r,n.default))continue;let i=Mi(r);if(i.length===0&&n.type!==`optional`&&n.type!=="default")return yield*aE(`searchParams`,`A required array cannot serialize as an absent search key.`,e.name);for(let t of i)c.append(e.name,String(t))}let l=c.toString(),u=i.hash===void 0||i.hash===``?``:`#${yield*fE(i.hash,`params`)}`;return`/${s.join(`/`)}${l===``?``:`?${l}`}${u}`}),TE=W({applicationName:U.check(Bv(1),Hv(256)),layouts:G(PT).check(Hv(hT.layouts)),page:V(NT),outcome:q([`Matched`,`Invalid`,`NotFound`])}).annotate({parseOptions:{onExcessProperty:`error`}}),EE=class extends ly()(`InvalidMetadata`,{message:U}){},DE=R(`Routing.resolveMetadata`)(function*(e){let{applicationName:t,layouts:n,page:r,outcome:i}=yield*H_(TE)(e).pipe(I(()=>EE.make({message:`Static metadata is invalid.`}))),a=t,o,s,c;for(let e of n)a=e.title??a,o=e.titleTemplate??o,s=e.meta?.description??s,c=e.meta?.robots??c;let l=i===`NotFound`?void 0:r,u=l?.title;u!==void 0&&(a=o===void 0?u:o.replace(`%s`,()=>u)),s=l?.meta?.description??s,c=i===`Matched`?l?.meta?.robots??c:`noindex`;let d=[];return s===void 0&&d.push(`description`),c===void 0&&d.push(`robots`),{title:a,meta:{description:s,robots:c},remove:d}}),OE=e=>e[0]===`_ignotum`,kE=R(`Routing.matchLocation`)(function*(e,t){let n=yield*mE(t).pipe(of);if(n._tag===`Failure`){let t=n.failure,r=t.partial,i=r?.segments??[],a=OE(i),o=r?.pathComplete?tE(e,i):eE(e,i);return{_tag:`Invalid`,status:400,route:!a&&r?.pathComplete?o.route:void 0,layouts:a?[]:o.layouts,reserved:a,location:void 0,issues:t.issues}}let r=n.success,i=OE(r.segments),a=tE(e,r.segments);if(i||a.route===void 0)return{_tag:`NotFound`,status:404,layouts:i?[]:a.layouts,reserved:i,location:r};let o=a.route,s=yield*SE(o,a.params,r.search).pipe(of);return s._tag===`Failure`?{_tag:`Invalid`,status:400,route:o,layouts:a.layouts,reserved:!1,location:r,issues:s.failure.issues}:{_tag:`Matched`,status:200,route:o,layouts:a.layouts,reserved:!1,location:r,...s.success}}),AE=t({createRouteReference:()=>ME,getRouteDefinition:()=>NE}),jE=Symbol.for(`ignotum/internal/routes/RouteReference`),ME=e=>({[jE]:q_(IT)(e)}),NE=e=>e[jE],PE=ke(void 0),FE=()=>{let e=Xe(PE);if(e===void 0)throw Error(`Ignotum routing hooks require a managed client mount.`);return e},IE=e=>{let[t,n]=He(e.getSnapshot);return Ge(()=>{let t=()=>n(e.getSnapshot()),r=e.subscribe(t);return t(),r},[e]),t};function LE(e,...t){return L(wE(NE(e),t[0]))}var RE=(e,t={})=>L(wE(NE(e),{params:t.params,searchParams:t.searchParams,hash:t.hash})),zE=W({params:V(iv),searchParams:V(iv),hash:V(U),replace:V(cv),scroll:V(q([`auto`,`preserve`]))}).annotate({parseOptions:{onExcessProperty:`error`}}),BE=()=>{let e=FE(),[t]=He(()=>Object.assign((t,...n)=>{let r=q_(zE)(n[0]??{});return e.navigate(RE(t,r),r)},{back:e.back,forward:e.forward}));return t},VE=()=>{let e=IE(FE());if(e.location===void 0)throw Error(`The initial Ignotum location has not committed.`);return e.location},HE=()=>IE(FE()).navigation,UE=({when:e})=>{let t=FE(),[n]=He(()=>Symbol(`blocker`));return IE(t),Ge(()=>{t.setBlocker(n,e)},[t,n,e]),Ge(()=>()=>t.setBlocker(n,!1),[t,n]),t.getBlocker(n)},WE=(e,t,n)=>{let r=t.location,i=t.branch?.outcome;if(r===void 0||i===void 0)return;let a=NE(e);if(n&&(i._tag!==`Matched`||i.route.id!==a.id))return;let o=L(mE(`${r.pathname}${r.search}`).pipe(of));if(o._tag===`Failure`)return;let s=L(QT([{...a,layouts:[]}],[]));for(let e=o.success.segments.length;e>=0&&(e!==0||o.success.segments.length===0);e--){let t=tE(s,o.success.segments.slice(0,e));if(t.route!==void 0){let e=L(SE(a,t.params,r.search).pipe(of));return e._tag===`Failure`?void 0:{...e.success,hash:r.hash}}if(n)break}};function GE(e,t){return WE(e,IE(FE()),t?.end??!0)}function KE(e){let t=FE(),n=WE(e,IE(t),!0);if(n===void 0)throw Error(`useRoute requires page '${NE(e).id}' to be active.`);return{...n,setSearchParams:(n,r)=>{let i=WE(e,t.getSnapshot(),!0),a=t.getSnapshot().location;if(i===void 0||a===void 0)throw Error(`Cannot update search parameters for an inactive route.`);let o=wt(n)?n(i.searchParams):n,s=RE(e,{params:i.params,searchParams:o,hash:i.hash}),c=new URL(s,t.browser.location.origin);c.pathname=a.pathname;let l=new Set(NE(e).searchParams.map(e=>e.name));for(let[e,t]of new URLSearchParams(a.search))l.has(e)||c.searchParams.append(e,t);return t.navigate(`${c.pathname}${c.search}${c.hash}`,{scroll:`preserve`,...r})}}}var qE=(e,t,n)=>{let r=L(mE(e).pipe(of)),i=L(mE(t).pipe(of));if(r._tag===`Failure`||i._tag===`Failure`)return!1;let a=r.success.segments,o=i.success.segments;return a.length!==o.length&&(n||o.length===0||a.length<o.length)?!1:o.every((e,t)=>a[t]===e)};function JE(e){let t=FE(),n=IE(t),{to:r,params:i,searchParams:a,hash:o,replace:s,scroll:c,preload:l=`intent`,end:u=!0,active:d=!1,class:f,onClick:p,onMouseEnter:m,onFocus:h,...g}=e,_=RE(r,{params:i,searchParams:a,hash:o}),v=d&&n.location!==void 0&&qE(n.location.pathname,_.split(/[?#]/)[0],u),y=()=>{l!==`none`&&t.preload(_).catch(()=>{})};return S(`a`,{...g,href:_,class:wt(f)?f({isActive:v}):f,"aria-current":v?`page`:g[`aria-current`],onClick:e=>{p?.(e);let n=e.currentTarget;e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||n.target!==``&&n.target.toLowerCase()!==`_self`||n.hasAttribute(`download`)||n.relList.contains(`external`)||n.origin!==t.browser.location.origin||`${n.pathname}${n.search}${n.hash}`!==_||(e.preventDefault(),t.navigate(_,{replace:s,scroll:c}))},onMouseEnter:e=>{m?.(e),e.defaultPrevented||y()},onFocus:e=>{h?.(e),e.defaultPrevented||y()}})}function YE(e){return S(JE,e)}function XE(e){return S(JE,{...e,active:!0})}function ZE(e){let t=FE(),n=RE(e.to,e),r=Ke(),i=e.replace??!0;return We(()=>{let a=JSON.stringify([n,i,e.scroll]);r.current!==a&&(r.current=a,t.navigate(n,{replace:i,scroll:e.scroll},!0))},[t,n,i,e.scroll]),null}var QE=W({formatVersion:H(1),key:U}),$E=W({formatVersion:H(2),key:U,index:mv(Rv)}),eD=Vx(Bx(QE),$E,e=>({formatVersion:2,key:e.key,index:null})),tD=W({__ignotumRouter:eD}),nD=dv(U,iv),rD=e=>`${e.location.pathname}${e.location.search}${e.location.hash}`,iD=class{browser;onTraversal;committed;actual;positions=new Map;seeking;originalScrollRestoration;direction=-1;scrollPending=!1;expectedKey;scroll=new Map;constructor(e,t){this.browser=e,this.onTraversal=t;let n=G_(tD)(e.history.state),r=n._tag===`Some`?n.value.__ignotumRouter:void 0;this.actual=this.committed={key:r?.key??e.crypto.randomUUID(),index:r?.index??0,href:rD(e)},this.write(this.actual,!1),this.originalScrollRestoration=e.history.scrollRestoration,e.history.scrollRestoration=`manual`,e.addEventListener(`popstate`,this.onPop),e.addEventListener(`scroll`,this.saveScroll)}write(e,t){let n=G_(nD)(this.browser.history.state),r={__ignotumRouter:Q_(eD)({formatVersion:2,key:e.key,index:e.index})},i=n._tag===`Some`?{...n.value,...r}:r;t?this.browser.history.pushState(i,``,e.href):this.browser.history.replaceState(i,``,e.href),this.positions.set(e.key,e.index)}saveScroll=()=>{this.scrollPending||this.scroll.set(this.committed.key,{x:this.browser.scrollX,y:this.browser.scrollY})};captureScroll(){return this.saveScroll(),this.scrollPending=!0,this.scroll.get(this.committed.key)??{x:this.browser.scrollX,y:this.browser.scrollY}}finishScroll(){this.scrollPending=!1,this.saveScroll()}restoreSourceScroll(){if(!this.scrollPending)return;let e=this.scroll.get(this.committed.key);e!==void 0&&this.browser.scrollTo(e.x,e.y),this.finishScroll()}onPop=()=>{let e=G_(tD)(this.browser.history.state),t=e._tag===`Some`?e.value.__ignotumRouter:void 0,n=t?.key??this.browser.crypto.randomUUID(),r=t?.index??this.positions.get(n)??this.actual.index+this.direction;this.actual={key:n,index:r,href:rD(this.browser)},this.write(this.actual,!1);let i=this.expectedKey;this.expectedKey=void 0;let a=this.seeking;if(a!==void 0&&(i===n||a.position.key===n)){this.advanceSeek();return}a!==void 0&&(this.seeking=void 0,L(Ku(a.done,!1))),this.onTraversal(this.actual)};advanceSeek(){let e=this.seeking;e!==void 0&&this.expectedKey===void 0&&(this.actual.key===e.position.key?(this.seeking=void 0,L(Ku(e.done,!0))):(this.expectedKey=e.position.key,this.browser.history.go(e.position.index-this.actual.index)))}seek(e){if(this.seeking!==void 0){if(this.seeking.position.key===e.key)return Ff(Wu(this.seeking.done));L(Ku(this.seeking.done,!1))}let t=Hu();return this.seeking={position:e,done:t},this.advanceSeek(),Ff(Wu(t))}commit(e,t){(t===`push`||t===`replace`)&&this.write(e,t===`push`),this.actual=this.committed=e}back=()=>{this.direction=-1,this.browser.history.back()};forward=()=>{this.direction=1,this.browser.history.forward()};dispose(){this.browser.removeEventListener(`popstate`,this.onPop),this.browser.removeEventListener(`scroll`,this.saveScroll),this.browser.history.scrollRestoration=this.originalScrollRestoration,this.seeking!==void 0&&L(Ku(this.seeking.done,!1))}},aD=F_(e=>wt(e)),oD=F_(e=>wt(e)),sD=F_(e=>wt(e)),cD=W({error:V(aD),invalid:V(oD),component:F_(e=>wt(e))}),lD=W({error:V(aD),invalid:V(oD),notFound:V(sD),component:F_(e=>wt(e))}),uD=dv(U,iv),dD=class extends ly()(`BranchLoadError`,{error:iv,branch:F_(e=>kt(e))}){},fD=(e,t,n)=>{let r=new URL(e,n),i=r.hash.slice(1);try{i=decodeURIComponent(i)}catch{}return{pathname:r.pathname,search:r.search,hash:i,key:t}},pD=class{registration;browser;selection;patterns;listeners=new Set;modules=new Map;styles=new Map;styleCleanups=new Set;redirects=new Set;history;blockers=new Set;blocked;upgrading=!1;admission;serial=0;transition;committedHref;disposed=!1;started=!1;snapshot={location:void 0,branch:void 0,navigation:{status:`idle`},failure:void 0,commit:0};constructor(e,t,n){this.registration=e,this.browser=n,this.selection=J_(lC)(t),this.patterns=L(QT(e.routes,e.layouts));for(let t of[...e.routes.map(e=>e.page),...e.layouts.map(e=>e.module)])if(!e.modules.has(t.module))throw Error(`Client module '${t.module}' is missing from registration.`)}getSnapshot=()=>this.snapshot;subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));update(e){this.snapshot=e;for(let e of this.listeners)e()}start(){if(this.started)throw Error(`The Ignotum router has already started.`);this.started=!0,this.history=new iD(this.browser,this.onTraversal),this.browser.addEventListener(`beforeunload`,this.onBeforeUnload);let e=this.history.committed;return this.transitionTo(e.href,`initial`,e.key,{},e)}onTraversal=e=>{this.redirects.clear(),this.history?.seek(this.history.committed),this.transitionTo(e.href,`traverse`,e.key,{},e)};back=()=>this.history?.back();forward=()=>this.history?.forward();onBeforeUnload=e=>{this.upgrading||this.blockers.size===0||(e.preventDefault(),e.returnValue=``)};stopForUpgrade=()=>{this.disposed||(this.upgrading=!0,this.browser.removeEventListener(`beforeunload`,this.onBeforeUnload),this.blockers.clear(),this.cancelPending())};upgrade=()=>{this.disposed||(this.stopForUpgrade(),this.browser.location.reload())};setAdmission(e){this.admission=e}setBlocker(e,t){t?this.blockers.add(e):this.blockers.delete(e),!t&&this.blocked?.remaining.delete(e)===!0&&this.releaseBlocked()}getBlocker(e){let t=this.blocked,n=this.snapshot.location;return t===void 0||n===void 0||!t.remaining.has(e)?{status:`idle`}:{status:`blocked`,from:n,to:t.transition.location,proceed:()=>{this.blocked===t&&(t.remaining.delete(e),this.releaseBlocked())},reset:()=>{this.blocked===t&&(this.cancelPending(),this.update({...this.snapshot,navigation:{status:`idle`}}))}}}releaseBlocked(){let e=this.blocked;e!==void 0&&(e.remaining.size===0?(this.blocked=void 0,this.loadTransition(e.transition)):this.update({...this.snapshot}))}navigate(e,t={},n=!1){if(this.disposed||this.upgrading)return Promise.resolve({status:`cancelled`});if(n||this.redirects.clear(),e===this.committedHref)return this.cancelPending(),this.update({...this.snapshot,navigation:{status:`idle`},failure:void 0}),Promise.resolve({status:`committed`});if(n&&(this.committedHref!==void 0&&this.redirects.add(this.committedHref),this.redirects.has(e)||this.redirects.size>=32)){let n=Error(`Ignotum redirect loop at '${e}'.`);return this.cancelPending(),this.update({...this.snapshot,navigation:{status:`idle`},failure:{error:n,retry:()=>{this.redirects.clear(),this.navigate(e,t,!0)}}}),Promise.resolve({status:`failed`,error:n})}let r=t.replace===!0?this.snapshot.location?.key??this.browser.crypto.randomUUID():this.browser.crypto.randomUUID();return this.transitionTo(e,t.replace===!0?`replace`:`push`,r,t)}preload=async e=>{if(this.disposed||this.upgrading||this.admission!==void 0&&!await this.admission.validate())return;let t=L(kE(this.patterns,e));await this.loadBranch(t,!1)};cancelPending(){this.history!==void 0&&this.history.seek(this.history.committed),this.blocked=void 0,this.transition!==void 0&&L(Ku(this.transition.completion,{status:`cancelled`})),this.transition=void 0}transitionTo(e,t,n,r={},i){if(this.disposed||this.upgrading)return Promise.resolve({status:`cancelled`});let a=this.history?.captureScroll()??{x:this.browser.scrollX,y:this.browser.scrollY};this.cancelPending();let o=fD(e,n,this.browser.location.origin),s=this.snapshot.location,c=s!==void 0&&s.pathname===o.pathname&&s.hash===o.hash,l=Hu(),u=i??{key:n,href:e,index:(this.history?.committed.index??0)+ +(t===`push`)},d={id:++this.serial,href:e,location:o,kind:t,completion:l,position:u,scroll:r.scroll??(c?`preserve`:`auto`),searchOnly:c,sourceScroll:a};return this.transition=d,t!==`initial`&&this.blockers.size>0&&this.snapshot.location!==void 0?(this.blocked={transition:d,remaining:new Set(this.blockers)},this.update({...this.snapshot,navigation:{status:`idle`},failure:void 0})):this.loadTransition(d),Ff(Wu(l))}loadTransition(e){let{href:t,location:n,kind:r}=e,i=L(kE(this.patterns,t));this.update({...this.snapshot,navigation:{status:`loading`,to:n},failure:void 0}),(async()=>{if(this.admission!==void 0&&!await this.admission.validate())throw Error(`The app must verify its current selection before navigating.`);if(this.upgrading||this.disposed)throw Error(`The app is updating.`);return this.loadBranch(i)})().then(async a=>{if(!(this.transition!==e||this.disposed))try{let o=this.history;if(o!==void 0){if(!await o.seek(o.committed)||this.transition!==e||this.disposed||r===`traverse`&&(!await o.seek(e.position)||this.transition!==e||this.disposed))return;o.commit(e.position,r)}this.applyMetadata(i),this.committedHref=t,this.update({location:n,branch:a,navigation:{status:`idle`},failure:void 0,commit:e.id})}catch(t){this.fail(e,t)}},t=>{this.fail(e,t),this.upgrading||this.admission?.recoverLoad()})}rendered(e){if(this.transition?.id!==e||this.snapshot.commit!==e){this.snapshot.navigation.status===`idle`&&this.blocked===void 0&&this.history?.restoreSourceScroll();return}let t=this.transition,n=this.browser.document;if(!t.searchOnly){let e=n.querySelector(`#app main, #app [role=main]`)??n.getElementById(`app`);e!==null&&(e.hasAttribute(`tabindex`)||e.setAttribute(`tabindex`,`-1`),e.focus({preventScroll:!0}))}let r=this.history?.scroll.get(t.location.key);if(t.kind===`traverse`&&r!==void 0)this.browser.scrollTo(r.x,r.y);else if(t.scroll===`auto`){let e=t.location.hash===``?null:n.getElementById(t.location.hash);e===null?this.browser.scrollTo(0,0):e.scrollIntoView()}else this.browser.scrollTo(t.sourceScroll.x,t.sourceScroll.y);this.history?.finishScroll(),L(Ku(this.transition.completion,{status:`committed`})),this.transition=void 0}fail(e,t){if(this.transition!==e||this.disposed)return;this.transition=void 0;let n=t instanceof dD?t:void 0,r=n===void 0?t:n.error;this.update({...this.snapshot,navigation:{status:`idle`},failure:{error:r,branch:e.kind===`initial`?void 0:n?.branch,retry:()=>{this.transitionTo(e.href,e.kind,e.location.key,{scroll:e.scroll},e.position)}}}),L(Ku(e.completion,{status:`failed`,error:r}))}loadStyle(e){let t=new URL(e,this.browser.location.origin).href,n=this.styles.get(t);if(n!==void 0)return n;let r=this.browser.document,i=Array.from(r.querySelectorAll(`link[rel="stylesheet"]`)).find(e=>e.href===t);if(i?.sheet!==null&&i?.sheet!==void 0)return Promise.resolve();let a=i??r.createElement(`link`),o=Ff(Jd(n=>{let o=()=>{a.removeEventListener(`load`,s),a.removeEventListener(`error`,c),this.styleCleanups.delete(l)},s=()=>{o(),n(qd)},c=()=>{o(),a.remove(),n(F(Error(`Could not load route stylesheet '${e}'.`)))},l=()=>{o(),i===void 0&&a.remove(),n(F(Error(`Router disposed.`)))};return this.styleCleanups.add(l),a.addEventListener(`load`,s),a.addEventListener(`error`,c),i===void 0&&(a.rel=`stylesheet`,a.crossOrigin=`anonymous`,a.href=t,r.head.append(a)),Kd(o)})).catch(e=>{throw this.styles.delete(t),e});return this.styles.set(t,o),o}loadModule(e){let t=this.modules.get(e);if(t!==void 0)return t;let n=this.registration.modules.get(e);if(n===void 0)return Promise.reject(Error(`Client module '${e}' is not registered.`));let r=Promise.resolve().then(n.load).then(q_(uD)).catch(t=>{throw this.modules.delete(e),t});return this.modules.set(e,r),r}async loadExport(e){let t=await this.loadModule(e.module);if(!Object.hasOwn(t,e.exportName))throw Error(`Module '${e.module}' has no '${e.exportName}' export.`);return t[e.exportName]}async loadBranch(e,t=!0){let n=e._tag===`NotFound`?void 0:e.route,r=new Map;try{let[i,a]=await Promise.all([Promise.all(e.layouts.map(async e=>{let[n]=await Promise.all([this.loadExport(e.module).then(q_(lD)),t?Promise.all((this.registration.modules.get(e.module.module)?.styles??[]).map(e=>this.loadStyle(e))):void 0]),i={id:e.id,...n};return r.set(e.id,i),i})),n===void 0?void 0:this.loadExport(n.page).then(q_(cD)),Promise.all(t?[...this.registration.styles??[],...n===void 0?[]:this.registration.modules.get(n.page.module)?.styles??[]].map(async e=>this.loadStyle(e)):[])]);return{outcome:e,layouts:i,page:a?.component,pageBoundaries:a}}catch(t){let n=[];for(let t of e.layouts){let e=r.get(t.id);if(e===void 0)break;n.push(e)}throw dD.make({error:t,branch:{outcome:e,layouts:n,page:void 0}})}}setRenderError(e){this.snapshot.branch!==void 0&&this.applyMetadata(this.snapshot.branch.outcome,e)}applyMetadata(e,t=!1){let n=L(DE({applicationName:this.registration.applicationName,layouts:e.layouts.map(e=>e.metadata),page:e._tag===`NotFound`?void 0:e.route?.metadata,outcome:t?`Invalid`:e._tag})),r=this.browser.document;r.title=n.title;for(let e of[`description`,`robots`]){let t=Array.from(r.head.querySelectorAll(`meta[name="${e}"]`)),i=n.meta[e];if(i===void 0){for(let e of t)e.remove();continue}let a=t.shift()??r.createElement(`meta`);for(let e of t)e.remove();a.name=e,a.content=i,a.isConnected||r.head.append(a)}}dispose(){this.disposed=!0,this.cancelPending(),this.history?.dispose(),this.browser.removeEventListener(`beforeunload`,this.onBeforeUnload);for(let e of this.styleCleanups)e();this.listeners.clear()}},mD=({error:e,retry:t})=>S(`div`,{role:`alert`},e instanceof Error?e.message:`This page could not load or render. `,S(`button`,{onClick:t},`Retry`)),hD=({children:e,component:t,branch:n,router:r,onRetry:i})=>{let[a,o]=He(),[,s]=Qe(e=>{o({branch:n,error:e}),r.setRenderError(!0)});return a?.branch===n?S(t,{error:a.error,retry:()=>{r.setRenderError(!1),i?.(),o(void 0),s()}}):e},gD=({branch:e,location:t,router:n,failure:r})=>{let i=e.outcome,a,o=e.layouts.length-1,s;if(i._tag===`Matched`&&e.page!==void 0)a=S(e.page,{key:i.route.id,params:i.params,searchParams:i.searchParams});else if(i._tag===`Invalid`&&e.pageBoundaries?.invalid!==void 0)a=S(e.pageBoundaries.invalid,{location:t,issues:i.issues});else{a=S(`main`,{"data-ignotum-outcome":i._tag},i._tag===`Invalid`?`Invalid URL`:`Page not found`);for(let n=o;n>=0;n--){let r=e.layouts[n];if(i._tag===`Invalid`&&r.invalid!==void 0){a=S(r.invalid,{location:t,issues:i.issues}),o=n,s=n;break}if(i._tag===`NotFound`&&r.notFound!==void 0){a=S(r.notFound,{location:t}),o=n,s=n;break}}}e.pageBoundaries?.error!==void 0&&i._tag===`Matched`&&(a=S(hD,{key:`page-boundary`,component:e.pageBoundaries.error,branch:e,router:n,children:a}));let c=0;for(;c<=o&&e.layouts[c]?.id===r?.branch?.layouts[c]?.id;)c++;let l=r===void 0?null:S(_D,{failure:r,router:n,layouts:e.layouts.slice(0,c)});for(let t=o;t>=0;t--){let r=e.layouts[t];r.error!==void 0&&t!==s&&(a=S(hD,{key:r.id,component:r.error,branch:e,router:n,children:a})),a=S(r.component,{key:r.id,children:S(ie,{},a,t===c-1?l:null)})}return S(hD,{component:mD,branch:e,router:n,children:S(ie,{},a,c===0?l:null)})},_D=({failure:e,router:t,layouts:n})=>{let r=e.branch;if(r===void 0)return S(`div`,{"data-ignotum-load-error":``},S(mD,e));let i=S(mD,e),a=!1;for(let o of[...n??r.layouts].reverse())o.error!==void 0&&(a?i=S(hD,{component:o.error,branch:r,router:t,onRetry:e.retry,children:i}):(i=S(o.error,{error:e.error,retry:e.retry}),a=!0));return S(`div`,{"data-ignotum-load-error":``},S(hD,{component:mD,branch:r,router:t,onRetry:e.retry,children:i}))},vD=({router:e})=>{let t=IE(e);return Ge(()=>{e.rendered(t.commit)},[e,t]),S(PE.Provider,{value:e},t.branch===void 0||t.location===void 0?S(`div`,{role:`status`},t.failure===void 0?`Loading…`:null):S(gD,{branch:t.branch,location:t.location,router:e,failure:t.failure}),t.failure!==void 0&&t.branch===void 0?S(_D,{failure:t.failure,router:e}):null)},yD=new WeakSet,bD=({client:e})=>{let[t,n]=He(e.upgrade.getSnapshot);return Ge(()=>e.upgrade.subscribe(()=>n(e.upgrade.getSnapshot())),[e]),t.phase===`ready`&&t.recovery.length===0?null:S(`aside`,{"data-ignotum-update":t.phase,role:t.phase===`error`?`alert`:`status`},t.message??(t.phase===`connecting`?`Connecting to the app…`:null),t.recovery.length===0?null:S(`ul`,null,t.recovery.map(e=>S(`li`,{key:e},e))),t.phase===`error`?S(`button`,{type:`button`,onClick:()=>e.retry()},`Reload app`):null,t.recovery.length===0?null:S(`button`,{type:`button`,onClick:e.upgrade.dismissRecovery},`Dismiss`))},xD=(e,t)=>{let n=window.document.getElementById(`app`);if(n===null)throw Error(`Ignotum mount element is missing.`);if(yD.has(n))throw Error(`The Ignotum client is already mounted.`);let r=new pD(e,t,window),i=mT(t,window,{stopAdmission:r.stopForUpgrade,reload:r.upgrade});r.setAdmission({validate:i.client.validate,recoverLoad:i.client.recoverLoad}),De(S(ie,null,S(bD,{client:i.client}),S(vD,{router:r})),n);let a=i.client.whenReady().then(e=>e?r.start():{status:`cancelled`});yD.add(n);let o=!1;return{ready:a,upgrade:()=>i.client.upgrade.require(),dispose:()=>{o||(o=!0,yD.delete(n),r.dispose(),i.dispose(),De(null,n))}}},SD=t({createApi:()=>ED,functionPathOf:()=>wD}),CD=Symbol.for(`ignotum/internal/api/FunctionReference`),wD=e=>e[CD],TD=e=>{let t=new Map;return new Proxy({},{get:(n,r)=>{if(!yt(r))return;let i=t.get(r);if(i!==void 0)return i;let a={[CD]:GC.make(`api.${e}.${r}`)};return t.set(r,a),a}})};function ED(){let e=new Map;return new Proxy({},{get:(t,n)=>{if(!yt(n))return;let r=e.get(n);if(r!==void 0)return r;let i=TD(n);return e.set(n,i),i}})}var DD=Symbol.for(`ignotum/client/QuerySkip`),OD=Object.freeze(new class{[DD]=DD}),kD={skip:OD},AD=e=>e===OD,jD=(e,t)=>{let n=new Map,r=!1,i=e=>{e.released=!0,e.release?.()};return{observe:R(`PageObservers.observe`)(function*(i,a){if(r)return;let o=uT.queryIdentity(i,a),s=n.get(o);if(s!==void 0)return yield*s.acquire;let c={acquire:yield*Tf(Yd(function*(){let n=yield*(yield*dT).observe(i,a);if(c.released){t(n.release);return}let r=n.subscribe(e);return c.release=()=>{r(),t(n.release)},n})),release:void 0,released:!1};return n.set(o,c),yield*c.acquire}),retain:e=>{for(let[t,r]of n)e.has(t)||(n.delete(t),i(r))},release:()=>{if(!r){r=!0;for(let e of n.values())i(e);n.clear()}}}};function MD(e,t){let n=wD(e),r=AD(t),i=t===void 0||r?{}:t,a=CS(i),o=r?`skip:${n}`:uT.queryIdentity(n,a),[s,c]=He(()=>({identity:o,result:KS()}));if(Ze({args:i,function:n,result:s.result}),We(()=>{if(r)return;let e=!0,t;return pT.runPromise(Yd(function*(){return yield*(yield*dT).observe(n,a)})).then(n=>{if(!e){pT.runFork(n.release);return}let r=()=>{let e=n.getSnapshot();c({identity:o,result:e})};t=n.subscribe(r),r();let i=t;t=()=>{i(),pT.runFork(n.release)}},t=>{e&&z_(Vw)(t)&&c({identity:o,result:t})}),()=>{e=!1,t?.()}},[o]),r||s.identity!==o)return KS();let l=s.result;if(z_(Vw)(l))throw l;return l}function ND(e,t,n={}){let r=wD(e),i=AD(t),a=t===void 0||i?{}:t,o=CS(a),s=J_(BC)(n.pageSize??20),c=i?`skip:${r}`:uT.queryIdentity(r,o),[l,u]=He(1),[d,f]=He(0),[p,m]=He(()=>({identity:c,result:KS()})),h=Ye(()=>u(e=>e+1),[]),g=Je(()=>jD(()=>f(e=>e+1),e=>{pT.runFork(e)}),[c,s]);if(We(()=>()=>g.release(),[g]),Ze({args:a,function:r,result:p.result}),We(()=>{u(1),m({identity:c,result:KS()})},[c,s]),We(()=>{if(i)return;let e=!0,t=new Set;return pT.runPromise(Yd(function*(){let n=[],i=null;for(let o=0;o<l;o+=1){let o=CS({...a,pagination:{cursor:i,pageSize:s}});t.add(uT.queryIdentity(r,o));let l=yield*g.observe(r,o);if(!e||l===void 0)return;let u=l.getSnapshot();if(z_(Vw)(u)){m({identity:c,result:u});return}let d=BS(u);if(d===void 0){m({identity:c,result:n.length===0?KS():JS.succeed({items:n,loadMore:h,status:`LoadingMore`})});return}if(d.type===`Failure`){m({identity:c,result:u});return}let f=d.value;if(n.push(...f.items),i=f.nextCursor,i===null){m({identity:c,result:JS.succeed({items:n,loadMore:h,status:`Exhausted`})});return}}m({identity:c,result:JS.succeed({items:n,loadMore:h,status:`CanLoadMore`})})}).pipe(Sf(Kd(()=>{e&&g.retain(t)})))).catch(t=>{e&&z_(Vw)(t)&&m({identity:c,result:t})}),()=>{e=!1}},[r,c,h,s,g,d,l,i]),i||p.identity!==c)return KS();let _=p.result;if(z_(Vw)(_))throw _;return _}var PD=e=>Je(()=>t=>{let n=wD(e),r=t===void 0?{}:t;return pT.runPromise(Yd(function*(){return yield*(yield*dT).mutate(n,r)}))},[e]);function FD(){let[e,t]=He({status:`pending`});We(()=>{let e=!0,n;return pT.runPromise(PC).then(r=>{if(!e)return;let i=()=>t(r.snapshot());n=r.subscribe(i),i()}),()=>{e=!1,n?.()}},[]);let n=Je(()=>({signIn:e=>pT.runPromise(Yd(function*(){return yield*(yield*PC).start(`signIn`,e?.profile??[],e?.returnTo)})),requestProfile:(e,t)=>pT.runPromise(Yd(function*(){return yield*(yield*PC).start(`requestProfile`,e,t?.returnTo)})),signOut:()=>pT.runPromise(Yd(function*(){return yield*(yield*PC).signOut}))}),[]);return{...e,...n}}var ID=({src:e,alt:t,...n})=>S(`img`,{...n,src:e.url,alt:t}),LD=e=>({type:`ImageSource`,url:e}),RD=t({Component:()=>ae,Files:()=>Qw,Fragment:()=>ie,Image:()=>ID,Link:()=>YE,NavLink:()=>XE,Query:()=>kD,Redirect:()=>ZE,Result:()=>zD,cloneElement:()=>Oe,createContext:()=>ke,createElement:()=>S,createRef:()=>re,h:()=>S,isValidElement:()=>a,toChildArray:()=>me,url:()=>LE,useBlocker:()=>UE,useCallback:()=>Ye,useContext:()=>Xe,useDebugValue:()=>Ze,useEffect:()=>We,useElementId:()=>$e,useErrorBoundary:()=>Qe,useId:()=>FD,useImperativeHandle:()=>qe,useLayoutEffect:()=>Ge,useLocation:()=>VE,useMatch:()=>GE,useMemo:()=>Je,useMutation:()=>PD,useNavigate:()=>BE,useNavigation:()=>HE,usePaginatedQuery:()=>ND,useQuery:()=>MD,useReducer:()=>Ue,useRef:()=>Ke,useRoute:()=>KE,useState:()=>He}),zD={match:JS.match},BD=0;Array.isArray;function VD(e,t,n,i,a,o){t||={};var s,c,l=t;if(`ref`in l)for(c in l={},t)c==`ref`?s=t[c]:l[c]=t[c];var u={type:e,props:l,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--BD,__i:-1,__u:0,__source:a,__self:o};if(typeof e==`function`&&(s=e.defaultProps))for(c in s)l[c]===void 0&&(l[c]=s[c]);return r.vnode&&r.vnode(u),u}var HD=t({Fragment:()=>ie,jsx:()=>VD,jsxDEV:()=>VD,jsxs:()=>VD}),UD=t({Fragment:()=>ie,jsx:()=>VD,jsxDEV:()=>VD,jsxs:()=>VD}),WD=t({bindSchema:()=>qD,createImageSource:()=>LD,createRouteReference:()=>ME,getRouteDefinition:()=>NE,mountClient:()=>xD}),GD=q_(kT),KD=e=>{let t=GD(e);return{descriptor:t,default:e=>({descriptor:GD({type:`default`,value:t,default:e})})}},qD=()=>({route:e=>{q_(NT)({title:e.title,meta:e.meta});let t=e.params??{};q_(IT.fields.params)(Object.entries(t).map(([e,t])=>({name:e,value:t.descriptor})));for(let t of Object.values(e.searchParams??{}))GD(t.descriptor);return e},layout:e=>(q_(PT)({title:e.title,titleTemplate:e.titleTemplate,meta:e.meta}),e),values:{string:()=>KD({type:`string`}),id:e=>KD({type:`id`,table:e}),number:()=>KD({type:`number`}),integer:()=>KD({type:`integer`}),boolean:()=>KD({type:`boolean`}),literal:e=>KD({type:`literal`,value:e}),literals:(...e)=>KD({type:`literals`,values:e}),optional:e=>({descriptor:GD({type:`optional`,value:e.descriptor})}),array:e=>KD({type:`array`,value:q_(TT)(e.descriptor)})}}),JD=t({Component:()=>bO,Fragment:()=>yO,cloneElement:()=>WO,createContext:()=>GO,createElement:()=>gO,createRef:()=>vO,h:()=>gO,hydrate:()=>UO,isValidElement:()=>ZD,options:()=>Z,render:()=>HO,toChildArray:()=>kO}),YD,Z,XD,ZD,QD,$D,eO,tO,nO,rO,iO,aO,oO,sO,cO,lO,uO={},dO=[],fO=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,pO=Array.isArray;function mO(e,t){for(var n in t)e[n]=t[n];return e}function hO(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function gO(e,t,n){var r,i,a,o={};for(a in t)a==`key`?r=t[a]:a==`ref`?i=t[a]:o[a]=t[a];if(arguments.length>2&&(o.children=arguments.length>3?YD.call(arguments,2):n),typeof e==`function`&&e.defaultProps!=null)for(a in e.defaultProps)o[a]===void 0&&(o[a]=e.defaultProps[a]);return _O(e,o,r,i,null)}function _O(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++XD,__i:-1,__u:0};return i==null&&Z.vnode!=null&&Z.vnode(a),a}function vO(){return{current:null}}function yO(e){return e.children}function bO(e,t){this.props=e,this.context=t}function xO(e,t){if(t==null)return e.__?xO(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==`function`?xO(e):null}function SO(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],a=mO({},t);a.__v=t.__v+1,Z.vnode&&Z.vnode(a),PO(e.__P,a,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??xO(t),!!(32&t.__u),i),a.__v=t.__v,a.__.__k[a.__i]=a,IO(r,a,i),t.__e=t.__=null,a.__e!=n&&CO(a)}}function CO(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),CO(e)}function wO(e){(!e.__d&&(e.__d=!0)&&QD.push(e)&&!TO.__r++||$D!=Z.debounceRendering)&&(($D=Z.debounceRendering)||eO)(TO)}function TO(){try{for(var e,t=1;QD.length;)QD.length>t&&QD.sort(tO),e=QD.shift(),t=QD.length,SO(e)}finally{QD.length=TO.__r=0}}function EO(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,_=r&&r.__k||dO,v=t.length;for(c=DO(n,t,_,c,v),d=0;d<v;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&_[p.__i]||uO,p.__i=d,g=PO(e,p,f,i,a,o,s,c,l,u),m=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&zO(f.ref,null,p),u.push(p.ref,p.__c||m,p)),h==null&&m!=null&&(h=m),4&p.__u?(c=OO(p,c,e),f.__e&&(f.__e=null)):typeof p.type==`function`&&g!==void 0?c=g:m&&(c=m.nextSibling),p.__u&=-7);return n.__e=h,c}function DO(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?o=e.__k[a]=_O(null,o,null,null,null):pO(o)?o=e.__k[a]=_O(yO,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=_O(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=AO(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=xO(s)),BO(s,s));return r}function OO(e,t,n){var r,i;if(typeof e.type==`function`){for(r=e.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=e,t=OO(r[i],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=xO(e)),t=n.insertBefore(e.__e,t||null));do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function kO(e,t){return t||=[],e==null||typeof e==`boolean`||(pO(e)?e.some(function(e){kO(e,t)}):t.push(e)),t}function AO(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&!(2&l.__u);if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function jO(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||fO.test(t)?n:n+`px`}function MO(e,t,n,r,i){var a,o;n:if(t==`style`){if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||jO(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||jO(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(aO,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||={},e.l[t+a]=n,n?r?n[iO]=r[iO]:(n[iO]=oO,e.addEventListener(t,a?cO:sO,a)):e.removeEventListener(t,a?cO:sO,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function NO(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[rO]==null)t[rO]=oO++;else if(t[rO]<n[iO])return;return n(Z.event?Z.event(t):t)}}}function PO(e,t,n,r,i,a,o,s,c,l){var u,d,f,p,m,h,g,_,v,y,b,ee,x,te,S,ne,re=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(c=!!(32&n.__u),a=[s=t.__e=n.__e]),(u=Z.__b)&&u(t);n:if(typeof re==`function`){d=o.length;try{if(v=t.props,y=re.prototype&&re.prototype.render,b=(u=re.contextType)&&r[u.__c],ee=u?b?b.props.value:u.__:r,n.__c?_=(f=t.__c=n.__c).__=f.__E:(y?t.__c=f=new re(v,ee):(t.__c=f=new bO(v,ee),f.constructor=re,f.render=VO),b&&b.sub(f),f.state||(f.state={}),f.__n=r,p=f.__d=!0,f.__h=[],f._sb=[]),y&&f.__s==null&&(f.__s=f.state),y&&re.getDerivedStateFromProps!=null&&(f.__s==f.state&&(f.__s=mO({},f.__s)),mO(f.__s,re.getDerivedStateFromProps(v,f.__s))),m=f.props,h=f.state,f.__v=t,p)y&&re.getDerivedStateFromProps==null&&f.componentWillMount!=null&&f.componentWillMount(),y&&f.componentDidMount!=null&&f.__h.push(f.componentDidMount);else{if(y&&re.getDerivedStateFromProps==null&&v!==m&&f.componentWillReceiveProps!=null&&f.componentWillReceiveProps(v,ee),t.__v==n.__v||!f.__e&&f.shouldComponentUpdate!=null&&!1===f.shouldComponentUpdate(v,f.__s,ee)){t.__v!=n.__v&&(f.props=v,f.state=f.__s,f.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),dO.push.apply(f.__h,f._sb),f._sb=[],f.__h.length&&o.push(f),s=xO(n);break n}f.componentWillUpdate!=null&&f.componentWillUpdate(v,f.__s,ee),y&&f.componentDidUpdate!=null&&f.__h.push(function(){f.componentDidUpdate(m,h,g)})}if(f.context=ee,f.props=v,f.__P=e,f.__e=!1,x=Z.__r,te=0,y)f.state=f.__s,f.__d=!1,x&&x(t),u=f.render(f.props,f.state,f.context),dO.push.apply(f.__h,f._sb),f._sb=[];else do f.__d=!1,x&&x(t),u=f.render(f.props,f.state,f.context),f.state=f.__s;while(f.__d&&++te<25);f.state=f.__s,f.getChildContext!=null&&(r=mO(mO({},r),f.getChildContext())),y&&!p&&f.getSnapshotBeforeUpdate!=null&&(g=f.getSnapshotBeforeUpdate(m,h)),S=u!=null&&u.type===yO&&u.key==null?LO(u.props.children):u,s=EO(e,pO(S)?S:[S],t,n,r,i,a,o,s,c,l),f.base=t.__e,t.__u&=-161,f.__h.length&&o.push(f),_&&(f.__E=f.__=null)}catch(e){if(o.length=d,t.__v=null,c||a!=null){if(e.then){for(t.__u|=c?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;a!=null&&(a[a.indexOf(s)]=null),t.__e=s}else if(a!=null)for(ne=a.length;ne--;)hO(a[ne])}else t.__e=n.__e;t.__k??=n.__k||[],e.then||FO(t),Z.__e(e,t,n)}}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=RO(n.__e,t,n,r,i,a,o,c,l);return(u=Z.diffed)&&u(t),128&t.__u?void 0:s}function FO(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(FO))}function IO(e,t,n){for(var r=0;r<n.length;r++)zO(n[r],n[++r],n[++r]);Z.__c&&Z.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){Z.__e(e,t.__v)}})}function LO(e){return typeof e!=`object`||!e||e.__b>0?e:pO(e)?e.map(LO):e.constructor===void 0?mO({},e):null}function RO(e,t,n,r,i,a,o,s,c){var l,u,d,f,p,m,h,g=n.props||uO,_=t.props,v=t.type;if(v==`svg`?i=`http://www.w3.org/2000/svg`:v==`math`?i=`http://www.w3.org/1998/Math/MathML`:i||=`http://www.w3.org/1999/xhtml`,a!=null){for(l=0;l<a.length;l++)if((p=a[l])&&`setAttribute`in p==!!v&&(v?p.localName==v:p.nodeType==3)){e=p,a[l]=null;break}}if(e==null){if(v==null)return document.createTextNode(_);e=document.createElementNS(i,v,_.is&&_),s&&=(Z.__m&&Z.__m(t,a),!1),a=null}if(v==null)g===_||s&&e.data==_||(e.data=_);else{if(a=v==`textarea`&&_.defaultValue!=null?null:a&&YD.call(e.childNodes),!s&&a!=null)for(g={},l=0;l<e.attributes.length;l++)g[(p=e.attributes[l]).name]=p.value;for(l in g)p=g[l],l==`dangerouslySetInnerHTML`?d=p:l==`children`||l in _||l==`value`&&`defaultValue`in _||l==`checked`&&`defaultChecked`in _||MO(e,l,null,p,i);for(l in _)p=_[l],l==`children`?f=p:l==`dangerouslySetInnerHTML`?u=p:l==`value`?m=p:l==`checked`?h=p:s&&typeof p!=`function`||g[l]===p||MO(e,l,p,g[l],i);if(u)s||d&&(u.__html==d.__html||u.__html==e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(d&&(e.innerHTML=``),EO(t.type==`template`?e.content:e,pO(f)?f:[f],t,n,r,v==`foreignObject`?`http://www.w3.org/1999/xhtml`:i,a,o,a?a[0]:n.__k&&xO(n,0),s,c),a!=null)for(l=a.length;l--;)hO(a[l]);s&&v!=`textarea`||(l=`value`,v==`progress`&&m==null?e.removeAttribute(`value`):m!=null&&(m!==e[l]||v==`progress`&&!m||v==`option`&&m!=g[l])&&MO(e,l,m,g[l],i),l=`checked`,h!=null&&h!=e[l]&&MO(e,l,h,g[l],i))}return e}function zO(e,t,n){try{if(typeof e==`function`){var r=typeof e.__u==`function`;r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(e){Z.__e(e,n)}}function BO(e,t,n){var r,i;if(Z.unmount&&Z.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||zO(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){Z.__e(e,t)}r.base=r.__P=r.__n=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&BO(r[i],t,n||typeof e.type!=`function`);n||hO(e.__e),e.__c=e.__=e.__e=void 0}function VO(e,t,n){return this.constructor(e,n)}function HO(e,t,n){var r,i,a,o;t==document&&(t=document.documentElement),Z.__&&Z.__(e,t),i=(r=typeof n==`function`)?null:n&&n.__k||t.__k,a=[],o=[],PO(t,e=(!r&&n||t).__k=gO(yO,null,[e]),i||uO,uO,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?YD.call(t.childNodes):null,a,!r&&n?n:i?i.__e:t.firstChild,r,o),IO(a,e,o),e.props.children=null}function UO(e,t){HO(e,t,UO)}function WO(e,t,n){var r,i,a,o,s=mO({},e.props);for(a in e.type&&e.type.defaultProps&&(o=e.type.defaultProps),t)a==`key`?r=t[a]:a==`ref`?i=t[a]:s[a]=t[a]===void 0&&o!=null?o[a]:t[a];return arguments.length>2&&(s.children=arguments.length>3?YD.call(arguments,2):n),_O(e.type,s,r||e.key,i||e.ref,null)}function GO(e){function t(e){var n,r;return this.getChildContext||(n=new Set,(r={})[t.__c]=this,this.getChildContext=function(){return r},this.componentWillUnmount=function(){n=null},this.shouldComponentUpdate=function(e){this.props.value!=e.value&&n.forEach(function(e){e.__e=!0,wO(e)})},this.sub=function(e){n.add(e);var t=e.componentWillUnmount;e.componentWillUnmount=function(){n&&n.delete(e),t&&t.call(e)}}),e.children}return t.__c=`__cC`+lO++,t.__=e,t.Provider=t.__l=(t.Consumer=function(e,t){return e.children(t)}).contextType=t,t}YD=dO.slice,Z={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(t){e=t}throw e}},XD=0,ZD=function(e){return e!=null&&e.constructor===void 0},bO.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=mO({},this.state);typeof e==`function`&&(e=e(mO({},n),this.props)),e&&mO(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),wO(this))},bO.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),wO(this))},bO.prototype.render=yO,QD=[],eO=typeof Promise==`function`?Promise.prototype.then.bind(Promise.resolve()):setTimeout,tO=function(e,t){return e.__v.__b-t.__v.__b},TO.__r=0,nO=Math.random().toString(8),rO=`__d`+nO,iO=`__a`+nO,aO=/(PointerCapture)$|Capture$/i,oO=0,sO=NO(!1),cO=NO(!0),lO=0;var KO=t({useCallback:()=>fk,useContext:()=>pk,useDebugValue:()=>mk,useEffect:()=>sk,useErrorBoundary:()=>hk,useId:()=>gk,useImperativeHandle:()=>uk,useLayoutEffect:()=>ck,useMemo:()=>dk,useReducer:()=>ok,useRef:()=>lk,useState:()=>ak}),qO,Q,JO,YO,XO=0,ZO=[],$=r,QO=$.__b,$O=$.__r,ek=$.diffed,tk=$.__c,nk=$.unmount,rk=$.__;function ik(e,t){$.__h&&$.__h(Q,e,XO||t),XO=0;var n=Q.__H||(Q.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function ak(e){return XO=1,ok(Ck,e)}function ok(e,t,n){var r=ik(qO++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Ck(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=Q,!Q.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=!1,o=r.__c.props!==e;if(r.__c.__H.__.some(function(e){if(e.__N){i=!0;var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),a){var s=a.call(this,e,t,n);return i?s||o:s}return!i||o};Q.__f=!0;var a=Q.shouldComponentUpdate,o=Q.componentWillUpdate;Q.componentWillUpdate=function(e,t,n){if(this.__e){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},Q.shouldComponentUpdate=i}return r.__N||r.__}function sk(e,t){var n=ik(qO++,3);!$.__s&&Sk(n.__H,t)&&(n.__=e,n.u=t,Q.__H.__h.push(n))}function ck(e,t){var n=ik(qO++,4);!$.__s&&Sk(n.__H,t)&&(n.__=e,n.u=t,Q.__h.push(n))}function lk(e){return XO=5,dk(function(){return{current:e}},[])}function uk(e,t,n){XO=6,ck(function(){if(typeof e==`function`){var n=e(t());return function(){e(null),n&&typeof n==`function`&&n()}}if(e)return e.current=t(),function(){return e.current=null}},n==null?n:n.concat(e))}function dk(e,t){var n=ik(qO++,7);return Sk(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function fk(e,t){return XO=8,dk(function(){return e},t)}function pk(e){var t=Q.context[e.__c],n=ik(qO++,9);return n.c=e,t?(n.__??(n.__=!0,t.sub(Q)),t.props.value):e.__}function mk(e,t){$.useDebugValue&&$.useDebugValue(t?t(e):e)}function hk(e){var t=ik(qO++,10),n=ak();return t.__=e,Q.componentDidCatch||(Q.componentDidCatch=function(e,r){t.__&&t.__(e,r),n[1](e)}),[n[0],function(){n[1](void 0)}]}function gk(){var e=ik(qO++,11);if(!e.__){for(var t=Q.__v;t!==null&&!t.__m&&t.__!==null;)t=t.__;var n=t.__m||(t.__m=[0,0]);e.__=`P`+n[0]+`-`+n[1]++}return e.__}function _k(){for(var e;e=ZO.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(bk),t.__h.some(xk),t.__h=[]}catch(n){t.__h=[],$.__e(n,e.__v)}}}$.__b=function(e){Q=null,QO&&QO(e)},$.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),rk&&rk(e,t)},$.__r=function(e){$O&&$O(e),qO=0;var t=(Q=e.__c).__H;t&&(JO===Q?(t.__h=[],Q.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(bk),t.__h.some(xk),t.__h=[],qO=0)),JO=Q},$.diffed=function(e){ek&&ek(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(ZO.push(t)!==1&&YO===$.requestAnimationFrame||((YO=$.requestAnimationFrame)||yk)(_k)),t.__H.__.some(function(e){e.u&&=(e.__H=e.u,void 0)})),JO=Q=null},$.__c=function(e,t){t.some(function(e){try{e.__h.some(bk),e.__h=e.__h.filter(function(e){return!e.__||xk(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],$.__e(n,e.__v)}}),tk&&tk(e,t)},$.unmount=function(e){nk&&nk(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{bk(e)}catch(e){t=e}}),n.__H=void 0,t&&$.__e(t,n.__v))};var vk=typeof requestAnimationFrame==`function`;function yk(e){var t,n=function(){clearTimeout(r),vk&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);vk&&(t=requestAnimationFrame(n))}function bk(e){var t=Q,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),Q=t}function xk(e){var t=Q;e.__c=e.__(),Q=t}function Sk(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function Ck(e,t){return typeof t==`function`?t(e):t}var wk=t({Fragment:()=>ie,jsx:()=>Ak,jsxAttr:()=>Pk,jsxDEV:()=>Ak,jsxEscape:()=>Fk,jsxTemplate:()=>jk,jsxs:()=>Ak}),Tk=/["&<]/;function Ek(e){if(e.length===0||!1===Tk.test(e))return e;for(var t=0,n=0,r=``,i=``;n<e.length;n++){switch(e.charCodeAt(n)){case 34:i=`&quot;`;break;case 38:i=`&amp;`;break;case 60:i=`&lt;`;break;default:continue}n!==t&&(r+=e.slice(t,n)),r+=i,t=n+1}return n!==t&&(r+=e.slice(t,n)),r}var Dk=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Ok=0,kk=Array.isArray;function Ak(e,t,n,i,a,o){t||={};var s,c,l=t;if(`ref`in l)for(c in l={},t)c==`ref`?s=t[c]:l[c]=t[c];var u={type:e,props:l,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Ok,__i:-1,__u:0,__source:a,__self:o};if(typeof e==`function`&&(s=e.defaultProps))for(c in s)l[c]===void 0&&(l[c]=s[c]);return r.vnode&&r.vnode(u),u}function jk(e){var t=Ak(ie,{tpl:e,exprs:[].slice.call(arguments,1)});return t.key=t.__v,t}var Mk={},Nk=/[A-Z]/g;function Pk(e,t){if(r.attr){var n=r.attr(e,t);if(typeof n==`string`)return n}if(t=function(e){return typeof e==`object`&&e&&typeof e.valueOf==`function`?e.valueOf():e}(t),e===`ref`||e===`key`)return``;if(e===`style`&&typeof t==`object`){var i=``;for(var a in t){var o=t[a];if(o!=null&&o!==``){var s=a[0]==`-`?a:Mk[a]||(Mk[a]=a.replace(Nk,`-$&`).toLowerCase()),c=`;`;typeof o!=`number`||s.startsWith(`--`)||Dk.test(s)||(c=`px;`),i=i+s+`:`+o+c}}return e+`="`+Ek(i)+`"`}return t==null||!1===t||typeof t==`function`||typeof t==`object`?``:!0===t?e:e+`="`+Ek(``+t)+`"`}function Fk(e){if(e==null||typeof e==`boolean`||typeof e==`function`)return null;if(typeof e==`object`){if(e.constructor===void 0)return e;if(kk(e)){for(var t=0;t<e.length;t++)e[t]=Fk(e[t]);return e}}return Ek(``+e)}export{SD as api,WD as bindings,RD as client,KO as hooks,HD as jsx,UD as jsxDev,xD as mount,JD as preact,wk as preactJsx,wk as preactJsxDev,AE as routes};