sketchi 0.0.2 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/sketchi.js CHANGED
@@ -1,56 +1,21 @@
1
1
  #!/usr/bin/env node
2
- import{createRequire as e}from"node:module";let t=e(import.meta.url);var r,n,i={2532(e){let{hasOwnProperty:t}=Object.prototype,r=(e,t={})=>{"string"==typeof t&&(t={section:t}),t.align=!0===t.align,t.newline=!0===t.newline,t.sort=!0===t.sort,t.whitespace=!0===t.whitespace||!0===t.align,t.platform=t.platform||"u">typeof process&&process.platform,t.bracketedArray=!1!==t.bracketedArray;let i="win32"===t.platform?"\r\n":"\n",s=t.whitespace?" = ":"=",o=[],l=t.sort?Object.keys(e).sort():Object.keys(e),c=0;t.align&&(c=a(l.filter(t=>null===e[t]||Array.isArray(e[t])||"object"!=typeof e[t]).map(t=>Array.isArray(e[t])?`${t}[]`:t).concat([""]).reduce((e,t)=>a(e).length>=a(t).length?e:t)).length);let u="",d=t.bracketedArray?"[]":"";for(let t of l){let r=e[t];if(r&&Array.isArray(r))for(let e of r)u+=a(`${t}${d}`).padEnd(c," ")+s+a(e)+i;else r&&"object"==typeof r?o.push(t):u+=a(t).padEnd(c," ")+s+a(r)+i}for(let s of(t.section&&u.length&&(u="["+a(t.section)+"]"+(t.newline?i+i:i)+u),o)){let a=n(s,".").join("\\."),o=(t.section?t.section+".":"")+a,l=r(e[s],{...t,section:o});u.length&&l.length&&(u+=i),u+=l}return u};function n(e,t){var r=0,n=0,i=0,s=[];do if(-1!==(i=e.indexOf(t,r))){if(r=i+t.length,i>0&&"\\"===e[i-1])continue;s.push(e.slice(n,i)),n=i+t.length}while(-1!==i)return s.push(e.slice(n)),s}let i=(e,r={})=>{r.bracketedArray=!1!==r.bracketedArray;let i=Object.create(null),s=i,a=null,l=/^\[([^\]]*)\]\s*$|^([^=]+)(=(.*))?$/i,c=e.split(/[\r\n]+/g),u={};for(let e of c){let n;if(!e||e.match(/^\s*[;#]/)||e.match(/^\s*$/))continue;let c=e.match(l);if(!c)continue;if(void 0!==c[1]){if("__proto__"===(a=o(c[1]))){s=Object.create(null);continue}s=i[a]=i[a]||Object.create(null);continue}let d=o(c[2]);r.bracketedArray?n=d.length>2&&"[]"===d.slice(-2):(u[d]=(u?.[d]||0)+1,n=u[d]>1);let f=n&&d.endsWith("[]")?d.slice(0,-2):d;if("__proto__"===f)continue;let h=!c[3]||o(c[4]),p="true"===h||"false"===h||"null"===h?JSON.parse(h):h;n&&(t.call(s,f)?Array.isArray(s[f])||(s[f]=[s[f]]):s[f]=[]),Array.isArray(s[f])?s[f].push(p):s[f]=p}let d=[];for(let e of Object.keys(i)){if(!t.call(i,e)||"object"!=typeof i[e]||Array.isArray(i[e]))continue;let r=n(e,".");s=i;let a=r.pop(),o=a.replace(/\\\./g,".");for(let e of r)"__proto__"!==e&&(t.call(s,e)&&"object"==typeof s[e]||(s[e]=Object.create(null)),s=s[e]);(s!==i||o!==a)&&(s[o]=i[e],d.push(e))}for(let e of d)delete i[e];return i},s=e=>e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"),a=e=>"string"!=typeof e||e.match(/[=\r\n]/)||e.match(/^\[/)||e.length>1&&s(e)||e!==e.trim()?JSON.stringify(e):e.split(";").join("\\;").split("#").join("\\#"),o=e=>{if(s(e=(e||"").trim())){"'"===e.charAt(0)&&(e=e.slice(1,-1));try{e=JSON.parse(e)}catch{}}else{let t=!1,r="";for(let n=0,i=e.length;n<i;n++){let i=e.charAt(n);if(t)-1!=="\\;#".indexOf(i)?r+=i:r+="\\"+i,t=!1;else if(-1!==";#".indexOf(i))break;else"\\"===i?t=!0:r+=i}return t&&(r+="\\"),r.trim()}return e};e.exports={parse:i,decode:i,stringify:r,encode:r,safe:a,unsafe:o}},3176(e,t,r){var n=r(3633),i=r(4239);e.exports={parse:function(e,t){var r=e.toString(),s=n.parse(r,t);return i.compile(s,r,t)}}},4239(e){e.exports={compile:function(e,t,r){var n=null;if((r=r||{}).useTemporal&&!(n=r.temporal||("u">typeof Temporal?Temporal:null)))throw Error("The `useTemporal` option was set, but no Temporal implementation is available. Use a runtime with global `Temporal` support, or provide an implementation (e.g. from the `@js-temporal/polyfill` package) via the `temporal` option.");for(var i=new Set,s=new Set,a=new Set,o=[],l=new WeakSet,c=b(),u=c,d=e,f,h=0;h<d.length;h++)switch((f=d[h]).type){case"Assign":!function(e){var t=e.key,r=e.value,l=e.offset;Array.isArray(t)||(t=[t]);for(var c=function e(t){if("Array"===t.type)return t.value.map(e);if("InlineTable"===t.type)return function(t){for(var r=b(),n=new Set,i=0;i<t.length;i++){var s=t[i];if("InlineTableValue"===s.type){var a=s.key;Array.isArray(a)||(a=[a]),function(e,t,r,n,i){for(var s=0;s<t.length-1;s++){var a=t[s],o=w(t.slice(0,s+1));void 0===e[a]?e[a]=b():"object"!=typeof e[a]||null===e[a]||Array.isArray(e[a])?p("Cannot redefine existing key '"+o+"'.",n):i&&i.has(o)&&p("Cannot extend inline table '"+o+"'.",n),e=e[a]}var l=t[t.length-1];void 0!==e[l]&&p("Cannot redefine existing key '"+w(t)+"'.",n),e[l]=r}(r,a,e(s.value),s.offset,n),n.add(w(a))}}return r}(t.value);if(n)switch(t.type){case"Date":return n.ZonedDateTime.from(m(t.raw)+t.tz+"["+("Z"===t.tz?"UTC":t.tz)+"]");case"LocalDateTime":return n.PlainDateTime.from(m(t.value));case"LocalDate":return n.PlainDate.from(t.value);case"LocalTime":return n.PlainTime.from(m(t.value))}return t.value}(r),d=u,f=0;f<t.length-1;f++){var h=t[f],g=x(t.slice(0,f+1));void 0===d[h]?(d[h]=b(),i.add(g)):"object"!=typeof d[h]||null===d[h]||Array.isArray(d[h])||s.has(g)?p("Cannot redefine existing key '"+g+"'.",l):a.has(g)&&g!==w(o)&&p("Cannot use dotted keys to extend table '"+g+"' defined elsewhere.",l),d=d[h]}var y=t[t.length-1],v=x(t);void 0!==d[y]&&p("Cannot redefine existing key '"+v+"'.",l),d[y]=c,i.add(v),s.add(v)}(f);break;case"ObjectPath":!function(e){var t=e.value,r=t.map(y).join("."),n=e.offset;i.has(r)&&p("Cannot redefine existing key '"+t+"'.",n),i.add(r),a.add(r),u=g(c,t,b(),n),o=t}(f);break;case"ArrayPath":!function(e){var t=e.value,r=t.map(y).join("."),n=e.offset;if(s.has(r)&&p("Cannot append to statically defined array '"+r+"'.",n),i.forEach(function(e){k(e,r)&&i.delete(e)}),s.forEach(function(e){k(e,r)&&s.delete(e)}),i.add(r),u=g(c,t,function(){var e=[];return l.add(e),e}(),n),o=t,u instanceof Array){var a=b();u.push(a),u=a}else p("Cannot redefine existing key '"+t+"'.",n)}(f)}return c;function p(e,r){var n=function(e){for(var r=1,n=1,i=0;i<e;i++)10===t.charCodeAt(i)?(r++,n=1):n++;return{line:r,column:n}}(r),i=Error(e);throw i.line=n.line,i.column=n.column,i}function m(e){return e.replace(/\.(\d{9})\d+/,".$1")}function g(e,t,r,n){for(var i=e,a=0;a<t.length;a++){var o=t[a],l=w(t.slice(0,a+1));void 0===i[o]?a===t.length-1?i[o]=r:i[o]=b():a!==t.length-1&&s.has(l)&&p("Cannot redefine existing key '"+l+"'.",n),i=i[o],a<t.length-1&&(v(i)||p("Cannot redefine existing key '"+l+"'.",n),i instanceof Array&&(i.length||p("Cannot redefine existing key '"+l+"'.",n),v(i=i[i.length-1])||p("Cannot redefine existing key '"+l+"'.",n)))}return i}function y(e){return e.indexOf(".")>-1?'"'+e+'"':e}function b(){var e=Object.create(null);return l.add(e),e}function v(e){return null!==e&&"object"==typeof e&&l.has(e)}function w(e){return e.map(y).join(".")}function x(e){return w(o.concat(e))}function k(e,t){return e===t||0===e.indexOf(t+".")}}}},3633(e){class t extends SyntaxError{constructor(e,t,r,n){super(e),this.expected=t,this.found=r,this.location=n,this.name="SyntaxError"}format(e){let t="Error: "+this.message;if(this.location){let r=null,n=e.find(e=>e.source===this.location.source);n&&(r=n.text.split(/\r\n|\n|\r/g));let i=this.location.start,s=this.location.source&&"function"==typeof this.location.source.offset?this.location.source.offset(i):i,a=this.location.source+":"+s.line+":"+s.column;if(r){let e=this.location.end,n="".padEnd(s.line.toString().length," "),o=r[i.line-1],l=(i.line===e.line?e.column:o.length+1)-i.column||1;t+="\n --\x3e "+a+"\n"+n+" |\n"+s.line+" | "+o+"\n"+n+" | "+"".padEnd(i.column-1," ")+"".padEnd(l,"^")}else t+="\n at "+a}return t}static buildMessage(e,t){function r(e){return e.codePointAt(0).toString(16).toUpperCase()}let n=Object.prototype.hasOwnProperty.call(RegExp.prototype,"unicode")?RegExp("[\\p{C}\\p{Mn}\\p{Mc}]","gu"):null;function i(e){return n?e.replace(n,e=>"\\u{"+r(e)+"}"):e}function s(e){return i(e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,e=>"\\x0"+r(e)).replace(/[\x10-\x1F\x7F-\x9F]/g,e=>"\\x"+r(e)))}function a(e){return i(e.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,e=>"\\x0"+r(e)).replace(/[\x10-\x1F\x7F-\x9F]/g,e=>"\\x"+r(e)))}let o={literal:e=>'"'+s(e.text)+'"',class(e){let t=e.parts.map(e=>Array.isArray(e)?a(e[0])+"-"+a(e[1]):a(e));return"["+(e.inverted?"^":"")+t.join("")+"]"+(e.unicode?"u":"")},any:()=>"any character",end:()=>"end of input",other:e=>e.description};function l(e){return o[e.type](e)}return"Expected "+function(e){let t=e.map(l);if(t.sort(),t.length>0){let e=1;for(let r=1;r<t.length;r++)t[r-1]!==t[r]&&(t[e]=t[r],e++);t.length=e}switch(t.length){case 1:return t[0];case 2:return t[0]+" or "+t[1];default:return t.slice(0,-1).join(", ")+", or "+t[t.length-1]}}(e)+" but "+(t?'"'+s(t)+'"':"end of input")+" found."}}e.exports={StartRules:["start"],SyntaxError:t,parse:function(e,r){let n,i={},s=(r=void 0!==r?r:{}).grammarSource,a={start:eP},o=eP,l="true",c="false",u=/^[\t -~\x80-\uFFFF]/,d=/^[+\-]/,f=/^[^"\\\0-\b\v-\x1F\x7F\r]/,h=/^[^'\0-\b\v-\x1F\x7F\r]/,p=/^[^"\\\0-\b\n-\x1F\x7F]/,m=/^[^'\0-\b\n-\x1F\x7F]/,g=/^[eE]/,y=/^[0-9_]/,b=/^[1-9]/,v=/^[_]/,w=/^[0-9]/,x=/^[0-9a-fA-F]/,k=/^[0-7]/,S=/^[01]/,_=/^[ \t]/,$=/^[A-Za-z0-9_\-]/,O=/^["\\btnfre]/,I=eM("#",!1),C=eN([" ",[" ","~"],["€","￿"]],!1,!1,!1),E=eM("[",!1),A=eM("]",!1),T=eM(".",!1),M=eM("=",!1),N=eN(["+","-"],!1,!1,!1),j=eM("inf",!1),F=eM("nan",!1),L=eM('"""',!1),P=eM('"',!1),D=eM("'''",!1),R=eM("'",!1),U=eM("\\",!1),B={type:"any"},q=eM("\r\n",!1),K=eN(['"',"\\",["\0","\b"],["\v","\x1f"],"","\r"],!0,!1,!1),z=eM('""',!1),V=eN(["'",["\0","\b"],["\v","\x1f"],"","\r"],!0,!1,!1),J=eM("''",!1),W=eN(['"',"\\",["\0","\b"],["\n","\x1f"],""],!0,!1,!1),Y=eN(["'",["\0","\b"],["\n","\x1f"],""],!0,!1,!1),G=eN(["e","E"],!1,!1,!1),H=eM("0",!1),Q=eM("0x",!1),Z=eM("0o",!1),X=eM("0b",!1),ee=eN([["0","9"],"_"],!1,!1,!1),et=eN([["1","9"]],!1,!1,!1),er=eN(["_"],!1,!1,!1),en=eN([["0","9"]],!1,!1,!1),ei=eN([["0","9"],["a","f"],["A","F"]],!1,!1,!1),es=eN([["0","7"]],!1,!1,!1),ea=eN(["0","1"],!1,!1,!1),eo=eM("true",!1),el=eM("false",!1),ec=eM(",",!1),eu=eM("{",!1),ed=eM("}",!1),ef=eM("-",!1),eh=eM(":",!1),ep=eM("Z",!0),em=eM("T",!0),eg=eM(" ",!1),ey=eN([" "," "],!1,!1,!1),eb=eM("\n",!1),ev=eM("\r",!1),ew=eM("\uFEFF",!1),ex=eN([["A","Z"],["a","z"],["0","9"],"_","-"],!1,!1,!1),ek=eN(['"',"\\","b","t","n","f","r","e"],!1,!1,!1),eS=eM("\\U",!1),e_=eM("\\u",!1),e$=eM("\\x",!1),eO=0|r.peg$currPos,eI=eO,eC=[{line:1,column:1}],eE=eO,eA=r.peg$maxFailExpected||[],eT=0|r.peg$silentFails;if(r.startRule){if(!(r.startRule in a))throw Error("Can't start parsing from rule \""+r.startRule+'".');o=a[r.startRule]}function eM(e,t){return{type:"literal",text:e,ignoreCase:t}}function eN(e,t,r,n){return{type:"class",parts:e,inverted:t,ignoreCase:r,unicode:n}}function ej(t){let r,n=eC[t];if(n)return n;if(t>=eC.length)r=eC.length-1;else for(r=t;!eC[--r];);for(n={line:(n=eC[r]).line,column:n.column};r<t;)10===e.charCodeAt(r)?(n.line++,n.column=1):n.column++,r++;return eC[t]=n,n}function eF(e,t,r){let n=ej(e),i=ej(t),a={source:s,start:{offset:e,line:n.line,column:n.column},end:{offset:t,line:i.line,column:i.column}};return r&&s&&"function"==typeof s.offset&&(a.start=s.offset(a.start),a.end=s.offset(a.end)),a}function eL(e){eO<eE||(eO>eE&&(eE=eO,eA=[]),eA.push(e))}function eP(){let t,r,n,s;for(t=eO,65279===e.charCodeAt(eO)?(s="\uFEFF",eO++):(s=i,0===eT&&eL(ew)),s===i,r=[],n=eD();n!==i;)r.push(n),n=eD();return eI=t,t=tl}function eD(){let t,r,n,s,a,o,l,c;for(t=eO,r=[],n=te();n!==i;)r.push(n),n=te();if((c=eR())===i&&(c=function(){let t,r,n,s,a,o,l,c;if(t=eO,91===e.charCodeAt(eO)?(r="[",eO++):(r=i,0===eT&&eL(E)),r!==i)if(91===e.charCodeAt(eO)?(n="[",eO++):(n=i,0===eT&&eL(E)),n!==i){for(s=[],a=te();a!==i;)s.push(a),a=te();if((a=eU())!==i){for(o=[],l=te();l!==i;)o.push(l),l=te();(93===e.charCodeAt(eO)?(l="]",eO++):(l=i,0===eT&&eL(A)),l!==i&&(93===e.charCodeAt(eO)?(c="]",eO++):(c=i,0===eT&&eL(A)),c!==i))?t=void tf(th("ArrayPath",a,eI=t)):(eO=t,t=i)}else eO=t,t=i}else eO=t,t=i;else eO=t,t=i;if(t===i)if(t=eO,91===e.charCodeAt(eO)?(r="[",eO++):(r=i,0===eT&&eL(E)),r!==i){for(n=[],s=te();s!==i;)n.push(s),s=te();if((s=eU())!==i){for(a=[],o=te();o!==i;)a.push(o),o=te();(93===e.charCodeAt(eO)?(o="]",eO++):(o=i,0===eT&&eL(A)),o!==i)?t=void tf(th("ObjectPath",s,eI=t)):(eO=t,t=i)}else eO=t,t=i}else eO=t,t=i;return t}())===i&&(c=function(){let t,r,n,s,a,o;if(t=eO,(r=e5())!==i){for(n=[],s=te();s!==i;)n.push(s),s=te();if(61===e.charCodeAt(eO)?(s="=",eO++):(s=i,0===eT&&eL(M)),s!==i){for(a=[],o=te();o!==i;)a.push(o),o=te();if((o=eK())!==i)t=void tf(th("Assign",o,eI=t,r));else eO=t,t=i}else eO=t,t=i}else eO=t,t=i;return t}()),(n=c)!==i){for(s=[],a=te();a!==i;)s.push(a),a=te();if((a=eR())===i&&(a=null),o=[],(l=tt())!==i)for(;l!==i;)o.push(l),l=tt();else o=i;o===i&&(o=tn()),o!==i?t=r=[r,n,s,a,o]:(eO=t,t=i)}else eO=t,t=i;if(t===i){if(t=eO,r=[],(n=te())!==i)for(;n!==i;)r.push(n),n=te();else r=i;if(r!==i){if(n=[],(s=tt())!==i)for(;s!==i;)n.push(s),s=tt();else n=i;n===i&&(n=tn()),n!==i?t=r=[r,n]:(eO=t,t=i)}else eO=t,t=i;t===i&&(t=tt())}return t}function eR(){let t,r,n,s;if(t=eO,35===e.charCodeAt(eO)?(r="#",eO++):(r=i,0===eT&&eL(I)),r!==i){for(n=[],s=e.charAt(eO),u.test(s)?eO++:(s=i,0===eT&&eL(C));s!==i;)n.push(s),s=e.charAt(eO),u.test(s)?eO++:(s=i,0===eT&&eL(C));t=r=[r,n]}else eO=t,t=i;return t}function eU(){let e,t,r;if(e=eO,t=[],(r=eq())!==i)for(;r!==i;)t.push(r),r=eq();else t=i;if(t!==i)if((r=eB())!==i){var n,s;eI=e,n=t,s=r,e=n.concat(s)}else eO=e,e=i;else eO=e,e=i;return e===i&&(e=eO,(t=eB())!==i&&(eI=e,t=[t]),e=t),e}function eB(){let e,t,r,n,s;for(e=eO,t=[],r=te();r!==i;)t.push(r),r=te();if((r=e8())!==i){for(n=[],s=te();s!==i;)n.push(s),s=te();eI=e,e=r}else eO=e,e=i;return e}function eq(){let t,r,n,s,a;for(t=eO,r=[],n=te();n!==i;)r.push(n),n=te();if((n=e8())!==i){for(s=[],a=te();a!==i;)s.push(a),a=te();(46===e.charCodeAt(eO)?(a=".",eO++):(a=i,0===eT&&eL(T)),a!==i)?(eI=t,t=n):(eO=t,t=i)}else eO=t,t=i;return t}function eK(){let t,r;return(t=eO,eI=eO,++tc>tu&&(tc--,td("Maximum nesting depth of "+tu+" exceeded.",eI)),void 0!==i&&(r=function(){let t,r,n,s,a,o,u,f,h,p,m,b,w,_,$,O,I;if(t=eO,(a=eO,'"""'===e.substr(eO,3)?(o='"""',eO+=3):(o=i,0===eT&&eL(L)),o!==i&&(tt()===i,u=function(){let t,r,n,s,a,o,l,c,u,d,f;for(t=eO,r=[],n=eJ();n!==i;)r.push(n),n=eJ();if(n=[],s=eO,(a=eW())!==i){if(o=[],(l=eJ())!==i)for(;l!==i;)o.push(l),l=eJ();else o=i;o!==i?s=a=[a,o]:(eO=s,s=i)}else eO=s,s=i;for(;s!==i;)if(n.push(s),s=eO,(a=eW())!==i){if(o=[],(l=eJ())!==i)for(;l!==i;)o.push(l),l=eJ();else o=i;o!==i?s=a=[a,o]:(eO=s,s=i)}else eO=s,s=i;return c=eO,'""'===e.substr(eO,2)?(u='""',eO+=2):(u=i,0===eT&&eL(z)),u!==i?(d=eO,eT++,'"""'===e.substr(eO,3)?(f='"""',eO+=3):(f=i,0===eT&&eL(L)),eT--,f!==i?(eO=d,d=void 0):d=i,d!==i?(eI=c,c='""'):(eO=c,c=i)):(eO=c,c=i),c===i&&(c=eO,34===e.charCodeAt(eO)?(u='"',eO++):(u=i,0===eT&&eL(P)),u!==i?(d=eO,eT++,'"""'===e.substr(eO,3)?(f='"""',eO+=3):(f=i,0===eT&&eL(L)),eT--,f!==i?(eO=d,d=void 0):d=i,d!==i?(eI=c,c='"'):(eO=c,c=i)):(eO=c,c=i)),(s=c)===i&&(s=null),eI=t,t=function(e,t,r){for(var n=e.join(""),i=0;i<t.length;i++)n+=t[i][0]+t[i][1].join("");return n+(r||"")}(r,n,s)}(),'"""'===e.substr(eO,3)?(f='"""',eO+=3):(f=i,0===eT&&eL(L)),f!==i))?a=th("String",u,eI=a):(eO=a,a=i),(s=a)===i&&(s=ez())===i&&((h=eO,"'''"===e.substr(eO,3)?(p="'''",eO+=3):(p=i,0===eT&&eL(D)),p!==i&&(tt()===i,m=function(){let t,r,n,s,a,o,l,c,u,d,f;for(t=eO,r=[],n=eY();n!==i;)r.push(n),n=eY();if(n=[],s=eO,(a=eG())!==i){if(o=[],(l=eY())!==i)for(;l!==i;)o.push(l),l=eY();else o=i;o!==i?s=a=[a,o]:(eO=s,s=i)}else eO=s,s=i;for(;s!==i;)if(n.push(s),s=eO,(a=eG())!==i){if(o=[],(l=eY())!==i)for(;l!==i;)o.push(l),l=eY();else o=i;o!==i?s=a=[a,o]:(eO=s,s=i)}else eO=s,s=i;return c=eO,"''"===e.substr(eO,2)?(u="''",eO+=2):(u=i,0===eT&&eL(J)),u!==i?(d=eO,eT++,"'''"===e.substr(eO,3)?(f="'''",eO+=3):(f=i,0===eT&&eL(D)),eT--,f!==i?(eO=d,d=void 0):d=i,d!==i?(eI=c,c="''"):(eO=c,c=i)):(eO=c,c=i),c===i&&(c=eO,39===e.charCodeAt(eO)?(u="'",eO++):(u=i,0===eT&&eL(R)),u!==i?(d=eO,eT++,"'''"===e.substr(eO,3)?(f="'''",eO+=3):(f=i,0===eT&&eL(D)),eT--,f!==i?(eO=d,d=void 0):d=i,d!==i?(eI=c,c="'"):(eO=c,c=i)):(eO=c,c=i)),(s=c)===i&&(s=null),eI=t,t=function(e,t,r){for(var n=e.join(""),i=0;i<t.length;i++)n+=t[i][0]+t[i][1].join("");return n+(r||"")}(r,n,s)}(),"'''"===e.substr(eO,3)?(b="'''",eO+=3):(b=i,0===eT&&eL(D)),b!==i))?h=th("String",m,eI=h):(eO=h,h=i),(s=h)===i)&&(s=eV()),(n=s)===i&&((w=eO,_=e.charAt(eO),d.test(_)?eO++:(_=i,0===eT&&eL(N)),_===i&&(_=null),"inf"===e.substr(eO,3)?($="inf",eO+=3):($=i,0===eT&&eL(j)),$!==i)?w=th("Float","-"===_?-1/0:1/0,eI=w):(eO=w,w=i),w===i&&(w=eO,_=e.charAt(eO),d.test(_)?eO++:(_=i,0===eT&&eL(N)),_===i&&(_=null),"nan"===e.substr(eO,3)?($="nan",eO+=3):($=i,0===eT&&eL(F)),$!==i?w=th("Float",NaN,eI=w):(eO=w,w=i),w===i&&(w=function(){var t,r,n,s,a,o,l,c,u,f,h;let p,m,g,y,b;if(p=eO,(m=e6())!==i)if((g=e7())!==i)if((y=e9())!==i){let a,o,l,c,u,f,h,g;(a=eO,"z"===(o=e.charAt(eO)).toLowerCase()?eO++:(o=i,0===eT&&eL(ep)),o!==i&&(eI=a,o="Z"),(a=o)===i&&(a=eO,o=eO,l=e.charAt(eO),d.test(l)?eO++:(l=i,0===eT&&eL(N)),l!==i&&(c=ti())!==i&&(u=ti())!==i?(58===e.charCodeAt(eO)?(f=":",eO++):(f=i,0===eT&&eL(eh)),f!==i&&(h=ti())!==i&&(g=ti())!==i?o=l=[l,c,u,f,h,g]:(eO=o,o=i)):(eO=o,o=i),a=o!==i?e.substring(a,eO):o),(b=a)!==i)?(eI=p,t=m,r=y,tp(t,n=eI),tm(r,n),function(e,t){if("Z"!==e&&"z"!==e){var r=(e.charCodeAt(1)-48)*10+e.charCodeAt(2)-48,n=(e.charCodeAt(4)-48)*10+e.charCodeAt(5)-48;r>23&&td("Invalid offset: hour "+r+" out of range.",t),n>59&&td("Invalid offset: minute "+n+" out of range.",t)}}(b,n),(s=th("Date",new Date(t+"T"+r+b),n)).raw=t+"T"+r,s.tz=b,p=s):(eO=p,p=i)}else eO=p,p=i;else eO=p,p=i;else eO=p,p=i;return p===i&&((p=eO,(m=e6())!==i&&(g=e7())!==i&&(y=e9())!==i)?(eI=p,a=m,o=y,tp(a,l=eI),tm(o,l),p=th("LocalDateTime",a+"T"+o,l)):(eO=p,p=i),p===i&&((p=eO,(m=e6())!==i&&(g=eO,eT++,y=e7(),eT--,y===i?g=void 0:(eO=g,g=i),g!==i))?(eI=p,tp(c=m,u=eI),p=th("LocalDate",c,u)):(eO=p,p=i),p===i&&(p=eO,(m=e9())!==i&&(eI=p,tm(f=m,h=eI),m=th("LocalTime",f,h)),p=m))),p}())===i&&(w=function(){let t,r,n,s,a,o,l,c,u,f;if(t=eO,(a=eO,o=e.charAt(eO),d.test(o)?eO++:(o=i,0===eT&&eL(N)),o===i&&(o=null),(l=eZ())!==i&&(46===e.charCodeAt(eO)?(c=".",eO++):(c=i,0===eT&&eL(T)),c!==i&&(u=eO,(u=(f=e0())!==i?e.substring(u,eO):f)!==i)))?(eI=a,a=("-"===o?"-":"")+l+"."+u):(eO=a,a=i),a===i&&((a=eO,o=e.charAt(eO),d.test(o)?eO++:(o=i,0===eT&&eL(N)),o===i&&(o=null),(l=eZ())!==i)?(eI=a,a=("-"===o?"-":"")+l):(eO=a,a=i)),(r=a)!==i)if(n=e.charAt(eO),g.test(n)?eO++:(n=i,0===eT&&eL(G)),n!==i){let n,a,o,l;if((n=eO,a=e.charAt(eO),d.test(a)?eO++:(a=i,0===eT&&eL(N)),a===i&&(a=null),o=eO,(o=(l=e0())!==i?e.substring(o,eO):l)!==i)?(eI=n,n=(a||"")+o):(eO=n,n=i),(s=n)!==i)eI=t,t=th("Float",parseFloat(tg(r+"e"+s)),eI);else eO=t,t=i}else eO=t,t=i;else eO=t,t=i;if(t===i){let n,s,a,o,l,c;t=eO,(n=eO,s=e.charAt(eO),d.test(s)?eO++:(s=i,0===eT&&eL(N)),s===i&&(s=null),(a=eZ())!==i&&(46===e.charCodeAt(eO)?(o=".",eO++):(o=i,0===eT&&eL(T)),o!==i&&(l=eO,(l=(c=e0())!==i?e.substring(l,eO):c)!==i)))?(eI=n,n=("-"===s?"-":"")+a+"."+l):(eO=n,n=i),(r=n)!==i&&(eI=t,r=th("Float",parseFloat(tg(r)),eI)),t=r}return t}())===i&&(w=function(){let t,r,n,s;if(((t=eO,"0x"===e.substr(eO,2)?(r="0x",eO+=2):(r=i,0===eT&&eL(Q)),r!==i&&(n=eO,(n=(s=function(){let t,r,n,s,a,o;if(t=eO,r=e.charAt(eO),x.test(r)?eO++:(r=i,0===eT&&eL(ei)),r!==i){for(n=[],s=eO,a=e.charAt(eO),v.test(a)?eO++:(a=i,0===eT&&eL(er)),a===i&&(a=null),o=e.charAt(eO),x.test(o)?eO++:(o=i,0===eT&&eL(ei)),o!==i?s=a=[a,o]:(eO=s,s=i);s!==i;)n.push(s),s=eO,a=e.charAt(eO),v.test(a)?eO++:(a=i,0===eT&&eL(er)),a===i&&(a=null),o=e.charAt(eO),x.test(o)?eO++:(o=i,0===eT&&eL(ei)),o!==i?s=a=[a,o]:(eO=s,s=i);t=r=[r,n]}else eO=t,t=i;return t}())!==i?e.substring(n,eO):s)!==i))?(eI=t,t=th("Integer",parseInt(tg(n),16),eI)):(eO=t,t=i),t===i)&&((t=eO,"0o"===e.substr(eO,2)?(r="0o",eO+=2):(r=i,0===eT&&eL(Z)),r!==i&&(n=eO,(n=(s=function(){let t,r,n,s,a,o;if(t=eO,r=e.charAt(eO),k.test(r)?eO++:(r=i,0===eT&&eL(es)),r!==i){for(n=[],s=eO,a=e.charAt(eO),v.test(a)?eO++:(a=i,0===eT&&eL(er)),a===i&&(a=null),o=e.charAt(eO),k.test(o)?eO++:(o=i,0===eT&&eL(es)),o!==i?s=a=[a,o]:(eO=s,s=i);s!==i;)n.push(s),s=eO,a=e.charAt(eO),v.test(a)?eO++:(a=i,0===eT&&eL(er)),a===i&&(a=null),o=e.charAt(eO),k.test(o)?eO++:(o=i,0===eT&&eL(es)),o!==i?s=a=[a,o]:(eO=s,s=i);t=r=[r,n]}else eO=t,t=i;return t}())!==i?e.substring(n,eO):s)!==i))?(eI=t,t=th("Integer",parseInt(tg(n),8),eI)):(eO=t,t=i),t===i)&&((t=eO,"0b"===e.substr(eO,2)?(r="0b",eO+=2):(r=i,0===eT&&eL(X)),r!==i&&(n=eO,(n=(s=function(){let t,r,n,s,a,o;if(t=eO,r=e.charAt(eO),S.test(r)?eO++:(r=i,0===eT&&eL(ea)),r!==i){for(n=[],s=eO,a=e.charAt(eO),v.test(a)?eO++:(a=i,0===eT&&eL(er)),a===i&&(a=null),o=e.charAt(eO),S.test(o)?eO++:(o=i,0===eT&&eL(ea)),o!==i?s=a=[a,o]:(eO=s,s=i);s!==i;)n.push(s),s=eO,a=e.charAt(eO),v.test(a)?eO++:(a=i,0===eT&&eL(er)),a===i&&(a=null),o=e.charAt(eO),S.test(o)?eO++:(o=i,0===eT&&eL(ea)),o!==i?s=a=[a,o]:(eO=s,s=i);t=r=[r,n]}else eO=t,t=i;return t}())!==i?e.substring(n,eO):s)!==i))?(eI=t,t=th("Integer",parseInt(tg(n),2),eI)):(eO=t,t=i),t===i)){let n,s,a,o,l,c;t=eO,(n=eO,s=e.charAt(eO),d.test(s)?eO++:(s=i,0===eT&&eL(N)),s===i&&(s=null),48===e.charCodeAt(eO)?(a="0",eO++):(a=i,0===eT&&eL(H)),a!==i&&(o=eO,eT++,l=e.charAt(eO),y.test(l)?eO++:(l=i,0===eT&&eL(ee)),eT--,l===i?o=void 0:(eO=o,o=i),o!==i&&(l=eO,eT++,46===e.charCodeAt(eO)?(c=".",eO++):(c=i,0===eT&&eL(T)),eT--,c===i?l=void 0:(eO=l,l=i),l!==i)))?(eI=n,n=(s||"")+"0"):(eO=n,n=i),n===i&&((n=eO,s=e.charAt(eO),d.test(s)?eO++:(s=i,0===eT&&eL(N)),s===i&&(s=null),a=eO,(a=(o=eX())!==i?e.substring(a,eO):o)!==i&&(o=eO,eT++,46===e.charCodeAt(eO)?(l=".",eO++):(l=i,0===eT&&eL(T)),eT--,l===i?o=void 0:(eO=o,o=i),o!==i))?(eI=n,n=(s||"")+a):(eO=n,n=i)),(r=n)!==i&&(eI=t,r=th("Integer",parseInt(tg(r),10),eI)),t=r}return t}())),(n=w)===i&&(O=eO,e.substr(eO,4)===l?(I=l,eO+=4):(I=i,0===eT&&eL(eo)),I!==i&&(I=th("Boolean",!0,eI=O)),(O=I)===i&&(O=eO,e.substr(eO,5)===c?(I=c,eO+=5):(I=i,0===eT&&eL(el)),I!==i&&(I=th("Boolean",!1,eI=O)),O=I),(n=O)===i&&(n=function(){let t,r,n,s,a,o,l,c,u,d;if(t=eO,91===e.charCodeAt(eO)?(r="[",eO++):(r=i,0===eT&&eL(E)),r!==i){for(n=[],s=e1();s!==i;)n.push(s),s=e1();93===e.charCodeAt(eO)?(s="]",eO++):(s=i,0===eT&&eL(A)),s!==i?t=th("Array",[],eI=t):(eO=t,t=i)}else eO=t,t=i;if(t===i)if(t=eO,91===e.charCodeAt(eO)?(r="[",eO++):(r=i,0===eT&&eL(E)),r!==i){for(n=[],s=e1();s!==i;)n.push(s),s=e1();if((s=eK())!==i){for(a=[],o=eO,l=[],c=e1();c!==i;)l.push(c),c=e1();if(44===e.charCodeAt(eO)?(c=",",eO++):(c=i,0===eT&&eL(ec)),c!==i){for(u=[],d=e1();d!==i;)u.push(d),d=e1();(d=eK())!==i?(eI=o,o=d):(eO=o,o=i)}else eO=o,o=i;for(;o!==i;){for(a.push(o),o=eO,l=[],c=e1();c!==i;)l.push(c),c=e1();if(44===e.charCodeAt(eO)?(c=",",eO++):(c=i,0===eT&&eL(ec)),c!==i){for(u=[],d=e1();d!==i;)u.push(d),d=e1();(d=eK())!==i?(eI=o,o=d):(eO=o,o=i)}else eO=o,o=i}for(o=[],l=e1();l!==i;)o.push(l),l=e1();for(44===e.charCodeAt(eO)?(l=",",eO++):(l=i,0===eT&&eL(ec)),l===i&&(l=null),c=[],u=e1();u!==i;)c.push(u),u=e1();if(93===e.charCodeAt(eO)?(u="]",eO++):(u=i,0===eT&&eL(A)),u!==i){var f;eI=t,f=s,a.unshift(f),t=th("Array",a,eI)}else eO=t,t=i}else eO=t,t=i}else eO=t,t=i;return t}())===i))&&(n=function(){let t,r,n,s,a,o,l,c,u,d;if(t=eO,123===e.charCodeAt(eO)?(r="{",eO++):(r=i,0===eT&&eL(eu)),r!==i){for(n=[],s=e3();s!==i;)n.push(s),s=e3();125===e.charCodeAt(eO)?(s="}",eO++):(s=i,0===eT&&eL(ed)),s!==i?t=th("InlineTable",[],eI=t):(eO=t,t=i)}else eO=t,t=i;if(t===i)if(t=eO,123===e.charCodeAt(eO)?(r="{",eO++):(r=i,0===eT&&eL(eu)),r!==i){for(n=[],s=e3();s!==i;)n.push(s),s=e3();if((s=e2())!==i){for(a=[],o=eO,l=[],c=e3();c!==i;)l.push(c),c=e3();if(44===e.charCodeAt(eO)?(c=",",eO++):(c=i,0===eT&&eL(ec)),c!==i){for(u=[],d=e3();d!==i;)u.push(d),d=e3();(d=e2())!==i?(eI=o,o=d):(eO=o,o=i)}else eO=o,o=i;for(;o!==i;){for(a.push(o),o=eO,l=[],c=e3();c!==i;)l.push(c),c=e3();if(44===e.charCodeAt(eO)?(c=",",eO++):(c=i,0===eT&&eL(ec)),c!==i){for(u=[],d=e3();d!==i;)u.push(d),d=e3();(d=e2())!==i?(eI=o,o=d):(eO=o,o=i)}else eO=o,o=i}for(o=[],l=e3();l!==i;)o.push(l),l=e3();for(44===e.charCodeAt(eO)?(l=",",eO++):(l=i,0===eT&&eL(ec)),l===i&&(l=null),c=[],u=e3();u!==i;)c.push(u),u=e3();if(125===e.charCodeAt(eO)?(u="}",eO++):(u=i,0===eT&&eL(ed)),u!==i){var f;eI=t,f=s,a.unshift(f),t=th("InlineTable",a,eI)}else eO=t,t=i}else eO=t,t=i}else eO=t,t=i;return t}()),(r=n)!==i){var C;eI=t,C=r,tc--,r=C}return(t=r)===i&&(eI=eO,tc--,t=!1,t=i),t}())!==i)?(eI=t,t=r):(eO=t,t=i),t}function ez(){let t,r,n,s;if(t=eO,34===e.charCodeAt(eO)?(r='"',eO++):(r=i,0===eT&&eL(P)),r!==i){for(n=[],s=eH();s!==i;)n.push(s),s=eH();(34===e.charCodeAt(eO)?(s='"',eO++):(s=i,0===eT&&eL(P)),s!==i)?(eI=t,t=th("String",n.join(""),eI)):(eO=t,t=i)}else eO=t,t=i;return t}function eV(){let t,r,n,s;if(t=eO,39===e.charCodeAt(eO)?(r="'",eO++):(r=i,0===eT&&eL(R)),r!==i){for(n=[],s=eQ();s!==i;)n.push(s),s=eQ();(39===e.charCodeAt(eO)?(s="'",eO++):(s=i,0===eT&&eL(R)),s!==i)?(eI=t,t=th("String",n.join(""),eI)):(eO=t,t=i)}else eO=t,t=i;return t}function eJ(){let t,r,n;if((t=to())===i&&(t=function(){let t,r,n,s,a,o;if(t=eO,92===e.charCodeAt(eO)?(r="\\",eO++):(r=i,0===eT&&eL(U)),r!==i){for(n=[],s=te();s!==i;)n.push(s),s=te();if((s=tt())!==i){for(a=[],o=tr();o!==i;)a.push(o),o=tr();eI=t,t=""}else eO=t,t=i}else eO=t,t=i;return t}())===i&&(t=eO,92===e.charCodeAt(eO)?(r="\\",eO++):(r=i,0===eT&&eL(U)),r!==i?(e.length>eO?(n=e.charAt(eO),eO++):(n=i,0===eT&&eL(B)),n!==i?t=void td("Invalid escape sequence",eI=t):(eO=t,t=i)):(eO=t,t=i),t===i)&&(t=eO,"\r\n"===e.substr(eO,2)?(r="\r\n",eO+=2):(r=i,0===eT&&eL(q)),r!==i&&(eI=t,r="\n"),(t=r)===i)){if(t=eO,r=[],n=e.charAt(eO),f.test(n)?eO++:(n=i,0===eT&&eL(K)),n!==i)for(;n!==i;)r.push(n),n=e.charAt(eO),f.test(n)?eO++:(n=i,0===eT&&eL(K));else r=i;t=r!==i?e.substring(t,eO):r}return t}function eW(){let t,r,n,s;return t=eO,'""'===e.substr(eO,2)?(r='""',eO+=2):(r=i,0===eT&&eL(z)),r!==i?(n=eO,eT++,34===e.charCodeAt(eO)?(s='"',eO++):(s=i,0===eT&&eL(P)),eT--,s===i?n=void 0:(eO=n,n=i),n!==i?(eI=t,t='""'):(eO=t,t=i)):(eO=t,t=i),t===i&&(t=eO,34===e.charCodeAt(eO)?(r='"',eO++):(r=i,0===eT&&eL(P)),r!==i?(n=eO,eT++,34===e.charCodeAt(eO)?(s='"',eO++):(s=i,0===eT&&eL(P)),eT--,s===i?n=void 0:(eO=n,n=i),n!==i?(eI=t,t='"'):(eO=t,t=i)):(eO=t,t=i)),t}function eY(){let t,r,n;if(t=eO,"\r\n"===e.substr(eO,2)?(r="\r\n",eO+=2):(r=i,0===eT&&eL(q)),r!==i&&(eI=t,r="\n"),(t=r)===i){if(t=eO,r=[],n=e.charAt(eO),h.test(n)?eO++:(n=i,0===eT&&eL(V)),n!==i)for(;n!==i;)r.push(n),n=e.charAt(eO),h.test(n)?eO++:(n=i,0===eT&&eL(V));else r=i;t=r!==i?e.substring(t,eO):r}return t}function eG(){let t,r,n,s;return t=eO,"''"===e.substr(eO,2)?(r="''",eO+=2):(r=i,0===eT&&eL(J)),r!==i?(n=eO,eT++,39===e.charCodeAt(eO)?(s="'",eO++):(s=i,0===eT&&eL(R)),eT--,s===i?n=void 0:(eO=n,n=i),n!==i?(eI=t,t="''"):(eO=t,t=i)):(eO=t,t=i),t===i&&(t=eO,39===e.charCodeAt(eO)?(r="'",eO++):(r=i,0===eT&&eL(R)),r!==i?(n=eO,eT++,39===e.charCodeAt(eO)?(s="'",eO++):(s=i,0===eT&&eL(R)),eT--,s===i?n=void 0:(eO=n,n=i),n!==i?(eI=t,t="'"):(eO=t,t=i)):(eO=t,t=i)),t}function eH(){let t,r,n;if((t=to())===i&&(t=eO,92===e.charCodeAt(eO)?(r="\\",eO++):(r=i,0===eT&&eL(U)),r!==i?(e.length>eO?(n=e.charAt(eO),eO++):(n=i,0===eT&&eL(B)),n!==i?t=void td("Invalid escape sequence",eI=t):(eO=t,t=i)):(eO=t,t=i),t===i)){if(t=eO,r=[],n=e.charAt(eO),p.test(n)?eO++:(n=i,0===eT&&eL(W)),n!==i)for(;n!==i;)r.push(n),n=e.charAt(eO),p.test(n)?eO++:(n=i,0===eT&&eL(W));else r=i;t=r!==i?e.substring(t,eO):r}return t}function eQ(){let t,r,n;if(t=eO,r=[],n=e.charAt(eO),m.test(n)?eO++:(n=i,0===eT&&eL(Y)),n!==i)for(;n!==i;)r.push(n),n=e.charAt(eO),m.test(n)?eO++:(n=i,0===eT&&eL(Y));else r=i;return r!==i?e.substring(t,eO):r}function eZ(){let t,r;return t=eO,48===e.charCodeAt(eO)?(r="0",eO++):(r=i,0===eT&&eL(H)),r!==i&&(eI=t,r="0"),(t=r)===i&&(t=eO,t=(r=eX())!==i?e.substring(t,eO):r),t}function eX(){let t,r,n,s,a,o;if(t=eO,r=e.charAt(eO),b.test(r)?eO++:(r=i,0===eT&&eL(et)),r!==i){for(n=[],s=eO,a=e.charAt(eO),v.test(a)?eO++:(a=i,0===eT&&eL(er)),a===i&&(a=null),o=e.charAt(eO),w.test(o)?eO++:(o=i,0===eT&&eL(en)),o!==i?s=a=[a,o]:(eO=s,s=i);s!==i;)n.push(s),s=eO,a=e.charAt(eO),v.test(a)?eO++:(a=i,0===eT&&eL(er)),a===i&&(a=null),o=e.charAt(eO),w.test(o)?eO++:(o=i,0===eT&&eL(en)),o!==i?s=a=[a,o]:(eO=s,s=i);t=r=[r,n]}else eO=t,t=i;return t}function e0(){let t,r,n,s,a,o;if(t=eO,r=e.charAt(eO),w.test(r)?eO++:(r=i,0===eT&&eL(en)),r!==i){for(n=[],s=eO,a=e.charAt(eO),v.test(a)?eO++:(a=i,0===eT&&eL(er)),a===i&&(a=null),o=e.charAt(eO),w.test(o)?eO++:(o=i,0===eT&&eL(en)),o!==i?s=a=[a,o]:(eO=s,s=i);s!==i;)n.push(s),s=eO,a=e.charAt(eO),v.test(a)?eO++:(a=i,0===eT&&eL(er)),a===i&&(a=null),o=e.charAt(eO),w.test(o)?eO++:(o=i,0===eT&&eL(en)),o!==i?s=a=[a,o]:(eO=s,s=i);t=r=[r,n]}else eO=t,t=i;return t}function e1(){let e;return(e=te())===i&&(e=tt())===i&&(e=eR()),e}function e2(){let t,r,n,s,a,o;if(t=eO,(r=e5())!==i){for(n=[],s=te();s!==i;)n.push(s),s=te();if(61===e.charCodeAt(eO)?(s="=",eO++):(s=i,0===eT&&eL(M)),s!==i){for(a=[],o=te();o!==i;)a.push(o),o=te();if((o=eK())!==i)t=th("InlineTableValue",o,eI=t,r);else eO=t,t=i}else eO=t,t=i}else eO=t,t=i;return t}function e3(){let e;return(e=te())===i&&(e=tt())===i&&(e=eR()),e}function e5(){let e,t,r,n;if(e=eO,t=[],(r=e4())!==i)for(;r!==i;)t.push(r),r=e4();else t=i;if(t!==i){for(r=[],n=te();n!==i;)r.push(n),n=te();if((n=e8())!==i){var s,a;eI=e,s=t,a=n,e=s.concat(a)}else eO=e,e=i}else eO=e,e=i;return e===i&&(e=eO,(t=e8())!==i&&(eI=e,t=[t]),e=t),e}function e4(){let t,r,n,s,a;for(t=eO,r=[],n=te();n!==i;)r.push(n),n=te();if((n=e8())!==i){for(s=[],a=te();a!==i;)s.push(a),a=te();(46===e.charCodeAt(eO)?(a=".",eO++):(a=i,0===eT&&eL(T)),a!==i)?(eI=t,t=n):(eO=t,t=i)}else eO=t,t=i;return t}function e8(){let t,r,n;return(t=function(){let t,r,n;if(t=eO,r=[],(n=ta())!==i)for(;n!==i;)r.push(n),n=ta();else r=i;return r!==i?e.substring(t,eO):r}())===i&&(r=eO,(n=ez())!==i&&(eI=r,n=n.value),(r=n)===i&&(r=eO,(n=eV())!==i&&(eI=r,n=n.value),r=n),t=r),t}function e6(){let t,r,n,s,a,o,l,c,u,d,f,h;return t=eO,r=eO,(n=ti())!==i&&(s=ti())!==i&&(a=ti())!==i&&(o=ti())!==i?(45===e.charCodeAt(eO)?(l="-",eO++):(l=i,0===eT&&eL(ef)),l!==i&&(c=ti())!==i&&(u=ti())!==i?(45===e.charCodeAt(eO)?(d="-",eO++):(d=i,0===eT&&eL(ef)),d!==i&&(f=ti())!==i&&(h=ti())!==i?r=n=[n,s,a,o,l,c,u,d,f,h]:(eO=r,r=i)):(eO=r,r=i)):(eO=r,r=i),t=r!==i?e.substring(t,eO):r}function e9(){let t,r,n,s,a,o,l,c,u,d,f;if(t=eO,r=eO,n=eO,(s=ti())!==i&&(a=ti())!==i?(58===e.charCodeAt(eO)?(o=":",eO++):(o=i,0===eT&&eL(eh)),o!==i&&(l=ti())!==i&&(c=ti())!==i?(58===e.charCodeAt(eO)?(u=":",eO++):(u=i,0===eT&&eL(eh)),u!==i&&(d=ti())!==i&&(f=ti())!==i?n=s=[s,a,o,l,c,u,d,f]:(eO=n,n=i)):(eO=n,n=i)):(eO=n,n=i),(r=n!==i?e.substring(r,eO):n)!==i){var h,p;(n=function(){let t,r,n,s,a;if(t=eO,r=eO,46===e.charCodeAt(eO)?(n=".",eO++):(n=i,0===eT&&eL(T)),n!==i){if(s=[],(a=ti())!==i)for(;a!==i;)s.push(a),a=ti();else s=i;s!==i?r=n=[n,s]:(eO=r,r=i)}else eO=r,r=i;return r!==i?e.substring(t,eO):r}())===i&&(n=null),eI=t,h=r,t=(p=n)?h+p:h}else eO=t,t=i;return t===i&&((t=eO,r=eO,n=eO,(s=ti())!==i&&(a=ti())!==i?(58===e.charCodeAt(eO)?(o=":",eO++):(o=i,0===eT&&eL(eh)),o!==i&&(l=ti())!==i&&(c=ti())!==i?n=s=[s,a,o,l,c]:(eO=n,n=i)):(eO=n,n=i),(r=n!==i?e.substring(r,eO):n)!==i&&(n=eO,eT++,58===e.charCodeAt(eO)?(s=":",eO++):(s=i,0===eT&&eL(eh)),eT--,s===i?n=void 0:(eO=n,n=i),n!==i))?(eI=t,t=r+":00"):(eO=t,t=i)),t}function e7(){let t,r,n,s;return"t"===(t=e.charAt(eO)).toLowerCase()?eO++:(t=i,0===eT&&eL(em)),t===i&&(t=eO,32===e.charCodeAt(eO)?(r=" ",eO++):(r=i,0===eT&&eL(eg)),r!==i?(n=eO,eT++,s=ti(),eT--,s!==i?(eO=n,n=void 0):n=i,n!==i?t=r=[r,n]:(eO=t,t=i)):(eO=t,t=i)),t}function te(){let t;return t=e.charAt(eO),_.test(t)?eO++:(t=i,0===eT&&eL(ey)),t}function tt(){let t,r,n;return 10===e.charCodeAt(eO)?(t="\n",eO++):(t=i,0===eT&&eL(eb)),t===i&&(t=eO,13===e.charCodeAt(eO)?(r="\r",eO++):(r=i,0===eT&&eL(ev)),r!==i?(10===e.charCodeAt(eO)?(n="\n",eO++):(n=i,0===eT&&eL(eb)),n!==i?t=r=[r,n]:(eO=t,t=i)):(eO=t,t=i)),t}function tr(){let e;return(e=tt())===i&&(e=te()),e}function tn(){let t,r;return t=eO,eT++,e.length>eO?(r=e.charAt(eO),eO++):(r=i,0===eT&&eL(B)),eT--,r===i?t=void 0:(eO=t,t=i),t}function ti(){let t;return t=e.charAt(eO),w.test(t)?eO++:(t=i,0===eT&&eL(en)),t}function ts(){let t;return t=e.charAt(eO),x.test(t)?eO++:(t=i,0===eT&&eL(ei)),t}function ta(){let t;return t=e.charAt(eO),$.test(t)?eO++:(t=i,0===eT&&eL(ex)),t}function to(){let t,r,n,s,a,o,l,c,u,d,f,h,p,m,g;if(t=eO,92===e.charCodeAt(eO)?(r="\\",eO++):(r=i,0===eT&&eL(U)),r!==i)if(n=e.charAt(eO),O.test(n)?eO++:(n=i,0===eT&&eL(ek)),n!==i){var y;eI=t,t="n"===(y=n)?"\n":"t"===y?" ":"r"===y?"\r":"\\"===y?"\\":'"'===y?'"':"b"===y?"\b":"f"===y?"\f":"\x1b"}else eO=t,t=i;else eO=t,t=i;return t===i&&((s=eO,"\\U"===e.substr(eO,2)?(a="\\U",eO+=2):(a=i,0===eT&&eL(eS)),a!==i&&(o=eO,l=eO,(c=ts())!==i&&(u=ts())!==i&&(d=ts())!==i&&(f=ts())!==i&&(h=ts())!==i&&(p=ts())!==i&&(m=ts())!==i&&(g=ts())!==i?l=c=[c,u,d,f,h,p,m,g]:(eO=l,l=i),(o=l!==i?e.substring(o,eO):l)!==i))?(eI=s,s=ty(o)):(eO=s,s=i),s===i&&((s=eO,"\\u"===e.substr(eO,2)?(a="\\u",eO+=2):(a=i,0===eT&&eL(e_)),a!==i&&(o=eO,l=eO,(c=ts())!==i&&(u=ts())!==i&&(d=ts())!==i&&(f=ts())!==i?l=c=[c,u,d,f]:(eO=l,l=i),(o=l!==i?e.substring(o,eO):l)!==i))?(eI=s,s=ty(o)):(eO=s,s=i),s===i&&((s=eO,"\\x"===e.substr(eO,2)?(a="\\x",eO+=2):(a=i,0===eT&&eL(e$)),a!==i&&(o=eO,l=eO,(c=ts())!==i&&(u=ts())!==i?l=c=[c,u]:(eO=l,l=i),(o=l!==i?e.substring(o,eO):l)!==i))?(eI=s,s=ty(o)):(eO=s,s=i))),t=s),t}var tl=[],tc=0,tu=r&&null!=r.maxDepth?r.maxDepth:500;function td(t,r){var n=function(t){for(var r=1,n=1,i=0;i<t;i++)10===e.charCodeAt(i)?(r++,n=1):n++;return{line:r,column:n}}(r),i=Error(t);throw i.line=n.line,i.column=n.column,i}function tf(e){tl.push(e)}function th(e,t,r,n){var i={type:e,value:t,offset:r};return n&&(i.key=n),i}function tp(e,t){var r=1e3*e.charCodeAt(0)+100*e.charCodeAt(1)+10*e.charCodeAt(2)+e.charCodeAt(3)-53328,n=(e.charCodeAt(5)-48)*10+e.charCodeAt(6)-48,i=(e.charCodeAt(8)-48)*10+e.charCodeAt(9)-48;(n<1||n>12)&&td("Invalid date: month "+n+" out of range.",t);var s=[31,28,31,30,31,30,31,31,30,31,30,31];(r%4==0&&r%100!=0||r%400==0)&&(s[1]=29),(i<1||i>s[n-1])&&td("Invalid date: day "+i+" out of range for month "+n+".",t)}function tm(e,t){var r=(e.charCodeAt(0)-48)*10+e.charCodeAt(1)-48,n=(e.charCodeAt(3)-48)*10+e.charCodeAt(4)-48,i=(e.charCodeAt(6)-48)*10+e.charCodeAt(7)-48;r>23&&td("Invalid time: hour "+r+" out of range.",t),n>59&&td("Invalid time: minute "+n+" out of range.",t),i>59&&td("Invalid time: second "+i+" out of range.",t)}function tg(e){return -1===e.indexOf("_")?e:e.replace(/_/g,"")}function ty(e){var t=parseInt(e,16);if(t==t&&!(t<0)&&!(t>1114111)&&(!(t>55295)||!(t<57344)))return String.fromCodePoint(t);td("Invalid Unicode escape code: "+e,eI)}let tb=(n=o())!==i&&eO===e.length;function tv(){var r,s,a;throw n!==i&&eO<e.length&&eL({type:"end"}),r=eA,s=eE<e.length?function(t=eO){let r=e.codePointAt(t);return void 0===r?"":String.fromCodePoint(r)}(eE):null,a=eE<e.length?eF(eE,eE+1):eF(eE,eE),new t(t.buildMessage(r,s),r,s,a)}return r.peg$library?{peg$result:n,peg$currPos:eO,peg$FAILED:i,peg$maxFailExpected:eA,peg$maxFailPos:eE,peg$success:tb,peg$throw:tb?void 0:tv}:tb?n:void tv()}}},181(e){e.exports=t("buffer")},932(e){e.exports=t("process")},7876(e,t,r){var n=r(6730),i=r(8376),s=r(73),a=r(7028),o=r(3244),l=r(6225),c=r(9661);function u(e,t,r,n,i,s){let a="block-map"===r.type?o.resolveBlockMap(e,t,r,n,s):"block-seq"===r.type?l.resolveBlockSeq(e,t,r,n,s):c.resolveFlowCollection(e,t,r,n,s),u=a.constructor;return"!"===i||i===u.tagName?a.tag=u.tagName:i&&(a.tag=i),a}t.composeCollection=function(e,t,r,o,l){let c=o.tag,d=c?t.directives.tagName(c.source,e=>l(c,"TAG_RESOLVE_FAILED",e)):null;if("block-seq"===r.type){let{anchor:e,newlineAfterProp:t}=o,r=e&&c?e.offset>c.offset?e:c:e??c;r&&(!t||t.offset<r.offset)&&l(r,"MISSING_CHAR","Missing newline after block sequence props")}let f="block-map"===r.type?"map":"block-seq"===r.type?"seq":"{"===r.start.source?"map":"seq";if(!c||!d||"!"===d||d===s.YAMLMap.tagName&&"map"===f||d===a.YAMLSeq.tagName&&"seq"===f)return u(e,t,r,l,d);let h=t.schema.tags.find(e=>e.tag===d&&e.collection===f);if(!h){let n=t.schema.knownTags[d];if(n?.collection!==f)return n?l(c,"BAD_COLLECTION_TYPE",`${n.tag} used for ${f} collection, but expects ${n.collection??"scalar"}`,!0):l(c,"TAG_RESOLVE_FAILED",`Unresolved tag: ${d}`,!0),u(e,t,r,l,d);t.schema.tags.push(Object.assign({},n,{default:!1})),h=n}let p=u(e,t,r,l,d,h),m=h.resolve?.(p,e=>l(c,"TAG_RESOLVE_FAILED",e),t.options)??p,g=n.isNode(m)?m:new i.Scalar(m);return g.range=p.range,g.tag=d,h?.format&&(g.format=h.format),g}},6040(e,t,r){var n=r(9960),i=r(9724),s=r(4915),a=r(7800);t.composeDoc=function(e,t,{offset:r,start:o,value:l,end:c},u){let d=Object.assign({_directives:t},e),f=new n.Document(void 0,d),h={atKey:!1,atRoot:!0,directives:f.directives,options:f.options,schema:f.schema},p=a.resolveProps(o,{indicator:"doc-start",next:l??c?.[0],offset:r,onError:u,parentIndent:0,startOnNewline:!0});p.found&&(f.directives.docStart=!0,l&&("block-map"===l.type||"block-seq"===l.type)&&!p.hasNewline&&u(p.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),f.contents=l?i.composeNode(h,l,p,u):i.composeEmptyNode(h,p.end,o,null,p,u);let m=f.contents.range[2],g=s.resolveEnd(c,m,!1,u);return g.comment&&(f.comment=g.comment),f.range=[r,m,g.offset],f}},9724(e,t,r){var n=r(2298),i=r(6730),s=r(7876),a=r(5120),o=r(4915),l=r(4898);let c={composeNode:u,composeEmptyNode:d};function u(e,t,r,l){let u,f=e.atKey,{spaceBefore:h,comment:p,anchor:m,tag:g}=r,y=!0;switch(t.type){case"alias":u=function({options:e},{offset:t,source:r,end:i},s){let a=new n.Alias(r.substring(1));""===a.source&&s(t,"BAD_ALIAS","Alias cannot be an empty string"),a.source.endsWith(":")&&s(t+r.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let l=t+r.length,c=o.resolveEnd(i,l,e.strict,s);return a.range=[t,l,c.offset],c.comment&&(a.comment=c.comment),a}(e,t,l),(m||g)&&l(t,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":u=a.composeScalar(e,t,g,l),m&&(u.anchor=m.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{u=s.composeCollection(c,e,t,r,l),m&&(u.anchor=m.source.substring(1))}catch(e){l(t,"RESOURCE_EXHAUSTION",e instanceof Error?e.message:String(e))}break;default:{let e="error"===t.type?t.message:`Unsupported token (type: ${t.type})`;l(t,"UNEXPECTED_TOKEN",e),y=!1}}return u??(u=d(e,t.offset,void 0,null,r,l)),m&&""===u.anchor&&l(m,"BAD_ALIAS","Anchor cannot be an empty string"),f&&e.options.stringKeys&&(!i.isScalar(u)||"string"!=typeof u.value||u.tag&&"tag:yaml.org,2002:str"!==u.tag)&&l(g??t,"NON_STRING_KEY","With stringKeys, all keys must be strings"),h&&(u.spaceBefore=!0),p&&("scalar"===t.type&&""===t.source?u.comment=p:u.commentBefore=p),e.options.keepSourceTokens&&y&&(u.srcToken=t),u}function d(e,t,r,n,{spaceBefore:i,comment:s,anchor:o,tag:c,end:u},f){let h={type:"scalar",offset:l.emptyScalarPosition(t,r,n),indent:-1,source:""},p=a.composeScalar(e,h,c,f);return o&&(p.anchor=o.source.substring(1),""===p.anchor&&f(o,"BAD_ALIAS","Anchor cannot be an empty string")),i&&(p.spaceBefore=!0),s&&(p.comment=s,p.range[2]=u),p}t.composeEmptyNode=d,t.composeNode=u},5120(e,t,r){var n=r(6730),i=r(8376),s=r(2992),a=r(3165);t.composeScalar=function(e,t,r,o){let l,c,{value:u,type:d,comment:f,range:h}="block-scalar"===t.type?s.resolveBlockScalar(e,t,o):a.resolveFlowScalar(t,e.options.strict,o),p=r?e.directives.tagName(r.source,e=>o(r,"TAG_RESOLVE_FAILED",e)):null;l=e.options.stringKeys&&e.atKey?e.schema[n.SCALAR]:p?function(e,t,r,i,s){if("!"===r)return e[n.SCALAR];let a=[];for(let t of e.tags)if(!t.collection&&t.tag===r)if(!t.default||!t.test)return t;else a.push(t);for(let e of a)if(e.test?.test(t))return e;let o=e.knownTags[r];return o&&!o.collection?(e.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(s(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${r}`,"tag:yaml.org,2002:str"!==r),e[n.SCALAR])}(e.schema,u,p,r,o):"scalar"===t.type?function({atKey:e,directives:t,schema:r},i,s,a){let o=r.tags.find(t=>(!0===t.default||e&&"key"===t.default)&&t.test?.test(i))||r[n.SCALAR];if(r.compat){let e=r.compat.find(e=>e.default&&e.test?.test(i))??r[n.SCALAR];if(o.tag!==e.tag){let r=t.tagString(o.tag),n=t.tagString(e.tag);a(s,"TAG_RESOLVE_FAILED",`Value may be parsed as either ${r} or ${n}`,!0)}}return o}(e,u,t,o):e.schema[n.SCALAR];try{let s=l.resolve(u,e=>o(r??t,"TAG_RESOLVE_FAILED",e),e.options);c=n.isScalar(s)?s:new i.Scalar(s)}catch(e){o(r??t,"TAG_RESOLVE_FAILED",e instanceof Error?e.message:String(e)),c=new i.Scalar(u)}return c.range=h,c.source=u,d&&(c.type=d),p&&(c.tag=p),l.format&&(c.format=l.format),f&&(c.comment=f),c}},2545(e,t,r){var n=r(932),i=r(7087),s=r(9960),a=r(3409),o=r(6730),l=r(6040),c=r(4915);function u(e){if("number"==typeof e)return[e,e+1];if(Array.isArray(e))return 2===e.length?e:[e[0],e[1]];let{offset:t,source:r}=e;return[t,t+("string"==typeof r?r.length:1)]}function d(e){let t="",r=!1,n=!1;for(let i=0;i<e.length;++i){let s=e[i];switch(s[0]){case"#":t+=(""===t?"":n?"\n\n":"\n")+(s.substring(1)||" "),r=!0,n=!1;break;case"%":e[i+1]?.[0]!=="#"&&(i+=1),r=!1;break;default:r||(n=!0),r=!1}}return{comment:t,afterEmptyLine:n}}t.Composer=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(e,t,r,n)=>{let i=u(e);n?this.warnings.push(new a.YAMLWarning(i,t,r)):this.errors.push(new a.YAMLParseError(i,t,r))},this.directives=new i.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,t){let{comment:r,afterEmptyLine:n}=d(this.prelude);if(r){let i=e.contents;if(t)e.comment=e.comment?`${e.comment}
3
- ${r}`:r;else if(n||e.directives.docStart||!i)e.commentBefore=r;else if(o.isCollection(i)&&!i.flow&&i.items.length>0){let e=i.items[0];o.isPair(e)&&(e=e.key);let t=e.commentBefore;e.commentBefore=t?`${r}
4
- ${t}`:r}else{let e=i.commentBefore;i.commentBefore=e?`${r}
5
- ${e}`:r}}if(t){for(let t=0;t<this.errors.length;++t)e.errors.push(this.errors[t]);for(let t=0;t<this.warnings.length;++t)e.warnings.push(this.warnings[t])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:d(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,r=-1){for(let t of e)yield*this.next(t);yield*this.end(t,r)}*next(e){switch(n.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(t,r,n)=>{let i=u(e);i[0]+=t,this.onError(i,"BAD_DIRECTIVE",r,n)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let t=l.composeDoc(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,r=new a.YAMLParseError(u(e),"UNEXPECTED_TOKEN",t);this.atDirectives||!this.doc?this.errors.push(r):this.doc.errors.push(r);break}case"doc-end":{if(!this.doc){this.errors.push(new a.YAMLParseError(u(e),"UNEXPECTED_TOKEN","Unexpected doc-end without preceding document"));break}this.doc.directives.docEnd=!0;let t=c.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let e=this.doc.comment;this.doc.comment=e?`${e}
6
- ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new a.YAMLParseError(u(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let e=Object.assign({_directives:this.directives},this.options),r=new s.Document(void 0,e);this.atDirectives&&this.onError(t,"MISSING_CHAR","Missing directives-end indicator line"),r.range=[0,t,t],this.decorate(r,!1),yield r}}}},3244(e,t,r){var n=r(7748),i=r(73),s=r(7800),a=r(6884),o=r(7090),l=r(8388);let c="All mapping items must start at the same column";t.resolveBlockMap=function({composeNode:e,composeEmptyNode:t},r,u,d,f){let h=new(f?.nodeClass??i.YAMLMap)(r.schema);r.atRoot&&(r.atRoot=!1);let p=u.offset,m=null;for(let i of u.items){let{start:f,key:g,sep:y,value:b}=i,v=s.resolveProps(f,{indicator:"explicit-key-ind",next:g??y?.[0],offset:p,onError:d,parentIndent:u.indent,startOnNewline:!0}),w=!v.found;if(w){if(g&&("block-seq"===g.type?d(p,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in g&&g.indent!==u.indent&&d(p,"BAD_INDENT",c)),!v.anchor&&!v.tag&&!y){m=v.end,v.comment&&(h.comment?h.comment+="\n"+v.comment:h.comment=v.comment);continue}(v.newlineAfterProp||a.containsNewline(g))&&d(g??f[f.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else v.found?.indent!==u.indent&&d(p,"BAD_INDENT",c);r.atKey=!0;let x=v.end,k=g?e(r,g,v,d):t(r,x,f,null,v,d);r.schema.compat&&o.flowIndentCheck(u.indent,g,d),r.atKey=!1,l.mapIncludes(r,h.items,k)&&d(x,"DUPLICATE_KEY","Map keys must be unique");let S=s.resolveProps(y??[],{indicator:"map-value-ind",next:b,offset:k.range[2],onError:d,parentIndent:u.indent,startOnNewline:!g||"block-scalar"===g.type});if(p=S.end,S.found){w&&(b?.type!=="block-map"||S.hasNewline||d(p,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),r.options.strict&&v.start<S.found.offset-1024&&d(k.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let s=b?e(r,b,S,d):t(r,p,y,null,S,d);r.schema.compat&&o.flowIndentCheck(u.indent,b,d),p=s.range[2];let a=new n.Pair(k,s);r.options.keepSourceTokens&&(a.srcToken=i),h.items.push(a)}else{w&&d(k.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),S.comment&&(k.comment?k.comment+="\n"+S.comment:k.comment=S.comment);let e=new n.Pair(k);r.options.keepSourceTokens&&(e.srcToken=i),h.items.push(e)}}return m&&m<p&&d(m,"IMPOSSIBLE","Map comment with trailing content"),h.range=[u.offset,p,m??p],h}},2992(e,t,r){var n=r(8376);t.resolveBlockScalar=function(e,t,r){let i=t.offset,s=function({offset:e,props:t},r,n){if("block-scalar-header"!==t[0].type)return n(t[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:i}=t[0],s=i[0],a=0,o="",l=-1;for(let t=1;t<i.length;++t){let r=i[t];if(o||"-"!==r&&"+"!==r){let n=Number(r);!a&&n?a=n:-1===l&&(l=e+t)}else o=r}-1!==l&&n(l,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${i}`);let c=!1,u="",d=i.length;for(let e=1;e<t.length;++e){let i=t[e];switch(i.type){case"space":c=!0;case"newline":d+=i.source.length;break;case"comment":r&&!c&&n(i,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),d+=i.source.length,u=i.source.substring(1);break;case"error":n(i,"UNEXPECTED_TOKEN",i.message),d+=i.source.length;break;default:{let e=`Unexpected token in block scalar header: ${i.type}`;n(i,"UNEXPECTED_TOKEN",e);let t=i.source;t&&"string"==typeof t&&(d+=t.length)}}}return{mode:s,indent:a,chomp:o,comment:u,length:d}}(t,e.options.strict,r);if(!s)return{value:"",type:null,comment:"",range:[i,i,i]};let a=">"===s.mode?n.Scalar.BLOCK_FOLDED:n.Scalar.BLOCK_LITERAL,o=t.source?function(e){let t=e.split(/\n( *)/),r=t[0],n=r.match(/^( *)/),i=[n?.[1]?[n[1],r.slice(n[1].length)]:["",r]];for(let e=1;e<t.length;e+=2)i.push([t[e],t[e+1]]);return i}(t.source):[],l=o.length;for(let e=o.length-1;e>=0;--e){let t=o[e][1];if(""===t||"\r"===t)l=e;else break}if(0===l){let e="+"===s.chomp&&o.length>0?"\n".repeat(Math.max(1,o.length-1)):"",r=i+s.length;return t.source&&(r+=t.source.length),{value:e,type:a,comment:s.comment,range:[i,r,r]}}let c=t.indent+s.indent,u=t.offset+s.length,d=0;for(let t=0;t<l;++t){let[n,i]=o[t];if(""===i||"\r"===i)0===s.indent&&n.length>c&&(c=n.length);else{n.length<c&&r(u+n.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),0===s.indent&&(c=n.length),d=t,0!==c||e.atRoot||r(u,"BAD_INDENT","Block scalar values in collections must be indented");break}u+=n.length+i.length+1}for(let e=o.length-1;e>=l;--e)o[e][0].length>c&&(l=e+1);let f="",h="",p=!1;for(let e=0;e<d;++e)f+=o[e][0].slice(c)+"\n";for(let e=d;e<l;++e){let[t,i]=o[e];u+=t.length+i.length+1;let l="\r"===i[i.length-1];if(l&&(i=i.slice(0,-1)),i&&t.length<c){let e=s.indent?"explicit indentation indicator":"first line",n=`Block scalar lines must not be less indented than their ${e}`;r(u-i.length-(l?2:1),"BAD_INDENT",n),t=""}a===n.Scalar.BLOCK_LITERAL?(f+=h+t.slice(c)+i,h="\n"):t.length>c||" "===i[0]?(" "===h?h="\n":p||"\n"!==h||(h="\n\n"),f+=h+t.slice(c)+i,h="\n",p=!0):""===i?"\n"===h?f+="\n":h="\n":(f+=h+i,h=" ",p=!1)}switch(s.chomp){case"-":break;case"+":for(let e=l;e<o.length;++e)f+="\n"+o[e][0].slice(c);"\n"!==f[f.length-1]&&(f+="\n");break;default:f+="\n"}let m=i+s.length+t.source.length;return{value:f,type:a,comment:s.comment,range:[i,m,m]}}},6225(e,t,r){var n=r(7028),i=r(7800),s=r(7090);t.resolveBlockSeq=function({composeNode:e,composeEmptyNode:t},r,a,o,l){let c=new(l?.nodeClass??n.YAMLSeq)(r.schema);r.atRoot&&(r.atRoot=!1),r.atKey&&(r.atKey=!1);let u=a.offset,d=null;for(let{start:n,value:l}of a.items){let f=i.resolveProps(n,{indicator:"seq-item-ind",next:l,offset:u,onError:o,parentIndent:a.indent,startOnNewline:!0});if(!f.found)if(f.anchor||f.tag||l)l?.type==="block-seq"?o(f.end,"BAD_INDENT","All sequence items must start at the same column"):o(u,"MISSING_CHAR","Sequence item without - indicator");else{d=f.end,f.comment&&(c.comment=f.comment);continue}let h=l?e(r,l,f,o):t(r,f.end,n,null,f,o);r.schema.compat&&s.flowIndentCheck(a.indent,l,o),u=h.range[2],c.items.push(h)}return c.range=[a.offset,u,d??u],c}},4915(e,t){t.resolveEnd=function(e,t,r,n){let i="";if(e){let s=!1,a="";for(let o of e){let{source:e,type:l}=o;switch(l){case"space":s=!0;break;case"comment":{r&&!s&&n(o,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let t=e.substring(1)||" ";i?i+=a+t:i=t,a="";break}case"newline":i&&(a+=e),s=!0;break;default:n(o,"UNEXPECTED_TOKEN",`Unexpected ${l} at node end`)}t+=e.length}}return{comment:i,offset:t}}},9661(e,t,r){var n=r(6730),i=r(7748),s=r(73),a=r(7028),o=r(4915),l=r(7800),c=r(6884),u=r(8388);let d="Block collections are not allowed within flow collections",f=e=>e&&("block-map"===e.type||"block-seq"===e.type);t.resolveFlowCollection=function({composeNode:e,composeEmptyNode:t},r,h,p,m){let g="{"===h.start.source,y=g?"flow map":"flow sequence",b=new(m?.nodeClass??(g?s.YAMLMap:a.YAMLSeq))(r.schema);b.flow=!0;let v=r.atRoot;v&&(r.atRoot=!1),r.atKey&&(r.atKey=!1);let w=h.offset+h.start.source.length;for(let a=0;a<h.items.length;++a){let o=h.items[a],{start:m,key:v,sep:x,value:k}=o,S=l.resolveProps(m,{flow:y,indicator:"explicit-key-ind",next:v??x?.[0],offset:w,onError:p,parentIndent:h.indent,startOnNewline:!1});if(!S.found){if(!S.anchor&&!S.tag&&!x&&!k){0===a&&S.comma?p(S.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${y}`):a<h.items.length-1&&p(S.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${y}`),S.comment&&(b.comment?b.comment+="\n"+S.comment:b.comment=S.comment),w=S.end;continue}!g&&r.options.strict&&c.containsNewline(v)&&p(v,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(0===a)S.comma&&p(S.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${y}`);else if(S.comma||p(S.start,"MISSING_CHAR",`Missing , between ${y} items`),S.comment){let e="";e:for(let t of m)switch(t.type){case"comma":case"space":break;case"comment":e=t.source.substring(1);break e;default:break e}if(e){let t=b.items[b.items.length-1];n.isPair(t)&&(t=t.value??t.key),t.comment?t.comment+="\n"+e:t.comment=e,S.comment=S.comment.substring(e.length+1)}}if(g||x||S.found){r.atKey=!0;let n=S.end,a=v?e(r,v,S,p):t(r,n,m,null,S,p);f(v)&&p(a.range,"BLOCK_IN_FLOW",d),r.atKey=!1;let c=l.resolveProps(x??[],{flow:y,indicator:"map-value-ind",next:k,offset:a.range[2],onError:p,parentIndent:h.indent,startOnNewline:!1});if(c.found){if(!g&&!S.found&&r.options.strict){if(x)for(let e of x){if(e===c.found)break;if("newline"===e.type){p(e,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}S.start<c.found.offset-1024&&p(c.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else k&&("source"in k&&k.source?.[0]===":"?p(k,"MISSING_CHAR",`Missing space after : in ${y}`):p(c.start,"MISSING_CHAR",`Missing , or : between ${y} items`));let _=k?e(r,k,c,p):c.found?t(r,c.end,x,null,c,p):null;_?f(k)&&p(_.range,"BLOCK_IN_FLOW",d):c.comment&&(a.comment?a.comment+="\n"+c.comment:a.comment=c.comment);let $=new i.Pair(a,_);if(r.options.keepSourceTokens&&($.srcToken=o),g)u.mapIncludes(r,b.items,a)&&p(n,"DUPLICATE_KEY","Map keys must be unique"),b.items.push($);else{let e=new s.YAMLMap(r.schema);e.flow=!0,e.items.push($);let t=(_??a).range;e.range=[a.range[0],t[1],t[2]],b.items.push(e)}w=_?_.range[2]:c.end}else{let n=k?e(r,k,S,p):t(r,S.end,x,null,S,p);b.items.push(n),w=n.range[2],f(k)&&p(n.range,"BLOCK_IN_FLOW",d)}}let x=g?"}":"]",[k,...S]=h.end,_=w;if(k?.source===x)_=k.offset+k.source.length;else{let e=y[0].toUpperCase()+y.substring(1),t=v?`${e} must end with a ${x}`:`${e} in block collection must be sufficiently indented and end with a ${x}`;p(w,v?"MISSING_CHAR":"BAD_INDENT",t),k&&1!==k.source.length&&S.unshift(k)}if(S.length>0){let e=o.resolveEnd(S,_,r.options.strict,p);e.comment&&(b.comment?b.comment+="\n"+e.comment:b.comment=e.comment),b.range=[h.offset,_,e.offset]}else b.range=[h.offset,_,_];return b}},3165(e,t,r){var n=r(8376),i=r(4915);function s(e){let t,r;try{t=RegExp("(.*?)(?<![ ])[ ]*\r?\n","sy"),r=RegExp("[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?\n","sy")}catch{t=/(.*?)[ \t]*\r?\n/sy,r=/[ \t]*(.*?)[ \t]*\r?\n/sy}let n=t.exec(e);if(!n)return e;let i=n[1],s=" ",a=t.lastIndex;for(r.lastIndex=a;n=r.exec(e);)""===n[1]?"\n"===s?i+=s:s="\n":(i+=s+n[1],s=" "),a=r.lastIndex;let o=/[ \t]*(.*)/sy;return o.lastIndex=a,n=o.exec(e),i+s+(n?.[1]??"")}let a={0:"\0",a:"\x07",b:"\b",e:"\x1b",f:"\f",n:"\n",r:"\r",t:" ",v:"\v",N:"…",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};t.resolveFlowScalar=function(e,t,r){let o,l,{offset:c,type:u,source:d,end:f}=e,h=(e,t,n)=>r(c+e,t,n);switch(u){case"scalar":o=n.Scalar.PLAIN,l=function(e,t){let r="";switch(e[0]){case" ":r="a tab character";break;case",":r="flow indicator character ,";break;case"%":r="directive indicator character %";break;case"|":case">":r=`block scalar indicator ${e[0]}`;break;case"@":case"`":r=`reserved character ${e[0]}`}return r&&t(0,"BAD_SCALAR_START",`Plain value cannot start with ${r}`),s(e)}(d,h);break;case"single-quoted-scalar":var p,m;o=n.Scalar.QUOTE_SINGLE,p=d,m=h,("'"!==p[p.length-1]||1===p.length)&&m(p.length,"MISSING_CHAR","Missing closing 'quote"),l=s(p.slice(1,-1)).replace(/''/g,"'");break;case"double-quoted-scalar":o=n.Scalar.QUOTE_DOUBLE,l=function(e,t){let r="";for(let n=1;n<e.length-1;++n){let i=e[n];if("\r"!==i||"\n"!==e[n+1])if("\n"===i){let{fold:t,offset:i}=function(e,t){let r="",n=e[t+1];for(;(" "===n||" "===n||"\n"===n||"\r"===n)&&("\r"!==n||"\n"===e[t+2]);)"\n"===n&&(r+="\n"),t+=1,n=e[t+1];return r||(r=" "),{fold:r,offset:t}}(e,n);r+=t,n=i}else if("\\"===i){let i=e[++n],s=a[i];if(s)r+=s;else if("\n"===i)for(i=e[n+1];" "===i||" "===i;)i=e[++n+1];else if("\r"===i&&"\n"===e[n+1])for(i=e[++n+1];" "===i||" "===i;)i=e[++n+1];else if("x"===i||"u"===i||"U"===i){let s="x"===i?2:"u"===i?4:8;r+=function(e,t,r,n){let i=e.substr(t,r),s=i.length===r&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;try{return String.fromCodePoint(s)}catch{let i=e.substr(t-2,r+2);return n(t-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${i}`),i}}(e,n+1,s,t),n+=s}else{let i=e.substr(n-1,2);t(n-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${i}`),r+=i}}else if(" "===i||" "===i){let t=n,s=e[n+1];for(;" "===s||" "===s;)s=e[++n+1];"\n"!==s&&("\r"!==s||"\n"!==e[n+2])&&(r+=n>t?e.slice(t,n+1):i)}else r+=i}return('"'!==e[e.length-1]||1===e.length)&&t(e.length,"MISSING_CHAR",'Missing closing "quote'),r}(d,h);break;default:return r(e,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${u}`),{value:"",type:null,comment:"",range:[c,c+d.length,c+d.length]}}let g=c+d.length,y=i.resolveEnd(f,g,t,r);return{value:l,type:o,comment:y.comment,range:[c,g,y.offset]}}},7800(e,t){t.resolveProps=function(e,{flow:t,indicator:r,next:n,offset:i,onError:s,parentIndent:a,startOnNewline:o}){let l=!1,c=o,u=o,d="",f="",h=!1,p=!1,m=null,g=null,y=null,b=null,v=null,w=null,x=null;for(let i of e)switch(p&&("space"!==i.type&&"newline"!==i.type&&"comma"!==i.type&&s(i.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),p=!1),m&&(c&&"comment"!==i.type&&"newline"!==i.type&&s(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),m=null),i.type){case"space":!t&&("doc-start"!==r||n?.type!=="flow-collection")&&i.source.includes(" ")&&(m=i),u=!0;break;case"comment":{u||s(i,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let e=i.source.substring(1)||" ";d?d+=f+e:d=e,f="",c=!1;break}case"newline":c?d?d+=i.source:w&&"seq-item-ind"===r||(l=!0):f+=i.source,c=!0,h=!0,(g||y)&&(b=i),u=!0;break;case"anchor":g&&s(i,"MULTIPLE_ANCHORS","A node can have at most one anchor"),i.source.endsWith(":")&&s(i.offset+i.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),g=i,x??(x=i.offset),c=!1,u=!1,p=!0;break;case"tag":y&&s(i,"MULTIPLE_TAGS","A node can have at most one tag"),y=i,x??(x=i.offset),c=!1,u=!1,p=!0;break;case r:(g||y)&&s(i,"BAD_PROP_ORDER",`Anchors and tags must be after the ${i.source} indicator`),w&&s(i,"UNEXPECTED_TOKEN",`Unexpected ${i.source} in ${t??"collection"}`),w=i,c="seq-item-ind"===r||"explicit-key-ind"===r,u=!1;break;case"comma":if(t){v&&s(i,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`),v=i,c=!1,u=!1;break}default:s(i,"UNEXPECTED_TOKEN",`Unexpected ${i.type} token`),c=!1,u=!1}let k=e[e.length-1],S=k?k.offset+k.source.length:i;return p&&n&&"space"!==n.type&&"newline"!==n.type&&"comma"!==n.type&&("scalar"!==n.type||""!==n.source)&&s(n.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),m&&(c&&m.indent<=a||n?.type==="block-map"||n?.type==="block-seq")&&s(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:v,found:w,spaceBefore:l,comment:d,hasNewline:h,anchor:g,tag:y,newlineAfterProp:b,end:S,start:x??S}}},6884(e,t){t.containsNewline=function e(t){if(!t)return null;switch(t.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(t.source.includes("\n"))return!0;if(t.end){for(let e of t.end)if("newline"===e.type)return!0}return!1;case"flow-collection":for(let r of t.items){for(let e of r.start)if("newline"===e.type)return!0;if(r.sep){for(let e of r.sep)if("newline"===e.type)return!0}if(e(r.key)||e(r.value))return!0}return!1;default:return!0}}},4898(e,t){t.emptyScalarPosition=function(e,t,r){if(t){r??(r=t.length);for(let n=r-1;n>=0;--n){let r=t[n];switch(r.type){case"space":case"comment":case"newline":e-=r.source.length;continue}for(r=t[++n];r?.type==="space";)e+=r.source.length,r=t[++n];break}}return e}},7090(e,t,r){var n=r(6884);t.flowIndentCheck=function(e,t,r){if(t?.type==="flow-collection"){let i=t.end[0];i.indent===e&&("]"===i.source||"}"===i.source)&&n.containsNewline(t)&&r(i,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}},8388(e,t,r){var n=r(6730);t.mapIncludes=function(e,t,r){let{uniqueKeys:i}=e.options;if(!1===i)return!1;let s="function"==typeof i?i:(e,t)=>e===t||n.isScalar(e)&&n.isScalar(t)&&e.value===t.value;return t.some(e=>s(e.key,r))}},9960(e,t,r){var n=r(2298),i=r(7580),s=r(6730),a=r(7748),o=r(2234),l=r(8227),c=r(5966),u=r(9531),d=r(9768),f=r(7377),h=r(7087);function p(e){if(s.isCollection(e))return!0;throw Error("Expected a YAML collection as document contents")}t.Document=class e{constructor(e,t,r){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,s.NODE_TYPE,{value:s.DOC});let n=null;"function"==typeof t||Array.isArray(t)?n=t:void 0===r&&t&&(r=t,t=void 0);let i=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},r);this.options=i;let{version:a}=i;r?._directives?(this.directives=r._directives.atDocument(),this.directives.yaml.explicit&&(a=this.directives.yaml.version)):this.directives=new h.Directives({version:a}),this.setSchema(a,r),this.contents=void 0===e?null:this.createNode(e,n,r)}clone(){let t=Object.create(e.prototype,{[s.NODE_TYPE]:{value:s.DOC}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=s.isNode(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(e){p(this.contents)&&this.contents.add(e)}addIn(e,t){p(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let r=u.anchorNames(this);e.anchor=!t||r.has(t)?u.findNewAnchor(t||"a",r):t}return new n.Alias(e.anchor)}createNode(e,t,r){let n;if("function"==typeof t)e=t.call({"":e},"",e),n=t;else if(Array.isArray(t)){let e=t.filter(e=>"number"==typeof e||e instanceof String||e instanceof Number).map(String);e.length>0&&(t=t.concat(e)),n=t}else void 0===r&&t&&(r=t,t=void 0);let{aliasDuplicateObjects:i,anchorPrefix:a,flow:o,keepUndefined:l,onTagObj:c,tag:d}=r??{},{onAnchor:h,setAnchors:p,sourceObjects:m}=u.createNodeAnchors(this,a||"a"),g={aliasDuplicateObjects:i??!0,keepUndefined:l??!1,onAnchor:h,onTagObj:c,replacer:n,schema:this.schema,sourceObjects:m},y=f.createNode(e,d,g);return o&&s.isCollection(y)&&(y.flow=!0),p(),y}createPair(e,t,r={}){let n=this.createNode(e,null,r),i=this.createNode(t,null,r);return new a.Pair(n,i)}delete(e){return!!p(this.contents)&&this.contents.delete(e)}deleteIn(e){return i.isEmptyPath(e)?null!=this.contents&&(this.contents=null,!0):!!p(this.contents)&&this.contents.deleteIn(e)}get(e,t){return s.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return i.isEmptyPath(e)?!t&&s.isScalar(this.contents)?this.contents.value:this.contents:s.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return!!s.isCollection(this.contents)&&this.contents.has(e)}hasIn(e){return i.isEmptyPath(e)?void 0!==this.contents:!!s.isCollection(this.contents)&&this.contents.hasIn(e)}set(e,t){null==this.contents?this.contents=i.collectionFromPath(this.schema,[e],t):p(this.contents)&&this.contents.set(e,t)}setIn(e,t){i.isEmptyPath(e)?this.contents=t:null==this.contents?this.contents=i.collectionFromPath(this.schema,Array.from(e),t):p(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){let r;switch("number"==typeof e&&(e=String(e)),e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new h.Directives({version:"1.1"}),r={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=e:this.directives=new h.Directives({version:e}),r={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,r=null;break;default:{let t=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${t}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(r)this.schema=new l.Schema(Object.assign(r,t));else throw Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:t,mapAsMap:r,maxAliasCount:n,onAnchor:i,reviver:s}={}){let a={anchors:new Map,doc:this,keep:!e,mapAsMap:!0===r,mapKeyWarned:!1,maxAliasCount:"number"==typeof n?n:100},l=o.toJS(this.contents,t??"",a);if("function"==typeof i)for(let{count:e,res:t}of a.anchors.values())i(t,e);return"function"==typeof s?d.applyReviver(s,{"":l},"",l):l}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||0>=Number(e.indent))){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return c.stringifyDocument(this,e)}}},9531(e,t,r){var n=r(6730),i=r(7995);function s(e){let t=new Set;return i.visit(e,{Value(e,r){r.anchor&&t.add(r.anchor)}}),t}function a(e,t){for(let r=1;;++r){let n=`${e}${r}`;if(!t.has(n))return n}}t.anchorIsValid=function(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=JSON.stringify(e);throw Error(`Anchor must not contain whitespace or control characters: ${t}`)}return!0},t.anchorNames=s,t.createNodeAnchors=function(e,t){let r=[],i=new Map,o=null;return{onAnchor:n=>{r.push(n),o??(o=s(e));let i=a(t,o);return o.add(i),i},setAnchors:()=>{for(let e of r){let t=i.get(e);if("object"==typeof t&&t.anchor&&(n.isScalar(t.node)||n.isCollection(t.node)))t.node.anchor=t.anchor;else{let t=Error("Failed to resolve repeated object (this should not happen)");throw t.source=e,t}}},sourceObjects:i}},t.findNewAnchor=a},9768(e,t){t.applyReviver=function e(t,r,n,i){if(i&&"object"==typeof i)if(Array.isArray(i))for(let r=0,n=i.length;r<n;++r){let n=i[r],s=e(t,i,String(r),n);void 0===s?delete i[r]:s!==n&&(i[r]=s)}else if(i instanceof Map)for(let r of Array.from(i.keys())){let n=i.get(r),s=e(t,i,r,n);void 0===s?i.delete(r):s!==n&&i.set(r,s)}else if(i instanceof Set)for(let r of Array.from(i)){let n=e(t,i,r,r);void 0===n?i.delete(r):n!==r&&(i.delete(r),i.add(n))}else for(let[r,n]of Object.entries(i)){let s=e(t,i,r,n);void 0===s?delete i[r]:s!==n&&(i[r]=s)}return t.call(r,n,i)}},7377(e,t,r){var n=r(2298),i=r(6730),s=r(8376);t.createNode=function(e,t,r){let a;if(i.isDocument(e)&&(e=e.contents),i.isNode(e))return e;if(i.isPair(e)){let t=r.schema[i.MAP].createNode?.(r.schema,null,r);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||"u">typeof BigInt&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:o,onAnchor:l,onTagObj:c,schema:u,sourceObjects:d}=r;if(o&&e&&"object"==typeof e){if(a=d.get(e))return a.anchor??(a.anchor=l(e)),new n.Alias(a.anchor);a={anchor:null,node:null},d.set(e,a)}t?.startsWith("!!")&&(t="tag:yaml.org,2002:"+t.slice(2));let f=function(e,t,r){if(t){let e=r.filter(e=>e.tag===t),n=e.find(e=>!e.format)??e[0];if(!n)throw Error(`Tag ${t} not found`);return n}return r.find(t=>t.identify?.(e)&&!t.format)}(e,t,u.tags);if(!f){if(e&&"function"==typeof e.toJSON&&(e=e.toJSON()),!e||"object"!=typeof e){let t=new s.Scalar(e);return a&&(a.node=t),t}f=e instanceof Map?u[i.MAP]:Symbol.iterator in Object(e)?u[i.SEQ]:u[i.MAP]}c&&(c(f),delete r.onTagObj);let h=f?.createNode?f.createNode(r.schema,e,r):"function"==typeof f?.nodeClass?.from?f.nodeClass.from(r.schema,e,r):new s.Scalar(e);return t?h.tag=t:f.default||(h.tag=f.tag),a&&(a.node=h),h}},7087(e,t,r){var n=r(6730),i=r(7995);let s={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},a=e=>e.replace(/[!,[\]{}]/g,e=>s[e]);class o{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},o.defaultYaml,e),this.tags=Object.assign({},o.defaultTags,t)}clone(){let e=new o(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new o(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:o.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},o.defaultTags)}return e}add(e,t){this.atNextDocument&&(this.yaml={explicit:o.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},o.defaultTags),this.atNextDocument=!1);let r=e.trim().split(/[ \t]+/),n=r.shift();switch(n){case"%TAG":{if(2!==r.length&&(t(0,"%TAG directive should contain exactly two parts"),r.length<2))return!1;let[e,n]=r;return this.tags[e]=n,!0}case"%YAML":{if(this.yaml.explicit=!0,1!==r.length)return t(0,"%YAML directive should contain exactly one part"),!1;let[e]=r;if("1.1"===e||"1.2"===e)return this.yaml.version=e,!0;{let r=/^\d+\.\d+$/.test(e);return t(6,`Unsupported YAML version ${e}`,r),!1}}default:return t(0,`Unknown directive ${n}`,!0),!1}}tagName(e,t){if("!"===e)return"!";if("!"!==e[0])return t(`Not a valid tag: ${e}`),null;if("<"===e[1]){let r=e.slice(2,-1);return"!"===r||"!!"===r?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(">"!==e[e.length-1]&&t("Verbatim tags must end with a >"),r)}let[,r,n]=e.match(/^(.*!)([^!]*)$/s);n||t(`The ${e} tag has no suffix`);let i=this.tags[r];if(i)try{return i+decodeURIComponent(n)}catch(e){return t(String(e)),null}return"!"===r?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,r]of Object.entries(this.tags))if(e.startsWith(r))return t+a(e.substring(r.length));return"!"===e[0]?e:`!<${e}>`}toString(e){let t,r=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],s=Object.entries(this.tags);if(e&&s.length>0&&n.isNode(e.contents)){let r={};i.visit(e.contents,(e,t)=>{n.isNode(t)&&t.tag&&(r[t.tag]=!0)}),t=Object.keys(r)}else t=[];for(let[n,i]of s)("!!"!==n||"tag:yaml.org,2002:"!==i)&&(!e||t.some(e=>e.startsWith(i)))&&r.push(`%TAG ${n} ${i}`);return r.join("\n")}}o.defaultYaml={explicit:!1,version:"1.2"},o.defaultTags={"!!":"tag:yaml.org,2002:"},t.Directives=o},3409(e,t){class r extends Error{constructor(e,t,r,n){super(),this.name=e,this.code=r,this.message=n,this.pos=t}}t.YAMLError=r,t.YAMLParseError=class extends r{constructor(e,t,r){super("YAMLParseError",e,t,r)}},t.YAMLWarning=class extends r{constructor(e,t,r){super("YAMLWarning",e,t,r)}},t.prettifyError=(e,t)=>r=>{if(-1===r.pos[0])return;r.linePos=r.pos.map(e=>t.linePos(e));let{line:n,col:i}=r.linePos[0];r.message+=` at line ${n}, column ${i}`;let s=i-1,a=e.substring(t.lineStarts[n-1],t.lineStarts[n]).replace(/[\n\r]+$/,"");if(s>=60&&a.length>80){let e=Math.min(s-39,a.length-79);a="…"+a.substring(e),s-=e-1}if(a.length>80&&(a=a.substring(0,79)+"…"),n>1&&/^ *$/.test(a.substring(0,s))){let r=e.substring(t.lineStarts[n-2],t.lineStarts[n-1]);r.length>80&&(r=r.substring(0,79)+"…\n"),a=r+a}if(/[^ ]/.test(a)){let e=1,t=r.linePos[1];t?.line===n&&t.col>i&&(e=Math.max(1,Math.min(t.col-i,80-s)));let o=" ".repeat(s)+"^".repeat(e);r.message+=`:
7
-
8
- ${a}
9
- ${o}
10
- `}}},2976(e,t,r){var n=r(2545),i=r(9960),s=r(8227),a=r(3409),o=r(2298),l=r(6730),c=r(7748),u=r(8376),d=r(73),f=r(7028);r(9810);var h=r(7894),p=r(3813),m=r(5849),g=r(1094),y=r(7995);n.Composer,i.Document,s.Schema,a.YAMLError,a.YAMLParseError,a.YAMLWarning,o.Alias,l.isAlias,l.isCollection,l.isDocument,l.isMap,l.isNode,l.isPair,l.isScalar,l.isSeq,c.Pair,u.Scalar,d.YAMLMap,f.YAMLSeq,h.Lexer,p.LineCounter,m.Parser,g.parse,g.parseAllDocuments,g.parseDocument,g.stringify,y.visit,y.visitAsync},2186(e,t,r){var n=r(932);t.debug=function(e,...t){"debug"===e&&console.log(...t)},t.warn=function(e,t){("debug"===e||"warn"===e)&&("function"==typeof n.emitWarning?n.emitWarning(t):console.warn(t))}},2298(e,t,r){var n=r(9531),i=r(7995),s=r(6730),a=r(5476),o=r(2234);class l extends a.NodeBase{constructor(e){super(s.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw Error("Alias nodes cannot have tags")}})}resolve(e,t){let r,n;if(t?.maxAliasCount===0)throw ReferenceError("Alias resolution is disabled");for(let a of(t?.aliasResolveCache?r=t.aliasResolveCache:(r=[],i.visit(e,{Node:(e,t)=>{(s.isAlias(t)||s.hasAnchor(t))&&r.push(t)}}),t&&(t.aliasResolveCache=r)),r)){if(a===this)break;a.anchor===this.source&&(n=a)}return n}toJSON(e,t){if(!t)return{source:this.source};let{anchors:r,doc:n,maxAliasCount:i}=t,a=this.resolve(n,t);if(!a)throw ReferenceError(`Unresolved alias (the anchor must be set before the alias): ${this.source}`);let l=r.get(a);if(l||(o.toJS(a,null,t),l=r.get(a)),l?.res===void 0)throw ReferenceError("This should not happen: Alias anchor was not resolved?");if(i>=0&&(l.count+=1,0===l.aliasCount&&(l.aliasCount=function e(t,r,n){if(s.isAlias(r)){let e=r.resolve(t),i=n&&e&&n.get(e);return i?i.count*i.aliasCount:0}if(s.isCollection(r)){let i=0;for(let s of r.items){let r=e(t,s,n);r>i&&(i=r)}return i}return s.isPair(r)?Math.max(e(t,r.key,n),e(t,r.value,n)):1}(n,a,r)),l.count*l.aliasCount>i))throw ReferenceError("Excessive alias count indicates a resource exhaustion attack");return l.res}toString(e,t,r){let i=`*${this.source}`;if(e){if(n.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source))throw Error(`Unresolved alias (the anchor must be set before the alias): ${this.source}`);if(e.implicitKey)return`${i} `}return i}}t.Alias=l},7580(e,t,r){var n=r(7377),i=r(6730),s=r(5476);function a(e,t,r){let i=r;for(let e=t.length-1;e>=0;--e){let r=t[e];if("number"==typeof r&&Number.isInteger(r)&&r>=0){let e=[];e[r]=i,i=e}else i=new Map([[r,i]])}return n.createNode(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}let o=e=>null==e||"object"==typeof e&&!!e[Symbol.iterator]().next().done;class l extends s.NodeBase{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(t=>i.isNode(t)||i.isPair(t)?t.clone(e):t),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(o(e))this.add(t);else{let[r,...n]=e,s=this.get(r,!0);if(i.isCollection(s))s.addIn(n,t);else if(void 0===s&&this.schema)this.set(r,a(this.schema,n,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${n}`)}}deleteIn(e){let[t,...r]=e;if(0===r.length)return this.delete(t);let n=this.get(t,!0);if(i.isCollection(n))return n.deleteIn(r);throw Error(`Expected YAML collection at ${t}. Remaining path: ${r}`)}getIn(e,t){let[r,...n]=e,s=this.get(r,!0);return 0===n.length?!t&&i.isScalar(s)?s.value:s:i.isCollection(s)?s.getIn(n,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!i.isPair(t))return!1;let r=t.value;return null==r||e&&i.isScalar(r)&&null==r.value&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(e){let[t,...r]=e;if(0===r.length)return this.has(t);let n=this.get(t,!0);return!!i.isCollection(n)&&n.hasIn(r)}setIn(e,t){let[r,...n]=e;if(0===n.length)this.set(r,t);else{let e=this.get(r,!0);if(i.isCollection(e))e.setIn(n,t);else if(void 0===e&&this.schema)this.set(r,a(this.schema,n,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${n}`)}}}t.Collection=l,t.collectionFromPath=a,t.isEmptyPath=o},5476(e,t,r){var n=r(9768),i=r(6730),s=r(2234);t.NodeBase=class{constructor(e){Object.defineProperty(this,i.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:r,onAnchor:a,reviver:o}={}){if(!i.isDocument(e))throw TypeError("A document argument is required");let l={anchors:new Map,doc:e,keep:!0,mapAsMap:!0===t,mapKeyWarned:!1,maxAliasCount:"number"==typeof r?r:100},c=s.toJS(this,"",l);if("function"==typeof a)for(let{count:e,res:t}of l.anchors.values())a(t,e);return"function"==typeof o?n.applyReviver(o,{"":c},"",c):c}}},7748(e,t,r){var n=r(7377),i=r(4711),s=r(3757),a=r(6730);class o{constructor(e,t=null){Object.defineProperty(this,a.NODE_TYPE,{value:a.PAIR}),this.key=e,this.value=t}clone(e){let{key:t,value:r}=this;return a.isNode(t)&&(t=t.clone(e)),a.isNode(r)&&(r=r.clone(e)),new o(t,r)}toJSON(e,t){let r=t?.mapAsMap?new Map:{};return s.addPairToJSMap(t,r,this)}toString(e,t,r){return e?.doc?i.stringifyPair(this,e,t,r):JSON.stringify(this)}}t.Pair=o,t.createPair=function(e,t,r){return new o(n.createNode(e,void 0,r),n.createNode(t,void 0,r))}},8376(e,t,r){var n=r(6730),i=r(5476),s=r(2234);class a extends i.NodeBase{constructor(e){super(n.SCALAR),this.value=e}toJSON(e,t){return t?.keep?this.value:s.toJS(this.value,e,t)}toString(){return String(this.value)}}a.BLOCK_FOLDED="BLOCK_FOLDED",a.BLOCK_LITERAL="BLOCK_LITERAL",a.PLAIN="PLAIN",a.QUOTE_DOUBLE="QUOTE_DOUBLE",a.QUOTE_SINGLE="QUOTE_SINGLE",t.Scalar=a,t.isScalarValue=e=>!e||"function"!=typeof e&&"object"!=typeof e},73(e,t,r){var n=r(8143),i=r(3757),s=r(7580),a=r(6730),o=r(7748),l=r(8376);function c(e,t){let r=a.isScalar(t)?t.value:t;for(let n of e)if(a.isPair(n)&&(n.key===t||n.key===r||a.isScalar(n.key)&&n.key.value===r))return n}class u extends s.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(a.MAP,e),this.items=[]}static from(e,t,r){let{keepUndefined:n,replacer:i}=r,s=new this(e),a=(e,a)=>{if("function"==typeof i)a=i.call(t,e,a);else if(Array.isArray(i)&&!i.includes(e))return;(void 0!==a||n)&&s.items.push(o.createPair(e,a,r))};if(t instanceof Map)for(let[e,r]of t)a(e,r);else if(t&&"object"==typeof t)for(let e of Object.keys(t))a(e,t[e]);return"function"==typeof e.sortMapEntries&&s.items.sort(e.sortMapEntries),s}add(e,t){let r;r=a.isPair(e)?e:e&&"object"==typeof e&&"key"in e?new o.Pair(e.key,e.value):new o.Pair(e,e?.value);let n=c(this.items,r.key),i=this.schema?.sortMapEntries;if(n){if(!t)throw Error(`Key ${r.key} already set`);a.isScalar(n.value)&&l.isScalarValue(r.value)?n.value.value=r.value:n.value=r.value}else if(i){let e=this.items.findIndex(e=>0>i(r,e));-1===e?this.items.push(r):this.items.splice(e,0,r)}else this.items.push(r)}delete(e){let t=c(this.items,e);return!!t&&this.items.splice(this.items.indexOf(t),1).length>0}get(e,t){let r=c(this.items,e),n=r?.value;return(!t&&a.isScalar(n)?n.value:n)??void 0}has(e){return!!c(this.items,e)}set(e,t){this.add(new o.Pair(e,t),!0)}toJSON(e,t,r){let n=r?new r:t?.mapAsMap?new Map:{};for(let e of(t?.onCreate&&t.onCreate(n),this.items))i.addPairToJSMap(t,n,e);return n}toString(e,t,r){if(!e)return JSON.stringify(this);for(let e of this.items)if(!a.isPair(e))throw Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),n.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:r,onComment:t})}}t.YAMLMap=u,t.findPair=c},7028(e,t,r){var n=r(7377),i=r(8143),s=r(7580),a=r(6730),o=r(8376),l=r(2234);class c extends s.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(a.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=u(e);return"number"==typeof t&&this.items.splice(t,1).length>0}get(e,t){let r=u(e);if("number"!=typeof r)return;let n=this.items[r];return!t&&a.isScalar(n)?n.value:n}has(e){let t=u(e);return"number"==typeof t&&t<this.items.length}set(e,t){let r=u(e);if("number"!=typeof r)throw Error(`Expected a valid index, not ${e}.`);let n=this.items[r];a.isScalar(n)&&o.isScalarValue(t)?n.value=t:this.items[r]=t}toJSON(e,t){let r=[];t?.onCreate&&t.onCreate(r);let n=0;for(let e of this.items)r.push(l.toJS(e,String(n++),t));return r}toString(e,t,r){return e?i.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:r,onComment:t}):JSON.stringify(this)}static from(e,t,r){let{replacer:i}=r,s=new this(e);if(t&&Symbol.iterator in Object(t)){let e=0;for(let a of t){if("function"==typeof i){let r=t instanceof Set?a:String(e++);a=i.call(t,r,a)}s.items.push(n.createNode(a,void 0,r))}}return s}}function u(e){let t=a.isScalar(e)?e.value:e;return t&&"string"==typeof t&&(t=Number(t)),"number"==typeof t&&Number.isInteger(t)&&t>=0?t:null}t.YAMLSeq=c},3757(e,t,r){var n=r(2186),i=r(8327),s=r(6203),a=r(6730),o=r(2234);t.addPairToJSMap=function(e,t,{key:r,value:l}){if(a.isNode(r)&&r.addToJSMap)r.addToJSMap(e,t,l);else if(i.isMergeKey(e,r))i.addMergeToJSMap(e,t,l);else{let i=o.toJS(r,"",e);if(t instanceof Map)t.set(i,o.toJS(l,i,e));else if(t instanceof Set)t.add(i);else{let c=function(e,t,r){if(null===t)return"";if("object"!=typeof t)return String(t);if(a.isNode(e)&&r?.doc){let t=s.createStringifyContext(r.doc,{});for(let e of(t.anchors=new Set,r.anchors.keys()))t.anchors.add(e.anchor);t.inFlow=!0,t.inStringifyKey=!0;let i=e.toString(t);if(!r.mapKeyWarned){let e=JSON.stringify(i);e.length>40&&(e=e.substring(0,36)+'..."'),n.warn(r.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`),r.mapKeyWarned=!0}return i}return JSON.stringify(t)}(r,i,e),u=o.toJS(l,c,e);c in t?Object.defineProperty(t,c,{value:u,writable:!0,enumerable:!0,configurable:!0}):t[c]=u}}return t}},6730(e,t){let r=Symbol.for("yaml.alias"),n=Symbol.for("yaml.document"),i=Symbol.for("yaml.map"),s=Symbol.for("yaml.pair"),a=Symbol.for("yaml.scalar"),o=Symbol.for("yaml.seq"),l=Symbol.for("yaml.node.type"),c=e=>!!e&&"object"==typeof e&&e[l]===a;function u(e){if(e&&"object"==typeof e)switch(e[l]){case i:case o:return!0}return!1}t.ALIAS=r,t.DOC=n,t.MAP=i,t.NODE_TYPE=l,t.PAIR=s,t.SCALAR=a,t.SEQ=o,t.hasAnchor=e=>(c(e)||u(e))&&!!e.anchor,t.isAlias=e=>!!e&&"object"==typeof e&&e[l]===r,t.isCollection=u,t.isDocument=e=>!!e&&"object"==typeof e&&e[l]===n,t.isMap=e=>!!e&&"object"==typeof e&&e[l]===i,t.isNode=function(e){if(e&&"object"==typeof e)switch(e[l]){case r:case i:case a:case o:return!0}return!1},t.isPair=e=>!!e&&"object"==typeof e&&e[l]===s,t.isScalar=c,t.isSeq=e=>!!e&&"object"==typeof e&&e[l]===o},2234(e,t,r){var n=r(6730);t.toJS=function e(t,r,i){if(Array.isArray(t))return t.map((t,r)=>e(t,String(r),i));if(t&&"function"==typeof t.toJSON){if(!i||!n.hasAnchor(t))return t.toJSON(r,i);let e={aliasCount:0,count:1,res:void 0};i.anchors.set(t,e),i.onCreate=t=>{e.res=t,delete i.onCreate};let s=t.toJSON(r,i);return i.onCreate&&i.onCreate(s),s}return"bigint"!=typeof t||i?.keep?t:Number(t)}},8215(e,t,r){var n=r(2992),i=r(3165),s=r(3409),a=r(4286);function o(e,t){if(t)for(let r of t)switch(r.type){case"space":case"comment":e.push(r);break;case"newline":return e.push(r),!0}return!1}function l(e,t,r){switch(e.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":e.type=r,e.source=t;break;case"block-scalar":{let n=e.props.slice(1),i=t.length;for(let t of("block-scalar-header"===e.props[0].type&&(i-=e.props[0].source.length),n))t.offset+=i;delete e.props,Object.assign(e,{type:r,source:t,end:n});break}case"block-map":case"block-seq":{let n={type:"newline",offset:e.offset+t.length,indent:e.indent,source:"\n"};delete e.items,Object.assign(e,{type:r,source:t,end:[n]});break}default:{let n="indent"in e?e.indent:-1,i="end"in e&&Array.isArray(e.end)?e.end.filter(e=>"space"===e.type||"comment"===e.type||"newline"===e.type):[];for(let t of Object.keys(e))"type"!==t&&"offset"!==t&&delete e[t];Object.assign(e,{type:r,indent:n,source:t,end:i})}}}t.createScalarToken=function(e,t){let{implicitKey:r=!1,indent:n,inFlow:i=!1,offset:s=-1,type:l="PLAIN"}=t,c=a.stringifyString({type:l,value:e},{implicitKey:r,indent:n>0?" ".repeat(n):"",inFlow:i,options:{blockQuote:!0,lineWidth:-1}}),u=t.end??[{type:"newline",offset:-1,indent:n,source:"\n"}];switch(c[0]){case"|":case">":{let e=c.indexOf("\n"),t=c.substring(0,e),r=c.substring(e+1)+"\n",i=[{type:"block-scalar-header",offset:s,indent:n,source:t}];return o(i,u)||i.push({type:"newline",offset:-1,indent:n,source:"\n"}),{type:"block-scalar",offset:s,indent:n,props:i,source:r}}case'"':return{type:"double-quoted-scalar",offset:s,indent:n,source:c,end:u};case"'":return{type:"single-quoted-scalar",offset:s,indent:n,source:c,end:u};default:return{type:"scalar",offset:s,indent:n,source:c,end:u}}},t.resolveAsScalar=function(e,t=!0,r){if(e){let a=(e,t,n)=>{let i="number"==typeof e?e:Array.isArray(e)?e[0]:e.offset;if(r)r(i,t,n);else throw new s.YAMLParseError([i,i+1],t,n)};switch(e.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return i.resolveFlowScalar(e,t,a);case"block-scalar":return n.resolveBlockScalar({options:{strict:t}},e,a)}}return null},t.setScalarValue=function(e,t,r={}){let{afterKey:n=!1,implicitKey:i=!1,inFlow:s=!1,type:c}=r,u="indent"in e?e.indent:null;if(n&&"number"==typeof u&&(u+=2),!c)switch(e.type){case"single-quoted-scalar":c="QUOTE_SINGLE";break;case"double-quoted-scalar":c="QUOTE_DOUBLE";break;case"block-scalar":{let t=e.props[0];if("block-scalar-header"!==t.type)throw Error("Invalid block scalar header");c=">"===t.source[0]?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:c="PLAIN"}let d=a.stringifyString({type:c,value:t},{implicitKey:i||null===u,indent:null!==u&&u>0?" ".repeat(u):"",inFlow:s,options:{blockQuote:!0,lineWidth:-1}});switch(d[0]){case"|":case">":!function(e,t){let r=t.indexOf("\n"),n=t.substring(0,r),i=t.substring(r+1)+"\n";if("block-scalar"===e.type){let t=e.props[0];if("block-scalar-header"!==t.type)throw Error("Invalid block scalar header");t.source=n,e.source=i}else{let{offset:t}=e,r="indent"in e?e.indent:-1,s=[{type:"block-scalar-header",offset:t,indent:r,source:n}];for(let t of(o(s,"end"in e?e.end:void 0)||s.push({type:"newline",offset:-1,indent:r,source:"\n"}),Object.keys(e)))"type"!==t&&"offset"!==t&&delete e[t];Object.assign(e,{type:"block-scalar",indent:r,props:s,source:i})}}(e,d);break;case'"':l(e,d,"double-quoted-scalar");break;case"'":l(e,d,"single-quoted-scalar");break;default:l(e,d,"scalar")}}},2142(e,t){function r(e){switch(e.type){case"block-scalar":{let t="";for(let n of e.props)t+=r(n);return t+e.source}case"block-map":case"block-seq":{let t="";for(let r of e.items)t+=n(r);return t}case"flow-collection":{let t=e.start.source;for(let r of e.items)t+=n(r);for(let r of e.end)t+=r.source;return t}case"document":{let t=n(e);if(e.end)for(let r of e.end)t+=r.source;return t}default:{let t=e.source;if("end"in e&&e.end)for(let r of e.end)t+=r.source;return t}}}function n({start:e,key:t,sep:i,value:s}){let a="";for(let t of e)a+=t.source;if(t&&(a+=r(t)),i)for(let e of i)a+=e.source;return s&&(a+=r(s)),a}t.stringify=e=>"type"in e?r(e):n(e)},1844(e,t){let r=Symbol("break visit"),n=Symbol("skip children"),i=Symbol("remove item");function s(e,t){"type"in e&&"document"===e.type&&(e={start:e.start,value:e.value}),function e(t,n,s){let a=s(n,t);if("symbol"==typeof a)return a;for(let o of["key","value"]){let l=n[o];if(l&&"items"in l){for(let n=0;n<l.items.length;++n){let a=e(Object.freeze(t.concat([[o,n]])),l.items[n],s);if("number"==typeof a)n=a-1;else{if(a===r)return r;a===i&&(l.items.splice(n,1),n-=1)}}"function"==typeof a&&"key"===o&&(a=a(n,t))}}return"function"==typeof a?a(n,t):a}(Object.freeze([]),e,t)}s.BREAK=r,s.SKIP=n,s.REMOVE=i,s.itemAtPath=(e,t)=>{let r=e;for(let[e,n]of t){let t=r?.[e];if(!t||!("items"in t))return;r=t.items[n]}return r},s.parentCollection=(e,t)=>{let r=s.itemAtPath(e,t.slice(0,-1)),n=t[t.length-1][0],i=r?.[n];if(i&&"items"in i)return i;throw Error("Parent collection not found")},t.visit=s},9810(e,t,r){var n=r(8215),i=r(2142),s=r(1844);t.createScalarToken=n.createScalarToken,t.resolveAsScalar=n.resolveAsScalar,t.setScalarValue=n.setScalarValue,t.stringify=i.stringify,t.visit=s.visit,t.BOM="\uFEFF",t.DOCUMENT="\x02",t.FLOW_END="\x18",t.SCALAR="\x1f",t.isCollection=e=>!!e&&"items"in e,t.isScalar=e=>!!e&&("scalar"===e.type||"single-quoted-scalar"===e.type||"double-quoted-scalar"===e.type||"block-scalar"===e.type),t.prettyToken=function(e){switch(e){case"\uFEFF":return"<BOM>";case"\x02":return"<DOC>";case"\x18":return"<FLOW_END>";case"\x1f":return"<SCALAR>";default:return JSON.stringify(e)}},t.tokenType=function(e){switch(e){case"\uFEFF":return"byte-order-mark";case"\x02":return"doc-mode";case"\x18":return"flow-error-end";case"\x1f":return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case"\n":case"\r\n":return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(e[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}},7894(e,t,r){var n=r(9810);function i(e){switch(e){case void 0:case" ":case"\n":case"\r":case" ":return!0;default:return!1}}let s=new Set("0123456789ABCDEFabcdef"),a=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),o=new Set(",[]{}"),l=new Set(" ,[]{}\n\r "),c=e=>!e||l.has(e);t.Lexer=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,t=!1){if(e){if("string"!=typeof e)throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let r=this.next??"stream";for(;r&&(t||this.hasChars(1));)r=yield*this.parseNext(r)}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;" "===t||" "===t;)t=this.buffer[++e];return!t||"#"===t||"\n"===t||"\r"===t&&"\n"===this.buffer[e+1]}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let t=this.buffer[e];if(this.indentNext>0){let r=0;for(;" "===t;)t=this.buffer[++r+e];if("\r"===t){let t=this.buffer[r+e+1];if("\n"===t||!t&&!this.atEnd)return e+r+1}return"\n"!==t&&!(r>=this.indentNext)&&(t||this.atEnd)?-1:e+r}if("-"===t||"."===t){let t=this.buffer.substr(e,3);if(("---"===t||"..."===t)&&i(this.buffer[e+3]))return -1}return e}getLine(){let e=this.lineEndPos;return(("number"!=typeof e||-1!==e&&e<this.pos)&&(e=this.buffer.indexOf("\n",this.pos),this.lineEndPos=e),-1===e)?this.atEnd?this.buffer.substring(this.pos):null:("\r"===this.buffer[e-1]&&(e-=1),this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(null===e)return this.setNext("stream");if(e[0]===n.BOM&&(yield*this.pushCount(1),e=e.substring(1)),"%"===e[0]){let t=e.length,r=e.indexOf("#");for(;-1!==r;){let n=e[r-1];if(" "===n||" "===n){t=r-1;break}r=e.indexOf("#",r+1)}for(;;){let r=e[t-1];if(" "===r||" "===r)t-=1;else break}let n=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-n),this.pushNewline(),"stream"}if(this.atLineEnd()){let t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),"stream"}return yield n.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if("-"===e||"."===e){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let e=this.peek(3);if(("---"===e||"..."===e)&&i(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,"---"===e?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!i(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext("block-start");if(("-"===e||"?"===e||":"===e)&&i(t)){let e=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=e,"block-start"}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(null===e)return this.setNext("doc");let t=yield*this.pushIndicators();switch(e[t]){case"#":yield*this.pushCount(e.length-t);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(c),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return t+=yield*this.parseBlockScalarHeader(),t+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-t),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,t,r=-1;do(e=yield*this.pushNewline())>0?(t=yield*this.pushSpaces(!1),this.indentValue=r=t):t=0,t+=yield*this.pushSpaces(!0);while(e+t>0)let s=this.getLine();if(null===s)return this.setNext("flow");if((-1!==r&&r<this.indentNext&&"#"!==s[0]||0===r&&(s.startsWith("---")||s.startsWith("..."))&&i(s[3]))&&(r!==this.indentNext-1||1!==this.flowLevel||"]"!==s[0]&&"}"!==s[0]))return this.flowLevel=0,yield n.FLOW_END,yield*this.parseLineStart();let a=0;for(;","===s[a];)a+=yield*this.pushCount(1),a+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(s[a+=yield*this.pushIndicators()]){case void 0:return"flow";case"#":return yield*this.pushCount(s.length-a),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(c),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let e=this.charAt(1);if(this.flowKey||i(e)||","===e)return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),t=this.buffer.indexOf(e,this.pos+1);if("'"===e)for(;-1!==t&&"'"===this.buffer[t+1];)t=this.buffer.indexOf("'",t+2);else for(;-1!==t;){let e=0;for(;"\\"===this.buffer[t-1-e];)e+=1;if(e%2==0)break;t=this.buffer.indexOf('"',t+1)}let r=this.buffer.substring(0,t),n=r.indexOf("\n",this.pos);if(-1!==n){for(;-1!==n;){let e=this.continueScalar(n+1);if(-1===e)break;n=r.indexOf("\n",e)}-1!==n&&(t=n-("\r"===r[n-1]?2:1))}if(-1===t){if(!this.atEnd)return this.setNext("quoted-scalar");t=this.buffer.length}return yield*this.pushToIndex(t+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let t=this.buffer[++e];if("+"===t)this.blockScalarKeep=!0;else if(t>"0"&&t<="9")this.blockScalarIndent=Number(t)-1;else if("-"!==t)break}return yield*this.pushUntil(e=>i(e)||"#"===e)}*parseBlockScalar(){let e,t=this.pos-1,r=0;e:for(let n=this.pos;e=this.buffer[n];++n)switch(e){case" ":r+=1;break;case"\n":t=n,r=0;break;case"\r":{let e=this.buffer[n+1];if(!e&&!this.atEnd)return this.setNext("block-scalar");if("\n"===e)break}default:break e}if(!e&&!this.atEnd)return this.setNext("block-scalar");if(r>=this.indentNext){-1===this.blockScalarIndent?this.indentNext=r:this.indentNext=this.blockScalarIndent+(0===this.indentNext?1:this.indentNext);do{let e=this.continueScalar(t+1);if(-1===e)break;t=this.buffer.indexOf("\n",e)}while(-1!==t)if(-1===t){if(!this.atEnd)return this.setNext("block-scalar");t=this.buffer.length}}let i=t+1;for(e=this.buffer[i];" "===e;)e=this.buffer[++i];if(" "===e){for(;" "===e||" "===e||"\r"===e||"\n"===e;)e=this.buffer[++i];t=i-1}else if(!this.blockScalarKeep)for(;;){let e=t-1,n=this.buffer[e];"\r"===n&&(n=this.buffer[--e]);let i=e;for(;" "===n;)n=this.buffer[--e];if("\n"===n&&e>=this.pos&&e+1+r>i)t=e;else break}return yield n.SCALAR,yield*this.pushToIndex(t+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e,t=this.flowLevel>0,r=this.pos-1,s=this.pos-1;for(;e=this.buffer[++s];)if(":"===e){let e=this.buffer[s+1];if(i(e)||t&&o.has(e))break;r=s}else if(i(e)){let n=this.buffer[s+1];if("\r"===e&&("\n"===n?(s+=1,e="\n",n=this.buffer[s+1]):r=s),"#"===n||t&&o.has(n))break;if("\n"===e){let e=this.continueScalar(s+1);if(-1===e)break;s=Math.max(s,e-2)}}else{if(t&&o.has(e))break;r=s}return e||this.atEnd?(yield n.SCALAR,yield*this.pushToIndex(r+1,!0),t?"flow":"doc"):this.setNext("plain-scalar")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){let r=this.buffer.slice(this.pos,e);return r?(yield r,this.pos+=r.length,r.length):(t&&(yield""),0)}*pushIndicators(){let e=0;for(;;){switch(this.charAt(0)){case"!":e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue;case"&":e+=yield*this.pushUntil(c),e+=yield*this.pushSpaces(!0);continue;case"-":case"?":case":":{let t=this.flowLevel>0,r=this.charAt(1);if(i(r)||t&&o.has(r)){t?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue}}}break}return e}*pushTag(){if("<"===this.charAt(1)){let e=this.pos+2,t=this.buffer[e];for(;!i(t)&&">"!==t;)t=this.buffer[++e];return yield*this.pushToIndex(">"===t?e+1:e,!1)}{let e=this.pos+1,t=this.buffer[e];for(;t;)if(a.has(t))t=this.buffer[++e];else if("%"===t&&s.has(this.buffer[e+1])&&s.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return"\n"===e?yield*this.pushCount(1):"\r"===e&&"\n"===this.charAt(1)?yield*this.pushCount(2):0}*pushSpaces(e){let t,r=this.pos-1;do t=this.buffer[++r];while(" "===t||e&&" "===t)let n=r-this.pos;return n>0&&(yield this.buffer.substr(this.pos,n),this.pos=r),n}*pushUntil(e){let t=this.pos,r=this.buffer[t];for(;!e(r);)r=this.buffer[++t];return yield*this.pushToIndex(t,!1)}}},3813(e,t){t.LineCounter=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,r=this.lineStarts.length;for(;t<r;){let n=t+r>>1;this.lineStarts[n]<e?t=n+1:r=n}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(0===t)return{line:0,col:e};let n=this.lineStarts[t-1];return{line:t,col:e-n+1}}}}},5849(e,t,r){var n=r(932),i=r(9810),s=r(7894);function a(e,t){for(let r=0;r<e.length;++r)if(e[r].type===t)return!0;return!1}function o(e){for(let t=0;t<e.length;++t)switch(e[t].type){case"space":case"comment":case"newline":break;default:return t}return -1}function l(e){switch(e?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function c(e){switch(e.type){case"document":return e.start;case"block-map":{let t=e.items[e.items.length-1];return t.sep??t.start}case"block-seq":return e.items[e.items.length-1].start;default:return[]}}function u(e){if(0===e.length)return[];let t=e.length;e:for(;--t>=0;)switch(e[t].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;e[++t]?.type==="space";);return e.splice(t,e.length)}function d(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let r=0;r<t.length;++r)e.push(t[r])}function f(e){if("flow-seq-start"===e.start.type)for(let t of e.items)!t.sep||t.value||a(t.start,"explicit-key-ind")||a(t.sep,"map-value-ind")||(t.key&&(t.value=t.key),delete t.key,l(t.value)?t.value.end?d(t.value.end,t.sep):t.value.end=t.sep:d(t.start,t.sep),delete t.sep)}t.Parser=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new s.Lexer,this.onNewLine=e}*parse(e,t=!1){for(let r of(this.onNewLine&&0===this.offset&&this.onNewLine(0),this.lexer.lex(e,t)))yield*this.next(r);t||(yield*this.end())}*next(e){if(this.source=e,n.env.LOG_TOKENS&&console.log("|",i.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=i.tokenType(e);if(t)if("scalar"===t)this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=t,yield*this.step(),t){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case"space":this.atNewLine&&" "===e[0]&&(this.indent+=e.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=e.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}else{let t=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:t,source:e}),this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if("doc-end"===this.type&&e?.type!=="doc-end"){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case"document":return yield*this.document(e);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(e);case"block-scalar":return yield*this.blockScalar(e);case"block-map":return yield*this.blockMap(e);case"block-seq":return yield*this.blockSequence(e);case"flow-collection":return yield*this.flowCollection(e);case"doc-end":return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let t=e??this.stack.pop();if(t)if(0===this.stack.length)yield t;else{let e=this.peek(1);switch("block-scalar"===t.type?t.indent="indent"in e?e.indent:0:"flow-collection"===t.type&&"document"===e.type&&(t.indent=0),"flow-collection"===t.type&&f(t),e.type){case"document":e.value=t;break;case"block-scalar":e.props.push(t);break;case"block-map":{let r=e.items[e.items.length-1];if(r.value){e.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}if(r.sep)r.value=t;else{Object.assign(r,{key:t,sep:[]}),this.onKeyLine=!r.explicitKey;return}break}case"block-seq":{let r=e.items[e.items.length-1];r.value?e.items.push({start:[],value:t}):r.value=t;break}case"flow-collection":{let r=e.items[e.items.length-1];!r||r.value?e.items.push({start:[],key:t,sep:[]}):r.sep?r.value=t:Object.assign(r,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if(("document"===e.type||"block-map"===e.type||"block-seq"===e.type)&&("block-map"===t.type||"block-seq"===t.type)){let r=t.items[t.items.length-1];r&&!r.sep&&!r.value&&r.start.length>0&&-1===o(r.start)&&(0===t.indent||r.start.every(e=>"comment"!==e.type||e.indent<t.indent))&&("document"===e.type?e.end=r.start:e.items.push({start:r.start}),t.items.splice(-1,1))}}else yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let e={type:"document",offset:this.offset,start:[]};"doc-start"===this.type&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case"doc-start":-1!==o(e.start)?(yield*this.pop(),yield*this.step()):e.start.push(this.sourceToken);return;case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}let t=this.startBlockValue(e);t?this.stack.push(t):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if("map-value-ind"===this.type){let t,r=u(c(this.peek(2)));e.end?((t=e.end).push(this.sourceToken),delete e.end):t=[this.sourceToken];let n={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:r,key:e,sep:t}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=n}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":e.props.push(this.sourceToken);return;case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let e=this.source.indexOf("\n")+1;for(;0!==e;)this.onNewLine(this.offset+e),e=this.source.indexOf("\n",e)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,t.value){let r="end"in t.value?t.value.end:void 0,n=Array.isArray(r)?r[r.length-1]:void 0;n?.type==="comment"?r?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let r=e.items[e.items.length-2],n=r?.value?.end;if(Array.isArray(n)){d(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let r=!this.onKeyLine&&this.indent===e.indent,n=r&&(t.sep||t.explicitKey)&&"seq-item-ind"!==this.type,i=[];if(n&&t.sep&&!t.value){let r=[];for(let n=0;n<t.sep.length;++n){let i=t.sep[n];switch(i.type){case"newline":r.push(n);break;case"space":break;case"comment":i.indent>e.indent&&(r.length=0);break;default:r.length=0}}r.length>=2&&(i=t.sep.splice(r[1]))}switch(this.type){case"anchor":case"tag":n||t.value?(i.push(this.sourceToken),e.items.push({start:i}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"explicit-key-ind":t.sep||t.explicitKey?n||t.value?(i.push(this.sourceToken),e.items.push({start:i,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}):(t.start.push(this.sourceToken),t.explicitKey=!0),this.onKeyLine=!0;return;case"map-value-ind":if(t.explicitKey)if(t.sep)if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(a(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]});else if(l(t.key)&&!a(t.sep,"newline")){let e=u(t.start),r=t.key,n=t.sep;n.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:e,key:r,sep:n}]})}else i.length>0?t.sep=t.sep.concat(i,this.sourceToken):t.sep.push(this.sourceToken);else if(a(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let e=u(t.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:e,key:null,sep:[this.sourceToken]}]})}else t.sep?t.value||n?e.items.push({start:i,key:null,sep:[this.sourceToken]}):a(t.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let r=this.flowScalar(this.type);n||t.value?(e.items.push({start:i,key:r,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(r):(Object.assign(t,{key:r,sep:[]}),this.onKeyLine=!0);return}default:{let n=this.startBlockValue(e);if(n){if("block-seq"===n.type){if(!t.explicitKey&&t.sep&&!a(t.sep,"newline"))return void(yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source}))}else r&&e.items.push({start:i});this.stack.push(n);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case"newline":if(t.value){let r="end"in t.value?t.value.end:void 0,n=Array.isArray(r)?r[r.length-1]:void 0;n?.type==="comment"?r?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let r=e.items[e.items.length-2],n=r?.value?.end;if(Array.isArray(n)){d(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case"anchor":case"tag":if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;t.value||a(t.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){let t=this.startBlockValue(e);if(t)return void this.stack.push(t)}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if("flow-error-end"===this.type){let e;do yield*this.pop(),e=this.peek(1);while(e?.type==="flow-collection")}else if(0===e.end.length){switch(this.type){case"comma":case"explicit-key-ind":!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case"map-value-ind":!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let r=this.flowScalar(this.type);!t||t.value?e.items.push({start:[],key:r,sep:[]}):t.sep?this.stack.push(r):Object.assign(t,{key:r,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let r=this.startBlockValue(e);r?this.stack.push(r):(yield*this.pop(),yield*this.step())}else{let t=this.peek(2);if("block-map"!==t.type||("map-value-ind"!==this.type||t.indent!==e.indent)&&("newline"!==this.type||t.items[t.items.length-1].sep))if("map-value-ind"===this.type&&"flow-collection"!==t.type){let r=u(c(t));f(e);let n=e.end.splice(1,e.end.length);n.push(this.sourceToken);let i={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:r,key:e,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e);else yield*this.pop(),yield*this.step()}}flowScalar(e){if(this.onNewLine){let e=this.source.indexOf("\n")+1;for(;0!==e;)this.onNewLine(this.offset+e),e=this.source.indexOf("\n",e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let t=u(c(e));return t.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let t=u(c(e));return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return"comment"===this.type&&!(this.indent<=t)&&e.every(e=>"newline"===e.type||"space"===e.type)}*documentEnd(e){"doc-mode"!==this.type&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],"newline"===this.type&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],"newline"===this.type&&(yield*this.pop())}}}},1094(e,t,r){var n=r(2545),i=r(9960),s=r(3409),a=r(2186),o=r(6730),l=r(3813),c=r(5849);function u(e){let t=!1!==e.prettyErrors;return{lineCounter:e.lineCounter||t&&new l.LineCounter||null,prettyErrors:t}}function d(e,t={}){let{lineCounter:r,prettyErrors:i}=u(t),a=new c.Parser(r?.addNewLine),o=new n.Composer(t),l=null;for(let t of o.compose(a.parse(e),!0,e.length))if(l){if("silent"!==l.options.logLevel){l.errors.push(new s.YAMLParseError(t.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}}else l=t;return i&&r&&(l.errors.forEach(s.prettifyError(e,r)),l.warnings.forEach(s.prettifyError(e,r))),l}t.parse=function(e,t,r){let n;"function"==typeof t?n=t:void 0===r&&t&&"object"==typeof t&&(r=t);let i=d(e,r);if(!i)return null;if(i.warnings.forEach(e=>a.warn(i.options.logLevel,e)),i.errors.length>0)if("silent"!==i.options.logLevel)throw i.errors[0];else i.errors=[];return i.toJS(Object.assign({reviver:n},r))},t.parseAllDocuments=function(e,t={}){let{lineCounter:r,prettyErrors:i}=u(t),a=new c.Parser(r?.addNewLine),o=new n.Composer(t),l=Array.from(o.compose(a.parse(e)));if(i&&r)for(let t of l)t.errors.forEach(s.prettifyError(e,r)),t.warnings.forEach(s.prettifyError(e,r));return l.length>0?l:Object.assign([],{empty:!0},o.streamInfo())},t.parseDocument=d,t.stringify=function(e,t,r){let n=null;if("function"==typeof t||Array.isArray(t)?n=t:void 0===r&&t&&(r=t),"string"==typeof r&&(r=r.length),"number"==typeof r){let e=Math.round(r);r=e<1?void 0:e>8?{indent:8}:{indent:e}}if(void 0===e){let{keepUndefined:e}=r??t??{};if(!e)return}return o.isDocument(e)&&!n?e.toString(r):new i.Document(e,n,r).toString(r)}},8227(e,t,r){var n=r(6730),i=r(9988),s=r(505),a=r(5613),o=r(7545);let l=(e,t)=>e.key<t.key?-1:+(e.key>t.key);t.Schema=class e{constructor({compat:e,customTags:t,merge:r,resolveKnownTags:c,schema:u,sortMapEntries:d,toStringDefaults:f}){this.compat=Array.isArray(e)?o.getTags(e,"compat"):e?o.getTags(null,e):null,this.name="string"==typeof u&&u||"core",this.knownTags=c?o.coreKnownTags:{},this.tags=o.getTags(t,this.name,r),this.toStringOptions=f??null,Object.defineProperty(this,n.MAP,{value:i.map}),Object.defineProperty(this,n.SCALAR,{value:a.string}),Object.defineProperty(this,n.SEQ,{value:s.seq}),this.sortMapEntries="function"==typeof d?d:!0===d?l:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}}},9988(e,t,r){var n=r(6730),i=r(73);t.map={collection:"map",default:!0,nodeClass:i.YAMLMap,tag:"tag:yaml.org,2002:map",resolve:(e,t)=>(n.isMap(e)||t("Expected a mapping for this tag"),e),createNode:(e,t,r)=>i.YAMLMap.from(e,t,r)}},5725(e,t,r){var n=r(8376);let i={identify:e=>null==e,createNode:()=>new n.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new n.Scalar(null),stringify:({source:e},t)=>"string"==typeof e&&i.test.test(e)?e:t.options.nullStr};t.nullTag=i},505(e,t,r){var n=r(6730),i=r(7028);t.seq={collection:"seq",default:!0,nodeClass:i.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve:(e,t)=>(n.isSeq(e)||t("Expected a sequence for this tag"),e),createNode:(e,t,r)=>i.YAMLSeq.from(e,t,r)}},5613(e,t,r){var n=r(4286);t.string={identify:e=>"string"==typeof e,default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify:(e,t,r,i)=>(t=Object.assign({actualString:!0},t),n.stringifyString(e,t,r,i))}},4302(e,t,r){var n=r(8376);let i={identify:e=>"boolean"==typeof e,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new n.Scalar("t"===e[0]||"T"===e[0]),stringify:({source:e,value:t},r)=>e&&i.test.test(e)&&t===("t"===e[0]||"T"===e[0])?e:t?r.options.trueStr:r.options.falseStr};t.boolTag=i},7878(e,t,r){var n=r(8376),i=r(4374);let s={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>"nan"===e.slice(-3).toLowerCase()?NaN:"-"===e[0]?-1/0:1/0,stringify:i.stringifyNumber};t.float={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let t=new n.Scalar(parseFloat(e)),r=e.indexOf(".");return -1!==r&&"0"===e[e.length-1]&&(t.minFractionDigits=e.length-r-1),t},stringify:i.stringifyNumber},t.floatExp={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():i.stringifyNumber(e)}},t.floatNaN=s},9305(e,t,r){var n=r(4374);let i=e=>"bigint"==typeof e||Number.isInteger(e),s=(e,t,r,{intAsBigInt:n})=>n?BigInt(e):parseInt(e.substring(t),r);function a(e,t,r){let{value:s}=e;return i(s)&&s>=0?r+s.toString(t):n.stringifyNumber(e)}t.int={identify:i,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,r)=>s(e,0,10,r),stringify:n.stringifyNumber},t.intHex={identify:e=>i(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,r)=>s(e,2,16,r),stringify:e=>a(e,16,"0x")},t.intOct={identify:e=>i(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,r)=>s(e,2,8,r),stringify:e=>a(e,8,"0o")}},8537(e,t,r){var n=r(9988),i=r(5725),s=r(505),a=r(5613),o=r(4302),l=r(7878),c=r(9305);t.schema=[n.map,s.seq,a.string,i.nullTag,o.boolTag,c.intOct,c.int,c.intHex,l.floatNaN,l.floatExp,l.float]},7150(e,t,r){var n=r(8376),i=r(9988),s=r(505);function a(e){return"bigint"==typeof e||Number.isInteger(e)}let o=({value:e})=>JSON.stringify(e),l=[{identify:e=>"string"==typeof e,default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify:o},{identify:e=>null==e,createNode:()=>new n.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:o},{identify:e=>"boolean"==typeof e,default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:e=>"true"===e,stringify:o},{identify:a,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:r})=>r?BigInt(e):parseInt(e,10),stringify:({value:e})=>a(e)?e.toString():JSON.stringify(e)},{identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:o}];t.schema=[i.map,s.seq].concat(l,{default:!0,tag:"",test:/^/,resolve:(e,t)=>(t(`Unresolved plain scalar ${JSON.stringify(e)}`),e)})},7545(e,t,r){var n=r(9988),i=r(5725),s=r(505),a=r(5613),o=r(4302),l=r(7878),c=r(9305),u=r(8537),d=r(7150),f=r(298),h=r(8327),p=r(8822),m=r(9946),g=r(3908),y=r(6675),b=r(9859);let v=new Map([["core",u.schema],["failsafe",[n.map,s.seq,a.string]],["json",d.schema],["yaml11",g.schema],["yaml-1.1",g.schema]]),w={binary:f.binary,bool:o.boolTag,float:l.float,floatExp:l.floatExp,floatNaN:l.floatNaN,floatTime:b.floatTime,int:c.int,intHex:c.intHex,intOct:c.intOct,intTime:b.intTime,map:n.map,merge:h.merge,null:i.nullTag,omap:p.omap,pairs:m.pairs,seq:s.seq,set:y.set,timestamp:b.timestamp};t.coreKnownTags={"tag:yaml.org,2002:binary":f.binary,"tag:yaml.org,2002:merge":h.merge,"tag:yaml.org,2002:omap":p.omap,"tag:yaml.org,2002:pairs":m.pairs,"tag:yaml.org,2002:set":y.set,"tag:yaml.org,2002:timestamp":b.timestamp},t.getTags=function(e,t,r){let n=v.get(t);if(n&&!e)return r&&!n.includes(h.merge)?n.concat(h.merge):n.slice();let i=n;if(!i)if(Array.isArray(e))i=[];else{let e=Array.from(v.keys()).filter(e=>"yaml11"!==e).map(e=>JSON.stringify(e)).join(", ");throw Error(`Unknown schema "${t}"; use one of ${e} or define customTags array`)}if(Array.isArray(e))for(let t of e)i=i.concat(t);else"function"==typeof e&&(i=e(i.slice()));return r&&(i=i.concat(h.merge)),i.reduce((e,t)=>{let r="string"==typeof t?w[t]:t;if(!r){let e=JSON.stringify(t),r=Object.keys(w).map(e=>JSON.stringify(e)).join(", ");throw Error(`Unknown custom tag ${e}; use one of ${r}`)}return e.includes(r)||e.push(r),e},[])}},298(e,t,r){var n=r(181),i=r(8376),s=r(4286);t.binary={identify:e=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if("function"==typeof n.Buffer)return n.Buffer.from(e,"base64");if("function"!=typeof atob)return t("This environment does not support reading binary tags; either Buffer or atob is required"),e;{let t=atob(e.replace(/[\n\r]/g,"")),r=new Uint8Array(t.length);for(let e=0;e<t.length;++e)r[e]=t.charCodeAt(e);return r}},stringify({comment:e,type:t,value:r},a,o,l){let c;if(!r)return"";if("function"==typeof n.Buffer)c=r instanceof n.Buffer?r.toString("base64"):n.Buffer.from(r.buffer).toString("base64");else if("function"==typeof btoa){let e="";for(let t=0;t<r.length;++t)e+=String.fromCharCode(r[t]);c=btoa(e)}else throw Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(t??(t=i.Scalar.BLOCK_LITERAL),t!==i.Scalar.QUOTE_DOUBLE){let e=Math.max(a.options.lineWidth-a.indent.length,a.options.minContentWidth),r=Math.ceil(c.length/e),n=Array(r);for(let t=0,i=0;t<r;++t,i+=e)n[t]=c.substr(i,e);c=n.join(t===i.Scalar.BLOCK_LITERAL?"\n":" ")}return s.stringifyString({comment:e,type:t,value:c},a,o,l)}}},4211(e,t,r){var n=r(8376);function i({value:e,source:t},r){let n=e?s:a;return t&&n.test.test(t)?t:e?r.options.trueStr:r.options.falseStr}let s={identify:e=>!0===e,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new n.Scalar(!0),stringify:i},a={identify:e=>!1===e,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new n.Scalar(!1),stringify:i};t.falseTag=a,t.trueTag=s},1489(e,t,r){var n=r(8376),i=r(4374);let s={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>"nan"===e.slice(-3).toLowerCase()?NaN:"-"===e[0]?-1/0:1/0,stringify:i.stringifyNumber};t.float={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new n.Scalar(parseFloat(e.replace(/_/g,""))),r=e.indexOf(".");if(-1!==r){let n=e.substring(r+1).replace(/_/g,"");"0"===n[n.length-1]&&(t.minFractionDigits=n.length)}return t},stringify:i.stringifyNumber},t.floatExp={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,"")),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():i.stringifyNumber(e)}},t.floatNaN=s},5566(e,t,r){var n=r(4374);let i=e=>"bigint"==typeof e||Number.isInteger(e);function s(e,t,r,{intAsBigInt:n}){let i=e[0];if(("-"===i||"+"===i)&&(t+=1),e=e.substring(t).replace(/_/g,""),n){switch(r){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`}let t=BigInt(e);return"-"===i?BigInt(-1)*t:t}let a=parseInt(e,r);return"-"===i?-1*a:a}function a(e,t,r){let{value:s}=e;if(i(s)){let e=s.toString(t);return s<0?"-"+r+e.substr(1):r+e}return n.stringifyNumber(e)}t.int={identify:i,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,r)=>s(e,0,10,r),stringify:n.stringifyNumber},t.intBin={identify:i,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,r)=>s(e,2,2,r),stringify:e=>a(e,2,"0b")},t.intHex={identify:i,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,r)=>s(e,2,16,r),stringify:e=>a(e,16,"0x")},t.intOct={identify:i,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,r)=>s(e,1,8,r),stringify:e=>a(e,8,"0")}},8327(e,t,r){var n=r(6730),i=r(8376);let s={identify:e=>"<<"===e||"symbol"==typeof e&&"<<"===e.description,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new i.Scalar(Symbol("<<")),{addToJSMap:a}),stringify:()=>"<<"};function a(e,t,r){let i=l(e,r);if(n.isSeq(i))for(let r of i.items)o(e,t,r);else if(Array.isArray(i))for(let r of i)o(e,t,r);else o(e,t,i)}function o(e,t,r){let i=l(e,r);if(!n.isMap(i))throw Error("Merge sources must be maps or map aliases");for(let[r,n]of i.toJSON(null,e,Map))t instanceof Map?t.has(r)||t.set(r,n):t instanceof Set?t.add(r):Object.prototype.hasOwnProperty.call(t,r)||Object.defineProperty(t,r,{value:n,writable:!0,enumerable:!0,configurable:!0});return t}function l(e,t){return e&&n.isAlias(t)?t.resolve(e.doc,e):t}t.addMergeToJSMap=a,t.isMergeKey=(e,t)=>(s.identify(t)||n.isScalar(t)&&(!t.type||t.type===i.Scalar.PLAIN)&&s.identify(t.value))&&e?.doc.schema.tags.some(e=>e.tag===s.tag&&e.default),t.merge=s},8822(e,t,r){var n=r(6730),i=r(2234),s=r(73),a=r(7028),o=r(9946);class l extends a.YAMLSeq{constructor(){super(),this.add=s.YAMLMap.prototype.add.bind(this),this.delete=s.YAMLMap.prototype.delete.bind(this),this.get=s.YAMLMap.prototype.get.bind(this),this.has=s.YAMLMap.prototype.has.bind(this),this.set=s.YAMLMap.prototype.set.bind(this),this.tag=l.tag}toJSON(e,t){if(!t)return super.toJSON(e);let r=new Map;for(let e of(t?.onCreate&&t.onCreate(r),this.items)){let s,a;if(n.isPair(e)?(s=i.toJS(e.key,"",t),a=i.toJS(e.value,s,t)):s=i.toJS(e,"",t),r.has(s))throw Error("Ordered maps must not include duplicate keys");r.set(s,a)}return r}static from(e,t,r){let n=o.createPairs(e,t,r),i=new this;return i.items=n.items,i}}l.tag="tag:yaml.org,2002:omap",t.YAMLOMap=l,t.omap={collection:"seq",identify:e=>e instanceof Map,nodeClass:l,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let r=o.resolvePairs(e,t),i=[];for(let{key:e}of r.items)n.isScalar(e)&&(i.includes(e.value)?t(`Ordered maps must not include duplicate keys: ${e.value}`):i.push(e.value));return Object.assign(new l,r)},createNode:(e,t,r)=>l.from(e,t,r)}},9946(e,t,r){var n=r(6730),i=r(7748),s=r(8376),a=r(7028);function o(e,t){if(n.isSeq(e))for(let r=0;r<e.items.length;++r){let a=e.items[r];if(!n.isPair(a)){if(n.isMap(a)){a.items.length>1&&t("Each pair must have its own sequence indicator");let e=a.items[0]||new i.Pair(new s.Scalar(null));if(a.commentBefore&&(e.key.commentBefore=e.key.commentBefore?`${a.commentBefore}
11
- ${e.key.commentBefore}`:a.commentBefore),a.comment){let t=e.value??e.key;t.comment=t.comment?`${a.comment}
12
- ${t.comment}`:a.comment}a=e}e.items[r]=n.isPair(a)?a:new i.Pair(a)}}else t("Expected a sequence for this tag");return e}function l(e,t,r){let{replacer:n}=r,s=new a.YAMLSeq(e);s.tag="tag:yaml.org,2002:pairs";let o=0;if(t&&Symbol.iterator in Object(t))for(let e of t){let a,l;if("function"==typeof n&&(e=n.call(t,String(o++),e)),Array.isArray(e))if(2===e.length)a=e[0],l=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`);else if(e&&e instanceof Object){let t=Object.keys(e);if(1===t.length)l=e[a=t[0]];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else a=e;s.items.push(i.createPair(a,l,r))}return s}t.createPairs=l,t.pairs={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:o,createNode:l},t.resolvePairs=o},3908(e,t,r){var n=r(9988),i=r(5725),s=r(505),a=r(5613),o=r(298),l=r(4211),c=r(1489),u=r(5566),d=r(8327),f=r(8822),h=r(9946),p=r(6675),m=r(9859);t.schema=[n.map,s.seq,a.string,i.nullTag,l.trueTag,l.falseTag,u.intBin,u.intOct,u.int,u.intHex,c.floatNaN,c.floatExp,c.float,o.binary,d.merge,f.omap,h.pairs,p.set,m.intTime,m.floatTime,m.timestamp]},6675(e,t,r){var n=r(6730),i=r(7748),s=r(73);class a extends s.YAMLMap{constructor(e){super(e),this.tag=a.tag}add(e){let t;t=n.isPair(e)?e:e&&"object"==typeof e&&"key"in e&&"value"in e&&null===e.value?new i.Pair(e.key,null):new i.Pair(e,null),s.findPair(this.items,t.key)||this.items.push(t)}get(e,t){let r=s.findPair(this.items,e);return!t&&n.isPair(r)?n.isScalar(r.key)?r.key.value:r.key:r}set(e,t){if("boolean"!=typeof t)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let r=s.findPair(this.items,e);r&&!t?this.items.splice(this.items.indexOf(r),1):!r&&t&&this.items.push(new i.Pair(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,r){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,r);throw Error("Set items must all have null values")}static from(e,t,r){let{replacer:n}=r,s=new this(e);if(t&&Symbol.iterator in Object(t))for(let e of t)"function"==typeof n&&(e=n.call(t,e,e)),s.items.push(i.createPair(e,null,r));return s}}a.tag="tag:yaml.org,2002:set",t.YAMLSet=a,t.set={collection:"map",identify:e=>e instanceof Set,nodeClass:a,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,r)=>a.from(e,t,r),resolve(e,t){if(n.isMap(e))if(e.hasAllNullValues(!0))return Object.assign(new a,e);else t("Set items must all have null values");else t("Expected a mapping for this tag");return e}}},9859(e,t,r){var n=r(4374);function i(e,t){let r=e[0],n="-"===r||"+"===r?e.substring(1):e,i=e=>t?BigInt(e):Number(e),s=n.replace(/_/g,"").split(":").reduce((e,t)=>e*i(60)+i(t),i(0));return"-"===r?i(-1)*s:s}function s(e){let{value:t}=e,r=e=>e;if("bigint"==typeof t)r=e=>BigInt(e);else if(isNaN(t)||!isFinite(t))return n.stringifyNumber(e);let i="";t<0&&(i="-",t*=r(-1));let s=r(60),a=[t%s];return t<60?a.unshift(0):(t=(t-a[0])/s,a.unshift(t%s),t>=60&&(t=(t-a[0])/s,a.unshift(t))),i+a.map(e=>String(e).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}let a={identify:e=>e instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(e){let t=e.match(a.test);if(!t)throw Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,r,n,s,o,l,c]=t.map(Number),u=Date.UTC(r,n-1,s,o||0,l||0,c||0,t[7]?Number((t[7]+"00").substr(1,3)):0),d=t[8];if(d&&"Z"!==d){let e=i(d,!1);30>Math.abs(e)&&(e*=60),u-=6e4*e}return new Date(u)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};t.floatTime={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>i(e,!1),stringify:s},t.intTime={identify:e=>"bigint"==typeof e||Number.isInteger(e),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:r})=>i(e,r),stringify:s},t.timestamp=a},3980(e,t){let r="block",n="quoted";function i(e,t,r){let n=t,i=t+1,s=e[i];for(;" "===s||" "===s;)if(t<i+r)s=e[++t];else{do s=e[++t];while(s&&"\n"!==s)n=t,s=e[i=t+1]}return n}t.FOLD_BLOCK=r,t.FOLD_FLOW="flow",t.FOLD_QUOTED=n,t.foldFlowLines=function(e,t,s="flow",{indentAtStart:a,lineWidth:o=80,minContentWidth:l=20,onFold:c,onOverflow:u}={}){let d,f,h;if(!o||o<0)return e;o<l&&(l=0);let p=Math.max(1+l,1+o-t.length);if(e.length<=p)return e;let m=[],g={},y=o-t.length;"number"==typeof a&&(a>o-Math.max(2,l)?m.push(0):y=o-a);let b=!1,v=-1,w=-1,x=-1;for(s===r&&-1!==(v=i(e,v,t.length))&&(y=v+p);h=e[v+=1];){if(s===n&&"\\"===h){switch(w=v,e[v+1]){case"x":v+=3;break;case"u":v+=5;break;case"U":v+=9;break;default:v+=1}x=v}if("\n"===h)s===r&&(v=i(e,v,t.length)),y=v+t.length+p,d=void 0;else{if(" "===h&&f&&" "!==f&&"\n"!==f&&" "!==f){let t=e[v+1];t&&" "!==t&&"\n"!==t&&" "!==t&&(d=v)}if(v>=y)if(d)m.push(d),y=d+p,d=void 0;else if(s===n){for(;" "===f||" "===f;)f=h,h=e[v+=1],b=!0;let t=v>x+1?v-2:w-1;if(g[t])return e;m.push(t),g[t]=!0,y=t+p,d=void 0}else b=!0}f=h}if(b&&u&&u(),0===m.length)return e;c&&c();let k=e.slice(0,m[0]);for(let r=0;r<m.length;++r){let i=m[r],a=m[r+1]||e.length;0===i?k=`
13
- ${t}${e.slice(0,a)}`:(s===n&&g[i]&&(k+=`${e[i]}\\`),k+=`
14
- ${t}${e.slice(i+1,a)}`)}return k}},6203(e,t,r){var n=r(9531),i=r(6730),s=r(3202),a=r(4286);t.createStringifyContext=function(e,t){let r,n=Object.assign({blockQuote:!0,commentString:s.stringifyComment,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},e.schema.toStringOptions,t);switch(n.collectionStyle){case"block":r=!1;break;case"flow":r=!0;break;default:r=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?" ":"",indent:"",indentStep:"number"==typeof n.indent?" ".repeat(n.indent):" ",inFlow:r,options:n}},t.stringify=function(e,t,r,s){let o;if(i.isPair(e))return e.toString(t,r,s);if(i.isAlias(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError("Cannot stringify circular structure without alias nodes");t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let l=i.isNode(e)?e:t.doc.createNode(e,{onTagObj:e=>o=e});o??(o=function(e,t){let r,n;if(t.tag){let r=e.filter(e=>e.tag===t.tag);if(r.length>0)return r.find(e=>e.format===t.format)??r[0]}if(i.isScalar(t)){r=t.value;let i=e.filter(e=>e.identify?.(r));if(i.length>1){let e=i.filter(e=>e.test);e.length>0&&(i=e)}n=i.find(e=>e.format===t.format)??i.find(e=>!e.format)}else r=t,n=e.find(e=>e.nodeClass&&r instanceof e.nodeClass);if(!n){let e=r?.constructor?.name??(null===r?"null":typeof r);throw Error(`Tag not resolved for ${e} value`)}return n}(t.doc.schema.tags,l));let c=function(e,t,{anchors:r,doc:s}){if(!s.directives)return"";let a=[],o=(i.isScalar(e)||i.isCollection(e))&&e.anchor;o&&n.anchorIsValid(o)&&(r.add(o),a.push(`&${o}`));let l=e.tag??(t.default?null:t.tag);return l&&a.push(s.directives.tagString(l)),a.join(" ")}(l,o,t);c.length>0&&(t.indentAtStart=(t.indentAtStart??0)+c.length+1);let u="function"==typeof o.stringify?o.stringify(l,t,r,s):i.isScalar(l)?a.stringifyString(l,t,r,s):l.toString(t,r,s);return c?i.isScalar(l)||"{"===u[0]||"["===u[0]?`${c} ${u}`:`${c}
15
- ${t.indent}${u}`:u}},8143(e,t,r){var n=r(6730),i=r(6203),s=r(3202);function a({indent:e,options:{commentString:t}},r,n,i){if(n&&i&&(n=n.replace(/^\n+/,"")),n){let i=s.indentComment(t(n),e);r.push(i.trimStart())}}t.stringifyCollection=function(e,t,r){return(t.inFlow??e.flow?function({items:e},t,{flowChars:r,itemIndent:o}){let{indent:l,indentStep:c,flowCollectionPadding:u,options:{commentString:d}}=t,f=Object.assign({},t,{indent:o+=c,inFlow:!0,type:null}),h=!1,p=0,m=[];for(let r=0;r<e.length;++r){let l=e[r],c=null;if(n.isNode(l))l.spaceBefore&&m.push(""),a(t,m,l.commentBefore,!1),l.comment&&(c=l.comment);else if(n.isPair(l)){let e=n.isNode(l.key)?l.key:null;e&&(e.spaceBefore&&m.push(""),a(t,m,e.commentBefore,!1),e.comment&&(h=!0));let r=n.isNode(l.value)?l.value:null;r?(r.comment&&(c=r.comment),r.commentBefore&&(h=!0)):null==l.value&&e?.comment&&(c=e.comment)}c&&(h=!0);let u=i.stringify(l,f,()=>c=null);h||(h=m.length>p||u.includes("\n")),r<e.length-1?u+=",":t.options.trailingComma&&(t.options.lineWidth>0&&(h||(h=m.reduce((e,t)=>e+t.length+2,2)+(u.length+2)>t.options.lineWidth)),h&&(u+=",")),c&&(u+=s.lineComment(u,o,d(c))),m.push(u),p=m.length}let{start:g,end:y}=r;if(0===m.length)return g+y;if(!h){let e=m.reduce((e,t)=>e+t.length+2,2);h=t.options.lineWidth>0&&e>t.options.lineWidth}if(!h)return`${g}${u}${m.join(" ")}${u}${y}`;{let e=g;for(let t of m)e+=t?`
16
- ${c}${l}${t}`:"\n";return`${e}
17
- ${l}${y}`}}:function({comment:e,items:t},r,{blockItemPrefix:o,flowChars:l,itemIndent:c,onChompKeep:u,onComment:d}){let f,{indent:h,options:{commentString:p}}=r,m=Object.assign({},r,{indent:c,type:null}),g=!1,y=[];for(let e=0;e<t.length;++e){let l=t[e],u=null;if(n.isNode(l))!g&&l.spaceBefore&&y.push(""),a(r,y,l.commentBefore,g),l.comment&&(u=l.comment);else if(n.isPair(l)){let e=n.isNode(l.key)?l.key:null;e&&(!g&&e.spaceBefore&&y.push(""),a(r,y,e.commentBefore,g))}g=!1;let d=i.stringify(l,m,()=>u=null,()=>g=!0);u&&(d+=s.lineComment(d,c,p(u))),g&&u&&(g=!1),y.push(o+d)}if(0===y.length)f=l.start+l.end;else{f=y[0];for(let e=1;e<y.length;++e){let t=y[e];f+=t?`
18
- ${h}${t}`:"\n"}}return e?(f+="\n"+s.indentComment(p(e),h),d&&d()):g&&u&&u(),f})(e,t,r)}},3202(e,t){function r(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}t.indentComment=r,t.lineComment=(e,t,n)=>e.endsWith("\n")?r(n,t):n.includes("\n")?"\n"+r(n,t):(e.endsWith(" ")?"":" ")+n,t.stringifyComment=e=>e.replace(/^(?!$)(?: $)?/gm,"#")},5966(e,t,r){var n=r(6730),i=r(6203),s=r(3202);t.stringifyDocument=function(e,t){let r=[],a=!0===t.directives;if(!1!==t.directives&&e.directives){let t=e.directives.toString(e);t?(r.push(t),a=!0):e.directives.docStart&&(a=!0)}a&&r.push("---");let o=i.createStringifyContext(e,t),{commentString:l}=o.options;if(e.commentBefore){1!==r.length&&r.unshift("");let t=l(e.commentBefore);r.unshift(s.indentComment(t,""))}let c=!1,u=null;if(e.contents){if(n.isNode(e.contents)){if(e.contents.spaceBefore&&a&&r.push(""),e.contents.commentBefore){let t=l(e.contents.commentBefore);r.push(s.indentComment(t,""))}o.forceBlockIndent=!!e.comment,u=e.contents.comment}let t=u?void 0:()=>c=!0,d=i.stringify(e.contents,o,()=>u=null,t);u&&(d+=s.lineComment(d,"",l(u))),("|"===d[0]||">"===d[0])&&"---"===r[r.length-1]?r[r.length-1]=`--- ${d}`:r.push(d)}else r.push(i.stringify(e.contents,o));if(e.directives?.docEnd)if(e.comment){let t=l(e.comment);t.includes("\n")?(r.push("..."),r.push(s.indentComment(t,""))):r.push(`... ${t}`)}else r.push("...");else{let t=e.comment;t&&c&&(t=t.replace(/^\n+/,"")),t&&((!c||u)&&""!==r[r.length-1]&&r.push(""),r.push(s.indentComment(l(t),"")))}return r.join("\n")+"\n"}},4374(e,t){t.stringifyNumber=function({format:e,minFractionDigits:t,tag:r,value:n}){if("bigint"==typeof n)return String(n);let i="number"==typeof n?n:Number(n);if(!isFinite(i))return isNaN(i)?".nan":i<0?"-.inf":".inf";let s=Object.is(n,-0)?"-0":JSON.stringify(n);if(!e&&t&&(!r||"tag:yaml.org,2002:float"===r)&&/^-?\d/.test(s)&&!s.includes("e")){let e=s.indexOf(".");e<0&&(e=s.length,s+=".");let r=t-(s.length-e-1);for(;r-- >0;)s+="0"}return s}},4711(e,t,r){var n=r(6730),i=r(8376),s=r(6203),a=r(3202);t.stringifyPair=function({key:e,value:t},r,o,l){let c,u,d,{allNullValues:f,doc:h,indent:p,indentStep:m,options:{commentString:g,indentSeq:y,simpleKeys:b}}=r,v=n.isNode(e)&&e.comment||null;if(b){if(v)throw Error("With simple keys, key nodes cannot have comments");if(n.isCollection(e)||!n.isNode(e)&&"object"==typeof e)throw Error("With simple keys, collection cannot be used as a key value")}let w=!b&&(!e||v&&null==t&&!r.inFlow||n.isCollection(e)||(n.isScalar(e)?e.type===i.Scalar.BLOCK_FOLDED||e.type===i.Scalar.BLOCK_LITERAL:"object"==typeof e));r=Object.assign({},r,{allNullValues:!1,implicitKey:!w&&(b||!f),indent:p+m});let x=!1,k=!1,S=s.stringify(e,r,()=>x=!0,()=>k=!0);if(!w&&!r.inFlow&&S.length>1024){if(b)throw Error("With simple keys, single line scalar must not span more than 1024 characters");w=!0}if(r.inFlow){if(f||null==t)return x&&o&&o(),""===S?"?":w?`? ${S}`:S}else if(f&&!b||null==t&&w)return S=`? ${S}`,v&&!x?S+=a.lineComment(S,r.indent,g(v)):k&&l&&l(),S;x&&(v=null),w?(v&&(S+=a.lineComment(S,r.indent,g(v))),S=`? ${S}
19
- ${p}:`):(S=`${S}:`,v&&(S+=a.lineComment(S,r.indent,g(v)))),n.isNode(t)?(c=!!t.spaceBefore,u=t.commentBefore,d=t.comment):(c=!1,u=null,d=null,t&&"object"==typeof t&&(t=h.createNode(t))),r.implicitKey=!1,!w&&!v&&n.isScalar(t)&&(r.indentAtStart=S.length+1),k=!1,!(!y&&m.length>=2&&!r.inFlow&&!w&&n.isSeq(t))||t.flow||t.tag||t.anchor||(r.indent=r.indent.substring(2));let _=!1,$=s.stringify(t,r,()=>_=!0,()=>k=!0),O=" ";if(v||c||u){if(O=c?"\n":"",u){let e=g(u);O+=`
20
- ${a.indentComment(e,r.indent)}`}""!==$||r.inFlow?O+=`
21
- ${r.indent}`:"\n"===O&&d&&(O="\n\n")}else if(!w&&n.isCollection(t)){let e=$[0],n=$.indexOf("\n"),i=-1!==n,s=r.inFlow??t.flow??0===t.items.length;if(i||!s){let t=!1;if(i&&("&"===e||"!"===e)){let r=$.indexOf(" ");"&"===e&&-1!==r&&r<n&&"!"===$[r+1]&&(r=$.indexOf(" ",r+1)),(-1===r||n<r)&&(t=!0)}t||(O=`
22
- ${r.indent}`)}}else(""===$||"\n"===$[0])&&(O="");return S+=O+$,r.inFlow?_&&o&&o():d&&!_?S+=a.lineComment(S,r.indent,g(d)):k&&l&&l(),S}},4286(e,t,r){let n;var i=r(8376),s=r(3980);let a=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth});function o(e,t){let r=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return r;let{implicitKey:n}=t,i=t.options.doubleQuotedMinMultiLineLength,o=t.indent||(/^(%|---|\.\.\.)/m.test(e)?" ":""),l="",c=0;for(let e=0,t=r[e];t;t=r[++e])if(" "===t&&"\\"===r[e+1]&&"n"===r[e+2]&&(l+=r.slice(c,e)+"\\ ",e+=1,c=e,t="\\"),"\\"===t)switch(r[e+1]){case"u":{l+=r.slice(c,e);let t=r.substr(e+2,4);switch(t){case"0000":l+="\\0";break;case"0007":l+="\\a";break;case"000b":l+="\\v";break;case"001b":l+="\\e";break;case"0085":l+="\\N";break;case"00a0":l+="\\_";break;case"2028":l+="\\L";break;case"2029":l+="\\P";break;default:"00"===t.substr(0,2)?l+="\\x"+t.substr(2):l+=r.substr(e,6)}e+=5,c=e+1}break;case"n":if(n||'"'===r[e+2]||r.length<i)e+=1;else{for(l+=r.slice(c,e)+"\n\n";"\\"===r[e+2]&&"n"===r[e+3]&&'"'!==r[e+4];)l+="\n",e+=2;l+=o," "===r[e+2]&&(l+="\\"),e+=1,c=e+1}break;default:e+=1}return l=c?l+r.slice(c):r,n?l:s.foldFlowLines(l,o,s.FOLD_QUOTED,a(t,!1))}function l(e,t){if(!1===t.options.singleQuote||t.implicitKey&&e.includes("\n")||/[ \t]\n|\n[ \t]/.test(e))return o(e,t);let r=t.indent||(/^(%|---|\.\.\.)/m.test(e)?" ":""),n="'"+e.replace(/'/g,"''").replace(/\n+/g,`$&
23
- ${r}`)+"'";return t.implicitKey?n:s.foldFlowLines(n,r,s.FOLD_FLOW,a(t,!1))}function c(e,t){let r,{singleQuote:n}=t.options;if(!1===n)r=o;else{let t=e.includes('"'),i=e.includes("'");r=t&&!i?l:i&&!t?o:n?l:o}return r(e,t)}try{n=RegExp("(^|(?<!\n))\n+(?!\n|$)","g")}catch{n=/\n+(?!\n|$)/g}function u({comment:e,type:t,value:r},o,l,d){let f,h,p,m,{blockQuote:g,commentString:y,lineWidth:b}=o.options;if(!g||/\n[\t ]+$/.test(r))return c(r,o);let v=o.indent||(o.forceBlockIndent||(m=r,/^(%|---|\.\.\.)/m.test(m))?" ":""),w="literal"===g||"folded"!==g&&t!==i.Scalar.BLOCK_FOLDED&&(t===i.Scalar.BLOCK_LITERAL||!function(e,t,r){if(!t||t<0)return!1;let n=t-r,i=e.length;if(i<=n)return!1;for(let t=0,r=0;t<i;++t)if("\n"===e[t]){if(t-r>n)return!0;if(i-(r=t+1)<=n)return!1}return!0}(r,b,v.length));if(!r)return w?"|\n":">\n";for(h=r.length;h>0;--h){let e=r[h-1];if("\n"!==e&&" "!==e&&" "!==e)break}let x=r.substring(h),k=x.indexOf("\n");-1===k?f="-":r===x||k!==x.length-1?(f="+",d&&d()):f="",x&&(r=r.slice(0,-x.length),"\n"===x[x.length-1]&&(x=x.slice(0,-1)),x=x.replace(n,`$&${v}`));let S=!1,_=-1;for(p=0;p<r.length;++p){let e=r[p];if(" "===e)S=!0;else if("\n"===e)_=p;else break}let $=r.substring(0,_<p?_+1:p);$&&(r=r.substring($.length),$=$.replace(/\n+/g,`$&${v}`));let O=v?"2":"1",I=(S?O:"")+f;if(e&&(I+=" "+y(e.replace(/ ?[\r\n]+/g," ")),l&&l()),!w){let e=r.replace(/\n+/g,"\n$&").replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${v}`),n=!1,l=a(o,!0);"folded"!==g&&t!==i.Scalar.BLOCK_FOLDED&&(l.onOverflow=()=>{n=!0});let c=s.foldFlowLines(`${$}${e}${x}`,v,s.FOLD_BLOCK,l);if(!n)return`>${I}
24
- ${v}${c}`}return r=r.replace(/\n+/g,`$&${v}`),`|${I}
25
- ${v}${$}${r}${x}`}t.stringifyString=function(e,t,r,n){let{implicitKey:d,inFlow:f}=t,h="string"==typeof e.value?e:Object.assign({},e,{value:String(e.value)}),{type:p}=e;p!==i.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(h.value)&&(p=i.Scalar.QUOTE_DOUBLE);let m=e=>{switch(e){case i.Scalar.BLOCK_FOLDED:case i.Scalar.BLOCK_LITERAL:return d||f?c(h.value,t):u(h,t,r,n);case i.Scalar.QUOTE_DOUBLE:return o(h.value,t);case i.Scalar.QUOTE_SINGLE:return l(h.value,t);case i.Scalar.PLAIN:return function(e,t,r,n){let{type:o,value:l}=e,{actualString:d,implicitKey:f,indent:h,indentStep:p,inFlow:m}=t;if(f&&l.includes("\n")||m&&/[[\]{},]/.test(l))return c(l,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(l))return f||m||!l.includes("\n")?c(l,t):u(e,t,r,n);if(!f&&!m&&o!==i.Scalar.PLAIN&&l.includes("\n"))return u(e,t,r,n);if(/^(%|---|\.\.\.)/m.test(l)){if(""===h)return t.forceBlockIndent=!0,u(e,t,r,n);else if(f&&h===p)return c(l,t)}let g=l.replace(/\n+/g,`$&
26
- ${h}`);if(d){let e=e=>e.default&&"tag:yaml.org,2002:str"!==e.tag&&e.test?.test(g),{compat:r,tags:n}=t.doc.schema;if(n.some(e)||r?.some(e))return c(l,t)}return f?g:s.foldFlowLines(g,h,s.FOLD_FLOW,a(t,!1))}(h,t,r,n);default:return null}},g=m(p);if(null===g){let{defaultKeyType:e,defaultStringType:r}=t.options,n=d&&e||r;if(null===(g=m(n)))throw Error(`Unsupported default string type ${n}`)}return g}},7995(e,t,r){var n=r(6730);let i=Symbol("break visit"),s=Symbol("skip children"),a=Symbol("remove node");function o(e,t){let r=d(t);n.isDocument(e)?l(null,e.contents,r,Object.freeze([e]))===a&&(e.contents=null):l(null,e,r,Object.freeze([]))}function l(e,t,r,s){let o=f(e,t,r,s);if(n.isNode(o)||n.isPair(o))return h(e,s,o),l(e,o,r,s);if("symbol"!=typeof o){if(n.isCollection(t)){s=Object.freeze(s.concat(t));for(let e=0;e<t.items.length;++e){let n=l(e,t.items[e],r,s);if("number"==typeof n)e=n-1;else{if(n===i)return i;n===a&&(t.items.splice(e,1),e-=1)}}}else if(n.isPair(t)){s=Object.freeze(s.concat(t));let e=l("key",t.key,r,s);if(e===i)return i;e===a&&(t.key=null);let n=l("value",t.value,r,s);if(n===i)return i;n===a&&(t.value=null)}}return o}async function c(e,t){let r=d(t);n.isDocument(e)?await u(null,e.contents,r,Object.freeze([e]))===a&&(e.contents=null):await u(null,e,r,Object.freeze([]))}async function u(e,t,r,s){let o=await f(e,t,r,s);if(n.isNode(o)||n.isPair(o))return h(e,s,o),u(e,o,r,s);if("symbol"!=typeof o){if(n.isCollection(t)){s=Object.freeze(s.concat(t));for(let e=0;e<t.items.length;++e){let n=await u(e,t.items[e],r,s);if("number"==typeof n)e=n-1;else{if(n===i)return i;n===a&&(t.items.splice(e,1),e-=1)}}}else if(n.isPair(t)){s=Object.freeze(s.concat(t));let e=await u("key",t.key,r,s);if(e===i)return i;e===a&&(t.key=null);let n=await u("value",t.value,r,s);if(n===i)return i;n===a&&(t.value=null)}}return o}function d(e){return"object"==typeof e&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function f(e,t,r,i){return"function"==typeof r?r(e,t,i):n.isMap(t)?r.Map?.(e,t,i):n.isSeq(t)?r.Seq?.(e,t,i):n.isPair(t)?r.Pair?.(e,t,i):n.isScalar(t)?r.Scalar?.(e,t,i):n.isAlias(t)?r.Alias?.(e,t,i):void 0}function h(e,t,r){let i=t[t.length-1];if(n.isCollection(i))i.items[e]=r;else if(n.isPair(i))"key"===e?i.key=r:i.value=r;else if(n.isDocument(i))i.contents=r;else{let e=n.isAlias(i)?"alias":"scalar";throw Error(`Cannot replace node with ${e} parent`)}}o.BREAK=i,o.SKIP=s,o.REMOVE=a,c.BREAK=i,c.SKIP=s,c.REMOVE=a,t.visit=o,t.visitAsync=c}},s={};function a(e){var t=s[e];if(void 0!==t)return t.exports;var r=s[e]={exports:{}};return i[e](r,r.exports,a),r.exports}n=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,a.t=function(e,t){if(1&t&&(e=this(e)),8&t||"object"==typeof e&&e&&(4&t&&e.__esModule||16&t&&"function"==typeof e.then))return e;var i=Object.create(null);a.r(i);var s={};r=r||[null,n({}),n([]),n(n)];for(var o=2&t&&e;("object"==typeof o||"function"==typeof o)&&!~r.indexOf(o);o=n(o))Object.getOwnPropertyNames(o).forEach(t=>{s[t]=()=>e[t]});return s.default=()=>e,a.d(i,s),i},a.d=(e,t,r)=>{var n=(t,r)=>{for(var n in t)a.o(t,n)&&!a.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,[r]:t[n]})};n(t,"get"),n(r,"value")},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{let e,r,n,i,s,o,l,c,u,d,f,h,p,m,g,y,b,v,w,x,k,S,_,$,O,I,C,E,A,T,M,N,j,F,L,P,D,R,U,B,q,K,z,V,J,W,Y;var G,H,Q,Z,X,ee,et,er,en,ei={};a.r(ei),a.d(ei,{Do:()=>nf,all:()=>r4,andThen:()=>rH,as:()=>rJ,asVoid:()=>rW,bind:()=>nd,bindTo:()=>nc,composeK:()=>r1,contains:()=>no,containsWith:()=>na,exists:()=>nl,filter:()=>nt,filterMap:()=>ne,firstSomeOf:()=>rF,flatMap:()=>rG,flatMapNullishOr:()=>rQ,flatten:()=>rZ,fromIterable:()=>rC,fromNullOr:()=>rD,fromNullishOr:()=>rL,fromUndefinedOr:()=>rP,gen:()=>nh,getFailure:()=>rA,getOrElse:()=>rT,getOrNull:()=>rU,getOrThrow:()=>rz,getOrThrowWith:()=>rK,getOrUndefined:()=>rB,getSuccess:()=>rE,isNone:()=>r_,isOption:()=>rS,isSome:()=>r$,let:()=>nu,lift2:()=>ni,liftNullishOr:()=>rR,liftPredicate:()=>ns,liftThrowable:()=>rq,makeCombinerFailFast:()=>nm,makeEquivalence:()=>nr,makeOrder:()=>nn,makeReducer:()=>np,makeReducerFailFast:()=>ng,map:()=>rV,match:()=>rO,none:()=>rx,orElse:()=>rM,orElseResult:()=>rj,orElseSome:()=>rN,partitionMap:()=>r7,product:()=>r3,productMany:()=>r5,reduceCompact:()=>r6,some:()=>rk,tap:()=>r2,toArray:()=>r9,toRefinement:()=>rI,void:()=>rY,zipLeft:()=>r0,zipRight:()=>rX,zipWith:()=>r8});let es=(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 e=0,n=t.length;e<n;e++)r=t[e](r);return r}}},ea={pipe(){return es(this,arguments)}},eo=function(){function e(){}return e.prototype=ea,e}(),el=function(e,t){if("function"==typeof e)return function(){return e(arguments)?t.apply(this,arguments):e=>t(e,...arguments)};switch(e){case 0:case 1:throw RangeError(`Invalid arity ${e}`);case 2:return function(e,r){return arguments.length>=2?t(e,r):function(r){return t(r,e)}};case 3:return function(e,r,n){return arguments.length>=3?t(e,r,n):function(n){return t(n,e,r)}};default:return function(){if(arguments.length>=e)return t.apply(this,arguments);let r=arguments;return function(e){return t(e,...r)}}}},ec=e=>e,eu=e=>()=>e,ed=eu(!0),ef=eu(!1),eh=eu(null),ep=eu(void 0);function em(e,...t){return es(e,t)}function eg(e){let t=new WeakMap;return r=>{if(t.has(r))return t.get(r);let n=e(r);return t.set(r,n),n}}let ey=e=>{let t=new Set(Reflect.ownKeys(e));if(e.constructor===Object)return t;e instanceof Error&&t.delete("stack");let r=Object.getPrototypeOf(e),n=r;for(;null!==n&&n!==Object.prototype;){let e=Reflect.ownKeys(n);for(let r=0;r<e.length;r++)t.add(e[r]);n=Object.getPrototypeOf(n)}return t.has("constructor")&&"function"==typeof e.constructor&&r===e.constructor.prototype&&t.delete("constructor"),t},eb=new WeakSet;function ev(e){return"string"==typeof e}function ew(e){return"number"==typeof e}function ex(e){return"boolean"==typeof e}function ek(e){return"bigint"==typeof e}function eS(e){return"symbol"==typeof e}function e_(e){return"function"==typeof e}function e$(e){return void 0===e}function eO(e){return void 0!==e}function eI(e){return null!==e}function eC(e){return null!=e}function eE(e){return!0}function eA(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}let eT=el(2,(e,t)=>{var r;return("object"==typeof(r=e)&&null!==r||e_(r))&&t in e}),eM=el(2,(e,t)=>eT(e,"_tag")&&e._tag===t);function eN(e){return eT(e,Symbol.iterator)||ev(e)}let ej="~effect/interfaces/Hash",eF=e=>{switch(typeof e){case"number":return eU(e);case"bigint":return eB(e.toString(10));case"boolean":case"symbol":return eB(String(e));case"string":return eB(e);case"undefined":return eB("undefined");case"function":case"object":if(null===e)return eB("null");{if(e instanceof Date)return eB(e.toISOString());if(e instanceof RegExp)return eB(e.toString());if(eb.has(e))return eL(e);if(eG.has(e))return eG.get(e);let t=function(e,t){if(eH.has(e))return eB("[Circular]");eH.add(e);let r=t();return eH.delete(e),r}(e,()=>{if(eR(e))return e[ej]();if("function"==typeof e)return eL(e);if(Array.isArray(e)||ArrayBuffer.isView(e))return eV(e);if(e instanceof Map)return eJ(e);if(e instanceof Set)return eW(e);return eK(e)});return eG.set(e,t),t}default:throw Error(`BUG: unhandled typeof ${typeof e} - please report an issue at https://github.com/Effect-TS/effect/issues`)}},eL=e=>(eY.has(e)||eY.set(e,eU(Math.floor(Math.random()*Number.MAX_SAFE_INTEGER))),eY.get(e)),eP=el(2,(e,t)=>53*e^t),eD=e=>0xbfffffff&e|e>>>1&0x40000000,eR=e=>eT(e,ej),eU=e=>{if(e!=e)return eB("NaN");if(e===1/0)return eB("Infinity");if(e===-1/0)return eB("-Infinity");let t=0|e;for(t!==e&&(t^=0xffffffff*e);e>0xffffffff;)t^=e/=0xffffffff;return eD(t)},eB=e=>{let t=5381,r=e.length;for(;r;)t=33*t^e.charCodeAt(--r);return eD(t)},eq=(e,t)=>{let r=12289;for(let n of t)r^=eP(eF(n),eF(e[n]));return eD(r)},eK=e=>eq(e,ey(e)),ez=(e,t)=>r=>{let n=e;for(let e of r)n^=t(e);return eD(n)},eV=ez(6151,eF),eJ=ez(eB("Map"),([e,t])=>eP(eF(e),eF(t))),eW=ez(eB("Set"),eF),eY=new WeakMap,eG=new WeakMap,eH=new WeakSet,eQ="~effect/interfaces/Equal";function eZ(){return 1==arguments.length?e=>eX(e,arguments[0]):eX(arguments[0],arguments[1])}function eX(e,t){if(e===t)return!0;if(null==e||null==t)return!1;let r=typeof e;return r===typeof t&&("number"===r&&e!=e&&t!=t||!("object"!==r&&"function"!==r||eb.has(e)||eb.has(t))&&function(e,t,r){let n=e3.get(e);if(n){if(n.has(t))return n.get(t)}else n=new WeakMap,e3.set(e,n);let i=r(e,t);n.set(t,i);let s=e3.get(t);return s||(s=new WeakMap,e3.set(t,s)),s.set(e,i),i}(e,t,e2))}let e0=new WeakSet,e1=new WeakSet;function e2(e,t){if(eF(e)!==eF(t))return!1;if(e instanceof Date)return t instanceof Date&&e.toISOString()===t.toISOString();if(e instanceof RegExp)return t instanceof RegExp&&e.toString()===t.toString();let r=e8(e),n=e8(t);if(r!==n)return!1;let i=r&&n;return("function"!=typeof e||!!i)&&function(e,t,r){let n=e0.has(e),i=e1.has(t);if(n&&i)return!0;if(n||i)return!1;e0.add(e),e1.add(t);let s=r();return e0.delete(e),e1.delete(t),s}(e,t,()=>{if(i)return e[eQ](t);if(Array.isArray(e))return!!Array.isArray(t)&&e.length===t.length&&function(e,t){for(let r=0;r<e.length;r++)if(!eX(e[r],t[r]))return!1;return!0}(e,t);if(ArrayBuffer.isView(e))return!!ArrayBuffer.isView(t)&&e.byteLength===t.byteLength&&function(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}(e,t);if(e instanceof Map)return t instanceof Map&&e.size===t.size&&e5(e,t);if(e instanceof Set)return t instanceof Set&&e.size===t.size&&e4(e,t);var r=e,n=t;let s=ey(r),a=ey(n);if(s.size!==a.size)return!1;for(let e of s)if(!a.has(e)||!eX(r[e],n[e]))return!1;return!0})}let e3=new WeakMap,e5=(H=eX,Q=eX,function(e,t){for(let[r,n]of e){let e=!1;for(let[i,s]of t)if(H(r,i)&&Q(n,s)){e=!0;break}if(!e)return!1}return!0}),e4=(Z=eX,function(e,t){for(let r of e){let e=!1;for(let n of t)if(Z(r,n)){e=!0;break}if(!e)return!1}return!0}),e8=e=>eT(e,eQ),e6=Symbol.for("~effect/Redactable");function e9(e){return eT(e,e6)?e7(e):e}function e7(e){return e[e6](globalThis[te]?.context??tt)}let te="~effect/Fiber/currentFiber",tt={"~effect/Context":{},mapUnsafe:new Map,pipe(){return es(this,arguments)}};function tr(e,t){let r=t?.space??0,n=new WeakSet,i=r?"number"==typeof r?" ".repeat(r):r:"",s=(e,t)=>{let r=e?.constructor;return r&&r!==Object.prototype.constructor&&r.name?`${r.name}(${t})`:t};return function e(r,a=0){if(Array.isArray(r)){let t,s;if(n.has(r))return tn;if(n.add(r),!i||r.length<=1)return`[${r.map(t=>e(t,a)).join(",")}]`;let o=r.map(t=>e(t,a+1)).join(",\n"+(t=a+1,i.repeat(t)));return`[
27
- ${s=a+1,i.repeat(s)}${o}
28
- ${i.repeat(a)}]`}if(r instanceof Date)return ts(r);if(!t?.ignoreToString&&eT(r,"toString")&&"function"==typeof r.toString&&r.toString!==Object.prototype.toString&&r.toString!==Array.prototype.toString){let t=function(e){try{let t=e.toString();return"string"==typeof t?t:String(t)}catch{return"[toString threw]"}}(r);return r instanceof Error&&r.cause?`${t} (cause: ${e(r.cause,a)})`:t}if("string"==typeof r)return JSON.stringify(r);if("number"==typeof r||null==r||"boolean"==typeof r||"symbol"==typeof r)return String(r);if("bigint"==typeof r)return String(r)+"n";if("object"==typeof r||"function"==typeof r){if(n.has(r))return tn;if(n.add(r),e6 in r)return tr(e7(r));if(Symbol.iterator in r)return`${r.constructor.name}(${e(Array.from(r),a)})`;let t=(e=>{try{return Reflect.ownKeys(e)}catch{return["[ownKeys threw]"]}})(r);if(!i||t.length<=1){let n=`{${t.map(t=>`${ti(t)}:${e(r[t],a)}`).join(",")}}`;return s(r,n)}let o=`{
29
- ${t.map(t=>{let n;return`${n=a+1,i.repeat(n)}${ti(t)}: ${e(r[t],a+1)}`}).join(",\n")}
30
- ${i.repeat(a)}}`;return s(r,o)}return String(r)}(e,0)}let tn="[Circular]";function ti(e){return"string"==typeof e?JSON.stringify(e):String(e)}function ts(e){try{return e.toISOString()}catch{return"Invalid Date"}}function ta(e,t){let r=[];return JSON.stringify(e,function(e,t){let n=e9(t);if("object"!=typeof n||null===n)return n;for(;r.length>0&&r[r.length-1]!==this;)r.pop();if(!r.includes(n))return r.push(n),n},t?.space)}let to=Symbol.for("nodejs.util.inspect.custom"),tl=e=>{try{if(eT(e,"toJSON")&&e_(e.toJSON)&&0===e.toJSON.length)return e.toJSON();if(Array.isArray(e))return e.map(tl)}catch{return"[toJSON threw]"}return e9(e)};class tc{called=!1;self;constructor(e){this.self=e}next(e){return this.called?{value:e,done:!0}:(this.called=!0,{value:this.self,done:!1})}[Symbol.iterator](){return new tc(this.self)}}let tu=(r={[e="~effect/Utils/internal"]:e=>e()},r[e](()=>Error().stack)?.includes(e)===!0?r[e]:({[e]:e=>e()})[e]),td="~effect/Effect",tf="~effect/Exit",th=`${td}/identifier`,tp=`${td}/args`,tm=`${td}/evaluate`,tg=`${td}/successCont`,ty=`${td}/failureCont`,tb=`${td}/ensureCont`,tv=Symbol.for("effect/Effect/Yield"),tw={pipe(){return es(this,arguments)},toJSON(){return{...this}},toString(){return tr(this.toJSON(),{ignoreToString:!0,space:2})},[to](){return this.toJSON()}},tx={[td]:{_A:ec,_E:ec,_R:ec},...tw,[Symbol.iterator](){return new tc(this)},toJSON(){return{_id:"Effect",op:this[th],...tp in this?{args:this[tp]}:void 0}}},tk=e=>eT(e,td),tS="~effect/Cause",t_="~effect/Cause/Reason",t$=e=>eT(e,tS);class tO{[tS];reasons;constructor(e){this[tS]=tS,this.reasons=e}pipe(){return es(this,arguments)}toJSON(){return{_id:"Cause",failures:this.reasons.map(e=>e.toJSON())}}toString(){return`Cause(${tr(this.reasons)})`}[to](){return this.toJSON()}[eQ](e){return t$(e)&&this.reasons.length===e.reasons.length&&this.reasons.every((t,r)=>eZ(t,e.reasons[r]))}[ej](){return eV(this.reasons)}}let tI=new WeakMap;class tC{[t_];annotations;_tag;constructor(e,t,r){if(this[t_]=t_,this._tag=e,t!==tE&&"object"==typeof r&&null!==r&&t.size>0){let e=tI.get(r);e&&(t=new Map([...e,...t])),tI.set(r,t)}this.annotations=t}annotate(e,t){if(0===e.mapUnsafe.size)return this;let r=new Map(this.annotations);e.mapUnsafe.forEach((e,n)=>{t?.overwrite!==!0&&r.has(n)||r.set(n,e)});let n=Object.assign(Object.create(Object.getPrototypeOf(this)),this);return n.annotations=r,n}pipe(){return es(this,arguments)}toString(){return tr(this)}[to](){return this.toString()}}let tE=new Map;class tA extends tC{error;constructor(e,t=tE){super("Fail",t,e),this.error=e}toString(){return`Fail(${tr(this.error)})`}toJSON(){return{_tag:"Fail",error:this.error}}[eQ](e){return tL(e)&&eZ(this.error,e.error)&&eZ(this.annotations,e.annotations)}[ej](){return eP(eB(this._tag))(eP(eF(this.error))(eF(this.annotations)))}}let tT=e=>new tO(e),tM=new tO([]),tN=e=>new tO([new tA(e)]);class tj extends tC{defect;constructor(e,t=tE){super("Die",t,e),this.defect=e}toString(){return`Die(${tr(this.defect)})`}toJSON(){return{_tag:"Die",defect:this.defect}}[eQ](e){return tP(e)&&eZ(this.defect,e.defect)&&eZ(this.annotations,e.annotations)}[ej](){return eP(eB(this._tag))(eP(eF(this.defect))(eF(this.annotations)))}}let tF=el(e=>t$(e[0]),(e,t,r)=>0===t.mapUnsafe.size?e:new tO(e.reasons.map(e=>e.annotate(t,r)))),tL=e=>"Fail"===e._tag,tP=e=>"Die"===e._tag,tD=e=>"Interrupt"===e._tag;function tR(e){return tW("Effect.evaluate: Not implemented")}let tU=e=>({...tx,[th]:e.op,[tm]:e[tm]??tR,[tg]:e[tg],[ty]:e[ty],[tb]:e[tb]}),tB=e=>{let t=tU(e);return function(){let r=Object.create(t);return r[tp]=!1===e.single?arguments:arguments[0],r}},tq=e=>{let t={...tU(e),[tf]:tf,_tag:e.op,get[e.prop](){return this[tp]},toString(){return`${e.op}(${tr(this[tp])})`},toJSON(){return{_id:"Exit",_tag:e.op,[e.prop]:this[tp]}},[eQ](e){return eT(e,tf)&&e._tag===this._tag&&eZ(this[tp],e[tp])},[ej](){return eP(eB(e.op),eF(this[tp]))}};return function(e){let r=Object.create(t);return r[tp]=e,r}},tK=tq({op:"Success",prop:"value",[tm](e){let t=e.getCont(tg);return t?t[tg](this[tp],e,this):e.yieldWith(this)}}),tz={key:"effect/Cause/StackTrace"},tV=tq({op:"Failure",prop:"cause",[tm](e){let t=this[tp],r=!1;e.currentStackFrame&&(t=tF(t,{mapUnsafe:new Map([[tz.key,e.currentStackFrame]])}),r=!0);let n=e.getCont(ty);for(;e.interruptible&&e._interruptedCause&&n;)n=e.getCont(ty);return n?n[ty](t,e,r?void 0:this):e.yieldWith(r?this:tV(t))}}),tJ=e=>tV(tN(e)),tW=e=>tV(new tO([new tj(e)])),tY=tB({op:"WithFiber",[tm](e){return this[tp](e)}}),tG=function(){class e extends globalThis.Error{}let t=tU({op:"YieldableError",[tm](){return tJ(this)}});return delete t.toString,Object.assign(e.prototype,t),e}(),tH=(n=Symbol.for("effect/Data/Error/plainArgs"),class extends tG{constructor(e){super(e?.message,e?.cause?{cause:e.cause}:void 0),e&&(Object.assign(this,e),Object.defineProperty(this,n,{value:e,enumerable:!1}))}toJSON(){return{...this[n],...this}}}),tQ=e=>{class t extends tH{_tag=e}return t.prototype.name=e,t},tZ="~effect/Cause/NoSuchElementError";class tX extends tQ("NoSuchElementError"){[tZ]=tZ;constructor(e){super({message:e})}}let t0="~effect/Cause/Done",t1={[t0]:t0,_tag:"Done",value:void 0},t2=e=>void 0===e?t1:{[t0]:t0,_tag:"Done",value:e},t3=tJ(t1),t5=e=>(t,r)=>t===r||e(t,r),t4=e=>e.length>0,t8="~effect/data/Option",t6={[t8]:{_A:e=>e},...tw,[Symbol.iterator](){return new tc(this)}},t9=Object.defineProperty(Object.assign(Object.create(t6),{_tag:"Some",_op:"Some",[eQ](e){return rt(e)&&rn(e)&&eZ(this.value,e.value)},[ej](){return eP(eF(this._tag))(eF(this.value))},toString(){return`some(${tr(this.value)})`},toJSON(){return{_id:"Option",_tag:this._tag,value:tl(this.value)}}}),"valueOrUndefined",{get(){return this.value}}),t7=eF("None"),re=Object.assign(Object.create(t6),{_tag:"None",_op:"None",valueOrUndefined:void 0,[eQ]:e=>rt(e)&&rr(e),[ej]:()=>t7,toString:()=>"none()",toJSON(){return{_id:"Option",_tag:this._tag}}}),rt=e=>eT(e,t8),rr=e=>"None"===e._tag,rn=e=>"Some"===e._tag,ri=Object.create(re),rs=e=>{let t=Object.create(t9);return t.value=e,t},ra="~effect/data/Result",ro={[ra]:{_A:e=>e,_E:e=>e},...tw,[Symbol.iterator](){return new tc(this)}},rl=Object.assign(Object.create(ro),{_tag:"Success",_op:"Success",[eQ](e){return ru(e)&&rf(e)&&eZ(this.success,e.success)},[ej](){return eP(eF(this._tag))(eF(this.success))},toString(){return`success(${tr(this.success)})`},toJSON(){return{_id:"Result",_tag:this._tag,value:tl(this.success)}}}),rc=Object.assign(Object.create(ro),{_tag:"Failure",_op:"Failure",[eQ](e){return ru(e)&&rd(e)&&eZ(this.failure,e.failure)},[ej](){return eP(eF(this._tag))(eF(this.failure))},toString(){return`failure(${tr(this.failure)})`},toJSON(){return{_id:"Result",_tag:this._tag,failure:tl(this.failure)}}}),ru=e=>eT(e,ra),rd=e=>"Failure"===e._tag,rf=e=>"Success"===e._tag,rh=e=>{let t=Object.create(rc);return t.failure=e,t},rp=e=>{let t=Object.create(rl);return t.success=e,t};function rm(e){return(t,r)=>t===r?0:e(t,r)}let rg=rm((e,t)=>globalThis.Number.isNaN(e)&&globalThis.Number.isNaN(t)?0:globalThis.Number.isNaN(e)?-1:globalThis.Number.isNaN(t)?1:e<t?-1:1),ry=rm((e,t)=>e<t?-1:1),rb=el(2,(e,t)=>rm((r,n)=>e(t(r),t(n)))),rv=(e=>e.getTime(),e=>el(2,(t,r)=>1===e(t,r)));function rw(e,t,r){return{combine:e,initialValue:t,combineAll:r??(r=>{let n=t;for(let t of r)n=e(n,t);return n})}}let rx=()=>ri,rk=rs,rS=rt,r_=rr,r$=rn,rO=el(2,(e,{onNone:t,onSome:r})=>r_(e)?t():r(e.value)),rI=e=>t=>r$(e(t)),rC=e=>{for(let t of e)return rk(t);return rx()},rE=e=>rd(e)?ri:rs(e.success),rA=e=>rf(e)?ri:rs(e.failure),rT=el(2,(e,t)=>r_(e)?t():e.value),rM=el(2,(e,t)=>r_(e)?t():e),rN=el(2,(e,t)=>r_(e)?rk(t()):e),rj=el(2,(e,t)=>r_(e)?rV(t(),rp):rV(e,rh)),rF=e=>{let t=rx();for(t of e)if(r$(t))break;return t},rL=e=>null==e?rx():rk(e),rP=e=>void 0===e?rx():rk(e),rD=e=>null===e?rx():rk(e),rR=e=>(...t)=>rL(e(...t)),rU=rT(eh),rB=rT(ep),rq=e=>(...t)=>{try{return rk(e(...t))}catch{return rx()}},rK=el(2,(e,t)=>{if(r$(e))return e.value;throw t()}),rz=rK(()=>Error("getOrThrow called on a None")),rV=el(2,(e,t)=>r_(e)?rx():rk(t(e.value))),rJ=el(2,(e,t)=>rV(e,()=>t)),rW=rJ(void 0),rY=rk(void 0),rG=el(2,(e,t)=>r_(e)?rx():t(e.value)),rH=el(2,(e,t)=>rG(e,e=>{let r=e_(t)?t(e):t;return rS(r)?r:rk(r)})),rQ=el(2,(e,t)=>r_(e)?rx():rL(t(e.value))),rZ=rG(ec),rX=el(2,(e,t)=>rG(e,()=>t)),r0=el(2,(e,t)=>r2(e,()=>t)),r1=el(2,(e,t)=>r=>rG(e(r),t)),r2=el(2,(e,t)=>rG(e,e=>rV(t(e),()=>e))),r3=(e,t)=>r$(e)&&r$(t)?rk([e.value,t.value]):rx(),r5=(e,t)=>{if(r_(e))return rx();let r=[e.value];for(let e of t){if(r_(e))return rx();r.push(e.value)}return rk(r)},r4=e=>{if(Symbol.iterator in e){let t=[];for(let r of e){if(r_(r))return rx();t.push(r.value)}return rk(t)}let t={};for(let r of Object.keys(e)){let n=e[r];if(r_(n))return rx();t[r]=n.value}return rk(t)},r8=el(3,(e,t,r)=>rV(r3(e,t),([e,t])=>r(e,t))),r6=el(3,(e,t,r)=>{let n=t;for(let t of e)r$(t)&&(n=r(n,t.value));return n}),r9=e=>r_(e)?[]:[e.value],r7=el(2,(e,t)=>{if(r_(e))return[rx(),rx()];let r=t(e.value);return rd(r)?[rk(r.failure),rx()]:[rx(),rk(r.success)]}),ne=el(2,(e,t)=>{if(r_(e))return rx();let r=t(e.value);return rf(r)?rk(r.success):rx()}),nt=el(2,(e,t)=>r_(e)?rx():t(e.value)?rk(e.value):rx()),nr=e=>t5((t,r)=>r_(t)?r_(r):!r_(r)&&e(t.value,r.value)),nn=e=>rm((t,r)=>r$(t)?r$(r)?e(t.value,r.value):1:-1),ni=e=>el(2,(t,r)=>r8(t,r,e)),ns=el(2,(e,t)=>t(e)?rk(e):rx()),na=e=>el(2,(t,r)=>!r_(t)&&e(t.value,r)),no=na(eZ),nl=el(2,(e,t)=>!r_(e)&&t(e.value)),nc=el(2,(e,t)=>rV(e,e=>({[t]:e}))),nu=el(3,(e,t,r)=>rV(e,e=>({...e,[t]:r(e)}))),nd=el(3,(e,t,r)=>rG(e,e=>rV(r(e),r=>({...e,[t]:r})))),nf=rk({}),nh=(...e)=>{let t=(1===e.length?e[0]:e[1].bind(e[0]))(),r=t.next();for(;!r.done;){let e=r.value;if(r_(e))return e;r=t.next(e.value)}return rk(r.value)};function np(e){return rw((t,r)=>r_(t)?r:r_(r)?t:rk(e.combine(t.value,r.value)),rx())}function nm(e){return{combine:(t,r)=>r_(t)||r_(r)?rx():rk(e.combine(t.value,r.value))}}function ng(e){let t=nm(e).combine,r=rk(e.initialValue);return rw(t,r,e=>{let n=r;for(let r of e)if(r_(n=t(n,r)))break;return n})}let ny=el(2,(e,t)=>{let r=0;for(let n of e){let e=t(n,r);if(ex(e)){if(e)return rk(n)}else if(r$(e))return e;r++}return rx()}),nb=e=>0===Object.keys(e).length,nv=el(2,(e,t)=>{let r={...e};for(let n of nx(e))r[n]=t(e[n],n);return r}),nw=el(2,(e,t)=>{let r={};for(let n of nx(e))t(e[n],n)&&(r[n]=e[n]);return r}),nx=e=>Object.keys(e),nk=el(2,(e,t)=>rd(e)?rh(t(e.failure)):rp(e.success)),nS=el(2,(e,t)=>rf(e)?rp(t(e.success)):rh(e.failure)),n_=el(2,(e,{onFailure:t,onSuccess:r})=>rd(e)?t(e.failure):r(e.success)),n$=globalThis.Array,nO=e=>n$.isArray(e)?e:n$.from(e),nI=el(2,(e,{onEmpty:t,onNonEmpty:r})=>nA(e)?r(e):t()),nC=el(2,(e,t)=>[...e,t]),nE=el(2,(e,t)=>nO(e).concat(nO(t)));n$.isArray;let nA=t4,nT=el(2,(e,t)=>{let r=Math.floor(t);if(r<0||r>=e.length)throw Error(`Index out of bounds: ${r}`);return e[r]})(0),nM=el(2,(e,t)=>{let r=0;for(let n of e){if(t(n,r))return rk(r);r++}return rx()}),nN=el(2,(e,t)=>{let r=nO(e);for(let e=r.length-1;e>=0;e--){let n=r[e],i=t(n,e);if("boolean"==typeof i){if(i)return rk(n)}else if(r$(i))return i}return rx()}),nj=el(2,(e,t)=>{let r=n$.from(e);return r.sort(t),r}),nF=el(3,(e,t,r)=>{let n=nO(e),i=nO(t);return nA(n)?nA(i)?nK(r)(nE(n,i)):n:i}),nL=el(2,(e,t)=>nF(e,t,eZ)),nP=()=>[],nD=e=>[e],nR=el(2,(e,t)=>e.map(t)),nU=el(2,(e,t)=>{let r=nO(e),n=[];for(let e=0;e<r.length;e++)t(r[e],e)&&n.push(r[e]);return n}),nB=el(2,(e,t)=>{let r=[],n=[],i=0;for(let s of e){let e=t(s,i++);rf(e)?n.push(e.success):r.push(e.failure)}return[r,n]}),nq=el(3,(e,t,r)=>nO(e).reduce((e,t,n)=>r(e,t,n),t)),nK=el(2,(e,t)=>{let r=nO(e);if(nA(r)){let e=[nT(r)];for(let n of r.slice(1))e.every(e=>!t(n,e))&&e.push(n);return e}return[]}),nz=e=>tU({op:e.label,[tm]:e.evaluate}),nV=Object.getOwnPropertyDescriptor,nJ=Object.prototype.hasOwnProperty,nW=Object.isExtensible,nY=void 0===(i=nV(Error,"stackTraceLimit"))?nW(Error):nJ.call(i,"writable")?!0===i.writable:void 0!==i.set,nG=e=>{nY&&(Error.stackTraceLimit=e)},nH="~effect/Context/Service",nQ=function(){let e=Error.stackTraceLimit;nG(2);let t=Error();nG(e);let r=function(){};return(Object.setPrototypeOf(r,nZ),Object.defineProperty(r,"stack",{get:()=>t.stack}),arguments.length>0)?(r.key=arguments[0],arguments[1]?.defaultValue&&(r[nX]=nX,r.defaultValue=arguments[1].defaultValue),r):function(e,t){return r.key=e,t?.make&&(r.make=t.make),r}},nZ={[nH]:nH,...nz({label:"Service",evaluate(e){return tK(n7(e.context,this))}}),toJSON(){return{_id:"Service",key:this.key,stack:this.stack}},of:e=>e,context(e){return n4(this,e)},use(e){return tY(t=>e(n7(t.context,this)))},useSync(e){return tY(t=>tK(e(n7(t.context,this))))}},nX="~effect/Context/Reference",n0="~effect/Context",n1=e=>{let t=Object.create(n2);return t.mapUnsafe=e,t.mutable=!1,t},n2={...tw,[n0]:{_Services:e=>e},toJSON(){return{_id:"Context",services:Array.from(this.mapUnsafe).map(([e,t])=>({key:e,value:t}))}},[eQ](e){if(!n3(e)||this.mapUnsafe.size!==e.mapUnsafe.size)return!1;for(let t of this.mapUnsafe.keys())if(!e.mapUnsafe.has(t)||!eZ(this.mapUnsafe.get(t),e.mapUnsafe.get(t)))return!1;return!0},[ej](){return eU(this.mapUnsafe.size)}},n3=e=>eT(e,n0),n5=n1(new Map),n4=(e,t)=>n1(new Map([[e.key,t]])),n8=el(3,(e,t,r)=>ia(e,e=>{e.set(t.key,r)})),n6=el(2,(e,t)=>e.mapUnsafe.get(t.key)),n9=el(2,(e,t)=>{if(!e.mapUnsafe.has(t.key)){if(nX in t)return it(t);throw ir(t)}return e.mapUnsafe.get(t.key)}),n7=n9,ie="~effect/Context/defaultValue",it=e=>ie in e?e[ie]:e[ie]=e.defaultValue(),ir=e=>{let t=Error(`Service not found${e.key?`: ${String(e.key)}`:""}`);if(e.stack){let r=e.stack.split("\n");if(r.length>2){let e=r[2].match(/at (.*)/);e&&(t.message=t.message+` (defined at ${e[1]})`)}}if(t.stack){let e=t.stack.split("\n");e.splice(1,3),t.stack=e.join("\n")}return t},ii=el(2,(e,t)=>e.mapUnsafe.has(t.key)?rk(e.mapUnsafe.get(t.key)):eT(t,nX)?rk(it(t)):rx()),is=el(2,(e,t)=>0===e.mapUnsafe.size?t:0===t.mapUnsafe.size?e:ia(e,e=>{t.mapUnsafe.forEach((t,r)=>e.set(r,t))})),ia=(e,t)=>{if(e.mutable)return t(e.mapUnsafe),e;let r=new Map(e.mapUnsafe);return t(r),n1(r)},io=nQ,il="~effect/time/Duration",ic=BigInt(0),iu=BigInt(1),id=BigInt(1e3),ih=e=>BigInt(e<0?Math.ceil(e-.5):Math.floor(e+.5)),ip=(e,t)=>e.includes(".")?ih(Number(e)*Number(t)):BigInt(e)*t,im=/^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/,ig=e=>{switch(typeof e){case"number":return iC(e);case"bigint":return iI(e);case"string":{if("Infinity"===e)return i$;if("-Infinity"===e)return iO;let t=im.exec(e);if(!t)break;let[r,n,i]=t;if("nano"===i||"nanos"===i)return iI(ip(n,iu));if("micro"===i||"micros"===i)return iI(ip(n,id));let s=Number(n);switch(i){case"milli":case"millis":return iC(s);case"second":case"seconds":return iE(s);case"minute":case"minutes":return iA(s);case"hour":case"hours":return iT(s);case"day":case"days":return iM(s);case"week":case"weeks":return iN(s)}break}case"object":{if(null===e)break;if(il in e)return e;if(Array.isArray(e)){if(2!==e.length||!e.every(ew))return iy(e);if(Number.isNaN(e[0])||Number.isNaN(e[1]))return i_;if(e[0]===-1/0||e[1]===-1/0)return iO;if(e[0]===1/0||e[1]===1/0)return i$;return ik(ih(1e9*e[0]+e[1]))}let t=0;if(e.weeks&&(t+=6048e5*e.weeks),e.days&&(t+=864e5*e.days),e.hours&&(t+=36e5*e.hours),e.minutes&&(t+=6e4*e.minutes),e.seconds&&(t+=1e3*e.seconds),e.milliseconds&&(t+=e.milliseconds),!e.microseconds&&!e.nanoseconds)return ik(t);return ik(ih(1e6*t+(e.microseconds??0)*1e3+(e.nanoseconds??0)))}}return iy(e)},iy=e=>{throw Error(`Invalid Input: ${e}`)},ib={_tag:"Millis",millis:0},iv={_tag:"Infinity"},iw={_tag:"NegativeInfinity"},ix={[il]:il,[ej](){return eK(this.value)},[eQ](e){return iS(e)&&iR(this,e)},toString(){switch(this.value._tag){case"Infinity":return"Infinity";case"NegativeInfinity":return"-Infinity";case"Nanos":return`${this.value.nanos} nanos`;case"Millis":return`${this.value.millis} millis`}},toJSON(){switch(this.value._tag){case"Millis":return{_id:"Duration",_tag:"Millis",millis:this.value.millis};case"Nanos":return{_id:"Duration",_tag:"Nanos",nanos:String(this.value.nanos)};case"Infinity":return{_id:"Duration",_tag:"Infinity"};case"NegativeInfinity":return{_id:"Duration",_tag:"NegativeInfinity"}}},[to](){return this.toJSON()},pipe(){return es(this,arguments)}},ik=e=>{let t=Object.create(ix);return"number"==typeof e?isNaN(e)||0===e||Object.is(e,-0)?t.value=ib:Number.isFinite(e)?Number.isInteger(e)?t.value={_tag:"Millis",millis:e}:t.value={_tag:"Nanos",nanos:ih(1e6*e)}:t.value=e>0?iv:iw:e===ic?t.value=ib:t.value={_tag:"Nanos",nanos:e},t},iS=e=>eT(e,il),i_=ik(0),i$=ik(1/0),iO=ik(-1/0),iI=e=>ik(e),iC=e=>ik(e),iE=e=>ik(1e3*e),iA=e=>ik(6e4*e),iT=e=>ik(36e5*e),iM=e=>ik(864e5*e),iN=e=>ik(6048e5*e),ij=e=>iL(ig(e),{onMillis:ec,onNanos:e=>Number(e)/1e6,onInfinity:()=>1/0,onNegativeInfinity:()=>-1/0}),iF=e=>{let t=ig(e);switch(t.value._tag){case"Infinity":case"NegativeInfinity":throw Error("Cannot convert infinite duration to nanos");case"Nanos":return t.value.nanos;case"Millis":return ih(1e6*t.value.millis)}},iL=el(2,(e,t)=>{switch(e.value._tag){case"Millis":return t.onMillis(e.value.millis);case"Nanos":return t.onNanos(e.value.nanos);case"Infinity":return t.onInfinity();case"NegativeInfinity":return(t.onNegativeInfinity??t.onInfinity)()}}),iP=el(3,(e,t,r)=>"Infinity"===e.value._tag||"NegativeInfinity"===e.value._tag||"Infinity"===t.value._tag||"NegativeInfinity"===t.value._tag?r.onInfinity(e,t):"Millis"===e.value._tag?"Millis"===t.value._tag?r.onMillis(e.value.millis,t.value.millis):r.onNanos(iF(e),t.value.nanos):r.onNanos(e.value.nanos,iF(t))),iD=(K=rm((e,t)=>iP(e,t,{onMillis:(e,t)=>e<t?-1:+(e>t),onNanos:(e,t)=>e<t?-1:+(e>t),onInfinity:(e,t)=>e.value._tag===t.value._tag?0:"Infinity"===e.value._tag?1:"NegativeInfinity"===e.value._tag||"Infinity"===t.value._tag?-1:1})),el(2,(e,t)=>1!==K(e,t))),iR=el(2,(e,t)=>iP(e,t,{onMillis:(e,t)=>e===t,onNanos:(e,t)=>e===t,onInfinity:(e,t)=>e.value._tag===t.value._tag})),iU=el(2,(e,t)=>r=>{let n=e(r);if(rd(n))return rh(r);let i=t(n.success);return rd(i)?rh(r):i}),iB=io("effect/Scheduler",{defaultValue:()=>new iz}),iq="setImmediate"in globalThis?e=>{let t=globalThis.setImmediate(e);return()=>globalThis.clearImmediate(t)}:e=>{let t=setTimeout(e,0);return()=>clearTimeout(t)};class iK{buckets=[];scheduleTask(e,t){let r,n=this.buckets,i=n.length,s=0;for(;s<i&&!(n[s][0]>t);s++)r=n[s];r&&r[0]===t?r[1].push(e):s===i?n.push([t,[e]]):n.splice(s,0,[t,[e]])}drain(){let e=this.buckets;return this.buckets=[],e}}class iz{executionMode;setImmediate;constructor(e="async",t=iq){this.executionMode=e,this.setImmediate=t}shouldYield(e){return e.currentOpCount>=e.maxOpsBeforeYield}makeDispatcher(){return new iV(this.setImmediate)}}class iV{tasks=new iK;running=void 0;setImmediate;constructor(e=iq){this.setImmediate=e}scheduleTask(e,t){this.tasks.scheduleTask(e,t),void 0===this.running&&(this.running=this.setImmediate(this.afterScheduled))}afterScheduled=()=>{this.running=void 0,this.runTasks()};runTasks(){let e=this.tasks.drain();for(let t=0;t<e.length;t++){let r=e[t][1];for(let e=0;e<r.length;e++)r[e]()}}flush(){for(;this.tasks.buckets.length>0;)void 0!==this.running&&(this.running(),this.running=void 0),this.runTasks()}}let iJ=io("effect/Scheduler/MaxOpsBeforeYield",{defaultValue:()=>2048}),iW=io("effect/Scheduler/PreventSchedulerYield",{defaultValue:()=>!1}),iY="effect/Tracer/ParentSpan";class iG extends nQ()(iY){}let iH=io("effect/Tracer/DisablePropagation",{defaultValue:ef}),iQ=io("effect/Tracer/CurrentTraceLevel",{defaultValue:()=>"Info"}),iZ=io("effect/Tracer/MinimumTraceLevel",{defaultValue:()=>"All"}),iX="effect/Tracer",i0=io(iX,{defaultValue:()=>({span:e=>new i1(e)})});class i1{_tag="Span";spanId;traceId="native";sampled;name;parent;annotations;links;startTime;kind;status;attributes;events=[];constructor(e){this.name=e.name,this.parent=e.parent,this.annotations=e.annotations,this.links=e.links,this.startTime=e.startTime,this.kind=e.kind,this.sampled=e.sampled,this.status={_tag:"Started",startTime:e.startTime},this.attributes=new Map,this.traceId=ei.getOrUndefined(e.parent)?.traceId??i2(32),this.spanId=i2(16)}end(e,t){this.status={_tag:"Ended",endTime:e,exit:t,startTime:this.status.startTime}}attribute(e,t){this.attributes.set(e,t)}event(e,t,r){this.events.push([e,t,r??{}])}addLinks(e){this.links.push(...e)}}let i2=(o=(s="abcdef0123456789").length,function(e){let t="";for(let r=0;r<e;r++)t+=s.charAt(Math.floor(Math.random()*o));return t}),i3=io("effect/References/CurrentConcurrency",{defaultValue:()=>"unbounded"}),i5=io("effect/ErrorReporter/CurrentErrorReporters",{defaultValue:()=>new Set}),i4=io("effect/References/CurrentStackFrame",{defaultValue:ep}),i8=io("effect/References/TracerEnabled",{defaultValue:ed}),i6=io("effect/References/TracerTimingEnabled",{defaultValue:ed}),i9=io("effect/References/TracerSpanAnnotations",{defaultValue:()=>({})}),i7=io("effect/References/TracerSpanLinks",{defaultValue:()=>[]}),se=io("effect/References/CurrentLogAnnotations",{defaultValue:()=>({})}),st=io("effect/References/CurrentLogLevel",{defaultValue:()=>"Info"}),sr=io("effect/References/MinimumLogLevel",{defaultValue:()=>"Info"}),sn=io("effect/References/CurrentLogSpans",{defaultValue:()=>[]}),si=e=>{if(e?.captureStackTrace===!1||e?.captureStackTrace!==void 0&&"boolean"!=typeof e.captureStackTrace)return e;let t=Error.stackTraceLimit;nG(3);let r=Error();return nG(t),{...e,captureStackTrace:sa(()=>r.stack)}},ss=e=>t=>{let r;return()=>{if(void 0!==r)return r;let n=t();if(!n)return;let i=n.split("\n");if(void 0!==i[e])return r=i[e].trim()}},sa=ss(3);class so extends tC{fiberId;constructor(e,t=tE){super("Interrupt",t,"Interrupted"),this.fiberId=e}toString(){return`Interrupt(${this.fiberId})`}toJSON(){return{_tag:"Interrupt",fiberId:this.fiberId}}[eQ](e){return tD(e)&&this.fiberId===e.fiberId&&this.annotations===e.annotations}[ej](){return eP(eB(`${this._tag}:${this.fiberId}`))(eL(this.annotations))}}let sl=e=>new tO([new so(e)]),sc=e=>{for(let t=0;t<e.reasons.length;t++){let r=e.reasons[t];if("Fail"===r._tag)return rp(r.error)}return rh(e)},su=e=>{let t=sc(e);return rd(t)?rx():rk(t.success)},sd=el(2,(e,t)=>{if(0===e.reasons.length)return t;if(0===t.reasons.length)return e;let r=new tO(nL(e.reasons,t.reasons));return eZ(e,r)?e:r}),sf=el(2,(e,t)=>{let r=!1,n=e.reasons.map(e=>tL(e)?(r=!0,new tA(t(e.error))):e);return r?tT(n):e}),sh=e=>{let t=(e=>{let t={Fail:[],Die:[],Interrupt:[]};for(let r=0;r<e.reasons.length;r++)t[e.reasons[r]._tag].push(e.reasons[r]);return t})(e);return t.Fail.length>0?t.Fail[0].error:t.Die.length>0?t.Die[0].defect:t.Interrupt.length>0?new globalThis.Error("All fibers interrupted without error"):new globalThis.Error("Empty cause")},sp=(e,t,r)=>{let n,i=typeof e;if(e&&"object"===i){if(n=new globalThis.Error(sm(e),{cause:e.cause?sp(e.cause):void 0}),"string"==typeof e.name&&(n.name=e.name),"string"==typeof e.stack)n.stack=sy(e.stack,n,t);else{let e=`${n.name}: ${n.message}`;n.stack=t?sb(e,t):e}for(let t of(r?.includeCauseInStack&&(n.stack=sx(n)),Object.keys(e)))t in n||(n[t]=e[t])}else n=new globalThis.Error(!e?`Unknown error: ${e}`:"string"===i?e:ta(e));return n},sm=e=>{if("string"==typeof e.message)return e.message;if("function"==typeof e.toString&&e.toString!==Object.prototype.toString&&e.toString!==Array.prototype.toString)try{return e.toString()}catch{}return ta(e)},sg=/\((.*)\)/g,sy=(e,t,r)=>{let n=`${t.name}: ${t.message}`,i=(e.startsWith(n)?e.slice(n.length):e).split("\n"),s=[n];for(let e=1;e<i.length&&!/(?:Generator\.next|~effect\/Effect)/.test(i[e]);e++)s.push(i[e]);return r?sb(s.join("\n"),r):s.join("\n")},sb=(e,t)=>{let r=t?.get(tz.key);return r&&(e=`${e}
31
- ${sv(r)}`),e},sv=e=>{let t=[],r=e,n=0;for(;r&&n<10;){let e=r.stack();if(e){let n=e.matchAll(sg),i=!1;for(let[,e]of n)i=!0,t.push(` at ${r.name} (${e})`);i||t.push(` at ${r.name} (${e.replace(/^at /,"")})`)}else t.push(` at ${r.name}`);r=r.parent,n++}return t.join("\n")},sw=e=>((e,t)=>{let r=[],n=[];if(0===e.reasons.length)return r;let i=Error.stackTraceLimit;for(let i of(nG(1),e.reasons)){if("Interrupt"===i._tag){n.push(i);continue}r.push(sp("Die"===i._tag?i.defect:i.error,i.annotations,t))}if(0===r.length){let e=Error("The fiber was interrupted by:");e.name="InterruptCause",e.stack=((e,t)=>{let r=[`${e.name}: ${e.message}`];for(let e of t){let t=void 0!==e.fiberId?`#${e.fiberId}`:"unknown",n=e.annotations.get("effect/Cause/InterruptorStackTrace");r.push(` at fiber (${t})`),n&&r.push(sv(n))}return r.join("\n")})(e,n);let i=new globalThis.Error("All fibers interrupted without error",{cause:e});i.name="InterruptError",i.stack=`${i.name}: ${i.message}`,r.push(sp(i,n[0].annotations,t))}return nG(i),r})(e).map(sx).join("\n"),sx=e=>e.cause?`${e.stack} {
32
- ${sk(e.cause," ")}
33
- }`:e.stack,sk=(e,t)=>{let r=e.stack.split("\n"),n=`${t}[cause]: ${r[0]}`;for(let e=1,i=r.length;e<i;e++)n+=`
34
- ${t}${r[e]}`;return e.cause&&(n+=` {
35
- ${sk(e.cause,`${t} `)}
36
- ${t}}`),n},sS="~effect/Fiber/dev",s_={_A:ec,_E:ec},s$={id:0},sO=()=>globalThis[te];class sI{constructor(e,t=!0){this[sS]=s_,this.setContext(e),this.id=++s$.id,this.currentOpCount=0,this.currentLoopCount=0,this.interruptible=t,this._stack=[],this._observers=[],this._exit=void 0,this._children=void 0,this._interruptedCause=void 0,this._yielded=void 0,this.runtimeMetrics?.recordFiberStart(this.context)}[sS];id;interruptible;currentOpCount;currentLoopCount;_stack;_observers;_exit;_currentExit;_children;_interruptedCause;_yielded;context;currentScheduler;currentTracerContext;currentSpan;currentLogLevel;minimumLogLevel;currentStackFrame;runtimeMetrics;maxOpsBeforeYield;currentPreventYield;_dispatcher=void 0;get currentDispatcher(){return this._dispatcher??=this.currentScheduler.makeDispatcher()}getRef(e){var t;return t=this.context,t.mapUnsafe.has(e.key)?t.mapUnsafe.get(e.key):it(e)}addObserver(e){return this._exit?(e(this._exit),ep):(this._observers.push(e),()=>{let t=this._observers.indexOf(e);t>=0&&this._observers.splice(t,1)})}interruptUnsafe(e,t){if(this._exit)return;let r=sl(e);this.currentStackFrame&&(r=tF(r,n4(tz,this.currentStackFrame))),t&&(r=tF(r,t)),this._interruptedCause=this._interruptedCause?sd(this._interruptedCause,r):r,this.interruptible&&this.evaluate(sF(this._interruptedCause))}pollUnsafe(){return this._exit}evaluate(e){if(this._exit)return;if(void 0!==this._yielded){let e=this._yielded;this._yielded=void 0,e()}let t=this.runLoop(e);if(t===tv)return;let r=sC.interruptChildren&&sC.interruptChildren(this);if(void 0!==r)return this.evaluate(s8(r,()=>t));this._exit=t,this.runtimeMetrics?.recordFiberEnd(this.context,this._exit);for(let e=0;e<this._observers.length;e++)this._observers[e](t);this._observers.length=0}runLoop(e){let t=globalThis[te];globalThis[te]=this;let r=!1,n=e;this.currentOpCount=0;let i=++this.currentLoopCount;try{for(;;){if(this.currentOpCount++,!r&&!this.currentPreventYield&&this.currentScheduler.shouldYield(this)){r=!0;let e=n;n=s8(sR,()=>e)}if(n=this.currentTracerContext?this.currentTracerContext(n,this):n[tm](this),i!==this.currentLoopCount)return tv;if(n===tv){let e=this._yielded;if(tf in e)return this._yielded=void 0,e;return tv}}}catch(e){if(!eT(n,tm))return tW(`Fiber.runLoop: Not a valid effect: ${String(n)}`);return this.runLoop(tW(e))}finally{globalThis[te]=t}}getCont(e){for(;;){let t=this._stack.pop();if(!t)return;let r=t[tb]&&t[tb](this);if(r)return r[e]=r,r;if(t[e])return t}}yieldWith(e){return this._yielded=e,tv}children(){return this._children??=new Set}pipe(){return es(this,arguments)}setContext(e){this.context=e;let t=this.getRef(iB);t!==this.currentScheduler&&(this.currentScheduler=t,this._dispatcher=void 0),this.currentSpan=e.mapUnsafe.get(iY),this.currentLogLevel=this.getRef(st),this.minimumLogLevel=this.getRef(sr),this.currentStackFrame=e.mapUnsafe.get(i4.key),this.maxOpsBeforeYield=this.getRef(iJ),this.currentPreventYield=this.getRef(iW),this.runtimeMetrics=e.mapUnsafe.get("effect/observability/Metric/FiberRuntimeMetricsKey");let r=e.mapUnsafe.get(iX);this.currentTracerContext=r?r.context:void 0}get currentSpanLocal(){return this.currentSpan?._tag==="Span"?this.currentSpan:void 0}}let sC={interruptChildren:void 0},sE=e=>{if(!e.currentStackFrame)return;let t=new Map;return t.set(tz.key,e.currentStackFrame),n1(t)},sA=e=>sW(t=>{let r,n=e[Symbol.iterator](),i=[];return!function e(){let s=n.next();for(;!s.done;){if(s.value._exit){i.push(s.value._exit),s=n.next();continue}r=s.value.addObserver(t=>{i.push(t),e()});return}t(sj(i))}(),sL(()=>r?.())}),sT=e=>tY(t=>sM(e,t.id)),sM=el(e=>eT(e[0],sS),(e,t,r)=>tY(n=>{let i=sE(n);return i=i&&r?is(i,r):i??r,e.interruptUnsafe(t,i),s5(e._exit?sj(e._exit):sW(t=>e._exit?t(sj(e._exit)):sL(e.addObserver(e=>t(sj(e))))))})),sN=e=>tY(t=>{let r=sE(t),n=nP();for(let i of e)i.interruptUnsafe(t.id,r),n.push(i);return s5(sA(n))}),sj=tK,sF=tV,sL=tB({op:"Sync",[tm](e){let t=this[tp](),r=e.getCont(tg);return r?r[tg](t,e):e.yieldWith(tK(t))}}),sP=tB({op:"Suspend",[tm](e){return this[tp]()}}),sD=n_({onFailure:tJ,onSuccess:sj}),sR=tB({op:"Yield",[tm](e){let t=!1;return e.currentDispatcher.scheduleTask(()=>{t||e.evaluate(ai)},this[tp]??0),e.yieldWith(()=>{t=!0})}})(0),sU=sj(rx()),sB=e=>tW(e),sq=e=>sP(()=>tJ(tu(e))),sK=sj(void 0),sz=e=>{let t="function"==typeof e?e:e.try,r="function"==typeof e?e=>new oL(e,"An error occurred in Effect.try"):e.catch;return sP(()=>{try{return sj(tu(t))}catch(e){return tJ(tu(()=>r(e)))}})},sV=tB({op:"Async",single:!1,[tm](e){let t=tu(()=>this[tp][0].bind(e.currentScheduler)),r=!1,n=!1,i=this[tp][1]?new AbortController:void 0,s=t(t=>{r||(r=!0,n?e.evaluate(t):n=t)},i?.signal);return!1!==n?n:(n=!0,e._yielded=()=>{r=!0},void 0===i&&void 0===s||e._stack.push(sJ(()=>(r=!0,i?.abort(),s??ai))),tv)}}),sJ=tB({op:"AsyncFinalizer",[tb](e){e.interruptible&&(e.interruptible=!1,e._stack.push(a5))},[ty](e,t){return e.reasons.some(tD)?s8(this[tp](),()=>sF(e)):sF(e)}}),sW=e=>sV(e,e.length>=2),sY=sW(ep),sG=(e,...t)=>{let r=0===t.length?function(){return sP(()=>s0(e.apply(this,arguments)))}:function(){let r=sP(()=>s0(e.apply(this,arguments)));for(let e=0;e<t.length;e++)r=t[e](r,...arguments);return r};return sH(e.length,r)},sH=(e,t)=>Object.defineProperty(t,"length",{value:e,configurable:!0}),sQ=ss(2),sZ=(e,t,r,n,i,s)=>{let a="function"==typeof t?t:n.pop().bind(t.self);return sH(a.length,function(...t){let o=sP(()=>{let e=a.apply(this,arguments);return tk(e)?e:s0(e)});for(let e=0;e<n.length;e++)o=n[e](o,...t);if(!tk(o))return o;let l=Error.stackTraceLimit;nG(2);let c=new globalThis.Error;return nG(l),ac(i?ob(e,s,e=>ov(o,e)):o,i4,t=>({name:e,stack:sQ(()=>c.stack),parent:{name:`${e} (definition)`,stack:sQ(()=>r.stack),parent:t}}))})},sX=e=>{try{let t,r=e();for(;;){let n=r.next(t);if(n.done)return sj(n.value);let i=n.value;if(i&&"Success"===i._tag){t=i.value;continue}{if(i&&"Failure"===i._tag)return n.value;let t=!0;return sP(()=>t?(t=!1,s8(n.value,e=>s0(r,e))):sP(()=>s0(e())))}}}catch(e){return sB(e)}},s0=tB({op:"Iterator",single:!1,[tg](e,t){let r=this[tp][0];for(;;){let n=r.next(e);if(n.done)return sj(n.value);if(!s9(n.value))return t._stack.push(this),n.value;if("Failure"===n.value._tag)return n.value;e=n.value.value}},[tm](e){return this[tg](this[tp][1],e)}}),s1=el(2,(e,t)=>{let r=sj(t);return s8(e,e=>r)}),s2=el(2,(e,t)=>s8(e,e=>tk(t)?t:tu(()=>t(e)))),s3=el(2,(e,t)=>s8(e,e=>s1(tk(t)?t:tu(()=>t(e)),e))),s5=e=>s8(e,e=>ai),s4=el(e=>tk(e[1]),(e,t,r)=>{let n;return n=[e,t],tY(e=>sW(t=>{let i=!1,s=new Set,a=e=>{i=!0,t(0===s.size?e:s8(a2(sN(s)),()=>e))},o=0;for(let t of n){if(i)break;let n=o++,l=oi(e,t,!0,!0,!1);s.add(l),l.addObserver(t=>{s.delete(l);let o=!i;a(t),o&&r?.onWinner&&r.onWinner({fiber:l,index:n,parentFiber:e})})}return sN(s)}))}),s8=el(2,(e,t)=>{let r=Object.create(s6);return r[tp]=e,r[tg]=1!==t.length?e=>t(e):t,r}),s6=tU({op:"OnSuccess",[tm](e){return e._stack.push(this),this[tp]}}),s9=e=>tf in e,s7=el(2,(e,t)=>s9(e)?"Success"===e._tag?t(e.value):e:s8(e,t)),ae=el(2,(e,t)=>s8(e,e=>sj(tu(()=>t(e))))),at=el(2,(e,t)=>s9(e)?as(e,t):ae(e,t)),ar=el(2,(e,t)=>s9(e)?aa(e,t):aO(e,t)),an=e=>"Failure"===e._tag?rp(e.cause):rh(e),ai=tK(void 0),as=el(2,(e,t)=>"Success"===e._tag?tK(t(e.value)):e),aa=el(2,(e,t)=>{if("Success"===e._tag)return e;let r=sc(e.cause);return rd(r)?e:tJ(t(r.success))});(e,t)=>{if("Success"===e._tag)return tK(t.onSuccess(e.value));let r=sc(e.cause);return rd(r)?e:tJ(t.onFailure(r.success))};let ao=el(2,(e,t)=>"Success"===e._tag?t:e),al=el(2,(e,t)=>tY(r=>{let n=r.context,i=t(n);return n===i?e:(r.setContext(i),aH(e,()=>{r.setContext(n)}))})),ac=el(3,(e,t,r)=>al(e,e=>{let n=n9(e,t),i=r(n);return n===i?e:n8(e,t,i)})),au=e=>tY(t=>e(t.context)),ad=el(2,(e,t)=>s9(e)?e:al(e,is(t))),af=function(){return 1==arguments.length?el(2,(e,t)=>ah(e,arguments[0],t)):el(3,(e,t,r)=>ah(e,t,r)).apply(this,arguments)},ah=(e,t,r)=>al(e,e=>e.mapUnsafe.get(t.key)===r?e:n8(e,t,r)),ap=((e,t,r)=>s8(r,r=>af(e,t,r)),el(e=>tk(e[0]),(e,t)=>a7({while:ed,body:eu(t?.disableYield?e:s8(e,e=>sR)),step:ep}))),am=el(2,(e,t)=>{let r=Object.create(ag);return r[tp]=e,r[ty]=1!==t.length?e=>t(e):t,r}),ag=tU({op:"OnFailure",[tm](e){return e._stack.push(this),this[tp]}}),ay=((e,t,r)=>am(e,e=>t(e)?tu(()=>r(e)):sF(e)),el(3,(e,t,r)=>am(e,e=>{let n=t(e);return rd(n)?sF(n.failure):tu(()=>r(n.success,e))}))),ab=el(2,(e,t)=>ay(e,sc,e=>t(e))),av=el(2,(e,t)=>am(e,e=>s2(tu(()=>t(e)),sF(e)))),aw=el(3,(e,t,r)=>am(e,e=>{let n=t(e);return rd(n)?sF(e):s2(tu(()=>r(n.success,e)),sF(e))})),ax=el(2,(e,t)=>aw(e,sc,e=>t(e))),ak=el(e=>tk(e[0]),(e,t,r,n)=>am(e,e=>{let i=sc(e);return rd(i)?sF(i.failure):t(i.success)?tu(()=>r(i.success)):n?tu(()=>n(i.success)):sF(e)})),aS=el(e=>tk(e[0]),(e,t,r,n)=>am(e,e=>{let i=sc(e);if(rd(i))return sF(i.failure);let s=t(i.success);return rd(s)?n?tu(()=>n(s.failure)):sF(e):tu(()=>r(s.success))})),a_=el(e=>tk(e[0]),(e,t,r,n)=>ak(e,Array.isArray(t)?e=>eT(e,"_tag")&&t.includes(e._tag):eM(t),r,n)),a$=el(e=>tk(e[0]),(e,t,r)=>{let n;return aS(e,e=>(n??=Object.keys(t),eT(e,"_tag")&&ev(e._tag)&&n.includes(e._tag)?rp(e):rh(e)),e=>tu(()=>t[e._tag](e)),r)}),aO=el(2,(e,t)=>ab(e,e=>sq(()=>t(e)))),aI=((e,t)=>aT(e,{onFailure:e=>sq(()=>t.onFailure(e)),onSuccess:e=>sL(()=>t.onSuccess(e))}),el(e=>tk(e[0]),(e,t)=>{if(!t?.log)return aT(e,{onFailure:e=>sK,onSuccess:e=>sK});let r=oz(!0===t.log?void 0:t.log);return aE(e,{onFailure(e){let n,i=(n=e.reasons.find(tL))?rp(n):rh(e);return rd(i)?sF(i.failure):void 0===t.message?r(e):r(t.message,e)},onSuccess:e=>sK})})),aC=e=>aN(e,{onFailure:rh,onSuccess:rp}),aE=el(2,(e,t)=>{let r=Object.create(aA);return r[tp]=e,r[tg]=1!==t.onSuccess.length?e=>t.onSuccess(e):t.onSuccess,r[ty]=1!==t.onFailure.length?e=>t.onFailure(e):t.onFailure,r}),aA=tU({op:"OnSuccessAndFailure",[tm](e){return e._stack.push(this),this[tp]}}),aT=((e,t)=>aE(e,{onFailure:e=>sL(()=>t.onFailure(e)),onSuccess:e=>sL(()=>t.onSuccess(e))}),el(2,(e,t)=>aE(e,{onFailure:e=>{let r=e.reasons.find(tL);return r?tu(()=>t.onFailure(r.error)):sF(e)},onSuccess:t.onSuccess}))),aM=el(2,(e,t)=>aT(e,{onFailure:e=>sL(()=>t.onFailure(e)),onSuccess:e=>sL(()=>t.onSuccess(e))})),aN=el(2,(e,t)=>{if(s9(e)){if("Success"===e._tag)return tK(t.onSuccess(e.value));let r=sc(e.cause);return rd(r)?e:tK(t.onFailure(r.success))}return aM(e,t)}),aj=e=>s9(e)?tK(e):aF(e),aF=tB({op:"Exit",[tm](e){return e._stack.push(this),this[tp]},[tg]:(e,t,r)=>sj(r??tK(e)),[ty]:(e,t,r)=>sj(r??tV(e))}),aL=el(2,(e,t)=>s4(e,s8(oE(t.duration),t.orElse))),aP="~effect/Scope",aD="~effect/Scope/Closeable",aR=nQ("effect/Scope"),aU=(e,t)=>sP(()=>aB(e,t)??sK),aB=(e,t)=>{if("Closed"===e.state._tag)return;let r={_tag:"Closed",exit:t};if("Empty"===e.state._tag){e.state=r;return}let{finalizers:n}=e.state;return(e.state=r,0===n.size)?void 0:1===n.size?n.values().next().value(t):aq(e,n,t)},aq=sG(function*(e,t,r){let n=[],i=[],s=Array.from(t.values()),a=sO();for(let t=s.length-1;t>=0;t--){let o=s[t];"sequential"===e.strategy?n.push((yield*aj(o(r)))):i.push(oi(a,o(r),!0,!0,"inherit"))}return i.length>0&&(n=yield*sA(i)),yield*(e=>{let t=[];for(let r of e)"Failure"===r._tag&&t.push(...r.cause.reasons);return 0===t.length?ai:tV(tT(t))})(n)}),aK=(e,t)=>sP(()=>"Closed"===e.state._tag?t(e.state.exit):(az(e,{},t),sK)),az=(e,t,r)=>{"Empty"===e.state._tag?e.state={_tag:"Open",finalizers:new Map([[t,r]])}:"Open"===e.state._tag&&e.state.finalizers.set(t,r)},aV=(e,t)=>{"Open"===e.state._tag&&e.state.finalizers.delete(t)},aJ=(e="sequential")=>({[aD]:aD,[aP]:aP,strategy:e,state:aW}),aW={_tag:"Empty"},aY=af(aR),aG=e=>sP(()=>{let t=aJ();return aQ(e(t),e=>sP(()=>aB(t,e)??sK))}),aH=tB({op:"OnExit",single:!1,[tm](e){return e._stack.push(this),this[tp][0]},[tb](e){e.interruptible&&!0!==this[tp][2]&&(e._stack.push(a5),e.interruptible=!1)},[tg](e,t,r){r??=tK(e);let n=this[tp][1](r);return n?s8(n,e=>r):r},[ty](e,t,r){r??=tV(e);let n=this[tp][1](r);return n?s8(n,e=>r):r}}),aQ=el(2,aH),aZ=el(2,(e,t)=>aQ(e,e=>t)),aX=((e,t,r)=>aQ(e,e=>t(e)?r(e):sK),el(3,(e,t,r)=>aQ(e,e=>{let n=t(e);return rd(n)?sK:r(n.success,e)}))),a0=el(2,(e,t)=>aX(e,an,t)),a1=((e,t,r)=>aQ(e,e=>{if("Failure"!==e._tag)return sK;let n=t(e.cause);return rd(n)?sK:r(n.success,e.cause)}),tY(e=>sF(sl(e.id)))),a2=e=>tY(t=>(t.interruptible&&(t.interruptible=!1,t._stack.push(a5)),e)),a3=tB({op:"SetInterruptible",[tb](e){if(e.interruptible=this[tp],e._interruptedCause&&e.interruptible)return()=>sF(e._interruptedCause)}}),a5=a3(!0),a4=a3(!1),a8=e=>tY(t=>t.interruptible?e:(t.interruptible=!0,t._stack.push(a4),t._interruptedCause)?sF(t._interruptedCause):e),a6=e=>tY(t=>t.interruptible?(t.interruptible=!1,t._stack.push(a5),e(a8)):e(ec)),a9=(e,t)=>eN(e)?t?.mode==="result"?oe(e,aC,t):oe(e,ec,t):t?.discard?"result"===t.mode?oe(Object.values(e),aC,t):oe(Object.values(e),ec,t):sP(()=>{let r={};return s1(oe(Object.entries(e),([e,n])=>ae(t?.mode==="result"?aC(n):n,t=>{r[e]=t}),{discard:!0,concurrency:t?.concurrency}),r)}),a7=((e=>eN(e[0])&&!tk(e[0]),(e,t,r)=>ae(oe(e,(e,r)=>aC(t(e,r)),r),e=>nB(e,ec))),tB({op:"While",[tg](e,t){return(this[tp].step(e),this[tp].while())?(t._stack.push(this),this[tp].body()):ai},[tm](e){return this[tp].while()?(e._stack.push(this),this[tp].body()):ai}})),oe=el(e=>"function"==typeof e[1],(e,t,r)=>tY(n=>{let i=r?.concurrency==="inherit"?n.getRef(i3):r?.concurrency??1,s="unbounded"===i?1/0:Math.max(1,i);if(1===s)return ot(e,t,r);let a=nO(e),o=a.length;if(0===o)return r?.discard?sK:sj([]);let l=r?.discard?void 0:Array(o),c=on({f:t,out:l},a,{concurrency:s});return c?s1(c,l):sj(l)})),ot=(e,t,r)=>sP(()=>{let n=r?.discard?void 0:[],i=e[Symbol.iterator](),s=i.next(),a=0;return s1(a7({while:()=>!s.done,body:()=>t(s.value,a++),step:e=>{n&&n.push(e),s=i.next()}}),n)}),or=e=>{let t=e.onItem,r=e.step;return(e,n,i)=>{let s,a,o,l,c,u=i?.start??0,d=i?.end??n.length,f=i?.concurrency??1,h=i?.orderedStep===!0&&f>1,p=!1,m=!1,g=u,y=h?Array(d):void 0,b=(t,i,s)=>{if(!h)return r(e,t,i,s);if(l)return l;for(y[s]=i;g<d;){let t=y[g];if(void 0===t)return;y[g]=void 0;let i=g++,s=r(e,n[i],t,i);if(s)return s}},v=()=>{let r=!1;for(;!l&&u<d;u++){let i=n[u],d=c??t(e,i,u);if(s9(d)){if(l=b(i,d,u))break}else{if(1===f)return s8(aj(d),e=>(l=b(i,e,u),u++,l??v()??sK));if(!s)return sW(e=>{s=sO(),c=d,o=e;let t=v();return t?e(t):sP(()=>(l=ai,m=!0,a?sN(a):sK))});c=void 0;let e=oi(s,d,!0,!0,"inherit");if(e._exit){if(l=b(i,e._exit,u))break;continue}a?a.add(e):a=new Set([e]);let t=u;if(e.addObserver(n=>{if(a.delete(e),l){if(!m&&"Failure"===n._tag)for(let e of n.cause.reasons)if("Interrupt"===e._tag)continue;else"Failure"===l._tag?l.cause.reasons.push(e):l=tV(tT([e]))}else{let e=b(i,n,t);e&&(l="Failure"===e._tag?tV(tT(e.cause.reasons.slice())):e,v())}if(r){let e=v();e&&o(e)}else p&&0===a.size&&o(l??sK)}),a.size<f)continue;r=!0,u++;return}}if(p=!0,l){if(a&&a.size>0){let e=sE(s);a.forEach(t=>t.interruptUnsafe(s.id,e));return}if(o||"Failure"===l._tag)return l}else if(o)if(!a)return ai;else 0===a.size&&o(sK)};return v()}},on=or({onItem:(e,t,r)=>e.f(t,r),step(e,t,r,n){if("Failure"===r._tag)return r;e.out&&(e.out[n]=r.value)}}),oi=((e,t,r)=>s8(e,e=>t(e)?sj(e):r(e)),(e,t,r=!1,n=!1,i=!1)=>{let s="inherit"===i?e.interruptible:!i,a=new sI(e.context,s);return r?a.evaluate(t):e.currentDispatcher.scheduleTask(()=>a.evaluate(t),0),n||a._exit||(e.children().add(a),a.addObserver(()=>e._children.delete(a))),a}),os=el(e=>tk(e[0]),(e,t,r)=>tY(n=>{let i=oi(n,e,r?.startImmediately,!0,r?.uninterruptible);if(!i._exit)if("Closed"!==t.state._tag){let e={};az(t,e,()=>{let e;return e=e=>e===i.id?sK:sT(i),tY(t=>e(t.id))}),i.addObserver(()=>aV(t,e))}else i.interruptUnsafe(n.id,sE(n));return sj(i)})),oa=el(e=>tk(e[0]),(e,t)=>s8(aR,r=>os(e,r,t))),oo=e=>(t,r)=>{let n=new sI(r?.scheduler?n8(e,iB,r.scheduler):e,r?.uninterruptible!==!0);if(n.evaluate(t),n._exit)return n;if(r?.signal)if(r.signal.aborted)n.interruptUnsafe();else{let e=()=>n.interruptUnsafe();r.signal.addEventListener("abort",e,{once:!0}),n.addObserver(()=>r.signal.removeEventListener("abort",e))}return r?.onFiberStart&&r.onFiberStart(n),n},ol=el(2,(e,t)=>{if(e._exit)return e;if("Closed"===t.state._tag)return e.interruptUnsafe(e.id),e;let r={};return az(t,r,()=>sT(e)),e.addObserver(()=>aV(t,r)),e}),oc=oo(n5),ou=(z=oo(n5),e=>{if(s9(e))return e;let t=z(e,{scheduler:new iz("sync")});return t.currentDispatcher?.flush(),t._exit??tW(new oj(t))}),od=sj(!0),of=sj(!1);class oh{waiters=[];scheduled=!1;_isOpen;constructor(e){this._isOpen=e}scheduleUnsafe(e){return this.scheduled||0===this.waiters.length||(this.scheduled=!0,e.currentDispatcher.scheduleTask(this.flushWaiters,0)),od}flushWaiters=()=>{this.scheduled=!1;let e=this.waiters;this.waiters=[];for(let t=0;t<e.length;t++)e[t](ai)};open=tY(e=>this._isOpen?of:(this._isOpen=!0,this.scheduleUnsafe(e)));release=tY(e=>this._isOpen?of:this.scheduleUnsafe(e));openUnsafe(){return!this._isOpen&&(this._isOpen=!0,this.flushWaiters(),!0)}await=sW(e=>this._isOpen?e(sK):(this.waiters.push(e),sL(()=>{let t=this.waiters.indexOf(e);-1!==t&&this.waiters.splice(t,1)})));closeUnsafe(){return!!this._isOpen&&(this._isOpen=!1,!0)}close=sL(()=>this.closeUnsafe());whenOpen=e=>s8(this.await,()=>e);isOpen(){return this._isOpen}}let op=e=>new oh(e??!1),om=BigInt(0),og={_tag:"Span",spanId:"noop",traceId:"noop",sampled:!1,status:{_tag:"Ended",startTime:om,endTime:om,exit:ai},attributes:new Map,links:[],kind:"internal",attribute(){},event(){},end(){},addLinks(){}},oy=e=>e?n7(e.annotations,iH)?"Span"===e._tag?oy(rB(e.parent)):rx():rk(e):rx(),ob=(e,...t)=>{let r=1===t.length?void 0:t[0],n=t[t.length-1];return tY(t=>{let i=((e,t,r)=>{let n,i=!e.getRef(i8)||r?.annotations&&n7(r.annotations,iH),s=r?.parent!==void 0?rk(r.parent):r?.root?rx():oy(e.currentSpan);if(i){let e;e={name:t,parent:s,annotations:n8(r?.annotations??n5,iH,!0)},n=Object.assign(Object.create(og),e)}else{let i=e.getRef(i0),a=e.getRef(oS),o=e.getRef(i6),l=e.getRef(i9),c=e.getRef(i7),u=r?.level??e.getRef(iQ),d=r?.links!==void 0?[...c,...r.links]:c.slice();for(let[c,f]of(n=i.span({name:t,parent:s,annotations:r?.annotations??n5,links:d,startTime:o?a.currentTimeNanosUnsafe():BigInt(0),kind:r?.kind??"internal",root:r?.root??r_(s),sampled:r?.sampled??((!r$(s)||!1!==s.value.sampled)&&!oD(e.getRef(iZ),u))}),Object.entries(l)))n.attribute(c,f);if(r?.attributes!==void 0)for(let[e,t]of Object.entries(r.attributes))n.attribute(e,t)}return n})(t,e,r),s=t.getRef(oS);return aQ(tu(()=>n(i)),e=>sL(()=>{"Ended"!==i.status._tag&&i.end(s.currentTimeNanosUnsafe(),e)}))})},ov=af(iG),ow=function(){let e=tk(arguments[0]),t=e?arguments[1]:arguments[0],r=e?arguments[2]:arguments[1],n=ec;if("Span"===t._tag){var i,s;r=si(r),i=t.name,s="function"==typeof(s=r?.captureStackTrace)?s:ep,n=ac(i4,e=>({name:i,stack:s,parent:e}))}return e?ov(n(arguments[0]),t):e=>ov(n(e),t)},ox=el(e=>tk(e[0]),(e,...t)=>ac(e,i9,e=>{let r={...e};return 1===t.length?Object.assign(r,t[0]):r[t[0]]=t[1],r})),ok=tY(e=>{let t=e.currentSpanLocal;return t?sj(t):tJ(new tX)}),oS=io("effect/Clock",{defaultValue:()=>new o$}),o_=0x80000000-1;class o${currentTimeMillisUnsafe(){return Date.now()}currentTimeMillis=sL(()=>this.currentTimeMillisUnsafe());currentTimeNanosUnsafe(){return oI()}currentTimeNanos=sL(()=>this.currentTimeNanosUnsafe());sleep(e){return this.sleepMillis(ij(e))}sleepMillis(e){return e<=0?sR:Number.isFinite(e)?sW(t=>{let r=e>o_?this.sleepMillis(e-o_):sK,n=setTimeout(()=>t(r),Math.min(e,o_));return sL(()=>clearTimeout(n))}):sY}}let oO=(c=BigInt(1e6),"u"<typeof performance||void 0===performance.now?()=>BigInt(Date.now())*c:()=>(l??=BigInt(Date.now())*c-BigInt(Math.round(1e6*performance.now())))+BigInt(Math.round(1e6*performance.now()))),oI=function(){let e="object"==typeof process&&"hrtime"in process&&"function"==typeof process.hrtime.bigint?process.hrtime:void 0;if(!e)return oO;let t=BigInt(Date.now())*BigInt(1e6)-e.bigint();return()=>t+e.bigint()}(),oC=e=>tY(t=>e(t.getRef(oS))),oE=e=>oC(t=>t.sleep(ig(e))),oA=oC(e=>e.currentTimeMillis),oT="~effect/Cause/IllegalArgumentError";class oM extends tQ("IllegalArgumentError"){[oT]=oT;constructor(e){super({message:e})}}let oN="~effect/Cause/AsyncFiberError";class oj extends tQ("AsyncFiberError"){[oN]=oN;constructor(e){super({message:"An asynchronous Effect was executed with Effect.runSync",fiber:e})}}let oF="~effect/Cause/UnknownError";class oL extends tQ("UnknownError"){[oF]=oF;constructor(e,t){super({message:t,cause:e})}}let oP=io("effect/Console/CurrentConsole",{defaultValue:()=>globalThis.console}),oD=rv(rb(rg,e=>{switch(e){case"All":return Number.MIN_SAFE_INTEGER;case"Fatal":return 5e4;case"Error":return 4e4;case"Warn":return 3e4;case"Info":return 2e4;case"Debug":return 1e4;case"Trace":return 0;case"None":return Number.MAX_SAFE_INTEGER}})),oR=io("effect/Loggers/CurrentLoggers",{defaultValue:()=>new Set([oV,oJ])}),oU=io("effect/Logger/LogToStderr",{defaultValue:ef}),oB={"~effect/Logger":{_Message:ec,_Output:ec},pipe(){return es(this,arguments)}},oq=e=>{let t=Object.create(oB);return t.log=e,t},oK=(e,t)=>{let r=e[0].replace(/[\s="]/g,"_");return`${r}=${t-e[1]}ms`},oz=e=>(...t)=>{let r;for(let e=0,n=t.length;e<n;e++){let n=t[e];t$(n)&&(r?t.splice(e,1):t=t.slice(0,e).concat(t.slice(e+1)),r=r?tT(r.reasons.concat(n.reasons)):n,e--)}return void 0===r&&(r=tM),tY(n=>{let i=e??n.currentLogLevel;if(oD(n.minimumLogLevel,i))return sK;let s=n.getRef(oS),a=n.getRef(oR);if(a.size>0){let e=new Date(s.currentTimeMillisUnsafe());for(let s of a)s.log({cause:r,fiber:n,date:e,logLevel:i,message:t})}return sK})},oV=oq(({cause:e,date:t,fiber:r,logLevel:n,message:i})=>{let s=Array.isArray(i)?i.slice():[i];e.reasons.length>0&&s.push(sw(e));let a=t.getTime(),o=r.getRef(sn),l="";for(let e of o)l+=` ${oK(e,a)}`;let c=r.getRef(se);Object.keys(c).length>0&&s.push(c);let u=r.getRef(oP);(r.getRef(oU)?u.error:u.log)(`[${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}:${t.getSeconds().toString().padStart(2,"0")}.${t.getMilliseconds().toString().padStart(3,"0")}] ${n.toUpperCase()} (#${r.id})${l}:`,...s)}),oJ=oq(({cause:e,fiber:t,logLevel:r,message:n})=>{let i=t.getRef(oS),s=t.getRef(se),a=t.currentSpan;if(void 0===a||"ExternalSpan"===a._tag)return;let o={};for(let[e,t]of Object.entries(s))o[e]=t;o["effect.fiberId"]=t.id,o["effect.logLevel"]=r.toUpperCase(),e.reasons.length>0&&(o["effect.cause"]=sw(e)),a.event(((e,t=2)=>{if("string"==typeof e)return e;try{return"object"==typeof e?ta(e,{space:t}):String(e)}catch{return String(e)}})(Array.isArray(n)&&1===n.length?n[0]:n),i.currentTimeNanosUnsafe(),o)}),oW=e=>e.reasons.length>0&&e.reasons.every(tD),oY=e=>void 0===e?t3:tJ(t2(e)),oG=el(2,(e,t)=>ay(e,oZ,e=>t(e))),oH=e=>"Fail"===e._tag&&eT(e.error,t0),oQ=iU(sc,e=>eT(e,t0)?rp(e):rh(e)),oZ=iU(sc,e=>eT(e,t0)?rp(e.value):rh(e)),oX=e=>{let t=oQ(e);return rd(t)?tV(t.failure):tK(t.success.value)},o0=el(2,(e,t)=>aE(e,{onSuccess:t.onSuccess,onFailure:e=>{let r=oQ(e);return rd(r)?t.onFailure(r.failure):t.onDone(r.success.value)}})),o1="~effect/Schedule",o2=io("effect/Schedule/CurrentMetadata",{defaultValue:eu({input:void 0,output:void 0,duration:i_,attempt:0,start:0,now:0,elapsed:0,elapsedSincePrevious:0})}),o3={[o1]:{_Out:ec,_In:ec,_Env:ec},pipe(){return es(this,arguments)}},o5=e=>{let t=Object.create(o3);return t.step=e,t},o4=()=>{let e,t,r=0;return(n,i)=>{void 0===t&&(t=n);let s=n-t,a=void 0===e?0:n-e;return e=n,{input:i,attempt:++r,start:t,now:n,elapsed:s,elapsedSincePrevious:a}}},o8=e=>am(e.step,e=>sj(()=>sF(e))),o6=e=>oC(t=>ae(o8(e),e=>{let r=o4();return n=>sP(()=>{let i=t.currentTimeMillisUnsafe();return s8(e(i,n),([e,t])=>{let s=r(i,n);return s.output=e,s.duration=t,s1(oE(t),s)})})})),o9=e=>o5(ae(o8(e),e=>(t,r)=>o0(e(t,r),{onSuccess:e=>sj([r,e[1]]),onFailure:sF,onDone:()=>oY(r)}))),o7=e=>{let t=ig(e);return o5(ae(sj(e=>sj([e.attempt-1,t])),e=>{let t=o4();return(r,n)=>e(t(r,n))}))},le=el(2,(e,t)=>{let r=void 0===t.duration?void 0:ig(t.duration);return lt(e,({attempt:e,elapsed:n})=>sj((void 0===t.times||e<=t.times)&&(void 0===r||iD(iC(n),r))))}),lt=el(2,(e,t)=>o5(ae(o8(e),e=>{let r=o4();return(n,i)=>s8(e(n,i),e=>{let[s,a]=e,o=t({...r(n,i),output:s,duration:a});return s8(tk(o)?o:sj(o),t=>t?sj(e):oY(s))})}))),lr=o7(i_),ln={"~effect/Deferred":{_A:ec,_E:ec},pipe(){return es(this,arguments)}},li=()=>{let e=Object.create(ln);return e.resumes=void 0,e.effect=void 0,e},ls=e=>sW(t=>e.effect?t(e.effect):(e.resumes??=[],e.resumes.push(t),sL(()=>{let r=e.resumes.indexOf(t);e.resumes.splice(r,1)}))),la=el(2,(e,t)=>sL(()=>lc(e,t))),lo=e=>sL(()=>ll(e)),ll=e=>void 0!==e.effect,lc=(e,t)=>{if(e.effect)return!1;if(e.effect=t,e.resumes){for(let r=0;r<e.resumes.length;r++)e.resumes[r](t);e.resumes=void 0}return!0},lu=(e,t)=>{let r=aJ(t);if("Closed"===e.state._tag)return r.state=e.state,r;let n={};return az(e,n,e=>aU(r,e)),az(r,n,t=>sL(()=>aV(e,n))),r},ld="~effect/Layer/MemoMap",lf={"~effect/Layer":{_ROut:ec,_E:ec,_RIn:ec},pipe(){return es(this,arguments)}},lh=e=>{let t=Object.create(lf);return t.build=e,t},lp=e=>lh((t,r)=>{let n=lu(r);return aQ(e(t,n),e=>"Failure"===e._tag?aU(n,e):sK)});class lm{get[ld](){return ld}parent;constructor(e){this.parent=e}map=new Map;get(e,t){let r=this.map.get(e);if(r)return r.observers++,s2(aK(t,e=>r.finalizer(e)),r.effect);return this.parent?.get(e,t)}getOrElseMemoize(e,t,r){var n;let i,s,a,o=this.get(e,t);return o?o:(n=this,i=aJ(),a={observers:1,effect:ls(s=li()),finalizer:t=>sP(()=>(a.observers--,0===a.observers)?(n.map.delete(e),aU(i,t)):sK)},n.map.set(e,a),aK(t,a.finalizer).pipe(s8(()=>r(n,i)),aQ(e=>(a.effect=e,la(s,e)))))}}let lg=()=>new lm;class ly extends nQ()("effect/Layer/CurrentMemoMap"){static forkOrCreate(e){let t=n6(e,ly);return t?new lm(t):lg()}}let lb=el(3,(e,t,r)=>af(ae(e.build(t,r),n8(ly,t)),ly,t)),lv=el(2,(e,t)=>tY(r=>lb(e,ly.forkOrCreate(r.context),t))),lw=function(){return 1==arguments.length?e=>lx(n4(arguments[0],e)):lx(n4(arguments[0],arguments[1]))},lx=e=>lh(eu(sj(e))),lk=function(){return 1==arguments.length?e=>lS(arguments[0],e):lS(arguments[0],arguments[1])},lS=(e,t)=>l_(ae(t,t=>n4(e,t))),l_=e=>{var t;let r;return t=(t,r)=>aY(e,r),r=lp((e,n)=>e.getOrElseMemoize(r,n,t))},l$=(e,t,r)=>{let n=lu(r,"parallel");return oe(e,e=>e.build(t,lu(n,"sequential")),{concurrency:e.length}).pipe(ae(e=>((...e)=>{let t=new Map;for(let r=0;r<e.length;r++)e[r].mapUnsafe.forEach((e,r)=>{t.set(r,e)});return n1(t)})(...e)))},lO=(...e)=>lp((t,r)=>l$(e,t,r)),lI=(e,t,r)=>lp((n,i)=>s8(Array.isArray(t)?l$(t,n,i):t.build(n,i),t=>e.build(n,i).pipe(ad(t),ae(e=>r(e,t))))),lC=el(2,(e,t)=>lI(e,t,ec)),lE=el(2,(e,t)=>lI(e,t,(e,t)=>is(t,e))),lA=el(e=>tk(e[0]),(e,t,r)=>{let n;return n3(t)?ad(e,t):(n=Array.isArray(t)?lO(...t):t,aG(t=>s8(r?.local?lb(n,lg(),t):lv(n,t),t=>ad(e,t))))}),lT=((e,t,r)=>s8(o6(t),t=>{let n=o2.defaultValue();return ab(ap(s3(s8(sP(()=>af(e,o2,n)),t),e=>sL(()=>{n=e})),{disableYield:!0}),e=>eT(e,t0)?sj(e.value):r(e,0===n.attempt?rx():rk(n)))}),el(3,(e,t,r)=>s8(o6(t),t=>{let n,i=o2.defaultValue(),s=ab(sP(()=>af(e,o2,i)),e=>(n=e,s8(t(e),e=>(i=e,s))));return oG(s,e=>tu(()=>r(n,e)))}))),lM=el(2,(e,t)=>lT(e,"function"==typeof t?t(ec):eT(t,o1)?t:lj(t),tJ)),lN=o9(lr),lj=e=>{let t=e.schedule?o9(e.schedule):lN;return e.while&&(t=lt(t,({input:t})=>{let r=e.while(t);return tk(r)?r:sj(r)})),e.until&&(t=lt(t,({input:t})=>{let r=e.until(t);return tk(r)?ae(r,e=>!e):sj(!r)})),void 0!==e.times&&(t=lt(t,({attempt:t})=>sj(t<=e.times))),t},lF=lt(lr,({attempt:e})=>sj(e<=1)),lL=(X={_E:e=>e,_A:e=>e,_R:e=>e},eb.add(X),X);({...{[ej](){return eq(this,Object.keys(this))},[eQ](e){let t=Object.keys(this),r=Object.keys(e);if(t.length!==r.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==r[n]||!eZ(this[t[n]],e[t[n]]))return!1;return!0}},"~effect/Request":lL});let lP=e=>{let t="function"==typeof e?e:e.try,r="function"==typeof e?e=>new oL(e,"An error occurred in Effect.tryPromise"):e.catch;return sV(function(e,n){let i=t=>{try{e(tJ(tu(()=>r(t))))}catch(t){e(sB(t))}};try{tu(()=>t(n)).then(t=>e(sj(t)),i)}catch(e){i(e)}},0!==t.length)},lD=sj,lR=(...e)=>sP(()=>s0(1===e.length?e[0]():e[1].call(e[0].self))),lU=e=>sP(()=>sF(tu(e))),lB=e=>aM(e,{onFailure:rx,onSuccess:rk}),lq=e=>ab(e,sB),lK=e=>tY(t=>{let r=t.context,n=aJ();return t.setContext(n8(t.context,aR,n)),aH(e,e=>(t.setContext(r),aB(n,e)))}),lz=(e,t,r)=>au(n=>a6(i=>s8(aR,s=>s3(r?.interruptible?i(e):e,e=>aK(s,r=>ad(t(e,r),n)))))),lV=(e,t,r)=>a6(n=>s8(e,e=>aH(n(t(e)),t=>r(e,t),!0))),lJ=function(){let e="string"!=typeof arguments[0],t=e?arguments[1]:arguments[0],r=si(arguments[2]);if(e){let e=arguments[0];return ob(t,arguments[2],t=>ow(e,t,r))}let n="function"==typeof arguments[1]?arguments[1]:void 0,i=n?void 0:arguments[1];return(e,...s)=>ob(t,n?n(...s):i,t=>ow(e,t,r))},lW=function(){let e="string"==typeof arguments[0],t=e?arguments[0]:"Effect.fn",r=e?arguments[1]:void 0,n=Error.stackTraceLimit;nG(2);let i=new globalThis.Error;return(nG(n),e)?(n,...s)=>sZ(t,n,i,s,e,r):sZ(t,arguments[0],i,Array.prototype.slice.call(arguments,1),e,r)},lY=oz("Error"),lG=el(e=>tk(e[0]),(e,...t)=>ac(e,se,e=>{let r={...e};return 1===t.length?Object.assign(r,t[0]):r[t[0]]=t[1],r})),lH=(e,t,r)=>(...n)=>sW(i=>{try{e(...n,(e,r)=>{e?i(tJ(t?t(e,n):e)):i(lD(r))})}catch(e){i(r?tJ(r(e,n)):sB(e))}}),lQ=(e,...t)=>sH(e.length,0===t.length?function(){return sX(()=>e.apply(this,arguments))}:function(){let r=sX(()=>e.apply(this,arguments));for(let e of t)r=e(r);return r}),lZ=(e,t)=>t("Success"===e._tag?0:oW(e.cause)?130:l0(sh(e.cause))),lX="~effect/Runtime/errorExitCode",l0=e=>{if("object"==typeof e&&null!==e&&lX in e){let t=e[lX];if("number"==typeof t)return t}return 1},l1="~effect/Runtime/errorReported",l2=(u=({fiber:e,teardown:t})=>{let r=!1;function n(){r=!0,e.interruptUnsafe(e.id)}e.addObserver(e=>{process.removeListener("SIGINT",n),process.removeListener("SIGTERM",n),t(e,e=>{(r||0!==e)&&process.exit(e)})}),process.on("SIGINT",n),process.on("SIGTERM",n)},el(e=>tk(e[0]),(e,t)=>{let r=oc(t?.disableErrorReporting===!0?e:av(e,e=>oW(e)?sK:(e=>{if("object"==typeof e&&null!==e&&l1 in e){let t=e[l1];if("boolean"==typeof t)return t}return!0})(sh(e))?lY(e):sK));try{let e=globalThis.setInterval(ep,0x7fffffff);r.addObserver(()=>{clearInterval(e)})}catch{}return u({fiber:r,teardown:t?.teardown??lZ})}));function l3(){return Object.assign(e=>e,{option:e=>rk(e),result:e=>rp(e),is:e=>!0})}let l5=class extends eo{constructor(e){super(),e&&Object.assign(this,e)}};function l4(){if(1==arguments.length){let e=arguments[0];return function(t){return e[t._tag](t)}}let e=arguments[0],t=arguments[1];return t[e._tag](e)}let l8=tH,l6=tQ,l9="~effect/platform/PlatformError";class l7 extends l6("BadArgument"){get message(){return`${this.module}.${this.method}${this.description?`: ${this.description}`:""}`}}class ce extends l8{get message(){return`${this._tag}: ${this.module}.${this.method}${void 0!==this.pathOrDescriptor?` (${this.pathOrDescriptor})`:""}${this.description?`: ${this.description}`:""}`}}class ct extends l6("PlatformError"){constructor(e){"cause"in e?super({reason:e,cause:e.cause}):super({reason:e})}[l9]=l9;get message(){return this.reason.message}}let cr=e=>new ct(new ce(e)),cn=e=>new ct(new l7(e)),ci=Symbol.for("effect/MutableList/Empty"),cs=()=>({array:[],mutable:!0,offset:0,next:void 0}),ca=(e,t)=>{e.tail?e.tail.mutable||(e.tail.next=cs(),e.tail=e.tail.next):e.head=e.tail=cs(),e.tail.array.push(t),e.length++},co=e=>{e.head=e.tail=void 0,e.length=0},cl=e=>{if(!e.head)return ci;let t=e.head.array[e.head.offset];return e.head.mutable&&(e.head.array[e.head.offset]=void 0),e.head.offset++,e.length--,e.head.offset===e.head.array.length&&(e.head.next?e.head=e.head.next:co(e)),t},cc={_A:ec,_E:ec},cu={"~effect/Queue":cc,"~effect/Queue/Enqueue":cc,"~effect/Queue/Dequeue":cc,...tw,toJSON(){return{_id:"effect/Queue",state:this.state._tag,size:ck(this)}}},cd=e=>tY(t=>{let r=Object.create(cu);return r.dispatcher=t.currentDispatcher,r.capacity=e?.capacity??1/0,r.strategy=e?.strategy??"suspend",r.messages={head:void 0,tail:void 0,length:0},r.scheduleRunning=!1,r.state={_tag:"Open",takers:new Set,offers:new Set,awaiters:new Set},sj(r)}),cf=(e,t)=>sP(()=>{if("Open"!==e.state._tag)return cS;if(e.messages.length>=e.capacity)switch(e.strategy){case"dropping":return cS;case"suspend":if(e.capacity<=0&&e.state.takers.size>0)return ca(e.messages,t),cI(e),c_;return cA(e,t);case"sliding":return cl(e.messages),ca(e.messages,t),c_}return ca(e.messages,t),cC(e),c_}),ch=(e,t)=>"Open"===e.state._tag&&(e.messages.length>=e.capacity?"sliding"===e.strategy?(cl(e.messages),ca(e.messages,t),!0):e.capacity<=0&&e.state.takers.size>0&&(ca(e.messages,t),cI(e),!0):(ca(e.messages,t),cC(e),!0)),cp=el(2,(e,t)=>sL(()=>cm(e,t))),cm=(e,t)=>{if("Open"!==e.state._tag)return!1;let r=ao(tV(t),c$);return 0===e.state.offers.size&&0===e.messages.length?cN(e,r):e.state={...e.state,_tag:"Closing",exit:r},!0},cg=e=>cm(e,tN(t2())),cy=e=>sL(()=>{if("Done"===e.state._tag)return!0;co(e.messages);let t=e.state.offers;if(cN(e,"Open"===e.state._tag?cO:e.state.exit),t.size>0){for(let e of t)"Single"===e._tag?e.resume(cS):e.resume(tK(e.remaining.slice(e.offset)));t.clear()}return!0}),cb=e=>cv(e,1,1/0),cv=(e,t,r)=>sP(()=>cE(e,t,r)??s2(cM(e),cv(e,1,r))),cw=e=>sP(()=>cx(e)??s2(cM(e),cw(e))),cx=e=>{if("Done"===e.state._tag)return e.state.exit;if(e.messages.length>0){let t=cl(e.messages);return cT(e),tK(t)}if(e.capacity<=0&&e.state.offers.size>0){e.capacity=1,cT(e),e.capacity=0;let t=cl(e.messages);return cT(e),tK(t)}},ck=e=>"Done"===e.state._tag?0:e.messages.length,cS=tK(!1),c_=tK(!0),c$=tJ(t2()),cO=tV(sl(void 0)),cI=e=>{if(e.scheduleRunning=!1,"Done"!==e.state._tag&&0!==e.state.takers.size){for(let t of e.state.takers)if(e.state.takers.delete(t),t(ai),0===e.messages.length)break}},cC=e=>{e.scheduleRunning||"Done"===e.state._tag||0===e.state.takers.size||(e.scheduleRunning=!0,e.dispatcher.scheduleTask(()=>cI(e),0))},cE=(e,t,r)=>{if("Done"===e.state._tag)return e.state.exit;if(r<=0||t<=0)return tK([]);if(e.capacity<=0&&e.state.offers.size>0){e.capacity=1,cT(e),e.capacity=0;let t=[cl(e.messages)];return cT(e),tK(t)}if((t=Math.min(t,e.capacity||1))<=e.messages.length){let t=((e,t)=>{if(t<=0||!e.head)return[];if((t=Math.min(t,e.length))===e.length&&e.head?.offset===0&&!e.head.next){let t=e.head.array;return co(e),t}let r=Array(t),n=0,i=e.head;for(;i;){for(;i.offset<i.array.length;)if(r[n++]=i.array[i.offset],i.mutable&&(i.array[i.offset]=void 0),i.offset++,n===t)return e.head=i,e.length-=t,0===e.length&&co(e),r;i=i.next}return co(e),r})(e.messages,r);return cT(e),tK(t)}},cA=(e,t)=>sW(r=>{if("Open"!==e.state._tag)return r(cS);let n={_tag:"Single",message:t,resume:r};return e.state.offers.add(n),sL(()=>{"Open"===e.state._tag&&e.state.offers.delete(n)})}),cT=e=>{if("Done"===e.state._tag)return e.state.exit.cause.reasons.some(oH);if(0===e.state.offers.size)return"Closing"===e.state._tag&&0===e.messages.length&&(cN(e,e.state.exit),e.state.exit.cause.reasons.some(oH));let t=e.capacity-e.messages.length;for(let r of e.state.offers)if(0===t)break;else if("Single"===r._tag)ca(e.messages,r.message),t--,r.resume(c_),e.state.offers.delete(r);else{for(;r.offset<r.remaining.length;r.offset++){if(0===t)return!1;ca(e.messages,r.remaining[r.offset]),t--}r.resume(tK([])),e.state.offers.delete(r)}return!1},cM=e=>sW(t=>"Done"===e.state._tag?t(e.state.exit):(e.state.takers.add(t),sL(()=>{"Done"!==e.state._tag&&e.state.takers.delete(t)}))),cN=(e,t)=>{if("Done"===e.state._tag)return;let r=e.state;for(let n of(e.state={_tag:"Done",exit:t},r.takers))n(t);for(let e of(r.takers.clear(),r.awaiters))e(t);r.awaiters.clear()},cj="~effect/Channel",cF={[cj]:{_Env:ec,_InErr:ec,_InElem:ec,_OutErr:ec,_OutElem:ec},pipe(){return es(this,arguments)}},cL=e=>{let t=Object.create(cF);return t.transform=(t,r)=>am(e(t,r),e=>lD(sF(e))),t},cP=(e,t)=>cL((r,n)=>s8(cR(e)(r,n),e=>t(e,n))),cD=e=>cL((t,r)=>e),cR=e=>e.transform,cU=cD(lD(oY())),cB=el(2,(e,t)=>cP(e,e=>sL(()=>{let r=0;return ae(e,e=>t(e,r++))}))),cq=el(2,(e,t)=>cK(e,e=>lD(t(e)))),cK=el(2,(e,t)=>cP(e,e=>lD(oG(e,e=>s8(t(e),oY))))),cz=el(e=>eT(e[0],cj)&&eT(e[1],cj),(e,t,r)=>{let n;return n=sG(function*(n,i,s){let a=r?.haltStrategy??"both",o=yield*cd({capacity:0});yield*aK(s,eu(cy(o)));let l=0,c=(e,t,r)=>cR(t)(n,r).pipe(s8(e=>e.pipe(s8(e=>cf(o,e)),ap)),a0(t=>s2(aU(r,oX(t)),function(e,t){if(l++,!t.reasons.some(oH))return cp(o,t);switch(a){case"both":return 2===l?cp(o,t):sK;case"left":case"right":return e===a?cp(o,t):sK;case"either":return cp(o,t)}}(e,t))),os(s));return yield*c("left",e,lu(s)),yield*c("right",t,lu(s)),cw(o)}),cL(sG(function*(e,t){let r=lu(t),i=e=>aU(r,oX(e)),s=yield*a0(n(e,t,r),i);return a0(s,i)}))}),cV=el(2,(e,t)=>cL((r,n)=>s8(cR(e)(r,n),e=>cR(t)(e,n)))),cJ=e=>cL((t,r)=>{let n;return lD(sP(()=>n||e.pipe(aY(r),s8(e=>cR(e)(t,r)),s8(e=>n=e))))}),cW=(e,t,r)=>sP(()=>{let n=aJ();return oG(s8(cR(e)(oY(),n),t),r||lD).pipe(aQ(e=>aU(n,e)))}),cY=el(2,(e,t)=>cW(e,e=>ap(s8(e,t),{disableYield:!0}))),cG=el(3,(e,t,r)=>sP(()=>{let n=t();return cW(e,e=>a7({while:ed,body:()=>e,step:e=>{n=r(n,e)}}),()=>lD(n))})),cH=(e,t)=>cR(e)(oY(),t),cQ="~effect/Sink",cZ=lD([void 0]),cX={[cQ]:{_A:ec,_In:ec,_L:ec,_E:ec,_R:ec},pipe(){return es(this,arguments)}},c0=e=>c1((t,r)=>cR(e)(t,r).pipe(s8(ap({disableYield:!0})),oG(lD))),c1=e=>{let t=Object.create(cX);return t.transform=e,t},c2=e=>cL((t,r)=>lD(s8(e.transform(t,r),oY))),c3=c1(e=>oG(ap(e,{disableYield:!0}),()=>cZ)),c5=e=>c0(cJ(ae(e,c2))),c4={"~effect/Stream":{_R:ec,_E:ec,_A:ec},pipe(){return es(this,arguments)}},c8=e=>{let t=Object.create(c4);return t.channel=e,t},c6=e=>e.channel,c9=c8(cU),c7=e=>{let t;return c8((t=()=>e().channel,cL((e,r)=>sP(()=>cR(t())(e,r)))))},ue=e=>{let t;return nA(e)?c8((t=lD(e),cD(sL(()=>{let e=!1;return sP(()=>e?oY():(e=!0,t))})))):c9},ut=e=>c8(cJ(ae(e,c6))),ur=el(2,(e,t)=>c7(()=>{let r=0;return c8(cB(e.channel,nR(e=>t(e,r++))))})),un=el(e=>eT(e[0],"~effect/Stream")&&eT(e[1],"~effect/Stream"),(e,t,r)=>c8(cz(c6(e),c6(t),r))),ui=el(2,(e,t)=>{let r;return r=(e,r)=>sL(()=>{let n,i,s=sP(()=>{if(void 0!==i){let e=i;return i=void 0,lD(e)}return e}).pipe(ab(e=>(n=tJ(e),oY()))),a=ae(sP(()=>t.transform(s,r)),([e,t])=>(i=t,nD(e)));return sP(()=>n||a)}),c8(cL((t,n)=>s8(cH(e.channel,n),e=>r(e,n))))}),us=el(e=>eT(e[0],"~effect/Stream"),(e,t)=>c7(()=>{let r=new TextDecoder(t?.encoding);return ur(e,e=>r.decode(e,{stream:!0}))})),ua=el(2,(e,t)=>aG(r=>cH(e.channel,r).pipe(s8(e=>t.transform(e,r)),ae(([e])=>e)))),uo=e=>cG(e.channel,()=>[],(e,t)=>{for(let r=0;r<t.length;r++)e.push(t[r]);return e}),ul=((e,t)=>cY(e.channel,t),"~effect/platform/FileSystem"),uc=e=>"bigint"==typeof e?e:BigInt(e),uu=nQ("effect/platform/FileSystem"),ud="~effect/platform/FileSystem/File",uf=l3();class uh extends nQ()("effect/platform/FileSystem/WatchBackend"){}let up="~effect/platform/Path",um=nQ("effect/Path"),ug=l3(),uy=l3(),ub="~effect/ChildProcessSpawner/ChildProcessHandle",uv={[ub]:ub,...{toJSON(){return tl(this)},[to](){return this.toJSON()},toString(){return tr(this.toJSON())}},toJSON(){return{_id:"ChildProcessHandle",pid:this.pid}}},uw=e=>Object.assign(Object.create(uv),e);class ux extends nQ()("effect/process/ChildProcessSpawner"){}let uk="~effect/unstable/process/ChildProcess",uS={...nz({label:"Command",evaluate(e){return n9(e.context,ux).spawn(this)}}),[uk]:uk},u_=(e,t,r)=>Object.assign(Object.create(uS),{_tag:"StandardCommand",command:e,args:t,options:r}),u$=function(...e){if(uO(e[0])){let[t,...r]=e,n=uE(t,r);return u_(n[0]??"",n.slice(1),{})}if("object"==typeof e[0]&&!Array.isArray(e[0])&&!uO(e[0])){let t=e[0];return function(e,...r){let n=uE(e,r);return u_(n[0]??"",n.slice(1),t)}}if("string"==typeof e[0]&&!Array.isArray(e[1])){let[t,r={}]=e;return u_(t,[],r)}let[t,r=[],n={}]=e;return u_(t,r,n)},uO=e=>Array.isArray(e)&&"raw"in e&&Array.isArray(e.raw),uI=e=>{let t=/^fd(\d+)$/.exec(e);if(null===t)return;let r=parseInt(t[1],10);return r>=3?r:void 0},uC=e=>`fd${e}`,uE=(e,t)=>{let r=[];for(let[n,i]of e.entries())r=uA(e,t,r,i,n);return r},uA=(e,t,r,n,i)=>{let s=e.raw[i];if(void 0===s)throw Error(`Invalid backslash sequence: ${e.raw[i]}`);let{hasLeadingWhitespace:a,hasTrailingWhitespace:o,tokens:l}=uj(n,s),c=uF(r,l,a);if(i===t.length)return c;let u=t[i];return uF(c,Array.isArray(u)?u.map(e=>uT(e)):[uT(u)],o)},uT=e=>"string"==typeof e?e:String(e),uM=new Set([" "," ","\r","\n"]),uN={x:3,u:5},uj=(e,t)=>{if(0===t.length)return{tokens:[],hasLeadingWhitespace:!1,hasTrailingWhitespace:!1};let r=uM.has(t[0]),n=[],i=0;for(let r=0,s=0;r<e.length;r+=1,s+=1){let a=t[s];if(uM.has(a))i!==r&&n.push(e.slice(i,r)),i=r+1;else if("\\"===a){let e=t[s+1];"\n"===e?(r-=1,s+=1):"u"===e&&"{"===t[s+2]?s=t.indexOf("}",s+3):s+=uN[e]??1}}let s=i===e.length;return s||n.push(e.slice(i)),{tokens:n,hasLeadingWhitespace:r,hasTrailingWhitespace:s}},uF=(e,t,r)=>r||0===e.length||0===t.length?[...e,...t]:[...e.slice(0,-1),`${e.at(-1)}${t.at(0)}`,...t.slice(1)],uL=t("node:child_process"),uP=t("node:stream"),uD=(e,t)=>(r,[n])=>{let i="Unknown";switch(r.code){case"ENOENT":i="NotFound";break;case"EACCES":i="PermissionDenied";break;case"EEXIST":i="AlreadyExists";break;case"EISDIR":case"ENOTDIR":case"ELOOP":i="BadResource";break;case"EBUSY":i="Busy"}return cr({_tag:i,module:e,method:t,pathOrDescriptor:n,syscall:r.syscall,cause:r})},uR=e=>c0(cq(uU(e),e=>[e])),uU=e=>cL(t=>{let r=e.evaluate();return lD(uB({...e,writable:r,pull:t}))}),uB=e=>e.pull.pipe(s8(t=>{let r=0;return sW(function n(i){for(;r<t.length;)if(!e.writable.write(t[r++],e.encoding))return void e.writable.once("drain",()=>n(i));i(sK)})}),ap({disableYield:!0}),s4(sW(t=>{let r=r=>t(tJ(e.onError(r)));return e.writable.once("error",r),sL(()=>{e.writable.off("error",r)})})),!1!==e.endOnDone?oG(t=>"closed"in e.writable&&e.writable.closed?oY(t):sW(r=>{e.writable.once("finish",()=>r(oY(t))),e.writable.end()})):ec),uq="~effect/MutableRef",uK={[uq]:uq,...tw,toJSON(){return{_id:"MutableRef",current:tl(this.current)}}},uz=e=>c8(uV(e)),uV=e=>cL((t,r)=>uJ({scope:r,readable:e.evaluate(),onError:e.onError??uW,chunkSize:e.chunkSize,closeOnDone:e.closeOnDone})),uJ=e=>{var t;let r,n=e.readable,i=e.closeOnDone??!0,s=e.exit??(t=void 0,(r=Object.create(uK)).current=t,r),a=op(!1);function o(){a.openUnsafe()}function l(t){s.current=tJ(e.onError(t)),a.openUnsafe()}function c(){s.current=tJ(t2()),a.openUnsafe()}n.on("readable",o),n.once("error",l),n.once("end",c);let u=sP(function t(){let r=e.readable.read(e.chunkSize);if(null===r)return s.current?s.current:n.readableEnded?tJ(t2()):(a.closeUnsafe(),s8(a.await,t));let i=nD(r);for(;null!==(r=e.readable.read(e.chunkSize));)i.push(r);return lD(i)});return s1(aK(e.scope,eu(sL(()=>{n.off("readable",o),n.off("error",l),n.off("end",c),i&&"closed"in e.readable&&!e.readable.closed&&e.readable.destroy()}))),u)};uP.Readable;let uW=e=>new oL(e),uY=e=>e instanceof globalThis.Error?e:new globalThis.Error(String(e)),uG=(e,t,r)=>{let{commands:n}=uZ(r),i=n.reduce((e,t)=>{let r=`${t.command} ${t.args.join(" ")}`;return 0===e.length?r:`${e} | ${r}`},"");return uD("ChildProcess",e)(t,[i])},uH=lR(function*(){let e,t,r=yield*uu,n=yield*um,i=sG(function*(e){if(!e$(e.cwd))return yield*r.access(e.cwd),n.resolve(e.cwd)}),s=e=>eT(e,cQ)?"pipe":e,a=e=>{let t={stream:"pipe",encoding:"utf-8",endOnDone:!0};return e$(e.stdin)?t:"string"==typeof e.stdin?{...t,stream:e.stdin}:eT(e.stdin,"~effect/Stream")?{...t,stream:e.stdin}:{stream:e.stdin.stream,encoding:e.stdin.encoding??t.encoding,endOnDone:e.stdin.endOnDone??t.endOnDone}},o=(e,t)=>{let r=e[t];return e$(r)?{stream:"pipe"}:"string"==typeof r?{stream:r}:eT(r,cQ)?{stream:r}:{stream:r.stream}},l=sG(function*(e,t,r){if(0===r.length)return{getInputFd:()=>c3,getOutputFd:()=>c9};let n=new Map,i=new Map;for(let{config:s,fd:a}of r){let r=t.stdio[a];switch(s.type){case"input":{let t=c3;r&&"write"in r&&(t=uR({evaluate:()=>r,onError:t=>uG(`fromWritable(fd${a})`,uY(t),e)})),s.stream&&(yield*oa(ua(s.stream,t))),n.set(a,t);break}case"output":{let t=c9;if(r&&"read"in r){let n=new uP.PassThrough;r.on("error",e=>n.destroy(e)),r.pipe(n),t=uz({evaluate:()=>n,onError:t=>uG(`fromReadable(fd${a})`,uY(t),e)})}s.sink&&(t=ui(t,s.sink)),i.set(a,t)}}}return{getInputFd:e=>n.get(e)??c3,getOutputFd:e=>i.get(e)??c9}}),c=(e,t,r)=>"win32"===globalThis.process.platform?sW(r=>{uL.exec(`taskkill /pid ${t.pid} /T /F`,t=>{t?r(tJ(uG("kill",uY(t),e))):r(sK)})}):sz({try:()=>{globalThis.process.kill(-t.pid,r)},catch:t=>uG("kill",uY(t),e)}),u=(e,t,r)=>sP(()=>t.kill(r)?sK:tJ(uG("kill",new globalThis.Error("Failed to kill child process"),e))),d=(e,t,r)=>n=>{let i=r?.killSignal??"SIGTERM";return e$(r?.forceKillAfter)?n(t,e,i):aL(n(t,e,i),{duration:r.forceKillAfter,orElse:()=>n(t,e,"SIGKILL")})},f=(e,t)=>{let r=t??"stdout";switch(r){case"stdout":return e.stdout;case"stderr":return e.stderr;case"all":return e.all;default:{let t=uI(r);if(eO(t))return e.getOutputFd(t);return e.stdout}}},h=sG(function*(e){switch(e._tag){case"StandardCommand":{var t,r,n,p;let f,h,m,g,y,b,v,w=a(e.options),x=o(e.options,"stdout"),k=o(e.options,"stderr"),S=(e=>{if(e$(e.additionalFds))return[];let t=[];for(let[r,n]of Object.entries(e.additionalFds)){let e=uI(r);eO(e)&&t.push({fd:e,config:n})}return t.sort((e,t)=>e.fd-t.fd)})(e.options),_=!0,$=yield*i(e.options),O=(b=e.options).extendEnv?{...globalThis.process.env,...b.env}:b.env,I=((e,t,r,n)=>{let i,a=[eT(i=e.stream,"~effect/Stream")?"pipe":i,s(t.stream),s(r.stream)];if(0===n.length)return a;let o=n.reduce((e,{fd:t})=>Math.max(e,t),2);for(let e=3;e<=o;e++)a[e]="ignore";for(let{fd:e}of n)a[e]="pipe";return a})(w,x,k,S),[C,E]=yield*lz((v={cwd:$,env:O,stdio:I,detached:e.options.detached??"win32"!==process.platform,shell:e.options.shell},sW(t=>{let r=li(),n=uL.spawn(e.command,e.args,v);return n.on("error",r=>{t(tJ(uG("spawn",r,e)))}),n.on("exit",(...e)=>{lc(r,tK(e))}),n.on("spawn",()=>{t(lD([n,r]))}),sL(()=>{n.kill("SIGTERM")})})),sG(function*([t,r]){let n=yield*lo(r),i=d(t,e,e.options);if(n){let[e]=yield*ls(r);return 0!==e&&eI(e)?yield*aI(i(c)):yield*sK}return _?yield*i((e,t,n)=>c(e,t,n).pipe(ab(()=>u(e,t,n)),s2(ls(r)))).pipe(aI):yield*sK})),A=uy(C.pid);C.on("exit",t=>{0!==t&&eI(t)&&((e,t)=>{if("win32"===globalThis.process.platform)return uL.exec(`taskkill /pid ${e.pid} /T /F`,()=>{});try{globalThis.process.kill(-e.pid,t)}catch{}})(C,e.options.killSignal??"SIGTERM")});let T=sL(()=>{_||(C.ref(),_=!0)}),M=sL(()=>(_&&(C.unref(),_=!1),T)),N=yield*sP(()=>{let t=c3;return eI(C.stdin)&&(t=uR({evaluate:()=>C.stdin,onError:t=>uG("fromWritable(stdin)",uY(t),e),endOnDone:w.endOnDone,encoding:w.encoding})),eT(w.stream,"~effect/Stream")?s1(oa(ua(w.stream,t)),t):lD(t)}),{all:j,stderr:F,stdout:L}=(t=e,r=C,n=x,p=k,m=r.stdout?(f=new uP.PassThrough,r.stdout.on("error",e=>f.destroy(e)),r.stdout.pipe(f),uz({evaluate:()=>f,onError:e=>uG("fromReadable(stdout)",uY(e),t)})):c9,g=r.stderr?(h=new uP.PassThrough,r.stderr.on("error",e=>h.destroy(e)),r.stderr.pipe(h),uz({evaluate:()=>h,onError:e=>uG("fromReadable(stderr)",uY(e),t)})):c9,eT(n.stream,cQ)&&(m=ui(m,n.stream)),eT(p.stream,cQ)&&(g=ui(g,p.stream)),y=un(m,g),{stdout:m,stderr:g,all:y}),{getInputFd:P,getOutputFd:D}=yield*l(e,C,S),R=ae(lo(E),e=>!e);return uw({pid:A,exitCode:s8(ls(E),([t,r])=>eI(t)?lD(ug(t)):tJ(uG("exitCode",new globalThis.Error(`Process interrupted due to receipt of signal: '${r}'`),e))),isRunning:R,kill:t=>d(C,e,t)((e,t,r)=>c(e,t,r).pipe(ab(()=>u(e,t,r)),s2(ls(E)))).pipe(s5),stdin:N,stdout:L,stderr:F,all:j,getInputFd:P,getOutputFd:D,unref:M})}case"PipedCommand":{let{commands:t,pipeOptions:r}=uZ(e),[n,...i]=t,s=[(yield*h(n))];for(let e=0;e<i.length;e++){let t=i[e],n=r[e]??{},o=a(t.options),l=ut(lD(f(s[s.length-1],n.from))),c=n.to??"stdin";if("stdin"===c)s.push((yield*h(u$(t.command,t.args,{...t.options,stdin:{...o,stream:l}}))));else{let e=uI(c);if(eO(e)){let r=uC(e),n=t.options.additionalFds??{};s.push((yield*h(u$(t.command,t.args,{...t.options,additionalFds:{...n,[r]:{type:"input",stream:l}}}))))}else s.push((yield*h(u$(t.command,t.args,{...t.options,stdin:{...o,stream:l}}))))}}let o=s[s.length-1],l=lR(function*(){let e=[];for(let t of s)e.push((yield*t.unref));return oe([...e].reverse(),e=>e,{discard:!0})});return uw({pid:o.pid,exitCode:o.exitCode,isRunning:o.isRunning,kill:o.kill,stdin:o.stdin,stdout:o.stdout,stderr:o.stderr,all:o.all,getInputFd:o.getInputFd,getOutputFd:o.getOutputFd,unref:l})}}});return e=(e,t)=>h(e).pipe(ae(e=>us(t?.includeStderr===!0?e.all:e.stdout)),ut),t=(t,r)=>e(t,r).channel.pipe(cV(cL((e,t)=>sL(()=>{let t="",r=!1,n=rx(),i=sP(()=>"Some"===n._tag?oY(n.value):o0(e,{onSuccess:s,onFailure:sF,onDone:e=>{if(n=rk(e),t.length>0||r){let e=t;return t="",r=!1,lD([e])}return oY(e)}}));function s(e){let n=function(e){let n=[];function i(e){0===t.length?n.push(e):(n.push(t+e),t="")}for(let n=0;n<e.length;n++){let s=e[n];if(0!==s.length){let e=0,n=s.indexOf("\r"),a=s.indexOf("\n");for(r&&(0===a?(i(""),e=1,a=s.indexOf("\n",e)):i(""),r=!1);-1!==n||-1!==a;)-1===n||-1!==a&&a<n?(i(s.substring(e,a)),e=a+1,a=s.indexOf("\n",e)):s.length===n+1?(r=!0,n=-1):(i(s.substring(e,n)),e=n+(a===n+1?2:1),n=s.indexOf("\r",e),a=s.indexOf("\n",e));t+=s.substring(e,s.length-!!r)}}return nA(n)?n:null}(e);return null!==n?lD(n):i}return i}))),c8),ux.of({spawn:h,exitCode:e=>lK(s8(h(e),e=>e.exitCode)),streamString:e,streamLines:t,lines:(e,r)=>uo(t(e,r)),string:(t,r)=>cG(e(t,r).channel,()=>"",(e,t)=>e+t.join(""))})}),uQ=lk(ux,uH),uZ=e=>{let t=[],r=[],n=e=>{switch(e._tag){case"StandardCommand":t.push(e);break;case"PipedCommand":n(e.left),r.push(e.options),n(e.right)}};if(n(e),0===t.length)throw Error("flattenCommand produced empty commands array");let[i,...s]=t;return{commands:[i,...s],pipeOptions:r}},uX="~effect/platform/Crypto",u0=nQ("effect/Crypto"),u1=e=>e.toString(16).padStart(2,"0"),u2=e=>[e.subarray(0,4),e.subarray(4,6),e.subarray(6,8),e.subarray(8,10),e.subarray(10,16)].map(e=>Array.from(e,u1).join("")).join("-"),u3=0x1000000000000-1,u5=t("node:crypto"),u4=(d=(ee={randomBytes:u5.randomBytes,digest:(e,t)=>sz({try:()=>Uint8Array.from(u5.createHash((e=>{switch(e){case"SHA-1":return"sha1";case"SHA-256":return"sha256";case"SHA-384":return"sha384";case"SHA-512":return"sha512"}})(e)).update(t).digest()),catch:e=>cr({module:"Crypto",method:"digest",_tag:"Unknown",description:"Could not compute digest",cause:e})})}).randomBytes,f=()=>{let e=d(7);return((31&e[0])*0x1000000000000+0x10000000000*e[1]+0x100000000*e[2]+0x1000000*e[3]+65536*e[4]+256*e[5]+e[6])/0x20000000000000},h=()=>Math.floor(f()*(Number.MAX_SAFE_INTEGER-Number.MIN_SAFE_INTEGER+1))+Number.MIN_SAFE_INTEGER,u0.of({[uX]:uX,randomBytes:e=>{let t,r;return ae((t="randomBytes",Number.isSafeInteger(r=e)&&r>=0?lD(r):tJ(cn({module:"Crypto",method:t,description:"size must be a non-negative safe integer"}))),d)},nextDoubleUnsafe:f,nextIntUnsafe:h,digest:ee.digest,random:sL(()=>f()),randomBoolean:sL(()=>f()>.5),randomInt:sL(()=>h()),randomBetween:(e,t)=>sL(()=>f()*(t-e)+e),randomIntBetween(e,t,r){let n=+(r?.halfOpen!==!0);return sL(()=>{let r=Math.ceil(e),i=Math.floor(t);return Math.floor(f()*(i-r+n))+r})},randomShuffle:e=>sL(()=>{let t=Array.from(e);for(let e=t.length-1;e>=1;e-=1){let r=Math.min(e,Math.floor(f()*(e+1))),n=t[e];t[e]=t[r],t[r]=n}return t}),randomUUIDv4:sL(()=>{let e;return(e=d(16))[6]=15&e[6]|64,e[8]=63&e[8]|128,u2(e)}),randomUUIDv7:oC(e=>{var t,r;let n;return lD((t=e.currentTimeMillisUnsafe(),r=d(16),n=Math.min(Math.max(0,Math.trunc(t)),u3),r[0]=Math.floor(n/0x10000000000),r[1]=255&Math.floor(n/0x100000000),r[2]=255&Math.floor(n/0x1000000),r[3]=255&Math.floor(n/65536),r[4]=255&Math.floor(n/256),r[5]=255&n,r[6]=15&r[6]|112,r[8]=63&r[8]|128,u2(r)))})})),u8=lw(u0,u4),u6=t("node:fs"),u9=t("node:os"),u7=t("node:path");var de=a.t(u7,2);let dt=e=>t=>cn({module:"FileSystem",method:e,description:t.message??String(t)}),dr=(p=lH(u6.access,uD("FileSystem","access"),dt("access")),(e,t)=>{let r=u6.constants.F_OK;return t?.readable&&(r|=u6.constants.R_OK),t?.writable&&(r|=u6.constants.W_OK),p(e,r)}),dn=(m=lH(u6.cp,uD("FileSystem","copy"),dt("copy")),(e,t,r)=>m(e,t,{force:r?.overwrite??!1,preserveTimestamps:r?.preserveTimestamps??!1,recursive:!0})),di=(g=lH(u6.copyFile,uD("FileSystem","copyFile"),dt("copyFile")),(e,t)=>g(e,t)),ds=(y=lH(u6.chmod,uD("FileSystem","chmod"),dt("chmod")),(e,t)=>y(e,t)),da=(b=lH(u6.chown,uD("FileSystem","chown"),dt("chown")),(e,t,r)=>b(e,t,r)),dl=(v=lH(u6.glob,uD("FileSystem","glob"),dt("glob")),(e,t)=>v(e,{cwd:t?.root,exclude:t?.exclude})),dc=(w=lH(u6.link,uD("FileSystem","link"),dt("link")),(e,t)=>w(e,t)),du=(x=lH(u6.mkdir,uD("FileSystem","makeDirectory"),dt("makeDirectory")),(e,t)=>x(e,{recursive:t?.recursive??!1,mode:t?.mode})),dd=e=>{let t=lH(u6.mkdtemp,uD("FileSystem",e),dt(e));return e=>sP(()=>{let r=e?.prefix??"",n="string"==typeof e?.directory?u7.join(e.directory,"."):u9.tmpdir();return t(r?u7.join(n,r):n+"/")})},df=dd("makeTempDirectory"),dh=e=>{let t=lH(u6.rm,uD("FileSystem",e),dt(e));return(e,r)=>t(e,{recursive:r?.recursive??!1,force:r?.force??!1})},dp=dh("remove"),dm=(k=dd("makeTempDirectoryScoped"),S=dh("makeTempDirectoryScoped"),e=>lz(k(e),e=>lq(S(e,{recursive:!0})))),dg=(et="open",_=lH(u6.open,uD("FileSystem",et),dt(et)),$=lH(u6.close,uD("FileSystem",et),dt(et)),(e,t)=>em(lz(_(e,t?.flag??"r",t?.mode),e=>lq($(e))),ae(e=>dy(uf(e),t?.flag?.startsWith("a")??!1)))),dy=(()=>{let e=e=>lH(u6.read,uD("FileSystem",e),dt(e)),t=e("read"),r=e("readAlloc"),n=lH(u6.fstat,uD("FileSystem","stat"),dt("stat")),i=lH(u6.ftruncate,uD("FileSystem","truncate"),dt("truncate")),s=lH(u6.fsync,uD("FileSystem","sync"),dt("sync")),a=e=>lH(u6.write,uD("FileSystem",e),dt(e)),o=a("write"),l=a("writeAll");class c{[ud];fd;append;position=BigInt(0);constructor(e,t){this[ud]=ud,this.fd=e,this.append=t}get stat(){return ae(n(this.fd),dO)}get sync(){return s(this.fd)}seek(e,t){let r=uc(e);return sL(()=>("start"===t?this.position=r:"current"===t&&(this.position=this.position+r),this.position))}read(e){return sP(()=>{let r=this.position;return ae(t(this.fd,{buffer:e,position:r}),e=>{let t=uc(e);return this.position=r+t,t})})}readAlloc(e){let t=Number(e);return sP(()=>{let e=Buffer.allocUnsafeSlow(t),n=this.position;return ae(r(this.fd,{buffer:e,position:n}),r=>{if(0===r)return rx();if(this.position=n+BigInt(r),r===t)return rk(e);let i=Buffer.allocUnsafeSlow(r);return e.copy(i,0,0,r),rk(i)})})}truncate(e){return ae(i(this.fd,e?Number(e):void 0),()=>{if(!this.append){let t=BigInt(e??0);this.position>t&&(this.position=t)}})}write(e){return sP(()=>{let t=this.position;return ae(o(this.fd,e,void 0,void 0,this.append?void 0:Number(t)),e=>{let r=uc(e);return this.append||(this.position=t+r),r})})}writeAllChunk(e){return sP(()=>{let t=this.position;return s8(l(this.fd,e,void 0,void 0,this.append?void 0:Number(t)),r=>0===r?tJ(cr({module:"FileSystem",method:"writeAll",_tag:"WriteZero",pathOrDescriptor:this.fd,description:"write returned 0 bytes written"})):(this.append||(this.position=t+BigInt(r)),r<e.length?this.writeAllChunk(e.subarray(r)):sK))})}writeAll(e){return this.writeAllChunk(e)}}return(e,t)=>new c(e,t)})(),db=e=>{let t=dd(e);return sG(function*(e){let r=yield*t(e),n=u5.randomBytes(6).toString("hex"),i=u7.join(r,e?.suffix?`${n}${e.suffix}`:n);return yield*dT(i,new Uint8Array(0)),i})},dv=db("makeTempFile"),dw=(O=db("makeTempFileScoped"),I=dh("makeTempFileScoped"),e=>lz(O(e),e=>lq(I(u7.dirname(e),{recursive:!0})))),dx=(e,t)=>lP({try:()=>u6.promises.readdir(e,t),catch:t=>uD("FileSystem","readDirectory")(t,[e])}),dk=e=>sW((t,r)=>{try{u6.readFile(e,{signal:r},(r,n)=>{r?t(tJ(uD("FileSystem","readFile")(r,[e]))):t(lD(n))})}catch(e){t(tJ(dt("readFile")(e)))}}),dS=(C=lH(u6.readlink,uD("FileSystem","readLink"),dt("readLink")),e=>C(e)),d_=(E=lH(u6.realpath,uD("FileSystem","realPath"),dt("realPath")),e=>E(e)),d$=(A=lH(u6.rename,uD("FileSystem","rename"),dt("rename")),(e,t)=>A(e,t)),dO=e=>({type:e.isFile()?"File":e.isDirectory()?"Directory":e.isSymbolicLink()?"SymbolicLink":e.isBlockDevice()?"BlockDevice":e.isCharacterDevice()?"CharacterDevice":e.isFIFO()?"FIFO":e.isSocket()?"Socket":"Unknown",mtime:rL(e.mtime),atime:rL(e.atime),birthtime:rL(e.birthtime),dev:e.dev,rdev:rL(e.rdev),ino:rL(e.ino),mode:e.mode,nlink:rL(e.nlink),uid:rL(e.uid),gid:rL(e.gid),size:uc(e.size),blksize:void 0!==e.blksize?rk(uc(e.blksize)):rx(),blocks:rL(e.blocks)}),dI=(T=lH(u6.stat,uD("FileSystem","stat"),dt("stat")),e=>ae(T(e),dO)),dC=(M=lH(u6.symlink,uD("FileSystem","symlink"),dt("symlink")),(e,t)=>M(e,t)),dE=(N=lH(u6.truncate,uD("FileSystem","truncate"),dt("truncate")),(e,t)=>N(e,void 0!==t?Number(t):void 0)),dA=(j=lH(u6.utimes,uD("FileSystem","utime"),dt("utime")),(e,t,r)=>j(e,t,r)),dT=(e,t,r)=>sW((n,i)=>{try{u6.writeFile(e,t,{signal:i,flag:r?.flag,mode:r?.mode},t=>{t?n(tJ(uD("FileSystem","writeFile")(t,[e]))):n(sK)})}catch(e){n(tJ(dt("writeFile")(e)))}}),dM=ae(tY(e=>sj(ii(e.context,uh))),e=>{let t;return t={access:dr,chmod:ds,chown:da,copy:dn,copyFile:di,glob:dl,link:dc,makeDirectory:du,makeTempDirectory:df,makeTempDirectoryScoped:dm,makeTempFile:dv,makeTempFileScoped:dw,open:dg,readDirectory:dx,readFile:dk,readLink:dS,realPath:d_,remove:dp,rename:d$,stat:dI,symlink:dC,truncate:dE,utimes:dA,watch:t=>dI(t).pipe(ae(r=>e.pipe(rG(e=>e.register(t,r)),rT(()=>{var e;let r;return c8((r=e=>lz(sL(()=>{let r=u6.watch(t,{recursive:!0},(t,r)=>{if(r)switch(t){case"rename":return void oc(aT(dI(r),{onSuccess:t=>cf(e,{_tag:"Create",path:r}),onFailure:t=>cf(e,{_tag:"Remove",path:r})}));case"change":return void ch(e,{_tag:"Update",path:r})}});return r.on("error",r=>{cm(e,tN(cr({module:"FileSystem",_tag:"Unknown",method:"watch",pathOrDescriptor:t,cause:r})))}),r.on("close",()=>{cg(e)}),r}),e=>sL(()=>e.close())),cL((t,n)=>ae(cd({capacity:e?.bufferSize,strategy:e?.strategy}).pipe(s3(e=>aK(n,eu(cy(e)))),s3(e=>os(aY(r(e),n),n))),cb))))}))),ut),writeFile:dT},uu.of({...t,[ul]:ul,exists:e=>em(t.access(e),s1(!0),a_("PlatformError",e=>"NotFound"===e.reason._tag?lD(!1):tJ(e))),readFileString:(e,r)=>s8(t.readFile(e),e=>sz({try:()=>new TextDecoder(r).decode(e),catch:e=>cn({module:"FileSystem",method:"readFileString",description:"invalid encoding",cause:e})})),stream:sG(function*(e,r){let n=yield*t.open(e,{flag:"r"});r?.offset&&(yield*n.seek(r.offset,"start"));let i=r?.bytesToRead!==void 0?uc(r.bytesToRead):void 0,s=BigInt(0),a=uc(r?.chunkSize??65536),o=n.readAlloc(a);return c8(cD(lD(s8(sP(()=>void 0!==i&&i<=s?oY():void 0!==i&&i-s<a?n.readAlloc(i-s):o),rO({onNone:()=>oY(),onSome:e=>(s+=BigInt(e.length),lD(nD(e)))})))))},ut),sink:(e,r)=>em(t.open(e,{flag:"w",...r}),ae(e=>{let t,r;return t=t=>e.writeAll(t),r=oe(e=>t(e),{discard:!0}),c1(e=>e.pipe(s8(r),ap({disableYield:!0}),oG(()=>cZ)))}),c5),writeFileString:(e,r,n)=>s8(sz({try:()=>new TextEncoder().encode(r),catch:e=>cn({module:"FileSystem",method:"writeFileString",description:"could not encode string",cause:e})}),r=>t.writeFile(e,r,n))})}),dN=lk(uu)(dM),dj=t("node:url"),dF=e=>sz({try:()=>dj.fileURLToPath(e),catch:e=>new l7({module:"Path",method:"fromFileUrl",cause:e})}),dL=e=>sz({try:()=>dj.pathToFileURL(e),catch:e=>new l7({module:"Path",method:"toFileUrl",cause:e})});u7.posix,u7.win32;let dP=lw(um)({[up]:up,...de,fromFileUrl:dF,toFileUrl:dL}),dD="~effect/Stdio",dR=nQ(dD),dU=lw(dR,{[dD]:dD,...{args:sL(()=>process.argv.slice(2)),stdout:e=>uR({evaluate:()=>process.stdout,onError:e=>cr({module:"Stdio",method:"stdout",_tag:"Unknown",cause:e}),endOnDone:e?.endOnDone??!1}),stderr:e=>uR({evaluate:()=>process.stderr,onError:e=>cr({module:"Stdio",method:"stderr",_tag:"Unknown",cause:e}),endOnDone:e?.endOnDone??!1}),stdin:uz({evaluate:()=>process.stdin,onError:e=>cr({module:"Stdio",method:"stdin",_tag:"Unknown",cause:e}),closeOnDone:!1})}});class dB{waiters=new Set;taken=0;permits;constructor(e){this.permits=e}get free(){return this.permits-this.taken}take(e){let t=sP(()=>this.free<e?sW(r=>{if(this.free>=e)return r(t);let n=()=>{this.free<e||(this.waiters.delete(n),r(t))};return this.waiters.add(n),sL(()=>{this.waiters.delete(n)})}):(this.taken+=e,sj(e)));return t}updateTakenUnsafe(e,t){return this.taken=t(this.taken),this.waiters.size>0&&e.currentDispatcher.scheduleTask(()=>{let e=this.waiters.values(),t=e.next();for(;!1===t.done&&this.free>0;)t.value(),t=e.next()},0),this.free}updateTaken(e){return tY(t=>sj(this.updateTakenUnsafe(t,e)))}resize(e){return tY(t=>(this.permits=e,this.free<0||this.updateTakenUnsafe(t,e=>e),sK))}release(e){return this.updateTaken(t=>t-e)}get releaseAll(){return this.updateTaken(e=>0)}withPermits(e){return t=>a6(r=>s8(r(this.take(e)),e=>aH(r(t),()=>{this.updateTakenUnsafe(sO(),t=>t-e)},!0)))}withPermit=this.withPermits(1);withPermitsIfAvailable(e){return t=>a6(r=>this.free<e?sU:(this.taken+=e,aH(r(ae(t,rk)),()=>{this.updateTakenUnsafe(sO(),t=>t-e)},!0)))}}let dq={_tag:"Empty"},dK={_tag:"Closed"},dz={_A:ec,_E:ec};class dV{"~effect/RcRef"=dz;pipe(){return es(this,arguments)}state=dq;semaphore=new dB(1);acquire;context;scope;idleTimeToLive;constructor(e,t,r,n){this.acquire=e,this.context=t,this.scope=r,this.idleTimeToLive=n}}let dJ=sG(function*(e){let t,r=yield*a6(t=>{switch(e.state._tag){case"Closed":return a1;case"Acquired":return e.state.refCount++,e.state.fiber?s1(sT(e.state.fiber),e.state):lD(e.state);case"Empty":{let r=aJ();return e.semaphore.withPermits(1)(t(ad(e.acquire,n8(e.context,aR,r))).pipe(ae(t=>{let n={_tag:"Acquired",value:t,scope:r,fiber:void 0,refCount:1,invalidated:!1};return e.state=n,n})))}}}),n=yield*aR,i=void 0!==e.idleTimeToLive&&"Infinity"!==(t=e.idleTimeToLive).value._tag&&"NegativeInfinity"!==t.value._tag;return yield*aK(n,()=>(r.refCount--,r.refCount>0)?sK:void 0===e.idleTimeToLive?(e.state=dq,aU(r.scope,ai)):r.invalidated?aU(r.scope,ai):i?(r.fiber=oE(e.idleTimeToLive).pipe(s8(()=>"Acquired"===e.state._tag&&0===e.state.refCount?(e.state=dq,aU(r.scope,ai)):sK),aZ(sL(()=>{r.fiber=void 0})),oo(e.context),ol(e.scope)),sK):sK),r.value}),dW=/^[+-]?\d+$/,dY="~effect/BigDecimal",dG={[dY]:dY,[ej](){let e=d5(this);return eP(eF(e.value),eU(e.scale))},[eQ](e){return dH(e)&&fr(this,e)},toString(){return`BigDecimal(${fn(this)})`},toJSON(){return{_id:"BigDecimal",value:String(this.value),scale:this.scale}},[to](){return this.toJSON()},pipe(){return es(this,arguments)}},dH=e=>eT(e,dY),dQ=(e,t)=>{let r=Object.create(dG);return r.value=e,r.scale=t,r},dZ=(e,t)=>{if(e!==dX&&e%d2===dX)throw RangeError("Value must be normalized");let r=dQ(e,t);return r.normalized=r,r},dX=BigInt(0),d0=BigInt(1),d1=BigInt(-1),d2=BigInt(10),d3=dZ(dX,0),d5=e=>{if(void 0===e.normalized)if(e.value===dX)e.normalized=d3;else{let t=`${e.value}`,r=0;for(let e=t.length-1;e>=0;e--)if("0"===t[e])r++;else break;0===r&&(e.normalized=e);let n=BigInt(t.substring(0,t.length-r)),i=e.scale-r;e.normalized=dZ(n,i)}return e.normalized},d4=el(2,(e,t)=>t>e.scale?dQ(e.value*d2**BigInt(t-e.scale),t):t<e.scale?dQ(e.value/d2**BigInt(e.scale-t),t):e),d8=el(2,(e,t)=>t.value===dX?e:e.value===dX?t:e.scale>t.scale?dQ(d4(t,e.scale).value+e.value,e.scale):e.scale<t.scale?dQ(d4(e,t.scale).value+t.value,t.scale):dQ(e.value+t.value,e.scale)),d6=rm((e,t)=>{let r=rg(fe(e),fe(t));return 0!==r?r:e.scale>t.scale?ry(e.value,d4(t,e.scale).value):e.scale<t.scale?ry(d4(e,t.scale).value,t.value):ry(e.value,t.value)}),d9=(V=d6,el(2,(e,t)=>-1===V(e,t))),d7=rv(d6),fe=e=>e.value===dX?0:e.value<dX?-1:1,ft=t5((e,t)=>e.scale>t.scale?d4(t,e.scale).value===e.value:e.scale<t.scale?d4(e,t.scale).value===t.value:e.value===t.value),fr=el(2,(e,t)=>ft(e,t)),fn=e=>{let t,r,n=d5(e);if(Math.abs(n.scale)>=16)return fi(n);let i=n.value<dX,s=i?`${n.value}`.substring(1):`${n.value}`;if(n.scale>=s.length)t="0",r="0".repeat(n.scale-s.length)+s;else{let e=s.length-n.scale;if(e>s.length){let n=e-s.length;t=`${s}${"0".repeat(n)}`,r=""}else r=s.slice(e),t=s.slice(0,e)}let a=""===r?t:`${t}.${r}`;return i?`-${a}`:a},fi=e=>{if(fs(e))return"0e+0";let t=d5(e),r=`${(t.value<dX?dQ(-t.value,t.scale):t).value}`,n=r.slice(0,1),i=r.slice(1),s=`${fa(t)?"-":""}${n}`;""!==i&&(s+=`.${i}`);let a=i.length-t.scale;return`${s}e${a>=0?"+":""}${a}`},fs=e=>e.value===dX,fa=e=>e.value<dX,fo=e=>dH(e[0]),fl=el(fo,(e,t=0)=>e.scale<=t?e:dQ(e.value/d2**BigInt(e.scale-t),t)),fc=el(fo,(e,t=0)=>{let r=fl(e,t);return e.value>dX&&d9(r,e)?d8(r,dQ(d0,t)):r}),fu=el(fo,(e,t=0)=>{let r=fl(e,t);return fa(e)&&d7(r,e)?d8(r,dQ(d1,t)):r}),fd="~effect/time/DateTime",ff="~effect/time/DateTime/TimeZone",fh={[fd]:fd,pipe(){return es(this,arguments)},[to](){return this.toString()},toJSON(){return fL(this).toJSON()}},fp={...fh,_tag:"Utc",[ej](){return eU(this.epochMilliseconds)},[eQ](e){return fw(e)&&"Utc"===e._tag&&this.epochMilliseconds===e.epochMilliseconds},toString(){return`DateTime.Utc(${fL(this).toJSON()})`}},fm={...fh,_tag:"Zoned",[ej](){return eP(eU(this.epochMilliseconds))(eF(this.zone))},[eQ](e){return fw(e)&&"Zoned"===e._tag&&this.epochMilliseconds===e.epochMilliseconds&&eZ(this.zone,e.zone)},toString(){return`DateTime.Zoned(${fQ(this)})`}},fg={[ff]:ff,[to](){return this.toString()}},fy={...fg,_tag:"Named",[ej](){return eB(`Named:${this.id}`)},[eQ](e){return fk(e)&&"Named"===e._tag&&this.id===e.id},toString(){return`TimeZone.Named(${this.id})`},toJSON(){return{_id:"TimeZone",_tag:"Named",id:this.id}}},fb={...fg,_tag:"Offset",[ej](){return eB(`Offset:${this.offset}`)},[eQ](e){return fk(e)&&"Offset"===e._tag&&this.offset===e.offset},toString(){return`TimeZone.Offset(${fR(this.offset)})`},toJSON(){return{_id:"TimeZone",_tag:"Offset",offset:this.offset}}},fv=(e,t,r)=>{let n=Object.create(fm);return n.epochMilliseconds=e,n.zone=t,Object.defineProperty(n,"partsUtc",{value:r,enumerable:!1,writable:!0}),Object.defineProperty(n,"adjustedEpochMillis",{value:void 0,enumerable:!1,writable:!0}),Object.defineProperty(n,"partsAdjusted",{value:void 0,enumerable:!1,writable:!0}),n},fw=e=>eT(e,fd),fx=e=>fw(e[0]),fk=e=>eT(e,ff),fS=((e,t)=>e.epochMilliseconds===t.epochMilliseconds,e=>{let t=Object.create(fp);return t.epochMilliseconds=e,Object.defineProperty(t,"partsUtc",{value:void 0,enumerable:!1,writable:!0}),t}),f_=e=>{let t=e.getTime();if(Number.isNaN(t))throw new oM("Invalid date");return fS(t)},f$=e=>{if(fw(e))return e;if(e instanceof Date)return f_(e);if("object"==typeof e){if("epochMilliseconds"in e)return fS(e.epochMilliseconds);let t=new Date(0);return fB(t,e),f_(t)}return"string"!=typeof e||fO(e)?f_(new Date(e)):f_(new Date(e+"Z"))},fO=e=>/Z|GMT|[+-]\d{2}$|[+-]\d{2}:?\d{2}$|\]$/.test(e),fI=rq((e,t)=>{let r,n=t?.timeZone;if(void 0===n&&fw(e)&&"Zoned"===e._tag)return e;let i=f$(e);if(i.epochMilliseconds<-86399999568e5||i.epochMilliseconds>86399999496e5)throw RangeError(`Epoch millis out of range: ${i.epochMilliseconds}`);if(void 0===n&&"object"==typeof e&&"timeZoneId"in e&&(n=e.timeZoneId),void 0===n)r=fM(-60*new Date(i.epochMilliseconds).getTimezoneOffset()*1e3);else if(fk(n))r=n;else if("number"==typeof n)r=fM(n);else{let e=fF(n);if(r_(e))throw new oM(`Invalid time zone: ${n}`);r=e.value}return t?.adjustForTimeZone!==!0?fv(i.epochMilliseconds,r,i.partsUtc):fq(i.epochMilliseconds,r,t?.disambiguation??"compatible")}),fC=rq(f$),fE=/^(.{17,35})\[(.+)\]$/,fA=((e,t,r)=>r?.adjustForTimeZone===!0?fq(e.epochMilliseconds,t,r?.disambiguation??"compatible"):fv(e.epochMilliseconds,t,e.partsUtc),new Map),fT={day:"numeric",month:"numeric",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"longOffset",fractionalSecondDigits:3,hourCycle:"h23"},fM=e=>{let t=Object.create(fb);return t.offset=e,t},fN=rq(e=>{if(fA.has(e))return fA.get(e);try{var t=new Intl.DateTimeFormat("en-US",{...fT,timeZone:e});let r=t.resolvedOptions().timeZone;if(fA.has(r))return fA.get(r);let n=Object.create(fy);return n.id=r,n.format=t,fA.set(r,n),n}catch{throw new oM(`Invalid time zone: ${e}`)}}),fj=/^(?:GMT|[+-])/,fF=e=>{if(fj.test(e)){let t=fz(e);return null===t?rx():rk(fM(t))}return fN(e)},fL=e=>new Date(e.epochMilliseconds),fP=e=>{if("Utc"===e._tag)return new Date(e.epochMilliseconds);if("Offset"===e.zone._tag)return new Date(e.epochMilliseconds+e.zone.offset);if(void 0!==e.adjustedEpochMilliseconds)return new Date(e.adjustedEpochMilliseconds);let t=e.zone.format.formatToParts(e.epochMilliseconds).filter(e=>"literal"!==e.type),r=new Date(0);return r.setUTCFullYear(Number(t[2].value),Number(t[0].value)-1,Number(t[1].value)),r.setUTCHours(Number(t[3].value),Number(t[4].value),Number(t[5].value),Number(t[6].value)),e.adjustedEpochMilliseconds=r.getTime(),r},fD=e=>fP(e).getTime()-fU(e),fR=e=>{let t=Math.abs(e),r=Math.floor(t/36e5),n=Math.round(t%36e5/6e4);return 60===n&&(r+=1,n=0),`${e<0?"-":"+"}${String(r).padStart(2,"0")}:${String(n).padStart(2,"0")}`},fU=e=>e.epochMilliseconds,fB=(e,t)=>{if(void 0!==t.year&&e.setUTCFullYear(t.year),void 0!==t.month&&e.setUTCMonth(t.month-1),void 0!==t.day&&e.setUTCDate(t.day),void 0!==t.weekDay){let r=t.weekDay-e.getUTCDay();e.setUTCDate(e.getUTCDate()+r)}void 0!==t.hour&&e.setUTCHours(t.hour),void 0!==t.minute&&e.setUTCMinutes(t.minute),void 0!==t.second&&e.setUTCSeconds(t.second),void 0!==t.millisecond&&e.setUTCMilliseconds(t.millisecond)},fq=(e,t,r)=>{if("Offset"===t._tag)return fv(e-t.offset,t);let n=fV(e-864e5,e,t),i=fV(e+864e5,e,t);if(n===i)return fv(e-n,t);let s=n-i;if(n<i){if(fV(e-i,e,t)===i)return fv(e-i,t);let s=fv(e-n,t);if(e!==fP(s).getTime())switch(r){case"reject":{let r=new Date(e).toISOString();throw RangeError(`Gap time: ${r} does not exist in time zone ${t.id}`)}case"earlier":return fv(e-i,t)}return s}if(fV(e-n,e,t)===n){if("earlier"===r||"compatible"===r||fV(e-n+s,e+s,t)===n)return fv(e-n,t);if("reject"===r){let r=new Date(e).toISOString();throw RangeError(`Ambiguous time: ${r} occurs twice in time zone ${t.id}`)}}return fv(e-i,t)},fK=/([+-])(\d{2}):(\d{2})$/,fz=e=>{let t=fK.exec(e);if(null===t)return null;let[,r,n,i]=t;return("+"===r?1:-1)*(60*Number(n)+Number(i))*6e4},fV=(e,t,r)=>{let n=r.format.formatToParts(e).find(e=>"timeZoneName"===e.type)?.value??"";if("GMT"===n)return 0;let i=fz(n);return null===i?fD(fv(t,r)):i},fJ=el(fx,(e,t,r)=>{if("Utc"===e._tag){let r=fL(e);return t(r),fS(r.getTime())}let n=new Date(fP(e).getTime());return t(n),fq(n.getTime(),e.zone,r?.disambiguation??"compatible")}),fW=((e,t)=>fW(e,e=>{let r=new Date(e);return t(r),r.getTime()}),el(2,(e,t)=>{let r=t(fU(e));return"Utc"===e._tag?fS(r):fv(r,e.zone)})),fY=((e,t)=>t(fP(e)),el(2,(e,t)=>t(fL(e)))),fG=(e,t)=>{e.setTime(e.getTime()+t)},fH=((e,t)=>fJ(e,e=>{if(t.milliseconds&&fG(e,t.milliseconds),t.seconds&&fG(e,1e3*t.seconds),t.minutes&&fG(e,60*t.minutes*1e3),t.hours&&fG(e,60*t.hours*6e4),t.days&&e.setUTCDate(e.getUTCDate()+t.days),t.weeks&&e.setUTCDate(e.getUTCDate()+7*t.weeks),t.months){let r=e.getUTCDate();e.setUTCMonth(e.getUTCMonth()+t.months+1,0),r<e.getUTCDate()&&e.setUTCDate(r)}if(t.years){let r=e.getUTCDate(),n=e.getUTCMonth();e.setUTCFullYear(e.getUTCFullYear()+t.years,n+1,0),r<e.getUTCDate()&&e.setUTCDate(r)}}),e=>{let t=fP(e);return"Utc"===e._tag?t.toISOString():`${t.toISOString().slice(0,-1)}${fR(fD(e))}`}),fQ=e=>"Offset"===e.zone._tag?fH(e):`${fH(e)}[${e.zone.id}]`,fZ="~effect/encoding/EncodingError";class fX extends l6("EncodingError"){[fZ]=fZ}let f0=e=>"string"==typeof e?f4(f2.encode(e)):f4(e),f1=e=>{let t=f5(e),r=t.length;if(r%4!=0)return rh(new fX({kind:"Decode",module:"Base64",input:t,message:`Length must be a multiple of 4, but is ${r}`}));let n=t.indexOf("=");if(-1!==n&&(n<r-2||n===r-2&&"="!==t[r-1]))return rh(new fX({kind:"Decode",module:"Base64",input:t,message:"Found a '=' character, but it is not at the end"}));try{let e=t.endsWith("==")?2:+!!t.endsWith("="),n=new Uint8Array(r/4*3-e);for(let e=0,i=0;e<r;e+=4,i+=3){let r=f8(t.charCodeAt(e))<<18|f8(t.charCodeAt(e+1))<<12|f8(t.charCodeAt(e+2))<<6|f8(t.charCodeAt(e+3));n[i]=r>>16,n[i+1]=r>>8&255,n[i+2]=255&r}return rp(n)}catch(e){return rh(new fX({kind:"Decode",module:"Base64",input:t,message:e instanceof Error?e.message:"Invalid input"}))}},f2=new TextEncoder,f3=new TextDecoder,f5=e=>e.replace(/[\n\r]/g,""),f4=e=>{let t,r=e.length,n="";for(t=2;t<r;t+=3)n+=f6[e[t-2]>>2],n+=f6[(3&e[t-2])<<4|e[t-1]>>4],n+=f6[(15&e[t-1])<<2|e[t]>>6],n+=f6[63&e[t]];return t===r+1&&(n+=f6[e[t-2]>>2],n+=f6[(3&e[t-2])<<4],n+="=="),t===r&&(n+=f6[e[t-2]>>2],n+=f6[(3&e[t-2])<<4|e[t-1]>>4],n+=f6[(15&e[t-1])<<2],n+="="),n};function f8(e){if(e>=f9.length)throw TypeError(`Invalid character ${String.fromCharCode(e)}`);let t=f9[e];if(255===t)throw TypeError(`Invalid character ${String.fromCharCode(e)}`);return t}let f6=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9","+","/"],f9=[255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,62,255,255,255,63,52,53,54,55,56,57,58,59,60,61,255,255,255,0,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255,255,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],f7=e=>f4(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"),he=e=>{let t="";for(let r=0;r<e.length;++r)t+=hr[e[r]];return t},ht=e=>{if(48<=e&&e<=57)return e-48;if(97<=e&&e<=102)return e-97+10;if(65<=e&&e<=70)return e-65+10;throw TypeError("Invalid input")},hr=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];function hn(e,t,r){return"__proto__"===t?Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0}):e[t]=r,e}let hi=e=>(e.checks?e.checks[e.checks.length-1].annotations:e.annotations)?.identifier,hs=eg(e=>{let t=hi(e);return"string"==typeof t?t:e.getExpected(hs)}),ha="~effect/SchemaIssue/Issue";class ho{[ha]=ha;toString(){return h$(this)}}class hl extends ho{_tag="Filter";actual;filter;issue;constructor(e,t,r){super(),this.actual=e,this.filter=t,this.issue=r}}class hc extends ho{_tag="Encoding";ast;actual;issue;constructor(e,t,r){super(),this.ast=e,this.actual=t,this.issue=r}}class hu extends ho{_tag="Pointer";path;issue;constructor(e,t){super(),this.path=e,this.issue=t}}class hd extends ho{_tag="MissingKey";annotations;constructor(e){super(),this.annotations=e}}class hf extends ho{_tag="UnexpectedKey";ast;actual;constructor(e,t){super(),this.ast=e,this.actual=t}}class hh extends ho{_tag="Composite";ast;actual;issues;constructor(e,t,r){super(),this.ast=e,this.actual=t,this.issues=r}}class hp extends ho{_tag="InvalidType";ast;actual;constructor(e,t){super(),this.ast=e,this.actual=t}}class hm extends ho{_tag="InvalidValue";actual;annotations;constructor(e,t){super(),this.actual=e,this.annotations=t}}class hg extends ho{_tag="Forbidden";actual;annotations;constructor(e,t){super(),this.actual=e,this.annotations=t}}class hy extends ho{_tag="AnyOf";ast;actual;issues;constructor(e,t,r){super(),this.ast=e,this.actual=t,this.issues=r}}class hb extends ho{_tag="OneOf";ast;actual;successes;constructor(e,t,r){super(),this.ast=e,this.actual=t,this.successes=r}}function hv(e,t){if(eT(t,ha))return t;if("string"==typeof t)return new hm(rk(e),{message:t});let r="string"==typeof t.issue?new hm(rk(e),{message:t.issue}):t.issue;return new hu(t.path,r)}let hw=e=>{let t=hI(e);if(void 0!==t)return t;switch(e._tag){case"InvalidType":return hS(hs(e.ast),hE(e.actual));case"InvalidValue":return`Invalid data ${hE(e.actual)}`;case"MissingKey":return"Missing key";case"UnexpectedKey":return`Unexpected key with value ${tr(e.actual)}`;case"Forbidden":return"Forbidden operation";case"OneOf":return`Expected exactly one member to match the input ${tr(e.actual)}`}},hx=e=>hI(e.issue)??hI(e);function hk(e){return t=>({issues:h_(t,[],e?.leafHook??hw,e?.checkHook??hx)})}function hS(e,t){return`Expected ${e}, got ${t}`}function h_(e,t,r,n){switch(e._tag){case"Filter":{let i=n(e);if(void 0!==i)return[{path:t,message:i}];if("InvalidValue"===e.issue._tag)return[{path:t,message:hS(function e(t){let r=t.annotations?.expected;if("string"==typeof r)return r;switch(t._tag){case"Filter":return"<filter>";case"FilterGroup":return t.checks.map(t=>e(t)).join(" & ")}}(e.filter),tr(e.actual))}];return h_(e.issue,t,r,n)}case"Encoding":return h_(e.issue,t,r,n);case"Pointer":return h_(e.issue,[...t,...e.path],r,n);case"Composite":return e.issues.flatMap(e=>h_(e,t,r,n));case"AnyOf":{let i=hI(e);if(0===e.issues.length){if(void 0!==i)return[{path:t,message:i}];return[{path:t,message:hS(hs(e.ast),tr(e.actual))}]}return e.issues.flatMap(e=>h_(e,t,r,n))}default:return[{path:t,message:r(e)}]}}let h$=e=>h_(e,[],hw,hx).map(hO).join("\n");function hO(e){let t=e.message;if(e.path&&e.path.length>0){let r=e.path.map(e=>`[${ti(e)}]`).join("");t+=`
37
- at ${r}`}return t}function hI(e){switch(e._tag){case"InvalidType":case"OneOf":case"Composite":case"AnyOf":return hC(e.ast.annotations);case"InvalidValue":case"Forbidden":return hC(e.annotations);case"MissingKey":return hC(e.annotations,"messageMissingKey");case"UnexpectedKey":return hC(e.ast.annotations,"messageUnexpectedKey");case"Filter":return hC(e.filter.annotations);case"Encoding":return hI(e.issue)}}function hC(e,t="message"){let r=e?.[t];if("string"==typeof r)return r}function hE(e){return r_(e)?"no value provided":tr(e.value)}function hA(e){let t;for(let r of e.reasons){if(!tL(r)||!eT(r.error,ha))return;t??=r.error}return t}function hT(e,t){let r=hA(e);if(void 0===r)throw Error(t,{cause:e});return r}class hM extends eo{run;constructor(e){super(),this.run=e}map(e){return new hM((t,r)=>this.run(t,r).pipe(at(rV(e))))}compose(e){return hj(this)?e:hj(e)?this:new hM((t,r)=>this.run(t,r).pipe(s7(t=>e.run(t,r))))}}let hN=new hM(lD);function hj(e){return e.run===hN.run}function hF(e){var t;return t=rV(e),new hM(e=>lD(t(e)))}function hL(e){var t;return t=(t,r)=>e(t,r).pipe(at(rk)),new hM((e,r)=>r_(e)?sU:t(e.value,r))}function hP(e){return new hM(t=>{let r=nt(t,eO);return r$(r)?lD(r):at(e,rk)})}function hD(){return hF(globalThis.String)}function hR(){return hF(globalThis.Number)}let hU="~effect/SchemaTransformation/Transformation";class hB{[hU]=hU;_tag="Transformation";decode;encode;constructor(e,t){this.decode=e,this.encode=t}flip(){return new hB(this.encode,this.decode)}compose(e){return new hB(this.decode.compose(e.decode),e.encode.compose(this.encode))}}let hq=e=>eT(e,hU)?e:new hB(e.decode,e.encode);function hK(e){return new hB(hL(e.decode),hL(e.encode))}function hz(e){return new hB(hF(e.decode),hF(e.encode))}let hV=new hB(hN,hN),hJ=new hB(hR(),hD()),hW=new hB(hF(globalThis.BigInt),hD());hF(e=>new globalThis.Date(e));let hY=e=>{let t;return eA(e)&&"string"==typeof e.message?(t=Object.hasOwn(e,"cause")?Error(e.message,{cause:hY(e.cause)}):Error(e.message),"string"==typeof e.name&&"Error"!==e.name&&(t.name=e.name),"string"==typeof e.stack&&(t.stack=e.stack),t):e};function hG(e){return t=>t._tag===e}hL(e=>ar(sD(f1(e)),t=>new hm(rk(e),{message:t.message}))),hF(f0),hL(e=>n_(nS(f1(e),e=>f3.decode(e)),{onFailure:t=>tJ(new hm(rk(e),{message:t.message})),onSuccess:lD})),hF(f0),hL(e=>n_(nS((e=>{let t=f5(e),r=t.length;if(r%4==1)return rh(new fX({module:"Base64Url",kind:"Decode",input:t,message:`Length should be a multiple of 4, but is ${r}`}));if(!/^[-_A-Z0-9]*?={0,2}$/i.test(t))return rh(new fX({module:"Base64Url",kind:"Decode",input:t,message:"Invalid input"}));let n=r%4==2?`${t}==`:r%4==3?`${t}=`:t;return f1(n=n.replace(/-/g,"+").replace(/_/g,"/"))})(e),e=>f3.decode(e)),{onFailure:t=>tJ(new hm(rk(e),{message:t.message})),onSuccess:lD})),hF(e=>"string"==typeof e?f7(f2.encode(e)):f7(e)),hL(e=>n_(nS((e=>{let t=new TextEncoder().encode(e);if(t.length%2!=0)return rh(new fX({module:"Hex",kind:"Decode",input:e,message:`Length must be a multiple of 2, but is ${t.length}`}));try{let e=t.length/2,r=new Uint8Array(e);for(let n=0;n<e;n++){let e=ht(t[2*n]),i=ht(t[2*n+1]);r[n]=e<<4|i}return rp(r)}catch(t){return rh(new fX({module:"Hex",kind:"Decode",input:e,message:t instanceof Error?t.message:"Invalid input"}))}})(e),e=>f3.decode(e)),{onFailure:t=>tJ(new hm(rk(e),{message:t.message})),onSuccess:lD})),hF(e=>"string"==typeof e?he(f2.encode(e)):he(e)),hL(e=>{try{return lD(globalThis.decodeURIComponent(e))}catch(t){return tJ(new hm(rk(e),{message:t instanceof URIError?t.message:"Invalid URI component"}))}}),hF(encodeURIComponent);let hH=hG("Declaration"),hQ=hG("Never"),hZ=hG("String"),hX=hG("Number"),h0=hG("Boolean"),h1=hG("Literal"),h2=hG("UniqueSymbol"),h3=hG("Arrays"),h5=hG("Objects"),h4=hG("Union");class h8{to;transformation;constructor(e,t){this.to=e,this.transformation=t}}let h6={};class h9{isOptional;isMutable;defaultValue;annotations;constructor(e,t,r,n){this.isOptional=e,this.isMutable=t,this.defaultValue=r,this.annotations=n}}let h7="~effect/Schema";class pe{[h7]=h7;annotations;checks;encoding;context;constructor(e,t,r,n){this.annotations=e,this.checks=t,this.encoding=r,this.context=n}toString(){return`<${this._tag}>`}}class pt extends pe{_tag="Declaration";typeParameters;run;encodingChecks;constructor(e,t,r,n,i,s,a){super(r,n,i,s),this.typeParameters=e,this.run=t,this.encodingChecks=a}getParser(){let e=this.run(this.typeParameters);return(t,r)=>r_(t)?sU:at(e(t.value,this,r),rk)}_rebuild(e,t,r){let n=pZ(this.typeParameters,e);return n===this.typeParameters&&t===this.checks&&r===this.encodingChecks?this:new pt(n,this.run,this.annotations,t,void 0,this.context,r)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}getExpected(){let e=this.annotations?.expected;return"string"==typeof e?e:"<Declaration>"}}let pr=new class extends pe{_tag="Null";getParser(){return p9(this,null)}getExpected(){return"null"}},pn=new h8(pr,new hB(hF(()=>void 0),hF(()=>null))),pi=new class extends pe{_tag="Undefined";getParser(){return p9(this,void 0)}toCodecJson(){return pK(this,[pn])}getExpected(){return"undefined"}},ps=new class extends pe{_tag="Unknown";getParser(){return p7(this,eE)}getExpected(){return"unknown"}};class pa extends pe{_tag="Literal";literal;constructor(e,t,r,n,i){if(super(t,r,n,i),"number"==typeof e&&!globalThis.Number.isFinite(e))throw Error(`A numeric literal must be finite, got ${tr(e)}`);this.literal=e}getParser(){return p9(this,this.literal)}matchPart(e,t){return e===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return"bigint"==typeof this.literal?po(this):this}toCodecStringTree(){return"string"==typeof this.literal?this:po(this)}getExpected(){return"string"==typeof this.literal?JSON.stringify(this.literal):globalThis.String(this.literal)}}function po(e){let t=globalThis.String(e.literal);return pK(e,[new h8(new pa(t),new hB(hF(()=>e.literal),hF(()=>t)))])}let pl=new class extends pe{_tag="String";getParser(){return p7(this,ev)}matchPart(e,t){return me(this,e,t)}getExpected(){return"string"}};function pc(e,t){return e.some(e=>{switch(e._tag){case"Filter":return e.annotations?.meta?._tag===t;case"FilterGroup":return pc(e.checks,t)}})}let pu=new class extends pe{_tag="Number";getParser(){return p7(this,ew)}matchKey(e,t){return this._match(ms,e,t)}matchPart(e,t){return this._match(mi,e,t)}_match(e,t,r){return e.test(t)?me(this,globalThis.Number(t),r):void 0}toCodecJson(){return this.checks&&(pc(this.checks,"isFinite")||pc(this.checks,"isInt"))?this:pK(this,[pF])}toCodecStringTree(){return this.checks&&(pc(this.checks,"isFinite")||pc(this.checks,"isInt"))?pK(this,[mo]):pK(this,[ml])}getExpected(){return"number"}},pd=new class extends pe{_tag="Boolean";getParser(){return p7(this,ex)}getExpected(){return"boolean"}},pf=new class extends pe{_tag="Symbol";getParser(){return p7(this,eS)}matchKey(e,t){return me(this,e,t)}toCodecStringTree(){return pK(this,[mf])}getExpected(){return"symbol"}},ph=new class extends pe{_tag="BigInt";getParser(){return p7(this,ek)}matchPart(e,t){return mc.test(e)?me(this,globalThis.BigInt(e),t):void 0}toCodecStringTree(){return pK(this,[mu])}getExpected(){return"bigint"}};class pp extends pe{_tag="Arrays";isMutable;elements;rest;encodingChecks;constructor(e,t,r,n,i,s,a,o){super(n,i,s,a),this.isMutable=e,this.elements=t,this.rest=r,this.encodingChecks=o;let l=t.findIndex(p5);if(-1!==l&&(t.slice(l+1).some(e=>!p5(e))||r.length>1))throw Error("A required element cannot follow an optional element. ts(1257)");if(r.length>1&&r.slice(1).some(p5))throw Error("An optional element cannot follow a rest element. ts(1266)")}getParser(e){let t=this,r=t.elements.map(t=>({ast:t,parser:e(t)})),n=t.rest.map(t=>({ast:t,parser:e(t)})),i=r.length,[s,...a]=n,o=a.length;function l(e,t){return t<i?r[t]:t>=e?a[t-e]:s}return lQ(function*(e,r){if("None"===e._tag)return e;let n=e.value;if(!Array.isArray(n))return yield*tJ(new hp(t,e));let s=n.length,a={ast:t,getParser:l,oinput:e,len:s,tailThreshold:Math.max(i,s-o),output:new globalThis.Array(s),issues:void 0,options:r},c=pg(r?.concurrency),u=pm(a,n,{concurrency:c?.concurrency,end:0===t.rest.length?i:Math.max(s,i+o)});if(u&&(yield*u),0===t.rest.length&&s>i)for(let o=i;o<=s-1;o++){let i=new hu([o],new hf(t,n[o]));if("all"!==r.errors)return yield*tJ(new hh(t,e,[i]));a.issues?a.issues.push(i):a.issues=[i]}return a.issues?yield*tJ(new hh(t,e,a.issues)):rk(a.output)})}_rebuild(e,t,r){let n=pZ(this.elements,e),i=pZ(this.rest,e);return n===this.elements&&i===this.rest&&t===this.checks&&r===this.encodingChecks?this:new pp(this.isMutable,n,i,this.annotations,t,void 0,this.context,r)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}getExpected(){return"array"}}let pm=or({onItem(e,t,r){let n=r<e.len?rk(t):rx();return e.getParser(e.tailThreshold,r).parser(n,e.options)},step(e,t,r,n){if("Failure"===r._tag)return py(e,e.ast,n,r);if("Some"===r.value._tag)e.output[n]=r.value.value;else{let t=e.getParser(e.tailThreshold,n);if(p5(t.ast))return;let r=new hu([n],new hd(t.ast.context?.annotations));if("all"!==e.options.errors)return tJ(new hh(e.ast,e.oinput,[r]));e.issues?e.issues.push(r):e.issues=[r]}}}),pg=e=>(e="unbounded"===e?1/0:e??1)>1?{concurrency:e}:void 0,py=(e,t,r,n)=>{if(0===n.cause.reasons.length)return n;let i=hA(n.cause);if(void 0===i)return tV(sf(n.cause,n=>new hh(t,e.oinput,[new hu([r],n)])));let s=new hu([r],i);if("all"!==e.options.errors)return tJ(new hh(t,e.oinput,[s]));e.issues?e.issues.push(s):e.issues=[s]},pb="[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?";class pv{name;type;constructor(e,t){this.name=e,this.type=t}}class pw{decode;encode;constructor(e,t){this.decode=e,this.encode=t}flip(){return new pw(this.encode,this.decode)}}function px(e){switch(e._tag){case"String":case"Number":case"Symbol":case"TemplateLiteral":return!0;case"Union":return e.types.every(px);default:return!1}}class pk{parameter;type;merge;constructor(e,t,r){if(!(px(e)&&px(p8(e))))throw Error(`Invalid index signature parameter ${e._tag}`);if(this.parameter=e,this.type=t,this.merge=r,p5(t)&&!function e(t){switch(t._tag){case"Undefined":return!0;case"Union":return t.types.some(e);default:return!1}}(t))throw Error("Cannot use `Schema.optionalKey` with index signatures, use `Schema.optional` instead.")}}class pS extends pe{_tag="Objects";propertySignatures;indexSignatures;encodingChecks;constructor(e,t,r,n,i,s,a){super(r,n,i,s),this.propertySignatures=e,this.indexSignatures=t,this.encodingChecks=a;let o=e.map(e=>e.name).filter((e,t,r)=>r.indexOf(e)!==t);if(o.length>0)throw Error(`Duplicate identifiers: ${JSON.stringify(o)}. ts(2300)`)}getParser(e){let t=this,r=[],n=new Set,i=[];for(let s of t.propertySignatures)r.push(s.name),n.add(s.name),i.push({ps:s,parser:e(s.type),name:s.name,type:s.type});let s=t.indexSignatures.length;if(0===t.propertySignatures.length&&0===t.indexSignatures.length)return p7(t,eC);let a=s>0?or({onItem:lQ(function*(r,[i,s]){let a=e(mt(s.parameter))(rk(i),r.options),o=s9(a)?a:yield*aj(a);if("Failure"===o._tag){let e=py(r,t,i,o);e&&(yield*e);return}let l=rk(r.input[i]),c=e(s.type)(l,r.options),u=s9(c)?c:yield*aj(c);if("Failure"===u._tag){let e=py(r,t,i,u);e&&(yield*e);return}if("Some"===o.value._tag&&"Some"===u.value._tag){let e=o.value.value;if(n.has(i)||n.has(e))return;let t=u.value.value;if(s.merge&&s.merge.decode&&Object.hasOwn(r.out,e)){let[n,i]=s.merge.decode.combine([e,r.out[e]],[e,t]);hn(r.out,n,i)}else hn(r.out,e,t)}}),step:(e,t,r)=>"Failure"===r._tag?r:void 0}):void 0;return lQ(function*(e,o){let l;if("None"===e._tag)return e;let c=e.value;if(!("object"==typeof c&&null!==c&&!Array.isArray(c)))return yield*tJ(new hp(t,e));let u={},d={ast:t,oinput:e,input:c,out:u,issues:void 0,options:o},f="all"===o.errors,h="error"===o.onExcessProperty,p="preserve"===o.onExcessProperty;if(0===t.indexSignatures.length&&(h||p)){l=Reflect.ownKeys(c);for(let r=0;r<l.length;r++){let i=l[r];if(!n.has(i))if(h){let r=new hu([i],new hf(t,c[i]));if(!f)return yield*tJ(new hh(t,e,[r]));d.issues?d.issues.push(r):d.issues=[r];continue}else hn(u,i,c[i])}}let m=pg(o?.concurrency),g=p_(d,i,m);if(g&&(yield*g),a){let e=nP();for(let r=0;r<s;r++){let n=t.indexSignatures[r],i=function(e,t,r=h6){let n,i;return function t(s){switch(s._tag){case"String":case"TemplateLiteral":return(n??=Object.keys(e)).filter(e=>void 0!==s.matchPart(e,r));case"Number":return(n??=Object.keys(e)).filter(e=>void 0!==s.matchKey(e,r));case"Symbol":return(i??=Object.getOwnPropertySymbols(e)).filter(e=>void 0!==s.matchKey(e,r));case"Union":return[...new Set(s.types.flatMap(t))];default:return[]}}(mt(p8(t)))}(c,n.parameter,o);for(let t=0;t<i.length;t++){let r=i[t];e.push([r,n])}}let r=a(d,e,m);r&&(yield*r)}if(d.issues)return yield*tJ(new hh(t,e,d.issues));if("original"===o.propertyOrder){let e=(l??Reflect.ownKeys(c)).concat(r),t={};for(let r of e)Object.hasOwn(u,r)&&hn(t,r,u[r]);return rk(t)}return rk(u)})}_rebuild(e,t,r,n,i){let s=pZ(this.propertySignatures,t=>{let r=e(t.type);return r===t.type?t:new pv(t.name,r)}),a=pZ(this.indexSignatures,n=>{let i=t(n.parameter),s=e(n.type),a=r?n.merge?.flip():n.merge;return i===n.parameter&&s===n.type&&a===n.merge?n:new pk(i,s,a)});return s===this.propertySignatures&&a===this.indexSignatures&&n===this.checks&&i===this.encodingChecks?this:new pS(s,a,this.annotations,n,void 0,this.context,i)}flip(e){return this._rebuild(e,e,!0,this.encodingChecks,this.checks)}recur(e,t=e){return this._rebuild(e,t,!1,this.checks,this.encodingChecks)}getExpected(){return 0===this.propertySignatures.length&&0===this.indexSignatures.length?"object | array":"object"}}let p_=or({onItem(e,t){let r=Object.hasOwn(e.input,t.name)?rk(e.input[t.name]):rx();return t.parser(r,e.options)},step(e,t,r){if("Failure"===r._tag)return py(e,e.ast,t.name,r);if("Some"===r.value._tag)hn(e.out,t.name,r.value.value);else if(!p5(t.type)){let r=new hu([t.name],new hd(t.type.context?.annotations));return"all"!==e.options.errors?tJ(new hh(e.ast,e.oinput,[r])):void(e.issues?e.issues.push(r):e.issues=[r])}}});function p$(e,t){return e?t?[...e,...t]:e:t}function pO(e,t,r){return new pS(Reflect.ownKeys(e).map(t=>new pv(t,e[t].ast)),[],r,t)}function pI(e){return e.ast}function pC(e,t,r){return new pM(e.map(pI),t,void 0,r)}function pE(e){switch(e._tag){default:return[];case"Declaration":{let t=e.annotations?.["~sentinels"];return Array.isArray(t)?t:[]}case"Objects":return e.propertySignatures.flatMap(e=>{let t=e.type;if(!p5(t)){if(h1(t))return[{key:e.name,literal:t.literal}];if(h2(t))return[{key:e.name,literal:t.symbol}]}return[]});case"Arrays":return e.elements.flatMap((e,t)=>h1(e)&&!p5(e)?[{key:t,literal:e.literal}]:[]);case"Suspend":return pE(e.thunk())}}let pA=new WeakMap;function pT(e){return t=>{let r=p8(t);return"Literal"===r._tag?r.literal===e:"UniqueSymbol"!==r._tag||r.symbol===e}}class pM extends pe{_tag="Union";types;mode;encodingChecks;constructor(e,t,r,n,i,s,a){super(r,n,i,s),this.types=e,this.mode=t,this.encodingChecks=a}getParser(e){let t=this;return(r,n)=>{if("None"===r._tag)return lD(r);let i=r.value,s=function(e,t){let r=function(e){let t=pA.get(e);if(t)return t;t={};for(let r=0;r<e.length;r++){let n=p8(e[r]);if(hQ(n))continue;let i=function e(t){switch(t._tag){case"Null":return["null"];case"Undefined":return["undefined"];case"String":case"TemplateLiteral":return["string"];case"Number":return["number"];case"Boolean":return["boolean"];case"Symbol":case"UniqueSymbol":return["symbol"];case"BigInt":return["bigint"];case"Arrays":return["array"];case"ObjectKeyword":return["object","array","function"];case"Objects":return t.propertySignatures.length||t.indexSignatures.length?["object"]:["object","array"];case"Enum":return Array.from(new Set(t.enums.map(([,e])=>typeof e)));case"Literal":return[typeof t.literal];case"Union":return Array.from(new Set(t.types.flatMap(e)));default:return["null","undefined","string","number","boolean","symbol","bigint","object","array","function"]}}(n),s=pE(n);for(let e of(t.byType??={},i))(t.byType[e]??=[]).push(r);if(s.length>0)for(let{key:e,literal:n}of(t.bySentinel??=new Map,s)){let i=t.bySentinel.get(e);i||t.bySentinel.set(e,i=new Map);let s=i.get(n);s||i.set(n,s=[]),s.push(r)}else for(let e of(t.otherwise??={},i))(t.otherwise[e]??=[]).push(r)}return pA.set(e,t),t}(t),n=null===e?"null":Array.isArray(e)?"array":typeof e;if(r.bySentinel){let i=r.otherwise?.[n]??[];if("object"===n||"array"===n){let n=new Set(i);for(let[t,i]of r.bySentinel)if(Object.hasOwn(e,t)){let r=i.get(e[t]);if(r)for(let e of r)n.add(e)}return Array.from(n).sort((e,t)=>e-t).map(e=>t[e]).filter(pT(e))}return i.map(e=>t[e])}return(r.byType?.[n]??[]).map(e=>t[e]).filter(pT(e))}(i,t.types),a={ast:t,recur:e,oinput:r,input:i,out:void 0,successes:[],issues:void 0,options:n},o=pg(n?.concurrency),l=pN(a,s,o?{...o,orderedStep:!0}:void 0);return l?s8(l,e=>a.out?lD(a.out):tJ(new hy(t,i,a.issues??[]))):a.out?lD(a.out):tJ(new hy(t,i,a.issues??[]))}}_rebuild(e,t,r){let n=pZ(this.types,e);return n===this.types&&t===this.checks&&r===this.encodingChecks?this:new pM(n,this.mode,this.annotations,t,void 0,this.context,r)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}matchPart(e,t){for(let r of this.types){let n=r.matchPart(e,t);if(void 0!==n)return n}}getExpected(e){let t=this.annotations?.expected;return"string"==typeof t?t:0===this.types.length?"never":Array.from(new Set(this.types.map(t=>{let r=p8(t);switch(r._tag){case"Arrays":{let t=r.elements.filter(h1);if(t.length>0)return`${pL(r.isMutable)}[ ${t.map(t=>e(t)+(t.context?.isOptional?"?":"")).join(", ")}, ... ]`;break}case"Objects":{let t=r.propertySignatures.filter(e=>h1(e.type));if(t.length>0)return`{ ${t.map(t=>`${pL(t.type.context?.isMutable)}${ti(t.name)}${t.type.context?.isOptional?"?":""}: ${e(t.type)}`).join(", ")}, ... }`}}return e(r)}))).join(" | ")}}let pN=or({onItem:(e,t)=>e.recur(t)(e.oinput,e.options),step(e,t,r){if("Failure"===r._tag){let t=hA(r.cause);if(void 0===t)return r;e.issues?e.issues.push(t):e.issues=[t]}else{if(e.out&&"oneOf"===e.ast.mode)return e.successes.push(t),tJ(new hb(e.ast,e.input,e.successes));if(e.out=r.value,e.successes.push(t),"anyOf"===e.ast.mode)return ai}}}),pj=new pM([new pa("Infinity"),new pa("-Infinity"),new pa("NaN")],"anyOf"),pF=new h8(new pM([pu,pj],"anyOf"),new hB(hR(),hF(e=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function pL(e){return e?"":"readonly "}class pP extends pe{_tag="Suspend";thunk;constructor(e,t,r,n,i){let s,a;if(void 0!==r)throw Error("Cannot add checks to Suspend");super(t,void 0,n,i),this.thunk=(a=!1,()=>(a||(s=e(),a=!0),s))}getParser(e){return e(this.thunk())}recur(e){return new pP(()=>e(this.thunk()),this.annotations,void 0,void 0,this.context)}getExpected(e){return e(this.thunk())}}class pD extends eo{_tag="Filter";run;annotations;aborted;constructor(e,t,r=!1){super(),this.run=e,this.annotations=t,this.aborted=r}annotate(e){return new pD(this.run,{...this.annotations,...e},this.aborted)}abort(){return new pD(this.run,this.annotations,!0)}and(e,t){return new pR([this,e],t)}}class pR extends eo{_tag="FilterGroup";checks;annotations;constructor(e,t){super(),this.checks=e,this.annotations=t}annotate(e){return new pR(this.checks,{...this.annotations,...e})}and(e,t){return new pR([this,e],t)}}function pU(e,t,r=!1){return new pD((t,r,n)=>(function(e,t,r){if(Array.isArray(r))return nA(r)?1===r.length?hv(e,r[0]):new hh(t,rk(e),nR(r,t=>hv(e,t))):void 0;if(void 0!==r)return"boolean"==typeof r?r?void 0:new hm(rk(e)):hv(e,r)})(t,r,e(t,r,n)),t,r)}function pB(e,t){let r=e.source;return pU(t=>e.test(t),{expected:`a string matching the RegExp ${r}`,meta:{_tag:"isPattern",regExp:e},arbitrary:{constraint:{patterns:[e.source]}},...t})}function pq(e,t){let r=Object.getOwnPropertyDescriptors(e);return t(r),Object.create(Object.getPrototypeOf(e),r)}function pK(e,t){return e.encoding===t?e:pq(e,e=>{e.encoding.value=t})}function pz(e,t){return e.context===t?e:pq(e,e=>{e.context.value=t})}function pV(e){return e.encoding?pV(e.encoding[e.encoding.length-1].to):e}function pJ(e,t){if(e.checks){let r=e.checks[e.checks.length-1];return pW(e,nC(e.checks.slice(0,-1),r.annotate(t)))}return pq(e,e=>{e.annotations.value={...e.annotations.value,...t}})}function pW(e,t){if("Suspend"===e._tag&&void 0!==t)throw Error("Cannot add checks to Suspend");return e.checks===t?e:pq(e,e=>{e.checks.value=t})}function pY(e,t){return pW(e,p$(e.checks,t))}function pG(e,t){let r=e[e.length-1],n=t(r.to);return n!==r.to?nC(e.slice(0,e.length-1),new h8(n,r.transformation)):e}function pH(e){return t=>t.encoding?pK(t,pG(t.encoding,e)):t}function pQ(e){return eg(function t(r){return r.encoding?pK(r,pG(r.encoding,t)):e(r)})}function pZ(e,t){let r=!1,n=Array(e.length);for(let i=0;i<e.length;i++){let s=e[i],a=t(s);a!==s&&(r=!0),n[i]=a}return r?n:e}function pX(e,t){let r=e.context?new h9(e.context.isOptional,e.context.isMutable,e.context.defaultValue,{...e.context.annotations,...t}):new h9(!1,!1,void 0,t);return pz(e,r)}let p0=pH(p1);function p1(e){let t=e.context?!1===e.context.isOptional?new h9(!0,e.context.isMutable,e.context.defaultValue,e.context.annotations):e.context:new h9(!0,!1);return p0(pz(e,t))}let p2=pH(p3);function p3(e){let t=e.context?!1===e.context.isMutable?new h9(e.context.isOptional,!0,e.context.defaultValue,e.context.annotations):e.context:new h9(!1,!0);return p2(pz(e,t))}function p5(e){return e.context?.isOptional??!1}let p4=eg(e=>{if(e.encoding)return p4(pK(e,void 0));let t=e.recur?.(p4)??e,r=t.encodingChecks;return r?pq(t,n=>{n.encodingChecks.value=void 0,t===e&&(n.checks.value=p$(t.checks,r))}):t}),p8=eg(e=>p4(p6(e))),p6=eg(e=>e.encoding?function(e,t){let r=t.length,n=t[r-1],i=[new h8(p6(pK(e,void 0)),t[0].transformation.flip())];for(let e=1;e<r;e++)i.unshift(new h8(p6(t[e-1].to),t[e].transformation.flip()));let s=p6(n.to);return s.encoding?pK(s,[...s.encoding,...i]):pK(s,i)}(e,e.encoding):e.flip?.(p6)??e.recur?.(p6)??e);function p9(e,t){let r=sj(rk(t));return n=>"None"===n._tag?sU:n.value===t?r:tJ(new hp(e,n))}function p7(e,t){return r=>"None"===r._tag?sU:t(r.value)?lD(r):tJ(new hp(e,r))}function me(e,t,r){if(r?.disableChecks||void 0===e.checks)return t;let n=[];return mh(e.checks,t,n,e,r),0===n.length?t:void 0}let mt=pQ(e=>{switch(e._tag){default:return e;case"Number":return e.toCodecStringTree();case"Union":return e.recur(mt)}}),mr=pQ(e=>{switch(e._tag){default:return e;case"Symbol":case"UniqueSymbol":return e.toCodecStringTree();case"Union":return e.recur(mr)}}),mn=pQ(e=>{switch(e._tag){default:return e;case"Number":case"Literal":case"BigInt":return e.toCodecStringTree();case"Union":return e.recur(mn)}}),mi=new globalThis.RegExp(`^${pb}$`),ms=new globalThis.RegExp(`(?:${pb}|Infinity|-Infinity|NaN)`),ma=pY(pl,[pB(mi,{expected:"a string representing a finite number",meta:{_tag:"isStringFinite",regExp:mi},...void 0})]),mo=new h8(ma,hJ),ml=new h8(new pM([ma,pj],"anyOf"),hJ),mc=new globalThis.RegExp("^-?\\d+$"),mu=new h8(pY(pl,[pB(mc,{expected:"a string representing a bigint",meta:{_tag:"isStringBigInt",regExp:mc},expected:"a string representing a bigint"})]),hW),md=new globalThis.RegExp("^Symbol\\((.*)\\)$"),mf=new h8(pY(pl,[pB(md,{expected:"a string representing a symbol",meta:{_tag:"isStringSymbol",regExp:md},...void 0})]),new hB(hF(e=>globalThis.Symbol.for(md.exec(e)[1])),hL(e=>void 0!==globalThis.Symbol.keyFor(e)?lD(globalThis.String(e)):tJ(new hg(rk(e),{message:"cannot serialize to string, Symbol is not registered"})))));function mh(e,t,r,n,i){for(let s=0;s<e.length;s++){let a=e[s];if("FilterGroup"===a._tag)mh(a.checks,t,r,n,i);else{let e=a.run(t,n,i);if(e&&(r.push(new hl(t,a,e)),a.aborted||i?.errors!=="all"))return}}}let mp="~effect/Schema/Class",mm="~structural",mg=new pt([],()=>(e,t)=>{let r,n;return(r=new Set,n=new Set,function e(t){if(null===t||"string"==typeof t||"boolean"==typeof t)return!0;if("number"==typeof t)return globalThis.Number.isFinite(t);if("object"!=typeof t||void 0===t||r.has(t))return!1;if(n.has(t))return!0;let i=Array.isArray(t);if(!i){let e=Object.getPrototypeOf(t);if(null!==e&&null!==Object.getPrototypeOf(e))return!1}r.add(t);let s=i?t.every(e):Object.keys(t).every(r=>e(t[r]));return r.delete(t),s&&n.add(t),s}(e))?lD(e):tJ(new hp(t,rk(e)))},{typeConstructor:{_tag:"effect/Json"},generation:{runtime:"Schema.Json",Type:"Schema.Json"},expected:"JSON value",toCodecJson:()=>new h8(ps,hV),toArbitrary:()=>e=>e.jsonValue()}),my=new h8(new pt([],()=>(e,t)=>{let r;return(r=new Set,function e(t){return void 0===t||"string"==typeof t||!("object"!=typeof t||null===t||r.has(t))&&((r.add(t),Array.isArray(t))?t.every(e):Object.keys(t).every(r=>e(t[r])))}(e))?lD(e):tJ(new hp(t,rk(e)))},{expected:"StringTree"}),hV),mb="~effect/SchemaError/SchemaError";class mv extends l6("SchemaError"){[mb]=mb;constructor(e){super({issue:e})}get message(){return this.issue.toString()}toString(){return`SchemaError(${this.message})`}}let mw=eg(e=>{switch(e._tag){case"Declaration":{let t=e.annotations?.[mp];if(e_(t)){let r=t(e.typeParameters),n=mw(r.to);return pK(e,n===r.to?[r]:[new h8(n,r.transformation)])}return e}case"Objects":case"Arrays":return e.recur(e=>{let t=e.context?.defaultValue;return t?pK(mw(e),t):mw(e)});case"Suspend":return e.recur(mw);default:return e}});function mx(e){let t=m$(mw(p4(e.ast)));return(e,r)=>t(e,r?.disableChecks?r?.parseOptions?{...r.parseOptions,disableChecks:!0}:{disableChecks:!0}:r?.parseOptions)}function mk(e){let t=mx(e);return(e,r)=>{let n=ou(t(e,r));return"Success"===n._tag?rk(n.value):(hT(n.cause,"Option adapter can only return none for schema issues"),rx())}}function mS(e,t){let r=m$(e.ast);return void 0===t?r:(e,n)=>r(e,m_(t,n))}let m_=(e,t)=>void 0===t?e:{...e,...t};function m$(e){let t=mC(e);return(e,r)=>s7(t(rk(e),r??h6),e=>"None"===e._tag?tJ(new hm(e)):lD(e.value))}function mO(e){return(t,r)=>ou(e(t,r))}function mI(e,t){return am(e,e=>lU(()=>sf(e,t)))}let mC=eg(e=>{let t,r=e.checks,n=e.encoding,i=n?.length??0,s=e.encodingChecks,a=(r?r[r.length-1].annotations:e.annotations)?.parseOptions;if(!e.context&&!n&&!r&&!s)return(r,n)=>(t??=e.getParser(mC),a&&(n={...n,...a}),t(r,n));let o=h3(e)||h5(e)||hH(e)&&e.typeParameters.length>0,l=r&&o?r.filter(e=>e.annotations?.[mm]):void 0;return(o,c)=>{let u;if(a&&(c={...c,...a}),n){for(let e=i-1;e>=0;e--){let t=n[e],r=mC(t.to);if(u=u?s7(u,e=>r(e,c)):r(o,c),"Transformation"===t.transformation._tag){let e=t.transformation.decode;u=s7(u,t=>e.run(t,c))}else u=t.transformation.decode(u,c)}u=mI(u,t=>new hc(e,o,t))}t??=e.getParser(mC);let d=n=>{let i=t(n,c);return s&&!c?.disableChecks&&(i=s7(i,t=>{if(r$(n)&&r$(t)){let t=[];if(mh(s,n.value,t,e,c),t4(t))return tJ(new hh(e,n,t))}return lD(t)})),r&&!c?.disableChecks&&(c?.errors==="all"&&l&&l.length>0&&r$(n)&&(i=mI(i,t=>{let r=[];return mh(l,n.value,r,e,c),t4(r)?"Composite"===t._tag&&t.ast===e?new hh(e,t.actual,[...t.issues,...r]):new hh(e,n,[t,...r]):t})),i=s7(i,t=>{if(r$(t)){let n=t.value,i=[];if(mh(r,n,i,e,c),t4(i))return tJ(new hh(e,t,i))}return lD(t)})),i};return u?s7(u,d):d(o)}}),mE="~effect/Schema/Schema",mA={[mE]:mE,pipe(){return es(this,arguments)},annotate(e){return this.rebuild(pJ(this.ast,e))},annotateKey(e){return this.rebuild(pX(this.ast,e))},check(...e){return this.rebuild(pY(this.ast,e))}};function mT(e,t){let r,n=Object.create(mA);t&&Object.assign(n,t),n.ast=e,n.rebuild=e=>mT(e,t);let i=mx(n);return n.makeEffect=(e,t)=>mM(i(e,t)),r=mx(n),n.make=(e,t)=>{let n=ou(r(e,t));if("Success"===n._tag)return n.value;let i=hT(n.cause,"Constructor adapter can only throw schema issues");throw Error(i.toString(),{cause:i})},n.makeOption=mk(n),n}function mM(e){return am(e,e=>lU(()=>sf(e,e=>new mv(e))))}let mN=mj(function(e){switch(e._tag){case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}});function mj(e){return t=>{let r=new Map;for(let e=0;e<t.length;e++)r.set(p8(t[e]),e);let n=[...t].sort((t,n)=>{t=p8(t),n=p8(n);let i=e(t),s=e(n);return i!==s?i-s:r.get(t)-r.get(n)});return n.some((e,r)=>e!==t[r])?n:t}}let mF=new Set(["~structural","~sentinels","meta","arbitrary","toArbitrary","toEquivalence","toFormatter","toCodec","toCodecJson","toCodecIso",mp]),mL=new Set(["title","description","default","examples","readOnly","writeOnly","format","contentEncoding","contentMediaType","contentSchema"]);function mP(e){if(void 0!==e){let t=nw(e,(e,t)=>!mF.has(t));if(!nb(t))return{annotations:t}}}function mD(e,t){return e.some(e=>{switch(e._tag){case"Filter":return e.meta._tag===t;case"FilterGroup":return mD(e.checks,t)}})}function mR(e,t){if(0===Object.keys(e).length)return t;let r=Object.keys(t).length;if(0===r)return e;let n=Array.isArray(t.allOf)&&1===r?t.allOf:[t];return Array.isArray(e.allOf)?{...e,allOf:[...e.allOf,...n]}:"string"==typeof e.$ref?{allOf:[e,...n]}:{...e,allOf:n}}function mU(e){switch(e._tag){case"Literal":return globalThis.String(e.literal).replace(/[/\\^$*+?.()|[\]{}]/g,"\\$&");case"String":return"[\\s\\S]*?";case"Number":return pb;case"TemplateLiteral":return e.parts.map(mU).join("");case"Union":return e.types.map(mU).join("|");default:throw new globalThis.Error("Unsupported part",{cause:e})}}function mB(){return(e,t,r)=>mY(new pt(e.map(pI),e=>t(e.map(e=>mY(e))),r))}function mq(e){return t=>m0(m0(t).annotate(e))}function mK(e){return t=>t.rebuild(pX(t.ast,e))}function mz(e){return"Success"===e._tag?e.value:{issues:[{message:sw(e.cause)}]}}let mV=function(e){let t;return t=mO(m$(p4(e.ast))),e=>{let r=t(e,h6);return"Success"===r._tag||(hT(r.cause,"Type guard adapter can only return false for schema issues"),!1)}};function mJ(e,t){let r=mS(e,t);return(e,t)=>mM(r(e,t))}function mW(e,t){let r,n=(r=mO(mS(e,t)),(e,t)=>{let n=r(e,t);return"Success"===n._tag?rp(n.value):rh(hT(n.cause,"Result adapter can only return schema issues"))});return(e,t)=>nk(n(e,t),e=>new mv(e))}let mY=mT,mG=e=>mY(p1(e.ast),{schema:e}),mH=e=>mG(gs(e)),mQ=e=>mY(p3(e.ast),{schema:e}),mZ=e=>mY(p8(e.ast),{schema:e}),mX="~effect/Schema/flip";function m0(e){return eT(e,mX)&&e[mX]===mX?e.schema.rebuild(p6(e.ast)):mY(p6(e.ast),{[mX]:mX,schema:e})}function m1(e){let t=mY(new pa(e),{literal:e,transform:r=>t.pipe(gl(m1(r),{decode:hF(()=>r),encode:hF(()=>e)}))});return t}let m2=mY(ps),m3=mY(pi),m5=mY(pl),m4=mY(pu),m8=mY(pd),m6=mY(pf);function m9(e,t){return mY(e,{fields:t,mapFields(e,t){let r=e(this.fields);return m9(pO(r,t?.unsafePreserveChecks?this.ast.checks:void 0),r)}})}function m7(e){return m9(pO(e,void 0),e)}function ge(e,t,r){let n=r?.keyValueCombiner?.decode||r?.keyValueCombiner?.encode?new pw(r.keyValueCombiner.decode,r.keyValueCombiner.encode):void 0;return mY(function(e,t,r){let n,i,{literals:s,parameters:a}=(n=[],i=[],!function e(t){switch(t._tag){case"Literal":var r;(ev(r=t.literal)||ew(r)||eS(r))&&n.push(t.literal);return;case"UniqueSymbol":n.push(t.symbol);return;case"Never":return;case"Union":for(let r=0;r<t.types.length;r++)e(t.types[r]);return;default:i.push(t)}}(e),{literals:n,parameters:i});return new pS(s.map(e=>new pv(e,t)),a.map(e=>new pk(e,t,r)))}(e.ast,t.ast,n),{key:e,value:t})}let gt=e=>mY(new pp(!1,[],[e.ast]),{value:e}),gr=e=>mY(new pp(!0,e.ast.elements,e.ast.rest),{schema:e});function gn(e,t){return function e(t,r){return mY(t,{members:r,mapMembers(t,r){let n=t(this.members);return e(pC(n,this.ast.mode,r?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}(pC(e,t?.mode??"anyOf",void 0),e)}function gi(e){let t=e.map(m1);return mY(pC(t,"anyOf",void 0),{literals:e,members:t,mapMembers(e){return gn(e(this.members))},pick:e=>gi(e),transform:e=>gn(t.map((t,r)=>t.transform(e[r])))})}let gs=e=>gn([e,m3]);function ga(e){return mY(new pP(()=>e().ast))}function go(e,t){return r=>mY(pY(r.ast,[new pD(t=>e(t)?void 0:new hm(rk(t)),t,!0)]),{schema:r})}function gl(e,t){return r=>{var n,i,s;let a;return mY((n=r.ast,i=e.ast,s=t?hq(t):hV,a=new h8(n,s),pK(i,i.encoding?[...i.encoding,a]:[a])),{from:r,to:e})}}function gc(e){return am(e,e=>lU(()=>sf(e,e=>e.issue)))}function gu(e,t){let r=t?.encodingStrategy==="omit"?new hM(()=>sU):hN;return t=>mH(mZ(t)).pipe(gl(t,{decode:hP(gc(e)),encode:r}))}function gd(e){var t;return m1(e).pipe((t=lD(e),e=>{var r;let n,i;return mY((r=e.ast,n=[new h8(ps,new hB(hP(gc(t)),hN))],i=r.context?new h9(r.context.isOptional,r.context.isMutable,n,r.context.annotations):new h9(!1,!1,n),pz(r,i)),{schema:e})}))}let gf=pU;function gh(e){return gf(e=>globalThis.Number.isFinite(e),{expected:"a finite number",meta:{_tag:"isFinite"},arbitrary:{constraint:{noInfinity:!0,noNaN:!0}},...e})}let gp=(F=rv((er={order:rg,annotate:e=>({meta:{_tag:"isGreaterThan",exclusiveMinimum:e}})}).order),L=er.formatter??tr,(e,t)=>gf(t=>F(t,e),{expected:`a value greater than ${L(e)}`,arbitrary:{constraint:{ordered:{order:er.order,minimum:e,exclusiveMinimum:!0}}},...er.annotate?.(e),...t})),gm=(W=(J=(G={order:rg,annotate:e=>({meta:{_tag:"isGreaterThanOrEqualTo",minimum:e}})}).order,el(2,(e,t)=>-1!==J(e,t))),Y=G.formatter??tr,(e,t)=>gf(t=>W(t,e),{expected:`a value greater than or equal to ${Y(e)}`,arbitrary:{constraint:{ordered:{order:G.order,minimum:e}}},...G.annotate?.(e),...t}));function gg(e,t){return e=Math.max(0,Math.floor(e)),gf(t=>t.length>=e,{expected:`a value with a length of at least ${e}`,meta:{_tag:"isMinLength",minLength:e},[mm]:!0,arbitrary:{constraint:{minLength:e}},...t})}let gy=m5.check(gg(1,void 0)),gb=[];function gv(e){var t;let r,n,i=e?.includeStack===!0|2*(e?.excludeCause===!0),s=gb[i];if(void 0!==s)return s;let a=gL.pipe(gl(m2,hz({decode:hY,encode:(t=(e=>{switch(e){case 0:return;case 1:return{includeStack:!0};case 2:return{excludeCause:!0};case 3:return{includeStack:!0,excludeCause:!0}}})(i),r=new WeakSet,n=e=>{if(e instanceof Error){var i;let s;if(r.has(e))return"[Circular]";r.add(e);let a=(i=n,s={name:e.name,message:"string"==typeof e.message?e.message:""},t?.includeStack&&"string"==typeof e.stack&&(s.stack=e.stack),t?.excludeCause||void 0===e.cause||(s.cause=i(e.cause)),s);return r.delete(e),a}try{let t=ta(e);return void 0===t?tr(e):JSON.parse(t)}catch{return tr(e)}})})));return gb[i]=a,a}gf(e=>!isNaN(e.getTime()),{expected:"a valid date",meta:{_tag:"isDateValid"},arbitrary:{constraint:{valid:!0}},...void 0});let gw=m4.check(gh()),gx=m4.check(gf(e=>globalThis.Number.isSafeInteger(e),{expected:"an integer",meta:{_tag:"isInt"},arbitrary:{constraint:{integer:!0}},...void 0})),gk=gn([gw,m6,m5]),gS=globalThis.Symbol.for("immer-draftable"),g_={};function g$(e,t,r,n,i){var s,a,o;let l,c=(s=r,a=t,o=n,e=>{if(void 0!==l)return l;let t=new hB(hF(t=>new e(t)),hN);return l=gl(mY(new pt([s.ast],()=>(t,r)=>t instanceof e||eT(t,gO(a))?lD(t):tJ(new hp(r,rk(t))),{identifier:a,[mp]:([e])=>new h8(e,t),toCodec:([e])=>new h8(e.ast,t),toArbitrary:([t])=>()=>({arbitrary:t.arbitrary.map(t=>new e(t)),terminal:t.terminal?.map(t=>new e(t))}),toFormatter:([t])=>r=>`${e.identifier}(${t(r)})`,"~sentinels":pE(s.ast),...o})),t)(s)}),u=gO(t),d=class extends e{constructor(...[e,t]){let n=t?.["~payload"],i=n?.token===g_?n.value:r.make(e??{},t);super(i,{...t,disableChecks:!0,"~payload":{token:g_,value:i}})}static [mE]=mE;get[u](){return u}static [gS]=!0;static identifier=t;static fields=r.fields;static get ast(){return c(this).ast}static pipe(){return es(this,arguments)}static rebuild(e){return c(this).rebuild(e)}static make(e,t){return new this(e,t)}static makeOption(e,t){return mk(c(this))(e??{},t)}static makeEffect(e,t){return c(this).makeEffect(e??{},t)}static annotate(e){return this.rebuild(pJ(this.ast,e))}static annotateKey(e){return this.rebuild(pX(this.ast,e))}static check(...e){return this.rebuild(pY(this.ast,e))}static extend(e){return(t,n)=>{let s=gI(t)?t:m7(t),a={...r.fields,...s.fields},o=pO(a,r.ast.checks,{identifier:e});return g$(this,e,m9(pY(o,s.ast.checks),a),n,i)}}static mapFields(e,t){return r.mapFields(e,t)}};return void 0!==i&&Object.assign(d.prototype,i(t)),d}function gO(e){return`~effect/Schema/Class/${e}`}function gI(e){return eT(e,mE)&&e[mE]===mE}let gC=e=>(t,r)=>g$(l5,e,gI(t)?t:m7(t),r,e=>({toString(){return`${e}(${tr({...this})})`}})),gE=e=>(t,r)=>g$(tH,e,gI(t)?t:m7(t),r,e=>({name:e})),gA=e=>(t,r,n)=>{let i=gI(r)?r.mapFields(e=>({_tag:gd(t),...e}),{unsafePreserveChecks:!0}):m7({_tag:gd(t),...r});return gE(e??t)(i,n)},gT=mj(function(e){switch(e._tag){case"Null":case"Boolean":case"Number":case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}}),gM=new h8(new pa("null"),new hB(hF(()=>null),hF(()=>"null"))),gN=new h8(new pM([new pa("true"),new pa("false")],"anyOf"),new hB(hF(e=>"true"===e),hD())),gj=pQ(e=>{if(h4(e)&&e.annotations?.["~effect/Schema/SERIALIZER_ENSURE_ARRAY"]===!0)return e;let t=function(e,t,r){switch(e._tag){case"Declaration":{let n=e.annotations?.toCodecJson??e.annotations?.toCodec;if(e_(n)){let r=n(hH(e)?e.typeParameters.map(e=>mY(t(p8(e)))):[]),i=t(r.to);return pK(e,i===r.to?[r]:[new h8(i,r.transformation)])}return r(e)}case"Null":return pK(e,[gM]);case"Boolean":return pK(e,[gN]);case"Unknown":case"ObjectKeyword":return pK(e,[my]);case"Enum":case"Number":case"Literal":case"UniqueSymbol":case"Symbol":case"BigInt":return e.toCodecStringTree();case"Objects":if(e.propertySignatures.some(e=>"string"!=typeof e.name))throw new globalThis.Error("Objects property names must be strings",{cause:e});return e.recur(t,mr);case"Union":{let r=gT(e.types);if(r!==e.types)return new pM(r,e.mode,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t);return e.recur(t)}case"Arrays":case"Suspend":return e.recur(t)}return e}(e,gj,e=>pK(e,[gF]));return t!==e&&p5(e)?p0(t):t}),gF=new h8(pi,new hB(hN,hF(()=>void 0))),gL=mY(mg),gP="~effect/platform/Terminal",gD="effect/platform/Terminal/QuitError";class gR extends gE("QuitError")({_tag:gd("QuitError")}){[gD]=gD}let gU=nQ("effect/platform/Terminal"),gB=t("node:readline"),gq=sG(function*(e=gK){let t,r,n=process.stdin,i=process.stdout,s=yield*(t={acquire:lz(sL(()=>{let e=gB.createInterface({input:n,escapeCodeTimeout:50});return gB.emitKeypressEvents(n,e),n.isTTY&&n.setRawMode(!0),e}),e=>sL(()=>{n.isTTY&&n.setRawMode(!1),e.close()}))},tY(e=>{let r=e.context,n=n7(r,aR),i=new dV(t.acquire,r,n,t.idleTimeToLive?ig(t.idleTimeToLive):void 0);return s1(aK(n,()=>{let e="Acquired"===i.state._tag?aU(i.state.scope,ai):sK;return i.state=dK,e}),i)})),a=sL(()=>i.columns??0),o=sL(()=>i.rows??0),l=lR(function*(){let t;yield*dJ(s);let r=yield*cd(),i=(t,n)=>{let i={input:rP(t),key:{name:n.name??"",ctrl:!!n.ctrl,meta:!!n.meta,shift:!!n.shift}};ch(r,i),e(i)&&cg(r)};return yield*(t=()=>sL(()=>n.off("keypress",i)),s8(aR,e=>au(r=>aK(e,e=>ad(t(),r))))),n.on("keypress",i),r});return r={columns:a,rows:o,readInput:l,readLine:lK(s8(dJ(s),e=>sW(t=>{let r=e=>t(lD(e));return e.once("line",r),sL(()=>e.off("line",r))}))),display:e=>a2(sW(t=>{i.write(e,e=>null==e?t(sK):t(tJ(cn({module:"Terminal",method:"display",description:"Failed to write prompt to stdout",cause:e}))))}))},gU.of({...r,[gP]:gP})});function gK(e){return e.key.ctrl&&("c"===e.key.name||"d"===e.key.name)}let gz=lE(uQ,lO(dN,u8,dP,dU,lk(gU,gq(gK)))),gV=/[,;]\s*(?:id|label|kind|group|source|target|title|direction|nodes|edges)\s*:?\s*$/i;function gJ(e){let t=e.trim();for(;;){let e=t.replace(gV,"").trim();if(e===t)return t;t=e}}class gW extends gC("ContractSchemaIssue")({code:g9("custom"),message:m5,path:gt(gk)},{identifier:void 0}){}class gY extends gA()("ContractSchemaError",{issues:gt(mZ(gW))}){}let gG=e=>{var t;if("InvalidType"!==e._tag)return hw(e);let r=r$(e.actual)?e.actual.value:void 0;return`Invalid input: expected ${hZ(t=e.ast)?"string":hX(t)?"number":h0(t)?"boolean":h3(t)?"array":h5(t)?"object":h1(t)?JSON.stringify(t.literal):"value"}, received ${null===r?"null":Array.isArray(r)?"array":typeof r}`},gH=hk({leafHook:gG});function gQ(e){return"string"==typeof e||"number"==typeof e||"symbol"==typeof e}function gZ(e,t){let r,n=mW(e,{errors:"all"})(t);return rf(n)?{data:n.success,success:!0}:{error:new gY({issues:(r=gH(n.failure.issue).issues.map(e=>{let t=(e.path??[]).flatMap(e=>{let t=gQ(e)?e:null!==e&&"object"==typeof e&&"key"in e&&gQ(e.key)?e.key:void 0;return void 0===t?[]:[t]});return{code:"custom",message:e.message,path:e.message.startsWith("Invalid discriminator value.")?[...t,"op"]:t}})).length>1&&r.every(e=>"source"===e.path[0])?[{code:"custom",message:"Invalid input",path:["source"]}]:r}),success:!1}}function gX(e){return Object.assign(e,{parse:t=>(function(e,t){let r=gZ(e,t);if(r.success)return r.data;throw r.error})(e,t),safeParse:t=>gZ(e,t)})}let g0=new Set(["const","exclusiveMaximum","exclusiveMinimum","maximum","maxLength","minimum","minItems","minLength","pattern"]);function g1(e){var t,r;let n,i,s=(t=mY(p4((n=e).ast),{schema:n}),r={includeAnnotationKey:e=>g0.has(e)},{dialect:"draft-2020-12",schema:(i=function(e,t){let{definitions:r,dialect:n,schemas:i}=function(e,t){let r=t?.generateDescriptions??!1,n=t?.additionalProperties??!1,i=t?.includeAnnotationKey,s=nv(e.references,e=>a(e));return{dialect:"draft-2020-12",schemas:nR(e.representations,e=>a(e)),definitions:s};function a(t){let r=function(t){switch(t._tag){case"Any":case"Unknown":return{};case"ObjectKeyword":return{anyOf:[{type:"object"},{type:"array"}]};case"Void":case"Undefined":case"Null":return{type:"null"};case"BigInt":return{type:"string",allOf:[{pattern:"^-?\\d+$"}]};case"Symbol":case"UniqueSymbol":return{type:"string",allOf:[{pattern:"^Symbol\\((.*)\\)$"}]};case"Declaration":return a(t.encodedSchema);case"Suspend":return a(t.thunk);case"Reference":return{$ref:`#/$defs/${t.$ref.replace(/~/g,"~0").replace(/\//g,"~1")}`};case"Never":return{not:{}};case"String":{let e={type:"string"};return void 0!==t.contentMediaType&&(e.contentMediaType=t.contentMediaType),void 0!==t.contentSchema&&(e.contentSchema=a(t.contentSchema)),e}case"Number":return mD(t.checks,"isInt")?{type:"integer"}:mD(t.checks,"isFinite")?{type:"number"}:{anyOf:[{type:"number"},{type:"string",enum:["NaN"]},{type:"string",enum:["Infinity"]},{type:"string",enum:["-Infinity"]}]};case"Boolean":return{type:"boolean"};case"Literal":{let e=t.literal;if("string"==typeof e)return{type:"string",enum:[e]};if("number"==typeof e)return{type:"number",enum:[e]};if("boolean"==typeof e)return{type:"boolean",enum:[e]};return{type:"string",enum:[String(e)]}}case"Enum":return a({_tag:"Union",types:t.enums.map(([e,t])=>({_tag:"Literal",literal:t,annotations:{title:e}})),mode:"anyOf",annotations:t.annotations});case"TemplateLiteral":{let e=t.parts.map(mU).join("");return{type:"string",pattern:`^${e}$`}}case"Arrays":{if(t.rest.length>1)throw new globalThis.Error("Generating a JSON Schema for post-rest elements is not supported");let e={type:"array"},r=t.elements.length,n=t.elements.map(e=>{e.isOptional&&r--;let t=a(e.type),n=o(e.annotations);return n?mR(t,n):t});if(n.length>0?(e.prefixItems=n,e.maxItems=t.elements.length,r>0&&(e.minItems=r)):e.items=!1,t.rest.length>0){delete e.maxItems;let r=a(t.rest[0]);Object.keys(r).length>0?e.items=r:delete e.items}return e}case"Objects":{if(0===t.propertySignatures.length&&0===t.indexSignatures.length)return{anyOf:[{type:"object"},{type:"array"}]};let r={type:"object"},i={},s=[];for(let e of t.propertySignatures){let t=e.name;if("string"!=typeof t)throw new globalThis.Error(`Unsupported property signature name: ${tr(t)}`);let r=a(e.type),n=o(e.annotations);i[t]=n?mR(r,n):r,e.isOptional||s.push(t)}Object.keys(i).length>0&&(r.properties=i),s.length>0&&(r.required=s),r.additionalProperties=n;let l={};for(let n of t.indexSignatures){let t=a(n.type);1===Object.keys(t).length&&"not"in t&&(t=!1);let i=function t(r){switch(r._tag){default:throw new globalThis.Error(`Unsupported index signature parameter: ${r._tag}`);case"Reference":return t(e.references[r.$ref]);case"String":return function e(t){return t.flatMap(t=>{switch(t._tag){case"Filter":if("regExp"in t.meta)return[t.meta.regExp.source];return[];case"FilterGroup":return e(t.checks)}})}(r.checks);case"TemplateLiteral":return[`^${r.parts.map(mU).join("")}$`];case"Union":return r.types.flatMap(t)}}(n.parameter);if(i.length>0)for(let e of i)l[e]=t;else r.additionalProperties=t}return Object.keys(l).length>0&&(r.patternProperties=l,delete r.additionalProperties),eA(r.additionalProperties)&&nb(r.additionalProperties)&&delete r.additionalProperties,r}case"Union":{let e=t.types.map(a);if(0===e.length)return{not:{}};if(e.length>1){let t=function(e){let t,r=[];for(let n of e){if(2!==Object.keys(n).length||void 0===n.type||!Array.isArray(n.enum)||0===n.enum.length)return;if(void 0===t)t=n.type;else if(n.type!==t)return;for(let e of n.enum)r.push(e)}return{type:t,enum:r}}(e);if(t)return t}return"anyOf"===t.mode?{anyOf:e}:{oneOf:e}}}}(t);if("annotations"in t){let e=o(t.annotations);e&&(r={...r,...e})}if("checks"in t){var i,s;for(let e of(i=t.checks,s=r.type,i.map(function e(t){switch(t._tag){case"Filter":var r=t,n=s;let i=r.meta;if(!i)return;let l=function(e){switch(e._tag){case"isMinLength":return"array"===n?{minItems:e.minLength}:{minLength:e.minLength};case"isMaxLength":return"array"===n?{maxItems:e.maxLength}:{maxLength:e.maxLength};case"isLengthBetween":return"array"===n?{allOf:[{minItems:e.minimum},{maxItems:e.maximum}]}:{allOf:[{minLength:e.minimum},{maxLength:e.maximum}]};case"isPattern":case"isGUID":case"isULID":case"isBase64":case"isBase64Url":case"isStartsWith":case"isEndsWith":case"isIncludes":case"isUppercased":case"isLowercased":case"isCapitalized":case"isUncapitalized":case"isTrimmed":case"isStringFinite":case"isStringBigInt":case"isStringSymbol":return{pattern:e.regExp.source};case"isUUID":return{pattern:e.regExp.source,format:"uuid"};case"isFinite":case"isInt":return;case"isMultipleOf":return{multipleOf:e.divisor};case"isGreaterThanOrEqualTo":return{minimum:e.minimum};case"isLessThanOrEqualTo":return{maximum:e.maximum};case"isGreaterThan":return{exclusiveMinimum:e.exclusiveMinimum};case"isLessThan":return{exclusiveMaximum:e.exclusiveMaximum};case"isBetween":return{[e.exclusiveMinimum?"exclusiveMinimum":"minimum"]:e.minimum,[e.exclusiveMaximum?"exclusiveMaximum":"maximum"]:e.maximum};case"isUnique":return{uniqueItems:!0};case"isMinProperties":return{minProperties:e.minProperties};case"isMaxProperties":return{maxProperties:e.maxProperties};case"isPropertiesLengthBetween":return{minProperties:e.minimum,maxProperties:e.maximum};case"isPropertyNames":return{propertyNames:a(e.propertyNames)};case"isDateValid":return{format:"date-time"}}}(i),c=o(r.annotations);return c&&(l={...l,...c}),l;case"FilterGroup":{let r=t.checks.map(e).filter(e=>void 0!==e);if(0===r.length)return;let n={allOf:r},i=o(t.annotations);return i&&(n={...n,...i}),n}}}).filter(e=>void 0!==e)))r=mR(r,e)}return r}function o(e){if(void 0===e)return;let t={};if("string"==typeof e.title&&(t.title=e.title),"string"==typeof e.description?t.description=e.description:r&&"string"==typeof e.expected&&(t.description=e.expected),void 0!==e.default&&(t.default=e.default),Array.isArray(e.examples)&&(t.examples=e.examples),"boolean"==typeof e.readOnly&&(t.readOnly=e.readOnly),"boolean"==typeof e.writeOnly&&(t.writeOnly=e.writeOnly),"string"==typeof e.format&&(t.format=e.format),"string"==typeof e.contentEncoding&&(t.contentEncoding=e.contentEncoding),"string"==typeof e.contentMediaType&&(t.contentMediaType=e.contentMediaType),i)for(let[r,n]of Object.entries(e))!(void 0===n||mL.has(r))&&i(r)&&(t[r]=n);if(Object.keys(t).length>0)return t}}({representations:[e.representation],references:e.references},t);return{dialect:n,schema:i[0],definitions:r}}(function(e){let{references:t,representations:r}=function(e){let t={},r=new Map,n=new Set,i=new Set;return{representations:nR(e,e=>a(e)),references:t};function s(e){let t=e,r=0;for(;n.has(t);)t=`${e}${++r}`;return n.add(t),t}function a(e,n){let l=r.get(e);if(void 0!==l)return{_tag:"Reference",$ref:l};let c=pV(e),u=hi(e)??n;if(e!==c)return a(c,u);if(void 0!==u){let n=s(u);r.set(e,n);let i=o(e),a=t[u];return void 0!==a&&eZ(i,a)?(r.set(e,u),{_tag:"Reference",$ref:u}):(t[n]=i,{_tag:"Reference",$ref:n})}if(i.has(e)){let t=s(`${e._tag}_`);return r.set(e,t),{_tag:"Reference",$ref:t}}i.add(e);let d=o(e);i.delete(e);let f=r.get(e);return void 0!==f?(t[f]=d,{_tag:"Reference",$ref:f}):d}function o(e){var t;let r=mP(e.annotations);switch(e._tag){case"Declaration":{let t,n=a(e_(t=e.annotations?.toCodecJson??e.annotations?.toCodec)?pK(e,[t(e.typeParameters.map(e=>mT(p8(e))))]):pr);return{_tag:"Declaration",typeParameters:e.typeParameters.map(e=>a(e)),encodedSchema:n,checks:l(e.checks),...r}}case"Null":case"Undefined":case"Void":case"Never":case"Unknown":case"Any":case"Boolean":case"Symbol":case"ObjectKeyword":return{_tag:e._tag,...r};case"String":{let n=e.annotations?.contentMediaType,i=e.annotations?.contentSchema;return{_tag:e._tag,checks:l(e.checks),...r,..."string"==typeof n&&eT(t=i,h7)&&t[h7]===h7?{contentSchema:a(i)}:void 0}}case"Number":case"BigInt":return{_tag:e._tag,checks:l(e.checks),...r};case"Literal":return{_tag:e._tag,literal:e.literal,...r};case"UniqueSymbol":return{_tag:e._tag,symbol:e.symbol,...r};case"Enum":return{_tag:e._tag,enums:e.enums,...r};case"TemplateLiteral":return{_tag:e._tag,parts:e.parts.map(e=>a(e)),...r};case"Arrays":return{_tag:e._tag,elements:e.elements.map(e=>{let t=pV(e);return{isOptional:p5(t),type:a(e),...mP(t.context?.annotations)}}),rest:e.rest.map(e=>a(e)),checks:l(e.checks),...r};case"Objects":return{_tag:e._tag,propertySignatures:e.propertySignatures.map(e=>{let t=pV(e.type);return{name:e.name,type:a(e.type),isOptional:p5(t),isMutable:t.context?.isMutable??!1,...mP(t.context?.annotations)}}),indexSignatures:e.indexSignatures.map(e=>({parameter:a(e.parameter),type:a(e.type)})),checks:l(e.checks),...r};case"Union":{let t=mN(e.types);return{_tag:e._tag,types:t.map(e=>a(e)),mode:e.mode,...r}}case"Suspend":return{_tag:"Suspend",checks:[],thunk:a(e.thunk()),...r}}}function l(e){return e?e.map(function(e){switch(e._tag){case"Filter":{let t=e.annotations?.meta;if(t)return{_tag:"Filter",meta:"isPropertyNames"===t._tag?{_tag:"isPropertyNames",propertyNames:a(t.propertyNames)}:t,...mP(e.annotations)};return}case"FilterGroup":{let t=l(e.checks);if(t4(t))return{_tag:"FilterGroup",checks:t,...mP(e.annotations)}}}}).filter(e=>void 0!==e):[]}}([e]);return{representation:r[0],references:t}}(t.ast),r)).schema,definitions:i.definitions});return{$schema:"https://json-schema.org/draft/2020-12/schema",...s.schema,...0===Object.keys(s.definitions).length?{}:{$defs:s.definitions}}}function g2(e){return gt(e).pipe(gr).annotate({minItems:1}).check(gf(e=>e.length>=1,{message:"Too small: expected array to have >=1 items"}))}function g3(e){return mG(mB()([e],([e])=>(t,r,n)=>void 0===t?lD(void 0):mS(e)(t,n),{toCodecJson:([e])=>{let t,r;return t=e,r={decode:hN,encode:new hM(e=>lD(nt(e,e=>void 0!==e)))},new h8(t.ast,hq(r))}}))}function g5(e){return e.pipe(mK({messageMissingKey:"Invalid input: expected string, received undefined"}))}function g4(e){return e.pipe(mK({messageMissingKey:"Invalid input: expected object, received undefined"}))}function g8(e){return e.pipe(mK({messageMissingKey:"Invalid input: expected array, received undefined"}))}function g6(e){return gi(e).annotate({message:`Invalid option: expected one of ${e.map(e=>JSON.stringify(e)).join("|")}`})}function g9(e){return m1(e).pipe(gl(m5.annotate({const:e}).pipe(go(t=>t===e,{message:`Invalid literal value, expected ${JSON.stringify(e)}`}))))}function g7(e){return m1(e).pipe(gl(m4.annotate({const:e}).pipe(go(t=>t===e,{message:`Invalid literal value, expected ${JSON.stringify(e)}`}))))}function ye(e){return m1(e).pipe(gl(m8.annotate({const:e}).pipe(go(t=>t===e,{message:`Invalid literal value, expected ${JSON.stringify(e)}`}))))}let yt=m5.annotate({minLength:1}).check(gf(e=>e.length>=1,{message:"Too small: expected string to have >=1 characters"})),yr=g5(yt),yn=gw,yi=m4.annotate({exclusiveMinimum:0}).check(gh(),gf(e=>e>0,{message:"Too small: expected number to be >0"})),ys=/^#[0-9a-fA-F]{6}$/;function ya(e){return m5.annotate({pattern:ys.source,...void 0===e?{}:{default:e}}).check(gf(e=>ys.test(e),{message:`Invalid string: must match pattern /${ys.source}/`}))}let yo=ya();gX(yo);let yl=["excalidraw","scene","png"],yc=["excalidraw","scene"],yu=Object.assign(gX(g6(yl)),{options:yl}),yd=Object.assign(gX(g6(yc)),{options:yc});class yf extends gC("ArtifactProvenance")({sourceArtifactId:yr.pipe(mQ)},{identifier:void 0}){}gX(yf);let yh=["missing_field","invalid_type","invalid_enum","invalid_color","duplicate_node_id","duplicate_edge_id","missing_edge_source","missing_edge_target","self_loop","missing_start","multiple_starts","missing_end","start_has_incoming","end_has_outgoing","unreachable_node","nonterminating_node","missing_outgoing_edge","underbranched_decision","unlabeled_decision_branch","duplicate_decision_branch_label","disconnected_graph","flowchart_too_large","mindmap_too_deep","mindmap_too_large","request_too_large","generic_label","label_too_long","quality_below_threshold","render_failed","text_overflow","arrow_binding_invalid","arrow_overlap","export_invalid_scene","storage_read_failed","storage_write_failed","unsupported_artifact_format","patch_source_unavailable","unknown_patch_target","unsupported_patch_operation","patch_preserve_connectivity_failed","patch_output_invalid"],yp=Object.assign(gX(g6(yh)),{options:yh}),ym=g6(["request","diagram","node","edge","artifact"]),yg=g6(["input","flowchart","mindmap","quality","render","export","storage"]);class yy extends gC("CodeModeIssueRef")({kind:ym,id:g3(yt),path:g3(yt)},{identifier:void 0}){}gX(yy);class yb extends gC("CodeModeIssue")({code:yp,severity:g6(["error","warning"]),stage:yg,ref:g3(yy),message:yr,hint:yr},{identifier:void 0}){}gX(yb);let yv=["start","process","decision","end"],yw=Object.assign(gX(g6(yv)),{options:yv}),yx=["setDefaultStyle","setStyle","setShape","translate","replaceText","rerouteEdges"];Object.assign(gX(g6(yx)),{options:yx});class yk extends gC("FlowchartSpecNode")({id:yr,label:yr,kind:yw,description:g3(yt)},{identifier:void 0}){}class yS extends gC("FlowchartSpecEdge")({id:g3(yt),source:yr,target:yr,label:g3(yt)},{identifier:void 0}){}let y_=g6(["TB","LR"]),y$=y_.annotate({default:"TB"}).pipe(gu(lD("TB")));class yO extends gC("FlowchartSpecLayout")({direction:y$},{identifier:void 0}){}let yI="#000000",yC=ya(yI).pipe(gu(lD(yI))),yE="#ffffff",yA=ya(yE).pipe(gu(lD(yE)));class yT extends gC("FlowchartSpecStyle")({accentColor:yC,backgroundColor:yA},{identifier:void 0}){}let yM=[],yN=gt(yS).pipe(gr).annotate({default:yM}).pipe(gu(lD(yM))),yj={direction:"TB"},yF=yO.annotate({default:yj}).pipe(gu(lD(yj))),yL={accentColor:"#000000",backgroundColor:"#ffffff"},yP=yT.annotate({default:yL}).pipe(gu(lD(yL)));class yD extends gC("FlowchartSpec")({id:g3(yt),title:yr,nodes:g8(g2(yk)),edges:yN,layout:yF,style:yP},{identifier:void 0}){}gX(yD),gX(yk),gX(yS),gX(yO),gX(yT);let yR=g3(g2(yu)),yU=g3(gt(yd).pipe(gr)),yB=g3(m4.annotate({minimum:0,maximum:10}).check(gh(),gf(e=>e>=0,{message:"Too small: expected number to be >=0"}),gf(e=>e<=10,{message:"Too big: expected number to be <=10"})));class yq extends gC("BuildFlowchartOptions")({artifactFormats:yR,inlineArtifacts:yU,minQualityScore:yB},{identifier:void 0}){}gX(g3(yq));class yK extends gC("BuildFlowchartRequest")({requestId:g3(yt),spec:g4(yD),options:g3(yq)},{identifier:void 0}){}let yz=yK.mapFields(({requestId:e,spec:t})=>({requestId:e,spec:t})),yV=(en={leafHook:gG,parseOptions:{errors:"all"}},P=mS(yz),D={errors:"all",...en?.parseOptions},R=hk(en),U=e=>{let t=new iz,r=oc(aM(P(e,D),{onFailure:R,onSuccess:e=>({value:e})}),{scheduler:t});r.currentDispatcher?.flush();let n=r.pollUnsafe();return n?mz(n):new Promise(e=>{r.addObserver(t=>{e(mz(t))})})},"~standard"in yz?("validate"in yz["~standard"]||Object.assign(yz["~standard"],{validate:U}),yz):Object.assign(yz,{"~standard":{version:1,vendor:"effect",validate:U}}));Object.assign(yV["~standard"],{jsonSchema:{input:()=>g1(yz),output:()=>g1(yz)}});let yJ=Object.assign(gX(yK),{omit:e=>yV}),yW=m5.annotate({minLength:1}).check(gf(e=>e.length>=1,{message:"Too small: expected string to have >=1 characters"}),gf(function(e){let t=gJ(e);return t.length>0&&!/^(?:""|''|``)$/.test(t)},{message:"Must contain semantic text after normalization."})),yY=g4(ga(()=>yG).annotate({identifier:"__schema0"})),yG=m7({label:g5(yW),children:mG(gt(yY).pipe(gr))});gX(yY);class yH extends gC("MindmapSpecLayout")({direction:g6(["LR","RL"]).annotate({default:"LR"}).pipe(gu(lD("LR")))},{identifier:void 0}){}let yQ={direction:"LR"},yZ=yH.annotate({default:yQ}).pipe(gu(lD(yQ))),yX={accentColor:"#7c3aed",backgroundColor:"#ffffff"},y0=yT.annotate({default:yX}).pipe(gu(lD(yX))),y1=m7({id:g3(yt),title:g5(yW),root:yY,layout:yZ,style:y0});class y2 extends gC("MindmapSpec")(y1,{identifier:void 0}){}gX(y2);let y3=m7({requestId:g3(yt),spec:g4(y1),options:g3(yq)});gC("BuildMindmapRequest")(y3,{identifier:void 0});let y5=gX(y3);class y4 extends gC("ScenePoint")({x:yn.pipe(mQ),y:yn.pipe(mQ)},{identifier:void 0}){}gX(y4);class y8 extends gC("NodeSceneElement")({type:g9("node"),id:yr,nodeId:yr,kind:g3(yt),shape:g6(["rectangle","ellipse","diamond","circle"]).pipe(mQ),fillColor:g3(yo).pipe(mQ),strokeColor:g3(yo).pipe(mQ),textColor:g3(yo).pipe(mQ),x:yn.pipe(mQ),y:yn.pipe(mQ),width:yi.pipe(mQ),height:yi.pipe(mQ),label:yr.pipe(mQ)},{identifier:void 0}){}class y6 extends gC("TextSceneElement")({type:g9("text"),id:yr,containerId:g3(yt),textColor:g3(yo).pipe(mQ),x:yn.pipe(mQ),y:yn.pipe(mQ),text:yr.pipe(mQ),fontSize:yi,maxWidth:g3(yi)},{identifier:void 0}){}class y9 extends gC("ArrowSceneElement")({type:g9("arrow"),id:yr,edgeId:yr,sourceNodeId:yr,targetNodeId:yr.pipe(mQ),strokeColor:g3(yo).pipe(mQ),textColor:g3(yo).pipe(mQ),points:g8(gt(y4).pipe(gr)).annotate({minItems:2}).check(gf(e=>e.length>=2,{message:"Too small: expected array to have >=2 items"})).pipe(mQ),label:g3(yt).pipe(mQ)},{identifier:void 0}){}gX(y8),gX(y6),gX(y9);let y7=gn([y8,y6,y9],{mode:"oneOf"});class be extends gC("RenderedDiagramScene")({diagramId:yr,title:yr,width:yi.pipe(mQ),height:yi.pipe(mQ),accentColor:yo.pipe(mQ),backgroundColor:yo.pipe(mQ),elements:g8(gt(y7).pipe(gr))},{identifier:void 0}){}let bt=gX(be),br=ge(m5,m2).check(gf(e=>"string"==typeof e.id&&e.id.length>0&&"string"==typeof e.type&&e.type.length>0,{message:"Invalid input"}));gX(br);class bn extends gC("ExcalidrawScene")({appState:ge(m5,m2),elements:gt(br).pipe(gr)},{identifier:void 0}){}gX(bn);class bi extends bn.extend("ExcalidrawFile")({files:ge(m5,m2),source:yr,type:g9("excalidraw"),version:g7(2)},{identifier:void 0}){}let bs=gX(bi);class ba extends gC("GetArtifactRequest")({artifactId:yr,format:g3(yu),inline:g3(m8)},{identifier:void 0}){}let bo=gX(ba);class bl extends gC("DiagramSelector")({ids:g3(gt(yt).pipe(gr)),nodeIds:g3(gt(yt).pipe(gr)),edgeIds:g3(gt(yt).pipe(gr)),kinds:g3(gt(yw).pipe(gr)),labels:g3(gt(yt).pipe(gr)),scope:g3(g6(["all","nodes","edges"]))},{identifier:void 0}){}gX(bl);class bc extends gC("DiagramStylePatch")({strokeColor:g3(yo),fillColor:g3(yo),textColor:g3(yo),backgroundColor:g3(yo)},{identifier:void 0}){}gX(bc);let bu=["rectangle","diamond","ellipse","circle"],bd=Object.assign(gX(g6(bu)),{options:bu});class bf extends gC("SetDefaultStyleOperation")({op:g9("setDefaultStyle"),style:g4(bc)},{identifier:void 0}){}class bh extends gC("SetStyleOperation")({op:g9("setStyle"),selector:g4(bl),style:g4(bc)},{identifier:void 0}){}class bp extends gC("SetShapeOperation")({op:g9("setShape"),selector:g4(bl),shape:bd},{identifier:void 0}){}class bm extends gC("TranslateOperation")({op:g9("translate"),selector:g4(bl),dx:yn,dy:yn},{identifier:void 0}){}class bg extends gC("ReplaceTextOperation")({op:g9("replaceText"),selector:g4(bl),text:yr},{identifier:void 0}){}class by extends gC("RerouteEdgesOperation")({op:g9("rerouteEdges"),selector:g3(bl)},{identifier:void 0}){}let bb=gn([bf,bh,bp,bm,bg,by],{mode:"oneOf"}).annotate({message:`Invalid discriminator value. Expected ${yx.map(e=>`'${e}'`).join(" | ")}`});class bv extends gC("ArtifactPatchSource")({artifactId:yr,format:g3(g9("scene"))},{identifier:void 0}){}class bw extends gC("InlineScenePatchSource")({scene:g4(be)},{identifier:void 0}){}let bx=gn([bv,bw]).annotate({message:"Invalid input"});class bk extends gC("ApplyDiagramPatchOptions")({artifactFormats:yR,inlineArtifacts:yU,preserveConnectivity:g3(m8)},{identifier:void 0}){}gX(g3(bk));class bS extends gC("ApplyDiagramPatchRequest")({requestId:g3(yt),source:bx.annotateKey({messageMissingKey:"Invalid input"}),operations:g8(g2(bb)).pipe(mq({minItems:1})),options:g3(bk),intent:g3(yt)},{identifier:void 0}){}let b_=gX(bS),b$=m7({id:yt,title:yt,nodes:gt(yk).pipe(gr),edges:gt(yS.mapFields(e=>({...e,id:yt}))).pipe(gr),layout:m7({direction:y_}),style:m7({accentColor:yo,backgroundColor:yo})}),bO=m7({id:yt,label:yt,children:gt(ga(()=>bO)).pipe(gr)}),bI=m7({id:yt,title:yt,root:bO,layout:m7({direction:g6(["LR","RL"])}),style:m7({accentColor:yo,backgroundColor:yo})}),bC=m7({code:m5,passed:m8,severity:g6(["error","warning"]),message:m5,refs:gt(yy).pipe(gr)}),bE=m7({accepted:m8,score:m4,threshold:m4,summary:m7({nodeCount:m4,edgeCount:m4}),checks:gt(bC).pipe(gr)}),bA=m7({format:yu,mimeType:m5,url:g3(m5),expiresAt:g3(m5),inline:g3(m2),sizeBytes:g3(m4)}),bT=m7({artifactId:m5,diagramId:m5,formats:gt(bA).pipe(gr),provenance:g3(yf),preview:g3(bA)}),bM=m7({artifactId:g3(m5),diagramId:g3(m5),formats:g3(gt(bA).pipe(gr))});class bN extends gC("BuildFlowchartAccepted")({ok:ye(!0),status:g9("accepted"),buildId:m5,requestId:g3(m5),normalizedSpec:b$,quality:bE,artifact:bT,issues:gt(yb).pipe(gr)},{identifier:void 0}){}class bj extends gC("BuildFlowchartRejected")({ok:ye(!1),status:g6(["invalid_input","invalid_flowchart","quality_failed","render_failed","export_failed","storage_failed"]),buildId:g3(m5),requestId:g3(m5),normalizedSpec:g3(b$),quality:g3(bE),partial:g3(bM),issues:gt(yb).pipe(gr)},{identifier:void 0}){}gn([bN,bj]);class bF extends gC("BuildMindmapAccepted")({ok:ye(!0),status:g9("accepted"),buildId:m5,requestId:g3(m5),normalizedSpec:bI,quality:bE,artifact:bT,issues:gt(yb).pipe(gr)},{identifier:void 0}){}class bL extends gC("BuildMindmapRejected")({ok:ye(!1),status:g6(["invalid_input","invalid_mindmap","quality_failed","render_failed","export_failed","storage_failed"]),buildId:g3(m5),requestId:g3(m5),normalizedSpec:g3(bI),quality:g3(bE),partial:g3(bM),issues:gt(yb).pipe(gr)},{identifier:void 0}){}gn([bF,bL]);class bP extends gC("GetArtifactAccepted")({ok:ye(!0),artifactId:m5,diagramId:m5,format:yu,mimeType:m5,url:g3(m5),expiresAt:g3(m5),inline:g3(m2),sizeBytes:g3(m4),provenance:g3(yf)},{identifier:void 0}){}class bD extends gC("GetArtifactRejected")({ok:ye(!1),status:g6(["invalid_input","not_found","format_unavailable","expired","storage_failed"]),issues:gt(yb).pipe(gr)},{identifier:void 0}){}gn([bP,bD]);class bR extends gC("ApplyDiagramPatchAccepted")({ok:ye(!0),status:g9("accepted"),patchId:m5,requestId:g3(m5),sourceArtifactId:g3(m5),artifact:bT,issues:gt(yb).pipe(gr)},{identifier:void 0}){}class bU extends gC("ApplyDiagramPatchRejected")({ok:ye(!1),status:g6(["invalid_input","source_unavailable","target_not_found","unsupported_operation","connectivity_changed","render_failed","export_failed","storage_failed"]),patchId:g3(m5),requestId:g3(m5),sourceArtifactId:g3(m5),partial:g3(bM),issues:gt(yb).pipe(gr)},{identifier:void 0}){}gn([bR,bU]);let bB=gi(["read","readManifest","write"]);class bq extends gA()("CodeModeArtifactStorageError",{cause:gv(),message:m5,operation:bB}){}class bK extends nQ()("@sketchi/diagram-agent/CodeModeArtifactStorage"){}let bz={excalidraw:"application/vnd.excalidraw+json",png:"image/png",scene:"application/vnd.sketchi.scene+json"};function bV(e){return"excalidraw"===e||"scene"===e}function bJ(e){return{format:e.format,mimeType:e.mimeType,sizeBytes:e.sizeBytes}}function bW(e){return structuredClone(e)}function bY(e){return new TextEncoder().encode(JSON.stringify(e)).length}function bG(e){return t=>{var r;return bq.make({cause:t,message:(r="write"===e?"Artifact storage failed.":"Artifact read failed.",t instanceof Error?t.message:r),operation:e})}}let bH=lk(bK)(lz(sL(function(){let e=new Map,t=new Map;return{close:sL(()=>{t.clear(),e.clear()}),storage:{read:lW("codeMode.artifacts.memory.read")(function*(e,r){return yield*sz({try:()=>{let n=t.get(`${e}:${r}`);return n?{...n,data:bW(n.data)}:null},catch:bG("read")})}),readManifest:lW("codeMode.artifacts.memory.readManifest")(function*(t){return yield*sz({try:()=>{let r=e.get(t);return r?bW(r):null},catch:bG("readManifest")})}),write:lW("codeMode.artifacts.memory.write")(function*(r){let n=yield*oA;return yield*sz({try:()=>{var i;let s,a=r.formats.map(bJ),o=r.provenance?bW(r.provenance):void 0,l={artifactId:r.artifactId,diagramId:r.diagramId,formats:a,...o?{provenance:o}:{},createdAt:new Date(n).toISOString()};for(let n of(e.set(r.artifactId,l),r.formats))t.set(`${r.artifactId}:${n.format}`,{...n,data:bW(n.data)});let c=r.formats.map(e=>{var t;return t=r.inlineFormats,{format:e.format,mimeType:e.mimeType,...bV(e.format)&&t.includes(e.format)?{inline:e.data}:{},sizeBytes:e.sizeBytes}});return s=(i={artifactId:r.artifactId,diagramId:r.diagramId,formats:c,...r.provenance?{provenance:bW(r.provenance)}:{}}).formats.find(e=>"scene"===e.format),{artifactId:i.artifactId,diagramId:i.diagramId,formats:i.formats,...i.provenance?{provenance:i.provenance}:{},...s?{preview:s}:{}}},catch:bG("write")})})}}}),e=>e.close).pipe(ae(e=>e.storage)));function bQ(e,t="storage_write_failed"){return{code:t,severity:"error",stage:"storage",message:e,hint:"Retry the request; if it keeps failing, inspect the artifact store binding."}}let bZ=gy,bX=ge(m5,m2);function b0(e,t){return e.pipe(gu(lD(t)))}function b1(e,t){let r;return(r=mJ(e,{errors:"all"}),(e,t)=>(function(e){let t=ou(e);if("Success"===t._tag)return t.value;throw function(e,t){let r;for(let n of e.reasons){if(!tL(n)||!eT(n.error,mb))throw new globalThis.Error(t,{cause:e});r??=n.error}if(void 0===r)throw new globalThis.Error(t,{cause:e});return r}(t.cause,"Sync adapter can only throw schema errors")})(r(e,t)))(t)}let b2=hk();function b3(e){return Object.assign(e,{parse:t=>b1(e,t),safeParse:t=>{let r;return rf(r=mW(e,{errors:"all"})(t))?{data:r.success,success:!0}:{error:{issues:b2(r.failure.issue).issues.map(e=>({message:e.message,path:(e.path??[]).map(e=>"object"==typeof e?e.key:e)}))},success:!1}}})}let b5=gi(["flowchart","mindmap"]),b4=gi(["TB","BT","LR","RL"]),b8=gi(["straight","orthogonal","curved"]);class b6 extends gC("DiagramNode")({id:bZ,label:bZ,group:mH(bZ),kind:mH(bZ),metadata:b0(bX,{})}){}b3(b6);class b9 extends gC("DiagramEdge")({id:bZ,source:bZ,target:bZ,label:mH(bZ),metadata:b0(bX,{})}){}b3(b9);let b7=m5.check(pB(/^#[0-9a-fA-F]{6}$/));class ve extends gC("DiagramStyle")({accentColor:b0(b7,"#0f766e"),backgroundColor:b0(b7,"#ffffff")}){}b3(ve);class vt extends gC("DiagramLayout")({direction:b0(b4,"LR"),edgeRouting:b0(b8,"orthogonal")}){}b3(vt);class vr extends gC("IntermediateDiagram")({id:bZ,title:bZ,type:b0(b5,"flowchart"),nodes:gt(b6).pipe(gr).check(gg(1)),edges:b0(gt(b9).pipe(gr),[]),layout:b0(vt,{direction:"LR",edgeRouting:"orthogonal"}),style:b0(ve,{accentColor:"#0f766e",backgroundColor:"#ffffff"}),metadata:b0(bX,{})}){}b3(vr);class vn extends Error{constructor(e){super(e),this.name="DiagramValidationError"}}let vi=e=>{let t=new Set;for(let r of e){if(t.has(r))return r;t.add(r)}};function vs(e){let t=vi(e.nodes.map(e=>e.id));if(t)throw new vn(`Duplicate node id "${t}" is not allowed.`);let r=vi(e.edges.map(e=>e.id));if(r)throw new vn(`Duplicate edge id "${r}" is not allowed.`);let n=new Set(e.nodes.map(e=>e.id));for(let t of e.edges){if(!n.has(t.source))throw new vn(`Edge "${t.id}" references missing source node "${t.source}".`);if(!n.has(t.target))throw new vn(`Edge "${t.id}" references missing target node "${t.target}".`);if(t.source===t.target)throw new vn(`Edge "${t.id}" cannot connect node "${t.source}" to itself.`)}return e}function va(e){return vs(b1(vr,e))}let vo="flowchart",vl=gi(["duplicate_node_id","duplicate_edge_id","missing_edge_source","missing_edge_target","self_loop","missing_start","multiple_starts","missing_end","start_has_incoming","end_has_outgoing","unreachable_node","missing_outgoing_edge","underbranched_decision","unlabeled_decision_branch","duplicate_decision_branch_label","nonterminating_node","flowchart_too_large"]);class vc extends gC("FlowchartValidationIssueRef")({kind:gi(["diagram","node","edge"]),id:mH(gy),path:mH(gy)}){}gC("FlowchartValidationIssue")({code:vl,ref:mH(vc),message:gy,hint:gy});let vu=gi(["start","process","decision","end"]);class vd extends b6.extend("FlowchartNode")({kind:vu,description:mH(gy)}){}class vf extends b9.extend("FlowchartEdge")({label:mH(gy)}){}class vh extends vr.extend("FlowchartDiagram")({type:m1(vo),nodes:gt(vd).pipe(gr).check(gg(2)),edges:gt(vf).pipe(gr).check(gg(1))}){}let vp=b3(vh);function vm(e){let t=new Set,r=new Set;for(let n of e)t.has(n)?r.add(n):t.add(n);return[...r]}function vg(e,t,r){let n=new Set,i=[...e];for(let e=0;e<i.length;e+=1){let s=i[e];if(!(void 0===s||n.has(s)))for(let e of(n.add(s),t.get(s)??[]))i.push(r(e))}return n}function vy(e){let t=[],r=new Set(e.nodes.map(e=>e.id)),{incoming:n,outgoing:i}=function(e){let t=new Map,r=new Map;for(let n of e)t.set(n.target,[...t.get(n.target)??[],n]),r.set(n.source,[...r.get(n.source)??[],n]);return{incoming:t,outgoing:r}}(e.edges);for(let r of(e.nodes.length>24&&t.push({code:"flowchart_too_large",ref:{kind:"diagram",id:e.id,path:"nodes"},message:`Flowchart has ${e.nodes.length} nodes; the supported maximum is 24.`,hint:"Split the workflow or combine lower-signal steps."}),e.edges.length>64&&t.push({code:"flowchart_too_large",ref:{kind:"diagram",id:e.id,path:"edges"},message:`Flowchart has ${e.edges.length} edges; the supported maximum is 64.`,hint:"Split the workflow or remove lower-signal connections."}),vm(e.nodes.map(e=>e.id))))t.push({code:"duplicate_node_id",ref:{kind:"node",id:r,path:"nodes"},message:`Node id "${r}" is used more than once.`,hint:"Give every node a stable unique id."});for(let r of vm(e.edges.map(e=>e.id)))t.push({code:"duplicate_edge_id",ref:{kind:"edge",id:r,path:"edges"},message:`Edge id "${r}" is used more than once.`,hint:"Give every edge a stable unique id."});for(let n of e.edges)r.has(n.source)||t.push({code:"missing_edge_source",ref:{kind:"edge",id:n.id,path:"edges.source"},message:`Edge "${n.id}" references missing source node "${n.source}".`,hint:"Set edge.source to one of the diagram node ids."}),r.has(n.target)||t.push({code:"missing_edge_target",ref:{kind:"edge",id:n.id,path:"edges.target"},message:`Edge "${n.id}" references missing target node "${n.target}".`,hint:"Set edge.target to one of the diagram node ids."}),n.source===n.target&&t.push({code:"self_loop",ref:{kind:"edge",id:n.id},message:`Edge "${n.id}" connects node "${n.source}" to itself.`,hint:"Connect the edge to a different target node."});let s=e.nodes.filter(e=>"start"===e.kind),a=e.nodes.filter(e=>"end"===e.kind);for(let r of(0===s.length?t.push({code:"missing_start",ref:{kind:"diagram",id:e.id,path:"nodes"},message:"Flowchart must contain exactly one start node.",hint:'Mark the first node in the flow with kind: "start".'}):s.length>1&&t.push({code:"multiple_starts",ref:{kind:"diagram",id:e.id,path:"nodes"},message:`Flowchart has ${s.length} start nodes.`,hint:"Keep one start node and change the others to process, decision, or end."}),0===a.length&&t.push({code:"missing_end",ref:{kind:"diagram",id:e.id,path:"nodes"},message:"Flowchart must contain at least one end node.",hint:'Add an end node or mark terminal outcomes with kind: "end".'}),e.nodes)){let e=n.get(r.id)??[],s=i.get(r.id)??[];"start"===r.kind&&e.length>0&&t.push({code:"start_has_incoming",ref:{kind:"node",id:r.id},message:`Start node "${r.id}" cannot have incoming edges.`,hint:"Route the start node only to later nodes."}),"end"===r.kind&&s.length>0&&t.push({code:"end_has_outgoing",ref:{kind:"node",id:r.id},message:`End node "${r.id}" cannot have outgoing edges.`,hint:"End nodes must be terminal outcomes."}),"end"!==r.kind&&0===s.length&&t.push({code:"missing_outgoing_edge",ref:{kind:"node",id:r.id},message:`Node "${r.id}" must have at least one outgoing edge.`,hint:'Connect it to the next step, or mark it as kind: "end".'}),"decision"===r.kind&&t.push(...function(e,t){let r=[];t.length<2&&r.push({code:"underbranched_decision",ref:{kind:"node",id:e.id},message:`Decision node "${e.id}" must have at least two outgoing branches.`,hint:"Add at least two outgoing edges for the decision outcomes."});let n=t.map(e=>e.label?.trim()??"");for(let n of t.filter(e=>!e.label?.trim()))r.push({code:"unlabeled_decision_branch",ref:{kind:"edge",id:n.id,path:"edges.label"},message:`Decision node "${e.id}" has an outgoing branch without a label.`,hint:'Add a short branch label such as "yes", "no", "approved", or "rejected".'});for(let t of vm(n.filter(e=>e.length>0).map(e=>e.toLowerCase())))r.push({code:"duplicate_decision_branch_label",ref:{kind:"node",id:e.id},message:`Decision node "${e.id}" repeats branch label "${t}".`,hint:"Make every outgoing branch label from the same decision unique."});return r}(r,s))}let o=1===s.length?s[0]:void 0;if(o){let r=vg([o.id],i,e=>e.target);for(let n of e.nodes)r.has(n.id)||t.push({code:"unreachable_node",ref:{kind:"node",id:n.id},message:`Node "${n.id}" is not reachable from the start node.`,hint:"Connect every node to the flow that begins at the single start node."});if(a.length>0){let s=vg(a.map(e=>e.id),n,e=>e.source);for(let n of e.nodes)r.has(n.id)&&!s.has(n.id)&&(i.get(n.id)?.length??0)>0&&t.push({code:"nonterminating_node",ref:{kind:"node",id:n.id},message:`Node "${n.id}" cannot reach an end node.`,hint:"Add an eventual exit from this path to an end node; retry loops are valid when they retain an exit."})}}return t.slice(0,20)}class vb extends vn{issues;constructor(e){super(e[0]?.message??"Flowchart failed semantic validation."),this.issues=e,this.name="FlowchartValidationError"}}function vv(e){let t=vy(e);if(t.length>0)throw new vb(t);return e}let vw=vv(b1(vh,{id:"onboarding-flow",title:"Sketchi onboarding decision flow",type:vo,nodes:[{id:"prompt",label:"Prompt received",kind:"start"},{id:"requirements",label:"Extract requirements",kind:"process"},{id:"clear",label:"Scope clear?",kind:"decision"},{id:"draft",label:"Draft typed IR",kind:"process"},{id:"review",label:"Review diagram",kind:"end"}],edges:[{id:"prompt-requirements",source:"prompt",target:"requirements"},{id:"requirements-clear",source:"requirements",target:"clear"},{id:"clear-draft",source:"clear",target:"draft",label:"yes"},{id:"clear-review",source:"clear",target:"review",label:"no"},{id:"draft-review",source:"draft",target:"review"}],layout:{direction:"TB",edgeRouting:"orthogonal"},style:{accentColor:"#0f766e",backgroundColor:"#ffffff"}}));vv(b1(vh,{id:"pharma-batch-disposition",title:"Pharma batch disposition flow",type:vo,nodes:[{id:"batch-received",label:"Batch received",kind:"start"},{id:"qa-review",label:"QA reviews Certificate of Analysis",kind:"process"},{id:"passes-specs",label:"Passes specs?",kind:"decision"},{id:"final-review",label:"QA Manager final review",kind:"process"},{id:"packaging",label:"Send to packaging",kind:"end"},{id:"investigate",label:"Investigate retesting",kind:"process"},{id:"reject",label:"Reject batch",kind:"end"}],edges:[{id:"batch-qa",source:"batch-received",target:"qa-review"},{id:"qa-specs",source:"qa-review",target:"passes-specs"},{id:"specs-pass",source:"passes-specs",target:"final-review",label:"yes"},{id:"specs-investigate",source:"passes-specs",target:"investigate",label:"retest"},{id:"specs-reject",source:"passes-specs",target:"reject",label:"reject"},{id:"review-packaging",source:"final-review",target:"packaging"},{id:"investigate-review",source:"investigate",target:"final-review"}],layout:{direction:"TB",edgeRouting:"orthogonal"},style:{accentColor:"#0f766e",backgroundColor:"#ffffff"}}));let vx="mindmap";class vk extends gC("MindmapNodeMetadata")({depth:gx.check(gm(0)),siblingIndex:gx.check(gm(0))}){}class vS extends b6.extend("MindmapNode")({kind:gi(["root","topic"]),metadata:vk}){}class v_ extends gC("MindmapEdgeMetadata")({depth:gx.check(gp(0)),siblingIndex:gx.check(gm(0))}){}class v$ extends b9.extend("MindmapEdge")({metadata:v_}){}class vO extends vr.extend("MindmapDiagram")({type:m1(vx),nodes:gt(vS).pipe(gr).check(gg(2)),edges:gt(v$).pipe(gr).check(gg(1))}){}function vI(e){return function(e){vs(e);let t=e.nodes.filter(e=>"root"===e.kind);if(1!==t.length)throw new vn(`Mindmap must contain exactly one root topic; found ${t.length}.`);let r=t[0];if(!r||0!==r.metadata.depth)throw new vn("Mindmap root topic must have depth 0.");let n=new Map,i=new Map(e.nodes.map(e=>[e.id,e])),s=new Map;for(let t of e.edges){n.set(t.target,(n.get(t.target)??0)+1);let e=i.get(t.source)?.metadata.depth,r=i.get(t.target),a=r?.metadata.depth;if(void 0===e||a!==e+1)throw new vn(`Mindmap edge "${t.id}" must connect a topic to its immediate child.`);if(!r||t.metadata.depth!==r.metadata.depth||t.metadata.siblingIndex!==r.metadata.siblingIndex)throw new vn(`Mindmap edge "${t.id}" metadata must match its child topic.`);s.set(t.source,[...s.get(t.source)??[],r.metadata.siblingIndex])}for(let t of e.nodes){let e=n.get(t.id)??0;if(t.id===r.id?0!==e:1!==e)throw new vn(`Mindmap topic "${t.id}" must have ${t.id===r.id?"no parent":"exactly one parent"}.`)}for(let[e,t]of s){let r=t.map((e,t)=>t);if([...t].sort((e,t)=>e-t).some((e,t)=>e!==r[t]))throw new vn(`Mindmap children of "${e}" must use contiguous sibling ordering from 0.`)}return e}(b1(vO,e))}b3(vO);let vC=vI({id:"public-mindmap-capability",title:"Public mindmap generation",type:vx,nodes:[{id:"topic-0",label:"Public mindmaps",kind:"root",metadata:{depth:0,siblingIndex:0}},{id:"topic-0-0",label:"Semantic input",kind:"topic",metadata:{depth:1,siblingIndex:0}},{id:"topic-0-0-0",label:"Nested topics",kind:"topic",metadata:{depth:2,siblingIndex:0}},{id:"topic-0-0-1",label:"Stable ordering",kind:"topic",metadata:{depth:2,siblingIndex:1}},{id:"topic-0-1",label:"Artifact output",kind:"topic",metadata:{depth:1,siblingIndex:1}},{id:"topic-0-1-0",label:"Scene",kind:"topic",metadata:{depth:2,siblingIndex:0}},{id:"topic-0-1-1",label:"Excalidraw",kind:"topic",metadata:{depth:2,siblingIndex:1}}],edges:[{id:"branch-0-0",source:"topic-0",target:"topic-0-0",metadata:{depth:1,siblingIndex:0}},{id:"branch-0-0-0",source:"topic-0-0",target:"topic-0-0-0",metadata:{depth:2,siblingIndex:0}},{id:"branch-0-0-1",source:"topic-0-0",target:"topic-0-0-1",metadata:{depth:2,siblingIndex:1}},{id:"branch-0-1",source:"topic-0",target:"topic-0-1",metadata:{depth:1,siblingIndex:1}},{id:"branch-0-1-0",source:"topic-0-1",target:"topic-0-1-0",metadata:{depth:2,siblingIndex:0}},{id:"branch-0-1-1",source:"topic-0-1",target:"topic-0-1-1",metadata:{depth:2,siblingIndex:1}}],layout:{direction:"LR",edgeRouting:"curved"},style:{accentColor:"#7c3aed",backgroundColor:"#ffffff"}});va(vw),va(vC);function vE(e){if(e>="a"&&e<="z")return e.charCodeAt(0)-97+2;if(e>="A"&&e<="Z")return 90-e.charCodeAt(0)+2;throw Error("invalid order key head: "+e)}function vA(e){let t=vE(e[0]);if(t>e.length)throw Error("invalid order key: "+e);return e.slice(0,t)}let vT=new Set(["rectangle","ellipse","diamond"]);function vM(e){return"number"==typeof e&&Number.isFinite(e)?e:null}function vN(e){if(!Array.isArray(e)||e.length<2)return null;let t=vM(e[0]),r=vM(e[1]);return null===t||null===r?null:[t,r]}function vj(e){let t=vM(e.x),r=vM(e.y),n=vM(e.width),i=vM(e.height);return null===t||null===r||null===n||null===i?null:{x:t,y:r,width:n,height:i}}function vF(e){return 1e-4>Math.abs(e-.5)?.5001:e}function vL(e,t){let r;return{elementId:e?.id??"",focus:0,gap:0,fixedPoint:e?(r=vj(e))&&0!==r.width&&0!==r.height?[vF((t.x-r.x)/r.width),vF((t.y-r.y)/r.height)]:null:null}}function vP(e,t){let r=function(e){let t=0x811c9dc5;for(let r of e)t^=r.charCodeAt(0),t=Math.imul(t,0x1000193);return Math.abs(t)||1}(e);return{id:e,angle:0,fillStyle:"solid",frameId:null,groupIds:[],index:t,isDeleted:!1,link:null,locked:!1,opacity:100,roughness:1,seed:r,strokeStyle:"solid",strokeWidth:2,updated:1,version:1,versionNonce:r+1}}function vD(e,t){return Math.ceil(e.split("\n").length*t*1.35)}function vR(e){var t,r;let n=Math.max(1,Math.min(e.maxWidth,(t=e.text,r=e.fontSize,Math.ceil(Math.max(...t.split("\n").map(e=>e.length))*r*.62)))),i=vD(e.text,e.fontSize);return{...vP(e.id,e.index),type:"text",x:e.x-n/2,y:e.y-i/2,width:n,height:i,backgroundColor:"transparent",boundElements:null,containerId:e.containerId,fontFamily:5,fontSize:e.fontSize,lineHeight:1.35,originalText:e.text,roundness:null,strokeColor:e.textColor??"#1e1e1e",text:e.text,textAlign:"center",verticalAlign:"middle",autoResize:!0}}function vU(e){return e.points[e.points.length-1]??e.points[0]}function vB(e){return"node"===e.type}function vq(e){return"text"===e.type}function vK(e){return"arrow"===e.type}function vz(e){let t=e.elements.filter(vB),r=new Map(e.elements.filter(vq).map(e=>[e.containerId??"",e])),n=e.elements.filter(vK),i=function(e){let t=new Map;for(let r of e)for(let e of[r.sourceNodeId,r.targetNodeId]){let n=`node:${e}`;t.set(n,[...t.get(n)??[],r.id])}return t}(n),s=new Map,a=[],o=null,l=()=>{let e=function(e,t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"){if(null!=e&&function(e,t){if(e==="A"+t[0].repeat(26))throw Error("invalid order key: "+e);let r=vA(e);if(e.slice(r.length).slice(-1)===t[0])throw Error("invalid order key: "+e)}(e,t),null==e)return"a"+t[0];{let r=vA(e),n=e.slice(r.length),i=function(e,t){var r=e;if(r.length!==vE(r[0]))throw Error("invalid integer part of order key: "+r);let[n,...i]=e.split(""),s=!0;for(let e=i.length-1;s&&e>=0;e--){let r=t.indexOf(i[e])+1;r===t.length?i[e]=t[0]:(i[e]=t[r],s=!1)}if(!s)return n+i.join("");{if("Z"===n)return"a"+t[0];if("z"===n)return null;let e=String.fromCharCode(n.charCodeAt(0)+1);return e>"a"?i.push(t[0]):i.pop(),e+i.join("")}}(r,t);return null==i?r+function e(t,r,n){let i=n[0];if(null!=r&&t>=r)throw Error(t+" >= "+r);if(t.slice(-1)===i||r&&r.slice(-1)===i)throw Error("trailing zero");if(r){let s=0;for(;(t[s]||i)===r[s];)s++;if(s>0)return r.slice(0,s)+e(t.slice(s),r.slice(s),n)}let s=t?n.indexOf(t[0]):0,a=null!=r?n.indexOf(r[0]):n.length;return a-s>1?n[Math.round(.5*(s+a))]:r&&r.length>1?r.slice(0,1):n[s]+e(t.slice(1),null,n)}(n,null,t):i}}(o);return o=e,e};for(let n of t){let t=r.get(n.id),o=function(e){let t=e.text?vD(e.text.text,e.text.fontSize)+18:0,r=Math.max(e.shape.height,t),n="circle"===e.shape.shape?"ellipse":e.shape.shape,i=[...e.text?[{id:e.text.id,type:"text"}]:[],...e.arrowIds.map(e=>({id:e,type:"arrow"}))];return{...vP(e.shape.id,e.index),type:n,x:e.shape.x,y:e.shape.y,width:e.shape.width,height:r,backgroundColor:e.shape.fillColor??"transparent",boundElements:i.length>0?i:null,roundness:"rectangle"===n?{type:3}:null,strokeColor:e.shape.strokeColor??e.scene.accentColor}}({scene:e,shape:n,arrowIds:i.get(n.id)??[],index:l(),...t?{text:t}:{}});s.set(n.nodeId,o),a.push(o)}for(let t of e.elements.filter(vq))t.containerId&&a.push(vR({id:t.id,index:l(),containerId:t.containerId,fontSize:t.fontSize,maxWidth:t.maxWidth??160,...t.textColor?{textColor:t.textColor}:{},text:t.text,x:t.x,y:t.y}));for(let t of n){a.push(function(e){let t=e.arrow.points[0],r=vU(e.arrow),n=e.arrow.points.length>2;return{...vP(e.arrow.id,e.index),type:"arrow",x:t.x,y:t.y,width:r.x-t.x,height:r.y-t.y,backgroundColor:"transparent",boundElements:e.arrow.label?[{id:`${e.arrow.id}:label`,type:"text"}]:null,elbowed:n,endArrowhead:"arrow",endBinding:vL(e.targetShape,r),...n?{fixedSegments:[],startIsSpecial:null,endIsSpecial:null}:{},points:e.arrow.points.map(e=>[e.x-t.x,e.y-t.y]),roundness:n?null:{type:2},startArrowhead:null,startBinding:vL(e.sourceShape,t),strokeColor:e.arrow.strokeColor??e.scene.accentColor}}({arrow:t,scene:e,index:l(),sourceShape:s.get(t.sourceNodeId),targetShape:s.get(t.targetNodeId)}));let r=t.label?function(e){if(!e.arrow.label)return null;let t=e.arrow.points[0],r=vU(e.arrow);return vR({id:`${e.arrow.id}:label`,index:e.index,containerId:e.arrow.id,fontSize:13,maxWidth:160,...e.arrow.textColor?{textColor:e.arrow.textColor}:{},text:e.arrow.label,x:(t.x+r.x)/2,y:(t.y+r.y)/2-10})}({arrow:t,index:l()}):null;r&&a.push(r)}return{appState:{viewBackgroundColor:e.backgroundColor,zoom:{value:Math.max(.42,Math.round(100*Math.min(1,860/Math.max(e.width,1),340/Math.max(e.height,1)))/100)}},elements:a}}function vV(e,t){let r=e[t];if(!(r&&"object"==typeof r))return null;let n=r.elementId;return"string"==typeof n?n:null}function vJ(e){return vN(e)}function vW(e){let t=vM(e.x)??0,r=vM(e.y)??0,n=vV(e,"startBinding"),i=vV(e,"endBinding"),s=Array.isArray(e.points)?e.points.map(vJ).filter(e=>!!e):[],a=[];for(let o=0;o<s.length-1;o+=1){let l=s[o],c=s[o+1];if(!l||!c)continue;let[u,d]=l,[f,h]=c,p=t+u,m=r+d,g=t+f,y=r+h;if(.001>=Math.abs(m-y)){a.push({arrowId:e.id,endBindingElementId:i,isLastSegment:o===s.length-2,max:Math.max(p,g),min:Math.min(p,g),orientation:"horizontal",segmentIndex:o,startBindingElementId:n,staticCoordinate:m});continue}.001>=Math.abs(p-g)&&a.push({arrowId:e.id,endBindingElementId:i,isLastSegment:o===s.length-2,max:Math.max(m,y),min:Math.min(m,y),orientation:"vertical",segmentIndex:o,startBindingElementId:n,staticCoordinate:p})}return a.filter(e=>e.max-e.min>.001)}function vY(e,t,r){return e>t+.01&&e<r-.01}function vG(e,t,r,n){return Math.min(t,n)-Math.max(e,r)>.01}function vH(e,t,r){return e>=t-.01&&e<=r+.01}function vQ(e,t){return .01>=Math.abs(e-t)}function vZ(e){let t=[],r=new Map(e.elements.map(e=>[e.id,e])),n=new Set(e.elements.filter(e=>vT.has(e.type)).map(e=>e.id));for(let i of(0===n.size&&t.push({code:"empty-scene",message:"Excalidraw scene must contain at least one shape."}),e.elements)){if("arrow"===i.type){let e=!0===i.elbowed;for(let s of((Array.isArray(i.points)?i.points:[]).length>2&&!e&&t.push({code:"invalid-elbow-binding",elementId:i.id,message:`Arrow "${i.id}" has an orthogonal route but is not marked elbowed.`}),e&&null!==i.fixedSegments&&!Array.isArray(i.fixedSegments)&&t.push({code:"invalid-elbow-binding",elementId:i.id,message:`Elbow arrow "${i.id}" is missing fixedSegments metadata.`}),["startBinding","endBinding"])){let a=vV(i,s);if(!(a&&n.has(a))){t.push({code:"missing-arrow-binding",elementId:i.id,message:`Arrow "${i.id}" has invalid ${s}.`});continue}let o=r.get(a);o&&!function(e,t,r){let n=e.boundElements;return!!Array.isArray(n)&&n.some(e=>!!(e&&"object"==typeof e)&&e.id===t&&e.type===r)}(o,i.id,"arrow")&&t.push({code:"missing-bound-arrow",elementId:o.id,message:`Shape "${o.id}" does not include bound arrow "${i.id}".`});let l=function(e,t){let r=vM(e.x)??0,n=vM(e.y)??0,i=Array.isArray(e.points)?e.points.map(vJ).filter(e=>!!e):[],s="startBinding"===t?i[0]:i[i.length-1];return s?{x:r+s[0],y:n+s[1]}:null}(i,s);if(o&&l&&!function(e,t){let r=vj(t);if(!r)return!1;if("diamond"===t.type){let t=r.width/2,n=r.height/2;if(0===t||0===n)return!1;let i=r.x+t,s=r.y+n;return vQ(Math.abs(e.x-i)/t+Math.abs(e.y-s)/n,1)}if("ellipse"===t.type){let t=r.width/2,n=r.height/2;if(0===t||0===n)return!1;let i=r.x+t,s=r.y+n;return vQ(((e.x-i)/t)**2+((e.y-s)/n)**2,1)}let n=(vQ(e.x,r.x)||vQ(e.x,r.x+r.width))&&vH(e.y,r.y,r.y+r.height),i=(vQ(e.y,r.y)||vQ(e.y,r.y+r.height))&&vH(e.x,r.x,r.x+r.width);return n||i}(l,o)&&t.push({code:"arrow-endpoint-off-shape",elementId:i.id,message:`Arrow "${i.id}" ${s} endpoint does not land on "${o.id}".`}),o&&l&&e){let e=function(e,t){let r=e[t];return r&&"object"==typeof r?vN(r.fixedPoint):null}(i,s);e&&function(e,t,r){let n=vj(r);if(!n)return!1;let i=1e-4>Math.abs(e[0]-.5001)?.5:e[0],s=1e-4>Math.abs(e[1]-.5001)?.5:e[1];return vQ(n.x+i*n.width,t.x)&&vQ(n.y+s*n.height,t.y)}(e,l,o)||t.push({code:"invalid-elbow-binding",elementId:i.id,message:`Elbow arrow "${i.id}" has invalid ${s} fixedPoint metadata.`})}}}if("text"===i.type){let e=i.containerId;if("string"!=typeof e)continue;let n=r.get(e);if(!n){t.push({code:"missing-container",elementId:i.id,message:`Text "${i.id}" references missing container "${e}".`});continue}let s="number"==typeof i.width?i.width:0,a="number"==typeof i.height?i.height:0,o="number"==typeof n.width?n.width:0,l="number"==typeof n.height?n.height:0;vT.has(n.type)&&(s+24>o||a+18>l)&&t.push({code:"text-overflow",elementId:i.id,message:`Text "${i.id}" does not fit inside "${e}".`})}}return t.push(...function(e){let t=e.filter(e=>"arrow"===e.type).flatMap(vW),r=e.filter(e=>vT.has(e.type)),n=[],i=new Set;for(let e of t)for(let t of r){if(t.id===e.startBindingElementId||t.id===e.endBindingElementId)continue;let r=vj(t);if(!r||("horizontal"===e.orientation?!(vY(e.staticCoordinate,r.y,r.y+r.height)&&vG(e.min,e.max,r.x,r.x+r.width)):!(vY(e.staticCoordinate,r.x,r.x+r.width)&&vG(e.min,e.max,r.y,r.y+r.height))))continue;let s=`${e.arrowId}:${e.segmentIndex}:${t.id}`;i.has(s)||(i.add(s),n.push({code:"arrow-segment-through-node",elementId:e.arrowId,message:`Arrow "${e.arrowId}" passes through shape "${t.id}".`}))}return n}(e.elements)),t.push(...function(e){let t=e.filter(e=>"arrow"===e.type).flatMap(vW),r=[],n=new Set;for(let e=0;e<t.length;e+=1){let i=t[e];if(i)for(let s=e+1;s<t.length;s+=1){let e=t[s];if(!e||i.arrowId===e.arrowId||i.orientation!==e.orientation||Math.abs(i.staticCoordinate-e.staticCoordinate)>.001||0===i.segmentIndex&&0===e.segmentIndex&&null!==i.startBindingElementId&&i.startBindingElementId===e.startBindingElementId||i.isLastSegment&&e.isLastSegment&&null!==i.endBindingElementId&&i.endBindingElementId===e.endBindingElementId||Math.min(i.max,e.max)-Math.max(i.min,e.min)<=.001)continue;let a=[i.arrowId,i.segmentIndex,e.arrowId,e.segmentIndex].sort().join(":");n.has(a)||(n.add(a),r.push({code:"overlapping-arrow-segment",elementId:i.arrowId,message:`Arrow "${i.arrowId}" overlaps arrow "${e.arrowId}".`}))}}return r}(e.elements)),{ok:0===t.length,issues:t}}function vX(e){return new Map(e.map((e,t)=>[e.id,t]))}function v0(e){return{type:"text",id:`label:${e.nodeId}`,containerId:e.id,x:e.x+e.width/2,y:e.y+e.height/2,text:e.label,fontSize:14,maxWidth:Math.max(1,e.width-36)}}function v1(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function v2(e,t,r){return Math.min(r,Math.max(t,e))}function v3(e,t,r=0){let n,i=(n="top"===t||"bottom"===t?e.width/2-16:e.height/2-16)>0?v2(r,-n,n):0,s=v1(e),a=e.width/2,o=e.height/2;if("diamond"===e.shape&&a>0&&o>0){if("top"===t||"bottom"===t){let e=s.x+i,r=o*(1-Math.abs(i)/a);return{x:e,y:"top"===t?s.y-r:s.y+r}}let e=s.y+i,r=a*(1-Math.abs(i)/o);return{x:"left"===t?s.x-r:s.x+r,y:e}}if(("ellipse"===e.shape||"circle"===e.shape)&&a>0&&o>0){if("top"===t||"bottom"===t){let e=s.x+i,r=o*Math.sqrt(Math.max(0,1-(i/a)**2));return{x:e,y:"top"===t?s.y-r:s.y+r}}let e=s.y+i,r=a*Math.sqrt(Math.max(0,1-(i/o)**2));return{x:"left"===t?s.x-r:s.x+r,y:e}}switch(t){case"top":return{x:e.x+e.width/2+i,y:e.y};case"right":return{x:e.x+e.width,y:e.y+e.height/2+i};case"bottom":return{x:e.x+e.width/2+i,y:e.y+e.height};case"left":return{x:e.x,y:e.y+e.height/2+i}}}function v5(e){return`${e.edgeId}:${e.endpoint}`}function v4(e){let t=[];for(let r of e){let e=t[t.length-1];e&&e.x===r.x&&e.y===r.y||t.push(r)}let r=t[0];return r?[r,...t.slice(1)]:[{x:0,y:0}]}function v8(e,t,r){return e>t+.01&&e<r-.01}function v6(e,t,r,n){return Math.min(t,n)-Math.max(e,r)>.01}function v9(e,t,r){let n=0;for(let i=0;i<e.length-1;i+=1){let s=e[i],a=e[i+1];if(s&&a)for(let e of t)!r.has(e.nodeId)&&(s.y===a.y?v8(s.y,e.y,e.y+e.height)&&v6(Math.min(s.x,a.x),Math.max(s.x,a.x),e.x,e.x+e.width):s.x===a.x&&v8(s.x,e.x,e.x+e.width)&&v6(Math.min(s.y,a.y),Math.max(s.y,a.y),e.y,e.y+e.height))&&(n+=1)}return n}function v7(e){let t=0;for(let r=0;r<e.length-1;r+=1){let n=e[r],i=e[r+1];n&&i&&(t+=Math.abs(i.x-n.x)+Math.abs(i.y-n.y))}return t}function we(e){let t=[];for(let r=0;r<e.points.length-1;r+=1){let n=e.points[r],i=e.points[r+1];if(n&&i){if(n.y===i.y){t.push({arrowId:e.arrowId,isFirstSegment:0===r,isLastSegment:r===e.points.length-2,max:Math.max(n.x,i.x),min:Math.min(n.x,i.x),orientation:"horizontal",segmentIndex:r,sourceNodeId:e.sourceNodeId,staticCoordinate:n.y,targetNodeId:e.targetNodeId});continue}n.x===i.x&&t.push({arrowId:e.arrowId,isFirstSegment:0===r,isLastSegment:r===e.points.length-2,max:Math.max(n.y,i.y),min:Math.min(n.y,i.y),orientation:"vertical",segmentIndex:r,sourceNodeId:e.sourceNodeId,staticCoordinate:n.x,targetNodeId:e.targetNodeId})}}return t.filter(e=>e.max-e.min>.01)}function wt(e,t){return Math.min(e.max,t.max)-Math.max(e.min,t.min)}function wr(e,t,r){let n=we({arrowId:`edge:${r.edge.id}`,points:e,sourceNodeId:r.edge.source,targetNodeId:r.edge.target}),i=t.flatMap(e=>we({arrowId:e.id,points:e.points,sourceNodeId:e.sourceNodeId,targetNodeId:e.targetNodeId})),s=0;for(let e of n)for(let t of i)e.arrowId===t.arrowId||e.orientation!==t.orientation||Math.abs(e.staticCoordinate-t.staticCoordinate)>.01||e.isFirstSegment&&t.isFirstSegment&&e.sourceNodeId===t.sourceNodeId||e.isLastSegment&&t.isLastSegment&&e.targetNodeId===t.targetNodeId||.01>=wt(e,t)||(s+=1);return s}function wn(e,t){let r=we({arrowId:`edge:${t.edge.id}`,points:e,sourceNodeId:t.edge.source,targetNodeId:t.edge.target}),n=0;for(let e=0;e<r.length;e+=1){let t=r[e];if(t)for(let i=e+1;i<r.length;i+=1){let e=r[i];!e||t.orientation!==e.orientation||Math.abs(t.staticCoordinate-e.staticCoordinate)>.01||.01>=wt(t,e)||(n+=1)}}return n}function wi(e){let t=e[0],r=e[e.length-1];if(!t||!r)return 0;let n=e.map(e=>e.x),i=e.map(e=>e.y),s=0;return r.x<t.x?s+=Math.max(0,Math.max(...n)-t.x):r.x>t.x&&(s+=Math.max(0,t.x-Math.min(...n))),r.y<t.y?s+=Math.max(0,Math.max(...i)-t.y):r.y>t.y&&(s+=Math.max(0,t.y-Math.min(...i))),s}function ws(e){let t=e[0],r=e[e.length-1];if(!t||!r)return 0;let n=e.map(e=>e.x),i=e.map(e=>e.y),s=0;return r.x<t.x?s+=Math.max(0,r.x-Math.min(...n)):r.x>t.x&&(s+=Math.max(0,Math.max(...n)-r.x)),r.y<t.y?s+=Math.max(0,r.y-Math.min(...i)):r.y>t.y&&(s+=Math.max(0,Math.max(...i)-r.y)),s}function wa(e,t,r){switch(r){case"top":return t.y<e.y;case"right":return t.x>e.x;case"bottom":return t.y>e.y;case"left":return t.x<e.x}}function wo(e,t){let r=e[0],n=e[1],i=e[e.length-1],s=e[e.length-2],a=0;return n&&wa(r,n,t.sourceEdge)&&(a+=1),s&&i&&wa(i,s,t.targetEdge)&&(a+=1),a}function wl(e,t,r){switch(t){case"top":return{x:e.x,y:e.y-r};case"right":return{x:e.x+r,y:e.y};case"bottom":return{x:e.x,y:e.y+r};case"left":return{x:e.x-r,y:e.y}}}function wc(e,t,r,n,i){var s;let a,o=Math.abs(r.x-t.x)>=Math.abs(r.y-t.y),l=new Set([e.source.nodeId,e.target.nodeId]),c=Math.min(...n.map(e=>e.x)),u=Math.max(...n.map(e=>e.x+e.width)),d=Math.min(...n.map(e=>e.y)),f=Math.max(...n.map(e=>e.y+e.height)),h="left"===e.sourceEdge||"left"===e.targetEdge||v1(e.target).x<v1(e.source).x,p="top"===e.sourceEdge||"top"===e.targetEdge||v1(e.source).y<=v1(e.target).y,m=18*e.index,g=c-56-m,y=u+56+m,b=d-48-m,v=f+48+m,w=h?g:y,x=h?y:g,k=p?b:v,S=p?v:b,_=[0,36+e.index%4*18],$=(n,i)=>{let s=i>0?wl(t,e.sourceEdge,i):t,a=i>0?wl(r,e.targetEdge,i):r;return v4([t,s,{x:n,y:s.y},{x:n,y:a.y},a,r])},O=(n,i)=>{let s=i>0?wl(t,e.sourceEdge,i):t,a=i>0?wl(r,e.targetEdge,i):r;return v4([t,s,{x:s.x,y:n},{x:a.x,y:n},a,r])},I=[..._.map(e=>O(k,e)),..._.map(e=>O(S,e)),..._.map(e=>$(w,e)),..._.map(e=>$(x,e))],C=[..._.map(e=>$(w,e)),..._.map(e=>$(x,e)),..._.map(e=>O(k,e)),..._.map(e=>O(S,e))];return(a=(s=o?I:C)[0])?s.slice(1).reduce((t,r)=>{let s=v9(t,n,l),a=v9(r,n,l);if(a<s)return r;if(s<a)return t;let o=wn(t,e),c=wn(r,e);if(c<o)return r;if(o<c)return t;let u=wr(t,i,e),d=wr(r,i,e);if(d<u)return r;if(u<d)return t;let f=wo(t,e),h=wo(r,e);if(h>f)return r;if(f>h)return t;let p=wi(t),m=wi(r);if(m<p)return r;if(p<m)return t;let g=ws(t),y=ws(r);return y<g?r:g<y?t:v7(r)<v7(t)?r:t},a):[{x:0,y:0}]}function wu(e){return e.flatMap(e=>"arrow"===e.type?[...e.points]:[{x:e.x,y:e.y},{x:e.x+("node"===e.type?e.width:e.maxWidth??e.text.length),y:e.y+("node"===e.type?e.height:e.fontSize)}])}function wd(e,t,r){return{x:e.x+t,y:e.y+r}}function wf(e){var t;let r,n,i,s,a,o=va(e),l=function(e){let t="TB"===e.layout.direction||"BT"===e.layout.direction,r=new Map(e.nodes.map(e=>{let t,r,n,i,s;return[e.id,(s=(i=e.label.split("\n").flatMap(e=>(function(e){if(e.length<=18)return[e];let t=[],r="";for(let n of e.split(" ")){if(n.length>18){r&&(t.push(r),r=""),t.push(...function(e){if(e.length<=18)return[e];let t=[];for(let r=0;r<e.length;r+=18)t.push(e.slice(r,r+18));return t}(n));continue}let e=r?`${r} ${n}`:n;if(e.length<=18){r=e;continue}t.push(r),r=n}return r&&t.push(r),t})(e)).join("\n")).split("\n"),t={text:i,width:Math.ceil(14*Math.max(...s.map(e=>e.length))*.62+36),height:Math.ceil(14*s.length*1.35+28)},n="start"===(r=e.kind?.toLowerCase())||"end"===r?"ellipse":"decision"===r?"diamond":"rectangle",{type:"node",id:`node:${e.id}`,nodeId:e.id,...e.kind?{kind:e.kind}:{},shape:n,x:0,y:0,width:Math.max(184,t.width+("diamond"===n?32:20*("ellipse"===n))),height:Math.max(72,t.height+32*("diamond"===n)),label:t.text})]})),n=function(e){let t=new Map,r=new Map;for(let n of e)t.set(n.target,[...t.get(n.target)??[],n]),r.set(n.source,[...r.get(n.source)??[],n]);return{incoming:t,outgoing:r}}(e.edges),i=function(e,t,r){let n=new Map,i=new Set;function s(e){for(let t of(n.set(e,"visiting"),r.get(e)??[])){let e=n.get(t.target);if("visiting"===e){i.add(t.id);continue}e||s(t.target)}n.set(e,"visited")}let a=e.nodes.find(e=>0===(t.get(e.id)??[]).length)??e.nodes[0];for(let t of(a&&s(a.id),e.nodes))n.has(t.id)||s(t.id);return i}(e,n.incoming,n.outgoing),s=function(e,t,r){let n=vX(e.nodes),i=new Map(e.nodes.map(e=>[e.id,0])),s=new Map(e.nodes.map(e=>[e.id,0]));for(let t of e.edges)r.has(t.id)||i.set(t.target,(i.get(t.target)??0)+1);let a=[];for(let t of e.nodes)(i.get(t.id)??0)===0&&a.push(t.id);let o=new Set;for(let e=0;e<a.length;e+=1){let l=a[e];if(!l||o.has(l))continue;o.add(l);let c=s.get(l)??0;for(let e of t.outgoing.get(l)??[]){if(r.has(e.id))continue;s.set(e.target,Math.max(s.get(e.target)??0,c+1));let t=(i.get(e.target)??0)-1;i.set(e.target,t),0===t&&function(e,t,r){let n=r.get(t)??Number.MAX_SAFE_INTEGER,i=e.findIndex(e=>(r.get(e)??Number.MAX_SAFE_INTEGER)>n);-1===i?e.push(t):e.splice(i,0,t)}(a,e.target,n)}}for(let n of e.nodes){if(o.has(n.id))continue;let e=(t.incoming.get(n.id)??[]).filter(e=>!r.has(e.id)).map(e=>s.get(e.source)??0);s.set(n.id,e.length>0?Math.max(...e)+1:0)}return s}(e,n,i),a=Array.from((function(e,t,r,n,i){let s=vX(e.nodes),a=new Map;for(let n of e.nodes){let e=r.get(n.id)??0,i=t.get(n.id);i&&a.set(e,[...a.get(e)??[],i])}for(let e=0;e<4;e+=1)for(let e of Array.from(a.keys()).sort((e,t)=>e-t)){let t=a.get(e);if(!t||t.length<2)continue;let r=new Map;(a.get(e-1)??[]).forEach((e,t)=>{r.set(e.nodeId,t)});let o=new Map;(a.get(e+1)??[]).forEach((e,t)=>{o.set(e.nodeId,t)});let l=e=>{let t=[...(n.incoming.get(e.nodeId)??[]).filter(e=>!i.has(e.id)).map(e=>r.get(e.source)).filter(e=>void 0!==e),...(n.outgoing.get(e.nodeId)??[]).filter(e=>!i.has(e.id)).map(e=>o.get(e.target)).filter(e=>void 0!==e)];return 0===t.length?s.get(e.nodeId)??Number.MAX_SAFE_INTEGER:t.reduce((e,t)=>e+t,0)/t.length};a.set(e,[...t].sort((e,t)=>{let r=l(e)-l(t);return Math.abs(r)>.001?r:(s.get(e.nodeId)??Number.MAX_SAFE_INTEGER)-(s.get(t.nodeId)??Number.MAX_SAFE_INTEGER)}))}return a})(e,r,s,n,i).entries()).sort(([e],[t])=>e-t).map(([e,r])=>({breadth:r.reduce((e,r,n)=>e+(t?r.width:r.height)+112*(n>0),0),depth:Math.max(...r.map(e=>t?e.height:e.width)),rank:e,shapes:r})),o=Math.max(...a.map(e=>e.breadth)),l=48,c=[];for(let e of a){let r=48+Math.max(0,o-e.breadth)/2;for(let n of e.shapes)t?(c.push({...n,x:r,y:l+Math.max(0,e.depth-n.height)/2}),r+=n.width+112):(c.push({...n,x:l+Math.max(0,e.depth-n.width)/2,y:r}),r+=n.height+112);l+=e.depth+96}if("BT"===e.layout.direction){let e=Math.max(...c.map(e=>e.y+e.height));return c.map(t=>({...t,y:48+e-t.y-t.height}))}if("RL"===e.layout.direction){let e=Math.max(...c.map(e=>e.x+e.width));return c.map(t=>({...t,x:48+e-t.x-t.width}))}return c}(o),c=new Map(l.map(e=>[e.nodeId,e])),u=o.edges.map((e,t)=>(function(e,t,r,n){let i=r.get(e.source),s=r.get(e.target);if(!i||!s)throw Error(`Cannot render edge "${e.id}" with unresolved nodes.`);let{sourceEdge:a,targetEdge:o}=function(e,t,r){let n=v1(e),i=v1(t),s=i.x-n.x,a=i.y-n.y,o=e.kind?.toLowerCase();if("LR"===r||"RL"===r)return s>=0?{sourceEdge:"right",targetEdge:"left"}:{sourceEdge:"left",targetEdge:"right"};if(a<0)return!(Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)>.01)&&Math.abs(s)>Math.abs(a)?{sourceEdge:s>0?"right":"left",targetEdge:"bottom"}:{sourceEdge:"top",targetEdge:"bottom"};let l="decision"===o&&a>e.height+96;return"decision"===o&&a>0&&(0!==s||l)?{sourceEdge:s<0?"left":"right",targetEdge:"top"}:a>0?{sourceEdge:"bottom",targetEdge:"top"}:Math.abs(s)>Math.abs(a)?s>0?{sourceEdge:"right",targetEdge:"left"}:{sourceEdge:"left",targetEdge:"right"}:a>0?{sourceEdge:"bottom",targetEdge:"top"}:{sourceEdge:"top",targetEdge:"bottom"}}(i,s,n);return{edge:e,index:t,source:i,sourceEdge:a,target:s,targetEdge:o}})(e,t,c,o.layout.direction)),d=function(e){let t=new Map;for(let a of e){var r,n,i,s;let e=(r=a.source.nodeId,n=a.sourceEdge,`${r}:${n}`),o=(i=a.target.nodeId,s=a.targetEdge,`${i}:${s}`);t.set(e,[...t.get(e)??[],{edgeId:a.edge.id,endpoint:"source"}]),t.set(o,[...t.get(o)??[],{edgeId:a.edge.id,endpoint:"target"}])}let a=new Map;for(let e of t.values())e.forEach((t,r)=>{a.set(v5(t),(r-(e.length-1)/2)*18)});return a}(u),f=[];for(let e of u)f.push(function(e,t,r,n,i,s){let{edge:a,source:o,sourceEdge:l,target:c,targetEdge:u}=e,d=v3(o,l,r.get(v5({edgeId:a.id,endpoint:"source"}))??0),f=v3(c,u,r.get(v5({edgeId:a.id,endpoint:"target"}))??0),h=v4([d,f]);if(function(e,t,r){let n=v1(e),i=v1(t);switch(r){case"TB":return i.y<n.y;case"BT":return i.y>n.y;case"LR":return i.x<n.x;case"RL":return i.x>n.x}}(o,c,s))h=wc(e,d,f,n,i);else if("orthogonal"===t&&d.x!==f.x&&d.y!==f.y){var p,m,g;let t,r,n,i=e.index%4*18,s=(p=d.y,m=f.y,g=f.y<d.y?-i:i,t=p+(m-p)/2,(r=Math.min(p,m)+18)<(n=Math.max(p,m)-18)?v2(t+g,r,n):t),a="left"===l?{x:d.x-36-i,y:d.y}:"right"===l?{x:d.x+36+i,y:d.y}:d,o="left"===u?{x:f.x-36-i,y:f.y}:"right"===u?{x:f.x+36+i,y:f.y}:f;h=v4([d,a,{x:a.x,y:s},{x:o.x,y:s},o,f])}return"orthogonal"===t&&(v9(h,n,new Set([o.nodeId,c.nodeId]))>0||wn(h,e)>0||wr(h,i,e)>0)&&(h=wc(e,d,f,n,i)),{type:"arrow",id:`edge:${a.id}`,edgeId:a.id,sourceNodeId:a.source,targetNodeId:a.target,points:h,...a.label?{label:a.label}:{}}}(e,o.layout.edgeRouting,d,l,f,o.layout.direction));let h=l.map(v0),p=(i=Math.max(0,48-(n={x:Math.min(...(r=wu(t=[...f,...l,...h])).map(e=>e.x)),y:Math.min(...r.map(e=>e.y))}).x),s=Math.max(0,48-n.y),0===i&&0===s?[...t]:t.map(e=>"arrow"===e.type?{...e,points:function(e,t,r){let[n,...i]=e;return[wd(n,t,r),...i.map(e=>wd(e,t,r))]}(e.points,i,s)}:{...e,x:e.x+i,y:e.y+s})),m={width:Math.max(...(a=wu(p)).map(e=>e.x))+48,height:Math.max(...a.map(e=>e.y))+48};return{diagramId:o.id,title:o.title,width:m.width,height:m.height,accentColor:o.style.accentColor,backgroundColor:o.style.backgroundColor,elements:p}}let wh=io("effect/Metric/CurrentMetricAttributes",{defaultValue:()=>({})}),wp=io("~effect/observability/Metric/MetricRegistryKey",{defaultValue:()=>new Map}),wm="~effect/observability/Metric";class wg{[wm]=wm;#e=new WeakMap;#t;id;description;attributes;constructor(e,t,r){this.id=e,this.description=t,this.attributes=r}valueUnsafe(e){return this.hook(e).get(e)}modifyUnsafe(e,t){return this.hook(t).modify(e,t)}updateUnsafe(e,t){return this.hook(t).update(e,t)}hook(e){let t=n7(e,wh);if(0===Object.keys(t).length)return eO(this.#t)||(this.#t=this.getOrCreate(e,this.attributes)),this.#t.hooks;let r=w_(this.attributes,t),n=this.#e.get(r);return eO(n)||(n=this.getOrCreate(e,r),this.#e.set(r,n)),n.hooks}getOrCreate(e,t){var r,n,i;let s,a=(r=this,n=t,s=`${r.type}:${r.id}`,eO(r.description)&&(s+=`:${r.description}`),eO(n)&&(s+=`:${(Array.isArray(i=n)?i:Object.entries(i)).map(([e,t])=>`${e}=${t}`).join(",")}`),s),o=n7(e,wp);if(o.has(a))return o.get(a);let l=this.createHooks(),c={id:this.id,type:this.type,description:this.description,attributes:w$(t),hooks:l};return o.set(a,c),c}pipe(){return es(this,arguments)}}let wy=BigInt(0);class wb extends wg{type="Counter";#r;#n;constructor(e,t){super(e,t?.description,w$(t?.attributes)),this.#r=t?.bigint??!1,this.#n=t?.incremental??!1}createHooks(){let e=this.#r?wy:0,t=this.#n?this.#r?e=>e>=wy:e=>e>=0:e=>!0;return wS(()=>({count:e,incremental:this.#n}),r=>{t(r)&&(e+=r)})}}class wv extends wg{type;metric;valueUnsafe;updateUnsafe;modifyUnsafe;constructor(e,t,r,n){super(e.id,e.description,e.attributes),this.metric=e,this.valueUnsafe=t,this.updateUnsafe=r,this.modifyUnsafe=n,this.type=e.type}createHooks(){return this.metric.createHooks()}}let ww=(e,t)=>new wb(e,t),wx=el(2,(e,t)=>au(r=>sL(()=>e.updateUnsafe(t,r)))),wk=el(2,(e,t)=>new wv(e,r=>e.valueUnsafe(wO(r,t)),(r,n)=>e.updateUnsafe(r,wO(n,t)),(r,n)=>e.modifyUnsafe(r,wO(n,t))));function wS(e,t,r){return{get:e,update:t,modify:r??t}}function w_(e,t){return{...w$(e),...w$(t)}}function w$(e){return eO(e)&&Array.isArray(e)?e.reduce((e,[t,r])=>(e[t]=r,e),{}):e}function wO(e,t){let r=w_(n7(e,wh),t);return n8(e,wh,r)}[...new Set(["artifact_count","artifact_format","artifact_kind","attempt","cache_mode","duration_ms","error_category","error_tag","failure_category","format_count","method","model","operation","outcome","provider","request_kind","retry_kind","sink","status","status_code","surface","timeout_kind","timeout_ms"])];let wI={metric:()=>void 0},wC=io("@sketchi/observability/TelemetryExporter",{defaultValue:()=>wI}),wE=io("@sketchi/observability/TelemetryCorrelation",{defaultValue:()=>({})});function wA(e){let t=e?.trim();if(t&&!(t.length>128)&&/^[A-Za-z0-9][A-Za-z0-9._:-]*$/.test(t))return t}function wT(e){let t=wA(e.artifactId),r=wA(e.attemptId),n=wA(e.projectId),i=wA(e.requestId),s=wA(e.runId),a=wA(e.scenarioId),o=wA(e.traceId);return{...t?{artifactId:t}:{},...r?{attemptId:r}:{},...n?{projectId:n}:{},...i?{requestId:i}:{},...s?{runId:s}:{},...a?{scenarioId:a}:{},...o?{traceId:o}:{}}}function wM(e,t){return lR(function*(){let r=wT({...yield*wE,...wT(t)}),n={...r.artifactId?{"sketchi.artifact_id":r.artifactId}:{},...r.attemptId?{"sketchi.attempt_id":r.attemptId}:{},...r.projectId?{"sketchi.project_id":r.projectId}:{},...r.requestId?{"sketchi.request_id":r.requestId}:{},...r.runId?{"sketchi.run_id":r.runId}:{},...r.scenarioId?{"sketchi.scenario_id":r.scenarioId}:{},...r.traceId?{"sketchi.trace_id":r.traceId}:{}};return yield*e.pipe(af(wE,r),ox(n),lG(n))})}io("@sketchi/observability/TelemetryResource",{defaultValue:()=>({serviceName:"sketchi"})});let wN=lW(function*(e,t,r={}){let n=function(e){let t={artifact_kind:e.artifactKind,failure_category:e.failureCategory,operation:e.operation,outcome:e.outcome,provider:e.provider,retry_kind:e.retryKind,sink:e.sink,surface:e.surface,timeout_kind:e.timeoutKind},r={};for(let[e,n]of Object.entries(t)){let t=wA(n);t&&(r[e]=t)}return r}(r);yield*wx(wk(e,n),t);let i=yield*wC,s=rB((yield*ok.pipe(lB)));yield*sL(()=>i.metric({attributes:n,metric:e.id,metricType:e.type,...s?{spanId:s.spanId,traceId:s.traceId}:{},value:t}))}),wj=/^(node|step|item|box|thing|process|task)\s*\d*$/i,wF=/^(diagram|untitled|flowchart|chart|sketch)$/i;function wL(e){return"decision"===e.kind||e.label.endsWith("?")}function wP(e){if(void 0===e)return;let t=gJ(e);return t.length>0?t:void 0}let wD=["excalidraw","scene"],wR=["scene"],wU=ww("sketchi_codemode_requests",{description:"Code Mode boundary requests by terminal outcome",incremental:!0}),wB=ww("sketchi_codemode_failures",{description:"Code Mode boundary failures by typed status",incremental:!0}),wq=ww("sketchi_codemode_artifacts",{description:"Code Mode artifacts accepted at workflow boundaries",incremental:!0}),wK=new class e extends wg{type="Histogram";#i;constructor(e,t){super(e,t?.description,w$(t?.attributes)),this.#i=t.boundaries}createHooks(){let e=this.#i,t=e.length,r=new Uint32Array(t+1),n=new Float64Array(t),i=0,s=0,a=Number.MAX_VALUE,o=5e-324;return nR(nj(e,rg),(e,t)=>{n[t]=e}),wS(()=>({buckets:(()=>{let e=new n$(t),i=0;for(let s=0;s<t;s++){let t=n[s];i+=r[s],e[s]=[t,i]}return e})(),count:i,min:a,max:o,sum:s}),e=>{let l=0,c=t;for(;l!==c;){let t=Math.floor(l+(c-l)/2);e<=n[t]?c=t:l=t,c===l+1&&(e<=n[l]?c=l:l=c)}r[l]=r[l]+1,i+=1,s+=e,e<a&&(a=e),e>o&&(o=e)})}}("sketchi_codemode_duration_ms",{description:"Code Mode boundary duration in milliseconds",boundaries:nC(nU(new Set([1,5,10,25,50,100,250,500,1e3,2500,5e3,1e4]),e=>e>0),1/0)});class wz extends nQ()("@sketchi/diagram-agent/CodeModeRuntimeEnvironment"){}function wV(e){return null===e||"object"!=typeof e||Array.isArray(e)?void 0:Object.fromEntries(Object.entries(e))}function wJ(e,t,r){let n,i,s,a;return wM(lR(function*(){let t=yield*oA,n=yield*r,i=yield*oA,s=n.ok?"success":"failure",a=n.ok?void 0:n.status??"unknown_failure";yield*wN(wU,1,{...a?{failureCategory:a}:{},operation:e,outcome:s,surface:"code_mode"}),yield*wN(wK,i-t,{...a?{failureCategory:a}:{},operation:e,outcome:s,surface:"code_mode"}),a&&(yield*wN(wB,1,{failureCategory:a,operation:e,surface:"code_mode"}));let o="buildFlowchart"===e?"flowchart":"buildMindmap"===e?"mindmap":"applyDiagramPatch"===e?"patch":void 0;return n.ok&&o&&(yield*wN(wq,1,{artifactKind:o,operation:e,surface:"code_mode"})),n}),(n=wV(t),i=wV(n?.source),s="string"==typeof n?.artifactId?n.artifactId:"string"==typeof i?.artifactId?i.artifactId:void 0,a="string"==typeof n?.requestId?n.requestId:void 0,{...s?{artifactId:s}:{},...a?{requestId:a}:{}}))}lw(wz,{createId:wZ});class wW extends gA()("CodeModeArtifactExportError",{cause:gv(),message:m5,optionPath:m8}){}class wY extends gA()("BuildFlowchartFailure",{message:m5,status:gi(["invalid_input","invalid_flowchart","quality_failed","render_failed","export_failed","storage_failed"])}){context;constructor(e){super({message:e.context.issues[0]?.message??e.status,status:e.status}),this.context=e.context}}class wG extends gA()("BuildMindmapFailure",{message:m5,status:gi(["invalid_input","invalid_mindmap","quality_failed","render_failed","export_failed","storage_failed"])}){context;constructor(e){super({message:e.context.issues[0]?.message??e.status,status:e.status}),this.context=e.context}}class wH extends gA()("GetArtifactFailure",{message:m5,status:gi(["invalid_input","not_found","format_unavailable","expired","storage_failed"])}){issues;constructor(e){super({message:e.issues[0]?.message??e.status,status:e.status}),this.issues=e.issues}}class wQ extends gA()("ApplyDiagramPatchFailure",{message:m5,status:gi(["invalid_input","source_unavailable","target_not_found","unsupported_operation","connectivity_changed","render_failed","export_failed","storage_failed"])}){context;constructor(e){super({message:e.context.issues[0]?.message??e.status,status:e.status}),this.context=e.context}}function wZ(e){return`${e}_${globalThis.crypto.randomUUID()}`}function wX(e){return{code:e.code,severity:e.severity??"error",stage:e.stage,...e.ref?{ref:e.ref}:{},message:e.message,hint:e.hint}}function w0(e){return 0===e.length?"input":e.map(e=>"number"==typeof e?`[${e}]`:String(e)).join(".")}function w1(e){let t=w0(e.path);return w2(t)?"unsupported_patch_operation":e.message.startsWith("Invalid input: expected")?"invalid_type":e.message.startsWith("Invalid option:")?"invalid_enum":t.toLowerCase().includes("color")?"invalid_color":"input"===t?"invalid_type":"missing_field"}function w2(e){return/^operations\.\[\d+\]\.op$/.test(e)}function w3(e){let t=e.issues.slice(0,20).map(e=>{let t=w0(e.path);return wX({code:w1(e),stage:"input",ref:{kind:"request",path:t},message:e.message,hint:w2(t)?`Use one of: ${yx.join(", ")}. For label edits, use replaceText with selector plus text.`:"source"===t?"Pass source: { artifactId } from an accepted build or patch, or source: { scene } for inline Sketchi scene patching.":`Fix ${t} so it matches the Code Mode API contract.`})});return e.issues.length>20&&t.push(wX({code:"invalid_type",stage:"input",ref:{kind:"request",path:"input"},message:`${e.issues.length-20} additional input issues were omitted.`,hint:"Fix the summarized request shape before retrying."})),t}function w5(e){return e.checks.map(e=>{var t;return wX({code:"generic_label"===(t=e.code)||"label_too_long"===t||"disconnected_graph"===t?t:"quality_below_threshold",severity:e.severity,stage:"quality",message:e.message,hint:"error"===e.severity?"Repair the structural issue and call buildFlowchart again.":"Improve the labels or scope before styling the artifact."})})}function w4(e){return e?.artifactFormats??wD}function w8(e){return e?.inlineArtifacts??wR}let w6=lW("codeMode.artifacts.exportFormats")(function*(e){let t=[];for(let s of e.formats){var r,n,i;let a=yield*(r=e,"scene"===(n=s)?lD(r.scene):"excalidraw"===n?lD(function(e,t={}){return{type:"excalidraw",version:2,source:t.source??"https://sketchi.app",elements:e.elements,appState:e.appState,files:{}}}(r.excalidraw)):r.renderer?r.renderer.renderPng({scene:r.scene,excalidraw:r.excalidraw}).pipe(aO(e=>wW.make({cause:e,message:e instanceof Error?e.message:"Artifact export failed.",optionPath:!1}))):tJ(wW.make({cause:Error("PNG artifact rendering is not configured for this runtime."),message:"PNG artifact rendering is not configured for this runtime.",optionPath:!0})));t.push({format:s,mimeType:bz[s],data:a,sizeBytes:(i=a)instanceof ArrayBuffer||i instanceof Uint8Array?i.byteLength:bY(i)})}return t});function w9(e){return[wX({code:"render_failed",stage:"export",...e.optionPath?{ref:{kind:"artifact",path:"options.artifactFormats"}}:{},message:e.message,hint:e.optionPath?"Use the hosted Studio Code Mode runtime with its Cloudflare Browser Run binding, or omit png from artifactFormats.":"Retry the request; if it keeps failing, inspect the configured renderer."})]}function w7(e){return e.map(e=>wX({code:"overlapping-arrow-segment"===e.code?"arrow_overlap":"text-overflow"===e.code?"text_overflow":e.code.includes("binding")||e.code.includes("bound")||e.code.includes("endpoint")?"arrow_binding_invalid":"export_invalid_scene",stage:"export",ref:e.elementId?{kind:"artifact",id:e.elementId}:{kind:"artifact"},message:e.message,hint:"Inspect the rendered scene and retry with a simpler layout or patch."}))}function xe(e){return structuredClone(e)}function xt(e){return e.elements.filter(e=>"arrow"===e.type).map(e=>`${e.edgeId}:${e.sourceNodeId}->${e.targetNodeId}`).sort()}function xr(e){return e.elements.filter(e=>"node"===e.type)}function xn(e){return e.elements.filter(e=>"text"===e.type)}function xi(e){return e.elements.filter(e=>"arrow"===e.type)}function xs(e,t){if(!e||0===e.length||!t)return!1;let r=t.trim().toLowerCase();return e.some(e=>e.trim().toLowerCase()===r)}function xa(e,t){let r=t?.scope??"all",n=!!(t&&((t.ids?.length??0)>0||(t.nodeIds?.length??0)>0||(t.edgeIds?.length??0)>0||(t.kinds?.length??0)>0||(t.labels?.length??0)>0)),i=new Set(t?.ids??[]),s=new Set(t?.nodeIds??[]),a=new Set(t?.edgeIds??[]),o=new Set(t?.kinds??[]),l=xr(e).filter(e=>"edges"!==r&&(!t||!n||i.has(e.id)||s.has(e.nodeId)||!!e.kind&&[...o].some(t=>t===e.kind)||xs(t.labels,e.label))),c=xi(e).filter(e=>"nodes"!==r&&(!t||!n||i.has(e.id)||a.has(e.edgeId)||xs(t.labels,e.label))),u=new Set(l.map(e=>e.id)),d=new Set(c.map(e=>e.id));return{arrows:c,nodes:l,texts:xn(e).filter(e=>t&&n?i.has(e.id)||!!e.containerId&&u.has(e.containerId)||!!e.containerId&&d.has(e.containerId)||xs(t.labels,e.text):"nodes"===r?!!e.containerId&&u.has(e.containerId):"edges"!==r||!!e.containerId&&d.has(e.containerId))}}function xo(e){return wX({code:"unknown_patch_target",stage:"flowchart",ref:{kind:"request",path:"operations.selector"},message:`Patch operation "${e.op}" did not match any scene element.`,hint:"Use nodeIds, edgeIds, ids, kinds, labels, or scope values that exist in the accepted artifact."})}function xl(e,t){return xn(e).find(e=>e.containerId===t)}function xc(e,t){let r=new Set(t);for(let t of xi(e))(r.has(t.sourceNodeId)||r.has(t.targetNodeId))&&xf(e,t)}function xu(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function xd(e,t,r){let n=xu(e),i=xu(t),s=i.x-n.x,a=i.y-n.y;return Math.abs(s)>Math.abs(a)?s>=0&&r||s<0&&!r?{x:e.x+e.width,y:n.y}:{x:e.x,y:n.y}:a>=0&&r||a<0&&!r?{x:n.x,y:e.y+e.height}:{x:n.x,y:e.y}}function xf(e,t){let r,n,i=new Map(xr(e).map(e=>[e.nodeId,e])),s=i.get(t.sourceNodeId),a=i.get(t.targetNodeId);if(!s||!a)return[wX({code:"patch_output_invalid",stage:"render",ref:{kind:"edge",id:t.edgeId},message:`Arrow "${t.id}" references a node that is not in the scene.`,hint:"Rebuild the diagram with buildFlowchart or buildMindmap before applying visual patches."})];let o=xd(s,a,!0),l=xd(a,s,!1);if(Math.abs(l.y-o.y)>=Math.abs(l.x-o.x)){let e=(o.y+l.y)/2;t.points=[o,{x:o.x,y:e},{x:l.x,y:e},l]}else{let e=(o.x+l.x)/2;t.points=[o,{x:e,y:o.y},{x:e,y:l.y},l]}return r=xl(e,t.id),n=function(e){let t=e[0],r=e[e.length-1];if(t&&r)return{x:(t.x+r.x)/2,y:(t.y+r.y)/2-10}}(t.points),r&&n&&(r.x=n.x,r.y=n.y),[]}let xh=lW("codeMode.patch.resolveSource")(function*(e){if("scene"in e.source)return{scene:xe(e.source.scene)};let t=yield*bK,r=yield*t.readManifest(e.source.artifactId).pipe(aO(e=>new wQ({status:"storage_failed",context:{issues:[bQ(e.message,"storage_read_failed")]}})));if(!r||r.artifactId!==e.source.artifactId||!r.formats.some(e=>"scene"===e.format))return yield*new wQ({status:"source_unavailable",context:{issues:[wX({code:"patch_source_unavailable",stage:"storage",ref:{kind:"artifact",id:e.source.artifactId},message:`Artifact "${e.source.artifactId}" does not have a valid source manifest.`,hint:"Rebuild with the appropriate build operation and patch the accepted artifact id."})]}});let n=yield*t.read(e.source.artifactId,"scene").pipe(aO(e=>new wQ({status:"storage_failed",context:{issues:[bQ(e.message,"storage_read_failed")]}})));if(!n)return yield*new wQ({status:"source_unavailable",context:{issues:[wX({code:"patch_source_unavailable",stage:"storage",ref:{kind:"artifact",id:e.source.artifactId},message:`Scene artifact "${e.source.artifactId}" is not available.`,hint:"Call buildFlowchart or buildMindmap first, then patch the accepted artifact id."})]}});let i=bt.safeParse(n.data);return i.success?{scene:xe(i.data),sourceArtifactId:e.source.artifactId}:yield*new wQ({status:"source_unavailable",context:{issues:[wX({code:"patch_source_unavailable",stage:"storage",ref:{kind:"artifact",id:e.source.artifactId},message:`Scene artifact "${e.source.artifactId}" could not be decoded.`,hint:"Rebuild with the appropriate build operation and patch the new artifact."})]}})});function xp(e){return e?{requestId:e}:{}}function xm(e,t){if(!t)return e;let r=e.formats.map(r=>({...r,url:t({artifactId:e.artifactId,format:r.format})})),n=e.preview?r.find(t=>t.format===e.preview?.format):void 0;return{...e,formats:r,...n?{preview:n}:{}}}function xg(e){return{diagramId:e.diagramId,formats:[{format:"scene",mimeType:bz.scene,inline:e,sizeBytes:bY(e)}]}}function xy(e){return{ok:!1,status:e.status,...e.context.buildId?{buildId:e.context.buildId}:{},...e.context.requestId?{requestId:e.context.requestId}:{},...e.context.normalizedSpec?{normalizedSpec:e.context.normalizedSpec}:{},...e.context.quality?{quality:e.context.quality}:{},...e.context.partial?{partial:e.context.partial}:{},issues:e.context.issues}}function xb(e){return{ok:!1,status:e.status,...e.context.buildId?{buildId:e.context.buildId}:{},...e.context.requestId?{requestId:e.context.requestId}:{},...e.context.normalizedSpec?{normalizedSpec:e.context.normalizedSpec}:{},...e.context.quality?{quality:e.context.quality}:{},...e.context.partial?{partial:e.context.partial}:{},issues:e.context.issues}}function xv(e){return{ok:!1,status:e.status,issues:e.issues}}function xw(e){return{ok:!1,status:e.status,...e.context.patchId?{patchId:e.context.patchId}:{},...e.context.requestId?{requestId:e.context.requestId}:{},...e.context.sourceArtifactId?{sourceArtifactId:e.context.sourceArtifactId}:{},...e.context.partial?{partial:e.context.partial}:{},issues:e.context.issues}}function xx(e,t){return bQ(e.message,t)}let xk=lW("codeMode.buildMindmap.workflow")(function*(e){let t=yield*sL(()=>(function(e){let t=wV(wV(wV(e)?.spec)?.root);if(!t)return[];let r=[{depth:0,topic:t}],n=1;for(;r.length>0;){let e=r.pop();if(!e)continue;if(e.depth>8)return[wX({code:"mindmap_too_deep",stage:"mindmap",ref:{kind:"request",path:"spec.root.children"},message:"Mindmap depth exceeds the supported maximum of 8.",hint:"Combine overly deep topics into a shallower hierarchy."})];let t=e.topic.children;if(Array.isArray(t)){if((n+=t.length)>100)return[wX({code:"mindmap_too_large",stage:"mindmap",ref:{kind:"request",path:"spec.root"},message:"Mindmap exceeds the supported maximum of 100 topic slots.",hint:"Split this hierarchy into smaller focused mindmaps."})];for(let n=t.length-1;n>=0;n-=1){let i=wV(t[n]);i&&r.push({depth:e.depth+1,topic:i})}}}return[]})(e)).pipe(lJ("codeMode.buildMindmap.preflight"));if(t.length>0)return yield*new wG({status:"invalid_mindmap",context:{issues:t}});let r=yield*sL(()=>y5.safeParse(e)).pipe(lJ("codeMode.buildMindmap.parse"));if(!r.success)return yield*new wG({status:"invalid_input",context:{issues:w3(r.error)}});let n=yield*wz,i=yield*bK,s=r.data,a=yield*sL(()=>n.createId("build")),o=yield*sL(()=>{var e;let t,r;return e=s.spec,t=(e,r)=>({id:`topic-${r.join("-")}`,label:gJ(e.label),children:(e.children??[]).map((e,n)=>t(e,[...r,n]))}),r=gJ(e.title),{id:function(e){if(void 0===e)return;let t=gJ(e);return t.length>0?t:void 0}(e.id)??(r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"sketchi-mindmap"),title:r,root:t(e.root,[0]),layout:{direction:e.layout.direction},style:e.style}}).pipe(lJ("codeMode.buildMindmap.normalize")),l={buildId:a,...xp(s.requestId),normalizedSpec:o},c=yield*sL(()=>{let e,t,r,n,i;return e=0,t=0,(r=(n,i)=>{e+=1,t=Math.max(t,i),n.children.forEach(e=>r(e,i+1))})(o.root,0),i=[],(n={count:e,depth:t}).count<2&&i.push(wX({code:"disconnected_graph",stage:"mindmap",ref:{kind:"diagram",id:o.id},message:"Mindmap root must contain at least one child topic.",hint:"Add one or more nested topics under spec.root.children."})),n.depth>8&&i.push(wX({code:"mindmap_too_deep",stage:"mindmap",ref:{kind:"diagram",id:o.id},message:`Mindmap depth ${n.depth} exceeds the supported maximum of 8.`,hint:"Combine overly deep topics into a shallower hierarchy."})),n.count>100&&i.push(wX({code:"mindmap_too_large",stage:"mindmap",ref:{kind:"diagram",id:o.id},message:`Mindmap has ${n.count} topics; the supported maximum is 100.`,hint:"Split this hierarchy into smaller focused mindmaps."})),i}).pipe(lJ("codeMode.buildMindmap.validate"));if(c.length>0)return yield*new wG({status:"invalid_mindmap",context:{...l,issues:c}});let u=yield*sz({try:()=>{let e,t,r;return e=[],t=[],(r=(n,i,s,a)=>{e.push({id:n.id,label:n.label,kind:0===i?"root":"topic",metadata:{depth:i,siblingIndex:s}}),a&&t.push({id:`branch-${n.id.slice(6)}`,source:a,target:n.id,metadata:{depth:i,siblingIndex:s}}),n.children.forEach((e,t)=>r(e,i+1,t,n.id))})(o.root,0,0),vI({id:o.id,title:o.title,type:"mindmap",nodes:e,edges:t,layout:{direction:o.layout.direction,edgeRouting:"curved"},style:o.style})},catch:e=>new wG({status:"invalid_mindmap",context:{...l,issues:[wX({code:"disconnected_graph",stage:"mindmap",ref:{kind:"diagram",id:o.id},message:e instanceof Error?e.message:"Mindmap failed core validation.",hint:"Repair the nested topic hierarchy and call buildMindmap again."})]}})}).pipe(lJ("codeMode.buildMindmap.canonicalize")),d=yield*sL(()=>{var e;let t,r;return e=s.options?.minQualityScore??8,{accepted:(r=Math.max(0,10-2*(t=u.nodes.filter(e=>/^(topic|branch|item|mindmap)$/i.test(e.label.trim()))).length))>=e,score:r,threshold:e,summary:{nodeCount:u.nodes.length,edgeCount:u.edges.length},checks:t.map(e=>({code:"generic_label",passed:!1,severity:"warning",message:`Topic "${e.label}" is too generic.`,refs:[{kind:"node",id:e.id}]}))}}).pipe(lJ("codeMode.buildMindmap.quality")),f={...l,quality:d};if(!d.accepted)return yield*new wG({status:"quality_failed",context:{...f,issues:w5(d)}});let h=yield*sz({try:()=>wf(u),catch:e=>new wG({status:"render_failed",context:{...f,issues:[wX({code:"render_failed",stage:"render",ref:{kind:"diagram",id:o.id},message:e instanceof Error?e.message:"Unable to render mindmap scene.",hint:"Simplify the hierarchy or retry with a smaller mindmap."})]}})}).pipe(lJ("codeMode.buildMindmap.render")),{excalidraw:p,exportValidation:m}=yield*sL(()=>{let e=vz(h);return{excalidraw:e,exportValidation:vZ(e)}}).pipe(lJ("codeMode.buildMindmap.exportValidate")),g={...f,partial:xg(h)};if(!m.ok)return yield*new wG({status:"export_failed",context:{...g,issues:w7(m.issues)}});let y=yield*w6({formats:w4(s.options),scene:h,excalidraw:p,renderer:n.renderer}).pipe(aO(e=>new wG({status:"export_failed",context:{...g,issues:w9(e)}}))),b=yield*sL(()=>n.createId("artifact")),v=yield*wM(i.write({artifactId:b,diagramId:h.diagramId,formats:y,inlineFormats:w8(s.options)}),{artifactId:b,...s.requestId?{requestId:s.requestId}:{}}).pipe(aO(e=>new wG({status:"storage_failed",context:{...f,partial:{diagramId:h.diagramId},issues:[xx(e,"storage_write_failed")]}})));return{ok:!0,status:"accepted",buildId:a,...xp(s.requestId),normalizedSpec:o,quality:d,artifact:xm(v,n.artifactUrl),issues:[]}}),xS=lW("codeMode.buildFlowchart.workflow")(function*(e){let t=yield*sL(()=>yJ.safeParse(e)).pipe(lJ("codeMode.buildFlowchart.parse"));if(!t.success)return yield*new wY({status:"invalid_input",context:{issues:w3(t.error)}});let r=yield*wz,n=yield*bK,i=t.data,s=w4(i.options),a=yield*sL(()=>r.createId("build")),o=yield*sL(()=>{var e;let t;return t=gJ((e=i.spec).title),{id:wP(e.id)??(t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"sketchi-flowchart"),title:t,nodes:e.nodes.map(e=>({id:gJ(e.id),label:gJ(e.label),kind:e.kind,...e.description?{description:gJ(e.description)}:{}})),edges:e.edges.map((e,t)=>({id:wP(e.id)??`edge-${t+1}`,source:gJ(e.source),target:gJ(e.target),...e.label?{label:gJ(e.label)}:{}})),layout:{direction:e.layout.direction},style:{accentColor:e.style.accentColor,backgroundColor:e.style.backgroundColor}}}).pipe(lJ("codeMode.buildFlowchart.normalize")),l={buildId:a,...xp(i.requestId),normalizedSpec:o},c=yield*sL(()=>vp.safeParse({id:o.id,title:o.title,type:"flowchart",nodes:o.nodes.map(e=>({...e,metadata:{}})),edges:o.edges.map(e=>({...e,metadata:{}})),layout:{direction:o.layout.direction,edgeRouting:"orthogonal"},style:o.style,metadata:{}})).pipe(lJ("codeMode.buildFlowchart.parseCanonical"));if(!c.success){var u;return yield*new wY({status:"invalid_flowchart",context:{...l,issues:(u=c.error,u.issues.slice(0,20).map(e=>{let t=function(e,t){let r=w0(e.path),n="input"===r?"spec":`spec.${r}`,[i,s]=e.path;if("nodes"===i&&"number"==typeof s){let e=t.nodes[s]?.id;return{kind:"node",...e?{id:e}:{},path:n}}if("edges"===i&&"number"==typeof s){let e=t.edges[s]?.id;return{kind:"edge",...e?{id:e}:{},path:n}}return{kind:"diagram",id:t.id,path:n}}(e,o);return wX({code:w1(e),stage:"flowchart",ref:t,message:e.message,hint:`Fix ${t.path??"spec"} so normalization produces a valid canonical flowchart value.`})}))}})}let d=c.data,f=yield*sL(()=>vy(d).map(e=>{let t=function(e){if(e)return{kind:e.kind,...e.id?{id:e.id}:{},...e.path?{path:`spec.${e.path}`}:{}}}(e.ref);return wX({code:e.code,stage:"flowchart",...t?{ref:t}:{},message:e.message,hint:e.hint})})).pipe(lJ("codeMode.buildFlowchart.validate"));if(f.length>0)return yield*new wY({status:"invalid_flowchart",context:{...l,issues:f}});yield*sL(()=>vv(d)).pipe(lJ("codeMode.buildFlowchart.assertValid"));let h=yield*sL(()=>(function(e,t){let r=[],n=0,i=(e,t,i=!1)=>{n+=e,r.push({severity:i?"error":"warning",message:t})},s=new Map,a=new Map;for(let t of e.edges)s.set(t.source,(s.get(t.source)??0)+1),s.set(t.target,(s.get(t.target)??0)+1),a.set(t.source,[...a.get(t.source)??[],t]);if(e.nodes.length>1&&0===e.edges.length)i(5,"no edges at all — every node floats unconnected",!0);else{let t=e.nodes.filter(e=>(s.get(e.id)??0)===0);t.length>0&&e.nodes.length>1&&i(Math.min(1.5*t.length,4.5),`unconnected node(s): ${t.map(e=>e.id).join(", ")}`,!0);let r=function(e){let t=new Map;for(let r of e.nodes)t.set(r.id,[]);for(let r of e.edges)t.get(r.source)?.push(r.target),t.get(r.target)?.push(r.source);let r=new Set,n=0;for(let i of e.nodes){if(r.has(i.id))continue;n+=1;let e=[i.id];for(r.add(i.id);e.length>0;){let n=e.pop();if(void 0===n)break;for(let i of t.get(n)??[])r.has(i)||(r.add(i),e.push(i))}}return n}(e);r>1&&0===t.length&&i(2,`diagram splits into ${r} disconnected islands`,!0)}e.nodes.length<3?i(2,"too sparse — a useful flow needs at least 3 nodes"):e.nodes.length>24&&i(2,"too dense — trim or merge nodes (24 max)");let o=new Map;for(let t of e.nodes){let e=t.label.trim().toLowerCase();o.set(e,(o.get(e)??0)+1)}let l=[...o.entries()].filter(([,e])=>e>1);l.length>0&&i(Math.min(l.length,3),`duplicate label(s): ${l.map(([e])=>`"${e}"`).join(", ")}`);let c=0,u=0;for(let t of e.nodes.filter(wL)){let e=a.get(t.id)??[];e.length<2?(c+=1,r.push({severity:"error",message:`decision "${t.id}" needs at least 2 outgoing branches`})):e.some(e=>!e.label)&&(u+=1,r.push({severity:"warning",message:`label every branch out of decision "${t.id}" (yes/no, …)`}))}n+=Math.min(1.5*c,4.5)+Math.min(u,3);let d=e.nodes.filter(e=>e.label.length>42);d.length>0&&i(Math.min(.5*d.length,2),`shorten label(s): ${d.map(e=>e.id).join(", ")}`);let f=e.nodes.filter(e=>wj.test(e.label.trim()));f.length>0&&i(Math.min(f.length,3),`generic label(s) say nothing: ${f.map(e=>`"${e.label}"`).join(", ")}`),(e.title.trim().length<4||wF.test(e.title.trim()))&&i(.5,"give the diagram a specific title");let h=Math.max(0,Math.round((10-n)*10)/10),p=r.map(e=>{var t;return{code:(t=e.message).includes("generic label")?"generic_label":t.includes("shorten label")?"label_too_long":t.includes("disconnected")?"disconnected_graph":"quality_below_threshold",passed:!1,severity:e.severity,message:e.message,refs:[]}});return{accepted:h>=t&&!p.some(e=>"error"===e.severity),score:h,threshold:t,summary:{nodeCount:e.nodes.length,edgeCount:e.edges.length},checks:p}})(d,i.options?.minQualityScore??8)).pipe(lJ("codeMode.buildFlowchart.quality")),p={...l,quality:h};if(!h.accepted)return yield*new wY({status:"quality_failed",context:{...p,issues:w5(h)}});let m=yield*sz({try:()=>wf(d),catch:e=>new wY({status:"render_failed",context:{...p,issues:[wX({code:"render_failed",stage:"render",ref:{kind:"diagram",id:o.id},message:e instanceof Error?e.message:"Unable to render flowchart scene.",hint:"Simplify the graph or retry with a smaller flowchart."})]}})}).pipe(lJ("codeMode.buildFlowchart.render")),{excalidraw:g,validation:y}=yield*sL(()=>{let e=vz(m);return{excalidraw:e,validation:vZ(e)}}).pipe(lJ("codeMode.buildFlowchart.exportValidate")),b={...p,partial:xg(m)};if(!y.ok)return yield*new wY({status:"export_failed",context:{...b,issues:w7(y.issues)}});let v=yield*w6({formats:s,scene:m,excalidraw:g,renderer:r.renderer}).pipe(aO(e=>new wY({status:"export_failed",context:{...b,issues:w9(e)}}))),w=yield*sL(()=>r.createId("artifact")),x=yield*wM(n.write({artifactId:w,diagramId:m.diagramId,formats:v,inlineFormats:w8(i.options)}),{artifactId:w,...i.requestId?{requestId:i.requestId}:{}}).pipe(aO(e=>new wY({status:"storage_failed",context:{...p,issues:[xx(e,"storage_write_failed")]}})));return{ok:!0,status:"accepted",buildId:a,...xp(i.requestId),normalizedSpec:o,quality:h,artifact:xm(x,r.artifactUrl),issues:[]}}),x_=lW("codeMode.getArtifact.workflow")(function*(e){let t=yield*sL(()=>bo.safeParse(e)).pipe(lJ("codeMode.getArtifact.parse"));if(!t.success)return yield*new wH({status:"invalid_input",issues:w3(t.error)});let r=yield*wz,n=yield*bK,i=t.data,s=yield*n.readManifest(i.artifactId).pipe(aO(e=>new wH({status:"storage_failed",issues:[xx(e,"storage_read_failed")]})));if(!s)return yield*new wH({status:"not_found",issues:[wX({code:"patch_source_unavailable",stage:"storage",ref:{kind:"artifact",id:i.artifactId},message:`Artifact "${i.artifactId}" was not found.`,hint:"Use the artifactId returned by buildFlowchart or applyDiagramPatch."})]});let a=i.format??"scene";if(!s.formats.some(e=>e.format===a))return yield*new wH({status:"format_unavailable",issues:[wX({code:"unsupported_artifact_format",stage:"storage",ref:{kind:"artifact",id:i.artifactId},message:`Artifact "${i.artifactId}" does not include format "${a}".`,hint:"Request a format listed in the artifact bundle."})]});let o=yield*n.read(i.artifactId,a).pipe(aO(e=>new wH({status:"storage_failed",issues:[xx(e,"storage_read_failed")]})));return o?{ok:!0,artifactId:i.artifactId,diagramId:s.diagramId,format:a,mimeType:o.mimeType,...r.artifactUrl?{url:r.artifactUrl({artifactId:i.artifactId,format:a})}:{},...!0!==i.inline||!bV(a)?{}:{inline:o.data},sizeBytes:o.sizeBytes,...s.provenance?{provenance:s.provenance}:{}}:yield*new wH({status:"format_unavailable",issues:[wX({code:"patch_source_unavailable",stage:"storage",ref:{kind:"artifact",id:i.artifactId},message:`Artifact "${i.artifactId}" format "${a}" could not be read.`,hint:"Retry retrieval or rebuild the artifact."})]})}),x$=lW("codeMode.applyDiagramPatch.workflow")(function*(e){let t=yield*sL(()=>b_.safeParse(e)).pipe(lJ("codeMode.applyDiagramPatch.parse"));if(!t.success)return yield*new wQ({status:"invalid_input",context:{issues:w3(t.error)}});let r=yield*wz,n=yield*bK,i=t.data,s=yield*sL(()=>r.createId("patch")),a={patchId:s,...xp(i.requestId)},o=w4(i.options),l=yield*xh(i).pipe(aO(e=>new wQ({status:e.status,context:{...a,...e.context}}))),c={...a,...l.sourceArtifactId?{sourceArtifactId:l.sourceArtifactId}:{}},u=l.scene,d=xt(u),f=yield*sL(()=>{for(let e of i.operations){let t=function(e,t){switch(t.op){case"setDefaultStyle":case"setStyle":if(t.style.backgroundColor&&(e.backgroundColor=t.style.backgroundColor),"setDefaultStyle"===t.op){for(let r of(t.style.strokeColor&&(e.accentColor=t.style.strokeColor),xr(e)))t.style.fillColor&&(r.fillColor=t.style.fillColor),t.style.strokeColor&&(r.strokeColor=t.style.strokeColor),t.style.textColor&&(r.textColor=t.style.textColor);for(let r of xi(e))t.style.strokeColor&&(r.strokeColor=t.style.strokeColor),t.style.textColor&&(r.textColor=t.style.textColor);for(let r of xn(e))t.style.textColor&&(r.textColor=t.style.textColor);return[]}let r=xa(e,t.selector);if(0===r.nodes.length&&0===r.arrows.length&&0===r.texts.length)return[xo(t)];for(let n of r.nodes)if(t.style.fillColor&&(n.fillColor=t.style.fillColor),t.style.strokeColor&&(n.strokeColor=t.style.strokeColor),t.style.textColor){n.textColor=t.style.textColor;let r=xl(e,n.id);r&&(r.textColor=t.style.textColor)}for(let n of r.arrows)if(t.style.strokeColor&&(n.strokeColor=t.style.strokeColor),t.style.textColor){n.textColor=t.style.textColor;let r=xl(e,n.id);r&&(r.textColor=t.style.textColor)}for(let e of r.texts)t.style.textColor&&(e.textColor=t.style.textColor);return[];case"setShape":let n=xa(e,t.selector);if(0===n.nodes.length)return[xo(t)];let i=[];for(let r of n.nodes){if(r.shape=t.shape,"circle"===t.shape){let e=Math.max(r.width,r.height);r.x-=(e-r.width)/2,r.y-=(e-r.height)/2,r.width=e,r.height=e,i.push(r.nodeId)}!function(e,t){let r=xl(e,t.id);r&&(r.x=t.x+t.width/2,r.y=t.y+t.height/2)}(e,r)}return xc(e,i),[];case"translate":return function(e,t){let r=xa(e,t.selector);if(0===r.nodes.length&&0===r.arrows.length&&0===r.texts.length)return[xo(t)];let n=new Set,i=new Set;for(let s of r.nodes){s.x+=t.dx,s.y+=t.dy,n.add(s.nodeId);let r=xl(e,s.id);r&&(r.x+=t.dx,r.y+=t.dy,i.add(r.id))}for(let n of r.arrows){n.points=n.points.map(e=>{var r,n;return r=t.dx,n=t.dy,{x:e.x+r,y:e.y+n}});let r=xl(e,n.id);r&&(r.x+=t.dx,r.y+=t.dy,i.add(r.id))}for(let e of r.texts)i.has(e.id)||(e.x+=t.dx,e.y+=t.dy);return xc(e,[...n]),function(e){let t=[e.width],r=[e.height];for(let n of xr(e))t.push(n.x+n.width),r.push(n.y+n.height);for(let n of xn(e))t.push(n.x+(n.maxWidth??0)),r.push(n.y+n.fontSize);for(let n of xi(e))for(let e of n.points)t.push(e.x),r.push(e.y);e.width=Math.max(...t)+48,e.height=Math.max(...r)+48}(e),[]}(e,t);case"replaceText":let s=xa(e,t.selector);if(0===s.nodes.length&&0===s.arrows.length&&0===s.texts.length)return[xo(t)];for(let r of s.nodes){r.label=t.text;let n=xl(e,r.id);n&&(n.text=t.text)}for(let r of s.arrows){r.label=t.text;let n=xl(e,r.id);n&&(n.text=t.text)}for(let e of s.texts)e.text=t.text;return[];case"rerouteEdges":let a;return 0===(a=xa(e,t.selector)).arrows.length?[xo(t)]:a.arrows.flatMap(t=>xf(e,t))}}(u,e);if(t.length>0)return t}return[]}).pipe(lJ("codeMode.applyDiagramPatch.operations"));if(f.length>0)return yield*new wQ({status:f[0]?.code==="unknown_patch_target"?"target_not_found":"unsupported_operation",context:{...c,issues:f}});if(i.options?.preserveConnectivity!==!1){let e=xt(u);if(!(d.length===e.length&&d.every((t,r)=>t===e[r])))return yield*new wQ({status:"connectivity_changed",context:{...c,issues:[wX({code:"patch_preserve_connectivity_failed",stage:"flowchart",ref:{kind:"diagram",id:u.diagramId},message:"Patch changed the diagram edge connectivity.",hint:"Use buildFlowchart for process-graph structure or buildMindmap for hierarchy structure."})]}})}let h=yield*sL(()=>(function(e){let t=[];for(let r of e.elements){if("arrow"===r.type){let e=r.points[0],n=r.points[1],i=r.points.slice(2);if(!e||!n)return null;let s=[e,n,...i];t.push({type:"arrow",id:r.id,edgeId:r.edgeId,sourceNodeId:r.sourceNodeId,targetNodeId:r.targetNodeId,...r.strokeColor?{strokeColor:r.strokeColor}:{},...r.textColor?{textColor:r.textColor}:{},points:s,...r.label?{label:r.label}:{}});continue}if("node"===r.type){t.push({type:"node",id:r.id,nodeId:r.nodeId,...r.kind?{kind:r.kind}:{},shape:r.shape,...r.fillColor?{fillColor:r.fillColor}:{},...r.strokeColor?{strokeColor:r.strokeColor}:{},...r.textColor?{textColor:r.textColor}:{},x:r.x,y:r.y,width:r.width,height:r.height,label:r.label});continue}t.push({type:"text",id:r.id,...r.containerId?{containerId:r.containerId}:{},...r.textColor?{textColor:r.textColor}:{},x:r.x,y:r.y,text:r.text,fontSize:r.fontSize,...r.maxWidth?{maxWidth:r.maxWidth}:{}})}return{diagramId:e.diagramId,title:e.title,width:e.width,height:e.height,accentColor:e.accentColor,backgroundColor:e.backgroundColor,elements:t}})(u)).pipe(lJ("codeMode.applyDiagramPatch.normalize"));if(!h)return yield*new wQ({status:"render_failed",context:{...c,issues:[wX({code:"patch_output_invalid",stage:"render",ref:{kind:"diagram",id:u.diagramId},message:"Patched scene has an invalid arrow point list.",hint:"Reroute edges or rebuild the flowchart artifact."})]}});let{excalidraw:p,validation:m}=yield*sL(()=>{let e=vz(h);return{excalidraw:e,validation:vZ(e)}}).pipe(lJ("codeMode.applyDiagramPatch.exportValidate")),g={...c,partial:xg(h)};if(!m.ok)return yield*new wQ({status:"export_failed",context:{...g,issues:w7(m.issues)}});let y=yield*w6({formats:o,scene:h,excalidraw:p,renderer:r.renderer}).pipe(aO(e=>new wQ({status:"export_failed",context:{...g,issues:w9(e)}}))),b=yield*sL(()=>r.createId("artifact")),v=yield*wM(n.write({artifactId:b,diagramId:h.diagramId,formats:y,inlineFormats:w8(i.options),...l.sourceArtifactId?{provenance:{sourceArtifactId:l.sourceArtifactId}}:{}}),{artifactId:b,...i.requestId?{requestId:i.requestId}:{}}).pipe(aO(e=>new wQ({status:"storage_failed",context:{...c,issues:[xx(e,"storage_write_failed")]}})));return{ok:!0,status:"accepted",patchId:s,...xp(i.requestId),...l.sourceArtifactId?{sourceArtifactId:l.sourceArtifactId}:{},artifact:xm(v,r.artifactUrl),issues:[]}});function xO(e,t){return e.pipe(aM({onFailure:t,onSuccess:e=>e}))}let xI=lW("codeMode.buildFlowchart")(e=>wJ("buildFlowchart",e,xO(xS(e),xy))),xC=lW("codeMode.buildMindmap")(e=>wJ("buildMindmap",e,xO(xk(e),xb)));lW("codeMode.getArtifact")(e=>wJ("getArtifact",e,xO(x_(e),xv))),lW("codeMode.applyDiagramPatch")(e=>wJ("applyDiagramPatch",e,xO(x$(e),xw)));class xE extends gA()("CliFilesystemError",{cause:gv(),operation:m5,path:m5,message:m5}){}class xA extends gA()("CliInputError",{code:gi(["input_read_failed","invalid_json","interactive_stdin"]),message:m5,hint:m5}){}class xT extends gA()("CliValidationError",{message:m5,hint:m5,details:gt(m5)}){}class xM extends gA()("CliBuildError",{status:m5,message:m5,hint:m5,details:gt(m5)}){}class xN extends gA()("CliGenerationError",{code:gi(["provider_failure","generation_timeout","malformed_output","invalid_generated_document"]),message:m5,hint:m5,details:gt(m5)}){}class xj extends gA()("CliStorageError",{code:gi(["diagram_not_found","diagram_already_exists","diagram_busy","corrupt_record","unsafe_storage_entry","storage_commit_failed"]),diagramId:mG(m5),message:m5,hint:m5}){}class xF extends gA()("CliExportError",{code:gi(["format_unavailable","export_write_failed"]),format:m5,message:m5,hint:m5}){}function xL(e){return"string"==typeof e||"number"==typeof e||"symbol"==typeof e}let xP=hk(),xD=mJ(yD,{errors:"all"}),xR=mJ(y2,{errors:"all"});function xU(e){return xT.make({message:"The canonical diagram document is invalid.",hint:'Use {"type":"flowchart","spec":...} or {"type":"mindmap","spec":...}.',details:e})}function xB(e){return xP(e).issues.map(e=>{var t;let r=(e.path??[]).flatMap(e=>{let t=xL(e)?e:null!==e&&"object"==typeof e&&"key"in e&&xL(e.key)?e.key:void 0;return void 0===t?[]:[t]});return`${0===(t=["spec",...r]).length?"document":t.map(e=>"number"==typeof e?`[${e}]`:String(e)).join(".")}: ${e.message}`})}let xq=lW("sketchi.cli.document.decodeCanonical")(function*(e){let t=function(e){if(!("object"!=typeof e||null===e||Array.isArray(e))&&"type"in e&&"spec"in e)return{type:e.type,spec:e.spec}}(e);return t?"flowchart"===t.type?{type:"flowchart",spec:yield*xD(t.spec).pipe(aO(e=>xU(xB(e.issue))))}:"mindmap"===t.type?{type:"mindmap",spec:yield*xR(t.spec).pipe(aO(e=>xU(xB(e.issue))))}:yield*xU(['document.type: Expected "flowchart" or "mindmap".']):yield*xU(["document: Expected an object with type and spec."])}),xK=lW("sketchi.cli.document.parseJson")(function*(e){let t=yield*sz({try:()=>JSON.parse(e),catch:()=>xA.make({code:"invalid_json",message:"The input is not valid JSON.",hint:"Pass one complete canonical document object."})});return yield*xq(t)});function xz(e){return`${JSON.stringify(e,null,2)}
38
- `}function xV(e){let t=e.spec.id?.trim();return t||e.spec.title.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||`sketchi-${e.type}`}function xJ(e){return/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/.test(e)?lD(e):tJ(xT.make({message:`Diagram id "${e}" is not safe for local storage.`,hint:"Use 1-128 ASCII letters, digits, dots, underscores, or hyphens; start with a letter or digit.",details:["spec.id"]}))}class xW extends nQ()("@sketchi/cli/DiagramBuilder"){}function xY(e){let t=e.ref?.path?` (${e.ref.path})`:"";return`${e.code}${t}: ${e.message}`}function xG(e,t){let r=e.formats.find(e=>e.format===t);return r?.inline!==void 0?lD(r.inline):tJ(xM.make({status:"missing_inline_artifact",message:`Code Mode did not return the ${t} artifact inline.`,hint:"Rebuild the document with the required offline artifact formats.",details:[t]}))}function xH(e){let t=bt.safeParse(e);return t.success?lD(t.data):tJ(xM.make({status:"invalid_scene_artifact",message:"Code Mode returned an invalid scene artifact.",hint:"Inspect the Code Mode build/export boundary.",details:t.error.issues.map(e=>e.message)}))}function xQ(e){let t=bs.safeParse(e);return t.success?lD(t.data):tJ(xM.make({status:"invalid_excalidraw_artifact",message:"Code Mode returned an invalid Excalidraw artifact.",hint:"Inspect the Code Mode build/export boundary.",details:t.error.issues.map(e=>e.message)}))}let xZ=lk(xW,lR(function*(){let e=yield*bK,t=yield*wz;return{build:lW("sketchi.cli.diagram.build")(function*(r){let n;if(!(n="flowchart"===r.type?yield*xI({spec:r.spec,options:{artifactFormats:["scene","excalidraw"],inlineArtifacts:["scene","excalidraw"]}}).pipe(af(bK,e),af(wz,t)):yield*xC({spec:r.spec,options:{artifactFormats:["scene","excalidraw"],inlineArtifacts:["scene","excalidraw"]}}).pipe(af(bK,e),af(wz,t))).ok){let e,t,r,i;return yield*(e=n.issues[0],t=e?.message??`Code Mode failed with ${n.status}.`,r=e?.hint??"Repair the document and retry.",i=n.issues.map(xY),"invalid_input"===n.status||"invalid_flowchart"===n.status||"invalid_mindmap"===n.status||"quality_failed"===n.status?xT.make({message:t,hint:r,details:i}):"storage_failed"===n.status?xj.make({code:"storage_commit_failed",message:t,hint:r}):xM.make({status:n.status,message:t,hint:r,details:i}))}let i=yield*xJ(xV(r)),s=yield*xG(n.artifact,"scene").pipe(s8(xH)),a=yield*xG(n.artifact,"excalidraw").pipe(s8(xQ));return{id:i,type:r.type,title:r.spec.title,document:r,scene:s,excalidraw:a}})}})),xX=1,x0="manifest.json",x1="document.json",x2="scene.json",x3="diagram.excalidraw",x5="diagram.png",x4="revisions";class x8 extends gC("DiagramRecordManifest")({schemaVersion:m1(xX),id:m5,type:gi(["flowchart","mindmap"]),title:m5,revision:gx.check(gp(0)),formats:gt(gi(["scene","excalidraw","png"]))}){}function x6(e){return{id:e.manifest.id,type:e.manifest.type,title:e.manifest.title,revision:e.manifest.revision,formats:e.manifest.formats}}function x9(e){return`${String(e).padStart(6,"0")}.json`}let x7=t("node:fs/promises");class ke extends nQ()("@sketchi/cli/LocalFileSystem"){}function kt(e,t,r){return xE.make({cause:r,operation:e,path:t,message:`Filesystem ${e} failed for ${t}.`})}function kr(e,t){return"object"==typeof e&&null!==e&&"code"in e&&e.code===t}let kn=lw(ke,{makeDirectory:(e,t=!1)=>lP({try:()=>(0,x7.mkdir)(e,{recursive:t}).then(()=>void 0),catch:t=>kt("make-directory",e,t)}),tryWriteText:(e,t)=>lP({try:async()=>{try{let r=await (0,x7.open)(e,u6.constants.O_WRONLY|u6.constants.O_CREAT|u6.constants.O_EXCL|u6.constants.O_NOFOLLOW,384);try{await r.writeFile(t,{encoding:"utf8"}),await r.sync()}finally{await r.close()}return!0}catch(e){if(kr(e,"EEXIST"))return!1;throw e}},catch:t=>kt("write-exclusive",e,t)}),tryLinkFile:(e,t)=>lP({try:async()=>{try{return await (0,x7.link)(e,t),!0}catch(e){if(kr(e,"EEXIST")||kr(e,"ENOENT"))return!1;throw e}},catch:r=>kt("link-exclusive",`${e} -> ${t}`,r)}),makeTempDirectory:(e,t)=>lP({try:()=>(0,x7.mkdtemp)((0,u7.join)(e,t)),catch:t=>kt("make-temp-directory",e,t)}),list:e=>lP({try:async()=>(await (0,x7.readdir)(e,{withFileTypes:!0})).map(e=>({name:e.name,kind:e.isFile()?"file":e.isDirectory()?"directory":e.isSymbolicLink()?"symbolic-link":"other"})),catch:t=>kt("read-directory",e,t)}),kind:e=>lP({try:async()=>{try{let t=await (0,x7.lstat)(e);if(t.isFile())return"file";if(t.isDirectory())return"directory";if(t.isSymbolicLink())return"symbolic-link";return"other"}catch(e){if(kr(e,"ENOENT"))return"missing";if(kr(e,"ELOOP"))return"symbolic-link";throw e}},catch:t=>kt("stat",e,t)}),readText:e=>lP({try:async()=>{let t=await (0,x7.open)(e,u6.constants.O_RDONLY|u6.constants.O_NOFOLLOW);try{return await t.readFile({encoding:"utf8"})}finally{await t.close()}},catch:t=>kt("read",e,t)}),readBytes:e=>lP({try:async()=>{let t=await (0,x7.open)(e,u6.constants.O_RDONLY|u6.constants.O_NOFOLLOW);try{return new Uint8Array(await t.readFile())}finally{await t.close()}},catch:t=>kt("read",e,t)}),writeText:(e,t,r=!1)=>lP({try:async()=>{let n=u6.constants.O_WRONLY|u6.constants.O_CREAT|u6.constants.O_NOFOLLOW|(r?u6.constants.O_TRUNC:u6.constants.O_EXCL),i=await (0,x7.open)(e,n,384);try{await i.writeFile(t,{encoding:"utf8"}),await i.sync()}finally{await i.close()}},catch:t=>kt("write",e,t)}),writeBytes:(e,t,r=!1)=>lP({try:async()=>{let n=u6.constants.O_WRONLY|u6.constants.O_CREAT|u6.constants.O_NOFOLLOW|(r?u6.constants.O_TRUNC:u6.constants.O_EXCL),i=await (0,x7.open)(e,n,384);try{await i.writeFile(t),await i.sync()}finally{await i.close()}},catch:t=>kt("write",e,t)}),rename:(e,t)=>lP({try:()=>(0,x7.rename)(e,t),catch:r=>kt("rename",`${e} -> ${t}`,r)}),tryRenameDirectory:(e,t)=>lP({try:async()=>{try{return await (0,x7.rename)(e,t),!0}catch(e){if(kr(e,"EEXIST")||kr(e,"ENOTEMPTY"))return!1;if(kr(e,"EPERM"))try{if((await (0,x7.lstat)(t)).isDirectory())return!1}catch{}throw e}},catch:r=>kt("rename-exclusive-directory",`${e} -> ${t}`,r)}),removeFile:e=>lP({try:async()=>{try{return await (0,x7.unlink)(e),!0}catch(e){if(kr(e,"ENOENT"))return!1;throw e}},catch:t=>kt("remove-file",e,t)}),remove:e=>lP({try:()=>(0,x7.rm)(e,{recursive:!0,force:!0}),catch:t=>kt("remove",e,t)})});class ki extends nQ()("@sketchi/cli/StorageRoot"){}class ks extends nQ()("@sketchi/cli/DiagramStore"){}let ka=".locks",ko="free.",kl="owner.",kc=".owner-candidate.",ku=".json",kd="recovery",kf=".backup.",kh=`.stage.${String(process.pid)}.`,kp=o7("10 millis").pipe(le({times:50})),km=lw(ki,{path:(0,u7.join)((0,u9.homedir)(),".sketchi","diagrams")});function kg(e,t,r,n){return xj.make({code:e,message:t,hint:r,...n?{diagramId:n}:{}})}function ky(e){return Buffer.from(e,"utf8").toString("base64url")}function kb(e,t){return e<t?-1:+(e>t)}function kv(e){if(!Number.isSafeInteger(e)||e<=0)return!1;try{return process.kill(e,0),!0}catch(e){return"object"==typeof e&&null!==e&&"code"in e&&"EPERM"===e.code}}function kw(e,t){return"object"==typeof e.cause&&null!==e.cause&&"code"in e.cause&&e.cause.code===t}function kx(e,t){return(0,u7.join)(e,t)}function kk(e,t){return kg("unsafe_storage_entry",`Unsafe local storage entry at ${e}.`,"Replace symbolic links or special files with ordinary Sketchi record files.",t)}let kS=lk(ks,lR(function*(){let e=yield*ke,t=yield*ki,r=lW("sketchi.cli.storage.ensureOwnedDirectory")(function*(t){let r=yield*e.kind(t);if("missing"===r&&(yield*e.makeDirectory(t).pipe(ab(e=>kw(e,"EEXIST")?sK:tJ(e))),r=yield*e.kind(t)),"directory"!==r)return yield*kk(t)}),n=lW("sketchi.cli.storage.ensureRoot")(function*(){yield*r((0,u7.dirname)(t.path)),yield*r(t.path),yield*r((0,u7.join)(t.path,ka))}),i=lW("sketchi.cli.storage.assertSafeTree")(function*(t,r){for(let n of yield*e.list(t)){let e=(0,u7.join)(t,n.name);if("symbolic-link"===n.kind||"other"===n.kind)return yield*kk(e,r);"directory"===n.kind&&(yield*i(e,r))}}),s=lW("sketchi.cli.storage.recoverStages")(function*(){for(let r of(yield*n(),[...yield*e.list(t.path)].sort((e,t)=>kb(e.name,t.name)))){if(!r.name.startsWith(".stage."))continue;let n=function(e){let t=Number(e.split(".").at(-2));return Number.isSafeInteger(t)?t:void 0}(r.name);void 0!==n&&kv(n)||(yield*e.remove((0,u7.join)(t.path,r.name)))}}),a=lW("sketchi.cli.storage.recoverRecordTransactions")(function*(r){yield*n(),yield*s();let i=`${kf}${ky(r)}.`;for(let n of[...yield*e.list(t.path)].filter(e=>e.name.startsWith(i)).sort((e,t)=>kb(e.name,t.name))){let i=(0,u7.join)(t.path,n.name),s=kx(t.path,r);"missing"===(yield*e.kind(s))?yield*e.rename(i,s):yield*e.remove(i)}}),o=lW("sketchi.cli.storage.initializeLockDirectory")(function*(r){let n=(0,u7.join)(t.path,ka,`${ky(r)}.lock`),i=yield*e.kind(n);if("directory"===i)return n;if("missing"!==i)return yield*kk(n,r);let s=(0,u7.join)(t.path,ka);return yield*lV(e.makeTempDirectory(s,`.init.${ky(r)}.`),t=>lR(function*(){let i=crypto.randomUUID();return(yield*e.writeText((0,u7.join)(t,`${ko}${i}${ku}`),xz({token:i})),(yield*e.tryRenameDirectory(t,n))||"directory"===(yield*e.kind(n)))?n:yield*kk(n,r)}),t=>e.remove(t))}),l=e=>kg("diagram_busy",`Diagram "${e}" is being changed by another Sketchi process.`,"Wait for that command to finish, then retry.",e),c=lW("sketchi.cli.storage.readLockEntries")(function*(t,r){let n=[...yield*e.list(t)].sort((e,t)=>kb(e.name,t.name)),i=[];for(let s of n){let n=(0,u7.join)(t,s.name);if("file"!==s.kind)return yield*kk(n,r);let a=function(e){if(!e.startsWith(ko)||!e.endsWith(ku))return;let t=e.slice(ko.length,-ku.length).split(".");if(1!==t.length&&2!==t.length||t.some(e=>!/^[a-zA-Z0-9_-]+$/.test(e)))return;let[r,n]=t;if(r)return{token:r,...n?{releasedOwnerToken:n}:{}}}(s.name);if(a){i.push({name:s.name,path:n,state:"free",token:a.token,...a.releasedOwnerToken?{releasedOwnerToken:a.releasedOwnerToken}:{}});continue}if(s.name.startsWith(ko))return yield*kk(n,r);let o=function(e){if(!e.startsWith(kc)||!e.endsWith(ku))return;let t=e.slice(kc.length,-ku.length);return/^[a-zA-Z0-9_-]+$/.test(t)?t:void 0}(s.name);if(o){i.push({name:s.name,path:n,state:"unpublished-owner",token:o});continue}if(s.name.startsWith(kc)||!s.name.startsWith(kl)||!s.name.endsWith(ku))return yield*kk(n,r);let c=function(e){try{let t=JSON.parse(e);return"object"==typeof t&&null!==t&&"pid"in t&&"number"==typeof t.pid&&"token"in t&&"string"==typeof t.token&&t.token.length>0?{pid:t.pid,token:t.token}:void 0}catch{return}}((yield*e.readText(n).pipe(aO(e=>kw(e,"ENOENT")?l(r):e))));if(!c)return yield*l(r);if(s.name!==`${kl}${c.token}${ku}`)return yield*kk(n,r);i.push({name:s.name,path:n,token:c.token,state:kv(c.pid)?"live-owner":"stale-owner"})}return i}),u=lW("sketchi.cli.storage.acquireLockOnce")(function*(t){yield*n();let r=yield*o(t),i=yield*c(r,t),s=new Set(i.flatMap(e=>e.releasedOwnerToken?[e.releasedOwnerToken]:[]));if(i.some(e=>"live-owner"===e.state&&!s.has(e.token)))return yield*l(t);let a=i.find(e=>"free"===e.state)??i.find(e=>"stale-owner"===e.state);if(!a){let n=(0,u7.join)(r,`${ko}${kd}${ku}`);if(!(yield*e.tryWriteText(n,xz({token:kd}))))return yield*l(t);a={name:`${ko}${kd}${ku}`,path:n,state:"free",token:kd}}let u=crypto.randomUUID(),d=(0,u7.join)(r,`${kl}${u}${ku}`),f=(0,u7.join)(r,`${kc}${u}${ku}`);return yield*a2(lV(lD(f),()=>lR(function*(){if(yield*e.writeText(f,xz({pid:process.pid,token:u})),!(yield*e.tryLinkFile(f,d)))return yield*l(t);if(!(yield*e.removeFile(a.path).pipe(ab(t=>e.removeFile(d).pipe(s2(tJ(t)))))))return yield*e.removeFile(d),yield*l(t);for(let t of i)t.path!==a.path&&(yield*e.removeFile(t.path).pipe(ab(()=>sK)));return{directory:r,ownerPath:d,token:u}}),t=>e.removeFile(t).pipe(ab(()=>sK))))}),d=lW("sketchi.cli.storage.releaseLock")(function*(t,r){let n=crypto.randomUUID(),i=(0,u7.join)(r.directory,`${ko}${n}.${r.token}${ku}`),s=xz({token:n,releasedOwnerToken:r.token});if(!(yield*e.writeText(i,s).pipe(s1(!0),ab(()=>e.tryWriteText(i,s).pipe(s8(t=>t?lD(!0):e.kind(i).pipe(ae(e=>"file"===e))),ab(()=>lD(!1))))))){if(yield*e.removeFile(r.ownerPath))return;return yield*kg("storage_commit_failed",`Diagram "${t}" lock ownership changed before release.`,"Retry after the active Sketchi command finishes.",t)}if(!(yield*e.removeFile(r.ownerPath).pipe(aM({onFailure:()=>!0,onSuccess:e=>e}))))return yield*e.removeFile(i).pipe(ab(()=>sK)),yield*kg("storage_commit_failed",`Diagram "${t}" lock ownership changed before release.`,"Retry after the active Sketchi command finishes.",t)}),f=(e,t,r=!1)=>{let n;return lV((n=u(e),r?n.pipe(lM({schedule:kp,while:e=>"CliStorageError"===e._tag&&"diagram_busy"===e.code})):n),()=>a(e).pipe(s2(t)),t=>d(e,t).pipe(ab(()=>sK)))},h=lW("sketchi.cli.storage.decodeManifest")(function*(t,r){let n=yield*e.readText(t),i=yield*sz({try:()=>JSON.parse(n),catch:()=>kg("corrupt_record",`Diagram "${r}" has an invalid manifest.`,"Inspect manifest.json and restore it from a known-good backup.",r)});return yield*mJ(x8)(i).pipe(aO(()=>kg("corrupt_record",`Diagram "${r}" has an incompatible manifest.`,`Expected manifest schema version ${String(1)}.`,r)))}),p=lW("sketchi.cli.storage.decodeDocument")(function*(t,r){let n=yield*e.readText(t),i=yield*sz({try:()=>JSON.parse(n),catch:()=>kg("corrupt_record",`Diagram "${r}" has invalid document JSON.`,"Recover a prior canonical document from the revisions directory.",r)});return yield*xq(i).pipe(aO(()=>kg("corrupt_record",`Diagram "${r}" has an invalid canonical document.`,"Recover a prior canonical document from the revisions directory.",r)))}),m=lW("sketchi.cli.storage.loadUnlocked")(function*(r){let n=kx(t.path,r),s=yield*e.kind(n);if("missing"===s)return yield*kg("diagram_not_found",`Diagram "${r}" does not exist.`,"Run sketchi list to discover stored diagram ids.",r);if("directory"!==s)return yield*kk(n,r);yield*i(n,r);let a=yield*h((0,u7.join)(n,x0),r);if(a.id!==r)return yield*kg("corrupt_record",`Diagram directory "${r}" contains manifest id "${a.id}".`,"Make the directory name and manifest id agree before retrying.",r);let o=yield*p((0,u7.join)(n,x1),r);if(a.type!==o.type||a.title!==o.spec.title)return yield*kg("corrupt_record",`Diagram "${r}" manifest does not match its canonical document.`,"Recover the canonical document and rebuild the record with sketchi edit.",r);for(let t of[x2,x3])if((yield*e.kind((0,u7.join)(n,t)))!=="file")return yield*kg("corrupt_record",`Diagram "${r}" is missing required artifact ${t}.`,"Recover the canonical document and rebuild the record with sketchi edit.",r);let l=yield*e.kind((0,u7.join)(n,x5));if("file"!==l&&"missing"!==l)return yield*kk((0,u7.join)(n,x5),r);let c="file"===l?["scene","excalidraw","png"]:["scene","excalidraw"];if(a.formats.length!==c.length||a.formats.some((e,t)=>e!==c[t]))return yield*kg("corrupt_record",`Diagram "${r}" manifest formats do not match stored artifacts.`,"Recover the canonical document and rebuild the record with sketchi edit.",r);let u=(0,u7.join)(n,x4);return{manifest:a,document:o,revisions:[...yield*e.list(u)].filter(e=>"file"===e.kind&&e.name.endsWith(".json")).map(e=>e.name).sort(kb)}}),g=lW("sketchi.cli.storage.copySafeTree")(function*(t,r,n){for(let i of yield*e.list(t)){let s=(0,u7.join)(t,i.name),a=(0,u7.join)(r,i.name);if("directory"===i.kind)yield*e.makeDirectory(a),yield*g(s,a,n);else{if("file"!==i.kind)return yield*kk(s,n);let t=yield*e.readBytes(s);yield*e.writeBytes(a,t)}}}),y=lW("sketchi.cli.storage.writeBuilt")(function*(t,r,n){yield*e.makeDirectory((0,u7.join)(t,x4),!0),yield*e.writeText((0,u7.join)(t,x1),xz(r.document),!0),yield*e.writeText((0,u7.join)(t,x2),xz(r.scene),!0),yield*e.writeText((0,u7.join)(t,x3),xz(r.excalidraw),!0);let i=(0,u7.join)(t,x5);yield*e.remove(i),r.png&&(yield*e.writeBytes(i,r.png)),yield*e.writeText((0,u7.join)(t,x0),xz(n),!0)}),b=lW("sketchi.cli.storage.create")(function*(r){return yield*f(r.id,lR(function*(){let n=kx(t.path,r.id);if((yield*e.kind(n))!=="missing")return yield*kg("diagram_already_exists",`Diagram "${r.id}" already exists.`,"Use sketchi edit for full-document replacement.",r.id);let i=x8.make({schemaVersion:1,id:r.id,type:r.type,title:r.title,revision:1,formats:r.png?["scene","excalidraw","png"]:["scene","excalidraw"]});return yield*lV(e.makeTempDirectory(t.path,kh),t=>lR(function*(){return yield*y(t,r,i),yield*e.rename(t,n),{manifest:i,document:r.document,revisions:[]}}),t=>e.remove(t))}))}),v=lW("sketchi.cli.storage.edit")(function*(r,n){return yield*f(r,lR(function*(){let i=yield*m(r);if(n.id!==r)return yield*kg("storage_commit_failed",`Edited document id "${n.id}" does not match "${r}".`,"Keep spec.id equal to the diagram id being edited.",r);let s=kx(t.path,r),a=x8.make({schemaVersion:1,id:r,type:n.type,title:n.title,revision:i.manifest.revision+1,formats:n.png?["scene","excalidraw","png"]:["scene","excalidraw"]});return yield*lV(e.makeTempDirectory(t.path,kh),o=>lR(function*(){yield*g(s,o,r),yield*e.writeText((0,u7.join)(o,x4,x9(i.manifest.revision)),xz(i.document)),yield*y(o,n,a);let l=(0,u7.join)(t.path,`${kf}${ky(r)}.${String(process.pid)}.${crypto.randomUUID()}`);return yield*e.rename(s,l),(yield*e.rename(o,s).pipe(aT({onFailure:t=>e.rename(l,s).pipe(aT({onFailure:()=>tJ(kg("storage_commit_failed",`Atomic edit commit and rollback both failed for "${r}".`,"Retry; Sketchi will recover the backup transaction before the next operation.",r)),onSuccess:()=>tJ(t)})),onSuccess:()=>lD(!0)})))&&(yield*e.remove(l).pipe(ab(()=>sK))),{manifest:a,document:n.document,revisions:[...i.revisions,x9(i.manifest.revision)].sort(kb)}}),t=>e.remove(t))}))}),w=lW("sketchi.cli.storage.show")(e=>f(e,m(e),!0)),x=lW("sketchi.cli.storage.list")(function*(){yield*n(),yield*s();let r=new Set;for(let n of yield*e.list(t.path)){if("directory"===n.kind&&!n.name.startsWith(".")){r.add(n.name);continue}if(!n.name.startsWith(kf))continue;let e=function(e){try{let t=Buffer.from(e,"base64url").toString("utf8");return/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/.test(t)?t:void 0}catch{return}}(n.name.split(".")[2]??"");e&&r.add(e)}let i=[];for(let e of[...r].sort(kb)){let t=yield*w(e);i.push(x6(t))}return i});return{create:b,edit:v,show:w,list:x,readArtifact:lW("sketchi.cli.storage.readArtifact")(function*(r,n){return yield*f(r,lR(function*(){return(yield*m(r)).manifest.formats.includes(n)?yield*e.readBytes((0,u7.join)(kx(t.path,r),function(e){switch(e){case"scene":return x2;case"excalidraw":return x3;case"png":return x5}}(n))):yield*xF.make({code:"format_unavailable",format:n,message:`Diagram "${r}" has no stored ${n} artifact.`,hint:"png"===n?"PNG export is offline-only and requires an already-stored PNG artifact.":"Edit the diagram to rebuild its local artifacts."})}),!0)})}})),k_=lW("sketchi.cli.export.writeFile")(function*(e,t){let r=yield*ke,n=(0,u7.dirname)(e);if((yield*r.kind(n))!=="directory")return yield*xF.make({code:"export_write_failed",format:(0,u7.basename)(e),message:`Export destination directory does not exist: ${n}.`,hint:"Create the destination directory and retry."});let i=(0,u7.join)(n,`.${(0,u7.basename)(e)}.sketchi.${String(process.pid)}.${crypto.randomUUID()}`);return yield*lV(lD(i),n=>r.writeBytes(n,t).pipe(s2(r.rename(n,e)),aO(()=>xF.make({code:"export_write_failed",format:(0,u7.basename)(e),message:`Unable to write export destination ${e}.`,hint:"Check the destination path and permissions, then retry."}))),e=>r.remove(e))}),k$="gemini-3.1-flash-lite",kO="https://playground.sketchi.app/api/v1/generate",kI="SKETCHI_GENERATE_ENDPOINT";function kC(){return xN.make({code:"provider_failure",message:"The Sketchi generate API could not be reached.",hint:"Check your network connection and retry; generate is the only command that uses the network.",details:["transport"]})}function kE(){return xN.make({code:"malformed_output",message:"The Sketchi generate API returned an unreadable response.",hint:"Retry once; if it persists, report the prompt without secrets.",details:[]})}function kA(){return xN.make({code:"invalid_generated_document",message:"The generated diagram failed Sketchi schema or semantic validation.",hint:"Refine the prompt with concrete diagram content, then retry.",details:[]})}let kT=lW("sketchi.cli.generate.request")(function*(e){let t=yield*lP({try:t=>globalThis.fetch(e.endpoint,{method:"POST",headers:{"content-type":"application/json","x-sketchi-client":"sketchi-cli"},body:JSON.stringify({prompt:e.prompt,type:e.type,model:e.model}),signal:t}),catch:()=>kC()}),r=yield*lP({try:()=>t.text(),catch:()=>kC()});if(!t.ok)return yield*tJ(function(e,t){let r=function(e){try{let t=JSON.parse(e);return null!==t&&"object"==typeof t?t:{}}catch{return{}}}(t),n=r.issues?.[0],i=[`http_status:${String(e)}`];switch(r.status){case"generation_timeout":return xN.make({code:"generation_timeout",message:n?.message??"The generate API timed out.",hint:n?.hint??"Retry once; if it persists, try a shorter prompt.",details:i});case"malformed_output":return xN.make({code:"malformed_output",message:n?.message??"The generate API returned unreadable model output.",hint:n?.hint??"Retry once; if it persists, try another prompt.",details:i});case"invalid_input":case"invalid_generated_document":case"quality_failed":return xN.make({code:"invalid_generated_document",message:n?.message??"The generated diagram failed Sketchi validation.",hint:n?.hint??"Refine the prompt with concrete content, then retry.",details:i});default:return xN.make({code:"provider_failure",message:n?.message??`The Sketchi generate API responded with HTTP ${String(e)}.`,hint:n?.hint??"Retry once; if it persists, report the prompt without secrets.",details:i})}}(t.status,r));let n=function(e){let t;try{t=JSON.parse(e)}catch{return}if(null===t||"object"!=typeof t)return;let r=t;if(!0===r.ok&&r.diagram&&void 0!==r.diagram.document&&void 0!==r.diagram.scene&&void 0!==r.diagram.excalidraw)return{document:r.diagram.document,scene:r.diagram.scene,excalidraw:r.diagram.excalidraw,model:"string"==typeof r.generation?.model?r.generation.model:"",provider:"string"==typeof r.generation?.provider?r.generation.provider:"cloudflare-google-ai-studio"}}(r);return n||(yield*tJ(kE()))}),kM=lW("sketchi.cli.generate")(function*(e){var t,r;let n,i,s=yield*ks,a=yield*kT(e),o=yield*xq(a.document).pipe(aO(()=>kA())),l=yield*xJ(xV(o)).pipe(aO(()=>kA())),c=yield*(t=a.scene,(n=bt.safeParse(t)).success?lD(n.data):tJ(kE())),u=yield*(r=a.excalidraw,(i=bs.safeParse(r)).success?lD(i.data):tJ(kE())),d={id:l,type:o.type,title:o.spec.title,document:o,scene:c,excalidraw:u};return{diagram:yield*s.create(d),model:a.model||e.model,provider:a.provider}}),kN=e=>tY(t=>e(t.getRef(oP))),kj=(...e)=>kN(t=>sL(()=>{t.error(...e)})),kF=(...e)=>kN(t=>sL(()=>{t.log(...e)})),kL="~effect/cli/CliError";class kP extends gA(`${kL}/UnrecognizedOption`)("UnrecognizedOption",{option:m5,command:mH(gt(m5)),suggestions:gt(m5)}){[kL]=kL;get message(){let e=this.suggestions.length>0?`
2
+ import{createRequire as e}from"node:module";let t=e(import.meta.url);var r,n,i,s,a={2532(e){let{hasOwnProperty:t}=Object.prototype,r=(e,t={})=>{"string"==typeof t&&(t={section:t}),t.align=!0===t.align,t.newline=!0===t.newline,t.sort=!0===t.sort,t.whitespace=!0===t.whitespace||!0===t.align,t.platform=t.platform||"u">typeof process&&process.platform,t.bracketedArray=!1!==t.bracketedArray;let i="win32"===t.platform?"\r\n":"\n",s=t.whitespace?" = ":"=",o=[],l=t.sort?Object.keys(e).sort():Object.keys(e),c=0;t.align&&(c=a(l.filter(t=>null===e[t]||Array.isArray(e[t])||"object"!=typeof e[t]).map(t=>Array.isArray(e[t])?`${t}[]`:t).concat([""]).reduce((e,t)=>a(e).length>=a(t).length?e:t)).length);let u="",d=t.bracketedArray?"[]":"";for(let t of l){let r=e[t];if(r&&Array.isArray(r))for(let e of r)u+=a(`${t}${d}`).padEnd(c," ")+s+a(e)+i;else r&&"object"==typeof r?o.push(t):u+=a(t).padEnd(c," ")+s+a(r)+i}for(let s of(t.section&&u.length&&(u="["+a(t.section)+"]"+(t.newline?i+i:i)+u),o)){let a=n(s,".").join("\\."),o=(t.section?t.section+".":"")+a,l=r(e[s],{...t,section:o});u.length&&l.length&&(u+=i),u+=l}return u};function n(e,t){var r=0,n=0,i=0,s=[];do if(-1!==(i=e.indexOf(t,r))){if(r=i+t.length,i>0&&"\\"===e[i-1])continue;s.push(e.slice(n,i)),n=i+t.length}while(-1!==i)return s.push(e.slice(n)),s}let i=(e,r={})=>{r.bracketedArray=!1!==r.bracketedArray;let i=Object.create(null),s=i,a=null,l=/^\[([^\]]*)\]\s*$|^([^=]+)(=(.*))?$/i,c=e.split(/[\r\n]+/g),u={};for(let e of c){let n;if(!e||e.match(/^\s*[;#]/)||e.match(/^\s*$/))continue;let c=e.match(l);if(!c)continue;if(void 0!==c[1]){if("__proto__"===(a=o(c[1]))){s=Object.create(null);continue}s=i[a]=i[a]||Object.create(null);continue}let d=o(c[2]);r.bracketedArray?n=d.length>2&&"[]"===d.slice(-2):(u[d]=(u?.[d]||0)+1,n=u[d]>1);let f=n&&d.endsWith("[]")?d.slice(0,-2):d;if("__proto__"===f)continue;let h=!c[3]||o(c[4]),p="true"===h||"false"===h||"null"===h?JSON.parse(h):h;n&&(t.call(s,f)?Array.isArray(s[f])||(s[f]=[s[f]]):s[f]=[]),Array.isArray(s[f])?s[f].push(p):s[f]=p}let d=[];for(let e of Object.keys(i)){if(!t.call(i,e)||"object"!=typeof i[e]||Array.isArray(i[e]))continue;let r=n(e,".");s=i;let a=r.pop(),o=a.replace(/\\\./g,".");for(let e of r)"__proto__"!==e&&(t.call(s,e)&&"object"==typeof s[e]||(s[e]=Object.create(null)),s=s[e]);(s!==i||o!==a)&&(s[o]=i[e],d.push(e))}for(let e of d)delete i[e];return i},s=e=>e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"),a=e=>"string"!=typeof e||e.match(/[=\r\n]/)||e.match(/^\[/)||e.length>1&&s(e)||e!==e.trim()?JSON.stringify(e):e.split(";").join("\\;").split("#").join("\\#"),o=e=>{if(s(e=(e||"").trim())){"'"===e.charAt(0)&&(e=e.slice(1,-1));try{e=JSON.parse(e)}catch{}}else{let t=!1,r="";for(let n=0,i=e.length;n<i;n++){let i=e.charAt(n);if(t)-1!=="\\;#".indexOf(i)?r+=i:r+="\\"+i,t=!1;else if(-1!==";#".indexOf(i))break;else"\\"===i?t=!0:r+=i}return t&&(r+="\\"),r.trim()}return e};e.exports={parse:i,decode:i,stringify:r,encode:r,safe:a,unsafe:o}},3176(e,t,r){var n=r(3633),i=r(4239);e.exports={parse:function(e,t){var r=e.toString(),s=n.parse(r,t);return i.compile(s,r,t)}}},4239(e){e.exports={compile:function(e,t,r){var n=null;if((r=r||{}).useTemporal&&!(n=r.temporal||("u">typeof Temporal?Temporal:null)))throw Error("The `useTemporal` option was set, but no Temporal implementation is available. Use a runtime with global `Temporal` support, or provide an implementation (e.g. from the `@js-temporal/polyfill` package) via the `temporal` option.");for(var i=new Set,s=new Set,a=new Set,o=[],l=new WeakSet,c=b(),u=c,d=e,f,h=0;h<d.length;h++)switch((f=d[h]).type){case"Assign":!function(e){var t=e.key,r=e.value,l=e.offset;Array.isArray(t)||(t=[t]);for(var c=function e(t){if("Array"===t.type)return t.value.map(e);if("InlineTable"===t.type)return function(t){for(var r=b(),n=new Set,i=0;i<t.length;i++){var s=t[i];if("InlineTableValue"===s.type){var a=s.key;Array.isArray(a)||(a=[a]),function(e,t,r,n,i){for(var s=0;s<t.length-1;s++){var a=t[s],o=w(t.slice(0,s+1));void 0===e[a]?e[a]=b():"object"!=typeof e[a]||null===e[a]||Array.isArray(e[a])?p("Cannot redefine existing key '"+o+"'.",n):i&&i.has(o)&&p("Cannot extend inline table '"+o+"'.",n),e=e[a]}var l=t[t.length-1];void 0!==e[l]&&p("Cannot redefine existing key '"+w(t)+"'.",n),e[l]=r}(r,a,e(s.value),s.offset,n),n.add(w(a))}}return r}(t.value);if(n)switch(t.type){case"Date":return n.ZonedDateTime.from(m(t.raw)+t.tz+"["+("Z"===t.tz?"UTC":t.tz)+"]");case"LocalDateTime":return n.PlainDateTime.from(m(t.value));case"LocalDate":return n.PlainDate.from(t.value);case"LocalTime":return n.PlainTime.from(m(t.value))}return t.value}(r),d=u,f=0;f<t.length-1;f++){var h=t[f],g=x(t.slice(0,f+1));void 0===d[h]?(d[h]=b(),i.add(g)):"object"!=typeof d[h]||null===d[h]||Array.isArray(d[h])||s.has(g)?p("Cannot redefine existing key '"+g+"'.",l):a.has(g)&&g!==w(o)&&p("Cannot use dotted keys to extend table '"+g+"' defined elsewhere.",l),d=d[h]}var y=t[t.length-1],v=x(t);void 0!==d[y]&&p("Cannot redefine existing key '"+v+"'.",l),d[y]=c,i.add(v),s.add(v)}(f);break;case"ObjectPath":!function(e){var t=e.value,r=t.map(y).join("."),n=e.offset;i.has(r)&&p("Cannot redefine existing key '"+t+"'.",n),i.add(r),a.add(r),u=g(c,t,b(),n),o=t}(f);break;case"ArrayPath":!function(e){var t=e.value,r=t.map(y).join("."),n=e.offset;if(s.has(r)&&p("Cannot append to statically defined array '"+r+"'.",n),i.forEach(function(e){k(e,r)&&i.delete(e)}),s.forEach(function(e){k(e,r)&&s.delete(e)}),i.add(r),u=g(c,t,function(){var e=[];return l.add(e),e}(),n),o=t,u instanceof Array){var a=b();u.push(a),u=a}else p("Cannot redefine existing key '"+t+"'.",n)}(f)}return c;function p(e,r){var n=function(e){for(var r=1,n=1,i=0;i<e;i++)10===t.charCodeAt(i)?(r++,n=1):n++;return{line:r,column:n}}(r),i=Error(e);throw i.line=n.line,i.column=n.column,i}function m(e){return e.replace(/\.(\d{9})\d+/,".$1")}function g(e,t,r,n){for(var i=e,a=0;a<t.length;a++){var o=t[a],l=w(t.slice(0,a+1));void 0===i[o]?a===t.length-1?i[o]=r:i[o]=b():a!==t.length-1&&s.has(l)&&p("Cannot redefine existing key '"+l+"'.",n),i=i[o],a<t.length-1&&(v(i)||p("Cannot redefine existing key '"+l+"'.",n),i instanceof Array&&(i.length||p("Cannot redefine existing key '"+l+"'.",n),v(i=i[i.length-1])||p("Cannot redefine existing key '"+l+"'.",n)))}return i}function y(e){return e.indexOf(".")>-1?'"'+e+'"':e}function b(){var e=Object.create(null);return l.add(e),e}function v(e){return null!==e&&"object"==typeof e&&l.has(e)}function w(e){return e.map(y).join(".")}function x(e){return w(o.concat(e))}function k(e,t){return e===t||0===e.indexOf(t+".")}}}},3633(e){class t extends SyntaxError{constructor(e,t,r,n){super(e),this.expected=t,this.found=r,this.location=n,this.name="SyntaxError"}format(e){let t="Error: "+this.message;if(this.location){let r=null,n=e.find(e=>e.source===this.location.source);n&&(r=n.text.split(/\r\n|\n|\r/g));let i=this.location.start,s=this.location.source&&"function"==typeof this.location.source.offset?this.location.source.offset(i):i,a=this.location.source+":"+s.line+":"+s.column;if(r){let e=this.location.end,n="".padEnd(s.line.toString().length," "),o=r[i.line-1],l=(i.line===e.line?e.column:o.length+1)-i.column||1;t+="\n --\x3e "+a+"\n"+n+" |\n"+s.line+" | "+o+"\n"+n+" | "+"".padEnd(i.column-1," ")+"".padEnd(l,"^")}else t+="\n at "+a}return t}static buildMessage(e,t){function r(e){return e.codePointAt(0).toString(16).toUpperCase()}let n=Object.prototype.hasOwnProperty.call(RegExp.prototype,"unicode")?RegExp("[\\p{C}\\p{Mn}\\p{Mc}]","gu"):null;function i(e){return n?e.replace(n,e=>"\\u{"+r(e)+"}"):e}function s(e){return i(e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,e=>"\\x0"+r(e)).replace(/[\x10-\x1F\x7F-\x9F]/g,e=>"\\x"+r(e)))}function a(e){return i(e.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,e=>"\\x0"+r(e)).replace(/[\x10-\x1F\x7F-\x9F]/g,e=>"\\x"+r(e)))}let o={literal:e=>'"'+s(e.text)+'"',class(e){let t=e.parts.map(e=>Array.isArray(e)?a(e[0])+"-"+a(e[1]):a(e));return"["+(e.inverted?"^":"")+t.join("")+"]"+(e.unicode?"u":"")},any:()=>"any character",end:()=>"end of input",other:e=>e.description};function l(e){return o[e.type](e)}return"Expected "+function(e){let t=e.map(l);if(t.sort(),t.length>0){let e=1;for(let r=1;r<t.length;r++)t[r-1]!==t[r]&&(t[e]=t[r],e++);t.length=e}switch(t.length){case 1:return t[0];case 2:return t[0]+" or "+t[1];default:return t.slice(0,-1).join(", ")+", or "+t[t.length-1]}}(e)+" but "+(t?'"'+s(t)+'"':"end of input")+" found."}}e.exports={StartRules:["start"],SyntaxError:t,parse:function(e,r){let n,i={},s=(r=void 0!==r?r:{}).grammarSource,a={start:eF},o=eF,l="true",c="false",u=/^[\t -~\x80-\uFFFF]/,d=/^[+\-]/,f=/^[^"\\\0-\b\v-\x1F\x7F\r]/,h=/^[^'\0-\b\v-\x1F\x7F\r]/,p=/^[^"\\\0-\b\n-\x1F\x7F]/,m=/^[^'\0-\b\n-\x1F\x7F]/,g=/^[eE]/,y=/^[0-9_]/,b=/^[1-9]/,v=/^[_]/,w=/^[0-9]/,x=/^[0-9a-fA-F]/,k=/^[0-7]/,S=/^[01]/,_=/^[ \t]/,O=/^[A-Za-z0-9_\-]/,I=/^["\\btnfre]/,$=eN("#",!1),E=eM([" ",[" ","~"],["€","￿"]],!1,!1,!1),C=eN("[",!1),A=eN("]",!1),T=eN(".",!1),N=eN("=",!1),M=eM(["+","-"],!1,!1,!1),P=eN("inf",!1),j=eN("nan",!1),D=eN('"""',!1),F=eN('"',!1),L=eN("'''",!1),R=eN("'",!1),U=eN("\\",!1),B={type:"any"},Y=eN("\r\n",!1),X=eM(['"',"\\",["\0","\b"],["\v","\x1f"],"","\r"],!0,!1,!1),W=eN('""',!1),J=eM(["'",["\0","\b"],["\v","\x1f"],"","\r"],!0,!1,!1),q=eN("''",!1),K=eM(['"',"\\",["\0","\b"],["\n","\x1f"],""],!0,!1,!1),V=eM(["'",["\0","\b"],["\n","\x1f"],""],!0,!1,!1),G=eM(["e","E"],!1,!1,!1),H=eN("0",!1),z=eN("0x",!1),Q=eN("0o",!1),Z=eN("0b",!1),ee=eM([["0","9"],"_"],!1,!1,!1),et=eM([["1","9"]],!1,!1,!1),er=eM(["_"],!1,!1,!1),en=eM([["0","9"]],!1,!1,!1),ei=eM([["0","9"],["a","f"],["A","F"]],!1,!1,!1),es=eM([["0","7"]],!1,!1,!1),ea=eM(["0","1"],!1,!1,!1),eo=eN("true",!1),el=eN("false",!1),ec=eN(",",!1),eu=eN("{",!1),ed=eN("}",!1),ef=eN("-",!1),eh=eN(":",!1),ep=eN("Z",!0),em=eN("T",!0),eg=eN(" ",!1),ey=eM([" "," "],!1,!1,!1),eb=eN("\n",!1),ev=eN("\r",!1),ew=eN("\uFEFF",!1),ex=eM([["A","Z"],["a","z"],["0","9"],"_","-"],!1,!1,!1),ek=eM(['"',"\\","b","t","n","f","r","e"],!1,!1,!1),eS=eN("\\U",!1),e_=eN("\\u",!1),eO=eN("\\x",!1),eI=0|r.peg$currPos,e$=eI,eE=[{line:1,column:1}],eC=eI,eA=r.peg$maxFailExpected||[],eT=0|r.peg$silentFails;if(r.startRule){if(!(r.startRule in a))throw Error("Can't start parsing from rule \""+r.startRule+'".');o=a[r.startRule]}function eN(e,t){return{type:"literal",text:e,ignoreCase:t}}function eM(e,t,r,n){return{type:"class",parts:e,inverted:t,ignoreCase:r,unicode:n}}function eP(t){let r,n=eE[t];if(n)return n;if(t>=eE.length)r=eE.length-1;else for(r=t;!eE[--r];);for(n={line:(n=eE[r]).line,column:n.column};r<t;)10===e.charCodeAt(r)?(n.line++,n.column=1):n.column++,r++;return eE[t]=n,n}function ej(e,t,r){let n=eP(e),i=eP(t),a={source:s,start:{offset:e,line:n.line,column:n.column},end:{offset:t,line:i.line,column:i.column}};return r&&s&&"function"==typeof s.offset&&(a.start=s.offset(a.start),a.end=s.offset(a.end)),a}function eD(e){eI<eC||(eI>eC&&(eC=eI,eA=[]),eA.push(e))}function eF(){let t,r,n,s;for(t=eI,65279===e.charCodeAt(eI)?(s="\uFEFF",eI++):(s=i,0===eT&&eD(ew)),s===i,r=[],n=eL();n!==i;)r.push(n),n=eL();return e$=t,t=tl}function eL(){let t,r,n,s,a,o,l,c;for(t=eI,r=[],n=te();n!==i;)r.push(n),n=te();if((c=eR())===i&&(c=function(){let t,r,n,s,a,o,l,c;if(t=eI,91===e.charCodeAt(eI)?(r="[",eI++):(r=i,0===eT&&eD(C)),r!==i)if(91===e.charCodeAt(eI)?(n="[",eI++):(n=i,0===eT&&eD(C)),n!==i){for(s=[],a=te();a!==i;)s.push(a),a=te();if((a=eU())!==i){for(o=[],l=te();l!==i;)o.push(l),l=te();(93===e.charCodeAt(eI)?(l="]",eI++):(l=i,0===eT&&eD(A)),l!==i&&(93===e.charCodeAt(eI)?(c="]",eI++):(c=i,0===eT&&eD(A)),c!==i))?t=void tf(th("ArrayPath",a,e$=t)):(eI=t,t=i)}else eI=t,t=i}else eI=t,t=i;else eI=t,t=i;if(t===i)if(t=eI,91===e.charCodeAt(eI)?(r="[",eI++):(r=i,0===eT&&eD(C)),r!==i){for(n=[],s=te();s!==i;)n.push(s),s=te();if((s=eU())!==i){for(a=[],o=te();o!==i;)a.push(o),o=te();(93===e.charCodeAt(eI)?(o="]",eI++):(o=i,0===eT&&eD(A)),o!==i)?t=void tf(th("ObjectPath",s,e$=t)):(eI=t,t=i)}else eI=t,t=i}else eI=t,t=i;return t}())===i&&(c=function(){let t,r,n,s,a,o;if(t=eI,(r=e5())!==i){for(n=[],s=te();s!==i;)n.push(s),s=te();if(61===e.charCodeAt(eI)?(s="=",eI++):(s=i,0===eT&&eD(N)),s!==i){for(a=[],o=te();o!==i;)a.push(o),o=te();if((o=eX())!==i)t=void tf(th("Assign",o,e$=t,r));else eI=t,t=i}else eI=t,t=i}else eI=t,t=i;return t}()),(n=c)!==i){for(s=[],a=te();a!==i;)s.push(a),a=te();if((a=eR())===i&&(a=null),o=[],(l=tt())!==i)for(;l!==i;)o.push(l),l=tt();else o=i;o===i&&(o=tn()),o!==i?t=r=[r,n,s,a,o]:(eI=t,t=i)}else eI=t,t=i;if(t===i){if(t=eI,r=[],(n=te())!==i)for(;n!==i;)r.push(n),n=te();else r=i;if(r!==i){if(n=[],(s=tt())!==i)for(;s!==i;)n.push(s),s=tt();else n=i;n===i&&(n=tn()),n!==i?t=r=[r,n]:(eI=t,t=i)}else eI=t,t=i;t===i&&(t=tt())}return t}function eR(){let t,r,n,s;if(t=eI,35===e.charCodeAt(eI)?(r="#",eI++):(r=i,0===eT&&eD($)),r!==i){for(n=[],s=e.charAt(eI),u.test(s)?eI++:(s=i,0===eT&&eD(E));s!==i;)n.push(s),s=e.charAt(eI),u.test(s)?eI++:(s=i,0===eT&&eD(E));t=r=[r,n]}else eI=t,t=i;return t}function eU(){let e,t,r;if(e=eI,t=[],(r=eY())!==i)for(;r!==i;)t.push(r),r=eY();else t=i;if(t!==i)if((r=eB())!==i){var n,s;e$=e,n=t,s=r,e=n.concat(s)}else eI=e,e=i;else eI=e,e=i;return e===i&&(e=eI,(t=eB())!==i&&(e$=e,t=[t]),e=t),e}function eB(){let e,t,r,n,s;for(e=eI,t=[],r=te();r!==i;)t.push(r),r=te();if((r=e8())!==i){for(n=[],s=te();s!==i;)n.push(s),s=te();e$=e,e=r}else eI=e,e=i;return e}function eY(){let t,r,n,s,a;for(t=eI,r=[],n=te();n!==i;)r.push(n),n=te();if((n=e8())!==i){for(s=[],a=te();a!==i;)s.push(a),a=te();(46===e.charCodeAt(eI)?(a=".",eI++):(a=i,0===eT&&eD(T)),a!==i)?(e$=t,t=n):(eI=t,t=i)}else eI=t,t=i;return t}function eX(){let t,r;return(t=eI,e$=eI,++tc>tu&&(tc--,td("Maximum nesting depth of "+tu+" exceeded.",e$)),void 0!==i&&(r=function(){let t,r,n,s,a,o,u,f,h,p,m,b,w,_,O,I,$;if(t=eI,(a=eI,'"""'===e.substr(eI,3)?(o='"""',eI+=3):(o=i,0===eT&&eD(D)),o!==i&&(tt()===i,u=function(){let t,r,n,s,a,o,l,c,u,d,f;for(t=eI,r=[],n=eq();n!==i;)r.push(n),n=eq();if(n=[],s=eI,(a=eK())!==i){if(o=[],(l=eq())!==i)for(;l!==i;)o.push(l),l=eq();else o=i;o!==i?s=a=[a,o]:(eI=s,s=i)}else eI=s,s=i;for(;s!==i;)if(n.push(s),s=eI,(a=eK())!==i){if(o=[],(l=eq())!==i)for(;l!==i;)o.push(l),l=eq();else o=i;o!==i?s=a=[a,o]:(eI=s,s=i)}else eI=s,s=i;return c=eI,'""'===e.substr(eI,2)?(u='""',eI+=2):(u=i,0===eT&&eD(W)),u!==i?(d=eI,eT++,'"""'===e.substr(eI,3)?(f='"""',eI+=3):(f=i,0===eT&&eD(D)),eT--,f!==i?(eI=d,d=void 0):d=i,d!==i?(e$=c,c='""'):(eI=c,c=i)):(eI=c,c=i),c===i&&(c=eI,34===e.charCodeAt(eI)?(u='"',eI++):(u=i,0===eT&&eD(F)),u!==i?(d=eI,eT++,'"""'===e.substr(eI,3)?(f='"""',eI+=3):(f=i,0===eT&&eD(D)),eT--,f!==i?(eI=d,d=void 0):d=i,d!==i?(e$=c,c='"'):(eI=c,c=i)):(eI=c,c=i)),(s=c)===i&&(s=null),e$=t,t=function(e,t,r){for(var n=e.join(""),i=0;i<t.length;i++)n+=t[i][0]+t[i][1].join("");return n+(r||"")}(r,n,s)}(),'"""'===e.substr(eI,3)?(f='"""',eI+=3):(f=i,0===eT&&eD(D)),f!==i))?a=th("String",u,e$=a):(eI=a,a=i),(s=a)===i&&(s=eW())===i&&((h=eI,"'''"===e.substr(eI,3)?(p="'''",eI+=3):(p=i,0===eT&&eD(L)),p!==i&&(tt()===i,m=function(){let t,r,n,s,a,o,l,c,u,d,f;for(t=eI,r=[],n=eV();n!==i;)r.push(n),n=eV();if(n=[],s=eI,(a=eG())!==i){if(o=[],(l=eV())!==i)for(;l!==i;)o.push(l),l=eV();else o=i;o!==i?s=a=[a,o]:(eI=s,s=i)}else eI=s,s=i;for(;s!==i;)if(n.push(s),s=eI,(a=eG())!==i){if(o=[],(l=eV())!==i)for(;l!==i;)o.push(l),l=eV();else o=i;o!==i?s=a=[a,o]:(eI=s,s=i)}else eI=s,s=i;return c=eI,"''"===e.substr(eI,2)?(u="''",eI+=2):(u=i,0===eT&&eD(q)),u!==i?(d=eI,eT++,"'''"===e.substr(eI,3)?(f="'''",eI+=3):(f=i,0===eT&&eD(L)),eT--,f!==i?(eI=d,d=void 0):d=i,d!==i?(e$=c,c="''"):(eI=c,c=i)):(eI=c,c=i),c===i&&(c=eI,39===e.charCodeAt(eI)?(u="'",eI++):(u=i,0===eT&&eD(R)),u!==i?(d=eI,eT++,"'''"===e.substr(eI,3)?(f="'''",eI+=3):(f=i,0===eT&&eD(L)),eT--,f!==i?(eI=d,d=void 0):d=i,d!==i?(e$=c,c="'"):(eI=c,c=i)):(eI=c,c=i)),(s=c)===i&&(s=null),e$=t,t=function(e,t,r){for(var n=e.join(""),i=0;i<t.length;i++)n+=t[i][0]+t[i][1].join("");return n+(r||"")}(r,n,s)}(),"'''"===e.substr(eI,3)?(b="'''",eI+=3):(b=i,0===eT&&eD(L)),b!==i))?h=th("String",m,e$=h):(eI=h,h=i),(s=h)===i)&&(s=eJ()),(n=s)===i&&((w=eI,_=e.charAt(eI),d.test(_)?eI++:(_=i,0===eT&&eD(M)),_===i&&(_=null),"inf"===e.substr(eI,3)?(O="inf",eI+=3):(O=i,0===eT&&eD(P)),O!==i)?w=th("Float","-"===_?-1/0:1/0,e$=w):(eI=w,w=i),w===i&&(w=eI,_=e.charAt(eI),d.test(_)?eI++:(_=i,0===eT&&eD(M)),_===i&&(_=null),"nan"===e.substr(eI,3)?(O="nan",eI+=3):(O=i,0===eT&&eD(j)),O!==i?w=th("Float",NaN,e$=w):(eI=w,w=i),w===i&&(w=function(){var t,r,n,s,a,o,l,c,u,f,h;let p,m,g,y,b;if(p=eI,(m=e9())!==i)if((g=e7())!==i)if((y=e4())!==i){let a,o,l,c,u,f,h,g;(a=eI,"z"===(o=e.charAt(eI)).toLowerCase()?eI++:(o=i,0===eT&&eD(ep)),o!==i&&(e$=a,o="Z"),(a=o)===i&&(a=eI,o=eI,l=e.charAt(eI),d.test(l)?eI++:(l=i,0===eT&&eD(M)),l!==i&&(c=ti())!==i&&(u=ti())!==i?(58===e.charCodeAt(eI)?(f=":",eI++):(f=i,0===eT&&eD(eh)),f!==i&&(h=ti())!==i&&(g=ti())!==i?o=l=[l,c,u,f,h,g]:(eI=o,o=i)):(eI=o,o=i),a=o!==i?e.substring(a,eI):o),(b=a)!==i)?(e$=p,t=m,r=y,tp(t,n=e$),tm(r,n),function(e,t){if("Z"!==e&&"z"!==e){var r=(e.charCodeAt(1)-48)*10+e.charCodeAt(2)-48,n=(e.charCodeAt(4)-48)*10+e.charCodeAt(5)-48;r>23&&td("Invalid offset: hour "+r+" out of range.",t),n>59&&td("Invalid offset: minute "+n+" out of range.",t)}}(b,n),(s=th("Date",new Date(t+"T"+r+b),n)).raw=t+"T"+r,s.tz=b,p=s):(eI=p,p=i)}else eI=p,p=i;else eI=p,p=i;else eI=p,p=i;return p===i&&((p=eI,(m=e9())!==i&&(g=e7())!==i&&(y=e4())!==i)?(e$=p,a=m,o=y,tp(a,l=e$),tm(o,l),p=th("LocalDateTime",a+"T"+o,l)):(eI=p,p=i),p===i&&((p=eI,(m=e9())!==i&&(g=eI,eT++,y=e7(),eT--,y===i?g=void 0:(eI=g,g=i),g!==i))?(e$=p,tp(c=m,u=e$),p=th("LocalDate",c,u)):(eI=p,p=i),p===i&&(p=eI,(m=e4())!==i&&(e$=p,tm(f=m,h=e$),m=th("LocalTime",f,h)),p=m))),p}())===i&&(w=function(){let t,r,n,s,a,o,l,c,u,f;if(t=eI,(a=eI,o=e.charAt(eI),d.test(o)?eI++:(o=i,0===eT&&eD(M)),o===i&&(o=null),(l=eQ())!==i&&(46===e.charCodeAt(eI)?(c=".",eI++):(c=i,0===eT&&eD(T)),c!==i&&(u=eI,(u=(f=e0())!==i?e.substring(u,eI):f)!==i)))?(e$=a,a=("-"===o?"-":"")+l+"."+u):(eI=a,a=i),a===i&&((a=eI,o=e.charAt(eI),d.test(o)?eI++:(o=i,0===eT&&eD(M)),o===i&&(o=null),(l=eQ())!==i)?(e$=a,a=("-"===o?"-":"")+l):(eI=a,a=i)),(r=a)!==i)if(n=e.charAt(eI),g.test(n)?eI++:(n=i,0===eT&&eD(G)),n!==i){let n,a,o,l;if((n=eI,a=e.charAt(eI),d.test(a)?eI++:(a=i,0===eT&&eD(M)),a===i&&(a=null),o=eI,(o=(l=e0())!==i?e.substring(o,eI):l)!==i)?(e$=n,n=(a||"")+o):(eI=n,n=i),(s=n)!==i)e$=t,t=th("Float",parseFloat(tg(r+"e"+s)),e$);else eI=t,t=i}else eI=t,t=i;else eI=t,t=i;if(t===i){let n,s,a,o,l,c;t=eI,(n=eI,s=e.charAt(eI),d.test(s)?eI++:(s=i,0===eT&&eD(M)),s===i&&(s=null),(a=eQ())!==i&&(46===e.charCodeAt(eI)?(o=".",eI++):(o=i,0===eT&&eD(T)),o!==i&&(l=eI,(l=(c=e0())!==i?e.substring(l,eI):c)!==i)))?(e$=n,n=("-"===s?"-":"")+a+"."+l):(eI=n,n=i),(r=n)!==i&&(e$=t,r=th("Float",parseFloat(tg(r)),e$)),t=r}return t}())===i&&(w=function(){let t,r,n,s;if(((t=eI,"0x"===e.substr(eI,2)?(r="0x",eI+=2):(r=i,0===eT&&eD(z)),r!==i&&(n=eI,(n=(s=function(){let t,r,n,s,a,o;if(t=eI,r=e.charAt(eI),x.test(r)?eI++:(r=i,0===eT&&eD(ei)),r!==i){for(n=[],s=eI,a=e.charAt(eI),v.test(a)?eI++:(a=i,0===eT&&eD(er)),a===i&&(a=null),o=e.charAt(eI),x.test(o)?eI++:(o=i,0===eT&&eD(ei)),o!==i?s=a=[a,o]:(eI=s,s=i);s!==i;)n.push(s),s=eI,a=e.charAt(eI),v.test(a)?eI++:(a=i,0===eT&&eD(er)),a===i&&(a=null),o=e.charAt(eI),x.test(o)?eI++:(o=i,0===eT&&eD(ei)),o!==i?s=a=[a,o]:(eI=s,s=i);t=r=[r,n]}else eI=t,t=i;return t}())!==i?e.substring(n,eI):s)!==i))?(e$=t,t=th("Integer",parseInt(tg(n),16),e$)):(eI=t,t=i),t===i)&&((t=eI,"0o"===e.substr(eI,2)?(r="0o",eI+=2):(r=i,0===eT&&eD(Q)),r!==i&&(n=eI,(n=(s=function(){let t,r,n,s,a,o;if(t=eI,r=e.charAt(eI),k.test(r)?eI++:(r=i,0===eT&&eD(es)),r!==i){for(n=[],s=eI,a=e.charAt(eI),v.test(a)?eI++:(a=i,0===eT&&eD(er)),a===i&&(a=null),o=e.charAt(eI),k.test(o)?eI++:(o=i,0===eT&&eD(es)),o!==i?s=a=[a,o]:(eI=s,s=i);s!==i;)n.push(s),s=eI,a=e.charAt(eI),v.test(a)?eI++:(a=i,0===eT&&eD(er)),a===i&&(a=null),o=e.charAt(eI),k.test(o)?eI++:(o=i,0===eT&&eD(es)),o!==i?s=a=[a,o]:(eI=s,s=i);t=r=[r,n]}else eI=t,t=i;return t}())!==i?e.substring(n,eI):s)!==i))?(e$=t,t=th("Integer",parseInt(tg(n),8),e$)):(eI=t,t=i),t===i)&&((t=eI,"0b"===e.substr(eI,2)?(r="0b",eI+=2):(r=i,0===eT&&eD(Z)),r!==i&&(n=eI,(n=(s=function(){let t,r,n,s,a,o;if(t=eI,r=e.charAt(eI),S.test(r)?eI++:(r=i,0===eT&&eD(ea)),r!==i){for(n=[],s=eI,a=e.charAt(eI),v.test(a)?eI++:(a=i,0===eT&&eD(er)),a===i&&(a=null),o=e.charAt(eI),S.test(o)?eI++:(o=i,0===eT&&eD(ea)),o!==i?s=a=[a,o]:(eI=s,s=i);s!==i;)n.push(s),s=eI,a=e.charAt(eI),v.test(a)?eI++:(a=i,0===eT&&eD(er)),a===i&&(a=null),o=e.charAt(eI),S.test(o)?eI++:(o=i,0===eT&&eD(ea)),o!==i?s=a=[a,o]:(eI=s,s=i);t=r=[r,n]}else eI=t,t=i;return t}())!==i?e.substring(n,eI):s)!==i))?(e$=t,t=th("Integer",parseInt(tg(n),2),e$)):(eI=t,t=i),t===i)){let n,s,a,o,l,c;t=eI,(n=eI,s=e.charAt(eI),d.test(s)?eI++:(s=i,0===eT&&eD(M)),s===i&&(s=null),48===e.charCodeAt(eI)?(a="0",eI++):(a=i,0===eT&&eD(H)),a!==i&&(o=eI,eT++,l=e.charAt(eI),y.test(l)?eI++:(l=i,0===eT&&eD(ee)),eT--,l===i?o=void 0:(eI=o,o=i),o!==i&&(l=eI,eT++,46===e.charCodeAt(eI)?(c=".",eI++):(c=i,0===eT&&eD(T)),eT--,c===i?l=void 0:(eI=l,l=i),l!==i)))?(e$=n,n=(s||"")+"0"):(eI=n,n=i),n===i&&((n=eI,s=e.charAt(eI),d.test(s)?eI++:(s=i,0===eT&&eD(M)),s===i&&(s=null),a=eI,(a=(o=eZ())!==i?e.substring(a,eI):o)!==i&&(o=eI,eT++,46===e.charCodeAt(eI)?(l=".",eI++):(l=i,0===eT&&eD(T)),eT--,l===i?o=void 0:(eI=o,o=i),o!==i))?(e$=n,n=(s||"")+a):(eI=n,n=i)),(r=n)!==i&&(e$=t,r=th("Integer",parseInt(tg(r),10),e$)),t=r}return t}())),(n=w)===i&&(I=eI,e.substr(eI,4)===l?($=l,eI+=4):($=i,0===eT&&eD(eo)),$!==i&&($=th("Boolean",!0,e$=I)),(I=$)===i&&(I=eI,e.substr(eI,5)===c?($=c,eI+=5):($=i,0===eT&&eD(el)),$!==i&&($=th("Boolean",!1,e$=I)),I=$),(n=I)===i&&(n=function(){let t,r,n,s,a,o,l,c,u,d;if(t=eI,91===e.charCodeAt(eI)?(r="[",eI++):(r=i,0===eT&&eD(C)),r!==i){for(n=[],s=e1();s!==i;)n.push(s),s=e1();93===e.charCodeAt(eI)?(s="]",eI++):(s=i,0===eT&&eD(A)),s!==i?t=th("Array",[],e$=t):(eI=t,t=i)}else eI=t,t=i;if(t===i)if(t=eI,91===e.charCodeAt(eI)?(r="[",eI++):(r=i,0===eT&&eD(C)),r!==i){for(n=[],s=e1();s!==i;)n.push(s),s=e1();if((s=eX())!==i){for(a=[],o=eI,l=[],c=e1();c!==i;)l.push(c),c=e1();if(44===e.charCodeAt(eI)?(c=",",eI++):(c=i,0===eT&&eD(ec)),c!==i){for(u=[],d=e1();d!==i;)u.push(d),d=e1();(d=eX())!==i?(e$=o,o=d):(eI=o,o=i)}else eI=o,o=i;for(;o!==i;){for(a.push(o),o=eI,l=[],c=e1();c!==i;)l.push(c),c=e1();if(44===e.charCodeAt(eI)?(c=",",eI++):(c=i,0===eT&&eD(ec)),c!==i){for(u=[],d=e1();d!==i;)u.push(d),d=e1();(d=eX())!==i?(e$=o,o=d):(eI=o,o=i)}else eI=o,o=i}for(o=[],l=e1();l!==i;)o.push(l),l=e1();for(44===e.charCodeAt(eI)?(l=",",eI++):(l=i,0===eT&&eD(ec)),l===i&&(l=null),c=[],u=e1();u!==i;)c.push(u),u=e1();if(93===e.charCodeAt(eI)?(u="]",eI++):(u=i,0===eT&&eD(A)),u!==i){var f;e$=t,f=s,a.unshift(f),t=th("Array",a,e$)}else eI=t,t=i}else eI=t,t=i}else eI=t,t=i;return t}())===i))&&(n=function(){let t,r,n,s,a,o,l,c,u,d;if(t=eI,123===e.charCodeAt(eI)?(r="{",eI++):(r=i,0===eT&&eD(eu)),r!==i){for(n=[],s=e3();s!==i;)n.push(s),s=e3();125===e.charCodeAt(eI)?(s="}",eI++):(s=i,0===eT&&eD(ed)),s!==i?t=th("InlineTable",[],e$=t):(eI=t,t=i)}else eI=t,t=i;if(t===i)if(t=eI,123===e.charCodeAt(eI)?(r="{",eI++):(r=i,0===eT&&eD(eu)),r!==i){for(n=[],s=e3();s!==i;)n.push(s),s=e3();if((s=e2())!==i){for(a=[],o=eI,l=[],c=e3();c!==i;)l.push(c),c=e3();if(44===e.charCodeAt(eI)?(c=",",eI++):(c=i,0===eT&&eD(ec)),c!==i){for(u=[],d=e3();d!==i;)u.push(d),d=e3();(d=e2())!==i?(e$=o,o=d):(eI=o,o=i)}else eI=o,o=i;for(;o!==i;){for(a.push(o),o=eI,l=[],c=e3();c!==i;)l.push(c),c=e3();if(44===e.charCodeAt(eI)?(c=",",eI++):(c=i,0===eT&&eD(ec)),c!==i){for(u=[],d=e3();d!==i;)u.push(d),d=e3();(d=e2())!==i?(e$=o,o=d):(eI=o,o=i)}else eI=o,o=i}for(o=[],l=e3();l!==i;)o.push(l),l=e3();for(44===e.charCodeAt(eI)?(l=",",eI++):(l=i,0===eT&&eD(ec)),l===i&&(l=null),c=[],u=e3();u!==i;)c.push(u),u=e3();if(125===e.charCodeAt(eI)?(u="}",eI++):(u=i,0===eT&&eD(ed)),u!==i){var f;e$=t,f=s,a.unshift(f),t=th("InlineTable",a,e$)}else eI=t,t=i}else eI=t,t=i}else eI=t,t=i;return t}()),(r=n)!==i){var E;e$=t,E=r,tc--,r=E}return(t=r)===i&&(e$=eI,tc--,t=!1,t=i),t}())!==i)?(e$=t,t=r):(eI=t,t=i),t}function eW(){let t,r,n,s;if(t=eI,34===e.charCodeAt(eI)?(r='"',eI++):(r=i,0===eT&&eD(F)),r!==i){for(n=[],s=eH();s!==i;)n.push(s),s=eH();(34===e.charCodeAt(eI)?(s='"',eI++):(s=i,0===eT&&eD(F)),s!==i)?(e$=t,t=th("String",n.join(""),e$)):(eI=t,t=i)}else eI=t,t=i;return t}function eJ(){let t,r,n,s;if(t=eI,39===e.charCodeAt(eI)?(r="'",eI++):(r=i,0===eT&&eD(R)),r!==i){for(n=[],s=ez();s!==i;)n.push(s),s=ez();(39===e.charCodeAt(eI)?(s="'",eI++):(s=i,0===eT&&eD(R)),s!==i)?(e$=t,t=th("String",n.join(""),e$)):(eI=t,t=i)}else eI=t,t=i;return t}function eq(){let t,r,n;if((t=to())===i&&(t=function(){let t,r,n,s,a,o;if(t=eI,92===e.charCodeAt(eI)?(r="\\",eI++):(r=i,0===eT&&eD(U)),r!==i){for(n=[],s=te();s!==i;)n.push(s),s=te();if((s=tt())!==i){for(a=[],o=tr();o!==i;)a.push(o),o=tr();e$=t,t=""}else eI=t,t=i}else eI=t,t=i;return t}())===i&&(t=eI,92===e.charCodeAt(eI)?(r="\\",eI++):(r=i,0===eT&&eD(U)),r!==i?(e.length>eI?(n=e.charAt(eI),eI++):(n=i,0===eT&&eD(B)),n!==i?t=void td("Invalid escape sequence",e$=t):(eI=t,t=i)):(eI=t,t=i),t===i)&&(t=eI,"\r\n"===e.substr(eI,2)?(r="\r\n",eI+=2):(r=i,0===eT&&eD(Y)),r!==i&&(e$=t,r="\n"),(t=r)===i)){if(t=eI,r=[],n=e.charAt(eI),f.test(n)?eI++:(n=i,0===eT&&eD(X)),n!==i)for(;n!==i;)r.push(n),n=e.charAt(eI),f.test(n)?eI++:(n=i,0===eT&&eD(X));else r=i;t=r!==i?e.substring(t,eI):r}return t}function eK(){let t,r,n,s;return t=eI,'""'===e.substr(eI,2)?(r='""',eI+=2):(r=i,0===eT&&eD(W)),r!==i?(n=eI,eT++,34===e.charCodeAt(eI)?(s='"',eI++):(s=i,0===eT&&eD(F)),eT--,s===i?n=void 0:(eI=n,n=i),n!==i?(e$=t,t='""'):(eI=t,t=i)):(eI=t,t=i),t===i&&(t=eI,34===e.charCodeAt(eI)?(r='"',eI++):(r=i,0===eT&&eD(F)),r!==i?(n=eI,eT++,34===e.charCodeAt(eI)?(s='"',eI++):(s=i,0===eT&&eD(F)),eT--,s===i?n=void 0:(eI=n,n=i),n!==i?(e$=t,t='"'):(eI=t,t=i)):(eI=t,t=i)),t}function eV(){let t,r,n;if(t=eI,"\r\n"===e.substr(eI,2)?(r="\r\n",eI+=2):(r=i,0===eT&&eD(Y)),r!==i&&(e$=t,r="\n"),(t=r)===i){if(t=eI,r=[],n=e.charAt(eI),h.test(n)?eI++:(n=i,0===eT&&eD(J)),n!==i)for(;n!==i;)r.push(n),n=e.charAt(eI),h.test(n)?eI++:(n=i,0===eT&&eD(J));else r=i;t=r!==i?e.substring(t,eI):r}return t}function eG(){let t,r,n,s;return t=eI,"''"===e.substr(eI,2)?(r="''",eI+=2):(r=i,0===eT&&eD(q)),r!==i?(n=eI,eT++,39===e.charCodeAt(eI)?(s="'",eI++):(s=i,0===eT&&eD(R)),eT--,s===i?n=void 0:(eI=n,n=i),n!==i?(e$=t,t="''"):(eI=t,t=i)):(eI=t,t=i),t===i&&(t=eI,39===e.charCodeAt(eI)?(r="'",eI++):(r=i,0===eT&&eD(R)),r!==i?(n=eI,eT++,39===e.charCodeAt(eI)?(s="'",eI++):(s=i,0===eT&&eD(R)),eT--,s===i?n=void 0:(eI=n,n=i),n!==i?(e$=t,t="'"):(eI=t,t=i)):(eI=t,t=i)),t}function eH(){let t,r,n;if((t=to())===i&&(t=eI,92===e.charCodeAt(eI)?(r="\\",eI++):(r=i,0===eT&&eD(U)),r!==i?(e.length>eI?(n=e.charAt(eI),eI++):(n=i,0===eT&&eD(B)),n!==i?t=void td("Invalid escape sequence",e$=t):(eI=t,t=i)):(eI=t,t=i),t===i)){if(t=eI,r=[],n=e.charAt(eI),p.test(n)?eI++:(n=i,0===eT&&eD(K)),n!==i)for(;n!==i;)r.push(n),n=e.charAt(eI),p.test(n)?eI++:(n=i,0===eT&&eD(K));else r=i;t=r!==i?e.substring(t,eI):r}return t}function ez(){let t,r,n;if(t=eI,r=[],n=e.charAt(eI),m.test(n)?eI++:(n=i,0===eT&&eD(V)),n!==i)for(;n!==i;)r.push(n),n=e.charAt(eI),m.test(n)?eI++:(n=i,0===eT&&eD(V));else r=i;return r!==i?e.substring(t,eI):r}function eQ(){let t,r;return t=eI,48===e.charCodeAt(eI)?(r="0",eI++):(r=i,0===eT&&eD(H)),r!==i&&(e$=t,r="0"),(t=r)===i&&(t=eI,t=(r=eZ())!==i?e.substring(t,eI):r),t}function eZ(){let t,r,n,s,a,o;if(t=eI,r=e.charAt(eI),b.test(r)?eI++:(r=i,0===eT&&eD(et)),r!==i){for(n=[],s=eI,a=e.charAt(eI),v.test(a)?eI++:(a=i,0===eT&&eD(er)),a===i&&(a=null),o=e.charAt(eI),w.test(o)?eI++:(o=i,0===eT&&eD(en)),o!==i?s=a=[a,o]:(eI=s,s=i);s!==i;)n.push(s),s=eI,a=e.charAt(eI),v.test(a)?eI++:(a=i,0===eT&&eD(er)),a===i&&(a=null),o=e.charAt(eI),w.test(o)?eI++:(o=i,0===eT&&eD(en)),o!==i?s=a=[a,o]:(eI=s,s=i);t=r=[r,n]}else eI=t,t=i;return t}function e0(){let t,r,n,s,a,o;if(t=eI,r=e.charAt(eI),w.test(r)?eI++:(r=i,0===eT&&eD(en)),r!==i){for(n=[],s=eI,a=e.charAt(eI),v.test(a)?eI++:(a=i,0===eT&&eD(er)),a===i&&(a=null),o=e.charAt(eI),w.test(o)?eI++:(o=i,0===eT&&eD(en)),o!==i?s=a=[a,o]:(eI=s,s=i);s!==i;)n.push(s),s=eI,a=e.charAt(eI),v.test(a)?eI++:(a=i,0===eT&&eD(er)),a===i&&(a=null),o=e.charAt(eI),w.test(o)?eI++:(o=i,0===eT&&eD(en)),o!==i?s=a=[a,o]:(eI=s,s=i);t=r=[r,n]}else eI=t,t=i;return t}function e1(){let e;return(e=te())===i&&(e=tt())===i&&(e=eR()),e}function e2(){let t,r,n,s,a,o;if(t=eI,(r=e5())!==i){for(n=[],s=te();s!==i;)n.push(s),s=te();if(61===e.charCodeAt(eI)?(s="=",eI++):(s=i,0===eT&&eD(N)),s!==i){for(a=[],o=te();o!==i;)a.push(o),o=te();if((o=eX())!==i)t=th("InlineTableValue",o,e$=t,r);else eI=t,t=i}else eI=t,t=i}else eI=t,t=i;return t}function e3(){let e;return(e=te())===i&&(e=tt())===i&&(e=eR()),e}function e5(){let e,t,r,n;if(e=eI,t=[],(r=e6())!==i)for(;r!==i;)t.push(r),r=e6();else t=i;if(t!==i){for(r=[],n=te();n!==i;)r.push(n),n=te();if((n=e8())!==i){var s,a;e$=e,s=t,a=n,e=s.concat(a)}else eI=e,e=i}else eI=e,e=i;return e===i&&(e=eI,(t=e8())!==i&&(e$=e,t=[t]),e=t),e}function e6(){let t,r,n,s,a;for(t=eI,r=[],n=te();n!==i;)r.push(n),n=te();if((n=e8())!==i){for(s=[],a=te();a!==i;)s.push(a),a=te();(46===e.charCodeAt(eI)?(a=".",eI++):(a=i,0===eT&&eD(T)),a!==i)?(e$=t,t=n):(eI=t,t=i)}else eI=t,t=i;return t}function e8(){let t,r,n;return(t=function(){let t,r,n;if(t=eI,r=[],(n=ta())!==i)for(;n!==i;)r.push(n),n=ta();else r=i;return r!==i?e.substring(t,eI):r}())===i&&(r=eI,(n=eW())!==i&&(e$=r,n=n.value),(r=n)===i&&(r=eI,(n=eJ())!==i&&(e$=r,n=n.value),r=n),t=r),t}function e9(){let t,r,n,s,a,o,l,c,u,d,f,h;return t=eI,r=eI,(n=ti())!==i&&(s=ti())!==i&&(a=ti())!==i&&(o=ti())!==i?(45===e.charCodeAt(eI)?(l="-",eI++):(l=i,0===eT&&eD(ef)),l!==i&&(c=ti())!==i&&(u=ti())!==i?(45===e.charCodeAt(eI)?(d="-",eI++):(d=i,0===eT&&eD(ef)),d!==i&&(f=ti())!==i&&(h=ti())!==i?r=n=[n,s,a,o,l,c,u,d,f,h]:(eI=r,r=i)):(eI=r,r=i)):(eI=r,r=i),t=r!==i?e.substring(t,eI):r}function e4(){let t,r,n,s,a,o,l,c,u,d,f;if(t=eI,r=eI,n=eI,(s=ti())!==i&&(a=ti())!==i?(58===e.charCodeAt(eI)?(o=":",eI++):(o=i,0===eT&&eD(eh)),o!==i&&(l=ti())!==i&&(c=ti())!==i?(58===e.charCodeAt(eI)?(u=":",eI++):(u=i,0===eT&&eD(eh)),u!==i&&(d=ti())!==i&&(f=ti())!==i?n=s=[s,a,o,l,c,u,d,f]:(eI=n,n=i)):(eI=n,n=i)):(eI=n,n=i),(r=n!==i?e.substring(r,eI):n)!==i){var h,p;(n=function(){let t,r,n,s,a;if(t=eI,r=eI,46===e.charCodeAt(eI)?(n=".",eI++):(n=i,0===eT&&eD(T)),n!==i){if(s=[],(a=ti())!==i)for(;a!==i;)s.push(a),a=ti();else s=i;s!==i?r=n=[n,s]:(eI=r,r=i)}else eI=r,r=i;return r!==i?e.substring(t,eI):r}())===i&&(n=null),e$=t,h=r,t=(p=n)?h+p:h}else eI=t,t=i;return t===i&&((t=eI,r=eI,n=eI,(s=ti())!==i&&(a=ti())!==i?(58===e.charCodeAt(eI)?(o=":",eI++):(o=i,0===eT&&eD(eh)),o!==i&&(l=ti())!==i&&(c=ti())!==i?n=s=[s,a,o,l,c]:(eI=n,n=i)):(eI=n,n=i),(r=n!==i?e.substring(r,eI):n)!==i&&(n=eI,eT++,58===e.charCodeAt(eI)?(s=":",eI++):(s=i,0===eT&&eD(eh)),eT--,s===i?n=void 0:(eI=n,n=i),n!==i))?(e$=t,t=r+":00"):(eI=t,t=i)),t}function e7(){let t,r,n,s;return"t"===(t=e.charAt(eI)).toLowerCase()?eI++:(t=i,0===eT&&eD(em)),t===i&&(t=eI,32===e.charCodeAt(eI)?(r=" ",eI++):(r=i,0===eT&&eD(eg)),r!==i?(n=eI,eT++,s=ti(),eT--,s!==i?(eI=n,n=void 0):n=i,n!==i?t=r=[r,n]:(eI=t,t=i)):(eI=t,t=i)),t}function te(){let t;return t=e.charAt(eI),_.test(t)?eI++:(t=i,0===eT&&eD(ey)),t}function tt(){let t,r,n;return 10===e.charCodeAt(eI)?(t="\n",eI++):(t=i,0===eT&&eD(eb)),t===i&&(t=eI,13===e.charCodeAt(eI)?(r="\r",eI++):(r=i,0===eT&&eD(ev)),r!==i?(10===e.charCodeAt(eI)?(n="\n",eI++):(n=i,0===eT&&eD(eb)),n!==i?t=r=[r,n]:(eI=t,t=i)):(eI=t,t=i)),t}function tr(){let e;return(e=tt())===i&&(e=te()),e}function tn(){let t,r;return t=eI,eT++,e.length>eI?(r=e.charAt(eI),eI++):(r=i,0===eT&&eD(B)),eT--,r===i?t=void 0:(eI=t,t=i),t}function ti(){let t;return t=e.charAt(eI),w.test(t)?eI++:(t=i,0===eT&&eD(en)),t}function ts(){let t;return t=e.charAt(eI),x.test(t)?eI++:(t=i,0===eT&&eD(ei)),t}function ta(){let t;return t=e.charAt(eI),O.test(t)?eI++:(t=i,0===eT&&eD(ex)),t}function to(){let t,r,n,s,a,o,l,c,u,d,f,h,p,m,g;if(t=eI,92===e.charCodeAt(eI)?(r="\\",eI++):(r=i,0===eT&&eD(U)),r!==i)if(n=e.charAt(eI),I.test(n)?eI++:(n=i,0===eT&&eD(ek)),n!==i){var y;e$=t,t="n"===(y=n)?"\n":"t"===y?" ":"r"===y?"\r":"\\"===y?"\\":'"'===y?'"':"b"===y?"\b":"f"===y?"\f":"\x1b"}else eI=t,t=i;else eI=t,t=i;return t===i&&((s=eI,"\\U"===e.substr(eI,2)?(a="\\U",eI+=2):(a=i,0===eT&&eD(eS)),a!==i&&(o=eI,l=eI,(c=ts())!==i&&(u=ts())!==i&&(d=ts())!==i&&(f=ts())!==i&&(h=ts())!==i&&(p=ts())!==i&&(m=ts())!==i&&(g=ts())!==i?l=c=[c,u,d,f,h,p,m,g]:(eI=l,l=i),(o=l!==i?e.substring(o,eI):l)!==i))?(e$=s,s=ty(o)):(eI=s,s=i),s===i&&((s=eI,"\\u"===e.substr(eI,2)?(a="\\u",eI+=2):(a=i,0===eT&&eD(e_)),a!==i&&(o=eI,l=eI,(c=ts())!==i&&(u=ts())!==i&&(d=ts())!==i&&(f=ts())!==i?l=c=[c,u,d,f]:(eI=l,l=i),(o=l!==i?e.substring(o,eI):l)!==i))?(e$=s,s=ty(o)):(eI=s,s=i),s===i&&((s=eI,"\\x"===e.substr(eI,2)?(a="\\x",eI+=2):(a=i,0===eT&&eD(eO)),a!==i&&(o=eI,l=eI,(c=ts())!==i&&(u=ts())!==i?l=c=[c,u]:(eI=l,l=i),(o=l!==i?e.substring(o,eI):l)!==i))?(e$=s,s=ty(o)):(eI=s,s=i))),t=s),t}var tl=[],tc=0,tu=r&&null!=r.maxDepth?r.maxDepth:500;function td(t,r){var n=function(t){for(var r=1,n=1,i=0;i<t;i++)10===e.charCodeAt(i)?(r++,n=1):n++;return{line:r,column:n}}(r),i=Error(t);throw i.line=n.line,i.column=n.column,i}function tf(e){tl.push(e)}function th(e,t,r,n){var i={type:e,value:t,offset:r};return n&&(i.key=n),i}function tp(e,t){var r=1e3*e.charCodeAt(0)+100*e.charCodeAt(1)+10*e.charCodeAt(2)+e.charCodeAt(3)-53328,n=(e.charCodeAt(5)-48)*10+e.charCodeAt(6)-48,i=(e.charCodeAt(8)-48)*10+e.charCodeAt(9)-48;(n<1||n>12)&&td("Invalid date: month "+n+" out of range.",t);var s=[31,28,31,30,31,30,31,31,30,31,30,31];(r%4==0&&r%100!=0||r%400==0)&&(s[1]=29),(i<1||i>s[n-1])&&td("Invalid date: day "+i+" out of range for month "+n+".",t)}function tm(e,t){var r=(e.charCodeAt(0)-48)*10+e.charCodeAt(1)-48,n=(e.charCodeAt(3)-48)*10+e.charCodeAt(4)-48,i=(e.charCodeAt(6)-48)*10+e.charCodeAt(7)-48;r>23&&td("Invalid time: hour "+r+" out of range.",t),n>59&&td("Invalid time: minute "+n+" out of range.",t),i>59&&td("Invalid time: second "+i+" out of range.",t)}function tg(e){return -1===e.indexOf("_")?e:e.replace(/_/g,"")}function ty(e){var t=parseInt(e,16);if(t==t&&!(t<0)&&!(t>1114111)&&(!(t>55295)||!(t<57344)))return String.fromCodePoint(t);td("Invalid Unicode escape code: "+e,e$)}let tb=(n=o())!==i&&eI===e.length;function tv(){var r,s,a;throw n!==i&&eI<e.length&&eD({type:"end"}),r=eA,s=eC<e.length?function(t=eI){let r=e.codePointAt(t);return void 0===r?"":String.fromCodePoint(r)}(eC):null,a=eC<e.length?ej(eC,eC+1):ej(eC,eC),new t(t.buildMessage(r,s),r,s,a)}return r.peg$library?{peg$result:n,peg$currPos:eI,peg$FAILED:i,peg$maxFailExpected:eA,peg$maxFailPos:eC,peg$success:tb,peg$throw:tb?void 0:tv}:tb?n:void tv()}}},233(e,r,n){let i,s,a,o,l,c,u,d,f,h,p,m,g,y,b,v,w,x,k,S,_,O,I,$,E,C,A,T;var N,M,P=n(8543),j=n(7720),D=n(7598),F=n(4650);let L=(e,t)=>t(D.oJ(e)?0:P.nn(e.cause)?130:U(P.iw(e.cause))),R="~effect/Runtime/errorExitCode",U=e=>{if("object"==typeof e&&null!==e&&R in e){let t=e[R];if("number"==typeof t)return t}return 1},B="~effect/Runtime/errorReported",Y=(i=({fiber:e,teardown:t})=>{let r=!1;function n(){r=!0,e.interruptUnsafe(e.id)}e.addObserver(e=>{process.removeListener("SIGINT",n),process.removeListener("SIGTERM",n),t(e,e=>{(r||0!==e)&&process.exit(e)})}),process.on("SIGINT",n),process.on("SIGTERM",n)},(0,F.XY)(e=>j.yw5(e[0]),(e,t)=>{let r=t?.disableErrorReporting===!0?j.MY7(e):j.MY7(j.dGm(e,e=>P.nn(e)?j.rIH:(e=>{if("object"==typeof e&&null!==e&&B in e){let t=e[B];if("boolean"==typeof t)return t}return!0})(P.iw(e))?j.vVN(e):j.rIH));try{let e=globalThis.setInterval(F.Yi,0x7fffffff);r.addObserver(()=>{clearInterval(e)})}catch{}return i({fiber:r,teardown:t?.teardown??L})}));var X=n(5089),W=n(3717),J=n(8927),q=n(3833),K=n(995);function V(){return Object.assign(e=>e,{option:e=>q.some(e),result:e=>K.Py(e),is:e=>!0})}var G=n(8619),H=n(2718);let z="~effect/platform/PlatformError";class Q extends H.rN("BadArgument"){get message(){return`${this.module}.${this.method}${this.description?`: ${this.description}`:""}`}}class Z extends H.$D{get message(){return`${this._tag}: ${this.module}.${this.method}${void 0!==this.pathOrDescriptor?` (${this.pathOrDescriptor})`:""}${this.description?`: ${this.description}`:""}`}}class ee extends H.rN("PlatformError"){constructor(e){"cause"in e?super({reason:e,cause:e.cause}):super({reason:e})}[z]=z;get message(){return this.reason.message}}let et=e=>new ee(new Z(e)),er=e=>new ee(new Q(e));var en=n(9138),ei=n(5369),es=n(4505),ea=n(8433),eo=n(1136);let el=Symbol.for("effect/MutableList/Empty"),ec=()=>({array:[],mutable:!0,offset:0,next:void 0}),eu=(e,t)=>{e.tail?e.tail.mutable||(e.tail.next=ec(),e.tail=e.tail.next):e.head=e.tail=ec(),e.tail.array.push(t),e.length++},ed=e=>{e.head=e.tail=void 0,e.length=0},ef=e=>{if(!e.head)return el;let t=e.head.array[e.head.offset];return e.head.mutable&&(e.head.array[e.head.offset]=void 0),e.head.offset++,e.length--,e.head.offset===e.head.array.length&&(e.head.next?e.head=e.head.next:ed(e)),t},eh={_A:F.D_,_E:F.D_},ep={"~effect/Queue":eh,"~effect/Queue/Enqueue":eh,"~effect/Queue/Dequeue":eh,...ea.fU,toJSON(){return{_id:"effect/Queue",state:this.state._tag,size:eI(this)}}},em=e=>ea.R6(t=>{let r=Object.create(ep);return r.dispatcher=t.currentDispatcher,r.capacity=e?.capacity??1/0,r.strategy=e?.strategy??"suspend",r.messages={head:void 0,tail:void 0,length:0},r.scheduleRunning=!1,r.state={_tag:"Open",takers:new Set,offers:new Set,awaiters:new Set},eo.PyW(r)}),eg=(e,t)=>eo.DYE(()=>{if("Open"!==e.state._tag)return e$;if(e.messages.length>=e.capacity)switch(e.strategy){case"dropping":return e$;case"suspend":if(e.capacity<=0&&e.state.takers.size>0)return eu(e.messages,t),eT(e),eE;return eP(e,t);case"sliding":return ef(e.messages),eu(e.messages,t),eE}return eu(e.messages,t),eN(e),eE}),ey=(e,t)=>"Open"===e.state._tag&&(e.messages.length>=e.capacity?"sliding"===e.strategy?(ef(e.messages),eu(e.messages,t),!0):e.capacity<=0&&e.state.takers.size>0&&(eu(e.messages,t),eT(e),!0):(eu(e.messages,t),eN(e),!0)),eb=(0,F.XY)(2,(e,t)=>eo.OH5(()=>ev(e,t))),ev=(e,t)=>{if("Open"!==e.state._tag)return!1;let r=ea.cb(t),n=eo.il9(r,eC);return 0===e.state.offers.size&&0===e.messages.length?eF(e,n):e.state={...e.state,_tag:"Closing",exit:n},!0},ew=e=>ev(e,ea.OE(ea.RS())),ex=e=>eo.OH5(()=>{if("Done"===e.state._tag)return!0;ed(e.messages);let t=e.state.offers;if(eF(e,"Open"===e.state._tag?eA:e.state.exit),t.size>0){for(let e of t)"Single"===e._tag?e.resume(e$):e.resume(ea.xt(e.remaining.slice(e.offset)));t.clear()}return!0}),ek=e=>eS(e,1,1/0),eS=(e,t,r)=>eo.DYE(()=>eM(e,t,r)??eo.hgn(eD(e),eS(e,1,r))),e_=e=>eo.DYE(()=>eO(e)??eo.hgn(eD(e),e_(e))),eO=e=>{if("Done"===e.state._tag)return e.state.exit;if(e.messages.length>0){let t=ef(e.messages);return ej(e),ea.xt(t)}if(e.capacity<=0&&e.state.offers.size>0){e.capacity=1,ej(e),e.capacity=0;let t=ef(e.messages);return ej(e),ea.xt(t)}},eI=e=>"Done"===e.state._tag?0:e.messages.length,e$=ea.xt(!1),eE=ea.xt(!0),eC=ea.Rk(ea.RS()),eA=eo._sz(),eT=e=>{if(e.scheduleRunning=!1,"Done"!==e.state._tag&&0!==e.state.takers.size){for(let t of e.state.takers)if(e.state.takers.delete(t),t(eo.x5l),0===e.messages.length)break}},eN=e=>{e.scheduleRunning||"Done"===e.state._tag||0===e.state.takers.size||(e.scheduleRunning=!0,e.dispatcher.scheduleTask(()=>eT(e),0))},eM=(e,t,r)=>{if("Done"===e.state._tag)return e.state.exit;if(r<=0||t<=0)return ea.xt([]);if(e.capacity<=0&&e.state.offers.size>0){e.capacity=1,ej(e),e.capacity=0;let t=[ef(e.messages)];return ej(e),ea.xt(t)}if((t=Math.min(t,e.capacity||1))<=e.messages.length){let t=((e,t)=>{if(t<=0||!e.head)return[];if((t=Math.min(t,e.length))===e.length&&e.head?.offset===0&&!e.head.next){let t=e.head.array;return ed(e),t}let r=Array(t),n=0,i=e.head;for(;i;){for(;i.offset<i.array.length;)if(r[n++]=i.array[i.offset],i.mutable&&(i.array[i.offset]=void 0),i.offset++,n===t)return e.head=i,e.length-=t,0===e.length&&ed(e),r;i=i.next}return ed(e),r})(e.messages,r);return ej(e),ea.xt(t)}},eP=(e,t)=>eo.E2r(r=>{if("Open"!==e.state._tag)return r(e$);let n={_tag:"Single",message:t,resume:r};return e.state.offers.add(n),eo.OH5(()=>{"Open"===e.state._tag&&e.state.offers.delete(n)})}),ej=e=>{if("Done"===e.state._tag)return es.Og(e.state.exit.cause);if(0===e.state.offers.size)return"Closing"===e.state._tag&&0===e.messages.length&&(eF(e,e.state.exit),es.Og(e.state.exit.cause));let t=e.capacity-e.messages.length;for(let r of e.state.offers)if(0===t)break;else if("Single"===r._tag)eu(e.messages,r.message),t--,r.resume(eE),e.state.offers.delete(r);else{for(;r.offset<r.remaining.length;r.offset++){if(0===t)return!1;eu(e.messages,r.remaining[r.offset]),t--}r.resume(ea.xt([])),e.state.offers.delete(r)}return!1},eD=e=>eo.E2r(t=>"Done"===e.state._tag?t(e.state.exit):(e.state.takers.add(t),eo.OH5(()=>{"Done"!==e.state._tag&&e.state.takers.delete(t)}))),eF=(e,t)=>{if("Done"===e.state._tag)return;let r=e.state;for(let n of(e.state={_tag:"Done",exit:t},r.takers))n(t);for(let e of(r.takers.clear(),r.awaiters))e(t);r.awaiters.clear()};var eL=n(2672);let eR="~effect/Channel",eU=e=>(0,ei.i5)(e,eR),eB={[eR]:{_Env:F.D_,_InErr:F.D_,_InElem:F.D_,_OutErr:F.D_,_OutElem:F.D_},pipe(){return(0,en.tT)(this,arguments)}},eY=e=>{let t=Object.create(eB);return t.transform=(t,r)=>j.Tyx(e(t,r),e=>j.PyW(j.ATB(e))),t},eX=(e,t)=>eY((r,n)=>j.qIB(eJ(e)(r,n),e=>t(e,n))),eW=e=>eY((t,r)=>e),eJ=e=>e.transform,eq=eW(j.PyW(P.Vw()));j.ZmZ;let eK=(0,F.XY)(2,(e,t)=>eX(e,e=>j.OH5(()=>{let r=0;return j.TjK(e,e=>t(e,r++))}))),eV=(0,F.XY)(2,(e,t)=>eG(e,e=>j.PyW(t(e)))),eG=(0,F.XY)(2,(e,t)=>eX(e,e=>j.PyW(es.m8(e,e=>j.qIB(t(e),P.Vw))))),eH=(0,F.XY)(e=>eU(e[0])&&eU(e[1]),(e,t,r)=>{let n;return n=j.D9k(function*(n,i,s){let a=r?.haltStrategy??"both",o=yield*em({capacity:0});yield*eL.U9(s,ex(o));let l=0,c=(e,t,r)=>eJ(t)(n,r).pipe(j.qIB(e=>e.pipe(j.qIB(e=>eg(o,e)),j.i4r)),j.S5A(t=>j.hgn(eL.VN(r,es.aU(t)),function(e,t){if(l++,!es.Og(t))return eb(o,t);switch(a){case"both":return 2===l?eb(o,t):j.rIH;case"left":case"right":return e===a?eb(o,t):j.rIH;case"either":return eb(o,t)}}(e,t))),j.ar0(s));return yield*c("left",e,eL.Fp(s)),yield*c("right",t,eL.Fp(s)),e_(o)}),eY(j.D9k(function*(e,t){let r=eL.Fp(t),i=e=>eL.VN(r,es.aU(e)),s=yield*j.S5A(n(e,t,r),i);return j.S5A(s,i)}))}),ez=(0,F.XY)(2,(e,t)=>eY((r,n)=>j.qIB(eJ(e)(r,n),e=>eJ(t)(e,n)))),eQ=e=>eY((t,r)=>{let n;return j.PyW(j.DYE(()=>n||e.pipe(eL.Gt(r),j.qIB(e=>eJ(e)(t,r)),j.qIB(e=>n=e))))}),eZ=(e,t,r)=>j.DYE(()=>{let n=eL.LZ(),i=eJ(e)(P.Vw(),n);return es.m8(j.qIB(i,t),r||j.PyW).pipe(j.cfM(e=>eL.VN(n,e)))}),e0=(0,F.XY)(2,(e,t)=>eZ(e,e=>j.i4r(j.qIB(e,t),{disableYield:!0}))),e1=(0,F.XY)(3,(e,t,r)=>j.DYE(()=>{let n=t();return eZ(e,e=>j.iMI({while:F.ue,body:()=>e,step:e=>{n=r(n,e)}}),()=>j.PyW(n))})),e2=(e,t)=>eJ(e)(P.Vw(),t),e3="~effect/Sink",e5=j.PyW([void 0]),e6={[e3]:{_A:F.D_,_In:F.D_,_L:F.D_,_E:F.D_,_R:F.D_},pipe(){return(0,en.tT)(this,arguments)}},e8=e=>(0,ei.i5)(e,e3),e9=e=>e4((t,r)=>eJ(e)(t,r).pipe(j.qIB(j.i4r({disableYield:!0})),es.m8(j.PyW))),e4=e=>{let t=Object.create(e6);return t.transform=e,t},e7=e=>eY((t,r)=>j.PyW(j.qIB(e.transform(t,r),P.Vw)));j.ZmZ;let te=e4(e=>es.m8(j.i4r(e,{disableYield:!0}),()=>e5));q.none,q.isNone,q.none;let tt=e=>e9(eQ(j.TjK(e,e7))),tr={"~effect/Stream":{_R:F.D_,_E:F.D_,_A:F.D_},pipe(){return(0,en.tT)(this,arguments)}},tn=e=>(0,ei.i5)(e,"~effect/Stream"),ti=e=>{let t=Object.create(tr);return t.channel=e,t},ts=e=>e.channel,ta=ti(eq),to=e=>{let t;return ti((t=()=>e().channel,eY((e,r)=>j.DYE(()=>eJ(t())(e,r)))))},tl=e=>{let t;return J.ET(e)?ti((t=j.PyW(e),eW(j.OH5(()=>{let e=!1;return j.DYE(()=>e?P.Vw():(e=!0,t))})))):ta},tc=e=>ti(eQ(j.TjK(e,ts))),tu=(0,F.XY)(2,(e,t)=>to(()=>{let r=0;return ti(eK(e.channel,J.Tj(e=>t(e,r++))))})),td=(0,F.XY)(e=>tn(e[0])&&tn(e[1]),(e,t,r)=>ti(eH(ts(e),ts(t),r))),tf=(0,F.XY)(2,(e,t)=>{let r;return r=(e,r)=>j.OH5(()=>{let n,i,s=j.DYE(()=>{if(void 0!==i){let e=i;return i=void 0,j.PyW(e)}return e}).pipe(j.MfU(e=>(n=D.fJ(e),P.Vw()))),a=j.TjK(j.DYE(()=>t.transform(s,r)),([e,t])=>(i=t,J.of(e)));return j.DYE(()=>n||a)}),ti(eY((t,n)=>j.qIB(e2(e.channel,n),e=>r(e,n))))}),th=(0,F.XY)(e=>tn(e[0]),(e,t)=>to(()=>{let r=new TextDecoder(t?.encoding);return tu(e,e=>r.decode(e,{stream:!0}))})),tp=(0,F.XY)(2,(e,t)=>j.Pxi(r=>e2(e.channel,r).pipe(j.qIB(e=>t.transform(e,r)),j.TjK(([e])=>e)))),tm=e=>e1(e.channel,()=>[],(e,t)=>{for(let r=0;r<t.length;r++)e.push(t[r]);return e}),tg=((e,t)=>e0(e.channel,t),"~effect/platform/FileSystem"),ty=e=>"bigint"==typeof e?e:BigInt(e),tb=G.kl("effect/platform/FileSystem"),tv="~effect/platform/FileSystem/File",tw=V();class tx extends G.kl()("effect/platform/FileSystem/WatchBackend"){}let tk="~effect/platform/Path",tS=G.kl("effect/Path");var t_=n(3267),tO=n(6400);let tI=V(),t$=V(),tE="~effect/ChildProcessSpawner/ChildProcessHandle",tC={[tE]:tE,...tO.os,toJSON(){return{_id:"ChildProcessHandle",pid:this.pid}}},tA=e=>Object.assign(Object.create(tC),e);class tT extends G.kl()("effect/process/ChildProcessSpawner"){}let tN="~effect/unstable/process/ChildProcess",tM={...t_.b({label:"Command",evaluate(e){return G.fp(e.context,tT).spawn(this)}}),[tN]:tN},tP=(e,t,r)=>Object.assign(Object.create(tM),{_tag:"StandardCommand",command:e,args:t,options:r}),tj=function(...e){if(tD(e[0])){let[t,...r]=e,n=tR(t,r);return tP(n[0]??"",n.slice(1),{})}if("object"==typeof e[0]&&!Array.isArray(e[0])&&!tD(e[0])){let t=e[0];return function(e,...r){let n=tR(e,r);return tP(n[0]??"",n.slice(1),t)}}if("string"==typeof e[0]&&!Array.isArray(e[1])){let[t,r={}]=e;return tP(t,[],r)}let[t,r=[],n={}]=e;return tP(t,r,n)},tD=e=>Array.isArray(e)&&"raw"in e&&Array.isArray(e.raw),tF=e=>{let t=/^fd(\d+)$/.exec(e);if(null===t)return;let r=parseInt(t[1],10);return r>=3?r:void 0},tL=e=>`fd${e}`,tR=(e,t)=>{let r=[];for(let[n,i]of e.entries())r=tU(e,t,r,i,n);return r},tU=(e,t,r,n,i)=>{let s=e.raw[i];if(void 0===s)throw Error(`Invalid backslash sequence: ${e.raw[i]}`);let{hasLeadingWhitespace:a,hasTrailingWhitespace:o,tokens:l}=tW(n,s),c=tJ(r,l,a);if(i===t.length)return c;let u=t[i];return tJ(c,Array.isArray(u)?u.map(e=>tB(e)):[tB(u)],o)},tB=e=>"string"==typeof e?e:String(e),tY=new Set([" "," ","\r","\n"]),tX={x:3,u:5},tW=(e,t)=>{if(0===t.length)return{tokens:[],hasLeadingWhitespace:!1,hasTrailingWhitespace:!1};let r=tY.has(t[0]),n=[],i=0;for(let r=0,s=0;r<e.length;r+=1,s+=1){let a=t[s];if(tY.has(a))i!==r&&n.push(e.slice(i,r)),i=r+1;else if("\\"===a){let e=t[s+1];"\n"===e?(r-=1,s+=1):"u"===e&&"{"===t[s+2]?s=t.indexOf("}",s+3):s+=tX[e]??1}}let s=i===e.length;return s||n.push(e.slice(i)),{tokens:n,hasLeadingWhitespace:r,hasTrailingWhitespace:s}},tJ=(e,t,r)=>r||0===e.length||0===t.length?[...e,...t]:[...e.slice(0,-1),`${e.at(-1)}${t.at(0)}`,...t.slice(1)],tq=t("node:child_process"),tK=t("node:stream"),tV=(e,t)=>(r,[n])=>{let i="Unknown";switch(r.code){case"ENOENT":i="NotFound";break;case"EACCES":i="PermissionDenied";break;case"EEXIST":i="AlreadyExists";break;case"EISDIR":case"ENOTDIR":case"ELOOP":i="BadResource";break;case"EBUSY":i="Busy"}return et({_tag:i,module:e,method:t,pathOrDescriptor:n,syscall:r.syscall,cause:r})},tG=e=>e9(eV(tH(e),e=>[e])),tH=e=>eY(t=>{let r=e.evaluate();return j.PyW(tz({...e,writable:r,pull:t}))}),tz=e=>e.pull.pipe(j.qIB(t=>{let r=0;return j.E2r(function n(i){for(;r<t.length;)if(!e.writable.write(t[r++],e.encoding))return void e.writable.once("drain",()=>n(i));i(j.rIH)})}),j.i4r({disableYield:!0}),j.KT6(j.E2r(t=>{let r=r=>t(j.fJG(e.onError(r)));return e.writable.once("error",r),j.OH5(()=>{e.writable.off("error",r)})})),!1!==e.endOnDone?es.m8(t=>"closed"in e.writable&&e.writable.closed?P.Vw(t):j.E2r(r=>{e.writable.once("finish",()=>r(P.Vw(t))),e.writable.end()})):F.D_);eo.zFM,eo.C6p,eo.D7p,eo.INJ;let tQ=eo.mKq;eo.eGS,eo.DKo,eo.$MQ,eo.Iku;let tZ=eo.vTQ,t0=eo.zzk;eo.Fbb;let t1="~effect/MutableRef",t2={[t1]:t1,...ea.fU,toJSON(){return{_id:"MutableRef",current:(0,tO.aB)(this.current)}}},t3=e=>ti(t5(e)),t5=e=>eY((t,r)=>t6({scope:r,readable:e.evaluate(),onError:e.onError??t8,chunkSize:e.chunkSize,closeOnDone:e.closeOnDone})),t6=e=>{var t;let r,n=e.readable,i=e.closeOnDone??!0,s=e.exit??(t=void 0,(r=Object.create(t2)).current=t,r),a=t0(!1);function o(){a.openUnsafe()}function l(t){s.current=D.fJ(e.onError(t)),a.openUnsafe()}function c(){s.current=D.fJ(P.RS()),a.openUnsafe()}n.on("readable",o),n.once("error",l),n.once("end",c);let u=j.DYE(function t(){let r=e.readable.read(e.chunkSize);if(null===r)return s.current?s.current:n.readableEnded?j.fJG(P.RS()):(a.closeUnsafe(),j.qIB(a.await,t));let i=J.of(r);for(;null!==(r=e.readable.read(e.chunkSize));)i.push(r);return j.PyW(i)});return j.as(eL.U9(e.scope,j.OH5(()=>{n.off("readable",o),n.off("error",l),n.off("end",c),i&&"closed"in e.readable&&!e.readable.closed&&e.readable.destroy()})),u)};tK.Readable;let t8=e=>new P.Bk(e),t9=e=>e instanceof globalThis.Error?e:new globalThis.Error(String(e)),t4=(e,t,r)=>{let{commands:n}=rt(r),i=n.reduce((e,t)=>{let r=`${t.command} ${t.args.join(" ")}`;return 0===e.length?r:`${e} | ${r}`},"");return tV("ChildProcess",e)(t,[i])},t7=j.JkU(function*(){let e,t,r=yield*tb,n=yield*tS,i=j.D9k(function*(e){if(!ei.b0(e.cwd))return yield*r.access(e.cwd),n.resolve(e.cwd)}),s=e=>e8(e)?"pipe":e,a=e=>{let t={stream:"pipe",encoding:"utf-8",endOnDone:!0};return ei.b0(e.stdin)?t:"string"==typeof e.stdin||tn(e.stdin)?{...t,stream:e.stdin}:{stream:e.stdin.stream,encoding:e.stdin.encoding??t.encoding,endOnDone:e.stdin.endOnDone??t.endOnDone}},o=(e,t)=>{let r=e[t];return ei.b0(r)?{stream:"pipe"}:"string"==typeof r||e8(r)?{stream:r}:{stream:r.stream}},l=j.D9k(function*(e,t,r){if(0===r.length)return{getInputFd:()=>te,getOutputFd:()=>ta};let n=new Map,i=new Map;for(let{config:s,fd:a}of r){let r=t.stdio[a];switch(s.type){case"input":{let t=te;r&&"write"in r&&(t=tG({evaluate:()=>r,onError:t=>t4(`fromWritable(fd${a})`,t9(t),e)})),s.stream&&(yield*j.x6Z(tp(s.stream,t))),n.set(a,t);break}case"output":{let t=ta;if(r&&"read"in r){let n=new tK.PassThrough;r.on("error",e=>n.destroy(e)),r.pipe(n),t=t3({evaluate:()=>n,onError:t=>t4(`fromReadable(fd${a})`,t9(t),e)})}s.sink&&(t=tf(t,s.sink)),i.set(a,t)}}}return{getInputFd:e=>n.get(e)??te,getOutputFd:e=>i.get(e)??ta}}),c=(e,t,r)=>"win32"===globalThis.process.platform?j.E2r(r=>{tq.exec(`taskkill /pid ${t.pid} /T /F`,t=>{t?r(j.fJG(t4("kill",t9(t),e))):r(j.rIH)})}):j.SvU({try:()=>{globalThis.process.kill(-t.pid,r)},catch:t=>t4("kill",t9(t),e)}),u=(e,t,r)=>j.DYE(()=>{if(!t.kill(r)){let t=new globalThis.Error("Failed to kill child process");return j.fJG(t4("kill",t,e))}return j.rIH}),d=(e,t,r)=>n=>{let i=r?.killSignal??"SIGTERM";return ei.b0(r?.forceKillAfter)?n(t,e,i):j.mgX(n(t,e,i),{duration:r.forceKillAfter,orElse:()=>n(t,e,"SIGKILL")})},f=(e,t)=>{let r=t??"stdout";switch(r){case"stdout":return e.stdout;case"stderr":return e.stderr;case"all":return e.all;default:{let t=tF(r);if(ei.EA(t))return e.getOutputFd(t);return e.stdout}}},h=j.D9k(function*(e){switch(e._tag){case"StandardCommand":{let t,r,n,f,h,p,m,g=a(e.options),y=o(e.options,"stdout"),b=o(e.options,"stderr"),v=(e=>{if(ei.b0(e.additionalFds))return[];let t=[];for(let[r,n]of Object.entries(e.additionalFds)){let e=tF(r);ei.EA(e)&&t.push({fd:e,config:n})}return t.sort((e,t)=>e.fd-t.fd)})(e.options),w=!0,x=yield*i(e.options),k=(t=e.options).extendEnv?{...globalThis.process.env,...t.env}:t.env,S=((e,t,r,n)=>{let i,a=[tn(i=e.stream)?"pipe":i,s(t.stream),s(r.stream)];if(0===n.length)return a;let o=n.reduce((e,{fd:t})=>Math.max(e,t),2);for(let e=3;e<=o;e++)a[e]="ignore";for(let{fd:e}of n)a[e]="pipe";return a})(g,y,b,v),[_,O]=yield*j.Q56((r={cwd:x,env:k,stdio:S,detached:e.options.detached??"win32"!==process.platform,shell:e.options.shell},j.E2r(t=>{let n=W.LZ(),i=tq.spawn(e.command,e.args,r);return i.on("error",r=>{t(j.fJG(t4("spawn",r,e)))}),i.on("exit",(...e)=>{W.$w(n,D.Py(e))}),i.on("spawn",()=>{t(j.PyW([i,n]))}),j.OH5(()=>{i.kill("SIGTERM")})})),j.D9k(function*([t,r]){let n=yield*W.$L(r),i=d(t,e,e.options);if(n){let[e]=yield*W.Tx(r);return 0!==e&&ei.Pe(e)?yield*j.XeO(i(c)):yield*j.rIH}return w?yield*i((e,t,n)=>c(e,t,n).pipe(j.MfU(()=>u(e,t,n)),j.hgn(W.Tx(r)))).pipe(j.XeO):yield*j.rIH})),I=t$(_.pid);_.on("exit",t=>{0!==t&&ei.Pe(t)&&((e,t)=>{if("win32"===globalThis.process.platform)return tq.exec(`taskkill /pid ${e.pid} /T /F`,()=>{});try{globalThis.process.kill(-e.pid,t)}catch{}})(_,e.options.killSignal??"SIGTERM")});let $=j.OH5(()=>{w||(_.ref(),w=!0)}),E=j.OH5(()=>(w&&(_.unref(),w=!1),$)),C=yield*j.DYE(()=>{let t=te;return(ei.Pe(_.stdin)&&(t=tG({evaluate:()=>_.stdin,onError:t=>t4("fromWritable(stdin)",t9(t),e),endOnDone:g.endOnDone,encoding:g.encoding})),tn(g.stream))?j.as(j.x6Z(tp(g.stream,t)),t):j.PyW(t)}),{all:A,stderr:T,stdout:N}=(f=_.stdout?(n=new tK.PassThrough,_.stdout.on("error",e=>n.destroy(e)),_.stdout.pipe(n),t3({evaluate:()=>n,onError:t=>t4("fromReadable(stdout)",t9(t),e)})):ta,p=_.stderr?(h=new tK.PassThrough,_.stderr.on("error",e=>h.destroy(e)),_.stderr.pipe(h),t3({evaluate:()=>h,onError:t=>t4("fromReadable(stderr)",t9(t),e)})):ta,e8(y.stream)&&(f=tf(f,y.stream)),e8(b.stream)&&(p=tf(p,b.stream)),m=td(f,p),{stdout:f,stderr:p,all:m}),{getInputFd:M,getOutputFd:P}=yield*l(e,_,v),F=j.TjK(W.$L(O),e=>!e);return tA({pid:I,exitCode:j.qIB(W.Tx(O),([t,r])=>{if(ei.Pe(t))return j.PyW(tI(t));let n=new globalThis.Error(`Process interrupted due to receipt of signal: '${r}'`);return j.fJG(t4("exitCode",n,e))}),isRunning:F,kill:t=>d(_,e,t)((e,t,r)=>c(e,t,r).pipe(j.MfU(()=>u(e,t,r)),j.hgn(W.Tx(O)))).pipe(j.NLW),stdin:C,stdout:N,stderr:T,all:A,getInputFd:M,getOutputFd:P,unref:E})}case"PipedCommand":{let{commands:t,pipeOptions:r}=rt(e),[n,...i]=t,s=[(yield*h(n))];for(let e=0;e<i.length;e++){let t=i[e],n=r[e]??{},o=a(t.options),l=tc(j.PyW(f(s[s.length-1],n.from))),c=n.to??"stdin";if("stdin"===c)s.push((yield*h(tj(t.command,t.args,{...t.options,stdin:{...o,stream:l}}))));else{let e=tF(c);if(ei.EA(e)){let r=tL(e),n=t.options.additionalFds??{};s.push((yield*h(tj(t.command,t.args,{...t.options,additionalFds:{...n,[r]:{type:"input",stream:l}}}))))}else s.push((yield*h(tj(t.command,t.args,{...t.options,stdin:{...o,stream:l}}))))}}let o=s[s.length-1],l=j.JkU(function*(){let e=[];for(let t of s)e.push((yield*t.unref));return j.jJl([...e].reverse(),e=>e,{discard:!0})});return tA({pid:o.pid,exitCode:o.exitCode,isRunning:o.isRunning,kill:o.kill,stdin:o.stdin,stdout:o.stdout,stderr:o.stderr,all:o.all,getInputFd:o.getInputFd,getOutputFd:o.getOutputFd,unref:l})}}});return e=(e,t)=>h(e).pipe(j.TjK(e=>th(t?.includeStderr===!0?e.all:e.stdout)),tc),t=(t,r)=>e(t,r).channel.pipe(ez(eY((e,t)=>j.OH5(()=>{let t="",r=!1,n=q.none(),i=j.DYE(()=>"Some"===n._tag?P.Vw(n.value):es.tv(e,{onSuccess:s,onFailure:j.ATB,onDone:e=>{if(n=q.some(e),t.length>0||r){let e=t;return t="",r=!1,j.PyW([e])}return P.Vw(e)}}));function s(e){let n=function(e){let n=[];function i(e){0===t.length?n.push(e):(n.push(t+e),t="")}for(let n=0;n<e.length;n++){let s=e[n];if(0!==s.length){let e=0,n=s.indexOf("\r"),a=s.indexOf("\n");for(r&&(0===a?(i(""),e=1,a=s.indexOf("\n",e)):i(""),r=!1);-1!==n||-1!==a;)-1===n||-1!==a&&a<n?(i(s.substring(e,a)),e=a+1,a=s.indexOf("\n",e)):s.length===n+1?(r=!0,n=-1):(i(s.substring(e,n)),e=n+(a===n+1?2:1),n=s.indexOf("\r",e),a=s.indexOf("\n",e));t+=s.substring(e,s.length-!!r)}}return J.ET(n)?n:null}(e);return null!==n?j.PyW(n):i}return i}))),ti),tT.of({spawn:h,exitCode:e=>j.P1j(j.qIB(h(e),e=>e.exitCode)),streamString:e,streamLines:t,lines:(e,r)=>tm(t(e,r)),string:(t,r)=>e1(e(t,r).channel,()=>"",(e,t)=>e+t.join(""))})}),re=X.QZ(tT,t7),rt=e=>{let t=[],r=[],n=e=>{switch(e._tag){case"StandardCommand":t.push(e);break;case"PipedCommand":n(e.left),r.push(e.options),n(e.right)}};if(n(e),0===t.length)throw Error("flattenCommand produced empty commands array");let[i,...s]=t;return{commands:[i,...s],pipeOptions:r}},rr="~effect/platform/Crypto",rn=G.kl("effect/Crypto"),ri=e=>e.toString(16).padStart(2,"0"),rs=e=>[e.subarray(0,4),e.subarray(4,6),e.subarray(6,8),e.subarray(8,10),e.subarray(10,16)].map(e=>Array.from(e,ri).join("")).join("-"),ra=0x1000000000000-1,ro=t("node:crypto"),rl=(s=(N={randomBytes:ro.randomBytes,digest:(e,t)=>j.SvU({try:()=>Uint8Array.from(ro.createHash((e=>{switch(e){case"SHA-1":return"sha1";case"SHA-256":return"sha256";case"SHA-384":return"sha384";case"SHA-512":return"sha512"}})(e)).update(t).digest()),catch:e=>et({module:"Crypto",method:"digest",_tag:"Unknown",description:"Could not compute digest",cause:e})})}).randomBytes,a=()=>{let e=s(7);return((31&e[0])*0x1000000000000+0x10000000000*e[1]+0x100000000*e[2]+0x1000000*e[3]+65536*e[4]+256*e[5]+e[6])/0x20000000000000},o=()=>Math.floor(a()*(Number.MAX_SAFE_INTEGER-Number.MIN_SAFE_INTEGER+1))+Number.MIN_SAFE_INTEGER,rn.of({[rr]:rr,randomBytes:e=>{let t,r;return j.TjK((t="randomBytes",Number.isSafeInteger(r=e)&&r>=0?j.PyW(r):j.fJG(er({module:"Crypto",method:t,description:"size must be a non-negative safe integer"}))),s)},nextDoubleUnsafe:a,nextIntUnsafe:o,digest:N.digest,random:j.OH5(()=>a()),randomBoolean:j.OH5(()=>a()>.5),randomInt:j.OH5(()=>o()),randomBetween:(e,t)=>j.OH5(()=>a()*(t-e)+e),randomIntBetween(e,t,r){let n=+(r?.halfOpen!==!0);return j.OH5(()=>{let r=Math.ceil(e),i=Math.floor(t);return Math.floor(a()*(i-r+n))+r})},randomShuffle:e=>j.OH5(()=>{let t=Array.from(e);for(let e=t.length-1;e>=1;e-=1){let r=Math.min(e,Math.floor(a()*(e+1))),n=t[e];t[e]=t[r],t[r]=n}return t}),randomUUIDv4:j.OH5(()=>{let e;return(e=s(16))[6]=15&e[6]|64,e[8]=63&e[8]|128,rs(e)}),randomUUIDv7:j.RKA(e=>{var t,r;let n;return j.PyW((t=e.currentTimeMillisUnsafe(),r=s(16),n=Math.min(Math.max(0,Math.trunc(t)),ra),r[0]=Math.floor(n/0x10000000000),r[1]=255&Math.floor(n/0x100000000),r[2]=255&Math.floor(n/0x1000000),r[3]=255&Math.floor(n/65536),r[4]=255&Math.floor(n/256),r[5]=255&n,r[6]=15&r[6]|112,r[8]=63&r[8]|128,rs(r)))})})),rc=X.Py(rn,rl),ru=t("node:fs"),rd=t("node:os"),rf=t("node:path");var rh=n.t(rf,2);let rp=e=>t=>er({module:"FileSystem",method:e,description:t.message??String(t)}),rm=(l=(0,j._r7)(ru.access,tV("FileSystem","access"),rp("access")),(e,t)=>{let r=ru.constants.F_OK;return t?.readable&&(r|=ru.constants.R_OK),t?.writable&&(r|=ru.constants.W_OK),l(e,r)}),rg=(c=(0,j._r7)(ru.cp,tV("FileSystem","copy"),rp("copy")),(e,t,r)=>c(e,t,{force:r?.overwrite??!1,preserveTimestamps:r?.preserveTimestamps??!1,recursive:!0})),ry=(u=(0,j._r7)(ru.copyFile,tV("FileSystem","copyFile"),rp("copyFile")),(e,t)=>u(e,t)),rb=(d=(0,j._r7)(ru.chmod,tV("FileSystem","chmod"),rp("chmod")),(e,t)=>d(e,t)),rv=(f=(0,j._r7)(ru.chown,tV("FileSystem","chown"),rp("chown")),(e,t,r)=>f(e,t,r)),rw=(h=(0,j._r7)(ru.glob,tV("FileSystem","glob"),rp("glob")),(e,t)=>h(e,{cwd:t?.root,exclude:t?.exclude})),rx=(p=(0,j._r7)(ru.link,tV("FileSystem","link"),rp("link")),(e,t)=>p(e,t)),rk=(m=(0,j._r7)(ru.mkdir,tV("FileSystem","makeDirectory"),rp("makeDirectory")),(e,t)=>m(e,{recursive:t?.recursive??!1,mode:t?.mode})),rS=e=>{let t=(0,j._r7)(ru.mkdtemp,tV("FileSystem",e),rp(e));return e=>j.DYE(()=>{let r=e?.prefix??"",n="string"==typeof e?.directory?rf.join(e.directory,"."):rd.tmpdir();return t(r?rf.join(n,r):n+"/")})},r_=rS("makeTempDirectory"),rO=e=>{let t=(0,j._r7)(ru.rm,tV("FileSystem",e),rp(e));return(e,r)=>t(e,{recursive:r?.recursive??!1,force:r?.force??!1})},rI=rO("remove"),r$=(g=rS("makeTempDirectoryScoped"),y=rO("makeTempDirectoryScoped"),e=>j.Q56(g(e),e=>j.QgK(y(e,{recursive:!0})))),rE=(M="open",b=(0,j._r7)(ru.open,tV("FileSystem",M),rp(M)),v=(0,j._r7)(ru.close,tV("FileSystem",M),rp(M)),(e,t)=>(0,F.Fs)(j.Q56(b(e,t?.flag??"r",t?.mode),e=>j.QgK(v(e))),j.TjK(e=>rC(tw(e),t?.flag?.startsWith("a")??!1)))),rC=(()=>{let e=e=>(0,j._r7)(ru.read,tV("FileSystem",e),rp(e)),t=e("read"),r=e("readAlloc"),n=(0,j._r7)(ru.fstat,tV("FileSystem","stat"),rp("stat")),i=(0,j._r7)(ru.ftruncate,tV("FileSystem","truncate"),rp("truncate")),s=(0,j._r7)(ru.fsync,tV("FileSystem","sync"),rp("sync")),a=e=>(0,j._r7)(ru.write,tV("FileSystem",e),rp(e)),o=a("write"),l=a("writeAll");class c{[tv];fd;append;position=BigInt(0);constructor(e,t){this[tv]=tv,this.fd=e,this.append=t}get stat(){return j.TjK(n(this.fd),rL)}get sync(){return s(this.fd)}seek(e,t){let r=ty(e);return j.OH5(()=>("start"===t?this.position=r:"current"===t&&(this.position=this.position+r),this.position))}read(e){return j.DYE(()=>{let r=this.position;return j.TjK(t(this.fd,{buffer:e,position:r}),e=>{let t=ty(e);return this.position=r+t,t})})}readAlloc(e){let t=Number(e);return j.DYE(()=>{let e=Buffer.allocUnsafeSlow(t),n=this.position;return j.TjK(r(this.fd,{buffer:e,position:n}),r=>{if(0===r)return q.none();if(this.position=n+BigInt(r),r===t)return q.some(e);let i=Buffer.allocUnsafeSlow(r);return e.copy(i,0,0,r),q.some(i)})})}truncate(e){return j.TjK(i(this.fd,e?Number(e):void 0),()=>{if(!this.append){let t=BigInt(e??0);this.position>t&&(this.position=t)}})}write(e){return j.DYE(()=>{let t=this.position;return j.TjK(o(this.fd,e,void 0,void 0,this.append?void 0:Number(t)),e=>{let r=ty(e);return this.append||(this.position=t+r),r})})}writeAllChunk(e){return j.DYE(()=>{let t=this.position;return j.qIB(l(this.fd,e,void 0,void 0,this.append?void 0:Number(t)),r=>0===r?j.fJG(et({module:"FileSystem",method:"writeAll",_tag:"WriteZero",pathOrDescriptor:this.fd,description:"write returned 0 bytes written"})):(this.append||(this.position=t+BigInt(r)),r<e.length?this.writeAllChunk(e.subarray(r)):j.rIH))})}writeAll(e){return this.writeAllChunk(e)}}return(e,t)=>new c(e,t)})(),rA=e=>{let t=rS(e);return j.D9k(function*(e){let r=yield*t(e),n=ro.randomBytes(6).toString("hex"),i=rf.join(r,e?.suffix?`${n}${e.suffix}`:n);return yield*rX(i,new Uint8Array(0)),i})},rT=rA("makeTempFile"),rN=(w=rA("makeTempFileScoped"),x=rO("makeTempFileScoped"),e=>j.Q56(w(e),e=>j.QgK(x(rf.dirname(e),{recursive:!0})))),rM=(e,t)=>j.$mh({try:()=>ru.promises.readdir(e,t),catch:t=>tV("FileSystem","readDirectory")(t,[e])}),rP=e=>j.E2r((t,r)=>{try{ru.readFile(e,{signal:r},(r,n)=>{r?t(j.fJG(tV("FileSystem","readFile")(r,[e]))):t(j.PyW(n))})}catch(e){t(j.fJG(rp("readFile")(e)))}}),rj=(k=(0,j._r7)(ru.readlink,tV("FileSystem","readLink"),rp("readLink")),e=>k(e)),rD=(S=(0,j._r7)(ru.realpath,tV("FileSystem","realPath"),rp("realPath")),e=>S(e)),rF=(_=(0,j._r7)(ru.rename,tV("FileSystem","rename"),rp("rename")),(e,t)=>_(e,t)),rL=e=>({type:e.isFile()?"File":e.isDirectory()?"Directory":e.isSymbolicLink()?"SymbolicLink":e.isBlockDevice()?"BlockDevice":e.isCharacterDevice()?"CharacterDevice":e.isFIFO()?"FIFO":e.isSocket()?"Socket":"Unknown",mtime:q.fromNullishOr(e.mtime),atime:q.fromNullishOr(e.atime),birthtime:q.fromNullishOr(e.birthtime),dev:e.dev,rdev:q.fromNullishOr(e.rdev),ino:q.fromNullishOr(e.ino),mode:e.mode,nlink:q.fromNullishOr(e.nlink),uid:q.fromNullishOr(e.uid),gid:q.fromNullishOr(e.gid),size:ty(e.size),blksize:void 0!==e.blksize?q.some(ty(e.blksize)):q.none(),blocks:q.fromNullishOr(e.blocks)}),rR=(O=(0,j._r7)(ru.stat,tV("FileSystem","stat"),rp("stat")),e=>j.TjK(O(e),rL)),rU=(I=(0,j._r7)(ru.symlink,tV("FileSystem","symlink"),rp("symlink")),(e,t)=>I(e,t)),rB=($=(0,j._r7)(ru.truncate,tV("FileSystem","truncate"),rp("truncate")),(e,t)=>$(e,void 0!==t?Number(t):void 0)),rY=(E=(0,j._r7)(ru.utimes,tV("FileSystem","utime"),rp("utime")),(e,t,r)=>E(e,t,r)),rX=(e,t,r)=>j.E2r((n,i)=>{try{ru.writeFile(e,t,{signal:i,flag:r?.flag,mode:r?.mode},t=>{t?n(j.fJG(tV("FileSystem","writeFile")(t,[e]))):n(j.rIH)})}catch(e){n(j.fJG(rp("writeFile")(e)))}}),rW=j.TjK(j.Nav(tx),e=>{let t;return t={access:rm,chmod:rb,chown:rv,copy:rg,copyFile:ry,glob:rw,link:rx,makeDirectory:rk,makeTempDirectory:r_,makeTempDirectoryScoped:r$,makeTempFile:rT,makeTempFileScoped:rN,open:rE,readDirectory:rM,readFile:rP,readLink:rj,realPath:rD,remove:rI,rename:rF,stat:rR,symlink:rU,truncate:rB,utimes:rY,watch:t=>rR(t).pipe(j.TjK(r=>e.pipe(q.flatMap(e=>e.register(t,r)),q.getOrElse(()=>{var e;let r;return ti((r=e=>j.Q56(j.OH5(()=>{let r=ru.watch(t,{recursive:!0},(t,r)=>{if(r)switch(t){case"rename":return void j.MY7(j.tvg(rR(r),{onSuccess:t=>eg(e,{_tag:"Create",path:r}),onFailure:t=>eg(e,{_tag:"Remove",path:r})}));case"change":return void ey(e,{_tag:"Update",path:r})}});return r.on("error",r=>{ev(e,P.fJ(et({module:"FileSystem",_tag:"Unknown",method:"watch",pathOrDescriptor:t,cause:r})))}),r.on("close",()=>{ew(e)}),r}),e=>j.OH5(()=>e.close())),eY((t,n)=>j.TjK(em({capacity:e?.bufferSize,strategy:e?.strategy}).pipe(j.Mim(e=>eL.U9(n,ex(e))),j.Mim(e=>j.ar0(eL.Gt(r(e),n),n))),ek))))}))),tc),writeFile:rX},tb.of({...t,[tg]:tg,exists:e=>(0,F.Fs)(t.access(e),j.as(!0),j.KuX("PlatformError",e=>"NotFound"===e.reason._tag?j.PyW(!1):j.fJG(e))),readFileString:(e,r)=>j.qIB(t.readFile(e),e=>j.SvU({try:()=>new TextDecoder(r).decode(e),catch:e=>er({module:"FileSystem",method:"readFileString",description:"invalid encoding",cause:e})})),stream:j.D9k(function*(e,r){let n=yield*t.open(e,{flag:"r"});r?.offset&&(yield*n.seek(r.offset,"start"));let i=r?.bytesToRead!==void 0?ty(r.bytesToRead):void 0,s=BigInt(0),a=ty(r?.chunkSize??65536),o=n.readAlloc(a);return ti(eW(j.PyW(j.qIB(j.DYE(()=>void 0!==i&&i<=s?P.Vw():void 0!==i&&i-s<a?n.readAlloc(i-s):o),q.match({onNone:()=>P.Vw(),onSome:e=>(s+=BigInt(e.length),j.PyW(J.of(e)))})))))},tc),sink:(e,r)=>(0,F.Fs)(t.open(e,{flag:"w",...r}),j.TjK(e=>{let t,r;return t=t=>e.writeAll(t),r=j.jJl(e=>t(e),{discard:!0}),e4(e=>e.pipe(j.qIB(r),j.i4r({disableYield:!0}),es.m8(()=>e5)))}),tt),writeFileString:(e,r,n)=>j.qIB(j.SvU({try:()=>new TextEncoder().encode(r),catch:e=>er({module:"FileSystem",method:"writeFileString",description:"could not encode string",cause:e})}),r=>t.writeFile(e,r,n))})}),rJ=X.QZ(tb)(rW),rq=t("node:url"),rK=e=>j.SvU({try:()=>rq.fileURLToPath(e),catch:e=>new Q({module:"Path",method:"fromFileUrl",cause:e})}),rV=e=>j.SvU({try:()=>rq.pathToFileURL(e),catch:e=>new Q({module:"Path",method:"toFileUrl",cause:e})});rf.posix,rf.win32;let rG=X.Py(tS)({[tk]:tk,...rh,fromFileUrl:rK,toFileUrl:rV}),rH="~effect/Stdio",rz=G.kl(rH),rQ=X.Py(rz,{[rH]:rH,...{args:j.OH5(()=>process.argv.slice(2)),stdout:e=>tG({evaluate:()=>process.stdout,onError:e=>et({module:"Stdio",method:"stdout",_tag:"Unknown",cause:e}),endOnDone:e?.endOnDone??!1}),stderr:e=>tG({evaluate:()=>process.stderr,onError:e=>et({module:"Stdio",method:"stderr",_tag:"Unknown",cause:e}),endOnDone:e?.endOnDone??!1}),stdin:t3({evaluate:()=>process.stdin,onError:e=>et({module:"Stdio",method:"stdin",_tag:"Unknown",cause:e}),closeOnDone:!1})}});var rZ=n(2302);class r0{waiters=new Set;taken=0;permits;constructor(e){this.permits=e}get free(){return this.permits-this.taken}take(e){let t=eo.DYE(()=>this.free<e?eo.E2r(r=>{if(this.free>=e)return r(t);let n=()=>{this.free<e||(this.waiters.delete(n),r(t))};return this.waiters.add(n),eo.OH5(()=>{this.waiters.delete(n)})}):(this.taken+=e,eo.PyW(e)));return t}updateTakenUnsafe(e,t){return this.taken=t(this.taken),this.waiters.size>0&&e.currentDispatcher.scheduleTask(()=>{let e=this.waiters.values(),t=e.next();for(;!1===t.done&&this.free>0;)t.value(),t=e.next()},0),this.free}updateTaken(e){return ea.R6(t=>eo.PyW(this.updateTakenUnsafe(t,e)))}resize(e){return ea.R6(t=>(this.permits=e,this.free<0||this.updateTakenUnsafe(t,e=>e),eo.rIH))}release(e){return this.updateTaken(t=>t-e)}get releaseAll(){return this.updateTaken(e=>0)}withPermits(e){return t=>eo.FcF(r=>eo.qIB(r(this.take(e)),e=>eo.r7h(r(t),()=>{this.updateTakenUnsafe(eo.Iku(),t=>t-e)},!0)))}withPermit=this.withPermits(1);withPermitsIfAvailable(e){return t=>eo.FcF(r=>this.free<e?eo.lwU:(this.taken+=e,eo.r7h(r(eo.Xx$(t)),()=>{this.updateTakenUnsafe(eo.Iku(),t=>t-e)},!0)))}}let r1={_tag:"Empty"},r2={_tag:"Closed"},r3={_A:F.D_,_E:F.D_};class r5{"~effect/RcRef"=r3;pipe(){return(0,en.tT)(this,arguments)}state=r1;semaphore=(e=>new r0(e))(1);acquire;context;scope;idleTimeToLive;constructor(e,t,r,n){this.acquire=e,this.context=t,this.scope=r,this.idleTimeToLive=n}}let r6=j.D9k(function*(e){let t=yield*j.FcF(t=>{switch(e.state._tag){case"Closed":return j.GaK;case"Acquired":return e.state.refCount++,e.state.fiber?j.as(tQ(e.state.fiber),e.state):j.PyW(e.state);case"Empty":{let r=eL.LZ();return e.semaphore.withPermits(1)(t(j.PpN(e.acquire,G.WQ(e.context,eL.HG,r))).pipe(j.TjK(t=>{let n={_tag:"Acquired",value:t,scope:r,fiber:void 0,refCount:1,invalidated:!1};return e.state=n,n})))}}}),r=yield*j.z8E,n=void 0!==e.idleTimeToLive&&rZ.MI(e.idleTimeToLive);return yield*eL.a6(r,()=>(t.refCount--,t.refCount>0)?j.rIH:void 0===e.idleTimeToLive?(e.state=r1,eL.VN(t.scope,D.rI)):t.invalidated?eL.VN(t.scope,D.rI):n?(t.fiber=j.yy4(e.idleTimeToLive).pipe(j.qIB(()=>"Acquired"===e.state._tag&&0===e.state.refCount?(e.state=r1,eL.VN(t.scope,D.rI)):j.rIH),j.yeE(j.OH5(()=>{t.fiber=void 0})),j.eJC(e.context),tZ(e.scope)),j.rIH):j.rIH),t.value});var r8=n(8861);let r9="~effect/platform/Terminal",r4="effect/platform/Terminal/QuitError";class r7 extends r8.PSP("QuitError")({_tag:r8.TcI("QuitError")}){[r4]=r4}let ne=G.kl("effect/platform/Terminal"),nt=t("node:readline"),nr=j.D9k(function*(e=ni){let t,r,n=process.stdin,i=process.stdout,s=yield*(t={acquire:j.Q56(j.OH5(()=>{let e=nt.createInterface({input:n,escapeCodeTimeout:50});return nt.emitKeypressEvents(n,e),n.isTTY&&n.setRawMode(!0),e}),e=>j.OH5(()=>{n.isTTY&&n.setRawMode(!1),e.close()}))},j.R6R(e=>{let r=e.context,n=G.Jt(r,eL.HG),i=new r5(t.acquire,r,n,t.idleTimeToLive?rZ.bN(t.idleTimeToLive):void 0);return j.as(eL.a6(n,()=>{let e="Acquired"===i.state._tag?eL.VN(i.state.scope,D.rI):j.rIH;return i.state=r2,e}),i)})),a=j.OH5(()=>i.columns??0),o=j.OH5(()=>i.rows??0),l=j.JkU(function*(){yield*r6(s);let t=yield*em(),r=(r,n)=>{let i={input:q.fromUndefinedOr(r),key:{name:n.name??"",ctrl:!!n.ctrl,meta:!!n.meta,shift:!!n.shift}};ey(t,i),e(i)&&ew(t)};return yield*j.U9h(()=>j.OH5(()=>n.off("keypress",r))),n.on("keypress",r),t});return r={columns:a,rows:o,readInput:l,readLine:j.P1j(j.qIB(r6(s),e=>j.E2r(t=>{let r=e=>t(j.PyW(e));return e.once("line",r),j.OH5(()=>e.off("line",r))}))),display:e=>j.rfi(j.E2r(t=>{i.write(e,e=>ei.uy(e)?t(j.rIH):t(j.fJG(er({module:"Terminal",method:"display",description:"Failed to write prompt to stdout",cause:e}))))}))},ne.of({...r,[r9]:r9})}),nn=X.QZ(ne,nr(ni));function ni(e){return e.key.ctrl&&("c"===e.key.name||"d"===e.key.name)}let ns=X.S5(re,X.Um(rJ,rc,rG,rQ,nn));var na=n(2978),no=n(6030);class nl extends r8.X0d()("CliFilesystemError",{cause:r8.kld(),operation:r8.QfV,path:r8.QfV,message:r8.QfV}){}class nc extends r8.X0d()("CliInputError",{code:r8.xCb(["input_read_failed","invalid_json","interactive_stdin"]),message:r8.QfV,hint:r8.QfV}){}class nu extends r8.X0d()("CliValidationError",{message:r8.QfV,hint:r8.QfV,details:r8.O31(r8.QfV)}){}class nd extends r8.X0d()("CliBuildError",{status:r8.QfV,message:r8.QfV,hint:r8.QfV,details:r8.O31(r8.QfV)}){}class nf extends r8.X0d()("CliGenerationError",{code:r8.xCb(["provider_failure","generation_timeout","malformed_output","invalid_generated_document"]),message:r8.QfV,hint:r8.QfV,details:r8.O31(r8.QfV)}){}class nh extends r8.X0d()("CliStorageError",{code:r8.xCb(["diagram_not_found","diagram_already_exists","diagram_busy","corrupt_record","unsafe_storage_entry","storage_commit_failed"]),diagramId:r8.Qrq(r8.QfV),message:r8.QfV,hint:r8.QfV}){}class np extends r8.X0d()("CliExportError",{code:r8.xCb(["format_unavailable","invalid_destination","render_failed","export_write_failed"]),format:r8.QfV,message:r8.QfV,hint:r8.QfV}){}function nm(e){return"string"==typeof e||"number"==typeof e||"symbol"==typeof e}let ng=no.ID(),ny=r8._Re(na.Ky,{errors:"all"}),nb=r8._Re(na.e5,{errors:"all"});function nv(e){return nu.make({message:"The canonical diagram document is invalid.",hint:'Use {"type":"flowchart","spec":...} or {"type":"mindmap","spec":...}.',details:e})}function nw(e){return ng(e).issues.map(e=>{var t;let r=(e.path??[]).flatMap(e=>{let t=nm(e)?e:null!==e&&"object"==typeof e&&"key"in e&&nm(e.key)?e.key:void 0;return void 0===t?[]:[t]});return`${0===(t=["spec",...r]).length?"document":t.map(e=>"number"==typeof e?`[${e}]`:String(e)).join(".")}: ${e.message}`})}let nx=j.fn("sketchi.cli.document.decodeCanonical")(function*(e){let t=function(e){if(!("object"!=typeof e||null===e||Array.isArray(e))&&"type"in e&&"spec"in e)return{type:e.type,spec:e.spec}}(e);return t?"flowchart"===t.type?{type:"flowchart",spec:yield*ny(t.spec).pipe(j.xm_(e=>nv(nw(e.issue))))}:"mindmap"===t.type?{type:"mindmap",spec:yield*nb(t.spec).pipe(j.xm_(e=>nv(nw(e.issue))))}:yield*nv(['document.type: Expected "flowchart" or "mindmap".']):yield*nv(["document: Expected an object with type and spec."])}),nk=j.fn("sketchi.cli.document.parseJson")(function*(e){let t=yield*j.SvU({try:()=>JSON.parse(e),catch:()=>nc.make({code:"invalid_json",message:"The input is not valid JSON.",hint:"Pass one complete canonical document object."})});return yield*nx(t)});function nS(e){return`${JSON.stringify(e,null,2)}
3
+ `}function n_(e){let t=e.spec.id?.trim();return t||e.spec.title.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||`sketchi-${e.type}`}function nO(e){return/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/.test(e)?j.PyW(e):j.fJG(nu.make({message:`Diagram id "${e}" is not safe for local storage.`,hint:"Use 1-128 ASCII letters, digits, dots, underscores, or hyphens; start with a letter or digit.",details:["spec.id"]}))}class nI extends G.kl()("@sketchi/cli/DiagramBuilder"){}function n$(e){let t=e.ref?.path?` (${e.ref.path})`:"";return`${e.code}${t}: ${e.message}`}function nE(e,t){let r=e.formats.find(e=>e.format===t);return r?.inline!==void 0?j.PyW(r.inline):j.fJG(nd.make({status:"missing_inline_artifact",message:`Code Mode did not return the ${t} artifact inline.`,hint:"Rebuild the document with the required offline artifact formats.",details:[t]}))}function nC(e){let t=na.Uh.safeParse(e);return t.success?j.PyW(t.data):j.fJG(nd.make({status:"invalid_scene_artifact",message:"Code Mode returned an invalid scene artifact.",hint:"Inspect the Code Mode build/export boundary.",details:t.error.issues.map(e=>e.message)}))}function nA(e){let t=na.yE.safeParse(e);return t.success?j.PyW(t.data):j.fJG(nd.make({status:"invalid_excalidraw_artifact",message:"Code Mode returned an invalid Excalidraw artifact.",hint:"Inspect the Code Mode build/export boundary.",details:t.error.issues.map(e=>e.message)}))}let nT=X.QZ(nI,j.JkU(function*(){let e=yield*na.Ov,t=yield*na.UA;return{build:j.fn("sketchi.cli.diagram.build")(function*(r){let n;if(!(n="flowchart"===r.type?yield*(0,na.XV)({spec:r.spec,options:{artifactFormats:["scene","excalidraw"],inlineArtifacts:["scene","excalidraw"]}}).pipe(j.PfK(na.Ov,e),j.PfK(na.UA,t)):yield*(0,na.r8)({spec:r.spec,options:{artifactFormats:["scene","excalidraw"],inlineArtifacts:["scene","excalidraw"]}}).pipe(j.PfK(na.Ov,e),j.PfK(na.UA,t))).ok){let e,t,r,i;return yield*(e=n.issues[0],t=e?.message??`Code Mode failed with ${n.status}.`,r=e?.hint??"Repair the document and retry.",i=n.issues.map(n$),"invalid_input"===n.status||"invalid_flowchart"===n.status||"invalid_mindmap"===n.status||"quality_failed"===n.status?nu.make({message:t,hint:r,details:i}):"storage_failed"===n.status?nh.make({code:"storage_commit_failed",message:t,hint:r}):nd.make({status:n.status,message:t,hint:r,details:i}))}let i=yield*nO(n_(r)),s=yield*nE(n.artifact,"scene").pipe(j.qIB(nC)),a=yield*nE(n.artifact,"excalidraw").pipe(j.qIB(nA));return{id:i,type:r.type,title:r.spec.title,document:r,scene:s,excalidraw:a}})}})),nN=1,nM="manifest.json",nP="document.json",nj="scene.json",nD="diagram.excalidraw",nF="diagram.png",nL="revisions";class nR extends r8.Xsx("DiagramRecordManifest")({schemaVersion:r8.uSQ(nN),id:r8.QfV,type:r8.xCb(["flowchart","mindmap"]),title:r8.QfV,revision:r8.Aiz.check(r8.yJO(0)),formats:r8.O31(r8.xCb(["scene","excalidraw","png"]))}){}function nU(e){return{id:e.manifest.id,type:e.manifest.type,title:e.manifest.title,revision:e.manifest.revision,formats:e.manifest.formats}}function nB(e){return`${String(e).padStart(6,"0")}.json`}class nY extends r8.X0d()("HeadlessPngRenderError",{cause:r8.kld(),message:r8.QfV}){}class nX extends G.kl()("@sketchi/cli/CliPngRenderer"){}let nW=X.Py(nX,{renderPng:function(e){return j.$mh({try:async()=>(await Promise.all([n.e(831),n.e(869)]).then(n.bind(n,7665))).renderPngBytes(e),catch:e=>nY.make({cause:e,message:"Unable to render the stored Excalidraw artifact as PNG."})})}});var nJ=n(3587);let nq=t("node:fs/promises");class nK extends G.kl()("@sketchi/cli/LocalFileSystem"){}function nV(e,t,r){return nl.make({cause:r,operation:e,path:t,message:`Filesystem ${e} failed for ${t}.`})}function nG(e,t){return"object"==typeof e&&null!==e&&"code"in e&&e.code===t}let nH=X.Py(nK,{makeDirectory:(e,t=!1)=>j.$mh({try:()=>(0,nq.mkdir)(e,{recursive:t}).then(()=>void 0),catch:t=>nV("make-directory",e,t)}),tryWriteText:(e,t)=>j.$mh({try:async()=>{try{let r=await (0,nq.open)(e,ru.constants.O_WRONLY|ru.constants.O_CREAT|ru.constants.O_EXCL|ru.constants.O_NOFOLLOW,384);try{await r.writeFile(t,{encoding:"utf8"}),await r.sync()}finally{await r.close()}return!0}catch(e){if(nG(e,"EEXIST"))return!1;throw e}},catch:t=>nV("write-exclusive",e,t)}),tryLinkFile:(e,t)=>j.$mh({try:async()=>{try{return await (0,nq.link)(e,t),!0}catch(e){if(nG(e,"EEXIST")||nG(e,"ENOENT"))return!1;throw e}},catch:r=>nV("link-exclusive",`${e} -> ${t}`,r)}),makeTempDirectory:(e,t)=>j.$mh({try:()=>(0,nq.mkdtemp)((0,rf.join)(e,t)),catch:t=>nV("make-temp-directory",e,t)}),list:e=>j.$mh({try:async()=>(await (0,nq.readdir)(e,{withFileTypes:!0})).map(e=>({name:e.name,kind:e.isFile()?"file":e.isDirectory()?"directory":e.isSymbolicLink()?"symbolic-link":"other"})),catch:t=>nV("read-directory",e,t)}),kind:e=>j.$mh({try:async()=>{try{let t=await (0,nq.lstat)(e);if(t.isFile())return"file";if(t.isDirectory())return"directory";if(t.isSymbolicLink())return"symbolic-link";return"other"}catch(e){if(nG(e,"ENOENT"))return"missing";if(nG(e,"ELOOP"))return"symbolic-link";throw e}},catch:t=>nV("stat",e,t)}),realPath:e=>j.$mh({try:()=>(0,nq.realpath)(e),catch:t=>nV("resolve",e,t)}),readText:e=>j.$mh({try:async()=>{let t=await (0,nq.open)(e,ru.constants.O_RDONLY|ru.constants.O_NOFOLLOW);try{return await t.readFile({encoding:"utf8"})}finally{await t.close()}},catch:t=>nV("read",e,t)}),readBytes:e=>j.$mh({try:async()=>{let t=await (0,nq.open)(e,ru.constants.O_RDONLY|ru.constants.O_NOFOLLOW);try{return new Uint8Array(await t.readFile())}finally{await t.close()}},catch:t=>nV("read",e,t)}),writeText:(e,t,r=!1)=>j.$mh({try:async()=>{let n=ru.constants.O_WRONLY|ru.constants.O_CREAT|ru.constants.O_NOFOLLOW|(r?ru.constants.O_TRUNC:ru.constants.O_EXCL),i=await (0,nq.open)(e,n,384);try{await i.writeFile(t,{encoding:"utf8"}),await i.sync()}finally{await i.close()}},catch:t=>nV("write",e,t)}),writeBytes:(e,t,r=!1)=>j.$mh({try:async()=>{let n=ru.constants.O_WRONLY|ru.constants.O_CREAT|ru.constants.O_NOFOLLOW|(r?ru.constants.O_TRUNC:ru.constants.O_EXCL),i=await (0,nq.open)(e,n,384);try{await i.writeFile(t),await i.sync()}finally{await i.close()}},catch:t=>nV("write",e,t)}),rename:(e,t)=>j.$mh({try:()=>(0,nq.rename)(e,t),catch:r=>nV("rename",`${e} -> ${t}`,r)}),tryRenameDirectory:(e,t)=>j.$mh({try:async()=>{try{return await (0,nq.rename)(e,t),!0}catch(e){if(nG(e,"EEXIST")||nG(e,"ENOTEMPTY"))return!1;if(nG(e,"EPERM"))try{if((await (0,nq.lstat)(t)).isDirectory())return!1}catch{}throw e}},catch:r=>nV("rename-exclusive-directory",`${e} -> ${t}`,r)}),removeFile:e=>j.$mh({try:async()=>{try{return await (0,nq.unlink)(e),!0}catch(e){if(nG(e,"ENOENT"))return!1;throw e}},catch:t=>nV("remove-file",e,t)}),remove:e=>j.$mh({try:()=>(0,nq.rm)(e,{recursive:!0,force:!0}),catch:t=>nV("remove",e,t)})});class nz extends G.kl()("@sketchi/cli/StorageRoot"){}class nQ extends G.kl()("@sketchi/cli/DiagramStore"){}let nZ=".locks",n0="free.",n1="owner.",n2=".owner-candidate.",n3=".json",n5="recovery",n6=".backup.",n8=`.stage.${String(process.pid)}.`,n9=nJ.ji("10 millis").pipe(nJ.jB({times:50})),n4=X.Py(nz,{path:(0,rf.join)((0,rd.homedir)(),".sketchi","diagrams")});function n7(e,t,r,n){return nh.make({code:e,message:t,hint:r,...n?{diagramId:n}:{}})}function ie(e){return Buffer.from(e,"utf8").toString("base64url")}function it(e,t){return e<t?-1:+(e>t)}function ir(e){if(!Number.isSafeInteger(e)||e<=0)return!1;try{return process.kill(e,0),!0}catch(e){return"object"==typeof e&&null!==e&&"code"in e&&"EPERM"===e.code}}function ii(e,t){return"object"==typeof e.cause&&null!==e.cause&&"code"in e.cause&&e.cause.code===t}function is(e,t){return(0,rf.join)(e,t)}function ia(e){switch(e){case"scene":return nj;case"excalidraw":return nD;case"png":return nF}}function io(e,t){return n7("unsafe_storage_entry",`Unsafe local storage entry at ${e}.`,"Replace symbolic links or special files with ordinary Sketchi record files.",t)}let il=X.QZ(nQ,j.JkU(function*(){let e=yield*nK,t=yield*nz,r=j.fn("sketchi.cli.storage.ensureOwnedDirectory")(function*(t){let r=yield*e.kind(t);if("missing"===r&&(yield*e.makeDirectory(t).pipe(j.MfU(e=>ii(e,"EEXIST")?j.rIH:j.fJG(e))),r=yield*e.kind(t)),"directory"!==r)return yield*io(t)}),n=j.fn("sketchi.cli.storage.ensureRoot")(function*(){yield*r((0,rf.dirname)(t.path)),yield*r(t.path),yield*r((0,rf.join)(t.path,nZ))}),i=j.fn("sketchi.cli.storage.assertSafeTree")(function*(t,r){for(let n of yield*e.list(t)){let e=(0,rf.join)(t,n.name);if("symbolic-link"===n.kind||"other"===n.kind)return yield*io(e,r);"directory"===n.kind&&(yield*i(e,r))}}),s=j.fn("sketchi.cli.storage.recoverStages")(function*(){for(let r of(yield*n(),[...yield*e.list(t.path)].sort((e,t)=>it(e.name,t.name)))){if(!r.name.startsWith(".stage."))continue;let n=function(e){let t=Number(e.split(".").at(-2));return Number.isSafeInteger(t)?t:void 0}(r.name);void 0!==n&&ir(n)||(yield*e.remove((0,rf.join)(t.path,r.name)))}}),a=j.fn("sketchi.cli.storage.recoverRecordTransactions")(function*(r){yield*n(),yield*s();let i=`${n6}${ie(r)}.`;for(let n of[...yield*e.list(t.path)].filter(e=>e.name.startsWith(i)).sort((e,t)=>it(e.name,t.name))){let i=(0,rf.join)(t.path,n.name),s=is(t.path,r);"missing"===(yield*e.kind(s))?yield*e.rename(i,s):yield*e.remove(i)}}),o=j.fn("sketchi.cli.storage.initializeLockDirectory")(function*(r){let n=(0,rf.join)(t.path,nZ,`${ie(r)}.lock`),i=yield*e.kind(n);if("directory"===i)return n;if("missing"!==i)return yield*io(n,r);let s=(0,rf.join)(t.path,nZ);return yield*j.jGc(e.makeTempDirectory(s,`.init.${ie(r)}.`),t=>j.JkU(function*(){let i=crypto.randomUUID();return(yield*e.writeText((0,rf.join)(t,`${n0}${i}${n3}`),nS({token:i})),(yield*e.tryRenameDirectory(t,n))||"directory"===(yield*e.kind(n)))?n:yield*io(n,r)}),t=>e.remove(t))}),l=e=>n7("diagram_busy",`Diagram "${e}" is being changed by another Sketchi process.`,"Wait for that command to finish, then retry.",e),c=j.fn("sketchi.cli.storage.readLockEntries")(function*(t,r){let n=[...yield*e.list(t)].sort((e,t)=>it(e.name,t.name)),i=[];for(let s of n){let n=(0,rf.join)(t,s.name);if("file"!==s.kind)return yield*io(n,r);let a=function(e){if(!e.startsWith(n0)||!e.endsWith(n3))return;let t=e.slice(n0.length,-n3.length).split(".");if(1!==t.length&&2!==t.length||t.some(e=>!/^[a-zA-Z0-9_-]+$/.test(e)))return;let[r,n]=t;if(r)return{token:r,...n?{releasedOwnerToken:n}:{}}}(s.name);if(a){i.push({name:s.name,path:n,state:"free",token:a.token,...a.releasedOwnerToken?{releasedOwnerToken:a.releasedOwnerToken}:{}});continue}if(s.name.startsWith(n0))return yield*io(n,r);let o=function(e){if(!e.startsWith(n2)||!e.endsWith(n3))return;let t=e.slice(n2.length,-n3.length);return/^[a-zA-Z0-9_-]+$/.test(t)?t:void 0}(s.name);if(o){i.push({name:s.name,path:n,state:"unpublished-owner",token:o});continue}if(s.name.startsWith(n2)||!s.name.startsWith(n1)||!s.name.endsWith(n3))return yield*io(n,r);let c=function(e){try{let t=JSON.parse(e);return"object"==typeof t&&null!==t&&"pid"in t&&"number"==typeof t.pid&&"token"in t&&"string"==typeof t.token&&t.token.length>0?{pid:t.pid,token:t.token}:void 0}catch{return}}((yield*e.readText(n).pipe(j.xm_(e=>ii(e,"ENOENT")?l(r):e))));if(!c)return yield*l(r);if(s.name!==`${n1}${c.token}${n3}`)return yield*io(n,r);i.push({name:s.name,path:n,token:c.token,state:ir(c.pid)?"live-owner":"stale-owner"})}return i}),u=j.fn("sketchi.cli.storage.acquireLockOnce")(function*(t){yield*n();let r=yield*o(t),i=yield*c(r,t),s=new Set(i.flatMap(e=>e.releasedOwnerToken?[e.releasedOwnerToken]:[]));if(i.some(e=>"live-owner"===e.state&&!s.has(e.token)))return yield*l(t);let a=i.find(e=>"free"===e.state)??i.find(e=>"stale-owner"===e.state);if(!a){let n=(0,rf.join)(r,`${n0}${n5}${n3}`);if(!(yield*e.tryWriteText(n,nS({token:n5}))))return yield*l(t);a={name:`${n0}${n5}${n3}`,path:n,state:"free",token:n5}}let u=crypto.randomUUID(),d=(0,rf.join)(r,`${n1}${u}${n3}`),f=(0,rf.join)(r,`${n2}${u}${n3}`);return yield*j.rfi(j.jGc(j.PyW(f),()=>j.JkU(function*(){if(yield*e.writeText(f,nS({pid:process.pid,token:u})),!(yield*e.tryLinkFile(f,d)))return yield*l(t);if(!(yield*e.removeFile(a.path).pipe(j.MfU(t=>e.removeFile(d).pipe(j.hgn(j.fJG(t)))))))return yield*e.removeFile(d),yield*l(t);for(let t of i)t.path!==a.path&&(yield*e.removeFile(t.path).pipe(j.MfU(()=>j.rIH)));return{directory:r,ownerPath:d,token:u}}),t=>e.removeFile(t).pipe(j.MfU(()=>j.rIH))))}),d=j.fn("sketchi.cli.storage.releaseLock")(function*(t,r){let n=crypto.randomUUID(),i=(0,rf.join)(r.directory,`${n0}${n}.${r.token}${n3}`),s=nS({token:n,releasedOwnerToken:r.token});if(!(yield*e.writeText(i,s).pipe(j.as(!0),j.MfU(()=>e.tryWriteText(i,s).pipe(j.qIB(t=>t?j.PyW(!0):e.kind(i).pipe(j.TjK(e=>"file"===e))),j.MfU(()=>j.PyW(!1))))))){if(yield*e.removeFile(r.ownerPath))return;return yield*n7("storage_commit_failed",`Diagram "${t}" lock ownership changed before release.`,"Retry after the active Sketchi command finishes.",t)}if(!(yield*e.removeFile(r.ownerPath).pipe(j.YWq({onFailure:()=>!0,onSuccess:e=>e}))))return yield*e.removeFile(i).pipe(j.MfU(()=>j.rIH)),yield*n7("storage_commit_failed",`Diagram "${t}" lock ownership changed before release.`,"Retry after the active Sketchi command finishes.",t)}),f=(e,t,r=!1)=>{let n;return j.jGc((n=u(e),r?n.pipe(j.L5P({schedule:n9,while:e=>"CliStorageError"===e._tag&&"diagram_busy"===e.code})):n),()=>a(e).pipe(j.hgn(t)),t=>d(e,t).pipe(j.MfU(()=>j.rIH)))},h=j.fn("sketchi.cli.storage.decodeManifest")(function*(t,r){let n=yield*e.readText(t),i=yield*j.SvU({try:()=>JSON.parse(n),catch:()=>n7("corrupt_record",`Diagram "${r}" has an invalid manifest.`,"Inspect manifest.json and restore it from a known-good backup.",r)});return yield*r8._Re(nR)(i).pipe(j.xm_(()=>n7("corrupt_record",`Diagram "${r}" has an incompatible manifest.`,`Expected manifest schema version ${String(1)}.`,r)))}),p=j.fn("sketchi.cli.storage.decodeDocument")(function*(t,r){let n=yield*e.readText(t),i=yield*j.SvU({try:()=>JSON.parse(n),catch:()=>n7("corrupt_record",`Diagram "${r}" has invalid document JSON.`,"Recover a prior canonical document from the revisions directory.",r)});return yield*nx(i).pipe(j.xm_(()=>n7("corrupt_record",`Diagram "${r}" has an invalid canonical document.`,"Recover a prior canonical document from the revisions directory.",r)))}),m=j.fn("sketchi.cli.storage.loadUnlocked")(function*(r){let n=is(t.path,r),s=yield*e.kind(n);if("missing"===s)return yield*n7("diagram_not_found",`Diagram "${r}" does not exist.`,"Run sketchi list to discover stored diagram ids.",r);if("directory"!==s)return yield*io(n,r);yield*i(n,r);let a=yield*h((0,rf.join)(n,nM),r);if(a.id!==r)return yield*n7("corrupt_record",`Diagram directory "${r}" contains manifest id "${a.id}".`,"Make the directory name and manifest id agree before retrying.",r);let o=yield*p((0,rf.join)(n,nP),r);if(a.type!==o.type||a.title!==o.spec.title)return yield*n7("corrupt_record",`Diagram "${r}" manifest does not match its canonical document.`,"Recover the canonical document and rebuild the record with sketchi edit.",r);for(let t of[nj,nD])if((yield*e.kind((0,rf.join)(n,t)))!=="file")return yield*n7("corrupt_record",`Diagram "${r}" is missing required artifact ${t}.`,"Recover the canonical document and rebuild the record with sketchi edit.",r);let l=yield*e.kind((0,rf.join)(n,nF));if("file"!==l&&"missing"!==l)return yield*io((0,rf.join)(n,nF),r);let c="file"===l?["scene","excalidraw","png"]:["scene","excalidraw"];if(a.formats.length!==c.length||a.formats.some((e,t)=>e!==c[t]))return yield*n7("corrupt_record",`Diagram "${r}" manifest formats do not match stored artifacts.`,"Recover the canonical document and rebuild the record with sketchi edit.",r);let u=(0,rf.join)(n,nL);return{manifest:a,document:o,revisions:[...yield*e.list(u)].filter(e=>"file"===e.kind&&e.name.endsWith(".json")).map(e=>e.name).sort(it)}}),g=j.fn("sketchi.cli.storage.copySafeTree")(function*(t,r,n){for(let i of yield*e.list(t)){let s=(0,rf.join)(t,i.name),a=(0,rf.join)(r,i.name);if("directory"===i.kind)yield*e.makeDirectory(a),yield*g(s,a,n);else{if("file"!==i.kind)return yield*io(s,n);let t=yield*e.readBytes(s);yield*e.writeBytes(a,t)}}}),y=j.fn("sketchi.cli.storage.writeBuilt")(function*(t,r,n){yield*e.makeDirectory((0,rf.join)(t,nL),!0),yield*e.writeText((0,rf.join)(t,nP),nS(r.document),!0),yield*e.writeText((0,rf.join)(t,nj),nS(r.scene),!0),yield*e.writeText((0,rf.join)(t,nD),nS(r.excalidraw),!0);let i=(0,rf.join)(t,nF);yield*e.remove(i),r.png&&(yield*e.writeBytes(i,r.png)),yield*e.writeText((0,rf.join)(t,nM),nS(n),!0)}),b=j.fn("sketchi.cli.storage.create")(function*(r){return yield*f(r.id,j.JkU(function*(){let n=is(t.path,r.id);if((yield*e.kind(n))!=="missing")return yield*n7("diagram_already_exists",`Diagram "${r.id}" already exists.`,"Use sketchi edit for full-document replacement.",r.id);let i=nR.make({schemaVersion:1,id:r.id,type:r.type,title:r.title,revision:1,formats:r.png?["scene","excalidraw","png"]:["scene","excalidraw"]});return yield*j.jGc(e.makeTempDirectory(t.path,n8),t=>j.JkU(function*(){return yield*y(t,r,i),yield*e.rename(t,n),{manifest:i,document:r.document,revisions:[]}}),t=>e.remove(t))}))}),v=j.fn("sketchi.cli.storage.edit")(function*(r,n){return yield*f(r,j.JkU(function*(){let i=yield*m(r);if(n.id!==r)return yield*n7("storage_commit_failed",`Edited document id "${n.id}" does not match "${r}".`,"Keep spec.id equal to the diagram id being edited.",r);let s=is(t.path,r),a=nR.make({schemaVersion:1,id:r,type:n.type,title:n.title,revision:i.manifest.revision+1,formats:n.png?["scene","excalidraw","png"]:["scene","excalidraw"]});return yield*j.jGc(e.makeTempDirectory(t.path,n8),o=>j.JkU(function*(){yield*g(s,o,r),yield*e.writeText((0,rf.join)(o,nL,nB(i.manifest.revision)),nS(i.document)),yield*y(o,n,a);let l=(0,rf.join)(t.path,`${n6}${ie(r)}.${String(process.pid)}.${crypto.randomUUID()}`);return yield*e.rename(s,l),(yield*e.rename(o,s).pipe(j.tvg({onFailure:t=>e.rename(l,s).pipe(j.tvg({onFailure:()=>j.fJG(n7("storage_commit_failed",`Atomic edit commit and rollback both failed for "${r}".`,"Retry; Sketchi will recover the backup transaction before the next operation.",r)),onSuccess:()=>j.fJG(t)})),onSuccess:()=>j.PyW(!0)})))&&(yield*e.remove(l).pipe(j.MfU(()=>j.rIH))),{manifest:a,document:n.document,revisions:[...i.revisions,nB(i.manifest.revision)].sort(it)}}),t=>e.remove(t))}))}),w=j.fn("sketchi.cli.storage.show")(e=>f(e,m(e),!0)),x=j.fn("sketchi.cli.storage.list")(function*(){yield*n(),yield*s();let r=new Set;for(let n of yield*e.list(t.path)){if("directory"===n.kind&&!n.name.startsWith(".")){r.add(n.name);continue}if(!n.name.startsWith(n6))continue;let e=function(e){try{let t=Buffer.from(e,"base64url").toString("utf8");return/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/.test(t)?t:void 0}catch{return}}(n.name.split(".")[2]??"");e&&r.add(e)}let i=[];for(let e of[...r].sort(it)){let t=yield*w(e);i.push(nU(t))}return i});return{create:b,edit:v,show:w,list:x,readExportSource:j.fn("sketchi.cli.storage.readExportSource")(function*(r,n){return yield*f(r,j.JkU(function*(){let i=yield*m(r);if(i.manifest.formats.includes(n))return{_tag:"StoredArtifact",bytes:yield*e.readBytes((0,rf.join)(is(t.path,r),ia(n)))};if("png"!==n)return yield*np.make({code:"format_unavailable",format:n,message:`Diagram "${r}" has no stored ${n} artifact.`,hint:"Edit the diagram to rebuild its local artifacts."});for(let e of["scene","excalidraw"])if(!i.manifest.formats.includes(e))return yield*np.make({code:"format_unavailable",format:e,message:`Diagram "${r}" has no stored ${e} artifact.`,hint:"Edit the diagram to rebuild its local artifacts."});let[s,a]=yield*j.Q7R([e.readBytes((0,rf.join)(is(t.path,r),ia("scene"))),e.readBytes((0,rf.join)(is(t.path,r),ia("excalidraw")))]);return{_tag:"RenderPng",scene:s,excalidraw:a}}),!0)})}})),ic=j.fn("sketchi.cli.export.writeFile")(function*(e,t){let r=yield*nK,n=yield*nz,i=(0,rf.resolve)(e),s=(0,rf.dirname)(i),a=()=>np.make({code:"export_write_failed",format:(0,rf.basename)(e),message:`Export destination directory does not exist: ${s}.`,hint:"Create the destination directory and retry."}),o=yield*r.realPath(s).pipe(j.xm_(a));if((yield*r.kind(o))!=="directory")return yield*a();let l=yield*r.realPath(n.path),c=(0,rf.join)(o,(0,rf.basename)(i)),u=(0,rf.relative)(l,c);if(""===u||!u.startsWith("..")&&!(0,rf.isAbsolute)(u))return yield*np.make({code:"invalid_destination",format:(0,rf.basename)(e),message:`Export destination is inside Sketchi's diagram storage: ${e}.`,hint:"Choose a destination outside ~/.sketchi/diagrams so the stored record remains valid."});let d=(0,rf.join)(o,`.${(0,rf.basename)(e)}.sketchi.${String(process.pid)}.${crypto.randomUUID()}`);return yield*j.jGc(j.PyW(d),n=>r.writeBytes(n,t).pipe(j.hgn(r.rename(n,c)),j.xm_(()=>np.make({code:"export_write_failed",format:(0,rf.basename)(e),message:`Unable to write export destination ${e}.`,hint:"Check the destination path and permissions, then retry."}))),e=>r.remove(e))});class iu extends G.kl()("@sketchi/cli/DiagramExporter"){}function id(){return np.make({code:"render_failed",format:"png",message:"Unable to render the stored diagram as PNG.",hint:"Verify the stored scene and Excalidraw artifacts, then retry."})}function ih(e){return j.SvU({try:()=>JSON.parse(new TextDecoder().decode(e)),catch:id})}let ip=X.QZ(iu,j.JkU(function*(){let e=yield*nQ,t=yield*nX,r=j.fn("sketchi.cli.export.renderPng")(function*(e){let r=yield*ih(e.scene),n=yield*ih(e.excalidraw),i=na.Uh.safeParse(r),s=na.yE.safeParse(n);if(!i.success||!s.success)return yield*id();let a=yield*t.renderPng({scene:i.data,excalidraw:s.data}).pipe(j.xm_(id));return a instanceof Uint8Array?a:new Uint8Array(a)});return{exportArtifact:j.fn("sketchi.cli.export.artifact")(function*(t,n){let i=yield*e.readExportSource(t,n);return"StoredArtifact"===i._tag?i.bytes:yield*r(i)})}})),im="gemini-3.1-flash-lite",ig="https://playground.sketchi.app/api/v1/generate",iy="SKETCHI_GENERATE_ENDPOINT";function ib(){return nf.make({code:"provider_failure",message:"The Sketchi generate API could not be reached.",hint:"Check your network connection and retry; generate is the only command that uses the network.",details:["transport"]})}function iv(){return nf.make({code:"malformed_output",message:"The Sketchi generate API returned an unreadable response.",hint:"Retry once; if it persists, report the prompt without secrets.",details:[]})}function iw(){return nf.make({code:"invalid_generated_document",message:"The generated diagram failed Sketchi schema or semantic validation.",hint:"Refine the prompt with concrete diagram content, then retry.",details:[]})}let ix=j.fn("sketchi.cli.generate.request")(function*(e){let t=yield*j.$mh({try:t=>globalThis.fetch(e.endpoint,{method:"POST",headers:{"content-type":"application/json","x-sketchi-client":"sketchi-cli"},body:JSON.stringify({prompt:e.prompt,type:e.type,model:e.model}),signal:t}),catch:()=>ib()}),r=yield*j.$mh({try:()=>t.text(),catch:()=>ib()});if(!t.ok)return yield*j.fJG(function(e,t){let r=function(e){try{let t=JSON.parse(e);return null!==t&&"object"==typeof t?t:{}}catch{return{}}}(t),n=r.issues?.[0],i=[`http_status:${String(e)}`];switch(r.status){case"generation_timeout":return nf.make({code:"generation_timeout",message:n?.message??"The generate API timed out.",hint:n?.hint??"Retry once; if it persists, try a shorter prompt.",details:i});case"malformed_output":return nf.make({code:"malformed_output",message:n?.message??"The generate API returned unreadable model output.",hint:n?.hint??"Retry once; if it persists, try another prompt.",details:i});case"invalid_input":case"invalid_generated_document":case"quality_failed":return nf.make({code:"invalid_generated_document",message:n?.message??"The generated diagram failed Sketchi validation.",hint:n?.hint??"Refine the prompt with concrete content, then retry.",details:i});default:return nf.make({code:"provider_failure",message:n?.message??`The Sketchi generate API responded with HTTP ${String(e)}.`,hint:n?.hint??"Retry once; if it persists, report the prompt without secrets.",details:i})}}(t.status,r));let n=function(e){let t;try{t=JSON.parse(e)}catch{return}if(null===t||"object"!=typeof t)return;let r=t;if(!0===r.ok&&r.diagram&&void 0!==r.diagram.document&&void 0!==r.diagram.scene&&void 0!==r.diagram.excalidraw)return{document:r.diagram.document,scene:r.diagram.scene,excalidraw:r.diagram.excalidraw,model:"string"==typeof r.generation?.model?r.generation.model:"",provider:"string"==typeof r.generation?.provider?r.generation.provider:"cloudflare-google-ai-studio"}}(r);return n||(yield*j.fJG(iv()))}),ik=j.fn("sketchi.cli.generate")(function*(e){var t,r;let n,i,s=yield*nQ,a=yield*ix(e),o=yield*nx(a.document).pipe(j.xm_(()=>iw())),l=yield*nO(n_(o)).pipe(j.xm_(()=>iw())),c=yield*(t=a.scene,(n=na.Uh.safeParse(t)).success?j.PyW(n.data):j.fJG(iv())),u=yield*(r=a.excalidraw,(i=na.yE.safeParse(r)).success?j.PyW(i.data):j.fJG(iv())),d={id:l,type:o.type,title:o.spec.title,document:o,scene:c,excalidraw:u};return{diagram:yield*s.create(d),model:a.model||e.model,provider:a.provider}}),iS=eo.z4N,i_=e=>ea.R6(t=>e(t.getRef(iS))),iO=(...e)=>i_(t=>eo.OH5(()=>{t.error(...e)})),iI=(...e)=>i_(t=>eo.OH5(()=>{t.log(...e)})),i$="~effect/cli/CliError";class iE extends r8.X0d(`${i$}/UnrecognizedOption`)("UnrecognizedOption",{option:r8.QfV,command:r8.lqM(r8.O31(r8.QfV)),suggestions:r8.O31(r8.QfV)}){[i$]=i$;get message(){let e=this.suggestions.length>0?`
39
4
 
40
5
  Did you mean this?
41
- ${this.suggestions.join("\n ")}`:"";return(this.command?`Unrecognized flag: ${this.option} in command ${this.command.join(" ")}`:`Unrecognized flag: ${this.option}`)+e}}class kD extends gA(`${kL}/DuplicateOption`)("DuplicateOption",{option:m5,parentCommand:m5,childCommand:m5}){[kL]=kL;get message(){return`Duplicate flag name "${this.option}" in parent command "${this.parentCommand}" and subcommand "${this.childCommand}". Parent will always claim this flag (Mode A semantics). Consider renaming one of them to avoid confusion.`}}class kR extends gA(`${kL}/MissingOption`)("MissingOption",{option:m5}){[kL]=kL;get message(){return`Missing required flag: --${this.option}`}}class kU extends gA(`${kL}/MissingArgument`)("MissingArgument",{argument:m5}){[kL]=kL;get message(){return`Missing required argument: ${this.argument}`}}class kB extends gA(`${kL}/InvalidValue`)("InvalidValue",{option:m5,value:m5,expected:m5,kind:gn([m1("flag"),m1("argument")])}){[kL]=kL;get message(){return"argument"===this.kind?`Invalid value for argument <${this.option}>: "${this.value}". Expected: ${this.expected}`:0===this.value.length?`Missing value for flag --${this.option}. Expected: ${this.expected}`:`Invalid value for flag --${this.option}: "${this.value}". Expected: ${this.expected}`}}class kq extends gA(`${kL}/UnknownSubcommand`)("UnknownSubcomand",{subcommand:m5,parent:mH(gt(m5)),suggestions:gt(m5)}){[kL]=kL;get message(){let e=this.suggestions.length>0?`
6
+ ${this.suggestions.join("\n ")}`:"";return(this.command?`Unrecognized flag: ${this.option} in command ${this.command.join(" ")}`:`Unrecognized flag: ${this.option}`)+e}}class iC extends r8.X0d(`${i$}/DuplicateOption`)("DuplicateOption",{option:r8.QfV,parentCommand:r8.QfV,childCommand:r8.QfV}){[i$]=i$;get message(){return`Duplicate flag name "${this.option}" in parent command "${this.parentCommand}" and subcommand "${this.childCommand}". Parent will always claim this flag (Mode A semantics). Consider renaming one of them to avoid confusion.`}}class iA extends r8.X0d(`${i$}/MissingOption`)("MissingOption",{option:r8.QfV}){[i$]=i$;get message(){return`Missing required flag: --${this.option}`}}class iT extends r8.X0d(`${i$}/MissingArgument`)("MissingArgument",{argument:r8.QfV}){[i$]=i$;get message(){return`Missing required argument: ${this.argument}`}}class iN extends r8.X0d(`${i$}/InvalidValue`)("InvalidValue",{option:r8.QfV,value:r8.QfV,expected:r8.QfV,kind:r8.gPz([r8.uSQ("flag"),r8.uSQ("argument")])}){[i$]=i$;get message(){return"argument"===this.kind?`Invalid value for argument <${this.option}>: "${this.value}". Expected: ${this.expected}`:0===this.value.length?`Missing value for flag --${this.option}. Expected: ${this.expected}`:`Invalid value for flag --${this.option}: "${this.value}". Expected: ${this.expected}`}}class iM extends r8.X0d(`${i$}/UnknownSubcommand`)("UnknownSubcomand",{subcommand:r8.QfV,parent:r8.lqM(r8.O31(r8.QfV)),suggestions:r8.O31(r8.QfV)}){[i$]=i$;get message(){let e=this.suggestions.length>0?`
42
7
 
43
8
  Did you mean this?
44
- ${this.suggestions.join("\n ")}`:"";return this.parent?`Unknown subcommand "${this.subcommand}" for "${this.parent.join(" ")}"${e}`:`Unknown subcommand "${this.subcommand}"${e}`}}class kK extends gA(`${kL}/UserError`)("UserError",{cause:gv()}){[kL]=kL}let kz=gn([kP,kD,kR,kU,kB,kq,kK]);class kV extends gA(`${kL}/ShowHelp`)("ShowHelp",{commandPath:gt(m5),errors:gt(kz)}){[kL]=kL;[lX]=+!!this.errors.length;[l1]=!1;get message(){return"Help requested"}}a(2532),a(3176),a(2976);let kJ=io("effect/ConfigProvider",{defaultValue:()=>(function(){var e;let t,r,n=(void 0)??{...globalThis?.process?.env,...import.meta?.env},i=false,s=function(e){let t={};for(let[r,n]of Object.entries(e)){if(void 0===n)continue;let e=r.split("_"),i=t;for(let t of e)i.children??={},i=i.children[t]??={}}return t}(n);return t={_tag:"Source",get:e=>lD(function(e,t,r,n){var i;let s=(i=t[r.map(String).join("_")],""!==i||n?i:void 0),a=function(e,t){if(0===t.length)return e;let r=e;for(let e of t)if(!(r=r?.children?.[String(e)]))return;return r}(e,r),o=a?.children?Object.keys(a.children):[];return 0===o.length?void 0===s?void 0:{_tag:"Value",value:s}:o.every(e=>kG.test(e))?{_tag:"Array",length:Math.max(...o.map(e=>parseInt(e,10)))+1,value:s}:{_tag:"Record",keys:new Set(o),value:s}}(s,n,e,i)),transform:kY},e=e=>t.get(t.transform(e)),(r=Object.create(kW)).state=t,r.load=e,r})()}),kW={...tw,toJSON:()=>({_id:"ConfigProvider"})},kY=e=>e,kG=/^(0|[1-9][0-9]*)$/,kH=gi(["true","yes","on","1","y"]),kQ=gi(["false","no","off","0","n"]),kZ=gi([...kH.literals,...kQ.literals]).pipe(gl(m8,hz({decode:e=>"true"===e||"yes"===e||"on"===e||"1"===e||"y"===e,encode:e=>e?"true":"false"}))),kX={"~effect/cli/Primitive":{_A:ec}},k0=mV(kH),k1=mV(kQ),k2=e=>"Boolean"===e._tag,k3=(e,t)=>Object.assign(Object.create(kX),{_tag:e,parse:t}),k5=(B=mJ(mY(gj(kZ.ast),{schema:kZ})),k3("Boolean",e=>aO(B(e),e=>e.message))),k4=k3("String",e=>lD(e)),k8=(()=>tJ("This option does not accept values"),e=>{switch(e._tag){case"Boolean":return"boolean";case"String":case"Redacted":return"string";case"Integer":return"integer";case"Float":return"number";case"Date":return"date";case"Path":return"path";case"Choice":return"choice";case"FileText":case"FileParse":case"FileSchema":return"file";case"KeyValuePair":return"key=value";case"None":return"none";default:return"value"}}),k6=e=>"Choice"===e._tag?e.choiceKeys:void 0,k9="~effect/cli/Param",k7="argument",Se={[k9]:{_A:ec},pipe(){return es(this,arguments)}},St=e=>"flag"===e.kind,Sr=e=>Object.assign(Object.create(Se),{_tag:"Single",...e,description:e.description??rx(),aliases:e.aliases??[],hidden:e.hidden??!1,parse:t=>e.kind===k7?Sp(e.name,e.primitiveType,t):Sm(e.name,e.primitiveType,t)}),Sn=(e,t)=>Sr({name:t,primitiveType:k4,kind:e}),Si=(e,t,r)=>{let n,i;return Sr({name:t,primitiveType:(n=new Map(r),i=r.map(([e])=>tr(e)).join(" | "),Object.assign(k3("Choice",e=>n.has(e)?lD(n.get(e)):tJ(`Expected ${i}, got ${tr(e)}`)),{choiceKeys:r.map(([e])=>e)})),kind:e})},Ss=/^-+/,Sa=el(2,(e,t)=>Sv(e,e=>Sr({...e,aliases:[...e.aliases,t.replace(Ss,"")]}))),So=el(2,(e,t)=>Sv(e,e=>Sr({...e,description:rk(t)}))),Sl=el(2,(e,t)=>Object.assign(Object.create(Se),{_tag:"Map",kind:e.kind,param:e,f:t,parse:r=>ae(e.parse(r),([e,r])=>[e,t(r)])})),Sc=(e,t)=>Object.assign(Object.create(Se),{_tag:"Transform",kind:e.kind,param:e,f:t,parse:t(e.parse)}),Su=el(2,(e,t)=>Sc(e,e=>r=>s8(e(r),([e,r])=>t(r).pipe(ae(t=>[e,t]))))),Sd=e=>{let t=sG(function*(t){let r=Sx(e);return St(r)&&k2(r.primitiveType)&&![r.name,...r.aliases].some(e=>(t.flags[e]??[]).length>0)?[t.arguments,rx()]:yield*e.parse(t).pipe(ae(([e,t])=>[e,rk(t)]),a$({MissingOption:()=>lD([t.arguments,rx()]),MissingArgument:()=>lD([t.arguments,rx()])}))});return Object.assign(Object.create(Se),{_tag:"Optional",kind:e.kind,param:e,parse:t})},Sf=el(2,(e,t)=>tk(t)?Su(Sd(e),rO({onNone:()=>t,onSome:lD})):Sl(Sd(e),rT(()=>t))),Sh=el(2,(e,t)=>Sv(e,e=>Sr({...e,typeName:t}))),Sp=sG(function*(e,t,r){if(0===r.arguments.length)return yield*new kU({argument:e});let n=r.arguments[0],i=yield*aO(t.parse(n),t=>new kB({option:e,value:n,expected:t,kind:"argument"}));return[r.arguments.slice(1),i]}),Sm=sG(function*(e,t,r){let n=r.flags[e];if(void 0===n||0===n.length)if(k2(t))return[r.arguments,!1];else return yield*new kR({option:e});let i=n[0],s=yield*aO(t.parse(i),t=>new kB({option:e,value:i,expected:t,kind:"flag"}));return[r.arguments,s]}),Sg=sG(function*(e,t,r,n){let i=[],s=n?.min??0,a=n?.max??1/0,o=0,l=r.arguments;for(;l.length>0&&o<a;){let[t,n]=yield*e.parse({flags:r.flags,arguments:l});i.push(n),l=t,o++}return o<s?yield*new kB({option:t.name,value:`${o} values`,expected:`at least ${s} value${1===s?"":"s"}`,kind:t.kind}):[l,i]}),Sy=sG(function*(e,t,r,n){let i=[],s=[t.name,...t.aliases].flatMap(e=>r.flags[e]??[]),a=s.length;if(eO(n?.min)&&a<n.min)return yield*0===a?new kR({option:t.name}):new kB({option:t.name,value:`${a} occurrences`,expected:`at least ${n.min} value${1===n.min?"":"s"}`,kind:t.kind});if(eO(n?.max)&&a>n.max)return yield*new kB({option:t.name,value:`${a} occurrences`,expected:`at most ${n.max} value${1===n.max?"":"s"}`,kind:t.kind});for(let r of s){let[,n]=yield*e.parse({flags:{[t.name]:[r]},arguments:[]});i.push(n)}return[r.arguments,i]}),Sb=(e,t)=>{switch(e._tag){case"Single":return t.Single(e);case"Map":return t.Map(e);case"Transform":return t.Transform(e);case"Optional":return t.Optional(e);case"Variadic":return t.Variadic(e)}},Sv=(e,t)=>Sb(e,{Single:e=>t(e),Map:e=>Sl(Sv(e.param,t),e.f),Transform:e=>Sc(Sv(e.param,t),e.f),Optional:e=>Sd(Sv(e.param,t)),Variadic:e=>{var r,n;let i;return r=Sv(e.param,t),n={min:rB(e.min),max:rB(e.max)},i=Sx(r),Object.assign(Object.create(Se),{_tag:"Variadic",kind:r.kind,param:r,min:rP(n?.min),max:rP(n?.max),parse:e=>"argument"===i.kind?Sg(r,i,e,n):Sy(r,i,e,n)})}}),Sw=e=>Sb(e,{Single:e=>[e],Map:e=>Sw(e.param),Transform:e=>Sw(e.param),Optional:e=>Sw(e.param),Variadic:e=>Sw(e.param)}),Sx=e=>{let t=Sw(e);if(0===t.length)throw Error("No Single param found in param structure");if(t.length>1)throw Error(`Multiple Single params found: ${t.map(e=>e.name).join(", ")}`);return t[0]},Sk=e=>Sb(e,{Single:()=>({isOptional:!1,isVariadic:!1,variadicMin:rx(),variadicMax:rx()}),Map:e=>Sk(e.param),Transform:e=>Sk(e.param),Optional:e=>({...Sk(e.param),isOptional:!0}),Variadic:e=>({...Sk(e.param),isVariadic:!0,variadicMin:e.min,variadicMax:e.max})}),SS=io("effect/cli/CliOutput",{defaultValue:()=>S_()}),S_=e=>{let t=globalThis.process,r="object"==typeof t&&null!==t,n=e?.colors!==void 0?e.colors:r&&"object"==typeof t.stdout&&null!==t.stdout&&!0===t.stdout.isTTY&&t.env?.NO_COLOR!=="1",i=n?{bold:e=>`\x1b[1m${e}\x1b[0m`,dim:e=>`\x1b[2m${e}\x1b[0m`,cyan:e=>`\x1b[36m${e}\x1b[0m`,green:e=>`\x1b[32m${e}\x1b[0m`,blue:e=>`\x1b[34m${e}\x1b[0m`,yellow:e=>`\x1b[33m${e}\x1b[0m`,magenta:e=>`\x1b[35m${e}\x1b[0m`}:{bold:e=>e,dim:e=>e,cyan:e=>e,green:e=>e,blue:e=>e,yellow:e=>e,magenta:e=>e},s=n?"\x1b[0m":"",a=n?"\x1b[31m":"",o=n?"\x1b[1m":"";return{formatHelpDoc:e=>SC(e,i),formatCliError:e=>e.message,formatError:e=>`
9
+ ${this.suggestions.join("\n ")}`:"";return this.parent?`Unknown subcommand "${this.subcommand}" for "${this.parent.join(" ")}"${e}`:`Unknown subcommand "${this.subcommand}"${e}`}}class iP extends r8.X0d(`${i$}/UserError`)("UserError",{cause:r8.kld()}){[i$]=i$}let ij=r8.gPz([iE,iC,iA,iT,iN,iM,iP]);class iD extends r8.X0d(`${i$}/ShowHelp`)("ShowHelp",{commandPath:r8.O31(r8.QfV),errors:r8.O31(ij)}){[i$]=i$;[R]=+!!this.errors.length;[B]=!1;get message(){return"Help requested"}}n(2532),n(3176),n(2976);let iF=G.Or("effect/ConfigProvider",{defaultValue:()=>(function(){var e;let t,r,n=(void 0)??{...globalThis?.process?.env,...import.meta?.env},i=false,s=function(e){let t={};for(let[r,n]of Object.entries(e)){if(void 0===n)continue;let e=r.split("_"),i=t;for(let t of e)i.children??={},i=i.children[t]??={}}return t}(n);return t={_tag:"Source",get:e=>j.PyW(function(e,t,r,n){var i;let s=(i=t[r.map(String).join("_")],""!==i||n?i:void 0),a=function(e,t){if(0===t.length)return e;let r=e;for(let e of t)if(!(r=r?.children?.[String(e)]))return;return r}(e,r),o=a?.children?Object.keys(a.children):[];return 0===o.length?void 0===s?void 0:{_tag:"Value",value:s}:o.every(e=>iU.test(e))?{_tag:"Array",length:Math.max(...o.map(e=>parseInt(e,10)))+1,value:s}:{_tag:"Record",keys:new Set(o),value:s}}(s,n,e,i)),transform:iR},e=e=>t.get(t.transform(e)),(r=Object.create(iL)).state=t,r.load=e,r})()}),iL={...ea.fU,toJSON:()=>({_id:"ConfigProvider"})},iR=e=>e,iU=/^(0|[1-9][0-9]*)$/;eo.LkF,eo.OPA;var iB=n(5348);let iY=r8.xCb(["true","yes","on","1","y"]),iX=r8.xCb(["false","no","off","0","n"]),iW=r8.xCb([...iY.literals,...iX.literals]).pipe(r8.GLL(r8.v8c,iB.pd({decode:e=>"true"===e||"yes"===e||"on"===e||"1"===e||"y"===e,encode:e=>e?"true":"false"})));var iJ=n(6470);let iq={"~effect/cli/Primitive":{_A:F.D_}},iK=r8.is(iY),iV=r8.is(iX),iG=e=>"Boolean"===e._tag,iH=(e,t)=>Object.assign(Object.create(iq),{_tag:e,parse:t}),iz=(C=r8.lHk(iW),A=r8._Re(C),iH("Boolean",e=>j.xm_(A(e),e=>e.message)));r8.wYs,r8.Aiz,r8.Nej;let iQ=iH("String",e=>j.PyW(e)),iZ=(()=>j.fJG("This option does not accept values"),e=>{switch(e._tag){case"Boolean":return"boolean";case"String":case"Redacted":return"string";case"Integer":return"integer";case"Float":return"number";case"Date":return"date";case"Path":return"path";case"Choice":return"choice";case"FileText":case"FileParse":case"FileSchema":return"file";case"KeyValuePair":return"key=value";case"None":return"none";default:return"value"}}),i0=e=>"Choice"===e._tag?e.choiceKeys:void 0,i1="~effect/cli/Param",i2="argument",i3={[i1]:{_A:F.D_},pipe(){return(0,en.tT)(this,arguments)}},i5=e=>"flag"===e.kind,i6=e=>Object.assign(Object.create(i3),{_tag:"Single",...e,description:e.description??q.none(),aliases:e.aliases??[],hidden:e.hidden??!1,parse:t=>e.kind===i2?so(e.name,e.primitiveType,t):sl(e.name,e.primitiveType,t)}),i8=(e,t)=>i6({name:t,primitiveType:iQ,kind:e}),i9=(e,t,r)=>{let n,i;return i6({name:t,primitiveType:(n=new Map(r),i=r.map(([e])=>(0,iJ.GP)(e)).join(" | "),Object.assign(iH("Choice",e=>n.has(e)?j.PyW(n.get(e)):j.fJG(`Expected ${i}, got ${(0,iJ.GP)(e)}`)),{choiceKeys:r.map(([e])=>e)})),kind:e})},i4=/^-+/,i7=(0,F.XY)(2,(e,t)=>sf(e,e=>i6({...e,aliases:[...e.aliases,t.replace(i4,"")]}))),se=(0,F.XY)(2,(e,t)=>sf(e,e=>i6({...e,description:q.some(t)}))),st=(0,F.XY)(2,(e,t)=>Object.assign(Object.create(i3),{_tag:"Map",kind:e.kind,param:e,f:t,parse:r=>j.TjK(e.parse(r),([e,r])=>[e,t(r)])})),sr=(e,t)=>Object.assign(Object.create(i3),{_tag:"Transform",kind:e.kind,param:e,f:t,parse:t(e.parse)}),sn=(0,F.XY)(2,(e,t)=>sr(e,e=>r=>j.qIB(e(r),([e,r])=>t(r).pipe(j.TjK(t=>[e,t]))))),si=e=>{let t=j.D9k(function*(t){let r=sp(e);return i5(r)&&iG(r.primitiveType)&&![r.name,...r.aliases].some(e=>(t.flags[e]??[]).length>0)?[t.arguments,q.none()]:yield*e.parse(t).pipe(j.TjK(([e,t])=>[e,q.some(t)]),j.loE({MissingOption:()=>j.PyW([t.arguments,q.none()]),MissingArgument:()=>j.PyW([t.arguments,q.none()])}))});return Object.assign(Object.create(i3),{_tag:"Optional",kind:e.kind,param:e,parse:t})},ss=(0,F.XY)(2,(e,t)=>j.yw5(t)?sn(si(e),q.match({onNone:()=>t,onSome:j.PyW})):st(si(e),q.getOrElse(()=>t))),sa=(0,F.XY)(2,(e,t)=>sf(e,e=>i6({...e,typeName:t}))),so=j.D9k(function*(e,t,r){if(0===r.arguments.length)return yield*new iT({argument:e});let n=r.arguments[0],i=yield*j.xm_(t.parse(n),t=>new iN({option:e,value:n,expected:t,kind:"argument"}));return[r.arguments.slice(1),i]}),sl=j.D9k(function*(e,t,r){let n=r.flags[e];if(void 0===n||0===n.length)if(iG(t))return[r.arguments,!1];else return yield*new iA({option:e});let i=n[0],s=yield*j.xm_(t.parse(i),t=>new iN({option:e,value:i,expected:t,kind:"flag"}));return[r.arguments,s]}),sc=j.D9k(function*(e,t,r,n){let i=[],s=n?.min??0,a=n?.max??1/0,o=0,l=r.arguments;for(;l.length>0&&o<a;){let[t,n]=yield*e.parse({flags:r.flags,arguments:l});i.push(n),l=t,o++}return o<s?yield*new iN({option:t.name,value:`${o} values`,expected:`at least ${s} value${1===s?"":"s"}`,kind:t.kind}):[l,i]}),su=j.D9k(function*(e,t,r,n){let i=[],s=[t.name,...t.aliases].flatMap(e=>r.flags[e]??[]),a=s.length;if(ei.EA(n?.min)&&a<n.min)return yield*0===a?new iA({option:t.name}):new iN({option:t.name,value:`${a} occurrences`,expected:`at least ${n.min} value${1===n.min?"":"s"}`,kind:t.kind});if(ei.EA(n?.max)&&a>n.max)return yield*new iN({option:t.name,value:`${a} occurrences`,expected:`at most ${n.max} value${1===n.max?"":"s"}`,kind:t.kind});for(let r of s){let[,n]=yield*e.parse({flags:{[t.name]:[r]},arguments:[]});i.push(n)}return[r.arguments,i]}),sd=(e,t)=>{switch(e._tag){case"Single":return t.Single(e);case"Map":return t.Map(e);case"Transform":return t.Transform(e);case"Optional":return t.Optional(e);case"Variadic":return t.Variadic(e)}},sf=(e,t)=>sd(e,{Single:e=>t(e),Map:e=>st(sf(e.param,t),e.f),Transform:e=>sr(sf(e.param,t),e.f),Optional:e=>si(sf(e.param,t)),Variadic:e=>{var r,n;let i;return r=sf(e.param,t),n={min:q.getOrUndefined(e.min),max:q.getOrUndefined(e.max)},i=sp(r),Object.assign(Object.create(i3),{_tag:"Variadic",kind:r.kind,param:r,min:q.fromUndefinedOr(n?.min),max:q.fromUndefinedOr(n?.max),parse:e=>"argument"===i.kind?sc(r,i,e,n):su(r,i,e,n)})}}),sh=e=>sd(e,{Single:e=>[e],Map:e=>sh(e.param),Transform:e=>sh(e.param),Optional:e=>sh(e.param),Variadic:e=>sh(e.param)}),sp=e=>{let t=sh(e);if(0===t.length)throw Error("No Single param found in param structure");if(t.length>1)throw Error(`Multiple Single params found: ${t.map(e=>e.name).join(", ")}`);return t[0]},sm=e=>sd(e,{Single:()=>({isOptional:!1,isVariadic:!1,variadicMin:q.none(),variadicMax:q.none()}),Map:e=>sm(e.param),Transform:e=>sm(e.param),Optional:e=>({...sm(e.param),isOptional:!0}),Variadic:e=>({...sm(e.param),isVariadic:!0,variadicMin:e.min,variadicMax:e.max})});var sg=n(3864);let sy=G.Or("effect/cli/CliOutput",{defaultValue:()=>sb()}),sb=e=>{let t=globalThis.process,r="object"==typeof t&&null!==t,n=e?.colors!==void 0?e.colors:r&&"object"==typeof t.stdout&&null!==t.stdout&&!0===t.stdout.isTTY&&t.env?.NO_COLOR!=="1",i=n?{bold:e=>`\x1b[1m${e}\x1b[0m`,dim:e=>`\x1b[2m${e}\x1b[0m`,cyan:e=>`\x1b[36m${e}\x1b[0m`,green:e=>`\x1b[32m${e}\x1b[0m`,blue:e=>`\x1b[34m${e}\x1b[0m`,yellow:e=>`\x1b[33m${e}\x1b[0m`,magenta:e=>`\x1b[35m${e}\x1b[0m`}:{bold:e=>e,dim:e=>e,cyan:e=>e,green:e=>e,blue:e=>e,yellow:e=>e,magenta:e=>e},s=n?"\x1b[0m":"",a=n?"\x1b[31m":"",o=n?"\x1b[1m":"";return{formatHelpDoc:e=>sk(e,i),formatCliError:e=>e.message,formatError:e=>`
45
10
  ${o}${a}ERROR${s}
46
11
  ${e.message}${s}`,formatErrors:e=>{if(0===e.length)return"";if(1===e.length)return`
47
12
  ${o}${a}ERROR${s}
48
13
  ${e[0].message}${s}`;let t=new Map;for(let r of e){let e=r._tag??"Error",n=t.get(e)??[];n.push(r),t.set(e,n)}let r=[];for(let[,e]of(r.push(`
49
- ${o}${a}ERRORS${s}`),t))for(let t of e)r.push(` ${t.message}${s}`);return r.join("\n")},formatVersion:(e,t)=>`${i.bold(e)} ${i.dim("v")}${i.bold(t)}`}},S$=e=>e.replace(/\u001B\[[0-9;]*m/g,"").length,SO=(e,t)=>{let r=Math.max(...e.map(e=>S$(e.left)))+4,n=void 0===t?r:Math.min(r,t);return e.map(({left:e,right:t})=>{let r;return` ${r=Math.max(0,n-S$(e)),e+" ".repeat(r)}${t}`}).join("\n")},SI=(e,t)=>t?`${e}, ${t}`:e,SC=(e,t)=>{let r=[];if(e.description&&(r.push(t.bold("DESCRIPTION")),r.push(` ${e.description}`),r.push("")),r.push(t.bold("USAGE")),r.push(` ${t.cyan(e.usage)}`),r.push(""),e.args&&e.args.length>0){r.push(t.bold("ARGUMENTS"));let n=e.args.map(e=>{let r=e.name;e.variadic&&(r+="...");let n=t.green(r),i=t.dim(e.type),s=`${n} ${i}`,a=e.required?"":t.dim(" (optional)");return{left:s,right:rT(e.description,()=>"")+a}});r.push(SO(n,25)),r.push("")}if(e.flags.length>0){r.push(t.bold("FLAGS"));let n=e.flags.map(e=>{let r=[];for(let n of(r.push(t.green(`--${e.name}`)),e.aliases))r.push(t.green(n));return{left:r.join(", ")+("boolean"!==e.type?` ${t.dim(e.type)}`:""),right:rT(e.description,()=>"")}});r.push(SO(n)),r.push("")}if(e.globalFlags&&e.globalFlags.length>0){r.push(t.bold("GLOBAL FLAGS"));let n=e.globalFlags.map(e=>{let r=[];for(let n of(r.push(t.green(`--${e.name}`)),e.aliases))r.push(t.green(n));return{left:r.join(", ")+("boolean"!==e.type?` ${t.dim(e.type)}`:""),right:rT(e.description,()=>"")}});r.push(SO(n)),r.push("")}if(e.subcommands&&e.subcommands.length>0){let n=e.subcommands.find(e=>void 0===e.group);for(let i of(n&&(r.push(t.bold("SUBCOMMANDS")),r.push(SO(n.commands.map(e=>({left:t.cyan(SI(e.name,e.alias)),right:e.shortDescription??e.description})),20)),e.subcommands.length>1&&r.push("")),e.subcommands))void 0!==i.group&&(r.push(t.bold(`${i.group}:`)),r.push(SO(i.commands.map(e=>({left:t.cyan(SI(e.name,e.alias)),right:e.shortDescription??e.description})),20)),r.push(""))}if(e.examples&&e.examples.length>0){r.push(t.bold("EXAMPLES"));let n=!0,i=!1;for(let s of e.examples)s.description?(n||r.push(""),r.push(` ${t.dim(`# ${s.description}`)}`)):i&&r.push(""),r.push(` ${t.cyan(s.command)}`),n=!1,i=!!s.description;r.push("")}return""===r[r.length-1]&&r.pop(),r.join("\n")},SE=e=>e.replace(/[^a-zA-Z0-9_]/g,"_"),SA=e=>{let t=[`--${e.name}`];for(let r of e.aliases)t.push(1===r.length?`-${r}`:`--${r}`);return"Boolean"===e.type._tag&&t.push(`--no-${e.name}`),t},ST=e=>{switch(e._tag){case"Boolean":default:return;case"Choice":return`COMPREPLY=( $(compgen -W '${e.values.join(" ")}' -- "$cur") )`;case"Path":if("directory"===e.pathType)return'COMPREPLY=( $(compgen -d -- "$cur") )';return'COMPREPLY=( $(compgen -f -- "$cur") )'}},SM=e=>{switch(e._tag){case"Choice":return`COMPREPLY=( $(compgen -W '${e.values.join(" ")}' -- "$cur") )`;case"Path":if("directory"===e.pathType)return'COMPREPLY=( $(compgen -d -- "$cur") )';return'COMPREPLY=( $(compgen -f -- "$cur") )';default:return}},SN=(e,t,r)=>{let n=[...t,e.name],i=`_${n.map(SE).join("_")}`;r.push(`${i}()`),r.push("{"),r.push(" local cur prev words cword"),r.push(" _init_completion || return"),r.push("");let s=e.flags.filter(e=>"Boolean"!==e.type._tag);if(s.length>0){for(let e of(r.push(" # Flag value completions"),r.push(' case "$prev" in'),s)){let t=[`--${e.name}`];for(let r of e.aliases)t.push(1===r.length?`-${r}`:`--${r}`);let n=ST(e.type);n&&(r.push(` ${t.join("|")})`),r.push(` ${n}`),r.push(" return"),r.push(" ;;"))}r.push(" esac"),r.push("")}if(e.subcommands.length>0){for(let t of(r.push(" # Subcommand dispatch"),r.push(" local i cmd"),r.push(" for ((i = 1; i < cword; i++)); do"),r.push(' case "${words[i]}" in'),e.subcommands)){let e=`_${[...n,t.name].map(SE).join("_")}`;r.push(` ${t.name})`),r.push(` ${e}`),r.push(" return"),r.push(" ;;")}r.push(" esac"),r.push(" done"),r.push("")}((e,t)=>{if(0===e.length)return;t.push(" # Build used-flag filter"),t.push(" local -A _flag_groups");let r=0;for(let n of e){for(let e of SA(n))t.push(` _flag_groups[${e}]=${r}`);r++}t.push(" local -A _used_groups"),t.push(" for ((i = 1; i < cword; i++)); do"),t.push(' local _g="${_flag_groups[${words[i]}]:-}"'),t.push(' [[ -n "$_g" ]] && _used_groups[$_g]=1'),t.push(" done"),t.push(' local _filtered_flags=""'),t.push(` for _f in ${e.flatMap(SA).join(" ")}; do`),t.push(' local _g="${_flag_groups[$_f]:-}"'),t.push(' [[ -z "$_g" || -z "${_used_groups[$_g]:-}" ]] && _filtered_flags+=" $_f"'),t.push(" done"),t.push("")})(e.flags,r),(e.flags.length>0||e.subcommands.length>0)&&(r.push(" # Complete flags (filtered) and subcommands"),r.push(' if [[ "$cur" == -* ]]; then'),e.flags.length>0&&r.push(' COMPREPLY=( $(compgen -W "$_filtered_flags" -- "$cur") )'),r.push(" return"),r.push(" fi"),r.push(""));let a=e.arguments.filter(e=>void 0!==SM(e.type));if(a.length>0)for(let e of(r.push(" # Positional argument completions"),a)){let t=SM(e.type);r.push(` ${t}`),r.push(" return")}else if(e.subcommands.length>0){let t=e.subcommands.map(e=>e.name);r.push(` COMPREPLY=( $(compgen -W '${t.join(" ")}' -- "$cur") )`)}for(let t of(r.push("}"),r.push(""),e.subcommands))SN(t,n,r)},Sj=e=>e.replace(/'/g,"\\'"),SF=e=>{let t=[];for(let r of e.aliases)1===r.length&&t.push(`-s ${r}`);for(let r of(t.push(e.name),e.aliases))r.length>1&&t.push(r);return"Boolean"===e.type._tag&&t.push(`no-${e.name}`),`not __fish_contains_opt ${t.join(" ")}`},SL=e=>{let t=[`-l ${e.name}`];for(let r of e.aliases)1===r.length?t.push(`-s ${r}`):t.push(`-l ${r}`);e.description&&t.push(`-d '${Sj(e.description)}'`);let r=SP(e.type);return r&&t.push(r),t},SP=e=>{switch(e._tag){case"Boolean":return;case"Choice":return`-r -f -a '${e.values.join(" ")}'`;case"Path":return e.pathType,"-r -F";default:return"-r -f"}},SD=e=>{switch(e._tag){case"Choice":return`-r -f -a '${e.values.join(" ")}'`;case"Path":return"-r -F";default:return}},SR=(e,t,r,n)=>{let i=((e,t)=>{if(0===e.length)return t.length>0?"__fish_use_subcommand":"";let r=e[e.length-1];return t.length>0?`__fish_seen_subcommand_from ${r}; and not __fish_seen_subcommand_from ${t.join(" ")}`:`__fish_seen_subcommand_from ${r}`})(r,t.subcommands.map(e=>e.name)),s=i?`-n '${i}'`:"";if(!t.arguments.some(e=>"Path"===e.type._tag)){let t=[`complete -c ${e}`];s&&t.push(s),t.push("-f"),n.push(t.join(" "))}for(let r of t.subcommands){let t=[`complete -c ${e}`];s&&t.push(s),t.push(`-f -a '${Sj(r.name)}'`),r.description&&t.push(`-d '${Sj(r.description)}'`),n.push(t.join(" "))}for(let r of t.flags){let t="Boolean"===r.type._tag,s=t?i?`${i}; and ${SF(r)}`:SF(r):i,a=s?`-n '${s}'`:"",o=[`complete -c ${e}`];if(a&&o.push(a),o.push(...SL(r)),n.push(o.join(" ")),t){let t=[`complete -c ${e}`];a&&t.push(a),t.push(`-l no-${r.name}`),r.description&&t.push(`-d '${Sj(`Disable ${r.name}`)}'`),n.push(t.join(" "))}}if(t.flags.length>0){let r='not string match -q -- "-*" (commandline -ct)',s=i?`${i}; and ${r}`:r;for(let r of t.flags){let t=`${s}; and ${SF(r)}`,i="Boolean"===r.type._tag,a=[`complete -c ${e}`];if(a.push(`-n '${t}'`),a.push(`-f -a '--${r.name}'`),r.description&&a.push(`-d '${Sj(r.description)}'`),n.push(a.join(" ")),i){let i=[`complete -c ${e}`];i.push(`-n '${t}'`),i.push(`-f -a '--no-${r.name}'`),r.description&&i.push(`-d '${Sj(`Disable ${r.name}`)}'`),n.push(i.join(" "))}}}for(let r of t.arguments){let t=SD(r.type);if(t){let i=[`complete -c ${e}`];s&&i.push(s),i.push(t),r.description&&i.push(`-d '${Sj(r.description)}'`),n.push(i.join(" "))}}for(let i of t.subcommands)SR(e,i,[...r,i.name],n)},SU=e=>e.replace(/\\/g,"\\\\").replace(/'/g,"'\\''").replace(/:/g,"\\:"),SB=e=>e.replace(/[^a-zA-Z0-9_]/g,"_"),Sq=e=>{let t=[],r=e.description?`[${SU(e.description)}]`:"",n=(e=>{switch(e._tag){case"Boolean":return"";case"Choice":return`:value:(${e.values.join(" ")})`;case"Path":return"directory"===e.pathType?":directory:_directories":":file:_files";case"Integer":return":integer:";case"Float":return":float:";case"Date":return":date:";default:return":value:"}})(e.type),i=`(${(e=>{let t=[`--${e.name}`];for(let r of e.aliases)t.push(1===r.length?`-${r}`:`--${r}`);return"Boolean"===e.type._tag&&t.push(`--no-${e.name}`),t})(e).join(" ")})`;for(let s of(t.push(`'${i}--${e.name}${r}${n}'`),e.aliases)){let e=1===s.length?"-":"--";t.push(`'${i}${e}${s}${r}${n}'`)}if("Boolean"===e.type._tag){let r=e.description?`[${SU(`Disable ${e.name}`)}]`:"";t.push(`'${i}--no-${e.name}${r}'`)}return t},SK=e=>{let t=e.description?SU(e.description):e.name,r=(e=>{switch(e._tag){case"Choice":return`(${e.values.join(" ")})`;case"Path":return"directory"===e.pathType?"_directories":"_files";default:return""}})(e.type),n=e.variadic?"*":"";return`'${n}:${t}:${r}'`},Sz=(e,t,r)=>{let n=[...t,e.name],i=`_${n.map(SB).join("_")}`;if(r.push(`${i}() {`),e.subcommands.length>0){for(let t of(r.push(" local context state state_descr line"),r.push(" typeset -A opt_args"),r.push(""),r.push(" local -a commands"),r.push(" commands=("),e.subcommands)){let e=t.description?SU(t.description):"";r.push(` '${t.name}:${e}'`)}for(let t of(r.push(" )"),r.push(""),r.push(" local -a specs"),r.push(" specs=("),e.flags))for(let e of Sq(t))r.push(` ${e}`);for(let t of e.arguments)r.push(` ${SK(t)}`);for(let t of(r.push(" '1:command:->command'"),r.push(" '*::arg:->args'"),r.push(" )"),r.push(""),r.push(' _arguments -C "${specs[@]}"'),r.push(""),r.push(' case "$state" in'),r.push(" command)"),r.push(" _describe -t commands 'commands' commands"),r.push(" ;;"),r.push(" args)"),r.push(' case "$words[1]" in'),e.subcommands)){let e=`_${[...n,t.name].map(SB).join("_")}`;r.push(` ${t.name})`),r.push(` ${e}`),r.push(" ;;")}r.push(" esac"),r.push(" ;;"),r.push(" esac")}else{let t=[];for(let r of e.flags)t.push(...Sq(r));for(let r of e.arguments)t.push(SK(r));if(t.length>0){for(let e of(r.push(" local -a specs"),r.push(" specs=("),t))r.push(` ${e}`);r.push(" )"),r.push(' _arguments "${specs[@]}"')}}for(let t of(r.push("}"),r.push(""),e.subcommands))Sz(t,n,r)},SV=e=>Sr({name:e,primitiveType:k5,kind:"flag"}),SJ=(e,t)=>Si("flag",e,t.map(e=>[e,e])),SW=el(2,(e,t)=>Sa(e,t)),SY=el(2,(e,t)=>So(e,t)),SG=el(2,(e,t)=>Sh(e,t)),SH=e=>Sd(e),SQ=el(2,(e,t)=>Sl(e,t)),SZ="~effect/cli/Command/Config/Internal",SX=e=>{let t=[],r=[],n=[];return{[SZ]:SZ,flags:r,arguments:n,orderedParams:t,tree:function e(i){let s={};for(let a in i)s[a]=function i(s){if(Array.isArray(s))return{_tag:"Array",children:s.map(e=>i(e))};if(!eT(s,k9))return{_tag:"Nested",tree:e(s)};{let e=t.length;return t.push(s),"argument"===s.kind?n.push(s):r.push(s),{_tag:"Param",index:e}}}(i[a]);return s}(e)}},S0=SX({}),S1=(e,t)=>{switch(e._tag){case"Param":return{_tag:"Param",index:e.index+t};case"Array":return{_tag:"Array",children:e.children.map(e=>S1(e,t))};case"Nested":return{_tag:"Nested",tree:S2(e.tree,t)}}},S2=(e,t)=>{let r={};for(let n in e)r[n]=S1(e[n],t);return r},S3=(e,t)=>{let r=e.orderedParams.length;return{[SZ]:SZ,flags:[...e.flags,...t.flags],arguments:[...e.arguments,...t.arguments],orderedParams:[...e.orderedParams,...t.orderedParams],tree:{...e.tree,...S2(t.tree,r)}}},S5=(e,t)=>{let r={};for(let n in e)r[n]=function e(r){switch(r._tag){case"Param":return t[r.index];case"Array":return r.children.map(t=>e(t));case"Nested":return S5(r.tree,t)}}(e[n]);return r},S4="~effect/cli/Command",S8=e=>e,S6={...nz({label:"Command",evaluate(){return S8(this).service}})},S9=e=>{let t=e.config,r=e.contextConfig??S0,n=e.service??nQ(`${S4}/${e.name}`),i=e.annotations??n5,s=e.globalFlags??[],a=e.subcommands??[],o=e.parse??_t(t),l=e.parseContext??_t(r);return Object.assign(Object.create(S6),{[S4]:S4,name:e.name,examples:e.examples??[],annotations:i,globalFlags:s,subcommands:a,hidden:e.hidden??!1,config:t,contextConfig:r,service:n,parse:o,parseContext:l,handle:(t,r)=>eO(e.handle)?e.handle(t,r):tJ(new kV({commandPath:r,errors:[]})),buildHelpDoc:r=>{let n=[],s=[];for(let e of t.arguments){let t=Sw(e),r=Sk(e);for(let e of t)n.push({name:e.name,type:e.typeName??k8(e.primitiveType),description:e.description,required:!r.isOptional,variadic:r.isVariadic})}let o=r.length>0?r.join(" "):e.name;for(let e of(a.some(e=>e.commands.some(e=>!e.hidden))&&(o+=" <subcommand>"),o+=" [flags]",n)){let t=e.variadic?`<${e.name}...>`:`<${e.name}>`;o+=` ${e.required?t:`[${t}]`}`}for(let e of t.flags)for(let t of Sw(e))t.hidden||s.push(S7(t));let l=[];for(let e of a){let t=e.commands.filter(e=>!e.hidden);0!==t.length&&l.push({group:e.group,commands:nR(t,e=>({name:e.name,alias:e.alias,shortDescription:e.shortDescription,description:e.description??""}))})}let c=e.examples??[];return{description:e.description??"",usage:o,flags:s,annotations:i,...n.length>0&&{args:n},...l.length>0&&{subcommands:l},...c.length>0&&{examples:c}}},...eO(e.description)?{description:e.description}:{},...eO(e.shortDescription)?{shortDescription:e.shortDescription}:{},...eO(e.alias)?{alias:e.alias}:{}})},S7=e=>{let t=e.aliases.map(e=>1===e.length?`-${e}`:`--${e}`);return{name:e.name,aliases:t,type:e.typeName??k8(e.primitiveType),description:_e(e.description,k6(e.primitiveType)),required:"Boolean"!==e.primitiveType._tag}},_e=(e,t)=>{if(void 0===t||0===t.length)return e;let r=`(choices: ${t.join(", ")})`;return rO(e,{onNone:()=>rk(r),onSome:e=>rk(`${e} ${r}`)})},_t=e=>sG(function*(t){let r={flags:t.flags,arguments:t.arguments},n=yield*_r(r,e.orderedParams);return S5(e.tree,n)}),_r=sG(function*(e,t){let r=[],n=e.arguments;for(let i of t){let[t,s]=yield*i.parse({flags:e.flags,arguments:n});r.push(s),n=t}return r}),_n=(e,t,r)=>{let n=S8(e),i=new Set;for(let e of(r?.contextConfig??n.contextConfig).flags)for(let t of Sw(e))i.add(t.name);for(let r of t)for(let t of S8(r).config.flags)for(let n of Sw(t))if(i.has(n.name))throw new kD({option:n.name,parentCommand:e.name,childCommand:r.name})},_i=e=>{switch(e.primitiveType._tag){case"Boolean":return{_tag:"Boolean"};case"Integer":return{_tag:"Integer"};case"Float":return{_tag:"Float"};case"Date":return{_tag:"Date"};case"Choice":return{_tag:"Choice",values:k6(e.primitiveType)??[]};case"Path":{let t=e.typeName;return{_tag:"Path",pathType:"file"===t?"file":"directory"===t?"directory":"either"}}default:return{_tag:"String"}}},_s=e=>{switch(e.primitiveType._tag){case"Integer":return{_tag:"Integer"};case"Float":return{_tag:"Float"};case"Date":return{_tag:"Date"};case"Choice":return{_tag:"Choice",values:k6(e.primitiveType)??[]};case"Path":{let t=e.typeName;return{_tag:"Path",pathType:"file"===t?"file":"directory"===t?"directory":"either"}}default:return{_tag:"String"}}},_a=e=>{let t=S8(e).config,r=[];for(let e of t.flags)for(let t of Sw(e))"flag"===t.kind&&(t.hidden||r.push({name:t.name,aliases:t.aliases,description:rB(t.description),type:_i(t)}));let n=[];for(let e of t.arguments){let t=Sw(e),r=Sk(e);for(let e of t)"argument"===e.kind&&n.push({name:e.name,description:rB(e.description),required:!r.isOptional,variadic:r.isVariadic,type:_s(e)})}let i=[];for(let t of e.subcommands)for(let e of t.commands)e.hidden||i.push(_a(e));return{name:e.name,description:e.shortDescription??e.description,flags:r,arguments:n,subcommands:i}},_o=e=>{let t=new Set,r=[];for(let n of e)t.has(n)||(t.add(n),r.push(n));return r},_l=(e,t)=>{let r=[e],n=e;for(let e=1;e<t.length;e++){let i,s=t[e];for(let e of n.subcommands)if(i=e.commands.find(e=>e.name===s))break;if(!i)break;r.push(i),n=i}return r},_c=(e,t,r)=>_o([...r,..._l(e,t).flatMap(e=>S8(e).globalFlags)]),_u=(e,t,r)=>lR(function*(){let n=_l(e,t),i=S8(n.length>0?n[n.length-1]:e).buildHelpDoc(t),s=((e,t)=>{if(e.length<=1)return[];let r=new Set(t.map(e=>e.name)),n=[];for(let t of e.slice(0,-1))for(let e of S8(t).contextConfig.flags)for(let t of Sw(e))!r.has(t.name)&&(t.hidden||(r.add(t.name),n.push(S7(t))));return n})(n,i.flags),a=_c(e,t,r),o=[];for(let e of a)for(let t of Sw(e.flag))t.hidden||o.push({...S7(t),required:!1});return{...i,flags:[...s,...i.flags],globalFlags:o}}),_d=e=>({_tag:"Action",flag:e.flag,run:e.run}),_f=0,_h=_d({flag:SV("help").pipe(SW("h"),SY("Show help information")),run:sG(function*(e,{builtIns:t,command:r,commandPath:n}){let i=yield*SS,s=yield*_u(r,n,t);yield*kF(i.formatHelpDoc(s))})}),_p=_d({flag:SV("version").pipe(SW("v"),SY("Show version information")),run:sG(function*(e,{command:t,version:r}){let n=yield*SS;yield*kF(n.formatVersion(t.name,r))})}),_m=_d({flag:SV("wizard").pipe(SY("Start wizard mode for a command")),run:()=>sK}),_g=_d({flag:SJ("completions",["bash","zsh","fish","sh"]).pipe(SH,SQ(e=>rV(e,e=>"sh"===e?"bash":e)),SG("<bash|zsh|fish|sh>"),SY("Print shell completion script")),run:sG(function*(e,{command:t}){if(r_(e))return;let r=_a(t);yield*kF(((e,t,r)=>{switch(t){case"bash":let n=[],i=SE(e);return n.push(`###-begin-${e.replace(/'/g,"'\\''")}-completions-###`),n.push("#"),n.push("# Static completion script for Bash"),n.push("#"),n.push("# Installation:"),n.push(`# ${e.replace(/'/g,"'\\''")} --completions bash >> ~/.bashrc`),n.push("#"),n.push(""),n.push("if ! type _init_completion &>/dev/null; then"),n.push(" _init_completion()"),n.push(" {"),n.push(" COMPREPLY=()"),n.push(' cur="${COMP_WORDS[COMP_CWORD]}"'),n.push(' prev="${COMP_WORDS[COMP_CWORD-1]}"'),n.push(' words=("${COMP_WORDS[@]}")'),n.push(" cword=$COMP_CWORD"),n.push(" }"),n.push("fi"),n.push(""),SN(r,[],n),n.push(`complete -F _${i} ${e.replace(/'/g,"'\\''")}`),n.push(`###-end-${e.replace(/'/g,"'\\''")}-completions-###`),n.join("\n");case"zsh":let s,a;return s=[],a=SB(e),s.push(`#compdef ${e}`),s.push(`###-begin-${e}-completions-###`),s.push("#"),s.push("# Static completion script for Zsh"),s.push("#"),s.push("# Installation:"),s.push(`# ${e} --completions zsh > ~/.zsh/completions/_${e}`),s.push("# then add ~/.zsh/completions to your fpath"),s.push("#"),s.push(""),Sz(r,[],s),s.push("# Handle both direct invocation and autoload"),s.push('if [[ "${zsh_eval_context[-1]}" == "loadautofunc" ]]; then'),s.push(` _${a} "$@"`),s.push("else"),s.push(` compdef _${a} ${e}`),s.push("fi"),s.push(`###-end-${e}-completions-###`),s.join("\n");case"fish":let o;return(o=[]).push(`###-begin-${e}-completions-###`),o.push("#"),o.push("# Static completion script for Fish"),o.push("#"),o.push("# Installation:"),o.push(`# ${e} --completions fish > ~/.config/fish/completions/${e}.fish`),o.push("#"),o.push(""),SR(e,r,[],o),o.push(""),o.push(`###-end-${e}-completions-###`),o.join("\n")}})(t.name,e.value,r))})}),_y=(q="log-level",e=>(_f+=1,Object.assign(nQ(`effect/unstable/cli/GlobalFlag/${q}/${_f}`),{_tag:"Setting",id:q,flag:e.flag})))({flag:Si("flag","log-level",[["all","All"],["trace","Trace"],["debug","Debug"],["info","Info"],["warn","Warn"],["warning","Warn"],["error","Error"],["fatal","Fatal"],["none","None"]]).pipe(SH,SY("Sets the minimum log level"),SG("<all|trace|debug|info|warn|warning|error|fatal|none>"))}),_b=[_h,_p,_m,_g,_y];class _v extends io("effect/unstable/cli/CliConfig",{defaultValue:()=>_w}){}let _w={builtIns:_b},_x=e=>{let t=[];for(let r of e)if(r.startsWith("-"))if(r.startsWith("--")){let[e,n]=r.slice(2).split("=",2);t.push({_tag:"LongOption",name:e,raw:r,value:n})}else if(r.length>1){let e=r.slice(1),n=e.indexOf("=");if(-1!==n){let r=e.slice(0,n),i=e.slice(n+1);t.push({_tag:"ShortOption",flag:r,raw:`-${r}`,value:i})}else for(let r of e)t.push({_tag:"ShortOption",flag:r,raw:`-${r}`})}else t.push({_tag:"Value",value:r});else t.push({_tag:"Value",value:r});return t},_k=(e,t)=>{let r=t.map(t=>[((e,t)=>{let r=e.length,n=t.length,i=Array.from({length:r+1},()=>Array(n+1).fill(0));for(let e=0;e<=r;e++)i[e][0]=e;for(let e=0;e<=n;e++)i[0][e]=e;for(let s=1;s<=r;s++)for(let r=1;r<=n;r++){let n=+(e[s-1]!==t[r-1]);i[s][r]=Math.min(i[s-1][r]+1,i[s][r-1]+1,i[s-1][r-1]+n)}return i[r][n]})(e,t),t]).filter(([e])=>e<=2).sort(([e],[t])=>e-t);if(0===r.length)return[];let n=r[0][0];return r.filter(([e])=>e===n).map(([,e])=>e)},_S=e=>rO(e.subcommand,{onNone:()=>[],onSome:e=>[e.name,..._S(e.parsedInput)]}),__=(e,t,r=[])=>lR(function*(){let{tokens:n,trailingOperands:i}=e,s=[...r,t.name],a=S8(t),o=a.config.flags.flatMap(Sw).filter(St),l=_O(o),c=a.contextConfig.flags.flatMap(Sw).filter(St),u=_O(c),d=new Set(c.map(e=>e.name)),f=_B(n,{command:t,commandPath:s,flagRegistry:l,inheritedFlagRegistry:u,localFlagNames:o.filter(e=>!d.has(e.name)).map(e=>e.name)});if("Leaf"===f._tag)return{flags:f.flags,arguments:[...f.arguments,...i],subcommand:rx(),...f.errors.length>0&&{errors:f.errors}};let h={tokens:f.childTokens,trailingOperands:[]},p=yield*__(h,f.sub,s),m=[...f.errors,...p.errors??[]];return{flags:f.flags,arguments:i,subcommand:rk({name:f.sub.name,parsedInput:p}),...m.length>0&&{errors:m}}}),_$=e=>{let t=0;return{peek:()=>e[t],take:()=>e[t++],rest:()=>e.slice(t)}},_O=e=>{let t=new Map;for(let r of e){if(t.has(r.name))throw Error(`Duplicate flag name "${r.name}" in command definition`);for(let e of(t.set(r.name,r),r.aliases)){if(t.has(e))throw Error(`Duplicate flag/alias "${e}" in command definition (conflicts with "${t.get(e).name}")`);t.set(e,r)}}return{params:e,index:t}},_I=e=>{let t=new Map,r=(e,r)=>{let n=t.get(e);if(n&&n!==r)throw Error(`Duplicate subcommand name/alias "${e}" in command definition (conflicts with "${n.name}")`);t.set(e,r)};for(let t of e)for(let e of t.commands)r(e.name,e),e.alias&&e.alias!==e.name&&r(e.alias,e);return t},_C=e=>Object.fromEntries(e.map(e=>[e.name,[]])),_E=e=>"LongOption"===e._tag||"ShortOption"===e._tag,_A=e=>"LongOption"===e._tag?e.name:e.flag,_T=(e,t)=>{let r=_A(e),n=t.index.get(r);if(n&&n.name===r)return{param:n,negated:!1};if("LongOption"===e._tag&&e.name.startsWith("no-")){let r=e.name.slice(3),n=t.index.get(r);if(n&&n.name===r&&k2(n.primitiveType))return{param:n,negated:!0}}if(n)return{param:n,negated:!1}},_M=(e,t,r)=>new kB({option:t.name,value:r,expected:`omit the value and use ${e.raw} by itself to set --${t.name} to false`,kind:"flag"}),_N=e=>e?._tag==="Value"&&(k0(e.value)||k1(e.value))?e.value:void 0,_j=(e,t,r,n=!1)=>{let i=_F(e,t,r,n);switch(i._tag){case"Value":return{_tag:"Value",value:i.value};case"Error":return{_tag:"Error",error:i.error}}},_F=(e,t,r,n=!1)=>{let i;if(n){if(void 0!==t.value)return{_tag:"Error",error:_M(t,r,t.value),tokens:[]};let n=_N(e.peek());if(void 0!==n){let i=e.take();return{_tag:"Error",error:_M(t,r,n),tokens:void 0===i?[]:[i]}}return{_tag:"Value",value:"false",tokens:[]}}if(void 0!==t.value)return{_tag:"Value",value:t.value,tokens:[]};if(k2(r.primitiveType)){let t=_N(e.peek()),r=void 0!==t?e.take():void 0;return{_tag:"Value",value:t??"true",tokens:void 0===r?[]:[r]}}let s=e.peek();if(s?._tag==="Value"){let t=e.take();return{_tag:"Value",value:s.value,tokens:void 0===t?[]:[t]}}return{_tag:"Error",error:(i=k6(r.primitiveType),new kB({option:r.name,value:"",expected:void 0===i?r.typeName??k8(r.primitiveType):i.join(" | "),kind:"flag"})),tokens:[]}},_L=(e,t)=>{for(let r of t){let t=_T(e,r);if(void 0!==t)return t}},_P=(e,t,r,n)=>{e.push(r);let i=_F(t,r,n.param,n.negated);e.push(...i.tokens)},_D=(e,t,r,n,i)=>{let s=_$(t);_F(s,e,r.param,r.negated);for(let e=s.take();e;e=s.take()){if(_E(e)){let t=_L(e,i);void 0!==t&&_F(s,e,t.param,t.negated);continue}if("Value"===e._tag)return n.has(e.value)}return!1},_R=(e,t,r,n)=>{let{commandPath:i,flagRegistry:s}=r,a=_T(e,s);if(!a)return void n.errors.push(((e,t,r)=>{let n="LongOption"===e._tag?`--${e.name}`:`-${e.flag}`,i=[];for(let e of t)if(!e.hidden)for(let t of(i.push(e.name),k2(e.primitiveType)&&i.push(`no-${e.name}`),e.aliases))i.push(t);return new kP({option:n,suggestions:_k(_A(e),i).map(e=>1===e.length?`-${e}`:`--${e}`),command:r})})(e,s.params,i));let o=_j(t,e,a.param,a.negated);"Error"===o._tag?n.errors.push(o.error):n.flags.add(a.param.name,o.value)},_U=(e,t,r,n)=>{if("AwaitingFirstValue"===n.mode._tag){let i=((e,t,r,n)=>{let{command:i,commandPath:s,inheritedFlagRegistry:a,localFlagNames:o}=r,l=_I(i.subcommands),c=l.get(e);if(c){let e=[...s,c.name],r=n.flags.snapshot();for(let t of o){let i=r[t];void 0!==i&&i.length>0&&n.errors.push(new kP({option:`--${t}`,suggestions:[],command:e}))}let i=((e,t)=>{let r=_C(t.params),n=[],i=[],s=_$(e);for(let e=s.take();e;e=s.take()){if(!_E(e)){n.push(e);continue}let a=_T(e,t);if(!a){n.push(e);continue}let o=_j(s,e,a.param,a.negated);if("Error"===o._tag){i.push(o.error);continue}void 0!==o.value&&r[a.param.name].push(o.value)}return{flagMap:r,remainder:n,errors:i}})(t.rest(),a);return n.flags.merge(i.flagMap),n.errors.push(...i.errors),{_tag:"Subcommand",result:{_tag:"Sub",flags:n.flags.snapshot(),sub:c,childTokens:i.remainder,errors:n.errors}}}if(!(S8(i).config.arguments.length>0)&&l.size>0){let t=[];for(let[e,r]of l)r.hidden||t.push(e);let r=_k(e,t);n.errors.push(new kq({subcommand:e,parent:s,suggestions:r}))}return{_tag:"Argument"}})(e,t,r,n);if("Subcommand"===i._tag)return i.result;n.mode={_tag:"CollectingArguments"}}n.arguments.push(e)},_B=(e,t)=>{let r,n=_$(e),i={flags:(r=_C(t.flagRegistry.params),{add:(e,t)=>{void 0!==t&&r[e].push(t)},merge:e=>{for(let t in e){let n=e[t];if(n?.length)for(let e=0;e<n.length;e++)r[t].push(n[e])}},snapshot:()=>r}),arguments:[],errors:[],mode:{_tag:"AwaitingFirstValue"}};for(let e=n.take();e;e=n.take()){if(_E(e)){_R(e,n,t,i);continue}if("Value"===e._tag){let r=_U(e.value,n,t,i);if(r)return r}}return{_tag:"Leaf",flags:i.flags.snapshot(),arguments:i.arguments,errors:i.errors}},_q=new WeakMap,_K="~effect/data/Redacted",_z=(e,t)=>{let r=Object.create(_V);return t?.label&&(r.label=t.label),_q.set(r,e),r},_V={[_K]:{_A:e=>e},label:void 0,...tw,toJSON(){return this.toString()},toString(){return`<redacted${ev(this.label)?":"+this.label:""}>`},[ej](){return eF(_q.get(this))},[eQ](e){return eT(e,_K)&&eZ(_q.get(this),_q.get(e))}},_J=e=>{if(_q.has(e))return _q.get(e);throw Error("Unable to get redacted value"+(e.label?` with label: "${e.label}"`:""))},_W=el(2,(e,t)=>{let r=Math.pow(10,t);return Math.round(e*r)/r}),_Y=(e,...t)=>{let r=t.flat();return`${r.join("")}${e}`},_G={arrowUp:"↑",arrowDown:"↓",arrowLeft:"←",arrowRight:"→",radioOn:"◉",radioOff:"◯",checkboxOn:"☒",checkboxOff:"☐",tick:"✔",cross:"✖",ellipsis:"…",pointerSmall:"›",line:"─",pointer:"❯"},_H={arrowUp:_G.arrowUp,arrowDown:_G.arrowDown,arrowLeft:_G.arrowLeft,arrowRight:_G.arrowRight,radioOn:"(*)",radioOff:"( )",checkboxOn:"[*]",checkboxOff:"[ ]",tick:"√",cross:"×",ellipsis:"...",pointerSmall:"»",line:"─",pointer:">"},_Q=ae(sL(()=>"win32"===process.platform),e=>e?_H:_G),_Z=e=>_Y(e,"\x1b[1m"),_X=e=>_Y(e,((...e)=>e)("\x1b[3m","\x1b[31m")),_0=e=>{let t={initial:!1,...e,label:{confirm:"yes",deny:"no",...e.label},placeholder:{defaultConfirm:"(Y/n)",defaultDeny:"(y/N)",...e.placeholder}};return _1({value:t.initial},{render:$u(t),process:e=>$h(e,t.initial),clear:$a(t)})},_1=(e,...t)=>{let[r,n]=1===t.length?[void 0,t[0]]:[t[0],t[1]],i=Object.create(_7);return i._tag="Loop",i.initialState=e,i.render=n.render,i.process=n.process,i.clear=n.clear,i.events=r,i},_2=el(2,(e,t)=>{let r=Object.create(_7);return r._tag="OnSuccess",r.prompt=e,r.onSuccess=t,r}),_3=e=>{let t={default:0,min:-1/0,max:1/0,incrementBy:1,decrementBy:1,validate:e=>e<t.min?tJ(`${e} must be greater than or equal to ${t.min}`):e>t.max?tJ(`${e} must be less than or equal to ${t.max}`):lD(e),...e},r=void 0===e.default?"":`${t.default}`;return _1({cursor:r.length,value:r,error:rx()},{render:$U(t),process:$B(t),clear:$N(t)})},_5=el(2,(e,t)=>_2(e,e=>_6(t(e)))),_4=sG(function*(e){let t=yield*gU,r=yield*t.readInput;return yield*$e(e,t,r)},aO(()=>new gR({})),lK),_8=e=>{let t={maxPerPage:10,...e};return _1((e=>{let t=0,r=-1;for(let t=0;t<e.length;t++)if(!0===e[t].selected){if(-1!==r)throw Error("InvalidArgumentException: only a single choice can be selected by default for Prompt.select");r=t}return -1!==r&&(t=r),t})(t.choices),{render:$Y(t),process:$H(t),clear:$G(t)})},_6=e=>{let t=Object.create(_7);return t._tag="Succeed",t.value=e,t},_9=e=>{let t={initial:!1,active:"on",inactive:"off",...e};return _1(t.initial,{render:Or(t),process:On,clear:()=>$4(t)})},_7={...nz({label:"Prompt",evaluate(){return _4(this)}}),"~effect/cli/Prompt":{_Output:e=>e}},$e=(e,t,r)=>sP(()=>{switch(e._tag){case"Loop":return $t(e,t,r);case"OnSuccess":return s8($e(e.prompt,t,r),n=>$e(e.onSuccess(n),t,r));case"Succeed":return lD(e.value)}}),$t=sG(function*(e,t,r){let n=tk(e.initialState)?yield*e.initialState:e.initialState,i=$r.NextFrame({state:n});for(;;){let s=yield*e.render(n,i);if(yield*lq(t.display(s)),e.events){let t=cw(r).pipe(ae(e=>({_tag:"Input",input:e}))),s=yield*s4(t,cw(e.events).pipe(ae(e=>({_tag:"Event",value:e}))));i=yield*e.process(s,n)}else{let t=yield*cw(r);i=yield*e.process(t,n)}switch(i._tag){case"Beep":continue;case"NextFrame":yield*lq(t.display((yield*e.clear(n,i)))),n=i.state;continue;case"Submit":{yield*lq(t.display((yield*e.clear(n,i))));let r=yield*e.render(n,i);return yield*lq(t.display(r)),i.value}}}},(e,t,r)=>aZ(e,lq(r.display("\x1b[?25h")))),$r=new Proxy({},{get:(e,t,r)=>"$is"===t?eM:"$match"===t?l4:e=>({...e,_tag:t})}),$n=(e,t)=>{if(0===t){var r;return"\x1b[2K"+(void 0===r?`\x1b${Math.max(1,0)} G`:`\x1b${r+1};${Math.max(1,0)} H`)}let n=0;for(let r of e.split($s))n+=1+Math.floor(Math.max(r.length-1,0)/t);var i=n;let s="";for(let e=0;e<i;e++)s+="\x1b[2K"+(e<i-1?"\x1b[1A":"");return i>0&&(s+="\x1b[G"),s},$i=(e,t,r)=>{if(void 0!==r&&r.length>0){let n;return((e=1)=>`\x1b[${e}B`)((n=r.split($s),0===t?n.length:em(nR(n,e=>Math.ceil(e.length/t)),nq(0,(e,t)=>e+t))))+$n(`
50
- ${r}`,t)+$n(e,t)}return $n(e,t)},$s=/\r?\n/,$a=e=>sG(function*(t,r){let n=yield*gU,i=yield*n.columns,s=yield*_Q;return $n($o(t.value?e.placeholder.defaultConfirm:e.placeholder.defaultDeny,"?",s.pointerSmall,e,{plain:!0}),i)+"\x1b[2K\x1b[G"}),$o=(e,t,r,n,i)=>$T(e,n.message,t,r,i),$l=sG(function*(e,t){let r=yield*_Q,n=_Y("?","\x1b[96m"),i=_Y(r.pointerSmall,"\x1b[90m");return"\x1b[?25l"+$o(_Y(e.value?t.placeholder.defaultConfirm:t.placeholder.defaultDeny,"\x1b[90m"),n,i,t)}),$c=sG(function*(e,t){let r=yield*_Q,n=_Y(r.tick,"\x1b[32m"),i=_Y(r.ellipsis,"\x1b[90m");return $o(e?t.label.confirm:t.label.deny,n,i,t)+"\n"}),$u=e=>(t,r)=>$r.$match(r,{Beep:()=>lD("\x07"),NextFrame:({state:t})=>$l(t,e),Submit:({value:t})=>$c(t,e)}),$d=/^y|t$/,$f=/^n|f$/,$h=(e,t)=>{let r=rT(e.input,()=>"");return"enter"===e.key.name||"return"===e.key.name?lD($r.Submit({value:t})):$d.test(r.toLowerCase())?lD($r.Submit({value:!0})):$f.test(r.toLowerCase())?lD($r.Submit({value:!1})):lD($r.Beep())},$p=(e,t=!1)=>nq(e.dateParts,"",(r,n,i)=>{let s=n.toString();return i!==e.cursor||t?r+s:r+_Y(s,((...e)=>e)("\x1b[4m","\x1b[96m"))}),$m=(e,t,r,n,i)=>$T(r,n.message,e,t,i),$g=sG(function*(e,t){let r=yield*_Q;return"\x1b[?25l"+$m(_Y("?","\x1b[96m"),_Y(r.pointerSmall,"\x1b[90m"),$p(e),t)+((e,t)=>{if(r$(e.error)){let r=e.error.value.split($s);if(nA(r))return"\x1b[s\n"+(_Y(t,"\x1b[31m")+" ")+nR(r,e=>_X(e)).join("\n")+"\x1b[u"}return""})(e,r.pointerSmall)}),$y=sG(function*(e,t){let r=yield*_Q;return $m(_Y(r.tick,"\x1b[32m"),_Y(r.ellipsis,"\x1b[90m"),$p(e,!0),t)+"\n"}),$b={months:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],weekdays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],weekdaysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]},$v=/\\(.)|"((?:\\["\\]|[^"])+)"|(D[Do]?|d{3,4}|d)|(M{1,4})|(YY(?:YY)?)|([aA])|([Hh]{1,2})|(m{1,2})|(s{1,2})|(S{1,4})|./g,$w={1:({token:e,...t})=>new $k({token:e.replace(/\\(.)/g,"$1"),...t}),2:e=>new $I(e),3:e=>new $C(e),4:e=>new $E(e),5:e=>new $A(e),6:e=>new $O(e),7:e=>new $$(e),8:e=>new $_(e),9:e=>new $S(e)};class $x{token;date;parts;locales;constructor(e){this.token=e.token,this.locales=e.locales,this.date=e.date||new Date,this.parts=e.parts||[this]}isToken(){return!1}nextPart(){let e=rT(nM(this.parts,e=>e===this),()=>0);return ny(this.parts.slice(e+1),e=>!e.isToken())}previousPart(){let e=nM(this.parts,e=>e===this);return r$(e)?nN(this.parts.slice(0,e.value),e=>!e.isToken()):rx()}toString(){return String(this.date)}}class $k extends $x{increment(){}decrement(){}setValue(e){this.token=this.token+e}isToken(){return!0}toString(){return this.token}}class $S extends $x{increment(){this.date.setMilliseconds(this.date.getMilliseconds()+1)}decrement(){this.date.setMilliseconds(this.date.getMilliseconds()-1)}setValue(e){this.date.setMilliseconds(Number.parseInt(e.slice(-this.token.length)))}toString(){return`${this.date.getMilliseconds()}`.padStart(4,"0").substring(0,this.token.length)}}class $_ extends $x{increment(){this.date.setSeconds(this.date.getSeconds()+1)}decrement(){this.date.setSeconds(this.date.getSeconds()-1)}setValue(e){this.date.setSeconds(Number.parseInt(e.slice(-2)))}toString(){let e=`${this.date.getSeconds()}`;return this.token.length>1?e.padStart(2,"0"):e}}class $$ extends $x{increment(){this.date.setMinutes(this.date.getMinutes()+1)}decrement(){this.date.setMinutes(this.date.getMinutes()-1)}setValue(e){this.date.setMinutes(Number.parseInt(e.slice(-2)))}toString(){let e=`${this.date.getMinutes()}`;return this.token.length>1?e.padStart(2,"0"):e}}class $O extends $x{increment(){this.date.setHours(this.date.getHours()+1)}decrement(){this.date.setHours(this.date.getHours()-1)}setValue(e){this.date.setHours(Number.parseInt(e.slice(-2)))}toString(){let e=/h/.test(this.token)?this.date.getHours()%12||12:this.date.getHours();return this.token.length>1?`${e}`.padStart(2,"0"):`${e}`}}class $I extends $x{increment(){this.date.setDate(this.date.getDate()+1)}decrement(){this.date.setDate(this.date.getDate()-1)}setValue(e){this.date.setDate(Number.parseInt(e.slice(-2)))}toString(){let e=this.date.getDate(),t=this.date.getDay();switch(this.token){case"DD":return`${e}`.padStart(2,"0");case"Do":return`${e}${this.ordinalIndicator(e)}`;case"d":return`${t+1}`;case"ddd":return this.locales.weekdaysShort[t];case"dddd":return this.locales.weekdays[t];default:return`${e}`}}ordinalIndicator(e){switch(e%10){case 1:return"st";case 2:return"nd";case 3:return"rd";default:return"th"}}}class $C extends $x{increment(){this.date.setMonth(this.date.getMonth()+1)}decrement(){this.date.setMonth(this.date.getMonth()-1)}setValue(e){let t=Number.parseInt(e.slice(-2))-1;this.date.setMonth(t<0?0:t)}toString(){let e=this.date.getMonth();switch(this.token.length){case 2:return`${e+1}`.padStart(2,"0");case 3:return this.locales.monthsShort[e];case 4:return this.locales.months[e];default:return`${e+1}`}}}class $E extends $x{increment(){this.date.setFullYear(this.date.getFullYear()+1)}decrement(){this.date.setFullYear(this.date.getFullYear()-1)}setValue(e){this.date.setFullYear(Number.parseInt(e.slice(-4)))}toString(){let e=`${this.date.getFullYear()}`.padStart(4,"0");return 2===this.token.length?e.substring(-2):e}}class $A extends $x{increment(){this.date.setHours((this.date.getHours()+12)%24)}decrement(){this.increment()}setValue(e){}toString(){let e=this.date.getHours()>12?"pm":"am";return/A/.test(this.token)?e.toUpperCase():e}}let $T=(e,t,r,n,i)=>{let s=r+" ",a=i?.plain===!0?e=>e:_Z;return nI(t.split($s),{onEmpty:()=>s+" "+n+" "+e,onNonEmpty:t=>s+nR(t,e=>a(e)).join("\n")+" "+n+" "+e})},$M=(e,t,r)=>!e.disabled&&e.description&&t?r?.plain===!0?"- "+e.description:_Y("- "+e.description,"\x1b[90m"):"",$N=e=>sG(function*(t,r){let n=yield*gU,i=yield*n.columns,s=yield*_Q,a=$j(t,s.pointerSmall,{plain:!0});return $i($F(t,"?",s.pointerSmall,e,{plain:!0}),i,a)+"\x1b[2K\x1b[G"}),$j=(e,t,r)=>r$(e.error)?nI(e.error.value.split($s),{onEmpty:()=>"",onNonEmpty:e=>r?.plain===!0?`${t} ${e.join("\n")}`:"\x1b[s\n"+(_Y(t,"\x1b[31m")+" ")+nR(e,e=>_X(e)).join("\n")+"\x1b[u"}):"",$F=(e,t,r,n,i,s=!1)=>{let a;return $T((a=""===e.value?"":`${e.value}`,s||i?.plain===!0?a:_Y(a,r$(e.error)?"\x1b[31m":((...e)=>e)("\x1b[4m","\x1b[96m"))),n.message,t,r,i)},$L=sG(function*(e,t){let r=yield*_Q,n=_Y("?","\x1b[96m"),i=_Y(r.pointerSmall,"\x1b[90m"),s=$j(e,r.pointerSmall);return $F(e,n,i,t)+s}),$P=sG(function*(e,t){let r=yield*_Q;return $F(e,_Y(r.tick,"\x1b[32m"),_Y(r.ellipsis,"\x1b[90m"),t,void 0,!0)+"\n"}),$D=e=>{if(e.value.length<=0)return lD($r.Beep());let t=e.value.slice(0,e.value.length-1);return lD($r.NextFrame({state:{...e,value:t,error:rx()}}))},$R=e=>lD($r.NextFrame({state:{...e,cursor:0,value:"",error:rx()}})),$U=e=>(t,r)=>$r.$match(r,{Beep:()=>lD("\x07"),NextFrame:({state:t})=>$L(t,e),Submit:()=>$P(t,e)}),$B=e=>(t,r)=>{if(t.key.ctrl&&"u"===t.key.name)return $R(r);switch(t.key.name){case"backspace":return $D(r);case"k":case"up":return lD($r.NextFrame({state:{...r,value:""===r.value||"-"===r.value?`${e.incrementBy}`:`${Number.parseInt(r.value)+e.incrementBy}`,error:rx()}}));case"j":case"down":return lD($r.NextFrame({state:{...r,value:""===r.value||"-"===r.value?`-${e.decrementBy}`:`${Number.parseInt(r.value)-e.decrementBy}`,error:rx()}}));case"enter":case"return":{let t=Number.parseInt(r.value);if(Number.isNaN(t))return lD($r.NextFrame({state:{...r,error:rk("Must provide an integer value")}}));return aM(e.validate(t),{onFailure:e=>$r.NextFrame({state:{...r,error:rk(e)}}),onSuccess:e=>$r.Submit({value:e})})}default:var n=rT(t.input,()=>"");if(0===r.value.length&&"-"===n)return lD($r.NextFrame({state:{...r,value:"-",error:rx()}}));let i=Number.parseInt(r.value+n);return Number.isNaN(i)?lD($r.Beep()):lD($r.NextFrame({state:{...r,value:`${i}`,error:rx()}}))}},$q=(e,t,r,n)=>$T("",r.message,e,t,n),$K=(e,t,r,n,i,s)=>{let a=" ";if(n===r.startIndex&&r.startIndex>0?a=i.arrowUp:n===r.endIndex-1&&r.endIndex<t.length&&(a=i.arrowDown),s?.plain===!0)return e===n?i.pointer+a:a+" ";if(t[n].disabled){let t=((...e)=>e)("\x1b[1m","\x1b[90m");return e===n?_Y(i.pointer,t)+a:a+" "}return e===n?_Y(i.pointer,"\x1b[96m")+a:a+" "},$z=(e,t,r)=>{if(r?.plain===!0)return e.title;let n=e.title;return t?e.disabled?_Y(n,((...e)=>e)("\x1b[4m","\x1b[90m")):_Y(n,((...e)=>e)("\x1b[4m","\x1b[96m")):e.disabled?_Y(n,((...e)=>e)("\x1b[9m","\x1b[90m")):n},$V=(e,t,r,n)=>{let i=t.choices,s=Oi(e,i.length,t.maxPerPage),a=[];for(let t=s.startIndex;t<s.endIndex;t++){let o=i[t],l=e===t,c=$K(e,i,s,t,r,n),u=$z(o,l,n),d=$M(o,l,n);a.push(c+u+" "+d)}return a.join("\n")},$J=sG(function*(e,t){let r=yield*_Q,n=$V(e,t,r);return"\x1b[?25l"+$q(_Y("?","\x1b[96m"),_Y(r.pointerSmall,"\x1b[90m"),t)+"\n"+n}),$W=sG(function*(e,t){let r=yield*_Q,n=t.choices[e].title;return $q(_Y(r.tick,"\x1b[32m"),_Y(r.ellipsis,"\x1b[90m"),t)+" "+_Y(n,"\x1b[37m")+"\n"}),$Y=e=>(t,r)=>$r.$match(r,{Beep:()=>lD("\x07"),NextFrame:({state:t})=>$J(t,e),Submit:()=>$W(t,e)}),$G=e=>sG(function*(t,r){let n=yield*gU,i=yield*n.columns,s=yield*_Q,a=$q("?",s.pointerSmall,e,{plain:!0}),o=$V(t,e,s,{plain:!0});return $n(`${a}
51
- ${o}`,i)+"\x1b[2K\x1b[G"}),$H=e=>(t,r)=>{var n;switch(t.key.name){case"k":case"up":return n=e.choices,0===r?lD($r.NextFrame({state:n.length-1})):lD($r.NextFrame({state:r-1}));case"j":case"down":return r===e.choices.length-1?lD($r.NextFrame({state:0})):lD($r.NextFrame({state:r+1}));case"tab":let i;return i=e.choices,lD($r.NextFrame({state:(r+1)%i.length}));case"enter":case"return":{let t=e.choices[r];if(t.disabled)return lD($r.Beep());return lD($r.Submit({value:t.value}))}default:return lD($r.Beep())}},$Q=sG(function*(e,t){let r=yield*gU,n=yield*r.columns,i=yield*_Q,s=$Z(e,i.pointerSmall,{plain:!0});return $i($X(e,"?",i.pointerSmall,t,{plain:!0}),n,s)+"\x1b[2K\x1b[G"}),$Z=(e,t,r)=>r$(e.error)?nI(e.error.value.split($s),{onEmpty:()=>"",onNonEmpty:e=>r?.plain===!0?`${t} ${e.join("\n")}`:"\x1b[s\n"+(_Y(t,"\x1b[31m")+" ")+nR(e,e=>_X(e)).join("\n")+"\x1b[u"}):"",$X=(e,t,r,n,i,s=!1)=>$T(((e,t,r,n)=>{let i=e.value;if(n?.plain===!0)switch(t.type){case"hidden":return"";case"password":return"*".repeat(i.length);case"text":return i}let s=r$(e.error)?"\x1b[31m":r?"\x1b[37m":0===e.value.length?"\x1b[90m":((...e)=>e)("\x1b[4m","\x1b[96m");switch(t.type){case"hidden":return"";case"password":return _Y("*".repeat(i.length),s);case"text":return _Y(i,s)}})(e,n,s,i),n.message,t,r,i),$0=sG(function*(e,t){let r=yield*_Q;return $X(e,_Y("?","\x1b[96m"),_Y(r.pointerSmall,"\x1b[90m"),t)+$Z(e,r.pointerSmall)+((e,t=0)=>{let r="";return t<0&&(r+=`\x1b[${-t}A`),t>0&&(r+=`\x1b[${t}B`),e>0&&(r+=`\x1b[${e}C`),e<0&&(r+=`\x1b[${-e}D`),r})(e.cursor-e.value.length)}),$1=sG(function*(e,t){let r=yield*_Q;return $X(e,_Y(r.tick,"\x1b[32m"),_Y(r.ellipsis,"\x1b[90m"),t,void 0,!0)+"\n"}),$2=e=>lD($r.NextFrame({state:{...e,cursor:0,error:rx()}})),$3=e=>lD($r.NextFrame({state:{...e,cursor:e.value.length,error:rx()}})),$5=(e,t)=>{let r={default:"",type:t,validate:lD,...e};return _1({cursor:r.default.length,value:r.default,error:rx()},{render:(e,t)=>$r.$match(t,{Beep:()=>lD("\x07"),NextFrame:({state:e})=>$0(e,r),Submit:()=>$1(e,r)}),process:(e,t)=>{if(e.key.ctrl)switch(e.key.name){case"u":return lD($r.NextFrame({state:{...t,cursor:0,value:"",error:rx()}}));case"a":return $2(t);case"e":return $3(t);default:return lD($r.Beep())}switch(e.key.name){case"backspace":var n;if(t.cursor<=0)return lD($r.Beep());let i=t.value.slice(0,t.cursor-1),s=t.value.slice(t.cursor),a=t.cursor-1,o=`${i}${s}`;return lD($r.NextFrame({state:{...t,cursor:a,value:o,error:rx()}}));case"left":if(t.cursor<=0)return lD($r.Beep());let l=t.cursor-1;return lD($r.NextFrame({state:{...t,cursor:l,error:rx()}}));case"right":if(t.cursor>=t.value.length)return lD($r.Beep());let c=Math.min(t.cursor+1,t.value.length);return lD($r.NextFrame({state:{...t,cursor:c,error:rx()}}));case"home":return $2(t);case"end":return $3(t);case"enter":case"return":{let e=t.value;return aM(r.validate(e),{onFailure:r=>$r.NextFrame({state:{...t,value:e,error:rk(r)}}),onSuccess:e=>$r.Submit({value:e})})}case"tab":if(t.value===r.default)return lD($r.Beep());let u=0===t.value.length?r.default:t.value;return lD($r.NextFrame({state:{...t,value:u,cursor:u.length,error:rx()}}));default:let d,f,h,p;return n=rT(e.input,()=>""),d=t.value.slice(0,t.cursor),f=t.value.slice(t.cursor),h=`${d}${n}${f}`,p=t.cursor+n.length,lD($r.NextFrame({state:{...t,cursor:p,value:h,error:rx()}}))}},clear:(e,t)=>$Q(e,r)})},$4=sG(function*(e){let t=yield*gU,r=yield*t.columns,n=yield*_Q;return $n($T(`${e.active} / ${e.inactive}`,e.message,"?",n.pointerSmall,{plain:!0}),r)+"\x1b[2K\x1b[G"}),$8=(e,t,r=!1)=>{let n=_Y("/","\x1b[90m"),i=((...e)=>e)("\x1b[4m",r?"\x1b[37m":"\x1b[96m"),s=e?t.inactive:_Y(t.inactive,i);return(e?_Y(t.active,i):t.active)+" "+n+" "+s},$6=(e,t,r,n)=>{let i=n.message.split($s),s=t+" ";return nA(i)?s+nR(i,e=>_Z(e)).join("\n")+" "+r+" "+e:s+" "+r+" "+e},$9=sG(function*(e,t){let r=yield*_Q,n=_Y("?","\x1b[96m"),i=_Y(r.pointerSmall,"\x1b[90m");return"\x1b[?25l"+$6($8(e,t),n,i,t)}),$7=sG(function*(e,t){let r=yield*_Q,n=_Y(r.tick,"\x1b[32m"),i=_Y(r.ellipsis,"\x1b[90m");return $6($8(e,t,!0),n,i,t)+"\n"}),Oe=lD($r.NextFrame({state:!0})),Ot=lD($r.NextFrame({state:!1})),Or=e=>(t,r)=>{switch(r._tag){case"Beep":return lD("\x07");case"NextFrame":return $9(t,e);case"Submit":return $7(t,e)}},On=(e,t)=>{switch(e.key.name){case"0":case"j":case"delete":case"right":case"down":return Ot;case"1":case"k":case"left":case"up":return Oe;case" ":case"tab":return t?Ot:Oe;case"enter":case"return":return lD($r.Submit({value:t}));default:return lD($r.Beep())}},Oi=(e,t,r)=>{let n=void 0===r?t:r,i=Math.min(t-n,e-Math.floor(n/2));i<0&&(i=0);let s=Math.min(i+n,t);return{startIndex:i,endIndex:s}},Os=sG(function*(e,t){let r=t?.commandPath??[e.name],n=Oa(e,r),i=[...t?.prefix??r];return yield*Op(i),yield*Oo(n,i,n===e?"ROOT":n.name),i}),Oa=(e,t)=>{let r=e;for(let e of t.slice(1)){let t=r.subcommands.flatMap(e=>e.commands).find(t=>t.name===e||t.alias===e);if(void 0===t)break;r=t}return r},Oo=sG(function*(e,t,r){let n=S8(e),i=e.subcommands.flatMap(e=>e.commands.filter(e=>!e.hidden)),s=0===i.length?n.config:n.contextConfig;if(s.flags.length>0){for(let e of(yield*kF(Om(r,"FLAGS")),s.flags))t.push(...yield*Oc(e));(s.arguments.length>0||i.length>0)&&(yield*Op(t))}if(s.arguments.length>0){for(let e of(yield*kF(Om(r,"ARGUMENTS")),s.arguments))t.push(...yield*Oc(e));i.length>0&&(yield*Op(t))}if(0===i.length)return;let a=yield*_4(_8({message:"Command",choices:i.map(e=>({title:e.name,value:e,...void 0!==e.shortDescription?{description:e.shortDescription}:void 0!==e.description?{description:e.description}:{}}))}));yield*kF(),t.push(a.name),Ol(a)&&(yield*Op(t)),yield*Oo(a,t,a.name)}),Ol=e=>e.subcommands.some(e=>e.commands.some(e=>!e.hidden))||S8(e).config.orderedParams.length>0,Oc=sG(function*(e){let t=Sx(e),r=Sk(e);if(r.isOptional&&!(yield*_4(_0({message:`Set ${Of(t)}?`,initial:!1}))))return yield*kF(),[];let n=r.isVariadic?yield*_4(_3({message:`${Of(t)} count`,default:rT(r.variadicMin,()=>0),min:rT(r.variadicMin,()=>0),...r$(r.variadicMax)?{max:r.variadicMax.value}:{}})):1,i=[];for(let e=0;e<n;e++)i.push((yield*Ou(t)));let s="flag"===t.kind?{flags:{[t.name]:i},arguments:[]}:{flags:{},arguments:i};return(yield*e.parse(s),yield*kF(),t.kind===k7)?i:i.flatMap(e=>[`--${t.name}`,e])}),Ou=e=>{var t,r;let n=Od(e);switch(e.primitiveType._tag){case"Boolean":return ae(_4(_0({message:n,label:{confirm:"true",deny:"false"},placeholder:{defaultConfirm:"(T/f)",defaultDeny:"(t/F)"}})),String);case"Choice":return _4(_8({message:n,choices:(k6(e.primitiveType)??[]).map(e=>({title:e,value:e}))}));case"Date":let i,s,a,o,l,c;return ae(_4((t={message:n},a=(s=((e,t,r)=>{let n=[],i=null;for(;i=$v.exec(e);){let e=i.shift(),s=i.findIndex(e=>void 0!==e);if(s in $w){let a=i[s]||e;n.push($w[s]({token:a,date:t,parts:n,locales:r}))}else n.push(new $k({token:i[s]||e,date:t,parts:n,locales:r}))}let s=n.reduce((e,t)=>{let r=e[e.length-1];return t.isToken()&&void 0!==r&&r.isToken()?r.setValue(t.token):e.push(t),e},nP());return n.splice(0,n.length,...s),n})((i={initial:new Date,dateMask:"YYYY-MM-DD HH:mm:ss",validate:lD,...t,locales:{...$b,...t.locales}}).dateMask,i.initial,i.locales)).findIndex(e=>!e.isToken()),_1({dateParts:s,typed:"",cursor:a,value:i.initial,error:rx()},{render:(o=i,(e,t)=>$r.$match(t,{Beep:()=>lD("\x07"),NextFrame:({state:e})=>$g(e,o),Submit:()=>$y(e,o)})),process:(l=i,(e,t)=>{switch(e.key.name){case"left":let r;return lD(r$(r=t.dateParts[t.cursor].previousPart())?$r.NextFrame({state:{...t,typed:"",cursor:t.dateParts.indexOf(r.value)}}):$r.Beep());case"right":let n;return lD(r$(n=t.dateParts[t.cursor].nextPart())?$r.NextFrame({state:{...t,typed:"",cursor:t.dateParts.indexOf(n.value)}}):$r.Beep());case"k":case"up":return lD((t.dateParts[t.cursor].increment(),$r.NextFrame({state:{...t,typed:""}})));case"j":case"down":return lD((t.dateParts[t.cursor].decrement(),$r.NextFrame({state:{...t,typed:""}})));case"tab":let i;return lD((i=rO(t.dateParts[t.cursor].nextPart(),{onNone:()=>t.dateParts.findIndex(e=>!e.isToken()),onSome:e=>t.dateParts.indexOf(e)}),$r.NextFrame({state:{...t,cursor:i}})));case"enter":case"return":return aM(l.validate(t.value),{onFailure:e=>$r.NextFrame({state:{...t,error:rk(e)}}),onSuccess:e=>$r.Submit({value:e})});default:return lD(((e,t)=>{if(/\d/.test(e)){let r=t.typed+e;return t.dateParts[t.cursor].setValue(r),$r.NextFrame({state:{...t,typed:r}})}return $r.Beep()})(rT(e.input,()=>""),t))}}),clear:(c=i,sG(function*(e,t){let r=yield*gU,n=yield*r.columns,i=yield*_Q,s=nq(e.dateParts,"",(e,t)=>e+t.toString());return $i($m("?",i.pointerSmall,s,c,{plain:!0}),n,r$(e.error)?nI(e.error.value.split($s),{onEmpty:()=>"",onNonEmpty:e=>`${i.pointerSmall} ${e.join("\n")}`}):"")+"\x1b[2K\x1b[G"}))}))),e=>e.toISOString());case"Float":let u,d,f,h;return ae(_4((u={default:0,min:-1/0,max:1/0,incrementBy:1,decrementBy:1,precision:2,validate:e=>e<u.min?tJ(`${e} must be greater than or equal to ${u.min}`):e>u.max?tJ(`${e} must be less than or equal to ${u.max}`):lD(e),...r={message:n}},_1({cursor:(d=void 0===r.default?"":`${u.default}`).length,value:d,error:rx()},{render:(f=u,(e,t)=>$r.$match(t,{Beep:()=>lD("\x07"),NextFrame:({state:e})=>$L(e,f),Submit:()=>$P(e,f)})),process:(h=u,(e,t)=>{if(e.key.ctrl&&"u"===e.key.name)return $R(t);switch(e.key.name){case"backspace":return $D(t);case"k":case"up":return lD($r.NextFrame({state:{...t,value:""===t.value||"-"===t.value?`${h.incrementBy}`:`${Number.parseFloat(t.value)+h.incrementBy}`,error:rx()}}));case"j":case"down":return lD($r.NextFrame({state:{...t,value:""===t.value||"-"===t.value?`-${h.decrementBy}`:`${Number.parseFloat(t.value)-h.decrementBy}`,error:rx()}}));case"enter":case"return":{let e=Number.parseFloat(t.value);if(Number.isNaN(e))return lD($r.NextFrame({state:{...t,error:rk("Must provide a floating point value")}}));return s8(sL(()=>_W(e,h.precision)),e=>aM(h.validate(e),{onFailure:e=>$r.NextFrame({state:{...t,error:rk(e)}}),onSuccess:e=>$r.Submit({value:e})}))}default:var r=rT(e.input,()=>"");if("."===r&&t.value.includes("."))return lD($r.Beep());if(0===t.value.length&&"-"===r)return lD($r.NextFrame({state:{...t,value:"-",error:rx()}}));let n=Number.parseFloat(t.value+r);return Number.isNaN(n)?lD($r.Beep()):lD($r.NextFrame({state:{...t,value:"."===r?`${n}.`:`${n}`,error:rx()}}))}}),clear:$N(u)}))),String);case"Integer":return ae(_4(_3({message:n})),String);case"Redacted":return ae(_4($5({message:n},"password").pipe(_5(_z))),_J);default:return _4($5({message:n},"text"))}},Od=e=>Of(e),Of=e=>{let t=ei.getOrUndefined(e.description)?.trim(),r="flag"===e.kind&&void 0!==t&&t.length<=32?t:Oh(e.name);return"flag"===e.kind?`${r} (${"flag"===e.kind?`--${e.name}`:e.name})`:r},Oh=e=>{let t=e.split(/[-_]+/).filter(e=>e.length>0);return 0===t.length?e:[t[0][0].toUpperCase()+t[0].slice(1),...t.slice(1)].join(" ")},Op=e=>kF(Ov("Current command",e,"\x1b[35m")),Om=(e,t)=>`${_Y(e.toUpperCase(),"\x1b[1m","\x1b[96m")} ${_Y("·","\x1b[90m")} ${_Y(t,"\x1b[1m","\x1b[37m")}`,Og=(e,t,r)=>[`${_Y(e,"\x1b[1m","\x1b[96m")} ${_Y(`v${t}`,"\x1b[37m")} ${_Y("· Command wizard","\x1b[1m","\x1b[37m")}`,...void 0===r||0===r.length?[]:[r],_Y("Build a command interactively. Press Ctrl+C to cancel.","\x1b[90m"),""].join("\n"),Oy=e=>Ov("Command ready",e,"\x1b[96m","\x1b[32m"),Ob=()=>`
52
- ${_Y("Wizard cancelled.","\x1b[31m")}`,Ov=(e,t,r,n="\x1b[37m")=>{let i=Ow(t);return[_Y(e,"\x1b[1m",n),...i.map(e=>_Y(e,r)),""].join("\n")},Ow=e=>{let t=" $ ",r=" ",n=e.map(Ox),i=[],s=t;for(let e of n){let n=s===t||s===r?"":" ";s.length+n.length+e.length>88&&s!==t?(i.push(`${s} \\`),s=`${r}${e}`):s+=`${n}${e}`}return s!==t&&i.push(s),i},Ox=e=>/^[A-Za-z0-9_./:@%+=,-]+$/.test(e)?e:`'${e.replaceAll("'","'\"'\"'")}'`,Ok=e=>eT(e,S4),OS=(e,t,r)=>S9({name:e,config:SX(t??{}),...eO(r)?{handle:r}:{}}),O_=el(2,(e,t)=>{let r=(e=>{let t=[],r=new Map,n=(e,n)=>{t.push(n);let i=r.get(e);i?i.push(n):r.set(e,[n])};for(let t of e){if(Ok(t)){n(void 0,t);continue}for(let e of t.commands)n(t.group,e)}let i=[],s=r.get(void 0);for(let[e,t]of(s&&s.length>0&&i.push({group:void 0,commands:s}),r))void 0!==e&&i.push({group:e,commands:t});return{flat:t,groups:i}})(t);_n(e,r.flat);let n=S8(e),i=new Map(r.flat.map(e=>[e.name,S8(e)])),s=Symbol("effect/cli/SubcommandState"),a=sG(function*(e){if(r_(e.subcommand))return yield*n.parse(e);let t=i.get(e.subcommand.value.name);if(!t)return yield*n.parse(e);let r=yield*n.parseContext(e),a=yield*t.parse(e.subcommand.value.parsedInput);return Object.assign({},r,{[s]:{name:t.name,result:a}})}),o=sG(function*(e,t){let r=e[s];if(r){let s=i.get(r.name);return s?yield*s.handle(r.result,[...t,s.name]).pipe(af(n.service,e)):yield*new kV({commandPath:t,errors:[]})}return yield*n.handle(e,t)});return S9({name:n.name,config:n.config,contextConfig:n.contextConfig,description:n.description,shortDescription:n.shortDescription,alias:n.alias,annotations:n.annotations,globalFlags:n.globalFlags,examples:n.examples,service:n.service,subcommands:r.groups,parse:a,parseContext:n.parseContext,handle:o})}),O$=el(2,(e,t)=>{let r=S8(e),n=SX(t),i=S3(r.config,n),s=S3(r.contextConfig,n);r.subcommands.length>0&&_n(e,r.subcommands.flatMap(e=>e.commands),{contextConfig:s});let a=_t(n),o=sG(function*(e){return Object.assign({},(yield*r.parse(e)),(yield*a(e)))}),l=sG(function*(e){return Object.assign({},(yield*r.parseContext(e)),(yield*a(e)))});return S9({name:r.name,config:i,contextConfig:s,description:r.description,shortDescription:r.shortDescription,alias:r.alias,annotations:r.annotations,globalFlags:r.globalFlags,examples:r.examples,service:r.service,subcommands:r.subcommands,parse:o,parseContext:l,handle:(e,t)=>r.handle(e,t)})}),OO=el(2,(e,t)=>S9({...S8(e),description:t})),OI=el(2,(e,t)=>S9({...S8(e),shortDescription:t})),OC=el(2,(e,t)=>S9({...S8(e),examples:t})),OE=(e,t)=>{let r=S8(e);return sG(function*(n){let i,s,a,o,l,c,{builtIns:u}=yield*_v,{tokens:d,trailingOperands:f}=-1===(i=n.indexOf("--"))?{tokens:_x(n),trailingOperands:[]}:{tokens:_x(n.slice(0,i)),trailingOperands:n.slice(i+1)},h=_o([...u,...(s=[],(a=e=>{for(let t of S8(e).globalFlags)s.push(t);for(let t of e.subcommands)for(let e of t.commands)a(e)})(e),_o(s))]),p=_O(h.flatMap(e=>Sw(e.flag)).filter(St)),{flagMap:m,remainder:g,errors:y}=(o=_C(p.params),l=[],c=(e,t,r)=>{let n=_O(S8(t).config.flags.flatMap(Sw).filter(St)),i=_O(S8(t).contextConfig.flags.flatMap(Sw).filter(St)),s=_I(t.subcommands),a=_$(e),u=[],d=!0;for(let e=a.take();e;e=a.take()){if(_E(e)){let t=_L(e,r);if(void 0!==t){_P(u,a,e,t);continue}let c=_T(e,i);if(void 0!==c){_P(u,a,e,c);continue}let f=_T(e,n),h=_T(e,p);if(void 0!==f&&(void 0===h||!d||!_D(e,a.rest(),f,s,[n,i,p]))){_P(u,a,e,f);continue}if(void 0!==h){let t=_F(a,e,h.param,h.negated);if("Error"===t._tag){l.push(t.error);continue}void 0!==t.value&&o[h.param.name].push(t.value);continue}u.push(e);continue}if("Value"===e._tag&&d){let t=s.get(e.value);if(void 0!==t)return u.push(e),u.push(...c(a.rest(),t,[...r,i])),u;d=!1}u.push(e)}return u},{flagMap:o,remainder:c(d,e,[]),errors:l}),b={flags:m,arguments:[]},v=yield*__({tokens:g,trailingOperands:f},e),w=[e.name,..._S(v)],x={builtIns:u,command:e,commandPath:w,version:t.version},k=_c(e,w,u),S=((e,t,r,n)=>{let i=new Set(t),s=[],a=new Set;for(let t of e)if(!i.has(t))for(let e of Sw(t.flag)){let t=r[e.name];if(!t||0===t.length)continue;let i=`--${e.name}`;a.has(i)||(a.add(i),s.push(new kP({option:i,suggestions:[],command:n})))}return s})(h,k,m,w);if(S.length>0||y.length>0){let e=v.errors??[];return yield*new kV({commandPath:w,errors:[...y,...S,...e]})}for(let r of k){if("Action"!==r._tag||!Sw(r.flag).some(e=>{let t=m[e.name];return void 0!==t&&t.length>0}))continue;let[,i]=yield*r.flag.parse(b);if(r===_m)return yield*lR(function*(){yield*kF(Og(e.name,t.version,e.description));let r=[e.name,...n.filter(e=>"--wizard"!==e&&!e.startsWith("--wizard="))],i=yield*Os(e,{commandPath:w,prefix:r});yield*kF(Oy(i)),(yield*_4(_9({message:"Run this command?",initial:!0,active:"yes",inactive:"no"})))&&(yield*kF(),yield*OE(e,t)(i.slice(1)))}).pipe(a_("QuitError",()=>kF(Ob())));yield*r.run(i,x);return}if(v.errors&&v.errors.length>0)return yield*new kV({commandPath:w,errors:v.errors});let _=yield*aC(r.parse(v));if("Failure"===_._tag)return yield*new kV({commandPath:w,errors:[_.failure]});let $=r.handle(_.success,[e.name]),O=k.includes(_y)?(yield*_y.flag.parse(b))[1]:rx();for(let e of($=af($,_y,O),k)){if("Setting"!==e._tag||e===_y)continue;let[,t]=yield*e.flag.parse(b);$=af($,e,t)}let I=rO(O,{onNone:()=>n5,onSome:e=>n4(sr,e)});yield*ad($,I)},aS(e=>eT(e,kL)&&"ShowHelp"===e._tag?rp(e):rh(e),t=>s2(lR(function*(){let{builtIns:r}=yield*_v,n=yield*SS,i=yield*_u(e,t.commandPath,r);yield*kF(n.formatHelpDoc(i)),t.errors.length>0&&(yield*kj(n.formatErrors(t.errors)))}),tJ(t))),aS(e=>eT(e,gD)?rp(e):rh(e),e=>a1))},OA=new Set(["create","show","edit","list","export"]);function OT(e){return{_tag:"File",path:e}}function OM(e){return{_tag:"InlineJson",value:e}}function ON(){let e=Sn("flag","file").pipe(SG("PATH|-"),SY("Read one canonical document from PATH, or stdin with -."),SQ(OT)),t=Sn("flag","json").pipe(SG("VALUE"),SY("Read one canonical document from inline JSON."),SQ(OM));return{source:Object.assign(Object.create(Object.getPrototypeOf(e)),e,{parse:r=>{let n=r.flags.file?.length??0,i=r.flags.json?.length??0;return 1===n&&0===i?e.parse(r):0===n&&1===i?t.parse(r):tJ(new kB({option:"file/--json",value:0===n&&0===i?"neither provided":"more than one source provided",expected:"exactly one of --file PATH|- or --json VALUE",kind:"flag"}))}}),jsonInput:SH(t)}}class Oj extends nQ()("@sketchi/cli/InputReader"){}function OF(e,t){return sz({try:()=>new TextDecoder("utf-8",{fatal:!0}).decode(e),catch:()=>xA.make({code:"input_read_failed",message:"stdin"===t?"Standard input is not valid UTF-8.":"The input file is not valid UTF-8.",hint:"Provide one complete UTF-8 JSON document and retry."})})}let OL=function(e=()=>!0===process.stdin.isTTY){return lk(Oj,lR(function*(){let t=yield*ke,r=yield*dR;return{read:lW("sketchi.cli.input.read")(function*(n){if("InlineJson"===n._tag)return n.value;if("-"!==n.path){let e=yield*t.readBytes(n.path).pipe(aO(()=>xA.make({code:"input_read_failed",message:`Unable to read input file ${n.path}.`,hint:"Check the path and file permissions, then retry."})));return yield*OF(e,"file")}if(e())return yield*xA.make({code:"interactive_stdin",message:"--file - requires piped or redirected stdin.",hint:"Pipe one JSON document, or use --file PATH / --json VALUE."});let i=yield*uo(r.stdin).pipe(aO(()=>xA.make({code:"input_read_failed",message:"Unable to read JSON from stdin.",hint:"Pipe one complete UTF-8 JSON document and retry."})));return yield*OF(function(e){let t=new Uint8Array(e.reduce((e,t)=>e+t.byteLength,0)),r=0;for(let n of e)t.set(n,r),r+=n.byteLength;return t}(i),"stdin")})}}))}(),OP=lW("sketchi.cli.input.readDocument")(function*(e){let t=yield*Oj,r=yield*t.read(e);return yield*xK(r)});class OD extends nQ()("@sketchi/cli/OutputWriter"){}class OR extends gA()("CliCommandExit",{exitCode:m4}){}function OU(e){return xE.make({cause:e,operation:"write-output",path:"standard stream",message:"Unable to write command output."})}let OB=lk(OD,lR(function*(){let e=yield*dR;return{stdout:t=>((...e)=>ue(e))(t).pipe(ua(e.stdout()),aO(OU)),stderr:t=>((...e)=>ue(e))(t).pipe(ua(e.stderr()),aO(OU))}}));function Oq(e){let t=e.details?.map(e=>` - ${e}`).join("\n");return[`error: ${e.code}`,e.message,`next: ${e.hint}`,...t?["details:",t]:[]].join("\n")+"\n"}let OK=lW("sketchi.cli.output.failure")(function*(e,t,r){let n=yield*OD,i=function(e){switch(e._tag){case"CliFilesystemError":return{code:"filesystem_error",message:e.message,hint:"Check local paths and permissions, then retry."};case"CliInputError":case"CliStorageError":case"CliExportError":return{code:e.code,message:e.message,hint:e.hint};case"CliValidationError":return{code:"invalid_document",message:e.message,hint:e.hint,details:e.details};case"CliBuildError":return{code:"build_failed",message:e.message,hint:e.hint,details:e.details};case"CliGenerationError":return{code:e.code,message:e.message,hint:e.hint,details:e.details}}}(r),s="json"===t?xz({ok:!1,command:e,error:i}):Oq(i);return yield*n.stderr(s),yield*OR.make({exitCode:function(e){switch(e._tag){case"CliInputError":return"interactive_stdin"===e.code?2:3;case"CliValidationError":return 3;case"CliBuildError":return 4;case"CliGenerationError":switch(e.code){case"invalid_generated_document":return 3;case"provider_failure":return 10;case"generation_timeout":return 11;case"malformed_output":return 12}case"CliStorageError":if("diagram_not_found"===e.code)return 5;if("diagram_already_exists"===e.code||"diagram_busy"===e.code)return 6;return 7;case"CliFilesystemError":return 7;case"CliExportError":return 8}}(r)})}),Oz=lW("sketchi.cli.output.success")(function*(e,t,r,n,i="stdout"){let s=yield*OD,a="json"===t?xz({ok:!0,command:e,data:r}):n;yield*s[i](a.endsWith("\n")?a:`${a}
53
- `)});function OV(e,t,r,n,i=e=>e){return r.pipe(aT({onFailure:r=>OK(e,t,r),onSuccess:r=>Oz(e,t,i(r),n(r))}))}let OJ=`Local Sketchi authoring for canonical flowcharts and mindmaps, with one prompt-assisted path.
14
+ ${o}${a}ERRORS${s}`),t))for(let t of e)r.push(` ${t.message}${s}`);return r.join("\n")},formatVersion:(e,t)=>`${i.bold(e)} ${i.dim("v")}${i.bold(t)}`}},sv=e=>e.replace(/\u001B\[[0-9;]*m/g,"").length,sw=(e,t)=>{let r=Math.max(...e.map(e=>sv(e.left)))+4,n=void 0===t?r:Math.min(r,t);return e.map(({left:e,right:t})=>{let r;return` ${r=Math.max(0,n-sv(e)),e+" ".repeat(r)}${t}`}).join("\n")},sx=(e,t)=>t?`${e}, ${t}`:e,sk=(e,t)=>{let r=[];if(e.description&&(r.push(t.bold("DESCRIPTION")),r.push(` ${e.description}`),r.push("")),r.push(t.bold("USAGE")),r.push(` ${t.cyan(e.usage)}`),r.push(""),e.args&&e.args.length>0){r.push(t.bold("ARGUMENTS"));let n=e.args.map(e=>{let r=e.name;e.variadic&&(r+="...");let n=t.green(r),i=t.dim(e.type),s=`${n} ${i}`,a=e.required?"":t.dim(" (optional)");return{left:s,right:q.getOrElse(e.description,()=>"")+a}});r.push(sw(n,25)),r.push("")}if(e.flags.length>0){r.push(t.bold("FLAGS"));let n=e.flags.map(e=>{let r=[];for(let n of(r.push(t.green(`--${e.name}`)),e.aliases))r.push(t.green(n));return{left:r.join(", ")+("boolean"!==e.type?` ${t.dim(e.type)}`:""),right:q.getOrElse(e.description,()=>"")}});r.push(sw(n)),r.push("")}if(e.globalFlags&&e.globalFlags.length>0){r.push(t.bold("GLOBAL FLAGS"));let n=e.globalFlags.map(e=>{let r=[];for(let n of(r.push(t.green(`--${e.name}`)),e.aliases))r.push(t.green(n));return{left:r.join(", ")+("boolean"!==e.type?` ${t.dim(e.type)}`:""),right:q.getOrElse(e.description,()=>"")}});r.push(sw(n)),r.push("")}if(e.subcommands&&e.subcommands.length>0){let n=e.subcommands.find(e=>void 0===e.group);for(let i of(n&&(r.push(t.bold("SUBCOMMANDS")),r.push(sw(n.commands.map(e=>({left:t.cyan(sx(e.name,e.alias)),right:e.shortDescription??e.description})),20)),e.subcommands.length>1&&r.push("")),e.subcommands))void 0!==i.group&&(r.push(t.bold(`${i.group}:`)),r.push(sw(i.commands.map(e=>({left:t.cyan(sx(e.name,e.alias)),right:e.shortDescription??e.description})),20)),r.push(""))}if(e.examples&&e.examples.length>0){r.push(t.bold("EXAMPLES"));let n=!0,i=!1;for(let s of e.examples)s.description?(n||r.push(""),r.push(` ${t.dim(`# ${s.description}`)}`)):i&&r.push(""),r.push(` ${t.cyan(s.command)}`),n=!1,i=!!s.description;r.push("")}return""===r[r.length-1]&&r.pop(),r.join("\n")},sS=e=>e.replace(/[^a-zA-Z0-9_]/g,"_"),s_=e=>{let t=[`--${e.name}`];for(let r of e.aliases)t.push(1===r.length?`-${r}`:`--${r}`);return"Boolean"===e.type._tag&&t.push(`--no-${e.name}`),t},sO=e=>{switch(e._tag){case"Boolean":default:return;case"Choice":return`COMPREPLY=( $(compgen -W '${e.values.join(" ")}' -- "$cur") )`;case"Path":if("directory"===e.pathType)return'COMPREPLY=( $(compgen -d -- "$cur") )';return'COMPREPLY=( $(compgen -f -- "$cur") )'}},sI=e=>{switch(e._tag){case"Choice":return`COMPREPLY=( $(compgen -W '${e.values.join(" ")}' -- "$cur") )`;case"Path":if("directory"===e.pathType)return'COMPREPLY=( $(compgen -d -- "$cur") )';return'COMPREPLY=( $(compgen -f -- "$cur") )';default:return}},s$=(e,t,r)=>{let n=[...t,e.name],i=`_${n.map(sS).join("_")}`;r.push(`${i}()`),r.push("{"),r.push(" local cur prev words cword"),r.push(" _init_completion || return"),r.push("");let s=e.flags.filter(e=>"Boolean"!==e.type._tag);if(s.length>0){for(let e of(r.push(" # Flag value completions"),r.push(' case "$prev" in'),s)){let t=[`--${e.name}`];for(let r of e.aliases)t.push(1===r.length?`-${r}`:`--${r}`);let n=sO(e.type);n&&(r.push(` ${t.join("|")})`),r.push(` ${n}`),r.push(" return"),r.push(" ;;"))}r.push(" esac"),r.push("")}if(e.subcommands.length>0){for(let t of(r.push(" # Subcommand dispatch"),r.push(" local i cmd"),r.push(" for ((i = 1; i < cword; i++)); do"),r.push(' case "${words[i]}" in'),e.subcommands)){let e=`_${[...n,t.name].map(sS).join("_")}`;r.push(` ${t.name})`),r.push(` ${e}`),r.push(" return"),r.push(" ;;")}r.push(" esac"),r.push(" done"),r.push("")}((e,t)=>{if(0===e.length)return;t.push(" # Build used-flag filter"),t.push(" local -A _flag_groups");let r=0;for(let n of e){for(let e of s_(n))t.push(` _flag_groups[${e}]=${r}`);r++}t.push(" local -A _used_groups"),t.push(" for ((i = 1; i < cword; i++)); do"),t.push(' local _g="${_flag_groups[${words[i]}]:-}"'),t.push(' [[ -n "$_g" ]] && _used_groups[$_g]=1'),t.push(" done"),t.push(' local _filtered_flags=""'),t.push(` for _f in ${e.flatMap(s_).join(" ")}; do`),t.push(' local _g="${_flag_groups[$_f]:-}"'),t.push(' [[ -z "$_g" || -z "${_used_groups[$_g]:-}" ]] && _filtered_flags+=" $_f"'),t.push(" done"),t.push("")})(e.flags,r),(e.flags.length>0||e.subcommands.length>0)&&(r.push(" # Complete flags (filtered) and subcommands"),r.push(' if [[ "$cur" == -* ]]; then'),e.flags.length>0&&r.push(' COMPREPLY=( $(compgen -W "$_filtered_flags" -- "$cur") )'),r.push(" return"),r.push(" fi"),r.push(""));let a=e.arguments.filter(e=>void 0!==sI(e.type));if(a.length>0)for(let e of(r.push(" # Positional argument completions"),a)){let t=sI(e.type);r.push(` ${t}`),r.push(" return")}else if(e.subcommands.length>0){let t=e.subcommands.map(e=>e.name);r.push(` COMPREPLY=( $(compgen -W '${t.join(" ")}' -- "$cur") )`)}for(let t of(r.push("}"),r.push(""),e.subcommands))s$(t,n,r)},sE=e=>e.replace(/'/g,"\\'"),sC=e=>{let t=[];for(let r of e.aliases)1===r.length&&t.push(`-s ${r}`);for(let r of(t.push(e.name),e.aliases))r.length>1&&t.push(r);return"Boolean"===e.type._tag&&t.push(`no-${e.name}`),`not __fish_contains_opt ${t.join(" ")}`},sA=e=>{let t=[`-l ${e.name}`];for(let r of e.aliases)1===r.length?t.push(`-s ${r}`):t.push(`-l ${r}`);e.description&&t.push(`-d '${sE(e.description)}'`);let r=sT(e.type);return r&&t.push(r),t},sT=e=>{switch(e._tag){case"Boolean":return;case"Choice":return`-r -f -a '${e.values.join(" ")}'`;case"Path":return e.pathType,"-r -F";default:return"-r -f"}},sN=e=>{switch(e._tag){case"Choice":return`-r -f -a '${e.values.join(" ")}'`;case"Path":return"-r -F";default:return}},sM=(e,t,r,n)=>{let i=((e,t)=>{if(0===e.length)return t.length>0?"__fish_use_subcommand":"";let r=e[e.length-1];return t.length>0?`__fish_seen_subcommand_from ${r}; and not __fish_seen_subcommand_from ${t.join(" ")}`:`__fish_seen_subcommand_from ${r}`})(r,t.subcommands.map(e=>e.name)),s=i?`-n '${i}'`:"";if(!t.arguments.some(e=>"Path"===e.type._tag)){let t=[`complete -c ${e}`];s&&t.push(s),t.push("-f"),n.push(t.join(" "))}for(let r of t.subcommands){let t=[`complete -c ${e}`];s&&t.push(s),t.push(`-f -a '${sE(r.name)}'`),r.description&&t.push(`-d '${sE(r.description)}'`),n.push(t.join(" "))}for(let r of t.flags){let t="Boolean"===r.type._tag,s=t?i?`${i}; and ${sC(r)}`:sC(r):i,a=s?`-n '${s}'`:"",o=[`complete -c ${e}`];if(a&&o.push(a),o.push(...sA(r)),n.push(o.join(" ")),t){let t=[`complete -c ${e}`];a&&t.push(a),t.push(`-l no-${r.name}`),r.description&&t.push(`-d '${sE(`Disable ${r.name}`)}'`),n.push(t.join(" "))}}if(t.flags.length>0){let r='not string match -q -- "-*" (commandline -ct)',s=i?`${i}; and ${r}`:r;for(let r of t.flags){let t=`${s}; and ${sC(r)}`,i="Boolean"===r.type._tag,a=[`complete -c ${e}`];if(a.push(`-n '${t}'`),a.push(`-f -a '--${r.name}'`),r.description&&a.push(`-d '${sE(r.description)}'`),n.push(a.join(" ")),i){let i=[`complete -c ${e}`];i.push(`-n '${t}'`),i.push(`-f -a '--no-${r.name}'`),r.description&&i.push(`-d '${sE(`Disable ${r.name}`)}'`),n.push(i.join(" "))}}}for(let r of t.arguments){let t=sN(r.type);if(t){let i=[`complete -c ${e}`];s&&i.push(s),i.push(t),r.description&&i.push(`-d '${sE(r.description)}'`),n.push(i.join(" "))}}for(let i of t.subcommands)sM(e,i,[...r,i.name],n)},sP=e=>e.replace(/\\/g,"\\\\").replace(/'/g,"'\\''").replace(/:/g,"\\:"),sj=e=>e.replace(/[^a-zA-Z0-9_]/g,"_"),sD=e=>{let t=[],r=e.description?`[${sP(e.description)}]`:"",n=(e=>{switch(e._tag){case"Boolean":return"";case"Choice":return`:value:(${e.values.join(" ")})`;case"Path":return"directory"===e.pathType?":directory:_directories":":file:_files";case"Integer":return":integer:";case"Float":return":float:";case"Date":return":date:";default:return":value:"}})(e.type),i=`(${(e=>{let t=[`--${e.name}`];for(let r of e.aliases)t.push(1===r.length?`-${r}`:`--${r}`);return"Boolean"===e.type._tag&&t.push(`--no-${e.name}`),t})(e).join(" ")})`;for(let s of(t.push(`'${i}--${e.name}${r}${n}'`),e.aliases)){let e=1===s.length?"-":"--";t.push(`'${i}${e}${s}${r}${n}'`)}if("Boolean"===e.type._tag){let r=e.description?`[${sP(`Disable ${e.name}`)}]`:"";t.push(`'${i}--no-${e.name}${r}'`)}return t},sF=e=>{let t=e.description?sP(e.description):e.name,r=(e=>{switch(e._tag){case"Choice":return`(${e.values.join(" ")})`;case"Path":return"directory"===e.pathType?"_directories":"_files";default:return""}})(e.type),n=e.variadic?"*":"";return`'${n}:${t}:${r}'`},sL=(e,t,r)=>{let n=[...t,e.name],i=`_${n.map(sj).join("_")}`;if(r.push(`${i}() {`),e.subcommands.length>0){for(let t of(r.push(" local context state state_descr line"),r.push(" typeset -A opt_args"),r.push(""),r.push(" local -a commands"),r.push(" commands=("),e.subcommands)){let e=t.description?sP(t.description):"";r.push(` '${t.name}:${e}'`)}for(let t of(r.push(" )"),r.push(""),r.push(" local -a specs"),r.push(" specs=("),e.flags))for(let e of sD(t))r.push(` ${e}`);for(let t of e.arguments)r.push(` ${sF(t)}`);for(let t of(r.push(" '1:command:->command'"),r.push(" '*::arg:->args'"),r.push(" )"),r.push(""),r.push(' _arguments -C "${specs[@]}"'),r.push(""),r.push(' case "$state" in'),r.push(" command)"),r.push(" _describe -t commands 'commands' commands"),r.push(" ;;"),r.push(" args)"),r.push(' case "$words[1]" in'),e.subcommands)){let e=`_${[...n,t.name].map(sj).join("_")}`;r.push(` ${t.name})`),r.push(` ${e}`),r.push(" ;;")}r.push(" esac"),r.push(" ;;"),r.push(" esac")}else{let t=[];for(let r of e.flags)t.push(...sD(r));for(let r of e.arguments)t.push(sF(r));if(t.length>0){for(let e of(r.push(" local -a specs"),r.push(" specs=("),t))r.push(` ${e}`);r.push(" )"),r.push(' _arguments "${specs[@]}"')}}for(let t of(r.push("}"),r.push(""),e.subcommands))sL(t,n,r)},sR=e=>i6({name:e,primitiveType:iz,kind:"flag"}),sU=(e,t)=>i9("flag",e,t.map(e=>[e,e])),sB=(0,F.XY)(2,(e,t)=>i7(e,t)),sY=(0,F.XY)(2,(e,t)=>se(e,t)),sX=(0,F.XY)(2,(e,t)=>sa(e,t)),sW=e=>si(e),sJ=(0,F.XY)(2,(e,t)=>st(e,t)),sq="~effect/cli/Command/Config/Internal",sK=e=>{let t=[],r=[],n=[];return{[sq]:sq,flags:r,arguments:n,orderedParams:t,tree:function e(i){let s={};for(let a in i)s[a]=function i(s){if(Array.isArray(s))return{_tag:"Array",children:s.map(e=>i(e))};if(!ei.i5(s,i1))return{_tag:"Nested",tree:e(s)};{let e=t.length;return t.push(s),"argument"===s.kind?n.push(s):r.push(s),{_tag:"Param",index:e}}}(i[a]);return s}(e)}},sV=sK({}),sG=(e,t)=>{switch(e._tag){case"Param":return{_tag:"Param",index:e.index+t};case"Array":return{_tag:"Array",children:e.children.map(e=>sG(e,t))};case"Nested":return{_tag:"Nested",tree:sH(e.tree,t)}}},sH=(e,t)=>{let r={};for(let n in e)r[n]=sG(e[n],t);return r},sz=(e,t)=>{let r=e.orderedParams.length;return{[sq]:sq,flags:[...e.flags,...t.flags],arguments:[...e.arguments,...t.arguments],orderedParams:[...e.orderedParams,...t.orderedParams],tree:{...e.tree,...sH(t.tree,r)}}},sQ=(e,t)=>{let r={};for(let n in e)r[n]=function e(r){switch(r._tag){case"Param":return t[r.index];case"Array":return r.children.map(t=>e(t));case"Nested":return sQ(r.tree,t)}}(e[n]);return r},sZ="~effect/cli/Command",s0=e=>e,s1={...t_.b({label:"Command",evaluate(){return s0(this).service}})},s2=e=>{let t=e.config,r=e.contextConfig??sV,n=e.service??G.kl(`${sZ}/${e.name}`),i=e.annotations??G.Ie(),s=e.globalFlags??[],a=e.subcommands??[],o=e.parse??s6(t),l=e.parseContext??s6(r);return Object.assign(Object.create(s1),{[sZ]:sZ,name:e.name,examples:e.examples??[],annotations:i,globalFlags:s,subcommands:a,hidden:e.hidden??!1,config:t,contextConfig:r,service:n,parse:o,parseContext:l,handle:(t,r)=>ei.EA(e.handle)?e.handle(t,r):j.fJG(new iD({commandPath:r,errors:[]})),buildHelpDoc:r=>{let n=[],s=[];for(let e of t.arguments){let t=sh(e),r=sm(e);for(let e of t)n.push({name:e.name,type:e.typeName??iZ(e.primitiveType),description:e.description,required:!r.isOptional,variadic:r.isVariadic})}let o=r.length>0?r.join(" "):e.name;for(let e of(a.some(e=>e.commands.some(e=>!e.hidden))&&(o+=" <subcommand>"),o+=" [flags]",n)){let t=e.variadic?`<${e.name}...>`:`<${e.name}>`;o+=` ${e.required?t:`[${t}]`}`}for(let e of t.flags)for(let t of sh(e))t.hidden||s.push(s3(t));let l=[];for(let e of a){let t=e.commands.filter(e=>!e.hidden);0!==t.length&&l.push({group:e.group,commands:J.Tj(t,e=>({name:e.name,alias:e.alias,shortDescription:e.shortDescription,description:e.description??""}))})}let c=e.examples??[];return{description:e.description??"",usage:o,flags:s,annotations:i,...n.length>0&&{args:n},...l.length>0&&{subcommands:l},...c.length>0&&{examples:c}}},...ei.EA(e.description)?{description:e.description}:{},...ei.EA(e.shortDescription)?{shortDescription:e.shortDescription}:{},...ei.EA(e.alias)?{alias:e.alias}:{}})},s3=e=>{let t=e.aliases.map(e=>1===e.length?`-${e}`:`--${e}`);return{name:e.name,aliases:t,type:e.typeName??iZ(e.primitiveType),description:s5(e.description,i0(e.primitiveType)),required:"Boolean"!==e.primitiveType._tag}},s5=(e,t)=>{if(void 0===t||0===t.length)return e;let r=`(choices: ${t.join(", ")})`;return q.match(e,{onNone:()=>q.some(r),onSome:e=>q.some(`${e} ${r}`)})},s6=e=>j.D9k(function*(t){let r={flags:t.flags,arguments:t.arguments},n=yield*s8(r,e.orderedParams);return sQ(e.tree,n)}),s8=j.D9k(function*(e,t){let r=[],n=e.arguments;for(let i of t){let[t,s]=yield*i.parse({flags:e.flags,arguments:n});r.push(s),n=t}return r}),s9=(e,t,r)=>{let n=s0(e),i=new Set;for(let e of(r?.contextConfig??n.contextConfig).flags)for(let t of sh(e))i.add(t.name);for(let r of t)for(let t of s0(r).config.flags)for(let n of sh(t))if(i.has(n.name))throw new iC({option:n.name,parentCommand:e.name,childCommand:r.name})},s4=e=>{switch(e.primitiveType._tag){case"Boolean":return{_tag:"Boolean"};case"Integer":return{_tag:"Integer"};case"Float":return{_tag:"Float"};case"Date":return{_tag:"Date"};case"Choice":return{_tag:"Choice",values:i0(e.primitiveType)??[]};case"Path":{let t=e.typeName;return{_tag:"Path",pathType:"file"===t?"file":"directory"===t?"directory":"either"}}default:return{_tag:"String"}}},s7=e=>{switch(e.primitiveType._tag){case"Integer":return{_tag:"Integer"};case"Float":return{_tag:"Float"};case"Date":return{_tag:"Date"};case"Choice":return{_tag:"Choice",values:i0(e.primitiveType)??[]};case"Path":{let t=e.typeName;return{_tag:"Path",pathType:"file"===t?"file":"directory"===t?"directory":"either"}}default:return{_tag:"String"}}},ae=e=>{let t=s0(e).config,r=[];for(let e of t.flags)for(let t of sh(e))"flag"===t.kind&&(t.hidden||r.push({name:t.name,aliases:t.aliases,description:q.getOrUndefined(t.description),type:s4(t)}));let n=[];for(let e of t.arguments){let t=sh(e),r=sm(e);for(let e of t)"argument"===e.kind&&n.push({name:e.name,description:q.getOrUndefined(e.description),required:!r.isOptional,variadic:r.isVariadic,type:s7(e)})}let i=[];for(let t of e.subcommands)for(let e of t.commands)e.hidden||i.push(ae(e));return{name:e.name,description:e.shortDescription??e.description,flags:r,arguments:n,subcommands:i}},at=e=>{let t=new Set,r=[];for(let n of e)t.has(n)||(t.add(n),r.push(n));return r},ar=(e,t)=>{let r=[e],n=e;for(let e=1;e<t.length;e++){let i,s=t[e];for(let e of n.subcommands)if(i=e.commands.find(e=>e.name===s))break;if(!i)break;r.push(i),n=i}return r},an=(e,t,r)=>at([...r,...ar(e,t).flatMap(e=>s0(e).globalFlags)]),ai=(e,t,r)=>j.JkU(function*(){let n=ar(e,t),i=s0(n.length>0?n[n.length-1]:e).buildHelpDoc(t),s=((e,t)=>{if(e.length<=1)return[];let r=new Set(t.map(e=>e.name)),n=[];for(let t of e.slice(0,-1))for(let e of s0(t).contextConfig.flags)for(let t of sh(e))!r.has(t.name)&&(t.hidden||(r.add(t.name),n.push(s3(t))));return n})(n,i.flags),a=an(e,t,r),o=[];for(let e of a)for(let t of sh(e.flag))t.hidden||o.push({...s3(t),required:!1});return{...i,flags:[...s,...i.flags],globalFlags:o}}),as=e=>({_tag:"Action",flag:e.flag,run:e.run}),aa=0,ao=as({flag:sR("help").pipe(sB("h"),sY("Show help information")),run:j.D9k(function*(e,{builtIns:t,command:r,commandPath:n}){let i=yield*sy,s=yield*ai(r,n,t);yield*iI(i.formatHelpDoc(s))})}),al=as({flag:sR("version").pipe(sB("v"),sY("Show version information")),run:j.D9k(function*(e,{command:t,version:r}){let n=yield*sy;yield*iI(n.formatVersion(t.name,r))})}),ac=as({flag:sR("wizard").pipe(sY("Start wizard mode for a command")),run:()=>j.rIH}),au=as({flag:sU("completions",["bash","zsh","fish","sh"]).pipe(sW,sJ(e=>q.map(e,e=>"sh"===e?"bash":e)),sX("<bash|zsh|fish|sh>"),sY("Print shell completion script")),run:j.D9k(function*(e,{command:t}){if(q.isNone(e))return;let r=ae(t);yield*iI(((e,t,r)=>{switch(t){case"bash":let n=[],i=sS(e);return n.push(`###-begin-${e.replace(/'/g,"'\\''")}-completions-###`),n.push("#"),n.push("# Static completion script for Bash"),n.push("#"),n.push("# Installation:"),n.push(`# ${e.replace(/'/g,"'\\''")} --completions bash >> ~/.bashrc`),n.push("#"),n.push(""),n.push("if ! type _init_completion &>/dev/null; then"),n.push(" _init_completion()"),n.push(" {"),n.push(" COMPREPLY=()"),n.push(' cur="${COMP_WORDS[COMP_CWORD]}"'),n.push(' prev="${COMP_WORDS[COMP_CWORD-1]}"'),n.push(' words=("${COMP_WORDS[@]}")'),n.push(" cword=$COMP_CWORD"),n.push(" }"),n.push("fi"),n.push(""),s$(r,[],n),n.push(`complete -F _${i} ${e.replace(/'/g,"'\\''")}`),n.push(`###-end-${e.replace(/'/g,"'\\''")}-completions-###`),n.join("\n");case"zsh":let s,a;return s=[],a=sj(e),s.push(`#compdef ${e}`),s.push(`###-begin-${e}-completions-###`),s.push("#"),s.push("# Static completion script for Zsh"),s.push("#"),s.push("# Installation:"),s.push(`# ${e} --completions zsh > ~/.zsh/completions/_${e}`),s.push("# then add ~/.zsh/completions to your fpath"),s.push("#"),s.push(""),sL(r,[],s),s.push("# Handle both direct invocation and autoload"),s.push('if [[ "${zsh_eval_context[-1]}" == "loadautofunc" ]]; then'),s.push(` _${a} "$@"`),s.push("else"),s.push(` compdef _${a} ${e}`),s.push("fi"),s.push(`###-end-${e}-completions-###`),s.join("\n");case"fish":let o;return(o=[]).push(`###-begin-${e}-completions-###`),o.push("#"),o.push("# Static completion script for Fish"),o.push("#"),o.push("# Installation:"),o.push(`# ${e} --completions fish > ~/.config/fish/completions/${e}.fish`),o.push("#"),o.push(""),sM(e,r,[],o),o.push(""),o.push(`###-end-${e}-completions-###`),o.join("\n")}})(t.name,e.value,r))})}),ad=(T="log-level",e=>(aa+=1,Object.assign(G.kl(`effect/unstable/cli/GlobalFlag/${T}/${aa}`),{_tag:"Setting",id:T,flag:e.flag})))({flag:i9("flag","log-level",[["all","All"],["trace","Trace"],["debug","Debug"],["info","Info"],["warn","Warn"],["warning","Warn"],["error","Error"],["fatal","Fatal"],["none","None"]]).pipe(sW,sY("Sets the minimum log level"),sX("<all|trace|debug|info|warn|warning|error|fatal|none>"))}),af=[ao,al,ac,au,ad];class ah extends G.Or("effect/unstable/cli/CliConfig",{defaultValue:()=>ap}){}let ap={builtIns:af},am=e=>{let t=[];for(let r of e)if(r.startsWith("-"))if(r.startsWith("--")){let[e,n]=r.slice(2).split("=",2);t.push({_tag:"LongOption",name:e,raw:r,value:n})}else if(r.length>1){let e=r.slice(1),n=e.indexOf("=");if(-1!==n){let r=e.slice(0,n),i=e.slice(n+1);t.push({_tag:"ShortOption",flag:r,raw:`-${r}`,value:i})}else for(let r of e)t.push({_tag:"ShortOption",flag:r,raw:`-${r}`})}else t.push({_tag:"Value",value:r});else t.push({_tag:"Value",value:r});return t},ag=(e,t)=>{let r=t.map(t=>[((e,t)=>{let r=e.length,n=t.length,i=Array.from({length:r+1},()=>Array(n+1).fill(0));for(let e=0;e<=r;e++)i[e][0]=e;for(let e=0;e<=n;e++)i[0][e]=e;for(let s=1;s<=r;s++)for(let r=1;r<=n;r++){let n=+(e[s-1]!==t[r-1]);i[s][r]=Math.min(i[s-1][r]+1,i[s][r-1]+1,i[s-1][r-1]+n)}return i[r][n]})(e,t),t]).filter(([e])=>e<=2).sort(([e],[t])=>e-t);if(0===r.length)return[];let n=r[0][0];return r.filter(([e])=>e===n).map(([,e])=>e)},ay=e=>q.match(e.subcommand,{onNone:()=>[],onSome:e=>[e.name,...ay(e.parsedInput)]}),ab=(e,t,r=[])=>j.JkU(function*(){let{tokens:n,trailingOperands:i}=e,s=[...r,t.name],a=s0(t),o=a.config.flags.flatMap(sh).filter(i5),l=aw(o),c=a.contextConfig.flags.flatMap(sh).filter(i5),u=aw(c),d=new Set(c.map(e=>e.name)),f=aj(n,{command:t,commandPath:s,flagRegistry:l,inheritedFlagRegistry:u,localFlagNames:o.filter(e=>!d.has(e.name)).map(e=>e.name)});if("Leaf"===f._tag)return{flags:f.flags,arguments:[...f.arguments,...i],subcommand:q.none(),...f.errors.length>0&&{errors:f.errors}};let h={tokens:f.childTokens,trailingOperands:[]},p=yield*ab(h,f.sub,s),m=[...f.errors,...p.errors??[]];return{flags:f.flags,arguments:i,subcommand:q.some({name:f.sub.name,parsedInput:p}),...m.length>0&&{errors:m}}}),av=e=>{let t=0;return{peek:()=>e[t],take:()=>e[t++],rest:()=>e.slice(t)}},aw=e=>{let t=new Map;for(let r of e){if(t.has(r.name))throw Error(`Duplicate flag name "${r.name}" in command definition`);for(let e of(t.set(r.name,r),r.aliases)){if(t.has(e))throw Error(`Duplicate flag/alias "${e}" in command definition (conflicts with "${t.get(e).name}")`);t.set(e,r)}}return{params:e,index:t}},ax=e=>{let t=new Map,r=(e,r)=>{let n=t.get(e);if(n&&n!==r)throw Error(`Duplicate subcommand name/alias "${e}" in command definition (conflicts with "${n.name}")`);t.set(e,r)};for(let t of e)for(let e of t.commands)r(e.name,e),e.alias&&e.alias!==e.name&&r(e.alias,e);return t},ak=e=>Object.fromEntries(e.map(e=>[e.name,[]])),aS=e=>"LongOption"===e._tag||"ShortOption"===e._tag,a_=e=>"LongOption"===e._tag?e.name:e.flag,aO=(e,t)=>{let r=a_(e),n=t.index.get(r);if(n&&n.name===r)return{param:n,negated:!1};if("LongOption"===e._tag&&e.name.startsWith("no-")){let r=e.name.slice(3),n=t.index.get(r);if(n&&n.name===r&&iG(n.primitiveType))return{param:n,negated:!0}}if(n)return{param:n,negated:!1}},aI=(e,t,r)=>new iN({option:t.name,value:r,expected:`omit the value and use ${e.raw} by itself to set --${t.name} to false`,kind:"flag"}),a$=e=>e?._tag==="Value"&&(iK(e.value)||iV(e.value))?e.value:void 0,aE=(e,t,r,n=!1)=>{let i=aC(e,t,r,n);switch(i._tag){case"Value":return{_tag:"Value",value:i.value};case"Error":return{_tag:"Error",error:i.error}}},aC=(e,t,r,n=!1)=>{let i;if(n){if(void 0!==t.value)return{_tag:"Error",error:aI(t,r,t.value),tokens:[]};let n=a$(e.peek());if(void 0!==n){let i=e.take();return{_tag:"Error",error:aI(t,r,n),tokens:void 0===i?[]:[i]}}return{_tag:"Value",value:"false",tokens:[]}}if(void 0!==t.value)return{_tag:"Value",value:t.value,tokens:[]};if(iG(r.primitiveType)){let t=a$(e.peek()),r=void 0!==t?e.take():void 0;return{_tag:"Value",value:t??"true",tokens:void 0===r?[]:[r]}}let s=e.peek();if(s?._tag==="Value"){let t=e.take();return{_tag:"Value",value:s.value,tokens:void 0===t?[]:[t]}}return{_tag:"Error",error:(i=i0(r.primitiveType),new iN({option:r.name,value:"",expected:void 0===i?r.typeName??iZ(r.primitiveType):i.join(" | "),kind:"flag"})),tokens:[]}},aA=(e,t)=>{for(let r of t){let t=aO(e,r);if(void 0!==t)return t}},aT=(e,t,r,n)=>{e.push(r);let i=aC(t,r,n.param,n.negated);e.push(...i.tokens)},aN=(e,t,r,n,i)=>{let s=av(t);aC(s,e,r.param,r.negated);for(let e=s.take();e;e=s.take()){if(aS(e)){let t=aA(e,i);void 0!==t&&aC(s,e,t.param,t.negated);continue}if("Value"===e._tag)return n.has(e.value)}return!1},aM=(e,t,r,n)=>{let{commandPath:i,flagRegistry:s}=r,a=aO(e,s);if(!a)return void n.errors.push(((e,t,r)=>{let n="LongOption"===e._tag?`--${e.name}`:`-${e.flag}`,i=[];for(let e of t)if(!e.hidden)for(let t of(i.push(e.name),iG(e.primitiveType)&&i.push(`no-${e.name}`),e.aliases))i.push(t);return new iE({option:n,suggestions:ag(a_(e),i).map(e=>1===e.length?`-${e}`:`--${e}`),command:r})})(e,s.params,i));let o=aE(t,e,a.param,a.negated);"Error"===o._tag?n.errors.push(o.error):n.flags.add(a.param.name,o.value)},aP=(e,t,r,n)=>{if("AwaitingFirstValue"===n.mode._tag){let i=((e,t,r,n)=>{let{command:i,commandPath:s,inheritedFlagRegistry:a,localFlagNames:o}=r,l=ax(i.subcommands),c=l.get(e);if(c){let e=[...s,c.name],r=n.flags.snapshot();for(let t of o){let i=r[t];void 0!==i&&i.length>0&&n.errors.push(new iE({option:`--${t}`,suggestions:[],command:e}))}let i=((e,t)=>{let r=ak(t.params),n=[],i=[],s=av(e);for(let e=s.take();e;e=s.take()){if(!aS(e)){n.push(e);continue}let a=aO(e,t);if(!a){n.push(e);continue}let o=aE(s,e,a.param,a.negated);if("Error"===o._tag){i.push(o.error);continue}void 0!==o.value&&r[a.param.name].push(o.value)}return{flagMap:r,remainder:n,errors:i}})(t.rest(),a);return n.flags.merge(i.flagMap),n.errors.push(...i.errors),{_tag:"Subcommand",result:{_tag:"Sub",flags:n.flags.snapshot(),sub:c,childTokens:i.remainder,errors:n.errors}}}if(!(s0(i).config.arguments.length>0)&&l.size>0){let t=[];for(let[e,r]of l)r.hidden||t.push(e);let r=ag(e,t);n.errors.push(new iM({subcommand:e,parent:s,suggestions:r}))}return{_tag:"Argument"}})(e,t,r,n);if("Subcommand"===i._tag)return i.result;n.mode={_tag:"CollectingArguments"}}n.arguments.push(e)},aj=(e,t)=>{let r,n=av(e),i={flags:(r=ak(t.flagRegistry.params),{add:(e,t)=>{void 0!==t&&r[e].push(t)},merge:e=>{for(let t in e){let n=e[t];if(n?.length)for(let e=0;e<n.length;e++)r[t].push(n[e])}},snapshot:()=>r}),arguments:[],errors:[],mode:{_tag:"AwaitingFirstValue"}};for(let e=n.take();e;e=n.take()){if(aS(e)){aM(e,n,t,i);continue}if("Value"===e._tag){let r=aP(e.value,n,t,i);if(r)return r}}return{_tag:"Leaf",flags:i.flags.snapshot(),arguments:i.arguments,errors:i.errors}};var aD=n(8036),aF=n(4450);let aL=new WeakMap,aR="~effect/data/Redacted",aU=(e,t)=>{let r=Object.create(aB);return t?.label&&(r.label=t.label),aL.set(r,e),r},aB={[aR]:{_A:e=>e},label:void 0,...ea.fU,toJSON(){return this.toString()},toString(){return`<redacted${(0,ei.Kg)(this.label)?":"+this.label:""}>`},[aF.HR](){return aF.tW(aL.get(this))},[aD.HR](e){return(0,ei.i5)(e,aR)&&aD.aI(aL.get(this),aL.get(e))}},aY=e=>{if(aL.has(e))return aL.get(e);throw Error("Unable to get redacted value"+(e.label?` with label: "${e.label}"`:""))};var aX=n(1044),aW=n(6364);ei.Et,aW.wN,aX.wN;let aJ=(0,F.XY)(2,(e,t)=>{let r=Math.pow(10,t);return Math.round(e*r)/r}),aq=(e,...t)=>{let r=t.flat();return`${r.join("")}${e}`},aK={arrowUp:"↑",arrowDown:"↓",arrowLeft:"←",arrowRight:"→",radioOn:"◉",radioOff:"◯",checkboxOn:"☒",checkboxOff:"☐",tick:"✔",cross:"✖",ellipsis:"…",pointerSmall:"›",line:"─",pointer:"❯"},aV={arrowUp:aK.arrowUp,arrowDown:aK.arrowDown,arrowLeft:aK.arrowLeft,arrowRight:aK.arrowRight,radioOn:"(*)",radioOff:"( )",checkboxOn:"[*]",checkboxOff:"[ ]",tick:"√",cross:"×",ellipsis:"...",pointerSmall:"»",line:"─",pointer:">"},aG=j.TjK(j.OH5(()=>"win32"===process.platform),e=>e?aV:aK),aH=e=>aq(e,"\x1b[1m"),az=e=>aq(e,((...e)=>e)("\x1b[3m","\x1b[31m")),aQ=e=>{let t={initial:!1,...e,label:{confirm:"yes",deny:"no",...e.label},placeholder:{defaultConfirm:"(Y/n)",defaultDeny:"(y/N)",...e.placeholder}};return aZ({value:t.initial},{render:ol(t),process:e=>od(e,t.initial),clear:oi(t)})},aZ=(e,...t)=>{let[r,n]=1===t.length?[void 0,t[0]]:[t[0],t[1]],i=Object.create(a9);return i._tag="Loop",i.initialState=e,i.render=n.render,i.process=n.process,i.clear=n.clear,i.events=r,i},a0=(0,F.XY)(2,(e,t)=>{let r=Object.create(a9);return r._tag="OnSuccess",r.prompt=e,r.onSuccess=t,r}),a1=e=>{let t={default:0,min:-1/0,max:1/0,incrementBy:1,decrementBy:1,validate:e=>e<t.min?j.fJG(`${e} must be greater than or equal to ${t.min}`):e>t.max?j.fJG(`${e} must be less than or equal to ${t.max}`):j.PyW(e),...e},r=void 0===e.default?"":`${t.default}`;return aZ({cursor:r.length,value:r,error:q.none()},{render:oL(t),process:oR(t),clear:oT(t)})},a2=(0,F.XY)(2,(e,t)=>a0(e,e=>a6(t(e)))),a3=j.D9k(function*(e){let t=yield*ne,r=yield*t.readInput;return yield*a4(e,t,r)},j.xm_(()=>new r7({})),j.P1j),a5=e=>{let t={maxPerPage:10,...e};return aZ((e=>{let t=0,r=-1;for(let t=0;t<e.length;t++)if(!0===e[t].selected){if(-1!==r)throw Error("InvalidArgumentException: only a single choice can be selected by default for Prompt.select");r=t}return -1!==r&&(t=r),t})(t.choices),{render:oq(t),process:oV(t),clear:oK(t)})},a6=e=>{let t=Object.create(a9);return t._tag="Succeed",t.value=e,t},a8=e=>{let t={initial:!1,active:"on",inactive:"off",...e};return aZ(t.initial,{render:le(t),process:lt,clear:()=>o3(t)})},a9={...t_.b({label:"Prompt",evaluate(){return a3(this)}}),"~effect/cli/Prompt":{_Output:e=>e}},a4=(e,t,r)=>j.DYE(()=>{switch(e._tag){case"Loop":return a7(e,t,r);case"OnSuccess":return j.qIB(a4(e.prompt,t,r),n=>a4(e.onSuccess(n),t,r));case"Succeed":return j.PyW(e.value)}}),a7=j.D9k(function*(e,t,r){let n=j.yw5(e.initialState)?yield*e.initialState:e.initialState,i=oe.NextFrame({state:n});for(;;){let s=yield*e.render(n,i);if(yield*j.QgK(t.display(s)),e.events){let t=e_(r).pipe(j.TjK(e=>({_tag:"Input",input:e}))),s=yield*j.KT6(t,e_(e.events).pipe(j.TjK(e=>({_tag:"Event",value:e}))));i=yield*e.process(s,n)}else{let t=yield*e_(r);i=yield*e.process(t,n)}switch(i._tag){case"Beep":continue;case"NextFrame":yield*j.QgK(t.display((yield*e.clear(n,i)))),n=i.state;continue;case"Submit":{yield*j.QgK(t.display((yield*e.clear(n,i))));let r=yield*e.render(n,i);return yield*j.QgK(t.display(r)),i.value}}}},(e,t,r)=>j.yeE(e,j.QgK(r.display("\x1b[?25h")))),oe=H.Ij(),ot=(e,t)=>{if(0===t){var r;return"\x1b[2K"+(void 0===r?`\x1b${Math.max(1,0)} G`:`\x1b${r+1};${Math.max(1,0)} H`)}let n=0;for(let r of e.split(on))n+=1+Math.floor(Math.max(r.length-1,0)/t);var i=n;let s="";for(let e=0;e<i;e++)s+="\x1b[2K"+(e<i-1?"\x1b[1A":"");return i>0&&(s+="\x1b[G"),s},or=(e,t,r)=>{if(void 0!==r&&r.length>0){let n;return((e=1)=>`\x1b[${e}B`)((n=r.split(on),0===t?n.length:(0,F.Fs)(J.Tj(n,e=>Math.ceil(e.length/t)),J.TS(0,(e,t)=>e+t))))+ot(`
15
+ ${r}`,t)+ot(e,t)}return ot(e,t)},on=/\r?\n/,oi=e=>j.D9k(function*(t,r){let n=yield*ne,i=yield*n.columns,s=yield*aG;return ot(os(t.value?e.placeholder.defaultConfirm:e.placeholder.defaultDeny,"?",s.pointerSmall,e,{plain:!0}),i)+"\x1b[2K\x1b[G"}),os=(e,t,r,n,i)=>oC(e,n.message,t,r,i),oa=j.D9k(function*(e,t){let r=yield*aG,n=aq("?","\x1b[96m"),i=aq(r.pointerSmall,"\x1b[90m");return"\x1b[?25l"+os(aq(e.value?t.placeholder.defaultConfirm:t.placeholder.defaultDeny,"\x1b[90m"),n,i,t)}),oo=j.D9k(function*(e,t){let r=yield*aG,n=aq(r.tick,"\x1b[32m"),i=aq(r.ellipsis,"\x1b[90m");return os(e?t.label.confirm:t.label.deny,n,i,t)+"\n"}),ol=e=>(t,r)=>oe.$match(r,{Beep:()=>j.PyW("\x07"),NextFrame:({state:t})=>oa(t,e),Submit:({value:t})=>oo(t,e)}),oc=/^y|t$/,ou=/^n|f$/,od=(e,t)=>{let r=q.getOrElse(e.input,()=>"");return"enter"===e.key.name||"return"===e.key.name?j.PyW(oe.Submit({value:t})):oc.test(r.toLowerCase())?j.PyW(oe.Submit({value:!0})):ou.test(r.toLowerCase())?j.PyW(oe.Submit({value:!1})):j.PyW(oe.Beep())},of=(e,t=!1)=>J.TS(e.dateParts,"",(r,n,i)=>{let s=n.toString();return i!==e.cursor||t?r+s:r+aq(s,((...e)=>e)("\x1b[4m","\x1b[96m"))}),oh=(e,t,r,n,i)=>oC(r,n.message,e,t,i),op=j.D9k(function*(e,t){let r=yield*aG;return"\x1b[?25l"+oh(aq("?","\x1b[96m"),aq(r.pointerSmall,"\x1b[90m"),of(e),t)+((e,t)=>{if(q.isSome(e.error)){let r=e.error.value.split(on);if(J.ET(r))return"\x1b[s\n"+(aq(t,"\x1b[31m")+" ")+J.Tj(r,e=>az(e)).join("\n")+"\x1b[u"}return""})(e,r.pointerSmall)}),om=j.D9k(function*(e,t){let r=yield*aG;return oh(aq(r.tick,"\x1b[32m"),aq(r.ellipsis,"\x1b[90m"),of(e,!0),t)+"\n"}),og={months:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],weekdays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],weekdaysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]},oy=/\\(.)|"((?:\\["\\]|[^"])+)"|(D[Do]?|d{3,4}|d)|(M{1,4})|(YY(?:YY)?)|([aA])|([Hh]{1,2})|(m{1,2})|(s{1,2})|(S{1,4})|./g,ob={1:({token:e,...t})=>new ow({token:e.replace(/\\(.)/g,"$1"),...t}),2:e=>new oO(e),3:e=>new oI(e),4:e=>new o$(e),5:e=>new oE(e),6:e=>new o_(e),7:e=>new oS(e),8:e=>new ok(e),9:e=>new ox(e)};class ov{token;date;parts;locales;constructor(e){this.token=e.token,this.locales=e.locales,this.date=e.date||new Date,this.parts=e.parts||[this]}isToken(){return!1}nextPart(){let e=q.getOrElse(J.g9(this.parts,e=>e===this),()=>0);return J.i8(this.parts.slice(e+1),e=>!e.isToken())}previousPart(){let e=J.g9(this.parts,e=>e===this);return q.isSome(e)?J.Uk(this.parts.slice(0,e.value),e=>!e.isToken()):q.none()}toString(){return String(this.date)}}class ow extends ov{increment(){}decrement(){}setValue(e){this.token=this.token+e}isToken(){return!0}toString(){return this.token}}class ox extends ov{increment(){this.date.setMilliseconds(this.date.getMilliseconds()+1)}decrement(){this.date.setMilliseconds(this.date.getMilliseconds()-1)}setValue(e){this.date.setMilliseconds(Number.parseInt(e.slice(-this.token.length)))}toString(){return`${this.date.getMilliseconds()}`.padStart(4,"0").substring(0,this.token.length)}}class ok extends ov{increment(){this.date.setSeconds(this.date.getSeconds()+1)}decrement(){this.date.setSeconds(this.date.getSeconds()-1)}setValue(e){this.date.setSeconds(Number.parseInt(e.slice(-2)))}toString(){let e=`${this.date.getSeconds()}`;return this.token.length>1?e.padStart(2,"0"):e}}class oS extends ov{increment(){this.date.setMinutes(this.date.getMinutes()+1)}decrement(){this.date.setMinutes(this.date.getMinutes()-1)}setValue(e){this.date.setMinutes(Number.parseInt(e.slice(-2)))}toString(){let e=`${this.date.getMinutes()}`;return this.token.length>1?e.padStart(2,"0"):e}}class o_ extends ov{increment(){this.date.setHours(this.date.getHours()+1)}decrement(){this.date.setHours(this.date.getHours()-1)}setValue(e){this.date.setHours(Number.parseInt(e.slice(-2)))}toString(){let e=/h/.test(this.token)?this.date.getHours()%12||12:this.date.getHours();return this.token.length>1?`${e}`.padStart(2,"0"):`${e}`}}class oO extends ov{increment(){this.date.setDate(this.date.getDate()+1)}decrement(){this.date.setDate(this.date.getDate()-1)}setValue(e){this.date.setDate(Number.parseInt(e.slice(-2)))}toString(){let e=this.date.getDate(),t=this.date.getDay();switch(this.token){case"DD":return`${e}`.padStart(2,"0");case"Do":return`${e}${this.ordinalIndicator(e)}`;case"d":return`${t+1}`;case"ddd":return this.locales.weekdaysShort[t];case"dddd":return this.locales.weekdays[t];default:return`${e}`}}ordinalIndicator(e){switch(e%10){case 1:return"st";case 2:return"nd";case 3:return"rd";default:return"th"}}}class oI extends ov{increment(){this.date.setMonth(this.date.getMonth()+1)}decrement(){this.date.setMonth(this.date.getMonth()-1)}setValue(e){let t=Number.parseInt(e.slice(-2))-1;this.date.setMonth(t<0?0:t)}toString(){let e=this.date.getMonth();switch(this.token.length){case 2:return`${e+1}`.padStart(2,"0");case 3:return this.locales.monthsShort[e];case 4:return this.locales.months[e];default:return`${e+1}`}}}class o$ extends ov{increment(){this.date.setFullYear(this.date.getFullYear()+1)}decrement(){this.date.setFullYear(this.date.getFullYear()-1)}setValue(e){this.date.setFullYear(Number.parseInt(e.slice(-4)))}toString(){let e=`${this.date.getFullYear()}`.padStart(4,"0");return 2===this.token.length?e.substring(-2):e}}class oE extends ov{increment(){this.date.setHours((this.date.getHours()+12)%24)}decrement(){this.increment()}setValue(e){}toString(){let e=this.date.getHours()>12?"pm":"am";return/A/.test(this.token)?e.toUpperCase():e}}let oC=(e,t,r,n,i)=>{let s=r+" ",a=i?.plain===!0?e=>e:aH;return J.YW(t.split(on),{onEmpty:()=>s+" "+n+" "+e,onNonEmpty:t=>s+J.Tj(t,e=>a(e)).join("\n")+" "+n+" "+e})},oA=(e,t,r)=>!e.disabled&&e.description&&t?r?.plain===!0?"- "+e.description:aq("- "+e.description,"\x1b[90m"):"",oT=e=>j.D9k(function*(t,r){let n=yield*ne,i=yield*n.columns,s=yield*aG,a=oN(t,s.pointerSmall,{plain:!0});return or(oM(t,"?",s.pointerSmall,e,{plain:!0}),i,a)+"\x1b[2K\x1b[G"}),oN=(e,t,r)=>q.isSome(e.error)?J.YW(e.error.value.split(on),{onEmpty:()=>"",onNonEmpty:e=>r?.plain===!0?`${t} ${e.join("\n")}`:"\x1b[s\n"+(aq(t,"\x1b[31m")+" ")+J.Tj(e,e=>az(e)).join("\n")+"\x1b[u"}):"",oM=(e,t,r,n,i,s=!1)=>{let a;return oC((a=""===e.value?"":`${e.value}`,s||i?.plain===!0?a:aq(a,q.isSome(e.error)?"\x1b[31m":((...e)=>e)("\x1b[4m","\x1b[96m"))),n.message,t,r,i)},oP=j.D9k(function*(e,t){let r=yield*aG,n=aq("?","\x1b[96m"),i=aq(r.pointerSmall,"\x1b[90m"),s=oN(e,r.pointerSmall);return oM(e,n,i,t)+s}),oj=j.D9k(function*(e,t){let r=yield*aG;return oM(e,aq(r.tick,"\x1b[32m"),aq(r.ellipsis,"\x1b[90m"),t,void 0,!0)+"\n"}),oD=e=>{if(e.value.length<=0)return j.PyW(oe.Beep());let t=e.value.slice(0,e.value.length-1);return j.PyW(oe.NextFrame({state:{...e,value:t,error:q.none()}}))},oF=e=>j.PyW(oe.NextFrame({state:{...e,cursor:0,value:"",error:q.none()}})),oL=e=>(t,r)=>oe.$match(r,{Beep:()=>j.PyW("\x07"),NextFrame:({state:t})=>oP(t,e),Submit:()=>oj(t,e)}),oR=e=>(t,r)=>{if(t.key.ctrl&&"u"===t.key.name)return oF(r);switch(t.key.name){case"backspace":return oD(r);case"k":case"up":return j.PyW(oe.NextFrame({state:{...r,value:""===r.value||"-"===r.value?`${e.incrementBy}`:`${Number.parseInt(r.value)+e.incrementBy}`,error:q.none()}}));case"j":case"down":return j.PyW(oe.NextFrame({state:{...r,value:""===r.value||"-"===r.value?`-${e.decrementBy}`:`${Number.parseInt(r.value)-e.decrementBy}`,error:q.none()}}));case"enter":case"return":{let t=Number.parseInt(r.value);if(Number.isNaN(t))return j.PyW(oe.NextFrame({state:{...r,error:q.some("Must provide an integer value")}}));return j.YWq(e.validate(t),{onFailure:e=>oe.NextFrame({state:{...r,error:q.some(e)}}),onSuccess:e=>oe.Submit({value:e})})}default:var n=q.getOrElse(t.input,()=>"");if(0===r.value.length&&"-"===n)return j.PyW(oe.NextFrame({state:{...r,value:"-",error:q.none()}}));let i=Number.parseInt(r.value+n);return Number.isNaN(i)?j.PyW(oe.Beep()):j.PyW(oe.NextFrame({state:{...r,value:`${i}`,error:q.none()}}))}},oU=(e,t,r,n)=>oC("",r.message,e,t,n),oB=(e,t,r,n,i,s)=>{let a=" ";if(n===r.startIndex&&r.startIndex>0?a=i.arrowUp:n===r.endIndex-1&&r.endIndex<t.length&&(a=i.arrowDown),s?.plain===!0)return e===n?i.pointer+a:a+" ";if(t[n].disabled){let t=((...e)=>e)("\x1b[1m","\x1b[90m");return e===n?aq(i.pointer,t)+a:a+" "}return e===n?aq(i.pointer,"\x1b[96m")+a:a+" "},oY=(e,t,r)=>{if(r?.plain===!0)return e.title;let n=e.title;return t?e.disabled?aq(n,((...e)=>e)("\x1b[4m","\x1b[90m")):aq(n,((...e)=>e)("\x1b[4m","\x1b[96m")):e.disabled?aq(n,((...e)=>e)("\x1b[9m","\x1b[90m")):n},oX=(e,t,r,n)=>{let i=t.choices,s=lr(e,i.length,t.maxPerPage),a=[];for(let t=s.startIndex;t<s.endIndex;t++){let o=i[t],l=e===t,c=oB(e,i,s,t,r,n),u=oY(o,l,n),d=oA(o,l,n);a.push(c+u+" "+d)}return a.join("\n")},oW=j.D9k(function*(e,t){let r=yield*aG,n=oX(e,t,r);return"\x1b[?25l"+oU(aq("?","\x1b[96m"),aq(r.pointerSmall,"\x1b[90m"),t)+"\n"+n}),oJ=j.D9k(function*(e,t){let r=yield*aG,n=t.choices[e].title;return oU(aq(r.tick,"\x1b[32m"),aq(r.ellipsis,"\x1b[90m"),t)+" "+aq(n,"\x1b[37m")+"\n"}),oq=e=>(t,r)=>oe.$match(r,{Beep:()=>j.PyW("\x07"),NextFrame:({state:t})=>oW(t,e),Submit:()=>oJ(t,e)}),oK=e=>j.D9k(function*(t,r){let n=yield*ne,i=yield*n.columns,s=yield*aG,a=oU("?",s.pointerSmall,e,{plain:!0}),o=oX(t,e,s,{plain:!0});return ot(`${a}
16
+ ${o}`,i)+"\x1b[2K\x1b[G"}),oV=e=>(t,r)=>{var n;switch(t.key.name){case"k":case"up":return n=e.choices,0===r?j.PyW(oe.NextFrame({state:n.length-1})):j.PyW(oe.NextFrame({state:r-1}));case"j":case"down":return r===e.choices.length-1?j.PyW(oe.NextFrame({state:0})):j.PyW(oe.NextFrame({state:r+1}));case"tab":let i;return i=e.choices,j.PyW(oe.NextFrame({state:(r+1)%i.length}));case"enter":case"return":{let t=e.choices[r];if(t.disabled)return j.PyW(oe.Beep());return j.PyW(oe.Submit({value:t.value}))}default:return j.PyW(oe.Beep())}},oG=j.D9k(function*(e,t){let r=yield*ne,n=yield*r.columns,i=yield*aG,s=oH(e,i.pointerSmall,{plain:!0});return or(oz(e,"?",i.pointerSmall,t,{plain:!0}),n,s)+"\x1b[2K\x1b[G"}),oH=(e,t,r)=>q.isSome(e.error)?J.YW(e.error.value.split(on),{onEmpty:()=>"",onNonEmpty:e=>r?.plain===!0?`${t} ${e.join("\n")}`:"\x1b[s\n"+(aq(t,"\x1b[31m")+" ")+J.Tj(e,e=>az(e)).join("\n")+"\x1b[u"}):"",oz=(e,t,r,n,i,s=!1)=>oC(((e,t,r,n)=>{let i=e.value;if(n?.plain===!0)switch(t.type){case"hidden":return"";case"password":return"*".repeat(i.length);case"text":return i}let s=q.isSome(e.error)?"\x1b[31m":r?"\x1b[37m":0===e.value.length?"\x1b[90m":((...e)=>e)("\x1b[4m","\x1b[96m");switch(t.type){case"hidden":return"";case"password":return aq("*".repeat(i.length),s);case"text":return aq(i,s)}})(e,n,s,i),n.message,t,r,i),oQ=j.D9k(function*(e,t){let r=yield*aG;return oz(e,aq("?","\x1b[96m"),aq(r.pointerSmall,"\x1b[90m"),t)+oH(e,r.pointerSmall)+((e,t=0)=>{let r="";return t<0&&(r+=`\x1b[${-t}A`),t>0&&(r+=`\x1b[${t}B`),e>0&&(r+=`\x1b[${e}C`),e<0&&(r+=`\x1b[${-e}D`),r})(e.cursor-e.value.length)}),oZ=j.D9k(function*(e,t){let r=yield*aG;return oz(e,aq(r.tick,"\x1b[32m"),aq(r.ellipsis,"\x1b[90m"),t,void 0,!0)+"\n"}),o0=e=>j.PyW(oe.NextFrame({state:{...e,cursor:0,error:q.none()}})),o1=e=>j.PyW(oe.NextFrame({state:{...e,cursor:e.value.length,error:q.none()}})),o2=(e,t)=>{let r={default:"",type:t,validate:j.PyW,...e};return aZ({cursor:r.default.length,value:r.default,error:q.none()},{render:(e,t)=>oe.$match(t,{Beep:()=>j.PyW("\x07"),NextFrame:({state:e})=>oQ(e,r),Submit:()=>oZ(e,r)}),process:(e,t)=>{if(e.key.ctrl)switch(e.key.name){case"u":return j.PyW(oe.NextFrame({state:{...t,cursor:0,value:"",error:q.none()}}));case"a":return o0(t);case"e":return o1(t);default:return j.PyW(oe.Beep())}switch(e.key.name){case"backspace":var n;if(t.cursor<=0)return j.PyW(oe.Beep());let i=t.value.slice(0,t.cursor-1),s=t.value.slice(t.cursor),a=t.cursor-1,o=`${i}${s}`;return j.PyW(oe.NextFrame({state:{...t,cursor:a,value:o,error:q.none()}}));case"left":if(t.cursor<=0)return j.PyW(oe.Beep());let l=t.cursor-1;return j.PyW(oe.NextFrame({state:{...t,cursor:l,error:q.none()}}));case"right":if(t.cursor>=t.value.length)return j.PyW(oe.Beep());let c=Math.min(t.cursor+1,t.value.length);return j.PyW(oe.NextFrame({state:{...t,cursor:c,error:q.none()}}));case"home":return o0(t);case"end":return o1(t);case"enter":case"return":{let e=t.value;return j.YWq(r.validate(e),{onFailure:r=>oe.NextFrame({state:{...t,value:e,error:q.some(r)}}),onSuccess:e=>oe.Submit({value:e})})}case"tab":if(t.value===r.default)return j.PyW(oe.Beep());let u=0===t.value.length?r.default:t.value;return j.PyW(oe.NextFrame({state:{...t,value:u,cursor:u.length,error:q.none()}}));default:let d,f,h,p;return n=q.getOrElse(e.input,()=>""),d=t.value.slice(0,t.cursor),f=t.value.slice(t.cursor),h=`${d}${n}${f}`,p=t.cursor+n.length,j.PyW(oe.NextFrame({state:{...t,cursor:p,value:h,error:q.none()}}))}},clear:(e,t)=>oG(e,r)})},o3=j.D9k(function*(e){let t=yield*ne,r=yield*t.columns,n=yield*aG;return ot(oC(`${e.active} / ${e.inactive}`,e.message,"?",n.pointerSmall,{plain:!0}),r)+"\x1b[2K\x1b[G"}),o5=(e,t,r=!1)=>{let n=aq("/","\x1b[90m"),i=((...e)=>e)("\x1b[4m",r?"\x1b[37m":"\x1b[96m"),s=e?t.inactive:aq(t.inactive,i);return(e?aq(t.active,i):t.active)+" "+n+" "+s},o6=(e,t,r,n)=>{let i=n.message.split(on),s=t+" ";return J.ET(i)?s+J.Tj(i,e=>aH(e)).join("\n")+" "+r+" "+e:s+" "+r+" "+e},o8=j.D9k(function*(e,t){let r=yield*aG,n=aq("?","\x1b[96m"),i=aq(r.pointerSmall,"\x1b[90m");return"\x1b[?25l"+o6(o5(e,t),n,i,t)}),o9=j.D9k(function*(e,t){let r=yield*aG,n=aq(r.tick,"\x1b[32m"),i=aq(r.ellipsis,"\x1b[90m");return o6(o5(e,t,!0),n,i,t)+"\n"}),o4=j.PyW(oe.NextFrame({state:!0})),o7=j.PyW(oe.NextFrame({state:!1})),le=e=>(t,r)=>{switch(r._tag){case"Beep":return j.PyW("\x07");case"NextFrame":return o8(t,e);case"Submit":return o9(t,e)}},lt=(e,t)=>{switch(e.key.name){case"0":case"j":case"delete":case"right":case"down":return o7;case"1":case"k":case"left":case"up":return o4;case" ":case"tab":return t?o7:o4;case"enter":case"return":return j.PyW(oe.Submit({value:t}));default:return j.PyW(oe.Beep())}},lr=(e,t,r)=>{let n=void 0===r?t:r,i=Math.min(t-n,e-Math.floor(n/2));i<0&&(i=0);let s=Math.min(i+n,t);return{startIndex:i,endIndex:s}},ln=j.D9k(function*(e,t){let r=t?.commandPath??[e.name],n=li(e,r),i=[...t?.prefix??r];return yield*lf(i),yield*ls(n,i,n===e?"ROOT":n.name),i}),li=(e,t)=>{let r=e;for(let e of t.slice(1)){let t=r.subcommands.flatMap(e=>e.commands).find(t=>t.name===e||t.alias===e);if(void 0===t)break;r=t}return r},ls=j.D9k(function*(e,t,r){let n=s0(e),i=e.subcommands.flatMap(e=>e.commands.filter(e=>!e.hidden)),s=0===i.length?n.config:n.contextConfig;if(s.flags.length>0){for(let e of(yield*iI(lh(r,"FLAGS")),s.flags))t.push(...yield*lo(e));(s.arguments.length>0||i.length>0)&&(yield*lf(t))}if(s.arguments.length>0){for(let e of(yield*iI(lh(r,"ARGUMENTS")),s.arguments))t.push(...yield*lo(e));i.length>0&&(yield*lf(t))}if(0===i.length)return;let a=yield*a3(a5({message:"Command",choices:i.map(e=>({title:e.name,value:e,...void 0!==e.shortDescription?{description:e.shortDescription}:void 0!==e.description?{description:e.description}:{}}))}));yield*iI(),t.push(a.name),la(a)&&(yield*lf(t)),yield*ls(a,t,a.name)}),la=e=>e.subcommands.some(e=>e.commands.some(e=>!e.hidden))||s0(e).config.orderedParams.length>0,lo=j.D9k(function*(e){let t=sp(e),r=sm(e);if(r.isOptional&&!(yield*a3(aQ({message:`Set ${lu(t)}?`,initial:!1}))))return yield*iI(),[];let n=r.isVariadic?yield*a3(a1({message:`${lu(t)} count`,default:q.getOrElse(r.variadicMin,()=>0),min:q.getOrElse(r.variadicMin,()=>0),...q.isSome(r.variadicMax)?{max:r.variadicMax.value}:{}})):1,i=[];for(let e=0;e<n;e++)i.push((yield*ll(t)));let s="flag"===t.kind?{flags:{[t.name]:i},arguments:[]}:{flags:{},arguments:i};return(yield*e.parse(s),yield*iI(),t.kind===i2)?i:i.flatMap(e=>[`--${t.name}`,e])}),ll=e=>{var t,r;let n=lc(e);switch(e.primitiveType._tag){case"Boolean":return j.TjK(a3(aQ({message:n,label:{confirm:"true",deny:"false"},placeholder:{defaultConfirm:"(T/f)",defaultDeny:"(t/F)"}})),String);case"Choice":return a3(a5({message:n,choices:(i0(e.primitiveType)??[]).map(e=>({title:e,value:e}))}));case"Date":let i,s,a,o,l,c;return j.TjK(a3((t={message:n},a=(s=((e,t,r)=>{let n=[],i=null;for(;i=oy.exec(e);){let e=i.shift(),s=i.findIndex(e=>void 0!==e);if(s in ob){let a=i[s]||e;n.push(ob[s]({token:a,date:t,parts:n,locales:r}))}else n.push(new ow({token:i[s]||e,date:t,parts:n,locales:r}))}let s=n.reduce((e,t)=>{let r=e[e.length-1];return t.isToken()&&void 0!==r&&r.isToken()?r.setValue(t.token):e.push(t),e},J.Ie());return n.splice(0,n.length,...s),n})((i={initial:new Date,dateMask:"YYYY-MM-DD HH:mm:ss",validate:j.PyW,...t,locales:{...og,...t.locales}}).dateMask,i.initial,i.locales)).findIndex(e=>!e.isToken()),aZ({dateParts:s,typed:"",cursor:a,value:i.initial,error:q.none()},{render:(o=i,(e,t)=>oe.$match(t,{Beep:()=>j.PyW("\x07"),NextFrame:({state:e})=>op(e,o),Submit:()=>om(e,o)})),process:(l=i,(e,t)=>{switch(e.key.name){case"left":let r;return j.PyW((r=t.dateParts[t.cursor].previousPart(),q.isSome(r)?oe.NextFrame({state:{...t,typed:"",cursor:t.dateParts.indexOf(r.value)}}):oe.Beep()));case"right":let n;return j.PyW((n=t.dateParts[t.cursor].nextPart(),q.isSome(n)?oe.NextFrame({state:{...t,typed:"",cursor:t.dateParts.indexOf(n.value)}}):oe.Beep()));case"k":case"up":return j.PyW((t.dateParts[t.cursor].increment(),oe.NextFrame({state:{...t,typed:""}})));case"j":case"down":return j.PyW((t.dateParts[t.cursor].decrement(),oe.NextFrame({state:{...t,typed:""}})));case"tab":let i,s;return j.PyW((i=t.dateParts[t.cursor].nextPart(),s=q.match(i,{onNone:()=>t.dateParts.findIndex(e=>!e.isToken()),onSome:e=>t.dateParts.indexOf(e)}),oe.NextFrame({state:{...t,cursor:s}})));case"enter":case"return":return j.YWq(l.validate(t.value),{onFailure:e=>oe.NextFrame({state:{...t,error:q.some(e)}}),onSuccess:e=>oe.Submit({value:e})});default:return j.PyW(((e,t)=>{if(/\d/.test(e)){let r=t.typed+e;return t.dateParts[t.cursor].setValue(r),oe.NextFrame({state:{...t,typed:r}})}return oe.Beep()})(q.getOrElse(e.input,()=>""),t))}}),clear:(c=i,j.D9k(function*(e,t){let r=yield*ne,n=yield*r.columns,i=yield*aG,s=J.TS(e.dateParts,"",(e,t)=>e+t.toString());return or(oh("?",i.pointerSmall,s,c,{plain:!0}),n,q.isSome(e.error)?J.YW(e.error.value.split(on),{onEmpty:()=>"",onNonEmpty:e=>`${i.pointerSmall} ${e.join("\n")}`}):"")+"\x1b[2K\x1b[G"}))}))),e=>e.toISOString());case"Float":let u,d,f,h;return j.TjK(a3((u={default:0,min:-1/0,max:1/0,incrementBy:1,decrementBy:1,precision:2,validate:e=>e<u.min?j.fJG(`${e} must be greater than or equal to ${u.min}`):e>u.max?j.fJG(`${e} must be less than or equal to ${u.max}`):j.PyW(e),...r={message:n}},aZ({cursor:(d=void 0===r.default?"":`${u.default}`).length,value:d,error:q.none()},{render:(f=u,(e,t)=>oe.$match(t,{Beep:()=>j.PyW("\x07"),NextFrame:({state:e})=>oP(e,f),Submit:()=>oj(e,f)})),process:(h=u,(e,t)=>{if(e.key.ctrl&&"u"===e.key.name)return oF(t);switch(e.key.name){case"backspace":return oD(t);case"k":case"up":return j.PyW(oe.NextFrame({state:{...t,value:""===t.value||"-"===t.value?`${h.incrementBy}`:`${Number.parseFloat(t.value)+h.incrementBy}`,error:q.none()}}));case"j":case"down":return j.PyW(oe.NextFrame({state:{...t,value:""===t.value||"-"===t.value?`-${h.decrementBy}`:`${Number.parseFloat(t.value)-h.decrementBy}`,error:q.none()}}));case"enter":case"return":{let e=Number.parseFloat(t.value);if(Number.isNaN(e))return j.PyW(oe.NextFrame({state:{...t,error:q.some("Must provide a floating point value")}}));return j.qIB(j.OH5(()=>aJ(e,h.precision)),e=>j.YWq(h.validate(e),{onFailure:e=>oe.NextFrame({state:{...t,error:q.some(e)}}),onSuccess:e=>oe.Submit({value:e})}))}default:var r=q.getOrElse(e.input,()=>"");if("."===r&&t.value.includes("."))return j.PyW(oe.Beep());if(0===t.value.length&&"-"===r)return j.PyW(oe.NextFrame({state:{...t,value:"-",error:q.none()}}));let n=Number.parseFloat(t.value+r);return Number.isNaN(n)?j.PyW(oe.Beep()):j.PyW(oe.NextFrame({state:{...t,value:"."===r?`${n}.`:`${n}`,error:q.none()}}))}}),clear:oT(u)}))),String);case"Integer":return j.TjK(a3(a1({message:n})),String);case"Redacted":return j.TjK(a3(o2({message:n},"password").pipe(a2(aU))),aY);default:return a3(o2({message:n},"text"))}},lc=e=>lu(e),lu=e=>{let t=q.getOrUndefined(e.description)?.trim(),r="flag"===e.kind&&void 0!==t&&t.length<=32?t:ld(e.name);return"flag"===e.kind?`${r} (${"flag"===e.kind?`--${e.name}`:e.name})`:r},ld=e=>{let t=e.split(/[-_]+/).filter(e=>e.length>0);return 0===t.length?e:[t[0][0].toUpperCase()+t[0].slice(1),...t.slice(1)].join(" ")},lf=e=>iI(ly("Current command",e,"\x1b[35m")),lh=(e,t)=>`${aq(e.toUpperCase(),"\x1b[1m","\x1b[96m")} ${aq("·","\x1b[90m")} ${aq(t,"\x1b[1m","\x1b[37m")}`,lp=(e,t,r)=>[`${aq(e,"\x1b[1m","\x1b[96m")} ${aq(`v${t}`,"\x1b[37m")} ${aq("· Command wizard","\x1b[1m","\x1b[37m")}`,...void 0===r||0===r.length?[]:[r],aq("Build a command interactively. Press Ctrl+C to cancel.","\x1b[90m"),""].join("\n"),lm=e=>ly("Command ready",e,"\x1b[96m","\x1b[32m"),lg=()=>`
17
+ ${aq("Wizard cancelled.","\x1b[31m")}`,ly=(e,t,r,n="\x1b[37m")=>{let i=lb(t);return[aq(e,"\x1b[1m",n),...i.map(e=>aq(e,r)),""].join("\n")},lb=e=>{let t=" $ ",r=" ",n=e.map(lv),i=[],s=t;for(let e of n){let n=s===t||s===r?"":" ";s.length+n.length+e.length>88&&s!==t?(i.push(`${s} \\`),s=`${r}${e}`):s+=`${n}${e}`}return s!==t&&i.push(s),i},lv=e=>/^[A-Za-z0-9_./:@%+=,-]+$/.test(e)?e:`'${e.replaceAll("'","'\"'\"'")}'`,lw=e=>ei.i5(e,sZ),lx=(e,t,r)=>s2({name:e,config:sK(t??{}),...ei.EA(r)?{handle:r}:{}}),lk=(0,F.XY)(2,(e,t)=>{let r=(e=>{let t=[],r=new Map,n=(e,n)=>{t.push(n);let i=r.get(e);i?i.push(n):r.set(e,[n])};for(let t of e){if(lw(t)){n(void 0,t);continue}for(let e of t.commands)n(t.group,e)}let i=[],s=r.get(void 0);for(let[e,t]of(s&&s.length>0&&i.push({group:void 0,commands:s}),r))void 0!==e&&i.push({group:e,commands:t});return{flat:t,groups:i}})(t);s9(e,r.flat);let n=s0(e),i=new Map(r.flat.map(e=>[e.name,s0(e)])),s=Symbol("effect/cli/SubcommandState"),a=j.D9k(function*(e){if(q.isNone(e.subcommand))return yield*n.parse(e);let t=i.get(e.subcommand.value.name);if(!t)return yield*n.parse(e);let r=yield*n.parseContext(e),a=yield*t.parse(e.subcommand.value.parsedInput);return Object.assign({},r,{[s]:{name:t.name,result:a}})}),o=j.D9k(function*(e,t){let r=e[s];if(r){let s=i.get(r.name);return s?yield*s.handle(r.result,[...t,s.name]).pipe(j.PfK(n.service,e)):yield*new iD({commandPath:t,errors:[]})}return yield*n.handle(e,t)});return s2({name:n.name,config:n.config,contextConfig:n.contextConfig,description:n.description,shortDescription:n.shortDescription,alias:n.alias,annotations:n.annotations,globalFlags:n.globalFlags,examples:n.examples,service:n.service,subcommands:r.groups,parse:a,parseContext:n.parseContext,handle:o})}),lS=(0,F.XY)(2,(e,t)=>{let r=s0(e),n=sK(t),i=sz(r.config,n),s=sz(r.contextConfig,n);r.subcommands.length>0&&s9(e,r.subcommands.flatMap(e=>e.commands),{contextConfig:s});let a=s6(n),o=j.D9k(function*(e){return Object.assign({},(yield*r.parse(e)),(yield*a(e)))}),l=j.D9k(function*(e){return Object.assign({},(yield*r.parseContext(e)),(yield*a(e)))});return s2({name:r.name,config:i,contextConfig:s,description:r.description,shortDescription:r.shortDescription,alias:r.alias,annotations:r.annotations,globalFlags:r.globalFlags,examples:r.examples,service:r.service,subcommands:r.subcommands,parse:o,parseContext:l,handle:(e,t)=>r.handle(e,t)})}),l_=(0,F.XY)(2,(e,t)=>s2({...s0(e),description:t})),lO=(0,F.XY)(2,(e,t)=>s2({...s0(e),shortDescription:t})),lI=(0,F.XY)(2,(e,t)=>s2({...s0(e),examples:t})),l$=(e,t)=>{let r=s0(e);return j.D9k(function*(n){let i,s,a,o,l,c,{builtIns:u}=yield*ah,{tokens:d,trailingOperands:f}=-1===(i=n.indexOf("--"))?{tokens:am(n),trailingOperands:[]}:{tokens:am(n.slice(0,i)),trailingOperands:n.slice(i+1)},h=at([...u,...(s=[],(a=e=>{for(let t of s0(e).globalFlags)s.push(t);for(let t of e.subcommands)for(let e of t.commands)a(e)})(e),at(s))]),p=aw(h.flatMap(e=>sh(e.flag)).filter(i5)),{flagMap:m,remainder:g,errors:y}=(o=ak(p.params),l=[],c=(e,t,r)=>{let n=aw(s0(t).config.flags.flatMap(sh).filter(i5)),i=aw(s0(t).contextConfig.flags.flatMap(sh).filter(i5)),s=ax(t.subcommands),a=av(e),u=[],d=!0;for(let e=a.take();e;e=a.take()){if(aS(e)){let t=aA(e,r);if(void 0!==t){aT(u,a,e,t);continue}let c=aO(e,i);if(void 0!==c){aT(u,a,e,c);continue}let f=aO(e,n),h=aO(e,p);if(void 0!==f&&(void 0===h||!d||!aN(e,a.rest(),f,s,[n,i,p]))){aT(u,a,e,f);continue}if(void 0!==h){let t=aC(a,e,h.param,h.negated);if("Error"===t._tag){l.push(t.error);continue}void 0!==t.value&&o[h.param.name].push(t.value);continue}u.push(e);continue}if("Value"===e._tag&&d){let t=s.get(e.value);if(void 0!==t)return u.push(e),u.push(...c(a.rest(),t,[...r,i])),u;d=!1}u.push(e)}return u},{flagMap:o,remainder:c(d,e,[]),errors:l}),b={flags:m,arguments:[]},v=yield*ab({tokens:g,trailingOperands:f},e),w=[e.name,...ay(v)],x={builtIns:u,command:e,commandPath:w,version:t.version},k=an(e,w,u),S=((e,t,r,n)=>{let i=new Set(t),s=[],a=new Set;for(let t of e)if(!i.has(t))for(let e of sh(t.flag)){let t=r[e.name];if(!t||0===t.length)continue;let i=`--${e.name}`;a.has(i)||(a.add(i),s.push(new iE({option:i,suggestions:[],command:n})))}return s})(h,k,m,w);if(S.length>0||y.length>0){let e=v.errors??[];return yield*new iD({commandPath:w,errors:[...y,...S,...e]})}for(let r of k){if("Action"!==r._tag||!sh(r.flag).some(e=>{let t=m[e.name];return void 0!==t&&t.length>0}))continue;let[,i]=yield*r.flag.parse(b);if(r===ac)return yield*j.JkU(function*(){yield*iI(lp(e.name,t.version,e.description));let r=[e.name,...n.filter(e=>"--wizard"!==e&&!e.startsWith("--wizard="))],i=yield*ln(e,{commandPath:w,prefix:r});yield*iI(lm(i)),(yield*a3(a8({message:"Run this command?",initial:!0,active:"yes",inactive:"no"})))&&(yield*iI(),yield*l$(e,t)(i.slice(1)))}).pipe(j.KuX("QuitError",()=>iI(lg())));yield*r.run(i,x);return}if(v.errors&&v.errors.length>0)return yield*new iD({commandPath:w,errors:v.errors});let _=yield*j.Ket(r.parse(v));if("Failure"===_._tag)return yield*new iD({commandPath:w,errors:[_.failure]});let O=r.handle(_.success,[e.name]),I=k.includes(ad)?(yield*ad.flag.parse(b))[1]:q.none();for(let e of(O=j.PfK(O,ad,I),k)){if("Setting"!==e._tag||e===ad)continue;let[,t]=yield*e.flag.parse(b);O=j.PfK(O,e,t)}let $=q.match(I,{onNone:()=>G.Ie(),onSome:e=>G.L8(sg.zQ,e)});yield*j.PpN(O,$)},j.osR(e=>ei.i5(e,i$)&&"ShowHelp"===e._tag?K.Py(e):K.fJ(e),t=>j.hgn(j.JkU(function*(){let{builtIns:r}=yield*ah,n=yield*sy,i=yield*ai(e,t.commandPath,r);yield*iI(n.formatHelpDoc(i)),t.errors.length>0&&(yield*iO(n.formatErrors(t.errors)))}),j.fJG(t))),j.osR(e=>ei.i5(e,r4)?K.Py(e):K.fJ(e),e=>j.GaK))},lE=new Set(["create","show","edit","list","export"]);function lC(e){return{_tag:"File",path:e}}function lA(e){return{_tag:"InlineJson",value:e}}function lT(){let e=i8("flag","file").pipe(sX("PATH|-"),sY("Read one canonical document from PATH, or stdin with -."),sJ(lC)),t=i8("flag","json").pipe(sX("VALUE"),sY("Read one canonical document from inline JSON."),sJ(lA));return{source:Object.assign(Object.create(Object.getPrototypeOf(e)),e,{parse:r=>{let n=r.flags.file?.length??0,i=r.flags.json?.length??0;return 1===n&&0===i?e.parse(r):0===n&&1===i?t.parse(r):j.fJG(new iN({option:"file/--json",value:0===n&&0===i?"neither provided":"more than one source provided",expected:"exactly one of --file PATH|- or --json VALUE",kind:"flag"}))}}),jsonInput:sW(t)}}class lN extends G.kl()("@sketchi/cli/InputReader"){}function lM(e,t){return j.SvU({try:()=>new TextDecoder("utf-8",{fatal:!0}).decode(e),catch:()=>nc.make({code:"input_read_failed",message:"stdin"===t?"Standard input is not valid UTF-8.":"The input file is not valid UTF-8.",hint:"Provide one complete UTF-8 JSON document and retry."})})}let lP=function(e=()=>!0===process.stdin.isTTY){return X.QZ(lN,j.JkU(function*(){let t=yield*nK,r=yield*rz;return{read:j.fn("sketchi.cli.input.read")(function*(n){if("InlineJson"===n._tag)return n.value;if("-"!==n.path){let e=yield*t.readBytes(n.path).pipe(j.xm_(()=>nc.make({code:"input_read_failed",message:`Unable to read input file ${n.path}.`,hint:"Check the path and file permissions, then retry."})));return yield*lM(e,"file")}if(e())return yield*nc.make({code:"interactive_stdin",message:"--file - requires piped or redirected stdin.",hint:"Pipe one JSON document, or use --file PATH / --json VALUE."});let i=yield*tm(r.stdin).pipe(j.xm_(()=>nc.make({code:"input_read_failed",message:"Unable to read JSON from stdin.",hint:"Pipe one complete UTF-8 JSON document and retry."})));return yield*lM(function(e){let t=new Uint8Array(e.reduce((e,t)=>e+t.byteLength,0)),r=0;for(let n of e)t.set(n,r),r+=n.byteLength;return t}(i),"stdin")})}}))}(),lj=j.fn("sketchi.cli.input.readDocument")(function*(e){let t=yield*lN,r=yield*t.read(e);return yield*nk(r)});class lD extends G.kl()("@sketchi/cli/OutputWriter"){}class lF extends r8.X0d()("CliCommandExit",{exitCode:r8.wNn}){}function lL(e){return nl.make({cause:e,operation:"write-output",path:"standard stream",message:"Unable to write command output."})}let lR=X.QZ(lD,j.JkU(function*(){let e=yield*rz;return{stdout:t=>((...e)=>tl(e))(t).pipe(tp(e.stdout()),j.xm_(lL)),stderr:t=>((...e)=>tl(e))(t).pipe(tp(e.stderr()),j.xm_(lL))}}));function lU(e){let t=e.details?.map(e=>` - ${e}`).join("\n");return[`error: ${e.code}`,e.message,`next: ${e.hint}`,...t?["details:",t]:[]].join("\n")+"\n"}let lB=j.fn("sketchi.cli.output.failure")(function*(e,t,r){let n=yield*lD,i=function(e){switch(e._tag){case"CliFilesystemError":return{code:"filesystem_error",message:e.message,hint:"Check local paths and permissions, then retry."};case"CliInputError":case"CliStorageError":case"CliExportError":return{code:e.code,message:e.message,hint:e.hint};case"CliValidationError":return{code:"invalid_document",message:e.message,hint:e.hint,details:e.details};case"CliBuildError":return{code:"build_failed",message:e.message,hint:e.hint,details:e.details};case"CliGenerationError":return{code:e.code,message:e.message,hint:e.hint,details:e.details}}}(r),s="json"===t?nS({ok:!1,command:e,error:i}):lU(i);return yield*n.stderr(s),yield*lF.make({exitCode:function(e){switch(e._tag){case"CliInputError":return"interactive_stdin"===e.code?2:3;case"CliValidationError":return 3;case"CliBuildError":return 4;case"CliGenerationError":switch(e.code){case"invalid_generated_document":return 3;case"provider_failure":return 10;case"generation_timeout":return 11;case"malformed_output":return 12}case"CliStorageError":if("diagram_not_found"===e.code)return 5;if("diagram_already_exists"===e.code||"diagram_busy"===e.code)return 6;return 7;case"CliFilesystemError":return 7;case"CliExportError":return 8}}(r)})}),lY=j.fn("sketchi.cli.output.success")(function*(e,t,r,n,i="stdout"){let s=yield*lD,a="json"===t?nS({ok:!0,command:e,data:r}):n;yield*s[i](a.endsWith("\n")?a:`${a}
18
+ `)});function lX(e,t,r,n,i=e=>e){return r.pipe(j.tvg({onFailure:r=>lB(e,t,r),onSuccess:r=>lY(e,t,i(r),n(r))}))}let lW=`Local Sketchi authoring for canonical flowcharts and mindmaps, with one prompt-assisted path.
54
19
 
55
20
  Manual JSON workflow (strictly offline):
56
21
  create a canonical document, inspect or replace it, list local records, and export stored artifacts.
@@ -65,31 +30,34 @@ Canonical mindmap example:
65
30
  Prompt-assisted workflow (sole network boundary):
66
31
  sketchi generate --prompt TEXT [--type flowchart|mindmap] [--model MODEL]
67
32
  Only generate uses the network. It makes one unauthenticated HTTPS POST to the public
68
- Sketchi generate API at ${kO}
33
+ Sketchi generate API at ${ig}
69
34
  and needs no token, key, account, or login. The model call, validation, and quality gate
70
35
  run server-side; the finished diagram and Excalidraw artifact come back and are committed
71
36
  through the same local store as create. The default type is flowchart and default model is
72
- ${k$}. Override the endpoint for preview or local testing with
73
- ${kI} or --endpoint URL.
37
+ ${im}. Override the endpoint for preview or local testing with
38
+ ${iy} or --endpoint URL.
74
39
 
75
40
  Input and output contracts:
76
41
  create/edit require exactly one of --file PATH|- or --json VALUE. --file - reads one
77
42
  noninteractive UTF-8 JSON document from stdin and exits with usage code 2 on a TTY.
78
43
  --json is inline input only. --prompt is noninteractive text. Use --output text|json for
79
44
  result presentation on every command.
80
- export writes bytes with --dest PATH|-. With --dest -, bytes use stdout and status uses stderr.
45
+ export writes bytes with --dest PATH|- and always writes status to stderr. With --dest -,
46
+ stdout contains only artifact bytes. A successful PNG file export adds a generic inline-Markdown
47
+ display hint for calling agents.
81
48
 
82
49
  Offline boundary and storage:
83
50
  create, show, edit, list, and export use no model, remote agent, MCP server, login,
84
51
  account, browser, credential, or network. No command sends stored records to a provider.
85
52
  Records live at ~/.sketchi/diagrams/<id>/ with manifest.json, document.json, scene.json,
86
53
  diagram.excalidraw, optional diagram.png, and revisions/<revision>.json.
87
- Formats are scene, excalidraw, and png. PNG export only returns an already-stored PNG.
54
+ Formats are scene, excalidraw, and png. If no PNG is stored, export deterministically renders one
55
+ on demand from the local scene and Excalidraw artifacts, without a browser, network, or record write.
88
56
 
89
57
  Exit codes and errors:
90
58
  0 success; 1 internal failure; 2 usage or interactive stdin; 3 invalid input/document;
91
59
  4 build/export construction failure; 5 diagram not found; 6 conflict/busy;
92
- 7 filesystem/storage failure; 8 unavailable format or export write failure;
60
+ 7 filesystem/storage failure; 8 unavailable format, render, destination, or write failure;
93
61
  10 generate network/endpoint failure; 11 generate timeout; 12 malformed generate output.
94
62
  Text errors start with "error: CODE". JSON errors use {"ok":false,"command":...,"error":...}.
95
63
  Errors never include stacks.
@@ -98,19 +66,19 @@ Revision recovery and next steps:
98
66
  edit validates and builds before an atomic commit, then saves the prior document under revisions/.
99
67
  To recover, inspect the prior revision JSON and pass that complete document back to edit.
100
68
  Start with create for accepted JSON or generate for a prompt. Use the returned id with show/list,
101
- edit with a complete replacement document, then export a stored scene or Excalidraw artifact.`,OW=SJ("output",["text","json"]).pipe(Sf("text"),SY("Result presentation format."),SG("text|json")),OY=OS("sketchi").pipe(O$({output:OW}),OO(OJ),OI("Local Sketchi authoring with one credential-free prompt-assisted command."));function OG(e){return`~/.sketchi/diagrams/${e}`}function OH(e){return e.revisions.map(t=>`${OG(e.manifest.id)}/revisions/${t}`)}function OQ(e){return{...x6(e),storagePath:OG(e.manifest.id),revisions:OH(e),document:e.document}}function OZ(e,t){return`${e}: ${t.manifest.id}
69
+ edit with a complete replacement document, then export a stored scene or Excalidraw artifact.`,lJ=sU("output",["text","json"]).pipe(ss("text"),sY("Result presentation format."),sX("text|json")),lq=lx("sketchi").pipe(lS({output:lJ}),l_(lW),lO("Local Sketchi authoring with one credential-free prompt-assisted command."));function lK(e){return`~/.sketchi/diagrams/${e}`}function lV(e){return e.revisions.map(t=>`${lK(e.manifest.id)}/revisions/${t}`)}function lG(e){return{...nU(e),storagePath:lK(e.manifest.id),revisions:lV(e),document:e.document}}function lH(e,t){return`${e}: ${t.manifest.id}
102
70
  type: ${t.manifest.type}
103
71
  title: ${t.manifest.title}
104
72
  revision: ${String(t.manifest.revision)}
105
73
  formats: ${t.manifest.formats.join(",")}
106
- storage: ${OG(t.manifest.id)}`}function OX(e){return{...OQ(e.diagram),generation:{model:e.model,provider:e.provider}}}function O0(e){return[OZ("created",e.diagram).replace(/^created:/u,"generated:"),`provider: ${e.provider}`,`model: ${e.model}`].join("\n")}function O1(e){let t=OH(e);return[`id: ${e.manifest.id}`,`type: ${e.manifest.type}`,`title: ${e.manifest.title}`,`revision: ${String(e.manifest.revision)}`,`formats: ${e.manifest.formats.join(",")}`,`revisions: ${0===t.length?"none":t.join(",")}`,"document:",xz(e.document).trimEnd()].join("\n")}function O2(e){return 0===e.length?"no diagrams":["id type revision formats title",...e.map(e=>[e.id,e.type,String(e.revision),e.formats.join(","),e.title].join(" "))].join("\n")}let O3=`Create one persisted diagram from --prompt TEXT. This is Sketchi's only command that uses the network. It makes one unauthenticated HTTPS POST to the public Sketchi generate API and needs no token, key, account, or login.
74
+ storage: ${lK(t.manifest.id)}`}function lz(e){return{...lG(e.diagram),generation:{model:e.model,provider:e.provider}}}function lQ(e){return[lH("created",e.diagram).replace(/^created:/u,"generated:"),`provider: ${e.provider}`,`model: ${e.model}`].join("\n")}function lZ(e){let t=lV(e);return[`id: ${e.manifest.id}`,`type: ${e.manifest.type}`,`title: ${e.manifest.title}`,`revision: ${String(e.manifest.revision)}`,`formats: ${e.manifest.formats.join(",")}`,`revisions: ${0===t.length?"none":t.join(",")}`,"document:",nS(e.document).trimEnd()].join("\n")}function l0(e){return 0===e.length?"no diagrams":["id type revision formats title",...e.map(e=>[e.id,e.type,String(e.revision),e.formats.join(","),e.title].join(" "))].join("\n")}let l1=`Create one persisted diagram from --prompt TEXT. This is Sketchi's only command that uses the network. It makes one unauthenticated HTTPS POST to the public Sketchi generate API and needs no token, key, account, or login.
107
75
 
108
76
  Network and options:
109
- Endpoint: ${kO}
77
+ Endpoint: ${ig}
110
78
  The model call, schema validation, and quality gate run server-side; the finished diagram
111
79
  and Excalidraw artifact are returned over plain HTTPS. Sketchi sends no credentials.
112
- --type defaults to flowchart; --model defaults to ${k$}.
113
- Override the endpoint for preview or local testing with ${kI}
80
+ --type defaults to flowchart; --model defaults to ${im}.
81
+ Override the endpoint for preview or local testing with ${iy}
114
82
  or --endpoint URL. --output text|json controls only the local result envelope.
115
83
 
116
84
  Validation and storage:
@@ -123,11 +91,43 @@ Errors and next steps:
123
91
  Exit 10 means a network or endpoint failure, 11 a timeout, and 12 malformed output;
124
92
  a rejected or invalid generated document uses 3, conflict uses 6, and storage uses 7.
125
93
  On success, pass the returned id to show, edit, list, or export. For strictly offline manual
126
- authoring and accepted canonical JSON examples, run sketchi --help.`,O5=OS("generate",{prompt:Sn("flag","prompt").pipe(SY("Diagram request text sent to the public Sketchi generate API."),SG("TEXT")),type:SJ("type",["flowchart","mindmap"]).pipe(Sf("flowchart"),SY("Requested canonical diagram type; default flowchart."),SG("flowchart|mindmap")),model:Sn("flag","model").pipe(Sf(k$),SY(`Server-routed generation model id; default ${k$}.`),SG("MODEL")),endpoint:Sn("flag","endpoint").pipe(Sf(process.env[kI]?.trim()||kO),SY("Unauthenticated generate API URL; defaults to the production Sketchi endpoint."),SG("URL"))},e=>lR(function*(){let{output:t}=yield*OY;yield*OV("generate",t,kM(e),O0,OX)})).pipe(OO(O3),OI("Generate and persist one diagram through the public unauthenticated Sketchi generate API."),OC([{command:'sketchi generate --prompt "Map release approval with pass and revise branches"',description:`Generate a flowchart with ${k$}.`},{command:'sketchi generate --prompt "Organize launch readiness" --type mindmap --model gemini-3.1-flash-lite --output json',description:"Generate and persist a mindmap with structured output."}])),O4=OS("create",ON(),({source:e})=>lR(function*(){let{output:t}=yield*OY,r=yield*xW,n=yield*ks,i=lR(function*(){let t=yield*OP(e),i=yield*r.build(t);return yield*n.create(i)});yield*OV("create",t,i,e=>OZ("created",e),OQ)})).pipe(OO("Create one local diagram from exactly one canonical document source. The document is validated and built before the record directory is committed atomically. --file - rejects an interactive TTY with exit 2."),OC([{command:"sketchi create --file diagram.json",description:"Create from a UTF-8 JSON file."},{command:"printf '%s' '{...}' | sketchi create --file - --output json",description:"Create from noninteractive stdin with a JSON result."}])),O8=OS("show",{diagramId:Sn(k7,"diagram-id")},({diagramId:e})=>lR(function*(){let{output:t}=yield*OY,r=yield*ks,n=xJ(e).pipe(s8(e=>r.show(e)));yield*OV("show",t,n,O1,OQ)})).pipe(OO("Show the current canonical document, manifest summary, formats, and recoverable revision paths for DIAGRAM_ID. This does not rebuild or mutate the record."),OC([{command:"sketchi show release-flow --output json",description:"Read a record as a stable JSON envelope."}])),O6=OS("edit",{diagramId:Sn(k7,"diagram-id"),...ON()},({diagramId:e,source:t})=>lR(function*(){let{output:r}=yield*OY,n=yield*xW,i=yield*ks,s=lR(function*(){let r=yield*xJ(e),s=yield*OP(t),a=yield*n.build(s);return a.id!==r?yield*xT.make({message:`Edited document id "${a.id}" does not match "${r}".`,hint:"Keep spec.id equal to the diagram id being edited.",details:["spec.id"]}):yield*i.edit(r,a)});yield*OV("edit",r,s,e=>OZ("edited",e),OQ)})).pipe(OO("Replace the complete canonical document for DIAGRAM_ID. Sketchi validates and builds first, preserves the prior document under revisions/, and atomically swaps the record. The new spec.id must match DIAGRAM_ID."),OC([{command:"sketchi edit release-flow --file revised.json",description:"Replace a document and retain the prior revision."}])),O9=OS("list",{},()=>lR(function*(){let{output:e}=yield*OY,t=yield*ks;yield*OV("list",e,t.list(),O2)})).pipe(OO("List local diagrams in ascending id order with type, revision, stored formats, and title. The command is deterministic and read-only."),OC([{command:"sketchi list --output json",description:"List records as a stable JSON envelope."}])),O7=OS("export",{diagramId:Sn(k7,"diagram-id"),format:SJ("format",["scene","excalidraw","png"]).pipe(SY("Stored artifact format to export."),SG("scene|excalidraw|png")),destination:Sn("flag","dest").pipe(SY("Artifact byte destination path, or - for stdout."),SG("PATH|-"))},({destination:e,diagramId:t,format:r})=>lR(function*(){let{output:n}=yield*OY,i=yield*ks,s=lR(function*(){let n=yield*xJ(t),s=yield*i.readArtifact(n,r);return"-"!==e&&(yield*k_(e,s)),{id:n,format:r,destination:e,sizeBytes:s.byteLength,..."-"===e?{stdoutBytes:s}:{}}});yield*s.pipe(aT({onFailure:e=>OK("export",n,e),onSuccess:e=>lR(function*(){let t=yield*OD;e.stdoutBytes&&(yield*t.stdout(e.stdoutBytes));let r={id:e.id,format:e.format,destination:e.destination,sizeBytes:e.sizeBytes},i=`exported: ${e.id}
127
- format: ${e.format}
128
- destination: ${e.destination}
129
- bytes: ${String(e.sizeBytes)}`;yield*Oz("export",n,r,i,e.stdoutBytes?"stderr":"stdout")})}))})).pipe(OO("Export one already-stored scene, Excalidraw, or PNG artifact. --dest - writes only artifact bytes to stdout and writes the text/JSON success envelope to stderr. PNG never starts a browser or network request; unavailable PNG exits 8."),OC([{command:"sketchi export release-flow --format excalidraw --dest release.excalidraw",description:"Write an Excalidraw artifact atomically to a file."},{command:"sketchi export release-flow --format scene --dest - > scene.json",description:"Pipe raw scene bytes without status contamination."}])),Ie=OY.pipe(O_([O5,O4,O8,O6,O9,O7])),It=lW("sketchi.cli.run")(function*(e){let t,r,n,i,s,a,o,l,c=(t=e.lastIndexOf("--output"))>=0&&"json"===e[t+1]||e.some(e=>"--output=json"===e)?"json":"text";return yield*(r=S_({colors:!1}),n=e.some(e=>"--help"===e||"-h"===e||"--version"===e||"-v"===e),i=e.some(e=>"--output=json"===e)||e.some((t,r)=>"--output"===t&&"json"===e[r+1]),a=(s=e.find(e=>OA.has(e)))??"sketchi",o={...r,formatHelpDoc:e=>i&&!n?"":r.formatHelpDoc(e).replace(/[ \t]+$/gmu,""),formatErrors:e=>{let t=e.map(e=>r.formatCliError(e)).join("; "),n=`Run sketchi${s?` ${s}`:""} --help for usage.`;return i?`${JSON.stringify({ok:!1,command:a,error:{code:"usage_error",message:t,hint:n}},null,2)}
94
+ authoring and accepted canonical JSON examples, run sketchi --help.`,l2=lx("generate",{prompt:i8("flag","prompt").pipe(sY("Diagram request text sent to the public Sketchi generate API."),sX("TEXT")),type:sU("type",["flowchart","mindmap"]).pipe(ss("flowchart"),sY("Requested canonical diagram type; default flowchart."),sX("flowchart|mindmap")),model:i8("flag","model").pipe(ss(im),sY(`Server-routed generation model id; default ${im}.`),sX("MODEL")),endpoint:i8("flag","endpoint").pipe(ss(process.env[iy]?.trim()||ig),sY("Unauthenticated generate API URL; defaults to the production Sketchi endpoint."),sX("URL"))},e=>j.JkU(function*(){let{output:t}=yield*lq;yield*lX("generate",t,ik(e),lQ,lz)})).pipe(l_(l1),lO("Generate and persist one diagram through the public unauthenticated Sketchi generate API."),lI([{command:'sketchi generate --prompt "Map release approval with pass and revise branches"',description:`Generate a flowchart with ${im}.`},{command:'sketchi generate --prompt "Organize launch readiness" --type mindmap --model gemini-3.1-flash-lite --output json',description:"Generate and persist a mindmap with structured output."}])),l3=lx("create",lT(),({source:e})=>j.JkU(function*(){let{output:t}=yield*lq,r=yield*nI,n=yield*nQ,i=j.JkU(function*(){let t=yield*lj(e),i=yield*r.build(t);return yield*n.create(i)});yield*lX("create",t,i,e=>lH("created",e),lG)})).pipe(l_("Create one local diagram from exactly one canonical document source. The document is validated and built before the record directory is committed atomically. --file - rejects an interactive TTY with exit 2."),lI([{command:"sketchi create --file diagram.json",description:"Create from a UTF-8 JSON file."},{command:"printf '%s' '{...}' | sketchi create --file - --output json",description:"Create from noninteractive stdin with a JSON result."}])),l5=lx("show",{diagramId:i8(i2,"diagram-id")},({diagramId:e})=>j.JkU(function*(){let{output:t}=yield*lq,r=yield*nQ,n=nO(e).pipe(j.qIB(e=>r.show(e)));yield*lX("show",t,n,lZ,lG)})).pipe(l_("Show the current canonical document, manifest summary, formats, and recoverable revision paths for DIAGRAM_ID. This does not rebuild or mutate the record."),lI([{command:"sketchi show release-flow --output json",description:"Read a record as a stable JSON envelope."}])),l6=lx("edit",{diagramId:i8(i2,"diagram-id"),...lT()},({diagramId:e,source:t})=>j.JkU(function*(){let{output:r}=yield*lq,n=yield*nI,i=yield*nQ,s=j.JkU(function*(){let r=yield*nO(e),s=yield*lj(t),a=yield*n.build(s);return a.id!==r?yield*nu.make({message:`Edited document id "${a.id}" does not match "${r}".`,hint:"Keep spec.id equal to the diagram id being edited.",details:["spec.id"]}):yield*i.edit(r,a)});yield*lX("edit",r,s,e=>lH("edited",e),lG)})).pipe(l_("Replace the complete canonical document for DIAGRAM_ID. Sketchi validates and builds first, preserves the prior document under revisions/, and atomically swaps the record. The new spec.id must match DIAGRAM_ID."),lI([{command:"sketchi edit release-flow --file revised.json",description:"Replace a document and retain the prior revision."}])),l8=lx("list",{},()=>j.JkU(function*(){let{output:e}=yield*lq,t=yield*nQ;yield*lX("list",e,t.list(),l0)})).pipe(l_("List local diagrams in ascending id order with type, revision, stored formats, and title. The command is deterministic and read-only."),lI([{command:"sketchi list --output json",description:"List records as a stable JSON envelope."}]));function l9(e){let t=[...e.destination].map(e=>{let t=e.codePointAt(0)??0;return t<32||t>=128&&t<=159||127===t||8232===t||8233===t||"%<>#?\\".includes(e)?encodeURIComponent(e):e}).join("");return"png"===e.format&&"-"!==e.destination?`to show this diagram to the user, display the exported file as an inline markdown image, e.g. ![${e.id}](<${t}>)`:void 0}let l4=lx("export",{diagramId:i8(i2,"diagram-id"),format:sU("format",["scene","excalidraw","png"]).pipe(sY("Artifact format to export or render on demand."),sX("scene|excalidraw|png")),destination:i8("flag","dest").pipe(sY("Artifact byte destination path, or - for stdout."),sX("PATH|-"))},({destination:e,diagramId:t,format:r})=>j.JkU(function*(){let{output:n}=yield*lq,i=yield*iu,s=j.JkU(function*(){let n=yield*nO(t),s=yield*i.exportArtifact(n,r);return"-"!==e&&(yield*ic(e,s)),{id:n,format:r,destination:e,sizeBytes:s.byteLength,..."-"===e?{stdoutBytes:s}:{}}});yield*s.pipe(j.tvg({onFailure:e=>lB("export",n,e),onSuccess:e=>j.JkU(function*(){let t,r=yield*lD;e.stdoutBytes&&(yield*r.stdout(e.stdoutBytes));let i=(t=l9(e),{id:e.id,format:e.format,destination:e.destination,sizeBytes:e.sizeBytes,...t?{hint:t}:{}}),s=l9(e),a=[`exported: ${e.id}`,`format: ${e.format}`,`destination: ${e.destination}`,`bytes: ${String(e.sizeBytes)}`,...s?[`hint: ${s}`]:[]].join("\n");yield*lY("export",n,i,a,"stderr")})}))})).pipe(l_("Export a stored scene or Excalidraw artifact, or render PNG on demand from both when no PNG is stored. Rendering is deterministic, export-only, and uses bundled fonts plus a WASM rasterizer: it never starts a browser or network request and never writes the PNG back to the record. Status always uses stderr, so --dest - leaves stdout byte-only. A successful PNG file export adds a generic inline-Markdown display hint for calling agents. Render or write failures exit 8."),lI([{command:"sketchi export release-flow --format excalidraw --dest release.excalidraw",description:"Write an Excalidraw artifact atomically to a file."},{command:"sketchi export release-flow --format scene --dest - > scene.json",description:"Pipe raw scene bytes without status contamination."}])),l7=lq.pipe(lk([l2,l3,l5,l6,l8,l4])),ce=j.fn("sketchi.cli.run")(function*(e){let t,r,n,i,s,a,o,l,c=(t=e.lastIndexOf("--output"))>=0&&"json"===e[t+1]||e.some(e=>"--output=json"===e)?"json":"text";return yield*(r=sb({colors:!1}),n=e.some(e=>"--help"===e||"-h"===e||"--version"===e||"-v"===e),i=e.some(e=>"--output=json"===e)||e.some((t,r)=>"--output"===t&&"json"===e[r+1]),a=(s=e.find(e=>lE.has(e)))??"sketchi",o={...r,formatHelpDoc:e=>i&&!n?"":r.formatHelpDoc(e).replace(/[ \t]+$/gmu,""),formatErrors:e=>{let t=e.map(e=>r.formatCliError(e)).join("; "),n=`Run sketchi${s?` ${s}`:""} --help for usage.`;return i?`${JSON.stringify({ok:!1,command:a,error:{code:"usage_error",message:t,hint:n}},null,2)}
130
95
  `:`error: usage_error
131
96
  ${t}
132
97
  next: ${n}
133
- `}},l=new Proxy(globalThis.console,{get(e,t,r){if("log"===t)return(...t)=>{(1!==t.length||""!==t[0])&&e.log(...t)};let n=Reflect.get(e,t,r);return"function"==typeof n?n.bind(e):n}}),OE(Ie,{version:"0.0.2"})(e).pipe(ax(e=>eT(e,kL)&&"ShowHelp"!==e._tag?kj(o.formatErrors([e])):sK),af(_v,{builtIns:[_h,_p,_g]}),af(SS,o),af(oP,l))).pipe(aE({onFailure:e=>lR(function*(){let t,r=rB(su(e));if(r instanceof OR)return r.exitCode;if(r instanceof xE)return 7;let n=function(e){if(eT(e,kL))return"ShowHelp"===e._tag?2*(e.errors.length>0):2}(r);if(void 0!==n)return n;let i=yield*OD;return yield*i.stderr((t={code:"internal_error",message:"Sketchi could not complete the command.",hint:"Retry once; if it persists, report the command and inputs without secrets."},"json"===c?xz({ok:!1,command:"sketchi",error:t}):Oq(t))).pipe(ab(()=>sK)),1}),onSuccess:()=>lD(0)}))}),Ir=lC(xZ,lO(bH,function(e={}){return lw(wz,{createId:e.createId??wZ,...e.renderer?{renderer:e.renderer}:{},...e.artifactUrl?{artifactUrl:e.artifactUrl}:{}})}({createId:e=>`${e}_offline_cli`}))),In=lC(kS,lO(kn,km)),Ii=lE(lO(kn,km,Ir,In,OL.pipe(lC(kn)),OB),gz);l2(It(process.argv.slice(2)).pipe(s3(e=>sL(()=>{process.exitCode=e})),lA(Ii)),{disableErrorReporting:!0})})();
98
+ `}},l=new Proxy(globalThis.console,{get(e,t,r){if("log"===t)return(...t)=>{(1!==t.length||""!==t[0])&&e.log(...t)};let n=Reflect.get(e,t,r);return"function"==typeof n?n.bind(e):n}}),l$(l7,{version:"0.1.0"})(e).pipe(j.sFT(e=>ei.i5(e,i$)&&"ShowHelp"!==e._tag?iO(o.formatErrors([e])):j.rIH),j.PfK(ah,{builtIns:[ao,al,au]}),j.PfK(sy,o),j.PfK(iS,l))).pipe(j.khu({onFailure:e=>j.JkU(function*(){let t,r=q.getOrUndefined(P.L$(e));if(r instanceof lF)return r.exitCode;if(r instanceof nl)return 7;let n=function(e){if(ei.i5(e,i$))return"ShowHelp"===e._tag?2*(e.errors.length>0):2}(r);if(void 0!==n)return n;let i=yield*lD;return yield*i.stderr((t={code:"internal_error",message:"Sketchi could not complete the command.",hint:"Retry once; if it persists, report the command and inputs without secrets."},"json"===c?nS({ok:!1,command:"sketchi",error:t}):lU(t))).pipe(j.MfU(()=>j.rIH)),1}),onSuccess:()=>j.PyW(0)}))}),ct=X.Um(na.Tx,(0,na.rR)({createId:e=>`${e}_offline_cli`})),cr=X.Gt(nT,ct),cn=X.Um(nH,n4),ci=X.Gt(il,cn),cs=X.Gt(ip,X.Um(ci,nW)),ca=X.Um(nH,n4,cr,ci,cs,lP.pipe(X.Gt(nH)),lR),co=X.S5(ca,ns);Y(ce(process.argv.slice(2)).pipe(j.Mim(e=>j.OH5(()=>{process.exitCode=e})),j.Gte(co)),{disableErrorReporting:!0})},181(e){e.exports=t("buffer")},6982(e){e.exports=t("crypto")},932(e){e.exports=t("process")},7876(e,t,r){var n=r(6730),i=r(8376),s=r(73),a=r(7028),o=r(3244),l=r(6225),c=r(9661);function u(e,t,r,n,i,s){let a="block-map"===r.type?o.resolveBlockMap(e,t,r,n,s):"block-seq"===r.type?l.resolveBlockSeq(e,t,r,n,s):c.resolveFlowCollection(e,t,r,n,s),u=a.constructor;return"!"===i||i===u.tagName?a.tag=u.tagName:i&&(a.tag=i),a}t.composeCollection=function(e,t,r,o,l){let c=o.tag,d=c?t.directives.tagName(c.source,e=>l(c,"TAG_RESOLVE_FAILED",e)):null;if("block-seq"===r.type){let{anchor:e,newlineAfterProp:t}=o,r=e&&c?e.offset>c.offset?e:c:e??c;r&&(!t||t.offset<r.offset)&&l(r,"MISSING_CHAR","Missing newline after block sequence props")}let f="block-map"===r.type?"map":"block-seq"===r.type?"seq":"{"===r.start.source?"map":"seq";if(!c||!d||"!"===d||d===s.YAMLMap.tagName&&"map"===f||d===a.YAMLSeq.tagName&&"seq"===f)return u(e,t,r,l,d);let h=t.schema.tags.find(e=>e.tag===d&&e.collection===f);if(!h){let n=t.schema.knownTags[d];if(n?.collection!==f)return n?l(c,"BAD_COLLECTION_TYPE",`${n.tag} used for ${f} collection, but expects ${n.collection??"scalar"}`,!0):l(c,"TAG_RESOLVE_FAILED",`Unresolved tag: ${d}`,!0),u(e,t,r,l,d);t.schema.tags.push(Object.assign({},n,{default:!1})),h=n}let p=u(e,t,r,l,d,h),m=h.resolve?.(p,e=>l(c,"TAG_RESOLVE_FAILED",e),t.options)??p,g=n.isNode(m)?m:new i.Scalar(m);return g.range=p.range,g.tag=d,h?.format&&(g.format=h.format),g}},6040(e,t,r){var n=r(9960),i=r(9724),s=r(4915),a=r(7800);t.composeDoc=function(e,t,{offset:r,start:o,value:l,end:c},u){let d=Object.assign({_directives:t},e),f=new n.Document(void 0,d),h={atKey:!1,atRoot:!0,directives:f.directives,options:f.options,schema:f.schema},p=a.resolveProps(o,{indicator:"doc-start",next:l??c?.[0],offset:r,onError:u,parentIndent:0,startOnNewline:!0});p.found&&(f.directives.docStart=!0,l&&("block-map"===l.type||"block-seq"===l.type)&&!p.hasNewline&&u(p.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),f.contents=l?i.composeNode(h,l,p,u):i.composeEmptyNode(h,p.end,o,null,p,u);let m=f.contents.range[2],g=s.resolveEnd(c,m,!1,u);return g.comment&&(f.comment=g.comment),f.range=[r,m,g.offset],f}},9724(e,t,r){var n=r(2298),i=r(6730),s=r(7876),a=r(5120),o=r(4915),l=r(4898);let c={composeNode:u,composeEmptyNode:d};function u(e,t,r,l){let u,f=e.atKey,{spaceBefore:h,comment:p,anchor:m,tag:g}=r,y=!0;switch(t.type){case"alias":u=function({options:e},{offset:t,source:r,end:i},s){let a=new n.Alias(r.substring(1));""===a.source&&s(t,"BAD_ALIAS","Alias cannot be an empty string"),a.source.endsWith(":")&&s(t+r.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let l=t+r.length,c=o.resolveEnd(i,l,e.strict,s);return a.range=[t,l,c.offset],c.comment&&(a.comment=c.comment),a}(e,t,l),(m||g)&&l(t,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":u=a.composeScalar(e,t,g,l),m&&(u.anchor=m.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{u=s.composeCollection(c,e,t,r,l),m&&(u.anchor=m.source.substring(1))}catch(e){l(t,"RESOURCE_EXHAUSTION",e instanceof Error?e.message:String(e))}break;default:{let e="error"===t.type?t.message:`Unsupported token (type: ${t.type})`;l(t,"UNEXPECTED_TOKEN",e),y=!1}}return u??(u=d(e,t.offset,void 0,null,r,l)),m&&""===u.anchor&&l(m,"BAD_ALIAS","Anchor cannot be an empty string"),f&&e.options.stringKeys&&(!i.isScalar(u)||"string"!=typeof u.value||u.tag&&"tag:yaml.org,2002:str"!==u.tag)&&l(g??t,"NON_STRING_KEY","With stringKeys, all keys must be strings"),h&&(u.spaceBefore=!0),p&&("scalar"===t.type&&""===t.source?u.comment=p:u.commentBefore=p),e.options.keepSourceTokens&&y&&(u.srcToken=t),u}function d(e,t,r,n,{spaceBefore:i,comment:s,anchor:o,tag:c,end:u},f){let h={type:"scalar",offset:l.emptyScalarPosition(t,r,n),indent:-1,source:""},p=a.composeScalar(e,h,c,f);return o&&(p.anchor=o.source.substring(1),""===p.anchor&&f(o,"BAD_ALIAS","Anchor cannot be an empty string")),i&&(p.spaceBefore=!0),s&&(p.comment=s,p.range[2]=u),p}t.composeEmptyNode=d,t.composeNode=u},5120(e,t,r){var n=r(6730),i=r(8376),s=r(2992),a=r(3165);t.composeScalar=function(e,t,r,o){let l,c,{value:u,type:d,comment:f,range:h}="block-scalar"===t.type?s.resolveBlockScalar(e,t,o):a.resolveFlowScalar(t,e.options.strict,o),p=r?e.directives.tagName(r.source,e=>o(r,"TAG_RESOLVE_FAILED",e)):null;l=e.options.stringKeys&&e.atKey?e.schema[n.SCALAR]:p?function(e,t,r,i,s){if("!"===r)return e[n.SCALAR];let a=[];for(let t of e.tags)if(!t.collection&&t.tag===r)if(!t.default||!t.test)return t;else a.push(t);for(let e of a)if(e.test?.test(t))return e;let o=e.knownTags[r];return o&&!o.collection?(e.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(s(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${r}`,"tag:yaml.org,2002:str"!==r),e[n.SCALAR])}(e.schema,u,p,r,o):"scalar"===t.type?function({atKey:e,directives:t,schema:r},i,s,a){let o=r.tags.find(t=>(!0===t.default||e&&"key"===t.default)&&t.test?.test(i))||r[n.SCALAR];if(r.compat){let e=r.compat.find(e=>e.default&&e.test?.test(i))??r[n.SCALAR];if(o.tag!==e.tag){let r=t.tagString(o.tag),n=t.tagString(e.tag);a(s,"TAG_RESOLVE_FAILED",`Value may be parsed as either ${r} or ${n}`,!0)}}return o}(e,u,t,o):e.schema[n.SCALAR];try{let s=l.resolve(u,e=>o(r??t,"TAG_RESOLVE_FAILED",e),e.options);c=n.isScalar(s)?s:new i.Scalar(s)}catch(e){o(r??t,"TAG_RESOLVE_FAILED",e instanceof Error?e.message:String(e)),c=new i.Scalar(u)}return c.range=h,c.source=u,d&&(c.type=d),p&&(c.tag=p),l.format&&(c.format=l.format),f&&(c.comment=f),c}},2545(e,t,r){var n=r(932),i=r(7087),s=r(9960),a=r(3409),o=r(6730),l=r(6040),c=r(4915);function u(e){if("number"==typeof e)return[e,e+1];if(Array.isArray(e))return 2===e.length?e:[e[0],e[1]];let{offset:t,source:r}=e;return[t,t+("string"==typeof r?r.length:1)]}function d(e){let t="",r=!1,n=!1;for(let i=0;i<e.length;++i){let s=e[i];switch(s[0]){case"#":t+=(""===t?"":n?"\n\n":"\n")+(s.substring(1)||" "),r=!0,n=!1;break;case"%":e[i+1]?.[0]!=="#"&&(i+=1),r=!1;break;default:r||(n=!0),r=!1}}return{comment:t,afterEmptyLine:n}}t.Composer=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(e,t,r,n)=>{let i=u(e);n?this.warnings.push(new a.YAMLWarning(i,t,r)):this.errors.push(new a.YAMLParseError(i,t,r))},this.directives=new i.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,t){let{comment:r,afterEmptyLine:n}=d(this.prelude);if(r){let i=e.contents;if(t)e.comment=e.comment?`${e.comment}
99
+ ${r}`:r;else if(n||e.directives.docStart||!i)e.commentBefore=r;else if(o.isCollection(i)&&!i.flow&&i.items.length>0){let e=i.items[0];o.isPair(e)&&(e=e.key);let t=e.commentBefore;e.commentBefore=t?`${r}
100
+ ${t}`:r}else{let e=i.commentBefore;i.commentBefore=e?`${r}
101
+ ${e}`:r}}if(t){for(let t=0;t<this.errors.length;++t)e.errors.push(this.errors[t]);for(let t=0;t<this.warnings.length;++t)e.warnings.push(this.warnings[t])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:d(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,r=-1){for(let t of e)yield*this.next(t);yield*this.end(t,r)}*next(e){switch(n.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(t,r,n)=>{let i=u(e);i[0]+=t,this.onError(i,"BAD_DIRECTIVE",r,n)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let t=l.composeDoc(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,r=new a.YAMLParseError(u(e),"UNEXPECTED_TOKEN",t);this.atDirectives||!this.doc?this.errors.push(r):this.doc.errors.push(r);break}case"doc-end":{if(!this.doc){this.errors.push(new a.YAMLParseError(u(e),"UNEXPECTED_TOKEN","Unexpected doc-end without preceding document"));break}this.doc.directives.docEnd=!0;let t=c.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let e=this.doc.comment;this.doc.comment=e?`${e}
102
+ ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new a.YAMLParseError(u(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let e=Object.assign({_directives:this.directives},this.options),r=new s.Document(void 0,e);this.atDirectives&&this.onError(t,"MISSING_CHAR","Missing directives-end indicator line"),r.range=[0,t,t],this.decorate(r,!1),yield r}}}},3244(e,t,r){var n=r(7748),i=r(73),s=r(7800),a=r(6884),o=r(7090),l=r(8388);let c="All mapping items must start at the same column";t.resolveBlockMap=function({composeNode:e,composeEmptyNode:t},r,u,d,f){let h=new(f?.nodeClass??i.YAMLMap)(r.schema);r.atRoot&&(r.atRoot=!1);let p=u.offset,m=null;for(let i of u.items){let{start:f,key:g,sep:y,value:b}=i,v=s.resolveProps(f,{indicator:"explicit-key-ind",next:g??y?.[0],offset:p,onError:d,parentIndent:u.indent,startOnNewline:!0}),w=!v.found;if(w){if(g&&("block-seq"===g.type?d(p,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in g&&g.indent!==u.indent&&d(p,"BAD_INDENT",c)),!v.anchor&&!v.tag&&!y){m=v.end,v.comment&&(h.comment?h.comment+="\n"+v.comment:h.comment=v.comment);continue}(v.newlineAfterProp||a.containsNewline(g))&&d(g??f[f.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else v.found?.indent!==u.indent&&d(p,"BAD_INDENT",c);r.atKey=!0;let x=v.end,k=g?e(r,g,v,d):t(r,x,f,null,v,d);r.schema.compat&&o.flowIndentCheck(u.indent,g,d),r.atKey=!1,l.mapIncludes(r,h.items,k)&&d(x,"DUPLICATE_KEY","Map keys must be unique");let S=s.resolveProps(y??[],{indicator:"map-value-ind",next:b,offset:k.range[2],onError:d,parentIndent:u.indent,startOnNewline:!g||"block-scalar"===g.type});if(p=S.end,S.found){w&&(b?.type!=="block-map"||S.hasNewline||d(p,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),r.options.strict&&v.start<S.found.offset-1024&&d(k.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let s=b?e(r,b,S,d):t(r,p,y,null,S,d);r.schema.compat&&o.flowIndentCheck(u.indent,b,d),p=s.range[2];let a=new n.Pair(k,s);r.options.keepSourceTokens&&(a.srcToken=i),h.items.push(a)}else{w&&d(k.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),S.comment&&(k.comment?k.comment+="\n"+S.comment:k.comment=S.comment);let e=new n.Pair(k);r.options.keepSourceTokens&&(e.srcToken=i),h.items.push(e)}}return m&&m<p&&d(m,"IMPOSSIBLE","Map comment with trailing content"),h.range=[u.offset,p,m??p],h}},2992(e,t,r){var n=r(8376);t.resolveBlockScalar=function(e,t,r){let i=t.offset,s=function({offset:e,props:t},r,n){if("block-scalar-header"!==t[0].type)return n(t[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:i}=t[0],s=i[0],a=0,o="",l=-1;for(let t=1;t<i.length;++t){let r=i[t];if(o||"-"!==r&&"+"!==r){let n=Number(r);!a&&n?a=n:-1===l&&(l=e+t)}else o=r}-1!==l&&n(l,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${i}`);let c=!1,u="",d=i.length;for(let e=1;e<t.length;++e){let i=t[e];switch(i.type){case"space":c=!0;case"newline":d+=i.source.length;break;case"comment":r&&!c&&n(i,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),d+=i.source.length,u=i.source.substring(1);break;case"error":n(i,"UNEXPECTED_TOKEN",i.message),d+=i.source.length;break;default:{let e=`Unexpected token in block scalar header: ${i.type}`;n(i,"UNEXPECTED_TOKEN",e);let t=i.source;t&&"string"==typeof t&&(d+=t.length)}}}return{mode:s,indent:a,chomp:o,comment:u,length:d}}(t,e.options.strict,r);if(!s)return{value:"",type:null,comment:"",range:[i,i,i]};let a=">"===s.mode?n.Scalar.BLOCK_FOLDED:n.Scalar.BLOCK_LITERAL,o=t.source?function(e){let t=e.split(/\n( *)/),r=t[0],n=r.match(/^( *)/),i=[n?.[1]?[n[1],r.slice(n[1].length)]:["",r]];for(let e=1;e<t.length;e+=2)i.push([t[e],t[e+1]]);return i}(t.source):[],l=o.length;for(let e=o.length-1;e>=0;--e){let t=o[e][1];if(""===t||"\r"===t)l=e;else break}if(0===l){let e="+"===s.chomp&&o.length>0?"\n".repeat(Math.max(1,o.length-1)):"",r=i+s.length;return t.source&&(r+=t.source.length),{value:e,type:a,comment:s.comment,range:[i,r,r]}}let c=t.indent+s.indent,u=t.offset+s.length,d=0;for(let t=0;t<l;++t){let[n,i]=o[t];if(""===i||"\r"===i)0===s.indent&&n.length>c&&(c=n.length);else{n.length<c&&r(u+n.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),0===s.indent&&(c=n.length),d=t,0!==c||e.atRoot||r(u,"BAD_INDENT","Block scalar values in collections must be indented");break}u+=n.length+i.length+1}for(let e=o.length-1;e>=l;--e)o[e][0].length>c&&(l=e+1);let f="",h="",p=!1;for(let e=0;e<d;++e)f+=o[e][0].slice(c)+"\n";for(let e=d;e<l;++e){let[t,i]=o[e];u+=t.length+i.length+1;let l="\r"===i[i.length-1];if(l&&(i=i.slice(0,-1)),i&&t.length<c){let e=s.indent?"explicit indentation indicator":"first line",n=`Block scalar lines must not be less indented than their ${e}`;r(u-i.length-(l?2:1),"BAD_INDENT",n),t=""}a===n.Scalar.BLOCK_LITERAL?(f+=h+t.slice(c)+i,h="\n"):t.length>c||" "===i[0]?(" "===h?h="\n":p||"\n"!==h||(h="\n\n"),f+=h+t.slice(c)+i,h="\n",p=!0):""===i?"\n"===h?f+="\n":h="\n":(f+=h+i,h=" ",p=!1)}switch(s.chomp){case"-":break;case"+":for(let e=l;e<o.length;++e)f+="\n"+o[e][0].slice(c);"\n"!==f[f.length-1]&&(f+="\n");break;default:f+="\n"}let m=i+s.length+t.source.length;return{value:f,type:a,comment:s.comment,range:[i,m,m]}}},6225(e,t,r){var n=r(7028),i=r(7800),s=r(7090);t.resolveBlockSeq=function({composeNode:e,composeEmptyNode:t},r,a,o,l){let c=new(l?.nodeClass??n.YAMLSeq)(r.schema);r.atRoot&&(r.atRoot=!1),r.atKey&&(r.atKey=!1);let u=a.offset,d=null;for(let{start:n,value:l}of a.items){let f=i.resolveProps(n,{indicator:"seq-item-ind",next:l,offset:u,onError:o,parentIndent:a.indent,startOnNewline:!0});if(!f.found)if(f.anchor||f.tag||l)l?.type==="block-seq"?o(f.end,"BAD_INDENT","All sequence items must start at the same column"):o(u,"MISSING_CHAR","Sequence item without - indicator");else{d=f.end,f.comment&&(c.comment=f.comment);continue}let h=l?e(r,l,f,o):t(r,f.end,n,null,f,o);r.schema.compat&&s.flowIndentCheck(a.indent,l,o),u=h.range[2],c.items.push(h)}return c.range=[a.offset,u,d??u],c}},4915(e,t){t.resolveEnd=function(e,t,r,n){let i="";if(e){let s=!1,a="";for(let o of e){let{source:e,type:l}=o;switch(l){case"space":s=!0;break;case"comment":{r&&!s&&n(o,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let t=e.substring(1)||" ";i?i+=a+t:i=t,a="";break}case"newline":i&&(a+=e),s=!0;break;default:n(o,"UNEXPECTED_TOKEN",`Unexpected ${l} at node end`)}t+=e.length}}return{comment:i,offset:t}}},9661(e,t,r){var n=r(6730),i=r(7748),s=r(73),a=r(7028),o=r(4915),l=r(7800),c=r(6884),u=r(8388);let d="Block collections are not allowed within flow collections",f=e=>e&&("block-map"===e.type||"block-seq"===e.type);t.resolveFlowCollection=function({composeNode:e,composeEmptyNode:t},r,h,p,m){let g="{"===h.start.source,y=g?"flow map":"flow sequence",b=new(m?.nodeClass??(g?s.YAMLMap:a.YAMLSeq))(r.schema);b.flow=!0;let v=r.atRoot;v&&(r.atRoot=!1),r.atKey&&(r.atKey=!1);let w=h.offset+h.start.source.length;for(let a=0;a<h.items.length;++a){let o=h.items[a],{start:m,key:v,sep:x,value:k}=o,S=l.resolveProps(m,{flow:y,indicator:"explicit-key-ind",next:v??x?.[0],offset:w,onError:p,parentIndent:h.indent,startOnNewline:!1});if(!S.found){if(!S.anchor&&!S.tag&&!x&&!k){0===a&&S.comma?p(S.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${y}`):a<h.items.length-1&&p(S.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${y}`),S.comment&&(b.comment?b.comment+="\n"+S.comment:b.comment=S.comment),w=S.end;continue}!g&&r.options.strict&&c.containsNewline(v)&&p(v,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(0===a)S.comma&&p(S.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${y}`);else if(S.comma||p(S.start,"MISSING_CHAR",`Missing , between ${y} items`),S.comment){let e="";e:for(let t of m)switch(t.type){case"comma":case"space":break;case"comment":e=t.source.substring(1);break e;default:break e}if(e){let t=b.items[b.items.length-1];n.isPair(t)&&(t=t.value??t.key),t.comment?t.comment+="\n"+e:t.comment=e,S.comment=S.comment.substring(e.length+1)}}if(g||x||S.found){r.atKey=!0;let n=S.end,a=v?e(r,v,S,p):t(r,n,m,null,S,p);f(v)&&p(a.range,"BLOCK_IN_FLOW",d),r.atKey=!1;let c=l.resolveProps(x??[],{flow:y,indicator:"map-value-ind",next:k,offset:a.range[2],onError:p,parentIndent:h.indent,startOnNewline:!1});if(c.found){if(!g&&!S.found&&r.options.strict){if(x)for(let e of x){if(e===c.found)break;if("newline"===e.type){p(e,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}S.start<c.found.offset-1024&&p(c.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else k&&("source"in k&&k.source?.[0]===":"?p(k,"MISSING_CHAR",`Missing space after : in ${y}`):p(c.start,"MISSING_CHAR",`Missing , or : between ${y} items`));let _=k?e(r,k,c,p):c.found?t(r,c.end,x,null,c,p):null;_?f(k)&&p(_.range,"BLOCK_IN_FLOW",d):c.comment&&(a.comment?a.comment+="\n"+c.comment:a.comment=c.comment);let O=new i.Pair(a,_);if(r.options.keepSourceTokens&&(O.srcToken=o),g)u.mapIncludes(r,b.items,a)&&p(n,"DUPLICATE_KEY","Map keys must be unique"),b.items.push(O);else{let e=new s.YAMLMap(r.schema);e.flow=!0,e.items.push(O);let t=(_??a).range;e.range=[a.range[0],t[1],t[2]],b.items.push(e)}w=_?_.range[2]:c.end}else{let n=k?e(r,k,S,p):t(r,S.end,x,null,S,p);b.items.push(n),w=n.range[2],f(k)&&p(n.range,"BLOCK_IN_FLOW",d)}}let x=g?"}":"]",[k,...S]=h.end,_=w;if(k?.source===x)_=k.offset+k.source.length;else{let e=y[0].toUpperCase()+y.substring(1),t=v?`${e} must end with a ${x}`:`${e} in block collection must be sufficiently indented and end with a ${x}`;p(w,v?"MISSING_CHAR":"BAD_INDENT",t),k&&1!==k.source.length&&S.unshift(k)}if(S.length>0){let e=o.resolveEnd(S,_,r.options.strict,p);e.comment&&(b.comment?b.comment+="\n"+e.comment:b.comment=e.comment),b.range=[h.offset,_,e.offset]}else b.range=[h.offset,_,_];return b}},3165(e,t,r){var n=r(8376),i=r(4915);function s(e){let t,r;try{t=RegExp("(.*?)(?<![ ])[ ]*\r?\n","sy"),r=RegExp("[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?\n","sy")}catch{t=/(.*?)[ \t]*\r?\n/sy,r=/[ \t]*(.*?)[ \t]*\r?\n/sy}let n=t.exec(e);if(!n)return e;let i=n[1],s=" ",a=t.lastIndex;for(r.lastIndex=a;n=r.exec(e);)""===n[1]?"\n"===s?i+=s:s="\n":(i+=s+n[1],s=" "),a=r.lastIndex;let o=/[ \t]*(.*)/sy;return o.lastIndex=a,n=o.exec(e),i+s+(n?.[1]??"")}let a={0:"\0",a:"\x07",b:"\b",e:"\x1b",f:"\f",n:"\n",r:"\r",t:" ",v:"\v",N:"…",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};t.resolveFlowScalar=function(e,t,r){let o,l,{offset:c,type:u,source:d,end:f}=e,h=(e,t,n)=>r(c+e,t,n);switch(u){case"scalar":o=n.Scalar.PLAIN,l=function(e,t){let r="";switch(e[0]){case" ":r="a tab character";break;case",":r="flow indicator character ,";break;case"%":r="directive indicator character %";break;case"|":case">":r=`block scalar indicator ${e[0]}`;break;case"@":case"`":r=`reserved character ${e[0]}`}return r&&t(0,"BAD_SCALAR_START",`Plain value cannot start with ${r}`),s(e)}(d,h);break;case"single-quoted-scalar":var p,m;o=n.Scalar.QUOTE_SINGLE,p=d,m=h,("'"!==p[p.length-1]||1===p.length)&&m(p.length,"MISSING_CHAR","Missing closing 'quote"),l=s(p.slice(1,-1)).replace(/''/g,"'");break;case"double-quoted-scalar":o=n.Scalar.QUOTE_DOUBLE,l=function(e,t){let r="";for(let n=1;n<e.length-1;++n){let i=e[n];if("\r"!==i||"\n"!==e[n+1])if("\n"===i){let{fold:t,offset:i}=function(e,t){let r="",n=e[t+1];for(;(" "===n||" "===n||"\n"===n||"\r"===n)&&("\r"!==n||"\n"===e[t+2]);)"\n"===n&&(r+="\n"),t+=1,n=e[t+1];return r||(r=" "),{fold:r,offset:t}}(e,n);r+=t,n=i}else if("\\"===i){let i=e[++n],s=a[i];if(s)r+=s;else if("\n"===i)for(i=e[n+1];" "===i||" "===i;)i=e[++n+1];else if("\r"===i&&"\n"===e[n+1])for(i=e[++n+1];" "===i||" "===i;)i=e[++n+1];else if("x"===i||"u"===i||"U"===i){let s="x"===i?2:"u"===i?4:8;r+=function(e,t,r,n){let i=e.substr(t,r),s=i.length===r&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;try{return String.fromCodePoint(s)}catch{let i=e.substr(t-2,r+2);return n(t-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${i}`),i}}(e,n+1,s,t),n+=s}else{let i=e.substr(n-1,2);t(n-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${i}`),r+=i}}else if(" "===i||" "===i){let t=n,s=e[n+1];for(;" "===s||" "===s;)s=e[++n+1];"\n"!==s&&("\r"!==s||"\n"!==e[n+2])&&(r+=n>t?e.slice(t,n+1):i)}else r+=i}return('"'!==e[e.length-1]||1===e.length)&&t(e.length,"MISSING_CHAR",'Missing closing "quote'),r}(d,h);break;default:return r(e,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${u}`),{value:"",type:null,comment:"",range:[c,c+d.length,c+d.length]}}let g=c+d.length,y=i.resolveEnd(f,g,t,r);return{value:l,type:o,comment:y.comment,range:[c,g,y.offset]}}},7800(e,t){t.resolveProps=function(e,{flow:t,indicator:r,next:n,offset:i,onError:s,parentIndent:a,startOnNewline:o}){let l=!1,c=o,u=o,d="",f="",h=!1,p=!1,m=null,g=null,y=null,b=null,v=null,w=null,x=null;for(let i of e)switch(p&&("space"!==i.type&&"newline"!==i.type&&"comma"!==i.type&&s(i.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),p=!1),m&&(c&&"comment"!==i.type&&"newline"!==i.type&&s(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),m=null),i.type){case"space":!t&&("doc-start"!==r||n?.type!=="flow-collection")&&i.source.includes(" ")&&(m=i),u=!0;break;case"comment":{u||s(i,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let e=i.source.substring(1)||" ";d?d+=f+e:d=e,f="",c=!1;break}case"newline":c?d?d+=i.source:w&&"seq-item-ind"===r||(l=!0):f+=i.source,c=!0,h=!0,(g||y)&&(b=i),u=!0;break;case"anchor":g&&s(i,"MULTIPLE_ANCHORS","A node can have at most one anchor"),i.source.endsWith(":")&&s(i.offset+i.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),g=i,x??(x=i.offset),c=!1,u=!1,p=!0;break;case"tag":y&&s(i,"MULTIPLE_TAGS","A node can have at most one tag"),y=i,x??(x=i.offset),c=!1,u=!1,p=!0;break;case r:(g||y)&&s(i,"BAD_PROP_ORDER",`Anchors and tags must be after the ${i.source} indicator`),w&&s(i,"UNEXPECTED_TOKEN",`Unexpected ${i.source} in ${t??"collection"}`),w=i,c="seq-item-ind"===r||"explicit-key-ind"===r,u=!1;break;case"comma":if(t){v&&s(i,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`),v=i,c=!1,u=!1;break}default:s(i,"UNEXPECTED_TOKEN",`Unexpected ${i.type} token`),c=!1,u=!1}let k=e[e.length-1],S=k?k.offset+k.source.length:i;return p&&n&&"space"!==n.type&&"newline"!==n.type&&"comma"!==n.type&&("scalar"!==n.type||""!==n.source)&&s(n.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),m&&(c&&m.indent<=a||n?.type==="block-map"||n?.type==="block-seq")&&s(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:v,found:w,spaceBefore:l,comment:d,hasNewline:h,anchor:g,tag:y,newlineAfterProp:b,end:S,start:x??S}}},6884(e,t){t.containsNewline=function e(t){if(!t)return null;switch(t.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(t.source.includes("\n"))return!0;if(t.end){for(let e of t.end)if("newline"===e.type)return!0}return!1;case"flow-collection":for(let r of t.items){for(let e of r.start)if("newline"===e.type)return!0;if(r.sep){for(let e of r.sep)if("newline"===e.type)return!0}if(e(r.key)||e(r.value))return!0}return!1;default:return!0}}},4898(e,t){t.emptyScalarPosition=function(e,t,r){if(t){r??(r=t.length);for(let n=r-1;n>=0;--n){let r=t[n];switch(r.type){case"space":case"comment":case"newline":e-=r.source.length;continue}for(r=t[++n];r?.type==="space";)e+=r.source.length,r=t[++n];break}}return e}},7090(e,t,r){var n=r(6884);t.flowIndentCheck=function(e,t,r){if(t?.type==="flow-collection"){let i=t.end[0];i.indent===e&&("]"===i.source||"}"===i.source)&&n.containsNewline(t)&&r(i,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}},8388(e,t,r){var n=r(6730);t.mapIncludes=function(e,t,r){let{uniqueKeys:i}=e.options;if(!1===i)return!1;let s="function"==typeof i?i:(e,t)=>e===t||n.isScalar(e)&&n.isScalar(t)&&e.value===t.value;return t.some(e=>s(e.key,r))}},9960(e,t,r){var n=r(2298),i=r(7580),s=r(6730),a=r(7748),o=r(2234),l=r(8227),c=r(5966),u=r(9531),d=r(9768),f=r(7377),h=r(7087);function p(e){if(s.isCollection(e))return!0;throw Error("Expected a YAML collection as document contents")}t.Document=class e{constructor(e,t,r){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,s.NODE_TYPE,{value:s.DOC});let n=null;"function"==typeof t||Array.isArray(t)?n=t:void 0===r&&t&&(r=t,t=void 0);let i=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},r);this.options=i;let{version:a}=i;r?._directives?(this.directives=r._directives.atDocument(),this.directives.yaml.explicit&&(a=this.directives.yaml.version)):this.directives=new h.Directives({version:a}),this.setSchema(a,r),this.contents=void 0===e?null:this.createNode(e,n,r)}clone(){let t=Object.create(e.prototype,{[s.NODE_TYPE]:{value:s.DOC}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=s.isNode(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(e){p(this.contents)&&this.contents.add(e)}addIn(e,t){p(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let r=u.anchorNames(this);e.anchor=!t||r.has(t)?u.findNewAnchor(t||"a",r):t}return new n.Alias(e.anchor)}createNode(e,t,r){let n;if("function"==typeof t)e=t.call({"":e},"",e),n=t;else if(Array.isArray(t)){let e=t.filter(e=>"number"==typeof e||e instanceof String||e instanceof Number).map(String);e.length>0&&(t=t.concat(e)),n=t}else void 0===r&&t&&(r=t,t=void 0);let{aliasDuplicateObjects:i,anchorPrefix:a,flow:o,keepUndefined:l,onTagObj:c,tag:d}=r??{},{onAnchor:h,setAnchors:p,sourceObjects:m}=u.createNodeAnchors(this,a||"a"),g={aliasDuplicateObjects:i??!0,keepUndefined:l??!1,onAnchor:h,onTagObj:c,replacer:n,schema:this.schema,sourceObjects:m},y=f.createNode(e,d,g);return o&&s.isCollection(y)&&(y.flow=!0),p(),y}createPair(e,t,r={}){let n=this.createNode(e,null,r),i=this.createNode(t,null,r);return new a.Pair(n,i)}delete(e){return!!p(this.contents)&&this.contents.delete(e)}deleteIn(e){return i.isEmptyPath(e)?null!=this.contents&&(this.contents=null,!0):!!p(this.contents)&&this.contents.deleteIn(e)}get(e,t){return s.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return i.isEmptyPath(e)?!t&&s.isScalar(this.contents)?this.contents.value:this.contents:s.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return!!s.isCollection(this.contents)&&this.contents.has(e)}hasIn(e){return i.isEmptyPath(e)?void 0!==this.contents:!!s.isCollection(this.contents)&&this.contents.hasIn(e)}set(e,t){null==this.contents?this.contents=i.collectionFromPath(this.schema,[e],t):p(this.contents)&&this.contents.set(e,t)}setIn(e,t){i.isEmptyPath(e)?this.contents=t:null==this.contents?this.contents=i.collectionFromPath(this.schema,Array.from(e),t):p(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){let r;switch("number"==typeof e&&(e=String(e)),e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new h.Directives({version:"1.1"}),r={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=e:this.directives=new h.Directives({version:e}),r={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,r=null;break;default:{let t=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${t}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(r)this.schema=new l.Schema(Object.assign(r,t));else throw Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:t,mapAsMap:r,maxAliasCount:n,onAnchor:i,reviver:s}={}){let a={anchors:new Map,doc:this,keep:!e,mapAsMap:!0===r,mapKeyWarned:!1,maxAliasCount:"number"==typeof n?n:100},l=o.toJS(this.contents,t??"",a);if("function"==typeof i)for(let{count:e,res:t}of a.anchors.values())i(t,e);return"function"==typeof s?d.applyReviver(s,{"":l},"",l):l}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||0>=Number(e.indent))){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return c.stringifyDocument(this,e)}}},9531(e,t,r){var n=r(6730),i=r(7995);function s(e){let t=new Set;return i.visit(e,{Value(e,r){r.anchor&&t.add(r.anchor)}}),t}function a(e,t){for(let r=1;;++r){let n=`${e}${r}`;if(!t.has(n))return n}}t.anchorIsValid=function(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=JSON.stringify(e);throw Error(`Anchor must not contain whitespace or control characters: ${t}`)}return!0},t.anchorNames=s,t.createNodeAnchors=function(e,t){let r=[],i=new Map,o=null;return{onAnchor:n=>{r.push(n),o??(o=s(e));let i=a(t,o);return o.add(i),i},setAnchors:()=>{for(let e of r){let t=i.get(e);if("object"==typeof t&&t.anchor&&(n.isScalar(t.node)||n.isCollection(t.node)))t.node.anchor=t.anchor;else{let t=Error("Failed to resolve repeated object (this should not happen)");throw t.source=e,t}}},sourceObjects:i}},t.findNewAnchor=a},9768(e,t){t.applyReviver=function e(t,r,n,i){if(i&&"object"==typeof i)if(Array.isArray(i))for(let r=0,n=i.length;r<n;++r){let n=i[r],s=e(t,i,String(r),n);void 0===s?delete i[r]:s!==n&&(i[r]=s)}else if(i instanceof Map)for(let r of Array.from(i.keys())){let n=i.get(r),s=e(t,i,r,n);void 0===s?i.delete(r):s!==n&&i.set(r,s)}else if(i instanceof Set)for(let r of Array.from(i)){let n=e(t,i,r,r);void 0===n?i.delete(r):n!==r&&(i.delete(r),i.add(n))}else for(let[r,n]of Object.entries(i)){let s=e(t,i,r,n);void 0===s?delete i[r]:s!==n&&(i[r]=s)}return t.call(r,n,i)}},7377(e,t,r){var n=r(2298),i=r(6730),s=r(8376);t.createNode=function(e,t,r){let a;if(i.isDocument(e)&&(e=e.contents),i.isNode(e))return e;if(i.isPair(e)){let t=r.schema[i.MAP].createNode?.(r.schema,null,r);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||"u">typeof BigInt&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:o,onAnchor:l,onTagObj:c,schema:u,sourceObjects:d}=r;if(o&&e&&"object"==typeof e){if(a=d.get(e))return a.anchor??(a.anchor=l(e)),new n.Alias(a.anchor);a={anchor:null,node:null},d.set(e,a)}t?.startsWith("!!")&&(t="tag:yaml.org,2002:"+t.slice(2));let f=function(e,t,r){if(t){let e=r.filter(e=>e.tag===t),n=e.find(e=>!e.format)??e[0];if(!n)throw Error(`Tag ${t} not found`);return n}return r.find(t=>t.identify?.(e)&&!t.format)}(e,t,u.tags);if(!f){if(e&&"function"==typeof e.toJSON&&(e=e.toJSON()),!e||"object"!=typeof e){let t=new s.Scalar(e);return a&&(a.node=t),t}f=e instanceof Map?u[i.MAP]:Symbol.iterator in Object(e)?u[i.SEQ]:u[i.MAP]}c&&(c(f),delete r.onTagObj);let h=f?.createNode?f.createNode(r.schema,e,r):"function"==typeof f?.nodeClass?.from?f.nodeClass.from(r.schema,e,r):new s.Scalar(e);return t?h.tag=t:f.default||(h.tag=f.tag),a&&(a.node=h),h}},7087(e,t,r){var n=r(6730),i=r(7995);let s={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},a=e=>e.replace(/[!,[\]{}]/g,e=>s[e]);class o{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},o.defaultYaml,e),this.tags=Object.assign({},o.defaultTags,t)}clone(){let e=new o(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new o(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:o.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},o.defaultTags)}return e}add(e,t){this.atNextDocument&&(this.yaml={explicit:o.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},o.defaultTags),this.atNextDocument=!1);let r=e.trim().split(/[ \t]+/),n=r.shift();switch(n){case"%TAG":{if(2!==r.length&&(t(0,"%TAG directive should contain exactly two parts"),r.length<2))return!1;let[e,n]=r;return this.tags[e]=n,!0}case"%YAML":{if(this.yaml.explicit=!0,1!==r.length)return t(0,"%YAML directive should contain exactly one part"),!1;let[e]=r;if("1.1"===e||"1.2"===e)return this.yaml.version=e,!0;{let r=/^\d+\.\d+$/.test(e);return t(6,`Unsupported YAML version ${e}`,r),!1}}default:return t(0,`Unknown directive ${n}`,!0),!1}}tagName(e,t){if("!"===e)return"!";if("!"!==e[0])return t(`Not a valid tag: ${e}`),null;if("<"===e[1]){let r=e.slice(2,-1);return"!"===r||"!!"===r?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(">"!==e[e.length-1]&&t("Verbatim tags must end with a >"),r)}let[,r,n]=e.match(/^(.*!)([^!]*)$/s);n||t(`The ${e} tag has no suffix`);let i=this.tags[r];if(i)try{return i+decodeURIComponent(n)}catch(e){return t(String(e)),null}return"!"===r?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,r]of Object.entries(this.tags))if(e.startsWith(r))return t+a(e.substring(r.length));return"!"===e[0]?e:`!<${e}>`}toString(e){let t,r=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],s=Object.entries(this.tags);if(e&&s.length>0&&n.isNode(e.contents)){let r={};i.visit(e.contents,(e,t)=>{n.isNode(t)&&t.tag&&(r[t.tag]=!0)}),t=Object.keys(r)}else t=[];for(let[n,i]of s)("!!"!==n||"tag:yaml.org,2002:"!==i)&&(!e||t.some(e=>e.startsWith(i)))&&r.push(`%TAG ${n} ${i}`);return r.join("\n")}}o.defaultYaml={explicit:!1,version:"1.2"},o.defaultTags={"!!":"tag:yaml.org,2002:"},t.Directives=o},3409(e,t){class r extends Error{constructor(e,t,r,n){super(),this.name=e,this.code=r,this.message=n,this.pos=t}}t.YAMLError=r,t.YAMLParseError=class extends r{constructor(e,t,r){super("YAMLParseError",e,t,r)}},t.YAMLWarning=class extends r{constructor(e,t,r){super("YAMLWarning",e,t,r)}},t.prettifyError=(e,t)=>r=>{if(-1===r.pos[0])return;r.linePos=r.pos.map(e=>t.linePos(e));let{line:n,col:i}=r.linePos[0];r.message+=` at line ${n}, column ${i}`;let s=i-1,a=e.substring(t.lineStarts[n-1],t.lineStarts[n]).replace(/[\n\r]+$/,"");if(s>=60&&a.length>80){let e=Math.min(s-39,a.length-79);a="…"+a.substring(e),s-=e-1}if(a.length>80&&(a=a.substring(0,79)+"…"),n>1&&/^ *$/.test(a.substring(0,s))){let r=e.substring(t.lineStarts[n-2],t.lineStarts[n-1]);r.length>80&&(r=r.substring(0,79)+"…\n"),a=r+a}if(/[^ ]/.test(a)){let e=1,t=r.linePos[1];t?.line===n&&t.col>i&&(e=Math.max(1,Math.min(t.col-i,80-s)));let o=" ".repeat(s)+"^".repeat(e);r.message+=`:
103
+
104
+ ${a}
105
+ ${o}
106
+ `}}},2976(e,t,r){var n=r(2545),i=r(9960),s=r(8227),a=r(3409),o=r(2298),l=r(6730),c=r(7748),u=r(8376),d=r(73),f=r(7028);r(9810);var h=r(7894),p=r(3813),m=r(5849),g=r(1094),y=r(7995);n.Composer,i.Document,s.Schema,a.YAMLError,a.YAMLParseError,a.YAMLWarning,o.Alias,l.isAlias,l.isCollection,l.isDocument,l.isMap,l.isNode,l.isPair,l.isScalar,l.isSeq,c.Pair,u.Scalar,d.YAMLMap,f.YAMLSeq,h.Lexer,p.LineCounter,m.Parser,g.parse,g.parseAllDocuments,g.parseDocument,g.stringify,y.visit,y.visitAsync},2186(e,t,r){var n=r(932);t.debug=function(e,...t){"debug"===e&&console.log(...t)},t.warn=function(e,t){("debug"===e||"warn"===e)&&("function"==typeof n.emitWarning?n.emitWarning(t):console.warn(t))}},2298(e,t,r){var n=r(9531),i=r(7995),s=r(6730),a=r(5476),o=r(2234);class l extends a.NodeBase{constructor(e){super(s.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw Error("Alias nodes cannot have tags")}})}resolve(e,t){let r,n;if(t?.maxAliasCount===0)throw ReferenceError("Alias resolution is disabled");for(let a of(t?.aliasResolveCache?r=t.aliasResolveCache:(r=[],i.visit(e,{Node:(e,t)=>{(s.isAlias(t)||s.hasAnchor(t))&&r.push(t)}}),t&&(t.aliasResolveCache=r)),r)){if(a===this)break;a.anchor===this.source&&(n=a)}return n}toJSON(e,t){if(!t)return{source:this.source};let{anchors:r,doc:n,maxAliasCount:i}=t,a=this.resolve(n,t);if(!a)throw ReferenceError(`Unresolved alias (the anchor must be set before the alias): ${this.source}`);let l=r.get(a);if(l||(o.toJS(a,null,t),l=r.get(a)),l?.res===void 0)throw ReferenceError("This should not happen: Alias anchor was not resolved?");if(i>=0&&(l.count+=1,0===l.aliasCount&&(l.aliasCount=function e(t,r,n){if(s.isAlias(r)){let e=r.resolve(t),i=n&&e&&n.get(e);return i?i.count*i.aliasCount:0}if(s.isCollection(r)){let i=0;for(let s of r.items){let r=e(t,s,n);r>i&&(i=r)}return i}return s.isPair(r)?Math.max(e(t,r.key,n),e(t,r.value,n)):1}(n,a,r)),l.count*l.aliasCount>i))throw ReferenceError("Excessive alias count indicates a resource exhaustion attack");return l.res}toString(e,t,r){let i=`*${this.source}`;if(e){if(n.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source))throw Error(`Unresolved alias (the anchor must be set before the alias): ${this.source}`);if(e.implicitKey)return`${i} `}return i}}t.Alias=l},7580(e,t,r){var n=r(7377),i=r(6730),s=r(5476);function a(e,t,r){let i=r;for(let e=t.length-1;e>=0;--e){let r=t[e];if("number"==typeof r&&Number.isInteger(r)&&r>=0){let e=[];e[r]=i,i=e}else i=new Map([[r,i]])}return n.createNode(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}let o=e=>null==e||"object"==typeof e&&!!e[Symbol.iterator]().next().done;class l extends s.NodeBase{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(t=>i.isNode(t)||i.isPair(t)?t.clone(e):t),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(o(e))this.add(t);else{let[r,...n]=e,s=this.get(r,!0);if(i.isCollection(s))s.addIn(n,t);else if(void 0===s&&this.schema)this.set(r,a(this.schema,n,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${n}`)}}deleteIn(e){let[t,...r]=e;if(0===r.length)return this.delete(t);let n=this.get(t,!0);if(i.isCollection(n))return n.deleteIn(r);throw Error(`Expected YAML collection at ${t}. Remaining path: ${r}`)}getIn(e,t){let[r,...n]=e,s=this.get(r,!0);return 0===n.length?!t&&i.isScalar(s)?s.value:s:i.isCollection(s)?s.getIn(n,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!i.isPair(t))return!1;let r=t.value;return null==r||e&&i.isScalar(r)&&null==r.value&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(e){let[t,...r]=e;if(0===r.length)return this.has(t);let n=this.get(t,!0);return!!i.isCollection(n)&&n.hasIn(r)}setIn(e,t){let[r,...n]=e;if(0===n.length)this.set(r,t);else{let e=this.get(r,!0);if(i.isCollection(e))e.setIn(n,t);else if(void 0===e&&this.schema)this.set(r,a(this.schema,n,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${n}`)}}}t.Collection=l,t.collectionFromPath=a,t.isEmptyPath=o},5476(e,t,r){var n=r(9768),i=r(6730),s=r(2234);t.NodeBase=class{constructor(e){Object.defineProperty(this,i.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:r,onAnchor:a,reviver:o}={}){if(!i.isDocument(e))throw TypeError("A document argument is required");let l={anchors:new Map,doc:e,keep:!0,mapAsMap:!0===t,mapKeyWarned:!1,maxAliasCount:"number"==typeof r?r:100},c=s.toJS(this,"",l);if("function"==typeof a)for(let{count:e,res:t}of l.anchors.values())a(t,e);return"function"==typeof o?n.applyReviver(o,{"":c},"",c):c}}},7748(e,t,r){var n=r(7377),i=r(4711),s=r(3757),a=r(6730);class o{constructor(e,t=null){Object.defineProperty(this,a.NODE_TYPE,{value:a.PAIR}),this.key=e,this.value=t}clone(e){let{key:t,value:r}=this;return a.isNode(t)&&(t=t.clone(e)),a.isNode(r)&&(r=r.clone(e)),new o(t,r)}toJSON(e,t){let r=t?.mapAsMap?new Map:{};return s.addPairToJSMap(t,r,this)}toString(e,t,r){return e?.doc?i.stringifyPair(this,e,t,r):JSON.stringify(this)}}t.Pair=o,t.createPair=function(e,t,r){return new o(n.createNode(e,void 0,r),n.createNode(t,void 0,r))}},8376(e,t,r){var n=r(6730),i=r(5476),s=r(2234);class a extends i.NodeBase{constructor(e){super(n.SCALAR),this.value=e}toJSON(e,t){return t?.keep?this.value:s.toJS(this.value,e,t)}toString(){return String(this.value)}}a.BLOCK_FOLDED="BLOCK_FOLDED",a.BLOCK_LITERAL="BLOCK_LITERAL",a.PLAIN="PLAIN",a.QUOTE_DOUBLE="QUOTE_DOUBLE",a.QUOTE_SINGLE="QUOTE_SINGLE",t.Scalar=a,t.isScalarValue=e=>!e||"function"!=typeof e&&"object"!=typeof e},73(e,t,r){var n=r(8143),i=r(3757),s=r(7580),a=r(6730),o=r(7748),l=r(8376);function c(e,t){let r=a.isScalar(t)?t.value:t;for(let n of e)if(a.isPair(n)&&(n.key===t||n.key===r||a.isScalar(n.key)&&n.key.value===r))return n}class u extends s.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(a.MAP,e),this.items=[]}static from(e,t,r){let{keepUndefined:n,replacer:i}=r,s=new this(e),a=(e,a)=>{if("function"==typeof i)a=i.call(t,e,a);else if(Array.isArray(i)&&!i.includes(e))return;(void 0!==a||n)&&s.items.push(o.createPair(e,a,r))};if(t instanceof Map)for(let[e,r]of t)a(e,r);else if(t&&"object"==typeof t)for(let e of Object.keys(t))a(e,t[e]);return"function"==typeof e.sortMapEntries&&s.items.sort(e.sortMapEntries),s}add(e,t){let r;r=a.isPair(e)?e:e&&"object"==typeof e&&"key"in e?new o.Pair(e.key,e.value):new o.Pair(e,e?.value);let n=c(this.items,r.key),i=this.schema?.sortMapEntries;if(n){if(!t)throw Error(`Key ${r.key} already set`);a.isScalar(n.value)&&l.isScalarValue(r.value)?n.value.value=r.value:n.value=r.value}else if(i){let e=this.items.findIndex(e=>0>i(r,e));-1===e?this.items.push(r):this.items.splice(e,0,r)}else this.items.push(r)}delete(e){let t=c(this.items,e);return!!t&&this.items.splice(this.items.indexOf(t),1).length>0}get(e,t){let r=c(this.items,e),n=r?.value;return(!t&&a.isScalar(n)?n.value:n)??void 0}has(e){return!!c(this.items,e)}set(e,t){this.add(new o.Pair(e,t),!0)}toJSON(e,t,r){let n=r?new r:t?.mapAsMap?new Map:{};for(let e of(t?.onCreate&&t.onCreate(n),this.items))i.addPairToJSMap(t,n,e);return n}toString(e,t,r){if(!e)return JSON.stringify(this);for(let e of this.items)if(!a.isPair(e))throw Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),n.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:r,onComment:t})}}t.YAMLMap=u,t.findPair=c},7028(e,t,r){var n=r(7377),i=r(8143),s=r(7580),a=r(6730),o=r(8376),l=r(2234);class c extends s.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(a.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=u(e);return"number"==typeof t&&this.items.splice(t,1).length>0}get(e,t){let r=u(e);if("number"!=typeof r)return;let n=this.items[r];return!t&&a.isScalar(n)?n.value:n}has(e){let t=u(e);return"number"==typeof t&&t<this.items.length}set(e,t){let r=u(e);if("number"!=typeof r)throw Error(`Expected a valid index, not ${e}.`);let n=this.items[r];a.isScalar(n)&&o.isScalarValue(t)?n.value=t:this.items[r]=t}toJSON(e,t){let r=[];t?.onCreate&&t.onCreate(r);let n=0;for(let e of this.items)r.push(l.toJS(e,String(n++),t));return r}toString(e,t,r){return e?i.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:r,onComment:t}):JSON.stringify(this)}static from(e,t,r){let{replacer:i}=r,s=new this(e);if(t&&Symbol.iterator in Object(t)){let e=0;for(let a of t){if("function"==typeof i){let r=t instanceof Set?a:String(e++);a=i.call(t,r,a)}s.items.push(n.createNode(a,void 0,r))}}return s}}function u(e){let t=a.isScalar(e)?e.value:e;return t&&"string"==typeof t&&(t=Number(t)),"number"==typeof t&&Number.isInteger(t)&&t>=0?t:null}t.YAMLSeq=c},3757(e,t,r){var n=r(2186),i=r(8327),s=r(6203),a=r(6730),o=r(2234);t.addPairToJSMap=function(e,t,{key:r,value:l}){if(a.isNode(r)&&r.addToJSMap)r.addToJSMap(e,t,l);else if(i.isMergeKey(e,r))i.addMergeToJSMap(e,t,l);else{let i=o.toJS(r,"",e);if(t instanceof Map)t.set(i,o.toJS(l,i,e));else if(t instanceof Set)t.add(i);else{let c=function(e,t,r){if(null===t)return"";if("object"!=typeof t)return String(t);if(a.isNode(e)&&r?.doc){let t=s.createStringifyContext(r.doc,{});for(let e of(t.anchors=new Set,r.anchors.keys()))t.anchors.add(e.anchor);t.inFlow=!0,t.inStringifyKey=!0;let i=e.toString(t);if(!r.mapKeyWarned){let e=JSON.stringify(i);e.length>40&&(e=e.substring(0,36)+'..."'),n.warn(r.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`),r.mapKeyWarned=!0}return i}return JSON.stringify(t)}(r,i,e),u=o.toJS(l,c,e);c in t?Object.defineProperty(t,c,{value:u,writable:!0,enumerable:!0,configurable:!0}):t[c]=u}}return t}},6730(e,t){let r=Symbol.for("yaml.alias"),n=Symbol.for("yaml.document"),i=Symbol.for("yaml.map"),s=Symbol.for("yaml.pair"),a=Symbol.for("yaml.scalar"),o=Symbol.for("yaml.seq"),l=Symbol.for("yaml.node.type"),c=e=>!!e&&"object"==typeof e&&e[l]===a;function u(e){if(e&&"object"==typeof e)switch(e[l]){case i:case o:return!0}return!1}t.ALIAS=r,t.DOC=n,t.MAP=i,t.NODE_TYPE=l,t.PAIR=s,t.SCALAR=a,t.SEQ=o,t.hasAnchor=e=>(c(e)||u(e))&&!!e.anchor,t.isAlias=e=>!!e&&"object"==typeof e&&e[l]===r,t.isCollection=u,t.isDocument=e=>!!e&&"object"==typeof e&&e[l]===n,t.isMap=e=>!!e&&"object"==typeof e&&e[l]===i,t.isNode=function(e){if(e&&"object"==typeof e)switch(e[l]){case r:case i:case a:case o:return!0}return!1},t.isPair=e=>!!e&&"object"==typeof e&&e[l]===s,t.isScalar=c,t.isSeq=e=>!!e&&"object"==typeof e&&e[l]===o},2234(e,t,r){var n=r(6730);t.toJS=function e(t,r,i){if(Array.isArray(t))return t.map((t,r)=>e(t,String(r),i));if(t&&"function"==typeof t.toJSON){if(!i||!n.hasAnchor(t))return t.toJSON(r,i);let e={aliasCount:0,count:1,res:void 0};i.anchors.set(t,e),i.onCreate=t=>{e.res=t,delete i.onCreate};let s=t.toJSON(r,i);return i.onCreate&&i.onCreate(s),s}return"bigint"!=typeof t||i?.keep?t:Number(t)}},8215(e,t,r){var n=r(2992),i=r(3165),s=r(3409),a=r(4286);function o(e,t){if(t)for(let r of t)switch(r.type){case"space":case"comment":e.push(r);break;case"newline":return e.push(r),!0}return!1}function l(e,t,r){switch(e.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":e.type=r,e.source=t;break;case"block-scalar":{let n=e.props.slice(1),i=t.length;for(let t of("block-scalar-header"===e.props[0].type&&(i-=e.props[0].source.length),n))t.offset+=i;delete e.props,Object.assign(e,{type:r,source:t,end:n});break}case"block-map":case"block-seq":{let n={type:"newline",offset:e.offset+t.length,indent:e.indent,source:"\n"};delete e.items,Object.assign(e,{type:r,source:t,end:[n]});break}default:{let n="indent"in e?e.indent:-1,i="end"in e&&Array.isArray(e.end)?e.end.filter(e=>"space"===e.type||"comment"===e.type||"newline"===e.type):[];for(let t of Object.keys(e))"type"!==t&&"offset"!==t&&delete e[t];Object.assign(e,{type:r,indent:n,source:t,end:i})}}}t.createScalarToken=function(e,t){let{implicitKey:r=!1,indent:n,inFlow:i=!1,offset:s=-1,type:l="PLAIN"}=t,c=a.stringifyString({type:l,value:e},{implicitKey:r,indent:n>0?" ".repeat(n):"",inFlow:i,options:{blockQuote:!0,lineWidth:-1}}),u=t.end??[{type:"newline",offset:-1,indent:n,source:"\n"}];switch(c[0]){case"|":case">":{let e=c.indexOf("\n"),t=c.substring(0,e),r=c.substring(e+1)+"\n",i=[{type:"block-scalar-header",offset:s,indent:n,source:t}];return o(i,u)||i.push({type:"newline",offset:-1,indent:n,source:"\n"}),{type:"block-scalar",offset:s,indent:n,props:i,source:r}}case'"':return{type:"double-quoted-scalar",offset:s,indent:n,source:c,end:u};case"'":return{type:"single-quoted-scalar",offset:s,indent:n,source:c,end:u};default:return{type:"scalar",offset:s,indent:n,source:c,end:u}}},t.resolveAsScalar=function(e,t=!0,r){if(e){let a=(e,t,n)=>{let i="number"==typeof e?e:Array.isArray(e)?e[0]:e.offset;if(r)r(i,t,n);else throw new s.YAMLParseError([i,i+1],t,n)};switch(e.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return i.resolveFlowScalar(e,t,a);case"block-scalar":return n.resolveBlockScalar({options:{strict:t}},e,a)}}return null},t.setScalarValue=function(e,t,r={}){let{afterKey:n=!1,implicitKey:i=!1,inFlow:s=!1,type:c}=r,u="indent"in e?e.indent:null;if(n&&"number"==typeof u&&(u+=2),!c)switch(e.type){case"single-quoted-scalar":c="QUOTE_SINGLE";break;case"double-quoted-scalar":c="QUOTE_DOUBLE";break;case"block-scalar":{let t=e.props[0];if("block-scalar-header"!==t.type)throw Error("Invalid block scalar header");c=">"===t.source[0]?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:c="PLAIN"}let d=a.stringifyString({type:c,value:t},{implicitKey:i||null===u,indent:null!==u&&u>0?" ".repeat(u):"",inFlow:s,options:{blockQuote:!0,lineWidth:-1}});switch(d[0]){case"|":case">":!function(e,t){let r=t.indexOf("\n"),n=t.substring(0,r),i=t.substring(r+1)+"\n";if("block-scalar"===e.type){let t=e.props[0];if("block-scalar-header"!==t.type)throw Error("Invalid block scalar header");t.source=n,e.source=i}else{let{offset:t}=e,r="indent"in e?e.indent:-1,s=[{type:"block-scalar-header",offset:t,indent:r,source:n}];for(let t of(o(s,"end"in e?e.end:void 0)||s.push({type:"newline",offset:-1,indent:r,source:"\n"}),Object.keys(e)))"type"!==t&&"offset"!==t&&delete e[t];Object.assign(e,{type:"block-scalar",indent:r,props:s,source:i})}}(e,d);break;case'"':l(e,d,"double-quoted-scalar");break;case"'":l(e,d,"single-quoted-scalar");break;default:l(e,d,"scalar")}}},2142(e,t){function r(e){switch(e.type){case"block-scalar":{let t="";for(let n of e.props)t+=r(n);return t+e.source}case"block-map":case"block-seq":{let t="";for(let r of e.items)t+=n(r);return t}case"flow-collection":{let t=e.start.source;for(let r of e.items)t+=n(r);for(let r of e.end)t+=r.source;return t}case"document":{let t=n(e);if(e.end)for(let r of e.end)t+=r.source;return t}default:{let t=e.source;if("end"in e&&e.end)for(let r of e.end)t+=r.source;return t}}}function n({start:e,key:t,sep:i,value:s}){let a="";for(let t of e)a+=t.source;if(t&&(a+=r(t)),i)for(let e of i)a+=e.source;return s&&(a+=r(s)),a}t.stringify=e=>"type"in e?r(e):n(e)},1844(e,t){let r=Symbol("break visit"),n=Symbol("skip children"),i=Symbol("remove item");function s(e,t){"type"in e&&"document"===e.type&&(e={start:e.start,value:e.value}),function e(t,n,s){let a=s(n,t);if("symbol"==typeof a)return a;for(let o of["key","value"]){let l=n[o];if(l&&"items"in l){for(let n=0;n<l.items.length;++n){let a=e(Object.freeze(t.concat([[o,n]])),l.items[n],s);if("number"==typeof a)n=a-1;else{if(a===r)return r;a===i&&(l.items.splice(n,1),n-=1)}}"function"==typeof a&&"key"===o&&(a=a(n,t))}}return"function"==typeof a?a(n,t):a}(Object.freeze([]),e,t)}s.BREAK=r,s.SKIP=n,s.REMOVE=i,s.itemAtPath=(e,t)=>{let r=e;for(let[e,n]of t){let t=r?.[e];if(!t||!("items"in t))return;r=t.items[n]}return r},s.parentCollection=(e,t)=>{let r=s.itemAtPath(e,t.slice(0,-1)),n=t[t.length-1][0],i=r?.[n];if(i&&"items"in i)return i;throw Error("Parent collection not found")},t.visit=s},9810(e,t,r){var n=r(8215),i=r(2142),s=r(1844);t.createScalarToken=n.createScalarToken,t.resolveAsScalar=n.resolveAsScalar,t.setScalarValue=n.setScalarValue,t.stringify=i.stringify,t.visit=s.visit,t.BOM="\uFEFF",t.DOCUMENT="\x02",t.FLOW_END="\x18",t.SCALAR="\x1f",t.isCollection=e=>!!e&&"items"in e,t.isScalar=e=>!!e&&("scalar"===e.type||"single-quoted-scalar"===e.type||"double-quoted-scalar"===e.type||"block-scalar"===e.type),t.prettyToken=function(e){switch(e){case"\uFEFF":return"<BOM>";case"\x02":return"<DOC>";case"\x18":return"<FLOW_END>";case"\x1f":return"<SCALAR>";default:return JSON.stringify(e)}},t.tokenType=function(e){switch(e){case"\uFEFF":return"byte-order-mark";case"\x02":return"doc-mode";case"\x18":return"flow-error-end";case"\x1f":return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case"\n":case"\r\n":return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(e[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}},7894(e,t,r){var n=r(9810);function i(e){switch(e){case void 0:case" ":case"\n":case"\r":case" ":return!0;default:return!1}}let s=new Set("0123456789ABCDEFabcdef"),a=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),o=new Set(",[]{}"),l=new Set(" ,[]{}\n\r "),c=e=>!e||l.has(e);t.Lexer=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,t=!1){if(e){if("string"!=typeof e)throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let r=this.next??"stream";for(;r&&(t||this.hasChars(1));)r=yield*this.parseNext(r)}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;" "===t||" "===t;)t=this.buffer[++e];return!t||"#"===t||"\n"===t||"\r"===t&&"\n"===this.buffer[e+1]}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let t=this.buffer[e];if(this.indentNext>0){let r=0;for(;" "===t;)t=this.buffer[++r+e];if("\r"===t){let t=this.buffer[r+e+1];if("\n"===t||!t&&!this.atEnd)return e+r+1}return"\n"!==t&&!(r>=this.indentNext)&&(t||this.atEnd)?-1:e+r}if("-"===t||"."===t){let t=this.buffer.substr(e,3);if(("---"===t||"..."===t)&&i(this.buffer[e+3]))return -1}return e}getLine(){let e=this.lineEndPos;return(("number"!=typeof e||-1!==e&&e<this.pos)&&(e=this.buffer.indexOf("\n",this.pos),this.lineEndPos=e),-1===e)?this.atEnd?this.buffer.substring(this.pos):null:("\r"===this.buffer[e-1]&&(e-=1),this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(null===e)return this.setNext("stream");if(e[0]===n.BOM&&(yield*this.pushCount(1),e=e.substring(1)),"%"===e[0]){let t=e.length,r=e.indexOf("#");for(;-1!==r;){let n=e[r-1];if(" "===n||" "===n){t=r-1;break}r=e.indexOf("#",r+1)}for(;;){let r=e[t-1];if(" "===r||" "===r)t-=1;else break}let n=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-n),this.pushNewline(),"stream"}if(this.atLineEnd()){let t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),"stream"}return yield n.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if("-"===e||"."===e){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let e=this.peek(3);if(("---"===e||"..."===e)&&i(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,"---"===e?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!i(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext("block-start");if(("-"===e||"?"===e||":"===e)&&i(t)){let e=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=e,"block-start"}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(null===e)return this.setNext("doc");let t=yield*this.pushIndicators();switch(e[t]){case"#":yield*this.pushCount(e.length-t);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(c),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return t+=yield*this.parseBlockScalarHeader(),t+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-t),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,t,r=-1;do(e=yield*this.pushNewline())>0?(t=yield*this.pushSpaces(!1),this.indentValue=r=t):t=0,t+=yield*this.pushSpaces(!0);while(e+t>0)let s=this.getLine();if(null===s)return this.setNext("flow");if((-1!==r&&r<this.indentNext&&"#"!==s[0]||0===r&&(s.startsWith("---")||s.startsWith("..."))&&i(s[3]))&&(r!==this.indentNext-1||1!==this.flowLevel||"]"!==s[0]&&"}"!==s[0]))return this.flowLevel=0,yield n.FLOW_END,yield*this.parseLineStart();let a=0;for(;","===s[a];)a+=yield*this.pushCount(1),a+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(s[a+=yield*this.pushIndicators()]){case void 0:return"flow";case"#":return yield*this.pushCount(s.length-a),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(c),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let e=this.charAt(1);if(this.flowKey||i(e)||","===e)return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),t=this.buffer.indexOf(e,this.pos+1);if("'"===e)for(;-1!==t&&"'"===this.buffer[t+1];)t=this.buffer.indexOf("'",t+2);else for(;-1!==t;){let e=0;for(;"\\"===this.buffer[t-1-e];)e+=1;if(e%2==0)break;t=this.buffer.indexOf('"',t+1)}let r=this.buffer.substring(0,t),n=r.indexOf("\n",this.pos);if(-1!==n){for(;-1!==n;){let e=this.continueScalar(n+1);if(-1===e)break;n=r.indexOf("\n",e)}-1!==n&&(t=n-("\r"===r[n-1]?2:1))}if(-1===t){if(!this.atEnd)return this.setNext("quoted-scalar");t=this.buffer.length}return yield*this.pushToIndex(t+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let t=this.buffer[++e];if("+"===t)this.blockScalarKeep=!0;else if(t>"0"&&t<="9")this.blockScalarIndent=Number(t)-1;else if("-"!==t)break}return yield*this.pushUntil(e=>i(e)||"#"===e)}*parseBlockScalar(){let e,t=this.pos-1,r=0;e:for(let n=this.pos;e=this.buffer[n];++n)switch(e){case" ":r+=1;break;case"\n":t=n,r=0;break;case"\r":{let e=this.buffer[n+1];if(!e&&!this.atEnd)return this.setNext("block-scalar");if("\n"===e)break}default:break e}if(!e&&!this.atEnd)return this.setNext("block-scalar");if(r>=this.indentNext){-1===this.blockScalarIndent?this.indentNext=r:this.indentNext=this.blockScalarIndent+(0===this.indentNext?1:this.indentNext);do{let e=this.continueScalar(t+1);if(-1===e)break;t=this.buffer.indexOf("\n",e)}while(-1!==t)if(-1===t){if(!this.atEnd)return this.setNext("block-scalar");t=this.buffer.length}}let i=t+1;for(e=this.buffer[i];" "===e;)e=this.buffer[++i];if(" "===e){for(;" "===e||" "===e||"\r"===e||"\n"===e;)e=this.buffer[++i];t=i-1}else if(!this.blockScalarKeep)for(;;){let e=t-1,n=this.buffer[e];"\r"===n&&(n=this.buffer[--e]);let i=e;for(;" "===n;)n=this.buffer[--e];if("\n"===n&&e>=this.pos&&e+1+r>i)t=e;else break}return yield n.SCALAR,yield*this.pushToIndex(t+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e,t=this.flowLevel>0,r=this.pos-1,s=this.pos-1;for(;e=this.buffer[++s];)if(":"===e){let e=this.buffer[s+1];if(i(e)||t&&o.has(e))break;r=s}else if(i(e)){let n=this.buffer[s+1];if("\r"===e&&("\n"===n?(s+=1,e="\n",n=this.buffer[s+1]):r=s),"#"===n||t&&o.has(n))break;if("\n"===e){let e=this.continueScalar(s+1);if(-1===e)break;s=Math.max(s,e-2)}}else{if(t&&o.has(e))break;r=s}return e||this.atEnd?(yield n.SCALAR,yield*this.pushToIndex(r+1,!0),t?"flow":"doc"):this.setNext("plain-scalar")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){let r=this.buffer.slice(this.pos,e);return r?(yield r,this.pos+=r.length,r.length):(t&&(yield""),0)}*pushIndicators(){let e=0;for(;;){switch(this.charAt(0)){case"!":e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue;case"&":e+=yield*this.pushUntil(c),e+=yield*this.pushSpaces(!0);continue;case"-":case"?":case":":{let t=this.flowLevel>0,r=this.charAt(1);if(i(r)||t&&o.has(r)){t?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue}}}break}return e}*pushTag(){if("<"===this.charAt(1)){let e=this.pos+2,t=this.buffer[e];for(;!i(t)&&">"!==t;)t=this.buffer[++e];return yield*this.pushToIndex(">"===t?e+1:e,!1)}{let e=this.pos+1,t=this.buffer[e];for(;t;)if(a.has(t))t=this.buffer[++e];else if("%"===t&&s.has(this.buffer[e+1])&&s.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return"\n"===e?yield*this.pushCount(1):"\r"===e&&"\n"===this.charAt(1)?yield*this.pushCount(2):0}*pushSpaces(e){let t,r=this.pos-1;do t=this.buffer[++r];while(" "===t||e&&" "===t)let n=r-this.pos;return n>0&&(yield this.buffer.substr(this.pos,n),this.pos=r),n}*pushUntil(e){let t=this.pos,r=this.buffer[t];for(;!e(r);)r=this.buffer[++t];return yield*this.pushToIndex(t,!1)}}},3813(e,t){t.LineCounter=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,r=this.lineStarts.length;for(;t<r;){let n=t+r>>1;this.lineStarts[n]<e?t=n+1:r=n}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(0===t)return{line:0,col:e};let n=this.lineStarts[t-1];return{line:t,col:e-n+1}}}}},5849(e,t,r){var n=r(932),i=r(9810),s=r(7894);function a(e,t){for(let r=0;r<e.length;++r)if(e[r].type===t)return!0;return!1}function o(e){for(let t=0;t<e.length;++t)switch(e[t].type){case"space":case"comment":case"newline":break;default:return t}return -1}function l(e){switch(e?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function c(e){switch(e.type){case"document":return e.start;case"block-map":{let t=e.items[e.items.length-1];return t.sep??t.start}case"block-seq":return e.items[e.items.length-1].start;default:return[]}}function u(e){if(0===e.length)return[];let t=e.length;e:for(;--t>=0;)switch(e[t].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;e[++t]?.type==="space";);return e.splice(t,e.length)}function d(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let r=0;r<t.length;++r)e.push(t[r])}function f(e){if("flow-seq-start"===e.start.type)for(let t of e.items)!t.sep||t.value||a(t.start,"explicit-key-ind")||a(t.sep,"map-value-ind")||(t.key&&(t.value=t.key),delete t.key,l(t.value)?t.value.end?d(t.value.end,t.sep):t.value.end=t.sep:d(t.start,t.sep),delete t.sep)}t.Parser=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new s.Lexer,this.onNewLine=e}*parse(e,t=!1){for(let r of(this.onNewLine&&0===this.offset&&this.onNewLine(0),this.lexer.lex(e,t)))yield*this.next(r);t||(yield*this.end())}*next(e){if(this.source=e,n.env.LOG_TOKENS&&console.log("|",i.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=i.tokenType(e);if(t)if("scalar"===t)this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=t,yield*this.step(),t){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case"space":this.atNewLine&&" "===e[0]&&(this.indent+=e.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=e.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}else{let t=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:t,source:e}),this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if("doc-end"===this.type&&e?.type!=="doc-end"){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case"document":return yield*this.document(e);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(e);case"block-scalar":return yield*this.blockScalar(e);case"block-map":return yield*this.blockMap(e);case"block-seq":return yield*this.blockSequence(e);case"flow-collection":return yield*this.flowCollection(e);case"doc-end":return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let t=e??this.stack.pop();if(t)if(0===this.stack.length)yield t;else{let e=this.peek(1);switch("block-scalar"===t.type?t.indent="indent"in e?e.indent:0:"flow-collection"===t.type&&"document"===e.type&&(t.indent=0),"flow-collection"===t.type&&f(t),e.type){case"document":e.value=t;break;case"block-scalar":e.props.push(t);break;case"block-map":{let r=e.items[e.items.length-1];if(r.value){e.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}if(r.sep)r.value=t;else{Object.assign(r,{key:t,sep:[]}),this.onKeyLine=!r.explicitKey;return}break}case"block-seq":{let r=e.items[e.items.length-1];r.value?e.items.push({start:[],value:t}):r.value=t;break}case"flow-collection":{let r=e.items[e.items.length-1];!r||r.value?e.items.push({start:[],key:t,sep:[]}):r.sep?r.value=t:Object.assign(r,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if(("document"===e.type||"block-map"===e.type||"block-seq"===e.type)&&("block-map"===t.type||"block-seq"===t.type)){let r=t.items[t.items.length-1];r&&!r.sep&&!r.value&&r.start.length>0&&-1===o(r.start)&&(0===t.indent||r.start.every(e=>"comment"!==e.type||e.indent<t.indent))&&("document"===e.type?e.end=r.start:e.items.push({start:r.start}),t.items.splice(-1,1))}}else yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let e={type:"document",offset:this.offset,start:[]};"doc-start"===this.type&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case"doc-start":-1!==o(e.start)?(yield*this.pop(),yield*this.step()):e.start.push(this.sourceToken);return;case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}let t=this.startBlockValue(e);t?this.stack.push(t):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if("map-value-ind"===this.type){let t,r=u(c(this.peek(2)));e.end?((t=e.end).push(this.sourceToken),delete e.end):t=[this.sourceToken];let n={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:r,key:e,sep:t}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=n}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":e.props.push(this.sourceToken);return;case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let e=this.source.indexOf("\n")+1;for(;0!==e;)this.onNewLine(this.offset+e),e=this.source.indexOf("\n",e)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,t.value){let r="end"in t.value?t.value.end:void 0,n=Array.isArray(r)?r[r.length-1]:void 0;n?.type==="comment"?r?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let r=e.items[e.items.length-2],n=r?.value?.end;if(Array.isArray(n)){d(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let r=!this.onKeyLine&&this.indent===e.indent,n=r&&(t.sep||t.explicitKey)&&"seq-item-ind"!==this.type,i=[];if(n&&t.sep&&!t.value){let r=[];for(let n=0;n<t.sep.length;++n){let i=t.sep[n];switch(i.type){case"newline":r.push(n);break;case"space":break;case"comment":i.indent>e.indent&&(r.length=0);break;default:r.length=0}}r.length>=2&&(i=t.sep.splice(r[1]))}switch(this.type){case"anchor":case"tag":n||t.value?(i.push(this.sourceToken),e.items.push({start:i}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"explicit-key-ind":t.sep||t.explicitKey?n||t.value?(i.push(this.sourceToken),e.items.push({start:i,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}):(t.start.push(this.sourceToken),t.explicitKey=!0),this.onKeyLine=!0;return;case"map-value-ind":if(t.explicitKey)if(t.sep)if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(a(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]});else if(l(t.key)&&!a(t.sep,"newline")){let e=u(t.start),r=t.key,n=t.sep;n.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:e,key:r,sep:n}]})}else i.length>0?t.sep=t.sep.concat(i,this.sourceToken):t.sep.push(this.sourceToken);else if(a(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let e=u(t.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:e,key:null,sep:[this.sourceToken]}]})}else t.sep?t.value||n?e.items.push({start:i,key:null,sep:[this.sourceToken]}):a(t.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let r=this.flowScalar(this.type);n||t.value?(e.items.push({start:i,key:r,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(r):(Object.assign(t,{key:r,sep:[]}),this.onKeyLine=!0);return}default:{let n=this.startBlockValue(e);if(n){if("block-seq"===n.type){if(!t.explicitKey&&t.sep&&!a(t.sep,"newline"))return void(yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source}))}else r&&e.items.push({start:i});this.stack.push(n);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case"newline":if(t.value){let r="end"in t.value?t.value.end:void 0,n=Array.isArray(r)?r[r.length-1]:void 0;n?.type==="comment"?r?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let r=e.items[e.items.length-2],n=r?.value?.end;if(Array.isArray(n)){d(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case"anchor":case"tag":if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;t.value||a(t.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){let t=this.startBlockValue(e);if(t)return void this.stack.push(t)}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if("flow-error-end"===this.type){let e;do yield*this.pop(),e=this.peek(1);while(e?.type==="flow-collection")}else if(0===e.end.length){switch(this.type){case"comma":case"explicit-key-ind":!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case"map-value-ind":!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let r=this.flowScalar(this.type);!t||t.value?e.items.push({start:[],key:r,sep:[]}):t.sep?this.stack.push(r):Object.assign(t,{key:r,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let r=this.startBlockValue(e);r?this.stack.push(r):(yield*this.pop(),yield*this.step())}else{let t=this.peek(2);if("block-map"!==t.type||("map-value-ind"!==this.type||t.indent!==e.indent)&&("newline"!==this.type||t.items[t.items.length-1].sep))if("map-value-ind"===this.type&&"flow-collection"!==t.type){let r=u(c(t));f(e);let n=e.end.splice(1,e.end.length);n.push(this.sourceToken);let i={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:r,key:e,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e);else yield*this.pop(),yield*this.step()}}flowScalar(e){if(this.onNewLine){let e=this.source.indexOf("\n")+1;for(;0!==e;)this.onNewLine(this.offset+e),e=this.source.indexOf("\n",e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let t=u(c(e));return t.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let t=u(c(e));return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return"comment"===this.type&&!(this.indent<=t)&&e.every(e=>"newline"===e.type||"space"===e.type)}*documentEnd(e){"doc-mode"!==this.type&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],"newline"===this.type&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],"newline"===this.type&&(yield*this.pop())}}}},1094(e,t,r){var n=r(2545),i=r(9960),s=r(3409),a=r(2186),o=r(6730),l=r(3813),c=r(5849);function u(e){let t=!1!==e.prettyErrors;return{lineCounter:e.lineCounter||t&&new l.LineCounter||null,prettyErrors:t}}function d(e,t={}){let{lineCounter:r,prettyErrors:i}=u(t),a=new c.Parser(r?.addNewLine),o=new n.Composer(t),l=null;for(let t of o.compose(a.parse(e),!0,e.length))if(l){if("silent"!==l.options.logLevel){l.errors.push(new s.YAMLParseError(t.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}}else l=t;return i&&r&&(l.errors.forEach(s.prettifyError(e,r)),l.warnings.forEach(s.prettifyError(e,r))),l}t.parse=function(e,t,r){let n;"function"==typeof t?n=t:void 0===r&&t&&"object"==typeof t&&(r=t);let i=d(e,r);if(!i)return null;if(i.warnings.forEach(e=>a.warn(i.options.logLevel,e)),i.errors.length>0)if("silent"!==i.options.logLevel)throw i.errors[0];else i.errors=[];return i.toJS(Object.assign({reviver:n},r))},t.parseAllDocuments=function(e,t={}){let{lineCounter:r,prettyErrors:i}=u(t),a=new c.Parser(r?.addNewLine),o=new n.Composer(t),l=Array.from(o.compose(a.parse(e)));if(i&&r)for(let t of l)t.errors.forEach(s.prettifyError(e,r)),t.warnings.forEach(s.prettifyError(e,r));return l.length>0?l:Object.assign([],{empty:!0},o.streamInfo())},t.parseDocument=d,t.stringify=function(e,t,r){let n=null;if("function"==typeof t||Array.isArray(t)?n=t:void 0===r&&t&&(r=t),"string"==typeof r&&(r=r.length),"number"==typeof r){let e=Math.round(r);r=e<1?void 0:e>8?{indent:8}:{indent:e}}if(void 0===e){let{keepUndefined:e}=r??t??{};if(!e)return}return o.isDocument(e)&&!n?e.toString(r):new i.Document(e,n,r).toString(r)}},8227(e,t,r){var n=r(6730),i=r(9988),s=r(505),a=r(5613),o=r(7545);let l=(e,t)=>e.key<t.key?-1:+(e.key>t.key);t.Schema=class e{constructor({compat:e,customTags:t,merge:r,resolveKnownTags:c,schema:u,sortMapEntries:d,toStringDefaults:f}){this.compat=Array.isArray(e)?o.getTags(e,"compat"):e?o.getTags(null,e):null,this.name="string"==typeof u&&u||"core",this.knownTags=c?o.coreKnownTags:{},this.tags=o.getTags(t,this.name,r),this.toStringOptions=f??null,Object.defineProperty(this,n.MAP,{value:i.map}),Object.defineProperty(this,n.SCALAR,{value:a.string}),Object.defineProperty(this,n.SEQ,{value:s.seq}),this.sortMapEntries="function"==typeof d?d:!0===d?l:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}}},9988(e,t,r){var n=r(6730),i=r(73);t.map={collection:"map",default:!0,nodeClass:i.YAMLMap,tag:"tag:yaml.org,2002:map",resolve:(e,t)=>(n.isMap(e)||t("Expected a mapping for this tag"),e),createNode:(e,t,r)=>i.YAMLMap.from(e,t,r)}},5725(e,t,r){var n=r(8376);let i={identify:e=>null==e,createNode:()=>new n.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new n.Scalar(null),stringify:({source:e},t)=>"string"==typeof e&&i.test.test(e)?e:t.options.nullStr};t.nullTag=i},505(e,t,r){var n=r(6730),i=r(7028);t.seq={collection:"seq",default:!0,nodeClass:i.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve:(e,t)=>(n.isSeq(e)||t("Expected a sequence for this tag"),e),createNode:(e,t,r)=>i.YAMLSeq.from(e,t,r)}},5613(e,t,r){var n=r(4286);t.string={identify:e=>"string"==typeof e,default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify:(e,t,r,i)=>(t=Object.assign({actualString:!0},t),n.stringifyString(e,t,r,i))}},4302(e,t,r){var n=r(8376);let i={identify:e=>"boolean"==typeof e,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new n.Scalar("t"===e[0]||"T"===e[0]),stringify:({source:e,value:t},r)=>e&&i.test.test(e)&&t===("t"===e[0]||"T"===e[0])?e:t?r.options.trueStr:r.options.falseStr};t.boolTag=i},7878(e,t,r){var n=r(8376),i=r(4374);let s={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>"nan"===e.slice(-3).toLowerCase()?NaN:"-"===e[0]?-1/0:1/0,stringify:i.stringifyNumber};t.float={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let t=new n.Scalar(parseFloat(e)),r=e.indexOf(".");return -1!==r&&"0"===e[e.length-1]&&(t.minFractionDigits=e.length-r-1),t},stringify:i.stringifyNumber},t.floatExp={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():i.stringifyNumber(e)}},t.floatNaN=s},9305(e,t,r){var n=r(4374);let i=e=>"bigint"==typeof e||Number.isInteger(e),s=(e,t,r,{intAsBigInt:n})=>n?BigInt(e):parseInt(e.substring(t),r);function a(e,t,r){let{value:s}=e;return i(s)&&s>=0?r+s.toString(t):n.stringifyNumber(e)}t.int={identify:i,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,r)=>s(e,0,10,r),stringify:n.stringifyNumber},t.intHex={identify:e=>i(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,r)=>s(e,2,16,r),stringify:e=>a(e,16,"0x")},t.intOct={identify:e=>i(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,r)=>s(e,2,8,r),stringify:e=>a(e,8,"0o")}},8537(e,t,r){var n=r(9988),i=r(5725),s=r(505),a=r(5613),o=r(4302),l=r(7878),c=r(9305);t.schema=[n.map,s.seq,a.string,i.nullTag,o.boolTag,c.intOct,c.int,c.intHex,l.floatNaN,l.floatExp,l.float]},7150(e,t,r){var n=r(8376),i=r(9988),s=r(505);function a(e){return"bigint"==typeof e||Number.isInteger(e)}let o=({value:e})=>JSON.stringify(e),l=[{identify:e=>"string"==typeof e,default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify:o},{identify:e=>null==e,createNode:()=>new n.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:o},{identify:e=>"boolean"==typeof e,default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:e=>"true"===e,stringify:o},{identify:a,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:r})=>r?BigInt(e):parseInt(e,10),stringify:({value:e})=>a(e)?e.toString():JSON.stringify(e)},{identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:o}];t.schema=[i.map,s.seq].concat(l,{default:!0,tag:"",test:/^/,resolve:(e,t)=>(t(`Unresolved plain scalar ${JSON.stringify(e)}`),e)})},7545(e,t,r){var n=r(9988),i=r(5725),s=r(505),a=r(5613),o=r(4302),l=r(7878),c=r(9305),u=r(8537),d=r(7150),f=r(298),h=r(8327),p=r(8822),m=r(9946),g=r(3908),y=r(6675),b=r(9859);let v=new Map([["core",u.schema],["failsafe",[n.map,s.seq,a.string]],["json",d.schema],["yaml11",g.schema],["yaml-1.1",g.schema]]),w={binary:f.binary,bool:o.boolTag,float:l.float,floatExp:l.floatExp,floatNaN:l.floatNaN,floatTime:b.floatTime,int:c.int,intHex:c.intHex,intOct:c.intOct,intTime:b.intTime,map:n.map,merge:h.merge,null:i.nullTag,omap:p.omap,pairs:m.pairs,seq:s.seq,set:y.set,timestamp:b.timestamp};t.coreKnownTags={"tag:yaml.org,2002:binary":f.binary,"tag:yaml.org,2002:merge":h.merge,"tag:yaml.org,2002:omap":p.omap,"tag:yaml.org,2002:pairs":m.pairs,"tag:yaml.org,2002:set":y.set,"tag:yaml.org,2002:timestamp":b.timestamp},t.getTags=function(e,t,r){let n=v.get(t);if(n&&!e)return r&&!n.includes(h.merge)?n.concat(h.merge):n.slice();let i=n;if(!i)if(Array.isArray(e))i=[];else{let e=Array.from(v.keys()).filter(e=>"yaml11"!==e).map(e=>JSON.stringify(e)).join(", ");throw Error(`Unknown schema "${t}"; use one of ${e} or define customTags array`)}if(Array.isArray(e))for(let t of e)i=i.concat(t);else"function"==typeof e&&(i=e(i.slice()));return r&&(i=i.concat(h.merge)),i.reduce((e,t)=>{let r="string"==typeof t?w[t]:t;if(!r){let e=JSON.stringify(t),r=Object.keys(w).map(e=>JSON.stringify(e)).join(", ");throw Error(`Unknown custom tag ${e}; use one of ${r}`)}return e.includes(r)||e.push(r),e},[])}},298(e,t,r){var n=r(181),i=r(8376),s=r(4286);t.binary={identify:e=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if("function"==typeof n.Buffer)return n.Buffer.from(e,"base64");if("function"!=typeof atob)return t("This environment does not support reading binary tags; either Buffer or atob is required"),e;{let t=atob(e.replace(/[\n\r]/g,"")),r=new Uint8Array(t.length);for(let e=0;e<t.length;++e)r[e]=t.charCodeAt(e);return r}},stringify({comment:e,type:t,value:r},a,o,l){let c;if(!r)return"";if("function"==typeof n.Buffer)c=r instanceof n.Buffer?r.toString("base64"):n.Buffer.from(r.buffer).toString("base64");else if("function"==typeof btoa){let e="";for(let t=0;t<r.length;++t)e+=String.fromCharCode(r[t]);c=btoa(e)}else throw Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(t??(t=i.Scalar.BLOCK_LITERAL),t!==i.Scalar.QUOTE_DOUBLE){let e=Math.max(a.options.lineWidth-a.indent.length,a.options.minContentWidth),r=Math.ceil(c.length/e),n=Array(r);for(let t=0,i=0;t<r;++t,i+=e)n[t]=c.substr(i,e);c=n.join(t===i.Scalar.BLOCK_LITERAL?"\n":" ")}return s.stringifyString({comment:e,type:t,value:c},a,o,l)}}},4211(e,t,r){var n=r(8376);function i({value:e,source:t},r){let n=e?s:a;return t&&n.test.test(t)?t:e?r.options.trueStr:r.options.falseStr}let s={identify:e=>!0===e,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new n.Scalar(!0),stringify:i},a={identify:e=>!1===e,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new n.Scalar(!1),stringify:i};t.falseTag=a,t.trueTag=s},1489(e,t,r){var n=r(8376),i=r(4374);let s={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>"nan"===e.slice(-3).toLowerCase()?NaN:"-"===e[0]?-1/0:1/0,stringify:i.stringifyNumber};t.float={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new n.Scalar(parseFloat(e.replace(/_/g,""))),r=e.indexOf(".");if(-1!==r){let n=e.substring(r+1).replace(/_/g,"");"0"===n[n.length-1]&&(t.minFractionDigits=n.length)}return t},stringify:i.stringifyNumber},t.floatExp={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,"")),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():i.stringifyNumber(e)}},t.floatNaN=s},5566(e,t,r){var n=r(4374);let i=e=>"bigint"==typeof e||Number.isInteger(e);function s(e,t,r,{intAsBigInt:n}){let i=e[0];if(("-"===i||"+"===i)&&(t+=1),e=e.substring(t).replace(/_/g,""),n){switch(r){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`}let t=BigInt(e);return"-"===i?BigInt(-1)*t:t}let a=parseInt(e,r);return"-"===i?-1*a:a}function a(e,t,r){let{value:s}=e;if(i(s)){let e=s.toString(t);return s<0?"-"+r+e.substr(1):r+e}return n.stringifyNumber(e)}t.int={identify:i,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,r)=>s(e,0,10,r),stringify:n.stringifyNumber},t.intBin={identify:i,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,r)=>s(e,2,2,r),stringify:e=>a(e,2,"0b")},t.intHex={identify:i,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,r)=>s(e,2,16,r),stringify:e=>a(e,16,"0x")},t.intOct={identify:i,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,r)=>s(e,1,8,r),stringify:e=>a(e,8,"0")}},8327(e,t,r){var n=r(6730),i=r(8376);let s={identify:e=>"<<"===e||"symbol"==typeof e&&"<<"===e.description,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new i.Scalar(Symbol("<<")),{addToJSMap:a}),stringify:()=>"<<"};function a(e,t,r){let i=l(e,r);if(n.isSeq(i))for(let r of i.items)o(e,t,r);else if(Array.isArray(i))for(let r of i)o(e,t,r);else o(e,t,i)}function o(e,t,r){let i=l(e,r);if(!n.isMap(i))throw Error("Merge sources must be maps or map aliases");for(let[r,n]of i.toJSON(null,e,Map))t instanceof Map?t.has(r)||t.set(r,n):t instanceof Set?t.add(r):Object.prototype.hasOwnProperty.call(t,r)||Object.defineProperty(t,r,{value:n,writable:!0,enumerable:!0,configurable:!0});return t}function l(e,t){return e&&n.isAlias(t)?t.resolve(e.doc,e):t}t.addMergeToJSMap=a,t.isMergeKey=(e,t)=>(s.identify(t)||n.isScalar(t)&&(!t.type||t.type===i.Scalar.PLAIN)&&s.identify(t.value))&&e?.doc.schema.tags.some(e=>e.tag===s.tag&&e.default),t.merge=s},8822(e,t,r){var n=r(6730),i=r(2234),s=r(73),a=r(7028),o=r(9946);class l extends a.YAMLSeq{constructor(){super(),this.add=s.YAMLMap.prototype.add.bind(this),this.delete=s.YAMLMap.prototype.delete.bind(this),this.get=s.YAMLMap.prototype.get.bind(this),this.has=s.YAMLMap.prototype.has.bind(this),this.set=s.YAMLMap.prototype.set.bind(this),this.tag=l.tag}toJSON(e,t){if(!t)return super.toJSON(e);let r=new Map;for(let e of(t?.onCreate&&t.onCreate(r),this.items)){let s,a;if(n.isPair(e)?(s=i.toJS(e.key,"",t),a=i.toJS(e.value,s,t)):s=i.toJS(e,"",t),r.has(s))throw Error("Ordered maps must not include duplicate keys");r.set(s,a)}return r}static from(e,t,r){let n=o.createPairs(e,t,r),i=new this;return i.items=n.items,i}}l.tag="tag:yaml.org,2002:omap",t.YAMLOMap=l,t.omap={collection:"seq",identify:e=>e instanceof Map,nodeClass:l,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let r=o.resolvePairs(e,t),i=[];for(let{key:e}of r.items)n.isScalar(e)&&(i.includes(e.value)?t(`Ordered maps must not include duplicate keys: ${e.value}`):i.push(e.value));return Object.assign(new l,r)},createNode:(e,t,r)=>l.from(e,t,r)}},9946(e,t,r){var n=r(6730),i=r(7748),s=r(8376),a=r(7028);function o(e,t){if(n.isSeq(e))for(let r=0;r<e.items.length;++r){let a=e.items[r];if(!n.isPair(a)){if(n.isMap(a)){a.items.length>1&&t("Each pair must have its own sequence indicator");let e=a.items[0]||new i.Pair(new s.Scalar(null));if(a.commentBefore&&(e.key.commentBefore=e.key.commentBefore?`${a.commentBefore}
107
+ ${e.key.commentBefore}`:a.commentBefore),a.comment){let t=e.value??e.key;t.comment=t.comment?`${a.comment}
108
+ ${t.comment}`:a.comment}a=e}e.items[r]=n.isPair(a)?a:new i.Pair(a)}}else t("Expected a sequence for this tag");return e}function l(e,t,r){let{replacer:n}=r,s=new a.YAMLSeq(e);s.tag="tag:yaml.org,2002:pairs";let o=0;if(t&&Symbol.iterator in Object(t))for(let e of t){let a,l;if("function"==typeof n&&(e=n.call(t,String(o++),e)),Array.isArray(e))if(2===e.length)a=e[0],l=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`);else if(e&&e instanceof Object){let t=Object.keys(e);if(1===t.length)l=e[a=t[0]];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else a=e;s.items.push(i.createPair(a,l,r))}return s}t.createPairs=l,t.pairs={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:o,createNode:l},t.resolvePairs=o},3908(e,t,r){var n=r(9988),i=r(5725),s=r(505),a=r(5613),o=r(298),l=r(4211),c=r(1489),u=r(5566),d=r(8327),f=r(8822),h=r(9946),p=r(6675),m=r(9859);t.schema=[n.map,s.seq,a.string,i.nullTag,l.trueTag,l.falseTag,u.intBin,u.intOct,u.int,u.intHex,c.floatNaN,c.floatExp,c.float,o.binary,d.merge,f.omap,h.pairs,p.set,m.intTime,m.floatTime,m.timestamp]},6675(e,t,r){var n=r(6730),i=r(7748),s=r(73);class a extends s.YAMLMap{constructor(e){super(e),this.tag=a.tag}add(e){let t;t=n.isPair(e)?e:e&&"object"==typeof e&&"key"in e&&"value"in e&&null===e.value?new i.Pair(e.key,null):new i.Pair(e,null),s.findPair(this.items,t.key)||this.items.push(t)}get(e,t){let r=s.findPair(this.items,e);return!t&&n.isPair(r)?n.isScalar(r.key)?r.key.value:r.key:r}set(e,t){if("boolean"!=typeof t)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let r=s.findPair(this.items,e);r&&!t?this.items.splice(this.items.indexOf(r),1):!r&&t&&this.items.push(new i.Pair(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,r){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,r);throw Error("Set items must all have null values")}static from(e,t,r){let{replacer:n}=r,s=new this(e);if(t&&Symbol.iterator in Object(t))for(let e of t)"function"==typeof n&&(e=n.call(t,e,e)),s.items.push(i.createPair(e,null,r));return s}}a.tag="tag:yaml.org,2002:set",t.YAMLSet=a,t.set={collection:"map",identify:e=>e instanceof Set,nodeClass:a,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,r)=>a.from(e,t,r),resolve(e,t){if(n.isMap(e))if(e.hasAllNullValues(!0))return Object.assign(new a,e);else t("Set items must all have null values");else t("Expected a mapping for this tag");return e}}},9859(e,t,r){var n=r(4374);function i(e,t){let r=e[0],n="-"===r||"+"===r?e.substring(1):e,i=e=>t?BigInt(e):Number(e),s=n.replace(/_/g,"").split(":").reduce((e,t)=>e*i(60)+i(t),i(0));return"-"===r?i(-1)*s:s}function s(e){let{value:t}=e,r=e=>e;if("bigint"==typeof t)r=e=>BigInt(e);else if(isNaN(t)||!isFinite(t))return n.stringifyNumber(e);let i="";t<0&&(i="-",t*=r(-1));let s=r(60),a=[t%s];return t<60?a.unshift(0):(t=(t-a[0])/s,a.unshift(t%s),t>=60&&(t=(t-a[0])/s,a.unshift(t))),i+a.map(e=>String(e).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}let a={identify:e=>e instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(e){let t=e.match(a.test);if(!t)throw Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,r,n,s,o,l,c]=t.map(Number),u=Date.UTC(r,n-1,s,o||0,l||0,c||0,t[7]?Number((t[7]+"00").substr(1,3)):0),d=t[8];if(d&&"Z"!==d){let e=i(d,!1);30>Math.abs(e)&&(e*=60),u-=6e4*e}return new Date(u)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};t.floatTime={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>i(e,!1),stringify:s},t.intTime={identify:e=>"bigint"==typeof e||Number.isInteger(e),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:r})=>i(e,r),stringify:s},t.timestamp=a},3980(e,t){let r="block",n="quoted";function i(e,t,r){let n=t,i=t+1,s=e[i];for(;" "===s||" "===s;)if(t<i+r)s=e[++t];else{do s=e[++t];while(s&&"\n"!==s)n=t,s=e[i=t+1]}return n}t.FOLD_BLOCK=r,t.FOLD_FLOW="flow",t.FOLD_QUOTED=n,t.foldFlowLines=function(e,t,s="flow",{indentAtStart:a,lineWidth:o=80,minContentWidth:l=20,onFold:c,onOverflow:u}={}){let d,f,h;if(!o||o<0)return e;o<l&&(l=0);let p=Math.max(1+l,1+o-t.length);if(e.length<=p)return e;let m=[],g={},y=o-t.length;"number"==typeof a&&(a>o-Math.max(2,l)?m.push(0):y=o-a);let b=!1,v=-1,w=-1,x=-1;for(s===r&&-1!==(v=i(e,v,t.length))&&(y=v+p);h=e[v+=1];){if(s===n&&"\\"===h){switch(w=v,e[v+1]){case"x":v+=3;break;case"u":v+=5;break;case"U":v+=9;break;default:v+=1}x=v}if("\n"===h)s===r&&(v=i(e,v,t.length)),y=v+t.length+p,d=void 0;else{if(" "===h&&f&&" "!==f&&"\n"!==f&&" "!==f){let t=e[v+1];t&&" "!==t&&"\n"!==t&&" "!==t&&(d=v)}if(v>=y)if(d)m.push(d),y=d+p,d=void 0;else if(s===n){for(;" "===f||" "===f;)f=h,h=e[v+=1],b=!0;let t=v>x+1?v-2:w-1;if(g[t])return e;m.push(t),g[t]=!0,y=t+p,d=void 0}else b=!0}f=h}if(b&&u&&u(),0===m.length)return e;c&&c();let k=e.slice(0,m[0]);for(let r=0;r<m.length;++r){let i=m[r],a=m[r+1]||e.length;0===i?k=`
109
+ ${t}${e.slice(0,a)}`:(s===n&&g[i]&&(k+=`${e[i]}\\`),k+=`
110
+ ${t}${e.slice(i+1,a)}`)}return k}},6203(e,t,r){var n=r(9531),i=r(6730),s=r(3202),a=r(4286);t.createStringifyContext=function(e,t){let r,n=Object.assign({blockQuote:!0,commentString:s.stringifyComment,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},e.schema.toStringOptions,t);switch(n.collectionStyle){case"block":r=!1;break;case"flow":r=!0;break;default:r=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?" ":"",indent:"",indentStep:"number"==typeof n.indent?" ".repeat(n.indent):" ",inFlow:r,options:n}},t.stringify=function(e,t,r,s){let o;if(i.isPair(e))return e.toString(t,r,s);if(i.isAlias(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError("Cannot stringify circular structure without alias nodes");t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let l=i.isNode(e)?e:t.doc.createNode(e,{onTagObj:e=>o=e});o??(o=function(e,t){let r,n;if(t.tag){let r=e.filter(e=>e.tag===t.tag);if(r.length>0)return r.find(e=>e.format===t.format)??r[0]}if(i.isScalar(t)){r=t.value;let i=e.filter(e=>e.identify?.(r));if(i.length>1){let e=i.filter(e=>e.test);e.length>0&&(i=e)}n=i.find(e=>e.format===t.format)??i.find(e=>!e.format)}else r=t,n=e.find(e=>e.nodeClass&&r instanceof e.nodeClass);if(!n){let e=r?.constructor?.name??(null===r?"null":typeof r);throw Error(`Tag not resolved for ${e} value`)}return n}(t.doc.schema.tags,l));let c=function(e,t,{anchors:r,doc:s}){if(!s.directives)return"";let a=[],o=(i.isScalar(e)||i.isCollection(e))&&e.anchor;o&&n.anchorIsValid(o)&&(r.add(o),a.push(`&${o}`));let l=e.tag??(t.default?null:t.tag);return l&&a.push(s.directives.tagString(l)),a.join(" ")}(l,o,t);c.length>0&&(t.indentAtStart=(t.indentAtStart??0)+c.length+1);let u="function"==typeof o.stringify?o.stringify(l,t,r,s):i.isScalar(l)?a.stringifyString(l,t,r,s):l.toString(t,r,s);return c?i.isScalar(l)||"{"===u[0]||"["===u[0]?`${c} ${u}`:`${c}
111
+ ${t.indent}${u}`:u}},8143(e,t,r){var n=r(6730),i=r(6203),s=r(3202);function a({indent:e,options:{commentString:t}},r,n,i){if(n&&i&&(n=n.replace(/^\n+/,"")),n){let i=s.indentComment(t(n),e);r.push(i.trimStart())}}t.stringifyCollection=function(e,t,r){return(t.inFlow??e.flow?function({items:e},t,{flowChars:r,itemIndent:o}){let{indent:l,indentStep:c,flowCollectionPadding:u,options:{commentString:d}}=t,f=Object.assign({},t,{indent:o+=c,inFlow:!0,type:null}),h=!1,p=0,m=[];for(let r=0;r<e.length;++r){let l=e[r],c=null;if(n.isNode(l))l.spaceBefore&&m.push(""),a(t,m,l.commentBefore,!1),l.comment&&(c=l.comment);else if(n.isPair(l)){let e=n.isNode(l.key)?l.key:null;e&&(e.spaceBefore&&m.push(""),a(t,m,e.commentBefore,!1),e.comment&&(h=!0));let r=n.isNode(l.value)?l.value:null;r?(r.comment&&(c=r.comment),r.commentBefore&&(h=!0)):null==l.value&&e?.comment&&(c=e.comment)}c&&(h=!0);let u=i.stringify(l,f,()=>c=null);h||(h=m.length>p||u.includes("\n")),r<e.length-1?u+=",":t.options.trailingComma&&(t.options.lineWidth>0&&(h||(h=m.reduce((e,t)=>e+t.length+2,2)+(u.length+2)>t.options.lineWidth)),h&&(u+=",")),c&&(u+=s.lineComment(u,o,d(c))),m.push(u),p=m.length}let{start:g,end:y}=r;if(0===m.length)return g+y;if(!h){let e=m.reduce((e,t)=>e+t.length+2,2);h=t.options.lineWidth>0&&e>t.options.lineWidth}if(!h)return`${g}${u}${m.join(" ")}${u}${y}`;{let e=g;for(let t of m)e+=t?`
112
+ ${c}${l}${t}`:"\n";return`${e}
113
+ ${l}${y}`}}:function({comment:e,items:t},r,{blockItemPrefix:o,flowChars:l,itemIndent:c,onChompKeep:u,onComment:d}){let f,{indent:h,options:{commentString:p}}=r,m=Object.assign({},r,{indent:c,type:null}),g=!1,y=[];for(let e=0;e<t.length;++e){let l=t[e],u=null;if(n.isNode(l))!g&&l.spaceBefore&&y.push(""),a(r,y,l.commentBefore,g),l.comment&&(u=l.comment);else if(n.isPair(l)){let e=n.isNode(l.key)?l.key:null;e&&(!g&&e.spaceBefore&&y.push(""),a(r,y,e.commentBefore,g))}g=!1;let d=i.stringify(l,m,()=>u=null,()=>g=!0);u&&(d+=s.lineComment(d,c,p(u))),g&&u&&(g=!1),y.push(o+d)}if(0===y.length)f=l.start+l.end;else{f=y[0];for(let e=1;e<y.length;++e){let t=y[e];f+=t?`
114
+ ${h}${t}`:"\n"}}return e?(f+="\n"+s.indentComment(p(e),h),d&&d()):g&&u&&u(),f})(e,t,r)}},3202(e,t){function r(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}t.indentComment=r,t.lineComment=(e,t,n)=>e.endsWith("\n")?r(n,t):n.includes("\n")?"\n"+r(n,t):(e.endsWith(" ")?"":" ")+n,t.stringifyComment=e=>e.replace(/^(?!$)(?: $)?/gm,"#")},5966(e,t,r){var n=r(6730),i=r(6203),s=r(3202);t.stringifyDocument=function(e,t){let r=[],a=!0===t.directives;if(!1!==t.directives&&e.directives){let t=e.directives.toString(e);t?(r.push(t),a=!0):e.directives.docStart&&(a=!0)}a&&r.push("---");let o=i.createStringifyContext(e,t),{commentString:l}=o.options;if(e.commentBefore){1!==r.length&&r.unshift("");let t=l(e.commentBefore);r.unshift(s.indentComment(t,""))}let c=!1,u=null;if(e.contents){if(n.isNode(e.contents)){if(e.contents.spaceBefore&&a&&r.push(""),e.contents.commentBefore){let t=l(e.contents.commentBefore);r.push(s.indentComment(t,""))}o.forceBlockIndent=!!e.comment,u=e.contents.comment}let t=u?void 0:()=>c=!0,d=i.stringify(e.contents,o,()=>u=null,t);u&&(d+=s.lineComment(d,"",l(u))),("|"===d[0]||">"===d[0])&&"---"===r[r.length-1]?r[r.length-1]=`--- ${d}`:r.push(d)}else r.push(i.stringify(e.contents,o));if(e.directives?.docEnd)if(e.comment){let t=l(e.comment);t.includes("\n")?(r.push("..."),r.push(s.indentComment(t,""))):r.push(`... ${t}`)}else r.push("...");else{let t=e.comment;t&&c&&(t=t.replace(/^\n+/,"")),t&&((!c||u)&&""!==r[r.length-1]&&r.push(""),r.push(s.indentComment(l(t),"")))}return r.join("\n")+"\n"}},4374(e,t){t.stringifyNumber=function({format:e,minFractionDigits:t,tag:r,value:n}){if("bigint"==typeof n)return String(n);let i="number"==typeof n?n:Number(n);if(!isFinite(i))return isNaN(i)?".nan":i<0?"-.inf":".inf";let s=Object.is(n,-0)?"-0":JSON.stringify(n);if(!e&&t&&(!r||"tag:yaml.org,2002:float"===r)&&/^-?\d/.test(s)&&!s.includes("e")){let e=s.indexOf(".");e<0&&(e=s.length,s+=".");let r=t-(s.length-e-1);for(;r-- >0;)s+="0"}return s}},4711(e,t,r){var n=r(6730),i=r(8376),s=r(6203),a=r(3202);t.stringifyPair=function({key:e,value:t},r,o,l){let c,u,d,{allNullValues:f,doc:h,indent:p,indentStep:m,options:{commentString:g,indentSeq:y,simpleKeys:b}}=r,v=n.isNode(e)&&e.comment||null;if(b){if(v)throw Error("With simple keys, key nodes cannot have comments");if(n.isCollection(e)||!n.isNode(e)&&"object"==typeof e)throw Error("With simple keys, collection cannot be used as a key value")}let w=!b&&(!e||v&&null==t&&!r.inFlow||n.isCollection(e)||(n.isScalar(e)?e.type===i.Scalar.BLOCK_FOLDED||e.type===i.Scalar.BLOCK_LITERAL:"object"==typeof e));r=Object.assign({},r,{allNullValues:!1,implicitKey:!w&&(b||!f),indent:p+m});let x=!1,k=!1,S=s.stringify(e,r,()=>x=!0,()=>k=!0);if(!w&&!r.inFlow&&S.length>1024){if(b)throw Error("With simple keys, single line scalar must not span more than 1024 characters");w=!0}if(r.inFlow){if(f||null==t)return x&&o&&o(),""===S?"?":w?`? ${S}`:S}else if(f&&!b||null==t&&w)return S=`? ${S}`,v&&!x?S+=a.lineComment(S,r.indent,g(v)):k&&l&&l(),S;x&&(v=null),w?(v&&(S+=a.lineComment(S,r.indent,g(v))),S=`? ${S}
115
+ ${p}:`):(S=`${S}:`,v&&(S+=a.lineComment(S,r.indent,g(v)))),n.isNode(t)?(c=!!t.spaceBefore,u=t.commentBefore,d=t.comment):(c=!1,u=null,d=null,t&&"object"==typeof t&&(t=h.createNode(t))),r.implicitKey=!1,!w&&!v&&n.isScalar(t)&&(r.indentAtStart=S.length+1),k=!1,!(!y&&m.length>=2&&!r.inFlow&&!w&&n.isSeq(t))||t.flow||t.tag||t.anchor||(r.indent=r.indent.substring(2));let _=!1,O=s.stringify(t,r,()=>_=!0,()=>k=!0),I=" ";if(v||c||u){if(I=c?"\n":"",u){let e=g(u);I+=`
116
+ ${a.indentComment(e,r.indent)}`}""!==O||r.inFlow?I+=`
117
+ ${r.indent}`:"\n"===I&&d&&(I="\n\n")}else if(!w&&n.isCollection(t)){let e=O[0],n=O.indexOf("\n"),i=-1!==n,s=r.inFlow??t.flow??0===t.items.length;if(i||!s){let t=!1;if(i&&("&"===e||"!"===e)){let r=O.indexOf(" ");"&"===e&&-1!==r&&r<n&&"!"===O[r+1]&&(r=O.indexOf(" ",r+1)),(-1===r||n<r)&&(t=!0)}t||(I=`
118
+ ${r.indent}`)}}else(""===O||"\n"===O[0])&&(I="");return S+=I+O,r.inFlow?_&&o&&o():d&&!_?S+=a.lineComment(S,r.indent,g(d)):k&&l&&l(),S}},4286(e,t,r){let n;var i=r(8376),s=r(3980);let a=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth});function o(e,t){let r=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return r;let{implicitKey:n}=t,i=t.options.doubleQuotedMinMultiLineLength,o=t.indent||(/^(%|---|\.\.\.)/m.test(e)?" ":""),l="",c=0;for(let e=0,t=r[e];t;t=r[++e])if(" "===t&&"\\"===r[e+1]&&"n"===r[e+2]&&(l+=r.slice(c,e)+"\\ ",e+=1,c=e,t="\\"),"\\"===t)switch(r[e+1]){case"u":{l+=r.slice(c,e);let t=r.substr(e+2,4);switch(t){case"0000":l+="\\0";break;case"0007":l+="\\a";break;case"000b":l+="\\v";break;case"001b":l+="\\e";break;case"0085":l+="\\N";break;case"00a0":l+="\\_";break;case"2028":l+="\\L";break;case"2029":l+="\\P";break;default:"00"===t.substr(0,2)?l+="\\x"+t.substr(2):l+=r.substr(e,6)}e+=5,c=e+1}break;case"n":if(n||'"'===r[e+2]||r.length<i)e+=1;else{for(l+=r.slice(c,e)+"\n\n";"\\"===r[e+2]&&"n"===r[e+3]&&'"'!==r[e+4];)l+="\n",e+=2;l+=o," "===r[e+2]&&(l+="\\"),e+=1,c=e+1}break;default:e+=1}return l=c?l+r.slice(c):r,n?l:s.foldFlowLines(l,o,s.FOLD_QUOTED,a(t,!1))}function l(e,t){if(!1===t.options.singleQuote||t.implicitKey&&e.includes("\n")||/[ \t]\n|\n[ \t]/.test(e))return o(e,t);let r=t.indent||(/^(%|---|\.\.\.)/m.test(e)?" ":""),n="'"+e.replace(/'/g,"''").replace(/\n+/g,`$&
119
+ ${r}`)+"'";return t.implicitKey?n:s.foldFlowLines(n,r,s.FOLD_FLOW,a(t,!1))}function c(e,t){let r,{singleQuote:n}=t.options;if(!1===n)r=o;else{let t=e.includes('"'),i=e.includes("'");r=t&&!i?l:i&&!t?o:n?l:o}return r(e,t)}try{n=RegExp("(^|(?<!\n))\n+(?!\n|$)","g")}catch{n=/\n+(?!\n|$)/g}function u({comment:e,type:t,value:r},o,l,d){let f,h,p,m,{blockQuote:g,commentString:y,lineWidth:b}=o.options;if(!g||/\n[\t ]+$/.test(r))return c(r,o);let v=o.indent||(o.forceBlockIndent||(m=r,/^(%|---|\.\.\.)/m.test(m))?" ":""),w="literal"===g||"folded"!==g&&t!==i.Scalar.BLOCK_FOLDED&&(t===i.Scalar.BLOCK_LITERAL||!function(e,t,r){if(!t||t<0)return!1;let n=t-r,i=e.length;if(i<=n)return!1;for(let t=0,r=0;t<i;++t)if("\n"===e[t]){if(t-r>n)return!0;if(i-(r=t+1)<=n)return!1}return!0}(r,b,v.length));if(!r)return w?"|\n":">\n";for(h=r.length;h>0;--h){let e=r[h-1];if("\n"!==e&&" "!==e&&" "!==e)break}let x=r.substring(h),k=x.indexOf("\n");-1===k?f="-":r===x||k!==x.length-1?(f="+",d&&d()):f="",x&&(r=r.slice(0,-x.length),"\n"===x[x.length-1]&&(x=x.slice(0,-1)),x=x.replace(n,`$&${v}`));let S=!1,_=-1;for(p=0;p<r.length;++p){let e=r[p];if(" "===e)S=!0;else if("\n"===e)_=p;else break}let O=r.substring(0,_<p?_+1:p);O&&(r=r.substring(O.length),O=O.replace(/\n+/g,`$&${v}`));let I=v?"2":"1",$=(S?I:"")+f;if(e&&($+=" "+y(e.replace(/ ?[\r\n]+/g," ")),l&&l()),!w){let e=r.replace(/\n+/g,"\n$&").replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${v}`),n=!1,l=a(o,!0);"folded"!==g&&t!==i.Scalar.BLOCK_FOLDED&&(l.onOverflow=()=>{n=!0});let c=s.foldFlowLines(`${O}${e}${x}`,v,s.FOLD_BLOCK,l);if(!n)return`>${$}
120
+ ${v}${c}`}return r=r.replace(/\n+/g,`$&${v}`),`|${$}
121
+ ${v}${O}${r}${x}`}t.stringifyString=function(e,t,r,n){let{implicitKey:d,inFlow:f}=t,h="string"==typeof e.value?e:Object.assign({},e,{value:String(e.value)}),{type:p}=e;p!==i.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(h.value)&&(p=i.Scalar.QUOTE_DOUBLE);let m=e=>{switch(e){case i.Scalar.BLOCK_FOLDED:case i.Scalar.BLOCK_LITERAL:return d||f?c(h.value,t):u(h,t,r,n);case i.Scalar.QUOTE_DOUBLE:return o(h.value,t);case i.Scalar.QUOTE_SINGLE:return l(h.value,t);case i.Scalar.PLAIN:return function(e,t,r,n){let{type:o,value:l}=e,{actualString:d,implicitKey:f,indent:h,indentStep:p,inFlow:m}=t;if(f&&l.includes("\n")||m&&/[[\]{},]/.test(l))return c(l,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(l))return f||m||!l.includes("\n")?c(l,t):u(e,t,r,n);if(!f&&!m&&o!==i.Scalar.PLAIN&&l.includes("\n"))return u(e,t,r,n);if(/^(%|---|\.\.\.)/m.test(l)){if(""===h)return t.forceBlockIndent=!0,u(e,t,r,n);else if(f&&h===p)return c(l,t)}let g=l.replace(/\n+/g,`$&
122
+ ${h}`);if(d){let e=e=>e.default&&"tag:yaml.org,2002:str"!==e.tag&&e.test?.test(g),{compat:r,tags:n}=t.doc.schema;if(n.some(e)||r?.some(e))return c(l,t)}return f?g:s.foldFlowLines(g,h,s.FOLD_FLOW,a(t,!1))}(h,t,r,n);default:return null}},g=m(p);if(null===g){let{defaultKeyType:e,defaultStringType:r}=t.options,n=d&&e||r;if(null===(g=m(n)))throw Error(`Unsupported default string type ${n}`)}return g}},7995(e,t,r){var n=r(6730);let i=Symbol("break visit"),s=Symbol("skip children"),a=Symbol("remove node");function o(e,t){let r=d(t);n.isDocument(e)?l(null,e.contents,r,Object.freeze([e]))===a&&(e.contents=null):l(null,e,r,Object.freeze([]))}function l(e,t,r,s){let o=f(e,t,r,s);if(n.isNode(o)||n.isPair(o))return h(e,s,o),l(e,o,r,s);if("symbol"!=typeof o){if(n.isCollection(t)){s=Object.freeze(s.concat(t));for(let e=0;e<t.items.length;++e){let n=l(e,t.items[e],r,s);if("number"==typeof n)e=n-1;else{if(n===i)return i;n===a&&(t.items.splice(e,1),e-=1)}}}else if(n.isPair(t)){s=Object.freeze(s.concat(t));let e=l("key",t.key,r,s);if(e===i)return i;e===a&&(t.key=null);let n=l("value",t.value,r,s);if(n===i)return i;n===a&&(t.value=null)}}return o}async function c(e,t){let r=d(t);n.isDocument(e)?await u(null,e.contents,r,Object.freeze([e]))===a&&(e.contents=null):await u(null,e,r,Object.freeze([]))}async function u(e,t,r,s){let o=await f(e,t,r,s);if(n.isNode(o)||n.isPair(o))return h(e,s,o),u(e,o,r,s);if("symbol"!=typeof o){if(n.isCollection(t)){s=Object.freeze(s.concat(t));for(let e=0;e<t.items.length;++e){let n=await u(e,t.items[e],r,s);if("number"==typeof n)e=n-1;else{if(n===i)return i;n===a&&(t.items.splice(e,1),e-=1)}}}else if(n.isPair(t)){s=Object.freeze(s.concat(t));let e=await u("key",t.key,r,s);if(e===i)return i;e===a&&(t.key=null);let n=await u("value",t.value,r,s);if(n===i)return i;n===a&&(t.value=null)}}return o}function d(e){return"object"==typeof e&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function f(e,t,r,i){return"function"==typeof r?r(e,t,i):n.isMap(t)?r.Map?.(e,t,i):n.isSeq(t)?r.Seq?.(e,t,i):n.isPair(t)?r.Pair?.(e,t,i):n.isScalar(t)?r.Scalar?.(e,t,i):n.isAlias(t)?r.Alias?.(e,t,i):void 0}function h(e,t,r){let i=t[t.length-1];if(n.isCollection(i))i.items[e]=r;else if(n.isPair(i))"key"===e?i.key=r:i.value=r;else if(n.isDocument(i))i.contents=r;else{let e=n.isAlias(i)?"alias":"scalar";throw Error(`Cannot replace node with ${e} parent`)}}o.BREAK=i,o.SKIP=s,o.REMOVE=a,c.BREAK=i,c.SKIP=s,c.REMOVE=a,t.visit=o,t.visitAsync=c},8927(e,t,r){r.d(t,{CN:()=>h,BC:()=>g,Ie:()=>C,pb:()=>N,i8:()=>_,g9:()=>S,Uk:()=>O,Ts:()=>p,CZ:()=>b,ET:()=>v,HV:()=>x,Tj:()=>T,YW:()=>m,of:()=>A,jB:()=>M,TS:()=>P,di:()=>I,KC:()=>E});var n=r(8036),i=r(1044),s=r(4650);let a=e=>e.length>0;var o=r(8496),l=r(3833),c=r(6364),u=r(8099),d=r(995);let f=globalThis.Array,h=e=>new f(e),p=e=>f.isArray(e)?e:f.from(e);u.Wo,l.toArray;let m=(0,s.XY)(2,(e,{onEmpty:t,onNonEmpty:r})=>v(e)?r(e):t()),g=(0,s.XY)(2,(e,t)=>[...e,t]),y=(0,s.XY)(2,(e,t)=>p(e).concat(p(t)));f.isArray;let b=a,v=a,w=(0,s.XY)(2,(e,t)=>{let r=Math.floor(t);if(r<0||r>=e.length)throw Error(`Index out of bounds: ${r}`);return e[r]})(0),x=e=>v(e)?l.some(k(e)):l.none(),k=e=>e[e.length-1],S=(0,s.XY)(2,(e,t)=>{let r=0;for(let n of e){if(t(n,r))return l.some(r);r++}return l.none()}),_=o.i8,O=(0,s.XY)(2,(e,t)=>{let r=p(e);for(let e=r.length-1;e>=0;e--){let n=r[e],i=t(n,e);if("boolean"==typeof i){if(i)return l.some(n)}else if(l.isSome(i))return i}return l.none()}),I=(0,s.XY)(2,(e,t)=>{let r=f.from(e);return r.sort(t),r}),$=(0,s.XY)(3,(e,t,r)=>{let n=p(e),i=p(t);return v(n)?v(i)?j(r)(y(n,i)):n:i}),E=(0,s.XY)(2,(e,t)=>$(e,t,n.jI())),C=()=>[],A=e=>[e],T=(0,s.XY)(2,(e,t)=>e.map(t)),N=(0,s.XY)(2,(e,t)=>{let r=p(e),n=[];for(let e=0;e<r.length;e++)t(r[e],e)&&n.push(r[e]);return n}),M=(0,s.XY)(2,(e,t)=>{let r=[],n=[],i=0;for(let s of e){let e=t(s,i++);d.oJ(e)?n.push(e.success):r.push(e.failure)}return[r,n]}),P=(0,s.XY)(3,(e,t,r)=>p(e).reduce((e,t,n)=>r(e,t,n),t));c.O3,i.O3;let j=(0,s.XY)(2,(e,t)=>{let r=p(e);if(v(r)){let e=[w(r)];for(let n of r.slice(1))e.every(e=>!t(n,e))&&e.push(n);return e}return[]})},631(e,t,r){var n=r(8036),i=r(1044),s=r(4650),a=r(4450),o=r(6400),l=r(3833),c=r(6364),u=r(9138),d=r(5369);let f=/^[+-]?\d+$/,h="~effect/BigDecimal",p={[h]:h,[a.HR](){let e=S(this);return a.kg(a.tW(e.value),a.ai(e.scale))},[n.HR](e){return m(e)&&T(this,e)},toString(){return`BigDecimal(${N(this)})`},toJSON(){return{_id:"BigDecimal",value:String(this.value),scale:this.scale}},[o.FX](){return this.toJSON()},pipe(){return(0,u.tT)(this,arguments)}},m=e=>(0,d.i5)(e,h),g=(e,t)=>{let r=Object.create(p);return r.value=e,r.scale=t,r},y=(e,t)=>{if(e!==b&&e%x===b)throw RangeError("Value must be normalized");let r=g(e,t);return r.normalized=r,r},b=BigInt(0),v=BigInt(1),w=BigInt(-1),x=BigInt(10),k=y(b,0),S=e=>{if(void 0===e.normalized)if(e.value===b)e.normalized=k;else{let t=`${e.value}`,r=0;for(let e=t.length-1;e>=0;e--)if("0"===t[e])r++;else break;0===r&&(e.normalized=e);let n=BigInt(t.substring(0,t.length-r)),i=e.scale-r;e.normalized=y(n,i)}return e.normalized},_=(0,s.XY)(2,(e,t)=>t>e.scale?g(e.value*x**BigInt(t-e.scale),t):t<e.scale?g(e.value/x**BigInt(e.scale-t),t):e),O=(0,s.XY)(2,(e,t)=>t.value===b?e:e.value===b?t:e.scale>t.scale?g(_(t,e.scale).value+e.value,e.scale):e.scale<t.scale?g(_(e,t.scale).value+t.value,t.scale):g(e.value+t.value,e.scale)),I=c.L8((e,t)=>{let r=c.wN(C(e),C(t));return 0!==r?r:e.scale>t.scale?c.Qw(e.value,_(t,e.scale).value):e.scale<t.scale?c.Qw(_(e,t.scale).value,t.value):c.Qw(e.value,t.value)}),$=c.hl(I),E=c.yJ(I),C=e=>e.value===b?0:e.value<b?-1:1,A=i.L8((e,t)=>e.scale>t.scale?_(t,e.scale).value===e.value:e.scale<t.scale?_(e,t.scale).value===t.value:e.value===t.value),T=(0,s.XY)(2,(e,t)=>A(e,t)),N=e=>{let t,r,n=S(e);if(Math.abs(n.scale)>=16)return M(n);let i=n.value<b,s=i?`${n.value}`.substring(1):`${n.value}`;if(n.scale>=s.length)t="0",r="0".repeat(n.scale-s.length)+s;else{let e=s.length-n.scale;if(e>s.length){let n=e-s.length;t=`${s}${"0".repeat(n)}`,r=""}else r=s.slice(e),t=s.slice(0,e)}let a=""===r?t:`${t}.${r}`;return i?`-${a}`:a},M=e=>{if(P(e))return"0e+0";let t=S(e),r=`${(t.value<b?g(-t.value,t.scale):t).value}`,n=r.slice(0,1),i=r.slice(1),s=`${j(t)?"-":""}${n}`;""!==i&&(s+=`.${i}`);let a=i.length-t.scale;return`${s}e${a>=0?"+":""}${a}`},P=e=>e.value===b,j=e=>e.value<b,D=e=>m(e[0]),F=(0,s.XY)(D,(e,t=0)=>e.scale<=t?e:g(e.value/x**BigInt(e.scale-t),t)),L=(0,s.XY)(D,(e,t=0)=>{let r=F(e,t);return e.value>b&&$(r,e)?O(r,g(v,t)):r}),R=(0,s.XY)(D,(e,t=0)=>{let r=F(e,t);return j(e)&&E(r,e)?O(r,g(w,t)):r});r.d(t,{},{GP:N,L8:g,RI:R,hs:_,mk:L,pH:I,rs:A,s5:m,sH:e=>{let t,r,n,i;if(""===e)return l.some(k);let s=e.search(/[eE]/);if(-1!==s){let n=e.slice(s+1);if(t=e.slice(0,s),r=Number(n),""===t||!Number.isSafeInteger(r)||!f.test(n))return l.none()}else t=e,r=0;let a=t.search(/\./);if(-1!==a){let e=t.slice(0,a),r=t.slice(a+1);n=`${e}${r}`,i=r.length}else n=t,i=0;if(!f.test(n))return l.none();let o=i-r;return Number.isSafeInteger(o)?l.some(g(BigInt(n),o)):l.none()}})},8543(e,t,r){var n=r(8433),i=r(1136);n.PX,n.B4,n.Aj,n.Wg;let s=n.lC;n.Xb,n.ik,n.b5,n.DH;let a=n.OE;n.Iu,i.nIy,i.ORc;let o=i.nn5,l=i.O$X;i.h2c;let c=i.ReC;i.myX,i.QE5;let u=i.khU,d=i.L$u;i.gpn,i.k7S,i.BbX;let f=i.prj;i.tU5,i.h74,i.Bou,i.RJ6;let h=i.GyP;n.PW,n.qB,n.Xm;let p=n.$L;n.q_;let m=n.RS,g=n.Vw;i.DQo,i.c8t,i.MUS,i.t8c,i._y;let y=i.qwd;i.ASO,i.F7W,i.Aub,i.cOF,i.Rft,i.RD4,i.Kkt,i.PnV;let b=i.Bk6;n.Eh,i.tQ6,i.On5,r.d(t,{},{$L:p,Bk:b,L$:d,RS:m,Tj:l,Vw:g,fJ:a,iw:c,j9:h,kh:u,lC:s,nn:o,pr:f,qw:y})},190(e,t,r){var n=r(1136);n.a1U,n.RKA;let i=n.Rud;n.s0X,r.d(t,{},{Ru:i})},8619(e,t,r){var n=r(3267),i=r(8036),s=r(4650),a=r(4450),o=r(8433),l=r(3628),c=r(3833),u=r(5369);let d="~effect/Context/Service",f=function(){let e=(0,l.jt)();(0,l.ft)(2);let t=Error();(0,l.ft)(e);let r=function(){};return(Object.setPrototypeOf(r,h),Object.defineProperty(r,"stack",{get:()=>t.stack}),arguments.length>0)?(r.key=arguments[0],arguments[1]?.defaultValue&&(r[p]=p,r.defaultValue=arguments[1].defaultValue),r):function(e,t){return r.key=e,t?.make&&(r.make=t.make),r}},h={[d]:d,...n.b({label:"Service",evaluate(e){return(0,o.xt)(_(e.context,this))}}),toJSON(){return{_id:"Service",key:this.key,stack:this.stack}},of:e=>e,context(e){return w(this,e)},use(e){return(0,o.R6)(t=>e(_(t.context,this)))},useSync(e){return(0,o.R6)(t=>(0,o.xt)(e(_(t.context,this))))}},p="~effect/Context/Reference",m="~effect/Context",g=e=>{let t=Object.create(y);return t.mapUnsafe=e,t.mutable=!1,t},y={...o.fU,[m]:{_Services:e=>e},toJSON(){return{_id:"Context",services:Array.from(this.mapUnsafe).map(([e,t])=>({key:e,value:t}))}},[i.HR](e){if(!b(e)||this.mapUnsafe.size!==e.mapUnsafe.size)return!1;for(let t of this.mapUnsafe.keys())if(!e.mapUnsafe.has(t)||!i.aI(this.mapUnsafe.get(t),e.mapUnsafe.get(t)))return!1;return!0},[a.HR](){return a.ai(this.mapUnsafe.size)}},b=e=>(0,u.i5)(e,m),v=g(new Map),w=(e,t)=>g(new Map([[e.key,t]])),x=(0,s.XY)(3,(e,t,r)=>A(e,e=>{e.set(t.key,r)})),k=(0,s.XY)(2,(e,t)=>e.mapUnsafe.get(t.key)),S=(0,s.XY)(2,(e,t)=>{if(!e.mapUnsafe.has(t.key)){if(p in t)return I(t);throw $(t)}return e.mapUnsafe.get(t.key)}),_=S,O="~effect/Context/defaultValue",I=e=>O in e?e[O]:e[O]=e.defaultValue(),$=e=>{let t=Error(`Service not found${e.key?`: ${String(e.key)}`:""}`);if(e.stack){let r=e.stack.split("\n");if(r.length>2){let e=r[2].match(/at (.*)/);e&&(t.message=t.message+` (defined at ${e[1]})`)}}if(t.stack){let e=t.stack.split("\n");e.splice(1,3),t.stack=e.join("\n")}return t},E=(0,s.XY)(2,(e,t)=>e.mapUnsafe.has(t.key)?c.some(e.mapUnsafe.get(t.key)):(0,u.i5)(t,p)?c.some(I(t)):c.none()),C=(0,s.XY)(2,(e,t)=>0===e.mapUnsafe.size?t:0===t.mapUnsafe.size?e:A(e,e=>{t.mapUnsafe.forEach((t,r)=>e.set(r,t))})),A=(e,t)=>{if(e.mutable)return t(e.mapUnsafe),e;let r=new Map(e.mapUnsafe);return t(r),g(r)};r.d(t,{},{Ie:()=>v,Jt:_,L8:w,LZ:g,Or:f,Um:(...e)=>{let t=new Map;for(let r=0;r<e.length;r++)e[r].mapUnsafe.forEach((e,r)=>{t.set(r,e)});return g(t)},WQ:x,Y6:k,aE:b,fp:S,h1:C,kA:(e,t)=>e.mapUnsafe.has(t.key)?e.mapUnsafe.get(t.key):I(t),kl:f,om:E})},2718(e,t,r){var n=r(8433),i=r(9138),s=r(5369);let a=class extends i.Xs{constructor(e){super(),e&&Object.assign(this,e)}};function o(){if(1==arguments.length){let e=arguments[0];return function(t){return e[t._tag](t)}}let e=arguments[0],t=arguments[1];return t[e._tag](e)}let l=n.$D,c=n.rN;r.d(t,{},{$D:l,Ij:()=>new Proxy({},{get:(e,t,r)=>"$is"===t?s.$J:"$match"===t?o:e=>({...e,_tag:t})}),Xs:a,rN:c})},4705(e,t,r){r.d(t,{rs:()=>ef,pH:()=>eh,dv:()=>eI,Rd:()=>e$,tn:()=>ep,Ar:()=>ea,kQ:()=>eo,rg:()=>ec,lU:()=>el,rr:()=>eu,Ry:()=>ed,L8:()=>eg,MO:()=>ey,TT:()=>em,yF:()=>e_,Xy:()=>eO,yT:()=>eb,ez:()=>ek,y3:()=>ex,k9:()=>ev,ko:()=>ew,xV:()=>eS}),r(8619);var n=r(4650),i=r(8543),s=r(190),a=(r(2302),r(8036)),o=r(1044),l=r(4450),c=r(6400),u=r(3833),d=r(6364),f=r(9138),h=r(5369);r(1136);let p="~effect/time/DateTime",m="~effect/time/DateTime/TimeZone",g={[p]:p,pipe(){return(0,f.tT)(this,arguments)},[c.FX](){return this.toString()},toJSON(){return W(this).toJSON()}},y={...g,_tag:"Utc",[l.HR](){return l.ai(this.epochMilliseconds)},[a.HR](e){return S(e)&&"Utc"===e._tag&&this.epochMilliseconds===e.epochMilliseconds},toString(){return`DateTime.Utc(${W(this).toJSON()})`}},b={...g,_tag:"Zoned",[l.HR](){return l.kg(l.ai(this.epochMilliseconds))(l.tW(this.zone))},[a.HR](e){return S(e)&&"Zoned"===e._tag&&this.epochMilliseconds===e.epochMilliseconds&&a.aI(this.zone,e.zone)},toString(){return`DateTime.Zoned(${es(this)})`}},v={[m]:m,[c.FX](){return this.toString()}},w={...v,_tag:"Named",[l.HR](){return l.Yj(`Named:${this.id}`)},[a.HR](e){return O(e)&&"Named"===e._tag&&this.id===e.id},toString(){return`TimeZone.Named(${this.id})`},toJSON(){return{_id:"TimeZone",_tag:"Named",id:this.id}}},x={...v,_tag:"Offset",[l.HR](){return l.Yj(`Offset:${this.offset}`)},[a.HR](e){return O(e)&&"Offset"===e._tag&&this.offset===e.offset},toString(){return`TimeZone.Offset(${K(this.offset)})`},toJSON(){return{_id:"TimeZone",_tag:"Offset",offset:this.offset}}},k=(e,t,r)=>{let n=Object.create(b);return n.epochMilliseconds=e,n.zone=t,Object.defineProperty(n,"partsUtc",{value:r,enumerable:!1,writable:!0}),Object.defineProperty(n,"adjustedEpochMillis",{value:void 0,enumerable:!1,writable:!0}),Object.defineProperty(n,"partsAdjusted",{value:void 0,enumerable:!1,writable:!0}),n},S=e=>h.i5(e,p),_=e=>S(e[0]),O=e=>h.i5(e,m),I=e=>"Zoned"===e._tag,$=o.L8((e,t)=>e.epochMilliseconds===t.epochMilliseconds),E=d.L8((e,t)=>e.epochMilliseconds<t.epochMilliseconds?-1:+(e.epochMilliseconds>t.epochMilliseconds)),C=e=>{let t=Object.create(y);return t.epochMilliseconds=e,Object.defineProperty(t,"partsUtc",{value:void 0,enumerable:!1,writable:!0}),t},A=e=>{let t=e.getTime();if(Number.isNaN(t))throw new i.qw("Invalid date");return C(t)},T=e=>{if(S(e))return e;if(e instanceof Date)return A(e);if("object"==typeof e){if("epochMilliseconds"in e)return C(e.epochMilliseconds);let t=new Date(0);return G(t,e),A(t)}return"string"!=typeof e||N(e)?A(new Date(e)):A(new Date(e+"Z"))},N=e=>/Z|GMT|[+-]\d{2}$|[+-]\d{2}:?\d{2}$|\]$/.test(e),M=(e,t)=>{let r,n=t?.timeZone;if(void 0===n&&S(e)&&I(e))return e;let s=T(e);if(s.epochMilliseconds<-86399999568e5||s.epochMilliseconds>86399999496e5)throw RangeError(`Epoch millis out of range: ${s.epochMilliseconds}`);if(void 0===n&&"object"==typeof e&&"timeZoneId"in e&&(n=e.timeZoneId),void 0===n)r=U(-60*new Date(s.epochMilliseconds).getTimezoneOffset()*1e3);else if(O(n))r=n;else if("number"==typeof n)r=U(n);else{let e=X(n);if(u.isNone(e))throw new i.qw(`Invalid time zone: ${n}`);r=e.value}return t?.adjustForTimeZone!==!0?k(s.epochMilliseconds,r,s.partsUtc):H(s.epochMilliseconds,r,t?.disambiguation??"compatible")},P=u.liftThrowable(M),j=u.liftThrowable(T),D=/^(.{17,35})\[(.+)\]$/;s.Ru,s.Ru,(e,t,r)=>r?.adjustForTimeZone===!0?H(e.epochMilliseconds,t,r?.disambiguation??"compatible"):k(e.epochMilliseconds,t,e.partsUtc);let F=new Map,L={day:"numeric",month:"numeric",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"longOffset",fractionalSecondDigits:3,hourCycle:"h23"},R=e=>{if(F.has(e))return F.get(e);try{var t=new Intl.DateTimeFormat("en-US",{...L,timeZone:e});let r=t.resolvedOptions().timeZone;if(F.has(r))return F.get(r);let n=Object.create(w);return n.id=r,n.format=t,F.set(r,n),n}catch{throw new i.qw(`Invalid time zone: ${e}`)}},U=e=>{let t=Object.create(x);return t.offset=e,t},B=u.liftThrowable(R),Y=/^(?:GMT|[+-])/,X=e=>{if(Y.test(e)){let t=Q(e);return null===t?u.none():u.some(U(t))}return B(e)},W=e=>new Date(e.epochMilliseconds),J=e=>{if("Utc"===e._tag)return new Date(e.epochMilliseconds);if("Offset"===e.zone._tag)return new Date(e.epochMilliseconds+e.zone.offset);if(void 0!==e.adjustedEpochMilliseconds)return new Date(e.adjustedEpochMilliseconds);let t=e.zone.format.formatToParts(e.epochMilliseconds).filter(e=>"literal"!==e.type),r=new Date(0);return r.setUTCFullYear(Number(t[2].value),Number(t[0].value)-1,Number(t[1].value)),r.setUTCHours(Number(t[3].value),Number(t[4].value),Number(t[5].value),Number(t[6].value)),e.adjustedEpochMilliseconds=r.getTime(),r},q=e=>J(e).getTime()-V(e),K=e=>{let t=Math.abs(e),r=Math.floor(t/36e5),n=Math.round(t%36e5/6e4);return 60===n&&(r+=1,n=0),`${e<0?"-":"+"}${String(r).padStart(2,"0")}:${String(n).padStart(2,"0")}`},V=e=>e.epochMilliseconds,G=(e,t)=>{if(void 0!==t.year&&e.setUTCFullYear(t.year),void 0!==t.month&&e.setUTCMonth(t.month-1),void 0!==t.day&&e.setUTCDate(t.day),void 0!==t.weekDay){let r=t.weekDay-e.getUTCDay();e.setUTCDate(e.getUTCDate()+r)}void 0!==t.hour&&e.setUTCHours(t.hour),void 0!==t.minute&&e.setUTCMinutes(t.minute),void 0!==t.second&&e.setUTCSeconds(t.second),void 0!==t.millisecond&&e.setUTCMilliseconds(t.millisecond)},H=(e,t,r)=>{if("Offset"===t._tag)return k(e-t.offset,t);let n=Z(e-864e5,e,t),i=Z(e+864e5,e,t);if(n===i)return k(e-n,t);let s=n-i;if(n<i){if(Z(e-i,e,t)===i)return k(e-i,t);let s=k(e-n,t);if(e!==J(s).getTime())switch(r){case"reject":{let r=new Date(e).toISOString();throw RangeError(`Gap time: ${r} does not exist in time zone ${t.id}`)}case"earlier":return k(e-i,t)}return s}if(Z(e-n,e,t)===n){if("earlier"===r||"compatible"===r||Z(e-n+s,e+s,t)===n)return k(e-n,t);if("reject"===r){let r=new Date(e).toISOString();throw RangeError(`Ambiguous time: ${r} occurs twice in time zone ${t.id}`)}}return k(e-i,t)},z=/([+-])(\d{2}):(\d{2})$/,Q=e=>{let t=z.exec(e);if(null===t)return null;let[,r,n,i]=t;return("+"===r?1:-1)*(60*Number(n)+Number(i))*6e4},Z=(e,t,r)=>{let n=r.format.formatToParts(e).find(e=>"timeZoneName"===e.type)?.value??"";if("GMT"===n)return 0;let i=Q(n);return null===i?q(k(t,r)):i},ee=(0,n.XY)(_,(e,t,r)=>{if("Utc"===e._tag){let r=W(e);return t(r),C(r.getTime())}let n=new Date(J(e).getTime());return t(n),H(n.getTime(),e.zone,r?.disambiguation??"compatible")}),et=((e,t)=>et(e,e=>{let r=new Date(e);return t(r),r.getTime()}),(0,n.XY)(2,(e,t)=>{let r=t(V(e));return"Utc"===e._tag?C(r):k(r,e.zone)})),er=((e,t)=>t(J(e)),(0,n.XY)(2,(e,t)=>t(W(e)))),en=(e,t)=>{e.setTime(e.getTime()+t)},ei=((e,t)=>ee(e,e=>{if(t.milliseconds&&en(e,t.milliseconds),t.seconds&&en(e,1e3*t.seconds),t.minutes&&en(e,60*t.minutes*1e3),t.hours&&en(e,60*t.hours*6e4),t.days&&e.setUTCDate(e.getUTCDate()+t.days),t.weeks&&e.setUTCDate(e.getUTCDate()+7*t.weeks),t.months){let r=e.getUTCDate();e.setUTCMonth(e.getUTCMonth()+t.months+1,0),r<e.getUTCDate()&&e.setUTCDate(r)}if(t.years){let r=e.getUTCDate(),n=e.getUTCMonth();e.setUTCFullYear(e.getUTCFullYear()+t.years,n+1,0),r<e.getUTCDate()&&e.setUTCDate(r)}}),e=>{let t=J(e);return"Utc"===e._tag?t.toISOString():`${t.toISOString().slice(0,-1)}${K(q(e))}`}),es=e=>"Offset"===e.zone._tag?ei(e):`${ei(e)}[${e.zone.id}]`;r(5089);let ea=S,eo=O,el=e=>O(e)&&"Offset"===e._tag,ec=e=>O(e)&&"Named"===e._tag,eu=e=>"Utc"===e._tag,ed=I,ef=$,eh=E,ep=A,em=M,eg=j,ey=e=>{let t=D.exec(e);if(null===t){let t=Q(e);return null!==t?P(e,{timeZone:t}):u.none()}let[,r,n]=t;return P(r,{timeZone:n})},eb=e=>C(e.epochMilliseconds),ev=R,ew=U,ex=B,ek=X,eS=e=>"Offset"===e._tag?K(e.offset):e.id,e_=W,eO=V,eI=e=>W(e).toISOString(),e$=es},3717(e,t,r){var n=r(4650),i=r(1136),s=r(9138);let a={"~effect/Deferred":{_A:n.D_,_E:n.D_},pipe(){return(0,s.tT)(this,arguments)}},o=(0,n.XY)(2,(e,t)=>i.OH5(()=>l(e,t))),l=(e,t)=>{if(e.effect)return!1;if(e.effect=t,e.resumes){for(let r=0;r<e.resumes.length;r++)e.resumes[r](t);e.resumes=void 0}return!0};r.d(t,{},{$L:e=>i.OH5(()=>void 0!==e.effect),$w:l,LZ:()=>{let e=Object.create(a);return e.resumes=void 0,e.effect=void 0,e},Tx:e=>i.E2r(t=>e.effect?t(e.effect):(e.resumes??=[],e.resumes.push(t),i.OH5(()=>{let r=e.resumes.indexOf(t);e.resumes.splice(r,1)}))),Vw:o})},2302(e,t,r){var n=r(8036),i=r(4650),s=r(4450),a=r(6400),o=r(3833),l=r(6364),c=r(9138),u=r(5369);let d="~effect/time/Duration",f=BigInt(0),h=BigInt(1),p=BigInt(1e3),m=e=>BigInt(e<0?Math.ceil(e-.5):Math.floor(e+.5)),g=(e,t)=>e.includes(".")?m(Number(e)*Number(t)):BigInt(e)*t,y=/^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/,b=e=>{switch(typeof e){case"number":return T(e);case"bigint":return A(e);case"string":{if("Infinity"===e)return E;if("-Infinity"===e)return C;let t=y.exec(e);if(!t)break;let[r,n,i]=t;if("nano"===i||"nanos"===i)return A(g(n,h));if("micro"===i||"micros"===i)return A(g(n,p));let s=Number(n);switch(i){case"milli":case"millis":return T(s);case"second":case"seconds":return N(s);case"minute":case"minutes":return M(s);case"hour":case"hours":return P(s);case"day":case"days":return j(s);case"week":case"weeks":return D(s)}break}case"object":{if(null===e)break;if(d in e)return e;if(Array.isArray(e)){if(2!==e.length||!e.every(u.Et))return v(e);if(Number.isNaN(e[0])||Number.isNaN(e[1]))return $;if(e[0]===-1/0||e[1]===-1/0)return C;if(e[0]===1/0||e[1]===1/0)return E;return O(m(1e9*e[0]+e[1]))}let t=0;if(e.weeks&&(t+=6048e5*e.weeks),e.days&&(t+=864e5*e.days),e.hours&&(t+=36e5*e.hours),e.minutes&&(t+=6e4*e.minutes),e.seconds&&(t+=1e3*e.seconds),e.milliseconds&&(t+=e.milliseconds),!e.microseconds&&!e.nanoseconds)return O(t);return O(m(1e6*t+(e.microseconds??0)*1e3+(e.nanoseconds??0)))}}return v(e)},v=e=>{throw Error(`Invalid Input: ${e}`)},w=o.liftThrowable(b),x={_tag:"Millis",millis:0},k={_tag:"Infinity"},S={_tag:"NegativeInfinity"},_={[d]:d,[s.HR](){return s.QK(this.value)},[n.HR](e){return I(e)&&W(this,e)},toString(){switch(this.value._tag){case"Infinity":return"Infinity";case"NegativeInfinity":return"-Infinity";case"Nanos":return`${this.value.nanos} nanos`;case"Millis":return`${this.value.millis} millis`}},toJSON(){switch(this.value._tag){case"Millis":return{_id:"Duration",_tag:"Millis",millis:this.value.millis};case"Nanos":return{_id:"Duration",_tag:"Nanos",nanos:String(this.value.nanos)};case"Infinity":return{_id:"Duration",_tag:"Infinity"};case"NegativeInfinity":return{_id:"Duration",_tag:"NegativeInfinity"}}},[a.FX](){return this.toJSON()},pipe(){return(0,c.tT)(this,arguments)}},O=e=>{let t=Object.create(_);return"number"==typeof e?isNaN(e)||0===e||Object.is(e,-0)?t.value=x:Number.isFinite(e)?Number.isInteger(e)?t.value={_tag:"Millis",millis:e}:t.value={_tag:"Nanos",nanos:m(1e6*e)}:t.value=e>0?k:S:e===f?t.value=x:t.value={_tag:"Nanos",nanos:e},t},I=e=>(0,u.i5)(e,d),$=O(0),E=O(1/0),C=O(-1/0),A=e=>O(e),T=e=>O(e),N=e=>O(1e3*e),M=e=>O(6e4*e),P=e=>O(36e5*e),j=e=>O(864e5*e),D=e=>O(6048e5*e),F=e=>{let t=b(e);switch(t.value._tag){case"Infinity":case"NegativeInfinity":throw Error("Cannot convert infinite duration to nanos");case"Nanos":return t.value.nanos;case"Millis":return m(1e6*t.value.millis)}},L=o.liftThrowable(F),R=(0,i.XY)(2,(e,t)=>{switch(e.value._tag){case"Millis":return t.onMillis(e.value.millis);case"Nanos":return t.onNanos(e.value.nanos);case"Infinity":return t.onInfinity();case"NegativeInfinity":return(t.onNegativeInfinity??t.onInfinity)()}}),U=(0,i.XY)(3,(e,t,r)=>"Infinity"===e.value._tag||"NegativeInfinity"===e.value._tag||"Infinity"===t.value._tag||"NegativeInfinity"===t.value._tag?r.onInfinity(e,t):"Millis"===e.value._tag?"Millis"===t.value._tag?r.onMillis(e.value.millis,t.value.millis):r.onNanos(F(e),t.value.nanos):r.onNanos(e.value.nanos,F(t))),B=l.L8((e,t)=>U(e,t,{onMillis:(e,t)=>e<t?-1:+(e>t),onNanos:(e,t)=>e<t?-1:+(e>t),onInfinity:(e,t)=>e.value._tag===t.value._tag?0:"Infinity"===e.value._tag?1:"NegativeInfinity"===e.value._tag||"Infinity"===t.value._tag?-1:1})),Y=(e,t)=>U(e,t,{onMillis:(e,t)=>e===t,onNanos:(e,t)=>e===t,onInfinity:(e,t)=>e.value._tag===t.value._tag}),X=l.bi(B),W=(0,i.XY)(2,(e,t)=>Y(e,t));r.d(t,{},{MI:e=>"Infinity"!==e.value._tag&&"NegativeInfinity"!==e.value._tag,Tn:E,bN:b,bi:X,cF:A,kE:e=>R(b(e),{onMillis:i.D_,onNanos:e=>Number(e)/1e6,onInfinity:()=>1/0,onNegativeInfinity:()=>-1/0}),lX:w,n$:I,ne:T,qv:C,rs:Y,tb:L,v_:$})},7720(e,t,r){r.d(t,{Q56:()=>ew,jGc:()=>ex,U9h:()=>ek,Q7R:()=>x,hgn:()=>Y,swY:()=>eY,Muk:()=>eA,as:()=>V,NLW:()=>G,E2r:()=>T,MfU:()=>H,Tyx:()=>Z,osR:()=>ee,KuX:()=>z,loE:()=>Q,RKA:()=>eU,_32:()=>eT,_r7:()=>eX,yeE:()=>eS,NS5:()=>q,fJG:()=>P,ATB:()=>j,pVV:()=>D,qIB:()=>B,Ab9:()=>eK,fn:()=>eR,D9k:()=>eL,vCS:()=>eV,jJl:()=>k,i4r:()=>eC,ar0:()=>eM,x6Z:()=>eP,yUA:()=>U,JkU:()=>M,XeO:()=>ea,GaK:()=>eI,yw5:()=>w,vVN:()=>eB,TjK:()=>K,q7Y:()=>eq,jkJ:()=>eW,xm_:()=>et,Z9x:()=>eJ,YWq:()=>eu,khu:()=>ed,tvg:()=>ef,ZmZ:()=>N,S5A:()=>e_,cfM:()=>eO,uKv:()=>J,QgK:()=>er,Gte:()=>eh,PpN:()=>ep,PfK:()=>eg,KT6:()=>ec,Ket:()=>W,L5P:()=>es,MY7:()=>ej,eJC:()=>eD,lKS:()=>eF,z8E:()=>ey,P1j:()=>eb,Pxi:()=>ev,Nav:()=>em,yy4:()=>el,PyW:()=>O,lwU:()=>I,nGE:()=>$,DYE:()=>E,OH5:()=>C,Mim:()=>X,dGm:()=>ei,sFT:()=>en,mgX:()=>eo,SvU:()=>L,$mh:()=>_,rfi:()=>e$,FcF:()=>eE,rIH:()=>A,iMI:()=>S,R6R:()=>R,fRP:()=>eN});var n=r(4650),i=r(8433),s=r(1136),a=r(8619);r(995);var o=r(3587),l=r(5089);let c=(0,n.XY)(e=>(0,i.yw)(e[0]),(e,t,r)=>{let n;return a.aE(t)?s.PpN(e,t):(n=Array.isArray(t)?l.Um(...t):t,s.Pxi(t=>s.qIB(r?.local?l.H7(n,l.j6(),t):l.LT(n,t),t=>s.PpN(e,t))))});var u=r(3833),d=r(4505),f=r(3537);(e,t,r)=>s.qIB(o.xn(t),t=>{let n=o.d3.defaultValue();return s.h_t(s.i4r(s.Mim(s.qIB(s.DYE(()=>s.PfK(e,o.d3,n)),t),e=>s.OH5(()=>{n=e})),{disableYield:!0}),e=>i.$L(e)?s.PyW(e.value):r(e,0===n.attempt?u.none():u.some(n)))});let h=(0,n.XY)(3,(e,t,r)=>s.qIB(o.xn(t),t=>{let n,i=o.d3.defaultValue(),a=s.h_t(s.DYE(()=>s.PfK(e,o.d3,i)),e=>(n=e,s.qIB(t(e),e=>(i=e,a))));return d.m8(a,e=>(0,f.s)(()=>r(n,e)))})),p=(0,n.XY)(2,(e,t)=>h(e,"function"==typeof t?t(n.D_):o.GM(t)?t:g(t),s.fJG)),m=o.le(o.i4),g=e=>{let t=e.schedule?o.le(e.schedule):m;return e.while&&(t=o.E6(t,({input:t})=>{let r=e.while(t);return i.yw(r)?r:s.PyW(r)})),e.until&&(t=o.E6(t,({input:t})=>{let r=e.until(t);return i.yw(r)?s.TjK(r,e=>!e):s.PyW(!r)})),void 0!==e.times&&(t=o.E6(t,({attempt:t})=>s.PyW(t<=e.times))),t},y=o.t5(1),b=r(8036).Xq({_E:e=>e,_A:e=>e,_R:e=>e});({...i.In,"~effect/Request":b}),r(8469);var v=r(3864);i.$n;let w=i.yw,x=s.Q7R;s.jBG,s.tfT,s.i8i,s.kAe;let k=s.jJl,S=s.iMI;s.ivC;let _=s.$mh,O=s.PyW,I=s.lwU,$=s.nGE,E=s.DYE,C=s.OH5,A=s.rIH;s.Vxk;let T=s.E2r,N=s.ZmZ;s.Do,s.JrD,s.uVU,s.oIE;let M=s.JkU,P=s.fJG;s.gOk;let j=s.ATB,D=s.pVV,F=s.F_Q,L=s.SvU;s.m9E,s.KN3;let R=i.R6,U=s.yUA;s.sVm,s.pkL,s.bJ;let B=s.qIB;s.Bqz;let Y=s.hgn,X=s.Mim,W=s.Ket,J=s.uKv,q=s.NS5,K=s.TjK,V=s.as;s.Xx$;let G=s.NLW;s.UUz,s.yU6,s.OYO;let H=s.h_t,z=s.KuX,Q=s.loE;s.AXC,s.zt4,s.scW;let Z=s.Tyx;s.Fig,s.XWm;let ee=s.osR;s.U9Y,s.sJf,s.rNk;let et=s.xm_;s.UcN;let er=s.QgK,en=s.sFT;s.k$L;let ei=s.dGm;s.cA6,s.bKC,s.nAi,s.u4Y;let es=p;s._Sg;let ea=s.XeO;s.GrF,s.$$g,s.DM4,s.Dd,s.wRz,s.D52;let eo=s.mgX;s.cbG;let el=s.yy4;s.ayu,s.Vdx,s.FfP,s.O4F;let ec=s.KT6;s.pbD,s.x1Q,s.E8K,s.Pm0,s.VtY,s.W$I,s.ahH,s.z7s;let eu=s.YWq;s.G$Q,s.D$$,s.NZb,s.wR5;let ed=s.khu,ef=s.tvg;s.N6O,s.oJd,s._OA,s.sxi;let eh=c,ep=s.PpN;s.oao,s.euC;let em=s.Nav;s.r_d,s.bUZ;let eg=s.PfK;s.c7E,s.KyM;let ey=s.z8E,eb=s.P1j,ev=s.Pxi,ew=s.Q56;s.N24;let ex=s.jGc,ek=s.U9h,eS=s.yeE,e_=s.S5A;s.BeE,s.iKM,s.r7h;let eO=s.cfM;s.fGe,s.uRq,s.PO3,s.Rgn,s.CJw;let eI=s.GaK;s.Inz,s.nAr;let e$=s.rfi,eE=s.FcF;s.eMl,s.dsN;let eC=s.i4r;s.aAq,s.Xrv,s.kJM,s._o1,s.nDN,s.MaT;let eA=s.Muk;s.ww9;let eT=s._32;s.Wj8,s.Fu6,s.WbR,s.A_r,s.Z98,s.Rd$,s.gvr;let eN=s.fRP;s.zr8,s.hq,s.zhn;let eM=s.ar0,eP=s.x6Z;s.yxg,s.PCg,s.pEE,s.ABT;let ej=s.MY7,eD=s.eJC;s.lSz,s.bPG,s.pR5,s.v2Q,s.NpQ,s.jqV,s.HZF,s.lE;let eF=s.lKS;s.rfH;let eL=s.D9k,eR=s.fn,eU=s.RKA;s.lIX;let eB=s.lIX("Error"),eY=(0,n.XY)(e=>w(e[0]),(e,...t)=>s.bUZ(e,v.iL,e=>{let r={...e};return 1===t.length?Object.assign(r,t[0]):r[t[0]]=t[1],r}));s.gsV;let eX=(e,t,r)=>(...n)=>T(i=>{try{e(...n,(e,r)=>{e?i(P(t?t(e,n):e)):i(O(r))})}catch(e){i(r?P(r(e,n)):F(e))}}),eW=s.jkJ,eJ=s.Z9x,eq=s.q7Y,eK=s.Ab9;s.UVN;let eV=s.vCS},3267(e,t,r){var n=r(8433);r.d(t,{},{b:e=>(0,n.yj)({op:e.label,[n._3]:e.evaluate})})},8983(e,t,r){var n=r(2718),i=r(995);let s="~effect/encoding/EncodingError";class a extends n.rN("EncodingError"){[s]=s}let o=e=>{let t=f(e),r=t.length;if(r%4!=0)return i.fJ(new a({kind:"Decode",module:"Base64",input:t,message:`Length must be a multiple of 4, but is ${r}`}));let n=t.indexOf("=");if(-1!==n&&(n<r-2||n===r-2&&"="!==t[r-1]))return i.fJ(new a({kind:"Decode",module:"Base64",input:t,message:"Found a '=' character, but it is not at the end"}));try{let e=t.endsWith("==")?2:+!!t.endsWith("="),n=new Uint8Array(r/4*3-e);for(let e=0,i=0;e<r;e+=4,i+=3){let r=p(t.charCodeAt(e))<<18|p(t.charCodeAt(e+1))<<12|p(t.charCodeAt(e+2))<<6|p(t.charCodeAt(e+3));n[i]=r>>16,n[i+1]=r>>8&255,n[i+2]=255&r}return i.Py(n)}catch(e){return i.fJ(new a({kind:"Decode",module:"Base64",input:t,message:e instanceof Error?e.message:"Invalid input"}))}},l=e=>{let t=f(e),r=t.length;if(r%4==1)return i.fJ(new a({module:"Base64Url",kind:"Decode",input:t,message:`Length should be a multiple of 4, but is ${r}`}));if(!/^[-_A-Z0-9]*?={0,2}$/i.test(t))return i.fJ(new a({module:"Base64Url",kind:"Decode",input:t,message:"Invalid input"}));let n=r%4==2?`${t}==`:r%4==3?`${t}=`:t;return o(n=n.replace(/-/g,"+").replace(/_/g,"/"))},c=e=>{let t=new TextEncoder().encode(e);if(t.length%2!=0)return i.fJ(new a({module:"Hex",kind:"Decode",input:e,message:`Length must be a multiple of 2, but is ${t.length}`}));try{let e=t.length/2,r=new Uint8Array(e);for(let n=0;n<e;n++){let e=v(t[2*n]),i=v(t[2*n+1]);r[n]=e<<4|i}return i.Py(r)}catch(t){return i.fJ(new a({module:"Hex",kind:"Decode",input:e,message:t instanceof Error?t.message:"Invalid input"}))}},u=new TextEncoder,d=new TextDecoder,f=e=>e.replace(/[\n\r]/g,""),h=e=>{let t,r=e.length,n="";for(t=2;t<r;t+=3)n+=m[e[t-2]>>2],n+=m[(3&e[t-2])<<4|e[t-1]>>4],n+=m[(15&e[t-1])<<2|e[t]>>6],n+=m[63&e[t]];return t===r+1&&(n+=m[e[t-2]>>2],n+=m[(3&e[t-2])<<4],n+="=="),t===r&&(n+=m[e[t-2]>>2],n+=m[(3&e[t-2])<<4|e[t-1]>>4],n+=m[(15&e[t-1])<<2],n+="="),n};function p(e){if(e>=g.length)throw TypeError(`Invalid character ${String.fromCharCode(e)}`);let t=g[e];if(255===t)throw TypeError(`Invalid character ${String.fromCharCode(e)}`);return t}let m=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9","+","/"],g=[255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,62,255,255,255,63,52,53,54,55,56,57,58,59,60,61,255,255,255,0,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255,255,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],y=e=>h(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"),b=e=>{let t="";for(let r=0;r<e.length;++r)t+=w[e[r]];return t},v=e=>{if(48<=e&&e<=57)return e-48;if(97<=e&&e<=102)return e-97+10;if(65<=e&&e<=70)return e-65+10;throw TypeError("Invalid input")},w=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];r.d(t,{},{$T:e=>i.Tj(o(e),e=>d.decode(e)),$X:l,DX:e=>"string"==typeof e?y(u.encode(e)):y(e),EF:c,UD:e=>i.Tj(l(e),e=>d.decode(e)),WG:e=>"string"==typeof e?h(u.encode(e)):h(e),mU:e=>"string"==typeof e?b(u.encode(e)):b(e),xQ:e=>i.Tj(c(e),e=>d.decode(e)),y4:o})},8036(e,t,r){var n,i,s,a=r(4450),o=r(6516),l=r(5369);let c="~effect/interfaces/Equal";function u(){return 1==arguments.length?e=>d(e,arguments[0]):d(arguments[0],arguments[1])}function d(e,t){if(e===t)return!0;if(null==e||null==t)return!1;let r=typeof e;return r===typeof t&&("number"===r&&e!=e&&t!=t||!("object"!==r&&"function"!==r||o.J.has(e)||o.J.has(t))&&function(e,t,r){let n=m.get(e);if(n){if(n.has(t))return n.get(t)}else n=new WeakMap,m.set(e,n);let i=r(e,t);n.set(t,i);let s=m.get(t);return s||(s=new WeakMap,m.set(t,s)),s.set(e,i),i}(e,t,p))}let f=new WeakSet,h=new WeakSet;function p(e,t){if(a.tW(e)!==a.tW(t))return!1;if(e instanceof Date)return t instanceof Date&&e.toISOString()===t.toISOString();if(e instanceof RegExp)return t instanceof RegExp&&e.toString()===t.toString();let r=b(e),n=b(t);if(r!==n)return!1;let i=r&&n;return("function"!=typeof e||!!i)&&function(e,t,r){let n=f.has(e),i=h.has(t);if(n&&i)return!0;if(n||i)return!1;f.add(e),h.add(t);let s=r();return f.delete(e),h.delete(t),s}(e,t,()=>{if(i)return e[c](t);if(Array.isArray(e))return!!Array.isArray(t)&&e.length===t.length&&function(e,t){for(let r=0;r<e.length;r++)if(!d(e[r],t[r]))return!1;return!0}(e,t);if(ArrayBuffer.isView(e))return!!ArrayBuffer.isView(t)&&e.byteLength===t.byteLength&&function(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}(e,t);if(e instanceof Map)return t instanceof Map&&e.size===t.size&&g(e,t);if(e instanceof Set)return t instanceof Set&&e.size===t.size&&y(e,t);var r=e,n=t;let s=(0,o.X)(r),a=(0,o.X)(n);if(s.size!==a.size)return!1;for(let e of s)if(!a.has(e)||!d(r[e],n[e]))return!1;return!0})}let m=new WeakMap,g=(n=d,i=d,function(e,t){for(let[r,s]of e){let e=!1;for(let[a,o]of t)if(n(r,a)&&i(s,o)){e=!0;break}if(!e)return!1}return!0}),y=(s=d,function(e,t){for(let r of e){let e=!1;for(let n of t)if(s(r,n)){e=!0;break}if(!e)return!1}return!0}),b=e=>(0,l.i5)(e,c);r.d(t,{aI:()=>u},{HR:c,Xq:e=>(o.J.add(e),e),jI:()=>u})},1044(e,t,r){let n=e=>(t,r)=>t===r||e(t,r),i=n((e,t)=>globalThis.Number.isNaN(e)&&globalThis.Number.isNaN(t));function s(e){return n((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})}function a(e){let t=Reflect.ownKeys(e);return n((r,n)=>{for(let i of t)if(!e[i](r[i],n[i]))return!1;return!0})}r.d(t,{O3:()=>s,_k:()=>a},{L8:n,wN:i})},7598(e,t,r){var n=r(8433),i=r(1136);n.IH,n.b9;let s=n.xt,a=n.cb,o=n.Rk;n.V2,i._sz;let l=i.x5l,c=i.CoE,u=i.VE1;i._mh,i.YDM,i.lNM,i.K$2,i.GUt,i.HIt,i.yJo,i._OD,i.jCT,i.Wtn,i.v9O,i.zPu,i.EkE,i.Hox,i.ely,i.kMI,i.Sv3,i.lgw,r.d(t,{},{AT:a,N6:u,Py:s,fJ:o,oJ:c,rI:l})},956(e,t,r){var n=r(4650),i=r(3833),s=r(5369),a=r(995);s.Kg,s.Et,s.Lm,s.sI,s.Bm,s.$P;let o=(0,n.XY)(2,(e,t)=>r=>{let n=e(r);if(a.N6(n))return a.fJ(r);let i=t(n.success);return a.N6(i)?a.fJ(r):i});r.d(t,{},{Bh:o,zL:e=>t=>{let r=e(t);return a.N6(r)?i.none():i.some(r.success)}})},6470(e,t,r){var n=r(5369),i=r(1743);let s="[Circular]";function a(e){return"string"==typeof e?JSON.stringify(e):String(e)}function o(e){return e.map(e=>`[${a(e)}]`).join("")}function l(e){try{return e.toISOString()}catch{return"Invalid Date"}}function c(e,t){let r=[];return JSON.stringify(e,function(e,t){let n=(0,i.E$)(t);if("object"!=typeof n||null===n)return n;for(;r.length>0&&r[r.length-1]!==this;)r.pop();if(!r.includes(n))return r.push(n),n},t?.space)}r.d(t,{GP:()=>function e(t,r){let o=r?.space??0,c=new WeakSet,u=o?"number"==typeof o?" ".repeat(o):o:"",d=(e,t)=>{let r=e?.constructor;return r&&r!==Object.prototype.constructor&&r.name?`${r.name}(${t})`:t};return function t(o,f=0){if(Array.isArray(o)){let e,r;if(c.has(o))return s;if(c.add(o),!u||o.length<=1)return`[${o.map(e=>t(e,f)).join(",")}]`;let n=o.map(e=>t(e,f+1)).join(",\n"+(e=f+1,u.repeat(e)));return`[
123
+ ${r=f+1,u.repeat(r)}${n}
124
+ ${u.repeat(f)}]`}if(o instanceof Date)return l(o);if(!r?.ignoreToString&&n.i5(o,"toString")&&"function"==typeof o.toString&&o.toString!==Object.prototype.toString&&o.toString!==Array.prototype.toString){let e=function(e){try{let t=e.toString();return"string"==typeof t?t:String(t)}catch{return"[toString threw]"}}(o);return o instanceof Error&&o.cause?`${e} (cause: ${t(o.cause,f)})`:e}if("string"==typeof o)return JSON.stringify(o);if("number"==typeof o||null==o||"boolean"==typeof o||"symbol"==typeof o)return String(o);if("bigint"==typeof o)return String(o)+"n";if("object"==typeof o||"function"==typeof o){if(c.has(o))return s;if(c.add(o),i.uC in o)return e((0,i.f6)(o));if(Symbol.iterator in o)return`${o.constructor.name}(${t(Array.from(o),f)})`;let r=(e=>{try{return Reflect.ownKeys(e)}catch{return["[ownKeys threw]"]}})(o);if(!u||r.length<=1){let e=`{${r.map(e=>`${a(e)}:${t(o[e],f)}`).join(",")}}`;return d(o,e)}let n=`{
125
+ ${r.map(e=>{let r;return`${r=f+1,u.repeat(r)}${a(e)}: ${t(o[e],f+1)}`}).join(",\n")}
126
+ ${u.repeat(f)}}`;return d(o,n)}return String(o)}(t,0)},IB:()=>c,Yq:()=>l,_r:()=>a,jV:()=>o})},4650(e,t,r){var n=r(9138);let i=e=>()=>e,s=i(!0),a=i(!1),o=i(null),l=i(void 0);function c(e,...t){return(0,n.tT)(e,t)}function u(e,t,r,n,i,s,a,o,l){switch(arguments.length){case 1:return e;case 2:return function(){return t(e.apply(this,arguments))};case 3:return function(){return r(t(e.apply(this,arguments)))};case 4:return function(){return n(r(t(e.apply(this,arguments))))};case 5:return function(){return i(n(r(t(e.apply(this,arguments)))))};case 6:return function(){return s(i(n(r(t(e.apply(this,arguments))))))};case 7:return function(){return a(s(i(n(r(t(e.apply(this,arguments)))))))};case 8:return function(){return o(a(s(i(n(r(t(e.apply(this,arguments))))))))};case 9:return function(){return l(o(a(s(i(n(r(t(e.apply(this,arguments)))))))))}}}function d(e){let t=new WeakMap;return r=>{if(t.has(r))return t.get(r);let n=e(r);return t.set(r,n),n}}r.d(t,{Bj:()=>d,Fs:()=>c,L3:()=>u},{D_:e=>e,MN:l,XR:o,XY:function(e,t){if("function"==typeof e)return function(){return e(arguments)?t.apply(this,arguments):e=>t(e,...arguments)};switch(e){case 0:case 1:throw RangeError(`Invalid arity ${e}`);case 2:return function(e,r){return arguments.length>=2?t(e,r):function(r){return t(r,e)}};case 3:return function(e,r,n){return arguments.length>=3?t(e,r,n):function(n){return t(n,e,r)}};default:return function(){if(arguments.length>=e)return t.apply(this,arguments);let r=arguments;return function(e){return t(e,...r)}}}},Yi:l,dY:i,f4:a,ue:s})},4450(e,t,r){var n=r(4650),i=r(6516),s=r(5369);let a="~effect/interfaces/Hash",o=e=>{switch(typeof e){case"number":return f(e);case"bigint":return h(e.toString(10));case"boolean":case"symbol":return h(String(e));case"string":return h(e);case"undefined":return h("undefined");case"function":case"object":if(null===e)return h("null");{if(e instanceof Date)return h(e.toISOString());if(e instanceof RegExp)return h(e.toString());if(i.J.has(e))return l(e);if(x.has(e))return x.get(e);let t=function(e,t){if(k.has(e))return h("[Circular]");k.add(e);let r=t();return k.delete(e),r}(e,()=>{if(d(e))return e[a]();if("function"==typeof e)return l(e);if(Array.isArray(e)||ArrayBuffer.isView(e))return y(e);if(e instanceof Map)return b(e);if(e instanceof Set)return v(e);return m(e)});return x.set(e,t),t}default:throw Error(`BUG: unhandled typeof ${typeof e} - please report an issue at https://github.com/Effect-TS/effect/issues`)}},l=e=>(w.has(e)||w.set(e,f(Math.floor(Math.random()*Number.MAX_SAFE_INTEGER))),w.get(e)),c=(0,n.XY)(2,(e,t)=>53*e^t),u=e=>0xbfffffff&e|e>>>1&0x40000000,d=e=>(0,s.i5)(e,a),f=e=>{if(e!=e)return h("NaN");if(e===1/0)return h("Infinity");if(e===-1/0)return h("-Infinity");let t=0|e;for(t!==e&&(t^=0xffffffff*e);e>0xffffffff;)t^=e/=0xffffffff;return u(t)},h=e=>{let t=5381,r=e.length;for(;r;)t=33*t^e.charCodeAt(--r);return u(t)},p=(e,t)=>{let r=12289;for(let n of t)r^=c(o(n),o(e[n]));return u(r)},m=e=>p(e,(0,i.X)(e)),g=(e,t)=>r=>{let n=e;for(let e of r)n^=t(e);return u(n)},y=g(6151,o),b=g(h("Map"),([e,t])=>c(o(e),o(t))),v=g(h("Set"),o),w=new WeakMap,x=new WeakMap,k=new WeakSet;r.d(t,{},{HR:a,QK:m,YO:y,Yj:h,ai:f,kg:c,tW:o,uN:p,yT:l})},6400(e,t,r){var n=r(6470),i=r(5369),s=r(1743);let a=Symbol.for("nodejs.util.inspect.custom"),o=e=>{try{if(i.i5(e,"toJSON")&&i.Tn(e.toJSON)&&0===e.toJSON.length)return e.toJSON();if(Array.isArray(e))return e.map(o)}catch{return"[toJSON threw]"}return(0,s.E$)(e)};r.d(t,{},{FX:a,ZK:(e,t=2)=>{if("string"==typeof e)return e;try{return"object"==typeof e?(0,n.IB)(e,{space:t}):String(e)}catch{return String(e)}},aB:o,os:{toJSON(){return o(this)},[a](){return this.toJSON()},toString(){return(0,n.GP)(this.toJSON())}}})},8496(e,t,r){var n=r(4650),i=r(3833),s=r(5369);let a=(0,n.XY)(2,(e,t)=>{let r=0;for(let n of e){let e=t(n,r);if((0,s.Lm)(e)){if(e)return i.some(n)}else if(i.isSome(e))return e;r++}return i.none()}),o=(0,n.XY)(2,(e,t)=>({[Symbol.iterator](){let r=e[Symbol.iterator](),n=0;return{next(){let e=r.next();for(;!e.done;){if(t(e.value,n++))return{done:!1,value:e.value};e=r.next()}return{done:!0,value:void 0}}}}}));r.d(t,{},{i8:a,pb:o})},5089(e,t,r){var n=r(8619),i=r(3717),s=r(4650),a=r(8433),o=r(1136),l=r(9138),c=r(2672);let u="~effect/Layer/MemoMap",d={"~effect/Layer":{_ROut:s.D_,_E:s.D_,_RIn:s.D_},pipe(){return(0,l.tT)(this,arguments)}},f=e=>{let t=Object.create(d);return t.build=e,t},h=e=>f((t,r)=>{let n=c.Fp(r);return o.cfM(e(t,n),e=>"Failure"===e._tag?c.VN(n,e):o.rIH)});class p{get[u](){return u}parent;constructor(e){this.parent=e}map=new Map;get(e,t){let r=this.map.get(e);if(r)return r.observers++,o.hgn(o.Uio(t,e=>r.finalizer(e)),r.effect);return this.parent?.get(e,t)}getOrElseMemoize(e,t,r){var n;let s,a,l,u=this.get(e,t);return u?u:(n=this,s=c.LZ(),a=i.LZ(),l={observers:1,effect:i.Tx(a),finalizer:t=>o.DYE(()=>(l.observers--,0===l.observers)?(n.map.delete(e),c.VN(s,t)):o.rIH)},n.map.set(e,l),o.Uio(t,l.finalizer).pipe(o.qIB(()=>r(n,s)),o.cfM(e=>(l.effect=e,i.Vw(a,e)))))}}let m=()=>new p;class g extends n.kl()("effect/Layer/CurrentMemoMap"){static forkOrCreate(e){let t=n.Y6(e,g);return t?new p(t):m()}}let y=(0,s.XY)(3,(e,t,r)=>o.PfK(o.TjK(e.build(t,r),n.WQ(g,t)),g,t)),b=(0,s.XY)(2,(e,t)=>a.R6(r=>y(e,g.forkOrCreate(r.context),t))),v=e=>f((0,s.dY)(o.PyW(e))),w=(e,t)=>x(o.TjK(t,t=>n.L8(e,t))),x=e=>{var t;let r;return t=(t,r)=>c.Gt(e,r),r=h((e,n)=>e.getOrElseMemoize(r,n,t))},k=(e,t,r)=>{let i=c.Fp(r,"parallel");return o.jJl(e,e=>e.build(t,c.Fp(i,"sequential")),{concurrency:e.length}).pipe(o.TjK(e=>n.Um(...e)))},S=(e,t,r)=>h((n,i)=>o.qIB(Array.isArray(t)?k(t,n,i):t.build(n,i),t=>e.build(n,i).pipe(o.PpN(t),o.TjK(e=>r(e,t))))),_=(0,s.XY)(2,(e,t)=>S(e,t,s.D_)),O=(0,s.XY)(2,(e,t)=>S(e,t,(e,t)=>n.h1(t,e)));r.d(t,{},{Gt:_,H7:y,LT:b,Py:function(){return 1==arguments.length?e=>v(n.L8(arguments[0],e)):v(n.L8(arguments[0],arguments[1]))},QZ:function(){return 1==arguments.length?e=>w(arguments[0],e):w(arguments[0],arguments[1])},S5:O,Um:(...e)=>h((t,r)=>k(e,t,r)),j6:m})},3833(e,t,r){r.r(t),r.d(t,{Do:()=>eh,all:()=>H,andThen:()=>B,as:()=>F,asVoid:()=>L,bind:()=>ef,bindTo:()=>eu,composeK:()=>q,contains:()=>el,containsWith:()=>eo,exists:()=>ec,filter:()=>er,filterMap:()=>et,firstSomeOf:()=>I,flatMap:()=>U,flatMapNullishOr:()=>Y,flatten:()=>X,fromIterable:()=>v,fromNullOr:()=>C,fromNullishOr:()=>$,fromUndefinedOr:()=>E,gen:()=>ep,getFailure:()=>x,getOrElse:()=>k,getOrNull:()=>T,getOrThrow:()=>j,getOrThrowWith:()=>P,getOrUndefined:()=>N,getSuccess:()=>w,isNone:()=>m,isOption:()=>p,isSome:()=>g,let:()=>ed,lift2:()=>es,liftNullishOr:()=>A,liftPredicate:()=>ea,liftThrowable:()=>M,makeCombinerFailFast:()=>eg,makeEquivalence:()=>en,makeOrder:()=>ei,makeReducer:()=>em,makeReducerFailFast:()=>ey,map:()=>D,match:()=>y,none:()=>f,orElse:()=>S,orElseResult:()=>O,orElseSome:()=>_,partitionMap:()=>ee,product:()=>V,productMany:()=>G,reduceCompact:()=>Q,some:()=>h,tap:()=>K,toArray:()=>Z,toRefinement:()=>b,void:()=>R,zipLeft:()=>J,zipRight:()=>W,zipWith:()=>z});var n=r(8036),i=r(1044),s=r(4650),a=r(2849),o=r(5091),l=r(4403),c=r(6364),u=r(5369);function d(e,t,r){return{combine:e,initialValue:t,combineAll:r??(r=>{let n=t;for(let t of r)n=e(n,t);return n})}}let f=()=>o.dv,h=o.zN,p=o.oL,m=o.$I,g=o.Ru,y=(0,s.XY)(2,(e,{onNone:t,onSome:r})=>m(e)?t():r(e.value)),b=e=>t=>g(e(t)),v=e=>{for(let t of e)return h(t);return f()},w=l.Oz,x=l.L8,k=(0,s.XY)(2,(e,t)=>m(e)?t():e.value),S=(0,s.XY)(2,(e,t)=>m(e)?t():e),_=(0,s.XY)(2,(e,t)=>m(e)?h(t()):e),O=(0,s.XY)(2,(e,t)=>m(e)?D(t(),l.Py):D(e,l.fJ)),I=e=>{let t=f();for(t of e)if(g(t))break;return t},$=e=>null==e?f():h(e),E=e=>void 0===e?f():h(e),C=e=>null===e?f():h(e),A=e=>(...t)=>$(e(...t)),T=k(s.XR),N=k(s.MN),M=e=>(...t)=>{try{return h(e(...t))}catch{return f()}},P=(0,s.XY)(2,(e,t)=>{if(g(e))return e.value;throw t()}),j=P(()=>Error("getOrThrow called on a None")),D=(0,s.XY)(2,(e,t)=>m(e)?f():h(t(e.value))),F=(0,s.XY)(2,(e,t)=>D(e,()=>t)),L=F(void 0),R=h(void 0),U=(0,s.XY)(2,(e,t)=>m(e)?f():t(e.value)),B=(0,s.XY)(2,(e,t)=>U(e,e=>{let r=(0,u.Tn)(t)?t(e):t;return p(r)?r:h(r)})),Y=(0,s.XY)(2,(e,t)=>m(e)?f():$(t(e.value))),X=U(s.D_),W=(0,s.XY)(2,(e,t)=>U(e,()=>t)),J=(0,s.XY)(2,(e,t)=>K(e,()=>t)),q=(0,s.XY)(2,(e,t)=>r=>U(e(r),t)),K=(0,s.XY)(2,(e,t)=>U(e,e=>D(t(e),()=>e))),V=(e,t)=>g(e)&&g(t)?h([e.value,t.value]):f(),G=(e,t)=>{if(m(e))return f();let r=[e.value];for(let e of t){if(m(e))return f();r.push(e.value)}return h(r)},H=e=>{if(Symbol.iterator in e){let t=[];for(let r of e){if(m(r))return f();t.push(r.value)}return h(t)}let t={};for(let r of Object.keys(e)){let n=e[r];if(m(n))return f();t[r]=n.value}return h(t)},z=(0,s.XY)(3,(e,t,r)=>D(V(e,t),([e,t])=>r(e,t))),Q=(0,s.XY)(3,(e,t,r)=>{let n=t;for(let t of e)g(t)&&(n=r(n,t.value));return n}),Z=e=>m(e)?[]:[e.value],ee=(0,s.XY)(2,(e,t)=>{if(m(e))return[f(),f()];let r=t(e.value);return l.N6(r)?[h(r.failure),f()]:[f(),h(r.success)]}),et=(0,s.XY)(2,(e,t)=>{if(m(e))return f();let r=t(e.value);return l.oJ(r)?h(r.success):f()}),er=(0,s.XY)(2,(e,t)=>m(e)?f():t(e.value)?h(e.value):f()),en=e=>i.L8((t,r)=>m(t)?m(r):!m(r)&&e(t.value,r.value)),ei=e=>c.L8((t,r)=>g(t)?g(r)?e(t.value,r.value):1:-1),es=e=>(0,s.XY)(2,(t,r)=>z(t,r,e)),ea=(0,s.XY)(2,(e,t)=>t(e)?h(e):f()),eo=e=>(0,s.XY)(2,(t,r)=>!m(t)&&e(t.value,r)),el=eo(n.jI()),ec=(0,s.XY)(2,(e,t)=>!m(e)&&t(e.value)),eu=a.Jr(D),ed=a.zM(D),ef=a.oI(D,U),eh=h({}),ep=(...e)=>{let t=(1===e.length?e[0]:e[1].bind(e[0]))(),r=t.next();for(;!r.done;){let e=r.value;if(m(e))return e;r=t.next(e.value)}return h(r.value)};function em(e){return d((t,r)=>m(t)?r:m(r)?t:h(e.combine(t.value,r.value)),f())}function eg(e){return{combine:(t,r)=>m(t)||m(r)?f():h(e.combine(t.value,r.value))}}function ey(e){let t=eg(e).combine,r=h(e.initialValue);return d(t,r,e=>{let n=r;for(let r of e)if(m(n=t(n,r)))break;return n})}},6364(e,t,r){var n=r(4650);function i(e){return(t,r)=>t===r?0:e(t,r)}let s=i((e,t)=>globalThis.Number.isNaN(e)&&globalThis.Number.isNaN(t)?0:globalThis.Number.isNaN(e)?-1:globalThis.Number.isNaN(t)?1:e<t?-1:1),a=i((e,t)=>e<t?-1:1),o=(0,n.XY)(2,(e,t)=>i((r,n)=>e(t(r),t(n)))),l=o(s,e=>e.getTime());function c(e){return i((t,r)=>{let n=t.length,i=r.length,a=Math.min(n,i);for(let n=0;n<a;n++){let i=e(t[n],r[n]);if(0!==i)return i}return s(n,i)})}function u(e){let t=Object.keys(e);return i((r,n)=>{for(let i of t){let t=e[i](r[i],n[i]);if(0!==t)return t}return 0})}let d=e=>(0,n.XY)(2,(t,r)=>-1===e(t,r)),f=e=>(0,n.XY)(2,(t,r)=>1===e(t,r)),h=e=>(0,n.XY)(2,(t,r)=>t===r||1>e(t,r)?t:r),p=e=>(0,n.XY)(2,(t,r)=>t===r||e(t,r)>-1?t:r);r.d(t,{L8:()=>i,O3:()=>c,_k:()=>u},{Bt:e=>(0,n.XY)(2,(t,r)=>!d(e)(t,r.minimum)&&!f(e)(t,r.maximum)),OW:e=>(0,n.XY)(2,(t,r)=>-1!==e(t,r)),Qw:a,T9:p,bi:e=>(0,n.XY)(2,(t,r)=>1!==e(t,r)),hl:d,jk:h,n9:l,qE:e=>(0,n.XY)(2,(t,r)=>h(e)(r.maximum,p(e)(r.minimum,t))),wN:s,yJ:f,zQ:o})},9138(e,t,r){let n=(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 e=0,n=t.length;e<n;e++)r=t[e](r);return r}}},i={pipe(){return n(this,arguments)}},s=function(){function e(){}return e.prototype=i,e}();r.d(t,{},{Xs:s,tT:n})},5369(e,t,r){var n=r(4650);function i(e){return"string"==typeof e}function s(e){return"number"==typeof e}function a(e){return"boolean"==typeof e}function o(e){return"bigint"==typeof e}function l(e){return"symbol"==typeof e}function c(e){return i(e)||s(e)||l(e)}function u(e){return"function"==typeof e}function d(e){return void 0===e}function f(e){return void 0!==e}function h(e){return null!==e}function p(e){return null==e}function m(e){return null!=e}function g(e){return!1}function y(e){return!0}function b(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function v(e){return"object"==typeof e&&null!==e||u(e)}let w=(0,n.XY)(2,(e,t)=>v(e)&&t in e),x=(0,n.XY)(2,(e,t)=>w(e,"_tag")&&e._tag===t);function k(e){return e instanceof Error}function S(e){return e instanceof Date}function _(e){return w(e,Symbol.iterator)||i(e)}function O(e){return e instanceof RegExp}r.d(t,{$P:()=>S,Bm:()=>l,EA:()=>f,Et:()=>s,Fw:()=>v,Gv:()=>b,Kg:()=>i,Lm:()=>a,Pd:()=>g,Pe:()=>h,Tn:()=>u,Vq:()=>m,b0:()=>d,bJ:()=>k,gd:()=>O,hL:()=>c,sI:()=>o,t8:()=>y,uy:()=>p,xZ:()=>_},{$J:x,i5:w})},4505(e,t,r){var n=r(8543),i=r(7598),s=r(956),a=r(4650),o=r(1136),l=r(995);let c=(0,a.XY)(2,(e,t)=>o.rNk(e,f,e=>t(e))),u=e=>"Fail"===e._tag&&n.$L(e.error),d=s.Bh(n.kh,e=>n.$L(e)?l.Py(e):l.fJ(e));n.kh;let f=s.Bh(n.kh,e=>n.$L(e)?l.Py(e.value):l.fJ(e)),h=(0,a.XY)(2,(e,t)=>o.khu(e,{onSuccess:t.onSuccess,onFailure:e=>{let r=d(e);return l.N6(r)?t.onFailure(r.failure):t.onDone(r.success.value)}}));r.d(t,{},{Og:e=>e.reasons.some(u),aU:e=>{let t=d(e);return l.N6(t)?i.AT(t.failure):i.Py(t.success.value)},m8:c,tv:h})},8099(e,t,r){var n=r(4650);let i=(0,n.XY)(2,(e,t)=>{let r=[];for(let n of o(e))r.push(t(n,e[n]));return r})((e,t)=>[e,t]),s=(0,n.XY)(2,(e,t)=>{let r={...e};for(let n of o(e))r[n]=t(e[n],n);return r}),a=(0,n.XY)(2,(e,t)=>{let r={};for(let n of o(e))t(e[n],n)&&(r[n]=e[n]);return r}),o=e=>Object.keys(e);r.d(t,{},{DM:e=>0===Object.keys(e).length,Tj:s,Wo:i,pb:a})},1743(e,t,r){var n=r(9138),i=r(5369);let s=Symbol.for("~effect/Redactable");function a(e){return(0,i.i5)(e,s)?o(e):e}function o(e){return e[s](globalThis[l]?.context??c)}let l="~effect/Fiber/currentFiber",c={"~effect/Context":{},mapUnsafe:new Map,pipe(){return(0,n.tT)(this,arguments)}};r.d(t,{E$:()=>a,f6:()=>o},{fL:l,uC:s})},3864(e,t,r){var n=r(1136),i=r(8344);i.F8;let s=i.iL;i.Gl,i.d8,i.vA;let a=i.zQ;i.rf,i.ce,i.ls,i.nU,i.aG,n.d$_,n.olX,r.d(t,{},{iL:s,zQ:a})},995(e,t,r){var n=r(4650),i=r(5091),s=r(4403);let a=s.Py,o=s.fJ;s.sV,s.aI;let l=s.N6,c=s.oJ;s.Oz,s.L8;let u=(0,n.XY)(2,(e,t)=>l(e)?o(t(e.failure)):a(e.success)),d=(0,n.XY)(2,(e,t)=>c(e)?a(t(e.success)):o(e.failure)),f=(0,n.XY)(2,(e,{onFailure:t,onSuccess:r})=>l(e)?t(e.failure):r(e.success));i.dv,r.d(t,{},{N6:l,Py:a,Tj:d,YW:f,fJ:o,oJ:c,xm:u})},3587(e,t,r){var n=r(8543),i=r(8619),s=r(2302),a=r(4650),o=r(8433),l=r(1136),c=r(9138),u=r(5369),d=r(4505);let f="~effect/Schedule",h=i.Or("effect/Schedule/CurrentMetadata",{defaultValue:(0,a.dY)({input:void 0,output:void 0,duration:s.v_,attempt:0,start:0,now:0,elapsed:0,elapsedSincePrevious:0})}),p={[f]:{_Out:a.D_,_In:a.D_,_Env:a.D_},pipe(){return(0,c.tT)(this,arguments)}},m=e=>{let t=Object.create(p);return t.step=e,t},g=()=>{let e,t,r=0;return(n,i)=>{void 0===t&&(t=n);let s=n-t,a=void 0===e?0:n-e;return e=n,{input:i,attempt:++r,start:t,now:n,elapsed:s,elapsedSincePrevious:a}}},y=e=>l.Tyx(e.step,e=>l.PyW(()=>l.ATB(e))),b=e=>{let t,r=s.bN(e);return t=l.PyW(e=>l.PyW([e.attempt-1,r])),m(l.TjK(t,e=>{let t=g();return(r,n)=>e(t(r,n))}))},v=(0,a.XY)(2,(e,t)=>{let r=void 0===t.duration?void 0:s.bN(t.duration);return w(e,({attempt:e,elapsed:n})=>l.PyW((void 0===t.times||e<=t.times)&&(void 0===r||s.bi(s.ne(n),r))))}),w=(0,a.XY)(2,(e,t)=>m(l.TjK(y(e),e=>{let r=g();return(i,s)=>l.qIB(e(i,s),e=>{let[a,c]=e,u=t({...r(i,s),output:a,duration:c});return l.qIB((0,o.yw)(u)?u:l.PyW(u),t=>t?l.PyW(e):n.Vw(a))})}))),x=b(s.v_);r.d(t,{},{E6:w,GM:e=>(0,u.i5)(e,f),d3:h,i4:x,jB:v,ji:b,le:e=>m(l.TjK(y(e),e=>(t,r)=>d.tv(e(t,r),{onSuccess:e=>l.PyW([r,e[1]]),onFailure:l.ATB,onDone:()=>n.Vw(r)}))),t5:e=>w(x,({attempt:t})=>l.PyW(t<=e)),xn:e=>l.RKA(t=>l.TjK(y(e),e=>{let r=g();return n=>l.DYE(()=>{let i=t.currentTimeMillisUnsafe();return l.qIB(e(i,n),([e,t])=>{let s=r(i,n);return s.output=e,s.duration=t,l.as(l.yy4(t),s)})})}))})},8469(e,t,r){var n=r(8619);let i=n.Or("effect/Scheduler",{defaultValue:()=>new o}),s="setImmediate"in globalThis?e=>{let t=globalThis.setImmediate(e);return()=>globalThis.clearImmediate(t)}:e=>{let t=setTimeout(e,0);return()=>clearTimeout(t)};class a{buckets=[];scheduleTask(e,t){let r,n=this.buckets,i=n.length,s=0;for(;s<i&&!(n[s][0]>t);s++)r=n[s];r&&r[0]===t?r[1].push(e):s===i?n.push([t,[e]]):n.splice(s,0,[t,[e]])}drain(){let e=this.buckets;return this.buckets=[],e}}class o{executionMode;setImmediate;constructor(e="async",t=s){this.executionMode=e,this.setImmediate=t}shouldYield(e){return e.currentOpCount>=e.maxOpsBeforeYield}makeDispatcher(){return new l(this.setImmediate)}}class l{tasks=new a;running=void 0;setImmediate;constructor(e=s){this.setImmediate=e}scheduleTask(e,t){this.tasks.scheduleTask(e,t),void 0===this.running&&(this.running=this.setImmediate(this.afterScheduled))}afterScheduled=()=>{this.running=void 0,this.runTasks()};runTasks(){let e=this.tasks.drain();for(let t=0;t<e.length;t++){let r=e[t][1];for(let e=0;e<r.length;e++)r[e]()}}flush(){for(;this.tasks.buckets.length>0;)void 0!==this.running&&(this.running(),this.running=void 0),this.runTasks()}}let c=n.Or("effect/Scheduler/MaxOpsBeforeYield",{defaultValue:()=>2048}),u=n.Or("effect/Scheduler/PreventSchedulerYield",{defaultValue:()=>!1});r.d(t,{FG:()=>o},{Zm:c,_F:i,hf:u})},8861(e,t,r){let n,i,s,a;r.d(t,{O31:()=>e_,v8c:()=>ev,Xsx:()=>e1,Nej:()=>eq,kld:()=>eX,PSP:()=>e2,wYs:()=>eK,Aiz:()=>eV,uSQ:()=>ep,xCb:()=>function e(t){let r=t.map(ep);return ea(I.KC(r,"anyOf",void 0),{literals:t,members:r,mapMembers(e){return eI(e(this.members))},pick:t=>e(t),transform:e=>eI(r.map((t,r)=>t.transform(e[r])))})},ukk:()=>eB,wNn:()=>eb,pHd:()=>eG,mSG:()=>eS,QfV:()=>ey,_kM:()=>ek,X0d:()=>e3,gPz:()=>eI,$r1:()=>em,rvE:()=>Q,usV:()=>Z,hzj:()=>z,GLL:()=>eA,_Re:()=>en,q$Z:()=>ei,svK:()=>es,is:()=>er,MIs:()=>eF,yJO:()=>eL,OWK:()=>eR,tJb:()=>eU,Pto:()=>eD,nfo:()=>eP,HNH:()=>ej,fXn:()=>eO,Wa3:()=>ec,lqM:()=>el,Qrq:()=>eo,YPB:()=>eC,DYE:()=>eE,TcI:()=>eM,lHk:()=>e6,O3D:()=>ed,_oz:()=>e5,rcy:()=>et,AxX:()=>eu,tiU:()=>eN});var o,l,c,u,d,f,h=r(631),p=r(8543),m=r(2718),g=r(4705),y=r(2302),b=r(7720),v=(r(8983),r(7598)),w=r(6470),x=r(8433),k=r(8927),S=r(8036),_=r(5369),O=r(8099);_.gd;var I=r(9177),$=r(4888),E=r(9138);let C="~effect/SchemaError/SchemaError";class A extends m.rN("SchemaError"){[C]=C;constructor(e){super({issue:e})}get message(){return this.issue.toString()}toString(){return`SchemaError(${this.message})`}}var T=r(4858);let N="~effect/Schema/Schema",M={[N]:N,pipe(){return E.tT(this,arguments)},annotate(e){return this.rebuild(I.fz(this.ast,e))},annotateKey(e){return this.rebuild(I.us(this.ast,e))},check(...e){return this.rebuild(I.EJ(this.ast,e))}};function P(e,t){let r=Object.create(M);t&&Object.assign(r,t),r.ast=e,r.rebuild=e=>P(e,t);let n=T.o(r);return r.makeEffect=(e,t)=>j(n(e,t)),r.make=T.L8(r),r.makeOption=T.YY(r),r}function j(e){return b.Tyx(e,e=>b.pVV(()=>p.Tj(e,e=>new A(e))))}let D=F(function(e){switch(e._tag){case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}});function F(e){return t=>{let r=new Map;for(let e=0;e<t.length;e++)r.set(I.O3(t[e]),e);let n=[...t].sort((t,n)=>{t=I.O3(t),n=I.O3(n);let i=e(t),s=e(n);return i!==s?i-s:r.get(t)-r.get(n)});return n.some((e,r)=>e!==t[r])?n:t}}let L=new Set(["~structural","~sentinels","meta","arbitrary","toArbitrary","toEquivalence","toFormatter","toCodec","toCodecJson","toCodecIso",I.YA]),R=new Set(["title","description","default","examples","readOnly","writeOnly","format","contentEncoding","contentMediaType","contentSchema"]);function U(e){if(void 0!==e){let t=O.pb(e,(e,t)=>!L.has(t));if(!O.DM(t))return{annotations:t}}}function B(e,t){return e.some(e=>{switch(e._tag){case"Filter":return e.meta._tag===t;case"FilterGroup":return B(e.checks,t)}})}function Y(e,t){if(0===Object.keys(e).length)return t;let r=Object.keys(t).length;if(0===r)return e;let n=Array.isArray(t.allOf)&&1===r?t.allOf:[t];return Array.isArray(e.allOf)?{...e,allOf:[...e.allOf,...n]}:"string"==typeof e.$ref?{allOf:[e,...n]}:{...e,allOf:n}}function X(e){switch(e._tag){case"Literal":return globalThis.String(e.literal).replace(/[/\\^$*+?.()|[\]{}]/g,"\\$&");case"String":return I.XV;case"Number":return I.bm;case"TemplateLiteral":return e.parts.map(X).join("");case"Union":return e.types.map(X).join("|");default:throw new globalThis.Error("Unsupported part",{cause:e})}}var W=r(3833),J=r(6364),q=r(995),K=r(8469),V=r(6310),G=r(6030),H=r(5348);function z(){return(e,t,r)=>ea(new I.D6(e.map(I.hu),e=>t(e.map(e=>ea(e))),r))}r(1044)._k,J._k;function Q(e){return t=>eh(eh(t).annotate(e))}function Z(e){return t=>t.rebuild(I.us(t.ast,e))}function ee(e){return v.oJ(e)?e.value:{issues:[{message:p.j9(e.cause)}]}}function et(e,t){let r=T._R(e),n={errors:"all",...t?.parseOptions},i=G.ID(t),s=e=>{let t=new K.FG,s=b.MY7(b.YWq(r(e,n),{onFailure:i,onSuccess:e=>({value:e})}),{scheduler:t});s.currentDispatcher?.flush();let a=s.pollUnsafe();return a?ee(a):new Promise(e=>{s.addObserver(t=>{e(ee(t))})})};return"~standard"in e?("validate"in e["~standard"]||Object.assign(e["~standard"],{validate:s}),e):Object.assign(e,{"~standard":{version:1,vendor:"effect",validate:s}})}let er=T.is;function en(e,t){let r=T._R(e,t);return(e,t)=>j(r(e,t))}function ei(e,t){let r=T.q$(e,t);return(e,t)=>q.xm(r(e,t),e=>new A(e))}function es(e,t){let r=en(e,t);return(e,t)=>(function(e){let t=b.lKS(e);if(v.oJ(t))return t.value;throw function(e,t){let r;for(let i of e.reasons){var n;if(!p.lC(i)||(n=i.error,!_.i5(n,C)))throw new globalThis.Error(t,{cause:e});r??=i.error}if(void 0===r)throw new globalThis.Error(t,{cause:e});return r}(t.cause,"Sync adapter can only throw schema errors")})(r(e,t))}T.kv,T.y9,T.mR,T.IQ,T.GP;let ea=P,eo=e=>ea(I.Qr(e.ast),{schema:e}),el=e=>eo(e$(e)),ec=e=>ea(I.W(e.ast),{schema:e}),eu=e=>ea(I.Ax(e.ast),{schema:e}),ed=e=>ea(I.O3(e.ast),{schema:e}),ef="~effect/Schema/flip";function eh(e){return _.i5(e,ef)&&e[ef]===ef?e.schema.rebuild(I.UU(e.ast)):ea(I.UU(e.ast),{[ef]:ef,schema:e})}function ep(e){let t=ea(new I.uS(e),{literal:e,transform:r=>t.pipe(eA(ep(r),{decode:V.pd(()=>r),encode:V.pd(()=>e)}))});return t}I.Zm,I.bz;let em=ea(I.L5);I.ch;let eg=ea(I.Vx),ey=ea(I.Yj),eb=ea(I.ai),ev=ea(I.zM),ew=ea(I.HR);function ex(e,t){return ea(e,{fields:t,mapFields(e,t){let r=e(this.fields);return ex(I.w3(r,t?.unsafePreserveChecks?this.ast.checks:void 0),r)}})}function ek(e){return ex(I.w3(e,void 0),e)}function eS(e,t,r){let n=r?.keyValueCombiner?.decode||r?.keyValueCombiner?.encode?new I.E$(r.keyValueCombiner.decode,r.keyValueCombiner.encode):void 0;return ea(I.g1(e.ast,t.ast,n),{key:e,value:t})}I.we,I.rI,I.ZG;let e_=e=>ea(new I.DO(!1,[],[e.ast]),{value:e}),eO=e=>ea(new I.DO(!0,e.ast.elements,e.ast.rest),{schema:e});function eI(e,t){return function e(t,r){return ea(t,{members:r,mapMembers(t,r){let n=t(this.members);return e(I.KC(n,this.ast.mode,r?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}(I.KC(e,t?.mode??"anyOf",void 0),e)}let e$=e=>eI([e,eg]);function eE(e){return ea(new I.V3(()=>e().ast))}function eC(e,t){return r=>ea(I.EJ(r.ast,[I.D$(e,t)]),{schema:r})}function eA(e,t){return r=>ea(I.GL(r.ast,e.ast,t?H.L8(t):H.le()),{from:r,to:e})}function eT(e){return b.Tyx(e,e=>b.pVV(()=>p.Tj(e,e=>e.issue)))}function eN(e,t){let r=t?.encodingStrategy==="omit"?V.cJ():V.le();return t=>el(ed(t)).pipe(eA(t,{decode:V.IQ(eT(e)),encode:r}))}function eM(e){var t;return ep(e).pipe((t=b.PyW(e),e=>ea(I.Ez(e.ast,eT(t)),{schema:e})))}function eP(){return(e,t)=>new I.N_(e.ast,H.L8(t))}let ej=I.HN,eD=I.Pt;function eF(e){return ej(e=>globalThis.Number.isFinite(e),{expected:"a finite number",meta:{_tag:"isFinite"},arbitrary:{constraint:{noInfinity:!0,noNaN:!0}},...e})}I.bk,I.ZB,I.IZ;let eL=(f={order:J.wN,annotate:e=>({meta:{_tag:"isGreaterThan",exclusiveMinimum:e}})},n=J.yJ(f.order),i=f.formatter??w.GP,(e,t)=>ej(t=>n(t,e),{expected:`a value greater than ${i(e)}`,arbitrary:{constraint:{ordered:{order:f.order,minimum:e,exclusiveMinimum:!0}}},...f.annotate?.(e),...t})),eR=(o={order:J.wN,annotate:e=>({meta:{_tag:"isGreaterThanOrEqualTo",minimum:e}})},s=J.OW(o.order),a=o.formatter??w.GP,(e,t)=>ej(t=>s(t,e),{expected:`a value greater than or equal to ${a(e)}`,arbitrary:{constraint:{ordered:{order:o.order,minimum:e}}},...o.annotate?.(e),...t}));function eU(e,t){return e=Math.max(0,Math.floor(e)),ej(t=>t.length>=e,{expected:`a value with a length of at least ${e}`,meta:{_tag:"isMinLength",minLength:e},[I.C3]:!0,arbitrary:{constraint:{minLength:e}},...t})}J.wN,J.wN,J.wN,J.n9,J.n9,J.n9,J.n9,J.n9,J.Qw,J.Qw,J.Qw,J.Qw,J.Qw,h.pH,h.pH,h.pH,h.pH,h.pH;let eB=ey.check(eU(1,void 0)),eY=[];function eX(e){let t=e?.includeStack===!0|2*(e?.excludeCause===!0),r=eY[t];if(void 0!==r)return r;let n=tt.pipe(eA(em,H.sm((e=>{switch(e){case 0:return;case 1:return{includeStack:!0};case 2:return{excludeCause:!0};case 3:return{includeStack:!0,excludeCause:!0}}})(t))));return eY[t]=n,n}H.nY;let eW=ey.annotate({expected:"a string in ISO 8601 format that will be decoded as a Date"}),eJ=(l=globalThis.Date,c={typeConstructor:{_tag:"Date"},generation:{runtime:"Schema.Date",Type:"globalThis.Date"},expected:"Date",toCodecJson:()=>eP()(eW,H.YZ),toArbitrary:()=>(e,t)=>e.date(function(e,t){let r={...void 0};if(delete r.valid,e?.valid&&(r.noInvalidDate=!0),t?.minimum!==void 0){let e=(0,t.minimum),n=t.exclusiveMinimum?new globalThis.Date(e.getTime()+1):e;(void 0===r.min||n.getTime()>r.min.getTime())&&(r.min=n)}if(t?.maximum!==void 0){let e=(0,t.maximum),n=t.exclusiveMaximum?new globalThis.Date(e.getTime()-1):e;(void 0===r.max||n.getTime()<r.max.getTime())&&(r.max=n)}return r}(t?.constraint,t?.constraint?.ordered?.order===J.n9?t.constraint.ordered:void 0))},u=e=>e instanceof l,d=c,z()([],()=>(e,t)=>u(e)?b.PyW(e):b.fJG(new G.eE(t,W.some(e))),d));H.YZ,H.HO;let eq=eJ.check(ej(e=>!isNaN(e.getTime()),{expected:"a valid date",meta:{_tag:"isDateValid"},arbitrary:{constraint:{valid:!0}},...void 0}));y.n$,H.EJ,H.m8,H.PE;h.s5,H.dG;let eK=eb.check(eF()),eV=eb.check(ej(e=>globalThis.Number.isSafeInteger(e),{expected:"an integer",meta:{_tag:"isInt"},arbitrary:{constraint:{integer:!0}},...void 0}));H.ZK,H.ZK,H.R7,H.Ct,H.LL,H.Y5,H.Pp;let eG=eI([eK,ew,ey]);H.U0,g.yF,H.Nh,g.Xy,g.lU,g.rg,H.yd,g.kQ,H.XU,H.d9;let eH=globalThis.Symbol.for("immer-draftable"),ez={};function eQ(e,t,r,n,i){var s,a,o;let l,c=(s=r,a=t,o=n,e=>{if(void 0!==l)return l;let t=new H.IT(V.pd(t=>new e(t)),V.le());return l=eA(ea(new I.D6([s.ast],()=>(t,r)=>t instanceof e||_.i5(t,eZ(a))?b.PyW(t):b.fJG(new G.eE(r,W.some(t))),{identifier:a,[I.YA]:([e])=>new I.N_(e,t),toCodec:([e])=>new I.N_(e.ast,t),toArbitrary:([t])=>()=>({arbitrary:t.arbitrary.map(t=>new e(t)),terminal:t.terminal?.map(t=>new e(t))}),toFormatter:([t])=>r=>`${e.identifier}(${t(r)})`,"~sentinels":I.SL(s.ast),...o})),t)(s)}),u=eZ(t),d=class extends e{constructor(...[e,t]){let n=t?.["~payload"],i=n?.token===ez?n.value:r.make(e??{},t);super(i,{...t,disableChecks:!0,"~payload":{token:ez,value:i}})}static [N]=N;get[u](){return u}static [eH]=!0;static identifier=t;static fields=r.fields;static get ast(){return c(this).ast}static pipe(){return E.tT(this,arguments)}static rebuild(e){return c(this).rebuild(e)}static make(e,t){return new this(e,t)}static makeOption(e,t){return T.YY(c(this))(e??{},t)}static makeEffect(e,t){return c(this).makeEffect(e??{},t)}static annotate(e){return this.rebuild(I.fz(this.ast,e))}static annotateKey(e){return this.rebuild(I.us(this.ast,e))}static check(...e){return this.rebuild(I.EJ(this.ast,e))}static extend(e){return(t,n)=>{let s=e0(t)?t:ek(t),a={...r.fields,...s.fields},o=I.w3(a,r.ast.checks,{identifier:e});return eQ(this,e,ex(I.EJ(o,s.ast.checks),a),n,i)}}static mapFields(e,t){return r.mapFields(e,t)}};return void 0!==i&&Object.assign(d.prototype,i(t)),d}function eZ(e){return`~effect/Schema/Class/${e}`}function e0(e){return _.i5(e,N)&&e[N]===N}let e1=e=>(t,r)=>{let n=e0(t)?t:ek(t);return eQ(m.Xs,e,n,r,e=>({toString(){return`${e}(${(0,w.GP)({...this})})`}}))},e2=e=>(t,r)=>{let n=e0(t)?t:ek(t);return eQ(x.$D,e,n,r,e=>({name:e}))},e3=e=>(t,r,n)=>{let i=e0(r)?r.mapFields(e=>({_tag:eM(t),...e}),{unsafePreserveChecks:!0}):ek({_tag:eM(t),...r});return e2(e??t)(i,n)};function e5(e,t){let r=function(e,t){let{definitions:r,dialect:n,schemas:i}=function(e,t){let r=t?.generateDescriptions??!1,n=t?.additionalProperties??!1,i=t?.includeAnnotationKey,s=O.Tj(e.references,e=>a(e));return{dialect:"draft-2020-12",schemas:k.Tj(e.representations,e=>a(e)),definitions:s};function a(t){let r=function(t){switch(t._tag){case"Any":case"Unknown":return{};case"ObjectKeyword":return{anyOf:[{type:"object"},{type:"array"}]};case"Void":case"Undefined":case"Null":return{type:"null"};case"BigInt":return{type:"string",allOf:[{pattern:"^-?\\d+$"}]};case"Symbol":case"UniqueSymbol":return{type:"string",allOf:[{pattern:"^Symbol\\((.*)\\)$"}]};case"Declaration":return a(t.encodedSchema);case"Suspend":return a(t.thunk);case"Reference":return{$ref:`#/$defs/${t.$ref.replace(/~/g,"~0").replace(/\//g,"~1")}`};case"Never":return{not:{}};case"String":{let e={type:"string"};return void 0!==t.contentMediaType&&(e.contentMediaType=t.contentMediaType),void 0!==t.contentSchema&&(e.contentSchema=a(t.contentSchema)),e}case"Number":return B(t.checks,"isInt")?{type:"integer"}:B(t.checks,"isFinite")?{type:"number"}:{anyOf:[{type:"number"},{type:"string",enum:["NaN"]},{type:"string",enum:["Infinity"]},{type:"string",enum:["-Infinity"]}]};case"Boolean":return{type:"boolean"};case"Literal":{let e=t.literal;if("string"==typeof e)return{type:"string",enum:[e]};if("number"==typeof e)return{type:"number",enum:[e]};if("boolean"==typeof e)return{type:"boolean",enum:[e]};return{type:"string",enum:[String(e)]}}case"Enum":return a({_tag:"Union",types:t.enums.map(([e,t])=>({_tag:"Literal",literal:t,annotations:{title:e}})),mode:"anyOf",annotations:t.annotations});case"TemplateLiteral":{let e=t.parts.map(X).join("");return{type:"string",pattern:`^${e}$`}}case"Arrays":{if(t.rest.length>1)throw new globalThis.Error("Generating a JSON Schema for post-rest elements is not supported");let e={type:"array"},r=t.elements.length,n=t.elements.map(e=>{e.isOptional&&r--;let t=a(e.type),n=o(e.annotations);return n?Y(t,n):t});if(n.length>0?(e.prefixItems=n,e.maxItems=t.elements.length,r>0&&(e.minItems=r)):e.items=!1,t.rest.length>0){delete e.maxItems;let r=a(t.rest[0]);Object.keys(r).length>0?e.items=r:delete e.items}return e}case"Objects":{if(0===t.propertySignatures.length&&0===t.indexSignatures.length)return{anyOf:[{type:"object"},{type:"array"}]};let r={type:"object"},i={},s=[];for(let e of t.propertySignatures){let t=e.name;if("string"!=typeof t)throw new globalThis.Error(`Unsupported property signature name: ${(0,w.GP)(t)}`);let r=a(e.type),n=o(e.annotations);i[t]=n?Y(r,n):r,e.isOptional||s.push(t)}Object.keys(i).length>0&&(r.properties=i),s.length>0&&(r.required=s),r.additionalProperties=n;let l={};for(let n of t.indexSignatures){let t=a(n.type);1===Object.keys(t).length&&"not"in t&&(t=!1);let i=function t(r){switch(r._tag){default:throw new globalThis.Error(`Unsupported index signature parameter: ${r._tag}`);case"Reference":return t(e.references[r.$ref]);case"String":return function e(t){return t.flatMap(t=>{switch(t._tag){case"Filter":if("regExp"in t.meta)return[t.meta.regExp.source];return[];case"FilterGroup":return e(t.checks)}})}(r.checks);case"TemplateLiteral":return[`^${r.parts.map(X).join("")}$`];case"Union":return r.types.flatMap(t)}}(n.parameter);if(i.length>0)for(let e of i)l[e]=t;else r.additionalProperties=t}return Object.keys(l).length>0&&(r.patternProperties=l,delete r.additionalProperties),_.Gv(r.additionalProperties)&&O.DM(r.additionalProperties)&&delete r.additionalProperties,r}case"Union":{let e=t.types.map(a);if(0===e.length)return{not:{}};if(e.length>1){let t=function(e){let t,r=[];for(let n of e){if(2!==Object.keys(n).length||void 0===n.type||!Array.isArray(n.enum)||0===n.enum.length)return;if(void 0===t)t=n.type;else if(n.type!==t)return;for(let e of n.enum)r.push(e)}return{type:t,enum:r}}(e);if(t)return t}return"anyOf"===t.mode?{anyOf:e}:{oneOf:e}}}}(t);if("annotations"in t){let e=o(t.annotations);e&&(r={...r,...e})}if("checks"in t){var i,s;for(let e of(i=t.checks,s=r.type,i.map(function e(t){switch(t._tag){case"Filter":var r=t,n=s;let i=r.meta;if(!i)return;let l=function(e){switch(e._tag){case"isMinLength":return"array"===n?{minItems:e.minLength}:{minLength:e.minLength};case"isMaxLength":return"array"===n?{maxItems:e.maxLength}:{maxLength:e.maxLength};case"isLengthBetween":return"array"===n?{allOf:[{minItems:e.minimum},{maxItems:e.maximum}]}:{allOf:[{minLength:e.minimum},{maxLength:e.maximum}]};case"isPattern":case"isGUID":case"isULID":case"isBase64":case"isBase64Url":case"isStartsWith":case"isEndsWith":case"isIncludes":case"isUppercased":case"isLowercased":case"isCapitalized":case"isUncapitalized":case"isTrimmed":case"isStringFinite":case"isStringBigInt":case"isStringSymbol":return{pattern:e.regExp.source};case"isUUID":return{pattern:e.regExp.source,format:"uuid"};case"isFinite":case"isInt":return;case"isMultipleOf":return{multipleOf:e.divisor};case"isGreaterThanOrEqualTo":return{minimum:e.minimum};case"isLessThanOrEqualTo":return{maximum:e.maximum};case"isGreaterThan":return{exclusiveMinimum:e.exclusiveMinimum};case"isLessThan":return{exclusiveMaximum:e.exclusiveMaximum};case"isBetween":return{[e.exclusiveMinimum?"exclusiveMinimum":"minimum"]:e.minimum,[e.exclusiveMaximum?"exclusiveMaximum":"maximum"]:e.maximum};case"isUnique":return{uniqueItems:!0};case"isMinProperties":return{minProperties:e.minProperties};case"isMaxProperties":return{maxProperties:e.maxProperties};case"isPropertiesLengthBetween":return{minProperties:e.minimum,maxProperties:e.maximum};case"isPropertyNames":return{propertyNames:a(e.propertyNames)};case"isDateValid":return{format:"date-time"}}}(i),c=o(r.annotations);return c&&(l={...l,...c}),l;case"FilterGroup":{let r=t.checks.map(e).filter(e=>void 0!==e);if(0===r.length)return;let n={allOf:r},i=o(t.annotations);return i&&(n={...n,...i}),n}}}).filter(e=>void 0!==e)))r=Y(r,e)}return r}function o(e){if(void 0===e)return;let t={};if("string"==typeof e.title&&(t.title=e.title),"string"==typeof e.description?t.description=e.description:r&&"string"==typeof e.expected&&(t.description=e.expected),void 0!==e.default&&(t.default=e.default),Array.isArray(e.examples)&&(t.examples=e.examples),"boolean"==typeof e.readOnly&&(t.readOnly=e.readOnly),"boolean"==typeof e.writeOnly&&(t.writeOnly=e.writeOnly),"string"==typeof e.format&&(t.format=e.format),"string"==typeof e.contentEncoding&&(t.contentEncoding=e.contentEncoding),"string"==typeof e.contentMediaType&&(t.contentMediaType=e.contentMediaType),i)for(let[r,n]of Object.entries(e))!(void 0===n||R.has(r))&&i(r)&&(t[r]=n);if(Object.keys(t).length>0)return t}}({representations:[e.representation],references:e.references},t);return{dialect:n,schema:i[0],definitions:r}}(function(e){let{references:t,representations:r}=function(e){let t={},r=new Map,n=new Set,i=new Set;return{representations:k.Tj(e,e=>a(e)),references:t};function s(e){let t=e,r=0;for(;n.has(t);)t=`${e}${++r}`;return n.add(t),t}function a(e,n){let l=r.get(e);if(void 0!==l)return{_tag:"Reference",$ref:l};let c=I.S5(e),u=$.KE(e)??n;if(e!==c)return a(c,u);if(void 0!==u){let n=s(u);r.set(e,n);let i=o(e),a=t[u];return void 0!==a&&S.aI(i,a)?(r.set(e,u),{_tag:"Reference",$ref:u}):(t[n]=i,{_tag:"Reference",$ref:n})}if(i.has(e)){let t=s(`${e._tag}_`);return r.set(e,t),{_tag:"Reference",$ref:t}}i.add(e);let d=o(e);i.delete(e);let f=r.get(e);return void 0!==f?(t[f]=d,{_tag:"Reference",$ref:f}):d}function o(e){let t=U(e.annotations);switch(e._tag){case"Declaration":{let r,n=a((r=e.annotations?.toCodecJson??e.annotations?.toCodec,_.Tn(r)?I.ES(e,[r(e.typeParameters.map(e=>P(I.O3(e))))]):I.ch));return{_tag:"Declaration",typeParameters:e.typeParameters.map(e=>a(e)),encodedSchema:n,checks:l(e.checks),...t}}case"Null":case"Undefined":case"Void":case"Never":case"Unknown":case"Any":case"Boolean":case"Symbol":case"ObjectKeyword":return{_tag:e._tag,...t};case"String":{let r=e.annotations?.contentMediaType,n=e.annotations?.contentSchema;return{_tag:e._tag,checks:l(e.checks),...t,..."string"==typeof r&&I.zm(n)?{contentSchema:a(n)}:void 0}}case"Number":case"BigInt":return{_tag:e._tag,checks:l(e.checks),...t};case"Literal":return{_tag:e._tag,literal:e.literal,...t};case"UniqueSymbol":return{_tag:e._tag,symbol:e.symbol,...t};case"Enum":return{_tag:e._tag,enums:e.enums,...t};case"TemplateLiteral":return{_tag:e._tag,parts:e.parts.map(e=>a(e)),...t};case"Arrays":return{_tag:e._tag,elements:e.elements.map(e=>{let t=I.S5(e);return{isOptional:I.dK(t),type:a(e),...U(t.context?.annotations)}}),rest:e.rest.map(e=>a(e)),checks:l(e.checks),...t};case"Objects":return{_tag:e._tag,propertySignatures:e.propertySignatures.map(e=>{let t=I.S5(e.type);return{name:e.name,type:a(e.type),isOptional:I.dK(t),isMutable:I.bV(t),...U(t.context?.annotations)}}),indexSignatures:e.indexSignatures.map(e=>({parameter:a(e.parameter),type:a(e.type)})),checks:l(e.checks),...t};case"Union":{let r=D(e.types);return{_tag:e._tag,types:r.map(e=>a(e)),mode:e.mode,...t}}case"Suspend":return{_tag:"Suspend",checks:[],thunk:a(e.thunk()),...t}}}function l(e){return e?e.map(function(e){switch(e._tag){case"Filter":{let t=e.annotations?.meta;if(t)return{_tag:"Filter",meta:"isPropertyNames"===t._tag?{_tag:"isPropertyNames",propertyNames:a(t.propertyNames)}:t,...U(e.annotations)};return}case"FilterGroup":{let t=l(e.checks);if(k.CZ(t))return{_tag:"FilterGroup",checks:t,...U(e.annotations)}}}}).filter(e=>void 0!==e):[]}}([e]);return{representation:r[0],references:t}}(e.ast),t);return{dialect:"draft-2020-12",schema:r.schema,definitions:r.definitions}}function e6(e){return ea(e7(e.ast),{schema:e})}let e8=F(function(e){switch(e._tag){case"Null":case"Boolean":case"Number":case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}}),e9=new I.N_(new I.uS("null"),new H.IT(V.pd(()=>null),V.pd(()=>"null"))),e4=new I.N_(new I.gP([new I.uS("true"),new I.uS("false")],"anyOf"),new H.IT(V.pd(e=>"true"===e),V.Qf())),e7=I.oZ(e=>{if(I.mi(e)&&e.annotations?.["~effect/Schema/SERIALIZER_ENSURE_ARRAY"]===!0)return e;let t=function(e,t,r){switch(e._tag){case"Declaration":{let n=e.annotations?.toCodecJson??e.annotations?.toCodec;if(_.Tn(n)){let r=n(I.HC(e)?e.typeParameters.map(e=>ea(t(I.O3(e)))):[]),i=t(r.to);return I.ES(e,i===r.to?[r]:[new I.N_(i,r.transformation)])}return r(e)}case"Null":return I.ES(e,[e9]);case"Boolean":return I.ES(e,[e4]);case"Unknown":case"ObjectKeyword":return I.ES(e,[I.tC]);case"Enum":case"Number":case"Literal":case"UniqueSymbol":case"Symbol":case"BigInt":return e.toCodecStringTree();case"Objects":if(e.propertySignatures.some(e=>"string"!=typeof e.name))throw new globalThis.Error("Objects property names must be strings",{cause:e});return e.recur(t,I.xw);case"Union":{let r=e8(e.types);if(r!==e.types)return new I.gP(r,e.mode,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t);return e.recur(t)}case"Arrays":case"Suspend":return e.recur(t)}return e}(e,e7,e=>I.ES(e,[te]));return t!==e&&I.dK(e)?I.nj(t):t}),te=new I.N_(I.Vx,new H.IT(V.le(),V.pd(()=>void 0))),tt=ea(I.LM);I.BF},9177(e,t,r){r.d(t,{DO:()=>Z,YA:()=>tc,D6:()=>D,bm:()=>en,LM:()=>td,E$:()=>es,N_:()=>T,uS:()=>J,BF:()=>tf,XV:()=>e5,C3:()=>tu,V3:()=>eS,gP:()=>eb,fz:()=>eN,us:()=>eR,bz:()=>Y,EJ:()=>eP,oZ:()=>eF,we:()=>Q,Nt:()=>tn,zM:()=>H,Lp:()=>tl,SL:()=>em,GL:()=>eJ,vr:()=>N,UU:()=>ez,hu:()=>ef,S5:()=>function e(t){return t.encoding?e(t.encoding[t.encoding.length-1].to):t},zm:()=>w,tF:()=>E,Lm:()=>O,HC:()=>x,c$:()=>I,bV:()=>eV,Et:()=>_,RP:()=>C,dK:()=>eK,Pt:()=>eE,Kg:()=>S,ZB:()=>tr,bk:()=>e9,IZ:()=>to,mi:()=>A,HN:()=>eI,D$:()=>e$,W:()=>eX,Zm:()=>B,ch:()=>F,ai:()=>G,ZG:()=>W,Qr:()=>eB,nj:()=>eU,xw:()=>e2,g1:()=>eq,ES:()=>eA,Yj:()=>K,w3:()=>ed,HR:()=>z,O3:()=>eH,Ax:()=>eG,PV:()=>eh,Vx:()=>R,KC:()=>ep,L5:()=>X,tC:()=>th,rI:()=>U,Ez:()=>eW});var n=r(8927),i=r(8543),s=r(7720),a=r(7598),o=r(6470),l=r(4650),c=r(1136);function u(e,t,r){return"__proto__"===t?Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0}):e[t]=r,e}var d=r(4888),f=r(8045),h=r(3833),p=r(9138),m=r(5369),g=r(6310),y=r(6030),b=r(5348);function v(e){return t=>t._tag===e}function w(e){return m.i5(e,P)&&e[P]===P}let x=v("Declaration"),k=v("Never"),S=v("String"),_=v("Number"),O=v("Boolean"),I=v("Literal"),$=v("UniqueSymbol"),E=v("Arrays"),C=v("Objects"),A=v("Union");class T{to;transformation;constructor(e,t){this.to=e,this.transformation=t}}let N={};class M{isOptional;isMutable;defaultValue;annotations;constructor(e,t,r,n){this.isOptional=e,this.isMutable=t,this.defaultValue=r,this.annotations=n}}let P="~effect/Schema";class j{[P]=P;annotations;checks;encoding;context;constructor(e,t,r,n){this.annotations=e,this.checks=t,this.encoding=r,this.context=n}toString(){return`<${this._tag}>`}}class D extends j{_tag="Declaration";typeParameters;run;encodingChecks;constructor(e,t,r,n,i,s,a){super(r,n,i,s),this.typeParameters=e,this.run=t,this.encodingChecks=a}getParser(){let e=this.run(this.typeParameters);return(t,r)=>h.isNone(t)?s.lwU:s.jkJ(e(t.value,this,r),h.some)}_rebuild(e,t,r){let n=eL(this.typeParameters,e);return n===this.typeParameters&&t===this.checks&&r===this.encodingChecks?this:new D(n,this.run,this.annotations,t,void 0,this.context,r)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}getExpected(){let e=this.annotations?.expected;return"string"==typeof e?e:"<Declaration>"}}let F=new class extends j{_tag="Null";getParser(){return eQ(this,null)}getExpected(){return"null"}},L=new T(F,new b.IT(g.pd(()=>void 0),g.pd(()=>null))),R=new class extends j{_tag="Undefined";getParser(){return eQ(this,void 0)}toCodecJson(){return eA(this,[L])}getExpected(){return"undefined"}},U=new class extends j{_tag="Void";getParser(){var e;let t;return e=void 0,t=s.nGE(e),e=>"None"===e._tag?s.lwU:t}toCodecJson(){return eA(this,[L])}getExpected(){return"void"}},B=new class extends j{_tag="Never";getParser(){return eZ(this,m.Pd)}getExpected(){return"never"}},Y=new class extends j{_tag="Any";getParser(){return eZ(this,m.t8)}getExpected(){return"any"}},X=new class extends j{_tag="Unknown";getParser(){return eZ(this,m.t8)}getExpected(){return"unknown"}},W=new class extends j{_tag="ObjectKeyword";getParser(){return eZ(this,m.Fw)}getExpected(){return"object | array | function"}};class J extends j{_tag="Literal";literal;constructor(e,t,r,n,i){if(super(t,r,n,i),"number"==typeof e&&!globalThis.Number.isFinite(e))throw Error(`A numeric literal must be finite, got ${(0,o.GP)(e)}`);this.literal=e}getParser(){return eQ(this,this.literal)}matchPart(e,t){return e===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return"bigint"==typeof this.literal?q(this):this}toCodecStringTree(){return"string"==typeof this.literal?this:q(this)}getExpected(){return"string"==typeof this.literal?JSON.stringify(this.literal):globalThis.String(this.literal)}}function q(e){let t=globalThis.String(e.literal);return eA(e,[new T(new J(t),new b.IT(g.pd(()=>e.literal),g.pd(()=>t)))])}let K=new class extends j{_tag="String";getParser(){return eZ(this,m.Kg)}matchPart(e,t){return e0(this,e,t)}getExpected(){return"string"}};function V(e,t){return e.some(e=>{switch(e._tag){case"Filter":return e.annotations?.meta?._tag===t;case"FilterGroup":return V(e.checks,t)}})}let G=new class extends j{_tag="Number";getParser(){return eZ(this,m.Et)}matchKey(e,t){return this._match(e8,e,t)}matchPart(e,t){return this._match(e6,e,t)}_match(e,t,r){return e.test(t)?e0(this,globalThis.Number(t),r):void 0}toCodecJson(){return this.checks&&(V(this.checks,"isFinite")||V(this.checks,"isInt"))?this:eA(this,[ex])}toCodecStringTree(){return this.checks&&(V(this.checks,"isFinite")||V(this.checks,"isInt"))?eA(this,[e7]):eA(this,[te])}getExpected(){return"number"}},H=new class extends j{_tag="Boolean";getParser(){return eZ(this,m.Lm)}getExpected(){return"boolean"}},z=new class extends j{_tag="Symbol";getParser(){return eZ(this,m.Bm)}matchKey(e,t){return e0(this,e,t)}toCodecStringTree(){return eA(this,[ta])}getExpected(){return"symbol"}},Q=new class extends j{_tag="BigInt";getParser(){return eZ(this,m.sI)}matchPart(e,t){return tt.test(e)?e0(this,globalThis.BigInt(e),t):void 0}toCodecStringTree(){return eA(this,[ti])}getExpected(){return"bigint"}};class Z extends j{_tag="Arrays";isMutable;elements;rest;encodingChecks;constructor(e,t,r,n,i,s,a,o){super(n,i,s,a),this.isMutable=e,this.elements=t,this.rest=r,this.encodingChecks=o;let l=t.findIndex(eK);if(-1!==l&&(t.slice(l+1).some(e=>!eK(e))||r.length>1))throw Error("A required element cannot follow an optional element. ts(1257)");if(r.length>1&&r.slice(1).some(eK))throw Error("An optional element cannot follow a rest element. ts(1266)")}getParser(e){let t=this,r=t.elements.map(t=>({ast:t,parser:e(t)})),n=t.rest.map(t=>({ast:t,parser:e(t)})),i=r.length,[a,...o]=n,l=o.length;function c(e,t){return t<i?r[t]:t>=e?o[t-e]:a}return s.vCS(function*(e,r){if("None"===e._tag)return e;let n=e.value;if(!Array.isArray(n))return yield*s.fJG(new y.eE(t,e));let a=n.length,o={ast:t,getParser:c,oinput:e,len:a,tailThreshold:Math.max(i,a-l),output:new globalThis.Array(a),issues:void 0,options:r},u=et(r?.concurrency),d=ee(o,n,{concurrency:u?.concurrency,end:0===t.rest.length?i:Math.max(a,i+l)});if(d&&(yield*d),0===t.rest.length&&a>i)for(let l=i;l<=a-1;l++){let i=new y.gm([l],new y.vF(t,n[l]));if("all"!==r.errors)return yield*s.fJG(new y.eC(t,e,[i]));o.issues?o.issues.push(i):o.issues=[i]}return o.issues?yield*s.fJG(new y.eC(t,e,o.issues)):h.some(o.output)})}_rebuild(e,t,r){let n=eL(this.elements,e),i=eL(this.rest,e);return n===this.elements&&i===this.rest&&t===this.checks&&r===this.encodingChecks?this:new Z(this.isMutable,n,i,this.annotations,t,void 0,this.context,r)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}getExpected(){return"array"}}let ee=(0,c.h$X)()({onItem(e,t,r){let n=r<e.len?h.some(t):h.none();return e.getParser(e.tailThreshold,r).parser(n,e.options)},step(e,t,r,n){if("Failure"===r._tag)return er(e,e.ast,n,r);if("Some"===r.value._tag)e.output[n]=r.value.value;else{let t=e.getParser(e.tailThreshold,n);if(eK(t.ast))return;let r=new y.gm([n],new y.Mw(t.ast.context?.annotations));if("all"!==e.options.errors)return a.fJ(new y.eC(e.ast,e.oinput,[r]));e.issues?e.issues.push(r):e.issues=[r]}}}),et=e=>(e="unbounded"===e?1/0:e??1)>1?{concurrency:e}:void 0,er=(e,t,r,n)=>{if(0===n.cause.reasons.length)return n;let s=f.R(n.cause);if(void 0===s)return a.AT(i.Tj(n.cause,n=>new y.eC(t,e.oinput,[new y.gm([r],n)])));let o=new y.gm([r],s);if("all"!==e.options.errors)return a.fJ(new y.eC(t,e.oinput,[o]));e.issues?e.issues.push(o):e.issues=[o]},en="[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?";class ei{name;type;constructor(e,t){this.name=e,this.type=t}}class es{decode;encode;constructor(e,t){this.decode=e,this.encode=t}flip(){return new es(this.encode,this.decode)}}function ea(e){switch(e._tag){case"String":case"Number":case"Symbol":case"TemplateLiteral":return!0;case"Union":return e.types.every(ea);default:return!1}}class eo{parameter;type;merge;constructor(e,t,r){if(!(ea(e)&&ea(eH(e))))throw Error(`Invalid index signature parameter ${e._tag}`);if(this.parameter=e,this.type=t,this.merge=r,eK(t)&&!function e(t){switch(t._tag){case"Undefined":return!0;case"Union":return t.types.some(e);default:return!1}}(t))throw Error("Cannot use `Schema.optionalKey` with index signatures, use `Schema.optional` instead.")}}class el extends j{_tag="Objects";propertySignatures;indexSignatures;encodingChecks;constructor(e,t,r,n,i,s,a){super(r,n,i,s),this.propertySignatures=e,this.indexSignatures=t,this.encodingChecks=a;let o=e.map(e=>e.name).filter((e,t,r)=>r.indexOf(e)!==t);if(o.length>0)throw Error(`Duplicate identifiers: ${JSON.stringify(o)}. ts(2300)`)}getParser(e){let t=this,r=[],i=new Set,a=[];for(let n of t.propertySignatures)r.push(n.name),i.add(n.name),a.push({ps:n,parser:e(n.type),name:n.name,type:n.type});let o=t.indexSignatures.length;if(0===t.propertySignatures.length&&0===t.indexSignatures.length)return eZ(t,m.Vq);let l=o>0?(0,c.h$X)()({onItem:s.vCS(function*(r,[n,a]){let o=e(e1(a.parameter))(h.some(n),r.options),l=(0,c.OY)(o)?o:yield*s.NS5(o);if("Failure"===l._tag){let e=er(r,t,n,l);e&&(yield*e);return}let d=h.some(r.input[n]),f=e(a.type)(d,r.options),p=(0,c.OY)(f)?f:yield*s.NS5(f);if("Failure"===p._tag){let e=er(r,t,n,p);e&&(yield*e);return}if("Some"===l.value._tag&&"Some"===p.value._tag){let e=l.value.value;if(i.has(n)||i.has(e))return;let t=p.value.value;if(a.merge&&a.merge.decode&&Object.hasOwn(r.out,e)){let[n,i]=a.merge.decode.combine([e,r.out[e]],[e,t]);u(r.out,n,i)}else u(r.out,e,t)}}),step:(e,t,r)=>"Failure"===r._tag?r:void 0}):void 0;return s.vCS(function*(e,c){let d;if("None"===e._tag)return e;let f=e.value;if(!("object"==typeof f&&null!==f&&!Array.isArray(f)))return yield*s.fJG(new y.eE(t,e));let p={},m={ast:t,oinput:e,input:f,out:p,issues:void 0,options:c},g="all"===c.errors,b="error"===c.onExcessProperty,v="preserve"===c.onExcessProperty;if(0===t.indexSignatures.length&&(b||v)){d=Reflect.ownKeys(f);for(let r=0;r<d.length;r++){let n=d[r];if(!i.has(n))if(b){let r=new y.gm([n],new y.vF(t,f[n]));if(!g)return yield*s.fJG(new y.eC(t,e,[r]));m.issues?m.issues.push(r):m.issues=[r];continue}else u(p,n,f[n])}}let w=et(c?.concurrency),x=ec(m,a,w);if(x&&(yield*x),l){let e=n.Ie();for(let r=0;r<o;r++){let n=t.indexSignatures[r],i=function(e,t,r=N){let n,i;return function t(s){switch(s._tag){case"String":case"TemplateLiteral":return(n??=Object.keys(e)).filter(e=>void 0!==s.matchPart(e,r));case"Number":return(n??=Object.keys(e)).filter(e=>void 0!==s.matchKey(e,r));case"Symbol":return(i??=Object.getOwnPropertySymbols(e)).filter(e=>void 0!==s.matchKey(e,r));case"Union":return[...new Set(s.types.flatMap(t))];default:return[]}}(e1(eH(t)))}(f,n.parameter,c);for(let t=0;t<i.length;t++){let r=i[t];e.push([r,n])}}let r=l(m,e,w);r&&(yield*r)}if(m.issues)return yield*s.fJG(new y.eC(t,e,m.issues));if("original"===c.propertyOrder){let e=(d??Reflect.ownKeys(f)).concat(r),t={};for(let r of e)Object.hasOwn(p,r)&&u(t,r,p[r]);return h.some(t)}return h.some(p)})}_rebuild(e,t,r,n,i){let s=eL(this.propertySignatures,t=>{let r=e(t.type);return r===t.type?t:new ei(t.name,r)}),a=eL(this.indexSignatures,n=>{let i=t(n.parameter),s=e(n.type),a=r?n.merge?.flip():n.merge;return i===n.parameter&&s===n.type&&a===n.merge?n:new eo(i,s,a)});return s===this.propertySignatures&&a===this.indexSignatures&&n===this.checks&&i===this.encodingChecks?this:new el(s,a,this.annotations,n,void 0,this.context,i)}flip(e){return this._rebuild(e,e,!0,this.encodingChecks,this.checks)}recur(e,t=e){return this._rebuild(e,t,!1,this.checks,this.encodingChecks)}getExpected(){return 0===this.propertySignatures.length&&0===this.indexSignatures.length?"object | array":"object"}}let ec=(0,c.h$X)()({onItem(e,t){let r=Object.hasOwn(e.input,t.name)?h.some(e.input[t.name]):h.none();return t.parser(r,e.options)},step(e,t,r){if("Failure"===r._tag)return er(e,e.ast,t.name,r);if("Some"===r.value._tag)u(e.out,t.name,r.value.value);else if(!eK(t.type)){let r=new y.gm([t.name],new y.Mw(t.type.context?.annotations));return"all"!==e.options.errors?a.fJ(new y.eC(e.ast,e.oinput,[r])):void(e.issues?e.issues.push(r):e.issues=[r])}}});function eu(e,t){return e?t?[...e,...t]:e:t}function ed(e,t,r){return new el(Reflect.ownKeys(e).map(t=>new ei(t,e[t].ast)),[],r,t)}function ef(e){return e.ast}function eh(e,t){return new Z(!1,e.map(e=>e.ast),[],void 0,t)}function ep(e,t,r){return new eb(e.map(ef),t,void 0,r)}function em(e){switch(e._tag){default:return[];case"Declaration":{let t=e.annotations?.["~sentinels"];return Array.isArray(t)?t:[]}case"Objects":return e.propertySignatures.flatMap(e=>{let t=e.type;if(!eK(t)){if(I(t))return[{key:e.name,literal:t.literal}];if($(t))return[{key:e.name,literal:t.symbol}]}return[]});case"Arrays":return e.elements.flatMap((e,t)=>I(e)&&!eK(e)?[{key:t,literal:e.literal}]:[]);case"Suspend":return em(e.thunk())}}let eg=new WeakMap;function ey(e){return t=>{let r=eH(t);return"Literal"===r._tag?r.literal===e:"UniqueSymbol"!==r._tag||r.symbol===e}}class eb extends j{_tag="Union";types;mode;encodingChecks;constructor(e,t,r,n,i,s,a){super(r,n,i,s),this.types=e,this.mode=t,this.encodingChecks=a}getParser(e){let t=this;return(r,n)=>{if("None"===r._tag)return s.PyW(r);let i=r.value,a=function(e,t){let r=function(e){let t=eg.get(e);if(t)return t;t={};for(let r=0;r<e.length;r++){let n=eH(e[r]);if(k(n))continue;let i=function e(t){switch(t._tag){case"Null":return["null"];case"Undefined":return["undefined"];case"String":case"TemplateLiteral":return["string"];case"Number":return["number"];case"Boolean":return["boolean"];case"Symbol":case"UniqueSymbol":return["symbol"];case"BigInt":return["bigint"];case"Arrays":return["array"];case"ObjectKeyword":return["object","array","function"];case"Objects":return t.propertySignatures.length||t.indexSignatures.length?["object"]:["object","array"];case"Enum":return Array.from(new Set(t.enums.map(([,e])=>typeof e)));case"Literal":return[typeof t.literal];case"Union":return Array.from(new Set(t.types.flatMap(e)));default:return["null","undefined","string","number","boolean","symbol","bigint","object","array","function"]}}(n),s=em(n);for(let e of(t.byType??={},i))(t.byType[e]??=[]).push(r);if(s.length>0)for(let{key:e,literal:n}of(t.bySentinel??=new Map,s)){let i=t.bySentinel.get(e);i||t.bySentinel.set(e,i=new Map);let s=i.get(n);s||i.set(n,s=[]),s.push(r)}else for(let e of(t.otherwise??={},i))(t.otherwise[e]??=[]).push(r)}return eg.set(e,t),t}(t),n=null===e?"null":Array.isArray(e)?"array":typeof e;if(r.bySentinel){let i=r.otherwise?.[n]??[];if("object"===n||"array"===n){let n=new Set(i);for(let[t,i]of r.bySentinel)if(Object.hasOwn(e,t)){let r=i.get(e[t]);if(r)for(let e of r)n.add(e)}return Array.from(n).sort((e,t)=>e-t).map(e=>t[e]).filter(ey(e))}return i.map(e=>t[e])}return(r.byType?.[n]??[]).map(e=>t[e]).filter(ey(e))}(i,t.types),o={ast:t,recur:e,oinput:r,input:i,out:void 0,successes:[],issues:void 0,options:n},l=et(n?.concurrency),c=ev(o,a,l?{...l,orderedStep:!0}:void 0);return c?s.qIB(c,e=>o.out?s.PyW(o.out):s.fJG(new y.W(t,i,o.issues??[]))):o.out?s.PyW(o.out):s.fJG(new y.W(t,i,o.issues??[]))}}_rebuild(e,t,r){let n=eL(this.types,e);return n===this.types&&t===this.checks&&r===this.encodingChecks?this:new eb(n,this.mode,this.annotations,t,void 0,this.context,r)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}matchPart(e,t){for(let r of this.types){let n=r.matchPart(e,t);if(void 0!==n)return n}}getExpected(e){let t=this.annotations?.expected;return"string"==typeof t?t:0===this.types.length?"never":Array.from(new Set(this.types.map(t=>{let r=eH(t);switch(r._tag){case"Arrays":{let t=r.elements.filter(I);if(t.length>0)return`${ek(r.isMutable)}[ ${t.map(t=>e(t)+(t.context?.isOptional?"?":"")).join(", ")}, ... ]`;break}case"Objects":{let t=r.propertySignatures.filter(e=>I(e.type));if(t.length>0)return`{ ${t.map(t=>`${ek(t.type.context?.isMutable)}${(0,o._r)(t.name)}${t.type.context?.isOptional?"?":""}: ${e(t.type)}`).join(", ")}, ... }`}}return e(r)}))).join(" | ")}}let ev=(0,c.h$X)()({onItem:(e,t)=>e.recur(t)(e.oinput,e.options),step(e,t,r){if("Failure"===r._tag){let t=f.R(r.cause);if(void 0===t)return r;e.issues?e.issues.push(t):e.issues=[t]}else{if(e.out&&"oneOf"===e.ast.mode)return e.successes.push(t),a.fJ(new y.E8(e.ast,e.input,e.successes));if(e.out=r.value,e.successes.push(t),"anyOf"===e.ast.mode)return a.rI}}}),ew=new eb([new J("Infinity"),new J("-Infinity"),new J("NaN")],"anyOf"),ex=new T(new eb([G,ew],"anyOf"),new b.IT(g.wN(),g.pd(e=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function ek(e){return e?"":"readonly "}class eS extends j{_tag="Suspend";thunk;constructor(e,t,r,n,i){let s,a;if(void 0!==r)throw Error("Cannot add checks to Suspend");super(t,void 0,n,i),this.thunk=(a=!1,()=>(a||(s=e(),a=!0),s))}getParser(e){return e(this.thunk())}recur(e){return new eS(()=>e(this.thunk()),this.annotations,void 0,void 0,this.context)}getExpected(e){return e(this.thunk())}}class e_ extends p.Xs{_tag="Filter";run;annotations;aborted;constructor(e,t,r=!1){super(),this.run=e,this.annotations=t,this.aborted=r}annotate(e){return new e_(this.run,{...this.annotations,...e},this.aborted)}abort(){return new e_(this.run,this.annotations,!0)}and(e,t){return new eO([this,e],t)}}class eO extends p.Xs{_tag="FilterGroup";checks;annotations;constructor(e,t){super(),this.checks=e,this.annotations=t}annotate(e){return new eO(this.checks,{...this.annotations,...e})}and(e,t){return new eO([this,e],t)}}function eI(e,t,r=!1){return new e_((t,r,n)=>y.L8(t,r,e(t,r,n)),t,r)}function e$(e,t){return new e_(t=>e(t)?void 0:new y.h6(h.some(t)),t,!0)}function eE(e,t){let r=e.source;return eI(t=>e.test(t),{expected:`a string matching the RegExp ${r}`,meta:{_tag:"isPattern",regExp:e},arbitrary:{constraint:{patterns:[e.source]}},...t})}function eC(e,t){let r=Object.getOwnPropertyDescriptors(e);return t(r),Object.create(Object.getPrototypeOf(e),r)}function eA(e,t){return e.encoding===t?e:eC(e,e=>{e.encoding.value=t})}function eT(e,t){return e.context===t?e:eC(e,e=>{e.context.value=t})}function eN(e,t){if(e.checks){let r=e.checks[e.checks.length-1];return eM(e,n.BC(e.checks.slice(0,-1),r.annotate(t)))}return eC(e,e=>{e.annotations.value={...e.annotations.value,...t}})}function eM(e,t){if("Suspend"===e._tag&&void 0!==t)throw Error("Cannot add checks to Suspend");return e.checks===t?e:eC(e,e=>{e.checks.value=t})}function eP(e,t){return eM(e,eu(e.checks,t))}function ej(e,t){let r=e[e.length-1],i=t(r.to);return i!==r.to?n.BC(e.slice(0,e.length-1),new T(i,r.transformation)):e}function eD(e){return t=>t.encoding?eA(t,ej(t.encoding,e)):t}function eF(e){return(0,l.Bj)(function t(r){return r.encoding?eA(r,ej(r.encoding,t)):e(r)})}function eL(e,t){let r=!1,n=Array(e.length);for(let i=0;i<e.length;i++){let s=e[i],a=t(s);a!==s&&(r=!0),n[i]=a}return r?n:e}function eR(e,t){let r=e.context?new M(e.context.isOptional,e.context.isMutable,e.context.defaultValue,{...e.context.annotations,...t}):new M(!1,!1,void 0,t);return eT(e,r)}let eU=eD(eB);function eB(e){let t=e.context?!1===e.context.isOptional?new M(!0,e.context.isMutable,e.context.defaultValue,e.context.annotations):e.context:new M(!0,!1);return eU(eT(e,t))}let eY=eD(eX);function eX(e){let t=e.context?!1===e.context.isMutable?new M(e.context.isOptional,!0,e.context.defaultValue,e.context.annotations):e.context:new M(!1,!0);return eY(eT(e,t))}function eW(e,t){let r=[new T(X,new b.IT(g.IQ(t),g.le()))],n=e.context?new M(e.context.isOptional,e.context.isMutable,r,e.context.annotations):new M(!1,!1,r);return eT(e,n)}function eJ(e,t,r){let n;return n=new T(e,r),eA(t,t.encoding?[...t.encoding,n]:[n])}function eq(e,t,r){let n,i,{literals:s,parameters:a}=(n=[],i=[],!function e(t){switch(t._tag){case"Literal":m.hL(t.literal)&&n.push(t.literal);return;case"UniqueSymbol":n.push(t.symbol);return;case"Never":return;case"Union":for(let r=0;r<t.types.length;r++)e(t.types[r]);return;default:i.push(t)}}(e),{literals:n,parameters:i});return new el(s.map(e=>new ei(e,t)),a.map(e=>new eo(e,t,r)))}function eK(e){return e.context?.isOptional??!1}function eV(e){return e.context?.isMutable??!1}let eG=(0,l.Bj)(e=>{if(e.encoding)return eG(eA(e,void 0));let t=e.recur?.(eG)??e,r=t.encodingChecks;return r?eC(t,n=>{n.encodingChecks.value=void 0,t===e&&(n.checks.value=eu(t.checks,r))}):t}),eH=(0,l.Bj)(e=>eG(ez(e))),ez=(0,l.Bj)(e=>e.encoding?function(e,t){let r=t.length,n=t[r-1],i=[new T(ez(eA(e,void 0)),t[0].transformation.flip())];for(let e=1;e<r;e++)i.unshift(new T(ez(t[e-1].to),t[e].transformation.flip()));let s=ez(n.to);return s.encoding?eA(s,[...s.encoding,...i]):eA(s,i)}(e,e.encoding):e.flip?.(ez)??e.recur?.(ez)??e);function eQ(e,t){let r=s.nGE(t);return n=>"None"===n._tag?s.lwU:n.value===t?r:s.fJG(new y.eE(e,n))}function eZ(e,t){return r=>"None"===r._tag?s.lwU:t(r.value)?s.PyW(r):s.fJG(new y.eE(e,r))}function e0(e,t,r){if(r?.disableChecks||void 0===e.checks)return t;let n=[];return tl(e.checks,t,n,e,r),0===n.length?t:void 0}let e1=eF(e=>{switch(e._tag){default:return e;case"Number":return e.toCodecStringTree();case"Union":return e.recur(e1)}}),e2=eF(e=>{switch(e._tag){default:return e;case"Symbol":case"UniqueSymbol":return e.toCodecStringTree();case"Union":return e.recur(e2)}}),e3=eF(e=>{switch(e._tag){default:return e;case"Number":case"Literal":case"BigInt":return e.toCodecStringTree();case"Union":return e.recur(e3)}}),e5="[\\s\\S]*?",e6=new globalThis.RegExp(`^${en}$`),e8=new globalThis.RegExp(`(?:${en}|Infinity|-Infinity|NaN)`);function e9(e){return eE(e6,{expected:"a string representing a finite number",meta:{_tag:"isStringFinite",regExp:e6},...e})}let e4=eP(K,[e9()]),e7=new T(e4,b.ZK),te=new T(new eb([e4,ew],"anyOf"),b.ZK),tt=new globalThis.RegExp("^-?\\d+$");function tr(e){return eE(tt,{expected:"a string representing a bigint",meta:{_tag:"isStringBigInt",regExp:tt},...e})}let tn=eP(K,[tr({expected:"a string representing a bigint"})]),ti=new T(tn,b.R7),ts=new globalThis.RegExp("^Symbol\\((.*)\\)$"),ta=new T(eP(K,[to()]),new b.IT(g.pd(e=>globalThis.Symbol.for(ts.exec(e)[1])),g.K$(e=>void 0!==globalThis.Symbol.keyFor(e)?s.PyW(globalThis.String(e)):s.fJG(new y.cw(h.some(e),{message:"cannot serialize to string, Symbol is not registered"})))));function to(e){return eE(ts,{expected:"a string representing a symbol",meta:{_tag:"isStringSymbol",regExp:ts},...e})}function tl(e,t,r,n,i){for(let s=0;s<e.length;s++){let a=e[s];if("FilterGroup"===a._tag)tl(a.checks,t,r,n,i);else{let e=a.run(t,n,i);if(e&&(r.push(new y.dJ(t,a,e)),a.aborted||i?.errors!=="all"))return}}}let tc="~effect/Schema/Class",tu="~structural";d.hd,d.ip,d.KE,d.DQ,d.Pk;let td=new D([],()=>(e,t)=>{let r,n;return(r=new Set,n=new Set,function e(t){if(null===t||"string"==typeof t||"boolean"==typeof t)return!0;if("number"==typeof t)return globalThis.Number.isFinite(t);if("object"!=typeof t||void 0===t||r.has(t))return!1;if(n.has(t))return!0;let i=Array.isArray(t);if(!i){let e=Object.getPrototypeOf(t);if(null!==e&&null!==Object.getPrototypeOf(e))return!1}r.add(t);let s=i?t.every(e):Object.keys(t).every(r=>e(t[r]));return r.delete(t),s&&n.add(t),s}(e))?s.PyW(e):s.fJG(new y.eE(t,h.some(e)))},{typeConstructor:{_tag:"effect/Json"},generation:{runtime:"Schema.Json",Type:"Schema.Json"},expected:"JSON value",toCodecJson:()=>new T(X,b.le()),toArbitrary:()=>e=>e.jsonValue()}),tf=eN(td,{typeConstructor:{_tag:"effect/MutableJson"},generation:{runtime:"Schema.MutableJson",Type:"Schema.MutableJson"}}),th=new T(new D([],()=>(e,t)=>{let r;return(r=new Set,function e(t){return void 0===t||"string"==typeof t||!("object"!=typeof t||null===t||r.has(t))&&((r.add(t),Array.isArray(t))?t.every(e):Object.keys(t).every(r=>e(t[r])))}(e))?s.PyW(e):s.fJG(new y.eE(t,h.some(e)))},{expected:"StringTree"}),b.le())},6310(e,t,r){var n=r(4705),i=r(7720),s=r(8983),a=r(3833),o=r(9138),l=r(5369),c=r(995),u=r(6030);class d extends o.Xs{run;constructor(e){super(),this.run=e}map(e){return new d((t,r)=>this.run(t,r).pipe(i.jkJ(a.map(e))))}compose(e){return h(this)?e:h(e)?this:new d((t,r)=>this.run(t,r).pipe(i.Ab9(t=>e.run(t,r))))}}let f=new d(i.PyW);function h(e){return e.run===f.run}function p(){return f}function m(e){var t;return t=a.map(e),new d(e=>i.PyW(t(e)))}function g(e){var t;return t=(t,r)=>e(t,r).pipe(i.jkJ(a.some)),new d((e,r)=>a.isNone(e)?i.lwU:t(e.value,r))}function y(){return new d(()=>i.lwU)}function b(e){return new d(t=>{let r=a.filter(t,l.EA);return a.isSome(r)?i.PyW(r):i.jkJ(e,a.some)})}function v(){return m(globalThis.String)}function w(){return m(globalThis.Number)}function x(){return m(globalThis.BigInt)}function k(){return m(e=>new globalThis.Date(e))}function S(){return m(s.WG)}function _(){return m(s.DX)}function O(){return m(s.mU)}function I(){return g(e=>i.Z9x(i.yUA(s.y4(e)),t=>new u.h6(a.some(e),{message:t.message})))}function $(){return g(e=>c.YW(s.$T(e),{onFailure:t=>i.fJG(new u.h6(a.some(e),{message:t.message})),onSuccess:i.PyW}))}function E(){return g(e=>c.YW(s.$X(e),{onFailure:t=>i.fJG(new u.h6(a.some(e),{message:t.message})),onSuccess:i.PyW}))}function C(){return g(e=>c.YW(s.UD(e),{onFailure:t=>i.fJG(new u.h6(a.some(e),{message:t.message})),onSuccess:i.PyW}))}function A(){return g(e=>c.YW(s.EF(e),{onFailure:t=>i.fJG(new u.h6(a.some(e),{message:t.message})),onSuccess:i.PyW}))}function T(){return g(e=>c.YW(s.xQ(e),{onFailure:t=>i.fJG(new u.h6(a.some(e),{message:t.message})),onSuccess:i.PyW}))}function N(){return m(encodeURIComponent)}function M(){return g(e=>{try{return i.PyW(globalThis.decodeURIComponent(e))}catch(t){return i.fJG(new u.h6(a.some(e),{message:t instanceof URIError?t.message:"Invalid URI component"}))}})}function P(){return g(e=>a.match(n.L8(e),{onNone:()=>i.fJG(new u.h6(a.some(e),{message:"Invalid DateTime input"})),onSome:e=>i.PyW(n.yT(e))}))}l.Kg,r.d(t,{$T:()=>$,$X:()=>E,A0:()=>P,DX:()=>_,EF:()=>A,IQ:()=>b,K$:()=>g,Qf:()=>v,Qw:()=>x,UD:()=>C,WG:()=>S,_p:()=>N,cJ:()=>y,le:()=>p,mF:()=>M,mU:()=>O,n9:()=>k,pd:()=>m,uB:()=>d,wN:()=>w,xQ:()=>T,y4:()=>I})},6030(e,t,r){var n=r(8927),i=r(6470),s=r(4888),a=r(3833),o=r(5369);let l="~effect/SchemaIssue/Issue";function c(e){return(0,o.i5)(e,l)}class u{[l]=l;toString(){return C(this)}}class d extends u{_tag="Filter";actual;filter;issue;constructor(e,t,r){super(),this.actual=e,this.filter=t,this.issue=r}}class f extends u{_tag="Encoding";ast;actual;issue;constructor(e,t,r){super(),this.ast=e,this.actual=t,this.issue=r}}class h extends u{_tag="Pointer";path;issue;constructor(e,t){super(),this.path=e,this.issue=t}}class p extends u{_tag="MissingKey";annotations;constructor(e){super(),this.annotations=e}}class m extends u{_tag="UnexpectedKey";ast;actual;constructor(e,t){super(),this.ast=e,this.actual=t}}class g extends u{_tag="Composite";ast;actual;issues;constructor(e,t,r){super(),this.ast=e,this.actual=t,this.issues=r}}class y extends u{_tag="InvalidType";ast;actual;constructor(e,t){super(),this.ast=e,this.actual=t}}class b extends u{_tag="InvalidValue";actual;annotations;constructor(e,t){super(),this.actual=e,this.annotations=t}}class v extends u{_tag="Forbidden";actual;annotations;constructor(e,t){super(),this.actual=e,this.annotations=t}}class w extends u{_tag="AnyOf";ast;actual;issues;constructor(e,t,r){super(),this.ast=e,this.actual=t,this.issues=r}}class x extends u{_tag="OneOf";ast;actual;successes;constructor(e,t,r){super(),this.ast=e,this.actual=t,this.successes=r}}function k(e,t){if(c(t))return t;if("string"==typeof t)return new b(a.some(e),{message:t});let r="string"==typeof t.issue?new b(a.some(e),{message:t.issue}):t.issue;return new h(t.path,r)}function S(e,t,r){if(Array.isArray(r))return n.ET(r)?1===r.length?k(e,r[0]):new g(t,a.some(e),n.Tj(r,t=>k(e,t))):void 0;if(void 0!==r)return"boolean"==typeof r?r?void 0:new b(a.some(e)):k(e,r)}let _=e=>{let t=T(e);if(void 0!==t)return t;switch(e._tag){case"InvalidType":return $(s.bo(e.ast),M(e.actual));case"InvalidValue":return`Invalid data ${M(e.actual)}`;case"MissingKey":return"Missing key";case"UnexpectedKey":return`Unexpected key with value ${(0,i.GP)(e.actual)}`;case"Forbidden":return"Forbidden operation";case"OneOf":return`Expected exactly one member to match the input ${(0,i.GP)(e.actual)}`}},O=e=>T(e.issue)??T(e);function I(e){return t=>({issues:E(t,[],e?.leafHook??_,e?.checkHook??O)})}function $(e,t){return`Expected ${e}, got ${t}`}function E(e,t,r,n){switch(e._tag){case"Filter":{let s=n(e);if(void 0!==s)return[{path:t,message:s}];if("InvalidValue"===e.issue._tag)return[{path:t,message:$(function e(t){let r=t.annotations?.expected;if("string"==typeof r)return r;switch(t._tag){case"Filter":return"<filter>";case"FilterGroup":return t.checks.map(t=>e(t)).join(" & ")}}(e.filter),(0,i.GP)(e.actual))}];return E(e.issue,t,r,n)}case"Encoding":return E(e.issue,t,r,n);case"Pointer":return E(e.issue,[...t,...e.path],r,n);case"Composite":return e.issues.flatMap(e=>E(e,t,r,n));case"AnyOf":{let a=T(e);if(0===e.issues.length){if(void 0!==a)return[{path:t,message:a}];return[{path:t,message:$(s.bo(e.ast),(0,i.GP)(e.actual))}]}return e.issues.flatMap(e=>E(e,t,r,n))}default:return[{path:t,message:r(e)}]}}let C=e=>E(e,[],_,O).map(A).join("\n");function A(e){let t=e.message;if(e.path&&e.path.length>0){let r=(0,i.jV)(e.path);t+=`
127
+ at ${r}`}return t}function T(e){switch(e._tag){case"InvalidType":case"OneOf":case"Composite":case"AnyOf":return N(e.ast.annotations);case"InvalidValue":case"Forbidden":return N(e.annotations);case"MissingKey":return N(e.annotations,"messageMissingKey");case"UnexpectedKey":return N(e.ast.annotations,"messageUnexpectedKey");case"Filter":return N(e.filter.annotations);case"Encoding":return T(e.issue)}}function N(e,t="message"){let r=e?.[t];if("string"==typeof r)return r}function M(e){return a.isNone(e)?"no value provided":(0,i.GP)(e.value)}r.d(t,{E8:()=>x,ID:()=>I,L8:()=>S,Mw:()=>p,W:()=>w,Wi:()=>f,cw:()=>v,dJ:()=>d,eC:()=>g,eE:()=>y,gh:()=>c,gm:()=>h,h6:()=>b,vF:()=>m},{vp:_})},4858(e,t,r){var n=r(8927),i=r(8543),s=r(7720),a=r(7598),o=r(4650),l=r(8045),c=r(3833),u=r(5369),d=r(995),f=r(9177),h=r(6030);let p=(0,o.Bj)(e=>{switch(e._tag){case"Declaration":{let t=e.annotations?.[f.YA];if(u.Tn(t)){let r=t(e.typeParameters),n=p(r.to);return f.ES(e,n===r.to?[r]:[new f.N_(n,r.transformation)])}return e}case"Objects":case"Arrays":return e.recur(e=>{let t=e.context?.defaultValue;return t?f.ES(p(e),t):p(e)});case"Suspend":return e.recur(p);default:return e}});function m(e){let t=O(p(f.Ax(e.ast)));return(e,r)=>t(e,r?.disableChecks?r?.parseOptions?{...r.parseOptions,disableChecks:!0}:{disableChecks:!0}:r?.parseOptions)}function g(e){let t=m(e);return(e,r)=>{let n=s.lKS(t(e,r));return a.oJ(n)?c.some(n.value):(l.q(n.cause,"Option adapter can only return none for schema issues"),c.none())}}function y(e){let t=m(e);return(e,r)=>{let n=s.lKS(t(e,r));if(a.oJ(n))return n.value;let i=l.q(n.cause,"Constructor adapter can only throw schema issues");throw Error(i.toString(),{cause:i})}}function b(e){var t;let r;return t=e.ast,r=I(O(f.Ax(t))),e=>{let t=r(e,f.vr);return!!a.oJ(t)||(l.q(t.cause,"Type guard adapter can only return false for schema issues"),!1)}}function v(e,t){let r=I(O(f.Ax(e.ast)))(t,f.vr);if(a.N6(r)){let e=l.q(r.cause,"Assertion adapter can only throw schema issues");throw Error(e.toString(),{cause:e})}}function w(e,t){let r=O(e.ast);return void 0===t?r:(e,n)=>r(e,_(t,n))}function x(e,t){return $(w(e,t))}function k(e,t){let r;return r=I(w(e,t)),(e,t)=>{let n=r(e,t);return a.oJ(n)?d.Py(n.value):d.fJ(l.q(n.cause,"Result adapter can only return schema issues"))}}function S(e,t){let r;return $((r=O(f.UU(e.ast)),void 0===t?r:(e,n)=>r(e,_(t,n))))}let _=(e,t)=>void 0===t?e:{...e,...t};function O(e){let t=C(e);return(e,r)=>s.Ab9(t(c.some(e),r??f.vr),e=>"None"===e._tag?s.fJG(new h.h6(e)):s.PyW(e.value))}function I(e){return(t,r)=>s.lKS(e(t,r))}function $(e){let t=I(e);return(e,r)=>{let n=t(e,r);return a.oJ(n)?c.some(n.value):(l.q(n.cause,"Option adapter can only return none for schema issues"),c.none())}}function E(e,t){return s.Tyx(e,e=>s.pVV(()=>i.Tj(e,t)))}let C=(0,o.Bj)(e=>{let t,r=e.checks,i=e.encoding,a=i?.length??0,o=e.encodingChecks,l=(r?r[r.length-1].annotations:e.annotations)?.parseOptions;if(!e.context&&!i&&!r&&!o)return(r,n)=>(t??=e.getParser(C),l&&(n={...n,...l}),t(r,n));let u=f.tF(e)||f.RP(e)||f.HC(e)&&e.typeParameters.length>0,d=r&&u?r.filter(e=>e.annotations?.[f.C3]):void 0;return(u,p)=>{let m;if(l&&(p={...p,...l}),i){for(let e=a-1;e>=0;e--){let t=i[e],r=C(t.to);if(m=m?s.Ab9(m,e=>r(e,p)):r(u,p),"Transformation"===t.transformation._tag){let e=t.transformation.decode;m=s.Ab9(m,t=>e.run(t,p))}else m=t.transformation.decode(m,p)}m=E(m,t=>new h.Wi(e,u,t))}t??=e.getParser(C);let g=i=>{let a=t(i,p);return o&&!p?.disableChecks&&(a=s.Ab9(a,t=>{if(c.isSome(i)&&c.isSome(t)){let t=[];if(f.Lp(o,i.value,t,e,p),n.CZ(t))return s.fJG(new h.eC(e,i,t))}return s.PyW(t)})),r&&!p?.disableChecks&&(p?.errors==="all"&&d&&d.length>0&&c.isSome(i)&&(a=E(a,t=>{let r=[];return f.Lp(d,i.value,r,e,p),n.CZ(r)?"Composite"===t._tag&&t.ast===e?new h.eC(e,t.actual,[...t.issues,...r]):new h.eC(e,i,[t,...r]):t})),a=s.Ab9(a,t=>{if(c.isSome(t)){let i=t.value,a=[];if(f.Lp(r,i,a,e,p),n.CZ(a))return s.fJG(new h.eC(e,t,a))}return s.PyW(t)})),a};return m?s.Ab9(m,g):g(u)}});r.d(t,{IQ:()=>S,L8:()=>y,YY:()=>g,_R:()=>w,is:()=>b,kv:()=>v,o:()=>m,q$:()=>k,y9:()=>x},{GP:S,mR:x})},5348(e,t,r){var n=r(631),i=r(4705),s=r(2302),a=r(7720),o=r(6470),l=r(3833),c=r(5369),u=r(6310),d=r(6030);let f="~effect/SchemaTransformation/Transformation";class h{[f]=f;_tag="Transformation";decode;encode;constructor(e,t){this.decode=e,this.encode=t}flip(){return new h(this.encode,this.decode)}compose(e){return new h(this.decode.compose(e.decode),e.encode.compose(this.encode))}}function p(e){return new h(u.K$(e.decode),u.K$(e.encode))}function m(e){return new h(u.pd(e.decode),u.pd(e.encode))}let g=new h(u.le(),u.le());function y(){return g}let b=new h(u.wN(),u.Qf()),v=new h(u.Qw(),u.Qf()),w=new h(u.n9(),u.pd(o.Yq)),x=new h(u.n9(),u.pd(e=>e.getTime())),k=p({decode:e=>l.match(s.lX(e),{onNone:()=>a.fJG(new d.h6(l.some(e),{message:`Invalid Duration string: ${e}`})),onSome:a.PyW}),encode:e=>a.PyW(globalThis.String(e))}),S=p({decode:e=>a.PyW(s.cF(e)),encode:e=>l.match(s.tb(e),{onNone:()=>a.fJG(new d.h6(l.some(e),{message:`Unable to encode ${e} into a bigint`})),onSome:e=>a.PyW(e)})}),_=m({decode:e=>s.ne(e),encode:e=>s.kE(e)}),O=e=>{let t;return c.Gv(e)&&"string"==typeof e.message?(t=Object.hasOwn(e,"cause")?Error(e.message,{cause:O(e.cause)}):Error(e.message),"string"==typeof e.name&&"Error"!==e.name&&(t.name=e.name),"string"==typeof e.stack&&(t.stack=e.stack),t):e},I=p({decode:e=>URL.canParse(e)?a.PyW(new URL(e)):a.fJG(new d.h6(l.some(e),{message:`Invalid URL string: ${e}`})),encode:e=>a.PyW(e.href)}),$=p({decode:e=>{let t=n.sH(e);return l.isNone(t)?a.fJG(new d.h6(l.some(e),{message:`Invalid BigDecimal string: ${e}`})):a.PyW(t.value)},encode:e=>a.PyW(n.GP(e))}),E=new h(u.y4(),u.WG()),C=new h(u.$T(),u.WG()),A=new h(u.UD(),u.DX()),T=new h(u.xQ(),u.mU()),N=new h(u.mF(),u._p()),M=m({decode:e=>i.ko(e),encode:e=>e.offset}),P=p({decode:e=>l.match(i.y3(e),{onNone:()=>a.fJG(new d.h6(l.some(e),{message:`Invalid IANA time zone: ${e}`})),onSome:a.PyW}),encode:e=>a.PyW(e.id)}),j=p({decode:e=>l.match(i.ez(e),{onNone:()=>a.fJG(new d.h6(l.some(e),{message:`Invalid time zone: ${e}`})),onSome:a.PyW}),encode:e=>a.PyW(i.xV(e))}),D=p({decode:e=>l.match(i.L8(e),{onNone:()=>a.fJG(new d.h6(l.some(e),{message:`Invalid UTC DateTime string: ${e}`})),onSome:e=>a.PyW(i.yT(e))}),encode:e=>a.PyW(i.dv(e))}),F=p({decode:e=>l.match(i.MO(e),{onNone:()=>a.fJG(new d.h6(l.some(e),{message:`Invalid Zoned DateTime string: ${e}`})),onSome:a.PyW}),encode:e=>a.PyW(i.Rd(e))});r.d(t,{IT:()=>h,K$:()=>p,le:()=>y,pd:()=>m},{Ct:C,EJ:k,HO:x,I9:M,L8:e=>c.i5(e,f)?e:new h(e.decode,e.encode),LL:A,Nh:D,PE:_,Pp:N,R7:v,U0:E,XU:j,Y5:T,YZ:w,ZK:b,d9:F,dG:$,m8:S,nY:I,sm:e=>{let t,r;return m({decode:O,encode:(t=new WeakSet,r=n=>{if(c.bJ(n)){var i;let s;if(t.has(n))return"[Circular]";t.add(n);let a=(i=r,s={name:n.name,message:"string"==typeof n.message?n.message:""},e?.includeStack&&"string"==typeof n.stack&&(s.stack=n.stack),e?.excludeCause||void 0===n.cause||(s.cause=i(n.cause)),s);return t.delete(n),a}try{let e=(0,o.IB)(n);return void 0===e?(0,o.GP)(n):JSON.parse(e)}catch{return(0,o.GP)(n)}})})},yd:P})},2672(e,t,r){var n=r(1136);n.kWD,n.obm;let i=n.DLK;n.RWE;let s=n.d97,a=n.AAo,o=n.Uio,l=n.iLB;n.Z$R;let c=n.pSt,u=n.vDJ;n.fou,n.mdu,r.d(t,{},{Fp:c,Gt:a,HG:i,LZ:s,U9:l,VN:u,a6:o})},755(e,t,r){let n,i;var s=r(8619),a=r(4650),o=r(3833);let l="effect/Tracer/ParentSpan";class c extends s.kl()(l){}let u=s.Or("effect/Tracer/DisablePropagation",{defaultValue:a.f4}),d=s.Or("effect/Tracer/CurrentTraceLevel",{defaultValue:()=>"Info"}),f=s.Or("effect/Tracer/MinimumTraceLevel",{defaultValue:()=>"All"}),h="effect/Tracer",p=s.Or(h,{defaultValue:()=>({span:e=>new m(e)})});class m{_tag="Span";spanId;traceId="native";sampled;name;parent;annotations;links;startTime;kind;status;attributes;events=[];constructor(e){this.name=e.name,this.parent=e.parent,this.annotations=e.annotations,this.links=e.links,this.startTime=e.startTime,this.kind=e.kind,this.sampled=e.sampled,this.status={_tag:"Started",startTime:e.startTime},this.attributes=new Map,this.traceId=o.getOrUndefined(e.parent)?.traceId??g(32),this.spanId=g(16)}end(e,t){this.status={_tag:"Ended",endTime:e,exit:t,startTime:this.status.startTime}}attribute(e,t){this.attributes.set(e,t)}event(e,t,r){this.events.push([e,t,r??{}])}addLinks(e){this.links.push(...e)}}let g=(i=(n="abcdef0123456789").length,function(e){let t="";for(let r=0;r<e;r++)t+=n.charAt(Math.floor(Math.random()*i));return t});r.d(t,{Tv:()=>c,W1:()=>m},{DW:u,EW:f,RL:h,WG:l,pX:d,sh:p})},3537(e,t,r){let n,i;class s{called=!1;self;constructor(e){this.self=e}next(e){return this.called?{value:e,done:!0}:(this.called=!0,{value:this.self,done:!1})}[Symbol.iterator](){return new s(this.self)}}let a=(i={[n="~effect/Utils/internal"]:e=>e()},i[n](()=>Error().stack)?.includes(n)===!0?i[n]:({[n]:e=>e()})[n]);r.d(t,{B:()=>s},{s:a})},8433(e,t,r){let n;var i=r(8036),s=r(6470),a=r(4650),o=r(4450),l=r(6400),c=r(9138),u=r(5369),d=r(3537);let f="~effect/Effect",h="~effect/Exit",p={_A:a.D_,_E:a.D_,_R:a.D_},m=`${f}/identifier`,g=`${f}/args`,y=`${f}/evaluate`,b=`${f}/successCont`,v=`${f}/failureCont`,w=`${f}/ensureCont`,x=Symbol.for("effect/Effect/Yield"),k={pipe(){return(0,c.tT)(this,arguments)},toJSON(){return{...this}},toString(){return(0,s.GP)(this.toJSON(),{ignoreToString:!0,space:2})},[l.FX](){return this.toJSON()}},S={[o.HR](){return o.uN(this,Object.keys(this))},[i.HR](e){let t=Object.keys(this),r=Object.keys(e);if(t.length!==r.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==r[n]||!i.aI(this[t[n]],e[t[n]]))return!1;return!0}},_={[f]:p,...k,[Symbol.iterator](){return new d.B(this)},toJSON(){return{_id:"Effect",op:this[m],...g in this?{args:this[g]}:void 0}}},O=e=>(0,u.i5)(e,h),I="~effect/Cause",$="~effect/Cause/Reason",E=e=>(0,u.i5)(e,I);class C{[I];reasons;constructor(e){this[I]=I,this.reasons=e}pipe(){return(0,c.tT)(this,arguments)}toJSON(){return{_id:"Cause",failures:this.reasons.map(e=>e.toJSON())}}toString(){return`Cause(${(0,s.GP)(this.reasons)})`}[l.FX](){return this.toJSON()}[i.HR](e){return E(e)&&this.reasons.length===e.reasons.length&&this.reasons.every((t,r)=>i.aI(t,e.reasons[r]))}[o.HR](){return o.YO(this.reasons)}}let A=new WeakMap;class T{[$];annotations;_tag;constructor(e,t,r){if(this[$]=$,this._tag=e,t!==N&&"object"==typeof r&&null!==r&&t.size>0){let e=A.get(r);e&&(t=new Map([...e,...t])),A.set(r,t)}this.annotations=t}annotate(e,t){if(0===e.mapUnsafe.size)return this;let r=new Map(this.annotations);e.mapUnsafe.forEach((e,n)=>{t?.overwrite!==!0&&r.has(n)||r.set(n,e)});let n=Object.assign(Object.create(Object.getPrototypeOf(this)),this);return n.annotations=r,n}pipe(){return(0,c.tT)(this,arguments)}toString(){return(0,s.GP)(this)}[l.FX](){return this.toString()}}let N=new Map;class M extends T{error;constructor(e,t=N){super("Fail",t,e),this.error=e}toString(){return`Fail(${(0,s.GP)(this.error)})`}toJSON(){return{_tag:"Fail",error:this.error}}[i.HR](e){return R(e)&&i.aI(this.error,e.error)&&i.aI(this.annotations,e.annotations)}[o.HR](){return o.kg(o.Yj(this._tag))(o.kg(o.tW(this.error))(o.tW(this.annotations)))}}let P=new C([]),j=e=>new C([new M(e)]);class D extends T{defect;constructor(e,t=N){super("Die",t,e),this.defect=e}toString(){return`Die(${(0,s.GP)(this.defect)})`}toJSON(){return{_tag:"Die",defect:this.defect}}[i.HR](e){return U(e)&&i.aI(this.defect,e.defect)&&i.aI(this.annotations,e.annotations)}[o.HR](){return o.kg(o.Yj(this._tag))(o.kg(o.tW(this.defect))(o.tW(this.annotations)))}}let F=e=>new C([new D(e)]),L=(0,a.XY)(e=>E(e[0]),(e,t,r)=>0===t.mapUnsafe.size?e:new C(e.reasons.map(e=>e.annotate(t,r)))),R=e=>"Fail"===e._tag,U=e=>"Die"===e._tag;function B(e){return G("Effect.evaluate: Not implemented")}let Y=e=>({..._,[m]:e.op,[y]:e[y]??B,[b]:e[b],[v]:e[v],[w]:e[w]}),X=e=>{let t=Y(e);return function(){let r=Object.create(t);return r[g]=!1===e.single?arguments:arguments[0],r}},W=e=>{let t={...Y(e),[h]:h,_tag:e.op,get[e.prop](){return this[g]},toString(){return`${e.op}(${(0,s.GP)(this[g])})`},toJSON(){return{_id:"Exit",_tag:e.op,[e.prop]:this[g]}},[i.HR](e){return O(e)&&e._tag===this._tag&&i.aI(this[g],e[g])},[o.HR](){return o.kg(o.Yj(e.op),o.tW(this[g]))}};return function(e){let r=Object.create(t);return r[g]=e,r}},J=W({op:"Success",prop:"value",[y](e){let t=e.getCont(b);return t?t[b](this[g],e,this):e.yieldWith(this)}}),q={key:"effect/Cause/StackTrace"},K=W({op:"Failure",prop:"cause",[y](e){let t=this[g],r=!1;e.currentStackFrame&&(t=L(t,{mapUnsafe:new Map([[q.key,e.currentStackFrame]])}),r=!0);let n=e.getCont(v);for(;e.interruptible&&e._interruptedCause&&n;)n=e.getCont(v);return n?n[v](t,e,r?void 0:this):e.yieldWith(r?this:K(t))}}),V=e=>K(j(e)),G=e=>K(F(e)),H=X({op:"WithFiber",[y](e){return this[g](e)}}),z=function(){class e extends globalThis.Error{}let t=Y({op:"YieldableError",[y](){return V(this)}});return delete t.toString,Object.assign(e.prototype,t),e}(),Q=(n=Symbol.for("effect/Data/Error/plainArgs"),class extends z{constructor(e){super(e?.message,e?.cause?{cause:e.cause}:void 0),e&&(Object.assign(this,e),Object.defineProperty(this,n,{value:e,enumerable:!1}))}toJSON(){return{...this[n],...this}}}),Z=e=>{class t extends Q{_tag=e}return t.prototype.name=e,t},ee="~effect/Cause/NoSuchElementError";class et extends Z("NoSuchElementError"){[ee]=ee;constructor(e){super({message:e})}}let er="~effect/Cause/Done",en={[er]:er,_tag:"Done",value:void 0},ei=e=>void 0===e?en:{[er]:er,_tag:"Done",value:e},es=V(en);r.d(t,{ET:()=>T,Xm:()=>et,dM:()=>M,s0:()=>C},{$D:Q,$L:e=>(0,u.i5)(e,er),$n:f,Aj:E,B4:$,DH:P,Eh:L,GN:x,IH:h,In:S,Iu:F,OE:j,PW:e=>(0,u.i5)(e,ee),PX:I,QJ:{key:"effect/Cause/InterruptorStackTrace"},R6:H,RS:ei,Rk:V,Sc:v,Uf:X,V2:G,Vw:e=>void 0===e?es:V(ei(e)),Wg:e=>(0,u.i5)(e,$),Xb:U,_3:y,a2:g,b5:e=>new C(e),b9:O,cb:K,dO:N,ee:b,fU:k,ik:e=>"Interrupt"===e._tag,lC:R,qB:ee,q_:er,rN:Z,u4:w,xt:J,yj:Y,yw:e=>(0,u.i5)(e,f),z8:q})},2849(e,t,r){var n=r(4650);r.d(t,{},{Jr:e=>(0,n.XY)(2,(t,r)=>e(t,e=>({[r]:e}))),oI:(e,t)=>(0,n.XY)(3,(r,n,i)=>t(r,t=>e(i(t),e=>({...t,[n]:e})))),zM:e=>(0,n.XY)(3,(t,r,n)=>e(t,e=>({...e,[r]:n(e)})))})},1136(e,t,r){let n,i,s;r.d(t,{RD4:()=>i2,cOF:()=>i0,a1U:()=>iD,z4N:()=>i8,d$_:()=>i7,Do:()=>nK,Aub:()=>iZ,F7W:()=>iz,qwd:()=>iH,t8c:()=>iV,LkF:()=>i9,olX:()=>se,obm:()=>rV,kWD:()=>rK,MUS:()=>iK,DQo:()=>iJ,Bk6:()=>i6,Kkt:()=>i3,dsN:()=>n$,N24:()=>nm,Q56:()=>nn,jGc:()=>np,U9h:()=>ni,Q7R:()=>nE,hgn:()=>tr,ww9:()=>iM,gsV:()=>st,Muk:()=>iN,as:()=>e7,Xx$:()=>te,NLW:()=>ti,PCg:()=>n0,oIE:()=>nG,JrD:()=>nV,PO3:()=>nb,CJw:()=>ng,Rgn:()=>ny,E2r:()=>eQ,Tyx:()=>rt,rNk:()=>ri,sJf:()=>rn,Fig:()=>ro,UVN:()=>tw,osR:()=>rm,XWm:()=>rp,U9Y:()=>ra,AXC:()=>rb,zt4:()=>rv,KuX:()=>rg,loE:()=>ry,h_t:()=>rs,On5:()=>H,h2c:()=>z,Bou:()=>J,nIy:()=>j,h74:()=>q,O$X:()=>Q,GyP:()=>el,RJ6:()=>ee,ReC:()=>Z,RKA:()=>iB,_OA:()=>tG,sxi:()=>tz,Wj8:()=>ij,_32:()=>iP,Rud:()=>iX,s0X:()=>iW,cbG:()=>rY,F_Q:()=>eB,OY:()=>th,yeE:()=>no,u4Y:()=>rI,NS5:()=>rL,Hox:()=>tU,ely:()=>tB,yJo:()=>t$,HIt:()=>tI,K$2:()=>tS,GUt:()=>t_,jCT:()=>tC,_OD:()=>tE,lgw:()=>tW,Sv3:()=>tX,kMI:()=>tY,YDM:()=>tT,_mh:()=>tN,lNM:()=>tA,_sz:()=>tx,VE1:()=>tO,CoE:()=>tk,v9O:()=>tP,EkE:()=>tD,zPu:()=>tj,Wtn:()=>tR,x5l:()=>tM,il9:()=>tL,fJG:()=>eC,ATB:()=>eE,pVV:()=>eU,gOk:()=>eY,pEE:()=>eV,zFM:()=>ev,C6p:()=>ew,ABT:()=>eG,mKq:()=>eS,DKo:()=>eO,$MQ:()=>eI,eGS:()=>e_,D7p:()=>ex,INJ:()=>ek,vTQ:()=>n5,pbD:()=>nW,x1Q:()=>nJ,E8K:()=>nq,VtY:()=>nY,ahH:()=>nX,Pm0:()=>nB,W$I:()=>t8,BbX:()=>Y,k7S:()=>B,khU:()=>L,L$u:()=>R,QE5:()=>F,i8i:()=>nT,kAe:()=>nM,tU5:()=>W,Dd:()=>rO,qIB:()=>tu,Ab9:()=>tp,Bqz:()=>tm,UUz:()=>tt,fn:()=>e5,D9k:()=>e1,vCS:()=>e8,jJl:()=>nD,i4r:()=>re,zhn:()=>nz,yxg:()=>nZ,ar0:()=>n1,x6Z:()=>n2,bJ:()=>eP,sVm:()=>eN,yUA:()=>eM,JkU:()=>e0,Iku:()=>ep,gpn:()=>U,myX:()=>D,prj:()=>X,nn5:()=>V,XeO:()=>r$,GrF:()=>rE,GaK:()=>nv,Inz:()=>n_,eMl:()=>nI,Rft:()=>i1,ASO:()=>iQ,N6O:()=>rU,_y:()=>iG,OPA:()=>i4,oJd:()=>rB,c8t:()=>iq,PnV:()=>i5,h$X:()=>nR,uVU:()=>nH,A_r:()=>iI,lIX:()=>ss,ORc:()=>P,Fbb:()=>id,zzk:()=>iu,Z98:()=>ix,Rd$:()=>ik,TjK:()=>tg,UcN:()=>rk,q7Y:()=>tv,jkJ:()=>ty,xm_:()=>rx,Z9x:()=>tb,YWq:()=>rj,D$$:()=>rM,NZb:()=>rF,khu:()=>rT,wR5:()=>tf,G$Q:()=>rD,tvg:()=>rP,ZmZ:()=>eZ,S5A:()=>nu,iKM:()=>nf,BeE:()=>nd,cfM:()=>na,uRq:()=>nc,fGe:()=>nl,r7h:()=>ns,nAr:()=>nh,uKv:()=>rC,QgK:()=>rS,DM4:()=>r_,jBG:()=>nC,ivC:()=>eJ,PpN:()=>tZ,AAo:()=>r7,PfK:()=>t0,c7E:()=>t2,O4F:()=>tl,Vdx:()=>ta,FfP:()=>to,KT6:()=>tc,tQ6:()=>G,aAq:()=>t4,Xrv:()=>t7,Ket:()=>rA,bPG:()=>n9,lSz:()=>n8,MY7:()=>n6,eJC:()=>n3,pR5:()=>it,NpQ:()=>n7,jqV:()=>n4,v2Q:()=>ie,HZF:()=>ia,lKS:()=>ii,rfH:()=>ir,lE:()=>is,_Sg:()=>ts,z8E:()=>r4,iLB:()=>r2,Uio:()=>r1,vDJ:()=>rH,fou:()=>rz,Z$R:()=>rZ,pSt:()=>r0,RWE:()=>r9,d97:()=>r6,DLK:()=>rG,mdu:()=>nt,P1j:()=>ne,Pxi:()=>nr,euC:()=>tJ,Nav:()=>tq,oao:()=>tQ,yy4:()=>iY,Fu6:()=>i_,WbR:()=>iO,PyW:()=>e$,lwU:()=>eL,nGE:()=>eF,DYE:()=>eT,OH5:()=>eA,Mim:()=>tn,dGm:()=>rl,bKC:()=>ru,cA6:()=>rc,nAi:()=>rh,sFT:()=>rd,k$L:()=>rf,ayu:()=>rq,wRz:()=>rW,D52:()=>rJ,mgX:()=>rX,kJM:()=>ih,pkL:()=>eR,SvU:()=>eW,$mh:()=>eq,Vxk:()=>sl,rfi:()=>nw,FcF:()=>nO,scW:()=>rw,r_d:()=>tK,bUZ:()=>tV,gvr:()=>iE,tfT:()=>nA,rIH:()=>eX,z7s:()=>t9,iMI:()=>nj,KyM:()=>t3,$$g:()=>sc,hq:()=>iA,fRP:()=>iT,zr8:()=>iS,_o1:()=>ip,nDN:()=>im,MaT:()=>ig,m9E:()=>eD,KN3:()=>ej,yU6:()=>t5,OYO:()=>t6});var a=r(8927),o=r(8619),l=r(2302),c=r(8036),u=r(956),d=r(6470),f=r(4650),h=r(4450),p=r(6400),m=r(8496),g=r(3833),y=r(6364),b=r(9138),v=r(5369),w=r(1743),x=r(995),k=r(8469),S=r(755),_=r(3537),O=r(8433),I=r(2849),$=r(9354),E=r(8344),C=r(3628);let A=e=>{if(e?.captureStackTrace===!1||e?.captureStackTrace!==void 0&&"boolean"!=typeof e.captureStackTrace)return e;let t=(0,C.jt)();(0,C.ft)(3);let r=Error();return(0,C.ft)(t),{...e,captureStackTrace:N(()=>r.stack)}},T=e=>t=>{let r;return()=>{if(void 0!==r)return r;let n=t();if(!n)return;let i=n.split("\n");if(void 0!==i[e])return r=i[e].trim()}},N=T(3);class M extends O.ET{fiberId;constructor(e,t=O.dO){super("Interrupt",t,"Interrupted"),this.fiberId=e}toString(){return`Interrupt(${this.fiberId})`}toJSON(){return{_tag:"Interrupt",fiberId:this.fiberId}}[c.HR](e){return(0,O.ik)(e)&&this.fiberId===e.fiberId&&this.annotations===e.annotations}[h.HR](){return h.kg(h.Yj(`${this._tag}:${this.fiberId}`))(h.yT(this.annotations))}}let P=e=>new M(e),j=e=>new O.s0([new M(e)]),D=e=>e.reasons.some(O.lC),F=e=>{let t=e.reasons.find(O.lC);return t?x.Py(t):x.fJ(e)},L=e=>{for(let t=0;t<e.reasons.length;t++){let r=e.reasons[t];if("Fail"===r._tag)return x.Py(r.error)}return x.fJ(e)},R=u.zL(L),U=e=>e.reasons.some(O.Xb),B=e=>{let t=e.reasons.find(O.Xb);return t?x.Py(t):x.fJ(e)},Y=e=>{let t=e.reasons.find(O.Xb);return t?x.Py(t.defect):x.fJ(e)},X=e=>e.reasons.some(O.ik),W=e=>{let t=e.reasons.find(O.ik);return t?x.Py(t):x.fJ(e)},J=e=>{let t;for(let r=0;r<e.reasons.length;r++){let n=e.reasons[r];"Interrupt"===n._tag&&(t??=new Set,void 0!==n.fiberId&&t.add(n.fiberId))}return t?x.Py(t):x.fJ(e)},q=e=>{let t=J(e);return x.N6(t)?K:t.success},K=new Set,V=e=>e.reasons.length>0&&e.reasons.every(O.ik),G=e=>o.LZ(e.annotations),H=e=>{let t=new Map;for(let r of e.reasons)if(r.annotations.size>0)for(let[e,n]of r.annotations)t.set(e,n);return o.LZ(t)},z=(0,f.XY)(2,(e,t)=>{if(0===e.reasons.length)return t;if(0===t.reasons.length)return e;let r=new O.s0(a.KC(e.reasons,t.reasons));return c.aI(e,r)?e:r}),Q=(0,f.XY)(2,(e,t)=>{let r=!1,n=e.reasons.map(e=>(0,O.lC)(e)?(r=!0,new O.dM(t(e.error))):e);return r?(0,O.b5)(n):e}),Z=e=>{let t=(e=>{let t={Fail:[],Die:[],Interrupt:[]};for(let r=0;r<e.reasons.length;r++)t[e.reasons[r]._tag].push(e.reasons[r]);return t})(e);return t.Fail.length>0?t.Fail[0].error:t.Die.length>0?t.Die[0].defect:t.Interrupt.length>0?new globalThis.Error("All fibers interrupted without error"):new globalThis.Error("Empty cause")},ee=(e,t)=>{let r=[],n=[];if(0===e.reasons.length)return r;let i=(0,C.jt)();for(let i of((0,C.ft)(1),e.reasons)){if("Interrupt"===i._tag){n.push(i);continue}r.push(et("Die"===i._tag?i.defect:i.error,i.annotations,t))}if(0===r.length){let e=Error("The fiber was interrupted by:");e.name="InterruptCause",e.stack=ea(e,n);let i=new globalThis.Error("All fibers interrupted without error",{cause:e});i.name="InterruptError",i.stack=`${i.name}: ${i.message}`,r.push(et(i,n[0].annotations,t))}return(0,C.ft)(i),r},et=(e,t,r)=>{let n,i=typeof e;if(e&&"object"===i){if(n=new globalThis.Error(er(e),{cause:e.cause?et(e.cause):void 0}),"string"==typeof e.name&&(n.name=e.name),"string"==typeof e.stack)n.stack=ei(e.stack,n,t);else{let e=`${n.name}: ${n.message}`;n.stack=t?es(e,t):e}for(let t of(r?.includeCauseInStack&&(n.stack=ec(n)),Object.keys(e)))t in n||(n[t]=e[t])}else n=new globalThis.Error(!e?`Unknown error: ${e}`:"string"===i?e:(0,d.IB)(e));return n},er=e=>{if("string"==typeof e.message)return e.message;if("function"==typeof e.toString&&e.toString!==Object.prototype.toString&&e.toString!==Array.prototype.toString)try{return e.toString()}catch{}return(0,d.IB)(e)},en=/\((.*)\)/g,ei=(e,t,r)=>{let n=`${t.name}: ${t.message}`,i=(e.startsWith(n)?e.slice(n.length):e).split("\n"),s=[n];for(let e=1;e<i.length&&!/(?:Generator\.next|~effect\/Effect)/.test(i[e]);e++)s.push(i[e]);return r?es(s.join("\n"),r):s.join("\n")},es=(e,t)=>{let r=t?.get(O.z8.key);return r&&(e=`${e}
128
+ ${eo(r)}`),e},ea=(e,t)=>{let r=[`${e.name}: ${e.message}`];for(let e of t){let t=void 0!==e.fiberId?`#${e.fiberId}`:"unknown",n=e.annotations.get(O.QJ.key);r.push(` at fiber (${t})`),n&&r.push(eo(n))}return r.join("\n")},eo=e=>{let t=[],r=e,n=0;for(;r&&n<10;){let e=r.stack();if(e){let n=e.matchAll(en),i=!1;for(let[,e]of n)i=!0,t.push(` at ${r.name} (${e})`);i||t.push(` at ${r.name} (${e.replace(/^at /,"")})`)}else t.push(` at ${r.name}`);r=r.parent,n++}return t.join("\n")},el=e=>ee(e).map(ec).join("\n"),ec=e=>e.cause?`${e.stack} {
129
+ ${eu(e.cause," ")}
130
+ }`:e.stack,eu=(e,t)=>{let r=e.stack.split("\n"),n=`${t}[cause]: ${r[0]}`;for(let e=1,i=r.length;e<i;e++)n+=`
131
+ ${t}${r[e]}`;return e.cause&&(n+=` {
132
+ ${eu(e.cause,`${t} `)}
133
+ ${t}}`),n},ed="~effect/Fiber/dev",ef={_A:f.D_,_E:f.D_},eh={id:0},ep=()=>globalThis[w.fL];class em{constructor(e,t=!0){this[ed]=ef,this.setContext(e),this.id=++eh.id,this.currentOpCount=0,this.currentLoopCount=0,this.interruptible=t,this._stack=[],this._observers=[],this._exit=void 0,this._children=void 0,this._interruptedCause=void 0,this._yielded=void 0,this.runtimeMetrics?.recordFiberStart(this.context)}[ed];id;interruptible;currentOpCount;currentLoopCount;_stack;_observers;_exit;_currentExit;_children;_interruptedCause;_yielded;context;currentScheduler;currentTracerContext;currentSpan;currentLogLevel;minimumLogLevel;currentStackFrame;runtimeMetrics;maxOpsBeforeYield;currentPreventYield;_dispatcher=void 0;get currentDispatcher(){return this._dispatcher??=this.currentScheduler.makeDispatcher()}getRef(e){return o.kA(this.context,e)}addObserver(e){return this._exit?(e(this._exit),f.Yi):(this._observers.push(e),()=>{let t=this._observers.indexOf(e);t>=0&&this._observers.splice(t,1)})}interruptUnsafe(e,t){if(this._exit)return;let r=j(e);this.currentStackFrame&&(r=(0,O.Eh)(r,o.L8(O.z8,this.currentStackFrame))),t&&(r=(0,O.Eh)(r,t)),this._interruptedCause=this._interruptedCause?z(this._interruptedCause,r):r,this.interruptible&&this.evaluate(eE(this._interruptedCause))}pollUnsafe(){return this._exit}evaluate(e){if(this._exit)return;if(void 0!==this._yielded){let e=this._yielded;this._yielded=void 0,e()}let t=this.runLoop(e);if(t===O.GN)return;let r=eg.interruptChildren&&eg.interruptChildren(this);if(void 0!==r)return this.evaluate(tu(r,()=>t));this._exit=t,this.runtimeMetrics?.recordFiberEnd(this.context,this._exit);for(let e=0;e<this._observers.length;e++)this._observers[e](t);this._observers.length=0}runLoop(e){let t=globalThis[w.fL];globalThis[w.fL]=this;let r=!1,n=e;this.currentOpCount=0;let i=++this.currentLoopCount;try{for(;;){if(this.currentOpCount++,!r&&!this.currentPreventYield&&this.currentScheduler.shouldYield(this)){r=!0;let e=n;n=tu(eD,()=>e)}if(n=this.currentTracerContext?this.currentTracerContext(n,this):n[O._3](this),i!==this.currentLoopCount)return O.GN;if(n===O.GN){let e=this._yielded;if(O.IH in e)return this._yielded=void 0,e;return O.GN}}}catch(e){if(!(0,v.i5)(n,O._3))return(0,O.V2)(`Fiber.runLoop: Not a valid effect: ${String(n)}`);return this.runLoop((0,O.V2)(e))}finally{globalThis[w.fL]=t}}getCont(e){for(;;){let t=this._stack.pop();if(!t)return;let r=t[O.u4]&&t[O.u4](this);if(r)return r[e]=r,r;if(t[e])return t}}yieldWith(e){return this._yielded=e,O.GN}children(){return this._children??=new Set}pipe(){return(0,b.tT)(this,arguments)}setContext(e){this.context=e;let t=this.getRef(k._F);t!==this.currentScheduler&&(this.currentScheduler=t,this._dispatcher=void 0),this.currentSpan=e.mapUnsafe.get(S.WG),this.currentLogLevel=this.getRef(E.Gl),this.minimumLogLevel=this.getRef(E.zQ),this.currentStackFrame=e.mapUnsafe.get(E.vA.key),this.maxOpsBeforeYield=this.getRef(k.Zm),this.currentPreventYield=this.getRef(k.hf),this.runtimeMetrics=e.mapUnsafe.get($.F);let r=e.mapUnsafe.get(S.RL);this.currentTracerContext=r?r.context:void 0}get currentSpanLocal(){return this.currentSpan?._tag==="Span"?this.currentSpan:void 0}}let eg={interruptChildren:void 0},ey=e=>{if(!e.currentStackFrame)return;let t=new Map;return t.set(O.z8.key,e.currentStackFrame),o.LZ(t)},eb=e=>{if(void 0!==e._children&&0!==e._children.size)return eO(e._children)},ev=e=>e._exit?e$(e._exit):eQ(t=>e._exit?t(e$(e._exit)):eA(e.addObserver(e=>t(e$(e))))),ew=e=>eQ(t=>{let r,n=e[Symbol.iterator](),i=[];return!function e(){let s=n.next();for(;!s.done;){if(s.value._exit){i.push(s.value._exit),s=n.next();continue}r=s.value.addObserver(t=>{i.push(t),e()});return}t(e$(i))}(),eA(()=>r?.())}),ex=e=>e._exit?e._exit:eQ(t=>e._exit?t(e._exit):eA(e.addObserver(t))),ek=e=>eQ(t=>{let r=Array.from(e);if(0===r.length)return t(e$(a.Ie()));let n=Array(r.length),i=a.Ie(),s=0,o=!1;for(let e=0;e<r.length&&!o;e++)i.push(r[e].addObserver(a=>{if(s++,"Failure"===a._tag)return o=!0,i.forEach(e=>e()),t(a);n[e]=a.value,s===r.length&&t(e$(n))}))}),eS=e=>(0,O.R6)(t=>e_(e,t.id)),e_=(0,f.XY)(e=>(0,v.i5)(e[0],ed),(e,t,r)=>(0,O.R6)(n=>{let i=ey(n);return i=i&&r?o.h1(i,r):i??r,e.interruptUnsafe(t,i),ti(ev(e))})),eO=e=>(0,O.R6)(t=>{let r=ey(t),n=a.Ie();for(let i of e)i.interruptUnsafe(t.id,r),n.push(i);return ti(ew(n))}),eI=(0,f.XY)(2,(e,t)=>(0,O.R6)(r=>{let n=ey(r),i=a.Ie();for(let r of e)r.interruptUnsafe(t,n),i.push(r);return ti(ew(i))})),e$=O.xt,eE=O.cb,eC=O.Rk,eA=(0,O.Uf)({op:"Sync",[O._3](e){let t=this[O.a2](),r=e.getCont(O.ee);return r?r[O.ee](t,e):e.yieldWith((0,O.xt)(t))}}),eT=(0,O.Uf)({op:"Suspend",[O._3](e){return this[O.a2]()}}),eN=(0,f.XY)(e=>e.length>=2||g.isOption(e[0]),(e,t)=>g.isNone(e)?eC(t?t():new O.Xm("Effect.fromOption: Option.none")):e$(e.value)),eM=x.YW({onFailure:eC,onSuccess:e$}),eP=e=>null==e?eC(new O.Xm):e$(e),ej=(0,O.Uf)({op:"Yield",[O._3](e){let t=!1;return e.currentDispatcher.scheduleTask(()=>{t||e.evaluate(tM)},this[O.a2]??0),e.yieldWith(()=>{t=!0})}}),eD=ej(0),eF=e=>e$(g.some(e)),eL=e$(g.none()),eR=e=>g.isNone(e)?eL:tg(e.value,g.some),eU=e=>eT(()=>eE((0,_.s)(e))),eB=e=>(0,O.V2)(e),eY=e=>eT(()=>eC((0,_.s)(e))),eX=e$(void 0),eW=e=>{let t="function"==typeof e?e:e.try,r="function"==typeof e?e=>new i6(e,"An error occurred in Effect.try"):e.catch;return eT(()=>{try{return e$((0,_.s)(t))}catch(e){return eC((0,_.s)(()=>r(e)))}})},eJ=e=>eH(function(t,r){(0,_.s)(()=>e(r)).then(e=>t(e$(e)),e=>t(eB(e)))},0!==e.length),eq=e=>{let t="function"==typeof e?e:e.try,r="function"==typeof e?e=>new i6(e,"An error occurred in Effect.tryPromise"):e.catch;return eH(function(e,n){let i=t=>{try{e(eC((0,_.s)(()=>r(t))))}catch(t){e(eB(t))}};try{(0,_.s)(()=>t(n)).then(t=>e(e$(t)),i)}catch(e){i(e)}},0!==t.length)},eK=e=>(0,O.R6)(t=>e(t.id)),eV=(0,O.R6)(e$),eG=eK(e$),eH=(0,O.Uf)({op:"Async",single:!1,[O._3](e){let t=(0,_.s)(()=>this[O.a2][0].bind(e.currentScheduler)),r=!1,n=!1,i=this[O.a2][1]?new AbortController:void 0,s=t(t=>{r||(r=!0,n?e.evaluate(t):n=t)},i?.signal);return!1!==n?n:(n=!0,e._yielded=()=>{r=!0},void 0===i&&void 0===s||e._stack.push(ez(()=>(r=!0,i?.abort(),s??tM))),O.GN)}}),ez=(0,O.Uf)({op:"AsyncFinalizer",[O.u4](e){e.interruptible&&(e.interruptible=!1,e._stack.push(nk))},[O.Sc](e,t){return X(e)?tu(this[O.a2](),()=>eE(e)):eE(e)}}),eQ=e=>eH(e,e.length>=2),eZ=eQ(f.Yi),e0=(...e)=>eT(()=>e4(1===e.length?e[0]():e[1].call(e[0].self))),e1=(e,...t)=>{let r=0===t.length?function(){return eT(()=>e4(e.apply(this,arguments)))}:function(){let r=eT(()=>e4(e.apply(this,arguments)));for(let e=0;e<t.length;e++)r=t[e](r,...arguments);return r};return e2(e.length,r)},e2=(e,t)=>Object.defineProperty(t,"length",{value:e,configurable:!0}),e3=T(2),e5=function(){let e="string"==typeof arguments[0],t=e?arguments[0]:"Effect.fn",r=e?arguments[1]:void 0,n=(0,C.jt)();(0,C.ft)(2);let i=new globalThis.Error;return((0,C.ft)(n),e)?(n,...s)=>e6(t,n,i,s,e,r):e6(t,arguments[0],i,Array.prototype.slice.call(arguments,1),e,r)},e6=(e,t,r,n,i,s)=>{let a="function"==typeof t?t:n.pop().bind(t.self);return e2(a.length,function(...t){let o=eT(()=>{let e=a.apply(this,arguments);return(0,O.yw)(e)?e:e4(e)});for(let e=0;e<n.length;e++)o=n[e](o,...t);if(!(0,O.yw)(o))return o;let l=(0,C.jt)();(0,C.ft)(2);let c=new globalThis.Error;return(0,C.ft)(l),tV(i?iE(e,s,e=>iC(o,e)):o,E.vA,t=>({name:e,stack:e3(()=>c.stack),parent:{name:`${e} (definition)`,stack:e3(()=>r.stack),parent:t}}))})},e8=(e,...t)=>e2(e.length,0===t.length?function(){return e9(()=>e.apply(this,arguments))}:function(){let r=e9(()=>e.apply(this,arguments));for(let e of t)r=e(r);return r}),e9=e=>{try{let t,r=e();for(;;){let n=r.next(t);if(n.done)return e$(n.value);let i=n.value;if(i&&"Success"===i._tag){t=i.value;continue}{if(i&&"Failure"===i._tag)return n.value;let t=!0;return eT(()=>t?(t=!1,tu(n.value,e=>e4(r,e))):eT(()=>e4(e())))}}}catch(e){return eB(e)}},e4=(0,O.Uf)({op:"Iterator",single:!1,[O.ee](e,t){let r=this[O.a2][0];for(;;){let n=r.next(e);if(n.done)return e$(n.value);if(!th(n.value))return t._stack.push(this),n.value;if("Failure"===n.value._tag)return n.value;e=n.value.value}},[O._3](e){return this[O.ee](this[O.a2][1],e)}}),e7=(0,f.XY)(2,(e,t)=>{let r=e$(t);return tu(e,e=>r)}),te=e=>tg(e,g.some),tt=e=>rP(e,{onFailure:e$,onSuccess:eC}),tr=(0,f.XY)(2,(e,t)=>tu(e,e=>(0,O.yw)(t)?t:(0,_.s)(()=>t(e)))),tn=(0,f.XY)(2,(e,t)=>tu(e,e=>e7((0,O.yw)(t)?t:(0,_.s)(()=>t(e)),e))),ti=e=>tu(e,e=>tM),ts=e=>rt(e,eC),ta=(e,t)=>(0,O.R6)(r=>eQ(n=>{let i=a.Ts(e),s=i.length,o=0,l=!1,c=new Set,u=[],d=(e,i,a)=>{if(o++,"Failure"===e._tag){u.push(...e.cause.reasons),o>=s&&n(eE((0,O.b5)(u)));return}let d=!l;l=!0,n(0===c.size?e:tu(nw(eO(c)),()=>e)),d&&t?.onWinner&&t.onWinner({fiber:i,index:a,parentFiber:r})};for(let e=0;e<s;e++){let t=nQ(r,i[e],!0,!0,!1);if(c.add(t),t.addObserver(r=>{c.delete(t),d(r,t,e)}),l)break}return eO(c)})),to=(e,t)=>(0,O.R6)(r=>eQ(n=>{let i=!1,s=new Set,a=e=>{i=!0,n(0===s.size?e:tu(nw(eO(s)),()=>e))},o=0;for(let n of e){if(i)break;let e=o++,l=nQ(r,n,!0,!0,!1);s.add(l),l.addObserver(n=>{s.delete(l);let o=!i;a(n),o&&t?.onWinner&&t.onWinner({fiber:l,index:e,parentFiber:r})})}return eO(s)})),tl=(0,f.XY)(e=>(0,O.yw)(e[1]),(e,t,r)=>ta([e,t],r)),tc=(0,f.XY)(e=>(0,O.yw)(e[1]),(e,t,r)=>to([e,t],r)),tu=(0,f.XY)(2,(e,t)=>{let r=Object.create(td);return r[O.a2]=e,r[O.ee]=1!==t.length?e=>t(e):t,r}),td=(0,O.yj)({op:"OnSuccess",[O._3](e){return e._stack.push(this),this[O.a2]}}),tf=(0,f.XY)(2,(e,t)=>th(e)?"Success"===e._tag?t.onSuccess(e.value):t.onFailure(e.cause):rT(e,t)),th=e=>O.IH in e,tp=(0,f.XY)(2,(e,t)=>th(e)?"Success"===e._tag?t(e.value):e:tu(e,t)),tm=e=>tu(e,f.D_),tg=(0,f.XY)(2,(e,t)=>tu(e,e=>e$((0,_.s)(()=>t(e))))),ty=(0,f.XY)(2,(e,t)=>th(e)?tP(e,t):tg(e,t)),tb=(0,f.XY)(2,(e,t)=>th(e)?tj(e,t):rx(e,t)),tv=(0,f.XY)(2,(e,t)=>th(e)?tD(e,t):rk(e,t)),tw=(0,f.XY)(2,(e,t)=>{if(th(e)){if("Success"===e._tag)return e;let r=L(e.cause);return x.N6(r)?e:t(r.success)}return rs(e,t)}),tx=e=>(0,O.cb)(j(e)),tk=e=>"Success"===e._tag,tS=e=>"Success"===e._tag?x.Py(e):x.fJ(e),t_=e=>"Success"===e._tag?x.Py(e.value):x.fJ(e),tO=e=>"Failure"===e._tag,tI=e=>"Failure"===e._tag?x.Py(e):x.fJ(e),t$=e=>"Failure"===e._tag?x.Py(e.cause):x.fJ(e),tE=u.Bh(t$,L),tC=u.Bh(t$,Y),tA=e=>"Failure"===e._tag&&X(e.cause),tT=e=>"Failure"===e._tag&&U(e.cause),tN=e=>"Failure"===e._tag&&D(e.cause),tM=(0,O.xt)(void 0),tP=(0,f.XY)(2,(e,t)=>"Success"===e._tag?(0,O.xt)(t(e.value)):e),tj=(0,f.XY)(2,(e,t)=>{if("Success"===e._tag)return e;let r=L(e.cause);return x.N6(r)?e:(0,O.Rk)(t(r.success))}),tD=(0,f.XY)(2,(e,t)=>{if("Success"===e._tag)return(0,O.xt)(t.onSuccess(e.value));let r=L(e.cause);return x.N6(r)?e:(0,O.Rk)(t.onFailure(r.success))}),tF=(0,f.XY)(2,(e,t)=>tk(e)?(0,O.xt)(t):e),tL=(0,f.XY)(2,(e,t)=>tk(e)?t:e),tR=(0,f.XY)(2,(e,t)=>tk(e)?t.onSuccess(e.value):t.onFailure(e.cause)),tU=tF(void 0),tB=e=>{let t=[];for(let r of e)"Failure"===r._tag&&t.push(...r.cause.reasons);return 0===t.length?tM:(0,O.cb)((0,O.b5)(t))},tY=e=>tk(e)?g.some(e.value):g.none(),tX=e=>tO(e)?g.some(e.cause):g.none(),tW=e=>{let t=tE(e);return x.N6(t)?g.none():g.some(t.success)},tJ=e=>e,tq=e=>(0,O.R6)(t=>e$(o.om(t.context,e))),tK=(0,f.XY)(2,(e,t)=>(0,O.R6)(r=>{let n=r.context,i=t(n);return n===i?e:(r.setContext(i),ns(e,()=>{r.setContext(n)}))})),tV=(0,f.XY)(3,(e,t,r)=>tK(e,e=>{let n=o.fp(e,t),i=r(n);return n===i?e:o.WQ(e,t,i)})),tG=()=>tH,tH=(0,O.R6)(e=>e$(e.context)),tz=e=>(0,O.R6)(t=>e(t.context)),tQ=(0,f.XY)(2,(e,t)=>tK(e,(0,f.dY)(t))),tZ=(0,f.XY)(2,(e,t)=>th(e)?e:tK(e,o.h1(t))),t0=function(){return 1==arguments.length?(0,f.XY)(2,(e,t)=>t1(e,arguments[0],t)):(0,f.XY)(3,(e,t,r)=>t1(e,t,r)).apply(this,arguments)},t1=(e,t,r)=>tK(e,e=>e.mapUnsafe.get(t.key)===r?e:o.WQ(e,t,r)),t2=(0,f.XY)(3,(e,t,r)=>tu(r,r=>t0(e,t,r))),t3=t0(E.F8),t5=(0,f.XY)(e=>(0,O.yw)(e[1]),(e,t,r)=>t6(e,t,(e,t)=>[e,t],r)),t6=(0,f.XY)(e=>(0,O.yw)(e[1]),(e,t,r,n)=>n?.concurrent?tg(nE([e,t],{concurrency:2}),([e,t])=>(0,_.s)(()=>r(e,t))):tu(e,e=>tg(t,t=>(0,_.s)(()=>r(e,t))))),t8=(0,f.XY)(e=>(0,O.yw)(e[0]),(e,t,r)=>nB(e,t,r?e=>eC(r(e)):()=>eC(new O.Xm))),t9=(0,f.XY)(2,(e,t)=>tu(t,t=>t?te(e):eL)),t4=(0,f.XY)(2,(e,t)=>Array.from({length:t},()=>e)),t7=(0,f.XY)(e=>(0,O.yw)(e[0]),(e,t,r)=>nE(t4(e,t),r)),re=(0,f.XY)(e=>(0,O.yw)(e[0]),(e,t)=>nj({while:f.ue,body:(0,f.dY)(t?.disableYield?e:tu(e,e=>eD)),step:f.Yi})),rt=(0,f.XY)(2,(e,t)=>{let r=Object.create(rr);return r[O.a2]=e,r[O.Sc]=1!==t.length?e=>t(e):t,r}),rr=(0,O.yj)({op:"OnFailure",[O._3](e){return e._stack.push(this),this[O.a2]}}),rn=(0,f.XY)(3,(e,t,r)=>rt(e,e=>t(e)?(0,_.s)(()=>r(e)):eE(e))),ri=(0,f.XY)(3,(e,t,r)=>rt(e,e=>{let n=t(e);return x.N6(n)?eE(n.failure):(0,_.s)(()=>r(n.success,e))})),rs=(0,f.XY)(2,(e,t)=>ri(e,L,e=>t(e))),ra=e=>rP(e,{onFailure:e=>(0,O.PW)(e)?eL:eC(e),onSuccess:eF}),ro=(0,f.XY)(2,(e,t)=>ri(e,Y,t)),rl=(0,f.XY)(2,(e,t)=>rt(e,e=>tr((0,_.s)(()=>t(e)),eE(e)))),rc=(0,f.XY)(3,(e,t,r)=>rn(e,t,e=>tr((0,_.s)(()=>r(e)),eE(e)))),ru=(0,f.XY)(3,(e,t,r)=>rt(e,e=>{let n=t(e);return x.N6(n)?eE(e):tr((0,_.s)(()=>r(n.success,e)),eE(e))})),rd=(0,f.XY)(2,(e,t)=>ru(e,L,e=>t(e))),rf=(0,f.XY)(3,(e,t,r)=>{let n=Array.isArray(t)?e=>(0,v.i5)(e,"_tag")&&t.includes(e._tag):(0,v.$J)(t);return rd(e,e=>n(e)?r(e):eX)}),rh=(0,f.XY)(2,(e,t)=>ru(e,Y,e=>t(e))),rp=(0,f.XY)(e=>(0,O.yw)(e[0]),(e,t,r,n)=>rt(e,e=>{let i=L(e);return x.N6(i)?eE(i.failure):t(i.success)?(0,_.s)(()=>r(i.success)):n?(0,_.s)(()=>n(i.success)):eE(e)})),rm=(0,f.XY)(e=>(0,O.yw)(e[0]),(e,t,r,n)=>rt(e,e=>{let i=L(e);if(x.N6(i))return eE(i.failure);let s=t(i.success);return x.N6(s)?n?(0,_.s)(()=>n(s.failure)):eE(e):(0,_.s)(()=>r(s.success))})),rg=(0,f.XY)(e=>(0,O.yw)(e[0]),(e,t,r,n)=>rp(e,Array.isArray(t)?e=>(0,v.i5)(e,"_tag")&&t.includes(e._tag):(0,v.$J)(t),r,n)),ry=(0,f.XY)(e=>(0,O.yw)(e[0]),(e,t,r)=>{let n;return rm(e,e=>(n??=Object.keys(t),(0,v.i5)(e,"_tag")&&(0,v.Kg)(e._tag)&&n.includes(e._tag)?x.Py(e):x.fJ(e)),e=>(0,_.s)(()=>t[e._tag](e)),r)}),rb=(0,f.XY)(e=>(0,O.yw)(e[0]),(e,t,r,n,i)=>rp(e,e=>(0,v.$J)(e,t)&&(0,v.i5)(e,"reason"),e=>{let t=e.reason;return(0,v.$J)(t,r)?n(t,e):i?(0,_.s)(()=>i(t,e)):eC(e)})),rv=(0,f.XY)(e=>(0,O.yw)(e[0]),(e,t,r,n)=>{let i;return rp(e,e=>(0,v.$J)(e,t)&&(0,v.i5)(e,"reason")&&(0,v.i5)(e.reason,"_tag")&&(0,v.Kg)(e.reason._tag),e=>{let t=e.reason;return(i??=Object.keys(r)).includes(t._tag)?(0,_.s)(()=>r[t._tag](t,e)):n?(0,_.s)(()=>n(t,e)):eC(e)})}),rw=(0,f.XY)(2,(e,t)=>rm(e,e=>(0,v.$J)(e,t)&&(0,v.i5)(e,"reason")?x.Py(e.reason):x.fJ(e),eC)),rx=(0,f.XY)(2,(e,t)=>rs(e,e=>eY(()=>t(e)))),rk=(0,f.XY)(2,(e,t)=>rP(e,{onFailure:e=>eY(()=>t.onFailure(e)),onSuccess:e=>eA(()=>t.onSuccess(e))})),rS=e=>rs(e,eB),r_=(0,f.XY)(2,(e,t)=>rs(e,e=>eA(t))),rO=e=>eT(()=>{let t=e[Symbol.iterator](),r=t.next();return r.done?eB(Error("Received an empty collection of effects")):function e(r){let n=t.next();return n.done?r.value:rs(r.value,t=>e(n))}(r)}),rI=e=>rs(e,t=>tu(eD,()=>rI(e))),r$=(0,f.XY)(e=>(0,O.yw)(e[0]),(e,t)=>{if(!t?.log)return rP(e,{onFailure:e=>eX,onSuccess:e=>eX});let r=ss(!0===t.log?void 0:t.log);return rT(e,{onFailure(e){let n=F(e);return x.N6(n)?eE(n.failure):void 0===t.message?r(e):r(t.message,e)},onSuccess:e=>eX})}),rE=(0,f.XY)(e=>(0,O.yw)(e[0]),(e,t)=>{if(!t?.log)return rT(e,{onFailure:e=>eX,onSuccess:e=>eX});let r=ss(!0===t.log?void 0:t.log);return rT(e,{onFailure:e=>void 0===t.message?r(e):r(t.message,e),onSuccess:e=>eX})}),rC=e=>rj(e,{onFailure:g.none,onSuccess:g.some}),rA=e=>rD(e,{onFailure:x.fJ,onSuccess:x.Py}),rT=(0,f.XY)(2,(e,t)=>{let r=Object.create(rN);return r[O.a2]=e,r[O.ee]=1!==t.onSuccess.length?e=>t.onSuccess(e):t.onSuccess,r[O.Sc]=1!==t.onFailure.length?e=>t.onFailure(e):t.onFailure,r}),rN=(0,O.yj)({op:"OnSuccessAndFailure",[O._3](e){return e._stack.push(this),this[O.a2]}}),rM=(0,f.XY)(2,(e,t)=>rT(e,{onFailure:e=>eA(()=>t.onFailure(e)),onSuccess:e=>eA(()=>t.onSuccess(e))})),rP=(0,f.XY)(2,(e,t)=>rT(e,{onFailure:e=>{let r=e.reasons.find(O.lC);return r?(0,_.s)(()=>t.onFailure(r.error)):eE(e)},onSuccess:t.onSuccess})),rj=(0,f.XY)(2,(e,t)=>rP(e,{onFailure:e=>eA(()=>t.onFailure(e)),onSuccess:e=>eA(()=>t.onSuccess(e))})),rD=(0,f.XY)(2,(e,t)=>{if(th(e)){if("Success"===e._tag)return(0,O.xt)(t.onSuccess(e.value));let r=L(e.cause);return x.N6(r)?e:(0,O.xt)(t.onFailure(r.success))}return rj(e,t)}),rF=(0,f.XY)(2,(e,t)=>th(e)?"Success"===e._tag?(0,O.xt)(t.onSuccess(e.value)):(0,O.xt)(t.onFailure(e.cause)):rM(e,t)),rL=e=>th(e)?(0,O.xt)(e):rR(e),rR=(0,O.Uf)({op:"Exit",[O._3](e){return e._stack.push(this),this[O.a2]},[O.ee]:(e,t,r)=>e$(r??(0,O.xt)(e)),[O.Sc]:(e,t,r)=>e$(r??(0,O.cb)(e))}),rU=rD({onFailure:()=>!0,onSuccess:()=>!1}),rB=rD({onFailure:()=>!1,onSuccess:()=>!0}),rY=(0,f.XY)(2,(e,t)=>tr(iY(t),e)),rX=(0,f.XY)(2,(e,t)=>tc(e,tu(iY(t.duration),t.orElse))),rW=(0,f.XY)(2,(e,t)=>rX(e,{duration:t,orElse:()=>eC(new iK)})),rJ=(0,f.XY)(2,(e,t)=>tc(te(e),e7(iY(t),g.none()))),rq=e=>iB(t=>{let r=t.currentTimeNanosUnsafe();return tg(e,e=>[l.cF(t.currentTimeNanosUnsafe()-r),e])}),rK="~effect/Scope",rV="~effect/Scope/Closeable",rG=o.kl("effect/Scope"),rH=(e,t)=>eT(()=>rz(e,t)??eX),rz=(e,t)=>{if("Closed"===e.state._tag)return;let r={_tag:"Closed",exit:t};if("Empty"===e.state._tag){e.state=r;return}let{finalizers:n}=e.state;return(e.state=r,0===n.size)?void 0:1===n.size?n.values().next().value(t):rQ(e,n,t)},rQ=e1(function*(e,t,r){let n=[],i=[],s=Array.from(t.values()),a=ep();for(let t=s.length-1;t>=0;t--){let o=s[t];"sequential"===e.strategy?n.push((yield*rL(o(r)))):i.push(nQ(a,o(r),!0,!0,"inherit"))}return i.length>0&&(n=yield*ew(i)),yield*tB(n)}),rZ=(e,t)=>eA(()=>r0(e,t)),r0=(e,t)=>{let r=r6(t);if("Closed"===e.state._tag)return r.state=e.state,r;let n={};return r3(e,n,e=>rH(r,e)),r3(r,n,t=>eA(()=>r5(e,n))),r},r1=(e,t)=>eT(()=>"Closed"===e.state._tag?t(e.state.exit):(r3(e,{},t),eX)),r2=(e,t)=>r1(e,(0,f.dY)(t)),r3=(e,t,r)=>{"Empty"===e.state._tag?e.state={_tag:"Open",finalizers:new Map([[t,r]])}:"Open"===e.state._tag&&e.state.finalizers.set(t,r)},r5=(e,t)=>{"Open"===e.state._tag&&e.state.finalizers.delete(t)},r6=(e="sequential")=>({[rV]:rV,[rK]:rK,strategy:e,state:r8}),r8={_tag:"Empty"},r9=e=>eA(()=>r6(e)),r4=rG,r7=t0(rG),ne=e=>(0,O.R6)(t=>{let r=t.context,n=r6();return t.setContext(o.WQ(t.context,rG,n)),ns(e,e=>(t.setContext(r),rz(n,e)))}),nt=(0,f.XY)(2,(e,t)=>na(r7(e,t),e=>eT(()=>rz(t,e)??eX))),nr=e=>eT(()=>{let t=r6();return na(e(t),e=>eT(()=>rz(t,e)??eX))}),nn=(e,t,r)=>tz(n=>nO(i=>tu(r4,s=>tn(r?.interruptible?i(e):e,e=>r1(s,r=>tZ(t(e,r),n)))))),ni=e=>tu(r4,t=>tz(r=>r1(t,t=>tZ(e(t),r)))),ns=(0,O.Uf)({op:"OnExit",single:!1,[O._3](e){return e._stack.push(this),this[O.a2][0]},[O.u4](e){e.interruptible&&!0!==this[O.a2][2]&&(e._stack.push(nk),e.interruptible=!1)},[O.ee](e,t,r){r??=(0,O.xt)(e);let n=this[O.a2][1](r);return n?tu(n,e=>r):r},[O.Sc](e,t,r){r??=(0,O.cb)(e);let n=this[O.a2][1](r);return n?tu(n,e=>r):r}}),na=(0,f.XY)(2,ns),no=(0,f.XY)(2,(e,t)=>na(e,e=>t)),nl=(0,f.XY)(3,(e,t,r)=>na(e,e=>t(e)?r(e):eX)),nc=(0,f.XY)(3,(e,t,r)=>na(e,e=>{let n=t(e);return x.N6(n)?eX:r(n.success,e)})),nu=(0,f.XY)(2,(e,t)=>nc(e,t$,t)),nd=(0,f.XY)(3,(e,t,r)=>nl(e,e=>"Failure"===e._tag&&t(e.cause),e=>r(e.cause))),nf=(0,f.XY)(3,(e,t,r)=>na(e,e=>{if("Failure"!==e._tag)return eX;let n=t(e.cause);return x.N6(n)?eX:r(n.success,e.cause)})),nh=(0,f.XY)(2,(e,t)=>nf(J,t)(e)),np=(e,t,r)=>nO(n=>tu(e,e=>ns(n(t(e)),t=>r(e,t),!0))),nm=e=>nn(e,e=>(0,v.i5)(e,Symbol.asyncDispose)?eJ(()=>e[Symbol.asyncDispose]()):eA(()=>e[Symbol.dispose]())),ng=(0,f.XY)(2,(e,t)=>eA(()=>{let r,n=l.kE(l.bN(t)),i=Number.isFinite(n),s=iu(!1),a=0,o=!1,c=tu(s.await,()=>r);return[(0,O.R6)(t=>{let l=t.getRef(iD),u=i?l.currentTimeMillisUnsafe():0;return o||u<a?r??c:(o=!0,s.closeUnsafe(),r=void 0,na(e,e=>eA(()=>{o=!1,a=l.currentTimeMillisUnsafe()+n,r=e,s.openUnsafe()})))}),eA(()=>{a=0,s.closeUnsafe(),r=void 0})]})),ny=(0,f.XY)(2,(e,t)=>tg(ng(e,t),e=>e[0])),nb=e=>ny(e,l.Tn),nv=(0,O.R6)(e=>eE(j(e.id))),nw=e=>(0,O.R6)(t=>(t.interruptible&&(t.interruptible=!1,t._stack.push(nk)),e)),nx=(0,O.Uf)({op:"SetInterruptible",[O.u4](e){if(e.interruptible=this[O.a2],e._interruptedCause&&e.interruptible)return()=>eE(e._interruptedCause)}}),nk=nx(!0),nS=nx(!1),n_=e=>(0,O.R6)(t=>t.interruptible?e:(t.interruptible=!0,t._stack.push(nS),t._interruptedCause)?eE(t._interruptedCause):e),nO=e=>(0,O.R6)(t=>t.interruptible?(t.interruptible=!1,t._stack.push(nk),e(n_)):e(f.D_)),nI=e=>(0,O.R6)(t=>t.interruptible?e(f.D_):(t.interruptible=!0,t._stack.push(nS),e(nw))),n$=tg(nn(eA(()=>new AbortController),e=>eA(()=>e.abort())),e=>e.signal),nE=(e,t)=>(0,v.xZ)(e)?t?.mode==="result"?nD(e,rA,t):nD(e,f.D_,t):t?.discard?"result"===t.mode?nD(Object.values(e),rA,t):nD(Object.values(e),f.D_,t):eT(()=>{let r={};return e7(nD(Object.entries(e),([e,n])=>tg(t?.mode==="result"?rA(n):n,t=>{r[e]=t}),{discard:!0,concurrency:t?.concurrency}),r)}),nC=(0,f.XY)(e=>(0,v.xZ)(e[0])&&!(0,O.yw)(e[0]),(e,t,r)=>tg(nD(e,(e,r)=>rA(t(e,r)),r),e=>a.jB(e,f.D_))),nA=(0,f.XY)(e=>(0,v.xZ)(e[0])&&!(0,O.yw)(e[0]),(e,t,r)=>tu(nC(e,t,{concurrency:r?.concurrency}),([e,t])=>a.CZ(e)?eC(e):r?.discard?eX:e$(t))),nT=(0,f.XY)(e=>(0,v.xZ)(e[0])&&!(0,O.yw)(e[0]),(e,t)=>eT(()=>{let r=e[Symbol.iterator](),n=r.next();return n.done?e$(g.none()):nN(r,0,t,n.value)})),nN=(e,t,r,n)=>tu(r(n,t),i=>{if(i)return e$(g.some(n));let s=e.next();return s.done?e$(g.none()):nN(e,t+1,r,s.value)}),nM=(0,f.XY)(e=>(0,v.xZ)(e[0])&&!(0,O.yw)(e[0]),(e,t)=>eT(()=>{let r=e[Symbol.iterator](),n=r.next();return n.done?e$(g.none()):nP(r,0,t,n.value)})),nP=(e,t,r,n)=>tu(r(n,t),n=>{if(x.oJ(n))return e$(g.some(n.success));let i=e.next();return i.done?e$(g.none()):nP(e,t+1,r,i.value)}),nj=(0,O.Uf)({op:"While",[O.ee](e,t){return(this[O.a2].step(e),this[O.a2].while())?(t._stack.push(this),this[O.a2].body()):tM},[O._3](e){return this[O.a2].while()?(e._stack.push(this),this[O.a2].body()):tM}}),nD=(0,f.XY)(e=>"function"==typeof e[1],(e,t,r)=>(0,O.R6)(n=>{let i=r?.concurrency==="inherit"?n.getRef(E.F8):r?.concurrency??1,s="unbounded"===i?1/0:Math.max(1,i);if(1===s)return nF(e,t,r);let o=a.Ts(e),l=o.length;if(0===l)return r?.discard?eX:e$([]);let c=r?.discard?void 0:Array(l),u=nU({f:t,out:c},o,{concurrency:s});return u?e7(u,c):e$(c)})),nF=(e,t,r)=>eT(()=>{let n=r?.discard?void 0:[],i=e[Symbol.iterator](),s=i.next(),a=0;return e7(nj({while:()=>!s.done,body:()=>t(s.value,a++),step:e=>{n&&n.push(e),s=i.next()}}),n)}),nL=e=>{let t=e.onItem,r=e.step;return(e,n,i)=>{let s,a,o,l,c,u=i?.start??0,d=i?.end??n.length,f=i?.concurrency??1,h=i?.orderedStep===!0&&f>1,p=!1,m=!1,g=u,y=h?Array(d):void 0,b=(t,i,s)=>{if(!h)return r(e,t,i,s);if(l)return l;for(y[s]=i;g<d;){let t=y[g];if(void 0===t)return;y[g]=void 0;let i=g++,s=r(e,n[i],t,i);if(s)return s}},v=()=>{let r=!1;for(;!l&&u<d;u++){let i=n[u],d=c??t(e,i,u);if(th(d)){if(l=b(i,d,u))break}else{if(1===f)return tu(rL(d),e=>(l=b(i,e,u),u++,l??v()??eX));if(!s)return eQ(e=>{s=ep(),c=d,o=e;let t=v();return t?e(t):eT(()=>(l=tM,m=!0,a?eO(a):eX))});c=void 0;let e=nQ(s,d,!0,!0,"inherit");if(e._exit){if(l=b(i,e._exit,u))break;continue}a?a.add(e):a=new Set([e]);let t=u;if(e.addObserver(n=>{if(a.delete(e),l){if(!m&&"Failure"===n._tag)for(let e of n.cause.reasons)if("Interrupt"===e._tag)continue;else"Failure"===l._tag?l.cause.reasons.push(e):l=(0,O.cb)((0,O.b5)([e]))}else{let e=b(i,n,t);e&&(l="Failure"===e._tag?(0,O.cb)((0,O.b5)(e.cause.reasons.slice())):e,v())}if(r){let e=v();e&&o(e)}else p&&0===a.size&&o(l??eX)}),a.size<f)continue;r=!0,u++;return}}if(p=!0,l){if(a&&a.size>0){let e=ey(s);a.forEach(t=>t.interruptUnsafe(s.id,e));return}if(o||"Failure"===l._tag)return l}else if(o)if(!a)return tM;else 0===a.size&&o(eX)};return v()}},nR=()=>nL,nU=nL({onItem:(e,t,r)=>e.f(t,r),step(e,t,r,n){if("Failure"===r._tag)return r;e.out&&(e.out[n]=r.value)}}),nB=(0,f.XY)(3,(e,t,r)=>tu(e,e=>t(e)?e$(e):r(e))),nY=(0,f.XY)(3,(e,t,r)=>tu(e,e=>{let n=t(e);return x.N6(n)?r(n.failure):e$(n.success)})),nX=(0,f.XY)(e=>(0,O.yw)(e[0]),(e,t,r)=>nY(e,t,r?e=>eC(r(e)):()=>eC(new O.Xm))),nW=(0,f.XY)(e=>(0,v.xZ)(e[0])&&!(0,O.yw)(e[0]),(e,t,r)=>eT(()=>{let n=[];return e7(nD(e,(e,r)=>{let i=t(e,r);return"boolean"==typeof i?(i&&n.push(e),eX):tg(i,t=>{t&&n.push(e)})},{discard:!0,concurrency:r?.concurrency}),n)})),nJ=(0,f.XY)(e=>(0,v.xZ)(e[0])&&!(0,O.yw)(e[0]),(e,t)=>eT(()=>{let r=[];for(let n of e){let e=t(n);x.oJ(e)&&r.push(e.success)}return e$(r)})),nq=(0,f.XY)(e=>(0,v.xZ)(e[0])&&!(0,O.yw)(e[0]),(e,t,r)=>eT(()=>{let n=[];return e7(nD(e,e=>tg(t(e),e=>{x.oJ(e)&&n.push(e.success)}),{discard:!0,concurrency:r?.concurrency}),n)})),nK=e$({}),nV=I.Jr(tg),nG=I.oI(tg,tu),nH=I.zM(tg),nz=(0,f.XY)(e=>(0,O.yw)(e[0]),(e,t)=>(0,O.R6)(r=>(eg.interruptChildren??=eb,e$(nQ(r,e,t?.startImmediately,!1,t?.uninterruptible??!1))))),nQ=(e,t,r=!1,n=!1,i=!1)=>{let s="inherit"===i?e.interruptible:!i,a=new em(e.context,s);return r?a.evaluate(t):e.currentDispatcher.scheduleTask(()=>a.evaluate(t),0),n||a._exit||(e.children().add(a),a.addObserver(()=>e._children.delete(a))),a},nZ=(0,f.XY)(e=>(0,O.yw)(e[0]),(e,t)=>(0,O.R6)(r=>e$(nQ(r,e,t?.startImmediately,!0,t?.uninterruptible)))),n0=e=>(0,O.R6)(t=>{let r=t._children&&a.Ts(t._children);return na(e,e=>{let n=t._children;return void 0===n||0===n.size?eX:(r&&(n=m.pb(n,e=>!r.includes(e))),ti(ew(n)))})}),n1=(0,f.XY)(e=>(0,O.yw)(e[0]),(e,t,r)=>(0,O.R6)(n=>{let i=nQ(n,e,r?.startImmediately,!0,r?.uninterruptible);if(!i._exit)if("Closed"!==t.state._tag){let e={};r3(t,e,()=>eK(e=>e===i.id?eX:eS(i))),i.addObserver(()=>r5(t,e))}else i.interruptUnsafe(n.id,ey(n));return e$(i)})),n2=(0,f.XY)(e=>(0,O.yw)(e[0]),(e,t)=>tu(r4,r=>n1(e,r,t))),n3=e=>(t,r)=>{let n=new em(r?.scheduler?o.WQ(e,k._F,r.scheduler):e,r?.uninterruptible!==!0);if(n.evaluate(t),n._exit)return n;if(r?.signal)if(r.signal.aborted)n.interruptUnsafe();else{let e=()=>n.interruptUnsafe();r.signal.addEventListener("abort",e,{once:!0}),n.addObserver(()=>r.signal.removeEventListener("abort",e))}return r?.onFiberStart&&r.onFiberStart(n),n},n5=(0,f.XY)(2,(e,t)=>{if(e._exit)return e;if("Closed"===t.state._tag)return e.interruptUnsafe(e.id),e;let r={};return r3(t,r,()=>eS(e)),e.addObserver(()=>r5(t,r)),e}),n6=n3(o.Ie()),n8=e=>{let t=n3(e);return(e,r)=>{let n=t(e,r);return r?.onExit&&n.addObserver(r.onExit),e=>n.interruptUnsafe(e)}},n9=n8(o.Ie()),n4=e=>{let t=n3(e);return(e,r)=>{let n=t(e,r);return new Promise(e=>{n.addObserver(t=>e(t))})}},n7=n4(o.Ie()),ie=e=>{let t=n4(e);return(e,r)=>t(e,r).then(e=>{if("Failure"===e._tag)throw Z(e.cause);return e.value})},it=ie(o.Ie()),ir=e=>{let t=n3(e);return e=>{if(th(e))return e;let r=t(e,{scheduler:new k.FG("sync")});return r.currentDispatcher?.flush(),r._exit??(0,O.V2)(new i2(r))}},ii=ir(o.Ie()),is=e=>{let t=ir(e);return e=>{let r=t(e);if("Failure"===r._tag)throw Z(r.cause);return r.value}},ia=is(o.Ie()),io=e$(!0),il=e$(!1);class ic{waiters=[];scheduled=!1;_isOpen;constructor(e){this._isOpen=e}scheduleUnsafe(e){return this.scheduled||0===this.waiters.length||(this.scheduled=!0,e.currentDispatcher.scheduleTask(this.flushWaiters,0)),io}flushWaiters=()=>{this.scheduled=!1;let e=this.waiters;this.waiters=[];for(let t=0;t<e.length;t++)e[t](tM)};open=(0,O.R6)(e=>this._isOpen?il:(this._isOpen=!0,this.scheduleUnsafe(e)));release=(0,O.R6)(e=>this._isOpen?il:this.scheduleUnsafe(e));openUnsafe(){return!this._isOpen&&(this._isOpen=!0,this.flushWaiters(),!0)}await=eQ(e=>this._isOpen?e(eX):(this.waiters.push(e),eA(()=>{let t=this.waiters.indexOf(e);-1!==t&&this.waiters.splice(t,1)})));closeUnsafe(){return!!this._isOpen&&(this._isOpen=!1,!0)}close=eA(()=>this.closeUnsafe());whenOpen=e=>tu(this.await,()=>e);isOpen(){return this._isOpen}}let iu=e=>new ic(e??!1),id=e=>eA(()=>iu(e)),ih=(0,O.R6)(e=>e$(e.getRef(S.sh))),ip=(0,f.XY)(2,(e,t)=>t0(e,S.sh,t)),im=t0(E.rf),ig=t0(E.nU),iy=BigInt(0),ib={_tag:"Span",spanId:"noop",traceId:"noop",sampled:!1,status:{_tag:"Ended",startTime:iy,endTime:iy,exit:tM},attributes:new Map,links:[],kind:"internal",attribute(){},event(){},end(){},addLinks(){}},iv=e=>e?o.Jt(e.annotations,S.DW)?"Span"===e._tag?iv(g.getOrUndefined(e.parent)):g.none():g.some(e):g.none(),iw=(e,t,r)=>{let n,i=!e.getRef(E.rf)||r?.annotations&&o.Jt(r.annotations,S.DW),s=r?.parent!==void 0?g.some(r.parent):r?.root?g.none():iv(e.currentSpan);if(i){let e;e={name:t,parent:s,annotations:o.WQ(r?.annotations??o.Ie(),S.DW,!0)},n=Object.assign(Object.create(ib),e)}else{let i=e.getRef(S.sh),a=e.getRef(iD),l=e.getRef(E.nU),c=e.getRef(E.ce),u=e.getRef(E.ls),d=r?.level??e.getRef(S.pX),f=r?.links!==void 0?[...u,...r.links]:u.slice();for(let[u,h]of(n=i.span({name:t,parent:s,annotations:r?.annotations??o.Ie(),links:f,startTime:l?a.currentTimeNanosUnsafe():BigInt(0),kind:r?.kind??"internal",root:r?.root??g.isNone(s),sampled:r?.sampled??((!g.isSome(s)||!1!==s.value.sampled)&&!i4(e.getRef(S.EW),d))}),Object.entries(c)))n.attribute(u,h);if(r?.attributes!==void 0)for(let[e,t]of Object.entries(r.attributes))n.attribute(e,t)}return n},ix=(e,t)=>(0,O.R6)(r=>e$(iw(r,e,t))),ik=(e,t)=>nw((0,O.R6)(r=>{let n=o.fp(r.context,rG),i=iw(r,e,t??{}),s=r.getRef(iD),a=r.getRef(E.nU);return e7(r1(n,e=>i$(i,e,s,a)),i)})),iS=function(){let e="string"!=typeof arguments[0],t=e?arguments[1]:arguments[0],r=A(e?arguments[2]:arguments[1]);if(e){let e=arguments[0];return tu(ik(t,r),t=>iA(e,t,r))}return e=>tu(ik(t,r),t=>iA(e,t,r))},i_=E.ce,iO=E.ls,iI=(0,f.XY)(e=>(0,O.yw)(e[0]),(e,t,r={})=>{let n=(Array.isArray(t)?t:[t]).map(e=>({span:e,attributes:r}));return tV(e,E.ls,e=>[...e,...n])}),i$=(e,t,r,n)=>eA(()=>{"Ended"!==e.status._tag&&e.end(n?r.currentTimeNanosUnsafe():iy,t)}),iE=(e,...t)=>{let r=1===t.length?void 0:t[0],n=t[t.length-1];return(0,O.R6)(t=>{let i=iw(t,e,r),s=t.getRef(iD);return na((0,_.s)(()=>n(i)),e=>eA(()=>{"Ended"!==i.status._tag&&i.end(s.currentTimeNanosUnsafe(),e)}))})},iC=t0(S.Tv),iA=function(){let e=(0,O.yw)(arguments[0]),t=e?arguments[1]:arguments[0],r=e?arguments[2]:arguments[1],n=f.D_;if("Span"===t._tag){var i,s;r=A(r),i=t.name,s="function"==typeof(s=r?.captureStackTrace)?s:f.MN,n=tV(E.vA,e=>({name:i,stack:s,parent:e}))}return e?iC(n(arguments[0]),t):e=>iC(n(e),t)},iT=function(){let e="string"!=typeof arguments[0],t=e?arguments[1]:arguments[0],r=A(arguments[2]);if(e){let e=arguments[0];return iE(t,arguments[2],t=>iA(e,t,r))}let n="function"==typeof arguments[1]?arguments[1]:void 0,i=n?void 0:arguments[1];return(e,...s)=>iE(t,n?n(...s):i,t=>iA(e,t,r))},iN=(0,f.XY)(e=>(0,O.yw)(e[0]),(e,...t)=>tV(e,E.ce,e=>{let r={...e};return 1===t.length?Object.assign(r,t[0]):r[t[0]]=t[1],r})),iM=(...e)=>(0,O.R6)(t=>{let r=t.currentSpanLocal;if(r)if(1===e.length)for(let[t,n]of Object.entries(e[0]))r.attribute(t,n);else r.attribute(e[0],e[1]);return eX}),iP=(0,O.R6)(e=>{let t=e.currentSpanLocal;return t?e$(t):eC(new O.Xm)}),ij=(n=S.Tv,(0,O.R6)(e=>e.context.mapUnsafe.has(n.key)?e$(o.fp(e.context,n)):eC(new O.Xm))),iD=o.Or("effect/Clock",{defaultValue:()=>new iL}),iF=0x80000000-1;class iL{currentTimeMillisUnsafe(){return Date.now()}currentTimeMillis=eA(()=>this.currentTimeMillisUnsafe());currentTimeNanosUnsafe(){return iU()}currentTimeNanos=eA(()=>this.currentTimeNanosUnsafe());sleep(e){return this.sleepMillis(l.kE(e))}sleepMillis(e){return e<=0?eD:Number.isFinite(e)?eQ(t=>{let r=e>iF?this.sleepMillis(e-iF):eX,n=setTimeout(()=>t(r),Math.min(e,iF));return eA(()=>clearTimeout(n))}):eZ}}let iR=(s=BigInt(1e6),"u"<typeof performance||void 0===performance.now?()=>BigInt(Date.now())*s:()=>(i??=BigInt(Date.now())*s-BigInt(Math.round(1e6*performance.now())))+BigInt(Math.round(1e6*performance.now()))),iU=function(){let e="object"==typeof process&&"hrtime"in process&&"function"==typeof process.hrtime.bigint?process.hrtime:void 0;if(!e)return iR;let t=BigInt(Date.now())*BigInt(1e6)-e.bigint();return()=>t+e.bigint()}(),iB=e=>(0,O.R6)(t=>e(t.getRef(iD))),iY=e=>iB(t=>t.sleep(l.bN(e))),iX=iB(e=>e.currentTimeMillis),iW=iB(e=>e.currentTimeNanos),iJ="~effect/Cause/TimeoutError",iq=e=>(0,v.i5)(e,iJ);class iK extends(0,O.rN)("TimeoutError"){[iJ]=iJ;constructor(e){super({message:e})}}let iV="~effect/Cause/IllegalArgumentError",iG=e=>(0,v.i5)(e,iV);class iH extends(0,O.rN)("IllegalArgumentError"){[iV]=iV;constructor(e){super({message:e})}}let iz="~effect/Cause/ExceededCapacityError",iQ=e=>(0,v.i5)(e,iz);class iZ extends(0,O.rN)("ExceededCapacityError"){[iz]=iz;constructor(e){super({message:e})}}let i0="~effect/Cause/AsyncFiberError",i1=e=>(0,v.i5)(e,i0);class i2 extends(0,O.rN)("AsyncFiberError"){[i0]=i0;constructor(e){super({message:"An asynchronous Effect was executed with Effect.runSync",fiber:e})}}let i3="~effect/Cause/UnknownError",i5=e=>(0,v.i5)(e,i3);class i6 extends(0,O.rN)("UnknownError"){[i3]=i3;constructor(e,t){super({message:t,cause:e})}}let i8=o.Or("effect/Console/CurrentConsole",{defaultValue:()=>globalThis.console}),i9=y.zQ(y.wN,e=>{switch(e){case"All":return Number.MIN_SAFE_INTEGER;case"Fatal":return 5e4;case"Error":return 4e4;case"Warn":return 3e4;case"Info":return 2e4;case"Debug":return 1e4;case"Trace":return 0;case"None":return Number.MAX_SAFE_INTEGER}}),i4=y.yJ(i9),i7=o.Or("effect/Loggers/CurrentLoggers",{defaultValue:()=>new Set([sa,so])}),se=o.Or("effect/Logger/LogToStderr",{defaultValue:f.f4}),st=function(){let e="string"==typeof arguments[0]?[[arguments[0],arguments[1]]]:Object.entries(arguments[0]);return nw((0,O.R6)(t=>{let r=t.getRef(E.iL),n={...r};for(let t=0;t<e.length;t++){let[r,i]=e[t];n[r]=i}return t.setContext(o.WQ(t.context,E.iL,n)),r1(o.fp(t.context,rG),n=>{let i=t.getRef(E.iL),s={...i};for(let t=0;t<e.length;t++){let[n,a]=e[t];i[n]===a&&(n in r?s[n]=r[n]:delete s[n])}return t.setContext(o.WQ(t.context,E.iL,s)),eX})}))},sr={"~effect/Logger":{_Message:f.D_,_Output:f.D_},pipe(){return(0,b.tT)(this,arguments)}},sn=e=>{let t=Object.create(sr);return t.log=e,t},si=(e,t)=>{let r=e[0].replace(/[\s="]/g,"_");return`${r}=${t-e[1]}ms`},ss=e=>(...t)=>{let r;for(let e=0,n=t.length;e<n;e++){let n=t[e];(0,O.Aj)(n)&&(r?t.splice(e,1):t=t.slice(0,e).concat(t.slice(e+1)),r=r?(0,O.b5)(r.reasons.concat(n.reasons)):n,e--)}return void 0===r&&(r=O.DH),(0,O.R6)(n=>{let i=e??n.currentLogLevel;if(i4(n.minimumLogLevel,i))return eX;let s=n.getRef(iD),a=n.getRef(i7);if(a.size>0){let e=new Date(s.currentTimeMillisUnsafe());for(let s of a)s.log({cause:r,fiber:n,date:e,logLevel:i,message:t})}return eX})},sa=sn(({cause:e,date:t,fiber:r,logLevel:n,message:i})=>{let s=Array.isArray(i)?i.slice():[i];e.reasons.length>0&&s.push(el(e));let a=t.getTime(),o=r.getRef(E.d8),l="";for(let e of o)l+=` ${si(e,a)}`;let c=r.getRef(E.iL);Object.keys(c).length>0&&s.push(c);let u=r.getRef(i8);(r.getRef(se)?u.error:u.log)(`[${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}:${t.getSeconds().toString().padStart(2,"0")}.${t.getMilliseconds().toString().padStart(3,"0")}] ${n.toUpperCase()} (#${r.id})${l}:`,...s)}),so=sn(({cause:e,fiber:t,logLevel:r,message:n})=>{let i=t.getRef(iD),s=t.getRef(E.iL),a=t.currentSpan;if(void 0===a||"ExternalSpan"===a._tag)return;let o={};for(let[e,t]of Object.entries(s))o[e]=t;o["effect.fiberId"]=t.id,o["effect.logLevel"]=r.toUpperCase(),e.reasons.length>0&&(o["effect.cause"]=el(e)),a.event((0,p.ZK)(Array.isArray(n)&&1===n.length?n[0]:n),i.currentTimeNanosUnsafe(),o)}),sl=e$(void 0),sc=(0,f.XY)(e=>(0,O.yw)(e[0]),(e,t)=>nu(e,e=>(0,O.R6)(r=>(su(r,e,t?.defectsOnly),eX)))),su=(e,t,r)=>{let n=e.getRef(E.oQ);if(0===n.size||r&&!U(t))return;let i={cause:t,fiber:e,timestamp:e.getRef(iD).currentTimeNanosUnsafe()};n.forEach(e=>e.report(i))}},6516(e,t,r){let n=new WeakSet;r.d(t,{},{J:n,X:e=>{let t=new Set(Reflect.ownKeys(e));if(e.constructor===Object)return t;e instanceof Error&&t.delete("stack");let r=Object.getPrototypeOf(e),n=r;for(;null!==n&&n!==Object.prototype;){let e=Reflect.ownKeys(n);for(let r=0;r<e.length;r++)t.add(e[r]);n=Object.getPrototypeOf(n)}return t.has("constructor")&&"function"==typeof e.constructor&&r===e.constructor.prototype&&t.delete("constructor"),t}})},9354(e,t,r){r.d(t,{},{F:"effect/observability/Metric/FiberRuntimeMetricsKey"})},5091(e,t,r){var n=r(8036),i=r(6470),s=r(4450),a=r(6400),o=r(5369),l=r(3537),c=r(8433);let u="~effect/data/Option",d={[u]:{_A:e=>e},...c.fU,[Symbol.iterator](){return new l.B(this)}},f=Object.defineProperty(Object.assign(Object.create(d),{_tag:"Some",_op:"Some",[n.HR](e){return m(e)&&y(e)&&n.aI(this.value,e.value)},[s.HR](){return s.kg(s.tW(this._tag))(s.tW(this.value))},toString(){return`some(${(0,i.GP)(this.value)})`},toJSON(){return{_id:"Option",_tag:this._tag,value:(0,a.aB)(this.value)}}}),"valueOrUndefined",{get(){return this.value}}),h=s.tW("None"),p=Object.assign(Object.create(d),{_tag:"None",_op:"None",valueOrUndefined:void 0,[n.HR]:e=>m(e)&&g(e),[s.HR]:()=>h,toString:()=>"none()",toJSON(){return{_id:"Option",_tag:this._tag}}}),m=e=>(0,o.i5)(e,u),g=e=>"None"===e._tag,y=e=>"Some"===e._tag,b=Object.create(p);r.d(t,{},{$I:g,Ru:y,dv:b,oL:m,zN:e=>{let t=Object.create(f);return t.value=e,t}})},8344(e,t,r){var n=r(8619),i=r(4650);let s=n.Or("effect/References/CurrentConcurrency",{defaultValue:()=>"unbounded"}),a=n.Or("effect/ErrorReporter/CurrentErrorReporters",{defaultValue:()=>new Set}),o=n.Or("effect/References/CurrentStackFrame",{defaultValue:i.MN}),l=n.Or("effect/References/TracerEnabled",{defaultValue:i.ue}),c=n.Or("effect/References/TracerTimingEnabled",{defaultValue:i.ue}),u=n.Or("effect/References/TracerSpanAnnotations",{defaultValue:()=>({})}),d=n.Or("effect/References/TracerSpanLinks",{defaultValue:()=>[]}),f=n.Or("effect/References/CurrentLogAnnotations",{defaultValue:()=>({})}),h=n.Or("effect/References/CurrentLogLevel",{defaultValue:()=>"Info"}),p=n.Or("effect/References/MinimumLogLevel",{defaultValue:()=>"Info"}),m=n.Or("effect/References/UnhandledLogLevel",{defaultValue:()=>"Error"}),g=n.Or("effect/References/CurrentLogSpans",{defaultValue:()=>[]});r.d(t,{},{F8:s,Gl:h,aG:m,ce:u,d8:g,iL:f,ls:d,nU:c,oQ:a,rf:l,vA:o,zQ:p})},4403(e,t,r){var n=r(8036),i=r(6470),s=r(4650),a=r(4450),o=r(6400),l=r(5369),c=r(3537),u=r(8433),d=r(5091);let f="~effect/data/Result",h={[f]:{_A:e=>e,_E:e=>e},...u.fU,[Symbol.iterator](){return new c.B(this)}},p=Object.assign(Object.create(h),{_tag:"Success",_op:"Success",[n.HR](e){return g(e)&&b(e)&&n.aI(this.success,e.success)},[a.HR](){return a.kg(a.tW(this._tag))(a.tW(this.success))},toString(){return`success(${(0,i.GP)(this.success)})`},toJSON(){return{_id:"Result",_tag:this._tag,value:(0,o.aB)(this.success)}}}),m=Object.assign(Object.create(h),{_tag:"Failure",_op:"Failure",[n.HR](e){return g(e)&&y(e)&&n.aI(this.failure,e.failure)},[a.HR](){return a.kg(a.tW(this._tag))(a.tW(this.failure))},toString(){return`failure(${(0,i.GP)(this.failure)})`},toJSON(){return{_id:"Result",_tag:this._tag,failure:(0,o.aB)(this.failure)}}}),g=e=>(0,l.i5)(e,f),y=e=>"Failure"===e._tag,b=e=>"Success"===e._tag,v=e=>{let t=Object.create(m);return t.failure=e,t},w=e=>{let t=Object.create(p);return t.success=e,t},x=(0,s.XY)(2,(e,t)=>d.$I(e)?v(t()):w(e.value));r.d(t,{},{L8:e=>b(e)?d.dv:d.zN(e.failure),N6:y,Oz:e=>y(e)?d.dv:d.zN(e.success),Py:w,aI:g,fJ:v,oJ:b,sV:x})},4888(e,t,r){var n=r(4650);function i(e){return e.checks?e.checks[e.checks.length-1].annotations:e.annotations}function s(e){return t=>i(t)?.[e]}let a=s("identifier"),o=s("title"),l=s("description"),c=(0,n.Bj)(e=>{let t=a(e);return"string"==typeof t?t:e.getExpected(c)});r.d(t,{hd:()=>i,ip:()=>s},{DQ:o,KE:a,Pk:l,bo:c})},8045(e,t,r){var n=r(8543),i=r(6030);function s(e){let t;for(let r of e.reasons){if(!n.lC(r)||!i.gh(r.error))return;t??=r.error}return t}function a(e,t){let r=s(e);if(void 0===r)throw Error(t,{cause:e});return r}r.d(t,{R:()=>s,q:()=>a})},3628(e,t,r){let n,i=Object.getOwnPropertyDescriptor,s=Object.prototype.hasOwnProperty,a=Object.isExtensible,o=void 0===(n=i(Error,"stackTraceLimit"))?a(Error):s.call(n,"writable")?!0===n.writable:void 0!==n.set;r.d(t,{},{ft:e=>{o&&(Error.stackTraceLimit=e)},jt:()=>Error.stackTraceLimit})},1580(e,t,r){let n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function i(e,t,r){let n=r[0];if(null!=t&&e>=t)throw Error(e+" >= "+t);if(e.slice(-1)===n||t&&t.slice(-1)===n)throw Error("trailing zero");if(t){let s=0;for(;(e[s]||n)===t[s];)s++;if(s>0)return t.slice(0,s)+i(e.slice(s),t.slice(s),r)}let s=e?r.indexOf(e[0]):0,a=null!=t?r.indexOf(t[0]):r.length;return a-s>1?r[Math.round(.5*(s+a))]:t&&t.length>1?t.slice(0,1):r[s]+i(e.slice(1),null,r)}function s(e){if(e.length!==a(e[0]))throw Error("invalid integer part of order key: "+e)}function a(e){if(e>="a"&&e<="z")return e.charCodeAt(0)-97+2;if(e>="A"&&e<="Z")return 90-e.charCodeAt(0)+2;throw Error("invalid order key head: "+e)}function o(e){let t=a(e[0]);if(t>e.length)throw Error("invalid order key: "+e);return e.slice(0,t)}function l(e,t){if(e==="A"+t[0].repeat(26))throw Error("invalid order key: "+e);let r=o(e);if(e.slice(r.length).slice(-1)===t[0])throw Error("invalid order key: "+e)}function c(e,t){s(e);let[r,...n]=e.split(""),i=!0;for(let e=n.length-1;i&&e>=0;e--){let r=t.indexOf(n[e])+1;r===t.length?n[e]=t[0]:(n[e]=t[r],i=!1)}if(!i)return r+n.join("");{if("Z"===r)return"a"+t[0];if("z"===r)return null;let e=String.fromCharCode(r.charCodeAt(0)+1);return e>"a"?n.push(t[0]):n.pop(),e+n.join("")}}function u(e,t,r=n){if(null!=e&&l(e,r),null!=t&&l(t,r),null!=e&&null!=t&&e>=t)throw Error(e+" >= "+t);if(null==e){if(null==t)return"a"+r[0];let e=o(t),n=t.slice(e.length);if(e==="A"+r[0].repeat(26))return e+i("",n,r);if(e<t)return e;let a=function(e,t){s(e);let[r,...n]=e.split(""),i=!0;for(let e=n.length-1;i&&e>=0;e--){let r=t.indexOf(n[e])-1;-1===r?n[e]=t.slice(-1):(n[e]=t[r],i=!1)}if(!i)return r+n.join("");{if("a"===r)return"Z"+t.slice(-1);if("A"===r)return null;let e=String.fromCharCode(r.charCodeAt(0)-1);return e<"Z"?n.push(t.slice(-1)):n.pop(),e+n.join("")}}(e,r);if(null==a)throw Error("cannot decrement any more");return a}if(null==t){let t=o(e),n=e.slice(t.length),s=c(t,r);return null==s?t+i(n,null,r):s}let a=o(e),d=e.slice(a.length),f=o(t),h=t.slice(f.length);if(a===f)return a+i(d,h,r);let p=c(a,r);if(null==p)throw Error("cannot increment any more");return p<t?p:a+i(d,null,r)}r.d(t,{TU:()=>u,YT:()=>function e(t,r,i,s=n){if(0===i)return[];if(1===i)return[u(t,r,s)];if(null==r){let e=u(t,r,s),n=[e];for(let t=0;t<i-1;t++)n.push(e=u(e,r,s));return n}if(null==t){let e=u(t,r,s),n=[e];for(let r=0;r<i-1;r++)n.push(e=u(t,e,s));return n.reverse(),n}let a=Math.floor(i/2),o=u(t,r,s);return[...e(t,o,a,s),o,...e(o,r,i-a-1,s)]}})},2978(e,t,r){let n;r.d(t,{Ov:()=>tS,Tx:()=>tA,UA:()=>nT,yE:()=>eG,Ky:()=>eb,e5:()=>eD,Uh:()=>eJ,XV:()=>iy,r8:()=>ib,rR:()=>nN});var i=r(8861),s=r(8619),a=r(7720),o=r(190),l=r(5089),c=r(9177),u=r(6030),d=r(3833),f=r(995),h=r(4858),p=r(6310);let m=/[,;]\s*(?:id|label|kind|group|source|target|title|direction|nodes|edges)\s*:?\s*$/i;function g(e){let t=e.trim();for(;;){let e=t.replace(m,"").trim();if(e===t)return t;t=e}}class y extends i.Xsx("ContractSchemaIssue")({code:N("custom"),message:i.QfV,path:i.O31(i.pHd)},{identifier:void 0}){}class b extends i.X0d()("ContractSchemaError",{issues:i.O31(i.O3D(y))}){}let v=e=>{var t;if("InvalidType"!==e._tag)return u.vp(e);let r=d.isSome(e.actual)?e.actual.value:void 0;return`Invalid input: expected ${t=e.ast,c.Kg(t)?"string":c.Et(t)?"number":c.Lm(t)?"boolean":c.tF(t)?"array":c.RP(t)?"object":c.c$(t)?JSON.stringify(t.literal):"value"}, received ${null===r?"null":Array.isArray(r)?"array":typeof r}`},w=u.ID({leafHook:v});function x(e){return"string"==typeof e||"number"==typeof e||"symbol"==typeof e}function k(e,t){let r,n=i.q$Z(e,{errors:"all"})(t);return f.oJ(n)?{data:n.success,success:!0}:{error:new b({issues:(r=w(n.failure.issue).issues.map(e=>{let t=(e.path??[]).flatMap(e=>{let t=x(e)?e:null!==e&&"object"==typeof e&&"key"in e&&x(e.key)?e.key:void 0;return void 0===t?[]:[t]});return{code:"custom",message:e.message,path:e.message.startsWith("Invalid discriminator value.")?[...t,"op"]:t}})).length>1&&r.every(e=>"source"===e.path[0])?[{code:"custom",message:"Invalid input",path:["source"]}]:r}),success:!1}}function S(e){return Object.assign(e,{parse:t=>(function(e,t){let r=k(e,t);if(r.success)return r.data;throw r.error})(e,t),safeParse:t=>k(e,t)})}let _=new Set(["const","exclusiveMaximum","exclusiveMinimum","maximum","maxLength","minimum","minItems","minLength","pattern"]);function O(e){let t=i._oz(i.AxX(e),{includeAnnotationKey:e=>_.has(e)});return{$schema:"https://json-schema.org/draft/2020-12/schema",...t.schema,...0===Object.keys(t.definitions).length?{}:{$defs:t.definitions}}}function I(e){return i.O31(e).pipe(i.fXn).annotate({minItems:1}).check(i.HNH(e=>e.length>=1,{message:"Too small: expected array to have >=1 items"}))}function $(e){let t=i.hzj()([e],([e])=>(t,r,n)=>void 0===t?a.PyW(void 0):h._R(e)(t,n),{toCodecJson:([e])=>i.nfo()(e,{decode:p.le({strict:!1}),encode:new p.uB(e=>a.PyW(d.filter(e,e=>void 0!==e)))})});return i.Qrq(t)}function E(e){return e.pipe(i.usV({messageMissingKey:"Invalid input: expected string, received undefined"}))}function C(e){return e.pipe(i.usV({messageMissingKey:"Invalid input: expected object, received undefined"}))}function A(e){return e.pipe(i.usV({messageMissingKey:"Invalid input: expected array, received undefined"}))}function T(e){return i.xCb(e).annotate({message:`Invalid option: expected one of ${e.map(e=>JSON.stringify(e)).join("|")}`})}function N(e){return i.uSQ(e).pipe(i.GLL(i.QfV.annotate({const:e}).pipe(i.YPB(t=>t===e,{message:`Invalid literal value, expected ${JSON.stringify(e)}`}))))}function M(e){return i.uSQ(e).pipe(i.GLL(i.wNn.annotate({const:e}).pipe(i.YPB(t=>t===e,{message:`Invalid literal value, expected ${JSON.stringify(e)}`}))))}function P(e){return i.uSQ(e).pipe(i.GLL(i.v8c.annotate({const:e}).pipe(i.YPB(t=>t===e,{message:`Invalid literal value, expected ${JSON.stringify(e)}`}))))}let j=i.QfV.annotate({minLength:1}).check(i.HNH(e=>e.length>=1,{message:"Too small: expected string to have >=1 characters"})),D=E(j),F=i.wYs,L=i.wNn.annotate({exclusiveMinimum:0}).check(i.MIs(),i.HNH(e=>e>0,{message:"Too small: expected number to be >0"})),R=/^#[0-9a-fA-F]{6}$/;function U(e){return i.QfV.annotate({pattern:R.source,...void 0===e?{}:{default:e}}).check(i.HNH(e=>R.test(e),{message:`Invalid string: must match pattern /${R.source}/`}))}let B=U();S(B);let Y=["excalidraw","scene","png"],X=["excalidraw","scene"],W=Object.assign(S(T(Y)),{options:Y}),J=Object.assign(S(T(X)),{options:X});class q extends i.Xsx("ArtifactProvenance")({sourceArtifactId:D.pipe(i.Wa3)},{identifier:void 0}){}S(q);let K=["missing_field","invalid_type","invalid_enum","invalid_color","duplicate_node_id","duplicate_edge_id","missing_edge_source","missing_edge_target","self_loop","missing_start","multiple_starts","missing_end","start_has_incoming","end_has_outgoing","unreachable_node","nonterminating_node","missing_outgoing_edge","underbranched_decision","unlabeled_decision_branch","duplicate_decision_branch_label","disconnected_graph","flowchart_too_large","mindmap_too_deep","mindmap_too_large","request_too_large","generic_label","label_too_long","quality_below_threshold","render_failed","text_overflow","arrow_binding_invalid","arrow_overlap","export_invalid_scene","storage_read_failed","storage_write_failed","unsupported_artifact_format","patch_source_unavailable","unknown_patch_target","unsupported_patch_operation","patch_preserve_connectivity_failed","patch_output_invalid"],V=Object.assign(S(T(K)),{options:K}),G=T(["request","diagram","node","edge","artifact"]),H=T(["input","flowchart","mindmap","quality","render","export","storage"]);class z extends i.Xsx("CodeModeIssueRef")({kind:G,id:$(j),path:$(j)},{identifier:void 0}){}S(z);class Q extends i.Xsx("CodeModeIssue")({code:V,severity:T(["error","warning"]),stage:H,ref:$(z),message:D,hint:D},{identifier:void 0}){}S(Q);let Z=["start","process","decision","end"],ee=Object.assign(S(T(Z)),{options:Z}),et=["setDefaultStyle","setStyle","setShape","translate","replaceText","rerouteEdges"];Object.assign(S(T(et)),{options:et});class er extends i.Xsx("FlowchartSpecNode")({id:D,label:D,kind:ee,description:$(j)},{identifier:void 0}){}class en extends i.Xsx("FlowchartSpecEdge")({id:$(j),source:D,target:D,label:$(j)},{identifier:void 0}){}let ei=T(["TB","LR"]),es=ei.annotate({default:"TB"}).pipe(i.tiU(a.PyW("TB")));class ea extends i.Xsx("FlowchartSpecLayout")({direction:es},{identifier:void 0}){}let eo="#000000",el=U(eo).pipe(i.tiU(a.PyW(eo))),ec="#ffffff",eu=U(ec).pipe(i.tiU(a.PyW(ec)));class ed extends i.Xsx("FlowchartSpecStyle")({accentColor:el,backgroundColor:eu},{identifier:void 0}){}let ef=[],eh=i.O31(en).pipe(i.fXn).annotate({default:ef}).pipe(i.tiU(a.PyW(ef))),ep={direction:"TB"},em=ea.annotate({default:ep}).pipe(i.tiU(a.PyW(ep))),eg={accentColor:"#000000",backgroundColor:"#ffffff"},ey=ed.annotate({default:eg}).pipe(i.tiU(a.PyW(eg)));class eb extends i.Xsx("FlowchartSpec")({id:$(j),title:D,nodes:A(I(er)),edges:eh,layout:em,style:ey},{identifier:void 0}){}S(eb),S(er),S(en),S(ea),S(ed);let ev=$(I(W)),ew=$(i.O31(J).pipe(i.fXn)),ex=$(i.wNn.annotate({minimum:0,maximum:10}).check(i.MIs(),i.HNH(e=>e>=0,{message:"Too small: expected number to be >=0"}),i.HNH(e=>e<=10,{message:"Too big: expected number to be <=10"})));class ek extends i.Xsx("BuildFlowchartOptions")({artifactFormats:ev,inlineArtifacts:ew,minQualityScore:ex},{identifier:void 0}){}S($(ek));class eS extends i.Xsx("BuildFlowchartRequest")({requestId:$(j),spec:C(eb),options:$(ek)},{identifier:void 0}){}let e_=eS.mapFields(({requestId:e,spec:t})=>({requestId:e,spec:t})),eO=i.rcy(e_,{leafHook:v,parseOptions:{errors:"all"}});Object.assign(eO["~standard"],{jsonSchema:{input:()=>O(e_),output:()=>O(e_)}});let eI=Object.assign(S(eS),{omit:e=>eO}),e$=i.QfV.annotate({minLength:1}).check(i.HNH(e=>e.length>=1,{message:"Too small: expected string to have >=1 characters"}),i.HNH(function(e){let t=g(e);return t.length>0&&!/^(?:""|''|``)$/.test(t)},{message:"Must contain semantic text after normalization."})),eE=C(i.DYE(()=>eC).annotate({identifier:"__schema0"})),eC=i._kM({label:E(e$),children:i.Qrq(i.O31(eE).pipe(i.fXn))});S(eE);class eA extends i.Xsx("MindmapSpecLayout")({direction:T(["LR","RL"]).annotate({default:"LR"}).pipe(i.tiU(a.PyW("LR")))},{identifier:void 0}){}let eT={direction:"LR"},eN=eA.annotate({default:eT}).pipe(i.tiU(a.PyW(eT))),eM={accentColor:"#7c3aed",backgroundColor:"#ffffff"},eP=ed.annotate({default:eM}).pipe(i.tiU(a.PyW(eM))),ej=i._kM({id:$(j),title:E(e$),root:eE,layout:eN,style:eP});class eD extends i.Xsx("MindmapSpec")(ej,{identifier:void 0}){}S(eD);let eF=i._kM({requestId:$(j),spec:C(ej),options:$(ek)});i.Xsx("BuildMindmapRequest")(eF,{identifier:void 0});let eL=S(eF);class eR extends i.Xsx("ScenePoint")({x:F.pipe(i.Wa3),y:F.pipe(i.Wa3)},{identifier:void 0}){}S(eR);class eU extends i.Xsx("NodeSceneElement")({type:N("node"),id:D,nodeId:D,kind:$(j),shape:T(["rectangle","ellipse","diamond","circle"]).pipe(i.Wa3),fillColor:$(B).pipe(i.Wa3),strokeColor:$(B).pipe(i.Wa3),textColor:$(B).pipe(i.Wa3),x:F.pipe(i.Wa3),y:F.pipe(i.Wa3),width:L.pipe(i.Wa3),height:L.pipe(i.Wa3),label:D.pipe(i.Wa3)},{identifier:void 0}){}class eB extends i.Xsx("TextSceneElement")({type:N("text"),id:D,containerId:$(j),textColor:$(B).pipe(i.Wa3),x:F.pipe(i.Wa3),y:F.pipe(i.Wa3),text:D.pipe(i.Wa3),fontSize:L,maxWidth:$(L)},{identifier:void 0}){}class eY extends i.Xsx("ArrowSceneElement")({type:N("arrow"),id:D,edgeId:D,sourceNodeId:D,targetNodeId:D.pipe(i.Wa3),strokeColor:$(B).pipe(i.Wa3),textColor:$(B).pipe(i.Wa3),points:A(i.O31(eR).pipe(i.fXn)).annotate({minItems:2}).check(i.HNH(e=>e.length>=2,{message:"Too small: expected array to have >=2 items"})).pipe(i.Wa3),label:$(j).pipe(i.Wa3)},{identifier:void 0}){}S(eU),S(eB),S(eY);let eX=i.gPz([eU,eB,eY],{mode:"oneOf"});class eW extends i.Xsx("RenderedDiagramScene")({diagramId:D,title:D,width:L.pipe(i.Wa3),height:L.pipe(i.Wa3),accentColor:B.pipe(i.Wa3),backgroundColor:B.pipe(i.Wa3),elements:A(i.O31(eX).pipe(i.fXn))},{identifier:void 0}){}let eJ=S(eW),eq=i.mSG(i.QfV,i.$r1).check(i.HNH(e=>"string"==typeof e.id&&e.id.length>0&&"string"==typeof e.type&&e.type.length>0,{message:"Invalid input"}));S(eq);class eK extends i.Xsx("ExcalidrawScene")({appState:i.mSG(i.QfV,i.$r1),elements:i.O31(eq).pipe(i.fXn)},{identifier:void 0}){}S(eK);class eV extends eK.extend("ExcalidrawFile")({files:i.mSG(i.QfV,i.$r1),source:D,type:N("excalidraw"),version:M(2)},{identifier:void 0}){}let eG=S(eV);class eH extends i.Xsx("GetArtifactRequest")({artifactId:D,format:$(W),inline:$(i.v8c)},{identifier:void 0}){}let ez=S(eH);class eQ extends i.Xsx("DiagramSelector")({ids:$(i.O31(j).pipe(i.fXn)),nodeIds:$(i.O31(j).pipe(i.fXn)),edgeIds:$(i.O31(j).pipe(i.fXn)),kinds:$(i.O31(ee).pipe(i.fXn)),labels:$(i.O31(j).pipe(i.fXn)),scope:$(T(["all","nodes","edges"]))},{identifier:void 0}){}S(eQ);class eZ extends i.Xsx("DiagramStylePatch")({strokeColor:$(B),fillColor:$(B),textColor:$(B),backgroundColor:$(B)},{identifier:void 0}){}S(eZ);let e0=["rectangle","diamond","ellipse","circle"],e1=Object.assign(S(T(e0)),{options:e0});class e2 extends i.Xsx("SetDefaultStyleOperation")({op:N("setDefaultStyle"),style:C(eZ)},{identifier:void 0}){}class e3 extends i.Xsx("SetStyleOperation")({op:N("setStyle"),selector:C(eQ),style:C(eZ)},{identifier:void 0}){}class e5 extends i.Xsx("SetShapeOperation")({op:N("setShape"),selector:C(eQ),shape:e1},{identifier:void 0}){}class e6 extends i.Xsx("TranslateOperation")({op:N("translate"),selector:C(eQ),dx:F,dy:F},{identifier:void 0}){}class e8 extends i.Xsx("ReplaceTextOperation")({op:N("replaceText"),selector:C(eQ),text:D},{identifier:void 0}){}class e9 extends i.Xsx("RerouteEdgesOperation")({op:N("rerouteEdges"),selector:$(eQ)},{identifier:void 0}){}let e4=i.gPz([e2,e3,e5,e6,e8,e9],{mode:"oneOf"}).annotate({message:`Invalid discriminator value. Expected ${et.map(e=>`'${e}'`).join(" | ")}`});class e7 extends i.Xsx("ArtifactPatchSource")({artifactId:D,format:$(N("scene"))},{identifier:void 0}){}class te extends i.Xsx("InlineScenePatchSource")({scene:C(eW)},{identifier:void 0}){}let tt=i.gPz([e7,te]).annotate({message:"Invalid input"});class tr extends i.Xsx("ApplyDiagramPatchOptions")({artifactFormats:ev,inlineArtifacts:ew,preserveConnectivity:$(i.v8c)},{identifier:void 0}){}S($(tr));class tn extends i.Xsx("ApplyDiagramPatchRequest")({requestId:$(j),source:tt.annotateKey({messageMissingKey:"Invalid input"}),operations:A(I(e4)).pipe(i.rvE({minItems:1})),options:$(tr),intent:$(j)},{identifier:void 0}){}let ti=S(tn),ts=i._kM({id:j,title:j,nodes:i.O31(er).pipe(i.fXn),edges:i.O31(en.mapFields(e=>({...e,id:j}))).pipe(i.fXn),layout:i._kM({direction:ei}),style:i._kM({accentColor:B,backgroundColor:B})}),ta=i._kM({id:j,label:j,children:i.O31(i.DYE(()=>ta)).pipe(i.fXn)}),to=i._kM({id:j,title:j,root:ta,layout:i._kM({direction:T(["LR","RL"])}),style:i._kM({accentColor:B,backgroundColor:B})}),tl=i._kM({code:i.QfV,passed:i.v8c,severity:T(["error","warning"]),message:i.QfV,refs:i.O31(z).pipe(i.fXn)}),tc=i._kM({accepted:i.v8c,score:i.wNn,threshold:i.wNn,summary:i._kM({nodeCount:i.wNn,edgeCount:i.wNn}),checks:i.O31(tl).pipe(i.fXn)}),tu=i._kM({format:W,mimeType:i.QfV,url:$(i.QfV),expiresAt:$(i.QfV),inline:$(i.$r1),sizeBytes:$(i.wNn)}),td=i._kM({artifactId:i.QfV,diagramId:i.QfV,formats:i.O31(tu).pipe(i.fXn),provenance:$(q),preview:$(tu)}),tf=i._kM({artifactId:$(i.QfV),diagramId:$(i.QfV),formats:$(i.O31(tu).pipe(i.fXn))});class th extends i.Xsx("BuildFlowchartAccepted")({ok:P(!0),status:N("accepted"),buildId:i.QfV,requestId:$(i.QfV),normalizedSpec:ts,quality:tc,artifact:td,issues:i.O31(Q).pipe(i.fXn)},{identifier:void 0}){}class tp extends i.Xsx("BuildFlowchartRejected")({ok:P(!1),status:T(["invalid_input","invalid_flowchart","quality_failed","render_failed","export_failed","storage_failed"]),buildId:$(i.QfV),requestId:$(i.QfV),normalizedSpec:$(ts),quality:$(tc),partial:$(tf),issues:i.O31(Q).pipe(i.fXn)},{identifier:void 0}){}i.gPz([th,tp]);class tm extends i.Xsx("BuildMindmapAccepted")({ok:P(!0),status:N("accepted"),buildId:i.QfV,requestId:$(i.QfV),normalizedSpec:to,quality:tc,artifact:td,issues:i.O31(Q).pipe(i.fXn)},{identifier:void 0}){}class tg extends i.Xsx("BuildMindmapRejected")({ok:P(!1),status:T(["invalid_input","invalid_mindmap","quality_failed","render_failed","export_failed","storage_failed"]),buildId:$(i.QfV),requestId:$(i.QfV),normalizedSpec:$(to),quality:$(tc),partial:$(tf),issues:i.O31(Q).pipe(i.fXn)},{identifier:void 0}){}i.gPz([tm,tg]);class ty extends i.Xsx("GetArtifactAccepted")({ok:P(!0),artifactId:i.QfV,diagramId:i.QfV,format:W,mimeType:i.QfV,url:$(i.QfV),expiresAt:$(i.QfV),inline:$(i.$r1),sizeBytes:$(i.wNn),provenance:$(q)},{identifier:void 0}){}class tb extends i.Xsx("GetArtifactRejected")({ok:P(!1),status:T(["invalid_input","not_found","format_unavailable","expired","storage_failed"]),issues:i.O31(Q).pipe(i.fXn)},{identifier:void 0}){}i.gPz([ty,tb]);class tv extends i.Xsx("ApplyDiagramPatchAccepted")({ok:P(!0),status:N("accepted"),patchId:i.QfV,requestId:$(i.QfV),sourceArtifactId:$(i.QfV),artifact:td,issues:i.O31(Q).pipe(i.fXn)},{identifier:void 0}){}class tw extends i.Xsx("ApplyDiagramPatchRejected")({ok:P(!1),status:T(["invalid_input","source_unavailable","target_not_found","unsupported_operation","connectivity_changed","render_failed","export_failed","storage_failed"]),patchId:$(i.QfV),requestId:$(i.QfV),sourceArtifactId:$(i.QfV),partial:$(tf),issues:i.O31(Q).pipe(i.fXn)},{identifier:void 0}){}i.gPz([tv,tw]);let tx=i.xCb(["read","readManifest","write"]);class tk extends i.X0d()("CodeModeArtifactStorageError",{cause:i.kld(),message:i.QfV,operation:tx}){}class tS extends s.kl()("@sketchi/diagram-agent/CodeModeArtifactStorage"){}let t_={excalidraw:"application/vnd.excalidraw+json",png:"image/png",scene:"application/vnd.sketchi.scene+json"};function tO(e){return"excalidraw"===e||"scene"===e}function tI(e){return{format:e.format,mimeType:e.mimeType,sizeBytes:e.sizeBytes}}function t$(e){return structuredClone(e)}function tE(e){return new TextEncoder().encode(JSON.stringify(e)).length}function tC(e){return t=>{var r;return tk.make({cause:t,message:(r="write"===e?"Artifact storage failed.":"Artifact read failed.",t instanceof Error?t.message:r),operation:e})}}let tA=l.QZ(tS)(a.Q56(a.OH5(function(){let e=new Map,t=new Map;return{close:a.OH5(()=>{t.clear(),e.clear()}),storage:{read:a.fn("codeMode.artifacts.memory.read")(function*(e,r){return yield*a.SvU({try:()=>{let n=t.get(`${e}:${r}`);return n?{...n,data:t$(n.data)}:null},catch:tC("read")})}),readManifest:a.fn("codeMode.artifacts.memory.readManifest")(function*(t){return yield*a.SvU({try:()=>{let r=e.get(t);return r?t$(r):null},catch:tC("readManifest")})}),write:a.fn("codeMode.artifacts.memory.write")(function*(r){let n=yield*o.Ru;return yield*a.SvU({try:()=>{var i;let s,a=r.formats.map(tI),o=r.provenance?t$(r.provenance):void 0,l={artifactId:r.artifactId,diagramId:r.diagramId,formats:a,...o?{provenance:o}:{},createdAt:new Date(n).toISOString()};for(let n of(e.set(r.artifactId,l),r.formats))t.set(`${r.artifactId}:${n.format}`,{...n,data:t$(n.data)});let c=r.formats.map(e=>{var t;return t=r.inlineFormats,{format:e.format,mimeType:e.mimeType,...tO(e.format)&&t.includes(e.format)?{inline:e.data}:{},sizeBytes:e.sizeBytes}});return s=(i={artifactId:r.artifactId,diagramId:r.diagramId,formats:c,...r.provenance?{provenance:t$(r.provenance)}:{}}).formats.find(e=>"scene"===e.format),{artifactId:i.artifactId,diagramId:i.diagramId,formats:i.formats,...i.provenance?{provenance:i.provenance}:{},...s?{preview:s}:{}}},catch:tC("write")})})}}}),e=>e.close).pipe(a.TjK(e=>e.storage)));function tT(e,t="storage_write_failed"){return{code:t,severity:"error",stage:"storage",message:e,hint:"Retry the request; if it keeps failing, inspect the artifact store binding."}}let tN=i.ukk,tM=i.mSG(i.QfV,i.$r1);function tP(e,t){return e.pipe(i.tiU(a.PyW(t)))}function tj(e,t){return i.svK(e,{errors:"all"})(t)}let tD=u.ID();function tF(e){return Object.assign(e,{parse:t=>tj(e,t),safeParse:t=>{let r;return r=i.q$Z(e,{errors:"all"})(t),f.oJ(r)?{data:r.success,success:!0}:{error:{issues:tD(r.failure.issue).issues.map(e=>({message:e.message,path:(e.path??[]).map(e=>"object"==typeof e?e.key:e)}))},success:!1}}})}let tL=i.xCb(["flowchart","mindmap"]),tR=i.xCb(["TB","BT","LR","RL"]),tU=i.xCb(["straight","orthogonal","curved"]);class tB extends i.Xsx("DiagramNode")({id:tN,label:tN,group:i.lqM(tN),kind:i.lqM(tN),metadata:tP(tM,{})}){}tF(tB);class tY extends i.Xsx("DiagramEdge")({id:tN,source:tN,target:tN,label:i.lqM(tN),metadata:tP(tM,{})}){}tF(tY);let tX=i.QfV.check(i.Pto(/^#[0-9a-fA-F]{6}$/));class tW extends i.Xsx("DiagramStyle")({accentColor:tP(tX,"#0f766e"),backgroundColor:tP(tX,"#ffffff")}){}tF(tW);class tJ extends i.Xsx("DiagramLayout")({direction:tP(tR,"LR"),edgeRouting:tP(tU,"orthogonal")}){}tF(tJ);class tq extends i.Xsx("IntermediateDiagram")({id:tN,title:tN,type:tP(tL,"flowchart"),nodes:i.O31(tB).pipe(i.fXn).check(i.tJb(1)),edges:tP(i.O31(tY).pipe(i.fXn),[]),layout:tP(tJ,{direction:"LR",edgeRouting:"orthogonal"}),style:tP(tW,{accentColor:"#0f766e",backgroundColor:"#ffffff"}),metadata:tP(tM,{})}){}tF(tq);class tK extends Error{constructor(e){super(e),this.name="DiagramValidationError"}}let tV=e=>{let t=new Set;for(let r of e){if(t.has(r))return r;t.add(r)}};function tG(e){let t=tV(e.nodes.map(e=>e.id));if(t)throw new tK(`Duplicate node id "${t}" is not allowed.`);let r=tV(e.edges.map(e=>e.id));if(r)throw new tK(`Duplicate edge id "${r}" is not allowed.`);let n=new Set(e.nodes.map(e=>e.id));for(let t of e.edges){if(!n.has(t.source))throw new tK(`Edge "${t.id}" references missing source node "${t.source}".`);if(!n.has(t.target))throw new tK(`Edge "${t.id}" references missing target node "${t.target}".`);if(t.source===t.target)throw new tK(`Edge "${t.id}" cannot connect node "${t.source}" to itself.`)}return e}function tH(e){return tG(tj(tq,e))}let tz="flowchart",tQ=i.xCb(["duplicate_node_id","duplicate_edge_id","missing_edge_source","missing_edge_target","self_loop","missing_start","multiple_starts","missing_end","start_has_incoming","end_has_outgoing","unreachable_node","missing_outgoing_edge","underbranched_decision","unlabeled_decision_branch","duplicate_decision_branch_label","nonterminating_node","flowchart_too_large"]);class tZ extends i.Xsx("FlowchartValidationIssueRef")({kind:i.xCb(["diagram","node","edge"]),id:i.lqM(i.ukk),path:i.lqM(i.ukk)}){}i.Xsx("FlowchartValidationIssue")({code:tQ,ref:i.lqM(tZ),message:i.ukk,hint:i.ukk});let t0=i.xCb(["start","process","decision","end"]);class t1 extends tB.extend("FlowchartNode")({kind:t0,description:i.lqM(i.ukk)}){}class t2 extends tY.extend("FlowchartEdge")({label:i.lqM(i.ukk)}){}class t3 extends tq.extend("FlowchartDiagram")({type:i.uSQ(tz),nodes:i.O31(t1).pipe(i.fXn).check(i.tJb(2)),edges:i.O31(t2).pipe(i.fXn).check(i.tJb(1))}){}let t5=tF(t3);function t6(e){let t=new Set,r=new Set;for(let n of e)t.has(n)?r.add(n):t.add(n);return[...r]}function t8(e,t,r){let n=new Set,i=[...e];for(let e=0;e<i.length;e+=1){let s=i[e];if(!(void 0===s||n.has(s)))for(let e of(n.add(s),t.get(s)??[]))i.push(r(e))}return n}function t9(e){let t=[],r=new Set(e.nodes.map(e=>e.id)),{incoming:n,outgoing:i}=function(e){let t=new Map,r=new Map;for(let n of e)t.set(n.target,[...t.get(n.target)??[],n]),r.set(n.source,[...r.get(n.source)??[],n]);return{incoming:t,outgoing:r}}(e.edges);for(let r of(e.nodes.length>24&&t.push({code:"flowchart_too_large",ref:{kind:"diagram",id:e.id,path:"nodes"},message:`Flowchart has ${e.nodes.length} nodes; the supported maximum is 24.`,hint:"Split the workflow or combine lower-signal steps."}),e.edges.length>64&&t.push({code:"flowchart_too_large",ref:{kind:"diagram",id:e.id,path:"edges"},message:`Flowchart has ${e.edges.length} edges; the supported maximum is 64.`,hint:"Split the workflow or remove lower-signal connections."}),t6(e.nodes.map(e=>e.id))))t.push({code:"duplicate_node_id",ref:{kind:"node",id:r,path:"nodes"},message:`Node id "${r}" is used more than once.`,hint:"Give every node a stable unique id."});for(let r of t6(e.edges.map(e=>e.id)))t.push({code:"duplicate_edge_id",ref:{kind:"edge",id:r,path:"edges"},message:`Edge id "${r}" is used more than once.`,hint:"Give every edge a stable unique id."});for(let n of e.edges)r.has(n.source)||t.push({code:"missing_edge_source",ref:{kind:"edge",id:n.id,path:"edges.source"},message:`Edge "${n.id}" references missing source node "${n.source}".`,hint:"Set edge.source to one of the diagram node ids."}),r.has(n.target)||t.push({code:"missing_edge_target",ref:{kind:"edge",id:n.id,path:"edges.target"},message:`Edge "${n.id}" references missing target node "${n.target}".`,hint:"Set edge.target to one of the diagram node ids."}),n.source===n.target&&t.push({code:"self_loop",ref:{kind:"edge",id:n.id},message:`Edge "${n.id}" connects node "${n.source}" to itself.`,hint:"Connect the edge to a different target node."});let s=e.nodes.filter(e=>"start"===e.kind),a=e.nodes.filter(e=>"end"===e.kind);for(let r of(0===s.length?t.push({code:"missing_start",ref:{kind:"diagram",id:e.id,path:"nodes"},message:"Flowchart must contain exactly one start node.",hint:'Mark the first node in the flow with kind: "start".'}):s.length>1&&t.push({code:"multiple_starts",ref:{kind:"diagram",id:e.id,path:"nodes"},message:`Flowchart has ${s.length} start nodes.`,hint:"Keep one start node and change the others to process, decision, or end."}),0===a.length&&t.push({code:"missing_end",ref:{kind:"diagram",id:e.id,path:"nodes"},message:"Flowchart must contain at least one end node.",hint:'Add an end node or mark terminal outcomes with kind: "end".'}),e.nodes)){let e=n.get(r.id)??[],s=i.get(r.id)??[];"start"===r.kind&&e.length>0&&t.push({code:"start_has_incoming",ref:{kind:"node",id:r.id},message:`Start node "${r.id}" cannot have incoming edges.`,hint:"Route the start node only to later nodes."}),"end"===r.kind&&s.length>0&&t.push({code:"end_has_outgoing",ref:{kind:"node",id:r.id},message:`End node "${r.id}" cannot have outgoing edges.`,hint:"End nodes must be terminal outcomes."}),"end"!==r.kind&&0===s.length&&t.push({code:"missing_outgoing_edge",ref:{kind:"node",id:r.id},message:`Node "${r.id}" must have at least one outgoing edge.`,hint:'Connect it to the next step, or mark it as kind: "end".'}),"decision"===r.kind&&t.push(...function(e,t){let r=[];t.length<2&&r.push({code:"underbranched_decision",ref:{kind:"node",id:e.id},message:`Decision node "${e.id}" must have at least two outgoing branches.`,hint:"Add at least two outgoing edges for the decision outcomes."});let n=t.map(e=>e.label?.trim()??"");for(let n of t.filter(e=>!e.label?.trim()))r.push({code:"unlabeled_decision_branch",ref:{kind:"edge",id:n.id,path:"edges.label"},message:`Decision node "${e.id}" has an outgoing branch without a label.`,hint:'Add a short branch label such as "yes", "no", "approved", or "rejected".'});for(let t of t6(n.filter(e=>e.length>0).map(e=>e.toLowerCase())))r.push({code:"duplicate_decision_branch_label",ref:{kind:"node",id:e.id},message:`Decision node "${e.id}" repeats branch label "${t}".`,hint:"Make every outgoing branch label from the same decision unique."});return r}(r,s))}let o=1===s.length?s[0]:void 0;if(o){let r=t8([o.id],i,e=>e.target);for(let n of e.nodes)r.has(n.id)||t.push({code:"unreachable_node",ref:{kind:"node",id:n.id},message:`Node "${n.id}" is not reachable from the start node.`,hint:"Connect every node to the flow that begins at the single start node."});if(a.length>0){let s=t8(a.map(e=>e.id),n,e=>e.source);for(let n of e.nodes)r.has(n.id)&&!s.has(n.id)&&(i.get(n.id)?.length??0)>0&&t.push({code:"nonterminating_node",ref:{kind:"node",id:n.id},message:`Node "${n.id}" cannot reach an end node.`,hint:"Add an eventual exit from this path to an end node; retry loops are valid when they retain an exit."})}}return t.slice(0,20)}class t4 extends tK{issues;constructor(e){super(e[0]?.message??"Flowchart failed semantic validation."),this.issues=e,this.name="FlowchartValidationError"}}function t7(e){let t=t9(e);if(t.length>0)throw new t4(t);return e}let re=t7(tj(t3,{id:"onboarding-flow",title:"Sketchi onboarding decision flow",type:tz,nodes:[{id:"prompt",label:"Prompt received",kind:"start"},{id:"requirements",label:"Extract requirements",kind:"process"},{id:"clear",label:"Scope clear?",kind:"decision"},{id:"draft",label:"Draft typed IR",kind:"process"},{id:"review",label:"Review diagram",kind:"end"}],edges:[{id:"prompt-requirements",source:"prompt",target:"requirements"},{id:"requirements-clear",source:"requirements",target:"clear"},{id:"clear-draft",source:"clear",target:"draft",label:"yes"},{id:"clear-review",source:"clear",target:"review",label:"no"},{id:"draft-review",source:"draft",target:"review"}],layout:{direction:"TB",edgeRouting:"orthogonal"},style:{accentColor:"#0f766e",backgroundColor:"#ffffff"}}));t7(tj(t3,{id:"pharma-batch-disposition",title:"Pharma batch disposition flow",type:tz,nodes:[{id:"batch-received",label:"Batch received",kind:"start"},{id:"qa-review",label:"QA reviews Certificate of Analysis",kind:"process"},{id:"passes-specs",label:"Passes specs?",kind:"decision"},{id:"final-review",label:"QA Manager final review",kind:"process"},{id:"packaging",label:"Send to packaging",kind:"end"},{id:"investigate",label:"Investigate retesting",kind:"process"},{id:"reject",label:"Reject batch",kind:"end"}],edges:[{id:"batch-qa",source:"batch-received",target:"qa-review"},{id:"qa-specs",source:"qa-review",target:"passes-specs"},{id:"specs-pass",source:"passes-specs",target:"final-review",label:"yes"},{id:"specs-investigate",source:"passes-specs",target:"investigate",label:"retest"},{id:"specs-reject",source:"passes-specs",target:"reject",label:"reject"},{id:"review-packaging",source:"final-review",target:"packaging"},{id:"investigate-review",source:"investigate",target:"final-review"}],layout:{direction:"TB",edgeRouting:"orthogonal"},style:{accentColor:"#0f766e",backgroundColor:"#ffffff"}}));let rt="mindmap";class rr extends i.Xsx("MindmapNodeMetadata")({depth:i.Aiz.check(i.OWK(0)),siblingIndex:i.Aiz.check(i.OWK(0))}){}class rn extends tB.extend("MindmapNode")({kind:i.xCb(["root","topic"]),metadata:rr}){}class ri extends i.Xsx("MindmapEdgeMetadata")({depth:i.Aiz.check(i.yJO(0)),siblingIndex:i.Aiz.check(i.OWK(0))}){}class rs extends tY.extend("MindmapEdge")({metadata:ri}){}class ra extends tq.extend("MindmapDiagram")({type:i.uSQ(rt),nodes:i.O31(rn).pipe(i.fXn).check(i.tJb(2)),edges:i.O31(rs).pipe(i.fXn).check(i.tJb(1))}){}function ro(e){return function(e){tG(e);let t=e.nodes.filter(e=>"root"===e.kind);if(1!==t.length)throw new tK(`Mindmap must contain exactly one root topic; found ${t.length}.`);let r=t[0];if(!r||0!==r.metadata.depth)throw new tK("Mindmap root topic must have depth 0.");let n=new Map,i=new Map(e.nodes.map(e=>[e.id,e])),s=new Map;for(let t of e.edges){n.set(t.target,(n.get(t.target)??0)+1);let e=i.get(t.source)?.metadata.depth,r=i.get(t.target),a=r?.metadata.depth;if(void 0===e||a!==e+1)throw new tK(`Mindmap edge "${t.id}" must connect a topic to its immediate child.`);if(!r||t.metadata.depth!==r.metadata.depth||t.metadata.siblingIndex!==r.metadata.siblingIndex)throw new tK(`Mindmap edge "${t.id}" metadata must match its child topic.`);s.set(t.source,[...s.get(t.source)??[],r.metadata.siblingIndex])}for(let t of e.nodes){let e=n.get(t.id)??0;if(t.id===r.id?0!==e:1!==e)throw new tK(`Mindmap topic "${t.id}" must have ${t.id===r.id?"no parent":"exactly one parent"}.`)}for(let[e,t]of s){let r=t.map((e,t)=>t);if([...t].sort((e,t)=>e-t).some((e,t)=>e!==r[t]))throw new tK(`Mindmap children of "${e}" must use contiguous sibling ordering from 0.`)}return e}(tj(ra,e))}tF(ra);let rl=ro({id:"public-mindmap-capability",title:"Public mindmap generation",type:rt,nodes:[{id:"topic-0",label:"Public mindmaps",kind:"root",metadata:{depth:0,siblingIndex:0}},{id:"topic-0-0",label:"Semantic input",kind:"topic",metadata:{depth:1,siblingIndex:0}},{id:"topic-0-0-0",label:"Nested topics",kind:"topic",metadata:{depth:2,siblingIndex:0}},{id:"topic-0-0-1",label:"Stable ordering",kind:"topic",metadata:{depth:2,siblingIndex:1}},{id:"topic-0-1",label:"Artifact output",kind:"topic",metadata:{depth:1,siblingIndex:1}},{id:"topic-0-1-0",label:"Scene",kind:"topic",metadata:{depth:2,siblingIndex:0}},{id:"topic-0-1-1",label:"Excalidraw",kind:"topic",metadata:{depth:2,siblingIndex:1}}],edges:[{id:"branch-0-0",source:"topic-0",target:"topic-0-0",metadata:{depth:1,siblingIndex:0}},{id:"branch-0-0-0",source:"topic-0-0",target:"topic-0-0-0",metadata:{depth:2,siblingIndex:0}},{id:"branch-0-0-1",source:"topic-0-0",target:"topic-0-0-1",metadata:{depth:2,siblingIndex:1}},{id:"branch-0-1",source:"topic-0",target:"topic-0-1",metadata:{depth:1,siblingIndex:1}},{id:"branch-0-1-0",source:"topic-0-1",target:"topic-0-1-0",metadata:{depth:2,siblingIndex:0}},{id:"branch-0-1-1",source:"topic-0-1",target:"topic-0-1-1",metadata:{depth:2,siblingIndex:1}}],layout:{direction:"LR",edgeRouting:"curved"},style:{accentColor:"#7c3aed",backgroundColor:"#ffffff"}});tH(re),tH(rl);var rc=r(1580);let ru=new Set(["rectangle","ellipse","diamond"]);function rd(e){return"number"==typeof e&&Number.isFinite(e)?e:null}function rf(e){if(!Array.isArray(e)||e.length<2)return null;let t=rd(e[0]),r=rd(e[1]);return null===t||null===r?null:[t,r]}function rh(e){let t=rd(e.x),r=rd(e.y),n=rd(e.width),i=rd(e.height);return null===t||null===r||null===n||null===i?null:{x:t,y:r,width:n,height:i}}function rp(e){return 1e-4>Math.abs(e-.5)?.5001:e}function rm(e,t){let r;return{elementId:e?.id??"",focus:0,gap:0,fixedPoint:e?(r=rh(e))&&0!==r.width&&0!==r.height?[rp((t.x-r.x)/r.width),rp((t.y-r.y)/r.height)]:null:null}}function rg(e,t){let r=function(e){let t=0x811c9dc5;for(let r of e)t^=r.charCodeAt(0),t=Math.imul(t,0x1000193);return Math.abs(t)||1}(e);return{id:e,angle:0,fillStyle:"solid",frameId:null,groupIds:[],index:t,isDeleted:!1,link:null,locked:!1,opacity:100,roughness:1,seed:r,strokeStyle:"solid",strokeWidth:2,updated:1,version:1,versionNonce:r+1}}function ry(e,t){return Math.ceil(e.split("\n").length*t*1.35)}function rb(e){var t,r;let n=Math.max(1,Math.min(e.maxWidth,(t=e.text,r=e.fontSize,Math.ceil(Math.max(...t.split("\n").map(e=>e.length))*r*.62)))),i=ry(e.text,e.fontSize);return{...rg(e.id,e.index),type:"text",x:e.x-n/2,y:e.y-i/2,width:n,height:i,backgroundColor:"transparent",boundElements:null,containerId:e.containerId,fontFamily:5,fontSize:e.fontSize,lineHeight:1.35,originalText:e.text,roundness:null,strokeColor:e.textColor??"#1e1e1e",text:e.text,textAlign:"center",verticalAlign:"middle",autoResize:!0}}function rv(e){return e.points[e.points.length-1]??e.points[0]}function rw(e){return"node"===e.type}function rx(e){return"text"===e.type}function rk(e){return"arrow"===e.type}function rS(e){let t=e.elements.filter(rw),r=new Map(e.elements.filter(rx).map(e=>[e.containerId??"",e])),n=e.elements.filter(rk),i=function(e){let t=new Map;for(let r of e)for(let e of[r.sourceNodeId,r.targetNodeId]){let n=`node:${e}`;t.set(n,[...t.get(n)??[],r.id])}return t}(n),s=new Map,a=[],o=null,l=()=>{let e=(0,rc.TU)(o,null);return o=e,e};for(let n of t){let t=r.get(n.id),o=function(e){let t=e.text?ry(e.text.text,e.text.fontSize)+18:0,r=Math.max(e.shape.height,t),n="circle"===e.shape.shape?"ellipse":e.shape.shape,i=[...e.text?[{id:e.text.id,type:"text"}]:[],...e.arrowIds.map(e=>({id:e,type:"arrow"}))];return{...rg(e.shape.id,e.index),type:n,x:e.shape.x,y:e.shape.y,width:e.shape.width,height:r,backgroundColor:e.shape.fillColor??"transparent",boundElements:i.length>0?i:null,roundness:"rectangle"===n?{type:3}:null,strokeColor:e.shape.strokeColor??e.scene.accentColor}}({scene:e,shape:n,arrowIds:i.get(n.id)??[],index:l(),...t?{text:t}:{}});s.set(n.nodeId,o),a.push(o)}for(let t of e.elements.filter(rx))t.containerId&&a.push(rb({id:t.id,index:l(),containerId:t.containerId,fontSize:t.fontSize,maxWidth:t.maxWidth??160,...t.textColor?{textColor:t.textColor}:{},text:t.text,x:t.x,y:t.y}));for(let t of n){a.push(function(e){let t=e.arrow.points[0],r=rv(e.arrow),n=e.arrow.points.length>2;return{...rg(e.arrow.id,e.index),type:"arrow",x:t.x,y:t.y,width:r.x-t.x,height:r.y-t.y,backgroundColor:"transparent",boundElements:e.arrow.label?[{id:`${e.arrow.id}:label`,type:"text"}]:null,elbowed:n,endArrowhead:"arrow",endBinding:rm(e.targetShape,r),...n?{fixedSegments:[],startIsSpecial:null,endIsSpecial:null}:{},points:e.arrow.points.map(e=>[e.x-t.x,e.y-t.y]),roundness:n?null:{type:2},startArrowhead:null,startBinding:rm(e.sourceShape,t),strokeColor:e.arrow.strokeColor??e.scene.accentColor}}({arrow:t,scene:e,index:l(),sourceShape:s.get(t.sourceNodeId),targetShape:s.get(t.targetNodeId)}));let r=t.label?function(e){if(!e.arrow.label)return null;let t=e.arrow.points[0],r=rv(e.arrow);return rb({id:`${e.arrow.id}:label`,index:e.index,containerId:e.arrow.id,fontSize:13,maxWidth:160,...e.arrow.textColor?{textColor:e.arrow.textColor}:{},text:e.arrow.label,x:(t.x+r.x)/2,y:(t.y+r.y)/2-10})}({arrow:t,index:l()}):null;r&&a.push(r)}return{appState:{viewBackgroundColor:e.backgroundColor,zoom:{value:Math.max(.42,Math.round(100*Math.min(1,860/Math.max(e.width,1),340/Math.max(e.height,1)))/100)}},elements:a}}function r_(e,t){let r=e[t];if(!(r&&"object"==typeof r))return null;let n=r.elementId;return"string"==typeof n?n:null}function rO(e){return rf(e)}function rI(e){let t=rd(e.x)??0,r=rd(e.y)??0,n=r_(e,"startBinding"),i=r_(e,"endBinding"),s=Array.isArray(e.points)?e.points.map(rO).filter(e=>!!e):[],a=[];for(let o=0;o<s.length-1;o+=1){let l=s[o],c=s[o+1];if(!l||!c)continue;let[u,d]=l,[f,h]=c,p=t+u,m=r+d,g=t+f,y=r+h;if(.001>=Math.abs(m-y)){a.push({arrowId:e.id,endBindingElementId:i,isLastSegment:o===s.length-2,max:Math.max(p,g),min:Math.min(p,g),orientation:"horizontal",segmentIndex:o,startBindingElementId:n,staticCoordinate:m});continue}.001>=Math.abs(p-g)&&a.push({arrowId:e.id,endBindingElementId:i,isLastSegment:o===s.length-2,max:Math.max(m,y),min:Math.min(m,y),orientation:"vertical",segmentIndex:o,startBindingElementId:n,staticCoordinate:p})}return a.filter(e=>e.max-e.min>.001)}function r$(e,t,r){return e>t+.01&&e<r-.01}function rE(e,t,r,n){return Math.min(t,n)-Math.max(e,r)>.01}function rC(e,t,r){return e>=t-.01&&e<=r+.01}function rA(e,t){return .01>=Math.abs(e-t)}function rT(e){let t=[],r=new Map(e.elements.map(e=>[e.id,e])),n=new Set(e.elements.filter(e=>ru.has(e.type)).map(e=>e.id));for(let i of(0===n.size&&t.push({code:"empty-scene",message:"Excalidraw scene must contain at least one shape."}),e.elements)){if("arrow"===i.type){let e=!0===i.elbowed;for(let s of((Array.isArray(i.points)?i.points:[]).length>2&&!e&&t.push({code:"invalid-elbow-binding",elementId:i.id,message:`Arrow "${i.id}" has an orthogonal route but is not marked elbowed.`}),e&&null!==i.fixedSegments&&!Array.isArray(i.fixedSegments)&&t.push({code:"invalid-elbow-binding",elementId:i.id,message:`Elbow arrow "${i.id}" is missing fixedSegments metadata.`}),["startBinding","endBinding"])){let a=r_(i,s);if(!(a&&n.has(a))){t.push({code:"missing-arrow-binding",elementId:i.id,message:`Arrow "${i.id}" has invalid ${s}.`});continue}let o=r.get(a);o&&!function(e,t,r){let n=e.boundElements;return!!Array.isArray(n)&&n.some(e=>!!(e&&"object"==typeof e)&&e.id===t&&e.type===r)}(o,i.id,"arrow")&&t.push({code:"missing-bound-arrow",elementId:o.id,message:`Shape "${o.id}" does not include bound arrow "${i.id}".`});let l=function(e,t){let r=rd(e.x)??0,n=rd(e.y)??0,i=Array.isArray(e.points)?e.points.map(rO).filter(e=>!!e):[],s="startBinding"===t?i[0]:i[i.length-1];return s?{x:r+s[0],y:n+s[1]}:null}(i,s);if(o&&l&&!function(e,t){let r=rh(t);if(!r)return!1;if("diamond"===t.type){let t=r.width/2,n=r.height/2;if(0===t||0===n)return!1;let i=r.x+t,s=r.y+n;return rA(Math.abs(e.x-i)/t+Math.abs(e.y-s)/n,1)}if("ellipse"===t.type){let t=r.width/2,n=r.height/2;if(0===t||0===n)return!1;let i=r.x+t,s=r.y+n;return rA(((e.x-i)/t)**2+((e.y-s)/n)**2,1)}let n=(rA(e.x,r.x)||rA(e.x,r.x+r.width))&&rC(e.y,r.y,r.y+r.height),i=(rA(e.y,r.y)||rA(e.y,r.y+r.height))&&rC(e.x,r.x,r.x+r.width);return n||i}(l,o)&&t.push({code:"arrow-endpoint-off-shape",elementId:i.id,message:`Arrow "${i.id}" ${s} endpoint does not land on "${o.id}".`}),o&&l&&e){let e=function(e,t){let r=e[t];return r&&"object"==typeof r?rf(r.fixedPoint):null}(i,s);e&&function(e,t,r){let n=rh(r);if(!n)return!1;let i=1e-4>Math.abs(e[0]-.5001)?.5:e[0],s=1e-4>Math.abs(e[1]-.5001)?.5:e[1];return rA(n.x+i*n.width,t.x)&&rA(n.y+s*n.height,t.y)}(e,l,o)||t.push({code:"invalid-elbow-binding",elementId:i.id,message:`Elbow arrow "${i.id}" has invalid ${s} fixedPoint metadata.`})}}}if("text"===i.type){let e=i.containerId;if("string"!=typeof e)continue;let n=r.get(e);if(!n){t.push({code:"missing-container",elementId:i.id,message:`Text "${i.id}" references missing container "${e}".`});continue}let s="number"==typeof i.width?i.width:0,a="number"==typeof i.height?i.height:0,o="number"==typeof n.width?n.width:0,l="number"==typeof n.height?n.height:0;ru.has(n.type)&&(s+24>o||a+18>l)&&t.push({code:"text-overflow",elementId:i.id,message:`Text "${i.id}" does not fit inside "${e}".`})}}return t.push(...function(e){let t=e.filter(e=>"arrow"===e.type).flatMap(rI),r=e.filter(e=>ru.has(e.type)),n=[],i=new Set;for(let e of t)for(let t of r){if(t.id===e.startBindingElementId||t.id===e.endBindingElementId)continue;let r=rh(t);if(!r||("horizontal"===e.orientation?!(r$(e.staticCoordinate,r.y,r.y+r.height)&&rE(e.min,e.max,r.x,r.x+r.width)):!(r$(e.staticCoordinate,r.x,r.x+r.width)&&rE(e.min,e.max,r.y,r.y+r.height))))continue;let s=`${e.arrowId}:${e.segmentIndex}:${t.id}`;i.has(s)||(i.add(s),n.push({code:"arrow-segment-through-node",elementId:e.arrowId,message:`Arrow "${e.arrowId}" passes through shape "${t.id}".`}))}return n}(e.elements)),t.push(...function(e){let t=e.filter(e=>"arrow"===e.type).flatMap(rI),r=[],n=new Set;for(let e=0;e<t.length;e+=1){let i=t[e];if(i)for(let s=e+1;s<t.length;s+=1){let e=t[s];if(!e||i.arrowId===e.arrowId||i.orientation!==e.orientation||Math.abs(i.staticCoordinate-e.staticCoordinate)>.001||0===i.segmentIndex&&0===e.segmentIndex&&null!==i.startBindingElementId&&i.startBindingElementId===e.startBindingElementId||i.isLastSegment&&e.isLastSegment&&null!==i.endBindingElementId&&i.endBindingElementId===e.endBindingElementId||Math.min(i.max,e.max)-Math.max(i.min,e.min)<=.001)continue;let a=[i.arrowId,i.segmentIndex,e.arrowId,e.segmentIndex].sort().join(":");n.has(a)||(n.add(a),r.push({code:"overlapping-arrow-segment",elementId:i.arrowId,message:`Arrow "${i.arrowId}" overlaps arrow "${e.arrowId}".`}))}}return r}(e.elements)),{ok:0===t.length,issues:t}}function rN(e){return new Map(e.map((e,t)=>[e.id,t]))}function rM(e){return{type:"text",id:`label:${e.nodeId}`,containerId:e.id,x:e.x+e.width/2,y:e.y+e.height/2,text:e.label,fontSize:14,maxWidth:Math.max(1,e.width-36)}}function rP(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function rj(e,t,r){return Math.min(r,Math.max(t,e))}function rD(e,t,r=0){let n,i=(n="top"===t||"bottom"===t?e.width/2-16:e.height/2-16)>0?rj(r,-n,n):0,s=rP(e),a=e.width/2,o=e.height/2;if("diamond"===e.shape&&a>0&&o>0){if("top"===t||"bottom"===t){let e=s.x+i,r=o*(1-Math.abs(i)/a);return{x:e,y:"top"===t?s.y-r:s.y+r}}let e=s.y+i,r=a*(1-Math.abs(i)/o);return{x:"left"===t?s.x-r:s.x+r,y:e}}if(("ellipse"===e.shape||"circle"===e.shape)&&a>0&&o>0){if("top"===t||"bottom"===t){let e=s.x+i,r=o*Math.sqrt(Math.max(0,1-(i/a)**2));return{x:e,y:"top"===t?s.y-r:s.y+r}}let e=s.y+i,r=a*Math.sqrt(Math.max(0,1-(i/o)**2));return{x:"left"===t?s.x-r:s.x+r,y:e}}switch(t){case"top":return{x:e.x+e.width/2+i,y:e.y};case"right":return{x:e.x+e.width,y:e.y+e.height/2+i};case"bottom":return{x:e.x+e.width/2+i,y:e.y+e.height};case"left":return{x:e.x,y:e.y+e.height/2+i}}}function rF(e){return`${e.edgeId}:${e.endpoint}`}function rL(e){let t=[];for(let r of e){let e=t[t.length-1];e&&e.x===r.x&&e.y===r.y||t.push(r)}let r=t[0];return r?[r,...t.slice(1)]:[{x:0,y:0}]}function rR(e,t,r){return e>t+.01&&e<r-.01}function rU(e,t,r,n){return Math.min(t,n)-Math.max(e,r)>.01}function rB(e,t,r){let n=0;for(let i=0;i<e.length-1;i+=1){let s=e[i],a=e[i+1];if(s&&a)for(let e of t)!r.has(e.nodeId)&&(s.y===a.y?rR(s.y,e.y,e.y+e.height)&&rU(Math.min(s.x,a.x),Math.max(s.x,a.x),e.x,e.x+e.width):s.x===a.x&&rR(s.x,e.x,e.x+e.width)&&rU(Math.min(s.y,a.y),Math.max(s.y,a.y),e.y,e.y+e.height))&&(n+=1)}return n}function rY(e){let t=0;for(let r=0;r<e.length-1;r+=1){let n=e[r],i=e[r+1];n&&i&&(t+=Math.abs(i.x-n.x)+Math.abs(i.y-n.y))}return t}function rX(e){let t=[];for(let r=0;r<e.points.length-1;r+=1){let n=e.points[r],i=e.points[r+1];if(n&&i){if(n.y===i.y){t.push({arrowId:e.arrowId,isFirstSegment:0===r,isLastSegment:r===e.points.length-2,max:Math.max(n.x,i.x),min:Math.min(n.x,i.x),orientation:"horizontal",segmentIndex:r,sourceNodeId:e.sourceNodeId,staticCoordinate:n.y,targetNodeId:e.targetNodeId});continue}n.x===i.x&&t.push({arrowId:e.arrowId,isFirstSegment:0===r,isLastSegment:r===e.points.length-2,max:Math.max(n.y,i.y),min:Math.min(n.y,i.y),orientation:"vertical",segmentIndex:r,sourceNodeId:e.sourceNodeId,staticCoordinate:n.x,targetNodeId:e.targetNodeId})}}return t.filter(e=>e.max-e.min>.01)}function rW(e,t){return Math.min(e.max,t.max)-Math.max(e.min,t.min)}function rJ(e,t,r){let n=rX({arrowId:`edge:${r.edge.id}`,points:e,sourceNodeId:r.edge.source,targetNodeId:r.edge.target}),i=t.flatMap(e=>rX({arrowId:e.id,points:e.points,sourceNodeId:e.sourceNodeId,targetNodeId:e.targetNodeId})),s=0;for(let e of n)for(let t of i)e.arrowId===t.arrowId||e.orientation!==t.orientation||Math.abs(e.staticCoordinate-t.staticCoordinate)>.01||e.isFirstSegment&&t.isFirstSegment&&e.sourceNodeId===t.sourceNodeId||e.isLastSegment&&t.isLastSegment&&e.targetNodeId===t.targetNodeId||.01>=rW(e,t)||(s+=1);return s}function rq(e,t){let r=rX({arrowId:`edge:${t.edge.id}`,points:e,sourceNodeId:t.edge.source,targetNodeId:t.edge.target}),n=0;for(let e=0;e<r.length;e+=1){let t=r[e];if(t)for(let i=e+1;i<r.length;i+=1){let e=r[i];!e||t.orientation!==e.orientation||Math.abs(t.staticCoordinate-e.staticCoordinate)>.01||.01>=rW(t,e)||(n+=1)}}return n}function rK(e){let t=e[0],r=e[e.length-1];if(!t||!r)return 0;let n=e.map(e=>e.x),i=e.map(e=>e.y),s=0;return r.x<t.x?s+=Math.max(0,Math.max(...n)-t.x):r.x>t.x&&(s+=Math.max(0,t.x-Math.min(...n))),r.y<t.y?s+=Math.max(0,Math.max(...i)-t.y):r.y>t.y&&(s+=Math.max(0,t.y-Math.min(...i))),s}function rV(e){let t=e[0],r=e[e.length-1];if(!t||!r)return 0;let n=e.map(e=>e.x),i=e.map(e=>e.y),s=0;return r.x<t.x?s+=Math.max(0,r.x-Math.min(...n)):r.x>t.x&&(s+=Math.max(0,Math.max(...n)-r.x)),r.y<t.y?s+=Math.max(0,r.y-Math.min(...i)):r.y>t.y&&(s+=Math.max(0,Math.max(...i)-r.y)),s}function rG(e,t,r){switch(r){case"top":return t.y<e.y;case"right":return t.x>e.x;case"bottom":return t.y>e.y;case"left":return t.x<e.x}}function rH(e,t){let r=e[0],n=e[1],i=e[e.length-1],s=e[e.length-2],a=0;return n&&rG(r,n,t.sourceEdge)&&(a+=1),s&&i&&rG(i,s,t.targetEdge)&&(a+=1),a}function rz(e,t,r){switch(t){case"top":return{x:e.x,y:e.y-r};case"right":return{x:e.x+r,y:e.y};case"bottom":return{x:e.x,y:e.y+r};case"left":return{x:e.x-r,y:e.y}}}function rQ(e,t,r,n,i){var s;let a,o=Math.abs(r.x-t.x)>=Math.abs(r.y-t.y),l=new Set([e.source.nodeId,e.target.nodeId]),c=Math.min(...n.map(e=>e.x)),u=Math.max(...n.map(e=>e.x+e.width)),d=Math.min(...n.map(e=>e.y)),f=Math.max(...n.map(e=>e.y+e.height)),h="left"===e.sourceEdge||"left"===e.targetEdge||rP(e.target).x<rP(e.source).x,p="top"===e.sourceEdge||"top"===e.targetEdge||rP(e.source).y<=rP(e.target).y,m=18*e.index,g=c-56-m,y=u+56+m,b=d-48-m,v=f+48+m,w=h?g:y,x=h?y:g,k=p?b:v,S=p?v:b,_=[0,36+e.index%4*18],O=(n,i)=>{let s=i>0?rz(t,e.sourceEdge,i):t,a=i>0?rz(r,e.targetEdge,i):r;return rL([t,s,{x:n,y:s.y},{x:n,y:a.y},a,r])},I=(n,i)=>{let s=i>0?rz(t,e.sourceEdge,i):t,a=i>0?rz(r,e.targetEdge,i):r;return rL([t,s,{x:s.x,y:n},{x:a.x,y:n},a,r])},$=[..._.map(e=>I(k,e)),..._.map(e=>I(S,e)),..._.map(e=>O(w,e)),..._.map(e=>O(x,e))],E=[..._.map(e=>O(w,e)),..._.map(e=>O(x,e)),..._.map(e=>I(k,e)),..._.map(e=>I(S,e))];return(a=(s=o?$:E)[0])?s.slice(1).reduce((t,r)=>{let s=rB(t,n,l),a=rB(r,n,l);if(a<s)return r;if(s<a)return t;let o=rq(t,e),c=rq(r,e);if(c<o)return r;if(o<c)return t;let u=rJ(t,i,e),d=rJ(r,i,e);if(d<u)return r;if(u<d)return t;let f=rH(t,e),h=rH(r,e);if(h>f)return r;if(f>h)return t;let p=rK(t),m=rK(r);if(m<p)return r;if(p<m)return t;let g=rV(t),y=rV(r);return y<g?r:g<y?t:rY(r)<rY(t)?r:t},a):[{x:0,y:0}]}function rZ(e){return e.flatMap(e=>"arrow"===e.type?[...e.points]:[{x:e.x,y:e.y},{x:e.x+("node"===e.type?e.width:e.maxWidth??e.text.length),y:e.y+("node"===e.type?e.height:e.fontSize)}])}function r0(e,t,r){return{x:e.x+t,y:e.y+r}}function r1(e){var t;let r,n,i,s,a,o=tH(e),l=function(e){let t="TB"===e.layout.direction||"BT"===e.layout.direction,r=new Map(e.nodes.map(e=>{let t,r,n,i,s;return[e.id,(s=(i=e.label.split("\n").flatMap(e=>(function(e){if(e.length<=18)return[e];let t=[],r="";for(let n of e.split(" ")){if(n.length>18){r&&(t.push(r),r=""),t.push(...function(e){if(e.length<=18)return[e];let t=[];for(let r=0;r<e.length;r+=18)t.push(e.slice(r,r+18));return t}(n));continue}let e=r?`${r} ${n}`:n;if(e.length<=18){r=e;continue}t.push(r),r=n}return r&&t.push(r),t})(e)).join("\n")).split("\n"),t={text:i,width:Math.ceil(14*Math.max(...s.map(e=>e.length))*.62+36),height:Math.ceil(14*s.length*1.35+28)},n="start"===(r=e.kind?.toLowerCase())||"end"===r?"ellipse":"decision"===r?"diamond":"rectangle",{type:"node",id:`node:${e.id}`,nodeId:e.id,...e.kind?{kind:e.kind}:{},shape:n,x:0,y:0,width:Math.max(184,t.width+("diamond"===n?32:20*("ellipse"===n))),height:Math.max(72,t.height+32*("diamond"===n)),label:t.text})]})),n=function(e){let t=new Map,r=new Map;for(let n of e)t.set(n.target,[...t.get(n.target)??[],n]),r.set(n.source,[...r.get(n.source)??[],n]);return{incoming:t,outgoing:r}}(e.edges),i=function(e,t,r){let n=new Map,i=new Set;function s(e){for(let t of(n.set(e,"visiting"),r.get(e)??[])){let e=n.get(t.target);if("visiting"===e){i.add(t.id);continue}e||s(t.target)}n.set(e,"visited")}let a=e.nodes.find(e=>0===(t.get(e.id)??[]).length)??e.nodes[0];for(let t of(a&&s(a.id),e.nodes))n.has(t.id)||s(t.id);return i}(e,n.incoming,n.outgoing),s=function(e,t,r){let n=rN(e.nodes),i=new Map(e.nodes.map(e=>[e.id,0])),s=new Map(e.nodes.map(e=>[e.id,0]));for(let t of e.edges)r.has(t.id)||i.set(t.target,(i.get(t.target)??0)+1);let a=[];for(let t of e.nodes)(i.get(t.id)??0)===0&&a.push(t.id);let o=new Set;for(let e=0;e<a.length;e+=1){let l=a[e];if(!l||o.has(l))continue;o.add(l);let c=s.get(l)??0;for(let e of t.outgoing.get(l)??[]){if(r.has(e.id))continue;s.set(e.target,Math.max(s.get(e.target)??0,c+1));let t=(i.get(e.target)??0)-1;i.set(e.target,t),0===t&&function(e,t,r){let n=r.get(t)??Number.MAX_SAFE_INTEGER,i=e.findIndex(e=>(r.get(e)??Number.MAX_SAFE_INTEGER)>n);-1===i?e.push(t):e.splice(i,0,t)}(a,e.target,n)}}for(let n of e.nodes){if(o.has(n.id))continue;let e=(t.incoming.get(n.id)??[]).filter(e=>!r.has(e.id)).map(e=>s.get(e.source)??0);s.set(n.id,e.length>0?Math.max(...e)+1:0)}return s}(e,n,i),a=Array.from((function(e,t,r,n,i){let s=rN(e.nodes),a=new Map;for(let n of e.nodes){let e=r.get(n.id)??0,i=t.get(n.id);i&&a.set(e,[...a.get(e)??[],i])}for(let e=0;e<4;e+=1)for(let e of Array.from(a.keys()).sort((e,t)=>e-t)){let t=a.get(e);if(!t||t.length<2)continue;let r=new Map;(a.get(e-1)??[]).forEach((e,t)=>{r.set(e.nodeId,t)});let o=new Map;(a.get(e+1)??[]).forEach((e,t)=>{o.set(e.nodeId,t)});let l=e=>{let t=[...(n.incoming.get(e.nodeId)??[]).filter(e=>!i.has(e.id)).map(e=>r.get(e.source)).filter(e=>void 0!==e),...(n.outgoing.get(e.nodeId)??[]).filter(e=>!i.has(e.id)).map(e=>o.get(e.target)).filter(e=>void 0!==e)];return 0===t.length?s.get(e.nodeId)??Number.MAX_SAFE_INTEGER:t.reduce((e,t)=>e+t,0)/t.length};a.set(e,[...t].sort((e,t)=>{let r=l(e)-l(t);return Math.abs(r)>.001?r:(s.get(e.nodeId)??Number.MAX_SAFE_INTEGER)-(s.get(t.nodeId)??Number.MAX_SAFE_INTEGER)}))}return a})(e,r,s,n,i).entries()).sort(([e],[t])=>e-t).map(([e,r])=>({breadth:r.reduce((e,r,n)=>e+(t?r.width:r.height)+112*(n>0),0),depth:Math.max(...r.map(e=>t?e.height:e.width)),rank:e,shapes:r})),o=Math.max(...a.map(e=>e.breadth)),l=48,c=[];for(let e of a){let r=48+Math.max(0,o-e.breadth)/2;for(let n of e.shapes)t?(c.push({...n,x:r,y:l+Math.max(0,e.depth-n.height)/2}),r+=n.width+112):(c.push({...n,x:l+Math.max(0,e.depth-n.width)/2,y:r}),r+=n.height+112);l+=e.depth+96}if("BT"===e.layout.direction){let e=Math.max(...c.map(e=>e.y+e.height));return c.map(t=>({...t,y:48+e-t.y-t.height}))}if("RL"===e.layout.direction){let e=Math.max(...c.map(e=>e.x+e.width));return c.map(t=>({...t,x:48+e-t.x-t.width}))}return c}(o),c=new Map(l.map(e=>[e.nodeId,e])),u=o.edges.map((e,t)=>(function(e,t,r,n){let i=r.get(e.source),s=r.get(e.target);if(!i||!s)throw Error(`Cannot render edge "${e.id}" with unresolved nodes.`);let{sourceEdge:a,targetEdge:o}=function(e,t,r){let n=rP(e),i=rP(t),s=i.x-n.x,a=i.y-n.y,o=e.kind?.toLowerCase();if("LR"===r||"RL"===r)return s>=0?{sourceEdge:"right",targetEdge:"left"}:{sourceEdge:"left",targetEdge:"right"};if(a<0)return!(Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)>.01)&&Math.abs(s)>Math.abs(a)?{sourceEdge:s>0?"right":"left",targetEdge:"bottom"}:{sourceEdge:"top",targetEdge:"bottom"};let l="decision"===o&&a>e.height+96;return"decision"===o&&a>0&&(0!==s||l)?{sourceEdge:s<0?"left":"right",targetEdge:"top"}:a>0?{sourceEdge:"bottom",targetEdge:"top"}:Math.abs(s)>Math.abs(a)?s>0?{sourceEdge:"right",targetEdge:"left"}:{sourceEdge:"left",targetEdge:"right"}:a>0?{sourceEdge:"bottom",targetEdge:"top"}:{sourceEdge:"top",targetEdge:"bottom"}}(i,s,n);return{edge:e,index:t,source:i,sourceEdge:a,target:s,targetEdge:o}})(e,t,c,o.layout.direction)),d=function(e){let t=new Map;for(let a of e){var r,n,i,s;let e=(r=a.source.nodeId,n=a.sourceEdge,`${r}:${n}`),o=(i=a.target.nodeId,s=a.targetEdge,`${i}:${s}`);t.set(e,[...t.get(e)??[],{edgeId:a.edge.id,endpoint:"source"}]),t.set(o,[...t.get(o)??[],{edgeId:a.edge.id,endpoint:"target"}])}let a=new Map;for(let e of t.values())e.forEach((t,r)=>{a.set(rF(t),(r-(e.length-1)/2)*18)});return a}(u),f=[];for(let e of u)f.push(function(e,t,r,n,i,s){let{edge:a,source:o,sourceEdge:l,target:c,targetEdge:u}=e,d=rD(o,l,r.get(rF({edgeId:a.id,endpoint:"source"}))??0),f=rD(c,u,r.get(rF({edgeId:a.id,endpoint:"target"}))??0),h=rL([d,f]);if(function(e,t,r){let n=rP(e),i=rP(t);switch(r){case"TB":return i.y<n.y;case"BT":return i.y>n.y;case"LR":return i.x<n.x;case"RL":return i.x>n.x}}(o,c,s))h=rQ(e,d,f,n,i);else if("orthogonal"===t&&d.x!==f.x&&d.y!==f.y){var p,m,g;let t,r,n,i=e.index%4*18,s=(p=d.y,m=f.y,g=f.y<d.y?-i:i,t=p+(m-p)/2,(r=Math.min(p,m)+18)<(n=Math.max(p,m)-18)?rj(t+g,r,n):t),a="left"===l?{x:d.x-36-i,y:d.y}:"right"===l?{x:d.x+36+i,y:d.y}:d,o="left"===u?{x:f.x-36-i,y:f.y}:"right"===u?{x:f.x+36+i,y:f.y}:f;h=rL([d,a,{x:a.x,y:s},{x:o.x,y:s},o,f])}return"orthogonal"===t&&(rB(h,n,new Set([o.nodeId,c.nodeId]))>0||rq(h,e)>0||rJ(h,i,e)>0)&&(h=rQ(e,d,f,n,i)),{type:"arrow",id:`edge:${a.id}`,edgeId:a.id,sourceNodeId:a.source,targetNodeId:a.target,points:h,...a.label?{label:a.label}:{}}}(e,o.layout.edgeRouting,d,l,f,o.layout.direction));let h=l.map(rM),p=(i=Math.max(0,48-(n={x:Math.min(...(r=rZ(t=[...f,...l,...h])).map(e=>e.x)),y:Math.min(...r.map(e=>e.y))}).x),s=Math.max(0,48-n.y),0===i&&0===s?[...t]:t.map(e=>"arrow"===e.type?{...e,points:function(e,t,r){let[n,...i]=e;return[r0(n,t,r),...i.map(e=>r0(e,t,r))]}(e.points,i,s)}:{...e,x:e.x+i,y:e.y+s})),m={width:Math.max(...(a=rZ(p)).map(e=>e.x))+48,height:Math.max(...a.map(e=>e.y))+48};return{diagramId:o.id,title:o.title,width:m.width,height:m.height,accentColor:o.style.accentColor,backgroundColor:o.style.backgroundColor,elements:p}}var r2=r(8927);r(2302);var r3=r(4650),r5=r(1136),r6=r(9354),r8=r(6364),r9=r(9138),r4=r(5369);let r7=s.Or("effect/Metric/CurrentMetricAttributes",{defaultValue:()=>({})}),ne=s.Or("~effect/observability/Metric/MetricRegistryKey",{defaultValue:()=>new Map}),nt="~effect/observability/Metric";class nr{[nt]=nt;#e=new WeakMap;#t;id;description;attributes;constructor(e,t,r){this.id=e,this.description=t,this.attributes=r}valueUnsafe(e){return this.hook(e).get(e)}modifyUnsafe(e,t){return this.hook(t).modify(e,t)}updateUnsafe(e,t){return this.hook(t).update(e,t)}hook(e){let t=s.Jt(e,r7);if(0===Object.keys(t).length)return r4.EA(this.#t)||(this.#t=this.getOrCreate(e,this.attributes)),this.#t.hooks;let r=nu(this.attributes,t),n=this.#e.get(r);return r4.EA(n)||(n=this.getOrCreate(e,r),this.#e.set(r,n)),n.hooks}getOrCreate(e,t){var r,n,i;let a,o=(r=this,n=t,a=`${r.type}:${r.id}`,r4.EA(r.description)&&(a+=`:${r.description}`),r4.EA(n)&&(a+=`:${(Array.isArray(i=n)?i:Object.entries(i)).map(([e,t])=>`${e}=${t}`).join(",")}`),a),l=s.Jt(e,ne);if(l.has(o))return l.get(o);let c=this.createHooks(),u={id:this.id,type:this.type,description:this.description,attributes:nd(t),hooks:c};return l.set(o,u),u}pipe(){return(0,r9.tT)(this,arguments)}}let nn=BigInt(0);class ni extends nr{type="Counter";#r;#n;constructor(e,t){super(e,t?.description,nd(t?.attributes)),this.#r=t?.bigint??!1,this.#n=t?.incremental??!1}createHooks(){let e=this.#r?nn:0,t=this.#n?this.#r?e=>e>=nn:e=>e>=0:e=>!0;return nc(()=>({count:e,incremental:this.#n}),r=>{t(r)&&(e+=r)})}}class ns extends nr{type;metric;valueUnsafe;updateUnsafe;modifyUnsafe;constructor(e,t,r,n){super(e.id,e.description,e.attributes),this.metric=e,this.valueUnsafe=t,this.updateUnsafe=r,this.modifyUnsafe=n,this.type=e.type}createHooks(){return this.metric.createHooks()}}let na=(e,t)=>new ni(e,t),no=(0,r3.XY)(2,(e,t)=>r5.sxi(r=>r5.OH5(()=>e.updateUnsafe(t,r)))),nl=(0,r3.XY)(2,(e,t)=>new ns(e,r=>e.valueUnsafe(nf(r,t)),(r,n)=>e.updateUnsafe(r,nf(n,t)),(r,n)=>e.modifyUnsafe(r,nf(n,t))));function nc(e,t,r){return{get:e,update:t,modify:r??t}}function nu(e,t){return{...nd(e),...nd(t)}}function nd(e){return r4.EA(e)&&Array.isArray(e)?e.reduce((e,[t,r])=>(e[t]=r,e),{}):e}function nf(e,t){let r=nu(s.Jt(e,r7),t);return s.WQ(e,r7,r)}r6.F,r6.F,r3.MN,r(7598),r(8543);var nh=r(755);[...new Set(["artifact_count","artifact_format","artifact_kind","attempt","cache_mode","duration_ms","error_category","error_tag","failure_category","format_count","method","model","operation","outcome","provider","request_kind","retry_kind","sink","status","status_code","surface","timeout_kind","timeout_ms"])];let np={metric:()=>void 0},nm=s.Or("@sketchi/observability/TelemetryExporter",{defaultValue:()=>np}),ng=s.Or("@sketchi/observability/TelemetryCorrelation",{defaultValue:()=>({})});function ny(e){let t=e?.trim();if(t&&!(t.length>128)&&/^[A-Za-z0-9][A-Za-z0-9._:-]*$/.test(t))return t}function nb(e){let t=ny(e.artifactId),r=ny(e.attemptId),n=ny(e.projectId),i=ny(e.requestId),s=ny(e.runId),a=ny(e.scenarioId),o=ny(e.traceId);return{...t?{artifactId:t}:{},...r?{attemptId:r}:{},...n?{projectId:n}:{},...i?{requestId:i}:{},...s?{runId:s}:{},...a?{scenarioId:a}:{},...o?{traceId:o}:{}}}function nv(e,t){return a.JkU(function*(){let r=nb({...yield*ng,...nb(t)}),n={...r.artifactId?{"sketchi.artifact_id":r.artifactId}:{},...r.attemptId?{"sketchi.attempt_id":r.attemptId}:{},...r.projectId?{"sketchi.project_id":r.projectId}:{},...r.requestId?{"sketchi.request_id":r.requestId}:{},...r.runId?{"sketchi.run_id":r.runId}:{},...r.scenarioId?{"sketchi.scenario_id":r.scenarioId}:{},...r.traceId?{"sketchi.trace_id":r.traceId}:{}};return yield*e.pipe(a.PfK(ng,r),a.Muk(n),a.swY(n))})}s.Or("@sketchi/observability/TelemetryResource",{defaultValue:()=>({serviceName:"sketchi"})});let nw=a.fn(function*(e,t,r={}){let n=function(e){let t={artifact_kind:e.artifactKind,failure_category:e.failureCategory,operation:e.operation,outcome:e.outcome,provider:e.provider,retry_kind:e.retryKind,sink:e.sink,surface:e.surface,timeout_kind:e.timeoutKind},r={};for(let[e,n]of Object.entries(t)){let t=ny(n);t&&(r[e]=t)}return r}(r);yield*no(nl(e,n),t);let i=yield*nm,s=d.getOrUndefined((yield*a._32.pipe(a.uKv)));yield*a.OH5(()=>i.metric({attributes:n,metric:e.id,metricType:e.type,...s?{spanId:s.spanId,traceId:s.traceId}:{},value:t}))});nh.W1;let nx=/^(node|step|item|box|thing|process|task)\s*\d*$/i,nk=/^(diagram|untitled|flowchart|chart|sketch)$/i;function nS(e){return"decision"===e.kind||e.label.endsWith("?")}function n_(e){if(void 0===e)return;let t=g(e);return t.length>0?t:void 0}let nO=["excalidraw","scene"],nI=["scene"],n$=na("sketchi_codemode_requests",{description:"Code Mode boundary requests by terminal outcome",incremental:!0}),nE=na("sketchi_codemode_failures",{description:"Code Mode boundary failures by typed status",incremental:!0}),nC=na("sketchi_codemode_artifacts",{description:"Code Mode artifacts accepted at workflow boundaries",incremental:!0}),nA=new class e extends nr{type="Histogram";#i;constructor(e,t){super(e,t?.description,nd(t?.attributes)),this.#i=t.boundaries}createHooks(){let e=this.#i,t=e.length,r=new Uint32Array(t+1),n=new Float64Array(t),i=0,s=0,a=Number.MAX_VALUE,o=5e-324;return r2.Tj(r2.di(e,r8.wN),(e,t)=>{n[t]=e}),nc(()=>({buckets:(()=>{let e=r2.CN(t),i=0;for(let s=0;s<t;s++){let t=n[s];i+=r[s],e[s]=[t,i]}return e})(),count:i,min:a,max:o,sum:s}),e=>{let l=0,c=t;for(;l!==c;){let t=Math.floor(l+(c-l)/2);e<=n[t]?c=t:l=t,c===l+1&&(e<=n[l]?c=l:l=c)}r[l]=r[l]+1,i+=1,s+=e,e<a&&(a=e),e>o&&(o=e)})}}("sketchi_codemode_duration_ms",{description:"Code Mode boundary duration in milliseconds",boundaries:(n=[1,5,10,25,50,100,250,500,1e3,2500,5e3,1e4],r2.BC(r2.pb(new Set(n),e=>e>0),1/0))});class nT extends s.kl()("@sketchi/diagram-agent/CodeModeRuntimeEnvironment"){}function nN(e={}){return l.Py(nT,{createId:e.createId??nU,...e.renderer?{renderer:e.renderer}:{},...e.artifactUrl?{artifactUrl:e.artifactUrl}:{}})}function nM(e){return null===e||"object"!=typeof e||Array.isArray(e)?void 0:Object.fromEntries(Object.entries(e))}function nP(e,t,r){let n,i,s,l;return nv(a.JkU(function*(){let t=yield*o.Ru,n=yield*r,i=yield*o.Ru,s=n.ok?"success":"failure",a=n.ok?void 0:n.status??"unknown_failure";yield*nw(n$,1,{...a?{failureCategory:a}:{},operation:e,outcome:s,surface:"code_mode"}),yield*nw(nA,i-t,{...a?{failureCategory:a}:{},operation:e,outcome:s,surface:"code_mode"}),a&&(yield*nw(nE,1,{failureCategory:a,operation:e,surface:"code_mode"}));let l="buildFlowchart"===e?"flowchart":"buildMindmap"===e?"mindmap":"applyDiagramPatch"===e?"patch":void 0;return n.ok&&l&&(yield*nw(nC,1,{artifactKind:l,operation:e,surface:"code_mode"})),n}),(n=nM(t),i=nM(n?.source),s="string"==typeof n?.artifactId?n.artifactId:"string"==typeof i?.artifactId?i.artifactId:void 0,l="string"==typeof n?.requestId?n.requestId:void 0,{...s?{artifactId:s}:{},...l?{requestId:l}:{}}))}l.Py(nT,{createId:nU});class nj extends i.X0d()("CodeModeArtifactExportError",{cause:i.kld(),message:i.QfV,optionPath:i.v8c}){}class nD extends i.X0d()("BuildFlowchartFailure",{message:i.QfV,status:i.xCb(["invalid_input","invalid_flowchart","quality_failed","render_failed","export_failed","storage_failed"])}){context;constructor(e){super({message:e.context.issues[0]?.message??e.status,status:e.status}),this.context=e.context}}class nF extends i.X0d()("BuildMindmapFailure",{message:i.QfV,status:i.xCb(["invalid_input","invalid_mindmap","quality_failed","render_failed","export_failed","storage_failed"])}){context;constructor(e){super({message:e.context.issues[0]?.message??e.status,status:e.status}),this.context=e.context}}class nL extends i.X0d()("GetArtifactFailure",{message:i.QfV,status:i.xCb(["invalid_input","not_found","format_unavailable","expired","storage_failed"])}){issues;constructor(e){super({message:e.issues[0]?.message??e.status,status:e.status}),this.issues=e.issues}}class nR extends i.X0d()("ApplyDiagramPatchFailure",{message:i.QfV,status:i.xCb(["invalid_input","source_unavailable","target_not_found","unsupported_operation","connectivity_changed","render_failed","export_failed","storage_failed"])}){context;constructor(e){super({message:e.context.issues[0]?.message??e.status,status:e.status}),this.context=e.context}}function nU(e){return`${e}_${globalThis.crypto.randomUUID()}`}function nB(e){return{code:e.code,severity:e.severity??"error",stage:e.stage,...e.ref?{ref:e.ref}:{},message:e.message,hint:e.hint}}function nY(e){return 0===e.length?"input":e.map(e=>"number"==typeof e?`[${e}]`:String(e)).join(".")}function nX(e){let t=nY(e.path);return nW(t)?"unsupported_patch_operation":e.message.startsWith("Invalid input: expected")?"invalid_type":e.message.startsWith("Invalid option:")?"invalid_enum":t.toLowerCase().includes("color")?"invalid_color":"input"===t?"invalid_type":"missing_field"}function nW(e){return/^operations\.\[\d+\]\.op$/.test(e)}function nJ(e){let t=e.issues.slice(0,20).map(e=>{let t=nY(e.path);return nB({code:nX(e),stage:"input",ref:{kind:"request",path:t},message:e.message,hint:nW(t)?`Use one of: ${et.join(", ")}. For label edits, use replaceText with selector plus text.`:"source"===t?"Pass source: { artifactId } from an accepted build or patch, or source: { scene } for inline Sketchi scene patching.":`Fix ${t} so it matches the Code Mode API contract.`})});return e.issues.length>20&&t.push(nB({code:"invalid_type",stage:"input",ref:{kind:"request",path:"input"},message:`${e.issues.length-20} additional input issues were omitted.`,hint:"Fix the summarized request shape before retrying."})),t}function nq(e){return e.checks.map(e=>{var t;return nB({code:"generic_label"===(t=e.code)||"label_too_long"===t||"disconnected_graph"===t?t:"quality_below_threshold",severity:e.severity,stage:"quality",message:e.message,hint:"error"===e.severity?"Repair the structural issue and call buildFlowchart again.":"Improve the labels or scope before styling the artifact."})})}function nK(e){return e?.artifactFormats??nO}function nV(e){return e?.inlineArtifacts??nI}let nG=a.fn("codeMode.artifacts.exportFormats")(function*(e){let t=[];for(let s of e.formats){var r,n,i;let o=yield*(r=e,"scene"===(n=s)?a.PyW(r.scene):"excalidraw"===n?a.PyW(function(e,t={}){return{type:"excalidraw",version:2,source:t.source??"https://sketchi.app",elements:e.elements,appState:e.appState,files:{}}}(r.excalidraw)):r.renderer?r.renderer.renderPng({scene:r.scene,excalidraw:r.excalidraw}).pipe(a.xm_(e=>nj.make({cause:e,message:e instanceof Error?e.message:"Artifact export failed.",optionPath:!1}))):a.fJG(nj.make({cause:Error("PNG artifact rendering is not configured for this runtime."),message:"PNG artifact rendering is not configured for this runtime.",optionPath:!0})));t.push({format:s,mimeType:t_[s],data:o,sizeBytes:(i=o)instanceof ArrayBuffer||i instanceof Uint8Array?i.byteLength:tE(i)})}return t});function nH(e){return[nB({code:"render_failed",stage:"export",...e.optionPath?{ref:{kind:"artifact",path:"options.artifactFormats"}}:{},message:e.message,hint:e.optionPath?"Use the hosted Studio Code Mode runtime with its Cloudflare Browser Run binding, or omit png from artifactFormats.":"Retry the request; if it keeps failing, inspect the configured renderer."})]}function nz(e){return e.map(e=>nB({code:"overlapping-arrow-segment"===e.code?"arrow_overlap":"text-overflow"===e.code?"text_overflow":e.code.includes("binding")||e.code.includes("bound")||e.code.includes("endpoint")?"arrow_binding_invalid":"export_invalid_scene",stage:"export",ref:e.elementId?{kind:"artifact",id:e.elementId}:{kind:"artifact"},message:e.message,hint:"Inspect the rendered scene and retry with a simpler layout or patch."}))}function nQ(e){return structuredClone(e)}function nZ(e){return e.elements.filter(e=>"arrow"===e.type).map(e=>`${e.edgeId}:${e.sourceNodeId}->${e.targetNodeId}`).sort()}function n0(e){return e.elements.filter(e=>"node"===e.type)}function n1(e){return e.elements.filter(e=>"text"===e.type)}function n2(e){return e.elements.filter(e=>"arrow"===e.type)}function n3(e,t){if(!e||0===e.length||!t)return!1;let r=t.trim().toLowerCase();return e.some(e=>e.trim().toLowerCase()===r)}function n5(e,t){let r=t?.scope??"all",n=!!(t&&((t.ids?.length??0)>0||(t.nodeIds?.length??0)>0||(t.edgeIds?.length??0)>0||(t.kinds?.length??0)>0||(t.labels?.length??0)>0)),i=new Set(t?.ids??[]),s=new Set(t?.nodeIds??[]),a=new Set(t?.edgeIds??[]),o=new Set(t?.kinds??[]),l=n0(e).filter(e=>"edges"!==r&&(!t||!n||i.has(e.id)||s.has(e.nodeId)||!!e.kind&&[...o].some(t=>t===e.kind)||n3(t.labels,e.label))),c=n2(e).filter(e=>"nodes"!==r&&(!t||!n||i.has(e.id)||a.has(e.edgeId)||n3(t.labels,e.label))),u=new Set(l.map(e=>e.id)),d=new Set(c.map(e=>e.id));return{arrows:c,nodes:l,texts:n1(e).filter(e=>t&&n?i.has(e.id)||!!e.containerId&&u.has(e.containerId)||!!e.containerId&&d.has(e.containerId)||n3(t.labels,e.text):"nodes"===r?!!e.containerId&&u.has(e.containerId):"edges"!==r||!!e.containerId&&d.has(e.containerId))}}function n6(e){return nB({code:"unknown_patch_target",stage:"flowchart",ref:{kind:"request",path:"operations.selector"},message:`Patch operation "${e.op}" did not match any scene element.`,hint:"Use nodeIds, edgeIds, ids, kinds, labels, or scope values that exist in the accepted artifact."})}function n8(e,t){return n1(e).find(e=>e.containerId===t)}function n9(e,t){let r=new Set(t);for(let t of n2(e))(r.has(t.sourceNodeId)||r.has(t.targetNodeId))&&ie(e,t)}function n4(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function n7(e,t,r){let n=n4(e),i=n4(t),s=i.x-n.x,a=i.y-n.y;return Math.abs(s)>Math.abs(a)?s>=0&&r||s<0&&!r?{x:e.x+e.width,y:n.y}:{x:e.x,y:n.y}:a>=0&&r||a<0&&!r?{x:n.x,y:e.y+e.height}:{x:n.x,y:e.y}}function ie(e,t){let r,n,i=new Map(n0(e).map(e=>[e.nodeId,e])),s=i.get(t.sourceNodeId),a=i.get(t.targetNodeId);if(!s||!a)return[nB({code:"patch_output_invalid",stage:"render",ref:{kind:"edge",id:t.edgeId},message:`Arrow "${t.id}" references a node that is not in the scene.`,hint:"Rebuild the diagram with buildFlowchart or buildMindmap before applying visual patches."})];let o=n7(s,a,!0),l=n7(a,s,!1);if(Math.abs(l.y-o.y)>=Math.abs(l.x-o.x)){let e=(o.y+l.y)/2;t.points=[o,{x:o.x,y:e},{x:l.x,y:e},l]}else{let e=(o.x+l.x)/2;t.points=[o,{x:e,y:o.y},{x:e,y:l.y},l]}return r=n8(e,t.id),n=function(e){let t=e[0],r=e[e.length-1];if(t&&r)return{x:(t.x+r.x)/2,y:(t.y+r.y)/2-10}}(t.points),r&&n&&(r.x=n.x,r.y=n.y),[]}let it=a.fn("codeMode.patch.resolveSource")(function*(e){if("scene"in e.source)return{scene:nQ(e.source.scene)};let t=yield*tS,r=yield*t.readManifest(e.source.artifactId).pipe(a.xm_(e=>new nR({status:"storage_failed",context:{issues:[tT(e.message,"storage_read_failed")]}})));if(!r||r.artifactId!==e.source.artifactId||!r.formats.some(e=>"scene"===e.format))return yield*new nR({status:"source_unavailable",context:{issues:[nB({code:"patch_source_unavailable",stage:"storage",ref:{kind:"artifact",id:e.source.artifactId},message:`Artifact "${e.source.artifactId}" does not have a valid source manifest.`,hint:"Rebuild with the appropriate build operation and patch the accepted artifact id."})]}});let n=yield*t.read(e.source.artifactId,"scene").pipe(a.xm_(e=>new nR({status:"storage_failed",context:{issues:[tT(e.message,"storage_read_failed")]}})));if(!n)return yield*new nR({status:"source_unavailable",context:{issues:[nB({code:"patch_source_unavailable",stage:"storage",ref:{kind:"artifact",id:e.source.artifactId},message:`Scene artifact "${e.source.artifactId}" is not available.`,hint:"Call buildFlowchart or buildMindmap first, then patch the accepted artifact id."})]}});let i=eJ.safeParse(n.data);return i.success?{scene:nQ(i.data),sourceArtifactId:e.source.artifactId}:yield*new nR({status:"source_unavailable",context:{issues:[nB({code:"patch_source_unavailable",stage:"storage",ref:{kind:"artifact",id:e.source.artifactId},message:`Scene artifact "${e.source.artifactId}" could not be decoded.`,hint:"Rebuild with the appropriate build operation and patch the new artifact."})]}})});function ir(e){return e?{requestId:e}:{}}function ii(e,t){if(!t)return e;let r=e.formats.map(r=>({...r,url:t({artifactId:e.artifactId,format:r.format})})),n=e.preview?r.find(t=>t.format===e.preview?.format):void 0;return{...e,formats:r,...n?{preview:n}:{}}}function is(e){return{diagramId:e.diagramId,formats:[{format:"scene",mimeType:t_.scene,inline:e,sizeBytes:tE(e)}]}}function ia(e){return{ok:!1,status:e.status,...e.context.buildId?{buildId:e.context.buildId}:{},...e.context.requestId?{requestId:e.context.requestId}:{},...e.context.normalizedSpec?{normalizedSpec:e.context.normalizedSpec}:{},...e.context.quality?{quality:e.context.quality}:{},...e.context.partial?{partial:e.context.partial}:{},issues:e.context.issues}}function io(e){return{ok:!1,status:e.status,...e.context.buildId?{buildId:e.context.buildId}:{},...e.context.requestId?{requestId:e.context.requestId}:{},...e.context.normalizedSpec?{normalizedSpec:e.context.normalizedSpec}:{},...e.context.quality?{quality:e.context.quality}:{},...e.context.partial?{partial:e.context.partial}:{},issues:e.context.issues}}function il(e){return{ok:!1,status:e.status,issues:e.issues}}function ic(e){return{ok:!1,status:e.status,...e.context.patchId?{patchId:e.context.patchId}:{},...e.context.requestId?{requestId:e.context.requestId}:{},...e.context.sourceArtifactId?{sourceArtifactId:e.context.sourceArtifactId}:{},...e.context.partial?{partial:e.context.partial}:{},issues:e.context.issues}}function iu(e,t){return tT(e.message,t)}let id=a.fn("codeMode.buildMindmap.workflow")(function*(e){let t=yield*a.OH5(()=>(function(e){let t=nM(nM(nM(e)?.spec)?.root);if(!t)return[];let r=[{depth:0,topic:t}],n=1;for(;r.length>0;){let e=r.pop();if(!e)continue;if(e.depth>8)return[nB({code:"mindmap_too_deep",stage:"mindmap",ref:{kind:"request",path:"spec.root.children"},message:"Mindmap depth exceeds the supported maximum of 8.",hint:"Combine overly deep topics into a shallower hierarchy."})];let t=e.topic.children;if(Array.isArray(t)){if((n+=t.length)>100)return[nB({code:"mindmap_too_large",stage:"mindmap",ref:{kind:"request",path:"spec.root"},message:"Mindmap exceeds the supported maximum of 100 topic slots.",hint:"Split this hierarchy into smaller focused mindmaps."})];for(let n=t.length-1;n>=0;n-=1){let i=nM(t[n]);i&&r.push({depth:e.depth+1,topic:i})}}}return[]})(e)).pipe(a.fRP("codeMode.buildMindmap.preflight"));if(t.length>0)return yield*new nF({status:"invalid_mindmap",context:{issues:t}});let r=yield*a.OH5(()=>eL.safeParse(e)).pipe(a.fRP("codeMode.buildMindmap.parse"));if(!r.success)return yield*new nF({status:"invalid_input",context:{issues:nJ(r.error)}});let n=yield*nT,i=yield*tS,s=r.data,o=yield*a.OH5(()=>n.createId("build")),l=yield*a.OH5(()=>{var e;let t,r;return e=s.spec,t=(e,r)=>({id:`topic-${r.join("-")}`,label:g(e.label),children:(e.children??[]).map((e,n)=>t(e,[...r,n]))}),r=g(e.title),{id:function(e){if(void 0===e)return;let t=g(e);return t.length>0?t:void 0}(e.id)??(r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"sketchi-mindmap"),title:r,root:t(e.root,[0]),layout:{direction:e.layout.direction},style:e.style}}).pipe(a.fRP("codeMode.buildMindmap.normalize")),c={buildId:o,...ir(s.requestId),normalizedSpec:l},u=yield*a.OH5(()=>{let e,t,r,n,i;return e=0,t=0,(r=(n,i)=>{e+=1,t=Math.max(t,i),n.children.forEach(e=>r(e,i+1))})(l.root,0),i=[],(n={count:e,depth:t}).count<2&&i.push(nB({code:"disconnected_graph",stage:"mindmap",ref:{kind:"diagram",id:l.id},message:"Mindmap root must contain at least one child topic.",hint:"Add one or more nested topics under spec.root.children."})),n.depth>8&&i.push(nB({code:"mindmap_too_deep",stage:"mindmap",ref:{kind:"diagram",id:l.id},message:`Mindmap depth ${n.depth} exceeds the supported maximum of 8.`,hint:"Combine overly deep topics into a shallower hierarchy."})),n.count>100&&i.push(nB({code:"mindmap_too_large",stage:"mindmap",ref:{kind:"diagram",id:l.id},message:`Mindmap has ${n.count} topics; the supported maximum is 100.`,hint:"Split this hierarchy into smaller focused mindmaps."})),i}).pipe(a.fRP("codeMode.buildMindmap.validate"));if(u.length>0)return yield*new nF({status:"invalid_mindmap",context:{...c,issues:u}});let d=yield*a.SvU({try:()=>{let e,t,r;return e=[],t=[],(r=(n,i,s,a)=>{e.push({id:n.id,label:n.label,kind:0===i?"root":"topic",metadata:{depth:i,siblingIndex:s}}),a&&t.push({id:`branch-${n.id.slice(6)}`,source:a,target:n.id,metadata:{depth:i,siblingIndex:s}}),n.children.forEach((e,t)=>r(e,i+1,t,n.id))})(l.root,0,0),ro({id:l.id,title:l.title,type:"mindmap",nodes:e,edges:t,layout:{direction:l.layout.direction,edgeRouting:"curved"},style:l.style})},catch:e=>new nF({status:"invalid_mindmap",context:{...c,issues:[nB({code:"disconnected_graph",stage:"mindmap",ref:{kind:"diagram",id:l.id},message:e instanceof Error?e.message:"Mindmap failed core validation.",hint:"Repair the nested topic hierarchy and call buildMindmap again."})]}})}).pipe(a.fRP("codeMode.buildMindmap.canonicalize")),f=yield*a.OH5(()=>{var e;let t,r;return e=s.options?.minQualityScore??8,{accepted:(r=Math.max(0,10-2*(t=d.nodes.filter(e=>/^(topic|branch|item|mindmap)$/i.test(e.label.trim()))).length))>=e,score:r,threshold:e,summary:{nodeCount:d.nodes.length,edgeCount:d.edges.length},checks:t.map(e=>({code:"generic_label",passed:!1,severity:"warning",message:`Topic "${e.label}" is too generic.`,refs:[{kind:"node",id:e.id}]}))}}).pipe(a.fRP("codeMode.buildMindmap.quality")),h={...c,quality:f};if(!f.accepted)return yield*new nF({status:"quality_failed",context:{...h,issues:nq(f)}});let p=yield*a.SvU({try:()=>r1(d),catch:e=>new nF({status:"render_failed",context:{...h,issues:[nB({code:"render_failed",stage:"render",ref:{kind:"diagram",id:l.id},message:e instanceof Error?e.message:"Unable to render mindmap scene.",hint:"Simplify the hierarchy or retry with a smaller mindmap."})]}})}).pipe(a.fRP("codeMode.buildMindmap.render")),{excalidraw:m,exportValidation:y}=yield*a.OH5(()=>{let e=rS(p);return{excalidraw:e,exportValidation:rT(e)}}).pipe(a.fRP("codeMode.buildMindmap.exportValidate")),b={...h,partial:is(p)};if(!y.ok)return yield*new nF({status:"export_failed",context:{...b,issues:nz(y.issues)}});let v=yield*nG({formats:nK(s.options),scene:p,excalidraw:m,renderer:n.renderer}).pipe(a.xm_(e=>new nF({status:"export_failed",context:{...b,issues:nH(e)}}))),w=yield*a.OH5(()=>n.createId("artifact")),x=yield*nv(i.write({artifactId:w,diagramId:p.diagramId,formats:v,inlineFormats:nV(s.options)}),{artifactId:w,...s.requestId?{requestId:s.requestId}:{}}).pipe(a.xm_(e=>new nF({status:"storage_failed",context:{...h,partial:{diagramId:p.diagramId},issues:[iu(e,"storage_write_failed")]}})));return{ok:!0,status:"accepted",buildId:o,...ir(s.requestId),normalizedSpec:l,quality:f,artifact:ii(x,n.artifactUrl),issues:[]}}),ih=a.fn("codeMode.buildFlowchart.workflow")(function*(e){let t=yield*a.OH5(()=>eI.safeParse(e)).pipe(a.fRP("codeMode.buildFlowchart.parse"));if(!t.success)return yield*new nD({status:"invalid_input",context:{issues:nJ(t.error)}});let r=yield*nT,n=yield*tS,i=t.data,s=nK(i.options),o=yield*a.OH5(()=>r.createId("build")),l=yield*a.OH5(()=>{var e;let t;return t=g((e=i.spec).title),{id:n_(e.id)??(t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"sketchi-flowchart"),title:t,nodes:e.nodes.map(e=>({id:g(e.id),label:g(e.label),kind:e.kind,...e.description?{description:g(e.description)}:{}})),edges:e.edges.map((e,t)=>({id:n_(e.id)??`edge-${t+1}`,source:g(e.source),target:g(e.target),...e.label?{label:g(e.label)}:{}})),layout:{direction:e.layout.direction},style:{accentColor:e.style.accentColor,backgroundColor:e.style.backgroundColor}}}).pipe(a.fRP("codeMode.buildFlowchart.normalize")),c={buildId:o,...ir(i.requestId),normalizedSpec:l},u=yield*a.OH5(()=>t5.safeParse({id:l.id,title:l.title,type:"flowchart",nodes:l.nodes.map(e=>({...e,metadata:{}})),edges:l.edges.map(e=>({...e,metadata:{}})),layout:{direction:l.layout.direction,edgeRouting:"orthogonal"},style:l.style,metadata:{}})).pipe(a.fRP("codeMode.buildFlowchart.parseCanonical"));if(!u.success){var d;return yield*new nD({status:"invalid_flowchart",context:{...c,issues:(d=u.error,d.issues.slice(0,20).map(e=>{let t=function(e,t){let r=nY(e.path),n="input"===r?"spec":`spec.${r}`,[i,s]=e.path;if("nodes"===i&&"number"==typeof s){let e=t.nodes[s]?.id;return{kind:"node",...e?{id:e}:{},path:n}}if("edges"===i&&"number"==typeof s){let e=t.edges[s]?.id;return{kind:"edge",...e?{id:e}:{},path:n}}return{kind:"diagram",id:t.id,path:n}}(e,l);return nB({code:nX(e),stage:"flowchart",ref:t,message:e.message,hint:`Fix ${t.path??"spec"} so normalization produces a valid canonical flowchart value.`})}))}})}let f=u.data,h=yield*a.OH5(()=>t9(f).map(e=>{let t=function(e){if(e)return{kind:e.kind,...e.id?{id:e.id}:{},...e.path?{path:`spec.${e.path}`}:{}}}(e.ref);return nB({code:e.code,stage:"flowchart",...t?{ref:t}:{},message:e.message,hint:e.hint})})).pipe(a.fRP("codeMode.buildFlowchart.validate"));if(h.length>0)return yield*new nD({status:"invalid_flowchart",context:{...c,issues:h}});yield*a.OH5(()=>t7(f)).pipe(a.fRP("codeMode.buildFlowchart.assertValid"));let p=yield*a.OH5(()=>(function(e,t){let r=[],n=0,i=(e,t,i=!1)=>{n+=e,r.push({severity:i?"error":"warning",message:t})},s=new Map,a=new Map;for(let t of e.edges)s.set(t.source,(s.get(t.source)??0)+1),s.set(t.target,(s.get(t.target)??0)+1),a.set(t.source,[...a.get(t.source)??[],t]);if(e.nodes.length>1&&0===e.edges.length)i(5,"no edges at all — every node floats unconnected",!0);else{let t=e.nodes.filter(e=>(s.get(e.id)??0)===0);t.length>0&&e.nodes.length>1&&i(Math.min(1.5*t.length,4.5),`unconnected node(s): ${t.map(e=>e.id).join(", ")}`,!0);let r=function(e){let t=new Map;for(let r of e.nodes)t.set(r.id,[]);for(let r of e.edges)t.get(r.source)?.push(r.target),t.get(r.target)?.push(r.source);let r=new Set,n=0;for(let i of e.nodes){if(r.has(i.id))continue;n+=1;let e=[i.id];for(r.add(i.id);e.length>0;){let n=e.pop();if(void 0===n)break;for(let i of t.get(n)??[])r.has(i)||(r.add(i),e.push(i))}}return n}(e);r>1&&0===t.length&&i(2,`diagram splits into ${r} disconnected islands`,!0)}e.nodes.length<3?i(2,"too sparse — a useful flow needs at least 3 nodes"):e.nodes.length>24&&i(2,"too dense — trim or merge nodes (24 max)");let o=new Map;for(let t of e.nodes){let e=t.label.trim().toLowerCase();o.set(e,(o.get(e)??0)+1)}let l=[...o.entries()].filter(([,e])=>e>1);l.length>0&&i(Math.min(l.length,3),`duplicate label(s): ${l.map(([e])=>`"${e}"`).join(", ")}`);let c=0,u=0;for(let t of e.nodes.filter(nS)){let e=a.get(t.id)??[];e.length<2?(c+=1,r.push({severity:"error",message:`decision "${t.id}" needs at least 2 outgoing branches`})):e.some(e=>!e.label)&&(u+=1,r.push({severity:"warning",message:`label every branch out of decision "${t.id}" (yes/no, …)`}))}n+=Math.min(1.5*c,4.5)+Math.min(u,3);let d=e.nodes.filter(e=>e.label.length>42);d.length>0&&i(Math.min(.5*d.length,2),`shorten label(s): ${d.map(e=>e.id).join(", ")}`);let f=e.nodes.filter(e=>nx.test(e.label.trim()));f.length>0&&i(Math.min(f.length,3),`generic label(s) say nothing: ${f.map(e=>`"${e.label}"`).join(", ")}`),(e.title.trim().length<4||nk.test(e.title.trim()))&&i(.5,"give the diagram a specific title");let h=Math.max(0,Math.round((10-n)*10)/10),p=r.map(e=>{var t;return{code:(t=e.message).includes("generic label")?"generic_label":t.includes("shorten label")?"label_too_long":t.includes("disconnected")?"disconnected_graph":"quality_below_threshold",passed:!1,severity:e.severity,message:e.message,refs:[]}});return{accepted:h>=t&&!p.some(e=>"error"===e.severity),score:h,threshold:t,summary:{nodeCount:e.nodes.length,edgeCount:e.edges.length},checks:p}})(f,i.options?.minQualityScore??8)).pipe(a.fRP("codeMode.buildFlowchart.quality")),m={...c,quality:p};if(!p.accepted)return yield*new nD({status:"quality_failed",context:{...m,issues:nq(p)}});let y=yield*a.SvU({try:()=>r1(f),catch:e=>new nD({status:"render_failed",context:{...m,issues:[nB({code:"render_failed",stage:"render",ref:{kind:"diagram",id:l.id},message:e instanceof Error?e.message:"Unable to render flowchart scene.",hint:"Simplify the graph or retry with a smaller flowchart."})]}})}).pipe(a.fRP("codeMode.buildFlowchart.render")),{excalidraw:b,validation:v}=yield*a.OH5(()=>{let e=rS(y);return{excalidraw:e,validation:rT(e)}}).pipe(a.fRP("codeMode.buildFlowchart.exportValidate")),w={...m,partial:is(y)};if(!v.ok)return yield*new nD({status:"export_failed",context:{...w,issues:nz(v.issues)}});let x=yield*nG({formats:s,scene:y,excalidraw:b,renderer:r.renderer}).pipe(a.xm_(e=>new nD({status:"export_failed",context:{...w,issues:nH(e)}}))),k=yield*a.OH5(()=>r.createId("artifact")),S=yield*nv(n.write({artifactId:k,diagramId:y.diagramId,formats:x,inlineFormats:nV(i.options)}),{artifactId:k,...i.requestId?{requestId:i.requestId}:{}}).pipe(a.xm_(e=>new nD({status:"storage_failed",context:{...m,issues:[iu(e,"storage_write_failed")]}})));return{ok:!0,status:"accepted",buildId:o,...ir(i.requestId),normalizedSpec:l,quality:p,artifact:ii(S,r.artifactUrl),issues:[]}}),ip=a.fn("codeMode.getArtifact.workflow")(function*(e){let t=yield*a.OH5(()=>ez.safeParse(e)).pipe(a.fRP("codeMode.getArtifact.parse"));if(!t.success)return yield*new nL({status:"invalid_input",issues:nJ(t.error)});let r=yield*nT,n=yield*tS,i=t.data,s=yield*n.readManifest(i.artifactId).pipe(a.xm_(e=>new nL({status:"storage_failed",issues:[iu(e,"storage_read_failed")]})));if(!s)return yield*new nL({status:"not_found",issues:[nB({code:"patch_source_unavailable",stage:"storage",ref:{kind:"artifact",id:i.artifactId},message:`Artifact "${i.artifactId}" was not found.`,hint:"Use the artifactId returned by buildFlowchart or applyDiagramPatch."})]});let o=i.format??"scene";if(!s.formats.some(e=>e.format===o))return yield*new nL({status:"format_unavailable",issues:[nB({code:"unsupported_artifact_format",stage:"storage",ref:{kind:"artifact",id:i.artifactId},message:`Artifact "${i.artifactId}" does not include format "${o}".`,hint:"Request a format listed in the artifact bundle."})]});let l=yield*n.read(i.artifactId,o).pipe(a.xm_(e=>new nL({status:"storage_failed",issues:[iu(e,"storage_read_failed")]})));return l?{ok:!0,artifactId:i.artifactId,diagramId:s.diagramId,format:o,mimeType:l.mimeType,...r.artifactUrl?{url:r.artifactUrl({artifactId:i.artifactId,format:o})}:{},...!0!==i.inline||!tO(o)?{}:{inline:l.data},sizeBytes:l.sizeBytes,...s.provenance?{provenance:s.provenance}:{}}:yield*new nL({status:"format_unavailable",issues:[nB({code:"patch_source_unavailable",stage:"storage",ref:{kind:"artifact",id:i.artifactId},message:`Artifact "${i.artifactId}" format "${o}" could not be read.`,hint:"Retry retrieval or rebuild the artifact."})]})}),im=a.fn("codeMode.applyDiagramPatch.workflow")(function*(e){let t=yield*a.OH5(()=>ti.safeParse(e)).pipe(a.fRP("codeMode.applyDiagramPatch.parse"));if(!t.success)return yield*new nR({status:"invalid_input",context:{issues:nJ(t.error)}});let r=yield*nT,n=yield*tS,i=t.data,s=yield*a.OH5(()=>r.createId("patch")),o={patchId:s,...ir(i.requestId)},l=nK(i.options),c=yield*it(i).pipe(a.xm_(e=>new nR({status:e.status,context:{...o,...e.context}}))),u={...o,...c.sourceArtifactId?{sourceArtifactId:c.sourceArtifactId}:{}},d=c.scene,f=nZ(d),h=yield*a.OH5(()=>{for(let e of i.operations){let t=function(e,t){switch(t.op){case"setDefaultStyle":case"setStyle":if(t.style.backgroundColor&&(e.backgroundColor=t.style.backgroundColor),"setDefaultStyle"===t.op){for(let r of(t.style.strokeColor&&(e.accentColor=t.style.strokeColor),n0(e)))t.style.fillColor&&(r.fillColor=t.style.fillColor),t.style.strokeColor&&(r.strokeColor=t.style.strokeColor),t.style.textColor&&(r.textColor=t.style.textColor);for(let r of n2(e))t.style.strokeColor&&(r.strokeColor=t.style.strokeColor),t.style.textColor&&(r.textColor=t.style.textColor);for(let r of n1(e))t.style.textColor&&(r.textColor=t.style.textColor);return[]}let r=n5(e,t.selector);if(0===r.nodes.length&&0===r.arrows.length&&0===r.texts.length)return[n6(t)];for(let n of r.nodes)if(t.style.fillColor&&(n.fillColor=t.style.fillColor),t.style.strokeColor&&(n.strokeColor=t.style.strokeColor),t.style.textColor){n.textColor=t.style.textColor;let r=n8(e,n.id);r&&(r.textColor=t.style.textColor)}for(let n of r.arrows)if(t.style.strokeColor&&(n.strokeColor=t.style.strokeColor),t.style.textColor){n.textColor=t.style.textColor;let r=n8(e,n.id);r&&(r.textColor=t.style.textColor)}for(let e of r.texts)t.style.textColor&&(e.textColor=t.style.textColor);return[];case"setShape":let n=n5(e,t.selector);if(0===n.nodes.length)return[n6(t)];let i=[];for(let r of n.nodes){if(r.shape=t.shape,"circle"===t.shape){let e=Math.max(r.width,r.height);r.x-=(e-r.width)/2,r.y-=(e-r.height)/2,r.width=e,r.height=e,i.push(r.nodeId)}!function(e,t){let r=n8(e,t.id);r&&(r.x=t.x+t.width/2,r.y=t.y+t.height/2)}(e,r)}return n9(e,i),[];case"translate":return function(e,t){let r=n5(e,t.selector);if(0===r.nodes.length&&0===r.arrows.length&&0===r.texts.length)return[n6(t)];let n=new Set,i=new Set;for(let s of r.nodes){s.x+=t.dx,s.y+=t.dy,n.add(s.nodeId);let r=n8(e,s.id);r&&(r.x+=t.dx,r.y+=t.dy,i.add(r.id))}for(let n of r.arrows){n.points=n.points.map(e=>{var r,n;return r=t.dx,n=t.dy,{x:e.x+r,y:e.y+n}});let r=n8(e,n.id);r&&(r.x+=t.dx,r.y+=t.dy,i.add(r.id))}for(let e of r.texts)i.has(e.id)||(e.x+=t.dx,e.y+=t.dy);return n9(e,[...n]),function(e){let t=[e.width],r=[e.height];for(let n of n0(e))t.push(n.x+n.width),r.push(n.y+n.height);for(let n of n1(e))t.push(n.x+(n.maxWidth??0)),r.push(n.y+n.fontSize);for(let n of n2(e))for(let e of n.points)t.push(e.x),r.push(e.y);e.width=Math.max(...t)+48,e.height=Math.max(...r)+48}(e),[]}(e,t);case"replaceText":let s=n5(e,t.selector);if(0===s.nodes.length&&0===s.arrows.length&&0===s.texts.length)return[n6(t)];for(let r of s.nodes){r.label=t.text;let n=n8(e,r.id);n&&(n.text=t.text)}for(let r of s.arrows){r.label=t.text;let n=n8(e,r.id);n&&(n.text=t.text)}for(let e of s.texts)e.text=t.text;return[];case"rerouteEdges":let a;return 0===(a=n5(e,t.selector)).arrows.length?[n6(t)]:a.arrows.flatMap(t=>ie(e,t))}}(d,e);if(t.length>0)return t}return[]}).pipe(a.fRP("codeMode.applyDiagramPatch.operations"));if(h.length>0)return yield*new nR({status:h[0]?.code==="unknown_patch_target"?"target_not_found":"unsupported_operation",context:{...u,issues:h}});if(i.options?.preserveConnectivity!==!1){let e=nZ(d);if(!(f.length===e.length&&f.every((t,r)=>t===e[r])))return yield*new nR({status:"connectivity_changed",context:{...u,issues:[nB({code:"patch_preserve_connectivity_failed",stage:"flowchart",ref:{kind:"diagram",id:d.diagramId},message:"Patch changed the diagram edge connectivity.",hint:"Use buildFlowchart for process-graph structure or buildMindmap for hierarchy structure."})]}})}let p=yield*a.OH5(()=>(function(e){let t=[];for(let r of e.elements){if("arrow"===r.type){let e=r.points[0],n=r.points[1],i=r.points.slice(2);if(!e||!n)return null;let s=[e,n,...i];t.push({type:"arrow",id:r.id,edgeId:r.edgeId,sourceNodeId:r.sourceNodeId,targetNodeId:r.targetNodeId,...r.strokeColor?{strokeColor:r.strokeColor}:{},...r.textColor?{textColor:r.textColor}:{},points:s,...r.label?{label:r.label}:{}});continue}if("node"===r.type){t.push({type:"node",id:r.id,nodeId:r.nodeId,...r.kind?{kind:r.kind}:{},shape:r.shape,...r.fillColor?{fillColor:r.fillColor}:{},...r.strokeColor?{strokeColor:r.strokeColor}:{},...r.textColor?{textColor:r.textColor}:{},x:r.x,y:r.y,width:r.width,height:r.height,label:r.label});continue}t.push({type:"text",id:r.id,...r.containerId?{containerId:r.containerId}:{},...r.textColor?{textColor:r.textColor}:{},x:r.x,y:r.y,text:r.text,fontSize:r.fontSize,...r.maxWidth?{maxWidth:r.maxWidth}:{}})}return{diagramId:e.diagramId,title:e.title,width:e.width,height:e.height,accentColor:e.accentColor,backgroundColor:e.backgroundColor,elements:t}})(d)).pipe(a.fRP("codeMode.applyDiagramPatch.normalize"));if(!p)return yield*new nR({status:"render_failed",context:{...u,issues:[nB({code:"patch_output_invalid",stage:"render",ref:{kind:"diagram",id:d.diagramId},message:"Patched scene has an invalid arrow point list.",hint:"Reroute edges or rebuild the flowchart artifact."})]}});let{excalidraw:m,validation:g}=yield*a.OH5(()=>{let e=rS(p);return{excalidraw:e,validation:rT(e)}}).pipe(a.fRP("codeMode.applyDiagramPatch.exportValidate")),y={...u,partial:is(p)};if(!g.ok)return yield*new nR({status:"export_failed",context:{...y,issues:nz(g.issues)}});let b=yield*nG({formats:l,scene:p,excalidraw:m,renderer:r.renderer}).pipe(a.xm_(e=>new nR({status:"export_failed",context:{...y,issues:nH(e)}}))),v=yield*a.OH5(()=>r.createId("artifact")),w=yield*nv(n.write({artifactId:v,diagramId:p.diagramId,formats:b,inlineFormats:nV(i.options),...c.sourceArtifactId?{provenance:{sourceArtifactId:c.sourceArtifactId}}:{}}),{artifactId:v,...i.requestId?{requestId:i.requestId}:{}}).pipe(a.xm_(e=>new nR({status:"storage_failed",context:{...u,issues:[iu(e,"storage_write_failed")]}})));return{ok:!0,status:"accepted",patchId:s,...ir(i.requestId),...c.sourceArtifactId?{sourceArtifactId:c.sourceArtifactId}:{},artifact:ii(w,r.artifactUrl),issues:[]}});function ig(e,t){return e.pipe(a.YWq({onFailure:t,onSuccess:e=>e}))}let iy=a.fn("codeMode.buildFlowchart")(e=>nP("buildFlowchart",e,ig(ih(e),ia))),ib=a.fn("codeMode.buildMindmap")(e=>nP("buildMindmap",e,ig(id(e),io)));a.fn("codeMode.getArtifact")(e=>nP("getArtifact",e,ig(ip(e),il))),a.fn("codeMode.applyDiagramPatch")(e=>nP("applyDiagramPatch",e,ig(im(e),ic)))}},o={};function l(e){var t=o[e];if(void 0!==t)return t.exports;var r=o[e]={exports:{}};return a[e].call(r.exports,r,r.exports,l),r.exports}l.m=a,n=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,l.t=function(e,t){if(1&t&&(e=this(e)),8&t||"object"==typeof e&&e&&(4&t&&e.__esModule||16&t&&"function"==typeof e.then))return e;var i=Object.create(null);l.r(i);var s={};r=r||[null,n({}),n([]),n(n)];for(var a=2&t&&e;("object"==typeof a||"function"==typeof a)&&!~r.indexOf(a);a=n(a))Object.getOwnPropertyNames(a).forEach(t=>{s[t]=()=>e[t]});return s.default=()=>e,l.d(i,s),i},l.d=(e,t,r)=>{var n=(t,r)=>{for(var n in t)l.o(t,n)&&!l.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,[r]:t[n]})};n(t,"get"),n(r,"value")},l.f={},l.e=e=>Promise.all(Object.keys(l.f).reduce((t,r)=>(l.f[r](e,t),t),[])),l.u=e=>"chunks/"+e+"."+({831:"0761b12c81336696",869:"1dfc43b6f9a12ea7"})[e]+".js",l.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),l.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.nc=void 0,i={889:0},s=e=>{var t,r,n=e.__rspack_esm_ids,s=e.__webpack_modules__,a=e.__rspack_esm_runtime,o=0;for(t in s)l.o(s,t)&&(l.m[t]=s[t]);for(a&&a(l);o<n.length;o++)r=n[o],l.o(i,r)&&i[r]&&i[r][0](),i[n[o]]=0},l.f.j=function(e,t){var r=l.o(i,e)?i[e]:void 0;if(0!==r)if(r)t.push(r[1]);else{var n=import("./"+l.u(e)).then(s,t=>{throw 0!==i[e]&&(i[e]=void 0),t}),n=Promise.race([n,new Promise(t=>{r=i[e]=[t]})]);t.push(r[1]=n)}},l(233);