@shivaedev/work-board 0.14.1 → 0.15.0

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 (197) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +1 -1
  3. package/assets/agent.js +1 -1
  4. package/assets/native.js +25 -25
  5. package/assets/react.js +38 -37
  6. package/dist/browser/diagnostics/schema.d.ts +15 -12
  7. package/dist/browser/diagnostics/schema.d.ts.map +1 -1
  8. package/dist/browser/diagnostics/schema.js +12 -2
  9. package/dist/browser/diagnostics/schema.js.map +1 -1
  10. package/dist/browser/views/remaining.d.ts +20 -12
  11. package/dist/browser/views/remaining.d.ts.map +1 -1
  12. package/dist/client/client.d.ts +1 -0
  13. package/dist/client/client.d.ts.map +1 -1
  14. package/dist/client/client.js +1 -1
  15. package/dist/client/client.js.map +1 -1
  16. package/dist/client/formStatus.d.ts +12 -0
  17. package/dist/client/formStatus.d.ts.map +1 -0
  18. package/dist/client/formStatus.js +27 -0
  19. package/dist/client/formStatus.js.map +1 -0
  20. package/dist/client/react/BoardShell.d.ts.map +1 -1
  21. package/dist/client/react/BoardShell.js +15 -21
  22. package/dist/client/react/BoardShell.js.map +1 -1
  23. package/dist/client/react/DocumentContext.d.ts.map +1 -1
  24. package/dist/client/react/DocumentContext.js +6 -3
  25. package/dist/client/react/DocumentContext.js.map +1 -1
  26. package/dist/client/react/FormContext.d.ts +5 -0
  27. package/dist/client/react/FormContext.d.ts.map +1 -0
  28. package/dist/client/react/FormContext.js +10 -0
  29. package/dist/client/react/FormContext.js.map +1 -0
  30. package/dist/client/react/LiveControls.d.ts +4 -3
  31. package/dist/client/react/LiveControls.d.ts.map +1 -1
  32. package/dist/client/react/LiveControls.js +5 -19
  33. package/dist/client/react/LiveControls.js.map +1 -1
  34. package/dist/client/react/MainLocationContext.d.ts +3 -0
  35. package/dist/client/react/MainLocationContext.d.ts.map +1 -0
  36. package/dist/client/react/MainLocationContext.js +7 -0
  37. package/dist/client/react/MainLocationContext.js.map +1 -0
  38. package/dist/client/react/ProjectionFrame.d.ts +1 -2
  39. package/dist/client/react/ProjectionFrame.d.ts.map +1 -1
  40. package/dist/client/react/ProjectionFrame.js +10 -4
  41. package/dist/client/react/ProjectionFrame.js.map +1 -1
  42. package/dist/client/react/ReadingLibrary.d.ts.map +1 -1
  43. package/dist/client/react/ReadingLibrary.js +7 -8
  44. package/dist/client/react/ReadingLibrary.js.map +1 -1
  45. package/dist/client/react/SystemPage.d.ts.map +1 -1
  46. package/dist/client/react/SystemPage.js +2 -1
  47. package/dist/client/react/SystemPage.js.map +1 -1
  48. package/dist/client/react/TodayOptions.d.ts.map +1 -1
  49. package/dist/client/react/TodayOptions.js +23 -14
  50. package/dist/client/react/TodayOptions.js.map +1 -1
  51. package/dist/client/react/VisualViewer.d.ts.map +1 -1
  52. package/dist/client/react/VisualViewer.js +6 -5
  53. package/dist/client/react/VisualViewer.js.map +1 -1
  54. package/dist/client/react/boardRouter.d.ts +3 -2
  55. package/dist/client/react/boardRouter.d.ts.map +1 -1
  56. package/dist/client/react/boardRouter.js +2 -1
  57. package/dist/client/react/boardRouter.js.map +1 -1
  58. package/dist/client/react/createResponse.d.ts +32 -4
  59. package/dist/client/react/createResponse.d.ts.map +1 -1
  60. package/dist/client/react/createResponse.js +7 -28
  61. package/dist/client/react/createResponse.js.map +1 -1
  62. package/dist/client/react/diagnosticsValues.d.ts.map +1 -1
  63. package/dist/client/react/diagnosticsValues.js +5 -7
  64. package/dist/client/react/diagnosticsValues.js.map +1 -1
  65. package/dist/client/react/entry.d.ts.map +1 -1
  66. package/dist/client/react/entry.js +2 -34
  67. package/dist/client/react/entry.js.map +1 -1
  68. package/dist/client/react/githubLimited.d.ts +3 -0
  69. package/dist/client/react/githubLimited.d.ts.map +1 -0
  70. package/dist/client/react/githubLimited.js +4 -0
  71. package/dist/client/react/githubLimited.js.map +1 -0
  72. package/dist/client/react/loadProjection.d.ts +135 -135
  73. package/dist/client/react/loadRemaining.d.ts +37 -29
  74. package/dist/client/react/loadRemaining.d.ts.map +1 -1
  75. package/dist/client/react/mainLocation.d.ts +4 -2
  76. package/dist/client/react/mainLocation.d.ts.map +1 -1
  77. package/dist/client/react/mainLocation.js +1 -8
  78. package/dist/client/react/mainLocation.js.map +1 -1
  79. package/dist/client/react/mountBoard.d.ts +3 -0
  80. package/dist/client/react/mountBoard.d.ts.map +1 -0
  81. package/dist/client/react/mountBoard.js +45 -0
  82. package/dist/client/react/mountBoard.js.map +1 -0
  83. package/dist/client/react/navigationLocation.d.ts +1 -1
  84. package/dist/client/react/navigationLocation.d.ts.map +1 -1
  85. package/dist/client/react/navigationLocation.js +1 -1
  86. package/dist/client/react/navigationLocation.js.map +1 -1
  87. package/dist/client/react/retryPage.d.ts +2 -1
  88. package/dist/client/react/retryPage.d.ts.map +1 -1
  89. package/dist/client/react/retryPage.js +3 -4
  90. package/dist/client/react/retryPage.js.map +1 -1
  91. package/dist/client/react/useBoardNavigation.d.ts.map +1 -1
  92. package/dist/client/react/useBoardNavigation.js +18 -8
  93. package/dist/client/react/useBoardNavigation.js.map +1 -1
  94. package/dist/client/react/useDocumentPage.d.ts +1 -1
  95. package/dist/client/react/useDocumentPage.d.ts.map +1 -1
  96. package/dist/client/react/useDocumentPage.js +9 -6
  97. package/dist/client/react/useDocumentPage.js.map +1 -1
  98. package/dist/client/react/useHandoffForm.d.ts +56 -30
  99. package/dist/client/react/useHandoffForm.d.ts.map +1 -1
  100. package/dist/client/react/useHandoffForm.js +19 -30
  101. package/dist/client/react/useHandoffForm.js.map +1 -1
  102. package/dist/client/react/useResponseForm.d.ts +72 -43
  103. package/dist/client/react/useResponseForm.d.ts.map +1 -1
  104. package/dist/client/react/useResponseForm.js +20 -17
  105. package/dist/client/react/useResponseForm.js.map +1 -1
  106. package/dist/client/react/visualSources.d.ts.map +1 -1
  107. package/dist/client/react/visualSources.js +10 -8
  108. package/dist/client/react/visualSources.js.map +1 -1
  109. package/dist/client/saveFailure.d.ts +8 -0
  110. package/dist/client/saveFailure.d.ts.map +1 -0
  111. package/dist/client/saveFailure.js +8 -0
  112. package/dist/client/saveFailure.js.map +1 -0
  113. package/dist/diagnostics/daemonContract.d.ts +65 -38
  114. package/dist/diagnostics/daemonContract.d.ts.map +1 -1
  115. package/dist/diagnostics/daemonContract.js +2 -1
  116. package/dist/diagnostics/daemonContract.js.map +1 -1
  117. package/dist/diagnostics/health.d.ts +10 -0
  118. package/dist/diagnostics/health.d.ts.map +1 -1
  119. package/dist/diagnostics/health.js +2 -0
  120. package/dist/diagnostics/health.js.map +1 -1
  121. package/dist/diagnostics/source.d.ts +55 -36
  122. package/dist/diagnostics/source.d.ts.map +1 -1
  123. package/dist/diagnostics/source.js +1 -2
  124. package/dist/diagnostics/source.js.map +1 -1
  125. package/dist/rpc/contract.d.ts +60 -36
  126. package/dist/rpc/contract.d.ts.map +1 -1
  127. package/dist/rpc/handoffContract.d.ts +8 -8
  128. package/dist/server/diagnostics/daemon.d.ts +41 -25
  129. package/dist/server/diagnostics/daemon.d.ts.map +1 -1
  130. package/dist/server/diagnostics/fleetHealth.d.ts +10 -0
  131. package/dist/server/diagnostics/fleetHealth.d.ts.map +1 -1
  132. package/dist/server/diagnostics/githubLimits.d.ts +12 -13
  133. package/dist/server/diagnostics/githubLimits.d.ts.map +1 -1
  134. package/dist/server/diagnostics/githubLimits.js +6 -6
  135. package/dist/server/diagnostics/githubLimits.js.map +1 -1
  136. package/dist/server/integration/diagnostics.d.ts +74 -38
  137. package/dist/server/integration/diagnostics.d.ts.map +1 -1
  138. package/dist/server/mcp/client.d.ts +589 -581
  139. package/dist/server/mcp/client.d.ts.map +1 -1
  140. package/dist/server/mcp/queries.d.ts +60 -36
  141. package/dist/server/mcp/queries.d.ts.map +1 -1
  142. package/dist/server/metadata/fields.js +1 -1
  143. package/dist/server/metadata/fields.js.map +1 -1
  144. package/dist/server/packageInfo.d.ts +1 -1
  145. package/dist/server/packageInfo.js +1 -1
  146. package/dist/server/views/remainingQueries.d.ts +20 -12
  147. package/dist/server/views/remainingQueries.d.ts.map +1 -1
  148. package/package.json +7 -6
  149. package/src/browser/diagnostics/schema.ts +12 -2
  150. package/src/client/client.ts +2 -1
  151. package/src/client/formStatus.ts +35 -0
  152. package/src/client/react/BoardShell.tsx +19 -26
  153. package/src/client/react/DocumentContext.tsx +6 -3
  154. package/src/client/react/FormContext.ts +13 -0
  155. package/src/client/react/LiveControls.tsx +5 -25
  156. package/src/client/react/MainLocationContext.ts +8 -0
  157. package/src/client/react/ProjectionFrame.tsx +13 -5
  158. package/src/client/react/ReadingLibrary.tsx +7 -8
  159. package/src/client/react/SystemPage.tsx +2 -1
  160. package/src/client/react/TodayOptions.tsx +40 -33
  161. package/src/client/react/VisualViewer.tsx +6 -6
  162. package/src/client/react/boardRouter.ts +3 -2
  163. package/src/client/react/createResponse.ts +10 -35
  164. package/src/client/react/diagnosticsValues.tsx +20 -12
  165. package/src/client/react/entry.tsx +2 -37
  166. package/src/client/react/githubLimited.ts +5 -0
  167. package/src/client/react/mainLocation.ts +5 -8
  168. package/src/client/react/mountBoard.tsx +49 -0
  169. package/src/client/react/navigationLocation.ts +2 -2
  170. package/src/client/react/retryPage.ts +4 -4
  171. package/src/client/react/useBoardNavigation.ts +20 -8
  172. package/src/client/react/useDocumentPage.ts +12 -6
  173. package/src/client/react/useHandoffForm.ts +25 -33
  174. package/src/client/react/useResponseForm.ts +20 -18
  175. package/src/client/react/visualSources.ts +10 -8
  176. package/src/client/saveFailure.ts +14 -0
  177. package/src/diagnostics/daemonContract.ts +2 -1
  178. package/src/diagnostics/health.ts +2 -0
  179. package/src/diagnostics/source.ts +1 -2
  180. package/src/server/diagnostics/githubLimits.ts +9 -11
  181. package/src/server/metadata/fields.ts +1 -1
  182. package/src/server/packageInfo.ts +1 -1
  183. package/dist/client/handoffs/failureStatus.d.ts +0 -2
  184. package/dist/client/handoffs/failureStatus.d.ts.map +0 -1
  185. package/dist/client/handoffs/failureStatus.js +0 -7
  186. package/dist/client/handoffs/failureStatus.js.map +0 -1
  187. package/dist/client/responses/failure.d.ts +0 -5
  188. package/dist/client/responses/failure.d.ts.map +0 -1
  189. package/dist/client/responses/failure.js +0 -13
  190. package/dist/client/responses/failure.js.map +0 -1
  191. package/dist/server/diagnostics/readCommand.d.ts +0 -4
  192. package/dist/server/diagnostics/readCommand.d.ts.map +0 -1
  193. package/dist/server/diagnostics/readCommand.js +0 -20
  194. package/dist/server/diagnostics/readCommand.js.map +0 -1
  195. package/src/client/handoffs/failureStatus.ts +0 -6
  196. package/src/client/responses/failure.ts +0 -13
  197. package/src/server/diagnostics/readCommand.ts +0 -24
package/assets/native.js CHANGED
@@ -1,37 +1,37 @@
1
1
  /* @shivaedev/work-board native browser bundle */
2
- var IK=Object.defineProperty;var ps=(e,t)=>{for(var r in t)IK(e,r,{get:t[r],enumerable:!0})};var V=(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 r=e;for(let n=0,o=t.length;n<o;n++)r=t[n](r);return r}}},oI={pipe(){return V(this,arguments)}},Ra=(function(){function e(){}return e.prototype=oI,e})();var d=function(e,t){if(typeof e=="function")return function(){return e(arguments)?t.apply(this,arguments):r=>t(r,...arguments)};switch(e){case 0:case 1:throw new RangeError(`Invalid arity ${e}`);case 2:return function(r,n){return arguments.length>=2?t(r,n):function(o){return t(o,r)}};case 3:return function(r,n,o){return arguments.length>=3?t(r,n,o):function(s){return t(s,r,n)}};default:return function(){if(arguments.length>=e)return t.apply(this,arguments);let r=arguments;return function(n){return t(n,...r)}}}};var F=e=>e;var qe=e=>()=>e,nr=qe(!0),Oa=qe(!1),sI=qe(null),po=qe(void 0),Rr=po;function Ud(e,...t){return V(e,t)}function $c(e,t,r,n,o,s,i,a,c){switch(arguments.length){case 1:return e;case 2:return function(){return t(e.apply(this,arguments))};case 3:return function(){return r(t(e.apply(this,arguments)))};case 4:return function(){return n(r(t(e.apply(this,arguments))))};case 5:return function(){return o(n(r(t(e.apply(this,arguments)))))};case 6:return function(){return s(o(n(r(t(e.apply(this,arguments))))))};case 7:return function(){return i(s(o(n(r(t(e.apply(this,arguments)))))))};case 8:return function(){return a(i(s(o(n(r(t(e.apply(this,arguments))))))))};case 9:return function(){return c(a(i(s(o(n(r(t(e.apply(this,arguments)))))))))}}}function mo(e){let t=new WeakMap;return r=>{let n=t.get(r);if(n!==void 0)return n;let o=e(r);return t.set(r,o),o}}function jc(e){let t=new WeakMap;return r=>{let n=t.get(r);if(n!==void 0)return n;let o=e(r);return t.set(r,o),o!==r&&t.set(o,o),o}}var Dd=e=>{let t=new Set(Reflect.ownKeys(e));if(e.constructor===Object)return t;e instanceof Error&&t.delete("stack");let r=Object.getPrototypeOf(e),n=r;for(;n!==null&&n!==Object.prototype;){let o=Reflect.ownKeys(n);for(let s=0;s<o.length;s++)t.add(o[s]);n=Object.getPrototypeOf(n)}return t.has("constructor")&&typeof e.constructor=="function"&&r===e.constructor.prototype&&t.delete("constructor"),t},Af=new WeakSet,Ld=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength);var Hc=0,UO=()=>{Hc++};function On(e){return typeof e=="string"}function Bd(e){return typeof e=="number"}function px(e){return typeof e=="boolean"}function DO(e){return typeof e=="bigint"}function iI(e){return typeof e=="symbol"}function mx(e){return On(e)||Bd(e)||iI(e)}function or(e){return typeof e=="function"}function LO(e){return e===void 0}function ei(e){return e!==void 0}function BO(e){return e==null}function hx(e){return e!=null}function $O(e){return!1}function aI(e){return!0}function $d(e){return typeof e=="object"&&e!==null}function Jt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function jd(e){return typeof e=="object"&&e!==null||or(e)}var O=d(2,(e,t)=>jd(e)&&t in e),Or=d(2,(e,t)=>O(e,"_tag")&&e._tag===t);function jO(e){return e instanceof Error}function ti(e){return O(e,Symbol.iterator)||On(e)}var ie="~effect/Hash",G=e=>{switch(typeof e){case"number":return zt(e);case"bigint":return Be(e.toString(10));case"string":return Be(e);case"function":case"object":{if(e===null)break;if(e instanceof Date)return Number.isNaN(e.getTime())?Be("Invalid Date"):Be(e.toISOString());if(e instanceof RegExp)return Be(e.toString());{if(Af.has(e))return xx(e);let t=qO.get(e);if(t!==void 0)return t;if(fI.has(e))return UO(),Be("[Circular]");fI.add(e);let r=Hc,n;try{ie in e?n=e[ie]():typeof e=="function"?n=xx(e):e instanceof DataView?n=ri(Ld(e)):Array.isArray(e)||ArrayBuffer.isView(e)?n=ri(e):e instanceof Map?n=TK(e):e instanceof Set?n=wK(e):n=qd(e)}finally{fI.delete(e)}return r===Hc&&qO.set(e,n),n}}}return _r(zO(Be(String(e))))},xx=e=>(uI.has(e)||uI.set(e,_r(Math.random()*4294967296|0)),uI.get(e)),zO=e=>(e^=e>>>16,e=Math.imul(e,2246822507),e^=e>>>13,e=Math.imul(e,3266489909),e^e>>>16),he=d(2,(e,t)=>zO(Math.imul(e,2654435761)+Math.imul(t,2246822507))),_r=e=>e&3221225471|e>>>1&1073741824;var cI=new DataView(new ArrayBuffer(8)),zt=e=>{let t=e|0;return t===e?_r(t):(cI.setFloat64(0,e!==e?NaN:e),_r(he(cI.getInt32(0),cI.getInt32(4))))},Be=e=>{let t=5381,r=e.length;for(;r;)t=t*33^e.charCodeAt(--r);return _r(t)},Hd=(e,t)=>{let r=12289;for(let n of t)r^=he(G(n),G(e[n]));return _r(r)},qd=e=>Hd(e,Dd(e)),WO=(e,t)=>r=>{let n=e;for(let o of r)n^=t(o);return _r(n)},ri=e=>{let t=6151;for(let r of e)t=he(t,G(r));return _r(t)},TK=WO(Be("Map"),([e,t])=>he(G(e),G(t))),HO=Be("Set"),wK=WO(HO,e=>he(HO,G(e))),uI=new WeakMap,qO=new WeakMap,fI=new WeakSet;var ae="~effect/Equal";function Z(){return arguments.length===1?e=>qc(e,arguments[0]):qc(arguments[0],arguments[1])}function qc(e,t){if(e===t)return!0;if(e==null||t==null)return!1;let r=typeof e;return r!==typeof t?!1:r==="number"&&e!==e&&t!==t?!0:r!=="object"&&r!=="function"||Af.has(e)||Af.has(t)?!1:vK(e,t)}function vK(e,t){let r=gx.length;for(let s=r;s-- >0;)if(gx[s]===e&&lI[s]===t)return!0;if(r)return KO(e,t);let n=VO.get(e);n||VO.set(e,n=new WeakMap);let o=n.get(t);return o===void 0&&n.set(t,o=KO(e,t)),o}function KO(e,t){gx.push(e),lI.push(t);try{return CK(e,t)}finally{gx.pop(),lI.pop()}}var gx=[],lI=[],VO=new WeakMap;function CK(e,t){if(G(e)!==G(t))return!1;if(e instanceof Date){if(!(t instanceof Date))return!1;let n=e.getTime(),o=t.getTime();return n===o||Number.isNaN(n)&&Number.isNaN(o)}else if(e instanceof RegExp)return t instanceof RegExp&&e.toString()===t.toString();let r=JO(e);if(r!==JO(t)||typeof e=="function"&&!r)return!1;if(r)return e[ae](t);if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:AK(e,t);if(ArrayBuffer.isView(e)){let n=e instanceof DataView;return!ArrayBuffer.isView(t)||e.byteLength!==t.byteLength||n!==t instanceof DataView?!1:n?GO(Ld(e),Ld(t)):GO(e,t)}else{if(e instanceof Map)return!(t instanceof Map)||e.size!==t.size?!1:dI(e,t,RK,OK);if(e instanceof Set)return!(t instanceof Set)||e.size!==t.size?!1:dI(e,t,G,qc)}return kK(e,t)}function AK(e,t){for(let r=0;r<e.length;r++)if(!qc(e[r],t[r]))return!1;return!0}function GO(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}function kK(e,t){let r=Dd(e),n=Dd(t);if(r.size!==n.size)return!1;for(let o of r)if(!n.has(o)||!qc(e[o],t[o]))return!1;return!0}function dI(e,t,r,n){let o=new Map,s=0;for(let i of t){let a=r(i),c=o.get(a);c?c.push(i):o.set(a,[i]),s++}e:for(let i of e){let a=o.get(r(i));if(a){for(let c=0;c<a.length;c++)if(n(i,a[c])){a[c]=a[a.length-1],a.pop(),s--;continue e}}return!1}return s===0}var RK=e=>G(e[0]),OK=(e,t)=>qc(e[0],t[0])&&qc(e[1],t[1]),_K=()=>0;function yx(e,t){return zd((r,n)=>e(r[0],n[0])&&t(r[1],n[1]))}function zd(e){return function(r,n){return dI(r,n,_K,e)}}var JO=e=>O(e,ae),Wd=()=>Z;var ZO=e=>(Af.add(e),e);var zc=Symbol.for("~effect/Redactable"),PK=e=>O(e,zc);function ho(e){return PK(e)?pI(e):e}function pI(e){return e[zc](globalThis[kf]?.context??MK)}var kf="~effect/Fiber/currentFiber",QO=new Map,MK={"~effect/Context":{},base:QO,depth:0,mapUnsafe:QO,pipe(){return V(this,arguments)}};function H(e,t){let r=t?.space??0,n=new WeakSet,o=r?typeof r=="number"?" ".repeat(r):r:"",s=f=>o.repeat(f),i=(f,p)=>{let m=f?.constructor;return m&&m!==Object.prototype.constructor&&m.name?`${m.name}(${p})`:p},a=f=>{try{return Reflect.ownKeys(f)}catch{return["[ownKeys threw]"]}};function c(f,p=0){try{return u(f,p)}catch{return(typeof f=="object"&&f!==null||typeof f=="function")&&n.delete(f),"[inspection threw]"}}function u(f,p=0){if(typeof f=="string")return JSON.stringify(f);if(typeof f=="number"||f==null||typeof f=="boolean"||typeof f=="symbol")return String(f);if(typeof f=="bigint")return String(f)+"n";if(typeof f=="object"||typeof f=="function"){if(n.has(f))return FK;n.add(f);let m;if(zc in f)m=c(pI(f),p);else if(Array.isArray(f))m=!o||f.length<=1?`[${f.map(h=>c(h,p)).join(",")}]`:`[
2
+ var IK=Object.defineProperty;var ps=(e,t)=>{for(var r in t)IK(e,r,{get:t[r],enumerable:!0})};var V=(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 r=e;for(let n=0,o=t.length;n<o;n++)r=t[n](r);return r}}},iI={pipe(){return V(this,arguments)}},Oa=(function(){function e(){}return e.prototype=iI,e})();var d=function(e,t){if(typeof e=="function")return function(){return e(arguments)?t.apply(this,arguments):r=>t(r,...arguments)};switch(e){case 0:case 1:throw new RangeError(`Invalid arity ${e}`);case 2:return function(r,n){return arguments.length>=2?t(r,n):function(o){return t(o,r)}};case 3:return function(r,n,o){return arguments.length>=3?t(r,n,o):function(s){return t(s,r,n)}};default:return function(){if(arguments.length>=e)return t.apply(this,arguments);let r=arguments;return function(n){return t(n,...r)}}}};var F=e=>e;var qe=e=>()=>e,nr=qe(!0),_a=qe(!1),aI=qe(null),po=qe(void 0),Rr=po;function Ud(e,...t){return V(e,t)}function jc(e,t,r,n,o,s,i,a,c){switch(arguments.length){case 1:return e;case 2:return function(){return t(e.apply(this,arguments))};case 3:return function(){return r(t(e.apply(this,arguments)))};case 4:return function(){return n(r(t(e.apply(this,arguments))))};case 5:return function(){return o(n(r(t(e.apply(this,arguments)))))};case 6:return function(){return s(o(n(r(t(e.apply(this,arguments))))))};case 7:return function(){return i(s(o(n(r(t(e.apply(this,arguments)))))))};case 8:return function(){return a(i(s(o(n(r(t(e.apply(this,arguments))))))))};case 9:return function(){return c(a(i(s(o(n(r(t(e.apply(this,arguments)))))))))}}}function mo(e){let t=new WeakMap;return r=>{let n=t.get(r);if(n!==void 0)return n;let o=e(r);return t.set(r,o),o}}function Hc(e){let t=new WeakMap;return r=>{let n=t.get(r);if(n!==void 0)return n;let o=e(r);return t.set(r,o),o!==r&&t.set(o,o),o}}var Dd=e=>{let t=new Set(Reflect.ownKeys(e));if(e.constructor===Object)return t;e instanceof Error&&t.delete("stack");let r=Object.getPrototypeOf(e),n=r;for(;n!==null&&n!==Object.prototype;){let o=Reflect.ownKeys(n);for(let s=0;s<o.length;s++)t.add(o[s]);n=Object.getPrototypeOf(n)}return t.has("constructor")&&typeof e.constructor=="function"&&r===e.constructor.prototype&&t.delete("constructor"),t},Cf=new WeakSet,Ld=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength);var qc=0,DO=()=>{qc++};function On(e){return typeof e=="string"}function Bd(e){return typeof e=="number"}function px(e){return typeof e=="boolean"}function LO(e){return typeof e=="bigint"}function cI(e){return typeof e=="symbol"}function mx(e){return On(e)||Bd(e)||cI(e)}function or(e){return typeof e=="function"}function BO(e){return e===void 0}function ei(e){return e!==void 0}function $O(e){return e==null}function hx(e){return e!=null}function jO(e){return!1}function uI(e){return!0}function $d(e){return typeof e=="object"&&e!==null}function Jt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function jd(e){return typeof e=="object"&&e!==null||or(e)}var O=d(2,(e,t)=>jd(e)&&t in e),Or=d(2,(e,t)=>O(e,"_tag")&&e._tag===t);function HO(e){return e instanceof Error}function ti(e){return O(e,Symbol.iterator)||On(e)}var ie="~effect/Hash",G=e=>{switch(typeof e){case"number":return zt(e);case"bigint":return Be(e.toString(10));case"string":return Be(e);case"function":case"object":{if(e===null)break;if(e instanceof Date)return Number.isNaN(e.getTime())?Be("Invalid Date"):Be(e.toISOString());if(e instanceof RegExp)return Be(e.toString());{if(Cf.has(e))return xx(e);let t=zO.get(e);if(t!==void 0)return t;if(dI.has(e))return DO(),Be("[Circular]");dI.add(e);let r=qc,n;try{ie in e?n=e[ie]():typeof e=="function"?n=xx(e):e instanceof DataView?n=ri(Ld(e)):Array.isArray(e)||ArrayBuffer.isView(e)?n=ri(e):e instanceof Map?n=TK(e):e instanceof Set?n=wK(e):n=qd(e)}finally{dI.delete(e)}return r===qc&&zO.set(e,n),n}}}return _r(WO(Be(String(e))))},xx=e=>(lI.has(e)||lI.set(e,_r(Math.random()*4294967296|0)),lI.get(e)),WO=e=>(e^=e>>>16,e=Math.imul(e,2246822507),e^=e>>>13,e=Math.imul(e,3266489909),e^e>>>16),he=d(2,(e,t)=>WO(Math.imul(e,2654435761)+Math.imul(t,2246822507))),_r=e=>e&3221225471|e>>>1&1073741824;var fI=new DataView(new ArrayBuffer(8)),zt=e=>{let t=e|0;return t===e?_r(t):(fI.setFloat64(0,e!==e?NaN:e),_r(he(fI.getInt32(0),fI.getInt32(4))))},Be=e=>{let t=5381,r=e.length;for(;r;)t=t*33^e.charCodeAt(--r);return _r(t)},Hd=(e,t)=>{let r=12289;for(let n of t)r^=he(G(n),G(e[n]));return _r(r)},qd=e=>Hd(e,Dd(e)),KO=(e,t)=>r=>{let n=e;for(let o of r)n^=t(o);return _r(n)},ri=e=>{let t=6151;for(let r of e)t=he(t,G(r));return _r(t)},TK=KO(Be("Map"),([e,t])=>he(G(e),G(t))),qO=Be("Set"),wK=KO(qO,e=>he(qO,G(e))),lI=new WeakMap,zO=new WeakMap,dI=new WeakSet;var ae="~effect/Equal";function Z(){return arguments.length===1?e=>zc(e,arguments[0]):zc(arguments[0],arguments[1])}function zc(e,t){if(e===t)return!0;if(e==null||t==null)return!1;let r=typeof e;return r!==typeof t?!1:r==="number"&&e!==e&&t!==t?!0:r!=="object"&&r!=="function"||Cf.has(e)||Cf.has(t)?!1:vK(e,t)}function vK(e,t){let r=gx.length;for(let s=r;s-- >0;)if(gx[s]===e&&pI[s]===t)return!0;if(r)return VO(e,t);let n=GO.get(e);n||GO.set(e,n=new WeakMap);let o=n.get(t);return o===void 0&&n.set(t,o=VO(e,t)),o}function VO(e,t){gx.push(e),pI.push(t);try{return AK(e,t)}finally{gx.pop(),pI.pop()}}var gx=[],pI=[],GO=new WeakMap;function AK(e,t){if(G(e)!==G(t))return!1;if(e instanceof Date){if(!(t instanceof Date))return!1;let n=e.getTime(),o=t.getTime();return n===o||Number.isNaN(n)&&Number.isNaN(o)}else if(e instanceof RegExp)return t instanceof RegExp&&e.toString()===t.toString();let r=ZO(e);if(r!==ZO(t)||typeof e=="function"&&!r)return!1;if(r)return e[ae](t);if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:CK(e,t);if(ArrayBuffer.isView(e)){let n=e instanceof DataView;return!ArrayBuffer.isView(t)||e.byteLength!==t.byteLength||n!==t instanceof DataView?!1:n?JO(Ld(e),Ld(t)):JO(e,t)}else{if(e instanceof Map)return!(t instanceof Map)||e.size!==t.size?!1:mI(e,t,RK,OK);if(e instanceof Set)return!(t instanceof Set)||e.size!==t.size?!1:mI(e,t,G,zc)}return kK(e,t)}function CK(e,t){for(let r=0;r<e.length;r++)if(!zc(e[r],t[r]))return!1;return!0}function JO(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}function kK(e,t){let r=Dd(e),n=Dd(t);if(r.size!==n.size)return!1;for(let o of r)if(!n.has(o)||!zc(e[o],t[o]))return!1;return!0}function mI(e,t,r,n){let o=new Map,s=0;for(let i of t){let a=r(i),c=o.get(a);c?c.push(i):o.set(a,[i]),s++}e:for(let i of e){let a=o.get(r(i));if(a){for(let c=0;c<a.length;c++)if(n(i,a[c])){a[c]=a[a.length-1],a.pop(),s--;continue e}}return!1}return s===0}var RK=e=>G(e[0]),OK=(e,t)=>zc(e[0],t[0])&&zc(e[1],t[1]),_K=()=>0;function yx(e,t){return zd((r,n)=>e(r[0],n[0])&&t(r[1],n[1]))}function zd(e){return function(r,n){return mI(r,n,_K,e)}}var ZO=e=>O(e,ae),Wd=()=>Z;var QO=e=>(Cf.add(e),e);var Wc=Symbol.for("~effect/Redactable"),PK=e=>O(e,Wc);function ho(e){return PK(e)?hI(e):e}function hI(e){return e[Wc](globalThis[kf]?.context??MK)}var kf="~effect/Fiber/currentFiber",YO=new Map,MK={"~effect/Context":{},base:YO,depth:0,mapUnsafe:YO,pipe(){return V(this,arguments)}};function H(e,t){let r=t?.space??0,n=new WeakSet,o=r?typeof r=="number"?" ".repeat(r):r:"",s=f=>o.repeat(f),i=(f,p)=>{let m=f?.constructor;return m&&m!==Object.prototype.constructor&&m.name?`${m.name}(${p})`:p},a=f=>{try{return Reflect.ownKeys(f)}catch{return["[ownKeys threw]"]}};function c(f,p=0){try{return u(f,p)}catch{return(typeof f=="object"&&f!==null||typeof f=="function")&&n.delete(f),"[inspection threw]"}}function u(f,p=0){if(typeof f=="string")return JSON.stringify(f);if(typeof f=="number"||f==null||typeof f=="boolean"||typeof f=="symbol")return String(f);if(typeof f=="bigint")return String(f)+"n";if(typeof f=="object"||typeof f=="function"){if(n.has(f))return FK;n.add(f);let m;if(Wc in f)m=c(hI(f),p);else if(Array.isArray(f))m=!o||f.length<=1?`[${f.map(h=>c(h,p)).join(",")}]`:`[
3
3
  ${s(p+1)}${f.map(h=>c(h,p+1)).join(`,
4
4
  `+s(p+1))}
5
- ${s(p)}]`;else if(f instanceof Date)m=mI(f);else if(!t?.ignoreToString&&O(f,"toString")&&typeof f.toString=="function"&&f.toString!==Object.prototype.toString&&f.toString!==Array.prototype.toString){let h=NK(f);m=f instanceof Error&&f.cause!==void 0?`${h} (cause: ${c(f.cause,p)})`:h}else if(Symbol.iterator in f)m=`${f.constructor.name}(${c(Array.from(f),p)})`;else{let h=a(f);if(!o||h.length<=1){let x=`{${h.map(g=>`${ni(g)}:${c(XO(f,g),p)}`).join(",")}}`;m=i(f,x)}else{let x=`{
6
- ${h.map(g=>`${s(p+1)}${ni(g)}: ${c(XO(f,g),p+1)}`).join(`,
5
+ ${s(p)}]`;else if(f instanceof Date)m=xI(f);else if(!t?.ignoreToString&&O(f,"toString")&&typeof f.toString=="function"&&f.toString!==Object.prototype.toString&&f.toString!==Array.prototype.toString){let h=NK(f);m=f instanceof Error&&f.cause!==void 0?`${h} (cause: ${c(f.cause,p)})`:h}else if(Symbol.iterator in f)m=`${f.constructor.name}(${c(Array.from(f),p)})`;else{let h=a(f);if(!o||h.length<=1){let x=`{${h.map(g=>`${ni(g)}:${c(e_(f,g),p)}`).join(",")}}`;m=i(f,x)}else{let x=`{
6
+ ${h.map(g=>`${s(p+1)}${ni(g)}: ${c(e_(f,g),p+1)}`).join(`,
7
7
  `)}
8
- ${s(p)}}`;m=i(f,x)}}return n.delete(f),m}return String(f)}return c(e,0)}var FK="[Circular]";function ni(e){return typeof e=="string"?JSON.stringify(e):String(e)}function Sx(e){return e.map(t=>`[${ni(t)}]`).join("")}function mI(e){try{return e.toISOString()}catch{return"Invalid Date"}}function NK(e){try{let t=e.toString();return typeof t=="string"?t:String(t)}catch{return"[toString threw]"}}function XO(e,t){try{return e[t]}catch{return"[property access threw]"}}function Wc(e,t){let r=[];return JSON.stringify(e,function(n,o){let s=Object.getOwnPropertyDescriptor(this,n)?.value,i=O(s,zc)?ho(s):ho(o);if(typeof i=="bigint")return H(i);if(typeof i!="object"||i===null)return i;let a=i instanceof Error&&!O(i,"toJSON")?{...i,name:i.name,message:i.message}:i;for(;r.length>0&&r[r.length-1]!==this;)r.pop();if(r.includes(i))return;if(r.push(i),a!==i&&r.push(a),!UK(a)||DK(a))return a;let c=new Proxy(a,{get(u,f){let p=Reflect.get(u,f,u);return Object.getOwnPropertyDescriptor(u,f)?.get!==void 0?ho(p):p}});return r.push(c),c},t?.space)??"null"}function UK(e){for(let t of Object.getOwnPropertyNames(e))if(Object.getOwnPropertyDescriptor(e,t)?.get!==void 0)return!0;return!1}function DK(e){for(let t of[Number.prototype.valueOf,Boolean.prototype.valueOf,String.prototype.valueOf])try{return Reflect.apply(t,e,[]),!0}catch{}return!1}var Qe=Symbol.for("nodejs.util.inspect.custom"),pr=e=>{try{return e=ho(e),O(e,"toJSON")&&or(e.toJSON)&&e.toJSON.length===0?e.toJSON():Array.isArray(e)?e.map(pr):e}catch{return"[toJSON threw]"}},e_=(e,t=2)=>{if(typeof e=="string")return e;try{return typeof e=="object"?Wc(e,{space:t}):H(e,{space:t})}catch{return String(e)}},Ot={toJSON(){return pr(this)},[Qe](){return this.toJSON()},toString(){return H(this.toJSON())}},bx=class{[Qe](){return this.toJSON()}toString(){return H(this.toJSON())}};var BK=()=>{let e=Object.getOwnPropertyDescriptor(Error,"stackTraceLimit");return e===void 0?Object.isExtensible(Error):Object.hasOwn(e,"writable")?e.writable===!0:e.set!==void 0},$K=BK(),Ir=()=>Error.stackTraceLimit,yt=e=>{$K&&(Error.stackTraceLimit=e)};var _a=class{constructor(t){this.value=t,this.done=!1}next(t){return this.done?(this.value=t,this):(this.done=!0,{value:this.value,done:!1})}},jK=()=>{let e="~effect/Utils/internal",t={[e]:s=>s()},r={[e]:s=>s()},n=Ir();if(n===0)return r[e];yt(2);let o=t[e](()=>new Error);return yt(n),o.stack?.includes(e)===!0?t[e]:r[e]},Pa=jK();function B(e,t,r){t==="__proto__"?Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0}):e[t]=r}function Ex(e,t){for(let r of Reflect.ownKeys(t))Object.prototype.propertyIsEnumerable.call(t,r)&&B(e,r,t[r])}var si="~effect/Effect",Kc="~effect/Exit",qK={_A:F,_E:F,_R:F},hI=`${si}/identifier`,Se=`${si}/args`,St=`${si}/evaluate`,mr=`${si}/successCont`,go=`${si}/failureCont`,Vc=`${si}/ensureCont`,Jc=Symbol.for("effect/Effect/Yield"),wr={pipe(){return V(this,arguments)},toJSON(){return{...this}},toString(){return H(this.toJSON(),{ignoreToString:!0,space:2})},[Qe](){return this.toJSON()}},r_={[ie](){return Hd(this,Object.keys(this))},[ae](e){let t=Object.keys(this),r=Object.keys(e);if(t.length!==r.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==r[n]||!Z(this[t[n]],e[t[n]]))return!1;return!0}},zK={[si]:qK,...wr,[Symbol.iterator](){return new _a(this)},toJSON(){return{_id:"Effect",op:this[hI],...Se in this?{args:this[Se]}:void 0}}},ge=e=>O(e,si),Gd=e=>O(e,Kc),Ix="~effect/Cause",Kd="~effect/Cause/Reason",_f=e=>O(e,Ix),n_=e=>O(e,Kd),oi=class{constructor(t){this[Ix]=Ix,this.reasons=t}pipe(){return V(this,arguments)}toJSON(){return{_id:"Cause",failures:this.reasons.map(t=>t.toJSON())}}toString(){return`Cause(${H(this.reasons)})`}[Qe](){return this.toJSON()}[ae](t){return _f(t)&&this.reasons.length===t.reasons.length&&this.reasons.every((r,n)=>Z(r,t.reasons[n]))}[ie](){return ri(this.reasons)}},t_=new WeakMap,Rf=class{[Kd];annotations;_tag;constructor(t,r,n){if(this[Kd]=Kd,this._tag=t,r!==Jd&&typeof n=="object"&&n!==null&&r.size>0){let o=t_.get(n);o&&(r=new Map([...o,...r])),t_.set(n,r)}this.annotations=r}annotate(t,r){if(t.mapUnsafe.size===0)return this;let n=new Map(this.annotations);t.mapUnsafe.forEach((s,i)=>{r?.overwrite!==!0&&n.has(i)||n.set(i,s)});let o=Object.assign(Object.create(Object.getPrototypeOf(this)),this);return o.annotations=n,o}pipe(){return V(this,arguments)}toString(){return H(this)}[Qe](){return this.toString()}},Jd=new Map,Gc=class extends Rf{constructor(t,r=Jd){super("Fail",r,t),this.error=t}toString(){return`Fail(${H(this.error)})`}toJSON(){return{_tag:"Fail",error:this.error}}[ae](t){return hs(t)&&Z(this.error,t.error)&&Z(this.annotations,t.annotations)}[ie](){return he(Be(this._tag))(he(G(this.error))(G(this.annotations)))}},zi=e=>new oi(e),WK=(e,t)=>{let r=new Map,n=[];for(let o of e.concat(t)){let s=G(o),i=r.get(s);if(i===void 0)r.set(s,[o]);else{if(i.some(a=>Z(a,o)))continue;i.push(o)}n.push(o)}return n},Pf=d(2,(e,t)=>{if(e.reasons.length===0)return t;if(t.reasons.length===0)return e;let r=new oi(WK(e.reasons,t.reasons));return Z(e,r)?e:r}),xI=new oi([]),Mf=e=>new oi([new Gc(e)]),Vd=class extends Rf{constructor(t,r=Jd){super("Die",r,t),this.defect=t}toString(){return`Die(${H(this.defect)})`}toJSON(){return{_tag:"Die",defect:this.defect}}[ae](t){return Qd(t)&&Z(this.defect,t.defect)&&Z(this.annotations,t.annotations)}[ie](){return he(Be(this._tag))(he(G(this.defect))(G(this.annotations)))}},gI=e=>new oi([new Vd(e)]),Zd=d(e=>_f(e[0]),(e,t,r)=>t.mapUnsafe.size===0?e:new oi(e.reasons.map(n=>n.annotate(t,r)))),hs=e=>e._tag==="Fail",Qd=e=>e._tag==="Die",Yd=e=>e._tag==="Interrupt";function KK(e){return ln("Effect.evaluate: Not implemented")}var yo=e=>({...zK,[hI]:e.op,[St]:e[St]??KK,[mr]:e[mr],[go]:e[go],[Vc]:e[Vc]}),Uo=e=>{let t=yo(e),r=function(n){this[Se]=n};return r.prototype=t,function(n){return new r(n)}},o_=e=>{let t={[Kc]:Kc,_tag:e.op,get[e.prop](){return this[Se]},...yo(e),toString(){return`${e.op}(${H(this[Se])})`},toJSON(){return{_id:"Exit",_tag:e.op,[e.prop]:this[Se]}},[ae](n){return Gd(n)&&n._tag===this._tag&&Z(this[Se],n[Se])},[ie](){return he(Be(e.op),G(this[Se]))}},r=function(n){this[Se]=n};return r.prototype=t,function(n){return new r(n)}},ze=o_({op:"Success",prop:"value",[St](e){let t=e.getCont(mr);return t?t[mr](this[Se],e,this):e.yieldWith(this)}}),wx={key:"effect/Cause/StackTrace"},yI={key:"effect/Cause/InterruptorStackTrace"},Pr=o_({op:"Failure",prop:"cause",[St](e){let t=this[Se],r=!1;e.cache.stackFrame&&(t=Zd(t,{mapUnsafe:new Map([[wx.key,e.cache.stackFrame]])}),r=!0);let n=e.getCont(go),o=e._interruptedCause;if(o&&e.interruptible){let s=!1;for(;n&&e.interruptible;)s||=hI in n,n=e.getCont(go);s&&(t=zi(t.reasons.filter(i=>i._tag!=="Fail"))),t=Pf(t,o),r=!0}return n?n[go](t,e,r?void 0:this):e.yieldWith(r?Pr(t):this)}}),So=e=>Pr(Mf(e)),ln=e=>Pr(gI(e)),oe=Uo({op:"WithFiber",[St](e){return this[Se](e)}}),s_=Uo({op:"WithFiberSucceed",[St](e){let t=this[Se](e),r=e.getCont(mr);return r?r[mr](t,e):e.yieldWith(ze(t))}}),VK=(function(){class e extends globalThis.Error{}let t=yo({op:"YieldableError",[St](){return So(this)}});return delete t.toString,Object.assign(e.prototype,t),e})(),Xd=(function(){let e=Symbol.for("effect/Data/Error/plainArgs");return class extends VK{constructor(r){super(r?.message,r?.cause?{cause:r.cause}:void 0),r&&(Ex(this,r),Object.defineProperty(this,e,{value:r,enumerable:!1}))}toJSON(){return{...this[e],...this}}}})(),Wi=e=>{class t extends Xd{_tag=e}return t.prototype.name=e,t},Tx="~effect/Cause/NoSuchElementError",SI=e=>O(e,Tx),ms=class extends Wi("NoSuchElementError"){[Tx]=Tx;constructor(t){super({message:t})}},Of="~effect/Cause/Done",i_=e=>O(e,Of),a_={[Of]:Of,_tag:"Done",value:void 0},Zc=e=>e===void 0?a_:{[Of]:Of,_tag:"Done",value:e},GK=So(a_),c_=e=>e===void 0?GK:So(Zc(e));var u_=e=>yo({op:e.label,[St]:e.evaluate});var ke={};ps(ke,{Do:()=>O3,all:()=>x3,andThen:()=>d3,as:()=>C_,asVoid:()=>f3,bind:()=>R3,bindTo:()=>A3,composeK:()=>m3,contains:()=>v3,containsWith:()=>__,exists:()=>C3,filter:()=>Fa,filterMap:()=>b3,firstSomeOf:()=>c3,flatMap:()=>gs,flatMapNullishOr:()=>RI,flatten:()=>eu,fromIterable:()=>r3,fromNullOr:()=>AI,fromNullishOr:()=>Xc,fromUndefinedOr:()=>CI,gen:()=>_3,getFailure:()=>o3,getOrElse:()=>Ma,getOrNull:()=>sp,getOrThrow:()=>kI,getOrThrowWith:()=>Bf,getOrUndefined:()=>_n,getSuccess:()=>n3,isNone:()=>fe,isOption:()=>ci,isSome:()=>de,let:()=>k3,lift2:()=>T3,liftNullishOr:()=>u3,liftPredicate:()=>w3,liftThrowable:()=>xs,makeCombinerFailFast:()=>P_,makeEquivalence:()=>E3,makeOrder:()=>I3,makeReducer:()=>P3,makeReducerFailFast:()=>M3,map:()=>Lt,match:()=>Zt,none:()=>_,orElse:()=>s3,orElseResult:()=>a3,orElseSome:()=>i3,partitionMap:()=>S3,product:()=>R_,productMany:()=>h3,reduceCompact:()=>g3,some:()=>N,tap:()=>k_,toArray:()=>y3,toRefinement:()=>t3,void:()=>l3,zipLeft:()=>p3,zipRight:()=>A_,zipWith:()=>O_});function l_(e){return{combine:e}}function bI(e,t,r){return{combine:e,initialValue:t,combineAll:r??(n=>{let o=t;for(let s of n)o=e(o,s);return o})}}var Wr=e=>(t,r)=>t===r||e(t,r),JK=(e,t)=>e===t,Qc=()=>JK;function m_(e){return Wr((t,r)=>{if(t.length!==r.length)return!1;for(let n=0;n<t.length;n++)if(!e[n](t[n],r[n]))return!1;return!0})}function vx(e){return Wr((t,r)=>{if(t.length!==r.length)return!1;for(let n=0;n<t.length;n++)if(!e(t[n],r[n]))return!1;return!0})}var Cx=e=>d(3,(t,r,n)=>e(t,o=>({...o,[r]:n(o)}))),Ax=e=>d(2,(t,r)=>e(t,n=>({[r]:n}))),kx=(e,t)=>d(3,(r,n,o)=>t(r,s=>e(o(s),i=>({...s,[n]:i}))));var x_="~effect/Option",g_={[x_]:{_A:e=>e},...wr,[Symbol.iterator](){return new _a(this)}},ZK=Object.defineProperty(Object.assign(Object.create(g_),{_tag:"Some",_op:"Some",[ae](e){return Rx(e)&&EI(e)&&Z(this.value,e.value)},[ie](){return he(G(this._tag))(G(this.value))},toString(){return`some(${H(this.value)})`},toJSON(){return{_id:"Option",_tag:this._tag,value:pr(this.value)}}}),"valueOrUndefined",{get(){return this.value}}),QK=G("None"),YK=Object.assign(Object.create(g_),{_tag:"None",_op:"None",valueOrUndefined:void 0,[ae](e){return Rx(e)&&Ox(e)},[ie](){return QK},toString(){return"none()"},toJSON(){return{_id:"Option",_tag:this._tag}}}),Rx=e=>O(e,x_),Ox=e=>e._tag==="None",EI=e=>e._tag==="Some",ep=Object.create(YK),y_=function(e){this.value=e};y_.prototype=ZK;var tp=e=>new y_(e);var b_="~effect/Result",E_={[b_]:{_A:e=>e,_E:e=>e},...wr,[Symbol.iterator](){return new _a(this)}},XK=Object.assign(Object.create(E_),{_tag:"Success",_op:"Success",[ae](e){return _x(e)&&Nf(e)&&Z(this.success,e.success)},[ie](){return he(G(this._tag))(G(this.success))},toString(){return`success(${H(this.success)})`},toJSON(){return{_id:"Result",_tag:this._tag,value:pr(this.success)}}}),e3=Object.assign(Object.create(E_),{_tag:"Failure",_op:"Failure",[ae](e){return _x(e)&&Ff(e)&&Z(this.failure,e.failure)},[ie](){return he(G(this._tag))(G(this.failure))},toString(){return`failure(${H(this.failure)})`},toJSON(){return{_id:"Result",_tag:this._tag,failure:pr(this.failure)}}}),_x=e=>O(e,b_),Ff=e=>e._tag==="Failure",Nf=e=>e._tag==="Success",I_=function(e){this.failure=e};I_.prototype=e3;var Px=e=>new I_(e),T_=function(e){this.success=e};T_.prototype=XK;var Mx=e=>new T_(e),II=e=>Nf(e)?ep:tp(e.failure),TI=e=>Ff(e)?ep:tp(e.success);function ai(e){return(t,r)=>t===r?0:e(t,r)}var v_=ai((e,t)=>e<t?-1:1),Ki=ai((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);var Uf=ai((e,t)=>e<t?-1:1);var wI=d(2,(e,t)=>ai((r,n)=>e(t(r),t(n)))),Df=wI(Ki,e=>e.getTime());var rp=e=>d(2,(t,r)=>e(t,r)===-1),Yc=e=>d(2,(t,r)=>e(t,r)===1),np=e=>d(2,(t,r)=>e(t,r)!==1),op=e=>d(2,(t,r)=>e(t,r)!==-1),vI=e=>d(2,(t,r)=>t===r||e(t,r)<1?t:r);var _=()=>ep,N=tp,ci=Rx,fe=Ox,de=EI,Zt=d(2,(e,{onNone:t,onSome:r})=>fe(e)?t():r(e.value)),t3=e=>t=>de(e(t)),r3=e=>{for(let t of e)return N(t);return _()},n3=TI,o3=II,Ma=d(2,(e,t)=>fe(e)?t():e.value),s3=d(2,(e,t)=>fe(e)?t():e),i3=d(2,(e,t)=>fe(e)?N(t()):e),a3=d(2,(e,t)=>fe(e)?Lt(t(),Mx):Lt(e,Px)),c3=e=>{let t=_();for(t of e)if(de(t))return t;return t},Xc=e=>e==null?_():N(e),CI=e=>e===void 0?_():N(e),AI=e=>e===null?_():N(e),u3=e=>(...t)=>Xc(e(...t)),sp=Ma(sI),_n=Ma(po),xs=e=>(...t)=>{try{return N(e(...t))}catch{return _()}},Bf=d(2,(e,t)=>{if(de(e))return e.value;throw t()}),kI=Bf(()=>new Error("getOrThrow called on a None")),Lt=d(2,(e,t)=>fe(e)?_():N(t(e.value))),C_=d(2,(e,t)=>Lt(e,()=>t)),f3=C_(void 0),l3=N(void 0);var gs=d(2,(e,t)=>fe(e)?_():t(e.value)),d3=d(2,(e,t)=>gs(e,r=>{let n=or(t)?t(r):t;return ci(n)?n:N(n)})),RI=d(2,(e,t)=>fe(e)?_():Xc(t(e.value))),eu=gs(F),A_=d(2,(e,t)=>gs(e,()=>t)),p3=d(2,(e,t)=>k_(e,()=>t)),m3=d(2,(e,t)=>r=>gs(e(r),t)),k_=d(2,(e,t)=>gs(e,r=>Lt(t(r),()=>r))),R_=d(2,(e,t)=>de(e)&&de(t)?N([e.value,t.value]):_()),h3=d(2,(e,t)=>{if(fe(e))return _();let r=[e.value];for(let n of t){if(fe(n))return _();r.push(n.value)}return N(r)}),x3=e=>{if(Symbol.iterator in e){let r=[];for(let n of e){if(fe(n))return _();r.push(n.value)}return N(r)}let t={};for(let r of Object.keys(e)){let n=e[r];if(fe(n))return _();B(t,r,n.value)}return N(t)},O_=d(3,(e,t,r)=>Lt(R_(e,t),([n,o])=>r(n,o))),g3=d(3,(e,t,r)=>{let n=t;for(let o of e)de(o)&&(n=r(n,o.value));return n}),y3=e=>fe(e)?[]:[e.value],S3=d(2,(e,t)=>{if(fe(e))return[_(),_()];let r=t(e.value);return Ff(r)?[_(),N(r.failure)]:[N(r.success),_()]}),b3=d(2,(e,t)=>{if(fe(e))return _();let r=t(e.value);return Nf(r)?N(r.success):_()}),Fa=d(2,(e,t)=>fe(e)?_():t(e.value)?N(e.value):_()),E3=e=>Wr((t,r)=>fe(t)?fe(r):fe(r)?!1:e(t.value,r.value)),I3=e=>ai((t,r)=>de(t)?de(r)?e(t.value,r.value):1:-1),T3=e=>d(2,(t,r)=>O_(t,r,e)),w3=d(2,(e,t)=>t(e)?N(e):_()),__=e=>d(2,(t,r)=>fe(t)?!1:e(t.value,r)),v3=__(Wd()),C3=d(2,(e,t)=>fe(e)?!1:t(e.value)),A3=Ax(Lt),k3=Cx(Lt);var R3=kx(Lt,gs),O3=N({}),_3=(...e)=>{let r=(e.length===1?e[0]:e[1].bind(e[0]))(),n=r.next();for(;!n.done;){let o=n.value;if(fe(o))return o;n=r.next(o.value)}return N(n.value)};function P3(e){return bI((t,r)=>fe(t)?r:fe(r)?t:N(e.combine(t.value,r.value)),_())}function P_(e){return l_((t,r)=>fe(t)||fe(r)?_():N(e.combine(t.value,r.value)))}function M3(e){let t=P_(e).combine,r=N(e.initialValue);return bI(t,r,n=>{let o=r;for(let s of n)if(o=t(o,s),fe(o))return o;return o})}var M_="~effect/Context/Service",Ue=function(){function e(){}let t=e;Object.setPrototypeOf(t,F3);let r=(n,o)=>(t.key=n,o?.defaultValue&&(t[_I]=_I,t.defaultValue=o.defaultValue),o?.make&&(t.make=o.make),o?.fiberCached&&F_.add(n),t);return arguments.length>0?r(arguments[0],arguments[1]):r},F3={[M_]:M_,...u_({label:"Service",evaluate(e){return ze(Re(e.context,this))}}),toJSON(){return{_id:"Service",key:this.key}},of(e){return e},context(e){return ys(this,e)},use(e){return oe(t=>e(Re(t.context,this)))},useSync(e){return oe(t=>ze(e(Re(t.context,this))))}},F_=new Set,_I="~effect/Context/Reference",N_="~effect/Context",N3=8,U3=8,PI=(e,t,r,n)=>{let o=Object.create(D3);return o.cacheRoot=e??o,o.base=t,o.overlay=r,o.depth=n,o._flat=void 0,o.baseHits=0,o},MI=(e,t)=>{t&&(MI(e,t.parent),e.set(t.key,t.value))},U_=e=>{if(e._flat)return e._flat;if(!e.overlay)return e._flat=e.base;let t=new Map(e.base);return MI(t,e.overlay),e._flat=t},D_=(e,t)=>{let r=new Map(e.mapUnsafe);return t(r),qn(r)},Fx=Symbol(),FI=(e,t)=>{let r=e;for(let o=r.overlay;o;o=o.parent)if(o.key===t)return o.value;let n=r.base.get(t);return n===void 0&&!r.base.has(t)?Fx:(r.overlay&&++r.baseHits>=r.base.size&&r.baseHits>=U3&&(r.base=U_(r),r.overlay=void 0,r.depth=0),n)},qn=e=>PI(void 0,e,void 0,0),D3={get mapUnsafe(){return U_(this)},...wr,[N_]:{_Services:e=>e},toJSON(){return{_id:"Context",services:Array.from(this.mapUnsafe).map(([e,t])=>({key:e,value:t}))}},[ae](e){if(!ip(e))return!1;let t=this.mapUnsafe,r=e.mapUnsafe;if(t.size!==r.size)return!1;for(let[n,o]of t)if(!r.has(n)||!Z(o,r.get(n)))return!1;return!0},[ie](){return zt(this.mapUnsafe.size)}},L_=(e,t)=>e.cacheRoot===t.cacheRoot,ip=e=>O(e,N_);var B_=e=>!!e[_I],pt=()=>L3,L3=qn(new Map),ys=(e,t)=>qn(new Map([[e.key,t]])),We=d(3,(e,t,r)=>B3(e,t.key,r)),B3=(e,t,r)=>{let n=e,o=F_.has(t)?void 0:n.cacheRoot;if(n.depth>=N3){let s=new Map(n._flat??n.base);return n._flat||MI(s,n.overlay),s.set(t,r),PI(o,s,void 0,0)}return PI(o,n.base,{key:t,value:r,parent:n.overlay},n.depth+1)};var Vi=d(2,(e,t)=>Gi(e,t.key)),Gi=(e,t)=>{let r=FI(e,t);return r===Fx?void 0:r},dn=d(2,(e,t)=>{let r=FI(e,t.key);if(r===Fx){if(B_(t))return $_(t);throw $3(t)}return r}),Re=dn,OI="~effect/Context/defaultValue",$_=e=>OI in e?e[OI]:e[OI]=e.defaultValue(),$3=e=>{let t=new Error(`Service not found${e.key?`: ${String(e.key)}`:""}`);if(t.stack){let r=t.stack.split(`
8
+ ${s(p)}}`;m=i(f,x)}}return n.delete(f),m}return String(f)}return c(e,0)}var FK="[Circular]";function ni(e){return typeof e=="string"?JSON.stringify(e):String(e)}function Sx(e){return e.map(t=>`[${ni(t)}]`).join("")}function xI(e){try{return e.toISOString()}catch{return"Invalid Date"}}function NK(e){try{let t=e.toString();return typeof t=="string"?t:String(t)}catch{return"[toString threw]"}}function e_(e,t){try{return e[t]}catch{return"[property access threw]"}}function Kc(e,t){let r=[];return JSON.stringify(e,function(n,o){let s=Object.getOwnPropertyDescriptor(this,n)?.value,i=O(s,Wc)?ho(s):ho(o);if(typeof i=="bigint")return H(i);if(typeof i!="object"||i===null)return i;let a=i instanceof Error&&!O(i,"toJSON")?{...i,name:i.name,message:i.message}:i;for(;r.length>0&&r[r.length-1]!==this;)r.pop();if(r.includes(i))return;if(r.push(i),a!==i&&r.push(a),!UK(a)||DK(a))return a;let c=new Proxy(a,{get(u,f){let p=Reflect.get(u,f,u);return Object.getOwnPropertyDescriptor(u,f)?.get!==void 0?ho(p):p}});return r.push(c),c},t?.space)??"null"}function UK(e){for(let t of Object.getOwnPropertyNames(e))if(Object.getOwnPropertyDescriptor(e,t)?.get!==void 0)return!0;return!1}function DK(e){for(let t of[Number.prototype.valueOf,Boolean.prototype.valueOf,String.prototype.valueOf])try{return Reflect.apply(t,e,[]),!0}catch{}return!1}var Qe=Symbol.for("nodejs.util.inspect.custom"),pr=e=>{try{return e=ho(e),O(e,"toJSON")&&or(e.toJSON)&&e.toJSON.length===0?e.toJSON():Array.isArray(e)?e.map(pr):e}catch{return"[toJSON threw]"}},t_=(e,t=2)=>{if(typeof e=="string")return e;try{return typeof e=="object"?Kc(e,{space:t}):H(e,{space:t})}catch{return String(e)}},Ot={toJSON(){return pr(this)},[Qe](){return this.toJSON()},toString(){return H(this.toJSON())}},bx=class{[Qe](){return this.toJSON()}toString(){return H(this.toJSON())}};var BK=()=>{let e=Object.getOwnPropertyDescriptor(Error,"stackTraceLimit");return e===void 0?Object.isExtensible(Error):Object.hasOwn(e,"writable")?e.writable===!0:e.set!==void 0},$K=BK(),Ir=()=>Error.stackTraceLimit,yt=e=>{$K&&(Error.stackTraceLimit=e)};var Pa=class{constructor(t){this.value=t,this.done=!1}next(t){return this.done?(this.value=t,this):(this.done=!0,{value:this.value,done:!1})}},jK=()=>{let e="~effect/Utils/internal",t={[e]:s=>s()},r={[e]:s=>s()},n=Ir();if(n===0)return r[e];yt(2);let o=t[e](()=>new Error);return yt(n),o.stack?.includes(e)===!0?t[e]:r[e]},Ma=jK();function B(e,t,r){t==="__proto__"?Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0}):e[t]=r}function Ex(e,t){for(let r of Reflect.ownKeys(t))Object.prototype.propertyIsEnumerable.call(t,r)&&B(e,r,t[r])}var si="~effect/Effect",Vc="~effect/Exit",qK={_A:F,_E:F,_R:F},gI=`${si}/identifier`,Se=`${si}/args`,St=`${si}/evaluate`,mr=`${si}/successCont`,go=`${si}/failureCont`,Gc=`${si}/ensureCont`,Zc=Symbol.for("effect/Effect/Yield"),wr={pipe(){return V(this,arguments)},toJSON(){return{...this}},toString(){return H(this.toJSON(),{ignoreToString:!0,space:2})},[Qe](){return this.toJSON()}},n_={[ie](){return Hd(this,Object.keys(this))},[ae](e){let t=Object.keys(this),r=Object.keys(e);if(t.length!==r.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==r[n]||!Z(this[t[n]],e[t[n]]))return!1;return!0}},zK={[si]:qK,...wr,[Symbol.iterator](){return new Pa(this)},toJSON(){return{_id:"Effect",op:this[gI],...Se in this?{args:this[Se]}:void 0}}},ge=e=>O(e,si),Gd=e=>O(e,Vc),Ix="~effect/Cause",Kd="~effect/Cause/Reason",_f=e=>O(e,Ix),o_=e=>O(e,Kd),oi=class{constructor(t){this[Ix]=Ix,this.reasons=t}pipe(){return V(this,arguments)}toJSON(){return{_id:"Cause",failures:this.reasons.map(t=>t.toJSON())}}toString(){return`Cause(${H(this.reasons)})`}[Qe](){return this.toJSON()}[ae](t){return _f(t)&&this.reasons.length===t.reasons.length&&this.reasons.every((r,n)=>Z(r,t.reasons[n]))}[ie](){return ri(this.reasons)}},r_=new WeakMap,Rf=class{[Kd];annotations;_tag;constructor(t,r,n){if(this[Kd]=Kd,this._tag=t,r!==Jd&&typeof n=="object"&&n!==null&&r.size>0){let o=r_.get(n);o&&(r=new Map([...o,...r])),r_.set(n,r)}this.annotations=r}annotate(t,r){if(t.mapUnsafe.size===0)return this;let n=new Map(this.annotations);t.mapUnsafe.forEach((s,i)=>{r?.overwrite!==!0&&n.has(i)||n.set(i,s)});let o=Object.assign(Object.create(Object.getPrototypeOf(this)),this);return o.annotations=n,o}pipe(){return V(this,arguments)}toString(){return H(this)}[Qe](){return this.toString()}},Jd=new Map,Jc=class extends Rf{constructor(t,r=Jd){super("Fail",r,t),this.error=t}toString(){return`Fail(${H(this.error)})`}toJSON(){return{_tag:"Fail",error:this.error}}[ae](t){return hs(t)&&Z(this.error,t.error)&&Z(this.annotations,t.annotations)}[ie](){return he(Be(this._tag))(he(G(this.error))(G(this.annotations)))}},zi=e=>new oi(e),WK=(e,t)=>{let r=new Map,n=[];for(let o of e.concat(t)){let s=G(o),i=r.get(s);if(i===void 0)r.set(s,[o]);else{if(i.some(a=>Z(a,o)))continue;i.push(o)}n.push(o)}return n},Pf=d(2,(e,t)=>{if(e.reasons.length===0)return t;if(t.reasons.length===0)return e;let r=new oi(WK(e.reasons,t.reasons));return Z(e,r)?e:r}),yI=new oi([]),Mf=e=>new oi([new Jc(e)]),Vd=class extends Rf{constructor(t,r=Jd){super("Die",r,t),this.defect=t}toString(){return`Die(${H(this.defect)})`}toJSON(){return{_tag:"Die",defect:this.defect}}[ae](t){return Qd(t)&&Z(this.defect,t.defect)&&Z(this.annotations,t.annotations)}[ie](){return he(Be(this._tag))(he(G(this.defect))(G(this.annotations)))}},SI=e=>new oi([new Vd(e)]),Zd=d(e=>_f(e[0]),(e,t,r)=>t.mapUnsafe.size===0?e:new oi(e.reasons.map(n=>n.annotate(t,r)))),hs=e=>e._tag==="Fail",Qd=e=>e._tag==="Die",Yd=e=>e._tag==="Interrupt";function KK(e){return ln("Effect.evaluate: Not implemented")}var yo=e=>({...zK,[gI]:e.op,[St]:e[St]??KK,[mr]:e[mr],[go]:e[go],[Gc]:e[Gc]}),Uo=e=>{let t=yo(e),r=function(n){this[Se]=n};return r.prototype=t,function(n){return new r(n)}},s_=e=>{let t={[Vc]:Vc,_tag:e.op,get[e.prop](){return this[Se]},...yo(e),toString(){return`${e.op}(${H(this[Se])})`},toJSON(){return{_id:"Exit",_tag:e.op,[e.prop]:this[Se]}},[ae](n){return Gd(n)&&n._tag===this._tag&&Z(this[Se],n[Se])},[ie](){return he(Be(e.op),G(this[Se]))}},r=function(n){this[Se]=n};return r.prototype=t,function(n){return new r(n)}},ze=s_({op:"Success",prop:"value",[St](e){let t=e.getCont(mr);return t?t[mr](this[Se],e,this):e.yieldWith(this)}}),wx={key:"effect/Cause/StackTrace"},bI={key:"effect/Cause/InterruptorStackTrace"},Pr=s_({op:"Failure",prop:"cause",[St](e){let t=this[Se],r=!1;e.cache.stackFrame&&(t=Zd(t,{mapUnsafe:new Map([[wx.key,e.cache.stackFrame]])}),r=!0);let n=e.getCont(go),o=e._interruptedCause;if(o&&e.interruptible){let s=!1;for(;n&&e.interruptible;)s||=gI in n,n=e.getCont(go);s&&(t=zi(t.reasons.filter(i=>i._tag!=="Fail"))),t=Pf(t,o),r=!0}return n?n[go](t,e,r?void 0:this):e.yieldWith(r?Pr(t):this)}}),So=e=>Pr(Mf(e)),ln=e=>Pr(SI(e)),oe=Uo({op:"WithFiber",[St](e){return this[Se](e)}}),i_=Uo({op:"WithFiberSucceed",[St](e){let t=this[Se](e),r=e.getCont(mr);return r?r[mr](t,e):e.yieldWith(ze(t))}}),VK=(function(){class e extends globalThis.Error{}let t=yo({op:"YieldableError",[St](){return So(this)}});return delete t.toString,Object.assign(e.prototype,t),e})(),Xd=(function(){let e=Symbol.for("effect/Data/Error/plainArgs");return class extends VK{constructor(r){super(r?.message,r?.cause?{cause:r.cause}:void 0),r&&(Ex(this,r),Object.defineProperty(this,e,{value:r,enumerable:!1}))}toJSON(){return{...this[e],...this}}}})(),Wi=e=>{class t extends Xd{_tag=e}return t.prototype.name=e,t},Tx="~effect/Cause/NoSuchElementError",EI=e=>O(e,Tx),ms=class extends Wi("NoSuchElementError"){[Tx]=Tx;constructor(t){super({message:t})}},Of="~effect/Cause/Done",a_=e=>O(e,Of),c_={[Of]:Of,_tag:"Done",value:void 0},Qc=e=>e===void 0?c_:{[Of]:Of,_tag:"Done",value:e},GK=So(c_),u_=e=>e===void 0?GK:So(Qc(e));var f_=e=>yo({op:e.label,[St]:e.evaluate});var ke={};ps(ke,{Do:()=>O3,all:()=>x3,andThen:()=>d3,as:()=>C_,asVoid:()=>f3,bind:()=>R3,bindTo:()=>C3,composeK:()=>m3,contains:()=>v3,containsWith:()=>P_,exists:()=>A3,filter:()=>Na,filterMap:()=>b3,firstSomeOf:()=>c3,flatMap:()=>gs,flatMapNullishOr:()=>_I,flatten:()=>tu,fromIterable:()=>r3,fromNullOr:()=>RI,fromNullishOr:()=>eu,fromUndefinedOr:()=>kI,gen:()=>_3,getFailure:()=>o3,getOrElse:()=>Fa,getOrNull:()=>sp,getOrThrow:()=>OI,getOrThrowWith:()=>Bf,getOrUndefined:()=>_n,getSuccess:()=>n3,isNone:()=>fe,isOption:()=>ci,isSome:()=>de,let:()=>k3,lift2:()=>T3,liftNullishOr:()=>u3,liftPredicate:()=>w3,liftThrowable:()=>xs,makeCombinerFailFast:()=>M_,makeEquivalence:()=>E3,makeOrder:()=>I3,makeReducer:()=>P3,makeReducerFailFast:()=>M3,map:()=>Lt,match:()=>Zt,none:()=>_,orElse:()=>s3,orElseResult:()=>a3,orElseSome:()=>i3,partitionMap:()=>S3,product:()=>O_,productMany:()=>h3,reduceCompact:()=>g3,some:()=>N,tap:()=>R_,toArray:()=>y3,toRefinement:()=>t3,void:()=>l3,zipLeft:()=>p3,zipRight:()=>k_,zipWith:()=>__});function d_(e){return{combine:e}}function II(e,t,r){return{combine:e,initialValue:t,combineAll:r??(n=>{let o=t;for(let s of n)o=e(o,s);return o})}}var Wr=e=>(t,r)=>t===r||e(t,r),JK=(e,t)=>e===t,Yc=()=>JK;function h_(e){return Wr((t,r)=>{if(t.length!==r.length)return!1;for(let n=0;n<t.length;n++)if(!e[n](t[n],r[n]))return!1;return!0})}function vx(e){return Wr((t,r)=>{if(t.length!==r.length)return!1;for(let n=0;n<t.length;n++)if(!e(t[n],r[n]))return!1;return!0})}var Ax=e=>d(3,(t,r,n)=>e(t,o=>({...o,[r]:n(o)}))),Cx=e=>d(2,(t,r)=>e(t,n=>({[r]:n}))),kx=(e,t)=>d(3,(r,n,o)=>t(r,s=>e(o(s),i=>({...s,[n]:i}))));var g_="~effect/Option",y_={[g_]:{_A:e=>e},...wr,[Symbol.iterator](){return new Pa(this)}},ZK=Object.defineProperty(Object.assign(Object.create(y_),{_tag:"Some",_op:"Some",[ae](e){return Rx(e)&&TI(e)&&Z(this.value,e.value)},[ie](){return he(G(this._tag))(G(this.value))},toString(){return`some(${H(this.value)})`},toJSON(){return{_id:"Option",_tag:this._tag,value:pr(this.value)}}}),"valueOrUndefined",{get(){return this.value}}),QK=G("None"),YK=Object.assign(Object.create(y_),{_tag:"None",_op:"None",valueOrUndefined:void 0,[ae](e){return Rx(e)&&Ox(e)},[ie](){return QK},toString(){return"none()"},toJSON(){return{_id:"Option",_tag:this._tag}}}),Rx=e=>O(e,g_),Ox=e=>e._tag==="None",TI=e=>e._tag==="Some",ep=Object.create(YK),S_=function(e){this.value=e};S_.prototype=ZK;var tp=e=>new S_(e);var E_="~effect/Result",I_={[E_]:{_A:e=>e,_E:e=>e},...wr,[Symbol.iterator](){return new Pa(this)}},XK=Object.assign(Object.create(I_),{_tag:"Success",_op:"Success",[ae](e){return _x(e)&&Nf(e)&&Z(this.success,e.success)},[ie](){return he(G(this._tag))(G(this.success))},toString(){return`success(${H(this.success)})`},toJSON(){return{_id:"Result",_tag:this._tag,value:pr(this.success)}}}),e3=Object.assign(Object.create(I_),{_tag:"Failure",_op:"Failure",[ae](e){return _x(e)&&Ff(e)&&Z(this.failure,e.failure)},[ie](){return he(G(this._tag))(G(this.failure))},toString(){return`failure(${H(this.failure)})`},toJSON(){return{_id:"Result",_tag:this._tag,failure:pr(this.failure)}}}),_x=e=>O(e,E_),Ff=e=>e._tag==="Failure",Nf=e=>e._tag==="Success",T_=function(e){this.failure=e};T_.prototype=e3;var Px=e=>new T_(e),w_=function(e){this.success=e};w_.prototype=XK;var Mx=e=>new w_(e),wI=e=>Nf(e)?ep:tp(e.failure),vI=e=>Ff(e)?ep:tp(e.success);function ai(e){return(t,r)=>t===r?0:e(t,r)}var A_=ai((e,t)=>e<t?-1:1),Ki=ai((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);var Uf=ai((e,t)=>e<t?-1:1);var AI=d(2,(e,t)=>ai((r,n)=>e(t(r),t(n)))),Df=AI(Ki,e=>e.getTime());var rp=e=>d(2,(t,r)=>e(t,r)===-1),Xc=e=>d(2,(t,r)=>e(t,r)===1),np=e=>d(2,(t,r)=>e(t,r)!==1),op=e=>d(2,(t,r)=>e(t,r)!==-1),CI=e=>d(2,(t,r)=>t===r||e(t,r)<1?t:r);var _=()=>ep,N=tp,ci=Rx,fe=Ox,de=TI,Zt=d(2,(e,{onNone:t,onSome:r})=>fe(e)?t():r(e.value)),t3=e=>t=>de(e(t)),r3=e=>{for(let t of e)return N(t);return _()},n3=vI,o3=wI,Fa=d(2,(e,t)=>fe(e)?t():e.value),s3=d(2,(e,t)=>fe(e)?t():e),i3=d(2,(e,t)=>fe(e)?N(t()):e),a3=d(2,(e,t)=>fe(e)?Lt(t(),Mx):Lt(e,Px)),c3=e=>{let t=_();for(t of e)if(de(t))return t;return t},eu=e=>e==null?_():N(e),kI=e=>e===void 0?_():N(e),RI=e=>e===null?_():N(e),u3=e=>(...t)=>eu(e(...t)),sp=Fa(aI),_n=Fa(po),xs=e=>(...t)=>{try{return N(e(...t))}catch{return _()}},Bf=d(2,(e,t)=>{if(de(e))return e.value;throw t()}),OI=Bf(()=>new Error("getOrThrow called on a None")),Lt=d(2,(e,t)=>fe(e)?_():N(t(e.value))),C_=d(2,(e,t)=>Lt(e,()=>t)),f3=C_(void 0),l3=N(void 0);var gs=d(2,(e,t)=>fe(e)?_():t(e.value)),d3=d(2,(e,t)=>gs(e,r=>{let n=or(t)?t(r):t;return ci(n)?n:N(n)})),_I=d(2,(e,t)=>fe(e)?_():eu(t(e.value))),tu=gs(F),k_=d(2,(e,t)=>gs(e,()=>t)),p3=d(2,(e,t)=>R_(e,()=>t)),m3=d(2,(e,t)=>r=>gs(e(r),t)),R_=d(2,(e,t)=>gs(e,r=>Lt(t(r),()=>r))),O_=d(2,(e,t)=>de(e)&&de(t)?N([e.value,t.value]):_()),h3=d(2,(e,t)=>{if(fe(e))return _();let r=[e.value];for(let n of t){if(fe(n))return _();r.push(n.value)}return N(r)}),x3=e=>{if(Symbol.iterator in e){let r=[];for(let n of e){if(fe(n))return _();r.push(n.value)}return N(r)}let t={};for(let r of Object.keys(e)){let n=e[r];if(fe(n))return _();B(t,r,n.value)}return N(t)},__=d(3,(e,t,r)=>Lt(O_(e,t),([n,o])=>r(n,o))),g3=d(3,(e,t,r)=>{let n=t;for(let o of e)de(o)&&(n=r(n,o.value));return n}),y3=e=>fe(e)?[]:[e.value],S3=d(2,(e,t)=>{if(fe(e))return[_(),_()];let r=t(e.value);return Ff(r)?[_(),N(r.failure)]:[N(r.success),_()]}),b3=d(2,(e,t)=>{if(fe(e))return _();let r=t(e.value);return Nf(r)?N(r.success):_()}),Na=d(2,(e,t)=>fe(e)?_():t(e.value)?N(e.value):_()),E3=e=>Wr((t,r)=>fe(t)?fe(r):fe(r)?!1:e(t.value,r.value)),I3=e=>ai((t,r)=>de(t)?de(r)?e(t.value,r.value):1:-1),T3=e=>d(2,(t,r)=>__(t,r,e)),w3=d(2,(e,t)=>t(e)?N(e):_()),P_=e=>d(2,(t,r)=>fe(t)?!1:e(t.value,r)),v3=P_(Wd()),A3=d(2,(e,t)=>fe(e)?!1:t(e.value)),C3=Cx(Lt),k3=Ax(Lt);var R3=kx(Lt,gs),O3=N({}),_3=(...e)=>{let r=(e.length===1?e[0]:e[1].bind(e[0]))(),n=r.next();for(;!n.done;){let o=n.value;if(fe(o))return o;n=r.next(o.value)}return N(n.value)};function P3(e){return II((t,r)=>fe(t)?r:fe(r)?t:N(e.combine(t.value,r.value)),_())}function M_(e){return d_((t,r)=>fe(t)||fe(r)?_():N(e.combine(t.value,r.value)))}function M3(e){let t=M_(e).combine,r=N(e.initialValue);return II(t,r,n=>{let o=r;for(let s of n)if(o=t(o,s),fe(o))return o;return o})}var F_="~effect/Context/Service",Ue=function(){function e(){}let t=e;Object.setPrototypeOf(t,F3);let r=(n,o)=>(t.key=n,o?.defaultValue&&(t[MI]=MI,t.defaultValue=o.defaultValue),o?.make&&(t.make=o.make),o?.fiberCached&&N_.add(n),t);return arguments.length>0?r(arguments[0],arguments[1]):r},F3={[F_]:F_,...f_({label:"Service",evaluate(e){return ze(Re(e.context,this))}}),toJSON(){return{_id:"Service",key:this.key}},of(e){return e},context(e){return ys(this,e)},use(e){return oe(t=>e(Re(t.context,this)))},useSync(e){return oe(t=>ze(e(Re(t.context,this))))}},N_=new Set,MI="~effect/Context/Reference",U_="~effect/Context",N3=8,U3=8,FI=(e,t,r,n)=>{let o=Object.create(D3);return o.cacheRoot=e??o,o.base=t,o.overlay=r,o.depth=n,o._flat=void 0,o.baseHits=0,o},NI=(e,t)=>{t&&(NI(e,t.parent),e.set(t.key,t.value))},D_=e=>{if(e._flat)return e._flat;if(!e.overlay)return e._flat=e.base;let t=new Map(e.base);return NI(t,e.overlay),e._flat=t},L_=(e,t)=>{let r=new Map(e.mapUnsafe);return t(r),qn(r)},Fx=Symbol(),UI=(e,t)=>{let r=e;for(let o=r.overlay;o;o=o.parent)if(o.key===t)return o.value;let n=r.base.get(t);return n===void 0&&!r.base.has(t)?Fx:(r.overlay&&++r.baseHits>=r.base.size&&r.baseHits>=U3&&(r.base=D_(r),r.overlay=void 0,r.depth=0),n)},qn=e=>FI(void 0,e,void 0,0),D3={get mapUnsafe(){return D_(this)},...wr,[U_]:{_Services:e=>e},toJSON(){return{_id:"Context",services:Array.from(this.mapUnsafe).map(([e,t])=>({key:e,value:t}))}},[ae](e){if(!ip(e))return!1;let t=this.mapUnsafe,r=e.mapUnsafe;if(t.size!==r.size)return!1;for(let[n,o]of t)if(!r.has(n)||!Z(o,r.get(n)))return!1;return!0},[ie](){return zt(this.mapUnsafe.size)}},B_=(e,t)=>e.cacheRoot===t.cacheRoot,ip=e=>O(e,U_);var $_=e=>!!e[MI],pt=()=>L3,L3=qn(new Map),ys=(e,t)=>qn(new Map([[e.key,t]])),We=d(3,(e,t,r)=>B3(e,t.key,r)),B3=(e,t,r)=>{let n=e,o=N_.has(t)?void 0:n.cacheRoot;if(n.depth>=N3){let s=new Map(n._flat??n.base);return n._flat||NI(s,n.overlay),s.set(t,r),FI(o,s,void 0,0)}return FI(o,n.base,{key:t,value:r,parent:n.overlay},n.depth+1)};var Vi=d(2,(e,t)=>Gi(e,t.key)),Gi=(e,t)=>{let r=UI(e,t);return r===Fx?void 0:r},dn=d(2,(e,t)=>{let r=UI(e,t.key);if(r===Fx){if($_(t))return j_(t);throw $3(t)}return r}),Re=dn,PI="~effect/Context/defaultValue",j_=e=>PI in e?e[PI]:e[PI]=e.defaultValue(),$3=e=>{let t=new Error(`Service not found${e.key?`: ${String(e.key)}`:""}`);if(t.stack){let r=t.stack.split(`
9
9
  `);r.splice(1,3),t.stack=r.join(`
10
- `)}return t},Nx=d(2,(e,t)=>{let r=FI(e,t.key);return r!==Fx?N(r):B_(t)?N($_(t)):_()}),Kr=d(2,(e,t)=>e.mapUnsafe.size===0?t:t.mapUnsafe.size===0?e:D_(e,r=>t.mapUnsafe.forEach((n,o)=>r.set(o,n)))),j_=(...e)=>{let t=new Map;for(let r=0;r<e.length;r++)e[r].mapUnsafe.forEach((n,o)=>{t.set(o,n)});return qn(t)};var H_=(...e)=>t=>D_(t,r=>{for(let n=0;n<e.length;n++)r.delete(e[n].key)}),Ce=Ue;var NI=e=>e.length>0;var Bt=e=>e>0?Math.floor(e):0,Lo=e=>Math.max(1,Bt(e));var X=Mx,re=Px;var Ux=e=>{if(or(e))try{return X(e())}catch(t){return re(t)}else try{return X(e.try())}catch(t){return re(e.catch(t))}};var $f=_x,be=Ff,tt=Nf;var UI=d(2,(e,t)=>be(e)?re(t(e.failure)):e),Vr=d(2,(e,t)=>tt(e)?X(t(e.success)):e),zn=d(2,(e,{onFailure:t,onSuccess:r})=>be(e)?t(e.failure):r(e.success));var ap=d(2,(e,t)=>be(e)?t(e.failure):e.success);var H3=d(2,(e,t)=>{if(tt(e))return e.success;throw t(e.failure)}),tu=H3(F);var hr=d(2,(e,t)=>be(e)?re(e.failure):t(e.success));var q_=m_;var q3=(e,t)=>{let r=t?.length!==void 0?Lo(t.length):1/0;return{[Symbol.iterator](){let n=0;return{next(){return n<r?{value:e(n++),done:!1}:{done:!0,value:void 0}}}}}};var z3=d(2,(e,t)=>W3(q3(()=>e,{length:t}))),W_=e=>z3(e,1/0);var K_=e=>{let r=e[Symbol.iterator]().next();if(r.done)throw new Error("headUnsafe: empty iterable");return r.value};var V_=d(2,(e,t)=>{let r=0;for(let n of e){let o=t(n,r);if(px(o)){if(o)return N(n)}else if(de(o))return o;r++}return _()});var W3=e=>({[Symbol.iterator](){let t=e[Symbol.iterator](),r;function n(){for(;;){if(r===void 0){let s=t.next();if(s.done)return s;r=s.value[Symbol.iterator]()}let o=r.next();if(!o.done)return o;r=void 0}}return{next:n}}});var G_=d(2,(e,t)=>({[Symbol.iterator](){let r=e[Symbol.iterator](),n=0;return{next(){let o=r.next();for(;!o.done;){if(t(o.value,n++))return{done:!1,value:o.value};o=r.next()}return{done:!0,value:void 0}}}}}));var K3=d(2,(e,t)=>Object.hasOwn(e,t));var Dx=d(2,(e,t)=>{let r={...e};for(let n of J_(e))B(r,n,t(e[n],n));return r});var J_=e=>Object.keys(e);var V3=e=>d(2,(t,r)=>{for(let n of J_(t))if(!K3(r,n)||!e(t[n],r[n]))return!1;return!0});var Z_=e=>{let t=V3(e);return(r,n)=>t(r,n)&&t(n,r)};var Bx=globalThis.Array;var Q_=d(2,(e,t)=>{let r=Lo(e),n=new Bx(r);for(let o=0;o<r;o++)n[o]=t(o);return n}),DI=(e,t)=>e<=t?Q_(t-e+1,r=>e+r):[e];var Ct=e=>Bx.isArray(e)?e:Bx.from(e);var $x=d(2,(e,t)=>[...e,t]),up=d(2,(e,t)=>Ct(e).concat(Ct(t)));var Y_=Bx.isArray;var Gr=NI,bt=NI;function jx(e){let t=Number(e);return String(t)===e&&Number.isInteger(t)&&t>=0&&t<2**32-1}function G3(e,t){return!Number.isFinite(e)||e<0||e>=t.length}var X_=d(2,(e,t)=>{let r=Math.floor(t);if(G3(r,e))throw new Error(`Index out of bounds: ${r}`);return e[r]});var jf=e=>e[e.length-1];var LI=V_;var J3=(e,t)=>{let r=G(t),n=e.get(r);if(n===void 0)return e.set(r,[t]),!0;for(let o of n)if(Z(o,t))return!1;return n.push(t),!0};var Qt=()=>[],Me=e=>[e],Bo=d(2,(e,t)=>e.map(t));var Hx=d(2,(e,t)=>{let r=Ct(e),n=[];for(let o=0;o<r.length;o++)t(r[o],o)&&n.push(r[o]);return n}),BI=d(2,(e,t)=>{let r=[],n=[],o=0;for(let s of e){let i=t(s,o++);tt(i)?r.push(i.success):n.push(i.failure)}return[r,n]});var eP=vx;var qx=e=>{let t=Ct(e);if(t.length<2)return[...t];let r=new Map,n=[];for(let o of t)J3(r,o)&&n.push(o);return n};var Wx="~effect/Duration",Ua=BigInt(0),aP=BigInt(1),X3=BigInt(2),eV=BigInt(10),tP=BigInt(24),zx=BigInt(60),$I=BigInt(1e3),rP=BigInt(1e6);var jI=e=>BigInt(Math.sign(e)*Math.round(Math.abs(e))),cP=e=>jI(e*1e6),nP=e=>pn(Number.isFinite(e)?jI(e):e),oP=(e,t)=>{let r=e.indexOf(".");if(r===-1)return BigInt(e)*t;let n=e[0]==="-",o=e.slice(r+1),s=eV**BigInt(o.length),i=(BigInt(e.slice(n?1:0,r))*s+BigInt(o))*t;return tV(n?-i:i,s)},tV=(e,t)=>{let r=e<Ua?-e:e,n=r/t+(r%t*X3>=t?aP:Ua);return e<Ua?-n:n};var rV=/^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/,$e=e=>{switch(typeof e){case"number":return Zi(e);case"bigint":return $o(e);case"string":{if(e==="Infinity")return Ss;if(e==="-Infinity")return Da;let t=rV.exec(e);if(!t)break;let[r,n,o]=t;if(o==="nano"||o==="nanos")return $o(oP(n,aP));if(o==="micro"||o==="micros")return $o(oP(n,$I));let s=Number(n);switch(o){case"milli":case"millis":return Zi(s);case"second":case"seconds":return fp(s);case"minute":case"minutes":return cV(s);case"hour":case"hours":return uV(s);case"day":case"days":return fV(s);case"week":case"weeks":return lV(s)}break}case"object":{if(e===null)break;if(Wx in e)return e;if(Array.isArray(e))return e.length!==2||!e.every(Bd)?sP(e):Number.isNaN(e[0])||Number.isNaN(e[1])?Ji:e[0]===-1/0||e[1]===-1/0?Da:e[0]===1/0||e[1]===1/0?Ss:nP(e[0]*1e9+e[1]);let t=e,r=0;return t.weeks&&(r+=t.weeks*6048e5),t.days&&(r+=t.days*864e5),t.hours&&(r+=t.hours*36e5),t.minutes&&(r+=t.minutes*6e4),t.seconds&&(r+=t.seconds*1e3),t.milliseconds&&(r+=t.milliseconds),!t.microseconds&&!t.nanoseconds?pn(r):nP(r*1e6+(t.microseconds??0)*1e3+(t.nanoseconds??0))}}return sP(e)},sP=e=>{throw new Error(`Invalid Input: ${e}`)},uP=xs($e),iP={_tag:"Millis",millis:0},nV={_tag:"Infinity"},oV={_tag:"NegativeInfinity"},sV={[Wx]:Wx,[ie](){switch(this.value._tag){case"Millis":{let e=this.value.millis*1e6;return Number.isFinite(e)?G(jI(e)):zt(this.value.millis)}case"Nanos":return G(this.value.nanos);default:return qd(this.value)}},[ae](e){return Qi(e)&&mV(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"}}},[Qe](){return this.toJSON()},pipe(){return V(this,arguments)}},pn=e=>{let t=Object.create(sV);return typeof e=="number"?isNaN(e)||e===0||Object.is(e,-0)?t.value=iP:Number.isFinite(e)?Number.isInteger(e)?t.value={_tag:"Millis",millis:e}:t.value={_tag:"Nanos",nanos:cP(e)}:t.value=e>0?nV:oV:e===Ua?t.value=iP:t.value={_tag:"Nanos",nanos:e},t},Qi=e=>O(e,Wx),Wn=e=>e.value._tag!=="Infinity"&&e.value._tag!=="NegativeInfinity",Hf=e=>{switch(e.value._tag){case"Millis":return e.value.millis===0;case"Nanos":return e.value.nanos===Ua;case"Infinity":case"NegativeInfinity":return!1}},iV=e=>{switch(e.value._tag){case"Millis":return e.value.millis<0;case"Nanos":return e.value.nanos<Ua;case"NegativeInfinity":return!0;case"Infinity":return!1}};var aV=e=>{switch(e.value._tag){case"Infinity":case"NegativeInfinity":return Ss;case"Millis":return e.value.millis<0?pn(-e.value.millis):e;case"Nanos":return e.value.nanos<Ua?pn(-e.value.nanos):e}};var Ji=pn(0),Ss=pn(1/0),Da=pn(-1/0),$o=e=>pn(e);var Zi=e=>pn(e),fp=e=>pn(e*1e3),cV=e=>pn(e*6e4),uV=e=>pn(e*36e5),fV=e=>pn(e*864e5),lV=e=>pn(e*6048e5),Wt=e=>lP($e(e),{onMillis:F,onNanos:t=>Number(t)/1e6,onInfinity:()=>1/0,onNegativeInfinity:()=>-1/0}),ui=e=>lP($e(e),{onMillis:t=>t/1e3,onNanos:t=>Number(t)/1e9,onInfinity:()=>1/0,onNegativeInfinity:()=>-1/0});var Kx=e=>{let t=$e(e);switch(t.value._tag){case"Infinity":case"NegativeInfinity":throw new Error("Cannot convert infinite duration to nanos");case"Nanos":return t.value.nanos;case"Millis":return cP(t.value.millis)}},fP=xs(Kx);var lP=d(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)()}}),HI=d(3,(e,t,r)=>e.value._tag==="Infinity"||e.value._tag==="NegativeInfinity"||t.value._tag==="Infinity"||t.value._tag==="NegativeInfinity"?r.onInfinity(e,t):e.value._tag==="Millis"?t.value._tag==="Millis"?r.onMillis(e.value.millis,t.value.millis):r.onNanos(Kx(e),t.value.nanos):r.onNanos(e.value.nanos,Kx(t))),dV=ai((e,t)=>HI(e,t,{onMillis:(r,n)=>r<n?-1:r>n?1:0,onNanos:(r,n)=>r<n?-1:r>n?1:0,onInfinity:(r,n)=>r.value._tag===n.value._tag?0:r.value._tag==="Infinity"?1:r.value._tag==="NegativeInfinity"||n.value._tag==="Infinity"?-1:1}));var pV=(e,t)=>HI(e,t,{onMillis:(r,n)=>r===n,onNanos:(r,n)=>r===n,onInfinity:(r,n)=>r.value._tag===n.value._tag}),dP=vI(dV);var pP=d(2,(e,t)=>HI(e,t,{onMillis:(r,n)=>pn(r-n),onNanos:(r,n)=>pn(r-n),onInfinity:(r,n)=>{let o=r.value._tag,s=n.value._tag;return o==="Infinity"?s==="Infinity"?Ji:Ss:o==="NegativeInfinity"?s==="NegativeInfinity"?Ji:Da:s==="Infinity"?Da:Ss}}));var mV=d(2,(e,t)=>pV(e,t)),hV=e=>{if(e.value._tag==="Infinity")return{days:1/0,hours:1/0,minutes:1/0,seconds:1/0,millis:1/0,nanos:1/0};if(e.value._tag==="NegativeInfinity")return{days:-1/0,hours:-1/0,minutes:-1/0,seconds:-1/0,millis:-1/0,nanos:-1/0};let t=Kx(e),r=t<Ua,n=r?-t:t,o=n/rP,s=o/$I,i=s/zx,a=i/zx,c=a/tP,u=r?-1:1;return{days:u*Number(c),hours:u*Number(a%tP),minutes:u*Number(i%zx),seconds:u*Number(s%zx),millis:u*Number(o%$I),nanos:u*Number(n%rP)}},qI=e=>{if(e.value._tag==="Infinity")return"Infinity";if(e.value._tag==="NegativeInfinity")return"-Infinity";if(Hf(e))return"0";if(iV(e))return"-"+qI(aV(e));let t=hV(e),r=[];return t.days!==0&&r.push(`${t.days}d`),t.hours!==0&&r.push(`${t.hours}h`),t.minutes!==0&&r.push(`${t.minutes}m`),t.seconds!==0&&r.push(`${t.seconds}s`),t.millis!==0&&r.push(`${t.millis}ms`),t.nanos!==0&&r.push(`${t.nanos}ns`),r.join(" ")};var La=Ce("effect/Scheduler",{fiberCached:!0,defaultValue:()=>new fi}),mP=e=>{let t=!1;return Promise.resolve().then(()=>{t||e()}),()=>{t=!0}},xV="setImmediate"in globalThis?e=>{let t=globalThis.setImmediate(e);return()=>globalThis.clearImmediate(t)}:e=>{let t=setTimeout(e,0);return()=>clearTimeout(t)},hP=e=>{try{return xV(e)}catch{return mP(e)}},zI=class{buckets=[];scheduleTask(t,r){let n=this.buckets,o=n.length,s,i=0;for(;i<o&&!(n[i][0]>r);i++)s=n[i];s&&s[0]===r?s[1].push(t):i===o?n.push([r,[t]]):n.splice(i,0,[r,[t]])}drain(){let t=this.buckets;return this.buckets=[],t}},fi=class{executionMode;setImmediate;constructor(t="async",r){this.executionMode=t,this.setImmediate=r??(t==="sync"?mP:hP)}shouldYield(t){return t.currentOpCount>=t.cache.maxOpsBeforeYield}makeDispatcher(){return new WI(this.setImmediate)}},WI=class{tasks=new zI;running=void 0;setImmediate;constructor(t=hP){this.setImmediate=t}scheduleTask(t,r){this.tasks.scheduleTask(t,r),this.running===void 0&&(this.running=this.setImmediate(this.afterScheduled))}afterScheduled=()=>{this.running=void 0,this.runTasks()};runTasks(){let t=this.tasks.drain();for(let r=0;r<t.length;r++){let n=t[r][1];for(let o=0;o<n.length;o++)n[o]()}}flush(){for(;this.tasks.buckets.length>0;)this.running!==void 0&&(this.running(),this.running=void 0),this.runTasks()}},xP=Ce("effect/Scheduler/MaxOpsBeforeYield",{fiberCached:!0,defaultValue:()=>2048}),gP=Ce("effect/Scheduler/PreventSchedulerYield",{fiberCached:!0,defaultValue:()=>!1});var yP=class extends Ra{constructor(e){super(),e&&Ex(this,e)}};var SP=Xd,sr=Wi;var bP="~effect/encoding/EncodingError",jo=class extends sr("EncodingError"){[bP]=bP};var Gx=e=>EP(typeof e=="string"?bV.encode(e):e),KI=e=>{switch(e){case 16:return yV();case 32:return SV();default:{let t="";for(let r=e>>>3;r>0;r--)t+=gV();return t}}},ue=Uint8Array.from("0123456789abcdef",e=>e.charCodeAt(0)),ru=()=>Math.random()*4294967296>>>0,gV=()=>{let e=ru();return String.fromCharCode(ue[e>>>28],ue[e>>>24&15],ue[e>>>20&15],ue[e>>>16&15],ue[e>>>12&15],ue[e>>>8&15],ue[e>>>4&15],ue[e&15])},yV=()=>{let e=ru(),t=ru();return String.fromCharCode(ue[e>>>28],ue[e>>>24&15],ue[e>>>20&15],ue[e>>>16&15],ue[e>>>12&15],ue[e>>>8&15],ue[e>>>4&15],ue[e&15],ue[t>>>28],ue[t>>>24&15],ue[t>>>20&15],ue[t>>>16&15],ue[t>>>12&15],ue[t>>>8&15],ue[t>>>4&15],ue[t&15])},SV=()=>{let e=ru(),t=ru(),r=ru(),n=ru();return String.fromCharCode(ue[e>>>28],ue[e>>>24&15],ue[e>>>20&15],ue[e>>>16&15],ue[e>>>12&15],ue[e>>>8&15],ue[e>>>4&15],ue[e&15],ue[t>>>28],ue[t>>>24&15],ue[t>>>20&15],ue[t>>>16&15],ue[t>>>12&15],ue[t>>>8&15],ue[t>>>4&15],ue[t&15],ue[r>>>28],ue[r>>>24&15],ue[r>>>20&15],ue[r>>>16&15],ue[r>>>12&15],ue[r>>>8&15],ue[r>>>4&15],ue[r&15],ue[n>>>28],ue[n>>>24&15],ue[n>>>20&15],ue[n>>>16&15],ue[n>>>12&15],ue[n>>>8&15],ue[n>>>4&15],ue[n&15])},VI=e=>{let t=new TextEncoder().encode(e);if(t.length%2!==0)return re(new jo({module:"Hex",kind:"Decode",input:e,message:`Length must be a multiple of 2, but is ${t.length}`}));try{let r=t.length/2,n=new Uint8Array(r);for(let o=0;o<r;o++){let s=IP(t[o*2]),i=IP(t[o*2+1]);n[o]=s<<4|i}return X(n)}catch(r){return re(new jo({module:"Hex",kind:"Decode",input:e,message:r instanceof Error?r.message:"Invalid input"}))}},TP=e=>Vr(VI(e),t=>EV.decode(t)),bV=new TextEncoder,EV=new TextDecoder,IV=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0")),EP=e=>{let t="";for(let r=0;r<e.length;r++)t+=IV[e[r]];return t},IP=e=>{if(48<=e&&e<=57)return e-48;if(97<=e&&e<=102)return e-97+10;if(65<=e&&e<=70)return e-65+10;throw new TypeError("Invalid input")};var ZI="effect/Tracer/ParentSpan",li=class extends Ue()(ZI,{fiberCached:!0}){},TV=e=>e;var qf=Ce("effect/Tracer/DisablePropagation",{defaultValue:Oa}),wP=Ce("effect/Tracer/CurrentTraceLevel",{defaultValue:()=>"Info"}),vP=Ce("effect/Tracer/MinimumTraceLevel",{defaultValue:()=>"All"}),QI="effect/Tracer",YI=Ce(QI,{fiberCached:!0,defaultValue:()=>XI}),XI=TV({span:e=>new JI(e)}),JI=class{_tag="Span";sampled;name;parent;annotations;links;startTime;kind;status;_traceId=void 0;_spanId=void 0;_attributes=void 0;_events=void 0;constructor(t){this.name=t.name,this.parent=t.parent,this.annotations=t.annotations,this.links=t.links,this.startTime=t.startTime,this.kind=t.kind,this.sampled=t.sampled,this.status={_tag:"Started",startTime:t.startTime}}get traceId(){return this._traceId??=_n(this.parent)?.traceId??KI(32)}get spanId(){return this._spanId??=KI(16)}get attributes(){return this._attributes??=new Map}get events(){return this._events??=[]}end(t,r){this.status={_tag:"Ended",endTime:t,exit:r,startTime:this.status.startTime}}attribute(t,r){this.attributes.set(t,r)}event(t,r,n){this.events.push([t,r,n??{}])}addLinks(t){this.links.push(...t)}};var CP="effect/Metric/FiberRuntimeMetrics";var AP=Ce("effect/ErrorReporter/CurrentErrorReporters",{defaultValue:()=>new Set}),zf=Ce("effect/References/CurrentStackFrame",{fiberCached:!0,defaultValue:po}),Zx=Ce("effect/References/TracerEnabled",{fiberCached:!0,defaultValue:nr}),nu=Ce("effect/References/TracerTimingEnabled",{defaultValue:nr}),lp=Ce("effect/References/TracerSpanAnnotations",{defaultValue:()=>({})}),dp=Ce("effect/References/TracerSpanLinks",{defaultValue:()=>[]}),Xi=Ce("effect/References/CurrentLogAnnotations",{defaultValue:()=>({})}),eT=Ce("effect/References/CurrentLogLevel",{fiberCached:!0,defaultValue:()=>"Info"}),tT=Ce("effect/References/MinimumLogLevel",{fiberCached:!0,defaultValue:()=>"Info"}),kP=Ce("effect/References/UnhandledLogLevel",{defaultValue:()=>"Error"}),Qx=Ce("effect/References/CurrentLogSpans",{defaultValue:()=>[]});var Ho=e=>{if(e?.captureStackTrace===!1)return e;if(e?.captureStackTrace!==void 0&&typeof e.captureStackTrace!="boolean")return e;let t=Ir();if(t===0&&e?.captureStackTrace!==!0)return{...e,captureStackTrace:!1};yt(3);let r=new Error;return yt(t),{...e,captureStackTrace:CV(()=>r.stack)}},rT=e=>t=>{let r;return()=>{if(r!==void 0)return r;let n=t();if(!n)return;let o=n.split(`
11
- `);if(o[e]!==void 0)return r=o[e].trim(),r}},CV=rT(3);var Yx=class extends Rf{constructor(t,r=Jd){super("Interrupt",r,"Interrupted"),this.fiberId=t}toString(){return`Interrupt(${this.fiberId})`}toJSON(){return{_tag:"Interrupt",fiberId:this.fiberId}}[ae](t){return Yd(t)&&this.fiberId===t.fiberId&&this.annotations===t.annotations}[ie](){return he(Be(`${this._tag}:${this.fiberId}`))(xx(this.annotations))}},UP=e=>new Yx(e),$a=e=>new oi([new Yx(e)]),DP=e=>e.reasons.some(hs),LP=e=>{let t=e.reasons.find(hs);return t?X(t):re(e)},qo=e=>{for(let t=0;t<e.reasons.length;t++){let r=e.reasons[t];if(r._tag==="Fail")return X(r.error)}return re(e)};var BP=e=>e.reasons.some(Qd);var ag=e=>{let t=e.reasons.find(Qd);return t?X(t.defect):re(e)},cg=e=>e.reasons.some(Yd);var yT=e=>{let t;for(let r=0;r<e.reasons.length;r++){let n=e.reasons[r];n._tag==="Interrupt"&&(t??=new Set,n.fiberId!==void 0&&t.add(n.fiberId))}return t?X(t):re(e)},$P=e=>{let t=yT(e);return be(t)?kV:t.success},kV=new Set,ug=e=>e.reasons.length>0&&e.reasons.every(Yd);var jP=d(2,(e,t)=>{let r=!1,n=e.reasons.map(o=>hs(o)?(r=!0,new Gc(t(o.error),o.annotations)):o);return r?zi(n):e}),fg=e=>{let t;for(let r of e.reasons){if(r._tag==="Fail")return r.error;r._tag==="Die"&&(t??=r)}return t!==void 0?t.defect:e.reasons.length>0?new globalThis.Error("All fibers interrupted without error"):new globalThis.Error("Empty cause")},HP=(e,t)=>{let r=[],n=[];if(e.reasons.length===0)return r;let o=Ir();o!==0&&yt(1);try{for(let s of e.reasons){if(s._tag==="Interrupt"){n.push(s);continue}r.push(oT(s._tag==="Die"?s.defect:s.error,s.annotations,t))}if(r.length===0){let s=new Error("The fiber was interrupted by:");s.name="InterruptCause",s.stack=PV(s,n);let i=new globalThis.Error("All fibers interrupted without error",{cause:s});i.name="InterruptError",i.stack=`${i.name}: ${i.message}`,r.push(oT(i,n[0].annotations,t))}}finally{o!==0&&yt(o)}return r},oT=(e,t,r)=>{let n=typeof e,o;if(e&&n==="object"){if(o=new globalThis.Error(RV(e),{cause:e.cause?oT(e.cause):void 0}),typeof e.name=="string"&&(o.name=e.name),typeof e.stack=="string")o.stack=_V(e.stack,o,t);else{let s=`${o.name}: ${o.message}`;o.stack=t?sT(s,t):s}r?.includeCauseInStack&&(o.stack=zP(o));for(let s of Object.keys(e))s in o||(o[s]=e[s])}else{o=new globalThis.Error(e?n==="string"?e:Wc(e):`Unknown error: ${e}`);let s=`${o.name}: ${o.message}`;o.stack=t?sT(s,t):s}return o},RV=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 Wc(e)},OV=/\((.*)\)/g,_V=(e,t,r)=>{let n=`${t.name}: ${t.message}`,o=(e.startsWith(n)?e.slice(n.length):e).split(`
12
- `),s=[n];for(let i=1;i<o.length&&!/Generator\.next|~effect\/(?:Effect|Utils)/.test(o[i]);i++)s.push(o[i]);return r?sT(s.join(`
10
+ `)}return t},Nx=d(2,(e,t)=>{let r=UI(e,t.key);return r!==Fx?N(r):$_(t)?N(j_(t)):_()}),Kr=d(2,(e,t)=>e.mapUnsafe.size===0?t:t.mapUnsafe.size===0?e:L_(e,r=>t.mapUnsafe.forEach((n,o)=>r.set(o,n)))),H_=(...e)=>{let t=new Map;for(let r=0;r<e.length;r++)e[r].mapUnsafe.forEach((n,o)=>{t.set(o,n)});return qn(t)};var q_=(...e)=>t=>L_(t,r=>{for(let n=0;n<e.length;n++)r.delete(e[n].key)}),Ae=Ue;var DI=e=>e.length>0;var Bt=e=>e>0?Math.floor(e):0,Lo=e=>Math.max(1,Bt(e));var X=Mx,re=Px;var Ux=e=>{if(or(e))try{return X(e())}catch(t){return re(t)}else try{return X(e.try())}catch(t){return re(e.catch(t))}};var $f=_x,be=Ff,tt=Nf;var LI=d(2,(e,t)=>be(e)?re(t(e.failure)):e),Vr=d(2,(e,t)=>tt(e)?X(t(e.success)):e),zn=d(2,(e,{onFailure:t,onSuccess:r})=>be(e)?t(e.failure):r(e.success));var ap=d(2,(e,t)=>be(e)?t(e.failure):e.success);var H3=d(2,(e,t)=>{if(tt(e))return e.success;throw t(e.failure)}),ru=H3(F);var hr=d(2,(e,t)=>be(e)?re(e.failure):t(e.success));var z_=h_;var q3=(e,t)=>{let r=t?.length!==void 0?Lo(t.length):1/0;return{[Symbol.iterator](){let n=0;return{next(){return n<r?{value:e(n++),done:!1}:{done:!0,value:void 0}}}}}};var z3=d(2,(e,t)=>W3(q3(()=>e,{length:t}))),K_=e=>z3(e,1/0);var V_=e=>{let r=e[Symbol.iterator]().next();if(r.done)throw new Error("headUnsafe: empty iterable");return r.value};var G_=d(2,(e,t)=>{let r=0;for(let n of e){let o=t(n,r);if(px(o)){if(o)return N(n)}else if(de(o))return o;r++}return _()});var W3=e=>({[Symbol.iterator](){let t=e[Symbol.iterator](),r;function n(){for(;;){if(r===void 0){let s=t.next();if(s.done)return s;r=s.value[Symbol.iterator]()}let o=r.next();if(!o.done)return o;r=void 0}}return{next:n}}});var J_=d(2,(e,t)=>({[Symbol.iterator](){let r=e[Symbol.iterator](),n=0;return{next(){let o=r.next();for(;!o.done;){if(t(o.value,n++))return{done:!1,value:o.value};o=r.next()}return{done:!0,value:void 0}}}}}));var K3=d(2,(e,t)=>Object.hasOwn(e,t));var Dx=d(2,(e,t)=>{let r={...e};for(let n of Z_(e))B(r,n,t(e[n],n));return r});var Z_=e=>Object.keys(e);var V3=e=>d(2,(t,r)=>{for(let n of Z_(t))if(!K3(r,n)||!e(t[n],r[n]))return!1;return!0});var Q_=e=>{let t=V3(e);return(r,n)=>t(r,n)&&t(n,r)};var Bx=globalThis.Array;var Y_=d(2,(e,t)=>{let r=Lo(e),n=new Bx(r);for(let o=0;o<r;o++)n[o]=t(o);return n}),BI=(e,t)=>e<=t?Y_(t-e+1,r=>e+r):[e];var At=e=>Bx.isArray(e)?e:Bx.from(e);var $x=d(2,(e,t)=>[...e,t]),up=d(2,(e,t)=>At(e).concat(At(t)));var X_=Bx.isArray;var Gr=DI,bt=DI;function jx(e){let t=Number(e);return String(t)===e&&Number.isInteger(t)&&t>=0&&t<2**32-1}function G3(e,t){return!Number.isFinite(e)||e<0||e>=t.length}var eP=d(2,(e,t)=>{let r=Math.floor(t);if(G3(r,e))throw new Error(`Index out of bounds: ${r}`);return e[r]});var jf=e=>e[e.length-1];var $I=G_;var J3=(e,t)=>{let r=G(t),n=e.get(r);if(n===void 0)return e.set(r,[t]),!0;for(let o of n)if(Z(o,t))return!1;return n.push(t),!0};var Qt=()=>[],Me=e=>[e],Bo=d(2,(e,t)=>e.map(t));var Hx=d(2,(e,t)=>{let r=At(e),n=[];for(let o=0;o<r.length;o++)t(r[o],o)&&n.push(r[o]);return n}),jI=d(2,(e,t)=>{let r=[],n=[],o=0;for(let s of e){let i=t(s,o++);tt(i)?r.push(i.success):n.push(i.failure)}return[r,n]});var tP=vx;var qx=e=>{let t=At(e);if(t.length<2)return[...t];let r=new Map,n=[];for(let o of t)J3(r,o)&&n.push(o);return n};var Wx="~effect/Duration",Da=BigInt(0),cP=BigInt(1),X3=BigInt(2),eV=BigInt(10),rP=BigInt(24),zx=BigInt(60),HI=BigInt(1e3),nP=BigInt(1e6);var qI=e=>BigInt(Math.sign(e)*Math.round(Math.abs(e))),uP=e=>qI(e*1e6),oP=e=>pn(Number.isFinite(e)?qI(e):e),sP=(e,t)=>{let r=e.indexOf(".");if(r===-1)return BigInt(e)*t;let n=e[0]==="-",o=e.slice(r+1),s=eV**BigInt(o.length),i=(BigInt(e.slice(n?1:0,r))*s+BigInt(o))*t;return tV(n?-i:i,s)},tV=(e,t)=>{let r=e<Da?-e:e,n=r/t+(r%t*X3>=t?cP:Da);return e<Da?-n:n};var rV=/^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/,$e=e=>{switch(typeof e){case"number":return Zi(e);case"bigint":return $o(e);case"string":{if(e==="Infinity")return Ss;if(e==="-Infinity")return La;let t=rV.exec(e);if(!t)break;let[r,n,o]=t;if(o==="nano"||o==="nanos")return $o(sP(n,cP));if(o==="micro"||o==="micros")return $o(sP(n,HI));let s=Number(n);switch(o){case"milli":case"millis":return Zi(s);case"second":case"seconds":return fp(s);case"minute":case"minutes":return cV(s);case"hour":case"hours":return uV(s);case"day":case"days":return fV(s);case"week":case"weeks":return lV(s)}break}case"object":{if(e===null)break;if(Wx in e)return e;if(Array.isArray(e))return e.length!==2||!e.every(Bd)?iP(e):Number.isNaN(e[0])||Number.isNaN(e[1])?Ji:e[0]===-1/0||e[1]===-1/0?La:e[0]===1/0||e[1]===1/0?Ss:oP(e[0]*1e9+e[1]);let t=e,r=0;return t.weeks&&(r+=t.weeks*6048e5),t.days&&(r+=t.days*864e5),t.hours&&(r+=t.hours*36e5),t.minutes&&(r+=t.minutes*6e4),t.seconds&&(r+=t.seconds*1e3),t.milliseconds&&(r+=t.milliseconds),!t.microseconds&&!t.nanoseconds?pn(r):oP(r*1e6+(t.microseconds??0)*1e3+(t.nanoseconds??0))}}return iP(e)},iP=e=>{throw new Error(`Invalid Input: ${e}`)},fP=xs($e),aP={_tag:"Millis",millis:0},nV={_tag:"Infinity"},oV={_tag:"NegativeInfinity"},sV={[Wx]:Wx,[ie](){switch(this.value._tag){case"Millis":{let e=this.value.millis*1e6;return Number.isFinite(e)?G(qI(e)):zt(this.value.millis)}case"Nanos":return G(this.value.nanos);default:return qd(this.value)}},[ae](e){return Qi(e)&&mV(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"}}},[Qe](){return this.toJSON()},pipe(){return V(this,arguments)}},pn=e=>{let t=Object.create(sV);return typeof e=="number"?isNaN(e)||e===0||Object.is(e,-0)?t.value=aP:Number.isFinite(e)?Number.isInteger(e)?t.value={_tag:"Millis",millis:e}:t.value={_tag:"Nanos",nanos:uP(e)}:t.value=e>0?nV:oV:e===Da?t.value=aP:t.value={_tag:"Nanos",nanos:e},t},Qi=e=>O(e,Wx),Wn=e=>e.value._tag!=="Infinity"&&e.value._tag!=="NegativeInfinity",Hf=e=>{switch(e.value._tag){case"Millis":return e.value.millis===0;case"Nanos":return e.value.nanos===Da;case"Infinity":case"NegativeInfinity":return!1}},iV=e=>{switch(e.value._tag){case"Millis":return e.value.millis<0;case"Nanos":return e.value.nanos<Da;case"NegativeInfinity":return!0;case"Infinity":return!1}};var aV=e=>{switch(e.value._tag){case"Infinity":case"NegativeInfinity":return Ss;case"Millis":return e.value.millis<0?pn(-e.value.millis):e;case"Nanos":return e.value.nanos<Da?pn(-e.value.nanos):e}};var Ji=pn(0),Ss=pn(1/0),La=pn(-1/0),$o=e=>pn(e);var Zi=e=>pn(e),fp=e=>pn(e*1e3),cV=e=>pn(e*6e4),uV=e=>pn(e*36e5),fV=e=>pn(e*864e5),lV=e=>pn(e*6048e5),Wt=e=>dP($e(e),{onMillis:F,onNanos:t=>Number(t)/1e6,onInfinity:()=>1/0,onNegativeInfinity:()=>-1/0}),ui=e=>dP($e(e),{onMillis:t=>t/1e3,onNanos:t=>Number(t)/1e9,onInfinity:()=>1/0,onNegativeInfinity:()=>-1/0});var Kx=e=>{let t=$e(e);switch(t.value._tag){case"Infinity":case"NegativeInfinity":throw new Error("Cannot convert infinite duration to nanos");case"Nanos":return t.value.nanos;case"Millis":return uP(t.value.millis)}},lP=xs(Kx);var dP=d(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)()}}),zI=d(3,(e,t,r)=>e.value._tag==="Infinity"||e.value._tag==="NegativeInfinity"||t.value._tag==="Infinity"||t.value._tag==="NegativeInfinity"?r.onInfinity(e,t):e.value._tag==="Millis"?t.value._tag==="Millis"?r.onMillis(e.value.millis,t.value.millis):r.onNanos(Kx(e),t.value.nanos):r.onNanos(e.value.nanos,Kx(t))),dV=ai((e,t)=>zI(e,t,{onMillis:(r,n)=>r<n?-1:r>n?1:0,onNanos:(r,n)=>r<n?-1:r>n?1:0,onInfinity:(r,n)=>r.value._tag===n.value._tag?0:r.value._tag==="Infinity"?1:r.value._tag==="NegativeInfinity"||n.value._tag==="Infinity"?-1:1}));var pV=(e,t)=>zI(e,t,{onMillis:(r,n)=>r===n,onNanos:(r,n)=>r===n,onInfinity:(r,n)=>r.value._tag===n.value._tag}),pP=CI(dV);var mP=d(2,(e,t)=>zI(e,t,{onMillis:(r,n)=>pn(r-n),onNanos:(r,n)=>pn(r-n),onInfinity:(r,n)=>{let o=r.value._tag,s=n.value._tag;return o==="Infinity"?s==="Infinity"?Ji:Ss:o==="NegativeInfinity"?s==="NegativeInfinity"?Ji:La:s==="Infinity"?La:Ss}}));var mV=d(2,(e,t)=>pV(e,t)),hV=e=>{if(e.value._tag==="Infinity")return{days:1/0,hours:1/0,minutes:1/0,seconds:1/0,millis:1/0,nanos:1/0};if(e.value._tag==="NegativeInfinity")return{days:-1/0,hours:-1/0,minutes:-1/0,seconds:-1/0,millis:-1/0,nanos:-1/0};let t=Kx(e),r=t<Da,n=r?-t:t,o=n/nP,s=o/HI,i=s/zx,a=i/zx,c=a/rP,u=r?-1:1;return{days:u*Number(c),hours:u*Number(a%rP),minutes:u*Number(i%zx),seconds:u*Number(s%zx),millis:u*Number(o%HI),nanos:u*Number(n%nP)}},WI=e=>{if(e.value._tag==="Infinity")return"Infinity";if(e.value._tag==="NegativeInfinity")return"-Infinity";if(Hf(e))return"0";if(iV(e))return"-"+WI(aV(e));let t=hV(e),r=[];return t.days!==0&&r.push(`${t.days}d`),t.hours!==0&&r.push(`${t.hours}h`),t.minutes!==0&&r.push(`${t.minutes}m`),t.seconds!==0&&r.push(`${t.seconds}s`),t.millis!==0&&r.push(`${t.millis}ms`),t.nanos!==0&&r.push(`${t.nanos}ns`),r.join(" ")};var Ba=Ae("effect/Scheduler",{fiberCached:!0,defaultValue:()=>new fi}),hP=e=>{let t=!1;return Promise.resolve().then(()=>{t||e()}),()=>{t=!0}},xV="setImmediate"in globalThis?e=>{let t=globalThis.setImmediate(e);return()=>globalThis.clearImmediate(t)}:e=>{let t=setTimeout(e,0);return()=>clearTimeout(t)},xP=e=>{try{return xV(e)}catch{return hP(e)}},KI=class{buckets=[];scheduleTask(t,r){let n=this.buckets,o=n.length,s,i=0;for(;i<o&&!(n[i][0]>r);i++)s=n[i];s&&s[0]===r?s[1].push(t):i===o?n.push([r,[t]]):n.splice(i,0,[r,[t]])}drain(){let t=this.buckets;return this.buckets=[],t}},fi=class{executionMode;setImmediate;constructor(t="async",r){this.executionMode=t,this.setImmediate=r??(t==="sync"?hP:xP)}shouldYield(t){return t.currentOpCount>=t.cache.maxOpsBeforeYield}makeDispatcher(){return new VI(this.setImmediate)}},VI=class{tasks=new KI;running=void 0;setImmediate;constructor(t=xP){this.setImmediate=t}scheduleTask(t,r){this.tasks.scheduleTask(t,r),this.running===void 0&&(this.running=this.setImmediate(this.afterScheduled))}afterScheduled=()=>{this.running=void 0,this.runTasks()};runTasks(){let t=this.tasks.drain();for(let r=0;r<t.length;r++){let n=t[r][1];for(let o=0;o<n.length;o++)n[o]()}}flush(){for(;this.tasks.buckets.length>0;)this.running!==void 0&&(this.running(),this.running=void 0),this.runTasks()}},gP=Ae("effect/Scheduler/MaxOpsBeforeYield",{fiberCached:!0,defaultValue:()=>2048}),yP=Ae("effect/Scheduler/PreventSchedulerYield",{fiberCached:!0,defaultValue:()=>!1});var SP=class extends Oa{constructor(e){super(),e&&Ex(this,e)}};var bP=Xd,sr=Wi;var EP="~effect/encoding/EncodingError",jo=class extends sr("EncodingError"){[EP]=EP};var Gx=e=>IP(typeof e=="string"?bV.encode(e):e),GI=e=>{switch(e){case 16:return yV();case 32:return SV();default:{let t="";for(let r=e>>>3;r>0;r--)t+=gV();return t}}},ue=Uint8Array.from("0123456789abcdef",e=>e.charCodeAt(0)),nu=()=>Math.random()*4294967296>>>0,gV=()=>{let e=nu();return String.fromCharCode(ue[e>>>28],ue[e>>>24&15],ue[e>>>20&15],ue[e>>>16&15],ue[e>>>12&15],ue[e>>>8&15],ue[e>>>4&15],ue[e&15])},yV=()=>{let e=nu(),t=nu();return String.fromCharCode(ue[e>>>28],ue[e>>>24&15],ue[e>>>20&15],ue[e>>>16&15],ue[e>>>12&15],ue[e>>>8&15],ue[e>>>4&15],ue[e&15],ue[t>>>28],ue[t>>>24&15],ue[t>>>20&15],ue[t>>>16&15],ue[t>>>12&15],ue[t>>>8&15],ue[t>>>4&15],ue[t&15])},SV=()=>{let e=nu(),t=nu(),r=nu(),n=nu();return String.fromCharCode(ue[e>>>28],ue[e>>>24&15],ue[e>>>20&15],ue[e>>>16&15],ue[e>>>12&15],ue[e>>>8&15],ue[e>>>4&15],ue[e&15],ue[t>>>28],ue[t>>>24&15],ue[t>>>20&15],ue[t>>>16&15],ue[t>>>12&15],ue[t>>>8&15],ue[t>>>4&15],ue[t&15],ue[r>>>28],ue[r>>>24&15],ue[r>>>20&15],ue[r>>>16&15],ue[r>>>12&15],ue[r>>>8&15],ue[r>>>4&15],ue[r&15],ue[n>>>28],ue[n>>>24&15],ue[n>>>20&15],ue[n>>>16&15],ue[n>>>12&15],ue[n>>>8&15],ue[n>>>4&15],ue[n&15])},JI=e=>{let t=new TextEncoder().encode(e);if(t.length%2!==0)return re(new jo({module:"Hex",kind:"Decode",input:e,message:`Length must be a multiple of 2, but is ${t.length}`}));try{let r=t.length/2,n=new Uint8Array(r);for(let o=0;o<r;o++){let s=TP(t[o*2]),i=TP(t[o*2+1]);n[o]=s<<4|i}return X(n)}catch(r){return re(new jo({module:"Hex",kind:"Decode",input:e,message:r instanceof Error?r.message:"Invalid input"}))}},wP=e=>Vr(JI(e),t=>EV.decode(t)),bV=new TextEncoder,EV=new TextDecoder,IV=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0")),IP=e=>{let t="";for(let r=0;r<e.length;r++)t+=IV[e[r]];return t},TP=e=>{if(48<=e&&e<=57)return e-48;if(97<=e&&e<=102)return e-97+10;if(65<=e&&e<=70)return e-65+10;throw new TypeError("Invalid input")};var YI="effect/Tracer/ParentSpan",li=class extends Ue()(YI,{fiberCached:!0}){},TV=e=>e;var qf=Ae("effect/Tracer/DisablePropagation",{defaultValue:_a}),vP=Ae("effect/Tracer/CurrentTraceLevel",{defaultValue:()=>"Info"}),AP=Ae("effect/Tracer/MinimumTraceLevel",{defaultValue:()=>"All"}),XI="effect/Tracer",eT=Ae(XI,{fiberCached:!0,defaultValue:()=>tT}),tT=TV({span:e=>new QI(e)}),QI=class{_tag="Span";sampled;name;parent;annotations;links;startTime;kind;status;_traceId=void 0;_spanId=void 0;_attributes=void 0;_events=void 0;constructor(t){this.name=t.name,this.parent=t.parent,this.annotations=t.annotations,this.links=t.links,this.startTime=t.startTime,this.kind=t.kind,this.sampled=t.sampled,this.status={_tag:"Started",startTime:t.startTime}}get traceId(){return this._traceId??=_n(this.parent)?.traceId??GI(32)}get spanId(){return this._spanId??=GI(16)}get attributes(){return this._attributes??=new Map}get events(){return this._events??=[]}end(t,r){this.status={_tag:"Ended",endTime:t,exit:r,startTime:this.status.startTime}}attribute(t,r){this.attributes.set(t,r)}event(t,r,n){this.events.push([t,r,n??{}])}addLinks(t){this.links.push(...t)}};var CP="effect/Metric/FiberRuntimeMetrics";var kP=Ae("effect/ErrorReporter/CurrentErrorReporters",{defaultValue:()=>new Set}),zf=Ae("effect/References/CurrentStackFrame",{fiberCached:!0,defaultValue:po}),Zx=Ae("effect/References/TracerEnabled",{fiberCached:!0,defaultValue:nr}),ou=Ae("effect/References/TracerTimingEnabled",{defaultValue:nr}),lp=Ae("effect/References/TracerSpanAnnotations",{defaultValue:()=>({})}),dp=Ae("effect/References/TracerSpanLinks",{defaultValue:()=>[]}),Xi=Ae("effect/References/CurrentLogAnnotations",{defaultValue:()=>({})}),rT=Ae("effect/References/CurrentLogLevel",{fiberCached:!0,defaultValue:()=>"Info"}),nT=Ae("effect/References/MinimumLogLevel",{fiberCached:!0,defaultValue:()=>"Info"}),RP=Ae("effect/References/UnhandledLogLevel",{defaultValue:()=>"Error"}),Qx=Ae("effect/References/CurrentLogSpans",{defaultValue:()=>[]});var Ho=e=>{if(e?.captureStackTrace===!1)return e;if(e?.captureStackTrace!==void 0&&typeof e.captureStackTrace!="boolean")return e;let t=Ir();if(t===0&&e?.captureStackTrace!==!0)return{...e,captureStackTrace:!1};yt(3);let r=new Error;return yt(t),{...e,captureStackTrace:AV(()=>r.stack)}},oT=e=>t=>{let r;return()=>{if(r!==void 0)return r;let n=t();if(!n)return;let o=n.split(`
11
+ `);if(o[e]!==void 0)return r=o[e].trim(),r}},AV=oT(3);var Yx=class extends Rf{constructor(t,r=Jd){super("Interrupt",r,"Interrupted"),this.fiberId=t}toString(){return`Interrupt(${this.fiberId})`}toJSON(){return{_tag:"Interrupt",fiberId:this.fiberId}}[ae](t){return Yd(t)&&this.fiberId===t.fiberId&&this.annotations===t.annotations}[ie](){return he(Be(`${this._tag}:${this.fiberId}`))(xx(this.annotations))}},DP=e=>new Yx(e),ja=e=>new oi([new Yx(e)]),LP=e=>e.reasons.some(hs),BP=e=>{let t=e.reasons.find(hs);return t?X(t):re(e)},qo=e=>{for(let t=0;t<e.reasons.length;t++){let r=e.reasons[t];if(r._tag==="Fail")return X(r.error)}return re(e)};var $P=e=>e.reasons.some(Qd);var ag=e=>{let t=e.reasons.find(Qd);return t?X(t.defect):re(e)},cg=e=>e.reasons.some(Yd);var bT=e=>{let t;for(let r=0;r<e.reasons.length;r++){let n=e.reasons[r];n._tag==="Interrupt"&&(t??=new Set,n.fiberId!==void 0&&t.add(n.fiberId))}return t?X(t):re(e)},jP=e=>{let t=bT(e);return be(t)?kV:t.success},kV=new Set,ug=e=>e.reasons.length>0&&e.reasons.every(Yd);var HP=d(2,(e,t)=>{let r=!1,n=e.reasons.map(o=>hs(o)?(r=!0,new Jc(t(o.error),o.annotations)):o);return r?zi(n):e}),fg=e=>{let t;for(let r of e.reasons){if(r._tag==="Fail")return r.error;r._tag==="Die"&&(t??=r)}return t!==void 0?t.defect:e.reasons.length>0?new globalThis.Error("All fibers interrupted without error"):new globalThis.Error("Empty cause")},qP=(e,t)=>{let r=[],n=[];if(e.reasons.length===0)return r;let o=Ir();o!==0&&yt(1);try{for(let s of e.reasons){if(s._tag==="Interrupt"){n.push(s);continue}r.push(iT(s._tag==="Die"?s.defect:s.error,s.annotations,t))}if(r.length===0){let s=new Error("The fiber was interrupted by:");s.name="InterruptCause",s.stack=PV(s,n);let i=new globalThis.Error("All fibers interrupted without error",{cause:s});i.name="InterruptError",i.stack=`${i.name}: ${i.message}`,r.push(iT(i,n[0].annotations,t))}}finally{o!==0&&yt(o)}return r},iT=(e,t,r)=>{let n=typeof e,o;if(e&&n==="object"){if(o=new globalThis.Error(RV(e),{cause:e.cause?iT(e.cause):void 0}),typeof e.name=="string"&&(o.name=e.name),typeof e.stack=="string")o.stack=_V(e.stack,o,t);else{let s=`${o.name}: ${o.message}`;o.stack=t?aT(s,t):s}r?.includeCauseInStack&&(o.stack=WP(o));for(let s of Object.keys(e))s in o||(o[s]=e[s])}else{o=new globalThis.Error(e?n==="string"?e:Kc(e):`Unknown error: ${e}`);let s=`${o.name}: ${o.message}`;o.stack=t?aT(s,t):s}return o},RV=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 Kc(e)},OV=/\((.*)\)/g,_V=(e,t,r)=>{let n=`${t.name}: ${t.message}`,o=(e.startsWith(n)?e.slice(n.length):e).split(`
12
+ `),s=[n];for(let i=1;i<o.length&&!/Generator\.next|~effect\/(?:Effect|Utils)/.test(o[i]);i++)s.push(o[i]);return r?aT(s.join(`
13
13
  `),r):s.join(`
14
- `)},sT=(e,t)=>{let r=t?.get(wx.key);return r&&(e=`${e}
15
- ${qP(r)}`),e},PV=(e,t)=>{let r=[`${e.name}: ${e.message}`];for(let n of t){let o=n.fiberId!==void 0?`#${n.fiberId}`:"unknown",s=n.annotations.get(yI.key);r.push(` at fiber (${o})`),s&&r.push(qP(s))}return r.join(`
16
- `)},qP=e=>{let t=[],r=e,n=0;for(;r&&n<10;){let o=r.stack();if(o){let s=o.matchAll(OV),i=!1;for(let[,a]of s)i=!0,t.push(` at ${r.name} (${a})`);i||t.push(` at ${r.name} (${o.replace(/^at /,"")})`)}else t.push(` at ${r.name}`);r=r.parent,n++}return t.join(`
17
- `)},lg=e=>HP(e).map(zP).join(`
18
- `),zP=e=>e.cause?`${e.stack} {
19
- ${WP(e.cause," ")}
20
- }`:e.stack,WP=(e,t)=>{let r=e.stack.split(`
14
+ `)},aT=(e,t)=>{let r=t?.get(wx.key);return r&&(e=`${e}
15
+ ${zP(r)}`),e},PV=(e,t)=>{let r=[`${e.name}: ${e.message}`];for(let n of t){let o=n.fiberId!==void 0?`#${n.fiberId}`:"unknown",s=n.annotations.get(bI.key);r.push(` at fiber (${o})`),s&&r.push(zP(s))}return r.join(`
16
+ `)},zP=e=>{let t=[],r=e,n=0;for(;r&&n<10;){let o=r.stack();if(o){let s=o.matchAll(OV),i=!1;for(let[,a]of s)i=!0,t.push(` at ${r.name} (${a})`);i||t.push(` at ${r.name} (${o.replace(/^at /,"")})`)}else t.push(` at ${r.name}`);r=r.parent,n++}return t.join(`
17
+ `)},lg=e=>qP(e).map(WP).join(`
18
+ `),WP=e=>e.cause?`${e.stack} {
19
+ ${KP(e.cause," ")}
20
+ }`:e.stack,KP=(e,t)=>{let r=e.stack.split(`
21
21
  `),n=`${t}[cause]: ${r[0]}`;for(let o=1,s=r.length;o<s;o++)n+=`
22
22
  ${t}${r[o]}`;return e.cause&&(n+=` {
23
- ${WP(e.cause,`${t} `)}
24
- ${t}}`),n},ST="~effect/Fiber",MV={_A:F,_E:F},FV={id:0},RP=(()=>{try{return globalThis.process?.getBuiltinModule?.("node:async_hooks")?.AsyncResource}catch{return}})(),KP=()=>RP===void 0?void 0:new RP("effect/Fiber"),ea=()=>globalThis[kf],pp=class{constructor(t,r=!0){this.setContext(t),this.id=++FV.id,this.currentOpCount=0,this.interruptible=r,this._stack=[],this._observers=void 0,this._exit=void 0,this._children=void 0,this._interruptedCause=void 0,this._yielded=void 0,this._running=!1,this._deferredInterrupt=!1,this._parent=void 0,this._asyncContext=void 0,this.cache.runtimeMetrics?.recordFiberStart(this.context)}get[ST](){return MV}get currentDispatcher(){return this._dispatcher??=this.cache.scheduler.makeDispatcher()}getRef(t){return Re(this.context,t)}addObserver(t){return this._exit?(t(this._exit),Rr):(this._observers===void 0?this._observers=[t]:this._observers.push(t),()=>this.removeObserver(t))}removeObserver(t){if(this._exit||this._observers===void 0)return;let r=this._observers.indexOf(t);r>=0&&this._observers.splice(r,1)}interruptUnsafe(t,r){if(this._exit)return;let n=$a(t);this.cache.stackFrame&&(n=Zd(n,ys(wx,this.cache.stackFrame))),r&&(n=Zd(n,r)),this._interruptedCause=this._interruptedCause?Pf(this._interruptedCause,n):n,this.interruptible&&(this._running?this._deferredInterrupt=!0:this.evaluate(Ye(this._interruptedCause)))}pollUnsafe(){return this._exit}evaluate(t){if(this._exit)return;if(this._asyncContext!==void 0){let o=this._asyncContext;return this._asyncContext=void 0,o.runInAsyncScope(this.evaluate,this,t)}else if(this._yielded!==void 0){let o=this._yielded;this._yielded=void 0,o()}let r=this.runLoop(t);if(r===Jc){this._asyncContext=KP();return}let n=iT.interruptChildren&&iT.interruptChildren(this);if(n!==void 0)return this.evaluate(Y(n,()=>r));if(this._exit=r,this.cache.runtimeMetrics?.recordFiberEnd(this.context,this._exit),this._parent&&(this._parent._children?.delete(this),this._parent=void 0),this._observers!==void 0){let o=this._observers;this._observers=void 0;for(let s=0;s<o.length;s++)o[s](r)}this._stack.length=0,this._children=void 0,this.context=pt()}runLoop(t){let r=globalThis[kf];globalThis[kf]=this;let n=this._running;this._running=!0;let o=!1,s=t;this.currentOpCount=0;try{for(;;)try{this._deferredInterrupt&&(this._deferredInterrupt=!1,s=Ye(this._interruptedCause)),this.currentOpCount++;let i=this.cache;if(!o&&!i.preventYield&&i.scheduler.shouldYield(this)){o=!0;let a=s;s=Y(Gf,()=>a)}if(s=i.tracerContext?i.tracerContext(s,this):s[St](this),s===Jc){let a=this._yielded;if(Kc in a)return this._deferredInterrupt=!1,this._yielded=void 0,a;if(this._deferredInterrupt){this._yielded=void 0,a();continue}return Jc}}catch(i){if(!O(s,St))return ln(`Fiber.runLoop: Not a valid effect: ${String(s)}`);s=ln(i)}}finally{this._running=n,globalThis[kf]=r}}getCont(t){if(this._deferredInterrupt)return this._deferredInterrupt=!1,UV;for(;;){let r=this._stack.pop();if(!r)return;let n=r[Vc];if(n!==void 0){let o=n.call(r,this);if(o)return o[t]=o,o}if(r[t])return r}}succeedWith(t){if((++this.currentOpCount&DV-1)===0)return ze(t);let r=this.getCont(mr);return r?r[mr](t,this):this.yieldWith(ze(t))}yieldWith(t){return this._yielded=t,Jc}children(){return this._children??=new Set}pipe(){return V(this,arguments)}setContext(t){let r=this.context;if(this.context=t,r!==void 0&&L_(r,t))return;let n=t.cacheRoot,o=n._fiberCache??=NV(t);this.cache?.scheduler!==o.scheduler&&(this._dispatcher=void 0),this.cache=o}get currentSpanLocal(){let t=this.cache.span;return t?._tag==="Span"?t:void 0}},NV=e=>{let t=Gi(e,QI);return{scheduler:Re(e,La),tracer:t,tracerContext:t?t.context:void 0,tracerEnabled:Re(e,Zx),span:Gi(e,ZI),logLevel:Re(e,eT),minimumLogLevel:Re(e,tT),stackFrame:Re(e,zf),runtimeMetrics:Gi(e,CP),maxOpsBeforeYield:Re(e,xP),preventYield:Re(e,gP)}},UV={[mr](e,t){return Ye(t._interruptedCause)},[go](e,t){return Ye(t._interruptedCause)}},DV=32,iT={interruptChildren:void 0},dg=e=>{if(!e.cache.stackFrame)return;let t=new Map;return t.set(yI.key,e.cache.stackFrame),qn(t)},LV=e=>{if(!(e._children===void 0||e._children.size===0))return Wf(e._children)},bT=e=>{let t=e;return t._exit?q(t._exit):$t(r=>t._exit?r(q(t._exit)):ye(e.addObserver(n=>r(q(n)))))},pg=e=>$t(t=>{let r=e[Symbol.iterator](),n=[],o;function s(){let i=r.next();for(;!i.done;){if(i.value._exit){n.push(i.value._exit),i=r.next();continue}o=i.value.addObserver(a=>{n.push(a),s()});return}t(q(n))}return s(),ye(()=>o?.())}),Xx=e=>{let t=e;return t._exit?t._exit:$t(r=>t._exit?r(t._exit):ye(e.addObserver(r)))},VP=e=>$t(t=>{let r=Array.from(e);if(r.length===0)return t(q(Qt()));let n=new Array(r.length),o=Qt(),s=()=>{for(let c=0;c<o.length;c++)r[c].removeObserver(o[c])},i=0,a=!1;for(let c=0;c<r.length&&!a;c++){let u=f=>{if(i++,f._tag==="Failure")return a=!0,s(),t(f);n[c]=f.value,i===r.length&&t(q(n))};o.push(u),r[c].addObserver(u)}return ye(()=>{a=!0,s()})}),xp=e=>oe(t=>GP(e,t.id)),GP=d(e=>O(e[0],ST),(e,t,r)=>oe(n=>{let o=dg(n);return o=o&&r?Kr(o,r):o??r,e.interruptUnsafe(t,o),yp(bT(e))})),Wf=e=>oe(t=>{let r=dg(t),n=Qt();for(let o of e)o.interruptUnsafe(t.id,r),n.push(o);return yp(pg(n))});var q=ze,Ye=Pr,Et=So,ye=Uo({op:"Sync",[St](e){let t=this[Se](),r=e.getCont(mr);return r?r[mr](t,e):e.yieldWith(ze(t))}}),ce=Uo({op:"Suspend",[St](e){return this[Se]()}}),ET=d(e=>e.length>=2||ci(e[0]),(e,t)=>fe(e)?Et(t?t():new ms("Effect.fromOption: Option.none")):q(e.value)),Vf=zn({onFailure:Et,onSuccess:q}),JP=e=>e==null?Et(new ms):q(e),IT=Uo({op:"Yield",[St](e){let t=!1;return e.currentDispatcher.scheduleTask(()=>{t||e.evaluate(hn)},this[Se]??0),e.yieldWith(()=>{t=!0})}}),Gf=IT(0),TT=e=>q(N(e)),iu=q(_()),ZP=e=>fe(e)?iu:_e(e.value,N),QP=e=>ce(()=>Ye(e())),ta=e=>ln(e),mg=e=>ce(()=>Et(e())),pe=q(void 0);var YP=e=>{let t=typeof e=="function"?e:e.try,r=typeof e=="function"?n=>new hp(n,"An error occurred in Effect.try"):e.catch;return ce(()=>{try{return q(t())}catch(n){return Et(r(n))}})};var wT=e=>vT(function(t,r){e(r).then(n=>t(q(n)),n=>t(ta(n)))},e.length!==0),XP=e=>{let t=typeof e=="function"?e:e.try,r=typeof e=="function"?n=>new hp(n,"An error occurred in Effect.tryPromise"):e.catch;return vT(function(n,o){let s=i=>ce(()=>{try{return Et(Pa(()=>r(i)))}catch(a){return ta(a)}});try{t(o).then(i=>n(q(i)),i=>n(s(i)))}catch(i){n(s(i))}},t.length!==0)},eM=e=>oe(t=>e(t.id)),tM=oe(q),rM=eM(q),vT=(function(){let e=yo({op:"Async",[St](r){let n=!1,o=!1,s=this.withSignal?new AbortController:void 0,i=this.register.call(r.cache.scheduler,a=>{n||(n=!0,o?r.evaluate(a):o=a)},s?.signal);return o!==!1?o:(o=!0,r._yielded=()=>{n=!0},s===void 0&&i===void 0?Jc:(r._stack.push(BV(()=>(n=!0,s?.abort(),i??hn))),Jc))}}),t=function(r,n){this.register=r,this.withSignal=n};return t.prototype=e,function(r,n){return new t(r,n)}})(),BV=Uo({op:"AsyncFinalizer",[Vc](e){e.interruptible&&(e.interruptible=!1,e._stack.push(wp))},[go](e,t){return cg(e)?Y(rF(Pr(e),this[Se]()),()=>Ye(e)):Ye(e)}}),$t=e=>vT(e,e.length>=2),gp=$t(Rr),nM=(...e)=>{if(e.length===1){let n=e[0];return ce(()=>su(n()))}let[t,r]=e;return ce(()=>su(r.call(t.self)))},CT=(e,...t)=>{let r=t.length===0?function(){return ce(()=>su(e.apply(this,arguments)))}:function(){let n=ce(()=>su(e.apply(this,arguments)));for(let o=0;o<t.length;o++)n=t[o](n,...arguments);return n};return AT(e.length,r)},AT=(e,t)=>Object.defineProperty(t,"length",{value:e,configurable:!0}),OP=rT(2),oM=function(){let e=typeof arguments[0]=="string",t=e?arguments[0]:"Effect.fn",r=e?arguments[1]:void 0,n=Ir(),o;return n!==0&&(yt(2),o=new globalThis.Error,yt(n)),e?(s,...i)=>_P(t,s,o,i,e,r):_P(t,arguments[0],o,Array.prototype.slice.call(arguments,1),e,r)},_P=(e,t,r,n,o,s)=>{let i=typeof t=="function"?t:n.shift().bind(t.self),a=`${e} (definition)`,c=r?OP(()=>r.stack):po;return AT(i.length,function(...u){let f=ce(()=>{let h=i.apply(this,arguments);return ge(h)?h:su(h)});for(let h=0;h<n.length;h++)f=n[h](f,...u);if(!ge(f))return f;let p=Ir(),m;return p!==0&&(yt(2),m=new globalThis.Error,yt(p)),na(o?mp(e,s,h=>lT(f,h)):f,zf,h=>({name:e,stack:m?OP(()=>m.stack):po,parent:{name:a,stack:c,parent:h}}))})},sM=(e,...t)=>AT(e.length,t.length===0?function(){return PP(()=>e.apply(this,arguments))}:function(){let r=PP(()=>e.apply(this,arguments));for(let n of t)r=n(r,...arguments);return r}),PP=e=>{try{let t=e(),r;for(;;){let n=t.next(r);if(n.done)return q(n.value);let o=n.value;if(o&&o._tag==="Success"){r=o.value;continue}else{if(o&&o._tag==="Failure")return n.value;{let s=!0;return ce(()=>s?(s=!1,Y(n.value,i=>su(t,i))):ce(()=>su(e())))}}}}catch(t){return ta(t)}},su=(function(){let e=yo({op:"Iterator",[mr](r,n){let o=this.iterator;for(;;){let s=o.next(r);if(s.done)return q(s.value);if(Xe(s.value)){if(s.value._tag==="Failure")return s.value}else return n._stack.push(this),s.value;r=s.value.value}},[St](r){return this[mr](this.initial,r)}}),t=function(r,n){this.iterator=r,this.initial=n};return t.prototype=e,function(r,n){return new t(r,n)}})(),Zr=d(2,(e,t)=>new ra(e,kT,q(t))),hg=function(e){return e._stack.push(this),this[Se]},$V=yo({op:"OnSuccess",[St]:hg}),ra=function(e,t,r){this[Se]=e,this[mr]=t,this.payload=r};ra.prototype=$V;var kT=function(){return this.payload},iM=function(e,t){return t.succeedWith(this.payload)},xg=(()=>{let e=Ir();if(e===0)return!1;let t="~effect/Effect/stackProbe",r={[t]:function(){return new Error}};yt(1);let n=r[t]();return yt(e),n.stack?.includes("[as "+t+"]")===!0})(),jV=function(e,t){let r=this.payload;return t.succeedWith(xg?r(e):Pa(()=>r(e)))},aM=function(e){let t=this.payload;return t(e)},HV=function(e){let t=this.payload;return new ra(t(e),iM,e)},qV=function(e){return new ra(this.payload,iM,e)},Jf=e=>_e(e,N),cM=e=>Xf(e,{onFailure:q,onSuccess:Et}),bo=d(2,(e,t)=>new ra(e,ge(t)?kT:aM,t)),pi=d(2,(e,t)=>new ra(e,ge(t)?qV:HV,t)),yp=e=>new ra(e,kT,hn),uM=e=>Mn(e,Et),RT=(e,t)=>oe(r=>{let n=new Set;return Wa(r,()=>n.size===0?void 0:Wf(n)),$t(o=>{let s=Ct(e),i=s.length,a=0,c=!1,u=[],f=(p,m,h)=>{if(a++,p._tag==="Failure"){u.push(...p.cause.reasons),a>=i&&o(Ye(zi(u)));return}let x=!c;c=!0,o(p),x&&t?.onWinner&&t.onWinner({fiber:m,index:h,parentFiber:r})};for(let p=0;p<i;p++){let m=cu(r,s[p],!0,!0,!1);if(n.add(m),m.addObserver(h=>{n.delete(m),f(h,m,p)}),c)break}})}),OT=(e,t)=>oe(r=>{let n=new Set;return Wa(r,()=>n.size===0?void 0:Wf(n)),$t(o=>{let s=!1,i=0;for(let a of e){if(s)break;let c=i++,u=cu(r,a,!0,!0,!1);n.add(u),u.addObserver(f=>{n.delete(u);let p=!s;s=!0,o(f),p&&t?.onWinner&&t.onWinner({fiber:u,index:c,parentFiber:r})})}})}),fM=d(e=>ge(e[1]),(e,t,r)=>RT([e,t],r)),_T=d(e=>ge(e[1]),(e,t,r)=>OT([e,t],r)),Y=d(2,(e,t)=>new ra(e,aM,t)),lM=d(2,(e,t)=>Xe(e)?e._tag==="Success"?t.onSuccess(e.value):t.onFailure(e.cause):di(e,t)),Xe=e=>e[Kc]!==void 0,dM=d(2,(e,t)=>Xe(e)?e._tag==="Success"?t(e.value):e:Y(e,t)),pM=e=>Y(e,F),_e=d(2,(e,t)=>new ra(e,jV,t)),mM=d(2,(e,t)=>Xe(e)?bM(e,t):_e(e,t)),hM=d(2,(e,t)=>Xe(e)?EM(e,t):BT(e,t)),xM=d(2,(e,t)=>Xe(e)?IM(e,t):$T(e,t)),gM=d(2,(e,t)=>{if(Xe(e)){if(e._tag==="Success")return e;let r=qo(e.cause);return be(r)?e:t(r.success)}return Es(e,t)}),Zf=e=>Pr($a(e)),Qf=e=>e._tag==="Success";var yM=e=>e._tag==="Failure";var SM=e=>e._tag==="Failure"?X(e.cause):re(e);var PT=e=>e._tag==="Failure"&&cg(e.cause);var hn=ze(void 0),bM=d(2,(e,t)=>e._tag==="Success"?ze(t(e.value)):e),EM=d(2,(e,t)=>{if(e._tag==="Success")return e;let r=qo(e.cause);return be(r)?e:So(t(r.success))}),IM=d(2,(e,t)=>{if(e._tag==="Success")return ze(t.onSuccess(e.value));let r=qo(e.cause);return be(r)?e:So(t.onFailure(r.success))});var TM=d(2,(e,t)=>Qf(e)?t:e),wM=d(2,(e,t)=>Qf(e)?t.onSuccess(e.value):t.onFailure(e.cause));var MT=e=>{let t=[];for(let r of e)r._tag==="Failure"&&t.push(...r.cause.reasons);return t.length===0?hn:Pr(zi(t))};var vM=e=>e,CM=e=>oe(t=>q(Nx(t.context,e))),zV=e=>oe(t=>ET(Nx(t.context,e))),Yf=d(2,(e,t)=>oe(r=>{let n=r.context,o=t(n);return n===o||(r.setContext(o),Wa(r,()=>{r.setContext(n)})),e})),na=d(3,(e,t,r)=>Yf(e,n=>{let o=dn(n,t),s=r(o);return o===s?n:We(n,t,s)})),AM=(e,t,r)=>au(oe(n=>{let o=dn(n.context,e),s=t(o);return n.setContext(We(n.context,e,s)),qa(dn(n.context,Ha),i=>{let a=Nx(n.context,e);if(fe(a))return pe;let c=a.value,u;if(r?.reset===void 0){if(c!==s)return pe;u=o}else u=r.reset(o,s,c);return n.setContext(We(n.context,e,u)),pe})})),FT=()=>WV,WV=oe(e=>q(e.context)),ja=e=>oe(t=>e(t.context)),kM=d(2,(e,t)=>Yf(e,qe(t))),Eo=d(2,(e,t)=>Xe(e)?e:Yf(e,Kr(t))),Pn=function(){return arguments.length===1?d(2,(e,t)=>MP(e,arguments[0],t)):d(3,(e,t,r)=>MP(e,t,r)).apply(this,arguments)},MP=(e,t,r)=>Yf(e,We(t,r)),gg=d(3,(e,t,r)=>Y(r,n=>Pn(e,t,n))),RM=d(e=>ge(e[1]),(e,t,r)=>NT(e,t,(n,o)=>[n,o],r)),NT=d(e=>ge(e[1]),(e,t,r,n)=>n?.concurrent?_e(ol([e,t],{concurrency:2}),([o,s])=>r(o,s)):Y(e,o=>_e(t,s=>r(o,s)))),OM=d(e=>ge(e[0]),(e,t,r)=>QT(e,t,r?n=>Et(r(n)):()=>Et(new ms))),_M=d(2,(e,t)=>Y(t,r=>r?Jf(e):iu)),UT=d(2,(e,t)=>Array.from({length:t},()=>e)),PM=d(e=>ge(e[0]),(e,t,r)=>ol(UT(e,t),r)),yg=d(e=>ge(e[0]),(e,t)=>mi({while:nr,body:qe(t?.disableYield?e:Y(e,r=>Gf)),step:Rr})),Mn=d(2,(e,t)=>new MM(e,t.length!==1?r=>t(r):t)),KV=yo({op:"OnFailure",[St]:hg}),MM=function(e,t){this[Se]=e,this[go]=t};MM.prototype=KV;var DT=d(3,(e,t,r)=>Mn(e,n=>t(n)?r(n):Ye(n))),oa=d(3,(e,t,r)=>Mn(e,n=>{let o=t(n);return be(o)?Ye(o.failure):r(o.success,n)})),Es=d(2,(e,t)=>oa(e,qo,r=>t(r))),FM=e=>Xf(e,{onFailure:t=>SI(t)?iu:Et(t),onSuccess:TT}),NM=d(2,(e,t)=>oa(e,ag,t)),UM=d(2,(e,t)=>Mn(e,r=>bo(t(r),Ye(r)))),DM=d(3,(e,t,r)=>DT(e,t,n=>bo(r(n),Ye(n)))),Sg=d(3,(e,t,r)=>Mn(e,n=>{let o=t(n);return be(o)?Ye(n):bo(r(o.success,n),Ye(n))})),LT=d(2,(e,t)=>Sg(e,qo,r=>t(r))),LM=d(3,(e,t,r)=>{let n=Array.isArray(t)?o=>O(o,"_tag")&&t.includes(o._tag):Or(t);return LT(e,o=>n(o)?r(o):pe)}),BM=d(2,(e,t)=>Sg(e,ag,r=>t(r))),Sp=d(e=>ge(e[0]),(e,t,r,n)=>Mn(e,o=>{let s=qo(o);return be(s)?Ye(s.failure):t(s.success)?r(s.success):n?n(s.success):Ye(o)})),bg=d(e=>ge(e[0]),(e,t,r,n)=>Mn(e,o=>{let s=qo(o);if(be(s))return Ye(s.failure);let i=t(s.success);return be(i)?n?n(i.failure):Ye(o):r(i.success)})),Eg=d(e=>ge(e[0]),(e,t,r,n)=>{let o=Array.isArray(t)?s=>O(s,"_tag")&&t.includes(s._tag):Or(t);return Sp(e,o,r,n)}),$M=d(e=>ge(e[0]),(e,t,r)=>{let n;return bg(e,o=>(n??=Object.keys(t),O(o,"_tag")&&On(o._tag)&&n.includes(o._tag)?X(o):re(o)),o=>t[o._tag](o),r)}),jM=d(e=>ge(e[0]),(e,t,r,n,o)=>Sp(e,s=>Or(s,t)&&O(s,"reason")&&(o!==void 0||Or(s.reason,r)),s=>{let i=s.reason;return Or(i,r)?n(i,s):o?o(i,s):Et(s)})),HM=d(e=>ge(e[0]),(e,t,r,n)=>{let o;return Sp(e,s=>Or(s,t)&&O(s,"reason")&&O(s.reason,"_tag")&&On(s.reason._tag)&&(n!==void 0||(o??=Object.keys(r)).includes(s.reason._tag)),s=>{let i=s.reason;return o??=Object.keys(r),o.includes(i._tag)?r[i._tag](i,s):n?n(i,s):Et(s)})}),qM=d(2,(e,t)=>bg(e,r=>Or(r,t)&&O(r,"reason")?X(r.reason):re(r),Et)),BT=d(2,(e,t)=>Es(e,r=>mg(()=>t(r)))),$T=d(2,(e,t)=>Xf(e,{onFailure:r=>mg(()=>t.onFailure(r)),onSuccess:r=>ye(()=>t.onSuccess(r))})),Ig=e=>Es(e,ta),zM=d(2,(e,t)=>Es(e,r=>ye(()=>t(r)))),WM=e=>ce(()=>{let t=e[Symbol.iterator](),r=t.next();if(r.done)return ta(new Error("Received an empty collection of effects"));function n(o){let s=t.next();return s.done?o.value:Es(o.value,i=>n(s))}return n(r)}),jT=e=>Es(e,t=>Y(Gf,()=>jT(e))),KM=d(e=>ge(e[0]),(e,t)=>{if(!t?.log)return Xf(e,{onFailure:n=>pe,onSuccess:n=>pe});let r=Ts(t.log===!0?void 0:t.log);return di(e,{onFailure(n){let o=LP(n);return be(o)?Ye(o.failure):t.message===void 0?r(n):r(t.message,n)},onSuccess:n=>pe})}),Tg=d(e=>ge(e[0]),(e,t)=>{if(!t?.log)return di(e,{onFailure:n=>pe,onSuccess:n=>pe});let r=Ts(t.log===!0?void 0:t.log);return di(e,{onFailure:n=>t.message===void 0?r(n):r(t.message,n),onSuccess:n=>pe})}),VM=e=>wg(e,{onFailure:_,onSuccess:N}),Ba=e=>bp(e,{onFailure:re,onSuccess:X}),di=d(2,(e,t)=>new GM(e,t.onSuccess.length!==1?r=>t.onSuccess(r):t.onSuccess,t.onFailure.length!==1?r=>t.onFailure(r):t.onFailure)),VV=yo({op:"OnSuccessAndFailure",[St]:hg}),GM=function(e,t,r){this[Se]=e,this[mr]=t,this[go]=r};GM.prototype=VV;var GV=function(e,t){let r=this.payload;return t.succeedWith(xg?r.onSuccess(e):Pa(()=>r.onSuccess(e)))},JM=(e,t)=>{let r=yo({op:e,[St]:hg,[mr]:GV,[go]:t}),n=function(o,s){this[Se]=o,this.payload=s};return n.prototype=r,n},JV=JM("Match",function(e,t){let r=e.reasons.find(hs);if(r===void 0)return Ye(e);let n=this.payload;return t.succeedWith(xg?n.onFailure(r.error):Pa(()=>n.onFailure(r.error)))}),ZV=JM("MatchCause",function(e,t){let r=this.payload;return t.succeedWith(xg?r.onFailure(e):Pa(()=>r.onFailure(e)))}),HT=d(2,(e,t)=>new ZV(e,t)),Xf=d(2,(e,t)=>di(e,{onFailure:r=>{let n=r.reasons.find(hs);return n?t.onFailure(n.error):Ye(r)},onSuccess:t.onSuccess})),wg=d(2,(e,t)=>new JV(e,t)),bp=d(2,(e,t)=>{if(Xe(e)){if(e._tag==="Success")return ze(t.onSuccess(e.value));let r=qo(e.cause);return be(r)?e:ze(t.onFailure(r.success))}return wg(e,t)}),ZM=d(2,(e,t)=>Xe(e)?e._tag==="Success"?ze(t.onSuccess(e.value)):ze(t.onFailure(e.cause)):HT(e,t)),Ep=e=>Xe(e)?ze(e):QV(e),QV=Uo({op:"Exit",[St](e){return e._stack.push(this),this[Se]},[mr](e,t,r){return t.succeedWith(r??ze(e))},[go](e,t,r){return t.succeedWith(r??Pr(e))}}),QM=bp({onFailure:()=>!0,onSuccess:()=>!1}),YM=bp({onFailure:()=>!1,onSuccess:()=>!0}),XM=d(2,(e,t)=>bo(sl(t),e)),qT=d(2,(e,t)=>Y(zT(e,t.duration),r=>fe(r)?t.orElse():q(r.value))),YV=e=>new ng(`Operation timed out after '${qI(e)}'`),eF=d(2,(e,t)=>{let r=$e(t);return qT(e,{duration:r,orElse:()=>Et(YV(r))})}),zT=d(2,(e,t)=>_T(Jf(e),Zr(sl(t),_()))),tF=e=>Is(t=>{let r=t.monotonicTimeNanosUnsafe();return _e(e,n=>[$o(t.monotonicTimeNanosUnsafe()-r),n])}),aT="~effect/Scope",cT="~effect/Scope/Closeable",Ha=Ue("effect/Scope"),WT=(e,t)=>oe(r=>(rG(r),el(e,t)??pe)),el=(e,t)=>{let r=e.state;if(r._tag==="Closed"||(e.state={_tag:"Closed",exit:t},e.parent!==void 0&&tg(e.parent,e),r._tag==="Empty"))return;if(r.finalizer!==void 0)return eg(r.finalizer,t);let n=r.finalizers;return n.size===1?eg(n.values().next().value,t):XV(e,n,t)},eg=(e,t)=>{try{return e(t)}catch(r){return ln(r)}},rF=(e,t)=>Qf(e)?t:Mn(t,r=>Ye(Pf(e.cause,r))),XV=CT(function*(e,t,r){let n=[],o=[],s=Array.from(t.values()),i=ea();for(let a=s.length-1;a>=0;a--){let c=s[a];e.strategy==="sequential"?n.push(yield*Ep(eg(c,r))):o.push(cu(i,eg(c,r),!0,!0,"inherit"))}return o.length>0&&(n=yield*pg(o)),yield*MT(n)});var nF=(e,t)=>{let r=sF(t,e);return e.state._tag==="Closed"?(r.state=e.state,r):(za(e,r,n=>WT(r,n)),r)},qa=(e,t)=>ce(()=>e.state._tag==="Closed"?t(e.state.exit):(za(e,{},t),pe)),oF=(e,t)=>qa(e,qe(t)),za=(e,t,r)=>{if(e.state._tag==="Empty")e.state={_tag:"Open",finalizerKey:t,finalizer:r,finalizers:void 0};else if(e.state._tag==="Open"){let n=e.state;n.finalizer!==void 0&&(n.finalizers=new Map([[n.finalizerKey,n.finalizer]]),n.finalizerKey=void 0,n.finalizer=void 0),n.finalizers.set(t,r)}},tg=(e,t)=>{if(e.state._tag!=="Open")return;let r=e.state;r.finalizerKey===t?e.state=uT:r.finalizers!==void 0&&(r.finalizers.delete(t),r.finalizers.size===0&&(e.state=uT))},tl=e=>sF(e,void 0),sF=(e="sequential",t)=>({[cT]:cT,[aT]:aT,strategy:e,parent:t,state:uT}),uT={_tag:"Empty"};var Ip=Ha,iF=Pn(Ha),vg=e=>oe(t=>{let r=t.context,n=tl();return t.setContext(We(t.context,Ha,n)),Wa(t,o=>(t.setContext(r),el(n,o))),e});var Cg=e=>ce(()=>{let t=tl();return To(e(t),r=>ce(()=>el(t,r)??pe))}),Ag=(e,t,r)=>ja(n=>Gn(o=>Y(Ip,s=>pi(r?.interruptible?o(e):e,i=>qa(s,a=>Eo(t(i,a),n)))))),rl=e=>Y(Ip,t=>ja(r=>qa(t,n=>Eo(e(n),r)))),aF=(function(){let e=yo({op:"OnExit",[St](r){return r._stack.push(this),this.effect},[Vc](r){r.interruptible&&this.interruptible!==!0&&(r._stack.push(wp),r.interruptible=!1)},[mr](r,n,o){o??=ze(r);let s;try{s=this.onExit(o)}catch(i){s=ln(i)}return s?Y(s,i=>o):o},[go](r,n,o){o??=Pr(r);let s;try{s=this.onExit(o)}catch(i){s=ln(i)}return s?Y(rF(o,s),i=>o):o}}),t=function(r,n,o){this.effect=r,this.onExit=n,this.interruptible=o};return t.prototype=e,t})(),Io=(e,t,r)=>new aF(e,t,r),Wa=(e,t)=>{e._stack.push(new aF(void 0,t,void 0))},To=d(2,Io),cF=d(2,(e,t)=>To(e,r=>t)),KT=d(3,(e,t,r)=>To(e,n=>t(n)?r(n):pe)),VT=d(3,(e,t,r)=>To(e,n=>{let o=t(n);return be(o)?pe:r(o.success,n)})),Tp=d(2,(e,t)=>VT(e,SM,t)),uF=d(3,(e,t,r)=>KT(e,n=>n._tag!=="Failure"?!1:t(n.cause),n=>r(n.cause))),GT=d(3,(e,t,r)=>To(e,n=>{if(n._tag!=="Failure")return pe;let o=t(n.cause);return be(o)?pe:r(o.success,n.cause)})),fF=d(2,(e,t)=>GT(yT,t)(e)),lF=(e,t,r)=>Gn(n=>Y(e,o=>Io(ce(()=>n(t(o))),s=>r(o,s),!0))),dF=e=>Ag(e,t=>O(t,Symbol.asyncDispose)?wT(()=>t[Symbol.asyncDispose]()):ye(()=>t[Symbol.dispose]())),JT=d(2,(e,t)=>ye(()=>pF(e,typeof t=="function"?r=>Wt($e(t(r))):qe(Wt($e(t)))))),eG=qe(1/0),pF=(e,t)=>{let r=0,n,o,s=(i,a)=>(a.awaiters++,Wa(i,()=>{if(!(--a.awaiters>0||o!==a))return o=void 0,xp(a.fiber)}),Xx(a.fiber));return[oe(i=>{if(o!==void 0)return i===o.fiber?Xx(o.fiber):s(i,o);if(n!==void 0&&(r===1/0||i.getRef(Vn).currentTimeMillisUnsafe()<r))return n;n=void 0;let a=i.getRef(Vn),c={fiber:new pp(i.context),awaiters:0};o=c;let u=s(i,c);return c.fiber.evaluate(Io(e,f=>{if(o!==c||(o=void 0,PT(f)))return;let p=t(f);r=p===1/0?1/0:a.currentTimeMillisUnsafe()+p,n=f})),c.fiber._exit??u}),ye(()=>{n=void 0})]},mF=d(2,(e,t)=>_e(JT(e,t),r=>r[0])),hF=e=>ye(()=>pF(e,eG)[0]),nl=oe(e=>Ye($a(e.id))),au=e=>oe(t=>(t.interruptible&&(t.interruptible=!1,t._stack.push(wp)),e)),xF=Uo({op:"SetInterruptible",[Vc](e){if(e.interruptible=this[Se],e._interruptedCause&&e.interruptible)return()=>Ye(e._interruptedCause)}}),wp=xF(!0),tG=xF(!1),gF=e=>{if(e.interruptible=!0,e._stack.push(tG),e._interruptedCause)return Ye(e._interruptedCause)},rG=e=>{let t=e;t.interruptible&&(t.interruptible=!1,t._stack.push(wp))};var kg=e=>oe(t=>t.interruptible?e:gF(t)??e),Gn=e=>oe(t=>t.interruptible?(t.interruptible=!1,t._stack.push(wp),e(kg)):e(F)),yF=e=>oe(t=>{if(t.interruptible)return e(F);let r=gF(t),n=e(au);return r??n}),SF=_e(Ag(ye(()=>new AbortController),e=>ye(()=>e.abort())),e=>e.signal),ol=(e,t)=>ti(e)?t?.mode==="result"?Kn(e,Ba,t):Kn(e,F,t):t?.discard?t.mode==="result"?Kn(Object.values(e),Ba,t):Kn(Object.values(e),F,t):ce(()=>{let r={};return Zr(Kn(Object.entries(e),([n,o])=>_e(t?.mode==="result"?Ba(o):o,s=>{B(r,n,s)}),{discard:!0,concurrency:t?.concurrency}),r)}),ZT=d(e=>ti(e[0])&&!ge(e[0]),(e,t,r)=>_e(Kn(e,(n,o)=>Ba(t(n,o)),r),n=>BI(n,F))),bF=d(3,(e,t,r)=>{let n=Ct(e);return n.length===0?ye(t):ce(()=>{let o=0,s=t();return _e(mi({while:()=>o<n.length,body:()=>r(s,n[o],o),step(i){s=i,o++}}),()=>s)})}),EF=d(e=>ti(e[0])&&!ge(e[0]),(e,t,r)=>Y(ZT(e,t,{concurrency:r?.concurrency}),([n,o])=>Gr(o)?Et(o):r?.discard?pe:q(n))),IF=d(e=>ti(e[0])&&!ge(e[0]),(e,t)=>ce(()=>{let r=e[Symbol.iterator](),n=r.next();return n.done?q(_()):TF(r,0,t,n.value)})),TF=(e,t,r,n)=>Y(r(n,t),o=>{if(o)return q(N(n));let s=e.next();return s.done?q(_()):TF(e,t+1,r,s.value)}),wF=d(e=>ti(e[0])&&!ge(e[0]),(e,t)=>ce(()=>{let r=e[Symbol.iterator](),n=r.next();return n.done?q(_()):vF(r,0,t,n.value)})),vF=(e,t,r,n)=>Y(r(n,t),o=>{if(tt(o))return q(N(o.success));let s=e.next();return s.done?q(_()):vF(e,t+1,r,s.value)}),mi=Uo({op:"While",[mr](e,t){return this[Se].step(e),this[Se].while()?(t._stack.push(this),this[Se].body()):hn},[St](e){return this[Se].while()?(e._stack.push(this),this[Se].body()):hn}}),Kn=d(e=>typeof e[1]=="function",(e,t,r)=>ce(()=>{let n=vp(r?.concurrency);if(n===1)return nG(e,t,r);let o=Ct(e),s=o.length;if(s===0)return r?.discard?pe:q([]);let i=r?.discard?void 0:new Array(s),a=oG({f:t,out:i},o,{concurrency:n});return a?Zr(a,i):q(i)})),CF=e=>Y(e,t=>{let r=t[Symbol.iterator]().next();return r.done?Et(new ms):q(r.value)}),nG=(e,t,r)=>ce(()=>{let n=r?.discard?void 0:[],o=e[Symbol.iterator](),s=o.next(),i=0;return Zr(mi({while:()=>!s.done,body:()=>t(s.value,i++),step:a=>{n&&n.push(a),s=o.next()}}),n)}),vp=e=>e==="unbounded"?Number.POSITIVE_INFINITY:Math.max(1,e??1),Rg=()=>e=>{let t=e.onItem,r=e.step,n=(s,i,a,c,u)=>Y(Ep(u),f=>r(s,i[a],f,a)??o(s,i,a+1,c)??pe),o=(s,i,a=0,c=i.length)=>{for(;a<c;a++){let u=i[a],f=t(s,u,a);if(!Xe(f))return n(s,i,a,c,f);let p=r(s,u,f,a);if(p)return p._tag==="Failure"?p:void 0}};return o},AF=e=>{let t=e.onItem,r=e.step;return(n,o,s)=>{let i=0,a=s.end??o.length,c=s.concurrency,u=!1,f,p,m,h,x,g=E=>{let b=ln(E);return h=b,u=!0,p&&p.size>0?Y(au(Wf(Array.from(p))),()=>h??b):b},y=()=>{let E=!1;for(;!h&&i<a;i++){let b=o[i],v=x??t(n,b,i);if(Xe(v)){if(h=r(n,b,v,i),h)break}else if(f){x=void 0;let T=cu(f,v,!0,!0,"inherit");if(T._exit){if(h=r(n,b,T._exit,i),h)break;continue}p.add(T);let S=i;if(T.addObserver(w=>{p.delete(T);try{if(h){if(w._tag==="Failure"){let k=w.cause.reasons.filter(C=>C._tag!=="Interrupt");if(k.length>0){let C=zi(k);h=Pr(h._tag==="Failure"?Pf(h.cause,C):C)}}}else{let k=r(n,b,w,S);k&&(h=k,y())}if(E){let k=y();k&&m(k)}else u&&p.size===0&&m(h??pe)}catch(k){m(g(k))}}),p.size<c)continue;E=!0,i++;return}else return $t(T=>{f=ea(),p=new Set,x=v,m=T;let S;try{S=y()}catch(w){return T(g(w))}return S?T(S):ce(()=>(h??=hn,Y(p?Wf(p):pe,()=>h?._tag==="Failure"?h:pe)))})}if(u=!0,h){if(p&&p.size>0){let b=dg(f);p.forEach(v=>v.interruptUnsafe(f.id,b));return}if(m||h._tag==="Failure")return h}else if(m)if(p)p.size===0&&m(pe);else return hn};return y()}},Og=()=>e=>AF(e),oG=AF({onItem(e,t,r){return e.f(t,r)},step(e,t,r,n){if(r._tag==="Failure")return r;e.out&&(e.out[n]=r.value)}}),QT=d(3,(e,t,r)=>Y(e,n=>t(n)?q(n):r(n))),YT=d(3,(e,t,r)=>Y(e,n=>{let o=t(n);return be(o)?r(o.failure):q(o.success)})),kF=d(e=>ge(e[0]),(e,t,r)=>YT(e,t,r?n=>Et(r(n)):()=>Et(new ms))),RF=d(e=>ti(e[0])&&!ge(e[0]),(e,t,r)=>ce(()=>{let n=[];return Zr(Kn(e,(o,s)=>{let i=t(o,s);return typeof i=="boolean"?(i&&n.push(o),pe):_e(i,a=>{a&&n.push(o)})},{discard:!0,concurrency:r?.concurrency}),n)})),OF=d(e=>ti(e[0])&&!ge(e[0]),(e,t)=>ce(()=>{let r=[];for(let n of e){let o=t(n);tt(o)&&r.push(o.success)}return q(r)})),_F=d(e=>ti(e[0])&&!ge(e[0]),(e,t,r)=>ce(()=>{let n=[];return Zr(Kn(e,o=>_e(t(o),s=>{tt(s)&&n.push(s.success)}),{discard:!0,concurrency:r?.concurrency}),n)})),PF=q({}),MF=Ax(_e),FF=kx(_e,Y),NF=Cx(_e);var UF=d(e=>ge(e[0]),(e,t)=>oe(r=>(bG(),q(cu(r,e,t?.startImmediately,!1,t?.uninterruptible??!1))))),cu=(e,t,r=!1,n=!1,o=!1)=>{let s=e,i=o==="inherit"?s.interruptible:!o,a=new pp(s.context,i);return n||(s.children().add(a),a._parent=s),r?a.evaluate(t):(a._asyncContext=KP(),s.currentDispatcher.scheduleTask(()=>a.evaluate(t),0)),a},DF=d(e=>ge(e[0]),(e,t)=>oe(r=>q(cu(r,e,t?.startImmediately,!0,t?.uninterruptible)))),LF=e=>oe(t=>{let r=t._children&&new Set(t._children),n=t.interruptible;return Io(e,o=>{let s=t._children;if(s===void 0||s.size===0)return pe;r&&(s=G_(s,a=>!r.has(a)));let i=yp(pg(s));return n?kg(i):i})}),XT=d(e=>ge(e[0]),(e,t,r)=>oe(n=>{let o=cu(n,e,r?.startImmediately,!0,r?.uninterruptible);if(!o._exit)if(t.state._tag!=="Closed"){let s={};za(t,s,()=>eM(a=>a===o.id?pe:xp(o))),o.addObserver(()=>tg(t,s))}else o.interruptUnsafe(n.id,dg(n));return q(o)})),BF=d(e=>ge(e[0]),(e,t)=>Y(Ip,r=>XT(e,r,t))),sa=e=>(t,r)=>{let n=new pp(r?.scheduler?We(e,La,r.scheduler):e,r?.uninterruptible!==!0);if(n.evaluate(t),n._exit)return n;if(r?.signal)if(r.signal.aborted)n.interruptUnsafe();else{let o=()=>n.interruptUnsafe();r.signal.addEventListener("abort",o,{once:!0}),n.addObserver(()=>r.signal.removeEventListener("abort",o))}return r?.onFiberStart&&r.onFiberStart(n),n},$F=d(2,(e,t)=>e._exit?e:t.state._tag==="Closed"?(e.interruptUnsafe(e.id),e):(tg(t,e),za(t,e,()=>xp(e)),e.addObserver(()=>tg(t,e)),e)),jF=sa(pt()),e0=e=>{let t=sa(e);return(r,n)=>{let o=t(r,n);return n?.onExit&&o.addObserver(n.onExit),s=>o.interruptUnsafe(s)}},HF=e0(pt()),_g=e=>{let t=sa(e);return(r,n)=>{let o=t(r,n);return new Promise(s=>{o.addObserver(i=>s(i))})}},qF=_g(pt()),t0=e=>{let t=_g(e);return(r,n)=>t(r,n).then(o=>{if(o._tag==="Failure")throw fg(o.cause);return o.value})},zF=t0(pt()),Pg=e=>{let t=sa(e);return r=>{if(Xe(r))return r;let n=new fi("sync"),o=t(r,{scheduler:n});return o._dispatcher?.flush(),o._exit??ln(new ig(o))}},WF=Pg(pt()),r0=e=>{let t=Pg(e);return r=>{let n=t(r);if(n._tag==="Failure")throw fg(n.cause);return n.value}},KF=r0(pt()),FP=q(!0),NP=q(!1),fT=class{waiters=[];scheduled=void 0;_isOpen;constructor(t){this._isOpen=t}scheduleUnsafe(t){if(this.waiters.length===0)return FP;if(this.scheduled===void 0)this.scheduled=this.waiters,t.currentDispatcher.scheduleTask(this.flushScheduled,0);else for(let r=0;r<this.waiters.length;r++)this.scheduled.push(this.waiters[r]);return this.waiters=[],FP}flushScheduled=()=>{if(this.scheduled===void 0)return;let t=this.scheduled;this.scheduled=void 0;for(let r=0;r<t.length;r++)t[r](hn)};flushWaiters(){let t=this.waiters;this.waiters=[],this.flushScheduled();for(let r=0;r<t.length;r++)t[r](hn)}open=oe(t=>this._isOpen?NP:(this._isOpen=!0,this.scheduleUnsafe(t)));release=oe(t=>this._isOpen?NP:this.scheduleUnsafe(t));openUnsafe(){return this._isOpen?!1:(this._isOpen=!0,this.flushWaiters(),!0)}await=$t(t=>this._isOpen?t(pe):(this.waiters.push(t),ye(()=>{let r=this.waiters.indexOf(t);r!==-1?this.waiters.splice(r,1):this.scheduled!==void 0&&(r=this.scheduled.indexOf(t),r!==-1&&this.scheduled.splice(r,1))})));closeUnsafe(){return this._isOpen?(this._isOpen=!1,!0):!1}close=ye(()=>this.closeUnsafe());whenOpen=t=>Y(this.await,()=>t);isOpen(){return this._isOpen}},n0=e=>new fT(e??!1),VF=e=>ye(()=>n0(e)),GF=oe(e=>q(e.getRef(YI))),JF=d(2,(e,t)=>Pn(e,YI,t)),ZF=Pn(Zx),QF=Pn(nu),rg=BigInt(0),sG={_tag:"Span",spanId:"noop",traceId:"noop",sampled:!1,status:{_tag:"Ended",startTime:rg,endTime:rg,exit:hn},attributes:new Map,links:[],kind:"internal",attribute(){},event(){},end(){},addLinks(){}},iG=e=>Object.assign(Object.create(sG),e),YF=e=>e?Re(e.annotations,qf)?e._tag==="Span"?YF(_n(e.parent)):_():N(e):_(),o0=(e,t,r)=>{let n=!e.cache.tracerEnabled||r?.annotations&&Re(r.annotations,qf),o=r?.parent!==void 0?N(r.parent):r?.root?_():YF(e.cache.span),s;if(n)s=iG({name:t,parent:o,annotations:We(r?.annotations??pt(),qf,!0)});else{let i=e.cache.tracer??XI,a=e.getRef(Vn),c=e.getRef(nu),u=e.getRef(lp),f=e.getRef(dp),p=r?.level??e.getRef(wP),m=r?.links!==void 0?[...f,...r.links]:f.length===0?[]:f.slice();s=i.span({name:t,parent:o,annotations:r?.annotations??pt(),links:m,startTime:c?a.currentTimeNanosUnsafe():rg,kind:r?.kind??"internal",root:r?.root??!1,sampled:r?.sampled??(de(o)&&o.value.sampled===!1?!1:!lN(e.getRef(vP),p))});for(let h in u)s.attribute(h,u[h]);if(r?.attributes!==void 0)for(let h in r.attributes)s.attribute(h,r.attributes[h])}return s},XF=(e,t)=>oe(r=>q(o0(r,e,t))),bs=(e,t)=>au(oe(r=>{let n=dn(r.context,Ha),o=o0(r,e,t??{}),s=r.getRef(Vn),i=r.getRef(nu);return Zr(qa(n,a=>Mg(o,a,s,i)),o)})),eN=function(){let e=typeof arguments[0]!="string",t=e?arguments[1]:arguments[0],r=Ho(e?arguments[2]:arguments[1]);if(e){let n=arguments[0];return Y(bs(t,r),o=>Kf(n,o,r))}return n=>Y(bs(t,r),o=>Kf(n,o,r))},aG=(e,t)=>(t=typeof t=="function"?t:po,na(zf,r=>({name:e,stack:t,parent:r}))),tN=lp,rN=dp,nN=d(e=>ge(e[0]),(e,t,r={})=>{let o=(Array.isArray(t)?t:[t]).map(s=>({span:s,attributes:r}));return na(e,dp,s=>[...s,...o])}),Mg=(e,t,r,n)=>ye(()=>{e.status._tag!=="Ended"&&e.end(n?r.currentTimeNanosUnsafe():rg,t)}),mp=(e,...t)=>{let r=t.length===1?void 0:t[0],n=t[t.length-1];return oe(o=>{let s=o0(o,e,r),i=o.getRef(Vn),a=o.getRef(nu);return Wa(o,c=>Mg(s,c,i,a)),n(s)})},lT=Pn(li),Kf=function(){let e=ge(arguments[0]),t=e?arguments[1]:arguments[0],r=e?arguments[2]:arguments[1],n=F;return t._tag==="Span"&&(r=Ho(r),n=aG(t.name,r?.captureStackTrace)),e?lT(n(arguments[0]),t):o=>lT(n(o),t)},oN=function(){let e=typeof arguments[0]!="string",t=e?arguments[1]:arguments[0],r=Ho(arguments[2]);if(e){let s=arguments[0];return mp(t,arguments[2],i=>Kf(s,i,r))}let n=typeof arguments[1]=="function"?arguments[1]:void 0,o=n?void 0:arguments[1];return(s,...i)=>mp(t,n?n(...i):o,a=>Kf(s,a,r))},sN=d(e=>ge(e[0]),(e,...t)=>na(e,lp,r=>{let n=t.length===1?{...r,...t[0]}:{...r};return t.length===1||B(n,t[0],t[1]),n})),iN=(...e)=>oe(t=>{let r=t.currentSpanLocal;if(r)if(e.length===1)for(let[n,o]of Object.entries(e[0]))r.attribute(n,o);else r.attribute(e[0],e[1]);return pe}),aN=oe(e=>{let t=e.currentSpanLocal;return t?q(t):Et(new ms)}),cN=zV(li),Vn=Ce("effect/Clock",{defaultValue:()=>new dT}),nT=2**31-1,dT=class{currentTimeMillisUnsafe(){return Date.now()}currentTimeMillis=ye(()=>this.currentTimeMillisUnsafe());currentTimeNanosUnsafe(){return cG()}currentTimeNanos=ye(()=>this.currentTimeNanosUnsafe());monotonicTimeNanosUnsafe(){return fN()}monotonicTimeNanos=ye(()=>this.monotonicTimeNanosUnsafe());sleep(t){return this.sleepMillis(Wt(t))}sleepMillis(t){return t<=0?Gf:Number.isFinite(t)?$t(r=>{let n=t>nT?this.sleepMillis(t-nT):pe,o=setTimeout(()=>r(n),Math.min(t,nT));return ye(()=>clearTimeout(o))}):gp}},uN=BigInt(1e6),fN=(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 r=BigInt(Date.now())*uN;return r>t&&(t=r),t}})(),cG=(function(){let e=BigInt(1e9),t;return()=>{let r=fN(),n=BigInt(Date.now())*uN;if(t===void 0)t=n-r;else{let o=t+r;(n>o?n-o:o-n)>e&&(t=n-r)}return t+r}})(),Is=e=>oe(t=>e(t.getRef(Vn))),sl=e=>Is(t=>t.sleep($e(e))),s0=Is(e=>e.currentTimeMillis);var pT="~effect/Cause/TimeoutError";var ng=class extends Wi("TimeoutError"){[pT]=pT;constructor(t){super({message:t})}},mT="~effect/Cause/IllegalArgumentError";var og=class extends Wi("IllegalArgumentError"){[mT]=mT;constructor(t){super({message:t})}},hT="~effect/Cause/ExceededCapacityError";var sg=class extends Wi("ExceededCapacityError"){[hT]=hT;constructor(t){super({message:t})}},xT="~effect/Cause/AsyncFiberError";var ig=class extends Wi("AsyncFiberError"){[xT]=xT;constructor(t){super({message:"An asynchronous Effect was executed with Effect.runSync",fiber:t})}},gT="~effect/Cause/UnknownError";var hp=class extends Wi("UnknownError"){[gT]=gT;constructor(t,r){super({message:r,cause:t})}},uG=Ce("effect/Console",{defaultValue:()=>globalThis.console}),fG=e=>{switch(e){case"All":return Number.MIN_SAFE_INTEGER;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 Number.MAX_SAFE_INTEGER}},lG=wI(Ki,fG),lN=Yc(lG),i0=Ce("effect/Logger/CurrentLoggers",{defaultValue:()=>new Set([yG,SG])}),dG=Ce("effect/Logger/LogToStderr",{defaultValue:Oa}),dN=function(){let e=typeof arguments[0]=="string"?[[arguments[0],arguments[1]]]:Object.entries(arguments[0]);return au(oe(t=>{let r=t.getRef(Xi),n={...r};for(let o=0;o<e.length;o++){let[s,i]=e[o];B(n,s,i)}return t.setContext(We(t.context,Xi,n)),qa(dn(t.context,Ha),o=>{let s=t.getRef(Xi),i={...s};for(let a=0;a<e.length;a++){let[c,u]=e[a];s[c]!==u&&!Object.is(s[c],u)||(Object.hasOwn(r,c)?B(i,c,r[c]):delete i[c])}return t.setContext(We(t.context,Xi,i)),pe})}))},pG="~effect/Logger",mG={[pG]:{_Message:F,_Output:F},pipe(){return V(this,arguments)}},pN=e=>{let t=Object.create(mG);return t.log=e,t},hG=e=>e.replace(/[\s="]/g,"_"),xG=(e,t)=>`${hG(e[0])}=${t-e[1]}ms`;var Ts=e=>(...t)=>{let r;for(let n=0,o=t.length;n<o;n++){let s=t[n];_f(s)&&(r?t.splice(n,1):t=t.slice(0,n).concat(t.slice(n+1)),r=r?zi(r.reasons.concat(s.reasons)):s,n--)}return r===void 0&&(r=xI),oe(n=>{let o=e??n.cache.logLevel;if(lN(n.cache.minimumLogLevel,o))return pe;let s=n.getRef(Vn),i=n.getRef(i0);if(i.size>0){let a=new Date(s.currentTimeMillisUnsafe());for(let c of i)c.log({cause:r,fiber:n,date:a,logLevel:o,message:t})}return pe})};var ou={bold:"1",red:"31",green:"32",yellow:"33",blue:"34",cyan:"36",white:"37",gray:"90",black:"30",bgBrightRed:"101"},qle={None:[],All:[],Trace:[ou.gray],Debug:[ou.blue],Info:[ou.green],Warn:[ou.yellow],Error:[ou.red],Fatal:[ou.bgBrightRed,ou.black]};var gG=e=>`${e.getHours().toString().padStart(2,"0")}:${e.getMinutes().toString().padStart(2,"0")}:${e.getSeconds().toString().padStart(2,"0")}.${e.getMilliseconds().toString().padStart(3,"0")}`;var yG=pN(({cause:e,date:t,fiber:r,logLevel:n,message:o})=>{let s=Array.isArray(o)?o.slice():[o];e.reasons.length>0&&s.push(lg(e));let i=t.getTime(),a=r.getRef(Qx),c="";for(let m of a)c+=` ${xG(m,i)}`;let u=r.getRef(Xi);Object.keys(u).length>0&&s.push(u);let f=r.getRef(uG);(r.getRef(dG)?f.error:f.log)(`[${gG(t)}] ${n.toUpperCase()} (#${r.id})${c}:`,...s)}),SG=pN(({cause:e,fiber:t,logLevel:r,message:n})=>{let o=t.getRef(Vn),s=t.getRef(Xi),i=t.cache.span;if(i===void 0||i._tag==="ExternalSpan")return;let a={};for(let[c,u]of Object.entries(s))B(a,c,u);a["effect.fiberId"]=t.id,a["effect.logLevel"]=r.toUpperCase(),e.reasons.length>0&&(a["effect.cause"]=lg(e)),i.event(e_(Array.isArray(n)&&n.length===1?n[0]:n),o.currentTimeNanosUnsafe(),a)});function bG(){iT.interruptChildren??=LV}var Fg=q(void 0);var mN=d(e=>ge(e[0]),(e,t)=>Tp(e,r=>oe(n=>(EG(n,r,t?.defectsOnly),pe)))),EG=(e,t,r)=>{let n=e.getRef(AP);if(n.size===0||r&&!BP(t))return;let o={cause:t,fiber:e,timestamp:e.getRef(Vn).currentTimeNanosUnsafe()};n.forEach(s=>s.report(o))};var il=_f,al=n_,Ng=hs;var uu=zi;var hN=Mf,cl=gI,xN=$a,Cp=e=>new Gc(e),Ap=e=>new Vd(e),kp=UP,a0=ug,Ka=jP;var fu=fg,gN=DP;var ul=qo;var Rp=ag,fl=cg;var yN=$P;var SN=lg;var ll=ms,Op=i_;var bN=Zc,se=c_;var Ug=og;var EN=sg;var ne={};ps(ne,{Do:()=>zJ,Transaction:()=>gl,TypeId:()=>UJ,abortSignal:()=>q8,acquireDisposable:()=>N8,acquireRelease:()=>Ti,acquireUseRelease:()=>zU,addFinalizer:()=>WU,all:()=>DJ,andThen:()=>Vt,annotateCurrentSpan:()=>Y8,annotateLogs:()=>py,annotateLogsScoped:()=>IZ,annotateSpans:()=>Q8,as:()=>Pt,asSome:()=>iy,asVoid:()=>vo,awaitAllChildren:()=>cZ,bind:()=>VJ,bindTo:()=>WJ,cached:()=>ly,cachedInvalidateWithTTL:()=>j8,cachedWithTTL:()=>$8,callback:()=>Nn,catch:()=>gu,catchCause:()=>rt,catchCauseFilter:()=>LU,catchCauseIf:()=>z0,catchDefect:()=>q0,catchEager:()=>my,catchFilter:()=>a8,catchIf:()=>i8,catchNoSuchElement:()=>c8,catchReason:()=>n8,catchReasons:()=>o8,catchTag:()=>UU,catchTags:()=>DU,clockWith:()=>bu,context:()=>Nr,contextWith:()=>yn,currentParentSpan:()=>eZ,currentSpan:()=>X8,delay:()=>ca,die:()=>gn,effectify:()=>MZ,ensuring:()=>wi,eventually:()=>p8,exit:()=>eo,fail:()=>D,failCause:()=>je,failCauseSync:()=>aa,failSync:()=>sy,fiber:()=>uZ,fiberId:()=>fZ,filter:()=>G0,filterMap:()=>T8,filterMapEffect:()=>J0,filterMapOrElse:()=>w8,filterMapOrFail:()=>v8,filterOrElse:()=>jU,filterOrFail:()=>HU,findFirst:()=>jJ,findFirstFilter:()=>HJ,firstSuccessOf:()=>y8,flatMap:()=>A,flatMapEager:()=>ur,flatten:()=>j0,flip:()=>t8,fn:()=>mZ,fnUntraced:()=>me,fnUntracedEager:()=>aw,forEach:()=>Ko,forever:()=>Mt,forkChild:()=>El,forkDetach:()=>Il,forkIn:()=>gt,forkScoped:()=>Rs,fromNullishOr:()=>YJ,fromOption:()=>ZJ,fromResult:()=>$0,gen:()=>xt,head:()=>qJ,ignore:()=>cy,ignoreCause:()=>uy,interrupt:()=>Dn,interruptible:()=>vi,interruptibleMask:()=>H8,isEffect:()=>Yr,isFailure:()=>O8,isSuccess:()=>_8,let:()=>KJ,linkSpans:()=>nZ,log:()=>hZ,logDebug:()=>SZ,logError:()=>Xp,logFatal:()=>xZ,logInfo:()=>yZ,logTrace:()=>bZ,logWarning:()=>gZ,logWithLevel:()=>Tl,makeSpan:()=>tw,makeSpanScoped:()=>rw,map:()=>K,mapBoth:()=>u8,mapBothEager:()=>cr,mapEager:()=>Eu,mapError:()=>yl,mapErrorEager:()=>Iu,match:()=>Z0,matchCause:()=>A8,matchCauseEager:()=>k8,matchCauseEffect:()=>Un,matchCauseEffectEager:()=>R8,matchEager:()=>C8,matchEffect:()=>qU,never:()=>Xn,onError:()=>to,onErrorFilter:()=>D8,onErrorIf:()=>U8,onExit:()=>Xr,onExitFilter:()=>B8,onExitIf:()=>L8,onExitPrimitive:()=>Zp,onInterrupt:()=>Su,option:()=>e8,orDie:()=>Ii,orElseSucceed:()=>g8,partition:()=>LJ,promise:()=>Wp,provide:()=>Q0,provideContext:()=>Ur,provideService:()=>Jo,provideServiceEffect:()=>F8,race:()=>I8,raceAll:()=>V0,raceAllFirst:()=>E8,raceFirst:()=>Ya,reduce:()=>BJ,repeat:()=>KU,repeatOrElse:()=>z8,replicate:()=>W8,replicateEffect:()=>ew,request:()=>iZ,requestUnsafe:()=>aZ,result:()=>XJ,retry:()=>ay,retryOrElse:()=>W0,runCallback:()=>lZ,runCallbackWith:()=>nw,runFork:()=>Yp,runForkWith:()=>Sr,runPromise:()=>ow,runPromiseExit:()=>dy,runPromiseExitWith:()=>dZ,runPromiseWith:()=>sw,runSync:()=>Ai,runSyncExit:()=>ki,runSyncExitWith:()=>pZ,runSyncWith:()=>iw,sandbox:()=>m8,satisfiesErrorType:()=>NZ,satisfiesServicesType:()=>UZ,satisfiesSuccessType:()=>FZ,schedule:()=>K8,scheduleFrom:()=>VU,scope:()=>Co,scoped:()=>ec,scopedWith:()=>Sl,service:()=>Y0,serviceOption:()=>yu,setContext:()=>P8,sleep:()=>ua,spanAnnotations:()=>tZ,spanLinks:()=>rZ,succeed:()=>I,succeedNone:()=>ia,succeedSome:()=>B0,suspend:()=>L,sync:()=>W,tap:()=>_t,tapCause:()=>Jp,tapCauseFilter:()=>d8,tapCauseIf:()=>l8,tapDefect:()=>BU,tapError:()=>Gp,tapErrorTag:()=>f8,timed:()=>b8,timeout:()=>K0,timeoutOption:()=>S8,timeoutOrElse:()=>$U,tracer:()=>V8,track:()=>wZ,trackDefects:()=>AZ,trackDuration:()=>kZ,trackErrors:()=>CZ,trackSuccesses:()=>vZ,transposeOption:()=>QJ,try:()=>Go,tryPromise:()=>Vo,tx:()=>RZ,txRetry:()=>PZ,undefined:()=>Kp,uninterruptible:()=>Ci,uninterruptibleMask:()=>en,unwrapReason:()=>s8,updateContext:()=>Xa,updateService:()=>X0,updateServiceScoped:()=>M8,useSpan:()=>Qp,validate:()=>$J,void:()=>P,when:()=>fy,whileLoop:()=>xn,withErrorReporting:()=>x8,withExecutionPlan:()=>h8,withFiber:()=>ar,withFiberSucceed:()=>JJ,withLogSpan:()=>TZ,withLogger:()=>EZ,withParentSpan:()=>bl,withSpan:()=>oZ,withSpanScoped:()=>sZ,withTracer:()=>G8,withTracerEnabled:()=>J8,withTracerTiming:()=>Z8,yieldNow:()=>Vp,yieldNowWith:()=>GJ,zip:()=>H0,zipWith:()=>r8});var ws=Gd,Mr=ze,ir=Pr,Jn=So,Dg=ln,Lg=Zf,Kt=hn;var ft=Qf,vs=yM;var IN=PT;var TN=wM;var wN=MT;var Fn={};ps(Fn,{CurrentMemoMap:()=>du,build:()=>LN,buildWithMemoMap:()=>gi,buildWithScope:()=>_p,catch:()=>LG,catchCause:()=>$G,catchTag:()=>BG,effect:()=>Qn,effectContext:()=>Ja,effectDiscard:()=>PG,empty:()=>_G,flatMap:()=>jN,forkMemoMap:()=>OG,forkMemoMapUnsafe:()=>d0,fresh:()=>jG,fromBuild:()=>Va,fromBuildMemo:()=>Wg,isLayer:()=>zg,launch:()=>HG,makeMemoMap:()=>RG,makeMemoMapUnsafe:()=>xi,merge:()=>FG,mergeAll:()=>Kg,mock:()=>qG,orDie:()=>Vg,parentSpan:()=>qN,provide:()=>As,provideMerge:()=>Pp,satisfiesErrorType:()=>KG,satisfiesServicesType:()=>VG,satisfiesSuccessType:()=>WG,span:()=>GG,succeed:()=>Ga,succeedContext:()=>pu,suspend:()=>MG,sync:()=>p0,syncContext:()=>u0,tap:()=>NG,tapCause:()=>DG,tapError:()=>UG,unwrap:()=>f0,updateService:()=>HN,withParentSpan:()=>l0,withSpan:()=>JG});var IG="~effect/Deferred";var TG={[IG]:{_A:F,_E:F},pipe(){return V(this,arguments)}},vN=function(){this.resumes=void 0,this.effect=void 0};vN.prototype=TG;var lu=()=>new vN;var Bg=e=>$t(t=>e.effect?t(e.effect):(e.resumes??=[],e.resumes.push(t),ye(()=>{let r=e.resumes;if(r===void 0)return;let n=r.indexOf(t);n>=0&&r.splice(n,1)})));var wG=d(2,(e,t)=>ye(()=>hi(e,t))),vG=wG;var CG=d(2,(e,t)=>vG(e,Pr(t)));var c0=d(2,(e,t)=>CG(e,$a(t)));var hi=(e,t)=>{if(e.effect)return!1;if(e.effect=t,e.resumes){let r=e.resumes;e.resumes=void 0;for(let n=0;n<r.length;n++)r[n](t)}return!0};var CN=Xi;var AN=Qx,kN=zf;var jg=nu,RN=kP;var it=Ha;var Zn=tl,zo=iF,Wo=qa,It=oF;var yr=nF,Ve=WT;var DN="~effect/Layer",_N="~effect/Layer/MemoMap",AG=(e,t)=>{let r={observers:0,deferred:lu(),scope:Zn(),finalizer:n=>ce(()=>--r.observers>0?pe:(e.map.delete(t),Ve(r.scope,n)))};return r},PN=(e,t)=>t.state._tag==="Closed"?!1:(e.observers++,za(t,{},e.finalizer),!0),zg=e=>O(e,DN),kG={[DN]:{_ROut:F,_E:F,_RIn:F},pipe(){return V(this,arguments)}},mu=e=>{let t=Object.create(kG);return t.build=e,t},Va=e=>mu((t,r)=>{let n=yr(r);return To(e(t,n),o=>o._tag==="Failure"?Ve(n,o):pe)}),Wg=e=>{let t=Va((r,n)=>r.getOrElseMemoize(t,n,e));return t},qg=class{get[_N](){return _N}parent;constructor(t){this.parent=t}map=new Map;get(t,r){let n=this.map.get(t);return n?(PN(n,r),n.deferred.effect??Bg(n.deferred)):this.parent?.get(t,r)}getOrElseMemoize(t,r,n){return ce(()=>{let o;return Io(ce(()=>{let s=this.get(t,r);if(s)return s;let i=AG(this,t);return PN(i,r)?(o=i.deferred,this.map.set(t,i),n(this,i.scope)):n(this,r)}),s=>{o&&hi(o,s)})})}},xi=()=>new qg,d0=e=>new qg(e),RG=ye(xi),OG=e=>ye(()=>d0(e)),du=class e extends Ue()("effect/Layer/CurrentMemoMap"){static forkOrCreate(t){let r=Vi(t,e);return r?d0(r):xi()}},gi=d(3,(e,t,r)=>Pn(_e(ce(()=>e.build(t,r)),We(du,t)),du,t)),LN=e=>oe(t=>gi(e,du.forkOrCreate(t.context),dn(t.context,it))),_p=d(2,(e,t)=>oe(r=>gi(e,du.forkOrCreate(r.context),t))),Ga=function(){return arguments.length===1?e=>pu(ys(arguments[0],e)):pu(ys(arguments[0],arguments[1]))},pu=e=>mu(qe(q(e))),_G=pu(pt()),p0=function(){return arguments.length===1?e=>u0(()=>ys(arguments[0],e())):u0(()=>ys(arguments[0],arguments[1]()))},u0=e=>Wg(qe(ye(e))),Qn=function(){return arguments.length===1?e=>MN(arguments[0],e):MN(arguments[0],arguments[1])},MN=(e,t)=>Ja(_e(t,r=>ys(e,r))),Ja=e=>Wg((t,r)=>zo(e,r)),PG=e=>Ja(Zr(e,pt())),MG=e=>Wg((t,r)=>ce(()=>e().build(t,r))),FN=Ue("effect/Layer/unwrap"),f0=e=>jN(Qn(FN)(e),Re(FN)),BN=(e,t,r)=>{let n=yr(r,"parallel");return Kn(e,o=>o.build(t,yr(n,"sequential")),{concurrency:e.length}).pipe(_e(o=>j_(...o)))},Kg=(...e)=>Va((t,r)=>BN(e,t,r)),FG=d(2,(e,t)=>Kg(e,...Array.isArray(t)?t:[t])),$N=(e,t,r)=>Va((n,o)=>Y(Array.isArray(t)?BN(t,n,o):t.build(n,o),s=>e.build(n,o).pipe(Eo(s),_e(i=>r(i,s))))),As=d(2,(e,t)=>$N(e,t,F)),Pp=d(2,(e,t)=>$N(e,t,(r,n)=>Kr(n,r))),jN=d(2,(e,t)=>Va((r,n)=>Y(e.build(r,n),o=>t(o).build(r,n)))),NG=d(2,(e,t)=>Va((r,n)=>Y(e.build(r,n),o=>zo(Zr(t(o),o),n)))),UG=d(2,(e,t)=>Va((r,n)=>Es(e.build(r,n),o=>zo(bo(t(o),Et(o)),n)))),DG=d(2,(e,t)=>Va((r,n)=>Mn(e.build(r,n),o=>zo(bo(t(o),Ye(o)),n)))),Vg=e=>mu((t,r)=>Ig(e.build(t,r))),LG=d(2,(e,t)=>mu((r,n)=>Es(e.build(r,n),o=>t(o).build(r,n))));var BG=d(3,(e,t,r)=>mu((n,o)=>Eg(e.build(n,o),t,s=>r(s).build(n,o)))),$G=d(2,(e,t)=>mu((r,n)=>Mn(e.build(r,n),o=>t(o).build(r,n)))),HN=d(3,(e,t,r)=>As(e,Qn(t,_e(t,r)))),jG=e=>mu((t,r)=>e.build(xi(),r)),HG=e=>vg(bo(LN(e),gp)),qG=function(){return arguments.length===1?e=>NN(arguments[0],e):NN(arguments[0],arguments[1])},NN=(e,t)=>Ga(e)(new Proxy({...t},{get(r,n,o){if(n in r)return r[n];let s=Ir();yt(2);let i=new Error(`${e.key}: Unimplemented method "${n.toString()}"`);return yt(s),i.name="UnimplementedError",zG(i)},has:nr})),zG=e=>{let t=Object.assign(ta(e),{[UN]:UN,channel:{[Hg]:Hg,transform:()=>q(t),pipe(){return V(this,arguments)}},[Hg]:Hg,transform:()=>q(t)});function r(){return t}return Object.assign(r,t),Object.setPrototypeOf(r,Object.getPrototypeOf(t)),r},UN="~effect/Stream",Hg="~effect/Channel",WG=()=>e=>e,KG=()=>e=>e,VG=()=>e=>e,GG=(e,t)=>(t=Ho(t),Qn(li,t?.onEnd?pi(bs(e,t),r=>rl(n=>t.onEnd(r,n))):bs(e,t))),qN=e=>pu(li.context(e)),JG=function(){let e=typeof arguments[0]!="string",t=e?arguments[1]:arguments[0],r=Ho(e?arguments[2]:arguments[1]);if(e){let n=arguments[0];return f0(_e(r?.onEnd!==void 0?pi(bs(t,r),o=>rl(s=>r.onEnd(o,s))):bs(t,r),o=>l0(n,o,r)))}return n=>f0(_e(r?.onEnd!==void 0?pi(bs(t,r),o=>rl(s=>r.onEnd(o,s))):bs(t,r),o=>l0(n,o,r)))},l0=function(){let e=zg(arguments[0]),t=e?arguments[1]:arguments[0],r=e?arguments[2]:arguments[1],n=F;t._tag==="Span"&&(r=Ho(r),n=ZG(t.name,r?.captureStackTrace));let o=qN(t);return e?As(n(arguments[0]),o):s=>As(n(s),o)},ZG=(e,t)=>(t=typeof t=="function"?t:po,HN(kN,r=>({name:e,stack:t,parent:r})));var Yn=Vn;var Gg="~effect/DateTime",Jg="~effect/DateTime/TimeZone",KN={[Gg]:Gg,pipe(){return V(this,arguments)},[Qe](){return this.toString()},toJSON(){return Np(this).toJSON()}},QG={...KN,_tag:"Utc",[ie](){return zt(this.epochMilliseconds)},[ae](e){return pl(e)&&e._tag==="Utc"&&this.epochMilliseconds===e.epochMilliseconds},toString(){return`DateTime.Utc(${Np(this).toJSON()})`}},YG={...KN,_tag:"Zoned",[ie](){return he(zt(this.epochMilliseconds))(G(this.zone))},[ae](e){return pl(e)&&e._tag==="Zoned"&&this.epochMilliseconds===e.epochMilliseconds&&Z(this.zone,e.zone)},toString(){return`DateTime.Zoned(${v0(this)})`}},VN={[Jg]:Jg,[Qe](){return this.toString()}},XG={...VN,_tag:"Named",[ie](){return Be(`Named:${this.id}`)},[ae](e){return hu(e)&&e._tag==="Named"&&this.id===e.id},toString(){return`TimeZone.Named(${this.id})`},toJSON(){return{_id:"TimeZone",_tag:"Named",id:this.id}}},eJ={...VN,_tag:"Offset",[ie](){return Be(`Offset:${this.offset}`)},[ae](e){return hu(e)&&e._tag==="Offset"&&this.offset===e.offset},toString(){return`TimeZone.Offset(${I0(this.offset)})`},toJSON(){return{_id:"TimeZone",_tag:"Offset",offset:this.offset}}},yi=(e,t,r)=>{let n=Object.create(YG);return n.epochMilliseconds=e,n.zone=t,Object.defineProperty(n,"partsUtc",{value:r,enumerable:!1,writable:!0}),Object.defineProperty(n,"adjustedEpochMillis",{value:void 0,enumerable:!1,writable:!0}),Object.defineProperty(n,"partsAdjusted",{value:void 0,enumerable:!1,writable:!0}),n},pl=e=>O(e,Gg);var hu=e=>O(e,Jg),GN=e=>hu(e)&&e._tag==="Offset",JN=e=>hu(e)&&e._tag==="Named",ZN=e=>e._tag==="Utc",x0=e=>e._tag==="Zoned",QN=Wr((e,t)=>e.epochMilliseconds===t.epochMilliseconds);var YN=e=>{let t=Object.create(QG);return t.epochMilliseconds=e,Object.defineProperty(t,"partsUtc",{value:void 0,enumerable:!1,writable:!0}),t},dl=e=>{let t=e.getTime();if(Number.isNaN(t))throw new Ug("Invalid date");return YN(t)},Qg=e=>{if(pl(e))return e;if(e instanceof Date)return dl(e);if(typeof e=="object"){if("epochMilliseconds"in e)return dl(new Date(e.epochMilliseconds));let t=new Date(0);return cJ(t,e),dl(t)}else if(typeof e=="string"&&!tJ(e))return dl(new Date(e+"Z"));return dl(new Date(e))},tJ=e=>/Z|GMT|[+-]\d{2}$|[+-]\d{2}:?\d{2}$|\]$/.test(e),rJ=-864e13+720*60*1e3,nJ=864e13-840*60*1e3,g0=(e,t)=>{let r=t?.timeZone;if(r===void 0&&pl(e)&&x0(e))return e;let n=Qg(e);if(n.epochMilliseconds<rJ||n.epochMilliseconds>nJ)throw new RangeError(`Epoch millis out of range: ${n.epochMilliseconds}`);r===void 0&&typeof e=="object"&&"timeZoneId"in e&&(r=e.timeZoneId);let o;if(r===void 0){let s=new Date(n.epochMilliseconds).getTimezoneOffset()*-60*1e3;o=Fp(s)}else if(hu(r))o=r;else if(typeof r=="number")o=Fp(r);else{let s=b0(r);if(fe(s))throw new Ug(`Invalid time zone: ${r}`);o=s.value}return t?.adjustForTimeZone!==!0?yi(n.epochMilliseconds,o,n.partsUtc):uJ(n.epochMilliseconds,o,t?.disambiguation??"compatible")},m0=xs(g0),XN=xs(Qg),oJ=/^(.{17,35})\[(.+)\]$/,eU=e=>{let t=oJ.exec(e);if(t===null){let o=w0(e);return o!==null?m0(e,{timeZone:o}):_()}let[,r,n]=t;return m0(r,{timeZone:n})};var tU=e=>YN(e.epochMilliseconds);var Zg=new Map,sJ={day:"numeric",month:"numeric",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"longOffset",fractionalSecondDigits:3,hourCycle:"h23"},iJ=e=>{let t=e.resolvedOptions().timeZone,r=Zg.get(t);if(r!==void 0)return r;let n=Object.create(XG);return n.id=t,n.format=e,Zg.set(t,n),n},y0=e=>{let t=Zg.get(e);if(t!==void 0)return t;try{let r=iJ(new Intl.DateTimeFormat("en-US",{...sJ,timeZone:e}));return Zg.set(e,r),r}catch{throw new Ug(`Invalid time zone: ${e}`)}},Fp=e=>{let t=Object.create(eJ);return t.offset=e,t},S0=xs(y0);var aJ=/^(?:GMT|[+-])/,b0=e=>{if(aJ.test(e)){let t=w0(e);return t===null?_():N(Fp(t))}return S0(e)},rU=e=>e._tag==="Offset"?I0(e.offset):e.id;var Np=e=>new Date(e.epochMilliseconds),Yg=e=>{if(e._tag==="Utc")return new Date(e.epochMilliseconds);if(e.zone._tag==="Offset")return new Date(e.epochMilliseconds+e.zone.offset);if(e.adjustedEpochMilliseconds!==void 0)return new Date(e.adjustedEpochMilliseconds);let t=e.zone.format.formatToParts(e.epochMilliseconds).filter(n=>n.type!=="literal"),r=new Date(0);return r.setUTCFullYear(Number(t[2].value),Number(t[0].value)-1,Number(t[1].value)),r.setUTCHours(Number(t[3].value),Number(t[4].value),Number(t[5].value),t[6]?.type==="fractionalSecond"?Number(t[6].value):(e.epochMilliseconds%1e3+1e3)%1e3),e.adjustedEpochMilliseconds=r.getTime(),r},E0=e=>Yg(e).getTime()-T0(e),I0=e=>{let t=Math.abs(e),r=Math.floor(t/(3600*1e3)),n=Math.round(t%(3600*1e3)/(60*1e3));return n===60&&(r+=1,n=0),`${e<0?"-":"+"}${String(r).padStart(2,"0")}:${String(n).padStart(2,"0")}`},nU=e=>I0(E0(e)),T0=e=>e.epochMilliseconds;var cJ=(e,t)=>{if((t.year!==void 0||t.month!==void 0||t.day!==void 0)&&e.setUTCFullYear(t.year??e.getUTCFullYear(),t.month!==void 0?t.month-1:e.getUTCMonth(),t.day??e.getUTCDate()),t.weekDay!==void 0){let r=t.weekDay-e.getUTCDay();e.setUTCDate(e.getUTCDate()+r)}t.hour!==void 0&&e.setUTCHours(t.hour),t.minute!==void 0&&e.setUTCMinutes(t.minute),t.second!==void 0&&e.setUTCSeconds(t.second),t.millisecond!==void 0&&e.setUTCMilliseconds(t.millisecond)};var WN=1440*60*1e3,uJ=(e,t,r)=>{if(t._tag==="Offset")return yi(e-t.offset,t);let n=Mp(e-WN,e,t),o=Mp(e+WN,e,t);if(n===o)return yi(e-n,t);let s=n<o,i=n-o;if(s){if(Mp(e-o,e,t)===o)return yi(e-o,t);let u=yi(e-n,t),f=Yg(u).getTime();if(e!==f)switch(r){case"reject":{let p=new Date(e).toISOString();throw new RangeError(`Gap time: ${p} does not exist in time zone ${t.id}`)}case"earlier":return yi(e-o,t);case"compatible":case"later":return u}return u}if(Mp(e-n,e,t)===n){if(r==="earlier"||r==="compatible"||Mp(e-n+i,e+i,t)===n)return yi(e-n,t);if(r==="reject"){let u=new Date(e).toISOString();throw new RangeError(`Ambiguous time: ${u} occurs twice in time zone ${t.id}`)}}return yi(e-o,t)},fJ=/([+-])(\d{2}):(\d{2})$/,w0=e=>{let t=fJ.exec(e);if(t===null)return null;let[,r,n,o]=t;return(r==="+"?1:-1)*(Number(n)*60+Number(o))*60*1e3},Mp=(e,t,r)=>{let n=r.format.formatToParts(e).find(s=>s.type==="timeZoneName")?.value??"";if(n==="GMT")return 0;let o=w0(n);return o===null?E0(yi(t,r)):o};var oU=e=>Np(e).toISOString();var h0=e=>{let t=Yg(e);return e._tag==="Utc"?t.toISOString():`${t.toISOString().slice(0,-1)}${nU(e)}`},v0=e=>e.zone._tag==="Offset"?h0(e):`${h0(e)}[${e.zone.id}]`;var Cde=globalThis.Number;var iU=d(2,(e,t)=>{if(!globalThis.Number.isFinite(e)||!globalThis.Number.isFinite(t)||t===0)return NaN;if(globalThis.Number.isInteger(e)&&globalThis.Number.isInteger(t))return e%t;let[r,n]=sU(e),[o,s]=sU(t),i=Math.min(n,s),a=r*BigInt(10)**BigInt(n-i),c=o*BigInt(10)**BigInt(s-i),u=a%c;if(u===BigInt(0))return e<0||Object.is(e,-0)?-0:0;let f=globalThis.Number(`${u}e${i}`);return f===0?Math.sign(e)*globalThis.Number.MIN_VALUE:f});function sU(e){if(globalThis.Number.isInteger(e))return[BigInt(e),0];let t=Math.abs(e).toExponential(),r=t.indexOf("e"),n=t.slice(0,r).replace(".","");return[BigInt(n)*(e<0?-BigInt(1):BigInt(1)),globalThis.Number(t.slice(r+1))-n.length+1]}var aU=e=>{let t=Math.ceil(Math.log(e)/Math.log(2));return Math.max(Math.pow(2,t),2)};var kde=globalThis.String,Xg=On;var cU=e=>e.trim();var ht=d(2,(e,t)=>oa(e,pJ,r=>t(r))),wo=e=>e.reasons.some(A0),A0=e=>e._tag==="Fail"&&Op(e.error),Up=e=>{let t,r=!1;for(let n of e.reasons)A0(n)?t??=n.error:n._tag!=="Interrupt"&&(r=!0);return t===void 0?re(e):r?re(uu(e.reasons.filter(n=>!A0(n)))):X(t)};var pJ=e=>{let t=Up(e);return be(t)?t:X(t.success.value)},ey=e=>{let t=Up(e);return be(t)?ir(t.failure):Mr(t.success.value)},Dp=d(2,(e,t)=>di(e,{onSuccess:t.onSuccess,onFailure:r=>{let n=Up(r);return be(n)?t.onFailure(n.failure):t.onDone(n.success.value)}}));var uU="~effect/Schedule";var Fr=Ce("effect/Schedule/CurrentMetadata",{defaultValue:qe({input:void 0,output:void 0,duration:Ji,attempt:0,start:0,now:0,elapsed:0,elapsedSincePrevious:0})}),mJ={[uU]:{_Out:F,_In:F,_Env:F},pipe(){return V(this,arguments)}},k0=e=>O(e,uU),ml=e=>{let t=Object.create(mJ);return t.step=e,t},R0=()=>{let e=0,t,r;return(n,o)=>{r===void 0&&(r=n);let s=n-r,i=t===void 0?0:n-t;return t=n,{input:o,attempt:++e,start:r,now:n,elapsed:s,elapsedSincePrevious:i}}},fU=e=>ml(_e(e,t=>{let r=R0();return(n,o)=>t(r(n,o))})),Qa=e=>Mn(e.step,t=>q(()=>Ye(t))),ks=e=>Is(t=>_e(Qa(e),r=>{let n=R0();return o=>ce(()=>{let s=t.currentTimeMillisUnsafe();return Y(r(s,o),([i,a])=>{let c=n(s,o);return c.output=i,c.duration=a,Zr(sl(a),c)})})})),Lp=e=>_e(ks(e),t=>r=>_e(t(r),n=>n.output));var lU=e=>ml(_e(ol(e.map(Qa)),t=>(r,n)=>Y(Kn(t,o=>Dp(o(r,n),{onSuccess:s=>q(s[1]),onDone:()=>Fg,onFailure:Ye})),o=>{let s=hJ(o);return s===void 0?se(Ji):q([s,s])}))),hJ=e=>{let t;for(let r=0;r<e.length;r++){let n=e[r];n!==void 0&&(t=t===void 0?n:dP(t,n))}return t},dU=(e,t=2)=>{let r=Wt($e(e));return fU(q(n=>{let o=Zi(r*Math.pow(t,n.attempt-1));return q([o,o])}))};var O0=e=>ml(_e(Qa(e),t=>(r,n)=>Dp(t(r,n),{onSuccess:o=>q([n,o[1]]),onFailure:Ye,onDone:()=>se(n)}))),pU=e=>Bp($p,({attempt:t})=>q(t<=e)),hl=e=>{let t=$e(e);return fU(q(r=>q([r.attempt-1,t])))};var Bp=d(2,(e,t)=>ml(_e(Qa(e),r=>{let n=R0();return(o,s)=>Y(r(o,s),i=>{let[a,c]=i,u=t({...n(o,s),output:a,duration:c});return Y(ge(u)?u:q(u),f=>f?q(i):se(a))})})));var $p=hl(Ji);var mU="~effect/ExecutionPlan";var xJ={[mU]:mU,get captureRequirements(){let e=this;return ja(t=>q(gJ(e.steps.map(r=>({...r,while:r.while?n=>Eo(r.while(n),t):void 0,schedule:r.schedule?ml(Eo(_e(Qa(r.schedule),n=>(o,s)=>Eo(n(o,s),t)),t)):void 0,provide:zg(r.provide)?As(r.provide,pu(t)):r.provide})))))},pipe(){return V(this,arguments)}},gJ=e=>{let t=Object.create(xJ);return t.steps=e,t};var ty=Ce("effect/ExecutionPlan/CurrentMetadata",{defaultValue:qe({attempt:0,stepIndex:0})});var yJ=(e,t,r)=>Cg(n=>Y(r?.local?gi(t,xi(),n):_p(t,n),o=>Eo(e,o))),ry=d(e=>ge(e[0]),(e,t,r)=>ip(t)?Eo(e,t):yJ(e,Array.isArray(t)?Kg(...t):t,r));var xU=e=>e.reasons.every(hs)?qo(e):re(e),P0=d(3,(e,t,r)=>Y(ks(t),n=>{let o=Fr.defaultValue();return oa(ht(yg(pi(Y(ce(()=>Pn(e,Fr,o)),n),s=>ye(()=>{o=s})),{disableYield:!0}),s=>q(s)),xU,s=>r(s,o.attempt===0?_():N(o)))})),M0=d(3,(e,t,r)=>Y(ks(t),n=>{let o=Fr.defaultValue(),s,i=oa(ce(()=>Pn(e,Fr,o)),xU,a=>(s=a,Y(n(a),c=>(o=c,i))));return ht(i,a=>Pa(()=>r(s,a)))})),gU=d(2,(e,t)=>{let r=typeof t=="function"?t(F):k0(t)?t:Hp(t);return P0(e,r,Et)}),jp=d(2,(e,t)=>{let r=typeof t=="function"?t(F):k0(t)?t:Hp(t);return M0(e,r,Et)}),yU=d(3,(e,t,r)=>Y(ks(r),n=>{let o=Fr.defaultValue(),s=ce(()=>Pn(e,Fr,o));return ht(Y(n(t),i=>{o=i;let a=qe(Y(s,n));return mi({while:nr,body:a,step(c){o=c}})}),i=>q(i))})),SJ=O0($p),Hp=e=>{let t=e.schedule?O0(e.schedule):SJ;return e.while&&(t=Bp(t,({input:r})=>{let n=e.while(r);return ge(n)?n:q(n)})),e.until&&(t=Bp(t,({input:r})=>{let n=e.until(r);return ge(n)?_e(n,o=>!o):q(!n)})),e.times!==void 0&&(t=Bp(t,({attempt:r})=>q(r<=e.times))),t};var F0=(e,t)=>{let r=-1,n=0,o=s=>Tg(e(s));return{begin:Is(s=>ce(()=>{let i=t();i.stepIndex!==r&&(r=i.stepIndex,n=0),n++;let a={attempt:i.attempt,stepAttempt:n,stepIndex:i.stepIndex,startNanos:s.monotonicTimeNanosUnsafe()};return Zr(o({_tag:"AttemptStart",attempt:a.attempt,stepAttempt:a.stepAttempt,stepIndex:a.stepIndex}),a)})),end:(s,i)=>Is(a=>{let c=$o(a.monotonicTimeNanosUnsafe()-s.startNanos);return o(i._tag==="Success"?{_tag:"AttemptSuccess",attempt:s.attempt,stepAttempt:s.stepAttempt,stepIndex:s.stepIndex,duration:c}:{_tag:"AttemptFailure",attempt:s.attempt,stepAttempt:s.stepAttempt,stepIndex:s.stepIndex,duration:c,cause:i.cause})})}},bU=d(e=>ge(e[0]),(e,t,r)=>ce(()=>{let n=0,o={attempt:0,stepIndex:0},s=gg(ty,ye(()=>(o={attempt:o.attempt+1,stepIndex:n},o))),i=r?.onEvent===void 0?void 0:F0(r.onEvent,()=>o),a=i===void 0?F:u=>Gn(f=>Y(i.begin,p=>To(f(u),m=>i.end(p,m)))),c;return Y(mi({while:()=>n<t.steps.length&&(c===void 0||be(c)),body(){let u=t.steps[n],f=s(a(ry(e,u.provide)));if(c){let p=!1,m=f;f=ce(()=>p?m:(p=!0,Vf(c))),f=jp(f,qp(u,!1))}else{let p=qp(u,!0);f=p?jp(f,p):f}return Ba(f)},step(u){c=u,n++}}),()=>Vf(c))})),qp=(e,t)=>{if(t){if(e.attempts===1||!(e.schedule||e.attempts))return}else return Hp({schedule:e.schedule?e.schedule:e.attempts?void 0:bJ,times:e.attempts,while:e.while});return Hp({schedule:e.schedule,while:e.while,times:e.attempts?e.attempts-1:void 0})},bJ=pU(1);var IU="~effect/MutableHashMap";var EJ={[IU]:IU,[Symbol.iterator](){return this.backing[Symbol.iterator]()},toString(){return`MutableHashMap(${H(Array.from(this))})`},toJSON(){return{_id:"MutableHashMap",values:pr(Array.from(this))}},[Qe](){return this.toJSON()},pipe(){return V(this,arguments)}},Si=()=>{let e=Object.create(EJ);return e.backing=new Map,e.buckets=new Map,e};var Qr=d(2,(e,t)=>{if(e.backing.has(t))return N(e.backing.get(t));if(N0(t))return _();let r=G(t),n=e.buckets.get(r);return n===void 0?_():IJ(e,n,t)}),N0=e=>typeof e!="object"&&typeof e!="function";var IJ=(e,t,r)=>{for(let n=0,o=t.length;n<o;n++)if(Z(r,t[n])){let s=t[n];return N(e.backing.get(s))}return _()},U0=d(2,(e,t)=>de(Qr(e,t))),bi=d(3,(e,t,r)=>{if(e.backing.has(t)||N0(t))return e.backing.set(t,r),e;let n=G(t),o=e.buckets.get(n);if(o===void 0)return e.buckets.set(n,[t]),e.backing.set(t,r),e;let s=TJ(o,t);return s===void 0&&(o.push(t),s=t),e.backing.set(s,r),e}),TJ=(e,t)=>{for(let r=0,n=e.length;r<n;r++)if(Z(t,e[r]))return e[r]};var Ei=d(2,(e,t)=>{if(N0(t))return e.backing.delete(t),e;let r=G(t),n=e.buckets.get(r);if(n===void 0)return e;for(let o=0,s=n.length;o<s;o++){let i=n[o];if(i===t||Z(t,i)){e.backing.delete(i),n.splice(o,1);break}}return n.length===0&&e.buckets.delete(r),e}),ny=e=>(e.backing.clear(),e.buckets.clear(),e),TU=e=>e.backing.size;var wJ="~effect/Request",vJ=ZO({_E:e=>e,_A:e=>e,_R:e=>e}),Jde={...r_,[wJ]:vJ};var wU=e=>e;var CU=d(2,(e,t)=>{let r=n=>$t(o=>{let s=kU(n,e,o,ea());return RJ(n,s)});return ge(t)?Y(t,r):r(t)}),AU=(e,t)=>{let r=kU(t.resolver,e,t.onExit,{context:t.context,cache:{scheduler:Re(t.context,La)}});return()=>RU(t.resolver,r)},AJ=new WeakSet,kJ=e=>{if(!AJ.has(e.batchKey))return new Map;let t=Si();return{get:r=>_n(Qr(t,r)),has:r=>U0(t,r),set:(r,n)=>bi(t,r,n),delete:r=>Ei(t,r)}},oy=[],D0=new WeakMap,kU=(e,t,r,n)=>{let o=D0.get(e);o||(o=kJ(e),D0.set(e,o));let s,i=!1,a=wU({request:t,context:n.context,uninterruptible:!1,completeUnsafe(u){i||(i=!0,!(s&&!s.entrySet.delete(a))&&r(u))}});if(e.preCheck!==void 0&&!e.preCheck(a))return a;let c=e.batchKey(a);if(s=o.get(c),!s){if(oy.length>0)s=oy.pop(),s.key=c,s.resolver=e,s.map=o;else{let u={key:c,resolver:e,map:o,entrySet:new Set,entries:new Set,delayEffect:Y(ce(()=>u.resolver.delay),f=>vU(u)),run:To(ce(()=>u.resolver.runAll(Array.from(u.entries),u.key)),f=>{for(let p of u.entrySet)p.completeUnsafe(f._tag==="Success"?ln(new Error("Effect.request: RequestResolver did not complete request",{cause:p.request})):f);return u.entries.clear(),oy.length<128&&(u.entrySet.clear(),u.key=void 0,u.fiber=void 0,u.resolver=void 0,u.map=void 0,oy.push(u)),pe})};s=u}o.set(c,s),s.fiber=sa(n.context)(s.delayEffect,{scheduler:n.cache.scheduler})}return s.entrySet.add(a),s.entries.add(a),s.resolver.collectWhile(s.entries)||(s.fiber.interruptUnsafe(n.id),s.fiber=sa(n.context)(vU(s),{scheduler:n.cache.scheduler})),a},RU=(e,t)=>{if(t.uninterruptible)return;let r=D0.get(e);if(!r)return;let n=e.batchKey(t),o=r.get(n);if(!o||!o.entries.delete(t))return;o.entrySet.delete(t);let s;o.entries.size===0&&(r.delete(n),s=o.fiber),t.completeUnsafe(Zf()),s?.interruptUnsafe()},RJ=(e,t)=>ye(()=>RU(e,t));function vU(e){return e.map.has(e.key)?(e.map.delete(e.key),e.run):pe}var _J="effect/Metric/CurrentMetricAttributes",PJ=Ce(_J,{defaultValue:()=>({})}),MJ="effect/Metric/MetricRegistry",FJ=Ce(MJ,{defaultValue:()=>new Map}),OU="~effect/Metric",_U=class{[OU]=OU;#e;#t="";id;description;attributes;constructor(t,r,n){this.id=t,this.description=r,this.attributes=n}valueUnsafe(t){return this.hook(t).get(t)}modifyUnsafe(t,r){return this.hook(r).modify(t,r)}updateUnsafe(t,r){return this.hook(r).update(t,r)}hook(t){let r=Re(t,PJ);r!==this.#e&&(this.#e=r,this.#t=NJ(this,PU(this.attributes,r)));let n=Re(t,FJ),o=n.get(this.#t);return LO(o)&&(o={id:this.id,type:this.type,description:this.description,attributes:Object.keys(r).length>0?PU(this.attributes,r):this.attributes,hooks:this.createHooks()},n.set(this.#t,o)),o.hooks}pipe(){return V(this,arguments)}};var xl=d(2,(e,t)=>ja(r=>ye(()=>e.updateUnsafe(t,r))));function NJ(e,t){let r=Object.entries(t).sort((n,o)=>n[0]<o[0]?-1:n[0]>o[0]?1:0);return JSON.stringify([e.type,e.id,e.description,r])}function PU(e,t){return{...MU(e),...MU(t)}}function MU(e){return ei(e)&&Array.isArray(e)?e.reduce((t,[r,n])=>(B(t,r,n),t),{}):e}var UJ=si,Yr=ge,DJ=ol,LJ=ZT,BJ=bF,$J=EF,jJ=IF,HJ=wF,Ko=Kn,qJ=CF,xn=mi,Wp=wT,Vo=XP,I=q,ia=iu,B0=TT,L=ce,W=ye,P=pe;var Kp=Fg;var Nn=$t,Xn=gp,zJ=PF,WJ=MF,KJ=NF;var VJ=FF,xt=nM,D=Et,sy=mg,je=Ye,aa=QP,gn=ta,Go=YP;var Vp=Gf,GJ=IT,ar=oe,JJ=s_,$0=Vf,ZJ=ET,QJ=ZP,YJ=JP,A=Y,j0=pM,Vt=bo,_t=pi,XJ=Ba,e8=VM,eo=Ep,K=_e,Pt=Zr,iy=Jf,vo=yp,t8=cM,H0=RM,r8=NT,gu=Es;var UU=Eg,DU=$M,n8=jM,o8=HM,s8=qM,rt=Mn,q0=NM,i8=Sp,a8=bg,c8=FM,z0=DT,LU=oa,yl=BT,u8=$T,Ii=Ig,Gp=LT,f8=LM,Jp=UM,l8=DM,d8=Sg,BU=BM,p8=jT,ay=jp,W0=M0,m8=uM,cy=KM,uy=Tg,h8=bU,x8=mN,g8=zM,y8=WM,K0=eF,S8=zT,$U=qT,ca=XM,ua=sl,b8=tF,V0=RT,E8=OT,I8=fM,Ya=_T,G0=RF,T8=OF,J0=_F,jU=QT,w8=YT,HU=OM,v8=kF,fy=_M,Z0=wg,C8=bp,A8=HT,k8=ZM,R8=lM,Un=di,qU=Xf,O8=QM,_8=YM,Nr=FT,yn=ja,Q0=ry,Ur=Eo,P8=kM,Y0=vM,yu=CM,Xa=Yf,X0=na,M8=AM,Jo=Pn,F8=gg,Co=Ip,ec=vg,Sl=Cg,Ti=Ag,N8=dF,zU=lF,WU=rl,wi=cF,to=Tp,U8=uF,D8=GT,Zp=Io,Xr=To,L8=KT,B8=VT,ly=hF,$8=mF,j8=JT,Dn=nl,vi=kg,Su=fF,Ci=au,en=Gn,H8=yF,q8=SF,Mt=yg,KU=gU,z8=P0,W8=UT,ew=PM,K8=d(2,(e,t)=>VU(e,void 0,t)),VU=yU,V8=GF,G8=JF,J8=ZF,Z8=QF,Q8=sN,Y8=iN,X8=aN,eZ=cN,tZ=tN,rZ=rN,nZ=nN,tw=XF,rw=bs,Qp=mp,oZ=oN,sZ=eN,bl=Kf,iZ=CU,aZ=AU,El=UF,gt=XT,Rs=BF,Il=DF,cZ=LF,uZ=tM,fZ=rM,Yp=jF,Sr=sa,nw=e0,lZ=HF,ow=zF,sw=t0,dy=qF,dZ=_g,Ai=KF,iw=r0,ki=WF,pZ=Pg,me=CT,mZ=oM,bu=Is,Tl=Ts,hZ=Ts(),xZ=Ts("Fatal"),gZ=Ts("Warn"),Xp=Ts("Error"),yZ=Ts("Info"),SZ=Ts("Debug"),bZ=Ts("Trace"),EZ=d(2,(e,t)=>na(e,i0,r=>new Set([...r,t]))),py=d(e=>Yr(e[0]),(e,...t)=>na(e,CN,r=>{let n=t.length===1?{...r,...t[0]}:{...r};return t.length===1||B(n,t[0],t[1]),n})),IZ=dN,TZ=d(2,(e,t)=>Y(s0,r=>na(e,AN,n=>[[t,r],...n]))),wZ=d(e=>Yr(e[0]),(e,t,r)=>Xr(e,n=>{let o=r===void 0?n:r(n);return xl(t,o)})),vZ=d(e=>Yr(e[0]),(e,t,r)=>_t(e,n=>{let o=r===void 0?n:r(n);return xl(t,o)})),CZ=d(e=>Yr(e[0]),(e,t,r)=>Gp(e,n=>{let o=r===void 0?n:r(n);return xl(t,o)})),AZ=d(e=>Yr(e[0]),(e,t,r)=>BU(e,n=>{let o=r===void 0?n:r(n);return xl(t,o)})),kZ=d(e=>Yr(e[0]),(e,t,r)=>bu(n=>{let o=n.monotonicTimeNanosUnsafe();return Xr(e,()=>{let s=n.monotonicTimeNanosUnsafe(),i=pP($e(s),$e(o)),a=r===void 0?i:r(i);return xl(t,a)})})),gl=class extends Ue()("effect/Effect/Transaction"){},RZ=e=>ar(t=>{let r=Vi(t.context,gl);if(r&&!NU.has(r))return e;r={journal:new Map,retry:!1};let n;return en(o=>A(xn({while:()=>!n,body:qe(o(e).pipe(Jo(gl,r),Jp(s=>r.retry?ug(s)?o(OZ(r)):W(()=>L0(r)):P),eo)),step(s){if(r.retry||!GU(r))return L0(r);ft(s)&&_Z(t,r),L0(r),NU.add(r),n=s}}),()=>n))}),NU=new WeakSet,GU=e=>{for(let[t,{version:r}]of e.journal)if(t.version!==r)return!1;return!0},OZ=e=>Nn(t=>{if(!GU(e))return t(P);let r={},n=Array.from(e.journal.keys()),o=()=>{for(let i of n)i.pending.delete(r)},s=()=>{o(),t(P)};for(let i of n)i.pending.set(r,s);return W(o)});function _Z(e,t){for(let[r,{value:n,written:o}]of t.journal)if(o){Object.is(n,r.value)||(r.version=r.version+1,r.value=n);for(let s of r.pending.values())e.currentDispatcher.scheduleTask(s,0);r.pending.clear()}}function L0(e){e.retry=!1,e.journal.clear()}var PZ=A(gl,e=>(e.retry=!0,Dn)),MZ=(e,t,r)=>(...n)=>Nn(o=>{try{e(...n,(s,i)=>{o(s?t?L(()=>D(t(s,n))):D(s):I(i))})}catch(s){o(r?D(r(s,n)):gn(s))}}),FZ=()=>e=>e,NZ=()=>e=>e,UZ=()=>e=>e,Eu=mM,Iu=hM,cr=xM,ur=dM,my=gM,aw=sM;var JU=/^[+-]?\d+$/,uw="~effect/BigDecimal",DZ={[uw]:uw,[ie](){let e=em(this);return he(Be(String(e.value)),zt(e.scale))},[ae](e){return Tu(e)&&eD(this,e)===0},toString(){return`BigDecimal(${fa(this)})`},toJSON(){return{_id:"BigDecimal",value:String(this.value),scale:this.scale}},[Qe](){return this.toJSON()},pipe(){return V(this,arguments)}},Tu=e=>O(e,uw),hy=(e,t)=>{if(!Number.isSafeInteger(t))throw new RangeError(`Scale must be a safe integer, got ${t}`);let r=Object.create(DZ);return r.value=e,r.scale=t,r},YU=(e,t)=>{let r=hy(e,t);return r.normalized=r,r};var Os=BigInt(0),LZ=BigInt(1);var BZ=BigInt(10),XU=YU(Os,0);var em=e=>{if(e.normalized===void 0)if(e.value===Os)e.normalized=XU;else{let t=`${e.value}`,r=t.length;for(;t[r-1]==="0";)r--;e.normalized=YU(BigInt(t.slice(0,r)),e.scale-(t.length-r))}return e.normalized};var $Z=100,jZ=[LZ],cw=(e,t)=>e===t?0:e<t?-1:1,ZU=(e,t)=>{let r=`${e.value<Os?-e.value:e.value}`,n=`${t.value<Os?-t.value:t.value}`,o=BigInt(r.length-n.length)-BigInt(e.scale)+BigInt(t.scale);if(o!==Os)return o<Os?-1:1;let s=Math.max(r.length,n.length);return v_(r.padEnd(s,"0"),n.padEnd(s,"0"))},eD=(e,t)=>{if(e.scale===t.scale)return cw(e.value,t.value);let r=QU(e),n=QU(t);if(r!==n)return r<n?-1:1;if(r===0)return 0;let o=e.scale-t.scale,s=Math.abs(o);if(s>$Z)return r===-1?ZU(t,e):ZU(e,t);let i=jZ[s]??=BZ**BigInt(s);return o>0?cw(e.value,t.value*i):cw(e.value*i,t.value)},wl=ai(eD);var QU=e=>e.value===Os?0:e.value<Os?-1:1;var tD=e=>{if(e==="")return N(XU);let t,r,n=e.search(/[eE]/);if(n!==-1){let c=e.slice(n+1);if(t=e.slice(0,n),r=Number(c),t===""||!Number.isSafeInteger(r)||!JU.test(c))return _()}else t=e,r=0;let o,s,i=t.search(/\./);if(i!==-1){let c=t.slice(0,i),u=t.slice(i+1);o=`${c}${u}`,s=u.length}else o=t,s=0;if(!JU.test(o))return _();let a=s-r;return Number.isSafeInteger(a)?N(hy(BigInt(o),a)):_()};var fa=e=>{let t=em(e);if(Math.abs(t.scale)>=16)return HZ(t);let r=t.value<Os,n=`${r?-t.value:t.value}`,o=t.scale>0?n.padStart(t.scale+1,"0"):n.padEnd(n.length-t.scale,"0"),s=o.length-t.scale,i=t.scale>0?`${o.slice(0,s)}.${o.slice(s)}`:o;return r?`-${i}`:i},HZ=e=>{if(qZ(e))return"0e+0";let t=em(e),r=`${t.value}`,n=t.value<Os?2:1,o=r.slice(0,n),s=r.slice(n),i=s.length-t.scale;return`${o}${s===""?"":`.${s}`}e${i>=0?"+":""}${i}`};var qZ=e=>e.value===Os;var l={};ps(l,{Any:()=>C7,Array:()=>ct,ArrayEnsure:()=>U7,BigDecimal:()=>oj,BigDecimalFromString:()=>hee,BigInt:()=>dd,BigIntFromString:()=>eee,Boolean:()=>Fi,BooleanFromBit:()=>aee,BooleanLiterals:()=>q7,ByteSize:()=>JS,ByteSizeFromBigInt:()=>gee,ByteSizeFromNumber:()=>yee,ByteSizeFromString:()=>xee,Cause:()=>Jm,CauseReason:()=>XC,Char:()=>$X,Chunk:()=>See,Class:()=>YS,Cookie:()=>Gj,Cookies:()=>Jj,Date:()=>GS,DateFromMillis:()=>VX,DateFromString:()=>KX,DateTimeUtc:()=>ZS,DateTimeUtcFromDate:()=>vee,DateTimeUtcFromMillis:()=>Aee,DateTimeUtcFromString:()=>Cee,DateTimeZoned:()=>Ej,DateTimeZonedFromString:()=>_ee,Defect:()=>er,DnsARecord:()=>Uj,DnsAaaaRecord:()=>Dj,DnsCaaRecord:()=>Lj,DnsCnameRecord:()=>Bj,DnsMxRecord:()=>$j,DnsNaptrRecord:()=>jj,DnsNsRecord:()=>Hj,DnsPtrRecord:()=>qj,DnsRecord:()=>Ate,DnsRecordType:()=>Cte,DnsSoaRecord:()=>zj,DnsSrvRecord:()=>Wj,DnsTlsaRecord:()=>Kj,DnsTxtRecord:()=>Vj,DomainName:()=>Sa,DomainNameFromString:()=>_j,Duration:()=>ih,DurationFromMillis:()=>vte,DurationFromNanos:()=>wte,DurationFromString:()=>Tte,Enum:()=>v7,Error:()=>Ar,ErrorInstance:()=>jX,Exit:()=>yA,FalseLiterals:()=>_$,File:()=>Z$,Finite:()=>KS,FiniteFromString:()=>XX,FormData:()=>Q$,Graph:()=>_te,HashMap:()=>Pte,HashSet:()=>Mte,Headers:()=>Lte,Host:()=>hte,HostFromString:()=>xte,HostPort:()=>Mj,HostPortFromString:()=>gte,InetAddress:()=>Rj,InetAddressFromString:()=>dte,InetAddressV4:()=>fte,InetAddressV6:()=>lte,Int:()=>In,IpAddress:()=>Sc,IpAddressFromString:()=>tf,IpInterface:()=>vj,IpInterfaceFromString:()=>ite,IpLinkLocalAddress:()=>Kee,IpLinkLocalAddressFromString:()=>Vee,IpLoopbackAddress:()=>zee,IpLoopbackAddressFromString:()=>Wee,IpMulticastAddress:()=>Pee,IpMulticastAddressFromString:()=>Mee,IpNetwork:()=>kj,IpNetworkFromString:()=>ute,IpUnicastAddress:()=>Uee,IpUnicastAddressFromString:()=>Dee,IpUnspecifiedAddress:()=>Gee,IpUnspecifiedAddressFromString:()=>Jee,Ipv4Address:()=>sh,Ipv4AddressFromString:()=>xA,Ipv4BroadcastAddress:()=>$ee,Ipv4BroadcastAddressFromString:()=>jee,Ipv4Interface:()=>Tj,Ipv4InterfaceFromString:()=>ote,Ipv4Network:()=>Cj,Ipv4NetworkFromString:()=>ate,Ipv4PrivateAddress:()=>Zee,Ipv4PrivateAddressFromString:()=>Qee,Ipv6Address:()=>QS,Ipv6AddressFromString:()=>Ij,Ipv6Interface:()=>wj,Ipv6InterfaceFromString:()=>ste,Ipv6Network:()=>Aj,Ipv6NetworkFromString:()=>cte,Ipv6UniqueLocalAddress:()=>Yee,Ipv6UniqueLocalAddressFromString:()=>Xee,Json:()=>XS,JsonFromUrlParamsField:()=>Bte,JsonObject:()=>dre,Literal:()=>fr,Literals:()=>Fo,MacAddress:()=>ef,MacAddressFromString:()=>hd,MacBroadcastAddress:()=>Hee,MacBroadcastAddressFromString:()=>qee,MacLocallyAdministeredAddress:()=>ete,MacLocallyAdministeredAddressFromString:()=>tte,MacMulticastAddress:()=>Fee,MacMulticastAddressFromString:()=>Nee,MacUnicastAddress:()=>Lee,MacUnicastAddressFromString:()=>Bee,MacUniversallyAdministeredAddress:()=>rte,MacUniversallyAdministeredAddressFromString:()=>nte,MutableJson:()=>mre,Natural:()=>Vu,Never:()=>Mi,NonEmptyArray:()=>Yu,NonEmptyString:()=>pA,Null:()=>HS,NullOr:()=>iA,NullishOr:()=>T$,Number:()=>Zu,NumberFromString:()=>YX,ObjectKeyword:()=>k7,Opaque:()=>Z7,Option:()=>ba,OptionFromNullOr:()=>Fte,OptionFromNullishOr:()=>Ute,OptionFromOptional:()=>Hte,OptionFromOptionalKey:()=>jte,OptionFromOptionalNullOr:()=>qte,OptionFromUndefinedOr:()=>Nte,Port:()=>yte,PropertyKey:()=>YC,ReadonlyMap:()=>HX,ReadonlySet:()=>qX,Record:()=>Qu,RecordFromCookies:()=>Dte,RecordFromUrlParams:()=>$te,Redacted:()=>Zj,RedactedFromValue:()=>zte,RegExp:()=>zX,Result:()=>Wte,SchemaError:()=>$n,ScopedIpv6Literal:()=>gA,ScopedIpv6LiteralFromString:()=>Pj,SocketAddress:()=>mte,StandardSchemaV1FailureResult:()=>iee,String:()=>z,StringForLiteralAutocomplete:()=>A7,StringFromBase64:()=>ree,StringFromBase64Url:()=>nee,StringFromHex:()=>oee,StringFromUriComponent:()=>see,Struct:()=>Te,StructWithRest:()=>F7,Symbol:()=>b$,TaggedClass:()=>Jte,TaggedError:()=>EA,TaggedStruct:()=>ya,TaggedUnion:()=>J7,TemplateLiteral:()=>T7,TemplateLiteralParser:()=>w7,TimeZone:()=>Sj,TimeZoneFromString:()=>Oee,TimeZoneNamed:()=>gj,TimeZoneNamedFromString:()=>Ree,TimeZoneOffset:()=>kee,Tree:()=>lre,Trim:()=>tee,Trimmed:()=>X$,TrueLiterals:()=>O$,Tuple:()=>rs,TupleWithRest:()=>N7,URL:()=>G$,URLFromString:()=>WX,URLSearchParams:()=>Y$,Uint8Array:()=>qs,Uint8ArrayFromBase64:()=>cee,Uint8ArrayFromBase64Url:()=>uee,Uint8ArrayFromHex:()=>tj,Undefined:()=>oA,UndefinedOr:()=>zS,Union:()=>Pe,UniqueArray:()=>D7,UniqueSymbol:()=>R7,UnixPathAddress:()=>Oj,UnixPathAddressFromString:()=>pte,Unknown:()=>Xm,UnknownFromJsonString:()=>JX,UrlParams:()=>SA,Void:()=>pd,annotate:()=>t7,annotateEncoded:()=>r7,annotateKey:()=>n7,asserts:()=>c7,brand:()=>WS,catchDecoding:()=>j7,catchDecodingWithContext:()=>k$,catchEncoding:()=>H7,catchEncodingWithContext:()=>R$,check:()=>B7,declare:()=>Ge,declareConstructor:()=>Cr,decode:()=>z7,decodeEffect:()=>u7,decodeExit:()=>d$,decodeOption:()=>l7,decodePromise:()=>p7,decodeResult:()=>d7,decodeSync:()=>Zm,decodeTo:()=>ee,decodeUnknownEffect:()=>xc,decodeUnknownExit:()=>l$,decodeUnknownOption:()=>f7,decodeUnknownPromise:()=>m$,decodeUnknownResult:()=>p$,decodeUnknownSync:()=>jS,encode:()=>W7,encodeEffect:()=>rA,encodeExit:()=>x$,encodeKeys:()=>P7,encodeOption:()=>h7,encodePromise:()=>g7,encodeResult:()=>x7,encodeSync:()=>nA,encodeTo:()=>aA,encodeUnknownEffect:()=>Qm,encodeUnknownExit:()=>h$,encodeUnknownOption:()=>m7,encodeUnknownPromise:()=>y$,encodeUnknownResult:()=>g$,encodeUnknownSync:()=>Ym,extendTo:()=>M7,fieldsAssign:()=>O7,flip:()=>QC,fromBrand:()=>$7,fromFormData:()=>ZX,fromJsonString:()=>mA,fromURLSearchParams:()=>QX,instanceOf:()=>gc,is:()=>a7,isBase64:()=>D$,isBase64Url:()=>sX,isBetween:()=>yc,isBetweenBigDecimal:()=>mee,isBetweenBigInt:()=>RX,isBetweenCodePoints:()=>PX,isBetweenDate:()=>vX,isBetweenLength:()=>fA,isBetweenProperties:()=>LX,isBetweenSize:()=>NX,isCapitalized:()=>lX,isEndingWith:()=>aX,isFinite:()=>pX,isGUID:()=>nX,isGreaterThan:()=>hX,isGreaterThanBigDecimal:()=>fee,isGreaterThanBigInt:()=>CX,isGreaterThanDate:()=>EX,isGreaterThanOrEqualTo:()=>L$,isGreaterThanOrEqualToBigDecimal:()=>lee,isGreaterThanOrEqualToBigInt:()=>B$,isGreaterThanOrEqualToDate:()=>IX,isIncluding:()=>cX,isInt:()=>VS,isInt32:()=>SX,isLessThan:()=>xX,isLessThanBigDecimal:()=>dee,isLessThanBigInt:()=>AX,isLessThanDate:()=>TX,isLessThanOrEqualTo:()=>gX,isLessThanOrEqualToBigDecimal:()=>pee,isLessThanOrEqualToBigInt:()=>kX,isLessThanOrEqualToDate:()=>wX,isLowercased:()=>fX,isMaxCodePoints:()=>_X,isMaxLength:()=>q$,isMaxProperties:()=>DX,isMaxSize:()=>FX,isMinCodePoints:()=>OX,isMinLength:()=>$$,isMinProperties:()=>UX,isMinSize:()=>MX,isMultipleOf:()=>yX,isNonEmpty:()=>H$,isPattern:()=>Xu,isPropertyNames:()=>BX,isSchema:()=>Ju,isSchemaError:()=>fd,isStartingWith:()=>iX,isStringBigInt:()=>X7,isStringFinite:()=>Y7,isStringSymbol:()=>eX,isTrimmed:()=>U$,isULID:()=>oX,isUUID:()=>rX,isUint32:()=>bX,isUncapitalized:()=>dX,isUnique:()=>dA,isUniqueKey:()=>z$,isUppercased:()=>uX,link:()=>Ne,linkDecoding:()=>md,make:()=>J,makeFilter:()=>Je,makeFilterGroup:()=>Q7,makeIsBetween:()=>oh,makeIsGreaterThan:()=>eh,makeIsGreaterThanOrEqualTo:()=>th,makeIsLessThan:()=>rh,makeIsLessThanOrEqualTo:()=>nh,makeIsMultipleOf:()=>mX,middlewareDecoding:()=>C$,middlewareEncoding:()=>A$,mutable:()=>L7,mutableKey:()=>b7,optional:()=>lr,optionalKey:()=>Gu,overrideToCodecIso:()=>ure,overrideToEquivalence:()=>Yte,overrideToFormatter:()=>Zte,readonlyKey:()=>E7,refine:()=>v$,required:()=>S7,requiredKey:()=>y7,resolveAnnotations:()=>hre,resolveAnnotationsKey:()=>xre,revealBottom:()=>e7,revealCodec:()=>o7,suspend:()=>w$,tag:()=>He,tagDefaultOmit:()=>G7,toCodecArrayFromSingle:()=>ore,toCodecIso:()=>rre,toCodecJson:()=>rf,toCodecStringTree:()=>nre,toDifferJsonPatch:()=>fre,toEncoded:()=>ld,toEncoderXml:()=>sre,toEquivalence:()=>Xte,toFormatter:()=>Qte,toIso:()=>ire,toIsoFocus:()=>cre,toIsoSource:()=>are,toJsonSchemaDocument:()=>tre,toRepresentation:()=>ere,toStandardJSONSchemaV1:()=>i7,toStandardSchemaV1:()=>s7,toTaggedUnion:()=>N$,toType:()=>oo,withArrayLengthConstraints:()=>qS,withConstructorDefault:()=>P$,withDecodingDefault:()=>F$,withDecodingDefaultKey:()=>cA,withDecodingDefaultType:()=>V7,withDecodingDefaultTypeKey:()=>K7});var rD=globalThis.BigInt;var nD=e=>e>rD(Number.MAX_SAFE_INTEGER)||e<rD(Number.MIN_SAFE_INTEGER)?_():N(Number(e));var lw=BigInt(0),zZ=BigInt(1),Ri=BigInt(1e3),tc=BigInt(1024),sD=[{symbol:"B",factor:zZ,names:["B","byte","bytes"]},{symbol:"kB",factor:Ri,names:["kB","kilobyte","kilobytes"]},{symbol:"MB",factor:Ri**BigInt(2),names:["MB","megabyte","megabytes"]},{symbol:"GB",factor:Ri**BigInt(3),names:["GB","gigabyte","gigabytes"]},{symbol:"TB",factor:Ri**BigInt(4),names:["TB","terabyte","terabytes"]},{symbol:"PB",factor:Ri**BigInt(5),names:["PB","petabyte","petabytes"]},{symbol:"EB",factor:Ri**BigInt(6),names:["EB","exabyte","exabytes"]},{symbol:"ZB",factor:Ri**BigInt(7),names:["ZB","zettabyte","zettabytes"]},{symbol:"YB",factor:Ri**BigInt(8),names:["YB","yottabyte","yottabytes"]},{symbol:"RB",factor:Ri**BigInt(9),names:["RB","ronnabyte","ronnabytes"]},{symbol:"QB",factor:Ri**BigInt(10),names:["QB","quettabyte","quettabytes"]}],WZ=[sD[0],{symbol:"KiB",factor:tc,names:["KiB","kibibyte","kibibytes"]},{symbol:"MiB",factor:tc**BigInt(2),names:["MiB","mebibyte","mebibytes"]},{symbol:"GiB",factor:tc**BigInt(3),names:["GiB","gibibyte","gibibytes"]},{symbol:"TiB",factor:tc**BigInt(4),names:["TiB","tebibyte","tebibytes"]},{symbol:"PiB",factor:tc**BigInt(5),names:["PiB","pebibyte","pebibytes"]},{symbol:"EiB",factor:tc**BigInt(6),names:["EiB","exbibyte","exbibytes"]},{symbol:"ZiB",factor:tc**BigInt(7),names:["ZiB","zebibyte","zebibytes"]},{symbol:"YiB",factor:tc**BigInt(8),names:["YiB","yobibyte","yobibytes"]}],KZ=[...sD,...WZ.slice(1)],VZ=new Map(KZ.flatMap(e=>e.names.map(t=>[t,e])));var dw=e=>e;var vl=e=>{throw new Error(`Invalid ByteSize: ${e}`)},iD=e=>!Number.isSafeInteger(e)||e<0?vl(`expected a non-negative safe integer, received ${e}`):dw(BigInt(e));var aD=e=>{let t=/^\s*(\d+)(?:\.(\d+))?\s*([A-Za-z]+)\s*$/.exec(e);if(t===null)return vl(`unsupported syntax ${JSON.stringify(e)}`);let r=VZ.get(t[3]);if(r===void 0)return vl(`unsupported unit ${JSON.stringify(t[3])}`);let n=t[2]??"",o=BigInt(10)**BigInt(n.length),s=BigInt(t[1]+n)*r.factor;return s%o!==lw?vl(`${JSON.stringify(e)} does not represent an integral number of bytes`):dw(s/o)},cD=xs(aD),xy=e=>{switch(typeof e){case"bigint":return e<lw?vl(`expected a non-negative bigint, received ${e}`):dw(e);case"number":return iD(e);case"string":return aD(e)}return vl(`unsupported input ${e}`)},pw=xs(xy),uD=e=>typeof e=="bigint"?xy(e):iD(e);var fD=e=>typeof e=="bigint"&&e>=lw;var gy=e=>e,lD=nD;var pD="~effect/Chunk";function dD(e,t,r,n,o){for(let s=t;s<Math.min(e.length,t+o);s++)r[n+s-t]=e[s];return r}var mD=[],hw=e=>Wr((t,r)=>{if(t.length!==r.length)return!1;let n=wu(t),o=wu(r);for(let s=0;s<n.length;s++)if(!e(n[s],o[s]))return!1;return!0}),ZZ=hw(Z),QZ={[pD]:{_A:e=>e},toString(){return`Chunk(${H(wu(this))})`},toJSON(){return{_id:"Chunk",values:pr(wu(this))}},[Qe](){return this.toJSON()},[ae](e){return Cl(e)&&ZZ(this,e)},[ie](){return ri(wu(this))},[Symbol.iterator](){switch(this.backing._tag){case"IArray":return this.backing.array[Symbol.iterator]();case"IEmpty":return mD[Symbol.iterator]();default:return wu(this)[Symbol.iterator]()}},pipe(){return V(this,arguments)}},xw=e=>{let t=Object.create(QZ);switch(t.backing=e,e._tag){case"IEmpty":{t.length=0,t.depth=0,t.left=t,t.right=t;break}case"IConcat":{t.length=e.left.length+e.right.length,t.depth=1+Math.max(e.left.depth,e.right.depth),t.left=e.left,t.right=e.right;break}case"IArray":{t.length=e.array.length,t.depth=0,t.left=la,t.right=la;break}case"ISingleton":{t.length=1,t.depth=0,t.left=la,t.right=la;break}case"ISlice":{t.length=e.length,t.depth=0,t.left=la,t.right=la;break}}return t},Cl=e=>O(e,pD),la=xw({_tag:"IEmpty"}),YZ=()=>la;var XZ=e=>xw({_tag:"ISingleton",a:e}),gw=e=>Cl(e)?e:t5(Ct(e)),mw=(e,t,r)=>{switch(e.backing._tag){case"IArray":{dD(e.backing.array,0,t,r,e.length);break}case"IConcat":{mw(e.left,t,r),mw(e.right,t,r+e.left.length);break}case"ISingleton":{t[r]=e.backing.a;break}case"ISlice":{dD(wu(e.backing.chunk),e.backing.offset,t,r,e.length);break}}};var e5=e=>{switch(e.backing._tag){case"IEmpty":return mD;case"IArray":return e.backing.array;default:{let t=new Array(e.length);return mw(e,t,0),e.backing={_tag:"IArray",array:t},e.left=la,e.right=la,e.depth=0,t}}},wu=e5;var t5=e=>e.length===0?YZ():e.length===1?XZ(e[0]):xw({_tag:"IArray",array:e});var hD=e=>e.length;var vu=pl,xD=hu,gD=GN,yD=JN,SD=ZN,bD=x0,ED=QN;var by=Qg;var Ey=g0;var yw=XN,ID=eU;var Sw=tU;var bw=y0,Ew=Fp,TD=S0;var wD=b0,tm=rU;var vD=Np;var CD=T0;var AD=oU;var Iw=v0;var Al=e=>r5(typeof e=="string"?n5.encode(e):e),Cu=e=>{let t=s5(e),r=t.length;if(r%4!==0)return re(new jo({kind:"Decode",module:"Base64",input:t,message:`Length must be a multiple of 4, but is ${r}`}));let n=t.indexOf("=");if(n!==-1&&(n<r-2||n===r-2&&t[r-1]!=="="))return re(new jo({kind:"Decode",module:"Base64",input:t,message:"Found a '=' character, but it is not at the end"}));try{let o=t.endsWith("==")?2:t.endsWith("=")?1:0,s=new Uint8Array(3*(r/4)-o);for(let i=0,a=0;i<r;i+=4,a+=3){let c=Iy(t.charCodeAt(i))<<18|Iy(t.charCodeAt(i+1))<<12|Iy(t.charCodeAt(i+2))<<6|Iy(t.charCodeAt(i+3));s[a]=c>>16,s[a+1]=c>>8&255,s[a+2]=c&255}return X(s)}catch(o){return re(new jo({kind:"Decode",module:"Base64",input:t,message:o instanceof Error?o.message:"Invalid input"}))}},kD=e=>Vr(Cu(e),t=>o5.decode(t)),r5=e=>{let t=e.length,r="",n;for(n=2;n<t;n+=3)r+=_s[e[n-2]>>2],r+=_s[(e[n-2]&3)<<4|e[n-1]>>4],r+=_s[(e[n-1]&15)<<2|e[n]>>6],r+=_s[e[n]&63];return n===t+1&&(r+=_s[e[n-2]>>2],r+=_s[(e[n-2]&3)<<4],r+="=="),n===t&&(r+=_s[e[n-2]>>2],r+=_s[(e[n-2]&3)<<4|e[n-1]>>4],r+=_s[(e[n-1]&15)<<2],r+="="),r},n5=new TextEncoder,o5=new TextDecoder,s5=e=>e.replace(/[\n\r]/g,""),_s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",rm=new Uint8Array(123).fill(255);for(let e=0;e<_s.length;e++)rm[_s.charCodeAt(e)]=e;rm[61]=0;var Iy=e=>{if(e>=rm.length||rm[e]===255)throw new TypeError(`Invalid character ${String.fromCharCode(e)}`);return rm[e]};var wy="~effect/HashMap",Ps=5,om=1<<Ps,i5=om/4,RD=om/2,a5=om-1,c5=e=>(e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),(e+(e>>>4)&252645135)*16843009>>>24),nm=(e,t)=>e>>>t&a5,rc=(e,t)=>1<<nm(e,t),Ty=(e,t)=>c5(e&t-1);function OD(e,t,r,n,o,s){if(t>32)throw new Error("HashMap: max depth exceeded");let i=rc(r,t),a=rc(o,t);if(i===a){let f=OD(e,t+Ps,r,n,o,s);return new Ru(e,i,[f])}let c=i|a,u=i>>>0<a>>>0?[n,s]:[s,n];return new Ru(e,c,u)}var u5=Be("HashMap"),_D=(e,t)=>he(G(e),G(t)),PD=e=>{let t=0;for(let r=0;r<e.length;r++){let n=e[r];n&&(t^=n.subtreeHash())}return t},Au=class{canEdit(t){return this.edit===t}subtreeHash(){let t=this._hash;if(t===void 0){let r=Hc;t=this.computeHash(),r===Hc&&(this._hash=t)}return t}},vw=class extends Au{_tag="EmptyNode";edit=0;get size(){return 0}get(t,r,n){return _()}has(t,r,n){return!1}set(t,r,n,o,s,i){return i.value=!0,new ku(t,n,o,s)}remove(t,r,n,o,s){return this}canEdit(t){return!1}computeHash(){return 0}},ku=class e extends Au{_tag="LeafNode";edit;hash;key;value;constructor(t,r,n,o){super(),this.edit=t,this.hash=r,this.key=n,this.value=o}get size(){return 1}get(t,r,n){return this.hash===r&&Z(this.key,n)?N(this.value):_()}has(t,r,n){return this.hash===r&&Z(this.key,n)}set(t,r,n,o,s,i){if(this.canEdit(t)&&(this._hash=void 0),this.hash===n&&Z(this.key,o))return Z(this.value,s)?this:this.canEdit(t)?(this.value=s,this):new e(t,n,o,s);if(i.value=!0,this.hash===n)return new Cw(t,n,[[this.key,this.value],[o,s]]);let a=rc(n,r),c=rc(this.hash,r);if(a===c)return new Ru(t,a,[this.set(t,r+Ps,n,o,s,i)]);let u=a|c,f=a>>>0<c>>>0?[new e(t,n,o,s),this]:[this,new e(t,n,o,s)];return new Ru(t,u,f)}remove(t,r,n,o,s){if(this.hash===n&&Z(this.key,o)){s.value=!0;return}return this}computeHash(){return _D(this.key,this.value)}},Cw=class e extends Au{_tag="CollisionNode";edit;hash;entries;constructor(t,r,n){super(),this.edit=t,this.hash=r,this.entries=n}get size(){return this.entries.length}get(t,r,n){if(this.hash!==r)return _();for(let[o,s]of this.entries)if(Z(o,n))return N(s);return _()}has(t,r,n){if(this.hash!==r)return!1;for(let[o]of this.entries)if(Z(o,n))return!0;return!1}set(t,r,n,o,s,i){if(this.canEdit(t)&&(this._hash=void 0),this.hash!==n)return i.value=!0,OD(t,r,this.hash,this,n,new ku(t,n,o,s));for(let a=0;a<this.entries.length;a++)if(Z(this.entries[a][0],o)){if(Z(this.entries[a][1],s))return this;if(this.canEdit(t))return this.entries[a]=[o,s],this;let c=[...this.entries];return c[a]=[o,s],new e(t,this.hash,c)}return i.value=!0,this.canEdit(t)?(this.entries.push([o,s]),this):new e(t,this.hash,[...this.entries,[o,s]])}remove(t,r,n,o,s){if(this.canEdit(t)&&(this._hash=void 0),this.hash!==n)return this;let i=this.entries.findIndex(([c])=>Z(c,o));if(i===-1)return this;if(s.value=!0,this.entries.length===1)return;if(this.entries.length===2){let c=this.entries[i===0?1:0];return new ku(t,this.hash,c[0],c[1])}if(this.canEdit(t))return this.entries.splice(i,1),this;let a=[...this.entries];return a.splice(i,1),new e(t,this.hash,a)}computeHash(){let t=0,r=this.entries;for(let n=0;n<r.length;n++)t^=_D(r[n][0],r[n][1]);return t}},Ru=class e extends Au{_tag="IndexedNode";edit;_size;bitmap;children;constructor(t,r,n){super(),this.edit=t,this.bitmap=r,this.children=n}get size(){return this._size===void 0&&(this._size=this.children.reduce((t,r)=>t+r.size,0)),this._size}get(t,r,n){let o=rc(r,t);if((this.bitmap&o)===0)return _();let s=Ty(this.bitmap,o);return this.children[s].get(t+Ps,r,n)}has(t,r,n){let o=rc(r,t);if((this.bitmap&o)===0)return!1;let s=Ty(this.bitmap,o);return this.children[s].has(t+Ps,r,n)}set(t,r,n,o,s,i){this.canEdit(t)&&(this._hash=void 0);let a=rc(n,r),c=Ty(this.bitmap,a);if((this.bitmap&a)!==0){let u=this.children[c],f=u.set(t,r+Ps,n,o,s,i);if(u===f)return this;if(this.canEdit(t))return this.children[c]=f,this;let p=[...this.children];return p[c]=f,new e(t,this.bitmap,p)}else{i.value=!0;let u=new ku(t,n,o,s),f=this.bitmap|a;if(this.canEdit(t))return this.children.splice(c,0,u),this.bitmap=f,this._size=void 0,this.children.length>RD?this.expand(t,f,this.children):this;let p=[...this.children];return p.splice(c,0,u),p.length>RD?this.expand(t,f,p):new e(t,f,p)}}remove(t,r,n,o,s){this.canEdit(t)&&(this._hash=void 0);let i=rc(n,r);if((this.bitmap&i)===0)return this;let a=Ty(this.bitmap,i),c=this.children[a],u=c.remove(t,r+Ps,n,o,s);if(!s.value)return this;if(u===void 0){let p=this.bitmap^i;if(p===0)return;if(this.children.length===2){let h=this.children[a===0?1:0];if(h._tag==="LeafNode")return h}if(this.canEdit(t))return this.children.splice(a,1),this.bitmap=p,this._size=void 0,this;let m=[...this.children];return m.splice(a,1),new e(t,p,m)}if(c===u)return this;if(this.canEdit(t))return this.children[a]=u,this;let f=[...this.children];return f[a]=u,new e(t,this.bitmap,f)}expand(t,r,n){let o=new globalThis.Array(om),s=0;for(let i=0;i<om;i++)(r&1<<i)!==0&&(o[i]=n[s++]);return new Aw(t,n.length,o)}computeHash(){return PD(this.children)}},Aw=class e extends Au{_tag="ArrayNode";edit;_size;count;children;constructor(t,r,n){super(),this.edit=t,this.count=r,this.children=n}get size(){return this._size===void 0&&(this._size=this.children.reduce((t,r)=>t+(r?.size??0),0)),this._size}get(t,r,n){let o=nm(r,t),s=this.children[o];return s?s.get(t+Ps,r,n):_()}has(t,r,n){let o=nm(r,t),s=this.children[o];return s?s.has(t+Ps,r,n):!1}set(t,r,n,o,s,i){this.canEdit(t)&&(this._hash=void 0);let a=nm(n,r),c=this.children[a];if(c){let u=c.set(t,r+Ps,n,o,s,i);if(c===u)return this;if(this.canEdit(t))return this.children[a]=u,this;let f=[...this.children];return f[a]=u,new e(t,this.count,f)}else{i.value=!0;let u=new ku(t,n,o,s);if(this.canEdit(t))return this.children[a]=u,this.count++,this._size=void 0,this;let f=[...this.children];return f[a]=u,new e(t,this.count+1,f)}}remove(t,r,n,o,s){this.canEdit(t)&&(this._hash=void 0);let i=nm(n,r),a=this.children[i];if(!a)return this;let c=a.remove(t,r+Ps,n,o,s);if(!s.value)return this;let u=this.count-(c?0:1);if(u<i5)return this.pack(t,i,c);if(a===c)return this;if(this.canEdit(t))return this.children[i]=c,c||(this.count=u),this._size=void 0,this;let f=[...this.children];return f[i]=c,new e(t,u,f)}pack(t,r,n){let o=[],s=0,i=1;for(let a=0;a<this.children.length;a++){let c=a===r?n:this.children[a];c&&(o.push(c),s|=i),i<<=1}return new Ru(t,s,o)}computeHash(){return PD(this.children)}},vy=class{stack;project;entries=[];index=0;constructor(t,r){this.stack=[t],this.project=r}next(){for(;;){if(this.index<this.entries.length){let r=this.entries[this.index++];return{done:!1,value:this.project(r[0],r[1])}}if(this.stack.length===0)return{done:!0,value:void 0};let t=this.stack.pop();switch(t._tag){case"LeafNode":{let r=t;return{done:!1,value:this.project(r.key,r.value)}}case"CollisionNode":{this.entries=t.entries,this.index=0;break}case"IndexedNode":case"ArrayNode":{let r=t.children;for(let n=r.length-1;n>=0;n--){let o=r[n];o&&this.stack.push(o)}}}}}[Symbol.iterator](){return this}},f5=(e,t)=>[e,t];var sm=class{[wy]=wy;_editable;_edit;_root;_size;constructor(t,r,n,o){this._editable=t,this._edit=r,this._root=n,this._size=o}get size(){return this._size}[Symbol.iterator](){return new vy(this._root,f5)}[ae](t){if(kw(t)){let r=t;if(this.size!==r.size)return!1;for(let[n,o]of this){let s=Ud(t,ND(n));if(fe(s)||!Z(o,s.value))return!1}return!0}return!1}[ie](){return _r(u5^this._root.subtreeHash())}[Qe](){return pr(this)}toString(){return`HashMap(${H(Array.from(this))})`}toJSON(){return{_id:"HashMap",values:Array.from(this).map(([t,r])=>[pr(t),pr(r)])}}pipe(){return V(this,arguments)}},MD=new vw,kw=e=>O(e,wy),Rw=()=>new sm(!1,0,MD,0);var FD=e=>{let t=MD,r=0,n={value:!1};for(let[o,s]of e){let i=G(o);n.value=!1,t=t.set(NaN,0,i,o,s,n),n.value&&r++}return new sm(!1,0,t,r)};var ND=d(2,(e,t)=>e._root.get(0,G(t),t));var Ow=d(2,(e,t)=>e._root.has(0,G(t),t));var l5=(e,t,r,n)=>{let o=e,s={value:!1},i=o._editable?o._edit:NaN,a=o._root.set(i,0,r,t,n,s);return o._editable?(o._root=a,s.value&&o._size++,e):o._root===a?e:new sm(!1,o._edit,a,o._size+(s.value?1:0))},_w=d(3,(e,t,r)=>l5(e,t,G(t),r)),Pw=e=>new vy(e._root,F);var UD=e=>e[Symbol.iterator](),Cy=e=>e.size;var Ay=kw;var Mw=FD;var m5=UD,im=e=>Array.from(m5(e)),LD=Cy;var am="~effect/HashSet",h5=Be(am),x5={[ie](){return _r(he(h5,G(Ry(this))))},[ae](e){return Fw(e)&&Oy(this)===Oy(e)&&jD(this,t=>$D(e,t))},[Symbol.iterator](){return Pw(Ry(this))},toString(){return`HashSet(${H(Array.from(this))})`},toJSON(){return{_id:"HashSet",values:pr(Array.from(this))}},[Qe](){return this.toJSON()},pipe(){return V(this,arguments)}},g5=e=>{let t=Object.create(x5);return t[am]=am,t.keyMap=e,t},Fw=e=>O(e,am),Ry=e=>e.keyMap;var BD=e=>{let t=Rw();for(let r of e)t=_w(t,r,!0);return g5(t)},$D=(e,t)=>Ow(Ry(e),t);var Oy=e=>Cy(Ry(e));var jD=(e,t)=>{for(let r of e)if(!t(r))return!1;return!0};var Nw=BD,_y=Fw;var HD=Oy;var Uw="~effect/http/Cookies",zD=e=>O(e,Uw),Dw="~effect/http/Cookies/Cookie",WD=e=>O(e,Dw),qD="~effect/http/Cookies/CookieError",Lw=class extends SP{},Ou=class e extends sr("CookiesError"){static fromReason(t,r){return new e({reason:new Lw({_tag:t,cause:r})})}[qD]=qD;get message(){return this.reason._tag}};var S5={[Uw]:Uw,...Ot,toJSON(){return{_id:"effect/Cookies",cookies:Dx(this.cookies,e=>e.toJSON())}},pipe(){return V(this,arguments)}},$w=e=>{let t=Object.create(S5);return t.cookies=e,t},jw=e=>{let t={};for(let r of e)B(t,r.name,r);return $w(t)},My=e=>{let t=typeof e=="string"?[e]:e,r=[];for(let n of t){let o=b5(n.trim());o&&r.push(o)}return jw(r)};function b5(e){let t=e.split(";").map(a=>a.trim()).filter(a=>a!=="");if(t.length===0)return;let r=t[0].indexOf("=");if(r===-1)return;let n=t[0].slice(0,r);if(!KD.test(n))return;let o=t[0].slice(r+1),s=C5(o);if(t.length===1)return Object.assign(Object.create(Bw),{name:n,value:s,valueEncoded:o});let i={};for(let a=1;a<t.length;a++){let c=t[a],u=c.indexOf("="),f=u===-1?c:c.slice(0,u).trim(),p=u===-1?void 0:c.slice(u+1).trim();switch(f.toLowerCase()){case"domain":{if(p===void 0)break;let m=p.trim().replace(/^\./,"");m&&(i.domain=m);break}case"expires":{if(p===void 0)break;let m=new Date(p);isNaN(m.getTime())||(i.expires=m);break}case"max-age":{if(p===void 0)break;let m=parseInt(p,10);isNaN(m)||(i.maxAge=fp(m));break}case"path":{if(p===void 0)break;p[0]==="/"&&(i.path=p);break}case"priority":{if(p===void 0)break;switch(p.toLowerCase()){case"low":i.priority="low";break;case"medium":i.priority="medium";break;case"high":i.priority="high";break}break}case"httponly":{i.httpOnly=!0;break}case"secure":{i.secure=!0;break}case"partitioned":{i.partitioned=!0;break}case"samesite":{if(p===void 0)break;switch(p.toLowerCase()){case"lax":i.sameSite="lax";break;case"strict":i.sameSite="strict";break;case"none":i.sameSite="none";break}break}}}return Object.assign(Object.create(Bw),{name:n,value:s,valueEncoded:o,options:Object.keys(i).length>0?i:void 0})}var E5=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,KD=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,I5=/^[\u0009\u0020-\u003a\u003c-\u007e\u0080-\u00ff]+$/,T5=/^[\u0020-\u003a\u003c-\u007e]+$/,Bw={[Dw]:Dw,...Ot,toJSON(){return{_id:"effect/Cookies/Cookie",name:this.name,value:this.value,options:this.options}}};function w5(e,t,r){let n=encodeURIComponent(t),o=VD(e,n,r);return o!==void 0?re(o):X(Object.assign(Object.create(Bw),{name:e,value:t,valueEncoded:n,options:r}))}function VD(e,t,r){if(!KD.test(e))return Ou.fromReason("InvalidCookieName");if(t&&!E5.test(t))return Ou.fromReason("InvalidCookieValue");if(r?.domain!==void 0&&!I5.test(r.domain))return Ou.fromReason("InvalidCookieDomain");if(r?.path!==void 0&&!T5.test(r.path))return Ou.fromReason("InvalidCookiePath");if(r?.maxAge!==void 0&&!Wn($e(r.maxAge)))return Ou.fromReason("CookieInfinityMaxAge")}var GD=(e,t,r)=>tu(w5(e,t,r));function v5(e){let t=VD(e.name,e.valueEncoded,e.options);if(t!==void 0)throw t;let r=e.name+"="+e.valueEncoded;if(e.options===void 0)return r;let n=e.options;if(n.maxAge!==void 0){let o=ui($e(n.maxAge));r+="; Max-Age="+Math.trunc(o)}if(n.domain!==void 0&&(r+="; Domain="+n.domain),n.path!==void 0&&(r+="; Path="+n.path),n.priority!==void 0)switch(n.priority){case"low":r+="; Priority=Low";break;case"medium":r+="; Priority=Medium";break;case"high":r+="; Priority=High";break}if(n.expires!==void 0&&(r+="; Expires="+n.expires.toUTCString()),n.httpOnly&&(r+="; HttpOnly"),n.secure&&(r+="; Secure"),n.partitioned&&(r+="; Partitioned"),n.sameSite!==void 0)switch(n.sameSite){case"lax":r+="; SameSite=Lax";break;case"strict":r+="; SameSite=Strict";break;case"none":r+="; SameSite=None";break}return r}var JD=e=>{let t={},r=Object.values(e.cookies);for(let n=0;n<r.length;n++){let o=r[n];B(t,o.name,o.value)}return t},ZD=e=>Object.values(e.cookies).map(v5);var C5=e=>{try{return decodeURIComponent(e)}catch{return e}};var _u=new WeakMap,QD=e=>{if(_u.has(e))return _u.get(e);throw new Error("Unable to get redacted value"+(e.label?` with label: "${e.label}"`:""))};var YD="~effect/Redacted",cm=e=>O(e,YD),Pu=(e,t)=>{let r=Object.create(k5);return t?.label&&(r.label=t.label),_u.set(r,e),r},k5={[YD]:{_A:e=>e},label:void 0,...wr,toJSON(){return this.toString()},toString(){return`<redacted${On(this.label)?":"+this.label:""}>`},[ie](){return G(_u.get(this))},[ae](e){return cm(e)&&Z(_u.get(this),_u.get(e))}},nc=QD;var XD=e=>Wr((t,r)=>e(nc(t),nc(r)));var qw=Symbol.for("~effect/http/Headers"),e1=e=>O(e,qw),um=Object.defineProperties(Object.create(null),{[qw]:{value:qw},[zc]:{value(e){return R5(this,Re(e,Ww))}},toJSON:{value(){return ho(this)}},[ae]:{value(e){return zw(this,e)}},[ie]:{value(){return qd(this)}},toString:{value:Ot.toString},[Qe]:{value:Ot[Qe]}}),Ny=e=>Object.assign(Object.create(um),e),zw=Z_(Qc()),kl=Object.create(um),Zo=e=>{if(e===void 0)return kl;if(Symbol.iterator in e){let r=Object.create(um);for(let[n,o]of e)r[n.toLowerCase()]=o;return r}let t=Object.create(um);for(let[r,n]of Object.entries(e))Array.isArray(n)?t[r.toLowerCase()]=n.join(", "):n!==void 0&&(t[r.toLowerCase()]=n);return t},t1=e=>Object.setPrototypeOf(e,um);var fm=d(3,(e,t,r)=>{let n=Ny(e);return n[t.toLowerCase()]=r,n}),r1=d(2,(e,t)=>Ny({...e,...Zo(t)})),Rl=d(2,(e,t)=>{let r=Ny(e);return Object.assign(r,t),r}),oc=d(2,(e,t)=>{let r=Ny(e);return delete r[t.toLowerCase()],r});var R5=d(2,(e,t)=>{let r={...e},n=o=>{if(typeof o=="string"){let s=o.toLowerCase();s in e&&(r[s]=Pu(e[s]))}else for(let s in e)s.search(o)!==-1&&(r[s]=Pu(e[s]))};if(Array.isArray(t))for(let o=0;o<t.length;o++)n(t[o]);else n(t);return r}),n1=(e,t)=>{for(let r=0;r<t.length;r++){let n=t[r];if(typeof n=="string"){if(n.toLowerCase()===e.toLowerCase())return!0}else if(e.search(n)!==-1)return!0}return!1},Ww=Ce("effect/Headers/CurrentRedactedNames",{defaultValue:()=>["authorization","cookie","set-cookie","x-api-key","AWSAccessKeyId","Signature","sig","X-Goog-Signature"]});var Kw="~effect/http/UrlParams",Vw=e=>O(e,Kw),O5={...wr,[Kw]:Kw,[Symbol.iterator](){return this.params[Symbol.iterator]()},toJSON(){return{_id:"UrlParams",params:Object.fromEntries(this.params)}},[ae](e){return Gw(this,e)},[ie](){return ri(this.params.flat())}},Ol=e=>{let t=Object.create(O5);return t.params=e,t},Mu=e=>{if(Vw(e))return e;let t=o1(e),r=[];for(let n=0;n<t.length;n++)if(Array.isArray(t[n][0])){let[o,s]=t[n];r.push([`${o[0]}[${o.slice(1).join("][")}]`,s])}else r.push(t[n]);return Ol(r)},o1=e=>{let t=typeof e[Symbol.iterator]=="function"?Ct(e):Object.entries(e),r=[];for(let[n,o]of t)if(Array.isArray(o))for(let s=0;s<o.length;s++)o[s]!==void 0&&r.push([n,String(o[s])]);else if(o!==null&&typeof o=="object"){let s=o1(o);for(let[i,a]of s)r.push([[n,...typeof i=="string"?[i]:i],a])}else o!==void 0&&r.push([n,String(o)]);return r},Gw=Wr((e,t)=>_5(e.params,t.params)),_5=eP(q_([Qc(),Qc()])),s1=Ol([]);var i1=d(2,(e,t)=>LI(e.params,([r])=>r===t).pipe(Lt(([,r])=>r)));var a1=d(2,(e,t)=>{let r=Mu(t).params.slice(),n=new Set;for(let o=0;o<r.length;o++)n.add(r[o][0]);for(let o=0;o<e.params.length;o++)n.has(e.params[o][0])||r.push(e.params[o]);return Ol(r)});var P5=e=>{let t={};for(let[r,n]of e.params)if(!Object.hasOwn(t,r))B(t,r,n);else{let o=t[r];typeof o=="string"?B(t,r,[o,n]):o.push(n)}return t},c1=P5;var Jw="~effect/Graph",Zw=e=>O(e,Jw),u1=e=>e;var M5=(e,t,r)=>(e==="directed"?t.source===r.source&&t.target===r.target:t.source===r.source&&t.target===r.target||t.source===r.target&&t.target===r.source)&&Z(t.data,r.data),F5=(e,t)=>e==="directed"?G(t):_r(he(G(t.data),N5(t.source,t.target))),N5=(e,t)=>he(0,G(e))+he(0,G(t)),U5=Be("Graph"),D5={[Jw]:{_N:e=>e,_E:e=>e},[Symbol.iterator](){return this.nodes[Symbol.iterator]()},[Qe](){return this.toJSON()},[ae](e){if(O(e,Jw)){let t=u1(e);if(this.nodes.size!==t.nodes.size||this.edges.size!==t.edges.size||this.type!==t.type)return!1;for(let[r,n]of this.nodes)if(!t.nodes.has(r)||!Z(n,t.nodes.get(r)))return!1;for(let[r,n]of this.edges){let o=t.edges.get(r);if(o===void 0||!M5(this.type,n,o))return!1}return!0}return!1},[ie](){let e=U5;e=e^Be(this.type),e=e^zt(this.nodes.size),e=e^zt(this.edges.size);for(let[t,r]of this.nodes)e^=he(G(t),G(r));for(let[t,r]of this.edges)e^=he(G(t),F5(this.type,r));return _r(e)},toJSON(){return{_id:"Graph",nodeCount:this.nodes.size,edgeCount:this.edges.size,type:this.type}},toString(){return`Graph(${this.type}, ${this.nodes.size}, ${this.edges.size})`},pipe(){return V(this,arguments)}},L5=(e,t)=>{let r=Object.create(D5);return r.type=e,r.mutable=t,r.transforming=!1,r.nodes=new Map,r.edges=new Map,r.adjacency=new Map,r.reverseAdjacency=new Map,r.nextNodeIndex=0,r.nextEdgeIndex=0,r.acyclic=N(!0),r};var lm=e=>{let t=u1(e);return{type:e.type,nodes:Array.from(t.nodes,([r,n])=>({index:r,data:n})).sort((r,n)=>r.index-n.index),edges:Array.from(t.edges,([r,n])=>({index:r,source:n.source,target:n.target,data:n.data})).sort((r,n)=>r.index-n.index)}},Dy=e=>{let t=L5(e.type,!1);for(let r of e.nodes)t.nodes.set(r.index,r.data),t.adjacency.set(r.index,[]),t.reverseAdjacency.set(r.index,[]);for(let r of e.edges)t.edges.set(r.index,{source:r.source,target:r.target,data:r.data}),t.adjacency.get(r.source).push(r.index),t.reverseAdjacency.get(r.target).push(r.index),e.type==="undirected"&&(t.adjacency.get(r.target).push(r.index),t.reverseAdjacency.get(r.source).push(r.index));return t.nextNodeIndex=e.nodes.length===0?0:e.nodes[e.nodes.length-1].index+1,t.nextEdgeIndex=e.edges.length===0?0:e.edges[e.edges.length-1].index+1,t.acyclic=_(),t};function da(e){return e.checks?e.checks[e.checks.length-1].annotations:e.annotations}function Ly(e){return t=>da(t)?.[e]}var ro="~structural",Fu="~identifier",dm="~sentinels",By="~constructor",f1=["title","description","default","examples","readOnly","writeOnly","format","contentEncoding","contentMediaType","contentSchema"],_l=Ly("identifier"),Qw=Ly(Fu),Yw=Ly("title");var pm=mo(e=>{let t=da(e)?.identifier;return typeof t=="string"?t:e.getExpected(pm)}),l1=new Set([dm,ro,"representation","arbitraryConstraint","toJsonSchema","toCode","toEquivalence","toFormatter","toCodec","toCodecJson","toCodecStringTree","toCodecIso","toCodecArbitrary"]);var ve=Symbol();var Dr=Mr,no=Dr(ve),nt=Dr(ve),mm=e=>e===ve?_():N(e),Xw=e=>e._tag==="None"?no:Dr(e.value);var xm="~effect/SchemaIssue/Issue";function tv(e){return O(e,xm)&&e[xm]===xm}function $5(e){return Object.hasOwn(e,"input")}var Ao=class{[xm]=xm;constructor(t,r){r?.reportInput===!0&&t!==ve&&(this.input=t)}},d1=class extends Ao{_tag="Filter";filter;issue;constructor(e,t,r,n){super(r,n),this.filter=e,this.issue=t}},p1=class extends Ao{_tag="Encoding";ast;issue;constructor(e,t,r,n){super(r,n),this.ast=e,this.issue=t}},At=class extends Ao{_tag="Pointer";path;issue;constructor(e,t){super(),this.path=e,this.issue=t}},Yt=class extends Ao{_tag="MissingKey";annotations;constructor(e){super(),this.annotations=e}},Nu=class extends Ao{_tag="UnexpectedKey";ast;constructor(e,t,r){super(t,r),this.ast=e}},Ft=class extends Ao{_tag="Composite";ast;issues;constructor(e,t,r,n){super(r,n),this.ast=e,this.issues=t}},at=class extends Ao{_tag="InvalidType";ast;constructor(e,t,r){super(t,r),this.ast=e}},le=class extends Ao{_tag="InvalidValue";annotations;constructor(e,t,r){super(t,r),this.annotations=e}};function tn(e,t,r,n,o){return new Ft(e,[new At([t],r)],n,o)}var gm=class extends Ao{_tag="Forbidden";annotations;constructor(e,t,r){super(t,r),this.annotations=e}},ym=class extends Ao{_tag="AnyOf";ast;issues;constructor(e,t,r,n){super(r,n),this.ast=e,this.issues=t}},m1=class extends Ao{_tag="OneOf";ast;successes;constructor(e,t,r,n){super(r,n),this.ast=e,this.successes=t}};function ev(e,t,r){if(tv(e))return e;if(typeof e=="string")return new le({message:e},t,r);let n=typeof e.issue=="string"?new le({message:e.issue},t,r):e.issue;return new At(e.path,n)}function h1(e,t,r){if(e!==void 0)return typeof e=="boolean"?e?void 0:new le(void 0,t,r):ev(e,t,r)}function x1(e,t,r,n){return Array.isArray(t)?bt(t)?t.length===1?ev(t[0],r,n):new Ft(e,Bo(t,o=>ev(o,r,n)),r,n):void 0:h1(t,r,n)}var g1=e=>{let t=Fl(e);if(t!==void 0)return t;switch(e._tag){case"InvalidType":return ic(pm(e.ast),e);case"InvalidValue":{let r=rv(e);if(r!==void 0)return ic(r,e);let n=$y(e);return n===void 0?"Expected a valid value":`Invalid data ${n}`}case"MissingKey":return"Missing key";case"UnexpectedKey":{let r=$y(e);return r===void 0?"Expected no excess property":`Unexpected key with value ${r}`}case"Forbidden":return"Forbidden operation";case"OneOf":{let r=$y(e);return r===void 0?"Expected exactly one member to match":`Expected exactly one member to match the input ${r}`}}},y1=e=>Fl(e.issue)??Fl(e);function S1(e){return t=>({issues:Ml(t,[],e?.leafHook??g1,e?.checkHook??y1)})}function $y(e){return $5(e)?H(e.input):void 0}function rv(e){let t=e.annotations?.expected;return typeof t=="string"?t:void 0}function ic(e,t){let r=$y(t);return r===void 0?`Expected ${e}`:`Expected ${e}, got ${r}`}function Ml(e,t,r,n){switch(e._tag){case"Filter":{let o=n(e);if(o!==void 0)return[{path:t,message:o}];if(e.issue._tag!=="InvalidValue")return Ml(e.issue,t,r,n);let s=rv(e.issue);return[{path:t,message:s===void 0?ic(nv(e.filter),e):ic(s,e.issue)}]}case"Encoding":return Ml(e.issue,t,r,n);case"Pointer":return Ml(e.issue,[...t,...e.path],r,n);case"Composite":return e.issues.flatMap(o=>Ml(o,t,r,n));case"AnyOf":return e.issues.length===0?[{path:t,message:Fl(e)??ic(pm(e.ast),e)}]:e.issues.flatMap(o=>Ml(o,t,r,n));default:return[{path:t,message:r(e)}]}}function nv(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(r=>nv(r)).join(" & ")}}function j5(){return e=>hm(e,"")}var b1=j5();function hm(e,t){let r;switch(e._tag){case"Filter":{let n=y1(e);if(n!==void 0)r=n;else{if(e.issue._tag!=="InvalidValue")return hm(e.issue,t);let o=rv(e.issue);r=o===void 0?ic(nv(e.filter),e):ic(o,e.issue)}break}case"Encoding":return hm(e.issue,t);case"Pointer":return hm(e.issue,t+Sx(e.path));case"Composite":case"AnyOf":{if(e._tag==="Composite"||e.issues.length>0)return e.issues.map(n=>hm(n,t)).join(`
25
- `);r=Fl(e)??ic(pm(e.ast),e);break}default:r=g1(e);break}return t?`${r}
26
- at ${t}`:r}function Fl(e){if(e._tag==="Pointer")return;if(e._tag==="Encoding")return Fl(e.issue);let r=(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 r=="string")return r}function Sm(e){let t;for(let r of e.reasons){if(!Ng(r)||!tv(r.error))return;t??=r.error}return t}function ko(e,t){let r=Sm(e);if(r===void 0)throw new Error(t,{cause:e});return r}var I1=e=>Al(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"),ov=e=>{let t=e.replace(/[\n\r]/g,""),r=t.length;if(r%4===1)return re(new jo({module:"Base64Url",kind:"Decode",input:t,message:`Length should be a multiple of 4, but is ${r}`}));if(!/^[-_A-Z0-9]*?={0,2}$/i.test(t))return re(new jo({module:"Base64Url",kind:"Decode",input:t,message:"Invalid input"}));let n=r%4===2?`${t}==`:r%4===3?`${t}=`:t;return n=n.replace(/-/g,"+").replace(/_/g,"/"),Cu(n)},T1=e=>Vr(ov(e),t=>H5.decode(t)),H5=new TextDecoder;var bm=e=>Object.assign(Object.create(oI),e);function z5(e){return v1((t,r)=>D(e(t,r)))}function jy(e){return z5((t,r)=>{let n={message:e(t)};return de(t)?new gm(n,t.value,r):new gm(n)})}var w1=jy(()=>"Encoding is not supported"),W5=bm({_tag:"Passthrough"});function Oi(){return W5}function Ie(e){return bm({_tag:"Transform",transform:e})}function rn(e){return bm({_tag:"TransformEffect",transform:e})}function Hy(e){return bm({_tag:"TransformOptional",transform:e})}function v1(e){return bm({_tag:"TransformOptionalEffect",transform:e})}function sv(){return Hy(()=>_())}function iv(e){return v1(t=>{let r=Fa(t,ei);return de(r)?I(r):Eu(e,N)})}function Uu(){return Ie(globalThis.String)}function qy(){return Ie(globalThis.Number)}function C1(){return Ie(globalThis.BigInt)}function av(){return Ie(e=>new globalThis.Date(e))}function A1(){return Ie(cU)}function k1(e){return rn((t,r)=>Go({try:()=>JSON.parse(t,e?.reviver),catch:()=>new le({expected:"a valid JSON string"},t,r)}))}function R1(e){return rn((t,r)=>Go({try:()=>{let n=JSON.stringify(t,e?.replacer,e?.space);if(n===void 0)throw new TypeError("Value cannot be represented as JSON");return n},catch:()=>new le({expected:"a JSON-serializable value"},t,r)}))}function cv(){return Ie(Al)}function zy(){return Ie(I1)}function Wy(){return Ie(Gx)}function O1(){return rn((e,t)=>Iu($0(Cu(e)),()=>new le({expected:"a valid Base64 string"},e,t)))}function _1(){return rn((e,t)=>zn(kD(e),{onFailure:()=>D(new le({expected:"a valid Base64 string"},e,t)),onSuccess:I}))}function P1(){return rn((e,t)=>zn(ov(e),{onFailure:()=>D(new le({expected:"a valid Base64Url string"},e,t)),onSuccess:I}))}function M1(){return rn((e,t)=>zn(T1(e),{onFailure:()=>D(new le({expected:"a valid Base64Url string"},e,t)),onSuccess:I}))}function F1(){return rn((e,t)=>zn(VI(e),{onFailure:()=>D(new le({expected:"a valid hexadecimal string"},e,t)),onSuccess:I}))}function N1(){return rn((e,t)=>zn(TP(e),{onFailure:()=>D(new le({expected:"a valid hexadecimal string"},e,t)),onSuccess:I}))}function U1(){return Ie(encodeURIComponent)}function D1(){return rn((e,t)=>{try{return I(globalThis.decodeURIComponent(e))}catch{return D(new le({expected:"a valid URI component"},e,t))}})}function L1(){return Ie(e=>H1(Array.from(e.entries())))}var K5=q1(e=>typeof e=="string"||typeof Blob<"u"&&e instanceof Blob);function B1(){return Ie(e=>{let t=new FormData;return typeof e=="object"&&e!==null&&K5(e).forEach(([n,o])=>{t.append(n,o)}),t})}function $1(){return Ie(e=>H1(Array.from(e.entries())))}var V5=q1(On);function j1(){return Ie(e=>typeof e=="object"&&e!==null?new URLSearchParams(V5(e)):new URLSearchParams)}function G5(e){if(e==="")return[""];let t=e.replace(/\[(.*?)\]/g,".$1"),r=t.split("."),n=t.startsWith(".")?1:0;return r.slice(n).map(o=>jx(o)?globalThis.Number(o):o)}var J5=20;function H1(e){let t={},r=new WeakSet,n=new WeakSet,o=new Map;e.forEach(([s,i])=>{let a=G5(s),c=t;for(let u=0;u<a.length;u++){let f=o.get(c),p=a[u]===""&&f!==void 0?f.length:a[u];f!==void 0&&typeof p=="number"&&(f.length=Math.max(f.length,p+1));let m=Object.hasOwn(c,p),h=m?c[p]:void 0;if(u===a.length-1){let x=o.get(h);if(x!==void 0)B(h,x.length++,i);else if(n.has(h))h.push(i);else if(m){let g=[h,i];n.add(g),B(c,p,g)}else B(c,p,i)}else{let x=a[u+1],g=typeof x=="number"||x==="";if(r.has(h)&&o.has(h)===g)c=h;else{let y={};r.add(y),g&&o.set(y,{parent:c,key:p,length:0}),B(c,p,y),c=y}}}});for(let[s,{key:i,length:a,parent:c}]of Array.from(o).reverse())c[i]===s&&a-Object.keys(s).length<=J5&&B(c,i,Object.assign(new Array(a),s));return t}function q1(e){return t=>{let r=[];function n(o,s){if(e(s))r.push([o,s]);else if(Array.isArray(s))s.every(e)?s.forEach(a=>{r.push([o,a])}):s.forEach((a,c)=>{n(`${o}[${c}]`,a)});else if(typeof s=="object"&&s!==null)for(let[i,a]of Object.entries(s))n(`${o}[${i}]`,a)}for(let[o,s]of Object.entries(t))n(o,s);return r}}var Ky=class extends Ra{_tag="Middleware";decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new Ky(this.encode,this.decode)}},Im="~effect/SchemaTransformation/Transformation",et=class extends Ra{[Im]=Im;_tag="Transformation";decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new et(this.encode,this.decode)}};function Z5(e){return O(e,Im)&&e[Im]===Im}var Vy=e=>Z5(e)?e:new et(e.decode,e.encode);function Xt(e){return new et(rn(e.decode),rn(e.encode))}function Fe(e){return new et(Ie(e.decode),Ie(e.encode))}function Gy(e){return new et(Hy(e.decode),Hy(e.encode))}function z1(){return new et(A1(),Oi())}var Q5=new et(Oi(),Oi());function Nl(){return Q5}var Ul=new et(qy(),Uu()),Jy=new et(C1(),Uu()),uv=new et(av(),Ie(mI)),W1=new et(av(),Ie(e=>e.getTime()));var fv=Xt({decode:(e,t)=>Zt(cD(e),{onNone:()=>D(new le({expected:"a valid ByteSize string"},e,t)),onSome:I}),encode:e=>I(`${e} ${e===BigInt(1)?"byte":"bytes"}`)}),K1=Xt({decode:(e,t)=>Zt(pw(e),{onNone:()=>D(new le({expected:"a non-negative bigint byte count"},e,t)),onSome:I}),encode:e=>I(gy(e))}),V1=Xt({decode:(e,t)=>Zt(pw(e),{onNone:()=>D(new le({expected:"a non-negative safe-integer byte count"},e,t)),onSome:I}),encode:(e,t)=>Zt(lD(e),{onNone:()=>D(new le({expected:"a ByteSize representable as a safe integer"},e,t)),onSome:I})}),Y5=e=>Jt(e)&&typeof e.message=="string",G1=e=>{let r=Object.hasOwn(e,"cause")?new Error(e.message,{cause:Z1(e.cause)}):new Error(e.message);return typeof e.name=="string"&&e.name!=="Error"&&(r.name=e.name),typeof e.stack=="string"&&(r.stack=e.stack),r},X5=e=>{try{let t=Wc(e);return t===void 0?H(e):JSON.parse(t)}catch{return H(e)}},eQ=(e,t,r)=>{let n={name:e.name,message:typeof e.message=="string"?e.message:""};return t?.includeStack&&typeof e.stack=="string"&&(n.stack=e.stack),!t?.excludeCause&&e.cause!==void 0&&(n.cause=r(e.cause)),n},J1=e=>{let t=new WeakSet,r=n=>{if(jO(n)){if(t.has(n))return"[Circular]";t.add(n);let o=eQ(n,e,r);return t.delete(n),o}return X5(n)};return r},Z1=e=>Y5(e)?G1(e):e,Q1=e=>Fe({decode:G1,encode:t=>J1(e)(t)}),Y1=e=>Fe({decode:Z1,encode:J1(e)});function X1(){return Fe({decode:AI,encode:sp})}function e2(){return Fe({decode:CI,encode:_n})}function t2(e){return Fe({decode:Xc,encode:e?.onNoneEncoding===null?sp:_n})}function r2(){return Gy({decode:N,encode:eu})}function n2(){return Gy({decode:e=>e.pipe(Fa(ei),N),encode:eu})}var lv=Xt({decode:(e,t)=>URL.canParse(e)?I(new URL(e)):D(new le({expected:"a valid URL string"},e,t)),encode:e=>I(e.href)});var dv=new et(O1(),cv()),o2=new et(_1(),cv()),s2=new et(M1(),zy()),i2=new et(N1(),Wy()),a2=new et(D1(),U1());function c2(e){return new et(k1(e??{}),R1(e))}var u2=new et(L1(),B1()),f2=new et($1(),j1());function cc(e){return t=>t._tag===e}var jl=cc("Declaration");var tQ=cc("Never");var Bl=cc("Literal"),mv=cc("UniqueSymbol");var Iv=cc("Arrays"),rQ=cc("Objects"),S2=cc("Union"),b2=cc("Suspend"),jt=class{to;transformation;constructor(e,t){this.to=e,this.transformation=t}},nn={},Yo=class{isOptional;isMutable;constructorDefault;annotations;constructor(e,t,r=void 0,n=void 0){this.isOptional=e,this.isMutable=t,this.constructorDefault=r,this.annotations=n}},l2="~effect/Schema",Gt=class{[l2]=l2;annotations;checks;encoding;context;constructor(t=void 0,r=void 0,n=void 0,o=void 0){this.annotations=t,this.checks=r,this.encoding=n,this.context=o}toString(){return`<${this._tag}>`}},uc=class extends Gt{_tag="Declaration";typeParameters;run;encodingChecks;encodingRun;constructor(e,t,r,n,o,s,i,a){super(r,n,o,s),this.typeParameters=e,this.run=t,this.encodingChecks=i,this.encodingRun=a}getParser(){let e;return(t,r)=>t===ve?no:(e??=this.run(this.typeParameters))(t,this,r)}_rebuild(e,t,r,n,o){let s=Lu(this.typeParameters,e);return s===this.typeParameters&&t===this.checks&&r===this.encodingChecks&&n===this.run&&o===this.encodingRun?this:new uc(s,n,this.annotations,t,void 0,this.context,r,o)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks,this.run,this.encodingRun)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks,this.encodingRun??this.run,this.run)}getExpected(){let e=this.annotations?.expected;return typeof e=="string"?e:"<Declaration>"}},nQ=class extends Gt{_tag="Null";getParser(){return sS(this,null)}getExpected(){return"null"}},Tv=new nQ;var oQ=class extends Gt{_tag="Undefined";getParser(){return sS(this,void 0)}toCodecJson(){return lt(this,[E2])}getExpected(){return"undefined"}},E2=new jt(Tv,new et(Ie(()=>{}),Ie(()=>null))),wv=new oQ;var sQ=class extends Gt{_tag="Void";getParser(){let e=Dr(void 0);return t=>t===ve?no:e}toCodecJson(){return lt(this,[E2])}getExpected(){return"void"}},I2=new sQ;var iQ=class extends Gt{_tag="Never";getParser(){return Ns(this,$O)}getExpected(){return"never"}},vv=new iQ,aQ=class extends Gt{_tag="Any";getParser(){return Ns(this,aI)}getExpected(){return"any"}},T2=new aQ,cQ=class extends Gt{_tag="Unknown";getParser(){return Ns(this,aI)}getExpected(){return"unknown"}},pa=new cQ,uQ=class extends Gt{_tag="ObjectKeyword";getParser(){return Ns(this,jd)}getExpected(){return"object | array | function"}},w2=new uQ,v2=class extends Gt{_tag="Enum";enums;constructor(e,t,r,n,o){super(t,r,n,o);for(let[,s]of e)if(typeof s=="number"&&!globalThis.Number.isFinite(s))throw new Error(`A numeric enum value must be finite, got ${H(s)}`);this.enums=e}getParser(){let e=new Set(this.enums.map(([,t])=>t));return Ns(this,t=>e.has(t))}toCodecStringTree(){if(this.enums.some(([e,t])=>typeof t=="number")){let e=Object.fromEntries(this.enums.map(([t,r])=>[globalThis.String(r),r]));return lt(this,[new jt(new Sn(Object.keys(e).map(t=>new Ln(t))),new et(Ie(t=>e[t]),Uu()))])}return this}getExpected(){return this.enums.map(([e,t])=>JSON.stringify(t)).join(" | ")}};function pv(e){return typeof e=="number"?`parts[${e}]`:e}function hv(e,t,r){if(r.has(e))return!0;if(e.encoding)throw new Error(`TemplateLiteral parts cannot have an encoding at ${pv(t)}`);let n;switch(e._tag){case"String":case"Number":case"BigInt":n=!0;break;case"Literal":n=!e.checks;break;case"TemplateLiteral":{let o=pv(t);n=!e.checks&&e.parts.every((s,i)=>hv(s,`${o}.parts[${i}]`,r));break}case"Union":{let o=pv(t);n=!e.checks&&e.types.every((s,i)=>hv(s,`${o}.types[${i}]`,r));break}default:return!1}return n&&r.add(e),n}var Cv=class extends Gt{_tag="TemplateLiteral";parts;encodedParts;literals;suffixLengths;constructor(e,t,r,n,o){super(t,r,n,o);let s=[],i=[],a=new Set;for(let u=0;u<e.length;u++){let f=e[u];if(!hv(f,u,a))throw new Error(`Invalid TemplateLiteral part ${f._tag}`);s.push(f),i.push(f._tag==="Literal"?globalThis.String(f.literal):void 0)}let c=new Array(s.length+1);c[s.length]=0;for(let u=s.length-1;u>=0;u--)c[u]=c[u+1]+(i[u]?.length??0);this.parts=e,this.encodedParts=s,this.literals=i,this.suffixLengths=c}getParser(e){let t=new Xo(!1,this.parts.map(Bv),[]),r=e(Kl(Ro,t,A2(this)));return(n,o)=>{if(n===ve)return no;let s=r(n,o);return s._tag==="Success"?nt:cr(s,{onSuccess:()=>n,onFailure:i=>new Ft(this,[i],n,o)})}}getExpected(){return"string"}matchPart(e,t){return X2(this,e,t)===void 0?void 0:e}};function C2(e){let t=mo(o=>{if(o._tag!=="Union")return o;let s=Lu(o.types,t);return(o.options?.mode??"anyOf")==="anyOf"&&s===o.types?o:new Sn(s,o.options===void 0?void 0:{...o.options,mode:"anyOf"},o.annotations,o.checks,void 0,o.context)}),r=new Cv(e.map(o=>t(Bn(o)))),n=new Xo(!1,e.map(Bv),[]);return Kl(r,n,A2(r))}function A2(e){return new et(rn((t,r)=>{let n=X2(e,t,r);return n?I(n):D(new le({expected:"a string matching template literal parts"},t,r))}),Ie(t=>t.join("")))}var k2=class extends Gt{_tag="UniqueSymbol";symbol;constructor(e,t,r,n,o){super(t,r,n,o),this.symbol=e}getParser(){return sS(this,this.symbol)}toCodecStringTree(){let e=globalThis.Symbol.keyFor(this.symbol);return lt(this,[new jt(e===void 0?vv:new Ln(globalThis.String(this.symbol)),rL.transformation)])}getExpected(){return globalThis.String(this.symbol)}},Ln=class extends Gt{_tag="Literal";literal;constructor(e,t,r,n,o){if(super(t,r,n,o),typeof e=="number"&&!globalThis.Number.isFinite(e))throw new Error(`A numeric literal must be finite, got ${H(e)}`);this.literal=e}getParser(){return sS(this,this.literal)}matchPart(e,t){return e===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return typeof this.literal=="bigint"?d2(this):this}toCodecStringTree(){return typeof this.literal=="string"?this:d2(this)}getExpected(){return typeof this.literal=="string"?JSON.stringify(this.literal):globalThis.String(this.literal)}};function d2(e){let t=globalThis.String(e.literal);return lt(e,[new jt(new Ln(t),new et(Ie(()=>e.literal),Ie(()=>t)))])}var fQ=class extends Gt{_tag="String";getParser(){return Ns(this,On)}matchPart(e,t){let r=this.checks;return r&&!t.disableChecks&&Us(r,e,void 0,this,t)?void 0:e}getExpected(){return"string"}},Ro=new fQ,lQ=class extends Gt{_tag="Number";getParser(){return Ns(this,Bd)}matchKey(e,t){return this._match(RQ,e,t)}matchPart(e,t){return this._match(Sv,e,t)}_match(e,t,r){if(!e.test(t))return;let n=globalThis.Number(t);return r.disableChecks||!this.checks?n:Us(this.checks,n,void 0,this,r)?void 0:n}toCodecJson(){return this.checks&&(xv(this.checks,"effect/schema/isFinite")||xv(this.checks,"effect/schema/isInt"))?this:lt(this,[IQ])}toCodecStringTree(){return this.toCodecJson()===this?lt(this,[OQ]):lt(this,[_Q])}getExpected(){return"number"}};function xv(e,t){return e.some(r=>r.annotations?.representation?.id===t||r._tag==="FilterGroup"&&xv(r.checks,t))}var Av=new lQ,dQ=class extends Gt{_tag="Boolean";getParser(){return Ns(this,px)}getExpected(){return"boolean"}},R2=new dQ,pQ=class extends Gt{_tag="Symbol";getParser(){return Ns(this,iI)}matchKey(e,t){return t.disableChecks||!this.checks?e:Us(this.checks,e,void 0,this,t)?void 0:e}toCodecStringTree(){return lt(this,[rL])}getExpected(){return"symbol"}},O2=new pQ,mQ=class extends Gt{_tag="BigInt";getParser(){return Ns(this,DO)}matchPart(e,t){if(!bv.test(e))return;let r=globalThis.BigInt(e);return t.disableChecks||!this.checks?r:Us(this.checks,r,void 0,this,t)?void 0:r}toCodecStringTree(){return lt(this,[MQ])}getExpected(){return"bigint"}},_2=new mQ,Xo=class extends Gt{_tag="Arrays";isMutable;elements;rest;encodingChecks;constructor(e,t,r,n,o,s,i,a){super(n,o,s,i),this.isMutable=e,this.elements=t,this.rest=r,this.encodingChecks=a;let c=!1;for(let u=0;u<t.length;u++)if(Lr(t[u]))c=!0;else if(c)throw new Error("A required element cannot follow an optional element. ts(1257)");if(c&&r.length>1)throw new Error("A required element cannot follow an optional element. ts(1257)");for(let u=1;u<r.length;u++)if(Lr(r[u]))throw new Error("An optional element cannot follow a rest element. ts(1266)")}getParser(e,t=e){let r=this,n,o,s=r.elements.length,i=Math.max(0,r.rest.length-1);function a(f,p){return p<s?n[p]:p>=f?o[p-f+1]:o[0]}let c=f=>{let{input:p,len:m,options:h}=f;if(r.rest.length===0&&m>s)for(let x=s;x<m;x++){let g=new Nu(r,p[x],h),y=new At([x],g);if(h.errors==="all")f.issues?f.issues.push(y):f.issues=[y];else return D(new Ft(r,[y],p,h))}return f.issues?D(new Ft(r,f.issues,p,h)):Dr(f.output)},u=(f,p)=>{let m=f.length,h={ast:r,getParser:a,input:f,len:m,tailThreshold:Math.max(s,m-i),output:new globalThis.Array(m),issues:void 0,options:p},x=r.rest.length===0?s:Math.max(m,s+i),g=p.concurrency===void 0?1:vp(p.concurrency),y=g===1?xQ(h,f,0,x):gQ(h,f,{concurrency:g,end:x});if(!y)return c(h);if(Xe(y))return ur(y,()=>c(h));let E=!0;return L(()=>E?(E=!1,A(y,()=>c(h))):u(f,p))};return(f,p)=>{if(f===ve)return no;try{return Array.isArray(f)?(n||(n=r.elements.map(m=>({ast:m,parser:t(m)})),o=r.rest.map(m=>({ast:m,parser:t(m)}))),u(f,p)):D(new at(r,f,p))}catch(m){return gn(m)}}}_rebuild(e,t,r){let n=Lu(this.elements,e),o=Lu(this.rest,e);return n===this.elements&&o===this.rest&&t===this.checks&&r===this.encodingChecks?this:new Xo(this.isMutable,n,o,this.annotations,t,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"}};function hQ(e,t,r,n){if(r._tag==="Failure")return Qy(e,e.ast,n,r);let o=r===nt?t:r[Se];if(o!==ve)e.output[n]=o;else{let s=e.getParser(e.tailThreshold,n);if(Lr(s.ast))return;let i=new At([n],new Yt(s.ast.context?.annotations));if(e.options.errors==="all")e.issues?e.issues.push(i):e.issues=[i];else return Jn(new Ft(e.ast,[i],e.input,e.options))}}var P2={onItem(e,t,r){let n=r<e.len?t:ve;return e.getParser(e.tailThreshold,r).parser(n,e.options)},step:hQ},xQ=Rg()(P2),gQ=Og()(P2),Qy=(e,t,r,n)=>{if(n.cause.reasons.length===0)return n;let o=Sm(n.cause);if(o===void 0)return ir(Ka(n.cause,i=>new Ft(t,[new At([r],i)],e.input,e.options)));let s=new At([r],o);if(e.options.errors==="all")e.issues?e.issues.push(s):e.issues=[s];else return Jn(new Ft(t,[s],e.input,e.options))},Xy="[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?";function _i(e,t,r=nn){let n,o;function s(i){switch(i._tag){case"String":case"TemplateLiteral":return(n??=Object.keys(e)).filter(a=>i.matchPart(a,r)!==void 0);case"Number":return(n??=Object.keys(e)).filter(a=>i.matchKey(a,r)!==void 0);case"Symbol":return(o??=Object.getOwnPropertySymbols(e)).filter(a=>Object.prototype.propertyIsEnumerable.call(e,a)&&i.matchKey(a,r)!==void 0);case"Union":return[...new Set(i.types.flatMap(s))];default:return[]}}return s(Lv(Bn(t)))}var kv=class{name;type;constructor(e,t){this.name=e,this.type=t}};function M2(e){switch(e._tag){case"String":case"Number":case"Symbol":case"TemplateLiteral":return!0;case"Union":return e.types.every(M2);default:return!1}}function F2(e){let t=ql(e);switch(t._tag){case"String":case"Number":case"Symbol":case"TemplateLiteral":return!0;case"Union":return t.types.every(F2);default:return!1}}function yQ(e){return M2(e)&&F2(e)}var Rv=class{parameter;type;constructor(e,t){if(!yQ(e))throw new Error(`Invalid index signature parameter ${e._tag}`);if(this.parameter=e,this.type=t,Lr(t)&&!Y2(t))throw new Error("Cannot use `Schema.optionalKey` with index signatures, use `Schema.optional` instead.")}},Tm=class extends Gt{_tag="Objects";propertySignatures;indexSignatures;encodingChecks;constructor(e,t,r,n,o,s,i){super(r,n,o,s),this.propertySignatures=e,this.indexSignatures=t,this.encodingChecks=i}getParser(e,t=e){let r=this,n=r.propertySignatures.length,o=r.indexSignatures.length;if(!n&&!o)return Ns(r,hx);let s,i,a=()=>(s||(s=r.propertySignatures.map(p=>({parser:t(p.type),name:p.name,type:p.type})),i=o?r.indexSignatures.map(p=>({is:p,parserKey:e(Lv(p.parameter)),parserValue:t(p.type)})):void 0),s),c=()=>{let p=new Set(r.propertySignatures.map(y=>typeof y.name=="number"?globalThis.String(y.name):y.name)),m=(y,E,b,v,T)=>{if(T._tag==="Failure")return Qy(y,r,E,T)??Kt;let S=T===nt?v:T[Se];if(b!==ve&&S!==ve){if(n&&(p.has(E)||p.has(typeof b=="number"?globalThis.String(b):b)))return Kt;B(y.out,b,S)}return Kt},h=(y,E,b,v)=>{if(!v){let k=b.parserKey(E,y.options);if(!Xe(k))return A(eo(k),C=>h(y,E,b,C));v=k}if(v._tag==="Failure")return Qy(y,r,E,v)??Kt;let T=v===nt?E:v[Se],S=y.input[E],w=b.parserValue(S,y.options);return Xe(w)?m(y,E,T,S,w):A(eo(w),k=>m(y,E,T,S,k))},x=(y,E,b)=>{let v=y.input[E],T=b.parserValue(v,y.options);return Xe(T)?m(y,E,E,v,T):A(eo(T),S=>m(y,E,E,v,S))},g=o?Og()({onItem:(y,[E,b])=>b.is.parameter===Ro?x(y,E,b):h(y,E,b),step:(y,E,b)=>b._tag==="Failure"?b:void 0}):void 0;return aw(function*(y,E){if(y===ve)return ve;if(!(typeof y=="object"&&y!==null&&!Array.isArray(y)))return yield*D(new at(r,y,E));a();let b=y,v={},T={ast:r,input:b,out:v,issues:void 0,options:E},S=E.errors==="all",w=E.onExcessProperty==="error",k=E.concurrency===void 0?1:vp(E.concurrency),C=o&&w?r.indexSignatures.map(R=>_i(b,R.parameter,E)):void 0;if(w){let R=C?new Set(p):p;if(C)for(let $ of C)for(let te of $)R.add(te);let M=Reflect.ownKeys(b);for(let $=0;$<M.length;$++){let te=M[$];if(!R.has(te)&&Object.prototype.propertyIsEnumerable.call(b,te)){let xe=new Nu(r,b[te],E),Le=new At([te],xe);if(S){T.issues?T.issues.push(Le):T.issues=[Le];continue}else return yield*D(new Ft(r,[Le],y,E))}}}if(n){let R=k===1?p2(T,s):SQ(T,s,{concurrency:k});R&&(yield*R)}if(o&&k===1)for(let R=0;R<o;R++){let M=i[R],$=M.is.parameter===Ro?x:h,te=C?.[R]??(M.is.parameter===Ro?Object.keys(b):_i(b,M.is.parameter,E));for(let xe=0;xe<te.length;xe++){let Le=$(T,te[xe],M);if(!Xe(Le))yield*Le;else if(Le._tag==="Failure")return yield*Le}}else if(g){let R=Qt();for(let $=0;$<o;$++){let te=i[$],xe=C?.[$]??(te.is.parameter===Ro?Object.keys(b):_i(b,te.is.parameter,E));for(let Le=0;Le<xe.length;Le++)R.push([xe[Le],te])}let M=g(T,R,{concurrency:k});M&&(yield*M)}return T.issues?yield*D(new Ft(r,T.issues,y,E)):v})};if(o)return c();let u,f=(p,m,h)=>{let x=s[m];return A(eo(h),g=>{let y=gv(p,x,g);if(y)return y;let E=()=>Dr(p.out),b=p2(p,s.slice(m+1));return b?ur(b,E):E()})};return(p,m)=>{if(p===ve)return no;if(m.errors==="all"||m.onExcessProperty!==void 0||m.concurrency!==void 0&&vp(m.concurrency)!==1)return(u??=c())(p,m);if(!(typeof p=="object"&&p!==null&&!Array.isArray(p)))return D(new at(r,p,m));let h=a(),x=p,g={},y={ast:r,input:x,out:g,issues:void 0,options:m};try{for(let E=0;E<h.length;E++){let b=h[E],v=b.name,T=Ll(x,v),S=T?x[v]:ve,w=b.parser(S,m);if(!Xe(w))return f(y,E,w);if(w===nt){T&&B(g,v,S);continue}let k=gv(y,b,w);if(k)return k}}catch(E){return gn(E)}return Dr(g)}}_rebuild(e,t,r,n){let o=Lu(this.propertySignatures,i=>{let a=e(i.type);return a===i.type?i:new kv(i.name,a)}),s=Lu(this.indexSignatures,i=>{let a=t(i.parameter),c=e(i.type);return a===i.parameter&&c===i.type?i:new Rv(a,c)});return o===this.propertySignatures&&s===this.indexSignatures&&r===this.checks&&n===this.encodingChecks?this:new Tm(o,s,this.annotations,r,void 0,this.context,n)}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"}};function gv(e,t,r){if(r._tag==="Failure")return Qy(e,e.ast,t.name,r);if(r===nt)return;let n=r[Se];if(n!==ve){B(e.out,t.name,n);return}if(delete e.out[t.name],!Lr(t.type)){let o=new At([t.name],new Yt(t.type.context?.annotations));if(e.options.errors==="all"){e.issues?e.issues.push(o):e.issues=[o];return}else return Jn(new Ft(e.ast,[o],e.input,e.options))}}var N2={onItem(e,t){if(!Ll(e.input,t.name))return t.parser(ve,e.options);let r=e.input[t.name];return B(e.out,t.name,r),t.parser(r,e.options)},step:gv},p2=Rg()(N2),SQ=Og()(N2);function Ov(e,t){return e?t?[...e,...t]:e:t}function eS(e,t,r){return new Tm(Reflect.ownKeys(e).map(n=>new kv(n,e[n].ast)),[],r,t)}function wm(e){return e.ast}function _v(e,t=void 0){return new Xo(!1,e.map(r=>r.ast),[],void 0,t)}function tS(e,t,r){return new Sn(e.map(wm),t,void 0,r)}function U2(e,t){if(e.encoding||t.some(s=>s.encoding))throw new Error("StructWithRest does not support encodings");let r=e.propertySignatures,n=e.indexSignatures,o=e.checks;for(let s of t){for(let i of s.propertySignatures)if(r.some(a=>a.name===i.name))throw new Error(`Duplicate identifier: ${JSON.stringify(i.name)}. ts(2300)`);r=r.concat(s.propertySignatures),n=n.concat(s.indexSignatures),o=Ov(o,s.checks)}return new Tm(r,n,void 0,o)}function D2(e,t){if(e.encoding)throw new Error("TupleWithRest does not support encodings");return new Xo(e.isMutable,e.elements,t,void 0,e.checks)}function L2(e){if(e.encoding)throw new Error("mutable does not support encodings");return new Xo(!0,e.elements,e.rest,e.annotations,e.checks,void 0,e.context,e.encodingChecks)}var Pv=jc(e=>{for(;;){if(b2(e))return pa;let t=e.encoding;if(!t)return e.recur?.(Pv,F)??e;if(t.some(r=>r.transformation._tag==="Middleware"&&r.transformation.decode!==F))return pa;e=t[t.length-1].to}});function B2(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(([,t])=>typeof t)));case"Literal":return[typeof e.literal];case"Union":return Array.from(new Set(e.types.flatMap(B2)));default:return["null","undefined","string","number","boolean","symbol","bigint","object","array","function"]}}function ac(e){switch(e._tag){default:return[];case"Declaration":{let t=e.annotations?.[dm];return Array.isArray(t)?t:[]}case"Objects":return e.propertySignatures.flatMap(t=>{let r=t.type;if(!Lr(r)){if(Bl(r))return[{key:t.name,literal:r.literal}];if(mv(r))return[{key:t.name,literal:r.symbol}]}return[]});case"Arrays":return e.elements.flatMap((t,r)=>{if(!Lr(t)){if(Bl(t))return[{key:r,literal:t.literal}];if(mv(t))return[{key:r,literal:t.symbol}]}return[]});case"Union":{if(e.types.length===0)return[];let t=e.types.map(r=>ac(Pv(r)));return t[0].filter(r=>t.every(n=>n.some(o=>o.key===r.key&&o.literal===r.literal)))}case"Suspend":return ac(e.thunk())}}var m2=new WeakMap,Zy=Object.freeze([]),h2=e=>e===null?"null":Array.isArray(e)?"array":typeof e,Ll=(e,t)=>t==="__proto__"?Object.hasOwn(e,t):t in e;function vm(e){let t=m2.get(e);if(t)return t;let r,n=0,o,s,i=!0,a=[];for(let f=0;f<e.length;f++){let p=e[f],m=Pv(p);if(tQ(m))continue;if(Bl(m)||mv(m)){s??=new Map;let x=Bl(m)?m.literal:m.symbol;a[f]=x;let g=s.get(x);g||s.set(x,g=[]),g.push(f)}else i=!1;let h=ac(m);if(h.length){r??=new Map,n++;for(let{key:x,literal:g}of h){let y=r.get(x);y||r.set(x,y=[new Map,new Set]),y[1].add(f);let E=y[0].get(g);E||y[0].set(g,E=new Set),E.add(f)}}else{o??={};let x=B2(m);for(let g of x)(o[g]??=[]).push(f)}}let c={},u=f=>c[f]??=Object.freeze(o?.[f]??Zy);if(i&&s)s.forEach(Object.freeze),t=f=>s.get(f)??Zy;else if(r?.size===1&&!o){let[f,[p]]=r.entries().next().value,m=new Map;for(let[x,g]of p)m.set(x,Object.freeze(Array.from(g)));let h=Object.freeze(e.map((x,g)=>g));t=(x,g)=>{if(jd(x)){let y=Ll(x,f)?x[f]:void 0;if(y!==void 0)return m.get(y)??Zy;if(g)return h}return Zy}}else if(r){let f;for(let p of r)(!f||p[1][0].size>f[1][0].size)&&p[1][1].size===n&&(f=p);t=(p,m)=>{let h=h2(p);if(!jd(p))return u(h);let x=new Set(o?.[h]),g;if(f){let[y,[E]]=f,b=Ll(p,y),v=b?p[y]:void 0;if(b&&(!m||v!==void 0)){let T=E.get(v);if(!T)return u(h);for(let S of T)x.add(S);g=y}}if(g===void 0)for(let[y,[E,b]]of r){let v=Ll(p,y),T=v?p[y]:void 0;if(v&&(!m||T!==void 0)){let S=E.get(T);if(S)for(let w of S)x.add(w)}else if(m)for(let S of b)x.add(S)}for(let[y,[E,b]]of r){if(y===g)continue;let v=Ll(p,y),T=v?p[y]:void 0;if(v&&(!m||T!==void 0)){let S=E.get(T);for(let w of x)b.has(w)&&!S?.has(w)&&x.delete(w)}}return Array.from(x).sort((y,E)=>y-E)}}else t=f=>{let p=u(h2(f));return s?p.filter(m=>a[m]===void 0||a[m]===f):p};return m2.set(e,t),t}var Sn=class extends Gt{_tag="Union";types;options;encodingChecks;constructor(e,t,r,n,o,s,i){super(r,n,o,s),this.types=e,this.options=t,this.encodingChecks=i}getParser(e,t){let r=this,n=t!==void 0,o=[],s=a=>o[a]??=e(r.types[a]),i;return(a,c)=>{if(a===ve)return no;let u=(i??=vm(r.types))(a,n);if(u.length===0)return D(new ym(r,[],a,c));if(u.length===1){let f=s(u[0])(a,c);return f._tag==="Success"?f:Xe(f)?$2(r,f.cause,a,c):bQ(r,f,a,c)}return j2(r,s,u,a,c)}}_rebuild(e,t,r){let n=Lu(this.types,e);return n===this.types&&t===this.checks&&r===this.encodingChecks?this:new Sn(n,this.options,this.annotations,t,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 r of this.types){let n=r.matchPart(e,t);if(n!==void 0)return n}}getExpected(e){let t=this.annotations?.expected;if(typeof t=="string")return t;if(this.types.length===0)return"never";let r=this.types.map(n=>{let o=Bn(n);switch(o._tag){case"Arrays":{let s=o.elements.filter(Bl);if(s.length>0)return`${g2(o.isMutable)}[ ${s.map(i=>e(i)+y2(i.context?.isOptional)).join(", ")}, ... ]`;break}case"Objects":{let s=o.propertySignatures.filter(i=>Bl(i.type));if(s.length>0)return`{ ${s.map(i=>`${g2(i.type.context?.isMutable)}${ni(i.name)}${y2(i.type.context?.isOptional)}: ${e(i.type)}`).join(", ")}, ... }`;break}}return e(o)});return Array.from(new Set(r)).join(" | ")}};function $2(e,t,r,n){let o=Sm(t);return o?Jn(new ym(e,[o],r,n)):ir(t)}function bQ(e,t,r,n){return rt(t,o=>$2(e,o,r,n))}function j2(e,t,r,n,o){let s={ast:e,parser:t,input:n,out:void 0,successes:e.options?.mode==="oneOf"?[]:void 0,issues:void 0,options:o},i=EQ(s,r);if(!i)return s.out?s.out:D(new ym(e,s.issues??[],n,o));if(Xe(i))return x2(i,s);let a=!0;return L(()=>a?(a=!1,x2(i,s)):j2(e,t,r,n,o))}function x2(e,t){return ur(e,r=>t.out===nt?I(t.input):t.out?t.out:D(new ym(t.ast,t.issues??[],t.input,t.options)))}var EQ=Rg()({onItem(e,t){return e.parser(t)(e.input,e.options)},step(e,t,r){if(r._tag==="Failure"){let n=Sm(r.cause);if(n===void 0)return r;e.issues?e.issues.push(n):e.issues=[n]}else{if(e.out&&e.successes)return e.successes.push(e.ast.types[t]),Jn(new m1(e.ast,e.successes,e.input,e.options));if(e.out=r,e.successes)e.successes.push(e.ast.types[t]);else return Kt}}}),H2=new Sn([new Ln("Infinity"),new Ln("-Infinity"),new Ln("NaN")]);function g2(e){return e?"":"readonly "}function y2(e){return e?"?":""}var Mv=class extends Gt{_tag="Suspend";thunk;constructor(e,t,r,n,o){if(r)throw new Error("Cannot add checks to Suspend");super(t,void 0,n,o);let s;this.thunk=()=>s??=e()}getParser(e){let t;return(r,n)=>(t??=e(this.thunk()))(r,n)}recur(e){return new Mv(()=>e(this.thunk()),this.annotations,void 0,void 0,this.context)}getExpected(e){return e(this.thunk())}},Yy=class extends Ra{_tag="Filter";run;annotations;aborted;constructor(e,t=void 0,r=!1){super(),this.run=e,this.annotations=t,this.aborted=r}annotate(e){return new Yy(this.run,{...this.annotations,...e},this.aborted)}abort(){return new Yy(this.run,this.annotations,!0)}and(e,t){return new Du([this,e],t)}},Du=class extends Ra{_tag="FilterGroup";checks;annotations;constructor(e,t=void 0){super(),this.checks=e,this.annotations=t}annotate(e){return new Du(this.checks,{...this.annotations,...e})}and(e,t){return new Du([this,e],t)}};function rS(e,t,r=!1){return new Yy((n,o,s)=>x1(o,e(n,o,s),n,s),t,r)}function nS(e,t){return new Yy((r,n,o)=>e(r)?void 0:new le(void 0,r,o),t,!0)}function Fv(e){return rS(t=>globalThis.Number.isFinite(t),{expected:"a finite number",representation:{id:"effect/schema/isFinite",payload:null},toJsonSchema:()=>({type:"number"}),toCode:()=>({runtime:"Schema.isFinite()"}),arbitraryConstraint:{number:"finite"},...e})}var Nv=Pi(Av,[Fv()]),IQ=new jt(new Sn([Nv,H2]),new et(qy(),Ie(e=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function Cm(e,t){let r=new globalThis.RegExp(e),n={source:r.source,flags:r.flags};return rS(o=>(r.lastIndex=0,r.test(o)),{expected:`a string matching the RegExp ${n.source}`,representation:{id:"effect/schema/isPattern",payload:n},toJsonSchema:()=>[{},!0],arbitraryConstraint:{patterns:[n]},...t})}var yv=new WeakMap;function Am(e,t){let r=Object.assign(Object.create(Object.getPrototypeOf(e)),e,t);return Reflect.ownKeys(t).every(n=>n==="context"||n==="encoding")&&yv.set(r,Hl(e)),r}function Hl(e){let t=yv.get(e);if(t!==void 0)return t;if(e.encoding===void 0)return e;let r=Object.assign(Object.create(Object.getPrototypeOf(e)),e,{encoding:void 0});return yv.set(e,r),r}function lt(e,t){return e.encoding===t?e:Am(e,{encoding:t})}function Bu(e,t){if(e.context===t)return e;let r=Hl(e);return r.context===t&&r.encoding===e.encoding?r:Am(e,{context:t})}function ql(e){return e.encoding?ql(e.encoding[e.encoding.length-1].to):e}function Fs(e,t){if(e.checks){let r=e.checks[e.checks.length-1];return q2(e,$x(e.checks.slice(0,-1),r.annotate(t)))}return Am(e,{annotations:{...e.annotations,...t}})}function q2(e,t){if(e._tag==="Suspend"&&t)throw new Error("Cannot add checks to Suspend");return e.checks===t?e:Am(e,{checks:t})}function Pi(e,t){return q2(e,Ov(e.checks,t))}function fc(e,t){let r=t(e.to);return r===e.to?e:new jt(r,e.transformation)}function z2(e,t){let r=e,n=r[r.length-1],o=fc(n,t);return o===n?e:$x(e.slice(0,e.length-1),o)}function oS(e){return t=>t.encoding?lt(t,z2(t.encoding,e)):t}function zl(e,t){return oS(r=>Bu(r,t))(e)}function ma(e,t){function r(n){if(n.encoding){let o=n.encoding[n.encoding.length-1];return t?.stopAt?.(o)?n:lt(n,z2(n.encoding,r))}return e(n)}return jc(r)}function W2(e,t){return Uv(e,t,Nt(e))}function K2(e,t){return Uv(Bn(e),t,e)}function Uv(e,t,r){let n=new jt(e,t);return lt(r,r.encoding?[...r.encoding,n]:[n])}function Lu(e,t){let r;for(let n=0;n<e.length;n++){let o=e[n],s=t(o);if(r)r[n]=s;else if(s!==o){r=new Array(e.length);for(let i=0;i<n;i++)r[i]=e[i];r[n]=s}}return r??e}function Wl(e,t){let r=e.context?new Yo(e.context.isOptional,e.context.isMutable,e.context.constructorDefault,{...e.context.annotations,...t}):new Yo(!1,!1,void 0,t);return Bu(e,r)}var $u=jc(e=>{let t=e.context?e.context.isOptional===!1?new Yo(!0,e.context.isMutable,e.context.constructorDefault,e.context.annotations):e.context:new Yo(!0,!1);return TQ(Bu(e,t))}),TQ=oS($u),V2=mo(e=>$u(new Sn([e,wv]))),Dv=jc(e=>{let t=e.context?e.context.isMutable===!1?new Yo(e.context.isOptional,!0,e.context.constructorDefault,e.context.annotations):e.context:new Yo(!1,!0);return wQ(Bu(e,t))}),wQ=oS(Dv);function G2(e,t){let r=e.context?new Yo(e.context.isOptional,e.context.isMutable,t,e.context.annotations):new Yo(!1,!1,t);return Bu(e,r)}function Kl(e,t,r){return Uv(e,r,t)}function vQ(e){let t=[],r=[];function n(o){switch(o._tag){case"Literal":mx(o.literal)&&!t.includes(o.literal)&&t.push(o.literal);return;case"UniqueSymbol":t.includes(o.symbol)||t.push(o.symbol);return;case"Never":return;case"Union":for(let s=0;s<o.types.length;s++)n(o.types[s]);return;default:r.push(o)}}return n(e),{literals:t,parameters:r}}function J2(e,t){let{literals:r,parameters:n}=vQ(e);return new Tm(r.map(o=>new kv(o,t)),n.map(o=>new Rv(o,t)))}function Lr(e){return e.context?.isOptional??!1}function Z2(e){return e.context?.isMutable??!1}function Q2(e){return e.annotations?.[ro]===!0||e._tag==="FilterGroup"&&e.checks.every(Q2)}function CQ(e){function t(n){return Q2(n)?[n]:n._tag==="FilterGroup"?n.checks.flatMap(t):[]}let r=e.flatMap(t);return Gr(r)?r:void 0}function AQ(e){let t=!0;function r(n){return t=t&&!n.encoding&&!b2(n),t&&"recur"in n&&n.recur(r),n}return"recur"in e&&e.recur(r),t}var Nt=jc(e=>{let t=Hl(e);if(t!==e){let n=Nt(t);return n===t&&e.encoding===void 0?e:Bu(n,e.context)}let r="recur"in e?e.recur(Nt):e;if("encodingChecks"in r&&r.encodingChecks){let n=AQ(e)?r.encodingChecks:Iv(r)||rQ(r)||jl(r)&&r.typeParameters.length>0?CQ(r.encodingChecks):void 0;return Am(r,{encodingChecks:void 0,checks:Ov(r.checks,n)})}return r}),Bn=jc(e=>Nt(Oo(e)));function kQ(e,t){let r=t,n=r.length,o=r[n-1],s=[new jt(Oo(lt(e,void 0)),r[0].transformation.flip())];for(let a=1;a<n;a++)s.unshift(new jt(Oo(r[a-1].to),r[a].transformation.flip()));let i=Oo(o.to);return i.encoding?lt(i,[...i.encoding,...s]):lt(i,s)}var Oo=mo(e=>{if(e.encoding)return kQ(e,e.encoding);let t=Hl(e);if(t!==e){let r=Oo(t);return r===t?e:Bu(r,e.context)}return"flip"in e?e.flip(Oo):"recur"in e?e.recur(Oo):e});function Y2(e){switch(e._tag){case"Undefined":return!0;case"Union":return e.types.some(Y2);default:return!1}}function sS(e,t){let r=t===0?nt:Dr(t);return(n,o)=>n===ve?no:n===t?r:D(new at(e,n,o))}function Ns(e,t){return(r,n)=>r===ve?no:t(r)?nt:D(new at(e,r,n))}function X2(e,t,r){let n=e.encodedParts,o=e.literals,s=t.length;for(let u=0;u<o.length;u++){let f=o[u];if(f&&!t.includes(f))return}if(e.suffixLengths[0]>s)return;let i=new Array(n.length),a;function c(u,f){if(u===n.length)return f===s;if(a?.has(u*(s+1)+f))return!1;let p=n[u];if(u===n.length-1){let m=t.slice(f);if(p.matchPart(m,r)!==void 0)return i[u]=m,!0}else if(p._tag==="Literal"){let m=o[u];if(t.startsWith(m,f)&&c(u+1,f+m.length))return i[u]=m,!0}else{let m=s-e.suffixLengths[u+1],h=o[u+1],x=h===void 0?m:t.lastIndexOf(h,m);for(;x>=f;){let g=t.slice(f,x);if(p.matchPart(g,r)!==void 0&&c(u+1,x))return i[u]=g,!0;if(x===0)break;x=h===void 0?x-1:t.lastIndexOf(h,x-1)}}return a??=new Set,a.add(u*(s+1)+f),!1}return c(0,0)?i:void 0}var Lv=ma(e=>{switch(e._tag){default:return e;case"Number":return e.toCodecStringTree();case"Union":return e.recur(Lv)}}),iS=ma(e=>{switch(e._tag){default:return e;case"Symbol":case"UniqueSymbol":return e.toCodecStringTree();case"Union":return e.recur(iS)}}),Bv=ma(e=>{switch(e._tag){default:return e;case"Number":case"Literal":case"BigInt":return e.toCodecStringTree();case"Union":return e.recur(Bv)}}),eL="[\\s\\S]*?",Sv=new globalThis.RegExp(`^${Xy}$`),RQ=new globalThis.RegExp(`^(?:${Xy}|Infinity|-Infinity|NaN)$`);function $v(e){return Cm(Sv,{expected:"a string representing a finite number",representation:{id:"effect/schema/isStringFinite",payload:null},toJsonSchema:()=>({pattern:Sv.source}),...e})}var tL=Pi(Ro,[$v()]),OQ=new jt(tL,Ul),_Q=new jt(new Sn([tL,H2]),Ul),PQ="-?\\d+",bv=new globalThis.RegExp(`^${PQ}$`);function jv(e){return Cm(bv,{expected:"a string representing a bigint",representation:{id:"effect/schema/isStringBigInt",payload:null},toJsonSchema:()=>({pattern:bv.source}),...e})}var Hv=Pi(Ro,[jv({expected:"a string representing a bigint"})]),MQ=new jt(Hv,Jy),FQ="Symbol\\(([\\s\\S]*)\\)",Ev=new globalThis.RegExp(`^${FQ}$`),NQ=Pi(Ro,[qv()]),rL=new jt(NQ,new et(Ie(e=>globalThis.Symbol.for(Ev.exec(e)[1])),rn((e,t)=>globalThis.Symbol.keyFor(e)!==void 0?I(globalThis.String(e)):D(new gm({message:"cannot serialize to string, Symbol is not registered"},e,t)))));function qv(e){return Cm(Ev,{expected:"a string representing a symbol",representation:{id:"effect/schema/isStringSymbol",payload:null},toJsonSchema:()=>({pattern:Ev.source}),...e})}function Us(e,t,r,n,o){for(let s=0;s<e.length;s++){let i=e[s];if(i._tag==="FilterGroup"){if(r=Us(i.checks,t,r,n,o),r&&(o.errors!=="all"||r[r.length-1].filter.aborted))return r}else{let a=i.run(t,n,o);if(a){let c=new d1(i,a,t,o);if(r?r.push(c):r=[c],o.errors!=="all"||i.aborted)return r}}}return r}function nL(e,t){let r=Us(e,t,void 0,pa,{errors:"all"});if(r){let n=new Ft(pa,r);return re(n)}return X(t)}function oL(e){if(!jl(e))return;let t=e.annotations?.[By];return or(t)?t(e.typeParameters):void 0}function UQ(e){return e===null||typeof e=="string"||typeof e=="boolean"||typeof e=="number"&&globalThis.Number.isFinite(e)}function DQ(e){return e===void 0||typeof e=="string"}function sL(e,t){let r=new WeakMap,n=[];e:for(;;){if(typeof e!="object"||e===null){if(!t(e))return!1}else{let o=e,s=r.get(o);if(s===!1)return!1;if(s===void 0){let i=Array.isArray(o);if(!i){let a=Object.getPrototypeOf(o);if(a!==null&&a!==Object.prototype&&Object.getPrototypeOf(a)!==null)return!1}r.set(o,!1),n.push({value:o,keys:i?o.length:Object.keys(o),index:0})}}for(;n.length>0;){let o=n[n.length-1],s=o.keys;if(typeof s=="number"){if(o.index<s){e=o.value[o.index++];continue e}}else if(o.index<s.length){e=o.value[s[o.index++]];continue e}r.set(o.value,!0),n.pop()}return!0}}function Vl(e){return sL(e,UQ)}var $l=new uc([],()=>(e,t,r)=>Vl(e)?nt:D(new at(t,e,r)),{representation:{id:"effect/schema/Json",payload:null},expected:"JSON value",toCodecJson:()=>{},toCodecStringTree:()=>Wv}),iL=Fs($l,{representation:{id:"effect/schema/MutableJson",payload:null}}),zv=new jt($l,Nl()),aL=new jt(new Sn([new Xo(!1,[],[$l]),new Tm([],[new Rv(Ro,$l)])]),Nl());function LQ(e){return sL(e,DQ)}var BQ=new uc([],()=>(e,t,r)=>LQ(e)?nt:D(new at(t,e,r)),{expected:"StringTree",toCodecStringTree:()=>{}}),Wv=new jt(BQ,Nl());var aS=(e,t,r)=>e===nt?r(t):ur(e,r);function uL(e){if(e._tag==="Middleware")return(r,n,o)=>{let s=r===nt?e.decode(Dr(mm(n)),o):e.decode(Eu(r,mm),o);return cL(s)};let t=e.decode;switch(t._tag){case"Passthrough":return(r,n)=>r===nt?Dr(n):r;case"Transform":{let r=n=>n===ve?no:Dr(t.transform(n));return(n,o)=>aS(n,o,r)}case"TransformOptional":{let r=n=>Xw(t.transform(mm(n)));return(n,o)=>aS(n,o,r)}case"TransformEffect":return(r,n,o)=>aS(r,n,s=>s===ve?no:t.transform(s,o));case"TransformOptionalEffect":return(r,n,o)=>aS(r,n,s=>cL(t.transform(mm(s),o)))}}var cL=e=>ur(e,Xw),fL=(e,t,r,n)=>rt(n,o=>aa(()=>Ka(o,s=>new p1(e,s,t,r))));function $Q(e,t){let r=uL(e.link.transformation),n;return(o,s)=>{if(o===ve)return no;if(e.isConstructed(o))return nt;let i=(n??=t(e.link.to))(o,s);return r(i,o,s)}}function jQ(e,t){let r=e.context.constructorDefault;return(n,o)=>{if(n!==ve&&n!==void 0)return t(n,o);let s=r;if(Xe(s)&&s._tag==="Success"){let i=t(s[Se],o);return i===nt?s:i}return ur(fL(e,n,o,s),i=>{let a=t(i,o);return a===nt?Dr(i):a})}}function Kv(e,t){let r=t(e);return e.context?.constructorDefault===void 0?r:jQ(e,r)}function km(e,t,r,n,o){if(e._tag==="Declaration")for(let x of e.typeParameters)t(x);let s=r?oL(e):void 0,i=s?$Q(s,t):n??e.getParser(t,r),a=e.checks,c=e.encoding,u=c?.map(x=>uL(x.transformation)),f=e.encodingChecks;if(!c&&!a&&!f)return i;let p,m=(x,g)=>{let y=i(x,g);if(f&&!g.disableChecks)if(Xe(y)){if(y._tag==="Success"){let E=y===nt?x:y[Se];if(x!==ve&&E!==ve){let b=Us(f,x,void 0,e,g);b&&(y=D(new Ft(e,b,x,g)))}}}else y=A(y,E=>{if(x!==ve&&E!==ve){let b=Us(f,x,void 0,e,g);if(b)return D(new Ft(e,b,x,g))}return I(E)});if(a&&!g.disableChecks)if(Xe(y)){if(y._tag==="Success"){let E=y===nt?x:y[Se];if(E===ve)return y;let b=Us(a,E,void 0,e,g);b&&(y=D(new Ft(e,b,E,g)))}}else y=A(y,E=>{if(E!==ve){let b=Us(a,E,void 0,e,g);if(b)return D(new Ft(e,b,E,g))}return I(E)});return y},h=o===void 0?m:o(m);return c?(x,g)=>{let y=p??=c.map(v=>t(v.to)),E=x,b=y[y.length-1](x,g);for(let v=c.length-1;v>=0;v--)if(b=u[v](b,E,g),v!==0){let T=y[v-1];b._tag==="Success"?(E=b[Se],b=T(E,g)):b=ur(b,S=>{let w=T(S,g);return w===nt?Dr(S):w})}if(b._tag==="Success"){let v=b[Se],T=h(v,g);return T===nt?b:T}return b=fL(e,x,g,b),ur(b,v=>{let T=h(v,g);return T===nt?Dr(v):T})}:h}var fS=Symbol(),lL=new WeakMap,dL,Gl=!1;var qQ=e=>Gl?uS(Po,e,"parser"):Po(e).parser,pL=e=>Gl?uS(Po,e,"makeEffect"):Po(e).makeEffect,zQ=e=>Kv(e,pL),cS=class{ast;constructor(t){this.ast=t}get decodeEffect(){return this.cachedDecodeEffect??=km(this.ast,qQ)}get parser(){return this.decodeEffect}get makeEffect(){return this.cachedMakeEffect??=km(this.ast,pL,zQ)}},Vv=class extends cS{compiled;resolve;constructor(t,r,n){super(t),this.compiled=r,this.resolve=n}save(t,r){return Object.defineProperty(this,t,{value:r}),r}operation(t){let r=this.compiled;return typeof r=="function"?r(this.ast,this.resolve,t):r?.[t]}get is(){return this.save("is",this.operation("is"))}get decode(){return this.save("decode",this.operation("decode"))}get make(){return this.save("make",this.operation("make"))}get decodeEffect(){return this.save("decodeEffect",this.operation("decodeEffect")??km(this.ast,t=>uS(this.resolve,t,"parser")))}get parser(){let t=this.decode;return t===void 0?this.decodeEffect:this.save("parser",WQ(t,()=>this.decodeEffect))}get makeEffect(){let t=this.operation("makeEffect");if(t!==void 0)return this.save("makeEffect",t);let r=n=>uS(this.resolve,n,"makeEffect");return this.save("makeEffect",km(this.ast,r,n=>Kv(n,r)))}};function WQ(e,t){let r;return(n,o)=>{if(n!==ve)try{let s=e(n,o);if(s!==fS)return s===n?nt:Dr(s)}catch(s){return gn(s)}return(r??=t())(n,o)}}function uS(e,t,r){let n=e(t);if(n.compiled===void 0||Object.hasOwn(n,r))return n[r];let o;return(s,i)=>(o??=n[r])(s,i)}function Po(e){let t=lL.get(e);if(t!==void 0)return t;let r=dL===void 0?new cS(e):new Vv(e,dL(e,Po),Po);return lL.set(e,r),r}function Jv(e){let t=e.ast,r;return(n,o)=>(r??=rC(e9,Nt(t)))(n,o?.disableChecks?o?.parseOptions?{...o.parseOptions,disableChecks:!0}:{disableChecks:!0}:o?.parseOptions)}function dS(e){let t=Jv(e);return(r,n)=>{let o=ki(t(r,n));return ft(o)?N(o.value):(ko(o.cause,"Option adapter can only return none for schema issues"),_())}}function pS(e){return YQ(Nt(e.ast))}function Zv(e){return Rm(e.ast)}function VQ(e){if(!Gl){let o=Jl(xS(e));return s=>{let i=o(s,nn);return ft(i)?!0:(ko(i.cause,"Type guard adapter can only return false for schema issues"),!1)}}let t=Po(e),r=t.is;if(r!==void 0)return o=>{try{return r(o,nn)}catch(s){return ko(cl(s),"Type guard adapter can only return false for schema issues"),!1}};let n=t.parser;return o=>{let s=ki(tC(n(o,nn),o));return ft(s)?!0:(ko(s.cause,"Type guard adapter can only return false for schema issues"),!1)}}function Rm(e){let t=Nt(e),r=n=>(r=VQ(t),r(n));return n=>r(n)}function mL(e){let t=xS(e);return(r,n)=>{let o=ki(t(r,n));if(!ft(o))return ko(o.cause,"Issue adapter can only return schema issues")}}function hL(e,t){let r=Nt(e.ast),n=Po(r).parser(t,nn),o=ki(tC(n,t));if(vs(o)){let s=ko(o.cause,"Assertion adapter can only throw schema issues");throw new Error("Schema validation failed",{cause:s})}}function ot(e,t){let r=xS(e.ast);return t===void 0?r:(n,o)=>r(n,eC(t,o))}var Qv=ot;function xL(e,t){return Jl(ot(e,t))}function Yv(e,t){return TL(ot(e,t))}var gL=Yv;function yL(e,t){return wL(ot(e,t))}function GQ(e,t){return Gl?vL(e.ast,t):nC(ot(e,t))}var mS=GQ;function ju(e,t){let r=xS(Oo(e.ast));return t===void 0?r:(n,o)=>r(n,eC(t,o))}var SL=ju;function bL(e,t){return Jl(ju(e,t))}function Xv(e,t){return TL(ju(e,t))}var EL=Xv;function IL(e,t){return wL(ju(e,t))}function JQ(e,t){return Gl?vL(Oo(e.ast),t):nC(ju(e,t))}var hS=JQ,eC=(e,t)=>t?{...e,...t}:e,lS=e=>e===ve?D(new le):I(e);function xS(e){return rC(XQ,e)}function tC(e,t){return e===nt?I(t):Xe(e)?e[Se]===ve?lS(ve):e:ur(e,lS)}function rC(e,t){let r;return(n,o)=>{let s=(r??=e(t))(n,o??nn);return s===nt?I(n):Xe(s)?s[Se]===ve?lS(ve):s:ur(s,lS)}}function Jl(e){return(t,r)=>ki(e(t,r))}function TL(e){let t=Jl(e);return(r,n)=>{let o=t(r,n);return ft(o)?N(o.value):(ko(o.cause,"Option adapter can only return none for schema issues"),_())}}function wL(e){let t=Jl(e);return(r,n)=>{let o=t(r,n);return ft(o)?X(o.value):re(ko(o.cause,"Result adapter can only return schema issues"))}}function vL(e,t){let r;return(n,o)=>(r??=ZQ(Po(e),t))(n,o)}function ZQ(e,t){let r=e.decode,n,o=r===void 0?(s,i=nn)=>(n??=Gv(e))(s,i):(s,i=nn)=>{if(s===ve)return(n??=Gv(e))(s,i);let a;try{a=r(s,i)}catch(c){throw ko(cl(c),"Sync adapter can only throw schema issues"),c}return a!==fS?a:(n??=Gv(e))(s,i)};return t===void 0?o:(s,i)=>o(s,eC(t,i))}function Gv(e){return nC(rC(()=>e.decodeEffect,e.ast))}function nC(e){let t=Jl(e);return(r,n)=>{let o=t(r,n);if(ft(o))return o.value;let s=ko(o.cause,"Sync adapter can only throw schema issues");throw new Error("Schema validation failed",{cause:s})}}function QQ(e,t){let r=ki(e);if(ft(r))return r.value;let n=ko(r.cause,t);throw new Error("Schema validation failed",{cause:n})}function YQ(e){let t,r;return(n,o)=>{t??=Po(e);let s=o?.disableChecks?o.parseOptions?{...o.parseOptions,disableChecks:!0}:{disableChecks:!0}:o?.parseOptions??nn,i=t.make;if(i!==void 0&&n!==ve){let c;try{c=i(n,s)}catch(u){throw ko(cl(u),"Constructor adapter can only throw schema issues"),u}if(c!==fS&&c!==ve)return c}let a=(r??=t.makeEffect)(n,s);return QQ(tC(a,n),"Constructor adapter can only throw schema issues")}}var XQ=e=>Po(e).parser,e9=e=>Po(e).makeEffect;var gS="~effect/Schema/Schema",CL=Symbol(),t9={[gS]:gS,get make(){let e=pS(this);return Object.defineProperty(this,"make",{value:e,enumerable:!0}),e},get makeEffect(){let e=Jv(this);return Object.defineProperty(this,"makeEffect",{value:e,enumerable:!0}),e},get makeOption(){let e=dS(this);return Object.defineProperty(this,"makeOption",{value:e,enumerable:!0}),e},pipe(){return V(this,arguments)},annotate(e){return this.rebuild(Fs(this.ast,e))},annotateKey(e){return this.rebuild(Wl(this.ast,e))},check(...e){return this.rebuild(Pi(this.ast,e))},rebuild(e){return Ls(e,this[CL])}};function Ls(e,t){function r(){}let n=Object.setPrototypeOf(r,t9);return t&&(Object.hasOwn(t,"name")||Object.hasOwn(t,"length")||Object.hasOwn(t,"__proto__"))?Object.defineProperties(n,Object.getOwnPropertyDescriptors({...t})):Object.assign(n,t),n[CL]=t,n.ast=e,n}function oC(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Om(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function sC(e){return encodeURI(oC(e)).replace(/#/g,"%23")}function iC(e){if(e.length===0||e==="#")return"";if(!e.startsWith("#"))return;let t=e.slice(1);try{if(encodeURI(t).replace(/%25/g,"%").replace(/#/g,"%23")!==t)return;let r=decodeURIComponent(t);return r.startsWith("/")&&!/~(?:[^01]|$)/.test(r)?r:void 0}catch{return}}function kL(e){let t=iC(e);return t===void 0?void 0:t.length===0?[]:t.slice(1).split("/").map(Om)}function RL(e){return e.reduce((t,r)=>`${t}/${sC(r)}`,"#")}var n9="http://json-schema.org/draft-07/schema#",OL="https://json-schema.org/draft/2020-12/schema";function _L(e,t){return e===t||e===(t.endsWith("#")?t.slice(0,-1):`${t}#`)}function FL(e){return{dialect:"draft-07",...c9(e,y9)}}function o9(e,t){return r(e,!1,!0);function r(n,o,s=!1){if(!Jt(n))return n;let i=o||!s&&DL(n.$id),a={};for(let c of Object.keys(n)){let u=n[c],f=u;switch(c){case"$defs":case"properties":case"patternProperties":case"dependentSchemas":f=cC(u,p=>r(p,i))??u;break;case"allOf":case"anyOf":case"oneOf":case"prefixItems":f=Array.isArray(u)?u.map(p=>r(p,i)):u;break;case"not":case"additionalProperties":case"propertyNames":case"unevaluatedProperties":case"items":case"contains":case"unevaluatedItems":case"if":case"then":case"else":case"contentSchema":f=r(u,i)}B(a,c,f)}return t(a,i),a}}function NL(e,t){return o9(e,r=>{s9(r,t)})}function s9(e,t){typeof e.$ref=="string"&&B(e,"$ref",t(e.$ref,"$ref")),typeof e.$dynamicRef=="string"&&B(e,"$dynamicRef",t(e.$dynamicRef,"$dynamicRef"))}function cC(e,t){if(!Jt(e))return;let r={};for(let n of Object.keys(e))B(r,n,t(e[n],n));return r}function i9(e,t,r){let n=new Map,o=[],s=aC;function i(m,h=[],x=[]){if(h.length===0&&t?.trackIds){let g=Jt(m)?f(m):void 0;s=PL(g,aC)??aC}return u(m,h,x,{sourceRoot:[],targetRoot:[],uri:s})}function a(){for(let[m,h,x]of o){let g=h,y=UL(h,x);if(y!==void 0){let E=kL(y.hash);if(y.hash="",E!==void 0){let b=n.get(ML(y.href,E));b!==void 0&&(g=a9(h,b))}}B(m,"$ref",g)}}let c=r(i);return a(),c;function u(m,h,x,g){if(typeof m=="boolean")return p(h,x,g),t?.booleanAdapter?.(m)??m;if(!Jt(m))return m;let y=g,E=f(m);if(h.length>0&&t?.trackIds&&DL(E)){let T=PL(E,g.uri);T!==void 0&&(y={parent:g,sourceRoot:h,targetRoot:x,uri:T})}p(h,x,y);let b=y.uri,v={isDocumentRoot:h.length===0,schema(T,S,w=S){return u(T,[...h,S],[...x,w],y)},schemaAt(T,S,w){return u(T,[...h,...S],[...x,...w],y)},schemaArray(T,S,w=S){return Array.isArray(T)?T.map((k,C)=>u(k,[...h,S,String(C)],[...x,w,String(C)],y)):T},schemaMap(T,S,w=S){return Jt(T)?cC(T,(k,C)=>u(k,[...h,S,C],[...x,w,C],y)):T},reference(T,S){typeof S=="string"?o.push([T,S,b]):B(T,"$ref",S)}};return e(m,v)}function f(m){return t?.ignoreRefSiblings===!0&&typeof m.$ref=="string"?void 0:m.$id}function p(m,h,x){x.parent!==void 0&&p(m,h,x.parent),n.set(ML(x.uri,m.slice(x.sourceRoot.length)),h.slice(x.targetRoot.length))}}var aC="https://effect.invalid/.json-schema/";function UL(e,t){return URL.canParse(e,t)?new URL(e,t):void 0}function PL(e,t){if(typeof e!="string")return;let r=UL(e,t);if(r!==void 0)return r.hash="",r.href}function a9(e,t){let r=e.indexOf("#");return r===-1&&t.length===0?e:`${r===-1?e:e.slice(0,r)}${RL(t)}`}function ML(e,t){return`${e}\0${JSON.stringify(t)}`}function DL(e){return typeof e=="string"&&e.length>0&&e[0]!=="#"}function c9(e,t,r){return i9(t,{...r,trackIds:!0},n=>({schema:n(e.schema),definitions:cC(e.definitions,(o,s)=>n(o,["$defs",s],["definitions",s]))}))}var u9=new Set(["properties","patternProperties"]),f9=new Set(["allOf","anyOf","oneOf"]),l9=new Set(["not","additionalProperties","propertyNames","contains","if","then","else","contentSchema"]);function d9(e,t,r,n,o,s=u9){let i;if(s.has(t))i=n.schemaMap(r,t);else if(f9.has(t))i=n.schemaArray(r,t);else if(o.has(t))i=n.schema(r,t);else return!1;return B(e,t,i),!0}var LL=["$anchor","$defs","$dynamicAnchor","$dynamicRef","$vocabulary","contentSchema","dependentRequired","dependentSchemas","maxContains","minContains","prefixItems","unevaluatedItems","unevaluatedProperties"],cge=[...LL,"deprecated"],uge=[...LL,"$comment","$id","$schema","const","contains","contentEncoding","contentMediaType","else","examples","if","patternProperties","propertyNames","then"],p9=/^[A-Za-z_][-A-Za-z0-9._]*$/,m9=/^[A-Za-z][-A-Za-z0-9._:]*$/;function Hu(e,t,r){throw new Error(`Cannot convert JSON Schema keyword "${e}" to ${t}: ${r}`)}function h9(e,t,r,n){for(let o of t)Object.hasOwn(e,o)&&Hu(o,r,`it is not active in ${n} but would become active in the target`)}var x9=["additionalItems","definitions","dependencies"];function g9(e,t,r,n,o){r.isDocumentRoot?B(e,"$schema",_L(t,OL)?n:t):_L(t,OL)||Hu("$schema",o,"an embedded resource cannot declare a different dialect")}function y9(e,t){h9(e,x9,"Draft-07","Draft 2020-12");let r={},n,o,s;for(let i of Object.keys(e)){let a=e[i];if(!d9(r,i,a,t,l9))switch(i){case"$ref":n=a;break;case"$schema":g9(r,a,t,n9,"Draft-07");break;case"$id":case"$anchor":break;case"$defs":B(r,"definitions",t.schemaMap(a,i,"definitions"));break;case"prefixItems":o=a;break;case"items":s=a;break;case"dependentRequired":case"dependentSchemas":case"minContains":case"maxContains":break;case"$dynamicRef":case"$dynamicAnchor":case"$vocabulary":case"unevaluatedProperties":case"unevaluatedItems":Hu(i,"Draft-07","the target dialect has no equivalent");case"required":if(Array.isArray(a)&&a.length===0)break;B(r,i,a);break;default:B(r,i,a)}}if(S9(r,o,s,t),Object.hasOwn(e,"contains")){let i=e.minContains,a=e.maxContains;(i!==void 0&&i!==1||a!==void 0)&&Hu("minContains/maxContains","Draft-07","contains cardinality cannot be represented"),Object.hasOwn(e,"minContains")&&B(r,"minContains",i)}else Object.hasOwn(e,"minContains")&&B(r,"minContains",e.minContains),Object.hasOwn(e,"maxContains")&&B(r,"maxContains",e.maxContains);return E9(e,r,t,"draft-07"),T9(e,r,"$id","Draft-07"),b9(r,n,t),r}function S9(e,t,r,n){if(t===void 0){r!==void 0&&B(e,"items",n.schema(r,"items"));return}B(e,"items",n.schemaArray(t,"prefixItems","items")),r!==void 0&&B(e,"additionalItems",n.schema(r,"items","additionalItems"))}function b9(e,t,r){if(t!==void 0)if(typeof t=="string"&&Object.keys(e).length>0){let n={};r.reference(n,t),I9(e,n)}else r.reference(e,t)}function E9(e,t,r,n){let o=Jt(e.dependentRequired)?e.dependentRequired:void 0,s=Jt(e.dependentSchemas)?e.dependentSchemas:void 0;if(o===void 0&&s===void 0)return;let i={},a=new Set([...Object.keys(o??{}),...Object.keys(s??{})]);for(let c of a){let u=o?.[c],f=s?.[c],p=n==="draft-04"&&Array.isArray(u)&&u.length===0;f===void 0?p||B(i,c,u):u===void 0||p?B(i,c,r.schemaAt(f,["dependentSchemas",c],["dependencies",c])):B(i,c,{allOf:[r.schemaAt(f,["dependentSchemas",c],["dependencies",c,"allOf","0"]),{required:u}]})}Object.keys(i).length>0&&B(t,"dependencies",i)}function I9(e,t){Array.isArray(e.allOf)?e.allOf.push(t):B(e,"allOf",[t])}function T9(e,t,r,n){let o=e.$id,s=e.$anchor;if(s===void 0){o!==void 0&&B(t,r,o);return}(typeof s!="string"||!p9.test(s))&&Hu("$anchor",n,"the anchor is not valid"),m9.test(s)||Hu("$anchor",n,"the anchor cannot be represented as a plain-name fragment identifier"),o===void 0?B(t,r,`#${s}`):Hu("$anchor",n,"it cannot be combined with the schema $id")}function yS(e){return Ls(Zl(e.ast),{schema:e})}var Zl=ma(e=>{let t=v9(e,Zl),r=e.context;return t===e||r===void 0?t:zl(t,uC(r))});function uC(e){return e.constructorDefault===void 0?e:new Yo(e.isOptional,e.isMutable,void 0,e.annotations)}function jL(e){if(e.propertySignatures.some(t=>typeof t.name!="string"))throw new globalThis.Error("Objects property names must be strings",{cause:e})}function HL(e){return t=>{let r=[...t].sort((o,s)=>e(Bn(o))-e(Bn(s)));return r.some((o,s)=>o!==t[s])?r:t}}var w9=HL(e=>{switch(e._tag){case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}});function v9(e,t){switch(e._tag){case"Declaration":{let r=e.annotations?.toCodecJson??e.annotations?.toCodec;if(!or(r))return lt(e,[zv]);let n=e.typeParameters.map(s=>Ls(Bn(s))),o=r(n);return o===void 0?e:lt(e,[fc(o,t)])}case"Unknown":return lt(e,[zv]);case"ObjectKeyword":return lt(e,[aL]);case"Undefined":case"Void":case"Literal":case"Number":return e.toCodecJson();case"UniqueSymbol":case"Symbol":case"BigInt":return e.toCodecStringTree();case"Objects":return jL(e),e.recur(t,iS);case"Union":{let r=w9(e.types);return r!==e.types?new Sn(r,e.options,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t):e.recur(t)}case"Arrays":case"Suspend":return e.recur(t)}return e}function SS(e){return Ls(qL(Nt(e.ast)))}var qL=mo(e=>{let t=C9(e,qL);return t!==e&&e.context!==void 0?zl(t,uC(e.context)):t});function C9(e,t){switch(e._tag){case"Declaration":{let r=e.annotations?.toCodecIso??e.annotations?.toCodec;if(or(r)){let n=r(e.typeParameters.map(o=>Ls(o)));return lt(e,[fc(n,t)])}return e}case"Arrays":case"Objects":case"Union":case"Suspend":return e.recur(t)}return e}function bS(e){return Ls(VL(e.ast),{schema:e})}function zL(e){return Ls(GL(e.ast))}var A9=HL(e=>{switch(e._tag){case"Null":case"Boolean":case"Number":case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}});function k9(e,t,r){switch(e._tag){case"Declaration":{let n=e.typeParameters.map(u=>Ls(t(Bn(u)))),o=e.annotations?.toCodecStringTree;if(or(o)){let u=o(n);return u===void 0?e:lt(e,[fc(u,t)])}let s=e.annotations?.toCodecJson,i=or(s)?s(n):void 0,a=i===void 0?e.annotations?.toCodec:void 0,c=i??(or(a)?a(n):void 0);return c===void 0?r(e):lt(e,[fc(c,t)])}case"Null":return lt(e,[R9]);case"Boolean":return lt(e,[O9]);case"Unknown":case"ObjectKeyword":return lt(e,[Wv]);case"Enum":case"Number":case"Literal":case"UniqueSymbol":case"Symbol":case"BigInt":return e.toCodecStringTree();case"Objects":return jL(e),e.recur(t,iS);case"Union":{let n=A9(e.types);return n!==e.types?new Sn(n,e.options,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t):e.recur(t)}case"Arrays":case"Suspend":return e.recur(t)}return e}var R9=new jt(new Ln("null"),new et(Ie(()=>null),Ie(()=>"null"))),O9=new jt(new Sn([new Ln("true"),new Ln("false")]),new et(Ie(e=>e==="true"),Uu())),WL=new et(Ie(e=>typeof e=="string"?[e]:e),Oi()),KL=e=>e.transformation===WL,VL=ma(e=>{let t=k9(e,VL,r=>{throw new globalThis.Error("Missing structural codec for StringTree",{cause:r})});return t!==e&&e.context!==void 0?zl(t,uC(e.context)):t},{stopAt:KL}),$L=e=>Lr(e)?$u(pa):pa,GL=ma(e=>{let t=_9(e);if(Iv(t)){let r=Kl(new Sn([new Xo(t.isMutable,t.elements.map($L),t.rest.map($L)),Ro],{mode:"anyOf"}),t,WL);return Lr(e)?$u(r):r}return t},{stopAt:KL});function _9(e){return e._tag==="Declaration"||e._tag==="Arrays"||e._tag==="Objects"||e._tag==="Union"||e._tag==="Suspend"?e.recur(GL):e}var lge=globalThis.RegExp;var ha=e=>e.replace(/[/\\^$*+?.()|[\]{}]/g,"\\$&");function lc(e,t){return t.length>0&&(e+=`
27
- at ${Sx(t)}`),new Error(e)}function JL(e){return`#/$defs/${sC(e)}`}var P9=new Set([...l1,Fu,...f1]);function Pm(e,t){if(e===void 0)return;let r={},n=e.title;typeof n=="string"&&(r.title=n);let o=e.description,s=e.expected;typeof o=="string"?r.description=o:t?.generateDescriptions===!0&&typeof s=="string"&&(r.description=s);let i=e.default;Vl(i)&&(r.default=i);let a=e.examples;Array.isArray(a)&&Vl(a)&&(r.examples=a);let c=e.readOnly;typeof c=="boolean"&&(r.readOnly=c);let u=e.writeOnly;typeof u=="boolean"&&(r.writeOnly=u);let f=e.format;typeof f=="string"&&(r.format=f);let p=e.contentEncoding;typeof p=="string"&&(r.contentEncoding=p);let m=e.contentMediaType;typeof m=="string"&&(r.contentMediaType=m);let h=e.contentSchema;if(Vl(h)&&(r.contentSchema=h),t?.includeAnnotationKey!==void 0)for(let[x,g]of Object.entries(e))P9.has(x)||!t.includeAnnotationKey(x)||Vl(g)&&B(r,x,g);return Object.keys(r).length===0?void 0:r}function ZL(e){let t=e.type==="number"||e.type==="integer"?e.type:void 0,r=e;if(t!==void 0&&(r={...e},delete r.type),Array.isArray(r.allOf)){let n=[],o=!1;for(let s of r.allOf){let i=ZL(s);i.type!==void 0&&(o=!0,(t===void 0||i.type==="integer")&&(t=i.type)),Object.keys(i.schema).length>0&&n.push(i.schema)}if(o){let{allOf:s,...i}=r;r=n.length===0?i:{...i,allOf:n}}}return{type:t,schema:r}}function M9(e){if(!Array.isArray(e.anyOf)||e.anyOf.length!==2||e.anyOf[0]?.type!=="number")return!1;let t=e.anyOf[1];return t?.type==="string"&&Array.isArray(t.enum)&&t.enum.length===3&&t.enum.includes("NaN")&&t.enum.includes("Infinity")&&t.enum.includes("-Infinity")}var QL="|type|format|pattern|multipleOf|minimum|maximum|exclusiveMinimum|exclusiveMaximum|minLength|maxLength|minItems|maxItems|uniqueItems|minProperties|maxProperties|propertyNames|";function ES(e,t){return Object.keys(e).every(r=>t.includes(`|${r}|`))}function F9(e,t){return typeof e.$ref!="string"&&t.every(r=>!Object.hasOwn(e,r))}var N9="|minimum|exclusiveMinimum|minLength|minItems|minProperties|",U9="|maximum|exclusiveMaximum|maxLength|maxItems|maxProperties|";function D9(e,t,r){if(typeof e.$ref=="string")return;let n={...e,...t};for(let o of r){if(!Object.hasOwn(e,o))continue;let s=e[o],i=t[o];if(typeof s!="number"||typeof i!="number")return;if(N9.includes(`|${o}|`))n[o]=Math.max(s,i);else if(U9.includes(`|${o}|`))n[o]=Math.min(s,i);else return}return typeof n.minimum=="number"&&typeof n.exclusiveMinimum=="number"&&delete n[n.exclusiveMinimum>=n.minimum?"minimum":"exclusiveMinimum"],typeof n.maximum=="number"&&typeof n.exclusiveMaximum=="number"&&delete n[n.exclusiveMaximum<=n.maximum?"maximum":"exclusiveMaximum"],n}var dC="|title|description|default|examples|readOnly|writeOnly|",L9=QL+dC;function Mm(e,t,r){if(Object.keys(e).length===0)return t;let n=Object.keys(t);if(n.length===0)return e;let o=e.type==="number"||e.type==="integer"?e.type:void 0,s=M9(e);if(o!==void 0||s){let a=ZL(t);if(a.type!==void 0){let c=o==="integer"||a.type==="integer"?"integer":"number",u={...e,type:c};s&&delete u.anyOf;let f=Object.keys(a.schema);return f.length===0?u:ES(a.schema,dC)&&F9(u,f)?{...u,...a.schema}:Mm(u,a.schema,r)}}if(r){let a=D9(e,t,n);if(a!==void 0)return a}let i=Array.isArray(t.allOf)&&n.length===1?t.allOf:[t];return Array.isArray(e.allOf)?{...e,allOf:[...e.allOf,...i]}:typeof e.$ref=="string"?{allOf:[e,...i]}:{...e,allOf:i}}function lC(e,t=new Set){return typeof e=="boolean"?e:t.has(e)?!0:(t.add(e),e.every(r=>lC(r,t)))}function B9(e){return Array.isArray(e)}function $9(e,t,r,n){let o=new Map,s=new Map,i=new WeakMap,a=new Map,c=new Map,u=Object.keys(r);for(let S of u)x(S,["references",S]);let f=Bo(e,(S,w)=>b(S,t[w],[]));for(let[S,w]of a.values())if(!lC(S))for(let k of w)Array.isArray(k.oneOf)&&(k.anyOf=k.oneOf,delete k.oneOf);for(let S of u){let w=r[S],k=y(w);if(k===void 0)continue;let C=o.get(S)[0],R=c.get(k),M=R?.find($=>Z(o.get($)[0],C));M===void 0?R===void 0?c.set(k,[S]):R.push(S):s.set(S,M)}let p=Bo(f,g),m={};for(let S of u)s.has(S)||B(m,S,g(o.get(S)[0]));return{dialect:"draft-2020-12",schemas:p,definitions:m};function h(S){return Array.isArray(S.oneOf)&&a.get(S.oneOf)?.[1].push(S),S}function x(S,w){if(!Object.hasOwn(r,S))throw lc(`Invalid reference ${S}`,[...w,"$ref"]);let k=o.get(S);if(k!==void 0)return k;let C=[{},[]];return o.set(S,C),C[0]=b(r[S],["references",S],C[1]),C}function g(S){return NL(S,w=>{let k=iC(w);if(k===void 0){if(/^#(?:\/|%2f)/i.test(w))throw new Error(`Invalid JSON Pointer URI fragment ${JSON.stringify(w)}`);return w}if(!k.startsWith("/$defs/"))return w;let C=k.indexOf("/",7),R=s.get(Om(k.slice(7,C<0?void 0:C)));return R===void 0?w:w.replace(/^#(?:\/|%2f).*?(?:\/|%2f).*?(?=\/|%2f|$)/i,JL(R))})}function y(S){if(S._tag==="Reference")return;let w=S.checks.length===0?S.annotations:S.checks[S.checks.length-1].annotations;return typeof w?.identifier!="string"&&typeof w?.[Fu]=="string"?w[Fu]:void 0}function E(S,w,k,C){let R=S.annotations,M=R?.toJsonSchema;if(M!==void 0){let Le=S.representation?.schemas?.map((Rn,nI)=>b(Rn,[...k,"representation","schemas",nI],C))??[],Er=M({type:w,schemas:Le}),Ee=B9(Er);Ee&&C.push(!1);let Oe=Ee?Er[0]:Er,rr=Pm(R,n),lo=rr===void 0?Oe:{...Oe,...rr},Xs=rr===void 0?QL:L9;return[lo,S._tag==="Filter"&&ES(lo,Xs)&&(rr===void 0||ES(rr,dC))?!0:void 0]}if(S._tag==="Filter"){C.push(!1);return}let $=S.checks.flatMap((Le,Er)=>{let Ee=E(Le,w,[...k,"checks",Er],C);return Ee===void 0?[]:[Ee[0]]});if($.length===0)return;let te=Pm(R,n),xe={allOf:$};return[te===void 0?xe:{...xe,...te}]}function b(S,w,k){if(S._tag==="Reference")return k.push(x(S.$ref,w)[1]),{$ref:JL(S.$ref)};let C=i.get(S);if(C!==void 0)return k.push(C[1]),C[0];let R=[];k.push(R);let M=v(S,w,R),$=Pm(S.annotations,n);$!==void 0&&(M={...M,...$});for(let te=0;te<S.checks.length;te++){let xe=typeof M.type=="string"&&j9(M.type)?M.type:void 0,Le=E(S.checks[te],xe,[...w,"checks",te],R);Le!==void 0&&(M=Mm(M,...Le))}return i.set(S,[M,R]),h(M)}function v(S,w,k){switch(S._tag){case"Any":case"Unknown":return{};case"ObjectKeyword":return{anyOf:[{type:"object"},{type:"array"}]};case"Void":case"Undefined":case"Null":return{type:"null"};case"BigInt":return{type:"string",allOf:[{pattern:"^-?\\d+$"}]};case"Symbol":return{type:"string",allOf:[{pattern:"^Symbol\\(([\\s\\S]*)\\)$"}]};case"UniqueSymbol":return globalThis.Symbol.keyFor(S.symbol)===void 0?{not:{}}:{type:"string",enum:[globalThis.String(S.symbol)]};case"Declaration":return k.push(!1),{};case"Suspend":return b(S.thunk,[...w,"thunk"],k);case"Never":return{not:{}};case"String":return{type:"string"};case"Number":return{anyOf:[{type:"number"},{type:"string",enum:["NaN","Infinity","-Infinity"]}]};case"Boolean":return{type:"boolean"};case"Literal":{let C=S.literal;return typeof C=="bigint"?{type:"string",enum:[globalThis.String(C)]}:{type:typeof C,enum:[C]}}case"Enum":{let C=S.enums.map(([R,M],$)=>{if(typeof M=="number"&&!globalThis.Number.isFinite(M))throw lc(`Invalid numeric enum value ${globalThis.String(M)}`,[...w,"enums",$,1]);return{type:typeof M,enum:[M],title:R}});return C.length===0?{not:{}}:{anyOf:C}}case"TemplateLiteral":return{type:"string",pattern:`^${S.parts.map(IS).join("")}$`};case"Arrays":{if(S.rest.length>1)throw lc("Invalid schema representation document",[...w,"rest"]);let C={type:"array"},R=S.elements.length,M=S.elements.map(($,te)=>{$.isOptional&&R--;let xe=b($.type,[...w,"elements",te,"type"],k),Le=Pm($.annotations,n);return Le===void 0?xe:h(Mm(xe,Le))});if(M.length>0?(C.prefixItems=M,C.maxItems=S.elements.length,R>0&&(C.minItems=R)):C.items=!1,S.rest.length===1){delete C.maxItems;let $=b(S.rest[0],[...w,"rest",0],k);Object.keys($).length>0?C.items=$:delete C.items}return C}case"Objects":{if(S.propertySignatures.length===0&&S.indexSignatures.length===0)return{not:{type:"null"}};let C={type:"object"},R={},M=[];for(let Ee=0;Ee<S.propertySignatures.length;Ee++){let Oe=S.propertySignatures[Ee];if(typeof Oe.name!="string")throw lc("Invalid schema representation document",[...w,"propertySignatures",Ee,"name"]);let rr=Oe.name,lo=b(Oe.type,[...w,"propertySignatures",Ee,"type"],k),Xs=Pm(Oe.annotations,n);B(R,rr,Xs===void 0?lo:h(Mm(lo,Xs))),Oe.isOptional||M.push(rr)}S.propertySignatures.length>0&&(C.properties=R),M.length>0&&(C.required=M);let $={},te=[],xe=[],Le=!1;for(let Ee=0;Ee<S.indexSignatures.length;Ee++){let Oe=S.indexSignatures[Ee],rr=b(Oe.type,[...w,"indexSignatures",Ee,"type"],k);Z(rr,{not:{}})&&(rr=!1),xe.push(rr);let lo=T(Oe.parameter,[...w,"indexSignatures",Ee,"parameter"],new Set);if(lo===void 0){Le=!0,k.push(!1);continue}if(lo.length===0)te.push(rr);else for(let Xs of lo){let Rn=$[Xs];B($,Xs,Rn===void 0?rr:Rn===!1||rr===!1?!1:h(Mm(Rn,rr)))}}let Er=Object.keys($).length>0;if(Er&&(C.patternProperties=$),Le&&n?.onExcessProperty==="error"){let Ee=[];S.propertySignatures.length>0&&Ee.push({enum:Object.keys(R)});for(let Oe=0;Oe<S.indexSignatures.length;Oe++)Ee.push(b(S.indexSignatures[Oe].parameter,[...w,"indexSignatures",Oe,"parameter"],k));C.propertyNames=Ee.length===1?Ee[0]:{anyOf:Ee},C.additionalProperties=xe.length===1?xe[0]:{anyOf:xe},te.length>0&&(C.allOf=te.map(Oe=>({type:"object",additionalProperties:Oe})))}else te.length===0?C.additionalProperties=Le||n?.onExcessProperty!=="error":te.length===1&&S.propertySignatures.length===0&&!Er?C.additionalProperties=te[0]:te.length>0&&(C.allOf=te.map(Ee=>({type:"object",additionalProperties:Ee})));return typeof C.additionalProperties=="object"&&C.additionalProperties!==null&&Object.keys(C.additionalProperties).length===0&&delete C.additionalProperties,C}case"Union":{let C=[],R=S.types.map(($,te)=>b($,[...w,"types",te],C));if(k.push(C),R.length===0)return{not:{}};let M=S.options?.mode??"anyOf";if(M==="anyOf"&&R.length>1){let $=H9(R);if($!==void 0)return $}return M==="oneOf"&&a.set(R,[C,[]]),{[M]:R}}}}function T(S,w,k){switch(S._tag){case"Reference":{if(!Object.hasOwn(r,S.$ref))throw lc(`Invalid reference ${S.$ref}`,[...w,"$ref"]);if(x(S.$ref,w),k.has(S.$ref))return;let C=new Set(k).add(S.$ref);return T(r[S.$ref],["references",S.$ref],C)}case"String":{if(S.checks.length===0)return[];if(S.checks.length!==1||S.checks[0]._tag!=="Filter"||S.checks[0].annotations?.toJsonSchema===void 0)return;let C=[],R=b(S,w,C);return lC(C)&&R.type==="string"&&typeof R.pattern=="string"&&ES(R,"|type|pattern|title|description|default|examples|readOnly|writeOnly|")?[R.pattern]:void 0}case"TemplateLiteral":return S.checks.length===0?[`^${S.parts.map(IS).join("")}$`]:void 0;case"Union":{if(S.types.length===0||S.checks.length>0||S.options?.mode==="oneOf")return;let C=[];for(let R=0;R<S.types.length;R++){let M=T(S.types[R],[...w,"types",R],k);if(M===void 0)return;if(M.length===0)return[];C.push(...M)}return C}default:throw lc("Invalid schema representation document",w)}}}function j9(e){return e==="string"||e==="number"||e==="boolean"||e==="array"||e==="object"||e==="null"||e==="integer"}function H9(e){let t,r=[];for(let n of e){if(Object.keys(n).length!==2||n.type===void 0||!Array.isArray(n.enum)||n.enum.length===0)return;if(t===void 0)t=n.type;else if(n.type!==t)return;for(let s of n.enum){if(r.includes(s))return;r.push(s)}}return{type:t,enum:r}}function IS(e){switch(e._tag){case"Literal":return ha(globalThis.String(e.literal));case"String":return eL;case"Number":return Xy;case"TemplateLiteral":return e.parts.map(IS).join("");case"Union":return`(?:${e.types.map(IS).join("|")})`;default:throw lc("Invalid schema representation document",[])}}function TS(e,t){let r=$9([e.representation],[["representation"]],e.references,t);return{dialect:r.dialect,schema:r.schemas[0],definitions:r.definitions}}var q9=({identifier:e})=>e;function Bs(e){return e===void 0?void 0:{annotations:e}}function Fm(e,t){let{references:r,representations:n}=z9([e],t);return{representation:n[0],references:r}}function z9(e,t){let r={},n=new Map,o=new Set,s=new Map,i=new Set;for(let S of e)h(S);let a=t?.referencePolicy??q9;for(let S of s.values())for(let w of S.values()){let k=a({ast:w.ast,occurrences:w.occurrences,identifier:w.identifier});if(k!==void 0){let C=k===w.identifier||!k.endsWith("_")?"_":"";w.reference=u(k,w,C)}else w.isRecursive&&(w.reference=u(`${w.ast._tag}_`,w,""))}return{representations:Bo(e,S=>g(S)),references:r};function u(S,w,k="_"){let C=S,R=0;for(;n.has(C);){if(n.get(C)===w)return C;C=`${S}${k}${++R}`}return n.set(C,w),C}function f(S,w,k){let C=w.fallback;return C!==void 0?Qw(S)===C?S:Fs(S,{[Fu]:C}):k===w.identifier?S:Fs(S,{identifier:k})}function p(S,w){if(!Object.hasOwn(r,S)&&!o.has(S)){o.add(S);let k=y(w);o.delete(S),B(r,S,k)}return{_tag:"Reference",$ref:S}}function m(S){let w=ql(S),k=Hl(w),C=_l(w),R=C===void 0?(w!==S?_l(S):void 0)??Qw(w):void 0;R!==void 0&&(C=`${R}Encoded`);let M=s.get(k);M===void 0&&(M=new Map,s.set(k,M));let $=M.get(C);return $===void 0&&($={ast:k,identifier:C,fallback:R,occurrences:0,isRecursive:!1,reference:void 0},M.set(C,$)),$}function h(S){let w=m(S),k=w.ast;if(w.occurrences++,i.has(w)){w.isRecursive=!0;return}if(!(w.occurrences>1)){switch(i.add(w),x(k.checks),k._tag){case"Declaration":case"Arrays":case"Objects":case"Union":k.recur(C=>(h(C),C));break;case"TemplateLiteral":k.parts.forEach(h);break;case"Suspend":h(k.thunk());break}i.delete(w)}}function x(S){S?.forEach(w=>{w.annotations?.representation?.schemas?.forEach(k=>h(Nt(k))),w._tag==="FilterGroup"&&x(w.checks)})}function g(S){let w=m(S),k=w.ast,C=w.reference;if(C!==void 0){let R=w.identifier===void 0?k:f(k,w,C);return p(C,R)}return y(k)}function y(S){let w=E(S.checks);switch(S._tag){case"Declaration":return{_tag:"Declaration",typeParameters:S.typeParameters.map(k=>g(k)),checks:w,...v(S.annotations)};case"Null":case"Undefined":case"Void":case"Never":case"Unknown":case"Any":case"String":case"Boolean":case"Number":case"BigInt":case"Symbol":case"ObjectKeyword":return{_tag:S._tag,checks:w,...Bs(S.annotations)};case"Literal":return{_tag:"Literal",literal:S.literal,checks:w,...Bs(S.annotations)};case"UniqueSymbol":return{_tag:"UniqueSymbol",symbol:S.symbol,checks:w,...Bs(S.annotations)};case"Enum":return{_tag:"Enum",enums:S.enums,checks:w,...Bs(S.annotations)};case"TemplateLiteral":return{_tag:"TemplateLiteral",parts:S.parts.map(k=>g(k)),checks:w,...Bs(S.annotations)};case"Arrays":return{_tag:"Arrays",elements:S.elements.map(k=>{let C=ql(k),R=C.context?.annotations;return{isOptional:Lr(C),type:g(k),...Bs(R)}}),rest:S.rest.map(k=>g(k)),checks:w,...Bs(S.annotations)};case"Objects":return{_tag:"Objects",propertySignatures:S.propertySignatures.map(k=>{let C=ql(k.type),R=C.context?.annotations;return{name:k.name,type:g(k.type),isOptional:Lr(C),isMutable:Z2(C),...Bs(R)}}),indexSignatures:S.indexSignatures.map(k=>({parameter:g(k.parameter),type:g(k.type)})),checks:w,...Bs(S.annotations)};case"Union":return{_tag:"Union",types:S.types.map(k=>g(k)),...S.options===void 0?{}:{options:S.options},checks:w,...Bs(S.annotations)};case"Suspend":return{_tag:"Suspend",checks:[],thunk:g(S.thunk()),...Bs(S.annotations)}}}function E(S){return S?.map(b)??[]}function b(S){switch(S._tag){case"Filter":return{_tag:"Filter",aborted:S.aborted,...T(S.annotations)};case"FilterGroup":return{_tag:"FilterGroup",checks:Bo(S.checks,b),...T(S.annotations)}}}function v(S){if(S===void 0)return;let{representation:w,...k}=S;return{...w===void 0?void 0:{representation:w},...Object.keys(k).length===0?void 0:{annotations:k}}}function T(S){if(S===void 0)return;let{representation:w,...k}=S,C=w===void 0?void 0:w.schemas===void 0?w:{...w,schemas:w.schemas.map(R=>g(Nt(R)))};return{...C===void 0?void 0:{representation:C},...Object.keys(k).length===0?void 0:{annotations:k}}}}function eB(e){return ft(e)?e.value:{issues:[{message:SN(e.cause)}]}}function rB(e,t){let r=ot(e),n={errors:"all",...t?.parseOptions},o=S1(t),s=i=>{let a=new fi("sync"),c=Yp(Z0(r(i,n),{onFailure:o,onSuccess:f=>({value:f})}),{scheduler:a});c.currentDispatcher?.flush();let u=c.pollUnsafe();return u?eB(u):new Promise(f=>{c.addObserver(p=>{f(eB(p))})})};if(Object.hasOwn(e,"~standard")){let i=e;return"validate"in i["~standard"]||Object.assign(i["~standard"],{validate:s}),i}return Object.assign(e,{"~standard":{version:1,vendor:"effect",validate:s}})}function W9(e){let t=Fm(Zl(e));return TS(t)}function tB(e,t){let r=W9(e);if(t==="draft-2020-12"){let n=r.schema;return Object.keys(r.definitions).length>0&&(n.$defs=r.definitions),n}else if(t==="draft-07"){let n=FL(r),o=n.schema;return Object.keys(n.definitions).length>0&&(o.definitions=n.definitions),o}throw new globalThis.Error(`Unsupported target: ${t}`)}function nB(e){let t={input(r){return tB(e.ast,r.target)},output(r){return tB(Nt(e.ast),r.target)}};if(Object.hasOwn(e,"~standard")){let r=e;return"jsonSchema"in r["~standard"]||Object.assign(r["~standard"],{jsonSchema:t}),r}return Object.assign(e,{"~standard":{version:1,vendor:"effect",jsonSchema:t}})}function sB(e,t){let r=[];return pC(e,t,"",r),r}function pC(e,t,r,n){if(!Object.is(e,t)){if(Array.isArray(e)&&Array.isArray(t)){let o=e.length,s=t.length,i=Math.min(o,s);for(let a=0;a<i;a++)pC(e[a],t[a],`${r}/${a}`,n);for(let a=o-1;a>=s;a--)n.push({op:"remove",path:`${r}/${a}`});for(let a=o;a<s;a++)n.push({op:"add",path:`${r}/${a}`,value:t[a]});return}if(wS(e)&&wS(t)){let o=Object.keys(e),s=Object.keys(t),i=Array.from(new Set([...o,...s])).sort();for(let a of i){let c=`${r}/${oC(a)}`,u=Object.hasOwn(e,a),f=Object.hasOwn(t,a);u&&f?pC(e[a],t[a],c,n):!u&&f?n.push({op:"add",path:c,value:t[a]}):n.push({op:"remove",path:c})}return}n.push({op:"replace",path:r,value:t})}}function iB(e,t){let r=t;for(let n of e)r=G9(r,n);return r}function wS(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function V9(e){if(e==="")return[];if(e.charCodeAt(0)!==47)throw new Error(`Invalid JSON Pointer, it must start with "/": ${JSON.stringify(e)}`);return e.split("/").slice(1).map(Om)}function aB(e){if(!/^(0|[1-9]\d*)$/.test(e))throw new Error(`Invalid array index: "${e}"`);return Number(e)}function G9(e,t){if(t.path===""){if(t.op==="remove")throw new Error("Unsupported operation at the root");return t.value}let r=J9(e,t.path);if(r===null)throw new Error(`Cannot ${t.op} at "${t.path}" (parent not found or not a container).`);let{lastToken:n,parent:o,stack:s}=r;if(Array.isArray(o)){if(n==="-"&&t.op!=="add")throw new Error(`"-" is not valid for ${t.op} at "${t.path}".`);let i=n==="-"?o.length:aB(n),a=t.op==="add"?o.length:o.length-1;if(i>a)throw new Error(`Array index out of bounds at "${t.path}".`);let c=o.slice();return t.op==="add"?c.splice(i,0,t.value):t.op==="remove"?c.splice(i,1):c[i]=t.value,oB(s,c)}if(wS(o)){if(t.op!=="add"&&!Object.hasOwn(o,n))throw new Error(`Property "${n}" does not exist at "${t.path}".`);let i={...o};return t.op==="remove"?delete i[n]:B(i,n,t.value),oB(s,i)}throw new Error(`Cannot ${t.op} at "${t.path}" (parent not found or not a container).`)}function J9(e,t){let r=V9(t);if(r.length===0)return null;let n=r[r.length-1],o=[],s=e;for(let i=0;i<r.length-1;i++){let a=r[i];if(Array.isArray(s)){let c=aB(a);if(c>=s.length)return null;o.push({container:s,token:c}),s=s[c];continue}if(wS(s)){if(!Object.hasOwn(s,a))return null;o.push({container:s,token:a}),s=s[a];continue}return null}return{stack:o,parent:s,lastToken:n}}function oB(e,t){let r=t;for(let n=e.length-1;n>=0;n--){let{container:o,token:s}=e[n];if(Array.isArray(o)){let i=o.slice();i[s]=r,r=i}else{let i={...o};B(i,s,r),r=i}}return r}function uB(e){let t=yS(e),r=hS(t),n=mS(t);return{empty:[],diff:(o,s)=>sB(r(o),r(s)),combine:(o,s)=>[...o,...s],patch:(o,s)=>{let i=r(o),a=iB(s,i);return Object.is(a,i)?o:n(a)}}}function fB(e,t){let r=_l(e.ast)??Yw(e.ast),n=SL(bS(e));return o=>n(o).pipe(K(s=>Q9(s,{rootName:r,...t})))}function Q9(e,t){let r=t.rootName??"root",n=t.arrayItemName??"item",o=t.pretty??!0,s=t.indent??" ",i=t.sortKeys??!0,a=new Set,c=[];return f(r,e,0),c.join(o?`
28
- `:"");function u(p,m){c.push(o?s.repeat(p)+m:m)}function f(p,m,h,x){let{attrs:g,safe:y}=Ql.tagInfo(p,x);if(m===void 0)u(h,`<${y}${g}/>`);else if(typeof m=="string")u(h,`<${y}${g}>${Ql.escapeText(m)}</${y}>`);else if(typeof m!="object"||m===null)u(h,`<${y}${g}>${Ql.escapeText(H(m))}</${y}>`);else{if(a.has(m))throw new globalThis.Error("Cycle detected while serializing to XML.",{cause:m});a.add(m);try{if(globalThis.Array.isArray(m)){if(m.length===0){u(h,`<${y}${g}/>`);return}u(h,`<${y}${g}>`);for(let v of m)f(n,v,h+1);u(h,`</${y}>`);return}let E=m,b=Object.keys(E);if(i&&b.sort(),b.length===0){u(h,`<${y}${g}/>`);return}u(h,`<${y}${g}>`);for(let v of b)f(Ql.parseTagName(v).safe,E[v],h+1,v);u(h,`</${y}>`)}finally{a.delete(m)}}}}var Ql={escapeText(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")},escapeAttribute(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")},parseTagName(e){let t=e,r=e;return/^[A-Za-z_]/.test(r)||(r="_"+r),r=r.replace(/[^A-Za-z0-9._-]/g,"_"),/^xml/i.test(r)&&(r="_"+r),{safe:r,changed:r!==t}},tagInfo(e,t){let{changed:r,safe:n}=Ql.parseTagName(e),s=r||t&&t!==e?` data-name="${Ql.escapeAttribute(t??e)}"`:"";return{safe:n,attrs:s}}};var mC=mo(e=>dc(e));function dc(e){let t=da(e)?.toEquivalence;if(t)return t(jl(e)?e.typeParameters.map(dc):[]);switch(e._tag){case"Never":return Qc();case"Declaration":return X9(e);case"Null":case"Undefined":case"Void":case"Unknown":case"Any":case"String":case"Number":case"Boolean":case"BigInt":case"Symbol":case"Literal":case"UniqueSymbol":case"ObjectKeyword":case"Enum":case"TemplateLiteral":return Z;case"Arrays":{let r=e.elements.map(dc),n=e.rest.map(dc),[o,...s]=n,i=s.length;return Wr((a,c)=>{if(!Array.isArray(a)||!Array.isArray(c))return!1;let u=a.length;if(u!==c.length)return!1;let f=0;for(;f<Math.min(u,e.elements.length);f++)if(!r[f](a[f],c[f]))return!1;if(n.length>0){for(;f<u-i;f++)if(!o(a[f],c[f]))return!1;for(let p=0;p<i;p++)if(!s[p](a[f+p],c[f+p]))return!1}return!0})}case"Objects":{if(e.propertySignatures.length===0&&e.indexSignatures.length===0)return Z;let r=e.propertySignatures.map(o=>dc(o.type)),n=e.indexSignatures.map(o=>dc(o.type));return Wr((o,s)=>{if(!Jt(o)||!Jt(s))return!1;for(let i=0;i<r.length;i++){let a=e.propertySignatures[i],c=a.name,u=Object.hasOwn(o,c),f=Object.hasOwn(s,c);if(Lr(a.type)&&u!==f||u&&f&&!r[i](o[c],s[c]))return!1}for(let i=0;i<n.length;i++){let a=e.indexSignatures[i],c=_i(o,a.parameter),u=_i(s,a.parameter);if(c.length!==u.length)return!1;for(let f=0;f<c.length;f++){let p=c[f];if(!Object.hasOwn(s,p)||!n[i](o[p],s[p]))return!1}}return!0})}case"Union":{let r=Nt(e).types,n=vm(r),o=r.map((s,i)=>[Rm(s),dc(e.types[i])]);return Wr((s,i)=>{let a=n(s,!1);for(let c=0;c<a.length;c++){let[u,f]=o[a[c]];if(u(s)&&u(i))return f(s,i)}return!1})}case"Suspend":{let r;return Wr((n,o)=>(r??=mC(e.thunk()))(n,o))}}}function X9(e){let t=e.annotations?.representation;if(t===void 0)return Z;switch(t.id){case"effect/schema/Option":{let[r]=qu(e);return(n,o)=>n._tag===o._tag&&(n._tag==="None"||r(n.value,o.value))}case"effect/schema/Result":{let[r,n]=qu(e);return(o,s)=>o._tag===s._tag&&(o._tag==="Success"?r(o.success,s.success):n(o.failure,s.failure))}case"effect/schema/CauseReason":{let[r,n]=qu(e);return dB(r,n)}case"effect/schema/Cause":{let[r,n]=qu(e);return lB(r,n)}case"effect/schema/Exit":{let[r,n,o]=qu(e),s=lB(n,o);return(i,a)=>i._tag===a._tag&&(i._tag==="Success"?r(i.value,a.value):s(i.cause,a.cause))}case"effect/schema/ReadonlyMap":{let[r,n]=qu(e);return yx(r,n)}case"effect/schema/ReadonlySet":return zd(qu(e)[0]);case"effect/schema/RegExp":return(r,n)=>r.source===n.source&&r.flags===n.flags;case"effect/schema/URL":return(r,n)=>r.toString()===n.toString();default:return Z}}function qu(e){return e.typeParameters.map(dc)}function dB(e,t){return(r,n)=>{if(r._tag!==n._tag)return!1;switch(r._tag){case"Fail":return e(r.error,n.error);case"Die":return t(r.defect,n.defect);case"Interrupt":return r.fiberId===n.fiberId}}}function lB(e,t){let r=vx(dB(e,t));return(n,o)=>r(n.reasons,o.reasons)}function mB(e,t){return r=>{switch(r._tag){case"Fail":return`Fail(${e(r.error)})`;case"Die":return`Die(${t(r.defect)})`;case"Interrupt":return"Interrupt"}}}function pB(e,t){let r=mB(e,t);return n=>`Cause([${n.reasons.map(r).join(", ")}])`}function hB(e,t){let r=new Map;return n(e);function n(i){let a=r.get(i);return a===void 0&&(a=o(i),r.set(i,a)),a}function o(i){let a=da(i)?.toFormatter;if(typeof a=="function")return a(jl(i)?i.typeParameters.map(n):[]);if(t?.onBefore){let c=t.onBefore(i,n);if(c!==void 0)return c}return s(i)}function s(i){switch(i._tag){default:return H;case"Never":return()=>"never";case"Void":return()=>"void";case"Declaration":{let a=i.annotations?.representation;if(a===void 0)return H;let c=i.typeParameters.map(n);switch(a.id){case"effect/schema/Option":{let[u]=c;return Zt({onNone:()=>"none()",onSome:f=>`some(${u(f)})`})}case"effect/schema/Result":{let[u,f]=c;return zn({onSuccess:p=>`success(${u(p)})`,onFailure:p=>`failure(${f(p)})`})}case"effect/schema/CauseReason":return mB(c[0],c[1]);case"effect/schema/Cause":return pB(c[0],c[1]);case"effect/schema/Exit":{let[u,f,p]=c,m=pB(f,p);return h=>{switch(h._tag){case"Success":return`Exit.Success(${u(h.value)})`;case"Failure":return`Exit.Failure(${m(h.cause)})`}}}case"effect/schema/ReadonlyMap":{let[u,f]=c;return p=>{let m=p.size;if(m===0)return"ReadonlyMap(0) {}";let h=globalThis.Array.from(p.entries()).sort().map(([x,g])=>`${u(x)} => ${f(g)}`);return`ReadonlyMap(${m}) { ${h.join(", ")} }`}}case"effect/schema/HashMap":{let[u,f]=c;return p=>{let m=LD(p);if(m===0)return"HashMap(0) {}";let h=im(p).sort().map(([x,g])=>`${u(x)} => ${f(g)}`);return`HashMap(${m}) { ${h.join(", ")} }`}}case"effect/schema/ReadonlySet":{let[u]=c;return f=>{let p=f.size;if(p===0)return"ReadonlySet(0) {}";let m=globalThis.Array.from(f.values()).sort().map(h=>`${u(h)}`);return`ReadonlySet(${p}) { ${m.join(", ")} }`}}case"effect/schema/HashSet":{let[u]=c;return f=>{let p=HD(f);if(p===0)return"HashSet(0) {}";let m=globalThis.Array.from(f).sort().map(h=>`${u(h)}`);return`HashSet(${p}) { ${m.join(", ")} }`}}case"effect/schema/Chunk":{let[u]=c;return f=>{let p=hD(f);if(p===0)return"Chunk(0) {}";let m=globalThis.Array.from(f).sort().map(h=>`${u(h)}`);return`Chunk(${p}) { ${m.join(", ")} }`}}default:return H}}case"Arrays":{let a=i.elements.map(m=>n(m)),c=i.rest.map(n),[u,...f]=c,p=f.length;return m=>{let h=[],x=0;for(;x<a.length;x++)if(m.length<x+1){if(Lr(i.elements[x]))continue}else h.push(a[x](m[x]));if(c.length>0){for(;x<m.length-p;x++)h.push(u(m[x]));for(let g=0;g<p;g++)h.push(f[g](m[x+g]))}return"["+h.join(", ")+"]"}}case"Objects":{let a=i.propertySignatures.map(u=>n(u.type)),c=i.indexSignatures.map(u=>n(u.type));return i.propertySignatures.length===0&&i.indexSignatures.length===0?H:u=>{let f=[],p=new Set;for(let m=0;m<a.length;m++){let h=i.propertySignatures[m],x=h.name;p.add(x),!(Lr(h.type)&&!Object.hasOwn(u,x))&&f.push(`${ni(x)}: ${a[m](u[x])}`)}for(let m=0;m<c.length;m++){let h=_i(u,i.indexSignatures[m].parameter);for(let x of h)p.has(x)||(p.add(x),f.push(`${ni(x)}: ${c[m](u[x])}`))}return f.length>0?"{ "+f.join(", ")+" }":"{}"}}case"Union":{let a=Nt(i).types,c=vm(a),u=a.map((f,p)=>[Rm(f),n(i.types[p])]);return f=>{let p=c(f,!1);for(let m=0;m<p.length;m++){let[h,x]=u[p[m]];if(h(f))return x(f)}return H(f)}}case"Suspend":{let a;return c=>(a??=n(i.thunk()))(c)}}}}var hC=d(2,(e,t)=>yC(e,(r,n)=>gB(t,r)?[r,n]:void 0)),xC=d(2,(e,t)=>yC(e,(r,n)=>gB(t,r)?void 0:[r,n])),xB=d(2,(e,t)=>({...e,...t}));var gC=d(2,(e,t)=>yC(e,(r,n)=>[Object.hasOwn(t,r)?t[r]:r,n]));var bn=e=>e;function gB(e,t){return e.some(r=>r===t||typeof r=="number"&&String(r)===t)}function yC(e,t){let r={};for(let n of Reflect.ownKeys(e)){if(!Object.prototype.propertyIsEnumerable.call(e,n))continue;let o=t(n,e[n]);if(o){let[s,i]=o;B(r,s,i)}}return r}function bB(e,t){return $s(Yl("Iso",e,t))}function yB(e,t){return $s(Yl("Lens",e,t))}function Yl(e,t,r){return[{_tag:"PrimitiveNode",kind:e,get:t,set:r}]}var rY={kind:"Iso",get:F,set:F},vS=class{_tag="PathNode";kind="Lens";path;get;set;constructor(t){this.path=t,this.get=r=>{let n=r;for(let o=0;o<t.length;o++)n=n[t[o]];return n},this.set=(r,n)=>{let o=CS(n),s=o,i=0;for(;i<t.length-1;i++){let a=t[i];B(s,a,CS(s[a])),s=s[a]}return B(s,t[i],r),o}}},Nm=class{_tag="CheckNode";kind="Prism";checks;get;set=F;constructor(t){this.checks=t,this.get=r=>nL(t,r)}};function zu(e,t){if(e.length===0)return t;if(t.length===0)return e;let r=e.slice();for(let n=0;n<t.length;n++){let o=t[n],s=r[r.length-1];s._tag==="PathNode"&&o._tag==="PathNode"?r[r.length-1]=new vS([...s.path,...o.path]):s._tag==="CheckNode"&&o._tag==="CheckNode"?r[r.length-1]=new Nm([...s.checks,...o.checks]):r.push(o)}return r}function nY(e,t){return $s(Yl("Optional",e,t))}var Xl=class{node;getResult;replaceResult;constructor(t,r,n){this.node=t,this.getResult=r,this.replaceResult=n}replace(t,r){return ap(this.replaceResult(t,r),()=>r)}modify(t){return r=>ap(hr(this.getResult(r),n=>this.replaceResult(t(n),r)),()=>r)}compose(t){return $s(zu(this.node,t.node))}key(t){return $s(zu(this.node,[new vS([t])]))}optionalKey(t){return $s(zu(this.node,Yl("Lens",r=>r[t],(r,n)=>{let o=CS(n);return r===void 0?Array.isArray(o)&&(typeof t=="number"||typeof t=="string"&&jx(t))?o.splice(Number(t),1):delete o[t]:B(o,t,r),o})))}check(...t){return $s(zu(this.node,[new Nm(t)]))}refine(t,r){return $s(zu(this.node,[new Nm([nS(t,r)])]))}tag(t){let r=re(new le({expected:`${JSON.stringify(t)} tag`}));return $s(zu(this.node,Yl("Prism",n=>n._tag===t?X(n):r,F)))}at(t,...r){let n=re(new At([t],new Yt(void 0)));return $s(zu(this.node,Yl("Optional",o=>Object.hasOwn(o,t)?X(o[t]):n,(o,s)=>{if(Object.hasOwn(s,t)){let i=CS(s);return B(i,t,o),X(i)}else return n})))}pick(t){return this.compose(yB(hC(t),(r,n)=>({...xC(n,t),...r})))}omit(t){return this.compose(yB(xC(t),(r,n)=>({...hC(n,t),...r})))}notUndefined(){return this.refine(ei,{expected:"a value other than `undefined`"})}forEach(t){let r=t(AS());return nY(n=>Vr(this.getResult(n),o=>{let s=[];for(let i=0;i<o.length;i++){let a=r.getResult(o[i]);tt(a)&&s.push(a.success)}return s}),(n,o)=>hr(this.getResult(o),s=>{let i=[];for(let c=0;c<s.length;c++)tt(r.getResult(s[c]))&&i.push(c);if(n.length!==i.length)return re(new le({message:`each: replacement length mismatch: ${n.length} !== ${i.length}`}));let a=s.slice();for(let c=0;c<i.length;c++){let u=i[c],f=r.replaceResult(n[c],s[u]);if(be(f))return re(new At([u],f.failure));a[u]=f.success}return this.replaceResult(a,o)}))}modifyAll(t){return r=>ap(hr(this.getResult(r),n=>this.replaceResult(n.map(t),r)),()=>r)}},bC=class extends Xl{get;set;constructor(t,r,n){super(t,o=>X(r(o)),o=>X(n(o))),this.get=r,this.set=n}replace(t,r){return this.set(t)}modify(t){return r=>this.set(t(this.get(r)))}},EC=class extends Xl{get;constructor(t,r,n){super(t,o=>X(r(o)),(o,s)=>X(n(o,s))),this.get=r,this.replace=n}modify(t){return r=>this.replace(t(this.get(r)),r)}},IC=class extends Xl{set;constructor(t,r,n){super(t,r,(o,s)=>X(n(o))),this.set=n}replace(t,r){return this.set(t)}modify(t){return r=>ap(Vr(this.getResult(r),n=>this.set(t(n))),()=>r)}};function $s(e){let t=e[0]??rY;if(e.length>1){let r=e.reduce((n,o)=>iY(n,o.kind),"Iso");t={kind:r,get:oY(e,r),set:sY(e,r)}}switch(t.kind){case"Iso":return new bC(e,t.get,t.set);case"Lens":return new EC(e,t.get,t.set);case"Prism":return new IC(e,t.get,t.set);case"Optional":return new Xl(e,t.get,t.set)}}function CS(e){if(Array.isArray(e))return e.slice();if(typeof e=="object"&&e!==null){let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)throw new Error("Cannot clone object with non-Object constructor or null prototype");return{...e}}return e}function oY(e,t){return r=>{for(let n=0;n<e.length;n++){let o=e[n],s=o.get(r);if(TC(o.kind)){if(be(s))return s;r=s.success}else r=s}return TC(t)?X(r):r}}function sY(e,t){return SB(t)?r=>{for(let n=e.length-1;n>=0;n--)r=e[n].set(r);return r}:(r,n)=>{let o=e.length,s=new Array(o);for(let i=0;i<o;i++){s[i]=n;let a=e[i];if(TC(a.kind)){let c=a.get(n);if(be(c))return c;n=c.success}else n=a.get(n)}for(let i=o-1;i>=0;i--){let a=e[i];if(SB(a.kind))r=a.set(r);else if(a.kind==="Lens")r=a.set(r,s[i]);else{let c=a.set(r,s[i]);if(be(c))return c;r=c.success}}return t==="Optional"?X(r):r}}function TC(e){return e==="Prism"||e==="Optional"}function SB(e){return e==="Iso"||e==="Prism"}function iY(e,t){return e==="Iso"?t:t==="Iso"||e===t?e:"Optional"}var aY=$s([]);function AS(){return aY}function IB(e){let t=SS(e);return bB(hS(t),mS(t))}function TB(e){return AS()}function wB(e){return AS()}var ed="~effect/Schema/SchemaError";function vB(e){return O(e,ed)&&e[ed]===ed}var Mo="~effect/net/NetAddress";var js=e=>e.value,Hs=e=>e,xa=e=>e.bytes,es=class extends sr("NetAddressError"){},td=e=>O(e,Mo),Br=e=>td(e)&&e._tag==="Ipv4Address",ts=e=>td(e)&&e._tag==="Ipv6Address",wC=e=>Br(e)||ts(e),rd=e=>Br(e)?32:128;var nd=e=>td(e)&&e._tag==="MacAddress",Dm=e=>td(e)&&e._tag==="InetAddressV4",Lm=e=>td(e)&&e._tag==="InetAddressV6",vC=e=>Dm(e)||Lm(e),kS=e=>td(e)&&e._tag==="UnixPathAddress",CB=e=>vC(e)||kS(e),uY={...Ot,_tag:"Ipv4Address",[Mo]:Mo,[ae](e){return Br(e)&&js(this)===js(e)},[ie](){return _r(he(pY,js(this)|0))},toString(){return $r(this)},toJSON(){return this.toString()}},fY={...Ot,_tag:"Ipv6Address",[Mo]:Mo,[ae](e){if(!ts(e))return!1;let t=Hs(this),r=Hs(e);return t.w0===r.w0&&t.w1===r.w1&&t.w2===r.w2&&t.w3===r.w3},[ie](){let e=Hs(this),t=he(mY,e.w0|0);return t=he(t,e.w1|0),t=he(t,e.w2|0),_r(he(t,e.w3|0))},toString(){return $r(this)},toJSON(){return this.toString()}},lY={...Ot,_tag:"MacAddress",[Mo]:Mo,[ae](e){return nd(e)&&dY(xa(this),xa(e))},[ie](){return he(hY,ri(xa(this)))},toString(){return kC(this)},toJSON(){return this.toString()}},dY=(e,t)=>{if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0},pY=Be("Ipv4Address"),mY=Be("Ipv6Address"),hY=Be("MacAddress"),xY=e=>{let t=Object.create(uY);return t.value=e>>>0,Object.freeze(t)},gY=(e,t,r,n)=>{let o=Object.create(fY);return o.w0=e>>>0,o.w1=t>>>0,o.w2=r>>>0,o.w3=n>>>0,Object.freeze(o)},yY=(e,t,r,n)=>(e<<24|t<<16|r<<8|n)>>>0;var Um=e=>[e>>>24,e>>>16&255,e>>>8&255,e&255],SY=e=>{let t=Object.assign(Object.create(lY),{bytes:new Uint8Array(e)});return Object.freeze(t)};var Ut=(e,t)=>re(new es({input:e,message:t})),AB=(e,t)=>{for(let r=0;r<e.length;r++){let n=e[r];if(!Number.isInteger(n)||n<0||n>t)return!1}return!0},bY=e=>AB(e,255)?X(xY(yY(e[0],e[1],e[2],e[3]))):Ut(e,"octets must be integers from 0 through 255"),EY=e=>AB(e,65535)?X(gY(e[0]*65536+e[1],e[2]*65536+e[3],e[4]*65536+e[5],e[6]*65536+e[7])):Ut(e,"segments must be integers from 0 through 65535");var kB=e=>/^(?:[0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$/.test(e)?X(SY(new Uint8Array(e.split(":").map(t=>Number.parseInt(t,16))))):Ut(e,"expected six two-digit hexadecimal octets separated by colons");var Wu=e=>{let t=e.split(".");if(t.length!==4||t.some(n=>!/^\d{1,3}$/.test(n)))return Ut(e,"expected exactly four decimal octets");if(t.some(n=>n.length>1&&n[0]==="0"))return Ut(e,"leading zeroes are not allowed");let r=t.map(Number);return r.some(n=>n>255)?Ut(e,"octets must be at most 255"):bY([r[0],r[1],r[2],r[3]])},IY=e=>{if(e.includes("[")||e.includes("]")||e.includes("%"))return Ut(e,"brackets and zone identifiers are not valid in a bare IPv6 address");let t=e.split("::");if(t.length>2)return Ut(e,"only one compression marker is allowed");let r=t[0]===""?[]:t[0].split(":"),n=t.length===2&&t[1]!==""?t[1].split(":"):[];if(r.some(f=>f==="")||n.some(f=>f===""))return Ut(e,"empty segments are only valid in the compression marker");let o=n.length>0?n[n.length-1]:r.length>0?r[r.length-1]:"",s;if(o.includes(".")){if(t.length===2&&n.length===0)return Ut(e,"embedded IPv4 syntax must be trailing");let f=Vr(Wu(o),p=>{let m=js(p);return[m>>>16,m&65535]});if(be(f))return f;s=f.success,n.length>0?n.pop():r.pop()}let i=r.length+n.length+(s?2:0);if(t.length===1?i!==8:i>=8)return Ut(e,t.length===1?"expected eight segments":"compression must replace at least one segment");let a=f=>/^[0-9a-fA-F]{1,4}$/.test(f)?Number.parseInt(f,16):void 0,c=r.map(a),u=n.map(a);return c.some(f=>f===void 0)||u.some(f=>f===void 0)?Ut(e,"segments must contain one through four hexadecimal digits"):X([...c,...Array(8-i).fill(0),...u,...s??[]])},Ku=e=>hr(IY(e),t=>EY(t)),pc=e=>e.includes(":")?Ku(e):Wu(e);var CC=e=>{if(typeof e!="string"||!e.includes("%"))return!1;let t=Bm(e);return tt(t)&&t.success===e},Bm=e=>{let t=e.indexOf("%");if(t===-1)return Ut(e,"expected an IPv6 zone");let r=e.slice(t+1);if(r.length===0||/[%[\]/\s\p{Cc}]/u.test(r))return Ut(e,"invalid IPv6 scope identifier");if(/^\d+$/.test(r)){let n=Number(r);if(n>4294967295)return Ut(e,"scope identifier must be an unsigned 32-bit integer");r=String(n)}return Vr(Ku(e.slice(0,t)),n=>`${$r(n)}%${r}`)};var RS=e=>Um(js(e)),TY=e=>{let{w0:t,w1:r,w2:n,w3:o}=Hs(e);return[t>>>16,t&65535,r>>>16,r&65535,n>>>16,n&65535,o>>>16,o&65535]},AC=e=>{let{w0:t,w1:r,w2:n,w3:o}=Hs(e);return[...Um(t),...Um(r),...Um(n),...Um(o)]};var kC=e=>Array.from(xa(e),t=>t.toString(16).padStart(2,"0")).join(":"),OS=e=>xa(e).every(t=>t===255),wY=e=>(xa(e)[0]&1)!==0,_S=e=>(xa(e)[0]&1)===0,RC=e=>(xa(e)[0]&2)!==0,OC=e=>(xa(e)[0]&2)===0;var $r=e=>{if(Br(e))return RS(e).join(".");let t=TY(e);if(vY(e))return`::ffff:${t[6]>>8}.${t[6]&255}.${t[7]>>8}.${t[7]&255}`;let r=-1,n=0,o=-1;for(let a=0;a<=8;a++)a<8&&t[a]===0?o===-1&&(o=a):o!==-1&&(a-o>n&&(r=o,n=a-o),o=-1);if(n<2)return t.map(a=>a.toString(16)).join(":");let s=t.slice(0,r).map(a=>a.toString(16)).join(":"),i=t.slice(r+n).map(a=>a.toString(16)).join(":");return`${s}::${i}`},PS=e=>{if(Br(e))return js(e)===0;let{w0:t,w1:r,w2:n,w3:o}=Hs(e);return t===0&&r===0&&n===0&&o===0},_C=e=>{if(Br(e))return js(e)>>>24===127;let{w0:t,w1:r,w2:n,w3:o}=Hs(e);return t===0&&r===0&&n===0&&o===1},od=e=>nd(e)?wY(e):Br(e)?js(e)>>>28===14:Hs(e).w0>>>24===255,MS=e=>nd(e)?OS(e):js(e)===4294967295,PC=e=>nd(e)?_S(e):!od(e)&&!PS(e)&&(!Br(e)||!MS(e)),MC=e=>Br(e)?js(e)>>>16===43518:(Hs(e).w0>>>16&65472)===65152,FC=e=>{let t=js(e);return t>>>24===10||(t>>>16&65520)===44048||t>>>16===49320},NC=e=>(Hs(e).w0>>>24&254)===252,vY=e=>{let{w0:t,w1:r,w2:n}=Hs(e);return t===0&&r===0&&n===65535};var CY={...Ot,_tag:"InetAddressV4",[Mo]:Mo,[ae](e){return Dm(e)&&this.port===e.port&&Z(this.address,e.address)},[ie](){return he(G(this.address),zt(this.port))},toString(){return FS(this)},toJSON(){return this.toString()}},AY={...Ot,_tag:"InetAddressV6",[Mo]:Mo,[ae](e){return Lm(e)&&this.port===e.port&&this.scopeId===e.scopeId&&Z(this.address,e.address)},[ie](){return he(he(G(this.address),zt(this.port)),zt(this.scopeId))},toString(){return FS(this)},toJSON(){return this.toString()}},RB=e=>Number.isInteger(e)&&e>=0&&e<=65535,kY=(e,t)=>{if(!RB(t))return Ut(e,"port must be an integer from 0 through 65535");let r=Object.create(CY);return r.address=e,r.port=t,X(Object.freeze(r))},RY=(e,t,r)=>{if(!RB(t))return Ut(e,"port must be an integer from 0 through 65535");let n=r?.scopeId??0;if(!Number.isInteger(n)||n<0||n>4294967295)return Ut(e,"scopeId must be an unsigned 32-bit integer");let o=Object.create(AY);return o.address=e,o.port=t,o.scopeId=n,X(Object.freeze(o))};var UC=e=>{let t,r,n=0,o=e.startsWith("[");if(o){let s=e.indexOf("]");if(s<0||e[s+1]!==":"||e.indexOf("]",s+1)!==-1)return Ut(e,"expected [IPv6]:port");t=e.slice(1,s),r=e.slice(s+2);let i=t.indexOf("%");if(i!==-1){let a=t.slice(i+1);if(t.indexOf("%",i+1)!==-1||!/^\d+$/.test(a))return Ut(e,"scope identifier must be decimal");if(n=Number(a),!Number.isInteger(n)||n>4294967295)return Ut(e,"scope identifier must be an unsigned 32-bit integer");t=t.slice(0,i)}}else{let s=e.lastIndexOf(":");if(s<0)return Ut(e,"expected host:port or [IPv6]:port");if(e.indexOf(":")!==s)return Ut(e,"IPv6 addresses must be bracketed");t=e.slice(0,s),r=e.slice(s+1)}return/^(0|[1-9]\d*)$/.test(r)?hr(pc(t),s=>o!==ts(s)?Ut(e,"only IPv6 addresses use brackets"):ts(s)?RY(s,Number(r),{scopeId:n}):kY(s,Number(r))):Ut(e,"port must be an unpadded decimal integer")};var OY=e=>$r(e.address)+(Lm(e)&&e.scopeId!==0?`%${e.scopeId}`:"");var FS=e=>{let t=OY(e);return Dm(e)?`${t}:${e.port}`:`[${t}]:${e.port}`};var _Y={...Ot,_tag:"UnixPathAddress",[Mo]:Mo,[ae](e){return kS(e)&&this.path===e.path},[ie](){return he(Be("UnixPathAddress"),Be(this.path))},toString(){return this.path},toJSON(){return this.toString()}},OB=e=>{let t=Object.create(_Y);return t.path=e,Object.freeze(t)};var DC="~effect/net/Host",mc=(e,t)=>re(new es({input:e,message:t})),PY=/^[a-z0-9_.-]$/i,MY=/^[a-z0-9_](?:[a-z0-9_-]{0,61}[a-z0-9_])?$/,FY=/^(?:\d+|0x[0-9a-f]*)$/,_B=e=>{if(e===".")return;let t=e.endsWith(".")?e.slice(0,-1):e;if(t.length===0)return"domain name must not be empty";if(t.length>253)return"domain name must be at most 253 characters";let r=t.split(".");for(let n of r){if(n.length===0)return"domain name labels must not be empty";if(n.length>63)return"domain name labels must be at most 63 characters";if(!MY.test(n))return"domain name labels must contain only letters, digits, hyphens, or underscores and must not start or end with a hyphen"}if(FY.test(r[r.length-1]))return"the last domain name label must not be numeric"},NY=e=>{let t=!0;for(let r of e)if(r.charCodeAt(0)<128){if(!PY.test(r))return}else t=!1;if(t)return e.toLowerCase();try{return new URL(`http://${e}`).hostname}catch{return}},ga=e=>typeof e=="string"&&/^[a-z0-9_.-]+$/.test(e)&&_B(e)===void 0;var BC=e=>O(e,DC),NS=e=>{let t=NY(e);if(t===void 0)return mc(e,"invalid domain name");let r=_B(t);return r===void 0?X(t):mc(e,r)};var UY=e=>{if(e.includes("%"))return Bm(e);if(e.includes(":"))return pc(e);if(/^[\d.]+$/.test(e)){let t=pc(e);if(tt(t))return t}return NS(e)};var DY=e=>typeof e=="string"?e:$r(e);var LY={...Ot,_tag:"HostPort",[DC]:DC,[ae](e){return BC(e)&&this.port===e.port&&Z(this.host,e.host)},[ie](){return he(G(this.host),zt(this.port))},toString(){return $C(this)},toJSON(){return this.toString()}},BY=e=>Number.isInteger(e)&&e>=0&&e<=65535,$Y=(e,t)=>{let r=Object.create(LY);return r.host=e,r.port=t,Object.freeze(r)};var PB=e=>{let t,r;if(e.startsWith("[")){let o=e.indexOf("]");if(o===-1||e[o+1]!==":")return mc(e,"expected [IPv6]:port");if(t=e.slice(1,o),r=e.slice(o+2),!t.includes(":"))return mc(e,"only IPv6 addresses use brackets")}else{let o=e.lastIndexOf(":");if(o===-1)return mc(e,"expected host:port");if(e.indexOf(":")!==o)return mc(e,"IPv6 addresses must be bracketed");t=e.slice(0,o),r=e.slice(o+1)}if(!/^(0|[1-9]\d*)$/.test(r))return mc(e,"port must be an unpadded decimal integer");let n=Number(r);return BY(n)?Vr(UY(t),o=>$Y(o,n)):mc(e,"port must be an integer from 0 through 65535")};var $C=e=>{let t=DY(e.host);return t.includes(":")?`[${t}]:${e.port}`:`${t}:${e.port}`};var HC="~effect/net/Dns/DnsRecord",jC=e=>Number.isInteger(e)&&e>=0&&e<=255,sd=e=>Number.isInteger(e)&&e>=0&&e<=65535,NB=e=>Number.isInteger(e)&&e>=0&&e<=4294967295,hc=e=>typeof e=="string",US=e=>Qi(e)&&Wn(e)&&NB(ui(e)),UB={A:{address:Br},AAAA:{address:ts},CAA:{critical:e=>typeof e=="boolean",tag:e=>hc(e)&&/^[a-z0-9]+$/i.test(e),value:hc},CNAME:{target:ga},MX:{exchange:ga,priority:sd},NAPTR:{order:sd,preference:sd,flags:hc,service:hc,regexp:hc,replacement:ga},NS:{host:ga},PTR:{host:e=>hc(e)&&e.length>0},SOA:{primary:ga,admin:e=>hc(e)&&e.length>0,serial:NB,refresh:US,retry:US,expire:US,minimum:US},SRV:{target:ga,port:sd,priority:sd,weight:sd},TLSA:{certUsage:jC,selector:jC,matchingType:jC,data:e=>e instanceof Uint8Array&&e.length>0},TXT:{chunks:e=>Array.isArray(e)&&e.length>0&&e.every(hc)}},qC=Object.keys(UB),jY=e=>qC.includes(e),zC=e=>O(e,HC),HY={...Ot,[HC]:HC,[ae](e){return zC(e)&&e._tag===this._tag&&Object.keys(this).every(t=>Z(this[t],e[t]))},[ie](){return Hd(this,Object.keys(this))},toString(){return zY(this)},toJSON(){return{...this}}},DB=(e,t)=>{if(!jY(e))return re(new es({input:e,message:"unknown DNS record type"}));let r=typeof t=="object"&&t!==null?t:{},n=Object.create(HY);n._tag=e;for(let[o,s]of Object.entries(UB[e])){let i=r[o];if(!s(i))return re(new es({input:t,message:`invalid ${e} record ${o}`}));n[o]=Array.isArray(i)?Object.freeze([...i]):i instanceof Uint8Array?new Uint8Array(i):i}return X(Object.freeze(n))};var LB=new TextEncoder,BB=e=>`\\${e.toString().padStart(3,"0")}`,jm=e=>{let t='"';for(let r of LB.encode(e))t+=r===34||r===92?`\\${String.fromCharCode(r)}`:r<32||r>126?BB(r):String.fromCharCode(r);return t+'"'},qY=[34,36,40,41,59,64],FB=e=>{let t=LB.encode(e),r="";for(let n=0;n<t.length;n++){let o=t[n];if(o===92){let s=t[n+1];s===46||s===92?(r+=`\\${String.fromCharCode(s)}`,n++):r+="\\\\"}else o<=32||o>126?r+=BB(o):r+=qY.includes(o)?`\\${String.fromCharCode(o)}`:String.fromCharCode(o)}return r},zY=e=>{switch(e._tag){case"A":case"AAAA":return`${e._tag} ${$r(e.address)}`;case"CAA":return`CAA ${e.critical?128:0} ${e.tag} ${jm(e.value)}`;case"CNAME":return`CNAME ${e.target}`;case"MX":return`MX ${e.priority} ${e.exchange}`;case"NAPTR":return`NAPTR ${e.order} ${e.preference} ${jm(e.flags)} ${jm(e.service)} ${jm(e.regexp)} ${e.replacement}`;case"NS":return`NS ${e.host}`;case"PTR":return`PTR ${FB(e.host)}`;case"SOA":return`SOA ${e.primary} ${FB(e.admin)} ${e.serial} ${ui(e.refresh)} ${ui(e.retry)} ${ui(e.expire)} ${ui(e.minimum)}`;case"SRV":return`SRV ${e.priority} ${e.weight} ${e.port} ${e.target}`;case"TLSA":return`TLSA ${e.certUsage} ${e.selector} ${e.matchingType} ${Gx(e.data).toUpperCase()}`;case"TXT":return`TXT ${e.chunks.map(jm).join(" ")}`}};var WC="~effect/net/IpInterface",$B=e=>Hm(e)&&Br(e.address),jB=e=>Hm(e)&&ts(e.address),Hm=e=>O(e,WC),GY={...Ot,_tag:"IpInterface",[WC]:WC,[ae](e){return Hm(e)&&this.prefixLength===e.prefixLength&&Z(this.address,e.address)},[ie](){return he(G(this.address),zt(this.prefixLength))},toString(){return zm(this)},toJSON(){return this.toString()}},KC=(e,t)=>re(new es({input:e,message:t})),qm=(e,t)=>{let r=rd(e);if(!Number.isInteger(t)||t<0||t>r)return KC(e,`prefix length must be an integer from 0 through ${r}`);let n=Object.assign(Object.create(GY),{address:e,prefixLength:t});return X(Object.freeze(n))},VC=(e,t)=>{let r=e.indexOf("/");if(r===-1&&t?.prefix!=="required")return X({address:e,prefixLength:void 0});if(r<=0||r!==e.lastIndexOf("/")||r===e.length-1)return KC(e,"expected an address and prefix length separated by one slash");let n=e.slice(r+1);return/^(0|[1-9][0-9]*)$/.test(n)?X({address:e.slice(0,r),prefixLength:Number(n)}):KC(e,"prefix length must be an unpadded ASCII decimal integer")},DS=(e,t)=>hr(VC(e,t),r=>hr(Wu(r.address),n=>qm(n,r.prefixLength??rd(n)))),LS=(e,t)=>hr(VC(e,t),r=>hr(Ku(r.address),n=>qm(n,r.prefixLength??rd(n)))),BS=(e,t)=>hr(VC(e,t),r=>hr(pc(r.address),n=>qm(n,r.prefixLength??rd(n))));var zm=e=>`${$r(e.address)}/${e.prefixLength}`;var GC="~effect/net/IpNetwork",qB=e=>Wm(e)&&Br(e.address),zB=e=>Wm(e)&&ts(e.address),Wm=e=>O(e,GC),JY={...Ot,_tag:"IpNetwork",[GC]:GC,[ae](e){return Wm(e)&&this.prefixLength===e.prefixLength&&Z(this.address,e.address)},[ie](){return he(G(this.address),zt(this.prefixLength))},toString(){return Km(this)},toJSON(){return this.toString()}},ZY=e=>{let t=Object.assign(Object.create(JY),{address:e.address,prefixLength:e.prefixLength});return Object.freeze(t)},QY=e=>Br(e)?RS(e):AC(e);var YY=(e,t)=>{let r=Math.floor(t/8),n=t%8;return e.map((o,s)=>s<r?o:s===r&&n!==0?o&(255<<8-n&255):0)},JC=(e,t)=>hr(qm(e,t),r=>{let n=QY(e),o=YY(n,t);return n.some((s,i)=>s!==o[i])?re(new es({input:e,message:"address has non-zero host bits"})):X(ZY(r))});var WB=e=>hr(DS(e,{prefix:"required"}),t=>JC(t.address,t.prefixLength)),KB=e=>hr(LS(e,{prefix:"required"}),t=>JC(t.address,t.prefixLength)),VB=e=>hr(BS(e,{prefix:"required"}),t=>JC(t.address,t.prefixLength));var Km=e=>`${$r(e.address)}/${e.prefixLength}`;var Vm=gS;function Cr(){return(e,t,r)=>J(new uc(e.map(wm),n=>t(n.map(o=>J(o))),r))}function Ge(e,t){return Cr()([],()=>(r,n,o)=>e(r)?I(r):D(new at(n,r,o)),t)}function e7(e){return e}function t7(e){return t=>t.annotate(e)}function r7(e){return t=>QC(QC(t).annotate(e))}function n7(e){return t=>t.rebuild(Wl(t.ast,e))}function o7(e){return e}var $n=class extends sr("SchemaError"){[ed]=ed;constructor(t){let r=Ir();yt(0);try{super({issue:t})}finally{yt(r)}}get message(){return b1(this.issue)}toJSON(){return{_tag:this._tag,message:this.message}}[Qe](){return this.toJSON()}toString(){return`SchemaError(${this.message})`}};function fd(e){return vB(e)}function a$(e){return Xe(e)?tA(e):rt(e,t=>aa(()=>Ka(t,r=>new $n(r))))}function tA(e){return ft(e)?e:ir(Ka(e.cause,t=>new $n(t)))}function c$(e,t){let r;for(let n of e.reasons){if(!Ng(n)||!fd(n.error))throw new globalThis.Error(t,{cause:e});r??=n.error}if(r===void 0)throw new globalThis.Error(t,{cause:e});return r}function u$(e){return dy(e).then(t=>{if(ft(t))return t.value;throw c$(t.cause,"Promise adapter can only reject schema errors")})}function f$(e){let t=ki(e);if(ft(t))return t.value;throw c$(t.cause,"Sync adapter can only throw schema errors")}function s7(e,t){return rB(e,t)}function i7(e){return nB(e)}var a7=Zv,c7=hL;function xc(e,t){let r=ot(e,t);return(n,o)=>a$(r(n,o))}var u7=xc;function l$(e,t){let r=xL(e,t);return(n,o)=>tA(r(n,o))}var d$=l$,f7=Yv,l7=gL;function p$(e,t){let r=yL(e,t);return(n,o)=>UI(r(n,o),s=>new $n(s))}var d7=p$;function m$(e,t){let r=xc(e,t);return(n,o)=>u$(r(n,o))}var p7=m$;function jS(e,t){let r=xc(e,t);return(n,o)=>f$(r(n,o))}var Zm=jS;function Qm(e,t){let r=ju(e,t);return(n,o)=>a$(r(n,o))}var rA=Qm;function h$(e,t){let r=bL(e,t);return(n,o)=>tA(r(n,o))}var x$=h$,m7=Xv,h7=EL;function g$(e,t){let r=IL(e,t);return(n,o)=>UI(r(n,o),s=>new $n(s))}var x7=g$;function y$(e,t){let r=Qm(e,t);return(n,o)=>u$(r(n,o))}var g7=y$;function Ym(e,t){let r=Qm(e,t);return(n,o)=>f$(r(n,o))}var nA=Ym,J=Ls;function Ju(e){return O(e,Vm)&&e[Vm]===Vm}var Gu=bn(e=>J($u(e.ast),{schema:e})),y7=bn(e=>e.schema),lr=bn(e=>{let t=zS(e);return J(V2(e.ast),{schema:t})}),S7=bn(e=>e.schema.members[0]),b7=bn(e=>J(Dv(e.ast),{schema:e})),E7=bn(e=>e.schema),oo=bn(e=>J(Nt(e.ast),{schema:e})),ld=bn(e=>J(Bn(e.ast),{schema:e})),Gm="~effect/Schema/flip";function I7(e){return O(e,Gm)&&e[Gm]===Gm}function QC(e){return I7(e)?e.schema.rebuild(Oo(e.ast)):J(Oo(e.ast),{[Gm]:Gm,schema:e})}function fr(e){let t=J(new Ln(e),{literal:e,transform(r){return t.pipe(ee(fr(r),{decode:Ie(()=>r),encode:Ie(()=>e)}))}});return t}function S$(e){return e.map(t=>Ju(t)?t.ast:new Ln(t))}function T7(e){return J(new Cv(S$(e)),{parts:e})}function w7(e){return J(C2(S$(e)),{parts:e})}function v7(e){return J(new v2(Object.keys(e).filter(t=>typeof e[e[t]]!="number").map(t=>[t,e[t]])),{enums:e})}var Mi=J(vv),C7=J(T2),Xm=J(pa),HS=J(Tv),oA=J(wv),z=J(Ro),A7=z,Zu=J(Av),Fi=J(R2),b$=J(O2),dd=J(_2),pd=J(I2),k7=J(w2);function R7(e){return J(new k2(e))}function sA(e,t){return J(e,{fields:t,mapFields(r,n){let o=r(this.fields);return sA(eS(o,n?.unsafePreserveChecks?this.ast.checks:void 0),o)}})}function Te(e){return sA(eS(e,void 0),e)}function O7(e){return bn(t=>t.mapFields(xB(e)))}var _7=e=>typeof e=="symbol"?e:globalThis.String(e);function P7(e){return function(t){let r={},n=Object.create(null),o=Object.create(null),s=new Set;for(let i of Reflect.ownKeys(t.fields)){let a=ld(t.fields[i]),c=Object.hasOwn(e,i),u=c?e[i]:i,f=_7(u);if(s.has(f))throw new globalThis.Error(`Duplicate encoded keys: ${ni(u)}`);s.add(f),B(r,u,a),c&&(n[i]=u,o[u]=i)}return Te(r).pipe(ee(t,Fe({decode:gC(o),encode:gC(n)})))}}function M7(e,t){return r=>{let n=Dx(r.fields,oo),o=Te({...n,...e});return r.pipe(ee(o,Fe({decode:s=>{let i={...s};for(let a in e){let c=t[a],u=c(s);de(u)&&B(i,a,u.value)}return i},encode:s=>{let i={...s};for(let a in e)delete i[a];return i}})))}}function Qu(e,t){return J(J2(e.ast,t.ast),{key:e,value:t})}function F7(e,t){return J(U2(e.ast,t.map(wm)),{schema:e,records:t})}function E$(e,t){return J(e,{elements:t,mapElements(r,n){let o=r(this.elements);return E$(_v(o,n?.unsafePreserveChecks?this.ast.checks:void 0),o)}})}function rs(e){return E$(_v(e),e)}function N7(e,t){return J(D2(e.ast,t.map(wm)),{schema:e,rest:t})}var ct=bn(e=>J(new Xo(!1,[],[e.ast]),{value:e}));function qS(e,t,r){return t!==void 0&&r!==void 0?e.check(fA(t,r)):t!==void 0?e.check($$(t)):r!==void 0?e.check(q$(r)):e}var Yu=bn(e=>J(new Xo(!1,[e.ast],[e.ast]),{value:e}));function U7(e){let t=ct(e),r=ct(oo(e)),n=ee(rs([Xm]),Fe({decode:o=>[o],encode:([o])=>o}))(e);return J(Pe([n,t]).pipe(ee(r)).ast,{from:Pe([e,t]),to:r})}function D7(e){return ct(e).check(dA())}var L7=bn(e=>J(L2(e.ast),{schema:e}));function I$(e,t){return J(e,{members:t,mapMembers(r,n){let o=r(this.members);return I$(tS(o,this.ast.options,n?.unsafePreserveChecks?this.ast.checks:void 0),o)}})}function Pe(e,t){return I$(tS(e,t,void 0),e)}function Fo(e){let t=e.map(fr);return J(tS(t,void 0,void 0),{literals:e,members:t,mapMembers(r){return Pe(r(this.members))},pick(r){return Fo(r)},transform(r){return Pe(t.map((n,o)=>n.transform(r[o])))}})}var iA=bn(e=>Pe([e,HS])),zS=bn(e=>Pe([e,oA])),T$=bn(e=>Pe([e,HS,oA]));function w$(e){return J(new Mv(()=>e().ast))}function B7(...e){return t=>t.check(...e)}function v$(e,t){return r=>J(Pi(r.ast,[nS(e,t)]),{schema:r})}function WS(e){return t=>J(t.ast,{schema:t,identifier:e})}function $7(e,t){return r=>(t.checks?r.check(...t.checks):r).pipe(WS(e))}function C$(e){return t=>J(W2(t.ast,new Ky(e,F)),{schema:t})}function A$(e){return t=>J(K2(t.ast,new Ky(F,e)),{schema:t})}function j7(e){return k$(e)}function k$(e){return t=>C$(my(e))(t)}function H7(e){return R$(e)}function R$(e){return t=>A$(my(e))(t)}function ee(e,t){return r=>J(Kl(r.ast,e.ast,t?Vy(t):Nl()),{from:r,to:e})}function md(){return(e,t)=>Ne()(e,{decode:t,encode:w1})}var O$=Fo(["true","yes","on","1","y"]),_$=Fo(["false","no","off","0","n"]),q7=Fo([...O$.literals,..._$.literals]).pipe(ee(Fi,Fe({decode:e=>e==="true"||e==="yes"||e==="on"||e==="1"||e==="y",encode:e=>e?"true":"false"})));function z7(e){return t=>ee(oo(t),e)(t)}function aA(e,t){return r=>t?ee(r,t)(e):ee(r)(e)}function W7(e){return t=>ee(t,e)(ld(t))}function P$(e){return t=>J(G2(t.ast,e),{schema:t})}function M$(e){return rt(e,t=>aa(()=>Ka(t,r=>r.issue)))}function cA(e,t){let r=t?.encodingStrategy==="omit"?sv():Oi();return n=>Gu(ld(n)).pipe(ee(n,{decode:iv(M$(e)),encode:r}))}function K7(e,t){return r=>oo(r).pipe(cA(e,t),aA(Gu(r)))}function F$(e,t){let r=t?.encodingStrategy==="omit"?sv():Oi();return n=>lr(ld(n)).pipe(ee(n,{decode:iv(M$(e)),encode:r}))}function V7(e,t){return r=>oo(r).pipe(F$(e,t),aA(lr(r)))}function He(e){return fr(e).pipe(P$(I(e)))}function G7(e){return He(e).pipe(cA(I(e),{encodingStrategy:"omit"}))}function ya(e,t){return Te({_tag:He(e),...t})}function N$(e){return t=>{let r={},n=[],o=new Set,s={},i=f=>p=>f.includes(p[e]);return a(t),Object.assign(t,{tag:e,cases:r,discriminants:n,isAnyOf:i,guards:s,match:c,matchOrElse:u});function a(f){let p=f.ast;if(S2(p)&&"members"in f&&globalThis.Array.isArray(f.members)&&f.members.every(Ju))return f.members.forEach(a);let m=ac(p);if(m.length>0){let h=m.find(x=>x.key===e)?.literal;if(mx(h)){let x=typeof h=="number"?globalThis.String(h):h;if(o.has(x))throw new globalThis.Error(`Duplicate discriminant: ${globalThis.String(h)}`);o.add(x),n.push(h),B(r,h,f),B(s,h,Zv(oo(f)));return}}throw new globalThis.Error("No literal or unique symbol found")}function c(){if(arguments.length===1){let x=arguments[0];return function(g){let y=g[e];return(Object.hasOwn(x,y)?x[y]:void 0)(g)}}let f=arguments[0],p=arguments[1],m=f[e];return(Object.hasOwn(p,m)?p[m]:void 0)(f)}function u(){if(arguments.length===2){let g=arguments[0],y=arguments[1];return function(E){let b=E[e];return(Object.hasOwn(g,b)?g[b]??y:y)(E)}}let f=arguments[0],p=arguments[1],m=arguments[2],h=f[e];return(Object.hasOwn(p,h)?p[h]??m:m)(f)}}}function J7(e){let t={},r=[];for(let u of Object.keys(e)){let f=ya(u,e[u]);B(t,u,f),r.push(f)}let n=Pe(r),{tag:o,guards:s,isAnyOf:i,match:a,matchOrElse:c}=N$("_tag")(n);return J(n.ast,{tag:o,cases:t,isAnyOf:i,guards:s,match:a,matchOrElse:c})}function Z7(){return e=>e}function gc(e,t){return Ge(r=>r instanceof e,t)}function Ne(){return(e,t)=>new jt(e.ast,Vy(t))}var Je=rS;function Q7(e,t=void 0){return new Du(e,t)}var GB="^\\S[\\s\\S]*\\S$|^\\S$|^$";function U$(e){let t=new globalThis.RegExp(GB);return Je(r=>r.trim()===r,{expected:"a string with no leading or trailing whitespace",representation:{id:"effect/schema/isTrimmed",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isTrimmed()"}),arbitraryConstraint:{patterns:[{source:GB,flags:""}]},...e})}function Xu(e,t){let r=e.source,n=e.flags,o=/^[dg]*uy?$/.test(n),s=n===""?`new RegExp(${H(r)})`:`new RegExp(${H(r)}, ${H(n)})`;return Cm(e,{toJsonSchema:()=>o?{pattern:n.endsWith("y")?`^(?:${r})`:r}:[{},!0],toCode:()=>({runtime:`Schema.isPattern(${s})`}),...t})}function Y7(e){return $v({toCode:()=>({runtime:"Schema.isStringFinite()"}),...e})}function X7(e){return jv({toCode:()=>({runtime:"Schema.isStringBigInt()"}),...e})}function eX(e){return qv({toCode:()=>({runtime:"Schema.isStringSymbol()"}),...e})}var tX=e=>e?new globalThis.RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|[fF]{8}-[fF]{4}-[fF]{4}-[fF]{4}-[fF]{12})$/;function rX(e,t){let r=tX(e);return Xu(r,{expected:e?`a UUID v${e}`:"a UUID",representation:{id:"effect/schema/isUUID",payload:{version:e??null}},toJsonSchema:()=>({pattern:r.source,format:"uuid"}),toCode:()=>({runtime:e===void 0?"Schema.isUUID()":`Schema.isUUID(${e})`}),...t})}var JB=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;function nX(e){return Xu(JB,{expected:"a GUID",representation:{id:"effect/schema/isGUID",payload:null},toJsonSchema:()=>({pattern:JB.source}),toCode:()=>({runtime:"Schema.isGUID()"}),...e})}function oX(e){let t=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;return Xu(t,{representation:{id:"effect/schema/isULID",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isULID()"}),...e})}function D$(e){let t=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;return Xu(t,{expected:"a base64 encoded string",representation:{id:"effect/schema/isBase64",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isBase64()"}),...e})}function sX(e){let t=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;return Xu(t,{expected:"a base64url encoded string",representation:{id:"effect/schema/isBase64Url",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isBase64Url()"}),...e})}function uA(e,t,r){if(e.length===0)return t.length===0?{}:[{},!0];let n={pattern:new globalThis.RegExp(r).source};return e===t?n:[n,!0]}function iX(e,t){let r=JSON.stringify(e),n=new globalThis.RegExp(`^${ha(e)}`),o=e.replace(/[\uD800-\uDBFF]$/,"");return Je(s=>s.startsWith(e),{expected:`a string starting with ${r}`,representation:{id:"effect/schema/isStartingWith",payload:{startsWith:e}},toJsonSchema:()=>uA(o,e,`^${ha(o)}`),toCode:()=>({runtime:`Schema.isStartingWith(${H(e)})`}),arbitraryConstraint:{patterns:[{source:n.source,flags:n.flags}]},...t})}function aX(e,t){let r=JSON.stringify(e),n=new globalThis.RegExp(`${ha(e)}$`),o=e.replace(/^[\uDC00-\uDFFF]/,"");return Je(s=>s.endsWith(e),{expected:`a string ending with ${r}`,representation:{id:"effect/schema/isEndingWith",payload:{endsWith:e}},toJsonSchema:()=>uA(o,e,`${ha(o)}$`),toCode:()=>({runtime:`Schema.isEndingWith(${H(e)})`}),arbitraryConstraint:{patterns:[{source:n.source,flags:n.flags}]},...t})}function cX(e,t){let r=JSON.stringify(e),n=new globalThis.RegExp(ha(e)),o=e.replace(/^[\uDC00-\uDFFF]|[\uD800-\uDBFF]$/g,"");return Je(s=>s.includes(e),{expected:`a string including ${r}`,representation:{id:"effect/schema/isIncluding",payload:{includes:e}},toJsonSchema:()=>uA(o,e,ha(o)),toCode:()=>({runtime:`Schema.isIncluding(${H(e)})`}),arbitraryConstraint:{patterns:[{source:n.source,flags:n.flags}]},...t})}var ZB="^[^a-z]*$";function uX(e){let t=new globalThis.RegExp(ZB);return Je(r=>r.toUpperCase()===r,{expected:"a string with all characters in uppercase",representation:{id:"effect/schema/isUppercased",payload:null},toJsonSchema:()=>[{pattern:t.source},!0],toCode:()=>({runtime:"Schema.isUppercased()"}),arbitraryConstraint:{patterns:[{source:ZB,flags:""}]},...e})}var QB="^[^A-Z]*$";function fX(e){let t=new globalThis.RegExp(QB);return Je(r=>r.toLowerCase()===r,{expected:"a string with all characters in lowercase",representation:{id:"effect/schema/isLowercased",payload:null},toJsonSchema:()=>[{pattern:t.source},!0],toCode:()=>({runtime:"Schema.isLowercased()"}),arbitraryConstraint:{patterns:[{source:QB,flags:""}]},...e})}var YB="^(?:[^a-z][\\s\\S]*)?$";function lX(e){let t=new globalThis.RegExp(YB);return Je(r=>r.charAt(0).toUpperCase()===r.charAt(0),{expected:"a string with the first character in uppercase",representation:{id:"effect/schema/isCapitalized",payload:null},toJsonSchema:()=>[{pattern:t.source},!0],toCode:()=>({runtime:"Schema.isCapitalized()"}),arbitraryConstraint:{patterns:[{source:YB,flags:""}]},...e})}var XB="^(?:[^A-Z][\\s\\S]*)?$";function dX(e){let t=new globalThis.RegExp(XB);return Je(r=>r.charAt(0).toLowerCase()===r.charAt(0),{expected:"a string with the first character in lowercase",representation:{id:"effect/schema/isUncapitalized",payload:null},toJsonSchema:()=>[{pattern:t.source},!0],toCode:()=>({runtime:"Schema.isUncapitalized()"}),arbitraryConstraint:{patterns:[{source:XB,flags:""}]},...e})}var KS=J(Nv),pX=Fv;function eh(e){let t=Yc(e.order),r=e.formatter??H;return(n,o)=>Je(s=>t(s,n),{expected:`a value greater than ${r(n)}`,arbitraryConstraint:{order:e.order,minimum:n,exclusiveMinimum:!0},...e.annotate?.(n),...o})}function th(e){let t=op(e.order),r=e.formatter??H;return(n,o)=>Je(s=>t(s,n),{expected:`a value greater than or equal to ${r(n)}`,arbitraryConstraint:{order:e.order,minimum:n},...e.annotate?.(n),...o})}function rh(e){let t=rp(e.order),r=e.formatter??H;return(n,o)=>Je(s=>t(s,n),{expected:`a value less than ${r(n)}`,arbitraryConstraint:{order:e.order,maximum:n,exclusiveMaximum:!0},...e.annotate?.(n),...o})}function nh(e){let t=np(e.order),r=e.formatter??H;return(n,o)=>Je(s=>t(s,n),{expected:`a value less than or equal to ${r(n)}`,arbitraryConstraint:{order:e.order,maximum:n},...e.annotate?.(n),...o})}function oh(e){let t=op(e.order),r=Yc(e.order),n=np(e.order),o=rp(e.order),s=e.formatter??H;return(i,a)=>{let c=i.exclusiveMinimum?r:t,u=i.exclusiveMaximum?o:n;return Je(f=>c(f,i.minimum)&&u(f,i.maximum),{expected:`a value between ${s(i.minimum)}${i.exclusiveMinimum?" (excluded)":""} and ${s(i.maximum)}${i.exclusiveMaximum?" (excluded)":""}`,arbitraryConstraint:{order:e.order,minimum:i.minimum,maximum:i.maximum,...i.exclusiveMinimum&&{exclusiveMinimum:!0},...i.exclusiveMaximum&&{exclusiveMaximum:!0}},...e.annotate?.(i),...a})}}function mX(e){return(t,r)=>{let n=e.formatter??H;return Je(o=>e.remainder(o,t)===e.zero,{expected:`a value that is a multiple of ${n(t)}`,...e.annotate?.(t),...r})}}function ad(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${H(e)}`);return e}var hX=eh({order:Ki,annotate:e=>({representation:{id:"effect/schema/isGreaterThan",payload:{exclusiveMinimum:ad(e)}},toJsonSchema:()=>({exclusiveMinimum:e}),toCode:()=>({runtime:`Schema.isGreaterThan(${H(e)})`})})}),L$=th({order:Ki,annotate:e=>({representation:{id:"effect/schema/isGreaterThanOrEqualTo",payload:{minimum:ad(e)}},toJsonSchema:()=>({minimum:e}),toCode:()=>({runtime:`Schema.isGreaterThanOrEqualTo(${H(e)})`})})}),xX=rh({order:Ki,annotate:e=>({representation:{id:"effect/schema/isLessThan",payload:{exclusiveMaximum:ad(e)}},toJsonSchema:()=>({exclusiveMaximum:e}),toCode:()=>({runtime:`Schema.isLessThan(${H(e)})`})})}),gX=nh({order:Ki,annotate:e=>({representation:{id:"effect/schema/isLessThanOrEqualTo",payload:{maximum:ad(e)}},toJsonSchema:()=>({maximum:e}),toCode:()=>({runtime:`Schema.isLessThanOrEqualTo(${H(e)})`})})}),yc=oh({order:Ki,annotate:e=>{let t=e.exclusiveMinimum?!0:void 0,r=e.exclusiveMaximum?!0:void 0;return{representation:{id:"effect/schema/isBetween",payload:{minimum:ad(e.minimum),maximum:ad(e.maximum),...t&&{exclusiveMinimum:t},...r&&{exclusiveMaximum:r}}},toJsonSchema:()=>({[t?"exclusiveMinimum":"minimum"]:e.minimum,[r?"exclusiveMaximum":"maximum"]:e.maximum}),toCode:()=>({runtime:`Schema.isBetween({ minimum: ${H(e.minimum)}, maximum: ${H(e.maximum)}, exclusiveMinimum: ${H(t)}, exclusiveMaximum: ${H(r)} })`})}}});function yX(e,t){if(!globalThis.Number.isFinite(e)||e===0)throw new globalThis.RangeError(`Expected a finite non-zero number, got ${globalThis.String(e)}`);return e=globalThis.Math.abs(e),Je(r=>iU(r,e)===0,{expected:`a value that is a multiple of ${e}`,representation:{id:"effect/schema/isMultipleOf",payload:{divisor:e}},toJsonSchema:()=>({multipleOf:e}),toCode:()=>({runtime:`Schema.isMultipleOf(${H(e)})`}),...t})}function VS(e){return Je(t=>globalThis.Number.isSafeInteger(t),{expected:"an integer",representation:{id:"effect/schema/isInt",payload:null},toJsonSchema:()=>({type:"integer",minimum:globalThis.Number.MIN_SAFE_INTEGER,maximum:globalThis.Number.MAX_SAFE_INTEGER}),toCode:()=>({runtime:"Schema.isInt()"}),arbitraryConstraint:{number:"integer"},...e})}var In=Zu.check(VS()),Vu=In.check(L$(0));function SX(e){return new Du([VS(),yc({minimum:-2147483648,maximum:2147483647})],{expected:"a 32-bit integer",...e})}function bX(e){return new Du([VS(),yc({minimum:0,maximum:4294967295})],{expected:"a 32-bit unsigned integer",...e})}function cd(e){if(globalThis.Number.isNaN(e.getTime()))throw new globalThis.RangeError(`Expected a valid Date, got ${H(e)}`);return e.toISOString()}function ud(e){return`new Date(${H(e.getTime())})`}var EX=eh({order:Df,annotate:e=>({representation:{id:"effect/schema/isGreaterThanDate",payload:{exclusiveMinimum:cd(e)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isGreaterThanDate(${ud(e)})`})})}),IX=th({order:Df,annotate:e=>({representation:{id:"effect/schema/isGreaterThanOrEqualToDate",payload:{minimum:cd(e)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isGreaterThanOrEqualToDate(${ud(e)})`})})}),TX=rh({order:Df,annotate:e=>({representation:{id:"effect/schema/isLessThanDate",payload:{exclusiveMaximum:cd(e)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isLessThanDate(${ud(e)})`})})}),wX=nh({order:Df,annotate:e=>({representation:{id:"effect/schema/isLessThanOrEqualToDate",payload:{maximum:cd(e)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isLessThanOrEqualToDate(${ud(e)})`})})}),vX=oh({order:Df,annotate:e=>{let t=e.exclusiveMinimum?!0:void 0,r=e.exclusiveMaximum?!0:void 0;return{representation:{id:"effect/schema/isBetweenDate",payload:{minimum:cd(e.minimum),maximum:cd(e.maximum),...t&&{exclusiveMinimum:t},...r&&{exclusiveMaximum:r}}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isBetweenDate({ minimum: ${ud(e.minimum)}, maximum: ${ud(e.maximum)}, exclusiveMinimum: ${H(t)}, exclusiveMaximum: ${H(r)} })`})}}}),CX=eh({order:Uf,annotate:e=>({representation:{id:"effect/schema/isGreaterThanBigInt",payload:{exclusiveMinimum:e.toString(10)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isGreaterThanBigInt(${H(e)})`})})}),B$=th({order:Uf,annotate:e=>({representation:{id:"effect/schema/isGreaterThanOrEqualToBigInt",payload:{minimum:e.toString(10)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isGreaterThanOrEqualToBigInt(${H(e)})`})})}),AX=rh({order:Uf,annotate:e=>({representation:{id:"effect/schema/isLessThanBigInt",payload:{exclusiveMaximum:e.toString(10)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isLessThanBigInt(${H(e)})`})})}),kX=nh({order:Uf,annotate:e=>({representation:{id:"effect/schema/isLessThanOrEqualToBigInt",payload:{maximum:e.toString(10)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isLessThanOrEqualToBigInt(${H(e)})`})})}),RX=oh({order:Uf,annotate:e=>{let t=e.exclusiveMinimum?!0:void 0,r=e.exclusiveMaximum?!0:void 0;return{representation:{id:"effect/schema/isBetweenBigInt",payload:{minimum:e.minimum.toString(10),maximum:e.maximum.toString(10),...t&&{exclusiveMinimum:t},...r&&{exclusiveMaximum:r}}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isBetweenBigInt({ minimum: ${H(e.minimum)}, maximum: ${H(e.maximum)}, exclusiveMinimum: ${H(t)}, exclusiveMaximum: ${H(r)} })`})}}});function $$(e,t){return e=En(e),j$(e,Math.ceil(e/2),t)}function j$(e,t,r){return Je(n=>n.length>=e,{expected:`a value with a length of at least ${e}`,representation:{id:"effect/schema/isMinLength",payload:{minLength:e}},toJsonSchema:({type:n})=>n==="string"?e<=1?{minLength:t}:[{minLength:t},!0]:n==="array"?{minItems:e}:n===void 0?[{minLength:t,minItems:e},!0]:[{},!0],toCode:()=>({runtime:`Schema.isMinLength(${e})`}),[ro]:!0,arbitraryConstraint:{minLength:e},...r})}function H$(e){return j$(1,1,e)}function q$(e,t){return e=En(e),Je(r=>r.length<=e,{expected:`a value with a length of at most ${e}`,representation:{id:"effect/schema/isMaxLength",payload:{maxLength:e}},toJsonSchema:({type:r})=>r==="string"?e===0?{maxLength:e}:[{maxLength:e},!0]:r==="array"?{maxItems:e}:r===void 0?[{maxLength:e,maxItems:e},!0]:[{},!0],toCode:()=>({runtime:`Schema.isMaxLength(${e})`}),[ro]:!0,arbitraryConstraint:{maxLength:e},...t})}function fA(e,t,r){return e=En(e),t=En(t),Je(n=>n.length>=e&&n.length<=t,{expected:e===t?`a value with a length of ${e}`:`a value with a length between ${e} and ${t}`,representation:{id:"effect/schema/isBetweenLength",payload:{minimum:e,maximum:t}},toJsonSchema:({type:n})=>n==="string"?t===0||Math.ceil(e/2)>t?{minLength:Math.ceil(e/2),maxLength:t}:[{minLength:Math.ceil(e/2),maxLength:t},!0]:n==="array"?{minItems:e,maxItems:t}:n===void 0?[{minLength:Math.ceil(e/2),maxLength:t,minItems:e,maxItems:t},!0]:[{},!0],toCode:()=>({runtime:`Schema.isBetweenLength(${e}, ${t})`}),[ro]:!0,arbitraryConstraint:{minLength:e,maxLength:t},...r})}function OX(e,t){return e=En(e),Je(r=>lA(r,e)>=e,{expected:`a string with at least ${e} code points`,representation:{id:"effect/schema/isMinCodePoints",payload:{minCodePoints:e}},toJsonSchema:()=>({minLength:e}),toCode:()=>({runtime:`Schema.isMinCodePoints(${e})`}),arbitraryConstraint:{minCodePoints:e},...t})}function _X(e,t){return e=En(e),Je(r=>lA(r,e+1)<=e,{expected:`a string with at most ${e} code points`,representation:{id:"effect/schema/isMaxCodePoints",payload:{maxCodePoints:e}},toJsonSchema:()=>({maxLength:e}),toCode:()=>({runtime:`Schema.isMaxCodePoints(${e})`}),arbitraryConstraint:{maxCodePoints:e},...t})}function PX(e,t,r){return e=En(e),t=En(t),Je(n=>{let o=lA(n,t+1);return o>=e&&o<=t},{expected:e===t?`a string with ${e} code points`:`a string with between ${e} and ${t} code points`,representation:{id:"effect/schema/isBetweenCodePoints",payload:{minimum:e,maximum:t}},toJsonSchema:()=>({allOf:[{minLength:e},{maxLength:t}]}),toCode:()=>({runtime:`Schema.isBetweenCodePoints(${e}, ${t})`}),arbitraryConstraint:{minCodePoints:e,maxCodePoints:t},...r})}function lA(e,t){if(t===0)return 0;let r=0;for(let n of e)if(++r>=t)break;return r}function En(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${e}`);return Math.max(0,Math.floor(e))}function MX(e,t){return e=En(e),Je(r=>r.size>=e,{expected:`a value with a size of at least ${e}`,representation:{id:"effect/schema/isMinSize",payload:{minSize:e}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isMinSize(${e})`}),[ro]:!0,arbitraryConstraint:{minSize:e},...t})}function FX(e,t){return e=En(e),Je(r=>r.size<=e,{expected:`a value with a size of at most ${e}`,representation:{id:"effect/schema/isMaxSize",payload:{maxSize:e}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isMaxSize(${e})`}),[ro]:!0,arbitraryConstraint:{maxSize:e},...t})}function NX(e,t,r){return e=En(e),t=En(t),Je(n=>n.size>=e&&n.size<=t,{expected:e===t?`a value with a size of ${e}`:`a value with a size between ${e} and ${t}`,representation:{id:"effect/schema/isBetweenSize",payload:{minimum:e,maximum:t}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isBetweenSize(${e}, ${t})`}),[ro]:!0,arbitraryConstraint:{minSize:e,maxSize:t},...r})}function UX(e,t){return e=En(e),Je(r=>Reflect.ownKeys(r).length>=e,{expected:`a value with at least ${e===1?"1 entry":`${e} entries`}`,representation:{id:"effect/schema/isMinProperties",payload:{minProperties:e}},toJsonSchema:({type:r})=>r==="object"?{minProperties:e}:[{minProperties:e},!0],toCode:()=>({runtime:`Schema.isMinProperties(${e})`}),[ro]:!0,arbitraryConstraint:{minProperties:e},...t})}function DX(e,t){return e=En(e),Je(r=>Reflect.ownKeys(r).length<=e,{expected:`a value with at most ${e===1?"1 entry":`${e} entries`}`,representation:{id:"effect/schema/isMaxProperties",payload:{maxProperties:e}},toJsonSchema:({type:r})=>r==="object"?{maxProperties:e}:[{maxProperties:e},!0],toCode:()=>({runtime:`Schema.isMaxProperties(${e})`}),[ro]:!0,arbitraryConstraint:{maxProperties:e},...t})}function LX(e,t,r){return e=En(e),t=En(t),Je(n=>Reflect.ownKeys(n).length>=e&&Reflect.ownKeys(n).length<=t,{expected:e===t?`a value with exactly ${e===1?"1 entry":`${e} entries`}`:`a value with between ${e} and ${t} entries`,representation:{id:"effect/schema/isBetweenProperties",payload:{minimum:e,maximum:t}},toJsonSchema:({type:n})=>n==="object"?{minProperties:e,maxProperties:t}:[{minProperties:e,maxProperties:t},!0],toCode:()=>({runtime:`Schema.isBetweenProperties(${e}, ${t})`}),[ro]:!0,arbitraryConstraint:{minProperties:e,maxProperties:t},...r})}function BX(e,t){let r=ld(e),n=mL(r.ast);return Je((o,s,i)=>{let a=Reflect.ownKeys(o),c=[];for(let u of a){let f=n(u,i);if(f!==void 0&&(c.push(new At([u],f)),i.errors==="first"))break}return Gr(c)?new Ft(s,c,o,i):!0},{expected:"an object with property names matching the schema",representation:{id:"effect/schema/isPropertyNames",payload:null,schemas:[r.ast]},toJsonSchema:({schemas:o,type:s})=>s==="object"?{propertyNames:o[0]}:[{propertyNames:o[0]},!0],toCode:({schemas:o})=>({runtime:`Schema.isPropertyNames(${o[0].runtime})`}),[ro]:!0,...t})}function dA(e){return Je(t=>qx(t).length===t.length,{expected:"an array with unique items",representation:{id:"effect/schema/isUnique",payload:null},toJsonSchema:()=>({uniqueItems:!0}),toCode:()=>({runtime:"Schema.isUnique()"}),arbitraryConstraint:{uniqueBy:F},...e})}function z$(e){return Je(t=>qx(t.map(([r])=>r)).length===t.length,{expected:"an array with unique keys",representation:{id:"effect/schema/isUniqueKey",payload:null},toCode:()=>({runtime:"Schema.isUniqueKey()"}),arbitraryConstraint:{uniqueBy:t=>t[0]},...e})}var pA=z.check(H$()),$X=z.check(fA(1,1)),W$=e=>(e?.includeStack===!0?1:0)|(e?.excludeCause===!0?2:0),K$=e=>{switch(e){case 0:return;case 1:return{includeStack:!0};case 2:return{excludeCause:!0};case 3:return{includeStack:!0,excludeCause:!0}}},e$=[];function jX(e){let t=W$(e),r=e$[t];if(r!==void 0)return r;let n=K$(t),o=gc(globalThis.Error,{representation:{id:"effect/schema/Error",payload:n??null},toCode:()=>({runtime:n!==void 0?`Schema.ErrorInstance(${H(n)})`:"Schema.ErrorInstance()",Type:"globalThis.Error"}),expected:"Error",toCodecJson:()=>Ne()(pre,Q1(n))});return e$[t]=o,o}var t$=[];function er(e){let t=W$(e),r=t$[t];if(r!==void 0)return r;let n=XS.pipe(ee(Xm,Y1(K$(t))));return t$[t]=n,n}function HX(e,t){let r=Cr()([e,t],([n,o])=>{let s=ct(rs([n,o]));return(i,a,c)=>i instanceof globalThis.Map?cr(ot(s)([...i],c),{onSuccess:u=>new globalThis.Map(u),onFailure:u=>tn(a,"entries",u,i,c)}):D(new at(a,i,c))},{representation:{id:"effect/schema/ReadonlyMap",payload:null},toCode:({typeParameters:n})=>({runtime:`Schema.ReadonlyMap(${n[0].runtime}, ${n[1].runtime})`,Type:`globalThis.ReadonlyMap<${n[0].Type}, ${n[1].Type}>`}),expected:"ReadonlyMap",toCodec:([n,o])=>Ne()(ct(rs([n,o])),Fe({decode:s=>new globalThis.Map(s),encode:s=>[...s.entries()]}))});return J(r.ast,{key:e,value:t})}function qX(e){let t=Cr()([e],([r])=>{let n=ct(r);return(o,s,i)=>o instanceof globalThis.Set?cr(ot(n)([...o],i),{onSuccess:a=>new globalThis.Set(a),onFailure:a=>tn(s,"values",a,o,i)}):D(new at(s,o,i))},{representation:{id:"effect/schema/ReadonlySet",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.ReadonlySet(${r[0].runtime})`,Type:`globalThis.ReadonlySet<${r[0].Type}>`}),expected:"ReadonlySet",toCodec:([r])=>Ne()(ct(r),Fe({decode:n=>new globalThis.Set(n),encode:n=>[...n.values()]}))});return J(t.ast,{value:e})}var zX=gc(globalThis.RegExp,{representation:{id:"effect/schema/RegExp",payload:null},toCode:()=>({runtime:"Schema.RegExp",Type:"globalThis.RegExp"}),expected:"RegExp",toCodecJson:()=>Ne()(Te({source:z,flags:z}),Xt({decode:(e,t)=>Go({try:()=>new globalThis.RegExp(e.source,e.flags),catch:()=>new le({expected:"valid RegExp source and flags"},e,t)}),encode:e=>I({source:e.source,flags:e.flags})}))}),V$=z.annotate({expected:"a string that will be decoded as a URL"}),G$=gc(globalThis.URL,{representation:{id:"effect/schema/URL",payload:null},toCode:()=>({runtime:"Schema.URL",Type:"globalThis.URL"}),expected:"URL",toCodecJson:()=>Ne()(V$,lv)}),WX=V$.pipe(ee(G$,lv)),J$=z.annotate({expected:"a string that will be decoded as a Date"}),GS=Ge(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:()=>Ne()(J$,uv)}),KX=J$.pipe(ee(GS,uv)),VX=In.pipe(ee(GS,W1)),GX=z.annotate({expected:"a string that will be decoded as JSON",contentMediaType:"application/json"});function mA(e,t){return GX.pipe(ee(e,c2(t)))}var JX=mA(Xm),Z$=gc(globalThis.File,{representation:{id:"effect/schema/File",payload:null},toCode:()=>({runtime:"Schema.File",Type:"globalThis.File"}),expected:"File",toCodecJson:()=>Ne()(Te({data:z.check(D$()),type:z,name:z,lastModified:In}),Xt({decode:(e,t)=>zn(Cu(e.data),{onFailure:()=>D(new le({expected:"a valid Base64 string"},e.data,t)),onSuccess:r=>{let n=new globalThis.Uint8Array(r);return I(new globalThis.File([n],e.name,{type:e.type,lastModified:e.lastModified}))}}),encode:(e,t)=>Vo({try:async()=>{let r=new globalThis.Uint8Array(await e.arrayBuffer());return{data:Al(r),type:e.type,name:e.name,lastModified:e.lastModified}},catch:()=>new le({expected:"a readable File"},e,t)})}))}),Q$=gc(globalThis.FormData,{representation:{id:"effect/schema/FormData",payload:null},toCode:()=>({runtime:"Schema.FormData",Type:"globalThis.FormData"}),expected:"FormData",toCodecJson:()=>Ne()(ct(rs([z,Pe([Te({_tag:He("String"),value:z}),Te({_tag:He("File"),value:Z$})])])),Xt({decode:e=>{let t=new globalThis.FormData;for(let[r,n]of e)t.append(r,n.value);return I(t)},encode:e=>I(globalThis.Array.from(e.entries()).map(([t,r])=>typeof r=="string"?[t,{_tag:"String",value:r}]:[t,{_tag:"File",value:r}]))}))});function ZX(e){return Q$.pipe(ee(e,u2))}var Y$=gc(globalThis.URLSearchParams,{representation:{id:"effect/schema/URLSearchParams",payload:null},toCode:()=>({runtime:"Schema.URLSearchParams",Type:"globalThis.URLSearchParams"}),expected:"URLSearchParams",toCodecJson:()=>Ne()(z.annotate({expected:"a query string that will be decoded as URLSearchParams"}),Fe({decode:e=>new globalThis.URLSearchParams(e),encode:e=>e.toString()}))});function QX(e){return Y$.pipe(ee(e,f2))}var YX=z.annotate({expected:"a string that will be decoded as a number"}).pipe(ee(Zu,Ul)),XX=z.annotate({expected:"a string that will be decoded as a finite number"}).pipe(ee(KS,Ul)),eee=J(Hv).pipe(ee(dd,Jy)),X$=z.check(U$()),tee=z.annotate({expected:"a string that will be decoded as a trimmed string"}).pipe(ee(X$,z1())),ree=z.annotate({expected:"a base64 encoded string that will be decoded as a UTF-8 string"}).pipe(ee(z,o2)),nee=z.annotate({expected:"a base64 (URL) encoded string that will be decoded as a UTF-8 string"}).pipe(ee(z,s2)),oee=z.annotate({expected:"a hex encoded string that will be decoded as a UTF-8 string"}).pipe(ee(z,i2)),see=z.annotate({expected:"a URI component encoded string that will be decoded as a UTF-8 string"}).pipe(ee(z,a2)),YC=Pe([KS,b$,z]),iee=Te({issues:ct(Te({message:z,path:lr(ct(Pe([YC,Te({key:YC})])))}))}),aee=Fo([0,1]).pipe(ee(Fi,Fe({decode:e=>e===1,encode:e=>e?1:0}))),ej=z.annotate({expected:"a base64 encoded string that will be decoded as Uint8Array",format:"byte",contentEncoding:"base64"}),qs=gc(globalThis.Uint8Array,{representation:{id:"effect/schema/Uint8Array",payload:null},toCode:()=>({runtime:"Schema.Uint8Array",Type:"globalThis.Uint8Array"}),expected:"Uint8Array",toCodecJson:()=>Ne()(ej,dv)}),cee=ej.pipe(ee(qs,dv)),uee=z.annotate({expected:"a base64 (URL) encoded string that will be decoded as a Uint8Array"}).pipe(ee(qs,{decode:P1(),encode:zy()})),tj=z.annotate({expected:"a hex encoded string that will be decoded as a Uint8Array"}).pipe(ee(qs,{decode:F1(),encode:Wy()})),rj=Xt({decode:(e,t)=>{let r=tD(e);return fe(r)?D(new le({expected:"a valid BigDecimal string"},e,t)):I(r.value)},encode:e=>I(fa(e))}),fee=eh({order:wl,formatter:e=>fa(e)}),lee=th({order:wl,formatter:e=>fa(e)}),dee=rh({order:wl,formatter:e=>fa(e)}),pee=nh({order:wl,formatter:e=>fa(e)}),mee=oh({order:wl,formatter:e=>fa(e)}),nj=z.annotate({expected:"a string that will be decoded as a BigDecimal"}),oj=Ge(Tu,{representation:{id:"effect/schema/BigDecimal",payload:null},toCode:()=>({runtime:"Schema.BigDecimal",Type:"BigDecimal.BigDecimal",importDeclarations:['import * as BigDecimal from "effect/BigDecimal"']}),expected:"BigDecimal",toCodecJson:()=>Ne()(nj,rj),toFormatter:()=>e=>fa(e)}),hee=nj.pipe(ee(oj,rj)),JS=Ge(fD,{representation:{id:"effect/schema/ByteSize",payload:null},toCode:()=>({runtime:"Schema.ByteSize",Type:"ByteSize.ByteSize",importDeclarations:['import * as ByteSize from "effect/ByteSize"']}),expected:"ByteSize",toCodecJson:()=>Ne()(dd.check(B$(globalThis.BigInt(0))),Fe({decode:uD,encode:gy})),toCodecStringTree:()=>Ne()(sj,fv)}),sj=z.annotate({expected:"a string that will be decoded as a ByteSize"}),xee=sj.pipe(ee(JS,fv)),gee=dd.pipe(ee(JS,K1)),yee=Zu.pipe(ee(JS,V1));function XC(e,t){let r=Cr()([e,t],([n,o])=>(s,i,a)=>{if(!al(s))return D(new at(i,s,a));switch(s._tag){case"Fail":return cr(ot(n)(s.error,a),{onSuccess:Cp,onFailure:c=>tn(i,"error",c,s,a)});case"Die":return cr(ot(o)(s.defect,a),{onSuccess:Ap,onFailure:c=>tn(i,"defect",c,s,a)});case"Interrupt":return I(s)}},{representation:{id:"effect/schema/CauseReason",payload:null},toCode:({typeParameters:n})=>({runtime:`Schema.CauseReason(${n[0].runtime}, ${n[1].runtime})`,Type:`Cause.Failure<${n[0].Type}, ${n[1].Type}>`,importDeclarations:['import * as Cause from "effect/Cause"']}),expected:"Cause.Failure",toCodec:([n,o])=>Ne()(Pe([Te({_tag:fr("Fail"),error:n}),Te({_tag:fr("Die"),defect:o}),Te({_tag:fr("Interrupt"),fiberId:zS(KS)})]),Fe({decode:s=>{switch(s._tag){case"Fail":return Cp(s.error);case"Die":return Ap(s.defect);case"Interrupt":return kp(s.fiberId)}},encode:s=>{switch(s._tag){case"Fail":return{_tag:"Fail",error:s.error};case"Die":return{_tag:"Die",defect:s.defect};case"Interrupt":return{_tag:"Interrupt",fiberId:s.fiberId}}}}))});return J(r.ast,{error:e,defect:t})}function Jm(e,t){let r=Cr()([e,t],([n,o])=>{let s=ct(XC(n,o));return(i,a,c)=>il(i)?cr(ot(s)(i.reasons,c),{onSuccess:uu,onFailure:u=>tn(a,"failures",u,i,c)}):D(new at(a,i,c))},{representation:{id:"effect/schema/Cause",payload:null},toCode:({typeParameters:n})=>({runtime:`Schema.Cause(${n[0].runtime}, ${n[1].runtime})`,Type:`Cause.Cause<${n[0].Type}, ${n[1].Type}>`,importDeclarations:['import * as Cause from "effect/Cause"']}),expected:"Cause",toCodec:([n,o])=>Ne()(ct(XC(n,o)),Fe({decode:uu,encode:({reasons:s})=>s}))});return J(r.ast,{error:e,defect:t})}function r$(e){return Ne()(e,Fe({decode:gw,encode:Ct}))}function See(e){let t=Cr()([e],([r])=>{let n=ct(r);return(o,s,i)=>Cl(o)?cr(ot(n)(Ct(o),i),{onSuccess:gw,onFailure:a=>tn(s,"values",a,o,i)}):D(new at(s,o,i))},{representation:{id:"effect/schema/Chunk",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.Chunk(${r[0].runtime})`,Type:`Chunk.Chunk<${r[0].Type}>`}),expected:"Chunk",toCodec:([r])=>r$(ct(r)),toCodecArbitrary:({constraint:r,typeParameters:[n]})=>r$(qS(ct(n),r?.minLength,r?.maxLength)),toEquivalence:([r])=>hw(r)});return J(t.ast,{value:e})}function ij(){return rn((e,t)=>Zt(yw(e),{onNone:()=>D(new le({message:"Invalid DateTime input"},e,t)),onSome:r=>I(Sw(r))}))}var bee=Fe({decode:e=>Ew(e),encode:e=>e.offset}),aj=Xt({decode:(e,t)=>Zt(TD(e),{onNone:()=>D(new le({expected:"a valid IANA time zone"},e,t)),onSome:I}),encode:e=>I(e.id)}),cj=Xt({decode:(e,t)=>Zt(wD(e),{onNone:()=>D(new le({expected:"a valid time zone"},e,t)),onSome:I}),encode:e=>I(tm(e))}),uj=Xt({decode:(e,t)=>Zt(yw(e),{onNone:()=>D(new le({expected:"a valid UTC DateTime string"},e,t)),onSome:r=>I(Sw(r))}),encode:e=>I(AD(e))}),fj=Xt({decode:(e,t)=>Zt(ID(e),{onNone:()=>D(new le({expected:"a valid Zoned DateTime string"},e,t)),onSome:I}),encode:e=>I(Iw(e))}),lj=-864e13,dj=864e13,Eee=lj+840*60*1e3,Iee=dj-840*60*1e3,Tee=-720*60*1e3,wee=840*60*1e3,pj=["UTC","Europe/London","America/New_York","Asia/Tokyo","Australia/Sydney"];function mj(e,t,r){let n=Math.max(t,e?.minimum===void 0?t:e.minimum.epochMilliseconds+(e.exclusiveMinimum===!0?1:0)),o=Math.min(r,e?.maximum===void 0?r:e.maximum.epochMilliseconds-(e.exclusiveMaximum===!0?1:0));return n<=o?[n,o]:[t,r]}function hA(e,t){return In.check(yc({minimum:e,maximum:t}))}function hj(){return Pe([hA(Tee,wee),Fo(pj)])}var ZS=Ge(e=>vu(e)&&SD(e),{representation:{id:"effect/schema/DateTimeUtc",payload:null},toCode:()=>({runtime:"Schema.DateTimeUtc",Type:"DateTime.Utc",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.Utc",toCodecArbitrary:({constraint:e})=>{let[t,r]=mj(e,lj,dj);return md()(hA(t,r),Ie(by))},toCodecJson:()=>Ne()(z,uj),toFormatter:()=>e=>e.toString()}),vee=GS.pipe(ee(ZS,{decode:ij(),encode:Ie(vD)})),Cee=z.annotate({expected:"a string that will be decoded as a DateTime.Utc"}).pipe(ee(ZS,uj)),Aee=In.pipe(ee(ZS,{decode:ij(),encode:Ie(CD)})),kee=Ge(gD,{representation:{id:"effect/schema/TimeZoneOffset",payload:null},toCode:()=>({runtime:"Schema.TimeZoneOffset",Type:"DateTime.TimeZone.Offset",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.TimeZone.Offset",toCodecJson:()=>Ne()(In,bee),toFormatter:()=>e=>tm(e)}),xj=z.annotate({expected:"an IANA time zone identifier"}),gj=Ge(yD,{representation:{id:"effect/schema/TimeZoneNamed",payload:null},toCode:()=>({runtime:"Schema.TimeZoneNamed",Type:"DateTime.TimeZone.Named",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.TimeZone.Named",toCodecArbitrary:()=>md()(Fo(pj),Ie(bw)),toCodecJson:()=>Ne()(xj,aj),toFormatter:()=>e=>tm(e)}),Ree=xj.pipe(ee(gj,aj)),yj=z.annotate({expected:"a time zone string (IANA identifier or offset like +03:00)"}),Sj=Ge(xD,{representation:{id:"effect/schema/TimeZone",payload:null},toCode:()=>({runtime:"Schema.TimeZone",Type:"DateTime.TimeZone",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.TimeZone",toCodecArbitrary:()=>md()(hj(),Ie(e=>typeof e=="number"?Ew(e):bw(e))),toCodecJson:()=>Ne()(yj,cj),toFormatter:()=>e=>tm(e)}),Oee=yj.pipe(ee(Sj,cj)),bj=z.annotate({expected:"a zoned DateTime string (e.g. 2024-01-01T00:00:00.000+00:00[Europe/London])"}),Ej=Ge(e=>vu(e)&&bD(e),{representation:{id:"effect/schema/DateTimeZoned",payload:null},toCode:()=>({runtime:"Schema.DateTimeZoned",Type:"DateTime.Zoned",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.Zoned",toCodecArbitrary:({constraint:e})=>{let[t,r]=mj(e,Eee,Iee);return md()(Te({epochMilliseconds:hA(t,r),timeZone:hj()}),Ie(({epochMilliseconds:n,timeZone:o})=>Ey(n,{timeZone:o})))},toCodecJson:()=>Ne()(bj,fj),toFormatter:()=>e=>Iw(e),toEquivalence:()=>ED}),_ee=bj.pipe(ee(Ej,fj)),so=(e,t,r,n)=>z.pipe(ee(e,Xt({decode:(o,s)=>{let i=t(o);return tt(i)?I(i.success):D(new le({message:i.failure.message},o,s))},encode:o=>I(r(o))}))).annotate({identifier:n}),ef=Ge(nd,{identifier:"MacAddress"}),hd=so(ef,kB,kC,"MacAddressFromString"),sh=Ge(Br,{identifier:"Ipv4Address"}),xA=so(sh,Wu,$r,"Ipv4AddressFromString"),QS=Ge(ts,{identifier:"Ipv6Address"}),Ij=so(QS,Ku,$r,"Ipv6AddressFromString"),Sc=Ge(wC,{identifier:"IpAddress"}),tf=so(Sc,pc,$r,"IpAddressFromString"),kt=(e,t,r,n)=>v$(t,{expected:r})(e).annotate({identifier:n}),Pee=kt(Sc,od,"a multicast address","IpMulticastAddress"),Mee=kt(tf,od,"a multicast address","IpMulticastAddressFromString"),Fee=kt(ef,od,"a multicast address","MacMulticastAddress"),Nee=kt(hd,od,"a multicast address","MacMulticastAddressFromString"),Uee=kt(Sc,PC,"a unicast address","IpUnicastAddress"),Dee=kt(tf,PC,"a unicast address","IpUnicastAddressFromString"),Lee=kt(ef,_S,"a unicast address","MacUnicastAddress"),Bee=kt(hd,_S,"a unicast address","MacUnicastAddressFromString"),$ee=kt(sh,MS,"a broadcast address","Ipv4BroadcastAddress"),jee=kt(xA,MS,"a broadcast address","Ipv4BroadcastAddressFromString"),Hee=kt(ef,OS,"a broadcast address","MacBroadcastAddress"),qee=kt(hd,OS,"a broadcast address","MacBroadcastAddressFromString"),zee=kt(Sc,_C,"a loopback address","IpLoopbackAddress"),Wee=kt(tf,_C,"a loopback address","IpLoopbackAddressFromString"),Kee=kt(Sc,MC,"a link-local address","IpLinkLocalAddress"),Vee=kt(tf,MC,"a link-local address","IpLinkLocalAddressFromString"),Gee=kt(Sc,PS,"an unspecified address","IpUnspecifiedAddress"),Jee=kt(tf,PS,"an unspecified address","IpUnspecifiedAddressFromString"),Zee=kt(sh,FC,"a private address","Ipv4PrivateAddress"),Qee=kt(xA,FC,"a private address","Ipv4PrivateAddressFromString"),Yee=kt(QS,NC,"a unique-local address","Ipv6UniqueLocalAddress"),Xee=kt(Ij,NC,"a unique-local address","Ipv6UniqueLocalAddressFromString"),ete=kt(ef,RC,"a locally administered address","MacLocallyAdministeredAddress"),tte=kt(hd,RC,"a locally administered address","MacLocallyAdministeredAddressFromString"),rte=kt(ef,OC,"a universally administered address","MacUniversallyAdministeredAddress"),nte=kt(hd,OC,"a universally administered address","MacUniversallyAdministeredAddressFromString"),Tj=Ge($B,{identifier:"Ipv4Interface"}),ote=so(Tj,DS,zm,"Ipv4InterfaceFromString"),wj=Ge(jB,{identifier:"Ipv6Interface"}),ste=so(wj,LS,zm,"Ipv6InterfaceFromString"),vj=Ge(Hm,{identifier:"IpInterface"}),ite=so(vj,BS,zm,"IpInterfaceFromString"),Cj=Ge(qB,{identifier:"Ipv4Network"}),ate=so(Cj,WB,Km,"Ipv4NetworkFromString"),Aj=Ge(zB,{identifier:"Ipv6Network"}),cte=so(Aj,KB,Km,"Ipv6NetworkFromString"),kj=Ge(Wm,{identifier:"IpNetwork"}),ute=so(kj,VB,Km,"IpNetworkFromString"),fte=Ge(Dm,{identifier:"InetAddressV4"}),lte=Ge(Lm,{identifier:"InetAddressV6"}),Rj=Ge(vC,{identifier:"InetAddress"}),dte=so(Rj,UC,FS,"InetAddressFromString"),Oj=Ge(kS,{identifier:"UnixPathAddress"}),pte=z.pipe(ee(Oj,Fe({decode:OB,encode:e=>e.path}))).annotate({identifier:"UnixPathAddressFromString"}),mte=Ge(CB,{identifier:"SocketAddress"}),Sa=z.check(Je(ga,{expected:"a normalized domain name"})).pipe(WS("~effect/net/Host/DomainName")).annotate({identifier:"DomainName"}),_j=so(Sa,NS,e=>e,"DomainNameFromString"),gA=z.check(Je(CC,{expected:"a canonical scoped IPv6 literal"})).pipe(WS("~effect/net/NetAddress/ScopedIpv6Literal")).annotate({identifier:"ScopedIpv6Literal"}),Pj=so(gA,Bm,e=>e,"ScopedIpv6LiteralFromString"),hte=Pe([Sc,gA,Sa]).annotate({identifier:"Host"}),xte=Pe([tf,Pj,_j]).annotate({identifier:"HostFromString"}),Mj=Ge(BC,{identifier:"HostPort"}),gte=so(Mj,PB,$C,"HostPortFromString"),yte=In.check(yc({minimum:0,maximum:65535},{expected:"a port number"})),Ste=Xt({decode:(e,t)=>Zt(uP(e),{onNone:()=>D(new le({expected:"a valid Duration string"},e,t)),onSome:I}),encode:e=>I(globalThis.String(e))}),bte=Xt({decode:e=>I($o(e)),encode:(e,t)=>Zt(fP(e),{onNone:()=>D(new le({expected:"a Duration representable as a bigint"},e,t)),onSome:r=>I(r)})}),Ete=Fe({decode:e=>Zi(e),encode:e=>Wt(e)}),ih=Ge(Qi,{representation:{id:"effect/schema/Duration",payload:null},toCode:()=>({runtime:"Schema.Duration",Type:"Duration.Duration",importDeclarations:['import * as Duration from "effect/Duration"']}),expected:"Duration",toCodecJson:()=>Ne()(Pe([Te({_tag:fr("Infinity")}),Te({_tag:fr("NegativeInfinity")}),Te({_tag:fr("Nanos"),value:dd}),Te({_tag:fr("Millis"),value:In})]),Fe({decode:e=>{switch(e._tag){case"Infinity":return Ss;case"NegativeInfinity":return Da;case"Nanos":return $o(e.value);case"Millis":return Zi(e.value)}},encode:e=>{switch(e.value._tag){case"Infinity":return{_tag:"Infinity"};case"NegativeInfinity":return{_tag:"NegativeInfinity"};case"Nanos":return{_tag:"Nanos",value:e.value.nanos};case"Millis":return{_tag:"Millis",value:e.value.millis}}}}))}),Ite=z.annotate({expected:"a string that will be decoded as a Duration"}),Tte=Ite.pipe(ee(ih,Ste)),wte=dd.pipe(ee(ih,bte)),vte=Zu.pipe(ee(ih,Ete)),Cte=Fo(qC),Fj=(e,t)=>z.pipe(ee(e,Xt({decode:(r,n)=>{let o=t(r);return be(o)?D(new le({message:o.failure.message},r,n)):$r(o.success)===r?I(o.success):D(new le({message:"expected a canonical address"},r,n))},encode:r=>I($r(r))}))),ZC=In.check(yc({minimum:0,maximum:255})),id=In.check(yc({minimum:0,maximum:65535})),Nj=In.check(yc({minimum:0,maximum:4294967295})),$S=Nj.pipe(ee(ih,Fe({decode:fp,encode:ui}))),ns=(e,t)=>Ge(r=>zC(r)&&r._tag===e,{identifier:`Dns${e.charAt(0)}${e.slice(1).toLowerCase()}Record`,toCodecJson:()=>{let r=ya(e,t);return Ne()(r,Xt({decode:(n,o)=>{let{_tag:s,...i}=n,a=DB(e,i);return tt(a)?I(a.success):D(new le({message:a.failure.message},n,o))},encode:n=>I({...n})}))}}),Uj=ns("A",{address:Fj(sh,Wu)}),Dj=ns("AAAA",{address:Fj(QS,Ku)}),Lj=ns("CAA",{critical:Fi,tag:z.check(Xu(/^[a-z0-9]+$/i)),value:z}),Bj=ns("CNAME",{target:Sa}),$j=ns("MX",{exchange:Sa,priority:id}),jj=ns("NAPTR",{order:id,preference:id,flags:z,service:z,regexp:z,replacement:Sa}),Hj=ns("NS",{host:Sa}),qj=ns("PTR",{host:pA}),zj=ns("SOA",{primary:Sa,admin:pA,serial:Nj,refresh:$S,retry:$S,expire:$S,minimum:$S}),Wj=ns("SRV",{target:Sa,port:id,priority:id,weight:id}),Kj=ns("TLSA",{certUsage:ZC,selector:ZC,matchingType:ZC,data:tj}),Vj=ns("TXT",{chunks:Yu(z)}),Ate=Pe([Uj,Dj,Lj,Bj,$j,jj,Hj,qj,zj,Wj,Kj,Vj]).annotate({identifier:"DnsRecord"});function yA(e,t,r){let n=Cr()([e,t,r],([o,s,i])=>{let a=Jm(s,i);return(c,u,f)=>{if(!ws(c))return D(new at(u,c,f));switch(c._tag){case"Success":return cr(ot(o)(c.value,f),{onSuccess:Mr,onFailure:p=>tn(u,"value",p,c,f)});case"Failure":return cr(ot(a)(c.cause,f),{onSuccess:ir,onFailure:p=>tn(u,"cause",p,c,f)})}}},{representation:{id:"effect/schema/Exit",payload:null},toCode:({typeParameters:o})=>({runtime:`Schema.Exit(${o[0].runtime}, ${o[1].runtime}, ${o[2].runtime})`,Type:`Exit.Exit<${o[0].Type}, ${o[1].Type}, ${o[2].Type}>`,importDeclarations:['import * as Exit from "effect/Exit"']}),expected:"Exit",toCodec:([o,s,i])=>Ne()(Pe([Te({_tag:fr("Success"),value:o}),Te({_tag:fr("Failure"),cause:Jm(s,i)})]),Fe({decode:a=>a._tag==="Success"?Mr(a.value):ir(a.cause),encode:a=>ft(a)?{_tag:"Success",value:a.value}:{_tag:"Failure",cause:a.cause}}))});return J(n.ast,{value:e,error:t,defect:r})}function n$(e,t,r){return Te({type:fr(e),nodes:ct(Te({index:Vu,data:t})),edges:ct(Te({index:Vu,source:Vu,target:Vu,data:r}))})}function o$(e,t){let r=-1,n=new Set;for(let o=0;o<e.nodes.length;o++){let s=e.nodes[o].index;if(s<=r)return D(new At(["nodes",o,"index"],new le({expected:"a strictly increasing node index"},s,t)));r=s,n.add(s)}r=-1;for(let o=0;o<e.edges.length;o++){let s=e.edges[o];if(s.index<=r)return D(new At(["edges",o,"index"],new le({expected:"a strictly increasing edge index"},s.index,t)));if(r=s.index,!n.has(s.source))return D(new At(["edges",o,"source"],new le({expected:"an encoded node index"},s.source,t)));if(!n.has(s.target))return D(new At(["edges",o,"target"],new le({expected:"an encoded node index"},s.target,t)))}return I(Dy(e))}function kte(e,t,r){return!Zw(e)||e.mutable||e.type!==t?D(new le({expected:`an immutable ${t} Graph`},e,r)):I(lm(e))}function Rte(e,t){return(r,n)=>{let o=lm(r),s=lm(n);if(o.type!==s.type||o.nodes.length!==s.nodes.length||o.edges.length!==s.edges.length)return!1;for(let i=0;i<o.nodes.length;i++)if(o.nodes[i].index!==s.nodes[i].index||!e(o.nodes[i].data,s.nodes[i].data))return!1;for(let i=0;i<o.edges.length;i++){let a=o.edges[i],c=s.edges[i],u=o.type==="directed"?a.source===c.source&&a.target===c.target:a.source===c.source&&a.target===c.target||a.source===c.target&&a.target===c.source;if(a.index!==c.index||!u||!t(a.data,c.data))return!1}return!0}}function Ote(e,t,r){return md()(Pe([HS,Te({nodes:Yu(t),edges:ct(rs([Vu,Vu,r]))})]),Ie(n=>{if(n===null)return Dy({type:e,nodes:[],edges:[]});let o=n.nodes.map((s,i)=>({index:i,data:s}));return Dy({type:e,nodes:o,edges:n.edges.map(([s,i,a],c)=>({index:c,source:s%o.length,target:i%o.length,data:a}))})}))}function _te(e,t,r){let n=Cr()([t,r],([o,s])=>{let i=n$(e,o,s);return(a,c,u)=>!Zw(a)||a.mutable||a.type!==e?D(new at(c,a,u)):A(ot(i)(lm(a),u),f=>o$(f,u))},{representation:{id:"effect/schema/Graph",payload:e},toCode:({typeParameters:o})=>({runtime:`Schema.Graph(${H(e)}, ${o[0].runtime}, ${o[1].runtime})`,Type:`Graph.Graph<${o[0].Type}, ${o[1].Type}, ${H(e)}>`,importDeclarations:['import * as Graph from "effect/Graph"']}),expected:`an immutable ${e} Graph`,toCodec:([o,s])=>Ne()(n$(e,o,s),Xt({decode:o$,encode:(i,a)=>kte(i,e,a)})),toCodecArbitrary:({typeParameters:[o,s]})=>Ote(e,o,s),toEquivalence:([o,s])=>Rte(o,s)});return J(n.ast,{type:e,node:t,edge:r})}function s$(e){return Ne()(e,Fe({decode:Mw,encode:im}))}function Pte(e,t){let r=Cr()([e,t],([n,o])=>{let s=ct(rs([n,o]));return(i,a,c)=>Ay(i)?cr(ot(s)(im(i),c),{onSuccess:Mw,onFailure:u=>tn(a,"entries",u,i,c)}):D(new at(a,i,c))},{representation:{id:"effect/schema/HashMap",payload:null},toCode:({typeParameters:n})=>({runtime:`Schema.HashMap(${n[0].runtime}, ${n[1].runtime})`,Type:`HashMap.HashMap<${n[0].Type}, ${n[1].Type}>`,importDeclarations:['import * as HashMap from "effect/HashMap"']}),expected:"HashMap",toCodec:([n,o])=>s$(ct(rs([n,o]))),toCodecArbitrary:({constraint:n,typeParameters:[o,s]})=>s$(qS(ct(rs([o,s])).check(z$()),n?.minSize,n?.maxSize)),toEquivalence:([n,o])=>yx(n,o)});return J(r.ast,{key:e,value:t})}function i$(e){return Ne()(e,Fe({decode:Nw,encode:Ct}))}function Mte(e){let t=Cr()([e],([r])=>{let n=ct(r);return(o,s,i)=>_y(o)?cr(ot(n)(Ct(o),i),{onSuccess:Nw,onFailure:a=>tn(s,"values",a,o,i)}):D(new at(s,o,i))},{representation:{id:"effect/schema/HashSet",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.HashSet(${r[0].runtime})`,Type:`HashSet.HashSet<${r[0].Type}>`}),expected:"HashSet",toCodec:([r])=>i$(ct(r)),toCodecArbitrary:({constraint:r,typeParameters:[n]})=>i$(qS(ct(n).check(dA()),r?.minSize,r?.maxSize)),toEquivalence:([r])=>zd(r)});return J(t.ast,{value:e})}function ba(e){let t=Cr()([e],([r])=>(n,o,s)=>ci(n)?fe(n)?ia:cr(ot(r)(n.value,s),{onSuccess:N,onFailure:i=>tn(o,"value",i,n,s)}):D(new at(o,n,s)),{representation:{id:"effect/schema/Option",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.Option(${r[0].runtime})`,Type:`Option.Option<${r[0].Type}>`,importDeclarations:['import * as Option from "effect/Option"']}),expected:"Option",toCodec:([r])=>Ne()(Pe([Te({_tag:fr("Some"),value:r}),Te({_tag:fr("None")})]),Fe({decode:n=>n._tag==="None"?_():N(n.value),encode:n=>de(n)?{_tag:"Some",value:n.value}:{_tag:"None"}}))});return J(t.ast,{value:e})}function Fte(e){return iA(e).pipe(ee(ba(oo(e)),X1()))}function Nte(e){return zS(e).pipe(ee(ba(oo(e)),e2()))}function Ute(e,t){return T$(e).pipe(ee(ba(oo(e)),t2(t)))}var Gj=Ge(WD,{representation:{id:"effect/http/Cookie",payload:null},toCode:()=>({runtime:"Schema.Cookie",Type:"Cookies.Cookie",importDeclarations:['import * as Cookies from "effect/http/Cookies"']}),expected:"Cookie"}),Jj=Ge(zD,{representation:{id:"effect/http/Cookies",payload:null},toCode:()=>({runtime:"Schema.Cookies",Type:"Cookies.Cookies",importDeclarations:['import * as Cookies from "effect/http/Cookies"']}),expected:"Cookies",toCodecJson:()=>Ne()(ct(z),Fe({decode:My,encode:ZD})),toCodecIso:()=>Ne()(Qu(z,Gj),Fe({decode:$w,encode:e=>e.cookies}))}),Dte=Jj.pipe(ee(Qu(z,z),Fe({decode:JD,encode:e=>jw(globalThis.Object.entries(e).map(([t,r])=>GD(t,r)))}))),Lte=Ge(e1,{representation:{id:"effect/http/Headers",payload:null},toCode:()=>({runtime:"Schema.Headers",Type:"Headers.Headers",importDeclarations:['import * as Headers from "effect/http/Headers"']}),expected:"Headers",toEquivalence:()=>zw,toCodec:()=>Ne()(Qu(z,z),Fe({decode:Zo,encode:e=>({...e})}))}),SA=Ge(Vw,{representation:{id:"effect/http/UrlParams",payload:null},toCode:()=>({runtime:"Schema.UrlParams",Type:"UrlParams.UrlParams",importDeclarations:['import * as UrlParams from "effect/http/UrlParams"']}),expected:"UrlParams",toEquivalence:()=>Gw,toCodec:()=>Ne()(ct(rs([z,z])),Fe({decode:Ol,encode:e=>e.params}))}),Bte=(e,t)=>SA.pipe(ee(mA(Xm,t),Xt({decode:r=>Zt(i1(r,e),{onNone:()=>D(new At([e],new Yt(void 0))),onSome:I}),encode:r=>I(Ol([[e,r]]))}))),$te=SA.pipe(ee(Qu(z,Pe([z,Yu(z)])),Fe({decode:c1,encode:Mu})));function jte(e){return Gu(e).pipe(ee(ba(oo(e)),r2()))}function Hte(e){return lr(e).pipe(ee(ba(oo(e)),n2()))}function qte(e,t){let r=t===void 0?"omit":t.onNoneEncoding,n=r===null?null:void 0;return lr(iA(e)).pipe(ee(ba(oo(e)),Gy({decode:o=>o.pipe(Fa(hx),N),encode:r==="omit"?eu:o=>N(Ma(eu(o),()=>n))})))}function Zj(e,t){let r=typeof t?.label=="string"?t.label:void 0,n=t?.disallowJsonEncode===!0,o=r!==void 0?n?{label:r,disallowJsonEncode:!0}:{label:r}:n?{disallowJsonEncode:!0}:void 0,s=r!==void 0?ot(fr(r)):void 0,i=Cr()([e],([a])=>(c,u,f)=>{if(cm(c)){let p=s!==void 0?Iu(s(c.label,f),m=>new At(["label"],m)):P;return ur(p,()=>cr(ot(a)(nc(c),f),{onSuccess:m=>Pu(m,{label:c.label}),onFailure:()=>new Ft(u,[new At(["value"],new le(void 0,c,f))],c,f)}))}return D(new at(u,c,f))},{representation:{id:"effect/schema/Redacted",payload:o??null},toCode:({typeParameters:a})=>({runtime:o!==void 0?`Schema.Redacted(${a[0].runtime}, ${H(o)})`:`Schema.Redacted(${a[0].runtime})`,Type:`Redacted.Redacted<${a[0].Type}>`,importDeclarations:['import * as Redacted from "effect/Redacted"']}),expected:"Redacted",toCodecJson:([a])=>Ne()(a,{decode:Ie(c=>Pu(c,{label:r})),encode:n?jy(c=>"Cannot serialize Redacted"+(de(c)&&typeof c.value.label=="string"?` with label: "${c.value.label}"`:"")):Ie(nc)}),toEquivalence:([a])=>XD(a)});return J(i.ast,{value:e})}function zte(e,t){return ee(Zj(oo(e),{label:t?.label,disallowJsonEncode:t?.disallowEncode}),{decode:Ie(r=>Pu(r,{label:t?.label})),encode:t?.disallowEncode?jy(r=>"Cannot encode Redacted"+(de(r)&&typeof r.value.label=="string"?` with label: "${r.value.label}"`:"")):Ie(nc)})(e)}function Wte(e,t){let r=Cr()([e,t],([n,o])=>(s,i,a)=>{if(!$f(s))return D(new at(i,s,a));switch(s._tag){case"Success":return cr(Qv(n)(s.success,a),{onSuccess:X,onFailure:c=>tn(i,"success",c,s,a)});case"Failure":return cr(Qv(o)(s.failure,a),{onSuccess:re,onFailure:c=>tn(i,"failure",c,s,a)})}},{representation:{id:"effect/schema/Result",payload:null},toCode:({typeParameters:n})=>({runtime:`Schema.Result(${n[0].runtime}, ${n[1].runtime})`,Type:`Result.Result<${n[0].Type}, ${n[1].Type}>`,importDeclarations:['import * as Result from "effect/Result"']}),expected:"Result",toCodec:([n,o])=>Ne()(Pe([Te({_tag:fr("Success"),success:n}),Te({_tag:fr("Failure"),failure:o})]),Fe({decode:s=>s._tag==="Success"?X(s.success):re(s.failure),encode:s=>tt(s)?{_tag:"Success",success:s.success}:{_tag:"Failure",failure:s.failure}}))});return J(r.ast,{success:e,failure:t})}var Kte=globalThis.Symbol.for("immer-draftable"),eA={};function bA(e,t,r,n,o){let s=Gte(r,t,n),i=Qj(t),a=class extends e{constructor(...[c,u]){let p=u?.["~payload"],m=p?.token===eA?p.value:r.make(c??{},u);super(m,{...u,disableChecks:!0,"~payload":{token:eA,value:m}})}static[Vm]=Vm;get[i](){return i}static[Kte]=!0;static identifier=t;static fields=r.fields;static get ast(){return s(this).ast}static pipe(){return V(this,arguments)}static rebuild(c){return s(this).rebuild(c)}static make(c,u){return pS(s(this))(c??{},u)}static makeOption(c,u){return dS(s(this))(c??{},u)}static makeEffect(c,u){return s(this).makeEffect(c??{},u)}static annotate(c){return this.rebuild(Fs(this.ast,c))}static annotateKey(c){return this.rebuild(Wl(this.ast,c))}static check(...c){return this.rebuild(Pi(this.ast,c))}static extend(c){return(u,f)=>{let p=ah(u)?u:Te(u),m={...r.fields,...p.fields},h=eS(m,r.ast.checks,{identifier:c});return bA(this,c,sA(Pi(h,p.ast.checks),m),f,o)}}static mapFields(c,u){return r.mapFields(c,u)}};return o!==void 0&&Object.assign(a.prototype,o(t)),a}function Vte(e){return new et(Ie(t=>new e(t,{"~payload":{token:eA,value:t}})),Oi())}function Qj(e){return`~effect/Schema/Class/${e}`}function Gte(e,t,r){let n;return o=>{if(n!==void 0)return n;let s=Qj(t),i=u=>u instanceof o||O(u,s),a=Vte(o),c=J(new uc([e.ast],()=>(u,f,p)=>i(u)?I(u):D(new at(f,u,p)),{identifier:t,[By]:([u])=>({isConstructed:i,link:new jt(u,a)}),toCodec:([u])=>new jt(u.ast,a),toEquivalence:([u])=>u,toFormatter:([u])=>f=>`${o.identifier}(${u(f)})`,[dm]:ac(e.ast),...r}));return n=ee(c,a)(e)}}function ah(e){return Ju(e)}var YS=e=>(t,r)=>{let n=ah(t)?t:Te(t);return bA(yP,e,n,r,o=>({toString(){return`${o}(${H({...this})})`}}))},Jte=e=>(t,r,n)=>{let o=ah(r)?r.mapFields(s=>({_tag:He(t),...s}),{unsafePreserveChecks:!0}):ya(t,r);return YS(e??t)(o,n)},Ar=e=>(t,r)=>{let n=ah(t)?t:Te(t);return bA(Xd,e,n,r,s=>({name:s}))},EA=e=>(t,r,n)=>{let o=ah(r)?r.mapFields(s=>({_tag:He(t),...s}),{unsafePreserveChecks:!0}):ya(t,r);return Ar(e??t)(o,n)};function Zte(e){return t=>t.annotate({toFormatter:e})}function Qte(e,t){return hB(e.ast,t)}function Yte(e){return t=>t.annotate({toEquivalence:e})}function Xte(e){return mC(e.ast)}function ere(e,t){return Fm(e.ast,t)}function tre(e,t){let r=Fm(Zl(e.ast),t);return TS(r,t)}var rf=yS,rre=SS,nre=bS,ore=zL;function sre(e,t){return fB(e,t)}function ire(e){return IB(e)}function are(e){return TB(e)}function cre(e){return wB(e)}function ure(e,t){return r=>J(Fs(r.ast,{toCodecIso:()=>new jt(e.ast,Vy(t))}),{schema:r})}function fre(e){return uB(e)}function lre(e){let t=w$(()=>r),r=Pe([e,ct(t),Qu(z,t)]);return r}var XS=J(Fs($l,{toCode:()=>({runtime:"Schema.Json",Type:"Schema.Json"})})),dre=Qu(z,XS),pre=Te({message:z,name:Gu(z),stack:Gu(z),cause:Gu(XS)}),mre=J(Fs(iL,{toCode:()=>({runtime:"Schema.MutableJson",Type:"Schema.MutableJson"})}));function hre(e){return da(e.ast)}function xre(e){return e.ast.context?.annotations}var Yj=bT;var bc=Xx,eb=VP,Tn=xp;var os=ea,Ni=$F;var jr=n0,Xj=VF;var eH="~effect/MutableRef",gre={[eH]:eH,...wr,toJSON(){return{_id:"MutableRef",current:pr(this.current)}}},xd=e=>{let t=Object.create(gre);return t.current=e,t};var tH=e=>e.current;var tb=d(2,(e,t)=>(e.current=t,e));var Hr=Symbol.for("effect/MutableList/Empty"),Ta=()=>({head:void 0,tail:void 0,length:0}),TA=e=>{let t=e.head;t.offset>=1024&&t===e.tail&&t.mutable&&(t.array.length-t.offset)*8<=t.offset&&(e.head=e.tail={array:t.array.slice(t.offset),mutable:!0,offset:0,next:void 0})},rH=()=>({array:[],mutable:!0,offset:0,next:void 0}),zs=(e,t)=>{e.tail?e.tail.mutable||(e.tail.next=rH(),e.tail=e.tail.next):e.head=e.tail=rH(),e.tail.array.push(t),e.length++},wA=(e,t)=>{e.head={array:[t],mutable:!0,offset:0,next:e.head},e.tail||(e.tail=e.head),e.length++};var rb=(e,t)=>nb(e,Ct(t),!Array.isArray(t)),nb=(e,t,r=!1)=>{if(t.length===0)return 0;let n={array:t,mutable:r,offset:0,next:void 0};return e.head?e.tail=e.tail.next=n:e.head=e.tail=n,e.length+=t.length,t.length},Ia=e=>{e.head=e.tail=void 0,e.length=0},nf=(e,t)=>{if(t=Bt(t),t<=0||!e.head)return[];if(t=Math.min(t,e.length),t===e.length&&e.head?.offset===0&&!e.head.next){let s=e.head.array;return Ia(e),s}let r=new Array(t),n=0,o=e.head;for(;o;){for(;o.offset<o.array.length;)if(r[n++]=o.array[o.offset],o.mutable&&(o.array[o.offset]=void 0),o.offset++,n===t)return e.head=o.offset===o.array.length&&o.next?o.next:o,e.length-=t,e.length===0?Ia(e):TA(e),r;o=o.next}return Ia(e),r},ob=(e,t)=>{if(t=Bt(t),t<=0||!e.head)return;if(t=Math.min(t,e.length),t===e.length&&e.head?.offset===0&&!e.head.next){Ia(e);return}let r=0,n=e.head;for(;n;){let o=n.array.length-n.offset;if(r+o>t){n.offset+=t-r,e.head=n,e.length-=t,TA(e);return}r+=o,n=n.next}Ia(e)},Ec=e=>nf(e,e.length),of=e=>{if(!e.head)return Hr;let t=e.head.array[e.head.offset];return e.head.mutable&&(e.head.array[e.head.offset]=void 0),e.head.offset++,e.length--,e.head.offset===e.head.array.length?e.head.next?e.head=e.head.next:Ia(e):TA(e),t},nH=(e,t)=>{if(t=Bt(t),t<=0)return[];let r=Math.min(t,e.length),n=new Array(r),o=0,s=e.head;for(;s;){for(let i=s.offset;i<s.array.length;i++)if(n[o++]=s.array[i],o===r)return n;s=s.next}return n};var vA=(e,t)=>{let r=[],n=e.head,o=0;for(;n;){for(let s=n.offset;s<n.array.length;s++)t(n.array[s],o++)&&r.push(n.array[s]);n=n.next}if(r.length===0){Ia(e);return}e.head=e.tail={array:r,mutable:!0,offset:0,next:void 0},e.length=r.length},oH=(e,t)=>vA(e,r=>r!==t);var yre="~effect/PubSub";var Sre="~effect/PubSub/Subscription",ub=e=>W(()=>vre(e.atomicPubSub(),new Map,Zn(),jr(!1),xd(!1),e.strategy(),xd(_()))),fb=e=>ub({atomicPubSub:()=>DA(e),strategy:()=>new ib}),lb=e=>ub({atomicPubSub:()=>DA(e),strategy:()=>new ab}),db=e=>ub({atomicPubSub:()=>DA(e),strategy:()=>new UA}),uh=e=>ub({atomicPubSub:()=>sH(e),strategy:()=>new ab}),DA=e=>{let t=typeof e=="number"?{capacity:e}:e;if(Cre(t.capacity),t.capacity===1/0)return sH(t);let r=t.replay&&t.replay>0?new cb(Math.ceil(t.replay)):void 0;return t.capacity===1?new OA(r):aU(t.capacity)===t.capacity?new kA(t.capacity,r):new CA(t.capacity,r)},sH=e=>{let t=e?.replay;return new PA(t&&t>0?new cb(Math.ceil(t)):void 0)};var fh=e=>Ci(ar(t=>(tb(e.shutdownFlag,!0),Ve(e.scope,Lg(t.id)).pipe(Vt(e.strategy.shutdown),fy(e.shutdownHook.open),vo)))),pb=d(2,(e,t)=>W(()=>bre(e,t))),bre=d(2,(e,t)=>{if(e.shutdownFlag.current||de(e.ended.current))return!1;if(tb(e.ended,N(t)),e.strategy instanceof ib)for(let[n,o,s]of Ec(e.strategy.publishers))s&&hi(o,Mr(!1));let r=Mr(t);for(let n of e.subscribers.values())for(let o of n){let s;for(;(s=of(o))!==Hr;)hi(s,r)}return e.subscribers.clear(),!0});var mb=d(2,(e,t)=>L(()=>e.shutdownFlag.current||de(e.ended.current)?I(!1):e.pubsub.publish(t)?(e.strategy.completeSubscribersUnsafe(e.pubsub,e.subscribers),I(!0)):e.strategy.handleSurplus(e.pubsub,e.subscribers,[t],e.shutdownFlag,e.ended))),iH=d(2,(e,t)=>e.shutdownFlag.current||de(e.ended.current)?!1:e.pubsub.publish(t)?(e.strategy.completeSubscribersUnsafe(e.pubsub,e.subscribers),!0):!1),aH=d(2,(e,t)=>L(()=>{if(e.shutdownFlag.current||de(e.ended.current))return I(!1);let r=e.pubsub.publishAll(t);return e.strategy.completeSubscribersUnsafe(e.pubsub,e.subscribers),r.length===0?I(!0):e.strategy.handleSurplus(e.pubsub,e.subscribers,r,e.shutdownFlag,e.ended)})),lh=e=>Ci(yn(t=>{let r=Re(t,it),n=yr(e.scope),o=wre(e.pubsub,e.subscribers,e.strategy,e.ended);return It(n,Ere(o)).pipe(Vt(Wo(r,s=>Ve(n,s))),Pt(o))})),Ere=e=>Ci(ar(t=>(tb(e.shutdownFlag,!0),Ko(Ec(e.pollers),r=>c0(r,t.id),{discard:!0,concurrency:"unbounded"}).pipe(_t(()=>W(()=>{e.subscribers.delete(e.subscription),e.subscription.unsubscribe(),e.replayWindow.close(),e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers)})),fy(e.shutdownHook.open),vo)))),hb=e=>L(()=>{if(e.shutdownFlag.current)return Dn;if(e.replayWindow.remaining>0){let r=e.replayWindow.take();return I(r)}let t=e.pollers.length===0?e.subscription.poll():Hr;return t===Hr?uH(e):(e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers),I(t))}),cH=e=>L(function t(r){if(e.shutdownFlag.current)return Dn;let n=e.pollers.length===0?e.subscription.pollUpTo(Number.POSITIVE_INFINITY):[];return r&&(n=r.concat(n)),e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers),e.replayWindow.remaining>0?I(e.replayWindow.takeAll().concat(n)):Gr(n)?I(n):A(uH(e),o=>t([o]))}),uH=e=>Nn(t=>{if(e.shutdownFlag.current)return t(Dn);if(de(e.ended.current)){let o=e.pollers.length===0?e.subscription.poll():Hr;return o!==Hr?(e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers),t(I(o))):t(I(e.ended.current.value))}let r=lu(),n=e.subscribers.get(e.subscription);return n||(n=new Set,e.subscribers.set(e.subscription,n)),n.add(e.pollers),zs(e.pollers,r),e.strategy.completePollersUnsafe(e.pubsub,e.subscribers,e.subscription,e.pollers),r.effect?t(r.effect):(r.resumes=[t],W(()=>oH(e.pollers,r)))});var tr=Symbol.for("effect/PubSub/AbsentValue"),Ire=(e,t,r)=>{e.has(t)||e.set(t,new Set),e.get(t).add(r)},Tre=(e,t,r)=>{if(!e.has(t))return;let n=e.get(t);n.delete(r),n.size===0&&e.delete(t)},wre=(e,t,r,n)=>new FA(e,t,e.subscribe(),Ta(),jr(!1),xd(!1),r,e.replayWindow(),n),CA=class{array;replayIndices;publisherIndex=0;subscribers;subscriberCount=0;subscribersIndex=0;capacity;replayBuffer;constructor(t,r){this.capacity=t,this.replayBuffer=r,this.array=Array.from({length:t}),this.replayIndices=r?Array.from({length:t}):[],this.subscribers=Array.from({length:t})}replayWindow(){return this.replayBuffer?new gd(this.replayBuffer):xb}isEmpty(){return this.publisherIndex===this.subscribersIndex}isFull(){return this.publisherIndex===this.subscribersIndex+this.capacity}size(){return this.publisherIndex-this.subscribersIndex}publish(t){if(this.isFull())return!1;let r=this.replayBuffer?.offer(t);if(this.subscriberCount!==0){let n=this.publisherIndex%this.capacity;this.array[n]=t,r!==void 0&&(this.replayIndices[n]=r),this.subscribers[n]=this.subscriberCount,this.publisherIndex+=1}return!0}publishAll(t){if(this.subscriberCount===0)return this.replayBuffer&&this.replayBuffer.offerAll(t),[];let r=Ct(t),n=r.length,o=this.publisherIndex-this.subscribersIndex,s=this.capacity-o,i=Math.min(n,s);if(i===0)return r;let a=0,c=this.publisherIndex+i;for(;this.publisherIndex!==c;){let u=r[a++],f=this.publisherIndex%this.capacity;this.array[f]=u;let p=this.replayBuffer?.offer(u);p!==void 0&&(this.replayIndices[f]=p),this.subscribers[f]=this.subscriberCount,this.publisherIndex+=1}return r.slice(a)}slide(){if(this.subscribersIndex!==this.publisherIndex){let t=this.subscribersIndex%this.capacity,r=this.array[t];this.array[t]=tr,this.subscribers[t]=0,this.subscribersIndex+=1,this.replayBuffer?.slide(r,this.replayIndices[t])}}subscribe(){return this.subscriberCount+=1,new AA(this,this.publisherIndex,!1)}},AA=class{self;subscriberIndex;unsubscribed;constructor(t,r,n){this.self=t,this.subscriberIndex=r,this.unsubscribed=n}isEmpty(){return this.unsubscribed||this.self.publisherIndex===this.subscriberIndex||this.self.publisherIndex===this.self.subscribersIndex}size(){return this.unsubscribed?0:this.self.publisherIndex-Math.max(this.subscriberIndex,this.self.subscribersIndex)}poll(){if(this.unsubscribed)return Hr;if(this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex),this.subscriberIndex!==this.self.publisherIndex){let t=this.subscriberIndex%this.self.capacity,r=this.self.array[t];return this.self.subscribers[t]-=1,this.self.subscribers[t]===0&&(this.self.array[t]=tr,this.self.subscribersIndex+=1),this.subscriberIndex+=1,r}return Hr}pollUpTo(t){if(t=Bt(t),this.unsubscribed)return[];this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex);let r=this.self.publisherIndex-this.subscriberIndex,n=Math.min(t,r);if(n<=0)return[];let o=[],s=this.subscriberIndex+n;for(;this.subscriberIndex!==s;){let i=this.subscriberIndex%this.self.capacity,a=this.self.array[i];this.self.subscribers[i]-=1,this.self.subscribers[i]===0&&(this.self.array[i]=tr,this.self.subscribersIndex+=1),o.push(a),this.subscriberIndex+=1}return o}unsubscribe(){if(!this.unsubscribed)for(this.unsubscribed=!0,this.self.subscriberCount-=1,this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex);this.subscriberIndex!==this.self.publisherIndex;){let t=this.subscriberIndex%this.self.capacity;this.self.subscribers[t]-=1,this.self.subscribers[t]===0&&(this.self.array[t]=tr,this.self.subscribersIndex+=1),this.subscriberIndex+=1}}},kA=class{array;replayIndices;mask;publisherIndex=0;subscribers;subscriberCount=0;subscribersIndex=0;capacity;replayBuffer;constructor(t,r){this.capacity=t,this.replayBuffer=r,this.array=Array.from({length:t}),this.replayIndices=r?Array.from({length:t}):[],this.mask=t-1,this.subscribers=Array.from({length:t})}replayWindow(){return this.replayBuffer?new gd(this.replayBuffer):xb}isEmpty(){return this.publisherIndex===this.subscribersIndex}isFull(){return this.publisherIndex===this.subscribersIndex+this.capacity}size(){return this.publisherIndex-this.subscribersIndex}publish(t){if(this.isFull())return!1;let r=this.replayBuffer?.offer(t);if(this.subscriberCount!==0){let n=this.publisherIndex&this.mask;this.array[n]=t,r!==void 0&&(this.replayIndices[n]=r),this.subscribers[n]=this.subscriberCount,this.publisherIndex+=1}return!0}publishAll(t){if(this.subscriberCount===0)return this.replayBuffer&&this.replayBuffer.offerAll(t),[];let r=Ct(t),n=r.length,o=this.publisherIndex-this.subscribersIndex,s=this.capacity-o,i=Math.min(n,s);if(i===0)return r;let a=0,c=this.publisherIndex+i;for(;this.publisherIndex!==c;){let u=r[a++],f=this.publisherIndex&this.mask;this.array[f]=u;let p=this.replayBuffer?.offer(u);p!==void 0&&(this.replayIndices[f]=p),this.subscribers[f]=this.subscriberCount,this.publisherIndex+=1}return r.slice(a)}slide(){if(this.subscribersIndex!==this.publisherIndex){let t=this.subscribersIndex&this.mask,r=this.array[t];this.array[t]=tr,this.subscribers[t]=0,this.subscribersIndex+=1,this.replayBuffer?.slide(r,this.replayIndices[t])}}subscribe(){return this.subscriberCount+=1,new RA(this,this.publisherIndex,!1)}},RA=class{self;subscriberIndex;unsubscribed;constructor(t,r,n){this.self=t,this.subscriberIndex=r,this.unsubscribed=n}isEmpty(){return this.unsubscribed||this.self.publisherIndex===this.subscriberIndex||this.self.publisherIndex===this.self.subscribersIndex}size(){return this.unsubscribed?0:this.self.publisherIndex-Math.max(this.subscriberIndex,this.self.subscribersIndex)}poll(){if(this.unsubscribed)return Hr;if(this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex),this.subscriberIndex!==this.self.publisherIndex){let t=this.subscriberIndex&this.self.mask,r=this.self.array[t];return this.self.subscribers[t]-=1,this.self.subscribers[t]===0&&(this.self.array[t]=tr,this.self.subscribersIndex+=1),this.subscriberIndex+=1,r}return Hr}pollUpTo(t){if(t=Bt(t),this.unsubscribed)return[];this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex);let r=this.self.publisherIndex-this.subscriberIndex,n=Math.min(t,r);if(n<=0)return[];let o=[],s=this.subscriberIndex+n;for(;this.subscriberIndex!==s;){let i=this.subscriberIndex&this.self.mask,a=this.self.array[i];this.self.subscribers[i]-=1,this.self.subscribers[i]===0&&(this.self.array[i]=tr,this.self.subscribersIndex+=1),o.push(a),this.subscriberIndex+=1}return o}unsubscribe(){if(!this.unsubscribed)for(this.unsubscribed=!0,this.self.subscriberCount-=1,this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex);this.subscriberIndex!==this.self.publisherIndex;){let t=this.subscriberIndex&this.self.mask;this.self.subscribers[t]-=1,this.self.subscribers[t]===0&&(this.self.array[t]=tr,this.self.subscribersIndex+=1),this.subscriberIndex+=1}}},OA=class{publisherIndex=0;subscriberCount=0;subscribers=0;value=tr;replayIndex=0;capacity=1;replayBuffer;constructor(t){this.replayBuffer=t}replayWindow(){return this.replayBuffer?new gd(this.replayBuffer):xb}pipe(){return V(this,arguments)}isEmpty(){return this.subscribers===0}isFull(){return!this.isEmpty()}size(){return this.isEmpty()?0:1}publish(t){if(this.isFull())return!1;let r=this.replayBuffer?.offer(t);return this.subscriberCount!==0&&(this.value=t,r!==void 0&&(this.replayIndex=r),this.subscribers=this.subscriberCount,this.publisherIndex+=1),!0}publishAll(t){if(this.subscriberCount===0)return this.replayBuffer&&this.replayBuffer.offerAll(t),[];let r=Ct(t);return r.length===0?r:this.publish(r[0])?r.slice(1):r}slide(){if(this.isFull()){let t=this.value;this.subscribers=0,this.value=tr,this.replayBuffer?.slide(t,this.replayIndex)}}subscribe(){return this.subscriberCount+=1,new _A(this,this.publisherIndex,!1)}},_A=class{self;subscriberIndex;unsubscribed;constructor(t,r,n){this.self=t,this.subscriberIndex=r,this.unsubscribed=n}isEmpty(){return this.unsubscribed||this.self.subscribers===0||this.subscriberIndex===this.self.publisherIndex}size(){return this.isEmpty()?0:1}poll(){if(this.isEmpty())return Hr;let t=this.self.value;return this.self.subscribers-=1,this.self.subscribers===0&&(this.self.value=tr),this.subscriberIndex=this.self.publisherIndex,t}pollUpTo(t){return Bt(t)<1||this.isEmpty()?[]:[this.poll()]}unsubscribe(){this.unsubscribed||(this.unsubscribed=!0,this.self.subscriberCount-=1,this.self.subscribers!==0&&this.subscriberIndex!==this.self.publisherIndex&&(this.self.subscribers-=1,this.self.subscribers===0&&(this.self.value=tr)))}},PA=class{publisherHead={value:tr,replayIndex:void 0,subscribers:0,next:null};publisherTail=this.publisherHead;publisherIndex=0;subscribersIndex=0;capacity=Number.MAX_SAFE_INTEGER;replayBuffer;constructor(t){this.replayBuffer=t}replayWindow(){return this.replayBuffer?new gd(this.replayBuffer):xb}isEmpty(){return this.publisherHead===this.publisherTail}isFull(){return!1}size(){return this.publisherIndex-this.subscribersIndex}publish(t){let r=this.replayBuffer?.offer(t),n=this.publisherTail.subscribers;if(n!==0){let o={value:t,replayIndex:r,subscribers:n,next:null};this.publisherTail.next=o,this.publisherTail=this.publisherTail.next,this.publisherIndex+=1}return!0}publishAll(t){if(this.publisherTail.subscribers!==0)for(let r of t)this.publish(r);else this.replayBuffer&&this.replayBuffer.offerAll(t);return[]}slide(){if(this.publisherHead!==this.publisherTail){let t=this.publisherHead.next,r=t.value;this.publisherHead=this.publisherHead.next,this.publisherHead.value=tr,this.subscribersIndex+=1,this.replayBuffer?.slide(r,t.replayIndex)}}subscribe(){return this.publisherTail.subscribers+=1,new MA(this,this.publisherTail,this.publisherIndex,!1)}},MA=class{self;subscriberHead;subscriberIndex;unsubscribed;constructor(t,r,n,o){this.self=t,this.subscriberHead=r,this.subscriberIndex=n,this.unsubscribed=o}isEmpty(){if(this.unsubscribed)return!0;let t=!0,r=!0;for(;r;)this.subscriberHead===this.self.publisherTail?r=!1:this.subscriberHead.next.value!==tr?(t=!1,r=!1):(this.subscriberHead=this.subscriberHead.next,this.subscriberIndex+=1);return t}size(){return this.unsubscribed?0:this.self.publisherIndex-Math.max(this.subscriberIndex,this.self.subscribersIndex)}poll(){if(this.unsubscribed)return Hr;let t=!0,r=Hr;for(;t;)if(this.subscriberHead===this.self.publisherTail)t=!1;else{let n=this.subscriberHead.next.value;n!==tr&&(r=n,this.subscriberHead.subscribers-=1,this.subscriberHead.subscribers===0&&(this.self.publisherHead=this.self.publisherHead.next,this.self.publisherHead.value=tr,this.self.subscribersIndex+=1),t=!1),this.subscriberHead=this.subscriberHead.next,this.subscriberIndex+=1}return r}pollUpTo(t){t=Bt(t);let r=[],n=0;for(;n!==t;){let o=this.poll();o===Hr?n=t:(r.push(o),n+=1)}return r}unsubscribe(){if(!this.unsubscribed)for(this.unsubscribed=!0,this.self.publisherTail.subscribers-=1;this.subscriberHead!==this.self.publisherTail;)this.subscriberHead.next.value!==tr&&(this.subscriberHead.subscribers-=1,this.subscriberHead.subscribers===0&&(this.self.publisherHead=this.self.publisherHead.next,this.self.publisherHead.value=tr,this.self.subscribersIndex+=1)),this.subscriberHead=this.subscriberHead.next}},FA=class{[Sre]={_A:F};pubsub;subscribers;subscription;pollers;shutdownHook;shutdownFlag;strategy;replayWindow;ended;constructor(t,r,n,o,s,i,a,c,u){this.pubsub=t,this.subscribers=r,this.subscription=n,this.pollers=o,this.shutdownHook=s,this.shutdownFlag=i,this.strategy=a,this.replayWindow=c,this.ended=u}pipe(){return V(this,arguments)}},NA=class{[yre]={_A:F};pubsub;subscribers;scope;shutdownHook;shutdownFlag;strategy;ended;constructor(t,r,n,o,s,i,a){this.pubsub=t,this.subscribers=r,this.scope=n,this.shutdownHook=o,this.shutdownFlag=s,this.strategy=i,this.ended=a}pipe(){return V(this,arguments)}},vre=(e,t,r,n,o,s,i)=>new NA(e,t,r,n,o,s,i),Cre=e=>{if(e<=0||e!==1/0&&!Number.isInteger(e))throw new Error(`Cannot construct PubSub with capacity of ${e}`)},ib=class{publishers=Ta();get shutdown(){return ar(t=>Ko(Ec(this.publishers),([r,n,o])=>o?c0(n,t.id):P,{concurrency:"unbounded",discard:!0}))}handleSurplus(t,r,n,o,s){return Nn(i=>{if(de(s.current))return i(I(!1));let a=lu();return this.offerUnsafe(n,a),this.onPubSubEmptySpaceUnsafe(t,r),this.completeSubscribersUnsafe(t,r),tH(o)?(this.removeUnsafe(a),i(Dn)):a.effect?i(a.effect):(a.resumes=[i],W(()=>this.removeUnsafe(a)))})}onPubSubEmptySpaceUnsafe(t,r){let n=!0;for(;n&&!t.isFull();){let o=of(this.publishers);if(o===Hr)n=!1;else{let[s,i]=o,a=t.publish(s);a&&o[2]?hi(i,Mr(!0)):a||wA(this.publishers,o),this.completeSubscribersUnsafe(t,r)}}}completePollersUnsafe(t,r,n,o){return LA(this,t,r,n,o)}completeSubscribersUnsafe(t,r){return BA(this,t,r)}offerUnsafe(t,r){let n=t[Symbol.iterator](),o=n.next();if(!o.done)for(;;){let s=o.value;if(o=n.next(),o.done){zs(this.publishers,[s,r,!0]);break}zs(this.publishers,[s,r,!1])}}removeUnsafe(t){vA(this.publishers,([r,n])=>n!==t)}},ab=class{get shutdown(){return P}handleSurplus(t,r,n,o){return I(!1)}onPubSubEmptySpaceUnsafe(t,r){}completePollersUnsafe(t,r,n,o){return LA(this,t,r,n,o)}completeSubscribersUnsafe(t,r){return BA(this,t,r)}},UA=class{get shutdown(){return P}handleSurplus(t,r,n,o,s){return W(()=>de(s.current)?!1:(this.slidingPublishUnsafe(t,n),this.completeSubscribersUnsafe(t,r),!0))}onPubSubEmptySpaceUnsafe(t,r){}completePollersUnsafe(t,r,n,o){return LA(this,t,r,n,o)}completeSubscribersUnsafe(t,r){return BA(this,t,r)}slidingPublishUnsafe(t,r){let n=r[Symbol.iterator](),o=n.next();if(!o.done&&t.capacity>0){let s=o.value,i=!0;for(;i;){t.slide();let a=t.publish(s);a&&(o=n.next())&&!o.done?s=o.value:a&&(i=!1)}}}},LA=(e,t,r,n,o)=>{let s=!0;for(;s&&!n.isEmpty();){let i=of(o);if(i===Hr)Tre(r,n,o),o.length===0?s=!1:Ire(r,n,o);else{let a=n.poll();a===Hr?wA(o,i):(hi(i,Mr(a)),e.onPubSubEmptySpaceUnsafe(t,r))}}},BA=(e,t,r)=>{for(let[n,o]of r)for(let s of o)e.completePollersUnsafe(t,r,n,s)},cb=class{capacity;head={value:tr,index:0,next:null};tail=this.head;slideValues=[];size=0;index=0;publisherIndex=0;constructor(t){this.capacity=t}slide(t,r){this.slideValues[this.index%this.capacity]={value:t,index:r},this.index++}offer(t){let r=this.publisherIndex++;return this.tail.value=t,this.tail.index=r,this.tail.next={value:tr,index:0,next:null},this.tail=this.tail.next,this.size===this.capacity?this.head=this.head.next:this.size+=1,r}offerAll(t){for(let r of t)this.offer(r)}},gd=class{buffer;values;index=0;remaining;slideIndex;newestIndex=-1;constructor(t){this.buffer=t,this.remaining=t.size,this.slideIndex=t.index,this.values=new Array(this.remaining);let r=t.head;for(let n=0;n<this.remaining;n++)this.values[n]=r.value,this.newestIndex=r.index,r=r.next}close(){this.values.length=0,this.remaining=0}sync(){let t=this.buffer.index-this.slideIndex;if(t===0||this.remaining===0)return;let r=Math.min(t,this.buffer.capacity),n=this.buffer.index-r;for(let o=0;o<r;o++){let s=this.buffer.slideValues[(n+o)%this.buffer.capacity];s.index>this.newestIndex&&(this.index=(this.index+1)%this.values.length,this.values[(this.index+this.remaining-1)%this.values.length]=s.value,this.newestIndex=s.index)}this.slideIndex=this.buffer.index}take(){if(this.remaining===0)return;this.sync();let t=this.values[this.index];return this.values[this.index]=tr,this.index=(this.index+1)%this.values.length,this.remaining--,this.remaining===0&&this.close(),t}takeN(t){t=Bt(t);let r=Math.min(t,this.remaining),n=new Array(r);for(let o=0;o<r;o++)n[o]=this.take();return n}takeAll(){return this.takeN(this.remaining)}},xb={remaining:0,take:()=>{},takeN:()=>[],takeAll:()=>[],close:()=>{}};var Are="~effect/Queue",kre="~effect/Queue/Enqueue",Rre="~effect/Queue/Dequeue";var $A={_A:F,_E:F},Ore={[Are]:$A,[kre]:$A,[Rre]:$A,...wr,toJSON(){return{_id:"effect/Queue",state:this.state._tag,size:Pre(this)}}},io=e=>oe(t=>{let r=Object.create(Ore);return r.dispatcher=t.currentDispatcher,r.capacity=e?.capacity??Number.POSITIVE_INFINITY,r.strategy=e?.strategy??"suspend",r.messages=Ta(),r.scheduleRunning=!1,r.state={_tag:"Open",takers:new Set,offers:new Set,awaiters:new Set},q(r)}),sf=e=>io({capacity:e});var Sb=()=>io(),jn=d(2,(e,t)=>ce(()=>Ic(e,t)?Ib:e.state._tag==="Open"&&e.strategy==="suspend"?Ure(e,t):lH)),Ic=(e,t)=>e.state._tag!=="Open"?!1:e.messages.length>=e.capacity?e.strategy==="sliding"?(of(e.messages),zs(e.messages,t),!0):e.capacity<=0&&e.state.takers.size>0?(zs(e.messages,t),dH(e),!0):!1:(zs(e.messages,t),yb(e),!0),wa=d(2,(e,t)=>$t(r=>{let n=bb(e,t);return n.length===0||e.strategy==="dropping"?r(ze(n)):hH(e,{_tag:"Array",remaining:n,offset:0,resume:r})})),bb=(e,t)=>{if(e.state._tag!=="Open")return Ct(t);if(e.capacity===Number.POSITIVE_INFINITY||e.strategy==="sliding")return rb(e.messages,t),e.strategy==="sliding"&&nf(e.messages,e.messages.length-e.capacity),yb(e),[];let r=e.capacity<=0?e.state.takers.size:e.capacity-e.messages.length;if(r===0)return Ct(t);let n=[],o=0;for(let s of t)o<r?zs(e.messages,s):n.push(s),o++;return yb(e),n};var Ht=d(2,(e,t)=>ye(()=>Ui(e,t))),Ui=(e,t)=>{if(e.state._tag!=="Open")return!1;let r=Pr(t),n=TM(r,Mre);return e.state.offers.size===0&&e.messages.length===0?(Tb(e,n),!0):(e.state={...e.state,_tag:"Closing",exit:n},yb(e),!0)},yd=e=>Ht(e,Mf(Zc())),Eb=e=>Ui(e,Mf(Zc()));var ss=e=>ye(()=>HA(e)),HA=e=>{if(e.state._tag==="Done")return!1;Ia(e.messages);let t=e.state.offers;Tb(e,e.state._tag==="Open"?Fre:e.state.exit);for(let r of t)xH(r);return!0};var af=e=>fH(e,1,Number.POSITIVE_INFINITY);var fH=d(3,(e,t,r)=>(t=Bt(t),r=Bt(r),pH(()=>Nre(e,t,r)??bo(mH(e,()=>qA(e,t)),fH(e,t,r))))),Ws=e=>pH(()=>_re(e)??bo(mH(e,()=>qA(e,1)),Ws(e)));var _re=e=>{if(e.state._tag==="Done")return e.state.exit;if(e.messages.length>0){let t=of(e.messages);return jA(e),ze(t)}else if(e.capacity<=0&&e.state.offers.size>0){let t=gH(e.state.offers);return jA(e),ze(t)}};var Pre=e=>e.state._tag==="Done"?0:e.messages.length;var lH=ze(!1),Ib=ze(!0),Mre=So(Zc()),Fre=Zf(),dH=e=>{if(!(e.state._tag==="Done"||e.state.takers.size===0)){for(let t of e.state.takers)if(t.ready()&&(e.state.takers.delete(t),t.resume(hn),e.messages.length===0))break}},yb=e=>{e.scheduleRunning||e.state._tag==="Done"||e.state.takers.size===0||(e.scheduleRunning=!0,e.dispatcher.scheduleTask(()=>{e.scheduleRunning=!1,dH(e)},0))},Nre=(e,t,r)=>{if(e.state._tag==="Done")return e.state.exit;if(r<=0||t<=0)return ze([]);if(!qA(e,t))return;let n=e.messages.length>0?nf(e.messages,r):[gH(e.state.offers)];return jA(e),ze(n)},pH=Uo({op:"QueueTake",[St](e){let t=this[Se]();return Gd(t)?t[St](e):t}}),qA=(e,t)=>e.messages.length>=(e.state._tag==="Closing"?1:Math.min(t,e.capacity||1))||e.capacity<=0&&e.state._tag!=="Done"&&e.state.offers.size>0,mH=(e,t)=>$t(r=>{if(e.state._tag==="Done")return r(e.state.exit);if(t())return r(hn);let n={ready:t,resume:r};return e.state.takers.add(n),ye(()=>{e.state._tag!=="Done"&&e.state.takers.delete(n)})}),Ure=(e,t)=>$t(r=>Ic(e,t)?r(Ib):hH(e,{_tag:"Single",message:t,resume:r})),hH=(e,t)=>{if(e.state._tag!=="Open")return xH(t);let r=e.state.offers;return r.add(t),ye(()=>{e.state._tag!=="Done"&&(r.delete(t),e.state._tag==="Closing"&&r.size===0&&e.messages.length===0&&Tb(e,e.state.exit))})},xH=e=>e._tag==="Single"?e.resume(lH):e.resume(ze(e.remaining.slice(e.offset))),gH=e=>{let t=e.values().next().value;if(t._tag==="Single")return e.delete(t),t.resume(Ib),t.message;let r=t.remaining[t.offset++];return t.offset===t.remaining.length&&(e.delete(t),t.resume(ze([]))),r},jA=e=>{if(e.state._tag==="Done")return wo(e.state.exit.cause);if(e.state.offers.size===0)return e.state._tag==="Closing"&&e.messages.length===0?(Tb(e,e.state.exit),wo(e.state.exit.cause)):!1;for(let t of e.state.offers){let r=e.capacity-e.messages.length;if(r<=0)break;if(t._tag==="Single")zs(e.messages,t.message),e.state.offers.delete(t),t.resume(Ib);else{for(;t.offset<t.remaining.length;t.offset++){if(r===0)return!1;zs(e.messages,t.remaining[t.offset]),r--}e.state.offers.delete(t),t.resume(ze([]))}let n=e.state;if(n._tag==="Done")return wo(n.exit.cause)}return!1};var Tb=(e,t)=>{if(e.state._tag==="Done")return;let r=e.state;e.state={_tag:"Done",exit:t};for(let n of r.takers)n.resume(t);r.takers.clear();for(let n of r.awaiters)n(t);r.awaiters.clear()};var uf=e=>new zA(e),yH=(e,t,r)=>$t(n=>{if(e.free>=t)return n(r);let o=()=>{e.free<t||(e.waiters.delete(o),n(r))};return e.waiters.add(o),ye(()=>{e.waiters.delete(o)})}),zA=class{waiters=new Set;taken=0;permits;constructor(t){this.permits=t}get free(){return this.permits-this.taken}take(t){let r=ce(()=>this.free<t?yH(this,t,r):(this.taken+=t,q(t)));return r}takeIfAvailable(t){return ce(()=>this.free<t?q(!1):(this.taken+=t,q(!0)))}releaseUnsafe(t,r){return this.taken-=r,this.waiters.size>0&&t.currentDispatcher.scheduleTask(()=>{for(let n of this.waiters){if(this.free<=0)break;n()}},0),this.free}resize(t){return oe(r=>(this.permits=t,this.free<0?pe:(this.releaseUnsafe(r,0),pe)))}release(t){return oe(r=>q(this.releaseUnsafe(r,t)))}get releaseAll(){return oe(t=>q(this.releaseUnsafe(t,this.taken)))}withPermits(t){return r=>Gn(n=>{let o=ce(()=>{if(this.free<t){let s=yH(this,t,pe);return Y(n(s),()=>o)}return this.taken+=t,Io(n(r),()=>{this.releaseUnsafe(ea(),t)},!0)});return o})}withPermit=this.withPermits(1);withPermitsIfAvailable(t){return r=>Gn(n=>this.free<t?iu:(this.taken+=t,Io(n(Jf(r)),()=>{this.releaseUnsafe(ea(),t)},!0)))}};var KA=e=>ws(e)?ft(e)?se(e.value):e:I(e);var IH="~effect/Channel",on=e=>O(e,IH),Dre={[IH]:{_Env:F,_InErr:F,_InElem:F,_OutErr:F,_OutElem:F},pipe(){return V(this,arguments)}},De=e=>{let t=Object.create(Dre);return t.transform=(r,n)=>rt(e(r,n),o=>I(je(o))),t},is=(e,t)=>De((r,n)=>A(we(e)(r,n),o=>t(o,n))),qr=e=>De((t,r)=>e),Vs=e=>De(me(function*(t,r){let n=yr(r),o=i=>Ve(n,ey(i)),s=yield*to(e(t,r,n),o);return to(s,o)})),we=e=>e.transform,dh=4096,Lre=(e,t,r)=>io({capacity:r?.bufferSize,strategy:r?.strategy}).pipe(_t(n=>It(e,ss(n))),_t(n=>zo(t(n),e).pipe(rt(o=>Ht(n,o)),gt(e))));var TH=(e,t)=>De((r,n)=>K(Lre(n,e,t),af)),wb=e=>De((t,r)=>L(()=>we(e())(t,r))),Bre=(e,t,r)=>Vs(me(function*(n,o,s){let i=_();yield*Wo(s,c=>de(i)?r(i.value,c):P);let a=yield*Ci(K(e,c=>(i=N(c),c)));return yield*we(t(a))(n,o)}));var wH=e=>qr(W(()=>{let t=e();return L(()=>{let r=t.next();return r.done?se(r.value):I(r.value)})})),VA=e=>qr(W(()=>{let t=0;return L(()=>t>=e.length?se():I(e[t++]))}));var GA=(e,t=dh)=>{let r=Lo(t);return qr(W(()=>{let n=e(),o=_();return L(()=>{if(o._tag==="Some")return se(o.value);let s=[];for(;s.length<r;){let i=n.next();if(i.done){if(s.length===0)return se(i.value);o=N(i.value);break}s.push(i.value)}return I(s)})}))};var vH=(e,t=dh)=>GA(()=>e[Symbol.iterator](),t),vb=e=>Cb(I(e));var CH=e=>Cb(W(e)),Sd=qr(I(se())),AH=qr(I(Xn)),Di=e=>qr(I(D(e))),kH=e=>qr(sy(e)),ph=e=>qr(je(e)),RH=e=>qr(aa(e)),JA=e=>ph(cl(e)),Cb=e=>qr(W(()=>{let t=!1;return L(()=>t?se():(t=!0,e))}));var OH=e=>qr(A(e,()=>se())),ZA=e=>qr(I(A(e,KA)));var _H=e=>qr(I(af(e)));var QA=e=>qr(I(Su(cH(e),()=>se())));var PH=e=>Tc(K(lh(e),QA)),MH=e=>Tc(K(lh(e),t=>ZA(hb(t))));var FH=e=>De((t,r)=>$re({scope:r,readable:e.evaluate(),onError:e.onError,releaseLockOnEnd:e.releaseLockOnEnd}));var $re=e=>{let t=e.readable.getReader(),r=e.exit??xd(void 0),n=L(()=>r.current?r.current:Un(Vo({try:()=>t.read(),catch:e.onError}),{onFailure:o=>r.current??je(o),onSuccess:({done:o,value:s})=>r.current?r.current:o?se():I(Me(s))}));return Pt(It(e.scope,e.releaseLockOnEnd?W(()=>t.releaseLock()):Wp(()=>t.cancel().catch(Rr))),n)},jre=(e,t)=>De(me(function*(r,n){let o=e[Symbol.asyncIterator]();return o.return&&(yield*It(n,Wp(()=>o.return()))),A(Vo({try:()=>o.next(),catch:t}),s=>s.done?se(s.value):I(s.value))})),NH=(e,t)=>Gs(jre(e,t),Me),Gs=d(2,(e,t)=>is(e,r=>W(()=>{let n=0;return K(r,o=>t(o,n++))})));var UH=d(2,(e,t)=>is(e,r=>I(ht(r,n=>A(t(n),se))))),DH=e=>e===void 0||e!=="unbounded"&&e<=1,Ab=d(e=>on(e[0]),(e,t,r)=>DH(r?.concurrency)?LH(e,t):Hre(e,t,r)),LH=(e,t)=>De((r,n)=>{let o=0;return K(we(e)(r,n),A(s=>t(s,o++)))}),Hre=(e,t,r)=>Vs(me(function*(n,o,s){let i=0,a=yield*we(e)(n,o),c=r.concurrency==="unbounded"?Number.MAX_SAFE_INTEGER:r.concurrency,u=yield*sf(0);yield*It(s,ss(u));let f=Sr(yield*Nr()),p=Ni(s);if(r.unordered){let m=uf(c),h=qe(m.release(1)),x=Un({onFailure:g=>A(Ht(u,g),h),onSuccess:g=>A(jn(u,g),h)});yield*m.take(1).pipe(A(()=>a),A(g=>{let y=i++;return p(f(x(L(()=>t(g,y))))),P}),Mt({disableYield:!0}),rt(g=>m.withPermits(c-1)(Ht(u,g))),gt(s))}else{let m=yield*sf(c-2);yield*It(s,ss(m)),yield*Ws(m).pipe(j0,A(g=>jn(u,g)),Mt({disableYield:!0}),rt(g=>Ht(u,g)),gt(s));let h,x=g=>{g._tag!=="Success"&&(h=g.cause,Ui(u,g.cause))};yield*a.pipe(A(g=>{if(h)return je(h);let y=i++,E=f(L(()=>t(g,y)));return p(E),E.addObserver(x),jn(m,bc(E))}),Mt({disableYield:!0}),rt(g=>jn(m,ir(g)).pipe(Vt(Ht(m,g)))),gt(s))}return Ws(u)}));var YA=d(e=>on(e[0]),(e,t,r)=>DH(r?.concurrency)?qre(e,t):zre(e,t,r)),qre=(e,t)=>De((r,n)=>K(we(e)(r,n),o=>{let s,i,a=A(o,u=>(i??=yr(n),ur(we(t(u))(r,i),f=>(s=c(f),s)))),c=ht(u=>{if(s=void 0,i.state._tag==="Empty")return a;let f=Ve(i,Kt);return i=void 0,A(f,()=>a)});return L(()=>s??a)})),zre=(e,t,r)=>e.pipe(Gs(t),Ob(r)),BH=d(2,(e,t)=>De((r,n)=>W(()=>{let o,s=yr(n),i=A(we(e)(r,s),a=>(o=ht(a,c=>Ve(s,Kt).pipe(A(()=>we(t(c))(r,n)),A(u=>(o=u,u)))),o));return L(()=>o??i)})));var XA=d(4,(e,t,r,n)=>De(me(function*(o,s){let i=yield*we(e)(o,s),a=yield*we(t)(o,s),c=r();return L(()=>{let u=n(c,i,a);return K(u,([f,p])=>(c=p,f))})}))),$H=d(2,(e,t)=>De((r,n)=>W(()=>{let o,s=yr(n),i=A(we(e)(r,s),a=>{let c=a.pipe(_t(()=>(o=a,P)),ht(u=>Ve(s,Mr(u)).pipe(Vt(we(t(u))(r,n)),A(f=>(o=f,f)))));return o=c,c});return L(()=>o??i)}))),jH=e=>YA(e,F),wn=e=>is(e,t=>{let r,n=0,o=L(function s(){if(r===void 0)return A(t,a=>{switch(a.length){case 0:return s();case 1:return I(a[0]);default:return r=a,I(a[n++])}});let i=r[n++];return n>=r.length&&(r=void 0,n=0),I(i)});return I(o)}),HH=e=>LH(e,KA),qH=e=>is(e,t=>I(Mt(t,{disableYield:!0}))),zH=d(2,(e,t)=>ks(typeof t=="function"?t(F):t).pipe(K(r=>{let n=Fr.defaultValue();return WH(Fb(e,Fr,W(()=>n)),o=>r(o).pipe(K(s=>{n=s}),ht(()=>se(o))))}),Tc)),WH=(e,t)=>De((r,n)=>W(()=>{let o,s=()=>{let i=yr(n);return A(we(e)(r,i),a=>(o=ht(a,c=>Ve(i,Kt).pipe(A(()=>t(c)),A(s))),o))};return L(()=>o??s())})),KH=e=>WH(e,()=>P),VH=d(2,(e,t)=>is(e,(r,n)=>K(Lp(t),o=>_t(r,o)))),GH=d(2,(e,t)=>De((r,n)=>K(we(e)(r,n),o=>A(o,function s(i){return t(i)?I(i):A(o,s)}))));var JH=d(2,(e,t)=>is(e,r=>I(A(r,function n(o){let s=[];for(let i=0;i<o.length;i++)t(o[i])&&s.push(o[i]);return bt(s)?I(s):A(r,n)})))),ZH=d(2,(e,t)=>is(e,r=>I(A(r,function n(o){let s=[];for(let i=0;i<o.length;i++){let a=t(o[i]);tt(a)&&s.push(a.success)}return bt(s)?I(s):A(r,n)})))),QH=d(2,(e,t)=>is(e,r=>{let n=A(r,o=>G0(o,t));return I(A(n,function o(s){return bt(s)?I(s):A(n,o)}))})),YH=d(2,(e,t)=>is(e,r=>I(A(r,function n(o){return A(J0(o,t),s=>bt(s)?I(s):A(r,n))})))),bd=d(e=>on(e[0]),(e,t,r,n)=>De((o,s)=>K(we(e)(o,s),i=>{let a=t(),c,u=0,f,p=Un(i,{onFailure(h){f=h;let x=n?.onHalt&&n.onHalt(a);return x&&x.length>0?I([a,x]):je(h)},onSuccess(h){let x=r(a,h);return Y_(x)?I(x):x}});return L(function h(){if(c===void 0)return f?je(f):A(p,([g,y])=>(a=g,y.length===0?h():y.length===1?I(y[0]):(c=y,h())));let x=c[u++];return u>=c.length&&(c=void 0,u=0),I(x)})})));var XH=d(3,(e,t,r)=>De((n,o)=>K(we(e)(n,o),s=>{let i=t,a=!0;return L(()=>a?(a=!1,I(i)):K(A(s,c=>r(i,c)),c=>(i=c,i)))}))),Ed=d(2,(e,t)=>De((r,n)=>{let o=yr(n);return K(we(e)(r,o),s=>{let i=s.pipe(rt(a=>{if(wo(a))return je(a);let c=o;return o=yr(n),Ve(c,ir(a)).pipe(Vt(we(t(a))(r,o)),A(u=>(i=u,u)))}));return L(()=>i)})})),eq=d(2,(e,t)=>Rb(e,Rp,t)),kb=d(2,(e,t)=>Ed(e,r=>OH(A(t(r),n=>je(r))))),tq=d(3,(e,t,r)=>Ed(e,n=>t(n)?r(n):ph(n))),Rb=d(3,(e,t,r)=>Ed(e,n=>{let o=t(n);return be(o)?ph(o.failure):r(o.success,n)})),Ks=d(2,(e,t)=>Rb(e,ul,r=>t(r)));var rq=d(2,(e,t)=>is(e,r=>I(Gp(r,n=>Op(n)?P:vo(t(n)))))),nq=d(e=>on(e[0]),(e,t,r,n)=>Ks(e,o=>t(o)?r(o):n?n(o):Di(o))),oq=d(e=>on(e[0]),(e,t,r,n)=>Ks(e,o=>{let s=t(o);return be(s)?n?n(s.failure):Di(s.failure):r(s.success)}));var sq=d(e=>on(e[0]),(e,t,r,n,o)=>Ks(e,s=>{if(Or(s,t)&&O(s,"reason")){let i=s.reason;return Or(i,r)?n(i,s):o?o(i,s):Di(s)}return Di(s)})),iq=d(e=>on(e[0]),(e,t,r,n)=>{let o;return Ks(e,s=>{if(Or(s,t)&&O(s,"reason")&&O(s.reason,"_tag")&&Xg(s.reason._tag)){let i=s.reason;return o??=new Set(Object.keys(r)),o.has(i._tag)?r[i._tag](i,s):n?n(i,s):Di(s)}return Di(s)})});var aq=d(2,(e,t)=>Ks(e,r=>Di(t(r)))),cq=e=>Ks(e,JA),uq=d(e=>on(e[0]),(e,t)=>{if(!t?.log)return Ks(e,()=>Sd);let r=Tl(t.log===!0?void 0:t.log);return Ks(kb(e,n=>gN(n)?r(n):P),()=>Sd)}),bH=e=>Ed(e,()=>Sd),fq=d(e=>on(e[0]),(e,t)=>{if(!t?.log)return bH(e);let r=Tl(t.log===!0?void 0:t.log);return bH(kb(e,n=>r(n)))}),lq=d(2,(e,t)=>wb(()=>{let r,n=Fr.defaultValue(),o=Fb(e,Fr,W(()=>n)),s=nk(o,()=>(r=void 0,P)),i=typeof t=="function"?t(F):t,a=Ks(s,me(function*(c){return r||(r=yield*ks(i)),n=yield*r(c),a},(c,u)=>ht(c,()=>I(Di(u))),Tc));return a})),dq=d(e=>on(e[0]),(e,t,r)=>e.pipe(Gs(t),Ob({...r,concurrency:r?.concurrency??1,switch:!0}))),Ob=d(2,(e,{bufferSize:t=16,concurrency:r,switch:n=!1})=>Vs(me(function*(o,s,i){let a=r==="unbounded"?Number.MAX_SAFE_INTEGER:Math.max(1,r),c=n?void 0:uf(a),u=yield*Xj(!0),f=new Set,p=yield*sf(t);yield*It(i,ss(p));let m=yield*we(e)(o,s);return yield*xt(function*(){for(;;){let h;c&&(f.size<a?yield*c.take(1):(h=yield*El(m),yield*Ya(c.take(1),Vt(bc(h),Xn))));let x=h===void 0?yield*m:yield*bc(h),g=yr(i),y=yield*we(x)(o,g);for(;f.size>=a;){let b=K_(f);f.delete(b),f.size===0&&(yield*u.open),yield*Tn(b)}let E=yield*y.pipe(_t(()=>Vp),A(b=>jn(p,b)),Mt({disableYield:!0}),to(me(function*(b){let v=ey(b),T=yield*eo(Ve(g,v));if(!f.has(E))return;let S=wN([v,T]);vs(S)&&(yield*Ht(p,S.cause)),f.delete(E),c&&(yield*c.release(1)),f.size===0&&(yield*u.open)})),El);u.closeUnsafe(),f.add(E)}}).pipe(rt(h=>{let x=Up(h);return tt(x)?u.whenOpen(Ht(p,h)):Ht(p,h)}),gt(i)),Ws(p)}))),_b=d(e=>on(e[0])&&on(e[1]),(e,t,r)=>Vs(me(function*(n,o,s){let i=r?.haltStrategy??"both",a=yield*sf(0);yield*It(s,ss(a));let c=0;function u(p,m){if(c++,!wo(m))return Ht(a,m);switch(i){case"both":return c===2?Ht(a,m):P;case"left":case"right":return p===i?Ht(a,m):P;case"either":return Ht(a,m)}}let f=(p,m,h)=>we(m)(n,h).pipe(A(x=>x.pipe(A(g=>jn(a,g)),Mt)),to(x=>Zp(ey(x),g=>Ve(h,g)).pipe(Un({onFailure:g=>u(p,g),onSuccess:()=>u(p,x)}))),gt(s));return yield*f("left",e,yr(s)),yield*f("right",t,yr(s)),Ws(a)}))),pq=d(2,(e,t)=>_b(e,OH(t),{haltStrategy:"left"})),mq=()=>De((e,t)=>W(()=>{let r="",n=!1,o=_();function s(c){let u=[];function f(p){r.length===0?u.push(p):(u.push(r+p),r="")}for(let p=0;p<c.length;p++){let m=c[p];if(m.length!==0){let h=0,x=m.indexOf("\r"),g=m.indexOf(`
23
+ ${KP(e.cause,`${t} `)}
24
+ ${t}}`),n},ET="~effect/Fiber",MV={_A:F,_E:F},FV={id:0},OP=(()=>{try{return globalThis.process?.getBuiltinModule?.("node:async_hooks")?.AsyncResource}catch{return}})(),VP=()=>OP===void 0?void 0:new OP("effect/Fiber"),ea=()=>globalThis[kf],pp=class{constructor(t,r=!0){this.setContext(t),this.id=++FV.id,this.currentOpCount=0,this.interruptible=r,this._stack=[],this._observers=void 0,this._exit=void 0,this._children=void 0,this._interruptedCause=void 0,this._yielded=void 0,this._running=!1,this._deferredInterrupt=!1,this._parent=void 0,this._asyncContext=void 0,this.cache.runtimeMetrics?.recordFiberStart(this.context)}get[ET](){return MV}get currentDispatcher(){return this._dispatcher??=this.cache.scheduler.makeDispatcher()}getRef(t){return Re(this.context,t)}addObserver(t){return this._exit?(t(this._exit),Rr):(this._observers===void 0?this._observers=[t]:this._observers.push(t),()=>this.removeObserver(t))}removeObserver(t){if(this._exit||this._observers===void 0)return;let r=this._observers.indexOf(t);r>=0&&this._observers.splice(r,1)}interruptUnsafe(t,r){if(this._exit)return;let n=ja(t);this.cache.stackFrame&&(n=Zd(n,ys(wx,this.cache.stackFrame))),r&&(n=Zd(n,r)),this._interruptedCause=this._interruptedCause?Pf(this._interruptedCause,n):n,this.interruptible&&(this._running?this._deferredInterrupt=!0:this.evaluate(Ye(this._interruptedCause)))}pollUnsafe(){return this._exit}evaluate(t){if(this._exit)return;if(this._asyncContext!==void 0){let o=this._asyncContext;return this._asyncContext=void 0,o.runInAsyncScope(this.evaluate,this,t)}else if(this._yielded!==void 0){let o=this._yielded;this._yielded=void 0,o()}let r=this.runLoop(t);if(r===Zc){this._asyncContext=VP();return}let n=cT.interruptChildren&&cT.interruptChildren(this);if(n!==void 0)return this.evaluate(Y(n,()=>r));if(this._exit=r,this.cache.runtimeMetrics?.recordFiberEnd(this.context,this._exit),this._parent&&(this._parent._children?.delete(this),this._parent=void 0),this._observers!==void 0){let o=this._observers;this._observers=void 0;for(let s=0;s<o.length;s++)o[s](r)}this._stack.length=0,this._children=void 0,this.context=pt()}runLoop(t){let r=globalThis[kf];globalThis[kf]=this;let n=this._running;this._running=!0;let o=!1,s=t;this.currentOpCount=0;try{for(;;)try{this._deferredInterrupt&&(this._deferredInterrupt=!1,s=Ye(this._interruptedCause)),this.currentOpCount++;let i=this.cache;if(!o&&!i.preventYield&&i.scheduler.shouldYield(this)){o=!0;let a=s;s=Y(Gf,()=>a)}if(s=i.tracerContext?i.tracerContext(s,this):s[St](this),s===Zc){let a=this._yielded;if(Vc in a)return this._deferredInterrupt=!1,this._yielded=void 0,a;if(this._deferredInterrupt){this._yielded=void 0,a();continue}return Zc}}catch(i){if(!O(s,St))return ln(`Fiber.runLoop: Not a valid effect: ${String(s)}`);s=ln(i)}}finally{this._running=n,globalThis[kf]=r}}getCont(t){if(this._deferredInterrupt)return this._deferredInterrupt=!1,UV;for(;;){let r=this._stack.pop();if(!r)return;let n=r[Gc];if(n!==void 0){let o=n.call(r,this);if(o)return o[t]=o,o}if(r[t])return r}}succeedWith(t){if((++this.currentOpCount&DV-1)===0)return ze(t);let r=this.getCont(mr);return r?r[mr](t,this):this.yieldWith(ze(t))}yieldWith(t){return this._yielded=t,Zc}children(){return this._children??=new Set}pipe(){return V(this,arguments)}setContext(t){let r=this.context;if(this.context=t,r!==void 0&&B_(r,t))return;let n=t.cacheRoot,o=n._fiberCache??=NV(t);this.cache?.scheduler!==o.scheduler&&(this._dispatcher=void 0),this.cache=o}get currentSpanLocal(){let t=this.cache.span;return t?._tag==="Span"?t:void 0}},NV=e=>{let t=Gi(e,XI);return{scheduler:Re(e,Ba),tracer:t,tracerContext:t?t.context:void 0,tracerEnabled:Re(e,Zx),span:Gi(e,YI),logLevel:Re(e,rT),minimumLogLevel:Re(e,nT),stackFrame:Re(e,zf),runtimeMetrics:Gi(e,CP),maxOpsBeforeYield:Re(e,gP),preventYield:Re(e,yP)}},UV={[mr](e,t){return Ye(t._interruptedCause)},[go](e,t){return Ye(t._interruptedCause)}},DV=32,cT={interruptChildren:void 0},dg=e=>{if(!e.cache.stackFrame)return;let t=new Map;return t.set(bI.key,e.cache.stackFrame),qn(t)},LV=e=>{if(!(e._children===void 0||e._children.size===0))return Wf(e._children)},IT=e=>{let t=e;return t._exit?q(t._exit):$t(r=>t._exit?r(q(t._exit)):ye(e.addObserver(n=>r(q(n)))))},pg=e=>$t(t=>{let r=e[Symbol.iterator](),n=[],o;function s(){let i=r.next();for(;!i.done;){if(i.value._exit){n.push(i.value._exit),i=r.next();continue}o=i.value.addObserver(a=>{n.push(a),s()});return}t(q(n))}return s(),ye(()=>o?.())}),Xx=e=>{let t=e;return t._exit?t._exit:$t(r=>t._exit?r(t._exit):ye(e.addObserver(r)))},GP=e=>$t(t=>{let r=Array.from(e);if(r.length===0)return t(q(Qt()));let n=new Array(r.length),o=Qt(),s=()=>{for(let c=0;c<o.length;c++)r[c].removeObserver(o[c])},i=0,a=!1;for(let c=0;c<r.length&&!a;c++){let u=f=>{if(i++,f._tag==="Failure")return a=!0,s(),t(f);n[c]=f.value,i===r.length&&t(q(n))};o.push(u),r[c].addObserver(u)}return ye(()=>{a=!0,s()})}),xp=e=>oe(t=>JP(e,t.id)),JP=d(e=>O(e[0],ET),(e,t,r)=>oe(n=>{let o=dg(n);return o=o&&r?Kr(o,r):o??r,e.interruptUnsafe(t,o),yp(IT(e))})),Wf=e=>oe(t=>{let r=dg(t),n=Qt();for(let o of e)o.interruptUnsafe(t.id,r),n.push(o);return yp(pg(n))});var q=ze,Ye=Pr,Et=So,ye=Uo({op:"Sync",[St](e){let t=this[Se](),r=e.getCont(mr);return r?r[mr](t,e):e.yieldWith(ze(t))}}),ce=Uo({op:"Suspend",[St](e){return this[Se]()}}),TT=d(e=>e.length>=2||ci(e[0]),(e,t)=>fe(e)?Et(t?t():new ms("Effect.fromOption: Option.none")):q(e.value)),Vf=zn({onFailure:Et,onSuccess:q}),ZP=e=>e==null?Et(new ms):q(e),wT=Uo({op:"Yield",[St](e){let t=!1;return e.currentDispatcher.scheduleTask(()=>{t||e.evaluate(hn)},this[Se]??0),e.yieldWith(()=>{t=!0})}}),Gf=wT(0),vT=e=>q(N(e)),au=q(_()),QP=e=>fe(e)?au:_e(e.value,N),YP=e=>ce(()=>Ye(e())),ta=e=>ln(e),mg=e=>ce(()=>Et(e())),pe=q(void 0);var XP=e=>{let t=typeof e=="function"?e:e.try,r=typeof e=="function"?n=>new hp(n,"An error occurred in Effect.try"):e.catch;return ce(()=>{try{return q(t())}catch(n){return Et(r(n))}})};var AT=e=>CT(function(t,r){e(r).then(n=>t(q(n)),n=>t(ta(n)))},e.length!==0),eM=e=>{let t=typeof e=="function"?e:e.try,r=typeof e=="function"?n=>new hp(n,"An error occurred in Effect.tryPromise"):e.catch;return CT(function(n,o){let s=i=>ce(()=>{try{return Et(Ma(()=>r(i)))}catch(a){return ta(a)}});try{t(o).then(i=>n(q(i)),i=>n(s(i)))}catch(i){n(s(i))}},t.length!==0)},tM=e=>oe(t=>e(t.id)),rM=oe(q),nM=tM(q),CT=(function(){let e=yo({op:"Async",[St](r){let n=!1,o=!1,s=this.withSignal?new AbortController:void 0,i=this.register.call(r.cache.scheduler,a=>{n||(n=!0,o?r.evaluate(a):o=a)},s?.signal);return o!==!1?o:(o=!0,r._yielded=()=>{n=!0},s===void 0&&i===void 0?Zc:(r._stack.push(BV(()=>(n=!0,s?.abort(),i??hn))),Zc))}}),t=function(r,n){this.register=r,this.withSignal=n};return t.prototype=e,function(r,n){return new t(r,n)}})(),BV=Uo({op:"AsyncFinalizer",[Gc](e){e.interruptible&&(e.interruptible=!1,e._stack.push(wp))},[go](e,t){return cg(e)?Y(nF(Pr(e),this[Se]()),()=>Ye(e)):Ye(e)}}),$t=e=>CT(e,e.length>=2),gp=$t(Rr),oM=(...e)=>{if(e.length===1){let n=e[0];return ce(()=>iu(n()))}let[t,r]=e;return ce(()=>iu(r.call(t.self)))},kT=(e,...t)=>{let r=t.length===0?function(){return ce(()=>iu(e.apply(this,arguments)))}:function(){let n=ce(()=>iu(e.apply(this,arguments)));for(let o=0;o<t.length;o++)n=t[o](n,...arguments);return n};return RT(e.length,r)},RT=(e,t)=>Object.defineProperty(t,"length",{value:e,configurable:!0}),_P=oT(2),sM=function(){let e=typeof arguments[0]=="string",t=e?arguments[0]:"Effect.fn",r=e?arguments[1]:void 0,n=Ir(),o;return n!==0&&(yt(2),o=new globalThis.Error,yt(n)),e?(s,...i)=>PP(t,s,o,i,e,r):PP(t,arguments[0],o,Array.prototype.slice.call(arguments,1),e,r)},PP=(e,t,r,n,o,s)=>{let i=typeof t=="function"?t:n.shift().bind(t.self),a=`${e} (definition)`,c=r?_P(()=>r.stack):po;return RT(i.length,function(...u){let f=ce(()=>{let h=i.apply(this,arguments);return ge(h)?h:iu(h)});for(let h=0;h<n.length;h++)f=n[h](f,...u);if(!ge(f))return f;let p=Ir(),m;return p!==0&&(yt(2),m=new globalThis.Error,yt(p)),na(o?mp(e,s,h=>pT(f,h)):f,zf,h=>({name:e,stack:m?_P(()=>m.stack):po,parent:{name:a,stack:c,parent:h}}))})},iM=(e,...t)=>RT(e.length,t.length===0?function(){return MP(()=>e.apply(this,arguments))}:function(){let r=MP(()=>e.apply(this,arguments));for(let n of t)r=n(r,...arguments);return r}),MP=e=>{try{let t=e(),r;for(;;){let n=t.next(r);if(n.done)return q(n.value);let o=n.value;if(o&&o._tag==="Success"){r=o.value;continue}else{if(o&&o._tag==="Failure")return n.value;{let s=!0;return ce(()=>s?(s=!1,Y(n.value,i=>iu(t,i))):ce(()=>iu(e())))}}}}catch(t){return ta(t)}},iu=(function(){let e=yo({op:"Iterator",[mr](r,n){let o=this.iterator;for(;;){let s=o.next(r);if(s.done)return q(s.value);if(Xe(s.value)){if(s.value._tag==="Failure")return s.value}else return n._stack.push(this),s.value;r=s.value.value}},[St](r){return this[mr](this.initial,r)}}),t=function(r,n){this.iterator=r,this.initial=n};return t.prototype=e,function(r,n){return new t(r,n)}})(),Zr=d(2,(e,t)=>new ra(e,OT,q(t))),hg=function(e){return e._stack.push(this),this[Se]},$V=yo({op:"OnSuccess",[St]:hg}),ra=function(e,t,r){this[Se]=e,this[mr]=t,this.payload=r};ra.prototype=$V;var OT=function(){return this.payload},aM=function(e,t){return t.succeedWith(this.payload)},xg=(()=>{let e=Ir();if(e===0)return!1;let t="~effect/Effect/stackProbe",r={[t]:function(){return new Error}};yt(1);let n=r[t]();return yt(e),n.stack?.includes("[as "+t+"]")===!0})(),jV=function(e,t){let r=this.payload;return t.succeedWith(xg?r(e):Ma(()=>r(e)))},cM=function(e){let t=this.payload;return t(e)},HV=function(e){let t=this.payload;return new ra(t(e),aM,e)},qV=function(e){return new ra(this.payload,aM,e)},Jf=e=>_e(e,N),uM=e=>Xf(e,{onFailure:q,onSuccess:Et}),bo=d(2,(e,t)=>new ra(e,ge(t)?OT:cM,t)),pi=d(2,(e,t)=>new ra(e,ge(t)?qV:HV,t)),yp=e=>new ra(e,OT,hn),fM=e=>Mn(e,Et),_T=(e,t)=>oe(r=>{let n=new Set;return Ka(r,()=>n.size===0?void 0:Wf(n)),$t(o=>{let s=At(e),i=s.length,a=0,c=!1,u=[],f=(p,m,h)=>{if(a++,p._tag==="Failure"){u.push(...p.cause.reasons),a>=i&&o(Ye(zi(u)));return}let x=!c;c=!0,o(p),x&&t?.onWinner&&t.onWinner({fiber:m,index:h,parentFiber:r})};for(let p=0;p<i;p++){let m=uu(r,s[p],!0,!0,!1);if(n.add(m),m.addObserver(h=>{n.delete(m),f(h,m,p)}),c)break}})}),PT=(e,t)=>oe(r=>{let n=new Set;return Ka(r,()=>n.size===0?void 0:Wf(n)),$t(o=>{let s=!1,i=0;for(let a of e){if(s)break;let c=i++,u=uu(r,a,!0,!0,!1);n.add(u),u.addObserver(f=>{n.delete(u);let p=!s;s=!0,o(f),p&&t?.onWinner&&t.onWinner({fiber:u,index:c,parentFiber:r})})}})}),lM=d(e=>ge(e[1]),(e,t,r)=>_T([e,t],r)),MT=d(e=>ge(e[1]),(e,t,r)=>PT([e,t],r)),Y=d(2,(e,t)=>new ra(e,cM,t)),dM=d(2,(e,t)=>Xe(e)?e._tag==="Success"?t.onSuccess(e.value):t.onFailure(e.cause):di(e,t)),Xe=e=>e[Vc]!==void 0,pM=d(2,(e,t)=>Xe(e)?e._tag==="Success"?t(e.value):e:Y(e,t)),mM=e=>Y(e,F),_e=d(2,(e,t)=>new ra(e,jV,t)),hM=d(2,(e,t)=>Xe(e)?EM(e,t):_e(e,t)),xM=d(2,(e,t)=>Xe(e)?IM(e,t):jT(e,t)),gM=d(2,(e,t)=>Xe(e)?TM(e,t):HT(e,t)),yM=d(2,(e,t)=>{if(Xe(e)){if(e._tag==="Success")return e;let r=qo(e.cause);return be(r)?e:t(r.success)}return Es(e,t)}),Zf=e=>Pr(ja(e)),Qf=e=>e._tag==="Success";var SM=e=>e._tag==="Failure";var bM=e=>e._tag==="Failure"?X(e.cause):re(e);var FT=e=>e._tag==="Failure"&&cg(e.cause);var hn=ze(void 0),EM=d(2,(e,t)=>e._tag==="Success"?ze(t(e.value)):e),IM=d(2,(e,t)=>{if(e._tag==="Success")return e;let r=qo(e.cause);return be(r)?e:So(t(r.success))}),TM=d(2,(e,t)=>{if(e._tag==="Success")return ze(t.onSuccess(e.value));let r=qo(e.cause);return be(r)?e:So(t.onFailure(r.success))});var wM=d(2,(e,t)=>Qf(e)?t:e),vM=d(2,(e,t)=>Qf(e)?t.onSuccess(e.value):t.onFailure(e.cause));var NT=e=>{let t=[];for(let r of e)r._tag==="Failure"&&t.push(...r.cause.reasons);return t.length===0?hn:Pr(zi(t))};var AM=e=>e,CM=e=>oe(t=>q(Nx(t.context,e))),zV=e=>oe(t=>TT(Nx(t.context,e))),Yf=d(2,(e,t)=>oe(r=>{let n=r.context,o=t(n);return n===o||(r.setContext(o),Ka(r,()=>{r.setContext(n)})),e})),na=d(3,(e,t,r)=>Yf(e,n=>{let o=dn(n,t),s=r(o);return o===s?n:We(n,t,s)})),kM=(e,t,r)=>cu(oe(n=>{let o=dn(n.context,e),s=t(o);return n.setContext(We(n.context,e,s)),za(dn(n.context,qa),i=>{let a=Nx(n.context,e);if(fe(a))return pe;let c=a.value,u;if(r?.reset===void 0){if(c!==s)return pe;u=o}else u=r.reset(o,s,c);return n.setContext(We(n.context,e,u)),pe})})),UT=()=>WV,WV=oe(e=>q(e.context)),Ha=e=>oe(t=>e(t.context)),RM=d(2,(e,t)=>Yf(e,qe(t))),Eo=d(2,(e,t)=>Xe(e)?e:Yf(e,Kr(t))),Pn=function(){return arguments.length===1?d(2,(e,t)=>FP(e,arguments[0],t)):d(3,(e,t,r)=>FP(e,t,r)).apply(this,arguments)},FP=(e,t,r)=>Yf(e,We(t,r)),gg=d(3,(e,t,r)=>Y(r,n=>Pn(e,t,n))),OM=d(e=>ge(e[1]),(e,t,r)=>DT(e,t,(n,o)=>[n,o],r)),DT=d(e=>ge(e[1]),(e,t,r,n)=>n?.concurrent?_e(ol([e,t],{concurrency:2}),([o,s])=>r(o,s)):Y(e,o=>_e(t,s=>r(o,s)))),_M=d(e=>ge(e[0]),(e,t,r)=>XT(e,t,r?n=>Et(r(n)):()=>Et(new ms))),PM=d(2,(e,t)=>Y(t,r=>r?Jf(e):au)),LT=d(2,(e,t)=>Array.from({length:t},()=>e)),MM=d(e=>ge(e[0]),(e,t,r)=>ol(LT(e,t),r)),yg=d(e=>ge(e[0]),(e,t)=>mi({while:nr,body:qe(t?.disableYield?e:Y(e,r=>Gf)),step:Rr})),Mn=d(2,(e,t)=>new FM(e,t.length!==1?r=>t(r):t)),KV=yo({op:"OnFailure",[St]:hg}),FM=function(e,t){this[Se]=e,this[go]=t};FM.prototype=KV;var BT=d(3,(e,t,r)=>Mn(e,n=>t(n)?r(n):Ye(n))),oa=d(3,(e,t,r)=>Mn(e,n=>{let o=t(n);return be(o)?Ye(o.failure):r(o.success,n)})),Es=d(2,(e,t)=>oa(e,qo,r=>t(r))),NM=e=>Xf(e,{onFailure:t=>EI(t)?au:Et(t),onSuccess:vT}),UM=d(2,(e,t)=>oa(e,ag,t)),DM=d(2,(e,t)=>Mn(e,r=>bo(t(r),Ye(r)))),LM=d(3,(e,t,r)=>BT(e,t,n=>bo(r(n),Ye(n)))),Sg=d(3,(e,t,r)=>Mn(e,n=>{let o=t(n);return be(o)?Ye(n):bo(r(o.success,n),Ye(n))})),$T=d(2,(e,t)=>Sg(e,qo,r=>t(r))),BM=d(3,(e,t,r)=>{let n=Array.isArray(t)?o=>O(o,"_tag")&&t.includes(o._tag):Or(t);return $T(e,o=>n(o)?r(o):pe)}),$M=d(2,(e,t)=>Sg(e,ag,r=>t(r))),Sp=d(e=>ge(e[0]),(e,t,r,n)=>Mn(e,o=>{let s=qo(o);return be(s)?Ye(s.failure):t(s.success)?r(s.success):n?n(s.success):Ye(o)})),bg=d(e=>ge(e[0]),(e,t,r,n)=>Mn(e,o=>{let s=qo(o);if(be(s))return Ye(s.failure);let i=t(s.success);return be(i)?n?n(i.failure):Ye(o):r(i.success)})),Eg=d(e=>ge(e[0]),(e,t,r,n)=>{let o=Array.isArray(t)?s=>O(s,"_tag")&&t.includes(s._tag):Or(t);return Sp(e,o,r,n)}),jM=d(e=>ge(e[0]),(e,t,r)=>{let n;return bg(e,o=>(n??=Object.keys(t),O(o,"_tag")&&On(o._tag)&&n.includes(o._tag)?X(o):re(o)),o=>t[o._tag](o),r)}),HM=d(e=>ge(e[0]),(e,t,r,n,o)=>Sp(e,s=>Or(s,t)&&O(s,"reason")&&(o!==void 0||Or(s.reason,r)),s=>{let i=s.reason;return Or(i,r)?n(i,s):o?o(i,s):Et(s)})),qM=d(e=>ge(e[0]),(e,t,r,n)=>{let o;return Sp(e,s=>Or(s,t)&&O(s,"reason")&&O(s.reason,"_tag")&&On(s.reason._tag)&&(n!==void 0||(o??=Object.keys(r)).includes(s.reason._tag)),s=>{let i=s.reason;return o??=Object.keys(r),o.includes(i._tag)?r[i._tag](i,s):n?n(i,s):Et(s)})}),zM=d(2,(e,t)=>bg(e,r=>Or(r,t)&&O(r,"reason")?X(r.reason):re(r),Et)),jT=d(2,(e,t)=>Es(e,r=>mg(()=>t(r)))),HT=d(2,(e,t)=>Xf(e,{onFailure:r=>mg(()=>t.onFailure(r)),onSuccess:r=>ye(()=>t.onSuccess(r))})),Ig=e=>Es(e,ta),WM=d(2,(e,t)=>Es(e,r=>ye(()=>t(r)))),KM=e=>ce(()=>{let t=e[Symbol.iterator](),r=t.next();if(r.done)return ta(new Error("Received an empty collection of effects"));function n(o){let s=t.next();return s.done?o.value:Es(o.value,i=>n(s))}return n(r)}),qT=e=>Es(e,t=>Y(Gf,()=>qT(e))),VM=d(e=>ge(e[0]),(e,t)=>{if(!t?.log)return Xf(e,{onFailure:n=>pe,onSuccess:n=>pe});let r=Ts(t.log===!0?void 0:t.log);return di(e,{onFailure(n){let o=BP(n);return be(o)?Ye(o.failure):t.message===void 0?r(n):r(t.message,n)},onSuccess:n=>pe})}),Tg=d(e=>ge(e[0]),(e,t)=>{if(!t?.log)return di(e,{onFailure:n=>pe,onSuccess:n=>pe});let r=Ts(t.log===!0?void 0:t.log);return di(e,{onFailure:n=>t.message===void 0?r(n):r(t.message,n),onSuccess:n=>pe})}),GM=e=>wg(e,{onFailure:_,onSuccess:N}),$a=e=>bp(e,{onFailure:re,onSuccess:X}),di=d(2,(e,t)=>new JM(e,t.onSuccess.length!==1?r=>t.onSuccess(r):t.onSuccess,t.onFailure.length!==1?r=>t.onFailure(r):t.onFailure)),VV=yo({op:"OnSuccessAndFailure",[St]:hg}),JM=function(e,t,r){this[Se]=e,this[mr]=t,this[go]=r};JM.prototype=VV;var GV=function(e,t){let r=this.payload;return t.succeedWith(xg?r.onSuccess(e):Ma(()=>r.onSuccess(e)))},ZM=(e,t)=>{let r=yo({op:e,[St]:hg,[mr]:GV,[go]:t}),n=function(o,s){this[Se]=o,this.payload=s};return n.prototype=r,n},JV=ZM("Match",function(e,t){let r=e.reasons.find(hs);if(r===void 0)return Ye(e);let n=this.payload;return t.succeedWith(xg?n.onFailure(r.error):Ma(()=>n.onFailure(r.error)))}),ZV=ZM("MatchCause",function(e,t){let r=this.payload;return t.succeedWith(xg?r.onFailure(e):Ma(()=>r.onFailure(e)))}),zT=d(2,(e,t)=>new ZV(e,t)),Xf=d(2,(e,t)=>di(e,{onFailure:r=>{let n=r.reasons.find(hs);return n?t.onFailure(n.error):Ye(r)},onSuccess:t.onSuccess})),wg=d(2,(e,t)=>new JV(e,t)),bp=d(2,(e,t)=>{if(Xe(e)){if(e._tag==="Success")return ze(t.onSuccess(e.value));let r=qo(e.cause);return be(r)?e:ze(t.onFailure(r.success))}return wg(e,t)}),QM=d(2,(e,t)=>Xe(e)?e._tag==="Success"?ze(t.onSuccess(e.value)):ze(t.onFailure(e.cause)):zT(e,t)),Ep=e=>Xe(e)?ze(e):QV(e),QV=Uo({op:"Exit",[St](e){return e._stack.push(this),this[Se]},[mr](e,t,r){return t.succeedWith(r??ze(e))},[go](e,t,r){return t.succeedWith(r??Pr(e))}}),YM=bp({onFailure:()=>!0,onSuccess:()=>!1}),XM=bp({onFailure:()=>!1,onSuccess:()=>!0}),eF=d(2,(e,t)=>bo(sl(t),e)),WT=d(2,(e,t)=>Y(KT(e,t.duration),r=>fe(r)?t.orElse():q(r.value))),YV=e=>new ng(`Operation timed out after '${WI(e)}'`),tF=d(2,(e,t)=>{let r=$e(t);return WT(e,{duration:r,orElse:()=>Et(YV(r))})}),KT=d(2,(e,t)=>MT(Jf(e),Zr(sl(t),_()))),rF=e=>Is(t=>{let r=t.monotonicTimeNanosUnsafe();return _e(e,n=>[$o(t.monotonicTimeNanosUnsafe()-r),n])}),uT="~effect/Scope",fT="~effect/Scope/Closeable",qa=Ue("effect/Scope"),VT=(e,t)=>oe(r=>(rG(r),el(e,t)??pe)),el=(e,t)=>{let r=e.state;if(r._tag==="Closed"||(e.state={_tag:"Closed",exit:t},e.parent!==void 0&&tg(e.parent,e),r._tag==="Empty"))return;if(r.finalizer!==void 0)return eg(r.finalizer,t);let n=r.finalizers;return n.size===1?eg(n.values().next().value,t):XV(e,n,t)},eg=(e,t)=>{try{return e(t)}catch(r){return ln(r)}},nF=(e,t)=>Qf(e)?t:Mn(t,r=>Ye(Pf(e.cause,r))),XV=kT(function*(e,t,r){let n=[],o=[],s=Array.from(t.values()),i=ea();for(let a=s.length-1;a>=0;a--){let c=s[a];e.strategy==="sequential"?n.push(yield*Ep(eg(c,r))):o.push(uu(i,eg(c,r),!0,!0,"inherit"))}return o.length>0&&(n=yield*pg(o)),yield*NT(n)});var oF=(e,t)=>{let r=iF(t,e);return e.state._tag==="Closed"?(r.state=e.state,r):(Wa(e,r,n=>VT(r,n)),r)},za=(e,t)=>ce(()=>e.state._tag==="Closed"?t(e.state.exit):(Wa(e,{},t),pe)),sF=(e,t)=>za(e,qe(t)),Wa=(e,t,r)=>{if(e.state._tag==="Empty")e.state={_tag:"Open",finalizerKey:t,finalizer:r,finalizers:void 0};else if(e.state._tag==="Open"){let n=e.state;n.finalizer!==void 0&&(n.finalizers=new Map([[n.finalizerKey,n.finalizer]]),n.finalizerKey=void 0,n.finalizer=void 0),n.finalizers.set(t,r)}},tg=(e,t)=>{if(e.state._tag!=="Open")return;let r=e.state;r.finalizerKey===t?e.state=lT:r.finalizers!==void 0&&(r.finalizers.delete(t),r.finalizers.size===0&&(e.state=lT))},tl=e=>iF(e,void 0),iF=(e="sequential",t)=>({[fT]:fT,[uT]:uT,strategy:e,parent:t,state:lT}),lT={_tag:"Empty"};var Ip=qa,aF=Pn(qa),vg=e=>oe(t=>{let r=t.context,n=tl();return t.setContext(We(t.context,qa,n)),Ka(t,o=>(t.setContext(r),el(n,o))),e});var Ag=e=>ce(()=>{let t=tl();return To(e(t),r=>ce(()=>el(t,r)??pe))}),Cg=(e,t,r)=>Ha(n=>Gn(o=>Y(Ip,s=>pi(r?.interruptible?o(e):e,i=>za(s,a=>Eo(t(i,a),n)))))),rl=e=>Y(Ip,t=>Ha(r=>za(t,n=>Eo(e(n),r)))),cF=(function(){let e=yo({op:"OnExit",[St](r){return r._stack.push(this),this.effect},[Gc](r){r.interruptible&&this.interruptible!==!0&&(r._stack.push(wp),r.interruptible=!1)},[mr](r,n,o){o??=ze(r);let s;try{s=this.onExit(o)}catch(i){s=ln(i)}return s?Y(s,i=>o):o},[go](r,n,o){o??=Pr(r);let s;try{s=this.onExit(o)}catch(i){s=ln(i)}return s?Y(nF(o,s),i=>o):o}}),t=function(r,n,o){this.effect=r,this.onExit=n,this.interruptible=o};return t.prototype=e,t})(),Io=(e,t,r)=>new cF(e,t,r),Ka=(e,t)=>{e._stack.push(new cF(void 0,t,void 0))},To=d(2,Io),uF=d(2,(e,t)=>To(e,r=>t)),GT=d(3,(e,t,r)=>To(e,n=>t(n)?r(n):pe)),JT=d(3,(e,t,r)=>To(e,n=>{let o=t(n);return be(o)?pe:r(o.success,n)})),Tp=d(2,(e,t)=>JT(e,bM,t)),fF=d(3,(e,t,r)=>GT(e,n=>n._tag!=="Failure"?!1:t(n.cause),n=>r(n.cause))),ZT=d(3,(e,t,r)=>To(e,n=>{if(n._tag!=="Failure")return pe;let o=t(n.cause);return be(o)?pe:r(o.success,n.cause)})),lF=d(2,(e,t)=>ZT(bT,t)(e)),dF=(e,t,r)=>Gn(n=>Y(e,o=>Io(ce(()=>n(t(o))),s=>r(o,s),!0))),pF=e=>Cg(e,t=>O(t,Symbol.asyncDispose)?AT(()=>t[Symbol.asyncDispose]()):ye(()=>t[Symbol.dispose]())),QT=d(2,(e,t)=>ye(()=>mF(e,typeof t=="function"?r=>Wt($e(t(r))):qe(Wt($e(t)))))),eG=qe(1/0),mF=(e,t)=>{let r=0,n,o,s=(i,a)=>(a.awaiters++,Ka(i,()=>{if(!(--a.awaiters>0||o!==a))return o=void 0,xp(a.fiber)}),Xx(a.fiber));return[oe(i=>{if(o!==void 0)return i===o.fiber?Xx(o.fiber):s(i,o);if(n!==void 0&&(r===1/0||i.getRef(Vn).currentTimeMillisUnsafe()<r))return n;n=void 0;let a=i.getRef(Vn),c={fiber:new pp(i.context),awaiters:0};o=c;let u=s(i,c);return c.fiber.evaluate(Io(e,f=>{if(o!==c||(o=void 0,FT(f)))return;let p=t(f);r=p===1/0?1/0:a.currentTimeMillisUnsafe()+p,n=f})),c.fiber._exit??u}),ye(()=>{n=void 0})]},hF=d(2,(e,t)=>_e(QT(e,t),r=>r[0])),xF=e=>ye(()=>mF(e,eG)[0]),nl=oe(e=>Ye(ja(e.id))),cu=e=>oe(t=>(t.interruptible&&(t.interruptible=!1,t._stack.push(wp)),e)),gF=Uo({op:"SetInterruptible",[Gc](e){if(e.interruptible=this[Se],e._interruptedCause&&e.interruptible)return()=>Ye(e._interruptedCause)}}),wp=gF(!0),tG=gF(!1),yF=e=>{if(e.interruptible=!0,e._stack.push(tG),e._interruptedCause)return Ye(e._interruptedCause)},rG=e=>{let t=e;t.interruptible&&(t.interruptible=!1,t._stack.push(wp))};var kg=e=>oe(t=>t.interruptible?e:yF(t)??e),Gn=e=>oe(t=>t.interruptible?(t.interruptible=!1,t._stack.push(wp),e(kg)):e(F)),SF=e=>oe(t=>{if(t.interruptible)return e(F);let r=yF(t),n=e(cu);return r??n}),bF=_e(Cg(ye(()=>new AbortController),e=>ye(()=>e.abort())),e=>e.signal),ol=(e,t)=>ti(e)?t?.mode==="result"?Kn(e,$a,t):Kn(e,F,t):t?.discard?t.mode==="result"?Kn(Object.values(e),$a,t):Kn(Object.values(e),F,t):ce(()=>{let r={};return Zr(Kn(Object.entries(e),([n,o])=>_e(t?.mode==="result"?$a(o):o,s=>{B(r,n,s)}),{discard:!0,concurrency:t?.concurrency}),r)}),YT=d(e=>ti(e[0])&&!ge(e[0]),(e,t,r)=>_e(Kn(e,(n,o)=>$a(t(n,o)),r),n=>jI(n,F))),EF=d(3,(e,t,r)=>{let n=At(e);return n.length===0?ye(t):ce(()=>{let o=0,s=t();return _e(mi({while:()=>o<n.length,body:()=>r(s,n[o],o),step(i){s=i,o++}}),()=>s)})}),IF=d(e=>ti(e[0])&&!ge(e[0]),(e,t,r)=>Y(YT(e,t,{concurrency:r?.concurrency}),([n,o])=>Gr(o)?Et(o):r?.discard?pe:q(n))),TF=d(e=>ti(e[0])&&!ge(e[0]),(e,t)=>ce(()=>{let r=e[Symbol.iterator](),n=r.next();return n.done?q(_()):wF(r,0,t,n.value)})),wF=(e,t,r,n)=>Y(r(n,t),o=>{if(o)return q(N(n));let s=e.next();return s.done?q(_()):wF(e,t+1,r,s.value)}),vF=d(e=>ti(e[0])&&!ge(e[0]),(e,t)=>ce(()=>{let r=e[Symbol.iterator](),n=r.next();return n.done?q(_()):AF(r,0,t,n.value)})),AF=(e,t,r,n)=>Y(r(n,t),o=>{if(tt(o))return q(N(o.success));let s=e.next();return s.done?q(_()):AF(e,t+1,r,s.value)}),mi=Uo({op:"While",[mr](e,t){return this[Se].step(e),this[Se].while()?(t._stack.push(this),this[Se].body()):hn},[St](e){return this[Se].while()?(e._stack.push(this),this[Se].body()):hn}}),Kn=d(e=>typeof e[1]=="function",(e,t,r)=>ce(()=>{let n=vp(r?.concurrency);if(n===1)return nG(e,t,r);let o=At(e),s=o.length;if(s===0)return r?.discard?pe:q([]);let i=r?.discard?void 0:new Array(s),a=oG({f:t,out:i},o,{concurrency:n});return a?Zr(a,i):q(i)})),CF=e=>Y(e,t=>{let r=t[Symbol.iterator]().next();return r.done?Et(new ms):q(r.value)}),nG=(e,t,r)=>ce(()=>{let n=r?.discard?void 0:[],o=e[Symbol.iterator](),s=o.next(),i=0;return Zr(mi({while:()=>!s.done,body:()=>t(s.value,i++),step:a=>{n&&n.push(a),s=o.next()}}),n)}),vp=e=>e==="unbounded"?Number.POSITIVE_INFINITY:Math.max(1,e??1),Rg=()=>e=>{let t=e.onItem,r=e.step,n=(s,i,a,c,u)=>Y(Ep(u),f=>r(s,i[a],f,a)??o(s,i,a+1,c)??pe),o=(s,i,a=0,c=i.length)=>{for(;a<c;a++){let u=i[a],f=t(s,u,a);if(!Xe(f))return n(s,i,a,c,f);let p=r(s,u,f,a);if(p)return p._tag==="Failure"?p:void 0}};return o},kF=e=>{let t=e.onItem,r=e.step;return(n,o,s)=>{let i=0,a=s.end??o.length,c=s.concurrency,u=!1,f,p,m,h,x,g=E=>{let b=ln(E);return h=b,u=!0,p&&p.size>0?Y(cu(Wf(Array.from(p))),()=>h??b):b},y=()=>{let E=!1;for(;!h&&i<a;i++){let b=o[i],v=x??t(n,b,i);if(Xe(v)){if(h=r(n,b,v,i),h)break}else if(f){x=void 0;let T=uu(f,v,!0,!0,"inherit");if(T._exit){if(h=r(n,b,T._exit,i),h)break;continue}p.add(T);let S=i;if(T.addObserver(w=>{p.delete(T);try{if(h){if(w._tag==="Failure"){let k=w.cause.reasons.filter(A=>A._tag!=="Interrupt");if(k.length>0){let A=zi(k);h=Pr(h._tag==="Failure"?Pf(h.cause,A):A)}}}else{let k=r(n,b,w,S);k&&(h=k,y())}if(E){let k=y();k&&m(k)}else u&&p.size===0&&m(h??pe)}catch(k){m(g(k))}}),p.size<c)continue;E=!0,i++;return}else return $t(T=>{f=ea(),p=new Set,x=v,m=T;let S;try{S=y()}catch(w){return T(g(w))}return S?T(S):ce(()=>(h??=hn,Y(p?Wf(p):pe,()=>h?._tag==="Failure"?h:pe)))})}if(u=!0,h){if(p&&p.size>0){let b=dg(f);p.forEach(v=>v.interruptUnsafe(f.id,b));return}if(m||h._tag==="Failure")return h}else if(m)if(p)p.size===0&&m(pe);else return hn};return y()}},Og=()=>e=>kF(e),oG=kF({onItem(e,t,r){return e.f(t,r)},step(e,t,r,n){if(r._tag==="Failure")return r;e.out&&(e.out[n]=r.value)}}),XT=d(3,(e,t,r)=>Y(e,n=>t(n)?q(n):r(n))),e0=d(3,(e,t,r)=>Y(e,n=>{let o=t(n);return be(o)?r(o.failure):q(o.success)})),RF=d(e=>ge(e[0]),(e,t,r)=>e0(e,t,r?n=>Et(r(n)):()=>Et(new ms))),OF=d(e=>ti(e[0])&&!ge(e[0]),(e,t,r)=>ce(()=>{let n=[];return Zr(Kn(e,(o,s)=>{let i=t(o,s);return typeof i=="boolean"?(i&&n.push(o),pe):_e(i,a=>{a&&n.push(o)})},{discard:!0,concurrency:r?.concurrency}),n)})),_F=d(e=>ti(e[0])&&!ge(e[0]),(e,t)=>ce(()=>{let r=[];for(let n of e){let o=t(n);tt(o)&&r.push(o.success)}return q(r)})),PF=d(e=>ti(e[0])&&!ge(e[0]),(e,t,r)=>ce(()=>{let n=[];return Zr(Kn(e,o=>_e(t(o),s=>{tt(s)&&n.push(s.success)}),{discard:!0,concurrency:r?.concurrency}),n)})),MF=q({}),FF=Cx(_e),NF=kx(_e,Y),UF=Ax(_e);var DF=d(e=>ge(e[0]),(e,t)=>oe(r=>(bG(),q(uu(r,e,t?.startImmediately,!1,t?.uninterruptible??!1))))),uu=(e,t,r=!1,n=!1,o=!1)=>{let s=e,i=o==="inherit"?s.interruptible:!o,a=new pp(s.context,i);return n||(s.children().add(a),a._parent=s),r?a.evaluate(t):(a._asyncContext=VP(),s.currentDispatcher.scheduleTask(()=>a.evaluate(t),0)),a},LF=d(e=>ge(e[0]),(e,t)=>oe(r=>q(uu(r,e,t?.startImmediately,!0,t?.uninterruptible)))),BF=e=>oe(t=>{let r=t._children&&new Set(t._children),n=t.interruptible;return Io(e,o=>{let s=t._children;if(s===void 0||s.size===0)return pe;r&&(s=J_(s,a=>!r.has(a)));let i=yp(pg(s));return n?kg(i):i})}),t0=d(e=>ge(e[0]),(e,t,r)=>oe(n=>{let o=uu(n,e,r?.startImmediately,!0,r?.uninterruptible);if(!o._exit)if(t.state._tag!=="Closed"){let s={};Wa(t,s,()=>tM(a=>a===o.id?pe:xp(o))),o.addObserver(()=>tg(t,s))}else o.interruptUnsafe(n.id,dg(n));return q(o)})),$F=d(e=>ge(e[0]),(e,t)=>Y(Ip,r=>t0(e,r,t))),sa=e=>(t,r)=>{let n=new pp(r?.scheduler?We(e,Ba,r.scheduler):e,r?.uninterruptible!==!0);if(n.evaluate(t),n._exit)return n;if(r?.signal)if(r.signal.aborted)n.interruptUnsafe();else{let o=()=>n.interruptUnsafe();r.signal.addEventListener("abort",o,{once:!0}),n.addObserver(()=>r.signal.removeEventListener("abort",o))}return r?.onFiberStart&&r.onFiberStart(n),n},jF=d(2,(e,t)=>e._exit?e:t.state._tag==="Closed"?(e.interruptUnsafe(e.id),e):(tg(t,e),Wa(t,e,()=>xp(e)),e.addObserver(()=>tg(t,e)),e)),HF=sa(pt()),r0=e=>{let t=sa(e);return(r,n)=>{let o=t(r,n);return n?.onExit&&o.addObserver(n.onExit),s=>o.interruptUnsafe(s)}},qF=r0(pt()),_g=e=>{let t=sa(e);return(r,n)=>{let o=t(r,n);return new Promise(s=>{o.addObserver(i=>s(i))})}},zF=_g(pt()),n0=e=>{let t=_g(e);return(r,n)=>t(r,n).then(o=>{if(o._tag==="Failure")throw fg(o.cause);return o.value})},WF=n0(pt()),Pg=e=>{let t=sa(e);return r=>{if(Xe(r))return r;let n=new fi("sync"),o=t(r,{scheduler:n});return o._dispatcher?.flush(),o._exit??ln(new ig(o))}},KF=Pg(pt()),o0=e=>{let t=Pg(e);return r=>{let n=t(r);if(n._tag==="Failure")throw fg(n.cause);return n.value}},VF=o0(pt()),NP=q(!0),UP=q(!1),dT=class{waiters=[];scheduled=void 0;_isOpen;constructor(t){this._isOpen=t}scheduleUnsafe(t){if(this.waiters.length===0)return NP;if(this.scheduled===void 0)this.scheduled=this.waiters,t.currentDispatcher.scheduleTask(this.flushScheduled,0);else for(let r=0;r<this.waiters.length;r++)this.scheduled.push(this.waiters[r]);return this.waiters=[],NP}flushScheduled=()=>{if(this.scheduled===void 0)return;let t=this.scheduled;this.scheduled=void 0;for(let r=0;r<t.length;r++)t[r](hn)};flushWaiters(){let t=this.waiters;this.waiters=[],this.flushScheduled();for(let r=0;r<t.length;r++)t[r](hn)}open=oe(t=>this._isOpen?UP:(this._isOpen=!0,this.scheduleUnsafe(t)));release=oe(t=>this._isOpen?UP:this.scheduleUnsafe(t));openUnsafe(){return this._isOpen?!1:(this._isOpen=!0,this.flushWaiters(),!0)}await=$t(t=>this._isOpen?t(pe):(this.waiters.push(t),ye(()=>{let r=this.waiters.indexOf(t);r!==-1?this.waiters.splice(r,1):this.scheduled!==void 0&&(r=this.scheduled.indexOf(t),r!==-1&&this.scheduled.splice(r,1))})));closeUnsafe(){return this._isOpen?(this._isOpen=!1,!0):!1}close=ye(()=>this.closeUnsafe());whenOpen=t=>Y(this.await,()=>t);isOpen(){return this._isOpen}},s0=e=>new dT(e??!1),GF=e=>ye(()=>s0(e)),JF=oe(e=>q(e.getRef(eT))),ZF=d(2,(e,t)=>Pn(e,eT,t)),QF=Pn(Zx),YF=Pn(ou),rg=BigInt(0),sG={_tag:"Span",spanId:"noop",traceId:"noop",sampled:!1,status:{_tag:"Ended",startTime:rg,endTime:rg,exit:hn},attributes:new Map,links:[],kind:"internal",attribute(){},event(){},end(){},addLinks(){}},iG=e=>Object.assign(Object.create(sG),e),XF=e=>e?Re(e.annotations,qf)?e._tag==="Span"?XF(_n(e.parent)):_():N(e):_(),i0=(e,t,r)=>{let n=!e.cache.tracerEnabled||r?.annotations&&Re(r.annotations,qf),o=r?.parent!==void 0?N(r.parent):r?.root?_():XF(e.cache.span),s;if(n)s=iG({name:t,parent:o,annotations:We(r?.annotations??pt(),qf,!0)});else{let i=e.cache.tracer??tT,a=e.getRef(Vn),c=e.getRef(ou),u=e.getRef(lp),f=e.getRef(dp),p=r?.level??e.getRef(vP),m=r?.links!==void 0?[...f,...r.links]:f.length===0?[]:f.slice();s=i.span({name:t,parent:o,annotations:r?.annotations??pt(),links:m,startTime:c?a.currentTimeNanosUnsafe():rg,kind:r?.kind??"internal",root:r?.root??!1,sampled:r?.sampled??(de(o)&&o.value.sampled===!1?!1:!dN(e.getRef(AP),p))});for(let h in u)s.attribute(h,u[h]);if(r?.attributes!==void 0)for(let h in r.attributes)s.attribute(h,r.attributes[h])}return s},eN=(e,t)=>oe(r=>q(i0(r,e,t))),bs=(e,t)=>cu(oe(r=>{let n=dn(r.context,qa),o=i0(r,e,t??{}),s=r.getRef(Vn),i=r.getRef(ou);return Zr(za(n,a=>Mg(o,a,s,i)),o)})),tN=function(){let e=typeof arguments[0]!="string",t=e?arguments[1]:arguments[0],r=Ho(e?arguments[2]:arguments[1]);if(e){let n=arguments[0];return Y(bs(t,r),o=>Kf(n,o,r))}return n=>Y(bs(t,r),o=>Kf(n,o,r))},aG=(e,t)=>(t=typeof t=="function"?t:po,na(zf,r=>({name:e,stack:t,parent:r}))),rN=lp,nN=dp,oN=d(e=>ge(e[0]),(e,t,r={})=>{let o=(Array.isArray(t)?t:[t]).map(s=>({span:s,attributes:r}));return na(e,dp,s=>[...s,...o])}),Mg=(e,t,r,n)=>ye(()=>{e.status._tag!=="Ended"&&e.end(n?r.currentTimeNanosUnsafe():rg,t)}),mp=(e,...t)=>{let r=t.length===1?void 0:t[0],n=t[t.length-1];return oe(o=>{let s=i0(o,e,r),i=o.getRef(Vn),a=o.getRef(ou);return Ka(o,c=>Mg(s,c,i,a)),n(s)})},pT=Pn(li),Kf=function(){let e=ge(arguments[0]),t=e?arguments[1]:arguments[0],r=e?arguments[2]:arguments[1],n=F;return t._tag==="Span"&&(r=Ho(r),n=aG(t.name,r?.captureStackTrace)),e?pT(n(arguments[0]),t):o=>pT(n(o),t)},sN=function(){let e=typeof arguments[0]!="string",t=e?arguments[1]:arguments[0],r=Ho(arguments[2]);if(e){let s=arguments[0];return mp(t,arguments[2],i=>Kf(s,i,r))}let n=typeof arguments[1]=="function"?arguments[1]:void 0,o=n?void 0:arguments[1];return(s,...i)=>mp(t,n?n(...i):o,a=>Kf(s,a,r))},iN=d(e=>ge(e[0]),(e,...t)=>na(e,lp,r=>{let n=t.length===1?{...r,...t[0]}:{...r};return t.length===1||B(n,t[0],t[1]),n})),aN=(...e)=>oe(t=>{let r=t.currentSpanLocal;if(r)if(e.length===1)for(let[n,o]of Object.entries(e[0]))r.attribute(n,o);else r.attribute(e[0],e[1]);return pe}),cN=oe(e=>{let t=e.currentSpanLocal;return t?q(t):Et(new ms)}),uN=zV(li),Vn=Ae("effect/Clock",{defaultValue:()=>new mT}),sT=2**31-1,mT=class{currentTimeMillisUnsafe(){return Date.now()}currentTimeMillis=ye(()=>this.currentTimeMillisUnsafe());currentTimeNanosUnsafe(){return cG()}currentTimeNanos=ye(()=>this.currentTimeNanosUnsafe());monotonicTimeNanosUnsafe(){return lN()}monotonicTimeNanos=ye(()=>this.monotonicTimeNanosUnsafe());sleep(t){return this.sleepMillis(Wt(t))}sleepMillis(t){return t<=0?Gf:Number.isFinite(t)?$t(r=>{let n=t>sT?this.sleepMillis(t-sT):pe,o=setTimeout(()=>r(n),Math.min(t,sT));return ye(()=>clearTimeout(o))}):gp}},fN=BigInt(1e6),lN=(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 r=BigInt(Date.now())*fN;return r>t&&(t=r),t}})(),cG=(function(){let e=BigInt(1e9),t;return()=>{let r=lN(),n=BigInt(Date.now())*fN;if(t===void 0)t=n-r;else{let o=t+r;(n>o?n-o:o-n)>e&&(t=n-r)}return t+r}})(),Is=e=>oe(t=>e(t.getRef(Vn))),sl=e=>Is(t=>t.sleep($e(e))),a0=Is(e=>e.currentTimeMillis);var hT="~effect/Cause/TimeoutError";var ng=class extends Wi("TimeoutError"){[hT]=hT;constructor(t){super({message:t})}},xT="~effect/Cause/IllegalArgumentError";var og=class extends Wi("IllegalArgumentError"){[xT]=xT;constructor(t){super({message:t})}},gT="~effect/Cause/ExceededCapacityError";var sg=class extends Wi("ExceededCapacityError"){[gT]=gT;constructor(t){super({message:t})}},yT="~effect/Cause/AsyncFiberError";var ig=class extends Wi("AsyncFiberError"){[yT]=yT;constructor(t){super({message:"An asynchronous Effect was executed with Effect.runSync",fiber:t})}},ST="~effect/Cause/UnknownError";var hp=class extends Wi("UnknownError"){[ST]=ST;constructor(t,r){super({message:r,cause:t})}},uG=Ae("effect/Console",{defaultValue:()=>globalThis.console}),fG=e=>{switch(e){case"All":return Number.MIN_SAFE_INTEGER;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 Number.MAX_SAFE_INTEGER}},lG=AI(Ki,fG),dN=Xc(lG),c0=Ae("effect/Logger/CurrentLoggers",{defaultValue:()=>new Set([yG,SG])}),dG=Ae("effect/Logger/LogToStderr",{defaultValue:_a}),pN=function(){let e=typeof arguments[0]=="string"?[[arguments[0],arguments[1]]]:Object.entries(arguments[0]);return cu(oe(t=>{let r=t.getRef(Xi),n={...r};for(let o=0;o<e.length;o++){let[s,i]=e[o];B(n,s,i)}return t.setContext(We(t.context,Xi,n)),za(dn(t.context,qa),o=>{let s=t.getRef(Xi),i={...s};for(let a=0;a<e.length;a++){let[c,u]=e[a];s[c]!==u&&!Object.is(s[c],u)||(Object.hasOwn(r,c)?B(i,c,r[c]):delete i[c])}return t.setContext(We(t.context,Xi,i)),pe})}))},pG="~effect/Logger",mG={[pG]:{_Message:F,_Output:F},pipe(){return V(this,arguments)}},mN=e=>{let t=Object.create(mG);return t.log=e,t},hG=e=>e.replace(/[\s="]/g,"_"),xG=(e,t)=>`${hG(e[0])}=${t-e[1]}ms`;var Ts=e=>(...t)=>{let r;for(let n=0,o=t.length;n<o;n++){let s=t[n];_f(s)&&(r?t.splice(n,1):t=t.slice(0,n).concat(t.slice(n+1)),r=r?zi(r.reasons.concat(s.reasons)):s,n--)}return r===void 0&&(r=yI),oe(n=>{let o=e??n.cache.logLevel;if(dN(n.cache.minimumLogLevel,o))return pe;let s=n.getRef(Vn),i=n.getRef(c0);if(i.size>0){let a=new Date(s.currentTimeMillisUnsafe());for(let c of i)c.log({cause:r,fiber:n,date:a,logLevel:o,message:t})}return pe})};var su={bold:"1",red:"31",green:"32",yellow:"33",blue:"34",cyan:"36",white:"37",gray:"90",black:"30",bgBrightRed:"101"},zle={None:[],All:[],Trace:[su.gray],Debug:[su.blue],Info:[su.green],Warn:[su.yellow],Error:[su.red],Fatal:[su.bgBrightRed,su.black]};var gG=e=>`${e.getHours().toString().padStart(2,"0")}:${e.getMinutes().toString().padStart(2,"0")}:${e.getSeconds().toString().padStart(2,"0")}.${e.getMilliseconds().toString().padStart(3,"0")}`;var yG=mN(({cause:e,date:t,fiber:r,logLevel:n,message:o})=>{let s=Array.isArray(o)?o.slice():[o];e.reasons.length>0&&s.push(lg(e));let i=t.getTime(),a=r.getRef(Qx),c="";for(let m of a)c+=` ${xG(m,i)}`;let u=r.getRef(Xi);Object.keys(u).length>0&&s.push(u);let f=r.getRef(uG);(r.getRef(dG)?f.error:f.log)(`[${gG(t)}] ${n.toUpperCase()} (#${r.id})${c}:`,...s)}),SG=mN(({cause:e,fiber:t,logLevel:r,message:n})=>{let o=t.getRef(Vn),s=t.getRef(Xi),i=t.cache.span;if(i===void 0||i._tag==="ExternalSpan")return;let a={};for(let[c,u]of Object.entries(s))B(a,c,u);a["effect.fiberId"]=t.id,a["effect.logLevel"]=r.toUpperCase(),e.reasons.length>0&&(a["effect.cause"]=lg(e)),i.event(t_(Array.isArray(n)&&n.length===1?n[0]:n),o.currentTimeNanosUnsafe(),a)});function bG(){cT.interruptChildren??=LV}var Fg=q(void 0);var hN=d(e=>ge(e[0]),(e,t)=>Tp(e,r=>oe(n=>(EG(n,r,t?.defectsOnly),pe)))),EG=(e,t,r)=>{let n=e.getRef(kP);if(n.size===0||r&&!$P(t))return;let o={cause:t,fiber:e,timestamp:e.getRef(Vn).currentTimeNanosUnsafe()};n.forEach(s=>s.report(o))};var il=_f,al=o_,Ng=hs;var fu=zi;var xN=Mf,cl=SI,gN=ja,Ap=e=>new Jc(e),Cp=e=>new Vd(e),kp=DP,u0=ug,Va=HP;var lu=fg,yN=LP;var ul=qo;var Rp=ag,fl=cg;var SN=jP;var bN=lg;var ll=ms,Op=a_;var EN=Qc,se=u_;var Ug=og;var IN=sg;var ne={};ps(ne,{Do:()=>zJ,Transaction:()=>gl,TypeId:()=>UJ,abortSignal:()=>q8,acquireDisposable:()=>N8,acquireRelease:()=>Ti,acquireUseRelease:()=>WU,addFinalizer:()=>KU,all:()=>DJ,andThen:()=>Vt,annotateCurrentSpan:()=>Y8,annotateLogs:()=>py,annotateLogsScoped:()=>IZ,annotateSpans:()=>Q8,as:()=>Pt,asSome:()=>iy,asVoid:()=>vo,awaitAllChildren:()=>cZ,bind:()=>VJ,bindTo:()=>WJ,cached:()=>ly,cachedInvalidateWithTTL:()=>j8,cachedWithTTL:()=>$8,callback:()=>Nn,catch:()=>yu,catchCause:()=>rt,catchCauseFilter:()=>BU,catchCauseIf:()=>K0,catchDefect:()=>W0,catchEager:()=>my,catchFilter:()=>a8,catchIf:()=>i8,catchNoSuchElement:()=>c8,catchReason:()=>n8,catchReasons:()=>o8,catchTag:()=>DU,catchTags:()=>LU,clockWith:()=>Eu,context:()=>Nr,contextWith:()=>yn,currentParentSpan:()=>eZ,currentSpan:()=>X8,delay:()=>ca,die:()=>gn,effectify:()=>MZ,ensuring:()=>wi,eventually:()=>p8,exit:()=>eo,fail:()=>D,failCause:()=>je,failCauseSync:()=>aa,failSync:()=>sy,fiber:()=>uZ,fiberId:()=>fZ,filter:()=>Z0,filterMap:()=>T8,filterMapEffect:()=>Q0,filterMapOrElse:()=>w8,filterMapOrFail:()=>v8,filterOrElse:()=>HU,filterOrFail:()=>qU,findFirst:()=>jJ,findFirstFilter:()=>HJ,firstSuccessOf:()=>y8,flatMap:()=>C,flatMapEager:()=>ur,flatten:()=>q0,flip:()=>t8,fn:()=>mZ,fnUntraced:()=>me,fnUntracedEager:()=>uw,forEach:()=>Ko,forever:()=>Mt,forkChild:()=>El,forkDetach:()=>Il,forkIn:()=>gt,forkScoped:()=>Rs,fromNullishOr:()=>YJ,fromOption:()=>ZJ,fromResult:()=>H0,gen:()=>xt,head:()=>qJ,ignore:()=>cy,ignoreCause:()=>uy,interrupt:()=>Dn,interruptible:()=>vi,interruptibleMask:()=>H8,isEffect:()=>Yr,isFailure:()=>O8,isSuccess:()=>_8,let:()=>KJ,linkSpans:()=>nZ,log:()=>hZ,logDebug:()=>SZ,logError:()=>Xp,logFatal:()=>xZ,logInfo:()=>yZ,logTrace:()=>bZ,logWarning:()=>gZ,logWithLevel:()=>Tl,makeSpan:()=>nw,makeSpanScoped:()=>ow,map:()=>K,mapBoth:()=>u8,mapBothEager:()=>cr,mapEager:()=>Iu,mapError:()=>yl,mapErrorEager:()=>Tu,match:()=>Y0,matchCause:()=>C8,matchCauseEager:()=>k8,matchCauseEffect:()=>Un,matchCauseEffectEager:()=>R8,matchEager:()=>A8,matchEffect:()=>zU,never:()=>Xn,onError:()=>to,onErrorFilter:()=>D8,onErrorIf:()=>U8,onExit:()=>Xr,onExitFilter:()=>B8,onExitIf:()=>L8,onExitPrimitive:()=>Zp,onInterrupt:()=>bu,option:()=>e8,orDie:()=>Ii,orElseSucceed:()=>g8,partition:()=>LJ,promise:()=>Wp,provide:()=>X0,provideContext:()=>Ur,provideService:()=>Jo,provideServiceEffect:()=>F8,race:()=>I8,raceAll:()=>J0,raceAllFirst:()=>E8,raceFirst:()=>Xa,reduce:()=>BJ,repeat:()=>VU,repeatOrElse:()=>z8,replicate:()=>W8,replicateEffect:()=>rw,request:()=>iZ,requestUnsafe:()=>aZ,result:()=>XJ,retry:()=>ay,retryOrElse:()=>V0,runCallback:()=>lZ,runCallbackWith:()=>sw,runFork:()=>Yp,runForkWith:()=>Sr,runPromise:()=>iw,runPromiseExit:()=>dy,runPromiseExitWith:()=>dZ,runPromiseWith:()=>aw,runSync:()=>Ci,runSyncExit:()=>ki,runSyncExitWith:()=>pZ,runSyncWith:()=>cw,sandbox:()=>m8,satisfiesErrorType:()=>NZ,satisfiesServicesType:()=>UZ,satisfiesSuccessType:()=>FZ,schedule:()=>K8,scheduleFrom:()=>GU,scope:()=>Ao,scoped:()=>tc,scopedWith:()=>Sl,service:()=>ew,serviceOption:()=>Su,setContext:()=>P8,sleep:()=>ua,spanAnnotations:()=>tZ,spanLinks:()=>rZ,succeed:()=>I,succeedNone:()=>ia,succeedSome:()=>j0,suspend:()=>L,sync:()=>W,tap:()=>_t,tapCause:()=>Jp,tapCauseFilter:()=>d8,tapCauseIf:()=>l8,tapDefect:()=>$U,tapError:()=>Gp,tapErrorTag:()=>f8,timed:()=>b8,timeout:()=>G0,timeoutOption:()=>S8,timeoutOrElse:()=>jU,tracer:()=>V8,track:()=>wZ,trackDefects:()=>CZ,trackDuration:()=>kZ,trackErrors:()=>AZ,trackSuccesses:()=>vZ,transposeOption:()=>QJ,try:()=>Go,tryPromise:()=>Vo,tx:()=>RZ,txRetry:()=>PZ,undefined:()=>Kp,uninterruptible:()=>Ai,uninterruptibleMask:()=>en,unwrapReason:()=>s8,updateContext:()=>ec,updateService:()=>tw,updateServiceScoped:()=>M8,useSpan:()=>Qp,validate:()=>$J,void:()=>P,when:()=>fy,whileLoop:()=>xn,withErrorReporting:()=>x8,withExecutionPlan:()=>h8,withFiber:()=>ar,withFiberSucceed:()=>JJ,withLogSpan:()=>TZ,withLogger:()=>EZ,withParentSpan:()=>bl,withSpan:()=>oZ,withSpanScoped:()=>sZ,withTracer:()=>G8,withTracerEnabled:()=>J8,withTracerTiming:()=>Z8,yieldNow:()=>Vp,yieldNowWith:()=>GJ,zip:()=>z0,zipWith:()=>r8});var ws=Gd,Mr=ze,ir=Pr,Jn=So,Dg=ln,Lg=Zf,Kt=hn;var ft=Qf,vs=SM;var TN=FT;var wN=vM;var vN=NT;var Fn={};ps(Fn,{CurrentMemoMap:()=>pu,build:()=>BN,buildWithMemoMap:()=>gi,buildWithScope:()=>_p,catch:()=>LG,catchCause:()=>$G,catchTag:()=>BG,effect:()=>Qn,effectContext:()=>Za,effectDiscard:()=>PG,empty:()=>_G,flatMap:()=>HN,forkMemoMap:()=>OG,forkMemoMapUnsafe:()=>m0,fresh:()=>jG,fromBuild:()=>Ga,fromBuildMemo:()=>Wg,isLayer:()=>zg,launch:()=>HG,makeMemoMap:()=>RG,makeMemoMapUnsafe:()=>xi,merge:()=>FG,mergeAll:()=>Kg,mock:()=>qG,orDie:()=>Vg,parentSpan:()=>zN,provide:()=>Cs,provideMerge:()=>Pp,satisfiesErrorType:()=>KG,satisfiesServicesType:()=>VG,satisfiesSuccessType:()=>WG,span:()=>GG,succeed:()=>Ja,succeedContext:()=>mu,suspend:()=>MG,sync:()=>h0,syncContext:()=>l0,tap:()=>NG,tapCause:()=>DG,tapError:()=>UG,unwrap:()=>d0,updateService:()=>qN,withParentSpan:()=>p0,withSpan:()=>JG});var IG="~effect/Deferred";var TG={[IG]:{_A:F,_E:F},pipe(){return V(this,arguments)}},AN=function(){this.resumes=void 0,this.effect=void 0};AN.prototype=TG;var du=()=>new AN;var Bg=e=>$t(t=>e.effect?t(e.effect):(e.resumes??=[],e.resumes.push(t),ye(()=>{let r=e.resumes;if(r===void 0)return;let n=r.indexOf(t);n>=0&&r.splice(n,1)})));var wG=d(2,(e,t)=>ye(()=>hi(e,t))),vG=wG;var AG=d(2,(e,t)=>vG(e,Pr(t)));var f0=d(2,(e,t)=>AG(e,ja(t)));var hi=(e,t)=>{if(e.effect)return!1;if(e.effect=t,e.resumes){let r=e.resumes;e.resumes=void 0;for(let n=0;n<r.length;n++)r[n](t)}return!0};var CN=Xi;var kN=Qx,RN=zf;var jg=ou,ON=RP;var it=qa;var Zn=tl,zo=aF,Wo=za,It=sF;var yr=oF,Ve=VT;var LN="~effect/Layer",PN="~effect/Layer/MemoMap",CG=(e,t)=>{let r={observers:0,deferred:du(),scope:Zn(),finalizer:n=>ce(()=>--r.observers>0?pe:(e.map.delete(t),Ve(r.scope,n)))};return r},MN=(e,t)=>t.state._tag==="Closed"?!1:(e.observers++,Wa(t,{},e.finalizer),!0),zg=e=>O(e,LN),kG={[LN]:{_ROut:F,_E:F,_RIn:F},pipe(){return V(this,arguments)}},hu=e=>{let t=Object.create(kG);return t.build=e,t},Ga=e=>hu((t,r)=>{let n=yr(r);return To(e(t,n),o=>o._tag==="Failure"?Ve(n,o):pe)}),Wg=e=>{let t=Ga((r,n)=>r.getOrElseMemoize(t,n,e));return t},qg=class{get[PN](){return PN}parent;constructor(t){this.parent=t}map=new Map;get(t,r){let n=this.map.get(t);return n?(MN(n,r),n.deferred.effect??Bg(n.deferred)):this.parent?.get(t,r)}getOrElseMemoize(t,r,n){return ce(()=>{let o;return Io(ce(()=>{let s=this.get(t,r);if(s)return s;let i=CG(this,t);return MN(i,r)?(o=i.deferred,this.map.set(t,i),n(this,i.scope)):n(this,r)}),s=>{o&&hi(o,s)})})}},xi=()=>new qg,m0=e=>new qg(e),RG=ye(xi),OG=e=>ye(()=>m0(e)),pu=class e extends Ue()("effect/Layer/CurrentMemoMap"){static forkOrCreate(t){let r=Vi(t,e);return r?m0(r):xi()}},gi=d(3,(e,t,r)=>Pn(_e(ce(()=>e.build(t,r)),We(pu,t)),pu,t)),BN=e=>oe(t=>gi(e,pu.forkOrCreate(t.context),dn(t.context,it))),_p=d(2,(e,t)=>oe(r=>gi(e,pu.forkOrCreate(r.context),t))),Ja=function(){return arguments.length===1?e=>mu(ys(arguments[0],e)):mu(ys(arguments[0],arguments[1]))},mu=e=>hu(qe(q(e))),_G=mu(pt()),h0=function(){return arguments.length===1?e=>l0(()=>ys(arguments[0],e())):l0(()=>ys(arguments[0],arguments[1]()))},l0=e=>Wg(qe(ye(e))),Qn=function(){return arguments.length===1?e=>FN(arguments[0],e):FN(arguments[0],arguments[1])},FN=(e,t)=>Za(_e(t,r=>ys(e,r))),Za=e=>Wg((t,r)=>zo(e,r)),PG=e=>Za(Zr(e,pt())),MG=e=>Wg((t,r)=>ce(()=>e().build(t,r))),NN=Ue("effect/Layer/unwrap"),d0=e=>HN(Qn(NN)(e),Re(NN)),$N=(e,t,r)=>{let n=yr(r,"parallel");return Kn(e,o=>o.build(t,yr(n,"sequential")),{concurrency:e.length}).pipe(_e(o=>H_(...o)))},Kg=(...e)=>Ga((t,r)=>$N(e,t,r)),FG=d(2,(e,t)=>Kg(e,...Array.isArray(t)?t:[t])),jN=(e,t,r)=>Ga((n,o)=>Y(Array.isArray(t)?$N(t,n,o):t.build(n,o),s=>e.build(n,o).pipe(Eo(s),_e(i=>r(i,s))))),Cs=d(2,(e,t)=>jN(e,t,F)),Pp=d(2,(e,t)=>jN(e,t,(r,n)=>Kr(n,r))),HN=d(2,(e,t)=>Ga((r,n)=>Y(e.build(r,n),o=>t(o).build(r,n)))),NG=d(2,(e,t)=>Ga((r,n)=>Y(e.build(r,n),o=>zo(Zr(t(o),o),n)))),UG=d(2,(e,t)=>Ga((r,n)=>Es(e.build(r,n),o=>zo(bo(t(o),Et(o)),n)))),DG=d(2,(e,t)=>Ga((r,n)=>Mn(e.build(r,n),o=>zo(bo(t(o),Ye(o)),n)))),Vg=e=>hu((t,r)=>Ig(e.build(t,r))),LG=d(2,(e,t)=>hu((r,n)=>Es(e.build(r,n),o=>t(o).build(r,n))));var BG=d(3,(e,t,r)=>hu((n,o)=>Eg(e.build(n,o),t,s=>r(s).build(n,o)))),$G=d(2,(e,t)=>hu((r,n)=>Mn(e.build(r,n),o=>t(o).build(r,n)))),qN=d(3,(e,t,r)=>Cs(e,Qn(t,_e(t,r)))),jG=e=>hu((t,r)=>e.build(xi(),r)),HG=e=>vg(bo(BN(e),gp)),qG=function(){return arguments.length===1?e=>UN(arguments[0],e):UN(arguments[0],arguments[1])},UN=(e,t)=>Ja(e)(new Proxy({...t},{get(r,n,o){if(n in r)return r[n];let s=Ir();yt(2);let i=new Error(`${e.key}: Unimplemented method "${n.toString()}"`);return yt(s),i.name="UnimplementedError",zG(i)},has:nr})),zG=e=>{let t=Object.assign(ta(e),{[DN]:DN,channel:{[Hg]:Hg,transform:()=>q(t),pipe(){return V(this,arguments)}},[Hg]:Hg,transform:()=>q(t)});function r(){return t}return Object.assign(r,t),Object.setPrototypeOf(r,Object.getPrototypeOf(t)),r},DN="~effect/Stream",Hg="~effect/Channel",WG=()=>e=>e,KG=()=>e=>e,VG=()=>e=>e,GG=(e,t)=>(t=Ho(t),Qn(li,t?.onEnd?pi(bs(e,t),r=>rl(n=>t.onEnd(r,n))):bs(e,t))),zN=e=>mu(li.context(e)),JG=function(){let e=typeof arguments[0]!="string",t=e?arguments[1]:arguments[0],r=Ho(e?arguments[2]:arguments[1]);if(e){let n=arguments[0];return d0(_e(r?.onEnd!==void 0?pi(bs(t,r),o=>rl(s=>r.onEnd(o,s))):bs(t,r),o=>p0(n,o,r)))}return n=>d0(_e(r?.onEnd!==void 0?pi(bs(t,r),o=>rl(s=>r.onEnd(o,s))):bs(t,r),o=>p0(n,o,r)))},p0=function(){let e=zg(arguments[0]),t=e?arguments[1]:arguments[0],r=e?arguments[2]:arguments[1],n=F;t._tag==="Span"&&(r=Ho(r),n=ZG(t.name,r?.captureStackTrace));let o=zN(t);return e?Cs(n(arguments[0]),o):s=>Cs(n(s),o)},ZG=(e,t)=>(t=typeof t=="function"?t:po,qN(RN,r=>({name:e,stack:t,parent:r})));var Yn=Vn;var Gg="~effect/DateTime",Jg="~effect/DateTime/TimeZone",VN={[Gg]:Gg,pipe(){return V(this,arguments)},[Qe](){return this.toString()},toJSON(){return Np(this).toJSON()}},QG={...VN,_tag:"Utc",[ie](){return zt(this.epochMilliseconds)},[ae](e){return pl(e)&&e._tag==="Utc"&&this.epochMilliseconds===e.epochMilliseconds},toString(){return`DateTime.Utc(${Np(this).toJSON()})`}},YG={...VN,_tag:"Zoned",[ie](){return he(zt(this.epochMilliseconds))(G(this.zone))},[ae](e){return pl(e)&&e._tag==="Zoned"&&this.epochMilliseconds===e.epochMilliseconds&&Z(this.zone,e.zone)},toString(){return`DateTime.Zoned(${C0(this)})`}},GN={[Jg]:Jg,[Qe](){return this.toString()}},XG={...GN,_tag:"Named",[ie](){return Be(`Named:${this.id}`)},[ae](e){return xu(e)&&e._tag==="Named"&&this.id===e.id},toString(){return`TimeZone.Named(${this.id})`},toJSON(){return{_id:"TimeZone",_tag:"Named",id:this.id}}},eJ={...GN,_tag:"Offset",[ie](){return Be(`Offset:${this.offset}`)},[ae](e){return xu(e)&&e._tag==="Offset"&&this.offset===e.offset},toString(){return`TimeZone.Offset(${w0(this.offset)})`},toJSON(){return{_id:"TimeZone",_tag:"Offset",offset:this.offset}}},yi=(e,t,r)=>{let n=Object.create(YG);return n.epochMilliseconds=e,n.zone=t,Object.defineProperty(n,"partsUtc",{value:r,enumerable:!1,writable:!0}),Object.defineProperty(n,"adjustedEpochMillis",{value:void 0,enumerable:!1,writable:!0}),Object.defineProperty(n,"partsAdjusted",{value:void 0,enumerable:!1,writable:!0}),n},pl=e=>O(e,Gg);var xu=e=>O(e,Jg),JN=e=>xu(e)&&e._tag==="Offset",ZN=e=>xu(e)&&e._tag==="Named",QN=e=>e._tag==="Utc",y0=e=>e._tag==="Zoned",YN=Wr((e,t)=>e.epochMilliseconds===t.epochMilliseconds);var XN=e=>{let t=Object.create(QG);return t.epochMilliseconds=e,Object.defineProperty(t,"partsUtc",{value:void 0,enumerable:!1,writable:!0}),t},dl=e=>{let t=e.getTime();if(Number.isNaN(t))throw new Ug("Invalid date");return XN(t)},Qg=e=>{if(pl(e))return e;if(e instanceof Date)return dl(e);if(typeof e=="object"){if("epochMilliseconds"in e)return dl(new Date(e.epochMilliseconds));let t=new Date(0);return cJ(t,e),dl(t)}else if(typeof e=="string"&&!tJ(e))return dl(new Date(e+"Z"));return dl(new Date(e))},tJ=e=>/Z|GMT|[+-]\d{2}$|[+-]\d{2}:?\d{2}$|\]$/.test(e),rJ=-864e13+720*60*1e3,nJ=864e13-840*60*1e3,S0=(e,t)=>{let r=t?.timeZone;if(r===void 0&&pl(e)&&y0(e))return e;let n=Qg(e);if(n.epochMilliseconds<rJ||n.epochMilliseconds>nJ)throw new RangeError(`Epoch millis out of range: ${n.epochMilliseconds}`);r===void 0&&typeof e=="object"&&"timeZoneId"in e&&(r=e.timeZoneId);let o;if(r===void 0){let s=new Date(n.epochMilliseconds).getTimezoneOffset()*-60*1e3;o=Fp(s)}else if(xu(r))o=r;else if(typeof r=="number")o=Fp(r);else{let s=I0(r);if(fe(s))throw new Ug(`Invalid time zone: ${r}`);o=s.value}return t?.adjustForTimeZone!==!0?yi(n.epochMilliseconds,o,n.partsUtc):uJ(n.epochMilliseconds,o,t?.disambiguation??"compatible")},x0=xs(S0),eU=xs(Qg),oJ=/^(.{17,35})\[(.+)\]$/,tU=e=>{let t=oJ.exec(e);if(t===null){let o=A0(e);return o!==null?x0(e,{timeZone:o}):_()}let[,r,n]=t;return x0(r,{timeZone:n})};var rU=e=>XN(e.epochMilliseconds);var Zg=new Map,sJ={day:"numeric",month:"numeric",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"longOffset",fractionalSecondDigits:3,hourCycle:"h23"},iJ=e=>{let t=e.resolvedOptions().timeZone,r=Zg.get(t);if(r!==void 0)return r;let n=Object.create(XG);return n.id=t,n.format=e,Zg.set(t,n),n},b0=e=>{let t=Zg.get(e);if(t!==void 0)return t;try{let r=iJ(new Intl.DateTimeFormat("en-US",{...sJ,timeZone:e}));return Zg.set(e,r),r}catch{throw new Ug(`Invalid time zone: ${e}`)}},Fp=e=>{let t=Object.create(eJ);return t.offset=e,t},E0=xs(b0);var aJ=/^(?:GMT|[+-])/,I0=e=>{if(aJ.test(e)){let t=A0(e);return t===null?_():N(Fp(t))}return E0(e)},nU=e=>e._tag==="Offset"?w0(e.offset):e.id;var Np=e=>new Date(e.epochMilliseconds),Yg=e=>{if(e._tag==="Utc")return new Date(e.epochMilliseconds);if(e.zone._tag==="Offset")return new Date(e.epochMilliseconds+e.zone.offset);if(e.adjustedEpochMilliseconds!==void 0)return new Date(e.adjustedEpochMilliseconds);let t=e.zone.format.formatToParts(e.epochMilliseconds).filter(n=>n.type!=="literal"),r=new Date(0);return r.setUTCFullYear(Number(t[2].value),Number(t[0].value)-1,Number(t[1].value)),r.setUTCHours(Number(t[3].value),Number(t[4].value),Number(t[5].value),t[6]?.type==="fractionalSecond"?Number(t[6].value):(e.epochMilliseconds%1e3+1e3)%1e3),e.adjustedEpochMilliseconds=r.getTime(),r},T0=e=>Yg(e).getTime()-v0(e),w0=e=>{let t=Math.abs(e),r=Math.floor(t/(3600*1e3)),n=Math.round(t%(3600*1e3)/(60*1e3));return n===60&&(r+=1,n=0),`${e<0?"-":"+"}${String(r).padStart(2,"0")}:${String(n).padStart(2,"0")}`},oU=e=>w0(T0(e)),v0=e=>e.epochMilliseconds;var cJ=(e,t)=>{if((t.year!==void 0||t.month!==void 0||t.day!==void 0)&&e.setUTCFullYear(t.year??e.getUTCFullYear(),t.month!==void 0?t.month-1:e.getUTCMonth(),t.day??e.getUTCDate()),t.weekDay!==void 0){let r=t.weekDay-e.getUTCDay();e.setUTCDate(e.getUTCDate()+r)}t.hour!==void 0&&e.setUTCHours(t.hour),t.minute!==void 0&&e.setUTCMinutes(t.minute),t.second!==void 0&&e.setUTCSeconds(t.second),t.millisecond!==void 0&&e.setUTCMilliseconds(t.millisecond)};var KN=1440*60*1e3,uJ=(e,t,r)=>{if(t._tag==="Offset")return yi(e-t.offset,t);let n=Mp(e-KN,e,t),o=Mp(e+KN,e,t);if(n===o)return yi(e-n,t);let s=n<o,i=n-o;if(s){if(Mp(e-o,e,t)===o)return yi(e-o,t);let u=yi(e-n,t),f=Yg(u).getTime();if(e!==f)switch(r){case"reject":{let p=new Date(e).toISOString();throw new RangeError(`Gap time: ${p} does not exist in time zone ${t.id}`)}case"earlier":return yi(e-o,t);case"compatible":case"later":return u}return u}if(Mp(e-n,e,t)===n){if(r==="earlier"||r==="compatible"||Mp(e-n+i,e+i,t)===n)return yi(e-n,t);if(r==="reject"){let u=new Date(e).toISOString();throw new RangeError(`Ambiguous time: ${u} occurs twice in time zone ${t.id}`)}}return yi(e-o,t)},fJ=/([+-])(\d{2}):(\d{2})$/,A0=e=>{let t=fJ.exec(e);if(t===null)return null;let[,r,n,o]=t;return(r==="+"?1:-1)*(Number(n)*60+Number(o))*60*1e3},Mp=(e,t,r)=>{let n=r.format.formatToParts(e).find(s=>s.type==="timeZoneName")?.value??"";if(n==="GMT")return 0;let o=A0(n);return o===null?T0(yi(t,r)):o};var sU=e=>Np(e).toISOString();var g0=e=>{let t=Yg(e);return e._tag==="Utc"?t.toISOString():`${t.toISOString().slice(0,-1)}${oU(e)}`},C0=e=>e.zone._tag==="Offset"?g0(e):`${g0(e)}[${e.zone.id}]`;var Cde=globalThis.Number;var aU=d(2,(e,t)=>{if(!globalThis.Number.isFinite(e)||!globalThis.Number.isFinite(t)||t===0)return NaN;if(globalThis.Number.isInteger(e)&&globalThis.Number.isInteger(t))return e%t;let[r,n]=iU(e),[o,s]=iU(t),i=Math.min(n,s),a=r*BigInt(10)**BigInt(n-i),c=o*BigInt(10)**BigInt(s-i),u=a%c;if(u===BigInt(0))return e<0||Object.is(e,-0)?-0:0;let f=globalThis.Number(`${u}e${i}`);return f===0?Math.sign(e)*globalThis.Number.MIN_VALUE:f});function iU(e){if(globalThis.Number.isInteger(e))return[BigInt(e),0];let t=Math.abs(e).toExponential(),r=t.indexOf("e"),n=t.slice(0,r).replace(".","");return[BigInt(n)*(e<0?-BigInt(1):BigInt(1)),globalThis.Number(t.slice(r+1))-n.length+1]}var cU=e=>{let t=Math.ceil(Math.log(e)/Math.log(2));return Math.max(Math.pow(2,t),2)};var Rde=globalThis.String,Xg=On;var uU=e=>e.trim();var ht=d(2,(e,t)=>oa(e,pJ,r=>t(r))),wo=e=>e.reasons.some(R0),R0=e=>e._tag==="Fail"&&Op(e.error),Up=e=>{let t,r=!1;for(let n of e.reasons)R0(n)?t??=n.error:n._tag!=="Interrupt"&&(r=!0);return t===void 0?re(e):r?re(fu(e.reasons.filter(n=>!R0(n)))):X(t)};var pJ=e=>{let t=Up(e);return be(t)?t:X(t.success.value)},ey=e=>{let t=Up(e);return be(t)?ir(t.failure):Mr(t.success.value)},Dp=d(2,(e,t)=>di(e,{onSuccess:t.onSuccess,onFailure:r=>{let n=Up(r);return be(n)?t.onFailure(n.failure):t.onDone(n.success.value)}}));var fU="~effect/Schedule";var Fr=Ae("effect/Schedule/CurrentMetadata",{defaultValue:qe({input:void 0,output:void 0,duration:Ji,attempt:0,start:0,now:0,elapsed:0,elapsedSincePrevious:0})}),mJ={[fU]:{_Out:F,_In:F,_Env:F},pipe(){return V(this,arguments)}},O0=e=>O(e,fU),ml=e=>{let t=Object.create(mJ);return t.step=e,t},_0=()=>{let e=0,t,r;return(n,o)=>{r===void 0&&(r=n);let s=n-r,i=t===void 0?0:n-t;return t=n,{input:o,attempt:++e,start:r,now:n,elapsed:s,elapsedSincePrevious:i}}},lU=e=>ml(_e(e,t=>{let r=_0();return(n,o)=>t(r(n,o))})),Ya=e=>Mn(e.step,t=>q(()=>Ye(t))),ks=e=>Is(t=>_e(Ya(e),r=>{let n=_0();return o=>ce(()=>{let s=t.currentTimeMillisUnsafe();return Y(r(s,o),([i,a])=>{let c=n(s,o);return c.output=i,c.duration=a,Zr(sl(a),c)})})})),Lp=e=>_e(ks(e),t=>r=>_e(t(r),n=>n.output));var dU=e=>ml(_e(ol(e.map(Ya)),t=>(r,n)=>Y(Kn(t,o=>Dp(o(r,n),{onSuccess:s=>q(s[1]),onDone:()=>Fg,onFailure:Ye})),o=>{let s=hJ(o);return s===void 0?se(Ji):q([s,s])}))),hJ=e=>{let t;for(let r=0;r<e.length;r++){let n=e[r];n!==void 0&&(t=t===void 0?n:pP(t,n))}return t},pU=(e,t=2)=>{let r=Wt($e(e));return lU(q(n=>{let o=Zi(r*Math.pow(t,n.attempt-1));return q([o,o])}))};var P0=e=>ml(_e(Ya(e),t=>(r,n)=>Dp(t(r,n),{onSuccess:o=>q([n,o[1]]),onFailure:Ye,onDone:()=>se(n)}))),mU=e=>Bp($p,({attempt:t})=>q(t<=e)),hl=e=>{let t=$e(e);return lU(q(r=>q([r.attempt-1,t])))};var Bp=d(2,(e,t)=>ml(_e(Ya(e),r=>{let n=_0();return(o,s)=>Y(r(o,s),i=>{let[a,c]=i,u=t({...n(o,s),output:a,duration:c});return Y(ge(u)?u:q(u),f=>f?q(i):se(a))})})));var $p=hl(Ji);var hU="~effect/ExecutionPlan";var xJ={[hU]:hU,get captureRequirements(){let e=this;return Ha(t=>q(gJ(e.steps.map(r=>({...r,while:r.while?n=>Eo(r.while(n),t):void 0,schedule:r.schedule?ml(Eo(_e(Ya(r.schedule),n=>(o,s)=>Eo(n(o,s),t)),t)):void 0,provide:zg(r.provide)?Cs(r.provide,mu(t)):r.provide})))))},pipe(){return V(this,arguments)}},gJ=e=>{let t=Object.create(xJ);return t.steps=e,t};var ty=Ae("effect/ExecutionPlan/CurrentMetadata",{defaultValue:qe({attempt:0,stepIndex:0})});var yJ=(e,t,r)=>Ag(n=>Y(r?.local?gi(t,xi(),n):_p(t,n),o=>Eo(e,o))),ry=d(e=>ge(e[0]),(e,t,r)=>ip(t)?Eo(e,t):yJ(e,Array.isArray(t)?Kg(...t):t,r));var gU=e=>e.reasons.every(hs)?qo(e):re(e),F0=d(3,(e,t,r)=>Y(ks(t),n=>{let o=Fr.defaultValue();return oa(ht(yg(pi(Y(ce(()=>Pn(e,Fr,o)),n),s=>ye(()=>{o=s})),{disableYield:!0}),s=>q(s)),gU,s=>r(s,o.attempt===0?_():N(o)))})),N0=d(3,(e,t,r)=>Y(ks(t),n=>{let o=Fr.defaultValue(),s,i=oa(ce(()=>Pn(e,Fr,o)),gU,a=>(s=a,Y(n(a),c=>(o=c,i))));return ht(i,a=>Ma(()=>r(s,a)))})),yU=d(2,(e,t)=>{let r=typeof t=="function"?t(F):O0(t)?t:Hp(t);return F0(e,r,Et)}),jp=d(2,(e,t)=>{let r=typeof t=="function"?t(F):O0(t)?t:Hp(t);return N0(e,r,Et)}),SU=d(3,(e,t,r)=>Y(ks(r),n=>{let o=Fr.defaultValue(),s=ce(()=>Pn(e,Fr,o));return ht(Y(n(t),i=>{o=i;let a=qe(Y(s,n));return mi({while:nr,body:a,step(c){o=c}})}),i=>q(i))})),SJ=P0($p),Hp=e=>{let t=e.schedule?P0(e.schedule):SJ;return e.while&&(t=Bp(t,({input:r})=>{let n=e.while(r);return ge(n)?n:q(n)})),e.until&&(t=Bp(t,({input:r})=>{let n=e.until(r);return ge(n)?_e(n,o=>!o):q(!n)})),e.times!==void 0&&(t=Bp(t,({attempt:r})=>q(r<=e.times))),t};var U0=(e,t)=>{let r=-1,n=0,o=s=>Tg(e(s));return{begin:Is(s=>ce(()=>{let i=t();i.stepIndex!==r&&(r=i.stepIndex,n=0),n++;let a={attempt:i.attempt,stepAttempt:n,stepIndex:i.stepIndex,startNanos:s.monotonicTimeNanosUnsafe()};return Zr(o({_tag:"AttemptStart",attempt:a.attempt,stepAttempt:a.stepAttempt,stepIndex:a.stepIndex}),a)})),end:(s,i)=>Is(a=>{let c=$o(a.monotonicTimeNanosUnsafe()-s.startNanos);return o(i._tag==="Success"?{_tag:"AttemptSuccess",attempt:s.attempt,stepAttempt:s.stepAttempt,stepIndex:s.stepIndex,duration:c}:{_tag:"AttemptFailure",attempt:s.attempt,stepAttempt:s.stepAttempt,stepIndex:s.stepIndex,duration:c,cause:i.cause})})}},EU=d(e=>ge(e[0]),(e,t,r)=>ce(()=>{let n=0,o={attempt:0,stepIndex:0},s=gg(ty,ye(()=>(o={attempt:o.attempt+1,stepIndex:n},o))),i=r?.onEvent===void 0?void 0:U0(r.onEvent,()=>o),a=i===void 0?F:u=>Gn(f=>Y(i.begin,p=>To(f(u),m=>i.end(p,m)))),c;return Y(mi({while:()=>n<t.steps.length&&(c===void 0||be(c)),body(){let u=t.steps[n],f=s(a(ry(e,u.provide)));if(c){let p=!1,m=f;f=ce(()=>p?m:(p=!0,Vf(c))),f=jp(f,qp(u,!1))}else{let p=qp(u,!0);f=p?jp(f,p):f}return $a(f)},step(u){c=u,n++}}),()=>Vf(c))})),qp=(e,t)=>{if(t){if(e.attempts===1||!(e.schedule||e.attempts))return}else return Hp({schedule:e.schedule?e.schedule:e.attempts?void 0:bJ,times:e.attempts,while:e.while});return Hp({schedule:e.schedule,while:e.while,times:e.attempts?e.attempts-1:void 0})},bJ=mU(1);var TU="~effect/MutableHashMap";var EJ={[TU]:TU,[Symbol.iterator](){return this.backing[Symbol.iterator]()},toString(){return`MutableHashMap(${H(Array.from(this))})`},toJSON(){return{_id:"MutableHashMap",values:pr(Array.from(this))}},[Qe](){return this.toJSON()},pipe(){return V(this,arguments)}},Si=()=>{let e=Object.create(EJ);return e.backing=new Map,e.buckets=new Map,e};var Qr=d(2,(e,t)=>{if(e.backing.has(t))return N(e.backing.get(t));if(D0(t))return _();let r=G(t),n=e.buckets.get(r);return n===void 0?_():IJ(e,n,t)}),D0=e=>typeof e!="object"&&typeof e!="function";var IJ=(e,t,r)=>{for(let n=0,o=t.length;n<o;n++)if(Z(r,t[n])){let s=t[n];return N(e.backing.get(s))}return _()},L0=d(2,(e,t)=>de(Qr(e,t))),bi=d(3,(e,t,r)=>{if(e.backing.has(t)||D0(t))return e.backing.set(t,r),e;let n=G(t),o=e.buckets.get(n);if(o===void 0)return e.buckets.set(n,[t]),e.backing.set(t,r),e;let s=TJ(o,t);return s===void 0&&(o.push(t),s=t),e.backing.set(s,r),e}),TJ=(e,t)=>{for(let r=0,n=e.length;r<n;r++)if(Z(t,e[r]))return e[r]};var Ei=d(2,(e,t)=>{if(D0(t))return e.backing.delete(t),e;let r=G(t),n=e.buckets.get(r);if(n===void 0)return e;for(let o=0,s=n.length;o<s;o++){let i=n[o];if(i===t||Z(t,i)){e.backing.delete(i),n.splice(o,1);break}}return n.length===0&&e.buckets.delete(r),e}),ny=e=>(e.backing.clear(),e.buckets.clear(),e),wU=e=>e.backing.size;var wJ="~effect/Request",vJ=QO({_E:e=>e,_A:e=>e,_R:e=>e}),Zde={...n_,[wJ]:vJ};var vU=e=>e;var CU=d(2,(e,t)=>{let r=n=>$t(o=>{let s=RU(n,e,o,ea());return RJ(n,s)});return ge(t)?Y(t,r):r(t)}),kU=(e,t)=>{let r=RU(t.resolver,e,t.onExit,{context:t.context,cache:{scheduler:Re(t.context,Ba)}});return()=>OU(t.resolver,r)},CJ=new WeakSet,kJ=e=>{if(!CJ.has(e.batchKey))return new Map;let t=Si();return{get:r=>_n(Qr(t,r)),has:r=>L0(t,r),set:(r,n)=>bi(t,r,n),delete:r=>Ei(t,r)}},oy=[],B0=new WeakMap,RU=(e,t,r,n)=>{let o=B0.get(e);o||(o=kJ(e),B0.set(e,o));let s,i=!1,a=vU({request:t,context:n.context,uninterruptible:!1,completeUnsafe(u){i||(i=!0,!(s&&!s.entrySet.delete(a))&&r(u))}});if(e.preCheck!==void 0&&!e.preCheck(a))return a;let c=e.batchKey(a);if(s=o.get(c),!s){if(oy.length>0)s=oy.pop(),s.key=c,s.resolver=e,s.map=o;else{let u={key:c,resolver:e,map:o,entrySet:new Set,entries:new Set,delayEffect:Y(ce(()=>u.resolver.delay),f=>AU(u)),run:To(ce(()=>u.resolver.runAll(Array.from(u.entries),u.key)),f=>{for(let p of u.entrySet)p.completeUnsafe(f._tag==="Success"?ln(new Error("Effect.request: RequestResolver did not complete request",{cause:p.request})):f);return u.entries.clear(),oy.length<128&&(u.entrySet.clear(),u.key=void 0,u.fiber=void 0,u.resolver=void 0,u.map=void 0,oy.push(u)),pe})};s=u}o.set(c,s),s.fiber=sa(n.context)(s.delayEffect,{scheduler:n.cache.scheduler})}return s.entrySet.add(a),s.entries.add(a),s.resolver.collectWhile(s.entries)||(s.fiber.interruptUnsafe(n.id),s.fiber=sa(n.context)(AU(s),{scheduler:n.cache.scheduler})),a},OU=(e,t)=>{if(t.uninterruptible)return;let r=B0.get(e);if(!r)return;let n=e.batchKey(t),o=r.get(n);if(!o||!o.entries.delete(t))return;o.entrySet.delete(t);let s;o.entries.size===0&&(r.delete(n),s=o.fiber),t.completeUnsafe(Zf()),s?.interruptUnsafe()},RJ=(e,t)=>ye(()=>OU(e,t));function AU(e){return e.map.has(e.key)?(e.map.delete(e.key),e.run):pe}var _J="effect/Metric/CurrentMetricAttributes",PJ=Ae(_J,{defaultValue:()=>({})}),MJ="effect/Metric/MetricRegistry",FJ=Ae(MJ,{defaultValue:()=>new Map}),_U="~effect/Metric",PU=class{[_U]=_U;#e;#t="";id;description;attributes;constructor(t,r,n){this.id=t,this.description=r,this.attributes=n}valueUnsafe(t){return this.hook(t).get(t)}modifyUnsafe(t,r){return this.hook(r).modify(t,r)}updateUnsafe(t,r){return this.hook(r).update(t,r)}hook(t){let r=Re(t,PJ);r!==this.#e&&(this.#e=r,this.#t=NJ(this,MU(this.attributes,r)));let n=Re(t,FJ),o=n.get(this.#t);return BO(o)&&(o={id:this.id,type:this.type,description:this.description,attributes:Object.keys(r).length>0?MU(this.attributes,r):this.attributes,hooks:this.createHooks()},n.set(this.#t,o)),o.hooks}pipe(){return V(this,arguments)}};var xl=d(2,(e,t)=>Ha(r=>ye(()=>e.updateUnsafe(t,r))));function NJ(e,t){let r=Object.entries(t).sort((n,o)=>n[0]<o[0]?-1:n[0]>o[0]?1:0);return JSON.stringify([e.type,e.id,e.description,r])}function MU(e,t){return{...FU(e),...FU(t)}}function FU(e){return ei(e)&&Array.isArray(e)?e.reduce((t,[r,n])=>(B(t,r,n),t),{}):e}var UJ=si,Yr=ge,DJ=ol,LJ=YT,BJ=EF,$J=IF,jJ=TF,HJ=vF,Ko=Kn,qJ=CF,xn=mi,Wp=AT,Vo=eM,I=q,ia=au,j0=vT,L=ce,W=ye,P=pe;var Kp=Fg;var Nn=$t,Xn=gp,zJ=MF,WJ=FF,KJ=UF;var VJ=NF,xt=oM,D=Et,sy=mg,je=Ye,aa=YP,gn=ta,Go=XP;var Vp=Gf,GJ=wT,ar=oe,JJ=i_,H0=Vf,ZJ=TT,QJ=QP,YJ=ZP,C=Y,q0=mM,Vt=bo,_t=pi,XJ=$a,e8=GM,eo=Ep,K=_e,Pt=Zr,iy=Jf,vo=yp,t8=uM,z0=OM,r8=DT,yu=Es;var DU=Eg,LU=jM,n8=HM,o8=qM,s8=zM,rt=Mn,W0=UM,i8=Sp,a8=bg,c8=NM,K0=BT,BU=oa,yl=jT,u8=HT,Ii=Ig,Gp=$T,f8=BM,Jp=DM,l8=LM,d8=Sg,$U=$M,p8=qT,ay=jp,V0=N0,m8=fM,cy=VM,uy=Tg,h8=EU,x8=hN,g8=WM,y8=KM,G0=tF,S8=KT,jU=WT,ca=eF,ua=sl,b8=rF,J0=_T,E8=PT,I8=lM,Xa=MT,Z0=OF,T8=_F,Q0=PF,HU=XT,w8=e0,qU=_M,v8=RF,fy=PM,Y0=wg,A8=bp,C8=zT,k8=QM,R8=dM,Un=di,zU=Xf,O8=YM,_8=XM,Nr=UT,yn=Ha,X0=ry,Ur=Eo,P8=RM,ew=AM,Su=CM,ec=Yf,tw=na,M8=kM,Jo=Pn,F8=gg,Ao=Ip,tc=vg,Sl=Ag,Ti=Cg,N8=pF,WU=dF,KU=rl,wi=uF,to=Tp,U8=fF,D8=ZT,Zp=Io,Xr=To,L8=GT,B8=JT,ly=xF,$8=hF,j8=QT,Dn=nl,vi=kg,bu=lF,Ai=cu,en=Gn,H8=SF,q8=bF,Mt=yg,VU=yU,z8=F0,W8=LT,rw=MM,K8=d(2,(e,t)=>GU(e,void 0,t)),GU=SU,V8=JF,G8=ZF,J8=QF,Z8=YF,Q8=iN,Y8=aN,X8=cN,eZ=uN,tZ=rN,rZ=nN,nZ=oN,nw=eN,ow=bs,Qp=mp,oZ=sN,sZ=tN,bl=Kf,iZ=CU,aZ=kU,El=DF,gt=t0,Rs=$F,Il=LF,cZ=BF,uZ=rM,fZ=nM,Yp=HF,Sr=sa,sw=r0,lZ=qF,iw=WF,aw=n0,dy=zF,dZ=_g,Ci=VF,cw=o0,ki=KF,pZ=Pg,me=kT,mZ=sM,Eu=Is,Tl=Ts,hZ=Ts(),xZ=Ts("Fatal"),gZ=Ts("Warn"),Xp=Ts("Error"),yZ=Ts("Info"),SZ=Ts("Debug"),bZ=Ts("Trace"),EZ=d(2,(e,t)=>na(e,c0,r=>new Set([...r,t]))),py=d(e=>Yr(e[0]),(e,...t)=>na(e,CN,r=>{let n=t.length===1?{...r,...t[0]}:{...r};return t.length===1||B(n,t[0],t[1]),n})),IZ=pN,TZ=d(2,(e,t)=>Y(a0,r=>na(e,kN,n=>[[t,r],...n]))),wZ=d(e=>Yr(e[0]),(e,t,r)=>Xr(e,n=>{let o=r===void 0?n:r(n);return xl(t,o)})),vZ=d(e=>Yr(e[0]),(e,t,r)=>_t(e,n=>{let o=r===void 0?n:r(n);return xl(t,o)})),AZ=d(e=>Yr(e[0]),(e,t,r)=>Gp(e,n=>{let o=r===void 0?n:r(n);return xl(t,o)})),CZ=d(e=>Yr(e[0]),(e,t,r)=>$U(e,n=>{let o=r===void 0?n:r(n);return xl(t,o)})),kZ=d(e=>Yr(e[0]),(e,t,r)=>Eu(n=>{let o=n.monotonicTimeNanosUnsafe();return Xr(e,()=>{let s=n.monotonicTimeNanosUnsafe(),i=mP($e(s),$e(o)),a=r===void 0?i:r(i);return xl(t,a)})})),gl=class extends Ue()("effect/Effect/Transaction"){},RZ=e=>ar(t=>{let r=Vi(t.context,gl);if(r&&!UU.has(r))return e;r={journal:new Map,retry:!1};let n;return en(o=>C(xn({while:()=>!n,body:qe(o(e).pipe(Jo(gl,r),Jp(s=>r.retry?ug(s)?o(OZ(r)):W(()=>$0(r)):P),eo)),step(s){if(r.retry||!JU(r))return $0(r);ft(s)&&_Z(t,r),$0(r),UU.add(r),n=s}}),()=>n))}),UU=new WeakSet,JU=e=>{for(let[t,{version:r}]of e.journal)if(t.version!==r)return!1;return!0},OZ=e=>Nn(t=>{if(!JU(e))return t(P);let r={},n=Array.from(e.journal.keys()),o=()=>{for(let i of n)i.pending.delete(r)},s=()=>{o(),t(P)};for(let i of n)i.pending.set(r,s);return W(o)});function _Z(e,t){for(let[r,{value:n,written:o}]of t.journal)if(o){Object.is(n,r.value)||(r.version=r.version+1,r.value=n);for(let s of r.pending.values())e.currentDispatcher.scheduleTask(s,0);r.pending.clear()}}function $0(e){e.retry=!1,e.journal.clear()}var PZ=C(gl,e=>(e.retry=!0,Dn)),MZ=(e,t,r)=>(...n)=>Nn(o=>{try{e(...n,(s,i)=>{o(s?t?L(()=>D(t(s,n))):D(s):I(i))})}catch(s){o(r?D(r(s,n)):gn(s))}}),FZ=()=>e=>e,NZ=()=>e=>e,UZ=()=>e=>e,Iu=hM,Tu=xM,cr=gM,ur=pM,my=yM,uw=iM;var ZU=/^[+-]?\d+$/,lw="~effect/BigDecimal",DZ={[lw]:lw,[ie](){let e=em(this);return he(Be(String(e.value)),zt(e.scale))},[ae](e){return wu(e)&&tD(this,e)===0},toString(){return`BigDecimal(${fa(this)})`},toJSON(){return{_id:"BigDecimal",value:String(this.value),scale:this.scale}},[Qe](){return this.toJSON()},pipe(){return V(this,arguments)}},wu=e=>O(e,lw),hy=(e,t)=>{if(!Number.isSafeInteger(t))throw new RangeError(`Scale must be a safe integer, got ${t}`);let r=Object.create(DZ);return r.value=e,r.scale=t,r},XU=(e,t)=>{let r=hy(e,t);return r.normalized=r,r};var Os=BigInt(0),LZ=BigInt(1);var BZ=BigInt(10),eD=XU(Os,0);var em=e=>{if(e.normalized===void 0)if(e.value===Os)e.normalized=eD;else{let t=`${e.value}`,r=t.length;for(;t[r-1]==="0";)r--;e.normalized=XU(BigInt(t.slice(0,r)),e.scale-(t.length-r))}return e.normalized};var $Z=100,jZ=[LZ],fw=(e,t)=>e===t?0:e<t?-1:1,QU=(e,t)=>{let r=`${e.value<Os?-e.value:e.value}`,n=`${t.value<Os?-t.value:t.value}`,o=BigInt(r.length-n.length)-BigInt(e.scale)+BigInt(t.scale);if(o!==Os)return o<Os?-1:1;let s=Math.max(r.length,n.length);return A_(r.padEnd(s,"0"),n.padEnd(s,"0"))},tD=(e,t)=>{if(e.scale===t.scale)return fw(e.value,t.value);let r=YU(e),n=YU(t);if(r!==n)return r<n?-1:1;if(r===0)return 0;let o=e.scale-t.scale,s=Math.abs(o);if(s>$Z)return r===-1?QU(t,e):QU(e,t);let i=jZ[s]??=BZ**BigInt(s);return o>0?fw(e.value,t.value*i):fw(e.value*i,t.value)},wl=ai(tD);var YU=e=>e.value===Os?0:e.value<Os?-1:1;var rD=e=>{if(e==="")return N(eD);let t,r,n=e.search(/[eE]/);if(n!==-1){let c=e.slice(n+1);if(t=e.slice(0,n),r=Number(c),t===""||!Number.isSafeInteger(r)||!ZU.test(c))return _()}else t=e,r=0;let o,s,i=t.search(/\./);if(i!==-1){let c=t.slice(0,i),u=t.slice(i+1);o=`${c}${u}`,s=u.length}else o=t,s=0;if(!ZU.test(o))return _();let a=s-r;return Number.isSafeInteger(a)?N(hy(BigInt(o),a)):_()};var fa=e=>{let t=em(e);if(Math.abs(t.scale)>=16)return HZ(t);let r=t.value<Os,n=`${r?-t.value:t.value}`,o=t.scale>0?n.padStart(t.scale+1,"0"):n.padEnd(n.length-t.scale,"0"),s=o.length-t.scale,i=t.scale>0?`${o.slice(0,s)}.${o.slice(s)}`:o;return r?`-${i}`:i},HZ=e=>{if(qZ(e))return"0e+0";let t=em(e),r=`${t.value}`,n=t.value<Os?2:1,o=r.slice(0,n),s=r.slice(n),i=s.length-t.scale;return`${o}${s===""?"":`.${s}`}e${i>=0?"+":""}${i}`};var qZ=e=>e.value===Os;var l={};ps(l,{Any:()=>A7,Array:()=>ct,ArrayEnsure:()=>U7,BigDecimal:()=>sj,BigDecimalFromString:()=>hee,BigInt:()=>dd,BigIntFromString:()=>eee,Boolean:()=>Fi,BooleanFromBit:()=>aee,BooleanLiterals:()=>q7,ByteSize:()=>JS,ByteSizeFromBigInt:()=>gee,ByteSizeFromNumber:()=>yee,ByteSizeFromString:()=>xee,Cause:()=>Jm,CauseReason:()=>tC,Char:()=>$X,Chunk:()=>See,Class:()=>YS,Cookie:()=>Jj,Cookies:()=>Zj,Date:()=>GS,DateFromMillis:()=>VX,DateFromString:()=>KX,DateTimeUtc:()=>ZS,DateTimeUtcFromDate:()=>vee,DateTimeUtcFromMillis:()=>Cee,DateTimeUtcFromString:()=>Aee,DateTimeZoned:()=>Ij,DateTimeZonedFromString:()=>_ee,Defect:()=>er,DnsARecord:()=>Dj,DnsAaaaRecord:()=>Lj,DnsCaaRecord:()=>Bj,DnsCnameRecord:()=>$j,DnsMxRecord:()=>jj,DnsNaptrRecord:()=>Hj,DnsNsRecord:()=>qj,DnsPtrRecord:()=>zj,DnsRecord:()=>Cte,DnsRecordType:()=>Ate,DnsSoaRecord:()=>Wj,DnsSrvRecord:()=>Kj,DnsTlsaRecord:()=>Vj,DnsTxtRecord:()=>Gj,DomainName:()=>Sa,DomainNameFromString:()=>Pj,Duration:()=>ih,DurationFromMillis:()=>vte,DurationFromNanos:()=>wte,DurationFromString:()=>Tte,Enum:()=>v7,Error:()=>Cr,ErrorInstance:()=>jX,Exit:()=>bC,FalseLiterals:()=>P$,File:()=>Q$,Finite:()=>KS,FiniteFromString:()=>XX,FormData:()=>Y$,Graph:()=>_te,HashMap:()=>Pte,HashSet:()=>Mte,Headers:()=>Lte,Host:()=>hte,HostFromString:()=>xte,HostPort:()=>Fj,HostPortFromString:()=>gte,InetAddress:()=>Oj,InetAddressFromString:()=>dte,InetAddressV4:()=>fte,InetAddressV6:()=>lte,Int:()=>In,IpAddress:()=>bc,IpAddressFromString:()=>rf,IpInterface:()=>Aj,IpInterfaceFromString:()=>ite,IpLinkLocalAddress:()=>Kee,IpLinkLocalAddressFromString:()=>Vee,IpLoopbackAddress:()=>zee,IpLoopbackAddressFromString:()=>Wee,IpMulticastAddress:()=>Pee,IpMulticastAddressFromString:()=>Mee,IpNetwork:()=>Rj,IpNetworkFromString:()=>ute,IpUnicastAddress:()=>Uee,IpUnicastAddressFromString:()=>Dee,IpUnspecifiedAddress:()=>Gee,IpUnspecifiedAddressFromString:()=>Jee,Ipv4Address:()=>sh,Ipv4AddressFromString:()=>yC,Ipv4BroadcastAddress:()=>$ee,Ipv4BroadcastAddressFromString:()=>jee,Ipv4Interface:()=>wj,Ipv4InterfaceFromString:()=>ote,Ipv4Network:()=>Cj,Ipv4NetworkFromString:()=>ate,Ipv4PrivateAddress:()=>Zee,Ipv4PrivateAddressFromString:()=>Qee,Ipv6Address:()=>QS,Ipv6AddressFromString:()=>Tj,Ipv6Interface:()=>vj,Ipv6InterfaceFromString:()=>ste,Ipv6Network:()=>kj,Ipv6NetworkFromString:()=>cte,Ipv6UniqueLocalAddress:()=>Yee,Ipv6UniqueLocalAddressFromString:()=>Xee,Json:()=>XS,JsonFromUrlParamsField:()=>Bte,JsonObject:()=>dre,Literal:()=>fr,Literals:()=>Fo,MacAddress:()=>tf,MacAddressFromString:()=>hd,MacBroadcastAddress:()=>Hee,MacBroadcastAddressFromString:()=>qee,MacLocallyAdministeredAddress:()=>ete,MacLocallyAdministeredAddressFromString:()=>tte,MacMulticastAddress:()=>Fee,MacMulticastAddressFromString:()=>Nee,MacUnicastAddress:()=>Lee,MacUnicastAddressFromString:()=>Bee,MacUniversallyAdministeredAddress:()=>rte,MacUniversallyAdministeredAddressFromString:()=>nte,MutableJson:()=>mre,Natural:()=>Gu,Never:()=>Mi,NonEmptyArray:()=>Xu,NonEmptyString:()=>hC,Null:()=>HS,NullOr:()=>cC,NullishOr:()=>w$,Number:()=>Qu,NumberFromString:()=>YX,ObjectKeyword:()=>k7,Opaque:()=>Z7,Option:()=>ba,OptionFromNullOr:()=>Fte,OptionFromNullishOr:()=>Ute,OptionFromOptional:()=>Hte,OptionFromOptionalKey:()=>jte,OptionFromOptionalNullOr:()=>qte,OptionFromUndefinedOr:()=>Nte,Port:()=>yte,PropertyKey:()=>eC,ReadonlyMap:()=>HX,ReadonlySet:()=>qX,Record:()=>Yu,RecordFromCookies:()=>Dte,RecordFromUrlParams:()=>$te,Redacted:()=>Qj,RedactedFromValue:()=>zte,RegExp:()=>zX,Result:()=>Wte,SchemaError:()=>$n,ScopedIpv6Literal:()=>SC,ScopedIpv6LiteralFromString:()=>Mj,SocketAddress:()=>mte,StandardSchemaV1FailureResult:()=>iee,String:()=>z,StringForLiteralAutocomplete:()=>C7,StringFromBase64:()=>ree,StringFromBase64Url:()=>nee,StringFromHex:()=>oee,StringFromUriComponent:()=>see,Struct:()=>Te,StructWithRest:()=>F7,Symbol:()=>E$,TaggedClass:()=>Jte,TaggedError:()=>TC,TaggedStruct:()=>ya,TaggedUnion:()=>J7,TemplateLiteral:()=>T7,TemplateLiteralParser:()=>w7,TimeZone:()=>bj,TimeZoneFromString:()=>Oee,TimeZoneNamed:()=>yj,TimeZoneNamedFromString:()=>Ree,TimeZoneOffset:()=>kee,Tree:()=>lre,Trim:()=>tee,Trimmed:()=>ej,TrueLiterals:()=>_$,Tuple:()=>rs,TupleWithRest:()=>N7,URL:()=>J$,URLFromString:()=>WX,URLSearchParams:()=>X$,Uint8Array:()=>qs,Uint8ArrayFromBase64:()=>cee,Uint8ArrayFromBase64Url:()=>uee,Uint8ArrayFromHex:()=>rj,Undefined:()=>iC,UndefinedOr:()=>zS,Union:()=>Pe,UniqueArray:()=>D7,UniqueSymbol:()=>R7,UnixPathAddress:()=>_j,UnixPathAddressFromString:()=>pte,Unknown:()=>Xm,UnknownFromJsonString:()=>JX,UrlParams:()=>EC,Void:()=>pd,annotate:()=>t7,annotateEncoded:()=>r7,annotateKey:()=>n7,asserts:()=>c7,brand:()=>WS,catchDecoding:()=>j7,catchDecodingWithContext:()=>R$,catchEncoding:()=>H7,catchEncodingWithContext:()=>O$,check:()=>B7,declare:()=>Ge,declareConstructor:()=>Ar,decode:()=>z7,decodeEffect:()=>u7,decodeExit:()=>p$,decodeOption:()=>l7,decodePromise:()=>p7,decodeResult:()=>d7,decodeSync:()=>Zm,decodeTo:()=>ee,decodeUnknownEffect:()=>gc,decodeUnknownExit:()=>d$,decodeUnknownOption:()=>f7,decodeUnknownPromise:()=>h$,decodeUnknownResult:()=>m$,decodeUnknownSync:()=>jS,encode:()=>W7,encodeEffect:()=>oC,encodeExit:()=>g$,encodeKeys:()=>P7,encodeOption:()=>h7,encodePromise:()=>g7,encodeResult:()=>x7,encodeSync:()=>sC,encodeTo:()=>uC,encodeUnknownEffect:()=>Qm,encodeUnknownExit:()=>x$,encodeUnknownOption:()=>m7,encodeUnknownPromise:()=>S$,encodeUnknownResult:()=>y$,encodeUnknownSync:()=>Ym,extendTo:()=>M7,fieldsAssign:()=>O7,flip:()=>XA,fromBrand:()=>$7,fromFormData:()=>ZX,fromJsonString:()=>xC,fromURLSearchParams:()=>QX,instanceOf:()=>yc,is:()=>a7,isBase64:()=>L$,isBase64Url:()=>sX,isBetween:()=>Sc,isBetweenBigDecimal:()=>mee,isBetweenBigInt:()=>RX,isBetweenCodePoints:()=>PX,isBetweenDate:()=>vX,isBetweenLength:()=>dC,isBetweenProperties:()=>LX,isBetweenSize:()=>NX,isCapitalized:()=>lX,isEndingWith:()=>aX,isFinite:()=>pX,isGUID:()=>nX,isGreaterThan:()=>hX,isGreaterThanBigDecimal:()=>fee,isGreaterThanBigInt:()=>AX,isGreaterThanDate:()=>EX,isGreaterThanOrEqualTo:()=>B$,isGreaterThanOrEqualToBigDecimal:()=>lee,isGreaterThanOrEqualToBigInt:()=>$$,isGreaterThanOrEqualToDate:()=>IX,isIncluding:()=>cX,isInt:()=>VS,isInt32:()=>SX,isLessThan:()=>xX,isLessThanBigDecimal:()=>dee,isLessThanBigInt:()=>CX,isLessThanDate:()=>TX,isLessThanOrEqualTo:()=>gX,isLessThanOrEqualToBigDecimal:()=>pee,isLessThanOrEqualToBigInt:()=>kX,isLessThanOrEqualToDate:()=>wX,isLowercased:()=>fX,isMaxCodePoints:()=>_X,isMaxLength:()=>z$,isMaxProperties:()=>DX,isMaxSize:()=>FX,isMinCodePoints:()=>OX,isMinLength:()=>j$,isMinProperties:()=>UX,isMinSize:()=>MX,isMultipleOf:()=>yX,isNonEmpty:()=>q$,isPattern:()=>ef,isPropertyNames:()=>BX,isSchema:()=>Zu,isSchemaError:()=>fd,isStartingWith:()=>iX,isStringBigInt:()=>X7,isStringFinite:()=>Y7,isStringSymbol:()=>eX,isTrimmed:()=>D$,isULID:()=>oX,isUUID:()=>rX,isUint32:()=>bX,isUncapitalized:()=>dX,isUnique:()=>mC,isUniqueKey:()=>W$,isUppercased:()=>uX,link:()=>Ne,linkDecoding:()=>md,make:()=>J,makeFilter:()=>Je,makeFilterGroup:()=>Q7,makeIsBetween:()=>oh,makeIsGreaterThan:()=>eh,makeIsGreaterThanOrEqualTo:()=>th,makeIsLessThan:()=>rh,makeIsLessThanOrEqualTo:()=>nh,makeIsMultipleOf:()=>mX,middlewareDecoding:()=>C$,middlewareEncoding:()=>k$,mutable:()=>L7,mutableKey:()=>b7,optional:()=>lr,optionalKey:()=>Ju,overrideToCodecIso:()=>ure,overrideToEquivalence:()=>Yte,overrideToFormatter:()=>Zte,readonlyKey:()=>E7,refine:()=>A$,required:()=>S7,requiredKey:()=>y7,resolveAnnotations:()=>hre,resolveAnnotationsKey:()=>xre,revealBottom:()=>e7,revealCodec:()=>o7,suspend:()=>v$,tag:()=>He,tagDefaultOmit:()=>G7,toCodecArrayFromSingle:()=>ore,toCodecIso:()=>rre,toCodecJson:()=>nf,toCodecStringTree:()=>nre,toDifferJsonPatch:()=>fre,toEncoded:()=>ld,toEncoderXml:()=>sre,toEquivalence:()=>Xte,toFormatter:()=>Qte,toIso:()=>ire,toIsoFocus:()=>cre,toIsoSource:()=>are,toJsonSchemaDocument:()=>tre,toRepresentation:()=>ere,toStandardJSONSchemaV1:()=>i7,toStandardSchemaV1:()=>s7,toTaggedUnion:()=>U$,toType:()=>oo,withArrayLengthConstraints:()=>qS,withConstructorDefault:()=>M$,withDecodingDefault:()=>N$,withDecodingDefaultKey:()=>fC,withDecodingDefaultType:()=>V7,withDecodingDefaultTypeKey:()=>K7});var nD=globalThis.BigInt;var oD=e=>e>nD(Number.MAX_SAFE_INTEGER)||e<nD(Number.MIN_SAFE_INTEGER)?_():N(Number(e));var pw=BigInt(0),zZ=BigInt(1),Ri=BigInt(1e3),rc=BigInt(1024),iD=[{symbol:"B",factor:zZ,names:["B","byte","bytes"]},{symbol:"kB",factor:Ri,names:["kB","kilobyte","kilobytes"]},{symbol:"MB",factor:Ri**BigInt(2),names:["MB","megabyte","megabytes"]},{symbol:"GB",factor:Ri**BigInt(3),names:["GB","gigabyte","gigabytes"]},{symbol:"TB",factor:Ri**BigInt(4),names:["TB","terabyte","terabytes"]},{symbol:"PB",factor:Ri**BigInt(5),names:["PB","petabyte","petabytes"]},{symbol:"EB",factor:Ri**BigInt(6),names:["EB","exabyte","exabytes"]},{symbol:"ZB",factor:Ri**BigInt(7),names:["ZB","zettabyte","zettabytes"]},{symbol:"YB",factor:Ri**BigInt(8),names:["YB","yottabyte","yottabytes"]},{symbol:"RB",factor:Ri**BigInt(9),names:["RB","ronnabyte","ronnabytes"]},{symbol:"QB",factor:Ri**BigInt(10),names:["QB","quettabyte","quettabytes"]}],WZ=[iD[0],{symbol:"KiB",factor:rc,names:["KiB","kibibyte","kibibytes"]},{symbol:"MiB",factor:rc**BigInt(2),names:["MiB","mebibyte","mebibytes"]},{symbol:"GiB",factor:rc**BigInt(3),names:["GiB","gibibyte","gibibytes"]},{symbol:"TiB",factor:rc**BigInt(4),names:["TiB","tebibyte","tebibytes"]},{symbol:"PiB",factor:rc**BigInt(5),names:["PiB","pebibyte","pebibytes"]},{symbol:"EiB",factor:rc**BigInt(6),names:["EiB","exbibyte","exbibytes"]},{symbol:"ZiB",factor:rc**BigInt(7),names:["ZiB","zebibyte","zebibytes"]},{symbol:"YiB",factor:rc**BigInt(8),names:["YiB","yobibyte","yobibytes"]}],KZ=[...iD,...WZ.slice(1)],VZ=new Map(KZ.flatMap(e=>e.names.map(t=>[t,e])));var mw=e=>e;var vl=e=>{throw new Error(`Invalid ByteSize: ${e}`)},aD=e=>!Number.isSafeInteger(e)||e<0?vl(`expected a non-negative safe integer, received ${e}`):mw(BigInt(e));var cD=e=>{let t=/^\s*(\d+)(?:\.(\d+))?\s*([A-Za-z]+)\s*$/.exec(e);if(t===null)return vl(`unsupported syntax ${JSON.stringify(e)}`);let r=VZ.get(t[3]);if(r===void 0)return vl(`unsupported unit ${JSON.stringify(t[3])}`);let n=t[2]??"",o=BigInt(10)**BigInt(n.length),s=BigInt(t[1]+n)*r.factor;return s%o!==pw?vl(`${JSON.stringify(e)} does not represent an integral number of bytes`):mw(s/o)},uD=xs(cD),xy=e=>{switch(typeof e){case"bigint":return e<pw?vl(`expected a non-negative bigint, received ${e}`):mw(e);case"number":return aD(e);case"string":return cD(e)}return vl(`unsupported input ${e}`)},hw=xs(xy),fD=e=>typeof e=="bigint"?xy(e):aD(e);var lD=e=>typeof e=="bigint"&&e>=pw;var gy=e=>e,dD=oD;var mD="~effect/Chunk";function pD(e,t,r,n,o){for(let s=t;s<Math.min(e.length,t+o);s++)r[n+s-t]=e[s];return r}var hD=[],gw=e=>Wr((t,r)=>{if(t.length!==r.length)return!1;let n=vu(t),o=vu(r);for(let s=0;s<n.length;s++)if(!e(n[s],o[s]))return!1;return!0}),ZZ=gw(Z),QZ={[mD]:{_A:e=>e},toString(){return`Chunk(${H(vu(this))})`},toJSON(){return{_id:"Chunk",values:pr(vu(this))}},[Qe](){return this.toJSON()},[ae](e){return Al(e)&&ZZ(this,e)},[ie](){return ri(vu(this))},[Symbol.iterator](){switch(this.backing._tag){case"IArray":return this.backing.array[Symbol.iterator]();case"IEmpty":return hD[Symbol.iterator]();default:return vu(this)[Symbol.iterator]()}},pipe(){return V(this,arguments)}},yw=e=>{let t=Object.create(QZ);switch(t.backing=e,e._tag){case"IEmpty":{t.length=0,t.depth=0,t.left=t,t.right=t;break}case"IConcat":{t.length=e.left.length+e.right.length,t.depth=1+Math.max(e.left.depth,e.right.depth),t.left=e.left,t.right=e.right;break}case"IArray":{t.length=e.array.length,t.depth=0,t.left=la,t.right=la;break}case"ISingleton":{t.length=1,t.depth=0,t.left=la,t.right=la;break}case"ISlice":{t.length=e.length,t.depth=0,t.left=la,t.right=la;break}}return t},Al=e=>O(e,mD),la=yw({_tag:"IEmpty"}),YZ=()=>la;var XZ=e=>yw({_tag:"ISingleton",a:e}),Sw=e=>Al(e)?e:t5(At(e)),xw=(e,t,r)=>{switch(e.backing._tag){case"IArray":{pD(e.backing.array,0,t,r,e.length);break}case"IConcat":{xw(e.left,t,r),xw(e.right,t,r+e.left.length);break}case"ISingleton":{t[r]=e.backing.a;break}case"ISlice":{pD(vu(e.backing.chunk),e.backing.offset,t,r,e.length);break}}};var e5=e=>{switch(e.backing._tag){case"IEmpty":return hD;case"IArray":return e.backing.array;default:{let t=new Array(e.length);return xw(e,t,0),e.backing={_tag:"IArray",array:t},e.left=la,e.right=la,e.depth=0,t}}},vu=e5;var t5=e=>e.length===0?YZ():e.length===1?XZ(e[0]):yw({_tag:"IArray",array:e});var xD=e=>e.length;var Au=pl,gD=xu,yD=JN,SD=ZN,bD=QN,ED=y0,ID=YN;var by=Qg;var Ey=S0;var bw=eU,TD=tU;var Ew=rU;var Iw=b0,Tw=Fp,wD=E0;var vD=I0,tm=nU;var AD=Np;var CD=v0;var kD=sU;var ww=C0;var Cl=e=>r5(typeof e=="string"?n5.encode(e):e),Cu=e=>{let t=s5(e),r=t.length;if(r%4!==0)return re(new jo({kind:"Decode",module:"Base64",input:t,message:`Length must be a multiple of 4, but is ${r}`}));let n=t.indexOf("=");if(n!==-1&&(n<r-2||n===r-2&&t[r-1]!=="="))return re(new jo({kind:"Decode",module:"Base64",input:t,message:"Found a '=' character, but it is not at the end"}));try{let o=t.endsWith("==")?2:t.endsWith("=")?1:0,s=new Uint8Array(3*(r/4)-o);for(let i=0,a=0;i<r;i+=4,a+=3){let c=Iy(t.charCodeAt(i))<<18|Iy(t.charCodeAt(i+1))<<12|Iy(t.charCodeAt(i+2))<<6|Iy(t.charCodeAt(i+3));s[a]=c>>16,s[a+1]=c>>8&255,s[a+2]=c&255}return X(s)}catch(o){return re(new jo({kind:"Decode",module:"Base64",input:t,message:o instanceof Error?o.message:"Invalid input"}))}},RD=e=>Vr(Cu(e),t=>o5.decode(t)),r5=e=>{let t=e.length,r="",n;for(n=2;n<t;n+=3)r+=_s[e[n-2]>>2],r+=_s[(e[n-2]&3)<<4|e[n-1]>>4],r+=_s[(e[n-1]&15)<<2|e[n]>>6],r+=_s[e[n]&63];return n===t+1&&(r+=_s[e[n-2]>>2],r+=_s[(e[n-2]&3)<<4],r+="=="),n===t&&(r+=_s[e[n-2]>>2],r+=_s[(e[n-2]&3)<<4|e[n-1]>>4],r+=_s[(e[n-1]&15)<<2],r+="="),r},n5=new TextEncoder,o5=new TextDecoder,s5=e=>e.replace(/[\n\r]/g,""),_s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",rm=new Uint8Array(123).fill(255);for(let e=0;e<_s.length;e++)rm[_s.charCodeAt(e)]=e;rm[61]=0;var Iy=e=>{if(e>=rm.length||rm[e]===255)throw new TypeError(`Invalid character ${String.fromCharCode(e)}`);return rm[e]};var wy="~effect/HashMap",Ps=5,om=1<<Ps,i5=om/4,OD=om/2,a5=om-1,c5=e=>(e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),(e+(e>>>4)&252645135)*16843009>>>24),nm=(e,t)=>e>>>t&a5,nc=(e,t)=>1<<nm(e,t),Ty=(e,t)=>c5(e&t-1);function _D(e,t,r,n,o,s){if(t>32)throw new Error("HashMap: max depth exceeded");let i=nc(r,t),a=nc(o,t);if(i===a){let f=_D(e,t+Ps,r,n,o,s);return new Ou(e,i,[f])}let c=i|a,u=i>>>0<a>>>0?[n,s]:[s,n];return new Ou(e,c,u)}var u5=Be("HashMap"),PD=(e,t)=>he(G(e),G(t)),MD=e=>{let t=0;for(let r=0;r<e.length;r++){let n=e[r];n&&(t^=n.subtreeHash())}return t},ku=class{canEdit(t){return this.edit===t}subtreeHash(){let t=this._hash;if(t===void 0){let r=qc;t=this.computeHash(),r===qc&&(this._hash=t)}return t}},Cw=class extends ku{_tag="EmptyNode";edit=0;get size(){return 0}get(t,r,n){return _()}has(t,r,n){return!1}set(t,r,n,o,s,i){return i.value=!0,new Ru(t,n,o,s)}remove(t,r,n,o,s){return this}canEdit(t){return!1}computeHash(){return 0}},Ru=class e extends ku{_tag="LeafNode";edit;hash;key;value;constructor(t,r,n,o){super(),this.edit=t,this.hash=r,this.key=n,this.value=o}get size(){return 1}get(t,r,n){return this.hash===r&&Z(this.key,n)?N(this.value):_()}has(t,r,n){return this.hash===r&&Z(this.key,n)}set(t,r,n,o,s,i){if(this.canEdit(t)&&(this._hash=void 0),this.hash===n&&Z(this.key,o))return Z(this.value,s)?this:this.canEdit(t)?(this.value=s,this):new e(t,n,o,s);if(i.value=!0,this.hash===n)return new kw(t,n,[[this.key,this.value],[o,s]]);let a=nc(n,r),c=nc(this.hash,r);if(a===c)return new Ou(t,a,[this.set(t,r+Ps,n,o,s,i)]);let u=a|c,f=a>>>0<c>>>0?[new e(t,n,o,s),this]:[this,new e(t,n,o,s)];return new Ou(t,u,f)}remove(t,r,n,o,s){if(this.hash===n&&Z(this.key,o)){s.value=!0;return}return this}computeHash(){return PD(this.key,this.value)}},kw=class e extends ku{_tag="CollisionNode";edit;hash;entries;constructor(t,r,n){super(),this.edit=t,this.hash=r,this.entries=n}get size(){return this.entries.length}get(t,r,n){if(this.hash!==r)return _();for(let[o,s]of this.entries)if(Z(o,n))return N(s);return _()}has(t,r,n){if(this.hash!==r)return!1;for(let[o]of this.entries)if(Z(o,n))return!0;return!1}set(t,r,n,o,s,i){if(this.canEdit(t)&&(this._hash=void 0),this.hash!==n)return i.value=!0,_D(t,r,this.hash,this,n,new Ru(t,n,o,s));for(let a=0;a<this.entries.length;a++)if(Z(this.entries[a][0],o)){if(Z(this.entries[a][1],s))return this;if(this.canEdit(t))return this.entries[a]=[o,s],this;let c=[...this.entries];return c[a]=[o,s],new e(t,this.hash,c)}return i.value=!0,this.canEdit(t)?(this.entries.push([o,s]),this):new e(t,this.hash,[...this.entries,[o,s]])}remove(t,r,n,o,s){if(this.canEdit(t)&&(this._hash=void 0),this.hash!==n)return this;let i=this.entries.findIndex(([c])=>Z(c,o));if(i===-1)return this;if(s.value=!0,this.entries.length===1)return;if(this.entries.length===2){let c=this.entries[i===0?1:0];return new Ru(t,this.hash,c[0],c[1])}if(this.canEdit(t))return this.entries.splice(i,1),this;let a=[...this.entries];return a.splice(i,1),new e(t,this.hash,a)}computeHash(){let t=0,r=this.entries;for(let n=0;n<r.length;n++)t^=PD(r[n][0],r[n][1]);return t}},Ou=class e extends ku{_tag="IndexedNode";edit;_size;bitmap;children;constructor(t,r,n){super(),this.edit=t,this.bitmap=r,this.children=n}get size(){return this._size===void 0&&(this._size=this.children.reduce((t,r)=>t+r.size,0)),this._size}get(t,r,n){let o=nc(r,t);if((this.bitmap&o)===0)return _();let s=Ty(this.bitmap,o);return this.children[s].get(t+Ps,r,n)}has(t,r,n){let o=nc(r,t);if((this.bitmap&o)===0)return!1;let s=Ty(this.bitmap,o);return this.children[s].has(t+Ps,r,n)}set(t,r,n,o,s,i){this.canEdit(t)&&(this._hash=void 0);let a=nc(n,r),c=Ty(this.bitmap,a);if((this.bitmap&a)!==0){let u=this.children[c],f=u.set(t,r+Ps,n,o,s,i);if(u===f)return this;if(this.canEdit(t))return this.children[c]=f,this;let p=[...this.children];return p[c]=f,new e(t,this.bitmap,p)}else{i.value=!0;let u=new Ru(t,n,o,s),f=this.bitmap|a;if(this.canEdit(t))return this.children.splice(c,0,u),this.bitmap=f,this._size=void 0,this.children.length>OD?this.expand(t,f,this.children):this;let p=[...this.children];return p.splice(c,0,u),p.length>OD?this.expand(t,f,p):new e(t,f,p)}}remove(t,r,n,o,s){this.canEdit(t)&&(this._hash=void 0);let i=nc(n,r);if((this.bitmap&i)===0)return this;let a=Ty(this.bitmap,i),c=this.children[a],u=c.remove(t,r+Ps,n,o,s);if(!s.value)return this;if(u===void 0){let p=this.bitmap^i;if(p===0)return;if(this.children.length===2){let h=this.children[a===0?1:0];if(h._tag==="LeafNode")return h}if(this.canEdit(t))return this.children.splice(a,1),this.bitmap=p,this._size=void 0,this;let m=[...this.children];return m.splice(a,1),new e(t,p,m)}if(c===u)return this;if(this.canEdit(t))return this.children[a]=u,this;let f=[...this.children];return f[a]=u,new e(t,this.bitmap,f)}expand(t,r,n){let o=new globalThis.Array(om),s=0;for(let i=0;i<om;i++)(r&1<<i)!==0&&(o[i]=n[s++]);return new Rw(t,n.length,o)}computeHash(){return MD(this.children)}},Rw=class e extends ku{_tag="ArrayNode";edit;_size;count;children;constructor(t,r,n){super(),this.edit=t,this.count=r,this.children=n}get size(){return this._size===void 0&&(this._size=this.children.reduce((t,r)=>t+(r?.size??0),0)),this._size}get(t,r,n){let o=nm(r,t),s=this.children[o];return s?s.get(t+Ps,r,n):_()}has(t,r,n){let o=nm(r,t),s=this.children[o];return s?s.has(t+Ps,r,n):!1}set(t,r,n,o,s,i){this.canEdit(t)&&(this._hash=void 0);let a=nm(n,r),c=this.children[a];if(c){let u=c.set(t,r+Ps,n,o,s,i);if(c===u)return this;if(this.canEdit(t))return this.children[a]=u,this;let f=[...this.children];return f[a]=u,new e(t,this.count,f)}else{i.value=!0;let u=new Ru(t,n,o,s);if(this.canEdit(t))return this.children[a]=u,this.count++,this._size=void 0,this;let f=[...this.children];return f[a]=u,new e(t,this.count+1,f)}}remove(t,r,n,o,s){this.canEdit(t)&&(this._hash=void 0);let i=nm(n,r),a=this.children[i];if(!a)return this;let c=a.remove(t,r+Ps,n,o,s);if(!s.value)return this;let u=this.count-(c?0:1);if(u<i5)return this.pack(t,i,c);if(a===c)return this;if(this.canEdit(t))return this.children[i]=c,c||(this.count=u),this._size=void 0,this;let f=[...this.children];return f[i]=c,new e(t,u,f)}pack(t,r,n){let o=[],s=0,i=1;for(let a=0;a<this.children.length;a++){let c=a===r?n:this.children[a];c&&(o.push(c),s|=i),i<<=1}return new Ou(t,s,o)}computeHash(){return MD(this.children)}},vy=class{stack;project;entries=[];index=0;constructor(t,r){this.stack=[t],this.project=r}next(){for(;;){if(this.index<this.entries.length){let r=this.entries[this.index++];return{done:!1,value:this.project(r[0],r[1])}}if(this.stack.length===0)return{done:!0,value:void 0};let t=this.stack.pop();switch(t._tag){case"LeafNode":{let r=t;return{done:!1,value:this.project(r.key,r.value)}}case"CollisionNode":{this.entries=t.entries,this.index=0;break}case"IndexedNode":case"ArrayNode":{let r=t.children;for(let n=r.length-1;n>=0;n--){let o=r[n];o&&this.stack.push(o)}}}}}[Symbol.iterator](){return this}},f5=(e,t)=>[e,t];var sm=class{[wy]=wy;_editable;_edit;_root;_size;constructor(t,r,n,o){this._editable=t,this._edit=r,this._root=n,this._size=o}get size(){return this._size}[Symbol.iterator](){return new vy(this._root,f5)}[ae](t){if(Ow(t)){let r=t;if(this.size!==r.size)return!1;for(let[n,o]of this){let s=Ud(t,UD(n));if(fe(s)||!Z(o,s.value))return!1}return!0}return!1}[ie](){return _r(u5^this._root.subtreeHash())}[Qe](){return pr(this)}toString(){return`HashMap(${H(Array.from(this))})`}toJSON(){return{_id:"HashMap",values:Array.from(this).map(([t,r])=>[pr(t),pr(r)])}}pipe(){return V(this,arguments)}},FD=new Cw,Ow=e=>O(e,wy),_w=()=>new sm(!1,0,FD,0);var ND=e=>{let t=FD,r=0,n={value:!1};for(let[o,s]of e){let i=G(o);n.value=!1,t=t.set(NaN,0,i,o,s,n),n.value&&r++}return new sm(!1,0,t,r)};var UD=d(2,(e,t)=>e._root.get(0,G(t),t));var Pw=d(2,(e,t)=>e._root.has(0,G(t),t));var l5=(e,t,r,n)=>{let o=e,s={value:!1},i=o._editable?o._edit:NaN,a=o._root.set(i,0,r,t,n,s);return o._editable?(o._root=a,s.value&&o._size++,e):o._root===a?e:new sm(!1,o._edit,a,o._size+(s.value?1:0))},Mw=d(3,(e,t,r)=>l5(e,t,G(t),r)),Fw=e=>new vy(e._root,F);var DD=e=>e[Symbol.iterator](),Ay=e=>e.size;var Cy=Ow;var Nw=ND;var m5=DD,im=e=>Array.from(m5(e)),BD=Ay;var am="~effect/HashSet",h5=Be(am),x5={[ie](){return _r(he(h5,G(Ry(this))))},[ae](e){return Uw(e)&&Oy(this)===Oy(e)&&HD(this,t=>jD(e,t))},[Symbol.iterator](){return Fw(Ry(this))},toString(){return`HashSet(${H(Array.from(this))})`},toJSON(){return{_id:"HashSet",values:pr(Array.from(this))}},[Qe](){return this.toJSON()},pipe(){return V(this,arguments)}},g5=e=>{let t=Object.create(x5);return t[am]=am,t.keyMap=e,t},Uw=e=>O(e,am),Ry=e=>e.keyMap;var $D=e=>{let t=_w();for(let r of e)t=Mw(t,r,!0);return g5(t)},jD=(e,t)=>Pw(Ry(e),t);var Oy=e=>Ay(Ry(e));var HD=(e,t)=>{for(let r of e)if(!t(r))return!1;return!0};var Dw=$D,_y=Uw;var qD=Oy;var Lw="~effect/http/Cookies",WD=e=>O(e,Lw),Bw="~effect/http/Cookies/Cookie",KD=e=>O(e,Bw),zD="~effect/http/Cookies/CookieError",$w=class extends bP{},_u=class e extends sr("CookiesError"){static fromReason(t,r){return new e({reason:new $w({_tag:t,cause:r})})}[zD]=zD;get message(){return this.reason._tag}};var S5={[Lw]:Lw,...Ot,toJSON(){return{_id:"effect/Cookies",cookies:Dx(this.cookies,e=>e.toJSON())}},pipe(){return V(this,arguments)}},Hw=e=>{let t=Object.create(S5);return t.cookies=e,t},qw=e=>{let t={};for(let r of e)B(t,r.name,r);return Hw(t)},My=e=>{let t=typeof e=="string"?[e]:e,r=[];for(let n of t){let o=b5(n.trim());o&&r.push(o)}return qw(r)};function b5(e){let t=e.split(";").map(a=>a.trim()).filter(a=>a!=="");if(t.length===0)return;let r=t[0].indexOf("=");if(r===-1)return;let n=t[0].slice(0,r);if(!VD.test(n))return;let o=t[0].slice(r+1),s=A5(o);if(t.length===1)return Object.assign(Object.create(jw),{name:n,value:s,valueEncoded:o});let i={};for(let a=1;a<t.length;a++){let c=t[a],u=c.indexOf("="),f=u===-1?c:c.slice(0,u).trim(),p=u===-1?void 0:c.slice(u+1).trim();switch(f.toLowerCase()){case"domain":{if(p===void 0)break;let m=p.trim().replace(/^\./,"");m&&(i.domain=m);break}case"expires":{if(p===void 0)break;let m=new Date(p);isNaN(m.getTime())||(i.expires=m);break}case"max-age":{if(p===void 0)break;let m=parseInt(p,10);isNaN(m)||(i.maxAge=fp(m));break}case"path":{if(p===void 0)break;p[0]==="/"&&(i.path=p);break}case"priority":{if(p===void 0)break;switch(p.toLowerCase()){case"low":i.priority="low";break;case"medium":i.priority="medium";break;case"high":i.priority="high";break}break}case"httponly":{i.httpOnly=!0;break}case"secure":{i.secure=!0;break}case"partitioned":{i.partitioned=!0;break}case"samesite":{if(p===void 0)break;switch(p.toLowerCase()){case"lax":i.sameSite="lax";break;case"strict":i.sameSite="strict";break;case"none":i.sameSite="none";break}break}}}return Object.assign(Object.create(jw),{name:n,value:s,valueEncoded:o,options:Object.keys(i).length>0?i:void 0})}var E5=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,VD=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,I5=/^[\u0009\u0020-\u003a\u003c-\u007e\u0080-\u00ff]+$/,T5=/^[\u0020-\u003a\u003c-\u007e]+$/,jw={[Bw]:Bw,...Ot,toJSON(){return{_id:"effect/Cookies/Cookie",name:this.name,value:this.value,options:this.options}}};function w5(e,t,r){let n=encodeURIComponent(t),o=GD(e,n,r);return o!==void 0?re(o):X(Object.assign(Object.create(jw),{name:e,value:t,valueEncoded:n,options:r}))}function GD(e,t,r){if(!VD.test(e))return _u.fromReason("InvalidCookieName");if(t&&!E5.test(t))return _u.fromReason("InvalidCookieValue");if(r?.domain!==void 0&&!I5.test(r.domain))return _u.fromReason("InvalidCookieDomain");if(r?.path!==void 0&&!T5.test(r.path))return _u.fromReason("InvalidCookiePath");if(r?.maxAge!==void 0&&!Wn($e(r.maxAge)))return _u.fromReason("CookieInfinityMaxAge")}var JD=(e,t,r)=>ru(w5(e,t,r));function v5(e){let t=GD(e.name,e.valueEncoded,e.options);if(t!==void 0)throw t;let r=e.name+"="+e.valueEncoded;if(e.options===void 0)return r;let n=e.options;if(n.maxAge!==void 0){let o=ui($e(n.maxAge));r+="; Max-Age="+Math.trunc(o)}if(n.domain!==void 0&&(r+="; Domain="+n.domain),n.path!==void 0&&(r+="; Path="+n.path),n.priority!==void 0)switch(n.priority){case"low":r+="; Priority=Low";break;case"medium":r+="; Priority=Medium";break;case"high":r+="; Priority=High";break}if(n.expires!==void 0&&(r+="; Expires="+n.expires.toUTCString()),n.httpOnly&&(r+="; HttpOnly"),n.secure&&(r+="; Secure"),n.partitioned&&(r+="; Partitioned"),n.sameSite!==void 0)switch(n.sameSite){case"lax":r+="; SameSite=Lax";break;case"strict":r+="; SameSite=Strict";break;case"none":r+="; SameSite=None";break}return r}var ZD=e=>{let t={},r=Object.values(e.cookies);for(let n=0;n<r.length;n++){let o=r[n];B(t,o.name,o.value)}return t},QD=e=>Object.values(e.cookies).map(v5);var A5=e=>{try{return decodeURIComponent(e)}catch{return e}};var Pu=new WeakMap,YD=e=>{if(Pu.has(e))return Pu.get(e);throw new Error("Unable to get redacted value"+(e.label?` with label: "${e.label}"`:""))};var XD="~effect/Redacted",cm=e=>O(e,XD),Mu=(e,t)=>{let r=Object.create(k5);return t?.label&&(r.label=t.label),Pu.set(r,e),r},k5={[XD]:{_A:e=>e},label:void 0,...wr,toJSON(){return this.toString()},toString(){return`<redacted${On(this.label)?":"+this.label:""}>`},[ie](){return G(Pu.get(this))},[ae](e){return cm(e)&&Z(Pu.get(this),Pu.get(e))}},oc=YD;var e1=e=>Wr((t,r)=>e(oc(t),oc(r)));var Ww=Symbol.for("~effect/http/Headers"),t1=e=>O(e,Ww),um=Object.defineProperties(Object.create(null),{[Ww]:{value:Ww},[Wc]:{value(e){return R5(this,Re(e,Vw))}},toJSON:{value(){return ho(this)}},[ae]:{value(e){return Kw(this,e)}},[ie]:{value(){return qd(this)}},toString:{value:Ot.toString},[Qe]:{value:Ot[Qe]}}),Ny=e=>Object.assign(Object.create(um),e),Kw=Q_(Yc()),kl=Object.create(um),Zo=e=>{if(e===void 0)return kl;if(Symbol.iterator in e){let r=Object.create(um);for(let[n,o]of e)r[n.toLowerCase()]=o;return r}let t=Object.create(um);for(let[r,n]of Object.entries(e))Array.isArray(n)?t[r.toLowerCase()]=n.join(", "):n!==void 0&&(t[r.toLowerCase()]=n);return t},r1=e=>Object.setPrototypeOf(e,um);var fm=d(3,(e,t,r)=>{let n=Ny(e);return n[t.toLowerCase()]=r,n}),n1=d(2,(e,t)=>Ny({...e,...Zo(t)})),Rl=d(2,(e,t)=>{let r=Ny(e);return Object.assign(r,t),r}),sc=d(2,(e,t)=>{let r=Ny(e);return delete r[t.toLowerCase()],r});var R5=d(2,(e,t)=>{let r={...e},n=o=>{if(typeof o=="string"){let s=o.toLowerCase();s in e&&(r[s]=Mu(e[s]))}else for(let s in e)s.search(o)!==-1&&(r[s]=Mu(e[s]))};if(Array.isArray(t))for(let o=0;o<t.length;o++)n(t[o]);else n(t);return r}),o1=(e,t)=>{for(let r=0;r<t.length;r++){let n=t[r];if(typeof n=="string"){if(n.toLowerCase()===e.toLowerCase())return!0}else if(e.search(n)!==-1)return!0}return!1},Vw=Ae("effect/Headers/CurrentRedactedNames",{defaultValue:()=>["authorization","cookie","set-cookie","x-api-key","AWSAccessKeyId","Signature","sig","X-Goog-Signature"]});var Gw="~effect/http/UrlParams",Jw=e=>O(e,Gw),O5={...wr,[Gw]:Gw,[Symbol.iterator](){return this.params[Symbol.iterator]()},toJSON(){return{_id:"UrlParams",params:Object.fromEntries(this.params)}},[ae](e){return Zw(this,e)},[ie](){return ri(this.params.flat())}},Ol=e=>{let t=Object.create(O5);return t.params=e,t},Fu=e=>{if(Jw(e))return e;let t=s1(e),r=[];for(let n=0;n<t.length;n++)if(Array.isArray(t[n][0])){let[o,s]=t[n];r.push([`${o[0]}[${o.slice(1).join("][")}]`,s])}else r.push(t[n]);return Ol(r)},s1=e=>{let t=typeof e[Symbol.iterator]=="function"?At(e):Object.entries(e),r=[];for(let[n,o]of t)if(Array.isArray(o))for(let s=0;s<o.length;s++)o[s]!==void 0&&r.push([n,String(o[s])]);else if(o!==null&&typeof o=="object"){let s=s1(o);for(let[i,a]of s)r.push([[n,...typeof i=="string"?[i]:i],a])}else o!==void 0&&r.push([n,String(o)]);return r},Zw=Wr((e,t)=>_5(e.params,t.params)),_5=tP(z_([Yc(),Yc()])),i1=Ol([]);var a1=d(2,(e,t)=>$I(e.params,([r])=>r===t).pipe(Lt(([,r])=>r)));var c1=d(2,(e,t)=>{let r=Fu(t).params.slice(),n=new Set;for(let o=0;o<r.length;o++)n.add(r[o][0]);for(let o=0;o<e.params.length;o++)n.has(e.params[o][0])||r.push(e.params[o]);return Ol(r)});var P5=e=>{let t={};for(let[r,n]of e.params)if(!Object.hasOwn(t,r))B(t,r,n);else{let o=t[r];typeof o=="string"?B(t,r,[o,n]):o.push(n)}return t},u1=P5;var Qw="~effect/Graph",Yw=e=>O(e,Qw),f1=e=>e;var M5=(e,t,r)=>(e==="directed"?t.source===r.source&&t.target===r.target:t.source===r.source&&t.target===r.target||t.source===r.target&&t.target===r.source)&&Z(t.data,r.data),F5=(e,t)=>e==="directed"?G(t):_r(he(G(t.data),N5(t.source,t.target))),N5=(e,t)=>he(0,G(e))+he(0,G(t)),U5=Be("Graph"),D5={[Qw]:{_N:e=>e,_E:e=>e},[Symbol.iterator](){return this.nodes[Symbol.iterator]()},[Qe](){return this.toJSON()},[ae](e){if(O(e,Qw)){let t=f1(e);if(this.nodes.size!==t.nodes.size||this.edges.size!==t.edges.size||this.type!==t.type)return!1;for(let[r,n]of this.nodes)if(!t.nodes.has(r)||!Z(n,t.nodes.get(r)))return!1;for(let[r,n]of this.edges){let o=t.edges.get(r);if(o===void 0||!M5(this.type,n,o))return!1}return!0}return!1},[ie](){let e=U5;e=e^Be(this.type),e=e^zt(this.nodes.size),e=e^zt(this.edges.size);for(let[t,r]of this.nodes)e^=he(G(t),G(r));for(let[t,r]of this.edges)e^=he(G(t),F5(this.type,r));return _r(e)},toJSON(){return{_id:"Graph",nodeCount:this.nodes.size,edgeCount:this.edges.size,type:this.type}},toString(){return`Graph(${this.type}, ${this.nodes.size}, ${this.edges.size})`},pipe(){return V(this,arguments)}},L5=(e,t)=>{let r=Object.create(D5);return r.type=e,r.mutable=t,r.transforming=!1,r.nodes=new Map,r.edges=new Map,r.adjacency=new Map,r.reverseAdjacency=new Map,r.nextNodeIndex=0,r.nextEdgeIndex=0,r.acyclic=N(!0),r};var lm=e=>{let t=f1(e);return{type:e.type,nodes:Array.from(t.nodes,([r,n])=>({index:r,data:n})).sort((r,n)=>r.index-n.index),edges:Array.from(t.edges,([r,n])=>({index:r,source:n.source,target:n.target,data:n.data})).sort((r,n)=>r.index-n.index)}},Dy=e=>{let t=L5(e.type,!1);for(let r of e.nodes)t.nodes.set(r.index,r.data),t.adjacency.set(r.index,[]),t.reverseAdjacency.set(r.index,[]);for(let r of e.edges)t.edges.set(r.index,{source:r.source,target:r.target,data:r.data}),t.adjacency.get(r.source).push(r.index),t.reverseAdjacency.get(r.target).push(r.index),e.type==="undirected"&&(t.adjacency.get(r.target).push(r.index),t.reverseAdjacency.get(r.source).push(r.index));return t.nextNodeIndex=e.nodes.length===0?0:e.nodes[e.nodes.length-1].index+1,t.nextEdgeIndex=e.edges.length===0?0:e.edges[e.edges.length-1].index+1,t.acyclic=_(),t};function da(e){return e.checks?e.checks[e.checks.length-1].annotations:e.annotations}function Ly(e){return t=>da(t)?.[e]}var ro="~structural",Nu="~identifier",dm="~sentinels",By="~constructor",l1=["title","description","default","examples","readOnly","writeOnly","format","contentEncoding","contentMediaType","contentSchema"],_l=Ly("identifier"),Xw=Ly(Nu),ev=Ly("title");var pm=mo(e=>{let t=da(e)?.identifier;return typeof t=="string"?t:e.getExpected(pm)}),d1=new Set([dm,ro,"representation","arbitraryConstraint","toJsonSchema","toCode","toEquivalence","toFormatter","toCodec","toCodecJson","toCodecStringTree","toCodecIso","toCodecArbitrary"]);var ve=Symbol();var Dr=Mr,no=Dr(ve),nt=Dr(ve),mm=e=>e===ve?_():N(e),tv=e=>e._tag==="None"?no:Dr(e.value);var xm="~effect/SchemaIssue/Issue";function nv(e){return O(e,xm)&&e[xm]===xm}function $5(e){return Object.hasOwn(e,"input")}var Co=class{[xm]=xm;constructor(t,r){r?.reportInput===!0&&t!==ve&&(this.input=t)}},p1=class extends Co{_tag="Filter";filter;issue;constructor(e,t,r,n){super(r,n),this.filter=e,this.issue=t}},m1=class extends Co{_tag="Encoding";ast;issue;constructor(e,t,r,n){super(r,n),this.ast=e,this.issue=t}},Ct=class extends Co{_tag="Pointer";path;issue;constructor(e,t){super(),this.path=e,this.issue=t}},Yt=class extends Co{_tag="MissingKey";annotations;constructor(e){super(),this.annotations=e}},Uu=class extends Co{_tag="UnexpectedKey";ast;constructor(e,t,r){super(t,r),this.ast=e}},Ft=class extends Co{_tag="Composite";ast;issues;constructor(e,t,r,n){super(r,n),this.ast=e,this.issues=t}},at=class extends Co{_tag="InvalidType";ast;constructor(e,t,r){super(t,r),this.ast=e}},le=class extends Co{_tag="InvalidValue";annotations;constructor(e,t,r){super(t,r),this.annotations=e}};function tn(e,t,r,n,o){return new Ft(e,[new Ct([t],r)],n,o)}var gm=class extends Co{_tag="Forbidden";annotations;constructor(e,t,r){super(t,r),this.annotations=e}},ym=class extends Co{_tag="AnyOf";ast;issues;constructor(e,t,r,n){super(r,n),this.ast=e,this.issues=t}},h1=class extends Co{_tag="OneOf";ast;successes;constructor(e,t,r,n){super(r,n),this.ast=e,this.successes=t}};function rv(e,t,r){if(nv(e))return e;if(typeof e=="string")return new le({message:e},t,r);let n=typeof e.issue=="string"?new le({message:e.issue},t,r):e.issue;return new Ct(e.path,n)}function x1(e,t,r){if(e!==void 0)return typeof e=="boolean"?e?void 0:new le(void 0,t,r):rv(e,t,r)}function g1(e,t,r,n){return Array.isArray(t)?bt(t)?t.length===1?rv(t[0],r,n):new Ft(e,Bo(t,o=>rv(o,r,n)),r,n):void 0:x1(t,r,n)}var y1=e=>{let t=Fl(e);if(t!==void 0)return t;switch(e._tag){case"InvalidType":return ac(pm(e.ast),e);case"InvalidValue":{let r=ov(e);if(r!==void 0)return ac(r,e);let n=$y(e);return n===void 0?"Expected a valid value":`Invalid data ${n}`}case"MissingKey":return"Missing key";case"UnexpectedKey":{let r=$y(e);return r===void 0?"Expected no excess property":`Unexpected key with value ${r}`}case"Forbidden":return"Forbidden operation";case"OneOf":{let r=$y(e);return r===void 0?"Expected exactly one member to match":`Expected exactly one member to match the input ${r}`}}},S1=e=>Fl(e.issue)??Fl(e);function b1(e){return t=>({issues:Ml(t,[],e?.leafHook??y1,e?.checkHook??S1)})}function $y(e){return $5(e)?H(e.input):void 0}function ov(e){let t=e.annotations?.expected;return typeof t=="string"?t:void 0}function ac(e,t){let r=$y(t);return r===void 0?`Expected ${e}`:`Expected ${e}, got ${r}`}function Ml(e,t,r,n){switch(e._tag){case"Filter":{let o=n(e);if(o!==void 0)return[{path:t,message:o}];if(e.issue._tag!=="InvalidValue")return Ml(e.issue,t,r,n);let s=ov(e.issue);return[{path:t,message:s===void 0?ac(sv(e.filter),e):ac(s,e.issue)}]}case"Encoding":return Ml(e.issue,t,r,n);case"Pointer":return Ml(e.issue,[...t,...e.path],r,n);case"Composite":return e.issues.flatMap(o=>Ml(o,t,r,n));case"AnyOf":return e.issues.length===0?[{path:t,message:Fl(e)??ac(pm(e.ast),e)}]:e.issues.flatMap(o=>Ml(o,t,r,n));default:return[{path:t,message:r(e)}]}}function sv(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(r=>sv(r)).join(" & ")}}function j5(){return e=>hm(e,"")}var E1=j5();function hm(e,t){let r;switch(e._tag){case"Filter":{let n=S1(e);if(n!==void 0)r=n;else{if(e.issue._tag!=="InvalidValue")return hm(e.issue,t);let o=ov(e.issue);r=o===void 0?ac(sv(e.filter),e):ac(o,e.issue)}break}case"Encoding":return hm(e.issue,t);case"Pointer":return hm(e.issue,t+Sx(e.path));case"Composite":case"AnyOf":{if(e._tag==="Composite"||e.issues.length>0)return e.issues.map(n=>hm(n,t)).join(`
25
+ `);r=Fl(e)??ac(pm(e.ast),e);break}default:r=y1(e);break}return t?`${r}
26
+ at ${t}`:r}function Fl(e){if(e._tag==="Pointer")return;if(e._tag==="Encoding")return Fl(e.issue);let r=(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 r=="string")return r}function Sm(e){let t;for(let r of e.reasons){if(!Ng(r)||!nv(r.error))return;t??=r.error}return t}function ko(e,t){let r=Sm(e);if(r===void 0)throw new Error(t,{cause:e});return r}var T1=e=>Cl(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"),iv=e=>{let t=e.replace(/[\n\r]/g,""),r=t.length;if(r%4===1)return re(new jo({module:"Base64Url",kind:"Decode",input:t,message:`Length should be a multiple of 4, but is ${r}`}));if(!/^[-_A-Z0-9]*?={0,2}$/i.test(t))return re(new jo({module:"Base64Url",kind:"Decode",input:t,message:"Invalid input"}));let n=r%4===2?`${t}==`:r%4===3?`${t}=`:t;return n=n.replace(/-/g,"+").replace(/_/g,"/"),Cu(n)},w1=e=>Vr(iv(e),t=>H5.decode(t)),H5=new TextDecoder;var bm=e=>Object.assign(Object.create(iI),e);function z5(e){return A1((t,r)=>D(e(t,r)))}function jy(e){return z5((t,r)=>{let n={message:e(t)};return de(t)?new gm(n,t.value,r):new gm(n)})}var v1=jy(()=>"Encoding is not supported"),W5=bm({_tag:"Passthrough"});function Oi(){return W5}function Ie(e){return bm({_tag:"Transform",transform:e})}function rn(e){return bm({_tag:"TransformEffect",transform:e})}function Hy(e){return bm({_tag:"TransformOptional",transform:e})}function A1(e){return bm({_tag:"TransformOptionalEffect",transform:e})}function av(){return Hy(()=>_())}function cv(e){return A1(t=>{let r=Na(t,ei);return de(r)?I(r):Iu(e,N)})}function Du(){return Ie(globalThis.String)}function qy(){return Ie(globalThis.Number)}function C1(){return Ie(globalThis.BigInt)}function uv(){return Ie(e=>new globalThis.Date(e))}function k1(){return Ie(uU)}function R1(e){return rn((t,r)=>Go({try:()=>JSON.parse(t,e?.reviver),catch:()=>new le({expected:"a valid JSON string"},t,r)}))}function O1(e){return rn((t,r)=>Go({try:()=>{let n=JSON.stringify(t,e?.replacer,e?.space);if(n===void 0)throw new TypeError("Value cannot be represented as JSON");return n},catch:()=>new le({expected:"a JSON-serializable value"},t,r)}))}function fv(){return Ie(Cl)}function zy(){return Ie(T1)}function Wy(){return Ie(Gx)}function _1(){return rn((e,t)=>Tu(H0(Cu(e)),()=>new le({expected:"a valid Base64 string"},e,t)))}function P1(){return rn((e,t)=>zn(RD(e),{onFailure:()=>D(new le({expected:"a valid Base64 string"},e,t)),onSuccess:I}))}function M1(){return rn((e,t)=>zn(iv(e),{onFailure:()=>D(new le({expected:"a valid Base64Url string"},e,t)),onSuccess:I}))}function F1(){return rn((e,t)=>zn(w1(e),{onFailure:()=>D(new le({expected:"a valid Base64Url string"},e,t)),onSuccess:I}))}function N1(){return rn((e,t)=>zn(JI(e),{onFailure:()=>D(new le({expected:"a valid hexadecimal string"},e,t)),onSuccess:I}))}function U1(){return rn((e,t)=>zn(wP(e),{onFailure:()=>D(new le({expected:"a valid hexadecimal string"},e,t)),onSuccess:I}))}function D1(){return Ie(encodeURIComponent)}function L1(){return rn((e,t)=>{try{return I(globalThis.decodeURIComponent(e))}catch{return D(new le({expected:"a valid URI component"},e,t))}})}function B1(){return Ie(e=>q1(Array.from(e.entries())))}var K5=z1(e=>typeof e=="string"||typeof Blob<"u"&&e instanceof Blob);function $1(){return Ie(e=>{let t=new FormData;return typeof e=="object"&&e!==null&&K5(e).forEach(([n,o])=>{t.append(n,o)}),t})}function j1(){return Ie(e=>q1(Array.from(e.entries())))}var V5=z1(On);function H1(){return Ie(e=>typeof e=="object"&&e!==null?new URLSearchParams(V5(e)):new URLSearchParams)}function G5(e){if(e==="")return[""];let t=e.replace(/\[(.*?)\]/g,".$1"),r=t.split("."),n=t.startsWith(".")?1:0;return r.slice(n).map(o=>jx(o)?globalThis.Number(o):o)}var J5=20;function q1(e){let t={},r=new WeakSet,n=new WeakSet,o=new Map;e.forEach(([s,i])=>{let a=G5(s),c=t;for(let u=0;u<a.length;u++){let f=o.get(c),p=a[u]===""&&f!==void 0?f.length:a[u];f!==void 0&&typeof p=="number"&&(f.length=Math.max(f.length,p+1));let m=Object.hasOwn(c,p),h=m?c[p]:void 0;if(u===a.length-1){let x=o.get(h);if(x!==void 0)B(h,x.length++,i);else if(n.has(h))h.push(i);else if(m){let g=[h,i];n.add(g),B(c,p,g)}else B(c,p,i)}else{let x=a[u+1],g=typeof x=="number"||x==="";if(r.has(h)&&o.has(h)===g)c=h;else{let y={};r.add(y),g&&o.set(y,{parent:c,key:p,length:0}),B(c,p,y),c=y}}}});for(let[s,{key:i,length:a,parent:c}]of Array.from(o).reverse())c[i]===s&&a-Object.keys(s).length<=J5&&B(c,i,Object.assign(new Array(a),s));return t}function z1(e){return t=>{let r=[];function n(o,s){if(e(s))r.push([o,s]);else if(Array.isArray(s))s.every(e)?s.forEach(a=>{r.push([o,a])}):s.forEach((a,c)=>{n(`${o}[${c}]`,a)});else if(typeof s=="object"&&s!==null)for(let[i,a]of Object.entries(s))n(`${o}[${i}]`,a)}for(let[o,s]of Object.entries(t))n(o,s);return r}}var Ky=class extends Oa{_tag="Middleware";decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new Ky(this.encode,this.decode)}},Im="~effect/SchemaTransformation/Transformation",et=class extends Oa{[Im]=Im;_tag="Transformation";decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new et(this.encode,this.decode)}};function Z5(e){return O(e,Im)&&e[Im]===Im}var Vy=e=>Z5(e)?e:new et(e.decode,e.encode);function Xt(e){return new et(rn(e.decode),rn(e.encode))}function Fe(e){return new et(Ie(e.decode),Ie(e.encode))}function Gy(e){return new et(Hy(e.decode),Hy(e.encode))}function W1(){return new et(k1(),Oi())}var Q5=new et(Oi(),Oi());function Nl(){return Q5}var Ul=new et(qy(),Du()),Jy=new et(C1(),Du()),lv=new et(uv(),Ie(xI)),K1=new et(uv(),Ie(e=>e.getTime()));var dv=Xt({decode:(e,t)=>Zt(uD(e),{onNone:()=>D(new le({expected:"a valid ByteSize string"},e,t)),onSome:I}),encode:e=>I(`${e} ${e===BigInt(1)?"byte":"bytes"}`)}),V1=Xt({decode:(e,t)=>Zt(hw(e),{onNone:()=>D(new le({expected:"a non-negative bigint byte count"},e,t)),onSome:I}),encode:e=>I(gy(e))}),G1=Xt({decode:(e,t)=>Zt(hw(e),{onNone:()=>D(new le({expected:"a non-negative safe-integer byte count"},e,t)),onSome:I}),encode:(e,t)=>Zt(dD(e),{onNone:()=>D(new le({expected:"a ByteSize representable as a safe integer"},e,t)),onSome:I})}),Y5=e=>Jt(e)&&typeof e.message=="string",J1=e=>{let r=Object.hasOwn(e,"cause")?new Error(e.message,{cause:Q1(e.cause)}):new Error(e.message);return typeof e.name=="string"&&e.name!=="Error"&&(r.name=e.name),typeof e.stack=="string"&&(r.stack=e.stack),r},X5=e=>{try{let t=Kc(e);return t===void 0?H(e):JSON.parse(t)}catch{return H(e)}},eQ=(e,t,r)=>{let n={name:e.name,message:typeof e.message=="string"?e.message:""};return t?.includeStack&&typeof e.stack=="string"&&(n.stack=e.stack),!t?.excludeCause&&e.cause!==void 0&&(n.cause=r(e.cause)),n},Z1=e=>{let t=new WeakSet,r=n=>{if(HO(n)){if(t.has(n))return"[Circular]";t.add(n);let o=eQ(n,e,r);return t.delete(n),o}return X5(n)};return r},Q1=e=>Y5(e)?J1(e):e,Y1=e=>Fe({decode:J1,encode:t=>Z1(e)(t)}),X1=e=>Fe({decode:Q1,encode:Z1(e)});function e2(){return Fe({decode:RI,encode:sp})}function t2(){return Fe({decode:kI,encode:_n})}function r2(e){return Fe({decode:eu,encode:e?.onNoneEncoding===null?sp:_n})}function n2(){return Gy({decode:N,encode:tu})}function o2(){return Gy({decode:e=>e.pipe(Na(ei),N),encode:tu})}var pv=Xt({decode:(e,t)=>URL.canParse(e)?I(new URL(e)):D(new le({expected:"a valid URL string"},e,t)),encode:e=>I(e.href)});var mv=new et(_1(),fv()),s2=new et(P1(),fv()),i2=new et(F1(),zy()),a2=new et(U1(),Wy()),c2=new et(L1(),D1());function u2(e){return new et(R1(e??{}),O1(e))}var f2=new et(B1(),$1()),l2=new et(j1(),H1());function uc(e){return t=>t._tag===e}var jl=uc("Declaration");var tQ=uc("Never");var Bl=uc("Literal"),xv=uc("UniqueSymbol");var wv=uc("Arrays"),rQ=uc("Objects"),b2=uc("Union"),E2=uc("Suspend"),jt=class{to;transformation;constructor(e,t){this.to=e,this.transformation=t}},nn={},Yo=class{isOptional;isMutable;constructorDefault;annotations;constructor(e,t,r=void 0,n=void 0){this.isOptional=e,this.isMutable=t,this.constructorDefault=r,this.annotations=n}},d2="~effect/Schema",Gt=class{[d2]=d2;annotations;checks;encoding;context;constructor(t=void 0,r=void 0,n=void 0,o=void 0){this.annotations=t,this.checks=r,this.encoding=n,this.context=o}toString(){return`<${this._tag}>`}},fc=class extends Gt{_tag="Declaration";typeParameters;run;encodingChecks;encodingRun;constructor(e,t,r,n,o,s,i,a){super(r,n,o,s),this.typeParameters=e,this.run=t,this.encodingChecks=i,this.encodingRun=a}getParser(){let e;return(t,r)=>t===ve?no:(e??=this.run(this.typeParameters))(t,this,r)}_rebuild(e,t,r,n,o){let s=Bu(this.typeParameters,e);return s===this.typeParameters&&t===this.checks&&r===this.encodingChecks&&n===this.run&&o===this.encodingRun?this:new fc(s,n,this.annotations,t,void 0,this.context,r,o)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks,this.run,this.encodingRun)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks,this.encodingRun??this.run,this.run)}getExpected(){let e=this.annotations?.expected;return typeof e=="string"?e:"<Declaration>"}},nQ=class extends Gt{_tag="Null";getParser(){return sS(this,null)}getExpected(){return"null"}},vv=new nQ;var oQ=class extends Gt{_tag="Undefined";getParser(){return sS(this,void 0)}toCodecJson(){return lt(this,[I2])}getExpected(){return"undefined"}},I2=new jt(vv,new et(Ie(()=>{}),Ie(()=>null))),Av=new oQ;var sQ=class extends Gt{_tag="Void";getParser(){let e=Dr(void 0);return t=>t===ve?no:e}toCodecJson(){return lt(this,[I2])}getExpected(){return"void"}},T2=new sQ;var iQ=class extends Gt{_tag="Never";getParser(){return Ns(this,jO)}getExpected(){return"never"}},Cv=new iQ,aQ=class extends Gt{_tag="Any";getParser(){return Ns(this,uI)}getExpected(){return"any"}},w2=new aQ,cQ=class extends Gt{_tag="Unknown";getParser(){return Ns(this,uI)}getExpected(){return"unknown"}},pa=new cQ,uQ=class extends Gt{_tag="ObjectKeyword";getParser(){return Ns(this,jd)}getExpected(){return"object | array | function"}},v2=new uQ,A2=class extends Gt{_tag="Enum";enums;constructor(e,t,r,n,o){super(t,r,n,o);for(let[,s]of e)if(typeof s=="number"&&!globalThis.Number.isFinite(s))throw new Error(`A numeric enum value must be finite, got ${H(s)}`);this.enums=e}getParser(){let e=new Set(this.enums.map(([,t])=>t));return Ns(this,t=>e.has(t))}toCodecStringTree(){if(this.enums.some(([e,t])=>typeof t=="number")){let e=Object.fromEntries(this.enums.map(([t,r])=>[globalThis.String(r),r]));return lt(this,[new jt(new Sn(Object.keys(e).map(t=>new Ln(t))),new et(Ie(t=>e[t]),Du()))])}return this}getExpected(){return this.enums.map(([e,t])=>JSON.stringify(t)).join(" | ")}};function hv(e){return typeof e=="number"?`parts[${e}]`:e}function gv(e,t,r){if(r.has(e))return!0;if(e.encoding)throw new Error(`TemplateLiteral parts cannot have an encoding at ${hv(t)}`);let n;switch(e._tag){case"String":case"Number":case"BigInt":n=!0;break;case"Literal":n=!e.checks;break;case"TemplateLiteral":{let o=hv(t);n=!e.checks&&e.parts.every((s,i)=>gv(s,`${o}.parts[${i}]`,r));break}case"Union":{let o=hv(t);n=!e.checks&&e.types.every((s,i)=>gv(s,`${o}.types[${i}]`,r));break}default:return!1}return n&&r.add(e),n}var kv=class extends Gt{_tag="TemplateLiteral";parts;encodedParts;literals;suffixLengths;constructor(e,t,r,n,o){super(t,r,n,o);let s=[],i=[],a=new Set;for(let u=0;u<e.length;u++){let f=e[u];if(!gv(f,u,a))throw new Error(`Invalid TemplateLiteral part ${f._tag}`);s.push(f),i.push(f._tag==="Literal"?globalThis.String(f.literal):void 0)}let c=new Array(s.length+1);c[s.length]=0;for(let u=s.length-1;u>=0;u--)c[u]=c[u+1]+(i[u]?.length??0);this.parts=e,this.encodedParts=s,this.literals=i,this.suffixLengths=c}getParser(e){let t=new Xo(!1,this.parts.map(jv),[]),r=e(Kl(Ro,t,k2(this)));return(n,o)=>{if(n===ve)return no;let s=r(n,o);return s._tag==="Success"?nt:cr(s,{onSuccess:()=>n,onFailure:i=>new Ft(this,[i],n,o)})}}getExpected(){return"string"}matchPart(e,t){return eL(this,e,t)===void 0?void 0:e}};function C2(e){let t=mo(o=>{if(o._tag!=="Union")return o;let s=Bu(o.types,t);return(o.options?.mode??"anyOf")==="anyOf"&&s===o.types?o:new Sn(s,o.options===void 0?void 0:{...o.options,mode:"anyOf"},o.annotations,o.checks,void 0,o.context)}),r=new kv(e.map(o=>t(Bn(o)))),n=new Xo(!1,e.map(jv),[]);return Kl(r,n,k2(r))}function k2(e){return new et(rn((t,r)=>{let n=eL(e,t,r);return n?I(n):D(new le({expected:"a string matching template literal parts"},t,r))}),Ie(t=>t.join("")))}var R2=class extends Gt{_tag="UniqueSymbol";symbol;constructor(e,t,r,n,o){super(t,r,n,o),this.symbol=e}getParser(){return sS(this,this.symbol)}toCodecStringTree(){let e=globalThis.Symbol.keyFor(this.symbol);return lt(this,[new jt(e===void 0?Cv:new Ln(globalThis.String(this.symbol)),nL.transformation)])}getExpected(){return globalThis.String(this.symbol)}},Ln=class extends Gt{_tag="Literal";literal;constructor(e,t,r,n,o){if(super(t,r,n,o),typeof e=="number"&&!globalThis.Number.isFinite(e))throw new Error(`A numeric literal must be finite, got ${H(e)}`);this.literal=e}getParser(){return sS(this,this.literal)}matchPart(e,t){return e===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return typeof this.literal=="bigint"?p2(this):this}toCodecStringTree(){return typeof this.literal=="string"?this:p2(this)}getExpected(){return typeof this.literal=="string"?JSON.stringify(this.literal):globalThis.String(this.literal)}};function p2(e){let t=globalThis.String(e.literal);return lt(e,[new jt(new Ln(t),new et(Ie(()=>e.literal),Ie(()=>t)))])}var fQ=class extends Gt{_tag="String";getParser(){return Ns(this,On)}matchPart(e,t){let r=this.checks;return r&&!t.disableChecks&&Us(r,e,void 0,this,t)?void 0:e}getExpected(){return"string"}},Ro=new fQ,lQ=class extends Gt{_tag="Number";getParser(){return Ns(this,Bd)}matchKey(e,t){return this._match(RQ,e,t)}matchPart(e,t){return this._match(Ev,e,t)}_match(e,t,r){if(!e.test(t))return;let n=globalThis.Number(t);return r.disableChecks||!this.checks?n:Us(this.checks,n,void 0,this,r)?void 0:n}toCodecJson(){return this.checks&&(yv(this.checks,"effect/schema/isFinite")||yv(this.checks,"effect/schema/isInt"))?this:lt(this,[IQ])}toCodecStringTree(){return this.toCodecJson()===this?lt(this,[OQ]):lt(this,[_Q])}getExpected(){return"number"}};function yv(e,t){return e.some(r=>r.annotations?.representation?.id===t||r._tag==="FilterGroup"&&yv(r.checks,t))}var Rv=new lQ,dQ=class extends Gt{_tag="Boolean";getParser(){return Ns(this,px)}getExpected(){return"boolean"}},O2=new dQ,pQ=class extends Gt{_tag="Symbol";getParser(){return Ns(this,cI)}matchKey(e,t){return t.disableChecks||!this.checks?e:Us(this.checks,e,void 0,this,t)?void 0:e}toCodecStringTree(){return lt(this,[nL])}getExpected(){return"symbol"}},_2=new pQ,mQ=class extends Gt{_tag="BigInt";getParser(){return Ns(this,LO)}matchPart(e,t){if(!Iv.test(e))return;let r=globalThis.BigInt(e);return t.disableChecks||!this.checks?r:Us(this.checks,r,void 0,this,t)?void 0:r}toCodecStringTree(){return lt(this,[MQ])}getExpected(){return"bigint"}},P2=new mQ,Xo=class extends Gt{_tag="Arrays";isMutable;elements;rest;encodingChecks;constructor(e,t,r,n,o,s,i,a){super(n,o,s,i),this.isMutable=e,this.elements=t,this.rest=r,this.encodingChecks=a;let c=!1;for(let u=0;u<t.length;u++)if(Lr(t[u]))c=!0;else if(c)throw new Error("A required element cannot follow an optional element. ts(1257)");if(c&&r.length>1)throw new Error("A required element cannot follow an optional element. ts(1257)");for(let u=1;u<r.length;u++)if(Lr(r[u]))throw new Error("An optional element cannot follow a rest element. ts(1266)")}getParser(e,t=e){let r=this,n,o,s=r.elements.length,i=Math.max(0,r.rest.length-1);function a(f,p){return p<s?n[p]:p>=f?o[p-f+1]:o[0]}let c=f=>{let{input:p,len:m,options:h}=f;if(r.rest.length===0&&m>s)for(let x=s;x<m;x++){let g=new Uu(r,p[x],h),y=new Ct([x],g);if(h.errors==="all")f.issues?f.issues.push(y):f.issues=[y];else return D(new Ft(r,[y],p,h))}return f.issues?D(new Ft(r,f.issues,p,h)):Dr(f.output)},u=(f,p)=>{let m=f.length,h={ast:r,getParser:a,input:f,len:m,tailThreshold:Math.max(s,m-i),output:new globalThis.Array(m),issues:void 0,options:p},x=r.rest.length===0?s:Math.max(m,s+i),g=p.concurrency===void 0?1:vp(p.concurrency),y=g===1?xQ(h,f,0,x):gQ(h,f,{concurrency:g,end:x});if(!y)return c(h);if(Xe(y))return ur(y,()=>c(h));let E=!0;return L(()=>E?(E=!1,C(y,()=>c(h))):u(f,p))};return(f,p)=>{if(f===ve)return no;try{return Array.isArray(f)?(n||(n=r.elements.map(m=>({ast:m,parser:t(m)})),o=r.rest.map(m=>({ast:m,parser:t(m)}))),u(f,p)):D(new at(r,f,p))}catch(m){return gn(m)}}}_rebuild(e,t,r){let n=Bu(this.elements,e),o=Bu(this.rest,e);return n===this.elements&&o===this.rest&&t===this.checks&&r===this.encodingChecks?this:new Xo(this.isMutable,n,o,this.annotations,t,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"}};function hQ(e,t,r,n){if(r._tag==="Failure")return Qy(e,e.ast,n,r);let o=r===nt?t:r[Se];if(o!==ve)e.output[n]=o;else{let s=e.getParser(e.tailThreshold,n);if(Lr(s.ast))return;let i=new Ct([n],new Yt(s.ast.context?.annotations));if(e.options.errors==="all")e.issues?e.issues.push(i):e.issues=[i];else return Jn(new Ft(e.ast,[i],e.input,e.options))}}var M2={onItem(e,t,r){let n=r<e.len?t:ve;return e.getParser(e.tailThreshold,r).parser(n,e.options)},step:hQ},xQ=Rg()(M2),gQ=Og()(M2),Qy=(e,t,r,n)=>{if(n.cause.reasons.length===0)return n;let o=Sm(n.cause);if(o===void 0)return ir(Va(n.cause,i=>new Ft(t,[new Ct([r],i)],e.input,e.options)));let s=new Ct([r],o);if(e.options.errors==="all")e.issues?e.issues.push(s):e.issues=[s];else return Jn(new Ft(t,[s],e.input,e.options))},Xy="[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?";function _i(e,t,r=nn){let n,o;function s(i){switch(i._tag){case"String":case"TemplateLiteral":return(n??=Object.keys(e)).filter(a=>i.matchPart(a,r)!==void 0);case"Number":return(n??=Object.keys(e)).filter(a=>i.matchKey(a,r)!==void 0);case"Symbol":return(o??=Object.getOwnPropertySymbols(e)).filter(a=>Object.prototype.propertyIsEnumerable.call(e,a)&&i.matchKey(a,r)!==void 0);case"Union":return[...new Set(i.types.flatMap(s))];default:return[]}}return s($v(Bn(t)))}var Ov=class{name;type;constructor(e,t){this.name=e,this.type=t}};function F2(e){switch(e._tag){case"String":case"Number":case"Symbol":case"TemplateLiteral":return!0;case"Union":return e.types.every(F2);default:return!1}}function N2(e){let t=ql(e);switch(t._tag){case"String":case"Number":case"Symbol":case"TemplateLiteral":return!0;case"Union":return t.types.every(N2);default:return!1}}function yQ(e){return F2(e)&&N2(e)}var _v=class{parameter;type;constructor(e,t){if(!yQ(e))throw new Error(`Invalid index signature parameter ${e._tag}`);if(this.parameter=e,this.type=t,Lr(t)&&!X2(t))throw new Error("Cannot use `Schema.optionalKey` with index signatures, use `Schema.optional` instead.")}},Tm=class extends Gt{_tag="Objects";propertySignatures;indexSignatures;encodingChecks;constructor(e,t,r,n,o,s,i){super(r,n,o,s),this.propertySignatures=e,this.indexSignatures=t,this.encodingChecks=i}getParser(e,t=e){let r=this,n=r.propertySignatures.length,o=r.indexSignatures.length;if(!n&&!o)return Ns(r,hx);let s,i,a=()=>(s||(s=r.propertySignatures.map(p=>({parser:t(p.type),name:p.name,type:p.type})),i=o?r.indexSignatures.map(p=>({is:p,parserKey:e($v(p.parameter)),parserValue:t(p.type)})):void 0),s),c=()=>{let p=new Set(r.propertySignatures.map(y=>typeof y.name=="number"?globalThis.String(y.name):y.name)),m=(y,E,b,v,T)=>{if(T._tag==="Failure")return Qy(y,r,E,T)??Kt;let S=T===nt?v:T[Se];if(b!==ve&&S!==ve){if(n&&(p.has(E)||p.has(typeof b=="number"?globalThis.String(b):b)))return Kt;B(y.out,b,S)}return Kt},h=(y,E,b,v)=>{if(!v){let k=b.parserKey(E,y.options);if(!Xe(k))return C(eo(k),A=>h(y,E,b,A));v=k}if(v._tag==="Failure")return Qy(y,r,E,v)??Kt;let T=v===nt?E:v[Se],S=y.input[E],w=b.parserValue(S,y.options);return Xe(w)?m(y,E,T,S,w):C(eo(w),k=>m(y,E,T,S,k))},x=(y,E,b)=>{let v=y.input[E],T=b.parserValue(v,y.options);return Xe(T)?m(y,E,E,v,T):C(eo(T),S=>m(y,E,E,v,S))},g=o?Og()({onItem:(y,[E,b])=>b.is.parameter===Ro?x(y,E,b):h(y,E,b),step:(y,E,b)=>b._tag==="Failure"?b:void 0}):void 0;return uw(function*(y,E){if(y===ve)return ve;if(!(typeof y=="object"&&y!==null&&!Array.isArray(y)))return yield*D(new at(r,y,E));a();let b=y,v={},T={ast:r,input:b,out:v,issues:void 0,options:E},S=E.errors==="all",w=E.onExcessProperty==="error",k=E.concurrency===void 0?1:vp(E.concurrency),A=o&&w?r.indexSignatures.map(R=>_i(b,R.parameter,E)):void 0;if(w){let R=A?new Set(p):p;if(A)for(let $ of A)for(let te of $)R.add(te);let M=Reflect.ownKeys(b);for(let $=0;$<M.length;$++){let te=M[$];if(!R.has(te)&&Object.prototype.propertyIsEnumerable.call(b,te)){let xe=new Uu(r,b[te],E),Le=new Ct([te],xe);if(S){T.issues?T.issues.push(Le):T.issues=[Le];continue}else return yield*D(new Ft(r,[Le],y,E))}}}if(n){let R=k===1?m2(T,s):SQ(T,s,{concurrency:k});R&&(yield*R)}if(o&&k===1)for(let R=0;R<o;R++){let M=i[R],$=M.is.parameter===Ro?x:h,te=A?.[R]??(M.is.parameter===Ro?Object.keys(b):_i(b,M.is.parameter,E));for(let xe=0;xe<te.length;xe++){let Le=$(T,te[xe],M);if(!Xe(Le))yield*Le;else if(Le._tag==="Failure")return yield*Le}}else if(g){let R=Qt();for(let $=0;$<o;$++){let te=i[$],xe=A?.[$]??(te.is.parameter===Ro?Object.keys(b):_i(b,te.is.parameter,E));for(let Le=0;Le<xe.length;Le++)R.push([xe[Le],te])}let M=g(T,R,{concurrency:k});M&&(yield*M)}return T.issues?yield*D(new Ft(r,T.issues,y,E)):v})};if(o)return c();let u,f=(p,m,h)=>{let x=s[m];return C(eo(h),g=>{let y=Sv(p,x,g);if(y)return y;let E=()=>Dr(p.out),b=m2(p,s.slice(m+1));return b?ur(b,E):E()})};return(p,m)=>{if(p===ve)return no;if(m.errors==="all"||m.onExcessProperty!==void 0||m.concurrency!==void 0&&vp(m.concurrency)!==1)return(u??=c())(p,m);if(!(typeof p=="object"&&p!==null&&!Array.isArray(p)))return D(new at(r,p,m));let h=a(),x=p,g={},y={ast:r,input:x,out:g,issues:void 0,options:m};try{for(let E=0;E<h.length;E++){let b=h[E],v=b.name,T=Ll(x,v),S=T?x[v]:ve,w=b.parser(S,m);if(!Xe(w))return f(y,E,w);if(w===nt){T&&B(g,v,S);continue}let k=Sv(y,b,w);if(k)return k}}catch(E){return gn(E)}return Dr(g)}}_rebuild(e,t,r,n){let o=Bu(this.propertySignatures,i=>{let a=e(i.type);return a===i.type?i:new Ov(i.name,a)}),s=Bu(this.indexSignatures,i=>{let a=t(i.parameter),c=e(i.type);return a===i.parameter&&c===i.type?i:new _v(a,c)});return o===this.propertySignatures&&s===this.indexSignatures&&r===this.checks&&n===this.encodingChecks?this:new Tm(o,s,this.annotations,r,void 0,this.context,n)}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"}};function Sv(e,t,r){if(r._tag==="Failure")return Qy(e,e.ast,t.name,r);if(r===nt)return;let n=r[Se];if(n!==ve){B(e.out,t.name,n);return}if(delete e.out[t.name],!Lr(t.type)){let o=new Ct([t.name],new Yt(t.type.context?.annotations));if(e.options.errors==="all"){e.issues?e.issues.push(o):e.issues=[o];return}else return Jn(new Ft(e.ast,[o],e.input,e.options))}}var U2={onItem(e,t){if(!Ll(e.input,t.name))return t.parser(ve,e.options);let r=e.input[t.name];return B(e.out,t.name,r),t.parser(r,e.options)},step:Sv},m2=Rg()(U2),SQ=Og()(U2);function Pv(e,t){return e?t?[...e,...t]:e:t}function eS(e,t,r){return new Tm(Reflect.ownKeys(e).map(n=>new Ov(n,e[n].ast)),[],r,t)}function wm(e){return e.ast}function Mv(e,t=void 0){return new Xo(!1,e.map(r=>r.ast),[],void 0,t)}function tS(e,t,r){return new Sn(e.map(wm),t,void 0,r)}function D2(e,t){if(e.encoding||t.some(s=>s.encoding))throw new Error("StructWithRest does not support encodings");let r=e.propertySignatures,n=e.indexSignatures,o=e.checks;for(let s of t){for(let i of s.propertySignatures)if(r.some(a=>a.name===i.name))throw new Error(`Duplicate identifier: ${JSON.stringify(i.name)}. ts(2300)`);r=r.concat(s.propertySignatures),n=n.concat(s.indexSignatures),o=Pv(o,s.checks)}return new Tm(r,n,void 0,o)}function L2(e,t){if(e.encoding)throw new Error("TupleWithRest does not support encodings");return new Xo(e.isMutable,e.elements,t,void 0,e.checks)}function B2(e){if(e.encoding)throw new Error("mutable does not support encodings");return new Xo(!0,e.elements,e.rest,e.annotations,e.checks,void 0,e.context,e.encodingChecks)}var Fv=Hc(e=>{for(;;){if(E2(e))return pa;let t=e.encoding;if(!t)return e.recur?.(Fv,F)??e;if(t.some(r=>r.transformation._tag==="Middleware"&&r.transformation.decode!==F))return pa;e=t[t.length-1].to}});function $2(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(([,t])=>typeof t)));case"Literal":return[typeof e.literal];case"Union":return Array.from(new Set(e.types.flatMap($2)));default:return["null","undefined","string","number","boolean","symbol","bigint","object","array","function"]}}function cc(e){switch(e._tag){default:return[];case"Declaration":{let t=e.annotations?.[dm];return Array.isArray(t)?t:[]}case"Objects":return e.propertySignatures.flatMap(t=>{let r=t.type;if(!Lr(r)){if(Bl(r))return[{key:t.name,literal:r.literal}];if(xv(r))return[{key:t.name,literal:r.symbol}]}return[]});case"Arrays":return e.elements.flatMap((t,r)=>{if(!Lr(t)){if(Bl(t))return[{key:r,literal:t.literal}];if(xv(t))return[{key:r,literal:t.symbol}]}return[]});case"Union":{if(e.types.length===0)return[];let t=e.types.map(r=>cc(Fv(r)));return t[0].filter(r=>t.every(n=>n.some(o=>o.key===r.key&&o.literal===r.literal)))}case"Suspend":return cc(e.thunk())}}var h2=new WeakMap,Zy=Object.freeze([]),x2=e=>e===null?"null":Array.isArray(e)?"array":typeof e,Ll=(e,t)=>t==="__proto__"?Object.hasOwn(e,t):t in e;function vm(e){let t=h2.get(e);if(t)return t;let r,n=0,o,s,i=!0,a=[];for(let f=0;f<e.length;f++){let p=e[f],m=Fv(p);if(tQ(m))continue;if(Bl(m)||xv(m)){s??=new Map;let x=Bl(m)?m.literal:m.symbol;a[f]=x;let g=s.get(x);g||s.set(x,g=[]),g.push(f)}else i=!1;let h=cc(m);if(h.length){r??=new Map,n++;for(let{key:x,literal:g}of h){let y=r.get(x);y||r.set(x,y=[new Map,new Set]),y[1].add(f);let E=y[0].get(g);E||y[0].set(g,E=new Set),E.add(f)}}else{o??={};let x=$2(m);for(let g of x)(o[g]??=[]).push(f)}}let c={},u=f=>c[f]??=Object.freeze(o?.[f]??Zy);if(i&&s)s.forEach(Object.freeze),t=f=>s.get(f)??Zy;else if(r?.size===1&&!o){let[f,[p]]=r.entries().next().value,m=new Map;for(let[x,g]of p)m.set(x,Object.freeze(Array.from(g)));let h=Object.freeze(e.map((x,g)=>g));t=(x,g)=>{if(jd(x)){let y=Ll(x,f)?x[f]:void 0;if(y!==void 0)return m.get(y)??Zy;if(g)return h}return Zy}}else if(r){let f;for(let p of r)(!f||p[1][0].size>f[1][0].size)&&p[1][1].size===n&&(f=p);t=(p,m)=>{let h=x2(p);if(!jd(p))return u(h);let x=new Set(o?.[h]),g;if(f){let[y,[E]]=f,b=Ll(p,y),v=b?p[y]:void 0;if(b&&(!m||v!==void 0)){let T=E.get(v);if(!T)return u(h);for(let S of T)x.add(S);g=y}}if(g===void 0)for(let[y,[E,b]]of r){let v=Ll(p,y),T=v?p[y]:void 0;if(v&&(!m||T!==void 0)){let S=E.get(T);if(S)for(let w of S)x.add(w)}else if(m)for(let S of b)x.add(S)}for(let[y,[E,b]]of r){if(y===g)continue;let v=Ll(p,y),T=v?p[y]:void 0;if(v&&(!m||T!==void 0)){let S=E.get(T);for(let w of x)b.has(w)&&!S?.has(w)&&x.delete(w)}}return Array.from(x).sort((y,E)=>y-E)}}else t=f=>{let p=u(x2(f));return s?p.filter(m=>a[m]===void 0||a[m]===f):p};return h2.set(e,t),t}var Sn=class extends Gt{_tag="Union";types;options;encodingChecks;constructor(e,t,r,n,o,s,i){super(r,n,o,s),this.types=e,this.options=t,this.encodingChecks=i}getParser(e,t){let r=this,n=t!==void 0,o=[],s=a=>o[a]??=e(r.types[a]),i;return(a,c)=>{if(a===ve)return no;let u=(i??=vm(r.types))(a,n);if(u.length===0)return D(new ym(r,[],a,c));if(u.length===1){let f=s(u[0])(a,c);return f._tag==="Success"?f:Xe(f)?j2(r,f.cause,a,c):bQ(r,f,a,c)}return H2(r,s,u,a,c)}}_rebuild(e,t,r){let n=Bu(this.types,e);return n===this.types&&t===this.checks&&r===this.encodingChecks?this:new Sn(n,this.options,this.annotations,t,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 r of this.types){let n=r.matchPart(e,t);if(n!==void 0)return n}}getExpected(e){let t=this.annotations?.expected;if(typeof t=="string")return t;if(this.types.length===0)return"never";let r=this.types.map(n=>{let o=Bn(n);switch(o._tag){case"Arrays":{let s=o.elements.filter(Bl);if(s.length>0)return`${y2(o.isMutable)}[ ${s.map(i=>e(i)+S2(i.context?.isOptional)).join(", ")}, ... ]`;break}case"Objects":{let s=o.propertySignatures.filter(i=>Bl(i.type));if(s.length>0)return`{ ${s.map(i=>`${y2(i.type.context?.isMutable)}${ni(i.name)}${S2(i.type.context?.isOptional)}: ${e(i.type)}`).join(", ")}, ... }`;break}}return e(o)});return Array.from(new Set(r)).join(" | ")}};function j2(e,t,r,n){let o=Sm(t);return o?Jn(new ym(e,[o],r,n)):ir(t)}function bQ(e,t,r,n){return rt(t,o=>j2(e,o,r,n))}function H2(e,t,r,n,o){let s={ast:e,parser:t,input:n,out:void 0,successes:e.options?.mode==="oneOf"?[]:void 0,issues:void 0,options:o},i=EQ(s,r);if(!i)return s.out?s.out:D(new ym(e,s.issues??[],n,o));if(Xe(i))return g2(i,s);let a=!0;return L(()=>a?(a=!1,g2(i,s)):H2(e,t,r,n,o))}function g2(e,t){return ur(e,r=>t.out===nt?I(t.input):t.out?t.out:D(new ym(t.ast,t.issues??[],t.input,t.options)))}var EQ=Rg()({onItem(e,t){return e.parser(t)(e.input,e.options)},step(e,t,r){if(r._tag==="Failure"){let n=Sm(r.cause);if(n===void 0)return r;e.issues?e.issues.push(n):e.issues=[n]}else{if(e.out&&e.successes)return e.successes.push(e.ast.types[t]),Jn(new h1(e.ast,e.successes,e.input,e.options));if(e.out=r,e.successes)e.successes.push(e.ast.types[t]);else return Kt}}}),q2=new Sn([new Ln("Infinity"),new Ln("-Infinity"),new Ln("NaN")]);function y2(e){return e?"":"readonly "}function S2(e){return e?"?":""}var Nv=class extends Gt{_tag="Suspend";thunk;constructor(e,t,r,n,o){if(r)throw new Error("Cannot add checks to Suspend");super(t,void 0,n,o);let s;this.thunk=()=>s??=e()}getParser(e){let t;return(r,n)=>(t??=e(this.thunk()))(r,n)}recur(e){return new Nv(()=>e(this.thunk()),this.annotations,void 0,void 0,this.context)}getExpected(e){return e(this.thunk())}},Yy=class extends Oa{_tag="Filter";run;annotations;aborted;constructor(e,t=void 0,r=!1){super(),this.run=e,this.annotations=t,this.aborted=r}annotate(e){return new Yy(this.run,{...this.annotations,...e},this.aborted)}abort(){return new Yy(this.run,this.annotations,!0)}and(e,t){return new Lu([this,e],t)}},Lu=class extends Oa{_tag="FilterGroup";checks;annotations;constructor(e,t=void 0){super(),this.checks=e,this.annotations=t}annotate(e){return new Lu(this.checks,{...this.annotations,...e})}and(e,t){return new Lu([this,e],t)}};function rS(e,t,r=!1){return new Yy((n,o,s)=>g1(o,e(n,o,s),n,s),t,r)}function nS(e,t){return new Yy((r,n,o)=>e(r)?void 0:new le(void 0,r,o),t,!0)}function Uv(e){return rS(t=>globalThis.Number.isFinite(t),{expected:"a finite number",representation:{id:"effect/schema/isFinite",payload:null},toJsonSchema:()=>({type:"number"}),toCode:()=>({runtime:"Schema.isFinite()"}),arbitraryConstraint:{number:"finite"},...e})}var Dv=Pi(Rv,[Uv()]),IQ=new jt(new Sn([Dv,q2]),new et(qy(),Ie(e=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function Am(e,t){let r=new globalThis.RegExp(e),n={source:r.source,flags:r.flags};return rS(o=>(r.lastIndex=0,r.test(o)),{expected:`a string matching the RegExp ${n.source}`,representation:{id:"effect/schema/isPattern",payload:n},toJsonSchema:()=>[{},!0],arbitraryConstraint:{patterns:[n]},...t})}var bv=new WeakMap;function Cm(e,t){let r=Object.assign(Object.create(Object.getPrototypeOf(e)),e,t);return Reflect.ownKeys(t).every(n=>n==="context"||n==="encoding")&&bv.set(r,Hl(e)),r}function Hl(e){let t=bv.get(e);if(t!==void 0)return t;if(e.encoding===void 0)return e;let r=Object.assign(Object.create(Object.getPrototypeOf(e)),e,{encoding:void 0});return bv.set(e,r),r}function lt(e,t){return e.encoding===t?e:Cm(e,{encoding:t})}function $u(e,t){if(e.context===t)return e;let r=Hl(e);return r.context===t&&r.encoding===e.encoding?r:Cm(e,{context:t})}function ql(e){return e.encoding?ql(e.encoding[e.encoding.length-1].to):e}function Fs(e,t){if(e.checks){let r=e.checks[e.checks.length-1];return z2(e,$x(e.checks.slice(0,-1),r.annotate(t)))}return Cm(e,{annotations:{...e.annotations,...t}})}function z2(e,t){if(e._tag==="Suspend"&&t)throw new Error("Cannot add checks to Suspend");return e.checks===t?e:Cm(e,{checks:t})}function Pi(e,t){return z2(e,Pv(e.checks,t))}function lc(e,t){let r=t(e.to);return r===e.to?e:new jt(r,e.transformation)}function W2(e,t){let r=e,n=r[r.length-1],o=lc(n,t);return o===n?e:$x(e.slice(0,e.length-1),o)}function oS(e){return t=>t.encoding?lt(t,W2(t.encoding,e)):t}function zl(e,t){return oS(r=>$u(r,t))(e)}function ma(e,t){function r(n){if(n.encoding){let o=n.encoding[n.encoding.length-1];return t?.stopAt?.(o)?n:lt(n,W2(n.encoding,r))}return e(n)}return Hc(r)}function K2(e,t){return Lv(e,t,Nt(e))}function V2(e,t){return Lv(Bn(e),t,e)}function Lv(e,t,r){let n=new jt(e,t);return lt(r,r.encoding?[...r.encoding,n]:[n])}function Bu(e,t){let r;for(let n=0;n<e.length;n++){let o=e[n],s=t(o);if(r)r[n]=s;else if(s!==o){r=new Array(e.length);for(let i=0;i<n;i++)r[i]=e[i];r[n]=s}}return r??e}function Wl(e,t){let r=e.context?new Yo(e.context.isOptional,e.context.isMutable,e.context.constructorDefault,{...e.context.annotations,...t}):new Yo(!1,!1,void 0,t);return $u(e,r)}var ju=Hc(e=>{let t=e.context?e.context.isOptional===!1?new Yo(!0,e.context.isMutable,e.context.constructorDefault,e.context.annotations):e.context:new Yo(!0,!1);return TQ($u(e,t))}),TQ=oS(ju),G2=mo(e=>ju(new Sn([e,Av]))),Bv=Hc(e=>{let t=e.context?e.context.isMutable===!1?new Yo(e.context.isOptional,!0,e.context.constructorDefault,e.context.annotations):e.context:new Yo(!1,!0);return wQ($u(e,t))}),wQ=oS(Bv);function J2(e,t){let r=e.context?new Yo(e.context.isOptional,e.context.isMutable,t,e.context.annotations):new Yo(!1,!1,t);return $u(e,r)}function Kl(e,t,r){return Lv(e,r,t)}function vQ(e){let t=[],r=[];function n(o){switch(o._tag){case"Literal":mx(o.literal)&&!t.includes(o.literal)&&t.push(o.literal);return;case"UniqueSymbol":t.includes(o.symbol)||t.push(o.symbol);return;case"Never":return;case"Union":for(let s=0;s<o.types.length;s++)n(o.types[s]);return;default:r.push(o)}}return n(e),{literals:t,parameters:r}}function Z2(e,t){let{literals:r,parameters:n}=vQ(e);return new Tm(r.map(o=>new Ov(o,t)),n.map(o=>new _v(o,t)))}function Lr(e){return e.context?.isOptional??!1}function Q2(e){return e.context?.isMutable??!1}function Y2(e){return e.annotations?.[ro]===!0||e._tag==="FilterGroup"&&e.checks.every(Y2)}function AQ(e){function t(n){return Y2(n)?[n]:n._tag==="FilterGroup"?n.checks.flatMap(t):[]}let r=e.flatMap(t);return Gr(r)?r:void 0}function CQ(e){let t=!0;function r(n){return t=t&&!n.encoding&&!E2(n),t&&"recur"in n&&n.recur(r),n}return"recur"in e&&e.recur(r),t}var Nt=Hc(e=>{let t=Hl(e);if(t!==e){let n=Nt(t);return n===t&&e.encoding===void 0?e:$u(n,e.context)}let r="recur"in e?e.recur(Nt):e;if("encodingChecks"in r&&r.encodingChecks){let n=CQ(e)?r.encodingChecks:wv(r)||rQ(r)||jl(r)&&r.typeParameters.length>0?AQ(r.encodingChecks):void 0;return Cm(r,{encodingChecks:void 0,checks:Pv(r.checks,n)})}return r}),Bn=Hc(e=>Nt(Oo(e)));function kQ(e,t){let r=t,n=r.length,o=r[n-1],s=[new jt(Oo(lt(e,void 0)),r[0].transformation.flip())];for(let a=1;a<n;a++)s.unshift(new jt(Oo(r[a-1].to),r[a].transformation.flip()));let i=Oo(o.to);return i.encoding?lt(i,[...i.encoding,...s]):lt(i,s)}var Oo=mo(e=>{if(e.encoding)return kQ(e,e.encoding);let t=Hl(e);if(t!==e){let r=Oo(t);return r===t?e:$u(r,e.context)}return"flip"in e?e.flip(Oo):"recur"in e?e.recur(Oo):e});function X2(e){switch(e._tag){case"Undefined":return!0;case"Union":return e.types.some(X2);default:return!1}}function sS(e,t){let r=t===0?nt:Dr(t);return(n,o)=>n===ve?no:n===t?r:D(new at(e,n,o))}function Ns(e,t){return(r,n)=>r===ve?no:t(r)?nt:D(new at(e,r,n))}function eL(e,t,r){let n=e.encodedParts,o=e.literals,s=t.length;for(let u=0;u<o.length;u++){let f=o[u];if(f&&!t.includes(f))return}if(e.suffixLengths[0]>s)return;let i=new Array(n.length),a;function c(u,f){if(u===n.length)return f===s;if(a?.has(u*(s+1)+f))return!1;let p=n[u];if(u===n.length-1){let m=t.slice(f);if(p.matchPart(m,r)!==void 0)return i[u]=m,!0}else if(p._tag==="Literal"){let m=o[u];if(t.startsWith(m,f)&&c(u+1,f+m.length))return i[u]=m,!0}else{let m=s-e.suffixLengths[u+1],h=o[u+1],x=h===void 0?m:t.lastIndexOf(h,m);for(;x>=f;){let g=t.slice(f,x);if(p.matchPart(g,r)!==void 0&&c(u+1,x))return i[u]=g,!0;if(x===0)break;x=h===void 0?x-1:t.lastIndexOf(h,x-1)}}return a??=new Set,a.add(u*(s+1)+f),!1}return c(0,0)?i:void 0}var $v=ma(e=>{switch(e._tag){default:return e;case"Number":return e.toCodecStringTree();case"Union":return e.recur($v)}}),iS=ma(e=>{switch(e._tag){default:return e;case"Symbol":case"UniqueSymbol":return e.toCodecStringTree();case"Union":return e.recur(iS)}}),jv=ma(e=>{switch(e._tag){default:return e;case"Number":case"Literal":case"BigInt":return e.toCodecStringTree();case"Union":return e.recur(jv)}}),tL="[\\s\\S]*?",Ev=new globalThis.RegExp(`^${Xy}$`),RQ=new globalThis.RegExp(`^(?:${Xy}|Infinity|-Infinity|NaN)$`);function Hv(e){return Am(Ev,{expected:"a string representing a finite number",representation:{id:"effect/schema/isStringFinite",payload:null},toJsonSchema:()=>({pattern:Ev.source}),...e})}var rL=Pi(Ro,[Hv()]),OQ=new jt(rL,Ul),_Q=new jt(new Sn([rL,q2]),Ul),PQ="-?\\d+",Iv=new globalThis.RegExp(`^${PQ}$`);function qv(e){return Am(Iv,{expected:"a string representing a bigint",representation:{id:"effect/schema/isStringBigInt",payload:null},toJsonSchema:()=>({pattern:Iv.source}),...e})}var zv=Pi(Ro,[qv({expected:"a string representing a bigint"})]),MQ=new jt(zv,Jy),FQ="Symbol\\(([\\s\\S]*)\\)",Tv=new globalThis.RegExp(`^${FQ}$`),NQ=Pi(Ro,[Wv()]),nL=new jt(NQ,new et(Ie(e=>globalThis.Symbol.for(Tv.exec(e)[1])),rn((e,t)=>globalThis.Symbol.keyFor(e)!==void 0?I(globalThis.String(e)):D(new gm({message:"cannot serialize to string, Symbol is not registered"},e,t)))));function Wv(e){return Am(Tv,{expected:"a string representing a symbol",representation:{id:"effect/schema/isStringSymbol",payload:null},toJsonSchema:()=>({pattern:Tv.source}),...e})}function Us(e,t,r,n,o){for(let s=0;s<e.length;s++){let i=e[s];if(i._tag==="FilterGroup"){if(r=Us(i.checks,t,r,n,o),r&&(o.errors!=="all"||r[r.length-1].filter.aborted))return r}else{let a=i.run(t,n,o);if(a){let c=new p1(i,a,t,o);if(r?r.push(c):r=[c],o.errors!=="all"||i.aborted)return r}}}return r}function oL(e,t){let r=Us(e,t,void 0,pa,{errors:"all"});if(r){let n=new Ft(pa,r);return re(n)}return X(t)}function sL(e){if(!jl(e))return;let t=e.annotations?.[By];return or(t)?t(e.typeParameters):void 0}function UQ(e){return e===null||typeof e=="string"||typeof e=="boolean"||typeof e=="number"&&globalThis.Number.isFinite(e)}function DQ(e){return e===void 0||typeof e=="string"}function iL(e,t){let r=new WeakMap,n=[];e:for(;;){if(typeof e!="object"||e===null){if(!t(e))return!1}else{let o=e,s=r.get(o);if(s===!1)return!1;if(s===void 0){let i=Array.isArray(o);if(!i){let a=Object.getPrototypeOf(o);if(a!==null&&a!==Object.prototype&&Object.getPrototypeOf(a)!==null)return!1}r.set(o,!1),n.push({value:o,keys:i?o.length:Object.keys(o),index:0})}}for(;n.length>0;){let o=n[n.length-1],s=o.keys;if(typeof s=="number"){if(o.index<s){e=o.value[o.index++];continue e}}else if(o.index<s.length){e=o.value[s[o.index++]];continue e}r.set(o.value,!0),n.pop()}return!0}}function Vl(e){return iL(e,UQ)}var $l=new fc([],()=>(e,t,r)=>Vl(e)?nt:D(new at(t,e,r)),{representation:{id:"effect/schema/Json",payload:null},expected:"JSON value",toCodecJson:()=>{},toCodecStringTree:()=>Vv}),aL=Fs($l,{representation:{id:"effect/schema/MutableJson",payload:null}}),Kv=new jt($l,Nl()),cL=new jt(new Sn([new Xo(!1,[],[$l]),new Tm([],[new _v(Ro,$l)])]),Nl());function LQ(e){return iL(e,DQ)}var BQ=new fc([],()=>(e,t,r)=>LQ(e)?nt:D(new at(t,e,r)),{expected:"StringTree",toCodecStringTree:()=>{}}),Vv=new jt(BQ,Nl());var aS=(e,t,r)=>e===nt?r(t):ur(e,r);function fL(e){if(e._tag==="Middleware")return(r,n,o)=>{let s=r===nt?e.decode(Dr(mm(n)),o):e.decode(Iu(r,mm),o);return uL(s)};let t=e.decode;switch(t._tag){case"Passthrough":return(r,n)=>r===nt?Dr(n):r;case"Transform":{let r=n=>n===ve?no:Dr(t.transform(n));return(n,o)=>aS(n,o,r)}case"TransformOptional":{let r=n=>tv(t.transform(mm(n)));return(n,o)=>aS(n,o,r)}case"TransformEffect":return(r,n,o)=>aS(r,n,s=>s===ve?no:t.transform(s,o));case"TransformOptionalEffect":return(r,n,o)=>aS(r,n,s=>uL(t.transform(mm(s),o)))}}var uL=e=>ur(e,tv),lL=(e,t,r,n)=>rt(n,o=>aa(()=>Va(o,s=>new m1(e,s,t,r))));function $Q(e,t){let r=fL(e.link.transformation),n;return(o,s)=>{if(o===ve)return no;if(e.isConstructed(o))return nt;let i=(n??=t(e.link.to))(o,s);return r(i,o,s)}}function jQ(e,t){let r=e.context.constructorDefault;return(n,o)=>{if(n!==ve&&n!==void 0)return t(n,o);let s=r;if(Xe(s)&&s._tag==="Success"){let i=t(s[Se],o);return i===nt?s:i}return ur(lL(e,n,o,s),i=>{let a=t(i,o);return a===nt?Dr(i):a})}}function Gv(e,t){let r=t(e);return e.context?.constructorDefault===void 0?r:jQ(e,r)}function km(e,t,r,n,o){if(e._tag==="Declaration")for(let x of e.typeParameters)t(x);let s=r?sL(e):void 0,i=s?$Q(s,t):n??e.getParser(t,r),a=e.checks,c=e.encoding,u=c?.map(x=>fL(x.transformation)),f=e.encodingChecks;if(!c&&!a&&!f)return i;let p,m=(x,g)=>{let y=i(x,g);if(f&&!g.disableChecks)if(Xe(y)){if(y._tag==="Success"){let E=y===nt?x:y[Se];if(x!==ve&&E!==ve){let b=Us(f,x,void 0,e,g);b&&(y=D(new Ft(e,b,x,g)))}}}else y=C(y,E=>{if(x!==ve&&E!==ve){let b=Us(f,x,void 0,e,g);if(b)return D(new Ft(e,b,x,g))}return I(E)});if(a&&!g.disableChecks)if(Xe(y)){if(y._tag==="Success"){let E=y===nt?x:y[Se];if(E===ve)return y;let b=Us(a,E,void 0,e,g);b&&(y=D(new Ft(e,b,E,g)))}}else y=C(y,E=>{if(E!==ve){let b=Us(a,E,void 0,e,g);if(b)return D(new Ft(e,b,E,g))}return I(E)});return y},h=o===void 0?m:o(m);return c?(x,g)=>{let y=p??=c.map(v=>t(v.to)),E=x,b=y[y.length-1](x,g);for(let v=c.length-1;v>=0;v--)if(b=u[v](b,E,g),v!==0){let T=y[v-1];b._tag==="Success"?(E=b[Se],b=T(E,g)):b=ur(b,S=>{let w=T(S,g);return w===nt?Dr(S):w})}if(b._tag==="Success"){let v=b[Se],T=h(v,g);return T===nt?b:T}return b=lL(e,x,g,b),ur(b,v=>{let T=h(v,g);return T===nt?Dr(v):T})}:h}var fS=Symbol(),dL=new WeakMap,pL,Gl=!1;var qQ=e=>Gl?uS(Po,e,"parser"):Po(e).parser,mL=e=>Gl?uS(Po,e,"makeEffect"):Po(e).makeEffect,zQ=e=>Gv(e,mL),cS=class{ast;constructor(t){this.ast=t}get decodeEffect(){return this.cachedDecodeEffect??=km(this.ast,qQ)}get parser(){return this.decodeEffect}get makeEffect(){return this.cachedMakeEffect??=km(this.ast,mL,zQ)}},Jv=class extends cS{compiled;resolve;constructor(t,r,n){super(t),this.compiled=r,this.resolve=n}save(t,r){return Object.defineProperty(this,t,{value:r}),r}operation(t){let r=this.compiled;return typeof r=="function"?r(this.ast,this.resolve,t):r?.[t]}get is(){return this.save("is",this.operation("is"))}get decode(){return this.save("decode",this.operation("decode"))}get make(){return this.save("make",this.operation("make"))}get decodeEffect(){return this.save("decodeEffect",this.operation("decodeEffect")??km(this.ast,t=>uS(this.resolve,t,"parser")))}get parser(){let t=this.decode;return t===void 0?this.decodeEffect:this.save("parser",WQ(t,()=>this.decodeEffect))}get makeEffect(){let t=this.operation("makeEffect");if(t!==void 0)return this.save("makeEffect",t);let r=n=>uS(this.resolve,n,"makeEffect");return this.save("makeEffect",km(this.ast,r,n=>Gv(n,r)))}};function WQ(e,t){let r;return(n,o)=>{if(n!==ve)try{let s=e(n,o);if(s!==fS)return s===n?nt:Dr(s)}catch(s){return gn(s)}return(r??=t())(n,o)}}function uS(e,t,r){let n=e(t);if(n.compiled===void 0||Object.hasOwn(n,r))return n[r];let o;return(s,i)=>(o??=n[r])(s,i)}function Po(e){let t=dL.get(e);if(t!==void 0)return t;let r=pL===void 0?new cS(e):new Jv(e,pL(e,Po),Po);return dL.set(e,r),r}function Qv(e){let t=e.ast,r;return(n,o)=>(r??=oA(e9,Nt(t)))(n,o?.disableChecks?o?.parseOptions?{...o.parseOptions,disableChecks:!0}:{disableChecks:!0}:o?.parseOptions)}function dS(e){let t=Qv(e);return(r,n)=>{let o=ki(t(r,n));return ft(o)?N(o.value):(ko(o.cause,"Option adapter can only return none for schema issues"),_())}}function pS(e){return YQ(Nt(e.ast))}function Yv(e){return Rm(e.ast)}function VQ(e){if(!Gl){let o=Jl(xS(e));return s=>{let i=o(s,nn);return ft(i)?!0:(ko(i.cause,"Type guard adapter can only return false for schema issues"),!1)}}let t=Po(e),r=t.is;if(r!==void 0)return o=>{try{return r(o,nn)}catch(s){return ko(cl(s),"Type guard adapter can only return false for schema issues"),!1}};let n=t.parser;return o=>{let s=ki(nA(n(o,nn),o));return ft(s)?!0:(ko(s.cause,"Type guard adapter can only return false for schema issues"),!1)}}function Rm(e){let t=Nt(e),r=n=>(r=VQ(t),r(n));return n=>r(n)}function hL(e){let t=xS(e);return(r,n)=>{let o=ki(t(r,n));if(!ft(o))return ko(o.cause,"Issue adapter can only return schema issues")}}function xL(e,t){let r=Nt(e.ast),n=Po(r).parser(t,nn),o=ki(nA(n,t));if(vs(o)){let s=ko(o.cause,"Assertion adapter can only throw schema issues");throw new Error("Schema validation failed",{cause:s})}}function ot(e,t){let r=xS(e.ast);return t===void 0?r:(n,o)=>r(n,rA(t,o))}var Xv=ot;function gL(e,t){return Jl(ot(e,t))}function eA(e,t){return wL(ot(e,t))}var yL=eA;function SL(e,t){return vL(ot(e,t))}function GQ(e,t){return Gl?AL(e.ast,t):sA(ot(e,t))}var mS=GQ;function Hu(e,t){let r=xS(Oo(e.ast));return t===void 0?r:(n,o)=>r(n,rA(t,o))}var bL=Hu;function EL(e,t){return Jl(Hu(e,t))}function tA(e,t){return wL(Hu(e,t))}var IL=tA;function TL(e,t){return vL(Hu(e,t))}function JQ(e,t){return Gl?AL(Oo(e.ast),t):sA(Hu(e,t))}var hS=JQ,rA=(e,t)=>t?{...e,...t}:e,lS=e=>e===ve?D(new le):I(e);function xS(e){return oA(XQ,e)}function nA(e,t){return e===nt?I(t):Xe(e)?e[Se]===ve?lS(ve):e:ur(e,lS)}function oA(e,t){let r;return(n,o)=>{let s=(r??=e(t))(n,o??nn);return s===nt?I(n):Xe(s)?s[Se]===ve?lS(ve):s:ur(s,lS)}}function Jl(e){return(t,r)=>ki(e(t,r))}function wL(e){let t=Jl(e);return(r,n)=>{let o=t(r,n);return ft(o)?N(o.value):(ko(o.cause,"Option adapter can only return none for schema issues"),_())}}function vL(e){let t=Jl(e);return(r,n)=>{let o=t(r,n);return ft(o)?X(o.value):re(ko(o.cause,"Result adapter can only return schema issues"))}}function AL(e,t){let r;return(n,o)=>(r??=ZQ(Po(e),t))(n,o)}function ZQ(e,t){let r=e.decode,n,o=r===void 0?(s,i=nn)=>(n??=Zv(e))(s,i):(s,i=nn)=>{if(s===ve)return(n??=Zv(e))(s,i);let a;try{a=r(s,i)}catch(c){throw ko(cl(c),"Sync adapter can only throw schema issues"),c}return a!==fS?a:(n??=Zv(e))(s,i)};return t===void 0?o:(s,i)=>o(s,rA(t,i))}function Zv(e){return sA(oA(()=>e.decodeEffect,e.ast))}function sA(e){let t=Jl(e);return(r,n)=>{let o=t(r,n);if(ft(o))return o.value;let s=ko(o.cause,"Sync adapter can only throw schema issues");throw new Error("Schema validation failed",{cause:s})}}function QQ(e,t){let r=ki(e);if(ft(r))return r.value;let n=ko(r.cause,t);throw new Error("Schema validation failed",{cause:n})}function YQ(e){let t,r;return(n,o)=>{t??=Po(e);let s=o?.disableChecks?o.parseOptions?{...o.parseOptions,disableChecks:!0}:{disableChecks:!0}:o?.parseOptions??nn,i=t.make;if(i!==void 0&&n!==ve){let c;try{c=i(n,s)}catch(u){throw ko(cl(u),"Constructor adapter can only throw schema issues"),u}if(c!==fS&&c!==ve)return c}let a=(r??=t.makeEffect)(n,s);return QQ(nA(a,n),"Constructor adapter can only throw schema issues")}}var XQ=e=>Po(e).parser,e9=e=>Po(e).makeEffect;var gS="~effect/Schema/Schema",CL=Symbol(),t9={[gS]:gS,get make(){let e=pS(this);return Object.defineProperty(this,"make",{value:e,enumerable:!0}),e},get makeEffect(){let e=Qv(this);return Object.defineProperty(this,"makeEffect",{value:e,enumerable:!0}),e},get makeOption(){let e=dS(this);return Object.defineProperty(this,"makeOption",{value:e,enumerable:!0}),e},pipe(){return V(this,arguments)},annotate(e){return this.rebuild(Fs(this.ast,e))},annotateKey(e){return this.rebuild(Wl(this.ast,e))},check(...e){return this.rebuild(Pi(this.ast,e))},rebuild(e){return Ls(e,this[CL])}};function Ls(e,t){function r(){}let n=Object.setPrototypeOf(r,t9);return t&&(Object.hasOwn(t,"name")||Object.hasOwn(t,"length")||Object.hasOwn(t,"__proto__"))?Object.defineProperties(n,Object.getOwnPropertyDescriptors({...t})):Object.assign(n,t),n[CL]=t,n.ast=e,n}function iA(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Om(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function aA(e){return encodeURI(iA(e)).replace(/#/g,"%23")}function cA(e){if(e.length===0||e==="#")return"";if(!e.startsWith("#"))return;let t=e.slice(1);try{if(encodeURI(t).replace(/%25/g,"%").replace(/#/g,"%23")!==t)return;let r=decodeURIComponent(t);return r.startsWith("/")&&!/~(?:[^01]|$)/.test(r)?r:void 0}catch{return}}function RL(e){let t=cA(e);return t===void 0?void 0:t.length===0?[]:t.slice(1).split("/").map(Om)}function OL(e){return e.reduce((t,r)=>`${t}/${aA(r)}`,"#")}var n9="http://json-schema.org/draft-07/schema#",_L="https://json-schema.org/draft/2020-12/schema";function PL(e,t){return e===t||e===(t.endsWith("#")?t.slice(0,-1):`${t}#`)}function NL(e){return{dialect:"draft-07",...c9(e,y9)}}function o9(e,t){return r(e,!1,!0);function r(n,o,s=!1){if(!Jt(n))return n;let i=o||!s&&LL(n.$id),a={};for(let c of Object.keys(n)){let u=n[c],f=u;switch(c){case"$defs":case"properties":case"patternProperties":case"dependentSchemas":f=fA(u,p=>r(p,i))??u;break;case"allOf":case"anyOf":case"oneOf":case"prefixItems":f=Array.isArray(u)?u.map(p=>r(p,i)):u;break;case"not":case"additionalProperties":case"propertyNames":case"unevaluatedProperties":case"items":case"contains":case"unevaluatedItems":case"if":case"then":case"else":case"contentSchema":f=r(u,i)}B(a,c,f)}return t(a,i),a}}function UL(e,t){return o9(e,r=>{s9(r,t)})}function s9(e,t){typeof e.$ref=="string"&&B(e,"$ref",t(e.$ref,"$ref")),typeof e.$dynamicRef=="string"&&B(e,"$dynamicRef",t(e.$dynamicRef,"$dynamicRef"))}function fA(e,t){if(!Jt(e))return;let r={};for(let n of Object.keys(e))B(r,n,t(e[n],n));return r}function i9(e,t,r){let n=new Map,o=[],s=uA;function i(m,h=[],x=[]){if(h.length===0&&t?.trackIds){let g=Jt(m)?f(m):void 0;s=ML(g,uA)??uA}return u(m,h,x,{sourceRoot:[],targetRoot:[],uri:s})}function a(){for(let[m,h,x]of o){let g=h,y=DL(h,x);if(y!==void 0){let E=RL(y.hash);if(y.hash="",E!==void 0){let b=n.get(FL(y.href,E));b!==void 0&&(g=a9(h,b))}}B(m,"$ref",g)}}let c=r(i);return a(),c;function u(m,h,x,g){if(typeof m=="boolean")return p(h,x,g),t?.booleanAdapter?.(m)??m;if(!Jt(m))return m;let y=g,E=f(m);if(h.length>0&&t?.trackIds&&LL(E)){let T=ML(E,g.uri);T!==void 0&&(y={parent:g,sourceRoot:h,targetRoot:x,uri:T})}p(h,x,y);let b=y.uri,v={isDocumentRoot:h.length===0,schema(T,S,w=S){return u(T,[...h,S],[...x,w],y)},schemaAt(T,S,w){return u(T,[...h,...S],[...x,...w],y)},schemaArray(T,S,w=S){return Array.isArray(T)?T.map((k,A)=>u(k,[...h,S,String(A)],[...x,w,String(A)],y)):T},schemaMap(T,S,w=S){return Jt(T)?fA(T,(k,A)=>u(k,[...h,S,A],[...x,w,A],y)):T},reference(T,S){typeof S=="string"?o.push([T,S,b]):B(T,"$ref",S)}};return e(m,v)}function f(m){return t?.ignoreRefSiblings===!0&&typeof m.$ref=="string"?void 0:m.$id}function p(m,h,x){x.parent!==void 0&&p(m,h,x.parent),n.set(FL(x.uri,m.slice(x.sourceRoot.length)),h.slice(x.targetRoot.length))}}var uA="https://effect.invalid/.json-schema/";function DL(e,t){return URL.canParse(e,t)?new URL(e,t):void 0}function ML(e,t){if(typeof e!="string")return;let r=DL(e,t);if(r!==void 0)return r.hash="",r.href}function a9(e,t){let r=e.indexOf("#");return r===-1&&t.length===0?e:`${r===-1?e:e.slice(0,r)}${OL(t)}`}function FL(e,t){return`${e}\0${JSON.stringify(t)}`}function LL(e){return typeof e=="string"&&e.length>0&&e[0]!=="#"}function c9(e,t,r){return i9(t,{...r,trackIds:!0},n=>({schema:n(e.schema),definitions:fA(e.definitions,(o,s)=>n(o,["$defs",s],["definitions",s]))}))}var u9=new Set(["properties","patternProperties"]),f9=new Set(["allOf","anyOf","oneOf"]),l9=new Set(["not","additionalProperties","propertyNames","contains","if","then","else","contentSchema"]);function d9(e,t,r,n,o,s=u9){let i;if(s.has(t))i=n.schemaMap(r,t);else if(f9.has(t))i=n.schemaArray(r,t);else if(o.has(t))i=n.schema(r,t);else return!1;return B(e,t,i),!0}var BL=["$anchor","$defs","$dynamicAnchor","$dynamicRef","$vocabulary","contentSchema","dependentRequired","dependentSchemas","maxContains","minContains","prefixItems","unevaluatedItems","unevaluatedProperties"],uge=[...BL,"deprecated"],fge=[...BL,"$comment","$id","$schema","const","contains","contentEncoding","contentMediaType","else","examples","if","patternProperties","propertyNames","then"],p9=/^[A-Za-z_][-A-Za-z0-9._]*$/,m9=/^[A-Za-z][-A-Za-z0-9._:]*$/;function qu(e,t,r){throw new Error(`Cannot convert JSON Schema keyword "${e}" to ${t}: ${r}`)}function h9(e,t,r,n){for(let o of t)Object.hasOwn(e,o)&&qu(o,r,`it is not active in ${n} but would become active in the target`)}var x9=["additionalItems","definitions","dependencies"];function g9(e,t,r,n,o){r.isDocumentRoot?B(e,"$schema",PL(t,_L)?n:t):PL(t,_L)||qu("$schema",o,"an embedded resource cannot declare a different dialect")}function y9(e,t){h9(e,x9,"Draft-07","Draft 2020-12");let r={},n,o,s;for(let i of Object.keys(e)){let a=e[i];if(!d9(r,i,a,t,l9))switch(i){case"$ref":n=a;break;case"$schema":g9(r,a,t,n9,"Draft-07");break;case"$id":case"$anchor":break;case"$defs":B(r,"definitions",t.schemaMap(a,i,"definitions"));break;case"prefixItems":o=a;break;case"items":s=a;break;case"dependentRequired":case"dependentSchemas":case"minContains":case"maxContains":break;case"$dynamicRef":case"$dynamicAnchor":case"$vocabulary":case"unevaluatedProperties":case"unevaluatedItems":qu(i,"Draft-07","the target dialect has no equivalent");case"required":if(Array.isArray(a)&&a.length===0)break;B(r,i,a);break;default:B(r,i,a)}}if(S9(r,o,s,t),Object.hasOwn(e,"contains")){let i=e.minContains,a=e.maxContains;(i!==void 0&&i!==1||a!==void 0)&&qu("minContains/maxContains","Draft-07","contains cardinality cannot be represented"),Object.hasOwn(e,"minContains")&&B(r,"minContains",i)}else Object.hasOwn(e,"minContains")&&B(r,"minContains",e.minContains),Object.hasOwn(e,"maxContains")&&B(r,"maxContains",e.maxContains);return E9(e,r,t,"draft-07"),T9(e,r,"$id","Draft-07"),b9(r,n,t),r}function S9(e,t,r,n){if(t===void 0){r!==void 0&&B(e,"items",n.schema(r,"items"));return}B(e,"items",n.schemaArray(t,"prefixItems","items")),r!==void 0&&B(e,"additionalItems",n.schema(r,"items","additionalItems"))}function b9(e,t,r){if(t!==void 0)if(typeof t=="string"&&Object.keys(e).length>0){let n={};r.reference(n,t),I9(e,n)}else r.reference(e,t)}function E9(e,t,r,n){let o=Jt(e.dependentRequired)?e.dependentRequired:void 0,s=Jt(e.dependentSchemas)?e.dependentSchemas:void 0;if(o===void 0&&s===void 0)return;let i={},a=new Set([...Object.keys(o??{}),...Object.keys(s??{})]);for(let c of a){let u=o?.[c],f=s?.[c],p=n==="draft-04"&&Array.isArray(u)&&u.length===0;f===void 0?p||B(i,c,u):u===void 0||p?B(i,c,r.schemaAt(f,["dependentSchemas",c],["dependencies",c])):B(i,c,{allOf:[r.schemaAt(f,["dependentSchemas",c],["dependencies",c,"allOf","0"]),{required:u}]})}Object.keys(i).length>0&&B(t,"dependencies",i)}function I9(e,t){Array.isArray(e.allOf)?e.allOf.push(t):B(e,"allOf",[t])}function T9(e,t,r,n){let o=e.$id,s=e.$anchor;if(s===void 0){o!==void 0&&B(t,r,o);return}(typeof s!="string"||!p9.test(s))&&qu("$anchor",n,"the anchor is not valid"),m9.test(s)||qu("$anchor",n,"the anchor cannot be represented as a plain-name fragment identifier"),o===void 0?B(t,r,`#${s}`):qu("$anchor",n,"it cannot be combined with the schema $id")}function yS(e){return Ls(Zl(e.ast),{schema:e})}var Zl=ma(e=>{let t=v9(e,Zl),r=e.context;return t===e||r===void 0?t:zl(t,lA(r))});function lA(e){return e.constructorDefault===void 0?e:new Yo(e.isOptional,e.isMutable,void 0,e.annotations)}function HL(e){if(e.propertySignatures.some(t=>typeof t.name!="string"))throw new globalThis.Error("Objects property names must be strings",{cause:e})}function qL(e){return t=>{let r=[...t].sort((o,s)=>e(Bn(o))-e(Bn(s)));return r.some((o,s)=>o!==t[s])?r:t}}var w9=qL(e=>{switch(e._tag){case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}});function v9(e,t){switch(e._tag){case"Declaration":{let r=e.annotations?.toCodecJson??e.annotations?.toCodec;if(!or(r))return lt(e,[Kv]);let n=e.typeParameters.map(s=>Ls(Bn(s))),o=r(n);return o===void 0?e:lt(e,[lc(o,t)])}case"Unknown":return lt(e,[Kv]);case"ObjectKeyword":return lt(e,[cL]);case"Undefined":case"Void":case"Literal":case"Number":return e.toCodecJson();case"UniqueSymbol":case"Symbol":case"BigInt":return e.toCodecStringTree();case"Objects":return HL(e),e.recur(t,iS);case"Union":{let r=w9(e.types);return r!==e.types?new Sn(r,e.options,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t):e.recur(t)}case"Arrays":case"Suspend":return e.recur(t)}return e}function SS(e){return Ls(zL(Nt(e.ast)))}var zL=mo(e=>{let t=A9(e,zL);return t!==e&&e.context!==void 0?zl(t,lA(e.context)):t});function A9(e,t){switch(e._tag){case"Declaration":{let r=e.annotations?.toCodecIso??e.annotations?.toCodec;if(or(r)){let n=r(e.typeParameters.map(o=>Ls(o)));return lt(e,[lc(n,t)])}return e}case"Arrays":case"Objects":case"Union":case"Suspend":return e.recur(t)}return e}function bS(e){return Ls(GL(e.ast),{schema:e})}function WL(e){return Ls(JL(e.ast))}var C9=qL(e=>{switch(e._tag){case"Null":case"Boolean":case"Number":case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}});function k9(e,t,r){switch(e._tag){case"Declaration":{let n=e.typeParameters.map(u=>Ls(t(Bn(u)))),o=e.annotations?.toCodecStringTree;if(or(o)){let u=o(n);return u===void 0?e:lt(e,[lc(u,t)])}let s=e.annotations?.toCodecJson,i=or(s)?s(n):void 0,a=i===void 0?e.annotations?.toCodec:void 0,c=i??(or(a)?a(n):void 0);return c===void 0?r(e):lt(e,[lc(c,t)])}case"Null":return lt(e,[R9]);case"Boolean":return lt(e,[O9]);case"Unknown":case"ObjectKeyword":return lt(e,[Vv]);case"Enum":case"Number":case"Literal":case"UniqueSymbol":case"Symbol":case"BigInt":return e.toCodecStringTree();case"Objects":return HL(e),e.recur(t,iS);case"Union":{let n=C9(e.types);return n!==e.types?new Sn(n,e.options,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t):e.recur(t)}case"Arrays":case"Suspend":return e.recur(t)}return e}var R9=new jt(new Ln("null"),new et(Ie(()=>null),Ie(()=>"null"))),O9=new jt(new Sn([new Ln("true"),new Ln("false")]),new et(Ie(e=>e==="true"),Du())),KL=new et(Ie(e=>typeof e=="string"?[e]:e),Oi()),VL=e=>e.transformation===KL,GL=ma(e=>{let t=k9(e,GL,r=>{throw new globalThis.Error("Missing structural codec for StringTree",{cause:r})});return t!==e&&e.context!==void 0?zl(t,lA(e.context)):t},{stopAt:VL}),jL=e=>Lr(e)?ju(pa):pa,JL=ma(e=>{let t=_9(e);if(wv(t)){let r=Kl(new Sn([new Xo(t.isMutable,t.elements.map(jL),t.rest.map(jL)),Ro],{mode:"anyOf"}),t,KL);return Lr(e)?ju(r):r}return t},{stopAt:VL});function _9(e){return e._tag==="Declaration"||e._tag==="Arrays"||e._tag==="Objects"||e._tag==="Union"||e._tag==="Suspend"?e.recur(JL):e}var dge=globalThis.RegExp;var ha=e=>e.replace(/[/\\^$*+?.()|[\]{}]/g,"\\$&");function dc(e,t){return t.length>0&&(e+=`
27
+ at ${Sx(t)}`),new Error(e)}function ZL(e){return`#/$defs/${aA(e)}`}var P9=new Set([...d1,Nu,...l1]);function Pm(e,t){if(e===void 0)return;let r={},n=e.title;typeof n=="string"&&(r.title=n);let o=e.description,s=e.expected;typeof o=="string"?r.description=o:t?.generateDescriptions===!0&&typeof s=="string"&&(r.description=s);let i=e.default;Vl(i)&&(r.default=i);let a=e.examples;Array.isArray(a)&&Vl(a)&&(r.examples=a);let c=e.readOnly;typeof c=="boolean"&&(r.readOnly=c);let u=e.writeOnly;typeof u=="boolean"&&(r.writeOnly=u);let f=e.format;typeof f=="string"&&(r.format=f);let p=e.contentEncoding;typeof p=="string"&&(r.contentEncoding=p);let m=e.contentMediaType;typeof m=="string"&&(r.contentMediaType=m);let h=e.contentSchema;if(Vl(h)&&(r.contentSchema=h),t?.includeAnnotationKey!==void 0)for(let[x,g]of Object.entries(e))P9.has(x)||!t.includeAnnotationKey(x)||Vl(g)&&B(r,x,g);return Object.keys(r).length===0?void 0:r}function QL(e){let t=e.type==="number"||e.type==="integer"?e.type:void 0,r=e;if(t!==void 0&&(r={...e},delete r.type),Array.isArray(r.allOf)){let n=[],o=!1;for(let s of r.allOf){let i=QL(s);i.type!==void 0&&(o=!0,(t===void 0||i.type==="integer")&&(t=i.type)),Object.keys(i.schema).length>0&&n.push(i.schema)}if(o){let{allOf:s,...i}=r;r=n.length===0?i:{...i,allOf:n}}}return{type:t,schema:r}}function M9(e){if(!Array.isArray(e.anyOf)||e.anyOf.length!==2||e.anyOf[0]?.type!=="number")return!1;let t=e.anyOf[1];return t?.type==="string"&&Array.isArray(t.enum)&&t.enum.length===3&&t.enum.includes("NaN")&&t.enum.includes("Infinity")&&t.enum.includes("-Infinity")}var YL="|type|format|pattern|multipleOf|minimum|maximum|exclusiveMinimum|exclusiveMaximum|minLength|maxLength|minItems|maxItems|uniqueItems|minProperties|maxProperties|propertyNames|";function ES(e,t){return Object.keys(e).every(r=>t.includes(`|${r}|`))}function F9(e,t){return typeof e.$ref!="string"&&t.every(r=>!Object.hasOwn(e,r))}var N9="|minimum|exclusiveMinimum|minLength|minItems|minProperties|",U9="|maximum|exclusiveMaximum|maxLength|maxItems|maxProperties|";function D9(e,t,r){if(typeof e.$ref=="string")return;let n={...e,...t};for(let o of r){if(!Object.hasOwn(e,o))continue;let s=e[o],i=t[o];if(typeof s!="number"||typeof i!="number")return;if(N9.includes(`|${o}|`))n[o]=Math.max(s,i);else if(U9.includes(`|${o}|`))n[o]=Math.min(s,i);else return}return typeof n.minimum=="number"&&typeof n.exclusiveMinimum=="number"&&delete n[n.exclusiveMinimum>=n.minimum?"minimum":"exclusiveMinimum"],typeof n.maximum=="number"&&typeof n.exclusiveMaximum=="number"&&delete n[n.exclusiveMaximum<=n.maximum?"maximum":"exclusiveMaximum"],n}var mA="|title|description|default|examples|readOnly|writeOnly|",L9=YL+mA;function Mm(e,t,r){if(Object.keys(e).length===0)return t;let n=Object.keys(t);if(n.length===0)return e;let o=e.type==="number"||e.type==="integer"?e.type:void 0,s=M9(e);if(o!==void 0||s){let a=QL(t);if(a.type!==void 0){let c=o==="integer"||a.type==="integer"?"integer":"number",u={...e,type:c};s&&delete u.anyOf;let f=Object.keys(a.schema);return f.length===0?u:ES(a.schema,mA)&&F9(u,f)?{...u,...a.schema}:Mm(u,a.schema,r)}}if(r){let a=D9(e,t,n);if(a!==void 0)return a}let i=Array.isArray(t.allOf)&&n.length===1?t.allOf:[t];return Array.isArray(e.allOf)?{...e,allOf:[...e.allOf,...i]}:typeof e.$ref=="string"?{allOf:[e,...i]}:{...e,allOf:i}}function pA(e,t=new Set){return typeof e=="boolean"?e:t.has(e)?!0:(t.add(e),e.every(r=>pA(r,t)))}function B9(e){return Array.isArray(e)}function $9(e,t,r,n){let o=new Map,s=new Map,i=new WeakMap,a=new Map,c=new Map,u=Object.keys(r);for(let S of u)x(S,["references",S]);let f=Bo(e,(S,w)=>b(S,t[w],[]));for(let[S,w]of a.values())if(!pA(S))for(let k of w)Array.isArray(k.oneOf)&&(k.anyOf=k.oneOf,delete k.oneOf);for(let S of u){let w=r[S],k=y(w);if(k===void 0)continue;let A=o.get(S)[0],R=c.get(k),M=R?.find($=>Z(o.get($)[0],A));M===void 0?R===void 0?c.set(k,[S]):R.push(S):s.set(S,M)}let p=Bo(f,g),m={};for(let S of u)s.has(S)||B(m,S,g(o.get(S)[0]));return{dialect:"draft-2020-12",schemas:p,definitions:m};function h(S){return Array.isArray(S.oneOf)&&a.get(S.oneOf)?.[1].push(S),S}function x(S,w){if(!Object.hasOwn(r,S))throw dc(`Invalid reference ${S}`,[...w,"$ref"]);let k=o.get(S);if(k!==void 0)return k;let A=[{},[]];return o.set(S,A),A[0]=b(r[S],["references",S],A[1]),A}function g(S){return UL(S,w=>{let k=cA(w);if(k===void 0){if(/^#(?:\/|%2f)/i.test(w))throw new Error(`Invalid JSON Pointer URI fragment ${JSON.stringify(w)}`);return w}if(!k.startsWith("/$defs/"))return w;let A=k.indexOf("/",7),R=s.get(Om(k.slice(7,A<0?void 0:A)));return R===void 0?w:w.replace(/^#(?:\/|%2f).*?(?:\/|%2f).*?(?=\/|%2f|$)/i,ZL(R))})}function y(S){if(S._tag==="Reference")return;let w=S.checks.length===0?S.annotations:S.checks[S.checks.length-1].annotations;return typeof w?.identifier!="string"&&typeof w?.[Nu]=="string"?w[Nu]:void 0}function E(S,w,k,A){let R=S.annotations,M=R?.toJsonSchema;if(M!==void 0){let Le=S.representation?.schemas?.map((Rn,sI)=>b(Rn,[...k,"representation","schemas",sI],A))??[],Er=M({type:w,schemas:Le}),Ee=B9(Er);Ee&&A.push(!1);let Oe=Ee?Er[0]:Er,rr=Pm(R,n),lo=rr===void 0?Oe:{...Oe,...rr},Xs=rr===void 0?YL:L9;return[lo,S._tag==="Filter"&&ES(lo,Xs)&&(rr===void 0||ES(rr,mA))?!0:void 0]}if(S._tag==="Filter"){A.push(!1);return}let $=S.checks.flatMap((Le,Er)=>{let Ee=E(Le,w,[...k,"checks",Er],A);return Ee===void 0?[]:[Ee[0]]});if($.length===0)return;let te=Pm(R,n),xe={allOf:$};return[te===void 0?xe:{...xe,...te}]}function b(S,w,k){if(S._tag==="Reference")return k.push(x(S.$ref,w)[1]),{$ref:ZL(S.$ref)};let A=i.get(S);if(A!==void 0)return k.push(A[1]),A[0];let R=[];k.push(R);let M=v(S,w,R),$=Pm(S.annotations,n);$!==void 0&&(M={...M,...$});for(let te=0;te<S.checks.length;te++){let xe=typeof M.type=="string"&&j9(M.type)?M.type:void 0,Le=E(S.checks[te],xe,[...w,"checks",te],R);Le!==void 0&&(M=Mm(M,...Le))}return i.set(S,[M,R]),h(M)}function v(S,w,k){switch(S._tag){case"Any":case"Unknown":return{};case"ObjectKeyword":return{anyOf:[{type:"object"},{type:"array"}]};case"Void":case"Undefined":case"Null":return{type:"null"};case"BigInt":return{type:"string",allOf:[{pattern:"^-?\\d+$"}]};case"Symbol":return{type:"string",allOf:[{pattern:"^Symbol\\(([\\s\\S]*)\\)$"}]};case"UniqueSymbol":return globalThis.Symbol.keyFor(S.symbol)===void 0?{not:{}}:{type:"string",enum:[globalThis.String(S.symbol)]};case"Declaration":return k.push(!1),{};case"Suspend":return b(S.thunk,[...w,"thunk"],k);case"Never":return{not:{}};case"String":return{type:"string"};case"Number":return{anyOf:[{type:"number"},{type:"string",enum:["NaN","Infinity","-Infinity"]}]};case"Boolean":return{type:"boolean"};case"Literal":{let A=S.literal;return typeof A=="bigint"?{type:"string",enum:[globalThis.String(A)]}:{type:typeof A,enum:[A]}}case"Enum":{let A=S.enums.map(([R,M],$)=>{if(typeof M=="number"&&!globalThis.Number.isFinite(M))throw dc(`Invalid numeric enum value ${globalThis.String(M)}`,[...w,"enums",$,1]);return{type:typeof M,enum:[M],title:R}});return A.length===0?{not:{}}:{anyOf:A}}case"TemplateLiteral":return{type:"string",pattern:`^${S.parts.map(IS).join("")}$`};case"Arrays":{if(S.rest.length>1)throw dc("Invalid schema representation document",[...w,"rest"]);let A={type:"array"},R=S.elements.length,M=S.elements.map(($,te)=>{$.isOptional&&R--;let xe=b($.type,[...w,"elements",te,"type"],k),Le=Pm($.annotations,n);return Le===void 0?xe:h(Mm(xe,Le))});if(M.length>0?(A.prefixItems=M,A.maxItems=S.elements.length,R>0&&(A.minItems=R)):A.items=!1,S.rest.length===1){delete A.maxItems;let $=b(S.rest[0],[...w,"rest",0],k);Object.keys($).length>0?A.items=$:delete A.items}return A}case"Objects":{if(S.propertySignatures.length===0&&S.indexSignatures.length===0)return{not:{type:"null"}};let A={type:"object"},R={},M=[];for(let Ee=0;Ee<S.propertySignatures.length;Ee++){let Oe=S.propertySignatures[Ee];if(typeof Oe.name!="string")throw dc("Invalid schema representation document",[...w,"propertySignatures",Ee,"name"]);let rr=Oe.name,lo=b(Oe.type,[...w,"propertySignatures",Ee,"type"],k),Xs=Pm(Oe.annotations,n);B(R,rr,Xs===void 0?lo:h(Mm(lo,Xs))),Oe.isOptional||M.push(rr)}S.propertySignatures.length>0&&(A.properties=R),M.length>0&&(A.required=M);let $={},te=[],xe=[],Le=!1;for(let Ee=0;Ee<S.indexSignatures.length;Ee++){let Oe=S.indexSignatures[Ee],rr=b(Oe.type,[...w,"indexSignatures",Ee,"type"],k);Z(rr,{not:{}})&&(rr=!1),xe.push(rr);let lo=T(Oe.parameter,[...w,"indexSignatures",Ee,"parameter"],new Set);if(lo===void 0){Le=!0,k.push(!1);continue}if(lo.length===0)te.push(rr);else for(let Xs of lo){let Rn=$[Xs];B($,Xs,Rn===void 0?rr:Rn===!1||rr===!1?!1:h(Mm(Rn,rr)))}}let Er=Object.keys($).length>0;if(Er&&(A.patternProperties=$),Le&&n?.onExcessProperty==="error"){let Ee=[];S.propertySignatures.length>0&&Ee.push({enum:Object.keys(R)});for(let Oe=0;Oe<S.indexSignatures.length;Oe++)Ee.push(b(S.indexSignatures[Oe].parameter,[...w,"indexSignatures",Oe,"parameter"],k));A.propertyNames=Ee.length===1?Ee[0]:{anyOf:Ee},A.additionalProperties=xe.length===1?xe[0]:{anyOf:xe},te.length>0&&(A.allOf=te.map(Oe=>({type:"object",additionalProperties:Oe})))}else te.length===0?A.additionalProperties=Le||n?.onExcessProperty!=="error":te.length===1&&S.propertySignatures.length===0&&!Er?A.additionalProperties=te[0]:te.length>0&&(A.allOf=te.map(Ee=>({type:"object",additionalProperties:Ee})));return typeof A.additionalProperties=="object"&&A.additionalProperties!==null&&Object.keys(A.additionalProperties).length===0&&delete A.additionalProperties,A}case"Union":{let A=[],R=S.types.map(($,te)=>b($,[...w,"types",te],A));if(k.push(A),R.length===0)return{not:{}};let M=S.options?.mode??"anyOf";if(M==="anyOf"&&R.length>1){let $=H9(R);if($!==void 0)return $}return M==="oneOf"&&a.set(R,[A,[]]),{[M]:R}}}}function T(S,w,k){switch(S._tag){case"Reference":{if(!Object.hasOwn(r,S.$ref))throw dc(`Invalid reference ${S.$ref}`,[...w,"$ref"]);if(x(S.$ref,w),k.has(S.$ref))return;let A=new Set(k).add(S.$ref);return T(r[S.$ref],["references",S.$ref],A)}case"String":{if(S.checks.length===0)return[];if(S.checks.length!==1||S.checks[0]._tag!=="Filter"||S.checks[0].annotations?.toJsonSchema===void 0)return;let A=[],R=b(S,w,A);return pA(A)&&R.type==="string"&&typeof R.pattern=="string"&&ES(R,"|type|pattern|title|description|default|examples|readOnly|writeOnly|")?[R.pattern]:void 0}case"TemplateLiteral":return S.checks.length===0?[`^${S.parts.map(IS).join("")}$`]:void 0;case"Union":{if(S.types.length===0||S.checks.length>0||S.options?.mode==="oneOf")return;let A=[];for(let R=0;R<S.types.length;R++){let M=T(S.types[R],[...w,"types",R],k);if(M===void 0)return;if(M.length===0)return[];A.push(...M)}return A}default:throw dc("Invalid schema representation document",w)}}}function j9(e){return e==="string"||e==="number"||e==="boolean"||e==="array"||e==="object"||e==="null"||e==="integer"}function H9(e){let t,r=[];for(let n of e){if(Object.keys(n).length!==2||n.type===void 0||!Array.isArray(n.enum)||n.enum.length===0)return;if(t===void 0)t=n.type;else if(n.type!==t)return;for(let s of n.enum){if(r.includes(s))return;r.push(s)}}return{type:t,enum:r}}function IS(e){switch(e._tag){case"Literal":return ha(globalThis.String(e.literal));case"String":return tL;case"Number":return Xy;case"TemplateLiteral":return e.parts.map(IS).join("");case"Union":return`(?:${e.types.map(IS).join("|")})`;default:throw dc("Invalid schema representation document",[])}}function TS(e,t){let r=$9([e.representation],[["representation"]],e.references,t);return{dialect:r.dialect,schema:r.schemas[0],definitions:r.definitions}}var q9=({identifier:e})=>e;function Bs(e){return e===void 0?void 0:{annotations:e}}function Fm(e,t){let{references:r,representations:n}=z9([e],t);return{representation:n[0],references:r}}function z9(e,t){let r={},n=new Map,o=new Set,s=new Map,i=new Set;for(let S of e)h(S);let a=t?.referencePolicy??q9;for(let S of s.values())for(let w of S.values()){let k=a({ast:w.ast,occurrences:w.occurrences,identifier:w.identifier});if(k!==void 0){let A=k===w.identifier||!k.endsWith("_")?"_":"";w.reference=u(k,w,A)}else w.isRecursive&&(w.reference=u(`${w.ast._tag}_`,w,""))}return{representations:Bo(e,S=>g(S)),references:r};function u(S,w,k="_"){let A=S,R=0;for(;n.has(A);){if(n.get(A)===w)return A;A=`${S}${k}${++R}`}return n.set(A,w),A}function f(S,w,k){let A=w.fallback;return A!==void 0?Xw(S)===A?S:Fs(S,{[Nu]:A}):k===w.identifier?S:Fs(S,{identifier:k})}function p(S,w){if(!Object.hasOwn(r,S)&&!o.has(S)){o.add(S);let k=y(w);o.delete(S),B(r,S,k)}return{_tag:"Reference",$ref:S}}function m(S){let w=ql(S),k=Hl(w),A=_l(w),R=A===void 0?(w!==S?_l(S):void 0)??Xw(w):void 0;R!==void 0&&(A=`${R}Encoded`);let M=s.get(k);M===void 0&&(M=new Map,s.set(k,M));let $=M.get(A);return $===void 0&&($={ast:k,identifier:A,fallback:R,occurrences:0,isRecursive:!1,reference:void 0},M.set(A,$)),$}function h(S){let w=m(S),k=w.ast;if(w.occurrences++,i.has(w)){w.isRecursive=!0;return}if(!(w.occurrences>1)){switch(i.add(w),x(k.checks),k._tag){case"Declaration":case"Arrays":case"Objects":case"Union":k.recur(A=>(h(A),A));break;case"TemplateLiteral":k.parts.forEach(h);break;case"Suspend":h(k.thunk());break}i.delete(w)}}function x(S){S?.forEach(w=>{w.annotations?.representation?.schemas?.forEach(k=>h(Nt(k))),w._tag==="FilterGroup"&&x(w.checks)})}function g(S){let w=m(S),k=w.ast,A=w.reference;if(A!==void 0){let R=w.identifier===void 0?k:f(k,w,A);return p(A,R)}return y(k)}function y(S){let w=E(S.checks);switch(S._tag){case"Declaration":return{_tag:"Declaration",typeParameters:S.typeParameters.map(k=>g(k)),checks:w,...v(S.annotations)};case"Null":case"Undefined":case"Void":case"Never":case"Unknown":case"Any":case"String":case"Boolean":case"Number":case"BigInt":case"Symbol":case"ObjectKeyword":return{_tag:S._tag,checks:w,...Bs(S.annotations)};case"Literal":return{_tag:"Literal",literal:S.literal,checks:w,...Bs(S.annotations)};case"UniqueSymbol":return{_tag:"UniqueSymbol",symbol:S.symbol,checks:w,...Bs(S.annotations)};case"Enum":return{_tag:"Enum",enums:S.enums,checks:w,...Bs(S.annotations)};case"TemplateLiteral":return{_tag:"TemplateLiteral",parts:S.parts.map(k=>g(k)),checks:w,...Bs(S.annotations)};case"Arrays":return{_tag:"Arrays",elements:S.elements.map(k=>{let A=ql(k),R=A.context?.annotations;return{isOptional:Lr(A),type:g(k),...Bs(R)}}),rest:S.rest.map(k=>g(k)),checks:w,...Bs(S.annotations)};case"Objects":return{_tag:"Objects",propertySignatures:S.propertySignatures.map(k=>{let A=ql(k.type),R=A.context?.annotations;return{name:k.name,type:g(k.type),isOptional:Lr(A),isMutable:Q2(A),...Bs(R)}}),indexSignatures:S.indexSignatures.map(k=>({parameter:g(k.parameter),type:g(k.type)})),checks:w,...Bs(S.annotations)};case"Union":return{_tag:"Union",types:S.types.map(k=>g(k)),...S.options===void 0?{}:{options:S.options},checks:w,...Bs(S.annotations)};case"Suspend":return{_tag:"Suspend",checks:[],thunk:g(S.thunk()),...Bs(S.annotations)}}}function E(S){return S?.map(b)??[]}function b(S){switch(S._tag){case"Filter":return{_tag:"Filter",aborted:S.aborted,...T(S.annotations)};case"FilterGroup":return{_tag:"FilterGroup",checks:Bo(S.checks,b),...T(S.annotations)}}}function v(S){if(S===void 0)return;let{representation:w,...k}=S;return{...w===void 0?void 0:{representation:w},...Object.keys(k).length===0?void 0:{annotations:k}}}function T(S){if(S===void 0)return;let{representation:w,...k}=S,A=w===void 0?void 0:w.schemas===void 0?w:{...w,schemas:w.schemas.map(R=>g(Nt(R)))};return{...A===void 0?void 0:{representation:A},...Object.keys(k).length===0?void 0:{annotations:k}}}}function tB(e){return ft(e)?e.value:{issues:[{message:bN(e.cause)}]}}function nB(e,t){let r=ot(e),n={errors:"all",...t?.parseOptions},o=b1(t),s=i=>{let a=new fi("sync"),c=Yp(Y0(r(i,n),{onFailure:o,onSuccess:f=>({value:f})}),{scheduler:a});c.currentDispatcher?.flush();let u=c.pollUnsafe();return u?tB(u):new Promise(f=>{c.addObserver(p=>{f(tB(p))})})};if(Object.hasOwn(e,"~standard")){let i=e;return"validate"in i["~standard"]||Object.assign(i["~standard"],{validate:s}),i}return Object.assign(e,{"~standard":{version:1,vendor:"effect",validate:s}})}function W9(e){let t=Fm(Zl(e));return TS(t)}function rB(e,t){let r=W9(e);if(t==="draft-2020-12"){let n=r.schema;return Object.keys(r.definitions).length>0&&(n.$defs=r.definitions),n}else if(t==="draft-07"){let n=NL(r),o=n.schema;return Object.keys(n.definitions).length>0&&(o.definitions=n.definitions),o}throw new globalThis.Error(`Unsupported target: ${t}`)}function oB(e){let t={input(r){return rB(e.ast,r.target)},output(r){return rB(Nt(e.ast),r.target)}};if(Object.hasOwn(e,"~standard")){let r=e;return"jsonSchema"in r["~standard"]||Object.assign(r["~standard"],{jsonSchema:t}),r}return Object.assign(e,{"~standard":{version:1,vendor:"effect",jsonSchema:t}})}function iB(e,t){let r=[];return hA(e,t,"",r),r}function hA(e,t,r,n){if(!Object.is(e,t)){if(Array.isArray(e)&&Array.isArray(t)){let o=e.length,s=t.length,i=Math.min(o,s);for(let a=0;a<i;a++)hA(e[a],t[a],`${r}/${a}`,n);for(let a=o-1;a>=s;a--)n.push({op:"remove",path:`${r}/${a}`});for(let a=o;a<s;a++)n.push({op:"add",path:`${r}/${a}`,value:t[a]});return}if(wS(e)&&wS(t)){let o=Object.keys(e),s=Object.keys(t),i=Array.from(new Set([...o,...s])).sort();for(let a of i){let c=`${r}/${iA(a)}`,u=Object.hasOwn(e,a),f=Object.hasOwn(t,a);u&&f?hA(e[a],t[a],c,n):!u&&f?n.push({op:"add",path:c,value:t[a]}):n.push({op:"remove",path:c})}return}n.push({op:"replace",path:r,value:t})}}function aB(e,t){let r=t;for(let n of e)r=G9(r,n);return r}function wS(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function V9(e){if(e==="")return[];if(e.charCodeAt(0)!==47)throw new Error(`Invalid JSON Pointer, it must start with "/": ${JSON.stringify(e)}`);return e.split("/").slice(1).map(Om)}function cB(e){if(!/^(0|[1-9]\d*)$/.test(e))throw new Error(`Invalid array index: "${e}"`);return Number(e)}function G9(e,t){if(t.path===""){if(t.op==="remove")throw new Error("Unsupported operation at the root");return t.value}let r=J9(e,t.path);if(r===null)throw new Error(`Cannot ${t.op} at "${t.path}" (parent not found or not a container).`);let{lastToken:n,parent:o,stack:s}=r;if(Array.isArray(o)){if(n==="-"&&t.op!=="add")throw new Error(`"-" is not valid for ${t.op} at "${t.path}".`);let i=n==="-"?o.length:cB(n),a=t.op==="add"?o.length:o.length-1;if(i>a)throw new Error(`Array index out of bounds at "${t.path}".`);let c=o.slice();return t.op==="add"?c.splice(i,0,t.value):t.op==="remove"?c.splice(i,1):c[i]=t.value,sB(s,c)}if(wS(o)){if(t.op!=="add"&&!Object.hasOwn(o,n))throw new Error(`Property "${n}" does not exist at "${t.path}".`);let i={...o};return t.op==="remove"?delete i[n]:B(i,n,t.value),sB(s,i)}throw new Error(`Cannot ${t.op} at "${t.path}" (parent not found or not a container).`)}function J9(e,t){let r=V9(t);if(r.length===0)return null;let n=r[r.length-1],o=[],s=e;for(let i=0;i<r.length-1;i++){let a=r[i];if(Array.isArray(s)){let c=cB(a);if(c>=s.length)return null;o.push({container:s,token:c}),s=s[c];continue}if(wS(s)){if(!Object.hasOwn(s,a))return null;o.push({container:s,token:a}),s=s[a];continue}return null}return{stack:o,parent:s,lastToken:n}}function sB(e,t){let r=t;for(let n=e.length-1;n>=0;n--){let{container:o,token:s}=e[n];if(Array.isArray(o)){let i=o.slice();i[s]=r,r=i}else{let i={...o};B(i,s,r),r=i}}return r}function fB(e){let t=yS(e),r=hS(t),n=mS(t);return{empty:[],diff:(o,s)=>iB(r(o),r(s)),combine:(o,s)=>[...o,...s],patch:(o,s)=>{let i=r(o),a=aB(s,i);return Object.is(a,i)?o:n(a)}}}function lB(e,t){let r=_l(e.ast)??ev(e.ast),n=bL(bS(e));return o=>n(o).pipe(K(s=>Q9(s,{rootName:r,...t})))}function Q9(e,t){let r=t.rootName??"root",n=t.arrayItemName??"item",o=t.pretty??!0,s=t.indent??" ",i=t.sortKeys??!0,a=new Set,c=[];return f(r,e,0),c.join(o?`
28
+ `:"");function u(p,m){c.push(o?s.repeat(p)+m:m)}function f(p,m,h,x){let{attrs:g,safe:y}=Ql.tagInfo(p,x);if(m===void 0)u(h,`<${y}${g}/>`);else if(typeof m=="string")u(h,`<${y}${g}>${Ql.escapeText(m)}</${y}>`);else if(typeof m!="object"||m===null)u(h,`<${y}${g}>${Ql.escapeText(H(m))}</${y}>`);else{if(a.has(m))throw new globalThis.Error("Cycle detected while serializing to XML.",{cause:m});a.add(m);try{if(globalThis.Array.isArray(m)){if(m.length===0){u(h,`<${y}${g}/>`);return}u(h,`<${y}${g}>`);for(let v of m)f(n,v,h+1);u(h,`</${y}>`);return}let E=m,b=Object.keys(E);if(i&&b.sort(),b.length===0){u(h,`<${y}${g}/>`);return}u(h,`<${y}${g}>`);for(let v of b)f(Ql.parseTagName(v).safe,E[v],h+1,v);u(h,`</${y}>`)}finally{a.delete(m)}}}}var Ql={escapeText(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")},escapeAttribute(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")},parseTagName(e){let t=e,r=e;return/^[A-Za-z_]/.test(r)||(r="_"+r),r=r.replace(/[^A-Za-z0-9._-]/g,"_"),/^xml/i.test(r)&&(r="_"+r),{safe:r,changed:r!==t}},tagInfo(e,t){let{changed:r,safe:n}=Ql.parseTagName(e),s=r||t&&t!==e?` data-name="${Ql.escapeAttribute(t??e)}"`:"";return{safe:n,attrs:s}}};var xA=mo(e=>pc(e));function pc(e){let t=da(e)?.toEquivalence;if(t)return t(jl(e)?e.typeParameters.map(pc):[]);switch(e._tag){case"Never":return Yc();case"Declaration":return X9(e);case"Null":case"Undefined":case"Void":case"Unknown":case"Any":case"String":case"Number":case"Boolean":case"BigInt":case"Symbol":case"Literal":case"UniqueSymbol":case"ObjectKeyword":case"Enum":case"TemplateLiteral":return Z;case"Arrays":{let r=e.elements.map(pc),n=e.rest.map(pc),[o,...s]=n,i=s.length;return Wr((a,c)=>{if(!Array.isArray(a)||!Array.isArray(c))return!1;let u=a.length;if(u!==c.length)return!1;let f=0;for(;f<Math.min(u,e.elements.length);f++)if(!r[f](a[f],c[f]))return!1;if(n.length>0){for(;f<u-i;f++)if(!o(a[f],c[f]))return!1;for(let p=0;p<i;p++)if(!s[p](a[f+p],c[f+p]))return!1}return!0})}case"Objects":{if(e.propertySignatures.length===0&&e.indexSignatures.length===0)return Z;let r=e.propertySignatures.map(o=>pc(o.type)),n=e.indexSignatures.map(o=>pc(o.type));return Wr((o,s)=>{if(!Jt(o)||!Jt(s))return!1;for(let i=0;i<r.length;i++){let a=e.propertySignatures[i],c=a.name,u=Object.hasOwn(o,c),f=Object.hasOwn(s,c);if(Lr(a.type)&&u!==f||u&&f&&!r[i](o[c],s[c]))return!1}for(let i=0;i<n.length;i++){let a=e.indexSignatures[i],c=_i(o,a.parameter),u=_i(s,a.parameter);if(c.length!==u.length)return!1;for(let f=0;f<c.length;f++){let p=c[f];if(!Object.hasOwn(s,p)||!n[i](o[p],s[p]))return!1}}return!0})}case"Union":{let r=Nt(e).types,n=vm(r),o=r.map((s,i)=>[Rm(s),pc(e.types[i])]);return Wr((s,i)=>{let a=n(s,!1);for(let c=0;c<a.length;c++){let[u,f]=o[a[c]];if(u(s)&&u(i))return f(s,i)}return!1})}case"Suspend":{let r;return Wr((n,o)=>(r??=xA(e.thunk()))(n,o))}}}function X9(e){let t=e.annotations?.representation;if(t===void 0)return Z;switch(t.id){case"effect/schema/Option":{let[r]=zu(e);return(n,o)=>n._tag===o._tag&&(n._tag==="None"||r(n.value,o.value))}case"effect/schema/Result":{let[r,n]=zu(e);return(o,s)=>o._tag===s._tag&&(o._tag==="Success"?r(o.success,s.success):n(o.failure,s.failure))}case"effect/schema/CauseReason":{let[r,n]=zu(e);return pB(r,n)}case"effect/schema/Cause":{let[r,n]=zu(e);return dB(r,n)}case"effect/schema/Exit":{let[r,n,o]=zu(e),s=dB(n,o);return(i,a)=>i._tag===a._tag&&(i._tag==="Success"?r(i.value,a.value):s(i.cause,a.cause))}case"effect/schema/ReadonlyMap":{let[r,n]=zu(e);return yx(r,n)}case"effect/schema/ReadonlySet":return zd(zu(e)[0]);case"effect/schema/RegExp":return(r,n)=>r.source===n.source&&r.flags===n.flags;case"effect/schema/URL":return(r,n)=>r.toString()===n.toString();default:return Z}}function zu(e){return e.typeParameters.map(pc)}function pB(e,t){return(r,n)=>{if(r._tag!==n._tag)return!1;switch(r._tag){case"Fail":return e(r.error,n.error);case"Die":return t(r.defect,n.defect);case"Interrupt":return r.fiberId===n.fiberId}}}function dB(e,t){let r=vx(pB(e,t));return(n,o)=>r(n.reasons,o.reasons)}function hB(e,t){return r=>{switch(r._tag){case"Fail":return`Fail(${e(r.error)})`;case"Die":return`Die(${t(r.defect)})`;case"Interrupt":return"Interrupt"}}}function mB(e,t){let r=hB(e,t);return n=>`Cause([${n.reasons.map(r).join(", ")}])`}function xB(e,t){let r=new Map;return n(e);function n(i){let a=r.get(i);return a===void 0&&(a=o(i),r.set(i,a)),a}function o(i){let a=da(i)?.toFormatter;if(typeof a=="function")return a(jl(i)?i.typeParameters.map(n):[]);if(t?.onBefore){let c=t.onBefore(i,n);if(c!==void 0)return c}return s(i)}function s(i){switch(i._tag){default:return H;case"Never":return()=>"never";case"Void":return()=>"void";case"Declaration":{let a=i.annotations?.representation;if(a===void 0)return H;let c=i.typeParameters.map(n);switch(a.id){case"effect/schema/Option":{let[u]=c;return Zt({onNone:()=>"none()",onSome:f=>`some(${u(f)})`})}case"effect/schema/Result":{let[u,f]=c;return zn({onSuccess:p=>`success(${u(p)})`,onFailure:p=>`failure(${f(p)})`})}case"effect/schema/CauseReason":return hB(c[0],c[1]);case"effect/schema/Cause":return mB(c[0],c[1]);case"effect/schema/Exit":{let[u,f,p]=c,m=mB(f,p);return h=>{switch(h._tag){case"Success":return`Exit.Success(${u(h.value)})`;case"Failure":return`Exit.Failure(${m(h.cause)})`}}}case"effect/schema/ReadonlyMap":{let[u,f]=c;return p=>{let m=p.size;if(m===0)return"ReadonlyMap(0) {}";let h=globalThis.Array.from(p.entries()).sort().map(([x,g])=>`${u(x)} => ${f(g)}`);return`ReadonlyMap(${m}) { ${h.join(", ")} }`}}case"effect/schema/HashMap":{let[u,f]=c;return p=>{let m=BD(p);if(m===0)return"HashMap(0) {}";let h=im(p).sort().map(([x,g])=>`${u(x)} => ${f(g)}`);return`HashMap(${m}) { ${h.join(", ")} }`}}case"effect/schema/ReadonlySet":{let[u]=c;return f=>{let p=f.size;if(p===0)return"ReadonlySet(0) {}";let m=globalThis.Array.from(f.values()).sort().map(h=>`${u(h)}`);return`ReadonlySet(${p}) { ${m.join(", ")} }`}}case"effect/schema/HashSet":{let[u]=c;return f=>{let p=qD(f);if(p===0)return"HashSet(0) {}";let m=globalThis.Array.from(f).sort().map(h=>`${u(h)}`);return`HashSet(${p}) { ${m.join(", ")} }`}}case"effect/schema/Chunk":{let[u]=c;return f=>{let p=xD(f);if(p===0)return"Chunk(0) {}";let m=globalThis.Array.from(f).sort().map(h=>`${u(h)}`);return`Chunk(${p}) { ${m.join(", ")} }`}}default:return H}}case"Arrays":{let a=i.elements.map(m=>n(m)),c=i.rest.map(n),[u,...f]=c,p=f.length;return m=>{let h=[],x=0;for(;x<a.length;x++)if(m.length<x+1){if(Lr(i.elements[x]))continue}else h.push(a[x](m[x]));if(c.length>0){for(;x<m.length-p;x++)h.push(u(m[x]));for(let g=0;g<p;g++)h.push(f[g](m[x+g]))}return"["+h.join(", ")+"]"}}case"Objects":{let a=i.propertySignatures.map(u=>n(u.type)),c=i.indexSignatures.map(u=>n(u.type));return i.propertySignatures.length===0&&i.indexSignatures.length===0?H:u=>{let f=[],p=new Set;for(let m=0;m<a.length;m++){let h=i.propertySignatures[m],x=h.name;p.add(x),!(Lr(h.type)&&!Object.hasOwn(u,x))&&f.push(`${ni(x)}: ${a[m](u[x])}`)}for(let m=0;m<c.length;m++){let h=_i(u,i.indexSignatures[m].parameter);for(let x of h)p.has(x)||(p.add(x),f.push(`${ni(x)}: ${c[m](u[x])}`))}return f.length>0?"{ "+f.join(", ")+" }":"{}"}}case"Union":{let a=Nt(i).types,c=vm(a),u=a.map((f,p)=>[Rm(f),n(i.types[p])]);return f=>{let p=c(f,!1);for(let m=0;m<p.length;m++){let[h,x]=u[p[m]];if(h(f))return x(f)}return H(f)}}case"Suspend":{let a;return c=>(a??=n(i.thunk()))(c)}}}}var gA=d(2,(e,t)=>bA(e,(r,n)=>yB(t,r)?[r,n]:void 0)),yA=d(2,(e,t)=>bA(e,(r,n)=>yB(t,r)?void 0:[r,n])),gB=d(2,(e,t)=>({...e,...t}));var SA=d(2,(e,t)=>bA(e,(r,n)=>[Object.hasOwn(t,r)?t[r]:r,n]));var bn=e=>e;function yB(e,t){return e.some(r=>r===t||typeof r=="number"&&String(r)===t)}function bA(e,t){let r={};for(let n of Reflect.ownKeys(e)){if(!Object.prototype.propertyIsEnumerable.call(e,n))continue;let o=t(n,e[n]);if(o){let[s,i]=o;B(r,s,i)}}return r}function EB(e,t){return $s(Yl("Iso",e,t))}function SB(e,t){return $s(Yl("Lens",e,t))}function Yl(e,t,r){return[{_tag:"PrimitiveNode",kind:e,get:t,set:r}]}var rY={kind:"Iso",get:F,set:F},vS=class{_tag="PathNode";kind="Lens";path;get;set;constructor(t){this.path=t,this.get=r=>{let n=r;for(let o=0;o<t.length;o++)n=n[t[o]];return n},this.set=(r,n)=>{let o=AS(n),s=o,i=0;for(;i<t.length-1;i++){let a=t[i];B(s,a,AS(s[a])),s=s[a]}return B(s,t[i],r),o}}},Nm=class{_tag="CheckNode";kind="Prism";checks;get;set=F;constructor(t){this.checks=t,this.get=r=>oL(t,r)}};function Wu(e,t){if(e.length===0)return t;if(t.length===0)return e;let r=e.slice();for(let n=0;n<t.length;n++){let o=t[n],s=r[r.length-1];s._tag==="PathNode"&&o._tag==="PathNode"?r[r.length-1]=new vS([...s.path,...o.path]):s._tag==="CheckNode"&&o._tag==="CheckNode"?r[r.length-1]=new Nm([...s.checks,...o.checks]):r.push(o)}return r}function nY(e,t){return $s(Yl("Optional",e,t))}var Xl=class{node;getResult;replaceResult;constructor(t,r,n){this.node=t,this.getResult=r,this.replaceResult=n}replace(t,r){return ap(this.replaceResult(t,r),()=>r)}modify(t){return r=>ap(hr(this.getResult(r),n=>this.replaceResult(t(n),r)),()=>r)}compose(t){return $s(Wu(this.node,t.node))}key(t){return $s(Wu(this.node,[new vS([t])]))}optionalKey(t){return $s(Wu(this.node,Yl("Lens",r=>r[t],(r,n)=>{let o=AS(n);return r===void 0?Array.isArray(o)&&(typeof t=="number"||typeof t=="string"&&jx(t))?o.splice(Number(t),1):delete o[t]:B(o,t,r),o})))}check(...t){return $s(Wu(this.node,[new Nm(t)]))}refine(t,r){return $s(Wu(this.node,[new Nm([nS(t,r)])]))}tag(t){let r=re(new le({expected:`${JSON.stringify(t)} tag`}));return $s(Wu(this.node,Yl("Prism",n=>n._tag===t?X(n):r,F)))}at(t,...r){let n=re(new Ct([t],new Yt(void 0)));return $s(Wu(this.node,Yl("Optional",o=>Object.hasOwn(o,t)?X(o[t]):n,(o,s)=>{if(Object.hasOwn(s,t)){let i=AS(s);return B(i,t,o),X(i)}else return n})))}pick(t){return this.compose(SB(gA(t),(r,n)=>({...yA(n,t),...r})))}omit(t){return this.compose(SB(yA(t),(r,n)=>({...gA(n,t),...r})))}notUndefined(){return this.refine(ei,{expected:"a value other than `undefined`"})}forEach(t){let r=t(CS());return nY(n=>Vr(this.getResult(n),o=>{let s=[];for(let i=0;i<o.length;i++){let a=r.getResult(o[i]);tt(a)&&s.push(a.success)}return s}),(n,o)=>hr(this.getResult(o),s=>{let i=[];for(let c=0;c<s.length;c++)tt(r.getResult(s[c]))&&i.push(c);if(n.length!==i.length)return re(new le({message:`each: replacement length mismatch: ${n.length} !== ${i.length}`}));let a=s.slice();for(let c=0;c<i.length;c++){let u=i[c],f=r.replaceResult(n[c],s[u]);if(be(f))return re(new Ct([u],f.failure));a[u]=f.success}return this.replaceResult(a,o)}))}modifyAll(t){return r=>ap(hr(this.getResult(r),n=>this.replaceResult(n.map(t),r)),()=>r)}},IA=class extends Xl{get;set;constructor(t,r,n){super(t,o=>X(r(o)),o=>X(n(o))),this.get=r,this.set=n}replace(t,r){return this.set(t)}modify(t){return r=>this.set(t(this.get(r)))}},TA=class extends Xl{get;constructor(t,r,n){super(t,o=>X(r(o)),(o,s)=>X(n(o,s))),this.get=r,this.replace=n}modify(t){return r=>this.replace(t(this.get(r)),r)}},wA=class extends Xl{set;constructor(t,r,n){super(t,r,(o,s)=>X(n(o))),this.set=n}replace(t,r){return this.set(t)}modify(t){return r=>ap(Vr(this.getResult(r),n=>this.set(t(n))),()=>r)}};function $s(e){let t=e[0]??rY;if(e.length>1){let r=e.reduce((n,o)=>iY(n,o.kind),"Iso");t={kind:r,get:oY(e,r),set:sY(e,r)}}switch(t.kind){case"Iso":return new IA(e,t.get,t.set);case"Lens":return new TA(e,t.get,t.set);case"Prism":return new wA(e,t.get,t.set);case"Optional":return new Xl(e,t.get,t.set)}}function AS(e){if(Array.isArray(e))return e.slice();if(typeof e=="object"&&e!==null){let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)throw new Error("Cannot clone object with non-Object constructor or null prototype");return{...e}}return e}function oY(e,t){return r=>{for(let n=0;n<e.length;n++){let o=e[n],s=o.get(r);if(vA(o.kind)){if(be(s))return s;r=s.success}else r=s}return vA(t)?X(r):r}}function sY(e,t){return bB(t)?r=>{for(let n=e.length-1;n>=0;n--)r=e[n].set(r);return r}:(r,n)=>{let o=e.length,s=new Array(o);for(let i=0;i<o;i++){s[i]=n;let a=e[i];if(vA(a.kind)){let c=a.get(n);if(be(c))return c;n=c.success}else n=a.get(n)}for(let i=o-1;i>=0;i--){let a=e[i];if(bB(a.kind))r=a.set(r);else if(a.kind==="Lens")r=a.set(r,s[i]);else{let c=a.set(r,s[i]);if(be(c))return c;r=c.success}}return t==="Optional"?X(r):r}}function vA(e){return e==="Prism"||e==="Optional"}function bB(e){return e==="Iso"||e==="Prism"}function iY(e,t){return e==="Iso"?t:t==="Iso"||e===t?e:"Optional"}var aY=$s([]);function CS(){return aY}function TB(e){let t=SS(e);return EB(hS(t),mS(t))}function wB(e){return CS()}function vB(e){return CS()}var ed="~effect/Schema/SchemaError";function AB(e){return O(e,ed)&&e[ed]===ed}var Mo="~effect/net/NetAddress";var js=e=>e.value,Hs=e=>e,xa=e=>e.bytes,es=class extends sr("NetAddressError"){},td=e=>O(e,Mo),Br=e=>td(e)&&e._tag==="Ipv4Address",ts=e=>td(e)&&e._tag==="Ipv6Address",AA=e=>Br(e)||ts(e),rd=e=>Br(e)?32:128;var nd=e=>td(e)&&e._tag==="MacAddress",Dm=e=>td(e)&&e._tag==="InetAddressV4",Lm=e=>td(e)&&e._tag==="InetAddressV6",CA=e=>Dm(e)||Lm(e),kS=e=>td(e)&&e._tag==="UnixPathAddress",CB=e=>CA(e)||kS(e),uY={...Ot,_tag:"Ipv4Address",[Mo]:Mo,[ae](e){return Br(e)&&js(this)===js(e)},[ie](){return _r(he(pY,js(this)|0))},toString(){return $r(this)},toJSON(){return this.toString()}},fY={...Ot,_tag:"Ipv6Address",[Mo]:Mo,[ae](e){if(!ts(e))return!1;let t=Hs(this),r=Hs(e);return t.w0===r.w0&&t.w1===r.w1&&t.w2===r.w2&&t.w3===r.w3},[ie](){let e=Hs(this),t=he(mY,e.w0|0);return t=he(t,e.w1|0),t=he(t,e.w2|0),_r(he(t,e.w3|0))},toString(){return $r(this)},toJSON(){return this.toString()}},lY={...Ot,_tag:"MacAddress",[Mo]:Mo,[ae](e){return nd(e)&&dY(xa(this),xa(e))},[ie](){return he(hY,ri(xa(this)))},toString(){return OA(this)},toJSON(){return this.toString()}},dY=(e,t)=>{if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0},pY=Be("Ipv4Address"),mY=Be("Ipv6Address"),hY=Be("MacAddress"),xY=e=>{let t=Object.create(uY);return t.value=e>>>0,Object.freeze(t)},gY=(e,t,r,n)=>{let o=Object.create(fY);return o.w0=e>>>0,o.w1=t>>>0,o.w2=r>>>0,o.w3=n>>>0,Object.freeze(o)},yY=(e,t,r,n)=>(e<<24|t<<16|r<<8|n)>>>0;var Um=e=>[e>>>24,e>>>16&255,e>>>8&255,e&255],SY=e=>{let t=Object.assign(Object.create(lY),{bytes:new Uint8Array(e)});return Object.freeze(t)};var Ut=(e,t)=>re(new es({input:e,message:t})),kB=(e,t)=>{for(let r=0;r<e.length;r++){let n=e[r];if(!Number.isInteger(n)||n<0||n>t)return!1}return!0},bY=e=>kB(e,255)?X(xY(yY(e[0],e[1],e[2],e[3]))):Ut(e,"octets must be integers from 0 through 255"),EY=e=>kB(e,65535)?X(gY(e[0]*65536+e[1],e[2]*65536+e[3],e[4]*65536+e[5],e[6]*65536+e[7])):Ut(e,"segments must be integers from 0 through 65535");var RB=e=>/^(?:[0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$/.test(e)?X(SY(new Uint8Array(e.split(":").map(t=>Number.parseInt(t,16))))):Ut(e,"expected six two-digit hexadecimal octets separated by colons");var Ku=e=>{let t=e.split(".");if(t.length!==4||t.some(n=>!/^\d{1,3}$/.test(n)))return Ut(e,"expected exactly four decimal octets");if(t.some(n=>n.length>1&&n[0]==="0"))return Ut(e,"leading zeroes are not allowed");let r=t.map(Number);return r.some(n=>n>255)?Ut(e,"octets must be at most 255"):bY([r[0],r[1],r[2],r[3]])},IY=e=>{if(e.includes("[")||e.includes("]")||e.includes("%"))return Ut(e,"brackets and zone identifiers are not valid in a bare IPv6 address");let t=e.split("::");if(t.length>2)return Ut(e,"only one compression marker is allowed");let r=t[0]===""?[]:t[0].split(":"),n=t.length===2&&t[1]!==""?t[1].split(":"):[];if(r.some(f=>f==="")||n.some(f=>f===""))return Ut(e,"empty segments are only valid in the compression marker");let o=n.length>0?n[n.length-1]:r.length>0?r[r.length-1]:"",s;if(o.includes(".")){if(t.length===2&&n.length===0)return Ut(e,"embedded IPv4 syntax must be trailing");let f=Vr(Ku(o),p=>{let m=js(p);return[m>>>16,m&65535]});if(be(f))return f;s=f.success,n.length>0?n.pop():r.pop()}let i=r.length+n.length+(s?2:0);if(t.length===1?i!==8:i>=8)return Ut(e,t.length===1?"expected eight segments":"compression must replace at least one segment");let a=f=>/^[0-9a-fA-F]{1,4}$/.test(f)?Number.parseInt(f,16):void 0,c=r.map(a),u=n.map(a);return c.some(f=>f===void 0)||u.some(f=>f===void 0)?Ut(e,"segments must contain one through four hexadecimal digits"):X([...c,...Array(8-i).fill(0),...u,...s??[]])},Vu=e=>hr(IY(e),t=>EY(t)),mc=e=>e.includes(":")?Vu(e):Ku(e);var kA=e=>{if(typeof e!="string"||!e.includes("%"))return!1;let t=Bm(e);return tt(t)&&t.success===e},Bm=e=>{let t=e.indexOf("%");if(t===-1)return Ut(e,"expected an IPv6 zone");let r=e.slice(t+1);if(r.length===0||/[%[\]/\s\p{Cc}]/u.test(r))return Ut(e,"invalid IPv6 scope identifier");if(/^\d+$/.test(r)){let n=Number(r);if(n>4294967295)return Ut(e,"scope identifier must be an unsigned 32-bit integer");r=String(n)}return Vr(Vu(e.slice(0,t)),n=>`${$r(n)}%${r}`)};var RS=e=>Um(js(e)),TY=e=>{let{w0:t,w1:r,w2:n,w3:o}=Hs(e);return[t>>>16,t&65535,r>>>16,r&65535,n>>>16,n&65535,o>>>16,o&65535]},RA=e=>{let{w0:t,w1:r,w2:n,w3:o}=Hs(e);return[...Um(t),...Um(r),...Um(n),...Um(o)]};var OA=e=>Array.from(xa(e),t=>t.toString(16).padStart(2,"0")).join(":"),OS=e=>xa(e).every(t=>t===255),wY=e=>(xa(e)[0]&1)!==0,_S=e=>(xa(e)[0]&1)===0,_A=e=>(xa(e)[0]&2)!==0,PA=e=>(xa(e)[0]&2)===0;var $r=e=>{if(Br(e))return RS(e).join(".");let t=TY(e);if(vY(e))return`::ffff:${t[6]>>8}.${t[6]&255}.${t[7]>>8}.${t[7]&255}`;let r=-1,n=0,o=-1;for(let a=0;a<=8;a++)a<8&&t[a]===0?o===-1&&(o=a):o!==-1&&(a-o>n&&(r=o,n=a-o),o=-1);if(n<2)return t.map(a=>a.toString(16)).join(":");let s=t.slice(0,r).map(a=>a.toString(16)).join(":"),i=t.slice(r+n).map(a=>a.toString(16)).join(":");return`${s}::${i}`},PS=e=>{if(Br(e))return js(e)===0;let{w0:t,w1:r,w2:n,w3:o}=Hs(e);return t===0&&r===0&&n===0&&o===0},MA=e=>{if(Br(e))return js(e)>>>24===127;let{w0:t,w1:r,w2:n,w3:o}=Hs(e);return t===0&&r===0&&n===0&&o===1},od=e=>nd(e)?wY(e):Br(e)?js(e)>>>28===14:Hs(e).w0>>>24===255,MS=e=>nd(e)?OS(e):js(e)===4294967295,FA=e=>nd(e)?_S(e):!od(e)&&!PS(e)&&(!Br(e)||!MS(e)),NA=e=>Br(e)?js(e)>>>16===43518:(Hs(e).w0>>>16&65472)===65152,UA=e=>{let t=js(e);return t>>>24===10||(t>>>16&65520)===44048||t>>>16===49320},DA=e=>(Hs(e).w0>>>24&254)===252,vY=e=>{let{w0:t,w1:r,w2:n}=Hs(e);return t===0&&r===0&&n===65535};var AY={...Ot,_tag:"InetAddressV4",[Mo]:Mo,[ae](e){return Dm(e)&&this.port===e.port&&Z(this.address,e.address)},[ie](){return he(G(this.address),zt(this.port))},toString(){return FS(this)},toJSON(){return this.toString()}},CY={...Ot,_tag:"InetAddressV6",[Mo]:Mo,[ae](e){return Lm(e)&&this.port===e.port&&this.scopeId===e.scopeId&&Z(this.address,e.address)},[ie](){return he(he(G(this.address),zt(this.port)),zt(this.scopeId))},toString(){return FS(this)},toJSON(){return this.toString()}},OB=e=>Number.isInteger(e)&&e>=0&&e<=65535,kY=(e,t)=>{if(!OB(t))return Ut(e,"port must be an integer from 0 through 65535");let r=Object.create(AY);return r.address=e,r.port=t,X(Object.freeze(r))},RY=(e,t,r)=>{if(!OB(t))return Ut(e,"port must be an integer from 0 through 65535");let n=r?.scopeId??0;if(!Number.isInteger(n)||n<0||n>4294967295)return Ut(e,"scopeId must be an unsigned 32-bit integer");let o=Object.create(CY);return o.address=e,o.port=t,o.scopeId=n,X(Object.freeze(o))};var LA=e=>{let t,r,n=0,o=e.startsWith("[");if(o){let s=e.indexOf("]");if(s<0||e[s+1]!==":"||e.indexOf("]",s+1)!==-1)return Ut(e,"expected [IPv6]:port");t=e.slice(1,s),r=e.slice(s+2);let i=t.indexOf("%");if(i!==-1){let a=t.slice(i+1);if(t.indexOf("%",i+1)!==-1||!/^\d+$/.test(a))return Ut(e,"scope identifier must be decimal");if(n=Number(a),!Number.isInteger(n)||n>4294967295)return Ut(e,"scope identifier must be an unsigned 32-bit integer");t=t.slice(0,i)}}else{let s=e.lastIndexOf(":");if(s<0)return Ut(e,"expected host:port or [IPv6]:port");if(e.indexOf(":")!==s)return Ut(e,"IPv6 addresses must be bracketed");t=e.slice(0,s),r=e.slice(s+1)}return/^(0|[1-9]\d*)$/.test(r)?hr(mc(t),s=>o!==ts(s)?Ut(e,"only IPv6 addresses use brackets"):ts(s)?RY(s,Number(r),{scopeId:n}):kY(s,Number(r))):Ut(e,"port must be an unpadded decimal integer")};var OY=e=>$r(e.address)+(Lm(e)&&e.scopeId!==0?`%${e.scopeId}`:"");var FS=e=>{let t=OY(e);return Dm(e)?`${t}:${e.port}`:`[${t}]:${e.port}`};var _Y={...Ot,_tag:"UnixPathAddress",[Mo]:Mo,[ae](e){return kS(e)&&this.path===e.path},[ie](){return he(Be("UnixPathAddress"),Be(this.path))},toString(){return this.path},toJSON(){return this.toString()}},_B=e=>{let t=Object.create(_Y);return t.path=e,Object.freeze(t)};var BA="~effect/net/Host",hc=(e,t)=>re(new es({input:e,message:t})),PY=/^[a-z0-9_.-]$/i,MY=/^[a-z0-9_](?:[a-z0-9_-]{0,61}[a-z0-9_])?$/,FY=/^(?:\d+|0x[0-9a-f]*)$/,PB=e=>{if(e===".")return;let t=e.endsWith(".")?e.slice(0,-1):e;if(t.length===0)return"domain name must not be empty";if(t.length>253)return"domain name must be at most 253 characters";let r=t.split(".");for(let n of r){if(n.length===0)return"domain name labels must not be empty";if(n.length>63)return"domain name labels must be at most 63 characters";if(!MY.test(n))return"domain name labels must contain only letters, digits, hyphens, or underscores and must not start or end with a hyphen"}if(FY.test(r[r.length-1]))return"the last domain name label must not be numeric"},NY=e=>{let t=!0;for(let r of e)if(r.charCodeAt(0)<128){if(!PY.test(r))return}else t=!1;if(t)return e.toLowerCase();try{return new URL(`http://${e}`).hostname}catch{return}},ga=e=>typeof e=="string"&&/^[a-z0-9_.-]+$/.test(e)&&PB(e)===void 0;var jA=e=>O(e,BA),NS=e=>{let t=NY(e);if(t===void 0)return hc(e,"invalid domain name");let r=PB(t);return r===void 0?X(t):hc(e,r)};var UY=e=>{if(e.includes("%"))return Bm(e);if(e.includes(":"))return mc(e);if(/^[\d.]+$/.test(e)){let t=mc(e);if(tt(t))return t}return NS(e)};var DY=e=>typeof e=="string"?e:$r(e);var LY={...Ot,_tag:"HostPort",[BA]:BA,[ae](e){return jA(e)&&this.port===e.port&&Z(this.host,e.host)},[ie](){return he(G(this.host),zt(this.port))},toString(){return HA(this)},toJSON(){return this.toString()}},BY=e=>Number.isInteger(e)&&e>=0&&e<=65535,$Y=(e,t)=>{let r=Object.create(LY);return r.host=e,r.port=t,Object.freeze(r)};var MB=e=>{let t,r;if(e.startsWith("[")){let o=e.indexOf("]");if(o===-1||e[o+1]!==":")return hc(e,"expected [IPv6]:port");if(t=e.slice(1,o),r=e.slice(o+2),!t.includes(":"))return hc(e,"only IPv6 addresses use brackets")}else{let o=e.lastIndexOf(":");if(o===-1)return hc(e,"expected host:port");if(e.indexOf(":")!==o)return hc(e,"IPv6 addresses must be bracketed");t=e.slice(0,o),r=e.slice(o+1)}if(!/^(0|[1-9]\d*)$/.test(r))return hc(e,"port must be an unpadded decimal integer");let n=Number(r);return BY(n)?Vr(UY(t),o=>$Y(o,n)):hc(e,"port must be an integer from 0 through 65535")};var HA=e=>{let t=DY(e.host);return t.includes(":")?`[${t}]:${e.port}`:`${t}:${e.port}`};var zA="~effect/net/Dns/DnsRecord",qA=e=>Number.isInteger(e)&&e>=0&&e<=255,sd=e=>Number.isInteger(e)&&e>=0&&e<=65535,UB=e=>Number.isInteger(e)&&e>=0&&e<=4294967295,xc=e=>typeof e=="string",US=e=>Qi(e)&&Wn(e)&&UB(ui(e)),DB={A:{address:Br},AAAA:{address:ts},CAA:{critical:e=>typeof e=="boolean",tag:e=>xc(e)&&/^[a-z0-9]+$/i.test(e),value:xc},CNAME:{target:ga},MX:{exchange:ga,priority:sd},NAPTR:{order:sd,preference:sd,flags:xc,service:xc,regexp:xc,replacement:ga},NS:{host:ga},PTR:{host:e=>xc(e)&&e.length>0},SOA:{primary:ga,admin:e=>xc(e)&&e.length>0,serial:UB,refresh:US,retry:US,expire:US,minimum:US},SRV:{target:ga,port:sd,priority:sd,weight:sd},TLSA:{certUsage:qA,selector:qA,matchingType:qA,data:e=>e instanceof Uint8Array&&e.length>0},TXT:{chunks:e=>Array.isArray(e)&&e.length>0&&e.every(xc)}},WA=Object.keys(DB),jY=e=>WA.includes(e),KA=e=>O(e,zA),HY={...Ot,[zA]:zA,[ae](e){return KA(e)&&e._tag===this._tag&&Object.keys(this).every(t=>Z(this[t],e[t]))},[ie](){return Hd(this,Object.keys(this))},toString(){return zY(this)},toJSON(){return{...this}}},LB=(e,t)=>{if(!jY(e))return re(new es({input:e,message:"unknown DNS record type"}));let r=typeof t=="object"&&t!==null?t:{},n=Object.create(HY);n._tag=e;for(let[o,s]of Object.entries(DB[e])){let i=r[o];if(!s(i))return re(new es({input:t,message:`invalid ${e} record ${o}`}));n[o]=Array.isArray(i)?Object.freeze([...i]):i instanceof Uint8Array?new Uint8Array(i):i}return X(Object.freeze(n))};var BB=new TextEncoder,$B=e=>`\\${e.toString().padStart(3,"0")}`,jm=e=>{let t='"';for(let r of BB.encode(e))t+=r===34||r===92?`\\${String.fromCharCode(r)}`:r<32||r>126?$B(r):String.fromCharCode(r);return t+'"'},qY=[34,36,40,41,59,64],NB=e=>{let t=BB.encode(e),r="";for(let n=0;n<t.length;n++){let o=t[n];if(o===92){let s=t[n+1];s===46||s===92?(r+=`\\${String.fromCharCode(s)}`,n++):r+="\\\\"}else o<=32||o>126?r+=$B(o):r+=qY.includes(o)?`\\${String.fromCharCode(o)}`:String.fromCharCode(o)}return r},zY=e=>{switch(e._tag){case"A":case"AAAA":return`${e._tag} ${$r(e.address)}`;case"CAA":return`CAA ${e.critical?128:0} ${e.tag} ${jm(e.value)}`;case"CNAME":return`CNAME ${e.target}`;case"MX":return`MX ${e.priority} ${e.exchange}`;case"NAPTR":return`NAPTR ${e.order} ${e.preference} ${jm(e.flags)} ${jm(e.service)} ${jm(e.regexp)} ${e.replacement}`;case"NS":return`NS ${e.host}`;case"PTR":return`PTR ${NB(e.host)}`;case"SOA":return`SOA ${e.primary} ${NB(e.admin)} ${e.serial} ${ui(e.refresh)} ${ui(e.retry)} ${ui(e.expire)} ${ui(e.minimum)}`;case"SRV":return`SRV ${e.priority} ${e.weight} ${e.port} ${e.target}`;case"TLSA":return`TLSA ${e.certUsage} ${e.selector} ${e.matchingType} ${Gx(e.data).toUpperCase()}`;case"TXT":return`TXT ${e.chunks.map(jm).join(" ")}`}};var VA="~effect/net/IpInterface",jB=e=>Hm(e)&&Br(e.address),HB=e=>Hm(e)&&ts(e.address),Hm=e=>O(e,VA),GY={...Ot,_tag:"IpInterface",[VA]:VA,[ae](e){return Hm(e)&&this.prefixLength===e.prefixLength&&Z(this.address,e.address)},[ie](){return he(G(this.address),zt(this.prefixLength))},toString(){return zm(this)},toJSON(){return this.toString()}},GA=(e,t)=>re(new es({input:e,message:t})),qm=(e,t)=>{let r=rd(e);if(!Number.isInteger(t)||t<0||t>r)return GA(e,`prefix length must be an integer from 0 through ${r}`);let n=Object.assign(Object.create(GY),{address:e,prefixLength:t});return X(Object.freeze(n))},JA=(e,t)=>{let r=e.indexOf("/");if(r===-1&&t?.prefix!=="required")return X({address:e,prefixLength:void 0});if(r<=0||r!==e.lastIndexOf("/")||r===e.length-1)return GA(e,"expected an address and prefix length separated by one slash");let n=e.slice(r+1);return/^(0|[1-9][0-9]*)$/.test(n)?X({address:e.slice(0,r),prefixLength:Number(n)}):GA(e,"prefix length must be an unpadded ASCII decimal integer")},DS=(e,t)=>hr(JA(e,t),r=>hr(Ku(r.address),n=>qm(n,r.prefixLength??rd(n)))),LS=(e,t)=>hr(JA(e,t),r=>hr(Vu(r.address),n=>qm(n,r.prefixLength??rd(n)))),BS=(e,t)=>hr(JA(e,t),r=>hr(mc(r.address),n=>qm(n,r.prefixLength??rd(n))));var zm=e=>`${$r(e.address)}/${e.prefixLength}`;var ZA="~effect/net/IpNetwork",zB=e=>Wm(e)&&Br(e.address),WB=e=>Wm(e)&&ts(e.address),Wm=e=>O(e,ZA),JY={...Ot,_tag:"IpNetwork",[ZA]:ZA,[ae](e){return Wm(e)&&this.prefixLength===e.prefixLength&&Z(this.address,e.address)},[ie](){return he(G(this.address),zt(this.prefixLength))},toString(){return Km(this)},toJSON(){return this.toString()}},ZY=e=>{let t=Object.assign(Object.create(JY),{address:e.address,prefixLength:e.prefixLength});return Object.freeze(t)},QY=e=>Br(e)?RS(e):RA(e);var YY=(e,t)=>{let r=Math.floor(t/8),n=t%8;return e.map((o,s)=>s<r?o:s===r&&n!==0?o&(255<<8-n&255):0)},QA=(e,t)=>hr(qm(e,t),r=>{let n=QY(e),o=YY(n,t);return n.some((s,i)=>s!==o[i])?re(new es({input:e,message:"address has non-zero host bits"})):X(ZY(r))});var KB=e=>hr(DS(e,{prefix:"required"}),t=>QA(t.address,t.prefixLength)),VB=e=>hr(LS(e,{prefix:"required"}),t=>QA(t.address,t.prefixLength)),GB=e=>hr(BS(e,{prefix:"required"}),t=>QA(t.address,t.prefixLength));var Km=e=>`${$r(e.address)}/${e.prefixLength}`;var Vm=gS;function Ar(){return(e,t,r)=>J(new fc(e.map(wm),n=>t(n.map(o=>J(o))),r))}function Ge(e,t){return Ar()([],()=>(r,n,o)=>e(r)?I(r):D(new at(n,r,o)),t)}function e7(e){return e}function t7(e){return t=>t.annotate(e)}function r7(e){return t=>XA(XA(t).annotate(e))}function n7(e){return t=>t.rebuild(Wl(t.ast,e))}function o7(e){return e}var $n=class extends sr("SchemaError"){[ed]=ed;constructor(t){let r=Ir();yt(0);try{super({issue:t})}finally{yt(r)}}get message(){return E1(this.issue)}toJSON(){return{_tag:this._tag,message:this.message}}[Qe](){return this.toJSON()}toString(){return`SchemaError(${this.message})`}};function fd(e){return AB(e)}function c$(e){return Xe(e)?nC(e):rt(e,t=>aa(()=>Va(t,r=>new $n(r))))}function nC(e){return ft(e)?e:ir(Va(e.cause,t=>new $n(t)))}function u$(e,t){let r;for(let n of e.reasons){if(!Ng(n)||!fd(n.error))throw new globalThis.Error(t,{cause:e});r??=n.error}if(r===void 0)throw new globalThis.Error(t,{cause:e});return r}function f$(e){return dy(e).then(t=>{if(ft(t))return t.value;throw u$(t.cause,"Promise adapter can only reject schema errors")})}function l$(e){let t=ki(e);if(ft(t))return t.value;throw u$(t.cause,"Sync adapter can only throw schema errors")}function s7(e,t){return nB(e,t)}function i7(e){return oB(e)}var a7=Yv,c7=xL;function gc(e,t){let r=ot(e,t);return(n,o)=>c$(r(n,o))}var u7=gc;function d$(e,t){let r=gL(e,t);return(n,o)=>nC(r(n,o))}var p$=d$,f7=eA,l7=yL;function m$(e,t){let r=SL(e,t);return(n,o)=>LI(r(n,o),s=>new $n(s))}var d7=m$;function h$(e,t){let r=gc(e,t);return(n,o)=>f$(r(n,o))}var p7=h$;function jS(e,t){let r=gc(e,t);return(n,o)=>l$(r(n,o))}var Zm=jS;function Qm(e,t){let r=Hu(e,t);return(n,o)=>c$(r(n,o))}var oC=Qm;function x$(e,t){let r=EL(e,t);return(n,o)=>nC(r(n,o))}var g$=x$,m7=tA,h7=IL;function y$(e,t){let r=TL(e,t);return(n,o)=>LI(r(n,o),s=>new $n(s))}var x7=y$;function S$(e,t){let r=Qm(e,t);return(n,o)=>f$(r(n,o))}var g7=S$;function Ym(e,t){let r=Qm(e,t);return(n,o)=>l$(r(n,o))}var sC=Ym,J=Ls;function Zu(e){return O(e,Vm)&&e[Vm]===Vm}var Ju=bn(e=>J(ju(e.ast),{schema:e})),y7=bn(e=>e.schema),lr=bn(e=>{let t=zS(e);return J(G2(e.ast),{schema:t})}),S7=bn(e=>e.schema.members[0]),b7=bn(e=>J(Bv(e.ast),{schema:e})),E7=bn(e=>e.schema),oo=bn(e=>J(Nt(e.ast),{schema:e})),ld=bn(e=>J(Bn(e.ast),{schema:e})),Gm="~effect/Schema/flip";function I7(e){return O(e,Gm)&&e[Gm]===Gm}function XA(e){return I7(e)?e.schema.rebuild(Oo(e.ast)):J(Oo(e.ast),{[Gm]:Gm,schema:e})}function fr(e){let t=J(new Ln(e),{literal:e,transform(r){return t.pipe(ee(fr(r),{decode:Ie(()=>r),encode:Ie(()=>e)}))}});return t}function b$(e){return e.map(t=>Zu(t)?t.ast:new Ln(t))}function T7(e){return J(new kv(b$(e)),{parts:e})}function w7(e){return J(C2(b$(e)),{parts:e})}function v7(e){return J(new A2(Object.keys(e).filter(t=>typeof e[e[t]]!="number").map(t=>[t,e[t]])),{enums:e})}var Mi=J(Cv),A7=J(w2),Xm=J(pa),HS=J(vv),iC=J(Av),z=J(Ro),C7=z,Qu=J(Rv),Fi=J(O2),E$=J(_2),dd=J(P2),pd=J(T2),k7=J(v2);function R7(e){return J(new R2(e))}function aC(e,t){return J(e,{fields:t,mapFields(r,n){let o=r(this.fields);return aC(eS(o,n?.unsafePreserveChecks?this.ast.checks:void 0),o)}})}function Te(e){return aC(eS(e,void 0),e)}function O7(e){return bn(t=>t.mapFields(gB(e)))}var _7=e=>typeof e=="symbol"?e:globalThis.String(e);function P7(e){return function(t){let r={},n=Object.create(null),o=Object.create(null),s=new Set;for(let i of Reflect.ownKeys(t.fields)){let a=ld(t.fields[i]),c=Object.hasOwn(e,i),u=c?e[i]:i,f=_7(u);if(s.has(f))throw new globalThis.Error(`Duplicate encoded keys: ${ni(u)}`);s.add(f),B(r,u,a),c&&(n[i]=u,o[u]=i)}return Te(r).pipe(ee(t,Fe({decode:SA(o),encode:SA(n)})))}}function M7(e,t){return r=>{let n=Dx(r.fields,oo),o=Te({...n,...e});return r.pipe(ee(o,Fe({decode:s=>{let i={...s};for(let a in e){let c=t[a],u=c(s);de(u)&&B(i,a,u.value)}return i},encode:s=>{let i={...s};for(let a in e)delete i[a];return i}})))}}function Yu(e,t){return J(Z2(e.ast,t.ast),{key:e,value:t})}function F7(e,t){return J(D2(e.ast,t.map(wm)),{schema:e,records:t})}function I$(e,t){return J(e,{elements:t,mapElements(r,n){let o=r(this.elements);return I$(Mv(o,n?.unsafePreserveChecks?this.ast.checks:void 0),o)}})}function rs(e){return I$(Mv(e),e)}function N7(e,t){return J(L2(e.ast,t.map(wm)),{schema:e,rest:t})}var ct=bn(e=>J(new Xo(!1,[],[e.ast]),{value:e}));function qS(e,t,r){return t!==void 0&&r!==void 0?e.check(dC(t,r)):t!==void 0?e.check(j$(t)):r!==void 0?e.check(z$(r)):e}var Xu=bn(e=>J(new Xo(!1,[e.ast],[e.ast]),{value:e}));function U7(e){let t=ct(e),r=ct(oo(e)),n=ee(rs([Xm]),Fe({decode:o=>[o],encode:([o])=>o}))(e);return J(Pe([n,t]).pipe(ee(r)).ast,{from:Pe([e,t]),to:r})}function D7(e){return ct(e).check(mC())}var L7=bn(e=>J(B2(e.ast),{schema:e}));function T$(e,t){return J(e,{members:t,mapMembers(r,n){let o=r(this.members);return T$(tS(o,this.ast.options,n?.unsafePreserveChecks?this.ast.checks:void 0),o)}})}function Pe(e,t){return T$(tS(e,t,void 0),e)}function Fo(e){let t=e.map(fr);return J(tS(t,void 0,void 0),{literals:e,members:t,mapMembers(r){return Pe(r(this.members))},pick(r){return Fo(r)},transform(r){return Pe(t.map((n,o)=>n.transform(r[o])))}})}var cC=bn(e=>Pe([e,HS])),zS=bn(e=>Pe([e,iC])),w$=bn(e=>Pe([e,HS,iC]));function v$(e){return J(new Nv(()=>e().ast))}function B7(...e){return t=>t.check(...e)}function A$(e,t){return r=>J(Pi(r.ast,[nS(e,t)]),{schema:r})}function WS(e){return t=>J(t.ast,{schema:t,identifier:e})}function $7(e,t){return r=>(t.checks?r.check(...t.checks):r).pipe(WS(e))}function C$(e){return t=>J(K2(t.ast,new Ky(e,F)),{schema:t})}function k$(e){return t=>J(V2(t.ast,new Ky(F,e)),{schema:t})}function j7(e){return R$(e)}function R$(e){return t=>C$(my(e))(t)}function H7(e){return O$(e)}function O$(e){return t=>k$(my(e))(t)}function ee(e,t){return r=>J(Kl(r.ast,e.ast,t?Vy(t):Nl()),{from:r,to:e})}function md(){return(e,t)=>Ne()(e,{decode:t,encode:v1})}var _$=Fo(["true","yes","on","1","y"]),P$=Fo(["false","no","off","0","n"]),q7=Fo([..._$.literals,...P$.literals]).pipe(ee(Fi,Fe({decode:e=>e==="true"||e==="yes"||e==="on"||e==="1"||e==="y",encode:e=>e?"true":"false"})));function z7(e){return t=>ee(oo(t),e)(t)}function uC(e,t){return r=>t?ee(r,t)(e):ee(r)(e)}function W7(e){return t=>ee(t,e)(ld(t))}function M$(e){return t=>J(J2(t.ast,e),{schema:t})}function F$(e){return rt(e,t=>aa(()=>Va(t,r=>r.issue)))}function fC(e,t){let r=t?.encodingStrategy==="omit"?av():Oi();return n=>Ju(ld(n)).pipe(ee(n,{decode:cv(F$(e)),encode:r}))}function K7(e,t){return r=>oo(r).pipe(fC(e,t),uC(Ju(r)))}function N$(e,t){let r=t?.encodingStrategy==="omit"?av():Oi();return n=>lr(ld(n)).pipe(ee(n,{decode:cv(F$(e)),encode:r}))}function V7(e,t){return r=>oo(r).pipe(N$(e,t),uC(lr(r)))}function He(e){return fr(e).pipe(M$(I(e)))}function G7(e){return He(e).pipe(fC(I(e),{encodingStrategy:"omit"}))}function ya(e,t){return Te({_tag:He(e),...t})}function U$(e){return t=>{let r={},n=[],o=new Set,s={},i=f=>p=>f.includes(p[e]);return a(t),Object.assign(t,{tag:e,cases:r,discriminants:n,isAnyOf:i,guards:s,match:c,matchOrElse:u});function a(f){let p=f.ast;if(b2(p)&&"members"in f&&globalThis.Array.isArray(f.members)&&f.members.every(Zu))return f.members.forEach(a);let m=cc(p);if(m.length>0){let h=m.find(x=>x.key===e)?.literal;if(mx(h)){let x=typeof h=="number"?globalThis.String(h):h;if(o.has(x))throw new globalThis.Error(`Duplicate discriminant: ${globalThis.String(h)}`);o.add(x),n.push(h),B(r,h,f),B(s,h,Yv(oo(f)));return}}throw new globalThis.Error("No literal or unique symbol found")}function c(){if(arguments.length===1){let x=arguments[0];return function(g){let y=g[e];return(Object.hasOwn(x,y)?x[y]:void 0)(g)}}let f=arguments[0],p=arguments[1],m=f[e];return(Object.hasOwn(p,m)?p[m]:void 0)(f)}function u(){if(arguments.length===2){let g=arguments[0],y=arguments[1];return function(E){let b=E[e];return(Object.hasOwn(g,b)?g[b]??y:y)(E)}}let f=arguments[0],p=arguments[1],m=arguments[2],h=f[e];return(Object.hasOwn(p,h)?p[h]??m:m)(f)}}}function J7(e){let t={},r=[];for(let u of Object.keys(e)){let f=ya(u,e[u]);B(t,u,f),r.push(f)}let n=Pe(r),{tag:o,guards:s,isAnyOf:i,match:a,matchOrElse:c}=U$("_tag")(n);return J(n.ast,{tag:o,cases:t,isAnyOf:i,guards:s,match:a,matchOrElse:c})}function Z7(){return e=>e}function yc(e,t){return Ge(r=>r instanceof e,t)}function Ne(){return(e,t)=>new jt(e.ast,Vy(t))}var Je=rS;function Q7(e,t=void 0){return new Lu(e,t)}var JB="^\\S[\\s\\S]*\\S$|^\\S$|^$";function D$(e){let t=new globalThis.RegExp(JB);return Je(r=>r.trim()===r,{expected:"a string with no leading or trailing whitespace",representation:{id:"effect/schema/isTrimmed",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isTrimmed()"}),arbitraryConstraint:{patterns:[{source:JB,flags:""}]},...e})}function ef(e,t){let r=e.source,n=e.flags,o=/^[dg]*uy?$/.test(n),s=n===""?`new RegExp(${H(r)})`:`new RegExp(${H(r)}, ${H(n)})`;return Am(e,{toJsonSchema:()=>o?{pattern:n.endsWith("y")?`^(?:${r})`:r}:[{},!0],toCode:()=>({runtime:`Schema.isPattern(${s})`}),...t})}function Y7(e){return Hv({toCode:()=>({runtime:"Schema.isStringFinite()"}),...e})}function X7(e){return qv({toCode:()=>({runtime:"Schema.isStringBigInt()"}),...e})}function eX(e){return Wv({toCode:()=>({runtime:"Schema.isStringSymbol()"}),...e})}var tX=e=>e?new globalThis.RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|[fF]{8}-[fF]{4}-[fF]{4}-[fF]{4}-[fF]{12})$/;function rX(e,t){let r=tX(e);return ef(r,{expected:e?`a UUID v${e}`:"a UUID",representation:{id:"effect/schema/isUUID",payload:{version:e??null}},toJsonSchema:()=>({pattern:r.source,format:"uuid"}),toCode:()=>({runtime:e===void 0?"Schema.isUUID()":`Schema.isUUID(${e})`}),...t})}var ZB=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;function nX(e){return ef(ZB,{expected:"a GUID",representation:{id:"effect/schema/isGUID",payload:null},toJsonSchema:()=>({pattern:ZB.source}),toCode:()=>({runtime:"Schema.isGUID()"}),...e})}function oX(e){let t=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;return ef(t,{representation:{id:"effect/schema/isULID",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isULID()"}),...e})}function L$(e){let t=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;return ef(t,{expected:"a base64 encoded string",representation:{id:"effect/schema/isBase64",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isBase64()"}),...e})}function sX(e){let t=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;return ef(t,{expected:"a base64url encoded string",representation:{id:"effect/schema/isBase64Url",payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:"Schema.isBase64Url()"}),...e})}function lC(e,t,r){if(e.length===0)return t.length===0?{}:[{},!0];let n={pattern:new globalThis.RegExp(r).source};return e===t?n:[n,!0]}function iX(e,t){let r=JSON.stringify(e),n=new globalThis.RegExp(`^${ha(e)}`),o=e.replace(/[\uD800-\uDBFF]$/,"");return Je(s=>s.startsWith(e),{expected:`a string starting with ${r}`,representation:{id:"effect/schema/isStartingWith",payload:{startsWith:e}},toJsonSchema:()=>lC(o,e,`^${ha(o)}`),toCode:()=>({runtime:`Schema.isStartingWith(${H(e)})`}),arbitraryConstraint:{patterns:[{source:n.source,flags:n.flags}]},...t})}function aX(e,t){let r=JSON.stringify(e),n=new globalThis.RegExp(`${ha(e)}$`),o=e.replace(/^[\uDC00-\uDFFF]/,"");return Je(s=>s.endsWith(e),{expected:`a string ending with ${r}`,representation:{id:"effect/schema/isEndingWith",payload:{endsWith:e}},toJsonSchema:()=>lC(o,e,`${ha(o)}$`),toCode:()=>({runtime:`Schema.isEndingWith(${H(e)})`}),arbitraryConstraint:{patterns:[{source:n.source,flags:n.flags}]},...t})}function cX(e,t){let r=JSON.stringify(e),n=new globalThis.RegExp(ha(e)),o=e.replace(/^[\uDC00-\uDFFF]|[\uD800-\uDBFF]$/g,"");return Je(s=>s.includes(e),{expected:`a string including ${r}`,representation:{id:"effect/schema/isIncluding",payload:{includes:e}},toJsonSchema:()=>lC(o,e,ha(o)),toCode:()=>({runtime:`Schema.isIncluding(${H(e)})`}),arbitraryConstraint:{patterns:[{source:n.source,flags:n.flags}]},...t})}var QB="^[^a-z]*$";function uX(e){let t=new globalThis.RegExp(QB);return Je(r=>r.toUpperCase()===r,{expected:"a string with all characters in uppercase",representation:{id:"effect/schema/isUppercased",payload:null},toJsonSchema:()=>[{pattern:t.source},!0],toCode:()=>({runtime:"Schema.isUppercased()"}),arbitraryConstraint:{patterns:[{source:QB,flags:""}]},...e})}var YB="^[^A-Z]*$";function fX(e){let t=new globalThis.RegExp(YB);return Je(r=>r.toLowerCase()===r,{expected:"a string with all characters in lowercase",representation:{id:"effect/schema/isLowercased",payload:null},toJsonSchema:()=>[{pattern:t.source},!0],toCode:()=>({runtime:"Schema.isLowercased()"}),arbitraryConstraint:{patterns:[{source:YB,flags:""}]},...e})}var XB="^(?:[^a-z][\\s\\S]*)?$";function lX(e){let t=new globalThis.RegExp(XB);return Je(r=>r.charAt(0).toUpperCase()===r.charAt(0),{expected:"a string with the first character in uppercase",representation:{id:"effect/schema/isCapitalized",payload:null},toJsonSchema:()=>[{pattern:t.source},!0],toCode:()=>({runtime:"Schema.isCapitalized()"}),arbitraryConstraint:{patterns:[{source:XB,flags:""}]},...e})}var e$="^(?:[^A-Z][\\s\\S]*)?$";function dX(e){let t=new globalThis.RegExp(e$);return Je(r=>r.charAt(0).toLowerCase()===r.charAt(0),{expected:"a string with the first character in lowercase",representation:{id:"effect/schema/isUncapitalized",payload:null},toJsonSchema:()=>[{pattern:t.source},!0],toCode:()=>({runtime:"Schema.isUncapitalized()"}),arbitraryConstraint:{patterns:[{source:e$,flags:""}]},...e})}var KS=J(Dv),pX=Uv;function eh(e){let t=Xc(e.order),r=e.formatter??H;return(n,o)=>Je(s=>t(s,n),{expected:`a value greater than ${r(n)}`,arbitraryConstraint:{order:e.order,minimum:n,exclusiveMinimum:!0},...e.annotate?.(n),...o})}function th(e){let t=op(e.order),r=e.formatter??H;return(n,o)=>Je(s=>t(s,n),{expected:`a value greater than or equal to ${r(n)}`,arbitraryConstraint:{order:e.order,minimum:n},...e.annotate?.(n),...o})}function rh(e){let t=rp(e.order),r=e.formatter??H;return(n,o)=>Je(s=>t(s,n),{expected:`a value less than ${r(n)}`,arbitraryConstraint:{order:e.order,maximum:n,exclusiveMaximum:!0},...e.annotate?.(n),...o})}function nh(e){let t=np(e.order),r=e.formatter??H;return(n,o)=>Je(s=>t(s,n),{expected:`a value less than or equal to ${r(n)}`,arbitraryConstraint:{order:e.order,maximum:n},...e.annotate?.(n),...o})}function oh(e){let t=op(e.order),r=Xc(e.order),n=np(e.order),o=rp(e.order),s=e.formatter??H;return(i,a)=>{let c=i.exclusiveMinimum?r:t,u=i.exclusiveMaximum?o:n;return Je(f=>c(f,i.minimum)&&u(f,i.maximum),{expected:`a value between ${s(i.minimum)}${i.exclusiveMinimum?" (excluded)":""} and ${s(i.maximum)}${i.exclusiveMaximum?" (excluded)":""}`,arbitraryConstraint:{order:e.order,minimum:i.minimum,maximum:i.maximum,...i.exclusiveMinimum&&{exclusiveMinimum:!0},...i.exclusiveMaximum&&{exclusiveMaximum:!0}},...e.annotate?.(i),...a})}}function mX(e){return(t,r)=>{let n=e.formatter??H;return Je(o=>e.remainder(o,t)===e.zero,{expected:`a value that is a multiple of ${n(t)}`,...e.annotate?.(t),...r})}}function ad(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${H(e)}`);return e}var hX=eh({order:Ki,annotate:e=>({representation:{id:"effect/schema/isGreaterThan",payload:{exclusiveMinimum:ad(e)}},toJsonSchema:()=>({exclusiveMinimum:e}),toCode:()=>({runtime:`Schema.isGreaterThan(${H(e)})`})})}),B$=th({order:Ki,annotate:e=>({representation:{id:"effect/schema/isGreaterThanOrEqualTo",payload:{minimum:ad(e)}},toJsonSchema:()=>({minimum:e}),toCode:()=>({runtime:`Schema.isGreaterThanOrEqualTo(${H(e)})`})})}),xX=rh({order:Ki,annotate:e=>({representation:{id:"effect/schema/isLessThan",payload:{exclusiveMaximum:ad(e)}},toJsonSchema:()=>({exclusiveMaximum:e}),toCode:()=>({runtime:`Schema.isLessThan(${H(e)})`})})}),gX=nh({order:Ki,annotate:e=>({representation:{id:"effect/schema/isLessThanOrEqualTo",payload:{maximum:ad(e)}},toJsonSchema:()=>({maximum:e}),toCode:()=>({runtime:`Schema.isLessThanOrEqualTo(${H(e)})`})})}),Sc=oh({order:Ki,annotate:e=>{let t=e.exclusiveMinimum?!0:void 0,r=e.exclusiveMaximum?!0:void 0;return{representation:{id:"effect/schema/isBetween",payload:{minimum:ad(e.minimum),maximum:ad(e.maximum),...t&&{exclusiveMinimum:t},...r&&{exclusiveMaximum:r}}},toJsonSchema:()=>({[t?"exclusiveMinimum":"minimum"]:e.minimum,[r?"exclusiveMaximum":"maximum"]:e.maximum}),toCode:()=>({runtime:`Schema.isBetween({ minimum: ${H(e.minimum)}, maximum: ${H(e.maximum)}, exclusiveMinimum: ${H(t)}, exclusiveMaximum: ${H(r)} })`})}}});function yX(e,t){if(!globalThis.Number.isFinite(e)||e===0)throw new globalThis.RangeError(`Expected a finite non-zero number, got ${globalThis.String(e)}`);return e=globalThis.Math.abs(e),Je(r=>aU(r,e)===0,{expected:`a value that is a multiple of ${e}`,representation:{id:"effect/schema/isMultipleOf",payload:{divisor:e}},toJsonSchema:()=>({multipleOf:e}),toCode:()=>({runtime:`Schema.isMultipleOf(${H(e)})`}),...t})}function VS(e){return Je(t=>globalThis.Number.isSafeInteger(t),{expected:"an integer",representation:{id:"effect/schema/isInt",payload:null},toJsonSchema:()=>({type:"integer",minimum:globalThis.Number.MIN_SAFE_INTEGER,maximum:globalThis.Number.MAX_SAFE_INTEGER}),toCode:()=>({runtime:"Schema.isInt()"}),arbitraryConstraint:{number:"integer"},...e})}var In=Qu.check(VS()),Gu=In.check(B$(0));function SX(e){return new Lu([VS(),Sc({minimum:-2147483648,maximum:2147483647})],{expected:"a 32-bit integer",...e})}function bX(e){return new Lu([VS(),Sc({minimum:0,maximum:4294967295})],{expected:"a 32-bit unsigned integer",...e})}function cd(e){if(globalThis.Number.isNaN(e.getTime()))throw new globalThis.RangeError(`Expected a valid Date, got ${H(e)}`);return e.toISOString()}function ud(e){return`new Date(${H(e.getTime())})`}var EX=eh({order:Df,annotate:e=>({representation:{id:"effect/schema/isGreaterThanDate",payload:{exclusiveMinimum:cd(e)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isGreaterThanDate(${ud(e)})`})})}),IX=th({order:Df,annotate:e=>({representation:{id:"effect/schema/isGreaterThanOrEqualToDate",payload:{minimum:cd(e)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isGreaterThanOrEqualToDate(${ud(e)})`})})}),TX=rh({order:Df,annotate:e=>({representation:{id:"effect/schema/isLessThanDate",payload:{exclusiveMaximum:cd(e)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isLessThanDate(${ud(e)})`})})}),wX=nh({order:Df,annotate:e=>({representation:{id:"effect/schema/isLessThanOrEqualToDate",payload:{maximum:cd(e)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isLessThanOrEqualToDate(${ud(e)})`})})}),vX=oh({order:Df,annotate:e=>{let t=e.exclusiveMinimum?!0:void 0,r=e.exclusiveMaximum?!0:void 0;return{representation:{id:"effect/schema/isBetweenDate",payload:{minimum:cd(e.minimum),maximum:cd(e.maximum),...t&&{exclusiveMinimum:t},...r&&{exclusiveMaximum:r}}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isBetweenDate({ minimum: ${ud(e.minimum)}, maximum: ${ud(e.maximum)}, exclusiveMinimum: ${H(t)}, exclusiveMaximum: ${H(r)} })`})}}}),AX=eh({order:Uf,annotate:e=>({representation:{id:"effect/schema/isGreaterThanBigInt",payload:{exclusiveMinimum:e.toString(10)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isGreaterThanBigInt(${H(e)})`})})}),$$=th({order:Uf,annotate:e=>({representation:{id:"effect/schema/isGreaterThanOrEqualToBigInt",payload:{minimum:e.toString(10)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isGreaterThanOrEqualToBigInt(${H(e)})`})})}),CX=rh({order:Uf,annotate:e=>({representation:{id:"effect/schema/isLessThanBigInt",payload:{exclusiveMaximum:e.toString(10)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isLessThanBigInt(${H(e)})`})})}),kX=nh({order:Uf,annotate:e=>({representation:{id:"effect/schema/isLessThanOrEqualToBigInt",payload:{maximum:e.toString(10)}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isLessThanOrEqualToBigInt(${H(e)})`})})}),RX=oh({order:Uf,annotate:e=>{let t=e.exclusiveMinimum?!0:void 0,r=e.exclusiveMaximum?!0:void 0;return{representation:{id:"effect/schema/isBetweenBigInt",payload:{minimum:e.minimum.toString(10),maximum:e.maximum.toString(10),...t&&{exclusiveMinimum:t},...r&&{exclusiveMaximum:r}}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isBetweenBigInt({ minimum: ${H(e.minimum)}, maximum: ${H(e.maximum)}, exclusiveMinimum: ${H(t)}, exclusiveMaximum: ${H(r)} })`})}}});function j$(e,t){return e=En(e),H$(e,Math.ceil(e/2),t)}function H$(e,t,r){return Je(n=>n.length>=e,{expected:`a value with a length of at least ${e}`,representation:{id:"effect/schema/isMinLength",payload:{minLength:e}},toJsonSchema:({type:n})=>n==="string"?e<=1?{minLength:t}:[{minLength:t},!0]:n==="array"?{minItems:e}:n===void 0?[{minLength:t,minItems:e},!0]:[{},!0],toCode:()=>({runtime:`Schema.isMinLength(${e})`}),[ro]:!0,arbitraryConstraint:{minLength:e},...r})}function q$(e){return H$(1,1,e)}function z$(e,t){return e=En(e),Je(r=>r.length<=e,{expected:`a value with a length of at most ${e}`,representation:{id:"effect/schema/isMaxLength",payload:{maxLength:e}},toJsonSchema:({type:r})=>r==="string"?e===0?{maxLength:e}:[{maxLength:e},!0]:r==="array"?{maxItems:e}:r===void 0?[{maxLength:e,maxItems:e},!0]:[{},!0],toCode:()=>({runtime:`Schema.isMaxLength(${e})`}),[ro]:!0,arbitraryConstraint:{maxLength:e},...t})}function dC(e,t,r){return e=En(e),t=En(t),Je(n=>n.length>=e&&n.length<=t,{expected:e===t?`a value with a length of ${e}`:`a value with a length between ${e} and ${t}`,representation:{id:"effect/schema/isBetweenLength",payload:{minimum:e,maximum:t}},toJsonSchema:({type:n})=>n==="string"?t===0||Math.ceil(e/2)>t?{minLength:Math.ceil(e/2),maxLength:t}:[{minLength:Math.ceil(e/2),maxLength:t},!0]:n==="array"?{minItems:e,maxItems:t}:n===void 0?[{minLength:Math.ceil(e/2),maxLength:t,minItems:e,maxItems:t},!0]:[{},!0],toCode:()=>({runtime:`Schema.isBetweenLength(${e}, ${t})`}),[ro]:!0,arbitraryConstraint:{minLength:e,maxLength:t},...r})}function OX(e,t){return e=En(e),Je(r=>pC(r,e)>=e,{expected:`a string with at least ${e} code points`,representation:{id:"effect/schema/isMinCodePoints",payload:{minCodePoints:e}},toJsonSchema:()=>({minLength:e}),toCode:()=>({runtime:`Schema.isMinCodePoints(${e})`}),arbitraryConstraint:{minCodePoints:e},...t})}function _X(e,t){return e=En(e),Je(r=>pC(r,e+1)<=e,{expected:`a string with at most ${e} code points`,representation:{id:"effect/schema/isMaxCodePoints",payload:{maxCodePoints:e}},toJsonSchema:()=>({maxLength:e}),toCode:()=>({runtime:`Schema.isMaxCodePoints(${e})`}),arbitraryConstraint:{maxCodePoints:e},...t})}function PX(e,t,r){return e=En(e),t=En(t),Je(n=>{let o=pC(n,t+1);return o>=e&&o<=t},{expected:e===t?`a string with ${e} code points`:`a string with between ${e} and ${t} code points`,representation:{id:"effect/schema/isBetweenCodePoints",payload:{minimum:e,maximum:t}},toJsonSchema:()=>({allOf:[{minLength:e},{maxLength:t}]}),toCode:()=>({runtime:`Schema.isBetweenCodePoints(${e}, ${t})`}),arbitraryConstraint:{minCodePoints:e,maxCodePoints:t},...r})}function pC(e,t){if(t===0)return 0;let r=0;for(let n of e)if(++r>=t)break;return r}function En(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${e}`);return Math.max(0,Math.floor(e))}function MX(e,t){return e=En(e),Je(r=>r.size>=e,{expected:`a value with a size of at least ${e}`,representation:{id:"effect/schema/isMinSize",payload:{minSize:e}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isMinSize(${e})`}),[ro]:!0,arbitraryConstraint:{minSize:e},...t})}function FX(e,t){return e=En(e),Je(r=>r.size<=e,{expected:`a value with a size of at most ${e}`,representation:{id:"effect/schema/isMaxSize",payload:{maxSize:e}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isMaxSize(${e})`}),[ro]:!0,arbitraryConstraint:{maxSize:e},...t})}function NX(e,t,r){return e=En(e),t=En(t),Je(n=>n.size>=e&&n.size<=t,{expected:e===t?`a value with a size of ${e}`:`a value with a size between ${e} and ${t}`,representation:{id:"effect/schema/isBetweenSize",payload:{minimum:e,maximum:t}},toJsonSchema:()=>[{},!0],toCode:()=>({runtime:`Schema.isBetweenSize(${e}, ${t})`}),[ro]:!0,arbitraryConstraint:{minSize:e,maxSize:t},...r})}function UX(e,t){return e=En(e),Je(r=>Reflect.ownKeys(r).length>=e,{expected:`a value with at least ${e===1?"1 entry":`${e} entries`}`,representation:{id:"effect/schema/isMinProperties",payload:{minProperties:e}},toJsonSchema:({type:r})=>r==="object"?{minProperties:e}:[{minProperties:e},!0],toCode:()=>({runtime:`Schema.isMinProperties(${e})`}),[ro]:!0,arbitraryConstraint:{minProperties:e},...t})}function DX(e,t){return e=En(e),Je(r=>Reflect.ownKeys(r).length<=e,{expected:`a value with at most ${e===1?"1 entry":`${e} entries`}`,representation:{id:"effect/schema/isMaxProperties",payload:{maxProperties:e}},toJsonSchema:({type:r})=>r==="object"?{maxProperties:e}:[{maxProperties:e},!0],toCode:()=>({runtime:`Schema.isMaxProperties(${e})`}),[ro]:!0,arbitraryConstraint:{maxProperties:e},...t})}function LX(e,t,r){return e=En(e),t=En(t),Je(n=>Reflect.ownKeys(n).length>=e&&Reflect.ownKeys(n).length<=t,{expected:e===t?`a value with exactly ${e===1?"1 entry":`${e} entries`}`:`a value with between ${e} and ${t} entries`,representation:{id:"effect/schema/isBetweenProperties",payload:{minimum:e,maximum:t}},toJsonSchema:({type:n})=>n==="object"?{minProperties:e,maxProperties:t}:[{minProperties:e,maxProperties:t},!0],toCode:()=>({runtime:`Schema.isBetweenProperties(${e}, ${t})`}),[ro]:!0,arbitraryConstraint:{minProperties:e,maxProperties:t},...r})}function BX(e,t){let r=ld(e),n=hL(r.ast);return Je((o,s,i)=>{let a=Reflect.ownKeys(o),c=[];for(let u of a){let f=n(u,i);if(f!==void 0&&(c.push(new Ct([u],f)),i.errors==="first"))break}return Gr(c)?new Ft(s,c,o,i):!0},{expected:"an object with property names matching the schema",representation:{id:"effect/schema/isPropertyNames",payload:null,schemas:[r.ast]},toJsonSchema:({schemas:o,type:s})=>s==="object"?{propertyNames:o[0]}:[{propertyNames:o[0]},!0],toCode:({schemas:o})=>({runtime:`Schema.isPropertyNames(${o[0].runtime})`}),[ro]:!0,...t})}function mC(e){return Je(t=>qx(t).length===t.length,{expected:"an array with unique items",representation:{id:"effect/schema/isUnique",payload:null},toJsonSchema:()=>({uniqueItems:!0}),toCode:()=>({runtime:"Schema.isUnique()"}),arbitraryConstraint:{uniqueBy:F},...e})}function W$(e){return Je(t=>qx(t.map(([r])=>r)).length===t.length,{expected:"an array with unique keys",representation:{id:"effect/schema/isUniqueKey",payload:null},toCode:()=>({runtime:"Schema.isUniqueKey()"}),arbitraryConstraint:{uniqueBy:t=>t[0]},...e})}var hC=z.check(q$()),$X=z.check(dC(1,1)),K$=e=>(e?.includeStack===!0?1:0)|(e?.excludeCause===!0?2:0),V$=e=>{switch(e){case 0:return;case 1:return{includeStack:!0};case 2:return{excludeCause:!0};case 3:return{includeStack:!0,excludeCause:!0}}},t$=[];function jX(e){let t=K$(e),r=t$[t];if(r!==void 0)return r;let n=V$(t),o=yc(globalThis.Error,{representation:{id:"effect/schema/Error",payload:n??null},toCode:()=>({runtime:n!==void 0?`Schema.ErrorInstance(${H(n)})`:"Schema.ErrorInstance()",Type:"globalThis.Error"}),expected:"Error",toCodecJson:()=>Ne()(pre,Y1(n))});return t$[t]=o,o}var r$=[];function er(e){let t=K$(e),r=r$[t];if(r!==void 0)return r;let n=XS.pipe(ee(Xm,X1(V$(t))));return r$[t]=n,n}function HX(e,t){let r=Ar()([e,t],([n,o])=>{let s=ct(rs([n,o]));return(i,a,c)=>i instanceof globalThis.Map?cr(ot(s)([...i],c),{onSuccess:u=>new globalThis.Map(u),onFailure:u=>tn(a,"entries",u,i,c)}):D(new at(a,i,c))},{representation:{id:"effect/schema/ReadonlyMap",payload:null},toCode:({typeParameters:n})=>({runtime:`Schema.ReadonlyMap(${n[0].runtime}, ${n[1].runtime})`,Type:`globalThis.ReadonlyMap<${n[0].Type}, ${n[1].Type}>`}),expected:"ReadonlyMap",toCodec:([n,o])=>Ne()(ct(rs([n,o])),Fe({decode:s=>new globalThis.Map(s),encode:s=>[...s.entries()]}))});return J(r.ast,{key:e,value:t})}function qX(e){let t=Ar()([e],([r])=>{let n=ct(r);return(o,s,i)=>o instanceof globalThis.Set?cr(ot(n)([...o],i),{onSuccess:a=>new globalThis.Set(a),onFailure:a=>tn(s,"values",a,o,i)}):D(new at(s,o,i))},{representation:{id:"effect/schema/ReadonlySet",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.ReadonlySet(${r[0].runtime})`,Type:`globalThis.ReadonlySet<${r[0].Type}>`}),expected:"ReadonlySet",toCodec:([r])=>Ne()(ct(r),Fe({decode:n=>new globalThis.Set(n),encode:n=>[...n.values()]}))});return J(t.ast,{value:e})}var zX=yc(globalThis.RegExp,{representation:{id:"effect/schema/RegExp",payload:null},toCode:()=>({runtime:"Schema.RegExp",Type:"globalThis.RegExp"}),expected:"RegExp",toCodecJson:()=>Ne()(Te({source:z,flags:z}),Xt({decode:(e,t)=>Go({try:()=>new globalThis.RegExp(e.source,e.flags),catch:()=>new le({expected:"valid RegExp source and flags"},e,t)}),encode:e=>I({source:e.source,flags:e.flags})}))}),G$=z.annotate({expected:"a string that will be decoded as a URL"}),J$=yc(globalThis.URL,{representation:{id:"effect/schema/URL",payload:null},toCode:()=>({runtime:"Schema.URL",Type:"globalThis.URL"}),expected:"URL",toCodecJson:()=>Ne()(G$,pv)}),WX=G$.pipe(ee(J$,pv)),Z$=z.annotate({expected:"a string that will be decoded as a Date"}),GS=Ge(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:()=>Ne()(Z$,lv)}),KX=Z$.pipe(ee(GS,lv)),VX=In.pipe(ee(GS,K1)),GX=z.annotate({expected:"a string that will be decoded as JSON",contentMediaType:"application/json"});function xC(e,t){return GX.pipe(ee(e,u2(t)))}var JX=xC(Xm),Q$=yc(globalThis.File,{representation:{id:"effect/schema/File",payload:null},toCode:()=>({runtime:"Schema.File",Type:"globalThis.File"}),expected:"File",toCodecJson:()=>Ne()(Te({data:z.check(L$()),type:z,name:z,lastModified:In}),Xt({decode:(e,t)=>zn(Cu(e.data),{onFailure:()=>D(new le({expected:"a valid Base64 string"},e.data,t)),onSuccess:r=>{let n=new globalThis.Uint8Array(r);return I(new globalThis.File([n],e.name,{type:e.type,lastModified:e.lastModified}))}}),encode:(e,t)=>Vo({try:async()=>{let r=new globalThis.Uint8Array(await e.arrayBuffer());return{data:Cl(r),type:e.type,name:e.name,lastModified:e.lastModified}},catch:()=>new le({expected:"a readable File"},e,t)})}))}),Y$=yc(globalThis.FormData,{representation:{id:"effect/schema/FormData",payload:null},toCode:()=>({runtime:"Schema.FormData",Type:"globalThis.FormData"}),expected:"FormData",toCodecJson:()=>Ne()(ct(rs([z,Pe([Te({_tag:He("String"),value:z}),Te({_tag:He("File"),value:Q$})])])),Xt({decode:e=>{let t=new globalThis.FormData;for(let[r,n]of e)t.append(r,n.value);return I(t)},encode:e=>I(globalThis.Array.from(e.entries()).map(([t,r])=>typeof r=="string"?[t,{_tag:"String",value:r}]:[t,{_tag:"File",value:r}]))}))});function ZX(e){return Y$.pipe(ee(e,f2))}var X$=yc(globalThis.URLSearchParams,{representation:{id:"effect/schema/URLSearchParams",payload:null},toCode:()=>({runtime:"Schema.URLSearchParams",Type:"globalThis.URLSearchParams"}),expected:"URLSearchParams",toCodecJson:()=>Ne()(z.annotate({expected:"a query string that will be decoded as URLSearchParams"}),Fe({decode:e=>new globalThis.URLSearchParams(e),encode:e=>e.toString()}))});function QX(e){return X$.pipe(ee(e,l2))}var YX=z.annotate({expected:"a string that will be decoded as a number"}).pipe(ee(Qu,Ul)),XX=z.annotate({expected:"a string that will be decoded as a finite number"}).pipe(ee(KS,Ul)),eee=J(zv).pipe(ee(dd,Jy)),ej=z.check(D$()),tee=z.annotate({expected:"a string that will be decoded as a trimmed string"}).pipe(ee(ej,W1())),ree=z.annotate({expected:"a base64 encoded string that will be decoded as a UTF-8 string"}).pipe(ee(z,s2)),nee=z.annotate({expected:"a base64 (URL) encoded string that will be decoded as a UTF-8 string"}).pipe(ee(z,i2)),oee=z.annotate({expected:"a hex encoded string that will be decoded as a UTF-8 string"}).pipe(ee(z,a2)),see=z.annotate({expected:"a URI component encoded string that will be decoded as a UTF-8 string"}).pipe(ee(z,c2)),eC=Pe([KS,E$,z]),iee=Te({issues:ct(Te({message:z,path:lr(ct(Pe([eC,Te({key:eC})])))}))}),aee=Fo([0,1]).pipe(ee(Fi,Fe({decode:e=>e===1,encode:e=>e?1:0}))),tj=z.annotate({expected:"a base64 encoded string that will be decoded as Uint8Array",format:"byte",contentEncoding:"base64"}),qs=yc(globalThis.Uint8Array,{representation:{id:"effect/schema/Uint8Array",payload:null},toCode:()=>({runtime:"Schema.Uint8Array",Type:"globalThis.Uint8Array"}),expected:"Uint8Array",toCodecJson:()=>Ne()(tj,mv)}),cee=tj.pipe(ee(qs,mv)),uee=z.annotate({expected:"a base64 (URL) encoded string that will be decoded as a Uint8Array"}).pipe(ee(qs,{decode:M1(),encode:zy()})),rj=z.annotate({expected:"a hex encoded string that will be decoded as a Uint8Array"}).pipe(ee(qs,{decode:N1(),encode:Wy()})),nj=Xt({decode:(e,t)=>{let r=rD(e);return fe(r)?D(new le({expected:"a valid BigDecimal string"},e,t)):I(r.value)},encode:e=>I(fa(e))}),fee=eh({order:wl,formatter:e=>fa(e)}),lee=th({order:wl,formatter:e=>fa(e)}),dee=rh({order:wl,formatter:e=>fa(e)}),pee=nh({order:wl,formatter:e=>fa(e)}),mee=oh({order:wl,formatter:e=>fa(e)}),oj=z.annotate({expected:"a string that will be decoded as a BigDecimal"}),sj=Ge(wu,{representation:{id:"effect/schema/BigDecimal",payload:null},toCode:()=>({runtime:"Schema.BigDecimal",Type:"BigDecimal.BigDecimal",importDeclarations:['import * as BigDecimal from "effect/BigDecimal"']}),expected:"BigDecimal",toCodecJson:()=>Ne()(oj,nj),toFormatter:()=>e=>fa(e)}),hee=oj.pipe(ee(sj,nj)),JS=Ge(lD,{representation:{id:"effect/schema/ByteSize",payload:null},toCode:()=>({runtime:"Schema.ByteSize",Type:"ByteSize.ByteSize",importDeclarations:['import * as ByteSize from "effect/ByteSize"']}),expected:"ByteSize",toCodecJson:()=>Ne()(dd.check($$(globalThis.BigInt(0))),Fe({decode:fD,encode:gy})),toCodecStringTree:()=>Ne()(ij,dv)}),ij=z.annotate({expected:"a string that will be decoded as a ByteSize"}),xee=ij.pipe(ee(JS,dv)),gee=dd.pipe(ee(JS,V1)),yee=Qu.pipe(ee(JS,G1));function tC(e,t){let r=Ar()([e,t],([n,o])=>(s,i,a)=>{if(!al(s))return D(new at(i,s,a));switch(s._tag){case"Fail":return cr(ot(n)(s.error,a),{onSuccess:Ap,onFailure:c=>tn(i,"error",c,s,a)});case"Die":return cr(ot(o)(s.defect,a),{onSuccess:Cp,onFailure:c=>tn(i,"defect",c,s,a)});case"Interrupt":return I(s)}},{representation:{id:"effect/schema/CauseReason",payload:null},toCode:({typeParameters:n})=>({runtime:`Schema.CauseReason(${n[0].runtime}, ${n[1].runtime})`,Type:`Cause.Failure<${n[0].Type}, ${n[1].Type}>`,importDeclarations:['import * as Cause from "effect/Cause"']}),expected:"Cause.Failure",toCodec:([n,o])=>Ne()(Pe([Te({_tag:fr("Fail"),error:n}),Te({_tag:fr("Die"),defect:o}),Te({_tag:fr("Interrupt"),fiberId:zS(KS)})]),Fe({decode:s=>{switch(s._tag){case"Fail":return Ap(s.error);case"Die":return Cp(s.defect);case"Interrupt":return kp(s.fiberId)}},encode:s=>{switch(s._tag){case"Fail":return{_tag:"Fail",error:s.error};case"Die":return{_tag:"Die",defect:s.defect};case"Interrupt":return{_tag:"Interrupt",fiberId:s.fiberId}}}}))});return J(r.ast,{error:e,defect:t})}function Jm(e,t){let r=Ar()([e,t],([n,o])=>{let s=ct(tC(n,o));return(i,a,c)=>il(i)?cr(ot(s)(i.reasons,c),{onSuccess:fu,onFailure:u=>tn(a,"failures",u,i,c)}):D(new at(a,i,c))},{representation:{id:"effect/schema/Cause",payload:null},toCode:({typeParameters:n})=>({runtime:`Schema.Cause(${n[0].runtime}, ${n[1].runtime})`,Type:`Cause.Cause<${n[0].Type}, ${n[1].Type}>`,importDeclarations:['import * as Cause from "effect/Cause"']}),expected:"Cause",toCodec:([n,o])=>Ne()(ct(tC(n,o)),Fe({decode:fu,encode:({reasons:s})=>s}))});return J(r.ast,{error:e,defect:t})}function n$(e){return Ne()(e,Fe({decode:Sw,encode:At}))}function See(e){let t=Ar()([e],([r])=>{let n=ct(r);return(o,s,i)=>Al(o)?cr(ot(n)(At(o),i),{onSuccess:Sw,onFailure:a=>tn(s,"values",a,o,i)}):D(new at(s,o,i))},{representation:{id:"effect/schema/Chunk",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.Chunk(${r[0].runtime})`,Type:`Chunk.Chunk<${r[0].Type}>`}),expected:"Chunk",toCodec:([r])=>n$(ct(r)),toCodecArbitrary:({constraint:r,typeParameters:[n]})=>n$(qS(ct(n),r?.minLength,r?.maxLength)),toEquivalence:([r])=>gw(r)});return J(t.ast,{value:e})}function aj(){return rn((e,t)=>Zt(bw(e),{onNone:()=>D(new le({message:"Invalid DateTime input"},e,t)),onSome:r=>I(Ew(r))}))}var bee=Fe({decode:e=>Tw(e),encode:e=>e.offset}),cj=Xt({decode:(e,t)=>Zt(wD(e),{onNone:()=>D(new le({expected:"a valid IANA time zone"},e,t)),onSome:I}),encode:e=>I(e.id)}),uj=Xt({decode:(e,t)=>Zt(vD(e),{onNone:()=>D(new le({expected:"a valid time zone"},e,t)),onSome:I}),encode:e=>I(tm(e))}),fj=Xt({decode:(e,t)=>Zt(bw(e),{onNone:()=>D(new le({expected:"a valid UTC DateTime string"},e,t)),onSome:r=>I(Ew(r))}),encode:e=>I(kD(e))}),lj=Xt({decode:(e,t)=>Zt(TD(e),{onNone:()=>D(new le({expected:"a valid Zoned DateTime string"},e,t)),onSome:I}),encode:e=>I(ww(e))}),dj=-864e13,pj=864e13,Eee=dj+840*60*1e3,Iee=pj-840*60*1e3,Tee=-720*60*1e3,wee=840*60*1e3,mj=["UTC","Europe/London","America/New_York","Asia/Tokyo","Australia/Sydney"];function hj(e,t,r){let n=Math.max(t,e?.minimum===void 0?t:e.minimum.epochMilliseconds+(e.exclusiveMinimum===!0?1:0)),o=Math.min(r,e?.maximum===void 0?r:e.maximum.epochMilliseconds-(e.exclusiveMaximum===!0?1:0));return n<=o?[n,o]:[t,r]}function gC(e,t){return In.check(Sc({minimum:e,maximum:t}))}function xj(){return Pe([gC(Tee,wee),Fo(mj)])}var ZS=Ge(e=>Au(e)&&bD(e),{representation:{id:"effect/schema/DateTimeUtc",payload:null},toCode:()=>({runtime:"Schema.DateTimeUtc",Type:"DateTime.Utc",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.Utc",toCodecArbitrary:({constraint:e})=>{let[t,r]=hj(e,dj,pj);return md()(gC(t,r),Ie(by))},toCodecJson:()=>Ne()(z,fj),toFormatter:()=>e=>e.toString()}),vee=GS.pipe(ee(ZS,{decode:aj(),encode:Ie(AD)})),Aee=z.annotate({expected:"a string that will be decoded as a DateTime.Utc"}).pipe(ee(ZS,fj)),Cee=In.pipe(ee(ZS,{decode:aj(),encode:Ie(CD)})),kee=Ge(yD,{representation:{id:"effect/schema/TimeZoneOffset",payload:null},toCode:()=>({runtime:"Schema.TimeZoneOffset",Type:"DateTime.TimeZone.Offset",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.TimeZone.Offset",toCodecJson:()=>Ne()(In,bee),toFormatter:()=>e=>tm(e)}),gj=z.annotate({expected:"an IANA time zone identifier"}),yj=Ge(SD,{representation:{id:"effect/schema/TimeZoneNamed",payload:null},toCode:()=>({runtime:"Schema.TimeZoneNamed",Type:"DateTime.TimeZone.Named",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.TimeZone.Named",toCodecArbitrary:()=>md()(Fo(mj),Ie(Iw)),toCodecJson:()=>Ne()(gj,cj),toFormatter:()=>e=>tm(e)}),Ree=gj.pipe(ee(yj,cj)),Sj=z.annotate({expected:"a time zone string (IANA identifier or offset like +03:00)"}),bj=Ge(gD,{representation:{id:"effect/schema/TimeZone",payload:null},toCode:()=>({runtime:"Schema.TimeZone",Type:"DateTime.TimeZone",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.TimeZone",toCodecArbitrary:()=>md()(xj(),Ie(e=>typeof e=="number"?Tw(e):Iw(e))),toCodecJson:()=>Ne()(Sj,uj),toFormatter:()=>e=>tm(e)}),Oee=Sj.pipe(ee(bj,uj)),Ej=z.annotate({expected:"a zoned DateTime string (e.g. 2024-01-01T00:00:00.000+00:00[Europe/London])"}),Ij=Ge(e=>Au(e)&&ED(e),{representation:{id:"effect/schema/DateTimeZoned",payload:null},toCode:()=>({runtime:"Schema.DateTimeZoned",Type:"DateTime.Zoned",importDeclarations:['import * as DateTime from "effect/DateTime"']}),expected:"DateTime.Zoned",toCodecArbitrary:({constraint:e})=>{let[t,r]=hj(e,Eee,Iee);return md()(Te({epochMilliseconds:gC(t,r),timeZone:xj()}),Ie(({epochMilliseconds:n,timeZone:o})=>Ey(n,{timeZone:o})))},toCodecJson:()=>Ne()(Ej,lj),toFormatter:()=>e=>ww(e),toEquivalence:()=>ID}),_ee=Ej.pipe(ee(Ij,lj)),so=(e,t,r,n)=>z.pipe(ee(e,Xt({decode:(o,s)=>{let i=t(o);return tt(i)?I(i.success):D(new le({message:i.failure.message},o,s))},encode:o=>I(r(o))}))).annotate({identifier:n}),tf=Ge(nd,{identifier:"MacAddress"}),hd=so(tf,RB,OA,"MacAddressFromString"),sh=Ge(Br,{identifier:"Ipv4Address"}),yC=so(sh,Ku,$r,"Ipv4AddressFromString"),QS=Ge(ts,{identifier:"Ipv6Address"}),Tj=so(QS,Vu,$r,"Ipv6AddressFromString"),bc=Ge(AA,{identifier:"IpAddress"}),rf=so(bc,mc,$r,"IpAddressFromString"),kt=(e,t,r,n)=>A$(t,{expected:r})(e).annotate({identifier:n}),Pee=kt(bc,od,"a multicast address","IpMulticastAddress"),Mee=kt(rf,od,"a multicast address","IpMulticastAddressFromString"),Fee=kt(tf,od,"a multicast address","MacMulticastAddress"),Nee=kt(hd,od,"a multicast address","MacMulticastAddressFromString"),Uee=kt(bc,FA,"a unicast address","IpUnicastAddress"),Dee=kt(rf,FA,"a unicast address","IpUnicastAddressFromString"),Lee=kt(tf,_S,"a unicast address","MacUnicastAddress"),Bee=kt(hd,_S,"a unicast address","MacUnicastAddressFromString"),$ee=kt(sh,MS,"a broadcast address","Ipv4BroadcastAddress"),jee=kt(yC,MS,"a broadcast address","Ipv4BroadcastAddressFromString"),Hee=kt(tf,OS,"a broadcast address","MacBroadcastAddress"),qee=kt(hd,OS,"a broadcast address","MacBroadcastAddressFromString"),zee=kt(bc,MA,"a loopback address","IpLoopbackAddress"),Wee=kt(rf,MA,"a loopback address","IpLoopbackAddressFromString"),Kee=kt(bc,NA,"a link-local address","IpLinkLocalAddress"),Vee=kt(rf,NA,"a link-local address","IpLinkLocalAddressFromString"),Gee=kt(bc,PS,"an unspecified address","IpUnspecifiedAddress"),Jee=kt(rf,PS,"an unspecified address","IpUnspecifiedAddressFromString"),Zee=kt(sh,UA,"a private address","Ipv4PrivateAddress"),Qee=kt(yC,UA,"a private address","Ipv4PrivateAddressFromString"),Yee=kt(QS,DA,"a unique-local address","Ipv6UniqueLocalAddress"),Xee=kt(Tj,DA,"a unique-local address","Ipv6UniqueLocalAddressFromString"),ete=kt(tf,_A,"a locally administered address","MacLocallyAdministeredAddress"),tte=kt(hd,_A,"a locally administered address","MacLocallyAdministeredAddressFromString"),rte=kt(tf,PA,"a universally administered address","MacUniversallyAdministeredAddress"),nte=kt(hd,PA,"a universally administered address","MacUniversallyAdministeredAddressFromString"),wj=Ge(jB,{identifier:"Ipv4Interface"}),ote=so(wj,DS,zm,"Ipv4InterfaceFromString"),vj=Ge(HB,{identifier:"Ipv6Interface"}),ste=so(vj,LS,zm,"Ipv6InterfaceFromString"),Aj=Ge(Hm,{identifier:"IpInterface"}),ite=so(Aj,BS,zm,"IpInterfaceFromString"),Cj=Ge(zB,{identifier:"Ipv4Network"}),ate=so(Cj,KB,Km,"Ipv4NetworkFromString"),kj=Ge(WB,{identifier:"Ipv6Network"}),cte=so(kj,VB,Km,"Ipv6NetworkFromString"),Rj=Ge(Wm,{identifier:"IpNetwork"}),ute=so(Rj,GB,Km,"IpNetworkFromString"),fte=Ge(Dm,{identifier:"InetAddressV4"}),lte=Ge(Lm,{identifier:"InetAddressV6"}),Oj=Ge(CA,{identifier:"InetAddress"}),dte=so(Oj,LA,FS,"InetAddressFromString"),_j=Ge(kS,{identifier:"UnixPathAddress"}),pte=z.pipe(ee(_j,Fe({decode:_B,encode:e=>e.path}))).annotate({identifier:"UnixPathAddressFromString"}),mte=Ge(CB,{identifier:"SocketAddress"}),Sa=z.check(Je(ga,{expected:"a normalized domain name"})).pipe(WS("~effect/net/Host/DomainName")).annotate({identifier:"DomainName"}),Pj=so(Sa,NS,e=>e,"DomainNameFromString"),SC=z.check(Je(kA,{expected:"a canonical scoped IPv6 literal"})).pipe(WS("~effect/net/NetAddress/ScopedIpv6Literal")).annotate({identifier:"ScopedIpv6Literal"}),Mj=so(SC,Bm,e=>e,"ScopedIpv6LiteralFromString"),hte=Pe([bc,SC,Sa]).annotate({identifier:"Host"}),xte=Pe([rf,Mj,Pj]).annotate({identifier:"HostFromString"}),Fj=Ge(jA,{identifier:"HostPort"}),gte=so(Fj,MB,HA,"HostPortFromString"),yte=In.check(Sc({minimum:0,maximum:65535},{expected:"a port number"})),Ste=Xt({decode:(e,t)=>Zt(fP(e),{onNone:()=>D(new le({expected:"a valid Duration string"},e,t)),onSome:I}),encode:e=>I(globalThis.String(e))}),bte=Xt({decode:e=>I($o(e)),encode:(e,t)=>Zt(lP(e),{onNone:()=>D(new le({expected:"a Duration representable as a bigint"},e,t)),onSome:r=>I(r)})}),Ete=Fe({decode:e=>Zi(e),encode:e=>Wt(e)}),ih=Ge(Qi,{representation:{id:"effect/schema/Duration",payload:null},toCode:()=>({runtime:"Schema.Duration",Type:"Duration.Duration",importDeclarations:['import * as Duration from "effect/Duration"']}),expected:"Duration",toCodecJson:()=>Ne()(Pe([Te({_tag:fr("Infinity")}),Te({_tag:fr("NegativeInfinity")}),Te({_tag:fr("Nanos"),value:dd}),Te({_tag:fr("Millis"),value:In})]),Fe({decode:e=>{switch(e._tag){case"Infinity":return Ss;case"NegativeInfinity":return La;case"Nanos":return $o(e.value);case"Millis":return Zi(e.value)}},encode:e=>{switch(e.value._tag){case"Infinity":return{_tag:"Infinity"};case"NegativeInfinity":return{_tag:"NegativeInfinity"};case"Nanos":return{_tag:"Nanos",value:e.value.nanos};case"Millis":return{_tag:"Millis",value:e.value.millis}}}}))}),Ite=z.annotate({expected:"a string that will be decoded as a Duration"}),Tte=Ite.pipe(ee(ih,Ste)),wte=dd.pipe(ee(ih,bte)),vte=Qu.pipe(ee(ih,Ete)),Ate=Fo(WA),Nj=(e,t)=>z.pipe(ee(e,Xt({decode:(r,n)=>{let o=t(r);return be(o)?D(new le({message:o.failure.message},r,n)):$r(o.success)===r?I(o.success):D(new le({message:"expected a canonical address"},r,n))},encode:r=>I($r(r))}))),YA=In.check(Sc({minimum:0,maximum:255})),id=In.check(Sc({minimum:0,maximum:65535})),Uj=In.check(Sc({minimum:0,maximum:4294967295})),$S=Uj.pipe(ee(ih,Fe({decode:fp,encode:ui}))),ns=(e,t)=>Ge(r=>KA(r)&&r._tag===e,{identifier:`Dns${e.charAt(0)}${e.slice(1).toLowerCase()}Record`,toCodecJson:()=>{let r=ya(e,t);return Ne()(r,Xt({decode:(n,o)=>{let{_tag:s,...i}=n,a=LB(e,i);return tt(a)?I(a.success):D(new le({message:a.failure.message},n,o))},encode:n=>I({...n})}))}}),Dj=ns("A",{address:Nj(sh,Ku)}),Lj=ns("AAAA",{address:Nj(QS,Vu)}),Bj=ns("CAA",{critical:Fi,tag:z.check(ef(/^[a-z0-9]+$/i)),value:z}),$j=ns("CNAME",{target:Sa}),jj=ns("MX",{exchange:Sa,priority:id}),Hj=ns("NAPTR",{order:id,preference:id,flags:z,service:z,regexp:z,replacement:Sa}),qj=ns("NS",{host:Sa}),zj=ns("PTR",{host:hC}),Wj=ns("SOA",{primary:Sa,admin:hC,serial:Uj,refresh:$S,retry:$S,expire:$S,minimum:$S}),Kj=ns("SRV",{target:Sa,port:id,priority:id,weight:id}),Vj=ns("TLSA",{certUsage:YA,selector:YA,matchingType:YA,data:rj}),Gj=ns("TXT",{chunks:Xu(z)}),Cte=Pe([Dj,Lj,Bj,$j,jj,Hj,qj,zj,Wj,Kj,Vj,Gj]).annotate({identifier:"DnsRecord"});function bC(e,t,r){let n=Ar()([e,t,r],([o,s,i])=>{let a=Jm(s,i);return(c,u,f)=>{if(!ws(c))return D(new at(u,c,f));switch(c._tag){case"Success":return cr(ot(o)(c.value,f),{onSuccess:Mr,onFailure:p=>tn(u,"value",p,c,f)});case"Failure":return cr(ot(a)(c.cause,f),{onSuccess:ir,onFailure:p=>tn(u,"cause",p,c,f)})}}},{representation:{id:"effect/schema/Exit",payload:null},toCode:({typeParameters:o})=>({runtime:`Schema.Exit(${o[0].runtime}, ${o[1].runtime}, ${o[2].runtime})`,Type:`Exit.Exit<${o[0].Type}, ${o[1].Type}, ${o[2].Type}>`,importDeclarations:['import * as Exit from "effect/Exit"']}),expected:"Exit",toCodec:([o,s,i])=>Ne()(Pe([Te({_tag:fr("Success"),value:o}),Te({_tag:fr("Failure"),cause:Jm(s,i)})]),Fe({decode:a=>a._tag==="Success"?Mr(a.value):ir(a.cause),encode:a=>ft(a)?{_tag:"Success",value:a.value}:{_tag:"Failure",cause:a.cause}}))});return J(n.ast,{value:e,error:t,defect:r})}function o$(e,t,r){return Te({type:fr(e),nodes:ct(Te({index:Gu,data:t})),edges:ct(Te({index:Gu,source:Gu,target:Gu,data:r}))})}function s$(e,t){let r=-1,n=new Set;for(let o=0;o<e.nodes.length;o++){let s=e.nodes[o].index;if(s<=r)return D(new Ct(["nodes",o,"index"],new le({expected:"a strictly increasing node index"},s,t)));r=s,n.add(s)}r=-1;for(let o=0;o<e.edges.length;o++){let s=e.edges[o];if(s.index<=r)return D(new Ct(["edges",o,"index"],new le({expected:"a strictly increasing edge index"},s.index,t)));if(r=s.index,!n.has(s.source))return D(new Ct(["edges",o,"source"],new le({expected:"an encoded node index"},s.source,t)));if(!n.has(s.target))return D(new Ct(["edges",o,"target"],new le({expected:"an encoded node index"},s.target,t)))}return I(Dy(e))}function kte(e,t,r){return!Yw(e)||e.mutable||e.type!==t?D(new le({expected:`an immutable ${t} Graph`},e,r)):I(lm(e))}function Rte(e,t){return(r,n)=>{let o=lm(r),s=lm(n);if(o.type!==s.type||o.nodes.length!==s.nodes.length||o.edges.length!==s.edges.length)return!1;for(let i=0;i<o.nodes.length;i++)if(o.nodes[i].index!==s.nodes[i].index||!e(o.nodes[i].data,s.nodes[i].data))return!1;for(let i=0;i<o.edges.length;i++){let a=o.edges[i],c=s.edges[i],u=o.type==="directed"?a.source===c.source&&a.target===c.target:a.source===c.source&&a.target===c.target||a.source===c.target&&a.target===c.source;if(a.index!==c.index||!u||!t(a.data,c.data))return!1}return!0}}function Ote(e,t,r){return md()(Pe([HS,Te({nodes:Xu(t),edges:ct(rs([Gu,Gu,r]))})]),Ie(n=>{if(n===null)return Dy({type:e,nodes:[],edges:[]});let o=n.nodes.map((s,i)=>({index:i,data:s}));return Dy({type:e,nodes:o,edges:n.edges.map(([s,i,a],c)=>({index:c,source:s%o.length,target:i%o.length,data:a}))})}))}function _te(e,t,r){let n=Ar()([t,r],([o,s])=>{let i=o$(e,o,s);return(a,c,u)=>!Yw(a)||a.mutable||a.type!==e?D(new at(c,a,u)):C(ot(i)(lm(a),u),f=>s$(f,u))},{representation:{id:"effect/schema/Graph",payload:e},toCode:({typeParameters:o})=>({runtime:`Schema.Graph(${H(e)}, ${o[0].runtime}, ${o[1].runtime})`,Type:`Graph.Graph<${o[0].Type}, ${o[1].Type}, ${H(e)}>`,importDeclarations:['import * as Graph from "effect/Graph"']}),expected:`an immutable ${e} Graph`,toCodec:([o,s])=>Ne()(o$(e,o,s),Xt({decode:s$,encode:(i,a)=>kte(i,e,a)})),toCodecArbitrary:({typeParameters:[o,s]})=>Ote(e,o,s),toEquivalence:([o,s])=>Rte(o,s)});return J(n.ast,{type:e,node:t,edge:r})}function i$(e){return Ne()(e,Fe({decode:Nw,encode:im}))}function Pte(e,t){let r=Ar()([e,t],([n,o])=>{let s=ct(rs([n,o]));return(i,a,c)=>Cy(i)?cr(ot(s)(im(i),c),{onSuccess:Nw,onFailure:u=>tn(a,"entries",u,i,c)}):D(new at(a,i,c))},{representation:{id:"effect/schema/HashMap",payload:null},toCode:({typeParameters:n})=>({runtime:`Schema.HashMap(${n[0].runtime}, ${n[1].runtime})`,Type:`HashMap.HashMap<${n[0].Type}, ${n[1].Type}>`,importDeclarations:['import * as HashMap from "effect/HashMap"']}),expected:"HashMap",toCodec:([n,o])=>i$(ct(rs([n,o]))),toCodecArbitrary:({constraint:n,typeParameters:[o,s]})=>i$(qS(ct(rs([o,s])).check(W$()),n?.minSize,n?.maxSize)),toEquivalence:([n,o])=>yx(n,o)});return J(r.ast,{key:e,value:t})}function a$(e){return Ne()(e,Fe({decode:Dw,encode:At}))}function Mte(e){let t=Ar()([e],([r])=>{let n=ct(r);return(o,s,i)=>_y(o)?cr(ot(n)(At(o),i),{onSuccess:Dw,onFailure:a=>tn(s,"values",a,o,i)}):D(new at(s,o,i))},{representation:{id:"effect/schema/HashSet",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.HashSet(${r[0].runtime})`,Type:`HashSet.HashSet<${r[0].Type}>`}),expected:"HashSet",toCodec:([r])=>a$(ct(r)),toCodecArbitrary:({constraint:r,typeParameters:[n]})=>a$(qS(ct(n).check(mC()),r?.minSize,r?.maxSize)),toEquivalence:([r])=>zd(r)});return J(t.ast,{value:e})}function ba(e){let t=Ar()([e],([r])=>(n,o,s)=>ci(n)?fe(n)?ia:cr(ot(r)(n.value,s),{onSuccess:N,onFailure:i=>tn(o,"value",i,n,s)}):D(new at(o,n,s)),{representation:{id:"effect/schema/Option",payload:null},toCode:({typeParameters:r})=>({runtime:`Schema.Option(${r[0].runtime})`,Type:`Option.Option<${r[0].Type}>`,importDeclarations:['import * as Option from "effect/Option"']}),expected:"Option",toCodec:([r])=>Ne()(Pe([Te({_tag:fr("Some"),value:r}),Te({_tag:fr("None")})]),Fe({decode:n=>n._tag==="None"?_():N(n.value),encode:n=>de(n)?{_tag:"Some",value:n.value}:{_tag:"None"}}))});return J(t.ast,{value:e})}function Fte(e){return cC(e).pipe(ee(ba(oo(e)),e2()))}function Nte(e){return zS(e).pipe(ee(ba(oo(e)),t2()))}function Ute(e,t){return w$(e).pipe(ee(ba(oo(e)),r2(t)))}var Jj=Ge(KD,{representation:{id:"effect/http/Cookie",payload:null},toCode:()=>({runtime:"Schema.Cookie",Type:"Cookies.Cookie",importDeclarations:['import * as Cookies from "effect/http/Cookies"']}),expected:"Cookie"}),Zj=Ge(WD,{representation:{id:"effect/http/Cookies",payload:null},toCode:()=>({runtime:"Schema.Cookies",Type:"Cookies.Cookies",importDeclarations:['import * as Cookies from "effect/http/Cookies"']}),expected:"Cookies",toCodecJson:()=>Ne()(ct(z),Fe({decode:My,encode:QD})),toCodecIso:()=>Ne()(Yu(z,Jj),Fe({decode:Hw,encode:e=>e.cookies}))}),Dte=Zj.pipe(ee(Yu(z,z),Fe({decode:ZD,encode:e=>qw(globalThis.Object.entries(e).map(([t,r])=>JD(t,r)))}))),Lte=Ge(t1,{representation:{id:"effect/http/Headers",payload:null},toCode:()=>({runtime:"Schema.Headers",Type:"Headers.Headers",importDeclarations:['import * as Headers from "effect/http/Headers"']}),expected:"Headers",toEquivalence:()=>Kw,toCodec:()=>Ne()(Yu(z,z),Fe({decode:Zo,encode:e=>({...e})}))}),EC=Ge(Jw,{representation:{id:"effect/http/UrlParams",payload:null},toCode:()=>({runtime:"Schema.UrlParams",Type:"UrlParams.UrlParams",importDeclarations:['import * as UrlParams from "effect/http/UrlParams"']}),expected:"UrlParams",toEquivalence:()=>Zw,toCodec:()=>Ne()(ct(rs([z,z])),Fe({decode:Ol,encode:e=>e.params}))}),Bte=(e,t)=>EC.pipe(ee(xC(Xm,t),Xt({decode:r=>Zt(a1(r,e),{onNone:()=>D(new Ct([e],new Yt(void 0))),onSome:I}),encode:r=>I(Ol([[e,r]]))}))),$te=EC.pipe(ee(Yu(z,Pe([z,Xu(z)])),Fe({decode:u1,encode:Fu})));function jte(e){return Ju(e).pipe(ee(ba(oo(e)),n2()))}function Hte(e){return lr(e).pipe(ee(ba(oo(e)),o2()))}function qte(e,t){let r=t===void 0?"omit":t.onNoneEncoding,n=r===null?null:void 0;return lr(cC(e)).pipe(ee(ba(oo(e)),Gy({decode:o=>o.pipe(Na(hx),N),encode:r==="omit"?tu:o=>N(Fa(tu(o),()=>n))})))}function Qj(e,t){let r=typeof t?.label=="string"?t.label:void 0,n=t?.disallowJsonEncode===!0,o=r!==void 0?n?{label:r,disallowJsonEncode:!0}:{label:r}:n?{disallowJsonEncode:!0}:void 0,s=r!==void 0?ot(fr(r)):void 0,i=Ar()([e],([a])=>(c,u,f)=>{if(cm(c)){let p=s!==void 0?Tu(s(c.label,f),m=>new Ct(["label"],m)):P;return ur(p,()=>cr(ot(a)(oc(c),f),{onSuccess:m=>Mu(m,{label:c.label}),onFailure:()=>new Ft(u,[new Ct(["value"],new le(void 0,c,f))],c,f)}))}return D(new at(u,c,f))},{representation:{id:"effect/schema/Redacted",payload:o??null},toCode:({typeParameters:a})=>({runtime:o!==void 0?`Schema.Redacted(${a[0].runtime}, ${H(o)})`:`Schema.Redacted(${a[0].runtime})`,Type:`Redacted.Redacted<${a[0].Type}>`,importDeclarations:['import * as Redacted from "effect/Redacted"']}),expected:"Redacted",toCodecJson:([a])=>Ne()(a,{decode:Ie(c=>Mu(c,{label:r})),encode:n?jy(c=>"Cannot serialize Redacted"+(de(c)&&typeof c.value.label=="string"?` with label: "${c.value.label}"`:"")):Ie(oc)}),toEquivalence:([a])=>e1(a)});return J(i.ast,{value:e})}function zte(e,t){return ee(Qj(oo(e),{label:t?.label,disallowJsonEncode:t?.disallowEncode}),{decode:Ie(r=>Mu(r,{label:t?.label})),encode:t?.disallowEncode?jy(r=>"Cannot encode Redacted"+(de(r)&&typeof r.value.label=="string"?` with label: "${r.value.label}"`:"")):Ie(oc)})(e)}function Wte(e,t){let r=Ar()([e,t],([n,o])=>(s,i,a)=>{if(!$f(s))return D(new at(i,s,a));switch(s._tag){case"Success":return cr(Xv(n)(s.success,a),{onSuccess:X,onFailure:c=>tn(i,"success",c,s,a)});case"Failure":return cr(Xv(o)(s.failure,a),{onSuccess:re,onFailure:c=>tn(i,"failure",c,s,a)})}},{representation:{id:"effect/schema/Result",payload:null},toCode:({typeParameters:n})=>({runtime:`Schema.Result(${n[0].runtime}, ${n[1].runtime})`,Type:`Result.Result<${n[0].Type}, ${n[1].Type}>`,importDeclarations:['import * as Result from "effect/Result"']}),expected:"Result",toCodec:([n,o])=>Ne()(Pe([Te({_tag:fr("Success"),success:n}),Te({_tag:fr("Failure"),failure:o})]),Fe({decode:s=>s._tag==="Success"?X(s.success):re(s.failure),encode:s=>tt(s)?{_tag:"Success",success:s.success}:{_tag:"Failure",failure:s.failure}}))});return J(r.ast,{success:e,failure:t})}var Kte=globalThis.Symbol.for("immer-draftable"),rC={};function IC(e,t,r,n,o){let s=Gte(r,t,n),i=Yj(t),a=class extends e{constructor(...[c,u]){let p=u?.["~payload"],m=p?.token===rC?p.value:r.make(c??{},u);super(m,{...u,disableChecks:!0,"~payload":{token:rC,value:m}})}static[Vm]=Vm;get[i](){return i}static[Kte]=!0;static identifier=t;static fields=r.fields;static get ast(){return s(this).ast}static pipe(){return V(this,arguments)}static rebuild(c){return s(this).rebuild(c)}static make(c,u){return pS(s(this))(c??{},u)}static makeOption(c,u){return dS(s(this))(c??{},u)}static makeEffect(c,u){return s(this).makeEffect(c??{},u)}static annotate(c){return this.rebuild(Fs(this.ast,c))}static annotateKey(c){return this.rebuild(Wl(this.ast,c))}static check(...c){return this.rebuild(Pi(this.ast,c))}static extend(c){return(u,f)=>{let p=ah(u)?u:Te(u),m={...r.fields,...p.fields},h=eS(m,r.ast.checks,{identifier:c});return IC(this,c,aC(Pi(h,p.ast.checks),m),f,o)}}static mapFields(c,u){return r.mapFields(c,u)}};return o!==void 0&&Object.assign(a.prototype,o(t)),a}function Vte(e){return new et(Ie(t=>new e(t,{"~payload":{token:rC,value:t}})),Oi())}function Yj(e){return`~effect/Schema/Class/${e}`}function Gte(e,t,r){let n;return o=>{if(n!==void 0)return n;let s=Yj(t),i=u=>u instanceof o||O(u,s),a=Vte(o),c=J(new fc([e.ast],()=>(u,f,p)=>i(u)?I(u):D(new at(f,u,p)),{identifier:t,[By]:([u])=>({isConstructed:i,link:new jt(u,a)}),toCodec:([u])=>new jt(u.ast,a),toEquivalence:([u])=>u,toFormatter:([u])=>f=>`${o.identifier}(${u(f)})`,[dm]:cc(e.ast),...r}));return n=ee(c,a)(e)}}function ah(e){return Zu(e)}var YS=e=>(t,r)=>{let n=ah(t)?t:Te(t);return IC(SP,e,n,r,o=>({toString(){return`${o}(${H({...this})})`}}))},Jte=e=>(t,r,n)=>{let o=ah(r)?r.mapFields(s=>({_tag:He(t),...s}),{unsafePreserveChecks:!0}):ya(t,r);return YS(e??t)(o,n)},Cr=e=>(t,r)=>{let n=ah(t)?t:Te(t);return IC(Xd,e,n,r,s=>({name:s}))},TC=e=>(t,r,n)=>{let o=ah(r)?r.mapFields(s=>({_tag:He(t),...s}),{unsafePreserveChecks:!0}):ya(t,r);return Cr(e??t)(o,n)};function Zte(e){return t=>t.annotate({toFormatter:e})}function Qte(e,t){return xB(e.ast,t)}function Yte(e){return t=>t.annotate({toEquivalence:e})}function Xte(e){return xA(e.ast)}function ere(e,t){return Fm(e.ast,t)}function tre(e,t){let r=Fm(Zl(e.ast),t);return TS(r,t)}var nf=yS,rre=SS,nre=bS,ore=WL;function sre(e,t){return lB(e,t)}function ire(e){return TB(e)}function are(e){return wB(e)}function cre(e){return vB(e)}function ure(e,t){return r=>J(Fs(r.ast,{toCodecIso:()=>new jt(e.ast,Vy(t))}),{schema:r})}function fre(e){return fB(e)}function lre(e){let t=v$(()=>r),r=Pe([e,ct(t),Yu(z,t)]);return r}var XS=J(Fs($l,{toCode:()=>({runtime:"Schema.Json",Type:"Schema.Json"})})),dre=Yu(z,XS),pre=Te({message:z,name:Ju(z),stack:Ju(z),cause:Ju(XS)}),mre=J(Fs(aL,{toCode:()=>({runtime:"Schema.MutableJson",Type:"Schema.MutableJson"})}));function hre(e){return da(e.ast)}function xre(e){return e.ast.context?.annotations}var Xj=IT;var Ec=Xx,eb=GP,Tn=xp;var os=ea,Ni=jF;var jr=s0,eH=GF;var tH="~effect/MutableRef",gre={[tH]:tH,...wr,toJSON(){return{_id:"MutableRef",current:pr(this.current)}}},xd=e=>{let t=Object.create(gre);return t.current=e,t};var rH=e=>e.current;var tb=d(2,(e,t)=>(e.current=t,e));var Hr=Symbol.for("effect/MutableList/Empty"),Ta=()=>({head:void 0,tail:void 0,length:0}),vC=e=>{let t=e.head;t.offset>=1024&&t===e.tail&&t.mutable&&(t.array.length-t.offset)*8<=t.offset&&(e.head=e.tail={array:t.array.slice(t.offset),mutable:!0,offset:0,next:void 0})},nH=()=>({array:[],mutable:!0,offset:0,next:void 0}),zs=(e,t)=>{e.tail?e.tail.mutable||(e.tail.next=nH(),e.tail=e.tail.next):e.head=e.tail=nH(),e.tail.array.push(t),e.length++},AC=(e,t)=>{e.head={array:[t],mutable:!0,offset:0,next:e.head},e.tail||(e.tail=e.head),e.length++};var rb=(e,t)=>nb(e,At(t),!Array.isArray(t)),nb=(e,t,r=!1)=>{if(t.length===0)return 0;let n={array:t,mutable:r,offset:0,next:void 0};return e.head?e.tail=e.tail.next=n:e.head=e.tail=n,e.length+=t.length,t.length},Ia=e=>{e.head=e.tail=void 0,e.length=0},of=(e,t)=>{if(t=Bt(t),t<=0||!e.head)return[];if(t=Math.min(t,e.length),t===e.length&&e.head?.offset===0&&!e.head.next){let s=e.head.array;return Ia(e),s}let r=new Array(t),n=0,o=e.head;for(;o;){for(;o.offset<o.array.length;)if(r[n++]=o.array[o.offset],o.mutable&&(o.array[o.offset]=void 0),o.offset++,n===t)return e.head=o.offset===o.array.length&&o.next?o.next:o,e.length-=t,e.length===0?Ia(e):vC(e),r;o=o.next}return Ia(e),r},ob=(e,t)=>{if(t=Bt(t),t<=0||!e.head)return;if(t=Math.min(t,e.length),t===e.length&&e.head?.offset===0&&!e.head.next){Ia(e);return}let r=0,n=e.head;for(;n;){let o=n.array.length-n.offset;if(r+o>t){n.offset+=t-r,e.head=n,e.length-=t,vC(e);return}r+=o,n=n.next}Ia(e)},Ic=e=>of(e,e.length),sf=e=>{if(!e.head)return Hr;let t=e.head.array[e.head.offset];return e.head.mutable&&(e.head.array[e.head.offset]=void 0),e.head.offset++,e.length--,e.head.offset===e.head.array.length?e.head.next?e.head=e.head.next:Ia(e):vC(e),t},oH=(e,t)=>{if(t=Bt(t),t<=0)return[];let r=Math.min(t,e.length),n=new Array(r),o=0,s=e.head;for(;s;){for(let i=s.offset;i<s.array.length;i++)if(n[o++]=s.array[i],o===r)return n;s=s.next}return n};var CC=(e,t)=>{let r=[],n=e.head,o=0;for(;n;){for(let s=n.offset;s<n.array.length;s++)t(n.array[s],o++)&&r.push(n.array[s]);n=n.next}if(r.length===0){Ia(e);return}e.head=e.tail={array:r,mutable:!0,offset:0,next:void 0},e.length=r.length},sH=(e,t)=>CC(e,r=>r!==t);var yre="~effect/PubSub";var Sre="~effect/PubSub/Subscription",ub=e=>W(()=>vre(e.atomicPubSub(),new Map,Zn(),jr(!1),xd(!1),e.strategy(),xd(_()))),fb=e=>ub({atomicPubSub:()=>BC(e),strategy:()=>new ib}),lb=e=>ub({atomicPubSub:()=>BC(e),strategy:()=>new ab}),db=e=>ub({atomicPubSub:()=>BC(e),strategy:()=>new LC}),uh=e=>ub({atomicPubSub:()=>iH(e),strategy:()=>new ab}),BC=e=>{let t=typeof e=="number"?{capacity:e}:e;if(Are(t.capacity),t.capacity===1/0)return iH(t);let r=t.replay&&t.replay>0?new cb(Math.ceil(t.replay)):void 0;return t.capacity===1?new PC(r):cU(t.capacity)===t.capacity?new OC(t.capacity,r):new kC(t.capacity,r)},iH=e=>{let t=e?.replay;return new FC(t&&t>0?new cb(Math.ceil(t)):void 0)};var fh=e=>Ai(ar(t=>(tb(e.shutdownFlag,!0),Ve(e.scope,Lg(t.id)).pipe(Vt(e.strategy.shutdown),fy(e.shutdownHook.open),vo)))),pb=d(2,(e,t)=>W(()=>bre(e,t))),bre=d(2,(e,t)=>{if(e.shutdownFlag.current||de(e.ended.current))return!1;if(tb(e.ended,N(t)),e.strategy instanceof ib)for(let[n,o,s]of Ic(e.strategy.publishers))s&&hi(o,Mr(!1));let r=Mr(t);for(let n of e.subscribers.values())for(let o of n){let s;for(;(s=sf(o))!==Hr;)hi(s,r)}return e.subscribers.clear(),!0});var mb=d(2,(e,t)=>L(()=>e.shutdownFlag.current||de(e.ended.current)?I(!1):e.pubsub.publish(t)?(e.strategy.completeSubscribersUnsafe(e.pubsub,e.subscribers),I(!0)):e.strategy.handleSurplus(e.pubsub,e.subscribers,[t],e.shutdownFlag,e.ended))),aH=d(2,(e,t)=>e.shutdownFlag.current||de(e.ended.current)?!1:e.pubsub.publish(t)?(e.strategy.completeSubscribersUnsafe(e.pubsub,e.subscribers),!0):!1),cH=d(2,(e,t)=>L(()=>{if(e.shutdownFlag.current||de(e.ended.current))return I(!1);let r=e.pubsub.publishAll(t);return e.strategy.completeSubscribersUnsafe(e.pubsub,e.subscribers),r.length===0?I(!0):e.strategy.handleSurplus(e.pubsub,e.subscribers,r,e.shutdownFlag,e.ended)})),lh=e=>Ai(yn(t=>{let r=Re(t,it),n=yr(e.scope),o=wre(e.pubsub,e.subscribers,e.strategy,e.ended);return It(n,Ere(o)).pipe(Vt(Wo(r,s=>Ve(n,s))),Pt(o))})),Ere=e=>Ai(ar(t=>(tb(e.shutdownFlag,!0),Ko(Ic(e.pollers),r=>f0(r,t.id),{discard:!0,concurrency:"unbounded"}).pipe(_t(()=>W(()=>{e.subscribers.delete(e.subscription),e.subscription.unsubscribe(),e.replayWindow.close(),e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers)})),fy(e.shutdownHook.open),vo)))),hb=e=>L(()=>{if(e.shutdownFlag.current)return Dn;if(e.replayWindow.remaining>0){let r=e.replayWindow.take();return I(r)}let t=e.pollers.length===0?e.subscription.poll():Hr;return t===Hr?fH(e):(e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers),I(t))}),uH=e=>L(function t(r){if(e.shutdownFlag.current)return Dn;let n=e.pollers.length===0?e.subscription.pollUpTo(Number.POSITIVE_INFINITY):[];return r&&(n=r.concat(n)),e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers),e.replayWindow.remaining>0?I(e.replayWindow.takeAll().concat(n)):Gr(n)?I(n):C(fH(e),o=>t([o]))}),fH=e=>Nn(t=>{if(e.shutdownFlag.current)return t(Dn);if(de(e.ended.current)){let o=e.pollers.length===0?e.subscription.poll():Hr;return o!==Hr?(e.strategy.onPubSubEmptySpaceUnsafe(e.pubsub,e.subscribers),t(I(o))):t(I(e.ended.current.value))}let r=du(),n=e.subscribers.get(e.subscription);return n||(n=new Set,e.subscribers.set(e.subscription,n)),n.add(e.pollers),zs(e.pollers,r),e.strategy.completePollersUnsafe(e.pubsub,e.subscribers,e.subscription,e.pollers),r.effect?t(r.effect):(r.resumes=[t],W(()=>sH(e.pollers,r)))});var tr=Symbol.for("effect/PubSub/AbsentValue"),Ire=(e,t,r)=>{e.has(t)||e.set(t,new Set),e.get(t).add(r)},Tre=(e,t,r)=>{if(!e.has(t))return;let n=e.get(t);n.delete(r),n.size===0&&e.delete(t)},wre=(e,t,r,n)=>new UC(e,t,e.subscribe(),Ta(),jr(!1),xd(!1),r,e.replayWindow(),n),kC=class{array;replayIndices;publisherIndex=0;subscribers;subscriberCount=0;subscribersIndex=0;capacity;replayBuffer;constructor(t,r){this.capacity=t,this.replayBuffer=r,this.array=Array.from({length:t}),this.replayIndices=r?Array.from({length:t}):[],this.subscribers=Array.from({length:t})}replayWindow(){return this.replayBuffer?new gd(this.replayBuffer):xb}isEmpty(){return this.publisherIndex===this.subscribersIndex}isFull(){return this.publisherIndex===this.subscribersIndex+this.capacity}size(){return this.publisherIndex-this.subscribersIndex}publish(t){if(this.isFull())return!1;let r=this.replayBuffer?.offer(t);if(this.subscriberCount!==0){let n=this.publisherIndex%this.capacity;this.array[n]=t,r!==void 0&&(this.replayIndices[n]=r),this.subscribers[n]=this.subscriberCount,this.publisherIndex+=1}return!0}publishAll(t){if(this.subscriberCount===0)return this.replayBuffer&&this.replayBuffer.offerAll(t),[];let r=At(t),n=r.length,o=this.publisherIndex-this.subscribersIndex,s=this.capacity-o,i=Math.min(n,s);if(i===0)return r;let a=0,c=this.publisherIndex+i;for(;this.publisherIndex!==c;){let u=r[a++],f=this.publisherIndex%this.capacity;this.array[f]=u;let p=this.replayBuffer?.offer(u);p!==void 0&&(this.replayIndices[f]=p),this.subscribers[f]=this.subscriberCount,this.publisherIndex+=1}return r.slice(a)}slide(){if(this.subscribersIndex!==this.publisherIndex){let t=this.subscribersIndex%this.capacity,r=this.array[t];this.array[t]=tr,this.subscribers[t]=0,this.subscribersIndex+=1,this.replayBuffer?.slide(r,this.replayIndices[t])}}subscribe(){return this.subscriberCount+=1,new RC(this,this.publisherIndex,!1)}},RC=class{self;subscriberIndex;unsubscribed;constructor(t,r,n){this.self=t,this.subscriberIndex=r,this.unsubscribed=n}isEmpty(){return this.unsubscribed||this.self.publisherIndex===this.subscriberIndex||this.self.publisherIndex===this.self.subscribersIndex}size(){return this.unsubscribed?0:this.self.publisherIndex-Math.max(this.subscriberIndex,this.self.subscribersIndex)}poll(){if(this.unsubscribed)return Hr;if(this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex),this.subscriberIndex!==this.self.publisherIndex){let t=this.subscriberIndex%this.self.capacity,r=this.self.array[t];return this.self.subscribers[t]-=1,this.self.subscribers[t]===0&&(this.self.array[t]=tr,this.self.subscribersIndex+=1),this.subscriberIndex+=1,r}return Hr}pollUpTo(t){if(t=Bt(t),this.unsubscribed)return[];this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex);let r=this.self.publisherIndex-this.subscriberIndex,n=Math.min(t,r);if(n<=0)return[];let o=[],s=this.subscriberIndex+n;for(;this.subscriberIndex!==s;){let i=this.subscriberIndex%this.self.capacity,a=this.self.array[i];this.self.subscribers[i]-=1,this.self.subscribers[i]===0&&(this.self.array[i]=tr,this.self.subscribersIndex+=1),o.push(a),this.subscriberIndex+=1}return o}unsubscribe(){if(!this.unsubscribed)for(this.unsubscribed=!0,this.self.subscriberCount-=1,this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex);this.subscriberIndex!==this.self.publisherIndex;){let t=this.subscriberIndex%this.self.capacity;this.self.subscribers[t]-=1,this.self.subscribers[t]===0&&(this.self.array[t]=tr,this.self.subscribersIndex+=1),this.subscriberIndex+=1}}},OC=class{array;replayIndices;mask;publisherIndex=0;subscribers;subscriberCount=0;subscribersIndex=0;capacity;replayBuffer;constructor(t,r){this.capacity=t,this.replayBuffer=r,this.array=Array.from({length:t}),this.replayIndices=r?Array.from({length:t}):[],this.mask=t-1,this.subscribers=Array.from({length:t})}replayWindow(){return this.replayBuffer?new gd(this.replayBuffer):xb}isEmpty(){return this.publisherIndex===this.subscribersIndex}isFull(){return this.publisherIndex===this.subscribersIndex+this.capacity}size(){return this.publisherIndex-this.subscribersIndex}publish(t){if(this.isFull())return!1;let r=this.replayBuffer?.offer(t);if(this.subscriberCount!==0){let n=this.publisherIndex&this.mask;this.array[n]=t,r!==void 0&&(this.replayIndices[n]=r),this.subscribers[n]=this.subscriberCount,this.publisherIndex+=1}return!0}publishAll(t){if(this.subscriberCount===0)return this.replayBuffer&&this.replayBuffer.offerAll(t),[];let r=At(t),n=r.length,o=this.publisherIndex-this.subscribersIndex,s=this.capacity-o,i=Math.min(n,s);if(i===0)return r;let a=0,c=this.publisherIndex+i;for(;this.publisherIndex!==c;){let u=r[a++],f=this.publisherIndex&this.mask;this.array[f]=u;let p=this.replayBuffer?.offer(u);p!==void 0&&(this.replayIndices[f]=p),this.subscribers[f]=this.subscriberCount,this.publisherIndex+=1}return r.slice(a)}slide(){if(this.subscribersIndex!==this.publisherIndex){let t=this.subscribersIndex&this.mask,r=this.array[t];this.array[t]=tr,this.subscribers[t]=0,this.subscribersIndex+=1,this.replayBuffer?.slide(r,this.replayIndices[t])}}subscribe(){return this.subscriberCount+=1,new _C(this,this.publisherIndex,!1)}},_C=class{self;subscriberIndex;unsubscribed;constructor(t,r,n){this.self=t,this.subscriberIndex=r,this.unsubscribed=n}isEmpty(){return this.unsubscribed||this.self.publisherIndex===this.subscriberIndex||this.self.publisherIndex===this.self.subscribersIndex}size(){return this.unsubscribed?0:this.self.publisherIndex-Math.max(this.subscriberIndex,this.self.subscribersIndex)}poll(){if(this.unsubscribed)return Hr;if(this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex),this.subscriberIndex!==this.self.publisherIndex){let t=this.subscriberIndex&this.self.mask,r=this.self.array[t];return this.self.subscribers[t]-=1,this.self.subscribers[t]===0&&(this.self.array[t]=tr,this.self.subscribersIndex+=1),this.subscriberIndex+=1,r}return Hr}pollUpTo(t){if(t=Bt(t),this.unsubscribed)return[];this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex);let r=this.self.publisherIndex-this.subscriberIndex,n=Math.min(t,r);if(n<=0)return[];let o=[],s=this.subscriberIndex+n;for(;this.subscriberIndex!==s;){let i=this.subscriberIndex&this.self.mask,a=this.self.array[i];this.self.subscribers[i]-=1,this.self.subscribers[i]===0&&(this.self.array[i]=tr,this.self.subscribersIndex+=1),o.push(a),this.subscriberIndex+=1}return o}unsubscribe(){if(!this.unsubscribed)for(this.unsubscribed=!0,this.self.subscriberCount-=1,this.subscriberIndex=Math.max(this.subscriberIndex,this.self.subscribersIndex);this.subscriberIndex!==this.self.publisherIndex;){let t=this.subscriberIndex&this.self.mask;this.self.subscribers[t]-=1,this.self.subscribers[t]===0&&(this.self.array[t]=tr,this.self.subscribersIndex+=1),this.subscriberIndex+=1}}},PC=class{publisherIndex=0;subscriberCount=0;subscribers=0;value=tr;replayIndex=0;capacity=1;replayBuffer;constructor(t){this.replayBuffer=t}replayWindow(){return this.replayBuffer?new gd(this.replayBuffer):xb}pipe(){return V(this,arguments)}isEmpty(){return this.subscribers===0}isFull(){return!this.isEmpty()}size(){return this.isEmpty()?0:1}publish(t){if(this.isFull())return!1;let r=this.replayBuffer?.offer(t);return this.subscriberCount!==0&&(this.value=t,r!==void 0&&(this.replayIndex=r),this.subscribers=this.subscriberCount,this.publisherIndex+=1),!0}publishAll(t){if(this.subscriberCount===0)return this.replayBuffer&&this.replayBuffer.offerAll(t),[];let r=At(t);return r.length===0?r:this.publish(r[0])?r.slice(1):r}slide(){if(this.isFull()){let t=this.value;this.subscribers=0,this.value=tr,this.replayBuffer?.slide(t,this.replayIndex)}}subscribe(){return this.subscriberCount+=1,new MC(this,this.publisherIndex,!1)}},MC=class{self;subscriberIndex;unsubscribed;constructor(t,r,n){this.self=t,this.subscriberIndex=r,this.unsubscribed=n}isEmpty(){return this.unsubscribed||this.self.subscribers===0||this.subscriberIndex===this.self.publisherIndex}size(){return this.isEmpty()?0:1}poll(){if(this.isEmpty())return Hr;let t=this.self.value;return this.self.subscribers-=1,this.self.subscribers===0&&(this.self.value=tr),this.subscriberIndex=this.self.publisherIndex,t}pollUpTo(t){return Bt(t)<1||this.isEmpty()?[]:[this.poll()]}unsubscribe(){this.unsubscribed||(this.unsubscribed=!0,this.self.subscriberCount-=1,this.self.subscribers!==0&&this.subscriberIndex!==this.self.publisherIndex&&(this.self.subscribers-=1,this.self.subscribers===0&&(this.self.value=tr)))}},FC=class{publisherHead={value:tr,replayIndex:void 0,subscribers:0,next:null};publisherTail=this.publisherHead;publisherIndex=0;subscribersIndex=0;capacity=Number.MAX_SAFE_INTEGER;replayBuffer;constructor(t){this.replayBuffer=t}replayWindow(){return this.replayBuffer?new gd(this.replayBuffer):xb}isEmpty(){return this.publisherHead===this.publisherTail}isFull(){return!1}size(){return this.publisherIndex-this.subscribersIndex}publish(t){let r=this.replayBuffer?.offer(t),n=this.publisherTail.subscribers;if(n!==0){let o={value:t,replayIndex:r,subscribers:n,next:null};this.publisherTail.next=o,this.publisherTail=this.publisherTail.next,this.publisherIndex+=1}return!0}publishAll(t){if(this.publisherTail.subscribers!==0)for(let r of t)this.publish(r);else this.replayBuffer&&this.replayBuffer.offerAll(t);return[]}slide(){if(this.publisherHead!==this.publisherTail){let t=this.publisherHead.next,r=t.value;this.publisherHead=this.publisherHead.next,this.publisherHead.value=tr,this.subscribersIndex+=1,this.replayBuffer?.slide(r,t.replayIndex)}}subscribe(){return this.publisherTail.subscribers+=1,new NC(this,this.publisherTail,this.publisherIndex,!1)}},NC=class{self;subscriberHead;subscriberIndex;unsubscribed;constructor(t,r,n,o){this.self=t,this.subscriberHead=r,this.subscriberIndex=n,this.unsubscribed=o}isEmpty(){if(this.unsubscribed)return!0;let t=!0,r=!0;for(;r;)this.subscriberHead===this.self.publisherTail?r=!1:this.subscriberHead.next.value!==tr?(t=!1,r=!1):(this.subscriberHead=this.subscriberHead.next,this.subscriberIndex+=1);return t}size(){return this.unsubscribed?0:this.self.publisherIndex-Math.max(this.subscriberIndex,this.self.subscribersIndex)}poll(){if(this.unsubscribed)return Hr;let t=!0,r=Hr;for(;t;)if(this.subscriberHead===this.self.publisherTail)t=!1;else{let n=this.subscriberHead.next.value;n!==tr&&(r=n,this.subscriberHead.subscribers-=1,this.subscriberHead.subscribers===0&&(this.self.publisherHead=this.self.publisherHead.next,this.self.publisherHead.value=tr,this.self.subscribersIndex+=1),t=!1),this.subscriberHead=this.subscriberHead.next,this.subscriberIndex+=1}return r}pollUpTo(t){t=Bt(t);let r=[],n=0;for(;n!==t;){let o=this.poll();o===Hr?n=t:(r.push(o),n+=1)}return r}unsubscribe(){if(!this.unsubscribed)for(this.unsubscribed=!0,this.self.publisherTail.subscribers-=1;this.subscriberHead!==this.self.publisherTail;)this.subscriberHead.next.value!==tr&&(this.subscriberHead.subscribers-=1,this.subscriberHead.subscribers===0&&(this.self.publisherHead=this.self.publisherHead.next,this.self.publisherHead.value=tr,this.self.subscribersIndex+=1)),this.subscriberHead=this.subscriberHead.next}},UC=class{[Sre]={_A:F};pubsub;subscribers;subscription;pollers;shutdownHook;shutdownFlag;strategy;replayWindow;ended;constructor(t,r,n,o,s,i,a,c,u){this.pubsub=t,this.subscribers=r,this.subscription=n,this.pollers=o,this.shutdownHook=s,this.shutdownFlag=i,this.strategy=a,this.replayWindow=c,this.ended=u}pipe(){return V(this,arguments)}},DC=class{[yre]={_A:F};pubsub;subscribers;scope;shutdownHook;shutdownFlag;strategy;ended;constructor(t,r,n,o,s,i,a){this.pubsub=t,this.subscribers=r,this.scope=n,this.shutdownHook=o,this.shutdownFlag=s,this.strategy=i,this.ended=a}pipe(){return V(this,arguments)}},vre=(e,t,r,n,o,s,i)=>new DC(e,t,r,n,o,s,i),Are=e=>{if(e<=0||e!==1/0&&!Number.isInteger(e))throw new Error(`Cannot construct PubSub with capacity of ${e}`)},ib=class{publishers=Ta();get shutdown(){return ar(t=>Ko(Ic(this.publishers),([r,n,o])=>o?f0(n,t.id):P,{concurrency:"unbounded",discard:!0}))}handleSurplus(t,r,n,o,s){return Nn(i=>{if(de(s.current))return i(I(!1));let a=du();return this.offerUnsafe(n,a),this.onPubSubEmptySpaceUnsafe(t,r),this.completeSubscribersUnsafe(t,r),rH(o)?(this.removeUnsafe(a),i(Dn)):a.effect?i(a.effect):(a.resumes=[i],W(()=>this.removeUnsafe(a)))})}onPubSubEmptySpaceUnsafe(t,r){let n=!0;for(;n&&!t.isFull();){let o=sf(this.publishers);if(o===Hr)n=!1;else{let[s,i]=o,a=t.publish(s);a&&o[2]?hi(i,Mr(!0)):a||AC(this.publishers,o),this.completeSubscribersUnsafe(t,r)}}}completePollersUnsafe(t,r,n,o){return $C(this,t,r,n,o)}completeSubscribersUnsafe(t,r){return jC(this,t,r)}offerUnsafe(t,r){let n=t[Symbol.iterator](),o=n.next();if(!o.done)for(;;){let s=o.value;if(o=n.next(),o.done){zs(this.publishers,[s,r,!0]);break}zs(this.publishers,[s,r,!1])}}removeUnsafe(t){CC(this.publishers,([r,n])=>n!==t)}},ab=class{get shutdown(){return P}handleSurplus(t,r,n,o){return I(!1)}onPubSubEmptySpaceUnsafe(t,r){}completePollersUnsafe(t,r,n,o){return $C(this,t,r,n,o)}completeSubscribersUnsafe(t,r){return jC(this,t,r)}},LC=class{get shutdown(){return P}handleSurplus(t,r,n,o,s){return W(()=>de(s.current)?!1:(this.slidingPublishUnsafe(t,n),this.completeSubscribersUnsafe(t,r),!0))}onPubSubEmptySpaceUnsafe(t,r){}completePollersUnsafe(t,r,n,o){return $C(this,t,r,n,o)}completeSubscribersUnsafe(t,r){return jC(this,t,r)}slidingPublishUnsafe(t,r){let n=r[Symbol.iterator](),o=n.next();if(!o.done&&t.capacity>0){let s=o.value,i=!0;for(;i;){t.slide();let a=t.publish(s);a&&(o=n.next())&&!o.done?s=o.value:a&&(i=!1)}}}},$C=(e,t,r,n,o)=>{let s=!0;for(;s&&!n.isEmpty();){let i=sf(o);if(i===Hr)Tre(r,n,o),o.length===0?s=!1:Ire(r,n,o);else{let a=n.poll();a===Hr?AC(o,i):(hi(i,Mr(a)),e.onPubSubEmptySpaceUnsafe(t,r))}}},jC=(e,t,r)=>{for(let[n,o]of r)for(let s of o)e.completePollersUnsafe(t,r,n,s)},cb=class{capacity;head={value:tr,index:0,next:null};tail=this.head;slideValues=[];size=0;index=0;publisherIndex=0;constructor(t){this.capacity=t}slide(t,r){this.slideValues[this.index%this.capacity]={value:t,index:r},this.index++}offer(t){let r=this.publisherIndex++;return this.tail.value=t,this.tail.index=r,this.tail.next={value:tr,index:0,next:null},this.tail=this.tail.next,this.size===this.capacity?this.head=this.head.next:this.size+=1,r}offerAll(t){for(let r of t)this.offer(r)}},gd=class{buffer;values;index=0;remaining;slideIndex;newestIndex=-1;constructor(t){this.buffer=t,this.remaining=t.size,this.slideIndex=t.index,this.values=new Array(this.remaining);let r=t.head;for(let n=0;n<this.remaining;n++)this.values[n]=r.value,this.newestIndex=r.index,r=r.next}close(){this.values.length=0,this.remaining=0}sync(){let t=this.buffer.index-this.slideIndex;if(t===0||this.remaining===0)return;let r=Math.min(t,this.buffer.capacity),n=this.buffer.index-r;for(let o=0;o<r;o++){let s=this.buffer.slideValues[(n+o)%this.buffer.capacity];s.index>this.newestIndex&&(this.index=(this.index+1)%this.values.length,this.values[(this.index+this.remaining-1)%this.values.length]=s.value,this.newestIndex=s.index)}this.slideIndex=this.buffer.index}take(){if(this.remaining===0)return;this.sync();let t=this.values[this.index];return this.values[this.index]=tr,this.index=(this.index+1)%this.values.length,this.remaining--,this.remaining===0&&this.close(),t}takeN(t){t=Bt(t);let r=Math.min(t,this.remaining),n=new Array(r);for(let o=0;o<r;o++)n[o]=this.take();return n}takeAll(){return this.takeN(this.remaining)}},xb={remaining:0,take:()=>{},takeN:()=>[],takeAll:()=>[],close:()=>{}};var Cre="~effect/Queue",kre="~effect/Queue/Enqueue",Rre="~effect/Queue/Dequeue";var HC={_A:F,_E:F},Ore={[Cre]:HC,[kre]:HC,[Rre]:HC,...wr,toJSON(){return{_id:"effect/Queue",state:this.state._tag,size:Pre(this)}}},io=e=>oe(t=>{let r=Object.create(Ore);return r.dispatcher=t.currentDispatcher,r.capacity=e?.capacity??Number.POSITIVE_INFINITY,r.strategy=e?.strategy??"suspend",r.messages=Ta(),r.scheduleRunning=!1,r.state={_tag:"Open",takers:new Set,offers:new Set,awaiters:new Set},q(r)}),af=e=>io({capacity:e});var Sb=()=>io(),jn=d(2,(e,t)=>ce(()=>Tc(e,t)?Ib:e.state._tag==="Open"&&e.strategy==="suspend"?Ure(e,t):dH)),Tc=(e,t)=>e.state._tag!=="Open"?!1:e.messages.length>=e.capacity?e.strategy==="sliding"?(sf(e.messages),zs(e.messages,t),!0):e.capacity<=0&&e.state.takers.size>0?(zs(e.messages,t),pH(e),!0):!1:(zs(e.messages,t),yb(e),!0),wa=d(2,(e,t)=>$t(r=>{let n=bb(e,t);return n.length===0||e.strategy==="dropping"?r(ze(n)):xH(e,{_tag:"Array",remaining:n,offset:0,resume:r})})),bb=(e,t)=>{if(e.state._tag!=="Open")return At(t);if(e.capacity===Number.POSITIVE_INFINITY||e.strategy==="sliding")return rb(e.messages,t),e.strategy==="sliding"&&of(e.messages,e.messages.length-e.capacity),yb(e),[];let r=e.capacity<=0?e.state.takers.size:e.capacity-e.messages.length;if(r===0)return At(t);let n=[],o=0;for(let s of t)o<r?zs(e.messages,s):n.push(s),o++;return yb(e),n};var Ht=d(2,(e,t)=>ye(()=>Ui(e,t))),Ui=(e,t)=>{if(e.state._tag!=="Open")return!1;let r=Pr(t),n=wM(r,Mre);return e.state.offers.size===0&&e.messages.length===0?(Tb(e,n),!0):(e.state={...e.state,_tag:"Closing",exit:n},yb(e),!0)},yd=e=>Ht(e,Mf(Qc())),Eb=e=>Ui(e,Mf(Qc()));var ss=e=>ye(()=>zC(e)),zC=e=>{if(e.state._tag==="Done")return!1;Ia(e.messages);let t=e.state.offers;Tb(e,e.state._tag==="Open"?Fre:e.state.exit);for(let r of t)gH(r);return!0};var cf=e=>lH(e,1,Number.POSITIVE_INFINITY);var lH=d(3,(e,t,r)=>(t=Bt(t),r=Bt(r),mH(()=>Nre(e,t,r)??bo(hH(e,()=>WC(e,t)),lH(e,t,r))))),Ws=e=>mH(()=>_re(e)??bo(hH(e,()=>WC(e,1)),Ws(e)));var _re=e=>{if(e.state._tag==="Done")return e.state.exit;if(e.messages.length>0){let t=sf(e.messages);return qC(e),ze(t)}else if(e.capacity<=0&&e.state.offers.size>0){let t=yH(e.state.offers);return qC(e),ze(t)}};var Pre=e=>e.state._tag==="Done"?0:e.messages.length;var dH=ze(!1),Ib=ze(!0),Mre=So(Qc()),Fre=Zf(),pH=e=>{if(!(e.state._tag==="Done"||e.state.takers.size===0)){for(let t of e.state.takers)if(t.ready()&&(e.state.takers.delete(t),t.resume(hn),e.messages.length===0))break}},yb=e=>{e.scheduleRunning||e.state._tag==="Done"||e.state.takers.size===0||(e.scheduleRunning=!0,e.dispatcher.scheduleTask(()=>{e.scheduleRunning=!1,pH(e)},0))},Nre=(e,t,r)=>{if(e.state._tag==="Done")return e.state.exit;if(r<=0||t<=0)return ze([]);if(!WC(e,t))return;let n=e.messages.length>0?of(e.messages,r):[yH(e.state.offers)];return qC(e),ze(n)},mH=Uo({op:"QueueTake",[St](e){let t=this[Se]();return Gd(t)?t[St](e):t}}),WC=(e,t)=>e.messages.length>=(e.state._tag==="Closing"?1:Math.min(t,e.capacity||1))||e.capacity<=0&&e.state._tag!=="Done"&&e.state.offers.size>0,hH=(e,t)=>$t(r=>{if(e.state._tag==="Done")return r(e.state.exit);if(t())return r(hn);let n={ready:t,resume:r};return e.state.takers.add(n),ye(()=>{e.state._tag!=="Done"&&e.state.takers.delete(n)})}),Ure=(e,t)=>$t(r=>Tc(e,t)?r(Ib):xH(e,{_tag:"Single",message:t,resume:r})),xH=(e,t)=>{if(e.state._tag!=="Open")return gH(t);let r=e.state.offers;return r.add(t),ye(()=>{e.state._tag!=="Done"&&(r.delete(t),e.state._tag==="Closing"&&r.size===0&&e.messages.length===0&&Tb(e,e.state.exit))})},gH=e=>e._tag==="Single"?e.resume(dH):e.resume(ze(e.remaining.slice(e.offset))),yH=e=>{let t=e.values().next().value;if(t._tag==="Single")return e.delete(t),t.resume(Ib),t.message;let r=t.remaining[t.offset++];return t.offset===t.remaining.length&&(e.delete(t),t.resume(ze([]))),r},qC=e=>{if(e.state._tag==="Done")return wo(e.state.exit.cause);if(e.state.offers.size===0)return e.state._tag==="Closing"&&e.messages.length===0?(Tb(e,e.state.exit),wo(e.state.exit.cause)):!1;for(let t of e.state.offers){let r=e.capacity-e.messages.length;if(r<=0)break;if(t._tag==="Single")zs(e.messages,t.message),e.state.offers.delete(t),t.resume(Ib);else{for(;t.offset<t.remaining.length;t.offset++){if(r===0)return!1;zs(e.messages,t.remaining[t.offset]),r--}e.state.offers.delete(t),t.resume(ze([]))}let n=e.state;if(n._tag==="Done")return wo(n.exit.cause)}return!1};var Tb=(e,t)=>{if(e.state._tag==="Done")return;let r=e.state;e.state={_tag:"Done",exit:t};for(let n of r.takers)n.resume(t);r.takers.clear();for(let n of r.awaiters)n(t);r.awaiters.clear()};var ff=e=>new KC(e),SH=(e,t,r)=>$t(n=>{if(e.free>=t)return n(r);let o=()=>{e.free<t||(e.waiters.delete(o),n(r))};return e.waiters.add(o),ye(()=>{e.waiters.delete(o)})}),KC=class{waiters=new Set;taken=0;permits;constructor(t){this.permits=t}get free(){return this.permits-this.taken}take(t){let r=ce(()=>this.free<t?SH(this,t,r):(this.taken+=t,q(t)));return r}takeIfAvailable(t){return ce(()=>this.free<t?q(!1):(this.taken+=t,q(!0)))}releaseUnsafe(t,r){return this.taken-=r,this.waiters.size>0&&t.currentDispatcher.scheduleTask(()=>{for(let n of this.waiters){if(this.free<=0)break;n()}},0),this.free}resize(t){return oe(r=>(this.permits=t,this.free<0?pe:(this.releaseUnsafe(r,0),pe)))}release(t){return oe(r=>q(this.releaseUnsafe(r,t)))}get releaseAll(){return oe(t=>q(this.releaseUnsafe(t,this.taken)))}withPermits(t){return r=>Gn(n=>{let o=ce(()=>{if(this.free<t){let s=SH(this,t,pe);return Y(n(s),()=>o)}return this.taken+=t,Io(n(r),()=>{this.releaseUnsafe(ea(),t)},!0)});return o})}withPermit=this.withPermits(1);withPermitsIfAvailable(t){return r=>Gn(n=>this.free<t?au:(this.taken+=t,Io(n(Jf(r)),()=>{this.releaseUnsafe(ea(),t)},!0)))}};var GC=e=>ws(e)?ft(e)?se(e.value):e:I(e);var TH="~effect/Channel",on=e=>O(e,TH),Dre={[TH]:{_Env:F,_InErr:F,_InElem:F,_OutErr:F,_OutElem:F},pipe(){return V(this,arguments)}},De=e=>{let t=Object.create(Dre);return t.transform=(r,n)=>rt(e(r,n),o=>I(je(o))),t},is=(e,t)=>De((r,n)=>C(we(e)(r,n),o=>t(o,n))),qr=e=>De((t,r)=>e),Vs=e=>De(me(function*(t,r){let n=yr(r),o=i=>Ve(n,ey(i)),s=yield*to(e(t,r,n),o);return to(s,o)})),we=e=>e.transform,dh=4096,Lre=(e,t,r)=>io({capacity:r?.bufferSize,strategy:r?.strategy}).pipe(_t(n=>It(e,ss(n))),_t(n=>zo(t(n),e).pipe(rt(o=>Ht(n,o)),gt(e))));var wH=(e,t)=>De((r,n)=>K(Lre(n,e,t),cf)),wb=e=>De((t,r)=>L(()=>we(e())(t,r))),Bre=(e,t,r)=>Vs(me(function*(n,o,s){let i=_();yield*Wo(s,c=>de(i)?r(i.value,c):P);let a=yield*Ai(K(e,c=>(i=N(c),c)));return yield*we(t(a))(n,o)}));var vH=e=>qr(W(()=>{let t=e();return L(()=>{let r=t.next();return r.done?se(r.value):I(r.value)})})),JC=e=>qr(W(()=>{let t=0;return L(()=>t>=e.length?se():I(e[t++]))}));var ZC=(e,t=dh)=>{let r=Lo(t);return qr(W(()=>{let n=e(),o=_();return L(()=>{if(o._tag==="Some")return se(o.value);let s=[];for(;s.length<r;){let i=n.next();if(i.done){if(s.length===0)return se(i.value);o=N(i.value);break}s.push(i.value)}return I(s)})}))};var AH=(e,t=dh)=>ZC(()=>e[Symbol.iterator](),t),vb=e=>Ab(I(e));var CH=e=>Ab(W(e)),Sd=qr(I(se())),kH=qr(I(Xn)),Di=e=>qr(I(D(e))),RH=e=>qr(sy(e)),ph=e=>qr(je(e)),OH=e=>qr(aa(e)),QC=e=>ph(cl(e)),Ab=e=>qr(W(()=>{let t=!1;return L(()=>t?se():(t=!0,e))}));var _H=e=>qr(C(e,()=>se())),YC=e=>qr(I(C(e,GC)));var PH=e=>qr(I(cf(e)));var XC=e=>qr(I(bu(uH(e),()=>se())));var MH=e=>wc(K(lh(e),XC)),FH=e=>wc(K(lh(e),t=>YC(hb(t))));var NH=e=>De((t,r)=>$re({scope:r,readable:e.evaluate(),onError:e.onError,releaseLockOnEnd:e.releaseLockOnEnd}));var $re=e=>{let t=e.readable.getReader(),r=e.exit??xd(void 0),n=L(()=>r.current?r.current:Un(Vo({try:()=>t.read(),catch:e.onError}),{onFailure:o=>r.current??je(o),onSuccess:({done:o,value:s})=>r.current?r.current:o?se():I(Me(s))}));return Pt(It(e.scope,e.releaseLockOnEnd?W(()=>t.releaseLock()):Wp(()=>t.cancel().catch(Rr))),n)},jre=(e,t)=>De(me(function*(r,n){let o=e[Symbol.asyncIterator]();return o.return&&(yield*It(n,Wp(()=>o.return()))),C(Vo({try:()=>o.next(),catch:t}),s=>s.done?se(s.value):I(s.value))})),UH=(e,t)=>Gs(jre(e,t),Me),Gs=d(2,(e,t)=>is(e,r=>W(()=>{let n=0;return K(r,o=>t(o,n++))})));var DH=d(2,(e,t)=>is(e,r=>I(ht(r,n=>C(t(n),se))))),LH=e=>e===void 0||e!=="unbounded"&&e<=1,Cb=d(e=>on(e[0]),(e,t,r)=>LH(r?.concurrency)?BH(e,t):Hre(e,t,r)),BH=(e,t)=>De((r,n)=>{let o=0;return K(we(e)(r,n),C(s=>t(s,o++)))}),Hre=(e,t,r)=>Vs(me(function*(n,o,s){let i=0,a=yield*we(e)(n,o),c=r.concurrency==="unbounded"?Number.MAX_SAFE_INTEGER:r.concurrency,u=yield*af(0);yield*It(s,ss(u));let f=Sr(yield*Nr()),p=Ni(s);if(r.unordered){let m=ff(c),h=qe(m.release(1)),x=Un({onFailure:g=>C(Ht(u,g),h),onSuccess:g=>C(jn(u,g),h)});yield*m.take(1).pipe(C(()=>a),C(g=>{let y=i++;return p(f(x(L(()=>t(g,y))))),P}),Mt({disableYield:!0}),rt(g=>m.withPermits(c-1)(Ht(u,g))),gt(s))}else{let m=yield*af(c-2);yield*It(s,ss(m)),yield*Ws(m).pipe(q0,C(g=>jn(u,g)),Mt({disableYield:!0}),rt(g=>Ht(u,g)),gt(s));let h,x=g=>{g._tag!=="Success"&&(h=g.cause,Ui(u,g.cause))};yield*a.pipe(C(g=>{if(h)return je(h);let y=i++,E=f(L(()=>t(g,y)));return p(E),E.addObserver(x),jn(m,Ec(E))}),Mt({disableYield:!0}),rt(g=>jn(m,ir(g)).pipe(Vt(Ht(m,g)))),gt(s))}return Ws(u)}));var ek=d(e=>on(e[0]),(e,t,r)=>LH(r?.concurrency)?qre(e,t):zre(e,t,r)),qre=(e,t)=>De((r,n)=>K(we(e)(r,n),o=>{let s,i,a=C(o,u=>(i??=yr(n),ur(we(t(u))(r,i),f=>(s=c(f),s)))),c=ht(u=>{if(s=void 0,i.state._tag==="Empty")return a;let f=Ve(i,Kt);return i=void 0,C(f,()=>a)});return L(()=>s??a)})),zre=(e,t,r)=>e.pipe(Gs(t),Ob(r)),$H=d(2,(e,t)=>De((r,n)=>W(()=>{let o,s=yr(n),i=C(we(e)(r,s),a=>(o=ht(a,c=>Ve(s,Kt).pipe(C(()=>we(t(c))(r,n)),C(u=>(o=u,u)))),o));return L(()=>o??i)})));var tk=d(4,(e,t,r,n)=>De(me(function*(o,s){let i=yield*we(e)(o,s),a=yield*we(t)(o,s),c=r();return L(()=>{let u=n(c,i,a);return K(u,([f,p])=>(c=p,f))})}))),jH=d(2,(e,t)=>De((r,n)=>W(()=>{let o,s=yr(n),i=C(we(e)(r,s),a=>{let c=a.pipe(_t(()=>(o=a,P)),ht(u=>Ve(s,Mr(u)).pipe(Vt(we(t(u))(r,n)),C(f=>(o=f,f)))));return o=c,c});return L(()=>o??i)}))),HH=e=>ek(e,F),wn=e=>is(e,t=>{let r,n=0,o=L(function s(){if(r===void 0)return C(t,a=>{switch(a.length){case 0:return s();case 1:return I(a[0]);default:return r=a,I(a[n++])}});let i=r[n++];return n>=r.length&&(r=void 0,n=0),I(i)});return I(o)}),qH=e=>BH(e,GC),zH=e=>is(e,t=>I(Mt(t,{disableYield:!0}))),WH=d(2,(e,t)=>ks(typeof t=="function"?t(F):t).pipe(K(r=>{let n=Fr.defaultValue();return KH(Fb(e,Fr,W(()=>n)),o=>r(o).pipe(K(s=>{n=s}),ht(()=>se(o))))}),wc)),KH=(e,t)=>De((r,n)=>W(()=>{let o,s=()=>{let i=yr(n);return C(we(e)(r,i),a=>(o=ht(a,c=>Ve(i,Kt).pipe(C(()=>t(c)),C(s))),o))};return L(()=>o??s())})),VH=e=>KH(e,()=>P),GH=d(2,(e,t)=>is(e,(r,n)=>K(Lp(t),o=>_t(r,o)))),JH=d(2,(e,t)=>De((r,n)=>K(we(e)(r,n),o=>C(o,function s(i){return t(i)?I(i):C(o,s)}))));var ZH=d(2,(e,t)=>is(e,r=>I(C(r,function n(o){let s=[];for(let i=0;i<o.length;i++)t(o[i])&&s.push(o[i]);return bt(s)?I(s):C(r,n)})))),QH=d(2,(e,t)=>is(e,r=>I(C(r,function n(o){let s=[];for(let i=0;i<o.length;i++){let a=t(o[i]);tt(a)&&s.push(a.success)}return bt(s)?I(s):C(r,n)})))),YH=d(2,(e,t)=>is(e,r=>{let n=C(r,o=>Z0(o,t));return I(C(n,function o(s){return bt(s)?I(s):C(n,o)}))})),XH=d(2,(e,t)=>is(e,r=>I(C(r,function n(o){return C(Q0(o,t),s=>bt(s)?I(s):C(r,n))})))),bd=d(e=>on(e[0]),(e,t,r,n)=>De((o,s)=>K(we(e)(o,s),i=>{let a=t(),c,u=0,f,p=Un(i,{onFailure(h){f=h;let x=n?.onHalt&&n.onHalt(a);return x&&x.length>0?I([a,x]):je(h)},onSuccess(h){let x=r(a,h);return X_(x)?I(x):x}});return L(function h(){if(c===void 0)return f?je(f):C(p,([g,y])=>(a=g,y.length===0?h():y.length===1?I(y[0]):(c=y,h())));let x=c[u++];return u>=c.length&&(c=void 0,u=0),I(x)})})));var eq=d(3,(e,t,r)=>De((n,o)=>K(we(e)(n,o),s=>{let i=t,a=!0;return L(()=>a?(a=!1,I(i)):K(C(s,c=>r(i,c)),c=>(i=c,i)))}))),Ed=d(2,(e,t)=>De((r,n)=>{let o=yr(n);return K(we(e)(r,o),s=>{let i=s.pipe(rt(a=>{if(wo(a))return je(a);let c=o;return o=yr(n),Ve(c,ir(a)).pipe(Vt(we(t(a))(r,o)),C(u=>(i=u,u)))}));return L(()=>i)})})),tq=d(2,(e,t)=>Rb(e,Rp,t)),kb=d(2,(e,t)=>Ed(e,r=>_H(C(t(r),n=>je(r))))),rq=d(3,(e,t,r)=>Ed(e,n=>t(n)?r(n):ph(n))),Rb=d(3,(e,t,r)=>Ed(e,n=>{let o=t(n);return be(o)?ph(o.failure):r(o.success,n)})),Ks=d(2,(e,t)=>Rb(e,ul,r=>t(r)));var nq=d(2,(e,t)=>is(e,r=>I(Gp(r,n=>Op(n)?P:vo(t(n)))))),oq=d(e=>on(e[0]),(e,t,r,n)=>Ks(e,o=>t(o)?r(o):n?n(o):Di(o))),sq=d(e=>on(e[0]),(e,t,r,n)=>Ks(e,o=>{let s=t(o);return be(s)?n?n(s.failure):Di(s.failure):r(s.success)}));var iq=d(e=>on(e[0]),(e,t,r,n,o)=>Ks(e,s=>{if(Or(s,t)&&O(s,"reason")){let i=s.reason;return Or(i,r)?n(i,s):o?o(i,s):Di(s)}return Di(s)})),aq=d(e=>on(e[0]),(e,t,r,n)=>{let o;return Ks(e,s=>{if(Or(s,t)&&O(s,"reason")&&O(s.reason,"_tag")&&Xg(s.reason._tag)){let i=s.reason;return o??=new Set(Object.keys(r)),o.has(i._tag)?r[i._tag](i,s):n?n(i,s):Di(s)}return Di(s)})});var cq=d(2,(e,t)=>Ks(e,r=>Di(t(r)))),uq=e=>Ks(e,QC),fq=d(e=>on(e[0]),(e,t)=>{if(!t?.log)return Ks(e,()=>Sd);let r=Tl(t.log===!0?void 0:t.log);return Ks(kb(e,n=>yN(n)?r(n):P),()=>Sd)}),EH=e=>Ed(e,()=>Sd),lq=d(e=>on(e[0]),(e,t)=>{if(!t?.log)return EH(e);let r=Tl(t.log===!0?void 0:t.log);return EH(kb(e,n=>r(n)))}),dq=d(2,(e,t)=>wb(()=>{let r,n=Fr.defaultValue(),o=Fb(e,Fr,W(()=>n)),s=sk(o,()=>(r=void 0,P)),i=typeof t=="function"?t(F):t,a=Ks(s,me(function*(c){return r||(r=yield*ks(i)),n=yield*r(c),a},(c,u)=>ht(c,()=>I(Di(u))),wc));return a})),pq=d(e=>on(e[0]),(e,t,r)=>e.pipe(Gs(t),Ob({...r,concurrency:r?.concurrency??1,switch:!0}))),Ob=d(2,(e,{bufferSize:t=16,concurrency:r,switch:n=!1})=>Vs(me(function*(o,s,i){let a=r==="unbounded"?Number.MAX_SAFE_INTEGER:Math.max(1,r),c=n?void 0:ff(a),u=yield*eH(!0),f=new Set,p=yield*af(t);yield*It(i,ss(p));let m=yield*we(e)(o,s);return yield*xt(function*(){for(;;){let h;c&&(f.size<a?yield*c.take(1):(h=yield*El(m),yield*Xa(c.take(1),Vt(Ec(h),Xn))));let x=h===void 0?yield*m:yield*Ec(h),g=yr(i),y=yield*we(x)(o,g);for(;f.size>=a;){let b=V_(f);f.delete(b),f.size===0&&(yield*u.open),yield*Tn(b)}let E=yield*y.pipe(_t(()=>Vp),C(b=>jn(p,b)),Mt({disableYield:!0}),to(me(function*(b){let v=ey(b),T=yield*eo(Ve(g,v));if(!f.has(E))return;let S=vN([v,T]);vs(S)&&(yield*Ht(p,S.cause)),f.delete(E),c&&(yield*c.release(1)),f.size===0&&(yield*u.open)})),El);u.closeUnsafe(),f.add(E)}}).pipe(rt(h=>{let x=Up(h);return tt(x)?u.whenOpen(Ht(p,h)):Ht(p,h)}),gt(i)),Ws(p)}))),_b=d(e=>on(e[0])&&on(e[1]),(e,t,r)=>Vs(me(function*(n,o,s){let i=r?.haltStrategy??"both",a=yield*af(0);yield*It(s,ss(a));let c=0;function u(p,m){if(c++,!wo(m))return Ht(a,m);switch(i){case"both":return c===2?Ht(a,m):P;case"left":case"right":return p===i?Ht(a,m):P;case"either":return Ht(a,m)}}let f=(p,m,h)=>we(m)(n,h).pipe(C(x=>x.pipe(C(g=>jn(a,g)),Mt)),to(x=>Zp(ey(x),g=>Ve(h,g)).pipe(Un({onFailure:g=>u(p,g),onSuccess:()=>u(p,x)}))),gt(s));return yield*f("left",e,yr(s)),yield*f("right",t,yr(s)),Ws(a)}))),mq=d(2,(e,t)=>_b(e,_H(t),{haltStrategy:"left"})),hq=()=>De((e,t)=>W(()=>{let r="",n=!1,o=_();function s(c){let u=[];function f(p){r.length===0?u.push(p):(u.push(r+p),r="")}for(let p=0;p<c.length;p++){let m=c[p];if(m.length!==0){let h=0,x=m.indexOf("\r"),g=m.indexOf(`
29
29
  `);for(n&&(g===0&&(h=1,g=m.indexOf(`
30
30
  `,h)),n=!1);x!==-1||g!==-1;)x===-1||g!==-1&&g<x?(f(m.substring(h,g)),h=g+1,g=m.indexOf(`
31
31
  `,h)):(f(m.substring(h,x)),m.length===x+1?(n=!0,h=m.length,x=-1):(h=x+(g===x+1?2:1),x=m.indexOf("\r",h),g=m.indexOf(`
32
- `,h)));r=r+m.substring(h)}}return bt(u)?u:null}let i=L(()=>o._tag==="Some"?se(o.value):Dp(e,{onSuccess:a,onFailure:je,onDone:c=>{if(o=N(c),r.length>0){let u=r;return r="",n=!1,I([u])}return se(c)}}));function a(c){let u=s(c);return u!==null?I(u):i}return i}));var ek=d(2,(e,t)=>De((r,n)=>A(we(e)(r,n),o=>we(t)(o,n)))),tk=d(2,(e,t)=>De((r,n)=>A(we(e)(r,n),o=>{let s=rt(o,i=>wo(i)?je(i):gn(bN(i)));return K(we(t)(s,n),i=>q0(i,a=>Op(a)?je(a.value):gn(a)))}))),Tc=e=>De((t,r)=>{let n;return I(L(()=>n||e.pipe(zo(r),A(o=>we(o)(t,r)),A(o=>n=o))))}),hq=e=>Vs((t,r,n)=>K(zo(we(e)(t,r),n),zo(n)));var xq=d(2,(e,t)=>De(me(function*(r,n){let o=yield*we(e)(r,n),s=yield*io({capacity:t.capacity==="unbounded"?void 0:t.capacity,strategy:t.capacity==="unbounded"?void 0:t.strategy});return yield*It(n,ss(s)),yield*o.pipe(A(i=>jn(s,i)),Mt({disableYield:!0}),to(i=>Ht(s,i)),gt(n)),Ws(s)}))),gq=d(2,(e,t)=>De(me(function*(r,n){let o=yield*we(e)(r,n),s=yield*io({capacity:t.capacity==="unbounded"?void 0:t.capacity,strategy:t.capacity==="unbounded"?void 0:t.strategy});return yield*It(n,ss(s)),yield*o.pipe(A(i=>wa(s,i)),Mt({disableYield:!0}),to(i=>Ht(s,i)),gt(n)),af(s)}))),rk=d(2,(e,t)=>_b(e,qr(I(A(t,se))),{haltStrategy:"either"})),yq=d(2,(e,t)=>Vs(me(function*(r,n,o){let s=yield*we(e)(r,n),i=yield*gt(t,o,{startImmediately:!0});return L(()=>{let a=i.pollUnsafe();return a===void 0?s:TN(a,{onFailure:je,onSuccess:se})})}))),Sq=d(2,(e,t)=>mh(e,r=>vs(r)?t(r.cause):P)),mh=d(2,(e,t)=>Vs((r,n,o)=>Wo(o,t).pipe(Vt(we(e)(r,n))))),bq=d(2,(e,t)=>Tc(Pt(t,e))),nk=d(2,(e,t)=>is(e,r=>W(()=>{let n=!0,o=_t(r,s=>(n=!1,t(s)));return L(()=>n?o:r)}))),Eq=d(2,(e,t)=>is(e,r=>I(ht(r,n=>A(t,()=>se(n)))))),Iq=d(2,(e,t)=>mh(e,r=>t)),ff=(e,t,r)=>L(()=>{let n=Zn(),o=we(e)(se(),n);return ht(A(o,t),r||I).pipe(Xr(s=>Ve(n,s)))});var Pb=d(2,(e,t)=>De((r,n)=>K(Ur(we(e)(r,n),t),Ur(t)))),Mb=d(3,(e,t,r)=>De((n,o)=>K(Jo(we(e)(n,o),t,r),Jo(t,r)))),Fb=d(3,(e,t,r)=>De((n,o)=>A(r,s=>we(Mb(e,t,s))(n,o)))),Tq=d(e=>on(e[0]),(e,t,r)=>ip(t)?Pb(e,t):De((n,o)=>A(r?.local?gi(t,xi(),o):_p(t,o),s=>K(Ur(we(e)(n,o),s),Ur(s))))),wq=d(2,(e,t)=>De((r,n)=>yn(o=>{let s=t(o);return we(Pb(e,s))(r,n)})));var ok=function(){let e=on(arguments[0]),t=e?arguments[1]:arguments[0],r=Ho(e?arguments[2]:arguments[1]);if(e){let n=arguments[0];return EH(n,t,r)}return n=>EH(n,t,r)},EH=(e,t,r)=>Bre(tw(t,r),n=>Mb(e,li,n),(n,o)=>ar(s=>{let i=s.getRef(Vn),a=s.getRef(jg);return Mg(n,o,i,a)}));var vq=e=>ff(e,t=>Mt(t,{disableYield:!0})),lf=d(2,(e,t)=>ff(e,r=>Mt(A(r,t),{disableYield:!0}))),Cq=d(2,(e,t)=>ff(e,r=>r.pipe(A(t),A(n=>n?P:se()),Mt({disableYield:!0})))),sk=e=>K(df(e,()=>({bytes:0,arrays:[]}),(t,r)=>{for(let n=0;n<r.length;n++)t.bytes+=r[n].length,t.arrays.push(r[n]);return t}),({arrays:t,bytes:r})=>{let n=new Uint8Array(r),o=0;for(let s=0;s<t.length;s++){let i=t[s];n.set(i,o),o+=i.length}return n});var Aq=e=>L(()=>{let t=_();return ff(e,r=>r.pipe(iy,A(n=>(t=n,se()))),()=>I(t))}),kq=e=>L(()=>{let t=Symbol(),r=t;return ff(e,n=>Mt(A(n,o=>(r=o,P)),{disableYield:!0}),()=>r===t?ia:B0(r))}),df=d(3,(e,t,r)=>L(()=>{let n=t();return ff(e,o=>xn({while:nr,body:()=>o,step:s=>{n=r(n,s)}}),()=>I(n))})),Rq=d(3,(e,t,r)=>L(()=>{let n=t();return ff(e,o=>xn({while:nr,body:qe(o.pipe(A(s=>r(n,s)),K(s=>{n=s}))),step:Rr}),()=>I(n))})),ik=me(function*(e){let t=uf(1),r=yield*Nr(),n=Re(r,it);return(yield*we(e)(se(),n)).pipe(Ur(r),t.withPermits(1))},rt(e=>I(je(e)))),as=(e,t)=>we(e)(se(),t);var ak=d(e=>on(e[0]),(e,t)=>en(r=>lf(e,n=>wa(t,n)).pipe(r,eo,A(n=>(ft(n)?Eb(t):Ui(t,n.cause),P)))));var Oq=d(e=>on(e[0]),me(function*(e,t){let r=yield*Co,n=yield*io({capacity:typeof t.capacity=="number"?t.capacity:void 0,strategy:typeof t.capacity=="number"?t.strategy:void 0});return yield*It(r,ss(n)),yield*gt(ak(e,n),r),n}));var _q=e=>Ti(e.capacity==="unbounded"?uh(e):e.strategy==="dropping"?lb(e):e.strategy==="sliding"?db(e):fb(e),fh),Pq=d(2,me(function*(e,t){let r=yield*_q(t);return yield*Rs(ck(e,r,{shutdownOnEnd:t.shutdownOnEnd!==!1})),r})),ck=d(e=>on(e[0]),(e,t,r)=>lf(e,n=>aH(t,n)).pipe(r?.shutdownOnEnd===!0?wi(fh(t)):F)),Mq=d(2,me(function*(e,t){let r=yield*_q(t);return yield*lf(e,n=>mb(r,n)).pipe(Xr(n=>pb(r,n)),Rs),r}));var Wre="~effect/Stream",Kre={_R:F,_E:F,_A:F},Fq=function(e){this.channel=e};Fq.prototype={[Wre]:Kre,pipe(){return V(this,arguments)}};var Nq=e=>new Fq(e);var Gre="~effect/Sink";var Jre={_A:F,_In:F,_L:F,_E:F,_R:F},Zre={[Gre]:Jre,pipe(){return V(this,arguments)}};var Qre=e=>{let t=Object.create(Zre);return t.transform=e,t},Uq=e=>De((t,r)=>I(A(e.transform(t,r),se)));var Dq=e=>{let t=Bt(e);return Qre(r=>{let n=[];if(t===0)return I([n]);let o;return r.pipe(A(s=>{if(n.length+s.length<=t)return n.push(...s),n.length===t?se():P;for(let i=0;i<s.length;i++)if(n.push(s[i]),n.length===t)return i+1<s.length&&(o=s.slice(i+1)),se();return P}),Mt({disableYield:!0}),ht(()=>I([n,o])))})};var sn={};ps(sn,{DefaultChunkSize:()=>Qq,Do:()=>Fse,TypeId:()=>Zq,accumulate:()=>bse,aggregate:()=>dse,aggregateWithin:()=>Tk,as:()=>Rne,bind:()=>Use,bindEffect:()=>Dse,bindTo:()=>Lse,broadcast:()=>wz,broadcastN:()=>pse,buffer:()=>Soe,bufferArray:()=>boe,callback:()=>Db,catch:()=>bh,catchCause:()=>fz,catchCauseFilter:()=>Ooe,catchCauseIf:()=>Roe,catchDefect:()=>Eoe,catchFilter:()=>Ek,catchIf:()=>dz,catchReason:()=>Coe,catchReasons:()=>Aoe,catchTag:()=>woe,catchTags:()=>voe,changes:()=>vz,changesWith:()=>Cz,changesWithEffect:()=>Ese,chunks:()=>Sz,collect:()=>Sse,combine:()=>Joe,combineArray:()=>Zoe,concat:()=>mf,cross:()=>Xne,crossWith:()=>cz,debounce:()=>rse,decodeText:()=>Ise,die:()=>pne,drain:()=>Lne,drainFork:()=>Bne,drop:()=>Ik,dropRight:()=>Koe,dropUntil:()=>qoe,dropUntilEffect:()=>zoe,dropWhile:()=>gz,dropWhileEffect:()=>yz,dropWhileFilter:()=>Woe,empty:()=>Js,encodeText:()=>Tse,ensuring:()=>Eh,fail:()=>wc,failCause:()=>ez,failCauseSync:()=>mne,failSync:()=>dne,filter:()=>yk,filterEffect:()=>poe,filterMap:()=>doe,filterMapEffect:()=>moe,flatMap:()=>Id,flatten:()=>sz,flattenArray:()=>Dne,flattenEffect:()=>_ne,flattenIterable:()=>Wne,flattenTake:()=>Kne,forever:()=>zne,fromArray:()=>yh,fromArrayEffect:()=>yne,fromArrays:()=>Sne,fromAsyncIterable:()=>bne,fromChannel:()=>U,fromEffect:()=>Ub,fromEffectDrain:()=>Yq,fromEffectRepeat:()=>Xq,fromEffectSchedule:()=>cne,fromEventListener:()=>Tne,fromIterable:()=>hf,fromIterableEffect:()=>xne,fromIterableEffectRepeat:()=>gne,fromIteratorSucceed:()=>hne,fromPubSub:()=>pk,fromPubSubTake:()=>tz,fromPull:()=>Li,fromQueue:()=>Sh,fromReadableStream:()=>mk,fromSchedule:()=>Ene,fromSubscription:()=>Ine,groupAdjacentBy:()=>fse,groupBy:()=>cse,groupByKey:()=>use,grouped:()=>ise,groupedWithin:()=>ase,haltWhen:()=>kse,ignore:()=>Foe,ignoreCause:()=>Noe,interleave:()=>Cse,interleaveWith:()=>kz,interruptWhen:()=>Ase,intersperse:()=>Az,intersperseAffixes:()=>vse,isStream:()=>Ae,iterate:()=>vne,let:()=>Nse,limitBytes:()=>Boe,make:()=>fne,map:()=>ao,mapAccum:()=>Qoe,mapAccumArray:()=>gf,mapAccumArrayEffect:()=>Xoe,mapAccumEffect:()=>Yoe,mapArray:()=>nz,mapArrayEffect:()=>Pne,mapBoth:()=>One,mapEffect:()=>xf,mapError:()=>pz,merge:()=>hk,mergeAll:()=>Yne,mergeEffect:()=>Lb,mergeLeft:()=>Zne,mergeResult:()=>Jne,mergeRight:()=>Qne,mkArrayBuffer:()=>Jse,mkString:()=>Gse,mkUint8Array:()=>Zse,never:()=>Ane,onEnd:()=>Ose,onError:()=>Rse,onExit:()=>Rz,onFirst:()=>_z,onStart:()=>Oz,orDie:()=>Moe,orElseIfEmpty:()=>_oe,orElseSucceed:()=>Poe,paginate:()=>wne,partition:()=>xoe,partitionEffect:()=>hoe,partitionQueue:()=>Sk,peel:()=>yoe,pipeThrough:()=>yse,pipeThroughChannel:()=>xse,pipeThroughChannelOrFail:()=>gse,prepend:()=>Gne,provide:()=>Pz,provideContext:()=>wk,provideService:()=>_se,provideServiceEffect:()=>vk,race:()=>loe,raceAll:()=>uz,range:()=>Cne,rechunk:()=>bz,repeat:()=>$ne,repeatElements:()=>qne,result:()=>Mne,retry:()=>Uoe,run:()=>Bse,runCollect:()=>Fz,runCount:()=>$se,runDrain:()=>$b,runFold:()=>Hse,runFoldEffect:()=>qse,runForEach:()=>Kse,runForEachArray:()=>Td,runForEachWhile:()=>Vse,runHead:()=>zse,runIntoPubSub:()=>eie,runIntoQueue:()=>nie,runLast:()=>Wse,runSum:()=>jse,scan:()=>ese,scanEffect:()=>tse,schedule:()=>jne,scoped:()=>kne,service:()=>ine,serviceOption:()=>ane,share:()=>hse,sliding:()=>Voe,slidingSize:()=>Ez,split:()=>Goe,splitLines:()=>wse,succeed:()=>pf,suspend:()=>vn,switchMap:()=>Une,sync:()=>lne,take:()=>Loe,takeRight:()=>$oe,takeUntil:()=>mz,takeUntilEffect:()=>hz,takeWhile:()=>xz,takeWhileEffect:()=>Hoe,takeWhileFilter:()=>joe,tap:()=>oz,tapBoth:()=>Fne,tapCause:()=>lz,tapDefect:()=>Toe,tapError:()=>bk,tapErrorTag:()=>Ioe,tapSink:()=>Nne,throttle:()=>sse,throttleEffect:()=>Iz,tick:()=>une,timeout:()=>Hne,timeoutOrElse:()=>iz,toAsyncIterable:()=>Xse,toAsyncIterableEffect:()=>Yse,toAsyncIterableWith:()=>Rk,toChannel:()=>cs,toPubSub:()=>tie,toPubSubTake:()=>Nz,toPull:()=>Ck,toQueue:()=>rie,toReadableStream:()=>Qse,toReadableStreamEffect:()=>kk,toReadableStreamWith:()=>Ak,transduce:()=>lse,transformPull:()=>br,transformPullBracket:()=>dk,unfold:()=>rz,unwrap:()=>Cn,unwrapReason:()=>koe,updateContext:()=>Mz,updateService:()=>Pse,when:()=>goe,withExecutionPlan:()=>Doe,withSpan:()=>Mse,zip:()=>toe,zipFlatten:()=>ooe,zipLatest:()=>uoe,zipLatestAll:()=>gk,zipLatestWith:()=>foe,zipLeft:()=>roe,zipRight:()=>noe,zipWith:()=>xk,zipWithArray:()=>Bb,zipWithIndex:()=>soe,zipWithNext:()=>ioe,zipWithPrevious:()=>aoe,zipWithPreviousAndNext:()=>coe});var Bq="~effect/RcMap",Yre=e=>({[Bq]:Bq,lookup:e.lookup,context:e.context,scope:e.scope,idleTimeToLive:e.idleTimeToLive,capacity:e.capacity,state:{_tag:"Open",map:Si()},pipe(){return V(this,arguments)}}),$q=e=>ar(t=>{let r=t.context,n=Re(r,it),o=Yre({lookup:e.lookup,context:r,scope:n,idleTimeToLive:typeof e.idleTimeToLive=="function"?$c(e.idleTimeToLive,$e):qe($e(e.idleTimeToLive??Ji)),capacity:Math.max(e.capacity??Number.POSITIVE_INFINITY,0)});return Pt(Wo(n,()=>{if(o.state._tag==="Closed")return P;let s=o.state.map;return o.state={_tag:"Closed"},Ko(s,([,i])=>eo(hh(i))).pipe(_t(()=>W(()=>{ny(s)})))}),o)}),uk=d(2,(e,t)=>en(r=>{if(e.state._tag==="Closed")return Dn;let n=e.state,o=os(),s=Qr(n.map,t),i;if(s._tag==="Some")i=s.value,i.refCount++;else{if(Number.isFinite(e.capacity)&&TU(e.state.map)>=e.capacity)return D(new EN(`RcMap attempted to exceed capacity of ${e.capacity}`));{i={deferred:lu(),scope:Zn(),idleTimeToLive:e.idleTimeToLive(t),finalizer:void 0,fiber:void 0,expiresAt:0,refCount:1},i.finalizer=ene(e,t,i),bi(n.map,t,i);let c=new Map(e.context.mapUnsafe);o.context.mapUnsafe.forEach((f,p)=>{c.set(p,f)}),c.set(it.key,i.scope);let u=qn(c);L(()=>e.lookup(t)).pipe(Sr(u),Ni(i.scope)).addObserver(f=>{IN(f)&&Xre(e,t,i,u),hi(i.deferred,f)})}}let a=dn(o.context,it);return It(a,i.finalizer).pipe(Vt(r(Bg(i.deferred))))}));var Xre=(e,t,r,n)=>{if(e.state._tag==="Closed")return;let o=Qr(e.state.map,t);o._tag==="None"||o.value!==r||(Ei(e.state.map,t),!(r.refCount>0)&&hh(r).pipe(Sr(n),Ni(e.scope)))},hh=e=>e.fiber?Tn(e.fiber).pipe(Vt(Ve(e.scope,Kt))):Ve(e.scope,Kt),ene=(e,t,r)=>ar(n=>{if(r.refCount--,r.refCount>0)return P;if(e.state._tag==="Closed")return hh(r);let o=Qr(e.state.map,t);if(o._tag==="None"||o.value!==r)return hh(r);if(Hf(r.idleTimeToLive))return Ei(e.state.map,t),hh(r);if(!Wn(r.idleTimeToLive))return P;let s=n.getRef(Yn);return r.expiresAt=s.currentTimeMillisUnsafe()+Wt(r.idleTimeToLive),r.fiber?P:(r.fiber=en(function i(a){let c=s.currentTimeMillisUnsafe(),u=r.expiresAt-c;if(u<=0){if(e.state._tag==="Closed"||r.refCount>0)return P;let f=Qr(e.state.map,t);return f._tag==="None"||f.value!==r?P:(Ei(e.state.map,t),Ve(r.scope,Kt))}return A(a(s.sleep(Zi(u))),()=>i(a))}).pipe(wi(W(()=>{r.fiber=void 0})),Sr(n.context),Ni(e.scope)),P)});var fk=d(2,(e,t)=>bu(r=>{if(e.state._tag==="Closed")return P;let n=Qr(e.state.map,t);if(n._tag==="None"||Hf(n.value.idleTimeToLive))return P;let o=n.value;return o.expiresAt=r.currentTimeMillisUnsafe()+Wt(o.idleTimeToLive),P}));var tne="~effect/RcRef",xh={_tag:"Empty"},rne={_tag:"Closed"},nne={_A:F,_E:F},lk=class{[tne]=nne;pipe(){return V(this,arguments)}state=xh;acquire;context;scope;idleTimeToLive;constructor(t,r,n,o){this.acquire=t,this.context=r,this.scope=n,this.idleTimeToLive=o}},qq=e=>ar(t=>{let r=t.context,n=Re(r,it),o=new lk(e.acquire,r,n,e.idleTimeToLive!==void 0?$e(e.idleTimeToLive):void 0);return Pt(Wo(n,()=>{let s=o.state;return o.state=rne,s._tag==="Acquired"?Ve(s.scope,Kt):s._tag==="Acquiring"?Tn(s.fiber):P}),o)}),one=(e,t)=>{switch(e.state._tag){case"Closed":return Dn;case"Acquired":{let r=e.state;return r.refCount++,r.fiber?Pt(Tn(r.fiber),r):I(r)}case"Acquiring":{let r=e.state;return r.awaiters++,Hq(e,r,t)}case"Empty":{let r={_tag:"Acquiring",fiber:void 0,awaiters:1,acquired:void 0};e.state=r;let n=Zn(),o=Ur(e.acquire,We(e.context,it,n)).pipe(A(s=>{if(e.state!==r)return Dn;let i={_tag:"Acquired",value:s,scope:n,fiber:void 0,refCount:r.awaiters,invalidated:!1};return e.state=i,r.acquired=i,I(i)}),Xr(s=>ft(s)?P:(e.state===r&&(e.state=xh),Ve(n,s))));return r.fiber=Sr(os().context)(o),Hq(e,r,t)}}},Hq=(e,t,r)=>Xr(r(bc(t.fiber)),n=>{let o=t.acquired;return o!==void 0?vs(n)?Wq(e,o):P:--t.awaiters>0||e.state!==t?P:(e.state=xh,Tn(t.fiber))}),zq=e=>{let t=e;return en(r=>A(Co,n=>A(one(t,r),o=>Pt(Wo(n,()=>Wq(t,o)),o.value))))},Wq=(e,t)=>{if(t.refCount--,t.refCount>0)return P;let r=e.idleTimeToLive;return r===void 0||t.invalidated?(e.state===t&&(e.state=xh),Ve(t.scope,Kt)):Wn(r)?(t.fiber=en(n=>A(n(ua(r)),()=>e.state===t&&t.refCount===0?(e.state=xh,Ve(t.scope,Kt)):P)).pipe(wi(W(()=>{t.fiber=void 0})),Sr(e.context),Ni(e.scope)),P):P};var Kq=qq,Vq=zq;var Zq="~effect/Stream",Ae=e=>O(e,Zq),Qq=dh,U=Nq,Ub=e=>U(Cb(K(e,Me))),ine=e=>Ub(Y0(e)),ane=e=>Ub(yu(e)),Yq=e=>Li(I(A(e,()=>se()))),Xq=e=>Li(I(K(e,Me))),cne=(e,t)=>Li(xt(function*(){let r=yield*ks(t),n=yield*Jo(e,Fr,Fr.defaultValue()),o=!0,s=L(()=>r(n)).pipe(A(i=>Jo(e,Fr,i)),K(i=>(n=i,Me(i))));return L(()=>o?(o=!1,I(Me(n))):s)})),une=e=>Li(W(()=>{let t=!0,r=I(Me(void 0)),n=ca(r,e);return L(()=>t?(t=!1,r):n)})),Li=e=>U(qr(e)),br=(e,t)=>U(De((r,n)=>A(as(e.channel,n),o=>t(o,n)))),dk=(e,t)=>U(Vs((r,n,o)=>A(as(e.channel,n),s=>t(s,n,o)))),cs=e=>e.channel,Db=(e,t)=>U(TH(e,t)),Js=U(Sd),pf=e=>U(vb(Me(e))),fne=(...e)=>yh(e),lne=e=>U(CH(()=>Me(e()))),vn=e=>U(wb(()=>e().channel)),wc=e=>U(Di(e)),dne=e=>U(kH(e)),ez=e=>U(ph(e)),pne=e=>U(JA(e)),mne=e=>U(RH(e)),hne=(e,t)=>U(GA(()=>e,t)),hf=(e,t)=>Array.isArray(e)&&t?.chunkSize===void 0?yh(e):U(vH(e,t?.chunkSize)),xne=e=>Cn(K(e,hf)),gne=e=>Id(Xq(e),hf),yh=e=>bt(e)?U(vb(e)):Js,yne=e=>Cn(K(e,yh)),Sne=(...e)=>U(VA(Hx(e,bt))),Sh=e=>U(_H(e)),pk=e=>U(PH(e)),tz=e=>U(MH(e)),mk=e=>U(FH(e)),bne=(e,t)=>U(NH(e,t)),Ene=e=>Li(K(Lp(e),t=>ht(K(t(void 0),Me),()=>se()))),Ine=e=>U(QA(e)),Tne=(e,t,r)=>Db(n=>{let o=typeof r=="object"&&r.once;function s(i){Ic(n,i),o&&Eb(n)}return Ti(W(()=>e.addEventListener(t,s,r)),()=>W(()=>e.removeEventListener(t,s,r)))},{bufferSize:typeof r=="object"?r.bufferSize:void 0}),rz=(e,t)=>Li(W(()=>{let r=e;return A(L(()=>t(r)),n=>n===void 0?se():(r=n[1],I(Me(n[0]))))})),wne=(e,t)=>Li(W(()=>{let r=e,n=!1;return L(function o(){return n?se():A(t(r),([s,i])=>(fe(i)?n=!0:r=i.value,bt(s)?I(s):o()))})})),vne=(e,t)=>rz(e,r=>I([r,t(r)])),Cne=(e,t,r=dh)=>e>t?Js:Li(W(()=>{let n=Lo(r),o=e,s=!1;return L(()=>{if(s)return se();let i=t-o+1;if(i>n){let c=DI(o,o+n-1);return o+=n,I(c)}let a=DI(o,o+i-1);return s=!0,I(a)})})),Ane=U(AH),Cn=e=>U(Tc(K(e,cs))),kne=e=>U(hq(e.channel)),ao=d(2,(e,t)=>vn(()=>{let r=0;return U(Gs(e.channel,Bo(n=>t(n,r++))))})),Rne=d(2,(e,t)=>ao(e,()=>t)),One=d(2,(e,t)=>e.pipe(ao(t.onElement),pz(t.onError))),nz=d(2,(e,t)=>U(Gs(e.channel,t))),xf=d(e=>Ae(e[0]),(e,t,r)=>e.channel.pipe(wn,Ab(t,r),Gs(Me),U)),_ne=d(e=>Ae(e[0]),(e,t)=>xf(e,F,t)),Pne=d(2,(e,t)=>U(Ab(e.channel,t))),Mne=e=>e.pipe(ao(X),bh(t=>pf(re(t)))),oz=d(e=>Ae(e[0]),(e,t,r)=>xf(e,n=>Pt(t(n),n),r)),Fne=d(2,(e,t)=>e.pipe(bk(t.onError),oz(t.onElement,{concurrency:t.concurrency}))),Nne=d(2,(e,t)=>dk(e,me(function*(r,n,o){let s=jr(),i=jr(),a,c,u=!1,f=!1,p=s.whenOpen(L(()=>{if(a){let h=a;return a=void 0,f||s.closeUnsafe(),Pt(i.open,h)}return se()}));yield*L(()=>t.transform(p,o)).pipe(h=>Zp(h,x=>(u=!0,vs(x)&&(c=x.cause),i.open),!0),gt(o));let m=r.pipe(A(h=>c?je(c):u?I(h):(a=h,i.closeUnsafe(),s.openUnsafe(),Pt(i.await,h))),ht(()=>c?je(c):u?se():(f=!0,i.closeUnsafe(),s.openUnsafe(),A(i.await,()=>c?je(c):se()))));return L(()=>c?je(c):u?r:m)}))),Id=d(e=>Ae(e[0]),(e,t,r)=>e.channel.pipe(wn,YA(n=>t(n).channel,r),U)),Une=d(e=>Ae(e[0]),(e,t,r)=>e.channel.pipe(wn,dq(n=>t(n).channel,r),U)),sz=d(e=>Ae(e[0]),(e,t)=>Id(e,F,t)),Dne=e=>U(wn(e.channel)),Lne=e=>U(qH(e.channel)),Bne=d(2,(e,t)=>Lb(e,$b(t))),$ne=d(2,(e,t)=>U(zH(e.channel,t))),jne=d(2,(e,t)=>e.channel.pipe(wn,VH(t),Gs(Me),U)),Hne=d(2,(e,t)=>iz(e,{duration:t,orElse:()=>Js})),iz=d(2,(e,t)=>{let r=$e(t.duration);if(!Wn(r))return e;if(Hf(r))return vn(t.orElse);let n=Symbol();return fz(vn(()=>{let s=os().getRef(Yn),i=Wt(r),a,c=jr(!1);return hk(br(e,(u,f)=>L(()=>(a=s.currentTimeMillisUnsafe()+i,c.openUnsafe(),u)).pipe(K(p=>(c.closeUnsafe(),a=void 0,p)),I)),Yq(xt(function*(){for(;;)if(yield*c.await,!(a===void 0||(yield*ua(a-s.currentTimeMillisUnsafe()),a===void 0)||a-s.currentTimeMillisUnsafe()>0))return yield*gn(n)})),{haltStrategy:"left"})}),o=>o.reasons.find(i=>i._tag==="Die"&&i.defect===n)?t.orElse():ez(o))}),qne=d(2,(e,t)=>U(De((r,n)=>K(we(wn(e.channel))(r,n),o=>{let s,i=xt(function*(){let a=yield*o,c=Me(a);return s=(yield*Lp(t))(a).pipe(Pt(c),ht(f=>(s=void 0,i))),c});return L(()=>s??i)})))),zne=e=>U(KH(e.channel)),Wne=e=>Id(e,hf),Kne=e=>e.channel.pipe(wn,HH,U),mf=d(2,(e,t)=>{let r=U(jH(wH(()=>Vne(e,t))));return az.set(r,[e,t]),r}),az=new WeakMap;function*Vne(e,t){let r=[t,e];for(;r.length>0;){let n=r.pop(),o=az.get(n);o===void 0?yield n.channel:r.push(o[1],o[0])}}var Gne=d(2,(e,t)=>mf(hf(t),e)),hk=d(e=>Ae(e[0])&&Ae(e[1]),(e,t,r)=>U(_b(cs(e),cs(t),r))),Lb=d(2,(e,t)=>e.channel.pipe(pq(t),U)),Jne=d(2,(e,t)=>hk(ao(e,X),ao(t,re))),Zne=d(2,(e,t)=>Lb(e,$b(t))),Qne=d(2,(e,t)=>Lb(t,$b(e))),Yne=d(2,(e,t)=>sz(hf(e),t)),Xne=d(2,(e,t)=>cz(e,t,(r,n)=>[r,n])),cz=d(3,(e,t,r)=>Id(e,n=>ao(t,o=>r(n,o)))),xk=d(3,(e,t,r)=>Bb(e,t,eoe(r))),eoe=e=>(t,r)=>{let n=Math.min(t.length,r.length),o=[];for(let s=0;s<n;s++)o.push(e(t[s],r[s]));return[o,t.slice(n),r.slice(n)]},Bb=d(3,(e,t,r)=>U(Vs(me(function*(n,o){let s=yield*as(e.channel,o),i=yield*as(t.channel,o),a=xt(function*(){let f=yield*gt(s,o),p=yield*gt(i,o);return yield*eb([f,p])}),c={_tag:"PullBoth"};return xt(function*(){let[f,p]=c._tag==="PullBoth"?yield*a:c._tag==="PullLeft"?[yield*s,c.rightArray]:[c.leftArray,yield*i],m=r(f,p);return bt(m[1])?c={_tag:"PullRight",leftArray:m[1]}:bt(m[2])?c={_tag:"PullLeft",rightArray:m[2]}:c={_tag:"PullBoth"},m[0]})})))),toe=d(2,(e,t)=>xk(e,t,(r,n)=>[r,n])),roe=d(2,(e,t)=>Bb(e,t,(r,n)=>{let o=Math.min(r.length,n.length),s=r.slice(0,o),i=r.slice(o),a=n.slice(o);return[s,i,a]})),noe=d(2,(e,t)=>Bb(e,t,(r,n)=>{let o=Math.min(r.length,n.length),s=n.slice(0,o),i=r.slice(o),a=n.slice(o);return[s,i,a]})),ooe=d(2,(e,t)=>xk(e,t,(r,n)=>[...r,n])),soe=e=>ao(e,(t,r)=>[t,r]),ioe=e=>gf(e,_,(t,r)=>{let n=0;t._tag==="None"&&(n=1,t=N(r[0]));let o=Qt();for(;n<r.length;n++){let s=t.value;t=N(r[n]),o.push([s,t])}return[t,o]},{onHalt(t){return t._tag==="Some"?[[t.value,_()]]:[]}}),aoe=e=>gf(e,_,(t,r)=>{let n=Qt();for(let o=0;o<r.length;o++){let s=r[o];n.push([t,s]),t=N(r[o])}return[t,n]}),coe=e=>gf(e,()=>({prev:_(),current:_()}),(t,r)=>{let n=0,o;t.current._tag==="None"?(n=1,o=r[0],t.current=N(o)):o=t.current.value;let s=Qt();for(;n<r.length;n++){let i=r[n];t.current=N(i),s.push([t.prev,o,t.current]),t.prev=N(o),o=i}return[t,s]},{onHalt(t){return t.current._tag==="Some"?[[t.prev,t.current.value,_()]]:[]}}),gk=(...e)=>U(wb(()=>{let t=[],r=new Set,n=jr(),o=jr();return Ob(VA(e.map((s,i)=>s.channel.pipe(wn,Ab(a=>(t[i]=a,r.has(i)?I(Me(t.slice())):(r.add(i),r.size<e.length?n.await:Pt(n.open,Me(t.slice()))))),GH(ei),UH(()=>r.has(i)?P:o.open)))),{concurrency:"unbounded",bufferSize:0}).pipe(rk(o.await))})),uoe=d(2,(e,t)=>gk(e,t)),foe=d(3,(e,t,r)=>ao(gk(e,t),([n,o])=>r(n,o))),uz=(...e)=>U(De((t,r)=>W(()=>{let n,o=V0(e.map(s=>{let i=yr(r);return as(s.channel,i).pipe(A(a=>H0(I(a),a)),Xr(a=>a._tag==="Success"?n?Ve(i,a):(n=a.value[0],P):Ve(i,a)),K(([,a])=>a))}));return L(()=>n??o)}))),loe=d(2,(e,t)=>uz(e,t)),yk=d(2,(e,t)=>U(JH(cs(e),t))),doe=d(2,(e,t)=>U(ZH(cs(e),t))),poe=d(2,(e,t)=>U(QH(cs(e),t))),moe=d(2,(e,t)=>U(YH(cs(e),t))),Sk=d(e=>Ae(e[0]),me(function*(e,t,r){let n=yield*Co,o=yield*as(e.channel,n),s=r?.capacity==="unbounded"?void 0:r?.capacity??Qq,i=yield*io({capacity:s}),a=yield*io({capacity:s});return yield*xt(function*(){for(;;){let c=yield*o,u=[],f=[];for(let m=0;m<c.length;m++){let h=t(c[m]);be(h)?u.push(h.failure):f.push(h.success)}let p;if(f.length>0){let m=bb(i,f);m.length>0&&(p=yield*El(wa(i,m)))}if(u.length>0){let m=bb(a,u);m.length>0&&(yield*wa(a,m))}p&&(yield*bc(p))}}).pipe(to(c=>(Ui(i,c),Ui(a,c),P)),gt(n)),[i,a]})),gh=e=>U(De((t,r)=>Pt(It(r,ss(e)),af(e)))),hoe=d(e=>Ae(e[0]),(e,t,r)=>K(Sk(xf(e,n=>t(n),r),n=>n,r),([n,o])=>[gh(n),gh(o)])),xoe=d(e=>Ae(e[0]),(e,t,r)=>K(Sk(e,t,{capacity:r?.capacity??16}),([n,o])=>[gh(n),gh(o)])),goe=d(2,(e,t)=>t.pipe(K(r=>r?e:Js),Cn)),yoe=d(2,me(function*(e,t){let r,n=yield*ik(e.channel),o=rt(n,c=>(r=c,je(c))),[s,i]=yield*Sl(c=>t.transform(o,c)),a=r?Js:Li(I(n));return i&&(a=mf(yh(i),a)),[s,a]})),Soe=d(2,(e,t)=>U(gq(e.channel,t))),boe=d(2,(e,t)=>U(xq(e.channel,t))),fz=d(2,(e,t)=>e.channel.pipe(Ed(r=>t(r).channel),U)),Eoe=d(2,(e,t)=>e.channel.pipe(eq(r=>t(r).channel),U)),lz=d(2,(e,t)=>e.channel.pipe(kb(t),U)),bh=d(2,(e,t)=>U(Ks(e.channel,r=>t(r).channel)));var bk=d(2,(e,t)=>e.channel.pipe(rq(t),U)),Ioe=d(3,(e,t,r)=>{let n=Array.isArray(t)?o=>O(o,"_tag")&&t.includes(o._tag):Or(t);return bk(e,o=>n(o)?r(o):P)}),Toe=d(2,(e,t)=>lz(e,r=>{let n=Rp(r);return tt(n)?t(n.success):P})),dz=d(e=>Ae(e[0]),(e,t,r,n)=>U(nq(cs(e),t,o=>r(o).channel,n&&(o=>n(o).channel)))),Ek=d(e=>Ae(e[0]),(e,t,r,n)=>U(oq(cs(e),t,o=>r(o).channel,n&&(o=>n(o).channel)))),woe=d(e=>Ae(e[0]),(e,t,r,n)=>{let o=Array.isArray(t)?s=>O(s,"_tag")&&t.includes(s._tag):Or(t);return dz(e,o,r,n)}),voe=d(e=>Ae(e[0]),(e,t,r)=>{let n;return Ek(e,o=>(n??=Object.keys(t),O(o,"_tag")&&Xg(o._tag)&&n.includes(o._tag)?X(o):re(o)),o=>t[o._tag](o),r)}),Coe=d(e=>Ae(e[0]),(e,t,r,n,o)=>U(sq(cs(e),t,r,(s,i)=>n(s,i).channel,o&&((s,i)=>o(s,i).channel)))),Aoe=d(e=>Ae(e[0]),(e,t,r,n)=>{let o=Object.create(null);for(let i of Object.keys(r)){let a=r[i];o[i]=(c,u)=>a(c,u).channel}let s=n&&((i,a)=>n(i,a).channel);return U(iq(e.channel,t,o,s))}),koe=d(2,(e,t)=>Ek(e,r=>Or(r,t)&&O(r,"reason")?X(r.reason):re(r),wc)),pz=d(2,(e,t)=>U(aq(e.channel,t))),Roe=d(3,(e,t,r)=>U(tq(e.channel,t,n=>r(n).channel))),Ooe=d(3,(e,t,r)=>U(Rb(e.channel,t,(n,o)=>r(n,o).channel))),_oe=d(2,(e,t)=>U($H(e.channel,r=>cs(t())))),Poe=d(2,(e,t)=>bh(e,r=>pf(t(r)))),Moe=e=>U(cq(e.channel)),Foe=d(e=>Ae(e[0]),(e,t)=>U(uq(e.channel,t))),Noe=d(e=>Ae(e[0]),(e,t)=>U(fq(e.channel,t))),Uoe=d(2,(e,t)=>U(lq(e.channel,t))),Jq=(e,t)=>Cn(K(ks(t),r=>{let n=Fr.defaultValue(),o=()=>bh(vk(e,Fr,W(()=>n)),s=>Cn(ht(K(r(s),i=>(n=i,Cn(Pt(Vp,o())))),()=>I(wc(s)))));return o()})),Doe=d(e=>Ae(e[0]),(e,t,r)=>vn(()=>{let n=r?.preventFallbackOnPartialStream??!1,o=0,s={attempt:0,stepIndex:0},i=vk(ty,W(()=>(s={attempt:s.attempt+1,stepIndex:o},s))),a=r?.onEvent===void 0?void 0:F0(r.onEvent,()=>s),c,u=a===void 0?F:m=>Rz(Oz(m,K(a.begin,h=>{c=h})),h=>L(()=>{if(c===void 0)return P;let x=c;return c=void 0,a.end(x,h)})),f=_(),p=vn(()=>{let m=t.steps[o];if(!m)return wc(kI(f));let h=i(u(Pz(e,m.provide))),x=!1;if(de(f)){let g=f.value,y=!1,E=h;h=vn(()=>y?E:(y=!0,wc(g))),h=Jq(h,qp(m,!1))}else{let g=qp(m,!0);h=g?Jq(h,g):h}return bh(n?_z(h,g=>(x=!0,P)):h,g=>(o++,n&&x?wc(g):(f=N(g),p)))});return p})),Loe=d(2,(e,t)=>{let r=Bt(t);return r===0?Js:mz(e,(n,o)=>o===r-1)}),Boe=d(3,(e,t,r)=>vn(()=>{let n=xy(t),o=BigInt(0),s=!1;return mf(xz(e,i=>{let a=o+BigInt(i.length);return a>n?(s=!0,!1):(o=a,!0)}),vn(()=>s?r():Js))})),$oe=d(2,(e,t)=>{let r=Bt(t);return r===0?Js:gf(e,Ta,(n,o)=>(rb(n,o),n.length>r&&ob(n,n.length-r),[n,va]),{onHalt(n){return Ec(n)}})}),mz=d(e=>Ae(e[0]),(e,t,r)=>br(e,(n,o)=>W(()=>{let s=0,i=!1;return A(L(()=>i?se():n),c=>{let u=c.findIndex(f=>t(f,s++));if(u>=0){i=!0;let f=c.slice(0,r?.excludeLast?u:u+1);return bt(f)?I(f):se()}return I(c)})}))),hz=d(e=>Ae(e[0]),(e,t,r)=>br(e,(n,o)=>W(()=>{let s=0,i=!1;return xt(function*(){if(i)return yield*se();let a=yield*n;for(let c=0;c<a.length;c++)if(yield*t(a[c],s++)){i=!0;let u=a.slice(0,r?.excludeLast?c:c+1);return bt(u)?u:yield*se()}return a})}))),xz=d(2,(e,t)=>br(e,(r,n)=>W(()=>{let o=0,s=!1,i=A(L(()=>s?se():r),a=>{let c=[];for(let u=0;u<a.length;u++){if(!t(a[u],o++)){s=!0;break}c.push(a[u])}return bt(c)?I(c):s?se():i});return i}))),joe=d(2,(e,t)=>br(e,(r,n)=>W(()=>{let o=!1,s=A(L(()=>o?se():r),i=>{let a=[];for(let c=0;c<i.length;c++){let u=t(i[c]);if(be(u)){o=!0;break}a.push(u.success)}return bt(a)?I(a):o?se():s});return s}))),Hoe=d(2,(e,t)=>hz(e,(r,n)=>K(t(r,n),o=>!o),{excludeLast:!0})),Ik=d(2,(e,t)=>{let r=Bt(t);return r===0?e:br(e,(n,o)=>W(()=>{let s=0,i=n.pipe(A(a=>s>=r?I(a):(s+=a.length,s<=r?i:I(a.slice(r-s)))));return i}))}),qoe=d(2,(e,t)=>Ik(gz(e,(r,n)=>!t(r,n)),1)),zoe=d(2,(e,t)=>Ik(yz(e,(r,n)=>K(t(r,n),o=>!o)),1)),gz=d(2,(e,t)=>br(e,(r,n)=>W(()=>{let o=!0,s=0,i=A(r,a=>{let c=a.findIndex(u=>!t(u,s++));return c===-1?i:(o=!1,I(a.slice(c)))});return L(()=>o?i:r)}))),Woe=d(2,(e,t)=>br(e,(r,n)=>W(()=>{let o=!0,s=A(r,i=>{let a=i.findIndex(c=>be(t(c)));return a===-1?s:(o=!1,I(i.slice(a)))});return L(()=>o?s:r)}))),yz=d(2,(e,t)=>br(e,(r,n)=>W(()=>{let o=!0,s=0,i=xt(function*(){for(;;){let a=yield*r;for(let c=0;c<a.length;c++)if(!(yield*t(a[c],s++)))return o=!1,a.slice(c)}});return L(()=>o?i:r)}))),Koe=d(2,(e,t)=>{let r=Bt(t);return r===0?e:br(e,(n,o)=>W(()=>{let s=Ta(),i=A(n,a=>{nb(s,a);let c=s.length-r,u=nf(s,c);return Gr(u)?I(u):i});return i}))}),Sz=e=>e.channel.pipe(Gs(Me),U),bz=d(2,(e,t)=>(t=Lo(t),br(e,(r,n)=>W(()=>{let o=Qt(),s=0,i,a=!1;return L(function c(){if(a)return se();if(i===void 0)return A(r,u=>{if(o.length===0&&u.length===t)return I(u);if(o.length+u.length<t){for(let f=0;f<u.length;f++)o.push(u[f]);return c()}return i=u,c()});for(;s<i.length;)if(o.push(i[s++]),o.length===t){let u=o;return o=[],I(u)}return s=0,i=void 0,c()}).pipe(ht(()=>{if(o.length===0)return se();let c=o;return a=!0,o=[],I(c)}))})))),Voe=d(2,(e,t)=>Ez(e,t,1)),Ez=d(3,(e,t,r)=>{let n=Lo(t),o=Lo(r);return br(e,(s,i)=>W(()=>{let a=null,c=Ta(),u=!1,f=0,p=Un(s,{onSuccess(m){if(nb(c,m),f>0){let x=c.length;ob(c,f),f=Math.max(0,f-x)}if(c.length<n)return p;u=!0;let h=[];for(;c.length>=n;)if(n===o)h.push(nf(c,n));else{h.push(nH(c,n));let x=c.length;ob(c,o),f=Math.max(0,o-x)}return I(h)},onFailure(m){return c.length===0||u&&c.length<=n-o?je(m):(a=m,I(Me(Ec(c))))}});return L(()=>a?je(a):p)}))}),Goe=d(2,(e,t)=>gf(e,Qt,(r,n)=>{let o=Qt();for(let s=0;s<n.length;s++)t(n[s])?Gr(r)&&(o.push(r),r=[]):r.push(n[s]);return[r,o]},{onHalt(r){return Gr(r)?Me(r):va}})),Joe=d(4,(e,t,r,n)=>XA(wn(e.channel),wn(t.channel),r,n).pipe(Gs(Me),U)),Zoe=d(4,(e,t,r,n)=>U(XA(e.channel,t.channel,r,n))),Qoe=d(e=>Ae(e[0]),(e,t,r,n)=>U(bd(e.channel,t,(o,s)=>{let i=Qt();for(let a=0;a<s.length;a++){let[c,u]=r(o,s[a]);o=c,i.push(...u)}return[o,Gr(i)?Me(i):va]},n?.onHalt?{onHalt(o){let s=n.onHalt(o);return bt(s)?Me(s):va}}:void 0))),gf=d(e=>Ae(e[0]),(e,t,r,n)=>U(bd(e.channel,t,(o,s)=>{let[i,a]=r(o,s);return o=i,[o,bt(a)?Me(a):va]},n?.onHalt?{onHalt(o){let s=n.onHalt(o);return bt(s)?Me(s):va}}:void 0))),va=Qt(),Yoe=d(e=>Ae(e[0]),(e,t,r,n)=>e.channel.pipe(wn,bd(t,(o,s)=>K(r(o,s),([i,a])=>[i,bt(a)?Me(a):Qt()]),n?.onHalt?{onHalt(o){let s=n.onHalt(o);return bt(s)?Me(s):va}}:void 0),U)),Xoe=d(e=>Ae(e[0]),(e,t,r,n)=>e.channel.pipe(bd(t,(o,s)=>K(r(o,s),([i,a])=>[i,bt(a)?Me(a):va]),n?.onHalt?{onHalt(o){let s=n.onHalt(o);return bt(s)?Me(s):va}}:void 0),U)),ese=d(3,(e,t,r)=>vn(()=>{let n=t();return mf(pf(n),U(bd(e.channel,()=>n,(o,s)=>{let i=Qt();for(let a=0;a<s.length;a++)o=r(o,s[a]),i.push(o);return[o,Me(i)]})))})),tse=d(3,(e,t,r)=>vn(()=>e.channel.pipe(wn,XH(t(),r),Gs(Me),U))),rse=d(2,(e,t)=>br(e,me(function*(r,n){let o=yield*Yn,s=Wt($e(t)),i,a,c=1/0,u=jr(),f=jr(),p=jr();yield*r.pipe(u.whenOpen,A(h=>(f.openUnsafe(),i=h,c=o.currentTimeMillisUnsafe()+s,P)),Mt({disableYield:!0}),to(h=>(a=h,c=o.currentTimeMillisUnsafe(),f.openUnsafe(),p.openUnsafe(),P)),gt(n));let m=L(function h(){let x=o.currentTimeMillisUnsafe(),g=c<x?s:Math.min(s,c-x);return A(Ya(ua(g),p.await),()=>{if(o.currentTimeMillisUnsafe()<c)return h();if(i){f.closeUnsafe(),u.closeUnsafe();let E=I(Me(jf(i)));return i=void 0,E}else if(a)return je(a);return h()})});return L(()=>{if(a){if(i){let h=I(Me(jf(i)));return i=void 0,h}return je(a)}return u.openUnsafe(),f.whenOpen(m)})}))),Iz=d(2,(e,t)=>{let r=t.burst??0;return t.strategy==="enforce"?nse(e,t.cost,t.units,t.duration,r):ose(e,t.cost,t.units,t.duration,r)}),nse=(e,t,r,n,o)=>br(e,s=>bu(i=>{let a=Wt($e(n)),c=r+o<0?Number.POSITIVE_INFINITY:r+o,u=r,f=i.currentTimeMillisUnsafe();return I(A(s,function p(m){return A(t(m),h=>{let x=i.currentTimeMillisUnsafe(),y=(x-f)/a,E=u+y*r,b=E<0?c:Math.min(E,c);return h<=b?(u=b-h,f=x,I(m)):A(s,p)})}))})),ose=(e,t,r,n,o)=>br(e,s=>bu(i=>{let a=Wt($e(n)),c=r+o<0?Number.POSITIVE_INFINITY:r+o,u=r,f=i.monotonicTimeNanosUnsafe();return I(A(s,p=>A(t(p),m=>{let h=i.monotonicTimeNanosUnsafe(),g=Number(h-f)/1e6/a,y=u+g*r,b=Math.min(y,c)-m;if(b>=0)return u=b,f=h,I(p);let v=-b/r,T=Math.max(0,v*a);return T>0?A(ua(T),()=>(u=b,f=h,I(p))):(u=b,f=h,I(p))})))})),sse=d(2,(e,t)=>Iz(e,{...t,cost:r=>I(t.cost(r))})),ise=d(2,(e,t)=>Sz(bz(e,t))),ase=d(3,(e,t,r)=>Tk(e,Dq(Lo(t)),hl(r))),cse=d(e=>Ae(e[0]),(e,t,r)=>Tz(e,me(function*(n,o,s){for(let i=0;i<n.length;i++){let[a,c]=yield*t(n[i]),u=Qr(s,a),f=de(u)?u.value:yield*ec(uk(o,a));yield*fk(o,a),yield*jn(f,c)}}),r)),use=d(e=>Ae(e[0]),(e,t,r)=>vn(()=>{let n=Si();return Tz(e,me(function*(o,s,i){for(let a=0;a<o.length;a++){let c=t(o[a]),u=Qr(n,c);fe(u)?bi(n,c,[o[a]]):u.value.push(o[a])}for(let[a,c]of n){let u=Qr(i,a),f=de(u)?u.value:yield*ec(uk(s,a));yield*fk(s,a),yield*wa(f,c)}ny(n)}),r)})),Tz=(e,t,r)=>dk(e,me(function*(n,o,s){let i=yield*Sb();yield*It(o,ss(i));let a=Si(),c=yield*$q({lookup:u=>Ti(io({capacity:r?.bufferSize??4096}).pipe(_t(f=>(bi(a,u,f),jn(i,[u,gh(f)])))),f=>(Ei(a,u),yd(f))),idleTimeToLive:r?.idleTimeToLive??Ss}).pipe(zo(s));return yield*xn({while:nr,body:qe(A(n,u=>t(u,c,a))),step:Rr}).pipe(rt(u=>Ht(i,u)),gt(o)),af(i)})),fse=d(2,(e,t)=>br(e,(r,n)=>W(()=>{let o,s,i=Qt(),a=r.pipe(A(u=>{for(let f=0;f<u.length;f++){let p=u[f],m=t(p);if(s===void 0){o=m,s=[p];continue}else if(Z(m,o)){s.push(p);continue}i.push([o,s]),o=m,s=[p]}if(Gr(i)){let f=i;return i=[],I(f)}return a})),c=!1;return ht(L(()=>c?se():a),()=>{c=!0;let u=s;return s=void 0,u&&Gr(u)?I(Me([o,u])):se()})}))),lse=d(2,(e,t)=>br(e,(r,n)=>W(()=>{let o,s,i=L(()=>{if(s!==void 0){let c=s;return s=void 0,I(c)}return r}).pipe(gu(c=>(o=Jn(c),se()))),a=K(L(()=>t.transform(i,n)),([c,u])=>(s=u,Me(c)));return L(()=>o||a)}))),dse=d(2,(e,t)=>Tk(e,t,$p)),Tk=d(3,(e,t,r)=>U(Vs(me(function*(n,o,s){let i=yield*as(e.channel,o),a=jr(!1),c=Symbol(),u=yield*io({capacity:0});yield*i.pipe(a.whenOpen,A(S=>(a.closeUnsafe(),jn(u,S))),Mt,rt(S=>Ht(u,S)),gt(s));let f=yield*Yn,p=yield*Qa(r),m=jr(!1),h=f.currentTimeMillisUnsafe(),x=0,g=_(),y,E=S=>(m.openUnsafe()&&(x=f.currentTimeMillisUnsafe()),I(S)),b=m.await.pipe(A(()=>p(h,g)),A(([,S])=>ua(S)),A(()=>jn(u,c)),ht(()=>yd(u)),A(()=>Xn)),v=L(()=>{if(y!==void 0){let S=y;return y=void 0,E(S)}return u.state._tag==="Open"&&a.openUnsafe(),A(Ws(u),S=>S===c?se():E(S))}),T=A(([S,w])=>{if(m.isOpen())h+=f.currentTimeMillisUnsafe()-x;else if(u.state._tag==="Done")return se();return g=N(S),y=w,I(Me(S))});return L(()=>{if(u.state._tag==="Done"&&y===void 0)return u.state.exit;m.closeUnsafe();let S=T(L(()=>t.transform(v,s)));return u.state._tag==="Open"?Ya(S,b):S})})))),pse=d(2,me(function*(e,t){let r=Bt(t.n),n=yield*mse(t),o=new Array(r),s=yield*it;for(let i=0;i<r;i++){let a=yr(s),c=yield*lh(n).pipe(Jo(it,a));o[i]=ZA(hb(c)).pipe(mh(u=>Ve(a,u)),U)}return yield*lf(e.channel,i=>mb(n,i)).pipe(Xr(i=>pb(n,i)),Rs),o})),mse=e=>Ti(e.capacity==="unbounded"?uh(e):e.strategy==="dropping"?lb(e):e.strategy==="sliding"?db(e):fb(e),fh),wz=d(2,(e,t)=>K(Nz(e,t),tz)),hse=d(2,(e,t)=>K(Kq({acquire:wz(e,t),idleTimeToLive:t.idleTimeToLive}),r=>Cn(Vq(r)))),xse=d(2,(e,t)=>U(ek(e.channel,t))),gse=d(2,(e,t)=>U(tk(e.channel,t))),yse=d(2,(e,t)=>e.channel.pipe(tk(Uq(t)),BH(([r,n])=>n?vb(n):Sd),U)),Sse=e=>Ub(Fz(e)),bse=e=>gf(e,Qt,(t,r)=>{let n=up(t,r);return[n,[n]]}),vz=e=>Cz(e,Z),Cz=d(2,(e,t)=>br(e,(r,n)=>W(()=>{let o=!0,s;return A(r,function i(a){let c=[],u=0;for(o&&(o=!1,s=a[0],u=1,c.push(s));u<a.length;u++){let f=a[u];t(f,s)||(s=f,c.push(f))}return Gr(c)?I(c):A(r,i)})}))),Ese=d(2,(e,t)=>br(e,(r,n)=>W(()=>{let o=!0,s;return A(r,me(function*i(a){let c=[],u=0;for(o&&(o=!1,s=a[0],u=1,c.push(s));u<a.length;u++){let f=a[u];(yield*t(f,s))||(s=f,c.push(f))}return Gr(c)?c:yield*A(r,me(i))}))}))),Ise=d(e=>Ae(e[0]),(e,t)=>vn(()=>{let r=new TextDecoder(t?.encoding);return ao(e,n=>r.decode(n,{stream:!0}))})),Tse=e=>vn(()=>{let t=new TextEncoder;return ao(e,r=>t.encode(r))}),wse=e=>e.channel.pipe(ek(mq()),U),Az=d(2,(e,t)=>nz(e,(r,n)=>{let o=n===0?[]:[t],s=r.length-1;for(let i=0;i<r.length;i++)i===s?o.push(r[i]):o.push(r[i],t);return o})),vse=d(2,(e,t)=>pf(t.start).pipe(mf(Az(e,t.middle)),mf(pf(t.end)))),Cse=d(2,(e,t)=>kz(e,t,hf(W_([!0,!1])))),kz=d(3,(e,t,r)=>U(De(me(function*(n,o){let s=yield*we(wn(r.channel))(n,o),i=Symbol(),a=!1,c=!1,u=(yield*we(wn(e.channel))(n,o)).pipe(ht(()=>(a=!0,I(i)))),f=(yield*we(wn(t.channel))(n,o)).pipe(ht(()=>(c=!0,I(i))));return xt(function*(){for(;;){if(a&&c)return yield*se();let p=yield*s;if(p&&a||!p&&c)continue;let m=yield*p?u:f;if(m!==i)return Me(m)}})})))),Ase=d(2,(e,t)=>U(rk(e.channel,t))),kse=d(2,(e,t)=>U(yq(e.channel,t))),Rz=d(2,(e,t)=>U(mh(e.channel,t))),Rse=d(2,(e,t)=>U(Sq(e.channel,t))),Oz=d(2,(e,t)=>U(bq(e.channel,t))),_z=d(2,(e,t)=>U(nk(e.channel,r=>t(r[0])))),Ose=d(2,(e,t)=>U(Eq(e.channel,t))),Eh=d(2,(e,t)=>U(Iq(e.channel,t))),Pz=d(e=>Ae(e[0]),(e,t,r)=>U(Tq(e.channel,t,r))),wk=d(2,(e,t)=>U(Pb(e.channel,t))),_se=d(3,(e,t,r)=>U(Mb(e.channel,t,r))),vk=d(3,(e,t,r)=>U(Fb(e.channel,t,r))),Mz=d(2,(e,t)=>U(wq(e.channel,t))),Pse=d(3,(e,t,r)=>Mz(e,n=>We(n,t,r(Re(n,t))))),Mse=function(){let e=Ae(arguments[0]),t=e?arguments[1]:arguments[0],r=Ho(e?arguments[2]:arguments[1]);if(e){let n=arguments[0];return U(ok(n.channel,t,r))}return n=>U(ok(n.channel,t,r))},Fse=pf({}),Nse=d(3,(e,t,r)=>ao(e,n=>({...n,[t]:r(n)})));var Use=d(e=>Ae(e[0]),(e,t,r,n)=>Id(e,o=>ao(r(o),s=>({...o,[t]:s})),n)),Dse=d(e=>Ae(e[0]),(e,t,r,n)=>xf(e,o=>K(r(o),s=>({...o,[t]:s})),n)),Lse=d(2,(e,t)=>ao(e,r=>({[t]:r}))),Bse=d(2,(e,t)=>Sl(r=>as(e.channel,r).pipe(A(n=>t.transform(n,r)),K(([n])=>n)))),Fz=e=>df(e.channel,()=>[],(t,r)=>{for(let n=0;n<r.length;n++)t.push(r[n]);return t}),$se=e=>df(e.channel,()=>0,(t,r)=>t+r.length),jse=e=>df(e.channel,()=>0,(t,r)=>{for(let n=0;n<r.length;n++)t+=r[n];return t}),Hse=d(3,(e,t,r)=>df(e.channel,t,(n,o)=>{for(let s=0;s<o.length;s++)n=r(n,o[s]);return n})),qse=d(3,(e,t,r)=>Rq(e.channel,t,(n,o)=>{let s=0,i=n;return K(xn({while:()=>s<o.length,body:()=>r(i,o[s]),step(a){i=a,s++}}),()=>i)})),zse=e=>K(Aq(e.channel),Lt(X_(0))),Wse=e=>K(kq(e.channel),Lt(jf)),Kse=d(2,(e,t)=>lf(e.channel,r=>{let n=0;return xn({while:()=>n<r.length,body:()=>t(r[n++]),step:Rr})})),Vse=d(2,(e,t)=>Cq(e.channel,r=>{let n=!1,o=0;return K(xn({while:()=>!n&&o<r.length,body:()=>t(r[o]),step(s){o++,s||(n=!0)}}),()=>!n)})),Td=d(2,(e,t)=>lf(e.channel,t)),$b=e=>vq(e.channel),Ck=e=>ik(e.channel),Gse=e=>df(e.channel,()=>"",(t,r)=>t+r.join("")),Jse=e=>K(sk(e.channel),t=>t.buffer),Zse=e=>sk(e.channel),Ak=d(e=>Ae(e[0]),(e,t,r)=>{let n,o,s=!1,i=jr(!1),a=r?.signal,c=()=>o.interruptUnsafe();return new ReadableStream({start(u){o=Yp(Ur(Td(e,f=>i.whenOpen(W(()=>{i.closeUnsafe();for(let p=0;p<f.length;p++)u.enqueue(f[p]);n(),n=void 0}))),t)),o.addObserver(f=>{a?.removeEventListener("abort",c),!s&&(f._tag==="Failure"&&a?.aborted!==!0?u.error(fu(f.cause)):u.close())}),a!==void 0&&o.pollUnsafe()===void 0&&(a.aborted?c():a.addEventListener("abort",c,{once:!0}))},pull(){return new Promise(u=>{n=u,i.openUnsafe()})},cancel(){if(o)return s=!0,ow(vo(Tn(o)))}},r?.strategy)}),Qse=d(e=>Ae(e[0]),(e,t)=>Ak(e,pt(),t)),kk=d(e=>Ae(e[0]),(e,t)=>K(Nr(),r=>Ak(e,r,t))),Rk=d(2,(e,t)=>({[Symbol.asyncIterator](){let r=sw(t),n=Sr(t),o=Zn(),s,i,a,c,u=p=>{if(c)return c;let m=a;return c=r(Pt(Vt(m?Tn(m):P,Ve(o,p)),{done:!0,value:void 0})),c},f=async p=>{try{await u(p)}catch(m){await r(Xp("Suppressed error while closing Stream async iterator",m))}};return{async next(){if(c)return c;if(i){let h=i.next();if(!h.done)return h;i=void 0}let p=n(s??A(as(e.channel,o),h=>(s=h,h)));a=p;let m=await r(Yj(p));if(a===p&&(a=void 0),ft(m))return i=m.value[Symbol.iterator](),i.next();if(wo(m.cause))return u(Kt);if(c&&a0(m.cause))return c;throw await f(m),fu(m.cause)},return(){return u(Kt)},async throw(p){throw await f(Dg(p)),p}}}})),Yse=e=>K(Nr(),t=>Rk(e,t)),Xse=e=>Rk(e,pt()),eie=d(e=>Ae(e[0]),(e,t,r)=>ck(e.channel,t,r)),tie=d(2,(e,t)=>Pq(e.channel,t)),Nz=d(2,(e,t)=>Mq(e.channel,t)),rie=d(2,(e,t)=>Oq(e.channel,t)),nie=d(2,(e,t)=>ak(e.channel,t));var Uz="~effect/PrimaryKey";var Lz="~effect/Pool",Hz=Symbol(),qz=Symbol(),_k=Symbol();var zz=e=>Kz({...e,min:e.size,max:e.size,strategy:Hb}),Wz=e=>A(e.timeToLiveStrategy==="creation"?die(e.timeToLive):pie(e.timeToLive),t=>Kz({...e,strategy:t})),Kz=e=>en(me(function*(t){let r=yield*Nr(),n=Re(r,it),o=Xa(e.acquire,u=>Kr(r,u)),s=e.concurrency??1,i={acquire:o,concurrency:s,isFixed:e.min===e.max,minSize:e.min,maxSize:e.max,strategy:e.strategy,targetUtilization:Math.min(Math.max(e.targetUtilization??1,.1),1)},a={scope:n,isShuttingDown:!1,usage:0,resizeSemaphore:uf(1),items:new Set,availableHead:void 0,availableTail:void 0,invalidated:new Set,waiters:new Set},c={[Lz]:Lz,[Hz]:e.acquire,[qz]:r,[_k]:yield*Yn,config:i,state:a,pipe(){return V(this,arguments)}};return yield*It(n,oie(c)),i.minSize>0&&(yield*_t(Il(t(jb(c)),{startImmediately:!0}),u=>It(n,Tn(u)))),e.strategy!==Hb&&(yield*_t(Il(t(e.strategy.run(c))),u=>It(n,Tn(u)))),c})),oie=me(function*(e){if(e.state.isShuttingDown)return;e.state.isShuttingDown=!0;let t=e.state.items.size,r=uf(t);for(let n of e.state.items)n.refCount>0?(n.finalizer=_t(n.finalizer,r.release(1)),e.state.invalidated.add(n),yield*r.take(1)):(e.state.items.delete(n),Ih(e,n),e.state.invalidated.delete(n),yield*n.finalizer);if(e.state.waiters.size>0){let n=Array.from(e.state.waiters);e.state.waiters.clear();for(let o of n)o()}yield*r.take(t)}),Pk=e=>oe(t=>{let r=e.state;if(r.isShuttingDown)return nl;if(r.availableHead?.exit._tag==="Success"){if(r.usage++,e.config.isFixed||Th(e)<=wh(e))return Vz(e,r.availableHead,t);r.usage--}return sie(e,cie)});var sie=(e,t)=>Gn(r=>{let n=e.state;n.usage++;let o=Y(Tp(r(fie(e)),()=>ye(()=>{n.usage--})),()=>i),s=oe(a=>{if(n.isShuttingDown)return n.usage--,nl;let c=Mk(e)??(Th(e)<=wh(e)?n.availableHead:void 0);return c===void 0?o:c.exit._tag==="Failure"?(aie(e,c),i):t(e,c,a,r)}),i=ce(()=>n.isShuttingDown?(n.usage--,nl):Th(e)>wh(e)?Y(n.resizeSemaphore.withPermitsIfAvailable(1)(gt(vi(jb(e)),n.scope)),()=>s):s);return i}),iie=(e,t)=>{t.refCount++,t.refCount>=e.config.concurrency&&Ih(e,t)},aie=(e,t)=>{e.state.items.delete(t),e.state.invalidated.delete(t),Ih(e,t)},Vz=(e,t,r)=>{iie(e,t);let n=dn(r.context,it);return n.state._tag==="Closed"?Wa(r,t.release):za(n,{},t.release),t.exit},cie=(e,t,r)=>Vz(e,t,r),uie=(e,t)=>oe(r=>{let n=e.state;return t.refCount--,n.usage--,t.refCount===0&&(t.idleSince=e[_k].currentTimeMillisUnsafe()),n.invalidated.has(t)?Nk(e,t):(t.refCount<e.config.concurrency&&(lie(e,t),Gz(e,r,1)),pe)}),Mk=e=>{let t=e.state.availableHead;for(;t!==void 0&&t.exit._tag==="Failure";)t=t.availableNext;return t},fie=e=>$t(t=>{let r=e.state;if(Mk(e)!==void 0||r.isShuttingDown)return t(pe);let n=o=>{r.waiters.delete(n),t(o??pe)};return r.waiters.add(n),ye(()=>{r.waiters.delete(n)})}),Gz=(e,t,r)=>{let n=e.state.waiters;n.size!==0&&t.currentDispatcher.scheduleTask(()=>{let o=r,s=[];for(let i of n){if(o--<=0)break;s.push(i)}for(let i=0;i<s.length;i++)s[i]()},0)},Bz=e=>oe(t=>(Gz(e,t,Number.POSITIVE_INFINITY),pe)),Fk=new WeakMap,$z=(e,t)=>{t.isAvailable||Fk.has(t)||(t.isAvailable=!0,t.availablePrevious=e.state.availableTail,t.availableNext=void 0,e.state.availableTail!==void 0?e.state.availableTail.availableNext=t:e.state.availableHead=t,e.state.availableTail=t)},lie=(e,t)=>{t.isAvailable||Fk.has(t)||(t.isAvailable=!0,t.availablePrevious=void 0,t.availableNext=e.state.availableHead,e.state.availableHead!==void 0?e.state.availableHead.availablePrevious=t:e.state.availableTail=t,e.state.availableHead=t)},Ih=(e,t)=>{t.isAvailable&&(t.isAvailable=!1,t.availablePrevious!==void 0?t.availablePrevious.availableNext=t.availableNext:e.state.availableHead=t.availableNext,t.availableNext!==void 0?t.availableNext.availablePrevious=t.availablePrevious:e.state.availableTail=t.availablePrevious,t.availablePrevious=void 0,t.availableNext=void 0)};var Nk=(e,t)=>L(()=>{if(e.state.items.has(t)){if(t.refCount===0)return e.state.items.delete(t),Ih(e,t),e.state.invalidated.delete(t),vo(A(t.finalizer,()=>gt(vi(jb(e)),e.state.scope,{startImmediately:!0})))}else return P;return e.state.invalidated.add(t),Ih(e,t),vo(gt(vi(jb(e)),e.state.scope,{startImmediately:!0}))}),jb=e=>e.state.resizeSemaphore.withPermits(1)(Ok(e)),Ok=e=>L(()=>{let t=wh(e),r=Th(e);if(t>=r)return P;let n=r-t,o=e.config.strategy===Hb?jz(e):A(e.config.strategy.reclaim(e),i=>i?I(i):jz(e));if(n===1){let i=_t(o,Bz(e));return e.config.isFixed?vo(i):A(i,a=>a.exit._tag==="Failure"?P:Ok(e))}let s=o.pipe(ew(n,{concurrency:n}),_t(Bz(e)));return e.config.isFixed?vo(s):A(s,i=>i.some(a=>a.exit._tag==="Failure")?P:Ok(e))}),jz=e=>Gn(t=>oe(r=>{let n=e,o=tl(),s=r.context;r.setContext(We(n[qz],it,o));let i=A(eo(n[Hz]),a=>{let c={exit:a,finalizer:rt(Ve(o,a),mie),refCount:0,idleSince:n[_k].currentTimeMillisUnsafe(),disableReclaim:!1,isAvailable:!1,availablePrevious:void 0,availableNext:void 0,release:void 0};c.release=qe(uie(e,c));let u=L(()=>e.state.items.has(c)?e.config.strategy.onAcquire(c):P);if(a._tag==="Success")return e.state.items.add(c),$z(e,c),e.config.strategy===Hb?I(c):Pt(u,c);let f=Mk(e)===void 0?e.state.waiters.values().next().value:void 0;return f!==void 0?f(a):(e.state.items.add(c),$z(e,c)),Pt(gt(Vt(c.finalizer,u),e.state.scope,{startImmediately:!0}),c)});return Io(t(i),a=>(r.setContext(s),a._tag==="Failure"?el(o,a):void 0),!0)})),Th=e=>{if(e.state.isShuttingDown)return 0;if(e.config.isFixed)return e.config.minSize;let t=e.state.usage/e.config.targetUtilization,r=Math.ceil(t/e.config.concurrency);return Math.min(Math.max(e.config.minSize,r),e.config.maxSize)},wh=e=>e.state.items.size-e.state.invalidated.size,Hb={run:e=>P,onAcquire:e=>P,reclaim:e=>Kp},die=me(function*(e){let t=yield*Yn,r=yield*Sb(),n=Wt($e(e)),o=new WeakMap;return F({run:s=>{let i=a=>L(()=>{if(!s.state.items.has(a)||s.state.invalidated.has(a))return P;let c=t.currentTimeMillisUnsafe(),u=o.get(a),f=n-(c-u);return f>0?ca(i(a),f):Nk(s,a)});return Ws(r).pipe(_t(i),Mt({disableYield:!0}))},onAcquire:s=>L(()=>(o.set(s,t.currentTimeMillisUnsafe()),jn(r,s))),reclaim:s=>Kp})}),pie=me(function*(e){let t=yield*Yn,r=Wt($e(e));return F({run:n=>{let o=L(()=>{if(wh(n)<=Th(n))return P;let s=t.currentTimeMillisUnsafe()-r,i;for(let a of n.state.items)a.refCount>0||a.idleSince>s||n.state.invalidated.has(a)||Fk.has(a)||(i===void 0||a.idleSince<i.idleSince)&&(i=a);return i===void 0?P:A(Nk(n,i),()=>o)});return o.pipe(ca(e),Mt({disableYield:!0}))},onAcquire:n=>P,reclaim:n=>Kp})}),mie=e=>ar(t=>{let r=t.getRef(RN);return r?Tl(r)("Unhandled error in pool finalizer",e):P});var Zz="~effect/reactivity/Reactivity",vc=Ue("effect/reactivity/Reactivity"),hie=W(()=>{let e=new Map,t=c=>{Uk(c,u=>{let f=e.get(u);f!==void 0&&f.forEach(p=>p())})},r=c=>yn(u=>{let f=Vi(u,qb);return f?Uk(c,p=>{f.add(p)}):t(c),P}),n=(c,u)=>_t(u,r(c)),o=(c,u)=>{let f=[];return Uk(c,p=>{f.push(p);let m=e.get(p);m===void 0&&(m=new Set,e.set(p,m)),m.add(u)}),()=>{for(let p=0;p<f.length;p++){let m=e.get(f[p]);m!==void 0&&(m.delete(u),m.size===0&&e.delete(f[p]))}}},s=(c,u)=>xt(function*(){let f=yield*Nr(),p=Re(f,it),m=yield*io(),h=$c(Sr(f),Ni(p)),x=!1,g=!1,y=v=>{v._tag==="Failure"?Ui(m,v.cause):Ic(m,v.value),g?(g=!1,h(u).addObserver(y)):x=!1};function E(){if(x){g=!0;return}x=!0,h(u).addObserver(y)}let b=o(c,E);return yield*It(p,W(b)),E(),m}),i=(c,u)=>s(c,u).pipe(K(Sh),Cn),a=c=>L(()=>{let u=new Set;return c.pipe(Jo(qb,u),Xr(f=>W(()=>{u.forEach(p=>{let m=e.get(p);m!==void 0&&m.forEach(h=>h())})})))});return vc.of({[Zz]:Zz,mutation:n,query:s,stream:i,invalidateUnsafe:t,invalidate:r,registerUnsafe:o,withBatch:a})}),qb=class extends Ue()("effect/reactivity/Reactivity/PendingInvalidation"){},zb=d(2,(e,t)=>vc.use(r=>r.mutation(t,e)));var Wb=e=>vc.use(t=>t.invalidate(e)),Kb=Qn(vc)(hie);function Qz(e){switch(typeof e){case"string":case"number":case"bigint":case"boolean":return String(e);default:return G(e)}}var Uk=(e,t)=>{if(Array.isArray(e)){for(let r=0;r<e.length;r++)t(Qz(e[r]));return}for(let r in e){t(r);let n=e[r];for(let o=0;o<n.length;o++)t(`${r}:${Qz(n[o])}`)}};var Yz="~effect/SubscriptionRef",vh=e=>O(e,Yz),Pye={...wr,[Yz]:{_A:F},toJSON(){return{_id:"SubscriptionRef",value:this.value}}};var Dk=e=>pk(e.pubsub);var Xz=e=>W(()=>e.value);var xie=(e,t)=>{e.value=t,iH(e.pubsub,t)};var Lk=d(2,(e,t)=>e.semaphore.withPermit(W(()=>xie(e,t))));var iE={};ps(iE,{Fetch:()=>CW,RequestInit:()=>sE,layer:()=>Lie});var Bk="~effect/http/HttpBody";var tW="~effect/http/HttpBody/HttpBodyError",rW=class extends sr("HttpBodyError"){[tW]=tW};var Gb=class{[Bk];constructor(){this[Bk]=Bk}[Qe](){return this.toJSON()}toString(){return H(this,{ignoreToString:!0})}},$k=class extends Gb{_tag="Empty";toJSON(){return{_id:"effect/HttpBody",_tag:"Empty"}}},nW=new $k;var Ch=class extends Gb{_tag="Uint8Array";contentType;contentLength;text;_body;constructor(t,r,n,o){super(),this._body=t,this.text=o,this.contentType=r,this.contentLength=n}get body(){return this._body??=gie(this.text)}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}}},jk=(e,t)=>new Ch(e,t??"application/octet-stream",e.length),oW=new TextEncoder,Jb=globalThis.Buffer,gie=Jb!==void 0?e=>Jb.from(e,"utf8"):e=>oW.encode(e),Hk=(e,t)=>{if(typeof e!="string"&&(e=e===void 0?"":String(e)),Jb!==void 0)return new Ch(void 0,t??"text/plain",Jb.byteLength(e,"utf8"),e);let r=oW.encode(e);return new Ch(r,t??"text/plain",r.length,e)};var zk="~effect/http/HttpClientError";var co=class extends sr("HttpClientError"){constructor(t){"cause"in t.reason?super({...t,cause:t.reason.cause}):super(t)}[zk]=zk;get request(){return this.reason.request}get response(){return"response"in this.reason?this.reason.response:void 0}get message(){return this.reason.message}},kh=e=>e.endsWith("Error")?e.slice(0,-5):e,Rh=(e,t,r)=>t?`${e}: ${t} (${r})`:`${e} error (${r})`,Zb=class extends sr("TransportError"){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return Rh(kh(this._tag),this.description,this.methodAndUrl)}};var Qb=class extends sr("InvalidUrlError"){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return Rh(kh(this._tag),this.description,this.methodAndUrl)}},Ah=class extends sr("StatusCodeError"){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let t=`${this.response.status} ${this.methodAndUrl}`;return Rh(kh(this._tag),this.description,t)}},Cc=class extends sr("DecodeError"){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let t=`${this.response.status} ${this.methodAndUrl}`;return Rh(kh(this._tag),this.description,t)}},Yb=class extends sr("EmptyBodyError"){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let t=`${this.response.status} ${this.methodAndUrl}`;return Rh(kh(this._tag),this.description,t)}},wd=class e extends Ar(zk)({_tag:He("HttpError"),kind:Fo(["EncodeError","DecodeError","TransportError","InvalidUrlError","StatusCodeError","EmptyBodyError"]),cause:lr(er())}){static fromHttpClientError(t){return new e({_tag:"HttpError",kind:t.reason._tag,cause:t.reason})}};var sW=[["GET","get"],["POST","post"],["PUT","put"],["DELETE","del"],["PATCH","patch"],["HEAD","head"],["OPTIONS","options"],["TRACE","trace"],["QUERY","query"]];var aW=(e,t)=>t._tag==="Empty"||t._tag==="FormData"?oc(oc(e,"content-type"),"content-length"):(e=t.contentType===void 0?oc(e,"content-type"):fm(e,"content-type",t.contentType),t.contentLength===void 0?oc(e,"content-length"):fm(e,"content-length",t.contentLength.toString()));var eE=class extends sr("UrlError"){},tE=(e,t,r)=>Ux({try:()=>{let n=new URL(e,Sie());for(let o=0;o<t.params.length;o++){let[s,i]=t.params[o];i!==void 0&&n.searchParams.append(s,i)}return r!==void 0&&(n.hash=r),n},catch:n=>new eE({cause:n})}),Sie=()=>{if("location"in globalThis&&globalThis.location!==void 0&&globalThis.location.origin!==void 0&&globalThis.location.pathname!==void 0)return location.origin+location.pathname};var cW="~effect/http/HttpClientRequest";var bie={[cW]:cW,...Ot,toJSON(){return{_id:"HttpClientRequest",method:this.method,url:this.url,urlParams:this.urlParams,hash:this.hash,headers:ho(this.headers),body:this.body.toJSON()}},pipe(){return V(this,arguments)}};function Bi(e,t,r,n,o,s){let i=Object.create(bie);return i.method=e,i.url=t,i.urlParams=r,i.hash=n,i.headers=o,i.body=s,i}var Eie=Bi("GET","",s1,_(),kl,nW),uW=e=>(t,r)=>Iie(Eie,{method:e,url:t,...r??void 0});var Iie=d(2,(e,t)=>{let r=e;return t.method&&(r=fW(r,t.method)),t.url&&(r=pW(r,t.url)),t.headers&&(r=Kk(r,t.headers)),t.urlParams&&(r=vie(r,t.urlParams)),t.hash&&(r=Cie(r,t.hash)),t.body&&(r=hW(r,t.body)),t.accept&&(r=dW(r,t.accept)),t.acceptJson&&(r=Tie(r)),r}),fW=d(2,(e,t)=>Bi(t,e.url,e.urlParams,e.hash,e.headers,e.body)),lW=d(3,(e,t,r)=>Bi(e.method,e.url,e.urlParams,e.hash,fm(e.headers,t,r),e.body)),Kk=d(2,(e,t)=>Bi(e.method,e.url,e.urlParams,e.hash,r1(e.headers,t),e.body));var dW=d(2,(e,t)=>lW(e,"Accept",t)),Tie=dW("application/json"),pW=d(2,(e,t)=>{if(typeof t=="string")return Bi(e.method,t,e.urlParams,e.hash,e.headers,e.body);let r=new URL(t.toString()),n=Mu(r.searchParams),o=Xc(r.hash===""?void 0:r.hash.slice(1));return r.search="",r.hash="",Bi(e.method,r.toString(),n,o,e.headers,e.body)}),mW=d(2,(e,t)=>t===""?e:Bi(e.method,wie(t,e.url),e.urlParams,e.hash,e.headers,e.body));var wie=(e,t)=>{let r=e.endsWith("/"),n=t.startsWith("/");return r&&n?e+t.slice(1):!r&&!n?e+"/"+t:e+t};var vie=d(2,(e,t)=>Bi(e.method,e.url,a1(e.urlParams,t),e.hash,e.headers,e.body));var Cie=d(2,(e,t)=>Bi(e.method,e.url,e.urlParams,N(t),e.headers,e.body));var hW=d(2,(e,t)=>Bi(e.method,e.url,e.urlParams,e.hash,aW(e.headers,t),t));function xW(e){let t=tE(e.url,e.urlParams,_n(e.hash));return tt(t)?N(t.success):_()}var yf="~effect/http/HttpIncomingMessage";var gW=(e,t)=>{let r=e.headers["content-type"]??"",n;if(r.includes("application/json"))try{n=Ai(e.json)}catch{}else if(r.includes("text/")||r.includes("urlencoded"))try{n=Ai(e.text)}catch{}let o={...t,headers:ho(e.headers),remoteAddress:e.remoteAddress};return n!==void 0&&(o.body=n),o};var vd="~effect/http/HttpClientResponse",yW=(e,t)=>new Gk(e,t);var Gk=class extends bx{[yf];[vd];request;source;constructor(t,r){super(),this.request=t,this.source=r,this[yf]=yf,this[vd]=vd}toJSON(){return gW(this,{_id:"HttpClientResponse",request:this.request.toJSON(),status:this.status})}get status(){return this.source.status}get url(){if(this.source.url)return this.source.url.split("#")[0];let t=xW(this.request);return fe(t)?"":(t.value.hash="",t.value.href)}get headers(){return Zo(this.source.headers)}cachedCookies;get cookies(){return this.cachedCookies?this.cachedCookies:this.cachedCookies=My(this.source.headers.getSetCookie?.()??[])}get remoteAddress(){return _()}get stream(){return this.source.body?mk({evaluate:()=>this.source.body,onError:t=>new co({reason:new Cc({request:this.request,response:this,cause:t})})}):wc(new co({reason:new Yb({request:this.request,response:this,description:"can not create stream from empty body"})}))}get json(){return A(this.text,t=>Go({try:()=>t===""?null:JSON.parse(t),catch:r=>new co({reason:new Cc({request:this.request,response:this,cause:r})})}))}textBody;get text(){return this.textBody??=K(this.arrayBuffer,t=>new TextDecoder().decode(t))}get urlParamsBody(){return A(this.text,t=>Go({try:()=>Mu(new URLSearchParams(t)),catch:r=>new co({reason:new Cc({request:this.request,response:this,cause:r})})}))}formDataBody;get formData(){return this.formDataBody??=Vo({try:()=>this.source.formData(),catch:t=>new co({reason:new Cc({request:this.request,response:this,cause:t})})}).pipe(ly,Ai)}arrayBufferBody;get arrayBuffer(){return this.arrayBufferBody?this.arrayBufferBody:(this.arrayBufferBody=Vo({try:()=>this.source.arrayBuffer(),catch:t=>new co({reason:new Cc({request:this.request,response:this,cause:t})})}).pipe(ly,Ai),this.arrayBufferBody)}pipe(){return V(this,arguments)}};var SW=e=>t1({b3:`${e.traceId}-${e.spanId}-${e.sampled?"1":"0"}${Zt(e.parent,{onNone:()=>"",onSome:t=>`-${t.spanId}`})}`,traceparent:`00-${e.traceId}-${e.spanId}-${e.sampled?"01":"00"}`});var Aie={"http:":80,"https:":443,"ws:":80,"wss:":443},EW=(e,t)=>{let r=t.search.slice(1);if(e.attribute("url.full",t.toString()),e.attribute("url.path",t.pathname),r!==""&&e.attribute("url.query",r),e.attribute("url.scheme",t.protocol.slice(0,-1)),t.hostname!==""){e.attribute("server.address",t.hostname.startsWith("[")?t.hostname.slice(1,-1):t.hostname);let n=t.port===""?Aie[t.protocol]:Number(t.port);n!==void 0&&e.attribute("server.port",n)}},Zk=(e,t,r,n,o)=>{for(let s in r)n(s,t)&&e.attribute(`http.${t}.header.${s}`,n1(s,o)?"<redacted>":r[s])};var IW="~effect/http/HttpClient";var Qk=Ue("effect/HttpClient");var Rie=d(2,(e,t)=>Yk(r=>t(e.postprocess(r)),e.preprocess));var Yk=(e,t)=>{let r=Object.create(Oie);return r.preprocess=t,r.postprocess=e,r.execute=function(n){return e(t(n))},r},Oie={[IW]:IW,pipe(){return V(this,arguments)},...Ot,toJSON(){return{_id:"effect/HttpClient"}},...Object.fromEntries(sW.map(([e,t])=>[t,function(r,n){return this.execute(uW(e)(r,n))}]))},TW=e=>Yk(t=>A(t,r=>ar(n=>{let o=Uie.get(r),s=o??new AbortController,i=tE(r.url,r.urlParams,_n(r.hash));if(be(i))return D(new co({reason:new Qb({request:r,cause:i.failure})}));let a=i.success;if(n.getRef(qf)||n.getRef(Pie)(r)){let u=e(r,a,s.signal,n);return o?u:en(f=>Un(f(u),{onSuccess(p){return nE.register(p,s),I(new oE(p,s))},onFailure(p){return fl(p)&&s.abort(),je(p)}}))}return Qp(n.getRef(Nie)(r),{kind:"client"},u=>{u.attribute("http.request.method",r.method);let f=n.getRef(Ww);EW(u,a);let p=n.getRef(Mie);return Zk(u,"request",r.headers,p,f),r=n.getRef(Fie)?Kk(r,SW(u)):r,en(m=>m(e(r,a,s.signal,n)).pipe(bl(u,{captureStackTrace:!1}),Un({onSuccess:h=>(u.attribute("http.response.status_code",h.status),Zk(u,"response",h.headers,p,f),h.status>=400&&h.status<600&&(u.attribute("error.type",String(h.status)),_ie(n,u,r,h)),o?I(h):(nE.register(h,s),I(new oE(h,s)))),onFailure(h){return!o&&fl(h)&&s.abort(),je(h)}})))})})),I),_ie=(e,t,r,n)=>{let o=Ir();yt(0);let s;try{s=Jn(new co({reason:new Ah({request:r,response:n})}))}finally{yt(o)}t.end(e.getRef(jg)?e.getRef(Yn).currentTimeNanosUnsafe():BigInt(0),s)},wW=d(2,(e,t)=>Yk(e.postprocess,r=>K(e.preprocess(r),t)));var Pie=Ce("effect/http/HttpClient/TracerDisabledWhen",{defaultValue:()=>Oa}),Mie=Ce("effect/http/HttpClient/TracerHeaderFilter",{defaultValue:()=>Oa}),Fie=Ce("effect/http/HttpClient/TracerPropagationEnabled",{defaultValue:nr}),Nie=Ce("effect/http/HttpClient/SpanNameGenerator",{defaultValue:()=>e=>e.method}),vW=e=>Qn(Qk)(yn(t=>K(e,r=>Rie(r,Xa(n=>Kr(t,n)))))),nE=(()=>{if("FinalizationRegistry"in globalThis&&globalThis.FinalizationRegistry){let t=new FinalizationRegistry(r=>{r.abort()});return{register(r,n){t.register(r,n,r)},unregister(r){t.unregister(r)}}}let e=new WeakMap;return{register(t,r){e.set(t,setTimeout(()=>r.abort(),5e3))},unregister(t){let r=e.get(t);r!==void 0&&(clearTimeout(r),e.delete(t))}}})(),Uie=new WeakMap,oE=class{original;controller;constructor(t,r){this.original=t,this.controller=r}[vd]=vd;[yf]=yf;applyInterrupt(t){return L(()=>(nE.unregister(this.original),Su(t,()=>W(()=>{this.controller.abort()}))))}get request(){return this.original.request}get url(){return this.original.url}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 vn(()=>(nE.unregister(this.original),Eh(this.original.stream,W(()=>{this.controller.abort()}))))}toJSON(){return this.original.toJSON()}[Qe](){return this.original[Qe]()}pipe(){return V(this,arguments)}};var CW=Ce("effect/http/FetchHttpClient/Fetch",{defaultValue:()=>globalThis.fetch}),sE=class extends Ue()("effect/http/FetchHttpClient/RequestInit"){},Die=TW((e,t,r,n)=>{let o=n.getRef(CW),s=Vi(n.context,sE)??{},i=s.headers?Rl(Zo(s.headers),e.headers):e.headers;i["content-length"]&&(i=oc(i,"content-length"));let a=c=>K(Vo({try:()=>o(t,{...s,method:e.method,headers:i,body:c,duplex:typeof ReadableStream<"u"&&c instanceof ReadableStream?"half":void 0,signal:r}),catch:u=>new co({reason:new Zb({request:e,cause:u})})}),u=>yW(e,u));switch(e.body._tag){case"Raw":case"Uint8Array":return a(e.body.body);case"FormData":return a(e.body.formData);case"Stream":return A(kk(e.body.stream),a)}return a(void 0)}),Lie=vW(I(Die));var kW=Ue("effect/socket/Socket");var eR="~effect/socket/Socket/CloseEvent",AW=class{[eR];code;reason;constructor(t=1e3,r){this[eR]=eR,this.code=t,this.reason=r}toString(){return this.reason?`${this.code}: ${this.reason}`:`${this.code}`}};var aE="~effect/socket/Socket/SocketError",Bie=e=>O(e,aE),Oh=class extends Ar("effect/socket/Socket/SocketReadError")({_tag:He("SocketReadError"),cause:er()}){message="An error occurred during Read"},tR=class extends Ar("effect/socket/Socket/SocketWriteError")({_tag:He("SocketWriteError"),cause:er()}){message="An error occurred during Write"},rR=class extends Ar("effect/socket/Socket/SocketOpenError")({_tag:He("SocketOpenError"),kind:Fo(["Unknown","Timeout"]),cause:er()}){get message(){return this.kind==="Timeout"?'timeout waiting for "open"':"An error occurred during Open"}},nR=class e extends Ar("effect/socket/Socket/SocketUpgradeError")({_tag:He("SocketUpgradeError"),cause:lr(er())}){static unsupported=()=>D(new _h({reason:new e({})}));get message(){return this.cause===void 0?"Socket does not support TLS upgrade":"An error occurred during TLS upgrade"}},oR=class extends Ar("effect/socket/Socket/SocketCloseError")({_tag:He("SocketCloseError"),code:In,closeReason:lr(z)}){get message(){return this.closeReason?`${this.code}: ${this.closeReason}`:`${this.code}`}},sR=Pe([Oh,tR,rR,nR,oR]),_h=class extends EA(aE)("SocketError",{_tag:He("SocketError"),reason:sR}){constructor(t){"cause"in t.reason?super({...t,cause:t.reason.cause}):super(t)}[aE]=aE;static is(t){return Bie(t)}message=this.reason.message};var gbe=64*1024;var RW="~effect/reactivity/AsyncResult",aR=e=>O(e,RW),cE={[RW]:{E:F,A:F},pipe(){return V(this,arguments)},[ae](e){if(this._tag!==e._tag||this.waiting!==e.waiting)return!1;switch(this._tag){case"Initial":return!0;case"Success":return Z(this.value,e.value);case"Failure":return Z(this.cause,e.cause)}},[ie](){let e=Be(`${this._tag}:${this.waiting}`);return this._tag==="Initial"?e:he(e)(this._tag==="Success"?G(this.value):G(this.cause))}};var cR=(e,t)=>e._tag==="Success"?us(e.value):Ad(e.cause,{previous:t}),uE=e=>e._tag==="None"?Ca(!0):Ph(e.value);var OW=e=>e._tag!=="Initial",Ca=(e=!1)=>{let t=Object.create(cE);return t._tag="Initial",t.waiting=e,t},Cd=e=>e._tag==="Success",us=(e,t)=>{let r=Object.create(cE);return r._tag="Success",r.value=e,r.waiting=t?.waiting??!1,r.timestamp=t?.timestamp??Date.now(),r},_W=e=>e._tag==="Failure";var iR=(e,t)=>{let r=Object.create(cE);return r._tag="Failure",r.cause=e,r.previousSuccess=t?.previousSuccess??_(),r.waiting=t?.waiting??!1,r},Ad=(e,t)=>iR(e,{previousSuccess:gs(t.previous,r=>Cd(r)?N(r):_W(r)?r.previousSuccess:_()),waiting:t.waiting});var PW=(e,t)=>Ad(hN(e),t),Ph=d(e=>aR(e[0]),(e,t)=>{if(e.waiting)return t?.touch?jie(e):e;let r=Object.assign(Object.create(cE),e);return r.waiting=!0,t?.touch&&Cd(r)&&(r.timestamp=Date.now()),r}),jie=e=>Cd(e)?us(e.value,{waiting:e.waiting}):e,Mh=d(2,(e,t)=>e._tag==="Failure"?Ad(e.cause,{previous:t,waiting:e.waiting}):e),uR=e=>e._tag==="Success"?N(e.value):e._tag==="Failure"?Lt(e.previousSuccess,t=>t.value):_();var fR=e=>Bf(uR(e),()=>new ll("AsyncResult.getOrThrow: no value found"));var kd=e=>{switch(e._tag){case"Success":return Mr(e.value);case"Failure":return ir(e.cause);default:return Jn(new ll)}};var lR=e=>{let t=e.success??Mi,r=e.error??Mi,n=Cr()([t,Jm(r,er())],([o,s])=>(i,a,c)=>{if(!aR(i))return D(new at(a,i,c));switch(i._tag){case"Initial":return I(i);case"Success":return cr(ot(o)(i.value,c),{onSuccess:u=>us(u,i),onFailure:u=>tn(a,"value",u,i,c)});case"Failure":{let u=i.previousSuccess.pipe(Lt(p=>cr(ot(o)(p.value,c),{onSuccess:m=>N(us(m,p)),onFailure:m=>new Ft(a,[new At(["previousSuccess","value"],m)],i,c)})),Ma(()=>ia)),f=Iu(ot(s)(i.cause,c),p=>tn(a,"cause",p,i,c));return ur(u,p=>Eu(f,m=>iR(m,{previousSuccess:p,waiting:i.waiting})))}}},{expected:"AsyncResult",toCodec([o,s]){let i=ya("Success",{value:o,waiting:Fi,timestamp:In});return Ne()(Pe([ya("Initial",{waiting:Fi}),i,ya("Failure",{cause:s,previousSuccess:ba(i),waiting:Fi})]),Fe({decode:a=>{switch(a._tag){case"Initial":return Ca(a.waiting);case"Success":return us(a.value,{waiting:a.waiting,timestamp:a.timestamp});case"Failure":return iR(a.cause,{previousSuccess:Lt(a.previousSuccess,c=>us(c.value,c)),waiting:a.waiting})}},encode(a){switch(a._tag){case"Initial":return{_tag:"Initial",waiting:a.waiting};case"Success":return{_tag:"Success",value:a.value,waiting:a.waiting,timestamp:a.timestamp};case"Failure":return{_tag:"Failure",cause:a.cause,previousSuccess:a.previousSuccess,waiting:a.waiting}}}}))},toEquivalence:Wd,toFormatter:([o,s])=>i=>{switch(i._tag){case"Success":return`AsyncResult.Success(${o(i.value)}, ${i.waiting}, ${i.timestamp})`;case"Failure":return`AsyncResult.Failure(${s(i.cause)}, ${i.waiting})`;case"Initial":return`AsyncResult.Initial(${i.waiting}, ${i.waiting})`}}});return Object.assign(n,{success:t,error:r})};var Nh="~effect/reactivity/AtomRegistry",Hie=e=>O(e,Nh),MW=e=>new mR(e?.initialValues,e?.scheduleTask,e?.timeoutResolution,e?.defaultIdleTTL),fE=Ue(Nh);var Dh=d(e=>Hie(e[0]),(e,t,r)=>{let n=r?.suspendOnWaiting??!1;return Nn(o=>{let s=e.get(t);if(s._tag!=="Initial"&&!(n&&s.waiting))return o(kd(s));let i=e.subscribe(t,a=>{a._tag!=="Initial"&&!(n&&a.waiting)&&(o(kd(a)),i())});return W(i)})});var qie={immediate:!0},FW=e=>{e()},An={};function Uh(e,t){let r=An;for(let n of e)try{t(n)}catch(o){r===An&&(r=o)}if(r!==An)throw r}var pR="~effect-atom/atom/Atom/Serializable",Fh=e=>pR in e?e[pR].key:e,mR=class{[Nh];timeoutResolution;defaultIdleTTL;scheduler;schedulerAsync;dispatcher;onNodeAdded;onNodeRemoved;constructor(t,r,n,o){if(this[Nh]=Nh,this.scheduler=new fi("sync",r),this.schedulerAsync=new fi("async",r),this.dispatcher=this.schedulerAsync.makeDispatcher(),this.defaultIdleTTL=o,n===void 0&&o!==void 0?this.timeoutResolution=Math.round(o/2):this.timeoutResolution=n??1e3,t!==void 0)for(let[s,i]of t){let a=s;for(;a.initialValueTarget;)a=a.initialValueTarget;this.ensureNode(a).setInitialValue(i)}}nodes=new Map;preloadedSerializable=new Map;timeoutBuckets=new Map;nodeTimeoutBucket=new Map;disposed=!1;getNodes(){return this.nodes}get(t){return this.ensureNode(t).value()}set(t,r){t.write(this.ensureNode(t).writeContext,r)}setSerializable(t,r){this.preloadedSerializable.set(t,r)}modify(t,r){let n=this.ensureNode(t),o=r(n.value());return t.write(n.writeContext,o[1]),o[0]}update(t,r){let n=this.ensureNode(t);t.write(n.writeContext,r(n.value()))}refresh=t=>{t.refresh!==void 0?t.refresh(this.refresh):this.invalidateAtom(t)};subscribe(t,r,n){let o=this.ensureNode(t);n?.immediate?r(o.value()):o.state===an.stale&&o.value();let s=o.subscribe(function(){r(o._value)});return()=>{s(),o.canBeRemoved&&this.scheduleNodeRemoval(o)}}mount(t){return this.subscribe(t,Rr,qie)}atomHasTtl(t){return!t.keepAlive&&t.idleTTL!==0&&(t.idleTTL!==void 0||this.defaultIdleTTL!==void 0)}ensureNode(t){let r=Fh(t),n=this.nodes.get(r);if(n===void 0?(n=this.createNode(t),this.nodes.set(r,n),this.onNodeAdded?.(n)):this.atomHasTtl(t)&&this.removeNodeTimeout(n),typeof r=="string"&&this.preloadedSerializable.has(r)){let o=this.preloadedSerializable.get(r);this.preloadedSerializable.delete(r);let s=t[pR].decode(o),i=t;for(;i.initialValueTarget;)i=i.initialValueTarget;i===t?n.setValue(s):this.ensureNode(i).setInitialValue(s)}return n}createNode(t){if(this.disposed)throw new Error(`Cannot access Atom ${t}: registry is disposed`);return t.keepAlive||this.scheduleAtomRemoval(t),new hR(this,t)}invalidateAtom=t=>{this.ensureNode(t).invalidate()};scheduleAtomRemoval(t){this.dispatcher.scheduleTask(()=>{let r=this.nodes.get(Fh(t));r!==void 0&&r.canBeRemoved&&this.removeNode(r)},0)}scheduleNodeRemoval(t){this.dispatcher.scheduleTask(()=>{t.canBeRemoved&&this.removeNode(t)},0)}removeNode(t){this.atomHasTtl(t.atom)?this.setNodeTimeout(t):(this.nodes.delete(Fh(t.atom)),t.remove(),this.onNodeRemoved?.(t))}setNodeTimeout(t){if(this.nodeTimeoutBucket.has(t))return;let r=t.atom.idleTTL??this.defaultIdleTTL;if(this.#e!==null&&(r-=this.#e,r<=0)){this.nodes.delete(Fh(t.atom)),t.remove(),this.onNodeRemoved?.(t);return}let n=Math.ceil(r/this.timeoutResolution)*this.timeoutResolution,o=Date.now()+n,s=o-o%this.timeoutResolution+this.timeoutResolution,i=this.timeoutBuckets.get(s);i===void 0&&(i=[new Set,setTimeout(()=>this.sweepBucket(s),s-Date.now())],this.timeoutBuckets.set(s,i)),i[0].add(t),this.nodeTimeoutBucket.set(t,s)}removeNodeTimeout(t){let r=this.nodeTimeoutBucket.get(t);if(r===void 0)return;this.nodeTimeoutBucket.delete(t),this.scheduleNodeRemoval(t);let[n,o]=this.timeoutBuckets.get(r);n.delete(t),n.size===0&&(clearTimeout(o),this.timeoutBuckets.delete(r))}#e=null;sweepBucket(t){let r=this.timeoutBuckets.get(t)[0];this.timeoutBuckets.delete(t),Uh(r,this.removeIdleNode)}removeIdleNode=t=>{if(this.nodeTimeoutBucket.delete(t),!!t.canBeRemoved){this.nodes.delete(Fh(t.atom)),this.onNodeRemoved?.(t),this.#e=t.atom.idleTTL??this.defaultIdleTTL;try{t.remove()}finally{this.#e=null}}};reset(){this.timeoutBuckets.forEach(([,r])=>clearTimeout(r)),this.timeoutBuckets.clear(),this.nodeTimeoutBucket.clear();let t=Array.from(this.nodes.values());this.nodes.clear();for(let r of t)r.state=an.removed;Uh(t,this.destroyNode)}destroyNode=t=>{t.remove(),this.onNodeRemoved?.(t)};dispose(){this.disposed=!0,this.reset()}},fs={alive:1,initialized:2,waitingForValue:4},an={uninitialized:fs.alive|fs.waitingForValue,stale:fs.alive|fs.initialized|fs.waitingForValue,valid:fs.alive|fs.initialized,removed:0},hR=class{constructor(t,r){this.registry=t,this.atom=r,this.writeContext=new xR(t,this)}registry;atom;state=an.uninitialized;lifetime;writeContext;preserveInitialValueOnBuild=!1;invalidatedDuringBuild=!1;failed=!1;parents=new Set;children=new Set;listeners=new Set;observedChildren=0;currentState(){switch(this.state){case an.uninitialized:return"uninitialized";case an.stale:return"stale";case an.valid:return"valid";default:return"removed"}}get canBeRemoved(){return!this.atom.keepAlive&&this.listeners.size===0&&this.children.size===0&&this.state!==0}get building(){return this.lifetime!==void 0&&this.lifetime.reads!==void 0}get isObserved(){return!this.atom.lazy||this.listeners.size>0||this.observedChildren>0}childObserved(t){let r=this.isObserved;this.observedChildren+=t,r!==this.isObserved&&this.observedChanged(t)}observedChanged(t){for(let r of this.parents)r.childObserved(t)}_value=void 0;value(){for(;(this.state&fs.waitingForValue)!==0;)this.build();return this._value}build(){this.disposeLifetime(),this.invalidatedDuringBuild=!1;let t=Wie(this);this.lifetime=t;let r,n=!1;try{r=this.atom.read(t),n=!0}finally{let o=t.reads;t.reads=void 0,this.lifetime===t&&(this.dropUnread(o),n||this.fail())}if(this.lifetime===t&&(this.state&fs.waitingForValue)!==0&&(this.preserveInitialValueOnBuild?(this.preserveInitialValueOnBuild=!1,this.failed=!1,this.state=an.valid):this.setValue(r)),t.failure!==An)throw t.failure}fail(){this.failed=!0;try{this.invalidateChildren()}catch{}}readTracked(t,r){let n=this.registry.ensureNode(t);this.parents.has(n)||(this.parents.add(n),n.children.add(this),this.isObserved&&n.childObserved(1));try{return n.value()}catch(o){if(r.reads===void 0||n.state!==an.valid)throw o;return r.failure===An&&(r.failure=o),n._value}finally{r.reads!==void 0&&!r.disposed&&r.reads.add(n)}}dropUnread(t){if(t.size===this.parents.size)return;let r=this.isObserved;for(let n of this.parents)t.has(n)||(this.parents.delete(n),n.children.delete(this),r&&n.childObserved(-1),n.canBeRemoved&&this.registry.scheduleNodeRemoval(n))}valueOption(){return(this.state&fs.initialized)===0?_():N(this._value)}setInitialValue(t){if((this.state&fs.initialized)===0){this.preserveInitialValueOnBuild=!0,this.state=an.stale,this._value=t,this.listeners.size>0&&this.announce();return}this.setValue(t)}setValue(t){let r=this.failed;this.failed=!1;let n=(this.state&fs.initialized)!==0;if(this.state=an.valid,n&&this.atom.equals(this._value,t)){r&&this.invalidateChildren();return}this._value=t;let o=An;try{this.invalidateChildren()}catch(s){o=s}if(this.listeners.size>0)try{this.announce()}catch(s){o===An&&(o=s)}if(o!==An)throw o}announce(){cn.phase===Ac.collect?cn.notify.add(this):this.notify()}invalidate(){if(this.state===an.valid){this.state=an.stale;try{this.disposeLifetime()}finally{this.propagate()}}else this.building&&cn.phase!==Ac.collect?this.build():this.propagate()}propagate(){cn.phase===Ac.collect?(this.building&&(this.invalidatedDuringBuild=!0),cn.stale.push(this)):this.isObserved?this.value():this.invalidateChildren()}invalidateChildren(){if(this.children.size===0)return;let t=An;for(let r of Array.from(this.children))if(r.affectedBy(this))try{r.invalidate()}catch(n){t===An&&(t=n)}if(t!==An)throw t}affectedBy(t){if(this.state===an.valid)return!0;let r=this.lifetime?.reads;return r!==void 0?r.has(t):this.isObserved&&t.state===an.valid}notify(){cn.phase===Ac.commit&&cn.notify.delete(this),Uh(this.listeners,FW)}disposeLifetime(){let t=this.lifetime;t!==void 0&&(this.lifetime=void 0,t.dispose())}remove(){let t=this.isObserved;this.state=an.removed,this.listeners.clear();try{this.disposeLifetime()}finally{let r=Array.from(this.parents);this.parents.clear(),Uh(r,n=>{n.children.delete(this),t&&n.childObserved(-1),n.canBeRemoved&&this.registry.removeNode(n)})}}subscribe(t){let r=this.isObserved;return this.listeners.add(t),r||this.observedChanged(1),()=>{this.listeners.delete(t)&&!this.isObserved&&this.observedChanged(-1)}}},zie={get registry(){return this.node.registry},addFinalizer(e){if(this.disposed)return e();this.finalizers??=[],this.finalizers.push(e)},get(e){return this.disposed?this.node.registry.get(e):this.node.readTracked(e,this)},result(e,t){if(this.disposed||this.isFn)return this.resultOnce(e,t);let r=this.get(e);if(t?.suspendOnWaiting&&r.waiting)return Xn;switch(r._tag){case"Initial":return Xn;case"Failure":return ir(r.cause);case"Success":return I(r.value)}},resultOnce(e,t){return Nn(r=>{let n=this.once(e);if(n._tag!=="Initial"&&!(t?.suspendOnWaiting&&n.waiting))return r(kd(n));let o=this.node.registry.subscribe(e,s=>{s._tag==="Initial"||t?.suspendOnWaiting&&s.waiting||(o(),r(kd(s)))},{immediate:!1});return W(o)})},setResult(e,t){return this.disposed?Xn:(this.node.registry.set(e,t),this.resultOnce(e,{suspendOnWaiting:!0}))},some(e){if(this.disposed||this.isFn)return this.someOnce(e);let t=this.get(e);return t._tag==="None"?Xn:I(t.value)},someOnce(e){return Nn(t=>{let r=this.once(e);if(de(r))return t(I(r.value));let n=this.node.registry.subscribe(e,o=>{fe(o)||(n(),t(I(o.value)))},{immediate:!1});return W(n)})},once(e){return this.node.registry.get(e)},self(){return this.disposed?_():this.node.valueOption()},refresh(e){this.disposed||this.node.registry.refresh(e)},refreshSelf(){this.disposed||this.node.invalidate()},mount(e){this.disposed||this.addFinalizer(this.node.registry.mount(e))},subscribe(e,t,r){this.disposed||this.addFinalizer(this.node.registry.subscribe(e,t,r))},setSelf(e){this.disposed||this.node.setValue(e)},set(e,t){this.disposed||this.node.registry.set(e,t)},stream(e,t){return this.disposed?Js:Db(r=>W(()=>{this.subscribe(e,n=>Ic(r,n),{immediate:!t?.withoutInitialValue})}))},streamResult(e,t){return this.stream(e,t).pipe(yk(OW),xf(r=>r._tag==="Success"?I(r.value):je(r.cause)))},dispose(){if(this.disposed=!0,this.finalizers===void 0)return;let e=this.finalizers;this.finalizers=void 0,Uh(e.reverse(),FW)}},Wie=e=>{function t(r){return t.disposed||t.isFn?e.registry.get(r):e.readTracked(r,t)}return Object.setPrototypeOf(t,zie),t.isFn=!1,t.disposed=!1,t.finalizers=void 0,t.node=e,t.reads=new Set,t.failure=An,t},xR=class{constructor(t,r){this.registry=t,this.node=r}registry;node;get(t){return this.registry.get(t)}set(t,r){return this.registry.set(t,r)}setSelf(t){return this.node.setValue(t)}refreshSelf(){return this.node.invalidate()}},Ac={disabled:0,collect:1,commit:2},cn={phase:Ac.disabled,depth:0,stale:[],notify:new Set};function NW(e){let t=cn.phase;cn.phase=Ac.collect,cn.depth++;let r=An;try{e()}catch(n){r=n}if(cn.depth===1){let{notify:n,stale:o}=cn,s=0;do{for(cn.phase=Ac.collect;s<o.length;s++)try{Kie(o[s])}catch(i){r===An&&(r=i)}cn.phase=Ac.commit;for(let i of n)try{i.notify()}catch(a){r===An&&(r=a)}}while(s<o.length);cn.stale=[],n.clear()}if(cn.depth--,cn.phase=t,r!==An)throw r}function Kie(e){if(e.state===an.valid){if(!e.invalidatedDuringBuild)return;e.invalidatedDuringBuild=!1,e.state=an.stale,e.disposeLifetime()}e.value()}var ex={};ps(ex,{ConnectionHooks:()=>Xh,CurrentHeaders:()=>DE,Protocol:()=>Hi,layerProtocolHttp:()=>uue,layerProtocolSocket:()=>due,layerProtocolWorker:()=>pue,make:()=>oO,makeNoSerialization:()=>d6,makeProtocolHttp:()=>p6,makeProtocolSocket:()=>m6,makeProtocolWorker:()=>h6,withHeaders:()=>cue});var Lh=class extends Ue()("effect/workers/Transferable/Collector"){},DW=()=>{let e=[],t=o=>{e.push(...o)},r=()=>e,n=()=>{let o=e;return e=[],o};return Lh.of({addAllUnsafe:t,addAll:o=>W(()=>t(o)),readUnsafe:r,read:W(r),clearUnsafe:n,clear:W(n)})};var gR="~effect/workers/WorkerError";var yR=class extends Ar("effect/workers/WorkerError/WorkerSpawnError")({_tag:He("WorkerSpawnError"),message:z,cause:lr(er())}){},SR=class extends Ar("effect/workers/WorkerError/WorkerSendError")({_tag:He("WorkerSendError"),message:z,cause:lr(er())}){},bR=class extends Ar("effect/workers/WorkerError/WorkerReceiveError")({_tag:He("WorkerReceiveError"),message:z,cause:lr(er())}){},ER=class extends Ar("effect/workers/WorkerError/WorkerUnknownError")({_tag:He("WorkerUnknownError"),message:z,cause:lr(er())}){},IR=Pe([yR,SR,bR,ER]),LW=class extends Ar(gR)({_tag:He("WorkerError"),reason:IR}){constructor(t){super({...t,cause:t.reason.cause})}[gR]=gR;get message(){return this.reason.message}};var lE=class extends Ue()("effect/workers/Worker/WorkerPlatform"){};var TR=(e,t)=>e===void 0?t:`${e}.${t}`,wR=(e,t)=>({"rpc.system.name":"effect_rpc","rpc.method":e,...t});var Od={};ps(Od,{ServerClient:()=>kR,custom:()=>Xie,exitSchema:()=>RR,fork:()=>rae,isRpc:()=>Qie,isWrapper:()=>Rd,make:()=>$W,uninterruptible:()=>nae,unwrap:()=>eae,wrap:()=>mE,wrapMap:()=>tae});var vR="~effect/rpc/RpcSchema/StreamSchema";function Bh(e){return O(e,vR)}function dE(e){return Bh(e)?N({success:e.success,error:e.error}):_()}var Zie=Ge(Ae);function BW(e,t){return J(Zie.ast,{[vR]:vR,success:e,error:t})}var AR="~effect/rpc/Rpc",Qie=e=>O(e,AR),kR=class{id;annotations;constructor(t){this.id=t,this.annotations=pt()}annotate(t,r){return this.annotations=We(this.annotations,t,r),this}},Yie={[AR]:AR,pipe(){return V(this,arguments)},setSuccess(e){return kc({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:e,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},setError(e){return kc({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:e,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},setPayload(e){return kc({_tag:this._tag,payloadSchema:Ju(e)?e:Te(e),successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},middleware(e){return kc({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:new Set([...this.middlewares,e])})},prefix(e){return kc({_tag:`${e}${this._tag}`,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},annotate(e,t){return kc({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,middlewares:this.middlewares,annotations:We(this.annotations,e,t)})},annotateMerge(e){return kc({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,middlewares:this.middlewares,annotations:Kr(this.annotations,e)})}},kc=e=>{function t(){}return Object.setPrototypeOf(t,Yie),Object.assign(t,e),t.key=`effect/rpc/Rpc/${e._tag}`,t},$W=(e,t)=>{let r=t?.success??pd,n=t?.error??Mi,o=t?.defect??er(),s;return t?.primaryKey?s=class extends YS(`effect/rpc/Rpc/${e}`)(t.payload){[Uz](){return t.primaryKey(this)}}:s=Ju(t?.payload)?t?.payload:t?.payload?Te(t?.payload):pd,kc({_tag:e,payloadSchema:s,successSchema:t?.stream?BW(r,n):r,errorSchema:t?.stream?Mi:n,defectSchema:o,annotations:pt(),middlewares:new Set})},Xie=e=>(t,r)=>{let n=r?.success??pd,o=r?.error??Mi,s=r?.defect??er(),i=e({success:n,error:o,defect:s});return $W(t,{...i,primaryKey:r?.primaryKey,payload:r?.payload,stream:r?.stream})},CR=new WeakMap,RR=e=>{if(CR.has(e))return CR.get(e);let t=e,r=new Set([t.errorSchema]),n=dE(t.successSchema);de(n)&&r.add(n.value.error);for(let s of t.middlewares)r.add(s.error);let o=yA(de(n)?pd:t.successSchema,Pe([...r]),t.defectSchema);return CR.set(e,o),o},$h="~effect/rpc/Rpc/Wrapper",Rd=e=>$h in e,mE=e=>t=>Rd(t)?{[$h]:$h,value:t.value,fork:e.fork??t.fork,uninterruptible:e.uninterruptible??t.uninterruptible}:{[$h]:$h,value:t,fork:e.fork??!1,uninterruptible:e.uninterruptible??!1},eae=e=>Rd(e)?e.value:e,tae=(e,t)=>Rd(e)?mE(e)(t(e.value)):t(e),rae=mE({fork:!0}),nae=mE({uninterruptible:!0});var OR="~effect/rpc/RpcClientError",Rc=class extends Ar("effect/rpc/RpcClientError/RpcClientDefect")({_tag:He("RpcClientDefect"),message:z,cause:er()}){},Zs=class extends Ar(OR)({_tag:He("RpcClientError"),reason:Pe([IR,sR,wd,Rc])}){[OR]=OR;get message(){return`${this.reason._tag}: ${this.reason.message}`}};var _R=e=>e;var jW={_tag:"Ping"};var jh=Pe([z,Zu]),sae=Te({_tag:He("Request"),id:jh,tag:z,payload:qs,headers:ct(rs([z,z])),isNotification:lr(fr(!0)),traceId:lr(z),spanId:lr(z),sampled:lr(Fi)}),PR=Pe([sae,Te({_tag:He("Ack"),requestId:jh}),Te({_tag:He("Interrupt"),requestId:jh}),Te({_tag:He("Ping")}),Te({_tag:He("Eof")}),Te({_tag:He("Chunk"),requestId:jh,values:qs}),Te({_tag:He("Exit"),requestId:jh,exit:qs}),Te({_tag:He("Defect"),defect:qs}),Te({_tag:He("Pong")})]);var MR=e=>{switch(e._tag){case"Exit":case"Defect":case"ClientProtocolError":return!0;default:return!1}};var Yh={};ps(Yh,{MaxBufferSizeExceeded:()=>ME,RpcSerialization:()=>fn,json:()=>o6,jsonRpc:()=>i6,layerJson:()=>Qce,layerJsonRpc:()=>eue,layerNdJsonRpc:()=>tue,layerNdjson:()=>Yce,layerNdjsonWith:()=>Xce,layerSchemaBinary:()=>rue,makeNdjson:()=>NE,ndJsonRpc:()=>a6,ndjson:()=>s6});var iae=new WeakMap,aae=new WeakMap,cae=new WeakMap,uae=new WeakMap;function c4(e,t){let r=t?.fingerprint===!0?aae:iae,n=r.get(e);if(n!==void 0)return n;let{exact:o,layout:s,recursive:i,target:a}=Md(e),c=bf(s,t?.fingerprint),u=o?{value:void 0}:void 0,f=NR(u===void 0?a:Bce(a,u,!i),s,c,u);return r.set(e,f),f}function VR(e,t){let r=t?.fingerprint===!0?uae:cae,n=r.get(e);if(n!==void 0)return n;let{exact:o,exitSuccess:s,layout:i,target:a}=Md(e);if(!o){if(!s)return c4(e,t);let u={value:void 0},f=NR(jce(a,u),i,bf(i,t?.fingerprint),u,!0);return r.set(e,f),f}let c=NR(Hce(a),i,bf(i,t?.fingerprint),void 0);return r.set(e,c),c}function NR(e,t,r,n,o=!1){return qs.pipe(ee(e,Uce(t,r,n,o)))}function u4(e,t){let{exact:r,exitSuccess:n,layout:o}=Md(e),s=bf(o,t?.fingerprint),i=t??nn;if(!r||i.onExcessProperty==="error"){let a=Ym(c4(e,t),t);return!n||i.onExcessProperty==="error"?a:c=>{if(!PE(c))return a(c);try{return AE(o,c,i,s)}catch(u){throw u instanceof ji?new $n(u.issue):u}}}return a=>{try{return AE(o,a,i,s)}catch(c){throw c instanceof ji?new $n(c.issue):c}}}function fae(e,t){let{exact:r,layout:n}=Md(e),o=t??nn;if(!r||o.onExcessProperty==="error"){let i=u4(e,t);return a=>lae(a.map(i))}let s=bf(n,t?.fingerprint);return i=>{try{return H4(n,i,o,s)}catch(a){throw a instanceof ji?new $n(a.issue):a}}}function lae(e){if(e.length===1)return e[0];let t=0;for(let o of e)t+=o.length;let r=new Uint8Array(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}function f4(e,t){let{exact:r,exitSuccess:n,layout:o,target:s}=Md(e),i=t??nn,a=r?void 0:jS(s,i),c=a!==void 0&&n?u=>PE(u)?u:a(u):a;return dae(o,bf(o,t?.fingerprint),i,t?.maxFrameSize,c,l4(r,t))}function l4(e,t){if(t?.dictionary!==!0)return!1;if(!e)throw new Error("Binary layout: dictionary needs a schema the binary layer validates on its own");return!0}function d4(e,t){let{exact:r,layout:n,target:o}=Md(e),s=l4(r,t),i=u4(e,t),a=fae(e,t);if(!s)return{encode:i,encodeMany:a};let c=bf(n,t?.fingerprint),u=t??nn,f=u.onExcessProperty==="error"?Ym(o,t):void 0,p=ace(),m=h=>{try{return h()}catch(x){throw x instanceof ji?new $n(x.issue):x}};return{encode:h=>m(()=>AE(n,f===void 0?h:f(h),u,c,p)),encodeMany:h=>m(()=>H4(n,f===void 0?h:h.map(f),u,c,p))}}function dae(e,t,r,n,o,s){let i=s?[]:void 0,a=new Uint8Array(0),c=0,u=0,f,p=!1,m=new zh,h=new qh(r,Mae),x=()=>{m.release(),h.clear(),a=$R,c=u=0},g=(v,T)=>{throw new $n(new le({expected:v},T,r))},y=()=>{let v=f;throw f=void 0,v},E=(v,T)=>{let S=v.length-T;S>a.length&&(a=new Uint8Array(Math.max(256,S))),a.set(T===0?v:v.subarray(T),0),c=0,u=S},b={feedSync(v){if(f!==void 0)return y();if(p)return g("parser is spent");let T=u===c,S,w,k;if(T)S=v,w=0,k=v.length;else{if(v.length>0){let $=u-c,te=$+v.length;if(te>a.length){let xe=new Uint8Array(Math.max(256,a.length*2,te));xe.set(a.subarray(c,u)),a=xe,c=0,u=$}else c>0&&(a.copyWithin(0,c,u),c=0,u=$);a.set(v,u),u+=v.length}S=a,w=c,k=u}let C=[],R=()=>(T?w<k&&E(v,w):(c=w,c===u&&(c=u=0)),C),M=($,te)=>{p=!0;let xe=new $n(new le({expected:$},te,r));if(x(),C.length===0)throw xe;return f=xe,C};for(;;){let $=0,te=-1,xe=k-w,Le=1;for(let Ee=0;Ee<Math.min(6,xe);Ee++){let Oe=S[w+Ee];if($+=(Oe&127)*Le,(Oe&128)===0){te=Ee+1;break}Le*=128}if(te===-1){if(xe<6)return R();let Ee=BigInt($);for(let Oe=6;Oe<Math.min(10,xe);Oe++){let rr=S[w+Oe];if(Ee|=BigInt(rr&127)<<BigInt(Oe*7),(rr&128)===0){if(te=Oe+1,Ee>UR)return M("safe integer length",Ee);$=Number(Ee);break}}if(te===-1)return xe>=10?M("uvarint",S.subarray(w,w+10)):R()}if($===0)return M("nonzero frame length",$);if(n!==void 0&&$>n)return M("frame within maxFrameSize",$);if(te+$>xe)return R();let Er=Q;try{Q=0;let Ee=w+te;h.beginFrame(),m.reset(S,Ee,Ee+$,r,h,t.positional,i);let Oe=Q4(e,m,t);C.push(o===void 0?Oe:o(Oe))}catch(Ee){p=!0,x();let Oe=Ee instanceof ji?new $n(Ee.issue):fd(Ee)?Ee:(()=>{throw Ee})();if(C.length===0)throw Oe;return f=Oe,C}finally{Q=Er}w+=te+$}},endSync(){if(f!==void 0)return y();if(p)return g("parser is spent");p=!0;let v=c<u?a.subarray(c,u):void 0;if(x(),v!==void 0)return g("complete value",v)},feed:v=>L(()=>{try{return I(b.feedSync(v))}catch(T){if(fd(T))return D(T);throw T}}),end:L(()=>{try{return b.endSync(),P}catch(v){if(fd(v))return D(v);throw v}})};return b}var pae="~effect/encoding/SchemaBinary/fieldId",mae=32,hae=33,UR=BigInt(Number.MAX_SAFE_INTEGER),EE=BigInt(0),ls=BigInt(1),xae=BigInt(2),p4=BigInt(7),qW=BigInt(127),gae=BigInt(1e6),yae=BigInt(255),zW=BigInt(4294967295),Sae=BigInt(32),$i=new TextEncoder,bae=new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0}),m4=7,WW=0xffffffffffff,Eae=0xfffffffffffff,h4=0,x4=1,g4=2,KW=512,Iae=1048576,Tae=4194304,Ef=0,Sf=1,Vh=2,Gh=3,Jh=4,Zh=5,wae=6,vae=7,ds=8;function GR(e){return typeof e=="number"&&Number.isInteger(e)&&e>=-WW&&e<=WW}var kE=8,DR=2199023255551,_c=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8];function JR(e){for(let t=1;t<=kE;t++){let r=Math.round(e*_c[t]);if(!(r>=-DR&&r<=DR))return 0;if(r/_c[t]===e)return t}return 0}function y4(e){let t=Math.floor(e/2);return e%2===1?-t:t}var dt={bool:1,null:2,undefined:3,number:4,string:5,bytes:6,bigint:7,int64:8,struct:9,variant:10,array:11,option:12,result:13,duration:14,bigDecimal:15,dateTimeZoned:16,json:17,exit:18,cause:19,causeReason:20};function S4(e){let t=2166136261;for(let r=0;r<e.length;r++)t=Math.imul(t^e[r],16777619);return t>>>0}var Cae=BigInt("14695981039346656037"),Aae=BigInt("1099511628211"),kae=BigInt("18446744073709551615");function VW(e){let t=Cae;for(let r=0;r<e.length;r++)t=(t^BigInt(e[r]))*Aae&kae;return t}function IE(e,t){for(let r=0;r<t.length;r++)e.push(t[r])}function Oc(e,t){for(;t>127;)e.push(t&127|128),t=Math.floor(t/128);e.push(t)}function TE(e,t){e.push(t&255,t>>>8&255,t>>>16&255,t>>>24&255)}function No(e,t){for(let r=0;r<8;r++)e.push(Number(t>>BigInt(r*8)&yae))}function b4(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)if(e[n]!==t[n])return e[n]-t[n];return e.length-t.length}var ji=class extends Error{issue;constructor(t){super("SchemaBinary failure"),this.issue=t}};function j(e,t,r){throw dr(new le({expected:e},t,r))}var Ze=[],Q=0;function dr(e){return new ji(Q===0?e:new At(Ze.slice(0,Q),e))}function Rae(e){let t=new Uint8Array(E4(e)),r=0;for(;e>127;)t[r++]=e&127|128,e=Math.floor(e/128);return t[r]=e,t}function E4(e){let t=1;for(;e>127;)e=Math.floor(e/128),t++;return t}var Oae=32;function _ae(e,t,r,n){let o=r-t;if(o===0)return"";if(o<=Oae){let s=Pae(e,t,r);if(s!==void 0)return s}try{return bae.decode(e.subarray(t,r))}catch{j("utf-8",void 0,n)}}function Pae(e,t,r){let n="",o=t;for(;o+16<=r;o+=16){let s=e[o],i=e[o+1],a=e[o+2],c=e[o+3],u=e[o+4],f=e[o+5],p=e[o+6],m=e[o+7],h=e[o+8],x=e[o+9],g=e[o+10],y=e[o+11],E=e[o+12],b=e[o+13],v=e[o+14],T=e[o+15];if((s|i|a|c|u|f|p|m|h|x|g|y|E|b|v|T)>127)return;n+=String.fromCharCode(s,i,a,c,u,f,p,m,h,x,g,y,E,b,v,T)}if(o+8<=r){let s=e[o],i=e[o+1],a=e[o+2],c=e[o+3],u=e[o+4],f=e[o+5],p=e[o+6],m=e[o+7];if((s|i|a|c|u|f|p|m)>127)return;n+=String.fromCharCode(s,i,a,c,u,f,p,m),o+=8}switch(r-o){case 0:return n;case 1:{let s=e[o];return s>127?void 0:n+String.fromCharCode(s)}case 2:{let s=e[o],i=e[o+1];return(s|i)>127?void 0:n+String.fromCharCode(s,i)}case 3:{let s=e[o],i=e[o+1],a=e[o+2];return(s|i|a)>127?void 0:n+String.fromCharCode(s,i,a)}case 4:{let s=e[o],i=e[o+1],a=e[o+2],c=e[o+3];return(s|i|a|c)>127?void 0:n+String.fromCharCode(s,i,a,c)}case 5:{let s=e[o],i=e[o+1],a=e[o+2],c=e[o+3],u=e[o+4];return(s|i|a|c|u)>127?void 0:n+String.fromCharCode(s,i,a,c,u)}case 6:{let s=e[o],i=e[o+1],a=e[o+2],c=e[o+3],u=e[o+4],f=e[o+5];return(s|i|a|c|u|f)>127?void 0:n+String.fromCharCode(s,i,a,c,u,f)}default:{let s=e[o],i=e[o+1],a=e[o+2],c=e[o+3],u=e[o+4],f=e[o+5],p=e[o+6];return(s|i|a|c|u|f|p)>127?void 0:n+String.fromCharCode(s,i,a,c,u,f,p)}}}var LR=64*1024,Mae=256,Fae=512,Nae=16*1024;function BR(e){let t=new Uint8Array(e);return{buf:t,view:new DataView(t.buffer),offset:0,writing:!1}}var Hh=BR(LR),wE=class{buf=new Uint8Array(0);view=new DataView(this.buf.buffer);arena;start=0;limit=0;len=0;reset(){let t=Hh;(t.writing||t.offset>=t.buf.length)&&(t=Hh=BR(LR)),t.writing=!0,this.arena=t,this.buf=t.buf,this.view=t.view,this.start=t.offset,this.limit=t.buf.length-t.offset,this.len=0}ensure(t){if(this.len+t>this.limit){let r=this.arena,n=this.len+t,o=LR;for(;o<n;)o*=2;let s=BR(o);s.writing=!0,s.buf.set(this.buf.subarray(this.start,this.start+this.len)),r.writing=!1,this.arena=Hh=s,this.buf=s.buf,this.view=s.view,this.start=0,this.limit=s.buf.length}}byte(t){this.ensure(1),this.buf[this.start+this.len++]=t}bytes(t){this.ensure(t.length),this.buf.set(t,this.start+this.len),this.len+=t.length}uvarint(t){this.ensure(10);let r=this.buf,n=this.start+this.len;if(t<128)r[n++]=t;else if(r[n++]=t&127|128,t<16384)r[n++]=t>>>7;else{for(r[n++]=t>>>7&127|128,t=Math.floor(t/16384);t>127;)r[n++]=t&127|128,t=Math.floor(t/128);r[n++]=t}this.len=n-this.start}uvarintBig(t){for(;t>qW;)this.byte(Number(t&qW)|128),t>>=p4;this.byte(Number(t))}zigzag(t){this.uvarintBig(t>=EE?t<<ls:(-t<<ls)-ls)}numberVarint(t){let r=t<0||t===0&&1/t<0,n=r?-t:t;n<=Eae?this.uvarint(n*2+(r?1:0)):this.uvarintBig(BigInt(n)*xae+(r?ls:EE))}f64(t){this.ensure(8),this.view.setFloat64(this.start+this.len,t,!0),this.len+=8}i64(t){this.ensure(8),this.view.setBigInt64(this.start+this.len,t,!0),this.len+=8}u32le(t){this.ensure(4),this.view.setUint32(this.start+this.len,t>>>0,!0),this.len+=4}i32le(t){this.ensure(4),this.view.setInt32(this.start+this.len,t|0,!0),this.len+=4}idAndMark(t){let r=t.length;this.ensure(r+1);let n=this.buf,o=this.start+this.len;for(let i=0;i<r;i++)n[o++]=t[i];let s=o-this.start;return this.len=s+1,s}beginSized(){return this.ensure(1),this.len++}endSized(t){let r=this.len-t-1;r<128?this.buf[this.start+t]=r:this.growSized(t,r)}endSizedRun(t){let r=(this.len-t-1)*2;r<128?this.buf[this.start+t]=r:this.growSized(t,r)}growSized(t,r){let n=E4(r),o=n-1;this.ensure(o);let s=this.start+t;this.buf.copyWithin(s+n,s+1,this.start+this.len),this.len+=o;let i=r,a=s;for(;i>127;)this.buf[a++]=i&127|128,i=Math.floor(i/128);this.buf[a]=i}string(t){let r=t.length;if(r===0)return;this.ensure(r*3);let n=this.buf,o=this.start+this.len,s=0;for(;s+4<=r;s+=4){let i=t.charCodeAt(s),a=t.charCodeAt(s+1),c=t.charCodeAt(s+2),u=t.charCodeAt(s+3);if((i|a|c|u)>127){this.len+=$i.encodeInto(t,n.subarray(this.start+this.len)).written;return}n[o++]=i,n[o++]=a,n[o++]=c,n[o++]=u}for(;s<r;s++){let i=t.charCodeAt(s);if(i>127){this.len+=$i.encodeInto(t,n.subarray(this.start+this.len)).written;return}n[o++]=i}this.len=o-this.start}out(){let t=this.arena,r=new Uint8Array(t.buf.buffer,this.start,this.len);return t===Hh&&(t.offset=this.start+this.len),t.writing=!1,this.arena=void 0,r}abort(){let t=this.arena;t!==void 0&&(t===Hh&&(t.offset=this.start),t.writing=!1,this.arena=void 0)}};function Uae(e){let t=Bn(e);return t._tag==="String"&&t.checks===void 0}function Dae(e,t,r){return e.extra.find(n=>_i({[t]:null},n.parameter,r).length>0)}var qh=class{entries=new WeakMap;orderLayouts;orderKeys;options;size=0;next=0;replace=!1;constructor(t,r){this.options=t,this.orderLayouts=r===void 0?void 0:new Array(r),this.orderKeys=r===void 0?void 0:new Array(r)}beginFrame(){this.replace=!0}find(t,r){let n=this.entries.get(t);if(n===void 0&&(n=new Map,this.entries.set(t,n)),n.has(r))return n.get(r);let o=Dae(t,r,this.options),s=this.orderLayouts;if(s===void 0)return n.set(r,o),o;let i=this.orderKeys;if(this.size<s.length)s[this.size]=t,i[this.size]=r,this.size++,n.set(r,o);else if(this.replace){this.replace=!1;let a=s[this.next];(a===t?n:this.entries.get(a))?.delete(i[this.next]),s[this.next]=t,i[this.next]=r,this.next=(this.next+1)%s.length,n.set(r,o)}return o}clear(){this.entries=new WeakMap,this.orderLayouts?.fill(void 0),this.orderKeys?.fill(void 0),this.size=this.next=0,this.replace=!1}},vE=new ArrayBuffer(0),$R=new Uint8Array(vE),GW=new DataView(vE),zh=class{pos=0;nesting=0;buf=$R;view;viewCache=GW;viewBuffer=vE;viewOffset=0;viewLength=0;end=0;options=nn;indexSignatures;positional=!1;intern;dict;reset(t,r,n,o,s,i,a){this.nesting=0,this.view=void 0,this.buf=t,this.pos=r,this.end=n,this.options=o,this.indexSignatures=s,this.positional=i,this.intern=void 0,this.dict=a}release(){this.pos=this.end=this.nesting=0,this.buf=$R,this.view=void 0,this.viewCache=GW,this.viewBuffer=vE,this.viewOffset=this.viewLength=0,this.options=nn,this.indexSignatures=void 0,this.positional=!1,this.intern=void 0,this.dict=void 0}get remaining(){return this.end-this.pos}dataView(){let t=this.buf;return(t.buffer!==this.viewBuffer||t.byteOffset!==this.viewOffset||t.byteLength!==this.viewLength)&&(this.viewBuffer=t.buffer,this.viewOffset=t.byteOffset,this.viewLength=t.byteLength,this.viewCache=new DataView(t.buffer,t.byteOffset,t.byteLength)),this.view=this.viewCache}byte(){return this.pos>=this.end&&j("complete value",void 0,this.options),this.buf[this.pos++]}take(t){this.pos+t>this.end&&j("complete value",void 0,this.options);let r=this.buf.subarray(this.pos,this.pos+t);return this.pos+=t,r}takeCopy(t){this.pos+t>this.end&&j("complete value",void 0,this.options);let r=this.buf.slice(this.pos,this.pos+t);return this.pos+=t,r}enter(t){this.pos+t>this.end&&j("complete value",void 0,this.options);let r=this.end;return this.end=this.pos+t,r}exit(t){this.pos=this.end,this.end=t}readUtf8(t){this.pos+t>this.end&&j("complete value",void 0,this.options);let r=this.pos;return this.pos+=t,_ae(this.buf,r,r+t,this.options)}uvarint(){let t=this.buf,r=this.end,n=this.pos;n>=r&&j("complete value",void 0,this.options);let o=t[n++];if(o<128)return this.pos=n,o;let s=o&127;if(n>=r&&j("complete value",void 0,this.options),o=t[n++],s|=(o&127)<<7,o<128)return this.pos=n,s;if(n>=r&&j("complete value",void 0,this.options),o=t[n++],s|=(o&127)<<14,o<128)return this.pos=n,s;if(n>=r&&j("complete value",void 0,this.options),o=t[n++],s|=(o&127)<<21,o<128)return this.pos=n,s;let i=268435456;for(let a=4;a<10;a++){n>=r&&(this.pos=n,j("complete value",void 0,this.options)),o=t[n++];let c=(o&127)*i;if(c>Number.MAX_SAFE_INTEGER-s&&(this.pos=n,j("safe integer length",void 0,this.options)),s+=c,o<128)return this.pos=n,s;i*=128}this.pos=n,j("uvarint",void 0,this.options)}fieldTag(){let t=this.buf,r=this.end,n=this.pos;n>=r&&j("complete value",void 0,this.options);let o=t[n++];if(o<128)return this.pos=n,o;let s=o&127;return n>=r&&j("complete value",void 0,this.options),o=t[n++],s|=(o&127)<<7,o<128?(this.pos=n,s):(n>=r&&j("complete value",void 0,this.options),o=t[n++],s|=(o&127)<<14,o<128?(this.pos=n,s):(n>=r&&j("complete value",void 0,this.options),o=t[n++],s|=(o&127)<<21,o<128?(this.pos=n,s):(n>=r&&j("complete value",void 0,this.options),o=t[n++],this.pos=n,o>=128&&j("uvarint",void 0,this.options),s+o*268435456)))}uvarintBig(){let t=EE,r=EE;for(;;){let n=this.byte();if(t|=BigInt(n&127)<<r,(n&128)===0)return t;r+=p4}}numberVarint(){let t=this.buf,r=this.end,n=this.pos,o=0,s=1;for(let c=0;c<m4;c++){n>=r&&(this.pos=n,j("complete value",void 0,this.options));let u=t[n++];if(o+=(u&127)*s,u<128)return this.pos=n,y4(o);s*=128}let i=this.uvarintBig(),a=Number(i>>ls);return Number.isFinite(a)||j("safe integer length",void 0,this.options),(i&ls)===ls?-a:a}zigzag(){let t=this.uvarintBig();return(t&ls)===ls?-(t+ls>>ls):t>>ls}f64(){this.pos+8>this.end&&j("complete value",void 0,this.options);let t=(this.view??this.dataView()).getFloat64(this.pos,!0);return this.pos+=8,t}i64(){this.pos+8>this.end&&j("complete value",void 0,this.options);let t=(this.view??this.dataView()).getBigInt64(this.pos,!0);return this.pos+=8,t}u32le(){this.pos+4>this.end&&j("complete value",void 0,this.options);let t=(this.view??this.dataView()).getUint32(this.pos,!0);return this.pos+=4,t}i32le(){this.pos+4>this.end&&j("complete value",void 0,this.options);let t=(this.view??this.dataView()).getInt32(this.pos,!0);return this.pos+=4,t}};function JW(e,t){return{_:"literal",leaf:e,values:t,valueSet:t.length>4?new Set(t):void 0}}function Qh(e,t){let r=e.values;return e.valueSet!==void 0?e.valueSet.has(t):r.length===1?t===r[0]:r.includes(t)}function RE(e){return e.values.map(t=>typeof t=="string"?JSON.stringify(t):String(t)).join(" | ")}var gE=0,ZR=1,I4=2,T4=3,w4=30,yE=1<<w4;function OE(e){return e._==="literal"?OE(e.leaf):e._==="int"}function _E(e){switch(e._){case"literal":return _E(e.leaf);case"bool":return 1;case"int64":return 8;default:return}}function jR(e){return _E(e)!==void 0||OE(e)||e._==="null"||e._==="undefined"}function v4(e){return e._==="literal"?v4(e.leaf):e._==="null"||e._==="undefined"}var Wh={"effect/schema/Date":{kind:dt.int64,exact:!0},"effect/schema/DateTimeUtc":{kind:dt.int64,exact:!0},"effect/schema/DateTimeZoned":{kind:dt.dateTimeZoned,exact:!0},"effect/schema/Duration":{kind:dt.duration,exact:!0},"effect/schema/BigDecimal":{kind:dt.bigDecimal,exact:!0},"effect/schema/Uint8Array":{kind:dt.bytes,exact:!0},"effect/schema/Option":{kind:dt.option,exact:"parameters"},"effect/schema/Result":{kind:dt.result,exact:"parameters"},"effect/schema/Exit":{kind:dt.exit,exact:"parameters"},"effect/schema/Cause":{kind:dt.cause,exact:"parameters"},"effect/schema/CauseReason":{kind:dt.causeReason,exact:"parameters"}};function Pd(e){let t=e.annotations?.representation;return Jt(t)&&typeof t.id=="string"?t.id:void 0}var SE=ma(e=>{let t=Lae(e),r=e.context;return t===e||r===void 0?t:zl(t,new Yo(r.isOptional,r.isMutable,void 0,r.annotations))});function Lae(e){switch(e._tag){case"Declaration":{let t=Pd(e);if(t!==void 0&&(t in Wh||t==="effect/schema/Json"||t==="effect/schema/MutableJson"))return e.recur(SE);let r=e.annotations?.toCodecJson,n=e.annotations?.toCodec;if(!or(r)&&!or(n))return e;let o=e.typeParameters.map(i=>J(Bn(i))),s=(or(r)?r(o):void 0)??(or(n)?n(o):void 0);return s===void 0?e:lt(e,[fc(s,SE)])}case"Arrays":case"Objects":case"Union":case"Suspend":return e.recur(SE);default:return e}}function Bae(e){let t=[...e].sort((n,o)=>{let s=typeof n.key=="number",i=typeof o.key=="number";return s!==i?s?-1:1:s?n.key-o.key:b4($i.encode(n.key),$i.encode(o.key))}),r=[];for(let n of t){let o=$i.encode(String(n.key));r.push(typeof n.key=="number"?0:1),TE(r,o.length),IE(r,o);let s=n.literal,i=$i.encode(A4(s));r.push(C4(s)),TE(r,i.length),IE(r,i)}return S4(r)}function C4(e){switch(typeof e){case"string":return 1;case"number":return 2;case"boolean":return 3;case"bigint":return 4;default:return 5}}function A4(e){if(typeof e=="symbol"){let t=globalThis.Symbol.keyFor(e);if(t===void 0)throw new Error("Binary layout: unregistered unique symbol (Symbol.keyFor)");return t}return String(e)}function k4(e){switch(e._tag){case"Symbol":return!0;case"Union":return e.types.some(k4);default:return!1}}function R4(e){let t=Pd(e);return t==="effect/schema/Json"||t==="effect/schema/MutableJson"?!0:or(e.annotations?.toCodecJson)}function $ae(e){let t=e.checks;if(t===void 0)return!1;let r=n=>n.annotations?.representation?.id==="effect/schema/isInt"?!0:n._tag==="FilterGroup"&&n.checks.some(r);return t.some(r)}function O4(e){for(;e._tag==="Suspend";)e=e.thunk();return e}function _4(e){return new Sn(e.enums.map(t=>new Ln(t[1],{title:t[0]})))}function ZW(e){let t=[],r=new Set,n=o=>{let s=O4(o);if(!r.has(s))switch(r.add(s),s._tag){case"Never":return;case"Union":s.types.forEach(n);return;case"Enum":_4(s).types.forEach(n);return;default:t.push(s)}};return e.types.forEach(n),t}function QW(e){switch(typeof e){case"string":return"string";case"number":return"number";case"boolean":return"bool";default:return"bigint"}}function bE(e){switch(e._tag){case"String":case"TemplateLiteral":case"Symbol":return dt.string;case"UniqueSymbol":if(globalThis.Symbol.keyFor(e.symbol)===void 0)throw new Error("Binary layout: unregistered unique symbol (Symbol.keyFor)");return dt.string;case"Boolean":return dt.bool;case"Null":return dt.null;case"Undefined":case"Void":return dt.undefined;case"Number":return dt.number;case"BigInt":return dt.bigint;case"Literal":switch(typeof e.literal){case"string":return dt.string;case"number":return dt.number;case"boolean":return dt.bool;default:return dt.bigint}case"Unknown":case"Any":case"ObjectKeyword":return dt.json;case"Objects":return dt.struct;case"Arrays":return dt.array;case"Declaration":{let t=Pd(e);if(t!==void 0&&t in Wh)return Wh[t].kind;if(R4(e))return dt.json;throw new Error(`Binary layout: declaration ${t??"<anonymous>"} has no toCodecJson or toCodec`)}case"Suspend":return bE(O4(e));default:throw new Error("Binary layout: union members are not uniquely identifiable")}}function YW(e){for(let t of e.fields)t.optional||(t.index<32?e.requiredMask|=1<<t.index:e.requiredWide=!0)}function jae(e){let t=P4(e),r=!t&&Hae(e);e=Bn(e);let n=new Map,o=!1,s=0,i=x=>({_:x,slot:x==="string"?s++:0});function a(x){let g=n.get(x);if(g!==void 0)return g;let y=c(x);return n.set(x,y),y}function c(x){switch(x._tag){case"String":case"TemplateLiteral":return i("string");case"Symbol":case"UniqueSymbol":return i("symbol");case"Boolean":return i("bool");case"Null":return i("null");case"Undefined":case"Void":return i("undefined");case"Number":return i($ae(x)?"int":"number");case"BigInt":return i("bigint");case"Literal":return JW(i(QW(x.literal)),[x.literal]);case"Unknown":case"Any":case"ObjectKeyword":return i("json");case"Never":return{_:"never",ast:x};case"Enum":return m(x,ZW(_4(x)));case"Suspend":{o=!0;let g=a(x.thunk());return n.set(x,g),g}case"Objects":return u(x);case"Arrays":return f(x);case"Union":return m(x,ZW(x));case"Declaration":return p(x)}}function u(x){let g=[],y=[],E=new Map;for(let T of x.propertySignatures){if(typeof T.name=="symbol")throw new Error("Binary layout: symbol property names are illegal");let S=String(T.name),w=T.type.context?.annotations,k=w?.[pae],C=typeof k=="number"?k:S4($i.encode(S));if(!Number.isInteger(C)||C<0||C>4294967295)throw new Error(`Binary layout: illegal field id for ${S}`);let R=E.get(C);R===void 0?E.set(C,[S]):R.push(S),g.push({name:S,id:C,tagBytes:Rae(C*ds+Ef),index:0,optional:T.type.context?.isOptional===!0,annotations:w,layout:void 0,wireMask:0,inline:!1}),y.push(T.type)}for(let[T,S]of E)if(T===0||S.length>1)throw new Error(`Binary layout field id collision: ${T} (${S.join(", ")})`);let b=[];for(let T of x.indexSignatures){if(k4(T.parameter))throw new Error("Binary layout: symbol property names are illegal");b.push({parameter:T.parameter,layout:void 0,wireMask:0})}let v={_:"struct",ast:x,fields:g,byId:new Map,extra:b,extraAll:b.length===1&&Uae(b[0].parameter)?b[0]:void 0,names:new Set(g.map(T=>T.name)),extraShape:void 0,optionalCount:0,requiredMask:0,requiredWide:!1};n.set(x,v);for(let T=0;T<g.length;T++){let S=g[T];S.layout=a(y[T]),S.wireMask=WR(S.layout),S.inline=jR(S.layout),S.optional&&v.optionalCount++,v.byId.set(S.id,S)}g.sort((T,S)=>T.id-S.id);for(let T=0;T<g.length;T++)g[T].index=T;YW(v);for(let T=0;T<b.length;T++)b[T].layout=a(x.indexSignatures[T].type),b[T].wireMask=WR(b[T].layout);return v}function f(x){let g=x.rest.length>0||x.elements.some(v=>v.context?.isOptional===!0),y=x.elements.filter(v=>v.context?.isOptional!==!0).length,E=Math.max(0,x.rest.length-1),b={_:"array",ast:x,elements:[],rest:[],hasCount:g,minCount:y+E,uniform:void 0,uniformInline:!1,uniformPacked:void 0,uniformNumbers:!1,run:void 0};n.set(x,b);for(let v of x.elements)b.elements.push({optional:v.context?.isOptional===!0,layout:a(v)});for(let v of x.rest)b.rest.push(a(v));if(b.elements.length===0&&b.rest.length===1){let v=b.rest[0];b.uniform=v,b.uniformPacked=_E(v),b.uniformNumbers=v._==="number",b.uniformInline=jR(v)}return b}function p(x){let g=Pd(x);switch(g){case"effect/schema/Date":return{_:"int64",flavor:"date"};case"effect/schema/DateTimeUtc":return{_:"int64",flavor:"utc"};case"effect/schema/DateTimeZoned":return i("dateTimeZoned");case"effect/schema/Duration":return i("duration");case"effect/schema/BigDecimal":return i("bigDecimal");case"effect/schema/Uint8Array":return i("bytes")}let y=x.typeParameters;switch(g){case"effect/schema/Option":{let E={_:"option",value:void 0};return n.set(x,E),E.value=a(y[0]),E}case"effect/schema/Result":{let E={_:"result",success:void 0,failure:void 0};return n.set(x,E),E.success=a(y[0]),E.failure=a(y[1]),E}case"effect/schema/Exit":{let E={_:"cause",error:void 0,defect:void 0},b={_:"exit",value:void 0,cause:E};return n.set(x,b),b.value=a(y[0]),E.error=a(y[1]),E.defect=a(y[2]),b}case"effect/schema/Cause":case"effect/schema/CauseReason":{let E={_:g==="effect/schema/Cause"?"cause":"causeReason",error:void 0,defect:void 0};return n.set(x,E),E.error=a(y[0]),E.defect=a(y[1]),E}}if(g!==void 0&&g in Wh)throw new Error(`Binary layout: native declaration ${g} has no layout constructor`);if(R4(x))return i("json");throw new Error(`Binary layout: declaration ${g??"<anonymous>"} has no toCodecJson or toCodec`)}function m(x,g){if(g.length===0)return{_:"never",ast:x};let y=[],E=[],b=new Map,v=new Map,T=(R,M)=>{let $=b.get(R);if($!==void 0&&$._!==M._)throw new Error("Binary layout: union members are not uniquely identifiable");b.set(R,M)};for(let R of g){if(R._tag==="Literal"){let M=bE(R),$=v.get(M);$===void 0?v.set(M,[R.literal]):$.includes(R.literal)||$.push(R.literal);continue}if(R._tag==="UniqueSymbol"){bE(R),T(dt.string,i("symbol"));continue}if(R._tag==="Objects"||R._tag==="Arrays"){let M=ac(R);if(M!==void 0&&M.length>0){for(let $ of M)if(typeof $.key=="symbol")throw new Error("Binary layout: symbol property names are illegal");y.push({member:R,sentinels:M});continue}}E.push({member:R,kind:bE(R)})}for(let[R,M]of v)T(R,JW(i(QW(M[0])),M));if(y.length===0&&E.length===0&&b.size===1)return b.values().next().value;let S=new Set(b.keys());for(let{kind:R}of E){if(S.has(R))throw new Error("Binary layout: union members are not uniquely identifiable");S.add(R)}if(y.length===0&&b.size===0&&E.length===1){let R=a(E[0].member);return n.set(x,R),R}let w=new Map,k=[];for(let{sentinels:R}of y){let M=Bae(R);if(w.has(M))throw new Error(`Binary layout sentinel collision: ${M}`);w.set(M,R),k.push(M)}let C={_:"union",ast:x,variants:[],byTag:new Map,discriminator:void 0,others:[],byKind:new Map,byPos:[]};n.set(x,C);for(let R=0;R<y.length;R++){let{member:M,sentinels:$}=y[R],te=k[R],xe=a(M),Le,Er;if(M._tag==="Objects"){let Oe=xe,rr=new Set($.map(Rn=>String(Rn.key))),lo=Oe.fields.filter(Rn=>!rr.has(Rn.name)),Xs={_:"struct",ast:Oe.ast,fields:lo,byId:new Map(lo.map(Rn=>[Rn.id,Rn])),extra:Oe.extra,extraAll:Oe.extraAll,names:Oe.names,extraShape:void 0,optionalCount:lo.reduce((Rn,nI)=>nI.optional?Rn+1:Rn,0),requiredMask:0,requiredWide:!1};YW(Xs),Le=Xs,Er=!1}else Le=xe,Er=!0;let Ee={tag:te,sentinels:$,tuple:Er,payload:Le,position:0};C.variants.push(Ee),C.byTag.set(te,Ee)}for(let[R,M]of b)C.others.push({kind:R,layout:M,position:0}),C.byKind.set(R,M);for(let{kind:R,member:M}of E){let $=a(M);C.others.push({kind:R,layout:$,position:0}),C.byKind.set(R,$)}for(let R of[...C.variants].sort((M,$)=>M.tag-$.tag))R.position=C.byPos.length,C.byPos.push({variant:R,layout:R.payload});for(let R of[...C.others].sort((M,$)=>M.kind-$.kind))R.position=C.byPos.length,C.byPos.push({variant:void 0,layout:R.layout});return C.others.sort((R,M)=>XW(R.layout)-XW(M.layout)),C.discriminator=gce(C.variants),C}return{layout:a(e),recursive:o,exact:t,exitSuccess:r}}function P4(e){let t=new Map,r=n=>{if(n.encoding!==void 0||n.checks!==void 0||n.encodingChecks!==void 0)return!1;switch(n._tag){case"String":case"Symbol":case"Boolean":case"Null":case"Undefined":case"Void":case"Number":case"BigInt":case"Literal":return!0;case"Never":return!0;case"Unknown":case"Any":return!0;case"Arrays":return n.elements.every(r)&&n.rest.every(r);case"Objects":return n.propertySignatures.every(o=>r(o.type))&&n.indexSignatures.every(o=>o.parameter._tag==="String"&&r(o.parameter)&&r(o.type));case"Union":return(n.options?.mode??"anyOf")==="anyOf"&&n.types.every(r);case"Suspend":{let o=t.get(n);if(o!==void 0)return o;t.set(n,!0);let s=r(n.thunk());return t.set(n,s),s}case"Declaration":{let o=Pd(n),s=o!==void 0?Wh[o]:void 0;return s===void 0?!1:s.exact===!0||n.typeParameters.every(r)}default:return!1}};return r(e)}function Hae(e){return e._tag==="Declaration"&&e.encoding===void 0&&e.checks===void 0&&e.encodingChecks===void 0&&Pd(e)==="effect/schema/Exit"&&P4(e.typeParameters[0])}var uo={backEdge:0,bool:1,null:2,undefined:3,number:4,int:5,string:6,symbol:7,bytes:8,bigint:9,json:10,duration:11,bigDecimal:12,dateTimeZoned:13,date:14,dateTimeUtc:15,never:16,struct:17,array:18,union:19,option:20,result:21,exit:22,cause:23,causeReason:24,literal:25};function qae(e){let t=new Map,r=[],n=Number.MAX_SAFE_INTEGER;function o(i){let a=r.lastIndexOf(i);if(a>=0){a<n&&(n=a);let h=[uo.backEdge];return Oc(h,r.length-a),VW(h)}let c=t.get(i);if(c!==void 0)return c;let u=r.length,f=n;n=Number.MAX_SAFE_INTEGER,r.push(i);let p=VW(s(i));r.pop();let m=n>=u;return m&&t.set(i,p),n=m?f:Math.min(f,n),p}function s(i){let a=[];switch(i._){case"bool":case"null":case"undefined":case"number":case"int":case"string":case"symbol":case"bytes":case"bigint":case"json":case"duration":case"bigDecimal":case"dateTimeZoned":return a.push(uo[i._]),a;case"literal":{a.push(uo.literal),IE(a,s(i.leaf)),Oc(a,i.values.length);let c=i.values.map(u=>[C4(u),A4(u)]).sort((u,f)=>u[1]<f[1]?-1:u[1]>f[1]?1:u[0]-f[0]);for(let[u,f]of c){a.push(u);let p=$i.encode(f);Oc(a,p.length),IE(a,p)}return a}case"int64":return a.push(i.flavor==="date"?uo.date:uo.dateTimeUtc),a;case"never":return a.push(uo.never),a;case"struct":{a.push(uo.struct),Oc(a,i.fields.length);for(let c of i.fields)TE(a,c.id),a.push(c.optional?1:0),No(a,o(c.layout));Oc(a,i.extra.length);for(let c of i.extra)No(a,o(c.layout));return a}case"array":{a.push(uo.array),Oc(a,i.elements.length);for(let c of i.elements)a.push(c.optional?1:0),No(a,o(c.layout));Oc(a,i.rest.length);for(let c of i.rest)No(a,o(c));return a}case"union":{a.push(uo.union),Oc(a,i.byPos.length);for(let c of i.byPos){let u=c.variant;u===void 0?a.push(0):(a.push(1,u.tuple?1:0),TE(a,u.tag)),No(a,o(c.layout))}return a}case"option":return a.push(uo.option),No(a,o(i.value)),a;case"result":return a.push(uo.result),No(a,o(i.success)),No(a,o(i.failure)),a;case"exit":return a.push(uo.exit),No(a,o(i.value)),No(a,o(i.cause.error)),No(a,o(i.cause.defect)),a;case"cause":case"causeReason":return a.push(i._==="cause"?uo.cause:uo.causeReason),No(a,o(i.error)),No(a,o(i.defect)),a}}return o(e)}function zae(e,t){let r=new Uint8Array(8);for(let n=0;n<4;n++)r[n]=e>>>n*8&255,r[n+4]=t>>>n*8&255;return r}var Wae={positional:!1,envelope:mae,expectedEnvelope:"version 2 envelope, flags 0",fingerprint:new Uint8Array(8)};function Kae(e){let t=qae(e);return{positional:!0,envelope:hae,expectedEnvelope:"version 2 envelope, flags 1",fingerprint:zae(Number(t&zW),Number(t>>Sae&zW))}}function XW(e){switch(e._){case"json":return 2;case"struct":return 1;default:return 0}}function HR(e,t){switch(e._){case"literal":return Qh(e,t);case"bool":return typeof t=="boolean";case"null":return t===null;case"undefined":return t===void 0;case"number":case"int":return typeof t=="number";case"string":return typeof t=="string";case"symbol":return typeof t=="symbol";case"bigint":return typeof t=="bigint";case"bytes":return t instanceof Uint8Array;case"int64":return e.flavor==="date"?t instanceof Date:vu(t)&&t._tag==="Utc";case"dateTimeZoned":return vu(t)&&t._tag==="Zoned";case"duration":return Qi(t);case"bigDecimal":return Tu(t);case"option":return ci(t);case"result":return $f(t);case"exit":return ws(t);case"cause":return il(t);case"causeReason":return al(t);case"array":return Array.isArray(t);case"struct":return Jt(t)&&!Array.isArray(t);case"json":return!0;case"union":case"never":return!1}}function ut(e,t,r){throw dr(new le({expected:e},t,r))}function kn(e,t=new Set){if(!$d(e))return!1;let r=Array.isArray(e),n=Object.getPrototypeOf(e);if(r||n===Object.prototype||n===null){if(t.has(e))return!0;t.add(e);try{if(r){for(let o=0;o<e.length;o++)if(kn(e[o],t))return!0}else for(let o of Object.keys(e))if(kn(e[o],t))return!0}finally{t.delete(e)}return!1}if(e instanceof Date||e instanceof Uint8Array||vu(e)||Qi(e)||Tu(e))return!1;if(t.has(e))return!0;t.add(e);try{if(ci(e))return de(e)&&kn(e.value,t);if($f(e))return kn(tt(e)?e.success:e.failure,t);if(ws(e))return kn(ft(e)?e.value:e.cause,t);if(il(e))return e.reasons.some(o=>kn(o,t));if(al(e))switch(e._tag){case"Fail":return kn(e.error,t);case"Die":return kn(e.defect,t);case"Interrupt":return!1}if(Cl(e)){for(let o of e)if(kn(o,t))return!0;return!1}if(Ay(e)){for(let[o,s]of e)if(kn(o,t)||kn(s,t))return!0;return!1}if(_y(e)){for(let o of e)if(kn(o,t))return!0;return!1}if(cm(e))return kn(nc(e),t);for(let o of Object.keys(e))if(kn(e[o],t))return!0}finally{t.delete(e)}return!1}function CE(e,t,r,n){let o=n.beginSized();zr(e,t,r,n),n.endSized(o)}function Vae(e,t,r){let n=globalThis.Symbol.keyFor(t);n===void 0&&ut("registered symbol",t,e.options),r.string(n)}function e4(e,t,r,n){let o=r;switch(o._tag){case"Fail":n.byte(0),zr(e,t.error,o.error,n);return;case"Die":n.byte(1),zr(e,t.defect,o.defect,n);return;case"Interrupt":o.fiberId===void 0?n.byte(2):(n.byte(3),n.f64(o.fiberId))}}function Gae(e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)>127)return!1;return!0}function t4(e,t,r){if(e.layout!==t||e.keys.length!==r.length)return!1;for(let n=0;n<r.length;n++)if(e.keys[n]!==r[n])return!1;return!0}function Jae(e,t){if(e.extraAll===void 0||t.length>Fae)return!1;let r=0;for(let n=0;n<t.length;n++)if(r+=t[n].length,r>Nae)return!1;return!0}function QR(e,t,r){let n=Object.keys(r),o=t.extraShape;if(o!==void 0&&t4(o,t,n))return o.pairs;let s=Jae(t,n),i=s?void 0:e.extraShape;if(i!==void 0&&t4(i,t,n))return i.pairs;let a=t.names,c=t.extraAll,u=[],f=!0;for(let m of n){if(a.has(m))continue;let h=c??(e.indexSignatures??=new qh(e.options)).find(t,m);h!==void 0&&(f&&!Gae(m)&&(f=!1),u.push([m,h,void 0]))}if(f)u.sort((m,h)=>m[0]<h[0]?-1:m[0]>h[0]?1:0);else{for(let m of u)m[2]=$i.encode(m[0]);u.sort((m,h)=>b4(m[2],h[2]))}if(s)for(let m of u)m[2]??=$i.encode(m[0]);let p={layout:t,keys:n,pairs:u};return s?t.extraShape=p:e.extraShape=p,u}function YR(e,t,r,n,o){for(let[s,i,a]of t){let c=a===void 0?s.length:a.length,u=r[s],f=XR(i.layout,u,e.options),p=f%ds;if(o===void 0)n.uvarint(c*ds+p);else{if(!o.disabled){let m=F4(o,s);if(m!==void 0){n.uvarint(m*16+p*2+1),Ze[Q++]=s,qR(e,i.layout,u,f,n),Q--;continue}N4(o,s)}n.uvarint(c*16+p*2)}a===void 0?n.string(s):n.bytes(a),Ze[Q++]=s,qR(e,i.layout,u,f,n),Q--}}function XR(e,t,r){if(e._==="literal")return Qh(e,t)||ut(RE(e),t,r),XR(e.leaf,t,r);switch(e._){case"bool":return typeof t!="boolean"&&ut("a boolean",t,r),t?Jh:Gh;case"number":if(typeof t!="number"&&ut("a number",t,r),GR(t))return Sf;{let n=JR(t);return n===0?Vh:n*ds+Zh}case"int":return Number.isSafeInteger(t)||ut("an integer",t,r),Sf;default:return Ef}}function qR(e,t,r,n,o){switch(n%ds){case Gh:case Jh:return;case Sf:o.numberVarint(r);return;case Vh:o.f64(r);return;case Zh:{let i=Math.floor(n/ds);o.numberVarint(Math.round(r*_c[i])),o.uvarint(i);return}default:CE(e,t,r,o)}}function Zae(e,t,r,n){let o=XR(t.layout,r,e.options),s=o%ds;if(s===Ef){let i=n.idAndMark(t.tagBytes);zr(e,t.layout,r,n),n.endSized(i);return}n.uvarint(t.id*ds+s),qR(e,t.layout,r,o,n)}function Qae(e,t){let r=e.byName;if(r===void 0)return;let n=Object.getOwnPropertyNames(t),o=0;for(let i=0;i<n.length;i++){let a=r.get(n[i]);a!==void 0&&(o|=1<<a)}let s=e.struct;if((o&s.requiredMask)!==s.requiredMask){let i=s.fields;for(let a=0;a<i.length;a++){let c=i[a];if(!c.optional&&(o&1<<a)===0)throw Ze[Q++]=c.name,dr(new Yt(c.annotations))}}return o}function Yae(e,t,r,n){let o=r;if(t.extra.length>0){let i=e.intern;e.intern=void 0;let a=QR(e,t,o);if(a.length>0){n.uvarint(0);let c=n.beginSized();YR(e,a,o,n,i),n.endSized(c)}}let s=t.fields;for(let i=0;i<s.length;i++){let a=s[i],c=a.name;if(!Object.hasOwn(o,c)){if(a.optional)continue;throw Ze[Q++]=c,dr(new Yt(a.annotations))}Ze[Q++]=c,Zae(e,a,o[c],n),Q--}}function Xae(e,t,r,n){let o=r,s=e.intern;e.intern=void 0;let i=t.optionalCount+7>>3,a=0;if(i>0){a=n.len;for(let f=0;f<i;f++)n.byte(0)}let c=t.fields,u=0;for(let f=0;f<c.length;f++){let p=c[f],m=p.name,h=Object.hasOwn(o,m);if(p.optional){if(h&&(n.buf[n.start+a+(u>>3)]|=1<<(u&7)),u++,!h)continue}else if(!h)throw Ze[Q++]=m,dr(new Yt(p.annotations));Ze[Q++]=m,p.inline?zr(e,p.layout,o[m],n):CE(e,p.layout,o[m],n),Q--}if(t.extra.length>0){let f=QR(e,t,o);n.uvarint(f.length),YR(e,f,o,n,s)}}function ece(e){switch(e._){case"string":return ZR;case"array":return e.uniform?._==="string"?I4:gE;case"struct":return e.extra.length>0?T4:gE;default:return gE}}function tce(e){let t=e.uniform;if(t===void 0){if(e.rest.length!==1)return;t=e.rest[0];for(let r of e.elements)if(r.optional||r.layout!==t)return}return t._==="struct"?t:void 0}function M4(e){let t=e.run;if(t!==void 0)return t;let r=tce(e);if(r===void 0)return e.run=t=null,t;let n=r.fields.map(s=>ece(s.layout)),o=r.fields.length<=w4;return t={struct:r,intern:n,shapes:o,byName:o&&r.extra.length===0?new Map(r.fields.map((s,i)=>[s.name,i])):void 0},e.run=t,t}var rce=16,nce=64;function r4(e,t){return e[t]??={values:[],refs:void 0,hits:0,disabled:!1}}function F4(e,t){let r=e.refs;if(r!==void 0){let o=r.get(t);return o!==void 0&&e.hits++,o}let n=e.values;for(let o=0;o<n.length;o++)if(n[o]===t)return e.hits++,o}function N4(e,t){let r=e.values;if(e.refs!==void 0){if(e.hits===0&&r.length>=nce){e.disabled=!0,e.refs=void 0;return}e.refs.set(t,r.length)}else if(r.length>=rce){let n=e.refs=new Map;for(let o=0;o<r.length;o++)n.set(r[o],o);n.set(t,r.length)}r.push(t)}var eO=0,oce=1,tO=2,sce=64,ice=512;function ace(){return{slots:[],marks:[],frame:0}}function U4(e,t){return e[t]??={values:[],refs:new Map,state:eO,stamp:-1}}function D4(e,t){if(e.refs.has(t)){e.state=oce;return}e.refs.set(t,e.values.length),e.values.push(t),e.values.length>=sce&&(e.state=tO)}function L4(e,t){let r=e.values;r.length>=ice||(e.refs.set(t,r.length),r.push(t))}function cce(e,t){t.stamp!==e.frame&&(t.stamp=e.frame,e.marks.push({slot:t,length:t.values.length,state:t.state}))}function uce(e){e.marks.length=0,e.frame++}function fce(e){let t=e.marks;for(let r=t.length-1;r>=0;r--){let{length:n,slot:o,state:s}=t[r],i=o.values;for(let a=n;a<i.length;a++)o.refs.delete(i[a]);i.length=n,o.state=s}t.length=0,e.frame++}function lce(e,t,r,n){let o=U4(e.slots,t.slot),s=o.state;if(s===tO){n.string(r);return}if(cce(e,o),s===eO){n.string(r),D4(o,r);return}let i=o.refs.get(r);if(i!==void 0){n.uvarint(i*2+1);return}n.byte(0),L4(o,r),n.string(r)}function dce(e,t,r){let n=U4(e,t.slot),o=n.state;if(o===tO)return r.readUtf8(r.end-r.pos);if(o===eO){let a=r.readUtf8(r.end-r.pos);return D4(n,a),a}let s=r.uvarint();if((s&1)===1){let a=(s-1)/2,c=n.values;return a>=c.length&&j("a dictionary reference",s,r.options),c[a]}s!==0&&j("a dictionary marker",s,r.options);let i=r.readUtf8(r.end-r.pos);return L4(n,i),i}function B4(e,t,r,n,o){if(!e.disabled){let i=F4(e,n);if(i!==void 0){o.uvarint(i*2+1);return}N4(e,n)}let s=o.beginSized();zr(t,r,n,o),o.endSizedRun(s)}function pce(e,t,r,n,o){let s=[],i=[];for(let a=0;a<n;a++){Ze[Q++]=a;let c=o.beginSized();mce(e,t,s,i,r[a],o),o.endSized(c),Q--}}function mce(e,t,r,n,o,s){let i=t.struct,a=o,c=i.fields,u;if(i.extra.length>0){let y=QR(e,i,a);y.length>0&&(u=y)}let f=!t.shapes,p=u===void 0?0:yE,m=Qae(t,a);if(m!==void 0)p=m;else for(let y=0;y<c.length;y++){let E=c[y];if(Object.hasOwn(a,E.name))f||(p|=1<<y);else if(!E.optional)throw Ze[Q++]=E.name,dr(new Yt(E.annotations))}let h=-1;for(let y=0;y<r.length;y++)if(r[y]===p){h=y;break}h>=0?s.uvarint(h+1):(s.uvarint(0),f||r.push(p));let x=h<0,g=e.positional&&!f;if(x&&g&&s.uvarint(p),u!==void 0){x&&!g&&s.uvarint(0);let y=s.beginSized();YR(e,u,a,s),s.endSizedRun(y)}for(let y=0;y<c.length;y++){let E=c[y];if(f?!Object.hasOwn(a,E.name):(p&1<<y)===0)continue;x&&!g&&s.uvarint(E.id),Ze[Q++]=E.name;let b=t.intern[y];if(b===ZR)B4(r4(n,y),e,E.layout,a[E.name],s);else{b!==gE&&(e.intern=r4(n,y));let v=s.beginSized();zr(e,E.layout,a[E.name],s),s.endSizedRun(v),e.intern=void 0}Q--}}function $4(e,t,r){let n=e.elements.length;if(t<n)return e.elements[t].layout;let o=Math.max(0,e.rest.length-1),s=Math.max(n,r-o);return t>=s?e.rest[t-s+1]:e.rest[0]}function hce(e,t,r,n){let o=r.length;if(t.rest.length===0&&o>t.elements.length)throw Ze[Q++]=t.elements.length,dr(new Nu(t.ast,r[t.elements.length],e.options));if(o<t.minCount)throw Ze[Q++]=o,dr(new Yt(void 0));if(t.hasCount&&n.uvarint(o),o>0){let i=M4(t);if(i!==null){pce(e,i,r,o,n);return}}let s=t.uniform;if(s!==void 0){if(t.uniformNumbers){xce(e,r,o,n);return}let i=e.intern;if(e.intern=void 0,i!==void 0){for(let c=0;c<o;c++)Ze[Q++]=c,B4(i,e,s,r[c],n),Q--;return}let a=t.uniformInline;for(let c=0;c<o;c++)Ze[Q++]=c,a?zr(e,s,r[c],n):CE(e,s,r[c],n),Q--;return}for(let i=0;i<o;i++){let a=$4(t,i,o);Ze[Q++]=i,jR(a)?zr(e,a,r[i],n):CE(e,a,r[i],n),Q--}}var n4=[];function xce(e,t,r,n){let o=!0,s=!0;for(let i=0;i<r;i++){let a=t[i];if(typeof a!="number"&&(Ze[Q++]=i,ut("a number",a,e.options)),GR(a))(a<0?-a:a)>DR&&(s=!1);else{o=!1;let c=JR(a);c===0?s=!1:n4[i]=c}if(!o&&!s)break}if(o){n.byte(x4);for(let i=0;i<r;i++)n.numberVarint(t[i])}else if(s){n.byte(g4);for(let i=0;i<r;i++){let a=t[i],c=Number.isInteger(a)?0:n4[i],u=c===0?a:Math.round(a*_c[c]),f=u<0||u===0&&1/u<0,p=f?-u:u;n.uvarint((p*2+(f?1:0))*16+c)}}else{n.byte(h4);for(let i=0;i<r;i++)n.f64(t[i])}}function gce(e){if(!(e.length<2||e.some(t=>t.tuple)))for(let t of e[0].sentinels){let r=new Map;for(let n of e){let o=n.sentinels.find(s=>s.key===t.key);if(o===void 0||r.has(o.literal)||Number.isNaN(o.literal))break;r.set(o.literal,n)}if(r.size===e.length)return{key:t.key,rows:r}}}function zR(e,t){let r=e.sentinels;for(let n=0;n<r.length;n++){let{key:o,literal:s}=r[n];if(t[o]!==s||!Object.hasOwn(t,o))return!1}return!0}function yce(e,t){return e.tuple?Array.isArray(t)&&zR(e,t):Jt(t)&&!Array.isArray(t)&&zR(e,t)}function o4(e,t,r,n){e.positional?n.uvarint(t.position):(n.byte(dt.variant),n.u32le(t.tag)),zr(e,t.payload,r,n)}function Sce(e,t,r,n){let o=t.discriminator;if(o!==void 0){if(Jt(r)&&!Array.isArray(r)){let s=r,i=o.rows.get(s[o.key]);if(i!==void 0&&zR(i,s)){o4(e,i,r,n);return}}}else for(let s of t.variants)if(yce(s,r)){o4(e,s,r,n);return}for(let s of t.others)if(HR(s.layout,r)){e.positional?n.uvarint(s.position):n.byte(s.kind),zr(e,s.layout,r,n);return}throw dr(new at(t.ast,r,e.options))}function zr(e,t,r,n){switch(t._){case"literal":Qh(t,r)||ut(RE(t),r,e.options),zr(e,t.leaf,r,n);return;case"bool":typeof r!="boolean"&&ut("a boolean",r,e.options),n.byte(r===!0?1:0);return;case"null":r!==null&&ut("null",r,e.options);return;case"undefined":r!==void 0&&ut("undefined",r,e.options);return;case"number":{if(typeof r!="number"&&ut("a number",r,e.options),GR(r)){n.numberVarint(r);return}let o=JR(r);o>0?(n.numberVarint(Math.round(r*_c[o])),n.byte(o)):n.f64(r);return}case"int":{Number.isSafeInteger(r)||ut("an integer",r,e.options),n.numberVarint(r);return}case"string":{typeof r!="string"&&ut("a string",r,e.options);let o=e.dict;o===void 0?n.string(r):lce(o,t,r,n);return}case"symbol":typeof r!="symbol"&&ut("a symbol",r,e.options),Vae(e,r,n);return;case"bytes":r instanceof Uint8Array||ut("a Uint8Array",r,e.options),n.bytes(r);return;case"bigint":typeof r!="bigint"&&ut("a bigint",r,e.options),n.zigzag(r);return;case"int64":{HR(t,r)||ut(t.flavor==="date"?"a Date":"a DateTime.Utc",r,e.options);let o=t.flavor==="date"?r.getTime():r.epochMilliseconds;Number.isNaN(o)&&ut("a valid Date",r,e.options),n.i64(BigInt(o));return}case"dateTimeZoned":{HR(t,r)||ut("a DateTime.Zoned",r,e.options);let o=r;n.i64(BigInt(o.epochMilliseconds)),o.zone._tag==="Offset"?(n.byte(0),n.i32le(o.zone.offset)):(n.byte(1),n.string(o.zone.id));return}case"duration":{Qi(r)||ut("a Duration",r,e.options);let o=r.value;switch(o._tag){case"Infinity":n.byte(1);return;case"NegativeInfinity":n.byte(2);return;case"Nanos":n.byte(0),n.zigzag(o.nanos);return;case"Millis":n.byte(0),n.zigzag(BigInt(o.millis)*gae);return}}case"bigDecimal":{Tu(r)||ut("a BigDecimal",r,e.options);let o=em(r);n.zigzag(o.value),n.zigzag(BigInt(o.scale));return}case"json":{let o;try{o=JSON.stringify(r)}catch{o=void 0}o===void 0&&(kn(r)&&ut("acyclic value",r,e.options),ut("a JSON-serializable value",r,e.options)),n.string(o);return}case"option":{ci(r)||ut("an Option",r,e.options);let o=r;o._tag==="None"?n.byte(0):(n.byte(1),zr(e,t.value,o.value,n));return}case"result":{$f(r)||ut("a Result",r,e.options);let o=r;o._tag==="Success"?(n.byte(0),zr(e,t.success,o.success,n)):(n.byte(1),zr(e,t.failure,o.failure,n));return}case"exit":{ws(r)||ut("an Exit",r,e.options);let o=r;o._tag==="Success"?(n.byte(0),zr(e,t.value,o.value,n)):(n.byte(1),zr(e,t.cause,o.cause,n));return}case"cause":{il(r)||ut("a Cause",r,e.options);let o=r.reasons;n.uvarint(o.length);for(let s of o){let i=n.beginSized();e4(e,t,s,n),n.endSized(i)}return}case"causeReason":{al(r)||ut("a Cause.Reason",r,e.options),e4(e,t,r,n);return}case"struct":{(!Jt(r)||Array.isArray(r))&&ut("an object",r,e.options),e.positional?Xae(e,t,r,n):Yae(e,t,r,n);return}case"array":{Array.isArray(r)||ut("an array",r,e.options),hce(e,t,r,n);return}case"union":Sce(e,t,r,n);return;case"never":throw dr(new at(t.ast,r,e.options))}}var hE=new wE;function s4(e,t,r,n,o){let s=o.beginSized();o.byte(n.envelope),n.positional&&o.bytes(n.fingerprint),zr(e,t,r,o),o.endSized(s)}function j4(e,t,r,n,o,s){let i={options:n,positional:o.positional,indexSignatures:void 0,extraShape:void 0,intern:void 0,dict:s},a=hE??new wE,c=a===hE;c&&(hE=void 0),a.reset();let u=Q,f=!1;try{if(r===void 0)Q=0,s4(i,e,t,o,a);else for(let m=0;m<r.length;m++)Q=0,s4(i,e,r[m],o,a);let p=a.out();return f=!0,p}finally{s!==void 0&&(f?uce(s):fce(s)),a.abort(),Q=u,c&&(hE=a)}}function H4(e,t,r,n,o){return j4(e,void 0,t,r,n,o)}function AE(e,t,r,n,o){return j4(e,t,void 0,r,n,o)}function PE(e){return ws(e)&&ft(e)}var kr=globalThis.Symbol.for("~effect/encoding/SchemaBinary/absent");function un(e,t){let r=Kh(e,t);return r!==kr&&t.pos!==t.end&&j("no leftover bytes",void 0,t.options),r}function q4(e,t){let r=t.enter(t.uvarint()),n=un(e,t);return t.exit(r),n}function z4(e,t){if(OE(e))return Kh(e,t);let r=_E(e),n=t.enter(r!==void 0?r:e._==="null"||e._==="undefined"?0:t.uvarint()),o=un(e,t);return t.exit(n),o}var bce=8;function Ece(e,t){let r=e.set;if(r!==void 0)return r.has(t)?!0:(r.add(t),!1);let n=e.list;if(n.includes(t))return!0;if(n.length>=bce){let o=e.set=new Set;for(let s=0;s<n.length;s++)o.add(n[s]);o.add(t)}else n.push(t);return!1}function W4(e,t,r,n,o){let s=t.uvarint(),i=Math.floor(o===void 0?s/ds:s/16),a=o===void 0?s-i*ds:Math.floor((s-i*16)/2),c=o===void 0?t.readUtf8(i):Ice(o,s,i,t);e.names.has(c)&&j("an extra key distinct from declared fields",c,t.options),Ece(n,c)&&j("unique extra keys",void 0,t.options);let u=e.extraAll??(t.indexSignatures??=new qh(t.options)).find(e,c);if(u===void 0){rO(a,t);return}Ze[Q++]=c;let f=G4(u.layout,u.wireMask,a,t);Q--,f!==kr&&B(r,c,f)}function Ice(e,t,r,n){if((t&1)===1)return r>=e.length&&j("a known back-reference",void 0,n.options),e[r];let o=n.readUtf8(r);return e.push(o),o}function K4(e){return new At([e.name],new Yt(e.annotations))}function V4(e,t){throw dr(new Ft(e.ast,t))}function FR(e){for(;(e.byte()&128)!==0;);}function rO(e,t){switch(e){case Ef:t.take(t.uvarint());return;case Sf:FR(t);return;case Vh:t.take(8);return;case Gh:case Jh:case vae:return;case Zh:FR(t),FR(t);return;case wae:t.take(4);return}}function WR(e){if(e._==="literal")return WR(e.leaf);switch(e._){case"bool":return 1<<Gh|1<<Jh;case"number":return 1<<Sf|1<<Vh|1<<Zh;case"int":return 1<<Sf;default:return 1<<Ef}}function Tce(e,t){switch(e){case Gh:return!1;case Jh:return!0;case Sf:return t.numberVarint();case Vh:return t.f64();case Zh:{let r=t.numberVarint(),n=t.uvarint();return(n===0||n>kE)&&j("a decimal scale in [1, 8]",n,t.options),r/_c[n]}}return j("matching field wire kind",void 0,t.options)}function G4(e,t,r,n){if((t&1<<r)===0)return rO(r,n),kr;if(r!==Ef){let i=Tce(r,n);return e._==="literal"&&!Qh(e,i)&&j(RE(e),i,n.options),i}let o=n.enter(n.uvarint()),s=un(e,n);return n.exit(o),s}function wce(e,t){let r;e.extra.length>0&&(r=t.intern,t.intern=void 0);let n={},o=0,s=0,i,a,c,u=!1,f=e.fields,p=0;for(;t.pos<t.end;){let m=t.fieldTag(),h=Math.floor(m/ds),x=m-h*ds;if(h===0){u&&j("unique field ids",void 0,t.options),u=!0,x!==Ef&&j("extra field map",void 0,t.options);let b=t.enter(t.uvarint());Z4(e,t,n,r),t.exit(b);continue}let g;if(p<f.length&&f[p].id===h?(g=f[p],p++):(g=e.byId.get(h),g!==void 0&&(p=g.index+1)),g===void 0){c===void 0?c=new Set:c.has(h)&&j("unique field ids",void 0,t.options),c.add(h),rO(x,t);continue}let y=g.index;if(y<32){let b=1<<y;(o&b)!==0&&j("unique field ids",void 0,t.options),o|=b}else i===void 0?i=new Set([y]):(i.has(y)&&j("unique field ids",void 0,t.options),i.add(y));Ze[Q++]=g.name;let E=G4(g.layout,g.wireMask,x,t);Q--,E!==kr&&(B(n,g.name,E),y<32?s|=1<<y:(a??=new Set).add(y))}return J4(e,s,a,t),n}function J4(e,t,r,n){if((t&e.requiredMask)===e.requiredMask&&!e.requiredWide)return;let o=e.fields,s;for(let i=0;i<o.length;i++){let a=o[i],c=a.index,u=c<32?(t&1<<c)!==0:r?.has(c)===!0;if(!a.optional&&!u&&((s??=[]).push(K4(a)),n.options.errors!=="all"))break}s!==void 0&&V4(e,s)}function vce(e,t){let r;e.extra.length>0&&(r=t.intern,t.intern=void 0);let n={},o=e.optionalCount+7>>3,s=0;o>0&&(t.pos+o>t.end&&j("complete value",void 0,t.options),s=t.pos,t.pos+=o);let i=t.buf,a=e.fields,c=0,u;for(let f=0;f<a.length;f++){let p=a[f];if(p.optional){let h=(i[s+(c>>3)]&1<<(c&7))!==0;if(c++,!h)continue}Ze[Q++]=p.name;let m=p.inline?z4(p.layout,t):q4(p.layout,t);if(Q--,m!==kr)B(n,p.name,m);else if(!p.optional&&((u??=[]).push(K4(p)),t.options.errors!=="all"))break}if(u!==void 0&&V4(e,u),e.extra.length>0){let f=t.uvarint();if(f>t.remaining&&j("complete value",void 0,t.options),f>0){let p={list:[],set:void 0};for(let m=0;m<f;m++)W4(e,t,n,p,r)}}return n}function Z4(e,t,r,n){let o={list:[],set:void 0};for(;t.pos<t.end;)W4(e,t,r,o,n)}function Cce(e,t,r){let n=r.uvarint();if((n&1)===1){let i=(n-1)/2;return i>=e.length&&j("a known back-reference",void 0,r.options),e[i]}if(t._==="string"){if(r.dict!==void 0){let a=r.enter(n/2),c=un(t,r);return r.exit(a),e.push(c),c}let i=r.readUtf8(n/2);return e.push(i),i}let o=r.enter(n/2),s=un(t,r);return r.exit(o),e.push(s),s}function Ace(e,t,r){let n=new Array(t),o=[],s=[];for(let i=0;i<t;i++){Ze[Q++]=i;let a=r.enter(r.uvarint());n[i]=Rce(e,o,s,r),r.exit(a),Q--}return n}function kce(e,t){let r=t.uvarint(),n=e.fields,o=r&~yE;(r>yE*2-1||o>>>n.length)&&j("a known row shape",void 0,t.options);let s=[];(r&yE)!==0&&s.push(null);for(let i=0;i<n.length;i++)(o&1<<i)!==0&&s.push(n[i]);return s}function Rce(e,t,r,n){let o=e.struct,s={},i=0,a,c=n.uvarint(),u;if(c===0?n.positional&&e.shapes&&(u=kce(o,n),t.push(u)):(u=t[c-1],u===void 0&&j("a known row shape",void 0,n.options)),u!==void 0){for(let f=0;f<u.length;f++){let p=i4(e,r,u[f],s,n);p>=0&&(p<32?i|=1<<p:(a??=new Set).add(p))}n.pos!==n.end&&j("no leftover bytes",void 0,n.options)}else{let f=e.shapes?[]:void 0,p=0,m,h,x=!1;for(;n.pos<n.end;){let g=n.uvarint(),y;g===0?(x&&j("unique field ids",void 0,n.options),x=!0,y=null):(y=o.byId.get(g),y===void 0?h===void 0?h=new Set([g]):h.has(g)?j("unique field ids",void 0,n.options):h.add(g):y.index<32?((p&1<<y.index)!==0&&j("unique field ids",void 0,n.options),p|=1<<y.index):m===void 0?m=new Set([y.index]):(m.has(y.index)&&j("unique field ids",void 0,n.options),m.add(y.index))),f?.push(y);let E=i4(e,r,y,s,n);E>=0&&(E<32?i|=1<<E:(a??=new Set).add(E))}f!==void 0&&t.push(f)}return J4(o,i,a,n),s}function i4(e,t,r,n,o){let s=o.uvarint();if((s&1)===1){if(r==null)return-1;let u=t[r.index],f=(s-1)/2;(u===void 0||f>=u.length)&&j("a known back-reference",void 0,o.options);let p=u[f];return p===kr?-1:(B(n,r.name,p),r.index)}let i=o.enter(s/2);if(r===null)return Z4(e.struct,o,n),o.exit(i),-1;if(r===void 0)return o.exit(i),-1;let a=e.intern[r.index];(a===I4||a===T4)&&(o.intern=t[r.index]??=[]),Ze[Q++]=r.name;let c=un(r.layout,o);return Q--,o.intern=void 0,o.exit(i),a===ZR&&(t[r.index]??=[]).push(c),c===kr?-1:(B(n,r.name,c),r.index)}function Oce(e,t){let r=e.elements.length,n=e.hasCount?t.uvarint():r;if(e.rest.length===0&&n>r)throw Ze[Q++]=r,dr(new Nu(e.ast,void 0,t.options));if(n<e.minCount)throw Ze[Q++]=n,dr(new Yt(void 0));if(e.hasCount){let i=e.rest.length>0&&v4(e.rest[0])?Tae:t.remaining+Iae;n>i&&j("array count within allocation limit",n,t.options)}if(n>0){let i=M4(e);if(i!==null)return Ace(i,n,t)}let o=new Array(n),s=e.uniform;if(s!==void 0){if(e.uniformNumbers)return _ce(o,n,t);let i=t.intern;if(t.intern=void 0,i!==void 0){for(let u=0;u<n;u++){Ze[Q++]=u;let f=Cce(i,s,t);if(f===kr)throw dr(new Yt(void 0));Q--,o[u]=f}return o}if(OE(s)){for(let u=0;u<n;u++)Ze[Q++]=u,o[u]=Kh(s,t),Q--;return o}if(s._==="string"){for(let u=0;u<n;u++)Ze[Q++]=u,o[u]=t.dict===void 0?t.readUtf8(t.uvarint()):q4(s,t),Q--;return o}let a=e.uniformPacked,c=e.uniformInline;for(let u=0;u<n;u++){Ze[Q++]=u;let f=t.enter(c?a??0:t.uvarint()),p=un(s,t);if(t.exit(f),p===kr)throw dr(new Yt(void 0));Q--,o[u]=p}return o}for(let i=0;i<n;i++){let a=$4(e,i,n),c=i<r&&e.elements[i].optional;if(!e.hasCount&&t.remaining===0&&!c&&a._!=="null"&&a._!=="undefined")throw Ze[Q++]=i,dr(new Yt(void 0));Ze[Q++]=i;let u=z4(a,t);if(u===kr)throw c&&j("known union member",void 0,t.options),dr(new Yt(void 0));Q--,o[i]=u}if(!e.hasCount&&t.pos<t.end)throw Ze[Q++]=r,dr(new Nu(e.ast,void 0,t.options));return o}function _ce(e,t,r){let n=r.byte();if(n===h4){r.remaining!==t*8&&j("f64",void 0,r.options);for(let o=0;o<t;o++)e[o]=r.f64();return e}if(n===g4){for(let o=0;o<t;o++){Ze[Q++]=o;let s=r.uvarint(),i=s%16;i>kE&&j("decimal",void 0,r.options);let a=y4((s-i)/16);e[o]=i===0?a:a/_c[i],Q--}return e}n!==x4&&j("f64",void 0,r.options);for(let o=0;o<t;o++)Ze[Q++]=o,e[o]=r.numberVarint(),Q--;return e}function Pce(e,t){let r=t.byte();if(r===dt.variant){let o=t.u32le(),s=e.byTag.get(o);if(s===void 0)return t.take(t.remaining),kr;let i=un(s.payload,t);if(i===kr)return kr;if(!s.tuple)for(let a of s.sentinels)B(i,a.key,a.literal);return i}let n=e.byKind.get(r);return n===void 0?(t.take(t.remaining),kr):un(n,t)}function Mce(e,t){let r=e.byPos[t.uvarint()];r===void 0&&j("known union member",void 0,t.options);let n=un(r.layout,t),o=r.variant;if(o!==void 0&&!o.tuple&&n!==kr)for(let s of o.sentinels)B(n,s.key,s.literal);return n}function a4(e,t){switch(t.byte()){case 0:return Cp(_d(un(e.error,t)));case 1:return Ap(_d(un(e.defect,t)));case 2:return t.remaining!==0&&j("empty",void 0,t.options),kp();case 3:return t.remaining!==8&&j("f64",void 0,t.options),kp(t.f64());default:return t.take(t.remaining),kr}}function _d(e){if(e===kr)throw dr(new Yt(void 0));return e}function Kh(e,t){t.nesting>=KW&&j(`nesting depth at most ${KW}`,t.nesting+1,t.options),t.nesting++;try{return Fce(e,t)}finally{t.nesting--}}function Fce(e,t){switch(e._){case"literal":{let r=Kh(e.leaf,t);return Qh(e,r)||j(RE(e),r,t.options),r}case"bool":{t.remaining!==1&&j("bool",void 0,t.options);let r=t.byte();return r>1&&j("bool",void 0,t.options),r===1}case"null":return t.remaining!==0&&j("empty",void 0,t.options),null;case"undefined":t.remaining!==0&&j("empty",void 0,t.options);return;case"number":{let r=t.remaining;if(r===8)return t.f64();(r===0||r>m4)&&j("f64",void 0,t.options);let n=t.numberVarint();if(t.remaining===0)return n;let o=t.byte();return(t.remaining!==0||o===0||o>kE)&&j("decimal",void 0,t.options),n/_c[o]}case"int":return t.numberVarint();case"string":{let r=t.dict;return r===void 0?t.readUtf8(t.end-t.pos):dce(r,e,t)}case"symbol":return globalThis.Symbol.for(t.readUtf8(t.end-t.pos));case"bytes":return t.takeCopy(t.end-t.pos);case"bigint":return t.zigzag();case"int64":{t.remaining!==8&&j("int64",void 0,t.options);let r=Number(t.i64()),n=new Date(r);return Number.isNaN(n.getTime())&&j(e.flavor==="date"?"a valid Date":"a valid DateTime",r,t.options),e.flavor==="date"?n:by(r)}case"dateTimeZoned":{let r=Number(t.i64()),n=t.byte(),o;if(n===0)t.remaining!==4&&j("time zone",void 0,t.options),o=t.i32le();else if(n===1)o=t.readUtf8(t.end-t.pos);else return j("time zone",void 0,t.options);try{return Ey(r,{timeZone:o})}catch{return j("time zone",void 0,t.options)}}case"duration":switch(t.byte()){case 0:return $o(t.zigzag());case 1:return Ss;case 2:return Da;default:return j("duration",void 0,t.options)}case"bigDecimal":{let r=t.zigzag(),n=t.zigzag();return(n>UR||-n>UR)&&j("safe integer length",void 0,t.options),hy(r,Number(n))}case"json":{let r=t.readUtf8(t.end-t.pos);try{return JSON.parse(r)}catch{return j("json",void 0,t.options)}}case"option":{let r=t.byte();return r===0?(t.remaining!==0&&j("empty",void 0,t.options),_()):(r!==1&&j("bool",void 0,t.options),N(_d(un(e.value,t))))}case"result":{let r=t.byte();return r===0?X(_d(un(e.success,t))):(r!==1&&j("bool",void 0,t.options),re(_d(un(e.failure,t))))}case"exit":{let r=t.byte();if(r===0)return Mr(_d(un(e.value,t)));r!==1&&j("bool",void 0,t.options);let n=Kh(e.cause,t);return ir(n)}case"cause":{let r=t.uvarint(),n=[];for(let o=0;o<r;o++){Ze[Q++]=o;let s=t.enter(t.uvarint()),i=a4(e,t);t.exit(s),Q--,i!==kr&&n.push(i)}return t.pos!==t.end&&j("no leftover bytes",void 0,t.options),uu(n)}case"causeReason":return a4(e,t);case"struct":return t.positional?vce(e,t):wce(e,t);case"array":return Oce(e,t);case"union":return t.positional?Mce(e,t):Pce(e,t);case"never":throw dr(new at(e.ast,void 0,t.options))}}function Q4(e,t,r){let n=t.byte();if(n!==r.envelope&&j(r.expectedEnvelope,n,t.options),r.positional){t.remaining<8&&j("complete value",void 0,t.options);let s=t.buf,i=r.fingerprint,a=t.pos;for(let c=0;c<8;c++)s[a+c]!==i[c]&&j("matching layout fingerprint",void 0,t.options);t.pos=a+8}let o=un(e,t);if(o===kr)throw dr(new Yt(void 0));return o}var xE=new zh;function Nce(e,t,r,n){let o=xE??new zh,s=o===xE;s&&(xE=void 0),o.reset(t,0,t.length,r,void 0,n.positional,void 0);let i=Q;Q=0;try{let a=o.uvarint();a===0&&j("nonzero frame length",void 0,r);let c=o.enter(a),u=Q4(e,o,n);return o.exit(c),o.pos!==t.length&&j("no leftover bytes",void 0,r),u}finally{Q=i,o.release(),s&&(xE=o)}}function Uce(e,t,r,n=!1){return Xt({decode:(o,s)=>{try{let i=Nce(e,o,s,t);return r!==void 0&&$d(i)&&(!n||PE(i))&&(r.value=i),I(i)}catch(i){return i instanceof ji?D(i.issue):gn(i)}},encode:(o,s)=>{try{return I(AE(e,o,s,t))}catch(i){return i instanceof ji?D(i.issue):gn(i)}}})}var Dce=mo(Kae);function bf(e,t){return t===!0?Dce(e):Wae}var Lce=mo(e=>{let t=J(SE(e)),{exact:r,exitSuccess:n,layout:o,recursive:s}=jae(t.ast);return{target:s?qce(t):t,layout:o,exact:r,exitSuccess:n,recursive:s}});function Md(e){return Lce(e.ast)}function Y4(e,t){return e.value===void 0||t!==e.value?!1:(e.value=void 0,!0)}function X4(e,t,r){let n=J(Nt(e.ast)),o=ot(n),s=i=>()=>(a,c,u)=>i(a,u)?nt:o(a,u);return J(new uc([n.ast],s(t),{identifier:"binary value"},void 0,void 0,void 0,void 0,s(r)))}function KR(e,t){return t.onExcessProperty!=="error"}function Bce(e,t,r){return X4(e,n=>Y4(t,n),r?KR:$ce)}function $ce(){return!1}function jce(e,t){return Cr()([e],([r])=>{let n=ot(r);return(o,s,i)=>Y4(t,o)||PE(o)&&i.onExcessProperty!=="error"?I(o):n(o,i)},{identifier:"binary exit value"})}function Hce(e){return X4(e,KR,KR)}function qce(e){let t=J(Nt(e.ast)),r=new WeakSet,n=Cr()([t],([o])=>(s,i,a)=>$d(s)&&r.delete(s)?I(s):kn(s)?D(new at(i,s,a)):ot(o)(s,a),{identifier:"acyclic value"});return ee(n,Fe({decode:o=>($d(o)&&r.add(o),o),encode:o=>o}))(e)}var FE=rf,Wce,n6=e=>(Wce??=new TextDecoder).decode(e),fn=class extends Ue()("effect/rpc/RpcSerialization"){},ME=class extends sr("MaxBufferSizeExceeded"){get message(){return`RPC serialization buffer exceeded the maximum size of ${this.maxBufferSize}`}},Kce=16*1024*1024,e6=(e,t)=>t!=="unbounded"&&e>t,o6=fn.of({contentType:"application/json",includesFraming:!1,codecFor:FE,makeUnsafe:()=>({decode:e=>{let t=JSON.parse(typeof e=="string"?e:n6(e));return Array.isArray(t)?t:[t]},encode:e=>JSON.stringify(e)})}),NE=e=>{let t=e?.maxBufferSize??Kce;return fn.of({contentType:"application/ndjson",includesFraming:!0,codecFor:FE,makeUnsafe:()=>{let r,n="",o=s=>{throw n="",new ME({maxBufferSize:s})};return{decode:s=>{n+=typeof s=="string"?s:(r??=new TextDecoder).decode(s,{stream:!0});let i=0,a=n.indexOf(`
33
- `,i),c=[];for(;a!==-1;){e6(a-i,t)&&o(t);let u=n.slice(i,a);i=a+1;try{c.push(JSON.parse(u))}catch{}a=n.indexOf(`
34
- `,i)}return n=n.slice(i),e6(n.length,t)&&o(t),c},encode:s=>{if(Array.isArray(s)){if(s.length===0)return;let i="";for(let a=0;a<s.length;a++)i+=JSON.stringify(s[a])+`
32
+ `,h)));r=r+m.substring(h)}}return bt(u)?u:null}let i=L(()=>o._tag==="Some"?se(o.value):Dp(e,{onSuccess:a,onFailure:je,onDone:c=>{if(o=N(c),r.length>0){let u=r;return r="",n=!1,I([u])}return se(c)}}));function a(c){let u=s(c);return u!==null?I(u):i}return i}));var rk=d(2,(e,t)=>De((r,n)=>C(we(e)(r,n),o=>we(t)(o,n)))),nk=d(2,(e,t)=>De((r,n)=>C(we(e)(r,n),o=>{let s=rt(o,i=>wo(i)?je(i):gn(EN(i)));return K(we(t)(s,n),i=>W0(i,a=>Op(a)?je(a.value):gn(a)))}))),wc=e=>De((t,r)=>{let n;return I(L(()=>n||e.pipe(zo(r),C(o=>we(o)(t,r)),C(o=>n=o))))}),xq=e=>Vs((t,r,n)=>K(zo(we(e)(t,r),n),zo(n)));var gq=d(2,(e,t)=>De(me(function*(r,n){let o=yield*we(e)(r,n),s=yield*io({capacity:t.capacity==="unbounded"?void 0:t.capacity,strategy:t.capacity==="unbounded"?void 0:t.strategy});return yield*It(n,ss(s)),yield*o.pipe(C(i=>jn(s,i)),Mt({disableYield:!0}),to(i=>Ht(s,i)),gt(n)),Ws(s)}))),yq=d(2,(e,t)=>De(me(function*(r,n){let o=yield*we(e)(r,n),s=yield*io({capacity:t.capacity==="unbounded"?void 0:t.capacity,strategy:t.capacity==="unbounded"?void 0:t.strategy});return yield*It(n,ss(s)),yield*o.pipe(C(i=>wa(s,i)),Mt({disableYield:!0}),to(i=>Ht(s,i)),gt(n)),cf(s)}))),ok=d(2,(e,t)=>_b(e,qr(I(C(t,se))),{haltStrategy:"either"})),Sq=d(2,(e,t)=>Vs(me(function*(r,n,o){let s=yield*we(e)(r,n),i=yield*gt(t,o,{startImmediately:!0});return L(()=>{let a=i.pollUnsafe();return a===void 0?s:wN(a,{onFailure:je,onSuccess:se})})}))),bq=d(2,(e,t)=>mh(e,r=>vs(r)?t(r.cause):P)),mh=d(2,(e,t)=>Vs((r,n,o)=>Wo(o,t).pipe(Vt(we(e)(r,n))))),Eq=d(2,(e,t)=>wc(Pt(t,e))),sk=d(2,(e,t)=>is(e,r=>W(()=>{let n=!0,o=_t(r,s=>(n=!1,t(s)));return L(()=>n?o:r)}))),Iq=d(2,(e,t)=>is(e,r=>I(ht(r,n=>C(t,()=>se(n)))))),Tq=d(2,(e,t)=>mh(e,r=>t)),lf=(e,t,r)=>L(()=>{let n=Zn(),o=we(e)(se(),n);return ht(C(o,t),r||I).pipe(Xr(s=>Ve(n,s)))});var Pb=d(2,(e,t)=>De((r,n)=>K(Ur(we(e)(r,n),t),Ur(t)))),Mb=d(3,(e,t,r)=>De((n,o)=>K(Jo(we(e)(n,o),t,r),Jo(t,r)))),Fb=d(3,(e,t,r)=>De((n,o)=>C(r,s=>we(Mb(e,t,s))(n,o)))),wq=d(e=>on(e[0]),(e,t,r)=>ip(t)?Pb(e,t):De((n,o)=>C(r?.local?gi(t,xi(),o):_p(t,o),s=>K(Ur(we(e)(n,o),s),Ur(s))))),vq=d(2,(e,t)=>De((r,n)=>yn(o=>{let s=t(o);return we(Pb(e,s))(r,n)})));var ik=function(){let e=on(arguments[0]),t=e?arguments[1]:arguments[0],r=Ho(e?arguments[2]:arguments[1]);if(e){let n=arguments[0];return IH(n,t,r)}return n=>IH(n,t,r)},IH=(e,t,r)=>Bre(nw(t,r),n=>Mb(e,li,n),(n,o)=>ar(s=>{let i=s.getRef(Vn),a=s.getRef(jg);return Mg(n,o,i,a)}));var Aq=e=>lf(e,t=>Mt(t,{disableYield:!0})),df=d(2,(e,t)=>lf(e,r=>Mt(C(r,t),{disableYield:!0}))),Cq=d(2,(e,t)=>lf(e,r=>r.pipe(C(t),C(n=>n?P:se()),Mt({disableYield:!0})))),ak=e=>K(pf(e,()=>({bytes:0,arrays:[]}),(t,r)=>{for(let n=0;n<r.length;n++)t.bytes+=r[n].length,t.arrays.push(r[n]);return t}),({arrays:t,bytes:r})=>{let n=new Uint8Array(r),o=0;for(let s=0;s<t.length;s++){let i=t[s];n.set(i,o),o+=i.length}return n});var kq=e=>L(()=>{let t=_();return lf(e,r=>r.pipe(iy,C(n=>(t=n,se()))),()=>I(t))}),Rq=e=>L(()=>{let t=Symbol(),r=t;return lf(e,n=>Mt(C(n,o=>(r=o,P)),{disableYield:!0}),()=>r===t?ia:j0(r))}),pf=d(3,(e,t,r)=>L(()=>{let n=t();return lf(e,o=>xn({while:nr,body:()=>o,step:s=>{n=r(n,s)}}),()=>I(n))})),Oq=d(3,(e,t,r)=>L(()=>{let n=t();return lf(e,o=>xn({while:nr,body:qe(o.pipe(C(s=>r(n,s)),K(s=>{n=s}))),step:Rr}),()=>I(n))})),ck=me(function*(e){let t=ff(1),r=yield*Nr(),n=Re(r,it);return(yield*we(e)(se(),n)).pipe(Ur(r),t.withPermits(1))},rt(e=>I(je(e)))),as=(e,t)=>we(e)(se(),t);var uk=d(e=>on(e[0]),(e,t)=>en(r=>df(e,n=>wa(t,n)).pipe(r,eo,C(n=>(ft(n)?Eb(t):Ui(t,n.cause),P)))));var _q=d(e=>on(e[0]),me(function*(e,t){let r=yield*Ao,n=yield*io({capacity:typeof t.capacity=="number"?t.capacity:void 0,strategy:typeof t.capacity=="number"?t.strategy:void 0});return yield*It(r,ss(n)),yield*gt(uk(e,n),r),n}));var Pq=e=>Ti(e.capacity==="unbounded"?uh(e):e.strategy==="dropping"?lb(e):e.strategy==="sliding"?db(e):fb(e),fh),Mq=d(2,me(function*(e,t){let r=yield*Pq(t);return yield*Rs(fk(e,r,{shutdownOnEnd:t.shutdownOnEnd!==!1})),r})),fk=d(e=>on(e[0]),(e,t,r)=>df(e,n=>cH(t,n)).pipe(r?.shutdownOnEnd===!0?wi(fh(t)):F)),Fq=d(2,me(function*(e,t){let r=yield*Pq(t);return yield*df(e,n=>mb(r,n)).pipe(Xr(n=>pb(r,n)),Rs),r}));var Wre="~effect/Stream",Kre={_R:F,_E:F,_A:F},Nq=function(e){this.channel=e};Nq.prototype={[Wre]:Kre,pipe(){return V(this,arguments)}};var Uq=e=>new Nq(e);var Gre="~effect/Sink";var Jre={_A:F,_In:F,_L:F,_E:F,_R:F},Zre={[Gre]:Jre,pipe(){return V(this,arguments)}};var Qre=e=>{let t=Object.create(Zre);return t.transform=e,t},Dq=e=>De((t,r)=>I(C(e.transform(t,r),se)));var Lq=e=>{let t=Bt(e);return Qre(r=>{let n=[];if(t===0)return I([n]);let o;return r.pipe(C(s=>{if(n.length+s.length<=t)return n.push(...s),n.length===t?se():P;for(let i=0;i<s.length;i++)if(n.push(s[i]),n.length===t)return i+1<s.length&&(o=s.slice(i+1)),se();return P}),Mt({disableYield:!0}),ht(()=>I([n,o])))})};var sn={};ps(sn,{DefaultChunkSize:()=>Yq,Do:()=>Fse,TypeId:()=>Qq,accumulate:()=>bse,aggregate:()=>dse,aggregateWithin:()=>vk,as:()=>Rne,bind:()=>Use,bindEffect:()=>Dse,bindTo:()=>Lse,broadcast:()=>vz,broadcastN:()=>pse,buffer:()=>Soe,bufferArray:()=>boe,callback:()=>Db,catch:()=>bh,catchCause:()=>lz,catchCauseFilter:()=>Ooe,catchCauseIf:()=>Roe,catchDefect:()=>Eoe,catchFilter:()=>Tk,catchIf:()=>pz,catchReason:()=>Aoe,catchReasons:()=>Coe,catchTag:()=>woe,catchTags:()=>voe,changes:()=>Az,changesWith:()=>Cz,changesWithEffect:()=>Ese,chunks:()=>bz,collect:()=>Sse,combine:()=>Joe,combineArray:()=>Zoe,concat:()=>hf,cross:()=>Xne,crossWith:()=>uz,debounce:()=>rse,decodeText:()=>Ise,die:()=>pne,drain:()=>Lne,drainFork:()=>Bne,drop:()=>wk,dropRight:()=>Koe,dropUntil:()=>qoe,dropUntilEffect:()=>zoe,dropWhile:()=>yz,dropWhileEffect:()=>Sz,dropWhileFilter:()=>Woe,empty:()=>Js,encodeText:()=>Tse,ensuring:()=>Eh,fail:()=>vc,failCause:()=>tz,failCauseSync:()=>mne,failSync:()=>dne,filter:()=>bk,filterEffect:()=>poe,filterMap:()=>doe,filterMapEffect:()=>moe,flatMap:()=>Id,flatten:()=>iz,flattenArray:()=>Dne,flattenEffect:()=>_ne,flattenIterable:()=>Wne,flattenTake:()=>Kne,forever:()=>zne,fromArray:()=>yh,fromArrayEffect:()=>yne,fromArrays:()=>Sne,fromAsyncIterable:()=>bne,fromChannel:()=>U,fromEffect:()=>Ub,fromEffectDrain:()=>Xq,fromEffectRepeat:()=>ez,fromEffectSchedule:()=>cne,fromEventListener:()=>Tne,fromIterable:()=>xf,fromIterableEffect:()=>xne,fromIterableEffectRepeat:()=>gne,fromIteratorSucceed:()=>hne,fromPubSub:()=>hk,fromPubSubTake:()=>rz,fromPull:()=>Li,fromQueue:()=>Sh,fromReadableStream:()=>xk,fromSchedule:()=>Ene,fromSubscription:()=>Ine,groupAdjacentBy:()=>fse,groupBy:()=>cse,groupByKey:()=>use,grouped:()=>ise,groupedWithin:()=>ase,haltWhen:()=>kse,ignore:()=>Foe,ignoreCause:()=>Noe,interleave:()=>Ase,interleaveWith:()=>Rz,interruptWhen:()=>Cse,intersperse:()=>kz,intersperseAffixes:()=>vse,isStream:()=>Ce,iterate:()=>vne,let:()=>Nse,limitBytes:()=>Boe,make:()=>fne,map:()=>ao,mapAccum:()=>Qoe,mapAccumArray:()=>yf,mapAccumArrayEffect:()=>Xoe,mapAccumEffect:()=>Yoe,mapArray:()=>oz,mapArrayEffect:()=>Pne,mapBoth:()=>One,mapEffect:()=>gf,mapError:()=>mz,merge:()=>gk,mergeAll:()=>Yne,mergeEffect:()=>Lb,mergeLeft:()=>Zne,mergeResult:()=>Jne,mergeRight:()=>Qne,mkArrayBuffer:()=>Jse,mkString:()=>Gse,mkUint8Array:()=>Zse,never:()=>Cne,onEnd:()=>Ose,onError:()=>Rse,onExit:()=>Oz,onFirst:()=>Pz,onStart:()=>_z,orDie:()=>Moe,orElseIfEmpty:()=>_oe,orElseSucceed:()=>Poe,paginate:()=>wne,partition:()=>xoe,partitionEffect:()=>hoe,partitionQueue:()=>Ek,peel:()=>yoe,pipeThrough:()=>yse,pipeThroughChannel:()=>xse,pipeThroughChannelOrFail:()=>gse,prepend:()=>Gne,provide:()=>Mz,provideContext:()=>Ak,provideService:()=>_se,provideServiceEffect:()=>Ck,race:()=>loe,raceAll:()=>fz,range:()=>Ane,rechunk:()=>Ez,repeat:()=>$ne,repeatElements:()=>qne,result:()=>Mne,retry:()=>Uoe,run:()=>Bse,runCollect:()=>Nz,runCount:()=>$se,runDrain:()=>$b,runFold:()=>Hse,runFoldEffect:()=>qse,runForEach:()=>Kse,runForEachArray:()=>Td,runForEachWhile:()=>Vse,runHead:()=>zse,runIntoPubSub:()=>eie,runIntoQueue:()=>nie,runLast:()=>Wse,runSum:()=>jse,scan:()=>ese,scanEffect:()=>tse,schedule:()=>jne,scoped:()=>kne,service:()=>ine,serviceOption:()=>ane,share:()=>hse,sliding:()=>Voe,slidingSize:()=>Iz,split:()=>Goe,splitLines:()=>wse,succeed:()=>mf,suspend:()=>vn,switchMap:()=>Une,sync:()=>lne,take:()=>Loe,takeRight:()=>$oe,takeUntil:()=>hz,takeUntilEffect:()=>xz,takeWhile:()=>gz,takeWhileEffect:()=>Hoe,takeWhileFilter:()=>joe,tap:()=>sz,tapBoth:()=>Fne,tapCause:()=>dz,tapDefect:()=>Toe,tapError:()=>Ik,tapErrorTag:()=>Ioe,tapSink:()=>Nne,throttle:()=>sse,throttleEffect:()=>Tz,tick:()=>une,timeout:()=>Hne,timeoutOrElse:()=>az,toAsyncIterable:()=>Xse,toAsyncIterableEffect:()=>Yse,toAsyncIterableWith:()=>_k,toChannel:()=>cs,toPubSub:()=>tie,toPubSubTake:()=>Uz,toPull:()=>kk,toQueue:()=>rie,toReadableStream:()=>Qse,toReadableStreamEffect:()=>Ok,toReadableStreamWith:()=>Rk,transduce:()=>lse,transformPull:()=>br,transformPullBracket:()=>mk,unfold:()=>nz,unwrap:()=>An,unwrapReason:()=>koe,updateContext:()=>Fz,updateService:()=>Pse,when:()=>goe,withExecutionPlan:()=>Doe,withSpan:()=>Mse,zip:()=>toe,zipFlatten:()=>ooe,zipLatest:()=>uoe,zipLatestAll:()=>Sk,zipLatestWith:()=>foe,zipLeft:()=>roe,zipRight:()=>noe,zipWith:()=>yk,zipWithArray:()=>Bb,zipWithIndex:()=>soe,zipWithNext:()=>ioe,zipWithPrevious:()=>aoe,zipWithPreviousAndNext:()=>coe});var $q="~effect/RcMap",Yre=e=>({[$q]:$q,lookup:e.lookup,context:e.context,scope:e.scope,idleTimeToLive:e.idleTimeToLive,capacity:e.capacity,state:{_tag:"Open",map:Si()},pipe(){return V(this,arguments)}}),jq=e=>ar(t=>{let r=t.context,n=Re(r,it),o=Yre({lookup:e.lookup,context:r,scope:n,idleTimeToLive:typeof e.idleTimeToLive=="function"?jc(e.idleTimeToLive,$e):qe($e(e.idleTimeToLive??Ji)),capacity:Math.max(e.capacity??Number.POSITIVE_INFINITY,0)});return Pt(Wo(n,()=>{if(o.state._tag==="Closed")return P;let s=o.state.map;return o.state={_tag:"Closed"},Ko(s,([,i])=>eo(hh(i))).pipe(_t(()=>W(()=>{ny(s)})))}),o)}),lk=d(2,(e,t)=>en(r=>{if(e.state._tag==="Closed")return Dn;let n=e.state,o=os(),s=Qr(n.map,t),i;if(s._tag==="Some")i=s.value,i.refCount++;else{if(Number.isFinite(e.capacity)&&wU(e.state.map)>=e.capacity)return D(new IN(`RcMap attempted to exceed capacity of ${e.capacity}`));{i={deferred:du(),scope:Zn(),idleTimeToLive:e.idleTimeToLive(t),finalizer:void 0,fiber:void 0,expiresAt:0,refCount:1},i.finalizer=ene(e,t,i),bi(n.map,t,i);let c=new Map(e.context.mapUnsafe);o.context.mapUnsafe.forEach((f,p)=>{c.set(p,f)}),c.set(it.key,i.scope);let u=qn(c);L(()=>e.lookup(t)).pipe(Sr(u),Ni(i.scope)).addObserver(f=>{TN(f)&&Xre(e,t,i,u),hi(i.deferred,f)})}}let a=dn(o.context,it);return It(a,i.finalizer).pipe(Vt(r(Bg(i.deferred))))}));var Xre=(e,t,r,n)=>{if(e.state._tag==="Closed")return;let o=Qr(e.state.map,t);o._tag==="None"||o.value!==r||(Ei(e.state.map,t),!(r.refCount>0)&&hh(r).pipe(Sr(n),Ni(e.scope)))},hh=e=>e.fiber?Tn(e.fiber).pipe(Vt(Ve(e.scope,Kt))):Ve(e.scope,Kt),ene=(e,t,r)=>ar(n=>{if(r.refCount--,r.refCount>0)return P;if(e.state._tag==="Closed")return hh(r);let o=Qr(e.state.map,t);if(o._tag==="None"||o.value!==r)return hh(r);if(Hf(r.idleTimeToLive))return Ei(e.state.map,t),hh(r);if(!Wn(r.idleTimeToLive))return P;let s=n.getRef(Yn);return r.expiresAt=s.currentTimeMillisUnsafe()+Wt(r.idleTimeToLive),r.fiber?P:(r.fiber=en(function i(a){let c=s.currentTimeMillisUnsafe(),u=r.expiresAt-c;if(u<=0){if(e.state._tag==="Closed"||r.refCount>0)return P;let f=Qr(e.state.map,t);return f._tag==="None"||f.value!==r?P:(Ei(e.state.map,t),Ve(r.scope,Kt))}return C(a(s.sleep(Zi(u))),()=>i(a))}).pipe(wi(W(()=>{r.fiber=void 0})),Sr(n.context),Ni(e.scope)),P)});var dk=d(2,(e,t)=>Eu(r=>{if(e.state._tag==="Closed")return P;let n=Qr(e.state.map,t);if(n._tag==="None"||Hf(n.value.idleTimeToLive))return P;let o=n.value;return o.expiresAt=r.currentTimeMillisUnsafe()+Wt(o.idleTimeToLive),P}));var tne="~effect/RcRef",xh={_tag:"Empty"},rne={_tag:"Closed"},nne={_A:F,_E:F},pk=class{[tne]=nne;pipe(){return V(this,arguments)}state=xh;acquire;context;scope;idleTimeToLive;constructor(t,r,n,o){this.acquire=t,this.context=r,this.scope=n,this.idleTimeToLive=o}},zq=e=>ar(t=>{let r=t.context,n=Re(r,it),o=new pk(e.acquire,r,n,e.idleTimeToLive!==void 0?$e(e.idleTimeToLive):void 0);return Pt(Wo(n,()=>{let s=o.state;return o.state=rne,s._tag==="Acquired"?Ve(s.scope,Kt):s._tag==="Acquiring"?Tn(s.fiber):P}),o)}),one=(e,t)=>{switch(e.state._tag){case"Closed":return Dn;case"Acquired":{let r=e.state;return r.refCount++,r.fiber?Pt(Tn(r.fiber),r):I(r)}case"Acquiring":{let r=e.state;return r.awaiters++,qq(e,r,t)}case"Empty":{let r={_tag:"Acquiring",fiber:void 0,awaiters:1,acquired:void 0};e.state=r;let n=Zn(),o=Ur(e.acquire,We(e.context,it,n)).pipe(C(s=>{if(e.state!==r)return Dn;let i={_tag:"Acquired",value:s,scope:n,fiber:void 0,refCount:r.awaiters,invalidated:!1};return e.state=i,r.acquired=i,I(i)}),Xr(s=>ft(s)?P:(e.state===r&&(e.state=xh),Ve(n,s))));return r.fiber=Sr(os().context)(o),qq(e,r,t)}}},qq=(e,t,r)=>Xr(r(Ec(t.fiber)),n=>{let o=t.acquired;return o!==void 0?vs(n)?Kq(e,o):P:--t.awaiters>0||e.state!==t?P:(e.state=xh,Tn(t.fiber))}),Wq=e=>{let t=e;return en(r=>C(Ao,n=>C(one(t,r),o=>Pt(Wo(n,()=>Kq(t,o)),o.value))))},Kq=(e,t)=>{if(t.refCount--,t.refCount>0)return P;let r=e.idleTimeToLive;return r===void 0||t.invalidated?(e.state===t&&(e.state=xh),Ve(t.scope,Kt)):Wn(r)?(t.fiber=en(n=>C(n(ua(r)),()=>e.state===t&&t.refCount===0?(e.state=xh,Ve(t.scope,Kt)):P)).pipe(wi(W(()=>{t.fiber=void 0})),Sr(e.context),Ni(e.scope)),P):P};var Vq=zq,Gq=Wq;var Qq="~effect/Stream",Ce=e=>O(e,Qq),Yq=dh,U=Uq,Ub=e=>U(Ab(K(e,Me))),ine=e=>Ub(ew(e)),ane=e=>Ub(Su(e)),Xq=e=>Li(I(C(e,()=>se()))),ez=e=>Li(I(K(e,Me))),cne=(e,t)=>Li(xt(function*(){let r=yield*ks(t),n=yield*Jo(e,Fr,Fr.defaultValue()),o=!0,s=L(()=>r(n)).pipe(C(i=>Jo(e,Fr,i)),K(i=>(n=i,Me(i))));return L(()=>o?(o=!1,I(Me(n))):s)})),une=e=>Li(W(()=>{let t=!0,r=I(Me(void 0)),n=ca(r,e);return L(()=>t?(t=!1,r):n)})),Li=e=>U(qr(e)),br=(e,t)=>U(De((r,n)=>C(as(e.channel,n),o=>t(o,n)))),mk=(e,t)=>U(Vs((r,n,o)=>C(as(e.channel,n),s=>t(s,n,o)))),cs=e=>e.channel,Db=(e,t)=>U(wH(e,t)),Js=U(Sd),mf=e=>U(vb(Me(e))),fne=(...e)=>yh(e),lne=e=>U(CH(()=>Me(e()))),vn=e=>U(wb(()=>e().channel)),vc=e=>U(Di(e)),dne=e=>U(RH(e)),tz=e=>U(ph(e)),pne=e=>U(QC(e)),mne=e=>U(OH(e)),hne=(e,t)=>U(ZC(()=>e,t)),xf=(e,t)=>Array.isArray(e)&&t?.chunkSize===void 0?yh(e):U(AH(e,t?.chunkSize)),xne=e=>An(K(e,xf)),gne=e=>Id(ez(e),xf),yh=e=>bt(e)?U(vb(e)):Js,yne=e=>An(K(e,yh)),Sne=(...e)=>U(JC(Hx(e,bt))),Sh=e=>U(PH(e)),hk=e=>U(MH(e)),rz=e=>U(FH(e)),xk=e=>U(NH(e)),bne=(e,t)=>U(UH(e,t)),Ene=e=>Li(K(Lp(e),t=>ht(K(t(void 0),Me),()=>se()))),Ine=e=>U(XC(e)),Tne=(e,t,r)=>Db(n=>{let o=typeof r=="object"&&r.once;function s(i){Tc(n,i),o&&Eb(n)}return Ti(W(()=>e.addEventListener(t,s,r)),()=>W(()=>e.removeEventListener(t,s,r)))},{bufferSize:typeof r=="object"?r.bufferSize:void 0}),nz=(e,t)=>Li(W(()=>{let r=e;return C(L(()=>t(r)),n=>n===void 0?se():(r=n[1],I(Me(n[0]))))})),wne=(e,t)=>Li(W(()=>{let r=e,n=!1;return L(function o(){return n?se():C(t(r),([s,i])=>(fe(i)?n=!0:r=i.value,bt(s)?I(s):o()))})})),vne=(e,t)=>nz(e,r=>I([r,t(r)])),Ane=(e,t,r=dh)=>e>t?Js:Li(W(()=>{let n=Lo(r),o=e,s=!1;return L(()=>{if(s)return se();let i=t-o+1;if(i>n){let c=BI(o,o+n-1);return o+=n,I(c)}let a=BI(o,o+i-1);return s=!0,I(a)})})),Cne=U(kH),An=e=>U(wc(K(e,cs))),kne=e=>U(xq(e.channel)),ao=d(2,(e,t)=>vn(()=>{let r=0;return U(Gs(e.channel,Bo(n=>t(n,r++))))})),Rne=d(2,(e,t)=>ao(e,()=>t)),One=d(2,(e,t)=>e.pipe(ao(t.onElement),mz(t.onError))),oz=d(2,(e,t)=>U(Gs(e.channel,t))),gf=d(e=>Ce(e[0]),(e,t,r)=>e.channel.pipe(wn,Cb(t,r),Gs(Me),U)),_ne=d(e=>Ce(e[0]),(e,t)=>gf(e,F,t)),Pne=d(2,(e,t)=>U(Cb(e.channel,t))),Mne=e=>e.pipe(ao(X),bh(t=>mf(re(t)))),sz=d(e=>Ce(e[0]),(e,t,r)=>gf(e,n=>Pt(t(n),n),r)),Fne=d(2,(e,t)=>e.pipe(Ik(t.onError),sz(t.onElement,{concurrency:t.concurrency}))),Nne=d(2,(e,t)=>mk(e,me(function*(r,n,o){let s=jr(),i=jr(),a,c,u=!1,f=!1,p=s.whenOpen(L(()=>{if(a){let h=a;return a=void 0,f||s.closeUnsafe(),Pt(i.open,h)}return se()}));yield*L(()=>t.transform(p,o)).pipe(h=>Zp(h,x=>(u=!0,vs(x)&&(c=x.cause),i.open),!0),gt(o));let m=r.pipe(C(h=>c?je(c):u?I(h):(a=h,i.closeUnsafe(),s.openUnsafe(),Pt(i.await,h))),ht(()=>c?je(c):u?se():(f=!0,i.closeUnsafe(),s.openUnsafe(),C(i.await,()=>c?je(c):se()))));return L(()=>c?je(c):u?r:m)}))),Id=d(e=>Ce(e[0]),(e,t,r)=>e.channel.pipe(wn,ek(n=>t(n).channel,r),U)),Une=d(e=>Ce(e[0]),(e,t,r)=>e.channel.pipe(wn,pq(n=>t(n).channel,r),U)),iz=d(e=>Ce(e[0]),(e,t)=>Id(e,F,t)),Dne=e=>U(wn(e.channel)),Lne=e=>U(zH(e.channel)),Bne=d(2,(e,t)=>Lb(e,$b(t))),$ne=d(2,(e,t)=>U(WH(e.channel,t))),jne=d(2,(e,t)=>e.channel.pipe(wn,GH(t),Gs(Me),U)),Hne=d(2,(e,t)=>az(e,{duration:t,orElse:()=>Js})),az=d(2,(e,t)=>{let r=$e(t.duration);if(!Wn(r))return e;if(Hf(r))return vn(t.orElse);let n=Symbol();return lz(vn(()=>{let s=os().getRef(Yn),i=Wt(r),a,c=jr(!1);return gk(br(e,(u,f)=>L(()=>(a=s.currentTimeMillisUnsafe()+i,c.openUnsafe(),u)).pipe(K(p=>(c.closeUnsafe(),a=void 0,p)),I)),Xq(xt(function*(){for(;;)if(yield*c.await,!(a===void 0||(yield*ua(a-s.currentTimeMillisUnsafe()),a===void 0)||a-s.currentTimeMillisUnsafe()>0))return yield*gn(n)})),{haltStrategy:"left"})}),o=>o.reasons.find(i=>i._tag==="Die"&&i.defect===n)?t.orElse():tz(o))}),qne=d(2,(e,t)=>U(De((r,n)=>K(we(wn(e.channel))(r,n),o=>{let s,i=xt(function*(){let a=yield*o,c=Me(a);return s=(yield*Lp(t))(a).pipe(Pt(c),ht(f=>(s=void 0,i))),c});return L(()=>s??i)})))),zne=e=>U(VH(e.channel)),Wne=e=>Id(e,xf),Kne=e=>e.channel.pipe(wn,qH,U),hf=d(2,(e,t)=>{let r=U(HH(vH(()=>Vne(e,t))));return cz.set(r,[e,t]),r}),cz=new WeakMap;function*Vne(e,t){let r=[t,e];for(;r.length>0;){let n=r.pop(),o=cz.get(n);o===void 0?yield n.channel:r.push(o[1],o[0])}}var Gne=d(2,(e,t)=>hf(xf(t),e)),gk=d(e=>Ce(e[0])&&Ce(e[1]),(e,t,r)=>U(_b(cs(e),cs(t),r))),Lb=d(2,(e,t)=>e.channel.pipe(mq(t),U)),Jne=d(2,(e,t)=>gk(ao(e,X),ao(t,re))),Zne=d(2,(e,t)=>Lb(e,$b(t))),Qne=d(2,(e,t)=>Lb(t,$b(e))),Yne=d(2,(e,t)=>iz(xf(e),t)),Xne=d(2,(e,t)=>uz(e,t,(r,n)=>[r,n])),uz=d(3,(e,t,r)=>Id(e,n=>ao(t,o=>r(n,o)))),yk=d(3,(e,t,r)=>Bb(e,t,eoe(r))),eoe=e=>(t,r)=>{let n=Math.min(t.length,r.length),o=[];for(let s=0;s<n;s++)o.push(e(t[s],r[s]));return[o,t.slice(n),r.slice(n)]},Bb=d(3,(e,t,r)=>U(Vs(me(function*(n,o){let s=yield*as(e.channel,o),i=yield*as(t.channel,o),a=xt(function*(){let f=yield*gt(s,o),p=yield*gt(i,o);return yield*eb([f,p])}),c={_tag:"PullBoth"};return xt(function*(){let[f,p]=c._tag==="PullBoth"?yield*a:c._tag==="PullLeft"?[yield*s,c.rightArray]:[c.leftArray,yield*i],m=r(f,p);return bt(m[1])?c={_tag:"PullRight",leftArray:m[1]}:bt(m[2])?c={_tag:"PullLeft",rightArray:m[2]}:c={_tag:"PullBoth"},m[0]})})))),toe=d(2,(e,t)=>yk(e,t,(r,n)=>[r,n])),roe=d(2,(e,t)=>Bb(e,t,(r,n)=>{let o=Math.min(r.length,n.length),s=r.slice(0,o),i=r.slice(o),a=n.slice(o);return[s,i,a]})),noe=d(2,(e,t)=>Bb(e,t,(r,n)=>{let o=Math.min(r.length,n.length),s=n.slice(0,o),i=r.slice(o),a=n.slice(o);return[s,i,a]})),ooe=d(2,(e,t)=>yk(e,t,(r,n)=>[...r,n])),soe=e=>ao(e,(t,r)=>[t,r]),ioe=e=>yf(e,_,(t,r)=>{let n=0;t._tag==="None"&&(n=1,t=N(r[0]));let o=Qt();for(;n<r.length;n++){let s=t.value;t=N(r[n]),o.push([s,t])}return[t,o]},{onHalt(t){return t._tag==="Some"?[[t.value,_()]]:[]}}),aoe=e=>yf(e,_,(t,r)=>{let n=Qt();for(let o=0;o<r.length;o++){let s=r[o];n.push([t,s]),t=N(r[o])}return[t,n]}),coe=e=>yf(e,()=>({prev:_(),current:_()}),(t,r)=>{let n=0,o;t.current._tag==="None"?(n=1,o=r[0],t.current=N(o)):o=t.current.value;let s=Qt();for(;n<r.length;n++){let i=r[n];t.current=N(i),s.push([t.prev,o,t.current]),t.prev=N(o),o=i}return[t,s]},{onHalt(t){return t.current._tag==="Some"?[[t.prev,t.current.value,_()]]:[]}}),Sk=(...e)=>U(wb(()=>{let t=[],r=new Set,n=jr(),o=jr();return Ob(JC(e.map((s,i)=>s.channel.pipe(wn,Cb(a=>(t[i]=a,r.has(i)?I(Me(t.slice())):(r.add(i),r.size<e.length?n.await:Pt(n.open,Me(t.slice()))))),JH(ei),DH(()=>r.has(i)?P:o.open)))),{concurrency:"unbounded",bufferSize:0}).pipe(ok(o.await))})),uoe=d(2,(e,t)=>Sk(e,t)),foe=d(3,(e,t,r)=>ao(Sk(e,t),([n,o])=>r(n,o))),fz=(...e)=>U(De((t,r)=>W(()=>{let n,o=J0(e.map(s=>{let i=yr(r);return as(s.channel,i).pipe(C(a=>z0(I(a),a)),Xr(a=>a._tag==="Success"?n?Ve(i,a):(n=a.value[0],P):Ve(i,a)),K(([,a])=>a))}));return L(()=>n??o)}))),loe=d(2,(e,t)=>fz(e,t)),bk=d(2,(e,t)=>U(ZH(cs(e),t))),doe=d(2,(e,t)=>U(QH(cs(e),t))),poe=d(2,(e,t)=>U(YH(cs(e),t))),moe=d(2,(e,t)=>U(XH(cs(e),t))),Ek=d(e=>Ce(e[0]),me(function*(e,t,r){let n=yield*Ao,o=yield*as(e.channel,n),s=r?.capacity==="unbounded"?void 0:r?.capacity??Yq,i=yield*io({capacity:s}),a=yield*io({capacity:s});return yield*xt(function*(){for(;;){let c=yield*o,u=[],f=[];for(let m=0;m<c.length;m++){let h=t(c[m]);be(h)?u.push(h.failure):f.push(h.success)}let p;if(f.length>0){let m=bb(i,f);m.length>0&&(p=yield*El(wa(i,m)))}if(u.length>0){let m=bb(a,u);m.length>0&&(yield*wa(a,m))}p&&(yield*Ec(p))}}).pipe(to(c=>(Ui(i,c),Ui(a,c),P)),gt(n)),[i,a]})),gh=e=>U(De((t,r)=>Pt(It(r,ss(e)),cf(e)))),hoe=d(e=>Ce(e[0]),(e,t,r)=>K(Ek(gf(e,n=>t(n),r),n=>n,r),([n,o])=>[gh(n),gh(o)])),xoe=d(e=>Ce(e[0]),(e,t,r)=>K(Ek(e,t,{capacity:r?.capacity??16}),([n,o])=>[gh(n),gh(o)])),goe=d(2,(e,t)=>t.pipe(K(r=>r?e:Js),An)),yoe=d(2,me(function*(e,t){let r,n=yield*ck(e.channel),o=rt(n,c=>(r=c,je(c))),[s,i]=yield*Sl(c=>t.transform(o,c)),a=r?Js:Li(I(n));return i&&(a=hf(yh(i),a)),[s,a]})),Soe=d(2,(e,t)=>U(yq(e.channel,t))),boe=d(2,(e,t)=>U(gq(e.channel,t))),lz=d(2,(e,t)=>e.channel.pipe(Ed(r=>t(r).channel),U)),Eoe=d(2,(e,t)=>e.channel.pipe(tq(r=>t(r).channel),U)),dz=d(2,(e,t)=>e.channel.pipe(kb(t),U)),bh=d(2,(e,t)=>U(Ks(e.channel,r=>t(r).channel)));var Ik=d(2,(e,t)=>e.channel.pipe(nq(t),U)),Ioe=d(3,(e,t,r)=>{let n=Array.isArray(t)?o=>O(o,"_tag")&&t.includes(o._tag):Or(t);return Ik(e,o=>n(o)?r(o):P)}),Toe=d(2,(e,t)=>dz(e,r=>{let n=Rp(r);return tt(n)?t(n.success):P})),pz=d(e=>Ce(e[0]),(e,t,r,n)=>U(oq(cs(e),t,o=>r(o).channel,n&&(o=>n(o).channel)))),Tk=d(e=>Ce(e[0]),(e,t,r,n)=>U(sq(cs(e),t,o=>r(o).channel,n&&(o=>n(o).channel)))),woe=d(e=>Ce(e[0]),(e,t,r,n)=>{let o=Array.isArray(t)?s=>O(s,"_tag")&&t.includes(s._tag):Or(t);return pz(e,o,r,n)}),voe=d(e=>Ce(e[0]),(e,t,r)=>{let n;return Tk(e,o=>(n??=Object.keys(t),O(o,"_tag")&&Xg(o._tag)&&n.includes(o._tag)?X(o):re(o)),o=>t[o._tag](o),r)}),Aoe=d(e=>Ce(e[0]),(e,t,r,n,o)=>U(iq(cs(e),t,r,(s,i)=>n(s,i).channel,o&&((s,i)=>o(s,i).channel)))),Coe=d(e=>Ce(e[0]),(e,t,r,n)=>{let o=Object.create(null);for(let i of Object.keys(r)){let a=r[i];o[i]=(c,u)=>a(c,u).channel}let s=n&&((i,a)=>n(i,a).channel);return U(aq(e.channel,t,o,s))}),koe=d(2,(e,t)=>Tk(e,r=>Or(r,t)&&O(r,"reason")?X(r.reason):re(r),vc)),mz=d(2,(e,t)=>U(cq(e.channel,t))),Roe=d(3,(e,t,r)=>U(rq(e.channel,t,n=>r(n).channel))),Ooe=d(3,(e,t,r)=>U(Rb(e.channel,t,(n,o)=>r(n,o).channel))),_oe=d(2,(e,t)=>U(jH(e.channel,r=>cs(t())))),Poe=d(2,(e,t)=>bh(e,r=>mf(t(r)))),Moe=e=>U(uq(e.channel)),Foe=d(e=>Ce(e[0]),(e,t)=>U(fq(e.channel,t))),Noe=d(e=>Ce(e[0]),(e,t)=>U(lq(e.channel,t))),Uoe=d(2,(e,t)=>U(dq(e.channel,t))),Zq=(e,t)=>An(K(ks(t),r=>{let n=Fr.defaultValue(),o=()=>bh(Ck(e,Fr,W(()=>n)),s=>An(ht(K(r(s),i=>(n=i,An(Pt(Vp,o())))),()=>I(vc(s)))));return o()})),Doe=d(e=>Ce(e[0]),(e,t,r)=>vn(()=>{let n=r?.preventFallbackOnPartialStream??!1,o=0,s={attempt:0,stepIndex:0},i=Ck(ty,W(()=>(s={attempt:s.attempt+1,stepIndex:o},s))),a=r?.onEvent===void 0?void 0:U0(r.onEvent,()=>s),c,u=a===void 0?F:m=>Oz(_z(m,K(a.begin,h=>{c=h})),h=>L(()=>{if(c===void 0)return P;let x=c;return c=void 0,a.end(x,h)})),f=_(),p=vn(()=>{let m=t.steps[o];if(!m)return vc(OI(f));let h=i(u(Mz(e,m.provide))),x=!1;if(de(f)){let g=f.value,y=!1,E=h;h=vn(()=>y?E:(y=!0,vc(g))),h=Zq(h,qp(m,!1))}else{let g=qp(m,!0);h=g?Zq(h,g):h}return bh(n?Pz(h,g=>(x=!0,P)):h,g=>(o++,n&&x?vc(g):(f=N(g),p)))});return p})),Loe=d(2,(e,t)=>{let r=Bt(t);return r===0?Js:hz(e,(n,o)=>o===r-1)}),Boe=d(3,(e,t,r)=>vn(()=>{let n=xy(t),o=BigInt(0),s=!1;return hf(gz(e,i=>{let a=o+BigInt(i.length);return a>n?(s=!0,!1):(o=a,!0)}),vn(()=>s?r():Js))})),$oe=d(2,(e,t)=>{let r=Bt(t);return r===0?Js:yf(e,Ta,(n,o)=>(rb(n,o),n.length>r&&ob(n,n.length-r),[n,va]),{onHalt(n){return Ic(n)}})}),hz=d(e=>Ce(e[0]),(e,t,r)=>br(e,(n,o)=>W(()=>{let s=0,i=!1;return C(L(()=>i?se():n),c=>{let u=c.findIndex(f=>t(f,s++));if(u>=0){i=!0;let f=c.slice(0,r?.excludeLast?u:u+1);return bt(f)?I(f):se()}return I(c)})}))),xz=d(e=>Ce(e[0]),(e,t,r)=>br(e,(n,o)=>W(()=>{let s=0,i=!1;return xt(function*(){if(i)return yield*se();let a=yield*n;for(let c=0;c<a.length;c++)if(yield*t(a[c],s++)){i=!0;let u=a.slice(0,r?.excludeLast?c:c+1);return bt(u)?u:yield*se()}return a})}))),gz=d(2,(e,t)=>br(e,(r,n)=>W(()=>{let o=0,s=!1,i=C(L(()=>s?se():r),a=>{let c=[];for(let u=0;u<a.length;u++){if(!t(a[u],o++)){s=!0;break}c.push(a[u])}return bt(c)?I(c):s?se():i});return i}))),joe=d(2,(e,t)=>br(e,(r,n)=>W(()=>{let o=!1,s=C(L(()=>o?se():r),i=>{let a=[];for(let c=0;c<i.length;c++){let u=t(i[c]);if(be(u)){o=!0;break}a.push(u.success)}return bt(a)?I(a):o?se():s});return s}))),Hoe=d(2,(e,t)=>xz(e,(r,n)=>K(t(r,n),o=>!o),{excludeLast:!0})),wk=d(2,(e,t)=>{let r=Bt(t);return r===0?e:br(e,(n,o)=>W(()=>{let s=0,i=n.pipe(C(a=>s>=r?I(a):(s+=a.length,s<=r?i:I(a.slice(r-s)))));return i}))}),qoe=d(2,(e,t)=>wk(yz(e,(r,n)=>!t(r,n)),1)),zoe=d(2,(e,t)=>wk(Sz(e,(r,n)=>K(t(r,n),o=>!o)),1)),yz=d(2,(e,t)=>br(e,(r,n)=>W(()=>{let o=!0,s=0,i=C(r,a=>{let c=a.findIndex(u=>!t(u,s++));return c===-1?i:(o=!1,I(a.slice(c)))});return L(()=>o?i:r)}))),Woe=d(2,(e,t)=>br(e,(r,n)=>W(()=>{let o=!0,s=C(r,i=>{let a=i.findIndex(c=>be(t(c)));return a===-1?s:(o=!1,I(i.slice(a)))});return L(()=>o?s:r)}))),Sz=d(2,(e,t)=>br(e,(r,n)=>W(()=>{let o=!0,s=0,i=xt(function*(){for(;;){let a=yield*r;for(let c=0;c<a.length;c++)if(!(yield*t(a[c],s++)))return o=!1,a.slice(c)}});return L(()=>o?i:r)}))),Koe=d(2,(e,t)=>{let r=Bt(t);return r===0?e:br(e,(n,o)=>W(()=>{let s=Ta(),i=C(n,a=>{nb(s,a);let c=s.length-r,u=of(s,c);return Gr(u)?I(u):i});return i}))}),bz=e=>e.channel.pipe(Gs(Me),U),Ez=d(2,(e,t)=>(t=Lo(t),br(e,(r,n)=>W(()=>{let o=Qt(),s=0,i,a=!1;return L(function c(){if(a)return se();if(i===void 0)return C(r,u=>{if(o.length===0&&u.length===t)return I(u);if(o.length+u.length<t){for(let f=0;f<u.length;f++)o.push(u[f]);return c()}return i=u,c()});for(;s<i.length;)if(o.push(i[s++]),o.length===t){let u=o;return o=[],I(u)}return s=0,i=void 0,c()}).pipe(ht(()=>{if(o.length===0)return se();let c=o;return a=!0,o=[],I(c)}))})))),Voe=d(2,(e,t)=>Iz(e,t,1)),Iz=d(3,(e,t,r)=>{let n=Lo(t),o=Lo(r);return br(e,(s,i)=>W(()=>{let a=null,c=Ta(),u=!1,f=0,p=Un(s,{onSuccess(m){if(nb(c,m),f>0){let x=c.length;ob(c,f),f=Math.max(0,f-x)}if(c.length<n)return p;u=!0;let h=[];for(;c.length>=n;)if(n===o)h.push(of(c,n));else{h.push(oH(c,n));let x=c.length;ob(c,o),f=Math.max(0,o-x)}return I(h)},onFailure(m){return c.length===0||u&&c.length<=n-o?je(m):(a=m,I(Me(Ic(c))))}});return L(()=>a?je(a):p)}))}),Goe=d(2,(e,t)=>yf(e,Qt,(r,n)=>{let o=Qt();for(let s=0;s<n.length;s++)t(n[s])?Gr(r)&&(o.push(r),r=[]):r.push(n[s]);return[r,o]},{onHalt(r){return Gr(r)?Me(r):va}})),Joe=d(4,(e,t,r,n)=>tk(wn(e.channel),wn(t.channel),r,n).pipe(Gs(Me),U)),Zoe=d(4,(e,t,r,n)=>U(tk(e.channel,t.channel,r,n))),Qoe=d(e=>Ce(e[0]),(e,t,r,n)=>U(bd(e.channel,t,(o,s)=>{let i=Qt();for(let a=0;a<s.length;a++){let[c,u]=r(o,s[a]);o=c,i.push(...u)}return[o,Gr(i)?Me(i):va]},n?.onHalt?{onHalt(o){let s=n.onHalt(o);return bt(s)?Me(s):va}}:void 0))),yf=d(e=>Ce(e[0]),(e,t,r,n)=>U(bd(e.channel,t,(o,s)=>{let[i,a]=r(o,s);return o=i,[o,bt(a)?Me(a):va]},n?.onHalt?{onHalt(o){let s=n.onHalt(o);return bt(s)?Me(s):va}}:void 0))),va=Qt(),Yoe=d(e=>Ce(e[0]),(e,t,r,n)=>e.channel.pipe(wn,bd(t,(o,s)=>K(r(o,s),([i,a])=>[i,bt(a)?Me(a):Qt()]),n?.onHalt?{onHalt(o){let s=n.onHalt(o);return bt(s)?Me(s):va}}:void 0),U)),Xoe=d(e=>Ce(e[0]),(e,t,r,n)=>e.channel.pipe(bd(t,(o,s)=>K(r(o,s),([i,a])=>[i,bt(a)?Me(a):va]),n?.onHalt?{onHalt(o){let s=n.onHalt(o);return bt(s)?Me(s):va}}:void 0),U)),ese=d(3,(e,t,r)=>vn(()=>{let n=t();return hf(mf(n),U(bd(e.channel,()=>n,(o,s)=>{let i=Qt();for(let a=0;a<s.length;a++)o=r(o,s[a]),i.push(o);return[o,Me(i)]})))})),tse=d(3,(e,t,r)=>vn(()=>e.channel.pipe(wn,eq(t(),r),Gs(Me),U))),rse=d(2,(e,t)=>br(e,me(function*(r,n){let o=yield*Yn,s=Wt($e(t)),i,a,c=1/0,u=jr(),f=jr(),p=jr();yield*r.pipe(u.whenOpen,C(h=>(f.openUnsafe(),i=h,c=o.currentTimeMillisUnsafe()+s,P)),Mt({disableYield:!0}),to(h=>(a=h,c=o.currentTimeMillisUnsafe(),f.openUnsafe(),p.openUnsafe(),P)),gt(n));let m=L(function h(){let x=o.currentTimeMillisUnsafe(),g=c<x?s:Math.min(s,c-x);return C(Xa(ua(g),p.await),()=>{if(o.currentTimeMillisUnsafe()<c)return h();if(i){f.closeUnsafe(),u.closeUnsafe();let E=I(Me(jf(i)));return i=void 0,E}else if(a)return je(a);return h()})});return L(()=>{if(a){if(i){let h=I(Me(jf(i)));return i=void 0,h}return je(a)}return u.openUnsafe(),f.whenOpen(m)})}))),Tz=d(2,(e,t)=>{let r=t.burst??0;return t.strategy==="enforce"?nse(e,t.cost,t.units,t.duration,r):ose(e,t.cost,t.units,t.duration,r)}),nse=(e,t,r,n,o)=>br(e,s=>Eu(i=>{let a=Wt($e(n)),c=r+o<0?Number.POSITIVE_INFINITY:r+o,u=r,f=i.currentTimeMillisUnsafe();return I(C(s,function p(m){return C(t(m),h=>{let x=i.currentTimeMillisUnsafe(),y=(x-f)/a,E=u+y*r,b=E<0?c:Math.min(E,c);return h<=b?(u=b-h,f=x,I(m)):C(s,p)})}))})),ose=(e,t,r,n,o)=>br(e,s=>Eu(i=>{let a=Wt($e(n)),c=r+o<0?Number.POSITIVE_INFINITY:r+o,u=r,f=i.monotonicTimeNanosUnsafe();return I(C(s,p=>C(t(p),m=>{let h=i.monotonicTimeNanosUnsafe(),g=Number(h-f)/1e6/a,y=u+g*r,b=Math.min(y,c)-m;if(b>=0)return u=b,f=h,I(p);let v=-b/r,T=Math.max(0,v*a);return T>0?C(ua(T),()=>(u=b,f=h,I(p))):(u=b,f=h,I(p))})))})),sse=d(2,(e,t)=>Tz(e,{...t,cost:r=>I(t.cost(r))})),ise=d(2,(e,t)=>bz(Ez(e,t))),ase=d(3,(e,t,r)=>vk(e,Lq(Lo(t)),hl(r))),cse=d(e=>Ce(e[0]),(e,t,r)=>wz(e,me(function*(n,o,s){for(let i=0;i<n.length;i++){let[a,c]=yield*t(n[i]),u=Qr(s,a),f=de(u)?u.value:yield*tc(lk(o,a));yield*dk(o,a),yield*jn(f,c)}}),r)),use=d(e=>Ce(e[0]),(e,t,r)=>vn(()=>{let n=Si();return wz(e,me(function*(o,s,i){for(let a=0;a<o.length;a++){let c=t(o[a]),u=Qr(n,c);fe(u)?bi(n,c,[o[a]]):u.value.push(o[a])}for(let[a,c]of n){let u=Qr(i,a),f=de(u)?u.value:yield*tc(lk(s,a));yield*dk(s,a),yield*wa(f,c)}ny(n)}),r)})),wz=(e,t,r)=>mk(e,me(function*(n,o,s){let i=yield*Sb();yield*It(o,ss(i));let a=Si(),c=yield*jq({lookup:u=>Ti(io({capacity:r?.bufferSize??4096}).pipe(_t(f=>(bi(a,u,f),jn(i,[u,gh(f)])))),f=>(Ei(a,u),yd(f))),idleTimeToLive:r?.idleTimeToLive??Ss}).pipe(zo(s));return yield*xn({while:nr,body:qe(C(n,u=>t(u,c,a))),step:Rr}).pipe(rt(u=>Ht(i,u)),gt(o)),cf(i)})),fse=d(2,(e,t)=>br(e,(r,n)=>W(()=>{let o,s,i=Qt(),a=r.pipe(C(u=>{for(let f=0;f<u.length;f++){let p=u[f],m=t(p);if(s===void 0){o=m,s=[p];continue}else if(Z(m,o)){s.push(p);continue}i.push([o,s]),o=m,s=[p]}if(Gr(i)){let f=i;return i=[],I(f)}return a})),c=!1;return ht(L(()=>c?se():a),()=>{c=!0;let u=s;return s=void 0,u&&Gr(u)?I(Me([o,u])):se()})}))),lse=d(2,(e,t)=>br(e,(r,n)=>W(()=>{let o,s,i=L(()=>{if(s!==void 0){let c=s;return s=void 0,I(c)}return r}).pipe(yu(c=>(o=Jn(c),se()))),a=K(L(()=>t.transform(i,n)),([c,u])=>(s=u,Me(c)));return L(()=>o||a)}))),dse=d(2,(e,t)=>vk(e,t,$p)),vk=d(3,(e,t,r)=>U(Vs(me(function*(n,o,s){let i=yield*as(e.channel,o),a=jr(!1),c=Symbol(),u=yield*io({capacity:0});yield*i.pipe(a.whenOpen,C(S=>(a.closeUnsafe(),jn(u,S))),Mt,rt(S=>Ht(u,S)),gt(s));let f=yield*Yn,p=yield*Ya(r),m=jr(!1),h=f.currentTimeMillisUnsafe(),x=0,g=_(),y,E=S=>(m.openUnsafe()&&(x=f.currentTimeMillisUnsafe()),I(S)),b=m.await.pipe(C(()=>p(h,g)),C(([,S])=>ua(S)),C(()=>jn(u,c)),ht(()=>yd(u)),C(()=>Xn)),v=L(()=>{if(y!==void 0){let S=y;return y=void 0,E(S)}return u.state._tag==="Open"&&a.openUnsafe(),C(Ws(u),S=>S===c?se():E(S))}),T=C(([S,w])=>{if(m.isOpen())h+=f.currentTimeMillisUnsafe()-x;else if(u.state._tag==="Done")return se();return g=N(S),y=w,I(Me(S))});return L(()=>{if(u.state._tag==="Done"&&y===void 0)return u.state.exit;m.closeUnsafe();let S=T(L(()=>t.transform(v,s)));return u.state._tag==="Open"?Xa(S,b):S})})))),pse=d(2,me(function*(e,t){let r=Bt(t.n),n=yield*mse(t),o=new Array(r),s=yield*it;for(let i=0;i<r;i++){let a=yr(s),c=yield*lh(n).pipe(Jo(it,a));o[i]=YC(hb(c)).pipe(mh(u=>Ve(a,u)),U)}return yield*df(e.channel,i=>mb(n,i)).pipe(Xr(i=>pb(n,i)),Rs),o})),mse=e=>Ti(e.capacity==="unbounded"?uh(e):e.strategy==="dropping"?lb(e):e.strategy==="sliding"?db(e):fb(e),fh),vz=d(2,(e,t)=>K(Uz(e,t),rz)),hse=d(2,(e,t)=>K(Vq({acquire:vz(e,t),idleTimeToLive:t.idleTimeToLive}),r=>An(Gq(r)))),xse=d(2,(e,t)=>U(rk(e.channel,t))),gse=d(2,(e,t)=>U(nk(e.channel,t))),yse=d(2,(e,t)=>e.channel.pipe(nk(Dq(t)),$H(([r,n])=>n?vb(n):Sd),U)),Sse=e=>Ub(Nz(e)),bse=e=>yf(e,Qt,(t,r)=>{let n=up(t,r);return[n,[n]]}),Az=e=>Cz(e,Z),Cz=d(2,(e,t)=>br(e,(r,n)=>W(()=>{let o=!0,s;return C(r,function i(a){let c=[],u=0;for(o&&(o=!1,s=a[0],u=1,c.push(s));u<a.length;u++){let f=a[u];t(f,s)||(s=f,c.push(f))}return Gr(c)?I(c):C(r,i)})}))),Ese=d(2,(e,t)=>br(e,(r,n)=>W(()=>{let o=!0,s;return C(r,me(function*i(a){let c=[],u=0;for(o&&(o=!1,s=a[0],u=1,c.push(s));u<a.length;u++){let f=a[u];(yield*t(f,s))||(s=f,c.push(f))}return Gr(c)?c:yield*C(r,me(i))}))}))),Ise=d(e=>Ce(e[0]),(e,t)=>vn(()=>{let r=new TextDecoder(t?.encoding);return ao(e,n=>r.decode(n,{stream:!0}))})),Tse=e=>vn(()=>{let t=new TextEncoder;return ao(e,r=>t.encode(r))}),wse=e=>e.channel.pipe(rk(hq()),U),kz=d(2,(e,t)=>oz(e,(r,n)=>{let o=n===0?[]:[t],s=r.length-1;for(let i=0;i<r.length;i++)i===s?o.push(r[i]):o.push(r[i],t);return o})),vse=d(2,(e,t)=>mf(t.start).pipe(hf(kz(e,t.middle)),hf(mf(t.end)))),Ase=d(2,(e,t)=>Rz(e,t,xf(K_([!0,!1])))),Rz=d(3,(e,t,r)=>U(De(me(function*(n,o){let s=yield*we(wn(r.channel))(n,o),i=Symbol(),a=!1,c=!1,u=(yield*we(wn(e.channel))(n,o)).pipe(ht(()=>(a=!0,I(i)))),f=(yield*we(wn(t.channel))(n,o)).pipe(ht(()=>(c=!0,I(i))));return xt(function*(){for(;;){if(a&&c)return yield*se();let p=yield*s;if(p&&a||!p&&c)continue;let m=yield*p?u:f;if(m!==i)return Me(m)}})})))),Cse=d(2,(e,t)=>U(ok(e.channel,t))),kse=d(2,(e,t)=>U(Sq(e.channel,t))),Oz=d(2,(e,t)=>U(mh(e.channel,t))),Rse=d(2,(e,t)=>U(bq(e.channel,t))),_z=d(2,(e,t)=>U(Eq(e.channel,t))),Pz=d(2,(e,t)=>U(sk(e.channel,r=>t(r[0])))),Ose=d(2,(e,t)=>U(Iq(e.channel,t))),Eh=d(2,(e,t)=>U(Tq(e.channel,t))),Mz=d(e=>Ce(e[0]),(e,t,r)=>U(wq(e.channel,t,r))),Ak=d(2,(e,t)=>U(Pb(e.channel,t))),_se=d(3,(e,t,r)=>U(Mb(e.channel,t,r))),Ck=d(3,(e,t,r)=>U(Fb(e.channel,t,r))),Fz=d(2,(e,t)=>U(vq(e.channel,t))),Pse=d(3,(e,t,r)=>Fz(e,n=>We(n,t,r(Re(n,t))))),Mse=function(){let e=Ce(arguments[0]),t=e?arguments[1]:arguments[0],r=Ho(e?arguments[2]:arguments[1]);if(e){let n=arguments[0];return U(ik(n.channel,t,r))}return n=>U(ik(n.channel,t,r))},Fse=mf({}),Nse=d(3,(e,t,r)=>ao(e,n=>({...n,[t]:r(n)})));var Use=d(e=>Ce(e[0]),(e,t,r,n)=>Id(e,o=>ao(r(o),s=>({...o,[t]:s})),n)),Dse=d(e=>Ce(e[0]),(e,t,r,n)=>gf(e,o=>K(r(o),s=>({...o,[t]:s})),n)),Lse=d(2,(e,t)=>ao(e,r=>({[t]:r}))),Bse=d(2,(e,t)=>Sl(r=>as(e.channel,r).pipe(C(n=>t.transform(n,r)),K(([n])=>n)))),Nz=e=>pf(e.channel,()=>[],(t,r)=>{for(let n=0;n<r.length;n++)t.push(r[n]);return t}),$se=e=>pf(e.channel,()=>0,(t,r)=>t+r.length),jse=e=>pf(e.channel,()=>0,(t,r)=>{for(let n=0;n<r.length;n++)t+=r[n];return t}),Hse=d(3,(e,t,r)=>pf(e.channel,t,(n,o)=>{for(let s=0;s<o.length;s++)n=r(n,o[s]);return n})),qse=d(3,(e,t,r)=>Oq(e.channel,t,(n,o)=>{let s=0,i=n;return K(xn({while:()=>s<o.length,body:()=>r(i,o[s]),step(a){i=a,s++}}),()=>i)})),zse=e=>K(kq(e.channel),Lt(eP(0))),Wse=e=>K(Rq(e.channel),Lt(jf)),Kse=d(2,(e,t)=>df(e.channel,r=>{let n=0;return xn({while:()=>n<r.length,body:()=>t(r[n++]),step:Rr})})),Vse=d(2,(e,t)=>Cq(e.channel,r=>{let n=!1,o=0;return K(xn({while:()=>!n&&o<r.length,body:()=>t(r[o]),step(s){o++,s||(n=!0)}}),()=>!n)})),Td=d(2,(e,t)=>df(e.channel,t)),$b=e=>Aq(e.channel),kk=e=>ck(e.channel),Gse=e=>pf(e.channel,()=>"",(t,r)=>t+r.join("")),Jse=e=>K(ak(e.channel),t=>t.buffer),Zse=e=>ak(e.channel),Rk=d(e=>Ce(e[0]),(e,t,r)=>{let n,o,s=!1,i=jr(!1),a=r?.signal,c=()=>o.interruptUnsafe();return new ReadableStream({start(u){o=Yp(Ur(Td(e,f=>i.whenOpen(W(()=>{i.closeUnsafe();for(let p=0;p<f.length;p++)u.enqueue(f[p]);n(),n=void 0}))),t)),o.addObserver(f=>{a?.removeEventListener("abort",c),!s&&(f._tag==="Failure"&&a?.aborted!==!0?u.error(lu(f.cause)):u.close())}),a!==void 0&&o.pollUnsafe()===void 0&&(a.aborted?c():a.addEventListener("abort",c,{once:!0}))},pull(){return new Promise(u=>{n=u,i.openUnsafe()})},cancel(){if(o)return s=!0,iw(vo(Tn(o)))}},r?.strategy)}),Qse=d(e=>Ce(e[0]),(e,t)=>Rk(e,pt(),t)),Ok=d(e=>Ce(e[0]),(e,t)=>K(Nr(),r=>Rk(e,r,t))),_k=d(2,(e,t)=>({[Symbol.asyncIterator](){let r=aw(t),n=Sr(t),o=Zn(),s,i,a,c,u=p=>{if(c)return c;let m=a;return c=r(Pt(Vt(m?Tn(m):P,Ve(o,p)),{done:!0,value:void 0})),c},f=async p=>{try{await u(p)}catch(m){await r(Xp("Suppressed error while closing Stream async iterator",m))}};return{async next(){if(c)return c;if(i){let h=i.next();if(!h.done)return h;i=void 0}let p=n(s??C(as(e.channel,o),h=>(s=h,h)));a=p;let m=await r(Xj(p));if(a===p&&(a=void 0),ft(m))return i=m.value[Symbol.iterator](),i.next();if(wo(m.cause))return u(Kt);if(c&&u0(m.cause))return c;throw await f(m),lu(m.cause)},return(){return u(Kt)},async throw(p){throw await f(Dg(p)),p}}}})),Yse=e=>K(Nr(),t=>_k(e,t)),Xse=e=>_k(e,pt()),eie=d(e=>Ce(e[0]),(e,t,r)=>fk(e.channel,t,r)),tie=d(2,(e,t)=>Mq(e.channel,t)),Uz=d(2,(e,t)=>Fq(e.channel,t)),rie=d(2,(e,t)=>_q(e.channel,t)),nie=d(2,(e,t)=>uk(e.channel,t));var Dz="~effect/PrimaryKey";var Bz="~effect/Pool",qz=Symbol(),zz=Symbol(),Mk=Symbol();var Wz=e=>Vz({...e,min:e.size,max:e.size,strategy:Hb}),Kz=e=>C(e.timeToLiveStrategy==="creation"?die(e.timeToLive):pie(e.timeToLive),t=>Vz({...e,strategy:t})),Vz=e=>en(me(function*(t){let r=yield*Nr(),n=Re(r,it),o=ec(e.acquire,u=>Kr(r,u)),s=e.concurrency??1,i={acquire:o,concurrency:s,isFixed:e.min===e.max,minSize:e.min,maxSize:e.max,strategy:e.strategy,targetUtilization:Math.min(Math.max(e.targetUtilization??1,.1),1)},a={scope:n,isShuttingDown:!1,usage:0,resizeSemaphore:ff(1),items:new Set,availableHead:void 0,availableTail:void 0,invalidated:new Set,waiters:new Set},c={[Bz]:Bz,[qz]:e.acquire,[zz]:r,[Mk]:yield*Yn,config:i,state:a,pipe(){return V(this,arguments)}};return yield*It(n,oie(c)),i.minSize>0&&(yield*_t(Il(t(jb(c)),{startImmediately:!0}),u=>It(n,Tn(u)))),e.strategy!==Hb&&(yield*_t(Il(t(e.strategy.run(c))),u=>It(n,Tn(u)))),c})),oie=me(function*(e){if(e.state.isShuttingDown)return;e.state.isShuttingDown=!0;let t=e.state.items.size,r=ff(t);for(let n of e.state.items)n.refCount>0?(n.finalizer=_t(n.finalizer,r.release(1)),e.state.invalidated.add(n),yield*r.take(1)):(e.state.items.delete(n),Ih(e,n),e.state.invalidated.delete(n),yield*n.finalizer);if(e.state.waiters.size>0){let n=Array.from(e.state.waiters);e.state.waiters.clear();for(let o of n)o()}yield*r.take(t)}),Fk=e=>oe(t=>{let r=e.state;if(r.isShuttingDown)return nl;if(r.availableHead?.exit._tag==="Success"){if(r.usage++,e.config.isFixed||Th(e)<=wh(e))return Gz(e,r.availableHead,t);r.usage--}return sie(e,cie)});var sie=(e,t)=>Gn(r=>{let n=e.state;n.usage++;let o=Y(Tp(r(fie(e)),()=>ye(()=>{n.usage--})),()=>i),s=oe(a=>{if(n.isShuttingDown)return n.usage--,nl;let c=Nk(e)??(Th(e)<=wh(e)?n.availableHead:void 0);return c===void 0?o:c.exit._tag==="Failure"?(aie(e,c),i):t(e,c,a,r)}),i=ce(()=>n.isShuttingDown?(n.usage--,nl):Th(e)>wh(e)?Y(n.resizeSemaphore.withPermitsIfAvailable(1)(gt(vi(jb(e)),n.scope)),()=>s):s);return i}),iie=(e,t)=>{t.refCount++,t.refCount>=e.config.concurrency&&Ih(e,t)},aie=(e,t)=>{e.state.items.delete(t),e.state.invalidated.delete(t),Ih(e,t)},Gz=(e,t,r)=>{iie(e,t);let n=dn(r.context,it);return n.state._tag==="Closed"?Ka(r,t.release):Wa(n,{},t.release),t.exit},cie=(e,t,r)=>Gz(e,t,r),uie=(e,t)=>oe(r=>{let n=e.state;return t.refCount--,n.usage--,t.refCount===0&&(t.idleSince=e[Mk].currentTimeMillisUnsafe()),n.invalidated.has(t)?Dk(e,t):(t.refCount<e.config.concurrency&&(lie(e,t),Jz(e,r,1)),pe)}),Nk=e=>{let t=e.state.availableHead;for(;t!==void 0&&t.exit._tag==="Failure";)t=t.availableNext;return t},fie=e=>$t(t=>{let r=e.state;if(Nk(e)!==void 0||r.isShuttingDown)return t(pe);let n=o=>{r.waiters.delete(n),t(o??pe)};return r.waiters.add(n),ye(()=>{r.waiters.delete(n)})}),Jz=(e,t,r)=>{let n=e.state.waiters;n.size!==0&&t.currentDispatcher.scheduleTask(()=>{let o=r,s=[];for(let i of n){if(o--<=0)break;s.push(i)}for(let i=0;i<s.length;i++)s[i]()},0)},$z=e=>oe(t=>(Jz(e,t,Number.POSITIVE_INFINITY),pe)),Uk=new WeakMap,jz=(e,t)=>{t.isAvailable||Uk.has(t)||(t.isAvailable=!0,t.availablePrevious=e.state.availableTail,t.availableNext=void 0,e.state.availableTail!==void 0?e.state.availableTail.availableNext=t:e.state.availableHead=t,e.state.availableTail=t)},lie=(e,t)=>{t.isAvailable||Uk.has(t)||(t.isAvailable=!0,t.availablePrevious=void 0,t.availableNext=e.state.availableHead,e.state.availableHead!==void 0?e.state.availableHead.availablePrevious=t:e.state.availableTail=t,e.state.availableHead=t)},Ih=(e,t)=>{t.isAvailable&&(t.isAvailable=!1,t.availablePrevious!==void 0?t.availablePrevious.availableNext=t.availableNext:e.state.availableHead=t.availableNext,t.availableNext!==void 0?t.availableNext.availablePrevious=t.availablePrevious:e.state.availableTail=t.availablePrevious,t.availablePrevious=void 0,t.availableNext=void 0)};var Dk=(e,t)=>L(()=>{if(e.state.items.has(t)){if(t.refCount===0)return e.state.items.delete(t),Ih(e,t),e.state.invalidated.delete(t),vo(C(t.finalizer,()=>gt(vi(jb(e)),e.state.scope,{startImmediately:!0})))}else return P;return e.state.invalidated.add(t),Ih(e,t),vo(gt(vi(jb(e)),e.state.scope,{startImmediately:!0}))}),jb=e=>e.state.resizeSemaphore.withPermits(1)(Pk(e)),Pk=e=>L(()=>{let t=wh(e),r=Th(e);if(t>=r)return P;let n=r-t,o=e.config.strategy===Hb?Hz(e):C(e.config.strategy.reclaim(e),i=>i?I(i):Hz(e));if(n===1){let i=_t(o,$z(e));return e.config.isFixed?vo(i):C(i,a=>a.exit._tag==="Failure"?P:Pk(e))}let s=o.pipe(rw(n,{concurrency:n}),_t($z(e)));return e.config.isFixed?vo(s):C(s,i=>i.some(a=>a.exit._tag==="Failure")?P:Pk(e))}),Hz=e=>Gn(t=>oe(r=>{let n=e,o=tl(),s=r.context;r.setContext(We(n[zz],it,o));let i=C(eo(n[qz]),a=>{let c={exit:a,finalizer:rt(Ve(o,a),mie),refCount:0,idleSince:n[Mk].currentTimeMillisUnsafe(),disableReclaim:!1,isAvailable:!1,availablePrevious:void 0,availableNext:void 0,release:void 0};c.release=qe(uie(e,c));let u=L(()=>e.state.items.has(c)?e.config.strategy.onAcquire(c):P);if(a._tag==="Success")return e.state.items.add(c),jz(e,c),e.config.strategy===Hb?I(c):Pt(u,c);let f=Nk(e)===void 0?e.state.waiters.values().next().value:void 0;return f!==void 0?f(a):(e.state.items.add(c),jz(e,c)),Pt(gt(Vt(c.finalizer,u),e.state.scope,{startImmediately:!0}),c)});return Io(t(i),a=>(r.setContext(s),a._tag==="Failure"?el(o,a):void 0),!0)})),Th=e=>{if(e.state.isShuttingDown)return 0;if(e.config.isFixed)return e.config.minSize;let t=e.state.usage/e.config.targetUtilization,r=Math.ceil(t/e.config.concurrency);return Math.min(Math.max(e.config.minSize,r),e.config.maxSize)},wh=e=>e.state.items.size-e.state.invalidated.size,Hb={run:e=>P,onAcquire:e=>P,reclaim:e=>Kp},die=me(function*(e){let t=yield*Yn,r=yield*Sb(),n=Wt($e(e)),o=new WeakMap;return F({run:s=>{let i=a=>L(()=>{if(!s.state.items.has(a)||s.state.invalidated.has(a))return P;let c=t.currentTimeMillisUnsafe(),u=o.get(a),f=n-(c-u);return f>0?ca(i(a),f):Dk(s,a)});return Ws(r).pipe(_t(i),Mt({disableYield:!0}))},onAcquire:s=>L(()=>(o.set(s,t.currentTimeMillisUnsafe()),jn(r,s))),reclaim:s=>Kp})}),pie=me(function*(e){let t=yield*Yn,r=Wt($e(e));return F({run:n=>{let o=L(()=>{if(wh(n)<=Th(n))return P;let s=t.currentTimeMillisUnsafe()-r,i;for(let a of n.state.items)a.refCount>0||a.idleSince>s||n.state.invalidated.has(a)||Uk.has(a)||(i===void 0||a.idleSince<i.idleSince)&&(i=a);return i===void 0?P:C(Dk(n,i),()=>o)});return o.pipe(ca(e),Mt({disableYield:!0}))},onAcquire:n=>P,reclaim:n=>Kp})}),mie=e=>ar(t=>{let r=t.getRef(ON);return r?Tl(r)("Unhandled error in pool finalizer",e):P});var Qz="~effect/reactivity/Reactivity",Ac=Ue("effect/reactivity/Reactivity"),hie=W(()=>{let e=new Map,t=c=>{Lk(c,u=>{let f=e.get(u);f!==void 0&&f.forEach(p=>p())})},r=c=>yn(u=>{let f=Vi(u,qb);return f?Lk(c,p=>{f.add(p)}):t(c),P}),n=(c,u)=>_t(u,r(c)),o=(c,u)=>{let f=[];return Lk(c,p=>{f.push(p);let m=e.get(p);m===void 0&&(m=new Set,e.set(p,m)),m.add(u)}),()=>{for(let p=0;p<f.length;p++){let m=e.get(f[p]);m!==void 0&&(m.delete(u),m.size===0&&e.delete(f[p]))}}},s=(c,u)=>xt(function*(){let f=yield*Nr(),p=Re(f,it),m=yield*io(),h=jc(Sr(f),Ni(p)),x=!1,g=!1,y=v=>{v._tag==="Failure"?Ui(m,v.cause):Tc(m,v.value),g?(g=!1,h(u).addObserver(y)):x=!1};function E(){if(x){g=!0;return}x=!0,h(u).addObserver(y)}let b=o(c,E);return yield*It(p,W(b)),E(),m}),i=(c,u)=>s(c,u).pipe(K(Sh),An),a=c=>L(()=>{let u=new Set;return c.pipe(Jo(qb,u),Xr(f=>W(()=>{u.forEach(p=>{let m=e.get(p);m!==void 0&&m.forEach(h=>h())})})))});return Ac.of({[Qz]:Qz,mutation:n,query:s,stream:i,invalidateUnsafe:t,invalidate:r,registerUnsafe:o,withBatch:a})}),qb=class extends Ue()("effect/reactivity/Reactivity/PendingInvalidation"){},zb=d(2,(e,t)=>Ac.use(r=>r.mutation(t,e)));var Wb=e=>Ac.use(t=>t.invalidate(e)),Kb=Qn(Ac)(hie);function Yz(e){switch(typeof e){case"string":case"number":case"bigint":case"boolean":return String(e);default:return G(e)}}var Lk=(e,t)=>{if(Array.isArray(e)){for(let r=0;r<e.length;r++)t(Yz(e[r]));return}for(let r in e){t(r);let n=e[r];for(let o=0;o<n.length;o++)t(`${r}:${Yz(n[o])}`)}};var Xz="~effect/SubscriptionRef",vh=e=>O(e,Xz),Mye={...wr,[Xz]:{_A:F},toJSON(){return{_id:"SubscriptionRef",value:this.value}}};var Bk=e=>hk(e.pubsub);var eW=e=>W(()=>e.value);var xie=(e,t)=>{e.value=t,aH(e.pubsub,t)};var $k=d(2,(e,t)=>e.semaphore.withPermit(W(()=>xie(e,t))));var iE={};ps(iE,{Fetch:()=>CW,RequestInit:()=>sE,layer:()=>Lie});var jk="~effect/http/HttpBody";var rW="~effect/http/HttpBody/HttpBodyError",nW=class extends sr("HttpBodyError"){[rW]=rW};var Gb=class{[jk];constructor(){this[jk]=jk}[Qe](){return this.toJSON()}toString(){return H(this,{ignoreToString:!0})}},Hk=class extends Gb{_tag="Empty";toJSON(){return{_id:"effect/HttpBody",_tag:"Empty"}}},oW=new Hk;var Ah=class extends Gb{_tag="Uint8Array";contentType;contentLength;text;_body;constructor(t,r,n,o){super(),this._body=t,this.text=o,this.contentType=r,this.contentLength=n}get body(){return this._body??=gie(this.text)}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}}},qk=(e,t)=>new Ah(e,t??"application/octet-stream",e.length),sW=new TextEncoder,Jb=globalThis.Buffer,gie=Jb!==void 0?e=>Jb.from(e,"utf8"):e=>sW.encode(e),zk=(e,t)=>{if(typeof e!="string"&&(e=e===void 0?"":String(e)),Jb!==void 0)return new Ah(void 0,t??"text/plain",Jb.byteLength(e,"utf8"),e);let r=sW.encode(e);return new Ah(r,t??"text/plain",r.length,e)};var Kk="~effect/http/HttpClientError";var co=class extends sr("HttpClientError"){constructor(t){"cause"in t.reason?super({...t,cause:t.reason.cause}):super(t)}[Kk]=Kk;get request(){return this.reason.request}get response(){return"response"in this.reason?this.reason.response:void 0}get message(){return this.reason.message}},kh=e=>e.endsWith("Error")?e.slice(0,-5):e,Rh=(e,t,r)=>t?`${e}: ${t} (${r})`:`${e} error (${r})`,Zb=class extends sr("TransportError"){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return Rh(kh(this._tag),this.description,this.methodAndUrl)}};var Qb=class extends sr("InvalidUrlError"){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return Rh(kh(this._tag),this.description,this.methodAndUrl)}},Ch=class extends sr("StatusCodeError"){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let t=`${this.response.status} ${this.methodAndUrl}`;return Rh(kh(this._tag),this.description,t)}},Cc=class extends sr("DecodeError"){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let t=`${this.response.status} ${this.methodAndUrl}`;return Rh(kh(this._tag),this.description,t)}},Yb=class extends sr("EmptyBodyError"){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let t=`${this.response.status} ${this.methodAndUrl}`;return Rh(kh(this._tag),this.description,t)}},wd=class e extends Cr(Kk)({_tag:He("HttpError"),kind:Fo(["EncodeError","DecodeError","TransportError","InvalidUrlError","StatusCodeError","EmptyBodyError"]),cause:lr(er())}){static fromHttpClientError(t){return new e({_tag:"HttpError",kind:t.reason._tag,cause:t.reason})}};var iW=[["GET","get"],["POST","post"],["PUT","put"],["DELETE","del"],["PATCH","patch"],["HEAD","head"],["OPTIONS","options"],["TRACE","trace"],["QUERY","query"]];var cW=(e,t)=>t._tag==="Empty"||t._tag==="FormData"?sc(sc(e,"content-type"),"content-length"):(e=t.contentType===void 0?sc(e,"content-type"):fm(e,"content-type",t.contentType),t.contentLength===void 0?sc(e,"content-length"):fm(e,"content-length",t.contentLength.toString()));var eE=class extends sr("UrlError"){},tE=(e,t,r)=>Ux({try:()=>{let n=new URL(e,Sie());for(let o=0;o<t.params.length;o++){let[s,i]=t.params[o];i!==void 0&&n.searchParams.append(s,i)}return r!==void 0&&(n.hash=r),n},catch:n=>new eE({cause:n})}),Sie=()=>{if("location"in globalThis&&globalThis.location!==void 0&&globalThis.location.origin!==void 0&&globalThis.location.pathname!==void 0)return location.origin+location.pathname};var uW="~effect/http/HttpClientRequest";var bie={[uW]:uW,...Ot,toJSON(){return{_id:"HttpClientRequest",method:this.method,url:this.url,urlParams:this.urlParams,hash:this.hash,headers:ho(this.headers),body:this.body.toJSON()}},pipe(){return V(this,arguments)}};function Bi(e,t,r,n,o,s){let i=Object.create(bie);return i.method=e,i.url=t,i.urlParams=r,i.hash=n,i.headers=o,i.body=s,i}var Eie=Bi("GET","",i1,_(),kl,oW),fW=e=>(t,r)=>Iie(Eie,{method:e,url:t,...r??void 0});var Iie=d(2,(e,t)=>{let r=e;return t.method&&(r=lW(r,t.method)),t.url&&(r=mW(r,t.url)),t.headers&&(r=Gk(r,t.headers)),t.urlParams&&(r=vie(r,t.urlParams)),t.hash&&(r=Aie(r,t.hash)),t.body&&(r=xW(r,t.body)),t.accept&&(r=pW(r,t.accept)),t.acceptJson&&(r=Tie(r)),r}),lW=d(2,(e,t)=>Bi(t,e.url,e.urlParams,e.hash,e.headers,e.body)),dW=d(3,(e,t,r)=>Bi(e.method,e.url,e.urlParams,e.hash,fm(e.headers,t,r),e.body)),Gk=d(2,(e,t)=>Bi(e.method,e.url,e.urlParams,e.hash,n1(e.headers,t),e.body));var pW=d(2,(e,t)=>dW(e,"Accept",t)),Tie=pW("application/json"),mW=d(2,(e,t)=>{if(typeof t=="string")return Bi(e.method,t,e.urlParams,e.hash,e.headers,e.body);let r=new URL(t.toString()),n=Fu(r.searchParams),o=eu(r.hash===""?void 0:r.hash.slice(1));return r.search="",r.hash="",Bi(e.method,r.toString(),n,o,e.headers,e.body)}),hW=d(2,(e,t)=>t===""?e:Bi(e.method,wie(t,e.url),e.urlParams,e.hash,e.headers,e.body));var wie=(e,t)=>{let r=e.endsWith("/"),n=t.startsWith("/");return r&&n?e+t.slice(1):!r&&!n?e+"/"+t:e+t};var vie=d(2,(e,t)=>Bi(e.method,e.url,c1(e.urlParams,t),e.hash,e.headers,e.body));var Aie=d(2,(e,t)=>Bi(e.method,e.url,e.urlParams,N(t),e.headers,e.body));var xW=d(2,(e,t)=>Bi(e.method,e.url,e.urlParams,e.hash,cW(e.headers,t),t));function gW(e){let t=tE(e.url,e.urlParams,_n(e.hash));return tt(t)?N(t.success):_()}var Sf="~effect/http/HttpIncomingMessage";var yW=(e,t)=>{let r=e.headers["content-type"]??"",n;if(r.includes("application/json"))try{n=Ci(e.json)}catch{}else if(r.includes("text/")||r.includes("urlencoded"))try{n=Ci(e.text)}catch{}let o={...t,headers:ho(e.headers),remoteAddress:e.remoteAddress};return n!==void 0&&(o.body=n),o};var vd="~effect/http/HttpClientResponse",SW=(e,t)=>new Zk(e,t);var Zk=class extends bx{[Sf];[vd];request;source;constructor(t,r){super(),this.request=t,this.source=r,this[Sf]=Sf,this[vd]=vd}toJSON(){return yW(this,{_id:"HttpClientResponse",request:this.request.toJSON(),status:this.status})}get status(){return this.source.status}get url(){if(this.source.url)return this.source.url.split("#")[0];let t=gW(this.request);return fe(t)?"":(t.value.hash="",t.value.href)}get headers(){return Zo(this.source.headers)}cachedCookies;get cookies(){return this.cachedCookies?this.cachedCookies:this.cachedCookies=My(this.source.headers.getSetCookie?.()??[])}get remoteAddress(){return _()}get stream(){return this.source.body?xk({evaluate:()=>this.source.body,onError:t=>new co({reason:new Cc({request:this.request,response:this,cause:t})})}):vc(new co({reason:new Yb({request:this.request,response:this,description:"can not create stream from empty body"})}))}get json(){return C(this.text,t=>Go({try:()=>t===""?null:JSON.parse(t),catch:r=>new co({reason:new Cc({request:this.request,response:this,cause:r})})}))}textBody;get text(){return this.textBody??=K(this.arrayBuffer,t=>new TextDecoder().decode(t))}get urlParamsBody(){return C(this.text,t=>Go({try:()=>Fu(new URLSearchParams(t)),catch:r=>new co({reason:new Cc({request:this.request,response:this,cause:r})})}))}formDataBody;get formData(){return this.formDataBody??=Vo({try:()=>this.source.formData(),catch:t=>new co({reason:new Cc({request:this.request,response:this,cause:t})})}).pipe(ly,Ci)}arrayBufferBody;get arrayBuffer(){return this.arrayBufferBody?this.arrayBufferBody:(this.arrayBufferBody=Vo({try:()=>this.source.arrayBuffer(),catch:t=>new co({reason:new Cc({request:this.request,response:this,cause:t})})}).pipe(ly,Ci),this.arrayBufferBody)}pipe(){return V(this,arguments)}};var bW=e=>r1({b3:`${e.traceId}-${e.spanId}-${e.sampled?"1":"0"}${Zt(e.parent,{onNone:()=>"",onSome:t=>`-${t.spanId}`})}`,traceparent:`00-${e.traceId}-${e.spanId}-${e.sampled?"01":"00"}`});var Cie={"http:":80,"https:":443,"ws:":80,"wss:":443},IW=(e,t)=>{let r=t.search.slice(1);if(e.attribute("url.full",t.toString()),e.attribute("url.path",t.pathname),r!==""&&e.attribute("url.query",r),e.attribute("url.scheme",t.protocol.slice(0,-1)),t.hostname!==""){e.attribute("server.address",t.hostname.startsWith("[")?t.hostname.slice(1,-1):t.hostname);let n=t.port===""?Cie[t.protocol]:Number(t.port);n!==void 0&&e.attribute("server.port",n)}},Yk=(e,t,r,n,o)=>{for(let s in r)n(s,t)&&e.attribute(`http.${t}.header.${s}`,o1(s,o)?"<redacted>":r[s])};var TW="~effect/http/HttpClient";var Xk=Ue("effect/HttpClient");var Rie=d(2,(e,t)=>eR(r=>t(e.postprocess(r)),e.preprocess));var eR=(e,t)=>{let r=Object.create(Oie);return r.preprocess=t,r.postprocess=e,r.execute=function(n){return e(t(n))},r},Oie={[TW]:TW,pipe(){return V(this,arguments)},...Ot,toJSON(){return{_id:"effect/HttpClient"}},...Object.fromEntries(iW.map(([e,t])=>[t,function(r,n){return this.execute(fW(e)(r,n))}]))},wW=e=>eR(t=>C(t,r=>ar(n=>{let o=Uie.get(r),s=o??new AbortController,i=tE(r.url,r.urlParams,_n(r.hash));if(be(i))return D(new co({reason:new Qb({request:r,cause:i.failure})}));let a=i.success;if(n.getRef(qf)||n.getRef(Pie)(r)){let u=e(r,a,s.signal,n);return o?u:en(f=>Un(f(u),{onSuccess(p){return nE.register(p,s),I(new oE(p,s))},onFailure(p){return fl(p)&&s.abort(),je(p)}}))}return Qp(n.getRef(Nie)(r),{kind:"client"},u=>{u.attribute("http.request.method",r.method);let f=n.getRef(Vw);IW(u,a);let p=n.getRef(Mie);return Yk(u,"request",r.headers,p,f),r=n.getRef(Fie)?Gk(r,bW(u)):r,en(m=>m(e(r,a,s.signal,n)).pipe(bl(u,{captureStackTrace:!1}),Un({onSuccess:h=>(u.attribute("http.response.status_code",h.status),Yk(u,"response",h.headers,p,f),h.status>=400&&h.status<600&&(u.attribute("error.type",String(h.status)),_ie(n,u,r,h)),o?I(h):(nE.register(h,s),I(new oE(h,s)))),onFailure(h){return!o&&fl(h)&&s.abort(),je(h)}})))})})),I),_ie=(e,t,r,n)=>{let o=Ir();yt(0);let s;try{s=Jn(new co({reason:new Ch({request:r,response:n})}))}finally{yt(o)}t.end(e.getRef(jg)?e.getRef(Yn).currentTimeNanosUnsafe():BigInt(0),s)},vW=d(2,(e,t)=>eR(e.postprocess,r=>K(e.preprocess(r),t)));var Pie=Ae("effect/http/HttpClient/TracerDisabledWhen",{defaultValue:()=>_a}),Mie=Ae("effect/http/HttpClient/TracerHeaderFilter",{defaultValue:()=>_a}),Fie=Ae("effect/http/HttpClient/TracerPropagationEnabled",{defaultValue:nr}),Nie=Ae("effect/http/HttpClient/SpanNameGenerator",{defaultValue:()=>e=>e.method}),AW=e=>Qn(Xk)(yn(t=>K(e,r=>Rie(r,ec(n=>Kr(t,n)))))),nE=(()=>{if("FinalizationRegistry"in globalThis&&globalThis.FinalizationRegistry){let t=new FinalizationRegistry(r=>{r.abort()});return{register(r,n){t.register(r,n,r)},unregister(r){t.unregister(r)}}}let e=new WeakMap;return{register(t,r){e.set(t,setTimeout(()=>r.abort(),5e3))},unregister(t){let r=e.get(t);r!==void 0&&(clearTimeout(r),e.delete(t))}}})(),Uie=new WeakMap,oE=class{original;controller;constructor(t,r){this.original=t,this.controller=r}[vd]=vd;[Sf]=Sf;applyInterrupt(t){return L(()=>(nE.unregister(this.original),bu(t,()=>W(()=>{this.controller.abort()}))))}get request(){return this.original.request}get url(){return this.original.url}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 vn(()=>(nE.unregister(this.original),Eh(this.original.stream,W(()=>{this.controller.abort()}))))}toJSON(){return this.original.toJSON()}[Qe](){return this.original[Qe]()}pipe(){return V(this,arguments)}};var CW=Ae("effect/http/FetchHttpClient/Fetch",{defaultValue:()=>globalThis.fetch}),sE=class extends Ue()("effect/http/FetchHttpClient/RequestInit"){},Die=wW((e,t,r,n)=>{let o=n.getRef(CW),s=Vi(n.context,sE)??{},i=s.headers?Rl(Zo(s.headers),e.headers):e.headers;i["content-length"]&&(i=sc(i,"content-length"));let a=c=>K(Vo({try:()=>o(t,{...s,method:e.method,headers:i,body:c,duplex:typeof ReadableStream<"u"&&c instanceof ReadableStream?"half":void 0,signal:r}),catch:u=>new co({reason:new Zb({request:e,cause:u})})}),u=>SW(e,u));switch(e.body._tag){case"Raw":case"Uint8Array":return a(e.body.body);case"FormData":return a(e.body.formData);case"Stream":return C(Ok(e.body.stream),a)}return a(void 0)}),Lie=AW(I(Die));var RW=Ue("effect/socket/Socket");var rR="~effect/socket/Socket/CloseEvent",kW=class{[rR];code;reason;constructor(t=1e3,r){this[rR]=rR,this.code=t,this.reason=r}toString(){return this.reason?`${this.code}: ${this.reason}`:`${this.code}`}};var aE="~effect/socket/Socket/SocketError",Bie=e=>O(e,aE),Oh=class extends Cr("effect/socket/Socket/SocketReadError")({_tag:He("SocketReadError"),cause:er()}){message="An error occurred during Read"},nR=class extends Cr("effect/socket/Socket/SocketWriteError")({_tag:He("SocketWriteError"),cause:er()}){message="An error occurred during Write"},oR=class extends Cr("effect/socket/Socket/SocketOpenError")({_tag:He("SocketOpenError"),kind:Fo(["Unknown","Timeout"]),cause:er()}){get message(){return this.kind==="Timeout"?'timeout waiting for "open"':"An error occurred during Open"}},sR=class e extends Cr("effect/socket/Socket/SocketUpgradeError")({_tag:He("SocketUpgradeError"),cause:lr(er())}){static unsupported=()=>D(new _h({reason:new e({})}));get message(){return this.cause===void 0?"Socket does not support TLS upgrade":"An error occurred during TLS upgrade"}},iR=class extends Cr("effect/socket/Socket/SocketCloseError")({_tag:He("SocketCloseError"),code:In,closeReason:lr(z)}){get message(){return this.closeReason?`${this.code}: ${this.closeReason}`:`${this.code}`}},aR=Pe([Oh,nR,oR,sR,iR]),_h=class extends TC(aE)("SocketError",{_tag:He("SocketError"),reason:aR}){constructor(t){"cause"in t.reason?super({...t,cause:t.reason.cause}):super(t)}[aE]=aE;static is(t){return Bie(t)}message=this.reason.message};var ybe=64*1024;var OW="~effect/reactivity/AsyncResult",uR=e=>O(e,OW),cE={[OW]:{E:F,A:F},pipe(){return V(this,arguments)},[ae](e){if(this._tag!==e._tag||this.waiting!==e.waiting)return!1;switch(this._tag){case"Initial":return!0;case"Success":return Z(this.value,e.value);case"Failure":return Z(this.cause,e.cause)}},[ie](){let e=Be(`${this._tag}:${this.waiting}`);return this._tag==="Initial"?e:he(e)(this._tag==="Success"?G(this.value):G(this.cause))}};var fR=(e,t)=>e._tag==="Success"?us(e.value):Cd(e.cause,{previous:t}),uE=e=>e._tag==="None"?Aa(!0):Ph(e.value);var _W=e=>e._tag!=="Initial",Aa=(e=!1)=>{let t=Object.create(cE);return t._tag="Initial",t.waiting=e,t},Ad=e=>e._tag==="Success",us=(e,t)=>{let r=Object.create(cE);return r._tag="Success",r.value=e,r.waiting=t?.waiting??!1,r.timestamp=t?.timestamp??Date.now(),r},PW=e=>e._tag==="Failure";var cR=(e,t)=>{let r=Object.create(cE);return r._tag="Failure",r.cause=e,r.previousSuccess=t?.previousSuccess??_(),r.waiting=t?.waiting??!1,r},Cd=(e,t)=>cR(e,{previousSuccess:gs(t.previous,r=>Ad(r)?N(r):PW(r)?r.previousSuccess:_()),waiting:t.waiting});var MW=(e,t)=>Cd(xN(e),t),Ph=d(e=>uR(e[0]),(e,t)=>{if(e.waiting)return t?.touch?jie(e):e;let r=Object.assign(Object.create(cE),e);return r.waiting=!0,t?.touch&&Ad(r)&&(r.timestamp=Date.now()),r}),jie=e=>Ad(e)?us(e.value,{waiting:e.waiting}):e,Mh=d(2,(e,t)=>e._tag==="Failure"?Cd(e.cause,{previous:t,waiting:e.waiting}):e),lR=e=>e._tag==="Success"?N(e.value):e._tag==="Failure"?Lt(e.previousSuccess,t=>t.value):_();var dR=e=>Bf(lR(e),()=>new ll("AsyncResult.getOrThrow: no value found"));var kd=e=>{switch(e._tag){case"Success":return Mr(e.value);case"Failure":return ir(e.cause);default:return Jn(new ll)}};var pR=e=>{let t=e.success??Mi,r=e.error??Mi,n=Ar()([t,Jm(r,er())],([o,s])=>(i,a,c)=>{if(!uR(i))return D(new at(a,i,c));switch(i._tag){case"Initial":return I(i);case"Success":return cr(ot(o)(i.value,c),{onSuccess:u=>us(u,i),onFailure:u=>tn(a,"value",u,i,c)});case"Failure":{let u=i.previousSuccess.pipe(Lt(p=>cr(ot(o)(p.value,c),{onSuccess:m=>N(us(m,p)),onFailure:m=>new Ft(a,[new Ct(["previousSuccess","value"],m)],i,c)})),Fa(()=>ia)),f=Tu(ot(s)(i.cause,c),p=>tn(a,"cause",p,i,c));return ur(u,p=>Iu(f,m=>cR(m,{previousSuccess:p,waiting:i.waiting})))}}},{expected:"AsyncResult",toCodec([o,s]){let i=ya("Success",{value:o,waiting:Fi,timestamp:In});return Ne()(Pe([ya("Initial",{waiting:Fi}),i,ya("Failure",{cause:s,previousSuccess:ba(i),waiting:Fi})]),Fe({decode:a=>{switch(a._tag){case"Initial":return Aa(a.waiting);case"Success":return us(a.value,{waiting:a.waiting,timestamp:a.timestamp});case"Failure":return cR(a.cause,{previousSuccess:Lt(a.previousSuccess,c=>us(c.value,c)),waiting:a.waiting})}},encode(a){switch(a._tag){case"Initial":return{_tag:"Initial",waiting:a.waiting};case"Success":return{_tag:"Success",value:a.value,waiting:a.waiting,timestamp:a.timestamp};case"Failure":return{_tag:"Failure",cause:a.cause,previousSuccess:a.previousSuccess,waiting:a.waiting}}}}))},toEquivalence:Wd,toFormatter:([o,s])=>i=>{switch(i._tag){case"Success":return`AsyncResult.Success(${o(i.value)}, ${i.waiting}, ${i.timestamp})`;case"Failure":return`AsyncResult.Failure(${s(i.cause)}, ${i.waiting})`;case"Initial":return`AsyncResult.Initial(${i.waiting}, ${i.waiting})`}}});return Object.assign(n,{success:t,error:r})};var Nh="~effect/reactivity/AtomRegistry",Hie=e=>O(e,Nh),FW=e=>new xR(e?.initialValues,e?.scheduleTask,e?.timeoutResolution,e?.defaultIdleTTL),fE=Ue(Nh);var Dh=d(e=>Hie(e[0]),(e,t,r)=>{let n=r?.suspendOnWaiting??!1;return Nn(o=>{let s=e.get(t);if(s._tag!=="Initial"&&!(n&&s.waiting))return o(kd(s));let i=e.subscribe(t,a=>{a._tag!=="Initial"&&!(n&&a.waiting)&&(o(kd(a)),i())});return W(i)})});var qie={immediate:!0},NW=e=>{e()},Cn={};function Uh(e,t){let r=Cn;for(let n of e)try{t(n)}catch(o){r===Cn&&(r=o)}if(r!==Cn)throw r}var hR="~effect-atom/atom/Atom/Serializable",Fh=e=>hR in e?e[hR].key:e,xR=class{[Nh];timeoutResolution;defaultIdleTTL;scheduler;schedulerAsync;dispatcher;onNodeAdded;onNodeRemoved;constructor(t,r,n,o){if(this[Nh]=Nh,this.scheduler=new fi("sync",r),this.schedulerAsync=new fi("async",r),this.dispatcher=this.schedulerAsync.makeDispatcher(),this.defaultIdleTTL=o,n===void 0&&o!==void 0?this.timeoutResolution=Math.round(o/2):this.timeoutResolution=n??1e3,t!==void 0)for(let[s,i]of t){let a=s;for(;a.initialValueTarget;)a=a.initialValueTarget;this.ensureNode(a).setInitialValue(i)}}nodes=new Map;preloadedSerializable=new Map;timeoutBuckets=new Map;nodeTimeoutBucket=new Map;disposed=!1;getNodes(){return this.nodes}get(t){return this.ensureNode(t).value()}set(t,r){t.write(this.ensureNode(t).writeContext,r)}setSerializable(t,r){this.preloadedSerializable.set(t,r)}modify(t,r){let n=this.ensureNode(t),o=r(n.value());return t.write(n.writeContext,o[1]),o[0]}update(t,r){let n=this.ensureNode(t);t.write(n.writeContext,r(n.value()))}refresh=t=>{t.refresh!==void 0?t.refresh(this.refresh):this.invalidateAtom(t)};subscribe(t,r,n){let o=this.ensureNode(t);n?.immediate?r(o.value()):o.state===an.stale&&o.value();let s=o.subscribe(function(){r(o._value)});return()=>{s(),o.canBeRemoved&&this.scheduleNodeRemoval(o)}}mount(t){return this.subscribe(t,Rr,qie)}atomHasTtl(t){return!t.keepAlive&&t.idleTTL!==0&&(t.idleTTL!==void 0||this.defaultIdleTTL!==void 0)}ensureNode(t){let r=Fh(t),n=this.nodes.get(r);if(n===void 0?(n=this.createNode(t),this.nodes.set(r,n),this.onNodeAdded?.(n)):this.atomHasTtl(t)&&this.removeNodeTimeout(n),typeof r=="string"&&this.preloadedSerializable.has(r)){let o=this.preloadedSerializable.get(r);this.preloadedSerializable.delete(r);let s=t[hR].decode(o),i=t;for(;i.initialValueTarget;)i=i.initialValueTarget;i===t?n.setValue(s):this.ensureNode(i).setInitialValue(s)}return n}createNode(t){if(this.disposed)throw new Error(`Cannot access Atom ${t}: registry is disposed`);return t.keepAlive||this.scheduleAtomRemoval(t),new gR(this,t)}invalidateAtom=t=>{this.ensureNode(t).invalidate()};scheduleAtomRemoval(t){this.dispatcher.scheduleTask(()=>{let r=this.nodes.get(Fh(t));r!==void 0&&r.canBeRemoved&&this.removeNode(r)},0)}scheduleNodeRemoval(t){this.dispatcher.scheduleTask(()=>{t.canBeRemoved&&this.removeNode(t)},0)}removeNode(t){this.atomHasTtl(t.atom)?this.setNodeTimeout(t):(this.nodes.delete(Fh(t.atom)),t.remove(),this.onNodeRemoved?.(t))}setNodeTimeout(t){if(this.nodeTimeoutBucket.has(t))return;let r=t.atom.idleTTL??this.defaultIdleTTL;if(this.#e!==null&&(r-=this.#e,r<=0)){this.nodes.delete(Fh(t.atom)),t.remove(),this.onNodeRemoved?.(t);return}let n=Math.ceil(r/this.timeoutResolution)*this.timeoutResolution,o=Date.now()+n,s=o-o%this.timeoutResolution+this.timeoutResolution,i=this.timeoutBuckets.get(s);i===void 0&&(i=[new Set,setTimeout(()=>this.sweepBucket(s),s-Date.now())],this.timeoutBuckets.set(s,i)),i[0].add(t),this.nodeTimeoutBucket.set(t,s)}removeNodeTimeout(t){let r=this.nodeTimeoutBucket.get(t);if(r===void 0)return;this.nodeTimeoutBucket.delete(t),this.scheduleNodeRemoval(t);let[n,o]=this.timeoutBuckets.get(r);n.delete(t),n.size===0&&(clearTimeout(o),this.timeoutBuckets.delete(r))}#e=null;sweepBucket(t){let r=this.timeoutBuckets.get(t)[0];this.timeoutBuckets.delete(t),Uh(r,this.removeIdleNode)}removeIdleNode=t=>{if(this.nodeTimeoutBucket.delete(t),!!t.canBeRemoved){this.nodes.delete(Fh(t.atom)),this.onNodeRemoved?.(t),this.#e=t.atom.idleTTL??this.defaultIdleTTL;try{t.remove()}finally{this.#e=null}}};reset(){this.timeoutBuckets.forEach(([,r])=>clearTimeout(r)),this.timeoutBuckets.clear(),this.nodeTimeoutBucket.clear();let t=Array.from(this.nodes.values());this.nodes.clear();for(let r of t)r.state=an.removed;Uh(t,this.destroyNode)}destroyNode=t=>{t.remove(),this.onNodeRemoved?.(t)};dispose(){this.disposed=!0,this.reset()}},fs={alive:1,initialized:2,waitingForValue:4},an={uninitialized:fs.alive|fs.waitingForValue,stale:fs.alive|fs.initialized|fs.waitingForValue,valid:fs.alive|fs.initialized,removed:0},gR=class{constructor(t,r){this.registry=t,this.atom=r,this.writeContext=new yR(t,this)}registry;atom;state=an.uninitialized;lifetime;writeContext;preserveInitialValueOnBuild=!1;invalidatedDuringBuild=!1;failed=!1;parents=new Set;children=new Set;listeners=new Set;observedChildren=0;currentState(){switch(this.state){case an.uninitialized:return"uninitialized";case an.stale:return"stale";case an.valid:return"valid";default:return"removed"}}get canBeRemoved(){return!this.atom.keepAlive&&this.listeners.size===0&&this.children.size===0&&this.state!==0}get building(){return this.lifetime!==void 0&&this.lifetime.reads!==void 0}get isObserved(){return!this.atom.lazy||this.listeners.size>0||this.observedChildren>0}childObserved(t){let r=this.isObserved;this.observedChildren+=t,r!==this.isObserved&&this.observedChanged(t)}observedChanged(t){for(let r of this.parents)r.childObserved(t)}_value=void 0;value(){for(;(this.state&fs.waitingForValue)!==0;)this.build();return this._value}build(){this.disposeLifetime(),this.invalidatedDuringBuild=!1;let t=Wie(this);this.lifetime=t;let r,n=!1;try{r=this.atom.read(t),n=!0}finally{let o=t.reads;t.reads=void 0,this.lifetime===t&&(this.dropUnread(o),n||this.fail())}if(this.lifetime===t&&(this.state&fs.waitingForValue)!==0&&(this.preserveInitialValueOnBuild?(this.preserveInitialValueOnBuild=!1,this.failed=!1,this.state=an.valid):this.setValue(r)),t.failure!==Cn)throw t.failure}fail(){this.failed=!0;try{this.invalidateChildren()}catch{}}readTracked(t,r){let n=this.registry.ensureNode(t);this.parents.has(n)||(this.parents.add(n),n.children.add(this),this.isObserved&&n.childObserved(1));try{return n.value()}catch(o){if(r.reads===void 0||n.state!==an.valid)throw o;return r.failure===Cn&&(r.failure=o),n._value}finally{r.reads!==void 0&&!r.disposed&&r.reads.add(n)}}dropUnread(t){if(t.size===this.parents.size)return;let r=this.isObserved;for(let n of this.parents)t.has(n)||(this.parents.delete(n),n.children.delete(this),r&&n.childObserved(-1),n.canBeRemoved&&this.registry.scheduleNodeRemoval(n))}valueOption(){return(this.state&fs.initialized)===0?_():N(this._value)}setInitialValue(t){if((this.state&fs.initialized)===0){this.preserveInitialValueOnBuild=!0,this.state=an.stale,this._value=t,this.listeners.size>0&&this.announce();return}this.setValue(t)}setValue(t){let r=this.failed;this.failed=!1;let n=(this.state&fs.initialized)!==0;if(this.state=an.valid,n&&this.atom.equals(this._value,t)){r&&this.invalidateChildren();return}this._value=t;let o=Cn;try{this.invalidateChildren()}catch(s){o=s}if(this.listeners.size>0)try{this.announce()}catch(s){o===Cn&&(o=s)}if(o!==Cn)throw o}announce(){cn.phase===kc.collect?cn.notify.add(this):this.notify()}invalidate(){if(this.state===an.valid){this.state=an.stale;try{this.disposeLifetime()}finally{this.propagate()}}else this.building&&cn.phase!==kc.collect?this.build():this.propagate()}propagate(){cn.phase===kc.collect?(this.building&&(this.invalidatedDuringBuild=!0),cn.stale.push(this)):this.isObserved?this.value():this.invalidateChildren()}invalidateChildren(){if(this.children.size===0)return;let t=Cn;for(let r of Array.from(this.children))if(r.affectedBy(this))try{r.invalidate()}catch(n){t===Cn&&(t=n)}if(t!==Cn)throw t}affectedBy(t){if(this.state===an.valid)return!0;let r=this.lifetime?.reads;return r!==void 0?r.has(t):this.isObserved&&t.state===an.valid}notify(){cn.phase===kc.commit&&cn.notify.delete(this),Uh(this.listeners,NW)}disposeLifetime(){let t=this.lifetime;t!==void 0&&(this.lifetime=void 0,t.dispose())}remove(){let t=this.isObserved;this.state=an.removed,this.listeners.clear();try{this.disposeLifetime()}finally{let r=Array.from(this.parents);this.parents.clear(),Uh(r,n=>{n.children.delete(this),t&&n.childObserved(-1),n.canBeRemoved&&this.registry.removeNode(n)})}}subscribe(t){let r=this.isObserved;return this.listeners.add(t),r||this.observedChanged(1),()=>{this.listeners.delete(t)&&!this.isObserved&&this.observedChanged(-1)}}},zie={get registry(){return this.node.registry},addFinalizer(e){if(this.disposed)return e();this.finalizers??=[],this.finalizers.push(e)},get(e){return this.disposed?this.node.registry.get(e):this.node.readTracked(e,this)},result(e,t){if(this.disposed||this.isFn)return this.resultOnce(e,t);let r=this.get(e);if(t?.suspendOnWaiting&&r.waiting)return Xn;switch(r._tag){case"Initial":return Xn;case"Failure":return ir(r.cause);case"Success":return I(r.value)}},resultOnce(e,t){return Nn(r=>{let n=this.once(e);if(n._tag!=="Initial"&&!(t?.suspendOnWaiting&&n.waiting))return r(kd(n));let o=this.node.registry.subscribe(e,s=>{s._tag==="Initial"||t?.suspendOnWaiting&&s.waiting||(o(),r(kd(s)))},{immediate:!1});return W(o)})},setResult(e,t){return this.disposed?Xn:(this.node.registry.set(e,t),this.resultOnce(e,{suspendOnWaiting:!0}))},some(e){if(this.disposed||this.isFn)return this.someOnce(e);let t=this.get(e);return t._tag==="None"?Xn:I(t.value)},someOnce(e){return Nn(t=>{let r=this.once(e);if(de(r))return t(I(r.value));let n=this.node.registry.subscribe(e,o=>{fe(o)||(n(),t(I(o.value)))},{immediate:!1});return W(n)})},once(e){return this.node.registry.get(e)},self(){return this.disposed?_():this.node.valueOption()},refresh(e){this.disposed||this.node.registry.refresh(e)},refreshSelf(){this.disposed||this.node.invalidate()},mount(e){this.disposed||this.addFinalizer(this.node.registry.mount(e))},subscribe(e,t,r){this.disposed||this.addFinalizer(this.node.registry.subscribe(e,t,r))},setSelf(e){this.disposed||this.node.setValue(e)},set(e,t){this.disposed||this.node.registry.set(e,t)},stream(e,t){return this.disposed?Js:Db(r=>W(()=>{this.subscribe(e,n=>Tc(r,n),{immediate:!t?.withoutInitialValue})}))},streamResult(e,t){return this.stream(e,t).pipe(bk(_W),gf(r=>r._tag==="Success"?I(r.value):je(r.cause)))},dispose(){if(this.disposed=!0,this.finalizers===void 0)return;let e=this.finalizers;this.finalizers=void 0,Uh(e.reverse(),NW)}},Wie=e=>{function t(r){return t.disposed||t.isFn?e.registry.get(r):e.readTracked(r,t)}return Object.setPrototypeOf(t,zie),t.isFn=!1,t.disposed=!1,t.finalizers=void 0,t.node=e,t.reads=new Set,t.failure=Cn,t},yR=class{constructor(t,r){this.registry=t,this.node=r}registry;node;get(t){return this.registry.get(t)}set(t,r){return this.registry.set(t,r)}setSelf(t){return this.node.setValue(t)}refreshSelf(){return this.node.invalidate()}},kc={disabled:0,collect:1,commit:2},cn={phase:kc.disabled,depth:0,stale:[],notify:new Set};function UW(e){let t=cn.phase;cn.phase=kc.collect,cn.depth++;let r=Cn;try{e()}catch(n){r=n}if(cn.depth===1){let{notify:n,stale:o}=cn,s=0;do{for(cn.phase=kc.collect;s<o.length;s++)try{Kie(o[s])}catch(i){r===Cn&&(r=i)}cn.phase=kc.commit;for(let i of n)try{i.notify()}catch(a){r===Cn&&(r=a)}}while(s<o.length);cn.stale=[],n.clear()}if(cn.depth--,cn.phase=t,r!==Cn)throw r}function Kie(e){if(e.state===an.valid){if(!e.invalidatedDuringBuild)return;e.invalidatedDuringBuild=!1,e.state=an.stale,e.disposeLifetime()}e.value()}var ex={};ps(ex,{ConnectionHooks:()=>Xh,CurrentHeaders:()=>DE,Protocol:()=>Hi,layerProtocolHttp:()=>uue,layerProtocolSocket:()=>due,layerProtocolWorker:()=>pue,make:()=>iO,makeNoSerialization:()=>p6,makeProtocolHttp:()=>m6,makeProtocolSocket:()=>h6,makeProtocolWorker:()=>x6,withHeaders:()=>cue});var Lh=class extends Ue()("effect/workers/Transferable/Collector"){},LW=()=>{let e=[],t=o=>{e.push(...o)},r=()=>e,n=()=>{let o=e;return e=[],o};return Lh.of({addAllUnsafe:t,addAll:o=>W(()=>t(o)),readUnsafe:r,read:W(r),clearUnsafe:n,clear:W(n)})};var SR="~effect/workers/WorkerError";var bR=class extends Cr("effect/workers/WorkerError/WorkerSpawnError")({_tag:He("WorkerSpawnError"),message:z,cause:lr(er())}){},ER=class extends Cr("effect/workers/WorkerError/WorkerSendError")({_tag:He("WorkerSendError"),message:z,cause:lr(er())}){},IR=class extends Cr("effect/workers/WorkerError/WorkerReceiveError")({_tag:He("WorkerReceiveError"),message:z,cause:lr(er())}){},TR=class extends Cr("effect/workers/WorkerError/WorkerUnknownError")({_tag:He("WorkerUnknownError"),message:z,cause:lr(er())}){},wR=Pe([bR,ER,IR,TR]),BW=class extends Cr(SR)({_tag:He("WorkerError"),reason:wR}){constructor(t){super({...t,cause:t.reason.cause})}[SR]=SR;get message(){return this.reason.message}};var lE=class extends Ue()("effect/workers/Worker/WorkerPlatform"){};var vR=(e,t)=>e===void 0?t:`${e}.${t}`,AR=(e,t)=>({"rpc.system.name":"effect_rpc","rpc.method":e,...t});var Od={};ps(Od,{ServerClient:()=>OR,custom:()=>Xie,exitSchema:()=>_R,fork:()=>rae,isRpc:()=>Qie,isWrapper:()=>Rd,make:()=>jW,uninterruptible:()=>nae,unwrap:()=>eae,wrap:()=>mE,wrapMap:()=>tae});var CR="~effect/rpc/RpcSchema/StreamSchema";function Bh(e){return O(e,CR)}function dE(e){return Bh(e)?N({success:e.success,error:e.error}):_()}var Zie=Ge(Ce);function $W(e,t){return J(Zie.ast,{[CR]:CR,success:e,error:t})}var RR="~effect/rpc/Rpc",Qie=e=>O(e,RR),OR=class{id;annotations;constructor(t){this.id=t,this.annotations=pt()}annotate(t,r){return this.annotations=We(this.annotations,t,r),this}},Yie={[RR]:RR,pipe(){return V(this,arguments)},setSuccess(e){return Rc({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:e,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},setError(e){return Rc({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:e,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},setPayload(e){return Rc({_tag:this._tag,payloadSchema:Zu(e)?e:Te(e),successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},middleware(e){return Rc({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:new Set([...this.middlewares,e])})},prefix(e){return Rc({_tag:`${e}${this._tag}`,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,annotations:this.annotations,middlewares:this.middlewares})},annotate(e,t){return Rc({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,middlewares:this.middlewares,annotations:We(this.annotations,e,t)})},annotateMerge(e){return Rc({_tag:this._tag,payloadSchema:this.payloadSchema,successSchema:this.successSchema,errorSchema:this.errorSchema,defectSchema:this.defectSchema,middlewares:this.middlewares,annotations:Kr(this.annotations,e)})}},Rc=e=>{function t(){}return Object.setPrototypeOf(t,Yie),Object.assign(t,e),t.key=`effect/rpc/Rpc/${e._tag}`,t},jW=(e,t)=>{let r=t?.success??pd,n=t?.error??Mi,o=t?.defect??er(),s;return t?.primaryKey?s=class extends YS(`effect/rpc/Rpc/${e}`)(t.payload){[Dz](){return t.primaryKey(this)}}:s=Zu(t?.payload)?t?.payload:t?.payload?Te(t?.payload):pd,Rc({_tag:e,payloadSchema:s,successSchema:t?.stream?$W(r,n):r,errorSchema:t?.stream?Mi:n,defectSchema:o,annotations:pt(),middlewares:new Set})},Xie=e=>(t,r)=>{let n=r?.success??pd,o=r?.error??Mi,s=r?.defect??er(),i=e({success:n,error:o,defect:s});return jW(t,{...i,primaryKey:r?.primaryKey,payload:r?.payload,stream:r?.stream})},kR=new WeakMap,_R=e=>{if(kR.has(e))return kR.get(e);let t=e,r=new Set([t.errorSchema]),n=dE(t.successSchema);de(n)&&r.add(n.value.error);for(let s of t.middlewares)r.add(s.error);let o=bC(de(n)?pd:t.successSchema,Pe([...r]),t.defectSchema);return kR.set(e,o),o},$h="~effect/rpc/Rpc/Wrapper",Rd=e=>$h in e,mE=e=>t=>Rd(t)?{[$h]:$h,value:t.value,fork:e.fork??t.fork,uninterruptible:e.uninterruptible??t.uninterruptible}:{[$h]:$h,value:t,fork:e.fork??!1,uninterruptible:e.uninterruptible??!1},eae=e=>Rd(e)?e.value:e,tae=(e,t)=>Rd(e)?mE(e)(t(e.value)):t(e),rae=mE({fork:!0}),nae=mE({uninterruptible:!0});var PR="~effect/rpc/RpcClientError",Oc=class extends Cr("effect/rpc/RpcClientError/RpcClientDefect")({_tag:He("RpcClientDefect"),message:z,cause:er()}){},Zs=class extends Cr(PR)({_tag:He("RpcClientError"),reason:Pe([wR,aR,wd,Oc])}){[PR]=PR;get message(){return`${this.reason._tag}: ${this.reason.message}`}};var MR=e=>e;var HW={_tag:"Ping"};var jh=Pe([z,Qu]),sae=Te({_tag:He("Request"),id:jh,tag:z,payload:qs,headers:ct(rs([z,z])),isNotification:lr(fr(!0)),traceId:lr(z),spanId:lr(z),sampled:lr(Fi)}),FR=Pe([sae,Te({_tag:He("Ack"),requestId:jh}),Te({_tag:He("Interrupt"),requestId:jh}),Te({_tag:He("Ping")}),Te({_tag:He("Eof")}),Te({_tag:He("Chunk"),requestId:jh,values:qs}),Te({_tag:He("Exit"),requestId:jh,exit:qs}),Te({_tag:He("Defect"),defect:qs}),Te({_tag:He("Pong")})]);var NR=e=>{switch(e._tag){case"Exit":case"Defect":case"ClientProtocolError":return!0;default:return!1}};var Yh={};ps(Yh,{MaxBufferSizeExceeded:()=>ME,RpcSerialization:()=>fn,json:()=>s6,jsonRpc:()=>a6,layerJson:()=>Qce,layerJsonRpc:()=>eue,layerNdJsonRpc:()=>tue,layerNdjson:()=>Yce,layerNdjsonWith:()=>Xce,layerSchemaBinary:()=>rue,makeNdjson:()=>NE,ndJsonRpc:()=>c6,ndjson:()=>i6});var iae=new WeakMap,aae=new WeakMap,cae=new WeakMap,uae=new WeakMap;function u4(e,t){let r=t?.fingerprint===!0?aae:iae,n=r.get(e);if(n!==void 0)return n;let{exact:o,layout:s,recursive:i,target:a}=Md(e),c=Ef(s,t?.fingerprint),u=o?{value:void 0}:void 0,f=DR(u===void 0?a:Bce(a,u,!i),s,c,u);return r.set(e,f),f}function JR(e,t){let r=t?.fingerprint===!0?uae:cae,n=r.get(e);if(n!==void 0)return n;let{exact:o,exitSuccess:s,layout:i,target:a}=Md(e);if(!o){if(!s)return u4(e,t);let u={value:void 0},f=DR(jce(a,u),i,Ef(i,t?.fingerprint),u,!0);return r.set(e,f),f}let c=DR(Hce(a),i,Ef(i,t?.fingerprint),void 0);return r.set(e,c),c}function DR(e,t,r,n,o=!1){return qs.pipe(ee(e,Uce(t,r,n,o)))}function f4(e,t){let{exact:r,exitSuccess:n,layout:o}=Md(e),s=Ef(o,t?.fingerprint),i=t??nn;if(!r||i.onExcessProperty==="error"){let a=Ym(u4(e,t),t);return!n||i.onExcessProperty==="error"?a:c=>{if(!PE(c))return a(c);try{return CE(o,c,i,s)}catch(u){throw u instanceof ji?new $n(u.issue):u}}}return a=>{try{return CE(o,a,i,s)}catch(c){throw c instanceof ji?new $n(c.issue):c}}}function fae(e,t){let{exact:r,layout:n}=Md(e),o=t??nn;if(!r||o.onExcessProperty==="error"){let i=f4(e,t);return a=>lae(a.map(i))}let s=Ef(n,t?.fingerprint);return i=>{try{return q4(n,i,o,s)}catch(a){throw a instanceof ji?new $n(a.issue):a}}}function lae(e){if(e.length===1)return e[0];let t=0;for(let o of e)t+=o.length;let r=new Uint8Array(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}function l4(e,t){let{exact:r,exitSuccess:n,layout:o,target:s}=Md(e),i=t??nn,a=r?void 0:jS(s,i),c=a!==void 0&&n?u=>PE(u)?u:a(u):a;return dae(o,Ef(o,t?.fingerprint),i,t?.maxFrameSize,c,d4(r,t))}function d4(e,t){if(t?.dictionary!==!0)return!1;if(!e)throw new Error("Binary layout: dictionary needs a schema the binary layer validates on its own");return!0}function p4(e,t){let{exact:r,layout:n,target:o}=Md(e),s=d4(r,t),i=f4(e,t),a=fae(e,t);if(!s)return{encode:i,encodeMany:a};let c=Ef(n,t?.fingerprint),u=t??nn,f=u.onExcessProperty==="error"?Ym(o,t):void 0,p=ace(),m=h=>{try{return h()}catch(x){throw x instanceof ji?new $n(x.issue):x}};return{encode:h=>m(()=>CE(n,f===void 0?h:f(h),u,c,p)),encodeMany:h=>m(()=>q4(n,f===void 0?h:h.map(f),u,c,p))}}function dae(e,t,r,n,o,s){let i=s?[]:void 0,a=new Uint8Array(0),c=0,u=0,f,p=!1,m=new zh,h=new qh(r,Mae),x=()=>{m.release(),h.clear(),a=HR,c=u=0},g=(v,T)=>{throw new $n(new le({expected:v},T,r))},y=()=>{let v=f;throw f=void 0,v},E=(v,T)=>{let S=v.length-T;S>a.length&&(a=new Uint8Array(Math.max(256,S))),a.set(T===0?v:v.subarray(T),0),c=0,u=S},b={feedSync(v){if(f!==void 0)return y();if(p)return g("parser is spent");let T=u===c,S,w,k;if(T)S=v,w=0,k=v.length;else{if(v.length>0){let $=u-c,te=$+v.length;if(te>a.length){let xe=new Uint8Array(Math.max(256,a.length*2,te));xe.set(a.subarray(c,u)),a=xe,c=0,u=$}else c>0&&(a.copyWithin(0,c,u),c=0,u=$);a.set(v,u),u+=v.length}S=a,w=c,k=u}let A=[],R=()=>(T?w<k&&E(v,w):(c=w,c===u&&(c=u=0)),A),M=($,te)=>{p=!0;let xe=new $n(new le({expected:$},te,r));if(x(),A.length===0)throw xe;return f=xe,A};for(;;){let $=0,te=-1,xe=k-w,Le=1;for(let Ee=0;Ee<Math.min(6,xe);Ee++){let Oe=S[w+Ee];if($+=(Oe&127)*Le,(Oe&128)===0){te=Ee+1;break}Le*=128}if(te===-1){if(xe<6)return R();let Ee=BigInt($);for(let Oe=6;Oe<Math.min(10,xe);Oe++){let rr=S[w+Oe];if(Ee|=BigInt(rr&127)<<BigInt(Oe*7),(rr&128)===0){if(te=Oe+1,Ee>LR)return M("safe integer length",Ee);$=Number(Ee);break}}if(te===-1)return xe>=10?M("uvarint",S.subarray(w,w+10)):R()}if($===0)return M("nonzero frame length",$);if(n!==void 0&&$>n)return M("frame within maxFrameSize",$);if(te+$>xe)return R();let Er=Q;try{Q=0;let Ee=w+te;h.beginFrame(),m.reset(S,Ee,Ee+$,r,h,t.positional,i);let Oe=Y4(e,m,t);A.push(o===void 0?Oe:o(Oe))}catch(Ee){p=!0,x();let Oe=Ee instanceof ji?new $n(Ee.issue):fd(Ee)?Ee:(()=>{throw Ee})();if(A.length===0)throw Oe;return f=Oe,A}finally{Q=Er}w+=te+$}},endSync(){if(f!==void 0)return y();if(p)return g("parser is spent");p=!0;let v=c<u?a.subarray(c,u):void 0;if(x(),v!==void 0)return g("complete value",v)},feed:v=>L(()=>{try{return I(b.feedSync(v))}catch(T){if(fd(T))return D(T);throw T}}),end:L(()=>{try{return b.endSync(),P}catch(v){if(fd(v))return D(v);throw v}})};return b}var pae="~effect/encoding/SchemaBinary/fieldId",mae=32,hae=33,LR=BigInt(Number.MAX_SAFE_INTEGER),EE=BigInt(0),ls=BigInt(1),xae=BigInt(2),m4=BigInt(7),zW=BigInt(127),gae=BigInt(1e6),yae=BigInt(255),WW=BigInt(4294967295),Sae=BigInt(32),$i=new TextEncoder,bae=new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0}),h4=7,KW=0xffffffffffff,Eae=0xfffffffffffff,x4=0,g4=1,y4=2,VW=512,Iae=1048576,Tae=4194304,If=0,bf=1,Vh=2,Gh=3,Jh=4,Zh=5,wae=6,vae=7,ds=8;function ZR(e){return typeof e=="number"&&Number.isInteger(e)&&e>=-KW&&e<=KW}var kE=8,BR=2199023255551,Pc=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8];function QR(e){for(let t=1;t<=kE;t++){let r=Math.round(e*Pc[t]);if(!(r>=-BR&&r<=BR))return 0;if(r/Pc[t]===e)return t}return 0}function S4(e){let t=Math.floor(e/2);return e%2===1?-t:t}var dt={bool:1,null:2,undefined:3,number:4,string:5,bytes:6,bigint:7,int64:8,struct:9,variant:10,array:11,option:12,result:13,duration:14,bigDecimal:15,dateTimeZoned:16,json:17,exit:18,cause:19,causeReason:20};function b4(e){let t=2166136261;for(let r=0;r<e.length;r++)t=Math.imul(t^e[r],16777619);return t>>>0}var Aae=BigInt("14695981039346656037"),Cae=BigInt("1099511628211"),kae=BigInt("18446744073709551615");function GW(e){let t=Aae;for(let r=0;r<e.length;r++)t=(t^BigInt(e[r]))*Cae&kae;return t}function IE(e,t){for(let r=0;r<t.length;r++)e.push(t[r])}function _c(e,t){for(;t>127;)e.push(t&127|128),t=Math.floor(t/128);e.push(t)}function TE(e,t){e.push(t&255,t>>>8&255,t>>>16&255,t>>>24&255)}function No(e,t){for(let r=0;r<8;r++)e.push(Number(t>>BigInt(r*8)&yae))}function E4(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)if(e[n]!==t[n])return e[n]-t[n];return e.length-t.length}var ji=class extends Error{issue;constructor(t){super("SchemaBinary failure"),this.issue=t}};function j(e,t,r){throw dr(new le({expected:e},t,r))}var Ze=[],Q=0;function dr(e){return new ji(Q===0?e:new Ct(Ze.slice(0,Q),e))}function Rae(e){let t=new Uint8Array(I4(e)),r=0;for(;e>127;)t[r++]=e&127|128,e=Math.floor(e/128);return t[r]=e,t}function I4(e){let t=1;for(;e>127;)e=Math.floor(e/128),t++;return t}var Oae=32;function _ae(e,t,r,n){let o=r-t;if(o===0)return"";if(o<=Oae){let s=Pae(e,t,r);if(s!==void 0)return s}try{return bae.decode(e.subarray(t,r))}catch{j("utf-8",void 0,n)}}function Pae(e,t,r){let n="",o=t;for(;o+16<=r;o+=16){let s=e[o],i=e[o+1],a=e[o+2],c=e[o+3],u=e[o+4],f=e[o+5],p=e[o+6],m=e[o+7],h=e[o+8],x=e[o+9],g=e[o+10],y=e[o+11],E=e[o+12],b=e[o+13],v=e[o+14],T=e[o+15];if((s|i|a|c|u|f|p|m|h|x|g|y|E|b|v|T)>127)return;n+=String.fromCharCode(s,i,a,c,u,f,p,m,h,x,g,y,E,b,v,T)}if(o+8<=r){let s=e[o],i=e[o+1],a=e[o+2],c=e[o+3],u=e[o+4],f=e[o+5],p=e[o+6],m=e[o+7];if((s|i|a|c|u|f|p|m)>127)return;n+=String.fromCharCode(s,i,a,c,u,f,p,m),o+=8}switch(r-o){case 0:return n;case 1:{let s=e[o];return s>127?void 0:n+String.fromCharCode(s)}case 2:{let s=e[o],i=e[o+1];return(s|i)>127?void 0:n+String.fromCharCode(s,i)}case 3:{let s=e[o],i=e[o+1],a=e[o+2];return(s|i|a)>127?void 0:n+String.fromCharCode(s,i,a)}case 4:{let s=e[o],i=e[o+1],a=e[o+2],c=e[o+3];return(s|i|a|c)>127?void 0:n+String.fromCharCode(s,i,a,c)}case 5:{let s=e[o],i=e[o+1],a=e[o+2],c=e[o+3],u=e[o+4];return(s|i|a|c|u)>127?void 0:n+String.fromCharCode(s,i,a,c,u)}case 6:{let s=e[o],i=e[o+1],a=e[o+2],c=e[o+3],u=e[o+4],f=e[o+5];return(s|i|a|c|u|f)>127?void 0:n+String.fromCharCode(s,i,a,c,u,f)}default:{let s=e[o],i=e[o+1],a=e[o+2],c=e[o+3],u=e[o+4],f=e[o+5],p=e[o+6];return(s|i|a|c|u|f|p)>127?void 0:n+String.fromCharCode(s,i,a,c,u,f,p)}}}var $R=64*1024,Mae=256,Fae=512,Nae=16*1024;function jR(e){let t=new Uint8Array(e);return{buf:t,view:new DataView(t.buffer),offset:0,writing:!1}}var Hh=jR($R),wE=class{buf=new Uint8Array(0);view=new DataView(this.buf.buffer);arena;start=0;limit=0;len=0;reset(){let t=Hh;(t.writing||t.offset>=t.buf.length)&&(t=Hh=jR($R)),t.writing=!0,this.arena=t,this.buf=t.buf,this.view=t.view,this.start=t.offset,this.limit=t.buf.length-t.offset,this.len=0}ensure(t){if(this.len+t>this.limit){let r=this.arena,n=this.len+t,o=$R;for(;o<n;)o*=2;let s=jR(o);s.writing=!0,s.buf.set(this.buf.subarray(this.start,this.start+this.len)),r.writing=!1,this.arena=Hh=s,this.buf=s.buf,this.view=s.view,this.start=0,this.limit=s.buf.length}}byte(t){this.ensure(1),this.buf[this.start+this.len++]=t}bytes(t){this.ensure(t.length),this.buf.set(t,this.start+this.len),this.len+=t.length}uvarint(t){this.ensure(10);let r=this.buf,n=this.start+this.len;if(t<128)r[n++]=t;else if(r[n++]=t&127|128,t<16384)r[n++]=t>>>7;else{for(r[n++]=t>>>7&127|128,t=Math.floor(t/16384);t>127;)r[n++]=t&127|128,t=Math.floor(t/128);r[n++]=t}this.len=n-this.start}uvarintBig(t){for(;t>zW;)this.byte(Number(t&zW)|128),t>>=m4;this.byte(Number(t))}zigzag(t){this.uvarintBig(t>=EE?t<<ls:(-t<<ls)-ls)}numberVarint(t){let r=t<0||t===0&&1/t<0,n=r?-t:t;n<=Eae?this.uvarint(n*2+(r?1:0)):this.uvarintBig(BigInt(n)*xae+(r?ls:EE))}f64(t){this.ensure(8),this.view.setFloat64(this.start+this.len,t,!0),this.len+=8}i64(t){this.ensure(8),this.view.setBigInt64(this.start+this.len,t,!0),this.len+=8}u32le(t){this.ensure(4),this.view.setUint32(this.start+this.len,t>>>0,!0),this.len+=4}i32le(t){this.ensure(4),this.view.setInt32(this.start+this.len,t|0,!0),this.len+=4}idAndMark(t){let r=t.length;this.ensure(r+1);let n=this.buf,o=this.start+this.len;for(let i=0;i<r;i++)n[o++]=t[i];let s=o-this.start;return this.len=s+1,s}beginSized(){return this.ensure(1),this.len++}endSized(t){let r=this.len-t-1;r<128?this.buf[this.start+t]=r:this.growSized(t,r)}endSizedRun(t){let r=(this.len-t-1)*2;r<128?this.buf[this.start+t]=r:this.growSized(t,r)}growSized(t,r){let n=I4(r),o=n-1;this.ensure(o);let s=this.start+t;this.buf.copyWithin(s+n,s+1,this.start+this.len),this.len+=o;let i=r,a=s;for(;i>127;)this.buf[a++]=i&127|128,i=Math.floor(i/128);this.buf[a]=i}string(t){let r=t.length;if(r===0)return;this.ensure(r*3);let n=this.buf,o=this.start+this.len,s=0;for(;s+4<=r;s+=4){let i=t.charCodeAt(s),a=t.charCodeAt(s+1),c=t.charCodeAt(s+2),u=t.charCodeAt(s+3);if((i|a|c|u)>127){this.len+=$i.encodeInto(t,n.subarray(this.start+this.len)).written;return}n[o++]=i,n[o++]=a,n[o++]=c,n[o++]=u}for(;s<r;s++){let i=t.charCodeAt(s);if(i>127){this.len+=$i.encodeInto(t,n.subarray(this.start+this.len)).written;return}n[o++]=i}this.len=o-this.start}out(){let t=this.arena,r=new Uint8Array(t.buf.buffer,this.start,this.len);return t===Hh&&(t.offset=this.start+this.len),t.writing=!1,this.arena=void 0,r}abort(){let t=this.arena;t!==void 0&&(t===Hh&&(t.offset=this.start),t.writing=!1,this.arena=void 0)}};function Uae(e){let t=Bn(e);return t._tag==="String"&&t.checks===void 0}function Dae(e,t,r){return e.extra.find(n=>_i({[t]:null},n.parameter,r).length>0)}var qh=class{entries=new WeakMap;orderLayouts;orderKeys;options;size=0;next=0;replace=!1;constructor(t,r){this.options=t,this.orderLayouts=r===void 0?void 0:new Array(r),this.orderKeys=r===void 0?void 0:new Array(r)}beginFrame(){this.replace=!0}find(t,r){let n=this.entries.get(t);if(n===void 0&&(n=new Map,this.entries.set(t,n)),n.has(r))return n.get(r);let o=Dae(t,r,this.options),s=this.orderLayouts;if(s===void 0)return n.set(r,o),o;let i=this.orderKeys;if(this.size<s.length)s[this.size]=t,i[this.size]=r,this.size++,n.set(r,o);else if(this.replace){this.replace=!1;let a=s[this.next];(a===t?n:this.entries.get(a))?.delete(i[this.next]),s[this.next]=t,i[this.next]=r,this.next=(this.next+1)%s.length,n.set(r,o)}return o}clear(){this.entries=new WeakMap,this.orderLayouts?.fill(void 0),this.orderKeys?.fill(void 0),this.size=this.next=0,this.replace=!1}},vE=new ArrayBuffer(0),HR=new Uint8Array(vE),JW=new DataView(vE),zh=class{pos=0;nesting=0;buf=HR;view;viewCache=JW;viewBuffer=vE;viewOffset=0;viewLength=0;end=0;options=nn;indexSignatures;positional=!1;intern;dict;reset(t,r,n,o,s,i,a){this.nesting=0,this.view=void 0,this.buf=t,this.pos=r,this.end=n,this.options=o,this.indexSignatures=s,this.positional=i,this.intern=void 0,this.dict=a}release(){this.pos=this.end=this.nesting=0,this.buf=HR,this.view=void 0,this.viewCache=JW,this.viewBuffer=vE,this.viewOffset=this.viewLength=0,this.options=nn,this.indexSignatures=void 0,this.positional=!1,this.intern=void 0,this.dict=void 0}get remaining(){return this.end-this.pos}dataView(){let t=this.buf;return(t.buffer!==this.viewBuffer||t.byteOffset!==this.viewOffset||t.byteLength!==this.viewLength)&&(this.viewBuffer=t.buffer,this.viewOffset=t.byteOffset,this.viewLength=t.byteLength,this.viewCache=new DataView(t.buffer,t.byteOffset,t.byteLength)),this.view=this.viewCache}byte(){return this.pos>=this.end&&j("complete value",void 0,this.options),this.buf[this.pos++]}take(t){this.pos+t>this.end&&j("complete value",void 0,this.options);let r=this.buf.subarray(this.pos,this.pos+t);return this.pos+=t,r}takeCopy(t){this.pos+t>this.end&&j("complete value",void 0,this.options);let r=this.buf.slice(this.pos,this.pos+t);return this.pos+=t,r}enter(t){this.pos+t>this.end&&j("complete value",void 0,this.options);let r=this.end;return this.end=this.pos+t,r}exit(t){this.pos=this.end,this.end=t}readUtf8(t){this.pos+t>this.end&&j("complete value",void 0,this.options);let r=this.pos;return this.pos+=t,_ae(this.buf,r,r+t,this.options)}uvarint(){let t=this.buf,r=this.end,n=this.pos;n>=r&&j("complete value",void 0,this.options);let o=t[n++];if(o<128)return this.pos=n,o;let s=o&127;if(n>=r&&j("complete value",void 0,this.options),o=t[n++],s|=(o&127)<<7,o<128)return this.pos=n,s;if(n>=r&&j("complete value",void 0,this.options),o=t[n++],s|=(o&127)<<14,o<128)return this.pos=n,s;if(n>=r&&j("complete value",void 0,this.options),o=t[n++],s|=(o&127)<<21,o<128)return this.pos=n,s;let i=268435456;for(let a=4;a<10;a++){n>=r&&(this.pos=n,j("complete value",void 0,this.options)),o=t[n++];let c=(o&127)*i;if(c>Number.MAX_SAFE_INTEGER-s&&(this.pos=n,j("safe integer length",void 0,this.options)),s+=c,o<128)return this.pos=n,s;i*=128}this.pos=n,j("uvarint",void 0,this.options)}fieldTag(){let t=this.buf,r=this.end,n=this.pos;n>=r&&j("complete value",void 0,this.options);let o=t[n++];if(o<128)return this.pos=n,o;let s=o&127;return n>=r&&j("complete value",void 0,this.options),o=t[n++],s|=(o&127)<<7,o<128?(this.pos=n,s):(n>=r&&j("complete value",void 0,this.options),o=t[n++],s|=(o&127)<<14,o<128?(this.pos=n,s):(n>=r&&j("complete value",void 0,this.options),o=t[n++],s|=(o&127)<<21,o<128?(this.pos=n,s):(n>=r&&j("complete value",void 0,this.options),o=t[n++],this.pos=n,o>=128&&j("uvarint",void 0,this.options),s+o*268435456)))}uvarintBig(){let t=EE,r=EE;for(;;){let n=this.byte();if(t|=BigInt(n&127)<<r,(n&128)===0)return t;r+=m4}}numberVarint(){let t=this.buf,r=this.end,n=this.pos,o=0,s=1;for(let c=0;c<h4;c++){n>=r&&(this.pos=n,j("complete value",void 0,this.options));let u=t[n++];if(o+=(u&127)*s,u<128)return this.pos=n,S4(o);s*=128}let i=this.uvarintBig(),a=Number(i>>ls);return Number.isFinite(a)||j("safe integer length",void 0,this.options),(i&ls)===ls?-a:a}zigzag(){let t=this.uvarintBig();return(t&ls)===ls?-(t+ls>>ls):t>>ls}f64(){this.pos+8>this.end&&j("complete value",void 0,this.options);let t=(this.view??this.dataView()).getFloat64(this.pos,!0);return this.pos+=8,t}i64(){this.pos+8>this.end&&j("complete value",void 0,this.options);let t=(this.view??this.dataView()).getBigInt64(this.pos,!0);return this.pos+=8,t}u32le(){this.pos+4>this.end&&j("complete value",void 0,this.options);let t=(this.view??this.dataView()).getUint32(this.pos,!0);return this.pos+=4,t}i32le(){this.pos+4>this.end&&j("complete value",void 0,this.options);let t=(this.view??this.dataView()).getInt32(this.pos,!0);return this.pos+=4,t}};function ZW(e,t){return{_:"literal",leaf:e,values:t,valueSet:t.length>4?new Set(t):void 0}}function Qh(e,t){let r=e.values;return e.valueSet!==void 0?e.valueSet.has(t):r.length===1?t===r[0]:r.includes(t)}function RE(e){return e.values.map(t=>typeof t=="string"?JSON.stringify(t):String(t)).join(" | ")}var gE=0,YR=1,T4=2,w4=3,v4=30,yE=1<<v4;function OE(e){return e._==="literal"?OE(e.leaf):e._==="int"}function _E(e){switch(e._){case"literal":return _E(e.leaf);case"bool":return 1;case"int64":return 8;default:return}}function qR(e){return _E(e)!==void 0||OE(e)||e._==="null"||e._==="undefined"}function A4(e){return e._==="literal"?A4(e.leaf):e._==="null"||e._==="undefined"}var Wh={"effect/schema/Date":{kind:dt.int64,exact:!0},"effect/schema/DateTimeUtc":{kind:dt.int64,exact:!0},"effect/schema/DateTimeZoned":{kind:dt.dateTimeZoned,exact:!0},"effect/schema/Duration":{kind:dt.duration,exact:!0},"effect/schema/BigDecimal":{kind:dt.bigDecimal,exact:!0},"effect/schema/Uint8Array":{kind:dt.bytes,exact:!0},"effect/schema/Option":{kind:dt.option,exact:"parameters"},"effect/schema/Result":{kind:dt.result,exact:"parameters"},"effect/schema/Exit":{kind:dt.exit,exact:"parameters"},"effect/schema/Cause":{kind:dt.cause,exact:"parameters"},"effect/schema/CauseReason":{kind:dt.causeReason,exact:"parameters"}};function Pd(e){let t=e.annotations?.representation;return Jt(t)&&typeof t.id=="string"?t.id:void 0}var SE=ma(e=>{let t=Lae(e),r=e.context;return t===e||r===void 0?t:zl(t,new Yo(r.isOptional,r.isMutable,void 0,r.annotations))});function Lae(e){switch(e._tag){case"Declaration":{let t=Pd(e);if(t!==void 0&&(t in Wh||t==="effect/schema/Json"||t==="effect/schema/MutableJson"))return e.recur(SE);let r=e.annotations?.toCodecJson,n=e.annotations?.toCodec;if(!or(r)&&!or(n))return e;let o=e.typeParameters.map(i=>J(Bn(i))),s=(or(r)?r(o):void 0)??(or(n)?n(o):void 0);return s===void 0?e:lt(e,[lc(s,SE)])}case"Arrays":case"Objects":case"Union":case"Suspend":return e.recur(SE);default:return e}}function Bae(e){let t=[...e].sort((n,o)=>{let s=typeof n.key=="number",i=typeof o.key=="number";return s!==i?s?-1:1:s?n.key-o.key:E4($i.encode(n.key),$i.encode(o.key))}),r=[];for(let n of t){let o=$i.encode(String(n.key));r.push(typeof n.key=="number"?0:1),TE(r,o.length),IE(r,o);let s=n.literal,i=$i.encode(k4(s));r.push(C4(s)),TE(r,i.length),IE(r,i)}return b4(r)}function C4(e){switch(typeof e){case"string":return 1;case"number":return 2;case"boolean":return 3;case"bigint":return 4;default:return 5}}function k4(e){if(typeof e=="symbol"){let t=globalThis.Symbol.keyFor(e);if(t===void 0)throw new Error("Binary layout: unregistered unique symbol (Symbol.keyFor)");return t}return String(e)}function R4(e){switch(e._tag){case"Symbol":return!0;case"Union":return e.types.some(R4);default:return!1}}function O4(e){let t=Pd(e);return t==="effect/schema/Json"||t==="effect/schema/MutableJson"?!0:or(e.annotations?.toCodecJson)}function $ae(e){let t=e.checks;if(t===void 0)return!1;let r=n=>n.annotations?.representation?.id==="effect/schema/isInt"?!0:n._tag==="FilterGroup"&&n.checks.some(r);return t.some(r)}function _4(e){for(;e._tag==="Suspend";)e=e.thunk();return e}function P4(e){return new Sn(e.enums.map(t=>new Ln(t[1],{title:t[0]})))}function QW(e){let t=[],r=new Set,n=o=>{let s=_4(o);if(!r.has(s))switch(r.add(s),s._tag){case"Never":return;case"Union":s.types.forEach(n);return;case"Enum":P4(s).types.forEach(n);return;default:t.push(s)}};return e.types.forEach(n),t}function YW(e){switch(typeof e){case"string":return"string";case"number":return"number";case"boolean":return"bool";default:return"bigint"}}function bE(e){switch(e._tag){case"String":case"TemplateLiteral":case"Symbol":return dt.string;case"UniqueSymbol":if(globalThis.Symbol.keyFor(e.symbol)===void 0)throw new Error("Binary layout: unregistered unique symbol (Symbol.keyFor)");return dt.string;case"Boolean":return dt.bool;case"Null":return dt.null;case"Undefined":case"Void":return dt.undefined;case"Number":return dt.number;case"BigInt":return dt.bigint;case"Literal":switch(typeof e.literal){case"string":return dt.string;case"number":return dt.number;case"boolean":return dt.bool;default:return dt.bigint}case"Unknown":case"Any":case"ObjectKeyword":return dt.json;case"Objects":return dt.struct;case"Arrays":return dt.array;case"Declaration":{let t=Pd(e);if(t!==void 0&&t in Wh)return Wh[t].kind;if(O4(e))return dt.json;throw new Error(`Binary layout: declaration ${t??"<anonymous>"} has no toCodecJson or toCodec`)}case"Suspend":return bE(_4(e));default:throw new Error("Binary layout: union members are not uniquely identifiable")}}function XW(e){for(let t of e.fields)t.optional||(t.index<32?e.requiredMask|=1<<t.index:e.requiredWide=!0)}function jae(e){let t=M4(e),r=!t&&Hae(e);e=Bn(e);let n=new Map,o=!1,s=0,i=x=>({_:x,slot:x==="string"?s++:0});function a(x){let g=n.get(x);if(g!==void 0)return g;let y=c(x);return n.set(x,y),y}function c(x){switch(x._tag){case"String":case"TemplateLiteral":return i("string");case"Symbol":case"UniqueSymbol":return i("symbol");case"Boolean":return i("bool");case"Null":return i("null");case"Undefined":case"Void":return i("undefined");case"Number":return i($ae(x)?"int":"number");case"BigInt":return i("bigint");case"Literal":return ZW(i(YW(x.literal)),[x.literal]);case"Unknown":case"Any":case"ObjectKeyword":return i("json");case"Never":return{_:"never",ast:x};case"Enum":return m(x,QW(P4(x)));case"Suspend":{o=!0;let g=a(x.thunk());return n.set(x,g),g}case"Objects":return u(x);case"Arrays":return f(x);case"Union":return m(x,QW(x));case"Declaration":return p(x)}}function u(x){let g=[],y=[],E=new Map;for(let T of x.propertySignatures){if(typeof T.name=="symbol")throw new Error("Binary layout: symbol property names are illegal");let S=String(T.name),w=T.type.context?.annotations,k=w?.[pae],A=typeof k=="number"?k:b4($i.encode(S));if(!Number.isInteger(A)||A<0||A>4294967295)throw new Error(`Binary layout: illegal field id for ${S}`);let R=E.get(A);R===void 0?E.set(A,[S]):R.push(S),g.push({name:S,id:A,tagBytes:Rae(A*ds+If),index:0,optional:T.type.context?.isOptional===!0,annotations:w,layout:void 0,wireMask:0,inline:!1}),y.push(T.type)}for(let[T,S]of E)if(T===0||S.length>1)throw new Error(`Binary layout field id collision: ${T} (${S.join(", ")})`);let b=[];for(let T of x.indexSignatures){if(R4(T.parameter))throw new Error("Binary layout: symbol property names are illegal");b.push({parameter:T.parameter,layout:void 0,wireMask:0})}let v={_:"struct",ast:x,fields:g,byId:new Map,extra:b,extraAll:b.length===1&&Uae(b[0].parameter)?b[0]:void 0,names:new Set(g.map(T=>T.name)),extraShape:void 0,optionalCount:0,requiredMask:0,requiredWide:!1};n.set(x,v);for(let T=0;T<g.length;T++){let S=g[T];S.layout=a(y[T]),S.wireMask=VR(S.layout),S.inline=qR(S.layout),S.optional&&v.optionalCount++,v.byId.set(S.id,S)}g.sort((T,S)=>T.id-S.id);for(let T=0;T<g.length;T++)g[T].index=T;XW(v);for(let T=0;T<b.length;T++)b[T].layout=a(x.indexSignatures[T].type),b[T].wireMask=VR(b[T].layout);return v}function f(x){let g=x.rest.length>0||x.elements.some(v=>v.context?.isOptional===!0),y=x.elements.filter(v=>v.context?.isOptional!==!0).length,E=Math.max(0,x.rest.length-1),b={_:"array",ast:x,elements:[],rest:[],hasCount:g,minCount:y+E,uniform:void 0,uniformInline:!1,uniformPacked:void 0,uniformNumbers:!1,run:void 0};n.set(x,b);for(let v of x.elements)b.elements.push({optional:v.context?.isOptional===!0,layout:a(v)});for(let v of x.rest)b.rest.push(a(v));if(b.elements.length===0&&b.rest.length===1){let v=b.rest[0];b.uniform=v,b.uniformPacked=_E(v),b.uniformNumbers=v._==="number",b.uniformInline=qR(v)}return b}function p(x){let g=Pd(x);switch(g){case"effect/schema/Date":return{_:"int64",flavor:"date"};case"effect/schema/DateTimeUtc":return{_:"int64",flavor:"utc"};case"effect/schema/DateTimeZoned":return i("dateTimeZoned");case"effect/schema/Duration":return i("duration");case"effect/schema/BigDecimal":return i("bigDecimal");case"effect/schema/Uint8Array":return i("bytes")}let y=x.typeParameters;switch(g){case"effect/schema/Option":{let E={_:"option",value:void 0};return n.set(x,E),E.value=a(y[0]),E}case"effect/schema/Result":{let E={_:"result",success:void 0,failure:void 0};return n.set(x,E),E.success=a(y[0]),E.failure=a(y[1]),E}case"effect/schema/Exit":{let E={_:"cause",error:void 0,defect:void 0},b={_:"exit",value:void 0,cause:E};return n.set(x,b),b.value=a(y[0]),E.error=a(y[1]),E.defect=a(y[2]),b}case"effect/schema/Cause":case"effect/schema/CauseReason":{let E={_:g==="effect/schema/Cause"?"cause":"causeReason",error:void 0,defect:void 0};return n.set(x,E),E.error=a(y[0]),E.defect=a(y[1]),E}}if(g!==void 0&&g in Wh)throw new Error(`Binary layout: native declaration ${g} has no layout constructor`);if(O4(x))return i("json");throw new Error(`Binary layout: declaration ${g??"<anonymous>"} has no toCodecJson or toCodec`)}function m(x,g){if(g.length===0)return{_:"never",ast:x};let y=[],E=[],b=new Map,v=new Map,T=(R,M)=>{let $=b.get(R);if($!==void 0&&$._!==M._)throw new Error("Binary layout: union members are not uniquely identifiable");b.set(R,M)};for(let R of g){if(R._tag==="Literal"){let M=bE(R),$=v.get(M);$===void 0?v.set(M,[R.literal]):$.includes(R.literal)||$.push(R.literal);continue}if(R._tag==="UniqueSymbol"){bE(R),T(dt.string,i("symbol"));continue}if(R._tag==="Objects"||R._tag==="Arrays"){let M=cc(R);if(M!==void 0&&M.length>0){for(let $ of M)if(typeof $.key=="symbol")throw new Error("Binary layout: symbol property names are illegal");y.push({member:R,sentinels:M});continue}}E.push({member:R,kind:bE(R)})}for(let[R,M]of v)T(R,ZW(i(YW(M[0])),M));if(y.length===0&&E.length===0&&b.size===1)return b.values().next().value;let S=new Set(b.keys());for(let{kind:R}of E){if(S.has(R))throw new Error("Binary layout: union members are not uniquely identifiable");S.add(R)}if(y.length===0&&b.size===0&&E.length===1){let R=a(E[0].member);return n.set(x,R),R}let w=new Map,k=[];for(let{sentinels:R}of y){let M=Bae(R);if(w.has(M))throw new Error(`Binary layout sentinel collision: ${M}`);w.set(M,R),k.push(M)}let A={_:"union",ast:x,variants:[],byTag:new Map,discriminator:void 0,others:[],byKind:new Map,byPos:[]};n.set(x,A);for(let R=0;R<y.length;R++){let{member:M,sentinels:$}=y[R],te=k[R],xe=a(M),Le,Er;if(M._tag==="Objects"){let Oe=xe,rr=new Set($.map(Rn=>String(Rn.key))),lo=Oe.fields.filter(Rn=>!rr.has(Rn.name)),Xs={_:"struct",ast:Oe.ast,fields:lo,byId:new Map(lo.map(Rn=>[Rn.id,Rn])),extra:Oe.extra,extraAll:Oe.extraAll,names:Oe.names,extraShape:void 0,optionalCount:lo.reduce((Rn,sI)=>sI.optional?Rn+1:Rn,0),requiredMask:0,requiredWide:!1};XW(Xs),Le=Xs,Er=!1}else Le=xe,Er=!0;let Ee={tag:te,sentinels:$,tuple:Er,payload:Le,position:0};A.variants.push(Ee),A.byTag.set(te,Ee)}for(let[R,M]of b)A.others.push({kind:R,layout:M,position:0}),A.byKind.set(R,M);for(let{kind:R,member:M}of E){let $=a(M);A.others.push({kind:R,layout:$,position:0}),A.byKind.set(R,$)}for(let R of[...A.variants].sort((M,$)=>M.tag-$.tag))R.position=A.byPos.length,A.byPos.push({variant:R,layout:R.payload});for(let R of[...A.others].sort((M,$)=>M.kind-$.kind))R.position=A.byPos.length,A.byPos.push({variant:void 0,layout:R.layout});return A.others.sort((R,M)=>e4(R.layout)-e4(M.layout)),A.discriminator=gce(A.variants),A}return{layout:a(e),recursive:o,exact:t,exitSuccess:r}}function M4(e){let t=new Map,r=n=>{if(n.encoding!==void 0||n.checks!==void 0||n.encodingChecks!==void 0)return!1;switch(n._tag){case"String":case"Symbol":case"Boolean":case"Null":case"Undefined":case"Void":case"Number":case"BigInt":case"Literal":return!0;case"Never":return!0;case"Unknown":case"Any":return!0;case"Arrays":return n.elements.every(r)&&n.rest.every(r);case"Objects":return n.propertySignatures.every(o=>r(o.type))&&n.indexSignatures.every(o=>o.parameter._tag==="String"&&r(o.parameter)&&r(o.type));case"Union":return(n.options?.mode??"anyOf")==="anyOf"&&n.types.every(r);case"Suspend":{let o=t.get(n);if(o!==void 0)return o;t.set(n,!0);let s=r(n.thunk());return t.set(n,s),s}case"Declaration":{let o=Pd(n),s=o!==void 0?Wh[o]:void 0;return s===void 0?!1:s.exact===!0||n.typeParameters.every(r)}default:return!1}};return r(e)}function Hae(e){return e._tag==="Declaration"&&e.encoding===void 0&&e.checks===void 0&&e.encodingChecks===void 0&&Pd(e)==="effect/schema/Exit"&&M4(e.typeParameters[0])}var uo={backEdge:0,bool:1,null:2,undefined:3,number:4,int:5,string:6,symbol:7,bytes:8,bigint:9,json:10,duration:11,bigDecimal:12,dateTimeZoned:13,date:14,dateTimeUtc:15,never:16,struct:17,array:18,union:19,option:20,result:21,exit:22,cause:23,causeReason:24,literal:25};function qae(e){let t=new Map,r=[],n=Number.MAX_SAFE_INTEGER;function o(i){let a=r.lastIndexOf(i);if(a>=0){a<n&&(n=a);let h=[uo.backEdge];return _c(h,r.length-a),GW(h)}let c=t.get(i);if(c!==void 0)return c;let u=r.length,f=n;n=Number.MAX_SAFE_INTEGER,r.push(i);let p=GW(s(i));r.pop();let m=n>=u;return m&&t.set(i,p),n=m?f:Math.min(f,n),p}function s(i){let a=[];switch(i._){case"bool":case"null":case"undefined":case"number":case"int":case"string":case"symbol":case"bytes":case"bigint":case"json":case"duration":case"bigDecimal":case"dateTimeZoned":return a.push(uo[i._]),a;case"literal":{a.push(uo.literal),IE(a,s(i.leaf)),_c(a,i.values.length);let c=i.values.map(u=>[C4(u),k4(u)]).sort((u,f)=>u[1]<f[1]?-1:u[1]>f[1]?1:u[0]-f[0]);for(let[u,f]of c){a.push(u);let p=$i.encode(f);_c(a,p.length),IE(a,p)}return a}case"int64":return a.push(i.flavor==="date"?uo.date:uo.dateTimeUtc),a;case"never":return a.push(uo.never),a;case"struct":{a.push(uo.struct),_c(a,i.fields.length);for(let c of i.fields)TE(a,c.id),a.push(c.optional?1:0),No(a,o(c.layout));_c(a,i.extra.length);for(let c of i.extra)No(a,o(c.layout));return a}case"array":{a.push(uo.array),_c(a,i.elements.length);for(let c of i.elements)a.push(c.optional?1:0),No(a,o(c.layout));_c(a,i.rest.length);for(let c of i.rest)No(a,o(c));return a}case"union":{a.push(uo.union),_c(a,i.byPos.length);for(let c of i.byPos){let u=c.variant;u===void 0?a.push(0):(a.push(1,u.tuple?1:0),TE(a,u.tag)),No(a,o(c.layout))}return a}case"option":return a.push(uo.option),No(a,o(i.value)),a;case"result":return a.push(uo.result),No(a,o(i.success)),No(a,o(i.failure)),a;case"exit":return a.push(uo.exit),No(a,o(i.value)),No(a,o(i.cause.error)),No(a,o(i.cause.defect)),a;case"cause":case"causeReason":return a.push(i._==="cause"?uo.cause:uo.causeReason),No(a,o(i.error)),No(a,o(i.defect)),a}}return o(e)}function zae(e,t){let r=new Uint8Array(8);for(let n=0;n<4;n++)r[n]=e>>>n*8&255,r[n+4]=t>>>n*8&255;return r}var Wae={positional:!1,envelope:mae,expectedEnvelope:"version 2 envelope, flags 0",fingerprint:new Uint8Array(8)};function Kae(e){let t=qae(e);return{positional:!0,envelope:hae,expectedEnvelope:"version 2 envelope, flags 1",fingerprint:zae(Number(t&WW),Number(t>>Sae&WW))}}function e4(e){switch(e._){case"json":return 2;case"struct":return 1;default:return 0}}function zR(e,t){switch(e._){case"literal":return Qh(e,t);case"bool":return typeof t=="boolean";case"null":return t===null;case"undefined":return t===void 0;case"number":case"int":return typeof t=="number";case"string":return typeof t=="string";case"symbol":return typeof t=="symbol";case"bigint":return typeof t=="bigint";case"bytes":return t instanceof Uint8Array;case"int64":return e.flavor==="date"?t instanceof Date:Au(t)&&t._tag==="Utc";case"dateTimeZoned":return Au(t)&&t._tag==="Zoned";case"duration":return Qi(t);case"bigDecimal":return wu(t);case"option":return ci(t);case"result":return $f(t);case"exit":return ws(t);case"cause":return il(t);case"causeReason":return al(t);case"array":return Array.isArray(t);case"struct":return Jt(t)&&!Array.isArray(t);case"json":return!0;case"union":case"never":return!1}}function ut(e,t,r){throw dr(new le({expected:e},t,r))}function kn(e,t=new Set){if(!$d(e))return!1;let r=Array.isArray(e),n=Object.getPrototypeOf(e);if(r||n===Object.prototype||n===null){if(t.has(e))return!0;t.add(e);try{if(r){for(let o=0;o<e.length;o++)if(kn(e[o],t))return!0}else for(let o of Object.keys(e))if(kn(e[o],t))return!0}finally{t.delete(e)}return!1}if(e instanceof Date||e instanceof Uint8Array||Au(e)||Qi(e)||wu(e))return!1;if(t.has(e))return!0;t.add(e);try{if(ci(e))return de(e)&&kn(e.value,t);if($f(e))return kn(tt(e)?e.success:e.failure,t);if(ws(e))return kn(ft(e)?e.value:e.cause,t);if(il(e))return e.reasons.some(o=>kn(o,t));if(al(e))switch(e._tag){case"Fail":return kn(e.error,t);case"Die":return kn(e.defect,t);case"Interrupt":return!1}if(Al(e)){for(let o of e)if(kn(o,t))return!0;return!1}if(Cy(e)){for(let[o,s]of e)if(kn(o,t)||kn(s,t))return!0;return!1}if(_y(e)){for(let o of e)if(kn(o,t))return!0;return!1}if(cm(e))return kn(oc(e),t);for(let o of Object.keys(e))if(kn(e[o],t))return!0}finally{t.delete(e)}return!1}function AE(e,t,r,n){let o=n.beginSized();zr(e,t,r,n),n.endSized(o)}function Vae(e,t,r){let n=globalThis.Symbol.keyFor(t);n===void 0&&ut("registered symbol",t,e.options),r.string(n)}function t4(e,t,r,n){let o=r;switch(o._tag){case"Fail":n.byte(0),zr(e,t.error,o.error,n);return;case"Die":n.byte(1),zr(e,t.defect,o.defect,n);return;case"Interrupt":o.fiberId===void 0?n.byte(2):(n.byte(3),n.f64(o.fiberId))}}function Gae(e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)>127)return!1;return!0}function r4(e,t,r){if(e.layout!==t||e.keys.length!==r.length)return!1;for(let n=0;n<r.length;n++)if(e.keys[n]!==r[n])return!1;return!0}function Jae(e,t){if(e.extraAll===void 0||t.length>Fae)return!1;let r=0;for(let n=0;n<t.length;n++)if(r+=t[n].length,r>Nae)return!1;return!0}function XR(e,t,r){let n=Object.keys(r),o=t.extraShape;if(o!==void 0&&r4(o,t,n))return o.pairs;let s=Jae(t,n),i=s?void 0:e.extraShape;if(i!==void 0&&r4(i,t,n))return i.pairs;let a=t.names,c=t.extraAll,u=[],f=!0;for(let m of n){if(a.has(m))continue;let h=c??(e.indexSignatures??=new qh(e.options)).find(t,m);h!==void 0&&(f&&!Gae(m)&&(f=!1),u.push([m,h,void 0]))}if(f)u.sort((m,h)=>m[0]<h[0]?-1:m[0]>h[0]?1:0);else{for(let m of u)m[2]=$i.encode(m[0]);u.sort((m,h)=>E4(m[2],h[2]))}if(s)for(let m of u)m[2]??=$i.encode(m[0]);let p={layout:t,keys:n,pairs:u};return s?t.extraShape=p:e.extraShape=p,u}function eO(e,t,r,n,o){for(let[s,i,a]of t){let c=a===void 0?s.length:a.length,u=r[s],f=tO(i.layout,u,e.options),p=f%ds;if(o===void 0)n.uvarint(c*ds+p);else{if(!o.disabled){let m=N4(o,s);if(m!==void 0){n.uvarint(m*16+p*2+1),Ze[Q++]=s,WR(e,i.layout,u,f,n),Q--;continue}U4(o,s)}n.uvarint(c*16+p*2)}a===void 0?n.string(s):n.bytes(a),Ze[Q++]=s,WR(e,i.layout,u,f,n),Q--}}function tO(e,t,r){if(e._==="literal")return Qh(e,t)||ut(RE(e),t,r),tO(e.leaf,t,r);switch(e._){case"bool":return typeof t!="boolean"&&ut("a boolean",t,r),t?Jh:Gh;case"number":if(typeof t!="number"&&ut("a number",t,r),ZR(t))return bf;{let n=QR(t);return n===0?Vh:n*ds+Zh}case"int":return Number.isSafeInteger(t)||ut("an integer",t,r),bf;default:return If}}function WR(e,t,r,n,o){switch(n%ds){case Gh:case Jh:return;case bf:o.numberVarint(r);return;case Vh:o.f64(r);return;case Zh:{let i=Math.floor(n/ds);o.numberVarint(Math.round(r*Pc[i])),o.uvarint(i);return}default:AE(e,t,r,o)}}function Zae(e,t,r,n){let o=tO(t.layout,r,e.options),s=o%ds;if(s===If){let i=n.idAndMark(t.tagBytes);zr(e,t.layout,r,n),n.endSized(i);return}n.uvarint(t.id*ds+s),WR(e,t.layout,r,o,n)}function Qae(e,t){let r=e.byName;if(r===void 0)return;let n=Object.getOwnPropertyNames(t),o=0;for(let i=0;i<n.length;i++){let a=r.get(n[i]);a!==void 0&&(o|=1<<a)}let s=e.struct;if((o&s.requiredMask)!==s.requiredMask){let i=s.fields;for(let a=0;a<i.length;a++){let c=i[a];if(!c.optional&&(o&1<<a)===0)throw Ze[Q++]=c.name,dr(new Yt(c.annotations))}}return o}function Yae(e,t,r,n){let o=r;if(t.extra.length>0){let i=e.intern;e.intern=void 0;let a=XR(e,t,o);if(a.length>0){n.uvarint(0);let c=n.beginSized();eO(e,a,o,n,i),n.endSized(c)}}let s=t.fields;for(let i=0;i<s.length;i++){let a=s[i],c=a.name;if(!Object.hasOwn(o,c)){if(a.optional)continue;throw Ze[Q++]=c,dr(new Yt(a.annotations))}Ze[Q++]=c,Zae(e,a,o[c],n),Q--}}function Xae(e,t,r,n){let o=r,s=e.intern;e.intern=void 0;let i=t.optionalCount+7>>3,a=0;if(i>0){a=n.len;for(let f=0;f<i;f++)n.byte(0)}let c=t.fields,u=0;for(let f=0;f<c.length;f++){let p=c[f],m=p.name,h=Object.hasOwn(o,m);if(p.optional){if(h&&(n.buf[n.start+a+(u>>3)]|=1<<(u&7)),u++,!h)continue}else if(!h)throw Ze[Q++]=m,dr(new Yt(p.annotations));Ze[Q++]=m,p.inline?zr(e,p.layout,o[m],n):AE(e,p.layout,o[m],n),Q--}if(t.extra.length>0){let f=XR(e,t,o);n.uvarint(f.length),eO(e,f,o,n,s)}}function ece(e){switch(e._){case"string":return YR;case"array":return e.uniform?._==="string"?T4:gE;case"struct":return e.extra.length>0?w4:gE;default:return gE}}function tce(e){let t=e.uniform;if(t===void 0){if(e.rest.length!==1)return;t=e.rest[0];for(let r of e.elements)if(r.optional||r.layout!==t)return}return t._==="struct"?t:void 0}function F4(e){let t=e.run;if(t!==void 0)return t;let r=tce(e);if(r===void 0)return e.run=t=null,t;let n=r.fields.map(s=>ece(s.layout)),o=r.fields.length<=v4;return t={struct:r,intern:n,shapes:o,byName:o&&r.extra.length===0?new Map(r.fields.map((s,i)=>[s.name,i])):void 0},e.run=t,t}var rce=16,nce=64;function n4(e,t){return e[t]??={values:[],refs:void 0,hits:0,disabled:!1}}function N4(e,t){let r=e.refs;if(r!==void 0){let o=r.get(t);return o!==void 0&&e.hits++,o}let n=e.values;for(let o=0;o<n.length;o++)if(n[o]===t)return e.hits++,o}function U4(e,t){let r=e.values;if(e.refs!==void 0){if(e.hits===0&&r.length>=nce){e.disabled=!0,e.refs=void 0;return}e.refs.set(t,r.length)}else if(r.length>=rce){let n=e.refs=new Map;for(let o=0;o<r.length;o++)n.set(r[o],o);n.set(t,r.length)}r.push(t)}var rO=0,oce=1,nO=2,sce=64,ice=512;function ace(){return{slots:[],marks:[],frame:0}}function D4(e,t){return e[t]??={values:[],refs:new Map,state:rO,stamp:-1}}function L4(e,t){if(e.refs.has(t)){e.state=oce;return}e.refs.set(t,e.values.length),e.values.push(t),e.values.length>=sce&&(e.state=nO)}function B4(e,t){let r=e.values;r.length>=ice||(e.refs.set(t,r.length),r.push(t))}function cce(e,t){t.stamp!==e.frame&&(t.stamp=e.frame,e.marks.push({slot:t,length:t.values.length,state:t.state}))}function uce(e){e.marks.length=0,e.frame++}function fce(e){let t=e.marks;for(let r=t.length-1;r>=0;r--){let{length:n,slot:o,state:s}=t[r],i=o.values;for(let a=n;a<i.length;a++)o.refs.delete(i[a]);i.length=n,o.state=s}t.length=0,e.frame++}function lce(e,t,r,n){let o=D4(e.slots,t.slot),s=o.state;if(s===nO){n.string(r);return}if(cce(e,o),s===rO){n.string(r),L4(o,r);return}let i=o.refs.get(r);if(i!==void 0){n.uvarint(i*2+1);return}n.byte(0),B4(o,r),n.string(r)}function dce(e,t,r){let n=D4(e,t.slot),o=n.state;if(o===nO)return r.readUtf8(r.end-r.pos);if(o===rO){let a=r.readUtf8(r.end-r.pos);return L4(n,a),a}let s=r.uvarint();if((s&1)===1){let a=(s-1)/2,c=n.values;return a>=c.length&&j("a dictionary reference",s,r.options),c[a]}s!==0&&j("a dictionary marker",s,r.options);let i=r.readUtf8(r.end-r.pos);return B4(n,i),i}function $4(e,t,r,n,o){if(!e.disabled){let i=N4(e,n);if(i!==void 0){o.uvarint(i*2+1);return}U4(e,n)}let s=o.beginSized();zr(t,r,n,o),o.endSizedRun(s)}function pce(e,t,r,n,o){let s=[],i=[];for(let a=0;a<n;a++){Ze[Q++]=a;let c=o.beginSized();mce(e,t,s,i,r[a],o),o.endSized(c),Q--}}function mce(e,t,r,n,o,s){let i=t.struct,a=o,c=i.fields,u;if(i.extra.length>0){let y=XR(e,i,a);y.length>0&&(u=y)}let f=!t.shapes,p=u===void 0?0:yE,m=Qae(t,a);if(m!==void 0)p=m;else for(let y=0;y<c.length;y++){let E=c[y];if(Object.hasOwn(a,E.name))f||(p|=1<<y);else if(!E.optional)throw Ze[Q++]=E.name,dr(new Yt(E.annotations))}let h=-1;for(let y=0;y<r.length;y++)if(r[y]===p){h=y;break}h>=0?s.uvarint(h+1):(s.uvarint(0),f||r.push(p));let x=h<0,g=e.positional&&!f;if(x&&g&&s.uvarint(p),u!==void 0){x&&!g&&s.uvarint(0);let y=s.beginSized();eO(e,u,a,s),s.endSizedRun(y)}for(let y=0;y<c.length;y++){let E=c[y];if(f?!Object.hasOwn(a,E.name):(p&1<<y)===0)continue;x&&!g&&s.uvarint(E.id),Ze[Q++]=E.name;let b=t.intern[y];if(b===YR)$4(n4(n,y),e,E.layout,a[E.name],s);else{b!==gE&&(e.intern=n4(n,y));let v=s.beginSized();zr(e,E.layout,a[E.name],s),s.endSizedRun(v),e.intern=void 0}Q--}}function j4(e,t,r){let n=e.elements.length;if(t<n)return e.elements[t].layout;let o=Math.max(0,e.rest.length-1),s=Math.max(n,r-o);return t>=s?e.rest[t-s+1]:e.rest[0]}function hce(e,t,r,n){let o=r.length;if(t.rest.length===0&&o>t.elements.length)throw Ze[Q++]=t.elements.length,dr(new Uu(t.ast,r[t.elements.length],e.options));if(o<t.minCount)throw Ze[Q++]=o,dr(new Yt(void 0));if(t.hasCount&&n.uvarint(o),o>0){let i=F4(t);if(i!==null){pce(e,i,r,o,n);return}}let s=t.uniform;if(s!==void 0){if(t.uniformNumbers){xce(e,r,o,n);return}let i=e.intern;if(e.intern=void 0,i!==void 0){for(let c=0;c<o;c++)Ze[Q++]=c,$4(i,e,s,r[c],n),Q--;return}let a=t.uniformInline;for(let c=0;c<o;c++)Ze[Q++]=c,a?zr(e,s,r[c],n):AE(e,s,r[c],n),Q--;return}for(let i=0;i<o;i++){let a=j4(t,i,o);Ze[Q++]=i,qR(a)?zr(e,a,r[i],n):AE(e,a,r[i],n),Q--}}var o4=[];function xce(e,t,r,n){let o=!0,s=!0;for(let i=0;i<r;i++){let a=t[i];if(typeof a!="number"&&(Ze[Q++]=i,ut("a number",a,e.options)),ZR(a))(a<0?-a:a)>BR&&(s=!1);else{o=!1;let c=QR(a);c===0?s=!1:o4[i]=c}if(!o&&!s)break}if(o){n.byte(g4);for(let i=0;i<r;i++)n.numberVarint(t[i])}else if(s){n.byte(y4);for(let i=0;i<r;i++){let a=t[i],c=Number.isInteger(a)?0:o4[i],u=c===0?a:Math.round(a*Pc[c]),f=u<0||u===0&&1/u<0,p=f?-u:u;n.uvarint((p*2+(f?1:0))*16+c)}}else{n.byte(x4);for(let i=0;i<r;i++)n.f64(t[i])}}function gce(e){if(!(e.length<2||e.some(t=>t.tuple)))for(let t of e[0].sentinels){let r=new Map;for(let n of e){let o=n.sentinels.find(s=>s.key===t.key);if(o===void 0||r.has(o.literal)||Number.isNaN(o.literal))break;r.set(o.literal,n)}if(r.size===e.length)return{key:t.key,rows:r}}}function KR(e,t){let r=e.sentinels;for(let n=0;n<r.length;n++){let{key:o,literal:s}=r[n];if(t[o]!==s||!Object.hasOwn(t,o))return!1}return!0}function yce(e,t){return e.tuple?Array.isArray(t)&&KR(e,t):Jt(t)&&!Array.isArray(t)&&KR(e,t)}function s4(e,t,r,n){e.positional?n.uvarint(t.position):(n.byte(dt.variant),n.u32le(t.tag)),zr(e,t.payload,r,n)}function Sce(e,t,r,n){let o=t.discriminator;if(o!==void 0){if(Jt(r)&&!Array.isArray(r)){let s=r,i=o.rows.get(s[o.key]);if(i!==void 0&&KR(i,s)){s4(e,i,r,n);return}}}else for(let s of t.variants)if(yce(s,r)){s4(e,s,r,n);return}for(let s of t.others)if(zR(s.layout,r)){e.positional?n.uvarint(s.position):n.byte(s.kind),zr(e,s.layout,r,n);return}throw dr(new at(t.ast,r,e.options))}function zr(e,t,r,n){switch(t._){case"literal":Qh(t,r)||ut(RE(t),r,e.options),zr(e,t.leaf,r,n);return;case"bool":typeof r!="boolean"&&ut("a boolean",r,e.options),n.byte(r===!0?1:0);return;case"null":r!==null&&ut("null",r,e.options);return;case"undefined":r!==void 0&&ut("undefined",r,e.options);return;case"number":{if(typeof r!="number"&&ut("a number",r,e.options),ZR(r)){n.numberVarint(r);return}let o=QR(r);o>0?(n.numberVarint(Math.round(r*Pc[o])),n.byte(o)):n.f64(r);return}case"int":{Number.isSafeInteger(r)||ut("an integer",r,e.options),n.numberVarint(r);return}case"string":{typeof r!="string"&&ut("a string",r,e.options);let o=e.dict;o===void 0?n.string(r):lce(o,t,r,n);return}case"symbol":typeof r!="symbol"&&ut("a symbol",r,e.options),Vae(e,r,n);return;case"bytes":r instanceof Uint8Array||ut("a Uint8Array",r,e.options),n.bytes(r);return;case"bigint":typeof r!="bigint"&&ut("a bigint",r,e.options),n.zigzag(r);return;case"int64":{zR(t,r)||ut(t.flavor==="date"?"a Date":"a DateTime.Utc",r,e.options);let o=t.flavor==="date"?r.getTime():r.epochMilliseconds;Number.isNaN(o)&&ut("a valid Date",r,e.options),n.i64(BigInt(o));return}case"dateTimeZoned":{zR(t,r)||ut("a DateTime.Zoned",r,e.options);let o=r;n.i64(BigInt(o.epochMilliseconds)),o.zone._tag==="Offset"?(n.byte(0),n.i32le(o.zone.offset)):(n.byte(1),n.string(o.zone.id));return}case"duration":{Qi(r)||ut("a Duration",r,e.options);let o=r.value;switch(o._tag){case"Infinity":n.byte(1);return;case"NegativeInfinity":n.byte(2);return;case"Nanos":n.byte(0),n.zigzag(o.nanos);return;case"Millis":n.byte(0),n.zigzag(BigInt(o.millis)*gae);return}}case"bigDecimal":{wu(r)||ut("a BigDecimal",r,e.options);let o=em(r);n.zigzag(o.value),n.zigzag(BigInt(o.scale));return}case"json":{let o;try{o=JSON.stringify(r)}catch{o=void 0}o===void 0&&(kn(r)&&ut("acyclic value",r,e.options),ut("a JSON-serializable value",r,e.options)),n.string(o);return}case"option":{ci(r)||ut("an Option",r,e.options);let o=r;o._tag==="None"?n.byte(0):(n.byte(1),zr(e,t.value,o.value,n));return}case"result":{$f(r)||ut("a Result",r,e.options);let o=r;o._tag==="Success"?(n.byte(0),zr(e,t.success,o.success,n)):(n.byte(1),zr(e,t.failure,o.failure,n));return}case"exit":{ws(r)||ut("an Exit",r,e.options);let o=r;o._tag==="Success"?(n.byte(0),zr(e,t.value,o.value,n)):(n.byte(1),zr(e,t.cause,o.cause,n));return}case"cause":{il(r)||ut("a Cause",r,e.options);let o=r.reasons;n.uvarint(o.length);for(let s of o){let i=n.beginSized();t4(e,t,s,n),n.endSized(i)}return}case"causeReason":{al(r)||ut("a Cause.Reason",r,e.options),t4(e,t,r,n);return}case"struct":{(!Jt(r)||Array.isArray(r))&&ut("an object",r,e.options),e.positional?Xae(e,t,r,n):Yae(e,t,r,n);return}case"array":{Array.isArray(r)||ut("an array",r,e.options),hce(e,t,r,n);return}case"union":Sce(e,t,r,n);return;case"never":throw dr(new at(t.ast,r,e.options))}}var hE=new wE;function i4(e,t,r,n,o){let s=o.beginSized();o.byte(n.envelope),n.positional&&o.bytes(n.fingerprint),zr(e,t,r,o),o.endSized(s)}function H4(e,t,r,n,o,s){let i={options:n,positional:o.positional,indexSignatures:void 0,extraShape:void 0,intern:void 0,dict:s},a=hE??new wE,c=a===hE;c&&(hE=void 0),a.reset();let u=Q,f=!1;try{if(r===void 0)Q=0,i4(i,e,t,o,a);else for(let m=0;m<r.length;m++)Q=0,i4(i,e,r[m],o,a);let p=a.out();return f=!0,p}finally{s!==void 0&&(f?uce(s):fce(s)),a.abort(),Q=u,c&&(hE=a)}}function q4(e,t,r,n,o){return H4(e,void 0,t,r,n,o)}function CE(e,t,r,n,o){return H4(e,t,void 0,r,n,o)}function PE(e){return ws(e)&&ft(e)}var kr=globalThis.Symbol.for("~effect/encoding/SchemaBinary/absent");function un(e,t){let r=Kh(e,t);return r!==kr&&t.pos!==t.end&&j("no leftover bytes",void 0,t.options),r}function z4(e,t){let r=t.enter(t.uvarint()),n=un(e,t);return t.exit(r),n}function W4(e,t){if(OE(e))return Kh(e,t);let r=_E(e),n=t.enter(r!==void 0?r:e._==="null"||e._==="undefined"?0:t.uvarint()),o=un(e,t);return t.exit(n),o}var bce=8;function Ece(e,t){let r=e.set;if(r!==void 0)return r.has(t)?!0:(r.add(t),!1);let n=e.list;if(n.includes(t))return!0;if(n.length>=bce){let o=e.set=new Set;for(let s=0;s<n.length;s++)o.add(n[s]);o.add(t)}else n.push(t);return!1}function K4(e,t,r,n,o){let s=t.uvarint(),i=Math.floor(o===void 0?s/ds:s/16),a=o===void 0?s-i*ds:Math.floor((s-i*16)/2),c=o===void 0?t.readUtf8(i):Ice(o,s,i,t);e.names.has(c)&&j("an extra key distinct from declared fields",c,t.options),Ece(n,c)&&j("unique extra keys",void 0,t.options);let u=e.extraAll??(t.indexSignatures??=new qh(t.options)).find(e,c);if(u===void 0){oO(a,t);return}Ze[Q++]=c;let f=J4(u.layout,u.wireMask,a,t);Q--,f!==kr&&B(r,c,f)}function Ice(e,t,r,n){if((t&1)===1)return r>=e.length&&j("a known back-reference",void 0,n.options),e[r];let o=n.readUtf8(r);return e.push(o),o}function V4(e){return new Ct([e.name],new Yt(e.annotations))}function G4(e,t){throw dr(new Ft(e.ast,t))}function UR(e){for(;(e.byte()&128)!==0;);}function oO(e,t){switch(e){case If:t.take(t.uvarint());return;case bf:UR(t);return;case Vh:t.take(8);return;case Gh:case Jh:case vae:return;case Zh:UR(t),UR(t);return;case wae:t.take(4);return}}function VR(e){if(e._==="literal")return VR(e.leaf);switch(e._){case"bool":return 1<<Gh|1<<Jh;case"number":return 1<<bf|1<<Vh|1<<Zh;case"int":return 1<<bf;default:return 1<<If}}function Tce(e,t){switch(e){case Gh:return!1;case Jh:return!0;case bf:return t.numberVarint();case Vh:return t.f64();case Zh:{let r=t.numberVarint(),n=t.uvarint();return(n===0||n>kE)&&j("a decimal scale in [1, 8]",n,t.options),r/Pc[n]}}return j("matching field wire kind",void 0,t.options)}function J4(e,t,r,n){if((t&1<<r)===0)return oO(r,n),kr;if(r!==If){let i=Tce(r,n);return e._==="literal"&&!Qh(e,i)&&j(RE(e),i,n.options),i}let o=n.enter(n.uvarint()),s=un(e,n);return n.exit(o),s}function wce(e,t){let r;e.extra.length>0&&(r=t.intern,t.intern=void 0);let n={},o=0,s=0,i,a,c,u=!1,f=e.fields,p=0;for(;t.pos<t.end;){let m=t.fieldTag(),h=Math.floor(m/ds),x=m-h*ds;if(h===0){u&&j("unique field ids",void 0,t.options),u=!0,x!==If&&j("extra field map",void 0,t.options);let b=t.enter(t.uvarint());Q4(e,t,n,r),t.exit(b);continue}let g;if(p<f.length&&f[p].id===h?(g=f[p],p++):(g=e.byId.get(h),g!==void 0&&(p=g.index+1)),g===void 0){c===void 0?c=new Set:c.has(h)&&j("unique field ids",void 0,t.options),c.add(h),oO(x,t);continue}let y=g.index;if(y<32){let b=1<<y;(o&b)!==0&&j("unique field ids",void 0,t.options),o|=b}else i===void 0?i=new Set([y]):(i.has(y)&&j("unique field ids",void 0,t.options),i.add(y));Ze[Q++]=g.name;let E=J4(g.layout,g.wireMask,x,t);Q--,E!==kr&&(B(n,g.name,E),y<32?s|=1<<y:(a??=new Set).add(y))}return Z4(e,s,a,t),n}function Z4(e,t,r,n){if((t&e.requiredMask)===e.requiredMask&&!e.requiredWide)return;let o=e.fields,s;for(let i=0;i<o.length;i++){let a=o[i],c=a.index,u=c<32?(t&1<<c)!==0:r?.has(c)===!0;if(!a.optional&&!u&&((s??=[]).push(V4(a)),n.options.errors!=="all"))break}s!==void 0&&G4(e,s)}function vce(e,t){let r;e.extra.length>0&&(r=t.intern,t.intern=void 0);let n={},o=e.optionalCount+7>>3,s=0;o>0&&(t.pos+o>t.end&&j("complete value",void 0,t.options),s=t.pos,t.pos+=o);let i=t.buf,a=e.fields,c=0,u;for(let f=0;f<a.length;f++){let p=a[f];if(p.optional){let h=(i[s+(c>>3)]&1<<(c&7))!==0;if(c++,!h)continue}Ze[Q++]=p.name;let m=p.inline?W4(p.layout,t):z4(p.layout,t);if(Q--,m!==kr)B(n,p.name,m);else if(!p.optional&&((u??=[]).push(V4(p)),t.options.errors!=="all"))break}if(u!==void 0&&G4(e,u),e.extra.length>0){let f=t.uvarint();if(f>t.remaining&&j("complete value",void 0,t.options),f>0){let p={list:[],set:void 0};for(let m=0;m<f;m++)K4(e,t,n,p,r)}}return n}function Q4(e,t,r,n){let o={list:[],set:void 0};for(;t.pos<t.end;)K4(e,t,r,o,n)}function Ace(e,t,r){let n=r.uvarint();if((n&1)===1){let i=(n-1)/2;return i>=e.length&&j("a known back-reference",void 0,r.options),e[i]}if(t._==="string"){if(r.dict!==void 0){let a=r.enter(n/2),c=un(t,r);return r.exit(a),e.push(c),c}let i=r.readUtf8(n/2);return e.push(i),i}let o=r.enter(n/2),s=un(t,r);return r.exit(o),e.push(s),s}function Cce(e,t,r){let n=new Array(t),o=[],s=[];for(let i=0;i<t;i++){Ze[Q++]=i;let a=r.enter(r.uvarint());n[i]=Rce(e,o,s,r),r.exit(a),Q--}return n}function kce(e,t){let r=t.uvarint(),n=e.fields,o=r&~yE;(r>yE*2-1||o>>>n.length)&&j("a known row shape",void 0,t.options);let s=[];(r&yE)!==0&&s.push(null);for(let i=0;i<n.length;i++)(o&1<<i)!==0&&s.push(n[i]);return s}function Rce(e,t,r,n){let o=e.struct,s={},i=0,a,c=n.uvarint(),u;if(c===0?n.positional&&e.shapes&&(u=kce(o,n),t.push(u)):(u=t[c-1],u===void 0&&j("a known row shape",void 0,n.options)),u!==void 0){for(let f=0;f<u.length;f++){let p=a4(e,r,u[f],s,n);p>=0&&(p<32?i|=1<<p:(a??=new Set).add(p))}n.pos!==n.end&&j("no leftover bytes",void 0,n.options)}else{let f=e.shapes?[]:void 0,p=0,m,h,x=!1;for(;n.pos<n.end;){let g=n.uvarint(),y;g===0?(x&&j("unique field ids",void 0,n.options),x=!0,y=null):(y=o.byId.get(g),y===void 0?h===void 0?h=new Set([g]):h.has(g)?j("unique field ids",void 0,n.options):h.add(g):y.index<32?((p&1<<y.index)!==0&&j("unique field ids",void 0,n.options),p|=1<<y.index):m===void 0?m=new Set([y.index]):(m.has(y.index)&&j("unique field ids",void 0,n.options),m.add(y.index))),f?.push(y);let E=a4(e,r,y,s,n);E>=0&&(E<32?i|=1<<E:(a??=new Set).add(E))}f!==void 0&&t.push(f)}return Z4(o,i,a,n),s}function a4(e,t,r,n,o){let s=o.uvarint();if((s&1)===1){if(r==null)return-1;let u=t[r.index],f=(s-1)/2;(u===void 0||f>=u.length)&&j("a known back-reference",void 0,o.options);let p=u[f];return p===kr?-1:(B(n,r.name,p),r.index)}let i=o.enter(s/2);if(r===null)return Q4(e.struct,o,n),o.exit(i),-1;if(r===void 0)return o.exit(i),-1;let a=e.intern[r.index];(a===T4||a===w4)&&(o.intern=t[r.index]??=[]),Ze[Q++]=r.name;let c=un(r.layout,o);return Q--,o.intern=void 0,o.exit(i),a===YR&&(t[r.index]??=[]).push(c),c===kr?-1:(B(n,r.name,c),r.index)}function Oce(e,t){let r=e.elements.length,n=e.hasCount?t.uvarint():r;if(e.rest.length===0&&n>r)throw Ze[Q++]=r,dr(new Uu(e.ast,void 0,t.options));if(n<e.minCount)throw Ze[Q++]=n,dr(new Yt(void 0));if(e.hasCount){let i=e.rest.length>0&&A4(e.rest[0])?Tae:t.remaining+Iae;n>i&&j("array count within allocation limit",n,t.options)}if(n>0){let i=F4(e);if(i!==null)return Cce(i,n,t)}let o=new Array(n),s=e.uniform;if(s!==void 0){if(e.uniformNumbers)return _ce(o,n,t);let i=t.intern;if(t.intern=void 0,i!==void 0){for(let u=0;u<n;u++){Ze[Q++]=u;let f=Ace(i,s,t);if(f===kr)throw dr(new Yt(void 0));Q--,o[u]=f}return o}if(OE(s)){for(let u=0;u<n;u++)Ze[Q++]=u,o[u]=Kh(s,t),Q--;return o}if(s._==="string"){for(let u=0;u<n;u++)Ze[Q++]=u,o[u]=t.dict===void 0?t.readUtf8(t.uvarint()):z4(s,t),Q--;return o}let a=e.uniformPacked,c=e.uniformInline;for(let u=0;u<n;u++){Ze[Q++]=u;let f=t.enter(c?a??0:t.uvarint()),p=un(s,t);if(t.exit(f),p===kr)throw dr(new Yt(void 0));Q--,o[u]=p}return o}for(let i=0;i<n;i++){let a=j4(e,i,n),c=i<r&&e.elements[i].optional;if(!e.hasCount&&t.remaining===0&&!c&&a._!=="null"&&a._!=="undefined")throw Ze[Q++]=i,dr(new Yt(void 0));Ze[Q++]=i;let u=W4(a,t);if(u===kr)throw c&&j("known union member",void 0,t.options),dr(new Yt(void 0));Q--,o[i]=u}if(!e.hasCount&&t.pos<t.end)throw Ze[Q++]=r,dr(new Uu(e.ast,void 0,t.options));return o}function _ce(e,t,r){let n=r.byte();if(n===x4){r.remaining!==t*8&&j("f64",void 0,r.options);for(let o=0;o<t;o++)e[o]=r.f64();return e}if(n===y4){for(let o=0;o<t;o++){Ze[Q++]=o;let s=r.uvarint(),i=s%16;i>kE&&j("decimal",void 0,r.options);let a=S4((s-i)/16);e[o]=i===0?a:a/Pc[i],Q--}return e}n!==g4&&j("f64",void 0,r.options);for(let o=0;o<t;o++)Ze[Q++]=o,e[o]=r.numberVarint(),Q--;return e}function Pce(e,t){let r=t.byte();if(r===dt.variant){let o=t.u32le(),s=e.byTag.get(o);if(s===void 0)return t.take(t.remaining),kr;let i=un(s.payload,t);if(i===kr)return kr;if(!s.tuple)for(let a of s.sentinels)B(i,a.key,a.literal);return i}let n=e.byKind.get(r);return n===void 0?(t.take(t.remaining),kr):un(n,t)}function Mce(e,t){let r=e.byPos[t.uvarint()];r===void 0&&j("known union member",void 0,t.options);let n=un(r.layout,t),o=r.variant;if(o!==void 0&&!o.tuple&&n!==kr)for(let s of o.sentinels)B(n,s.key,s.literal);return n}function c4(e,t){switch(t.byte()){case 0:return Ap(_d(un(e.error,t)));case 1:return Cp(_d(un(e.defect,t)));case 2:return t.remaining!==0&&j("empty",void 0,t.options),kp();case 3:return t.remaining!==8&&j("f64",void 0,t.options),kp(t.f64());default:return t.take(t.remaining),kr}}function _d(e){if(e===kr)throw dr(new Yt(void 0));return e}function Kh(e,t){t.nesting>=VW&&j(`nesting depth at most ${VW}`,t.nesting+1,t.options),t.nesting++;try{return Fce(e,t)}finally{t.nesting--}}function Fce(e,t){switch(e._){case"literal":{let r=Kh(e.leaf,t);return Qh(e,r)||j(RE(e),r,t.options),r}case"bool":{t.remaining!==1&&j("bool",void 0,t.options);let r=t.byte();return r>1&&j("bool",void 0,t.options),r===1}case"null":return t.remaining!==0&&j("empty",void 0,t.options),null;case"undefined":t.remaining!==0&&j("empty",void 0,t.options);return;case"number":{let r=t.remaining;if(r===8)return t.f64();(r===0||r>h4)&&j("f64",void 0,t.options);let n=t.numberVarint();if(t.remaining===0)return n;let o=t.byte();return(t.remaining!==0||o===0||o>kE)&&j("decimal",void 0,t.options),n/Pc[o]}case"int":return t.numberVarint();case"string":{let r=t.dict;return r===void 0?t.readUtf8(t.end-t.pos):dce(r,e,t)}case"symbol":return globalThis.Symbol.for(t.readUtf8(t.end-t.pos));case"bytes":return t.takeCopy(t.end-t.pos);case"bigint":return t.zigzag();case"int64":{t.remaining!==8&&j("int64",void 0,t.options);let r=Number(t.i64()),n=new Date(r);return Number.isNaN(n.getTime())&&j(e.flavor==="date"?"a valid Date":"a valid DateTime",r,t.options),e.flavor==="date"?n:by(r)}case"dateTimeZoned":{let r=Number(t.i64()),n=t.byte(),o;if(n===0)t.remaining!==4&&j("time zone",void 0,t.options),o=t.i32le();else if(n===1)o=t.readUtf8(t.end-t.pos);else return j("time zone",void 0,t.options);try{return Ey(r,{timeZone:o})}catch{return j("time zone",void 0,t.options)}}case"duration":switch(t.byte()){case 0:return $o(t.zigzag());case 1:return Ss;case 2:return La;default:return j("duration",void 0,t.options)}case"bigDecimal":{let r=t.zigzag(),n=t.zigzag();return(n>LR||-n>LR)&&j("safe integer length",void 0,t.options),hy(r,Number(n))}case"json":{let r=t.readUtf8(t.end-t.pos);try{return JSON.parse(r)}catch{return j("json",void 0,t.options)}}case"option":{let r=t.byte();return r===0?(t.remaining!==0&&j("empty",void 0,t.options),_()):(r!==1&&j("bool",void 0,t.options),N(_d(un(e.value,t))))}case"result":{let r=t.byte();return r===0?X(_d(un(e.success,t))):(r!==1&&j("bool",void 0,t.options),re(_d(un(e.failure,t))))}case"exit":{let r=t.byte();if(r===0)return Mr(_d(un(e.value,t)));r!==1&&j("bool",void 0,t.options);let n=Kh(e.cause,t);return ir(n)}case"cause":{let r=t.uvarint(),n=[];for(let o=0;o<r;o++){Ze[Q++]=o;let s=t.enter(t.uvarint()),i=c4(e,t);t.exit(s),Q--,i!==kr&&n.push(i)}return t.pos!==t.end&&j("no leftover bytes",void 0,t.options),fu(n)}case"causeReason":return c4(e,t);case"struct":return t.positional?vce(e,t):wce(e,t);case"array":return Oce(e,t);case"union":return t.positional?Mce(e,t):Pce(e,t);case"never":throw dr(new at(e.ast,void 0,t.options))}}function Y4(e,t,r){let n=t.byte();if(n!==r.envelope&&j(r.expectedEnvelope,n,t.options),r.positional){t.remaining<8&&j("complete value",void 0,t.options);let s=t.buf,i=r.fingerprint,a=t.pos;for(let c=0;c<8;c++)s[a+c]!==i[c]&&j("matching layout fingerprint",void 0,t.options);t.pos=a+8}let o=un(e,t);if(o===kr)throw dr(new Yt(void 0));return o}var xE=new zh;function Nce(e,t,r,n){let o=xE??new zh,s=o===xE;s&&(xE=void 0),o.reset(t,0,t.length,r,void 0,n.positional,void 0);let i=Q;Q=0;try{let a=o.uvarint();a===0&&j("nonzero frame length",void 0,r);let c=o.enter(a),u=Y4(e,o,n);return o.exit(c),o.pos!==t.length&&j("no leftover bytes",void 0,r),u}finally{Q=i,o.release(),s&&(xE=o)}}function Uce(e,t,r,n=!1){return Xt({decode:(o,s)=>{try{let i=Nce(e,o,s,t);return r!==void 0&&$d(i)&&(!n||PE(i))&&(r.value=i),I(i)}catch(i){return i instanceof ji?D(i.issue):gn(i)}},encode:(o,s)=>{try{return I(CE(e,o,s,t))}catch(i){return i instanceof ji?D(i.issue):gn(i)}}})}var Dce=mo(Kae);function Ef(e,t){return t===!0?Dce(e):Wae}var Lce=mo(e=>{let t=J(SE(e)),{exact:r,exitSuccess:n,layout:o,recursive:s}=jae(t.ast);return{target:s?qce(t):t,layout:o,exact:r,exitSuccess:n,recursive:s}});function Md(e){return Lce(e.ast)}function X4(e,t){return e.value===void 0||t!==e.value?!1:(e.value=void 0,!0)}function e6(e,t,r){let n=J(Nt(e.ast)),o=ot(n),s=i=>()=>(a,c,u)=>i(a,u)?nt:o(a,u);return J(new fc([n.ast],s(t),{identifier:"binary value"},void 0,void 0,void 0,void 0,s(r)))}function GR(e,t){return t.onExcessProperty!=="error"}function Bce(e,t,r){return e6(e,n=>X4(t,n),r?GR:$ce)}function $ce(){return!1}function jce(e,t){return Ar()([e],([r])=>{let n=ot(r);return(o,s,i)=>X4(t,o)||PE(o)&&i.onExcessProperty!=="error"?I(o):n(o,i)},{identifier:"binary exit value"})}function Hce(e){return e6(e,GR,GR)}function qce(e){let t=J(Nt(e.ast)),r=new WeakSet,n=Ar()([t],([o])=>(s,i,a)=>$d(s)&&r.delete(s)?I(s):kn(s)?D(new at(i,s,a)):ot(o)(s,a),{identifier:"acyclic value"});return ee(n,Fe({decode:o=>($d(o)&&r.add(o),o),encode:o=>o}))(e)}var FE=nf,Wce,o6=e=>(Wce??=new TextDecoder).decode(e),fn=class extends Ue()("effect/rpc/RpcSerialization"){},ME=class extends sr("MaxBufferSizeExceeded"){get message(){return`RPC serialization buffer exceeded the maximum size of ${this.maxBufferSize}`}},Kce=16*1024*1024,t6=(e,t)=>t!=="unbounded"&&e>t,s6=fn.of({contentType:"application/json",includesFraming:!1,codecFor:FE,makeUnsafe:()=>({decode:e=>{let t=JSON.parse(typeof e=="string"?e:o6(e));return Array.isArray(t)?t:[t]},encode:e=>JSON.stringify(e)})}),NE=e=>{let t=e?.maxBufferSize??Kce;return fn.of({contentType:"application/ndjson",includesFraming:!0,codecFor:FE,makeUnsafe:()=>{let r,n="",o=s=>{throw n="",new ME({maxBufferSize:s})};return{decode:s=>{n+=typeof s=="string"?s:(r??=new TextDecoder).decode(s,{stream:!0});let i=0,a=n.indexOf(`
33
+ `,i),c=[];for(;a!==-1;){t6(a-i,t)&&o(t);let u=n.slice(i,a);i=a+1;try{c.push(JSON.parse(u))}catch{}a=n.indexOf(`
34
+ `,i)}return n=n.slice(i),t6(n.length,t)&&o(t),c},encode:s=>{if(Array.isArray(s)){if(s.length===0)return;let i="";for(let a=0;a<s.length;a++)i+=JSON.stringify(s[a])+`
35
35
  `;return i}return JSON.stringify(s)+`
36
- `}}}})},s6=NE(),i6=e=>fn.of({contentType:e?.contentType??"application/json",includesFraming:!1,codecFor:FE,makeUnsafe:()=>{let t=new Map;return{decode:r=>{let n=JSON.parse(typeof r=="string"?r:n6(r));return c6(n,t)},encode:r=>{let n=u6(r,t);return n&&JSON.stringify(n)}}}}),a6=e=>fn.of({contentType:e?.contentType??"application/json-rpc",includesFraming:!0,codecFor:FE,makeUnsafe:()=>{let t=NE({maxBufferSize:e?.maxBufferSize}).makeUnsafe(),r=new Map;return{decode:n=>{let o=t.decode(n);if(o.length===0)return[];let s=[];for(let i=0;i<o.length;i++)s.push(...c6(o[i],r));return s},encode:n=>{let o=u6(n,r);return o&&t.encode(o)}}}});function c6(e,t){if(Array.isArray(e)){let r={size:0,responses:new Map},n=[];for(let o=0;o<e.length;o++){let s=e[o];if(!Jt(s))continue;let i=t6(s);n.push(i),i._tag==="Request"&&!i.isNotification&&(r.size++,t.set(i.id,r))}return n}return Jt(e)?[t6(e)]:[]}function t6(e){if(Object.hasOwn(e,"method")){let n=e;if(BO(n.id)&&On(n.method)&&n.method.startsWith("@effect/rpc/")){let o=n.method.slice(12),s=n.params?.requestId;return s!==void 0?{_tag:o,requestId:s}:{_tag:o}}return{_tag:"Request",id:n.id??"",tag:n.method,payload:n.params??null,headers:n.headers??[],...O(n,"id")?{}:{isNotification:!0},...n.spanId?{traceId:n.traceId,spanId:n.spanId,sampled:n.sampled}:{}}}let t=e,r=Object.hasOwn(t,"error");return r&&t.error&&t.error._tag==="Defect"?{_tag:"Defect",defect:t.error.data}:Object.hasOwn(t,"chunk")&&t.chunk===!0?{_tag:"Chunk",requestId:t.id??"",values:t.result}:{_tag:"Exit",requestId:t.id??"",exit:r&&t.error!=null?{_tag:"Failure",cause:t.error._tag==="Cause"?t.error.data:[{_tag:"Fail",error:t.error}]}:{_tag:"Success",value:t.result}}}function r6(e,t){if(!("requestId"in e))return nO(e);let r=t.get(e.requestId);return r?(t.delete(e.requestId),r.responses.set(e.requestId,e),r.size===r.responses.size?Array.from(r.responses.values(),nO):void 0):nO(e)}function u6(e,t){if(Array.isArray(e)===!1)return r6(e,t);if(e.length===0)return;let r=[];for(let o=0;o<e.length;o++){let s=r6(e[o],t);s!==void 0&&r.push(s)}if(r.length===0)return;if(r.length===1)return r[0];let n=[];for(let o=0;o<r.length;o++){let s=r[o];Array.isArray(s)?n.push(...s):n.push(s)}return n}function nO(e){switch(e._tag){case"Request":return{jsonrpc:"2.0",method:e.tag,params:e.payload,...e.isNotification?{}:{id:e.id},...e.headers?.length>0?{headers:e.headers}:{},traceId:e.traceId,spanId:e.spanId,sampled:e.sampled};case"Ping":case"Pong":case"Interrupt":case"Ack":case"Eof":return{jsonrpc:"2.0",method:`@effect/rpc/${e._tag}`,params:"requestId"in e?{requestId:e.requestId}:void 0};case"Chunk":return{jsonrpc:"2.0",chunk:!0,id:e.requestId,result:e.values};case"Exit":{if(e.exit._tag==="Success")return{jsonrpc:"2.0",id:e.requestId??void 0,result:e.exit.value};let t=e.exit.cause.find(n=>n._tag==="Fail"),r=t?._tag==="Fail"?t.error:void 0;return{jsonrpc:"2.0",id:e.requestId??void 0,error:e.exit._tag==="Failure"?{_tag:"Cause",code:r&&O(r,"code")?Number(r.code):0,message:r&&O(r,"message")?r.message:JSON.stringify(e.exit.cause),data:e.exit.cause}:void 0}}case"Defect":return{jsonrpc:"2.0",id:Vce,error:{_tag:"Defect",code:1,message:"A defect occurred",data:e.defect}};case"ClientProtocolError":return{}}}var Vce=-32603,Gce=16*1024*1024,Jce=new TextEncoder,Zce=e=>{let t=e?.maxFrameSize==="unbounded"?void 0:e?.maxFrameSize??Gce,r=e?.fingerprintPayloads===!0?o=>VR(o,{fingerprint:!0}):VR,n={fingerprint:!0};return fn.of({contentType:"application/vnd.effect.rpc+schema-binary",includesFraming:!0,codecFor:r,makeUnsafe:()=>{let o=f4(PR,{...n,maxFrameSize:t}),s=d4(PR,n);return{decode:i=>o.feedSync(typeof i=="string"?Jce.encode(i):i),encode:i=>{if(!Array.isArray(i))return s.encode(i);if(i.length!==0)return s.encodeMany(i)}}}})},Qce=Ga(fn)(o6),Yce=Ga(fn)(s6),Xce=e=>Ga(fn)(NE(e)),eue=e=>Ga(fn)(i6(e)),tue=e=>Ga(fn)(a6(e)),rue=e=>p0(fn)(()=>Zce(e));var UE=class extends Ue()("effect/rpc/RpcWorker/InitialMessage"){};var l6=e=>L(()=>{let t=new Set,r=new Map,n=new Map,o=(s,i)=>yn(a=>{let c=r.get(s);return c||(c=[],r.set(s,c)),c.push([i,a]),P});return K(e((s,i)=>{let a=n.get(s);return a?a(i):o(s,i)},t),s=>({...s,run(i,a){return xt(function*(){t.add(i),n.set(i,a);let c=r.get(i);if(c){r.delete(i);for(let[u,f]of c)yield*Ur(L(()=>a(u)),f)}return yield*Xr(Xn,()=>(t.delete(i),n.delete(i),P))})}}))});var oue=e=>Or(e,"RpcClientError"),sue=0,d6=me(function*(e,t){let r=t.spanPrefix,n=t?.supportsAck??!0,o=t?.disableTracing??!1,s=t?.generateRequestId??(()=>sue++),i=yield*Nr(),a=Re(i,it),c=new Map,u=!1;yield*It(a,ar(b=>(u=!0,f(Lg(b.id)))));let f=me(function*(b){for(let[v,T]of c)c.delete(v),T._tag==="Queue"?yield*b._tag==="Success"?yd(T.queue):Ht(T.queue,b.cause):T.resume(b)}),p=b=>{let v=Bh(b.successSchema),T=x(b);return(S,w)=>{let k=w?.headers?Zo(w.headers):kl,C=w?.context??pt();if(!v){let M=$=>m(b,T,$,b.payloadSchema.make(S),k,C,w?.discard??!1);return o?M(void 0):Qp(TR(r,b._tag),{kind:"client",attributes:wR(b._tag,t.spanAttributes)},M)}let R=h(b,T,b.payloadSchema.make(S),k,w?.streamBufferSize??16,C);return w?.asQueue?R:Cn(K(R,Sh))}},m=(b,v,T,S,w,k,C)=>ar(R=>{if(u)return Dn;let M=s(),$=v(xe=>t.onFromClient({message:xe,context:k,discard:C}),{_tag:"Request",id:M,tag:b._tag,payload:S,...T?{traceId:T.traceId,spanId:T.spanId,sampled:T.sampled}:{},headers:Rl(R.getRef(DE),w)});if(C)return $;let te;return Su(Nn(xe=>{let Le={_tag:"Effect",rpc:b,context:k,resume(Er){xe(Er),te&&!te.pollUnsafe()&&R.currentDispatcher.scheduleTask(()=>{te.interruptUnsafe(R.id)},0)}};c.set(M,Le),te=$.pipe(T?bl(T,{captureStackTrace:!1}):F,Sr(R.context)),te.addObserver(Er=>{if(Er._tag==="Failure")return xe(Er)})}),xe=>(c.delete(M),Vt(Tn(te),g(M,Array.from(xe),k))))}),h=me(function*(b,v,T,S,w,k){if(u)return yield*Dn;let C=o?void 0:yield*rw(TR(r,b._tag),{kind:"client",attributes:wR(b._tag,t.spanAttributes)}),R=os(),M=s(),$=dn(R.context,it),te=yield*sf(w);return yield*Wo($,xe=>(HA(te),c.has(M)?(c.delete(M),g(M,vs(xe)?Array.from(yN(xe.cause)):[],k)):P)),c.set(M,{_tag:"Queue",rpc:b,queue:te,scope:$,context:k}),yield*v(xe=>t.onFromClient({message:xe,context:k,discard:!1}),{_tag:"Request",id:M,tag:b._tag,payload:T,...C?{traceId:C.traceId,spanId:C.spanId,sampled:C.sampled}:{},headers:Rl(R.getRef(DE),S)}).pipe(C?bl(C,{captureStackTrace:!1}):F,to(xe=>Ht(te,xe)),vi,gt($,{startImmediately:!0})),te}),x=b=>{let v=[];for(let T of b.middlewares.values()){let S=Gi(i,`${T.key}/Client`);S&&v.push(S)}return v.length===0?(T,S)=>T(S):function T(S,w,k=v.length-1){return k===-1?S(w):v[k]({rpc:b,request:w,next(C){return T(S,C,k-1)}})}},g=(b,v,T)=>Nn(S=>{let w=os();t.onFromClient({message:{_tag:"Interrupt",requestId:b,interruptors:v},context:T,discard:!1}).pipe(K0(1e3),Sr(w.context)).addObserver(()=>{S(P)})}),y=b=>{switch(b._tag){case"Chunk":{let v=b.requestId,T=c.get(v);return!T||T._tag!=="Queue"?P:wa(T.queue,b.values).pipe(n?A(()=>t.onFromClient({message:{_tag:"Ack",requestId:b.requestId},context:T.context,discard:!1})):F,rt(S=>Ht(T.queue,S)))}case"Exit":{let v=b.requestId,T=c.get(v);return T?(c.delete(v),T._tag==="Effect"?(T.resume(b.exit),P):b.exit._tag==="Success"?yd(T.queue):Ht(T.queue,b.exit.cause)):P}case"Defect":return f(Dg(b.defect));case"ClientEnd":return P}},E;if(t.flatten){let b=new Map;E=function(T,S,w){let k=b.get(T);return k||(k=p(e.requests.get(T)),b.set(T,k)),k(S,w)}}else E={},e.requests.forEach(b=>{B(E,b._tag,p(b))});return{client:E,write:y}}),iue=0,oO=me(function*(e,t){let r=iue++,{codecFor:n,run:o,send:s,supportsAck:i,supportsTransferables:a}=yield*Hi,c=aue(n),u=Zm(n(er())),f=new Map,p=x=>f.has(x)?(f.delete(x),s(r,{_tag:"Interrupt",requestId:x})):P,{client:m,write:h}=yield*d6(e,{...t,supportsAck:i,onFromClient({message:x}){switch(x._tag){case"Request":{let g=e.requests.get(x.tag),y=a?DW():void 0,E=os(),b={rpc:g,context:y?We(E.context,Lh,y):E.context,schemas:c(g)};return f.set(x.id,b),b.schemas.encodePayload(x.payload).pipe(Ur(b.context),Ii,A(v=>s(r,{...x,id:x.id,payload:v,headers:Object.entries(x.headers)},y&&y.readUnsafe())))}case"Ack":return f.get(x.requestId)?s(r,{_tag:"Ack",requestId:x.requestId}):P;case"Interrupt":return p(x.requestId);case"Eof":return P}}});return yield*o(r,x=>{switch(x._tag){case"Chunk":{let g=_R(x.requestId),y=f.get(g);if(!y||fe(y.schemas.decodeChunk))return P;let E=y.schemas.decodeChunk.value;return en(b=>b(E(x.values).pipe(Ur(y.context),Ii,A(v=>h({_tag:"Chunk",clientId:0,requestId:g,values:v})))).pipe(to(v=>h({_tag:"Exit",clientId:0,requestId:g,exit:ir(v)}).pipe(Vt(fl(v)?P:cy(p(g))))),z0(v=>!fl(v),()=>P)))}case"Exit":{let g=_R(x.requestId),y=f.get(g);return y?(f.delete(g),y.schemas.decodeExit(x.exit).pipe(Ur(y.context),Ii,Un({onSuccess:E=>h({_tag:"Exit",clientId:0,requestId:g,exit:E}),onFailure:E=>h({_tag:"Exit",clientId:0,requestId:g,exit:ir(E)})}))):P}case"Defect":return h({_tag:"Defect",clientId:0,defect:u(x.defect)});case"ClientProtocolError":{let g=Jn(x.error);return Ko(Array.from(f.keys()),y=>h({_tag:"Exit",clientId:0,requestId:y,exit:g}))}default:return P}}).pipe(rt(Xp),vi,Rs),m}),aue=e=>{let t=new WeakMap;return r=>{let n=t.get(r);if(n!==void 0)return n;let o=dE(r.successSchema);return n={decodeChunk:Lt(o,s=>xc(e(Yu(s.success)))),encodePayload:rA(e(r.payloadSchema)),decodeExit:xc(e(RR(r)))},t.set(r,n),n}},DE=Ce("effect/rpc/RpcClient/CurrentHeaders",{defaultValue:()=>kl}),cue=d(2,(e,t)=>X0(e,DE,Rl(Zo(t)))),Hi=class extends Ue()("effect/rpc/RpcClient/Protocol"){static make=l6},p6=e=>Hi.make(me(function*(t){let r=yield*fn,n=r.includesFraming,o=u=>new Zs({reason:wd.fromHttpClientError(u)}),s=(u,f)=>new Zs({reason:new Rc({message:u,cause:f})}),i=u=>s("Received empty HTTP response from RPC server",u),a=u=>s("HTTP response ended before RPC request completed",u);return{send:me(function*(u,f){if(f._tag!=="Request")return;let p=r.makeUnsafe(),m=p.encode(f),h=typeof m=="string"?Hk(m,r.contentType):jk(m,r.contentType),x=yield*e.post("",{body:h}).pipe(yl(o));if(!n){let E=yield*x.text.pipe(yl(o)),b=yield*Go({try:()=>p.decode(E),catch:T=>s("Error decoding HTTP response",T)});if(!Array.isArray(b))return yield*s("Expected an array of responses",b);if(b.length===0)return yield*i(f);let v=!1;for(let T=0;T<b.length;T++){let S=b[T];MR(S)&&(v=!0),yield*t(u,S)}return v?void 0:yield*a(f)}let g=!1,y=!1;if(yield*Td(x.stream,E=>Go({try:()=>E.flatMap(p.decode),catch:b=>s("Error decoding HTTP response",b)}).pipe(A(b=>{if(b.length===0)return P;g=!0;let v=0;return xn({while:()=>v<b.length,body:()=>{let T=b[v++];return MR(T)&&(y=!0),t(u,T)},step:Rr})}))).pipe(yl(E=>oue(E)?E:o(E))),g){if(!y)return yield*a(f)}else return yield*i(f)}),supportsAck:!1,supportsTransferables:!1,codecFor:r.codecFor}})),uue=e=>Qn(Hi)(A(Qk,t=>(t=wW(t,mW(e.url)),p6(e.transformClient?e.transformClient(t):t)))),m6=e=>Hi.make(me(function*(t,r){let n=yield*kW,o=yield*fn,s=yield*yu(Xh),i=new Map,a=yield*n.writer,c=o.makeUnsafe(),u=yield*lue(L(()=>a.write(c.encode(jW))),e),f=uy(e?.onPingTimeout??P,{log:!0,message:"RpcClient onPingTimeout hook failed"}),p,m=g=>Ko(r,y=>t(y,g)),h=g=>(p=g,m({_tag:"ClientProtocolError",error:g})),x=g=>{try{let y=c.decode(g);if(y.length===0)return P;u.onFrame();let E=0;return xn({while:()=>E<y.length,body:()=>{let b=y[E++];if(b._tag==="Pong")return P;if(Object.hasOwn(b,"requestId")){let v=b.requestId,T=i.get(v);if(T!==void 0)return b._tag==="Exit"&&i.delete(v),t(T,b)}return m(b)},step:Rr})}catch(y){return m({_tag:"ClientProtocolError",error:new Zs({reason:new Rc({message:"Error decoding message",cause:y})})})}};return yield*L(()=>{c=o.makeUnsafe(),u.reset();let g=!1;return xt(function*(){let{pull:y}=yield*n.reader;for(p=void 0,g=!0,de(s)&&(yield*s.value.onConnect);;){let E=yield*y;for(let b=0;b<E.length;b++)yield*x(E[b])}}).pipe(ec,Ya(u.timeout),Vt(()=>g?f:P),Vt(()=>D(new _h({reason:new Oh({cause:new Error("ping timeout")})}))))}).pipe(de(s)?wi(s.value.onDisconnect):F,Jp(g=>{let y=ul(g),E=tt(y),b=new Zs({reason:E?y.success.reason:new Rc({message:"Unknown socket error",cause:fu(g)})});return e?.retryTransientErrors&&E&&y.success.reason._tag==="SocketOpenError"?(e.onTransientError?.(b)??P).pipe(uy({log:!0,message:"RpcClient onTransientError hook failed"})):h(b)}),W0(e?.retryPolicy??fue,g=>h(new Zs({reason:g.reason}))),py({module:"RpcClient",method:"makeProtocolSocket"}),Rs),{send(g,y){if(p)return D(p);y._tag==="Request"&&i.set(y.id,g);let E=c.encode(y);return E===void 0?P:Ii(a.write(E))},supportsAck:!0,supportsTransferables:!1,codecFor:o.codecFor}})),fue=lU([dU(500,1.5),hl(5e3)]),lue=me(function*(e,t){let r=yield*Yn,n=t?.pingInterval??"5 seconds",o=Wt(t?.pingTimeout??n),s=r.currentTimeMillisUnsafe(),i=jr(),a=()=>{s=r.currentTimeMillisUnsafe()},c=()=>{a(),i.closeUnsafe()};return yield*L(()=>r.currentTimeMillisUnsafe()-s>o?i.open:e).pipe(ca(n),cy,Mt,vi,Rs),{timeout:i.await,reset:c,onFrame:a}}),due=e=>Qn(Hi)(m6(e)),h6=e=>Hi.make(me(function*(t,r){let n=yield*lE,o=yield*Co,s=0,i=yield*yu(UE),a=yield*yu(Xh),c=new Map,u=h=>Ko(r,x=>t(x,h)),f=xt(function*(){let h=s++,x=yield*n.spawn(h);return yield*x.run(g=>{if(g._tag==="Exit"){let y=c.get(g.requestId);if(y)return c.delete(g.requestId),y.latch.openUnsafe(),t(y.clientId,g)}else if(g._tag==="Defect"){for(let[y,E]of c)c.delete(y),E.latch.openUnsafe();return u(g)}else if("requestId"in g){let y=c.get(g.requestId);if(y)return t(y.clientId,g)}return u(g)},{onSpawn:de(i)?A(i.value,([g,y])=>Ii(x.send({_tag:"InitialMessage",value:g},y))):void 0}).pipe(Jp(g=>{for(let[E,b]of c)b.worker===x&&(c.delete(E),b.latch.openUnsafe());let y=ul(g);return u({_tag:"ClientProtocolError",error:new Zs({reason:tt(y)?y.success.reason:new Rc({message:"Error in worker",cause:fu(g)})})})}),ay(hl(1e3)),py({module:"RpcClient",method:"makeProtocolWorker"}),vi,Rs),x}),p="minSize"in e?yield*Wz({acquire:f,min:e.minSize,max:e.maxSize,concurrency:e.concurrency,targetUtilization:e.targetUtilization,timeToLive:e.timeToLive}):yield*zz({acquire:f,size:e.size,concurrency:e.concurrency,targetUtilization:e.targetUtilization});yield*It(o,W(()=>{for(let h of c.values())h.latch.openUnsafe();c.clear()}));let m=(h,x,g)=>{switch(x._tag){case"Request":return Pk(p).pipe(A(y=>{let E=jr(!1);return c.set(x.id,{clientId:h,worker:y,latch:E}),A(y.send(x,g),()=>E.await)}),ec,Ii);case"Interrupt":{let y=c.get(x.requestId);return y?(c.delete(x.requestId),y.latch.openUnsafe(),Ii(y.worker.send(x))):P}case"Ack":{let y=c.get(x.requestId);return y?Ii(y.worker.send(x)):P}}return P};return yield*ec(Pk(p)),de(a)&&(yield*a.value.onConnect),{send:m,supportsAck:!0,supportsTransferables:!0,codecFor:rf}})),pue=$c(h6,Qn(Hi)),Xh=class extends Ue()("effect/rpc/RpcClient/ConnectionHooks"){};var LE="~effect/reactivity/Atom",y6=e=>O(e,LE),iO="~effect/reactivity/Atom/Writable",rx=d(2,(e,t)=>{let r=$e(t),n=Wn(r);return Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,keepAlive:!n,idleTTL:n?Wt(r):void 0})}),If=rx(0),cO={[LE]:LE,equals:Object.is,...wr,toJSON(){return{_id:"Atom",keepAlive:this.keepAlive,lazy:this.lazy,label:this.label}}},mue={...cO,atom(e,t){let r=S6(e,t);return qi(n=>{let o=n.self(),s=n(this);return s._tag!=="Success"?Mh(s,o):r(n,s.value)})},fn(e,t){return arguments.length===0?(r,n)=>x6(this,r,n):x6(this,e,t)},pull(e,t){let r=If(uO(0)),n=qi(o=>{let s=o.self(),i=o(this);return i._tag!=="Success"?Mh(i,s):BE(o,wue(o,r,e,t),Ca(!0),i.value)});return vue(r,n)},subscriptionRef(e){return Eue(If(qi(t=>{let r=t.self(),n=t(this);if(n._tag!=="Success")return Mh(n,r);let o=typeof e=="function"?e(t):e;return vh(o)?o:BE(t,o,Ca(!0),n.value)})),(t,r)=>{let n=fR(t(this));return bue(t,r,n)})}},x6=(e,t,r)=>{let[n,o,s]=Tue(r?.reactivityKeys?(i,a)=>{let c=t(i,a);return Yr(c)?zb(c,r.reactivityKeys):Eh(c,Wb(r.reactivityKeys))}:t,r);return nx(i=>{i.get(s);let a=i.self(),c=i.get(e);return c._tag!=="Success"?Mh(c,a):n(i,c.value)},o)},hue={...cO,[iO]:iO},xue=e=>iO in e,qi=(e,t)=>{let r=Object.create(cO);return r.keepAlive=!1,r.lazy=!0,r.read=e,r.refresh=t,r},nx=(e,t,r)=>{let n=Object.create(hue);return n.keepAlive=!1,n.lazy=!0,n.read=e,n.write=t,n.refresh=r,n};function gue(e,t){e.setSelf(t)}var tx=(e,t)=>{let r=S6(e,t);return LE in r?r:qi(r)},S6=(e,t)=>{if(typeof e=="function"&&!Yr(e)&&!Ae(e)){let r=e;return function(n,o){let s=r(n);switch(typeof s){case"function":case"object":return s===null?s:b6 in s?aO(n,s,t,o):yue in s?g6(n,s,t,o):s;default:return s}}}else{if(Yr(e))return function(r,n){return aO(r,e,t,n)};if(Ae(e))return function(r,n){return g6(r,e,t,n)}}return uO(e)},b6="~effect/Effect",yue="~effect/Stream",uO=e=>nx(function(t){return e},gue),aO=(e,t,r,n)=>{let o=r?.initialValue!==void 0?us(r.initialValue):Ca();return BE(e,t,o,n,r?.uninterruptible)};function BE(e,t,r,n=pt(),o=!1){let s=e.self(),i=Zn();e.addFinalizer(()=>{Sr(n)(Ve(i,Kt))});let a,c=!1,u=fO(n.pipe(We(it,i),We(fE,e.registry),We(La,e.registry.scheduler)),t,function(f){a=cR(f,s),c&&e.setSelf(a)},o);return c=!0,u!==void 0&&e.addFinalizer(u),a!==void 0?a:s._tag==="Some"?uE(s):Ph(r)}function fO(e,t,r,n=!1){if(ws(t)){r(t);return}let s=Sr(e)(t);s.currentDispatcher?.flush();let i=s.pollUnsafe();if(i){r(i);return}let a=s.addObserver(r);function c(){a(),n||s.interruptUnsafe()}return c}function Sue(e){let t=e?.memoMap??If(tx(()=>xi())),r=i=>y6(t)?i(t):t,n=Kb;function o(i){let a=Object.create(mue);a.keepAlive=!1,a.lazy=!0,a.refresh=void 0,a.factory=o;let c=mO(qi(typeof i=="function"?u=>Pp(i(u),n):()=>Pp(i,n)));return a.layer=c,a.read=function(f){let p=f(c),m=A(Co,h=>gi(p,r(f),h));return aO(f,m,{uninterruptible:!0})},a}o.memoMap=t,o.addGlobalLayer=i=>{n=Pp(n,As(i,Kb))};let s=If(tx(i=>yn(a=>gi(Kb,r(i),Re(a,it))).pipe(K(Re(vc)))));return o.withReactivity=i=>a=>Cue(a,c=>{let u=fR(c(s));return c.addFinalizer(u.registerUnsafe(i,()=>{c.refresh(a)})),c.subscribe(a,f=>c.setSelf(f)),c.once(a)},{initialValueTarget:a}),o}var lO=Sue(),hEe=lO.withReactivity,g6=(e,t,r,n)=>{let o=r?.initialValue!==void 0?us(r.initialValue):Ca();return dO(e,t,o,n)};function dO(e,t,r,n=pt()){let o=e.self();n=We(n,fE,e.registry);let s=Sl(a=>A(as(t.channel,a),c=>xn({while:nr,body:()=>c,step(u){e.setSelf(us(jf(u),{waiting:!0}))}}))).pipe(rt(a=>(wo(a)?Ud(e.self(),gs(uR),Zt({onNone:()=>e.setSelf(PW(new ll,{previous:e.self()})),onSome:c=>e.setSelf(us(c))})):e.setSelf(Ad(a,{previous:e.self()})),P))),i=fO(n.pipe(We(fE,e.registry),We(La,e.registry.scheduler)),s,Rr,!1);return i!==void 0&&e.addFinalizer(i),o._tag==="Some"?uE(o):Ph(r)}var bue=(e,t,r=pt())=>vh(t)?(e.addFinalizer(Dk(t).pipe(Td(n=>{for(let o=0;o<n.length;o++)e.setSelf(n[o]);return P}),nw(r))),iw(r)(Xz(t))):t._tag!=="Success"?t:dO(e,Dk(t.value),Ca(!0),r),Eue=(e,t)=>{function r(n,o){let s=n.get(e);vh(s)?Ai(Lk(s,o)):Cd(s)&&Ai(Lk(s.value,o))}return nx(n=>{let o=n(e);return vh(o)||Cd(o)?t(n,o):o},r)};var Iue=Symbol.for("effect/reactivity/atom/Atom/Reset"),sO=Symbol.for("effect/reactivity/atom/Atom/Interrupt");function Tue(e,t){let r=If(uO([0,void 0])),n=t?.initialValue!==void 0?us(t.initialValue):Ca(),o=t?.concurrent?If(qi(a=>{let c=new Set;return a.addFinalizer(()=>c.forEach(u=>u.interruptUnsafe())),c})):void 0;function s(a,c){let u=o?a(o):void 0;a.isFn=!0;let[f,p]=a.get(r);if(f===0)return n;if(p===sO)return Ad(xN(),{previous:a.self()});let m=e(p,a);return b6 in m?(u&&(m=A(Il(m,{startImmediately:!0}),x=>{u.add(x);let g=Array.from(u);return x.addObserver(()=>u.delete(x)),K(eb(g),y=>y[0])})),BE(a,m,n,c,!1)):dO(a,m,n,c)}function i(a,c){kue(()=>{c===Iue?a.set(r,[0,void 0]):c===sO?a.set(r,[a.get(r)[0]+1,sO]):a.set(r,[a.get(r)[0]+1,c]),a.refreshSelf()})}return[s,i,r]}var wue=(e,t,r,n)=>A(Ck(typeof r=="function"?r(e):r),o=>{let i=os().context,a=Qt(),c=Un(o,{onFailure(f){return wo(f)?bt(a)?I({done:!0,items:a}):D(new ll("Atom.pull: no items")):je(f)},onSuccess(f){let p;return n?.disableAccumulation?p=f:(p=up(a,f),a=p),I({done:!1,items:p})}}),u=new Set;return e.addFinalizer(()=>{for(let f of u)f()}),e.once(t),e.subscribe(t,()=>{e.setSelf(uE(e.self()));let f;f=fO(i,c,p=>{f&&u.delete(f);let m=cR(p,e.self()),h=u.size>0;e.setSelf(h?Ph(m):m)}),f&&u.add(f)}),c}),vue=(e,t)=>nx(t.read,function(r,n){r.set(e,r.get(e)+1)}),pO=typeof WeakRef>"u"||typeof FinalizationRegistry>"u"?e=>{let t=Si();return function(r){let n=Qr(t,r);if(n._tag==="Some")return n.value;let o=e(r);return bi(t,r,o),o}}:e=>{let t=Si(),r=new FinalizationRegistry(n=>{let o=Qr(t,n);o._tag==="Some"&&o.value.deref()===void 0&&Ei(t,n)});return function(n){let o=Qr(t,n).pipe(RI(i=>i.deref()));if(o._tag==="Some")return o.value;let s=e(n);return bi(t,n,new WeakRef(s)),r.register(s,n),s}};var mO=e=>Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,keepAlive:!0});var Cue=d(e=>y6(e[0]),(e,t,r)=>{let n=If(xue(e)?nx(o=>t(o,e),function(o,s){o.set(e,s)},e.refresh??function(o){o(e)}):qi(o=>t(o,e),e.refresh??function(o){o(e)}));return r?.initialValueTarget&&(n.initialValueTarget=Aue(r.initialValueTarget)),n}),Aue=e=>{let t=e;for(;t.initialValueTarget;)t=t.initialValueTarget;return t};var kue=NW;var Rue="~effect-atom/atom/Atom/Serializable";var hO=d(2,(e,t)=>{let r=rf(t.schema);return Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,label:e.label??[t.key,Ir()===0?"":new Error().stack?.split(`
37
- `)[5]??""],[Rue]:{key:t.key,encode:nA(r),decode:Zm(r)}})});var I6=()=>(e,t)=>{let r=Ue()(e),n=Qn(r,t.makeEffect??oO(t.group,{...t,flatten:!0})),o=t.runtime??lO;r.runtime=o(typeof t.protocol=="function"?i=>As(n,Vg(t.protocol(i))):As(n,Vg(t.protocol))),r.mutation=pO(i=>{let a=t.group.requests.get(i);return r.runtime.fn()(me(function*({headers:c,payload:u,reactivityKeys:f}){let m=(yield*r)(i,u,{headers:c});return yield*f?zb(m,f):m})).pipe(hO({key:`AtomRpc:mutation:${i}`,schema:lR({success:a.successSchema,error:E6(a)})}))});let s=pO(i=>{let{headers:a,payload:c,reactivityKeys:u,tag:f,timeToLive:p}=i,m=t.group.requests.get(f),h=Bh(m.successSchema),x=h?r.runtime.pull(Cn(r.use(g=>I(g(f,c,{headers:a}))))):r.runtime.atom(r.use(g=>g(f,c,{headers:a})));return u&&(x=r.runtime.factory.withReactivity(u)(x)),!h&&i.serializationKey&&(x=hO(x,{key:`AtomRpc:${i.tag}:${i.serializationKey}`,schema:lR({success:m.successSchema,error:E6(m)})})),p&&(x=Wn(p)?rx(x,p):mO(x)),x});return r.query=(i,a,c)=>{let u={tag:i,payload:a,headers:c?.headers?Zo(c.headers):void 0,reactivityKeys:c?.reactivityKeys,timeToLive:c?.timeToLive!==void 0?$e(c.timeToLive):void 0,serializationKey:c?.serializationKey};return s(u)},r},E6=e=>Pe([e.errorSchema,...Array.from(e.middlewares,t=>t.error),Zs]);var $E={};ps($E,{make:()=>Pue});var _ue={add(...e){let t=new Map(this.requests);for(let r of e)t.set(r._tag,r);return Aa({requests:t,annotations:this.annotations})},merge(...e){let t=new Map(this.requests),r=new Map(this.annotations.mapUnsafe);for(let n of e){for(let[o,s]of n.requests)t.set(o,s);for(let[o,s]of n.annotations.mapUnsafe)r.set(o,s)}return Aa({requests:t,annotations:qn(r)})},omit(...e){let t=new Map(this.requests);for(let r of e)t.delete(r);return Aa({requests:t,annotations:this.annotations})},middleware(e){let t=new Map;for(let[r,n]of this.requests)t.set(r,n.middleware(e));return Aa({requests:t,annotations:this.annotations})},toHandlers(e){let t=this;return xt(function*(){let r=yield*Nr(),n=Yr(e)?yield*e:e,o=new Map;return t.requests.forEach((s,i)=>{o.set(s.key,{tag:s._tag,handler:n[i],context:r})}),qn(o)})},prefix(e){let t=new Map;for(let r of this.requests.values()){let n=r.prefix(e);t.set(n._tag,n)}return Aa({requests:t,annotations:this.annotations})},toLayer(e){return Ja(this.toHandlers(e))},of:F,toLayerHandler(e,t){let r=this;return Ja(xt(function*(){let n=yield*Nr(),o=Yr(t)?yield*t:t,s=new Map,i=r.requests.get(e);return s.set(i.key,{handler:o,context:n}),qn(s)}))},accessHandler(e){return yn(t=>{let r=this.requests.get(e),{handler:n,context:o}=Gi(t,r.key);return I((s,i)=>{i.rpc=r;let a=n(s,i),c=Rd(a)?a.value:a;return Yr(c)?Q0(c,o):wk(c,o)})})},annotate(e,t){return Aa({requests:this.requests,annotations:We(this.annotations,e,t)})},annotateRpcs(e,t){return this.annotateRpcsMerge(ys(e,t))},annotateMerge(e){return Aa({requests:this.requests,annotations:Kr(this.annotations,e)})},annotateRpcsMerge(e){let t=new Map;for(let[r,n]of this.requests)t.set(r,n.annotateMerge(Kr(e,n.annotations)));return Aa({requests:t,annotations:this.annotations})}},Aa=e=>Object.assign(function(){},_ue,{requests:e.requests,annotations:e.annotations}),Pue=(...e)=>Aa({requests:new Map(e.map(t=>[t._tag,t])),annotations:pt()});var Tf={};ps(Tf,{Service:()=>Mue,TypeId:()=>gO,layerClient:()=>Fue});var gO="~effect/rpc/RpcMiddleware",Mue=()=>(e,t)=>{let r=Ir(),n;r!==0&&(yt(2),n=new globalThis.Error,yt(r));function o(){}let s=o;return Object.setPrototypeOf(o,Object.getPrototypeOf(Ue(e))),o.key=e,Object.defineProperty(o,"stack",{get(){return n?.stack}}),s[gO]=gO,s.error=t?.error??Mi,s.requiredForClient=t?.requiredForClient??!1,o},Fue=(e,t)=>Ja(xt(function*(){let r=(yield*Nr()).pipe(H_(it)),n=Yr(t)?yield*t:t;return qn(new Map([[`${e.key}/Client`,o=>Xa(n(o),s=>Kr(r,s))]]))}));var T6=l.Union([l.Struct({_tag:l.Literal("List"),collection:l.String}),l.Struct({_tag:l.Literal("Item"),collection:l.String,id:l.Union([l.String,l.Number])})]),wf=(e,t)=>({item:r=>({_tag:"Item",collection:e,id:r}),list:{_tag:"List",collection:e},name:e});function w6(e){return e._tag==="List"?e.collection:`${e.collection}:${e.id}`}var jE=e=>[...new Set(e.map(w6))],HE=e=>[...new Set(e.flatMap(t=>t._tag==="List"?[t.collection]:[w6(t),t.collection]))];var Nue=ne.fn("EffectContract.invalidateAfter")(function*(e){yield*Wb(HE(e))});function Uue(e,t,r){function n(o){return jE(r.reads(o))}return{query:(o,s={})=>e.query(t,o,{...s,reactivityKeys:n(o)}),run:o=>e.use(s=>s(t,o))}}function Due(e,t,r){return{run:n=>e.use(o=>o(t,n)).pipe(ne.tap(o=>Nue(r.invalidates(n,o))))}}function Lue(e,t){return{run:r=>sn.unwrap(e.use(n=>ne.succeed(n(t,r))))}}function qE(e,t){let{name:r,queries:n,commands:o,streams:s}=e.declaration;return Object.fromEntries([...n.map(i=>[i.name,Uue(t,`${r}.${i.name}`,i)]),...o.map(i=>[i.name,Due(t,`${r}.${i.name}`,i)]),...s.map(i=>[i.name,Lue(t,`${r}.${i.name}`)])])}var v6=l.Union([l.Struct({_tag:l.Literal("Changed"),keys:l.Array(T6)}),l.Struct({_tag:l.Literal("Resync")})]),Bue=256;function C6(e,t){let r=tx(!1),n=tx({connection:"connecting",failure:ke.none(),needsResync:!0,pending:0});return{connection:e.atom(s=>ne.gen(function*(){s.mount(n);let i=yield*vc;function a(f){s.set(n,{...s.once(n),...f})}function c(){if(s.once(r)){a({needsResync:!0});return}i.invalidateUnsafe(jE(t.resyncKeys)),a({needsResync:!1,pending:0})}s.subscribe(r,f=>{f||c()}),t.resume!==void 0&&(s.once(t.resume),s.subscribe(t.resume,c));let u=ne.suspend(()=>{let f=!0;function p(m){a({connection:"live",failure:ke.none()}),s.once(r)?a({needsResync:!0,pending:Math.min(Bue,s.once(n).pending+1)}):f||m._tag==="Resync"?c():i.invalidateUnsafe(HE(m.keys)),f=!1}return t.stream.pipe(sn.runForEach(m=>ne.sync(()=>p(m))),ne.scoped,ne.catchCause(m=>ne.sync(()=>a({failure:ke.some(m)}))),ne.andThen(ne.sync(()=>a({connection:"reconnecting",needsResync:!0}))),ne.andThen(ne.sleep(t.retryDelay??"1 second")))});yield*ne.forever(u)})).pipe(rx(0)),paused:r,status:n}}function A6(e,t){return r=>{function n(){e.document.visibilityState==="visible"&&r()}return e.addEventListener(t,n),()=>e.removeEventListener(t,n)}}function k6({window:e,native:t}){let r=e===void 0?[]:[A6(e,"visibilitychange"),A6(e,"online")],n=t===void 0?r:[...r,t];return qi(o=>{let s=0;function i(){s+=1,o.setSelf(s)}for(let a of n)o.addFinalizer(a(i));return s})}function $ue(e){let t=e.map(({name:r})=>r).filter((r,n,o)=>o.indexOf(r)!==n);if(t.length>0)throw new Error(`Operation names must be unique; duplicated: ${[...new Set(t)].join(", ")}`)}function R6(e,t){let r=e.middleware.bind(e);return Object.assign(e,{declaration:t,middleware:n=>R6(r(n),t)})}function Pc(e,t){let{queries:r=[],commands:n=[],streams:o=[]}=t;$ue([...r,...n,...o]);let s=[...r,...n,...o].map(i=>Od.make(`${e}.${i.name}`,{error:i.error,payload:i.payload,stream:i.kind==="stream",success:i.success}));return R6($E.make(...s),{commands:n,name:e,queries:r,streams:o})}function O6(e){let t=Object.entries(e).map(([r,n])=>[r,l.isSchema(n)?n:l.TaggedError()(r,n)]);return{error:t.length===0?l.Never:l.Union(t.map(([,r])=>r)),Rejection:Object.fromEntries(t),reject:Object.fromEntries(t.map(([r,n])=>[r,(...o)=>ne.fail(Reflect.construct(n,o))]))}}function jue(e){return e===void 0?l.Void:l.isSchema(e)?e:l.Struct(e)}function yO(e,t,r){let{payload:n,success:o,rejections:s={}}=r;return{kind:e,name:t,payload:jue(n),rejections:s,success:o??l.Void,...O6(s)}}function Tt(e,t){return{...yO("query",e,t),reads:t.reads}}function ox(e,t){return{...yO("command",e,t),invalidates:t.invalidates}}function _6(e,t){return{...yO("stream",e,t),reads:t.reads}}var Fc={message:l.String},M6={field:l.optionalKey(l.String),message:l.String},sx=class extends l.TaggedError()("NotFound",Fc){},ix=class extends l.TaggedError()("Unauthorized",Fc){},Mc=class extends l.TaggedError()("Forbidden",Fc){},zE=class extends l.TaggedError()("BadRequest",M6){},ax=class extends l.TaggedError()("Conflict",M6){},WE=class extends l.TaggedError()("PreconditionFailed",Fc){},P6=class extends l.TaggedError()("TooManyRequests",Fc){},Fd=class extends l.TaggedError()("AuthUnavailable",Fc){},Hn=class extends l.TaggedError()("InternalServerError",Fc){},vf=class extends l.TaggedError()("ServiceUnavailable",Fc){};var Nc=class extends Tf.Service()("@shivaedev/platform/rpc/RequestTracing"){},F6=class extends Tf.Service()("@shivaedev/platform/rpc/Authenticated",{error:l.Union([ix,Fd,Mc])}){},N6=class extends Tf.Service()("@shivaedev/platform/rpc/MaybeAuthenticated",{error:l.Union([Fd,Mc])}){},U6=class extends Tf.Service()("@shivaedev/platform/rpc/AuthenticatedUser",{error:l.Union([ix,Fd,Mc])}){};var wt=l.String.check(l.isPattern(/^[a-zA-Z\d][a-zA-Z\d._-]*$/u));var Qs=l.String.check(l.isPattern(/^[a-f\d]{64}$/u)),D6=l.Literals(["answer","clarify","not_now"]),Hue=l.Struct({prompt:wt.check(l.isMaxLength(128)),selected:l.Array(wt.check(l.isMaxLength(128))).check(l.isMaxLength(32)),text:l.String.check(l.isMaxLength(8192))}),L6=l.Array(Hue).check(l.isMaxLength(32)),SO=l.Struct({deadline:l.Number.check(l.isFinite(),l.isGreaterThanOrEqualTo(0),l.isLessThanOrEqualTo(864e13)),item:wt,reason:l.String,registeredAt:l.Number.check(l.isFinite(),l.isGreaterThanOrEqualTo(0),l.isLessThanOrEqualTo(864e13)),request:wt,reviewedRevision:Qs,source:l.String}),KE=l.Struct({answers:l.optional(L6),author:l.String.check(l.isPattern(/\S/u),l.isMaxLength(200)),question:wt,recordedAt:l.Number.check(l.isFinite(),l.isGreaterThanOrEqualTo(0),l.isLessThanOrEqualTo(864e13)),reviewedRevision:Qs,supersedes:l.optional(wt),type:D6}),VE=l.Struct({context:l.String,id:wt,item:wt,reason:l.String,request:wt,reviewedRevision:Qs,source:l.String}),Nd=l.Struct({context:l.String,id:wt,question:SO}),Uc=l.Struct({body:l.String,id:wt,response:KE}),B6=l.Struct({question:Nd,responses:l.Array(Uc)}),$6=l.Struct({expired:l.Boolean,question:Nd,response:l.optional(Uc)}),j6=l.Struct({answers:l.optional(L6),author:KE.fields.author,body:l.String.check(l.isMaxLength(32768)),id:wt,question:wt,supersedes:l.optional(wt),type:D6});var GE=l.Struct({disposition:l.Literals(["applied","superseded"]),question:wt,recordedAt:l.Number.check(l.isFinite(),l.isGreaterThanOrEqualTo(0),l.isLessThanOrEqualTo(864e13)),response:l.optional(wt),reviewedRevision:Qs});var cx=l.String.check(l.isPattern(/\S/u),l.isMaxLength(8192)),ux=l.Struct({by:l.optional(cx),constraints:l.String.check(l.isMaxLength(8192)),goal:cx,item:wt,nextAction:cx,note:l.optional(cx),preparedAt:l.Number.check(l.isFinite(),l.isGreaterThanOrEqualTo(0),l.isLessThanOrEqualTo(864e13)),recipient:cx.check(l.isMaxLength(200)),reviewedRevision:Qs,source:l.String,state:l.Literals(["requested","acknowledged","rejected","unavailable"])}),bO=ux.pipe(l.encodeKeys({nextAction:"next_action",preparedAt:"prepared_at",reviewedRevision:"reviewed_revision"})),H6=l.Struct({constraints:ux.fields.constraints,goal:ux.fields.goal,id:wt,item:wt,nextAction:ux.fields.nextAction,recipient:ux.fields.recipient,revision:Qs,source:l.String}),EO=l.Struct({context:l.String,file:l.String,handoff:bO,id:wt,prompt:l.String}),JE=l.Struct({records:l.Array(EO),unknown:l.Array(l.String)}),ZE=l.Struct({context:l.String,id:wt,item:wt,reviewedRevision:Qs,source:l.String});var QE=wt,IO=l.String.check(l.isPattern(/^[a-zA-Z\d][a-zA-Z\d._-]*(?:#[a-zA-Z\d][a-zA-Z\d._-]*)?$/u)),fo=l.String.check(l.isPattern(/\S/u)),que=l.Struct({id:QE,kind:l.Literals(["decision","review","blocker"]),managed:l.optional(l.Boolean),reason:fo,responseFrom:l.Array(fo).check(l.isMinLength(1)),state:l.Literals(["open","closed"]),unblocks:l.Array(IO).check(l.isMinLength(1))}).pipe(l.encodeKeys({responseFrom:"response_from"})),zue=l.Struct({id:QE,text:fo}),Wue=l.Struct({kind:l.Literals(["implements","informs","depends_on","relates_to"]),target:IO}),Kue=l.Struct({checkedRevision:l.optional(l.String.check(l.isPattern(/^(?:[a-f\d]{40}|[a-f\d]{64})$/iu))),criterion:l.optional(IO),method:l.optional(fo),observedAt:l.optional(fo.check(l.makeFilter(e=>Number.isFinite(Date.parse(e))&&/^\d{4}-\d{2}-\d{2}T.*(?:Z|[+-]\d{2}:\d{2})$/u.exec(e)!==null||"Expected an ISO timestamp with timezone"))),outcome:l.optional(fo),source:fo}).pipe(l.encodeKeys({checkedRevision:"checked_revision",observedAt:"observed_at"})),Dc=l.Struct({areas:l.optional(l.Array(fo)),attention:l.optional(l.Array(que)),criteria:l.optional(l.Array(zue)),evidence:l.optional(l.Array(Kue)),handoff:l.optional(bO),id:l.optional(QE),items:l.optional(l.Array(QE)),kind:l.optional(l.Literals(["task","investigation","decision","result","project","board","question","response","handoff","goal","report"])),nextAction:l.optional(fo),options:l.optional(l.Array(l.Struct({description:fo.check(l.isMaxLength(8192)),label:fo.check(l.isMaxLength(128))})).check(l.isMaxLength(32))),owner:l.optional(fo),question:l.optional(SO),recommended:l.optional(fo),relationships:l.optional(l.Array(Wue)),requestReceipt:l.optional(GE),response:l.optional(KE),status:l.optional(fo)}).pipe(l.encodeKeys({nextAction:"next_action",requestReceipt:"request_receipt"}));var Vue=l.Struct({href:l.optional(l.String),label:l.String}),q6=l.Struct({backlinks:l.Array(l.Struct({href:l.String,kind:l.String,label:l.String,status:l.optional(l.String),title:l.optional(l.String)})),board:l.Boolean,claims:l.Record(l.String,l.Array(Vue)),evidenceSources:l.Array(l.Struct({href:l.optional(l.String),problem:l.String})),lines:l.Record(l.String,l.Number),proseLine:l.Number,raw:l.optional(l.String),receipts:l.Record(l.String,GE)});var TO=l.Struct({id:l.String,open:l.Boolean,options:Dc.to.fields.options,preview:l.optional(VE),prompts:l.optional(l.Array(l.Struct({id:l.String,mode:l.Literals(["one","many","text"]),options:l.Array(l.Struct({id:l.String,source:l.String})),source:l.String}))),promptUnavailable:l.optional(l.String),recommended:Dc.to.fields.recommended,responses:l.optional(l.Array(Uc)),sourceOpen:l.optional(l.Boolean),title:l.optional(l.String),unavailable:l.optional(l.String)}),ka=l.Struct({diagnostics:l.Array(l.Struct({field:l.optional(l.String),line:l.Number,message:l.String})),file:l.String,identity:l.optional(l.String),links:l.Record(l.String,l.String),metadata:Dc,modified:l.Number,questionActions:l.Record(l.String,l.String),reading:l.optional(q6),referenceDetails:l.optional(l.Record(l.String,l.Struct({status:l.optional(l.String),title:l.String}))),references:l.Record(l.String,l.String),requests:l.Array(TO),source:l.String,unavailable:l.Array(l.String),writable:l.Boolean});var z6=l.Struct({counts:l.Struct({goals:l.Number,library:l.Number,now:l.Number,system:l.Number}),home:l.optional(l.Struct({file:l.String,identity:l.optional(l.String)})),inboxCount:l.NullOr(l.Number)});var W6={folder:l.optional(l.String),kind:l.optional(l.String),showFleet:l.optional(l.Boolean),status:l.optional(l.String)},Gue=l.Struct({href:l.String,kind:l.String,modified:l.Number,path:l.String,status:l.String,title:l.String}),K6=l.Struct({files:l.Array(Gue),fleetCount:l.Number,folders:l.Array(l.Struct({count:l.Number,name:l.String,path:l.String})),kinds:l.Array(l.String),statuses:l.Array(l.String)});var Jue=l.Literals(["prepared","executing","adopting","reviewing","repairing","validating","delivering","completed","needs-human","released"]),wO=l.Number.check(l.isFinite(),l.isGreaterThanOrEqualTo(0)),YE=l.Struct({attentionOwner:l.optional(l.Literals(["maintainer","orchestrator","automation"])),prUrl:l.optional(l.String),stage:Jue,stageEnteredAt:l.NullOr(wO),updatedAt:l.NullOr(wO),workId:l.String}),vO=l.Struct({...YE.fields,completedAt:wO,stage:l.Literal("completed")}),V6=l.Struct({completed:l.Array(vO),items:l.Array(YE)});var G6=l.NullOr(l.Struct({file:l.String,metadata:Dc,title:l.String})),J6=l.Union([l.Struct({completed:l.Array(l.Struct({...vO.fields,document:G6})),items:l.Array(l.Struct({...YE.fields,document:G6})),state:l.Literal("ready")}),l.Struct({reason:l.String,state:l.Literal("unavailable")})]);var Zue=l.Literals(["now","board","table"]),Que=l.Literals(["title","owner","status"]),Z6=l.Struct({board:l.String,item:l.String,owner:l.String,query:l.String,sort:Que,status:l.String,view:Zue});var lx=l.Struct({file:l.String,fleetApproved:l.optional(l.Boolean),id:l.String,metadata:Dc,title:l.String,waiting:l.optional(l.String)}),Q6=l.Struct({boards:l.Array(lx),issues:l.Array(l.String),items:l.Array(lx),rows:l.Array(lx),selected:l.optional(ka),selectedOutside:l.Boolean,selectionProblem:l.optional(l.String),state:Z6,title:l.String,validBoard:l.Boolean}),fx=l.Struct({earlierAsks:l.optional(l.Number),file:l.String,href:l.String,id:l.String,modified:l.optional(l.Number),problem:l.optional(l.String),reason:l.String,responseFrom:l.optional(l.Array(l.String)),title:l.String}),Y6=l.Struct({agents:l.Array(fx),complete:l.Boolean,issues:l.Array(l.Struct({file:l.String,line:l.Number,message:l.String})),items:l.Array(fx),parked:l.Array(fx),resolved:l.Array(fx),sourceIssues:l.Boolean,you:l.Array(fx)}),X6=l.Struct({counts:l.Array(l.Struct({count:l.Number,title:l.String})),document:ka});var tK=l.Struct({done:l.Number,"in progress":l.Number,planned:l.Number}),Yue=l.Struct({counts:tK,evidence:l.Number,id:l.String,linked:l.Number,text:l.String}),eK=l.Struct({counts:tK,criteria:l.Array(Yue),id:l.String,linked:l.Number,nextAction:l.optional(l.String),openAsks:l.Number,owner:l.optional(l.String),status:l.optional(l.String),title:l.String,unlinked:l.Boolean}),rK=l.Struct({closedGoals:l.Array(eK),goals:l.Array(eK),items:l.Array(lx)});var CO=l.Struct({href:l.optional(l.String),label:l.String}),Xue=l.Struct({checkedRevision:l.optional(l.String),method:l.optional(l.String),observedAt:l.optional(l.String),outcome:l.optional(l.String),problem:l.String,source:CO}),nK=l.Struct({document:ka,feedback:l.Array(l.Struct({matching:l.Boolean,question:Nd,questionFile:l.String,response:Uc,responseFile:l.String,supersedesFile:l.optional(l.String)})),feedbackUnknown:l.Boolean,revision:l.String,targets:l.Array(l.Struct({available:l.Boolean,criteria:l.Array(l.Struct({claims:l.Array(Xue),link:CO,text:l.String})),link:CO,status:l.optional(l.String)}))});var oK=l.Struct({resetsAt:l.NullOr(l.Int.check(l.isGreaterThanOrEqualTo(0),l.isLessThanOrEqualTo(864e10))),usedPercent:l.Number.check(l.isFinite(),l.isGreaterThanOrEqualTo(0)),windowDurationMins:l.NullOr(l.Int.check(l.isGreaterThan(0)))}),iK=l.Struct({primary:l.NullOr(oK),secondary:l.NullOr(oK)}),AO=l.Int.check(l.isGreaterThanOrEqualTo(0)),sK=l.Struct({limit:AO,remaining:AO,reset:AO.check(l.isLessThanOrEqualTo(864e10))}),aK=l.Struct({core:sK,graphql:sK});var dx=l.Int.check(l.isGreaterThanOrEqualTo(0)),kO=l.Number.check(l.isFinite(),l.isGreaterThanOrEqualTo(0),l.isLessThanOrEqualTo(864e13)),efe=l.Struct({at:kO,cause:l.String.check(l.isMinLength(1),l.isMaxLength(500))}),tfe="health.json",WIe=`fleet/${tfe}`,cK=l.Struct({concurrency:l.Int.check(l.isGreaterThan(0)),lastCapacityRejection:l.NullOr(efe),lastSchedulerPass:l.NullOr(kO),observedAt:kO,queued:dx,running:dx,staleAfterMs:l.Int.check(l.isGreaterThan(0)),version:l.Literal(2),waiting:l.Struct({automation:dx,maintainer:dx,orchestrator:dx})});var uK=l.Number.check(l.isFinite(),l.isGreaterThanOrEqualTo(0),l.isLessThanOrEqualTo(864e13));function RO(e){return l.Union([l.Struct({observedAt:uK,state:l.Literal("ready"),value:e}),l.Struct({cause:l.String,observedAt:uK,state:l.Literals(["not-configured","error"])})])}var OO=l.Struct({codex:RO(iK),fleet:RO(cK),github:RO(aK)}),XIe=Pc("daemon",{queries:[Tt("diagnostics",{payload:{},reads:()=>[],success:OO}),Tt("fleetItems",{payload:{},reads:()=>[],success:V6})]});var fK=l.Struct({now:l.Number,sources:OO}),lK=l.Struct({empty:l.Boolean,templates:l.Array(l.Struct({file:l.String,label:l.String,source:l.String}))}),dK=l.Struct({document:ka,request:TO}),pK=l.Struct({background:l.String,goal:l.String,item:l.String,nextAction:l.String,reading:JE,source:l.optional(ZE),unavailable:l.optional(l.String),writable:l.Boolean});var Rt=wf("work-board/workspace",l.String),mK=wf("work-board/documents",l.String),hK=wf("work-board/identities",l.String),xK=wf("work-board/navigation",l.String),Dt=wf("work-board/index",l.String),gK=wf("work-board/watcher",l.String);var _O=class extends l.TaggedError()("PublicationUncertain",{message:l.String}){},PO=class extends l.TaggedError()("Unanswered",{message:l.String}){},Ys={BadRequest:zE,Conflict:ax,Forbidden:Mc,InternalServerError:Hn,NotFound:sx,PreconditionFailed:WE,PublicationUncertain:_O,ServiceUnavailable:vf,Unanswered:PO},lTe=l.Union(Object.values(Ys)),Lc={Conflict:ax,InternalServerError:Hn,NotFound:sx,ServiceUnavailable:vf},dTe=l.Union(Object.values(Lc));var rfe=Tt("handoffSource",{payload:{item:l.String},reads:()=>[Rt.list,Dt.list],rejections:Ys,success:ZE}),nfe=Tt("handoffs",{payload:{item:l.String},reads:()=>[Rt.list,Dt.list],rejections:Ys,success:JE}),ofe=ox("prepareHandoff",{invalidates:()=>[Rt.list,Dt.list],payload:H6,rejections:Ys,success:EO}),XE=Pc("work-board",{commands:[ofe],queries:[rfe,nfe]}).middleware(Nc);var sfe=Tt("question",{payload:{item:l.String,request:l.String},reads:()=>[Rt.list,Dt.list],rejections:Ys,success:VE}),ife=Tt("awaitResponse",{payload:{after:l.optional(l.String),question:l.String},reads:()=>[Rt.list,Dt.list],rejections:Ys,success:$6}),afe=Tt("responses",{payload:{question:l.String},reads:()=>[Rt.list,Dt.list],rejections:Ys,success:B6}),cfe=ox("registerQuestion",{invalidates:()=>[Rt.list,Dt.list],payload:{item:l.String,request:l.String,revision:Qs},rejections:Ys,success:Nd}),ufe=ox("recordResponse",{invalidates:()=>[Rt.list,Dt.list],payload:j6,rejections:Ys,success:Uc}),eI=Pc("work-board",{commands:[cfe,ufe],queries:[sfe,afe,ife]}).middleware(Nc);var Cf=l.String.check(l.isMaxLength(8192),l.makeFilter(e=>{if(!e.startsWith("/")||e.startsWith("//"))return"Expected a local reading URL";try{let t=new URL(e,"http://127.0.0.1").pathname;return t==="/"||["/_board/inbox","/_board/system","/_board/work","/_board/overview","/_board/changes","/_board/start","/_board/respond","/_board/handoff","/_board/result"].includes(t)||/^\/_board\/item\/[^/]+\/?$/u.exec(t)!==null||/\.md$/iu.exec(t)!==null||"Expected a local reading URL"}catch{return"Expected a local reading URL"}}));function tI(e){let t=new URL(e,"http://127.0.0.1").pathname,r=/^\/_board\/item\/(?<id>[^/]+)\/?$/u.exec(t)?.groups?.id,n=mK.item(decodeURIComponent(t.slice(1)));return r?n=hK.item(decodeURIComponent(r)):t.startsWith("/_board/")&&(n=Dt.list),[Rt.list,n]}var yK=l.Struct({directory:l.String,url:l.String});var ffe=l.Struct({file:l.String,href:l.String,id:l.optional(l.String),itemKind:l.optional(l.String),kind:l.Literals(["document","heading","passage"]),line:l.optional(l.Number),snippet:l.String,status:l.optional(l.String),text:l.String,title:l.String}),lfe=Tt("document",{payload:{url:Cf},reads:({url:e})=>[...tI(e),Dt.list],rejections:Lc,success:ka}),dfe=Tt("board",{payload:{url:Cf},reads:({url:e})=>tI(e),rejections:Lc,success:X6}),pfe=Tt("work",{payload:{url:Cf},reads:()=>[Rt.list,Dt.list],rejections:Lc,success:Q6}),mfe=Tt("inbox",{reads:()=>[Rt.list,Dt.list],rejections:{InternalServerError:Hn},success:Y6}),hfe=Tt("server",{reads:()=>[],rejections:{ServiceUnavailable:vf},success:yK}),xfe=Tt("diagnostics",{reads:()=>[Rt.list],rejections:{InternalServerError:Hn},success:fK}),gfe=Tt("fleetItems",{reads:()=>[Rt.list,Dt.list],success:J6}),yfe=Tt("goals",{reads:()=>[Rt.list,Dt.list],rejections:{InternalServerError:Hn},success:rK}),Sfe=Tt("start",{reads:()=>[Rt.list,Dt.list],rejections:{InternalServerError:Hn},success:lK}),bfe=Tt("respond",{payload:{url:Cf},reads:({url:e})=>[...tI(e),Dt.list],rejections:Lc,success:dK}),Efe=Tt("handoff",{payload:{url:Cf},reads:()=>[Rt.list,Dt.list],rejections:Lc,success:pK}),Ife=Tt("result",{payload:{url:Cf},reads:()=>[Rt.list,Dt.list],rejections:Lc,success:nK}),Tfe=Tt("library",{payload:W6,reads:()=>[Rt.list,Dt.list],rejections:{InternalServerError:Hn},success:K6}),wfe=Tt("navigation",{payload:{current:l.String.check(l.isMaxLength(8192))},reads:()=>[Rt.list,xK.list,Dt.list],rejections:{InternalServerError:Hn},success:z6}),vfe=Tt("search",{payload:{query:l.String.check(l.isMaxLength(8192))},reads:()=>[Rt.list,Dt.list],rejections:{InternalServerError:Hn},success:l.Struct({results:l.Array(ffe),total:l.Number,unavailable:l.Array(l.String)})}),Cfe=Tt("watcher",{reads:()=>[Rt.list,gK.list],rejections:{InternalServerError:Hn},success:l.Struct({watching:l.Boolean})}),MO=_6("subscribe",{reads:()=>[Rt.list],rejections:{InternalServerError:Hn},success:v6}),FO=Pc("work-board",{queries:[hfe,lfe,dfe,pfe,mfe,xfe,gfe,yfe,Sfe,bfe,Efe,Ife,wfe,Tfe,vfe,Cfe],streams:[MO]}).middleware(Nc),SK=FO.merge(eI).merge(XE);function bK(e,t={}){class r extends I6()("WorkBoard/Reader",{group:SK,protocol:ex.layerProtocolHttp({url:`${e}/_board/rpc`}).pipe(Fn.provide([iE.layer,Yh.layerNdjson]))}){}let n=qE(FO,r),o=MW({defaultIdleTTL:0,timeoutResolution:1}),s=C6(r.runtime,{resume:k6(t),resyncKeys:MO.reads(void 0),stream:n.subscribe.run(void 0)});o.mount(s.connection);async function i(f,p){try{return await ne.runPromise(Dh(o,f,{suspendOnWaiting:!0}),{signal:p})}catch(m){if(p?.aborted){let h=new Error("Reading canceled",{cause:m});throw h.name="AbortError",h}throw m}}async function a(f,p){try{return await ne.runPromise(ne.flatMap(Dh(o,r.runtime),m=>ne.provideContext(f,m)),{signal:p})}catch(m){if(p?.aborted){let h=new Error("Reading canceled",{cause:m});throw h.name="AbortError",h}throw m}}async function c(f,p){let m=await ne.runPromise(ne.result(Dh(o,r.runtime.atom(f),{suspendOnWaiting:!0})),{signal:p});if(m._tag==="Failure")throw m.failure;return m.success}let u=qE(eI,r);return{api:n,handoffs:qE(XE,r),mutate:c,read:i,registry:o,responses:u,run:a,updates:s}}var rI=new WeakMap;function EK(e){let t=rI.get(e);if(t===void 0){let o=function(){n.registry.dispose(),rI.get(e)===n&&rI.delete(e),e.removeEventListener("pagehide",o)};var r=o;t=bK(e.location.origin,{window:e}),rI.set(e,t);let n=t;e.addEventListener("pagehide",o)}return t}var g0e=EK;export{g0e as session};
36
+ `}}}})},i6=NE(),a6=e=>fn.of({contentType:e?.contentType??"application/json",includesFraming:!1,codecFor:FE,makeUnsafe:()=>{let t=new Map;return{decode:r=>{let n=JSON.parse(typeof r=="string"?r:o6(r));return u6(n,t)},encode:r=>{let n=f6(r,t);return n&&JSON.stringify(n)}}}}),c6=e=>fn.of({contentType:e?.contentType??"application/json-rpc",includesFraming:!0,codecFor:FE,makeUnsafe:()=>{let t=NE({maxBufferSize:e?.maxBufferSize}).makeUnsafe(),r=new Map;return{decode:n=>{let o=t.decode(n);if(o.length===0)return[];let s=[];for(let i=0;i<o.length;i++)s.push(...u6(o[i],r));return s},encode:n=>{let o=f6(n,r);return o&&t.encode(o)}}}});function u6(e,t){if(Array.isArray(e)){let r={size:0,responses:new Map},n=[];for(let o=0;o<e.length;o++){let s=e[o];if(!Jt(s))continue;let i=r6(s);n.push(i),i._tag==="Request"&&!i.isNotification&&(r.size++,t.set(i.id,r))}return n}return Jt(e)?[r6(e)]:[]}function r6(e){if(Object.hasOwn(e,"method")){let n=e;if($O(n.id)&&On(n.method)&&n.method.startsWith("@effect/rpc/")){let o=n.method.slice(12),s=n.params?.requestId;return s!==void 0?{_tag:o,requestId:s}:{_tag:o}}return{_tag:"Request",id:n.id??"",tag:n.method,payload:n.params??null,headers:n.headers??[],...O(n,"id")?{}:{isNotification:!0},...n.spanId?{traceId:n.traceId,spanId:n.spanId,sampled:n.sampled}:{}}}let t=e,r=Object.hasOwn(t,"error");return r&&t.error&&t.error._tag==="Defect"?{_tag:"Defect",defect:t.error.data}:Object.hasOwn(t,"chunk")&&t.chunk===!0?{_tag:"Chunk",requestId:t.id??"",values:t.result}:{_tag:"Exit",requestId:t.id??"",exit:r&&t.error!=null?{_tag:"Failure",cause:t.error._tag==="Cause"?t.error.data:[{_tag:"Fail",error:t.error}]}:{_tag:"Success",value:t.result}}}function n6(e,t){if(!("requestId"in e))return sO(e);let r=t.get(e.requestId);return r?(t.delete(e.requestId),r.responses.set(e.requestId,e),r.size===r.responses.size?Array.from(r.responses.values(),sO):void 0):sO(e)}function f6(e,t){if(Array.isArray(e)===!1)return n6(e,t);if(e.length===0)return;let r=[];for(let o=0;o<e.length;o++){let s=n6(e[o],t);s!==void 0&&r.push(s)}if(r.length===0)return;if(r.length===1)return r[0];let n=[];for(let o=0;o<r.length;o++){let s=r[o];Array.isArray(s)?n.push(...s):n.push(s)}return n}function sO(e){switch(e._tag){case"Request":return{jsonrpc:"2.0",method:e.tag,params:e.payload,...e.isNotification?{}:{id:e.id},...e.headers?.length>0?{headers:e.headers}:{},traceId:e.traceId,spanId:e.spanId,sampled:e.sampled};case"Ping":case"Pong":case"Interrupt":case"Ack":case"Eof":return{jsonrpc:"2.0",method:`@effect/rpc/${e._tag}`,params:"requestId"in e?{requestId:e.requestId}:void 0};case"Chunk":return{jsonrpc:"2.0",chunk:!0,id:e.requestId,result:e.values};case"Exit":{if(e.exit._tag==="Success")return{jsonrpc:"2.0",id:e.requestId??void 0,result:e.exit.value};let t=e.exit.cause.find(n=>n._tag==="Fail"),r=t?._tag==="Fail"?t.error:void 0;return{jsonrpc:"2.0",id:e.requestId??void 0,error:e.exit._tag==="Failure"?{_tag:"Cause",code:r&&O(r,"code")?Number(r.code):0,message:r&&O(r,"message")?r.message:JSON.stringify(e.exit.cause),data:e.exit.cause}:void 0}}case"Defect":return{jsonrpc:"2.0",id:Vce,error:{_tag:"Defect",code:1,message:"A defect occurred",data:e.defect}};case"ClientProtocolError":return{}}}var Vce=-32603,Gce=16*1024*1024,Jce=new TextEncoder,Zce=e=>{let t=e?.maxFrameSize==="unbounded"?void 0:e?.maxFrameSize??Gce,r=e?.fingerprintPayloads===!0?o=>JR(o,{fingerprint:!0}):JR,n={fingerprint:!0};return fn.of({contentType:"application/vnd.effect.rpc+schema-binary",includesFraming:!0,codecFor:r,makeUnsafe:()=>{let o=l4(FR,{...n,maxFrameSize:t}),s=p4(FR,n);return{decode:i=>o.feedSync(typeof i=="string"?Jce.encode(i):i),encode:i=>{if(!Array.isArray(i))return s.encode(i);if(i.length!==0)return s.encodeMany(i)}}}})},Qce=Ja(fn)(s6),Yce=Ja(fn)(i6),Xce=e=>Ja(fn)(NE(e)),eue=e=>Ja(fn)(a6(e)),tue=e=>Ja(fn)(c6(e)),rue=e=>h0(fn)(()=>Zce(e));var UE=class extends Ue()("effect/rpc/RpcWorker/InitialMessage"){};var d6=e=>L(()=>{let t=new Set,r=new Map,n=new Map,o=(s,i)=>yn(a=>{let c=r.get(s);return c||(c=[],r.set(s,c)),c.push([i,a]),P});return K(e((s,i)=>{let a=n.get(s);return a?a(i):o(s,i)},t),s=>({...s,run(i,a){return xt(function*(){t.add(i),n.set(i,a);let c=r.get(i);if(c){r.delete(i);for(let[u,f]of c)yield*Ur(L(()=>a(u)),f)}return yield*Xr(Xn,()=>(t.delete(i),n.delete(i),P))})}}))});var oue=e=>Or(e,"RpcClientError"),sue=0,p6=me(function*(e,t){let r=t.spanPrefix,n=t?.supportsAck??!0,o=t?.disableTracing??!1,s=t?.generateRequestId??(()=>sue++),i=yield*Nr(),a=Re(i,it),c=new Map,u=!1;yield*It(a,ar(b=>(u=!0,f(Lg(b.id)))));let f=me(function*(b){for(let[v,T]of c)c.delete(v),T._tag==="Queue"?yield*b._tag==="Success"?yd(T.queue):Ht(T.queue,b.cause):T.resume(b)}),p=b=>{let v=Bh(b.successSchema),T=x(b);return(S,w)=>{let k=w?.headers?Zo(w.headers):kl,A=w?.context??pt();if(!v){let M=$=>m(b,T,$,b.payloadSchema.make(S),k,A,w?.discard??!1);return o?M(void 0):Qp(vR(r,b._tag),{kind:"client",attributes:AR(b._tag,t.spanAttributes)},M)}let R=h(b,T,b.payloadSchema.make(S),k,w?.streamBufferSize??16,A);return w?.asQueue?R:An(K(R,Sh))}},m=(b,v,T,S,w,k,A)=>ar(R=>{if(u)return Dn;let M=s(),$=v(xe=>t.onFromClient({message:xe,context:k,discard:A}),{_tag:"Request",id:M,tag:b._tag,payload:S,...T?{traceId:T.traceId,spanId:T.spanId,sampled:T.sampled}:{},headers:Rl(R.getRef(DE),w)});if(A)return $;let te;return bu(Nn(xe=>{let Le={_tag:"Effect",rpc:b,context:k,resume(Er){xe(Er),te&&!te.pollUnsafe()&&R.currentDispatcher.scheduleTask(()=>{te.interruptUnsafe(R.id)},0)}};c.set(M,Le),te=$.pipe(T?bl(T,{captureStackTrace:!1}):F,Sr(R.context)),te.addObserver(Er=>{if(Er._tag==="Failure")return xe(Er)})}),xe=>(c.delete(M),Vt(Tn(te),g(M,Array.from(xe),k))))}),h=me(function*(b,v,T,S,w,k){if(u)return yield*Dn;let A=o?void 0:yield*ow(vR(r,b._tag),{kind:"client",attributes:AR(b._tag,t.spanAttributes)}),R=os(),M=s(),$=dn(R.context,it),te=yield*af(w);return yield*Wo($,xe=>(zC(te),c.has(M)?(c.delete(M),g(M,vs(xe)?Array.from(SN(xe.cause)):[],k)):P)),c.set(M,{_tag:"Queue",rpc:b,queue:te,scope:$,context:k}),yield*v(xe=>t.onFromClient({message:xe,context:k,discard:!1}),{_tag:"Request",id:M,tag:b._tag,payload:T,...A?{traceId:A.traceId,spanId:A.spanId,sampled:A.sampled}:{},headers:Rl(R.getRef(DE),S)}).pipe(A?bl(A,{captureStackTrace:!1}):F,to(xe=>Ht(te,xe)),vi,gt($,{startImmediately:!0})),te}),x=b=>{let v=[];for(let T of b.middlewares.values()){let S=Gi(i,`${T.key}/Client`);S&&v.push(S)}return v.length===0?(T,S)=>T(S):function T(S,w,k=v.length-1){return k===-1?S(w):v[k]({rpc:b,request:w,next(A){return T(S,A,k-1)}})}},g=(b,v,T)=>Nn(S=>{let w=os();t.onFromClient({message:{_tag:"Interrupt",requestId:b,interruptors:v},context:T,discard:!1}).pipe(G0(1e3),Sr(w.context)).addObserver(()=>{S(P)})}),y=b=>{switch(b._tag){case"Chunk":{let v=b.requestId,T=c.get(v);return!T||T._tag!=="Queue"?P:wa(T.queue,b.values).pipe(n?C(()=>t.onFromClient({message:{_tag:"Ack",requestId:b.requestId},context:T.context,discard:!1})):F,rt(S=>Ht(T.queue,S)))}case"Exit":{let v=b.requestId,T=c.get(v);return T?(c.delete(v),T._tag==="Effect"?(T.resume(b.exit),P):b.exit._tag==="Success"?yd(T.queue):Ht(T.queue,b.exit.cause)):P}case"Defect":return f(Dg(b.defect));case"ClientEnd":return P}},E;if(t.flatten){let b=new Map;E=function(T,S,w){let k=b.get(T);return k||(k=p(e.requests.get(T)),b.set(T,k)),k(S,w)}}else E={},e.requests.forEach(b=>{B(E,b._tag,p(b))});return{client:E,write:y}}),iue=0,iO=me(function*(e,t){let r=iue++,{codecFor:n,run:o,send:s,supportsAck:i,supportsTransferables:a}=yield*Hi,c=aue(n),u=Zm(n(er())),f=new Map,p=x=>f.has(x)?(f.delete(x),s(r,{_tag:"Interrupt",requestId:x})):P,{client:m,write:h}=yield*p6(e,{...t,supportsAck:i,onFromClient({message:x}){switch(x._tag){case"Request":{let g=e.requests.get(x.tag),y=a?LW():void 0,E=os(),b={rpc:g,context:y?We(E.context,Lh,y):E.context,schemas:c(g)};return f.set(x.id,b),b.schemas.encodePayload(x.payload).pipe(Ur(b.context),Ii,C(v=>s(r,{...x,id:x.id,payload:v,headers:Object.entries(x.headers)},y&&y.readUnsafe())))}case"Ack":return f.get(x.requestId)?s(r,{_tag:"Ack",requestId:x.requestId}):P;case"Interrupt":return p(x.requestId);case"Eof":return P}}});return yield*o(r,x=>{switch(x._tag){case"Chunk":{let g=MR(x.requestId),y=f.get(g);if(!y||fe(y.schemas.decodeChunk))return P;let E=y.schemas.decodeChunk.value;return en(b=>b(E(x.values).pipe(Ur(y.context),Ii,C(v=>h({_tag:"Chunk",clientId:0,requestId:g,values:v})))).pipe(to(v=>h({_tag:"Exit",clientId:0,requestId:g,exit:ir(v)}).pipe(Vt(fl(v)?P:cy(p(g))))),K0(v=>!fl(v),()=>P)))}case"Exit":{let g=MR(x.requestId),y=f.get(g);return y?(f.delete(g),y.schemas.decodeExit(x.exit).pipe(Ur(y.context),Ii,Un({onSuccess:E=>h({_tag:"Exit",clientId:0,requestId:g,exit:E}),onFailure:E=>h({_tag:"Exit",clientId:0,requestId:g,exit:ir(E)})}))):P}case"Defect":return h({_tag:"Defect",clientId:0,defect:u(x.defect)});case"ClientProtocolError":{let g=Jn(x.error);return Ko(Array.from(f.keys()),y=>h({_tag:"Exit",clientId:0,requestId:y,exit:g}))}default:return P}}).pipe(rt(Xp),vi,Rs),m}),aue=e=>{let t=new WeakMap;return r=>{let n=t.get(r);if(n!==void 0)return n;let o=dE(r.successSchema);return n={decodeChunk:Lt(o,s=>gc(e(Xu(s.success)))),encodePayload:oC(e(r.payloadSchema)),decodeExit:gc(e(_R(r)))},t.set(r,n),n}},DE=Ae("effect/rpc/RpcClient/CurrentHeaders",{defaultValue:()=>kl}),cue=d(2,(e,t)=>tw(e,DE,Rl(Zo(t)))),Hi=class extends Ue()("effect/rpc/RpcClient/Protocol"){static make=d6},m6=e=>Hi.make(me(function*(t){let r=yield*fn,n=r.includesFraming,o=u=>new Zs({reason:wd.fromHttpClientError(u)}),s=(u,f)=>new Zs({reason:new Oc({message:u,cause:f})}),i=u=>s("Received empty HTTP response from RPC server",u),a=u=>s("HTTP response ended before RPC request completed",u);return{send:me(function*(u,f){if(f._tag!=="Request")return;let p=r.makeUnsafe(),m=p.encode(f),h=typeof m=="string"?zk(m,r.contentType):qk(m,r.contentType),x=yield*e.post("",{body:h}).pipe(yl(o));if(!n){let E=yield*x.text.pipe(yl(o)),b=yield*Go({try:()=>p.decode(E),catch:T=>s("Error decoding HTTP response",T)});if(!Array.isArray(b))return yield*s("Expected an array of responses",b);if(b.length===0)return yield*i(f);let v=!1;for(let T=0;T<b.length;T++){let S=b[T];NR(S)&&(v=!0),yield*t(u,S)}return v?void 0:yield*a(f)}let g=!1,y=!1;if(yield*Td(x.stream,E=>Go({try:()=>E.flatMap(p.decode),catch:b=>s("Error decoding HTTP response",b)}).pipe(C(b=>{if(b.length===0)return P;g=!0;let v=0;return xn({while:()=>v<b.length,body:()=>{let T=b[v++];return NR(T)&&(y=!0),t(u,T)},step:Rr})}))).pipe(yl(E=>oue(E)?E:o(E))),g){if(!y)return yield*a(f)}else return yield*i(f)}),supportsAck:!1,supportsTransferables:!1,codecFor:r.codecFor}})),uue=e=>Qn(Hi)(C(Xk,t=>(t=vW(t,hW(e.url)),m6(e.transformClient?e.transformClient(t):t)))),h6=e=>Hi.make(me(function*(t,r){let n=yield*RW,o=yield*fn,s=yield*Su(Xh),i=new Map,a=yield*n.writer,c=o.makeUnsafe(),u=yield*lue(L(()=>a.write(c.encode(HW))),e),f=uy(e?.onPingTimeout??P,{log:!0,message:"RpcClient onPingTimeout hook failed"}),p,m=g=>Ko(r,y=>t(y,g)),h=g=>(p=g,m({_tag:"ClientProtocolError",error:g})),x=g=>{try{let y=c.decode(g);if(y.length===0)return P;u.onFrame();let E=0;return xn({while:()=>E<y.length,body:()=>{let b=y[E++];if(b._tag==="Pong")return P;if(Object.hasOwn(b,"requestId")){let v=b.requestId,T=i.get(v);if(T!==void 0)return b._tag==="Exit"&&i.delete(v),t(T,b)}return m(b)},step:Rr})}catch(y){return m({_tag:"ClientProtocolError",error:new Zs({reason:new Oc({message:"Error decoding message",cause:y})})})}};return yield*L(()=>{c=o.makeUnsafe(),u.reset();let g=!1;return xt(function*(){let{pull:y}=yield*n.reader;for(p=void 0,g=!0,de(s)&&(yield*s.value.onConnect);;){let E=yield*y;for(let b=0;b<E.length;b++)yield*x(E[b])}}).pipe(tc,Xa(u.timeout),Vt(()=>g?f:P),Vt(()=>D(new _h({reason:new Oh({cause:new Error("ping timeout")})}))))}).pipe(de(s)?wi(s.value.onDisconnect):F,Jp(g=>{let y=ul(g),E=tt(y),b=new Zs({reason:E?y.success.reason:new Oc({message:"Unknown socket error",cause:lu(g)})});return e?.retryTransientErrors&&E&&y.success.reason._tag==="SocketOpenError"?(e.onTransientError?.(b)??P).pipe(uy({log:!0,message:"RpcClient onTransientError hook failed"})):h(b)}),V0(e?.retryPolicy??fue,g=>h(new Zs({reason:g.reason}))),py({module:"RpcClient",method:"makeProtocolSocket"}),Rs),{send(g,y){if(p)return D(p);y._tag==="Request"&&i.set(y.id,g);let E=c.encode(y);return E===void 0?P:Ii(a.write(E))},supportsAck:!0,supportsTransferables:!1,codecFor:o.codecFor}})),fue=dU([pU(500,1.5),hl(5e3)]),lue=me(function*(e,t){let r=yield*Yn,n=t?.pingInterval??"5 seconds",o=Wt(t?.pingTimeout??n),s=r.currentTimeMillisUnsafe(),i=jr(),a=()=>{s=r.currentTimeMillisUnsafe()},c=()=>{a(),i.closeUnsafe()};return yield*L(()=>r.currentTimeMillisUnsafe()-s>o?i.open:e).pipe(ca(n),cy,Mt,vi,Rs),{timeout:i.await,reset:c,onFrame:a}}),due=e=>Qn(Hi)(h6(e)),x6=e=>Hi.make(me(function*(t,r){let n=yield*lE,o=yield*Ao,s=0,i=yield*Su(UE),a=yield*Su(Xh),c=new Map,u=h=>Ko(r,x=>t(x,h)),f=xt(function*(){let h=s++,x=yield*n.spawn(h);return yield*x.run(g=>{if(g._tag==="Exit"){let y=c.get(g.requestId);if(y)return c.delete(g.requestId),y.latch.openUnsafe(),t(y.clientId,g)}else if(g._tag==="Defect"){for(let[y,E]of c)c.delete(y),E.latch.openUnsafe();return u(g)}else if("requestId"in g){let y=c.get(g.requestId);if(y)return t(y.clientId,g)}return u(g)},{onSpawn:de(i)?C(i.value,([g,y])=>Ii(x.send({_tag:"InitialMessage",value:g},y))):void 0}).pipe(Jp(g=>{for(let[E,b]of c)b.worker===x&&(c.delete(E),b.latch.openUnsafe());let y=ul(g);return u({_tag:"ClientProtocolError",error:new Zs({reason:tt(y)?y.success.reason:new Oc({message:"Error in worker",cause:lu(g)})})})}),ay(hl(1e3)),py({module:"RpcClient",method:"makeProtocolWorker"}),vi,Rs),x}),p="minSize"in e?yield*Kz({acquire:f,min:e.minSize,max:e.maxSize,concurrency:e.concurrency,targetUtilization:e.targetUtilization,timeToLive:e.timeToLive}):yield*Wz({acquire:f,size:e.size,concurrency:e.concurrency,targetUtilization:e.targetUtilization});yield*It(o,W(()=>{for(let h of c.values())h.latch.openUnsafe();c.clear()}));let m=(h,x,g)=>{switch(x._tag){case"Request":return Fk(p).pipe(C(y=>{let E=jr(!1);return c.set(x.id,{clientId:h,worker:y,latch:E}),C(y.send(x,g),()=>E.await)}),tc,Ii);case"Interrupt":{let y=c.get(x.requestId);return y?(c.delete(x.requestId),y.latch.openUnsafe(),Ii(y.worker.send(x))):P}case"Ack":{let y=c.get(x.requestId);return y?Ii(y.worker.send(x)):P}}return P};return yield*tc(Fk(p)),de(a)&&(yield*a.value.onConnect),{send:m,supportsAck:!0,supportsTransferables:!0,codecFor:nf}})),pue=jc(x6,Qn(Hi)),Xh=class extends Ue()("effect/rpc/RpcClient/ConnectionHooks"){};var LE="~effect/reactivity/Atom",S6=e=>O(e,LE),cO="~effect/reactivity/Atom/Writable",rx=d(2,(e,t)=>{let r=$e(t),n=Wn(r);return Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,keepAlive:!n,idleTTL:n?Wt(r):void 0})}),Tf=rx(0),fO={[LE]:LE,equals:Object.is,...wr,toJSON(){return{_id:"Atom",keepAlive:this.keepAlive,lazy:this.lazy,label:this.label}}},mue={...fO,atom(e,t){let r=b6(e,t);return qi(n=>{let o=n.self(),s=n(this);return s._tag!=="Success"?Mh(s,o):r(n,s.value)})},fn(e,t){return arguments.length===0?(r,n)=>g6(this,r,n):g6(this,e,t)},pull(e,t){let r=Tf(lO(0)),n=qi(o=>{let s=o.self(),i=o(this);return i._tag!=="Success"?Mh(i,s):BE(o,wue(o,r,e,t),Aa(!0),i.value)});return vue(r,n)},subscriptionRef(e){return Eue(Tf(qi(t=>{let r=t.self(),n=t(this);if(n._tag!=="Success")return Mh(n,r);let o=typeof e=="function"?e(t):e;return vh(o)?o:BE(t,o,Aa(!0),n.value)})),(t,r)=>{let n=dR(t(this));return bue(t,r,n)})}},g6=(e,t,r)=>{let[n,o,s]=Tue(r?.reactivityKeys?(i,a)=>{let c=t(i,a);return Yr(c)?zb(c,r.reactivityKeys):Eh(c,Wb(r.reactivityKeys))}:t,r);return nx(i=>{i.get(s);let a=i.self(),c=i.get(e);return c._tag!=="Success"?Mh(c,a):n(i,c.value)},o)},hue={...fO,[cO]:cO},xue=e=>cO in e,qi=(e,t)=>{let r=Object.create(fO);return r.keepAlive=!1,r.lazy=!0,r.read=e,r.refresh=t,r},nx=(e,t,r)=>{let n=Object.create(hue);return n.keepAlive=!1,n.lazy=!0,n.read=e,n.write=t,n.refresh=r,n};function gue(e,t){e.setSelf(t)}var tx=(e,t)=>{let r=b6(e,t);return LE in r?r:qi(r)},b6=(e,t)=>{if(typeof e=="function"&&!Yr(e)&&!Ce(e)){let r=e;return function(n,o){let s=r(n);switch(typeof s){case"function":case"object":return s===null?s:E6 in s?uO(n,s,t,o):yue in s?y6(n,s,t,o):s;default:return s}}}else{if(Yr(e))return function(r,n){return uO(r,e,t,n)};if(Ce(e))return function(r,n){return y6(r,e,t,n)}}return lO(e)},E6="~effect/Effect",yue="~effect/Stream",lO=e=>nx(function(t){return e},gue),uO=(e,t,r,n)=>{let o=r?.initialValue!==void 0?us(r.initialValue):Aa();return BE(e,t,o,n,r?.uninterruptible)};function BE(e,t,r,n=pt(),o=!1){let s=e.self(),i=Zn();e.addFinalizer(()=>{Sr(n)(Ve(i,Kt))});let a,c=!1,u=dO(n.pipe(We(it,i),We(fE,e.registry),We(Ba,e.registry.scheduler)),t,function(f){a=fR(f,s),c&&e.setSelf(a)},o);return c=!0,u!==void 0&&e.addFinalizer(u),a!==void 0?a:s._tag==="Some"?uE(s):Ph(r)}function dO(e,t,r,n=!1){if(ws(t)){r(t);return}let s=Sr(e)(t);s.currentDispatcher?.flush();let i=s.pollUnsafe();if(i){r(i);return}let a=s.addObserver(r);function c(){a(),n||s.interruptUnsafe()}return c}function Sue(e){let t=e?.memoMap??Tf(tx(()=>xi())),r=i=>S6(t)?i(t):t,n=Kb;function o(i){let a=Object.create(mue);a.keepAlive=!1,a.lazy=!0,a.refresh=void 0,a.factory=o;let c=xO(qi(typeof i=="function"?u=>Pp(i(u),n):()=>Pp(i,n)));return a.layer=c,a.read=function(f){let p=f(c),m=C(Ao,h=>gi(p,r(f),h));return uO(f,m,{uninterruptible:!0})},a}o.memoMap=t,o.addGlobalLayer=i=>{n=Pp(n,Cs(i,Kb))};let s=Tf(tx(i=>yn(a=>gi(Kb,r(i),Re(a,it))).pipe(K(Re(Ac)))));return o.withReactivity=i=>a=>Aue(a,c=>{let u=dR(c(s));return c.addFinalizer(u.registerUnsafe(i,()=>{c.refresh(a)})),c.subscribe(a,f=>c.setSelf(f)),c.once(a)},{initialValueTarget:a}),o}var pO=Sue(),xEe=pO.withReactivity,y6=(e,t,r,n)=>{let o=r?.initialValue!==void 0?us(r.initialValue):Aa();return mO(e,t,o,n)};function mO(e,t,r,n=pt()){let o=e.self();n=We(n,fE,e.registry);let s=Sl(a=>C(as(t.channel,a),c=>xn({while:nr,body:()=>c,step(u){e.setSelf(us(jf(u),{waiting:!0}))}}))).pipe(rt(a=>(wo(a)?Ud(e.self(),gs(lR),Zt({onNone:()=>e.setSelf(MW(new ll,{previous:e.self()})),onSome:c=>e.setSelf(us(c))})):e.setSelf(Cd(a,{previous:e.self()})),P))),i=dO(n.pipe(We(fE,e.registry),We(Ba,e.registry.scheduler)),s,Rr,!1);return i!==void 0&&e.addFinalizer(i),o._tag==="Some"?uE(o):Ph(r)}var bue=(e,t,r=pt())=>vh(t)?(e.addFinalizer(Bk(t).pipe(Td(n=>{for(let o=0;o<n.length;o++)e.setSelf(n[o]);return P}),sw(r))),cw(r)(eW(t))):t._tag!=="Success"?t:mO(e,Bk(t.value),Aa(!0),r),Eue=(e,t)=>{function r(n,o){let s=n.get(e);vh(s)?Ci($k(s,o)):Ad(s)&&Ci($k(s.value,o))}return nx(n=>{let o=n(e);return vh(o)||Ad(o)?t(n,o):o},r)};var Iue=Symbol.for("effect/reactivity/atom/Atom/Reset"),aO=Symbol.for("effect/reactivity/atom/Atom/Interrupt");function Tue(e,t){let r=Tf(lO([0,void 0])),n=t?.initialValue!==void 0?us(t.initialValue):Aa(),o=t?.concurrent?Tf(qi(a=>{let c=new Set;return a.addFinalizer(()=>c.forEach(u=>u.interruptUnsafe())),c})):void 0;function s(a,c){let u=o?a(o):void 0;a.isFn=!0;let[f,p]=a.get(r);if(f===0)return n;if(p===aO)return Cd(gN(),{previous:a.self()});let m=e(p,a);return E6 in m?(u&&(m=C(Il(m,{startImmediately:!0}),x=>{u.add(x);let g=Array.from(u);return x.addObserver(()=>u.delete(x)),K(eb(g),y=>y[0])})),BE(a,m,n,c,!1)):mO(a,m,n,c)}function i(a,c){kue(()=>{c===Iue?a.set(r,[0,void 0]):c===aO?a.set(r,[a.get(r)[0]+1,aO]):a.set(r,[a.get(r)[0]+1,c]),a.refreshSelf()})}return[s,i,r]}var wue=(e,t,r,n)=>C(kk(typeof r=="function"?r(e):r),o=>{let i=os().context,a=Qt(),c=Un(o,{onFailure(f){return wo(f)?bt(a)?I({done:!0,items:a}):D(new ll("Atom.pull: no items")):je(f)},onSuccess(f){let p;return n?.disableAccumulation?p=f:(p=up(a,f),a=p),I({done:!1,items:p})}}),u=new Set;return e.addFinalizer(()=>{for(let f of u)f()}),e.once(t),e.subscribe(t,()=>{e.setSelf(uE(e.self()));let f;f=dO(i,c,p=>{f&&u.delete(f);let m=fR(p,e.self()),h=u.size>0;e.setSelf(h?Ph(m):m)}),f&&u.add(f)}),c}),vue=(e,t)=>nx(t.read,function(r,n){r.set(e,r.get(e)+1)}),hO=typeof WeakRef>"u"||typeof FinalizationRegistry>"u"?e=>{let t=Si();return function(r){let n=Qr(t,r);if(n._tag==="Some")return n.value;let o=e(r);return bi(t,r,o),o}}:e=>{let t=Si(),r=new FinalizationRegistry(n=>{let o=Qr(t,n);o._tag==="Some"&&o.value.deref()===void 0&&Ei(t,n)});return function(n){let o=Qr(t,n).pipe(_I(i=>i.deref()));if(o._tag==="Some")return o.value;let s=e(n);return bi(t,n,new WeakRef(s)),r.register(s,n),s}};var xO=e=>Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,keepAlive:!0});var Aue=d(e=>S6(e[0]),(e,t,r)=>{let n=Tf(xue(e)?nx(o=>t(o,e),function(o,s){o.set(e,s)},e.refresh??function(o){o(e)}):qi(o=>t(o,e),e.refresh??function(o){o(e)}));return r?.initialValueTarget&&(n.initialValueTarget=Cue(r.initialValueTarget)),n}),Cue=e=>{let t=e;for(;t.initialValueTarget;)t=t.initialValueTarget;return t};var kue=UW;var Rue="~effect-atom/atom/Atom/Serializable";var gO=d(2,(e,t)=>{let r=nf(t.schema);return Object.assign(Object.create(Object.getPrototypeOf(e)),{...e,label:e.label??[t.key,Ir()===0?"":new Error().stack?.split(`
37
+ `)[5]??""],[Rue]:{key:t.key,encode:sC(r),decode:Zm(r)}})});var T6=()=>(e,t)=>{let r=Ue()(e),n=Qn(r,t.makeEffect??iO(t.group,{...t,flatten:!0})),o=t.runtime??pO;r.runtime=o(typeof t.protocol=="function"?i=>Cs(n,Vg(t.protocol(i))):Cs(n,Vg(t.protocol))),r.mutation=hO(i=>{let a=t.group.requests.get(i);return r.runtime.fn()(me(function*({headers:c,payload:u,reactivityKeys:f}){let m=(yield*r)(i,u,{headers:c});return yield*f?zb(m,f):m})).pipe(gO({key:`AtomRpc:mutation:${i}`,schema:pR({success:a.successSchema,error:I6(a)})}))});let s=hO(i=>{let{headers:a,payload:c,reactivityKeys:u,tag:f,timeToLive:p}=i,m=t.group.requests.get(f),h=Bh(m.successSchema),x=h?r.runtime.pull(An(r.use(g=>I(g(f,c,{headers:a}))))):r.runtime.atom(r.use(g=>g(f,c,{headers:a})));return u&&(x=r.runtime.factory.withReactivity(u)(x)),!h&&i.serializationKey&&(x=gO(x,{key:`AtomRpc:${i.tag}:${i.serializationKey}`,schema:pR({success:m.successSchema,error:I6(m)})})),p&&(x=Wn(p)?rx(x,p):xO(x)),x});return r.query=(i,a,c)=>{let u={tag:i,payload:a,headers:c?.headers?Zo(c.headers):void 0,reactivityKeys:c?.reactivityKeys,timeToLive:c?.timeToLive!==void 0?$e(c.timeToLive):void 0,serializationKey:c?.serializationKey};return s(u)},r},I6=e=>Pe([e.errorSchema,...Array.from(e.middlewares,t=>t.error),Zs]);var $E={};ps($E,{make:()=>Pue});var _ue={add(...e){let t=new Map(this.requests);for(let r of e)t.set(r._tag,r);return Ca({requests:t,annotations:this.annotations})},merge(...e){let t=new Map(this.requests),r=new Map(this.annotations.mapUnsafe);for(let n of e){for(let[o,s]of n.requests)t.set(o,s);for(let[o,s]of n.annotations.mapUnsafe)r.set(o,s)}return Ca({requests:t,annotations:qn(r)})},omit(...e){let t=new Map(this.requests);for(let r of e)t.delete(r);return Ca({requests:t,annotations:this.annotations})},middleware(e){let t=new Map;for(let[r,n]of this.requests)t.set(r,n.middleware(e));return Ca({requests:t,annotations:this.annotations})},toHandlers(e){let t=this;return xt(function*(){let r=yield*Nr(),n=Yr(e)?yield*e:e,o=new Map;return t.requests.forEach((s,i)=>{o.set(s.key,{tag:s._tag,handler:n[i],context:r})}),qn(o)})},prefix(e){let t=new Map;for(let r of this.requests.values()){let n=r.prefix(e);t.set(n._tag,n)}return Ca({requests:t,annotations:this.annotations})},toLayer(e){return Za(this.toHandlers(e))},of:F,toLayerHandler(e,t){let r=this;return Za(xt(function*(){let n=yield*Nr(),o=Yr(t)?yield*t:t,s=new Map,i=r.requests.get(e);return s.set(i.key,{handler:o,context:n}),qn(s)}))},accessHandler(e){return yn(t=>{let r=this.requests.get(e),{handler:n,context:o}=Gi(t,r.key);return I((s,i)=>{i.rpc=r;let a=n(s,i),c=Rd(a)?a.value:a;return Yr(c)?X0(c,o):Ak(c,o)})})},annotate(e,t){return Ca({requests:this.requests,annotations:We(this.annotations,e,t)})},annotateRpcs(e,t){return this.annotateRpcsMerge(ys(e,t))},annotateMerge(e){return Ca({requests:this.requests,annotations:Kr(this.annotations,e)})},annotateRpcsMerge(e){let t=new Map;for(let[r,n]of this.requests)t.set(r,n.annotateMerge(Kr(e,n.annotations)));return Ca({requests:t,annotations:this.annotations})}},Ca=e=>Object.assign(function(){},_ue,{requests:e.requests,annotations:e.annotations}),Pue=(...e)=>Ca({requests:new Map(e.map(t=>[t._tag,t])),annotations:pt()});var wf={};ps(wf,{Service:()=>Mue,TypeId:()=>SO,layerClient:()=>Fue});var SO="~effect/rpc/RpcMiddleware",Mue=()=>(e,t)=>{let r=Ir(),n;r!==0&&(yt(2),n=new globalThis.Error,yt(r));function o(){}let s=o;return Object.setPrototypeOf(o,Object.getPrototypeOf(Ue(e))),o.key=e,Object.defineProperty(o,"stack",{get(){return n?.stack}}),s[SO]=SO,s.error=t?.error??Mi,s.requiredForClient=t?.requiredForClient??!1,o},Fue=(e,t)=>Za(xt(function*(){let r=(yield*Nr()).pipe(q_(it)),n=Yr(t)?yield*t:t;return qn(new Map([[`${e.key}/Client`,o=>ec(n(o),s=>Kr(r,s))]]))}));var w6=l.Union([l.Struct({_tag:l.Literal("List"),collection:l.String}),l.Struct({_tag:l.Literal("Item"),collection:l.String,id:l.Union([l.String,l.Number])})]);function vf(e,t){return{item:r=>({_tag:"Item",collection:e,id:r}),list:{_tag:"List",collection:e},name:e}}function v6(e){return e._tag==="List"?e.collection:`${e.collection}:${e.id}`}function jE(e){return[...new Set(e.map(v6))]}function HE(e){return[...new Set(e.flatMap(t=>t._tag==="List"?[t.collection]:[v6(t),t.collection]))]}var Nue=ne.fn("EffectContract.invalidateAfter")(function*(e){yield*Wb(HE(e))});function Uue(e,t,r){function n(o){return jE(r.reads(o))}return{query:(o,s={})=>e.query(t,o,{...s,reactivityKeys:n(o)}),run:o=>e.use(s=>s(t,o))}}function Due(e,t,r){return{run:n=>e.use(o=>o(t,n)).pipe(ne.tap(o=>Nue(r.invalidates(n,o))))}}function Lue(e,t){return{run:r=>sn.unwrap(e.use(n=>ne.succeed(n(t,r))))}}function qE(e,t){let{name:r,queries:n,commands:o,streams:s}=e.declaration;return Object.fromEntries([...n.map(i=>[i.name,Uue(t,`${r}.${i.name}`,i)]),...o.map(i=>[i.name,Due(t,`${r}.${i.name}`,i)]),...s.map(i=>[i.name,Lue(t,`${r}.${i.name}`)])])}var A6=l.Union([l.Struct({_tag:l.Literal("Changed"),keys:l.Array(w6)}),l.Struct({_tag:l.Literal("Resync")})]),Bue=256;function C6(e,t){let r=tx(!1),n=tx({connection:"connecting",failure:ke.none(),needsResync:!0,pending:0});return{connection:e.atom(s=>ne.gen(function*(){s.mount(n);let i=yield*Ac;function a(f){s.set(n,{...s.once(n),...f})}function c(){if(s.once(r)){a({needsResync:!0});return}i.invalidateUnsafe(jE(t.resyncKeys)),a({needsResync:!1,pending:0})}s.subscribe(r,f=>{f||c()}),t.resume!==void 0&&(s.once(t.resume),s.subscribe(t.resume,c));let u=ne.suspend(()=>{let f=!0;function p(m){a({connection:"live",failure:ke.none()}),s.once(r)?a({needsResync:!0,pending:Math.min(Bue,s.once(n).pending+1)}):f||m._tag==="Resync"?c():i.invalidateUnsafe(HE(m.keys)),f=!1}return t.stream.pipe(sn.runForEach(m=>ne.sync(()=>p(m))),ne.scoped,ne.catchCause(m=>ne.sync(()=>a({failure:ke.some(m)}))),ne.andThen(ne.sync(()=>a({connection:"reconnecting",needsResync:!0}))),ne.andThen(ne.sleep(t.retryDelay??"1 second")))});yield*ne.forever(u)})).pipe(rx(0)),paused:r,status:n}}function k6(e,t){return r=>{function n(){e.document.visibilityState==="visible"&&r()}return e.addEventListener(t,n),()=>e.removeEventListener(t,n)}}function R6({window:e,native:t}){let r=e===void 0?[]:[k6(e,"visibilitychange"),k6(e,"online")],n=t===void 0?r:[...r,t];return qi(o=>{let s=0;function i(){s+=1,o.setSelf(s)}for(let a of n)o.addFinalizer(a(i));return s})}function $ue(e){let t=e.map(({name:r})=>r).filter((r,n,o)=>o.indexOf(r)!==n);if(t.length>0)throw new Error(`Operation names must be unique; duplicated: ${[...new Set(t)].join(", ")}`)}function O6(e,t){let r=e.middleware.bind(e);return Object.assign(e,{declaration:t,middleware:n=>O6(r(n),t)})}function Mc(e,t){let{queries:r=[],commands:n=[],streams:o=[]}=t;$ue([...r,...n,...o]);let s=[...r,...n,...o].map(i=>Od.make(`${e}.${i.name}`,{error:i.error,payload:i.payload,stream:i.kind==="stream",success:i.success}));return O6($E.make(...s),{commands:n,name:e,queries:r,streams:o})}function _6(e){let t=Object.entries(e).map(([r,n])=>[r,l.isSchema(n)?n:l.TaggedError()(r,n)]);return{error:t.length===0?l.Never:l.Union(t.map(([,r])=>r)),Rejection:Object.fromEntries(t),reject:Object.fromEntries(t.map(([r,n])=>[r,(...o)=>ne.fail(Reflect.construct(n,o))]))}}function jue(e){return e===void 0?l.Void:l.isSchema(e)?e:l.Struct(e)}function bO(e,t,r){let{payload:n,success:o,rejections:s={}}=r;return{kind:e,name:t,payload:jue(n),rejections:s,success:o??l.Void,..._6(s)}}function Tt(e,t){return{...bO("query",e,t),reads:t.reads}}function ox(e,t){return{...bO("command",e,t),invalidates:t.invalidates}}function P6(e,t){return{...bO("stream",e,t),reads:t.reads}}var Nc={message:l.String},F6={field:l.optionalKey(l.String),message:l.String},sx=class extends l.TaggedError()("NotFound",Nc){},ix=class extends l.TaggedError()("Unauthorized",Nc){},Fc=class extends l.TaggedError()("Forbidden",Nc){},zE=class extends l.TaggedError()("BadRequest",F6){},ax=class extends l.TaggedError()("Conflict",F6){},WE=class extends l.TaggedError()("PreconditionFailed",Nc){},M6=class extends l.TaggedError()("TooManyRequests",Nc){},Fd=class extends l.TaggedError()("AuthUnavailable",Nc){},Hn=class extends l.TaggedError()("InternalServerError",Nc){},ka=class extends l.TaggedError()("ServiceUnavailable",Nc){};var Uc=class extends wf.Service()("@shivaedev/platform/rpc/RequestTracing"){},N6=class extends wf.Service()("@shivaedev/platform/rpc/Authenticated",{error:l.Union([ix,Fd,Fc])}){},U6=class extends wf.Service()("@shivaedev/platform/rpc/MaybeAuthenticated",{error:l.Union([Fd,Fc])}){},D6=class extends wf.Service()("@shivaedev/platform/rpc/AuthenticatedUser",{error:l.Union([ix,Fd,Fc])}){};var wt=l.String.check(l.isPattern(/^[a-zA-Z\d][a-zA-Z\d._-]*$/u));var Qs=l.String.check(l.isPattern(/^[a-f\d]{64}$/u)),L6=l.Literals(["answer","clarify","not_now"]),Hue=l.Struct({prompt:wt.check(l.isMaxLength(128)),selected:l.Array(wt.check(l.isMaxLength(128))).check(l.isMaxLength(32)),text:l.String.check(l.isMaxLength(8192))}),B6=l.Array(Hue).check(l.isMaxLength(32)),EO=l.Struct({deadline:l.Number.check(l.isFinite(),l.isGreaterThanOrEqualTo(0),l.isLessThanOrEqualTo(864e13)),item:wt,reason:l.String,registeredAt:l.Number.check(l.isFinite(),l.isGreaterThanOrEqualTo(0),l.isLessThanOrEqualTo(864e13)),request:wt,reviewedRevision:Qs,source:l.String}),KE=l.Struct({answers:l.optional(B6),author:l.String.check(l.isPattern(/\S/u),l.isMaxLength(200)),question:wt,recordedAt:l.Number.check(l.isFinite(),l.isGreaterThanOrEqualTo(0),l.isLessThanOrEqualTo(864e13)),reviewedRevision:Qs,supersedes:l.optional(wt),type:L6}),VE=l.Struct({context:l.String,id:wt,item:wt,reason:l.String,request:wt,reviewedRevision:Qs,source:l.String}),Nd=l.Struct({context:l.String,id:wt,question:EO}),Dc=l.Struct({body:l.String,id:wt,response:KE}),$6=l.Struct({question:Nd,responses:l.Array(Dc)}),j6=l.Struct({expired:l.Boolean,question:Nd,response:l.optional(Dc)}),H6=l.Struct({answers:l.optional(B6),author:KE.fields.author,body:l.String.check(l.isMaxLength(32768)),id:wt,question:wt,supersedes:l.optional(wt),type:L6});var GE=l.Struct({disposition:l.Literals(["applied","superseded"]),question:wt,recordedAt:l.Number.check(l.isFinite(),l.isGreaterThanOrEqualTo(0),l.isLessThanOrEqualTo(864e13)),response:l.optional(wt),reviewedRevision:Qs});var cx=l.String.check(l.isPattern(/\S/u),l.isMaxLength(8192)),ux=l.Struct({by:l.optional(cx),constraints:l.String.check(l.isMaxLength(8192)),goal:cx,item:wt,nextAction:cx,note:l.optional(cx),preparedAt:l.Number.check(l.isFinite(),l.isGreaterThanOrEqualTo(0),l.isLessThanOrEqualTo(864e13)),recipient:cx.check(l.isMaxLength(200)),reviewedRevision:Qs,source:l.String,state:l.Literals(["requested","acknowledged","rejected","unavailable"])}),IO=ux.pipe(l.encodeKeys({nextAction:"next_action",preparedAt:"prepared_at",reviewedRevision:"reviewed_revision"})),q6=l.Struct({constraints:ux.fields.constraints,goal:ux.fields.goal,id:wt,item:wt,nextAction:ux.fields.nextAction,recipient:ux.fields.recipient,revision:Qs,source:l.String}),TO=l.Struct({context:l.String,file:l.String,handoff:IO,id:wt,prompt:l.String}),JE=l.Struct({records:l.Array(TO),unknown:l.Array(l.String)}),ZE=l.Struct({context:l.String,id:wt,item:wt,reviewedRevision:Qs,source:l.String});var QE=wt,wO=l.String.check(l.isPattern(/^[a-zA-Z\d][a-zA-Z\d._-]*(?:#[a-zA-Z\d][a-zA-Z\d._-]*)?$/u)),fo=l.String.check(l.isPattern(/\S/u)),que=l.Struct({id:QE,kind:l.Literals(["decision","review","blocker"]),managed:l.optional(l.Boolean),reason:fo,responseFrom:l.Array(fo).check(l.isMinLength(1)),state:l.Literals(["open","closed"]),unblocks:l.Array(wO).check(l.isMinLength(1))}).pipe(l.encodeKeys({responseFrom:"response_from"})),zue=l.Struct({id:QE,text:fo}),Wue=l.Struct({kind:l.Literals(["implements","informs","depends_on","relates_to"]),target:wO}),Kue=l.Struct({checkedRevision:l.optional(l.String.check(l.isPattern(/^(?:[a-f\d]{40}|[a-f\d]{64})$/iu))),criterion:l.optional(wO),method:l.optional(fo),observedAt:l.optional(fo.check(l.makeFilter(e=>Number.isFinite(Date.parse(e))&&/^\d{4}-\d{2}-\d{2}T.*(?:Z|[+-]\d{2}:\d{2})$/u.exec(e)!==null||"Expected an ISO timestamp with timezone"))),outcome:l.optional(fo),source:fo}).pipe(l.encodeKeys({checkedRevision:"checked_revision",observedAt:"observed_at"})),Lc=l.Struct({areas:l.optional(l.Array(fo)),attention:l.optional(l.Array(que)),criteria:l.optional(l.Array(zue)),evidence:l.optional(l.Array(Kue)),handoff:l.optional(IO),id:l.optional(QE),items:l.optional(l.Array(QE)),kind:l.optional(l.Literals(["task","investigation","decision","result","project","board","question","response","handoff","goal","report"])),nextAction:l.optional(fo),options:l.optional(l.Array(l.Struct({description:fo.check(l.isMaxLength(8192)),label:fo.check(l.isMaxLength(128))})).check(l.isMaxLength(32))),owner:l.optional(fo),question:l.optional(EO),recommended:l.optional(fo),relationships:l.optional(l.Array(Wue)),requestReceipt:l.optional(GE),response:l.optional(KE),status:l.optional(fo)}).pipe(l.encodeKeys({nextAction:"next_action",requestReceipt:"request_receipt"}));var Vue=l.Struct({href:l.optional(l.String),label:l.String}),z6=l.Struct({backlinks:l.Array(l.Struct({href:l.String,kind:l.String,label:l.String,status:l.optional(l.String),title:l.optional(l.String)})),board:l.Boolean,claims:l.Record(l.String,l.Array(Vue)),evidenceSources:l.Array(l.Struct({href:l.optional(l.String),problem:l.String})),lines:l.Record(l.String,l.Number),proseLine:l.Number,raw:l.optional(l.String),receipts:l.Record(l.String,GE)});var vO=l.Struct({id:l.String,open:l.Boolean,options:Lc.to.fields.options,preview:l.optional(VE),prompts:l.optional(l.Array(l.Struct({id:l.String,mode:l.Literals(["one","many","text"]),options:l.Array(l.Struct({id:l.String,source:l.String})),source:l.String}))),promptUnavailable:l.optional(l.String),recommended:Lc.to.fields.recommended,responses:l.optional(l.Array(Dc)),sourceOpen:l.optional(l.Boolean),title:l.optional(l.String),unavailable:l.optional(l.String)}),Ra=l.Struct({diagnostics:l.Array(l.Struct({field:l.optional(l.String),line:l.Number,message:l.String})),file:l.String,identity:l.optional(l.String),links:l.Record(l.String,l.String),metadata:Lc,modified:l.Number,questionActions:l.Record(l.String,l.String),reading:l.optional(z6),referenceDetails:l.optional(l.Record(l.String,l.Struct({status:l.optional(l.String),title:l.String}))),references:l.Record(l.String,l.String),requests:l.Array(vO),source:l.String,unavailable:l.Array(l.String),writable:l.Boolean});var W6=l.Struct({counts:l.Struct({goals:l.Number,library:l.Number,now:l.Number,system:l.Number}),home:l.optional(l.Struct({file:l.String,identity:l.optional(l.String)})),inboxCount:l.NullOr(l.Number)});var K6={folder:l.optional(l.String),kind:l.optional(l.String),showFleet:l.optional(l.Boolean),status:l.optional(l.String)},Gue=l.Struct({href:l.String,kind:l.String,modified:l.Number,path:l.String,status:l.String,title:l.String}),V6=l.Struct({files:l.Array(Gue),fleetCount:l.Number,folders:l.Array(l.Struct({count:l.Number,name:l.String,path:l.String})),kinds:l.Array(l.String),statuses:l.Array(l.String)});var Jue=l.Literals(["prepared","executing","adopting","reviewing","repairing","validating","delivering","completed","needs-human","released"]),AO=l.Number.check(l.isFinite(),l.isGreaterThanOrEqualTo(0)),YE=l.Struct({attentionOwner:l.optional(l.Literals(["maintainer","orchestrator","automation"])),prUrl:l.optional(l.String),stage:Jue,stageEnteredAt:l.NullOr(AO),updatedAt:l.NullOr(AO),workId:l.String}),CO=l.Struct({...YE.fields,completedAt:AO,stage:l.Literal("completed")}),G6=l.Struct({completed:l.Array(CO),items:l.Array(YE)});var J6=l.NullOr(l.Struct({file:l.String,metadata:Lc,title:l.String})),Z6=l.Union([l.Struct({completed:l.Array(l.Struct({...CO.fields,document:J6})),items:l.Array(l.Struct({...YE.fields,document:J6})),state:l.Literal("ready")}),l.Struct({reason:l.String,state:l.Literal("unavailable")})]);var Zue=l.Literals(["now","board","table"]),Que=l.Literals(["title","owner","status"]),Q6=l.Struct({board:l.String,item:l.String,owner:l.String,query:l.String,sort:Que,status:l.String,view:Zue});var lx=l.Struct({file:l.String,fleetApproved:l.optional(l.Boolean),id:l.String,metadata:Lc,title:l.String,waiting:l.optional(l.String)}),Y6=l.Struct({boards:l.Array(lx),issues:l.Array(l.String),items:l.Array(lx),rows:l.Array(lx),selected:l.optional(Ra),selectedOutside:l.Boolean,selectionProblem:l.optional(l.String),state:Q6,title:l.String,validBoard:l.Boolean}),fx=l.Struct({earlierAsks:l.optional(l.Number),file:l.String,href:l.String,id:l.String,modified:l.optional(l.Number),problem:l.optional(l.String),reason:l.String,responseFrom:l.optional(l.Array(l.String)),title:l.String}),X6=l.Struct({agents:l.Array(fx),complete:l.Boolean,issues:l.Array(l.Struct({file:l.String,line:l.Number,message:l.String})),items:l.Array(fx),parked:l.Array(fx),resolved:l.Array(fx),sourceIssues:l.Boolean,you:l.Array(fx)}),eK=l.Struct({counts:l.Array(l.Struct({count:l.Number,title:l.String})),document:Ra});var rK=l.Struct({done:l.Number,"in progress":l.Number,planned:l.Number}),Yue=l.Struct({counts:rK,evidence:l.Number,id:l.String,linked:l.Number,text:l.String}),tK=l.Struct({counts:rK,criteria:l.Array(Yue),id:l.String,linked:l.Number,nextAction:l.optional(l.String),openAsks:l.Number,owner:l.optional(l.String),status:l.optional(l.String),title:l.String,unlinked:l.Boolean}),nK=l.Struct({closedGoals:l.Array(tK),goals:l.Array(tK),items:l.Array(lx)});var kO=l.Struct({href:l.optional(l.String),label:l.String}),Xue=l.Struct({checkedRevision:l.optional(l.String),method:l.optional(l.String),observedAt:l.optional(l.String),outcome:l.optional(l.String),problem:l.String,source:kO}),oK=l.Struct({document:Ra,feedback:l.Array(l.Struct({matching:l.Boolean,question:Nd,questionFile:l.String,response:Dc,responseFile:l.String,supersedesFile:l.optional(l.String)})),feedbackUnknown:l.Boolean,revision:l.String,targets:l.Array(l.Struct({available:l.Boolean,criteria:l.Array(l.Struct({claims:l.Array(Xue),link:kO,text:l.String})),link:kO,status:l.optional(l.String)}))});var sK=l.Struct({resetsAt:l.NullOr(l.Int.check(l.isGreaterThanOrEqualTo(0),l.isLessThanOrEqualTo(864e10))),usedPercent:l.Number.check(l.isFinite(),l.isGreaterThanOrEqualTo(0)),windowDurationMins:l.NullOr(l.Int.check(l.isGreaterThan(0)))}),aK=l.Struct({primary:l.NullOr(sK),secondary:l.NullOr(sK)}),XE=l.Int.check(l.isGreaterThanOrEqualTo(0)),iK=l.Number.check(l.isFinite(),l.isGreaterThanOrEqualTo(0),l.isLessThanOrEqualTo(864e13)),efe=l.Struct({limit:XE,limitedBy:l.NullOr(l.Literals(["rate-limit","reserve"])),limitedUntil:l.NullOr(iK),observedAt:iK,remaining:XE,reset:XE.check(l.isLessThanOrEqualTo(864e10)),resource:l.String.check(l.isMinLength(1),l.isMaxLength(100)),used:XE}),eI=l.Array(efe).check(l.isMaxLength(50));var dx=l.Int.check(l.isGreaterThanOrEqualTo(0)),RO=l.Number.check(l.isFinite(),l.isGreaterThanOrEqualTo(0),l.isLessThanOrEqualTo(864e13)),tfe=l.Struct({at:RO,cause:l.String.check(l.isMinLength(1),l.isMaxLength(500))}),rfe="health.json",VIe=`fleet/${rfe}`,cK=l.Struct({concurrency:l.Int.check(l.isGreaterThan(0)),github:l.optional(eI),lastCapacityRejection:l.NullOr(tfe),lastSchedulerPass:l.NullOr(RO),observedAt:RO,queued:dx,running:dx,staleAfterMs:l.Int.check(l.isGreaterThan(0)),version:l.Literal(2),waiting:l.Struct({automation:dx,maintainer:dx,orchestrator:dx})});var uK=l.Number.check(l.isFinite(),l.isGreaterThanOrEqualTo(0),l.isLessThanOrEqualTo(864e13));function OO(e){return l.Union([l.Struct({observedAt:uK,state:l.Literal("ready"),value:e}),l.Struct({cause:l.String,observedAt:uK,state:l.Literals(["not-configured","error"])})])}var _O=l.Struct({codex:OO(aK),fleet:OO(cK),github:OO(eI)}),rTe=Mc("daemon",{queries:[Tt("diagnostics",{payload:{},reads:()=>[],success:_O}),Tt("fleetItems",{payload:{},reads:()=>[],rejections:{ServiceUnavailable:ka},success:G6})]});var fK=l.Struct({now:l.Number,sources:_O}),lK=l.Struct({empty:l.Boolean,templates:l.Array(l.Struct({file:l.String,label:l.String,source:l.String}))}),dK=l.Struct({document:Ra,request:vO}),pK=l.Struct({background:l.String,goal:l.String,item:l.String,nextAction:l.String,reading:JE,source:l.optional(ZE),unavailable:l.optional(l.String),writable:l.Boolean});var Rt=vf("work-board/workspace",l.String),mK=vf("work-board/documents",l.String),hK=vf("work-board/identities",l.String),xK=vf("work-board/navigation",l.String),Dt=vf("work-board/index",l.String),gK=vf("work-board/watcher",l.String);var PO=class extends l.TaggedError()("PublicationUncertain",{message:l.String}){},MO=class extends l.TaggedError()("Unanswered",{message:l.String}){},Ys={BadRequest:zE,Conflict:ax,Forbidden:Fc,InternalServerError:Hn,NotFound:sx,PreconditionFailed:WE,PublicationUncertain:PO,ServiceUnavailable:ka,Unanswered:MO},mTe=l.Union(Object.values(Ys)),Bc={Conflict:ax,InternalServerError:Hn,NotFound:sx,ServiceUnavailable:ka},hTe=l.Union(Object.values(Bc));var nfe=Tt("handoffSource",{payload:{item:l.String},reads:()=>[Rt.list,Dt.list],rejections:Ys,success:ZE}),ofe=Tt("handoffs",{payload:{item:l.String},reads:()=>[Rt.list,Dt.list],rejections:Ys,success:JE}),sfe=ox("prepareHandoff",{invalidates:()=>[Rt.list,Dt.list],payload:q6,rejections:Ys,success:TO}),tI=Mc("work-board",{commands:[sfe],queries:[nfe,ofe]}).middleware(Uc);var ife=Tt("question",{payload:{item:l.String,request:l.String},reads:()=>[Rt.list,Dt.list],rejections:Ys,success:VE}),afe=Tt("awaitResponse",{payload:{after:l.optional(l.String),question:l.String},reads:()=>[Rt.list,Dt.list],rejections:Ys,success:j6}),cfe=Tt("responses",{payload:{question:l.String},reads:()=>[Rt.list,Dt.list],rejections:Ys,success:$6}),ufe=ox("registerQuestion",{invalidates:()=>[Rt.list,Dt.list],payload:{item:l.String,request:l.String,revision:Qs},rejections:Ys,success:Nd}),ffe=ox("recordResponse",{invalidates:()=>[Rt.list,Dt.list],payload:H6,rejections:Ys,success:Dc}),rI=Mc("work-board",{commands:[ufe,ffe],queries:[ife,cfe,afe]}).middleware(Uc);var Af=l.String.check(l.isMaxLength(8192),l.makeFilter(e=>{if(!e.startsWith("/")||e.startsWith("//"))return"Expected a local reading URL";try{let t=new URL(e,"http://127.0.0.1").pathname;return t==="/"||["/_board/inbox","/_board/system","/_board/work","/_board/overview","/_board/changes","/_board/start","/_board/respond","/_board/handoff","/_board/result"].includes(t)||/^\/_board\/item\/[^/]+\/?$/u.exec(t)!==null||/\.md$/iu.exec(t)!==null||"Expected a local reading URL"}catch{return"Expected a local reading URL"}}));function nI(e){let t=new URL(e,"http://127.0.0.1").pathname,r=/^\/_board\/item\/(?<id>[^/]+)\/?$/u.exec(t)?.groups?.id,n=mK.item(decodeURIComponent(t.slice(1)));return r?n=hK.item(decodeURIComponent(r)):t.startsWith("/_board/")&&(n=Dt.list),[Rt.list,n]}var yK=l.Struct({directory:l.String,url:l.String});var lfe=l.Struct({file:l.String,href:l.String,id:l.optional(l.String),itemKind:l.optional(l.String),kind:l.Literals(["document","heading","passage"]),line:l.optional(l.Number),snippet:l.String,status:l.optional(l.String),text:l.String,title:l.String}),dfe=Tt("document",{payload:{url:Af},reads:({url:e})=>[...nI(e),Dt.list],rejections:Bc,success:Ra}),pfe=Tt("board",{payload:{url:Af},reads:({url:e})=>nI(e),rejections:Bc,success:eK}),mfe=Tt("work",{payload:{url:Af},reads:()=>[Rt.list,Dt.list],rejections:Bc,success:Y6}),hfe=Tt("inbox",{reads:()=>[Rt.list,Dt.list],rejections:{InternalServerError:Hn},success:X6}),xfe=Tt("server",{reads:()=>[],rejections:{ServiceUnavailable:ka},success:yK}),gfe=Tt("diagnostics",{reads:()=>[Rt.list],rejections:{InternalServerError:Hn},success:fK}),yfe=Tt("fleetItems",{reads:()=>[Rt.list,Dt.list],success:Z6}),Sfe=Tt("goals",{reads:()=>[Rt.list,Dt.list],rejections:{InternalServerError:Hn},success:nK}),bfe=Tt("start",{reads:()=>[Rt.list,Dt.list],rejections:{InternalServerError:Hn},success:lK}),Efe=Tt("respond",{payload:{url:Af},reads:({url:e})=>[...nI(e),Dt.list],rejections:Bc,success:dK}),Ife=Tt("handoff",{payload:{url:Af},reads:()=>[Rt.list,Dt.list],rejections:Bc,success:pK}),Tfe=Tt("result",{payload:{url:Af},reads:()=>[Rt.list,Dt.list],rejections:Bc,success:oK}),wfe=Tt("library",{payload:K6,reads:()=>[Rt.list,Dt.list],rejections:{InternalServerError:Hn},success:V6}),vfe=Tt("navigation",{payload:{current:l.String.check(l.isMaxLength(8192))},reads:()=>[Rt.list,xK.list,Dt.list],rejections:{InternalServerError:Hn},success:W6}),Afe=Tt("search",{payload:{query:l.String.check(l.isMaxLength(8192))},reads:()=>[Rt.list,Dt.list],rejections:{InternalServerError:Hn},success:l.Struct({results:l.Array(lfe),total:l.Number,unavailable:l.Array(l.String)})}),Cfe=Tt("watcher",{reads:()=>[Rt.list,gK.list],rejections:{InternalServerError:Hn},success:l.Struct({watching:l.Boolean})}),FO=P6("subscribe",{reads:()=>[Rt.list],rejections:{InternalServerError:Hn},success:A6}),NO=Mc("work-board",{queries:[xfe,dfe,pfe,mfe,hfe,gfe,yfe,Sfe,bfe,Efe,Ife,Tfe,vfe,wfe,Afe,Cfe],streams:[FO]}).middleware(Uc),SK=NO.merge(rI).merge(tI);function bK(e,t={}){class r extends T6()("WorkBoard/Reader",{group:SK,protocol:ex.layerProtocolHttp({url:`${e}/_board/rpc`}).pipe(Fn.provide([iE.layer,Yh.layerNdjson]))}){}let n=qE(NO,r),o=FW({defaultIdleTTL:0,timeoutResolution:1}),s=C6(r.runtime,{resume:R6(t),resyncKeys:FO.reads(void 0),stream:n.subscribe.run(void 0)});o.mount(s.connection);async function i(f,p){try{return await ne.runPromise(Dh(o,f,{suspendOnWaiting:!0}),{signal:p})}catch(m){if(p?.aborted){let h=new Error("Reading canceled",{cause:m});throw h.name="AbortError",h}throw m}}async function a(f,p){try{return await ne.runPromise(ne.flatMap(Dh(o,r.runtime),m=>ne.provideContext(f,m)),{signal:p})}catch(m){if(p?.aborted){let h=new Error("Reading canceled",{cause:m});throw h.name="AbortError",h}throw m}}async function c(f,p){let m=await ne.runPromise(ne.result(Dh(o,r.runtime.atom(f),{suspendOnWaiting:!0})),{signal:p});if(m._tag==="Failure")throw m.failure;return m.success}let u=qE(rI,r);return{api:n,handoffs:qE(tI,r),mutate:c,read:i,registry:o,responses:u,run:a,runtime:r.runtime,updates:s}}var oI=new WeakMap;function EK(e){let t=oI.get(e);if(t===void 0){let o=function(){n.registry.dispose(),oI.get(e)===n&&oI.delete(e),e.removeEventListener("pagehide",o)};var r=o;t=bK(e.location.origin,{window:e}),oI.set(e,t);let n=t;e.addEventListener("pagehide",o)}return t}var b0e=EK;export{b0e as session};