holycodex 0.16.3 → 0.16.4-dev.73.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -5
- package/dist/agent.js +128 -0
- package/dist/assets/plugin/plugin.json +2 -2
- package/dist/assets/plugin/skills/code-review/SKILL.md +15 -3
- package/dist/assets/plugin/skills/code-review/agents/openai.yaml +1 -1
- package/dist/assets/plugin/skills/commit/SKILL.md +29 -7
- package/dist/assets/plugin/skills/commit/agents/openai.yaml +1 -1
- package/dist/assets/plugin/skills/compress/SKILL.md +12 -3
- package/dist/assets/plugin/skills/compress/agents/openai.yaml +1 -1
- package/dist/assets/plugin/skills/debugging/SKILL.md +10 -5
- package/dist/assets/plugin/skills/debugging/agents/openai.yaml +1 -1
- package/dist/assets/plugin/skills/handoff/SKILL.md +13 -5
- package/dist/assets/plugin/skills/handoff/agents/openai.yaml +2 -2
- package/dist/assets/plugin/skills/operations/SKILL.md +31 -0
- package/dist/assets/plugin/skills/operations/agents/openai.yaml +6 -0
- package/dist/assets/plugin/skills/plan/SKILL.md +15 -3
- package/dist/assets/plugin/skills/plan/agents/openai.yaml +1 -1
- package/dist/assets/plugin/skills/plan-review/SKILL.md +14 -2
- package/dist/assets/plugin/skills/plan-review/agents/openai.yaml +1 -1
- package/dist/assets/plugin/skills/programming/SKILL.md +17 -6
- package/dist/assets/plugin/skills/programming/agents/openai.yaml +1 -1
- package/dist/assets/plugin/skills/refactor/SKILL.md +17 -6
- package/dist/assets/plugin/skills/refactor/agents/openai.yaml +1 -1
- package/dist/assets/plugin/skills/rules/SKILL.md +12 -3
- package/dist/assets/plugin/skills/rules/agents/openai.yaml +1 -1
- package/dist/assets/plugin/skills/stop-slop/SKILL.md +10 -2
- package/dist/assets/plugin/skills/stop-slop/agents/openai.yaml +1 -1
- package/dist/assets/plugin/skills/writing-for-agents/SKILL.md +18 -3
- package/dist/assets/plugin/skills/writing-for-agents/agents/openai.yaml +1 -1
- package/dist/index.js +87 -57
- package/package.json +8 -5
package/dist/agent.js
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
// @bun
|
|
3
|
+
var ju="0.15";function cr(e,t=new WeakSet){if(t.has(e))return;t.add(e);for(let r of Reflect.ownKeys(e)){let n=Object.getOwnPropertyDescriptor(e,r);if(n&&"value"in n&&$u(n.value))cr(n.value,t)}Object.freeze(e)}function $u(e){return typeof e==="object"&&e!==null}var Ca={comma:",",tab:"\t",pipe:"|"},kr=Ca.comma;function at(e){let t=0,r=e.length;while(t<r&&e[t]===" ")t++;while(r>t&&e[r-1]===" ")r--;return t===0&&r===e.length?e:e.slice(t,r)}function Gh(e){return e.replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(/[\u0000-\u001F]/g,(t)=>`\\u${t.charCodeAt(0).toString(16).padStart(4,"0")}`)}function Yh(e){let t="",r=0;while(r<e.length){if(e[r]==="\\"){if(r+1>=e.length)throw SyntaxError("Invalid escape sequence: backslash at end of string");let n=e[r+1];if(n==="n"){t+=`
|
|
4
|
+
`,r+=2;continue}if(n==="t"){t+="\t",r+=2;continue}if(n==="r"){t+="\r",r+=2;continue}if(n==="\\"){t+="\\",r+=2;continue}if(n==='"'){t+='"',r+=2;continue}if(n==="u"){if(r+6>e.length)throw SyntaxError(`Invalid escape sequence: truncated \\u escape at "${e.slice(r,r+6)}"`);let o=e.slice(r+2,r+6);if(!/^[0-9a-f]{4}$/i.test(o))throw SyntaxError(`Invalid escape sequence: \\u must be followed by 4 hex digits, got "${o}"`);let i=Number.parseInt(o,16);if(i>=55296&&i<=57343)throw SyntaxError(`Invalid escape sequence: \\u${o} is a lone surrogate. Supplementary code points MUST appear as literal UTF-8`);t+=String.fromCodePoint(i),r+=6;continue}throw SyntaxError(`Invalid escape sequence: \\${n}`)}t+=e[r],r++}return t}function La(e,t){let r=t+1;while(r<e.length){if(e[r]==="\\"&&r+1<e.length){r+=2;continue}if(e[r]==='"')return r;r++}return-1}function tt(e,t,r=0){let n=!1,o=r;while(o<e.length){if(e[o]==="\\"&&o+1<e.length&&n){o+=2;continue}if(e[o]==='"'){n=!n,o++;continue}if(e[o]===t&&!n)return o;o++}return-1}var ke=class extends SyntaxError{constructor(e,t){let r=t?.line!==void 0?`Line ${t.line}: `:"";super(r+e,t?.cause!==void 0?{cause:t.cause}:void 0);this.name="ToonDecodeError",this.line=t?.line,this.source=t?.source}};function rt(e,t){try{return t()}catch(r){if(r instanceof ke)throw r;if(r instanceof Error)throw new ke(r.message,{line:e.lineNumber,source:e.raw,cause:r});throw r}}var tk=/^[ \t]*/;function rk(){return{lineNumber:0,blankLines:[]}}function nk(e,t,r,n){t.lineNumber++;let o=t.lineNumber;if(o===1&&e[0]==="\uFEFF")e=e.slice(1);if(e[e.length-1]==="\r")e=e.slice(0,-1);let i=tk.exec(e)[0],s=i.indexOf("\t"),a=n&&s!==-1?s:i.length,c=n||s===-1?0:i.split("\t").length-1,l=ik(e.slice(a));if(s===-1&&l[0]==="#")return;let u=ok(a-c,r)+c;if(!l){t.blankLines.push({lineNumber:o,indent:a,depth:u});return}if(n){if(s!==-1)throw new ke("Tabs are not allowed in indentation in strict mode",{line:o,source:e});if(a>0&&a%r!==0)throw new ke(`Indentation must be exact multiple of ${r}, but found ${a} spaces`,{line:o,source:e})}return{raw:e,indent:a,content:l,depth:u,lineNumber:o}}function ok(e,t){return Math.floor(e/t)}function ik(e){let t=e.length;while(t>0&&e[t-1]===" ")t--;return t===e.length?e:e.slice(0,t)}var Zh=Symbol("fetch-line");function sk(e){return{buffer:[],done:!1,lastLine:void 0,scanState:rk(),indentSize:e.indentSize,strict:e.strict}}function*Qh(e){while(e.buffer.length===0&&!e.done){let t=yield Zh;if(t===void 0){e.done=!0;return}let r=nk(t,e.scanState,e.indentSize,e.strict);if(r!==void 0)e.buffer.push(r)}}function*Pt(e){return yield*Qh(e),e.buffer[0]}function*bt(e){yield*Qh(e);let t=e.buffer[0];if(t!==void 0)e.buffer.shift(),e.lastLine=t;return t}function*ak(e,t){let r=e[Symbol.iterator](),n=t.next();while(!n.done)if(n.value===Zh){let o=r.next();n=t.next(o.done?void 0:o.value)}else yield n.value,n=t.next()}var ck=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:e[+-]?\d+)?$/i;function Xh(e){return e==="true"||e==="false"||e==="null"}function lk(e){if(!e)return!1;if(!ck.test(e))return!1;let t=Number(e);return!Number.isNaN(t)&&Number.isFinite(t)}function Pa(e,t){let r=e.trimStart(),n=-1;if(r.startsWith('"')){let T=La(r,0);if(T===-1)return{kind:"notHeader"};if(!r.slice(T+1).startsWith("["))return{kind:"notHeader"};let A=e.length-r.length+T+1;n=e.indexOf("[",A)}else n=tt(e,"[");if(n===-1)return{kind:"notHeader"};let o=tt(e,":");if(o!==-1&&o<n)return{kind:"notHeader"};let i=tt(e,"]",n);if(i===-1)return{kind:"notHeader"};let s=i+1,a=s,c=tt(e,"{",i);if(c!==-1&&c<tt(e,":",i)){let T=e.slice(i+1,c);if(T!==""){let R=T.trim();return{kind:"invalid",reason:R===""?"Unexpected whitespace between bracket segment and field list":`Unexpected content "${R}" between bracket segment and field list`}}let A=Bu(e,c);if(A!==-1)a=A+1}if(s=tt(e,":",Math.max(i,a)),s===-1)return{kind:"notHeader"};let l=Math.max(i+1,a),u=e.slice(l,s);if(u!==""){let T=u.trim();return{kind:"invalid",reason:T===""?"Unexpected whitespace between bracket segment and colon":`Unexpected content "${T}" between bracket segment and colon`}}let f;if(n>0){let T=e.slice(0,n);if(T!==T.trimEnd())return{kind:"invalid",reason:"Unexpected whitespace between key and bracket segment"};f=T.startsWith('"')?Fa(T):T}let d=at(e.slice(s+1)),h=e.slice(n+1,i),g;try{g=pk(h,t)}catch(T){return{kind:"invalid",reason:T.message}}let{length:P,delimiter:x,keyed:E}=g,W;if(c!==-1&&c<s){let T=Bu(e,c);if(T!==-1&&T<s){let A=e.slice(c+1,T),R=mk(A,x);if(R!==void 0)return{kind:"invalid",reason:`Header delimiter mismatch: bracket declares "${Bh(x)}" but field list contains unquoted "${Bh(R)}"`};try{W=eg(A,x)}catch(v){return{kind:"invalid",reason:v.message}}}}let F=W?tg(W):void 0,D=F?`Duplicate field name "${F}" in field list`:void 0;if(E&&!W)return{kind:"invalid",reason:"Keyed header requires a field list"};if(W&&d)return{kind:"invalid",reason:D??"Unexpected content after fields-bearing header colon"};return{kind:"header",header:{key:f,length:P,delimiter:x,fields:W,keyed:E},inlineValues:d||void 0,strictError:D}}var uk=/^(?:0|[1-9]\d*)$/;function pk(e,t){let r=e,n=t;if(r.endsWith("\t"))n=Ca.tab,r=r.slice(0,-1);else if(r.endsWith("|"))n=Ca.pipe,r=r.slice(0,-1);let o=!1;if(r.endsWith(":"))o=!0,r=r.slice(0,-1);if(!uk.test(r))throw SyntaxError(`Invalid array length: "${e}" (expected non-negative integer with no leading zeros)`);return{length:Number.parseInt(r,10),delimiter:n,keyed:o}}function eg(e,t){return fk(e,t).map((r)=>{let n=at(r);if(!n)throw SyntaxError("Empty field name in field list");let o=tt(n,"{");if(o===-1)return{name:Fa(n)};let i=at(n.slice(0,o));if(!i)throw SyntaxError("Missing field name before nested field group");let s=Bu(n,o);if(s===-1)throw SyntaxError("Unmatched brace in field list");if(s!==n.length-1)throw SyntaxError("Unexpected content after nested field group");let a=eg(n.slice(o+1,s),t);return{name:Fa(i),children:a}})}function fk(e,t){let r=[],n="",o=!1,i=0,s=0;while(s<e.length){let a=e[s];if(a==="\\"&&s+1<e.length&&o){n+=a+e[s+1],s+=2;continue}if(a==='"'){o=!o,n+=a,s++;continue}if(!o){if(a==="{")i++;else if(a==="}")i--;else if(a===t&&i===0){r.push(n),n="",s++;continue}}n+=a,s++}return r.push(n),r}function Bu(e,t){let r=!1,n=0,o=t;while(o<e.length){let i=e[o];if(i==="\\"&&o+1<e.length&&r){o+=2;continue}if(i==='"'){r=!r,o++;continue}if(!r){if(i==="{")n++;else if(i==="}"){if(n--,n===0)return o}}o++}return-1}function tg(e){let t=new Set;for(let r of e){if(t.has(r.name))return r.name;if(t.add(r.name),r.children){let n=tg(r.children);if(n!==void 0)return n}}}function zu(e){let t=0;for(let r of e)t+=r.children?zu(r.children):1;return t}var dk=[",","\t","|"];function mk(e,t){for(let r of dk){if(r===t)continue;if(tt(e,r)!==-1)return r}}function Bh(e){if(e==="\t")return"\\t";return e}function Vu(e,t){let r=[],n="",o=!1,i=0;while(i<e.length){let s=e[i];if(s==="\\"&&i+1<e.length&&o){n+=s+e[i+1],i+=2;continue}if(s==='"'){o=!o,n+=s,i++;continue}if(s===t&&!o){r.push(at(n)),n="",i++;continue}n+=s,i++}if(n||r.length>0)r.push(at(n));return r}function Ju(e){return e.map((t)=>Da(t))}function Da(e){let t=at(e);if(!t)return"";if(t.startsWith('"'))return Fa(t);if(Xh(t)){if(t==="true")return!0;if(t==="false")return!1;if(t==="null")return null}if(lk(t)){let r=Number.parseFloat(t);return Object.is(r,-0)?0:r}return t}function Fa(e){let t=at(e);if(t.startsWith('"')){let r=La(t,0);if(r===-1)throw SyntaxError("Unterminated string: missing closing quote");if(r!==t.length-1)throw SyntaxError("Unexpected characters after closing quote");return Yh(t.slice(1,r))}return t}function hk(e,t){let r=tt(e,":",t);if(r===-1)throw SyntaxError("Missing colon after key");return{key:at(e.slice(t,r)),end:r+1}}function gk(e,t){let r=La(e,t);if(r===-1)throw SyntaxError("Unterminated quoted key");let n=Yh(e.slice(t+1,r)),o=r+1;if(o>=e.length||e[o]!==":")throw SyntaxError("Missing colon after key");return o++,{key:n,end:o}}function rg(e,t){return e[t]==='"'?gk(e,t):hk(e,t)}function ng(e){return e.trim().startsWith("[")&&tt(e,":")!==-1}function yk(e){return tt(e,":")!==-1}function Wn(e,t,r,n,o){if(n.strict&&e!==t)throw new ke(`Expected ${t} ${r}, but got ${e}`,{line:o.lineNumber,source:o.raw})}function xk(e,t,r){if(e?.depth===t&&e.content.startsWith("- "))throw new ke(`Expected ${r} list-form items, but found more`,{line:e.lineNumber,source:e.raw})}function Sk(e,t,r){if(e?.depth===t&&!e.content.startsWith("- ")&&og(e.content,r.delimiter))throw new ke(`Expected ${r.length} tabular rows, but found more`,{line:e.lineNumber,source:e.raw})}function Gu(e,t,r,n,o){if(!n)return;let i=r.find((s)=>s.lineNumber>e&&s.lineNumber<t);if(i)throw new ke(`Blank lines inside ${o} are not allowed in strict mode`,{line:i.lineNumber})}function og(e,t){let r=tt(e,":"),n=tt(e,t);if(r===-1)return!0;if(n!==-1&&n<r)return!0;return!1}function bk(e){return{indentSize:e?.indentSize??e?.indent??2,strict:e?.strict??!0}}function _k(e,t){let r=bk(t);return ak(e,wk(sk(r),r))}function*wk(e,t){let r=yield*Pt(e);if(!r){yield{type:"startObject"},yield{type:"endObject"};return}if(at(r.content)==="[]"){yield*bt(e),yield{type:"startArray",length:0},yield{type:"endArray"},yield*Kh(e,t.strict);return}if(ng(r.content)){let i=rt(r,()=>Ma(Pa(r.content,kr),t.strict));if(i){yield*bt(e),yield*Na(i.header,i.inlineValues,e,0,t,r),yield*Kh(e,t.strict);return}}yield*bt(e);let n=yield*Pt(e);if(n===void 0&&!zh(r)){yield{type:"primitive",value:rt(r,()=>Da(r.content))};return}if(!zh(r)&&n?.depth===0)throw new ke("Top-level document must start with a key-value or array-header line",{line:r.lineNumber,source:r.raw});let o=t.strict?new Set:void 0;yield{type:"startObject"},yield*ji(r,e,0,t,o);while(!0){let i=yield*Pt(e);if(!i)break;if(i.depth!==0){if(t.strict)throw ig(i,0);sg(i),yield*bt(e);continue}yield*bt(e),yield*ji(i,e,0,t,o)}yield{type:"endObject"}}function Ek(e,t,r){if(r&&e.depth>t+1)throw new ke(`Indentation depth jump: expected depth ${t+1}, but found ${e.depth}`,{line:e.lineNumber,source:e.raw})}function ig(e,t){return new ke(`Over-indented line: expected depth ${t}, but found ${e.depth}`,{line:e.lineNumber,source:e.raw})}function sg(e){if(e.content.startsWith("- ")||e.content==="-"||tt(e.content,":")!==-1)return;throw new ke("Unexpected bare token line outside root primitive position",{line:e.lineNumber,source:e.raw})}function ag(e){return new ke("Keyless keyed header is only valid at the document root",{line:e.lineNumber,source:e.raw})}function Ok(e){return new ke("Keyless array header is only valid at the document root or as a list item",{line:e.lineNumber,source:e.raw})}function Tk(e){return new ke("Keyless header with a field list is only valid at the document root",{line:e.lineNumber,source:e.raw})}function*Kh(e,t){if(!t)return;let r=yield*Pt(e);if(r)throw new ke("Unexpected content after the document root",{line:r.lineNumber,source:r.raw})}function Ku(e,t,r){if(!r)return;if(r.has(e))throw new ke(`Duplicate sibling key "${e}"`,{line:t.lineNumber,source:t.raw});r.add(e)}function*ji(e,t,r,n,o){let i=e.content,s=rt(e,()=>Ma(Pa(i,kr),n.strict));if(s&&s.header.key!==void 0){Ku(s.header.key,e,o),yield{type:"key",key:s.header.key},yield*Na(s.header,s.inlineValues,t,r,n,e);return}if(s&&s.header.key===void 0&&n.strict)throw s.header.keyed?ag(e):Ok(e);let{key:a,end:c}=rt(e,()=>rg(i,0)),l=at(i.slice(c));if(Ku(a,e,o),yield{type:"key",key:a},!l){let u=yield*Pt(t);if(u&&u.depth>r){Ek(u,r,n.strict),yield{type:"startObject"},yield*kk(t,r+1,n),yield{type:"endObject"};return}yield{type:"startObject"},yield{type:"endObject"};return}if(l==="[]"){yield{type:"startArray",length:0},yield{type:"endArray"};return}yield{type:"primitive",value:rt(e,()=>Da(l))}}function*kk(e,t,r){let n,o=r.strict?new Set:void 0;while(!0){let i=yield*Pt(e);if(!i||i.depth<t)break;if(n===void 0&&i.depth>=t)n=i.depth;if(i.depth===n)yield*bt(e),yield*ji(i,e,n,r,o);else if(n!==void 0&&i.depth>n){if(r.strict)throw ig(i,n);sg(i),yield*bt(e)}else break}}function*Na(e,t,r,n,o,i){if(e.keyed){yield*Ik(e,r,n,o,i);return}if(yield{type:"startArray",length:e.length},t){yield*Ak(e,t,o,i),yield{type:"endArray"};return}if(e.fields&&e.fields.length>0){yield*Rk(e,r,n,o,i),yield{type:"endArray"};return}yield*vk(e,r,n,o,i),yield{type:"endArray"}}function*Ak(e,t,r,n){if(!at(t)){Wn(0,e.length,"inline-form values",r,n);return}let o=rt(n,()=>Vu(t,e.delimiter)),i=rt(n,()=>Ju(o));Wn(i.length,e.length,"inline-form values",r,n);for(let s of i)yield{type:"primitive",value:s}}function*Ik(e,t,r,n,o){let i=r+1,s=zu(e.fields),a=n.strict?new Set:void 0,c=0,l,u,f=o;yield{type:"startObject"};while(!0){let d=yield*Pt(t);if(!d||d.depth<=r)break;if(d.depth>i){if(n.strict)throw new ke("Unexpected indentation inside keyed tabular object",{line:d.lineNumber,source:d.raw});yield*bt(t);continue}if(tt(d.content,":")===-1){if(n.strict)throw new ke("Expected entry row inside keyed tabular object",{line:d.lineNumber,source:d.raw});yield*bt(t);continue}if(yield*bt(t),l===void 0)l=d.lineNumber;u=d.lineNumber,f=d;let{key:h,end:g}=rt(d,()=>rg(d.content,0));Ku(h,d,a),yield{type:"key",key:h};let P=at(d.content.slice(g)),x=P===""?[]:rt(d,()=>Vu(P,e.delimiter));Wn(x.length,s,"keyed entry cells",n,d);let E=rt(d,()=>Ju(x));yield*cg(e.fields,E),c++}if(Wn(c,e.length,"keyed entries",n,f),n.strict&&l!==void 0&&u!==void 0)Gu(l,u,t.scanState.blankLines,n.strict,"keyed tabular object");yield{type:"endObject"}}function*Rk(e,t,r,n,o){let i=r+1,s=0,a,c,l=o;while(!n.strict||s<e.length){let u=yield*Pt(t);if(!u||u.depth<i)break;if(u.depth===i){if(!og(u.content,e.delimiter))break;if(a===void 0)a=u.lineNumber;c=u.lineNumber,l=u,yield*bt(t);let f=rt(u,()=>Vu(u.content,e.delimiter));Wn(f.length,zu(e.fields),"tabular row values",n,u);let d=rt(u,()=>Ju(f));yield*cg(e.fields,d),s++}else break}if(Wn(s,e.length,"tabular rows",n,l),n.strict&&a!==void 0&&c!==void 0)Gu(a,c,t.scanState.blankLines,n.strict,"tabular array");if(n.strict)Sk(yield*Pt(t),i,e)}function*vk(e,t,r,n,o){let i=r+1,s=0,a,c,l=o;while(!n.strict||s<e.length){let u=yield*Pt(t);if(!u||u.depth<i)break;let f=u.content.startsWith("- ")||u.content==="-";if(u.depth===i&&f){if(a===void 0)a=u.lineNumber;c=u.lineNumber,l=u,yield*Ck(t,i,n);let d=t.lastLine;if(d)c=d.lineNumber,l=d;s++}else break}if(Wn(s,e.length,"list-form items",n,l),n.strict&&a!==void 0&&c!==void 0)Gu(a,c,t.scanState.blankLines,n.strict,"list-form array");if(n.strict)xk(yield*Pt(t),i,e.length)}function*Ck(e,t,r){let n=yield*bt(e);if(!n)throw ReferenceError("Expected list item");let o;if(n.content==="-"){yield{type:"startObject"},yield{type:"endObject"};return}else if(n.content.startsWith("- "))o=n.content.slice(2);else throw new ke('Expected list item to start with "- "',{line:n.lineNumber,source:n.raw});if(!at(o)){yield{type:"startObject"},yield{type:"endObject"};return}if(at(o)==="[]"){yield{type:"startArray",length:0},yield{type:"endArray"};return}let i={...n,content:o};if(ng(o)){let a=rt(i,()=>Ma(Pa(o,kr),r.strict));if(a)if(a.header.keyed||a.header.fields!==void 0){if(r.strict)throw a.header.keyed?ag(i):Tk(i)}else{yield*Na(a.header,a.inlineValues,e,t,r,i);return}}let s=rt(i,()=>Ma(Pa(o,kr),r.strict));if(s&&s.header.key!==void 0&&s.header.fields!==void 0){let a=s.header,c=r.strict?new Set([a.key]):void 0;yield{type:"startObject"},yield{type:"key",key:a.key},yield*Na(a,s.inlineValues,e,t+1,r,i),yield*Wh(e,t+1,r,c),yield{type:"endObject"};return}if(yk(o)){let a=r.strict?new Set:void 0;yield{type:"startObject"},yield*ji(i,e,t+1,r,a),yield*Wh(e,t+1,r,a),yield{type:"endObject"};return}yield{type:"primitive",value:rt(i,()=>Da(o))}}function*Wh(e,t,r,n){while(!0){let o=yield*Pt(e);if(!o||o.depth<t)break;if(o.depth===t&&!o.content.startsWith("- "))yield*bt(e),yield*ji(o,e,t,r,n);else break}}function zh(e){let t=e.content;if(t.startsWith('"')){let r=La(t,0);if(r===-1)return!1;return t.slice(r+1).includes(":")}else return t.includes(":")}function Ma(e,t){if(e.kind==="notHeader")return;if(e.kind==="invalid"){if(t)throw SyntaxError(e.reason);return}if(t&&e.strictError!==void 0)throw SyntaxError(e.strictError);return{header:e.header,inlineValues:e.inlineValues}}function*cg(e,t){let r=0;function*n(o){yield{type:"startObject"};for(let i of o){if(!i.children&&r>=t.length)continue;if(yield{type:"key",key:i.name},i.children)yield*n(i.children);else yield{type:"primitive",value:t[r++]}}yield{type:"endObject"}}yield*n(e)}function Hi(e,t,r){if(t==="__proto__"){Object.defineProperty(e,t,{value:r,enumerable:!0,writable:!0,configurable:!0});return}e[t]=r}function Pk(e){let t={stack:[],root:void 0};for(let r of e)Fk(t,r);return Nk(t)}function Fk(e,t){let{stack:r}=e;switch(t.type){case"startObject":{let n={};if(r.length===0)r.push({type:"object",obj:n});else{let o=r[r.length-1];if(o.type==="object"){if(o.currentKey===void 0)throw Error("Object startObject event without preceding key");Hi(o.obj,o.currentKey,n),o.currentKey=void 0}else if(o.type==="array")o.arr.push(n);r.push({type:"object",obj:n})}break}case"endObject":{if(r.length===0)throw Error("Unexpected endObject event");let n=r.pop();if(n.type!=="object")throw Error("Mismatched endObject event");if(r.length===0)e.root=n.obj;break}case"startArray":{let n=[];if(r.length===0)r.push({type:"array",arr:n});else{let o=r[r.length-1];if(o.type==="object"){if(o.currentKey===void 0)throw Error("Array startArray event without preceding key");Hi(o.obj,o.currentKey,n),o.currentKey=void 0}else if(o.type==="array")o.arr.push(n);r.push({type:"array",arr:n})}break}case"endArray":{if(r.length===0)throw Error("Unexpected endArray event");let n=r.pop();if(n.type!=="array")throw Error("Mismatched endArray event");if(r.length===0)e.root=n.arr;break}case"key":{if(r.length===0)throw Error("Key event outside of object context");let n=r[r.length-1];if(n.type!=="object")throw Error("Key event outside of object context");n.currentKey=t.key;break}case"primitive":if(r.length===0)e.root=t.value;else{let n=r[r.length-1];if(n.type==="object"){if(n.currentKey===void 0)throw Error("Primitive event without preceding key in object");Hi(n.obj,n.currentKey,t.value),n.currentKey=void 0}else if(n.type==="array")n.arr.push(t.value)}break}}function Nk(e){if(e.stack.length!==0)throw Error("Incomplete event stream: unclosed objects or arrays");if(e.root===void 0)throw Error("No root value built from events");return e.root}var Mk=new RegExp("(?:^\uFEFF?|\\n) *#"),Lk=class{constructor(e){if(Mk.test(e))throw TypeError(`Raw string must not contain a line starting with "#": ${JSON.stringify(e)}`);this.value=e}};function Ki(e){return e instanceof Lk}var Dk=/[\uD800-\uDFFF]/;function Kn(e){if(e===null)return null;if(Ki(e))return e;if(typeof e==="object"&&e!==null&&"toJSON"in e&&typeof e.toJSON==="function"){let t=e.toJSON();if(t!==e)return Kn(t)}if(typeof e==="string")return Vh(e,"string value"),e;if(typeof e==="boolean")return e;if(typeof e==="number"){if(Object.is(e,-0))return 0;if(!Number.isFinite(e))return null;return e}if(typeof e==="bigint"){if(e>=Number.MIN_SAFE_INTEGER&&e<=Number.MAX_SAFE_INTEGER)return Number(e);return e.toString()}if(e instanceof Date)return e.toISOString();if(Array.isArray(e))return e.map(Kn);if(e instanceof Set)return Array.from(e).map(Kn);if(e instanceof Map)return Object.fromEntries(Array.from(e,([t,r])=>[String(t),Kn(r)]));if(Uk(e)){let t={};for(let r in e)if(Object.hasOwn(e,r))Vh(r,"object key"),Hi(t,r,Kn(e[r]));return t}return null}function Vh(e,t){if(!Dk.test(e))return;for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);if(n<55296||n>57343)continue;let o=n<=56319,i=e.charCodeAt(r+1);if(o&&i>=56320&&i<=57343){r++;continue}throw TypeError(`Cannot encode ${t} containing an unpaired surrogate U+${n.toString(16).toUpperCase()} at index ${r}`)}}function qk(e){return e===null||typeof e==="string"||typeof e==="number"||typeof e==="boolean"}function Vn(e){return qk(e)||Ki(e)}function zn(e){return Array.isArray(e)}function Ar(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)&&!Ki(e)}function $i(e){return Object.keys(e).length===0}function Uk(e){if(e===null||typeof e!=="object")return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function Bi(e){return e.length===0||e.every((t)=>Vn(t))}function Hk(e){return e.length===0||e.every((t)=>zn(t))}function lg(e){return e.length===0||e.every((t)=>Ar(t))}var jk=/^[+-]?\d+(?:\.\d+)?(?:e[+-]?\d+)?$/i;function $k(e){if(!Object.values(Ca).includes(e))throw TypeError(`Invalid delimiter ${JSON.stringify(e)}. Valid delimiters are: comma (,), tab (\\t), pipe (|)`)}function Bk(e){return/^[A-Z_][\w.]*$/i.test(e)}function Kk(e,t=kr){if(!e)return!1;if(/^[ \t]|[ \t]$/.test(e))return!1;if(Xh(e)||Wk(e))return!1;if(e.includes(":"))return!1;if(e.includes('"')||e.includes("\\"))return!1;if(/[[\]{}]/.test(e))return!1;if(/[\u0000-\u001F]/.test(e))return!1;if(e.includes(t))return!1;if(e.startsWith("-"))return!1;if(e.startsWith("#"))return!1;return!0}function Wk(e){return jk.test(e)}function Wi(e,t){if(Ki(e))return e.value;if(e===null)return"null";if(typeof e==="boolean")return String(e);if(typeof e==="number")return String(e);return zk(e,t)}function zk(e,t=kr){if(Kk(e,t))return e;return`"${Gh(e)}"`}function Ho(e){if(Bk(e))return e;return`"${Gh(e)}"`}function Yu(e,t=kr){return e.map((r)=>Wi(r,t)).join(t)}function Tr(e,t){let r=t?.key,n=t?.fields,o=t?.delimiter??",",i="";if(r!=null)i+=Ho(r);if(i+=`[${e}${t?.keyed?":":""}${o!==kr?o:""}]`,n)i+=`{${ug(n,o)}}`;return i+=":",i}function ug(e,t){return e.map((r)=>Ho(r.name)+(r.children?`{${ug(r.children,t)}}`:"")).join(t)}function qa(e){if(e.length===0)return;let t=Object.keys(e[0]);if(t.length===0)return;for(let n of e){if(Object.keys(n).length!==t.length)return;for(let o of t)if(!Object.hasOwn(n,o))return}let r=[];for(let n of t){let o=Vk(n,e.map((i)=>i[n]));if(!o)return;r.push(o)}return r}function Zu(e){let t=Object.values(e);if(t.length<2)return;if(!t.every((r)=>Ar(r)&&!$i(r)))return;return qa(t)}function pg(e,t){let r=[];return fg(e,t,r),r}function Vk(e,t){if(t.every((n)=>Vn(n)))return{name:e};if(!t.every((n)=>Ar(n)&&!$i(n)))return;let r=qa(t);if(!r)return;return{name:e,children:r}}function fg(e,t,r){for(let n of t){let o=e[n.name];if(n.children)fg(o,n.children,r);else r.push(o)}}function*Jk(e,t,r){if(Vn(e)){let n=Wi(e,t.delimiter);if(n!=="")yield n;return}if(zn(e))yield*hg(void 0,e,r,t);else if(Ar(e)){let n=Zu(e);if(n){yield*dg(void 0,e,n,r,t);return}yield*Uo(e,r,t)}}function*Uo(e,t,r){for(let[n,o]of Object.entries(e))yield*Gk(n,o,t,r)}function*Gk(e,t,r,n){let o=Ho(e);if(Vn(t))yield Ft(r,`${o}: ${Wi(t,n.delimiter)}`,n.indentSize);else if(zn(t))yield*hg(e,t,r,n);else if(Ar(t)){let i=Zu(t);if(i){yield*dg(e,t,i,r,n);return}if(yield Ft(r,`${o}:`,n.indentSize),!$i(t))yield*Uo(t,r+1,n)}}function*dg(e,t,r,n,o){let i=Object.entries(t);yield Ft(n,Tr(i.length,{key:e,fields:r,delimiter:o.delimiter,keyed:!0}),o.indentSize),yield*mg(i,r,n+1,o)}function*mg(e,t,r,n){for(let[o,i]of e){let s=pg(i,t);yield Ft(r,`${Ho(o)}: ${Yu(s,n.delimiter)}`,n.indentSize)}}function*hg(e,t,r,n){if(t.length===0){yield Ft(r,e!=null?`${Ho(e)}: []`:"[]",n.indentSize);return}if(Bi(t)){yield Ft(r,Ua(t,n.delimiter,e),n.indentSize);return}if(Hk(t)){if(t.every((o)=>Bi(o))){yield*Yk(e,t,r,n);return}}if(lg(t)){let o=qa(t);if(o)yield*Zk(e,t,o,r,n);else yield*Jh(e,t,r,n);return}yield*Jh(e,t,r,n)}function*Yk(e,t,r,n){yield Ft(r,Tr(t.length,{key:e,delimiter:n.delimiter}),n.indentSize);for(let o of t)if(Bi(o)){let i=Ua(o,n.delimiter);yield Kt(r+1,i,n.indentSize)}}function Ua(e,t,r){let n=Tr(e.length,{key:r,delimiter:t}),o=Yu(e,t);if(e.length===0)return n;return`${n} ${o}`}function*Zk(e,t,r,n,o){yield Ft(n,Tr(t.length,{key:e,fields:r,delimiter:o.delimiter}),o.indentSize),yield*gg(t,r,n+1,o)}function*gg(e,t,r,n){for(let o of e)yield Ft(r,Yu(pg(o,t),n.delimiter),n.indentSize)}function*Jh(e,t,r,n){yield Ft(r,Tr(t.length,{key:e,delimiter:n.delimiter}),n.indentSize);for(let o of t)yield*Qu(o,r+1,n)}function*Qk(e,t,r){if($i(e)){yield Ft(t,"-",r.indentSize);return}let n=Object.entries(e),[o,i]=n[0],s=n.slice(1);if(zn(i)&&lg(i)){let c=qa(i);if(c){if(yield Kt(t,Tr(i.length,{key:o,fields:c,delimiter:r.delimiter}),r.indentSize),yield*gg(i,c,t+2,r),s.length>0)yield*Uo(Object.fromEntries(s),t+1,r);return}}if(Ar(i)){let c=Zu(i);if(c){let l=Object.entries(i);if(yield Kt(t,Tr(l.length,{key:o,fields:c,delimiter:r.delimiter,keyed:!0}),r.indentSize),yield*mg(l,c,t+2,r),s.length>0)yield*Uo(Object.fromEntries(s),t+1,r);return}}let a=Ho(o);if(Vn(i))yield Kt(t,`${a}: ${Wi(i,r.delimiter)}`,r.indentSize);else if(zn(i))if(i.length===0)yield Kt(t,`${a}: []`,r.indentSize);else if(Bi(i))yield Kt(t,`${a}${Ua(i,r.delimiter)}`,r.indentSize);else{yield Kt(t,`${a}${Tr(i.length,{delimiter:r.delimiter})}`,r.indentSize);for(let c of i)yield*Qu(c,t+2,r)}else if(Ar(i)){if(yield Kt(t,`${a}:`,r.indentSize),!$i(i))yield*Uo(i,t+2,r)}if(s.length>0)yield*Uo(Object.fromEntries(s),t+1,r)}function*Qu(e,t,r){if(Vn(e))yield Kt(t,Wi(e,r.delimiter),r.indentSize);else if(zn(e))if(Bi(e))yield Kt(t,Ua(e,r.delimiter),r.indentSize);else{yield Kt(t,Tr(e.length,{delimiter:r.delimiter}),r.indentSize);for(let n of e)yield*Qu(n,t+1,r)}else if(Ar(e))yield*Qk(e,t,r)}function Ft(e,t,r){return" ".repeat(r*e)+t}function Kt(e,t,r){return Ft(e,"- "+t,r)}function Xk(e,t){let r=t("",e,[]);if(r===void 0)return Wu(e,t,[]);return Xu(e,r,t,[])}function Xu(e,t,r,n){if(Ki(t)&&!Vn(e))return Wu(e,r,n);return Wu(Kn(t),r,n)}function Wu(e,t,r){if(Ar(e))return eA(e,t,r);if(zn(e))return tA(e,t,r);return e}function eA(e,t,r){let n={};for(let[o,i]of Object.entries(e)){let s=[...r,o],a=t(o,i,s);if(a===void 0)continue;Hi(n,o,Xu(i,a,t,s))}return n}function tA(e,t,r){let n=[];for(let o=0;o<e.length;o++){let i=e[o],s=[...r,o],a=t(String(o),i,s);if(a===void 0)continue;n.push(Xu(i,a,t,s))}return n}function zi(e,t){return Array.from(rA(e,t)).join(`
|
|
5
|
+
`)}function yg(e,t){return nA(e.split(`
|
|
6
|
+
`),t)}function rA(e,t){let r=Kn(e),n=oA(t);return Jk(n.replacer?Xk(r,n.replacer):r,n,0)}function nA(e,t){return Pk(_k(e,iA(t)))}function oA(e){let t=e?.delimiter??kr;return $k(t),{indentSize:e?.indentSize??e?.indent??2,delimiter:t,replacer:e?.replacer}}function iA(e){return{indentSize:e?.indentSize??e?.indent??2,strict:e?.strict??!0}}class nt extends Error{code;details;constructor(e,t,r={},n){super(t,n);this.name="CoreError",this.code=e,this.details=r,cr(this.details),Object.freeze(this)}}var ep=(e)=>typeof e==="function",p=function(e,t){if(typeof e==="function")return function(){if(e(arguments))return t.apply(this,arguments);return(r)=>t(r,...arguments)};switch(e){case 0:case 1:throw RangeError(`Invalid arity ${e}`);case 2:return function(r,n){if(arguments.length>=2)return t(r,n);return function(o){return t(o,r)}};case 3:return function(r,n,o){if(arguments.length>=3)return t(r,n,o);return function(i){return t(i,r,n)}};case 4:return function(r,n,o,i){if(arguments.length>=4)return t(r,n,o,i);return function(s){return t(s,r,n,o)}};case 5:return function(r,n,o,i,s){if(arguments.length>=5)return t(r,n,o,i,s);return function(a){return t(a,r,n,o,i)}};default:return function(){if(arguments.length>=e)return t.apply(this,arguments);let r=arguments;return function(n){return t(n,...r)}}}};var Q=(e)=>e;var Vi=(e)=>()=>e,Ji=Vi(!0),an=Vi(!1);var Ha=Vi(void 0),Gi=Ha;function m(e,t,r,n,o,i,s,a,c){switch(arguments.length){case 1:return e;case 2:return t(e);case 3:return r(t(e));case 4:return n(r(t(e)));case 5:return o(n(r(t(e))));case 6:return i(o(n(r(t(e)))));case 7:return s(i(o(n(r(t(e))))));case 8:return a(s(i(o(n(r(t(e)))))));case 9:return c(a(s(i(o(n(r(t(e))))))));default:{let l=arguments[0];for(let u=1;u<arguments.length;u++)l=arguments[u](l);return l}}}var Zi=(e)=>(t,r)=>t===r||e(t,r),sA=(e,t)=>e===t,aA=()=>sA;var cA=aA();var tp=p(2,(e,t)=>Zi((r,n)=>e(t(r),t(n)))),xg=tp(cA,(e)=>e.getTime());var Sg=(e)=>Zi((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 Qi,N=(e,t)=>{if(!Qi)globalThis["effect/GlobalValue"]??=new Map,Qi=globalThis["effect/GlobalValue"];if(!Qi.has(e))Qi.set(e,t());return Qi.get(e)};var Be=(e)=>typeof e==="string",_t=(e)=>typeof e==="number",Jn=(e)=>typeof e==="boolean",cn=(e)=>typeof e==="bigint",Gn=(e)=>typeof e==="symbol";var ln=ep,bg=(e)=>e===void 0;var _g=(e)=>!1;var Xi=(e)=>typeof e==="object"&&e!==null,ot=(e)=>Xi(e)||ln(e),_=p(2,(e,t)=>ot(e)&&(t in e)),es=p(2,(e,t)=>_(e,"_tag")&&e._tag===t),Yn=(e)=>e===null||e===void 0,wg=(e)=>e!==null&&e!==void 0;var $a=(e)=>e instanceof Date,rp=(e)=>typeof e==="string"||_(e,Symbol.iterator),np=(e)=>Xi(e)&&!Array.isArray(e);var Eg=(e)=>_(e,"then")&&ln(e.then);var Zn=(e)=>`BUG: ${e} - please report an issue at https://github.com/Effect-TS/effect/issues`;class $o{self;called=!1;constructor(e){this.self=e}next(e){return this.called?{value:e,done:!0}:(this.called=!0,{value:this.self,done:!1})}return(e){return{value:e,done:!0}}throw(e){throw e}[Symbol.iterator](){return new $o(this.self)}}var lA=335903614,uA=4150755663,pA=1481765933,fA=1284865837,dA=9007199254740992,mA=134217728;class ip{_state;constructor(e,t,r,n){if(Yn(t)&&Yn(e))t=Math.random()*4294967295>>>0,e=0;else if(Yn(t))t=e,e=0;if(Yn(n)&&Yn(r))n=this._state?this._state[3]:uA,r=this._state?this._state[2]:lA;else if(Yn(n))n=r,r=0;return this._state=new Int32Array([0,0,r>>>0,((n||0)|1)>>>0]),this._next(),Og(this._state,this._state[0],this._state[1],e>>>0,t>>>0),this._next(),this}getState(){return[this._state[0],this._state[1],this._state[2],this._state[3]]}setState(e){this._state[0]=e[0],this._state[1]=e[1],this._state[2]=e[2],this._state[3]=e[3]|1}integer(e){return Math.round(this.number()*Number.MAX_SAFE_INTEGER)%e}number(){let e=(this._next()&67108863)*1,t=(this._next()&134217727)*1;return(e*mA+t)/dA}_next(){let e=this._state[0]>>>0,t=this._state[1]>>>0;hA(this._state,e,t,pA,fA),Og(this._state,this._state[0],this._state[1],this._state[2],this._state[3]);let r=e>>>18,n=(t>>>18|e<<14)>>>0;r=(r^e)>>>0,n=(n^t)>>>0;let o=(n>>>27|r<<5)>>>0,i=e>>>27,s=(-i>>>0&31)>>>0;return(o>>>i|o<<s)>>>0}}function hA(e,t,r,n,o){let i=(r>>>16)*(o&65535)>>>0,s=(r&65535)*(o>>>16)>>>0,a=(r&65535)*(o&65535)>>>0,c=(r>>>16)*(o>>>16)+((s>>>16)+(i>>>16))>>>0;if(s=s<<16>>>0,a=a+s>>>0,a>>>0<s>>>0)c=c+1>>>0;if(i=i<<16>>>0,a=a+i>>>0,a>>>0<i>>>0)c=c+1>>>0;c=c+Math.imul(r,n)>>>0,c=c+Math.imul(t,o)>>>0,e[0]=c,e[1]=a}function Og(e,t,r,n,o){let i=t+n>>>0,s=r+o>>>0;if(s>>>0<r>>>0)i=i+1|0;e[0]=i,e[1]=s}var op=Symbol.for("effect/Utils/YieldWrap");class Ir{#e;constructor(e){this.#e=e}[op](){return this.#e}}function sp(e){if(typeof e==="object"&&e!==null&&op in e)return e[op]();throw Error(Zn("yieldWrapGet"))}var ct=N("effect/Utils/isStructuralRegion",()=>({enabled:!1,tester:void 0}));var Tg={effect_internal_function:(e)=>e()},gA={effect_internal_function:(e)=>{try{return e()}finally{}}},yA=Tg.effect_internal_function(()=>Error().stack)?.includes("effect_internal_function")===!0,Ke=yA?Tg.effect_internal_function:gA.effect_internal_function,eL=function*(){}.constructor;var ap=N(Symbol.for("effect/Hash/randomHashCache"),()=>new WeakMap),k=Symbol.for("effect/Hash"),S=(e)=>{if(ct.enabled===!0)return 0;switch(typeof e){case"number":return Ka(e);case"bigint":return ne(e.toString(10));case"boolean":return ne(String(e));case"symbol":return ne(String(e));case"string":return ne(e);case"undefined":return ne("undefined");case"function":case"object":if(e===null)return ne("null");else if(e instanceof Date){if(Number.isNaN(e.getTime()))return ne("Invalid Date");return S(e.toISOString())}else if(e instanceof URL)return S(e.href);else if(SA(e))return e[k]();else return ts(e);default:throw Error(`BUG: unhandled typeof ${typeof e} - please report an issue at https://github.com/Effect-TS/effect/issues`)}},ts=(e)=>{if(!ap.has(e))ap.set(e,Ka(Math.floor(Math.random()*Number.MAX_SAFE_INTEGER)));return ap.get(e)},H=(e)=>(t)=>t*53^e,Ba=(e)=>e&3221225471|e>>>1&1073741824,SA=(e)=>_(e,k),Ka=(e)=>{if(e!==e||e===1/0)return 0;let t=e|0;if(t!==e)t^=e*4294967295;while(e>4294967295)t^=e/=4294967295;return Ba(t)},ne=(e)=>{let t=5381,r=e.length;while(r)t=t*33^e.charCodeAt(--r);return Ba(t)},bA=(e,t)=>{let r=12289;for(let n=0;n<t.length;n++)r^=m(ne(t[n]),H(S(e[t[n]])));return Ba(r)},Wa=(e)=>bA(e,Object.keys(e)),wt=(e)=>{let t=6151;for(let r=0;r<e.length;r++)t=m(t,H(S(e[r])));return Ba(t)},Z=function(){if(arguments.length===1){let r=arguments[0];return function(n){return Object.defineProperty(r,k,{value(){return n},enumerable:!1}),n}}let e=arguments[0],t=arguments[1];return Object.defineProperty(e,k,{value(){return t},enumerable:!1}),t};var O=Symbol.for("effect/Equal");function b(){if(arguments.length===1)return(e)=>za(e,arguments[0]);return za(arguments[0],arguments[1])}function za(e,t){if(e===t)return!0;let r=typeof e;if(r!==typeof t)return!1;if(r==="object"||r==="function"){if(e!==null&&t!==null){if(rs(e)&&rs(t))if(S(e)===S(t)&&e[O](t))return!0;else return ct.enabled&&ct.tester?ct.tester(e,t):!1;else if(e instanceof Date&&t instanceof Date){let n=e.getTime(),o=t.getTime();return n===o||Number.isNaN(n)&&Number.isNaN(o)}else if(e instanceof URL&&t instanceof URL)return e.href===t.href}if(ct.enabled){if(e===null||t===null)return!1;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((n,o)=>za(n,t[o]));if(Object.getPrototypeOf(e)===Object.prototype&&Object.getPrototypeOf(t)===Object.prototype){let n=Object.keys(e),o=Object.keys(t);if(n.length===o.length){for(let i of n)if(!((i in t)&&za(e[i],t[i])))return ct.tester?ct.tester(e,t):!1;return!0}}return ct.tester?ct.tester(e,t):!1}}return ct.enabled&&ct.tester?ct.tester(e,t):!1}var rs=(e)=>_(e,O),ns=()=>b;var J=Symbol.for("nodejs.util.inspect.custom"),X=(e)=>{try{if(_(e,"toJSON")&&ln(e.toJSON)&&e.toJSON.length===0)return e.toJSON();else if(Array.isArray(e))return e.map(X)}catch{return{}}return Ig(e)},cp="[Circular]";function _A(e){try{return e.toISOString()}catch{return"Invalid Date"}}function wA(e){try{let t=e.toString();return typeof t==="string"?t:String(t)}catch{return"[toString threw]"}}function os(e){return Be(e)?JSON.stringify(e):String(e)}function lr(e,t){let r=t?.space??0,n=new WeakSet,o=!r?"":_t(r)?" ".repeat(r):r,i=(l)=>o.repeat(l),s=(l,u)=>{let f=l?.constructor;return f&&f!==Object.prototype.constructor&&f.name?`${f.name}(${u})`:u},a=(l)=>{try{return Reflect.ownKeys(l)}catch{return["[ownKeys threw]"]}};function c(l,u=0){if(Array.isArray(l)){if(n.has(l))return cp;if(n.add(l),!o||l.length<=1)return`[${l.map((d)=>c(d,u)).join(",")}]`;let f=l.map((d)=>c(d,u+1)).join(`,
|
|
7
|
+
`+i(u+1));return`[
|
|
8
|
+
${i(u+1)}${f}
|
|
9
|
+
${i(u)}]`}if($a(l))return _A(l);if(!t?.ignoreToString&&_(l,"toString")&&ln(l.toString)&&l.toString!==Object.prototype.toString&&l.toString!==Array.prototype.toString){let f=wA(l);if(l instanceof Error&&l.cause)return`${f} (cause: ${c(l.cause,u)})`;return f}if(Be(l))return JSON.stringify(l);if(_t(l)||l==null||Jn(l)||Gn(l))return String(l);if(cn(l))return String(l)+"n";if(l instanceof Set||l instanceof Map){if(n.has(l))return cp;return n.add(l),`${l.constructor.name}(${c(Array.from(l),u)})`}if(ot(l)){if(n.has(l))return cp;n.add(l);let f=a(l);if(!o||f.length<=1){let h=`{${f.map((g)=>`${os(g)}:${c(l[g],u)}`).join(",")}}`;return s(l,h)}let d=`{
|
|
10
|
+
${f.map((h)=>`${i(u+1)}${os(h)}: ${c(l[h],u+1)}`).join(`,
|
|
11
|
+
`)}
|
|
12
|
+
${i(u)}}`;return s(l,d)}return String(l)}return c(e,0)}var oe=(e)=>JSON.stringify(e,null,2),cL={toJSON(){return X(this)},[J](){return this.toJSON()},toString(){return oe(this.toJSON())}};var Rr=(e,t=2)=>{if(typeof e==="string")return e;try{return typeof e==="object"?Va(e,t):String(e)}catch{return String(e)}},Va=(e,t)=>{let r=[],n=JSON.stringify(e,(o,i)=>typeof i==="object"&&i!==null?r.includes(i)?void 0:r.push(i)&&(Qn.fiberRefs!==void 0&&kg(i)?i[lp](Qn.fiberRefs):i):i,t);return r=void 0,n},lp=Symbol.for("effect/Inspectable/Redactable"),kg=(e)=>typeof e==="object"&&e!==null&&(lp in e),Qn=N("effect/Inspectable/redactableState",()=>({fiberRefs:void 0})),Ag=(e,t)=>{let r=Qn.fiberRefs;Qn.fiberRefs=e;try{return t()}finally{Qn.fiberRefs=r}},Ig=(e)=>{if(kg(e)&&Qn.fiberRefs!==void 0)return e[lp](Qn.fiberRefs);return e};var y=(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}}};var eo="Async",to="Commit",lt="Failure",is="OnFailure",Bo="OnSuccess",Ko="OnSuccessAndFailure",ut="Success",Ja="Sync",Rg="Tag",ro="UpdateRuntimeFlags",Wo="While",zo="Iterator",Ga="WithRuntime",Vo="Yield",ss="RevertFlags";var EA="3.22.1",as=()=>EA;var Cg=Symbol.for("effect/Effect"),Pg=Symbol.for("effect/Stream"),Fg=Symbol.for("effect/Sink"),Ng=Symbol.for("effect/Channel"),un={_R:(e)=>e,_E:(e)=>e,_A:(e)=>e,_V:as()},OA={_A:(e)=>e,_In:(e)=>e,_L:(e)=>e,_E:(e)=>e,_R:(e)=>e},TA={_Env:(e)=>e,_InErr:(e)=>e,_InElem:(e)=>e,_InDone:(e)=>e,_OutErr:(e)=>e,_OutElem:(e)=>e,_OutDone:(e)=>e},vr={[Cg]:un,[Pg]:un,[Fg]:OA,[Ng]:TA,[O](e){return this===e},[k](){return Z(this,ts(this))},[Symbol.iterator](){return new $o(new Ir(this))},pipe(){return y(this,arguments)}},cs={[k](){return Z(this,Wa(this))},[O](e){let t=Object.keys(this),r=Object.keys(e);if(t.length!==r.length)return!1;for(let n of t)if(!((n in e)&&b(this[n],e[n])))return!1;return!0}},pn={...vr,_op:to},pp={...pn,...cs},Mg=function(){function e(){}return e.prototype=pn,e}();var Dg=Symbol.for("effect/Option"),qg={...vr,[Dg]:{_A:(e)=>e},[J](){return this.toJSON()},toString(){return oe(this.toJSON())}},kA=Object.assign(Object.create(qg),{_tag:"Some",_op:"Some",[O](e){return fp(e)&&mp(e)&&b(this.value,e.value)},[k](){return Z(this,H(S(this._tag))(S(this.value)))},toJSON(){return{_id:"Option",_tag:this._tag,value:X(this.value)}}}),AA=S("None"),IA=Object.assign(Object.create(qg),{_tag:"None",_op:"None",[O](e){return fp(e)&&dp(e)},[k](){return AA},toJSON(){return{_id:"Option",_tag:this._tag}}}),fp=(e)=>_(e,Dg),dp=(e)=>e._tag==="None",mp=(e)=>e._tag==="Some",Ya=Object.create(IA),ls=(e)=>{let t=Object.create(kA);return t.value=e,t};var hp=Symbol.for("effect/Either"),Hg={...vr,[hp]:{_R:(e)=>e},[J](){return this.toJSON()},toString(){return oe(this.toJSON())}},RA=Object.assign(Object.create(Hg),{_tag:"Right",_op:"Right",[O](e){return Za(e)&&yp(e)&&b(this.right,e.right)},[k](){return H(S(this._tag))(S(this.right))},toJSON(){return{_id:"Either",_tag:this._tag,right:X(this.right)}}}),vA=Object.assign(Object.create(Hg),{_tag:"Left",_op:"Left",[O](e){return Za(e)&&gp(e)&&b(this.left,e.left)},[k](){return H(S(this._tag))(S(this.left))},toJSON(){return{_id:"Either",_tag:this._tag,left:X(this.left)}}}),Za=(e)=>_(e,hp),gp=(e)=>e._tag==="Left",yp=(e)=>e._tag==="Right",jg=(e)=>{let t=Object.create(vA);return t.left=e,t},$g=(e)=>{let t=Object.create(RA);return t.right=e,t};var B=$g;var U=jg;var xp=Za,he=gp,pt=yp;var Qa=p(2,(e,t)=>he(e)?U(t(e.left)):B(e.right)),Bg=p(2,(e,t)=>pt(e)?B(t(e.right)):U(e.left)),us=p(2,(e,{onLeft:t,onRight:r})=>he(e)?t(e.left):r(e.right));var Kg=us({onLeft:Q,onRight:Q});var Sp=p(2,(e,t)=>{if(pt(e))return e.right;throw t(e.left)}),Wg=Sp(()=>Error("getOrThrow called on a Left"));var bp=(e)=>e.length>0;var zg=(e)=>(t,r)=>t===r?0:e(t,r);var Vg=zg((e,t)=>e<t?-1:1);var Xa=p(2,(e,t)=>zg((r,n)=>e(t(r),t(n))));var _p=(e)=>p(2,(t,r)=>e(t,r)===1);var w=()=>Ya,I=ls;var ye=dp,ue=mp,Ee=p(2,(e,{onNone:t,onSome:r})=>ye(e)?t():r(e.value));var ce=p(2,(e,t)=>ye(e)?t():e.value),Wt=p(2,(e,t)=>ye(e)?t():e),Jg=p(2,(e,t)=>ye(e)?I(t()):e);var Pr=(e)=>e==null?w():I(e);var ft=ce(Ha),Gg=(e)=>(...t)=>{try{return I(e(...t))}catch{return w()}};var zt=p(2,(e,t)=>ye(e)?w():I(t(e.value)));var Vt=p(2,(e,t)=>ye(e)?w():t(e.value));var Yg=p(2,(e,t)=>ye(e)?w():Pr(t(e.value)));var NA=(e)=>p(2,(t,r)=>ye(t)?!1:e(t.value,r)),MA=ns(),Zg=NA(MA),Qg=p(2,(e,t)=>ye(e)?!1:t(e.value));var Xg=(...e)=>e;var no=(e)=>Array(e),Ep=p(2,(e,t)=>{let r=Math.max(1,Math.floor(e)),n=Array(r);for(let o=0;o<r;o++)n[o]=t(o);return n});var pe=(e)=>Array.isArray(e)?e:Array.from(e),Op=(e)=>Array.isArray(e)?e:[e];var ey=p(2,(e,{onEmpty:t,onNonEmpty:r})=>se(e)?r(Ie(e),Jt(e)):t());var Jo=p(2,(e,t)=>[t,...e]);var ty=p(2,(e,t)=>[...e,t]),Tp=p(2,(e,t)=>pe(e).concat(pe(t)));var kp=Array.isArray,DA=(e)=>e.length===0,ry=DA,fn=bp,se=bp;var ny=(e,t)=>e<0||e>=t.length,qA=(e,t)=>Math.floor(Math.min(Math.max(0,e),t.length)),UA=p(2,(e,t)=>{let r=Math.floor(t);return ny(r,e)?w():I(e[r])}),Ap=p(2,(e,t)=>{let r=Math.floor(t);if(ny(r,e))throw Error(`Index ${r} out of bounds`);return e[r]});var Fr=UA(0),Ie=Ap(0),oy=(e)=>se(e)?I(Ip(e)):w(),Ip=(e)=>e[e.length-1];var Jt=(e)=>e.slice(1);var HA=(e,t)=>{let r=0;for(let n of e){if(!t(n,r))break;r++}return r},iy=p(2,(e,t)=>$A(e,HA(e,t))),sy=p(2,(e,t)=>{let r=pe(e);return r.slice(qA(t,r),r.length)});var Rp=(e)=>Array.from(e).reverse(),Nr=p(2,(e,t)=>{let r=Array.from(e);return r.sort(t),r});var vp=p(2,(e,t)=>ay(e,t,Xg)),ay=p(3,(e,t,r)=>{let n=pe(e),o=pe(t);if(se(n)&&se(o)){let i=[r(Ie(n),Ie(o))],s=Math.min(n.length,o.length);for(let a=1;a<s;a++)i[a]=r(n[a],o[a]);return i}return[]});var jA=ns();var $A=p(2,(e,t)=>{let r=Array.from(e),n=Math.floor(t);if(se(r)){if(n>=1)return BA(r,n);return[[],r]}return[r,[]]}),BA=p(2,(e,t)=>{let r=Math.max(1,Math.floor(t));return r>=e.length?[Go(e),[]]:[Jo(e.slice(1,r),Ie(e)),e.slice(r)]});var Go=(e)=>e.slice();var KA=p(3,(e,t,r)=>{let n=pe(e),o=pe(t);if(se(n)){if(se(o))return cy(r)(Tp(n,o));return n}return o}),dn=p(2,(e,t)=>KA(e,t,jA));var Mr=()=>[],Ve=(e)=>[e],Gt=p(2,(e,t)=>e.map(t)),ps=p(2,(e,t)=>{if(ry(e))return[];let r=[];for(let n=0;n<e.length;n++){let o=t(e[n],n);for(let i=0;i<o.length;i++)r.push(o[i])}return r}),ec=ps(Q),tc=p(2,(e,t)=>{let r=pe(e),n=[];for(let o=0;o<r.length;o++){let i=t(r[o],o);if(ue(i))n.push(i.value)}return n});var Yo=p(3,(e,t,r)=>pe(e).reduce((n,o,i)=>r(n,o,i),t));var Cp=(e,t)=>{let r=[],n=e,o;while(ue(o=t(n))){let[i,s]=o.value;r.push(i),n=s}return r};var mn=Sg;var cy=p(2,(e,t)=>{let r=pe(e);if(se(r)){let n=[Ie(r)],o=Jt(r);for(let i of o)if(n.every((s)=>!t(i,s)))n.push(i);return n}return[]}),Pp=(e)=>cy(e,ns());var Lr=p(2,(e,t)=>pe(e).join(t));var uy=Symbol.for("effect/Chunk");function JA(e,t,r,n,o){for(let i=t;i<Math.min(e.length,t+o);i++)r[n+i-t]=e[i];return r}var py=[],GA=(e)=>Zi((t,r)=>t.length===r.length&&Dr(t).every((n,o)=>e(n,Zo(r,o)))),YA=GA(b),ZA={[uy]:{_A:(e)=>e},toString(){return oe(this.toJSON())},toJSON(){return{_id:"Chunk",values:Dr(this).map(X)}},[J](){return this.toJSON()},[O](e){return fy(e)&&YA(this,e)},[k](){return Z(this,wt(Dr(this)))},[Symbol.iterator](){switch(this.backing._tag){case"IArray":return this.backing.array[Symbol.iterator]();case"IEmpty":return py[Symbol.iterator]();default:return Dr(this)[Symbol.iterator]()}},pipe(){return y(this,arguments)}},Pe=(e)=>{let t=Object.create(ZA);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=ur,t.right=ur;break}case"ISingleton":{t.length=1,t.depth=0,t.left=ur,t.right=ur;break}case"ISlice":{t.length=e.length,t.depth=e.chunk.depth+1,t.left=ur,t.right=ur;break}}return t},fy=(e)=>_(e,uy),ur=Pe({_tag:"IEmpty"}),Nt=()=>ur,fs=(...e)=>eI(e),Re=(e)=>Pe({_tag:"ISingleton",a:e}),rc=(e)=>fy(e)?e:ds(pe(e)),Fp=(e,t,r)=>{switch(e.backing._tag){case"IArray":{JA(e.backing.array,0,t,r,e.length);break}case"IConcat":{Fp(e.left,t,r),Fp(e.right,t,r+e.left.length);break}case"ISingleton":{t[r]=e.backing.a;break}case"ISlice":{let n=0,o=r;while(n<e.length)t[o]=Zo(e,n),n+=1,o+=1;break}}};var QA=(e)=>{switch(e.backing._tag){case"IEmpty":return py;case"IArray":return e.backing.array;default:{let t=Array(e.length);return Fp(e,t,0),e.backing={_tag:"IArray",array:t},e.left=ur,e.right=ur,e.depth=0,t}}},Dr=QA,XA=(e)=>{switch(e.backing._tag){case"IEmpty":case"ISingleton":return e;case"IArray":return Pe({_tag:"IArray",array:Rp(e.backing.array)});case"IConcat":return Pe({_tag:"IConcat",left:hn(e.backing.right),right:hn(e.backing.left)});case"ISlice":return ds(Rp(Dr(e)))}},hn=XA;var ds=(e)=>e.length===0?Nt():e.length===1?Re(e[0]):Pe({_tag:"IArray",array:e}),eI=(e)=>ds(e),Zo=p(2,(e,t)=>{switch(e.backing._tag){case"IEmpty":throw Error("Index out of bounds");case"ISingleton":{if(t!==0)throw Error("Index out of bounds");return e.backing.a}case"IArray":{if(t>=e.length||t<0)throw Error("Index out of bounds");return e.backing.array[t]}case"IConcat":return t<e.left.length?Zo(e.left,t):Zo(e.right,t-e.left.length);case"ISlice":return Zo(e.backing.chunk,t+e.backing.offset)}}),dy=p(2,(e,t)=>Et(e,Re(t))),Je=p(2,(e,t)=>Et(Re(t),e));var Np=p(2,(e,t)=>{if(t<=0)return e;else if(t>=e.length)return ur;else switch(e.backing._tag){case"ISlice":return Pe({_tag:"ISlice",chunk:e.backing.chunk,offset:e.backing.offset+t,length:e.backing.length-t});case"IConcat":{if(t>e.left.length)return Np(e.right,t-e.left.length);return Pe({_tag:"IConcat",left:Np(e.left,t),right:e.right})}default:return Pe({_tag:"ISlice",chunk:e,offset:t,length:e.length-t})}});var Et=p(2,(e,t)=>{if(e.backing._tag==="IEmpty")return t;if(t.backing._tag==="IEmpty")return e;let r=t.depth-e.depth;if(Math.abs(r)<=1)return Pe({_tag:"IConcat",left:e,right:t});else if(r<-1)if(e.left.depth>=e.right.depth){let n=Et(e.right,t);return Pe({_tag:"IConcat",left:e.left,right:n})}else{let n=Et(e.right.right,t);if(n.depth===e.depth-3){let o=Pe({_tag:"IConcat",left:e.right.left,right:n});return Pe({_tag:"IConcat",left:e.left,right:o})}else{let o=Pe({_tag:"IConcat",left:e.left,right:e.right.left});return Pe({_tag:"IConcat",left:o,right:n})}}else if(t.right.depth>=t.left.depth){let n=Et(e,t.left);return Pe({_tag:"IConcat",left:n,right:t.right})}else{let n=Et(e,t.left.left);if(n.depth===t.depth-3){let o=Pe({_tag:"IConcat",left:n,right:t.left.right});return Pe({_tag:"IConcat",left:o,right:t.right})}else{let o=Pe({_tag:"IConcat",left:t.left.right,right:t.right});return Pe({_tag:"IConcat",left:n,right:o})}}});var my=(e)=>e.length===0,Yt=(e)=>e.length>0;var Mp=(e)=>Zo(e,0),Zt=Mp;var Qt=(e)=>Np(e,1);var gn=5,Lp=Math.pow(2,5),hy=Lp-1,gy=Lp/2,yy=Lp/4;function tI(e){return e-=e>>1&1431655765,e=(e&858993459)+(e>>2&858993459),e=e+(e>>4)&252645135,e+=e>>8,e+=e>>16,e&127}function yn(e,t){return t>>>e&hy}function xn(e){return 1<<e}function nc(e,t){return tI(e&t-1)}var xy=(e,t)=>({value:e,previous:t});function oo(e,t,r,n){let o=n;if(!e){let i=n.length;o=Array(i);for(let s=0;s<i;++s)o[s]=n[s]}return o[t]=r,o}function Dp(e,t,r){let n=r.length-1,o=0,i=0,s=r;if(e)o=i=t;else{s=Array(n);while(o<t)s[i++]=r[o++]}++o;while(o<=n)s[i++]=r[o++];if(e)s.length=n;return s}function Sy(e,t,r,n){let o=n.length;if(e){let c=o;while(c>=t)n[c--]=n[c];return n[t]=r,n}let i=0,s=0,a=Array(o+1);while(i<t)a[s++]=n[i++];a[t]=r;while(i<o)a[++s]=n[i++];return a}class Ur{_tag="EmptyNode";modify(e,t,r,n,o,i){let s=r(w());if(ye(s))return new Ur;return++i.value,new io(e,n,o,s)}}function Mt(e){return es(e,"EmptyNode")}function nI(e){return Mt(e)||e._tag==="LeafNode"||e._tag==="CollisionNode"}function oc(e,t){return Mt(e)?!1:t===e.edit}class io{edit;hash;key;value;_tag="LeafNode";constructor(e,t,r,n){this.edit=e,this.hash=t,this.key=r,this.value=n}modify(e,t,r,n,o,i){if(b(o,this.key)){let a=r(this.value);if(a===this.value)return this;else if(ye(a))return--i.value,new Ur;if(oc(this,e))return this.value=a,this;return new io(e,n,o,a)}let s=r(w());if(ye(s))return this;return++i.value,by(e,t,this.hash,this,n,new io(e,n,o,s))}}class qp{edit;hash;children;_tag="CollisionNode";constructor(e,t,r){this.edit=e,this.hash=t,this.children=r}modify(e,t,r,n,o,i){if(n===this.hash){let a=oc(this,e),c=this.updateCollisionList(a,e,this.hash,this.children,r,o,i);if(c===this.children)return this;return c.length>1?new qp(e,this.hash,c):c[0]}let s=r(w());if(ye(s))return this;return++i.value,by(e,t,this.hash,this,n,new io(e,n,o,s))}updateCollisionList(e,t,r,n,o,i,s){let a=n.length;for(let l=0;l<a;++l){let u=n[l];if("key"in u&&b(i,u.key)){let f=u.value,d=o(f);if(d===f)return n;if(ye(d))return--s.value,Dp(e,l,n);return oo(e,l,new io(t,r,i,d),n)}}let c=o(w());if(ye(c))return n;return++s.value,oo(e,a,new io(t,r,i,c),n)}}class Qo{edit;mask;children;_tag="IndexedNode";constructor(e,t,r){this.edit=e,this.mask=t,this.children=r}modify(e,t,r,n,o,i){let s=this.mask,a=this.children,c=yn(t,n),l=xn(c),u=nc(s,l),f=s&l,d=oc(this,e);if(!f){let E=new Ur().modify(e,t+gn,r,n,o,i);if(!E)return this;return a.length>=gy?iI(e,c,E,s,a):new Qo(e,s|l,Sy(d,u,E,a))}let h=a[u],g=h.modify(e,t+gn,r,n,o,i);if(h===g)return this;let P=s,x;if(Mt(g)){if(P&=~l,!P)return new Ur;if(a.length<=2&&nI(a[u^1]))return a[u^1];x=Dp(d,u,a)}else x=oo(d,u,g,a);if(d)return this.mask=P,this.children=x,this;return new Qo(e,P,x)}}class Up{edit;size;children;_tag="ArrayNode";constructor(e,t,r){this.edit=e,this.size=t,this.children=r}modify(e,t,r,n,o,i){let s=this.size,a=this.children,c=yn(t,n),l=a[c],u=(l||new Ur).modify(e,t+gn,r,n,o,i);if(l===u)return this;let f=oc(this,e),d;if(Mt(l)&&!Mt(u))++s,d=oo(f,c,u,a);else if(!Mt(l)&&Mt(u)){if(--s,s<=yy)return oI(e,s,c,a);d=oo(f,c,new Ur,a)}else d=oo(f,c,u,a);if(f)return this.size=s,this.children=d,this;return new Up(e,s,d)}}function oI(e,t,r,n){let o=Array(t-1),i=0,s=0;for(let a=0,c=n.length;a<c;++a)if(a!==r){let l=n[a];if(l&&!Mt(l))o[i++]=l,s|=1<<a}return new Qo(e,s,o)}function iI(e,t,r,n,o){let i=[],s=n,a=0;for(let c=0;s;++c){if(s&1)i[c]=o[a++];s>>>=1}return i[t]=r,new Up(e,a+1,i)}function sI(e,t,r,n,o,i){if(r===o)return new qp(e,r,[i,n]);let s=yn(t,r),a=yn(t,o);if(s===a)return(c)=>new Qo(e,xn(s)|xn(a),[c]);else{let c=s<a?[n,i]:[i,n];return new Qo(e,xn(s)|xn(a),c)}}function by(e,t,r,n,o,i){let s=void 0,a=t;while(!0){let c=sI(e,a,r,n,o,i);if(typeof c==="function")s=xy(c,s),a=a+gn;else{let l=c;while(s!=null)l=s.value(l),s=s.previous;return l}}}var _y="effect/HashMap",ic=Symbol.for(_y),cI={[ic]:ic,[Symbol.iterator](){return new ac(this,(e,t)=>[e,t])},[k](){let e=S(_y);for(let t of this)e^=m(S(t[0]),H(S(t[1])));return Z(this,e)},[O](e){if(Ty(e)){if(e._size!==this._size)return!1;for(let t of this){let r=m(e,cc(t[0],S(t[0])));if(ye(r))return!1;else if(!b(t[1],r.value))return!1}return!0}return!1},toString(){return oe(this.toJSON())},toJSON(){return{_id:"HashMap",values:Array.from(this).map(X)}},[J](){return this.toJSON()},pipe(){return y(this,arguments)}},Hp=(e,t,r,n)=>{let o=Object.create(cI);return o._editable=e,o._edit=t,o._root=r,o._size=n,o};class ac{map;f;v;constructor(e,t){this.map=e,this.f=t,this.v=wy(this.map._root,this.f,void 0)}next(){if(ye(this.v))return{done:!0,value:void 0};let e=this.v.value;return this.v=sc(e.cont),{done:!1,value:e.value}}[Symbol.iterator](){return new ac(this.map,this.f)}}var sc=(e)=>e?Ey(e[0],e[1],e[2],e[3],e[4]):w(),wy=(e,t,r=void 0)=>{switch(e._tag){case"LeafNode":{if(ue(e.value))return I({value:t(e.key,e.value.value),cont:r});return sc(r)}case"CollisionNode":case"ArrayNode":case"IndexedNode":{let n=e.children;return Ey(n.length,n,0,t,r)}default:return sc(r)}},Ey=(e,t,r,n,o)=>{while(r<e){let i=t[r++];if(i&&!Mt(i))return wy(i,n,[e,t,r,n,o])}return sc(o)},lI=Hp(!1,0,new Ur,0),Xo=()=>lI;var Oy=(e)=>{let t=uc(Xo());for(let r of e)so(t,r[0],r[1]);return Iy(t)},Ty=(e)=>_(e,ic),ky=(e)=>e&&Mt(e._root),Ay=p(2,(e,t)=>cc(e,t,S(t))),cc=p(3,(e,t,r)=>{let n=e._root,o=0;while(!0)switch(n._tag){case"LeafNode":return b(t,n.key)?n.value:w();case"CollisionNode":{if(r===n.hash){let i=n.children;for(let s=0,a=i.length;s<a;++s){let c=i[s];if("key"in c&&b(t,c.key))return c.value}}return w()}case"IndexedNode":{let i=yn(o,r),s=xn(i);if(n.mask&s){n=n.children[nc(n.mask,s)],o+=gn;break}return w()}case"ArrayNode":{if(n=n.children[yn(o,r)],n){o+=gn;break}return w()}default:return w()}});var jp=p(2,(e,t)=>ue(cc(e,t,S(t))));var so=p(3,(e,t,r)=>pc(e,t,()=>I(r))),uI=p(3,(e,t,r)=>{if(e._editable)return e._root=t,e._size=r,e;return t===e._root?e:Hp(e._editable,e._edit,t,r)}),lc=(e)=>new ac(e,(t)=>t);var ms=(e)=>e._size;var uc=(e)=>Hp(!0,e._edit+1,e._root,e._size),Iy=(e)=>(e._editable=!1,e);var pc=p(3,(e,t,r)=>Ry(e,t,S(t),r)),Ry=p(4,(e,t,r,n)=>{let o={value:e._size},i=e._root.modify(e._editable?e._edit:NaN,0,n,r,t,o);return m(e,uI(i,o.value))});var fc=p(2,(e,t)=>pc(e,t,w));var vy=p(2,(e,t)=>ei(e,Xo(),(r,n,o)=>so(r,o,t(n,o))));var $p=p(2,(e,t)=>ei(e,void 0,(r,n,o)=>t(n,o))),ei=p(3,(e,t,r)=>{let n=e._root;if(n._tag==="LeafNode")return ue(n.value)?r(t,n.value.value,n.key):t;if(n._tag==="EmptyNode")return t;let o=[n.children],i;while(i=o.pop())for(let s=0,a=i.length;s<a;){let c=i[s++];if(c&&!Mt(c))if(c._tag==="LeafNode"){if(ue(c.value))t=r(t,c.value.value,c.key)}else o.push(c.children)}return t});var Py="effect/HashSet",dc=Symbol.for(Py),pI={[dc]:dc,[Symbol.iterator](){return lc(this._keyMap)},[k](){return Z(this,H(S(this._keyMap))(S(Py)))},[O](e){if(Fy(e))return ms(this._keyMap)===ms(e._keyMap)&&b(this._keyMap,e._keyMap);return!1},toString(){return oe(this.toJSON())},toJSON(){return{_id:"HashSet",values:Array.from(this).map(X)}},[J](){return this.toJSON()},pipe(){return y(this,arguments)}},mc=(e)=>{let t=Object.create(pI);return t._keyMap=e,t},Fy=(e)=>_(e,dc),fI=mc(Xo()),hs=()=>fI,Ny=(e)=>{let t=hc(hs());for(let r of e)ti(t,r);return gc(t)},My=(...e)=>{let t=hc(hs());for(let r of e)ti(t,r);return gc(t)},Ly=p(2,(e,t)=>jp(e._keyMap,t));var Dy=(e)=>ms(e._keyMap),hc=(e)=>mc(uc(e._keyMap)),gc=(e)=>(e._keyMap._editable=!1,e),Bp=p(2,(e,t)=>{let r=hc(e);return t(r),gc(r)}),ti=p(2,(e,t)=>e._keyMap._editable?(so(t,!0)(e._keyMap),e):mc(so(t,!0)(e._keyMap))),Kp=p(2,(e,t)=>e._keyMap._editable?(fc(t)(e._keyMap),e):mc(fc(t)(e._keyMap))),qy=p(2,(e,t)=>Bp(e,(r)=>{for(let n of t)Kp(r,n)}));var Uy=p(2,(e,t)=>Bp(hs(),(r)=>{Hy(e,(n)=>ti(r,n));for(let n of t)ti(r,n)}));var Hy=p(2,(e,t)=>$p(e._keyMap,(r,n)=>t(n))),jy=p(3,(e,t,r)=>ei(e._keyMap,t,(n,o,i)=>r(n,i)));var pr=hs,$y=Ny,ao=My,By=Ly;var gs=Dy;var co=ti,Wp=Kp,zp=qy;var Hr=Uy;var lo=jy;var ni="Die",Sn="Empty",bn="Fail",uo="Interrupt",po="Parallel",fo="Sequential";var zy="effect/Cause",Gp=Symbol.for(zy),hI={_E:(e)=>e},oi={[Gp]:hI,[k](){return m(S(zy),H(S(yI(this))),Z(this))},[O](e){return Vy(e)&&gI(this,e)},pipe(){return y(this,arguments)},toJSON(){switch(this._tag){case"Empty":return{_id:"Cause",_tag:this._tag};case"Die":return{_id:"Cause",_tag:this._tag,defect:X(this.defect)};case"Interrupt":return{_id:"Cause",_tag:this._tag,fiberId:this.fiberId.toJSON()};case"Fail":return{_id:"Cause",_tag:this._tag,failure:X(this.error)};case"Sequential":case"Parallel":return{_id:"Cause",_tag:this._tag,left:X(this.left),right:X(this.right)}}},toString(){return er(this)},[J](){return this.toJSON()}},jr=(()=>{let e=Object.create(oi);return e._tag=Sn,e})(),ii=(e)=>{let t=Object.create(oi);return t._tag=bn,t.error=e,t},Ot=(e)=>{let t=Object.create(oi);return t._tag=ni,t.defect=e,t},Xt=(e)=>{let t=Object.create(oi);return t._tag=uo,t.fiberId=e,t},go=(e,t)=>{let r=Object.create(oi);return r._tag=po,r.left=e,r.right=t,r},Ge=(e,t)=>{let r=Object.create(oi);return r._tag=fo,r.left=e,r.right=t,r},Vy=(e)=>_(e,Gp),Yp=(e)=>e._tag===Sn,Jy=(e)=>e._tag===bn;var yc=(e)=>{if(e._tag===Sn)return!0;return mo(e,!0,(t,r)=>{switch(r._tag){case Sn:return I(t);case ni:case bn:case uo:return I(!1);default:return w()}})};var xc=(e)=>ue(Gy(e)),si=(e)=>_c(void 0,SI)(e),Zp=(e)=>hn(mo(e,Nt(),(t,r)=>r._tag===bn?I(m(t,Je(r.error))):w())),Qp=(e)=>hn(mo(e,Nt(),(t,r)=>r._tag===ni?I(m(t,Je(r.defect))):w())),Xp=(e)=>mo(e,pr(),(t,r)=>r._tag===uo?I(m(t,co(r.fiberId))):w()),ef=(e)=>tf(e,(t)=>t._tag===bn?I(t.error):w()),Sc=(e)=>{let t=ef(e);switch(t._tag){case"None":return B(e);case"Some":return U(t.value)}};var Gy=(e)=>tf(e,(t)=>t._tag===uo?I(t.fiberId):w());var bc=(e)=>rf(e,{onEmpty:jr,onFail:()=>jr,onDie:Ot,onInterrupt:Xt,onSequential:Ge,onParallel:go}),Yy=(e)=>rf(e,{onEmpty:jr,onFail:Ot,onDie:Ot,onInterrupt:Xt,onSequential:Ge,onParallel:go});var gI=(e,t)=>{let r=Re(e),n=Re(t);while(Yt(r)&&Yt(n)){let[o,i]=m(Zt(r),mo([pr(),Nt()],([c,l],u)=>{let[f,d]=Vp(u);return I([m(c,Hr(f)),m(l,Et(d))])})),[s,a]=m(Zt(n),mo([pr(),Nt()],([c,l],u)=>{let[f,d]=Vp(u);return I([m(c,Hr(f)),m(l,Et(d))])}));if(!b(o,s))return!1;r=i,n=a}return!0},yI=(e)=>xI(Re(e),Nt()),xI=(e,t)=>{while(!0){let[r,n]=m(e,Yo([pr(),Nt()],([i,s],a)=>{let[c,l]=Vp(a);return[m(i,Hr(c)),m(s,Et(l))]})),o=gs(r)>0?m(t,Je(r)):t;if(my(n))return hn(o);e=n,t=o}throw Error(Zn("Cause.flattenCauseLoop"))},tf=p(2,(e,t)=>{let r=[e];while(r.length>0){let n=r.pop(),o=t(n);switch(o._tag){case"None":{switch(n._tag){case fo:case po:{r.push(n.right),r.push(n.left);break}}break}case"Some":return o}}return w()});var Vp=(e)=>{let t=e,r=[],n=pr(),o=Nt();while(t!==void 0)switch(t._tag){case Sn:{if(r.length===0)return[n,o];t=r.pop();break}case bn:{if(n=co(n,fs(t._tag,t.error)),r.length===0)return[n,o];t=r.pop();break}case ni:{if(n=co(n,fs(t._tag,t.defect)),r.length===0)return[n,o];t=r.pop();break}case uo:{if(n=co(n,fs(t._tag,t.fiberId)),r.length===0)return[n,o];t=r.pop();break}case fo:{switch(t.left._tag){case Sn:{t=t.right;break}case fo:{t=Ge(t.left.left,Ge(t.left.right,t.right));break}case po:{t=go(Ge(t.left.left,t.right),Ge(t.left.right,t.right));break}default:{o=Je(o,t.right),t=t.left;break}}break}case po:{r.push(t.right),t=t.left;break}}throw Error(Zn("Cause.evaluateCauseLoop"))};var SI={emptyCase:Ji,failCase:an,dieCase:an,interruptCase:Ji,sequentialCase:(e,t,r)=>t&&r,parallelCase:(e,t,r)=>t&&r};var Ky="SequentialCase",Wy="ParallelCase",rf=p(2,(e,{onDie:t,onEmpty:r,onFail:n,onInterrupt:o,onParallel:i,onSequential:s})=>_c(e,void 0,{emptyCase:()=>r,failCase:(a,c)=>n(c),dieCase:(a,c)=>t(c),interruptCase:(a,c)=>o(c),sequentialCase:(a,c,l)=>s(c,l),parallelCase:(a,c,l)=>i(c,l)})),mo=p(3,(e,t,r)=>{let n=t,o=e,i=[];while(o!==void 0){let s=r(n,o);switch(n=ue(s)?s.value:n,o._tag){case fo:{i.push(o.right),o=o.left;break}case po:{i.push(o.right),o=o.left;break}default:{o=void 0;break}}if(o===void 0&&i.length>0)o=i.pop()}return n}),_c=p(3,(e,t,r)=>{let n=[e],o=[];while(n.length>0){let s=n.pop();switch(s._tag){case Sn:{o.push(B(r.emptyCase(t)));break}case bn:{o.push(B(r.failCase(t,s.error)));break}case ni:{o.push(B(r.dieCase(t,s.defect)));break}case uo:{o.push(B(r.interruptCase(t,s.fiberId)));break}case fo:{n.push(s.right),n.push(s.left),o.push(U({_tag:Ky}));break}case po:{n.push(s.right),n.push(s.left),o.push(U({_tag:Wy}));break}}}let i=[];while(o.length>0){let s=o.pop();switch(s._tag){case"Left":{switch(s.left._tag){case Ky:{let a=i.pop(),c=i.pop(),l=r.sequentialCase(t,a,c);i.push(l);break}case Wy:{let a=i.pop(),c=i.pop(),l=r.parallelCase(t,a,c);i.push(l);break}}break}case"Right":{i.push(s.right);break}}}if(i.length===0)throw Error("BUG: Cause.reduceWithContext - please report an issue at https://github.com/Effect-TS/effect/issues");return i.pop()}),er=(e,t)=>{if(si(e))return"All fibers interrupted without errors.";return ys(e).map(function(r){if(t?.renderErrorCause!==!0||r.cause===void 0)return r.stack;return`${r.stack} {
|
|
13
|
+
${Zy(r.cause," ")}
|
|
14
|
+
}`}).join(`
|
|
15
|
+
`)},Zy=(e,t)=>{let r=e.stack.split(`
|
|
16
|
+
`),n=`${t}[cause]: ${r[0]}`;for(let o=1,i=r.length;o<i;o++)n+=`
|
|
17
|
+
${t}${r[o]}`;if(e.cause)n+=` {
|
|
18
|
+
${Zy(e.cause,`${t} `)}
|
|
19
|
+
${t}}`;return n},Jp=(e)=>{let t=typeof e==="object"&&e!==null,r=Error.stackTraceLimit;Error.stackTraceLimit=1;let n=Error(bI(e),t&&"cause"in e&&typeof e.cause<"u"?{cause:Jp(e.cause)}:void 0);if(Error.stackTraceLimit=r,n.message==="")n.message="An error has occurred";if(Error.stackTraceLimit=r,n.name=e instanceof Error?e.name:"Error",t){if(ho in e)n.span=e[ho];Object.keys(e).forEach((o)=>{if(!(o in n))n[o]=e[o]})}return n.stack=EI(`${n.name}: ${n.message}`,e instanceof Error&&e.stack?e.stack:"",n.span),n},bI=(e)=>{if(typeof e==="string")return e;if(typeof e==="object"&&e!==null&&e instanceof Error)return e.message;try{if(_(e,"toString")&&ln(e.toString)&&e.toString!==Object.prototype.toString&&e.toString!==globalThis.Array.prototype.toString)return e.toString()}catch{}return Va(e)},_I=/\((.*)\)/g,wI=N("effect/Tracer/spanToTrace",()=>new WeakMap),EI=(e,t,r)=>{let n=[e],o=t.startsWith(e)?t.slice(e.length).split(`
|
|
20
|
+
`):t.split(`
|
|
21
|
+
`);for(let i=1;i<o.length;i++){if(o[i].includes(" at new BaseEffectError")||o[i].includes(" at new YieldableError")){i++;continue}if(o[i].includes("Generator.next"))break;if(o[i].includes("effect_internal_function"))break;n.push(o[i].replace(/at .*effect_instruction_i.*\((.*)\)/,"at $1").replace(/EffectPrimitive\.\w+/,"<anonymous>"))}if(r){let i=r,s=0;while(i&&i._tag==="Span"&&s<10){let a=wI.get(i);if(typeof a==="function"){let c=a();if(typeof c==="string"){let l=c.matchAll(_I),u=!1;for(let[,f]of l)u=!0,n.push(` at ${i.name} (${f})`);if(!u)n.push(` at ${i.name} (${c.replace(/^at /,"")})`)}else n.push(` at ${i.name}`)}else n.push(` at ${i.name}`);i=ft(i.parent),s++}}return n.join(`
|
|
22
|
+
`)},ho=Symbol.for("effect/SpanAnnotation"),ys=(e)=>_c(e,void 0,{emptyCase:()=>[],dieCase:(t,r)=>[Jp(r)],failCase:(t,r)=>[Jp(r)],interruptCase:()=>[],parallelCase:(t,r,n)=>[...r,...n],sequentialCase:(t,r,n)=>[...r,...n]});var Qy=Symbol.for("effect/Context/Tag"),Ss=Symbol.for("effect/Context/Reference"),OI="effect/STM",TI=Symbol.for(OI),Xy={...vr,_op:"Tag",[TI]:un,[Qy]:{_Service:(e)=>e,_Identifier:(e)=>e},toString(){return oe(this.toJSON())},toJSON(){return{_id:"Tag",key:this.key,stack:this.stack}},[J](){return this.toJSON()},of(e){return e},context(e){return sf(this,e)}},kI={...Xy,[Ss]:Ss},ex=(e)=>{let t=Error.stackTraceLimit;Error.stackTraceLimit=2;let r=Error();Error.stackTraceLimit=t;let n=Object.create(Xy);return Object.defineProperty(n,"stack",{get(){return r.stack}}),n.key=e,n};var tx=()=>(e,t)=>{let r=Error.stackTraceLimit;Error.stackTraceLimit=2;let n=Error();Error.stackTraceLimit=r;function o(){}return Object.setPrototypeOf(o,kI),o.key=e,o.defaultValue=t.defaultValue,Object.defineProperty(o,"stack",{get(){return n.stack}}),o},of=Symbol.for("effect/Context"),AI={[of]:{_Services:(e)=>e},[O](e){if(rx(e)){if(this.unsafeMap.size===e.unsafeMap.size){for(let t of this.unsafeMap.keys())if(!e.unsafeMap.has(t)||!b(this.unsafeMap.get(t),e.unsafeMap.get(t)))return!1;return!0}}return!1},[k](){return Z(this,Ka(this.unsafeMap.size))},pipe(){return y(this,arguments)},toString(){return oe(this.toJSON())},toJSON(){return{_id:"Context",services:Array.from(this.unsafeMap).map(X)}},[J](){return this.toJSON()}},_n=(e)=>{let t=Object.create(AI);return t.unsafeMap=e,t},II=(e)=>{let t=Error(`Service not found${e.key?`: ${String(e.key)}`:""}`);if(e.stack){let r=e.stack.split(`
|
|
23
|
+
`);if(r.length>2){let n=r[2].match(/at (.*)/);if(n)t.message=t.message+` (defined at ${n[1]})`}}if(t.stack){let r=t.stack.split(`
|
|
24
|
+
`);r.splice(1,3),t.stack=r.join(`
|
|
25
|
+
`)}return t},rx=(e)=>_(e,of);var nx=(e)=>_(e,Ss),RI=_n(new Map),ox=()=>RI,sf=(e,t)=>_n(new Map([[e.key,t]])),ix=p(3,(e,t,r)=>{let n=new Map(e.unsafeMap);return n.set(t.key,r),_n(n)}),nf=N("effect/Context/defaultValueCache",()=>new Map),af=(e)=>{if(nf.has(e.key))return nf.get(e.key);let t=e.defaultValue();return nf.set(e.key,t),t},sx=(e,t)=>e.unsafeMap.has(t.key)?e.unsafeMap.get(t.key):af(t),cf=p(2,(e,t)=>{if(!e.unsafeMap.has(t.key)){if(Ss in t)return af(t);throw II(t)}return e.unsafeMap.get(t.key)}),ax=cf;var cx=p(2,(e,t)=>{if(!e.unsafeMap.has(t.key))return nx(t)?ls(af(t)):Ya;return ls(e.unsafeMap.get(t.key))}),lx=p(2,(e,t)=>{let r=new Map(e.unsafeMap);for(let[n,o]of t.unsafeMap)r.set(n,o);return _n(r)});var dt=ex;var wn=ox,px=sf,fr=ix,bs=ax;var _s=cf,En=cx,ws=lx;var Es=tx;var uf=Symbol.for("effect/Duration"),gx=BigInt(0),fx=BigInt(24),wc=BigInt(60),pf=BigInt(1000),dx=BigInt(1e6),mx=BigInt(1e9),vI=/^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/,$r=(e)=>{if(yx(e))return e;else if(_t(e))return Ec(e);else if(cn(e))return lf(e);else if(Array.isArray(e)&&e.length===2&&e.every(_t)){if(e[0]===-1/0||e[1]===-1/0||Number.isNaN(e[0])||Number.isNaN(e[1]))return ff;if(e[0]===1/0||e[1]===1/0)return NI;return lf(BigInt(Math.round(e[0]*1e9))+BigInt(Math.round(e[1])))}else if(Be(e)){let t=vI.exec(e);if(t){let[r,n,o]=t,i=Number(n);switch(o){case"nano":case"nanos":return lf(BigInt(n));case"micro":case"micros":return MI(BigInt(n));case"milli":case"millis":return Ec(i);case"second":case"seconds":return LI(i);case"minute":case"minutes":return DI(i);case"hour":case"hours":return qI(i);case"day":case"days":return UI(i);case"week":case"weeks":return HI(i)}}}throw Error("Invalid DurationInput")};var hx={_tag:"Millis",millis:0},CI={_tag:"Infinity"},PI={[uf]:uf,[k](){return Z(this,Wa(this.value))},[O](e){return yx(e)&&WI(this,e)},toString(){return`Duration(${VI(this)})`},toJSON(){switch(this.value._tag){case"Millis":return{_id:"Duration",_tag:"Millis",millis:this.value.millis};case"Nanos":return{_id:"Duration",_tag:"Nanos",hrtime:$I(this)};case"Infinity":return{_id:"Duration",_tag:"Infinity"}}},[J](){return this.toJSON()},pipe(){return y(this,arguments)}},dr=(e)=>{let t=Object.create(PI);if(_t(e))if(isNaN(e)||e<=0)t.value=hx;else if(!Number.isFinite(e))t.value=CI;else if(!Number.isInteger(e))t.value={_tag:"Nanos",nanos:BigInt(Math.round(e*1e6))};else t.value={_tag:"Millis",millis:e};else if(e<=gx)t.value=hx;else t.value={_tag:"Nanos",nanos:e};return t},yx=(e)=>_(e,uf);var FI=(e)=>{switch(e.value._tag){case"Millis":return e.value.millis===0;case"Nanos":return e.value.nanos===gx;case"Infinity":return!1}},ff=dr(0),NI=dr(1/0),lf=(e)=>dr(e),MI=(e)=>dr(e*pf),Ec=(e)=>dr(e),LI=(e)=>dr(e*1000),DI=(e)=>dr(e*60000),qI=(e)=>dr(e*3600000),UI=(e)=>dr(e*86400000),HI=(e)=>dr(e*604800000),Oc=(e)=>BI(e,{onMillis:(t)=>t,onNanos:(t)=>Number(t)/1e6});var jI=(e)=>{let t=$r(e);switch(t.value._tag){case"Infinity":throw Error("Cannot convert infinite duration to nanos");case"Nanos":return t.value.nanos;case"Millis":return BigInt(Math.round(t.value.millis*1e6))}},$I=(e)=>{let t=$r(e);switch(t.value._tag){case"Infinity":return[1/0,0];case"Nanos":return[Number(t.value.nanos/mx),Number(t.value.nanos%mx)];case"Millis":return[Math.floor(t.value.millis/1000),Math.round(t.value.millis%1000*1e6)]}},BI=p(2,(e,t)=>{let r=$r(e);switch(r.value._tag){case"Nanos":return t.onNanos(r.value.nanos);case"Infinity":return t.onMillis(1/0);case"Millis":return t.onMillis(r.value.millis)}}),df=p(3,(e,t,r)=>{let n=$r(e),o=$r(t);if(n.value._tag==="Infinity"||o.value._tag==="Infinity")return r.onMillis(Oc(n),Oc(o));else if(n.value._tag==="Nanos"||o.value._tag==="Nanos"){let i=n.value._tag==="Nanos"?n.value.nanos:BigInt(Math.round(n.value.millis*1e6)),s=o.value._tag==="Nanos"?o.value.nanos:BigInt(Math.round(o.value.millis*1e6));return r.onNanos(i,s)}return r.onMillis(n.value.millis,o.value.millis)});var KI=(e,t)=>df(e,t,{onMillis:(r,n)=>r===n,onNanos:(r,n)=>r===n});var xx=p(2,(e,t)=>df(e,t,{onMillis:(r,n)=>r<=n,onNanos:(r,n)=>r<=n}));var Sx=p(2,(e,t)=>df(e,t,{onMillis:(r,n)=>r>=n,onNanos:(r,n)=>r>=n})),WI=p(2,(e,t)=>KI($r(e),$r(t))),zI=(e)=>{let t=$r(e);if(t.value._tag==="Infinity")return{days:1/0,hours:1/0,minutes:1/0,seconds:1/0,millis:1/0,nanos:1/0};let r=jI(t),n=r/dx,o=n/pf,i=o/wc,s=i/wc,a=s/fx;return{days:Number(a),hours:Number(s%fx),minutes:Number(i%wc),seconds:Number(o%wc),millis:Number(n%pf),nanos:Number(r%dx)}},VI=(e)=>{let t=$r(e);if(t.value._tag==="Infinity")return"Infinity";if(FI(t))return"0";let r=zI(t),n=[];if(r.days!==0)n.push(`${r.days}d`);if(r.hours!==0)n.push(`${r.hours}h`);if(r.minutes!==0)n.push(`${r.minutes}m`);if(r.seconds!==0)n.push(`${r.seconds}s`);if(r.millis!==0)n.push(`${r.millis}ms`);if(r.nanos!==0)n.push(`${r.nanos}ns`);return n.join(" ")};var _x=Symbol.for("effect/MutableRef"),JI={[_x]:_x,toString(){return oe(this.toJSON())},toJSON(){return{_id:"MutableRef",current:X(this.current)}},[J](){return this.toJSON()},pipe(){return y(this,arguments)}},Tc=(e)=>{let t=Object.create(JI);return t.current=e,t};var ai=(e)=>e.current;var kc=p(2,(e,t)=>(e.current=t,e));var hf="effect/FiberId",ci=Symbol.for(hf),Ac="None",mf="Runtime",GI="Composite",YI=ne(`${hf}-${Ac}`);class Ox{[ci]=ci;_tag=Ac;id=-1;startTimeMillis=-1;[k](){return YI}[O](e){return gf(e)&&e._tag===Ac}toString(){return oe(this.toJSON())}toJSON(){return{_id:"FiberId",_tag:this._tag}}[J](){return this.toJSON()}}class Tx{id;startTimeMillis;[ci]=ci;_tag=mf;constructor(e,t){this.id=e,this.startTimeMillis=t}[k](){return Z(this,ne(`${hf}-${this._tag}-${this.id}-${this.startTimeMillis}`))}[O](e){return gf(e)&&e._tag===mf&&this.id===e.id&&this.startTimeMillis===e.startTimeMillis}toString(){return oe(this.toJSON())}toJSON(){return{_id:"FiberId",_tag:this._tag,id:this.id,startTimeMillis:this.startTimeMillis}}[J](){return this.toJSON()}}var kx=new Ox;var gf=(e)=>_(e,ci);var Ic=(e)=>{switch(e._tag){case Ac:return pr();case mf:return ao(e.id);case GI:return m(Ic(e.left),Hr(Ic(e.right)))}},Ex=N(Symbol.for("effect/Fiber/Id/_fiberCounter"),()=>Tc(0));var Rc=(e)=>Array.from(Ic(e)).map((r)=>`#${r}`).join(",");var Ax=()=>{let e=ai(Ex);return m(Ex,kc(e+1)),new Tx(e,Date.now())};var Lt=kx;var Rx=Rc;var vc=Ax;var li=Xo;var vx=Oy,Cx=ky,yf=Ay;var xf=so,Sf=lc;var Px=pc;var Fx=vy;var bf=ei;var Ts=Symbol.for("effect/List"),wf=(e)=>pe(e),ZI=(e)=>tp(mn(e),wf),QI=ZI(b),XI={[Ts]:Ts,_tag:"Cons",toString(){return oe(this.toJSON())},toJSON(){return{_id:"List",_tag:"Cons",values:wf(this).map(X)}},[J](){return this.toJSON()},[O](e){return Mx(e)&&this._tag===e._tag&&QI(this,e)},[k](){return Z(this,wt(wf(this)))},[Symbol.iterator](){let e=!1,t=this;return{next(){if(e)return this.return();if(t._tag==="Nil")return e=!0,this.return();let r=t.head;return t=t.tail,{done:e,value:r}},return(r){if(!e)e=!0;return{done:!0,value:r}}}},pipe(){return y(this,arguments)}},Cc=(e,t)=>{let r=Object.create(XI);return r.head=e,r.tail=t,r},eR=ne("Nil"),tR={[Ts]:Ts,_tag:"Nil",toString(){return oe(this.toJSON())},toJSON(){return{_id:"List",_tag:"Nil"}},[J](){return this.toJSON()},[k](){return eR},[O](e){return Mx(e)&&this._tag===e._tag},[Symbol.iterator](){return{next(){return{done:!0,value:void 0}}}},pipe(){return y(this,arguments)}},Nx=Object.create(tR),Mx=(e)=>_(e,Ts),mr=(e)=>e._tag==="Nil",Ef=(e)=>e._tag==="Cons";var rR=()=>Nx,Br=(e,t)=>Cc(e,t),On=rR,ks=(e)=>Cc(e,Nx);var Lx=p(2,(e,t)=>oR(t,e)),nR=p(2,(e,t)=>Br(t,e)),oR=p(2,(e,t)=>{if(mr(e))return t;else if(mr(t))return e;else{let r=Cc(t.head,e),n=r,o=t.tail;while(!mr(o)){let i=Cc(o.head,e);n.tail=i,n=i,o=o.tail}return r}});var Dx=p(3,(e,t,r)=>{let n=t,o=e;while(!mr(o))n=r(n,o.head),o=o.tail;return n});var qx=(e)=>{let t=On(),r=e;while(!mr(r))t=nR(t,r.head),r=r.tail;return t};var Nq=Object.assign(Object.create(Array.prototype),{[k](){return Z(this,wt(this))},[O](e){if(Array.isArray(e)&&this.length===e.length)return this.every((t,r)=>b(t,e[r]));else return!1}}),ui=function(){function e(t){if(t)Object.assign(this,t)}return e.prototype=cs,e}();var sR=Symbol.for("effect/DifferContextPatch");function Ux(e){return e}var Is={...ui.prototype,[sR]:{_Value:Ux,_Patch:Ux}},aR=Object.assign(Object.create(Is),{_tag:"Empty"}),cR=Object.create(aR),Tf=()=>cR,lR=Object.assign(Object.create(Is),{_tag:"AndThen"}),uR=(e,t)=>{let r=Object.create(lR);return r.first=e,r.second=t,r},pR=Object.assign(Object.create(Is),{_tag:"AddService"}),fR=(e,t)=>{let r=Object.create(pR);return r.key=e,r.service=t,r},dR=Object.assign(Object.create(Is),{_tag:"RemoveService"}),mR=(e)=>{let t=Object.create(dR);return t.key=e,t},hR=Object.assign(Object.create(Is),{_tag:"UpdateService"}),gR=(e,t)=>{let r=Object.create(hR);return r.key=e,r.update=t,r},Hx=(e,t)=>{let r=new Map(e.unsafeMap),n=Tf();for(let[o,i]of t.unsafeMap.entries())if(r.has(o)){let s=r.get(o);if(r.delete(o),!b(s,i))n=As(gR(o,()=>i))(n)}else r.delete(o),n=As(fR(o,i))(n);for(let[o]of r.entries())n=As(mR(o))(n);return n},As=p(2,(e,t)=>uR(e,t)),jx=p(2,(e,t)=>{if(e._tag==="Empty")return t;let r=!1,n=Re(e),o=new Map(t.unsafeMap);while(Yt(n)){let s=Zt(n),a=Qt(n);switch(s._tag){case"Empty":{n=a;break}case"AddService":{o.set(s.key,s.service),n=a;break}case"AndThen":{n=Je(Je(a,s.second),s.first);break}case"RemoveService":{o.delete(s.key),n=a;break}case"UpdateService":{o.set(s.key,s.update(o.get(s.key))),r=!0,n=a;break}}}if(!r)return _n(o);let i=new Map;for(let[s]of t.unsafeMap)if(o.has(s))i.set(s,o.get(s)),o.delete(s);for(let[s,a]of o)i.set(s,a);return _n(i)});var xR=Symbol.for("effect/DifferHashSetPatch");function kf(e){return e}var Fc={...ui.prototype,[xR]:{_Value:kf,_Key:kf,_Patch:kf}},SR=Object.assign(Object.create(Fc),{_tag:"Empty"}),bR=Object.create(SR),Af=()=>bR,_R=Object.assign(Object.create(Fc),{_tag:"AndThen"}),wR=(e,t)=>{let r=Object.create(_R);return r.first=e,r.second=t,r},ER=Object.assign(Object.create(Fc),{_tag:"Add"}),OR=(e)=>{let t=Object.create(ER);return t.value=e,t},TR=Object.assign(Object.create(Fc),{_tag:"Remove"}),kR=(e)=>{let t=Object.create(TR);return t.value=e,t},$x=(e,t)=>{let[r,n]=lo([e,Af()],([o,i],s)=>{if(By(s)(o))return[Wp(s)(o),i];return[o,Pc(OR(s))(i)]})(t);return lo(n,(o,i)=>Pc(kR(i))(o))(r)},Pc=p(2,(e,t)=>wR(e,t)),Bx=p(2,(e,t)=>{if(e._tag==="Empty")return t;let r=t,n=Re(e);while(Yt(n)){let o=Zt(n),i=Qt(n);switch(o._tag){case"Empty":{n=i;break}case"AndThen":{n=Je(o.first)(Je(o.second)(i));break}case"Add":{r=co(o.value)(r),n=i;break}case"Remove":r=Wp(o.value)(r),n=i}}return r});var IR=Symbol.for("effect/DifferReadonlyArrayPatch");function Kx(e){return e}var vs={...ui.prototype,[IR]:{_Value:Kx,_Patch:Kx}},RR=Object.assign(Object.create(vs),{_tag:"Empty"}),vR=Object.create(RR),If=()=>vR,CR=Object.assign(Object.create(vs),{_tag:"AndThen"}),PR=(e,t)=>{let r=Object.create(CR);return r.first=e,r.second=t,r},FR=Object.assign(Object.create(vs),{_tag:"Append"}),NR=(e)=>{let t=Object.create(FR);return t.values=e,t},MR=Object.assign(Object.create(vs),{_tag:"Slice"}),LR=(e,t)=>{let r=Object.create(MR);return r.from=e,r.until=t,r},DR=Object.assign(Object.create(vs),{_tag:"Update"}),qR=(e,t)=>{let r=Object.create(DR);return r.index=e,r.patch=t,r},Wx=(e)=>{let t=0,r=If();while(t<e.oldValue.length&&t<e.newValue.length){let n=e.oldValue[t],o=e.newValue[t],i=e.differ.diff(n,o);if(!b(i,e.differ.empty))r=Rs(r,qR(t,i));t=t+1}if(t<e.oldValue.length)r=Rs(r,LR(0,t));if(t<e.newValue.length)r=Rs(r,NR(sy(t)(e.newValue)));return r},Rs=p(2,(e,t)=>PR(e,t)),zx=p(3,(e,t,r)=>{if(e._tag==="Empty")return t;let n=t.slice(),o=Ve(e);while(fn(o)){let i=Ie(o),s=Jt(o);switch(i._tag){case"Empty":{o=s;break}case"AndThen":{s.unshift(i.first,i.second),o=s;break}case"Append":{for(let a of i.values)n.push(a);o=s;break}case"Slice":{n=n.slice(i.from,i.until),o=s;break}case"Update":{n[i.index]=r.patch(i.patch,n[i.index]),o=s;break}}}return n});var Vx=Symbol.for("effect/Differ"),HR={[Vx]:{_P:Q,_V:Q},pipe(){return y(this,arguments)}},Tn=(e)=>{let t=Object.create(HR);return t.empty=e.empty,t.diff=e.diff,t.combine=e.combine,t.patch=e.patch,t},Rf=()=>Tn({empty:Tf(),combine:(e,t)=>As(t)(e),diff:(e,t)=>Hx(e,t),patch:(e,t)=>jx(t)(e)});var vf=()=>Tn({empty:Af(),combine:(e,t)=>Pc(t)(e),diff:(e,t)=>$x(e,t),patch:(e,t)=>Bx(t)(e)});var Cf=(e)=>Tn({empty:If(),combine:(t,r)=>Rs(t,r),diff:(t,r)=>Wx({oldValue:t,newValue:r,differ:e}),patch:(t,r)=>zx(t,r,e)});var Nc=()=>Jx((e,t)=>t),Jx=(e)=>Tn({empty:Q,combine:(t,r)=>{if(t===Q)return r;if(r===Q)return t;return(n)=>r(t(n))},diff:(t,r)=>{if(b(t,r))return Q;return Vi(r)},patch:(t,r)=>e(r,t(r))});var Cs=255,Gx=8,Mc=(e)=>e&Cs,Lc=(e)=>e>>Gx&Cs,yo=(e,t)=>(e&Cs)+((t&e&Cs)<<Gx),Ff=yo(0,0),Yx=(e)=>yo(e,e),Zx=(e)=>yo(e,0);var Qx=p(2,(e,t)=>yo(Mc(e)&~t,Lc(e)));var Nf=p(2,(e,t)=>e|t);var Xx=(e)=>~e>>>0&Cs;var jR=0,Kr=1,tS=2,Mf=4,Dc=16,Lf=32;var rS=(e)=>qc(e,Lf);var Df=p(2,(e,t)=>e|t);var Wr=(e)=>qf(e)&&!$R(e),qf=(e)=>qc(e,Kr);var qc=p(2,(e,t)=>(e&t)!==0),Uf=(...e)=>e.reduce((t,r)=>t|r,0),nS=Uf(jR);var Hf=(e)=>qc(e,Mf);var $R=(e)=>qc(e,Dc);var Ps=p(2,(e,t)=>yo(e^t,t)),Fs=p(2,(e,t)=>e&(Xx(Mc(t))|Lc(t))|Mc(t)&Lc(t));var jf=Tn({empty:Ff,diff:(e,t)=>Ps(e,t),combine:(e,t)=>Nf(t)(e),patch:(e,t)=>Fs(t,e)});var oS=Yx,Bf=Zx;var Kf=Qx;var zf=(e,t)=>({_tag:"Par",left:e,right:t}),Uc=(e,t)=>({_tag:"Seq",left:e,right:t});var sS=(e)=>{let t=ks(e),r=On();while(!0){let[n,o]=Dx(t,[aS(),On()],([i,s],a)=>{let[c,l]=BR(a);return[JR(i,c),Lx(s,l)]});if(r=KR(r,n),mr(o))return qx(r);t=o}throw Error("BUG: BlockedRequests.flatten - please report an issue at https://github.com/Effect-TS/effect/issues")},BR=(e)=>{let t=e,r=aS(),n=On(),o=On();while(!0)switch(t._tag){case"Empty":{if(mr(n))return[r,o];t=n.head,n=n.tail;break}case"Par":{n=Br(t.right,n),t=t.left;break}case"Seq":{let i=t.left,s=t.right;switch(i._tag){case"Empty":{t=s;break}case"Par":{let{left:a,right:c}=i;t=zf(Uc(a,s),Uc(c,s));break}case"Seq":{let{left:a,right:c}=i;t=Uc(a,Uc(c,s));break}case"Single":{t=i,o=Br(s,o);break}}break}case"Single":{if(r=VR(r,t),mr(n))return[r,o];t=n.head,n=n.tail;break}}throw Error("BUG: BlockedRequests.step - please report an issue at https://github.com/Effect-TS/effect/issues")},KR=(e,t)=>{if(mr(e))return ks(Wf(t));if(GR(t))return e;let r=tv(e.head),n=YR(t);if(r.length===1&&n.length===1&&b(r[0],n[0]))return Br(ev(e.head,Wf(t)),e.tail);return Br(Wf(t),e)};var WR=Symbol.for("effect/RequestBlock/RequestBlockParallel"),zR={_R:(e)=>e};class Hc{map;[WR]=zR;constructor(e){this.map=e}}var aS=()=>new Hc(li());var VR=(e,t)=>new Hc(Px(e.map,t.dataSource,(r)=>Jg(zt(r,dy(t.blockedRequest)),()=>Re(t.blockedRequest)))),JR=(e,t)=>new Hc(bf(e.map,t.map,(r,n,o)=>xf(r,o,Ee(yf(r,o),{onNone:()=>n,onSome:(i)=>Et(n,i)})))),GR=(e)=>Cx(e.map),YR=(e)=>Array.from(Sf(e.map)),Wf=(e)=>XR(Fx(e.map,(t)=>Re(t))),ZR=Symbol.for("effect/RequestBlock/RequestBlockSequential"),QR={_R:(e)=>e};class Vf{map;[ZR]=QR;constructor(e){this.map=e}}var XR=(e)=>new Vf(e),ev=(e,t)=>new Vf(bf(t.map,e.map,(r,n,o)=>xf(r,o,Ee(yf(r,o),{onNone:()=>Nt(),onSome:(i)=>Et(i,n)}))));var tv=(e)=>Array.from(Sf(e.map)),cS=(e)=>Array.from(e.map);var pi="Pending",jc="Done";var nv="effect/Deferred",uS=Symbol.for(nv),pS={_E:(e)=>e,_A:(e)=>e},fS=(e)=>({_tag:pi,joiners:e}),dS=(e)=>({_tag:jc,effect:e});class fi{self;called=!1;constructor(e){this.self=e}next(e){return this.called?{value:e,done:!0}:(this.called=!0,{value:this.self,done:!1})}return(e){return{value:e,done:!0}}throw(e){throw e}[Symbol.iterator](){return new fi(this.self)}}var Kc=(e,t)=>{let r=new De("Blocked");return r.effect_instruction_i0=e,r.effect_instruction_i1=t,r},Yf=(e)=>{let t=new De("RunBlocked");return t.effect_instruction_i0=e,t},kn=Symbol.for("effect/Effect");class Zf{patch;op;_op=ss;constructor(e,t){this.patch=e,this.op=t}}class De{_op;effect_instruction_i0=void 0;effect_instruction_i1=void 0;effect_instruction_i2=void 0;trace=void 0;[kn]=un;constructor(e){this._op=e}[O](e){return this===e}[k](){return Z(this,ts(this))}pipe(){return y(this,arguments)}toJSON(){return{_id:"Effect",_op:this._op,effect_instruction_i0:X(this.effect_instruction_i0),effect_instruction_i1:X(this.effect_instruction_i1),effect_instruction_i2:X(this.effect_instruction_i2)}}toString(){return oe(this.toJSON())}[J](){return this.toJSON()}[Symbol.iterator](){return new fi(new Ir(this))}}class Qf{_op;effect_instruction_i0=void 0;effect_instruction_i1=void 0;effect_instruction_i2=void 0;trace=void 0;[kn]=un;constructor(e){this._op=e,this._tag=e}[O](e){return xi(e)&&e._op==="Failure"&&b(this.effect_instruction_i0,e.effect_instruction_i0)}[k](){return m(ne(this._tag),H(S(this.effect_instruction_i0)),Z(this))}get cause(){return this.effect_instruction_i0}pipe(){return y(this,arguments)}toJSON(){return{_id:"Exit",_tag:this._op,cause:this.cause.toJSON()}}toString(){return oe(this.toJSON())}[J](){return this.toJSON()}[Symbol.iterator](){return new fi(new Ir(this))}}class Xf{_op;effect_instruction_i0=void 0;effect_instruction_i1=void 0;effect_instruction_i2=void 0;trace=void 0;[kn]=un;constructor(e){this._op=e,this._tag=e}[O](e){return xi(e)&&e._op==="Success"&&b(this.effect_instruction_i0,e.effect_instruction_i0)}[k](){return m(ne(this._tag),H(S(this.effect_instruction_i0)),Z(this))}get value(){return this.effect_instruction_i0}pipe(){return y(this,arguments)}toJSON(){return{_id:"Exit",_tag:this._op,value:X(this.value)}}toString(){return oe(this.toJSON())}[J](){return this.toJSON()}[Symbol.iterator](){return new fi(new Ir(this))}}var di=(e)=>_(e,kn),We=(e)=>{let t=new De(Ga);return t.effect_instruction_i0=e,t},wS=p(3,(e,t,r)=>Rn((n)=>L(e,(o)=>L(In(fe(()=>n(t(o)))),(i)=>fe(()=>r(o,i)).pipe(Dt({onFailure:(s)=>{switch(i._tag){case lt:return Ye(Ge(i.effect_instruction_i0,s));case ut:return Ye(s)}},onSuccess:()=>i})))))),zr=p(2,(e,t)=>L(e,()=>ee(t))),Vr=(e)=>zr(e,void 0),ed=function(){let e=new De(to);switch(arguments.length){case 2:{e.effect_instruction_i0=arguments[0],e.commit=arguments[1];break}case 3:{e.effect_instruction_i0=arguments[0],e.effect_instruction_i1=arguments[1],e.commit=arguments[2];break}case 4:{e.effect_instruction_i0=arguments[0],e.effect_instruction_i1=arguments[1],e.effect_instruction_i2=arguments[2],e.commit=arguments[3];break}default:throw Error(Zn("you're not supposed to end up here"))}return e},Ns=(e,t=Lt)=>{let r=new De(eo),n=void 0;return r.effect_instruction_i0=(o)=>{n=e(o)},r.effect_instruction_i1=t,qs(r,(o)=>di(n)?n:ve)},ES=(e,t=Lt)=>fe(()=>Ns(e,t)),An=(e,t=Lt)=>ed(e,function(){let r=void 0,n=void 0;function o(c){if(r)r(c);else if(n===void 0)n=c}let i=new De(eo);i.effect_instruction_i0=(c)=>{if(r=c,n)c(n)},i.effect_instruction_i1=t;let s=void 0,a=void 0;if(this.effect_instruction_i0.length!==1)a=new AbortController,s=Ke(()=>this.effect_instruction_i0(o,a.signal));else s=Ke(()=>this.effect_instruction_i0(o));return s||a?qs(i,(c)=>{if(a)a.abort();return s??ve}):i});var Ms=p(2,(e,t)=>mi(e,{onFailure:t,onSuccess:ee}));var mS=Symbol.for("effect/OriginalAnnotation");var Wc=(e,t)=>{if(ue(t))return new Proxy(e,{has(r,n){return n===ho||n===mS||n in r},get(r,n){if(n===ho)return t.value;if(n===mS)return e;return r[n]}});return e},zc=(e)=>ot(e)&&!(ho in e)?We((t)=>Ye(Ot(Wc(e,cl(t))))):Ye(Ot(e)),td=(e)=>OS(()=>Ot(new fv(e)));var xo=(e)=>mi(e,{onFailure:(t)=>ee(U(t)),onSuccess:(t)=>ee(B(t))}),In=(e)=>TS(e,{onFailure:ae,onSuccess:ge}),qe=(e)=>ot(e)&&!(ho in e)?We((t)=>Ye(ii(Wc(e,cl(t))))):Ye(ii(e)),rd=(e)=>L(C(e),qe),Ye=(e)=>{let t=new Qf(lt);return t.effect_instruction_i0=e,t},OS=(e)=>L(C(e),Ye),nd=We((e)=>ee(e.id())),Ls=(e)=>We((t)=>e(t.id())),L=p(2,(e,t)=>{let r=new De(Bo);return r.effect_instruction_i0=e,r.effect_instruction_i1=t,r});var od=(e)=>{let t=new De("OnStep");return t.effect_instruction_i0=e,t},Ds=(e)=>L(e,Q);var TS=p(2,(e,t)=>Dt(e,{onFailure:(r)=>ee(t.onFailure(r)),onSuccess:(r)=>ee(t.onSuccess(r))})),Dt=p(2,(e,t)=>{let r=new De(Ko);return r.effect_instruction_i0=e,r.effect_instruction_i1=t.onFailure,r.effect_instruction_i2=t.onSuccess,r}),mi=p(2,(e,t)=>Dt(e,{onFailure:(r)=>{if(Qp(r).length>0)return Ye(Yy(r));let o=Zp(r);if(o.length>0)return t.onFailure(Mp(o));return Ye(r)},onSuccess:t.onSuccess})),qt=p(2,(e,t)=>fe(()=>{let r=pe(e),n=no(r.length),o=0;return zr(Us({while:()=>o<r.length,body:()=>t(r[o],o),step:(i)=>{n[o++]=i}}),n)})),So=p(2,(e,t)=>fe(()=>{let r=pe(e),n=0;return Us({while:()=>n<r.length,body:()=>t(r[n],n),step:()=>{n++}})}));var Vc=(e)=>{let t=new De(ro);return t.effect_instruction_i0=oS(Kr),t.effect_instruction_i1=()=>e,t};var we=p(2,(e,t)=>L(e,(r)=>C(()=>t(r)))),Jc=p(2,(e,t)=>mi(e,{onFailure:(r)=>rd(()=>t.onFailure(r)),onSuccess:(r)=>C(()=>t.onSuccess(r))})),bo=p(2,(e,t)=>Dt(e,{onFailure:(r)=>{let n=Sc(r);switch(n._tag){case"Left":return rd(()=>t(n.left));case"Right":return Ye(n.right)}},onSuccess:ee}));var hi=p(2,(e,t)=>Rn((r)=>Dt(r(e),{onFailure:(n)=>{let o=ae(n);return Dt(t(o),{onFailure:(i)=>ae(Ge(n,i)),onSuccess:()=>o})},onSuccess:(n)=>{let o=ge(n);return vn(t(o),o)}}))),qs=p(2,(e,t)=>hi(e,il({onFailure:(r)=>si(r)?Vr(t(Xp(r))):ve,onSuccess:()=>ve})));var ee=(e)=>{let t=new Xf(ut);return t.effect_instruction_i0=e,t},fe=(e)=>{let t=new De(to);return t.commit=e,t},C=(e)=>{let t=new De(Ja);return t.effect_instruction_i0=e,t},Gc=p((e)=>e.length===3||e.length===2&&!(ot(e[1])&&("onlyEffect"in e[1])),(e,t)=>L(e,(r)=>{let n=typeof t==="function"?t(r):t;if(di(n))return zr(n,r);else if(Eg(n))return Ns((o)=>{n.then((i)=>o(ee(r)),(i)=>o(qe(new mv(i,"An unknown error occurred in Effect.tap"))))});return ee(r)})),id=(e)=>We((t)=>{let r=t.getFiberRef(Bc),n=m(r,ce(()=>t.scope()));return e(Cn(Bc,I(n)))});var Yc=(e)=>{let t=new De(ro);return t.effect_instruction_i0=Bf(Kr),t.effect_instruction_i1=()=>e,t},Rn=(e)=>ed(e,function(){let t=new De(ro);return t.effect_instruction_i0=Bf(Kr),t.effect_instruction_i1=(r)=>qf(r)?Ke(()=>this.effect_instruction_i0(Vc)):Ke(()=>this.effect_instruction_i0(Yc)),t}),ve=ee(void 0);var sd=(e)=>{let t=new De(ro);return t.effect_instruction_i0=e,t.effect_instruction_i1=void 0,t};var Us=(e)=>{let t=new De(Wo);return t.effect_instruction_i0=e.while,t.effect_instruction_i1=e.body,t.effect_instruction_i2=e.step,t};var Hs=(e)=>{let t=new De(Vo);return typeof e?.priority<"u"?LS(t,e.priority):t},Zc=p(2,(e,t)=>L(e,(r)=>we(t,(n)=>[r,n])));var Qc=p(2,(e,t)=>L(e,(r)=>zr(t,r))),vn=p(2,(e,t)=>L(e,()=>t));var js=ES(()=>{let e=setInterval(()=>{},2147483647);return C(()=>clearInterval(e))}),kS=(e)=>L(nd,(t)=>m(e,$s(t))),$s=p(2,(e,t)=>L(e.interruptAsFork(t),()=>e.await)),AS={_tag:"All",syslog:0,label:"ALL",ordinal:Number.MIN_SAFE_INTEGER,pipe(){return y(this,arguments)}},IS={_tag:"Fatal",syslog:2,label:"FATAL",ordinal:50000,pipe(){return y(this,arguments)}},RS={_tag:"Error",syslog:3,label:"ERROR",ordinal:40000,pipe(){return y(this,arguments)}},ad={_tag:"Warning",syslog:4,label:"WARN",ordinal:30000,pipe(){return y(this,arguments)}},cd={_tag:"Info",syslog:6,label:"INFO",ordinal:20000,pipe(){return y(this,arguments)}},ld={_tag:"Debug",syslog:7,label:"DEBUG",ordinal:1e4,pipe(){return y(this,arguments)}},vS={_tag:"Trace",syslog:7,label:"TRACE",ordinal:0,pipe(){return y(this,arguments)}},CS={_tag:"None",syslog:7,label:"OFF",ordinal:Number.MAX_SAFE_INTEGER,pipe(){return y(this,arguments)}};var av="effect/FiberRef",cv=Symbol.for(av),lv={_A:(e)=>e},Xc=(e)=>We((t)=>ge(t.getFiberRef(e)));var _o=p(2,(e,t)=>L(Xc(e),t)),Jf=p(2,(e,t)=>uv(e,()=>[void 0,t]));var uv=p(2,(e,t)=>We((r)=>{let[n,o]=t(r.getFiberRef(e));return r.setFiberRef(e,o),ee(n)}));var Cn=p(3,(e,t,r)=>wS(Qc(Xc(t),Jf(t,r)),()=>e,(n)=>Jf(t,n)));var ze=(e,t)=>wo(e,{differ:Nc(),fork:t?.fork??Q,join:t?.join}),PS=(e)=>{let t=vf();return wo(e,{differ:t,fork:t.empty})},pv=(e)=>{let t=Cf(Nc());return wo(e,{differ:t,fork:t.empty})},el=(e)=>{let t=Rf();return wo(e,{differ:t,fork:t.empty})},wo=(e,t)=>({...pn,[cv]:lv,initial:e,commit(){return Xc(this)},diff:(n,o)=>t.differ.diff(n,o),combine:(n,o)=>t.differ.combine(n,o),patch:(n)=>(o)=>t.differ.patch(n,o),fork:t.fork,join:t.join??((n,o)=>o)}),FS=(e)=>wo(e,{differ:jf,fork:jf.empty}),Eo=N(Symbol.for("effect/FiberRef/currentContext"),()=>el(wn())),gi=N(Symbol.for("effect/FiberRef/currentSchedulingPriority"),()=>ze(0)),ud=N(Symbol.for("effect/FiberRef/currentMaxOpsBeforeYield"),()=>ze(2048)),NS=N(Symbol.for("effect/FiberRef/currentLogAnnotation"),()=>ze(li())),pd=N(Symbol.for("effect/FiberRef/currentLogLevel"),()=>ze(cd)),MS=N(Symbol.for("effect/FiberRef/currentLogSpan"),()=>ze(On())),LS=p(2,(e,t)=>Cn(e,gi,t));var DS=N(Symbol.for("effect/FiberRef/currentConcurrency"),()=>ze("unbounded")),qS=N(Symbol.for("effect/FiberRef/currentRequestBatching"),()=>ze(!0)),US=N(Symbol.for("effect/FiberRef/currentUnhandledErrorLogLevel"),()=>ze(I(ld))),HS=N(Symbol.for("effect/FiberRef/versionMismatchErrorLogLevel"),()=>ze(I(ad)));var Bs=N(Symbol.for("effect/FiberRef/currentMetricLabels"),()=>pv(Mr()));var Bc=N(Symbol.for("effect/FiberRef/currentForkScopeOverride"),()=>ze(w(),{fork:()=>w(),join:(e,t)=>e})),Ks=N(Symbol.for("effect/FiberRef/currentInterruptedCause"),()=>ze(jr,{fork:()=>jr,join:(e,t)=>e}));var tl=Symbol.for("effect/Scope"),rl=Symbol.for("effect/CloseableScope"),nl=(e,t)=>e.addFinalizer(()=>Vr(t));var fd=(e,t)=>e.close(t),yi=(e,t)=>e.fork(t);var ol=function(){class e extends globalThis.Error{commit(){return qe(this)}toJSON(){let t={...this};if(this.message)t.message=this.message;if(this.cause)t.cause=this.cause;return t}[J](){if(this.toString!==globalThis.Error.prototype.toString)return this.stack?`${this.toString()}
|
|
26
|
+
${this.stack.split(`
|
|
27
|
+
`).slice(1).join(`
|
|
28
|
+
`)}`:this.toString();else if("Bun"in globalThis)return er(ii(this),{renderErrorCause:!0});return this}}return Object.assign(e.prototype,pp),e}(),Oo=(e,t)=>{class r extends ol{_tag=t}return Object.assign(r.prototype,e),r.prototype.name=t,r},hS=Symbol.for("effect/Cause/errors/RuntimeException"),fv=Oo({[hS]:hS},"RuntimeException");var Gf=Symbol.for("effect/Cause/errors/InterruptedException"),p2=Oo({[Gf]:Gf},"InterruptedException"),jS=(e)=>_(e,Gf),gS=Symbol.for("effect/Cause/errors/IllegalArgument"),dv=Oo({[gS]:gS},"IllegalArgumentException");var yS=Symbol.for("effect/Cause/errors/NoSuchElement"),Ws=Oo({[yS]:yS},"NoSuchElementException");var xS=Symbol.for("effect/Cause/errors/InvalidPubSubCapacityException"),f2=Oo({[xS]:xS},"InvalidPubSubCapacityException"),SS=Symbol.for("effect/Cause/errors/ExceededCapacityException"),d2=Oo({[SS]:SS},"ExceededCapacityException");var bS=Symbol.for("effect/Cause/errors/Timeout"),m2=Oo({[bS]:bS},"TimeoutException");var _S=Symbol.for("effect/Cause/errors/UnknownException"),mv=function(){class e extends ol{_tag="UnknownException";error;constructor(t,r){super(r??"An unknown error occurred",{cause:t});this.error=t}}return Object.assign(e.prototype,{[_S]:_S,name:"UnknownException"}),e}();var xi=(e)=>di(e)&&("_tag"in e)&&(e._tag==="Success"||e._tag==="Failure");var dd=(e)=>e._tag==="Success";var $S=p(2,(e,t)=>{switch(e._tag){case lt:return ae(e.effect_instruction_i0);case ut:return ge(t)}}),zs=(e)=>$S(e,void 0);var To=(e,t)=>hv(e,t?.parallel?go:Ge),md=(e)=>ae(Ot(e));var Vs=(e)=>ae(ii(e)),ae=(e)=>{let t=new Qf(lt);return t.effect_instruction_i0=e,t};var hd=(e)=>ae(Xt(e)),$c=p(2,(e,t)=>{switch(e._tag){case lt:return ae(e.effect_instruction_i0);case ut:return ge(t(e.effect_instruction_i0))}});var il=p(2,(e,{onFailure:t,onSuccess:r})=>{switch(e._tag){case lt:return t(e.effect_instruction_i0);case ut:return r(e.effect_instruction_i0)}});var ge=(e)=>{let t=new Xf(ut);return t.effect_instruction_i0=e,t},Ut=ge(void 0);var gd=p(3,(e,t,{onFailure:r,onSuccess:n})=>{switch(e._tag){case lt:switch(t._tag){case ut:return ae(e.effect_instruction_i0);case lt:return ae(r(e.effect_instruction_i0,t.effect_instruction_i0))}case ut:switch(t._tag){case ut:return ge(n(e.effect_instruction_i0,t.effect_instruction_i0));case lt:return ae(t.effect_instruction_i0)}}}),hv=(e,t)=>{let r=rc(e);if(!Yt(r))return w();return m(Qt(r),Yo(m(Zt(r),$c(Re)),(n,o)=>m(n,gd(o,{onSuccess:(i,s)=>m(i,Je(s)),onFailure:t}))),$c(hn),$c((n)=>Dr(n)),I)},BS=(e)=>({...pn,[uS]:pS,state:Tc(fS([])),commit(){return sl(this)},blockingOn:e});var sl=(e)=>ES((t)=>{let r=ai(e.state);switch(r._tag){case jc:return t(r.effect);case pi:return r.joiners.push(t),gv(e,t)}},e.blockingOn);var al=(e,t)=>{let r=ai(e.state);if(r._tag===pi){kc(e.state,dS(t));for(let n=0,o=r.joiners.length;n<o;n++)r.joiners[n](t)}},gv=(e,t)=>C(()=>{let r=ai(e.state);if(r._tag===pi){let n=r.joiners.indexOf(t);if(n>=0)r.joiners.splice(n,1)}}),yv=We((e)=>ge(e.currentContext)),KS=()=>yv;var ko=(e)=>L(KS(),e),xv=p(2,(e,t)=>Cn(Eo,t)(e));var yd=p(2,(e,t)=>ko((r)=>xv(e,t(r))));var cl=(e)=>{let t=e.currentSpan;return t!==void 0&&t._tag==="Span"?I(t):w()};var WS=Jy;var zS=er;var ll="And",ul="Or",pl="InvalidData",fl="MissingData",dl="SourceUnavailable",ml="Unsupported";var _v="effect/ConfigError",VS=Symbol.for(_v),Si={_tag:"ConfigError",[VS]:VS},hl=(e,t)=>{let r=Object.create(Si);return r._op=ll,r.left=e,r.right=t,Object.defineProperty(r,"toString",{enumerable:!1,value(){return`${this.left} and ${this.right}`}}),Object.defineProperty(r,"message",{enumerable:!1,get(){return this.toString()}}),r},gl=(e,t)=>{let r=Object.create(Si);return r._op=ul,r.left=e,r.right=t,Object.defineProperty(r,"toString",{enumerable:!1,value(){return`${this.left} or ${this.right}`}}),Object.defineProperty(r,"message",{enumerable:!1,get(){return this.toString()}}),r},xd=(e,t,r={pathDelim:"."})=>{let n=Object.create(Si);return n._op=pl,n.path=e,n.message=t,Object.defineProperty(n,"toString",{enumerable:!1,value(){return`(Invalid data at ${m(this.path,Lr(r.pathDelim))}: "${this.message}")`}}),n},hr=(e,t,r={pathDelim:"."})=>{let n=Object.create(Si);return n._op=fl,n.path=e,n.message=t,Object.defineProperty(n,"toString",{enumerable:!1,value(){return`(Missing data at ${m(this.path,Lr(r.pathDelim))}: "${this.message}")`}}),n},Sd=(e,t,r,n={pathDelim:"."})=>{let o=Object.create(Si);return o._op=dl,o.path=e,o.message=t,o.cause=r,Object.defineProperty(o,"toString",{enumerable:!1,value(){return`(Source unavailable at ${m(this.path,Lr(n.pathDelim))}: "${this.message}")`}}),o},bd=(e,t,r={pathDelim:"."})=>{let n=Object.create(Si);return n._op=ml,n.path=e,n.message=t,Object.defineProperty(n,"toString",{enumerable:!1,value(){return`(Unsupported operation at ${m(this.path,Lr(r.pathDelim))}: "${this.message}")`}}),n};var Pn=p(2,(e,t)=>{switch(e._op){case ll:return hl(Pn(e.left,t),Pn(e.right,t));case ul:return gl(Pn(e.left,t),Pn(e.right,t));case pl:return xd([...t,...e.path],e.message);case fl:return hr([...t,...e.path],e.message);case dl:return Sd([...t,...e.path],e.message,e.cause);case ml:return bd([...t,...e.path],e.message)}});var JS=p(3,(e,t,r)=>{let n=[e],o=[];while(n.length>0){let s=n.pop();switch(s._op){case ll:{n.push(s.right),n.push(s.left),o.push(U({_op:"AndCase"}));break}case ul:{n.push(s.right),n.push(s.left),o.push(U({_op:"OrCase"}));break}case pl:{o.push(B(r.invalidDataCase(t,s.path,s.message)));break}case fl:{o.push(B(r.missingDataCase(t,s.path,s.message)));break}case dl:{o.push(B(r.sourceUnavailableCase(t,s.path,s.message,s.cause)));break}case ml:{o.push(B(r.unsupportedCase(t,s.path,s.message)));break}}}let i=[];while(o.length>0){let s=o.pop();switch(s._op){case"Left":{switch(s.left._op){case"AndCase":{let a=i.pop(),c=i.pop(),l=r.andCase(t,a,c);i.push(l);break}case"OrCase":{let a=i.pop(),c=i.pop(),l=r.orCase(t,a,c);i.push(l);break}}break}case"Right":{i.push(s.right);break}}}if(i.length===0)throw Error("BUG: ConfigError.reduceWithContext - please report an issue at https://github.com/Effect-TS/effect/issues");return i.pop()});var wv="effect/Clock",YS=Symbol.for(wv),Js=dt("effect/Clock"),Ev=2147483647,ZS={unsafeSchedule(e,t){let r=Oc(t);if(r>Ev)return an;let n=!1,o=setTimeout(()=>{n=!0,e()},r);return()=>(clearTimeout(o),!n)}},QS=function(){let e=BigInt(1e6);if(typeof performance>"u"||typeof performance.now!=="function")return()=>BigInt(Date.now())*e;let t;return()=>{if(t===void 0)t=BigInt(Date.now())*e-BigInt(Math.round(performance.now()*1e6));return t+BigInt(Math.round(performance.now()*1e6))}}(),Ov=function(){let e=typeof process==="object"&&"hrtime"in process&&typeof process.hrtime.bigint==="function"?process.hrtime:void 0;if(!e)return QS;let t=QS()-e.bigint();return()=>t+e.bigint()}();class XS{[YS]=YS;unsafeCurrentTimeMillis(){return Date.now()}unsafeCurrentTimeNanos(){return Ov()}currentTimeMillis=C(()=>this.unsafeCurrentTimeMillis());currentTimeNanos=C(()=>this.unsafeCurrentTimeNanos());scheduler(){return ee(ZS)}sleep(e){return An((t)=>{let r=ZS.unsafeSchedule(()=>t(ve),e);return Vr(C(r))})}}var eb=()=>new XS;var gr=Vg;var bi=(e)=>e.replace(/[/\\^$*+?.()|[\]{}]/g,"\\$&");var nb={_tag:"Empty"};var xl=p(2,(e,t)=>{let r=ks(t),n=e;while(Ef(r)){let o=r.head;switch(o._tag){case"Empty":{r=r.tail;break}case"AndThen":{r=Br(o.first,Br(o.second,r.tail));break}case"MapName":{n=Gt(n,o.f),r=r.tail;break}case"Nested":{n=Jo(n,o.name),r=r.tail;break}case"Unnested":{if(m(Fr(n),Zg(o.name)))n=Jt(n),r=r.tail;else return U(hr(n,`Expected ${o.name} to be in path in ConfigProvider#unnested`));break}}}return B(n)});var ob="Constant",ib="Fail",sb="Fallback",ab="Described",cb="Lazy",lb="MapOrFail",ub="Nested",pb="Primitive",fb="Redacted",db="Sequence",mb="HashMap",hb="ZipWith";var Sl=(e,t)=>[...e,...t],Cv="effect/ConfigProvider",gb=Symbol.for(Cv),xb=dt("effect/ConfigProvider"),Pv="effect/ConfigProviderFlat",yb=Symbol.for(Pv),Fv=(e)=>({[gb]:gb,pipe(){return y(this,arguments)},...e}),Nv=(e)=>({[yb]:yb,patch:e.patch,load:(t,r,n=!0)=>e.load(t,r,n),enumerateChildren:e.enumerateChildren}),Mv=(e)=>Fv({load:(t)=>L(Tt(e,Mr(),t,!1),(r)=>Ee(Fr(r),{onNone:()=>qe(hr(Mr(),`Expected a single value having structure: ${t}`)),onSome:ee})),flattened:e}),Sb=(e)=>{let{pathDelim:t,seqDelim:r}=Object.assign({},{pathDelim:"_",seqDelim:","},e),n=(c)=>m(c,Lr(t)),o=(c)=>c.split(t),i=()=>typeof process<"u"&&("env"in process)&&typeof process.env==="object"?process.env:{};return Mv(Nv({load:(c,l,u=!0)=>{let f=n(c),d=i(),h=f in d?I(d[f]):w();return m(h,bo(()=>hr(c,`Expected ${f} to exist in the process context`)),L((g)=>$v(g,c,l,r,u)))},enumerateChildren:(c)=>C(()=>{let l=i(),d=Object.keys(l).map((h)=>o(h.toUpperCase())).filter((h)=>{for(let g=0;g<c.length;g++){let P=m(c,Ap(g)),x=h[g];if(x===void 0||P!==x)return!1}return!0}).flatMap((h)=>h.slice(c.length,c.length+1));return $y(d)}),patch:nb}))};var Lv=(e,t,r,n)=>{let o=Cp(r.length,(c)=>c>=n.length?w():I([e(c),c+1])),i=Cp(n.length,(c)=>c>=r.length?w():I([t(c),c+1])),s=Sl(r,o),a=Sl(n,i);return[s,a]},Dv=(e,t)=>{let r=t;if(r._tag==="Nested"){let n=e.slice();while(r._tag==="Nested")n.push(r.name),r=r.config;return n}return e},qv={andCase:(e,t,r)=>hl(t,r),orCase:(e,t,r)=>gl(t,r),invalidDataCase:(e,t)=>xd(t,"<redacted>"),missingDataCase:(e,t)=>hr(t,"<redacted>"),sourceUnavailableCase:(e,t,r,n)=>Sd(t,"<redacted>",n),unsupportedCase:(e,t)=>bd(t,"<redacted>")},Uv=(e)=>JS(e,void 0,qv),Tt=(e,t,r,n)=>{let o=r;switch(o._tag){case ob:return ee(Ve(o.value));case ab:return fe(()=>Tt(e,t,o.config,n));case ib:return qe(hr(t,o.message));case sb:return m(fe(()=>Tt(e,t,o.first,n)),Ms((i)=>{if(o.condition(i))return m(Tt(e,t,o.second,n),Ms((s)=>qe(gl(i,s))));return qe(i)}));case cb:return fe(()=>Tt(e,t,o.config(),n));case lb:return fe(()=>m(Tt(e,t,o.original,n),L(qt((i)=>m(o.mapOrFail(i),bo(Pn(Dv(t,o.original))))))));case ub:return fe(()=>Tt(e,Sl(t,Ve(o.name)),o.config,n));case pb:return m(xl(t,e.patch),L((i)=>m(e.load(i,o,n),L((s)=>{if(s.length===0){let a=m(oy(i),ce(()=>"<n/a>"));return qe(hr([],`Expected ${o.description} with name ${a}`))}return ee(s)}))));case fb:return fe(()=>m(Tt(e,t,o.original,n),bo(Uv),we(Gt(o.redact))));case db:return m(xl(t,e.patch),L((i)=>m(e.enumerateChildren(i),L(Kv),L((s)=>{if(s.length===0)return fe(()=>we(Tt(e,t,o.config,!0),Ve));return m(qt(s,(a)=>Tt(e,ty(t,`[${a}]`),o.config,!0)),we((a)=>{let c=ec(a);if(c.length===0)return Ve(Mr());return Ve(c)}))}))));case mb:return fe(()=>m(xl(t,e.patch),L((i)=>m(e.enumerateChildren(i),L((s)=>m(s,qt((a)=>Tt(e,Sl(i,Ve(a)),o.valueConfig,n)),we((a)=>{if(a.length===0)return Ve(li());return m(Bv(a),Gt((c)=>vx(vp(pe(s),c))))})))))));case hb:return fe(()=>m(Tt(e,t,o.left,n),xo,L((i)=>m(Tt(e,t,o.right,n),xo,L((s)=>{if(he(i)&&he(s))return qe(hl(i.left,s.left));if(he(i)&&pt(s))return qe(i.left);if(pt(i)&&he(s))return qe(s.left);if(pt(i)&&pt(s)){let a=m(t,Lr(".")),c=Hv(t,a),[l,u]=Lv(c,c,m(i.right,Gt(B)),m(s.right,Gt(B)));return m(l,vp(u),qt(([f,d])=>m(Zc(f,d),we(([h,g])=>o.zip(h,g)))))}throw Error("BUG: ConfigProvider.fromFlatLoop - please report an issue at https://github.com/Effect-TS/effect/issues")})))))}},Hv=(e,t)=>(r)=>U(hr(e,`The element at index ${r} in a sequence at path "${t}" was missing`));var jv=(e,t)=>e.split(new RegExp(`\\s*${bi(t)}\\s*`)),$v=(e,t,r,n,o)=>{if(!o)return m(r.parse(e),Jc({onFailure:Pn(t),onSuccess:Ve}));return m(jv(e,n),qt((i)=>r.parse(i.trim())),bo(Pn(t)))},Bv=(e)=>Object.keys(e[0]).map((t)=>e.map((r)=>r[t])),Kv=(e)=>m(qt(e,zv),Jc({onFailure:()=>Mr(),onSuccess:Nr(gr)}),xo,we(Kg));var Wv=/^(\[(\d+)\])$/,zv=(e)=>{let t=e.match(Wv);if(t!==null){let r=t[2];return m(r!==void 0&&r.length>0?I(r):w(),Vt(Vv))}return w()};var Vv=(e)=>{let t=Number.parseInt(e);return Number.isNaN(t)?w():I(t)};var bb=Symbol.for("effect/Console"),bl=dt("effect/Console"),_b={[bb]:bb,assert(e,...t){return C(()=>{console.assert(e,...t)})},clear:C(()=>{console.clear()}),count(e){return C(()=>{console.count(e)})},countReset(e){return C(()=>{console.countReset(e)})},debug(...e){return C(()=>{console.debug(...e)})},dir(e,t){return C(()=>{console.dir(e,t)})},dirxml(...e){return C(()=>{console.dirxml(...e)})},error(...e){return C(()=>{console.error(...e)})},group(e){return e?.collapsed?C(()=>console.groupCollapsed(e?.label)):C(()=>console.group(e?.label))},groupEnd:C(()=>{console.groupEnd()}),info(...e){return C(()=>{console.info(...e)})},log(...e){return C(()=>{console.log(...e)})},table(e,t){return C(()=>{console.table(e,t)})},time(e){return C(()=>console.time(e))},timeEnd(e){return C(()=>console.timeEnd(e))},timeLog(e,...t){return C(()=>{console.timeLog(e,...t)})},trace(...e){return C(()=>{console.trace(...e)})},warn(...e){return C(()=>{console.warn(...e)})},unsafe:console};var Yv="effect/Random",wb=Symbol.for(Yv),Eb=dt("effect/Random");class Ob{seed;[wb]=wb;PRNG;constructor(e){this.seed=e,this.PRNG=new ip(e)}get next(){return C(()=>this.PRNG.number())}get nextBoolean(){return we(this.next,(e)=>e>0.5)}get nextInt(){return C(()=>this.PRNG.integer(Number.MAX_SAFE_INTEGER))}nextRange(e,t){return we(this.next,(r)=>(t-e)*r+e)}nextIntBetween(e,t){return C(()=>this.PRNG.integer(t-e)+e)}shuffle(e){return Zv(e,(t)=>this.nextIntBetween(0,t))}}var Zv=(e,t)=>fe(()=>m(C(()=>Array.from(e)),L((r)=>{let n=[];for(let o=r.length;o>=2;o=o-1)n.push(o);return m(n,So((o)=>m(t(o),we((i)=>Qv(r,o-1,i)))),zr(rc(r)))}))),Qv=(e,t,r)=>{let n=e[t];return e[t]=e[r],e[r]=n,e},Tb=(e)=>new Ob(S(e));var kb=Symbol.for("effect/Tracer"),eC=(e)=>({[kb]:kb,...e}),Gs=dt("effect/Tracer"),_l=dt("effect/ParentSpan"),Ab=function(){return function(r){let n="";for(let o=0;o<r;o++)n+="abcdef0123456789".charAt(Math.floor(Math.random()*16));return n}}();class Ib{name;parent;context;startTime;kind;_tag="Span";spanId;traceId="native";sampled=!0;status;attributes;events=[];links;constructor(e,t,r,n,o,i){this.name=e,this.parent=t,this.context=r,this.startTime=o,this.kind=i,this.status={_tag:"Started",startTime:o},this.attributes=new Map,this.traceId=t._tag==="Some"?t.value.traceId:Ab(32),this.spanId=Ab(16),this.links=Array.from(n)}end(e,t){this.status={_tag:"Ended",endTime:e,exit:t,startTime:this.status.startTime}}attribute(e,t){this.attributes.set(e,t)}event(e,t,r){this.events.push([e,t,r??{}])}addLinks(e){this.links.push(...e)}}var Rb=eC({span:(e,t,r,n,o,i)=>new Ib(e,t,r,n,o,i),context:(e)=>e()});var vb=Es()("effect/Tracer/DisablePropagation",{defaultValue:an});var nC=m(wn(),fr(Js,eb()),fr(bl,_b),fr(Eb,Tb(Math.random())),fr(xb,Sb()),fr(Gs,Rb)),Ys=N(Symbol.for("effect/DefaultServices/currentServices"),()=>el(nC));var iC=function(){let e=Symbol.for("effect/Data/Error/plainArgs");return{BaseEffectError:class extends ol{constructor(r){super(r?.message,r?.cause?{cause:r.cause}:void 0);if(r)Object.assign(this,r),Object.defineProperty(this,e,{value:r,enumerable:!1})}toJSON(){return{...this[e],...this}}}}.BaseEffectError}(),Cb=(e)=>{let t={BaseEffectError:class extends iC{_tag=e}};return t.BaseEffectError.prototype.name=e,t.BaseEffectError};var Pb=vr;var sC=Mg;class wd extends sC{}var Nb="Sequential",Mb="Parallel",aC="ParallelN",_i={_tag:Nb},Lb={_tag:Mb},Db=(e)=>({_tag:aC,parallelism:e}),Ed=(e)=>e._tag===Nb,Od=(e)=>e._tag===Mb;var wl=_i,El=Lb,Ol=Db;function qb(e){return new Jr(e)}function Ub(){return qb(new Map)}var kd=Symbol.for("effect/FiberRefs");class Jr{locals;[kd]=kd;constructor(e){this.locals=e}pipe(){return y(this,arguments)}}var lC=(e,t,r,n=!1)=>{let o=e,i=t,s=r,a=n,c=void 0;while(c===void 0)if(se(i)&&se(s)){let l=Ie(i)[0],u=Jt(i),f=Ie(s)[0],d=Ie(s)[1],h=Jt(s);if(l.startTimeMillis<f.startTimeMillis)s=h,a=!0;else if(l.startTimeMillis>f.startTimeMillis)i=u;else if(l.id<f.id)s=h,a=!0;else if(l.id>f.id)i=u;else c=[d,a]}else c=[o.initial,!0];return c},Id=p(3,(e,t,r)=>{let n=new Map(e.locals);return r.locals.forEach((o,i)=>{let s=o[0][1];if(!o[0][0][O](t)){if(!n.has(i)){if(b(s,i.initial))return;n.set(i,[[t,i.join(i.initial,s)]]);return}let a=n.get(i),[c,l]=lC(i,a,o);if(l){let u=i.diff(c,s),f=a[0][1],d=i.join(f,i.patch(u)(f));if(!b(f,d)){let h,g=a[0][0];if(g[O](t))h=[[g,d],...a.slice(1)];else h=[[t,d],...a];n.set(i,h)}}}}),new Jr(n)}),Rd=p(2,(e,t)=>{let r=new Map;return Hb(e,r,t),new Jr(r)}),Hb=(e,t,r)=>{e.locals.forEach((n,o)=>{let i=n[0][1],s=o.patch(o.fork)(i);if(b(i,s))t.set(o,n);else t.set(o,[[r,s],...n])})};var Zs=p(2,(e,t)=>{let r=new Map(e.locals);return r.delete(t),new Jr(r)}),vd=p(2,(e,t)=>{if(!e.locals.has(t))return w();return I(Ie(e.locals.get(t))[1])}),Fn=p(2,(e,t)=>m(vd(e,t),ce(()=>t.initial))),wi=p(2,(e,{fiberId:t,fiberRef:r,value:n})=>{if(e.locals.size===0)return new Jr(new Map([[r,[[t,n]]]]));let o=new Map(e.locals);return Ad(o,t,r,n),new Jr(o)}),Ad=(e,t,r,n)=>{let o=e.get(r)??[],i;if(se(o)){let[s,a]=Ie(o);if(s[O](t))if(b(a,n))return;else i=[[t,n],...o.slice(1)];else i=[[t,n],...o]}else i=[[t,n]];e.set(r,i)},jb=p(2,(e,{entries:t,forkAs:r})=>{if(e.locals.size===0)return new Jr(new Map(t));let n=new Map(e.locals);if(r!==void 0)Hb(e,n,r);return t.forEach(([o,i])=>{if(i.length===1)Ad(n,i[0][0],o,i[0][1]);else i.forEach(([s,a])=>{Ad(n,s,o,a)})}),new Jr(n)});var $b=Fn;var Bb=jb;var Kb=Ub;var zb="Empty",Vb="Add",Jb="Remove",Gb="Update",Yb="AndThen",Zb={_tag:zb},Qb=(e,t)=>{let r=new Map(e.locals),n=Zb;for(let[o,i]of t.locals.entries()){let s=Ie(i)[1],a=r.get(o);if(a!==void 0){let c=Ie(a)[1];if(!b(c,s))n=Tl({_tag:Gb,fiberRef:o,patch:o.diff(c,s)})(n)}else n=Tl({_tag:Vb,fiberRef:o,value:s})(n);r.delete(o)}for(let[o]of r.entries())n=Tl({_tag:Jb,fiberRef:o})(n);return n},Tl=p(2,(e,t)=>({_tag:Yb,first:e,second:t})),Xb=p(3,(e,t,r)=>{let n=r,o=Ve(e);while(se(o)){let i=Ie(o),s=Jt(o);switch(i._tag){case zb:{o=s;break}case Vb:{n=wi(n,{fiberId:t,fiberRef:i.fiberRef,value:i.value}),o=s;break}case Jb:{n=Zs(n,i.fiberRef),o=s;break}case Gb:{let a=Fn(n,i.fiberRef);n=wi(n,{fiberId:t,fiberRef:i.fiberRef,value:i.fiberRef.patch(i.patch)(a)}),o=s;break}case Yb:{o=Jo(i.first)(Jo(i.second)(s));break}}}return n});var e_=Qb;var t_=Xb;var Al="effect/FiberStatus",Nn=Symbol.for(Al),kl="Done",r_="Running",n_="Suspended",fC=ne(`${Al}-${kl}`);class o_{[Nn]=Nn;_tag=kl;[k](){return fC}[O](e){return Il(e)&&e._tag===kl}}class i_{runtimeFlags;[Nn]=Nn;_tag=r_;constructor(e){this.runtimeFlags=e}[k](){return m(S(Al),H(S(this._tag)),H(S(this.runtimeFlags)),Z(this))}[O](e){return Il(e)&&e._tag===r_&&this.runtimeFlags===e.runtimeFlags}}class s_{runtimeFlags;blockingOn;[Nn]=Nn;_tag=n_;constructor(e,t){this.runtimeFlags=e,this.blockingOn=t}[k](){return m(S(Al),H(S(this._tag)),H(S(this.runtimeFlags)),H(S(this.blockingOn)),Z(this))}[O](e){return Il(e)&&e._tag===n_&&this.runtimeFlags===e.runtimeFlags&&b(this.blockingOn,e.blockingOn)}}var a_=new o_,c_=(e)=>new i_(e),l_=(e,t)=>new s_(e,t),Il=(e)=>_(e,Nn),u_=(e)=>e._tag===kl;var p_=a_,Pd=c_,f_=l_;var d_=u_;var hC=AS,gC=IS,yC=RS,xC=ad,SC=cd,bC=ld,_C=vS,wC=CS;var EC=m(gr,Xa((e)=>e.ordinal));var m_=_p(EC);var h_=(e)=>{switch(e){case"All":return hC;case"Debug":return bC;case"Error":return yC;case"Fatal":return gC;case"Info":return SC;case"Trace":return _C;case"None":return wC;case"Warning":return xC}};var TC=Symbol.for("effect/Micro"),vl=Symbol.for("effect/Micro/MicroExit");var g_=Symbol.for("effect/Micro/MicroCause");var kC={_E:Q};class Md extends globalThis.Error{_tag;traces;[g_];constructor(e,t,r){let n=`MicroCause.${e}`,o,i,s;if(t instanceof globalThis.Error){o=`(${n}) ${t.name}`,i=t.message;let a=i.split(`
|
|
29
|
+
`).length;s=t.stack?`(${n}) ${t.stack.split(`
|
|
30
|
+
`).slice(0,a+3).join(`
|
|
31
|
+
`)}`:`${o}: ${i}`}else o=n,i=Rr(t,0),s=`${o}: ${i}`;if(r.length>0)s+=`
|
|
32
|
+
${r.join(`
|
|
33
|
+
`)}`;super(i);this._tag=e,this.traces=r,this[g_]=kC,this.name=o,this.stack=s}pipe(){return y(this,arguments)}toString(){return this.stack}[J](){return this.stack}}class S_ extends Md{defect;constructor(e,t=[]){super("Die",e,t);this.defect=e}}var AC=(e,t=[])=>new S_(e,t);class b_ extends Md{constructor(e=[]){super("Interrupt","interrupted",e)}}var IC=(e=[])=>new b_(e);var RC=(e)=>e._tag==="Interrupt";var y_=Symbol.for("effect/Micro/MicroFiber"),vC={_A:Q,_E:Q};class __{context;interruptible;[y_];_stack=[];_observers=[];_exit;_children;currentOpCount=0;constructor(e,t=!0){this.context=e,this.interruptible=t,this[y_]=vC}getRef(e){return sx(this.context,e)}addObserver(e){if(this._exit)return e(this._exit),Gi;return this._observers.push(e),()=>{let t=this._observers.indexOf(e);if(t>=0)this._observers.splice(t,1)}}_interrupted=!1;unsafeInterrupt(){if(this._exit)return;if(this._interrupted=!0,this.interruptible)this.evaluate(Hd)}unsafePoll(){return this._exit}evaluate(e){if(this._exit)return;else if(this._yielded!==void 0){let n=this._yielded;this._yielded=void 0,n()}let t=this.runLoop(e);if(t===Rl)return;let r=x_.interruptChildren&&x_.interruptChildren(this);if(r!==void 0)return this.evaluate(Pl(r,()=>t));this._exit=t;for(let n=0;n<this._observers.length;n++)this._observers[n](t);this._observers.length=0}runLoop(e){let t=!1,r=e;this.currentOpCount=0;try{while(!0){if(this.currentOpCount++,!t&&this.getRef(Nl).shouldYield(this)){t=!0;let n=r;r=Pl(MC,()=>n)}if(r=r[Fd](this),r===Rl){let n=this._yielded;if(vl in n)return this._yielded=void 0,n;return Rl}}}catch(n){if(!_(r,Fd))return Nd(`MicroFiber.runLoop: Not a valid effect: ${String(r)}`);return Nd(n)}}getCont(e){while(!0){let t=this._stack.pop();if(!t)return;let r=t[Cl]&&t[Cl](this);if(r)return{[e]:r};if(t[e])return t}}_yielded=void 0;yieldWith(e){return this._yielded=e,Rl}children(){return this._children??=new Set}}var x_=N("effect/Micro/fiberMiddleware",()=>({interruptChildren:void 0}));var w_=Symbol.for("effect/Micro/identifier"),Fe=Symbol.for("effect/Micro/args"),Fd=Symbol.for("effect/Micro/evaluate"),Oi=Symbol.for("effect/Micro/successCont"),Ei=Symbol.for("effect/Micro/failureCont"),Cl=Symbol.for("effect/Micro/ensureCont"),Rl=Symbol.for("effect/Micro/Yield"),CC={_A:Q,_E:Q,_R:Q},PC={...Pb,_op:"Micro",[TC]:CC,pipe(){return y(this,arguments)},[Symbol.iterator](){return new $o(new Ir(this))},toJSON(){return{_id:"Micro",op:this[w_],...Fe in this?{args:this[Fe]}:void 0}},toString(){return oe(this)},[J](){return oe(this)}};function FC(e){return Nd("Micro.evaluate: Not implemented")}var Fl=(e)=>({...PC,[w_]:e.op,[Fd]:e.eval??FC,[Oi]:e.contA,[Ei]:e.contE,[Cl]:e.ensure}),Ld=(e)=>{let t=Fl(e);return function(){let r=Object.create(t);return r[Fe]=e.single===!1?arguments:arguments[0],r}},E_=(e)=>{let t={...Fl(e),[vl]:vl,_tag:e.op,get[e.prop](){return this[Fe]},toJSON(){return{_id:"MicroExit",_tag:e.op,[e.prop]:this[Fe]}},[O](r){return qC(r)&&r._tag===e.op&&b(this[Fe],r[Fe])},[k](){return Z(this,H(ne(e.op))(S(this[Fe])))}};return function(r){let n=Object.create(t);return n[Fe]=r,n[Oi]=void 0,n[Ei]=void 0,n[Cl]=void 0,n}},Dd=E_({op:"Success",prop:"value",eval(e){let t=e.getCont(Oi);return t?t[Oi](this[Fe],e):e.yieldWith(this)}}),O_=E_({op:"Failure",prop:"cause",eval(e){let t=e.getCont(Ei);while(RC(this[Fe])&&t&&e.interruptible)t=e.getCont(Ei);return t?t[Ei](this[Fe],e):e.yieldWith(this)}});var NC=Ld({op:"Yield",eval(e){let t=!1;return e.getRef(Nl).scheduleTask(()=>{if(t)return;e.evaluate(UC)},this[Fe]??0),e.yieldWith(()=>{t=!0})}}),MC=NC(0);var LC=Dd(void 0);var qd=Ld({op:"WithMicroFiber",eval(e){return this[Fe](e)}});var Pl=p(2,(e,t)=>{let r=Object.create(DC);return r[Fe]=e,r[Oi]=t,r}),DC=Fl({op:"OnSuccess",eval(e){return e._stack.push(this),this[Fe]}});var qC=(e)=>_(e,vl),T_=Dd,Ud=O_,Hd=Ud(IC());var Nd=(e)=>Ud(AC(e));var UC=T_(void 0);var HC="setImmediate"in globalThis?globalThis.setImmediate:(e)=>setTimeout(e,0);class jd{tasks=[];running=!1;scheduleTask(e,t){if(this.tasks.push(e),!this.running)this.running=!0,HC(this.afterScheduled)}afterScheduled=()=>{this.running=!1,this.runTasks()};runTasks(){let e=this.tasks;this.tasks=[];for(let t=0,r=e.length;t<r;t++)e[t]()}shouldYield(e){return e.currentOpCount>=e.getRef(A_)}flush(){while(this.tasks.length>0)this.runTasks()}}var jC=p(2,(e,t)=>qd((r)=>{let n=r.context;return r.context=t(n),KC(e,()=>(r.context=n,LC))}));var k_=p(2,(e,t)=>jC(e,ws(t)));class A_ extends Es()("effect/Micro/currentMaxOpsBeforeYield",{defaultValue:()=>2048}){}class Nl extends Es()("effect/Micro/currentScheduler",{defaultValue:()=>new jd}){}var $C=p(2,(e,t)=>{let r=Object.create(BC);return r[Fe]=e,r[Oi]=t.onSuccess,r[Ei]=t.onFailure,r}),BC=Fl({op:"OnSuccessAndFailure",eval(e){return e._stack.push(this),this[Fe]}});var KC=p(2,(e,t)=>zC((r)=>$C(r(e),{onFailure:(n)=>Pl(t(Ud(n)),()=>O_(n)),onSuccess:(n)=>Pl(t(T_(n)),()=>Dd(n))})));var I_=Ld({op:"SetInterruptible",ensure(e){if(e.interruptible=this[Fe],e._interrupted&&e.interruptible)return()=>Hd}}),WC=(e)=>qd((t)=>{if(t.interruptible)return e;if(t.interruptible=!0,t._stack.push(I_(!1)),t._interrupted)return Hd;return e}),zC=(e)=>qd((t)=>{if(!t.interruptible)return e(Q);return t.interruptible=!1,t._stack.push(I_(!0)),e(WC)});var R_=(e,t)=>{let r=new __(Nl.context(t?.scheduler??new jd));if(r.evaluate(e),t?.signal)if(t.signal.aborted)r.unsafeInterrupt();else{let n=()=>r.unsafeInterrupt();t.signal.addEventListener("abort",n,{once:!0}),r.addObserver(()=>t.signal.removeEventListener("abort",n))}return r};class Ml{scheduleDrain;running=!1;tasks=new $d;constructor(e){this.scheduleDrain=e}starveInternal=(e)=>{let t=this.tasks.buckets;this.tasks.buckets=[];for(let[r,n]of t)for(let o=0;o<n.length;o++)n[o]();if(this.tasks.buckets.length===0)this.running=!1;else this.starve(e)};starve(e=0){this.scheduleDrain(e,this.starveInternal)}scheduleTask(e,t){if(this.tasks.scheduleTask(e,t),!this.running)this.running=!0,this.starve()}static cached(e){let t=new Ml(e),r=new WeakMap;return(n)=>{if(n===void 0)return t;let o=r.get(n);if(o===void 0)o=new Ml(e),r.set(n,o);return o}}}class $d{buckets=[];scheduleTask(e,t){let r=this.buckets.length,n=void 0,o=0;for(;o<r;o++)if(this.buckets[o][0]<=t)n=this.buckets[o];else break;if(n&&n[0]===t)n[1].push(e);else if(o===r)this.buckets.push([t,[e]]);else this.buckets.splice(o,0,[t,[e]])}}class v_{maxNextTickBeforeTimer;getRunner=Ml.cached((e,t)=>{if(e>=this.maxNextTickBeforeTimer)setTimeout(()=>t(0),0);else Promise.resolve(void 0).then(()=>t(e+1))});constructor(e){this.maxNextTickBeforeTimer=e}shouldYield(e){return e.currentOpCount>e.getFiberRef(ud)?e.getFiberRef(gi):!1}scheduleTask(e,t,r){this.getRunner(r).scheduleTask(e,t)}}var C_=N(Symbol.for("effect/Scheduler/defaultScheduler"),()=>new v_(2048));class Qs{tasks=new $d;deferred=!1;scheduleTask(e,t,r){if(this.deferred)C_.scheduleTask(e,t,r);else this.tasks.scheduleTask(e,t)}shouldYield(e){return e.currentOpCount>e.getFiberRef(ud)?e.getFiberRef(gi):!1}flush(){while(this.tasks.buckets.length>0){let e=this.tasks.buckets;this.tasks.buckets=[];for(let[t,r]of e)for(let n=0;n<r.length;n++)r[n]()}this.deferred=!0}}var Ll=N(Symbol.for("effect/FiberRef/currentScheduler"),()=>ze(C_));var Dl=N(Symbol.for("effect/FiberRef/currentRequestMap"),()=>ze(new Map));var Bd=(e,t,r,n)=>{switch(e){case void 0:return t();case"unbounded":return r();case"inherit":return _o(DS,(o)=>o==="unbounded"?r():o>1?n(o):t());default:return e>1?n(e):t()}};var Kd=(e)=>e.replace(/[\s="]/g,"_"),F_=(e)=>(t)=>`${Kd(t.label)}=${e-t.startTime}ms`;var N_="effect/MetricLabel",Wd=Symbol.for(N_);class M_{key;value;[Wd]=Wd;_hash;constructor(e,t){this.key=e,this.value=t,this._hash=ne(N_+this.key+this.value)}[k](){return this._hash}[O](e){return ZC(e)&&this.key===e.key&&this.value===e.value}pipe(){return y(this,arguments)}}var L_=(e,t)=>new M_(e,t),ZC=(e)=>_(e,Wd);var zd=Vt((e)=>bs(e.context,vb)?e._tag==="Span"?zd(e.parent):w():I(e));var D_=dd;var Vd="InterruptSignal",Jd="Stateful",Gd="Resume",Yd="YieldNow",ql=(e)=>({_tag:"InterruptSignal",cause:e}),Ti=(e)=>({_tag:"Stateful",onFiber:e}),Ao=(e)=>({_tag:"Resume",effect:e}),q_=()=>({_tag:"YieldNow"});var nP="effect/FiberScope",Ul=Symbol.for(nP);class H_{[Ul]=Ul;fiberId=Lt;roots=new Set;add(e,t){this.roots.add(t),t.addObserver(()=>{this.roots.delete(t)})}}class j_{fiberId;parent;[Ul]=Ul;constructor(e,t){this.fiberId=e,this.parent=t}add(e,t){this.parent.tell(Ti((r)=>{r.addChild(t),t.addObserver(()=>{r.removeChild(t)})}))}}var $_=(e)=>new j_(e.id(),e),Xs=N(Symbol.for("effect/FiberScope/Global"),()=>new H_);var sP="effect/Fiber",Zd=Symbol.for(sP),Qd={_E:(e)=>e,_A:(e)=>e},aP={[Zd]:Qd,pipe(){return y(this,arguments)}},cP="effect/Fiber",K_=Symbol.for(cP);var Hl=(e)=>Qc(Ds(e.await),e.inheritAll);var GU={...pn,commit(){return Hl(this)},...aP,id:()=>Lt,await:js,children:ee([]),inheritAll:js,poll:ee(w()),interruptAsFork:()=>js};var Mn="effect/FiberCurrent";var uP="effect/Logger",W_=Symbol.for(uP),z_={_Message:(e)=>e,_Output:(e)=>e},jl=(e)=>({[W_]:z_,log:e,pipe(){return y(this,arguments)}});var QU={[W_]:z_,log:Gi,pipe(){return y(this,arguments)}};var pP=/^[^\s"=]*$/,fP=(e,t)=>({annotations:r,cause:n,date:o,fiberId:i,logLevel:s,message:a,spans:c})=>{let l=(g)=>g.match(pP)?g:e(g),u=(g,P)=>`${Kd(g)}=${l(P)}`,f=(g,P)=>" "+u(g,P),d=u("timestamp",o.toISOString());d+=f("level",s.label),d+=f("fiber",Rc(i));let h=Op(a);for(let g=0;g<h.length;g++)d+=f("message",Rr(h[g],t));if(!Yp(n))d+=f("cause",er(n,{renderErrorCause:!0}));for(let g of c)d+=" "+F_(o.getTime())(g);for(let[g,P]of r)d+=f(g,Rr(P,t));return d},dP=(e)=>`"${e.replace(/\\([\s\S])|(")/g,"\\$1$2")}"`,V_=jl(fP(dP));var Io={bold:"1",red:"31",green:"32",yellow:"33",blue:"34",cyan:"36",white:"37",gray:"90",black:"30",bgBrightRed:"101"},XU={None:[],All:[],Trace:[Io.gray],Debug:[Io.blue],Info:[Io.green],Warning:[Io.yellow],Error:[Io.red],Fatal:[Io.bgBrightRed,Io.black]};var J_=typeof process==="object"&&process!==null&&typeof process.stdout==="object"&&process.stdout!==null,e1=J_&&process.stdout.isTTY===!0,t1=J_||"Deno"in globalThis;var G_="effect/MetricBoundaries",Xd=Symbol.for(G_);class Y_{values;[Xd]=Xd;constructor(e){this.values=e,this._hash=m(ne(G_),H(wt(this.values)))}_hash;[k](){return this._hash}[O](e){return hP(e)&&b(this.values,e.values)}pipe(){return y(this,arguments)}}var hP=(e)=>_(e,Xd),gP=(e)=>{let t=m(e,Tp(Re(Number.POSITIVE_INFINITY)),Pp);return new Y_(t)};var Z_=(e)=>m(Ep(e.count-1,(t)=>e.start*Math.pow(e.factor,t)),ds,gP);var xP="effect/MetricKeyType",Q_=Symbol.for(xP),X_="effect/MetricKeyType/Counter",em=Symbol.for(X_),SP="effect/MetricKeyType/Frequency",bP=Symbol.for(SP),_P="effect/MetricKeyType/Gauge",wP=Symbol.for(_P),ew="effect/MetricKeyType/Histogram",tm=Symbol.for(ew),EP="effect/MetricKeyType/Summary",OP=Symbol.for(EP),tw={_In:(e)=>e,_Out:(e)=>e};class rw{incremental;bigint;[Q_]=tw;[em]=em;constructor(e,t){this.incremental=e,this.bigint=t,this._hash=ne(X_)}_hash;[k](){return this._hash}[O](e){return rm(e)}pipe(){return y(this,arguments)}}class nw{boundaries;[Q_]=tw;[tm]=tm;constructor(e){this.boundaries=e,this._hash=m(ne(ew),H(S(this.boundaries)))}_hash;[k](){return this._hash}[O](e){return nm(e)&&b(this.boundaries,e.boundaries)}pipe(){return y(this,arguments)}}var ow=(e)=>new rw(e?.incremental??!1,e?.bigint??!1);var iw=(e)=>new nw(e);var rm=(e)=>_(e,em),sw=(e)=>_(e,bP),aw=(e)=>_(e,wP),nm=(e)=>_(e,tm),cw=(e)=>_(e,OP);var TP="effect/MetricKey",uw=Symbol.for(TP),kP={_Type:(e)=>e},AP=mn(b);class $l{name;keyType;description;tags;[uw]=kP;constructor(e,t,r,n=[]){this.name=e,this.keyType=t,this.description=r,this.tags=n,this._hash=m(ne(this.name+this.description),H(S(this.keyType)),H(wt(this.tags)))}_hash;[k](){return this._hash}[O](e){return IP(e)&&this.name===e.name&&b(this.keyType,e.keyType)&&b(this.description,e.description)&&AP(this.tags,e.tags)}pipe(){return y(this,arguments)}}var IP=(e)=>_(e,uw),pw=(e,t)=>new $l(e,ow(t),Pr(t?.description));var fw=(e,t,r)=>new $l(e,iw(t),Pr(r));var dw=p(2,(e,t)=>t.length===0?e:new $l(e.name,e.keyType,e.description,dn(e.tags,t)));var mw=Symbol.for("effect/MutableHashMap"),vP={[mw]:mw,[Symbol.iterator](){return new om(this)},toString(){return oe(this.toJSON())},toJSON(){return{_id:"MutableHashMap",values:Array.from(this).map(X)}},[J](){return this.toJSON()},pipe(){return y(this,arguments)}};class om{self;referentialIterator;bucketIterator;constructor(e){this.self=e,this.referentialIterator=e.referential[Symbol.iterator]()}next(){if(this.bucketIterator!==void 0)return this.bucketIterator.next();let e=this.referentialIterator.next();if(e.done)return this.bucketIterator=new hw(this.self.buckets.values()),this.next();return e}[Symbol.iterator](){return new om(this.self)}}class hw{backing;constructor(e){this.backing=e}currentBucket;next(){if(this.currentBucket===void 0){let t=this.backing.next();if(t.done)return t;this.currentBucket=t.value[Symbol.iterator]()}let e=this.currentBucket.next();if(e.done)return this.currentBucket=void 0,this.next();return e}}var gw=()=>{let e=Object.create(vP);return e.referential=new Map,e.buckets=new Map,e.bucketsSize=0,e};var Ln=p(2,(e,t)=>{if(rs(t)===!1)return e.referential.has(t)?I(e.referential.get(t)):w();let r=t[k](),n=e.buckets.get(r);if(n===void 0)return w();return CP(e,n,t)});var CP=(e,t,r,n=!1)=>{for(let o=0,i=t.length;o<i;o++)if(r[O](t[o][0])){let s=t[o][1];if(n)t.splice(o,1),e.bucketsSize--;return I(s)}return w()},ki=p(2,(e,t)=>ue(Ln(e,t))),Ai=p(3,(e,t,r)=>{if(rs(t)===!1)return e.referential.set(t,r),e;let n=t[k](),o=e.buckets.get(n);if(o===void 0)return e.buckets.set(n,[[t,r]]),e.bucketsSize++,e;return PP(e,o,t),o.push([t,r]),e.bucketsSize++,e}),PP=(e,t,r)=>{for(let n=0,o=t.length;n<o;n++)if(r[O](t[n][0])){t.splice(n,1),e.bucketsSize--;return}};var NP="effect/MetricState",ea=Symbol.for(NP),yw="effect/MetricState/Counter",im=Symbol.for(yw),xw="effect/MetricState/Frequency",sm=Symbol.for(xw),Sw="effect/MetricState/Gauge",am=Symbol.for(Sw),bw="effect/MetricState/Histogram",cm=Symbol.for(bw),_w="effect/MetricState/Summary",lm=Symbol.for(_w),ta={_A:(e)=>e};class ww{count;[ea]=ta;[im]=im;constructor(e){this.count=e}[k](){return m(S(yw),H(S(this.count)),Z(this))}[O](e){return LP(e)&&this.count===e.count}pipe(){return y(this,arguments)}}var MP=mn(b);class Ew{occurrences;[ea]=ta;[sm]=sm;constructor(e){this.occurrences=e}_hash;[k](){return m(ne(xw),H(wt(pe(this.occurrences.entries()))),Z(this))}[O](e){return DP(e)&&MP(pe(this.occurrences.entries()),pe(e.occurrences.entries()))}pipe(){return y(this,arguments)}}class Ow{value;[ea]=ta;[am]=am;constructor(e){this.value=e}[k](){return m(S(Sw),H(S(this.value)),Z(this))}[O](e){return qP(e)&&this.value===e.value}pipe(){return y(this,arguments)}}class Tw{buckets;count;min;max;sum;[ea]=ta;[cm]=cm;constructor(e,t,r,n,o){this.buckets=e,this.count=t,this.min=r,this.max=n,this.sum=o}[k](){return m(S(bw),H(S(this.buckets)),H(S(this.count)),H(S(this.min)),H(S(this.max)),H(S(this.sum)),Z(this))}[O](e){return UP(e)&&b(this.buckets,e.buckets)&&this.count===e.count&&this.min===e.min&&this.max===e.max&&this.sum===e.sum}pipe(){return y(this,arguments)}}class kw{error;quantiles;count;min;max;sum;[ea]=ta;[lm]=lm;constructor(e,t,r,n,o,i){this.error=e,this.quantiles=t,this.count=r,this.min=n,this.max=o,this.sum=i}[k](){return m(S(_w),H(S(this.error)),H(S(this.quantiles)),H(S(this.count)),H(S(this.min)),H(S(this.max)),H(S(this.sum)),Z(this))}[O](e){return HP(e)&&this.error===e.error&&b(this.quantiles,e.quantiles)&&this.count===e.count&&this.min===e.min&&this.max===e.max&&this.sum===e.sum}pipe(){return y(this,arguments)}}var Aw=(e)=>new ww(e),Iw=(e)=>new Ew(e),Rw=(e)=>new Ow(e),vw=(e)=>new Tw(e.buckets,e.count,e.min,e.max,e.sum),Cw=(e)=>new kw(e.error,e.quantiles,e.count,e.min,e.max,e.sum);var LP=(e)=>_(e,im),DP=(e)=>_(e,sm),qP=(e)=>_(e,am),UP=(e)=>_(e,cm),HP=(e)=>_(e,lm);var $P="effect/MetricHook",BP=Symbol.for($P),KP={_In:(e)=>e,_Out:(e)=>e},ra=(e)=>({[BP]:KP,pipe(){return y(this,arguments)},...e});var Pw=BigInt(0),Nw=(e)=>{let t=e.keyType.bigint?Pw:0,r=e.keyType.incremental?e.keyType.bigint?(o)=>o>=Pw:(o)=>o>=0:(o)=>!0,n=(o)=>{if(r(o))t=t+o};return ra({get:()=>Aw(t),update:n,modify:n})},Mw=(e)=>{let t=new Map;for(let n of e.keyType.preregisteredWords)t.set(n,0);let r=(n)=>{let o=t.get(n)??0;t.set(n,o+1)};return ra({get:()=>Iw(t),update:r,modify:r})},Lw=(e,t)=>{let r=t;return ra({get:()=>Rw(r),update:(n)=>{r=n},modify:(n)=>{r=r+n}})},Dw=(e)=>{let t=e.keyType.boundaries.values,r=t.length,n=new Uint32Array(r+1),o=new Float64Array(r),i=0,s=0,{MAX_VALUE:a,MIN_VALUE:c}=Number;m(t,Nr(gr),Gt((f,d)=>{o[d]=f}));let l=(f)=>{let d=0,h=r;while(d!==h){let g=Math.floor(d+(h-d)/2),P=o[g];if(f<=P)h=g;else d=g;if(h===d+1)if(f<=o[d])h=d;else d=h}if(n[d]=n[d]+1,i=i+1,s=s+f,f<a)a=f;if(f>c)c=f},u=()=>{let f=no(r),d=0;for(let h=0;h<r;h++){let g=o[h],P=n[h];d=d+P,f[h]=[g,d]}return f};return ra({get:()=>vw({buckets:u(),count:i,min:a,max:c,sum:s}),update:l,modify:l})},qw=(e)=>{let{error:t,maxAge:r,maxSize:n,quantiles:o}=e.keyType,i=m(o,Nr(gr)),s=no(n),a=0,c=0,l=0,u=0,f=0,d=(g)=>{let P=[],x=0;while(x!==n-1){let E=s[x];if(E!=null){let[W,F]=E,D=Ec(g-W);if(Sx(D,ff)&&xx(D,r))P.push(F)}x=x+1}return WP(t,i,Nr(P,gr))},h=(g,P)=>{if(n>0){a=a+1;let x=a%n;s[x]=[P,g]}u=c===0?g:Math.min(u,g),f=c===0?g:Math.max(f,g),c=c+1,l=l+g};return ra({get:()=>Cw({error:t,quantiles:d(Date.now()),count:c,min:u,max:f,sum:l}),update:([g,P])=>h(g,P),modify:([g,P])=>h(g,P)})},WP=(e,t,r)=>{let n=r.length;if(!se(t))return Mr();let o=t[0],i=t.slice(1),s=Fw(e,n,w(),0,o,r),a=Ve(s);return i.forEach((c)=>{a.push(Fw(e,n,s.value,s.consumed,c,s.rest))}),Gt(a,(c)=>[c.quantile,c.value])},Fw=(e,t,r,n,o,i)=>{let s=e,a=t,c=r,l=n,u=o,f=i,d=e,h=t,g=r,P=n,x=o,E=i;while(!0){if(!se(f))return{quantile:u,value:w(),consumed:l,rest:[]};if(u===1)return{quantile:u,value:I(Ip(f)),consumed:l+f.length,rest:[]};let W=Ie(f),F=iy(f,(v)=>v===W),D=u*a,T=s/2*D,A=l+F[0].length,R=Math.abs(A-D);if(A<D-T){d=s,h=a,g=Fr(f),P=A,x=u,E=F[1],s=d,a=h,c=g,l=P,u=x,f=E;continue}if(A>D+T){let v=ye(c)?I(W):c;return{quantile:u,value:v,consumed:l,rest:f}}switch(c._tag){case"None":{d=s,h=a,g=Fr(f),P=A,x=u,E=F[1],s=d,a=h,c=g,l=P,u=x,f=E;continue}case"Some":{let v=Math.abs(D-c.value);if(R<v){d=s,h=a,g=Fr(f),P=A,x=u,E=F[1],s=d,a=h,c=g,l=P,u=x,f=E;continue}return{quantile:u,value:I(c.value),consumed:l,rest:f}}}}throw Error("BUG: MetricHook.resolveQuantiles - please report an issue at https://github.com/Effect-TS/effect/issues")};var VP="effect/MetricPair",JP=Symbol.for(VP),GP={_Type:(e)=>e};var Uw=(e,t)=>({[JP]:GP,metricKey:e,metricState:t,pipe(){return y(this,arguments)}});var ZP="effect/MetricRegistry",Hw=Symbol.for(ZP);class jw{[Hw]=Hw;map=gw();snapshot(){let e=[];for(let[t,r]of this.map)e.push(Uw(t,r.get()));return e}get(e){let t=m(this.map,Ln(e),ft);if(t==null){if(rm(e.keyType))return this.getCounter(e);if(aw(e.keyType))return this.getGauge(e);if(sw(e.keyType))return this.getFrequency(e);if(nm(e.keyType))return this.getHistogram(e);if(cw(e.keyType))return this.getSummary(e);throw Error("BUG: MetricRegistry.get - unknown MetricKeyType - please report an issue at https://github.com/Effect-TS/effect/issues")}else return t}getCounter(e){let t=m(this.map,Ln(e),ft);if(t==null){let r=Nw(e);if(!m(this.map,ki(e)))m(this.map,Ai(e,r));t=r}return t}getFrequency(e){let t=m(this.map,Ln(e),ft);if(t==null){let r=Mw(e);if(!m(this.map,ki(e)))m(this.map,Ai(e,r));t=r}return t}getGauge(e){let t=m(this.map,Ln(e),ft);if(t==null){let r=Lw(e,e.keyType.bigint?BigInt(0):0);if(!m(this.map,ki(e)))m(this.map,Ai(e,r));t=r}return t}getHistogram(e){let t=m(this.map,Ln(e),ft);if(t==null){let r=Dw(e);if(!m(this.map,ki(e)))m(this.map,Ai(e,r));t=r}return t}getSummary(e){let t=m(this.map,Ln(e),ft);if(t==null){let r=qw(e);if(!m(this.map,ki(e)))m(this.map,Ai(e,r));t=r}return t}}var $w=()=>new jw;var XP="effect/Metric",e0=Symbol.for(XP),t0={_Type:(e)=>e,_In:(e)=>e,_Out:(e)=>e},Bw=N(Symbol.for("effect/Metric/globalMetricRegistry"),()=>$w()),Kw=function(e,t,r,n){let o=Object.assign((i)=>Gc(i,(s)=>n0(o,s)),{[e0]:t0,keyType:e,unsafeUpdate:t,unsafeValue:r,unsafeModify:n,register(){return this.unsafeValue([]),this},pipe(){return y(this,arguments)}});return o};var na=(e,t)=>Ww(pw(e,t));var Ww=(e)=>{let t,r=new WeakMap,n=(o)=>{if(o.length===0){if(t!==void 0)return t;return t=Bw.get(e),t}let i=r.get(o);if(i!==void 0)return i;return i=Bw.get(dw(e,o)),r.set(o,i),i};return Kw(e.keyType,(o,i)=>n(i).update(o),(o)=>n(o).get(),(o,i)=>n(i).modify(o))};var zw=(e,t,r)=>Ww(fw(e,t,r));var Vw=p(3,(e,t,r)=>r0(e,[L_(t,r)]));var r0=p(2,(e,t)=>Kw(e.keyType,(r,n)=>e.unsafeUpdate(r,dn(t,n)),(r)=>e.unsafeValue(dn(t,r)),(r,n)=>e.unsafeModify(r,dn(t,n))));var n0=p(2,(e,t)=>_o(Bs,(r)=>C(()=>e.unsafeUpdate(t,r))));var i0="effect/Request",s0=Symbol.for(i0),a0={_E:(e)=>e,_A:(e)=>e},P1={...cs,[s0]:a0};var Jw=p(2,(e,t)=>_o(Dl,(r)=>C(()=>{if(r.has(e)){let n=r.get(e);if(!n.state.completed)n.state.completed=!0,al(n.result,t)}})));var c0="effect/Supervisor",Bl=Symbol.for(c0),um={_T:(e)=>e};class Kl{underlying;value0;[Bl]=um;constructor(e,t){this.underlying=e,this.value0=t}get value(){return this.value0}onStart(e,t,r,n){this.underlying.onStart(e,t,r,n)}onEnd(e,t){this.underlying.onEnd(e,t)}onEffect(e,t){this.underlying.onEffect(e,t)}onSuspend(e){this.underlying.onSuspend(e)}onResume(e){this.underlying.onResume(e)}map(e){return new Kl(this,m(this.value,we(e)))}zip(e){return new Wl(this,e)}}class Wl{left;right;_tag="Zip";[Bl]=um;constructor(e,t){this.left=e,this.right=t}get value(){return Zc(this.left.value,this.right.value)}onStart(e,t,r,n){this.left.onStart(e,t,r,n),this.right.onStart(e,t,r,n)}onEnd(e,t){this.left.onEnd(e,t),this.right.onEnd(e,t)}onEffect(e,t){this.left.onEffect(e,t),this.right.onEffect(e,t)}onSuspend(e){this.left.onSuspend(e),this.right.onSuspend(e)}onResume(e){this.left.onResume(e),this.right.onResume(e)}map(e){return new Kl(this,m(this.value,we(e)))}zip(e){return new Wl(this,e)}}var pm=(e)=>_(e,Bl)&&es(e,"Zip");class Gw{effect;[Bl]=um;constructor(e){this.effect=e}get value(){return this.effect}onStart(e,t,r,n){}onEnd(e,t){}onEffect(e,t){}onSuspend(e){}onResume(e){}map(e){return new Kl(this,m(this.value,we(e)))}zip(e){return new Wl(this,e)}onRun(e,t){return e()}}var l0=(e)=>new Gw(e),Ro=N("effect/Supervisor/none",()=>l0(ve));var Yw=Tn;var Zw="Empty",Qw="AddSupervisor",Xw="RemoveSupervisor",eE="AndThen",Ii={_tag:Zw},zl=(e,t)=>({_tag:eE,first:e,second:t}),p0=(e,t)=>f0(t,Re(e)),f0=(e,t)=>{let r=e,n=t;while(Yt(n)){let o=Zt(n);switch(o._tag){case Zw:{n=Qt(n);break}case Qw:{r=r.zip(o.supervisor),n=Qt(n);break}case Xw:{r=dm(r,o.supervisor),n=Qt(n);break}case eE:{n=Je(o.first)(Je(o.second)(Qt(n)));break}}}return r},dm=(e,t)=>{if(b(e,t))return Ro;else if(pm(e))return dm(e.left,t).zip(dm(e.right,t));else return e},Vl=(e)=>{if(b(e,Ro))return pr();else if(pm(e))return m(Vl(e.left),Hr(Vl(e.right)));else return ao(e)},d0=(e,t)=>{if(b(e,t))return Ii;let r=Vl(e),n=Vl(t),o=m(n,zp(r),lo(Ii,(s,a)=>zl(s,{_tag:Qw,supervisor:a}))),i=m(r,zp(n),lo(Ii,(s,a)=>zl(s,{_tag:Xw,supervisor:a})));return zl(o,i)},tE=Yw({empty:Ii,patch:p0,combine:zl,diff:d0});var E0=na("effect_fiber_started",{incremental:!0}),rE=na("effect_fiber_active"),O0=na("effect_fiber_successes",{incremental:!0}),T0=na("effect_fiber_failures",{incremental:!0}),k0=Vw(zw("effect_fiber_lifetimes",Z_({start:0.5,factor:2,count:35})),"time_unit","milliseconds"),oa="Continue",A0="Done",nE="Yield",I0={_E:(e)=>e,_A:(e)=>e},Jl=(e)=>{throw Error(`BUG: FiberRuntime - ${Rr(e)} - please report an issue at https://github.com/Effect-TS/effect/issues`)},Gr=Symbol.for("effect/internal/fiberRuntime/YieldedOp"),Yr=N("effect/internal/fiberRuntime/yieldedOpChannel",()=>({currentOp:null})),ia={[Bo]:(e,t,r)=>Ke(()=>t.effect_instruction_i1(r)),["OnStep"]:(e,t,r)=>ge(ge(r)),[Ko]:(e,t,r)=>Ke(()=>t.effect_instruction_i2(r)),[ss]:(e,t,r)=>{if(e.patchRuntimeFlags(e.currentRuntimeFlags,t.patch),Wr(e.currentRuntimeFlags)&&e.isInterrupted())return ae(e.getInterruptedCause());else return ge(r)},[Wo]:(e,t,r)=>{if(Ke(()=>t.effect_instruction_i2(r)),Ke(()=>t.effect_instruction_i0()))return e.pushStack(t),Ke(()=>t.effect_instruction_i1());else return ve},[zo]:(e,t,r)=>{while(!0){let n=Ke(()=>t.effect_instruction_i0.next(r));if(n.done)return ge(n.value);let o=sp(n.value);if(!xi(o))return e.pushStack(t),o;else if(o._tag==="Failure")return o;r=o.value}}},R0={[Vd]:(e,t,r,n)=>(e.processNewInterruptSignal(n.cause),Wr(t)?ae(n.cause):r),[Gd]:(e,t,r,n)=>{throw Error("It is illegal to have multiple concurrent run loops in a single fiber")},[Jd]:(e,t,r,n)=>(n.onFiber(e,Pd(t)),r),[Yd]:(e,t,r,n)=>L(Hs(),()=>r)},v0=(e)=>So(sS(e),(t)=>vo(cS(t),([r,n])=>{let o=new Map,i=[];for(let a of n){i.push(Dr(a));for(let c of a)o.set(c.request,c)}let s=i.flat();return Cn(W0(r.runAll(i),s,()=>s.forEach((a)=>{a.listeners.interrupted=!0})),Dl,o)},!1,!1)),C0=as();class Gl extends wd{[Zd]=Qd;[K_]=I0;_fiberRefs;_fiberId;_queue=[];_children=null;_observers=[];_running=!1;_stack=[];_asyncInterruptor=null;_asyncBlockingOn=null;_exitValue=null;_steps=[];_isYielding=!1;currentRuntimeFlags;currentOpCount=0;currentSupervisor;currentScheduler;currentTracer;currentSpan;currentContext;currentDefaultServices;constructor(e,t,r){super();if(this.currentRuntimeFlags=r,this._fiberId=e,this._fiberRefs=t,Hf(r)){let n=this.getFiberRef(Bs);E0.unsafeUpdate(1,n),rE.unsafeUpdate(1,n)}this.refreshRefCache()}commit(){return Hl(this)}id(){return this._fiberId}resume(e){this.tell(Ao(e))}get status(){return this.ask((e,t)=>t)}get runtimeFlags(){return this.ask((e,t)=>{if(d_(t))return e.currentRuntimeFlags;return t.runtimeFlags})}scope(){return $_(this)}get children(){return this.ask((e)=>Array.from(e.getChildren()))}getChildren(){if(this._children===null)this._children=new Set;return this._children}getInterruptedCause(){return this.getFiberRef(Ks)}fiberRefs(){return this.ask((e)=>e.getFiberRefs())}ask(e){return fe(()=>{let t=BS(this._fiberId);return this.tell(Ti((r,n)=>{al(t,C(()=>e(r,n)))})),sl(t)})}tell(e){if(this._queue.push(e),!this._running)this._running=!0,this.drainQueueLaterOnExecutor()}get await(){return An((e)=>{let t=(r)=>e(ee(r));if(this._exitValue!==null){t(this._exitValue);return}return this.tell(Ti((r,n)=>{if(r._exitValue!==null)t(this._exitValue);else r.addObserver(t)})),C(()=>this.tell(Ti((r,n)=>{r.removeObserver(t)})))},this.id())}get inheritAll(){return We((e,t)=>{let r=e.id(),n=e.getFiberRefs(),o=t.runtimeFlags,i=this.getFiberRefs(),s=Id(n,r,i);e.setFiberRefs(s);let a=e.getFiberRef(iE),c=m(Ps(o,a),Kf(Kr),Kf(Dc));return sd(c)})}get poll(){return C(()=>Pr(this._exitValue))}unsafePoll(){return this._exitValue}interruptAsFork(e){return C(()=>this.tell(ql(Xt(e))))}unsafeInterruptAsFork(e){this.tell(ql(Xt(e)))}addObserver(e){if(this._exitValue!==null)e(this._exitValue);else this._observers.push(e)}removeObserver(e){this._observers=this._observers.filter((t)=>t!==e)}getFiberRefs(){return this.setFiberRef(iE,this.currentRuntimeFlags),this._fiberRefs}unsafeDeleteFiberRef(e){this._fiberRefs=Zs(this._fiberRefs,e)}getFiberRef(e){if(this._fiberRefs.locals.has(e))return this._fiberRefs.locals.get(e)[0][1];return e.initial}setFiberRef(e,t){this._fiberRefs=wi(this._fiberRefs,{fiberId:this._fiberId,fiberRef:e,value:t}),this.refreshRefCache()}refreshRefCache(){this.currentDefaultServices=this.getFiberRef(Ys),this.currentTracer=this.currentDefaultServices.unsafeMap.get(Gs.key),this.currentSupervisor=this.getFiberRef(K0),this.currentScheduler=this.getFiberRef(Ll),this.currentContext=this.getFiberRef(Eo),this.currentSpan=this.currentContext.unsafeMap.get(_l.key)}setFiberRefs(e){this._fiberRefs=e,this.refreshRefCache()}addChild(e){this.getChildren().add(e)}removeChild(e){this.getChildren().delete(e)}transferChildren(e){let t=this._children;if(this._children=null,t!==null&&t.size>0){for(let r of t)if(r._exitValue===null)e.add(this.currentRuntimeFlags,r)}}drainQueueOnCurrentThread(){let e=!0;while(e){let t=oa,r=globalThis[Mn];globalThis[Mn]=this;try{while(t===oa)t=this._queue.length===0?A0:this.evaluateMessageWhileSuspended(this._queue.splice(0,1)[0])}finally{this._running=!1,globalThis[Mn]=r}if(this._queue.length>0&&!this._running)if(this._running=!0,t===nE)this.drainQueueLaterOnExecutor(),e=!1;else e=!0;else e=!1}}drainQueueLaterOnExecutor(){this.currentScheduler.scheduleTask(this.run,this.getFiberRef(gi),this)}drainQueueWhileRunning(e,t){let r=t;while(this._queue.length>0){let n=this._queue.splice(0,1)[0];r=R0[n._tag](this,e,r,n)}return r}isInterrupted(){return!yc(this.getFiberRef(Ks))}addInterruptedCause(e){let t=this.getFiberRef(Ks);this.setFiberRef(Ks,Ge(t,e))}processNewInterruptSignal(e){this.addInterruptedCause(e),this.sendInterruptSignalToAllChildren()}sendInterruptSignalToAllChildren(){if(this._children===null||this._children.size===0)return!1;let e=!1;for(let t of this._children)t.tell(ql(Xt(this.id()))),e=!0;return e}interruptAllChildren(){if(this.sendInterruptSignalToAllChildren()){let e=this._children.values();this._children=null;let t=!1;return Us({while:()=>!t,body:()=>{let n=e.next();if(!n.done)return Vr(n.value.await);else return C(()=>{t=!0})},step:()=>{}})}return null}reportExitValue(e){if(Hf(this.currentRuntimeFlags)){let t=this.getFiberRef(Bs),r=this.id().startTimeMillis,n=Date.now();switch(k0.unsafeUpdate(n-r,t),rE.unsafeUpdate(-1,t),e._tag){case ut:{O0.unsafeUpdate(1,t);break}case lt:{T0.unsafeUpdate(1,t);break}}}if(e._tag==="Failure"){let t=this.getFiberRef(US);if(!si(e.cause)&&t._tag==="Some")this.log("Fiber terminated with an unhandled error",e.cause,t)}}setExitValue(e){this._exitValue=e,this.reportExitValue(e);for(let t=this._observers.length-1;t>=0;t--)this._observers[t](e);this._observers=[]}getLoggers(){return this.getFiberRef(L0)}log(e,t,r){let n=ue(r)?r.value:this.getFiberRef(pd),o=this.getFiberRef(P0);if(m_(o,n))return;let i=this.getFiberRef(MS),s=this.getFiberRef(NS),a=this.getLoggers(),c=this.getFiberRefs();if(gs(a)>0){let l=bs(this.getFiberRef(Ys),Js),u=new Date(l.unsafeCurrentTimeMillis());Ag(c,()=>{for(let f of a)f.log({fiberId:this.id(),logLevel:n,message:e,cause:t,context:c,spans:i,annotations:s,date:u})})}}evaluateMessageWhileSuspended(e){switch(e._tag){case Yd:return nE;case Vd:{if(this.processNewInterruptSignal(e.cause),this._asyncInterruptor!==null)this._asyncInterruptor(ae(e.cause)),this._asyncInterruptor=null;return oa}case Gd:return this._asyncInterruptor=null,this._asyncBlockingOn=null,this.evaluateEffect(e.effect),oa;case Jd:return e.onFiber(this,this._exitValue!==null?p_:f_(this.currentRuntimeFlags,this._asyncBlockingOn)),oa;default:return Jl(e)}}evaluateEffect(e){this.currentSupervisor.onResume(this);try{let t=Wr(this.currentRuntimeFlags)&&this.isInterrupted()?ae(this.getInterruptedCause()):e;while(t!==null){let r=t,n=this.runLoop(r);if(n===Gr){let o=Yr.currentOp;if(Yr.currentOp=null,o._op===Vo)if(rS(this.currentRuntimeFlags))this.tell(q_()),this.tell(Ao(Ut)),t=null;else t=Ut;else if(o._op===eo)t=null}else{this.currentRuntimeFlags=m(this.currentRuntimeFlags,Df(Dc));let o=this.interruptAllChildren();if(o!==null)t=L(o,()=>n);else{if(this._queue.length===0)this.setExitValue(n);else this.tell(Ao(n));t=null}}}}finally{this.currentSupervisor.onSuspend(this)}}start(e){if(!this._running){this._running=!0;let t=globalThis[Mn];globalThis[Mn]=this;try{this.evaluateEffect(e)}finally{if(this._running=!1,globalThis[Mn]=t,this._queue.length>0)this.drainQueueLaterOnExecutor()}}else this.tell(Ao(e))}startFork(e){this.tell(Ao(e))}patchRuntimeFlags(e,t){let r=Fs(e,t);return globalThis[Mn]=this,this.currentRuntimeFlags=r,r}initiateAsync(e,t){let r=!1,n=(o)=>{if(!r)r=!0,this.tell(Ao(o))};if(Wr(e))this._asyncInterruptor=n;try{t(n)}catch(o){n(Ye(Ot(o)))}}pushStack(e){if(this._stack.push(e),e._op==="OnStep")this._steps.push({refs:this.getFiberRefs(),flags:this.currentRuntimeFlags})}popStack(){let e=this._stack.pop();if(e){if(e._op==="OnStep")this._steps.pop();return e}return}getNextSuccessCont(){let e=this.popStack();while(e){if(e._op!==is)return e;e=this.popStack()}}getNextFailCont(){let e=this.popStack();while(e){if(e._op!==Bo&&e._op!==Wo&&e._op!==zo)return e;e=this.popStack()}}[Rg](e){return C(()=>_s(this.currentContext,e))}["Left"](e){return qe(e.left)}["None"](e){return qe(new Ws)}["Right"](e){return ge(e.right)}["Some"](e){return ge(e.value)}["Micro"](e){return Ns((t)=>{let r=t,n=R_(k_(e,this.currentContext));return n.addObserver((o)=>{if(o._tag==="Success")return r(ge(o.value));switch(o.cause._tag){case"Interrupt":return r(ae(Xt(Lt)));case"Fail":return r(qe(o.cause.error));case"Die":return r(zc(o.cause.defect))}}),Ns((o)=>{r=(i)=>{o(ve)},n.unsafeInterrupt()})})}[Ja](e){let t=Ke(()=>e.effect_instruction_i0()),r=this.getNextSuccessCont();if(r!==void 0){if(!(r._op in ia))Jl(r);return ia[r._op](this,r,t)}else return Yr.currentOp=ge(t),Gr}[ut](e){let t=e,r=this.getNextSuccessCont();if(r!==void 0){if(!(r._op in ia))Jl(r);return ia[r._op](this,r,t.effect_instruction_i0)}else return Yr.currentOp=t,Gr}[lt](e){let t=e.effect_instruction_i0,r=this.getNextFailCont();if(r!==void 0)switch(r._op){case is:case Ko:if(!(Wr(this.currentRuntimeFlags)&&this.isInterrupted()))return Ke(()=>r.effect_instruction_i1(t));else return ae(bc(t));case"OnStep":if(!(Wr(this.currentRuntimeFlags)&&this.isInterrupted()))return ge(ae(t));else return ae(bc(t));case ss:if(this.patchRuntimeFlags(this.currentRuntimeFlags,r.patch),Wr(this.currentRuntimeFlags)&&this.isInterrupted())return ae(Ge(t,this.getInterruptedCause()));else return ae(t);default:Jl(r)}else return Yr.currentOp=ae(t),Gr}[Ga](e){return Ke(()=>e.effect_instruction_i0(this,Pd(this.currentRuntimeFlags)))}["Blocked"](e){let t=this.getFiberRefs(),r=this.currentRuntimeFlags;if(this._steps.length>0){let n=[],o=this._steps[this._steps.length-1],i=this.popStack();while(i&&i._op!=="OnStep")n.push(i),i=this.popStack();this.setFiberRefs(o.refs),this.currentRuntimeFlags=o.flags;let s=e_(o.refs,t),a=Ps(o.flags,r);return ge(Kc(e.effect_instruction_i0,We((c)=>{while(n.length>0)c.pushStack(n.pop());return c.setFiberRefs(t_(c.id(),c.getFiberRefs())(s)),c.currentRuntimeFlags=Fs(a)(c.currentRuntimeFlags),e.effect_instruction_i1})))}return Rn((n)=>L(ym(Yf(e.effect_instruction_i0)),()=>n(e.effect_instruction_i1)))}["RunBlocked"](e){return v0(e.effect_instruction_i0)}[ro](e){let t=e.effect_instruction_i0,r=this.currentRuntimeFlags,n=Fs(r,t);if(Wr(n)&&this.isInterrupted())return ae(this.getInterruptedCause());else if(this.patchRuntimeFlags(this.currentRuntimeFlags,t),e.effect_instruction_i1){let o=Ps(n,r);return this.pushStack(new Zf(o,e)),Ke(()=>e.effect_instruction_i1(r))}else return Ut}[Bo](e){return this.pushStack(e),e.effect_instruction_i0}["OnStep"](e){return this.pushStack(e),e.effect_instruction_i0}[is](e){return this.pushStack(e),e.effect_instruction_i0}[Ko](e){return this.pushStack(e),e.effect_instruction_i0}[eo](e){return this._asyncBlockingOn=e.effect_instruction_i1,this.initiateAsync(this.currentRuntimeFlags,e.effect_instruction_i0),Yr.currentOp=e,Gr}[Vo](e){return this._isYielding=!1,Yr.currentOp=e,Gr}[Wo](e){let{effect_instruction_i0:t,effect_instruction_i1:r}=e;if(t())return this.pushStack(e),r();else return Ut}[zo](e){return ia[zo](this,e,void 0)}[to](e){return Ke(()=>e.commit())}runLoop(e){let t=e;this.currentOpCount=0;while(!0){if((this.currentRuntimeFlags&tS)!==0)this.currentSupervisor.onEffect(this,t);if(this._queue.length>0)t=this.drainQueueWhileRunning(this.currentRuntimeFlags,t);if(!this._isYielding){this.currentOpCount+=1;let r=this.currentScheduler.shouldYield(this);if(r!==!1){this._isYielding=!0,this.currentOpCount=0;let n=t;t=L(Hs({priority:r}),()=>n)}}try{if(t=this.currentTracer.context(()=>{if(C0!==t[kn]._V){let r=this.getFiberRef(HS);if(r._tag==="Some"){let n=t[kn]._V;this.log(`Executing an Effect versioned ${n} with a Runtime of version ${as()}, you may want to dedupe the effect dependencies, you can use the language service plugin to detect this at compile time: https://github.com/Effect-TS/language-service`,jr,r)}}return this[t._op](t)},this),t===Gr){let r=Yr.currentOp;if(r._op===Vo||r._op===eo)return Gr;return Yr.currentOp=null,r._op===ut||r._op===lt?r:ae(Ot(r))}}catch(r){if(t!==Gr&&!_(t,"_op")||!(t._op in this))t=td(`Not a valid effect: ${Rr(t)}`);else if(jS(r))t=ae(Ge(Ot(r),Xt(Lt)));else t=zc(r)}}}run=()=>{this.drainQueueOnCurrentThread()}}var P0=N("effect/FiberRef/currentMinimumLogLevel",()=>ze(h_("Info"))),F0=(e)=>jl((t)=>{let r=$b(t.context,Ys);bs(r,bl).unsafe.log(e.log(t))});var N0=N(Symbol.for("effect/Logger/defaultLogger"),()=>F0(V_));var M0=N(Symbol.for("effect/Logger/tracerLogger"),()=>jl(({annotations:e,cause:t,context:r,fiberId:n,logLevel:o,message:i})=>{let s=zd(En(Fn(r,Eo),_l));if(s._tag==="None"||s.value._tag==="ExternalSpan")return;let a=_s(Fn(r,Ys),Js),c={};for(let[l,u]of e)c[l]=u;if(c["effect.fiberId"]=Rx(n),c["effect.logLevel"]=o.label,t!==null&&t._tag!=="Empty")c["effect.cause"]=er(t,{renderErrorCause:!0});s.value.event(Rr(Array.isArray(i)&&i.length===1?i[0]:i),a.unsafeCurrentTimeNanos(),c)}));var L0=N(Symbol.for("effect/FiberRef/currentLoggers"),()=>PS(ao(N0,M0)));var sE=p((e)=>rp(e[0]),(e,t,r)=>We((n)=>{let o=r?.batching===!0||r?.batching==="inherit"&&n.getFiberRef(qS);if(r?.discard)return Bd(r.concurrency,()=>Ri(wl,r?.concurrentFinalizers)((i)=>o?vo(e,(s,a)=>i(t(s,a)),!0,!1,1):So(e,(s,a)=>i(t(s,a)))),()=>Ri(El,r?.concurrentFinalizers)((i)=>vo(e,(s,a)=>i(t(s,a)),o,!1)),(i)=>Ri(Ol(i),r?.concurrentFinalizers)((s)=>vo(e,(a,c)=>s(t(a,c)),o,!1,i)));return Bd(r?.concurrency,()=>Ri(wl,r?.concurrentFinalizers)((i)=>o?mm(e,1,(s,a)=>i(t(s,a)),!0):qt(e,(s,a)=>i(t(s,a)))),()=>Ri(El,r?.concurrentFinalizers)((i)=>aE(e,(s,a)=>i(t(s,a)),o)),(i)=>Ri(Ol(i),r?.concurrentFinalizers)((s)=>mm(e,i,(a,c)=>s(t(a,c)),o)))})),aE=(e,t,r)=>fe(()=>{let n=pe(e),o=Array(n.length);return vn(vo(n,(s,a)=>L(t(s,a),(c)=>C(()=>o[a]=c)),r,!1),ee(o))}),vo=(e,t,r,n,o)=>Rn((i)=>id((s)=>We((a)=>{let c=Array.from(e).reverse(),l=c.length;if(l===0)return ve;let u=0,f=!1,d=o?Math.min(c.length,o):c.length,h=new Set,g=[],P=()=>h.forEach((v)=>{v.currentScheduler.scheduleTask(()=>{v.unsafeInterruptAsFork(a.id())},0,v)}),x=[],E=[],W=[],F=()=>{let v=g.filter(({exit:te})=>te._tag==="Failure").sort((te,re)=>te.index<re.index?-1:te.index===re.index?0:1).map(({exit:te})=>te);if(v.length===0)v.push(Ut);return v},D=(v,te=!1)=>{let re=Yc(s(v)),Y=q0(re,a,a.currentRuntimeFlags,Xs);return a.currentScheduler.scheduleTask(()=>{if(te)Y.unsafeInterruptAsFork(a.id());Y.resume(re)},0,Y),Y},T=()=>{if(!n)l-=c.length,c=[];f=!0,P()},A=r?od:In,R=D(An((v)=>{let te=(Y,xe)=>{if(Y._op==="Blocked")W.push(Y);else if(g.push({index:xe,exit:Y}),Y._op==="Failure"&&!f)T()},re=()=>{if(c.length>0){let Y=c.pop(),xe=u++,Rt=()=>{let $e=c.pop();return xe=u++,L(Hs(),()=>L(A(i(t($e,xe))),vt))},vt=($e)=>{if(c.length>0){if(te($e,xe),c.length>0)return Rt()}return ee($e)},Bt=L(A(i(t(Y,xe))),vt),je=D(Bt);if(x.push(je),h.add(je),f)je.currentScheduler.scheduleTask(()=>{je.unsafeInterruptAsFork(a.id())},0,je);je.addObserver(($e)=>{let Ct;if($e._op==="Failure")Ct=$e;else Ct=$e.effect_instruction_i0;if(E.push(je),h.delete(je),te(Ct,xe),g.length===l)v(ee(ce(To(F(),{parallel:!0}),()=>Ut)));else if(W.length+g.length===l){let qo=F(),Hu=W.map((Ui)=>Ui.effect_instruction_i0).reduce(zf);v(ee(Kc(Hu,vo([ce(To(qo,{parallel:!0}),()=>Ut),...W.map((Ui)=>Ui.effect_instruction_i1)],(Ui)=>Ui,r,!0,o))))}else re()})}};for(let Y=0;Y<d;Y++)re()}));return Vr(hi(Ds(i(Hl(R))),il({onFailure:(v)=>{T();let te=W.length+1,re=Math.min(typeof o==="number"?o:W.length,W.length),Y=Array.from(W);return An((xe)=>{let Rt=[],vt=0,Bt=0,je=(Ct,qo)=>(Hu)=>{if(Rt[Ct]=Hu,vt++,vt===te)xe(ge(ae(v)));if(Y.length>0&&qo)$e()},$e=()=>{D(Y.pop(),!0).addObserver(je(Bt,!0)),Bt++};R.addObserver(je(Bt,!1)),Bt++;for(let Ct=0;Ct<re;Ct++)$e()})},onSuccess:()=>qt(E,(v)=>v.inheritAll)})))}))),mm=(e,t,r,n)=>fe(()=>{let o=pe(e),i=Array(o.length);return vn(vo(o,(a,c)=>we(r(a,c),(l)=>i[c]=l),n,!1,t),ee(i))});var ym=(e)=>U0(e,Xs);var D0=(e,t,r,n=null)=>{let o=cE(e,t,r,n);return o.resume(e),o},q0=(e,t,r,n=null)=>cE(e,t,r,n),cE=(e,t,r,n=null)=>{let o=vc(),i=t.getFiberRefs(),s=Rd(i,o),a=new Gl(o,s,r),c=Fn(s,Eo),l=a.currentSupervisor;return l.onStart(c,e,I(t),a),a.addObserver((f)=>l.onEnd(f,a)),(n!==null?n:m(t.getFiberRef(Bc),ce(()=>t.scope()))).add(r,a),a},U0=(e,t)=>We((r,n)=>ee(D0(e,r,n.runtimeFlags,t)));var hm=(e)=>ko((t)=>Ee(En(t,sa),{onNone:()=>e,onSome:(r)=>{switch(r.strategy._tag){case"Parallel":return e;case"Sequential":case"ParallelN":return L(yi(r,El),(n)=>xm(e,n))}}})),oE=(e)=>(t)=>ko((r)=>Ee(En(r,sa),{onNone:()=>t,onSome:(n)=>{if(n.strategy._tag==="ParallelN"&&n.strategy.parallelism===e)return t;return L(yi(n,Ol(e)),(o)=>xm(t,o))}}));var Ri=(e,t)=>(r)=>ko((n)=>Ee(En(n,sa),{onNone:()=>r(Q),onSome:(o)=>{if(t===!0){let i=e._tag==="Parallel"?hm:e._tag==="Sequential"?gm:oE(e.parallelism);switch(o.strategy._tag){case"Parallel":return i(r(hm));case"Sequential":return i(r(gm));case"ParallelN":return i(r(oE(o.strategy.parallelism)))}}else return r(Q)}}));var gm=(e)=>ko((t)=>Ee(En(t,sa),{onNone:()=>e,onSome:(r)=>{switch(r.strategy._tag){case"Sequential":return e;case"Parallel":case"ParallelN":return L(yi(r,wl),(n)=>xm(e,n))}}}));var sa=dt("effect/Scope");var H0=(e,t)=>{if(e.state._tag==="Open")e.state.finalizers.set({},t)},j0={[tl]:tl,[rl]:rl,pipe(){return y(this,arguments)},fork(e){return C(()=>{let t=$0(e);if(this.state._tag==="Closed")return t.state=this.state,t;let r={},n=(o)=>t.close(o);return this.state.finalizers.set(r,n),H0(t,(o)=>C(()=>{if(this.state._tag==="Open")this.state.finalizers.delete(r)})),t})},close(e){return fe(()=>{if(this.state._tag==="Closed")return ve;let t=Array.from(this.state.finalizers.values()).reverse();if(this.state={_tag:"Closed",exit:e},t.length===0)return ve;return Ed(this.strategy)?m(qt(t,(r)=>In(r(e))),L((r)=>m(To(r),zt(zs),ce(()=>Ut)))):Od(this.strategy)?m(aE(t,(r)=>In(r(e)),!1),L((r)=>m(To(r,{parallel:!0}),zt(zs),ce(()=>Ut)))):m(mm(t,this.strategy.parallelism,(r)=>In(r(e)),!1),L((r)=>m(To(r,{parallel:!0}),zt(zs),ce(()=>Ut))))})},addFinalizer(e){return fe(()=>{if(this.state._tag==="Closed")return e(this.state.exit);return this.state.finalizers.set({},e),ve})}},$0=(e=_i)=>{let t=Object.create(j0);return t.strategy=e,t.state={_tag:"Open",finalizers:new Map},t};var xm=p(2,(e,t)=>yd(e,ws(px(sa,t))));var B0=(e)=>wo(e,{differ:tE,fork:Ii});var iE=FS(nS),K0=B0(Ro);var lE=p(2,(e,t)=>Rn((r)=>Dt(r(e),{onFailure:(n)=>Dt(t,{onFailure:(o)=>Ye(Ge(n,o)),onSuccess:()=>Ye(n)}),onSuccess:(n)=>zr(t,n)}))),W0=(e,t,r)=>Ls((n)=>lE(L(ym(Vc(e)),(o)=>An((i)=>{let s=t.map((l)=>l.listeners.count),a=()=>{if(s.every((l)=>l===0)){if(t.every((l)=>{if(l.result.state.current._tag==="Pending")return!0;else if(l.result.state.current._tag==="Done"&&xi(l.result.state.current.effect)&&l.result.state.current.effect._tag==="Failure"&&xc(l.result.state.current.effect.cause))return!0;else return!1}))c.forEach((l)=>l()),r?.(),i(kS(o))}};o.addObserver((l)=>{c.forEach((u)=>u()),i(l)});let c=t.map((l,u)=>{let f=(d)=>{s[u]=d,a()};return l.listeners.addObserver(f),()=>l.listeners.removeObserver(f)});return a(),C(()=>{c.forEach((l)=>l())})})),fe(()=>{let o=t.flatMap((i)=>{if(!i.state.completed)return[i];return[]});return So(o,(i)=>Jw(i.request,hd(n)))})));var pE=fd;var fE=yi;var bm=(e)=>function(){if(arguments.length===1){let t=arguments[0];return(r,...n)=>e(t,r,...n)}return e.apply(this,arguments)},dE=bm((e,t,r)=>{let n=vc(),o=[[Eo,[[n,e.context]]]];if(r?.scheduler)o.push([Ll,[[n,r.scheduler]]]);let i=Bb(e.fiberRefs,{entries:o,forkAs:n});if(r?.updateRefs)i=r.updateRefs(i,n);let s=new Gl(n,i,e.runtimeFlags),a=t;if(r?.scope)a=L(fE(r.scope,_i),(l)=>vn(nl(l,Ls((u)=>b(u,s.id())?ve:$s(s,u))),hi(t,(u)=>pE(l,u))));let c=s.currentSupervisor;if(c!==Ro)c.onStart(e.context,a,w(),s),s.addObserver((l)=>c.onEnd(l,s));if(Xs.add(e.runtimeFlags,s),r?.immediate===!1)s.resume(a);else s.start(a);return s});var G0=bm((e,t)=>{let r=X0(e)(t);if(r._tag==="Failure")throw Z0(r.effect_instruction_i0);return r.effect_instruction_i0});class mE extends Error{fiber;_tag="AsyncFiberException";constructor(e){super(`Fiber #${e.id().id} cannot be resolved synchronously. This is caused by using runSync on an effect that performs async work`);this.fiber=e,this.name=this._tag,this.stack=this.message}}var Y0=(e)=>{let t=Error.stackTraceLimit;Error.stackTraceLimit=0;let r=new mE(e);return Error.stackTraceLimit=t,r};var Sm=Symbol.for("effect/Runtime/FiberFailure"),Yl=Symbol.for("effect/Runtime/FiberFailure/Cause");class hE extends Error{[Sm];[Yl];constructor(e){let t=ys(e)[0];super(t?.message||"An error has occurred");if(this[Sm]=Sm,this[Yl]=e,this.name=t?`(FiberFailure) ${t.name}`:"FiberFailure",t?.stack)this.stack=t.stack}toJSON(){return{_id:"FiberFailure",cause:this[Yl].toJSON()}}toString(){return"(FiberFailure) "+er(this[Yl],{renderErrorCause:!0})}[J](){return this.toString()}}var Z0=(e)=>{let t=Error.stackTraceLimit;Error.stackTraceLimit=0;let r=new hE(e);return Error.stackTraceLimit=t,r};var Q0=(e)=>{let t=e;switch(t._op){case"Failure":case"Success":return t;case"Left":return Vs(t.left);case"Right":return ge(t.right);case"Some":return ge(t.value);case"None":return Vs(new Ws)}},X0=bm((e,t)=>{let r=Q0(t);if(r)return r;let n=new Qs,o=dE(e)(t,{scheduler:n});n.flush();let i=o.unsafePoll();if(i)return i;return md(Wc(Y0(o),cl(o)))});class gE{context;runtimeFlags;fiberRefs;constructor(e,t,r){this.context=e,this.runtimeFlags=t,this.fiberRefs=r}pipe(){return y(this,arguments)}}var eF=(e)=>new gE(e.context,e.runtimeFlags,e.fiberRefs);var tF=Uf(Kr,Lf,Mf),yE=eF({context:wn(),runtimeFlags:tF,fiberRefs:Kb()});var xE=dE(yE);var SE=G0(yE);var bE=di;var aa=sE;var ca=fe;var kt=ve;var _E=Ms;var Zl=we;var wE=bo;var Co=xo;var rr=L;var EE=xE;var OE=SE;var _m=(e,t)=>{switch(t._tag){case"StringKeyword":case"TemplateLiteral":return Object.keys(e);case"SymbolKeyword":return Object.getOwnPropertySymbols(e);case"Refinement":return _m(e,t.from)}},la=(e)=>{let t=!1,r;return()=>{if(t)return r;return r=e(),t=!0,r}},wm=(e)=>Array.isArray(e),kE=(e)=>!Array.isArray(e),TE=(e)=>`[${os(e)}]`,Ql=(e)=>wm(e)?e.map(TE).join(""):TE(e);var Dn=(e,t,r,n)=>{let o=e;if(r&&se(r))o+=`
|
|
34
|
+
at path: ${Ql(r)}`;if(t!==void 0)o+=`
|
|
35
|
+
details: ${t}`;if(n)o+=`
|
|
36
|
+
schema (${n._tag}): ${n}`;return o},AE=(e)=>Dn("Invalid Argument",e);var IE=(e)=>Dn("Unsupported key schema",void 0,void 0,e),RE=(e)=>Dn("Unsupported literal",`literal value: ${lr(e)}`),Em=(e)=>Dn("Duplicate index signature",`${e} index signature`),vE=Dn("Unsupported index signature parameter","An index signature parameter type must be `string`, `symbol`, a template literal type or a refinement of the previous types"),CE=Dn("Invalid element","A required element cannot follow an optional element. ts(1257)"),Om=(e)=>Dn("Duplicate property signature transformation",`Duplicate key ${lr(e)}`);var Tm=(e)=>Dn("Duplicate property signature",`Duplicate key ${lr(e)}`);var FE=Symbol.for("effect/SchemaId/DateFromSelf"),NE=Symbol.for("effect/SchemaId/GreaterThan"),ME=Symbol.for("effect/SchemaId/GreaterThanOrEqualTo");var LE=Symbol.for("effect/SchemaId/Int");var DE=Symbol.for("effect/SchemaId/MinLength");var qE=Symbol.for("effect/SchemaId/MinItems");var HE=Symbol.for("effect/annotation/TypeConstructor"),Im=Symbol.for("effect/annotation/Brand"),jE=Symbol.for("effect/annotation/SchemaId"),Rm=Symbol.for("effect/annotation/Message"),eu=Symbol.for("effect/annotation/MissingMessage"),tu=Symbol.for("effect/annotation/Identifier"),mt=Symbol.for("effect/annotation/Title"),ru=Symbol.for("effect/annotation/AutoTitle"),Zr=Symbol.for("effect/annotation/Description"),vm=Symbol.for("effect/annotation/Examples"),Cm=Symbol.for("effect/annotation/Default"),Pm=Symbol.for("effect/annotation/JSONSchema"),Fm=Symbol.for("effect/annotation/Arbitrary"),Nm=Symbol.for("effect/annotation/Pretty"),Mm=Symbol.for("effect/annotation/Equivalence"),$E=Symbol.for("effect/annotation/Documentation"),Lm=Symbol.for("effect/annotation/Concurrency"),Dm=Symbol.for("effect/annotation/Batching"),qm=Symbol.for("effect/annotation/ParseIssueTitle"),Um=Symbol.for("effect/annotation/ParseOptions"),Hm=Symbol.for("effect/annotation/DecodingFallback"),jm=Symbol.for("effect/annotation/Surrogate"),$m=Symbol.for("effect/annotation/StableFilter"),Ze=p(2,(e,t)=>Object.prototype.hasOwnProperty.call(e.annotations,t)?I(e.annotations[t]):w());var Bm=Ze(Im);var BE=Ze(Rm),KE=Ze(eu),Km=Ze(mt),Wm=Ze(ru),ua=Ze(tu),zm=Ze(Zr);var WE=Ze(Lm),zE=Ze(Dm),VE=Ze(qm),JE=Ze(Um),GE=Ze(Hm),Vm=Ze(jm),iF=Ze($m),Jm=(e)=>Qg(iF(e),(t)=>t===!0),Gm=Symbol.for("effect/annotation/JSONIdentifier"),sF=Ze(Gm),aF=(e)=>Wt(sF(e),()=>ua(e));class vi{typeParameters;decodeUnknown;encodeUnknown;annotations;_tag="Declaration";constructor(e,t,r,n={}){this.typeParameters=e,this.decodeUnknown=t,this.encodeUnknown=r,this.annotations=n}toString(){return ce(xr(this),()=>"<declaration schema>")}toJSON(){return{_tag:this._tag,typeParameters:this.typeParameters.map((e)=>e.toJSON()),annotations:be(this.annotations)}}}var pa=(e)=>(t)=>t._tag===e;class Po{literal;annotations;_tag="Literal";constructor(e,t={}){this.literal=e,this.annotations=t}toString(){return ce(xr(this),()=>lr(this.literal))}toJSON(){return{_tag:this._tag,literal:cn(this.literal)?String(this.literal):this.literal,annotations:be(this.annotations)}}}var nu=pa("Literal"),YE=new Po(null);class ou{symbol;annotations;_tag="UniqueSymbol";constructor(e,t={}){this.symbol=e,this.annotations=t}toString(){return ce(xr(this),()=>lr(this.symbol))}toJSON(){return{_tag:this._tag,symbol:String(this.symbol),annotations:be(this.annotations)}}}class ZE{annotations;_tag="UndefinedKeyword";constructor(e={}){this.annotations=e}toString(){return nr(this)}toJSON(){return{_tag:this._tag,annotations:be(this.annotations)}}}var iu=new ZE({[mt]:"undefined"});class QE{annotations;_tag="VoidKeyword";constructor(e={}){this.annotations=e}toString(){return nr(this)}toJSON(){return{_tag:this._tag,annotations:be(this.annotations)}}}var cF=new QE({[mt]:"void"});class XE{annotations;_tag="NeverKeyword";constructor(e={}){this.annotations=e}toString(){return nr(this)}toJSON(){return{_tag:this._tag,annotations:be(this.annotations)}}}var su=new XE({[mt]:"never"});class eO{annotations;_tag="UnknownKeyword";constructor(e={}){this.annotations=e}toString(){return nr(this)}toJSON(){return{_tag:this._tag,annotations:be(this.annotations)}}}var tO=new eO({[mt]:"unknown"});class rO{annotations;_tag="AnyKeyword";constructor(e={}){this.annotations=e}toString(){return nr(this)}toJSON(){return{_tag:this._tag,annotations:be(this.annotations)}}}var nO=new rO({[mt]:"any"});class oO{annotations;_tag="StringKeyword";constructor(e={}){this.annotations=e}toString(){return nr(this)}toJSON(){return{_tag:this._tag,annotations:be(this.annotations)}}}var iO=new oO({[mt]:"string",[Zr]:"a string"}),au=pa("StringKeyword");class sO{annotations;_tag="NumberKeyword";constructor(e={}){this.annotations=e}toString(){return nr(this)}toJSON(){return{_tag:this._tag,annotations:be(this.annotations)}}}var aO=new sO({[mt]:"number",[Zr]:"a number"});class cO{annotations;_tag="BooleanKeyword";constructor(e={}){this.annotations=e}toString(){return nr(this)}toJSON(){return{_tag:this._tag,annotations:be(this.annotations)}}}var lO=new cO({[mt]:"boolean",[Zr]:"a boolean"});class uO{annotations;_tag="BigIntKeyword";constructor(e={}){this.annotations=e}toString(){return nr(this)}toJSON(){return{_tag:this._tag,annotations:be(this.annotations)}}}var lF=new uO({[mt]:"bigint",[Zr]:"a bigint"});class pO{annotations;_tag="SymbolKeyword";constructor(e={}){this.annotations=e}toString(){return nr(this)}toJSON(){return{_tag:this._tag,annotations:be(this.annotations)}}}var uF=new pO({[mt]:"symbol",[Zr]:"a symbol"}),fO=pa("SymbolKeyword");class dO{annotations;_tag="ObjectKeyword";constructor(e={}){this.annotations=e}toString(){return nr(this)}toJSON(){return{_tag:this._tag,annotations:be(this.annotations)}}}var pF=new dO({[mt]:"object",[Zr]:"an object in the TypeScript meaning, i.e. the `object` type"});class Ci{type;annotations;constructor(e,t={}){this.type=e,this.annotations=t}toJSON(){return{type:this.type.toJSON(),annotations:be(this.annotations)}}toString(){return String(this.type)}}class qn extends Ci{isOptional;constructor(e,t,r={}){super(e,r);this.isOptional=t}toJSON(){return{type:this.type.toJSON(),isOptional:this.isOptional,annotations:be(this.annotations)}}toString(){return String(this.type)+(this.isOptional?"?":"")}}var mO=(e)=>e.map((t)=>t.type);class fa{elements;rest;isReadonly;annotations;_tag="TupleType";constructor(e,t,r,n={}){this.elements=e,this.rest=t,this.isReadonly=r,this.annotations=n;let o=!1,i=!1;for(let s of e)if(s.isOptional)o=!0;else if(o){i=!0;break}if(i||o&&t.length>1)throw Error(CE)}toString(){return ce(xr(this),()=>fF(this))}toJSON(){return{_tag:this._tag,elements:this.elements.map((e)=>e.toJSON()),rest:this.rest.map((e)=>e.toJSON()),isReadonly:this.isReadonly,annotations:be(this.annotations)}}}var fF=(e)=>{let t=e.elements.map(String).join(", ");return ey(e.rest,{onEmpty:()=>`readonly [${t}]`,onNonEmpty:(r,n)=>{let o=String(r),i=o.includes(" | ")?`(${o})`:o;if(n.length>0){let s=n.map(String).join(", ");if(e.elements.length>0)return`readonly [${t}, ...${i}[], ${s}]`;else return`readonly [...${i}[], ${s}]`}else if(e.elements.length>0)return`readonly [${t}, ...${i}[]]`;else return`ReadonlyArray<${o}>`}})};class Me extends qn{name;isReadonly;constructor(e,t,r,n,o){super(t,r,o);this.name=e,this.isReadonly=n}toString(){return(this.isReadonly?"readonly ":"")+String(this.name)+(this.isOptional?"?":"")+": "+this.type}toJSON(){return{name:String(this.name),type:this.type.toJSON(),isOptional:this.isOptional,isReadonly:this.isReadonly,annotations:be(this.annotations)}}}var hO=(e)=>{switch(e._tag){case"StringKeyword":case"SymbolKeyword":case"TemplateLiteral":return!0;case"Refinement":return hO(e.from)}return!1};class Pi{type;isReadonly;parameter;constructor(e,t,r){if(this.type=t,this.isReadonly=r,hO(e))this.parameter=e;else throw Error(vE)}toString(){return(this.isReadonly?"readonly ":"")+`[x: ${this.parameter}]: ${this.type}`}toJSON(){return{parameter:this.parameter.toJSON(),type:this.type.toJSON(),isReadonly:this.isReadonly}}}class Sr{annotations;_tag="TypeLiteral";propertySignatures;indexSignatures;constructor(e,t,r={}){this.annotations=r;let n={};for(let i=0;i<e.length;i++){let s=e[i].name;if(Object.prototype.hasOwnProperty.call(n,s))throw Error(Tm(s));n[s]=null}let o={string:!1,symbol:!1};for(let i=0;i<t.length;i++){let s=rh(t[i].parameter);if(au(s)){if(o.string)throw Error(Em("string"));o.string=!0}else if(fO(s)){if(o.symbol)throw Error(Em("symbol"));o.symbol=!0}}this.propertySignatures=e,this.indexSignatures=t}toString(){return ce(xr(this),()=>dF(this))}toJSON(){return{_tag:this._tag,propertySignatures:this.propertySignatures.map((e)=>e.toJSON()),indexSignatures:this.indexSignatures.map((e)=>e.toJSON()),annotations:be(this.annotations)}}}var UE=(e)=>e.map(String).join("; "),dF=(e)=>{if(e.propertySignatures.length>0){let t=e.propertySignatures.map(String).join("; ");if(e.indexSignatures.length>0)return`{ ${t}; ${UE(e.indexSignatures)} }`;else return`{ ${t} }`}else if(e.indexSignatures.length>0)return`{ ${UE(e.indexSignatures)} }`;else return"{}"};var mF=Nr(Xa(gr,(e)=>{switch(e._tag){case"AnyKeyword":return 0;case"UnknownKeyword":return 1;case"ObjectKeyword":return 2;case"StringKeyword":case"NumberKeyword":case"BooleanKeyword":case"BigIntKeyword":case"SymbolKeyword":return 3}return 4})),hF={string:"StringKeyword",number:"NumberKeyword",boolean:"BooleanKeyword",bigint:"BigIntKeyword"},gO=(e)=>ps(e,(t)=>Ym(t)?gO(t.types):[t]),gF=(e)=>{let t=mF(e),r=[],n={},o=[];for(let i of t)switch(i._tag){case"NeverKeyword":break;case"AnyKeyword":return[nO];case"UnknownKeyword":return[tO];case"ObjectKeyword":case"UndefinedKeyword":case"VoidKeyword":case"StringKeyword":case"NumberKeyword":case"BooleanKeyword":case"BigIntKeyword":case"SymbolKeyword":{if(!n[i._tag])n[i._tag]=i,r.push(i);break}case"Literal":{let s=typeof i.literal;switch(s){case"string":case"number":case"bigint":case"boolean":{let a=hF[s];if(!n[a]&&!o.includes(i.literal))o.push(i.literal),r.push(i);break}case"object":{if(!o.includes(i.literal))o.push(i.literal),r.push(i);break}}break}case"UniqueSymbol":{if(!n.SymbolKeyword&&!o.includes(i.symbol))o.push(i.symbol),r.push(i);break}case"TupleType":{if(!n.ObjectKeyword)r.push(i);break}case"TypeLiteral":{if(i.propertySignatures.length===0&&i.indexSignatures.length===0){if(!n["{}"])n["{}"]=i,r.push(i)}else if(!n.ObjectKeyword)r.push(i);break}default:r.push(i)}return r};class it{types;annotations;static make=(e,t)=>cu(e)?new it(e,t):e.length===1?e[0]:su;static unify=(e,t)=>it.make(gF(gO(e)),t);_tag="Union";constructor(e,t={}){this.types=e,this.annotations=t}toString(){return ce(xr(this),()=>this.types.map(String).join(" | "))}toJSON(){return{_tag:this._tag,types:this.types.map((e)=>e.toJSON()),annotations:be(this.annotations)}}}var yO=(e,t)=>e.map(t),cu=(e)=>e.length>1,Ym=pa("Union"),km=N(Symbol.for("effect/Schema/AST/toJSONMemoMap"),()=>new WeakMap);class lu{f;annotations;_tag="Suspend";constructor(e,t={}){this.f=e,this.annotations=t,this.f=la(e)}toString(){return xr(this).pipe(Wt(()=>Vt(Gg(this.f)(),(e)=>xr(e))),ce(()=>"<suspended schema>"))}toJSON(){let e=this.f(),t=km.get(e);if(t)return t;return km.set(e,{_tag:this._tag}),t={_tag:this._tag,ast:e.toJSON(),annotations:be(this.annotations)},km.set(e,t),t}}class da{from;filter;annotations;_tag="Refinement";constructor(e,t,r={}){this.from=e,this.filter=t,this.annotations=r}toString(){return ua(this).pipe(ce(()=>Ee(_O(this),{onNone:()=>`{ ${this.from} | filter }`,onSome:(e)=>ma(this.from)?String(this.from)+" & "+e:e})))}toJSON(){return{_tag:this._tag,from:this.from.toJSON(),annotations:be(this.annotations)}}}var ma=pa("Refinement"),uu={};class Zm{from;to;transformation;annotations;_tag="Transformation";constructor(e,t,r,n={}){this.from=e,this.to=t,this.transformation=r,this.annotations=n}toString(){return ce(xr(this),()=>`(${String(this.from)} <-> ${String(this.to)})`)}toJSON(){return{_tag:this._tag,from:this.from.toJSON(),to:this.to.toJSON(),annotations:be(this.annotations)}}}class Qm{from;to;decode;encode;constructor(e,t,r,n){this.from=e,this.to=t,this.decode=r,this.encode=n}}class Xm{propertySignatureTransformations;_tag="TypeLiteralTransformation";constructor(e){this.propertySignatureTransformations=e;let t={},r={};for(let n of e){let o=n.from;if(t[o])throw Error(Om(o));t[o]=!0;let i=n.to;if(r[i])throw Error(Om(i));r[i]=!0}}}var ha=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),n={...e.annotations};delete n[tu];let o={...n,...t},i=Vm(e);if(ue(i))o[jm]=ha(i.value,t);return r.annotations.value=o,Object.create(Object.getPrototypeOf(e),r)};var yF="[\\s\\S]*?",xF="[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?",xO=(e,t)=>{switch(e._tag){case"Literal":return bi(String(e.literal));case"StringKeyword":return yF;case"NumberKeyword":return xF;case"TemplateLiteral":return SO(e,t,!1);case"Union":return e.types.map((r)=>xO(r,t)).join("|")}},SF=(e,t,r,n)=>{if(Ym(e)){if(r&&!n)return`(?:${t})`}else if(!r||!n)return t;return`(${t})`},SO=(e,t,r)=>{let n="";if(e.head!==""){let o=bi(e.head);n+=t&&r?`(${o})`:o}for(let o of e.spans){let i=xO(o.type,t);if(n+=SF(o.type,i,t,r),o.literal!==""){let s=bi(o.literal);n+=t&&r?`(${s})`:s}}return n},bO=(e)=>new RegExp(`^${SO(e,!1,!0)}$`);var eh=(e,t)=>{let r=[],n=[],o=(i)=>{switch(i._tag){case"NeverKeyword":break;case"StringKeyword":case"SymbolKeyword":case"TemplateLiteral":case"Refinement":n.push(new Pi(i,t,!0));break;case"Literal":if(Be(i.literal)||_t(i.literal))r.push(new Me(i.literal,t,!1,!0));else throw Error(RE(i.literal));break;case"Enums":{for(let[s,a]of i.enums)r.push(new Me(a,t,!1,!0));break}case"UniqueSymbol":r.push(new Me(i.symbol,t,!1,!0));break;case"Union":i.types.forEach(o);break;default:throw Error(IE(i))}};return o(e),{propertySignatures:r,indexSignatures:n}};var th=(e)=>(t)=>{let r=void 0;for(let n of e)if(Object.prototype.hasOwnProperty.call(t.annotations,n)){if(r===void 0)r={};r[n]=t.annotations[n]}return r};var bF=th([vm,Cm,Pm,Fm,Nm,Mm]),Ne=(e)=>{switch(e._tag){case"Declaration":{let t=Ht(e.typeParameters,Ne);return t===e.typeParameters?e:new vi(t,e.decodeUnknown,e.encodeUnknown,e.annotations)}case"TupleType":{let t=Ht(e.elements,(o)=>{let i=Ne(o.type);return i===o.type?o:new qn(i,o.isOptional)}),r=mO(e.rest),n=Ht(r,Ne);return t===e.elements&&n===r?e:new fa(t,n.map((o)=>new Ci(o)),e.isReadonly,e.annotations)}case"TypeLiteral":{let t=Ht(e.propertySignatures,(n)=>{let o=Ne(n.type);return o===n.type?n:new Me(n.name,o,n.isOptional,n.isReadonly)}),r=Ht(e.indexSignatures,(n)=>{let o=Ne(n.type);return o===n.type?n:new Pi(n.parameter,o,n.isReadonly)});return t===e.propertySignatures&&r===e.indexSignatures?e:new Sr(t,r,e.annotations)}case"Union":{let t=Ht(e.types,Ne);return t===e.types?e:it.make(t,e.annotations)}case"Suspend":return new lu(()=>Ne(e.f()),e.annotations);case"Refinement":{let t=Ne(e.from);return t===e.from?e:new da(t,e.filter,e.annotations)}case"Transformation":{let t=bF(e);return Ne(t!==void 0?ha(e.to,t):e.to)}}return e};function Ht(e,t){let r=!1,n=no(e.length);for(let o=0;o<e.length;o++){let i=e[o],s=t(i);if(s!==i)r=!0;n[o]=s}return r?n:e}var Am=(e)=>{switch(e._tag){case"Transformation":return e.from;case"Refinement":return Am(e.from);case"Suspend":return Am(e.f())}},yr=(e,t)=>{switch(e._tag){case"Declaration":{let r=Ht(e.typeParameters,(n)=>yr(n,t));return r===e.typeParameters?e:new vi(r,e.decodeUnknown,e.encodeUnknown)}case"TupleType":{let r=Ht(e.elements,(i)=>{let s=yr(i.type,t);return s===i.type?i:new qn(s,i.isOptional)}),n=mO(e.rest),o=Ht(n,(i)=>yr(i,t));return r===e.elements&&o===n?e:new fa(r,o.map((i)=>new Ci(i)),e.isReadonly)}case"TypeLiteral":{let r=Ht(e.propertySignatures,(o)=>{let i=yr(o.type,t);return i===o.type?o:new Me(o.name,i,o.isOptional,o.isReadonly)}),n=Ht(e.indexSignatures,(o)=>{let i=yr(o.type,t);return i===o.type?o:new Pi(o.parameter,i,o.isReadonly)});return r===e.propertySignatures&&n===e.indexSignatures?e:new Sr(r,n)}case"Union":{let r=Ht(e.types,(n)=>yr(n,t));return r===e.types?e:it.make(r)}case"Suspend":{let r=void 0,n=aF(e);if(ue(n)){let o=t?"Bound":"";r={[Gm]:`${n.value}Encoded${o}`}}return new lu(()=>yr(e.f(),t),r)}case"Refinement":{let r=yr(e.from,t);if(t){if(r===e.from)return e;if(Am(e.from)===void 0&&Jm(e))return new da(r,e.filter,e.annotations);return r}else return r}case"Transformation":return yr(e.from,t)}return e},pu=(e)=>yr(e,!1);var be=(e)=>{let t={};for(let r of Object.getOwnPropertySymbols(e))t[String(r)]=e[r];return t},rh=(e)=>{switch(e._tag){case"StringKeyword":case"SymbolKeyword":case"TemplateLiteral":return e;case"Refinement":return rh(e.from)}};var nr=(e)=>ce(xr(e),()=>e._tag);function _F(e){return Ee(Bm(e),{onNone:()=>"",onSome:(t)=>t.map((r)=>` & Brand<${lr(r)}>`).join("")})}var _O=(e)=>Km(e).pipe(Wt(()=>zm(e)),Wt(()=>Wm(e)),zt((t)=>t+_F(e))),xr=(e)=>Wt(ua(e),()=>_O(e));class Le{path;actual;issue;_tag="Pointer";constructor(e,t,r){this.path=e,this.actual=t,this.issue=r}}class ih{actual;message;_tag="Unexpected";constructor(e,t){this.actual=e,this.message=t}}class Fi{ast;message;_tag="Missing";actual=void 0;constructor(e,t){this.ast=e,this.message=t}}class _e{ast;actual;issues;output;_tag="Composite";constructor(e,t,r,n){this.ast=e,this.actual=t,this.issues=r,this.output=n}}class du{ast;actual;kind;issue;_tag="Refinement";constructor(e,t,r,n){this.ast=e,this.actual=t,this.kind=r,this.issue=n}}class mu{ast;actual;kind;issue;_tag="Transformation";constructor(e,t,r,n){this.ast=e,this.actual=t,this.kind=r,this.issue=n}}class jt{ast;actual;message;_tag="Type";constructor(e,t,r){this.ast=e,this.actual=t,this.message=r}}class sh{ast;actual;message;_tag="Forbidden";constructor(e,t,r){this.ast=e,this.actual=t,this.message=r}}var EO=Symbol.for("effect/Schema/ParseErrorTypeId");class kO extends Cb("ParseError"){[EO]=EO;get message(){return this.toString()}toString(){return xa.formatIssueSync(this.issue)}toJSON(){return{_id:"ParseError",message:this.toString()}}[J](){return this.toJSON()}}var ch=(e)=>new kO({issue:e}),AO=B,IO=U;var gt=xp,Qr=p(2,(e,t)=>gt(e)?us(e,{onLeft:U,onRight:t}):rr(e,t)),ir=p(2,(e,t)=>gt(e)?Bg(e,t):Zl(e,t)),hu=p(2,(e,t)=>gt(e)?Qa(e,t):wE(e,t));var RO=p(2,(e,t)=>gt(e)?us(e,{onLeft:t,onRight:B}):_E(e,t)),vO=(e,t)=>{if(t===void 0||_t(t))return e;if(e===void 0)return t;return{...e,...t}},CO=(e,t,r)=>{let n=Qe(e,t);return(o,i)=>n(o,vO(r,i))},wF=(e,t,r)=>{let n=CO(e,t,r);return(o,i)=>Sp(n(o,i),ch)};var PO=(e,t)=>CO(e.ast,!0,t);var gu=(e,t)=>wF(Ne(e.ast),!0,t);var EF=N(Symbol.for("effect/ParseResult/decodeMemoMap"),()=>new WeakMap),OF=N(Symbol.for("effect/ParseResult/encodeMemoMap"),()=>new WeakMap),Qe=(e,t)=>{let r=t?EF:OF,n=r.get(e);if(n)return n;let o=TF(e,t),i=JE(e),s=ue(i)?(l,u)=>o(l,vO(u,i.value)):o,a=GE(e),c=t&&ue(a)?(l,u)=>ya(RO(s(l,u),a.value),e,l,u):s;return r.set(e,c),c},nh=(e)=>ft(WE(e)),oh=(e)=>ft(zE(e)),TF=(e,t)=>{switch(e._tag){case"Refinement":if(t){let r=Qe(e.from,!0);return(n,o)=>{o=o??uu;let i=o?.errors==="all",s=Qr(RO(r(n,o),(a)=>{let c=new du(e,n,"From",a);if(i&&Jm(e)&&DO(a))return Ee(e.filter(n,o,e),{onNone:()=>U(c),onSome:(l)=>U(new _e(e,n,[c,new du(e,n,"Predicate",l)]))});return U(c)}),(a)=>Ee(e.filter(a,o,e),{onNone:()=>B(a),onSome:(c)=>U(new du(e,n,"Predicate",c))}));return ya(s,e,n,o)}}else{let r=Qe(Ne(e),!0),n=Qe(NO(e.from),!1);return(o,i)=>ya(Qr(r(o,i),(s)=>n(s,i)),e,o,i)}case"Transformation":{let r=AF(e.transformation,t),n=t?Qe(e.from,!0):Qe(e.to,!1),o=t?Qe(e.to,!0):Qe(e.from,!1);return(i,s)=>ya(Qr(hu(n(i,s),(a)=>new mu(e,i,t?"Encoded":"Type",a)),(a)=>Qr(hu(r(a,s??uu,e,i),(c)=>new mu(e,i,"Transformation",c)),(c)=>hu(o(c,s),(l)=>new mu(e,i,t?"Type":"Encoded",l)))),e,i,s)}case"Declaration":{let r=t?e.decodeUnknown(...e.typeParameters):e.encodeUnknown(...e.typeParameters);return(n,o)=>ya(r(n,o??uu,e),e,n,o)}case"Literal":return ht(e,(r)=>r===e.literal);case"UniqueSymbol":return ht(e,(r)=>r===e.symbol);case"UndefinedKeyword":return ht(e,bg);case"NeverKeyword":return ht(e,_g);case"UnknownKeyword":case"AnyKeyword":case"VoidKeyword":return B;case"StringKeyword":return ht(e,Be);case"NumberKeyword":return ht(e,_t);case"BooleanKeyword":return ht(e,Jn);case"BigIntKeyword":return ht(e,cn);case"SymbolKeyword":return ht(e,Gn);case"ObjectKeyword":return ht(e,ot);case"Enums":return ht(e,(r)=>e.enums.some(([n,o])=>o===r));case"TemplateLiteral":{if(e.spans.every((n)=>au(n.type)))return ht(e,(n)=>{if(!Be(n)||!n.startsWith(e.head))return!1;let o=e.head.length;for(let s=0;s<e.spans.length-1;s++){let a=e.spans[s].literal,c=n.indexOf(a,o);if(c===-1)return!1;o=c+a.length}let i=e.spans[e.spans.length-1].literal;return n.endsWith(i)&&n.length-i.length>=o});let r=bO(e);return ht(e,(n)=>Be(n)&&r.test(n))}case"TupleType":{let r=e.elements.map((l)=>Qe(l.type,t)),n=e.rest.map((l)=>Qe(l.type,t)),o=e.elements.filter((l)=>!l.isOptional);if(e.rest.length>0)o=o.concat(e.rest.slice(1));let i=o.length,s=e.elements.length>0?e.elements.map((l,u)=>u).join(" | "):"never",a=nh(e),c=oh(e);return(l,u)=>{if(!kp(l))return U(new jt(e,l));let f=u?.errors==="all",d=[],h=0,g=[],P=l.length;for(let F=P;F<=i-1;F++){let D=new Le(F,l,new Fi(o[F-P]));if(f){d.push([h++,D]);continue}else return U(new _e(e,l,D,g))}if(e.rest.length===0)for(let F=e.elements.length;F<=P-1;F++){let D=new Le(F,l,new ih(l[F],`is unexpected, expected: ${s}`));if(f){d.push([h++,D]);continue}else return U(new _e(e,l,D,g))}let x=0,E=void 0;for(;x<r.length;x++)if(P<x+1){if(e.elements[x].isOptional)continue}else{let F=r[x],D=F(l[x],u);if(gt(D)){if(he(D)){let T=new Le(x,l,D.left);if(f){d.push([h++,T]);continue}else return U(new _e(e,l,T,or(g)))}g.push([h++,D.right])}else{let T=h++,A=x;if(!E)E=[];E.push(({es:R,output:v})=>rr(Co(D),(te)=>{if(he(te)){let re=new Le(A,l,te.left);if(f)return R.push([T,re]),kt;else return U(new _e(e,l,re,or(v)))}return v.push([T,te.right]),kt}))}}if(se(n)){let[F,...D]=n;for(;x<P-D.length;x++){let T=F(l[x],u);if(gt(T))if(he(T)){let A=new Le(x,l,T.left);if(f){d.push([h++,A]);continue}else return U(new _e(e,l,A,or(g)))}else g.push([h++,T.right]);else{let A=h++,R=x;if(!E)E=[];E.push(({es:v,output:te})=>rr(Co(T),(re)=>{if(he(re)){let Y=new Le(R,l,re.left);if(f)return v.push([A,Y]),kt;else return U(new _e(e,l,Y,or(te)))}else return te.push([A,re.right]),kt}))}}for(let T=0;T<D.length;T++){let A=x+T;if(P<A+1)continue;else{let R=D[T](l[A],u);if(gt(R)){if(he(R)){let v=new Le(A,l,R.left);if(f){d.push([h++,v]);continue}else return U(new _e(e,l,v,or(g)))}g.push([h++,R.right])}else{let v=h++;if(!E)E=[];E.push(({es:te,output:re})=>rr(Co(R),(Y)=>{if(he(Y)){let xe=new Le(A,l,Y.left);if(f)return te.push([v,xe]),kt;else return U(new _e(e,l,xe,or(re)))}return re.push([v,Y.right]),kt}))}}}}let W=({es:F,output:D})=>fn(F)?U(new _e(e,l,or(F),or(D))):B(or(D));if(E&&E.length>0){let F=E;return ca(()=>{let D={es:Go(d),output:Go(g)};return rr(aa(F,(T)=>T(D),{concurrency:a,batching:c,discard:!0}),()=>W(D))})}return W({output:g,es:d})}}case"TypeLiteral":{if(e.propertySignatures.length===0&&e.indexSignatures.length===0)return ht(e,wg);let r=[],n={},o=[];for(let u of e.propertySignatures)r.push([Qe(u.type,t),u]),n[u.name]=null,o.push(u.name);let i=e.indexSignatures.map((u)=>[Qe(u.parameter,t),Qe(u.type,t),u.parameter]),s=it.make(e.indexSignatures.map((u)=>u.parameter).concat(o.map((u)=>Gn(u)?new ou(u):new Po(u)))),a=Qe(s,t),c=nh(e),l=oh(e);return(u,f)=>{if(!np(u))return U(new jt(e,u));let d=f?.errors==="all",h=[],g=0,P=f?.onExcessProperty==="error",x=f?.onExcessProperty==="preserve",E={},W;if(P||x){W=Reflect.ownKeys(u);for(let A of W){let R=a(A,f);if(gt(R)&&he(R))if(P){let v=new Le(A,u,new ih(u[A],`is unexpected, expected: ${String(s)}`));if(d){h.push([g++,v]);continue}else return U(new _e(e,u,v,E))}else E[A]=u[A]}}let F=void 0,D=f?.exact===!0;for(let A=0;A<r.length;A++){let R=r[A][1],v=R.name,te=Object.prototype.hasOwnProperty.call(u,v);if(!te){if(R.isOptional)continue;else if(D){let xe=new Le(v,u,new Fi(R));if(d){h.push([g++,xe]);continue}else return U(new _e(e,u,xe,E))}}let re=r[A][0],Y=re(u[v],f);if(gt(Y)){if(he(Y)){let xe=new Le(v,u,te?Y.left:new Fi(R));if(d){h.push([g++,xe]);continue}else return U(new _e(e,u,xe,E))}E[v]=Y.right}else{let xe=g++,Rt=v;if(!F)F=[];F.push(({es:vt,output:Bt})=>rr(Co(Y),(je)=>{if(he(je)){let $e=new Le(Rt,u,te?je.left:new Fi(R));if(d)return vt.push([xe,$e]),kt;else return U(new _e(e,u,$e,Bt))}return Bt[Rt]=je.right,kt}))}}for(let A=0;A<i.length;A++){let R=i[A],v=R[0],te=R[1],re=_m(u,R[2]);for(let Y of re){let xe=v(Y,f);if(gt(xe)&&pt(xe)){let Rt=te(u[Y],f);if(gt(Rt)){if(he(Rt)){let vt=new Le(Y,u,Rt.left);if(d){h.push([g++,vt]);continue}else return U(new _e(e,u,vt,E))}else if(!Object.prototype.hasOwnProperty.call(n,Y))E[Y]=Rt.right}else{let vt=g++,Bt=Y;if(!F)F=[];F.push(({es:je,output:$e})=>rr(Co(Rt),(Ct)=>{if(he(Ct)){let qo=new Le(Bt,u,Ct.left);if(d)return je.push([vt,qo]),kt;else return U(new _e(e,u,qo,$e))}else{if(!Object.prototype.hasOwnProperty.call(n,Y))$e[Y]=Ct.right;return kt}}))}}}}let T=({es:A,output:R})=>{if(fn(A))return U(new _e(e,u,or(A),R));if(f?.propertyOrder==="original"){let v=W||Reflect.ownKeys(u);for(let re of o)if(v.indexOf(re)===-1)v.push(re);let te={};for(let re of v)if(Object.prototype.hasOwnProperty.call(R,re))te[re]=R[re];return B(te)}return B(R)};if(F&&F.length>0){let A=F;return ca(()=>{let R={es:Go(h),output:Object.assign({},E)};return rr(aa(A,(v)=>v(R),{concurrency:c,batching:l,discard:!0}),()=>T(R))})}return T({es:h,output:E})}}case"Union":{let r=FO(e.types,t),n=Reflect.ownKeys(r.keys),o=n.length,i=e.types.length,s=new Map;for(let l=0;l<i;l++)s.set(e.types[l],Qe(e.types[l],t));let a=nh(e)??1,c=oh(e);return(l,u)=>{let f=[],d=0,h=[];if(o>0)if(Xi(l))for(let x=0;x<o;x++){let E=n[x],W=r.keys[E].buckets;if(Object.prototype.hasOwnProperty.call(l,E)){let F=String(l[E]);if(Object.prototype.hasOwnProperty.call(W,F))h=h.concat(W[F]);else{let{candidates:D,literals:T}=r.keys[E],A=it.make(T),R=D.length===i?new Sr([new Me(E,A,!1,!0)],[]):it.make(D);f.push([d++,new _e(R,l,new Le(E,l,new jt(A,l[E])))])}}else{let{candidates:F,literals:D}=r.keys[E],T=new Me(E,it.make(D),!1,!0),A=F.length===i?new Sr([T],[]):it.make(F);f.push([d++,new _e(A,l,new Le(E,l,new Fi(T)))])}}else{let x=r.candidates.length===i?e:it.make(r.candidates);f.push([d++,new jt(x,l)])}if(r.otherwise.length>0)h=h.concat(r.otherwise);let g=void 0;for(let x=0;x<h.length;x++){let E=h[x],W=s.get(E)(l,u);if(gt(W)&&(!g||g.length===0))if(pt(W))return W;else f.push([d++,W.left]);else{let F=d++;if(!g)g=[];g.push((D)=>ca(()=>{if("finalResult"in D)return kt;else return rr(Co(W),(T)=>{if(pt(T))D.finalResult=T;else D.es.push([F,T.left]);return kt})}))}}let P=(x)=>fn(x)?x.length===1&&x[0][1]._tag==="Type"?U(x[0][1]):U(new _e(e,l,or(x))):U(new jt(e,l));if(g&&g.length>0){let x=g;return ca(()=>{let E={es:Go(f)};return rr(aa(x,(W)=>W(E),{concurrency:a,batching:c,discard:!0}),()=>{if("finalResult"in E)return E.finalResult;return P(E.es)})})}return P(f)}}case"Suspend":{let r=la(()=>Qe(e.f(),t));return(n,o)=>r()(n,o)}}},ht=(e,t)=>(r)=>t(r)?B(r):U(new jt(e,r)),ga=(e,t)=>{switch(e._tag){case"Declaration":{let r=Vm(e);if(ue(r))return ga(r.value,t);break}case"TypeLiteral":{let r=[];for(let n=0;n<e.propertySignatures.length;n++){let o=e.propertySignatures[n],i=t?pu(o.type):Ne(o.type);if(nu(i)&&!o.isOptional)r.push([o.name,i])}return r}case"TupleType":{let r=[];for(let n=0;n<e.elements.length;n++){let o=e.elements[n],i=t?pu(o.type):Ne(o.type);if(nu(i)&&!o.isOptional)r.push([n,i])}return r}case"Refinement":return ga(e.from,t);case"Suspend":return ga(e.f(),t);case"Transformation":return ga(t?e.from:e.to,t)}return[]},FO=(e,t)=>{let r={},n=[],o=[];for(let i=0;i<e.length;i++){let s=e[i],a=ga(s,t);if(a.length>0){o.push(s);for(let c=0;c<a.length;c++){let[l,u]=a[c],f=String(u.literal);r[l]=r[l]||{buckets:{},literals:[],candidates:[]};let d=r[l].buckets;if(Object.prototype.hasOwnProperty.call(d,f)){if(c<a.length-1)continue;d[f].push(s),r[l].literals.push(u),r[l].candidates.push(s)}else{d[f]=[s],r[l].literals.push(u),r[l].candidates.push(s);break}}}else n.push(s)}return{keys:r,otherwise:n,candidates:o}},NO=(e)=>ma(e)?NO(e.from):e,ya=(e,t,r,n)=>{if(n?.isEffectAllowed===!0)return e;if(gt(e))return e;let o=new Qs,i=EE(e,{scheduler:o});o.flush();let s=i.unsafePoll();if(s){if(D_(s))return B(s.value);let a=s.cause;if(WS(a))return U(a.error);return U(new sh(t,r,zS(a)))}return U(new sh(t,r,"cannot be be resolved synchronously, this is caused by using runSync on an effect that performs async work"))},kF=([e],[t])=>e>t?1:e<t?-1:0;function or(e){return e.sort(kF).map((t)=>t[1])}var AF=(e,t)=>{switch(e._tag){case"FinalTransformation":return t?e.decode:e.encode;case"ComposeTransformation":return B;case"TypeLiteralTransformation":return(r)=>{let n=B(r);for(let o of e.propertySignatureTransformations){let[i,s]=t?[o.from,o.to]:[o.to,o.from],a=t?o.decode:o.encode;n=ir(n,(l)=>{let u=a(Object.prototype.hasOwnProperty.call(l,i)?I(l[i]):w());if(delete l[i],ue(u))l[s]=u.value;return l})}return n}}},st=(e,t=[])=>({value:e,forest:t}),xa={formatIssue:(e)=>ir(Ni(e),IF),formatIssueSync:(e)=>{let t=xa.formatIssue(e);return gt(t)?Wg(t):OE(t)},formatError:(e)=>xa.formatIssue(e.issue),formatErrorSync:(e)=>xa.formatIssueSync(e.issue)},IF=(e)=>e.value+MO(`
|
|
37
|
+
`,e.forest),MO=(e,t)=>{let r="",n=t.length,o;for(let i=0;i<n;i++){o=t[i];let s=i===n-1;r+=e+(s?"\u2514":"\u251C")+"\u2500 "+o.value,r+=MO(e+(n>1&&!s?"\u2502 ":" "),o.forest)}return r},RF=(e)=>{switch(e){case"Encoded":return"Encoded side transformation failure";case"Transformation":return"Transformation process failure";case"Type":return"Type side transformation failure"}},vF=(e)=>{switch(e){case"From":return"From side refinement failure";case"Predicate":return"Predicate refinement failure"}},LO=(e)=>("ast"in e)?I(e.ast):w(),ah=B(void 0),CF=(e)=>LO(e).pipe(Vt(BE),Ee({onNone:()=>ah,onSome:(t)=>{let r=t(e);if(Be(r))return B({message:r,override:!1});if(bE(r))return Zl(r,(n)=>({message:n,override:!1}));if(Be(r.message))return B({message:r.message,override:r.override});return Zl(r.message,(n)=>({message:n,override:r.override}))}})),lh=(e)=>(t)=>t._tag===e,DO=lh("Composite"),OO=lh("Refinement"),TO=lh("Transformation"),Sa=(e)=>Qr(CF(e),(t)=>{if(t!==void 0)return!t.override&&(DO(e)||OO(e)&&e.kind==="From"||TO(e)&&e.kind!=="Transformation")?TO(e)||OO(e)?Sa(e.issue):ah:B(t.message);return ah}),qO=(e)=>LO(e).pipe(Vt(VE),Yg((t)=>t(e)),ft);function PF(e){return zm(e).pipe(Wt(()=>Km(e)),Wt(()=>Wm(e)),Wt(()=>ua(e)),ce(()=>`{ ${e.from} | filter }`))}function FF(e){if(e.message!==void 0)return e.message;return`Expected ${ma(e.ast)?PF(e.ast):String(e.ast)}, actual ${lr(e.actual)}`}var NF=(e)=>ir(Sa(e),(t)=>t??qO(e)??FF(e)),fu=(e)=>qO(e)??String(e.ast),MF=(e)=>e.message??"is forbidden",LF=(e)=>e.message??"is unexpected",DF=(e)=>{let t=KE(e.ast);if(ue(t)){let r=t.value();return Be(r)?B(r):r}return B(e.message??"is missing")},Ni=(e)=>{switch(e._tag){case"Type":return ir(NF(e),st);case"Forbidden":return B(st(fu(e),[st(MF(e))]));case"Unexpected":return B(st(LF(e)));case"Missing":return ir(DF(e),st);case"Transformation":return Qr(Sa(e),(t)=>{if(t!==void 0)return B(st(t));return ir(Ni(e.issue),(r)=>st(fu(e),[st(RF(e.kind),[r])]))});case"Refinement":return Qr(Sa(e),(t)=>{if(t!==void 0)return B(st(t));return ir(Ni(e.issue),(r)=>st(fu(e),[st(vF(e.kind),[r])]))});case"Pointer":return ir(Ni(e.issue),(t)=>st(Ql(e.path),[t]));case"Composite":return Qr(Sa(e),(t)=>{if(t!==void 0)return B(st(t));let r=fu(e);return wm(e.issues)?ir(aa(e.issues,Ni),(n)=>st(r,n)):ir(Ni(e.issues),(n)=>st(r,[n]))})}};var UO=p((e)=>ot(e[0]),(e,...t)=>{let r={};for(let n of t)if(n in e)r[n]=e[n];return r}),HO=p((e)=>ot(e[0]),(e,...t)=>{let r={...e};for(let n of t)delete r[n];return r});var ba=Symbol.for("effect/Schema");function Xe(e){return class{[ba]=jO;static ast=e;static annotations(r){return Xe(Xr(this.ast,r))}static pipe(){return y(this,arguments)}static toString(){return String(e)}static Type;static Encoded;static Context;static[ba]=jO}}var jO={_A:(e)=>e,_I:(e)=>e,_R:(e)=>e};var $O={typeConstructor:HE,schemaId:jE,message:Rm,missingMessage:eu,identifier:tu,title:mt,description:Zr,examples:vm,default:Cm,documentation:$E,jsonSchema:Pm,arbitrary:Fm,pretty:Nm,equivalence:Mm,concurrency:Lm,batching:Dm,parseIssueTitle:qm,parseOptions:Um,decodingFallback:Hm},Fo=(e)=>{if(!e)return{};let t={...e};for(let r in $O)if(r in e){let n=$O[r];t[n]=e[r],delete t[r]}return t},Xr=(e,t)=>ha(e,Fo(t));var yu=(e,t)=>{let r=PO(e,t);return(n,o)=>Qa(r(n,o),ch)};var BO=(e)=>_(e,ba)&&ot(e[ba]);function HF(e){return cu(e)?it.make(yO(e,(t)=>new Po(t))):new Po(e[0])}function JO(e,t=HF(e)){return class extends Xe(t){static annotations(n){return JO(this.literals,Xr(this.ast,n))}static literals=[...e]}}function q(...e){return se(e)?JO(e):fh}var jF=(e,t,r)=>ph(e,new vi(e.map((n)=>n.ast),(...n)=>t.decode(...n.map(Xe)),(...n)=>t.encode(...n.map(Xe)),Fo(r))),$F=(e,t)=>{let r=()=>(o,i,s)=>e(o)?AO(o):IO(new jt(s,o));return ph([],new vi([],r,r,Fo(t)))};function ph(e,t){return class extends Xe(t){static annotations(n){return ph(this.typeParameters,Xr(this.ast,n))}static typeParameters=[...e]}}var At=function(){if(Array.isArray(arguments[0])){let r=arguments[0],n=arguments[1],o=arguments[2];return jF(r,n,o)}let e=arguments[0],t=arguments[1];return $F(e,t)};class GO extends Xe(iu){}class en extends Xe(YE){}class fh extends Xe(su){}class le extends Xe(iO){}class xu extends Xe(aO){}class de extends Xe(lO){}var BF=(e)=>it.make(e.map((t)=>t.ast));function YO(e,t=BF(e)){return class extends Xe(t){static annotations(n){return YO(this.members,Xr(this.ast,n))}static members=[...e]}}function yt(...e){return cu(e)?YO(e):se(e)?e[0]:fh}var KF=(e)=>yt(e,GO);var WF=(e,t)=>new fa(e.map((r)=>BO(r)?new qn(r.ast,!1):r.ast),t.map((r)=>BO(r)?new Ci(r.ast):r.ast),!0);function ZO(e,t,r=WF(e,t)){return class extends Xe(r){static annotations(o){return ZO(this.elements,this.rest,Xr(this.ast,o))}static elements=[...e];static rest=[...t]}}function QO(e,t){return class extends ZO([],[e],t){static annotations(n){return QO(this.value,Xr(this.ast,n))}static value=e}}var V=(e)=>QO(e);var uh=(e)=>e?'"?:"':'":"';class dh extends qn{isReadonly;defaultValue;_tag="PropertySignatureDeclaration";constructor(e,t,r,n,o){super(e,t,n);this.isReadonly=r,this.defaultValue=o}toString(){let e=uh(this.isOptional),t=String(this.type);return`PropertySignature<${e}, ${t}, never, ${e}, ${t}>`}}class XO extends qn{isReadonly;defaultValue;constructor(e,t,r,n,o){super(e,t,n);this.isReadonly=r,this.defaultValue=o}}var zF=(e)=>{if(e===void 0)return"never";if(Be(e))return JSON.stringify(e);return String(e)};class eT{from;to;decode;encode;_tag="PropertySignatureTransformation";constructor(e,t,r,n){this.from=e,this.to=t,this.decode=r,this.encode=n}toString(){return`PropertySignature<${uh(this.to.isOptional)}, ${this.to.type}, ${zF(this.from.fromKey)}, ${uh(this.from.isOptional)}, ${this.from.type}>`}}var tT=(e,t)=>{switch(e._tag){case"PropertySignatureDeclaration":return new dh(e.type,e.isOptional,e.isReadonly,{...e.annotations,...t},e.defaultValue);case"PropertySignatureTransformation":return new eT(e.from,new XO(e.to.type,e.to.isOptional,e.to.isReadonly,{...e.to.annotations,...t},e.to.defaultValue),e.decode,e.encode)}},rT=Symbol.for("effect/PropertySignature"),nT=(e)=>_(e,rT);class mh{ast;[ba];[rT]=null;_TypeToken;_Key;_EncodedToken;_HasDefault;constructor(e){this.ast=e}pipe(){return y(this,arguments)}annotations(e){return new mh(tT(this.ast,Fo(e)))}toString(){return String(this.ast)}}class hh extends mh{from;constructor(e,t){super(e);this.from=t}annotations(e){return new hh(tT(this.ast,Fo(e)),this.from)}}var G=(e)=>{let t=e.ast===iu||e.ast===su?iu:KF(e).ast;return new hh(new dh(t,!0,!0,{},void 0),e)};var VF=th([eu]),JF=(e,t)=>{let r=Reflect.ownKeys(e),n=[];if(r.length>0){let i=[],s=[],a=[];for(let c=0;c<r.length;c++){let l=r[c],u=e[l];if(nT(u)){let f=u.ast;switch(f._tag){case"PropertySignatureDeclaration":{let{type:d,isOptional:h,annotations:g}=f;i.push(new Me(l,d,h,!0,VF(f))),s.push(new Me(l,Ne(d),h,!0,g)),n.push(new Me(l,d,h,!0,g));break}case"PropertySignatureTransformation":{let d=f.from.fromKey??l;i.push(new Me(d,f.from.type,f.from.isOptional,!0,f.from.annotations)),s.push(new Me(l,f.to.type,f.to.isOptional,!0,f.to.annotations)),a.push(new Qm(d,l,f.decode,f.encode));break}}}else i.push(new Me(l,u.ast,!1,!0)),s.push(new Me(l,Ne(u.ast),!1,!0)),n.push(new Me(l,u.ast,!1,!0))}if(se(a)){let c=[],l=[];for(let u of t){let{indexSignatures:f,propertySignatures:d}=eh(u.key.ast,u.value.ast);d.forEach((h)=>{i.push(h),s.push(new Me(h.name,Ne(h.type),h.isOptional,h.isReadonly,h.annotations))}),f.forEach((h)=>{c.push(h),l.push(new Pi(h.parameter,Ne(h.type),h.isReadonly))})}return new Zm(new Sr(i,c,{[ru]:"Struct (Encoded side)"}),new Sr(s,l,{[ru]:"Struct (Type side)"}),new Xm(a))}}let o=[];for(let i of t){let{indexSignatures:s,propertySignatures:a}=eh(i.key.ast,i.value.ast);a.forEach((c)=>n.push(c)),s.forEach((c)=>o.push(c))}return new Sr(n,o)},GF=(e,t)=>{let r=Reflect.ownKeys(e);for(let n of r){let o=e[n];if(t[n]===void 0&&nT(o)){let i=o.ast,s=i._tag==="PropertySignatureDeclaration"?i.defaultValue:i.to.defaultValue;if(s!==void 0)t[n]=s()}}return t};function oT(e,t,r=JF(e,t)){return class extends Xe(r){static annotations(o){return oT(this.fields,this.records,Xr(this.ast,o))}static fields={...e};static records=[...t];static make=(o,i)=>{let s=GF(e,{...o});return gh(i)?s:gu(this)(s)};static pick(...o){return z(UO(e,...o))}static omit(...o){return z(HO(e,...o))}}}function z(e,...t){return oT(e,t)}function iT(e,t){return class extends Xe(t){static annotations(n){return iT(this.from,Xr(this.ast,n))}static make=(n,o)=>gh(o)?n:gu(this)(n);static from=e}}var _a=(e,t)=>(r)=>{let n=Ee(Bm(r.ast),{onNone:()=>[e],onSome:(i)=>[...i,e]}),o=ha(r.ast,Fo({[Im]:n,...t}));return iT(r,o)};var YF=Symbol.for("effect/SchemaId/Refine");function sT(e,t,r){return class extends Xe(r){static annotations(o){return sT(this.from,this.filter,Xr(this.ast,o))}static[YF]=e;static from=e;static filter=t;static make=(o,i)=>gh(i)?o:gu(this)(o)}}var KO=(e,t,r)=>{if(Jn(e))return e?w():I(new jt(t,r));if(Be(e))return I(new jt(t,r,e));if(e!==void 0){if("_tag"in e)return I(e);let n=new jt(t,r,e.message);return I(se(e.path)?new Le(e.path,r,n):n)}return w()},ZF=(e,t,r)=>{if(kE(e))return KO(e,t,r);if(se(e)){let n=tc(e,(o)=>KO(o,t,r));if(se(n))return I(n.length===1?n[0]:new _e(t,r,n))}return w()};function br(e,t){return(r)=>{function n(i,s,a){return ZF(e(i,s,a),a,i)}let o=new da(r.ast,n,Fo(t));return sT(r,n,o)}}var QF=DE,aT=(e,t)=>(r)=>r.pipe(br((n)=>n.length>=e,{schemaId:QF,title:`minLength(${e})`,description:`a string at least ${e} character(s) long`,jsonSchema:{minLength:e},...t}));var WO=Symbol.for("effect/SchemaId/Pattern"),_r=(e,t)=>(r)=>{let n=e.source;return r.pipe(br((o)=>(e.lastIndex=0,e.test(o)),{schemaId:WO,[WO]:{regex:e},description:`a string matching the pattern ${n}`,jsonSchema:{pattern:n},...t}))};var XF=Symbol.for("effect/SchemaId/UUID"),zO=/^[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}$/i;class eN extends le.pipe(_r(zO,{schemaId:XF,identifier:"UUID",jsonSchema:{format:"uuid",pattern:zO.source},description:"a Universally Unique Identifier",arbitrary:()=>(e)=>e.uuid()})){}var tN=NE,cT=(e,t)=>(r)=>r.pipe(br((n)=>n>e,{schemaId:tN,title:`greaterThan(${e})`,description:e===0?"a positive number":`a number greater than ${e}`,jsonSchema:{exclusiveMinimum:e},...t})),rN=ME,lT=(e,t)=>(r)=>r.pipe(br((n)=>n>=e,{schemaId:rN,title:`greaterThanOrEqualTo(${e})`,description:e===0?"a non-negative number":`a number greater than or equal to ${e}`,jsonSchema:{minimum:e},...t}));var nN=LE,oN=(e)=>(t)=>t.pipe(br((r)=>Number.isSafeInteger(r),{schemaId:nN,title:"int",description:"an integer",jsonSchema:{type:"integer"},...e}));class Su extends xu.pipe(oN({identifier:"Int"})){}var iN=qE,bu=(e,t)=>(r)=>{let n=Math.floor(e);if(n<1)throw Error(AE(`Expected an integer greater than or equal to 1, actual ${e}`));return r.pipe(br((o)=>o.length>=n,{schemaId:iN,title:`minItems(${n})`,description:`an array of at least ${n} item(s)`,jsonSchema:{minItems:n},[$m]:!0,...t}))};var VO=FE;class sN extends At($a,{typeConstructor:{_tag:"Date"},identifier:"DateFromSelf",schemaId:VO,[VO]:{noInvalidDate:!1},description:"a potentially invalid Date instance",pretty:()=>(e)=>`new Date(${JSON.stringify(e)})`,arbitrary:()=>(e)=>e.date({noInvalidDate:!1}),equivalence:()=>xg}){}function gh(e){return Jn(e)?e:e?.disableValidation??!1}var aN={onExcessProperty:"error"};function tn(e,t){return yu(e,aN)(t)}var yh=q("computer_use","work","frontend","security"),cN=q("computer_use","work","frontend","security"),lN=q("installed","disabled","missing","uncertain"),uN=q("healthy","missing","disabled","uncertain"),pN=Object.freeze(["openai-curated","openai-curated-remote"]),fN=Object.freeze(["build-web-apps","codex-security"]);var rn=Object.freeze({coding:!0,computer_use:!1,work:!1,frontend:!0,security:!0}),dN={work:{name:"work",pluginIds:["documents@openai-primary-runtime","pdf@openai-primary-runtime","presentations@openai-primary-runtime","spreadsheets@openai-primary-runtime","template-creator@openai-primary-runtime"],defaultSelected:rn.work,migrationKey:"work",semanticSkillIds:["documents:documents","pdf:pdf","presentations:Presentations","spreadsheets:Spreadsheets","template-creator:template-creator"],ownership:"shared-preserve"},frontend:{name:"frontend",pluginIds:["build-web-apps@openai-curated"],defaultSelected:rn.frontend,migrationKey:"frontend",semanticSkillIds:["build-web-apps:frontend-app-builder","build-web-apps:frontend-testing-debugging","build-web-apps:react-best-practices"],ownership:"shared-preserve"},security:{name:"security",pluginIds:["codex-security@openai-curated"],defaultSelected:rn.security,migrationKey:"security",semanticSkillIds:["codex-security:security-scan","codex-security:security-diff-scan","codex-security:threat-model"],ownership:"shared-preserve"},computer_use:{name:"computer_use",pluginIds:["computer-use@openai-bundled"],defaultSelected:rn.computer_use,migrationKey:"computer_use",semanticSkillIds:["computer-use:computer-use"],ownership:"shared-preserve"}},mN=Object.freeze(dN),hN=Object.freeze(["computer_use","work","frontend","security"]),gN=Object.freeze({computer_use:rn.computer_use,work:rn.work,frontend:rn.frontend,security:rn.security});var fT=q("local.repository.edit","local.repository.check","local.repository.lint","local.repository.format","local.repository.commit","external.read","specialist.dispatch","vcs.server.mutation","vcs.server.ci-trigger","unknown.effect"),yN=z({identifier:fT,label:le,requiresRootApproval:de});function wr(e){return z({identifier:q(e),label:le,requiresRootApproval:de})}var xN=z({localRepositoryEdit:wr("local.repository.edit"),localRepositoryCheck:wr("local.repository.check"),localRepositoryLint:wr("local.repository.lint"),localRepositoryFormat:wr("local.repository.format"),localRepositoryCommit:wr("local.repository.commit"),externalRead:wr("external.read"),specialistDispatch:wr("specialist.dispatch"),versionControlServerMutation:wr("vcs.server.mutation"),versionControlServerCiTrigger:wr("vcs.server.ci-trigger"),unknownEffect:wr("unknown.effect")}),xh={localRepositoryEdit:{identifier:"local.repository.edit",label:"local repository edit",requiresRootApproval:!1},localRepositoryCheck:{identifier:"local.repository.check",label:"local repository check",requiresRootApproval:!1},localRepositoryLint:{identifier:"local.repository.lint",label:"local repository lint",requiresRootApproval:!1},localRepositoryFormat:{identifier:"local.repository.format",label:"local repository format",requiresRootApproval:!1},localRepositoryCommit:{identifier:"local.repository.commit",label:"local repository commit",requiresRootApproval:!1},externalRead:{identifier:"external.read",label:"external read",requiresRootApproval:!1},specialistDispatch:{identifier:"specialist.dispatch",label:"specialist dispatch",requiresRootApproval:!1},versionControlServerMutation:{identifier:"vcs.server.mutation",label:"version-control-server mutation",requiresRootApproval:!0},versionControlServerCiTrigger:{identifier:"vcs.server.ci-trigger",label:"version-control-server CI triggering",requiresRootApproval:!0},unknownEffect:{identifier:"unknown.effect",label:"unclassified effect",requiresRootApproval:!0}};cr(xh);var SN=q("never","root"),dT=Object.values(xh);function uT(e){let t=e.map((n)=>n.label),r=t.at(-1);if(r===void 0)return"";if(t.length===1)return r;return`${t.slice(0,-1).join(", ")}, and ${r}`}function pT(e){return e.length===0?e:`${e[0]?.toUpperCase()??""}${e.slice(1)}`}var bN=dT.filter((e)=>!e.requiresRootApproval),_N=dT.filter((e)=>e.requiresRootApproval),wN=Object.freeze({noRootApproval:`${pT(uT(bN))} actions do not require Root approval.`,rootApproval:`${pT(uT(_N))} require Root approval.`});var sr=le.pipe(_r(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u)),Sh=le.pipe(_r(/^[0-9a-f]{64}$/u)),IB=sr.pipe(_a("RunId")),RB=sr.pipe(_a("ProjectId")),vB=sr.pipe(_a("TrustId")),CB=Sh.pipe(_a("Sha256Digest"));var EN=z({run_id:sr,objective_lineage:sr,parent_run_id:G(yt(sr,en))}),ON=z({project_id:sr,trust_id:sr,trust_digest:Sh}),TN=z({project_id:sr,project_digest:Sh}),kN=le.pipe(_r(/^state-[0-9]+\.[0-9]+$/u));var _u=q("low","default","high"),yT=q("go","Go","plus-low","plus","plus-high","pro-5x","pro-20x"),AN=yt(_u,yT);var xT=q("standard","fast","fast-all"),IN=q("low","medium","high","xhigh","max"),ST="Make the smallest complete edit set within the authorized boundary, touch no unrelated paths, avoid speculative refactors or formatting churn, and perform no redundant writes or operations; preserve unrelated work and stop for Root input before expanding scope.",nn=[{role:"Explorer",tasks:[{name:"lookup",description:"Use when Root needs one exact repository fact; locate it and return the exact path, symbol, or value.",instruction:"Locate the exact requested repository fact."},{name:"trace",description:"Use when Root needs a complete in-scope execution or reference path; trace every relevant caller and constraint, then return the path and evidence.",instruction:"Trace the complete in-scope execution or reference path."}],capability:"repository-read",authority:"Read only the delegated Assignment repository scope; Git/VCS, lifecycle, and decisions remain Root-only.",evidence:"Return exact paths, symbols, callers, tests, and constraints.",completion:"Account for every in-scope caller and constraint.",permissions:{network:!1,write:!1}},{role:"Librarian",tasks:[{name:"lookup",description:"Use when Root needs one exact current external fact; locate it in the assigned authoritative source and return the citation.",instruction:"Locate the exact requested authoritative external fact."},{name:"research",description:"Use when Root needs a sourced current synthesis; combine the assigned authoritative sources with citations and return the evidence and uncertainty.",instruction:"Synthesize the assigned current sources with citations."}],capability:"current-research",authority:"Research only the delegated Assignment current sources without repository mutation; Git/VCS, lifecycle, and decisions remain Root-only.",evidence:"Return sourced facts, dates, and explicit uncertainty.",completion:"Resolve the assigned external fact or report the exact evidence gap.",permissions:{network:!0,write:!1}},{role:"Worker",tasks:[{name:"mechanical",description:"Use when Root has decided deterministic edits; apply only those edits, verify the result, and return changed paths and evidence.",instruction:"Apply only deterministic, already-decided edits."},{name:"implementation",description:"Use when Root has decided a bounded behavior seam; implement and verify that seam, then return changed paths and evidence.",instruction:"Implement and verify the bounded behavior seam."},{name:"integration",description:"Use when Root has decided seams that must be combined; integrate and verify them together, then return the result and residual risk.",instruction:"Integrate the decided seams and verify them together."},{name:"operations",description:"Use after Root approves an exact ref or SHA; observe required CI and release state to terminal evidence and return it, never treating pending as success.",instruction:"After Root approves an exact ref or SHA, observe required CI and release state through terminal evidence; pending or running state is never success."}],capability:"bounded-write",authority:"Change only the delegated Assignment seam; Intent lifecycle, Git/VCS, and material choices remain Root-only.",evidence:"Return changed files, verification results, and remaining risk.",completion:"Finish the delegated Assignment with proportional proof or an exact blocker and return a compact structured outcome.",permissions:{network:!1,write:!0}},{role:"Reviewer",tasks:[{name:"plan",description:"Use when Root needs a complete plan adversarially checked; review it to a fixed point and return findings, proof, and residual risk.",instruction:"Review the complete plan to a fixed point."},{name:"code",description:"Use when Root needs implemented code adversarially checked; review and repair it to a fixed point, returning findings, proof, and residual risk.",instruction:"Review and repair the implemented code to a fixed point."},{name:"artifact",description:"Use when Root needs a produced artifact inspected; review and repair it to a fixed point, returning findings, proof, and residual risk.",instruction:"Review and repair the produced artifact to a fixed point."}],capability:"bounded-review",authority:"Inspect and repair only reviewer-owned defects within the delegated Assignment; Intent lifecycle, Git/VCS, and material choices remain Root-only.",evidence:"Return findings, repaired paths, verification, and residual risk.",completion:"Reach a fixed point or report each reproducible blocker as a compact structured outcome.",permissions:{network:!1,write:!0}}];cr(nn);var bT=new Map(nn.map((e)=>[e.role,e])),RN=new Set(nn.map((e)=>e.role)),bh=nn.flatMap((e)=>e.tasks.map((t)=>`${e.role}:${t.name}`)),vN=new Set(bh),_T=bh.map((e)=>e.replace(":",".")),wT=new Set(_T);function ET(e){return typeof e==="string"&&RN.has(e)}function CN(e){if(typeof e!=="object"||e===null||!("role"in e)||!("task"in e))return!1;let{role:t,task:r}=e;if(!ET(t)||typeof r!=="string")return!1;return bT.get(t)?.tasks.some((n)=>n.name===r)===!0}function wu(e,t){return typeof t==="string"&&bT.get(e)?.tasks.some((r)=>r.name===t)===!0}function OT(e){return typeof e==="string"&&vN.has(e)}var _h=At(ET),PN=At((e)=>wu("Explorer",e)),FN=At((e)=>wu("Librarian",e)),NN=At((e)=>wu("Worker",e)),MN=At((e)=>wu("Reviewer",e)),wa=At(CN),No=Object.freeze(bh.filter((e)=>OT(e))),TT=At(OT),LN=Object.freeze(_T.filter((e)=>wT.has(e))),DN=At((e)=>typeof e==="string"&&wT.has(e));var kT=z({profile:_u,service_tier:G(xT)}),qN=q("git_vcs","computer_use"),UN=Object.freeze({requiresDelegation:!0,trivialWorkRequiresDelegation:!0,directExecutionExceptions:Object.freeze(["git_vcs","computer_use"]),requestUserInputGates:Object.freeze(["plan_approval","installation_profile_approval","remote_origin_server_vcs_mutation","public_publication_or_release","ambiguity_or_missing_material_input"]),surgicalMutationRule:ST,specialistOutcomes:Object.freeze(["completed","blocked","needs_root_input","failed"]),materialDecisionsRemainRootOwned:!0,lifecycleRemainsRootOwned:!0,integrationAndCompletionRemainRootOwned:!0,codeReviewRequiredForImplementation:!0,codeReviewRequiredBeforeVcs:!0,externalVerificationMustBeTerminal:!0,postVcsFlow:"discover_topology_observe_repair_repeat"});function et(e,t){return new nt("invalid_canonical_value",`Cannot canonicalize ${e}: ${t}.`,{path:e,reason:t})}function wh(e,t,r){if(e===null)return"null";switch(typeof e){case"string":{let n=JSON.stringify(e);if(n===void 0)throw et(t,"invalid string");return n}case"boolean":return e?"true":"false";case"number":{if(!Number.isFinite(e))throw et(t,"non-finite number");let n=JSON.stringify(e);if(n===void 0)throw et(t,"invalid number");return n}case"undefined":throw et(t,"undefined is not JSON");case"bigint":throw et(t,"bigint is not JSON");case"function":throw et(t,"function is not JSON");case"symbol":throw et(t,"symbol is not JSON");case"object":break}if(r.has(e))throw et(t,"cyclic value");r.add(e);try{if(Array.isArray(e)){for(let a of Object.getOwnPropertySymbols(e))throw et(t,`symbol property ${String(a)}`);let i=e,s=[];for(let a=0;a<i.length;a+=1){let c=Object.getOwnPropertyDescriptor(i,String(a));if(!c||!c.enumerable||!("value"in c))throw et(`${t}[${a}]`,"sparse or accessor array item");s.push(wh(c.value,`${t}[${a}]`,r))}for(let a of Object.getOwnPropertyNames(i)){if(a==="length")continue;let c=Number(a);if(!Number.isInteger(c)||c<0||c>=i.length||String(c)!==a)throw et(t,`non-index array property ${a}`);let l=Object.getOwnPropertyDescriptor(i,a);if(!l||!l.enumerable||!("value"in l))throw et(`${t}[${c}]`,"non-enumerable or accessor array item")}return`[${s.join(",")}]`}let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw et(t,"only plain objects are supported");for(let i of Object.getOwnPropertySymbols(e))throw et(t,`symbol property ${String(i)}`);for(let i of Object.getOwnPropertyNames(e)){let s=Object.getOwnPropertyDescriptor(e,i);if(!s||!s.enumerable||!("value"in s))throw et(`${t}.${i}`,"non-enumerable or accessor property")}let o=[];for(let i of Object.keys(e).sort()){let s=Object.getOwnPropertyDescriptor(e,i);if(!s||!("value"in s))throw et(`${t}.${i}`,"accessor property");o.push(`${JSON.stringify(i)}:${wh(s.value,`${t}.${i}`,r)}`)}return`{${o.join(",")}}`}finally{r.delete(e)}}function Eh(e){return wh(e,"$",new Set)}var AT=q("blocked","completed","failed","partial"),IT=yt(q("high","max","xhigh"),en);function RT(e){try{return Eh(e)!==void 0}catch{return!1}}var vT=At((e)=>RT(e)),jN=At((e)=>$u(e)&&!Array.isArray(e)&&RT(e)),$N=z({blocked:de,changed_files:V(le),confidence:xu,context_owner:yt(le,en),material_findings:V(le),needs_more_context:de,needs_root_decision:de,needs_verification:de,relevant_files:V(le),remaining_risk:V(le),reuse_recommended:de,status:AT,suggested_followup:yt(le,en),suggested_luna_effort:IT,suggested_specialist:yt(_h,en),verification:V(le),verification_passed:de}),Oh="holycodex-specialist-outcome-2",xt=le.pipe(aT(1)),Ea={protocol_version:q(Oh),route:wa,evidence:V(xt)},BN=z(Ea),KN=z({...Ea,status:q("completed"),summary:xt}),WN=z({...Ea,status:q("blocked"),reason:xt,needs_root_decision:de}),zN=z({...Ea,status:q("partial"),summary:xt,completed:V(xt),remaining:V(xt),needs_root_decision:de}),VN=z({...Ea,status:q("failed"),error:xt}),JN=yt(KN,WN,zN,VN),Eu={protocol_version:q(Oh),capability:yh,route:yt(wa,en),evidence:V(xt),data:vT},GN=z({...Eu,status:q("completed"),summary:xt}),YN=z({...Eu,status:q("blocked"),reason:xt,needs_root_decision:de}),ZN=z({...Eu,status:q("partial"),summary:xt,completed:V(xt),remaining:V(xt),needs_root_decision:de}),QN=z({...Eu,status:q("failed"),error:xt}),XN=yt(GN,YN,ZN,QN);var CT=V(le),PT=le.pipe(_r(/^[a-z][a-z0-9-]*(?: [a-z][a-z0-9-]*)*$/u)),FT=q(ju),eM=z({code:sr,message:le,details:jN}),NT=z({schema_version:FT,ok:q(!0),command:PT,data:vT,warnings:CT}),MT=z({schema_version:FT,ok:q(!1),command:PT,error:eM,warnings:CT}),tM=yt(NT,MT);var DT="gpt-5.6-luna";function rM(e,t,r){return{key:`${e}:${t}`,role:e,task:t,model:DT,effort:r}}var nM=new Set(No),LT={low:0,medium:1,high:2,xhigh:3,max:4},kh=[{profile:"low",rationale:"The low profile keeps bounded specialist work economical.",efforts:{"Explorer:lookup":"medium","Explorer:trace":"high","Librarian:lookup":"medium","Librarian:research":"high","Worker:mechanical":"high","Worker:implementation":"high","Worker:integration":"max","Worker:operations":"high","Reviewer:plan":"high","Reviewer:code":"max","Reviewer:artifact":"high"}},{profile:"default",rationale:"The default profile is the recommended balanced route.",efforts:{"Explorer:lookup":"medium","Explorer:trace":"xhigh","Librarian:lookup":"medium","Librarian:research":"xhigh","Worker:mechanical":"high","Worker:implementation":"xhigh","Worker:integration":"max","Worker:operations":"high","Reviewer:plan":"xhigh","Reviewer:code":"max","Reviewer:artifact":"xhigh"}},{profile:"high",rationale:"The high profile maximizes specialist reasoning where specified.",efforts:{"Explorer:lookup":"medium","Explorer:trace":"max","Librarian:lookup":"medium","Librarian:research":"max","Worker:mechanical":"xhigh","Worker:implementation":"max","Worker:integration":"max","Worker:operations":"xhigh","Reviewer:plan":"max","Reviewer:code":"max","Reviewer:artifact":"max"}}];cr(kh);var oM=new Map(kh.map((e)=>[e.profile,e]));function iM(e){let t=oM.get(e);if(t===void 0)throw new nt("catalog_invalid","A profile has no route effort policy.",{profile:e});return nn.flatMap((r)=>r.tasks.map((n)=>{let o=`${r.role}:${n.name}`,i=t.efforts[o];if(i===void 0)throw new nt("catalog_invalid","A route effort policy is incomplete.",{profile:e,route:o});return rM(r.role,n.name,i)}))}function Th(e){return{name:e.name,root:{model:"gpt-6-astra",effort:e.effort},specialistModel:"gpt-5.6-luna",defaultServiceTier:"standard",routes:iM(e.name)}}var Ah=[Th({name:"low",effort:"low"}),Th({name:"default",effort:"medium"}),Th({name:"high",effort:"high"})];function sM(e){let t=["low","default","high"];if(e.length!==t.length)throw new nt("catalog_invalid","The profile catalog has an invalid size.");for(let r=0;r<t.length;r+=1){let n=e[r],o=t[r];if(!n||n.name!==o)throw new nt("catalog_invalid","The profile catalog order is invalid.",{index:r});let i=o==="low"?"low":o==="default"?"medium":"high";if(n.root.model!=="gpt-6-astra"||n.root.effort!==i||n.specialistModel!=="gpt-5.6-luna")throw new nt("catalog_invalid","A profile has an invalid model route.",{profile:n.name});if(n.routes.length!==No.length)throw new nt("catalog_invalid","A profile is incomplete.",{profile:n.name});let s=new Set;for(let a of n.routes){if(s.has(a.key)||!nM.has(a.key)||a.model!=="gpt-5.6-luna"||`${a.role}:${a.task}`!==a.key)throw new nt("catalog_invalid","A profile contains an invalid route.",{profile:n.name});s.add(a.key)}if(s.size!==No.length)throw new nt("catalog_invalid","A profile is missing a specialist route.",{profile:n.name})}for(let r=0;r<No.length;r+=1){let n=-1;for(let o of e){let i=o.routes[r];if(!i||LT[i.effort]<n)throw new nt("catalog_invalid","Profile route effort is not monotonic.",{route:No[r]??"unknown"});n=LT[i.effort]}}}sM(Ah);cr(Ah);var qT=Ah,aM=new Map,cM=new Map;for(let e of qT){aM.set(e.name,e);let t=new Map;for(let r of e.routes)t.set(r.key,r);cM.set(e.name,t)}import{execFile as lM}from"child_process";import{createHash as uM}from"crypto";import{lstat as on,mkdir as Li,open as Pu,readFile as Ch,readdir as Ta,realpath as pM,rename as fM,rm as Aa,stat as dM}from"fs/promises";import{basename as Ih,dirname as jn,isAbsolute as mM,join as M,relative as hM,resolve as vu}from"path";import{promisify as gM}from"util";var Fu="holycodex-intent-1",Ph="holycodex-plan-1",Fh="holycodex-assignment-1",$n="toon-4",K=le.pipe(br((e)=>e.trim().length>0)),ar=le.pipe(_r(/^[a-z0-9][a-z0-9-]{0,95}$/u)),Nh=le.pipe(_r(/^[a-f0-9]{64}$/u)),Ia=Su.pipe(lT(1)),Or=le.pipe(br((e)=>!Number.isNaN(Date.parse(e)))),Te=V(K),yM=z({pid:Su.pipe(cT(0)),token:K}),xM=120000,SM=4294967295,Mh=z({role:q("Explorer","Librarian","Worker","Reviewer"),task:K}).pipe(br((e)=>nn.some((t)=>t.role===e.role&&t.tasks.some((r)=>r.name===e.task)))),Do=z({kind:q("changed_path","check","repository_fact","ci","behavior","uncertainty"),value:K,result:G(q("passed","failed","observed","unknown"))}),Lh=z({root:K,git_common_dir:K,initial_head:K,expected_head:K,expected_changes:Te,expected_status_digest:Nh,updated_at:Or}),qi=q("scoping","ready","executing","verifying","reviewing","blocked","needs_root_input","complete","abandoned"),bM=q("scoping","ready","executing","verifying","reviewing"),UT=z({required:de,status:q("not_required","missing","passed","failed","accepted","rejected"),evidence:V(Do)}),Ra=z({schema_version:q(Fu),toon_compatibility:q($n),id:ar,slug:ar,title:K,goal:K,acceptance_criteria:Te,state:qi,revision:Ia,plan_required:de,active_plan_revision:G(Ia),active_plan_digest:G(Nh),blockers:Te,resume_state:G(bM),verification:UT,review:UT,acceptance_met:de,root_readiness:de,evidence:V(Do),baseline:Lh,created_at:Or,updated_at:Or}),Ru=z({schema_version:q(Ph),toon_compatibility:q($n),intent_id:ar,revision:Ia,predecessor_digest:G(Nh),approach:K,scope:Te,exclusions:Te,assignments:Te,dependencies:Te,architecture:Te,risks:Te,assumptions:Te,open_questions:Te,verification:Te,recovery:Te,updated_at:Or}),Dh=q("completed","blocked","needs_root_input","failed"),zT=q("pending","executing","completed","blocked","needs_root_input","failed"),qh=z({id:ar,outcome:Dh,started_at:Or,finished_at:Or,summary:K,evidence:V(Do),blocker:G(K),remaining_risk:Te}),ka=z({schema_version:q(Fh),toon_compatibility:q($n),intent_id:ar,id:ar,objective:K,owner:Mh,scope:Te,constraints:Te,exclusions:Te,dependencies:Te,acceptance_criteria:Te,status:zT,revision:Ia,invocations:V(qh),evidence:V(Do),blocker:G(K),remaining_risk:Te,created_at:Or,updated_at:Or}),_M=z({schema_version:q("holycodex-intent-0"),id:ar,slug:ar,title:K,goal:K,acceptance_criteria:Te,state:qi,revision:Ia,baseline:Lh,created_at:Or,updated_at:Or});class j extends Error{code;details;constructor(e,t,r={}){super(t);this.name="IntentStoreError",this.code=e,this.details=r}}var Nu=z({title:K,goal:K,acceptanceCriteria:V(K).pipe(bu(1)),planRequired:G(de),verificationRequired:G(de),reviewRequired:G(de)}),Mu=z({approach:K,scope:G(V(K)),exclusions:G(V(K)),assignments:G(V(K)),dependencies:G(V(K)),architecture:G(V(K)),risks:G(V(K)),assumptions:G(V(K)),openQuestions:G(V(K)),verification:G(V(K)),recovery:G(V(K))}),Lu=z({id:G(K),objective:K,owner:Mh,scope:V(K).pipe(bu(1)),constraints:G(V(K)),exclusions:G(V(K)),dependencies:G(V(K)),acceptanceCriteria:V(K).pipe(bu(1))}),Du=z({invocationId:G(K),outcome:Dh,startedAt:G(K),summary:K,evidence:G(V(Do)),blocker:G(K),remainingRisk:G(V(K))}),qu=z({evidence:G(V(Do)),verification:G(q("passed","failed")),review:G(q("accepted","rejected")),acceptanceMet:G(de),rootReadiness:G(de),clearBlockers:G(de)}),Uh=gM(lM);class Uu{repositoryRoot;stateRoot;#e;#i;constructor(e,t={}){this.repositoryRoot=vu(e),this.stateRoot=M(this.repositoryRoot,".holycodex"),this.#e=t.now??(()=>new Date),this.#i=t.repositorySnapshot??(()=>VT(this.repositoryRoot))}async recover(){if(await this.#s(),!await Iu(this.stateRoot))return[];return await Au(M(this.stateRoot,".intent-store"),async()=>this.#c())}async#c(){let e;try{e=await Ta(this.stateRoot,{recursive:!0})}catch(r){if(me(r,"ENOENT"))return[];throw Ce(r)}let t=[];for(let r of e){let n=Ih(r);if(!n.startsWith(".holycodex-write-")||!n.endsWith(".tmp"))continue;let o=M(this.stateRoot,r),i=jn(o);if(i!==this.stateRoot&&await Iu(M(i,".intent-store")))continue;await Di(o),await Aa(o,{force:!0}),t.push(r.replaceAll("\\","/"))}return t.sort()}async#s(){try{let e=await on(this.stateRoot);if(e.isSymbolicLink()||!e.isDirectory())throw new j("schema_invalid","Repository-local work state must be a real directory.",{path:this.stateRoot})}catch(e){if(me(e,"ENOENT"))return;throw Ce(e)}}async createIntent(e){let t=He(Nu,e);if(!t.title.trim()||!t.goal.trim()||t.acceptanceCriteria.length===0)throw Lo("Intent title, goal, and acceptance criteria are required.");return await this.recover(),await Li(this.stateRoot,{recursive:!0}),await Au(M(this.stateRoot,".intent-store"),async()=>{let r=await this.#i(),n=OM(t.title),o=Hn([r.root,t.title.trim(),t.goal.trim()].join("\x00")).slice(0,10),i=`${n}-${o}`,s=1;while(await Iu(M(this.stateRoot,i)))s+=1,i=`${n}-${o}-${String(s).padStart(2,"0")}`;let a=`intent-${o}${s===1?"":`-${String(s).padStart(2,"0")}`}`,c=this.#e().toISOString(),l=He(Ra,{schema_version:Fu,toon_compatibility:$n,id:a,slug:n,title:t.title.trim(),goal:t.goal.trim(),acceptance_criteria:[...t.acceptanceCriteria],state:"scoping",revision:1,plan_required:t.planRequired??!1,blockers:[],verification:Cu(t.verificationRequired??!0),review:Cu(t.reviewRequired??!0),acceptance_met:!1,root_readiness:!1,evidence:[],baseline:HT(r,c),created_at:c,updated_at:c}),u=M(this.stateRoot,i);return await Li(M(u,"assignments"),{recursive:!0}),await It(M(u,"intent.toon"),l),await vh(M(this.stateRoot,"current"),`${i}
|
|
38
|
+
`),l})}async listIntents(){await this.#s(),await this.recover();let e;try{e=await Ta(this.stateRoot)}catch(r){if(me(r,"ENOENT"))return[];throw Ce(r)}let t=[];for(let r of e.sort()){let n=M(this.stateRoot,r);if(!await Rh(n))continue;let o=M(n,"intent.toon");if(await Oa(o))t.push(await this.#t(o))}return t.sort((r,n)=>r.id.localeCompare(n.id))}async readIntent(e){let t=await this.#r(e);return await this.#n(t,async()=>this.#t(M(t,"intent.toon")))}async currentIntent(){await this.#s();try{let t=M(this.stateRoot,"current"),r=await on(t).catch((o)=>{if(me(o,"ENOENT"))return;throw Ce(o)});if(r?.isSymbolicLink()||r&&!r.isFile())throw new j("schema_invalid","The current Intent pointer must be a regular file.");let n=r?(await Ch(t,"utf8")).trim():"";if(n){let o=vu(this.stateRoot,n);if(!CM(this.stateRoot,o))throw new j("schema_invalid","The current Intent pointer escapes repository-local state.",{directory:n});if(!await Rh(o))throw new j("schema_invalid","The current Intent pointer does not select a work-state directory.",{directory:n});return await this.#t(M(o,"intent.toon"))}}catch(t){if(!me(t,"ENOENT"))throw Ce(t)}let e=(await this.listIntents()).filter((t)=>t.state!=="complete"&&t.state!=="abandoned");if(e.length===1)return e[0];throw new j(e.length?"current_ambiguous":"not_found",e.length?"Multiple active Intents require explicit selection.":"No current Intent exists.",{intent_ids:e.map((t)=>t.id)})}async selectCurrent(e){let t=await this.#r(e),r=await this.#t(M(t,"intent.toon"));return await Au(M(this.stateRoot,".intent-store"),async()=>vh(M(this.stateRoot,"current"),`${Ih(t)}
|
|
39
|
+
`)),r}async transitionIntent(e,t,r,n){let o=He(qi,t),i=n===void 0?void 0:He(K,n);if(!Number.isSafeInteger(r)||r<1)throw Lo("Intent revision must be a positive integer.");let s=await this.#r(e);return await this.#n(s,async()=>{let a=await this.#t(M(s,"intent.toon"));if(Er(a.revision,r),o==="complete")throw new j("invalid_transition","Use the predicate-checked complete operation.");if(o==="abandoned")return await this.#a(s,a);return await this.#l(s,a,o,i)})}async completeIntent(e,t){let r=await this.#r(e);return await this.#n(r,async()=>{let n=await this.#t(M(r,"intent.toon"));if(Er(n.revision,t),Mi(n),await this.#o(n),n.active_plan_revision!==void 0)await this.readPlan(e);let o=await this.listAssignments(e),i=[];if(n.state!=="reviewing")i.push("intent_not_reviewing");if(n.plan_required&&n.active_plan_revision===void 0)i.push("required_plan_missing");if(n.blockers.length)i.push("global_blockers_unresolved");if(o.length===0)i.push("assignment_required");if(o.some((a)=>a.status!=="completed"))i.push("assignments_unresolved");if(n.verification.required&&n.verification.status!=="passed")i.push("verification_unresolved");if(n.review.required&&n.review.status!=="accepted")i.push("review_unresolved");if(!n.acceptance_met)i.push("acceptance_criteria_unmet");if(!n.root_readiness)i.push("root_readiness_missing");if(i.length)return{completed:!1,reasons:i};let s=Mo(n,this.#e,{state:"complete"});return await It(M(r,"intent.toon"),s),s})}async abandonIntent(e,t){let r=await this.#r(e);return await this.#n(r,async()=>{let n=await this.#t(M(r,"intent.toon"));return Er(n.revision,t),await this.#a(r,n)})}async recordIntentEvidence(e,t,r){let n=He(qu,r),o=await this.#r(e);return await this.#n(o,async()=>{let i=await this.#t(M(o,"intent.toon"));if(Er(i.revision,t),Mi(i),n.verification!==void 0||n.review!==void 0)await this.#o(i);if(n.verification!==void 0&&i.state!=="verifying")throw new j("invalid_transition","Verification evidence is only accepted while the Intent is verifying.",{state:i.state});if(n.review!==void 0&&i.state!=="reviewing")throw new j("invalid_transition","Review evidence is only accepted while the Intent is reviewing.",{state:i.state});let s=[...i.evidence,...n.evidence??[]],a=n.verification===void 0?i.verification:{...i.verification,status:n.verification,evidence:[...i.verification.evidence,...n.evidence??[]]},c=n.review===void 0?i.review:{...i.review,status:n.review,evidence:[...i.review.evidence,...n.evidence??[]]},l=n.review==="rejected"&&i.state==="reviewing"?"executing":i.state,u=Mo(i,this.#e,{state:l,evidence:s,verification:a,review:c,...n.acceptanceMet===void 0?{}:{acceptance_met:n.acceptanceMet},...n.rootReadiness===void 0?{}:{root_readiness:n.rootReadiness},...n.clearBlockers?{blockers:[]}:{}});return await It(M(o,"intent.toon"),u),u})}async readPlan(e){let t=await this.#r(e),r=M(t,"plan.toon");if(!await Oa(r))return;let n=await ku(r,Ru),o=await this.#t(M(t,"intent.toon")),i=Hn(`${zi(n)}
|
|
40
|
+
`);if(n.intent_id!==o.id||o.active_plan_revision!==n.revision||o.active_plan_digest!==i)throw new j("schema_invalid","Canonical Plan provenance does not match its Intent.",{intent_id:o.id,plan_revision:n.revision});return n}async revisePlan(e,t,r,n){let o=He(Mu,t);if(!o.approach.trim())throw Lo("Plan approach is required.");let i=await this.#r(e);return await this.#n(i,async()=>{let s=await this.#t(M(i,"intent.toon"));Er(s.revision,r),Mi(s),await this.#o(s);let a=M(i,"plan.toon"),c=await Oa(a)?await ku(a,Ru):void 0;if(c===void 0&&n!==void 0)Er(0,n);if(c!==void 0)Er(c.revision,n);let l,u;if(c){let g=`${zi(c)}
|
|
41
|
+
`;u=Hn(g),l=await vM(i),await kM(l,g)}let f=He(Ru,{schema_version:Ph,toon_compatibility:$n,intent_id:s.id,revision:(c?.revision??0)+1,...u?{predecessor_digest:u}:{},approach:o.approach.trim(),scope:[...o.scope??[]],exclusions:[...o.exclusions??[]],assignments:[...o.assignments??[]],dependencies:[...o.dependencies??[]],architecture:[...o.architecture??[]],risks:[...o.risks??[]],assumptions:[...o.assumptions??[]],open_questions:[...o.openQuestions??[]],verification:[...o.verification??[]],recovery:[...o.recovery??[]],updated_at:this.#e().toISOString()});await It(a,f);let d=Hn(`${zi(f)}
|
|
42
|
+
`),h=Mo(s,this.#e,{active_plan_revision:f.revision,active_plan_digest:d,verification:Ou(s.verification),review:Ou(s.review),acceptance_met:!1,root_readiness:!1});return await It(M(i,"intent.toon"),h),{intent:h,plan:f,...l?{archived:Ih(l)}:{}}})}async createAssignment(e,t,r){let n=He(Lu,t);if(!n.objective.trim()||n.scope.length===0||n.acceptanceCriteria.length===0)throw Lo("Assignment objective, scope, and acceptance criteria are required.");let o=await this.#r(e);return await this.#n(o,async()=>{let i=await this.#t(M(o,"intent.toon"));Er(i.revision,r),Mi(i),await this.#o(i);let s=n.id??`assignment-${Hn([i.id,n.objective,...n.scope].join("\x00")).slice(0,10)}`;if(!/^[a-z0-9][a-z0-9-]{0,95}$/u.test(s))throw Lo("Assignment id is invalid.");let a=M(o,"assignments",`${s}.toon`);if(await Iu(a))throw new j("already_exists","Assignment already exists.",{id:s});let c=this.#e().toISOString(),l=He(ka,{schema_version:Fh,toon_compatibility:$n,intent_id:i.id,id:s,objective:n.objective.trim(),owner:n.owner,scope:[...n.scope],constraints:[...n.constraints??[]],exclusions:[...n.exclusions??[]],dependencies:[...n.dependencies??[]],acceptance_criteria:[...n.acceptanceCriteria],status:"pending",revision:1,invocations:[],evidence:[],remaining_risk:[],created_at:c,updated_at:c});return await Li(jn(a),{recursive:!0}),await It(a,l),l})}async readAssignment(e,t){let r=He(ar,t),n=await this.#r(e),o=await this.#t(M(n,"intent.toon")),i=M(n,"assignments");await KT(i,!0);let s=M(i,`${r}.toon`);if(!await Oa(s))throw new j("not_found","Assignment was not found.",{assignment_id:r});let a=await ku(s,ka);return WT(a,o.id,r,s),a}async listAssignments(e){let t=await this.#r(e),r=await this.#t(M(t,"intent.toon")),n=M(t,"assignments");if(!await KT(n,!0))return[];let o;try{o=await Ta(n)}catch(s){if(me(s,"ENOENT"))return[];throw Ce(s)}return await Promise.all(o.filter((s)=>s.endsWith(".toon")).sort().map(async(s)=>{let a=M(n,s),c=await ku(a,ka),l=s.slice(0,-5);return WT(c,r.id,l,a),c}))}async startAssignment(e,t,r){let n=He(ar,t),o=await this.#r(e);return await this.#n(o,async()=>{let i=await this.#t(M(o,"intent.toon"));Mi(i),await this.#o(i);let s=await this.readAssignment(e,n);if(Er(s.revision,r),s.status==="completed")throw new j("invalid_transition","A completed Assignment cannot be restarted.");let a=$T(s,this.#e,{status:"executing",blocker:void 0});return await It(M(o,"assignments",`${n}.toon`),a),a})}async recordAssignmentResult(e,t,r,n){let o=He(Du,n),i=He(ar,t),s=await this.#r(e);return await this.#n(s,async()=>{let a=await this.#t(M(s,"intent.toon"));Mi(a);let c=await this.readAssignment(e,i);if(Er(c.revision,r),!["executing","blocked","needs_root_input","failed"].includes(c.status))throw new j("invalid_transition",`Assignment result is invalid from ${c.status}.`);if((o.outcome==="blocked"||o.outcome==="needs_root_input")&&!o.blocker?.trim())throw Lo("Blocked results require a local blocker.");let l=await this.#i(),u=[...o.evidence??[]],f=new Set(u.filter((R)=>R.kind==="changed_path").map((R)=>R.value)),d=[...f].filter((R)=>!c.scope.some((v)=>TM(R,v)));if(d.length)throw new j("repository_drift","Assignment evidence declares paths outside its bounded scope.",{assignment_id:c.id,out_of_scope_paths:d.sort()});let h=new Set([...a.baseline.expected_changes,...f]),g=l.changedPaths.filter((R)=>!h.has(R)),P=l.root!==a.baseline.root||l.gitCommonDir!==a.baseline.git_common_dir,x=jT(l.statusDigest)!==a.baseline.expected_status_digest,E=[...f].some((R)=>l.changedPaths.includes(R));if(P||g.length||x&&!E||l.head!==a.baseline.expected_head&&!E)throw new j("repository_drift","Repository state changed outside the recorded Assignment result.",{expected_head:a.baseline.expected_head,actual_head:l.head,unexpected_paths:g});let W=this.#e().toISOString(),F=o.invocationId??`invocation-${String(c.invocations.length+1).padStart(3,"0")}`;if(c.invocations.some((R)=>R.id===F))throw new j("already_exists","Assignment invocation already exists.",{invocation_id:F});let D=He(qh,{id:F,outcome:o.outcome,started_at:o.startedAt??W,finished_at:W,summary:o.summary,evidence:u,...o.blocker?{blocker:o.blocker}:{},remaining_risk:[...o.remainingRisk??[]]}),T=$T(c,this.#e,{status:o.outcome,invocations:[...c.invocations,D],evidence:[...c.evidence,...u],blocker:o.blocker,remaining_risk:[...o.remainingRisk??[]]});await It(M(s,"assignments",`${i}.toon`),T);let A=Mo(a,this.#e,{baseline:HT(l,W,a.baseline.initial_head),verification:Ou(a.verification),review:Ou(a.review),acceptance_met:!1,root_readiness:!1});return await It(M(s,"intent.toon"),A),{assignment:T,intent:A}})}async#l(e,t,r,n){let o=t.state;if(r==="blocked"||r==="needs_root_input"){if(["complete","abandoned","blocked","needs_root_input"].includes(o))throw Tu(o,r);if(!n?.trim())throw Lo("A blocker or required input is required.");let s=Mo(t,this.#e,{state:r,blockers:[n.trim()],resume_state:o});return await It(M(e,"intent.toon"),s),s}if(o==="blocked"||o==="needs_root_input"){if(r!==t.resume_state||t.blockers.length)throw Tu(o,r)}else if(!{scoping:["ready"],ready:["executing"],executing:["verifying"],verifying:["reviewing","executing"],reviewing:["executing"]}[o]?.includes(r))throw Tu(o,r);if(r==="ready"){let s=[];if(!t.goal.trim())s.push("goal_missing");if(!t.acceptance_criteria.length)s.push("acceptance_criteria_missing");if(t.plan_required&&t.active_plan_revision===void 0)s.push("required_plan_missing");if((t.active_plan_revision===void 0?void 0:await this.readPlan(t.id))?.open_questions.length)s.push("material_open_questions");if(s.length)throw new j("not_ready","Intent readiness predicates failed.",{reasons:s})}if(r==="executing"&&o==="ready")await this.#o(t);if(r==="reviewing"&&t.verification.required&&t.verification.status!=="passed")throw new j("invalid_transition","Verification must pass before review.");if(r==="reviewing")await this.#o(t);let i=Mo(t,this.#e,{state:r,resume_state:void 0});return await It(M(e,"intent.toon"),i),i}async#n(e,t){return await Au(M(e,".intent-store"),t)}async#a(e,t){if(t.state==="complete"||t.state==="abandoned")throw Tu(t.state,"abandoned");let r=Mo(t,this.#e,{state:"abandoned",blockers:[]});return await It(M(e,"intent.toon"),r),r}async#o(e){let t=await this.#i(),r=[...e.baseline.expected_changes].sort(),n=[...t.changedPaths].sort();if(t.root!==e.baseline.root||t.gitCommonDir!==e.baseline.git_common_dir||t.head!==e.baseline.expected_head||jT(t.statusDigest)!==e.baseline.expected_status_digest||r.join("\x00")!==n.join("\x00"))throw new j("repository_drift","Repository baseline no longer matches recorded assumptions.",{expected_head:e.baseline.expected_head,actual_head:t.head,expected_changes:r,actual_changes:n})}async#r(e){await this.#s();let t;try{t=await Ta(this.stateRoot)}catch(n){if(me(n,"ENOENT"))throw new j("not_found","Intent was not found.",{reference:e});throw Ce(n)}let r=[];for(let n of t.sort()){let o=M(this.stateRoot,n);if(!await Rh(o))continue;let i=M(o,"intent.toon");if(!await Oa(i))continue;let s=await this.#t(i);if(s.id===e||s.slug===e||n===e)r.push(o)}if(r.length===1)return r[0];if(r.length>1)throw new j("current_ambiguous","Intent reference is ambiguous.",{reference:e});throw new j("not_found","Intent was not found.",{reference:e})}async#t(e){let t=await GT(e),r=tn(Ra,t);if(pt(r))return r.right;let n=tn(_M,t);if(he(n))throw new j("schema_invalid","Persisted Intent failed schema validation.",{path:e,error:String(r.left)});let o=EM(n.right);return await It(e,o),o}}async function VT(e){let t=await pM(e),r=async(...a)=>{try{return(await Uh("git",["-C",t,...a],{encoding:"utf8"})).stdout.trim()}catch(c){throw new j("io_failure","Repository identity requires an accessible Git worktree.",{message:c instanceof Error?c.message:String(c)})}},n=await r("rev-parse","--git-common-dir"),o=await wM(t,"rev-parse","--verify","HEAD")??"unborn",i=await r("status","--porcelain=v1","--untracked-files=all"),s=i.split(`
|
|
43
|
+
`).filter(Boolean).map((a)=>a.slice(3).split(" -> ").at(-1)).sort();return{root:t,gitCommonDir:vu(t,n),head:o,changedPaths:s,statusDigest:Hn(i)}}async function wM(e,...t){try{return(await Uh("git",["-C",e,...t],{encoding:"utf8"})).stdout.trim()}catch{return}}function EM(e){return He(Ra,{...e,schema_version:Fu,toon_compatibility:$n,plan_required:!1,blockers:[],verification:Cu(!0),review:Cu(!0),acceptance_met:!1,root_readiness:!1,evidence:[]})}function Cu(e){return{required:e,status:e?"missing":"not_required",evidence:[]}}function Ou(e){return{...e,status:e.required?"missing":"not_required"}}function HT(e,t,r=e.head){return{root:e.root,git_common_dir:e.gitCommonDir,initial_head:r,expected_head:e.head,expected_changes:[...e.changedPaths].sort(),expected_status_digest:/^[a-f0-9]{64}$/u.test(e.statusDigest)?e.statusDigest:Hn(e.statusDigest),updated_at:t}}function jT(e){return/^[a-f0-9]{64}$/u.test(e)?e:Hn(e)}function Mo(e,t,r){return He(Ra,JT({...e,...r,revision:e.revision+1,updated_at:t().toISOString()}))}function $T(e,t,r){return He(ka,JT({...e,...r,revision:e.revision+1,updated_at:t().toISOString()}))}function JT(e){let t={...e};for(let[r,n]of Object.entries(t))if(n===void 0)delete t[r];return t}function OM(e){return e.normalize("NFKD").toLowerCase().replace(/[^a-z0-9]+/gu,"-").replace(/^-|-$/gu,"").slice(0,48).replace(/-$/u,"")||"intent"}function TM(e,t){let r=BT(e),n=BT(t).replace(/\/+$/u,"");if(!r||!n||r.startsWith("/")||n.startsWith("/")||/^[a-z]:\//u.test(r)||/^[a-z]:\//u.test(n)||r.split("/").includes("..")||n.split("/").includes(".."))return!1;return n==="."||r===n||r.startsWith(`${n}/`)}function BT(e){return e.trim().replaceAll("\\","/").replace(/^\.\//u,"")}function Hn(e){return uM("sha256").update(e).digest("hex")}function Er(e,t){if(t===void 0||e!==t)throw new j("stale_write","Persisted revision changed before mutation.",{expected_revision:t,actual_revision:e})}function Lo(e){return new j("invalid_input",e)}function Mi(e){if(e.state==="complete"||e.state==="abandoned")throw new j("invalid_transition","Terminal Intents cannot be mutated.",{state:e.state})}function Tu(e,t){return new j("invalid_transition",`Intent cannot transition from ${e} to ${t}.`,{source:e,target:t})}function He(e,t){let r=tn(e,t);if(he(r))throw new j("schema_invalid","Value failed Effect Schema validation.",{error:String(r.left)});return r.right}async function GT(e){let t;try{let r=await on(e);if(r.isSymbolicLink()||!r.isFile())throw new j("schema_invalid","Persistent work state must be a regular file.",{path:e});t=await Ch(e,"utf8")}catch(r){if(me(r,"ENOENT"))throw new j("not_found","Persistent work state was not found.",{path:e});throw Ce(r)}try{return yg(t,{strict:!0})}catch(r){throw new j("malformed_toon","Persistent work state is malformed TOON.",{path:e,message:r instanceof Error?r.message:String(r)})}}async function ku(e,t){return He(t,await GT(e))}async function It(e,t){await vh(e,`${zi(t)}
|
|
44
|
+
`)}async function vh(e,t){await Di(e),await Li(jn(e),{recursive:!0}),await Di(e);let r=M(jn(e),`.holycodex-write-${process.pid}-${crypto.randomUUID()}.tmp`);try{let n=await Pu(r,"wx",384);try{await n.writeFile(t,"utf8"),await n.sync()}finally{await n.close()}await fM(r,e),await YT(jn(e))}catch(n){throw await Aa(r,{force:!0}),Ce(n)}}async function kM(e,t){await Di(e);try{let r=await Pu(e,"wx",256);try{await r.writeFile(t,"utf8"),await r.sync()}finally{await r.close()}await YT(jn(e))}catch(r){if(me(r,"EEXIST"))throw new j("archive_conflict","Archived plans are immutable.",{path:e});throw Ce(r)}}async function YT(e){if(process.platform==="win32")return;try{let t=await Pu(e,"r");try{await t.sync()}finally{await t.close()}}catch(t){if(me(t,"EINVAL")||me(t,"ENOSYS")||me(t,"ENOTSUP")||me(t,"EOPNOTSUPP")||me(t,"EISDIR"))return;throw t}}async function Au(e,t){let r=jn(e);await Di(e),await Li(r,{recursive:!0});let n=!1;for(let a=0;a<200;a+=1)try{await Li(e),n=!0;break}catch(c){if(!me(c,"EEXIST"))throw Ce(c);try{let l=await on(e);if(l.isSymbolicLink()||!l.isDirectory())throw new j("schema_invalid","The work-state lock must be a real directory.",{path:e});let u=await ZT(e);if(u.kind==="owned"&&!await AM(u.owner.pid)){await Aa(e,{recursive:!0,force:!0});continue}if(u.kind==="missing"&&Date.now()-l.mtimeMs>xM){await Aa(e,{recursive:!0,force:!0});continue}}catch(l){if(!me(l,"ENOENT"))throw Ce(l)}await new Promise((l)=>setTimeout(l,Math.min(5+a,50)))}if(!n)throw new j("stale_write","Another mutation is still in progress.",{lock:e});let o=M(e,".owner"),i=crypto.randomUUID(),s;try{await Di(o),s=await Pu(o,"wx",384),await s.writeFile(`${JSON.stringify({pid:process.pid,token:i})}
|
|
45
|
+
`,"utf8"),await s.sync()}catch(a){if(s!==void 0)try{await s.close()}catch{}if(me(a,"EEXIST"))throw new j("stale_write","Another mutation is still in progress.",{lock:e});throw Ce(a)}if(s===void 0)throw Ce(Error("The work-state lock owner was not opened."));try{return await t()}finally{try{await s.close()}finally{await RM(e,i)}}}async function ZT(e){let t=M(e,".owner");try{let r=await on(t);if(r.isSymbolicLink()||!r.isFile())return{kind:"unknown"};let n=await Ch(t,"utf8"),o;try{o=JSON.parse(n)}catch{return{kind:"unknown"}}let i=tn(yM,o);return pt(i)?{kind:"owned",owner:i.right}:{kind:"unknown"}}catch(r){if(me(r,"ENOENT"))return{kind:"missing"};throw Ce(r)}}async function AM(e){if(e===process.pid)return!0;if(process.platform==="win32")return await IM(e);if(!["aix","android","darwin","freebsd","haiku","linux","openbsd","sunos","win32"].includes(process.platform))return!0;try{return process.kill(e,0),!0}catch(r){return me(r,"EPERM")}}async function IM(e){if(!Number.isSafeInteger(e)||e>SM)return!1;try{let{stdout:t}=await Uh("tasklist.exe",["/FI",`PID eq ${e}`,"/FO","CSV","/NH"],{encoding:"utf8",windowsHide:!0});return t.split(/\r?\n/u).some((r)=>/^"[^"]*","(\d+)",/u.exec(r)?.[1]===String(e))}catch{return!0}}async function RM(e,t){let r=await ZT(e);if(r.kind!=="owned"||r.owner.token!==t)return;await Aa(e,{recursive:!0,force:!0})}async function vM(e){let t=(await Ta(e)).map((r)=>/^plan\.old-(\d{3})\.toon$/u.exec(r)?.[1]).filter((r)=>r!==void 0).map(Number);return M(e,`plan.old-${String((t.length?Math.max(...t):0)+1).padStart(3,"0")}.toon`)}async function Iu(e){try{return await dM(e),!0}catch(t){if(me(t,"ENOENT"))return!1;throw Ce(t)}}async function Oa(e){try{let t=await on(e);return t.isFile()&&!t.isSymbolicLink()}catch(t){if(me(t,"ENOENT")||me(t,"ENOTDIR"))return!1;throw Ce(t)}}async function KT(e,t){try{let r=await on(e);if(r.isSymbolicLink()||!r.isDirectory())throw new j("schema_invalid","Persistent work-state directories must be real directories.",{path:e});return!0}catch(r){if(me(r,"ENOENT")&&t)return!1;throw Ce(r)}}async function Rh(e){try{let t=await on(e);return t.isDirectory()&&!t.isSymbolicLink()}catch(t){if(me(t,"ENOENT")||me(t,"ENOTDIR"))return!1;throw Ce(t)}}function WT(e,t,r,n){if(e.intent_id!==t||e.id!==r)throw new j("schema_invalid","Assignment provenance does not match its Intent or file name.",{path:n,expected_intent_id:t,actual_intent_id:e.intent_id,expected_assignment_id:r,actual_assignment_id:e.id})}async function Di(e){let t=vu(e);while(!0){try{if((await on(t)).isSymbolicLink())throw new j("schema_invalid","Persistent work state must not contain symbolic links.",{path:t})}catch(n){if(!me(n,"ENOENT"))throw Ce(n)}let r=jn(t);if(r===t)break;t=r}}function me(e,t){return typeof e==="object"&&e!==null&&"code"in e&&e.code===t}function Ce(e){return e instanceof j?e:new j("io_failure","Persistent work-state I/O failed.",{message:e instanceof Error?e.message:String(e)})}function CM(e,t){let r=hM(e,t);return r===""||!r.startsWith(`..${PM()}`)&&r!==".."&&!mM(r)}function PM(){return process.platform==="win32"?"\\":"/"}var QT={intent:`Usage: holycodex-agent intent <command> [options]
|
|
46
|
+
|
|
47
|
+
Intent owns the durable global goal, lifecycle, baseline, blockers, gates, and readiness.
|
|
48
|
+
Commands: create, list, current, read, select, transition, evidence, complete, abandon.
|
|
49
|
+
Reads emit validated JSON. Mutations are atomic; stale revisions and invalid transitions fail.
|
|
50
|
+
`,"intent create":`Usage: holycodex-agent intent create --input <json> [--repo <path>]
|
|
51
|
+
|
|
52
|
+
Input: {"title":string,"goal":string,"acceptanceCriteria":string[],"planRequired"?:boolean,
|
|
53
|
+
"verificationRequired"?:boolean,"reviewRequired"?:boolean}. Output: created Intent.
|
|
54
|
+
Effect: creates .holycodex/{slug}-{short-id}/intent.toon and selects it as current.
|
|
55
|
+
Fails for invalid input, inaccessible Git repository, collision exhaustion, or I/O failure.
|
|
56
|
+
`,"intent list":`Usage: holycodex-agent intent list [--repo <path>]
|
|
57
|
+
|
|
58
|
+
Output: validated Intents sorted by id. Effect: interrupted temporary writes are removed.
|
|
59
|
+
Fails if persisted TOON is malformed or violates the current schema.
|
|
60
|
+
`,"intent current":`Usage: holycodex-agent intent current [--repo <path>]
|
|
61
|
+
|
|
62
|
+
Output: selected current Intent. No mutation. Fails when absent, ambiguous, or invalid.
|
|
63
|
+
`,"intent read":`Usage: holycodex-agent intent read --intent <id|slug|directory> [--repo <path>]
|
|
64
|
+
|
|
65
|
+
Output: one validated Intent. Effect: supported legacy schema is migrated atomically.
|
|
66
|
+
`,"intent select":`Usage: holycodex-agent intent select --intent <id|slug|directory> [--repo <path>]
|
|
67
|
+
|
|
68
|
+
Output: selected Intent. Effect: atomically changes the repository-local current pointer.
|
|
69
|
+
`,"intent transition":`Usage: holycodex-agent intent transition --intent <ref> --revision <n> --state <state> [--blocker <text>] [--repo <path>]
|
|
70
|
+
|
|
71
|
+
Output: revised Intent. Effect: applies one guarded lifecycle transition.
|
|
72
|
+
blocked/needs_root_input require --blocker. Use intent complete for completion.
|
|
73
|
+
`,"intent evidence":`Usage: holycodex-agent intent evidence --intent <ref> --revision <n> --input <json> [--repo <path>]
|
|
74
|
+
|
|
75
|
+
Input may record evidence, verification, review, acceptanceMet, rootReadiness, clearBlockers.
|
|
76
|
+
Effect: atomically updates Root-owned global proof. Review rejection returns to executing.
|
|
77
|
+
`,"intent complete":`Usage: holycodex-agent intent complete --intent <ref> --revision <n> [--repo <path>]
|
|
78
|
+
|
|
79
|
+
Output: completed Intent or completion_refused with machine-readable reasons.
|
|
80
|
+
Effect: completes only after assignments, blockers, verification, review, acceptance, and Root readiness pass.
|
|
81
|
+
`,"intent abandon":`Usage: holycodex-agent intent abandon --intent <ref> --revision <n> [--repo <path>]
|
|
82
|
+
|
|
83
|
+
Output: abandoned Intent. Effect: closes incomplete work without claiming completion.
|
|
84
|
+
`,plan:`Usage: holycodex-agent plan <read|revise> [options]
|
|
85
|
+
|
|
86
|
+
Plan is optional and describes execution. revise archives an existing canonical plan first.
|
|
87
|
+
`,"plan read":`Usage: holycodex-agent plan read --intent <ref> [--repo <path>]
|
|
88
|
+
|
|
89
|
+
Output: current validated Plan or null. No mutation.
|
|
90
|
+
`,"plan revise":`Usage: holycodex-agent plan revise --intent <ref> --revision <n> [--plan-revision <n>] --input <json> [--repo <path>]
|
|
91
|
+
|
|
92
|
+
Input requires approach and may include scope, assignments, dependencies, architecture, risks,
|
|
93
|
+
assumptions, openQuestions, verification, and recovery. Effect: archives plan.old-NNN.toon
|
|
94
|
+
immutably before atomic replacement. Fails on stale Intent or Plan revision.
|
|
95
|
+
`,assignment:`Usage: holycodex-agent assignment <create|list|read|start|result> [options]
|
|
96
|
+
|
|
97
|
+
Assignments are bounded specialist contracts. Their results never own global lifecycle state.
|
|
98
|
+
`,"assignment create":`Usage: holycodex-agent assignment create --intent <ref> --revision <n> --input <json> [--repo <path>]
|
|
99
|
+
|
|
100
|
+
Input requires objective, owner, scope, and acceptanceCriteria. Effect: creates one atomic
|
|
101
|
+
assignments/{id}.toon after repository drift validation.
|
|
102
|
+
`,"assignment list":`Usage: holycodex-agent assignment list --intent <ref> [--repo <path>]
|
|
103
|
+
|
|
104
|
+
Output: validated Assignments sorted by id. No mutation.
|
|
105
|
+
`,"assignment read":`Usage: holycodex-agent assignment read --intent <ref> --assignment <id> [--repo <path>]
|
|
106
|
+
|
|
107
|
+
Output: one validated Assignment. No mutation.
|
|
108
|
+
`,"assignment start":`Usage: holycodex-agent assignment start --intent <ref> --assignment <id> --revision <n> [--repo <path>]
|
|
109
|
+
|
|
110
|
+
Effect: marks a pending/blocked/failed Assignment executing. Completed work cannot restart.
|
|
111
|
+
`,"assignment result":`Usage: holycodex-agent assignment result --intent <ref> --assignment <id> --revision <n> --input <json> [--repo <path>]
|
|
112
|
+
|
|
113
|
+
Input requires outcome and summary; supports compact invocation metadata, evidence, blocker,
|
|
114
|
+
and remainingRisk. Effect: appends one invocation and accepts only declared repository evolution.
|
|
115
|
+
`};function Hh(e){return QT[e.slice(0,2).join(" ")]??QT[e[0]??""]??`Usage: holycodex-agent <intent|plan|assignment> <command> [options]
|
|
116
|
+
|
|
117
|
+
Deterministic model-facing work-state API. JSON responses use holycodex-agent-response-1.
|
|
118
|
+
All mutations require --revision and are atomic. No command prompts or emits ANSI.
|
|
119
|
+
|
|
120
|
+
Commands:
|
|
121
|
+
intent create, list, current, read, select, transition, evidence, complete, abandon
|
|
122
|
+
plan read, revise
|
|
123
|
+
assignment create, list, read, start, result
|
|
124
|
+
|
|
125
|
+
Use -h or --help at any command depth. Failures are classified and exit nonzero.
|
|
126
|
+
`}function jh(e){return e.includes("-h")||e.includes("--help")||e.length===0}var XT="holycodex-agent-response-1",FM=V(le);async function NM(e=Bun.argv.slice(2),t={cwd:process.cwd(),writeStdout:(r)=>process.stdout.write(r),writeStderr:(r)=>process.stderr.write(r)}){try{let r=$h(FM,e),n=r.filter((a)=>!a.startsWith("-")).slice(0,2);if(jh(r))return t.writeStdout(Hh(n)),0;let o=LM(r),i=new Uu(o.options.repo??t.cwd??process.cwd()),s=await MM(i,o.command,o.subcommand,o.options);return t.writeStdout(`${JSON.stringify({schema_version:XT,ok:!0,operation:`${o.command}.${o.subcommand}`,data:s})}
|
|
127
|
+
`),0}catch(r){let n=UM(r);return t.writeStderr(`${JSON.stringify({schema_version:XT,ok:!1,error:n})}
|
|
128
|
+
`),n.code==="invalid_usage"||n.code==="invalid_input"?2:n.code==="completion_refused"?3:1}}async function MM(e,t,r,n){let o=n.intent;if(t==="intent"){if(r==="create")return await e.createIntent(va(Nu,sn(n,"input")));if(r==="list")return await e.listIntents();if(r==="current")return await e.currentIntent();if(r==="read")return await e.readIntent(St(o,"intent"));if(r==="select")return await e.selectCurrent(St(o,"intent"));if(r==="transition")return await e.transitionIntent(St(o,"intent"),$h(qi,sn(n,"state")),Bn(n),n.blocker);if(r==="evidence")return await e.recordIntentEvidence(St(o,"intent"),Bn(n),va(qu,sn(n,"input")));if(r==="abandon")return await e.abandonIntent(St(o,"intent"),Bn(n));if(r==="complete"){let i=await e.completeIntent(St(o,"intent"),Bn(n));if("completed"in i&&!i.completed)throw new $t("completion_refused","Intent completion predicates failed.",{reasons:i.reasons});return i}}if(t==="plan"){if(r==="read")return await e.readPlan(St(o,"intent"))??null;if(r==="revise")return await e.revisePlan(St(o,"intent"),va(Mu,sn(n,"input")),Bn(n),qM(n["plan-revision"]))}if(t==="assignment"){if(r==="create")return await e.createAssignment(St(o,"intent"),va(Lu,sn(n,"input")),Bn(n));if(r==="list")return await e.listAssignments(St(o,"intent"));if(r==="read")return await e.readAssignment(St(o,"intent"),sn(n,"assignment"));if(r==="start")return await e.startAssignment(St(o,"intent"),sn(n,"assignment"),Bn(n));if(r==="result")return await e.recordAssignmentResult(St(o,"intent"),sn(n,"assignment"),Bn(n),va(Du,sn(n,"input")))}throw new $t("invalid_usage","Unknown command. Use --help.")}function LM(e){let t=e[0],r=e[1];if(!t||!r||t.startsWith("-")||r.startsWith("-"))throw new $t("invalid_usage","A command and subcommand are required. Use --help.");let n={},o=DM(t,r);for(let i=2;i<e.length;i+=2){let s=e[i],a=e[i+1];if(!s?.startsWith("--")||a===void 0||a.startsWith("--"))throw new $t("invalid_usage","Options require --name value pairs.");let c=s.slice(2);if(n[c]!==void 0)throw new $t("invalid_usage",`Duplicate option --${c}.`);if(!o.has(c))throw new $t("invalid_usage",`Unknown option --${c}.`);n[c]=a}return{command:t,subcommand:r,options:n}}function DM(e,t){let r=["repo"],n={"intent create":["input"],"intent list":[],"intent current":[],"intent read":["intent"],"intent select":["intent"],"intent transition":["intent","revision","state","blocker"],"intent evidence":["intent","revision","input"],"intent complete":["intent","revision"],"intent abandon":["intent","revision"],"plan read":["intent"],"plan revise":["intent","revision","plan-revision","input"],"assignment create":["intent","revision","input"],"assignment list":["intent"],"assignment read":["intent","assignment"],"assignment start":["intent","assignment","revision"],"assignment result":["intent","assignment","revision","input"]};return new Set([...r,...n[`${e} ${t}`]??[]])}class $t extends Error{code;details;constructor(e,t,r={}){super(t);this.code=e,this.details=r}}function va(e,t){let r;try{r=JSON.parse(t)}catch{throw new $t("invalid_input","--input must be valid JSON.")}return $h(e,r)}function $h(e,t){let r=yu(e,{onExcessProperty:"error"})(t);if(he(r))throw new $t("invalid_input","Input failed Effect Schema validation.",{issue:String(r.left)});return r.right}function sn(e,t){return St(e[t],t)}function St(e,t){if(!e)throw new $t("invalid_usage",`Missing --${t}.`);return e}function Bn(e){return ek(e.revision,"revision")}function ek(e,t){let r=Number(e);if(!Number.isSafeInteger(r)||r<1)throw new $t("invalid_input",`--${t} must be a positive integer.`);return r}function qM(e){return e===void 0?void 0:ek(e,"plan-revision")}function UM(e){if(e instanceof j||e instanceof $t)return{code:e.code,message:e.message,details:e.details};return{code:"internal_error",message:e instanceof Error?e.message:"Agent CLI failed.",details:{}}}if(import.meta.main)process.exitCode=await NM();export{Hh as agentHelp,jh as agentHelpRequested,NM as runAgentBinary};
|