sketchi 0.4.3 → 0.6.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,63 +1,65 @@
1
1
  #!/usr/bin/env node
2
- import{createRequire as e}from"node:module";let t=e(import.meta.url);var r,n,i,a,s={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",a=t.whitespace?" = ":"=",o=[],l=t.sort?Object.keys(e).sort():Object.keys(e),c=0;t.align&&(c=s(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)=>s(e).length>=s(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+=s(`${t}${d}`).padEnd(c," ")+a+s(e)+i;else r&&"object"==typeof r?o.push(t):u+=s(t).padEnd(c," ")+a+s(r)+i}for(let a of(t.section&&u.length&&(u="["+s(t.section)+"]"+(t.newline?i+i:i)+u),o)){let s=n(a,".").join("\\."),o=(t.section?t.section+".":"")+s,l=r(e[a],{...t,section:o});u.length&&l.length&&(u+=i),u+=l}return u};function n(e,t){var r=0,n=0,i=0,a=[];do if(-1!==(i=e.indexOf(t,r))){if(r=i+t.length,i>0&&"\\"===e[i-1])continue;a.push(e.slice(n,i)),n=i+t.length}while(-1!==i)return a.push(e.slice(n)),a}let i=(e,r={})=>{r.bracketedArray=!1!==r.bracketedArray;let i=Object.create(null),a=i,s=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__"===(s=o(c[1]))){a=Object.create(null);continue}a=i[s]=i[s]||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(a,f)?Array.isArray(a[f])||(a[f]=[a[f]]):a[f]=[]),Array.isArray(a[f])?a[f].push(p):a[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,".");a=i;let s=r.pop(),o=s.replace(/\\\./g,".");for(let e of r)"__proto__"!==e&&(t.call(a,e)&&"object"==typeof a[e]||(a[e]=Object.create(null)),a=a[e]);(a!==i||o!==s)&&(a[o]=i[e],d.push(e))}for(let e of d)delete i[e];return i},a=e=>e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"),s=e=>"string"!=typeof e||e.match(/[=\r\n]/)||e.match(/^\[/)||e.length>1&&a(e)||e!==e.trim()?JSON.stringify(e):e.split(";").join("\\;").split("#").join("\\#"),o=e=>{if(a(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:s,unsafe:o}},5776(e){let t={to:(e,t)=>t?`[${t+1};${e+1}H`:`[${e+1}G`,move(e,t){let r="";return e<0?r+=`[${-e}D`:e>0&&(r+=`[${e}C`),t<0?r+=`[${-t}A`:t>0&&(r+=`[${t}B`),r},up:(e=1)=>`[${e}A`,down:(e=1)=>`[${e}B`,forward:(e=1)=>`[${e}C`,backward:(e=1)=>`[${e}D`,nextLine:(e=1)=>"\x1b[E".repeat(e),prevLine:(e=1)=>"\x1b[F".repeat(e),left:"\x1b[G",hide:"\x1b[?25l",show:"\x1b[?25h",save:"\x1b7",restore:"\x1b8"},r={screen:"\x1b[2J",up:(e=1)=>"\x1b[1J".repeat(e),down:(e=1)=>"\x1b[J".repeat(e),line:"\x1b[2K",lineEnd:"\x1b[K",lineStart:"\x1b[1K",lines(e){let r="";for(let n=0;n<e;n++)r+=this.line+(n<e-1?t.up():"");return e&&(r+=t.left),r}};e.exports={cursor:t,scroll:{up:(e=1)=>"\x1b[S".repeat(e),down:(e=1)=>"\x1b[T".repeat(e)},erase:r,beep:"\x07"}},3176(e,t,r){var n=r(3633),i=r(4239);e.exports={parse:function(e,t){var r=e.toString(),a=n.parse(r,t);return i.compile(a,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,a=new Set,s=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 a=t[i];if("InlineTableValue"===a.type){var s=a.key;Array.isArray(s)||(s=[s]),function(e,t,r,n,i){for(var a=0;a<t.length-1;a++){var s=t[a],o=w(t.slice(0,a+1));void 0===e[s]?e[s]=b():"object"!=typeof e[s]||null===e[s]||Array.isArray(e[s])?p("Cannot redefine existing key '"+o+"'.",n):i&&i.has(o)&&p("Cannot extend inline table '"+o+"'.",n),e=e[s]}var l=t[t.length-1];void 0!==e[l]&&p("Cannot redefine existing key '"+w(t)+"'.",n),e[l]=r}(r,s,e(a.value),a.offset,n),n.add(w(s))}}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=_(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])||a.has(g)?p("Cannot redefine existing key '"+g+"'.",l):s.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=_(t);void 0!==d[y]&&p("Cannot redefine existing key '"+v+"'.",l),d[y]=c,i.add(v),a.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),s.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(a.has(r)&&p("Cannot append to statically defined array '"+r+"'.",n),i.forEach(function(e){x(e,r)&&i.delete(e)}),a.forEach(function(e){x(e,r)&&a.delete(e)}),i.add(r),u=g(c,t,function(){var e=[];return l.add(e),e}(),n),o=t,u instanceof Array){var s=b();u.push(s),u=s}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,s=0;s<t.length;s++){var o=t[s],l=w(t.slice(0,s+1));void 0===i[o]?s===t.length-1?i[o]=r:i[o]=b():s!==t.length-1&&a.has(l)&&p("Cannot redefine existing key '"+l+"'.",n),i=i[o],s<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 _(e){return w(o.concat(e))}function x(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,a=this.location.source&&"function"==typeof this.location.source.offset?this.location.source.offset(i):i,s=this.location.source+":"+a.line+":"+a.column;if(r){let e=this.location.end,n="".padEnd(a.line.toString().length," "),o=r[i.line-1],l=(i.line===e.line?e.column:o.length+1)-i.column||1;t+="\n --\x3e "+s+"\n"+n+" |\n"+a.line+" | "+o+"\n"+n+" | "+"".padEnd(i.column-1," ")+"".padEnd(l,"^")}else t+="\n at "+s}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 a(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 s(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=>'"'+a(e.text)+'"',class(e){let t=e.parts.map(e=>Array.isArray(e)?s(e[0])+"-"+s(e[1]):s(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?'"'+a(t)+'"':"end of input")+" found."}}e.exports={StartRules:["start"],SyntaxError:t,parse:function(e,r){let n,i={},a=(r=void 0!==r?r:{}).grammarSource,s={start:eD},o=eD,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]/,_=/^[0-9a-fA-F]/,x=/^[0-7]/,k=/^[01]/,S=/^[ \t]/,E=/^[A-Za-z0-9_\-]/,I=/^["\\btnfre]/,$=eN("#",!1),O=eM([" ",[" ","~"],["€","￿"]],!1,!1,!1),T=eN("[",!1),A=eN("]",!1),C=eN(".",!1),N=eN("=",!1),M=eM(["+","-"],!1,!1,!1),P=eN("inf",!1),R=eN("nan",!1),j=eN('"""',!1),D=eN('"',!1),L=eN("'''",!1),U=eN("'",!1),F=eN("\\",!1),B={type:"any"},Y=eN("\r\n",!1),W=eM(['"',"\\",["\0","\b"],["\v","\x1f"],"","\r"],!0,!1,!1),q=eN('""',!1),X=eM(["'",["\0","\b"],["\v","\x1f"],"","\r"],!0,!1,!1),J=eN("''",!1),z=eM(['"',"\\",["\0","\b"],["\n","\x1f"],""],!0,!1,!1),G=eM(["'",["\0","\b"],["\n","\x1f"],""],!0,!1,!1),V=eM(["e","E"],!1,!1,!1),K=eN("0",!1),H=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),ea=eM([["0","7"]],!1,!1,!1),es=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),e_=eM([["A","Z"],["a","z"],["0","9"],"_","-"],!1,!1,!1),ex=eM(['"',"\\","b","t","n","f","r","e"],!1,!1,!1),ek=eN("\\U",!1),eS=eN("\\u",!1),eE=eN("\\x",!1),eI=0|r.peg$currPos,e$=eI,eO=[{line:1,column:1}],eT=eI,eA=r.peg$maxFailExpected||[],eC=0|r.peg$silentFails;if(r.startRule){if(!(r.startRule in s))throw Error("Can't start parsing from rule \""+r.startRule+'".');o=s[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=eO[t];if(n)return n;if(t>=eO.length)r=eO.length-1;else for(r=t;!eO[--r];);for(n={line:(n=eO[r]).line,column:n.column};r<t;)10===e.charCodeAt(r)?(n.line++,n.column=1):n.column++,r++;return eO[t]=n,n}function eR(e,t,r){let n=eP(e),i=eP(t),s={source:a,start:{offset:e,line:n.line,column:n.column},end:{offset:t,line:i.line,column:i.column}};return r&&a&&"function"==typeof a.offset&&(s.start=a.offset(s.start),s.end=a.offset(s.end)),s}function ej(e){eI<eT||(eI>eT&&(eT=eI,eA=[]),eA.push(e))}function eD(){let t,r,n,a;for(t=eI,65279===e.charCodeAt(eI)?(a="\uFEFF",eI++):(a=i,0===eC&&ej(ew)),a===i,r=[],n=eL();n!==i;)r.push(n),n=eL();return e$=t,t=tl}function eL(){let t,r,n,a,s,o,l,c;for(t=eI,r=[],n=te();n!==i;)r.push(n),n=te();if((c=eU())===i&&(c=function(){let t,r,n,a,s,o,l,c;if(t=eI,91===e.charCodeAt(eI)?(r="[",eI++):(r=i,0===eC&&ej(T)),r!==i)if(91===e.charCodeAt(eI)?(n="[",eI++):(n=i,0===eC&&ej(T)),n!==i){for(a=[],s=te();s!==i;)a.push(s),s=te();if((s=eF())!==i){for(o=[],l=te();l!==i;)o.push(l),l=te();(93===e.charCodeAt(eI)?(l="]",eI++):(l=i,0===eC&&ej(A)),l!==i&&(93===e.charCodeAt(eI)?(c="]",eI++):(c=i,0===eC&&ej(A)),c!==i))?t=void tf(th("ArrayPath",s,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===eC&&ej(T)),r!==i){for(n=[],a=te();a!==i;)n.push(a),a=te();if((a=eF())!==i){for(s=[],o=te();o!==i;)s.push(o),o=te();(93===e.charCodeAt(eI)?(o="]",eI++):(o=i,0===eC&&ej(A)),o!==i)?t=void tf(th("ObjectPath",a,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,a,s,o;if(t=eI,(r=e3())!==i){for(n=[],a=te();a!==i;)n.push(a),a=te();if(61===e.charCodeAt(eI)?(a="=",eI++):(a=i,0===eC&&ej(N)),a!==i){for(s=[],o=te();o!==i;)s.push(o),o=te();if((o=eW())!==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(a=[],s=te();s!==i;)a.push(s),s=te();if((s=eU())===i&&(s=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,a,s,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=[],(a=tt())!==i)for(;a!==i;)n.push(a),a=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 eU(){let t,r,n,a;if(t=eI,35===e.charCodeAt(eI)?(r="#",eI++):(r=i,0===eC&&ej($)),r!==i){for(n=[],a=e.charAt(eI),u.test(a)?eI++:(a=i,0===eC&&ej(O));a!==i;)n.push(a),a=e.charAt(eI),u.test(a)?eI++:(a=i,0===eC&&ej(O));t=r=[r,n]}else eI=t,t=i;return t}function eF(){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,a;e$=e,n=t,a=r,e=n.concat(a)}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,a;for(e=eI,t=[],r=te();r!==i;)t.push(r),r=te();if((r=e6())!==i){for(n=[],a=te();a!==i;)n.push(a),a=te();e$=e,e=r}else eI=e,e=i;return e}function eY(){let t,r,n,a,s;for(t=eI,r=[],n=te();n!==i;)r.push(n),n=te();if((n=e6())!==i){for(a=[],s=te();s!==i;)a.push(s),s=te();(46===e.charCodeAt(eI)?(s=".",eI++):(s=i,0===eC&&ej(C)),s!==i)?(e$=t,t=n):(eI=t,t=i)}else eI=t,t=i;return t}function eW(){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,a,s,o,u,f,h,p,m,b,w,S,E,I,$;if(t=eI,(s=eI,'"""'===e.substr(eI,3)?(o='"""',eI+=3):(o=i,0===eC&&ej(j)),o!==i&&(tt()===i,u=function(){let t,r,n,a,s,o,l,c,u,d,f;for(t=eI,r=[],n=eJ();n!==i;)r.push(n),n=eJ();if(n=[],a=eI,(s=ez())!==i){if(o=[],(l=eJ())!==i)for(;l!==i;)o.push(l),l=eJ();else o=i;o!==i?a=s=[s,o]:(eI=a,a=i)}else eI=a,a=i;for(;a!==i;)if(n.push(a),a=eI,(s=ez())!==i){if(o=[],(l=eJ())!==i)for(;l!==i;)o.push(l),l=eJ();else o=i;o!==i?a=s=[s,o]:(eI=a,a=i)}else eI=a,a=i;return c=eI,'""'===e.substr(eI,2)?(u='""',eI+=2):(u=i,0===eC&&ej(q)),u!==i?(d=eI,eC++,'"""'===e.substr(eI,3)?(f='"""',eI+=3):(f=i,0===eC&&ej(j)),eC--,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===eC&&ej(D)),u!==i?(d=eI,eC++,'"""'===e.substr(eI,3)?(f='"""',eI+=3):(f=i,0===eC&&ej(j)),eC--,f!==i?(eI=d,d=void 0):d=i,d!==i?(e$=c,c='"'):(eI=c,c=i)):(eI=c,c=i)),(a=c)===i&&(a=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,a)}(),'"""'===e.substr(eI,3)?(f='"""',eI+=3):(f=i,0===eC&&ej(j)),f!==i))?s=th("String",u,e$=s):(eI=s,s=i),(a=s)===i&&(a=eq())===i&&((h=eI,"'''"===e.substr(eI,3)?(p="'''",eI+=3):(p=i,0===eC&&ej(L)),p!==i&&(tt()===i,m=function(){let t,r,n,a,s,o,l,c,u,d,f;for(t=eI,r=[],n=eG();n!==i;)r.push(n),n=eG();if(n=[],a=eI,(s=eV())!==i){if(o=[],(l=eG())!==i)for(;l!==i;)o.push(l),l=eG();else o=i;o!==i?a=s=[s,o]:(eI=a,a=i)}else eI=a,a=i;for(;a!==i;)if(n.push(a),a=eI,(s=eV())!==i){if(o=[],(l=eG())!==i)for(;l!==i;)o.push(l),l=eG();else o=i;o!==i?a=s=[s,o]:(eI=a,a=i)}else eI=a,a=i;return c=eI,"''"===e.substr(eI,2)?(u="''",eI+=2):(u=i,0===eC&&ej(J)),u!==i?(d=eI,eC++,"'''"===e.substr(eI,3)?(f="'''",eI+=3):(f=i,0===eC&&ej(L)),eC--,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===eC&&ej(U)),u!==i?(d=eI,eC++,"'''"===e.substr(eI,3)?(f="'''",eI+=3):(f=i,0===eC&&ej(L)),eC--,f!==i?(eI=d,d=void 0):d=i,d!==i?(e$=c,c="'"):(eI=c,c=i)):(eI=c,c=i)),(a=c)===i&&(a=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,a)}(),"'''"===e.substr(eI,3)?(b="'''",eI+=3):(b=i,0===eC&&ej(L)),b!==i))?h=th("String",m,e$=h):(eI=h,h=i),(a=h)===i)&&(a=eX()),(n=a)===i&&((w=eI,S=e.charAt(eI),d.test(S)?eI++:(S=i,0===eC&&ej(M)),S===i&&(S=null),"inf"===e.substr(eI,3)?(E="inf",eI+=3):(E=i,0===eC&&ej(P)),E!==i)?w=th("Float","-"===S?-1/0:1/0,e$=w):(eI=w,w=i),w===i&&(w=eI,S=e.charAt(eI),d.test(S)?eI++:(S=i,0===eC&&ej(M)),S===i&&(S=null),"nan"===e.substr(eI,3)?(E="nan",eI+=3):(E=i,0===eC&&ej(R)),E!==i?w=th("Float",NaN,e$=w):(eI=w,w=i),w===i&&(w=function(){var t,r,n,a,s,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 s,o,l,c,u,f,h,g;(s=eI,"z"===(o=e.charAt(eI)).toLowerCase()?eI++:(o=i,0===eC&&ej(ep)),o!==i&&(e$=s,o="Z"),(s=o)===i&&(s=eI,o=eI,l=e.charAt(eI),d.test(l)?eI++:(l=i,0===eC&&ej(M)),l!==i&&(c=ti())!==i&&(u=ti())!==i?(58===e.charCodeAt(eI)?(f=":",eI++):(f=i,0===eC&&ej(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),s=o!==i?e.substring(s,eI):o),(b=s)!==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),(a=th("Date",new Date(t+"T"+r+b),n)).raw=t+"T"+r,a.tz=b,p=a):(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,s=m,o=y,tp(s,l=e$),tm(o,l),p=th("LocalDateTime",s+"T"+o,l)):(eI=p,p=i),p===i&&((p=eI,(m=e9())!==i&&(g=eI,eC++,y=e7(),eC--,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,a,s,o,l,c,u,f;if(t=eI,(s=eI,o=e.charAt(eI),d.test(o)?eI++:(o=i,0===eC&&ej(M)),o===i&&(o=null),(l=eQ())!==i&&(46===e.charCodeAt(eI)?(c=".",eI++):(c=i,0===eC&&ej(C)),c!==i&&(u=eI,(u=(f=e0())!==i?e.substring(u,eI):f)!==i)))?(e$=s,s=("-"===o?"-":"")+l+"."+u):(eI=s,s=i),s===i&&((s=eI,o=e.charAt(eI),d.test(o)?eI++:(o=i,0===eC&&ej(M)),o===i&&(o=null),(l=eQ())!==i)?(e$=s,s=("-"===o?"-":"")+l):(eI=s,s=i)),(r=s)!==i)if(n=e.charAt(eI),g.test(n)?eI++:(n=i,0===eC&&ej(V)),n!==i){let n,s,o,l;if((n=eI,s=e.charAt(eI),d.test(s)?eI++:(s=i,0===eC&&ej(M)),s===i&&(s=null),o=eI,(o=(l=e0())!==i?e.substring(o,eI):l)!==i)?(e$=n,n=(s||"")+o):(eI=n,n=i),(a=n)!==i)e$=t,t=th("Float",parseFloat(tg(r+"e"+a)),e$);else eI=t,t=i}else eI=t,t=i;else eI=t,t=i;if(t===i){let n,a,s,o,l,c;t=eI,(n=eI,a=e.charAt(eI),d.test(a)?eI++:(a=i,0===eC&&ej(M)),a===i&&(a=null),(s=eQ())!==i&&(46===e.charCodeAt(eI)?(o=".",eI++):(o=i,0===eC&&ej(C)),o!==i&&(l=eI,(l=(c=e0())!==i?e.substring(l,eI):c)!==i)))?(e$=n,n=("-"===a?"-":"")+s+"."+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,a;if(((t=eI,"0x"===e.substr(eI,2)?(r="0x",eI+=2):(r=i,0===eC&&ej(H)),r!==i&&(n=eI,(n=(a=function(){let t,r,n,a,s,o;if(t=eI,r=e.charAt(eI),_.test(r)?eI++:(r=i,0===eC&&ej(ei)),r!==i){for(n=[],a=eI,s=e.charAt(eI),v.test(s)?eI++:(s=i,0===eC&&ej(er)),s===i&&(s=null),o=e.charAt(eI),_.test(o)?eI++:(o=i,0===eC&&ej(ei)),o!==i?a=s=[s,o]:(eI=a,a=i);a!==i;)n.push(a),a=eI,s=e.charAt(eI),v.test(s)?eI++:(s=i,0===eC&&ej(er)),s===i&&(s=null),o=e.charAt(eI),_.test(o)?eI++:(o=i,0===eC&&ej(ei)),o!==i?a=s=[s,o]:(eI=a,a=i);t=r=[r,n]}else eI=t,t=i;return t}())!==i?e.substring(n,eI):a)!==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===eC&&ej(Q)),r!==i&&(n=eI,(n=(a=function(){let t,r,n,a,s,o;if(t=eI,r=e.charAt(eI),x.test(r)?eI++:(r=i,0===eC&&ej(ea)),r!==i){for(n=[],a=eI,s=e.charAt(eI),v.test(s)?eI++:(s=i,0===eC&&ej(er)),s===i&&(s=null),o=e.charAt(eI),x.test(o)?eI++:(o=i,0===eC&&ej(ea)),o!==i?a=s=[s,o]:(eI=a,a=i);a!==i;)n.push(a),a=eI,s=e.charAt(eI),v.test(s)?eI++:(s=i,0===eC&&ej(er)),s===i&&(s=null),o=e.charAt(eI),x.test(o)?eI++:(o=i,0===eC&&ej(ea)),o!==i?a=s=[s,o]:(eI=a,a=i);t=r=[r,n]}else eI=t,t=i;return t}())!==i?e.substring(n,eI):a)!==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===eC&&ej(Z)),r!==i&&(n=eI,(n=(a=function(){let t,r,n,a,s,o;if(t=eI,r=e.charAt(eI),k.test(r)?eI++:(r=i,0===eC&&ej(es)),r!==i){for(n=[],a=eI,s=e.charAt(eI),v.test(s)?eI++:(s=i,0===eC&&ej(er)),s===i&&(s=null),o=e.charAt(eI),k.test(o)?eI++:(o=i,0===eC&&ej(es)),o!==i?a=s=[s,o]:(eI=a,a=i);a!==i;)n.push(a),a=eI,s=e.charAt(eI),v.test(s)?eI++:(s=i,0===eC&&ej(er)),s===i&&(s=null),o=e.charAt(eI),k.test(o)?eI++:(o=i,0===eC&&ej(es)),o!==i?a=s=[s,o]:(eI=a,a=i);t=r=[r,n]}else eI=t,t=i;return t}())!==i?e.substring(n,eI):a)!==i))?(e$=t,t=th("Integer",parseInt(tg(n),2),e$)):(eI=t,t=i),t===i)){let n,a,s,o,l,c;t=eI,(n=eI,a=e.charAt(eI),d.test(a)?eI++:(a=i,0===eC&&ej(M)),a===i&&(a=null),48===e.charCodeAt(eI)?(s="0",eI++):(s=i,0===eC&&ej(K)),s!==i&&(o=eI,eC++,l=e.charAt(eI),y.test(l)?eI++:(l=i,0===eC&&ej(ee)),eC--,l===i?o=void 0:(eI=o,o=i),o!==i&&(l=eI,eC++,46===e.charCodeAt(eI)?(c=".",eI++):(c=i,0===eC&&ej(C)),eC--,c===i?l=void 0:(eI=l,l=i),l!==i)))?(e$=n,n=(a||"")+"0"):(eI=n,n=i),n===i&&((n=eI,a=e.charAt(eI),d.test(a)?eI++:(a=i,0===eC&&ej(M)),a===i&&(a=null),s=eI,(s=(o=eZ())!==i?e.substring(s,eI):o)!==i&&(o=eI,eC++,46===e.charCodeAt(eI)?(l=".",eI++):(l=i,0===eC&&ej(C)),eC--,l===i?o=void 0:(eI=o,o=i),o!==i))?(e$=n,n=(a||"")+s):(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===eC&&ej(eo)),$!==i&&($=th("Boolean",!0,e$=I)),(I=$)===i&&(I=eI,e.substr(eI,5)===c?($=c,eI+=5):($=i,0===eC&&ej(el)),$!==i&&($=th("Boolean",!1,e$=I)),I=$),(n=I)===i&&(n=function(){let t,r,n,a,s,o,l,c,u,d;if(t=eI,91===e.charCodeAt(eI)?(r="[",eI++):(r=i,0===eC&&ej(T)),r!==i){for(n=[],a=e1();a!==i;)n.push(a),a=e1();93===e.charCodeAt(eI)?(a="]",eI++):(a=i,0===eC&&ej(A)),a!==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===eC&&ej(T)),r!==i){for(n=[],a=e1();a!==i;)n.push(a),a=e1();if((a=eW())!==i){for(s=[],o=eI,l=[],c=e1();c!==i;)l.push(c),c=e1();if(44===e.charCodeAt(eI)?(c=",",eI++):(c=i,0===eC&&ej(ec)),c!==i){for(u=[],d=e1();d!==i;)u.push(d),d=e1();(d=eW())!==i?(e$=o,o=d):(eI=o,o=i)}else eI=o,o=i;for(;o!==i;){for(s.push(o),o=eI,l=[],c=e1();c!==i;)l.push(c),c=e1();if(44===e.charCodeAt(eI)?(c=",",eI++):(c=i,0===eC&&ej(ec)),c!==i){for(u=[],d=e1();d!==i;)u.push(d),d=e1();(d=eW())!==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===eC&&ej(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===eC&&ej(A)),u!==i){var f;e$=t,f=a,s.unshift(f),t=th("Array",s,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,a,s,o,l,c,u,d;if(t=eI,123===e.charCodeAt(eI)?(r="{",eI++):(r=i,0===eC&&ej(eu)),r!==i){for(n=[],a=e5();a!==i;)n.push(a),a=e5();125===e.charCodeAt(eI)?(a="}",eI++):(a=i,0===eC&&ej(ed)),a!==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===eC&&ej(eu)),r!==i){for(n=[],a=e5();a!==i;)n.push(a),a=e5();if((a=e2())!==i){for(s=[],o=eI,l=[],c=e5();c!==i;)l.push(c),c=e5();if(44===e.charCodeAt(eI)?(c=",",eI++):(c=i,0===eC&&ej(ec)),c!==i){for(u=[],d=e5();d!==i;)u.push(d),d=e5();(d=e2())!==i?(e$=o,o=d):(eI=o,o=i)}else eI=o,o=i;for(;o!==i;){for(s.push(o),o=eI,l=[],c=e5();c!==i;)l.push(c),c=e5();if(44===e.charCodeAt(eI)?(c=",",eI++):(c=i,0===eC&&ej(ec)),c!==i){for(u=[],d=e5();d!==i;)u.push(d),d=e5();(d=e2())!==i?(e$=o,o=d):(eI=o,o=i)}else eI=o,o=i}for(o=[],l=e5();l!==i;)o.push(l),l=e5();for(44===e.charCodeAt(eI)?(l=",",eI++):(l=i,0===eC&&ej(ec)),l===i&&(l=null),c=[],u=e5();u!==i;)c.push(u),u=e5();if(125===e.charCodeAt(eI)?(u="}",eI++):(u=i,0===eC&&ej(ed)),u!==i){var f;e$=t,f=a,s.unshift(f),t=th("InlineTable",s,e$)}else eI=t,t=i}else eI=t,t=i}else eI=t,t=i;return t}()),(r=n)!==i){var O;e$=t,O=r,tc--,r=O}return(t=r)===i&&(e$=eI,tc--,t=!1,t=i),t}())!==i)?(e$=t,t=r):(eI=t,t=i),t}function eq(){let t,r,n,a;if(t=eI,34===e.charCodeAt(eI)?(r='"',eI++):(r=i,0===eC&&ej(D)),r!==i){for(n=[],a=eK();a!==i;)n.push(a),a=eK();(34===e.charCodeAt(eI)?(a='"',eI++):(a=i,0===eC&&ej(D)),a!==i)?(e$=t,t=th("String",n.join(""),e$)):(eI=t,t=i)}else eI=t,t=i;return t}function eX(){let t,r,n,a;if(t=eI,39===e.charCodeAt(eI)?(r="'",eI++):(r=i,0===eC&&ej(U)),r!==i){for(n=[],a=eH();a!==i;)n.push(a),a=eH();(39===e.charCodeAt(eI)?(a="'",eI++):(a=i,0===eC&&ej(U)),a!==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;if((t=to())===i&&(t=function(){let t,r,n,a,s,o;if(t=eI,92===e.charCodeAt(eI)?(r="\\",eI++):(r=i,0===eC&&ej(F)),r!==i){for(n=[],a=te();a!==i;)n.push(a),a=te();if((a=tt())!==i){for(s=[],o=tr();o!==i;)s.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===eC&&ej(F)),r!==i?(e.length>eI?(n=e.charAt(eI),eI++):(n=i,0===eC&&ej(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===eC&&ej(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===eC&&ej(W)),n!==i)for(;n!==i;)r.push(n),n=e.charAt(eI),f.test(n)?eI++:(n=i,0===eC&&ej(W));else r=i;t=r!==i?e.substring(t,eI):r}return t}function ez(){let t,r,n,a;return t=eI,'""'===e.substr(eI,2)?(r='""',eI+=2):(r=i,0===eC&&ej(q)),r!==i?(n=eI,eC++,34===e.charCodeAt(eI)?(a='"',eI++):(a=i,0===eC&&ej(D)),eC--,a===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===eC&&ej(D)),r!==i?(n=eI,eC++,34===e.charCodeAt(eI)?(a='"',eI++):(a=i,0===eC&&ej(D)),eC--,a===i?n=void 0:(eI=n,n=i),n!==i?(e$=t,t='"'):(eI=t,t=i)):(eI=t,t=i)),t}function eG(){let t,r,n;if(t=eI,"\r\n"===e.substr(eI,2)?(r="\r\n",eI+=2):(r=i,0===eC&&ej(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===eC&&ej(X)),n!==i)for(;n!==i;)r.push(n),n=e.charAt(eI),h.test(n)?eI++:(n=i,0===eC&&ej(X));else r=i;t=r!==i?e.substring(t,eI):r}return t}function eV(){let t,r,n,a;return t=eI,"''"===e.substr(eI,2)?(r="''",eI+=2):(r=i,0===eC&&ej(J)),r!==i?(n=eI,eC++,39===e.charCodeAt(eI)?(a="'",eI++):(a=i,0===eC&&ej(U)),eC--,a===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===eC&&ej(U)),r!==i?(n=eI,eC++,39===e.charCodeAt(eI)?(a="'",eI++):(a=i,0===eC&&ej(U)),eC--,a===i?n=void 0:(eI=n,n=i),n!==i?(e$=t,t="'"):(eI=t,t=i)):(eI=t,t=i)),t}function eK(){let t,r,n;if((t=to())===i&&(t=eI,92===e.charCodeAt(eI)?(r="\\",eI++):(r=i,0===eC&&ej(F)),r!==i?(e.length>eI?(n=e.charAt(eI),eI++):(n=i,0===eC&&ej(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===eC&&ej(z)),n!==i)for(;n!==i;)r.push(n),n=e.charAt(eI),p.test(n)?eI++:(n=i,0===eC&&ej(z));else r=i;t=r!==i?e.substring(t,eI):r}return t}function eH(){let t,r,n;if(t=eI,r=[],n=e.charAt(eI),m.test(n)?eI++:(n=i,0===eC&&ej(G)),n!==i)for(;n!==i;)r.push(n),n=e.charAt(eI),m.test(n)?eI++:(n=i,0===eC&&ej(G));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===eC&&ej(K)),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,a,s,o;if(t=eI,r=e.charAt(eI),b.test(r)?eI++:(r=i,0===eC&&ej(et)),r!==i){for(n=[],a=eI,s=e.charAt(eI),v.test(s)?eI++:(s=i,0===eC&&ej(er)),s===i&&(s=null),o=e.charAt(eI),w.test(o)?eI++:(o=i,0===eC&&ej(en)),o!==i?a=s=[s,o]:(eI=a,a=i);a!==i;)n.push(a),a=eI,s=e.charAt(eI),v.test(s)?eI++:(s=i,0===eC&&ej(er)),s===i&&(s=null),o=e.charAt(eI),w.test(o)?eI++:(o=i,0===eC&&ej(en)),o!==i?a=s=[s,o]:(eI=a,a=i);t=r=[r,n]}else eI=t,t=i;return t}function e0(){let t,r,n,a,s,o;if(t=eI,r=e.charAt(eI),w.test(r)?eI++:(r=i,0===eC&&ej(en)),r!==i){for(n=[],a=eI,s=e.charAt(eI),v.test(s)?eI++:(s=i,0===eC&&ej(er)),s===i&&(s=null),o=e.charAt(eI),w.test(o)?eI++:(o=i,0===eC&&ej(en)),o!==i?a=s=[s,o]:(eI=a,a=i);a!==i;)n.push(a),a=eI,s=e.charAt(eI),v.test(s)?eI++:(s=i,0===eC&&ej(er)),s===i&&(s=null),o=e.charAt(eI),w.test(o)?eI++:(o=i,0===eC&&ej(en)),o!==i?a=s=[s,o]:(eI=a,a=i);t=r=[r,n]}else eI=t,t=i;return t}function e1(){let e;return(e=te())===i&&(e=tt())===i&&(e=eU()),e}function e2(){let t,r,n,a,s,o;if(t=eI,(r=e3())!==i){for(n=[],a=te();a!==i;)n.push(a),a=te();if(61===e.charCodeAt(eI)?(a="=",eI++):(a=i,0===eC&&ej(N)),a!==i){for(s=[],o=te();o!==i;)s.push(o),o=te();if((o=eW())!==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 e5(){let e;return(e=te())===i&&(e=tt())===i&&(e=eU()),e}function e3(){let e,t,r,n;if(e=eI,t=[],(r=e8())!==i)for(;r!==i;)t.push(r),r=e8();else t=i;if(t!==i){for(r=[],n=te();n!==i;)r.push(n),n=te();if((n=e6())!==i){var a,s;e$=e,a=t,s=n,e=a.concat(s)}else eI=e,e=i}else eI=e,e=i;return e===i&&(e=eI,(t=e6())!==i&&(e$=e,t=[t]),e=t),e}function e8(){let t,r,n,a,s;for(t=eI,r=[],n=te();n!==i;)r.push(n),n=te();if((n=e6())!==i){for(a=[],s=te();s!==i;)a.push(s),s=te();(46===e.charCodeAt(eI)?(s=".",eI++):(s=i,0===eC&&ej(C)),s!==i)?(e$=t,t=n):(eI=t,t=i)}else eI=t,t=i;return t}function e6(){let t,r,n;return(t=function(){let t,r,n;if(t=eI,r=[],(n=ts())!==i)for(;n!==i;)r.push(n),n=ts();else r=i;return r!==i?e.substring(t,eI):r}())===i&&(r=eI,(n=eq())!==i&&(e$=r,n=n.value),(r=n)===i&&(r=eI,(n=eX())!==i&&(e$=r,n=n.value),r=n),t=r),t}function e9(){let t,r,n,a,s,o,l,c,u,d,f,h;return t=eI,r=eI,(n=ti())!==i&&(a=ti())!==i&&(s=ti())!==i&&(o=ti())!==i?(45===e.charCodeAt(eI)?(l="-",eI++):(l=i,0===eC&&ej(ef)),l!==i&&(c=ti())!==i&&(u=ti())!==i?(45===e.charCodeAt(eI)?(d="-",eI++):(d=i,0===eC&&ej(ef)),d!==i&&(f=ti())!==i&&(h=ti())!==i?r=n=[n,a,s,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,a,s,o,l,c,u,d,f;if(t=eI,r=eI,n=eI,(a=ti())!==i&&(s=ti())!==i?(58===e.charCodeAt(eI)?(o=":",eI++):(o=i,0===eC&&ej(eh)),o!==i&&(l=ti())!==i&&(c=ti())!==i?(58===e.charCodeAt(eI)?(u=":",eI++):(u=i,0===eC&&ej(eh)),u!==i&&(d=ti())!==i&&(f=ti())!==i?n=a=[a,s,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,a,s;if(t=eI,r=eI,46===e.charCodeAt(eI)?(n=".",eI++):(n=i,0===eC&&ej(C)),n!==i){if(a=[],(s=ti())!==i)for(;s!==i;)a.push(s),s=ti();else a=i;a!==i?r=n=[n,a]:(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,(a=ti())!==i&&(s=ti())!==i?(58===e.charCodeAt(eI)?(o=":",eI++):(o=i,0===eC&&ej(eh)),o!==i&&(l=ti())!==i&&(c=ti())!==i?n=a=[a,s,o,l,c]:(eI=n,n=i)):(eI=n,n=i),(r=n!==i?e.substring(r,eI):n)!==i&&(n=eI,eC++,58===e.charCodeAt(eI)?(a=":",eI++):(a=i,0===eC&&ej(eh)),eC--,a===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,a;return"t"===(t=e.charAt(eI)).toLowerCase()?eI++:(t=i,0===eC&&ej(em)),t===i&&(t=eI,32===e.charCodeAt(eI)?(r=" ",eI++):(r=i,0===eC&&ej(eg)),r!==i?(n=eI,eC++,a=ti(),eC--,a!==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),S.test(t)?eI++:(t=i,0===eC&&ej(ey)),t}function tt(){let t,r,n;return 10===e.charCodeAt(eI)?(t="\n",eI++):(t=i,0===eC&&ej(eb)),t===i&&(t=eI,13===e.charCodeAt(eI)?(r="\r",eI++):(r=i,0===eC&&ej(ev)),r!==i?(10===e.charCodeAt(eI)?(n="\n",eI++):(n=i,0===eC&&ej(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,eC++,e.length>eI?(r=e.charAt(eI),eI++):(r=i,0===eC&&ej(B)),eC--,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===eC&&ej(en)),t}function ta(){let t;return t=e.charAt(eI),_.test(t)?eI++:(t=i,0===eC&&ej(ei)),t}function ts(){let t;return t=e.charAt(eI),E.test(t)?eI++:(t=i,0===eC&&ej(e_)),t}function to(){let t,r,n,a,s,o,l,c,u,d,f,h,p,m,g;if(t=eI,92===e.charCodeAt(eI)?(r="\\",eI++):(r=i,0===eC&&ej(F)),r!==i)if(n=e.charAt(eI),I.test(n)?eI++:(n=i,0===eC&&ej(ex)),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&&((a=eI,"\\U"===e.substr(eI,2)?(s="\\U",eI+=2):(s=i,0===eC&&ej(ek)),s!==i&&(o=eI,l=eI,(c=ta())!==i&&(u=ta())!==i&&(d=ta())!==i&&(f=ta())!==i&&(h=ta())!==i&&(p=ta())!==i&&(m=ta())!==i&&(g=ta())!==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$=a,a=ty(o)):(eI=a,a=i),a===i&&((a=eI,"\\u"===e.substr(eI,2)?(s="\\u",eI+=2):(s=i,0===eC&&ej(eS)),s!==i&&(o=eI,l=eI,(c=ta())!==i&&(u=ta())!==i&&(d=ta())!==i&&(f=ta())!==i?l=c=[c,u,d,f]:(eI=l,l=i),(o=l!==i?e.substring(o,eI):l)!==i))?(e$=a,a=ty(o)):(eI=a,a=i),a===i&&((a=eI,"\\x"===e.substr(eI,2)?(s="\\x",eI+=2):(s=i,0===eC&&ej(eE)),s!==i&&(o=eI,l=eI,(c=ta())!==i&&(u=ta())!==i?l=c=[c,u]:(eI=l,l=i),(o=l!==i?e.substring(o,eI):l)!==i))?(e$=a,a=ty(o)):(eI=a,a=i))),t=a),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 a=[31,28,31,30,31,30,31,31,30,31,30,31];(r%4==0&&r%100!=0||r%400==0)&&(a[1]=29),(i<1||i>a[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,a,s;throw n!==i&&eI<e.length&&ej({type:"end"}),r=eA,a=eT<e.length?function(t=eI){let r=e.codePointAt(t);return void 0===r?"":String.fromCodePoint(r)}(eT):null,s=eT<e.length?eR(eT,eT+1):eR(eT,eT),new t(t.buildMessage(r,a),r,a,s)}return r.peg$library?{peg$result:n,peg$currPos:eI,peg$FAILED:i,peg$maxFailExpected:eA,peg$maxFailPos:eT,peg$success:tb,peg$throw:tb?void 0:tv}:tb?n:void tv()}}},7192(e,r,n){let i,a,s,o,l,c,u,d,f,h,p,m,g,y,b,v,w,_,x,k,S,E,I,$,O,T,A,C,N;var M,P,R,j,D,L=n(8543),U=n(7720),F=n(7598),B=n(4650);let Y=(e,t)=>t(F.oJ(e)?0:L.nn(e.cause)?130:q(L.iw(e.cause))),W="~effect/Runtime/errorExitCode",q=e=>{if("object"==typeof e&&null!==e&&W in e){let t=e[W];if("number"==typeof t)return t}return 1},X="~effect/Runtime/errorReported",J=(a=({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,B.XY)(e=>U.yw5(e[0]),(e,t)=>{let r=t?.disableErrorReporting===!0?U.MY7(e):U.MY7(U.dGm(e,e=>L.nn(e)?U.rIH:(e=>{if("object"==typeof e&&null!==e&&X in e){let t=e[X];if("boolean"==typeof t)return t}return!0})(L.iw(e))?U.vVN(e):U.rIH));try{let e=globalThis.setInterval(B.Yi,0x7fffffff);r.addObserver(()=>{clearInterval(e)})}catch{}return a({fiber:r,teardown:t?.teardown??Y})}));var z=n(5089),G=n(3717),V=n(8927),K=n(3833),H=n(995);function Q(){return Object.assign(e=>e,{option:e=>K.some(e),result:e=>H.Py(e),is:e=>!0})}var Z=n(8619),ee=n(2718);let et="~effect/platform/PlatformError";class er extends ee.rN("BadArgument"){get message(){return`${this.module}.${this.method}${this.description?`: ${this.description}`:""}`}}class en extends ee.$D{get message(){return`${this._tag}: ${this.module}.${this.method}${void 0!==this.pathOrDescriptor?` (${this.pathOrDescriptor})`:""}${this.description?`: ${this.description}`:""}`}}class ei extends ee.rN("PlatformError"){constructor(e){"cause"in e?super({reason:e,cause:e.cause}):super({reason:e})}[et]=et;get message(){return this.reason.message}}let ea=e=>new ei(new en(e)),es=e=>new ei(new er(e));var eo=n(9138),el=n(5369),ec=n(4505),eu=n(8433),ed=n(1136);let ef=Symbol.for("effect/MutableList/Empty"),eh=()=>({array:[],mutable:!0,offset:0,next:void 0}),ep=(e,t)=>{e.tail?e.tail.mutable||(e.tail.next=eh(),e.tail=e.tail.next):e.head=e.tail=eh(),e.tail.array.push(t),e.length++},em=e=>{e.head=e.tail=void 0,e.length=0},eg=e=>{if(!e.head)return ef;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:em(e)),t},ey={_A:B.D_,_E:B.D_},eb={"~effect/Queue":ey,"~effect/Queue/Enqueue":ey,"~effect/Queue/Dequeue":ey,...eu.fU,toJSON(){return{_id:"effect/Queue",state:this.state._tag,size:eA(this)}}},ev=e=>eu.R6(t=>{let r=Object.create(eb);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},ed.PyW(r)}),ew=(e,t)=>ed.DYE(()=>{if("Open"!==e.state._tag)return eC;if(e.messages.length>=e.capacity)switch(e.strategy){case"dropping":return eC;case"suspend":if(e.capacity<=0&&e.state.takers.size>0)return ep(e.messages,t),eR(e),eN;return eL(e,t);case"sliding":return eg(e.messages),ep(e.messages,t),eN}return ep(e.messages,t),ej(e),eN}),e_=(e,t)=>"Open"===e.state._tag&&(e.messages.length>=e.capacity?"sliding"===e.strategy?(eg(e.messages),ep(e.messages,t),!0):e.capacity<=0&&e.state.takers.size>0&&(ep(e.messages,t),eR(e),!0):(ep(e.messages,t),ej(e),!0)),ex=(0,B.XY)(2,(e,t)=>ed.OH5(()=>ek(e,t))),ek=(e,t)=>{if("Open"!==e.state._tag)return!1;let r=eu.cb(t),n=ed.il9(r,eM);return 0===e.state.offers.size&&0===e.messages.length?eB(e,n):e.state={...e.state,_tag:"Closing",exit:n},!0},eS=e=>ek(e,eu.OE(eu.RS())),eE=e=>ed.OH5(()=>{if("Done"===e.state._tag)return!0;em(e.messages);let t=e.state.offers;if(eB(e,"Open"===e.state._tag?eP:e.state.exit),t.size>0){for(let e of t)"Single"===e._tag?e.resume(eC):e.resume(eu.xt(e.remaining.slice(e.offset)));t.clear()}return!0}),eI=e=>e$(e,1,1/0),e$=(e,t,r)=>ed.DYE(()=>eD(e,t,r)??ed.hgn(eF(e),e$(e,1,r))),eO=e=>ed.DYE(()=>eT(e)??ed.hgn(eF(e),eO(e))),eT=e=>{if("Done"===e.state._tag)return e.state.exit;if(e.messages.length>0){let t=eg(e.messages);return eU(e),eu.xt(t)}if(e.capacity<=0&&e.state.offers.size>0){e.capacity=1,eU(e),e.capacity=0;let t=eg(e.messages);return eU(e),eu.xt(t)}},eA=e=>"Done"===e.state._tag?0:e.messages.length,eC=eu.xt(!1),eN=eu.xt(!0),eM=eu.Rk(eu.RS()),eP=ed._sz(),eR=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(ed.x5l),0===e.messages.length)break}},ej=e=>{e.scheduleRunning||"Done"===e.state._tag||0===e.state.takers.size||(e.scheduleRunning=!0,e.dispatcher.scheduleTask(()=>eR(e),0))},eD=(e,t,r)=>{if("Done"===e.state._tag)return e.state.exit;if(r<=0||t<=0)return eu.xt([]);if(e.capacity<=0&&e.state.offers.size>0){e.capacity=1,eU(e),e.capacity=0;let t=[eg(e.messages)];return eU(e),eu.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 em(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&&em(e),r;i=i.next}return em(e),r})(e.messages,r);return eU(e),eu.xt(t)}},eL=(e,t)=>ed.E2r(r=>{if("Open"!==e.state._tag)return r(eC);let n={_tag:"Single",message:t,resume:r};return e.state.offers.add(n),ed.OH5(()=>{"Open"===e.state._tag&&e.state.offers.delete(n)})}),eU=e=>{if("Done"===e.state._tag)return ec.Og(e.state.exit.cause);if(0===e.state.offers.size)return"Closing"===e.state._tag&&0===e.messages.length&&(eB(e,e.state.exit),ec.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)ep(e.messages,r.message),t--,r.resume(eN),e.state.offers.delete(r);else{for(;r.offset<r.remaining.length;r.offset++){if(0===t)return!1;ep(e.messages,r.remaining[r.offset]),t--}r.resume(eu.xt([])),e.state.offers.delete(r)}return!1},eF=e=>ed.E2r(t=>"Done"===e.state._tag?t(e.state.exit):(e.state.takers.add(t),ed.OH5(()=>{"Done"!==e.state._tag&&e.state.takers.delete(t)}))),eB=(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 eY=n(2672);let eW="~effect/Channel",eq=e=>(0,el.i5)(e,eW),eX={[eW]:{_Env:B.D_,_InErr:B.D_,_InElem:B.D_,_OutErr:B.D_,_OutElem:B.D_},pipe(){return(0,eo.tT)(this,arguments)}},eJ=e=>{let t=Object.create(eX);return t.transform=(t,r)=>U.Tyx(e(t,r),e=>U.PyW(U.ATB(e))),t},ez=(e,t)=>eJ((r,n)=>U.qIB(eV(e)(r,n),e=>t(e,n))),eG=e=>eJ((t,r)=>e),eV=e=>e.transform,eK=eG(U.PyW(L.Vw()));U.ZmZ;let eH=(0,B.XY)(2,(e,t)=>ez(e,e=>U.OH5(()=>{let r=0;return U.TjK(e,e=>t(e,r++))}))),eQ=(0,B.XY)(2,(e,t)=>eZ(e,e=>U.PyW(t(e)))),eZ=(0,B.XY)(2,(e,t)=>ez(e,e=>U.PyW(ec.m8(e,e=>U.qIB(t(e),L.Vw))))),e0=(0,B.XY)(e=>eq(e[0])&&eq(e[1]),(e,t,r)=>{let n;return n=U.D9k(function*(n,i,a){let s=r?.haltStrategy??"both",o=yield*ev({capacity:0});yield*eY.U9(a,eE(o));let l=0,c=(e,t,r)=>eV(t)(n,r).pipe(U.qIB(e=>e.pipe(U.qIB(e=>ew(o,e)),U.i4r)),U.S5A(t=>U.hgn(eY.VN(r,ec.aU(t)),function(e,t){if(l++,!ec.Og(t))return ex(o,t);switch(s){case"both":return 2===l?ex(o,t):U.rIH;case"left":case"right":return e===s?ex(o,t):U.rIH;case"either":return ex(o,t)}}(e,t))),U.ar0(a));return yield*c("left",e,eY.Fp(a)),yield*c("right",t,eY.Fp(a)),eO(o)}),eJ(U.D9k(function*(e,t){let r=eY.Fp(t),i=e=>eY.VN(r,ec.aU(e)),a=yield*U.S5A(n(e,t,r),i);return U.S5A(a,i)}))}),e1=(0,B.XY)(2,(e,t)=>eJ((r,n)=>U.qIB(eV(e)(r,n),e=>eV(t)(e,n)))),e2=e=>eJ((t,r)=>{let n;return U.PyW(U.DYE(()=>n||e.pipe(eY.Gt(r),U.qIB(e=>eV(e)(t,r)),U.qIB(e=>n=e))))}),e5=(e,t,r)=>U.DYE(()=>{let n=eY.LZ(),i=eV(e)(L.Vw(),n);return ec.m8(U.qIB(i,t),r||U.PyW).pipe(U.cfM(e=>eY.VN(n,e)))}),e3=(0,B.XY)(2,(e,t)=>e5(e,e=>U.i4r(U.qIB(e,t),{disableYield:!0}))),e8=(0,B.XY)(3,(e,t,r)=>U.DYE(()=>{let n=t();return e5(e,e=>U.iMI({while:B.ue,body:()=>e,step:e=>{n=r(n,e)}}),()=>U.PyW(n))})),e6=(0,B.XY)(3,(e,t,r)=>U.DYE(()=>{let n=t();return e5(e,e=>U.iMI({while:B.ue,body:(0,B.dY)(e.pipe(U.qIB(e=>r(n,e)),U.TjK(e=>{n=e}))),step:B.Yi}),()=>U.PyW(n))})),e9=(e,t)=>eV(e)(L.Vw(),t),e4="~effect/Sink",e7=U.PyW([void 0]),te={[e4]:{_A:B.D_,_In:B.D_,_L:B.D_,_E:B.D_,_R:B.D_},pipe(){return(0,eo.tT)(this,arguments)}},tt=e=>(0,el.i5)(e,e4),tr=e=>tn((t,r)=>eV(e)(t,r).pipe(U.qIB(U.i4r({disableYield:!0})),ec.m8(U.PyW))),tn=e=>{let t=Object.create(te);return t.transform=e,t},ti=e=>eJ((t,r)=>U.PyW(U.qIB(e.transform(t,r),L.Vw)));U.ZmZ;let ta=tn(e=>ec.m8(U.i4r(e,{disableYield:!0}),()=>e7));K.none,K.isNone,K.none;let ts=e=>tr(e2(U.TjK(e,ti))),to={"~effect/Stream":{_R:B.D_,_E:B.D_,_A:B.D_},pipe(){return(0,eo.tT)(this,arguments)}},tl=e=>(0,el.i5)(e,"~effect/Stream"),tc=e=>{let t=Object.create(to);return t.channel=e,t},tu=e=>e.channel,td=tc(eK),tf=e=>{let t;return tc((t=()=>e().channel,eJ((e,r)=>U.DYE(()=>eV(t())(e,r)))))},th=e=>{let t;return V.ET(e)?tc((t=U.PyW(e),eG(U.OH5(()=>{let e=!1;return U.DYE(()=>e?L.Vw():(e=!0,t))})))):td},tp=e=>tc(e2(U.TjK(e,tu))),tm=(0,B.XY)(2,(e,t)=>tf(()=>{let r=0;return tc(eH(e.channel,V.Tj(e=>t(e,r++))))})),tg=(0,B.XY)(e=>tl(e[0])&&tl(e[1]),(e,t,r)=>tc(e0(tu(e),tu(t),r))),ty=(0,B.XY)(2,(e,t)=>{let r;return r=(e,r)=>U.OH5(()=>{let n,i,a=U.DYE(()=>{if(void 0!==i){let e=i;return i=void 0,U.PyW(e)}return e}).pipe(U.MfU(e=>(n=F.fJ(e),L.Vw()))),s=U.TjK(U.DYE(()=>t.transform(a,r)),([e,t])=>(i=t,V.of(e)));return U.DYE(()=>n||s)}),tc(eJ((t,n)=>U.qIB(e9(e.channel,n),e=>r(e,n))))}),tb=(0,B.XY)(e=>tl(e[0]),(e,t)=>tf(()=>{let r=new TextDecoder(t?.encoding);return tm(e,e=>r.decode(e,{stream:!0}))})),tv=(0,B.XY)(2,(e,t)=>U.Pxi(r=>e9(e.channel,r).pipe(U.qIB(e=>t.transform(e,r)),U.TjK(([e])=>e)))),tw=(0,B.XY)(3,(e,t,r)=>e6(e.channel,t,(e,t)=>{let n=0,i=e;return U.TjK(U.iMI({while:()=>n<t.length,body:()=>r(i,t[n]),step(e){i=e,n++}}),()=>i)})),t_=((e,t)=>e3(e.channel,t),"~effect/platform/FileSystem"),tx=e=>"bigint"==typeof e?e:BigInt(e),tk=Z.kl("effect/platform/FileSystem"),tS="~effect/platform/FileSystem/File",tE=Q();class tI extends Z.kl()("effect/platform/FileSystem/WatchBackend"){}let t$="~effect/platform/Path",tO=Z.kl("effect/Path");var tT=n(3267),tA=n(6400);let tC=Q(),tN=Q(),tM="~effect/ChildProcessSpawner/ChildProcessHandle",tP={[tM]:tM,...tA.os,toJSON(){return{_id:"ChildProcessHandle",pid:this.pid}}},tR=e=>Object.assign(Object.create(tP),e);class tj extends Z.kl()("effect/process/ChildProcessSpawner"){}let tD="~effect/unstable/process/ChildProcess",tL={...tT.b({label:"Command",evaluate(e){return Z.fp(e.context,tj).spawn(this)}}),[tD]:tD},tU=(e,t,r)=>Object.assign(Object.create(tL),{_tag:"StandardCommand",command:e,args:t,options:r}),tF=function(...e){if(tB(e[0])){let[t,...r]=e,n=tq(t,r);return tU(n[0]??"",n.slice(1),{})}if("object"==typeof e[0]&&!Array.isArray(e[0])&&!tB(e[0])){let t=e[0];return function(e,...r){let n=tq(e,r);return tU(n[0]??"",n.slice(1),t)}}if("string"==typeof e[0]&&!Array.isArray(e[1])){let[t,r={}]=e;return tU(t,[],r)}let[t,r=[],n={}]=e;return tU(t,r,n)},tB=e=>Array.isArray(e)&&"raw"in e&&Array.isArray(e.raw),tY=e=>{let t=/^fd(\d+)$/.exec(e);if(null===t)return;let r=parseInt(t[1],10);return r>=3?r:void 0},tW=e=>`fd${e}`,tq=(e,t)=>{let r=[];for(let[n,i]of e.entries())r=tX(e,t,r,i,n);return r},tX=(e,t,r,n,i)=>{let a=e.raw[i];if(void 0===a)throw Error(`Invalid backslash sequence: ${e.raw[i]}`);let{hasLeadingWhitespace:s,hasTrailingWhitespace:o,tokens:l}=tV(n,a),c=tK(r,l,s);if(i===t.length)return c;let u=t[i];return tK(c,Array.isArray(u)?u.map(e=>tJ(e)):[tJ(u)],o)},tJ=e=>"string"==typeof e?e:String(e),tz=new Set([" "," ","\r","\n"]),tG={x:3,u:5},tV=(e,t)=>{if(0===t.length)return{tokens:[],hasLeadingWhitespace:!1,hasTrailingWhitespace:!1};let r=tz.has(t[0]),n=[],i=0;for(let r=0,a=0;r<e.length;r+=1,a+=1){let s=t[a];if(tz.has(s))i!==r&&n.push(e.slice(i,r)),i=r+1;else if("\\"===s){let e=t[a+1];"\n"===e?(r-=1,a+=1):"u"===e&&"{"===t[a+2]?a=t.indexOf("}",a+3):a+=tG[e]??1}}let a=i===e.length;return a||n.push(e.slice(i)),{tokens:n,hasLeadingWhitespace:r,hasTrailingWhitespace:a}},tK=(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)],tH=t("node:child_process"),tQ=t("node:stream"),tZ=(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 ea({_tag:i,module:e,method:t,pathOrDescriptor:n,syscall:r.syscall,cause:r})},t0=e=>tr(eQ(t1(e),e=>[e])),t1=e=>eJ(t=>{let r=e.evaluate();return U.PyW(t2({...e,writable:r,pull:t}))}),t2=e=>e.pull.pipe(U.qIB(t=>{let r=0;return U.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(U.rIH)})}),U.i4r({disableYield:!0}),U.KT6(U.E2r(t=>{let r=r=>t(U.fJG(e.onError(r)));return e.writable.once("error",r),U.OH5(()=>{e.writable.off("error",r)})})),!1!==e.endOnDone?ec.m8(t=>"closed"in e.writable&&e.writable.closed?L.Vw(t):U.E2r(r=>{e.writable.once("finish",()=>r(L.Vw(t))),e.writable.end()})):B.D_);ed.zFM,ed.C6p,ed.D7p,ed.INJ;let t5=ed.mKq;ed.eGS,ed.DKo,ed.$MQ,ed.Iku;let t3=ed.vTQ,t8=ed.zzk;ed.Fbb;let t6="~effect/MutableRef",t9={[t6]:t6,...eu.fU,toJSON(){return{_id:"MutableRef",current:(0,tA.aB)(this.current)}}},t4=e=>tc(t7(e)),t7=e=>eJ((t,r)=>re({scope:r,readable:e.evaluate(),onError:e.onError??rt,chunkSize:e.chunkSize,closeOnDone:e.closeOnDone})),re=e=>{var t;let r,n=e.readable,i=e.closeOnDone??!0,a=e.exit??(t=void 0,(r=Object.create(t9)).current=t,r),s=t8(!1);function o(){s.openUnsafe()}function l(t){a.current=F.fJ(e.onError(t)),s.openUnsafe()}function c(){a.current=F.fJ(L.RS()),s.openUnsafe()}n.on("readable",o),n.once("error",l),n.once("end",c);let u=U.DYE(function t(){let r=e.readable.read(e.chunkSize);if(null===r)return a.current?a.current:n.readableEnded?U.fJG(L.RS()):(s.closeUnsafe(),U.qIB(s.await,t));let i=V.of(r);for(;null!==(r=e.readable.read(e.chunkSize));)i.push(r);return U.PyW(i)});return U.as(eY.U9(e.scope,U.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)};tQ.Readable;let rt=e=>new L.Bk(e),rr=e=>e instanceof globalThis.Error?e:new globalThis.Error(String(e)),rn=(e,t,r)=>{let{commands:n}=rs(r),i=n.reduce((e,t)=>{let r=`${t.command} ${t.args.join(" ")}`;return 0===e.length?r:`${e} | ${r}`},"");return tZ("ChildProcess",e)(t,[i])},ri=U.JkU(function*(){let e,t,r=yield*tk,n=yield*tO,i=U.D9k(function*(e){if(!el.b0(e.cwd))return yield*r.access(e.cwd),n.resolve(e.cwd)}),a=e=>tt(e)?"pipe":e,s=e=>{let t={stream:"pipe",encoding:"utf-8",endOnDone:!0};return el.b0(e.stdin)?t:"string"==typeof e.stdin||tl(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 el.b0(r)?{stream:"pipe"}:"string"==typeof r||tt(r)?{stream:r}:{stream:r.stream}},l=U.D9k(function*(e,t,r){if(0===r.length)return{getInputFd:()=>ta,getOutputFd:()=>td};let n=new Map,i=new Map;for(let{config:a,fd:s}of r){let r=t.stdio[s];switch(a.type){case"input":{let t=ta;r&&"write"in r&&(t=t0({evaluate:()=>r,onError:t=>rn(`fromWritable(fd${s})`,rr(t),e)})),a.stream&&(yield*U.x6Z(tv(a.stream,t))),n.set(s,t);break}case"output":{let t=td;if(r&&"read"in r){let n=new tQ.PassThrough;r.on("error",e=>n.destroy(e)),r.pipe(n),t=t4({evaluate:()=>n,onError:t=>rn(`fromReadable(fd${s})`,rr(t),e)})}a.sink&&(t=ty(t,a.sink)),i.set(s,t)}}}return{getInputFd:e=>n.get(e)??ta,getOutputFd:e=>i.get(e)??td}}),c=(e,t,r)=>"win32"===globalThis.process.platform?U.E2r(r=>{tH.exec(`taskkill /pid ${t.pid} /T /F`,t=>{t?r(U.fJG(rn("kill",rr(t),e))):r(U.rIH)})}):U.SvU({try:()=>{globalThis.process.kill(-t.pid,r)},catch:t=>rn("kill",rr(t),e)}),u=(e,t,r)=>U.DYE(()=>{if(!t.kill(r)){let t=new globalThis.Error("Failed to kill child process");return U.fJG(rn("kill",t,e))}return U.rIH}),d=(e,t,r)=>n=>{let i=r?.killSignal??"SIGTERM";return el.b0(r?.forceKillAfter)?n(t,e,i):U.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=tY(r);if(el.EA(t))return e.getOutputFd(t);return e.stdout}}},h=U.D9k(function*(e){switch(e._tag){case"StandardCommand":{let t,r,n,f,h,p,m,g=s(e.options),y=o(e.options,"stdout"),b=o(e.options,"stderr"),v=(e=>{if(el.b0(e.additionalFds))return[];let t=[];for(let[r,n]of Object.entries(e.additionalFds)){let e=tY(r);el.EA(e)&&t.push({fd:e,config:n})}return t.sort((e,t)=>e.fd-t.fd)})(e.options),w=!0,_=yield*i(e.options),x=(t=e.options).extendEnv?{...globalThis.process.env,...t.env}:t.env,k=((e,t,r,n)=>{let i,s=[tl(i=e.stream)?"pipe":i,a(t.stream),a(r.stream)];if(0===n.length)return s;let o=n.reduce((e,{fd:t})=>Math.max(e,t),2);for(let e=3;e<=o;e++)s[e]="ignore";for(let{fd:e}of n)s[e]="pipe";return s})(g,y,b,v),[S,E]=yield*U.Q56((r={cwd:_,env:x,stdio:k,detached:e.options.detached??"win32"!==process.platform,shell:e.options.shell},U.E2r(t=>{let n=G.LZ(),i=tH.spawn(e.command,e.args,r);return i.on("error",r=>{t(U.fJG(rn("spawn",r,e)))}),i.on("exit",(...e)=>{G.$w(n,F.Py(e))}),i.on("spawn",()=>{t(U.PyW([i,n]))}),U.OH5(()=>{i.kill("SIGTERM")})})),U.D9k(function*([t,r]){let n=yield*G.$L(r),i=d(t,e,e.options);if(n){let[e]=yield*G.Tx(r);return 0!==e&&el.Pe(e)?yield*U.XeO(i(c)):yield*U.rIH}return w?yield*i((e,t,n)=>c(e,t,n).pipe(U.MfU(()=>u(e,t,n)),U.hgn(G.Tx(r)))).pipe(U.XeO):yield*U.rIH})),I=tN(S.pid);S.on("exit",t=>{0!==t&&el.Pe(t)&&((e,t)=>{if("win32"===globalThis.process.platform)return tH.exec(`taskkill /pid ${e.pid} /T /F`,()=>{});try{globalThis.process.kill(-e.pid,t)}catch{}})(S,e.options.killSignal??"SIGTERM")});let $=U.OH5(()=>{w||(S.ref(),w=!0)}),O=U.OH5(()=>(w&&(S.unref(),w=!1),$)),T=yield*U.DYE(()=>{let t=ta;return(el.Pe(S.stdin)&&(t=t0({evaluate:()=>S.stdin,onError:t=>rn("fromWritable(stdin)",rr(t),e),endOnDone:g.endOnDone,encoding:g.encoding})),tl(g.stream))?U.as(U.x6Z(tv(g.stream,t)),t):U.PyW(t)}),{all:A,stderr:C,stdout:N}=(f=S.stdout?(n=new tQ.PassThrough,S.stdout.on("error",e=>n.destroy(e)),S.stdout.pipe(n),t4({evaluate:()=>n,onError:t=>rn("fromReadable(stdout)",rr(t),e)})):td,p=S.stderr?(h=new tQ.PassThrough,S.stderr.on("error",e=>h.destroy(e)),S.stderr.pipe(h),t4({evaluate:()=>h,onError:t=>rn("fromReadable(stderr)",rr(t),e)})):td,tt(y.stream)&&(f=ty(f,y.stream)),tt(b.stream)&&(p=ty(p,b.stream)),m=tg(f,p),{stdout:f,stderr:p,all:m}),{getInputFd:M,getOutputFd:P}=yield*l(e,S,v),R=U.TjK(G.$L(E),e=>!e);return tR({pid:I,exitCode:U.qIB(G.Tx(E),([t,r])=>{if(el.Pe(t))return U.PyW(tC(t));let n=new globalThis.Error(`Process interrupted due to receipt of signal: '${r}'`);return U.fJG(rn("exitCode",n,e))}),isRunning:R,kill:t=>d(S,e,t)((e,t,r)=>c(e,t,r).pipe(U.MfU(()=>u(e,t,r)),U.hgn(G.Tx(E)))).pipe(U.NLW),stdin:T,stdout:N,stderr:C,all:A,getInputFd:M,getOutputFd:P,unref:O})}case"PipedCommand":{let{commands:t,pipeOptions:r}=rs(e),[n,...i]=t,a=[(yield*h(n))];for(let e=0;e<i.length;e++){let t=i[e],n=r[e]??{},o=s(t.options),l=tp(U.PyW(f(a[a.length-1],n.from))),c=n.to??"stdin";if("stdin"===c)a.push((yield*h(tF(t.command,t.args,{...t.options,stdin:{...o,stream:l}}))));else{let e=tY(c);if(el.EA(e)){let r=tW(e),n=t.options.additionalFds??{};a.push((yield*h(tF(t.command,t.args,{...t.options,additionalFds:{...n,[r]:{type:"input",stream:l}}}))))}else a.push((yield*h(tF(t.command,t.args,{...t.options,stdin:{...o,stream:l}}))))}}let o=a[a.length-1],l=U.JkU(function*(){let e=[];for(let t of a)e.push((yield*t.unref));return U.jJl([...e].reverse(),e=>e,{discard:!0})});return tR({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(U.TjK(e=>tb(t?.includeStderr===!0?e.all:e.stdout)),tp),t=(t,r)=>e(t,r).channel.pipe(e1(eJ((e,t)=>U.OH5(()=>{let t="",r=!1,n=K.none(),i=U.DYE(()=>"Some"===n._tag?L.Vw(n.value):ec.tv(e,{onSuccess:a,onFailure:U.ATB,onDone:e=>{if(n=K.some(e),t.length>0||r){let e=t;return t="",r=!1,U.PyW([e])}return L.Vw(e)}}));function a(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 a=e[n];if(0!==a.length){let e=0,n=a.indexOf("\r"),s=a.indexOf("\n");for(r&&(0===s?(i(""),e=1,s=a.indexOf("\n",e)):i(""),r=!1);-1!==n||-1!==s;)-1===n||-1!==s&&s<n?(i(a.substring(e,s)),e=s+1,s=a.indexOf("\n",e)):a.length===n+1?(r=!0,n=-1):(i(a.substring(e,n)),e=n+(s===n+1?2:1),n=a.indexOf("\r",e),s=a.indexOf("\n",e));t+=a.substring(e,a.length-!!r)}}return V.ET(n)?n:null}(e);return null!==n?U.PyW(n):i}return i}))),tc),tj.of({spawn:h,exitCode:e=>U.P1j(U.qIB(h(e),e=>e.exitCode)),streamString:e,streamLines:t,lines:(e,r)=>e8(t(e,r).channel,()=>[],(e,t)=>{for(let r=0;r<t.length;r++)e.push(t[r]);return e}),string:(t,r)=>e8(e(t,r).channel,()=>"",(e,t)=>e+t.join(""))})}),ra=z.QZ(tj,ri),rs=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,...a]=t;return{commands:[i,...a],pipeOptions:r}},ro="~effect/platform/Crypto",rl=Z.kl("effect/Crypto"),rc=e=>e.toString(16).padStart(2,"0"),ru=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,rc).join("")).join("-"),rd=0x1000000000000-1,rf=t("node:crypto"),rh=(s=(j={randomBytes:rf.randomBytes,digest:(e,t)=>U.SvU({try:()=>Uint8Array.from(rf.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=>ea({module:"Crypto",method:"digest",_tag:"Unknown",description:"Could not compute digest",cause:e})})}).randomBytes,o=()=>{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},l=()=>Math.floor(o()*(Number.MAX_SAFE_INTEGER-Number.MIN_SAFE_INTEGER+1))+Number.MIN_SAFE_INTEGER,rl.of({[ro]:ro,randomBytes:e=>{let t,r;return U.TjK((t="randomBytes",Number.isSafeInteger(r=e)&&r>=0?U.PyW(r):U.fJG(es({module:"Crypto",method:t,description:"size must be a non-negative safe integer"}))),s)},nextDoubleUnsafe:o,nextIntUnsafe:l,digest:j.digest,random:U.OH5(()=>o()),randomBoolean:U.OH5(()=>o()>.5),randomInt:U.OH5(()=>l()),randomBetween:(e,t)=>U.OH5(()=>o()*(t-e)+e),randomIntBetween(e,t,r){let n=+(r?.halfOpen!==!0);return U.OH5(()=>{let r=Math.ceil(e),i=Math.floor(t);return Math.floor(o()*(i-r+n))+r})},randomShuffle:e=>U.OH5(()=>{let t=Array.from(e);for(let e=t.length-1;e>=1;e-=1){let r=Math.min(e,Math.floor(o()*(e+1))),n=t[e];t[e]=t[r],t[r]=n}return t}),randomUUIDv4:U.OH5(()=>{let e;return(e=s(16))[6]=15&e[6]|64,e[8]=63&e[8]|128,ru(e)}),randomUUIDv7:U.RKA(e=>{var t,r;let n;return U.PyW((t=e.currentTimeMillisUnsafe(),r=s(16),n=Math.min(Math.max(0,Math.trunc(t)),rd),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,ru(r)))})})),rp=z.Py(rl,rh),rm=t("node:fs"),rg=t("node:os"),ry=t("node:path");var rb=n.t(ry,2);let rv=e=>t=>es({module:"FileSystem",method:e,description:t.message??String(t)}),rw=(c=(0,U._r7)(rm.access,tZ("FileSystem","access"),rv("access")),(e,t)=>{let r=rm.constants.F_OK;return t?.readable&&(r|=rm.constants.R_OK),t?.writable&&(r|=rm.constants.W_OK),c(e,r)}),r_=(u=(0,U._r7)(rm.cp,tZ("FileSystem","copy"),rv("copy")),(e,t,r)=>u(e,t,{force:r?.overwrite??!1,preserveTimestamps:r?.preserveTimestamps??!1,recursive:!0})),rx=(d=(0,U._r7)(rm.copyFile,tZ("FileSystem","copyFile"),rv("copyFile")),(e,t)=>d(e,t)),rk=(f=(0,U._r7)(rm.chmod,tZ("FileSystem","chmod"),rv("chmod")),(e,t)=>f(e,t)),rS=(h=(0,U._r7)(rm.chown,tZ("FileSystem","chown"),rv("chown")),(e,t,r)=>h(e,t,r)),rE=(p=(0,U._r7)(rm.glob,tZ("FileSystem","glob"),rv("glob")),(e,t)=>p(e,{cwd:t?.root,exclude:t?.exclude})),rI=(m=(0,U._r7)(rm.link,tZ("FileSystem","link"),rv("link")),(e,t)=>m(e,t)),r$=(g=(0,U._r7)(rm.mkdir,tZ("FileSystem","makeDirectory"),rv("makeDirectory")),(e,t)=>g(e,{recursive:t?.recursive??!1,mode:t?.mode})),rO=e=>{let t=(0,U._r7)(rm.mkdtemp,tZ("FileSystem",e),rv(e));return e=>U.DYE(()=>{let r=e?.prefix??"",n="string"==typeof e?.directory?ry.join(e.directory,"."):rg.tmpdir();return t(r?ry.join(n,r):n+"/")})},rT=rO("makeTempDirectory"),rA=e=>{let t=(0,U._r7)(rm.rm,tZ("FileSystem",e),rv(e));return(e,r)=>t(e,{recursive:r?.recursive??!1,force:r?.force??!1})},rC=rA("remove"),rN=(y=rO("makeTempDirectoryScoped"),b=rA("makeTempDirectoryScoped"),e=>U.Q56(y(e),e=>U.QgK(b(e,{recursive:!0})))),rM=(D="open",v=(0,U._r7)(rm.open,tZ("FileSystem",D),rv(D)),w=(0,U._r7)(rm.close,tZ("FileSystem",D),rv(D)),(e,t)=>(0,B.Fs)(U.Q56(v(e,t?.flag??"r",t?.mode),e=>U.QgK(w(e))),U.TjK(e=>rP(tE(e),t?.flag?.startsWith("a")??!1)))),rP=(()=>{let e=e=>(0,U._r7)(rm.read,tZ("FileSystem",e),rv(e)),t=e("read"),r=e("readAlloc"),n=(0,U._r7)(rm.fstat,tZ("FileSystem","stat"),rv("stat")),i=(0,U._r7)(rm.ftruncate,tZ("FileSystem","truncate"),rv("truncate")),a=(0,U._r7)(rm.fsync,tZ("FileSystem","sync"),rv("sync")),s=e=>(0,U._r7)(rm.write,tZ("FileSystem",e),rv(e)),o=s("write"),l=s("writeAll");class c{[tS];fd;append;position=BigInt(0);constructor(e,t){this[tS]=tS,this.fd=e,this.append=t}get stat(){return U.TjK(n(this.fd),rW)}get sync(){return a(this.fd)}seek(e,t){let r=tx(e);return U.OH5(()=>("start"===t?this.position=r:"current"===t&&(this.position=this.position+r),this.position))}read(e){return U.DYE(()=>{let r=this.position;return U.TjK(t(this.fd,{buffer:e,position:r}),e=>{let t=tx(e);return this.position=r+t,t})})}readAlloc(e){let t=Number(e);return U.DYE(()=>{let e=Buffer.allocUnsafeSlow(t),n=this.position;return U.TjK(r(this.fd,{buffer:e,position:n}),r=>{if(0===r)return K.none();if(this.position=n+BigInt(r),r===t)return K.some(e);let i=Buffer.allocUnsafeSlow(r);return e.copy(i,0,0,r),K.some(i)})})}truncate(e){return U.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 U.DYE(()=>{let t=this.position;return U.TjK(o(this.fd,e,void 0,void 0,this.append?void 0:Number(t)),e=>{let r=tx(e);return this.append||(this.position=t+r),r})})}writeAllChunk(e){return U.DYE(()=>{let t=this.position;return U.qIB(l(this.fd,e,void 0,void 0,this.append?void 0:Number(t)),r=>0===r?U.fJG(ea({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)):U.rIH))})}writeAll(e){return this.writeAllChunk(e)}}return(e,t)=>new c(e,t)})(),rR=e=>{let t=rO(e);return U.D9k(function*(e){let r=yield*t(e),n=rf.randomBytes(6).toString("hex"),i=ry.join(r,e?.suffix?`${n}${e.suffix}`:n);return yield*rG(i,new Uint8Array(0)),i})},rj=rR("makeTempFile"),rD=(_=rR("makeTempFileScoped"),x=rA("makeTempFileScoped"),e=>U.Q56(_(e),e=>U.QgK(x(ry.dirname(e),{recursive:!0})))),rL=(e,t)=>U.$mh({try:()=>rm.promises.readdir(e,t),catch:t=>tZ("FileSystem","readDirectory")(t,[e])}),rU=e=>U.E2r((t,r)=>{try{rm.readFile(e,{signal:r},(r,n)=>{r?t(U.fJG(tZ("FileSystem","readFile")(r,[e]))):t(U.PyW(n))})}catch(e){t(U.fJG(rv("readFile")(e)))}}),rF=(k=(0,U._r7)(rm.readlink,tZ("FileSystem","readLink"),rv("readLink")),e=>k(e)),rB=(S=(0,U._r7)(rm.realpath,tZ("FileSystem","realPath"),rv("realPath")),e=>S(e)),rY=(E=(0,U._r7)(rm.rename,tZ("FileSystem","rename"),rv("rename")),(e,t)=>E(e,t)),rW=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:K.fromNullishOr(e.mtime),atime:K.fromNullishOr(e.atime),birthtime:K.fromNullishOr(e.birthtime),dev:e.dev,rdev:K.fromNullishOr(e.rdev),ino:K.fromNullishOr(e.ino),mode:e.mode,nlink:K.fromNullishOr(e.nlink),uid:K.fromNullishOr(e.uid),gid:K.fromNullishOr(e.gid),size:tx(e.size),blksize:void 0!==e.blksize?K.some(tx(e.blksize)):K.none(),blocks:K.fromNullishOr(e.blocks)}),rq=(I=(0,U._r7)(rm.stat,tZ("FileSystem","stat"),rv("stat")),e=>U.TjK(I(e),rW)),rX=($=(0,U._r7)(rm.symlink,tZ("FileSystem","symlink"),rv("symlink")),(e,t)=>$(e,t)),rJ=(O=(0,U._r7)(rm.truncate,tZ("FileSystem","truncate"),rv("truncate")),(e,t)=>O(e,void 0!==t?Number(t):void 0)),rz=(T=(0,U._r7)(rm.utimes,tZ("FileSystem","utime"),rv("utime")),(e,t,r)=>T(e,t,r)),rG=(e,t,r)=>U.E2r((n,i)=>{try{rm.writeFile(e,t,{signal:i,flag:r?.flag,mode:r?.mode},t=>{t?n(U.fJG(tZ("FileSystem","writeFile")(t,[e]))):n(U.rIH)})}catch(e){n(U.fJG(rv("writeFile")(e)))}}),rV=U.TjK(U.Nav(tI),e=>{let t;return t={access:rw,chmod:rk,chown:rS,copy:r_,copyFile:rx,glob:rE,link:rI,makeDirectory:r$,makeTempDirectory:rT,makeTempDirectoryScoped:rN,makeTempFile:rj,makeTempFileScoped:rD,open:rM,readDirectory:rL,readFile:rU,readLink:rF,realPath:rB,remove:rC,rename:rY,stat:rq,symlink:rX,truncate:rJ,utimes:rz,watch:t=>rq(t).pipe(U.TjK(r=>e.pipe(K.flatMap(e=>e.register(t,r)),K.getOrElse(()=>{var e;let r;return tc((r=e=>U.Q56(U.OH5(()=>{let r=rm.watch(t,{recursive:!0},(t,r)=>{if(r)switch(t){case"rename":return void U.MY7(U.tvg(rq(r),{onSuccess:t=>ew(e,{_tag:"Create",path:r}),onFailure:t=>ew(e,{_tag:"Remove",path:r})}));case"change":return void e_(e,{_tag:"Update",path:r})}});return r.on("error",r=>{ek(e,L.fJ(ea({module:"FileSystem",_tag:"Unknown",method:"watch",pathOrDescriptor:t,cause:r})))}),r.on("close",()=>{eS(e)}),r}),e=>U.OH5(()=>e.close())),eJ((t,n)=>U.TjK(ev({capacity:e?.bufferSize,strategy:e?.strategy}).pipe(U.Mim(e=>eY.U9(n,eE(e))),U.Mim(e=>U.ar0(eY.Gt(r(e),n),n))),eI))))}))),tp),writeFile:rG},tk.of({...t,[t_]:t_,exists:e=>(0,B.Fs)(t.access(e),U.as(!0),U.KuX("PlatformError",e=>"NotFound"===e.reason._tag?U.PyW(!1):U.fJG(e))),readFileString:(e,r)=>U.qIB(t.readFile(e),e=>U.SvU({try:()=>new TextDecoder(r).decode(e),catch:e=>es({module:"FileSystem",method:"readFileString",description:"invalid encoding",cause:e})})),stream:U.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?tx(r.bytesToRead):void 0,a=BigInt(0),s=tx(r?.chunkSize??65536),o=n.readAlloc(s);return tc(eG(U.PyW(U.qIB(U.DYE(()=>void 0!==i&&i<=a?L.Vw():void 0!==i&&i-a<s?n.readAlloc(i-a):o),K.match({onNone:()=>L.Vw(),onSome:e=>(a+=BigInt(e.length),U.PyW(V.of(e)))})))))},tp),sink:(e,r)=>(0,B.Fs)(t.open(e,{flag:"w",...r}),U.TjK(e=>{let t,r;return t=t=>e.writeAll(t),r=U.jJl(e=>t(e),{discard:!0}),tn(e=>e.pipe(U.qIB(r),U.i4r({disableYield:!0}),ec.m8(()=>e7)))}),ts),writeFileString:(e,r,n)=>U.qIB(U.SvU({try:()=>new TextEncoder().encode(r),catch:e=>es({module:"FileSystem",method:"writeFileString",description:"could not encode string",cause:e})}),r=>t.writeFile(e,r,n))})}),rK=z.QZ(tk)(rV),rH=t("node:url"),rQ=e=>U.SvU({try:()=>rH.fileURLToPath(e),catch:e=>new er({module:"Path",method:"fromFileUrl",cause:e})}),rZ=e=>U.SvU({try:()=>rH.pathToFileURL(e),catch:e=>new er({module:"Path",method:"toFileUrl",cause:e})});ry.posix,ry.win32;let r0=z.Py(tO)({[t$]:t$,...rb,fromFileUrl:rQ,toFileUrl:rZ}),r1="~effect/Stdio",r2=Z.kl(r1),r5=z.Py(r2,{[r1]:r1,...{args:U.OH5(()=>process.argv.slice(2)),stdout:e=>t0({evaluate:()=>process.stdout,onError:e=>ea({module:"Stdio",method:"stdout",_tag:"Unknown",cause:e}),endOnDone:e?.endOnDone??!1}),stderr:e=>t0({evaluate:()=>process.stderr,onError:e=>ea({module:"Stdio",method:"stderr",_tag:"Unknown",cause:e}),endOnDone:e?.endOnDone??!1}),stdin:t4({evaluate:()=>process.stdin,onError:e=>ea({module:"Stdio",method:"stdin",_tag:"Unknown",cause:e}),closeOnDone:!1})}});var r3=n(2302);class r8{waiters=new Set;taken=0;permits;constructor(e){this.permits=e}get free(){return this.permits-this.taken}take(e){let t=ed.DYE(()=>this.free<e?ed.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),ed.OH5(()=>{this.waiters.delete(n)})}):(this.taken+=e,ed.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 eu.R6(t=>ed.PyW(this.updateTakenUnsafe(t,e)))}resize(e){return eu.R6(t=>(this.permits=e,this.free<0||this.updateTakenUnsafe(t,e=>e),ed.rIH))}release(e){return this.updateTaken(t=>t-e)}get releaseAll(){return this.updateTaken(e=>0)}withPermits(e){return t=>ed.FcF(r=>ed.qIB(r(this.take(e)),e=>ed.r7h(r(t),()=>{this.updateTakenUnsafe(ed.Iku(),t=>t-e)},!0)))}withPermit=this.withPermits(1);withPermitsIfAvailable(e){return t=>ed.FcF(r=>this.free<e?ed.lwU:(this.taken+=e,ed.r7h(r(ed.Xx$(t)),()=>{this.updateTakenUnsafe(ed.Iku(),t=>t-e)},!0)))}}let r6={_tag:"Empty"},r9={_tag:"Closed"},r4={_A:B.D_,_E:B.D_};class r7{"~effect/RcRef"=r4;pipe(){return(0,eo.tT)(this,arguments)}state=r6;semaphore=(e=>new r8(e))(1);acquire;context;scope;idleTimeToLive;constructor(e,t,r,n){this.acquire=e,this.context=t,this.scope=r,this.idleTimeToLive=n}}let ne=U.D9k(function*(e){let t=yield*U.FcF(t=>{switch(e.state._tag){case"Closed":return U.GaK;case"Acquired":return e.state.refCount++,e.state.fiber?U.as(t5(e.state.fiber),e.state):U.PyW(e.state);case"Empty":{let r=eY.LZ();return e.semaphore.withPermits(1)(t(U.PpN(e.acquire,Z.WQ(e.context,eY.HG,r))).pipe(U.TjK(t=>{let n={_tag:"Acquired",value:t,scope:r,fiber:void 0,refCount:1,invalidated:!1};return e.state=n,n})))}}}),r=yield*U.z8E,n=void 0!==e.idleTimeToLive&&r3.MI(e.idleTimeToLive);return yield*eY.a6(r,()=>(t.refCount--,t.refCount>0)?U.rIH:void 0===e.idleTimeToLive?(e.state=r6,eY.VN(t.scope,F.rI)):t.invalidated?eY.VN(t.scope,F.rI):n?(t.fiber=U.yy4(e.idleTimeToLive).pipe(U.qIB(()=>"Acquired"===e.state._tag&&0===e.state.refCount?(e.state=r6,eY.VN(t.scope,F.rI)):U.rIH),U.yeE(U.OH5(()=>{t.fiber=void 0})),U.eJC(e.context),t3(e.scope)),U.rIH):U.rIH),t.value});var nt=n(8861);let nr="~effect/platform/Terminal",nn="effect/platform/Terminal/QuitError";class ni extends nt.PSP("QuitError")({_tag:nt.TcI("QuitError")}){[nn]=nn}let na=Z.kl("effect/platform/Terminal"),ns=t("node:readline"),no=U.D9k(function*(e=nc){let t,r,n=process.stdin,i=process.stdout,a=yield*(t={acquire:U.Q56(U.OH5(()=>{let e=ns.createInterface({input:n,escapeCodeTimeout:50});return ns.emitKeypressEvents(n,e),n.isTTY&&n.setRawMode(!0),e}),e=>U.OH5(()=>{n.isTTY&&n.setRawMode(!1),e.close()}))},U.R6R(e=>{let r=e.context,n=Z.Jt(r,eY.HG),i=new r7(t.acquire,r,n,t.idleTimeToLive?r3.bN(t.idleTimeToLive):void 0);return U.as(eY.a6(n,()=>{let e="Acquired"===i.state._tag?eY.VN(i.state.scope,F.rI):U.rIH;return i.state=r9,e}),i)})),s=U.OH5(()=>i.columns??0),o=U.OH5(()=>i.rows??0),l=U.JkU(function*(){yield*ne(a);let t=yield*ev(),r=(r,n)=>{let i={input:K.fromUndefinedOr(r),key:{name:n.name??"",ctrl:!!n.ctrl,meta:!!n.meta,shift:!!n.shift}};e_(t,i),e(i)&&eS(t)};return yield*U.U9h(()=>U.OH5(()=>n.off("keypress",r))),n.on("keypress",r),t});return r={columns:s,rows:o,readInput:l,readLine:U.P1j(U.qIB(ne(a),e=>U.E2r(t=>{let r=e=>t(U.PyW(e));return e.once("line",r),U.OH5(()=>e.off("line",r))}))),display:e=>U.rfi(U.E2r(t=>{i.write(e,e=>el.uy(e)?t(U.rIH):t(U.fJG(es({module:"Terminal",method:"display",description:"Failed to write prompt to stdout",cause:e}))))}))},na.of({...r,[nr]:nr})}),nl=z.QZ(na,no(nc));function nc(e){return e.key.ctrl&&("c"===e.key.name||"d"===e.key.name)}let nu=z.S5(ra,z.Um(rK,rp,r0,r5,nl));var nd=n(5810),nf=n(6030);class nh extends nt.X0d()("CliFilesystemError",{cause:nt.kld(),operation:nt.QfV,path:nt.QfV,message:nt.QfV}){}class np extends nt.X0d()("CliInputError",{code:nt.xCb(["input_read_failed","invalid_json","interactive_stdin"]),message:nt.QfV,hint:nt.QfV}){}class nm extends nt.X0d()("CliValidationError",{message:nt.QfV,hint:nt.QfV,details:nt.O31(nt.QfV)}){}class ng extends nt.X0d()("CliBuildError",{status:nt.QfV,message:nt.QfV,hint:nt.QfV,details:nt.O31(nt.QfV)}){}class ny extends nt.X0d()("CliGenerationError",{code:nt.xCb(["provider_failure","generation_timeout","malformed_output","invalid_generated_document"]),message:nt.QfV,hint:nt.QfV,details:nt.O31(nt.QfV)}){}class nb extends nt.X0d()("CliInteractiveError",{code:nt.xCb(["cancelled","prompt_failed"]),message:nt.QfV,hint:nt.QfV}){}class nv extends nt.X0d()("CliStorageError",{code:nt.xCb(["diagram_not_found","diagram_already_exists","diagram_busy","detached_edit","patch_source_unavailable","patch_conflict","replacement_conflict","restore_conflict","revision_not_found","corrupt_revision","corrupt_record","unsafe_storage_entry","storage_commit_failed"]),diagramId:nt.Qrq(nt.QfV),message:nt.QfV,hint:nt.QfV}){}class nw extends nt.X0d()("CliShareError",{code:nt.xCb(["invalid_share_link","unsupported_scene","share_payload_too_large","share_crypto_failed","share_transport_failed","share_timeout","share_api_changed","share_link_unavailable"]),message:nt.QfV,hint:nt.QfV,details:nt.O31(nt.QfV)}){}class n_ extends nt.X0d()("CliExportError",{code:nt.xCb(["format_unavailable","invalid_destination","render_failed","export_write_failed"]),format:nt.QfV,message:nt.QfV,hint:nt.QfV}){}function nx(e){return"string"==typeof e||"number"==typeof e||"symbol"==typeof e}let nk=nf.ID(),nS=nt._Re(nd.Ky,{errors:"all"}),nE=nt._Re(nd.e5,{errors:"all"});function nI(e){return nm.make({message:"The canonical diagram document is invalid.",hint:'Use {"type":"flowchart","spec":...} or {"type":"mindmap","spec":...}.',details:e})}function n$(e){return nk(e).issues.map(e=>{var t;let r=(e.path??[]).flatMap(e=>{let t=nx(e)?e:null!==e&&"object"==typeof e&&"key"in e&&nx(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 nO=U.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*nS(t.spec).pipe(U.xm_(e=>nI(n$(e.issue))))}:"mindmap"===t.type?{type:"mindmap",spec:yield*nE(t.spec).pipe(U.xm_(e=>nI(n$(e.issue))))}:yield*nI(['document.type: Expected "flowchart" or "mindmap".']):yield*nI(["document: Expected an object with type and spec."])}),nT=U.fn("sketchi.cli.document.parseJson")(function*(e){let t=yield*U.SvU({try:()=>JSON.parse(e),catch:()=>np.make({code:"invalid_json",message:"The input is not valid JSON.",hint:"Pass one complete canonical document object."})});return yield*nO(t)});function nA(e){return`${JSON.stringify(e,null,2)}
3
- `}function nC(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 nN(e){return/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/.test(e)?U.PyW(e):U.fJG(nm.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 nM extends Z.kl()("@sketchi/cli/DiagramBuilder"){}function nP(e){let t=e.ref?.path?` (${e.ref.path})`:"";return`${e.code}${t}: ${e.message}`}function nR(e,t){let r=e.formats.find(e=>e.format===t);return r?.inline!==void 0?U.PyW(r.inline):U.fJG(ng.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 nj(e){let t=nd.Uh.safeParse(e);return t.success?U.PyW(t.data):U.fJG(ng.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 nD(e){let t=nd.yE.safeParse(e);return t.success?U.PyW(t.data):U.fJG(ng.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 nL=z.QZ(nM,U.JkU(function*(){let e=yield*nd.Ov,t=yield*nd.UA;return{build:U.fn("sketchi.cli.diagram.build")(function*(r){let n;if(!(n="flowchart"===r.type?yield*(0,nd.XV)({spec:r.spec,options:{artifactFormats:["scene","excalidraw"],inlineArtifacts:["scene","excalidraw"]}}).pipe(U.PfK(nd.Ov,e),U.PfK(nd.UA,t)):yield*(0,nd.r8)({spec:r.spec,options:{artifactFormats:["scene","excalidraw"],inlineArtifacts:["scene","excalidraw"]}}).pipe(U.PfK(nd.Ov,e),U.PfK(nd.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(nP),"invalid_input"===n.status||"invalid_flowchart"===n.status||"invalid_mindmap"===n.status||"quality_failed"===n.status?nm.make({message:t,hint:r,details:i}):"storage_failed"===n.status?nv.make({code:"storage_commit_failed",message:t,hint:r}):ng.make({status:n.status,message:t,hint:r,details:i}))}let i=yield*nN(nC(r)),a=yield*nR(n.artifact,"scene").pipe(U.qIB(nj)),s=yield*nR(n.artifact,"excalidraw").pipe(U.qIB(nD));return{id:i,type:r.type,title:r.spec.title,document:r,scene:a,excalidraw:s}})}})),nU=1,nF="manifest.json",nB="document.json",nY="scene.json",nW="diagram.excalidraw",nq="diagram.png",nX="revisions";class nJ extends nt.Xsx("DiagramRecordManifest")({schemaVersion:nt.uSQ(nU),id:nt.QfV,type:nt.xCb(["flowchart","mindmap"]),title:nt.QfV,revision:nt.Aiz.check(nt.yJO(0)),authority:nt.xCb(["canonical","patched","detached"]).pipe(nt.E$i(U.PyW("canonical"))),formats:nt.O31(nt.xCb(["scene","excalidraw","png"]))}){}function nz(e){return{id:e.manifest.id,type:e.manifest.type,title:e.manifest.title,revision:e.manifest.revision,formats:e.manifest.formats,authority:e.authority,documentAuthoritative:e.documentAuthoritative}}function nG(e){return String(e).padStart(6,"0")}class nV extends nt.X0d()("HeadlessPngRenderError",{cause:nt.kld(),message:nt.QfV}){}class nK extends Z.kl()("@sketchi/cli/CliPngRenderer"){}let nH=z.Py(nK,{renderPng:function(e){return U.$mh({try:async()=>(await Promise.all([n.e(831),n.e(869)]).then(n.bind(n,7665))).renderPngBytes(e),catch:e=>nV.make({cause:e,message:"Unable to render the stored Excalidraw artifact as PNG."})})},normalizeExcalidraw:function(e){return U.$mh({try:async()=>(await Promise.all([n.e(831),n.e(869)]).then(n.bind(n,7665))).normalizeExcalidrawArtifact(e),catch:e=>nV.make({cause:e,message:"Unable to restore the Excalidraw share artifact."})})}}),nQ=t("node:zlib");var nZ=n(3587);let n0=t("node:fs/promises");class n1 extends Z.kl()("@sketchi/cli/LocalFileSystem"){}function n2(e,t,r){return nh.make({cause:r,operation:e,path:t,message:`Filesystem ${e} failed for ${t}.`})}function n5(e,t){return"object"==typeof e&&null!==e&&"code"in e&&e.code===t}let n3=z.Py(n1,{makeDirectory:(e,t=!1)=>U.$mh({try:()=>(0,n0.mkdir)(e,{recursive:t}).then(()=>void 0),catch:t=>n2("make-directory",e,t)}),tryWriteText:(e,t)=>U.$mh({try:async()=>{try{let r=await (0,n0.open)(e,rm.constants.O_WRONLY|rm.constants.O_CREAT|rm.constants.O_EXCL|rm.constants.O_NOFOLLOW,384);try{await r.writeFile(t,{encoding:"utf8"}),await r.sync()}finally{await r.close()}return!0}catch(e){if(n5(e,"EEXIST"))return!1;throw e}},catch:t=>n2("write-exclusive",e,t)}),tryLinkFile:(e,t)=>U.$mh({try:async()=>{try{return await (0,n0.link)(e,t),!0}catch(e){if(n5(e,"EEXIST")||n5(e,"ENOENT"))return!1;throw e}},catch:r=>n2("link-exclusive",`${e} -> ${t}`,r)}),makeTempDirectory:(e,t)=>U.$mh({try:()=>(0,n0.mkdtemp)((0,ry.join)(e,t)),catch:t=>n2("make-temp-directory",e,t)}),list:e=>U.$mh({try:async()=>(await (0,n0.readdir)(e,{withFileTypes:!0})).map(e=>({name:e.name,kind:e.isFile()?"file":e.isDirectory()?"directory":e.isSymbolicLink()?"symbolic-link":"other"})),catch:t=>n2("read-directory",e,t)}),kind:e=>U.$mh({try:async()=>{try{let t=await (0,n0.lstat)(e);if(t.isFile())return"file";if(t.isDirectory())return"directory";if(t.isSymbolicLink())return"symbolic-link";return"other"}catch(e){if(n5(e,"ENOENT"))return"missing";if(n5(e,"ELOOP"))return"symbolic-link";throw e}},catch:t=>n2("stat",e,t)}),realPath:e=>U.$mh({try:()=>(0,n0.realpath)(e),catch:t=>n2("resolve",e,t)}),readText:e=>U.$mh({try:async()=>{let t=await (0,n0.open)(e,rm.constants.O_RDONLY|rm.constants.O_NOFOLLOW);try{return await t.readFile({encoding:"utf8"})}finally{await t.close()}},catch:t=>n2("read",e,t)}),readBytes:e=>U.$mh({try:async()=>{let t=await (0,n0.open)(e,rm.constants.O_RDONLY|rm.constants.O_NOFOLLOW);try{return new Uint8Array(await t.readFile())}finally{await t.close()}},catch:t=>n2("read",e,t)}),writeText:(e,t,r=!1)=>U.$mh({try:async()=>{let n=rm.constants.O_WRONLY|rm.constants.O_CREAT|rm.constants.O_NOFOLLOW|(r?rm.constants.O_TRUNC:rm.constants.O_EXCL),i=await (0,n0.open)(e,n,384);try{await i.writeFile(t,{encoding:"utf8"}),await i.sync()}finally{await i.close()}},catch:t=>n2("write",e,t)}),writeBytes:(e,t,r=!1)=>U.$mh({try:async()=>{let n=rm.constants.O_WRONLY|rm.constants.O_CREAT|rm.constants.O_NOFOLLOW|(r?rm.constants.O_TRUNC:rm.constants.O_EXCL),i=await (0,n0.open)(e,n,384);try{await i.writeFile(t),await i.sync()}finally{await i.close()}},catch:t=>n2("write",e,t)}),rename:(e,t)=>U.$mh({try:()=>(0,n0.rename)(e,t),catch:r=>n2("rename",`${e} -> ${t}`,r)}),tryRenameDirectory:(e,t)=>U.$mh({try:async()=>{try{return await (0,n0.rename)(e,t),!0}catch(e){if(n5(e,"EEXIST")||n5(e,"ENOTEMPTY"))return!1;if(n5(e,"EPERM"))try{if((await (0,n0.lstat)(t)).isDirectory())return!1}catch{}throw e}},catch:r=>n2("rename-exclusive-directory",`${e} -> ${t}`,r)}),removeFile:e=>U.$mh({try:async()=>{try{return await (0,n0.unlink)(e),!0}catch(e){if(n5(e,"ENOENT"))return!1;throw e}},catch:t=>n2("remove-file",e,t)}),remove:e=>U.$mh({try:()=>(0,n0.rm)(e,{recursive:!0,force:!0}),catch:t=>n2("remove",e,t)})});var n8=n(8689),n6=n(5030);let n9="https://json.excalidraw.com/api/v2/",n4=["rectangle","ellipse","diamond","arrow","line","freedraw","text"],n7=new Set(n4),ie=new TextEncoder,it=new TextDecoder("utf-8",{fatal:!0}),ir=ie.encode(JSON.stringify({version:2,compression:"pako@1",encryption:"AES-GCM"}));function ii(e,t,r,n=[]){return nw.make({code:e,message:t,hint:r,details:n})}function ia(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function is(e){return"number"==typeof e&&Number.isFinite(e)}function io(e,t,r){new DataView(e.buffer,e.byteOffset,e.byteLength).setUint32(t,r)}function il(e,t){if(t+4>e.byteLength)throw Error("truncated chunk header");return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(t)}function ic(e,t){if(e.byteLength<4+4*t||1!==il(e,0))throw Error("unsupported chunk format");let r=[],n=4;for(let i=0;i<t;i+=1){let t=il(e,n),i=(n+=4)+t;if(i>e.byteLength)throw Error("truncated chunk");r.push(e.subarray(n,i)),n=i}if(n!==e.byteLength)throw Error("unexpected trailing chunk");return r}function iu(e){if(!/^[A-Za-z0-9_-]{22}$/.test(e))throw Error("invalid AES key encoding");let t=Buffer.from(e,"base64url");if(16!==t.byteLength)throw Error("invalid AES key length");return t}function id(e,t){return crypto.subtle.importKey("raw",Uint8Array.from(iu(e)),{name:"AES-GCM",length:128},!1,[t])}function ih(e){if(!ia(e)||"excalidraw"!==e.type||!is(e.version)||"string"!=typeof e.source||!Array.isArray(e.elements)||!ia(e.appState)||!(void 0===e.files||ia(e.files)))throw Error("invalid Excalidraw artifact shape");return{type:e.type,version:e.version,source:e.source,elements:e.elements,appState:e.appState,files:e.files??{}}}function ip(e,t){return"string"!=typeof e||!t.has(e)}function im(e,t){if("number"==typeof e)return Number.isFinite(e)?void 0:`${t} must be finite`;if(Array.isArray(e))for(let r of e){let e=im(r,`${t} item`);if(e)return e}else if(ia(e))for(let r of Object.values(e)){let e=im(r,`${t} property`);if(e)return e}}function ig(e){return U.SvU({try:()=>{let t=ih(e);if(ia(e)&&"libraryItems"in e)throw Error("Excalidraw library state is unsupported");if(t.elements.length>1e4)throw Error("element count exceeds 10000");if(Object.keys(t.files).length>0)throw Error("binary files are unsupported");let r=new Set;for(let[e,n]of t.elements.entries()){if(!ia(n)||"string"!=typeof n.id)throw Error(`elements[${String(e)}].id is invalid`);if(r.has(n.id))throw Error(`elements[${String(e)}].id is duplicated`);r.add(n.id)}for(let[e,n]of t.elements.entries()){let t=function(e,t,r){let n=`elements[${String(t)}]`;if(!ia(e)||"string"!=typeof e.id||0===e.id.length||"string"!=typeof e.type)return`elements[${String(t)}] is not an Excalidraw element`;if(!n7.has(e.type))return`${n}.type is unsupported`;if("link"in e&&null!==e.link&&void 0!==e.link||"fileId"in e)return`${n} contains an external resource`;let i=im(e,n);if(i)return i;for(let t of["x","y","width","height","angle"])if(!is(e[t]))return`${n}.${t} must be finite`;if("text"===e.type){if(5!==e.fontFamily)return`${n}.fontFamily must be ${String(5)}`;if("string"!=typeof e.text)return`${n}.text is invalid`}if(["arrow","line","freedraw"].includes(e.type)&&(!Array.isArray(e.points)||e.points.some(e=>!Array.isArray(e)||e.length<2||!is(e[0])||!is(e[1]))))return`${n}.points contains invalid geometry`;for(let t of["containerId","frameId"])if(null!==e[t]&&void 0!==e[t]&&ip(e[t],r))return`${n}.${t} is an invalid element reference`;for(let t of["startBinding","endBinding"]){let i=e[t];if(null!=i&&(!ia(i)||ip(i.elementId,r)))return`${n}.${t} is an invalid element binding`}let a=e.boundElements;if(null!=a&&(!Array.isArray(a)||a.some(e=>!ia(e)||ip(e.id,r))))return`${n}.boundElements contains an invalid element reference`}(n,e,r);if(t)throw Error(t)}let n=(0,n6.Gd)(t.elements);if(n)throw Error(n);let i=function(e){if("viewBackgroundColor"in e&&"string"!=typeof e.viewBackgroundColor)return"appState.viewBackgroundColor must be a string";if("gridModeEnabled"in e&&"boolean"!=typeof e.gridModeEnabled)return"appState.gridModeEnabled must be boolean";for(let t of["gridSize","gridStep"])if(t in e&&null!==e[t]&&!is(e[t]))return`appState.${t} must be finite or null`;if("lockedMultiSelections"in e){let t=e.lockedMultiSelections;if(!ia(t))return"appState.lockedMultiSelections must be an object";for(let[e,r]of Object.entries(t))if(0===e.length||!0!==r)return"appState.lockedMultiSelections contains an invalid lock entry"}return im(e,"appState")}(t.appState);if(i)throw Error(i);return e},catch:e=>ii("unsupported_scene","The Excalidraw scene is unsupported by share/pull v1.",`Use only ${n4.join(", ")} elements, Excalifont fontFamily ${String(5)}, and no files or images.`,[e instanceof Error?e.message:"invalid scene"])})}function iy(e){let t=new Uint8Array(4);return io(t,0,e),t}class ib extends Z.kl()("@sketchi/cli/StorageRoot"){}function iv(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}let iw=[[0,0,8,8],[4,0,8,8],[0,4,4,8],[2,0,4,4],[0,2,2,4],[1,0,2,2],[0,1,1,2]];function i_(e,t,r){return e<=t?0:Math.ceil((e-t)/r)}function ix(e){let t,r,n,i,a,s=[137,80,78,71,13,10,26,10];if(e.byteLength<33||s.some((t,r)=>e[r]!==t))return!1;let o=s.length,l=0,c=!1,u=!1,d=!1,f=[];for(;o+12<=e.byteLength;){let s=iv(e,o),h=o+12+s;if(h>e.byteLength)break;let p=o+4,m=e.subarray(p,p+4),g=e=>e>=65&&e<=90||e>=97&&e<=122;if(4!==m.byteLength||!m.every(g)||(32&m[2])!=0)break;let y=String.fromCharCode(...m);if(0===l&&("IHDR"!==y||13!==s))break;if("IHDR"===y){if(0!==l||13!==s)return!1;t=iv(e,o+8),r=iv(e,o+12),i=e[o+16],n=e[o+17],a=e[o+20];let c={0:[1,2,4,8,16],2:[8,16],3:[1,2,4,8],4:[8,16],6:[8,16]};if(0===t||0===r||t>0x7fffffff||r>0x7fffffff||void 0===n||void 0===i||!c[n]?.includes(i)||0!==e[o+18]||0!==e[o+19]||![0,1].includes(a??-1))break}else if("PLTE"===y){if(c||u||0===s||s%3!=0||s>768||0===n||4===n||3===n&&void 0!==i&&s/3>2**i)return!1;c=!0}else if("IDAT"===y){if(d||3===n&&!c)return!1;u=!0,f.push(e.subarray(o+8,o+8+s))}else if("IEND"===y){if(0!==s||!u||3===n&&!c)break}else{u&&(d=!0);let t=e[p];if(void 0===t||(32&t)==0)break}let b=iv(e,o+8+s);if(function(e){let t=0xffffffff;for(let r of e){t^=r;for(let e=0;e<8;e+=1)t=t>>>1^(1&t?0xedb88320:0)}return(0xffffffff^t)>>>0}(e.subarray(p,o+8+s))!==b)break;if(o=h,l+=1,"IEND"===y)return o===e.byteLength&&void 0!==t&&void 0!==r&&void 0!==i&&void 0!==n&&void 0!==a&&function(e,t,r,n,i,a){let s={0:1,2:3,3:1,4:2,6:4}[i];if(void 0===s)return!1;let o=function(e,t,r,n){let i=[],a=0;for(let[s,o,l,c]of 0===n?[[0,0,1,1]]:iw){let n=i_(e,s,l),u=i_(t,o,c);if(0===n||0===u)continue;let d=Math.ceil(n*r/8)+1;if(d>0x1000000-a||u>Math.floor((0x1000000-a)/d))return null;a+=u*d,i.push({rows:u,rowBytes:d})}return i}(t,r,s*n,a);if(null===o)return!1;let l=o.reduce((e,t)=>e+t.rows*t.rowBytes,0);try{let t=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}(e),r=(0,nQ.inflateSync)(t,{info:!0,maxOutputLength:0x1000000});if(r.engine.bytesWritten!==t.byteLength)return!1;let n=r.buffer;if(n.byteLength!==l)return!1;let i=0;for(let e of o)for(let t=0;t<e.rows;t+=1){if((n[i]??5)>4)return!1;i+=e.rowBytes}return i===n.byteLength}catch{return!1}}(f,t,r,i,n,a)}return!1}class ik extends Z.kl()("@sketchi/cli/DiagramStore"){}let iS=".locks",iE="free.",iI="owner.",i$=".owner-candidate.",iO=".json",iT="recovery",iA=".backup.",iC=`.stage.${String(process.pid)}.`,iN=nZ.ji("10 millis").pipe(nZ.jB({times:50})),iM=z.Py(ib,{path:(0,ry.join)((0,rg.homedir)(),".sketchi","diagrams")});function iP(e,t,r,n){return nv.make({code:e,message:t,hint:r,...n?{diagramId:n}:{}})}function iR(e){return Buffer.from(e,"utf8").toString("base64url")}function ij(e,t){return e<t?-1:+(e>t)}function iD(e,t){let r=e.replace(/(?:\/|\.json)$/u,"").replace(/^0+/u,""),n=t.replace(/(?:\/|\.json)$/u,"").replace(/^0+/u,""),i=r.length-n.length;return 0!==i?i:ij(r,n)||ij(e,t)}function iL(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 iU(e,t){return"object"==typeof e.cause&&null!==e.cause&&"code"in e.cause&&e.cause.code===t}function iF(e,t){return(0,ry.join)(e,t)}function iB(e){switch(e){case"scene":return nY;case"excalidraw":return nW;case"png":return nq}}function iY(e,t){return iP("unsafe_storage_entry",`Unsafe local storage entry at ${e}.`,"Replace symbolic links or special files with ordinary Sketchi record files.",t)}let iW=z.QZ(ik,U.JkU(function*(){let e=yield*n1,t=yield*ib,r=U.fn("sketchi.cli.storage.ensureOwnedDirectory")(function*(t){let r=yield*e.kind(t);if("missing"===r&&(yield*e.makeDirectory(t).pipe(U.MfU(e=>iU(e,"EEXIST")?U.rIH:U.fJG(e))),r=yield*e.kind(t)),"directory"!==r)return yield*iY(t)}),n=U.fn("sketchi.cli.storage.ensureRoot")(function*(){yield*r((0,ry.dirname)(t.path)),yield*r(t.path),yield*r((0,ry.join)(t.path,iS))}),i=U.fn("sketchi.cli.storage.assertSafeTree")(function*(t,r){for(let n of yield*e.list(t)){let e=(0,ry.join)(t,n.name);if("symbolic-link"===n.kind||"other"===n.kind)return yield*iY(e,r);"directory"===n.kind&&(yield*i(e,r))}}),a=U.fn("sketchi.cli.storage.recoverStages")(function*(){for(let r of(yield*n(),[...yield*e.list(t.path)].sort((e,t)=>ij(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&&iL(n)||(yield*e.remove((0,ry.join)(t.path,r.name)))}}),s=U.fn("sketchi.cli.storage.recoverRecordTransactions")(function*(r){yield*n(),yield*a();let i=`${iA}${iR(r)}.`;for(let n of[...yield*e.list(t.path)].filter(e=>e.name.startsWith(i)).sort((e,t)=>ij(e.name,t.name))){let i=(0,ry.join)(t.path,n.name),a=iF(t.path,r);"missing"===(yield*e.kind(a))?yield*e.rename(i,a):yield*e.remove(i)}}),o=U.fn("sketchi.cli.storage.initializeLockDirectory")(function*(r){let n=(0,ry.join)(t.path,iS,`${iR(r)}.lock`),i=yield*e.kind(n);if("directory"===i)return n;if("missing"!==i)return yield*iY(n,r);let a=(0,ry.join)(t.path,iS);return yield*U.jGc(e.makeTempDirectory(a,`.init.${iR(r)}.`),t=>U.JkU(function*(){let i=crypto.randomUUID();return(yield*e.writeText((0,ry.join)(t,`${iE}${i}${iO}`),nA({token:i})),(yield*e.tryRenameDirectory(t,n))||"directory"===(yield*e.kind(n)))?n:yield*iY(n,r)}),t=>e.remove(t))}),l=e=>iP("diagram_busy",`Diagram "${e}" is being changed by another Sketchi process.`,"Wait for that command to finish, then retry.",e),c=U.fn("sketchi.cli.storage.readLockEntries")(function*(t,r){let n=[...yield*e.list(t)].sort((e,t)=>ij(e.name,t.name)),i=[];for(let a of n){let n=(0,ry.join)(t,a.name);if("file"!==a.kind)return yield*iY(n,r);let s=function(e){if(!e.startsWith(iE)||!e.endsWith(iO))return;let t=e.slice(iE.length,-iO.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}:{}}}(a.name);if(s){i.push({name:a.name,path:n,state:"free",token:s.token,...s.releasedOwnerToken?{releasedOwnerToken:s.releasedOwnerToken}:{}});continue}if(a.name.startsWith(iE))return yield*iY(n,r);let o=function(e){if(!e.startsWith(i$)||!e.endsWith(iO))return;let t=e.slice(i$.length,-iO.length);return/^[a-zA-Z0-9_-]+$/.test(t)?t:void 0}(a.name);if(o){i.push({name:a.name,path:n,state:"unpublished-owner",token:o});continue}if(a.name.startsWith(i$)||!a.name.startsWith(iI)||!a.name.endsWith(iO))return yield*iY(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(U.xm_(e=>iU(e,"ENOENT")?l(r):e))));if(!c)return yield*l(r);if(a.name!==`${iI}${c.token}${iO}`)return yield*iY(n,r);i.push({name:a.name,path:n,token:c.token,state:iL(c.pid)?"live-owner":"stale-owner"})}return i}),u=U.fn("sketchi.cli.storage.acquireLockOnce")(function*(t){yield*n();let r=yield*o(t),i=yield*c(r,t),a=new Set(i.flatMap(e=>e.releasedOwnerToken?[e.releasedOwnerToken]:[]));if(i.some(e=>"live-owner"===e.state&&!a.has(e.token)))return yield*l(t);let s=i.find(e=>"free"===e.state)??i.find(e=>"stale-owner"===e.state);if(!s){let n=(0,ry.join)(r,`${iE}${iT}${iO}`);if(!(yield*e.tryWriteText(n,nA({token:iT}))))return yield*l(t);s={name:`${iE}${iT}${iO}`,path:n,state:"free",token:iT}}let u=crypto.randomUUID(),d=(0,ry.join)(r,`${iI}${u}${iO}`),f=(0,ry.join)(r,`${i$}${u}${iO}`);return yield*U.rfi(U.jGc(U.PyW(f),()=>U.JkU(function*(){if(yield*e.writeText(f,nA({pid:process.pid,token:u})),!(yield*e.tryLinkFile(f,d)))return yield*l(t);if(!(yield*e.removeFile(s.path).pipe(U.MfU(t=>e.removeFile(d).pipe(U.hgn(U.fJG(t)))))))return yield*e.removeFile(d),yield*l(t);for(let t of i)t.path!==s.path&&(yield*e.removeFile(t.path).pipe(U.MfU(()=>U.rIH)));return{directory:r,ownerPath:d,token:u}}),t=>e.removeFile(t).pipe(U.MfU(()=>U.rIH))))}),d=U.fn("sketchi.cli.storage.releaseLock")(function*(t,r){let n=crypto.randomUUID(),i=(0,ry.join)(r.directory,`${iE}${n}.${r.token}${iO}`),a=nA({token:n,releasedOwnerToken:r.token});if(!(yield*e.writeText(i,a).pipe(U.as(!0),U.MfU(()=>e.tryWriteText(i,a).pipe(U.qIB(t=>t?U.PyW(!0):e.kind(i).pipe(U.TjK(e=>"file"===e))),U.MfU(()=>U.PyW(!1))))))){if(yield*e.removeFile(r.ownerPath))return;return yield*iP("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(U.YWq({onFailure:()=>!0,onSuccess:e=>e}))))return yield*e.removeFile(i).pipe(U.MfU(()=>U.rIH)),yield*iP("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 U.jGc((n=u(e),r?n.pipe(U.L5P({schedule:iN,while:e=>"CliStorageError"===e._tag&&"diagram_busy"===e.code})):n),()=>s(e).pipe(U.hgn(t)),t=>d(e,t).pipe(U.MfU(()=>U.rIH)))},h=U.fn("sketchi.cli.storage.decodeManifest")(function*(t,r){let n=yield*e.readText(t),i=yield*U.SvU({try:()=>JSON.parse(n),catch:()=>iP("corrupt_record",`Diagram "${r}" has an invalid manifest.`,"Inspect manifest.json and restore it from a known-good backup.",r)});return yield*nt._Re(nJ)(i).pipe(U.xm_(()=>iP("corrupt_record",`Diagram "${r}" has an incompatible manifest.`,`Expected manifest schema version ${String(1)}.`,r)))}),p=U.fn("sketchi.cli.storage.decodeDocument")(function*(t,r){let n=yield*e.readText(t),i=yield*U.SvU({try:()=>JSON.parse(n),catch:()=>iP("corrupt_record",`Diagram "${r}" has invalid document JSON.`,"Recover a prior canonical document from the revisions directory.",r)});return yield*nO(i).pipe(U.xm_(()=>iP("corrupt_record",`Diagram "${r}" has an invalid canonical document.`,"Recover a prior canonical document from the revisions directory.",r)))}),m=U.fn("sketchi.cli.storage.loadUnlocked")(function*(r){let n=iF(t.path,r),a=yield*e.kind(n);if("missing"===a)return yield*iP("diagram_not_found",`Diagram "${r}" does not exist.`,"Run sketchi list to discover stored diagram ids.",r);if("directory"!==a)return yield*iY(n,r);yield*i(n,r);let s=yield*h((0,ry.join)(n,nF),r);if(s.id!==r)return yield*iP("corrupt_record",`Diagram directory "${r}" contains manifest id "${s.id}".`,"Make the directory name and manifest id agree before retrying.",r);let o=yield*p((0,ry.join)(n,nB),r);if(s.type!==o.type||s.title!==o.spec.title)return yield*iP("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[nY,nW])if((yield*e.kind((0,ry.join)(n,t)))!=="file")return yield*iP("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,ry.join)(n,nq));if("file"!==l&&"missing"!==l)return yield*iY((0,ry.join)(n,nq),r);if("file"===l&&!ix((yield*e.readBytes((0,ry.join)(n,nq)))))return yield*iP("corrupt_record",`Diagram "${r}" has an invalid stored PNG artifact.`,"Recover a valid prior revision or rebuild the record.",r);let c="detached"===s.authority?"file"===l?["excalidraw","png"]:["excalidraw"]:"file"===l?["scene","excalidraw","png"]:["scene","excalidraw"];if(s.formats.length!==c.length||s.formats.some((e,t)=>e!==c[t]))return yield*iP("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,ry.join)(n,nX),d=[];for(let t of yield*e.list(u)){if("file"===t.kind&&/^\d{6,}\.json$/u.test(t.name)){d.push(t.name);continue}if("directory"===t.kind&&/^\d{6,}$/u.test(t.name)){d.push(`${t.name}/`);continue}return yield*iY((0,ry.join)(u,t.name),r)}return d.sort(iD),{manifest:s,document:o,revisions:d,authority:s.authority,documentAuthoritative:"canonical"===s.authority}}),g=U.fn("sketchi.cli.storage.copySafeTree")(function*(t,r,n){for(let i of yield*e.list(t)){let a=(0,ry.join)(t,i.name),s=(0,ry.join)(r,i.name);if("directory"===i.kind)yield*e.makeDirectory(s),yield*g(a,s,n);else{if("file"!==i.kind)return yield*iY(a,n);let t=yield*e.readBytes(a);yield*e.writeBytes(s,t)}}}),y=U.fn("sketchi.cli.storage.copyRecordSnapshot")(function*(t,r,n){for(let i of(yield*e.makeDirectory(r),yield*e.list(t))){if(i.name===nX)continue;let a=(0,ry.join)(t,i.name),s=(0,ry.join)(r,i.name);if("file"!==i.kind)return yield*iY(a,n);yield*e.writeBytes(s,(yield*e.readBytes(a)))}}),b=U.fn("sketchi.cli.storage.commitStage")(function*(r,n){let i=iF(t.path,r),a=(0,ry.join)(t.path,`${iA}${iR(r)}.${String(process.pid)}.${crypto.randomUUID()}`);yield*e.rename(i,a),(yield*e.rename(n,i).pipe(U.tvg({onFailure:t=>e.rename(a,i).pipe(U.tvg({onFailure:()=>U.fJG(iP("storage_commit_failed",`Atomic storage commit and rollback both failed for "${r}".`,"Retry; Sketchi will recover the backup transaction before the next operation.",r)),onSuccess:()=>U.fJG(t)})),onSuccess:()=>U.PyW(!0)})))&&(yield*e.remove(a).pipe(U.MfU(()=>U.rIH)))}),v=U.fn("sketchi.cli.storage.snapshotCurrent")(function*(r,n,i){let a=(0,ry.join)(n,nX,nG(i));if((yield*e.kind(a))!=="missing")return yield*iP("corrupt_record",`Diagram "${r}" already has a snapshot for current revision ${String(i)}.`,"Inspect the revisions directory before retrying.",r);yield*y(iF(t.path,r),a,r)}),w=U.fn("sketchi.cli.storage.writeBuilt")(function*(t,r,n){yield*e.makeDirectory((0,ry.join)(t,nX),!0),yield*e.writeText((0,ry.join)(t,nB),nA(r.document),!0),yield*e.writeText((0,ry.join)(t,nY),nA(r.scene),!0),yield*e.writeText((0,ry.join)(t,nW),nA(r.excalidraw),!0);let i=(0,ry.join)(t,nq);yield*e.remove(i),r.png&&(yield*e.writeBytes(i,r.png)),yield*e.writeText((0,ry.join)(t,nF),nA(n),!0)}),_=U.fn("sketchi.cli.storage.create")(function*(r){return yield*f(r.id,U.JkU(function*(){let n=iF(t.path,r.id);if((yield*e.kind(n))!=="missing")return yield*iP("diagram_already_exists",`Diagram "${r.id}" already exists.`,"Use sketchi edit for full-document replacement.",r.id);let i=nJ.make({schemaVersion:1,id:r.id,type:r.type,title:r.title,revision:1,authority:"canonical",formats:r.png?["scene","excalidraw","png"]:["scene","excalidraw"]});return yield*U.jGc(e.makeTempDirectory(t.path,iC),t=>U.JkU(function*(){return yield*w(t,r,i),yield*e.rename(t,n),{manifest:i,document:r.document,revisions:[],authority:"canonical",documentAuthoritative:!0}}),t=>e.remove(t))}))}),x=U.fn("sketchi.cli.storage.edit")(function*(r,n){return yield*f(r,U.JkU(function*(){let i=yield*m(r);if("canonical"!==i.authority)return yield*iP("detached_edit",`Diagram "${r}" does not have an authoritative canonical document.`,"Restore a canonical revision before editing this diagram.",r);if(n.id!==r)return yield*iP("storage_commit_failed",`Edited document id "${n.id}" does not match "${r}".`,"Keep spec.id equal to the diagram id being edited.",r);let a=iF(t.path,r),s=nJ.make({schemaVersion:1,id:r,type:n.type,title:n.title,revision:i.manifest.revision+1,authority:"canonical",formats:n.png?["scene","excalidraw","png"]:["scene","excalidraw"]});return yield*U.jGc(e.makeTempDirectory(t.path,iC),e=>U.JkU(function*(){return yield*g(a,e,r),yield*v(r,e,i.manifest.revision),yield*w(e,n,s),yield*b(r,e),{manifest:s,document:n.document,revisions:[...i.revisions,`${nG(i.manifest.revision)}/`].sort(iD),authority:"canonical",documentAuthoritative:!0}}),t=>e.remove(t))}))}),k=e=>iP("patch_source_unavailable",`Diagram "${e}" has no current authoritative scene to patch.`,"Restore a canonical or patched revision before patching this diagram.",e),S=U.fn("sketchi.cli.storage.readPatchSourceUnlocked")(function*(r){let n=yield*m(r);if("detached"===n.authority||!n.manifest.formats.includes("scene"))return yield*k(r);let i=(0,ry.join)(iF(t.path,r),nY),a=yield*e.readText(i),s=yield*U.OH5(()=>{try{return nd.Uh.safeParse(JSON.parse(a))}catch{return}});return s?.success&&s.data.diagramId===r?{revision:n.manifest.revision,scene:s.data}:yield*iP("corrupt_record",`Diagram "${r}" has an invalid current scene artifact.`,"Restore a valid prior revision before patching this diagram.",r)}),E=U.fn("sketchi.cli.storage.readPatchSource")(e=>f(e,S(e),!0)),I=U.fn("sketchi.cli.storage.commitPatch")(function*(r,n,i){return yield*f(r,U.JkU(function*(){let a=yield*m(r);if(a.manifest.revision!==n)return yield*iP("patch_conflict",`Diagram "${r}" changed before the patch could commit.`,"Run sketchi show, verify the current record, and retry the patch if it is still intended.",r);if("detached"===a.authority||!a.manifest.formats.includes("scene"))return yield*k(r);if(i.scene.diagramId!==r)return yield*iP("storage_commit_failed",`Patched scene id "${i.scene.diagramId}" does not match "${r}".`,"Retry the patch against the named stored diagram.",r);let s=iF(t.path,r),o=nJ.make({schemaVersion:1,id:r,type:a.manifest.type,title:a.manifest.title,revision:a.manifest.revision+1,authority:"patched",formats:["scene","excalidraw"]});return yield*U.jGc(e.makeTempDirectory(t.path,iC),t=>U.JkU(function*(){return yield*g(s,t,r),yield*v(r,t,a.manifest.revision),yield*e.writeText((0,ry.join)(t,nY),nA(i.scene),!0),yield*e.writeText((0,ry.join)(t,nW),nA(i.excalidraw),!0),yield*e.remove((0,ry.join)(t,nq)),yield*e.writeText((0,ry.join)(t,nF),nA(o),!0),yield*b(r,t),{manifest:o,document:a.document,revisions:[...a.revisions,`${nG(a.manifest.revision)}/`].sort(iD),authority:"patched",documentAuthoritative:!1}}),t=>e.remove(t))}))}),$=(e,t)=>iP("corrupt_revision",`Diagram "${e}" revision ${String(t)} is corrupt.`,"Choose another revision or repair the corrupt snapshot.",e),O=U.fn("sketchi.cli.storage.validateArchivedJson")(function*(t,r,n){let i=yield*e.readText(t);return yield*U.SvU({try:()=>{let e=JSON.parse(i);if("object"!=typeof e||null===e)throw Error("archived JSON must contain an object");return e},catch:()=>$(r,n)})}),T=U.fn("sketchi.cli.storage.validateArchivedArtifact")(function*(e,t,r,n,i){let a=yield*O(e,n,i);if(!("scene"===t?nd.Uh.safeParse(a):nd.yE.safeParse(a)).success)return yield*$(n,i);"excalidraw"===t&&"detached"===r&&(yield*ig(a).pipe(U.xm_(()=>$(n,i))))}),A=U.fn("sketchi.cli.storage.validateArchivedPng")(function*(t,r,n){if(!ix((yield*e.readBytes(t))))return yield*$(r,n)}),C=U.fn("sketchi.cli.storage.readRevisionUnlocked")(function*(r,n){yield*m(r);let a=(0,ry.join)(iF(t.path,r),nX),s=(0,ry.join)(a,nG(n)),o=yield*e.kind(s);if("directory"===o){yield*i(s,r);let t=yield*h((0,ry.join)(s,nF),r).pipe(U.xm_(()=>$(r,n))),a=yield*p((0,ry.join)(s,nB),r).pipe(U.xm_(()=>$(r,n)));if(t.id!==r||t.revision!==n||t.type!==a.type||t.title!==a.spec.title)return yield*iP("corrupt_revision",`Diagram "${r}" revision ${String(n)} has inconsistent metadata.`,"Choose another revision or repair the corrupt snapshot.",r);for(let[i,a]of[[nY,"scene"],[nW,"excalidraw"]]){let o=(0,ry.join)(s,i);if((yield*e.kind(o))!=="file")return yield*iP("corrupt_revision",`Diagram "${r}" revision ${String(n)} is missing ${i}.`,"Choose another revision or repair the corrupt snapshot.",r);yield*T(o,a,t.authority,r,n).pipe(U.xm_(e=>"CliFilesystemError"===e._tag?$(r,n):e))}let o=yield*e.kind((0,ry.join)(s,nq));if("file"!==o&&"missing"!==o)return yield*iY((0,ry.join)(s,nq),r);"file"===o&&(yield*A((0,ry.join)(s,nq),r,n).pipe(U.xm_(e=>"CliFilesystemError"===e._tag?$(r,n):e)));let l="detached"!==t.authority?"file"===o?["scene","excalidraw","png"]:["scene","excalidraw"]:"file"===o?["excalidraw","png"]:["excalidraw"];return t.formats.length!==l.length||t.formats.some((e,t)=>e!==l[t])?yield*iP("corrupt_revision",`Diagram "${r}" revision ${String(n)} has inconsistent formats.`,"Choose another revision or repair the corrupt snapshot.",r):{_tag:"FullSnapshot",revision:n}}if("missing"!==o)return yield*iY(s,r);let l=(0,ry.join)(a,`${String(n).padStart(6,"0")}.json`),c=yield*e.kind(l);if("missing"===c)return yield*iP("revision_not_found",`Diagram "${r}" has no revision ${String(n)}.`,"Run sketchi show to inspect the available revision paths.",r);if("file"!==c)return yield*iY(l,r);let u=yield*p(l,r).pipe(U.xm_(e=>"CliStorageError"===e._tag?iP("corrupt_revision",`Diagram "${r}" revision ${String(n)} is corrupt.`,"Choose another revision or repair the legacy revision file.",r):e));return{_tag:"LegacyDocument",revision:n,document:u}}),N=U.fn("sketchi.cli.storage.replaceWithDetached")(function*(r,n,i){return yield*f(r,U.JkU(function*(){let a=yield*m(r);if(void 0!==i&&a.manifest.revision!==i)return yield*iP("replacement_conflict",`Diagram "${r}" changed before the pulled replacement could commit.`,"Run sketchi show, verify the current record, and retry the pull if it is still intended.",r);let s=iF(t.path,r),o=nJ.make({schemaVersion:1,id:r,type:a.manifest.type,title:a.manifest.title,revision:a.manifest.revision+1,authority:"detached",formats:["excalidraw"]});return yield*U.jGc(e.makeTempDirectory(t.path,iC),t=>U.JkU(function*(){return yield*g(s,t,r),yield*v(r,t,a.manifest.revision),yield*e.writeBytes((0,ry.join)(t,nW),n,!0),yield*e.remove((0,ry.join)(t,nq)),yield*e.writeText((0,ry.join)(t,nF),nA(o),!0),yield*b(r,t),{manifest:o,document:a.document,revisions:[...a.revisions,`${nG(a.manifest.revision)}/`].sort(iD),authority:"detached",documentAuthoritative:!1}}),t=>e.remove(t))}))}),M=U.fn("sketchi.cli.storage.readRevision")((e,t)=>f(e,C(e,t),!0)),P=U.fn("sketchi.cli.storage.restore")(function*(r,n,i){return yield*f(r,U.JkU(function*(){let a=yield*m(r),s=yield*C(r,n);if("LegacyDocument"===s._tag){if("canonical"!==a.authority||!i)return yield*iP("restore_conflict",`Legacy revision ${String(n)} requires a canonical rebuild for "${r}".`,"Restore a full canonical snapshot, or provide the rebuilt legacy document.",r);if(i.id!==r||nA(i.document)!==nA(s.document))return yield*iP("storage_commit_failed",`Legacy revision ${String(n)} rebuild does not match its archived document.`,"Rebuild the exact archived canonical document before restoring.",r)}let o=iF(t.path,r);return yield*U.jGc(e.makeTempDirectory(t.path,iC),t=>U.JkU(function*(){yield*g(o,t,r),yield*v(r,t,a.manifest.revision);let l=[...a.revisions,`${nG(a.manifest.revision)}/`].sort(iD),c=yield*"FullSnapshot"===s._tag?U.JkU(function*(){let i=(0,ry.join)(t,nX,nG(n));for(let r of yield*e.list(t))r.name!==nX&&(yield*e.remove((0,ry.join)(t,r.name)));yield*g(i,t,r);let s=(0,ry.join)(t,nF),o=yield*e.readText(s);yield*h(s,r);let c=yield*p((0,ry.join)(t,nB),r),u=function(e,t){let r=0,n=-1,i=-1;for(let t=0;t<e.length;t+=1){let a,s=e[t];if("{"===s){r+=1;continue}if("}"===s){r-=1;continue}if('"'!==s)continue;let o=t,l=!1;for(t+=1;t<e.length;t+=1){let r=e[t];if(l)l=!1;else if("\\"===r)l=!0;else if('"'===r)break}if(t>=e.length||1!==r)continue;try{a=JSON.parse(e.slice(o,t+1))}catch{return}if("revision"!==a)continue;let c=t+1;for(;/\s/u.test(e[c]??"");)c+=1;if(":"!==e[c])continue;for(c+=1;/\s/u.test(e[c]??"");)c+=1;let u=/^-?\d+/u.exec(e.slice(c));if(!u)return;let d=c+u[0].length,f=d;for(;/\s/u.test(e[f]??"");)f+=1;if(","!==e[f]&&"}"!==e[f]||-1!==n)return;n=c,i=d}return -1===n?void 0:`${e.slice(0,n)}${String(t)}${e.slice(i)}`}(o,a.manifest.revision+1);if(void 0===u)return yield*$(r,n);yield*e.writeText(s,u,!0);let d=yield*h(s,r);return{manifest:d,document:c,revisions:l,authority:d.authority,documentAuthoritative:"canonical"===d.authority}}):U.JkU(function*(){if(!i)return yield*iP("storage_commit_failed",`Legacy revision ${String(n)} has no rebuilt document.`,"Rebuild the archived canonical document before restoring.",r);let e=nJ.make({schemaVersion:1,id:r,type:i.type,title:i.title,revision:a.manifest.revision+1,authority:"canonical",formats:i.png?["scene","excalidraw","png"]:["scene","excalidraw"]});return yield*w(t,i,e),{manifest:e,document:i.document,revisions:l,authority:"canonical",documentAuthoritative:!0}});return yield*b(r,t),{diagram:c,restoredFromRevision:n}}),t=>e.remove(t))}))}),R=U.fn("sketchi.cli.storage.show")(e=>f(e,m(e),!0)),j=U.fn("sketchi.cli.storage.list")(function*(){yield*n(),yield*a();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(iA))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(ij)){let t=yield*R(e);i.push(nz(t))}return i});return{create:_,edit:x,readPatchSource:E,commitPatch:I,replaceWithDetached:N,readRevision:M,restore:P,show:R,list:j,readExportSource:U.fn("sketchi.cli.storage.readExportSource")(function*(r,n){return yield*f(r,U.JkU(function*(){let i=yield*m(r);if(i.manifest.formats.includes(n))return{_tag:"StoredArtifact",bytes:yield*e.readBytes((0,ry.join)(iF(t.path,r),iB(n)))};if("png"!==n)return yield*n_.make({code:"format_unavailable",format:n,message:`Diagram "${r}" has no stored ${n} artifact.`,hint:"Edit the diagram to rebuild its local artifacts."});if("detached"===i.authority)return{_tag:"RenderPng",excalidraw:yield*e.readBytes((0,ry.join)(iF(t.path,r),iB("excalidraw")))};for(let e of["scene","excalidraw"])if(!i.manifest.formats.includes(e))return yield*n_.make({code:"format_unavailable",format:e,message:`Diagram "${r}" has no stored ${e} artifact.`,hint:"Edit the diagram to rebuild its local artifacts."});let[a,s]=yield*U.Q7R([e.readBytes((0,ry.join)(iF(t.path,r),iB("scene"))),e.readBytes((0,ry.join)(iF(t.path,r),iB("excalidraw")))]);return{_tag:"RenderPng",scene:a,excalidraw:s}}),!0)})}})),iq=U.fn("sketchi.cli.export.writeFile")(function*(e,t){let r=yield*n1,n=yield*ib,i=(0,ry.resolve)(e),a=(0,ry.dirname)(i),s=()=>n_.make({code:"export_write_failed",format:(0,ry.basename)(e),message:`Export destination directory does not exist: ${a}.`,hint:"Create the destination directory and retry."}),o=yield*r.realPath(a).pipe(U.xm_(s));if((yield*r.kind(o))!=="directory")return yield*s();let l=yield*r.realPath(n.path),c=(0,ry.join)(o,(0,ry.basename)(i)),u=(0,ry.relative)(l,c);if(""===u||!u.startsWith("..")&&!(0,ry.isAbsolute)(u))return yield*n_.make({code:"invalid_destination",format:(0,ry.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,ry.join)(o,`.${(0,ry.basename)(e)}.sketchi.${String(process.pid)}.${crypto.randomUUID()}`);return yield*U.jGc(U.PyW(d),n=>r.writeBytes(n,t).pipe(U.hgn(r.rename(n,c)),U.xm_(()=>n_.make({code:"export_write_failed",format:(0,ry.basename)(e),message:`Unable to write export destination ${e}.`,hint:"Check the destination path and permissions, then retry."}))),e=>r.remove(e))});class iX extends Z.kl()("@sketchi/cli/DiagramExporter"){}function iJ(){return n_.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 iz(e){return U.SvU({try:()=>JSON.parse(new TextDecoder().decode(e)),catch:iJ})}let iG=z.QZ(iX,U.JkU(function*(){let e=yield*ik,t=yield*nK,r=U.fn("sketchi.cli.export.renderPng")(function*(e){let r=yield*iz(e.excalidraw),n=nd.yE.safeParse(r);if(!n.success)return yield*iJ();let i=e.scene?nd.Uh.safeParse((yield*iz(e.scene))):void 0;if(i&&!i.success)return yield*iJ();let a=yield*t.renderPng({...i?.success?{scene:i.data}:{},excalidraw:n.data}).pipe(U.xm_(iJ));return a instanceof Uint8Array?a:new Uint8Array(a)});return{exportArtifact:U.fn("sketchi.cli.export.artifact")(function*(t,n){let i=yield*e.readExportSource(t,n);return"StoredArtifact"===i._tag?i.bytes:yield*r(i)})}})),iV="gemini-3.1-flash-lite",iK="https://playground.sketchi.app/api/v1/generate",iH="SKETCHI_GENERATE_ENDPOINT";function iQ(){return ny.make({code:"provider_failure",message:"The Sketchi generate API could not be reached.",hint:"Check your network connection and retry. create/show/edit/list/export/restore remain offline; share and pull are separate explicit network commands.",details:["transport"]})}function iZ(){return ny.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 i0(){return ny.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 i1=U.fn("sketchi.cli.generate.request")(function*(e){let t=yield*U.$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:()=>iQ()}),r=yield*U.$mh({try:()=>t.text(),catch:()=>iQ()});if(!t.ok)return yield*U.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 ny.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 ny.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 ny.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 ny.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*U.fJG(iZ()))}),i2=U.fn("sketchi.cli.generate")(function*(e){var t,r;let n,i,a=yield*ik,s=yield*i1(e),o=yield*nO(s.document).pipe(U.xm_(()=>i0())),l=yield*nN(nC(o)).pipe(U.xm_(()=>i0())),c=yield*(t=s.scene,(n=nd.Uh.safeParse(t)).success?U.PyW(n.data):U.fJG(iZ())),u=yield*(r=s.excalidraw,(i=nd.yE.safeParse(r)).success?U.PyW(i.data):U.fJG(iZ())),d={id:l,type:o.type,title:o.spec.title,document:o,scene:c,excalidraw:u};return{diagram:yield*a.create(d),model:s.model||e.model,provider:s.provider}});function i5(e,t){switch(t){case"png":return`${e}.png`;case"excalidraw":return`${e}.excalidraw`;case"scene":return`${e}.scene.json`}}let i3=U.fn("sketchi.cli.generateWorkflow")(function*(e){let t=yield*iX,r=yield*i2(e),n=function(e,t,r){switch(r._tag){case"Default":return i5(e,t);case"CurrentDirectory":return(0,ry.resolve)(r.cwd,i5(e,"png"));case"ProjectDiagrams":return(0,ry.resolve)(r.cwd,"diagrams",i5(e,"png"));case"Custom":return r.path}}(r.diagram.manifest.id,e.format,e.destination),i=yield*t.exportArtifact(r.diagram.manifest.id,e.format);if("-"!==n){if("ProjectDiagrams"===e.destination._tag){let t=yield*n1;yield*t.makeDirectory((0,ry.join)(e.destination.cwd,"diagrams"),!0)}yield*iq(n,i)}return{generated:r,artifact:{id:r.diagram.manifest.id,format:e.format,destination:n,sizeBytes:i.byteLength,..."-"===n?{stdoutBytes:i}:{}}}}),i8=t("node:util"),i6=t("node:process"),i9=(A=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,e=>{let t=0;for(A.lastIndex=0;A.test(e);)t+=1;return e.length-t}),i4=e=>12288===e||e>=65281&&e<=65376||e>=65504&&e<=65510,i7=e=>8987===e||9001===e||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141,ae=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,at=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,ar=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,an=/\t{1,1000}/y,ai=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu,aa=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,as=/\p{M}+/gu,ao={limit:1/0,ellipsis:""},al=(e,t={},r={})=>{let n=t.limit??1/0,i=t.ellipsis??"",a=t?.ellipsisWidth??(i?al(i,ao,r).width:0),s=r.controlWidth??0,o=r.tabWidth??8,l=r.emojiWidth??2,c=r.regularWidth??1,u=r.wideWidth??2,d=[[aa,c],[ae,0],[at,s],[an,o],[ai,l],[ar,u]],f=0,h=0,p=e.length,m=0,g=!1,y=p,b=Math.max(0,n-a),v=0,w=0,_=0,x=0;e:for(;;){if(w>v||h>=p&&h>f){for(let t of(m=0,(e.slice(v,w)||e.slice(f,h)).replaceAll(as,""))){let e=t.codePointAt(0)||0;if(_+(x=i4(e)?2:i7(e)?u:c)>b&&(y=Math.min(y,Math.max(v,f)+m)),_+x>n){g=!0;break e}m+=t.length,_+=x}v=w=0}if(h>=p)break;for(let t=0,r=d.length;t<r;t++){let[r,i]=d[t];if(r.lastIndex=h,r.test(e)){if(_+(x=(m=r===ar?i9(e.slice(h,r.lastIndex)):r===ai?1:r.lastIndex-h)*i)>b&&(y=Math.min(y,h+Math.floor((b-_)/i))),_+x>n){g=!0;break e}_+=x,v=f,w=h,h=f=r.lastIndex;continue e}}h+=1}return{width:g?b:_,index:g?y:p,truncated:g,ellipsed:g&&n>=a}},ac={limit:1/0,ellipsis:"",ellipsisWidth:0},au=(e,t={})=>al(e,ac,t).width,ad="]8;;",af=RegExp(`(?:\\[(?<code>\\d+)m|\\${ad}(?<uri>.*)\u0007)`,"y"),ah=e=>e>=30&&e<=37||e>=90&&e<=97?39:e>=40&&e<=47||e>=100&&e<=107?49:1===e||2===e?22:3===e?23:4===e?24:7===e?27:8===e?28:9===e?29:0===e?0:void 0,ap=e=>`\x1b[${e}m`,am=e=>`\x1b${ad}${e}\u0007`,ag=(e,t,r)=>{let n=t[Symbol.iterator](),i=!1,a=!1,s=e.at(-1),o=void 0===s?0:au(s),l=n.next(),c=n.next(),u=0;for(;!l.done;){let s=l.value,d=au(s);o+d<=r?e[e.length-1]+=s:(e.push(s),o=0),("\x1b"===s||"›"===s)&&(i=!0,a=t.startsWith(ad,u+1)),i?a?"\x07"===s&&(i=!1,a=!1):"m"===s&&(i=!1):(o+=d)!==r||c.done||(e.push(""),o=0),l=c,c=n.next(),u+=s.length}s=e.at(-1),!o&&void 0!==s&&s.length&&e.length>1&&(e[e.length-2]+=e.pop())},ay=/\r?\n/;function ab(e,t,r){return String(e).normalize().split(ay).map(e=>((e,t,r={})=>{let n,i;if(!1!==r.trim&&""===e.trim())return"";let a="",s=e.split(" "),o=[""],l=0;for(let e=0;e<s.length;e++){let n=s[e];if(!1!==r.trim){let e=o.at(-1)??"",t=e.trimStart();e.length!==t.length&&(o[o.length-1]=t,l=au(t))}0!==e&&(l>=t&&(!1===r.wordWrap||!1===r.trim)&&(o.push(""),l=0),(l||!1===r.trim)&&(o[o.length-1]+=" ",l++));let i=au(n);if(r.hard&&i>t){let e=1+Math.floor((i-(t-l)-1)/t);Math.floor((i-1)/t)<e&&o.push(""),ag(o,n,t),l=au(o.at(-1)??"");continue}if(l+i>t&&l&&i){if(!1===r.wordWrap&&l<t){ag(o,n,t),l=au(o.at(-1)??"");continue}o.push(""),l=0}if(l+i>t&&!1===r.wordWrap){ag(o,n,t),l=au(o.at(-1)??"");continue}o[o.length-1]+=n,l+=i}!1!==r.trim&&(o=o.map(e=>(e=>{let t=e.split(" "),r=t.length;for(;r&&!au(t[r-1]);)r--;return r===t.length?e:t.slice(0,r).join(" ")+t.slice(r).join("")})(e)));let c=o.join("\n"),u=!1;for(let e=0;e<c.length;e++){let t=c[e];if(a+=t,u)u=!1;else if(u=t>="\uD800"&&t<="\uDBFF")continue;if("\x1b"===t||"›"===t){af.lastIndex=e+1;let t=af.exec(c),r=t?.groups;if(r?.code!==void 0){let e=Number.parseFloat(r.code);n=39===e?void 0:e}else r?.uri!==void 0&&(i=0===r.uri.length?void 0:r.uri)}if("\n"===c[e+1]){i&&(a+=am(""));let e=n?ah(n):void 0;n&&e&&(a+=ap(e))}else"\n"===t&&(n&&ah(n)&&(a+=ap(n)),i&&(a+=am(i)))}return a})(e,t,r)).join("\n")}var av=n(5776);let aw=t("node:tty");function a_(e,t,r){if(!r.some(e=>!e.disabled))return e;let n=e+t,i=Math.max(r.length-1,0),a=n<0?i:n>i?0:n;return r[a]?.disabled?a_(a,t<0?-1:1,r):a}let ax={actions:new Set(["up","down","left","right","space","enter","cancel"]),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"},withGuide:!0,date:{monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],messages:{required:"Please enter a valid date",invalidMonth:"There are only 12 months in a year",invalidDay:(e,t)=>`There are only ${e} days in ${t}`,afterMin:e=>`Date must be on or after ${e.toISOString().slice(0,10)}`,beforeMax:e=>`Date must be on or before ${e.toISOString().slice(0,10)}`}}};function ak(e,t){if("string"==typeof e)return ax.aliases.get(e)===t;for(let r of e)if(void 0!==r&&ak(r,t))return!0;return!1}let aS=globalThis.process.platform.startsWith("win"),aE=Symbol("clack:cancel");function aI(e,t){e.isTTY&&e.setRawMode(t)}let a$=e=>"columns"in e&&"number"==typeof e.columns?e.columns:80,aO=e=>"rows"in e&&"number"==typeof e.rows?e.rows:20;function aT(e,t,r,n=r,i=r,a){return ab(t,a$(e??i6.stdout)-r.length,{hard:!0,trim:!1}).split(`
2
+ import{createRequire as e}from"node:module";let t=e(import.meta.url);var r,n,i,a,s={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",a=t.whitespace?" = ":"=",o=[],l=t.sort?Object.keys(e).sort():Object.keys(e),c=0;t.align&&(c=s(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)=>s(e).length>=s(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+=s(`${t}${d}`).padEnd(c," ")+a+s(e)+i;else r&&"object"==typeof r?o.push(t):u+=s(t).padEnd(c," ")+a+s(r)+i}for(let a of(t.section&&u.length&&(u="["+s(t.section)+"]"+(t.newline?i+i:i)+u),o)){let s=n(a,".").join("\\."),o=(t.section?t.section+".":"")+s,l=r(e[a],{...t,section:o});u.length&&l.length&&(u+=i),u+=l}return u};function n(e,t){var r=0,n=0,i=0,a=[];do if(-1!==(i=e.indexOf(t,r))){if(r=i+t.length,i>0&&"\\"===e[i-1])continue;a.push(e.slice(n,i)),n=i+t.length}while(-1!==i)return a.push(e.slice(n)),a}let i=(e,r={})=>{r.bracketedArray=!1!==r.bracketedArray;let i=Object.create(null),a=i,s=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__"===(s=o(c[1]))){a=Object.create(null);continue}a=i[s]=i[s]||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(a,f)?Array.isArray(a[f])||(a[f]=[a[f]]):a[f]=[]),Array.isArray(a[f])?a[f].push(p):a[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,".");a=i;let s=r.pop(),o=s.replace(/\\\./g,".");for(let e of r)"__proto__"!==e&&(t.call(a,e)&&"object"==typeof a[e]||(a[e]=Object.create(null)),a=a[e]);(a!==i||o!==s)&&(a[o]=i[e],d.push(e))}for(let e of d)delete i[e];return i},a=e=>e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"),s=e=>"string"!=typeof e||e.match(/[=\r\n]/)||e.match(/^\[/)||e.length>1&&a(e)||e!==e.trim()?JSON.stringify(e):e.split(";").join("\\;").split("#").join("\\#"),o=e=>{if(a(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:s,unsafe:o}},5776(e){let t={to:(e,t)=>t?`[${t+1};${e+1}H`:`[${e+1}G`,move(e,t){let r="";return e<0?r+=`[${-e}D`:e>0&&(r+=`[${e}C`),t<0?r+=`[${-t}A`:t>0&&(r+=`[${t}B`),r},up:(e=1)=>`[${e}A`,down:(e=1)=>`[${e}B`,forward:(e=1)=>`[${e}C`,backward:(e=1)=>`[${e}D`,nextLine:(e=1)=>"\x1b[E".repeat(e),prevLine:(e=1)=>"\x1b[F".repeat(e),left:"\x1b[G",hide:"\x1b[?25l",show:"\x1b[?25h",save:"\x1b7",restore:"\x1b8"},r={screen:"\x1b[2J",up:(e=1)=>"\x1b[1J".repeat(e),down:(e=1)=>"\x1b[J".repeat(e),line:"\x1b[2K",lineEnd:"\x1b[K",lineStart:"\x1b[1K",lines(e){let r="";for(let n=0;n<e;n++)r+=this.line+(n<e-1?t.up():"");return e&&(r+=t.left),r}};e.exports={cursor:t,scroll:{up:(e=1)=>"\x1b[S".repeat(e),down:(e=1)=>"\x1b[T".repeat(e)},erase:r,beep:"\x07"}},3176(e,t,r){var n=r(3633),i=r(4239);e.exports={parse:function(e,t){var r=e.toString(),a=n.parse(r,t);return i.compile(a,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,a=new Set,s=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 a=t[i];if("InlineTableValue"===a.type){var s=a.key;Array.isArray(s)||(s=[s]),function(e,t,r,n,i){for(var a=0;a<t.length-1;a++){var s=t[a],o=w(t.slice(0,a+1));void 0===e[s]?e[s]=b():"object"!=typeof e[s]||null===e[s]||Array.isArray(e[s])?p("Cannot redefine existing key '"+o+"'.",n):i&&i.has(o)&&p("Cannot extend inline table '"+o+"'.",n),e=e[s]}var l=t[t.length-1];void 0!==e[l]&&p("Cannot redefine existing key '"+w(t)+"'.",n),e[l]=r}(r,s,e(a.value),a.offset,n),n.add(w(s))}}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])||a.has(g)?p("Cannot redefine existing key '"+g+"'.",l):s.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),a.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),s.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(a.has(r)&&p("Cannot append to statically defined array '"+r+"'.",n),i.forEach(function(e){_(e,r)&&i.delete(e)}),a.forEach(function(e){_(e,r)&&a.delete(e)}),i.add(r),u=g(c,t,function(){var e=[];return l.add(e),e}(),n),o=t,u instanceof Array){var s=b();u.push(s),u=s}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,s=0;s<t.length;s++){var o=t[s],l=w(t.slice(0,s+1));void 0===i[o]?s===t.length-1?i[o]=r:i[o]=b():s!==t.length-1&&a.has(l)&&p("Cannot redefine existing key '"+l+"'.",n),i=i[o],s<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 _(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,a=this.location.source&&"function"==typeof this.location.source.offset?this.location.source.offset(i):i,s=this.location.source+":"+a.line+":"+a.column;if(r){let e=this.location.end,n="".padEnd(a.line.toString().length," "),o=r[i.line-1],l=(i.line===e.line?e.column:o.length+1)-i.column||1;t+="\n --\x3e "+s+"\n"+n+" |\n"+a.line+" | "+o+"\n"+n+" | "+"".padEnd(i.column-1," ")+"".padEnd(l,"^")}else t+="\n at "+s}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 a(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 s(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=>'"'+a(e.text)+'"',class(e){let t=e.parts.map(e=>Array.isArray(e)?s(e[0])+"-"+s(e[1]):s(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?'"'+a(t)+'"':"end of input")+" found."}}e.exports={StartRules:["start"],SyntaxError:t,parse:function(e,r){let n,i={},a=(r=void 0!==r?r:{}).grammarSource,s={start:eD},o=eD,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]/,_=/^[0-7]/,k=/^[01]/,S=/^[ \t]/,I=/^[A-Za-z0-9_\-]/,E=/^["\\btnfre]/,$=eM("#",!1),O=eN([" ",[" ","~"],["€","￿"]],!1,!1,!1),C=eM("[",!1),T=eM("]",!1),A=eM(".",!1),M=eM("=",!1),N=eN(["+","-"],!1,!1,!1),P=eM("inf",!1),R=eM("nan",!1),j=eM('"""',!1),D=eM('"',!1),L=eM("'''",!1),U=eM("'",!1),F=eM("\\",!1),B={type:"any"},W=eM("\r\n",!1),q=eN(['"',"\\",["\0","\b"],["\v","\x1f"],"","\r"],!0,!1,!1),Y=eM('""',!1),z=eN(["'",["\0","\b"],["\v","\x1f"],"","\r"],!0,!1,!1),X=eM("''",!1),J=eN(['"',"\\",["\0","\b"],["\n","\x1f"],""],!0,!1,!1),G=eN(["'",["\0","\b"],["\n","\x1f"],""],!0,!1,!1),V=eN(["e","E"],!1,!1,!1),K=eM("0",!1),H=eM("0x",!1),Q=eM("0o",!1),Z=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),ea=eN([["0","7"]],!1,!1,!1),es=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),e_=eN(['"',"\\","b","t","n","f","r","e"],!1,!1,!1),ek=eM("\\U",!1),eS=eM("\\u",!1),eI=eM("\\x",!1),eE=0|r.peg$currPos,e$=eE,eO=[{line:1,column:1}],eC=eE,eT=r.peg$maxFailExpected||[],eA=0|r.peg$silentFails;if(r.startRule){if(!(r.startRule in s))throw Error("Can't start parsing from rule \""+r.startRule+'".');o=s[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 eP(t){let r,n=eO[t];if(n)return n;if(t>=eO.length)r=eO.length-1;else for(r=t;!eO[--r];);for(n={line:(n=eO[r]).line,column:n.column};r<t;)10===e.charCodeAt(r)?(n.line++,n.column=1):n.column++,r++;return eO[t]=n,n}function eR(e,t,r){let n=eP(e),i=eP(t),s={source:a,start:{offset:e,line:n.line,column:n.column},end:{offset:t,line:i.line,column:i.column}};return r&&a&&"function"==typeof a.offset&&(s.start=a.offset(s.start),s.end=a.offset(s.end)),s}function ej(e){eE<eC||(eE>eC&&(eC=eE,eT=[]),eT.push(e))}function eD(){let t,r,n,a;for(t=eE,65279===e.charCodeAt(eE)?(a="\uFEFF",eE++):(a=i,0===eA&&ej(ew)),a===i,r=[],n=eL();n!==i;)r.push(n),n=eL();return e$=t,t=tl}function eL(){let t,r,n,a,s,o,l,c;for(t=eE,r=[],n=te();n!==i;)r.push(n),n=te();if((c=eU())===i&&(c=function(){let t,r,n,a,s,o,l,c;if(t=eE,91===e.charCodeAt(eE)?(r="[",eE++):(r=i,0===eA&&ej(C)),r!==i)if(91===e.charCodeAt(eE)?(n="[",eE++):(n=i,0===eA&&ej(C)),n!==i){for(a=[],s=te();s!==i;)a.push(s),s=te();if((s=eF())!==i){for(o=[],l=te();l!==i;)o.push(l),l=te();(93===e.charCodeAt(eE)?(l="]",eE++):(l=i,0===eA&&ej(T)),l!==i&&(93===e.charCodeAt(eE)?(c="]",eE++):(c=i,0===eA&&ej(T)),c!==i))?t=void tf(th("ArrayPath",s,e$=t)):(eE=t,t=i)}else eE=t,t=i}else eE=t,t=i;else eE=t,t=i;if(t===i)if(t=eE,91===e.charCodeAt(eE)?(r="[",eE++):(r=i,0===eA&&ej(C)),r!==i){for(n=[],a=te();a!==i;)n.push(a),a=te();if((a=eF())!==i){for(s=[],o=te();o!==i;)s.push(o),o=te();(93===e.charCodeAt(eE)?(o="]",eE++):(o=i,0===eA&&ej(T)),o!==i)?t=void tf(th("ObjectPath",a,e$=t)):(eE=t,t=i)}else eE=t,t=i}else eE=t,t=i;return t}())===i&&(c=function(){let t,r,n,a,s,o;if(t=eE,(r=e3())!==i){for(n=[],a=te();a!==i;)n.push(a),a=te();if(61===e.charCodeAt(eE)?(a="=",eE++):(a=i,0===eA&&ej(M)),a!==i){for(s=[],o=te();o!==i;)s.push(o),o=te();if((o=eq())!==i)t=void tf(th("Assign",o,e$=t,r));else eE=t,t=i}else eE=t,t=i}else eE=t,t=i;return t}()),(n=c)!==i){for(a=[],s=te();s!==i;)a.push(s),s=te();if((s=eU())===i&&(s=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,a,s,o]:(eE=t,t=i)}else eE=t,t=i;if(t===i){if(t=eE,r=[],(n=te())!==i)for(;n!==i;)r.push(n),n=te();else r=i;if(r!==i){if(n=[],(a=tt())!==i)for(;a!==i;)n.push(a),a=tt();else n=i;n===i&&(n=tn()),n!==i?t=r=[r,n]:(eE=t,t=i)}else eE=t,t=i;t===i&&(t=tt())}return t}function eU(){let t,r,n,a;if(t=eE,35===e.charCodeAt(eE)?(r="#",eE++):(r=i,0===eA&&ej($)),r!==i){for(n=[],a=e.charAt(eE),u.test(a)?eE++:(a=i,0===eA&&ej(O));a!==i;)n.push(a),a=e.charAt(eE),u.test(a)?eE++:(a=i,0===eA&&ej(O));t=r=[r,n]}else eE=t,t=i;return t}function eF(){let e,t,r;if(e=eE,t=[],(r=eW())!==i)for(;r!==i;)t.push(r),r=eW();else t=i;if(t!==i)if((r=eB())!==i){var n,a;e$=e,n=t,a=r,e=n.concat(a)}else eE=e,e=i;else eE=e,e=i;return e===i&&(e=eE,(t=eB())!==i&&(e$=e,t=[t]),e=t),e}function eB(){let e,t,r,n,a;for(e=eE,t=[],r=te();r!==i;)t.push(r),r=te();if((r=e6())!==i){for(n=[],a=te();a!==i;)n.push(a),a=te();e$=e,e=r}else eE=e,e=i;return e}function eW(){let t,r,n,a,s;for(t=eE,r=[],n=te();n!==i;)r.push(n),n=te();if((n=e6())!==i){for(a=[],s=te();s!==i;)a.push(s),s=te();(46===e.charCodeAt(eE)?(s=".",eE++):(s=i,0===eA&&ej(A)),s!==i)?(e$=t,t=n):(eE=t,t=i)}else eE=t,t=i;return t}function eq(){let t,r;return(t=eE,e$=eE,++tc>tu&&(tc--,td("Maximum nesting depth of "+tu+" exceeded.",e$)),void 0!==i&&(r=function(){let t,r,n,a,s,o,u,f,h,p,m,b,w,S,I,E,$;if(t=eE,(s=eE,'"""'===e.substr(eE,3)?(o='"""',eE+=3):(o=i,0===eA&&ej(j)),o!==i&&(tt()===i,u=function(){let t,r,n,a,s,o,l,c,u,d,f;for(t=eE,r=[],n=eX();n!==i;)r.push(n),n=eX();if(n=[],a=eE,(s=eJ())!==i){if(o=[],(l=eX())!==i)for(;l!==i;)o.push(l),l=eX();else o=i;o!==i?a=s=[s,o]:(eE=a,a=i)}else eE=a,a=i;for(;a!==i;)if(n.push(a),a=eE,(s=eJ())!==i){if(o=[],(l=eX())!==i)for(;l!==i;)o.push(l),l=eX();else o=i;o!==i?a=s=[s,o]:(eE=a,a=i)}else eE=a,a=i;return c=eE,'""'===e.substr(eE,2)?(u='""',eE+=2):(u=i,0===eA&&ej(Y)),u!==i?(d=eE,eA++,'"""'===e.substr(eE,3)?(f='"""',eE+=3):(f=i,0===eA&&ej(j)),eA--,f!==i?(eE=d,d=void 0):d=i,d!==i?(e$=c,c='""'):(eE=c,c=i)):(eE=c,c=i),c===i&&(c=eE,34===e.charCodeAt(eE)?(u='"',eE++):(u=i,0===eA&&ej(D)),u!==i?(d=eE,eA++,'"""'===e.substr(eE,3)?(f='"""',eE+=3):(f=i,0===eA&&ej(j)),eA--,f!==i?(eE=d,d=void 0):d=i,d!==i?(e$=c,c='"'):(eE=c,c=i)):(eE=c,c=i)),(a=c)===i&&(a=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,a)}(),'"""'===e.substr(eE,3)?(f='"""',eE+=3):(f=i,0===eA&&ej(j)),f!==i))?s=th("String",u,e$=s):(eE=s,s=i),(a=s)===i&&(a=eY())===i&&((h=eE,"'''"===e.substr(eE,3)?(p="'''",eE+=3):(p=i,0===eA&&ej(L)),p!==i&&(tt()===i,m=function(){let t,r,n,a,s,o,l,c,u,d,f;for(t=eE,r=[],n=eG();n!==i;)r.push(n),n=eG();if(n=[],a=eE,(s=eV())!==i){if(o=[],(l=eG())!==i)for(;l!==i;)o.push(l),l=eG();else o=i;o!==i?a=s=[s,o]:(eE=a,a=i)}else eE=a,a=i;for(;a!==i;)if(n.push(a),a=eE,(s=eV())!==i){if(o=[],(l=eG())!==i)for(;l!==i;)o.push(l),l=eG();else o=i;o!==i?a=s=[s,o]:(eE=a,a=i)}else eE=a,a=i;return c=eE,"''"===e.substr(eE,2)?(u="''",eE+=2):(u=i,0===eA&&ej(X)),u!==i?(d=eE,eA++,"'''"===e.substr(eE,3)?(f="'''",eE+=3):(f=i,0===eA&&ej(L)),eA--,f!==i?(eE=d,d=void 0):d=i,d!==i?(e$=c,c="''"):(eE=c,c=i)):(eE=c,c=i),c===i&&(c=eE,39===e.charCodeAt(eE)?(u="'",eE++):(u=i,0===eA&&ej(U)),u!==i?(d=eE,eA++,"'''"===e.substr(eE,3)?(f="'''",eE+=3):(f=i,0===eA&&ej(L)),eA--,f!==i?(eE=d,d=void 0):d=i,d!==i?(e$=c,c="'"):(eE=c,c=i)):(eE=c,c=i)),(a=c)===i&&(a=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,a)}(),"'''"===e.substr(eE,3)?(b="'''",eE+=3):(b=i,0===eA&&ej(L)),b!==i))?h=th("String",m,e$=h):(eE=h,h=i),(a=h)===i)&&(a=ez()),(n=a)===i&&((w=eE,S=e.charAt(eE),d.test(S)?eE++:(S=i,0===eA&&ej(N)),S===i&&(S=null),"inf"===e.substr(eE,3)?(I="inf",eE+=3):(I=i,0===eA&&ej(P)),I!==i)?w=th("Float","-"===S?-1/0:1/0,e$=w):(eE=w,w=i),w===i&&(w=eE,S=e.charAt(eE),d.test(S)?eE++:(S=i,0===eA&&ej(N)),S===i&&(S=null),"nan"===e.substr(eE,3)?(I="nan",eE+=3):(I=i,0===eA&&ej(R)),I!==i?w=th("Float",NaN,e$=w):(eE=w,w=i),w===i&&(w=function(){var t,r,n,a,s,o,l,c,u,f,h;let p,m,g,y,b;if(p=eE,(m=e9())!==i)if((g=e7())!==i)if((y=e4())!==i){let s,o,l,c,u,f,h,g;(s=eE,"z"===(o=e.charAt(eE)).toLowerCase()?eE++:(o=i,0===eA&&ej(ep)),o!==i&&(e$=s,o="Z"),(s=o)===i&&(s=eE,o=eE,l=e.charAt(eE),d.test(l)?eE++:(l=i,0===eA&&ej(N)),l!==i&&(c=ti())!==i&&(u=ti())!==i?(58===e.charCodeAt(eE)?(f=":",eE++):(f=i,0===eA&&ej(eh)),f!==i&&(h=ti())!==i&&(g=ti())!==i?o=l=[l,c,u,f,h,g]:(eE=o,o=i)):(eE=o,o=i),s=o!==i?e.substring(s,eE):o),(b=s)!==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),(a=th("Date",new Date(t+"T"+r+b),n)).raw=t+"T"+r,a.tz=b,p=a):(eE=p,p=i)}else eE=p,p=i;else eE=p,p=i;else eE=p,p=i;return p===i&&((p=eE,(m=e9())!==i&&(g=e7())!==i&&(y=e4())!==i)?(e$=p,s=m,o=y,tp(s,l=e$),tm(o,l),p=th("LocalDateTime",s+"T"+o,l)):(eE=p,p=i),p===i&&((p=eE,(m=e9())!==i&&(g=eE,eA++,y=e7(),eA--,y===i?g=void 0:(eE=g,g=i),g!==i))?(e$=p,tp(c=m,u=e$),p=th("LocalDate",c,u)):(eE=p,p=i),p===i&&(p=eE,(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,a,s,o,l,c,u,f;if(t=eE,(s=eE,o=e.charAt(eE),d.test(o)?eE++:(o=i,0===eA&&ej(N)),o===i&&(o=null),(l=eQ())!==i&&(46===e.charCodeAt(eE)?(c=".",eE++):(c=i,0===eA&&ej(A)),c!==i&&(u=eE,(u=(f=e0())!==i?e.substring(u,eE):f)!==i)))?(e$=s,s=("-"===o?"-":"")+l+"."+u):(eE=s,s=i),s===i&&((s=eE,o=e.charAt(eE),d.test(o)?eE++:(o=i,0===eA&&ej(N)),o===i&&(o=null),(l=eQ())!==i)?(e$=s,s=("-"===o?"-":"")+l):(eE=s,s=i)),(r=s)!==i)if(n=e.charAt(eE),g.test(n)?eE++:(n=i,0===eA&&ej(V)),n!==i){let n,s,o,l;if((n=eE,s=e.charAt(eE),d.test(s)?eE++:(s=i,0===eA&&ej(N)),s===i&&(s=null),o=eE,(o=(l=e0())!==i?e.substring(o,eE):l)!==i)?(e$=n,n=(s||"")+o):(eE=n,n=i),(a=n)!==i)e$=t,t=th("Float",parseFloat(tg(r+"e"+a)),e$);else eE=t,t=i}else eE=t,t=i;else eE=t,t=i;if(t===i){let n,a,s,o,l,c;t=eE,(n=eE,a=e.charAt(eE),d.test(a)?eE++:(a=i,0===eA&&ej(N)),a===i&&(a=null),(s=eQ())!==i&&(46===e.charCodeAt(eE)?(o=".",eE++):(o=i,0===eA&&ej(A)),o!==i&&(l=eE,(l=(c=e0())!==i?e.substring(l,eE):c)!==i)))?(e$=n,n=("-"===a?"-":"")+s+"."+l):(eE=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,a;if(((t=eE,"0x"===e.substr(eE,2)?(r="0x",eE+=2):(r=i,0===eA&&ej(H)),r!==i&&(n=eE,(n=(a=function(){let t,r,n,a,s,o;if(t=eE,r=e.charAt(eE),x.test(r)?eE++:(r=i,0===eA&&ej(ei)),r!==i){for(n=[],a=eE,s=e.charAt(eE),v.test(s)?eE++:(s=i,0===eA&&ej(er)),s===i&&(s=null),o=e.charAt(eE),x.test(o)?eE++:(o=i,0===eA&&ej(ei)),o!==i?a=s=[s,o]:(eE=a,a=i);a!==i;)n.push(a),a=eE,s=e.charAt(eE),v.test(s)?eE++:(s=i,0===eA&&ej(er)),s===i&&(s=null),o=e.charAt(eE),x.test(o)?eE++:(o=i,0===eA&&ej(ei)),o!==i?a=s=[s,o]:(eE=a,a=i);t=r=[r,n]}else eE=t,t=i;return t}())!==i?e.substring(n,eE):a)!==i))?(e$=t,t=th("Integer",parseInt(tg(n),16),e$)):(eE=t,t=i),t===i)&&((t=eE,"0o"===e.substr(eE,2)?(r="0o",eE+=2):(r=i,0===eA&&ej(Q)),r!==i&&(n=eE,(n=(a=function(){let t,r,n,a,s,o;if(t=eE,r=e.charAt(eE),_.test(r)?eE++:(r=i,0===eA&&ej(ea)),r!==i){for(n=[],a=eE,s=e.charAt(eE),v.test(s)?eE++:(s=i,0===eA&&ej(er)),s===i&&(s=null),o=e.charAt(eE),_.test(o)?eE++:(o=i,0===eA&&ej(ea)),o!==i?a=s=[s,o]:(eE=a,a=i);a!==i;)n.push(a),a=eE,s=e.charAt(eE),v.test(s)?eE++:(s=i,0===eA&&ej(er)),s===i&&(s=null),o=e.charAt(eE),_.test(o)?eE++:(o=i,0===eA&&ej(ea)),o!==i?a=s=[s,o]:(eE=a,a=i);t=r=[r,n]}else eE=t,t=i;return t}())!==i?e.substring(n,eE):a)!==i))?(e$=t,t=th("Integer",parseInt(tg(n),8),e$)):(eE=t,t=i),t===i)&&((t=eE,"0b"===e.substr(eE,2)?(r="0b",eE+=2):(r=i,0===eA&&ej(Z)),r!==i&&(n=eE,(n=(a=function(){let t,r,n,a,s,o;if(t=eE,r=e.charAt(eE),k.test(r)?eE++:(r=i,0===eA&&ej(es)),r!==i){for(n=[],a=eE,s=e.charAt(eE),v.test(s)?eE++:(s=i,0===eA&&ej(er)),s===i&&(s=null),o=e.charAt(eE),k.test(o)?eE++:(o=i,0===eA&&ej(es)),o!==i?a=s=[s,o]:(eE=a,a=i);a!==i;)n.push(a),a=eE,s=e.charAt(eE),v.test(s)?eE++:(s=i,0===eA&&ej(er)),s===i&&(s=null),o=e.charAt(eE),k.test(o)?eE++:(o=i,0===eA&&ej(es)),o!==i?a=s=[s,o]:(eE=a,a=i);t=r=[r,n]}else eE=t,t=i;return t}())!==i?e.substring(n,eE):a)!==i))?(e$=t,t=th("Integer",parseInt(tg(n),2),e$)):(eE=t,t=i),t===i)){let n,a,s,o,l,c;t=eE,(n=eE,a=e.charAt(eE),d.test(a)?eE++:(a=i,0===eA&&ej(N)),a===i&&(a=null),48===e.charCodeAt(eE)?(s="0",eE++):(s=i,0===eA&&ej(K)),s!==i&&(o=eE,eA++,l=e.charAt(eE),y.test(l)?eE++:(l=i,0===eA&&ej(ee)),eA--,l===i?o=void 0:(eE=o,o=i),o!==i&&(l=eE,eA++,46===e.charCodeAt(eE)?(c=".",eE++):(c=i,0===eA&&ej(A)),eA--,c===i?l=void 0:(eE=l,l=i),l!==i)))?(e$=n,n=(a||"")+"0"):(eE=n,n=i),n===i&&((n=eE,a=e.charAt(eE),d.test(a)?eE++:(a=i,0===eA&&ej(N)),a===i&&(a=null),s=eE,(s=(o=eZ())!==i?e.substring(s,eE):o)!==i&&(o=eE,eA++,46===e.charCodeAt(eE)?(l=".",eE++):(l=i,0===eA&&ej(A)),eA--,l===i?o=void 0:(eE=o,o=i),o!==i))?(e$=n,n=(a||"")+s):(eE=n,n=i)),(r=n)!==i&&(e$=t,r=th("Integer",parseInt(tg(r),10),e$)),t=r}return t}())),(n=w)===i&&(E=eE,e.substr(eE,4)===l?($=l,eE+=4):($=i,0===eA&&ej(eo)),$!==i&&($=th("Boolean",!0,e$=E)),(E=$)===i&&(E=eE,e.substr(eE,5)===c?($=c,eE+=5):($=i,0===eA&&ej(el)),$!==i&&($=th("Boolean",!1,e$=E)),E=$),(n=E)===i&&(n=function(){let t,r,n,a,s,o,l,c,u,d;if(t=eE,91===e.charCodeAt(eE)?(r="[",eE++):(r=i,0===eA&&ej(C)),r!==i){for(n=[],a=e1();a!==i;)n.push(a),a=e1();93===e.charCodeAt(eE)?(a="]",eE++):(a=i,0===eA&&ej(T)),a!==i?t=th("Array",[],e$=t):(eE=t,t=i)}else eE=t,t=i;if(t===i)if(t=eE,91===e.charCodeAt(eE)?(r="[",eE++):(r=i,0===eA&&ej(C)),r!==i){for(n=[],a=e1();a!==i;)n.push(a),a=e1();if((a=eq())!==i){for(s=[],o=eE,l=[],c=e1();c!==i;)l.push(c),c=e1();if(44===e.charCodeAt(eE)?(c=",",eE++):(c=i,0===eA&&ej(ec)),c!==i){for(u=[],d=e1();d!==i;)u.push(d),d=e1();(d=eq())!==i?(e$=o,o=d):(eE=o,o=i)}else eE=o,o=i;for(;o!==i;){for(s.push(o),o=eE,l=[],c=e1();c!==i;)l.push(c),c=e1();if(44===e.charCodeAt(eE)?(c=",",eE++):(c=i,0===eA&&ej(ec)),c!==i){for(u=[],d=e1();d!==i;)u.push(d),d=e1();(d=eq())!==i?(e$=o,o=d):(eE=o,o=i)}else eE=o,o=i}for(o=[],l=e1();l!==i;)o.push(l),l=e1();for(44===e.charCodeAt(eE)?(l=",",eE++):(l=i,0===eA&&ej(ec)),l===i&&(l=null),c=[],u=e1();u!==i;)c.push(u),u=e1();if(93===e.charCodeAt(eE)?(u="]",eE++):(u=i,0===eA&&ej(T)),u!==i){var f;e$=t,f=a,s.unshift(f),t=th("Array",s,e$)}else eE=t,t=i}else eE=t,t=i}else eE=t,t=i;return t}())===i))&&(n=function(){let t,r,n,a,s,o,l,c,u,d;if(t=eE,123===e.charCodeAt(eE)?(r="{",eE++):(r=i,0===eA&&ej(eu)),r!==i){for(n=[],a=e5();a!==i;)n.push(a),a=e5();125===e.charCodeAt(eE)?(a="}",eE++):(a=i,0===eA&&ej(ed)),a!==i?t=th("InlineTable",[],e$=t):(eE=t,t=i)}else eE=t,t=i;if(t===i)if(t=eE,123===e.charCodeAt(eE)?(r="{",eE++):(r=i,0===eA&&ej(eu)),r!==i){for(n=[],a=e5();a!==i;)n.push(a),a=e5();if((a=e2())!==i){for(s=[],o=eE,l=[],c=e5();c!==i;)l.push(c),c=e5();if(44===e.charCodeAt(eE)?(c=",",eE++):(c=i,0===eA&&ej(ec)),c!==i){for(u=[],d=e5();d!==i;)u.push(d),d=e5();(d=e2())!==i?(e$=o,o=d):(eE=o,o=i)}else eE=o,o=i;for(;o!==i;){for(s.push(o),o=eE,l=[],c=e5();c!==i;)l.push(c),c=e5();if(44===e.charCodeAt(eE)?(c=",",eE++):(c=i,0===eA&&ej(ec)),c!==i){for(u=[],d=e5();d!==i;)u.push(d),d=e5();(d=e2())!==i?(e$=o,o=d):(eE=o,o=i)}else eE=o,o=i}for(o=[],l=e5();l!==i;)o.push(l),l=e5();for(44===e.charCodeAt(eE)?(l=",",eE++):(l=i,0===eA&&ej(ec)),l===i&&(l=null),c=[],u=e5();u!==i;)c.push(u),u=e5();if(125===e.charCodeAt(eE)?(u="}",eE++):(u=i,0===eA&&ej(ed)),u!==i){var f;e$=t,f=a,s.unshift(f),t=th("InlineTable",s,e$)}else eE=t,t=i}else eE=t,t=i}else eE=t,t=i;return t}()),(r=n)!==i){var O;e$=t,O=r,tc--,r=O}return(t=r)===i&&(e$=eE,tc--,t=!1,t=i),t}())!==i)?(e$=t,t=r):(eE=t,t=i),t}function eY(){let t,r,n,a;if(t=eE,34===e.charCodeAt(eE)?(r='"',eE++):(r=i,0===eA&&ej(D)),r!==i){for(n=[],a=eK();a!==i;)n.push(a),a=eK();(34===e.charCodeAt(eE)?(a='"',eE++):(a=i,0===eA&&ej(D)),a!==i)?(e$=t,t=th("String",n.join(""),e$)):(eE=t,t=i)}else eE=t,t=i;return t}function ez(){let t,r,n,a;if(t=eE,39===e.charCodeAt(eE)?(r="'",eE++):(r=i,0===eA&&ej(U)),r!==i){for(n=[],a=eH();a!==i;)n.push(a),a=eH();(39===e.charCodeAt(eE)?(a="'",eE++):(a=i,0===eA&&ej(U)),a!==i)?(e$=t,t=th("String",n.join(""),e$)):(eE=t,t=i)}else eE=t,t=i;return t}function eX(){let t,r,n;if((t=to())===i&&(t=function(){let t,r,n,a,s,o;if(t=eE,92===e.charCodeAt(eE)?(r="\\",eE++):(r=i,0===eA&&ej(F)),r!==i){for(n=[],a=te();a!==i;)n.push(a),a=te();if((a=tt())!==i){for(s=[],o=tr();o!==i;)s.push(o),o=tr();e$=t,t=""}else eE=t,t=i}else eE=t,t=i;return t}())===i&&(t=eE,92===e.charCodeAt(eE)?(r="\\",eE++):(r=i,0===eA&&ej(F)),r!==i?(e.length>eE?(n=e.charAt(eE),eE++):(n=i,0===eA&&ej(B)),n!==i?t=void td("Invalid escape sequence",e$=t):(eE=t,t=i)):(eE=t,t=i),t===i)&&(t=eE,"\r\n"===e.substr(eE,2)?(r="\r\n",eE+=2):(r=i,0===eA&&ej(W)),r!==i&&(e$=t,r="\n"),(t=r)===i)){if(t=eE,r=[],n=e.charAt(eE),f.test(n)?eE++:(n=i,0===eA&&ej(q)),n!==i)for(;n!==i;)r.push(n),n=e.charAt(eE),f.test(n)?eE++:(n=i,0===eA&&ej(q));else r=i;t=r!==i?e.substring(t,eE):r}return t}function eJ(){let t,r,n,a;return t=eE,'""'===e.substr(eE,2)?(r='""',eE+=2):(r=i,0===eA&&ej(Y)),r!==i?(n=eE,eA++,34===e.charCodeAt(eE)?(a='"',eE++):(a=i,0===eA&&ej(D)),eA--,a===i?n=void 0:(eE=n,n=i),n!==i?(e$=t,t='""'):(eE=t,t=i)):(eE=t,t=i),t===i&&(t=eE,34===e.charCodeAt(eE)?(r='"',eE++):(r=i,0===eA&&ej(D)),r!==i?(n=eE,eA++,34===e.charCodeAt(eE)?(a='"',eE++):(a=i,0===eA&&ej(D)),eA--,a===i?n=void 0:(eE=n,n=i),n!==i?(e$=t,t='"'):(eE=t,t=i)):(eE=t,t=i)),t}function eG(){let t,r,n;if(t=eE,"\r\n"===e.substr(eE,2)?(r="\r\n",eE+=2):(r=i,0===eA&&ej(W)),r!==i&&(e$=t,r="\n"),(t=r)===i){if(t=eE,r=[],n=e.charAt(eE),h.test(n)?eE++:(n=i,0===eA&&ej(z)),n!==i)for(;n!==i;)r.push(n),n=e.charAt(eE),h.test(n)?eE++:(n=i,0===eA&&ej(z));else r=i;t=r!==i?e.substring(t,eE):r}return t}function eV(){let t,r,n,a;return t=eE,"''"===e.substr(eE,2)?(r="''",eE+=2):(r=i,0===eA&&ej(X)),r!==i?(n=eE,eA++,39===e.charCodeAt(eE)?(a="'",eE++):(a=i,0===eA&&ej(U)),eA--,a===i?n=void 0:(eE=n,n=i),n!==i?(e$=t,t="''"):(eE=t,t=i)):(eE=t,t=i),t===i&&(t=eE,39===e.charCodeAt(eE)?(r="'",eE++):(r=i,0===eA&&ej(U)),r!==i?(n=eE,eA++,39===e.charCodeAt(eE)?(a="'",eE++):(a=i,0===eA&&ej(U)),eA--,a===i?n=void 0:(eE=n,n=i),n!==i?(e$=t,t="'"):(eE=t,t=i)):(eE=t,t=i)),t}function eK(){let t,r,n;if((t=to())===i&&(t=eE,92===e.charCodeAt(eE)?(r="\\",eE++):(r=i,0===eA&&ej(F)),r!==i?(e.length>eE?(n=e.charAt(eE),eE++):(n=i,0===eA&&ej(B)),n!==i?t=void td("Invalid escape sequence",e$=t):(eE=t,t=i)):(eE=t,t=i),t===i)){if(t=eE,r=[],n=e.charAt(eE),p.test(n)?eE++:(n=i,0===eA&&ej(J)),n!==i)for(;n!==i;)r.push(n),n=e.charAt(eE),p.test(n)?eE++:(n=i,0===eA&&ej(J));else r=i;t=r!==i?e.substring(t,eE):r}return t}function eH(){let t,r,n;if(t=eE,r=[],n=e.charAt(eE),m.test(n)?eE++:(n=i,0===eA&&ej(G)),n!==i)for(;n!==i;)r.push(n),n=e.charAt(eE),m.test(n)?eE++:(n=i,0===eA&&ej(G));else r=i;return r!==i?e.substring(t,eE):r}function eQ(){let t,r;return t=eE,48===e.charCodeAt(eE)?(r="0",eE++):(r=i,0===eA&&ej(K)),r!==i&&(e$=t,r="0"),(t=r)===i&&(t=eE,t=(r=eZ())!==i?e.substring(t,eE):r),t}function eZ(){let t,r,n,a,s,o;if(t=eE,r=e.charAt(eE),b.test(r)?eE++:(r=i,0===eA&&ej(et)),r!==i){for(n=[],a=eE,s=e.charAt(eE),v.test(s)?eE++:(s=i,0===eA&&ej(er)),s===i&&(s=null),o=e.charAt(eE),w.test(o)?eE++:(o=i,0===eA&&ej(en)),o!==i?a=s=[s,o]:(eE=a,a=i);a!==i;)n.push(a),a=eE,s=e.charAt(eE),v.test(s)?eE++:(s=i,0===eA&&ej(er)),s===i&&(s=null),o=e.charAt(eE),w.test(o)?eE++:(o=i,0===eA&&ej(en)),o!==i?a=s=[s,o]:(eE=a,a=i);t=r=[r,n]}else eE=t,t=i;return t}function e0(){let t,r,n,a,s,o;if(t=eE,r=e.charAt(eE),w.test(r)?eE++:(r=i,0===eA&&ej(en)),r!==i){for(n=[],a=eE,s=e.charAt(eE),v.test(s)?eE++:(s=i,0===eA&&ej(er)),s===i&&(s=null),o=e.charAt(eE),w.test(o)?eE++:(o=i,0===eA&&ej(en)),o!==i?a=s=[s,o]:(eE=a,a=i);a!==i;)n.push(a),a=eE,s=e.charAt(eE),v.test(s)?eE++:(s=i,0===eA&&ej(er)),s===i&&(s=null),o=e.charAt(eE),w.test(o)?eE++:(o=i,0===eA&&ej(en)),o!==i?a=s=[s,o]:(eE=a,a=i);t=r=[r,n]}else eE=t,t=i;return t}function e1(){let e;return(e=te())===i&&(e=tt())===i&&(e=eU()),e}function e2(){let t,r,n,a,s,o;if(t=eE,(r=e3())!==i){for(n=[],a=te();a!==i;)n.push(a),a=te();if(61===e.charCodeAt(eE)?(a="=",eE++):(a=i,0===eA&&ej(M)),a!==i){for(s=[],o=te();o!==i;)s.push(o),o=te();if((o=eq())!==i)t=th("InlineTableValue",o,e$=t,r);else eE=t,t=i}else eE=t,t=i}else eE=t,t=i;return t}function e5(){let e;return(e=te())===i&&(e=tt())===i&&(e=eU()),e}function e3(){let e,t,r,n;if(e=eE,t=[],(r=e8())!==i)for(;r!==i;)t.push(r),r=e8();else t=i;if(t!==i){for(r=[],n=te();n!==i;)r.push(n),n=te();if((n=e6())!==i){var a,s;e$=e,a=t,s=n,e=a.concat(s)}else eE=e,e=i}else eE=e,e=i;return e===i&&(e=eE,(t=e6())!==i&&(e$=e,t=[t]),e=t),e}function e8(){let t,r,n,a,s;for(t=eE,r=[],n=te();n!==i;)r.push(n),n=te();if((n=e6())!==i){for(a=[],s=te();s!==i;)a.push(s),s=te();(46===e.charCodeAt(eE)?(s=".",eE++):(s=i,0===eA&&ej(A)),s!==i)?(e$=t,t=n):(eE=t,t=i)}else eE=t,t=i;return t}function e6(){let t,r,n;return(t=function(){let t,r,n;if(t=eE,r=[],(n=ts())!==i)for(;n!==i;)r.push(n),n=ts();else r=i;return r!==i?e.substring(t,eE):r}())===i&&(r=eE,(n=eY())!==i&&(e$=r,n=n.value),(r=n)===i&&(r=eE,(n=ez())!==i&&(e$=r,n=n.value),r=n),t=r),t}function e9(){let t,r,n,a,s,o,l,c,u,d,f,h;return t=eE,r=eE,(n=ti())!==i&&(a=ti())!==i&&(s=ti())!==i&&(o=ti())!==i?(45===e.charCodeAt(eE)?(l="-",eE++):(l=i,0===eA&&ej(ef)),l!==i&&(c=ti())!==i&&(u=ti())!==i?(45===e.charCodeAt(eE)?(d="-",eE++):(d=i,0===eA&&ej(ef)),d!==i&&(f=ti())!==i&&(h=ti())!==i?r=n=[n,a,s,o,l,c,u,d,f,h]:(eE=r,r=i)):(eE=r,r=i)):(eE=r,r=i),t=r!==i?e.substring(t,eE):r}function e4(){let t,r,n,a,s,o,l,c,u,d,f;if(t=eE,r=eE,n=eE,(a=ti())!==i&&(s=ti())!==i?(58===e.charCodeAt(eE)?(o=":",eE++):(o=i,0===eA&&ej(eh)),o!==i&&(l=ti())!==i&&(c=ti())!==i?(58===e.charCodeAt(eE)?(u=":",eE++):(u=i,0===eA&&ej(eh)),u!==i&&(d=ti())!==i&&(f=ti())!==i?n=a=[a,s,o,l,c,u,d,f]:(eE=n,n=i)):(eE=n,n=i)):(eE=n,n=i),(r=n!==i?e.substring(r,eE):n)!==i){var h,p;(n=function(){let t,r,n,a,s;if(t=eE,r=eE,46===e.charCodeAt(eE)?(n=".",eE++):(n=i,0===eA&&ej(A)),n!==i){if(a=[],(s=ti())!==i)for(;s!==i;)a.push(s),s=ti();else a=i;a!==i?r=n=[n,a]:(eE=r,r=i)}else eE=r,r=i;return r!==i?e.substring(t,eE):r}())===i&&(n=null),e$=t,h=r,t=(p=n)?h+p:h}else eE=t,t=i;return t===i&&((t=eE,r=eE,n=eE,(a=ti())!==i&&(s=ti())!==i?(58===e.charCodeAt(eE)?(o=":",eE++):(o=i,0===eA&&ej(eh)),o!==i&&(l=ti())!==i&&(c=ti())!==i?n=a=[a,s,o,l,c]:(eE=n,n=i)):(eE=n,n=i),(r=n!==i?e.substring(r,eE):n)!==i&&(n=eE,eA++,58===e.charCodeAt(eE)?(a=":",eE++):(a=i,0===eA&&ej(eh)),eA--,a===i?n=void 0:(eE=n,n=i),n!==i))?(e$=t,t=r+":00"):(eE=t,t=i)),t}function e7(){let t,r,n,a;return"t"===(t=e.charAt(eE)).toLowerCase()?eE++:(t=i,0===eA&&ej(em)),t===i&&(t=eE,32===e.charCodeAt(eE)?(r=" ",eE++):(r=i,0===eA&&ej(eg)),r!==i?(n=eE,eA++,a=ti(),eA--,a!==i?(eE=n,n=void 0):n=i,n!==i?t=r=[r,n]:(eE=t,t=i)):(eE=t,t=i)),t}function te(){let t;return t=e.charAt(eE),S.test(t)?eE++:(t=i,0===eA&&ej(ey)),t}function tt(){let t,r,n;return 10===e.charCodeAt(eE)?(t="\n",eE++):(t=i,0===eA&&ej(eb)),t===i&&(t=eE,13===e.charCodeAt(eE)?(r="\r",eE++):(r=i,0===eA&&ej(ev)),r!==i?(10===e.charCodeAt(eE)?(n="\n",eE++):(n=i,0===eA&&ej(eb)),n!==i?t=r=[r,n]:(eE=t,t=i)):(eE=t,t=i)),t}function tr(){let e;return(e=tt())===i&&(e=te()),e}function tn(){let t,r;return t=eE,eA++,e.length>eE?(r=e.charAt(eE),eE++):(r=i,0===eA&&ej(B)),eA--,r===i?t=void 0:(eE=t,t=i),t}function ti(){let t;return t=e.charAt(eE),w.test(t)?eE++:(t=i,0===eA&&ej(en)),t}function ta(){let t;return t=e.charAt(eE),x.test(t)?eE++:(t=i,0===eA&&ej(ei)),t}function ts(){let t;return t=e.charAt(eE),I.test(t)?eE++:(t=i,0===eA&&ej(ex)),t}function to(){let t,r,n,a,s,o,l,c,u,d,f,h,p,m,g;if(t=eE,92===e.charCodeAt(eE)?(r="\\",eE++):(r=i,0===eA&&ej(F)),r!==i)if(n=e.charAt(eE),E.test(n)?eE++:(n=i,0===eA&&ej(e_)),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 eE=t,t=i;else eE=t,t=i;return t===i&&((a=eE,"\\U"===e.substr(eE,2)?(s="\\U",eE+=2):(s=i,0===eA&&ej(ek)),s!==i&&(o=eE,l=eE,(c=ta())!==i&&(u=ta())!==i&&(d=ta())!==i&&(f=ta())!==i&&(h=ta())!==i&&(p=ta())!==i&&(m=ta())!==i&&(g=ta())!==i?l=c=[c,u,d,f,h,p,m,g]:(eE=l,l=i),(o=l!==i?e.substring(o,eE):l)!==i))?(e$=a,a=ty(o)):(eE=a,a=i),a===i&&((a=eE,"\\u"===e.substr(eE,2)?(s="\\u",eE+=2):(s=i,0===eA&&ej(eS)),s!==i&&(o=eE,l=eE,(c=ta())!==i&&(u=ta())!==i&&(d=ta())!==i&&(f=ta())!==i?l=c=[c,u,d,f]:(eE=l,l=i),(o=l!==i?e.substring(o,eE):l)!==i))?(e$=a,a=ty(o)):(eE=a,a=i),a===i&&((a=eE,"\\x"===e.substr(eE,2)?(s="\\x",eE+=2):(s=i,0===eA&&ej(eI)),s!==i&&(o=eE,l=eE,(c=ta())!==i&&(u=ta())!==i?l=c=[c,u]:(eE=l,l=i),(o=l!==i?e.substring(o,eE):l)!==i))?(e$=a,a=ty(o)):(eE=a,a=i))),t=a),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 a=[31,28,31,30,31,30,31,31,30,31,30,31];(r%4==0&&r%100!=0||r%400==0)&&(a[1]=29),(i<1||i>a[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&&eE===e.length;function tv(){var r,a,s;throw n!==i&&eE<e.length&&ej({type:"end"}),r=eT,a=eC<e.length?function(t=eE){let r=e.codePointAt(t);return void 0===r?"":String.fromCodePoint(r)}(eC):null,s=eC<e.length?eR(eC,eC+1):eR(eC,eC),new t(t.buildMessage(r,a),r,a,s)}return r.peg$library?{peg$result:n,peg$currPos:eE,peg$FAILED:i,peg$maxFailExpected:eT,peg$maxFailPos:eC,peg$success:tb,peg$throw:tb?void 0:tv}:tb?n:void tv()}}},9074(e,r,n){let i,a,s,o,l,c,u,d,f,h,p,m,g,y,b,v,w,x,_,k,S,I,E,$,O,C,T,A,M;var N,P,R,j,D,L=n(8543),U=n(7720),F=n(7598),B=n(4650);let W=(e,t)=>t(F.oJ(e)?0:L.nn(e.cause)?130:Y(L.iw(e.cause))),q="~effect/Runtime/errorExitCode",Y=e=>{if("object"==typeof e&&null!==e&&q in e){let t=e[q];if("number"==typeof t)return t}return 1},z="~effect/Runtime/errorReported",X=(a=({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,B.XY)(e=>U.yw5(e[0]),(e,t)=>{let r=t?.disableErrorReporting===!0?U.MY7(e):U.MY7(U.dGm(e,e=>L.nn(e)?U.rIH:(e=>{if("object"==typeof e&&null!==e&&z in e){let t=e[z];if("boolean"==typeof t)return t}return!0})(L.iw(e))?U.vVN(e):U.rIH));try{let e=globalThis.setInterval(B.Yi,0x7fffffff);r.addObserver(()=>{clearInterval(e)})}catch{}return a({fiber:r,teardown:t?.teardown??W})}));var J=n(5089),G=n(3717),V=n(8927),K=n(3833),H=n(995);function Q(){return Object.assign(e=>e,{option:e=>K.some(e),result:e=>H.Py(e),is:e=>!0})}var Z=n(8619),ee=n(2718);let et="~effect/platform/PlatformError";class er extends ee.rN("BadArgument"){get message(){return`${this.module}.${this.method}${this.description?`: ${this.description}`:""}`}}class en extends ee.$D{get message(){return`${this._tag}: ${this.module}.${this.method}${void 0!==this.pathOrDescriptor?` (${this.pathOrDescriptor})`:""}${this.description?`: ${this.description}`:""}`}}class ei extends ee.rN("PlatformError"){constructor(e){"cause"in e?super({reason:e,cause:e.cause}):super({reason:e})}[et]=et;get message(){return this.reason.message}}let ea=e=>new ei(new en(e)),es=e=>new ei(new er(e));var eo=n(9138),el=n(5369),ec=n(4505),eu=n(8433),ed=n(1136);let ef=Symbol.for("effect/MutableList/Empty"),eh=()=>({array:[],mutable:!0,offset:0,next:void 0}),ep=(e,t)=>{e.tail?e.tail.mutable||(e.tail.next=eh(),e.tail=e.tail.next):e.head=e.tail=eh(),e.tail.array.push(t),e.length++},em=e=>{e.head=e.tail=void 0,e.length=0},eg=e=>{if(!e.head)return ef;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:em(e)),t},ey={_A:B.D_,_E:B.D_},eb={"~effect/Queue":ey,"~effect/Queue/Enqueue":ey,"~effect/Queue/Dequeue":ey,...eu.fU,toJSON(){return{_id:"effect/Queue",state:this.state._tag,size:eT(this)}}},ev=e=>eu.R6(t=>{let r=Object.create(eb);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},ed.PyW(r)}),ew=(e,t)=>ed.DYE(()=>{if("Open"!==e.state._tag)return eA;if(e.messages.length>=e.capacity)switch(e.strategy){case"dropping":return eA;case"suspend":if(e.capacity<=0&&e.state.takers.size>0)return ep(e.messages,t),eR(e),eM;return eL(e,t);case"sliding":return eg(e.messages),ep(e.messages,t),eM}return ep(e.messages,t),ej(e),eM}),ex=(e,t)=>"Open"===e.state._tag&&(e.messages.length>=e.capacity?"sliding"===e.strategy?(eg(e.messages),ep(e.messages,t),!0):e.capacity<=0&&e.state.takers.size>0&&(ep(e.messages,t),eR(e),!0):(ep(e.messages,t),ej(e),!0)),e_=(0,B.XY)(2,(e,t)=>ed.OH5(()=>ek(e,t))),ek=(e,t)=>{if("Open"!==e.state._tag)return!1;let r=eu.cb(t),n=ed.il9(r,eN);return 0===e.state.offers.size&&0===e.messages.length?eB(e,n):e.state={...e.state,_tag:"Closing",exit:n},!0},eS=e=>ek(e,eu.OE(eu.RS())),eI=e=>ed.OH5(()=>{if("Done"===e.state._tag)return!0;em(e.messages);let t=e.state.offers;if(eB(e,"Open"===e.state._tag?eP:e.state.exit),t.size>0){for(let e of t)"Single"===e._tag?e.resume(eA):e.resume(eu.xt(e.remaining.slice(e.offset)));t.clear()}return!0}),eE=e=>e$(e,1,1/0),e$=(e,t,r)=>ed.DYE(()=>eD(e,t,r)??ed.hgn(eF(e),e$(e,1,r))),eO=e=>ed.DYE(()=>eC(e)??ed.hgn(eF(e),eO(e))),eC=e=>{if("Done"===e.state._tag)return e.state.exit;if(e.messages.length>0){let t=eg(e.messages);return eU(e),eu.xt(t)}if(e.capacity<=0&&e.state.offers.size>0){e.capacity=1,eU(e),e.capacity=0;let t=eg(e.messages);return eU(e),eu.xt(t)}},eT=e=>"Done"===e.state._tag?0:e.messages.length,eA=eu.xt(!1),eM=eu.xt(!0),eN=eu.Rk(eu.RS()),eP=ed._sz(),eR=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(ed.x5l),0===e.messages.length)break}},ej=e=>{e.scheduleRunning||"Done"===e.state._tag||0===e.state.takers.size||(e.scheduleRunning=!0,e.dispatcher.scheduleTask(()=>eR(e),0))},eD=(e,t,r)=>{if("Done"===e.state._tag)return e.state.exit;if(r<=0||t<=0)return eu.xt([]);if(e.capacity<=0&&e.state.offers.size>0){e.capacity=1,eU(e),e.capacity=0;let t=[eg(e.messages)];return eU(e),eu.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 em(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&&em(e),r;i=i.next}return em(e),r})(e.messages,r);return eU(e),eu.xt(t)}},eL=(e,t)=>ed.E2r(r=>{if("Open"!==e.state._tag)return r(eA);let n={_tag:"Single",message:t,resume:r};return e.state.offers.add(n),ed.OH5(()=>{"Open"===e.state._tag&&e.state.offers.delete(n)})}),eU=e=>{if("Done"===e.state._tag)return ec.Og(e.state.exit.cause);if(0===e.state.offers.size)return"Closing"===e.state._tag&&0===e.messages.length&&(eB(e,e.state.exit),ec.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)ep(e.messages,r.message),t--,r.resume(eM),e.state.offers.delete(r);else{for(;r.offset<r.remaining.length;r.offset++){if(0===t)return!1;ep(e.messages,r.remaining[r.offset]),t--}r.resume(eu.xt([])),e.state.offers.delete(r)}return!1},eF=e=>ed.E2r(t=>"Done"===e.state._tag?t(e.state.exit):(e.state.takers.add(t),ed.OH5(()=>{"Done"!==e.state._tag&&e.state.takers.delete(t)}))),eB=(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 eW=n(2672);let eq="~effect/Channel",eY=e=>(0,el.i5)(e,eq),ez={[eq]:{_Env:B.D_,_InErr:B.D_,_InElem:B.D_,_OutErr:B.D_,_OutElem:B.D_},pipe(){return(0,eo.tT)(this,arguments)}},eX=e=>{let t=Object.create(ez);return t.transform=(t,r)=>U.Tyx(e(t,r),e=>U.PyW(U.ATB(e))),t},eJ=(e,t)=>eX((r,n)=>U.qIB(eV(e)(r,n),e=>t(e,n))),eG=e=>eX((t,r)=>e),eV=e=>e.transform,eK=eG(U.PyW(L.Vw()));U.ZmZ;let eH=(0,B.XY)(2,(e,t)=>eJ(e,e=>U.OH5(()=>{let r=0;return U.TjK(e,e=>t(e,r++))}))),eQ=(0,B.XY)(2,(e,t)=>eZ(e,e=>U.PyW(t(e)))),eZ=(0,B.XY)(2,(e,t)=>eJ(e,e=>U.PyW(ec.m8(e,e=>U.qIB(t(e),L.Vw))))),e0=(0,B.XY)(e=>eY(e[0])&&eY(e[1]),(e,t,r)=>{let n;return n=U.D9k(function*(n,i,a){let s=r?.haltStrategy??"both",o=yield*ev({capacity:0});yield*eW.U9(a,eI(o));let l=0,c=(e,t,r)=>eV(t)(n,r).pipe(U.qIB(e=>e.pipe(U.qIB(e=>ew(o,e)),U.i4r)),U.S5A(t=>U.hgn(eW.VN(r,ec.aU(t)),function(e,t){if(l++,!ec.Og(t))return e_(o,t);switch(s){case"both":return 2===l?e_(o,t):U.rIH;case"left":case"right":return e===s?e_(o,t):U.rIH;case"either":return e_(o,t)}}(e,t))),U.ar0(a));return yield*c("left",e,eW.Fp(a)),yield*c("right",t,eW.Fp(a)),eO(o)}),eX(U.D9k(function*(e,t){let r=eW.Fp(t),i=e=>eW.VN(r,ec.aU(e)),a=yield*U.S5A(n(e,t,r),i);return U.S5A(a,i)}))}),e1=(0,B.XY)(2,(e,t)=>eX((r,n)=>U.qIB(eV(e)(r,n),e=>eV(t)(e,n)))),e2=e=>eX((t,r)=>{let n;return U.PyW(U.DYE(()=>n||e.pipe(eW.Gt(r),U.qIB(e=>eV(e)(t,r)),U.qIB(e=>n=e))))}),e5=(e,t,r)=>U.DYE(()=>{let n=eW.LZ(),i=eV(e)(L.Vw(),n);return ec.m8(U.qIB(i,t),r||U.PyW).pipe(U.cfM(e=>eW.VN(n,e)))}),e3=(0,B.XY)(2,(e,t)=>e5(e,e=>U.i4r(U.qIB(e,t),{disableYield:!0}))),e8=(0,B.XY)(3,(e,t,r)=>U.DYE(()=>{let n=t();return e5(e,e=>U.iMI({while:B.ue,body:()=>e,step:e=>{n=r(n,e)}}),()=>U.PyW(n))})),e6=(0,B.XY)(3,(e,t,r)=>U.DYE(()=>{let n=t();return e5(e,e=>U.iMI({while:B.ue,body:(0,B.dY)(e.pipe(U.qIB(e=>r(n,e)),U.TjK(e=>{n=e}))),step:B.Yi}),()=>U.PyW(n))})),e9=(e,t)=>eV(e)(L.Vw(),t),e4="~effect/Sink",e7=U.PyW([void 0]),te={[e4]:{_A:B.D_,_In:B.D_,_L:B.D_,_E:B.D_,_R:B.D_},pipe(){return(0,eo.tT)(this,arguments)}},tt=e=>(0,el.i5)(e,e4),tr=e=>tn((t,r)=>eV(e)(t,r).pipe(U.qIB(U.i4r({disableYield:!0})),ec.m8(U.PyW))),tn=e=>{let t=Object.create(te);return t.transform=e,t},ti=e=>eX((t,r)=>U.PyW(U.qIB(e.transform(t,r),L.Vw)));U.ZmZ;let ta=tn(e=>ec.m8(U.i4r(e,{disableYield:!0}),()=>e7));K.none,K.isNone,K.none;let ts=e=>tr(e2(U.TjK(e,ti))),to={"~effect/Stream":{_R:B.D_,_E:B.D_,_A:B.D_},pipe(){return(0,eo.tT)(this,arguments)}},tl=e=>(0,el.i5)(e,"~effect/Stream"),tc=e=>{let t=Object.create(to);return t.channel=e,t},tu=e=>e.channel,td=tc(eK),tf=e=>{let t;return tc((t=()=>e().channel,eX((e,r)=>U.DYE(()=>eV(t())(e,r)))))},th=e=>{let t;return V.ET(e)?tc((t=U.PyW(e),eG(U.OH5(()=>{let e=!1;return U.DYE(()=>e?L.Vw():(e=!0,t))})))):td},tp=e=>tc(e2(U.TjK(e,tu))),tm=(0,B.XY)(2,(e,t)=>tf(()=>{let r=0;return tc(eH(e.channel,V.Tj(e=>t(e,r++))))})),tg=(0,B.XY)(e=>tl(e[0])&&tl(e[1]),(e,t,r)=>tc(e0(tu(e),tu(t),r))),ty=(0,B.XY)(2,(e,t)=>{let r;return r=(e,r)=>U.OH5(()=>{let n,i,a=U.DYE(()=>{if(void 0!==i){let e=i;return i=void 0,U.PyW(e)}return e}).pipe(U.MfU(e=>(n=F.fJ(e),L.Vw()))),s=U.TjK(U.DYE(()=>t.transform(a,r)),([e,t])=>(i=t,V.of(e)));return U.DYE(()=>n||s)}),tc(eX((t,n)=>U.qIB(e9(e.channel,n),e=>r(e,n))))}),tb=(0,B.XY)(e=>tl(e[0]),(e,t)=>tf(()=>{let r=new TextDecoder(t?.encoding);return tm(e,e=>r.decode(e,{stream:!0}))})),tv=(0,B.XY)(2,(e,t)=>U.Pxi(r=>e9(e.channel,r).pipe(U.qIB(e=>t.transform(e,r)),U.TjK(([e])=>e)))),tw=(0,B.XY)(3,(e,t,r)=>e6(e.channel,t,(e,t)=>{let n=0,i=e;return U.TjK(U.iMI({while:()=>n<t.length,body:()=>r(i,t[n]),step(e){i=e,n++}}),()=>i)})),tx=((e,t)=>e3(e.channel,t),"~effect/platform/FileSystem"),t_=e=>"bigint"==typeof e?e:BigInt(e),tk=Z.kl("effect/platform/FileSystem"),tS="~effect/platform/FileSystem/File",tI=Q();class tE extends Z.kl()("effect/platform/FileSystem/WatchBackend"){}let t$="~effect/platform/Path",tO=Z.kl("effect/Path");var tC=n(3267),tT=n(6400);let tA=Q(),tM=Q(),tN="~effect/ChildProcessSpawner/ChildProcessHandle",tP={[tN]:tN,...tT.os,toJSON(){return{_id:"ChildProcessHandle",pid:this.pid}}},tR=e=>Object.assign(Object.create(tP),e);class tj extends Z.kl()("effect/process/ChildProcessSpawner"){}let tD="~effect/unstable/process/ChildProcess",tL={...tC.b({label:"Command",evaluate(e){return Z.fp(e.context,tj).spawn(this)}}),[tD]:tD},tU=(e,t,r)=>Object.assign(Object.create(tL),{_tag:"StandardCommand",command:e,args:t,options:r}),tF=function(...e){if(tB(e[0])){let[t,...r]=e,n=tY(t,r);return tU(n[0]??"",n.slice(1),{})}if("object"==typeof e[0]&&!Array.isArray(e[0])&&!tB(e[0])){let t=e[0];return function(e,...r){let n=tY(e,r);return tU(n[0]??"",n.slice(1),t)}}if("string"==typeof e[0]&&!Array.isArray(e[1])){let[t,r={}]=e;return tU(t,[],r)}let[t,r=[],n={}]=e;return tU(t,r,n)},tB=e=>Array.isArray(e)&&"raw"in e&&Array.isArray(e.raw),tW=e=>{let t=/^fd(\d+)$/.exec(e);if(null===t)return;let r=parseInt(t[1],10);return r>=3?r:void 0},tq=e=>`fd${e}`,tY=(e,t)=>{let r=[];for(let[n,i]of e.entries())r=tz(e,t,r,i,n);return r},tz=(e,t,r,n,i)=>{let a=e.raw[i];if(void 0===a)throw Error(`Invalid backslash sequence: ${e.raw[i]}`);let{hasLeadingWhitespace:s,hasTrailingWhitespace:o,tokens:l}=tV(n,a),c=tK(r,l,s);if(i===t.length)return c;let u=t[i];return tK(c,Array.isArray(u)?u.map(e=>tX(e)):[tX(u)],o)},tX=e=>"string"==typeof e?e:String(e),tJ=new Set([" "," ","\r","\n"]),tG={x:3,u:5},tV=(e,t)=>{if(0===t.length)return{tokens:[],hasLeadingWhitespace:!1,hasTrailingWhitespace:!1};let r=tJ.has(t[0]),n=[],i=0;for(let r=0,a=0;r<e.length;r+=1,a+=1){let s=t[a];if(tJ.has(s))i!==r&&n.push(e.slice(i,r)),i=r+1;else if("\\"===s){let e=t[a+1];"\n"===e?(r-=1,a+=1):"u"===e&&"{"===t[a+2]?a=t.indexOf("}",a+3):a+=tG[e]??1}}let a=i===e.length;return a||n.push(e.slice(i)),{tokens:n,hasLeadingWhitespace:r,hasTrailingWhitespace:a}},tK=(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)],tH=t("node:child_process"),tQ=t("node:stream"),tZ=(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 ea({_tag:i,module:e,method:t,pathOrDescriptor:n,syscall:r.syscall,cause:r})},t0=e=>tr(eQ(t1(e),e=>[e])),t1=e=>eX(t=>{let r=e.evaluate();return U.PyW(t2({...e,writable:r,pull:t}))}),t2=e=>e.pull.pipe(U.qIB(t=>{let r=0;return U.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(U.rIH)})}),U.i4r({disableYield:!0}),U.KT6(U.E2r(t=>{let r=r=>t(U.fJG(e.onError(r)));return e.writable.once("error",r),U.OH5(()=>{e.writable.off("error",r)})})),!1!==e.endOnDone?ec.m8(t=>"closed"in e.writable&&e.writable.closed?L.Vw(t):U.E2r(r=>{e.writable.once("finish",()=>r(L.Vw(t))),e.writable.end()})):B.D_);ed.zFM,ed.C6p,ed.D7p,ed.INJ;let t5=ed.mKq;ed.eGS,ed.DKo,ed.$MQ,ed.Iku;let t3=ed.vTQ,t8=ed.zzk;ed.Fbb;let t6="~effect/MutableRef",t9={[t6]:t6,...eu.fU,toJSON(){return{_id:"MutableRef",current:(0,tT.aB)(this.current)}}},t4=e=>tc(t7(e)),t7=e=>eX((t,r)=>re({scope:r,readable:e.evaluate(),onError:e.onError??rt,chunkSize:e.chunkSize,closeOnDone:e.closeOnDone})),re=e=>{var t;let r,n=e.readable,i=e.closeOnDone??!0,a=e.exit??(t=void 0,(r=Object.create(t9)).current=t,r),s=t8(!1);function o(){s.openUnsafe()}function l(t){a.current=F.fJ(e.onError(t)),s.openUnsafe()}function c(){a.current=F.fJ(L.RS()),s.openUnsafe()}n.on("readable",o),n.once("error",l),n.once("end",c);let u=U.DYE(function t(){let r=e.readable.read(e.chunkSize);if(null===r)return a.current?a.current:n.readableEnded?U.fJG(L.RS()):(s.closeUnsafe(),U.qIB(s.await,t));let i=V.of(r);for(;null!==(r=e.readable.read(e.chunkSize));)i.push(r);return U.PyW(i)});return U.as(eW.U9(e.scope,U.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)};tQ.Readable;let rt=e=>new L.Bk(e),rr=e=>e instanceof globalThis.Error?e:new globalThis.Error(String(e)),rn=(e,t,r)=>{let{commands:n}=rs(r),i=n.reduce((e,t)=>{let r=`${t.command} ${t.args.join(" ")}`;return 0===e.length?r:`${e} | ${r}`},"");return tZ("ChildProcess",e)(t,[i])},ri=U.JkU(function*(){let e,t,r=yield*tk,n=yield*tO,i=U.D9k(function*(e){if(!el.b0(e.cwd))return yield*r.access(e.cwd),n.resolve(e.cwd)}),a=e=>tt(e)?"pipe":e,s=e=>{let t={stream:"pipe",encoding:"utf-8",endOnDone:!0};return el.b0(e.stdin)?t:"string"==typeof e.stdin||tl(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 el.b0(r)?{stream:"pipe"}:"string"==typeof r||tt(r)?{stream:r}:{stream:r.stream}},l=U.D9k(function*(e,t,r){if(0===r.length)return{getInputFd:()=>ta,getOutputFd:()=>td};let n=new Map,i=new Map;for(let{config:a,fd:s}of r){let r=t.stdio[s];switch(a.type){case"input":{let t=ta;r&&"write"in r&&(t=t0({evaluate:()=>r,onError:t=>rn(`fromWritable(fd${s})`,rr(t),e)})),a.stream&&(yield*U.x6Z(tv(a.stream,t))),n.set(s,t);break}case"output":{let t=td;if(r&&"read"in r){let n=new tQ.PassThrough;r.on("error",e=>n.destroy(e)),r.pipe(n),t=t4({evaluate:()=>n,onError:t=>rn(`fromReadable(fd${s})`,rr(t),e)})}a.sink&&(t=ty(t,a.sink)),i.set(s,t)}}}return{getInputFd:e=>n.get(e)??ta,getOutputFd:e=>i.get(e)??td}}),c=(e,t,r)=>"win32"===globalThis.process.platform?U.E2r(r=>{tH.exec(`taskkill /pid ${t.pid} /T /F`,t=>{t?r(U.fJG(rn("kill",rr(t),e))):r(U.rIH)})}):U.SvU({try:()=>{globalThis.process.kill(-t.pid,r)},catch:t=>rn("kill",rr(t),e)}),u=(e,t,r)=>U.DYE(()=>{if(!t.kill(r)){let t=new globalThis.Error("Failed to kill child process");return U.fJG(rn("kill",t,e))}return U.rIH}),d=(e,t,r)=>n=>{let i=r?.killSignal??"SIGTERM";return el.b0(r?.forceKillAfter)?n(t,e,i):U.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=tW(r);if(el.EA(t))return e.getOutputFd(t);return e.stdout}}},h=U.D9k(function*(e){switch(e._tag){case"StandardCommand":{let t,r,n,f,h,p,m,g=s(e.options),y=o(e.options,"stdout"),b=o(e.options,"stderr"),v=(e=>{if(el.b0(e.additionalFds))return[];let t=[];for(let[r,n]of Object.entries(e.additionalFds)){let e=tW(r);el.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),_=(t=e.options).extendEnv?{...globalThis.process.env,...t.env}:t.env,k=((e,t,r,n)=>{let i,s=[tl(i=e.stream)?"pipe":i,a(t.stream),a(r.stream)];if(0===n.length)return s;let o=n.reduce((e,{fd:t})=>Math.max(e,t),2);for(let e=3;e<=o;e++)s[e]="ignore";for(let{fd:e}of n)s[e]="pipe";return s})(g,y,b,v),[S,I]=yield*U.Q56((r={cwd:x,env:_,stdio:k,detached:e.options.detached??"win32"!==process.platform,shell:e.options.shell},U.E2r(t=>{let n=G.LZ(),i=tH.spawn(e.command,e.args,r);return i.on("error",r=>{t(U.fJG(rn("spawn",r,e)))}),i.on("exit",(...e)=>{G.$w(n,F.Py(e))}),i.on("spawn",()=>{t(U.PyW([i,n]))}),U.OH5(()=>{i.kill("SIGTERM")})})),U.D9k(function*([t,r]){let n=yield*G.$L(r),i=d(t,e,e.options);if(n){let[e]=yield*G.Tx(r);return 0!==e&&el.Pe(e)?yield*U.XeO(i(c)):yield*U.rIH}return w?yield*i((e,t,n)=>c(e,t,n).pipe(U.MfU(()=>u(e,t,n)),U.hgn(G.Tx(r)))).pipe(U.XeO):yield*U.rIH})),E=tM(S.pid);S.on("exit",t=>{0!==t&&el.Pe(t)&&((e,t)=>{if("win32"===globalThis.process.platform)return tH.exec(`taskkill /pid ${e.pid} /T /F`,()=>{});try{globalThis.process.kill(-e.pid,t)}catch{}})(S,e.options.killSignal??"SIGTERM")});let $=U.OH5(()=>{w||(S.ref(),w=!0)}),O=U.OH5(()=>(w&&(S.unref(),w=!1),$)),C=yield*U.DYE(()=>{let t=ta;return(el.Pe(S.stdin)&&(t=t0({evaluate:()=>S.stdin,onError:t=>rn("fromWritable(stdin)",rr(t),e),endOnDone:g.endOnDone,encoding:g.encoding})),tl(g.stream))?U.as(U.x6Z(tv(g.stream,t)),t):U.PyW(t)}),{all:T,stderr:A,stdout:M}=(f=S.stdout?(n=new tQ.PassThrough,S.stdout.on("error",e=>n.destroy(e)),S.stdout.pipe(n),t4({evaluate:()=>n,onError:t=>rn("fromReadable(stdout)",rr(t),e)})):td,p=S.stderr?(h=new tQ.PassThrough,S.stderr.on("error",e=>h.destroy(e)),S.stderr.pipe(h),t4({evaluate:()=>h,onError:t=>rn("fromReadable(stderr)",rr(t),e)})):td,tt(y.stream)&&(f=ty(f,y.stream)),tt(b.stream)&&(p=ty(p,b.stream)),m=tg(f,p),{stdout:f,stderr:p,all:m}),{getInputFd:N,getOutputFd:P}=yield*l(e,S,v),R=U.TjK(G.$L(I),e=>!e);return tR({pid:E,exitCode:U.qIB(G.Tx(I),([t,r])=>{if(el.Pe(t))return U.PyW(tA(t));let n=new globalThis.Error(`Process interrupted due to receipt of signal: '${r}'`);return U.fJG(rn("exitCode",n,e))}),isRunning:R,kill:t=>d(S,e,t)((e,t,r)=>c(e,t,r).pipe(U.MfU(()=>u(e,t,r)),U.hgn(G.Tx(I)))).pipe(U.NLW),stdin:C,stdout:M,stderr:A,all:T,getInputFd:N,getOutputFd:P,unref:O})}case"PipedCommand":{let{commands:t,pipeOptions:r}=rs(e),[n,...i]=t,a=[(yield*h(n))];for(let e=0;e<i.length;e++){let t=i[e],n=r[e]??{},o=s(t.options),l=tp(U.PyW(f(a[a.length-1],n.from))),c=n.to??"stdin";if("stdin"===c)a.push((yield*h(tF(t.command,t.args,{...t.options,stdin:{...o,stream:l}}))));else{let e=tW(c);if(el.EA(e)){let r=tq(e),n=t.options.additionalFds??{};a.push((yield*h(tF(t.command,t.args,{...t.options,additionalFds:{...n,[r]:{type:"input",stream:l}}}))))}else a.push((yield*h(tF(t.command,t.args,{...t.options,stdin:{...o,stream:l}}))))}}let o=a[a.length-1],l=U.JkU(function*(){let e=[];for(let t of a)e.push((yield*t.unref));return U.jJl([...e].reverse(),e=>e,{discard:!0})});return tR({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(U.TjK(e=>tb(t?.includeStderr===!0?e.all:e.stdout)),tp),t=(t,r)=>e(t,r).channel.pipe(e1(eX((e,t)=>U.OH5(()=>{let t="",r=!1,n=K.none(),i=U.DYE(()=>"Some"===n._tag?L.Vw(n.value):ec.tv(e,{onSuccess:a,onFailure:U.ATB,onDone:e=>{if(n=K.some(e),t.length>0||r){let e=t;return t="",r=!1,U.PyW([e])}return L.Vw(e)}}));function a(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 a=e[n];if(0!==a.length){let e=0,n=a.indexOf("\r"),s=a.indexOf("\n");for(r&&(0===s?(i(""),e=1,s=a.indexOf("\n",e)):i(""),r=!1);-1!==n||-1!==s;)-1===n||-1!==s&&s<n?(i(a.substring(e,s)),e=s+1,s=a.indexOf("\n",e)):a.length===n+1?(r=!0,n=-1):(i(a.substring(e,n)),e=n+(s===n+1?2:1),n=a.indexOf("\r",e),s=a.indexOf("\n",e));t+=a.substring(e,a.length-!!r)}}return V.ET(n)?n:null}(e);return null!==n?U.PyW(n):i}return i}))),tc),tj.of({spawn:h,exitCode:e=>U.P1j(U.qIB(h(e),e=>e.exitCode)),streamString:e,streamLines:t,lines:(e,r)=>e8(t(e,r).channel,()=>[],(e,t)=>{for(let r=0;r<t.length;r++)e.push(t[r]);return e}),string:(t,r)=>e8(e(t,r).channel,()=>"",(e,t)=>e+t.join(""))})}),ra=J.QZ(tj,ri),rs=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,...a]=t;return{commands:[i,...a],pipeOptions:r}},ro="~effect/platform/Crypto",rl=Z.kl("effect/Crypto"),rc=e=>e.toString(16).padStart(2,"0"),ru=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,rc).join("")).join("-"),rd=0x1000000000000-1,rf=t("node:crypto"),rh=(s=(j={randomBytes:rf.randomBytes,digest:(e,t)=>U.SvU({try:()=>Uint8Array.from(rf.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=>ea({module:"Crypto",method:"digest",_tag:"Unknown",description:"Could not compute digest",cause:e})})}).randomBytes,o=()=>{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},l=()=>Math.floor(o()*(Number.MAX_SAFE_INTEGER-Number.MIN_SAFE_INTEGER+1))+Number.MIN_SAFE_INTEGER,rl.of({[ro]:ro,randomBytes:e=>{let t,r;return U.TjK((t="randomBytes",Number.isSafeInteger(r=e)&&r>=0?U.PyW(r):U.fJG(es({module:"Crypto",method:t,description:"size must be a non-negative safe integer"}))),s)},nextDoubleUnsafe:o,nextIntUnsafe:l,digest:j.digest,random:U.OH5(()=>o()),randomBoolean:U.OH5(()=>o()>.5),randomInt:U.OH5(()=>l()),randomBetween:(e,t)=>U.OH5(()=>o()*(t-e)+e),randomIntBetween(e,t,r){let n=+(r?.halfOpen!==!0);return U.OH5(()=>{let r=Math.ceil(e),i=Math.floor(t);return Math.floor(o()*(i-r+n))+r})},randomShuffle:e=>U.OH5(()=>{let t=Array.from(e);for(let e=t.length-1;e>=1;e-=1){let r=Math.min(e,Math.floor(o()*(e+1))),n=t[e];t[e]=t[r],t[r]=n}return t}),randomUUIDv4:U.OH5(()=>{let e;return(e=s(16))[6]=15&e[6]|64,e[8]=63&e[8]|128,ru(e)}),randomUUIDv7:U.RKA(e=>{var t,r;let n;return U.PyW((t=e.currentTimeMillisUnsafe(),r=s(16),n=Math.min(Math.max(0,Math.trunc(t)),rd),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,ru(r)))})})),rp=J.Py(rl,rh),rm=t("node:fs"),rg=t("node:os"),ry=t("node:path");var rb=n.t(ry,2);let rv=e=>t=>es({module:"FileSystem",method:e,description:t.message??String(t)}),rw=(c=(0,U._r7)(rm.access,tZ("FileSystem","access"),rv("access")),(e,t)=>{let r=rm.constants.F_OK;return t?.readable&&(r|=rm.constants.R_OK),t?.writable&&(r|=rm.constants.W_OK),c(e,r)}),rx=(u=(0,U._r7)(rm.cp,tZ("FileSystem","copy"),rv("copy")),(e,t,r)=>u(e,t,{force:r?.overwrite??!1,preserveTimestamps:r?.preserveTimestamps??!1,recursive:!0})),r_=(d=(0,U._r7)(rm.copyFile,tZ("FileSystem","copyFile"),rv("copyFile")),(e,t)=>d(e,t)),rk=(f=(0,U._r7)(rm.chmod,tZ("FileSystem","chmod"),rv("chmod")),(e,t)=>f(e,t)),rS=(h=(0,U._r7)(rm.chown,tZ("FileSystem","chown"),rv("chown")),(e,t,r)=>h(e,t,r)),rI=(p=(0,U._r7)(rm.glob,tZ("FileSystem","glob"),rv("glob")),(e,t)=>p(e,{cwd:t?.root,exclude:t?.exclude})),rE=(m=(0,U._r7)(rm.link,tZ("FileSystem","link"),rv("link")),(e,t)=>m(e,t)),r$=(g=(0,U._r7)(rm.mkdir,tZ("FileSystem","makeDirectory"),rv("makeDirectory")),(e,t)=>g(e,{recursive:t?.recursive??!1,mode:t?.mode})),rO=e=>{let t=(0,U._r7)(rm.mkdtemp,tZ("FileSystem",e),rv(e));return e=>U.DYE(()=>{let r=e?.prefix??"",n="string"==typeof e?.directory?ry.join(e.directory,"."):rg.tmpdir();return t(r?ry.join(n,r):n+"/")})},rC=rO("makeTempDirectory"),rT=e=>{let t=(0,U._r7)(rm.rm,tZ("FileSystem",e),rv(e));return(e,r)=>t(e,{recursive:r?.recursive??!1,force:r?.force??!1})},rA=rT("remove"),rM=(y=rO("makeTempDirectoryScoped"),b=rT("makeTempDirectoryScoped"),e=>U.Q56(y(e),e=>U.QgK(b(e,{recursive:!0})))),rN=(D="open",v=(0,U._r7)(rm.open,tZ("FileSystem",D),rv(D)),w=(0,U._r7)(rm.close,tZ("FileSystem",D),rv(D)),(e,t)=>(0,B.Fs)(U.Q56(v(e,t?.flag??"r",t?.mode),e=>U.QgK(w(e))),U.TjK(e=>rP(tI(e),t?.flag?.startsWith("a")??!1)))),rP=(()=>{let e=e=>(0,U._r7)(rm.read,tZ("FileSystem",e),rv(e)),t=e("read"),r=e("readAlloc"),n=(0,U._r7)(rm.fstat,tZ("FileSystem","stat"),rv("stat")),i=(0,U._r7)(rm.ftruncate,tZ("FileSystem","truncate"),rv("truncate")),a=(0,U._r7)(rm.fsync,tZ("FileSystem","sync"),rv("sync")),s=e=>(0,U._r7)(rm.write,tZ("FileSystem",e),rv(e)),o=s("write"),l=s("writeAll");class c{[tS];fd;append;position=BigInt(0);constructor(e,t){this[tS]=tS,this.fd=e,this.append=t}get stat(){return U.TjK(n(this.fd),rq)}get sync(){return a(this.fd)}seek(e,t){let r=t_(e);return U.OH5(()=>("start"===t?this.position=r:"current"===t&&(this.position=this.position+r),this.position))}read(e){return U.DYE(()=>{let r=this.position;return U.TjK(t(this.fd,{buffer:e,position:r}),e=>{let t=t_(e);return this.position=r+t,t})})}readAlloc(e){let t=Number(e);return U.DYE(()=>{let e=Buffer.allocUnsafeSlow(t),n=this.position;return U.TjK(r(this.fd,{buffer:e,position:n}),r=>{if(0===r)return K.none();if(this.position=n+BigInt(r),r===t)return K.some(e);let i=Buffer.allocUnsafeSlow(r);return e.copy(i,0,0,r),K.some(i)})})}truncate(e){return U.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 U.DYE(()=>{let t=this.position;return U.TjK(o(this.fd,e,void 0,void 0,this.append?void 0:Number(t)),e=>{let r=t_(e);return this.append||(this.position=t+r),r})})}writeAllChunk(e){return U.DYE(()=>{let t=this.position;return U.qIB(l(this.fd,e,void 0,void 0,this.append?void 0:Number(t)),r=>0===r?U.fJG(ea({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)):U.rIH))})}writeAll(e){return this.writeAllChunk(e)}}return(e,t)=>new c(e,t)})(),rR=e=>{let t=rO(e);return U.D9k(function*(e){let r=yield*t(e),n=rf.randomBytes(6).toString("hex"),i=ry.join(r,e?.suffix?`${n}${e.suffix}`:n);return yield*rG(i,new Uint8Array(0)),i})},rj=rR("makeTempFile"),rD=(x=rR("makeTempFileScoped"),_=rT("makeTempFileScoped"),e=>U.Q56(x(e),e=>U.QgK(_(ry.dirname(e),{recursive:!0})))),rL=(e,t)=>U.$mh({try:()=>rm.promises.readdir(e,t),catch:t=>tZ("FileSystem","readDirectory")(t,[e])}),rU=e=>U.E2r((t,r)=>{try{rm.readFile(e,{signal:r},(r,n)=>{r?t(U.fJG(tZ("FileSystem","readFile")(r,[e]))):t(U.PyW(n))})}catch(e){t(U.fJG(rv("readFile")(e)))}}),rF=(k=(0,U._r7)(rm.readlink,tZ("FileSystem","readLink"),rv("readLink")),e=>k(e)),rB=(S=(0,U._r7)(rm.realpath,tZ("FileSystem","realPath"),rv("realPath")),e=>S(e)),rW=(I=(0,U._r7)(rm.rename,tZ("FileSystem","rename"),rv("rename")),(e,t)=>I(e,t)),rq=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:K.fromNullishOr(e.mtime),atime:K.fromNullishOr(e.atime),birthtime:K.fromNullishOr(e.birthtime),dev:e.dev,rdev:K.fromNullishOr(e.rdev),ino:K.fromNullishOr(e.ino),mode:e.mode,nlink:K.fromNullishOr(e.nlink),uid:K.fromNullishOr(e.uid),gid:K.fromNullishOr(e.gid),size:t_(e.size),blksize:void 0!==e.blksize?K.some(t_(e.blksize)):K.none(),blocks:K.fromNullishOr(e.blocks)}),rY=(E=(0,U._r7)(rm.stat,tZ("FileSystem","stat"),rv("stat")),e=>U.TjK(E(e),rq)),rz=($=(0,U._r7)(rm.symlink,tZ("FileSystem","symlink"),rv("symlink")),(e,t)=>$(e,t)),rX=(O=(0,U._r7)(rm.truncate,tZ("FileSystem","truncate"),rv("truncate")),(e,t)=>O(e,void 0!==t?Number(t):void 0)),rJ=(C=(0,U._r7)(rm.utimes,tZ("FileSystem","utime"),rv("utime")),(e,t,r)=>C(e,t,r)),rG=(e,t,r)=>U.E2r((n,i)=>{try{rm.writeFile(e,t,{signal:i,flag:r?.flag,mode:r?.mode},t=>{t?n(U.fJG(tZ("FileSystem","writeFile")(t,[e]))):n(U.rIH)})}catch(e){n(U.fJG(rv("writeFile")(e)))}}),rV=U.TjK(U.Nav(tE),e=>{let t;return t={access:rw,chmod:rk,chown:rS,copy:rx,copyFile:r_,glob:rI,link:rE,makeDirectory:r$,makeTempDirectory:rC,makeTempDirectoryScoped:rM,makeTempFile:rj,makeTempFileScoped:rD,open:rN,readDirectory:rL,readFile:rU,readLink:rF,realPath:rB,remove:rA,rename:rW,stat:rY,symlink:rz,truncate:rX,utimes:rJ,watch:t=>rY(t).pipe(U.TjK(r=>e.pipe(K.flatMap(e=>e.register(t,r)),K.getOrElse(()=>{var e;let r;return tc((r=e=>U.Q56(U.OH5(()=>{let r=rm.watch(t,{recursive:!0},(t,r)=>{if(r)switch(t){case"rename":return void U.MY7(U.tvg(rY(r),{onSuccess:t=>ew(e,{_tag:"Create",path:r}),onFailure:t=>ew(e,{_tag:"Remove",path:r})}));case"change":return void ex(e,{_tag:"Update",path:r})}});return r.on("error",r=>{ek(e,L.fJ(ea({module:"FileSystem",_tag:"Unknown",method:"watch",pathOrDescriptor:t,cause:r})))}),r.on("close",()=>{eS(e)}),r}),e=>U.OH5(()=>e.close())),eX((t,n)=>U.TjK(ev({capacity:e?.bufferSize,strategy:e?.strategy}).pipe(U.Mim(e=>eW.U9(n,eI(e))),U.Mim(e=>U.ar0(eW.Gt(r(e),n),n))),eE))))}))),tp),writeFile:rG},tk.of({...t,[tx]:tx,exists:e=>(0,B.Fs)(t.access(e),U.as(!0),U.KuX("PlatformError",e=>"NotFound"===e.reason._tag?U.PyW(!1):U.fJG(e))),readFileString:(e,r)=>U.qIB(t.readFile(e),e=>U.SvU({try:()=>new TextDecoder(r).decode(e),catch:e=>es({module:"FileSystem",method:"readFileString",description:"invalid encoding",cause:e})})),stream:U.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?t_(r.bytesToRead):void 0,a=BigInt(0),s=t_(r?.chunkSize??65536),o=n.readAlloc(s);return tc(eG(U.PyW(U.qIB(U.DYE(()=>void 0!==i&&i<=a?L.Vw():void 0!==i&&i-a<s?n.readAlloc(i-a):o),K.match({onNone:()=>L.Vw(),onSome:e=>(a+=BigInt(e.length),U.PyW(V.of(e)))})))))},tp),sink:(e,r)=>(0,B.Fs)(t.open(e,{flag:"w",...r}),U.TjK(e=>{let t,r;return t=t=>e.writeAll(t),r=U.jJl(e=>t(e),{discard:!0}),tn(e=>e.pipe(U.qIB(r),U.i4r({disableYield:!0}),ec.m8(()=>e7)))}),ts),writeFileString:(e,r,n)=>U.qIB(U.SvU({try:()=>new TextEncoder().encode(r),catch:e=>es({module:"FileSystem",method:"writeFileString",description:"could not encode string",cause:e})}),r=>t.writeFile(e,r,n))})}),rK=J.QZ(tk)(rV),rH=t("node:url"),rQ=e=>U.SvU({try:()=>rH.fileURLToPath(e),catch:e=>new er({module:"Path",method:"fromFileUrl",cause:e})}),rZ=e=>U.SvU({try:()=>rH.pathToFileURL(e),catch:e=>new er({module:"Path",method:"toFileUrl",cause:e})});ry.posix,ry.win32;let r0=J.Py(tO)({[t$]:t$,...rb,fromFileUrl:rQ,toFileUrl:rZ}),r1="~effect/Stdio",r2=Z.kl(r1),r5=J.Py(r2,{[r1]:r1,...{args:U.OH5(()=>process.argv.slice(2)),stdout:e=>t0({evaluate:()=>process.stdout,onError:e=>ea({module:"Stdio",method:"stdout",_tag:"Unknown",cause:e}),endOnDone:e?.endOnDone??!1}),stderr:e=>t0({evaluate:()=>process.stderr,onError:e=>ea({module:"Stdio",method:"stderr",_tag:"Unknown",cause:e}),endOnDone:e?.endOnDone??!1}),stdin:t4({evaluate:()=>process.stdin,onError:e=>ea({module:"Stdio",method:"stdin",_tag:"Unknown",cause:e}),closeOnDone:!1})}});var r3=n(2302);class r8{waiters=new Set;taken=0;permits;constructor(e){this.permits=e}get free(){return this.permits-this.taken}take(e){let t=ed.DYE(()=>this.free<e?ed.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),ed.OH5(()=>{this.waiters.delete(n)})}):(this.taken+=e,ed.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 eu.R6(t=>ed.PyW(this.updateTakenUnsafe(t,e)))}resize(e){return eu.R6(t=>(this.permits=e,this.free<0||this.updateTakenUnsafe(t,e=>e),ed.rIH))}release(e){return this.updateTaken(t=>t-e)}get releaseAll(){return this.updateTaken(e=>0)}withPermits(e){return t=>ed.FcF(r=>ed.qIB(r(this.take(e)),e=>ed.r7h(r(t),()=>{this.updateTakenUnsafe(ed.Iku(),t=>t-e)},!0)))}withPermit=this.withPermits(1);withPermitsIfAvailable(e){return t=>ed.FcF(r=>this.free<e?ed.lwU:(this.taken+=e,ed.r7h(r(ed.Xx$(t)),()=>{this.updateTakenUnsafe(ed.Iku(),t=>t-e)},!0)))}}let r6={_tag:"Empty"},r9={_tag:"Closed"},r4={_A:B.D_,_E:B.D_};class r7{"~effect/RcRef"=r4;pipe(){return(0,eo.tT)(this,arguments)}state=r6;semaphore=(e=>new r8(e))(1);acquire;context;scope;idleTimeToLive;constructor(e,t,r,n){this.acquire=e,this.context=t,this.scope=r,this.idleTimeToLive=n}}let ne=U.D9k(function*(e){let t=yield*U.FcF(t=>{switch(e.state._tag){case"Closed":return U.GaK;case"Acquired":return e.state.refCount++,e.state.fiber?U.as(t5(e.state.fiber),e.state):U.PyW(e.state);case"Empty":{let r=eW.LZ();return e.semaphore.withPermits(1)(t(U.PpN(e.acquire,Z.WQ(e.context,eW.HG,r))).pipe(U.TjK(t=>{let n={_tag:"Acquired",value:t,scope:r,fiber:void 0,refCount:1,invalidated:!1};return e.state=n,n})))}}}),r=yield*U.z8E,n=void 0!==e.idleTimeToLive&&r3.MI(e.idleTimeToLive);return yield*eW.a6(r,()=>(t.refCount--,t.refCount>0)?U.rIH:void 0===e.idleTimeToLive?(e.state=r6,eW.VN(t.scope,F.rI)):t.invalidated?eW.VN(t.scope,F.rI):n?(t.fiber=U.yy4(e.idleTimeToLive).pipe(U.qIB(()=>"Acquired"===e.state._tag&&0===e.state.refCount?(e.state=r6,eW.VN(t.scope,F.rI)):U.rIH),U.yeE(U.OH5(()=>{t.fiber=void 0})),U.eJC(e.context),t3(e.scope)),U.rIH):U.rIH),t.value});var nt=n(8861);let nr="~effect/platform/Terminal",nn="effect/platform/Terminal/QuitError";class ni extends nt.PSP("QuitError")({_tag:nt.TcI("QuitError")}){[nn]=nn}let na=Z.kl("effect/platform/Terminal"),ns=t("node:readline"),no=U.D9k(function*(e=nc){let t,r,n=process.stdin,i=process.stdout,a=yield*(t={acquire:U.Q56(U.OH5(()=>{let e=ns.createInterface({input:n,escapeCodeTimeout:50});return ns.emitKeypressEvents(n,e),n.isTTY&&n.setRawMode(!0),e}),e=>U.OH5(()=>{n.isTTY&&n.setRawMode(!1),e.close()}))},U.R6R(e=>{let r=e.context,n=Z.Jt(r,eW.HG),i=new r7(t.acquire,r,n,t.idleTimeToLive?r3.bN(t.idleTimeToLive):void 0);return U.as(eW.a6(n,()=>{let e="Acquired"===i.state._tag?eW.VN(i.state.scope,F.rI):U.rIH;return i.state=r9,e}),i)})),s=U.OH5(()=>i.columns??0),o=U.OH5(()=>i.rows??0),l=U.JkU(function*(){yield*ne(a);let t=yield*ev(),r=(r,n)=>{let i={input:K.fromUndefinedOr(r),key:{name:n.name??"",ctrl:!!n.ctrl,meta:!!n.meta,shift:!!n.shift}};ex(t,i),e(i)&&eS(t)};return yield*U.U9h(()=>U.OH5(()=>n.off("keypress",r))),n.on("keypress",r),t});return r={columns:s,rows:o,readInput:l,readLine:U.P1j(U.qIB(ne(a),e=>U.E2r(t=>{let r=e=>t(U.PyW(e));return e.once("line",r),U.OH5(()=>e.off("line",r))}))),display:e=>U.rfi(U.E2r(t=>{i.write(e,e=>el.uy(e)?t(U.rIH):t(U.fJG(es({module:"Terminal",method:"display",description:"Failed to write prompt to stdout",cause:e}))))}))},na.of({...r,[nr]:nr})}),nl=J.QZ(na,no(nc));function nc(e){return e.key.ctrl&&("c"===e.key.name||"d"===e.key.name)}let nu=J.S5(ra,J.Um(rK,rp,r0,r5,nl));var nd=n(3035),nf=n(6030);class nh extends nt.X0d()("CliFilesystemError",{cause:nt.kld(),operation:nt.QfV,path:nt.QfV,message:nt.QfV}){}class np extends nt.X0d()("CliInputError",{code:nt.xCb(["input_read_failed","invalid_json","interactive_stdin"]),message:nt.QfV,hint:nt.QfV}){}class nm extends nt.X0d()("CliValidationError",{message:nt.QfV,hint:nt.QfV,details:nt.O31(nt.QfV)}){}class ng extends nt.X0d()("CliBuildError",{status:nt.QfV,message:nt.QfV,hint:nt.QfV,details:nt.O31(nt.QfV)}){}class ny extends nt.X0d()("CliGenerationError",{code:nt.xCb(["provider_failure","generation_timeout","malformed_output","invalid_generated_document","unsupported_diagram_type"]),message:nt.QfV,hint:nt.QfV,details:nt.O31(nt.QfV)}){}class nb extends nt.X0d()("CliCanvasError",{code:nt.xCb(["canvas_rejected","endpoint_failure","malformed_response","network_failure"]),message:nt.QfV,hint:nt.QfV,details:nt.O31(nt.QfV)}){}class nv extends nt.X0d()("CliInteractiveError",{code:nt.xCb(["cancelled","prompt_failed"]),message:nt.QfV,hint:nt.QfV}){}class nw extends nt.X0d()("CliStorageError",{code:nt.xCb(["diagram_not_found","diagram_already_exists","diagram_busy","detached_edit","patch_source_unavailable","patch_conflict","replacement_conflict","restore_conflict","revision_not_found","corrupt_revision","corrupt_record","unsafe_storage_entry","storage_commit_failed"]),diagramId:nt.Qrq(nt.QfV),message:nt.QfV,hint:nt.QfV}){}class nx extends nt.X0d()("CliShareError",{code:nt.xCb(["invalid_share_link","unsupported_scene","share_payload_too_large","share_crypto_failed","share_transport_failed","share_timeout","share_api_changed","share_link_unavailable"]),message:nt.QfV,hint:nt.QfV,details:nt.O31(nt.QfV)}){}class n_ extends nt.X0d()("CliExportError",{code:nt.xCb(["format_unavailable","invalid_destination","render_failed","invalid_render_artifact","render_limit_exceeded","unsupported_render_glyph","rasterization_failed","export_write_failed"]),diagramId:nt.Qrq(nt.QfV),storagePath:nt.Qrq(nt.QfV),recoveryCommand:nt.Qrq(nt.QfV),details:nt.Qrq(nt.O31(nt.QfV)),format:nt.QfV,message:nt.QfV,hint:nt.QfV}){}function nk(e){return"string"==typeof e||"number"==typeof e||"symbol"==typeof e}let nS=nf.ID(),nI=nt._Re(nd.Ky,{errors:"all"}),nE=nt._Re(nd.e5,{errors:"all"}),n$=nt._Re(nd.nu,{errors:"all"}),nO=nt._Re(nd.y1,{errors:"all"});function nC(e){return nm.make({message:"The canonical diagram document is invalid.",hint:'Use {"type":"flowchart","spec":...}, {"type":"mindmap","spec":...}, or {"type":"sequence","spec":...}.',details:e})}function nT(e){return nS(e).issues.map(e=>{var t;let r=(e.path??[]).flatMap(e=>{let t=nk(e)?e:null!==e&&"object"==typeof e&&"key"in e&&nk(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}`})}function nA(e){if(!("object"!=typeof e||null===e||Array.isArray(e))&&"type"in e&&"spec"in e)return{type:e.type,spec:e.spec}}let nM=U.fn("sketchi.cli.document.decodeCanonical")(function*(e){let t=nA(e);return t?"flowchart"===t.type?{type:"flowchart",spec:yield*nI(t.spec).pipe(U.xm_(e=>nC(nT(e.issue))))}:"mindmap"===t.type?{type:"mindmap",spec:yield*nE(t.spec).pipe(U.xm_(e=>nC(nT(e.issue))))}:"sequence"===t.type?{type:"sequence",spec:yield*n$(t.spec).pipe(U.xm_(e=>nC(nT(e.issue))))}:yield*nC(['document.type: Expected "flowchart", "mindmap", or "sequence".']):yield*nC(["document: Expected an object with type and spec."])}),nN=U.fn("sketchi.cli.document.parseJson")(function*(e){let t=yield*U.SvU({try:()=>JSON.parse(e),catch:()=>np.make({code:"invalid_json",message:"The input is not valid JSON.",hint:"Pass one complete canonical document object."})});return yield*nM(t)}),nP=U.fn("sketchi.cli.document.decodeStored")(function*(e){let t=nA(e);return t?.type!=="canvas"?yield*nM(e):{type:"canvas",spec:yield*nO(t.spec).pipe(U.xm_(e=>nC(nT(e.issue))))}});function nR(e){return`${JSON.stringify(e,null,2)}
3
+ `}function nj(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 nD(e){return/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/.test(e)?U.PyW(e):U.fJG(nm.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 nL extends Z.kl()("@sketchi/cli/DiagramBuilder"){}function nU(e){let t=e.ref?.path?` (${e.ref.path})`:"";return`${e.code}${t}: ${e.message}`}function nF(e,t){let r=e.formats.find(e=>e.format===t);return r?.inline!==void 0?U.PyW(r.inline):U.fJG(ng.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 nB(e){let t=nd.Uh.safeParse(e);return t.success?U.PyW(t.data):U.fJG(ng.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 nW(e){let t=nd.yE.safeParse(e);return t.success?U.PyW(t.data):U.fJG(ng.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 nq=J.QZ(nL,U.JkU(function*(){let e=yield*nd.Ov,t=yield*nd.UA;return{build:U.fn("sketchi.cli.diagram.build")(function*(r){let n;if(!(n="flowchart"===r.type?yield*(0,nd.XV)({spec:r.spec,options:{artifactFormats:["scene","excalidraw"],inlineArtifacts:["scene","excalidraw"]}}).pipe(U.PfK(nd.Ov,e),U.PfK(nd.UA,t)):"mindmap"===r.type?yield*(0,nd.r8)({spec:r.spec,options:{artifactFormats:["scene","excalidraw"],inlineArtifacts:["scene","excalidraw"]}}).pipe(U.PfK(nd.Ov,e),U.PfK(nd.UA,t)):yield*(0,nd.rC)({spec:r.spec,options:{artifactFormats:["scene","excalidraw"],inlineArtifacts:["scene","excalidraw"]}}).pipe(U.PfK(nd.Ov,e),U.PfK(nd.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(nU),"invalid_input"===n.status||"invalid_flowchart"===n.status||"invalid_mindmap"===n.status||"invalid_sequence"===n.status||"quality_failed"===n.status?nm.make({message:t,hint:r,details:i}):"storage_failed"===n.status?nw.make({code:"storage_commit_failed",message:t,hint:r}):ng.make({status:n.status,message:t,hint:r,details:i}))}let i=yield*nD(nj(r)),a=yield*nF(n.artifact,"scene").pipe(U.qIB(nB)),s=yield*nF(n.artifact,"excalidraw").pipe(U.qIB(nW));return{id:i,type:r.type,title:r.spec.title,document:r,scene:a,excalidraw:s}})}})),nY=t("node:fs/promises");class nz extends Z.kl()("@sketchi/cli/LocalFileSystem"){}function nX(e,t,r){return nh.make({cause:r,operation:e,path:t,message:`Filesystem ${e} failed for ${t}.`})}function nJ(e,t){return"object"==typeof e&&null!==e&&"code"in e&&e.code===t}let nG=J.Py(nz,{makeDirectory:(e,t=!1)=>U.$mh({try:()=>(0,nY.mkdir)(e,{recursive:t}).then(()=>void 0),catch:t=>nX("make-directory",e,t)}),tryWriteText:(e,t)=>U.$mh({try:async()=>{try{let r=await (0,nY.open)(e,rm.constants.O_WRONLY|rm.constants.O_CREAT|rm.constants.O_EXCL|rm.constants.O_NOFOLLOW,384);try{await r.writeFile(t,{encoding:"utf8"}),await r.sync()}finally{await r.close()}return!0}catch(e){if(nJ(e,"EEXIST"))return!1;throw e}},catch:t=>nX("write-exclusive",e,t)}),tryLinkFile:(e,t)=>U.$mh({try:async()=>{try{return await (0,nY.link)(e,t),!0}catch(e){if(nJ(e,"EEXIST")||nJ(e,"ENOENT"))return!1;throw e}},catch:r=>nX("link-exclusive",`${e} -> ${t}`,r)}),makeTempDirectory:(e,t)=>U.$mh({try:()=>(0,nY.mkdtemp)((0,ry.join)(e,t)),catch:t=>nX("make-temp-directory",e,t)}),list:e=>U.$mh({try:async()=>(await (0,nY.readdir)(e,{withFileTypes:!0})).map(e=>({name:e.name,kind:e.isFile()?"file":e.isDirectory()?"directory":e.isSymbolicLink()?"symbolic-link":"other"})),catch:t=>nX("read-directory",e,t)}),kind:e=>U.$mh({try:async()=>{try{let t=await (0,nY.lstat)(e);if(t.isFile())return"file";if(t.isDirectory())return"directory";if(t.isSymbolicLink())return"symbolic-link";return"other"}catch(e){if(nJ(e,"ENOENT"))return"missing";if(nJ(e,"ELOOP"))return"symbolic-link";throw e}},catch:t=>nX("stat",e,t)}),realPath:e=>U.$mh({try:()=>(0,nY.realpath)(e),catch:t=>nX("resolve",e,t)}),readText:e=>U.$mh({try:async()=>{let t=await (0,nY.open)(e,rm.constants.O_RDONLY|rm.constants.O_NOFOLLOW);try{return await t.readFile({encoding:"utf8"})}finally{await t.close()}},catch:t=>nX("read",e,t)}),readBytes:e=>U.$mh({try:async()=>{let t=await (0,nY.open)(e,rm.constants.O_RDONLY|rm.constants.O_NOFOLLOW);try{return new Uint8Array(await t.readFile())}finally{await t.close()}},catch:t=>nX("read",e,t)}),writeText:(e,t,r=!1)=>U.$mh({try:async()=>{let n=rm.constants.O_WRONLY|rm.constants.O_CREAT|rm.constants.O_NOFOLLOW|(r?rm.constants.O_TRUNC:rm.constants.O_EXCL),i=await (0,nY.open)(e,n,384);try{await i.writeFile(t,{encoding:"utf8"}),await i.sync()}finally{await i.close()}},catch:t=>nX("write",e,t)}),writeBytes:(e,t,r=!1)=>U.$mh({try:async()=>{let n=rm.constants.O_WRONLY|rm.constants.O_CREAT|rm.constants.O_NOFOLLOW|(r?rm.constants.O_TRUNC:rm.constants.O_EXCL),i=await (0,nY.open)(e,n,384);try{await i.writeFile(t),await i.sync()}finally{await i.close()}},catch:t=>nX("write",e,t)}),rename:(e,t)=>U.$mh({try:()=>(0,nY.rename)(e,t),catch:r=>nX("rename",`${e} -> ${t}`,r)}),tryRenameDirectory:(e,t)=>U.$mh({try:async()=>{try{return await (0,nY.rename)(e,t),!0}catch(e){if(nJ(e,"EEXIST")||nJ(e,"ENOTEMPTY"))return!1;if(nJ(e,"EPERM"))try{if((await (0,nY.lstat)(t)).isDirectory())return!1}catch{}throw e}},catch:r=>nX("rename-exclusive-directory",`${e} -> ${t}`,r)}),removeFile:e=>U.$mh({try:async()=>{try{return await (0,nY.unlink)(e),!0}catch(e){if(nJ(e,"ENOENT"))return!1;throw e}},catch:t=>nX("remove-file",e,t)}),remove:e=>U.$mh({try:()=>(0,nY.rm)(e,{recursive:!0,force:!0}),catch:t=>nX("remove",e,t)})});function nV(e,t){return nm.make({message:e,hint:"Provide operations and optional options or intent only.",details:t})}let nK=U.fn("sketchi.cli.patch.decodeInput")(function*(e){if("object"!=typeof e||null===e||Array.isArray(e))return yield*nV("The diagram patch request is invalid.",["patch: Expected an object."]);if("source"in e)return yield*nV("The diagram patch request cannot supply source.",["source: The CLI binds the stored scene."]);if("requestId"in e)return yield*nV("The diagram patch request cannot supply requestId.",["requestId: The CLI owns the patch request id."]);let t=nd.Er.safeParse({...e,requestId:"cli-patch-validation",source:{scene:{kind:"canvas",version:1,diagramId:"validation",title:"Validation",width:1,height:1,accentColor:"#000000",backgroundColor:"#ffffff",elements:[],layers:[],layouts:[],zOrder:[]}}});return t.success?{operations:t.data.operations,...t.data.options?{options:t.data.options}:{},...t.data.intent?{intent:t.data.intent}:{}}:yield*nV("The diagram patch request is invalid.",t.error.issues.map(e=>e.message))}),nH=U.fn("sketchi.cli.patch.parseJson")(function*(e){let t=yield*U.SvU({try:()=>JSON.parse(e),catch:()=>np.make({code:"invalid_json",message:"The patch input is not valid JSON.",hint:"Pass one complete diagram patch request object."})});return yield*nK(t)});class nQ extends Z.kl()("@sketchi/cli/DiagramPatcher"){}function nZ(e){let t=e.ref?.path?` (${e.ref.path})`:"";return`${e.code}${t}: ${e.message}`}function n0(e,t){let r=e.formats.find(e=>e.format===t);return r?.inline!==void 0?U.PyW(r.inline):U.fJG(ng.make({status:"missing_inline_artifact",message:`Code Mode did not return the patched ${t} artifact inline.`,hint:"Retry the offline patch with the required artifact formats.",details:[t]}))}function n1(e){let t=nd.Uh.safeParse(e);return t.success?U.PyW(t.data):U.fJG(ng.make({status:"invalid_scene_artifact",message:"Code Mode returned an invalid patched scene artifact.",hint:"Inspect the Code Mode patch/export boundary.",details:t.error.issues.map(e=>e.message)}))}function n2(e){let t=nd.yE.safeParse(e);return t.success?U.PyW(t.data):U.fJG(ng.make({status:"invalid_excalidraw_artifact",message:"Code Mode returned an invalid patched Excalidraw artifact.",hint:"Inspect the Code Mode patch/export boundary.",details:t.error.issues.map(e=>e.message)}))}let n5=J.QZ(nQ,U.JkU(function*(){let e=yield*nd.Ov,t=yield*nd.UA;return{patch:U.fn("sketchi.cli.diagram.patch")(function*(r,n,i){let a=yield*(0,nd.OF)({requestId:i,source:{scene:r},operations:n.operations,options:{...n.options,artifactFormats:["scene","excalidraw"],inlineArtifacts:["scene","excalidraw"]},...n.intent?{intent:n.intent}:{}}).pipe(U.PfK(nd.Ov,e),U.PfK(nd.UA,t));if(!a.ok){let e,t,r,n;return yield*(e=a.issues[0],t=e?.message??`Code Mode patch failed with ${a.status}.`,r=e?.hint??"Repair the patch request and retry.",n=a.issues.map(nZ),"invalid_input"===a.status||"target_not_found"===a.status||"unsupported_operation"===a.status||"connectivity_changed"===a.status?nm.make({message:t,hint:r,details:n}):"storage_failed"===a.status?nw.make({code:"storage_commit_failed",message:t,hint:r}):ng.make({status:a.status,message:t,hint:r,details:n}))}return{scene:yield*n0(a.artifact,"scene").pipe(U.qIB(n1)),excalidraw:yield*n0(a.artifact,"excalidraw").pipe(U.qIB(n2))}})}}));class n3 extends Z.kl()("@sketchi/cli/InputReader"){}function n8(e,t){return U.SvU({try:()=>new TextDecoder("utf-8",{fatal:!0}).decode(e),catch:()=>np.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 n6=function(e=()=>!0===process.stdin.isTTY){return J.QZ(n3,U.JkU(function*(){let t=yield*nz,r=yield*r2;return{read:U.fn("sketchi.cli.input.read")(function*(n,i={content:"JSON document"}){if("InlineJson"===n._tag)return n.value;if("-"!==n.path){let e=yield*t.readBytes(n.path).pipe(U.xm_(()=>np.make({code:"input_read_failed",message:`Unable to read input file ${n.path}.`,hint:"Check the path and file permissions, then retry."})));return yield*n8(e,"file")}if(e())return yield*np.make({code:"interactive_stdin",message:`${i.content} input requires piped or redirected stdin.`,hint:"share link"===i.content?"Pipe one complete Excalidraw share link to --link -.":"Pipe one JSON document, or use --file PATH / --json VALUE."});let a=yield*tw(r.stdin,()=>({chunks:[],size:0}),(e,t)=>{let r=t.byteLength+e.size;return void 0!==i.maxBytes&&r>i.maxBytes?U.fJG(np.make({code:"input_read_failed",message:`Standard input exceeds the ${String(i.maxBytes)} byte limit for a ${i.content}.`,hint:`Pipe one complete ${i.content} within the documented limit.`})):U.PyW({chunks:[...e.chunks,t],size:r})}).pipe(U.xm_(e=>e instanceof np?e:np.make({code:"input_read_failed",message:`Unable to read the ${i.content} from stdin.`,hint:`Pipe one complete UTF-8 ${i.content} and retry.`})));return yield*n8(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}(a.chunks),"stdin")})}}))}(),n9=U.fn("sketchi.cli.input.readDocument")(function*(e){let t=yield*n3,r=yield*t.read(e);return yield*nN(r)}),n4=U.fn("sketchi.cli.input.readPatch")(function*(e){let t=yield*n3,r=yield*t.read(e,{content:"patch request"});return yield*nH(r)}),n7=t("node:zlib");var ie=n(3587);let it=1,ir="manifest.json",ii="document.json",ia="scene.json",is="diagram.excalidraw",io="diagram.png",il="revisions";class ic extends nt.Xsx("DiagramRecordManifest")({schemaVersion:nt.uSQ(it),id:nt.QfV,type:nt.xCb(["canvas","flowchart","mindmap","sequence"]),title:nt.QfV,revision:nt.Aiz.check(nt.yJO(0)),authority:nt.xCb(["canonical","patched","detached"]).pipe(nt.E$i(U.PyW("canonical"))),formats:nt.O31(nt.xCb(["scene","excalidraw","png"]))}){}function iu(e){return{id:e.manifest.id,type:e.manifest.type,title:e.manifest.title,revision:e.manifest.revision,formats:e.manifest.formats,authority:e.authority,documentAuthoritative:e.documentAuthoritative}}function id(e){return String(e).padStart(6,"0")}var ih=n(8689),ip=n(5030);let im="https://json.excalidraw.com/api/v2/",ig=["rectangle","ellipse","diamond","arrow","line","freedraw","text"],iy=new Set(ig),ib=new TextEncoder,iv=new TextDecoder("utf-8",{fatal:!0}),iw=ib.encode(JSON.stringify({version:2,compression:"pako@1",encryption:"AES-GCM"}));function ix(e,t,r,n=[]){return nx.make({code:e,message:t,hint:r,details:n})}function i_(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function ik(e){return"number"==typeof e&&Number.isFinite(e)}function iS(e,t,r){new DataView(e.buffer,e.byteOffset,e.byteLength).setUint32(t,r)}function iI(e,t){if(t+4>e.byteLength)throw Error("truncated chunk header");return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(t)}function iE(e,t){if(e.byteLength<4+4*t||1!==iI(e,0))throw Error("unsupported chunk format");let r=[],n=4;for(let i=0;i<t;i+=1){let t=iI(e,n),i=(n+=4)+t;if(i>e.byteLength)throw Error("truncated chunk");r.push(e.subarray(n,i)),n=i}if(n!==e.byteLength)throw Error("unexpected trailing chunk");return r}function i$(e){if(!/^[A-Za-z0-9_-]{22}$/.test(e))throw Error("invalid AES key encoding");let t=Buffer.from(e,"base64url");if(16!==t.byteLength)throw Error("invalid AES key length");return t}function iO(e,t){return crypto.subtle.importKey("raw",Uint8Array.from(i$(e)),{name:"AES-GCM",length:128},!1,[t])}function iC(e){if(!i_(e)||"excalidraw"!==e.type||!ik(e.version)||"string"!=typeof e.source||!Array.isArray(e.elements)||!i_(e.appState)||!(void 0===e.files||i_(e.files)))throw Error("invalid Excalidraw artifact shape");return{type:e.type,version:e.version,source:e.source,elements:e.elements,appState:e.appState,files:e.files??{}}}function iT(e,t){return"string"!=typeof e||!t.has(e)}function iA(e,t){if("number"==typeof e)return Number.isFinite(e)?void 0:`${t} must be finite`;if(Array.isArray(e))for(let r of e){let e=iA(r,`${t} item`);if(e)return e}else if(i_(e))for(let r of Object.values(e)){let e=iA(r,`${t} property`);if(e)return e}}function iM(e){return U.SvU({try:()=>{let t=iC(e);if(i_(e)&&"libraryItems"in e)throw Error("Excalidraw library state is unsupported");if(t.elements.length>1e4)throw Error("element count exceeds 10000");if(Object.keys(t.files).length>0)throw Error("binary files are unsupported");let r=new Set;for(let[e,n]of t.elements.entries()){if(!i_(n)||"string"!=typeof n.id)throw Error(`elements[${String(e)}].id is invalid`);if(r.has(n.id))throw Error(`elements[${String(e)}].id is duplicated`);r.add(n.id)}for(let[e,n]of t.elements.entries()){let t=function(e,t,r){let n=`elements[${String(t)}]`;if(!i_(e)||"string"!=typeof e.id||0===e.id.length||"string"!=typeof e.type)return`elements[${String(t)}] is not an Excalidraw element`;if(!iy.has(e.type))return`${n}.type is unsupported`;if("link"in e&&null!==e.link&&void 0!==e.link||"fileId"in e)return`${n} contains an external resource`;let i=iA(e,n);if(i)return i;for(let t of["x","y","width","height","angle"])if(!ik(e[t]))return`${n}.${t} must be finite`;if("text"===e.type){if(5!==e.fontFamily)return`${n}.fontFamily must be ${String(5)}`;if("string"!=typeof e.text)return`${n}.text is invalid`}if(["arrow","line","freedraw"].includes(e.type)&&(!Array.isArray(e.points)||e.points.some(e=>!Array.isArray(e)||e.length<2||!ik(e[0])||!ik(e[1]))))return`${n}.points contains invalid geometry`;for(let t of["containerId","frameId"])if(null!==e[t]&&void 0!==e[t]&&iT(e[t],r))return`${n}.${t} is an invalid element reference`;for(let t of["startBinding","endBinding"]){let i=e[t];if(null!=i&&(!i_(i)||iT(i.elementId,r)))return`${n}.${t} is an invalid element binding`}let a=e.boundElements;if(null!=a&&(!Array.isArray(a)||a.some(e=>!i_(e)||iT(e.id,r))))return`${n}.boundElements contains an invalid element reference`}(n,e,r);if(t)throw Error(t)}let n=(0,ip.Gd)(t.elements);if(n)throw Error(n);let i=function(e){if("viewBackgroundColor"in e&&"string"!=typeof e.viewBackgroundColor)return"appState.viewBackgroundColor must be a string";if("gridModeEnabled"in e&&"boolean"!=typeof e.gridModeEnabled)return"appState.gridModeEnabled must be boolean";for(let t of["gridSize","gridStep"])if(t in e&&null!==e[t]&&!ik(e[t]))return`appState.${t} must be finite or null`;if("lockedMultiSelections"in e){let t=e.lockedMultiSelections;if(!i_(t))return"appState.lockedMultiSelections must be an object";for(let[e,r]of Object.entries(t))if(0===e.length||!0!==r)return"appState.lockedMultiSelections contains an invalid lock entry"}return iA(e,"appState")}(t.appState);if(i)throw Error(i);return e},catch:e=>ix("unsupported_scene","The Excalidraw scene is unsupported by share/pull v1.",`Use only ${ig.join(", ")} elements, Excalifont fontFamily ${String(5)}, and no files or images.`,[e instanceof Error?e.message:"invalid scene"])})}function iN(e){let t=new Uint8Array(4);return iS(t,0,e),t}class iP extends Z.kl()("@sketchi/cli/StorageRoot"){}function iR(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}let ij=[[0,0,8,8],[4,0,8,8],[0,4,4,8],[2,0,4,4],[0,2,2,4],[1,0,2,2],[0,1,1,2]];function iD(e,t,r){return e<=t?0:Math.ceil((e-t)/r)}function iL(e){let t,r,n,i,a,s=[137,80,78,71,13,10,26,10];if(e.byteLength<33||s.some((t,r)=>e[r]!==t))return!1;let o=s.length,l=0,c=!1,u=!1,d=!1,f=[];for(;o+12<=e.byteLength;){let s=iR(e,o),h=o+12+s;if(h>e.byteLength)break;let p=o+4,m=e.subarray(p,p+4),g=e=>e>=65&&e<=90||e>=97&&e<=122;if(4!==m.byteLength||!m.every(g)||(32&m[2])!=0)break;let y=String.fromCharCode(...m);if(0===l&&("IHDR"!==y||13!==s))break;if("IHDR"===y){if(0!==l||13!==s)return!1;t=iR(e,o+8),r=iR(e,o+12),i=e[o+16],n=e[o+17],a=e[o+20];let c={0:[1,2,4,8,16],2:[8,16],3:[1,2,4,8],4:[8,16],6:[8,16]};if(0===t||0===r||t>0x7fffffff||r>0x7fffffff||void 0===n||void 0===i||!c[n]?.includes(i)||0!==e[o+18]||0!==e[o+19]||![0,1].includes(a??-1))break}else if("PLTE"===y){if(c||u||0===s||s%3!=0||s>768||0===n||4===n||3===n&&void 0!==i&&s/3>2**i)return!1;c=!0}else if("IDAT"===y){if(d||3===n&&!c)return!1;u=!0,f.push(e.subarray(o+8,o+8+s))}else if("IEND"===y){if(0!==s||!u||3===n&&!c)break}else{u&&(d=!0);let t=e[p];if(void 0===t||(32&t)==0)break}let b=iR(e,o+8+s);if(function(e){let t=0xffffffff;for(let r of e){t^=r;for(let e=0;e<8;e+=1)t=t>>>1^(1&t?0xedb88320:0)}return(0xffffffff^t)>>>0}(e.subarray(p,o+8+s))!==b)break;if(o=h,l+=1,"IEND"===y)return o===e.byteLength&&void 0!==t&&void 0!==r&&void 0!==i&&void 0!==n&&void 0!==a&&function(e,t,r,n,i,a){let s={0:1,2:3,3:1,4:2,6:4}[i];if(void 0===s)return!1;let o=function(e,t,r,n){let i=[],a=0;for(let[s,o,l,c]of 0===n?[[0,0,1,1]]:ij){let n=iD(e,s,l),u=iD(t,o,c);if(0===n||0===u)continue;let d=Math.ceil(n*r/8)+1;if(d>0x1000000-a||u>Math.floor((0x1000000-a)/d))return null;a+=u*d,i.push({rows:u,rowBytes:d})}return i}(t,r,s*n,a);if(null===o)return!1;let l=o.reduce((e,t)=>e+t.rows*t.rowBytes,0);try{let t=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}(e),r=(0,n7.inflateSync)(t,{info:!0,maxOutputLength:0x1000000});if(r.engine.bytesWritten!==t.byteLength)return!1;let n=r.buffer;if(n.byteLength!==l)return!1;let i=0;for(let e of o)for(let t=0;t<e.rows;t+=1){if((n[i]??5)>4)return!1;i+=e.rowBytes}return i===n.byteLength}catch{return!1}}(f,t,r,i,n,a)}return!1}class iU extends Z.kl()("@sketchi/cli/DiagramStore"){}let iF=".locks",iB="free.",iW="owner.",iq=".owner-candidate.",iY=".json",iz="recovery",iX=".backup.",iJ=`.stage.${String(process.pid)}.`,iG=ie.ji("10 millis").pipe(ie.jB({times:50})),iV=J.Py(iP,{path:(0,ry.join)((0,rg.homedir)(),".sketchi","diagrams")});function iK(e,t,r,n){return nw.make({code:e,message:t,hint:r,...n?{diagramId:n}:{}})}function iH(e){return Buffer.from(e,"utf8").toString("base64url")}function iQ(e,t){return e<t?-1:+(e>t)}function iZ(e,t){let r=e.replace(/(?:\/|\.json)$/u,"").replace(/^0+/u,""),n=t.replace(/(?:\/|\.json)$/u,"").replace(/^0+/u,""),i=r.length-n.length;return 0!==i?i:iQ(r,n)||iQ(e,t)}function i0(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 i1(e,t){return"object"==typeof e.cause&&null!==e.cause&&"code"in e.cause&&e.cause.code===t}function i2(e,t){return(0,ry.join)(e,t)}function i5(e){switch(e){case"scene":return ia;case"excalidraw":return is;case"png":return io}}function i3(e,t){return iK("unsafe_storage_entry",`Unsafe local storage entry at ${e}.`,"Replace symbolic links or special files with ordinary Sketchi record files.",t)}let i8=J.QZ(iU,U.JkU(function*(){let e=yield*nz,t=yield*iP,r=U.fn("sketchi.cli.storage.ensureOwnedDirectory")(function*(t){let r=yield*e.kind(t);if("missing"===r&&(yield*e.makeDirectory(t).pipe(U.MfU(e=>i1(e,"EEXIST")?U.rIH:U.fJG(e))),r=yield*e.kind(t)),"directory"!==r)return yield*i3(t)}),n=U.fn("sketchi.cli.storage.ensureRoot")(function*(){yield*r((0,ry.dirname)(t.path)),yield*r(t.path),yield*r((0,ry.join)(t.path,iF))}),i=U.fn("sketchi.cli.storage.assertSafeTree")(function*(t,r){for(let n of yield*e.list(t)){let e=(0,ry.join)(t,n.name);if("symbolic-link"===n.kind||"other"===n.kind)return yield*i3(e,r);"directory"===n.kind&&(yield*i(e,r))}}),a=U.fn("sketchi.cli.storage.recoverStages")(function*(){for(let r of(yield*n(),[...yield*e.list(t.path)].sort((e,t)=>iQ(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&&i0(n)||(yield*e.remove((0,ry.join)(t.path,r.name)))}}),s=U.fn("sketchi.cli.storage.recoverRecordTransactions")(function*(r){yield*n(),yield*a();let i=`${iX}${iH(r)}.`;for(let n of[...yield*e.list(t.path)].filter(e=>e.name.startsWith(i)).sort((e,t)=>iQ(e.name,t.name))){let i=(0,ry.join)(t.path,n.name),a=i2(t.path,r);"missing"===(yield*e.kind(a))?yield*e.rename(i,a):yield*e.remove(i)}}),o=U.fn("sketchi.cli.storage.initializeLockDirectory")(function*(r){let n=(0,ry.join)(t.path,iF,`${iH(r)}.lock`),i=yield*e.kind(n);if("directory"===i)return n;if("missing"!==i)return yield*i3(n,r);let a=(0,ry.join)(t.path,iF);return yield*U.jGc(e.makeTempDirectory(a,`.init.${iH(r)}.`),t=>U.JkU(function*(){let i=crypto.randomUUID();return(yield*e.writeText((0,ry.join)(t,`${iB}${i}${iY}`),nR({token:i})),(yield*e.tryRenameDirectory(t,n))||"directory"===(yield*e.kind(n)))?n:yield*i3(n,r)}),t=>e.remove(t))}),l=e=>iK("diagram_busy",`Diagram "${e}" is being changed by another Sketchi process.`,"Wait for that command to finish, then retry.",e),c=U.fn("sketchi.cli.storage.readLockEntries")(function*(t,r){let n=[...yield*e.list(t)].sort((e,t)=>iQ(e.name,t.name)),i=[];for(let a of n){let n=(0,ry.join)(t,a.name);if("file"!==a.kind)return yield*i3(n,r);let s=function(e){if(!e.startsWith(iB)||!e.endsWith(iY))return;let t=e.slice(iB.length,-iY.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}:{}}}(a.name);if(s){i.push({name:a.name,path:n,state:"free",token:s.token,...s.releasedOwnerToken?{releasedOwnerToken:s.releasedOwnerToken}:{}});continue}if(a.name.startsWith(iB))return yield*i3(n,r);let o=function(e){if(!e.startsWith(iq)||!e.endsWith(iY))return;let t=e.slice(iq.length,-iY.length);return/^[a-zA-Z0-9_-]+$/.test(t)?t:void 0}(a.name);if(o){i.push({name:a.name,path:n,state:"unpublished-owner",token:o});continue}if(a.name.startsWith(iq)||!a.name.startsWith(iW)||!a.name.endsWith(iY))return yield*i3(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(U.xm_(e=>i1(e,"ENOENT")?l(r):e))));if(!c)return yield*l(r);if(a.name!==`${iW}${c.token}${iY}`)return yield*i3(n,r);i.push({name:a.name,path:n,token:c.token,state:i0(c.pid)?"live-owner":"stale-owner"})}return i}),u=U.fn("sketchi.cli.storage.acquireLockOnce")(function*(t){yield*n();let r=yield*o(t),i=yield*c(r,t),a=new Set(i.flatMap(e=>e.releasedOwnerToken?[e.releasedOwnerToken]:[]));if(i.some(e=>"live-owner"===e.state&&!a.has(e.token)))return yield*l(t);let s=i.find(e=>"free"===e.state)??i.find(e=>"stale-owner"===e.state);if(!s){let n=(0,ry.join)(r,`${iB}${iz}${iY}`);if(!(yield*e.tryWriteText(n,nR({token:iz}))))return yield*l(t);s={name:`${iB}${iz}${iY}`,path:n,state:"free",token:iz}}let u=crypto.randomUUID(),d=(0,ry.join)(r,`${iW}${u}${iY}`),f=(0,ry.join)(r,`${iq}${u}${iY}`);return yield*U.rfi(U.jGc(U.PyW(f),()=>U.JkU(function*(){if(yield*e.writeText(f,nR({pid:process.pid,token:u})),!(yield*e.tryLinkFile(f,d)))return yield*l(t);if(!(yield*e.removeFile(s.path).pipe(U.MfU(t=>e.removeFile(d).pipe(U.hgn(U.fJG(t)))))))return yield*e.removeFile(d),yield*l(t);for(let t of i)t.path!==s.path&&(yield*e.removeFile(t.path).pipe(U.MfU(()=>U.rIH)));return{directory:r,ownerPath:d,token:u}}),t=>e.removeFile(t).pipe(U.MfU(()=>U.rIH))))}),d=U.fn("sketchi.cli.storage.releaseLock")(function*(t,r){let n=crypto.randomUUID(),i=(0,ry.join)(r.directory,`${iB}${n}.${r.token}${iY}`),a=nR({token:n,releasedOwnerToken:r.token});if(!(yield*e.writeText(i,a).pipe(U.as(!0),U.MfU(()=>e.tryWriteText(i,a).pipe(U.qIB(t=>t?U.PyW(!0):e.kind(i).pipe(U.TjK(e=>"file"===e))),U.MfU(()=>U.PyW(!1))))))){if(yield*e.removeFile(r.ownerPath))return;return yield*iK("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(U.YWq({onFailure:()=>!0,onSuccess:e=>e}))))return yield*e.removeFile(i).pipe(U.MfU(()=>U.rIH)),yield*iK("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 U.jGc((n=u(e),r?n.pipe(U.L5P({schedule:iG,while:e=>"CliStorageError"===e._tag&&"diagram_busy"===e.code})):n),()=>s(e).pipe(U.hgn(t)),t=>d(e,t).pipe(U.MfU(()=>U.rIH)))},h=U.fn("sketchi.cli.storage.decodeManifest")(function*(t,r){let n=yield*e.readText(t),i=yield*U.SvU({try:()=>JSON.parse(n),catch:()=>iK("corrupt_record",`Diagram "${r}" has an invalid manifest.`,"Inspect manifest.json and restore it from a known-good backup.",r)});return yield*nt._Re(ic)(i).pipe(U.xm_(()=>iK("corrupt_record",`Diagram "${r}" has an incompatible manifest.`,`Expected manifest schema version ${String(1)}.`,r)))}),p=U.fn("sketchi.cli.storage.decodeDocument")(function*(t,r){let n=yield*e.readText(t),i=yield*U.SvU({try:()=>JSON.parse(n),catch:()=>iK("corrupt_record",`Diagram "${r}" has invalid document JSON.`,"Recover a prior canonical document from the revisions directory.",r)});return yield*nP(i).pipe(U.xm_(()=>iK("corrupt_record",`Diagram "${r}" has an invalid canonical document.`,"Recover a prior canonical document from the revisions directory.",r)))}),m=U.fn("sketchi.cli.storage.loadUnlocked")(function*(r){let n=i2(t.path,r),a=yield*e.kind(n);if("missing"===a)return yield*iK("diagram_not_found",`Diagram "${r}" does not exist.`,"Run sketchi list to discover stored diagram ids.",r);if("directory"!==a)return yield*i3(n,r);yield*i(n,r);let s=yield*h((0,ry.join)(n,ir),r);if(s.id!==r)return yield*iK("corrupt_record",`Diagram directory "${r}" contains manifest id "${s.id}".`,"Make the directory name and manifest id agree before retrying.",r);let o=yield*p((0,ry.join)(n,ii),r);if(s.type!==o.type||s.title!==o.spec.title)return yield*iK("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[ia,is])if((yield*e.kind((0,ry.join)(n,t)))!=="file")return yield*iK("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,ry.join)(n,io));if("file"!==l&&"missing"!==l)return yield*i3((0,ry.join)(n,io),r);if("file"===l&&!iL((yield*e.readBytes((0,ry.join)(n,io)))))return yield*iK("corrupt_record",`Diagram "${r}" has an invalid stored PNG artifact.`,"Recover a valid prior revision or rebuild the record.",r);let c="detached"===s.authority?"file"===l?["excalidraw","png"]:["excalidraw"]:"file"===l?["scene","excalidraw","png"]:["scene","excalidraw"];if(s.formats.length!==c.length||s.formats.some((e,t)=>e!==c[t]))return yield*iK("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,ry.join)(n,il),d=[];for(let t of yield*e.list(u)){if("file"===t.kind&&/^\d{6,}\.json$/u.test(t.name)){d.push(t.name);continue}if("directory"===t.kind&&/^\d{6,}$/u.test(t.name)){d.push(`${t.name}/`);continue}return yield*i3((0,ry.join)(u,t.name),r)}return d.sort(iZ),{manifest:s,document:o,revisions:d,authority:s.authority,documentAuthoritative:"canonical"===s.authority}}),g=U.fn("sketchi.cli.storage.copySafeTree")(function*(t,r,n){for(let i of yield*e.list(t)){let a=(0,ry.join)(t,i.name),s=(0,ry.join)(r,i.name);if("directory"===i.kind)yield*e.makeDirectory(s),yield*g(a,s,n);else{if("file"!==i.kind)return yield*i3(a,n);let t=yield*e.readBytes(a);yield*e.writeBytes(s,t)}}}),y=U.fn("sketchi.cli.storage.copyRecordSnapshot")(function*(t,r,n){for(let i of(yield*e.makeDirectory(r),yield*e.list(t))){if(i.name===il)continue;let a=(0,ry.join)(t,i.name),s=(0,ry.join)(r,i.name);if("file"!==i.kind)return yield*i3(a,n);yield*e.writeBytes(s,(yield*e.readBytes(a)))}}),b=U.fn("sketchi.cli.storage.commitStage")(function*(r,n){let i=i2(t.path,r),a=(0,ry.join)(t.path,`${iX}${iH(r)}.${String(process.pid)}.${crypto.randomUUID()}`);yield*e.rename(i,a),(yield*e.rename(n,i).pipe(U.tvg({onFailure:t=>e.rename(a,i).pipe(U.tvg({onFailure:()=>U.fJG(iK("storage_commit_failed",`Atomic storage commit and rollback both failed for "${r}".`,"Retry; Sketchi will recover the backup transaction before the next operation.",r)),onSuccess:()=>U.fJG(t)})),onSuccess:()=>U.PyW(!0)})))&&(yield*e.remove(a).pipe(U.MfU(()=>U.rIH)))}),v=U.fn("sketchi.cli.storage.snapshotCurrent")(function*(r,n,i){let a=(0,ry.join)(n,il,id(i));if((yield*e.kind(a))!=="missing")return yield*iK("corrupt_record",`Diagram "${r}" already has a snapshot for current revision ${String(i)}.`,"Inspect the revisions directory before retrying.",r);yield*y(i2(t.path,r),a,r)}),w=U.fn("sketchi.cli.storage.writeBuilt")(function*(t,r,n){yield*e.makeDirectory((0,ry.join)(t,il),!0),yield*e.writeText((0,ry.join)(t,ii),nR(r.document),!0),yield*e.writeText((0,ry.join)(t,ia),nR(r.scene),!0),yield*e.writeText((0,ry.join)(t,is),nR(r.excalidraw),!0);let i=(0,ry.join)(t,io);yield*e.remove(i),r.png&&(yield*e.writeBytes(i,r.png)),yield*e.writeText((0,ry.join)(t,ir),nR(n),!0)}),x=U.fn("sketchi.cli.storage.create")(function*(r){return yield*f(r.id,U.JkU(function*(){let n=i2(t.path,r.id);if((yield*e.kind(n))!=="missing")return yield*iK("diagram_already_exists",`Diagram "${r.id}" already exists.`,"Use sketchi edit for full-document replacement.",r.id);let i=ic.make({schemaVersion:1,id:r.id,type:r.type,title:r.title,revision:1,authority:"canonical",formats:r.png?["scene","excalidraw","png"]:["scene","excalidraw"]});return yield*U.jGc(e.makeTempDirectory(t.path,iJ),t=>U.JkU(function*(){return yield*w(t,r,i),yield*e.rename(t,n),{manifest:i,document:r.document,revisions:[],authority:"canonical",documentAuthoritative:!0}}),t=>e.remove(t))}))}),_=U.fn("sketchi.cli.storage.edit")(function*(r,n){return yield*f(r,U.JkU(function*(){let i=yield*m(r);if("canonical"!==i.authority)return yield*iK("detached_edit",`Diagram "${r}" does not have an authoritative canonical document.`,"Restore a canonical revision before editing this diagram.",r);if(n.id!==r)return yield*iK("storage_commit_failed",`Edited document id "${n.id}" does not match "${r}".`,"Keep spec.id equal to the diagram id being edited.",r);let a=i2(t.path,r),s=ic.make({schemaVersion:1,id:r,type:n.type,title:n.title,revision:i.manifest.revision+1,authority:"canonical",formats:n.png?["scene","excalidraw","png"]:["scene","excalidraw"]});return yield*U.jGc(e.makeTempDirectory(t.path,iJ),e=>U.JkU(function*(){return yield*g(a,e,r),yield*v(r,e,i.manifest.revision),yield*w(e,n,s),yield*b(r,e),{manifest:s,document:n.document,revisions:[...i.revisions,`${id(i.manifest.revision)}/`].sort(iZ),authority:"canonical",documentAuthoritative:!0}}),t=>e.remove(t))}))}),k=e=>iK("patch_source_unavailable",`Diagram "${e}" has no current authoritative scene to patch.`,"Restore a canonical or patched revision before patching this diagram.",e),S=U.fn("sketchi.cli.storage.readPatchSourceUnlocked")(function*(r){let n=yield*m(r);if("detached"===n.authority||!n.manifest.formats.includes("scene"))return yield*k(r);let i=(0,ry.join)(i2(t.path,r),ia),a=yield*e.readText(i),s=yield*U.OH5(()=>{try{return nd.Uh.safeParse(JSON.parse(a))}catch{return}});return s?.success&&s.data.diagramId===r?{revision:n.manifest.revision,scene:s.data}:yield*iK("corrupt_record",`Diagram "${r}" has an invalid current scene artifact.`,"Restore a valid prior revision before patching this diagram.",r)}),I=U.fn("sketchi.cli.storage.readPatchSource")(e=>f(e,S(e),!0)),E=U.fn("sketchi.cli.storage.commitPatch")(function*(r,n,i){return yield*f(r,U.JkU(function*(){let a=yield*m(r);if(a.manifest.revision!==n)return yield*iK("patch_conflict",`Diagram "${r}" changed before the patch could commit.`,"Run sketchi show, verify the current record, and retry the patch if it is still intended.",r);if("detached"===a.authority||!a.manifest.formats.includes("scene"))return yield*k(r);if(i.scene.diagramId!==r)return yield*iK("storage_commit_failed",`Patched scene id "${i.scene.diagramId}" does not match "${r}".`,"Retry the patch against the named stored diagram.",r);let s=i2(t.path,r),o=ic.make({schemaVersion:1,id:r,type:a.manifest.type,title:a.manifest.title,revision:a.manifest.revision+1,authority:"patched",formats:["scene","excalidraw"]});return yield*U.jGc(e.makeTempDirectory(t.path,iJ),t=>U.JkU(function*(){return yield*g(s,t,r),yield*v(r,t,a.manifest.revision),yield*e.writeText((0,ry.join)(t,ia),nR(i.scene),!0),yield*e.writeText((0,ry.join)(t,is),nR(i.excalidraw),!0),yield*e.remove((0,ry.join)(t,io)),yield*e.writeText((0,ry.join)(t,ir),nR(o),!0),yield*b(r,t),{manifest:o,document:a.document,revisions:[...a.revisions,`${id(a.manifest.revision)}/`].sort(iZ),authority:"patched",documentAuthoritative:!1}}),t=>e.remove(t))}))}),$=(e,t)=>iK("corrupt_revision",`Diagram "${e}" revision ${String(t)} is corrupt.`,"Choose another revision or repair the corrupt snapshot.",e),O=U.fn("sketchi.cli.storage.validateArchivedJson")(function*(t,r,n){let i=yield*e.readText(t);return yield*U.SvU({try:()=>{let e=JSON.parse(i);if("object"!=typeof e||null===e)throw Error("archived JSON must contain an object");return e},catch:()=>$(r,n)})}),C=U.fn("sketchi.cli.storage.validateArchivedArtifact")(function*(e,t,r,n,i){let a=yield*O(e,n,i);if(!("scene"===t?nd.Uh.safeParse(a):nd.yE.safeParse(a)).success)return yield*$(n,i);"excalidraw"===t&&"detached"===r&&(yield*iM(a).pipe(U.xm_(()=>$(n,i))))}),T=U.fn("sketchi.cli.storage.validateArchivedPng")(function*(t,r,n){if(!iL((yield*e.readBytes(t))))return yield*$(r,n)}),A=U.fn("sketchi.cli.storage.readRevisionUnlocked")(function*(r,n){yield*m(r);let a=(0,ry.join)(i2(t.path,r),il),s=(0,ry.join)(a,id(n)),o=yield*e.kind(s);if("directory"===o){yield*i(s,r);let t=yield*h((0,ry.join)(s,ir),r).pipe(U.xm_(()=>$(r,n))),a=yield*p((0,ry.join)(s,ii),r).pipe(U.xm_(()=>$(r,n)));if(t.id!==r||t.revision!==n||t.type!==a.type||t.title!==a.spec.title)return yield*iK("corrupt_revision",`Diagram "${r}" revision ${String(n)} has inconsistent metadata.`,"Choose another revision or repair the corrupt snapshot.",r);for(let[i,a]of[[ia,"scene"],[is,"excalidraw"]]){let o=(0,ry.join)(s,i);if((yield*e.kind(o))!=="file")return yield*iK("corrupt_revision",`Diagram "${r}" revision ${String(n)} is missing ${i}.`,"Choose another revision or repair the corrupt snapshot.",r);yield*C(o,a,t.authority,r,n).pipe(U.xm_(e=>"CliFilesystemError"===e._tag?$(r,n):e))}let o=yield*e.kind((0,ry.join)(s,io));if("file"!==o&&"missing"!==o)return yield*i3((0,ry.join)(s,io),r);"file"===o&&(yield*T((0,ry.join)(s,io),r,n).pipe(U.xm_(e=>"CliFilesystemError"===e._tag?$(r,n):e)));let l="detached"!==t.authority?"file"===o?["scene","excalidraw","png"]:["scene","excalidraw"]:"file"===o?["excalidraw","png"]:["excalidraw"];return t.formats.length!==l.length||t.formats.some((e,t)=>e!==l[t])?yield*iK("corrupt_revision",`Diagram "${r}" revision ${String(n)} has inconsistent formats.`,"Choose another revision or repair the corrupt snapshot.",r):{_tag:"FullSnapshot",revision:n}}if("missing"!==o)return yield*i3(s,r);let l=(0,ry.join)(a,`${String(n).padStart(6,"0")}.json`),c=yield*e.kind(l);if("missing"===c)return yield*iK("revision_not_found",`Diagram "${r}" has no revision ${String(n)}.`,"Run sketchi show to inspect the available revision paths.",r);if("file"!==c)return yield*i3(l,r);let u=yield*nM((yield*O(l,r,n))).pipe(U.xm_(()=>iK("corrupt_revision",`Diagram "${r}" revision ${String(n)} is corrupt.`,"Choose another revision or repair the legacy revision file.",r)));return{_tag:"LegacyDocument",revision:n,document:u}}),M=U.fn("sketchi.cli.storage.replaceWithDetached")(function*(r,n,i){return yield*f(r,U.JkU(function*(){let a=yield*m(r);if(void 0!==i&&a.manifest.revision!==i)return yield*iK("replacement_conflict",`Diagram "${r}" changed before the pulled replacement could commit.`,"Run sketchi show, verify the current record, and retry the pull if it is still intended.",r);let s=i2(t.path,r),o=ic.make({schemaVersion:1,id:r,type:a.manifest.type,title:a.manifest.title,revision:a.manifest.revision+1,authority:"detached",formats:["excalidraw"]});return yield*U.jGc(e.makeTempDirectory(t.path,iJ),t=>U.JkU(function*(){return yield*g(s,t,r),yield*v(r,t,a.manifest.revision),yield*e.writeBytes((0,ry.join)(t,is),n,!0),yield*e.remove((0,ry.join)(t,io)),yield*e.writeText((0,ry.join)(t,ir),nR(o),!0),yield*b(r,t),{manifest:o,document:a.document,revisions:[...a.revisions,`${id(a.manifest.revision)}/`].sort(iZ),authority:"detached",documentAuthoritative:!1}}),t=>e.remove(t))}))}),N=U.fn("sketchi.cli.storage.readRevision")((e,t)=>f(e,A(e,t),!0)),P=U.fn("sketchi.cli.storage.restore")(function*(r,n,i){return yield*f(r,U.JkU(function*(){let a=yield*m(r),s=yield*A(r,n);if("LegacyDocument"===s._tag){if("canonical"!==a.authority||!i)return yield*iK("restore_conflict",`Legacy revision ${String(n)} requires a canonical rebuild for "${r}".`,"Restore a full canonical snapshot, or provide the rebuilt legacy document.",r);if(i.id!==r||nR(i.document)!==nR(s.document))return yield*iK("storage_commit_failed",`Legacy revision ${String(n)} rebuild does not match its archived document.`,"Rebuild the exact archived canonical document before restoring.",r)}let o=i2(t.path,r);return yield*U.jGc(e.makeTempDirectory(t.path,iJ),t=>U.JkU(function*(){yield*g(o,t,r),yield*v(r,t,a.manifest.revision);let l=[...a.revisions,`${id(a.manifest.revision)}/`].sort(iZ),c=yield*"FullSnapshot"===s._tag?U.JkU(function*(){let i=(0,ry.join)(t,il,id(n));for(let r of yield*e.list(t))r.name!==il&&(yield*e.remove((0,ry.join)(t,r.name)));yield*g(i,t,r);let s=(0,ry.join)(t,ir),o=yield*e.readText(s);yield*h(s,r);let c=yield*p((0,ry.join)(t,ii),r),u=function(e,t){let r=0,n=-1,i=-1;for(let t=0;t<e.length;t+=1){let a,s=e[t];if("{"===s){r+=1;continue}if("}"===s){r-=1;continue}if('"'!==s)continue;let o=t,l=!1;for(t+=1;t<e.length;t+=1){let r=e[t];if(l)l=!1;else if("\\"===r)l=!0;else if('"'===r)break}if(t>=e.length||1!==r)continue;try{a=JSON.parse(e.slice(o,t+1))}catch{return}if("revision"!==a)continue;let c=t+1;for(;/\s/u.test(e[c]??"");)c+=1;if(":"!==e[c])continue;for(c+=1;/\s/u.test(e[c]??"");)c+=1;let u=/^-?\d+/u.exec(e.slice(c));if(!u)return;let d=c+u[0].length,f=d;for(;/\s/u.test(e[f]??"");)f+=1;if(","!==e[f]&&"}"!==e[f]||-1!==n)return;n=c,i=d}return -1===n?void 0:`${e.slice(0,n)}${String(t)}${e.slice(i)}`}(o,a.manifest.revision+1);if(void 0===u)return yield*$(r,n);yield*e.writeText(s,u,!0);let d=yield*h(s,r);return{manifest:d,document:c,revisions:l,authority:d.authority,documentAuthoritative:"canonical"===d.authority}}):U.JkU(function*(){if(!i)return yield*iK("storage_commit_failed",`Legacy revision ${String(n)} has no rebuilt document.`,"Rebuild the archived canonical document before restoring.",r);let e=ic.make({schemaVersion:1,id:r,type:i.type,title:i.title,revision:a.manifest.revision+1,authority:"canonical",formats:i.png?["scene","excalidraw","png"]:["scene","excalidraw"]});return yield*w(t,i,e),{manifest:e,document:i.document,revisions:l,authority:"canonical",documentAuthoritative:!0}});return yield*b(r,t),{diagram:c,restoredFromRevision:n}}),t=>e.remove(t))}))}),R=U.fn("sketchi.cli.storage.show")(e=>f(e,m(e),!0)),j=U.fn("sketchi.cli.storage.list")(function*(){yield*n(),yield*a();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(iX))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(iQ)){let t=yield*R(e);i.push(iu(t))}return i});return{create:x,edit:_,readPatchSource:I,commitPatch:E,replaceWithDetached:M,readRevision:N,restore:P,show:R,list:j,readExportSource:U.fn("sketchi.cli.storage.readExportSource")(function*(r,n){return yield*f(r,U.JkU(function*(){let i=yield*m(r);if(i.manifest.formats.includes(n))return{_tag:"StoredArtifact",bytes:yield*e.readBytes((0,ry.join)(i2(t.path,r),i5(n)))};if("png"!==n)return yield*n_.make({code:"format_unavailable",format:n,message:`Diagram "${r}" has no stored ${n} artifact.`,hint:"Edit the diagram to rebuild its local artifacts."});if("detached"===i.authority)return{_tag:"RenderPng",excalidraw:yield*e.readBytes((0,ry.join)(i2(t.path,r),i5("excalidraw")))};for(let e of["scene","excalidraw"])if(!i.manifest.formats.includes(e))return yield*n_.make({code:"format_unavailable",format:e,message:`Diagram "${r}" has no stored ${e} artifact.`,hint:"Edit the diagram to rebuild its local artifacts."});let[a,s]=yield*U.Q7R([e.readBytes((0,ry.join)(i2(t.path,r),i5("scene"))),e.readBytes((0,ry.join)(i2(t.path,r),i5("excalidraw")))]);return{_tag:"RenderPng",scene:a,excalidraw:s}}),!0)})}})),i6=U.fn("sketchi.cli.export.writeFile")(function*(e,t){let r=yield*nz,n=yield*iP,i=(0,ry.resolve)(e),a=(0,ry.dirname)(i),s=()=>n_.make({code:"export_write_failed",format:(0,ry.basename)(e),message:`Export destination directory does not exist: ${a}.`,hint:"Create the destination directory and retry."}),o=yield*r.realPath(a).pipe(U.xm_(s));if((yield*r.kind(o))!=="directory")return yield*s();let l=yield*r.realPath(n.path),c=(0,ry.join)(o,(0,ry.basename)(i)),u=(0,ry.relative)(l,c);if(""===u||!u.startsWith("..")&&!(0,ry.isAbsolute)(u))return yield*n_.make({code:"invalid_destination",format:(0,ry.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,ry.join)(o,`.${(0,ry.basename)(e)}.sketchi.${String(process.pid)}.${crypto.randomUUID()}`);return yield*U.jGc(U.PyW(d),n=>r.writeBytes(n,t).pipe(U.hgn(r.rename(n,c)),U.xm_(()=>n_.make({code:"export_write_failed",format:(0,ry.basename)(e),message:`Unable to write export destination ${e}.`,hint:"Check the destination path and permissions, then retry."}))),e=>r.remove(e))}),i9="https://playground.sketchi.app/api/v1/canvases/create",i4="SKETCHI_CANVAS_ENDPOINT",i7=nf.ID();function ae(e){return i7(e.issue).issues.map(e=>{let t=(e.path??[]).map(e=>"object"==typeof e&&null!==e&&"key"in e?String(e.key):String(e)).join(".");return`${t||"spec"}: ${e.message}`})}let at=nt._Re(nd.y1,{errors:"all"}),ar=nt._Re(nd.JH,{errors:"all"}),an=U.fn("sketchi.cli.canvas.parseSpec")(function*(e){let t=yield*U.SvU({try:()=>JSON.parse(e),catch:()=>np.make({code:"invalid_json",message:"The CanvasSpec input is not valid JSON.",hint:"Pass one complete CanvasSpec JSON object."})});return yield*at(t).pipe(U.xm_(e=>nm.make({message:"The CanvasSpec document is invalid.",hint:"Use the version 1 CanvasSpec contract documented by sketchi docs.",details:ae(e)})))}),ai=U.fn("sketchi.cli.canvas.readSpecInput")(function*(e){let t=yield*n3,r=yield*t.read(e,{content:"CanvasSpec document"});return yield*an(r)});function aa(){return nb.make({code:"network_failure",message:"The Sketchi create-canvas API could not be reached.",hint:"Check the network connection and endpoint, then retry.",details:["transport"]})}function as(e=[]){return nb.make({code:"malformed_response",message:"The Sketchi create-canvas API returned an unreadable response.",hint:"Retry once; if the response remains invalid, report the endpoint.",details:e})}function ao(e){return nb.make({code:"endpoint_failure",message:`The Sketchi create-canvas API responded with HTTP ${String(e)}.`,hint:"Check the endpoint and retry.",details:[`http_status:${String(e)}`]})}let al=U.fn("sketchi.cli.canvas.request")(function*(e){var t,r,n,i,a,s;let o=yield*U.$mh({try:t=>globalThis.fetch(e.endpoint,{method:"POST",headers:{"content-type":"application/json","x-sketchi-client":"sketchi-cli"},body:JSON.stringify({spec:e.spec,options:{artifactFormats:["scene","excalidraw"],inlineArtifacts:["excalidraw"]}}),signal:t}),catch:aa}),l=yield*U.$mh({try:()=>o.text(),catch:aa}),c=yield*U.SvU({try:()=>JSON.parse(l),catch:()=>as()}),u=yield*ar(c).pipe(U.xm_(e=>o.ok?as(ae(e)):ao(o.status)));if(!u.ok)switch(u.status){case"export_failed":case"render_failed":case"storage_failed":return yield*(t=u.status,r=o.status,n=u.issues,nb.make({code:"endpoint_failure",message:`The Sketchi create-canvas API failed with status ${t}.`,hint:"Retry once; if the failure persists, report the endpoint and status.",details:[`status:${t}`,`http_status:${String(r)}`,...n.map(e=>`${e.code}: ${e.message}`)]}));case"invalid_canvas":case"invalid_input":case"limit_exceeded":let d;return yield*(i=u.status,a=o.status,d=(s=u.issues)[0],nb.make({code:"canvas_rejected",message:d?.message??"The create-canvas API rejected the CanvasSpec.",hint:"Correct the reported CanvasSpec issue and retry.",details:[`status:${i}`,`http_status:${String(a)}`,...s.map(e=>`${e.code}: ${e.message}`)]}))}return o.ok?u:yield*ao(o.status)}),ac=U.fn("sketchi.cli.canvas.create")(function*(e){let t=yield*iU;yield*nD(e.spec.diagramId).pipe(U.xm_(e=>nm.make({message:e.message,hint:e.hint,details:["spec.diagramId"]})));let r=yield*al(e);if(r.normalizedSpec.diagramId!==e.spec.diagramId)return yield*as(["normalizedSpec.diagramId does not match submitted spec.diagramId"]);let n=r.artifact.formats.find(e=>"excalidraw"===e.format);if(n?.inline===void 0)return yield*as(["artifact.formats.excalidraw.inline"]);let i=nd.yE.safeParse(n.inline);if(!i.success)return yield*as(i.error.issues.map(e=>`${e.path.join(".")}: ${e.message}`));let a=yield*nD(r.normalizedSpec.diagramId).pipe(U.xm_(()=>as(["normalizedSpec.diagramId is not storage-safe"])));if(r.artifact.diagramId!==a)return yield*as(["artifact.diagramId does not match normalizedSpec.diagramId"]);let s={id:a,type:"canvas",title:r.normalizedSpec.title,document:{type:"canvas",spec:r.normalizedSpec},scene:r.normalizedSpec,excalidraw:i.data},o=yield*t.create(s);return{artifactId:r.artifact.artifactId,diagram:o}});var au=n(1688);class ad extends Z.kl()("@sketchi/cli/CliPngRenderer"){}let af=J.Py(ad,{renderPng:function(e){return U.$mh({try:async()=>(await Promise.all([n.e(831),n.e(869)]).then(n.bind(n,7665))).renderPngBytes(e),catch:e=>e instanceof au.FG?e:au.FG.make({cause:e,code:"rasterization_failed",stage:"rasterization",message:"Unable to rasterize the stored diagram as PNG.",details:[]})})},normalizeExcalidraw:function(e){return U.$mh({try:async()=>(await Promise.all([n.e(831),n.e(869)]).then(n.bind(n,7665))).normalizeExcalidrawArtifact(e),catch:e=>e instanceof au.FG?e:au.FG.make({cause:e,code:"invalid_render_artifact",stage:"artifact",message:"Unable to restore the Excalidraw share artifact.",details:[]})})}});class ah extends Z.kl()("@sketchi/cli/DiagramExporter"){}function ap(e,t){let r=`sketchi export ${e} --format png --dest ${e}.png`;return n_.make({code:t?.code??"invalid_render_artifact",format:"png",diagramId:e,storagePath:`~/.sketchi/diagrams/${e}`,recoveryCommand:r,message:t?.message??"Unable to read the stored PNG source artifacts.",hint:`The canonical record is preserved. Retry with: ${r}`,details:t?[`stage:${t.stage}`,...t.details]:["stage:artifact"]})}function am(e,t){return U.SvU({try:()=>JSON.parse(new TextDecoder().decode(t)),catch:()=>ap(e)})}let ag=J.QZ(ah,U.JkU(function*(){let e=yield*iU,t=yield*ad,r=U.fn("sketchi.cli.export.renderPng")(function*(e,r){let n=yield*am(e,r.excalidraw),i=nd.yE.safeParse(n);if(!i.success)return yield*ap(e);let a=r.scene?nd.Uh.safeParse((yield*am(e,r.scene))):void 0;if(a&&!a.success)return yield*ap(e);let s=yield*t.renderPng({...a?.success?{scene:a.data}:{},excalidraw:i.data}).pipe(U.xm_(t=>ap(e,t)));return s instanceof Uint8Array?s:new Uint8Array(s)});return{exportArtifact:U.fn("sketchi.cli.export.artifact")(function*(t,n){let i=yield*e.readExportSource(t,n);return"StoredArtifact"===i._tag?i.bytes:yield*r(t,i)})}})),ay="gemini-3.1-flash-lite",ab="https://playground.sketchi.app/api/v1/generate",av="SKETCHI_GENERATE_ENDPOINT";function aw(){return ny.make({code:"provider_failure",message:"The Sketchi generate API could not be reached.",hint:"Check your network connection and retry. create/show/edit/list/export/restore remain offline; share and pull are separate explicit network commands.",details:["transport"]})}function ax(){return ny.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 a_(){return ny.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 ak=U.fn("sketchi.cli.generate.request")(function*(e){let t=yield*U.$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,...e.type?{type:e.type}:{},model:e.model}),signal:t}),catch:()=>aw()}),r=yield*U.$mh({try:()=>t.text(),catch:()=>aw()});if(!t.ok)return yield*U.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)}`,...(r.issues??[]).flatMap(e=>[...e.message?[e.message]:[],...e.hint?[e.hint]:[]])];switch(r.status){case"generation_timeout":return ny.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 ny.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 ny.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});case"unsupported_diagram_type":return ny.make({code:"unsupported_diagram_type",message:n?.message??"Sketchi does not natively support the requested diagram type.",hint:n?.hint??"Request a flowchart, mindmap, or sequence diagram instead.",details:i});default:return ny.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*U.fJG(ax()))}),aS=U.fn("sketchi.cli.generate")(function*(e){var t,r;let n,i,a=yield*iU,s=yield*ak(e),o=yield*nM(s.document).pipe(U.xm_(()=>a_())),l=yield*nD(nj(o)).pipe(U.xm_(()=>a_())),c=yield*(t=s.scene,(n=nd.Uh.safeParse(t)).success?U.PyW(n.data):U.fJG(ax())),u=yield*(r=s.excalidraw,(i=nd.yE.safeParse(r)).success?U.PyW(i.data):U.fJG(ax())),d={id:l,type:o.type,title:o.spec.title,document:o,scene:c,excalidraw:u};return{diagram:yield*a.create(d),model:s.model||e.model,provider:s.provider}});function aI(e,t){switch(t){case"png":return`${e}.png`;case"excalidraw":return`${e}.excalidraw`;case"scene":return`${e}.scene.json`}}let aE=U.fn("sketchi.cli.exportCreatedDiagram")(function*(e,t,r){let n=yield*ah,i=e.manifest.id,a=function(e,t,r){switch(r._tag){case"Default":return aI(e,t);case"CurrentDirectory":return(0,ry.resolve)(r.cwd,aI(e,"png"));case"ProjectDiagrams":return(0,ry.resolve)(r.cwd,"diagrams",aI(e,"png"));case"Custom":return r.path}}(i,t,r),s=yield*n.exportArtifact(i,t).pipe(U.xm_(e=>a$(e,i,t)));return yield*U.JkU(function*(){if("-"!==a){if("ProjectDiagrams"===r._tag){let e=yield*nz;yield*e.makeDirectory((0,ry.join)(r.cwd,"diagrams"),!0)}yield*i6(a,s)}}).pipe(U.xm_(e=>a$(e,i,t))),{id:i,format:t,destination:a,sizeBytes:s.byteLength,..."-"===a?{stdoutBytes:s}:{}}});function a$(e,t,r){let n=aI(t,r),i=`sketchi export ${t} --format ${r} --dest ${n}`,a="CliExportError"===e._tag?e.details:"CliStorageError"===e._tag?[`storage_error:${e.code}`]:[`filesystem_operation:${e.operation}`,`path:${e.path}`];return n_.make({code:"CliExportError"===e._tag?e.code:"CliStorageError"===e._tag?"invalid_render_artifact":"export_write_failed",diagramId:t,storagePath:`~/.sketchi/diagrams/${t}`,recoveryCommand:i,...a?{details:a}:{},format:r,message:e.message,hint:`The local record is preserved. Retry with: ${i}`})}let aO=U.fn("sketchi.cli.generateWorkflow")(function*(e){let t=yield*aS(e),r=yield*aE(t.diagram,e.format,e.destination);return{generated:t,artifact:r}}),aC=t("node:util"),aT=t("node:process"),aA=(T=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,e=>{let t=0;for(T.lastIndex=0;T.test(e);)t+=1;return e.length-t}),aM=e=>12288===e||e>=65281&&e<=65376||e>=65504&&e<=65510,aN=e=>8987===e||9001===e||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141,aP=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,aR=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,aj=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,aD=/\t{1,1000}/y,aL=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu,aU=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,aF=/\p{M}+/gu,aB={limit:1/0,ellipsis:""},aW=(e,t={},r={})=>{let n=t.limit??1/0,i=t.ellipsis??"",a=t?.ellipsisWidth??(i?aW(i,aB,r).width:0),s=r.controlWidth??0,o=r.tabWidth??8,l=r.emojiWidth??2,c=r.regularWidth??1,u=r.wideWidth??2,d=[[aU,c],[aP,0],[aR,s],[aD,o],[aL,l],[aj,u]],f=0,h=0,p=e.length,m=0,g=!1,y=p,b=Math.max(0,n-a),v=0,w=0,x=0,_=0;e:for(;;){if(w>v||h>=p&&h>f){for(let t of(m=0,(e.slice(v,w)||e.slice(f,h)).replaceAll(aF,""))){let e=t.codePointAt(0)||0;if(x+(_=aM(e)?2:aN(e)?u:c)>b&&(y=Math.min(y,Math.max(v,f)+m)),x+_>n){g=!0;break e}m+=t.length,x+=_}v=w=0}if(h>=p)break;for(let t=0,r=d.length;t<r;t++){let[r,i]=d[t];if(r.lastIndex=h,r.test(e)){if(x+(_=(m=r===aj?aA(e.slice(h,r.lastIndex)):r===aL?1:r.lastIndex-h)*i)>b&&(y=Math.min(y,h+Math.floor((b-x)/i))),x+_>n){g=!0;break e}x+=_,v=f,w=h,h=f=r.lastIndex;continue e}}h+=1}return{width:g?b:x,index:g?y:p,truncated:g,ellipsed:g&&n>=a}},aq={limit:1/0,ellipsis:"",ellipsisWidth:0},aY=(e,t={})=>aW(e,aq,t).width,az="]8;;",aX=RegExp(`(?:\\[(?<code>\\d+)m|\\${az}(?<uri>.*)\u0007)`,"y"),aJ=e=>e>=30&&e<=37||e>=90&&e<=97?39:e>=40&&e<=47||e>=100&&e<=107?49:1===e||2===e?22:3===e?23:4===e?24:7===e?27:8===e?28:9===e?29:0===e?0:void 0,aG=e=>`\x1b[${e}m`,aV=e=>`\x1b${az}${e}\u0007`,aK=(e,t,r)=>{let n=t[Symbol.iterator](),i=!1,a=!1,s=e.at(-1),o=void 0===s?0:aY(s),l=n.next(),c=n.next(),u=0;for(;!l.done;){let s=l.value,d=aY(s);o+d<=r?e[e.length-1]+=s:(e.push(s),o=0),("\x1b"===s||"›"===s)&&(i=!0,a=t.startsWith(az,u+1)),i?a?"\x07"===s&&(i=!1,a=!1):"m"===s&&(i=!1):(o+=d)!==r||c.done||(e.push(""),o=0),l=c,c=n.next(),u+=s.length}s=e.at(-1),!o&&void 0!==s&&s.length&&e.length>1&&(e[e.length-2]+=e.pop())},aH=/\r?\n/;function aQ(e,t,r){return String(e).normalize().split(aH).map(e=>((e,t,r={})=>{let n,i;if(!1!==r.trim&&""===e.trim())return"";let a="",s=e.split(" "),o=[""],l=0;for(let e=0;e<s.length;e++){let n=s[e];if(!1!==r.trim){let e=o.at(-1)??"",t=e.trimStart();e.length!==t.length&&(o[o.length-1]=t,l=aY(t))}0!==e&&(l>=t&&(!1===r.wordWrap||!1===r.trim)&&(o.push(""),l=0),(l||!1===r.trim)&&(o[o.length-1]+=" ",l++));let i=aY(n);if(r.hard&&i>t){let e=1+Math.floor((i-(t-l)-1)/t);Math.floor((i-1)/t)<e&&o.push(""),aK(o,n,t),l=aY(o.at(-1)??"");continue}if(l+i>t&&l&&i){if(!1===r.wordWrap&&l<t){aK(o,n,t),l=aY(o.at(-1)??"");continue}o.push(""),l=0}if(l+i>t&&!1===r.wordWrap){aK(o,n,t),l=aY(o.at(-1)??"");continue}o[o.length-1]+=n,l+=i}!1!==r.trim&&(o=o.map(e=>(e=>{let t=e.split(" "),r=t.length;for(;r&&!aY(t[r-1]);)r--;return r===t.length?e:t.slice(0,r).join(" ")+t.slice(r).join("")})(e)));let c=o.join("\n"),u=!1;for(let e=0;e<c.length;e++){let t=c[e];if(a+=t,u)u=!1;else if(u=t>="\uD800"&&t<="\uDBFF")continue;if("\x1b"===t||"›"===t){aX.lastIndex=e+1;let t=aX.exec(c),r=t?.groups;if(r?.code!==void 0){let e=Number.parseFloat(r.code);n=39===e?void 0:e}else r?.uri!==void 0&&(i=0===r.uri.length?void 0:r.uri)}if("\n"===c[e+1]){i&&(a+=aV(""));let e=n?aJ(n):void 0;n&&e&&(a+=aG(e))}else"\n"===t&&(n&&aJ(n)&&(a+=aG(n)),i&&(a+=aV(i)))}return a})(e,t,r)).join("\n")}var aZ=n(5776);let a0=t("node:tty");function a1(e,t,r){if(!r.some(e=>!e.disabled))return e;let n=e+t,i=Math.max(r.length-1,0),a=n<0?i:n>i?0:n;return r[a]?.disabled?a1(a,t<0?-1:1,r):a}let a2={actions:new Set(["up","down","left","right","space","enter","cancel"]),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"},withGuide:!0,date:{monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],messages:{required:"Please enter a valid date",invalidMonth:"There are only 12 months in a year",invalidDay:(e,t)=>`There are only ${e} days in ${t}`,afterMin:e=>`Date must be on or after ${e.toISOString().slice(0,10)}`,beforeMax:e=>`Date must be on or before ${e.toISOString().slice(0,10)}`}}};function a5(e,t){if("string"==typeof e)return a2.aliases.get(e)===t;for(let r of e)if(void 0!==r&&a5(r,t))return!0;return!1}let a3=globalThis.process.platform.startsWith("win"),a8=Symbol("clack:cancel");function a6(e,t){e.isTTY&&e.setRawMode(t)}let a9=e=>"columns"in e&&"number"==typeof e.columns?e.columns:80,a4=e=>"rows"in e&&"number"==typeof e.rows?e.rows:20;function a7(e,t,r,n=r,i=r,a){return aQ(t,a9(e??aT.stdout)-r.length,{hard:!0,trim:!1}).split(`
4
4
  `).map((e,t,s)=>{let o=a?a(e,t):e;return 0===t?`${n}${o}`:t===s.length-1?`${i}${o}`:`${r}${o}`}).join(`
5
- `)}class aA{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;state="initial";error="";value;userInput="";constructor(e,t=!0){let{input:r=i6.stdin,output:n=i6.stdout,render:i,signal:a,...s}=e;this.opts=s,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=i.bind(this),this._track=t,this._abortSignal=a,this.input=r,this.output=n}unsubscribe(){this._subscribers.clear()}setSubscriber(e,t){let r=this._subscribers.get(e)??[];r.push(t),this._subscribers.set(e,r)}on(e,t){this.setSubscriber(e,{cb:t})}once(e,t){this.setSubscriber(e,{cb:t,once:!0})}emit(e,...t){let r=this._subscribers.get(e)??[],n=[];for(let e of r)e.cb(...t),e.once&&n.push(()=>r.splice(r.indexOf(e),1));for(let e of n)e()}prompt(){return new Promise(e=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),e(aE);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=ns.createInterface({input:this.input,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),void 0!==this.opts.initialUserInput&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on("keypress",this.onKeypress),aI(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(av.cursor.show),this.output.off("resize",this.render),aI(this.input,!1),e(this.value)}),this.once("cancel",()=>{this.output.write(av.cursor.show),this.output.off("resize",this.render),aI(this.input,!1),e(aE)})})}_isActionKey(e,t){return" "===e}_shouldSubmit(e,t){return!0}_setValue(e){this.value=e,this.emit("value",this.value)}_setUserInput(e,t){this.userInput=e??"",this.emit("userInput",this.userInput),t&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:"u"}),this._setUserInput("")}onKeypress(e,t){if(this._track&&"return"!==t.name&&(t.name&&this._isActionKey(e,t)&&this.rl?.write(null,{ctrl:!0,name:"h"}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),"error"===this.state&&(this.state="active"),t?.name&&(!this._track&&ax.aliases.has(t.name)&&this.emit("cursor",ax.aliases.get(t.name)),ax.actions.has(t.name)&&this.emit("cursor",t.name)),e&&("y"===e.toLowerCase()||"n"===e.toLowerCase())&&this.emit("confirm","y"===e.toLowerCase()),this.emit("key",e,t),t?.name==="return"&&this._shouldSubmit(e,t)){if(this.opts.validate){let e=function(e,t){if("~standard"in e){let r=e["~standard"].validate(t);if(r instanceof Promise)throw TypeError("Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic.");return r.issues?.at(0)?.message}return e(t)}(this.opts.validate,this.value);e&&(this.error=e instanceof Error?e.message:e,this.state="error",this.rl?.write(this.userInput))}"error"!==this.state&&(this.state="submit")}ak([e,t?.name,t?.sequence],"cancel")&&(this.state="cancel"),("submit"===this.state||"cancel"===this.state)&&this.emit("finalize"),this.render(),("submit"===this.state||"cancel"===this.state)&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
6
- `),aI(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=ab(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
7
- `).length-1;this.output.write(av.cursor.move(-999,-1*e))}render(){let e=ab(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if(e!==this._prevFrame){if("initial"===this.state)this.output.write(av.cursor.hide);else{let t=function(e,t){if(e===t)return;let r=e.split(`
5
+ `)}class se{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;state="initial";error="";value;userInput="";constructor(e,t=!0){let{input:r=aT.stdin,output:n=aT.stdout,render:i,signal:a,...s}=e;this.opts=s,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=i.bind(this),this._track=t,this._abortSignal=a,this.input=r,this.output=n}unsubscribe(){this._subscribers.clear()}setSubscriber(e,t){let r=this._subscribers.get(e)??[];r.push(t),this._subscribers.set(e,r)}on(e,t){this.setSubscriber(e,{cb:t})}once(e,t){this.setSubscriber(e,{cb:t,once:!0})}emit(e,...t){let r=this._subscribers.get(e)??[],n=[];for(let e of r)e.cb(...t),e.once&&n.push(()=>r.splice(r.indexOf(e),1));for(let e of n)e()}prompt(){return new Promise(e=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),e(a8);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=ns.createInterface({input:this.input,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),void 0!==this.opts.initialUserInput&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on("keypress",this.onKeypress),a6(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(aZ.cursor.show),this.output.off("resize",this.render),a6(this.input,!1),e(this.value)}),this.once("cancel",()=>{this.output.write(aZ.cursor.show),this.output.off("resize",this.render),a6(this.input,!1),e(a8)})})}_isActionKey(e,t){return" "===e}_shouldSubmit(e,t){return!0}_setValue(e){this.value=e,this.emit("value",this.value)}_setUserInput(e,t){this.userInput=e??"",this.emit("userInput",this.userInput),t&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:"u"}),this._setUserInput("")}onKeypress(e,t){if(this._track&&"return"!==t.name&&(t.name&&this._isActionKey(e,t)&&this.rl?.write(null,{ctrl:!0,name:"h"}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),"error"===this.state&&(this.state="active"),t?.name&&(!this._track&&a2.aliases.has(t.name)&&this.emit("cursor",a2.aliases.get(t.name)),a2.actions.has(t.name)&&this.emit("cursor",t.name)),e&&("y"===e.toLowerCase()||"n"===e.toLowerCase())&&this.emit("confirm","y"===e.toLowerCase()),this.emit("key",e,t),t?.name==="return"&&this._shouldSubmit(e,t)){if(this.opts.validate){let e=function(e,t){if("~standard"in e){let r=e["~standard"].validate(t);if(r instanceof Promise)throw TypeError("Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic.");return r.issues?.at(0)?.message}return e(t)}(this.opts.validate,this.value);e&&(this.error=e instanceof Error?e.message:e,this.state="error",this.rl?.write(this.userInput))}"error"!==this.state&&(this.state="submit")}a5([e,t?.name,t?.sequence],"cancel")&&(this.state="cancel"),("submit"===this.state||"cancel"===this.state)&&this.emit("finalize"),this.render(),("submit"===this.state||"cancel"===this.state)&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
6
+ `),a6(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=aQ(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
7
+ `).length-1;this.output.write(aZ.cursor.move(-999,-1*e))}render(){let e=aQ(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if(e!==this._prevFrame){if("initial"===this.state)this.output.write(aZ.cursor.hide);else{let t=function(e,t){if(e===t)return;let r=e.split(`
8
8
  `),n=t.split(`
9
- `),i=Math.max(r.length,n.length),a=[];for(let e=0;e<i;e++)r[e]!==n[e]&&a.push(e);return{lines:a,numLinesBefore:r.length,numLinesAfter:n.length,numLines:i}}(this._prevFrame,e),r=aO(this.output);if(this.restoreCursor(),t){let n=Math.max(0,t.numLinesAfter-r),i=Math.max(0,t.numLinesBefore-r),a=t.lines.find(e=>e>=n);if(void 0===a){this._prevFrame=e;return}if(1===t.lines.length){this.output.write(av.cursor.move(0,a-i)),this.output.write(av.erase.lines(1));let t=e.split(`
10
- `);this.output.write(t[a]),this._prevFrame=e,this.output.write(av.cursor.move(0,t.length-a-1));return}if(t.lines.length>1){if(n<i)a=n;else{let e=a-i;e>0&&this.output.write(av.cursor.move(0,e))}this.output.write(av.erase.down());let t=e.split(`
9
+ `),i=Math.max(r.length,n.length),a=[];for(let e=0;e<i;e++)r[e]!==n[e]&&a.push(e);return{lines:a,numLinesBefore:r.length,numLinesAfter:n.length,numLines:i}}(this._prevFrame,e),r=a4(this.output);if(this.restoreCursor(),t){let n=Math.max(0,t.numLinesAfter-r),i=Math.max(0,t.numLinesBefore-r),a=t.lines.find(e=>e>=n);if(void 0===a){this._prevFrame=e;return}if(1===t.lines.length){this.output.write(aZ.cursor.move(0,a-i)),this.output.write(aZ.erase.lines(1));let t=e.split(`
10
+ `);this.output.write(t[a]),this._prevFrame=e,this.output.write(aZ.cursor.move(0,t.length-a-1));return}if(t.lines.length>1){if(n<i)a=n;else{let e=a-i;e>0&&this.output.write(aZ.cursor.move(0,e))}this.output.write(aZ.erase.down());let t=e.split(`
11
11
  `).slice(a);this.output.write(t.join(`
12
- `)),this._prevFrame=e;return}}this.output.write(av.erase.down())}this.output.write(e),"initial"===this.state&&(this.state="active"),this._prevFrame=e}}}let aC=class extends aA{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){let e=this._selectedValue;this.value=void 0===e?void 0:e.value}constructor(e){super(e,!1),this.options=e.options;let t=this.options.findIndex(({value:t})=>t===e.initialValue),r=-1===t?0:t;this.cursor=this.options[r]?.disabled?a_(r,1,this.options):r,this.changeValue(),this.on("cursor",e=>{switch(e){case"left":case"up":this.cursor=a_(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=a_(this.cursor,1,this.options)}this.changeValue()})}};class aN extends aA{get userInputWithCursor(){if("submit"===this.state)return this.userInput;let e=this.userInput;if(this.cursor>=e.length)return`${this.userInput}\u2588`;let t=e.slice(0,this.cursor),r=e.slice(this.cursor,this.cursor+1),n=e.slice(this.cursor+1);return`${t}${(0,i8.styleText)("inverse",r)}${n}`}get cursor(){return this._cursor}constructor(e){super({...e,initialUserInput:e.initialUserInput??e.initialValue}),this.on("userInput",e=>{this._setValue(e)}),this.on("finalize",()=>{this.value||(this.value=e.defaultValue),void 0===this.value&&(this.value="")})}}let aM="win32"!==i6.platform?"linux"!==i6.env.TERM:!!i6.env.CI||!!i6.env.WT_SESSION||!!i6.env.TERMINUS_SUBLIME||"{cmd::Cmder}"===i6.env.ConEmuTask||"Terminus-Sublime"===i6.env.TERM_PROGRAM||"vscode"===i6.env.TERM_PROGRAM||"xterm-256color"===i6.env.TERM||"alacritty"===i6.env.TERM||"JetBrains-JediTerm"===i6.env.TERMINAL_EMULATOR,aP=(e,t)=>aM?e:t,aR=aP("◆","*"),aj=aP("■","x"),aD=aP("▲","x"),aL=aP("◇","o"),aU=aP("┌","T"),aF=aP("│","|"),aB=aP("└","—"),aY=(aP("┐","T"),aP("┘","—"),aP("●",">")),aW=aP("○"," "),aq=(aP("◻","[•]"),aP("◼","[+]"),aP("◻","[ ]"),aP("▪","•"),aP("─","-"),aP("╮","+"),aP("├","+"),aP("╯","+"),aP("╰","+"),aP("╭","+"),aP("●","•"),aP("◆","*"),aP("▲","!"),aP("■","x"),e=>{switch(e){case"initial":case"active":return(0,i8.styleText)("cyan",aR);case"cancel":return(0,i8.styleText)("red",aj);case"error":return(0,i8.styleText)("yellow",aD);case"submit":return(0,i8.styleText)("green",aL)}}),aX=(e,t,r,n,i,a=!1)=>{let s=t,o=0;if(a)for(let t=n-1;t>=r;t--){let r=e[t];if(r&&(s-=r.length),o++,s<=i)break}else for(let t=r;t<n;t++){let r=e[t];if(r&&(s-=r.length),o++,s<=i)break}return{lineCount:s,removals:o}};(0,i8.styleText)("dim","↑/↓"),(0,i8.styleText)("dim","Space:"),(0,i8.styleText)("dim","Enter:");let aJ=e=>(0,i8.styleText)("magenta",e);aP("─","-"),aP("━","="),aP("█","#");let az=[`${(0,i8.styleText)("dim","↑/↓")} to navigate`,`${(0,i8.styleText)("dim","Enter:")} confirm`],aG=(e,t)=>e.includes(`
12
+ `)),this._prevFrame=e;return}}this.output.write(aZ.erase.down())}this.output.write(e),"initial"===this.state&&(this.state="active"),this._prevFrame=e}}}let st=class extends se{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){let e=this._selectedValue;this.value=void 0===e?void 0:e.value}constructor(e){super(e,!1),this.options=e.options;let t=this.options.findIndex(({value:t})=>t===e.initialValue),r=-1===t?0:t;this.cursor=this.options[r]?.disabled?a1(r,1,this.options):r,this.changeValue(),this.on("cursor",e=>{switch(e){case"left":case"up":this.cursor=a1(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=a1(this.cursor,1,this.options)}this.changeValue()})}};class sr extends se{get userInputWithCursor(){if("submit"===this.state)return this.userInput;let e=this.userInput;if(this.cursor>=e.length)return`${this.userInput}\u2588`;let t=e.slice(0,this.cursor),r=e.slice(this.cursor,this.cursor+1),n=e.slice(this.cursor+1);return`${t}${(0,aC.styleText)("inverse",r)}${n}`}get cursor(){return this._cursor}constructor(e){super({...e,initialUserInput:e.initialUserInput??e.initialValue}),this.on("userInput",e=>{this._setValue(e)}),this.on("finalize",()=>{this.value||(this.value=e.defaultValue),void 0===this.value&&(this.value="")})}}let sn="win32"!==aT.platform?"linux"!==aT.env.TERM:!!aT.env.CI||!!aT.env.WT_SESSION||!!aT.env.TERMINUS_SUBLIME||"{cmd::Cmder}"===aT.env.ConEmuTask||"Terminus-Sublime"===aT.env.TERM_PROGRAM||"vscode"===aT.env.TERM_PROGRAM||"xterm-256color"===aT.env.TERM||"alacritty"===aT.env.TERM||"JetBrains-JediTerm"===aT.env.TERMINAL_EMULATOR,si=(e,t)=>sn?e:t,sa=si("◆","*"),ss=si("■","x"),so=si("▲","x"),sl=si("◇","o"),sc=si("┌","T"),su=si("│","|"),sd=si("└","—"),sf=(si("┐","T"),si("┘","—"),si("●",">")),sh=si("○"," "),sp=(si("◻","[•]"),si("◼","[+]"),si("◻","[ ]"),si("▪","•"),si("─","-"),si("╮","+"),si("├","+"),si("╯","+"),si("╰","+"),si("╭","+"),si("●","•"),si("◆","*"),si("▲","!"),si("■","x"),e=>{switch(e){case"initial":case"active":return(0,aC.styleText)("cyan",sa);case"cancel":return(0,aC.styleText)("red",ss);case"error":return(0,aC.styleText)("yellow",so);case"submit":return(0,aC.styleText)("green",sl)}}),sm=(e,t,r,n,i,a=!1)=>{let s=t,o=0;if(a)for(let t=n-1;t>=r;t--){let r=e[t];if(r&&(s-=r.length),o++,s<=i)break}else for(let t=r;t<n;t++){let r=e[t];if(r&&(s-=r.length),o++,s<=i)break}return{lineCount:s,removals:o}};(0,aC.styleText)("dim","↑/↓"),(0,aC.styleText)("dim","Space:"),(0,aC.styleText)("dim","Enter:");let sg=e=>(0,aC.styleText)("magenta",e);si("─","-"),si("━","="),si("█","#");let sy=[`${(0,aC.styleText)("dim","↑/↓")} to navigate`,`${(0,aC.styleText)("dim","Enter:")} confirm`],sb=(e,t)=>e.includes(`
13
13
  `)?e.split(`
14
14
  `).map(e=>t(e)).join(`
15
- `):t(e),aV=e=>{let t=(e,t)=>{if(void 0===e)return"";let r=e.label??String(e.value);switch(t){case"disabled":return`${(0,i8.styleText)("gray",aW)} ${aG(r,e=>(0,i8.styleText)("gray",e))}${e.hint?` ${(0,i8.styleText)("dim",`(${e.hint??"disabled"})`)}`:""}`;case"selected":return`${aG(r,e=>(0,i8.styleText)("dim",e))}`;case"active":return`${(0,i8.styleText)("green",aY)} ${r}${e.hint?` ${(0,i8.styleText)("dim",`(${e.hint})`)}`:""}`;case"cancelled":return`${aG(r,e=>(0,i8.styleText)(["strikethrough","dim"],e))}`;default:return`${(0,i8.styleText)("dim",aW)} ${aG(r,e=>(0,i8.styleText)("dim",e))}`}},r=e.showInstructions??!0;return new aC({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue,render(){let n=e.withGuide??ax.withGuide,i=`${aq(this.state)} `,a=`${(e=>{switch(e){case"initial":case"active":return(0,i8.styleText)("cyan",aF);case"cancel":return(0,i8.styleText)("red",aF);case"error":return(0,i8.styleText)("yellow",aF);case"submit":return(0,i8.styleText)("green",aF)}})(this.state)} `,s=aT(e.output,e.message,a,i),o=`${n?`${(0,i8.styleText)("gray",aF)}
15
+ `):t(e),sv=e=>{let t=(e,t)=>{if(void 0===e)return"";let r=e.label??String(e.value);switch(t){case"disabled":return`${(0,aC.styleText)("gray",sh)} ${sb(r,e=>(0,aC.styleText)("gray",e))}${e.hint?` ${(0,aC.styleText)("dim",`(${e.hint??"disabled"})`)}`:""}`;case"selected":return`${sb(r,e=>(0,aC.styleText)("dim",e))}`;case"active":return`${(0,aC.styleText)("green",sf)} ${r}${e.hint?` ${(0,aC.styleText)("dim",`(${e.hint})`)}`:""}`;case"cancelled":return`${sb(r,e=>(0,aC.styleText)(["strikethrough","dim"],e))}`;default:return`${(0,aC.styleText)("dim",sh)} ${sb(r,e=>(0,aC.styleText)("dim",e))}`}},r=e.showInstructions??!0;return new st({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue,render(){let n=e.withGuide??a2.withGuide,i=`${sp(this.state)} `,a=`${(e=>{switch(e){case"initial":case"active":return(0,aC.styleText)("cyan",su);case"cancel":return(0,aC.styleText)("red",su);case"error":return(0,aC.styleText)("yellow",su);case"submit":return(0,aC.styleText)("green",su)}})(this.state)} `,s=a7(e.output,e.message,a,i),o=`${n?`${(0,aC.styleText)("gray",su)}
16
16
  `:""}${s}
17
- `;switch(this.state){case"submit":{let r=n?`${(0,i8.styleText)("gray",aF)} `:"",i=aT(e.output,t(this.options[this.cursor],"selected"),r);return`${o}${i}`}case"cancel":{let r=n?`${(0,i8.styleText)("gray",aF)} `:"",i=aT(e.output,t(this.options[this.cursor],"cancelled"),r);return`${o}${i}${n?`
18
- ${(0,i8.styleText)("gray",aF)}`:""}`}default:{let i,a=n?`${(0,i8.styleText)("cyan",aF)} `:"",s=o.split(`
19
- `).length,l=r?(i=[`${n?`${(0,i8.styleText)("cyan",aF)} `:""}${az.join(" • ")}`],n&&i.push((0,i8.styleText)("cyan",aB)),i):n?[(0,i8.styleText)("cyan",aB)]:[],c=l.join(`
20
- `),u=l.length+1;return`${o}${a}${(({cursor:e,options:t,style:r,output:n=process.stdout,maxItems:i=1/0,columnPadding:a=0,rowPadding:s=4})=>{let o=a$(n)-a,l=aO(n),c=(0,i8.styleText)("dim","..."),u=Math.max(l-s,0),d=Math.max(Math.min(i,u),5),f=0;e>=d-3&&(f=Math.max(Math.min(e-d+3,t.length-d),0));let h=d<t.length&&f>0,p=d<t.length&&f+d<t.length,m=Math.min(f+d,t.length),g=[],y=0;h&&y++,p&&y++;let b=f+ +!!h,v=m-!!p;for(let n=b;n<v;n++){let i=t[n],a=ab(i?r(i,n===e):"",o,{hard:!0,trim:!1}).split(`
21
- `);g.push(a),y+=a.length}if(y>u){let t=0,r=0,n=y,i=e-b,a=u,s=()=>aX(g,n,i+1,g.length,a,!0);h?({lineCount:n,removals:t}=aX(g,n,0,i,a),n>a&&(p||(a-=1),{lineCount:n,removals:r}=s())):(p||(a-=1),{lineCount:n,removals:r}=s(),n>a&&(a-=1,{lineCount:n,removals:t}=aX(g,n,0,i,a))),t>0&&(h=!0,g.splice(0,t)),r>0&&(p=!0,g.splice(g.length-r,r))}let w=[];for(let e of(h&&w.push(c),g))for(let t of e)w.push(t);return p&&w.push(c),w})({output:e.output,cursor:this.cursor,options:this.options,maxItems:e.maxItems,columnPadding:a.length,rowPadding:s+u,style:(e,r)=>t(e,e.disabled?"disabled":r?"active":"inactive")}).join(`
17
+ `;switch(this.state){case"submit":{let r=n?`${(0,aC.styleText)("gray",su)} `:"",i=a7(e.output,t(this.options[this.cursor],"selected"),r);return`${o}${i}`}case"cancel":{let r=n?`${(0,aC.styleText)("gray",su)} `:"",i=a7(e.output,t(this.options[this.cursor],"cancelled"),r);return`${o}${i}${n?`
18
+ ${(0,aC.styleText)("gray",su)}`:""}`}default:{let i,a=n?`${(0,aC.styleText)("cyan",su)} `:"",s=o.split(`
19
+ `).length,l=r?(i=[`${n?`${(0,aC.styleText)("cyan",su)} `:""}${sy.join(" • ")}`],n&&i.push((0,aC.styleText)("cyan",sd)),i):n?[(0,aC.styleText)("cyan",sd)]:[],c=l.join(`
20
+ `),u=l.length+1;return`${o}${a}${(({cursor:e,options:t,style:r,output:n=process.stdout,maxItems:i=1/0,columnPadding:a=0,rowPadding:s=4})=>{let o=a9(n)-a,l=a4(n),c=(0,aC.styleText)("dim","..."),u=Math.max(l-s,0),d=Math.max(Math.min(i,u),5),f=0;e>=d-3&&(f=Math.max(Math.min(e-d+3,t.length-d),0));let h=d<t.length&&f>0,p=d<t.length&&f+d<t.length,m=Math.min(f+d,t.length),g=[],y=0;h&&y++,p&&y++;let b=f+ +!!h,v=m-!!p;for(let n=b;n<v;n++){let i=t[n],a=aQ(i?r(i,n===e):"",o,{hard:!0,trim:!1}).split(`
21
+ `);g.push(a),y+=a.length}if(y>u){let t=0,r=0,n=y,i=e-b,a=u,s=()=>sm(g,n,i+1,g.length,a,!0);h?({lineCount:n,removals:t}=sm(g,n,0,i,a),n>a&&(p||(a-=1),{lineCount:n,removals:r}=s())):(p||(a-=1),{lineCount:n,removals:r}=s(),n>a&&(a-=1,{lineCount:n,removals:t}=sm(g,n,0,i,a))),t>0&&(h=!0,g.splice(0,t)),r>0&&(p=!0,g.splice(g.length-r,r))}let w=[];for(let e of(h&&w.push(c),g))for(let t of e)w.push(t);return p&&w.push(c),w})({output:e.output,cursor:this.cursor,options:this.options,maxItems:e.maxItems,columnPadding:a.length,rowPadding:s+u,style:(e,r)=>t(e,e.disabled?"disabled":r?"active":"inactive")}).join(`
22
22
  ${a}`)}
23
23
  ${c}
24
- `}}}}).prompt()};(0,i8.styleText)("gray",aF);let aK=e=>new aN({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,output:e.output,signal:e.signal,input:e.input,render(){let t=e?.withGuide??ax.withGuide,r=`${t?`${(0,i8.styleText)("gray",aF)}
25
- `:""}${aq(this.state)} ${e.message}
26
- `,n=e.placeholder&&e.placeholder.length>0?(0,i8.styleText)("inverse",e.placeholder[0])+(0,i8.styleText)("dim",e.placeholder.slice(1)):(0,i8.styleText)(["inverse","hidden"],"_"),i=this.userInput?this.userInputWithCursor:n,a=this.value??"";switch(this.state){case"error":{let e=this.error?` ${(0,i8.styleText)("yellow",this.error)}`:"",n=t?`${(0,i8.styleText)("yellow",aF)} `:"",a=t?(0,i8.styleText)("yellow",aB):"";return`${r.trim()}
24
+ `}}}}).prompt()};(0,aC.styleText)("gray",su);let sw=e=>new sr({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,output:e.output,signal:e.signal,input:e.input,render(){let t=e?.withGuide??a2.withGuide,r=`${t?`${(0,aC.styleText)("gray",su)}
25
+ `:""}${sp(this.state)} ${e.message}
26
+ `,n=e.placeholder&&e.placeholder.length>0?(0,aC.styleText)("inverse",e.placeholder[0])+(0,aC.styleText)("dim",e.placeholder.slice(1)):(0,aC.styleText)(["inverse","hidden"],"_"),i=this.userInput?this.userInputWithCursor:n,a=this.value??"";switch(this.state){case"error":{let e=this.error?` ${(0,aC.styleText)("yellow",this.error)}`:"",n=t?`${(0,aC.styleText)("yellow",su)} `:"",a=t?(0,aC.styleText)("yellow",sd):"";return`${r.trim()}
27
27
  ${n}${i}
28
28
  ${a}${e}
29
- `}case"submit":{let e=a?` ${(0,i8.styleText)("dim",a)}`:"",n=t?(0,i8.styleText)("gray",aF):"";return`${r}${n}${e}`}case"cancel":{let e=a?` ${(0,i8.styleText)(["strikethrough","dim"],a)}`:"",n=t?(0,i8.styleText)("gray",aF):"";return`${r}${n}${e}${a.trim()?`
30
- ${n}`:""}`}default:{let e=t?`${(0,i8.styleText)("cyan",aF)} `:"",n=t?(0,i8.styleText)("cyan",aB):"";return`${r}${e}${i}
29
+ `}case"submit":{let e=a?` ${(0,aC.styleText)("dim",a)}`:"",n=t?(0,aC.styleText)("gray",su):"";return`${r}${n}${e}`}case"cancel":{let e=a?` ${(0,aC.styleText)(["strikethrough","dim"],a)}`:"",n=t?(0,aC.styleText)("gray",su):"";return`${r}${n}${e}${a.trim()?`
30
+ ${n}`:""}`}default:{let e=t?`${(0,aC.styleText)("cyan",su)} `:"",n=t?(0,aC.styleText)("cyan",sd):"";return`${r}${e}${i}
31
31
  ${n}
32
- `}}}}).prompt();var aH=n(485),aQ=n.n(aH);class aZ extends Z.kl()("@sketchi/cli/GenerateWizard"){}function a0(){return nb.make({code:"prompt_failed",message:"Sketchi could not read the interactive prompt.",hint:"Retry in a terminal, or pass --prompt for noninteractive use."})}function a1(e){return e===aE?U.OH5(()=>((e="",t)=>{let r=t?.output??process.stdout,n=t?.withGuide??ax.withGuide?`${(0,i8.styleText)("gray",aB)} `:"";r.write(`${n}${(0,i8.styleText)("red",e)}
32
+ `}}}}).prompt();var sx=n(485),s_=n.n(sx);class sk extends Z.kl()("@sketchi/cli/GenerateWizard"){}function sS(){return nv.make({code:"prompt_failed",message:"Sketchi could not read the interactive prompt.",hint:"Retry in a terminal, or pass --prompt for noninteractive use."})}function sI(e){return e===a8?U.OH5(()=>((e="",t)=>{let r=t?.output??process.stdout,n=t?.withGuide??a2.withGuide?`${(0,aC.styleText)("gray",sd)} `:"";r.write(`${n}${(0,aC.styleText)("red",e)}
33
33
 
34
- `)})("Generation cancelled.")).pipe(U.hgn(U.fJG(nb.make({code:"cancelled",message:"Generation was cancelled.",hint:"Run sketchi generate again when you are ready."})))):U.PyW(e)}let a2=U.$mh({try:()=>aK({message:"What should Sketchi draw?",placeholder:"Map release approval with pass and revise branches",validate:e=>void 0!==e&&e.trim().length>0?void 0:"Enter a diagram description."}),catch:a0}).pipe(U.qIB(a1)),a5=U.$mh({try:()=>aV({message:"Diagram type",initialValue:"flowchart",options:[{value:"flowchart",label:"Flowchart",hint:"best for processes and decisions"},{value:"mindmap",label:"Mind map",hint:"best for ideas and topics"}]}),catch:a0}).pipe(U.qIB(a1)),a3=U.$mh({try:()=>aV({message:"Save the PNG",initialValue:"current",options:[{value:"current",label:"Current directory",hint:"<generated-id>.png"},{value:"project",label:"Project diagrams folder",hint:"diagrams/<generated-id>.png"},{value:"custom",label:"Custom path",hint:"same semantics as --dest"}]}),catch:a0}).pipe(U.qIB(a1));function a8(e){return void 0===e||0===e.trim().length?"Enter a file path.":"-"===e.trim()?"Interactive generation cannot write PNG bytes to stdout. Enter a file path.":void 0}let a6=U.$mh({try:()=>aK({message:"PNG destination",placeholder:"./diagram.png",validate:a8}),catch:a0}).pipe(U.qIB(a1)),a9=U.fn("sketchi.cli.generateWizard.destination")(function*(){let e=yield*a3;return"current"===e?{_tag:"CurrentDirectory"}:"project"===e?{_tag:"ProjectDiagrams"}:{_tag:"Custom",path:(yield*a6).trim()}}),a4=U.fn("sketchi.cli.generateWizard.ask")(function*(e){yield*U.OH5(()=>((e="",t)=>{let r=t?.output??process.stdout,n=t?.withGuide??ax.withGuide?`${(0,i8.styleText)("gray",aU)} `:"";r.write(`${n}${e}
35
- `)})("Create a diagram with Sketchi"));let t=yield*a2,r=e.type??(yield*a5),n=e.destination??(yield*a9());return{prompt:t.trim(),type:r,destination:n}}),a7=U.Q56(U.OH5(()=>{let e=(({indicator:e="dots",onCancel:t,output:r=process.stdout,cancelMessage:n,errorMessage:i,frames:a=aM?["◒","◐","◓","◑"]:["•","o","O","0"],delay:s=aM?80:120,signal:o,...l}={})=>{let c="true"===process.env.CI,u,d,f=!1,h=!1,p="",m,g=performance.now(),y=a$(r),b=l?.styleFrame??aJ,v=e=>{let r=e>1?i??ax.messages.error:n??ax.messages.cancel;h=1===e,f&&(E(r,e),h&&"function"==typeof t&&t())},w=()=>v(2),_=()=>v(1),x=()=>{if(void 0===m)return;c&&r.write(`
36
- `);let e=ab(m,y,{hard:!0,trim:!1}).split(`
37
- `);e.length>1&&r.write(av.cursor.up(e.length-1)),r.write(av.cursor.to(0)),r.write(av.erase.down())},k=e=>{let t=(performance.now()-e)/1e3,r=Math.floor(t/60),n=Math.floor(t%60);return r>0?`[${r}m ${n}s]`:`[${n}s]`},S=l.withGuide??ax.withGuide,E=(t="",n=0,i=!1)=>{if(!f)return;f=!1,clearInterval(d),x();let a=0===n?(0,i8.styleText)("green",aL):1===n?(0,i8.styleText)("red",aj):(0,i8.styleText)("red",aD);p=t??p,i||("timer"===e?r.write(`${a} ${p} ${k(g)}
34
+ `)})("Generation cancelled.")).pipe(U.hgn(U.fJG(nv.make({code:"cancelled",message:"Generation was cancelled.",hint:"Run sketchi generate again when you are ready."})))):U.PyW(e)}let sE=U.$mh({try:()=>sw({message:"What should Sketchi draw?",placeholder:"Map release approval with pass and revise branches",validate:e=>void 0!==e&&e.trim().length>0?void 0:"Enter a diagram description."}),catch:sS}).pipe(U.qIB(sI)),s$=U.$mh({try:()=>sv({message:"Diagram type",initialValue:"flowchart",options:[{value:"flowchart",label:"Flowchart",hint:"best for processes and decisions"},{value:"mindmap",label:"Mind map",hint:"best for ideas and topics"},{value:"sequence",label:"Sequence diagram",hint:"best for ordered participant interactions"}]}),catch:sS}).pipe(U.qIB(sI)),sO=U.$mh({try:()=>sv({message:"Save the PNG",initialValue:"current",options:[{value:"current",label:"Current directory",hint:"<generated-id>.png"},{value:"project",label:"Project diagrams folder",hint:"diagrams/<generated-id>.png"},{value:"custom",label:"Custom path",hint:"same semantics as --dest"}]}),catch:sS}).pipe(U.qIB(sI));function sC(e){return void 0===e||0===e.trim().length?"Enter a file path.":"-"===e.trim()?"Interactive generation cannot write PNG bytes to stdout. Enter a file path.":void 0}let sT=U.$mh({try:()=>sw({message:"PNG destination",placeholder:"./diagram.png",validate:sC}),catch:sS}).pipe(U.qIB(sI)),sA=U.fn("sketchi.cli.generateWizard.destination")(function*(){let e=yield*sO;return"current"===e?{_tag:"CurrentDirectory"}:"project"===e?{_tag:"ProjectDiagrams"}:{_tag:"Custom",path:(yield*sT).trim()}}),sM=U.fn("sketchi.cli.generateWizard.ask")(function*(e){yield*U.OH5(()=>((e="",t)=>{let r=t?.output??process.stdout,n=t?.withGuide??a2.withGuide?`${(0,aC.styleText)("gray",sc)} `:"";r.write(`${n}${e}
35
+ `)})("Create a diagram with Sketchi"));let t=yield*sE,r=e.type??(yield*s$),n=e.destination??(yield*sA());return{prompt:t.trim(),type:r,destination:n}}),sN=U.Q56(U.OH5(()=>{let e=(({indicator:e="dots",onCancel:t,output:r=process.stdout,cancelMessage:n,errorMessage:i,frames:a=sn?["◒","◐","◓","◑"]:["•","o","O","0"],delay:s=sn?80:120,signal:o,...l}={})=>{let c="true"===process.env.CI,u,d,f=!1,h=!1,p="",m,g=performance.now(),y=a9(r),b=l?.styleFrame??sg,v=e=>{let r=e>1?i??a2.messages.error:n??a2.messages.cancel;h=1===e,f&&(I(r,e),h&&"function"==typeof t&&t())},w=()=>v(2),x=()=>v(1),_=()=>{if(void 0===m)return;c&&r.write(`
36
+ `);let e=aQ(m,y,{hard:!0,trim:!1}).split(`
37
+ `);e.length>1&&r.write(aZ.cursor.up(e.length-1)),r.write(aZ.cursor.to(0)),r.write(aZ.erase.down())},k=e=>{let t=(performance.now()-e)/1e3,r=Math.floor(t/60),n=Math.floor(t%60);return r>0?`[${r}m ${n}s]`:`[${n}s]`},S=l.withGuide??a2.withGuide,I=(t="",n=0,i=!1)=>{if(!f)return;f=!1,clearInterval(d),_();let a=0===n?(0,aC.styleText)("green",sl):1===n?(0,aC.styleText)("red",ss):(0,aC.styleText)("red",so);p=t??p,i||("timer"===e?r.write(`${a} ${p} ${k(g)}
38
38
  `):r.write(`${a} ${p}
39
- `)),process.removeListener("uncaughtExceptionMonitor",w),process.removeListener("unhandledRejection",w),process.removeListener("SIGINT",_),process.removeListener("SIGTERM",_),process.removeListener("exit",v),o&&o.removeEventListener("abort",_),u()};return{start:(t="")=>{f=!0,u=function({input:e=i6.stdin,output:t=i6.stdout,overwrite:r=!0,hideCursor:n=!0}={}){let i=ns.createInterface({input:e,output:t,prompt:"",tabSize:1});ns.emitKeypressEvents(e,i),e instanceof aw.ReadStream&&e.isTTY&&e.setRawMode(!0);let a=(i,{name:s,sequence:o})=>{if(ak([String(i),s,o],"cancel")){n&&t.write(av.cursor.show),process.exit(0);return}r&&ns.moveCursor(t,"return"===s?0:-1,"return"===s?-1:0,()=>{ns.clearLine(t,1,()=>{e.once("keypress",a)})})};return n&&t.write(av.cursor.hide),e.once("keypress",a),()=>{e.off("keypress",a),n&&t.write(av.cursor.show),e instanceof aw.ReadStream&&e.isTTY&&!aS&&e.setRawMode(!1),i.terminal=!1,i.close()}}({output:r}),p=t.replace(/\.+$/,""),g=performance.now(),S&&r.write(`${(0,i8.styleText)("gray",aF)}
40
- `);let n=0,i=0;process.on("uncaughtExceptionMonitor",w),process.on("unhandledRejection",w),process.on("SIGINT",_),process.on("SIGTERM",_),process.on("exit",v),o&&o.addEventListener("abort",_),d=setInterval(()=>{let t;if(c&&p===m)return;x(),m=p;let s=b(a[n]);if(c)t=`${s} ${p}...`;else if("timer"===e)t=`${s} ${p} ${k(g)}`;else{let e=".".repeat(Math.floor(i)).slice(0,3);t=`${s} ${p}${e}`}let o=ab(t,y,{hard:!0,trim:!1});r.write(o),n=n+1<a.length?n+1:0,i=i<4?i+.125:0},s)},stop:(e="")=>E(e,0),message:(e="")=>{p=(e??p).replace(/\.+$/,"")},cancel:(e="")=>E(e,1),error:(e="")=>E(e,2),clear:()=>E("",0,!0),get isCancelled(){return h}}})({output:process.stdout}),t=!1;return e.start("Sketchi is drawing"),{succeed:r=>U.OH5(()=>{t||(t=!0,e.stop(r))}),fail:r=>U.OH5(()=>{t||(t=!0,e.error(r))}),finish:r=>U.OH5(()=>{t||(t=!0,F.N6(r)?e.error("Generation stopped"):e.clear())})}}),(e,t)=>e.finish(t)).pipe(U.TjK(e=>({succeed:e.succeed,fail:e.fail}))),se=z.Py(aZ,{ask:a4,activity:a7}),st=ed.z4N,sr=e=>eu.R6(t=>e(t.getRef(st))),sn=(...e)=>sr(t=>ed.OH5(()=>{t.error(...e)})),si=(...e)=>sr(t=>ed.OH5(()=>{t.log(...e)})),sa="~effect/cli/CliError";class ss extends nt.X0d(`${sa}/UnrecognizedOption`)("UnrecognizedOption",{option:nt.QfV,command:nt.lqM(nt.O31(nt.QfV)),suggestions:nt.O31(nt.QfV)}){[sa]=sa;get message(){let e=this.suggestions.length>0?`
39
+ `)),process.removeListener("uncaughtExceptionMonitor",w),process.removeListener("unhandledRejection",w),process.removeListener("SIGINT",x),process.removeListener("SIGTERM",x),process.removeListener("exit",v),o&&o.removeEventListener("abort",x),u()};return{start:(t="")=>{f=!0,u=function({input:e=aT.stdin,output:t=aT.stdout,overwrite:r=!0,hideCursor:n=!0}={}){let i=ns.createInterface({input:e,output:t,prompt:"",tabSize:1});ns.emitKeypressEvents(e,i),e instanceof a0.ReadStream&&e.isTTY&&e.setRawMode(!0);let a=(i,{name:s,sequence:o})=>{if(a5([String(i),s,o],"cancel")){n&&t.write(aZ.cursor.show),process.exit(0);return}r&&ns.moveCursor(t,"return"===s?0:-1,"return"===s?-1:0,()=>{ns.clearLine(t,1,()=>{e.once("keypress",a)})})};return n&&t.write(aZ.cursor.hide),e.once("keypress",a),()=>{e.off("keypress",a),n&&t.write(aZ.cursor.show),e instanceof a0.ReadStream&&e.isTTY&&!a3&&e.setRawMode(!1),i.terminal=!1,i.close()}}({output:r}),p=t.replace(/\.+$/,""),g=performance.now(),S&&r.write(`${(0,aC.styleText)("gray",su)}
40
+ `);let n=0,i=0;process.on("uncaughtExceptionMonitor",w),process.on("unhandledRejection",w),process.on("SIGINT",x),process.on("SIGTERM",x),process.on("exit",v),o&&o.addEventListener("abort",x),d=setInterval(()=>{let t;if(c&&p===m)return;_(),m=p;let s=b(a[n]);if(c)t=`${s} ${p}...`;else if("timer"===e)t=`${s} ${p} ${k(g)}`;else{let e=".".repeat(Math.floor(i)).slice(0,3);t=`${s} ${p}${e}`}let o=aQ(t,y,{hard:!0,trim:!1});r.write(o),n=n+1<a.length?n+1:0,i=i<4?i+.125:0},s)},stop:(e="")=>I(e,0),message:(e="")=>{p=(e??p).replace(/\.+$/,"")},cancel:(e="")=>I(e,1),error:(e="")=>I(e,2),clear:()=>I("",0,!0),get isCancelled(){return h}}})({output:process.stdout}),t=!1;return e.start("Sketchi is drawing"),{succeed:r=>U.OH5(()=>{t||(t=!0,e.stop(r))}),fail:r=>U.OH5(()=>{t||(t=!0,e.error(r))}),finish:r=>U.OH5(()=>{t||(t=!0,F.N6(r)?e.error("Generation stopped"):e.clear())})}}),(e,t)=>e.finish(t)).pipe(U.TjK(e=>({succeed:e.succeed,fail:e.fail}))),sP=J.Py(sk,{ask:sM,activity:sN}),sR=ed.z4N,sj=e=>eu.R6(t=>e(t.getRef(sR))),sD=(...e)=>sj(t=>ed.OH5(()=>{t.error(...e)})),sL=(...e)=>sj(t=>ed.OH5(()=>{t.log(...e)})),sU="~effect/cli/CliError";class sF extends nt.X0d(`${sU}/UnrecognizedOption`)("UnrecognizedOption",{option:nt.QfV,command:nt.lqM(nt.O31(nt.QfV)),suggestions:nt.O31(nt.QfV)}){[sU]=sU;get message(){let e=this.suggestions.length>0?`
41
41
 
42
42
  Did you mean this?
43
- ${this.suggestions.join("\n ")}`:"";return(this.command?`Unrecognized flag: ${this.option} in command ${this.command.join(" ")}`:`Unrecognized flag: ${this.option}`)+e}}class so extends nt.X0d(`${sa}/DuplicateOption`)("DuplicateOption",{option:nt.QfV,parentCommand:nt.QfV,childCommand:nt.QfV}){[sa]=sa;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 sl extends nt.X0d(`${sa}/MissingOption`)("MissingOption",{option:nt.QfV}){[sa]=sa;get message(){return`Missing required flag: --${this.option}`}}class sc extends nt.X0d(`${sa}/MissingArgument`)("MissingArgument",{argument:nt.QfV}){[sa]=sa;get message(){return`Missing required argument: ${this.argument}`}}class su extends nt.X0d(`${sa}/InvalidValue`)("InvalidValue",{option:nt.QfV,value:nt.QfV,expected:nt.QfV,kind:nt.gPz([nt.uSQ("flag"),nt.uSQ("argument")])}){[sa]=sa;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 sd extends nt.X0d(`${sa}/UnknownSubcommand`)("UnknownSubcomand",{subcommand:nt.QfV,parent:nt.lqM(nt.O31(nt.QfV)),suggestions:nt.O31(nt.QfV)}){[sa]=sa;get message(){let e=this.suggestions.length>0?`
43
+ ${this.suggestions.join("\n ")}`:"";return(this.command?`Unrecognized flag: ${this.option} in command ${this.command.join(" ")}`:`Unrecognized flag: ${this.option}`)+e}}class sB extends nt.X0d(`${sU}/DuplicateOption`)("DuplicateOption",{option:nt.QfV,parentCommand:nt.QfV,childCommand:nt.QfV}){[sU]=sU;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 sW extends nt.X0d(`${sU}/MissingOption`)("MissingOption",{option:nt.QfV}){[sU]=sU;get message(){return`Missing required flag: --${this.option}`}}class sq extends nt.X0d(`${sU}/MissingArgument`)("MissingArgument",{argument:nt.QfV}){[sU]=sU;get message(){return`Missing required argument: ${this.argument}`}}class sY extends nt.X0d(`${sU}/InvalidValue`)("InvalidValue",{option:nt.QfV,value:nt.QfV,expected:nt.QfV,kind:nt.gPz([nt.uSQ("flag"),nt.uSQ("argument")])}){[sU]=sU;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 sz extends nt.X0d(`${sU}/UnknownSubcommand`)("UnknownSubcomand",{subcommand:nt.QfV,parent:nt.lqM(nt.O31(nt.QfV)),suggestions:nt.O31(nt.QfV)}){[sU]=sU;get message(){let e=this.suggestions.length>0?`
44
44
 
45
45
  Did you mean this?
46
- ${this.suggestions.join("\n ")}`:"";return this.parent?`Unknown subcommand "${this.subcommand}" for "${this.parent.join(" ")}"${e}`:`Unknown subcommand "${this.subcommand}"${e}`}}class sf extends nt.X0d(`${sa}/UserError`)("UserError",{cause:nt.kld()}){[sa]=sa}let sh=nt.gPz([ss,so,sl,sc,su,sd,sf]);class sp extends nt.X0d(`${sa}/ShowHelp`)("ShowHelp",{commandPath:nt.O31(nt.QfV),errors:nt.O31(sh)}){[sa]=sa;[W]=+!!this.errors.length;[X]=!1;get message(){return"Help requested"}}n(2532),n(3176),n(2976);let sm=Z.Or("effect/ConfigProvider",{defaultValue:()=>(function(){var e;let t,r,n=(void 0)??{...globalThis?.process?.env,...import.meta?.env},i=false,a=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=>U.PyW(function(e,t,r,n){var i;let a=(i=t[r.map(String).join("_")],""!==i||n?i:void 0),s=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=s?.children?Object.keys(s.children):[];return 0===o.length?void 0===a?void 0:{_tag:"Value",value:a}:o.every(e=>sb.test(e))?{_tag:"Array",length:Math.max(...o.map(e=>parseInt(e,10)))+1,value:a}:{_tag:"Record",keys:new Set(o),value:a}}(a,n,e,i)),transform:sy},e=e=>t.get(t.transform(e)),(r=Object.create(sg)).state=t,r.load=e,r})()}),sg={...eu.fU,toJSON:()=>({_id:"ConfigProvider"})},sy=e=>e,sb=/^(0|[1-9][0-9]*)$/;ed.LkF,ed.OPA;var sv=n(5348);let sw=nt.xCb(["true","yes","on","1","y"]),s_=nt.xCb(["false","no","off","0","n"]),sx=nt.xCb([...sw.literals,...s_.literals]).pipe(nt.GLL(nt.v8c,sv.pd({decode:e=>"true"===e||"yes"===e||"on"===e||"1"===e||"y"===e,encode:e=>e?"true":"false"})));var sk=n(6470);let sS={"~effect/cli/Primitive":{_A:B.D_}},sE=nt.is(sw),sI=nt.is(s_),s$=e=>"Boolean"===e._tag,sO=(e,t)=>Object.assign(Object.create(sS),{_tag:e,parse:t}),sT=(e,t)=>{let r=nt.lHk(t),n=nt._Re(r);return sO(e,e=>U.xm_(n(e),e=>e.message))},sA=sT("Boolean",sx);nt.wYs;let sC=sT("Integer",nt.Aiz);nt.Nej;let sN=sO("String",e=>U.PyW(e)),sM=(()=>U.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"}}),sP=e=>"Choice"===e._tag?e.choiceKeys:void 0,sR="~effect/cli/Param",sj="argument",sD={[sR]:{_A:B.D_},pipe(){return(0,eo.tT)(this,arguments)}},sL=e=>"flag"===e.kind,sU=e=>Object.assign(Object.create(sD),{_tag:"Single",...e,description:e.description??K.none(),aliases:e.aliases??[],hidden:e.hidden??!1,parse:t=>e.kind===sj?sZ(e.name,e.primitiveType,t):s0(e.name,e.primitiveType,t)}),sF=(e,t)=>sU({name:t,primitiveType:sN,kind:e}),sB=(e,t,r)=>{let n,i;return sU({name:t,primitiveType:(n=new Map(r),i=r.map(([e])=>(0,sk.GP)(e)).join(" | "),Object.assign(sO("Choice",e=>n.has(e)?U.PyW(n.get(e)):U.fJG(`Expected ${i}, got ${(0,sk.GP)(e)}`)),{choiceKeys:r.map(([e])=>e)})),kind:e})},sY=/^-+/,sW=(0,B.XY)(2,(e,t)=>s3(e,e=>sU({...e,aliases:[...e.aliases,t.replace(sY,"")]}))),sq=(0,B.XY)(2,(e,t)=>s3(e,e=>sU({...e,description:K.some(t)}))),sX=(0,B.XY)(2,(e,t)=>Object.assign(Object.create(sD),{_tag:"Map",kind:e.kind,param:e,f:t,parse:r=>U.TjK(e.parse(r),([e,r])=>[e,t(r)])})),sJ=(e,t)=>Object.assign(Object.create(sD),{_tag:"Transform",kind:e.kind,param:e,f:t,parse:t(e.parse)}),sz=(0,B.XY)(2,(e,t)=>sJ(e,e=>r=>U.qIB(e(r),([e,r])=>t(r).pipe(U.TjK(t=>[e,t]))))),sG=e=>{let t=U.D9k(function*(t){let r=s6(e);return sL(r)&&s$(r.primitiveType)&&![r.name,...r.aliases].some(e=>(t.flags[e]??[]).length>0)?[t.arguments,K.none()]:yield*e.parse(t).pipe(U.TjK(([e,t])=>[e,K.some(t)]),U.loE({MissingOption:()=>U.PyW([t.arguments,K.none()]),MissingArgument:()=>U.PyW([t.arguments,K.none()])}))});return Object.assign(Object.create(sD),{_tag:"Optional",kind:e.kind,param:e,parse:t})},sV=(0,B.XY)(2,(e,t)=>U.yw5(t)?sz(sG(e),K.match({onNone:()=>t,onSome:U.PyW})):sX(sG(e),K.getOrElse(()=>t))),sK=(0,B.XY)(3,(e,t,r)=>sz(e,U.D9k(function*(n){let i=t(n);if(K.isSome(i))return i.value;let a=s6(e);return yield*new su({option:a.name,value:String(n),expected:r(n),kind:a.kind})}))),sH=(0,B.XY)(3,(e,t,r)=>sK(e,K.liftPredicate(t),r)),sQ=(0,B.XY)(2,(e,t)=>s3(e,e=>sU({...e,typeName:t}))),sZ=U.D9k(function*(e,t,r){if(0===r.arguments.length)return yield*new sc({argument:e});let n=r.arguments[0],i=yield*U.xm_(t.parse(n),t=>new su({option:e,value:n,expected:t,kind:"argument"}));return[r.arguments.slice(1),i]}),s0=U.D9k(function*(e,t,r){let n=r.flags[e];if(void 0===n||0===n.length)if(s$(t))return[r.arguments,!1];else return yield*new sl({option:e});let i=n[0],a=yield*U.xm_(t.parse(i),t=>new su({option:e,value:i,expected:t,kind:"flag"}));return[r.arguments,a]}),s1=U.D9k(function*(e,t,r,n){let i=[],a=n?.min??0,s=n?.max??1/0,o=0,l=r.arguments;for(;l.length>0&&o<s;){let[t,n]=yield*e.parse({flags:r.flags,arguments:l});i.push(n),l=t,o++}return o<a?yield*new su({option:t.name,value:`${o} values`,expected:`at least ${a} value${1===a?"":"s"}`,kind:t.kind}):[l,i]}),s2=U.D9k(function*(e,t,r,n){let i=[],a=[t.name,...t.aliases].flatMap(e=>r.flags[e]??[]),s=a.length;if(el.EA(n?.min)&&s<n.min)return yield*0===s?new sl({option:t.name}):new su({option:t.name,value:`${s} occurrences`,expected:`at least ${n.min} value${1===n.min?"":"s"}`,kind:t.kind});if(el.EA(n?.max)&&s>n.max)return yield*new su({option:t.name,value:`${s} occurrences`,expected:`at most ${n.max} value${1===n.max?"":"s"}`,kind:t.kind});for(let r of a){let[,n]=yield*e.parse({flags:{[t.name]:[r]},arguments:[]});i.push(n)}return[r.arguments,i]}),s5=(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)}},s3=(e,t)=>s5(e,{Single:e=>t(e),Map:e=>sX(s3(e.param,t),e.f),Transform:e=>sJ(s3(e.param,t),e.f),Optional:e=>sG(s3(e.param,t)),Variadic:e=>{var r,n;let i;return r=s3(e.param,t),n={min:K.getOrUndefined(e.min),max:K.getOrUndefined(e.max)},i=s6(r),Object.assign(Object.create(sD),{_tag:"Variadic",kind:r.kind,param:r,min:K.fromUndefinedOr(n?.min),max:K.fromUndefinedOr(n?.max),parse:e=>"argument"===i.kind?s1(r,i,e,n):s2(r,i,e,n)})}}),s8=e=>s5(e,{Single:e=>[e],Map:e=>s8(e.param),Transform:e=>s8(e.param),Optional:e=>s8(e.param),Variadic:e=>s8(e.param)}),s6=e=>{let t=s8(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]},s9=e=>s5(e,{Single:()=>({isOptional:!1,isVariadic:!1,variadicMin:K.none(),variadicMax:K.none()}),Map:e=>s9(e.param),Transform:e=>s9(e.param),Optional:e=>({...s9(e.param),isOptional:!0}),Variadic:e=>({...s9(e.param),isVariadic:!0,variadicMin:e.min,variadicMax:e.max})});var s4=n(3864);let s7=Z.Or("effect/cli/CliOutput",{defaultValue:()=>oe()}),oe=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},a=n?"\x1b[0m":"",s=n?"\x1b[31m":"",o=n?"\x1b[1m":"";return{formatHelpDoc:e=>oi(e,i),formatCliError:e=>e.message,formatError:e=>`
46
+ ${this.suggestions.join("\n ")}`:"";return this.parent?`Unknown subcommand "${this.subcommand}" for "${this.parent.join(" ")}"${e}`:`Unknown subcommand "${this.subcommand}"${e}`}}class sX extends nt.X0d(`${sU}/UserError`)("UserError",{cause:nt.kld()}){[sU]=sU}let sJ=nt.gPz([sF,sB,sW,sq,sY,sz,sX]);class sG extends nt.X0d(`${sU}/ShowHelp`)("ShowHelp",{commandPath:nt.O31(nt.QfV),errors:nt.O31(sJ)}){[sU]=sU;[q]=+!!this.errors.length;[z]=!1;get message(){return"Help requested"}}n(2532),n(3176),n(2976);let sV=Z.Or("effect/ConfigProvider",{defaultValue:()=>(function(){var e;let t,r,n=(void 0)??{...globalThis?.process?.env,...import.meta?.env},i=false,a=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=>U.PyW(function(e,t,r,n){var i;let a=(i=t[r.map(String).join("_")],""!==i||n?i:void 0),s=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=s?.children?Object.keys(s.children):[];return 0===o.length?void 0===a?void 0:{_tag:"Value",value:a}:o.every(e=>sQ.test(e))?{_tag:"Array",length:Math.max(...o.map(e=>parseInt(e,10)))+1,value:a}:{_tag:"Record",keys:new Set(o),value:a}}(a,n,e,i)),transform:sH},e=e=>t.get(t.transform(e)),(r=Object.create(sK)).state=t,r.load=e,r})()}),sK={...eu.fU,toJSON:()=>({_id:"ConfigProvider"})},sH=e=>e,sQ=/^(0|[1-9][0-9]*)$/;ed.LkF,ed.OPA;var sZ=n(5348);let s0=nt.xCb(["true","yes","on","1","y"]),s1=nt.xCb(["false","no","off","0","n"]),s2=nt.xCb([...s0.literals,...s1.literals]).pipe(nt.GLL(nt.v8c,sZ.pd({decode:e=>"true"===e||"yes"===e||"on"===e||"1"===e||"y"===e,encode:e=>e?"true":"false"})));var s5=n(6470);let s3={"~effect/cli/Primitive":{_A:B.D_}},s8=nt.is(s0),s6=nt.is(s1),s9=e=>"Boolean"===e._tag,s4=(e,t)=>Object.assign(Object.create(s3),{_tag:e,parse:t}),s7=(e,t)=>{let r=nt.lHk(t),n=nt._Re(r);return s4(e,e=>U.xm_(n(e),e=>e.message))},oe=s7("Boolean",s2);nt.wYs;let ot=s7("Integer",nt.Aiz);nt.Nej;let or=s4("String",e=>U.PyW(e)),on=(()=>U.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"}}),oi=e=>"Choice"===e._tag?e.choiceKeys:void 0,oa="~effect/cli/Param",os="argument",oo={[oa]:{_A:B.D_},pipe(){return(0,eo.tT)(this,arguments)}},ol=e=>"flag"===e.kind,oc=e=>Object.assign(Object.create(oo),{_tag:"Single",...e,description:e.description??K.none(),aliases:e.aliases??[],hidden:e.hidden??!1,parse:t=>e.kind===os?ok(e.name,e.primitiveType,t):oS(e.name,e.primitiveType,t)}),ou=(e,t)=>oc({name:t,primitiveType:or,kind:e}),od=(e,t,r)=>{let n,i;return oc({name:t,primitiveType:(n=new Map(r),i=r.map(([e])=>(0,s5.GP)(e)).join(" | "),Object.assign(s4("Choice",e=>n.has(e)?U.PyW(n.get(e)):U.fJG(`Expected ${i}, got ${(0,s5.GP)(e)}`)),{choiceKeys:r.map(([e])=>e)})),kind:e})},of=/^-+/,oh=(0,B.XY)(2,(e,t)=>oO(e,e=>oc({...e,aliases:[...e.aliases,t.replace(of,"")]}))),op=(0,B.XY)(2,(e,t)=>oO(e,e=>oc({...e,description:K.some(t)}))),om=(0,B.XY)(2,(e,t)=>Object.assign(Object.create(oo),{_tag:"Map",kind:e.kind,param:e,f:t,parse:r=>U.TjK(e.parse(r),([e,r])=>[e,t(r)])})),og=(e,t)=>Object.assign(Object.create(oo),{_tag:"Transform",kind:e.kind,param:e,f:t,parse:t(e.parse)}),oy=(0,B.XY)(2,(e,t)=>og(e,e=>r=>U.qIB(e(r),([e,r])=>t(r).pipe(U.TjK(t=>[e,t]))))),ob=e=>{let t=U.D9k(function*(t){let r=oT(e);return ol(r)&&s9(r.primitiveType)&&![r.name,...r.aliases].some(e=>(t.flags[e]??[]).length>0)?[t.arguments,K.none()]:yield*e.parse(t).pipe(U.TjK(([e,t])=>[e,K.some(t)]),U.loE({MissingOption:()=>U.PyW([t.arguments,K.none()]),MissingArgument:()=>U.PyW([t.arguments,K.none()])}))});return Object.assign(Object.create(oo),{_tag:"Optional",kind:e.kind,param:e,parse:t})},ov=(0,B.XY)(2,(e,t)=>U.yw5(t)?oy(ob(e),K.match({onNone:()=>t,onSome:U.PyW})):om(ob(e),K.getOrElse(()=>t))),ow=(0,B.XY)(3,(e,t,r)=>oy(e,U.D9k(function*(n){let i=t(n);if(K.isSome(i))return i.value;let a=oT(e);return yield*new sY({option:a.name,value:String(n),expected:r(n),kind:a.kind})}))),ox=(0,B.XY)(3,(e,t,r)=>ow(e,K.liftPredicate(t),r)),o_=(0,B.XY)(2,(e,t)=>oO(e,e=>oc({...e,typeName:t}))),ok=U.D9k(function*(e,t,r){if(0===r.arguments.length)return yield*new sq({argument:e});let n=r.arguments[0],i=yield*U.xm_(t.parse(n),t=>new sY({option:e,value:n,expected:t,kind:"argument"}));return[r.arguments.slice(1),i]}),oS=U.D9k(function*(e,t,r){let n=r.flags[e];if(void 0===n||0===n.length)if(s9(t))return[r.arguments,!1];else return yield*new sW({option:e});let i=n[0],a=yield*U.xm_(t.parse(i),t=>new sY({option:e,value:i,expected:t,kind:"flag"}));return[r.arguments,a]}),oI=U.D9k(function*(e,t,r,n){let i=[],a=n?.min??0,s=n?.max??1/0,o=0,l=r.arguments;for(;l.length>0&&o<s;){let[t,n]=yield*e.parse({flags:r.flags,arguments:l});i.push(n),l=t,o++}return o<a?yield*new sY({option:t.name,value:`${o} values`,expected:`at least ${a} value${1===a?"":"s"}`,kind:t.kind}):[l,i]}),oE=U.D9k(function*(e,t,r,n){let i=[],a=[t.name,...t.aliases].flatMap(e=>r.flags[e]??[]),s=a.length;if(el.EA(n?.min)&&s<n.min)return yield*0===s?new sW({option:t.name}):new sY({option:t.name,value:`${s} occurrences`,expected:`at least ${n.min} value${1===n.min?"":"s"}`,kind:t.kind});if(el.EA(n?.max)&&s>n.max)return yield*new sY({option:t.name,value:`${s} occurrences`,expected:`at most ${n.max} value${1===n.max?"":"s"}`,kind:t.kind});for(let r of a){let[,n]=yield*e.parse({flags:{[t.name]:[r]},arguments:[]});i.push(n)}return[r.arguments,i]}),o$=(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)}},oO=(e,t)=>o$(e,{Single:e=>t(e),Map:e=>om(oO(e.param,t),e.f),Transform:e=>og(oO(e.param,t),e.f),Optional:e=>ob(oO(e.param,t)),Variadic:e=>{var r,n;let i;return r=oO(e.param,t),n={min:K.getOrUndefined(e.min),max:K.getOrUndefined(e.max)},i=oT(r),Object.assign(Object.create(oo),{_tag:"Variadic",kind:r.kind,param:r,min:K.fromUndefinedOr(n?.min),max:K.fromUndefinedOr(n?.max),parse:e=>"argument"===i.kind?oI(r,i,e,n):oE(r,i,e,n)})}}),oC=e=>o$(e,{Single:e=>[e],Map:e=>oC(e.param),Transform:e=>oC(e.param),Optional:e=>oC(e.param),Variadic:e=>oC(e.param)}),oT=e=>{let t=oC(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]},oA=e=>o$(e,{Single:()=>({isOptional:!1,isVariadic:!1,variadicMin:K.none(),variadicMax:K.none()}),Map:e=>oA(e.param),Transform:e=>oA(e.param),Optional:e=>({...oA(e.param),isOptional:!0}),Variadic:e=>({...oA(e.param),isVariadic:!0,variadicMin:e.min,variadicMax:e.max})});var oM=n(3864);let oN=Z.Or("effect/cli/CliOutput",{defaultValue:()=>oP()}),oP=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},a=n?"\x1b[0m":"",s=n?"\x1b[31m":"",o=n?"\x1b[1m":"";return{formatHelpDoc:e=>oL(e,i),formatCliError:e=>e.message,formatError:e=>`
47
47
  ${o}${s}ERROR${a}
48
48
  ${e.message}${a}`,formatErrors:e=>{if(0===e.length)return"";if(1===e.length)return`
49
49
  ${o}${s}ERROR${a}
50
50
  ${e[0].message}${a}`;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(`
51
- ${o}${s}ERRORS${a}`),t))for(let t of e)r.push(` ${t.message}${a}`);return r.join("\n")},formatVersion:(e,t)=>`${i.bold(e)} ${i.dim("v")}${i.bold(t)}`}},ot=e=>e.replace(/\u001B\[[0-9;]*m/g,"").length,or=(e,t)=>{let r=Math.max(...e.map(e=>ot(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-ot(e)),e+" ".repeat(r)}${t}`}).join("\n")},on=(e,t)=>t?`${e}, ${t}`:e,oi=(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),a=`${n} ${i}`,s=e.required?"":t.dim(" (optional)");return{left:a,right:K.getOrElse(e.description,()=>"")+s}});r.push(or(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:K.getOrElse(e.description,()=>"")}});r.push(or(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:K.getOrElse(e.description,()=>"")}});r.push(or(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(or(n.commands.map(e=>({left:t.cyan(on(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(or(i.commands.map(e=>({left:t.cyan(on(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 a of e.examples)a.description?(n||r.push(""),r.push(` ${t.dim(`# ${a.description}`)}`)):i&&r.push(""),r.push(` ${t.cyan(a.command)}`),n=!1,i=!!a.description;r.push("")}return""===r[r.length-1]&&r.pop(),r.join("\n")},oa=e=>e.replace(/[^a-zA-Z0-9_]/g,"_"),os=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},oo=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") )'}},ol=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}},oc=(e,t,r)=>{let n=[...t,e.name],i=`_${n.map(oa).join("_")}`;r.push(`${i}()`),r.push("{"),r.push(" local cur prev words cword"),r.push(" _init_completion || return"),r.push("");let a=e.flags.filter(e=>"Boolean"!==e.type._tag);if(a.length>0){for(let e of(r.push(" # Flag value completions"),r.push(' case "$prev" in'),a)){let t=[`--${e.name}`];for(let r of e.aliases)t.push(1===r.length?`-${r}`:`--${r}`);let n=oo(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(oa).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 os(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(os).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 s=e.arguments.filter(e=>void 0!==ol(e.type));if(s.length>0)for(let e of(r.push(" # Positional argument completions"),s)){let t=ol(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))oc(t,n,r)},ou=e=>e.replace(/'/g,"\\'"),od=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(" ")}`},of=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 '${ou(e.description)}'`);let r=oh(e.type);return r&&t.push(r),t},oh=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"}},op=e=>{switch(e._tag){case"Choice":return`-r -f -a '${e.values.join(" ")}'`;case"Path":return"-r -F";default:return}},om=(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)),a=i?`-n '${i}'`:"";if(!t.arguments.some(e=>"Path"===e.type._tag)){let t=[`complete -c ${e}`];a&&t.push(a),t.push("-f"),n.push(t.join(" "))}for(let r of t.subcommands){let t=[`complete -c ${e}`];a&&t.push(a),t.push(`-f -a '${ou(r.name)}'`),r.description&&t.push(`-d '${ou(r.description)}'`),n.push(t.join(" "))}for(let r of t.flags){let t="Boolean"===r.type._tag,a=t?i?`${i}; and ${od(r)}`:od(r):i,s=a?`-n '${a}'`:"",o=[`complete -c ${e}`];if(s&&o.push(s),o.push(...of(r)),n.push(o.join(" ")),t){let t=[`complete -c ${e}`];s&&t.push(s),t.push(`-l no-${r.name}`),r.description&&t.push(`-d '${ou(`Disable ${r.name}`)}'`),n.push(t.join(" "))}}if(t.flags.length>0){let r='not string match -q -- "-*" (commandline -ct)',a=i?`${i}; and ${r}`:r;for(let r of t.flags){let t=`${a}; and ${od(r)}`,i="Boolean"===r.type._tag,s=[`complete -c ${e}`];if(s.push(`-n '${t}'`),s.push(`-f -a '--${r.name}'`),r.description&&s.push(`-d '${ou(r.description)}'`),n.push(s.join(" ")),i){let i=[`complete -c ${e}`];i.push(`-n '${t}'`),i.push(`-f -a '--no-${r.name}'`),r.description&&i.push(`-d '${ou(`Disable ${r.name}`)}'`),n.push(i.join(" "))}}}for(let r of t.arguments){let t=op(r.type);if(t){let i=[`complete -c ${e}`];a&&i.push(a),i.push(t),r.description&&i.push(`-d '${ou(r.description)}'`),n.push(i.join(" "))}}for(let i of t.subcommands)om(e,i,[...r,i.name],n)},og=e=>e.replace(/\\/g,"\\\\").replace(/'/g,"'\\''").replace(/:/g,"\\:"),oy=e=>e.replace(/[^a-zA-Z0-9_]/g,"_"),ob=e=>{let t=[],r=e.description?`[${og(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 a of(t.push(`'${i}--${e.name}${r}${n}'`),e.aliases)){let e=1===a.length?"-":"--";t.push(`'${i}${e}${a}${r}${n}'`)}if("Boolean"===e.type._tag){let r=e.description?`[${og(`Disable ${e.name}`)}]`:"";t.push(`'${i}--no-${e.name}${r}'`)}return t},ov=e=>{let t=e.description?og(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}'`},ow=(e,t,r)=>{let n=[...t,e.name],i=`_${n.map(oy).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?og(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 ob(t))r.push(` ${e}`);for(let t of e.arguments)r.push(` ${ov(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(oy).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(...ob(r));for(let r of e.arguments)t.push(ov(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))ow(t,n,r)},o_=e=>sU({name:e,primitiveType:sA,kind:"flag"}),ox=(e,t)=>sB("flag",e,t.map(e=>[e,e])),ok=(0,B.XY)(2,(e,t)=>sW(e,t)),oS=(0,B.XY)(2,(e,t)=>sq(e,t)),oE=(0,B.XY)(2,(e,t)=>sQ(e,t)),oI=e=>sG(e),o$=(0,B.XY)(2,(e,t)=>sX(e,t)),oO=(0,B.XY)(3,(e,t,r)=>sH(e,t,r)),oT="~effect/cli/Command/Config/Internal",oA=e=>{let t=[],r=[],n=[];return{[oT]:oT,flags:r,arguments:n,orderedParams:t,tree:function e(i){let a={};for(let s in i)a[s]=function i(a){if(Array.isArray(a))return{_tag:"Array",children:a.map(e=>i(e))};if(!el.i5(a,sR))return{_tag:"Nested",tree:e(a)};{let e=t.length;return t.push(a),"argument"===a.kind?n.push(a):r.push(a),{_tag:"Param",index:e}}}(i[s]);return a}(e)}},oC=oA({}),oN=(e,t)=>{switch(e._tag){case"Param":return{_tag:"Param",index:e.index+t};case"Array":return{_tag:"Array",children:e.children.map(e=>oN(e,t))};case"Nested":return{_tag:"Nested",tree:oM(e.tree,t)}}},oM=(e,t)=>{let r={};for(let n in e)r[n]=oN(e[n],t);return r},oP=(e,t)=>{let r=e.orderedParams.length;return{[oT]:oT,flags:[...e.flags,...t.flags],arguments:[...e.arguments,...t.arguments],orderedParams:[...e.orderedParams,...t.orderedParams],tree:{...e.tree,...oM(t.tree,r)}}},oR=(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 oR(r.tree,t)}}(e[n]);return r},oj="~effect/cli/Command",oD=e=>e,oL={...tT.b({label:"Command",evaluate(){return oD(this).service}})},oU=e=>{let t=e.config,r=e.contextConfig??oC,n=e.service??Z.kl(`${oj}/${e.name}`),i=e.annotations??Z.Ie(),a=e.globalFlags??[],s=e.subcommands??[],o=e.parse??oY(t),l=e.parseContext??oY(r);return Object.assign(Object.create(oL),{[oj]:oj,name:e.name,examples:e.examples??[],annotations:i,globalFlags:a,subcommands:s,hidden:e.hidden??!1,config:t,contextConfig:r,service:n,parse:o,parseContext:l,handle:(t,r)=>el.EA(e.handle)?e.handle(t,r):U.fJG(new sp({commandPath:r,errors:[]})),buildHelpDoc:r=>{let n=[],a=[];for(let e of t.arguments){let t=s8(e),r=s9(e);for(let e of t)n.push({name:e.name,type:e.typeName??sM(e.primitiveType),description:e.description,required:!r.isOptional,variadic:r.isVariadic})}let o=r.length>0?r.join(" "):e.name;for(let e of(s.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 s8(e))t.hidden||a.push(oF(t));let l=[];for(let e of s){let t=e.commands.filter(e=>!e.hidden);0!==t.length&&l.push({group:e.group,commands:V.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:a,annotations:i,...n.length>0&&{args:n},...l.length>0&&{subcommands:l},...c.length>0&&{examples:c}}},...el.EA(e.description)?{description:e.description}:{},...el.EA(e.shortDescription)?{shortDescription:e.shortDescription}:{},...el.EA(e.alias)?{alias:e.alias}:{}})},oF=e=>{let t=e.aliases.map(e=>1===e.length?`-${e}`:`--${e}`);return{name:e.name,aliases:t,type:e.typeName??sM(e.primitiveType),description:oB(e.description,sP(e.primitiveType)),required:"Boolean"!==e.primitiveType._tag}},oB=(e,t)=>{if(void 0===t||0===t.length)return e;let r=`(choices: ${t.join(", ")})`;return K.match(e,{onNone:()=>K.some(r),onSome:e=>K.some(`${e} ${r}`)})},oY=e=>U.D9k(function*(t){let r={flags:t.flags,arguments:t.arguments},n=yield*oW(r,e.orderedParams);return oR(e.tree,n)}),oW=U.D9k(function*(e,t){let r=[],n=e.arguments;for(let i of t){let[t,a]=yield*i.parse({flags:e.flags,arguments:n});r.push(a),n=t}return r}),oq=(e,t,r)=>{let n=oD(e),i=new Set;for(let e of(r?.contextConfig??n.contextConfig).flags)for(let t of s8(e))i.add(t.name);for(let r of t)for(let t of oD(r).config.flags)for(let n of s8(t))if(i.has(n.name))throw new so({option:n.name,parentCommand:e.name,childCommand:r.name})},oX=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:sP(e.primitiveType)??[]};case"Path":{let t=e.typeName;return{_tag:"Path",pathType:"file"===t?"file":"directory"===t?"directory":"either"}}default:return{_tag:"String"}}},oJ=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:sP(e.primitiveType)??[]};case"Path":{let t=e.typeName;return{_tag:"Path",pathType:"file"===t?"file":"directory"===t?"directory":"either"}}default:return{_tag:"String"}}},oz=e=>{let t=oD(e).config,r=[];for(let e of t.flags)for(let t of s8(e))"flag"===t.kind&&(t.hidden||r.push({name:t.name,aliases:t.aliases,description:K.getOrUndefined(t.description),type:oX(t)}));let n=[];for(let e of t.arguments){let t=s8(e),r=s9(e);for(let e of t)"argument"===e.kind&&n.push({name:e.name,description:K.getOrUndefined(e.description),required:!r.isOptional,variadic:r.isVariadic,type:oJ(e)})}let i=[];for(let t of e.subcommands)for(let e of t.commands)e.hidden||i.push(oz(e));return{name:e.name,description:e.shortDescription??e.description,flags:r,arguments:n,subcommands:i}},oG=e=>{let t=new Set,r=[];for(let n of e)t.has(n)||(t.add(n),r.push(n));return r},oV=(e,t)=>{let r=[e],n=e;for(let e=1;e<t.length;e++){let i,a=t[e];for(let e of n.subcommands)if(i=e.commands.find(e=>e.name===a))break;if(!i)break;r.push(i),n=i}return r},oK=(e,t,r)=>oG([...r,...oV(e,t).flatMap(e=>oD(e).globalFlags)]),oH=(e,t,r)=>U.JkU(function*(){let n=oV(e,t),i=oD(n.length>0?n[n.length-1]:e).buildHelpDoc(t),a=((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 oD(t).contextConfig.flags)for(let t of s8(e))!r.has(t.name)&&(t.hidden||(r.add(t.name),n.push(oF(t))));return n})(n,i.flags),s=oK(e,t,r),o=[];for(let e of s)for(let t of s8(e.flag))t.hidden||o.push({...oF(t),required:!1});return{...i,flags:[...a,...i.flags],globalFlags:o}}),oQ=e=>({_tag:"Action",flag:e.flag,run:e.run}),oZ=0,o0=oQ({flag:o_("help").pipe(ok("h"),oS("Show help information")),run:U.D9k(function*(e,{builtIns:t,command:r,commandPath:n}){let i=yield*s7,a=yield*oH(r,n,t);yield*si(i.formatHelpDoc(a))})}),o1=oQ({flag:o_("version").pipe(ok("v"),oS("Show version information")),run:U.D9k(function*(e,{command:t,version:r}){let n=yield*s7;yield*si(n.formatVersion(t.name,r))})}),o2=oQ({flag:o_("wizard").pipe(oS("Start wizard mode for a command")),run:()=>U.rIH}),o5=oQ({flag:ox("completions",["bash","zsh","fish","sh"]).pipe(oI,o$(e=>K.map(e,e=>"sh"===e?"bash":e)),oE("<bash|zsh|fish|sh>"),oS("Print shell completion script")),run:U.D9k(function*(e,{command:t}){if(K.isNone(e))return;let r=oz(t);yield*si(((e,t,r)=>{switch(t){case"bash":let n=[],i=oa(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(""),oc(r,[],n),n.push(`complete -F _${i} ${e.replace(/'/g,"'\\''")}`),n.push(`###-end-${e.replace(/'/g,"'\\''")}-completions-###`),n.join("\n");case"zsh":let a,s;return a=[],s=oy(e),a.push(`#compdef ${e}`),a.push(`###-begin-${e}-completions-###`),a.push("#"),a.push("# Static completion script for Zsh"),a.push("#"),a.push("# Installation:"),a.push(`# ${e} --completions zsh > ~/.zsh/completions/_${e}`),a.push("# then add ~/.zsh/completions to your fpath"),a.push("#"),a.push(""),ow(r,[],a),a.push("# Handle both direct invocation and autoload"),a.push('if [[ "${zsh_eval_context[-1]}" == "loadautofunc" ]]; then'),a.push(` _${s} "$@"`),a.push("else"),a.push(` compdef _${s} ${e}`),a.push("fi"),a.push(`###-end-${e}-completions-###`),a.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(""),om(e,r,[],o),o.push(""),o.push(`###-end-${e}-completions-###`),o.join("\n")}})(t.name,e.value,r))})}),o3=(C="log-level",e=>(oZ+=1,Object.assign(Z.kl(`effect/unstable/cli/GlobalFlag/${C}/${oZ}`),{_tag:"Setting",id:C,flag:e.flag})))({flag:sB("flag","log-level",[["all","All"],["trace","Trace"],["debug","Debug"],["info","Info"],["warn","Warn"],["warning","Warn"],["error","Error"],["fatal","Fatal"],["none","None"]]).pipe(oI,oS("Sets the minimum log level"),oE("<all|trace|debug|info|warn|warning|error|fatal|none>"))}),o8=[o0,o1,o2,o5,o3];class o6 extends Z.Or("effect/unstable/cli/CliConfig",{defaultValue:()=>o9}){}let o9={builtIns:o8},o4=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},o7=(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 a=1;a<=r;a++)for(let r=1;r<=n;r++){let n=+(e[a-1]!==t[r-1]);i[a][r]=Math.min(i[a-1][r]+1,i[a][r-1]+1,i[a-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)},le=e=>K.match(e.subcommand,{onNone:()=>[],onSome:e=>[e.name,...le(e.parsedInput)]}),lt=(e,t,r=[])=>U.JkU(function*(){let{tokens:n,trailingOperands:i}=e,a=[...r,t.name],s=oD(t),o=s.config.flags.flatMap(s8).filter(sL),l=ln(o),c=s.contextConfig.flags.flatMap(s8).filter(sL),u=ln(c),d=new Set(c.map(e=>e.name)),f=lb(n,{command:t,commandPath:a,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:K.none(),...f.errors.length>0&&{errors:f.errors}};let h={tokens:f.childTokens,trailingOperands:[]},p=yield*lt(h,f.sub,a),m=[...f.errors,...p.errors??[]];return{flags:f.flags,arguments:i,subcommand:K.some({name:f.sub.name,parsedInput:p}),...m.length>0&&{errors:m}}}),lr=e=>{let t=0;return{peek:()=>e[t],take:()=>e[t++],rest:()=>e.slice(t)}},ln=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}},li=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},la=e=>Object.fromEntries(e.map(e=>[e.name,[]])),ls=e=>"LongOption"===e._tag||"ShortOption"===e._tag,lo=e=>"LongOption"===e._tag?e.name:e.flag,ll=(e,t)=>{let r=lo(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&&s$(n.primitiveType))return{param:n,negated:!0}}if(n)return{param:n,negated:!1}},lc=(e,t,r)=>new su({option:t.name,value:r,expected:`omit the value and use ${e.raw} by itself to set --${t.name} to false`,kind:"flag"}),lu=e=>e?._tag==="Value"&&(sE(e.value)||sI(e.value))?e.value:void 0,ld=(e,t,r,n=!1)=>{let i=lf(e,t,r,n);switch(i._tag){case"Value":return{_tag:"Value",value:i.value};case"Error":return{_tag:"Error",error:i.error}}},lf=(e,t,r,n=!1)=>{let i;if(n){if(void 0!==t.value)return{_tag:"Error",error:lc(t,r,t.value),tokens:[]};let n=lu(e.peek());if(void 0!==n){let i=e.take();return{_tag:"Error",error:lc(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(s$(r.primitiveType)){let t=lu(e.peek()),r=void 0!==t?e.take():void 0;return{_tag:"Value",value:t??"true",tokens:void 0===r?[]:[r]}}let a=e.peek();if(a?._tag==="Value"){let t=e.take();return{_tag:"Value",value:a.value,tokens:void 0===t?[]:[t]}}return{_tag:"Error",error:(i=sP(r.primitiveType),new su({option:r.name,value:"",expected:void 0===i?r.typeName??sM(r.primitiveType):i.join(" | "),kind:"flag"})),tokens:[]}},lh=(e,t)=>{for(let r of t){let t=ll(e,r);if(void 0!==t)return t}},lp=(e,t,r,n)=>{e.push(r);let i=lf(t,r,n.param,n.negated);e.push(...i.tokens)},lm=(e,t,r,n,i)=>{let a=lr(t);lf(a,e,r.param,r.negated);for(let e=a.take();e;e=a.take()){if(ls(e)){let t=lh(e,i);void 0!==t&&lf(a,e,t.param,t.negated);continue}if("Value"===e._tag)return n.has(e.value)}return!1},lg=(e,t,r,n)=>{let{commandPath:i,flagRegistry:a}=r,s=ll(e,a);if(!s)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),s$(e.primitiveType)&&i.push(`no-${e.name}`),e.aliases))i.push(t);return new ss({option:n,suggestions:o7(lo(e),i).map(e=>1===e.length?`-${e}`:`--${e}`),command:r})})(e,a.params,i));let o=ld(t,e,s.param,s.negated);"Error"===o._tag?n.errors.push(o.error):n.flags.add(s.param.name,o.value)},ly=(e,t,r,n)=>{if("AwaitingFirstValue"===n.mode._tag){let i=((e,t,r,n)=>{let{command:i,commandPath:a,inheritedFlagRegistry:s,localFlagNames:o}=r,l=li(i.subcommands),c=l.get(e);if(c){let e=[...a,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 ss({option:`--${t}`,suggestions:[],command:e}))}let i=((e,t)=>{let r=la(t.params),n=[],i=[],a=lr(e);for(let e=a.take();e;e=a.take()){if(!ls(e)){n.push(e);continue}let s=ll(e,t);if(!s){n.push(e);continue}let o=ld(a,e,s.param,s.negated);if("Error"===o._tag){i.push(o.error);continue}void 0!==o.value&&r[s.param.name].push(o.value)}return{flagMap:r,remainder:n,errors:i}})(t.rest(),s);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(!(oD(i).config.arguments.length>0)&&l.size>0){let t=[];for(let[e,r]of l)r.hidden||t.push(e);let r=o7(e,t);n.errors.push(new sd({subcommand:e,parent:a,suggestions:r}))}return{_tag:"Argument"}})(e,t,r,n);if("Subcommand"===i._tag)return i.result;n.mode={_tag:"CollectingArguments"}}n.arguments.push(e)},lb=(e,t)=>{let r,n=lr(e),i={flags:(r=la(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(ls(e)){lg(e,n,t,i);continue}if("Value"===e._tag){let r=ly(e.value,n,t,i);if(r)return r}}return{_tag:"Leaf",flags:i.flags.snapshot(),arguments:i.arguments,errors:i.errors}};var lv=n(8036),lw=n(4450);let l_=new WeakMap,lx="~effect/data/Redacted",lk=(e,t)=>{let r=Object.create(lS);return t?.label&&(r.label=t.label),l_.set(r,e),r},lS={[lx]:{_A:e=>e},label:void 0,...eu.fU,toJSON(){return this.toString()},toString(){return`<redacted${(0,el.Kg)(this.label)?":"+this.label:""}>`},[lw.HR](){return lw.tW(l_.get(this))},[lv.HR](e){return(0,el.i5)(e,lx)&&lv.aI(l_.get(this),l_.get(e))}},lE=e=>{if(l_.has(e))return l_.get(e);throw Error("Unable to get redacted value"+(e.label?` with label: "${e.label}"`:""))};var lI=n(1044),l$=n(6364);el.Et,l$.wN,lI.wN;let lO=(0,B.XY)(2,(e,t)=>{let r=Math.pow(10,t);return Math.round(e*r)/r}),lT=(e,...t)=>{let r=t.flat();return`${r.join("")}${e}`},lA={arrowUp:"↑",arrowDown:"↓",arrowLeft:"←",arrowRight:"→",radioOn:"◉",radioOff:"◯",checkboxOn:"☒",checkboxOff:"☐",tick:"✔",cross:"✖",ellipsis:"…",pointerSmall:"›",line:"─",pointer:"❯"},lC={arrowUp:lA.arrowUp,arrowDown:lA.arrowDown,arrowLeft:lA.arrowLeft,arrowRight:lA.arrowRight,radioOn:"(*)",radioOff:"( )",checkboxOn:"[*]",checkboxOff:"[ ]",tick:"√",cross:"×",ellipsis:"...",pointerSmall:"»",line:"─",pointer:">"},lN=U.TjK(U.OH5(()=>"win32"===process.platform),e=>e?lC:lA),lM=e=>lT(e,"\x1b[1m"),lP=e=>lT(e,((...e)=>e)("\x1b[3m","\x1b[31m")),lR=e=>{let t={initial:!1,...e,label:{confirm:"yes",deny:"no",...e.label},placeholder:{defaultConfirm:"(Y/n)",defaultDeny:"(y/N)",...e.placeholder}};return lj({value:t.initial},{render:l1(t),process:e=>l3(e,t.initial),clear:lH(t)})},lj=(e,...t)=>{let[r,n]=1===t.length?[void 0,t[0]]:[t[0],t[1]],i=Object.create(lq);return i._tag="Loop",i.initialState=e,i.render=n.render,i.process=n.process,i.clear=n.clear,i.events=r,i},lD=(0,B.XY)(2,(e,t)=>{let r=Object.create(lq);return r._tag="OnSuccess",r.prompt=e,r.onSuccess=t,r}),lL=e=>{let t={default:0,min:-1/0,max:1/0,incrementBy:1,decrementBy:1,validate:e=>e<t.min?U.fJG(`${e} must be greater than or equal to ${t.min}`):e>t.max?U.fJG(`${e} must be less than or equal to ${t.max}`):U.PyW(e),...e},r=void 0===e.default?"":`${t.default}`;return lj({cursor:r.length,value:r,error:K.none()},{render:c_(t),process:cx(t),clear:cp(t)})},lU=(0,B.XY)(2,(e,t)=>lD(e,e=>lY(t(e)))),lF=U.D9k(function*(e){let t=yield*na,r=yield*t.readInput;return yield*lX(e,t,r)},U.xm_(()=>new ni({})),U.P1j),lB=e=>{let t={maxPerPage:10,...e};return lj((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:cT(t),process:cC(t),clear:cA(t)})},lY=e=>{let t=Object.create(lq);return t._tag="Succeed",t.value=e,t},lW=e=>{let t={initial:!1,active:"on",inactive:"off",...e};return lj(t.initial,{render:cz(t),process:cG,clear:()=>cF(t)})},lq={...tT.b({label:"Prompt",evaluate(){return lF(this)}}),"~effect/cli/Prompt":{_Output:e=>e}},lX=(e,t,r)=>U.DYE(()=>{switch(e._tag){case"Loop":return lJ(e,t,r);case"OnSuccess":return U.qIB(lX(e.prompt,t,r),n=>lX(e.onSuccess(n),t,r));case"Succeed":return U.PyW(e.value)}}),lJ=U.D9k(function*(e,t,r){let n=U.yw5(e.initialState)?yield*e.initialState:e.initialState,i=lz.NextFrame({state:n});for(;;){let a=yield*e.render(n,i);if(yield*U.QgK(t.display(a)),e.events){let t=eO(r).pipe(U.TjK(e=>({_tag:"Input",input:e}))),a=yield*U.KT6(t,eO(e.events).pipe(U.TjK(e=>({_tag:"Event",value:e}))));i=yield*e.process(a,n)}else{let t=yield*eO(r);i=yield*e.process(t,n)}switch(i._tag){case"Beep":continue;case"NextFrame":yield*U.QgK(t.display((yield*e.clear(n,i)))),n=i.state;continue;case"Submit":{yield*U.QgK(t.display((yield*e.clear(n,i))));let r=yield*e.render(n,i);return yield*U.QgK(t.display(r)),i.value}}}},(e,t,r)=>U.yeE(e,U.QgK(r.display("\x1b[?25h")))),lz=ee.Ij(),lG=(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(lK))n+=1+Math.floor(Math.max(r.length-1,0)/t);var i=n;let a="";for(let e=0;e<i;e++)a+="\x1b[2K"+(e<i-1?"\x1b[1A":"");return i>0&&(a+="\x1b[G"),a},lV=(e,t,r)=>{if(void 0!==r&&r.length>0){let n;return((e=1)=>`\x1b[${e}B`)((n=r.split(lK),0===t?n.length:(0,B.Fs)(V.Tj(n,e=>Math.ceil(e.length/t)),V.TS(0,(e,t)=>e+t))))+lG(`
52
- ${r}`,t)+lG(e,t)}return lG(e,t)},lK=/\r?\n/,lH=e=>U.D9k(function*(t,r){let n=yield*na,i=yield*n.columns,a=yield*lN;return lG(lQ(t.value?e.placeholder.defaultConfirm:e.placeholder.defaultDeny,"?",a.pointerSmall,e,{plain:!0}),i)+"\x1b[2K\x1b[G"}),lQ=(e,t,r,n,i)=>cf(e,n.message,t,r,i),lZ=U.D9k(function*(e,t){let r=yield*lN,n=lT("?","\x1b[96m"),i=lT(r.pointerSmall,"\x1b[90m");return"\x1b[?25l"+lQ(lT(e.value?t.placeholder.defaultConfirm:t.placeholder.defaultDeny,"\x1b[90m"),n,i,t)}),l0=U.D9k(function*(e,t){let r=yield*lN,n=lT(r.tick,"\x1b[32m"),i=lT(r.ellipsis,"\x1b[90m");return lQ(e?t.label.confirm:t.label.deny,n,i,t)+"\n"}),l1=e=>(t,r)=>lz.$match(r,{Beep:()=>U.PyW("\x07"),NextFrame:({state:t})=>lZ(t,e),Submit:({value:t})=>l0(t,e)}),l2=/^y|t$/,l5=/^n|f$/,l3=(e,t)=>{let r=K.getOrElse(e.input,()=>"");return"enter"===e.key.name||"return"===e.key.name?U.PyW(lz.Submit({value:t})):l2.test(r.toLowerCase())?U.PyW(lz.Submit({value:!0})):l5.test(r.toLowerCase())?U.PyW(lz.Submit({value:!1})):U.PyW(lz.Beep())},l8=(e,t=!1)=>V.TS(e.dateParts,"",(r,n,i)=>{let a=n.toString();return i!==e.cursor||t?r+a:r+lT(a,((...e)=>e)("\x1b[4m","\x1b[96m"))}),l6=(e,t,r,n,i)=>cf(r,n.message,e,t,i),l9=U.D9k(function*(e,t){let r=yield*lN;return"\x1b[?25l"+l6(lT("?","\x1b[96m"),lT(r.pointerSmall,"\x1b[90m"),l8(e),t)+((e,t)=>{if(K.isSome(e.error)){let r=e.error.value.split(lK);if(V.ET(r))return"\x1b[s\n"+(lT(t,"\x1b[31m")+" ")+V.Tj(r,e=>lP(e)).join("\n")+"\x1b[u"}return""})(e,r.pointerSmall)}),l4=U.D9k(function*(e,t){let r=yield*lN;return l6(lT(r.tick,"\x1b[32m"),lT(r.ellipsis,"\x1b[90m"),l8(e,!0),t)+"\n"}),l7={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"]},ce=/\\(.)|"((?:\\["\\]|[^"])+)"|(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,ct={1:({token:e,...t})=>new cn({token:e.replace(/\\(.)/g,"$1"),...t}),2:e=>new cl(e),3:e=>new cc(e),4:e=>new cu(e),5:e=>new cd(e),6:e=>new co(e),7:e=>new cs(e),8:e=>new ca(e),9:e=>new ci(e)};class cr{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=K.getOrElse(V.g9(this.parts,e=>e===this),()=>0);return V.i8(this.parts.slice(e+1),e=>!e.isToken())}previousPart(){let e=V.g9(this.parts,e=>e===this);return K.isSome(e)?V.Uk(this.parts.slice(0,e.value),e=>!e.isToken()):K.none()}toString(){return String(this.date)}}class cn extends cr{increment(){}decrement(){}setValue(e){this.token=this.token+e}isToken(){return!0}toString(){return this.token}}class ci extends cr{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 ca extends cr{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 cs extends cr{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 co extends cr{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 cl extends cr{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 cc extends cr{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 cu extends cr{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 cd extends cr{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 cf=(e,t,r,n,i)=>{let a=r+" ",s=i?.plain===!0?e=>e:lM;return V.YW(t.split(lK),{onEmpty:()=>a+" "+n+" "+e,onNonEmpty:t=>a+V.Tj(t,e=>s(e)).join("\n")+" "+n+" "+e})},ch=(e,t,r)=>!e.disabled&&e.description&&t?r?.plain===!0?"- "+e.description:lT("- "+e.description,"\x1b[90m"):"",cp=e=>U.D9k(function*(t,r){let n=yield*na,i=yield*n.columns,a=yield*lN,s=cm(t,a.pointerSmall,{plain:!0});return lV(cg(t,"?",a.pointerSmall,e,{plain:!0}),i,s)+"\x1b[2K\x1b[G"}),cm=(e,t,r)=>K.isSome(e.error)?V.YW(e.error.value.split(lK),{onEmpty:()=>"",onNonEmpty:e=>r?.plain===!0?`${t} ${e.join("\n")}`:"\x1b[s\n"+(lT(t,"\x1b[31m")+" ")+V.Tj(e,e=>lP(e)).join("\n")+"\x1b[u"}):"",cg=(e,t,r,n,i,a=!1)=>{let s;return cf((s=""===e.value?"":`${e.value}`,a||i?.plain===!0?s:lT(s,K.isSome(e.error)?"\x1b[31m":((...e)=>e)("\x1b[4m","\x1b[96m"))),n.message,t,r,i)},cy=U.D9k(function*(e,t){let r=yield*lN,n=lT("?","\x1b[96m"),i=lT(r.pointerSmall,"\x1b[90m"),a=cm(e,r.pointerSmall);return cg(e,n,i,t)+a}),cb=U.D9k(function*(e,t){let r=yield*lN;return cg(e,lT(r.tick,"\x1b[32m"),lT(r.ellipsis,"\x1b[90m"),t,void 0,!0)+"\n"}),cv=e=>{if(e.value.length<=0)return U.PyW(lz.Beep());let t=e.value.slice(0,e.value.length-1);return U.PyW(lz.NextFrame({state:{...e,value:t,error:K.none()}}))},cw=e=>U.PyW(lz.NextFrame({state:{...e,cursor:0,value:"",error:K.none()}})),c_=e=>(t,r)=>lz.$match(r,{Beep:()=>U.PyW("\x07"),NextFrame:({state:t})=>cy(t,e),Submit:()=>cb(t,e)}),cx=e=>(t,r)=>{if(t.key.ctrl&&"u"===t.key.name)return cw(r);switch(t.key.name){case"backspace":return cv(r);case"k":case"up":return U.PyW(lz.NextFrame({state:{...r,value:""===r.value||"-"===r.value?`${e.incrementBy}`:`${Number.parseInt(r.value)+e.incrementBy}`,error:K.none()}}));case"j":case"down":return U.PyW(lz.NextFrame({state:{...r,value:""===r.value||"-"===r.value?`-${e.decrementBy}`:`${Number.parseInt(r.value)-e.decrementBy}`,error:K.none()}}));case"enter":case"return":{let t=Number.parseInt(r.value);if(Number.isNaN(t))return U.PyW(lz.NextFrame({state:{...r,error:K.some("Must provide an integer value")}}));return U.YWq(e.validate(t),{onFailure:e=>lz.NextFrame({state:{...r,error:K.some(e)}}),onSuccess:e=>lz.Submit({value:e})})}default:var n=K.getOrElse(t.input,()=>"");if(0===r.value.length&&"-"===n)return U.PyW(lz.NextFrame({state:{...r,value:"-",error:K.none()}}));let i=Number.parseInt(r.value+n);return Number.isNaN(i)?U.PyW(lz.Beep()):U.PyW(lz.NextFrame({state:{...r,value:`${i}`,error:K.none()}}))}},ck=(e,t,r,n)=>cf("",r.message,e,t,n),cS=(e,t,r,n,i,a)=>{let s=" ";if(n===r.startIndex&&r.startIndex>0?s=i.arrowUp:n===r.endIndex-1&&r.endIndex<t.length&&(s=i.arrowDown),a?.plain===!0)return e===n?i.pointer+s:s+" ";if(t[n].disabled){let t=((...e)=>e)("\x1b[1m","\x1b[90m");return e===n?lT(i.pointer,t)+s:s+" "}return e===n?lT(i.pointer,"\x1b[96m")+s:s+" "},cE=(e,t,r)=>{if(r?.plain===!0)return e.title;let n=e.title;return t?e.disabled?lT(n,((...e)=>e)("\x1b[4m","\x1b[90m")):lT(n,((...e)=>e)("\x1b[4m","\x1b[96m")):e.disabled?lT(n,((...e)=>e)("\x1b[9m","\x1b[90m")):n},cI=(e,t,r,n)=>{let i=t.choices,a=cV(e,i.length,t.maxPerPage),s=[];for(let t=a.startIndex;t<a.endIndex;t++){let o=i[t],l=e===t,c=cS(e,i,a,t,r,n),u=cE(o,l,n),d=ch(o,l,n);s.push(c+u+" "+d)}return s.join("\n")},c$=U.D9k(function*(e,t){let r=yield*lN,n=cI(e,t,r);return"\x1b[?25l"+ck(lT("?","\x1b[96m"),lT(r.pointerSmall,"\x1b[90m"),t)+"\n"+n}),cO=U.D9k(function*(e,t){let r=yield*lN,n=t.choices[e].title;return ck(lT(r.tick,"\x1b[32m"),lT(r.ellipsis,"\x1b[90m"),t)+" "+lT(n,"\x1b[37m")+"\n"}),cT=e=>(t,r)=>lz.$match(r,{Beep:()=>U.PyW("\x07"),NextFrame:({state:t})=>c$(t,e),Submit:()=>cO(t,e)}),cA=e=>U.D9k(function*(t,r){let n=yield*na,i=yield*n.columns,a=yield*lN,s=ck("?",a.pointerSmall,e,{plain:!0}),o=cI(t,e,a,{plain:!0});return lG(`${s}
53
- ${o}`,i)+"\x1b[2K\x1b[G"}),cC=e=>(t,r)=>{var n;switch(t.key.name){case"k":case"up":return n=e.choices,0===r?U.PyW(lz.NextFrame({state:n.length-1})):U.PyW(lz.NextFrame({state:r-1}));case"j":case"down":return r===e.choices.length-1?U.PyW(lz.NextFrame({state:0})):U.PyW(lz.NextFrame({state:r+1}));case"tab":let i;return i=e.choices,U.PyW(lz.NextFrame({state:(r+1)%i.length}));case"enter":case"return":{let t=e.choices[r];if(t.disabled)return U.PyW(lz.Beep());return U.PyW(lz.Submit({value:t.value}))}default:return U.PyW(lz.Beep())}},cN=U.D9k(function*(e,t){let r=yield*na,n=yield*r.columns,i=yield*lN,a=cM(e,i.pointerSmall,{plain:!0});return lV(cP(e,"?",i.pointerSmall,t,{plain:!0}),n,a)+"\x1b[2K\x1b[G"}),cM=(e,t,r)=>K.isSome(e.error)?V.YW(e.error.value.split(lK),{onEmpty:()=>"",onNonEmpty:e=>r?.plain===!0?`${t} ${e.join("\n")}`:"\x1b[s\n"+(lT(t,"\x1b[31m")+" ")+V.Tj(e,e=>lP(e)).join("\n")+"\x1b[u"}):"",cP=(e,t,r,n,i,a=!1)=>cf(((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 a=K.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 lT("*".repeat(i.length),a);case"text":return lT(i,a)}})(e,n,a,i),n.message,t,r,i),cR=U.D9k(function*(e,t){let r=yield*lN;return cP(e,lT("?","\x1b[96m"),lT(r.pointerSmall,"\x1b[90m"),t)+cM(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)}),cj=U.D9k(function*(e,t){let r=yield*lN;return cP(e,lT(r.tick,"\x1b[32m"),lT(r.ellipsis,"\x1b[90m"),t,void 0,!0)+"\n"}),cD=e=>U.PyW(lz.NextFrame({state:{...e,cursor:0,error:K.none()}})),cL=e=>U.PyW(lz.NextFrame({state:{...e,cursor:e.value.length,error:K.none()}})),cU=(e,t)=>{let r={default:"",type:t,validate:U.PyW,...e};return lj({cursor:r.default.length,value:r.default,error:K.none()},{render:(e,t)=>lz.$match(t,{Beep:()=>U.PyW("\x07"),NextFrame:({state:e})=>cR(e,r),Submit:()=>cj(e,r)}),process:(e,t)=>{if(e.key.ctrl)switch(e.key.name){case"u":return U.PyW(lz.NextFrame({state:{...t,cursor:0,value:"",error:K.none()}}));case"a":return cD(t);case"e":return cL(t);default:return U.PyW(lz.Beep())}switch(e.key.name){case"backspace":var n;if(t.cursor<=0)return U.PyW(lz.Beep());let i=t.value.slice(0,t.cursor-1),a=t.value.slice(t.cursor),s=t.cursor-1,o=`${i}${a}`;return U.PyW(lz.NextFrame({state:{...t,cursor:s,value:o,error:K.none()}}));case"left":if(t.cursor<=0)return U.PyW(lz.Beep());let l=t.cursor-1;return U.PyW(lz.NextFrame({state:{...t,cursor:l,error:K.none()}}));case"right":if(t.cursor>=t.value.length)return U.PyW(lz.Beep());let c=Math.min(t.cursor+1,t.value.length);return U.PyW(lz.NextFrame({state:{...t,cursor:c,error:K.none()}}));case"home":return cD(t);case"end":return cL(t);case"enter":case"return":{let e=t.value;return U.YWq(r.validate(e),{onFailure:r=>lz.NextFrame({state:{...t,value:e,error:K.some(r)}}),onSuccess:e=>lz.Submit({value:e})})}case"tab":if(t.value===r.default)return U.PyW(lz.Beep());let u=0===t.value.length?r.default:t.value;return U.PyW(lz.NextFrame({state:{...t,value:u,cursor:u.length,error:K.none()}}));default:let d,f,h,p;return n=K.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,U.PyW(lz.NextFrame({state:{...t,cursor:p,value:h,error:K.none()}}))}},clear:(e,t)=>cN(e,r)})},cF=U.D9k(function*(e){let t=yield*na,r=yield*t.columns,n=yield*lN;return lG(cf(`${e.active} / ${e.inactive}`,e.message,"?",n.pointerSmall,{plain:!0}),r)+"\x1b[2K\x1b[G"}),cB=(e,t,r=!1)=>{let n=lT("/","\x1b[90m"),i=((...e)=>e)("\x1b[4m",r?"\x1b[37m":"\x1b[96m"),a=e?t.inactive:lT(t.inactive,i);return(e?lT(t.active,i):t.active)+" "+n+" "+a},cY=(e,t,r,n)=>{let i=n.message.split(lK),a=t+" ";return V.ET(i)?a+V.Tj(i,e=>lM(e)).join("\n")+" "+r+" "+e:a+" "+r+" "+e},cW=U.D9k(function*(e,t){let r=yield*lN,n=lT("?","\x1b[96m"),i=lT(r.pointerSmall,"\x1b[90m");return"\x1b[?25l"+cY(cB(e,t),n,i,t)}),cq=U.D9k(function*(e,t){let r=yield*lN,n=lT(r.tick,"\x1b[32m"),i=lT(r.ellipsis,"\x1b[90m");return cY(cB(e,t,!0),n,i,t)+"\n"}),cX=U.PyW(lz.NextFrame({state:!0})),cJ=U.PyW(lz.NextFrame({state:!1})),cz=e=>(t,r)=>{switch(r._tag){case"Beep":return U.PyW("\x07");case"NextFrame":return cW(t,e);case"Submit":return cq(t,e)}},cG=(e,t)=>{switch(e.key.name){case"0":case"j":case"delete":case"right":case"down":return cJ;case"1":case"k":case"left":case"up":return cX;case" ":case"tab":return t?cJ:cX;case"enter":case"return":return U.PyW(lz.Submit({value:t}));default:return U.PyW(lz.Beep())}},cV=(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 a=Math.min(i+n,t);return{startIndex:i,endIndex:a}},cK=U.D9k(function*(e,t){let r=t?.commandPath??[e.name],n=cH(e,r),i=[...t?.prefix??r];return yield*c8(i),yield*cQ(n,i,n===e?"ROOT":n.name),i}),cH=(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},cQ=U.D9k(function*(e,t,r){let n=oD(e),i=e.subcommands.flatMap(e=>e.commands.filter(e=>!e.hidden)),a=0===i.length?n.config:n.contextConfig;if(a.flags.length>0){for(let e of(yield*si(c6(r,"FLAGS")),a.flags))t.push(...yield*c0(e));(a.arguments.length>0||i.length>0)&&(yield*c8(t))}if(a.arguments.length>0){for(let e of(yield*si(c6(r,"ARGUMENTS")),a.arguments))t.push(...yield*c0(e));i.length>0&&(yield*c8(t))}if(0===i.length)return;let s=yield*lF(lB({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*si(),t.push(s.name),cZ(s)&&(yield*c8(t)),yield*cQ(s,t,s.name)}),cZ=e=>e.subcommands.some(e=>e.commands.some(e=>!e.hidden))||oD(e).config.orderedParams.length>0,c0=U.D9k(function*(e){let t=s6(e),r=s9(e);if(r.isOptional&&!(yield*lF(lR({message:`Set ${c5(t)}?`,initial:!1}))))return yield*si(),[];let n=r.isVariadic?yield*lF(lL({message:`${c5(t)} count`,default:K.getOrElse(r.variadicMin,()=>0),min:K.getOrElse(r.variadicMin,()=>0),...K.isSome(r.variadicMax)?{max:r.variadicMax.value}:{}})):1,i=[];for(let e=0;e<n;e++)i.push((yield*c1(t)));let a="flag"===t.kind?{flags:{[t.name]:i},arguments:[]}:{flags:{},arguments:i};return(yield*e.parse(a),yield*si(),t.kind===sj)?i:i.flatMap(e=>[`--${t.name}`,e])}),c1=e=>{var t,r;let n=c2(e);switch(e.primitiveType._tag){case"Boolean":return U.TjK(lF(lR({message:n,label:{confirm:"true",deny:"false"},placeholder:{defaultConfirm:"(T/f)",defaultDeny:"(t/F)"}})),String);case"Choice":return lF(lB({message:n,choices:(sP(e.primitiveType)??[]).map(e=>({title:e,value:e}))}));case"Date":let i,a,s,o,l,c;return U.TjK(lF((t={message:n},s=(a=((e,t,r)=>{let n=[],i=null;for(;i=ce.exec(e);){let e=i.shift(),a=i.findIndex(e=>void 0!==e);if(a in ct){let s=i[a]||e;n.push(ct[a]({token:s,date:t,parts:n,locales:r}))}else n.push(new cn({token:i[a]||e,date:t,parts:n,locales:r}))}let a=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},V.Ie());return n.splice(0,n.length,...a),n})((i={initial:new Date,dateMask:"YYYY-MM-DD HH:mm:ss",validate:U.PyW,...t,locales:{...l7,...t.locales}}).dateMask,i.initial,i.locales)).findIndex(e=>!e.isToken()),lj({dateParts:a,typed:"",cursor:s,value:i.initial,error:K.none()},{render:(o=i,(e,t)=>lz.$match(t,{Beep:()=>U.PyW("\x07"),NextFrame:({state:e})=>l9(e,o),Submit:()=>l4(e,o)})),process:(l=i,(e,t)=>{switch(e.key.name){case"left":let r;return U.PyW((r=t.dateParts[t.cursor].previousPart(),K.isSome(r)?lz.NextFrame({state:{...t,typed:"",cursor:t.dateParts.indexOf(r.value)}}):lz.Beep()));case"right":let n;return U.PyW((n=t.dateParts[t.cursor].nextPart(),K.isSome(n)?lz.NextFrame({state:{...t,typed:"",cursor:t.dateParts.indexOf(n.value)}}):lz.Beep()));case"k":case"up":return U.PyW((t.dateParts[t.cursor].increment(),lz.NextFrame({state:{...t,typed:""}})));case"j":case"down":return U.PyW((t.dateParts[t.cursor].decrement(),lz.NextFrame({state:{...t,typed:""}})));case"tab":let i,a;return U.PyW((i=t.dateParts[t.cursor].nextPart(),a=K.match(i,{onNone:()=>t.dateParts.findIndex(e=>!e.isToken()),onSome:e=>t.dateParts.indexOf(e)}),lz.NextFrame({state:{...t,cursor:a}})));case"enter":case"return":return U.YWq(l.validate(t.value),{onFailure:e=>lz.NextFrame({state:{...t,error:K.some(e)}}),onSuccess:e=>lz.Submit({value:e})});default:return U.PyW(((e,t)=>{if(/\d/.test(e)){let r=t.typed+e;return t.dateParts[t.cursor].setValue(r),lz.NextFrame({state:{...t,typed:r}})}return lz.Beep()})(K.getOrElse(e.input,()=>""),t))}}),clear:(c=i,U.D9k(function*(e,t){let r=yield*na,n=yield*r.columns,i=yield*lN,a=V.TS(e.dateParts,"",(e,t)=>e+t.toString());return lV(l6("?",i.pointerSmall,a,c,{plain:!0}),n,K.isSome(e.error)?V.YW(e.error.value.split(lK),{onEmpty:()=>"",onNonEmpty:e=>`${i.pointerSmall} ${e.join("\n")}`}):"")+"\x1b[2K\x1b[G"}))}))),e=>e.toISOString());case"Float":let u,d,f,h;return U.TjK(lF((u={default:0,min:-1/0,max:1/0,incrementBy:1,decrementBy:1,precision:2,validate:e=>e<u.min?U.fJG(`${e} must be greater than or equal to ${u.min}`):e>u.max?U.fJG(`${e} must be less than or equal to ${u.max}`):U.PyW(e),...r={message:n}},lj({cursor:(d=void 0===r.default?"":`${u.default}`).length,value:d,error:K.none()},{render:(f=u,(e,t)=>lz.$match(t,{Beep:()=>U.PyW("\x07"),NextFrame:({state:e})=>cy(e,f),Submit:()=>cb(e,f)})),process:(h=u,(e,t)=>{if(e.key.ctrl&&"u"===e.key.name)return cw(t);switch(e.key.name){case"backspace":return cv(t);case"k":case"up":return U.PyW(lz.NextFrame({state:{...t,value:""===t.value||"-"===t.value?`${h.incrementBy}`:`${Number.parseFloat(t.value)+h.incrementBy}`,error:K.none()}}));case"j":case"down":return U.PyW(lz.NextFrame({state:{...t,value:""===t.value||"-"===t.value?`-${h.decrementBy}`:`${Number.parseFloat(t.value)-h.decrementBy}`,error:K.none()}}));case"enter":case"return":{let e=Number.parseFloat(t.value);if(Number.isNaN(e))return U.PyW(lz.NextFrame({state:{...t,error:K.some("Must provide a floating point value")}}));return U.qIB(U.OH5(()=>lO(e,h.precision)),e=>U.YWq(h.validate(e),{onFailure:e=>lz.NextFrame({state:{...t,error:K.some(e)}}),onSuccess:e=>lz.Submit({value:e})}))}default:var r=K.getOrElse(e.input,()=>"");if("."===r&&t.value.includes("."))return U.PyW(lz.Beep());if(0===t.value.length&&"-"===r)return U.PyW(lz.NextFrame({state:{...t,value:"-",error:K.none()}}));let n=Number.parseFloat(t.value+r);return Number.isNaN(n)?U.PyW(lz.Beep()):U.PyW(lz.NextFrame({state:{...t,value:"."===r?`${n}.`:`${n}`,error:K.none()}}))}}),clear:cp(u)}))),String);case"Integer":return U.TjK(lF(lL({message:n})),String);case"Redacted":return U.TjK(lF(cU({message:n},"password").pipe(lU(lk))),lE);default:return lF(cU({message:n},"text"))}},c2=e=>c5(e),c5=e=>{let t=K.getOrUndefined(e.description)?.trim(),r="flag"===e.kind&&void 0!==t&&t.length<=32?t:c3(e.name);return"flag"===e.kind?`${r} (${"flag"===e.kind?`--${e.name}`:e.name})`:r},c3=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(" ")},c8=e=>si(ue("Current command",e,"\x1b[35m")),c6=(e,t)=>`${lT(e.toUpperCase(),"\x1b[1m","\x1b[96m")} ${lT("·","\x1b[90m")} ${lT(t,"\x1b[1m","\x1b[37m")}`,c9=(e,t,r)=>[`${lT(e,"\x1b[1m","\x1b[96m")} ${lT(`v${t}`,"\x1b[37m")} ${lT("· Command wizard","\x1b[1m","\x1b[37m")}`,...void 0===r||0===r.length?[]:[r],lT("Build a command interactively. Press Ctrl+C to cancel.","\x1b[90m"),""].join("\n"),c4=e=>ue("Command ready",e,"\x1b[96m","\x1b[32m"),c7=()=>`
54
- ${lT("Wizard cancelled.","\x1b[31m")}`,ue=(e,t,r,n="\x1b[37m")=>{let i=ut(t);return[lT(e,"\x1b[1m",n),...i.map(e=>lT(e,r)),""].join("\n")},ut=e=>{let t=" $ ",r=" ",n=e.map(ur),i=[],a=t;for(let e of n){let n=a===t||a===r?"":" ";a.length+n.length+e.length>88&&a!==t?(i.push(`${a} \\`),a=`${r}${e}`):a+=`${n}${e}`}return a!==t&&i.push(a),i},ur=e=>/^[A-Za-z0-9_./:@%+=,-]+$/.test(e)?e:`'${e.replaceAll("'","'\"'\"'")}'`,un=e=>el.i5(e,oj),ui=(e,t,r)=>oU({name:e,config:oA(t??{}),...el.EA(r)?{handle:r}:{}}),ua=(0,B.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(un(t)){n(void 0,t);continue}for(let e of t.commands)n(t.group,e)}let i=[],a=r.get(void 0);for(let[e,t]of(a&&a.length>0&&i.push({group:void 0,commands:a}),r))void 0!==e&&i.push({group:e,commands:t});return{flat:t,groups:i}})(t);oq(e,r.flat);let n=oD(e),i=new Map(r.flat.map(e=>[e.name,oD(e)])),a=Symbol("effect/cli/SubcommandState"),s=U.D9k(function*(e){if(K.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),s=yield*t.parse(e.subcommand.value.parsedInput);return Object.assign({},r,{[a]:{name:t.name,result:s}})}),o=U.D9k(function*(e,t){let r=e[a];if(r){let a=i.get(r.name);return a?yield*a.handle(r.result,[...t,a.name]).pipe(U.PfK(n.service,e)):yield*new sp({commandPath:t,errors:[]})}return yield*n.handle(e,t)});return oU({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:s,parseContext:n.parseContext,handle:o})}),us=(0,B.XY)(2,(e,t)=>{let r=oD(e),n=oA(t),i=oP(r.config,n),a=oP(r.contextConfig,n);r.subcommands.length>0&&oq(e,r.subcommands.flatMap(e=>e.commands),{contextConfig:a});let s=oY(n),o=U.D9k(function*(e){return Object.assign({},(yield*r.parse(e)),(yield*s(e)))}),l=U.D9k(function*(e){return Object.assign({},(yield*r.parseContext(e)),(yield*s(e)))});return oU({name:r.name,config:i,contextConfig:a,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)})}),uo=(0,B.XY)(2,(e,t)=>oU({...oD(e),description:t})),ul=(0,B.XY)(2,(e,t)=>oU({...oD(e),shortDescription:t})),uc=(0,B.XY)(2,(e,t)=>oU({...oD(e),examples:t})),uu=(e,t)=>{let r=oD(e);return U.D9k(function*(n){let i,a,s,o,l,c,{builtIns:u}=yield*o6,{tokens:d,trailingOperands:f}=-1===(i=n.indexOf("--"))?{tokens:o4(n),trailingOperands:[]}:{tokens:o4(n.slice(0,i)),trailingOperands:n.slice(i+1)},h=oG([...u,...(a=[],(s=e=>{for(let t of oD(e).globalFlags)a.push(t);for(let t of e.subcommands)for(let e of t.commands)s(e)})(e),oG(a))]),p=ln(h.flatMap(e=>s8(e.flag)).filter(sL)),{flagMap:m,remainder:g,errors:y}=(o=la(p.params),l=[],c=(e,t,r)=>{let n=ln(oD(t).config.flags.flatMap(s8).filter(sL)),i=ln(oD(t).contextConfig.flags.flatMap(s8).filter(sL)),a=li(t.subcommands),s=lr(e),u=[],d=!0;for(let e=s.take();e;e=s.take()){if(ls(e)){let t=lh(e,r);if(void 0!==t){lp(u,s,e,t);continue}let c=ll(e,i);if(void 0!==c){lp(u,s,e,c);continue}let f=ll(e,n),h=ll(e,p);if(void 0!==f&&(void 0===h||!d||!lm(e,s.rest(),f,a,[n,i,p]))){lp(u,s,e,f);continue}if(void 0!==h){let t=lf(s,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=a.get(e.value);if(void 0!==t)return u.push(e),u.push(...c(s.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*lt({tokens:g,trailingOperands:f},e),w=[e.name,...le(v)],_={builtIns:u,command:e,commandPath:w,version:t.version},x=oK(e,w,u),k=((e,t,r,n)=>{let i=new Set(t),a=[],s=new Set;for(let t of e)if(!i.has(t))for(let e of s8(t.flag)){let t=r[e.name];if(!t||0===t.length)continue;let i=`--${e.name}`;s.has(i)||(s.add(i),a.push(new ss({option:i,suggestions:[],command:n})))}return a})(h,x,m,w);if(k.length>0||y.length>0){let e=v.errors??[];return yield*new sp({commandPath:w,errors:[...y,...k,...e]})}for(let r of x){if("Action"!==r._tag||!s8(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===o2)return yield*U.JkU(function*(){yield*si(c9(e.name,t.version,e.description));let r=[e.name,...n.filter(e=>"--wizard"!==e&&!e.startsWith("--wizard="))],i=yield*cK(e,{commandPath:w,prefix:r});yield*si(c4(i)),(yield*lF(lW({message:"Run this command?",initial:!0,active:"yes",inactive:"no"})))&&(yield*si(),yield*uu(e,t)(i.slice(1)))}).pipe(U.KuX("QuitError",()=>si(c7())));yield*r.run(i,_);return}if(v.errors&&v.errors.length>0)return yield*new sp({commandPath:w,errors:v.errors});let S=yield*U.Ket(r.parse(v));if("Failure"===S._tag)return yield*new sp({commandPath:w,errors:[S.failure]});let E=r.handle(S.success,[e.name]),I=x.includes(o3)?(yield*o3.flag.parse(b))[1]:K.none();for(let e of(E=U.PfK(E,o3,I),x)){if("Setting"!==e._tag||e===o3)continue;let[,t]=yield*e.flag.parse(b);E=U.PfK(E,e,t)}let $=K.match(I,{onNone:()=>Z.Ie(),onSome:e=>Z.L8(s4.zQ,e)});yield*U.PpN(E,$)},U.osR(e=>el.i5(e,sa)&&"ShowHelp"===e._tag?H.Py(e):H.fJ(e),t=>U.hgn(U.JkU(function*(){let{builtIns:r}=yield*o6,n=yield*s7,i=yield*oH(e,t.commandPath,r);yield*si(n.formatHelpDoc(i)),t.errors.length>0&&(yield*sn(n.formatErrors(t.errors)))}),U.fJG(t))),U.osR(e=>el.i5(e,nn)?H.Py(e):H.fJ(e),e=>U.GaK))},ud=/(?:https:\/\/(?:www\.)?excalidraw\.com\/)?#json=[A-Za-z0-9_-]+,[A-Za-z0-9_-]{22,}/gu;function uf(e){return e.replace(ud,"[redacted-share-link]")}let uh=(e=0)=>t=>`\u{1B}[${t+e}m`,up=(e=0)=>t=>`\u{1B}[${38+e};5;${t}m`,um=(e=0)=>(t,r,n)=>`\u{1B}[${38+e};2;${t};${r};${n}m`,ug=e=>`\u{1B}[58;5;${e<90?e-30:e-90+8}m`,uy={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],underlineDouble:["4:2",24],underlineCurly:["4:3",24],underlineDotted:["4:4",24],underlineDashed:["4:5",24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]},underlineColor:{underlineBlack:["58;5;0",59],underlineRed:["58;5;1",59],underlineGreen:["58;5;2",59],underlineYellow:["58;5;3",59],underlineBlue:["58;5;4",59],underlineMagenta:["58;5;5",59],underlineCyan:["58;5;6",59],underlineWhite:["58;5;7",59],underlineBlackBright:["58;5;8",59],underlineGray:["58;5;8",59],underlineGrey:["58;5;8",59],underlineRedBright:["58;5;9",59],underlineGreenBright:["58;5;10",59],underlineYellowBright:["58;5;11",59],underlineBlueBright:["58;5;12",59],underlineMagentaBright:["58;5;13",59],underlineCyanBright:["58;5;14",59],underlineWhiteBright:["58;5;15",59]}};Object.keys(uy.modifier);let ub=Object.keys(uy.color),uv=Object.keys(uy.bgColor);Object.keys(uy.underlineColor),[...ub,...uv];let uw=function(){let e=new Map;for(let[t,r]of Object.entries(uy)){for(let[t,n]of Object.entries(r))uy[t]={open:`\u{1B}[${n[0]}m`,close:`\u{1B}[${n[1]}m`},r[t]=uy[t],e.set(Number.parseInt(n[0],10),n[1]);Object.defineProperty(uy,t,{value:r,enumerable:!1})}return Object.defineProperty(uy,"codes",{value:e,enumerable:!1}),uy.color.close="\x1b[39m",uy.bgColor.close="\x1b[49m",uy.underlineColor.close="\x1b[59m",uy.color.ansi=uh(),uy.color.ansi256=up(),uy.color.ansi16m=um(),uy.bgColor.ansi=uh(10),uy.bgColor.ansi256=up(10),uy.bgColor.ansi16m=um(10),uy.underlineColor.ansi=ug,uy.underlineColor.ansi256=up(20),uy.underlineColor.ansi16m=um(20),Object.defineProperties(uy,{rgbToAnsi256:{value:(e,t,r)=>e===t&&t===r?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(r/255*5),enumerable:!1},hexToRgb:{value(e){let t=/[\da-f]{6}|[\da-f]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[r]=t;3===r.length&&(r=[...r].map(e=>e+e).join(""));let n=Number.parseInt(r,16);return[n>>16&255,n>>8&255,255&n]},enumerable:!1},hexToAnsi256:{value:e=>uy.rgbToAnsi256(...uy.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){let t,r,n;if(e<8)return 30+e;if(e<16)return 90+(e-8);if(e>=232)r=t=((e-232)*10+8)/255,n=t;else{let i=(e-=16)%36;t=Math.floor(e/36)/5,r=Math.floor(i/6)/5,n=i%6/5}let i=2*Math.max(t,r,n);if(0===i)return 30;let a=30+(Math.round(n)<<2|Math.round(r)<<1|Math.round(t));return 2===i&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,r)=>uy.ansi256ToAnsi(uy.rgbToAnsi256(e,t,r)),enumerable:!1},hexToAnsi:{value:e=>uy.ansi256ToAnsi(uy.hexToAnsi256(e)),enumerable:!1}}),uy}();function u_(e,t=globalThis.Deno?globalThis.Deno.args:i6.argv){let r=e.startsWith("-")?"":1===e.length?"-":"--",n=t.indexOf(r+e),i=t.indexOf("--");return -1!==n&&(-1===i||n<i)}let{env:ux}=i6;function uk(){return/^\d+$/.test(ux.FORCE_COLOR)}function uS(e,t={}){var r;return 0!==(r=function(e,{streamIsTTY:t,sniffFlags:r=!0}={}){let n="FORCE_COLOR"in ux?"false"===ux.FORCE_COLOR?0:"true"===ux.FORCE_COLOR||0===ux.FORCE_COLOR.length?1:uk()?Math.min(Number.parseInt(ux.FORCE_COLOR,10),3):void 0:void 0;void 0!==n&&(i=n);let a=r?i:n;if(0===a)return 0;if(r){if(u_("color=16m")||u_("color=full")||u_("color=truecolor"))return 3;if(u_("color=256"))return 2}if(void 0!==a&&uk())return a;if("TF_BUILD"in ux&&"AGENT_NAME"in ux)return 1;if(e&&!t&&void 0===a)return 0;let s=a||0;if("dumb"===ux.TERM)return s;if("win32"===i6.platform){let e=rg.release().split(".");return Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if("CI"in ux)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(e=>e in ux)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(e=>e in ux)||"codeship"===ux.CI_NAME?1:s;if("TEAMCITY_VERSION"in ux)return+!!/^(?:9\.0*[1-9]\d*\.|\d{2,}\.)/.test(ux.TEAMCITY_VERSION);if("truecolor"===ux.COLORTERM||"xterm-kitty"===ux.TERM||"xterm-ghostty"===ux.TERM||"wezterm"===ux.TERM)return 3;if("TERM_PROGRAM"in ux){let e=Number.parseInt((ux.TERM_PROGRAM_VERSION||"").split(".",1)[0],10);switch(ux.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}return/-256(?:color)?$/i.test(ux.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(ux.TERM)||"COLORTERM"in ux?1:s}(e,{streamIsTTY:e&&e.isTTY,...t}))&&{level:r,hasBasic:!0,has256:r>=2,has16m:r>=3}}u_("no-color")||u_("no-colors")||u_("color=false")||u_("color=never")?i=0:(u_("color")||u_("colors")||u_("color=true")||u_("color=always"))&&(i=1);let{stdout:uE,stderr:uI}={stdout:uS({isTTY:aw.isatty(1)}),stderr:uS({isTTY:aw.isatty(2)})},u$=Symbol("GENERATOR"),uO=Symbol("STYLER"),uT=Symbol("IS_EMPTY"),uA=Symbol("LEVEL"),uC=Object.create(null),uN=e=>{if(!Number.isSafeInteger(e)||e<0||e>3)throw Error("The `level` should be an integer from 0 to 3")};class uM{constructor(e){return uP(e)}}let uP=e=>{let t=(...e)=>e.join(" ");return((e,t={})=>{void 0!==t.level&&uN(t.level);let r=uE?uE.level:0;e[uA]=void 0===t.level?r:t.level})(t,e),Object.setPrototypeOf(t,uR.prototype),t};function uR(e){return uP(e)}for(let[e,t]of(Object.setPrototypeOf(uR.prototype,Function.prototype),Object.entries(uw)))uC[e]={get(){let r=uU(this,uL(t.open,t.close,this[uO]),this[uT]);return Object.defineProperty(this,e,{value:r}),r}};uC.visible={get(){let e=uU(this,this[uO],!0);return Object.defineProperty(this,"visible",{value:e}),e}};let uj=(e,t)=>{let r=uw[t];if("rgb"===e){let e=(e,t,n)=>r.ansi(uw.rgbToAnsi(e,t,n));return[e,e,(e,t,n)=>r.ansi256(uw.rgbToAnsi256(e,t,n)),r.ansi16m]}if("hex"===e){let e=e=>r.ansi(uw.hexToAnsi(e));return[e,e,e=>r.ansi256(uw.hexToAnsi256(e)),e=>r.ansi16m(...uw.hexToRgb(e))]}let n=e=>r.ansi(uw.ansi256ToAnsi(e));return[n,n,r.ansi256,r.ansi256]};for(let e of["rgb","hex","ansi256"]){let t=e[0].toUpperCase()+e.slice(1);for(let[r,n]of[[e,"color"],["bg"+t,"bgColor"],["underline"+t,"underlineColor"]]){let{close:t}=uw[n],i=uj(e,n);uC[r]={get(){let e=function(e,r,n){return uU(this,uL(i[this.level](e,r,n),t,this[uO]),this[uT])};return Object.defineProperty(this,r,{value:e}),e}}}}let uD=Object.defineProperties(()=>{},{...uC,level:{enumerable:!0,get(){return this[u$].level},set(e){this[u$].level=e}}}),uL=(e,t,r)=>{let n,i;return void 0===r?(n=e,i=t):(n=r.openAll+e,i=t+r.closeAll),{open:e,close:t,openAll:n,closeAll:i,parent:r}},uU=(e,t,r)=>{let n=(...e)=>1===e.length?uF(n,""+e[0]):2===e.length?uF(n,e[0]+" "+e[1]):uF(n,e.join(" "));return Object.setPrototypeOf(n,uD),n[u$]=e[u$]??e,n[uO]=t,n[uT]=r,n},uF=(e,t)=>{if(e[u$][uA]<=0||!t)return e[uT]?"":t;let r=e[uO];if(void 0===r)return t;let{openAll:n,closeAll:i}=r;if(t.includes("\x1b"))for(;void 0!==r;)t=function(e,t,r){let n=e.indexOf(t);if(-1===n)return e;let i=t.length,a=0,s="";do s+=e.slice(a,n)+t+r,a=n+i,n=e.indexOf(t,a);while(-1!==n)return s+e.slice(a)}(t,r.close,r.open),r=r.parent;let a=t.indexOf("\n");return -1!==a&&(t=function(e,t,r,n){let i=0,a="";do{let s="\r"===e[n-1];a+=e.slice(i,s?n-1:n)+t+(s?"\r\n":"\n")+r,i=n+1,n=e.indexOf("\n",i)}while(-1!==n)return a+e.slice(i)}(t,i,n,a)),n+t+i};Object.defineProperties(uR.prototype,{...uC,level:{enumerable:!0,get(){return this[uA]},set(e){uN(e),this[uA]=e}}}),uP(void 0),uP({level:uI?uI.level:0});let uB=function({onlyFirst:e=!1}={}){return RegExp("(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]",e?void 0:"g")}();function uY(e){if("string"!=typeof e)throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.includes("\x1b")||e.includes("›")?e.replace(uB,""):e}let uW=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],uq=[12288,12288,65281,65376,65504,65510],uX=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141],uJ=(e,t)=>{let r=0,n=Math.floor(e.length/2)-1;for(;r<=n;){let i=Math.floor((r+n)/2),a=2*i;if(t<e[a])n=i-1;else{if(!(t>e[a+1]))return!0;r=i+1}}return!1},[uz,uG]=function(e){let t=e[0],r=e[1];for(let n=0;n<e.length;n+=2){let i=e[n],a=e[n+1];if(19968>=i&&19968<=a)return[i,a];a-i>r-t&&(t=i,r=a)}return[t,r]}(uX);function uV(e,{ambiguousAsWide:t=!1}={}){if(!Number.isSafeInteger(e))throw TypeError(`Expected a code point, got \`${typeof e}\`.`);return!(e<12288)&&!(e>65510)&&uJ(uq,e)||e>=uz&&e<=uG||!(e<4352)&&!(e>262141)&&uJ(uX,e)||t&&!(e<161)&&!(e>1114109)&&uJ(uW,e)?2:1}let uK=new Intl.Segmenter,uH=/^(?:\p{Default_Ignorable_Code_Point}|\p{Control}|\p{Format}|\p{Nonspacing_Mark}|\p{Enclosing_Mark}|\p{Surrogate})+$/v,uQ=/^[\p{Default_Ignorable_Code_Point}\p{Control}\p{Format}\p{Nonspacing_Mark}\p{Enclosing_Mark}\p{Surrogate}]+/v,uZ=/\p{Spacing_Mark}/v,u0=/^\p{RGI_Emoji}$/v,u1=/^[\d#*]\u20E3$/,u2=/\p{Extended_Pictographic}/gu;function u5(e){return e>=4352&&e<=4447||e>=43360&&e<=43388}function u3(e){return e>=4448&&e<=4519||e>=55216&&e<=55238}function u8(e){return e>=4520&&e<=4607||e>=55243&&e<=55291}function u6(e,t={}){if("string"!=typeof e||0===e.length)return 0;let{ambiguousIsNarrow:r=!0,countAnsiEscapeCodes:n=!1}=t,i=e;if(!n&&(i.includes("\x1b")||i.includes("›"))&&(i=uY(i)),0===i.length)return 0;if(/^[\u0020-\u007E]*$/.test(i))return i.length;let a=0,s={ambiguousAsWide:!r};for(let{segment:e}of uK.segment(i)){if(uH.test(e))continue;if(u0.test(e)||function(e){if(e.length>50)return!1;if(u1.test(e))return!0;if(e.includes("‍")){let t=e.match(u2);return null!==t&&t.length>=2}return!1}(e)){a+=2;continue}let t=e.replace(uQ,""),r=function(e,t){let r=[];for(let t of e)uH.test(t)||r.push(t.codePointAt(0));if(0===r.length)return;let n=0;for(let e=0;e<r.length;e++){let i=r[e];if(!(u5(i)||u3(i)||u8(i))){if(0===n)return;for(let i=e;i<r.length;i++)n+=uV(r[i],t);break}if(u5(i)&&u3(r[e+1])){n+=2,e+=u8(r[e+2])?2:1;continue}n+=uV(i,t)}return n}(t,s);if(void 0!==r){a+=r;continue}a+=uV(t.codePointAt(0),s),a+=function(e,t){let r=0,n=!0;for(let i of e){if(n){n=!1;continue}(uZ.test(i)||i>="＀"&&i<="￯")&&(r+=uV(i.codePointAt(0),t))}return r}(t,s)}return a}let u9=(e=0)=>t=>`\u001B[${t+e}m`,u4=(e=0)=>t=>`\u001B[${38+e};5;${t}m`,u7=(e=0)=>(t,r,n)=>`\u001B[${38+e};2;${t};${r};${n}m`,de={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(de.modifier),[...Object.keys(de.color),...Object.keys(de.bgColor)];let dt=function(){let e=new Map;for(let[t,r]of Object.entries(de)){for(let[t,n]of Object.entries(r))de[t]={open:`\u001B[${n[0]}m`,close:`\u001B[${n[1]}m`},r[t]=de[t],e.set(n[0],n[1]);Object.defineProperty(de,t,{value:r,enumerable:!1})}return Object.defineProperty(de,"codes",{value:e,enumerable:!1}),de.color.close="\x1b[39m",de.bgColor.close="\x1b[49m",de.color.ansi=u9(),de.color.ansi256=u4(),de.color.ansi16m=u7(),de.bgColor.ansi=u9(10),de.bgColor.ansi256=u4(10),de.bgColor.ansi16m=u7(10),Object.defineProperties(de,{rgbToAnsi256:{value:(e,t,r)=>e===t&&t===r?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(r/255*5),enumerable:!1},hexToRgb:{value(e){let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[r]=t;3===r.length&&(r=[...r].map(e=>e+e).join(""));let n=Number.parseInt(r,16);return[n>>16&255,n>>8&255,255&n]},enumerable:!1},hexToAnsi256:{value:e=>de.rgbToAnsi256(...de.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){let t,r,n;if(e<8)return 30+e;if(e<16)return 90+(e-8);if(e>=232)r=t=((e-232)*10+8)/255,n=t;else{let i=(e-=16)%36;t=Math.floor(e/36)/5,r=Math.floor(i/6)/5,n=i%6/5}let i=2*Math.max(t,r,n);if(0===i)return 30;let a=30+(Math.round(n)<<2|Math.round(r)<<1|Math.round(t));return 2===i&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,r)=>de.ansi256ToAnsi(de.rgbToAnsi256(e,t,r)),enumerable:!1},hexToAnsi:{value:e=>de.ansi256ToAnsi(de.hexToAnsi256(e)),enumerable:!1}}),de}(),dr=new Set(["\x1b","›"]),dn="]8;;",di=RegExp(`^\\u001B(?:\\[(?<sgr>[0-9;]*)m|${dn}(?<uri>[^\\u0007\\u001B]*)(?:\\u0007|\\u001B\\\\))`),da=RegExp("^\\u009B(?<sgr>[0-9;]*)m"),ds=new Set(dt.codes.values());ds.delete(0);let dl=new Intl.Segmenter,dc=e=>Array.from(dl.segment(e),({segment:e})=>e),du=e=>`\u001B[${e}m`,dd=e=>`\u001B${dn}${e}\u0007`,df=e=>{let t=e.split(";").map(e=>""===e?0:Number.parseInt(e,10)),r=[];for(let e=0;e<t.length;e++){let n=t[e];if(Number.isFinite(n)){if(38===n||48===n||58===n){if(e+1>=t.length)break;let i=t[e+1];if(5===i&&Number.isFinite(t[e+2])){r.push([n,i,t[e+2]]),e+=2;continue}let a=t[e+2],s=t[e+3],o=t[e+4];if(2===i&&Number.isFinite(a)&&Number.isFinite(s)&&Number.isFinite(o)){r.push([n,i,a,s,o]),e+=4;continue}break}r.push([n])}}return r},dh=(e,t)=>{let r=e.findIndex(e=>e.family===t);-1!==r&&e.splice(r,1)},dp=(e,t)=>{dh(e,t.family),e.push(t)},dm=(e,t)=>{if(0===e)return t.length=0,!0;if(39===e)return dh(t,"foreground"),!0;if(49===e)return dh(t,"background"),!0;if(59===e)return dh(t,"underlineColor"),!0;if(ds.has(e)){for(let r=t.length-1;r>=0;r--){let n=t[r];n.family.startsWith("modifier-")&&n.close===e&&t.splice(r,1)}return!0}return!1},dg=(e,t)=>{let[r]=e;if(dm(r,t))return;let n=r>=30&&r<=37||r>=90&&r<=97||38===r&&e.length>1?{family:"foreground",open:e.join(";"),close:39}:r>=40&&r<=47||r>=100&&r<=107||48===r&&e.length>1?{family:"background",open:e.join(";"),close:49}:58===r&&e.length>1?{family:"underlineColor",open:e.join(";"),close:59}:void 0;if(n)return void dp(t,n);let i=dt.codes.get(r);void 0!==i&&0!==i&&dp(t,{family:`modifier-${r}`,open:e.join(";"),close:i})},dy=(e,t)=>{for(let r of df(e))dg(r,t)},db=(e,t)=>{for(let r of df(e)){let[e]=r;dm(e,t)}},dv=(e,t)=>{let r=e;for(;r.length>0;){if(r.startsWith("\x1b")&&"\\"!==r[1]){let e=di.exec(r);if(!e)break;void 0!==e.groups.sgr&&db(e.groups.sgr,t),r=r.slice(e[0].length);continue}if(r.startsWith("›")){let e=da.exec(r);if(!e||void 0===e.groups.sgr)break;db(e.groups.sgr,t),r=r.slice(e[0].length);continue}break}},dw=e=>[...e].reverse().map(e=>du(e.close)).join(""),d_=e=>e.map(e=>du(e.open)).join(""),dx=(e,t,r)=>{let n=dc(t),i=!1,a=!1,s=u6(uY(e.at(-1)));for(let[t,o]of n.entries()){let l=u6(o);if(s+l<=r?e[e.length-1]+=o:(e.push(o),s=0),dr.has(o)&&!(a&&"\x1b"===o&&"\\"===n[t+1])&&(i=!0,a=n.slice(t+1,t+1+dn.length).join("")===dn),i){a?("\x07"===o||"\\"===o&&t>0&&"\x1b"===n[t-1])&&(i=!1,a=!1):"m"===o&&(i=!1);continue}(s+=l)===r&&t<n.length-1&&(e.push(""),s=0)}!s&&e.at(-1).length>0&&e.length>1&&(e[e.length-2]+=e.pop())},dk=[" pppppppppppp "," pppppppppppppp ","pppppppppppeeppp","ppppppppppfeeepp","pppppppppcffeepp","ppppppppcccffppp","pppppppcccccpppp","ppppppcccccppppp","pppppcccccpppppp","ppppwccccppppppp","pppwwwccpppppppp","pppkwwwppppppppp","pppkkwpppppppppp","pppppppppppppppp"," pppppppppppppp "," pppppppppppp "],dS={s:["....","....",".###","#...",".##.","...#","###.","...."],k:["#...","#...","#..#","#.#.","##..","#.#.","#..#","...."],e:["....","....",".##.","#..#","####","#...",".###","...."],t:[".#.",".#.","###",".#.",".#.",".#.",".##","..."],c:["....","....",".###","#...","#...","#...",".###","...."],h:["#...","#...","#.#.","##.#","#..#","#..#","#..#","...."],i:["#",".","#","#","#","#","#","."]},dE={p:{dark:{red:158,green:124,blue:140,ansi256:138},light:{red:143,green:112,blue:127,ansi256:96}},c:{dark:{red:250,green:248,blue:247,ansi256:231},light:{red:250,green:248,blue:247,ansi256:231}},w:{dark:{red:214,green:186,blue:152,ansi256:180},light:{red:214,green:186,blue:152,ansi256:180}},k:{dark:{red:58,green:50,blue:54,ansi256:237},light:{red:58,green:50,blue:54,ansi256:237}},f:{dark:{red:186,green:190,blue:196,ansi256:250},light:{red:186,green:190,blue:196,ansi256:250}},e:{dark:{red:222,green:152,blue:158,ansi256:175},light:{red:222,green:152,blue:158,ansi256:175}}},dI={dark:{red:195,green:154,blue:172,ansi256:181},light:{red:111,green:84,blue:98,ansi256:95}},d$={dark:{red:246,green:241,blue:231,ansi256:255},light:{red:26,green:23,blue:18,ansi256:234}},dO={dark:{red:216,green:204,blue:177,ansi256:187},light:{red:76,green:70,blue:57,ansi256:239}},dT=[[0,0,0],[205,0,0],[0,205,0],[205,205,0],[0,0,238],[205,0,205],[0,205,205],[229,229,229],[127,127,127],[255,0,0],[0,255,0],[255,255,0],[92,92,255],[255,0,255],[0,255,255],[255,255,255]];function dA(e,t,r,n="plain"){if("none"===r.colors)return e;let i=new uM({level:"truecolor"===r.colors?3:2}),a="truecolor"===r.colors?i.rgb(t.red,t.green,t.blue):i.ansi256(t.ansi256);return"bold"===n?a.bold(e):a(e)}function dC(e,t){return dA(e,dI[t.background],t,"bold")}function dN(e,t){return dA(e,d$[t.background],t,"bold")}function dM(e,t){return dA(e,dO[t.background],t)}function dP(e,t){let r=new uM({level:"truecolor"===t.colors?3:2});return"truecolor"===t.colors?r.rgb(e.red,e.green,e.blue):r.ansi256(e.ansi256)}function dR(e,t){let r=dE[e];return void 0===r?void 0:r[t.background]}function dj(e,t,r,n=u6(e)){var i;let a=Math.max(16,r-u6(e));return`${e}${(i={hard:!0,trim:!0},String(t).normalize().replaceAll("\r\n","\n").split("\n").map(e=>((e,t,r={})=>{let n;if(!1!==r.trim&&""===e.trim())return"";let i="",a=[],s=e.split(" ").map(e=>u6(e)),o=[""];for(let[n,i]of e.split(" ").entries()){!1!==r.trim&&(o[o.length-1]=o.at(-1).trimStart());let e=u6(o.at(-1));if(0!==n&&(e>=t&&(!1===r.wordWrap||!1===r.trim)&&(o.push(""),e=0),(e>0||!1===r.trim)&&(o[o.length-1]+=" ",e++)),r.hard&&!1!==r.wordWrap&&s[n]>t){let r=t-e,a=1+Math.floor((s[n]-r-1)/t);Math.floor((s[n]-1)/t)<a&&o.push(""),dx(o,i,t);continue}if(e+s[n]>t&&e>0&&s[n]>0){if(!1===r.wordWrap&&e<t){dx(o,i,t);continue}o.push("")}if(e+s[n]>t&&!1===r.wordWrap){dx(o,i,t);continue}o[o.length-1]+=i}!1!==r.trim&&(o=o.map(e=>(e=>{let t=e.split(" "),r=t.length;for(;r>0&&!(u6(t[r-1])>0);)r--;return r===t.length?e:t.slice(0,r).join(" ")+t.slice(r).join("")})(e)));let l=o.join("\n"),c=dc(l),u=0;for(let[e,t]of c.entries()){if(i+=t,"\x1b"===t&&"\\"!==c[e+1]){let{groups:e}=di.exec(l.slice(u))||{groups:{}};void 0!==e.sgr?dy(e.sgr,a):void 0!==e.uri&&(n=0===e.uri.length?void 0:e.uri)}else if("›"===t){let{groups:e}=da.exec(l.slice(u))||{groups:{}};void 0!==e.sgr&&dy(e.sgr,a)}if("\n"===c[e+1])n&&(i+=dd("")),i+=dw(a);else if("\n"===t){let e=[...a];dv(l.slice(u+1),e),i+=d_(e),n&&(i+=dd(n))}u+=t.length}return i})((e=>{if(!e.includes(" "))return e;let t=e.split(" "),r=0,n="";for(let[e,i]of t.entries())if(n+=i,r+=u6(i),e<t.length-1){let e=8-r%8;n+=" ".repeat(e),r+=e}return n})(e),a,i)).join("\n")).replaceAll("\n",`
55
- ${" ".repeat(n)}`)}`}function dD(e,t,r,n,i=8){if(n<52)return[` ${dN(e,r)}`,dj(" ",dM(t,r),n)].join("\n");let a=e.padEnd(i);return dj(` ${dN(a,r)} `,dM(t,r),n)}function dL(e){let t=Math.max(32,e.width??80);return[function(e){let t=Math.max(32,e.width??80),r=dj(" ",dM("describe it. sketchi draws it.",e),t);if("none"===e.colors||!1===e.unicode)return[` ${dA("sketchi",d$[e.background],e,"bold")}`,r].join("\n");let n=function(e){let t=Array.from({length:8},(e,t)=>[..."sketchi"].map((e,r)=>`${dS[e]?.[t]??""}${6===r?"":"."}`).join("")),r=d$[e.background],n=[];for(let i=0;i<t.length;i+=2){let a="";for(let e=0;e<(t[i]?.length??0);e+=1){let r=t[i]?.[e]==="#",n=t[i+1]?.[e]==="#";a+=r&&n?"█":r?"▀":n?"▄":" "}n.push("none"===e.colors?a:dP(r,e)(a))}return n}(e);if(t<50)return[...n.map(e=>` ${e}`),"",r].join("\n");let i=function(e){let t=[];for(let r=0;r<dk.length;r+=2){let n="";for(let t=0;t<16;t+=1){let i=dR(dk[r]?.[t]??" ",e),a=dR(dk[r+1]?.[t]??" ",e);void 0===i&&void 0===a?n+=" ":void 0===i?n+=dP(a,e)("▄"):void 0===a?n+=dP(i,e)("▀"):n+=function(e,t,r){let n=new uM({level:"truecolor"===r.colors?3:2}),i="truecolor"===r.colors?n.bgRgb(t.red,t.green,t.blue):n.bgAnsi256(t.ansi256);return"truecolor"===r.colors?i.rgb(e.red,e.green,e.blue)("▀"):i.ansi256(e.ansi256)("▀")}(i,a,e)}t.push(n)}return t}(e),a=(i.length-n.length)/2,s=" ".repeat(2);return[...i.map((e,t)=>{let r=n[t-a];return` ${e}${void 0===r?"":`${s}${r}`}`}),"",r].join("\n")}(e),"",dC("START HERE",e),dj(` ${dN("sketchi generate",e)} `,dM("interactive",e),t),dj(" ",dN('sketchi generate --prompt "Map release approval with pass and revise branches"',e),t),dj(" ",dM("Writes <generated-id>.png in this directory. No account or API key needed.",e),t),"",dC("WORK WITH A DIAGRAM",e),dD("show","Inspect a local diagram.",e,t),dD("edit","Replace its canonical document.",e,t),dD("export","Write PNG, Excalidraw, or scene bytes.",e,t),dD("share","Create an encrypted Excalidraw link.",e,t),"",dj("",dM("sketchi docs for every command. Add --output json for automation.",e),t)].join("\n")}function dU(e){if(!Number.isInteger(e)||e<0||e>255)return;if(e<16){let[t,r,n]=dT[e]??[0,0,0];return{red:t,green:r,blue:n}}if(e<232){let t=[0,95,135,175,215,255],r=e-16,n=t[Math.floor(r/36)]??0;return{red:n,green:t[Math.floor(r%36/6)]??0,blue:t[r%6]??0}}let t=8+(e-232)*10;return{red:t,green:t,blue:t}}function dF(e){let t=e=>{let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4};return .2126*t(e.red)+.7152*t(e.green)+.0722*t(e.blue)}function dB(e,t){return(Math.max(dF(e),dF(t))+.05)/(Math.min(dF(e),dF(t))+.05)}function dY(e,t,r){let n=e=>"truecolor"===r?e:dU(e.ansi256)??e;return Math.min(dB(e,n(dI[t])),dB(e,n(d$[t])),dB(e,n(dO[t])))}let dW=new Set(["generate","docs","create","show","edit","patch","list","restore","share","pull","export"]);function dq(e){return{_tag:"File",path:e}}function dX(e){return{_tag:"InlineJson",value:e}}function dJ(e="canonical document"){let t=sF("flag","file").pipe(oE("PATH|-"),oS(`Read one ${e} from PATH, or stdin with -.`),o$(dq)),r=sF("flag","json").pipe(oE("VALUE"),oS(`Read one ${e} from inline JSON.`),o$(dX));return{source:Object.assign(Object.create(Object.getPrototypeOf(t)),t,{parse:e=>{let n=e.flags.file?.length??0,i=e.flags.json?.length??0;return 1===n&&0===i?t.parse(e):0===n&&1===i?r.parse(e):U.fJG(new su({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:oI(r)}}function dz(e,t,r){return new su({option:e,value:t,expected:r,kind:"flag"})}function dG(e,t){return nm.make({message:e,hint:"Provide operations and optional options or intent only.",details:t})}let dV=U.fn("sketchi.cli.patch.decodeInput")(function*(e){if("object"!=typeof e||null===e||Array.isArray(e))return yield*dG("The diagram patch request is invalid.",["patch: Expected an object."]);if("source"in e)return yield*dG("The diagram patch request cannot supply source.",["source: The CLI binds the stored scene."]);if("requestId"in e)return yield*dG("The diagram patch request cannot supply requestId.",["requestId: The CLI owns the patch request id."]);let t=nd.Er.safeParse({...e,requestId:"cli-patch-validation",source:{scene:{diagramId:"validation",title:"Validation",width:1,height:1,accentColor:"#000000",backgroundColor:"#ffffff",elements:[]}}});return t.success?{operations:t.data.operations,...t.data.options?{options:t.data.options}:{},...t.data.intent?{intent:t.data.intent}:{}}:yield*dG("The diagram patch request is invalid.",t.error.issues.map(e=>e.message))}),dK=U.fn("sketchi.cli.patch.parseJson")(function*(e){let t=yield*U.SvU({try:()=>JSON.parse(e),catch:()=>np.make({code:"invalid_json",message:"The patch input is not valid JSON.",hint:"Pass one complete diagram patch request object."})});return yield*dV(t)});class dH extends Z.kl()("@sketchi/cli/DiagramPatcher"){}function dQ(e){let t=e.ref?.path?` (${e.ref.path})`:"";return`${e.code}${t}: ${e.message}`}function dZ(e,t){let r=e.formats.find(e=>e.format===t);return r?.inline!==void 0?U.PyW(r.inline):U.fJG(ng.make({status:"missing_inline_artifact",message:`Code Mode did not return the patched ${t} artifact inline.`,hint:"Retry the offline patch with the required artifact formats.",details:[t]}))}function d0(e){let t=nd.Uh.safeParse(e);return t.success?U.PyW(t.data):U.fJG(ng.make({status:"invalid_scene_artifact",message:"Code Mode returned an invalid patched scene artifact.",hint:"Inspect the Code Mode patch/export boundary.",details:t.error.issues.map(e=>e.message)}))}function d1(e){let t=nd.yE.safeParse(e);return t.success?U.PyW(t.data):U.fJG(ng.make({status:"invalid_excalidraw_artifact",message:"Code Mode returned an invalid patched Excalidraw artifact.",hint:"Inspect the Code Mode patch/export boundary.",details:t.error.issues.map(e=>e.message)}))}let d2=z.QZ(dH,U.JkU(function*(){let e=yield*nd.Ov,t=yield*nd.UA;return{patch:U.fn("sketchi.cli.diagram.patch")(function*(r,n,i){let a=yield*(0,nd.OF)({requestId:i,source:{scene:r},operations:n.operations,options:{...n.options,artifactFormats:["scene","excalidraw"],inlineArtifacts:["scene","excalidraw"]},...n.intent?{intent:n.intent}:{}}).pipe(U.PfK(nd.Ov,e),U.PfK(nd.UA,t));if(!a.ok){let e,t,r,n;return yield*(e=a.issues[0],t=e?.message??`Code Mode patch failed with ${a.status}.`,r=e?.hint??"Repair the patch request and retry.",n=a.issues.map(dQ),"invalid_input"===a.status||"target_not_found"===a.status||"unsupported_operation"===a.status||"connectivity_changed"===a.status?nm.make({message:t,hint:r,details:n}):"storage_failed"===a.status?nv.make({code:"storage_commit_failed",message:t,hint:r}):ng.make({status:a.status,message:t,hint:r,details:n}))}return{scene:yield*dZ(a.artifact,"scene").pipe(U.qIB(d0)),excalidraw:yield*dZ(a.artifact,"excalidraw").pipe(U.qIB(d1))}})}}));class d5 extends Z.kl()("@sketchi/cli/InputReader"){}function d3(e,t){return U.SvU({try:()=>new TextDecoder("utf-8",{fatal:!0}).decode(e),catch:()=>np.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 d8=function(e=()=>!0===process.stdin.isTTY){return z.QZ(d5,U.JkU(function*(){let t=yield*n1,r=yield*r2;return{read:U.fn("sketchi.cli.input.read")(function*(n,i={content:"JSON document"}){if("InlineJson"===n._tag)return n.value;if("-"!==n.path){let e=yield*t.readBytes(n.path).pipe(U.xm_(()=>np.make({code:"input_read_failed",message:`Unable to read input file ${n.path}.`,hint:"Check the path and file permissions, then retry."})));return yield*d3(e,"file")}if(e())return yield*np.make({code:"interactive_stdin",message:`${i.content} input requires piped or redirected stdin.`,hint:"share link"===i.content?"Pipe one complete Excalidraw share link to --link -.":"Pipe one JSON document, or use --file PATH / --json VALUE."});let a=yield*tw(r.stdin,()=>({chunks:[],size:0}),(e,t)=>{let r=t.byteLength+e.size;return void 0!==i.maxBytes&&r>i.maxBytes?U.fJG(np.make({code:"input_read_failed",message:`Standard input exceeds the ${String(i.maxBytes)} byte limit for a ${i.content}.`,hint:`Pipe one complete ${i.content} within the documented limit.`})):U.PyW({chunks:[...e.chunks,t],size:r})}).pipe(U.xm_(e=>e instanceof np?e:np.make({code:"input_read_failed",message:`Unable to read the ${i.content} from stdin.`,hint:`Pipe one complete UTF-8 ${i.content} and retry.`})));return yield*d3(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}(a.chunks),"stdin")})}}))}(),d6=U.fn("sketchi.cli.input.readDocument")(function*(e){let t=yield*d5,r=yield*t.read(e);return yield*nT(r)}),d9=U.fn("sketchi.cli.input.readPatch")(function*(e){let t=yield*d5,r=yield*t.read(e,{content:"patch request"});return yield*dK(r)});class d4 extends Z.kl()("@sketchi/cli/OutputWriter"){}class d7 extends nt.X0d()("CliCommandExit",{exitCode:nt.wNn}){}function fe(e){return nh.make({cause:e,operation:"write-output",path:"standard stream",message:"Unable to write command output."})}let ft=z.QZ(d4,U.JkU(function*(){let e=yield*r2;return{stdout:t=>((...e)=>th(e))(t).pipe(tv(e.stdout()),U.xm_(fe)),stderr:t=>((...e)=>th(e))(t).pipe(tv(e.stderr()),U.xm_(fe))}}));function fr(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 fn=U.fn("sketchi.cli.output.failure")(function*(e,t,r){let n=yield*d4,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"CliInteractiveError":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":case"CliShareError":return{code:e.code,message:e.message,hint:e.hint,details:e.details}}}(r),a="json"===t?nA({ok:!1,command:e,error:i}):fr(i);return yield*n.stderr(uf(a)),yield*d7.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"CliInteractiveError":return"cancelled"===e.code?2:1;case"CliStorageError":if("diagram_not_found"===e.code||"revision_not_found"===e.code)return 5;if("diagram_already_exists"===e.code||"diagram_busy"===e.code||"detached_edit"===e.code||"patch_conflict"===e.code||"replacement_conflict"===e.code||"restore_conflict"===e.code)return 6;return 7;case"CliFilesystemError":return 7;case"CliExportError":return 8;case"CliShareError":return"share_transport_failed"===e.code||"share_timeout"===e.code||"share_api_changed"===e.code||"share_link_unavailable"===e.code?13:3}}(r)})}),fi=U.fn("sketchi.cli.output.success")(function*(e,t,r,n,i="stdout"){let a=yield*d4,s="json"===t?nA({ok:!0,command:e,data:r}):n;yield*a[i](s.endsWith("\n")?s:`${s}
56
- `)});function fa(e,t,r,n,i=e=>e){return r.pipe(U.tvg({onFailure:r=>fn(e,t,r),onSuccess:r=>fi(e,t,i(r),n(r))}))}function fs(e,t,r){return nw.make({code:e,message:t,hint:r,details:[]})}async function fo(e,t){let r=Number(e.headers.get("content-length"));if(Number.isFinite(r)&&r>t)throw Error("response body exceeds limit");if(!e.body)return new Uint8Array;let n=e.body.getReader(),i=[],a=0;try{for(;;){let e=await n.read();if(e.done)break;if((a+=e.value.byteLength)>t)throw await n.cancel(),Error("response body exceeds limit");i.push(e.value)}}finally{n.releaseLock()}let s=new Uint8Array(a),o=0;for(let e of i)s.set(e,o),o+=e.byteLength;return s}function fl(){return fs("share_timeout","The Excalidraw storage request timed out.","Retry once. The unofficial third-party backend may be unavailable.")}function fc(){return fs("share_transport_failed","The Excalidraw storage request failed.","Retry once. The unofficial third-party backend may be unavailable.")}async function fu(e,t,r){let n=new AbortController,i=setTimeout(()=>n.abort(),15e3);try{let i=await fetch(e,{...t,redirect:"error",signal:n.signal});return await r(i)}finally{clearTimeout(i)}}class fd extends Z.kl()("@sketchi/cli/ShareTransport"){}let ff=z.Py(fd,{upload:e=>U.$mh({try:async()=>await fu("https://json.excalidraw.com/api/v2/post/",{method:"POST",body:Uint8Array.from(e)},async e=>{let t=await fo(e,65536);if(!e.ok)throw Error("upload HTTP failure");let r=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(t));if("object"!=typeof r||null===r||!("id"in r)||"string"!=typeof r.id||!/^[A-Za-z0-9_-]{1,128}$/.test(r.id)||!("data"in r)||r.data!==`${n9}${r.id}`)throw fs("share_api_changed","The Excalidraw storage API returned an unexpected response.","The unofficial API may have changed; update Sketchi compatibility before retrying.");return r.id}),catch:e=>e instanceof nw?e:e instanceof DOMException&&"AbortError"===e.name?fl():fc()}),download:e=>U.$mh({try:async()=>await fu(`${n9}${e}`,{method:"GET"},async e=>{if(404===e.status)throw fs("share_link_unavailable","The Excalidraw share link is unavailable.","Verify the complete bearer link or ask its sender to export a new link.");if(!e.ok)throw Error("download HTTP failure");return await fo(e,2097152)}),catch:e=>e instanceof nw?e:e instanceof DOMException&&"AbortError"===e.name?fl():fc()})});class fh extends Z.kl()("@sketchi/cli/LinkOpener"){}let fp=function(e=(e,t,r)=>{let n=(0,tH.spawn)(e,[...t],r);return{onError:e=>{n.once("error",e)},onExit:e=>{n.once("exit",e)},kill:()=>n.kill()}},t=process.platform,r=3e3){return z.Py(fh,{open:n=>U.ivC(()=>new Promise(i=>{let a=function(e,t){switch(t){case"darwin":return{command:"open",args:[e]};case"win32":return{command:"cmd.exe",args:["/d","/s","/c","start","",e]};default:return{command:"xdg-open",args:[e]}}}(n,t),s=e(a.command,a.args,{shell:!1,stdio:"ignore"}),o=!1,l=e=>{o||(o=!0,clearTimeout(c),i(e))};s.onError(()=>l({status:"unconfirmed",reason:"missing_executable"})),s.onExit(e=>l(0===e?{status:"accepted"}:{status:"unconfirmed",reason:"nonzero_exit"}));let c=setTimeout(()=>{s.kill(),l({status:"unconfirmed",reason:"timeout"})},r)}))})}();class fm extends Z.kl()("@sketchi/cli/ExcalidrawShare"){}let fg=z.QZ(fm,U.JkU(function*(){let e=yield*fd;return{share:U.fn("sketchi.cli.share.upload")(function*(t){var r;let n=yield*ig(t).pipe(U.qIB(()=>U.SvU({try:()=>{var e;let r=ih(t);return ie.encode(JSON.stringify({type:r.type,version:r.version,source:r.source,elements:r.elements,appState:(e=r.appState,Object.fromEntries(["gridSize","gridStep","gridModeEnabled","viewBackgroundColor","lockedMultiSelections"].flatMap(t=>t in e?[[t,e[t]]]:[])))},null,2))},catch:()=>ii("unsupported_scene","The Excalidraw scene could not be serialized.","Inspect the local diagram.excalidraw artifact and retry.")}))),i=Buffer.from(crypto.getRandomValues(new Uint8Array(16))).toString("base64url"),a=yield*U.$mh({try:async()=>{if(n.byteLength>0xfffff0)throw ii("share_payload_too_large","The Excalidraw share contents exceed 16 MiB.","Reduce the drawing size and retry.");let e=2097136-ir.byteLength-12-16,t=await function(e,t){let r=ie.encode("null"),n=[iy(1),iy(r.byteLength),r,iy(e.byteLength),e],i=new n8.Gy({chunkSize:65536}),a=[],s=0;for(let[e,r]of(i.onData=e=>{let r=e instanceof Uint8Array?e:new Uint8Array(e);if((s+=r.byteLength)>t)throw ii("share_payload_too_large","The encrypted Excalidraw share payload exceeds 2 MiB.","Reduce the drawing size and retry.");a.push(r)},n.entries()))if(i.push(r,e===n.length-1),0!==i.err)throw Error(i.msg);let o=new Uint8Array(s),l=0;for(let e of a)o.set(e,l),l+=e.byteLength;return o}(n,e),r=Uint8Array.from((void 0)??crypto.getRandomValues(new Uint8Array(12)));if(12!==r.byteLength)throw Error("invalid IV length");let a=new Uint8Array(await crypto.subtle.encrypt({name:"AES-GCM",iv:Uint8Array.from(r)},await id(i,"encrypt"),Uint8Array.from(t)));var s=[ir,r,a];let o=new Uint8Array(4+s.reduce((e,t)=>e+4+t.byteLength,0));io(o,0,1);let l=4;for(let e of s)io(o,l,e.byteLength),l+=4,o.set(e,l),l+=e.byteLength;return o},catch:e=>e instanceof nw?e:ii("share_crypto_failed","The Excalidraw share payload could not be encrypted.","Retry the command. If it persists, inspect the local artifact.")});return{link:(r={id:yield*e.upload(a),key:i},`https://excalidraw.com/#json=${r.id},${r.key}`)}}),pull:U.fn("sketchi.cli.share.pull")(function*(t){var r;let n=yield*ie.encode(t).byteLength>4096?U.fJG(ii("invalid_share_link","The Excalidraw share link is invalid.","Provide one complete https://excalidraw.com/#json=ID,KEY link.",["link exceeds 4 KiB"])):U.SvU({try:()=>{let e=/^https:\/\/(www\.)?excalidraw\.com\/#json=([A-Za-z0-9_-]{1,128}),([A-Za-z0-9_-]{22})$/u.exec(t);if(!e?.[2]||!e[3])throw Error("invalid raw URL grammar");let r=new URL(t),n=`https://${e[1]??""}excalidraw.com/#json=${e[2]},${e[3]}`;if(r.href!==n)throw Error("URL normalization changed the supplied link");return iu(e[3]),{id:e[2],key:e[3]}},catch:()=>ii("invalid_share_link","The Excalidraw share link is invalid.","Provide one complete https://excalidraw.com/#json=ID,KEY link.")}),i=yield*e.download(n.id);return yield*(r=n.key,i.byteLength>2097152?U.fJG(ii("share_payload_too_large","The Excalidraw share payload exceeds 2 MiB.","Use a smaller supported Excalidraw link.")):U.$mh({try:async()=>{let[e,t,n]=ic(i,3);if(!e||!t||!n||12!==t.byteLength)throw Error("invalid encrypted payload chunks");let a=JSON.parse(it.decode(e));if(!ia(a)||2!==a.version||"pako@1"!==a.compression||"AES-GCM"!==a.encryption)throw Error("unsupported encoding metadata");let s=new Uint8Array(await crypto.subtle.decrypt({name:"AES-GCM",iv:Uint8Array.from(t)},await id(r,"decrypt"),Uint8Array.from(n))),o=(0,nQ.inflateSync)(s,{maxOutputLength:0x1000001});if(o.byteLength>0x1000000)throw Error("decompressed payload exceeds 16 MiB");let l=ic(o,2);if(!l[0]||!l[1])throw Error("invalid inner chunk count");if("null"!==it.decode(l[0]))throw Error("unsupported contents metadata");return!function(e){let t=it.decode(e),r=0,n=!1,i=!1;for(let e of t){if(n){i?i=!1:"\\"===e?i=!0:'"'===e&&(n=!1);continue}if('"'===e)n=!0;else if("{"===e||"["===e){if((r+=1)>64)throw Error("JSON structure exceeds depth 64")}else if(("}"===e||"]"===e)&&(r-=1)<0)throw Error("unbalanced JSON structure")}if(0!==r||n)throw Error("incomplete JSON structure")}(l[1]),JSON.parse(it.decode(l[1]))},catch:e=>e instanceof RangeError||e instanceof Error&&(e.message.includes("maxOutputLength")||e.message.includes("larger than"))?ii("share_payload_too_large","The decompressed Excalidraw share payload exceeds 16 MiB.","Use a smaller supported Excalidraw link."):ii("share_crypto_failed","The Excalidraw share payload could not be decrypted or decoded.","Verify that the complete bearer link is correct and uses current format v2.")}))})}}));function fy(e){return nw.make({code:"unsupported_scene",message:"The pulled Excalidraw scene cannot be rendered safely.",hint:"Use a supported, renderable Excalidraw scene and retry.",details:[e.message]})}let fb=U.fn("sketchi.cli.preflightPullTarget")(function*(e){let t=yield*nN(e),r=yield*ik,n=yield*r.show(t);return{id:t,observed:n}}),fv=U.fn("sketchi.cli.pullIntoStore")(function*(e,t,r){let n=r??(yield*fb(e)),i=n.id,a=yield*ik,s=yield*fm,o=yield*nK,l=yield*s.pull(t);yield*ig(l);let c=yield*o.normalizeExcalidraw(l).pipe(U.xm_(fy));return yield*ig(c),yield*o.renderPng({excalidraw:c}).pipe(U.xm_(fy)),{diagram:yield*a.replaceWithDetached(i,new TextEncoder().encode(nA(c)),n.observed.manifest.revision),sourceIdentity:"unverified"}}),fw=`Sketchi CLI contracts for agents and automation.
51
+ ${o}${s}ERRORS${a}`),t))for(let t of e)r.push(` ${t.message}${a}`);return r.join("\n")},formatVersion:(e,t)=>`${i.bold(e)} ${i.dim("v")}${i.bold(t)}`}},oR=e=>e.replace(/\u001B\[[0-9;]*m/g,"").length,oj=(e,t)=>{let r=Math.max(...e.map(e=>oR(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-oR(e)),e+" ".repeat(r)}${t}`}).join("\n")},oD=(e,t)=>t?`${e}, ${t}`:e,oL=(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),a=`${n} ${i}`,s=e.required?"":t.dim(" (optional)");return{left:a,right:K.getOrElse(e.description,()=>"")+s}});r.push(oj(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:K.getOrElse(e.description,()=>"")}});r.push(oj(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:K.getOrElse(e.description,()=>"")}});r.push(oj(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(oj(n.commands.map(e=>({left:t.cyan(oD(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(oj(i.commands.map(e=>({left:t.cyan(oD(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 a of e.examples)a.description?(n||r.push(""),r.push(` ${t.dim(`# ${a.description}`)}`)):i&&r.push(""),r.push(` ${t.cyan(a.command)}`),n=!1,i=!!a.description;r.push("")}return""===r[r.length-1]&&r.pop(),r.join("\n")},oU=e=>e.replace(/[^a-zA-Z0-9_]/g,"_"),oF=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},oB=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") )'}},oW=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}},oq=(e,t,r)=>{let n=[...t,e.name],i=`_${n.map(oU).join("_")}`;r.push(`${i}()`),r.push("{"),r.push(" local cur prev words cword"),r.push(" _init_completion || return"),r.push("");let a=e.flags.filter(e=>"Boolean"!==e.type._tag);if(a.length>0){for(let e of(r.push(" # Flag value completions"),r.push(' case "$prev" in'),a)){let t=[`--${e.name}`];for(let r of e.aliases)t.push(1===r.length?`-${r}`:`--${r}`);let n=oB(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(oU).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 oF(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(oF).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 s=e.arguments.filter(e=>void 0!==oW(e.type));if(s.length>0)for(let e of(r.push(" # Positional argument completions"),s)){let t=oW(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))oq(t,n,r)},oY=e=>e.replace(/'/g,"\\'"),oz=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(" ")}`},oX=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 '${oY(e.description)}'`);let r=oJ(e.type);return r&&t.push(r),t},oJ=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"}},oG=e=>{switch(e._tag){case"Choice":return`-r -f -a '${e.values.join(" ")}'`;case"Path":return"-r -F";default:return}},oV=(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)),a=i?`-n '${i}'`:"";if(!t.arguments.some(e=>"Path"===e.type._tag)){let t=[`complete -c ${e}`];a&&t.push(a),t.push("-f"),n.push(t.join(" "))}for(let r of t.subcommands){let t=[`complete -c ${e}`];a&&t.push(a),t.push(`-f -a '${oY(r.name)}'`),r.description&&t.push(`-d '${oY(r.description)}'`),n.push(t.join(" "))}for(let r of t.flags){let t="Boolean"===r.type._tag,a=t?i?`${i}; and ${oz(r)}`:oz(r):i,s=a?`-n '${a}'`:"",o=[`complete -c ${e}`];if(s&&o.push(s),o.push(...oX(r)),n.push(o.join(" ")),t){let t=[`complete -c ${e}`];s&&t.push(s),t.push(`-l no-${r.name}`),r.description&&t.push(`-d '${oY(`Disable ${r.name}`)}'`),n.push(t.join(" "))}}if(t.flags.length>0){let r='not string match -q -- "-*" (commandline -ct)',a=i?`${i}; and ${r}`:r;for(let r of t.flags){let t=`${a}; and ${oz(r)}`,i="Boolean"===r.type._tag,s=[`complete -c ${e}`];if(s.push(`-n '${t}'`),s.push(`-f -a '--${r.name}'`),r.description&&s.push(`-d '${oY(r.description)}'`),n.push(s.join(" ")),i){let i=[`complete -c ${e}`];i.push(`-n '${t}'`),i.push(`-f -a '--no-${r.name}'`),r.description&&i.push(`-d '${oY(`Disable ${r.name}`)}'`),n.push(i.join(" "))}}}for(let r of t.arguments){let t=oG(r.type);if(t){let i=[`complete -c ${e}`];a&&i.push(a),i.push(t),r.description&&i.push(`-d '${oY(r.description)}'`),n.push(i.join(" "))}}for(let i of t.subcommands)oV(e,i,[...r,i.name],n)},oK=e=>e.replace(/\\/g,"\\\\").replace(/'/g,"'\\''").replace(/:/g,"\\:"),oH=e=>e.replace(/[^a-zA-Z0-9_]/g,"_"),oQ=e=>{let t=[],r=e.description?`[${oK(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 a of(t.push(`'${i}--${e.name}${r}${n}'`),e.aliases)){let e=1===a.length?"-":"--";t.push(`'${i}${e}${a}${r}${n}'`)}if("Boolean"===e.type._tag){let r=e.description?`[${oK(`Disable ${e.name}`)}]`:"";t.push(`'${i}--no-${e.name}${r}'`)}return t},oZ=e=>{let t=e.description?oK(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}'`},o0=(e,t,r)=>{let n=[...t,e.name],i=`_${n.map(oH).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?oK(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 oQ(t))r.push(` ${e}`);for(let t of e.arguments)r.push(` ${oZ(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(oH).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(...oQ(r));for(let r of e.arguments)t.push(oZ(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))o0(t,n,r)},o1=e=>oc({name:e,primitiveType:oe,kind:"flag"}),o2=(e,t)=>od("flag",e,t.map(e=>[e,e])),o5=(0,B.XY)(2,(e,t)=>oh(e,t)),o3=(0,B.XY)(2,(e,t)=>op(e,t)),o8=(0,B.XY)(2,(e,t)=>o_(e,t)),o6=e=>ob(e),o9=(0,B.XY)(2,(e,t)=>om(e,t)),o4=(0,B.XY)(3,(e,t,r)=>ox(e,t,r)),o7="~effect/cli/Command/Config/Internal",le=e=>{let t=[],r=[],n=[];return{[o7]:o7,flags:r,arguments:n,orderedParams:t,tree:function e(i){let a={};for(let s in i)a[s]=function i(a){if(Array.isArray(a))return{_tag:"Array",children:a.map(e=>i(e))};if(!el.i5(a,oa))return{_tag:"Nested",tree:e(a)};{let e=t.length;return t.push(a),"argument"===a.kind?n.push(a):r.push(a),{_tag:"Param",index:e}}}(i[s]);return a}(e)}},lt=le({}),lr=(e,t)=>{switch(e._tag){case"Param":return{_tag:"Param",index:e.index+t};case"Array":return{_tag:"Array",children:e.children.map(e=>lr(e,t))};case"Nested":return{_tag:"Nested",tree:ln(e.tree,t)}}},ln=(e,t)=>{let r={};for(let n in e)r[n]=lr(e[n],t);return r},li=(e,t)=>{let r=e.orderedParams.length;return{[o7]:o7,flags:[...e.flags,...t.flags],arguments:[...e.arguments,...t.arguments],orderedParams:[...e.orderedParams,...t.orderedParams],tree:{...e.tree,...ln(t.tree,r)}}},la=(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 la(r.tree,t)}}(e[n]);return r},ls="~effect/cli/Command",lo=e=>e,ll={...tC.b({label:"Command",evaluate(){return lo(this).service}})},lc=e=>{let t=e.config,r=e.contextConfig??lt,n=e.service??Z.kl(`${ls}/${e.name}`),i=e.annotations??Z.Ie(),a=e.globalFlags??[],s=e.subcommands??[],o=e.parse??lf(t),l=e.parseContext??lf(r);return Object.assign(Object.create(ll),{[ls]:ls,name:e.name,examples:e.examples??[],annotations:i,globalFlags:a,subcommands:s,hidden:e.hidden??!1,config:t,contextConfig:r,service:n,parse:o,parseContext:l,handle:(t,r)=>el.EA(e.handle)?e.handle(t,r):U.fJG(new sG({commandPath:r,errors:[]})),buildHelpDoc:r=>{let n=[],a=[];for(let e of t.arguments){let t=oC(e),r=oA(e);for(let e of t)n.push({name:e.name,type:e.typeName??on(e.primitiveType),description:e.description,required:!r.isOptional,variadic:r.isVariadic})}let o=r.length>0?r.join(" "):e.name;for(let e of(s.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 oC(e))t.hidden||a.push(lu(t));let l=[];for(let e of s){let t=e.commands.filter(e=>!e.hidden);0!==t.length&&l.push({group:e.group,commands:V.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:a,annotations:i,...n.length>0&&{args:n},...l.length>0&&{subcommands:l},...c.length>0&&{examples:c}}},...el.EA(e.description)?{description:e.description}:{},...el.EA(e.shortDescription)?{shortDescription:e.shortDescription}:{},...el.EA(e.alias)?{alias:e.alias}:{}})},lu=e=>{let t=e.aliases.map(e=>1===e.length?`-${e}`:`--${e}`);return{name:e.name,aliases:t,type:e.typeName??on(e.primitiveType),description:ld(e.description,oi(e.primitiveType)),required:"Boolean"!==e.primitiveType._tag}},ld=(e,t)=>{if(void 0===t||0===t.length)return e;let r=`(choices: ${t.join(", ")})`;return K.match(e,{onNone:()=>K.some(r),onSome:e=>K.some(`${e} ${r}`)})},lf=e=>U.D9k(function*(t){let r={flags:t.flags,arguments:t.arguments},n=yield*lh(r,e.orderedParams);return la(e.tree,n)}),lh=U.D9k(function*(e,t){let r=[],n=e.arguments;for(let i of t){let[t,a]=yield*i.parse({flags:e.flags,arguments:n});r.push(a),n=t}return r}),lp=(e,t,r)=>{let n=lo(e),i=new Set;for(let e of(r?.contextConfig??n.contextConfig).flags)for(let t of oC(e))i.add(t.name);for(let r of t)for(let t of lo(r).config.flags)for(let n of oC(t))if(i.has(n.name))throw new sB({option:n.name,parentCommand:e.name,childCommand:r.name})},lm=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:oi(e.primitiveType)??[]};case"Path":{let t=e.typeName;return{_tag:"Path",pathType:"file"===t?"file":"directory"===t?"directory":"either"}}default:return{_tag:"String"}}},lg=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:oi(e.primitiveType)??[]};case"Path":{let t=e.typeName;return{_tag:"Path",pathType:"file"===t?"file":"directory"===t?"directory":"either"}}default:return{_tag:"String"}}},ly=e=>{let t=lo(e).config,r=[];for(let e of t.flags)for(let t of oC(e))"flag"===t.kind&&(t.hidden||r.push({name:t.name,aliases:t.aliases,description:K.getOrUndefined(t.description),type:lm(t)}));let n=[];for(let e of t.arguments){let t=oC(e),r=oA(e);for(let e of t)"argument"===e.kind&&n.push({name:e.name,description:K.getOrUndefined(e.description),required:!r.isOptional,variadic:r.isVariadic,type:lg(e)})}let i=[];for(let t of e.subcommands)for(let e of t.commands)e.hidden||i.push(ly(e));return{name:e.name,description:e.shortDescription??e.description,flags:r,arguments:n,subcommands:i}},lb=e=>{let t=new Set,r=[];for(let n of e)t.has(n)||(t.add(n),r.push(n));return r},lv=(e,t)=>{let r=[e],n=e;for(let e=1;e<t.length;e++){let i,a=t[e];for(let e of n.subcommands)if(i=e.commands.find(e=>e.name===a))break;if(!i)break;r.push(i),n=i}return r},lw=(e,t,r)=>lb([...r,...lv(e,t).flatMap(e=>lo(e).globalFlags)]),lx=(e,t,r)=>U.JkU(function*(){let n=lv(e,t),i=lo(n.length>0?n[n.length-1]:e).buildHelpDoc(t),a=((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 lo(t).contextConfig.flags)for(let t of oC(e))!r.has(t.name)&&(t.hidden||(r.add(t.name),n.push(lu(t))));return n})(n,i.flags),s=lw(e,t,r),o=[];for(let e of s)for(let t of oC(e.flag))t.hidden||o.push({...lu(t),required:!1});return{...i,flags:[...a,...i.flags],globalFlags:o}}),l_=e=>({_tag:"Action",flag:e.flag,run:e.run}),lk=0,lS=l_({flag:o1("help").pipe(o5("h"),o3("Show help information")),run:U.D9k(function*(e,{builtIns:t,command:r,commandPath:n}){let i=yield*oN,a=yield*lx(r,n,t);yield*sL(i.formatHelpDoc(a))})}),lI=l_({flag:o1("version").pipe(o5("v"),o3("Show version information")),run:U.D9k(function*(e,{command:t,version:r}){let n=yield*oN;yield*sL(n.formatVersion(t.name,r))})}),lE=l_({flag:o1("wizard").pipe(o3("Start wizard mode for a command")),run:()=>U.rIH}),l$=l_({flag:o2("completions",["bash","zsh","fish","sh"]).pipe(o6,o9(e=>K.map(e,e=>"sh"===e?"bash":e)),o8("<bash|zsh|fish|sh>"),o3("Print shell completion script")),run:U.D9k(function*(e,{command:t}){if(K.isNone(e))return;let r=ly(t);yield*sL(((e,t,r)=>{switch(t){case"bash":let n=[],i=oU(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(""),oq(r,[],n),n.push(`complete -F _${i} ${e.replace(/'/g,"'\\''")}`),n.push(`###-end-${e.replace(/'/g,"'\\''")}-completions-###`),n.join("\n");case"zsh":let a,s;return a=[],s=oH(e),a.push(`#compdef ${e}`),a.push(`###-begin-${e}-completions-###`),a.push("#"),a.push("# Static completion script for Zsh"),a.push("#"),a.push("# Installation:"),a.push(`# ${e} --completions zsh > ~/.zsh/completions/_${e}`),a.push("# then add ~/.zsh/completions to your fpath"),a.push("#"),a.push(""),o0(r,[],a),a.push("# Handle both direct invocation and autoload"),a.push('if [[ "${zsh_eval_context[-1]}" == "loadautofunc" ]]; then'),a.push(` _${s} "$@"`),a.push("else"),a.push(` compdef _${s} ${e}`),a.push("fi"),a.push(`###-end-${e}-completions-###`),a.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(""),oV(e,r,[],o),o.push(""),o.push(`###-end-${e}-completions-###`),o.join("\n")}})(t.name,e.value,r))})}),lO=(A="log-level",e=>(lk+=1,Object.assign(Z.kl(`effect/unstable/cli/GlobalFlag/${A}/${lk}`),{_tag:"Setting",id:A,flag:e.flag})))({flag:od("flag","log-level",[["all","All"],["trace","Trace"],["debug","Debug"],["info","Info"],["warn","Warn"],["warning","Warn"],["error","Error"],["fatal","Fatal"],["none","None"]]).pipe(o6,o3("Sets the minimum log level"),o8("<all|trace|debug|info|warn|warning|error|fatal|none>"))}),lC=[lS,lI,lE,l$,lO];class lT extends Z.Or("effect/unstable/cli/CliConfig",{defaultValue:()=>lA}){}let lA={builtIns:lC},lM=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},lN=(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 a=1;a<=r;a++)for(let r=1;r<=n;r++){let n=+(e[a-1]!==t[r-1]);i[a][r]=Math.min(i[a-1][r]+1,i[a][r-1]+1,i[a-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)},lP=e=>K.match(e.subcommand,{onNone:()=>[],onSome:e=>[e.name,...lP(e.parsedInput)]}),lR=(e,t,r=[])=>U.JkU(function*(){let{tokens:n,trailingOperands:i}=e,a=[...r,t.name],s=lo(t),o=s.config.flags.flatMap(oC).filter(ol),l=lD(o),c=s.contextConfig.flags.flatMap(oC).filter(ol),u=lD(c),d=new Set(c.map(e=>e.name)),f=lQ(n,{command:t,commandPath:a,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:K.none(),...f.errors.length>0&&{errors:f.errors}};let h={tokens:f.childTokens,trailingOperands:[]},p=yield*lR(h,f.sub,a),m=[...f.errors,...p.errors??[]];return{flags:f.flags,arguments:i,subcommand:K.some({name:f.sub.name,parsedInput:p}),...m.length>0&&{errors:m}}}),lj=e=>{let t=0;return{peek:()=>e[t],take:()=>e[t++],rest:()=>e.slice(t)}},lD=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}},lL=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},lU=e=>Object.fromEntries(e.map(e=>[e.name,[]])),lF=e=>"LongOption"===e._tag||"ShortOption"===e._tag,lB=e=>"LongOption"===e._tag?e.name:e.flag,lW=(e,t)=>{let r=lB(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&&s9(n.primitiveType))return{param:n,negated:!0}}if(n)return{param:n,negated:!1}},lq=(e,t,r)=>new sY({option:t.name,value:r,expected:`omit the value and use ${e.raw} by itself to set --${t.name} to false`,kind:"flag"}),lY=e=>e?._tag==="Value"&&(s8(e.value)||s6(e.value))?e.value:void 0,lz=(e,t,r,n=!1)=>{let i=lX(e,t,r,n);switch(i._tag){case"Value":return{_tag:"Value",value:i.value};case"Error":return{_tag:"Error",error:i.error}}},lX=(e,t,r,n=!1)=>{let i;if(n){if(void 0!==t.value)return{_tag:"Error",error:lq(t,r,t.value),tokens:[]};let n=lY(e.peek());if(void 0!==n){let i=e.take();return{_tag:"Error",error:lq(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(s9(r.primitiveType)){let t=lY(e.peek()),r=void 0!==t?e.take():void 0;return{_tag:"Value",value:t??"true",tokens:void 0===r?[]:[r]}}let a=e.peek();if(a?._tag==="Value"){let t=e.take();return{_tag:"Value",value:a.value,tokens:void 0===t?[]:[t]}}return{_tag:"Error",error:(i=oi(r.primitiveType),new sY({option:r.name,value:"",expected:void 0===i?r.typeName??on(r.primitiveType):i.join(" | "),kind:"flag"})),tokens:[]}},lJ=(e,t)=>{for(let r of t){let t=lW(e,r);if(void 0!==t)return t}},lG=(e,t,r,n)=>{e.push(r);let i=lX(t,r,n.param,n.negated);e.push(...i.tokens)},lV=(e,t,r,n,i)=>{let a=lj(t);lX(a,e,r.param,r.negated);for(let e=a.take();e;e=a.take()){if(lF(e)){let t=lJ(e,i);void 0!==t&&lX(a,e,t.param,t.negated);continue}if("Value"===e._tag)return n.has(e.value)}return!1},lK=(e,t,r,n)=>{let{commandPath:i,flagRegistry:a}=r,s=lW(e,a);if(!s)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),s9(e.primitiveType)&&i.push(`no-${e.name}`),e.aliases))i.push(t);return new sF({option:n,suggestions:lN(lB(e),i).map(e=>1===e.length?`-${e}`:`--${e}`),command:r})})(e,a.params,i));let o=lz(t,e,s.param,s.negated);"Error"===o._tag?n.errors.push(o.error):n.flags.add(s.param.name,o.value)},lH=(e,t,r,n)=>{if("AwaitingFirstValue"===n.mode._tag){let i=((e,t,r,n)=>{let{command:i,commandPath:a,inheritedFlagRegistry:s,localFlagNames:o}=r,l=lL(i.subcommands),c=l.get(e);if(c){let e=[...a,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 sF({option:`--${t}`,suggestions:[],command:e}))}let i=((e,t)=>{let r=lU(t.params),n=[],i=[],a=lj(e);for(let e=a.take();e;e=a.take()){if(!lF(e)){n.push(e);continue}let s=lW(e,t);if(!s){n.push(e);continue}let o=lz(a,e,s.param,s.negated);if("Error"===o._tag){i.push(o.error);continue}void 0!==o.value&&r[s.param.name].push(o.value)}return{flagMap:r,remainder:n,errors:i}})(t.rest(),s);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(!(lo(i).config.arguments.length>0)&&l.size>0){let t=[];for(let[e,r]of l)r.hidden||t.push(e);let r=lN(e,t);n.errors.push(new sz({subcommand:e,parent:a,suggestions:r}))}return{_tag:"Argument"}})(e,t,r,n);if("Subcommand"===i._tag)return i.result;n.mode={_tag:"CollectingArguments"}}n.arguments.push(e)},lQ=(e,t)=>{let r,n=lj(e),i={flags:(r=lU(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(lF(e)){lK(e,n,t,i);continue}if("Value"===e._tag){let r=lH(e.value,n,t,i);if(r)return r}}return{_tag:"Leaf",flags:i.flags.snapshot(),arguments:i.arguments,errors:i.errors}};var lZ=n(8036),l0=n(4450);let l1=new WeakMap,l2="~effect/data/Redacted",l5=(e,t)=>{let r=Object.create(l3);return t?.label&&(r.label=t.label),l1.set(r,e),r},l3={[l2]:{_A:e=>e},label:void 0,...eu.fU,toJSON(){return this.toString()},toString(){return`<redacted${(0,el.Kg)(this.label)?":"+this.label:""}>`},[l0.HR](){return l0.tW(l1.get(this))},[lZ.HR](e){return(0,el.i5)(e,l2)&&lZ.aI(l1.get(this),l1.get(e))}},l8=e=>{if(l1.has(e))return l1.get(e);throw Error("Unable to get redacted value"+(e.label?` with label: "${e.label}"`:""))};var l6=n(1044),l9=n(6364);el.Et,l9.wN,l6.wN;let l4=(0,B.XY)(2,(e,t)=>{let r=Math.pow(10,t);return Math.round(e*r)/r}),l7=(e,...t)=>{let r=t.flat();return`${r.join("")}${e}`},ce={arrowUp:"↑",arrowDown:"↓",arrowLeft:"←",arrowRight:"→",radioOn:"◉",radioOff:"◯",checkboxOn:"☒",checkboxOff:"☐",tick:"✔",cross:"✖",ellipsis:"…",pointerSmall:"›",line:"─",pointer:"❯"},ct={arrowUp:ce.arrowUp,arrowDown:ce.arrowDown,arrowLeft:ce.arrowLeft,arrowRight:ce.arrowRight,radioOn:"(*)",radioOff:"( )",checkboxOn:"[*]",checkboxOff:"[ ]",tick:"√",cross:"×",ellipsis:"...",pointerSmall:"»",line:"─",pointer:">"},cr=U.TjK(U.OH5(()=>"win32"===process.platform),e=>e?ct:ce),cn=e=>l7(e,"\x1b[1m"),ci=e=>l7(e,((...e)=>e)("\x1b[3m","\x1b[31m")),ca=e=>{let t={initial:!1,...e,label:{confirm:"yes",deny:"no",...e.label},placeholder:{defaultConfirm:"(Y/n)",defaultDeny:"(y/N)",...e.placeholder}};return cs({value:t.initial},{render:cI(t),process:e=>cO(e,t.initial),clear:cx(t)})},cs=(e,...t)=>{let[r,n]=1===t.length?[void 0,t[0]]:[t[0],t[1]],i=Object.create(cp);return i._tag="Loop",i.initialState=e,i.render=n.render,i.process=n.process,i.clear=n.clear,i.events=r,i},co=(0,B.XY)(2,(e,t)=>{let r=Object.create(cp);return r._tag="OnSuccess",r.prompt=e,r.onSuccess=t,r}),cl=e=>{let t={default:0,min:-1/0,max:1/0,incrementBy:1,decrementBy:1,validate:e=>e<t.min?U.fJG(`${e} must be greater than or equal to ${t.min}`):e>t.max?U.fJG(`${e} must be less than or equal to ${t.max}`):U.PyW(e),...e},r=void 0===e.default?"":`${t.default}`;return cs({cursor:r.length,value:r,error:K.none()},{render:c1(t),process:c2(t),clear:cG(t)})},cc=(0,B.XY)(2,(e,t)=>co(e,e=>cf(t(e)))),cu=U.D9k(function*(e){let t=yield*na,r=yield*t.readInput;return yield*cm(e,t,r)},U.xm_(()=>new ni({})),U.P1j),cd=e=>{let t={maxPerPage:10,...e};return cs((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:c7(t),process:ut(t),clear:ue(t)})},cf=e=>{let t=Object.create(cp);return t._tag="Succeed",t.value=e,t},ch=e=>{let t={initial:!1,active:"on",inactive:"off",...e};return cs(t.initial,{render:uy(t),process:ub,clear:()=>uu(t)})},cp={...tC.b({label:"Prompt",evaluate(){return cu(this)}}),"~effect/cli/Prompt":{_Output:e=>e}},cm=(e,t,r)=>U.DYE(()=>{switch(e._tag){case"Loop":return cg(e,t,r);case"OnSuccess":return U.qIB(cm(e.prompt,t,r),n=>cm(e.onSuccess(n),t,r));case"Succeed":return U.PyW(e.value)}}),cg=U.D9k(function*(e,t,r){let n=U.yw5(e.initialState)?yield*e.initialState:e.initialState,i=cy.NextFrame({state:n});for(;;){let a=yield*e.render(n,i);if(yield*U.QgK(t.display(a)),e.events){let t=eO(r).pipe(U.TjK(e=>({_tag:"Input",input:e}))),a=yield*U.KT6(t,eO(e.events).pipe(U.TjK(e=>({_tag:"Event",value:e}))));i=yield*e.process(a,n)}else{let t=yield*eO(r);i=yield*e.process(t,n)}switch(i._tag){case"Beep":continue;case"NextFrame":yield*U.QgK(t.display((yield*e.clear(n,i)))),n=i.state;continue;case"Submit":{yield*U.QgK(t.display((yield*e.clear(n,i))));let r=yield*e.render(n,i);return yield*U.QgK(t.display(r)),i.value}}}},(e,t,r)=>U.yeE(e,U.QgK(r.display("\x1b[?25h")))),cy=ee.Ij(),cb=(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(cw))n+=1+Math.floor(Math.max(r.length-1,0)/t);var i=n;let a="";for(let e=0;e<i;e++)a+="\x1b[2K"+(e<i-1?"\x1b[1A":"");return i>0&&(a+="\x1b[G"),a},cv=(e,t,r)=>{if(void 0!==r&&r.length>0){let n;return((e=1)=>`\x1b[${e}B`)((n=r.split(cw),0===t?n.length:(0,B.Fs)(V.Tj(n,e=>Math.ceil(e.length/t)),V.TS(0,(e,t)=>e+t))))+cb(`
52
+ ${r}`,t)+cb(e,t)}return cb(e,t)},cw=/\r?\n/,cx=e=>U.D9k(function*(t,r){let n=yield*na,i=yield*n.columns,a=yield*cr;return cb(c_(t.value?e.placeholder.defaultConfirm:e.placeholder.defaultDeny,"?",a.pointerSmall,e,{plain:!0}),i)+"\x1b[2K\x1b[G"}),c_=(e,t,r,n,i)=>cX(e,n.message,t,r,i),ck=U.D9k(function*(e,t){let r=yield*cr,n=l7("?","\x1b[96m"),i=l7(r.pointerSmall,"\x1b[90m");return"\x1b[?25l"+c_(l7(e.value?t.placeholder.defaultConfirm:t.placeholder.defaultDeny,"\x1b[90m"),n,i,t)}),cS=U.D9k(function*(e,t){let r=yield*cr,n=l7(r.tick,"\x1b[32m"),i=l7(r.ellipsis,"\x1b[90m");return c_(e?t.label.confirm:t.label.deny,n,i,t)+"\n"}),cI=e=>(t,r)=>cy.$match(r,{Beep:()=>U.PyW("\x07"),NextFrame:({state:t})=>ck(t,e),Submit:({value:t})=>cS(t,e)}),cE=/^y|t$/,c$=/^n|f$/,cO=(e,t)=>{let r=K.getOrElse(e.input,()=>"");return"enter"===e.key.name||"return"===e.key.name?U.PyW(cy.Submit({value:t})):cE.test(r.toLowerCase())?U.PyW(cy.Submit({value:!0})):c$.test(r.toLowerCase())?U.PyW(cy.Submit({value:!1})):U.PyW(cy.Beep())},cC=(e,t=!1)=>V.TS(e.dateParts,"",(r,n,i)=>{let a=n.toString();return i!==e.cursor||t?r+a:r+l7(a,((...e)=>e)("\x1b[4m","\x1b[96m"))}),cT=(e,t,r,n,i)=>cX(r,n.message,e,t,i),cA=U.D9k(function*(e,t){let r=yield*cr;return"\x1b[?25l"+cT(l7("?","\x1b[96m"),l7(r.pointerSmall,"\x1b[90m"),cC(e),t)+((e,t)=>{if(K.isSome(e.error)){let r=e.error.value.split(cw);if(V.ET(r))return"\x1b[s\n"+(l7(t,"\x1b[31m")+" ")+V.Tj(r,e=>ci(e)).join("\n")+"\x1b[u"}return""})(e,r.pointerSmall)}),cM=U.D9k(function*(e,t){let r=yield*cr;return cT(l7(r.tick,"\x1b[32m"),l7(r.ellipsis,"\x1b[90m"),cC(e,!0),t)+"\n"}),cN={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"]},cP=/\\(.)|"((?:\\["\\]|[^"])+)"|(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,cR={1:({token:e,...t})=>new cD({token:e.replace(/\\(.)/g,"$1"),...t}),2:e=>new cW(e),3:e=>new cq(e),4:e=>new cY(e),5:e=>new cz(e),6:e=>new cB(e),7:e=>new cF(e),8:e=>new cU(e),9:e=>new cL(e)};class cj{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=K.getOrElse(V.g9(this.parts,e=>e===this),()=>0);return V.i8(this.parts.slice(e+1),e=>!e.isToken())}previousPart(){let e=V.g9(this.parts,e=>e===this);return K.isSome(e)?V.Uk(this.parts.slice(0,e.value),e=>!e.isToken()):K.none()}toString(){return String(this.date)}}class cD extends cj{increment(){}decrement(){}setValue(e){this.token=this.token+e}isToken(){return!0}toString(){return this.token}}class cL extends cj{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 cU extends cj{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 cF extends cj{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 cB extends cj{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 cW extends cj{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 cq extends cj{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 cY extends cj{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 cz extends cj{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 cX=(e,t,r,n,i)=>{let a=r+" ",s=i?.plain===!0?e=>e:cn;return V.YW(t.split(cw),{onEmpty:()=>a+" "+n+" "+e,onNonEmpty:t=>a+V.Tj(t,e=>s(e)).join("\n")+" "+n+" "+e})},cJ=(e,t,r)=>!e.disabled&&e.description&&t?r?.plain===!0?"- "+e.description:l7("- "+e.description,"\x1b[90m"):"",cG=e=>U.D9k(function*(t,r){let n=yield*na,i=yield*n.columns,a=yield*cr,s=cV(t,a.pointerSmall,{plain:!0});return cv(cK(t,"?",a.pointerSmall,e,{plain:!0}),i,s)+"\x1b[2K\x1b[G"}),cV=(e,t,r)=>K.isSome(e.error)?V.YW(e.error.value.split(cw),{onEmpty:()=>"",onNonEmpty:e=>r?.plain===!0?`${t} ${e.join("\n")}`:"\x1b[s\n"+(l7(t,"\x1b[31m")+" ")+V.Tj(e,e=>ci(e)).join("\n")+"\x1b[u"}):"",cK=(e,t,r,n,i,a=!1)=>{let s;return cX((s=""===e.value?"":`${e.value}`,a||i?.plain===!0?s:l7(s,K.isSome(e.error)?"\x1b[31m":((...e)=>e)("\x1b[4m","\x1b[96m"))),n.message,t,r,i)},cH=U.D9k(function*(e,t){let r=yield*cr,n=l7("?","\x1b[96m"),i=l7(r.pointerSmall,"\x1b[90m"),a=cV(e,r.pointerSmall);return cK(e,n,i,t)+a}),cQ=U.D9k(function*(e,t){let r=yield*cr;return cK(e,l7(r.tick,"\x1b[32m"),l7(r.ellipsis,"\x1b[90m"),t,void 0,!0)+"\n"}),cZ=e=>{if(e.value.length<=0)return U.PyW(cy.Beep());let t=e.value.slice(0,e.value.length-1);return U.PyW(cy.NextFrame({state:{...e,value:t,error:K.none()}}))},c0=e=>U.PyW(cy.NextFrame({state:{...e,cursor:0,value:"",error:K.none()}})),c1=e=>(t,r)=>cy.$match(r,{Beep:()=>U.PyW("\x07"),NextFrame:({state:t})=>cH(t,e),Submit:()=>cQ(t,e)}),c2=e=>(t,r)=>{if(t.key.ctrl&&"u"===t.key.name)return c0(r);switch(t.key.name){case"backspace":return cZ(r);case"k":case"up":return U.PyW(cy.NextFrame({state:{...r,value:""===r.value||"-"===r.value?`${e.incrementBy}`:`${Number.parseInt(r.value)+e.incrementBy}`,error:K.none()}}));case"j":case"down":return U.PyW(cy.NextFrame({state:{...r,value:""===r.value||"-"===r.value?`-${e.decrementBy}`:`${Number.parseInt(r.value)-e.decrementBy}`,error:K.none()}}));case"enter":case"return":{let t=Number.parseInt(r.value);if(Number.isNaN(t))return U.PyW(cy.NextFrame({state:{...r,error:K.some("Must provide an integer value")}}));return U.YWq(e.validate(t),{onFailure:e=>cy.NextFrame({state:{...r,error:K.some(e)}}),onSuccess:e=>cy.Submit({value:e})})}default:var n=K.getOrElse(t.input,()=>"");if(0===r.value.length&&"-"===n)return U.PyW(cy.NextFrame({state:{...r,value:"-",error:K.none()}}));let i=Number.parseInt(r.value+n);return Number.isNaN(i)?U.PyW(cy.Beep()):U.PyW(cy.NextFrame({state:{...r,value:`${i}`,error:K.none()}}))}},c5=(e,t,r,n)=>cX("",r.message,e,t,n),c3=(e,t,r,n,i,a)=>{let s=" ";if(n===r.startIndex&&r.startIndex>0?s=i.arrowUp:n===r.endIndex-1&&r.endIndex<t.length&&(s=i.arrowDown),a?.plain===!0)return e===n?i.pointer+s:s+" ";if(t[n].disabled){let t=((...e)=>e)("\x1b[1m","\x1b[90m");return e===n?l7(i.pointer,t)+s:s+" "}return e===n?l7(i.pointer,"\x1b[96m")+s:s+" "},c8=(e,t,r)=>{if(r?.plain===!0)return e.title;let n=e.title;return t?e.disabled?l7(n,((...e)=>e)("\x1b[4m","\x1b[90m")):l7(n,((...e)=>e)("\x1b[4m","\x1b[96m")):e.disabled?l7(n,((...e)=>e)("\x1b[9m","\x1b[90m")):n},c6=(e,t,r,n)=>{let i=t.choices,a=uv(e,i.length,t.maxPerPage),s=[];for(let t=a.startIndex;t<a.endIndex;t++){let o=i[t],l=e===t,c=c3(e,i,a,t,r,n),u=c8(o,l,n),d=cJ(o,l,n);s.push(c+u+" "+d)}return s.join("\n")},c9=U.D9k(function*(e,t){let r=yield*cr,n=c6(e,t,r);return"\x1b[?25l"+c5(l7("?","\x1b[96m"),l7(r.pointerSmall,"\x1b[90m"),t)+"\n"+n}),c4=U.D9k(function*(e,t){let r=yield*cr,n=t.choices[e].title;return c5(l7(r.tick,"\x1b[32m"),l7(r.ellipsis,"\x1b[90m"),t)+" "+l7(n,"\x1b[37m")+"\n"}),c7=e=>(t,r)=>cy.$match(r,{Beep:()=>U.PyW("\x07"),NextFrame:({state:t})=>c9(t,e),Submit:()=>c4(t,e)}),ue=e=>U.D9k(function*(t,r){let n=yield*na,i=yield*n.columns,a=yield*cr,s=c5("?",a.pointerSmall,e,{plain:!0}),o=c6(t,e,a,{plain:!0});return cb(`${s}
53
+ ${o}`,i)+"\x1b[2K\x1b[G"}),ut=e=>(t,r)=>{var n;switch(t.key.name){case"k":case"up":return n=e.choices,0===r?U.PyW(cy.NextFrame({state:n.length-1})):U.PyW(cy.NextFrame({state:r-1}));case"j":case"down":return r===e.choices.length-1?U.PyW(cy.NextFrame({state:0})):U.PyW(cy.NextFrame({state:r+1}));case"tab":let i;return i=e.choices,U.PyW(cy.NextFrame({state:(r+1)%i.length}));case"enter":case"return":{let t=e.choices[r];if(t.disabled)return U.PyW(cy.Beep());return U.PyW(cy.Submit({value:t.value}))}default:return U.PyW(cy.Beep())}},ur=U.D9k(function*(e,t){let r=yield*na,n=yield*r.columns,i=yield*cr,a=un(e,i.pointerSmall,{plain:!0});return cv(ui(e,"?",i.pointerSmall,t,{plain:!0}),n,a)+"\x1b[2K\x1b[G"}),un=(e,t,r)=>K.isSome(e.error)?V.YW(e.error.value.split(cw),{onEmpty:()=>"",onNonEmpty:e=>r?.plain===!0?`${t} ${e.join("\n")}`:"\x1b[s\n"+(l7(t,"\x1b[31m")+" ")+V.Tj(e,e=>ci(e)).join("\n")+"\x1b[u"}):"",ui=(e,t,r,n,i,a=!1)=>cX(((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 a=K.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 l7("*".repeat(i.length),a);case"text":return l7(i,a)}})(e,n,a,i),n.message,t,r,i),ua=U.D9k(function*(e,t){let r=yield*cr;return ui(e,l7("?","\x1b[96m"),l7(r.pointerSmall,"\x1b[90m"),t)+un(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)}),us=U.D9k(function*(e,t){let r=yield*cr;return ui(e,l7(r.tick,"\x1b[32m"),l7(r.ellipsis,"\x1b[90m"),t,void 0,!0)+"\n"}),uo=e=>U.PyW(cy.NextFrame({state:{...e,cursor:0,error:K.none()}})),ul=e=>U.PyW(cy.NextFrame({state:{...e,cursor:e.value.length,error:K.none()}})),uc=(e,t)=>{let r={default:"",type:t,validate:U.PyW,...e};return cs({cursor:r.default.length,value:r.default,error:K.none()},{render:(e,t)=>cy.$match(t,{Beep:()=>U.PyW("\x07"),NextFrame:({state:e})=>ua(e,r),Submit:()=>us(e,r)}),process:(e,t)=>{if(e.key.ctrl)switch(e.key.name){case"u":return U.PyW(cy.NextFrame({state:{...t,cursor:0,value:"",error:K.none()}}));case"a":return uo(t);case"e":return ul(t);default:return U.PyW(cy.Beep())}switch(e.key.name){case"backspace":var n;if(t.cursor<=0)return U.PyW(cy.Beep());let i=t.value.slice(0,t.cursor-1),a=t.value.slice(t.cursor),s=t.cursor-1,o=`${i}${a}`;return U.PyW(cy.NextFrame({state:{...t,cursor:s,value:o,error:K.none()}}));case"left":if(t.cursor<=0)return U.PyW(cy.Beep());let l=t.cursor-1;return U.PyW(cy.NextFrame({state:{...t,cursor:l,error:K.none()}}));case"right":if(t.cursor>=t.value.length)return U.PyW(cy.Beep());let c=Math.min(t.cursor+1,t.value.length);return U.PyW(cy.NextFrame({state:{...t,cursor:c,error:K.none()}}));case"home":return uo(t);case"end":return ul(t);case"enter":case"return":{let e=t.value;return U.YWq(r.validate(e),{onFailure:r=>cy.NextFrame({state:{...t,value:e,error:K.some(r)}}),onSuccess:e=>cy.Submit({value:e})})}case"tab":if(t.value===r.default)return U.PyW(cy.Beep());let u=0===t.value.length?r.default:t.value;return U.PyW(cy.NextFrame({state:{...t,value:u,cursor:u.length,error:K.none()}}));default:let d,f,h,p;return n=K.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,U.PyW(cy.NextFrame({state:{...t,cursor:p,value:h,error:K.none()}}))}},clear:(e,t)=>ur(e,r)})},uu=U.D9k(function*(e){let t=yield*na,r=yield*t.columns,n=yield*cr;return cb(cX(`${e.active} / ${e.inactive}`,e.message,"?",n.pointerSmall,{plain:!0}),r)+"\x1b[2K\x1b[G"}),ud=(e,t,r=!1)=>{let n=l7("/","\x1b[90m"),i=((...e)=>e)("\x1b[4m",r?"\x1b[37m":"\x1b[96m"),a=e?t.inactive:l7(t.inactive,i);return(e?l7(t.active,i):t.active)+" "+n+" "+a},uf=(e,t,r,n)=>{let i=n.message.split(cw),a=t+" ";return V.ET(i)?a+V.Tj(i,e=>cn(e)).join("\n")+" "+r+" "+e:a+" "+r+" "+e},uh=U.D9k(function*(e,t){let r=yield*cr,n=l7("?","\x1b[96m"),i=l7(r.pointerSmall,"\x1b[90m");return"\x1b[?25l"+uf(ud(e,t),n,i,t)}),up=U.D9k(function*(e,t){let r=yield*cr,n=l7(r.tick,"\x1b[32m"),i=l7(r.ellipsis,"\x1b[90m");return uf(ud(e,t,!0),n,i,t)+"\n"}),um=U.PyW(cy.NextFrame({state:!0})),ug=U.PyW(cy.NextFrame({state:!1})),uy=e=>(t,r)=>{switch(r._tag){case"Beep":return U.PyW("\x07");case"NextFrame":return uh(t,e);case"Submit":return up(t,e)}},ub=(e,t)=>{switch(e.key.name){case"0":case"j":case"delete":case"right":case"down":return ug;case"1":case"k":case"left":case"up":return um;case" ":case"tab":return t?ug:um;case"enter":case"return":return U.PyW(cy.Submit({value:t}));default:return U.PyW(cy.Beep())}},uv=(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 a=Math.min(i+n,t);return{startIndex:i,endIndex:a}},uw=U.D9k(function*(e,t){let r=t?.commandPath??[e.name],n=ux(e,r),i=[...t?.prefix??r];return yield*uC(i),yield*u_(n,i,n===e?"ROOT":n.name),i}),ux=(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},u_=U.D9k(function*(e,t,r){let n=lo(e),i=e.subcommands.flatMap(e=>e.commands.filter(e=>!e.hidden)),a=0===i.length?n.config:n.contextConfig;if(a.flags.length>0){for(let e of(yield*sL(uT(r,"FLAGS")),a.flags))t.push(...yield*uS(e));(a.arguments.length>0||i.length>0)&&(yield*uC(t))}if(a.arguments.length>0){for(let e of(yield*sL(uT(r,"ARGUMENTS")),a.arguments))t.push(...yield*uS(e));i.length>0&&(yield*uC(t))}if(0===i.length)return;let s=yield*cu(cd({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*sL(),t.push(s.name),uk(s)&&(yield*uC(t)),yield*u_(s,t,s.name)}),uk=e=>e.subcommands.some(e=>e.commands.some(e=>!e.hidden))||lo(e).config.orderedParams.length>0,uS=U.D9k(function*(e){let t=oT(e),r=oA(e);if(r.isOptional&&!(yield*cu(ca({message:`Set ${u$(t)}?`,initial:!1}))))return yield*sL(),[];let n=r.isVariadic?yield*cu(cl({message:`${u$(t)} count`,default:K.getOrElse(r.variadicMin,()=>0),min:K.getOrElse(r.variadicMin,()=>0),...K.isSome(r.variadicMax)?{max:r.variadicMax.value}:{}})):1,i=[];for(let e=0;e<n;e++)i.push((yield*uI(t)));let a="flag"===t.kind?{flags:{[t.name]:i},arguments:[]}:{flags:{},arguments:i};return(yield*e.parse(a),yield*sL(),t.kind===os)?i:i.flatMap(e=>[`--${t.name}`,e])}),uI=e=>{var t,r;let n=uE(e);switch(e.primitiveType._tag){case"Boolean":return U.TjK(cu(ca({message:n,label:{confirm:"true",deny:"false"},placeholder:{defaultConfirm:"(T/f)",defaultDeny:"(t/F)"}})),String);case"Choice":return cu(cd({message:n,choices:(oi(e.primitiveType)??[]).map(e=>({title:e,value:e}))}));case"Date":let i,a,s,o,l,c;return U.TjK(cu((t={message:n},s=(a=((e,t,r)=>{let n=[],i=null;for(;i=cP.exec(e);){let e=i.shift(),a=i.findIndex(e=>void 0!==e);if(a in cR){let s=i[a]||e;n.push(cR[a]({token:s,date:t,parts:n,locales:r}))}else n.push(new cD({token:i[a]||e,date:t,parts:n,locales:r}))}let a=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},V.Ie());return n.splice(0,n.length,...a),n})((i={initial:new Date,dateMask:"YYYY-MM-DD HH:mm:ss",validate:U.PyW,...t,locales:{...cN,...t.locales}}).dateMask,i.initial,i.locales)).findIndex(e=>!e.isToken()),cs({dateParts:a,typed:"",cursor:s,value:i.initial,error:K.none()},{render:(o=i,(e,t)=>cy.$match(t,{Beep:()=>U.PyW("\x07"),NextFrame:({state:e})=>cA(e,o),Submit:()=>cM(e,o)})),process:(l=i,(e,t)=>{switch(e.key.name){case"left":let r;return U.PyW((r=t.dateParts[t.cursor].previousPart(),K.isSome(r)?cy.NextFrame({state:{...t,typed:"",cursor:t.dateParts.indexOf(r.value)}}):cy.Beep()));case"right":let n;return U.PyW((n=t.dateParts[t.cursor].nextPart(),K.isSome(n)?cy.NextFrame({state:{...t,typed:"",cursor:t.dateParts.indexOf(n.value)}}):cy.Beep()));case"k":case"up":return U.PyW((t.dateParts[t.cursor].increment(),cy.NextFrame({state:{...t,typed:""}})));case"j":case"down":return U.PyW((t.dateParts[t.cursor].decrement(),cy.NextFrame({state:{...t,typed:""}})));case"tab":let i,a;return U.PyW((i=t.dateParts[t.cursor].nextPart(),a=K.match(i,{onNone:()=>t.dateParts.findIndex(e=>!e.isToken()),onSome:e=>t.dateParts.indexOf(e)}),cy.NextFrame({state:{...t,cursor:a}})));case"enter":case"return":return U.YWq(l.validate(t.value),{onFailure:e=>cy.NextFrame({state:{...t,error:K.some(e)}}),onSuccess:e=>cy.Submit({value:e})});default:return U.PyW(((e,t)=>{if(/\d/.test(e)){let r=t.typed+e;return t.dateParts[t.cursor].setValue(r),cy.NextFrame({state:{...t,typed:r}})}return cy.Beep()})(K.getOrElse(e.input,()=>""),t))}}),clear:(c=i,U.D9k(function*(e,t){let r=yield*na,n=yield*r.columns,i=yield*cr,a=V.TS(e.dateParts,"",(e,t)=>e+t.toString());return cv(cT("?",i.pointerSmall,a,c,{plain:!0}),n,K.isSome(e.error)?V.YW(e.error.value.split(cw),{onEmpty:()=>"",onNonEmpty:e=>`${i.pointerSmall} ${e.join("\n")}`}):"")+"\x1b[2K\x1b[G"}))}))),e=>e.toISOString());case"Float":let u,d,f,h;return U.TjK(cu((u={default:0,min:-1/0,max:1/0,incrementBy:1,decrementBy:1,precision:2,validate:e=>e<u.min?U.fJG(`${e} must be greater than or equal to ${u.min}`):e>u.max?U.fJG(`${e} must be less than or equal to ${u.max}`):U.PyW(e),...r={message:n}},cs({cursor:(d=void 0===r.default?"":`${u.default}`).length,value:d,error:K.none()},{render:(f=u,(e,t)=>cy.$match(t,{Beep:()=>U.PyW("\x07"),NextFrame:({state:e})=>cH(e,f),Submit:()=>cQ(e,f)})),process:(h=u,(e,t)=>{if(e.key.ctrl&&"u"===e.key.name)return c0(t);switch(e.key.name){case"backspace":return cZ(t);case"k":case"up":return U.PyW(cy.NextFrame({state:{...t,value:""===t.value||"-"===t.value?`${h.incrementBy}`:`${Number.parseFloat(t.value)+h.incrementBy}`,error:K.none()}}));case"j":case"down":return U.PyW(cy.NextFrame({state:{...t,value:""===t.value||"-"===t.value?`-${h.decrementBy}`:`${Number.parseFloat(t.value)-h.decrementBy}`,error:K.none()}}));case"enter":case"return":{let e=Number.parseFloat(t.value);if(Number.isNaN(e))return U.PyW(cy.NextFrame({state:{...t,error:K.some("Must provide a floating point value")}}));return U.qIB(U.OH5(()=>l4(e,h.precision)),e=>U.YWq(h.validate(e),{onFailure:e=>cy.NextFrame({state:{...t,error:K.some(e)}}),onSuccess:e=>cy.Submit({value:e})}))}default:var r=K.getOrElse(e.input,()=>"");if("."===r&&t.value.includes("."))return U.PyW(cy.Beep());if(0===t.value.length&&"-"===r)return U.PyW(cy.NextFrame({state:{...t,value:"-",error:K.none()}}));let n=Number.parseFloat(t.value+r);return Number.isNaN(n)?U.PyW(cy.Beep()):U.PyW(cy.NextFrame({state:{...t,value:"."===r?`${n}.`:`${n}`,error:K.none()}}))}}),clear:cG(u)}))),String);case"Integer":return U.TjK(cu(cl({message:n})),String);case"Redacted":return U.TjK(cu(uc({message:n},"password").pipe(cc(l5))),l8);default:return cu(uc({message:n},"text"))}},uE=e=>u$(e),u$=e=>{let t=K.getOrUndefined(e.description)?.trim(),r="flag"===e.kind&&void 0!==t&&t.length<=32?t:uO(e.name);return"flag"===e.kind?`${r} (${"flag"===e.kind?`--${e.name}`:e.name})`:r},uO=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(" ")},uC=e=>sL(uP("Current command",e,"\x1b[35m")),uT=(e,t)=>`${l7(e.toUpperCase(),"\x1b[1m","\x1b[96m")} ${l7("·","\x1b[90m")} ${l7(t,"\x1b[1m","\x1b[37m")}`,uA=(e,t,r)=>[`${l7(e,"\x1b[1m","\x1b[96m")} ${l7(`v${t}`,"\x1b[37m")} ${l7("· Command wizard","\x1b[1m","\x1b[37m")}`,...void 0===r||0===r.length?[]:[r],l7("Build a command interactively. Press Ctrl+C to cancel.","\x1b[90m"),""].join("\n"),uM=e=>uP("Command ready",e,"\x1b[96m","\x1b[32m"),uN=()=>`
54
+ ${l7("Wizard cancelled.","\x1b[31m")}`,uP=(e,t,r,n="\x1b[37m")=>{let i=uR(t);return[l7(e,"\x1b[1m",n),...i.map(e=>l7(e,r)),""].join("\n")},uR=e=>{let t=" $ ",r=" ",n=e.map(uj),i=[],a=t;for(let e of n){let n=a===t||a===r?"":" ";a.length+n.length+e.length>88&&a!==t?(i.push(`${a} \\`),a=`${r}${e}`):a+=`${n}${e}`}return a!==t&&i.push(a),i},uj=e=>/^[A-Za-z0-9_./:@%+=,-]+$/.test(e)?e:`'${e.replaceAll("'","'\"'\"'")}'`,uD=e=>el.i5(e,ls),uL=(e,t,r)=>lc({name:e,config:le(t??{}),...el.EA(r)?{handle:r}:{}}),uU=(0,B.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(uD(t)){n(void 0,t);continue}for(let e of t.commands)n(t.group,e)}let i=[],a=r.get(void 0);for(let[e,t]of(a&&a.length>0&&i.push({group:void 0,commands:a}),r))void 0!==e&&i.push({group:e,commands:t});return{flat:t,groups:i}})(t);lp(e,r.flat);let n=lo(e),i=new Map(r.flat.map(e=>[e.name,lo(e)])),a=Symbol("effect/cli/SubcommandState"),s=U.D9k(function*(e){if(K.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),s=yield*t.parse(e.subcommand.value.parsedInput);return Object.assign({},r,{[a]:{name:t.name,result:s}})}),o=U.D9k(function*(e,t){let r=e[a];if(r){let a=i.get(r.name);return a?yield*a.handle(r.result,[...t,a.name]).pipe(U.PfK(n.service,e)):yield*new sG({commandPath:t,errors:[]})}return yield*n.handle(e,t)});return lc({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:s,parseContext:n.parseContext,handle:o})}),uF=(0,B.XY)(2,(e,t)=>{let r=lo(e),n=le(t),i=li(r.config,n),a=li(r.contextConfig,n);r.subcommands.length>0&&lp(e,r.subcommands.flatMap(e=>e.commands),{contextConfig:a});let s=lf(n),o=U.D9k(function*(e){return Object.assign({},(yield*r.parse(e)),(yield*s(e)))}),l=U.D9k(function*(e){return Object.assign({},(yield*r.parseContext(e)),(yield*s(e)))});return lc({name:r.name,config:i,contextConfig:a,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)})}),uB=(0,B.XY)(2,(e,t)=>lc({...lo(e),description:t})),uW=(0,B.XY)(2,(e,t)=>lc({...lo(e),shortDescription:t})),uq=(0,B.XY)(2,(e,t)=>lc({...lo(e),examples:t})),uY=(e,t)=>{let r=lo(e);return U.D9k(function*(n){let i,a,s,o,l,c,{builtIns:u}=yield*lT,{tokens:d,trailingOperands:f}=-1===(i=n.indexOf("--"))?{tokens:lM(n),trailingOperands:[]}:{tokens:lM(n.slice(0,i)),trailingOperands:n.slice(i+1)},h=lb([...u,...(a=[],(s=e=>{for(let t of lo(e).globalFlags)a.push(t);for(let t of e.subcommands)for(let e of t.commands)s(e)})(e),lb(a))]),p=lD(h.flatMap(e=>oC(e.flag)).filter(ol)),{flagMap:m,remainder:g,errors:y}=(o=lU(p.params),l=[],c=(e,t,r)=>{let n=lD(lo(t).config.flags.flatMap(oC).filter(ol)),i=lD(lo(t).contextConfig.flags.flatMap(oC).filter(ol)),a=lL(t.subcommands),s=lj(e),u=[],d=!0;for(let e=s.take();e;e=s.take()){if(lF(e)){let t=lJ(e,r);if(void 0!==t){lG(u,s,e,t);continue}let c=lW(e,i);if(void 0!==c){lG(u,s,e,c);continue}let f=lW(e,n),h=lW(e,p);if(void 0!==f&&(void 0===h||!d||!lV(e,s.rest(),f,a,[n,i,p]))){lG(u,s,e,f);continue}if(void 0!==h){let t=lX(s,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=a.get(e.value);if(void 0!==t)return u.push(e),u.push(...c(s.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*lR({tokens:g,trailingOperands:f},e),w=[e.name,...lP(v)],x={builtIns:u,command:e,commandPath:w,version:t.version},_=lw(e,w,u),k=((e,t,r,n)=>{let i=new Set(t),a=[],s=new Set;for(let t of e)if(!i.has(t))for(let e of oC(t.flag)){let t=r[e.name];if(!t||0===t.length)continue;let i=`--${e.name}`;s.has(i)||(s.add(i),a.push(new sF({option:i,suggestions:[],command:n})))}return a})(h,_,m,w);if(k.length>0||y.length>0){let e=v.errors??[];return yield*new sG({commandPath:w,errors:[...y,...k,...e]})}for(let r of _){if("Action"!==r._tag||!oC(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===lE)return yield*U.JkU(function*(){yield*sL(uA(e.name,t.version,e.description));let r=[e.name,...n.filter(e=>"--wizard"!==e&&!e.startsWith("--wizard="))],i=yield*uw(e,{commandPath:w,prefix:r});yield*sL(uM(i)),(yield*cu(ch({message:"Run this command?",initial:!0,active:"yes",inactive:"no"})))&&(yield*sL(),yield*uY(e,t)(i.slice(1)))}).pipe(U.KuX("QuitError",()=>sL(uN())));yield*r.run(i,x);return}if(v.errors&&v.errors.length>0)return yield*new sG({commandPath:w,errors:v.errors});let S=yield*U.Ket(r.parse(v));if("Failure"===S._tag)return yield*new sG({commandPath:w,errors:[S.failure]});let I=r.handle(S.success,[e.name]),E=_.includes(lO)?(yield*lO.flag.parse(b))[1]:K.none();for(let e of(I=U.PfK(I,lO,E),_)){if("Setting"!==e._tag||e===lO)continue;let[,t]=yield*e.flag.parse(b);I=U.PfK(I,e,t)}let $=K.match(E,{onNone:()=>Z.Ie(),onSome:e=>Z.L8(oM.zQ,e)});yield*U.PpN(I,$)},U.osR(e=>el.i5(e,sU)&&"ShowHelp"===e._tag?H.Py(e):H.fJ(e),t=>U.hgn(U.JkU(function*(){let{builtIns:r}=yield*lT,n=yield*oN,i=yield*lx(e,t.commandPath,r);yield*sL(n.formatHelpDoc(i)),t.errors.length>0&&(yield*sD(n.formatErrors(t.errors)))}),U.fJG(t))),U.osR(e=>el.i5(e,nn)?H.Py(e):H.fJ(e),e=>U.GaK))},uz=/(?:https:\/\/(?:www\.)?excalidraw\.com\/)?#json=[A-Za-z0-9_-]+,[A-Za-z0-9_-]{22,}/gu;function uX(e){return e.replace(uz,"[redacted-share-link]")}let uJ=(e=0)=>t=>`\u{1B}[${t+e}m`,uG=(e=0)=>t=>`\u{1B}[${38+e};5;${t}m`,uV=(e=0)=>(t,r,n)=>`\u{1B}[${38+e};2;${t};${r};${n}m`,uK=e=>`\u{1B}[58;5;${e<90?e-30:e-90+8}m`,uH={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],underlineDouble:["4:2",24],underlineCurly:["4:3",24],underlineDotted:["4:4",24],underlineDashed:["4:5",24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]},underlineColor:{underlineBlack:["58;5;0",59],underlineRed:["58;5;1",59],underlineGreen:["58;5;2",59],underlineYellow:["58;5;3",59],underlineBlue:["58;5;4",59],underlineMagenta:["58;5;5",59],underlineCyan:["58;5;6",59],underlineWhite:["58;5;7",59],underlineBlackBright:["58;5;8",59],underlineGray:["58;5;8",59],underlineGrey:["58;5;8",59],underlineRedBright:["58;5;9",59],underlineGreenBright:["58;5;10",59],underlineYellowBright:["58;5;11",59],underlineBlueBright:["58;5;12",59],underlineMagentaBright:["58;5;13",59],underlineCyanBright:["58;5;14",59],underlineWhiteBright:["58;5;15",59]}};Object.keys(uH.modifier);let uQ=Object.keys(uH.color),uZ=Object.keys(uH.bgColor);Object.keys(uH.underlineColor),[...uQ,...uZ];let u0=function(){let e=new Map;for(let[t,r]of Object.entries(uH)){for(let[t,n]of Object.entries(r))uH[t]={open:`\u{1B}[${n[0]}m`,close:`\u{1B}[${n[1]}m`},r[t]=uH[t],e.set(Number.parseInt(n[0],10),n[1]);Object.defineProperty(uH,t,{value:r,enumerable:!1})}return Object.defineProperty(uH,"codes",{value:e,enumerable:!1}),uH.color.close="\x1b[39m",uH.bgColor.close="\x1b[49m",uH.underlineColor.close="\x1b[59m",uH.color.ansi=uJ(),uH.color.ansi256=uG(),uH.color.ansi16m=uV(),uH.bgColor.ansi=uJ(10),uH.bgColor.ansi256=uG(10),uH.bgColor.ansi16m=uV(10),uH.underlineColor.ansi=uK,uH.underlineColor.ansi256=uG(20),uH.underlineColor.ansi16m=uV(20),Object.defineProperties(uH,{rgbToAnsi256:{value:(e,t,r)=>e===t&&t===r?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(r/255*5),enumerable:!1},hexToRgb:{value(e){let t=/[\da-f]{6}|[\da-f]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[r]=t;3===r.length&&(r=[...r].map(e=>e+e).join(""));let n=Number.parseInt(r,16);return[n>>16&255,n>>8&255,255&n]},enumerable:!1},hexToAnsi256:{value:e=>uH.rgbToAnsi256(...uH.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){let t,r,n;if(e<8)return 30+e;if(e<16)return 90+(e-8);if(e>=232)r=t=((e-232)*10+8)/255,n=t;else{let i=(e-=16)%36;t=Math.floor(e/36)/5,r=Math.floor(i/6)/5,n=i%6/5}let i=2*Math.max(t,r,n);if(0===i)return 30;let a=30+(Math.round(n)<<2|Math.round(r)<<1|Math.round(t));return 2===i&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,r)=>uH.ansi256ToAnsi(uH.rgbToAnsi256(e,t,r)),enumerable:!1},hexToAnsi:{value:e=>uH.ansi256ToAnsi(uH.hexToAnsi256(e)),enumerable:!1}}),uH}();function u1(e,t=globalThis.Deno?globalThis.Deno.args:aT.argv){let r=e.startsWith("-")?"":1===e.length?"-":"--",n=t.indexOf(r+e),i=t.indexOf("--");return -1!==n&&(-1===i||n<i)}let{env:u2}=aT;function u5(){return/^\d+$/.test(u2.FORCE_COLOR)}function u3(e,t={}){var r;return 0!==(r=function(e,{streamIsTTY:t,sniffFlags:r=!0}={}){let n="FORCE_COLOR"in u2?"false"===u2.FORCE_COLOR?0:"true"===u2.FORCE_COLOR||0===u2.FORCE_COLOR.length?1:u5()?Math.min(Number.parseInt(u2.FORCE_COLOR,10),3):void 0:void 0;void 0!==n&&(i=n);let a=r?i:n;if(0===a)return 0;if(r){if(u1("color=16m")||u1("color=full")||u1("color=truecolor"))return 3;if(u1("color=256"))return 2}if(void 0!==a&&u5())return a;if("TF_BUILD"in u2&&"AGENT_NAME"in u2)return 1;if(e&&!t&&void 0===a)return 0;let s=a||0;if("dumb"===u2.TERM)return s;if("win32"===aT.platform){let e=rg.release().split(".");return Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if("CI"in u2)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(e=>e in u2)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(e=>e in u2)||"codeship"===u2.CI_NAME?1:s;if("TEAMCITY_VERSION"in u2)return+!!/^(?:9\.0*[1-9]\d*\.|\d{2,}\.)/.test(u2.TEAMCITY_VERSION);if("truecolor"===u2.COLORTERM||"xterm-kitty"===u2.TERM||"xterm-ghostty"===u2.TERM||"wezterm"===u2.TERM)return 3;if("TERM_PROGRAM"in u2){let e=Number.parseInt((u2.TERM_PROGRAM_VERSION||"").split(".",1)[0],10);switch(u2.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}return/-256(?:color)?$/i.test(u2.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(u2.TERM)||"COLORTERM"in u2?1:s}(e,{streamIsTTY:e&&e.isTTY,...t}))&&{level:r,hasBasic:!0,has256:r>=2,has16m:r>=3}}u1("no-color")||u1("no-colors")||u1("color=false")||u1("color=never")?i=0:(u1("color")||u1("colors")||u1("color=true")||u1("color=always"))&&(i=1);let{stdout:u8,stderr:u6}={stdout:u3({isTTY:a0.isatty(1)}),stderr:u3({isTTY:a0.isatty(2)})},u9=Symbol("GENERATOR"),u4=Symbol("STYLER"),u7=Symbol("IS_EMPTY"),de=Symbol("LEVEL"),dt=Object.create(null),dr=e=>{if(!Number.isSafeInteger(e)||e<0||e>3)throw Error("The `level` should be an integer from 0 to 3")};class dn{constructor(e){return di(e)}}let di=e=>{let t=(...e)=>e.join(" ");return((e,t={})=>{void 0!==t.level&&dr(t.level);let r=u8?u8.level:0;e[de]=void 0===t.level?r:t.level})(t,e),Object.setPrototypeOf(t,da.prototype),t};function da(e){return di(e)}for(let[e,t]of(Object.setPrototypeOf(da.prototype,Function.prototype),Object.entries(u0)))dt[e]={get(){let r=du(this,dc(t.open,t.close,this[u4]),this[u7]);return Object.defineProperty(this,e,{value:r}),r}};dt.visible={get(){let e=du(this,this[u4],!0);return Object.defineProperty(this,"visible",{value:e}),e}};let ds=(e,t)=>{let r=u0[t];if("rgb"===e){let e=(e,t,n)=>r.ansi(u0.rgbToAnsi(e,t,n));return[e,e,(e,t,n)=>r.ansi256(u0.rgbToAnsi256(e,t,n)),r.ansi16m]}if("hex"===e){let e=e=>r.ansi(u0.hexToAnsi(e));return[e,e,e=>r.ansi256(u0.hexToAnsi256(e)),e=>r.ansi16m(...u0.hexToRgb(e))]}let n=e=>r.ansi(u0.ansi256ToAnsi(e));return[n,n,r.ansi256,r.ansi256]};for(let e of["rgb","hex","ansi256"]){let t=e[0].toUpperCase()+e.slice(1);for(let[r,n]of[[e,"color"],["bg"+t,"bgColor"],["underline"+t,"underlineColor"]]){let{close:t}=u0[n],i=ds(e,n);dt[r]={get(){let e=function(e,r,n){return du(this,dc(i[this.level](e,r,n),t,this[u4]),this[u7])};return Object.defineProperty(this,r,{value:e}),e}}}}let dl=Object.defineProperties(()=>{},{...dt,level:{enumerable:!0,get(){return this[u9].level},set(e){this[u9].level=e}}}),dc=(e,t,r)=>{let n,i;return void 0===r?(n=e,i=t):(n=r.openAll+e,i=t+r.closeAll),{open:e,close:t,openAll:n,closeAll:i,parent:r}},du=(e,t,r)=>{let n=(...e)=>1===e.length?dd(n,""+e[0]):2===e.length?dd(n,e[0]+" "+e[1]):dd(n,e.join(" "));return Object.setPrototypeOf(n,dl),n[u9]=e[u9]??e,n[u4]=t,n[u7]=r,n},dd=(e,t)=>{if(e[u9][de]<=0||!t)return e[u7]?"":t;let r=e[u4];if(void 0===r)return t;let{openAll:n,closeAll:i}=r;if(t.includes("\x1b"))for(;void 0!==r;)t=function(e,t,r){let n=e.indexOf(t);if(-1===n)return e;let i=t.length,a=0,s="";do s+=e.slice(a,n)+t+r,a=n+i,n=e.indexOf(t,a);while(-1!==n)return s+e.slice(a)}(t,r.close,r.open),r=r.parent;let a=t.indexOf("\n");return -1!==a&&(t=function(e,t,r,n){let i=0,a="";do{let s="\r"===e[n-1];a+=e.slice(i,s?n-1:n)+t+(s?"\r\n":"\n")+r,i=n+1,n=e.indexOf("\n",i)}while(-1!==n)return a+e.slice(i)}(t,i,n,a)),n+t+i};Object.defineProperties(da.prototype,{...dt,level:{enumerable:!0,get(){return this[de]},set(e){dr(e),this[de]=e}}}),di(void 0),di({level:u6?u6.level:0});let df=function({onlyFirst:e=!1}={}){return RegExp("(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]",e?void 0:"g")}();function dh(e){if("string"!=typeof e)throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.includes("\x1b")||e.includes("›")?e.replace(df,""):e}let dp=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],dm=[12288,12288,65281,65376,65504,65510],dg=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141],dy=(e,t)=>{let r=0,n=Math.floor(e.length/2)-1;for(;r<=n;){let i=Math.floor((r+n)/2),a=2*i;if(t<e[a])n=i-1;else{if(!(t>e[a+1]))return!0;r=i+1}}return!1},[db,dv]=function(e){let t=e[0],r=e[1];for(let n=0;n<e.length;n+=2){let i=e[n],a=e[n+1];if(19968>=i&&19968<=a)return[i,a];a-i>r-t&&(t=i,r=a)}return[t,r]}(dg);function dw(e,{ambiguousAsWide:t=!1}={}){if(!Number.isSafeInteger(e))throw TypeError(`Expected a code point, got \`${typeof e}\`.`);return!(e<12288)&&!(e>65510)&&dy(dm,e)||e>=db&&e<=dv||!(e<4352)&&!(e>262141)&&dy(dg,e)||t&&!(e<161)&&!(e>1114109)&&dy(dp,e)?2:1}let dx=new Intl.Segmenter,d_=/^(?:\p{Default_Ignorable_Code_Point}|\p{Control}|\p{Format}|\p{Nonspacing_Mark}|\p{Enclosing_Mark}|\p{Surrogate})+$/v,dk=/^[\p{Default_Ignorable_Code_Point}\p{Control}\p{Format}\p{Nonspacing_Mark}\p{Enclosing_Mark}\p{Surrogate}]+/v,dS=/\p{Spacing_Mark}/v,dI=/^\p{RGI_Emoji}$/v,dE=/^[\d#*]\u20E3$/,d$=/\p{Extended_Pictographic}/gu;function dO(e){return e>=4352&&e<=4447||e>=43360&&e<=43388}function dC(e){return e>=4448&&e<=4519||e>=55216&&e<=55238}function dT(e){return e>=4520&&e<=4607||e>=55243&&e<=55291}function dA(e,t={}){if("string"!=typeof e||0===e.length)return 0;let{ambiguousIsNarrow:r=!0,countAnsiEscapeCodes:n=!1}=t,i=e;if(!n&&(i.includes("\x1b")||i.includes("›"))&&(i=dh(i)),0===i.length)return 0;if(/^[\u0020-\u007E]*$/.test(i))return i.length;let a=0,s={ambiguousAsWide:!r};for(let{segment:e}of dx.segment(i)){if(d_.test(e))continue;if(dI.test(e)||function(e){if(e.length>50)return!1;if(dE.test(e))return!0;if(e.includes("‍")){let t=e.match(d$);return null!==t&&t.length>=2}return!1}(e)){a+=2;continue}let t=e.replace(dk,""),r=function(e,t){let r=[];for(let t of e)d_.test(t)||r.push(t.codePointAt(0));if(0===r.length)return;let n=0;for(let e=0;e<r.length;e++){let i=r[e];if(!(dO(i)||dC(i)||dT(i))){if(0===n)return;for(let i=e;i<r.length;i++)n+=dw(r[i],t);break}if(dO(i)&&dC(r[e+1])){n+=2,e+=dT(r[e+2])?2:1;continue}n+=dw(i,t)}return n}(t,s);if(void 0!==r){a+=r;continue}a+=dw(t.codePointAt(0),s),a+=function(e,t){let r=0,n=!0;for(let i of e){if(n){n=!1;continue}(dS.test(i)||i>="＀"&&i<="￯")&&(r+=dw(i.codePointAt(0),t))}return r}(t,s)}return a}let dM=(e=0)=>t=>`\u001B[${t+e}m`,dN=(e=0)=>t=>`\u001B[${38+e};5;${t}m`,dP=(e=0)=>(t,r,n)=>`\u001B[${38+e};2;${t};${r};${n}m`,dR={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(dR.modifier),[...Object.keys(dR.color),...Object.keys(dR.bgColor)];let dj=function(){let e=new Map;for(let[t,r]of Object.entries(dR)){for(let[t,n]of Object.entries(r))dR[t]={open:`\u001B[${n[0]}m`,close:`\u001B[${n[1]}m`},r[t]=dR[t],e.set(n[0],n[1]);Object.defineProperty(dR,t,{value:r,enumerable:!1})}return Object.defineProperty(dR,"codes",{value:e,enumerable:!1}),dR.color.close="\x1b[39m",dR.bgColor.close="\x1b[49m",dR.color.ansi=dM(),dR.color.ansi256=dN(),dR.color.ansi16m=dP(),dR.bgColor.ansi=dM(10),dR.bgColor.ansi256=dN(10),dR.bgColor.ansi16m=dP(10),Object.defineProperties(dR,{rgbToAnsi256:{value:(e,t,r)=>e===t&&t===r?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(r/255*5),enumerable:!1},hexToRgb:{value(e){let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[r]=t;3===r.length&&(r=[...r].map(e=>e+e).join(""));let n=Number.parseInt(r,16);return[n>>16&255,n>>8&255,255&n]},enumerable:!1},hexToAnsi256:{value:e=>dR.rgbToAnsi256(...dR.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){let t,r,n;if(e<8)return 30+e;if(e<16)return 90+(e-8);if(e>=232)r=t=((e-232)*10+8)/255,n=t;else{let i=(e-=16)%36;t=Math.floor(e/36)/5,r=Math.floor(i/6)/5,n=i%6/5}let i=2*Math.max(t,r,n);if(0===i)return 30;let a=30+(Math.round(n)<<2|Math.round(r)<<1|Math.round(t));return 2===i&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,r)=>dR.ansi256ToAnsi(dR.rgbToAnsi256(e,t,r)),enumerable:!1},hexToAnsi:{value:e=>dR.ansi256ToAnsi(dR.hexToAnsi256(e)),enumerable:!1}}),dR}(),dD=new Set(["\x1b","›"]),dL="]8;;",dU=RegExp(`^\\u001B(?:\\[(?<sgr>[0-9;]*)m|${dL}(?<uri>[^\\u0007\\u001B]*)(?:\\u0007|\\u001B\\\\))`),dF=RegExp("^\\u009B(?<sgr>[0-9;]*)m"),dB=new Set(dj.codes.values());dB.delete(0);let dW=new Intl.Segmenter,dq=e=>Array.from(dW.segment(e),({segment:e})=>e),dY=e=>`\u001B[${e}m`,dz=e=>`\u001B${dL}${e}\u0007`,dX=e=>{let t=e.split(";").map(e=>""===e?0:Number.parseInt(e,10)),r=[];for(let e=0;e<t.length;e++){let n=t[e];if(Number.isFinite(n)){if(38===n||48===n||58===n){if(e+1>=t.length)break;let i=t[e+1];if(5===i&&Number.isFinite(t[e+2])){r.push([n,i,t[e+2]]),e+=2;continue}let a=t[e+2],s=t[e+3],o=t[e+4];if(2===i&&Number.isFinite(a)&&Number.isFinite(s)&&Number.isFinite(o)){r.push([n,i,a,s,o]),e+=4;continue}break}r.push([n])}}return r},dJ=(e,t)=>{let r=e.findIndex(e=>e.family===t);-1!==r&&e.splice(r,1)},dG=(e,t)=>{dJ(e,t.family),e.push(t)},dV=(e,t)=>{if(0===e)return t.length=0,!0;if(39===e)return dJ(t,"foreground"),!0;if(49===e)return dJ(t,"background"),!0;if(59===e)return dJ(t,"underlineColor"),!0;if(dB.has(e)){for(let r=t.length-1;r>=0;r--){let n=t[r];n.family.startsWith("modifier-")&&n.close===e&&t.splice(r,1)}return!0}return!1},dK=(e,t)=>{let[r]=e;if(dV(r,t))return;let n=r>=30&&r<=37||r>=90&&r<=97||38===r&&e.length>1?{family:"foreground",open:e.join(";"),close:39}:r>=40&&r<=47||r>=100&&r<=107||48===r&&e.length>1?{family:"background",open:e.join(";"),close:49}:58===r&&e.length>1?{family:"underlineColor",open:e.join(";"),close:59}:void 0;if(n)return void dG(t,n);let i=dj.codes.get(r);void 0!==i&&0!==i&&dG(t,{family:`modifier-${r}`,open:e.join(";"),close:i})},dH=(e,t)=>{for(let r of dX(e))dK(r,t)},dQ=(e,t)=>{for(let r of dX(e)){let[e]=r;dV(e,t)}},dZ=(e,t)=>{let r=e;for(;r.length>0;){if(r.startsWith("\x1b")&&"\\"!==r[1]){let e=dU.exec(r);if(!e)break;void 0!==e.groups.sgr&&dQ(e.groups.sgr,t),r=r.slice(e[0].length);continue}if(r.startsWith("›")){let e=dF.exec(r);if(!e||void 0===e.groups.sgr)break;dQ(e.groups.sgr,t),r=r.slice(e[0].length);continue}break}},d0=e=>[...e].reverse().map(e=>dY(e.close)).join(""),d1=e=>e.map(e=>dY(e.open)).join(""),d2=(e,t,r)=>{let n=dq(t),i=!1,a=!1,s=dA(dh(e.at(-1)));for(let[t,o]of n.entries()){let l=dA(o);if(s+l<=r?e[e.length-1]+=o:(e.push(o),s=0),dD.has(o)&&!(a&&"\x1b"===o&&"\\"===n[t+1])&&(i=!0,a=n.slice(t+1,t+1+dL.length).join("")===dL),i){a?("\x07"===o||"\\"===o&&t>0&&"\x1b"===n[t-1])&&(i=!1,a=!1):"m"===o&&(i=!1);continue}(s+=l)===r&&t<n.length-1&&(e.push(""),s=0)}!s&&e.at(-1).length>0&&e.length>1&&(e[e.length-2]+=e.pop())},d5=[" pppppppppppp "," pppppppppppppp ","pppppppppppeeppp","ppppppppppfeeepp","pppppppppcffeepp","ppppppppcccffppp","pppppppcccccpppp","ppppppcccccppppp","pppppcccccpppppp","ppppwccccppppppp","pppwwwccpppppppp","pppkwwwppppppppp","pppkkwpppppppppp","pppppppppppppppp"," pppppppppppppp "," pppppppppppp "],d3={s:["....","....",".###","#...",".##.","...#","###.","...."],k:["#...","#...","#..#","#.#.","##..","#.#.","#..#","...."],e:["....","....",".##.","#..#","####","#...",".###","...."],t:[".#.",".#.","###",".#.",".#.",".#.",".##","..."],c:["....","....",".###","#...","#...","#...",".###","...."],h:["#...","#...","#.#.","##.#","#..#","#..#","#..#","...."],i:["#",".","#","#","#","#","#","."]},d8={p:{dark:{red:158,green:124,blue:140,ansi256:138},light:{red:143,green:112,blue:127,ansi256:96}},c:{dark:{red:250,green:248,blue:247,ansi256:231},light:{red:250,green:248,blue:247,ansi256:231}},w:{dark:{red:214,green:186,blue:152,ansi256:180},light:{red:214,green:186,blue:152,ansi256:180}},k:{dark:{red:58,green:50,blue:54,ansi256:237},light:{red:58,green:50,blue:54,ansi256:237}},f:{dark:{red:186,green:190,blue:196,ansi256:250},light:{red:186,green:190,blue:196,ansi256:250}},e:{dark:{red:222,green:152,blue:158,ansi256:175},light:{red:222,green:152,blue:158,ansi256:175}}},d6={dark:{red:195,green:154,blue:172,ansi256:181},light:{red:111,green:84,blue:98,ansi256:95}},d9={dark:{red:246,green:241,blue:231,ansi256:255},light:{red:26,green:23,blue:18,ansi256:234}},d4={dark:{red:216,green:204,blue:177,ansi256:187},light:{red:76,green:70,blue:57,ansi256:239}},d7=[[0,0,0],[205,0,0],[0,205,0],[205,205,0],[0,0,238],[205,0,205],[0,205,205],[229,229,229],[127,127,127],[255,0,0],[0,255,0],[255,255,0],[92,92,255],[255,0,255],[0,255,255],[255,255,255]];function fe(e,t,r,n="plain"){if("none"===r.colors)return e;let i=new dn({level:"truecolor"===r.colors?3:2}),a="truecolor"===r.colors?i.rgb(t.red,t.green,t.blue):i.ansi256(t.ansi256);return"bold"===n?a.bold(e):a(e)}function ft(e,t){return fe(e,d6[t.background],t,"bold")}function fr(e,t){return fe(e,d9[t.background],t,"bold")}function fn(e,t){return fe(e,d4[t.background],t)}function fi(e,t){let r=new dn({level:"truecolor"===t.colors?3:2});return"truecolor"===t.colors?r.rgb(e.red,e.green,e.blue):r.ansi256(e.ansi256)}function fa(e,t){let r=d8[e];return void 0===r?void 0:r[t.background]}function fs(e,t,r,n=dA(e)){var i;let a=Math.max(16,r-dA(e));return`${e}${(i={hard:!0,trim:!0},String(t).normalize().replaceAll("\r\n","\n").split("\n").map(e=>((e,t,r={})=>{let n;if(!1!==r.trim&&""===e.trim())return"";let i="",a=[],s=e.split(" ").map(e=>dA(e)),o=[""];for(let[n,i]of e.split(" ").entries()){!1!==r.trim&&(o[o.length-1]=o.at(-1).trimStart());let e=dA(o.at(-1));if(0!==n&&(e>=t&&(!1===r.wordWrap||!1===r.trim)&&(o.push(""),e=0),(e>0||!1===r.trim)&&(o[o.length-1]+=" ",e++)),r.hard&&!1!==r.wordWrap&&s[n]>t){let r=t-e,a=1+Math.floor((s[n]-r-1)/t);Math.floor((s[n]-1)/t)<a&&o.push(""),d2(o,i,t);continue}if(e+s[n]>t&&e>0&&s[n]>0){if(!1===r.wordWrap&&e<t){d2(o,i,t);continue}o.push("")}if(e+s[n]>t&&!1===r.wordWrap){d2(o,i,t);continue}o[o.length-1]+=i}!1!==r.trim&&(o=o.map(e=>(e=>{let t=e.split(" "),r=t.length;for(;r>0&&!(dA(t[r-1])>0);)r--;return r===t.length?e:t.slice(0,r).join(" ")+t.slice(r).join("")})(e)));let l=o.join("\n"),c=dq(l),u=0;for(let[e,t]of c.entries()){if(i+=t,"\x1b"===t&&"\\"!==c[e+1]){let{groups:e}=dU.exec(l.slice(u))||{groups:{}};void 0!==e.sgr?dH(e.sgr,a):void 0!==e.uri&&(n=0===e.uri.length?void 0:e.uri)}else if("›"===t){let{groups:e}=dF.exec(l.slice(u))||{groups:{}};void 0!==e.sgr&&dH(e.sgr,a)}if("\n"===c[e+1])n&&(i+=dz("")),i+=d0(a);else if("\n"===t){let e=[...a];dZ(l.slice(u+1),e),i+=d1(e),n&&(i+=dz(n))}u+=t.length}return i})((e=>{if(!e.includes(" "))return e;let t=e.split(" "),r=0,n="";for(let[e,i]of t.entries())if(n+=i,r+=dA(i),e<t.length-1){let e=8-r%8;n+=" ".repeat(e),r+=e}return n})(e),a,i)).join("\n")).replaceAll("\n",`
55
+ ${" ".repeat(n)}`)}`}function fo(e,t,r,n,i=8){if(n<52)return[` ${fr(e,r)}`,fs(" ",fn(t,r),n)].join("\n");let a=e.padEnd(i);return fs(` ${fr(a,r)} `,fn(t,r),n)}function fl(e){let t=Math.max(32,e.width??80);return[function(e){let t=Math.max(32,e.width??80),r=fs(" ",fn("describe it. sketchi draws it.",e),t);if("none"===e.colors||!1===e.unicode)return[` ${fe("sketchi",d9[e.background],e,"bold")}`,r].join("\n");let n=function(e){let t=Array.from({length:8},(e,t)=>[..."sketchi"].map((e,r)=>`${d3[e]?.[t]??""}${6===r?"":"."}`).join("")),r=d9[e.background],n=[];for(let i=0;i<t.length;i+=2){let a="";for(let e=0;e<(t[i]?.length??0);e+=1){let r=t[i]?.[e]==="#",n=t[i+1]?.[e]==="#";a+=r&&n?"█":r?"▀":n?"▄":" "}n.push("none"===e.colors?a:fi(r,e)(a))}return n}(e);if(t<50)return[...n.map(e=>` ${e}`),"",r].join("\n");let i=function(e){let t=[];for(let r=0;r<d5.length;r+=2){let n="";for(let t=0;t<16;t+=1){let i=fa(d5[r]?.[t]??" ",e),a=fa(d5[r+1]?.[t]??" ",e);void 0===i&&void 0===a?n+=" ":void 0===i?n+=fi(a,e)("▄"):void 0===a?n+=fi(i,e)("▀"):n+=function(e,t,r){let n=new dn({level:"truecolor"===r.colors?3:2}),i="truecolor"===r.colors?n.bgRgb(t.red,t.green,t.blue):n.bgAnsi256(t.ansi256);return"truecolor"===r.colors?i.rgb(e.red,e.green,e.blue)("▀"):i.ansi256(e.ansi256)("▀")}(i,a,e)}t.push(n)}return t}(e),a=(i.length-n.length)/2,s=" ".repeat(2);return[...i.map((e,t)=>{let r=n[t-a];return` ${e}${void 0===r?"":`${s}${r}`}`}),"",r].join("\n")}(e),"",ft("START HERE",e),fs(` ${fr("sketchi generate",e)} `,fn("interactive",e),t),fs(" ",fr('sketchi generate --prompt "Map release approval with pass and revise branches"',e),t),fs(" ",fn("Writes <generated-id>.png in this directory. No account or API key needed.",e),t),fo("canvas","Build and export a typed Universal CanvasSpec.",e,t),"",ft("WORK WITH A DIAGRAM",e),fo("show","Inspect a local diagram.",e,t),fo("edit","Replace its canonical document.",e,t),fo("export","Write PNG, Excalidraw, or scene bytes.",e,t),fo("share","Create an encrypted Excalidraw link.",e,t),"",fs("",fn("sketchi docs for every command. Add --output json for automation.",e),t)].join("\n")}function fc(e){if(!Number.isInteger(e)||e<0||e>255)return;if(e<16){let[t,r,n]=d7[e]??[0,0,0];return{red:t,green:r,blue:n}}if(e<232){let t=[0,95,135,175,215,255],r=e-16,n=t[Math.floor(r/36)]??0;return{red:n,green:t[Math.floor(r%36/6)]??0,blue:t[r%6]??0}}let t=8+(e-232)*10;return{red:t,green:t,blue:t}}function fu(e){let t=e=>{let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4};return .2126*t(e.red)+.7152*t(e.green)+.0722*t(e.blue)}function fd(e,t){return(Math.max(fu(e),fu(t))+.05)/(Math.min(fu(e),fu(t))+.05)}function ff(e,t,r){let n=e=>"truecolor"===r?e:fc(e.ansi256)??e;return Math.min(fd(e,n(d6[t])),fd(e,n(d9[t])),fd(e,n(d4[t])))}let fh=new Set(["generate","canvas","docs","create","show","edit","patch","list","restore","share","pull","export"]);function fp(e){return{_tag:"File",path:e}}function fm(e){return{_tag:"InlineJson",value:e}}function fg(e="canonical document"){let t=ou("flag","file").pipe(o8("PATH|-"),o3(`Read one ${e} from PATH, or stdin with -.`),o9(fp)),r=ou("flag","json").pipe(o8("VALUE"),o3(`Read one ${e} from inline JSON.`),o9(fm));return{source:Object.assign(Object.create(Object.getPrototypeOf(t)),t,{parse:e=>{let n=e.flags.file?.length??0,i=e.flags.json?.length??0;return 1===n&&0===i?t.parse(e):0===n&&1===i?r.parse(e):U.fJG(new sY({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:o6(r)}}function fy(e,t,r){return new sY({option:e,value:t,expected:r,kind:"flag"})}class fb extends Z.kl()("@sketchi/cli/OutputWriter"){}class fv extends nt.X0d()("CliCommandExit",{exitCode:nt.wNn}){}function fw(e){return nh.make({cause:e,operation:"write-output",path:"standard stream",message:"Unable to write command output."})}let fx=J.QZ(fb,U.JkU(function*(){let e=yield*r2;return{stdout:t=>((...e)=>th(e))(t).pipe(tv(e.stdout()),U.xm_(fw)),stderr:t=>((...e)=>th(e))(t).pipe(tv(e.stderr()),U.xm_(fw))}}));function f_(e){let t=e.details?.map(e=>` - ${e}`).join("\n");return[`error: ${e.code}`,e.message,...e.diagramId?[`diagram: ${e.diagramId}`]:[],...e.storagePath?[`storage: ${e.storagePath}`]:[],...e.recoveryCommand?[`recovery: ${e.recoveryCommand}`]:[],`next: ${e.hint}`,...t?["details:",t]:[]].join("\n")+"\n"}let fk=U.fn("sketchi.cli.output.failure")(function*(e,t,r){let n=yield*fb,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"CliInteractiveError":case"CliStorageError":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"CliCanvasError":case"CliGenerationError":case"CliShareError":return{code:e.code,message:e.message,hint:e.hint,details:e.details};case"CliExportError":return{code:e.code,message:e.message,hint:e.hint,...e.details?{details:e.details}:{},...e.diagramId?{diagramId:e.diagramId}:{},...e.storagePath?{storagePath:e.storagePath}:{},...e.recoveryCommand?{recoveryCommand:e.recoveryCommand}:{}}}}(r),a="json"===t?nR({ok:!1,command:e,error:i}):f_(i);return yield*n.stderr(uX(a)),yield*fv.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":case"unsupported_diagram_type":return 3;case"provider_failure":return 10;case"generation_timeout":return 11;case"malformed_output":return 12}case"CliCanvasError":switch(e.code){case"canvas_rejected":return 4;case"endpoint_failure":case"network_failure":return 10;case"malformed_response":return 12}case"CliInteractiveError":return"cancelled"===e.code?2:1;case"CliStorageError":if("diagram_not_found"===e.code||"revision_not_found"===e.code)return 5;if("diagram_already_exists"===e.code||"diagram_busy"===e.code||"detached_edit"===e.code||"patch_conflict"===e.code||"replacement_conflict"===e.code||"restore_conflict"===e.code)return 6;return 7;case"CliFilesystemError":return 7;case"CliExportError":return 8;case"CliShareError":return"share_transport_failed"===e.code||"share_timeout"===e.code||"share_api_changed"===e.code||"share_link_unavailable"===e.code?13:3}}(r)})}),fS=U.fn("sketchi.cli.output.success")(function*(e,t,r,n,i="stdout"){let a=yield*fb,s="json"===t?nR({ok:!0,command:e,data:r}):n;yield*a[i](s.endsWith("\n")?s:`${s}
56
+ `)});function fI(e,t,r,n,i=e=>e){return r.pipe(U.tvg({onFailure:r=>fk(e,t,r),onSuccess:r=>fS(e,t,i(r),n(r))}))}function fE(e,t,r){return nx.make({code:e,message:t,hint:r,details:[]})}async function f$(e,t){let r=Number(e.headers.get("content-length"));if(Number.isFinite(r)&&r>t)throw Error("response body exceeds limit");if(!e.body)return new Uint8Array;let n=e.body.getReader(),i=[],a=0;try{for(;;){let e=await n.read();if(e.done)break;if((a+=e.value.byteLength)>t)throw await n.cancel(),Error("response body exceeds limit");i.push(e.value)}}finally{n.releaseLock()}let s=new Uint8Array(a),o=0;for(let e of i)s.set(e,o),o+=e.byteLength;return s}function fO(){return fE("share_timeout","The Excalidraw storage request timed out.","Retry once. The unofficial third-party backend may be unavailable.")}function fC(){return fE("share_transport_failed","The Excalidraw storage request failed.","Retry once. The unofficial third-party backend may be unavailable.")}async function fT(e,t,r){let n=new AbortController,i=setTimeout(()=>n.abort(),15e3);try{let i=await fetch(e,{...t,redirect:"error",signal:n.signal});return await r(i)}finally{clearTimeout(i)}}class fA extends Z.kl()("@sketchi/cli/ShareTransport"){}let fM=J.Py(fA,{upload:e=>U.$mh({try:async()=>await fT("https://json.excalidraw.com/api/v2/post/",{method:"POST",body:Uint8Array.from(e)},async e=>{let t=await f$(e,65536);if(!e.ok)throw Error("upload HTTP failure");let r=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(t));if("object"!=typeof r||null===r||!("id"in r)||"string"!=typeof r.id||!/^[A-Za-z0-9_-]{1,128}$/.test(r.id)||!("data"in r)||r.data!==`${im}${r.id}`)throw fE("share_api_changed","The Excalidraw storage API returned an unexpected response.","The unofficial API may have changed; update Sketchi compatibility before retrying.");return r.id}),catch:e=>e instanceof nx?e:e instanceof DOMException&&"AbortError"===e.name?fO():fC()}),download:e=>U.$mh({try:async()=>await fT(`${im}${e}`,{method:"GET"},async e=>{if(404===e.status)throw fE("share_link_unavailable","The Excalidraw share link is unavailable.","Verify the complete bearer link or ask its sender to export a new link.");if(!e.ok)throw Error("download HTTP failure");return await f$(e,2097152)}),catch:e=>e instanceof nx?e:e instanceof DOMException&&"AbortError"===e.name?fO():fC()})});class fN extends Z.kl()("@sketchi/cli/LinkOpener"){}let fP=function(e=(e,t,r)=>{let n=(0,tH.spawn)(e,[...t],r);return{onError:e=>{n.once("error",e)},onExit:e=>{n.once("exit",e)},kill:()=>n.kill()}},t=process.platform,r=3e3){return J.Py(fN,{open:n=>U.ivC(()=>new Promise(i=>{let a=function(e,t){switch(t){case"darwin":return{command:"open",args:[e]};case"win32":return{command:"cmd.exe",args:["/d","/s","/c","start","",e]};default:return{command:"xdg-open",args:[e]}}}(n,t),s=e(a.command,a.args,{shell:!1,stdio:"ignore"}),o=!1,l=e=>{o||(o=!0,clearTimeout(c),i(e))};s.onError(()=>l({status:"unconfirmed",reason:"missing_executable"})),s.onExit(e=>l(0===e?{status:"accepted"}:{status:"unconfirmed",reason:"nonzero_exit"}));let c=setTimeout(()=>{s.kill(),l({status:"unconfirmed",reason:"timeout"})},r)}))})}();class fR extends Z.kl()("@sketchi/cli/ExcalidrawShare"){}let fj=J.QZ(fR,U.JkU(function*(){let e=yield*fA;return{share:U.fn("sketchi.cli.share.upload")(function*(t){var r;let n=yield*iM(t).pipe(U.qIB(()=>U.SvU({try:()=>{var e;let r=iC(t);return ib.encode(JSON.stringify({type:r.type,version:r.version,source:r.source,elements:r.elements,appState:(e=r.appState,Object.fromEntries(["gridSize","gridStep","gridModeEnabled","viewBackgroundColor","lockedMultiSelections"].flatMap(t=>t in e?[[t,e[t]]]:[])))},null,2))},catch:()=>ix("unsupported_scene","The Excalidraw scene could not be serialized.","Inspect the local diagram.excalidraw artifact and retry.")}))),i=Buffer.from(crypto.getRandomValues(new Uint8Array(16))).toString("base64url"),a=yield*U.$mh({try:async()=>{if(n.byteLength>0xfffff0)throw ix("share_payload_too_large","The Excalidraw share contents exceed 16 MiB.","Reduce the drawing size and retry.");let e=2097136-iw.byteLength-12-16,t=await function(e,t){let r=ib.encode("null"),n=[iN(1),iN(r.byteLength),r,iN(e.byteLength),e],i=new ih.Gy({chunkSize:65536}),a=[],s=0;for(let[e,r]of(i.onData=e=>{let r=e instanceof Uint8Array?e:new Uint8Array(e);if((s+=r.byteLength)>t)throw ix("share_payload_too_large","The encrypted Excalidraw share payload exceeds 2 MiB.","Reduce the drawing size and retry.");a.push(r)},n.entries()))if(i.push(r,e===n.length-1),0!==i.err)throw Error(i.msg);let o=new Uint8Array(s),l=0;for(let e of a)o.set(e,l),l+=e.byteLength;return o}(n,e),r=Uint8Array.from((void 0)??crypto.getRandomValues(new Uint8Array(12)));if(12!==r.byteLength)throw Error("invalid IV length");let a=new Uint8Array(await crypto.subtle.encrypt({name:"AES-GCM",iv:Uint8Array.from(r)},await iO(i,"encrypt"),Uint8Array.from(t)));var s=[iw,r,a];let o=new Uint8Array(4+s.reduce((e,t)=>e+4+t.byteLength,0));iS(o,0,1);let l=4;for(let e of s)iS(o,l,e.byteLength),l+=4,o.set(e,l),l+=e.byteLength;return o},catch:e=>e instanceof nx?e:ix("share_crypto_failed","The Excalidraw share payload could not be encrypted.","Retry the command. If it persists, inspect the local artifact.")});return{link:(r={id:yield*e.upload(a),key:i},`https://excalidraw.com/#json=${r.id},${r.key}`)}}),pull:U.fn("sketchi.cli.share.pull")(function*(t){var r;let n=yield*ib.encode(t).byteLength>4096?U.fJG(ix("invalid_share_link","The Excalidraw share link is invalid.","Provide one complete https://excalidraw.com/#json=ID,KEY link.",["link exceeds 4 KiB"])):U.SvU({try:()=>{let e=/^https:\/\/(www\.)?excalidraw\.com\/#json=([A-Za-z0-9_-]{1,128}),([A-Za-z0-9_-]{22})$/u.exec(t);if(!e?.[2]||!e[3])throw Error("invalid raw URL grammar");let r=new URL(t),n=`https://${e[1]??""}excalidraw.com/#json=${e[2]},${e[3]}`;if(r.href!==n)throw Error("URL normalization changed the supplied link");return i$(e[3]),{id:e[2],key:e[3]}},catch:()=>ix("invalid_share_link","The Excalidraw share link is invalid.","Provide one complete https://excalidraw.com/#json=ID,KEY link.")}),i=yield*e.download(n.id);return yield*(r=n.key,i.byteLength>2097152?U.fJG(ix("share_payload_too_large","The Excalidraw share payload exceeds 2 MiB.","Use a smaller supported Excalidraw link.")):U.$mh({try:async()=>{let[e,t,n]=iE(i,3);if(!e||!t||!n||12!==t.byteLength)throw Error("invalid encrypted payload chunks");let a=JSON.parse(iv.decode(e));if(!i_(a)||2!==a.version||"pako@1"!==a.compression||"AES-GCM"!==a.encryption)throw Error("unsupported encoding metadata");let s=new Uint8Array(await crypto.subtle.decrypt({name:"AES-GCM",iv:Uint8Array.from(t)},await iO(r,"decrypt"),Uint8Array.from(n))),o=(0,n7.inflateSync)(s,{maxOutputLength:0x1000001});if(o.byteLength>0x1000000)throw Error("decompressed payload exceeds 16 MiB");let l=iE(o,2);if(!l[0]||!l[1])throw Error("invalid inner chunk count");if("null"!==iv.decode(l[0]))throw Error("unsupported contents metadata");return!function(e){let t=iv.decode(e),r=0,n=!1,i=!1;for(let e of t){if(n){i?i=!1:"\\"===e?i=!0:'"'===e&&(n=!1);continue}if('"'===e)n=!0;else if("{"===e||"["===e){if((r+=1)>64)throw Error("JSON structure exceeds depth 64")}else if(("}"===e||"]"===e)&&(r-=1)<0)throw Error("unbalanced JSON structure")}if(0!==r||n)throw Error("incomplete JSON structure")}(l[1]),JSON.parse(iv.decode(l[1]))},catch:e=>e instanceof RangeError||e instanceof Error&&(e.message.includes("maxOutputLength")||e.message.includes("larger than"))?ix("share_payload_too_large","The decompressed Excalidraw share payload exceeds 16 MiB.","Use a smaller supported Excalidraw link."):ix("share_crypto_failed","The Excalidraw share payload could not be decrypted or decoded.","Verify that the complete bearer link is correct and uses current format v2.")}))})}}));function fD(e){return nx.make({code:"unsupported_scene",message:"The pulled Excalidraw scene cannot be rendered safely.",hint:"Use a supported, renderable Excalidraw scene and retry.",details:[e.message]})}let fL=U.fn("sketchi.cli.preflightPullTarget")(function*(e){let t=yield*nD(e),r=yield*iU,n=yield*r.show(t);return{id:t,observed:n}}),fU=U.fn("sketchi.cli.pullIntoStore")(function*(e,t,r){let n=r??(yield*fL(e)),i=n.id,a=yield*iU,s=yield*fR,o=yield*ad,l=yield*s.pull(t);yield*iM(l);let c=yield*o.normalizeExcalidraw(l).pipe(U.xm_(fD));return yield*iM(c),yield*o.renderPng({excalidraw:c}).pipe(U.xm_(fD)),{diagram:yield*a.replaceWithDetached(i,new TextEncoder().encode(nR(c)),n.observed.manifest.revision),sourceIdentity:"unverified"}}),fF=`Sketchi CLI contracts for agents and automation.
57
57
 
58
58
  Command map:
59
- Start with generate for prompt-to-PNG. Use show, edit, patch, list, restore, and export for
60
- local records. Use create for accepted canonical JSON. Share and pull are explicit network
59
+ Start with generate for prompt-to-PNG or canvas for an authored CanvasSpec. Use show, list,
60
+ and export for every local record. Edit and patch support canonical flowchart, mindmap, and
61
+ sequence records. Use create for accepted canonical JSON.
62
+ Share and pull are explicit network
61
63
  boundaries for Excalidraw links. Run sketchi COMMAND --help for every flag and example.
62
64
 
63
65
  Manual JSON workflow (strictly offline):
@@ -71,22 +73,32 @@ Canonical flowchart example:
71
73
  Canonical mindmap example:
72
74
  {"type":"mindmap","spec":{"id":"launch-map","title":"Launch plan","root":{"label":"Launch","children":[{"label":"Product"},{"label":"Operations"}]}}}
73
75
 
76
+ Canonical sequence example:
77
+ {"type":"sequence","spec":{"id":"checkout-sequence","title":"Checkout sequence","participants":[{"id":"browser","label":"Browser"},{"id":"api","label":"API"}],"messages":[{"id":"request","source":"browser","target":"api","label":"Submit checkout"}]}}
78
+
79
+ Universal CanvasSpec example:
80
+ {"kind":"canvas","version":1,"diagramId":"release-board","title":"Release board","width":640,"height":360,"accentColor":"#2563eb","backgroundColor":"#ffffff","elements":[{"type":"node","id":"ready","nodeId":"ready","shape":"rectangle","x":40,"y":40,"width":240,"height":120,"label":"Ready to release"}],"layers":[],"layouts":[],"zOrder":["ready"]}
81
+
74
82
  Semantic color patch example:
75
83
  sketchi patch release-flow --json '{"operations":[{"op":"setStyle","selector":{"nodeIds":["review","approve"]},"style":{"fillColor":"#dbeafe","strokeColor":"#2563eb","textColor":"#1e3a8a"}}]}'
76
84
 
77
85
  Explicit network commands (one credential-free HTTPS request each):
78
- sketchi generate [--prompt TEXT] [--type flowchart|mindmap] [--model MODEL]
86
+ sketchi generate [--prompt TEXT] [--type flowchart|mindmap|sequence|er|architecture|swimlane|state-machine] [--model MODEL]
87
+ sketchi canvas --file PATH|- [--format png|excalidraw|scene] [--dest PATH|-]
79
88
  sketchi share DIAGRAM_ID [--open]
80
89
  sketchi pull DIAGRAM_ID --link URL|-
81
- generate makes one unauthenticated HTTPS POST to the public Sketchi generate API at ${iK}
90
+ generate makes one unauthenticated HTTPS POST to the public Sketchi generate API at ${ab}
82
91
  and needs no token, key, account, or login. The model call, validation, and quality gate
83
92
  run server-side; the finished diagram and Excalidraw artifact come back and are committed
84
- through the same local store as create. The default type is flowchart and default model is
85
- ${iV}. Override the endpoint for preview or local testing with
86
- ${iH} or --endpoint URL.
93
+ through the same local store as create. Without --type, the model selects a supported native type; the default model is
94
+ ${ay}. Override the endpoint for preview or local testing with
95
+ ${av} or --endpoint URL.
96
+ canvas submits the CanvasSpec object itself to ${i9}, validates the typed
97
+ response, stores the normalized scene and Excalidraw artifact, and exports locally. Override its
98
+ endpoint with ${i4} or --endpoint URL.
87
99
 
88
100
  Input and output contracts:
89
- create/edit/patch require exactly one of --file PATH|- or --json VALUE. --file - reads one
101
+ create/edit/patch/canvas require exactly one of --file PATH|- or --json VALUE. --file - reads one
90
102
  noninteractive UTF-8 JSON document from stdin and exits with usage code 2 on a TTY.
91
103
  --json is inline input only. --prompt is always direct and noninteractive. With no --prompt,
92
104
  generate opens a short prompt/type/PNG-destination wizard only when stdin and stdout are human
@@ -105,8 +117,8 @@ Input and output contracts:
105
117
  Share/pull safety limits:
106
118
  links 4 KiB; encrypted bodies 2 MiB; inflated contents 16 MiB; 10,000 elements;
107
119
  JSON depth 64; element dimensions ${String(8192)}; canvas dimensions
108
- ${String(8192)}; canvas area ${String(n6.Z4)} square units; final PNG
109
- ${String(n6.ce)} pixels. Limits are checked before encryption or raster allocation.
120
+ ${String(8192)}; canvas area ${String(ip.Z4)} square units; final PNG
121
+ ${String(ip.ce)} pixels. Limits are checked before encryption or raster allocation.
110
122
 
111
123
  Offline boundary and storage:
112
124
  create, patch, show, edit, list, export, and restore use no model, remote agent, MCP server, login,
@@ -118,7 +130,7 @@ Offline boundary and storage:
118
130
  A pulled record is detached: diagram.excalidraw is authoritative while document.json and
119
131
  scene.json remain non-authoritative provenance. A patched record makes scene.json authoritative
120
132
  while retaining document.json as provenance. show/list expose these states; edit refuses both.
121
- Formats are scene, excalidraw, and png. generate persists the canonical record before exporting
133
+ Formats are scene, excalidraw, and png. generate and canvas persist the local record before exporting
122
134
  the requested artifact; a later destination failure leaves that record recoverable. If no PNG is
123
135
  stored, export deterministically renders one on demand from the local scene and Excalidraw artifacts,
124
136
  without a browser, network, or record write.
@@ -127,7 +139,7 @@ Exit codes and errors:
127
139
  0 success; 1 internal failure; 2 usage or interactive stdin; 3 invalid input/document;
128
140
  4 build/export construction failure; 5 diagram not found; 6 conflict/busy;
129
141
  7 filesystem/storage failure; 8 unavailable format, render, destination, or write failure;
130
- 10 generate network/endpoint failure; 11 generate timeout; 12 malformed generate output;
142
+ 10 generate/canvas network or endpoint failure; 11 generate timeout; 12 malformed remote output;
131
143
  13 Excalidraw transport, timeout, HTTP, or API-shape failure.
132
144
  Text errors start with "error: CODE". JSON errors use {"ok":false,"command":...,"error":...}.
133
145
  Errors never include stacks.
@@ -135,22 +147,23 @@ Exit codes and errors:
135
147
  Revision recovery and next steps:
136
148
  edit, pull, and restore archive the complete prior authority state before atomic replacement.
137
149
  Use restore --revision N to recover through the CLI without consuming the selected snapshot.
138
- Start with generate for a prompt or create for accepted JSON. Use the returned id with show/list,
139
- edit with a complete replacement document, then export another stored artifact when needed.`,f_=ox("output",["text","json"]).pipe(sV("text"),oS("Result presentation format."),oE("text|json")),fx=ui("sketchi").pipe(us({output:f_}),uo("Turn one prompt into a validated PNG and editable local diagram."),ul("Turn a prompt into a validated PNG and editable local diagram.")),fk=ui("docs",{},()=>U.JkU(function*(){let{output:e}=yield*fx;yield*fi("docs",e,{documentation:fw},fw)})).pipe(uo("Print the complete CLI contracts for agents, automation, storage, formats, safety limits, and errors."),ul("Print complete agent and automation documentation."));function fS(e){return`~/.sketchi/diagrams/${e}`}function fE(e){return e.revisions.map(t=>`${fS(e.manifest.id)}/revisions/${t}`)}function fI(e){return{...nz(e),storagePath:fS(e.manifest.id),revisions:fE(e),document:e.document}}function f$(){return nw.make({code:"unsupported_scene",message:"The linked Excalidraw scene cannot be rendered by this Sketchi CLI.",hint:"Use only the supported v1 elements and Excalifont text, then export a new link.",details:[]})}let fO=U.fn("sketchi.cli.pull.readLink")(function*(e){if("-"!==e)return e;let t=yield*d5;return(yield*t.read({_tag:"File",path:"-"},{content:"share link",maxBytes:4096})).trim()});function fT(e,t){return`${e}: ${t.manifest.id}
150
+ Start with generate for a prompt, canvas for CanvasSpec, or create for accepted canonical JSON.
151
+ Every returned id supports show, list, and export. Edit and patch are only for flowchart,
152
+ mindmap, and sequence records; create a new canvas to replace a Universal CanvasSpec.`,fB=o2("output",["text","json"]).pipe(ov("text"),o3("Result presentation format."),o8("text|json")),fW=uL("sketchi").pipe(uF({output:fB}),uB("Turn one prompt into a validated PNG and editable local diagram."),uW("Turn a prompt into a validated PNG and editable local diagram.")),fq=uL("docs",{},()=>U.JkU(function*(){let{output:e}=yield*fW;yield*fS("docs",e,{documentation:fF},fF)})).pipe(uB("Print the complete CLI contracts for agents, automation, storage, formats, safety limits, and errors."),uW("Print complete agent and automation documentation."));function fY(e){return`~/.sketchi/diagrams/${e}`}function fz(e){return e.revisions.map(t=>`${fY(e.manifest.id)}/revisions/${t}`)}function fX(e){return{...iu(e),storagePath:fY(e.manifest.id),revisions:fz(e),document:e.document}}function fJ(){return nx.make({code:"unsupported_scene",message:"The linked Excalidraw scene cannot be rendered by this Sketchi CLI.",hint:"Use only the supported v1 elements and Excalifont text, then export a new link.",details:[]})}let fG=U.fn("sketchi.cli.pull.readLink")(function*(e){if("-"!==e)return e;let t=yield*n3;return(yield*t.read({_tag:"File",path:"-"},{content:"share link",maxBytes:4096})).trim()});function fV(e,t){return`${e}: ${t.manifest.id}
140
153
  type: ${t.manifest.type}
141
154
  title: ${t.manifest.title}
142
155
  revision: ${String(t.manifest.revision)}
143
156
  authority: ${t.authority}
144
157
  document authoritative: ${String(t.documentAuthoritative)}
145
158
  formats: ${t.manifest.formats.join(",")}
146
- storage: ${fS(t.manifest.id)}`}function fA(e,t){return t.pipe(U.tvg({onFailure:t=>fn("generate",e,t),onSuccess:t=>U.JkU(function*(){var r;let n=yield*d4;t.artifact.stdoutBytes&&(yield*n.stdout(t.artifact.stdoutBytes)),yield*fi("generate",e,{...{...fI((r=t.generated).diagram),generation:{model:r.model,provider:r.provider}},export:fW(t.artifact)},function(e){var t;if(e.interactive)return`created: ${e.generated.diagram.manifest.id}
159
+ storage: ${fY(t.manifest.id)}`}function fK(e,t){return t.pipe(U.tvg({onFailure:t=>fk("generate",e,t),onSuccess:t=>U.JkU(function*(){var r;let n=yield*fb;t.artifact.stdoutBytes&&(yield*n.stdout(t.artifact.stdoutBytes)),yield*fS("generate",e,{...{...fX((r=t.generated).diagram),generation:{model:r.model,provider:r.provider}},export:ht(t.artifact)},function(e){var t;if(e.interactive)return`created: ${e.generated.diagram.manifest.id}
147
160
  artifact: ${e.artifact.destination}
148
161
  next:
149
162
  sketchi show ${e.generated.diagram.manifest.id}
150
- sketchi export ${e.generated.diagram.manifest.id} --format excalidraw --dest ${e.generated.diagram.manifest.id}.excalidraw`;let r=fq(e.artifact);return[[fT("created",(t=e.generated).diagram).replace(/^created:/u,"generated:"),`provider: ${t.provider}`,`model: ${t.model}`].join("\n"),`format: ${e.artifact.format}`,`destination: ${e.artifact.destination}`,`bytes: ${String(e.artifact.sizeBytes)}`,...r?[`hint: ${r}`]:[]].join("\n")}(t),"-"===t.artifact.destination?"stderr":"stdout")})}))}function fC(e){let t=fE(e);return[`id: ${e.manifest.id}`,`type: ${e.manifest.type}`,`title: ${e.manifest.title}`,`revision: ${String(e.manifest.revision)}`,`authority: ${e.authority}`,`document authoritative: ${String(e.documentAuthoritative)}`,`formats: ${e.manifest.formats.join(",")}`,`revisions: ${0===t.length?"none":t.join(",")}`,"document:",nA(e.document).trimEnd()].join("\n")}function fN(e){return 0===e.length?"no diagrams":["id type revision authority document-authoritative formats title",...e.map(e=>[e.id,e.type,String(e.revision),e.authority,String(e.documentAuthoritative),e.formats.join(","),e.title].join(" "))].join("\n")}let fM=`Create one persisted diagram and export its PNG by default. With no --prompt, Sketchi opens a short wizard only when stdin and stdout are human TTYs, output is text, and CI is absent. Pipes, redirects, CI, and --output json never prompt or block; pass --prompt for every script and automation path. This is one of Sketchi's three explicit network commands (generate, share, pull). It makes one unauthenticated HTTPS POST to the public Sketchi generate API and needs no token, key, account, or login.
163
+ sketchi export ${e.generated.diagram.manifest.id} --format excalidraw --dest ${e.generated.diagram.manifest.id}.excalidraw`;let r=hr(e.artifact);return[[fV("created",(t=e.generated).diagram).replace(/^created:/u,"generated:"),`provider: ${t.provider}`,`model: ${t.model}`].join("\n"),`format: ${e.artifact.format}`,`destination: ${e.artifact.destination}`,`bytes: ${String(e.artifact.sizeBytes)}`,...r?[`hint: ${r}`]:[]].join("\n")}(t),"-"===t.artifact.destination?"stderr":"stdout")})}))}function fH(e){let t=fz(e);return[`id: ${e.manifest.id}`,`type: ${e.manifest.type}`,`title: ${e.manifest.title}`,`revision: ${String(e.manifest.revision)}`,`authority: ${e.authority}`,`document authoritative: ${String(e.documentAuthoritative)}`,`formats: ${e.manifest.formats.join(",")}`,`revisions: ${0===t.length?"none":t.join(",")}`,"document:",nR(e.document).trimEnd()].join("\n")}function fQ(e){return 0===e.length?"no diagrams":["id type revision authority document-authoritative formats title",...e.map(e=>[e.id,e.type,String(e.revision),e.authority,String(e.documentAuthoritative),e.formats.join(","),e.title].join(" "))].join("\n")}let fZ=`Create one persisted diagram and export its PNG by default. With no --prompt, Sketchi opens a short wizard only when stdin and stdout are human TTYs, output is text, and CI is absent. Pipes, redirects, CI, and --output json never prompt or block; pass --prompt for every script and automation path. This is one of Sketchi's four explicit network commands (generate, canvas, share, pull). It makes one unauthenticated HTTPS POST to the public Sketchi generate API and needs no token, key, account, or login.
151
164
 
152
165
  Everyday wizard:
153
- The wizard asks only for prompt text, flowchart (default) or mind map, and a PNG destination.
166
+ The wizard asks only for prompt text, flowchart (default), mind map, or sequence diagram, and a PNG destination.
154
167
  Current directory writes <cwd>/<generated-id>.png. Project diagrams folder means exactly the
155
168
  directory where Sketchi was run: <cwd>/diagrams/<generated-id>.png, with no Git detection; the
156
169
  diagrams folder is created only after generation succeeds. Explicit --type and file --dest values
@@ -158,11 +171,13 @@ Everyday wizard:
158
171
  format or --dest - because the interactive wizard writes only PNG files.
159
172
 
160
173
  Network and options:
161
- Endpoint: ${iK}
174
+ Endpoint: ${ab}
162
175
  The model call, schema validation, and quality gate run server-side; the finished diagram
163
176
  and Excalidraw artifact are returned over plain HTTPS. Sketchi sends no credentials.
164
- --type defaults to flowchart; --model defaults to ${iV}.
165
- Override the endpoint for preview or local testing with ${iH}
177
+ Without --type, the model selects flowchart, mindmap, or sequence from the request.
178
+ Explicit er, architecture, swimlane, and state-machine requests fail with a typed unsupported error.
179
+ --model defaults to ${ay}.
180
+ Override the endpoint for preview or local testing with ${av}
166
181
  or --endpoint URL. --format defaults to png. Without --dest, the artifact is written as
167
182
  <generated-id>.png, <generated-id>.excalidraw, or <generated-id>.scene.json in the current
168
183
  directory. --dest PATH|- overrides that path. --output text|json controls only the status envelope.
@@ -179,53 +194,70 @@ Errors and next steps:
179
194
  a rejected or invalid generated document uses 3, conflict uses 6, and storage uses 7.
180
195
  With --dest -, stdout contains artifact bytes only and all status uses stderr. On success, pass
181
196
  the returned id to show, edit, list, or export. For strictly offline manual authoring, accepted
182
- canonical JSON examples, and full error contracts, run sketchi docs.`,fP=ui("generate",{prompt:oI(sF("flag","prompt").pipe(oS("Diagram request text sent directly without interactive prompts."),oE("TEXT"))),type:oI(ox("type",["flowchart","mindmap"]).pipe(oS("Requested canonical diagram type; default flowchart."),oE("flowchart|mindmap"))),model:sF("flag","model").pipe(sV(iV),oS(`Server-routed generation model id; default ${iV}.`),oE("MODEL")),endpoint:sF("flag","endpoint").pipe(sV(process.env[iH]?.trim()||iK),oS("Unauthenticated generate API URL; defaults to the production Sketchi endpoint."),oE("URL")),format:oI(ox("format",["png","excalidraw","scene"]).pipe(oS("Artifact exported after generation; default png."),oE("png|excalidraw|scene"))),destination:oI(sF("flag","dest").pipe(oS("Artifact destination; defaults from the generated id, or - for stdout."),oE("PATH|-")))},e=>U.JkU(function*(){let{output:t}=yield*fx,r=K.getOrUndefined(e.prompt),n=K.getOrUndefined(e.type),i=K.getOrUndefined(e.format),a=K.getOrUndefined(e.destination);if(void 0===r){if(!function({stdinIsTTY:e,stdoutIsTTY:t,output:r,continuousIntegration:n}){return e&&t&&"text"===r&&!n}({stdinIsTTY:!0===process.stdin.isTTY,stdoutIsTTY:!0===process.stdout.isTTY,output:t,continuousIntegration:aQ()}))return yield*new sl({option:"prompt"});if(void 0!==i&&"png"!==i)return yield*dz("format",i,"png when --prompt is omitted; pass --prompt for excalidraw or scene generation");if("-"===a)return yield*dz("dest",a,"a file path when --prompt is omitted; pass --prompt to write an artifact to stdout");let r=yield*aZ;return void(yield*fA(t,U.P1j(U.JkU(function*(){let t=yield*r.ask({...void 0===n?{}:{type:n},...void 0===a?{}:{destination:{_tag:"Custom",path:a}}}),i=yield*r.activity,s=yield*i3({endpoint:e.endpoint,model:e.model,prompt:t.prompt,type:t.type,format:"png",destination:function(e){switch(e._tag){case"CurrentDirectory":return{_tag:"CurrentDirectory",cwd:process.cwd()};case"ProjectDiagrams":return{_tag:"ProjectDiagrams",cwd:process.cwd()};case"Custom":return e}}(t.destination)});return yield*i.succeed("Diagram ready"),{...s,interactive:!0}}))))}yield*fA(t,i3({endpoint:e.endpoint,model:e.model,prompt:r,type:n??"flowchart",format:i??"png",destination:void 0===a?{_tag:"Default"}:{_tag:"Custom",path:a}}).pipe(U.TjK(e=>({...e,interactive:!1}))))})).pipe(uo(fM),ul("Create a PNG with the wizard or a direct --prompt."),uc([{command:'sketchi generate --prompt "Map release approval with pass and revise branches"',description:`Generate a flowchart with ${iV} and write its PNG.`},{command:'sketchi generate --prompt "Organize launch readiness" --type mindmap --format excalidraw --dest launch.excalidraw --output json',description:"Generate a mindmap and write editable Excalidraw."}])),fR=ui("create",dJ(),({source:e})=>U.JkU(function*(){let{output:t}=yield*fx,r=yield*nM,n=yield*ik,i=U.JkU(function*(){let t=yield*d6(e),i=yield*r.build(t);return yield*n.create(i)});yield*fa("create",t,i,e=>fT("created",e),fI)})).pipe(uo("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."),ul("Create a local diagram from canonical JSON."),uc([{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."}])),fj=ui("show",{diagramId:sF(sj,"diagram-id")},({diagramId:e})=>U.JkU(function*(){let{output:t}=yield*fx,r=yield*ik,n=nN(e).pipe(U.qIB(e=>r.show(e)));yield*fa("show",t,n,fC,fI)})).pipe(uo("Show current authority, documentAuthoritative state, retained document provenance, manifest formats, and recoverable revision paths for DIAGRAM_ID. This is strictly offline and does not rebuild or mutate the record."),ul("Inspect one local diagram."),uc([{command:"sketchi show release-flow --output json",description:"Read a record as a stable JSON envelope."}])),fD=ui("edit",{diagramId:sF(sj,"diagram-id"),...dJ()},({diagramId:e,source:t})=>U.JkU(function*(){let{output:r}=yield*fx,n=yield*nM,i=yield*ik,a=U.JkU(function*(){let r=yield*nN(e),a=yield*d6(t),s=yield*n.build(a);return s.id!==r?yield*nm.make({message:`Edited document id "${s.id}" does not match "${r}".`,hint:"Keep spec.id equal to the diagram id being edited.",details:["spec.id"]}):yield*i.edit(r,s)});yield*fa("edit",r,a,e=>fT("edited",e),fI)})).pipe(uo("Replace the complete canonical document for DIAGRAM_ID. Sketchi validates and builds first, preserves the prior full authority state under revisions/, and atomically swaps the record. Patched and detached records refuse edit because their canonical document is no longer authoritative. The new spec.id must match DIAGRAM_ID."),ul("Replace a canonical diagram document."),uc([{command:"sketchi edit release-flow --file revised.json",description:"Replace a document and retain the prior revision."}])),fL=ui("patch",{diagramId:sF(sj,"diagram-id"),...dJ("patch request")},({diagramId:e,source:t})=>U.JkU(function*(){let{output:r}=yield*fx,n=yield*dH,i=yield*ik,a=U.JkU(function*(){let r=yield*nN(e),a=yield*d9(t),s=yield*i.readPatchSource(r),o=yield*n.patch(s.scene,a,`cli-patch-${r}-${String(s.revision+1)}`);return yield*i.commitPatch(r,s.revision,o)});yield*fa("patch",r,a,e=>fT("patched",e),fI)})).pipe(uo("Apply Sketchi semantic setStyle, setDefaultStyle, setShape, translate, replaceText, or rerouteEdges operations to the current stored scene. The CLI owns source and requestId; input contains operations plus optional options or intent. The prior full revision is recoverable, document.json remains unchanged provenance, stale stored PNG is removed, and the patched scene becomes authoritative. This command is strictly offline. Edit remains blocked until a canonical revision is restored."),ul("Apply semantic edits to a stored diagram."),uc([{command:'sketchi patch release-flow --json \'{"operations":[{"op":"setStyle","selector":{"nodeIds":["review","approve"]},"style":{"fillColor":"#dbeafe","strokeColor":"#2563eb","textColor":"#1e3a8a"}}]}\'',description:"Color selected nodes through semantic ids."},{command:"sketchi patch release-flow --file patch.json --output json",description:"Patch from a file, then export or restore the reported diagram revision."}])),fU=ui("list",{},()=>U.JkU(function*(){let{output:e}=yield*fx,t=yield*ik;yield*fa("list",e,t.list(),fN)})).pipe(uo("List local diagrams in ascending id order with type, revision, authority, documentAuthoritative, current stored formats, and retained title provenance. The command is deterministic, strictly offline, and read-only."),ul("List local diagrams."),uc([{command:"sketchi list --output json",description:"List records as a stable JSON envelope."}])),fF=ui("share",{diagramId:sF(sj,"diagram-id"),open:o_("open").pipe(oS("Hand the bearer link to the default OS browser opener."))},({diagramId:e,open:t})=>U.JkU(function*(){let{output:r}=yield*fx,n=yield*ik,i=yield*fm,a=yield*fh,s=U.JkU(function*(){let r=yield*nN(e),s=yield*n.readExportSource(r,"excalidraw");if("StoredArtifact"!==s._tag)return yield*nw.make({code:"unsupported_scene",message:`Diagram "${r}" has no authoritative Excalidraw artifact.`,hint:"Restore or rebuild the diagram before sharing it.",details:[]});let o=yield*U.SvU({try:()=>JSON.parse(new TextDecoder().decode(s.bytes)),catch:f$}),l=yield*i.share(o),c=t?yield*a.open(l.link):{status:"not_requested"};return{id:r,link:l.link,open:c,hint:"this immutable link is a bearer snapshot: anyone with the full URL can decrypt it, so share it only with the intended user. Browser edits do not update this link; after editing, choose Save to… → Export to Link and return the new link for sketchi pull."}});yield*s.pipe(U.tvg({onFailure:e=>fn("share",r,e),onSuccess:e=>U.JkU(function*(){if(yield*fi("share",r,e,`shared: ${e.id}
197
+ canonical JSON examples, and full error contracts, run sketchi docs.`,f0=uL("generate",{prompt:o6(ou("flag","prompt").pipe(o3("Diagram request text sent directly without interactive prompts."),o8("TEXT"))),type:o6(o2("type",["flowchart","mindmap","sequence","er","architecture","swimlane","state-machine"]).pipe(o3("Authoritative type; unsupported native requests fail clearly; omit for model selection."),o8("TYPE"))),model:ou("flag","model").pipe(ov(ay),o3(`Server-routed generation model id; default ${ay}.`),o8("MODEL")),endpoint:ou("flag","endpoint").pipe(ov(process.env[av]?.trim()||ab),o3("Unauthenticated generate API URL; defaults to the production Sketchi endpoint."),o8("URL")),format:o6(o2("format",["png","excalidraw","scene"]).pipe(o3("Artifact exported after generation; default png."),o8("png|excalidraw|scene"))),destination:o6(ou("flag","dest").pipe(o3("Artifact destination; defaults from the generated id, or - for stdout."),o8("PATH|-")))},e=>U.JkU(function*(){let{output:t}=yield*fW,r=K.getOrUndefined(e.prompt),n=K.getOrUndefined(e.type),i=K.getOrUndefined(e.format),a=K.getOrUndefined(e.destination);if(void 0===r){if(!function({stdinIsTTY:e,stdoutIsTTY:t,output:r,continuousIntegration:n}){return e&&t&&"text"===r&&!n}({stdinIsTTY:!0===process.stdin.isTTY,stdoutIsTTY:!0===process.stdout.isTTY,output:t,continuousIntegration:s_()}))return yield*new sW({option:"prompt"});if(void 0!==i&&"png"!==i)return yield*fy("format",i,"png when --prompt is omitted; pass --prompt for excalidraw or scene generation");if("-"===a)return yield*fy("dest",a,"a file path when --prompt is omitted; pass --prompt to write an artifact to stdout");if(void 0!==n&&"flowchart"!==n&&"mindmap"!==n&&"sequence"!==n)return yield*fy("type",n,"flowchart, mindmap, or sequence in the interactive wizard; pass --prompt to receive the typed unsupported-type error");let r=yield*sk;return void(yield*fK(t,U.P1j(U.JkU(function*(){let t=yield*r.ask({...void 0===n?{}:{type:n},...void 0===a?{}:{destination:{_tag:"Custom",path:a}}}),i=yield*r.activity,s=yield*aO({endpoint:e.endpoint,model:e.model,prompt:t.prompt,type:t.type,format:"png",destination:function(e){switch(e._tag){case"CurrentDirectory":return{_tag:"CurrentDirectory",cwd:process.cwd()};case"ProjectDiagrams":return{_tag:"ProjectDiagrams",cwd:process.cwd()};case"Custom":return e}}(t.destination)});return yield*i.succeed("Diagram ready"),{...s,interactive:!0}}))))}yield*fK(t,aO({endpoint:e.endpoint,model:e.model,prompt:r,...n?{type:n}:{},format:i??"png",destination:void 0===a?{_tag:"Default"}:{_tag:"Custom",path:a}}).pipe(U.TjK(e=>({...e,interactive:!1}))))})).pipe(uB(fZ),uW("Create a PNG with the wizard or a direct --prompt."),uq([{command:'sketchi generate --prompt "Map release approval with pass and revise branches"',description:`Generate a flowchart with ${ay} and write its PNG.`},{command:'sketchi generate --prompt "Organize launch readiness" --type mindmap --format excalidraw --dest launch.excalidraw --output json',description:"Generate a mindmap and write editable Excalidraw."},{command:'sketchi generate --prompt "Show Browser calling API" --type sequence --dest request-sequence.png',description:"Generate a native sequence diagram and write its PNG."}])),f1=`Build a complete Universal CanvasSpec through Sketchi's public create-canvas API, preserve the validated scene and Excalidraw result in the local store, and export PNG by default. This command is direct and noninteractive: pass exactly one CanvasSpec with --file PATH, --file - for piped stdin, or --json VALUE.
198
+
199
+ Network and options:
200
+ Endpoint: ${i9}
201
+ Override it for preview or local testing with ${i4} or --endpoint URL.
202
+ The request asks the server for scene and Excalidraw artifacts, validates the typed response,
203
+ stores the normalized CanvasSpec plus Excalidraw output, then exports locally. --format defaults
204
+ to png; --dest defaults to <diagramId>.png, <diagramId>.excalidraw, or
205
+ <diagramId>.scene.json. Use --dest - for artifact-only stdout and --output json for a stable
206
+ status envelope on stderr.
207
+
208
+ Input and failures:
209
+ Input must be the CanvasSpec object itself, not a create-canvas request wrapper and not raw
210
+ Excalidraw JSON. Interactive stdin is rejected with exit 2. Invalid JSON or CanvasSpec exits 3;
211
+ a typed server rejection exits 4; network/endpoint failure exits 10; malformed response exits 12.
212
+ The local record is committed before export, so a destination failure reports a concrete
213
+ sketchi export recovery command. The existing sketchi create command remains the strictly
214
+ offline path for accepted flowchart, mindmap, and sequence documents.`,f2=uL("canvas",{...fg("CanvasSpec document"),endpoint:ou("flag","endpoint").pipe(ov(process.env[i4]?.trim()||i9),o3("Unauthenticated create-canvas API URL; defaults to production."),o8("URL")),format:o2("format",["png","excalidraw","scene"]).pipe(ov("png"),o3("Artifact exported after the canvas is created."),o8("png|excalidraw|scene")),destination:o6(ou("flag","dest").pipe(o3("Artifact destination; defaults from diagramId, or - for stdout."),o8("PATH|-")))},({destination:e,endpoint:t,format:r,source:n})=>U.JkU(function*(){let{output:i}=yield*fW,a=U.JkU(function*(){let i=yield*ai(n),a=yield*ac({endpoint:t,spec:i}),s=yield*aE(a.diagram,r,K.match(e,{onNone:()=>({_tag:"Default"}),onSome:e=>({_tag:"Custom",path:e})}));return{...a,artifact:s}});yield*a.pipe(U.tvg({onFailure:e=>fk("canvas",i,e),onSuccess:e=>U.JkU(function*(){let t,r=yield*fb;e.artifact.stdoutBytes&&(yield*r.stdout(e.artifact.stdoutBytes)),yield*fS("canvas",i,{...fX(e.diagram),remoteArtifactId:e.artifactId,export:ht(e.artifact)},(t=hr(e.artifact),[fV("created",e.diagram).replace(/^created:/u,"canvas:"),`remote artifact: ${e.artifactId}`,`format: ${e.artifact.format}`,`destination: ${e.artifact.destination}`,`bytes: ${String(e.artifact.sizeBytes)}`,...t?[`hint: ${t}`]:[]].join("\n")),"-"===e.artifact.destination?"stderr":"stdout")})}))})).pipe(uB(f1),uW("Build and export a typed Universal CanvasSpec."),uq([{command:"sketchi canvas --file canvas.json --output json",description:"Build a CanvasSpec, store it locally, and write its PNG."},{command:"sketchi canvas --file - --format excalidraw --dest canvas.excalidraw",description:"Read CanvasSpec from stdin and export editable Excalidraw."}])),f5=uL("create",fg(),({source:e})=>U.JkU(function*(){let{output:t}=yield*fW,r=yield*nL,n=yield*iU,i=U.JkU(function*(){let t=yield*n9(e),i=yield*r.build(t);return yield*n.create(i)});yield*fI("create",t,i,e=>fV("created",e),fX)})).pipe(uB("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."),uW("Create a local diagram from canonical JSON."),uq([{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."}])),f3=uL("show",{diagramId:ou(os,"diagram-id")},({diagramId:e})=>U.JkU(function*(){let{output:t}=yield*fW,r=yield*iU,n=nD(e).pipe(U.qIB(e=>r.show(e)));yield*fI("show",t,n,fH,fX)})).pipe(uB("Show current authority, documentAuthoritative state, retained document provenance, manifest formats, and recoverable revision paths for DIAGRAM_ID. This is strictly offline and does not rebuild or mutate the record."),uW("Inspect one local diagram."),uq([{command:"sketchi show release-flow --output json",description:"Read a record as a stable JSON envelope."}])),f8=uL("edit",{diagramId:ou(os,"diagram-id"),...fg()},({diagramId:e,source:t})=>U.JkU(function*(){let{output:r}=yield*fW,n=yield*nL,i=yield*iU,a=U.JkU(function*(){let r=yield*nD(e),a=yield*n9(t),s=yield*n.build(a);return s.id!==r?yield*nm.make({message:`Edited document id "${s.id}" does not match "${r}".`,hint:"Keep spec.id equal to the diagram id being edited.",details:["spec.id"]}):yield*i.edit(r,s)});yield*fI("edit",r,a,e=>fV("edited",e),fX)})).pipe(uB("Replace the complete canonical document for DIAGRAM_ID. Sketchi validates and builds first, preserves the prior full authority state under revisions/, and atomically swaps the record. Patched and detached records refuse edit because their canonical document is no longer authoritative. The new spec.id must match DIAGRAM_ID."),uW("Replace a canonical diagram document."),uq([{command:"sketchi edit release-flow --file revised.json",description:"Replace a document and retain the prior revision."}])),f6=uL("patch",{diagramId:ou(os,"diagram-id"),...fg("patch request")},({diagramId:e,source:t})=>U.JkU(function*(){let{output:r}=yield*fW,n=yield*nQ,i=yield*iU,a=U.JkU(function*(){let r=yield*nD(e),a=yield*n4(t),s=yield*i.readPatchSource(r),o=yield*n.patch(s.scene,a,`cli-patch-${r}-${String(s.revision+1)}`);return yield*i.commitPatch(r,s.revision,o)});yield*fI("patch",r,a,e=>fV("patched",e),fX)})).pipe(uB("Apply Sketchi semantic setStyle, setDefaultStyle, setShape, translate, replaceText, or rerouteEdges operations to the current stored scene. The CLI owns source and requestId; input contains operations plus optional options or intent. The prior full revision is recoverable, document.json remains unchanged provenance, stale stored PNG is removed, and the patched scene becomes authoritative. This command is strictly offline. Edit remains blocked until a canonical revision is restored."),uW("Apply semantic edits to a stored diagram."),uq([{command:'sketchi patch release-flow --json \'{"operations":[{"op":"setStyle","selector":{"nodeIds":["review","approve"]},"style":{"fillColor":"#dbeafe","strokeColor":"#2563eb","textColor":"#1e3a8a"}}]}\'',description:"Color selected nodes through semantic ids."},{command:"sketchi patch release-flow --file patch.json --output json",description:"Patch from a file, then export or restore the reported diagram revision."}])),f9=uL("list",{},()=>U.JkU(function*(){let{output:e}=yield*fW,t=yield*iU;yield*fI("list",e,t.list(),fQ)})).pipe(uB("List local diagrams in ascending id order with type, revision, authority, documentAuthoritative, current stored formats, and retained title provenance. The command is deterministic, strictly offline, and read-only."),uW("List local diagrams."),uq([{command:"sketchi list --output json",description:"List records as a stable JSON envelope."}])),f4=uL("share",{diagramId:ou(os,"diagram-id"),open:o1("open").pipe(o3("Hand the bearer link to the default OS browser opener."))},({diagramId:e,open:t})=>U.JkU(function*(){let{output:r}=yield*fW,n=yield*iU,i=yield*fR,a=yield*fN,s=U.JkU(function*(){let r=yield*nD(e),s=yield*n.readExportSource(r,"excalidraw");if("StoredArtifact"!==s._tag)return yield*nx.make({code:"unsupported_scene",message:`Diagram "${r}" has no authoritative Excalidraw artifact.`,hint:"Restore or rebuild the diagram before sharing it.",details:[]});let o=yield*U.SvU({try:()=>JSON.parse(new TextDecoder().decode(s.bytes)),catch:fJ}),l=yield*i.share(o),c=t?yield*a.open(l.link):{status:"not_requested"};return{id:r,link:l.link,open:c,hint:"this immutable link is a bearer snapshot: anyone with the full URL can decrypt it, so share it only with the intended user. Browser edits do not update this link; after editing, choose Save to… → Export to Link and return the new link for sketchi pull."}});yield*s.pipe(U.tvg({onFailure:e=>fk("share",r,e),onSuccess:e=>U.JkU(function*(){if(yield*fS("share",r,e,`shared: ${e.id}
183
215
  link: ${e.link}
184
216
  open: ${e.open.status}
185
- hint: ${e.hint}`),"text"===r&&"unconfirmed"===e.open.status){let e=yield*d4;yield*e.stderr("notice: the OS browser opener could not be confirmed; the share link is still valid.\n")}})}))})).pipe(uo(`Encrypt and upload the current authoritative Excalidraw artifact as one immutable excalidraw.com bearer snapshot. This makes exactly one credential-free HTTPS request. The storage service can observe connection metadata, timing, and ciphertext size; retention is uncontrolled, and Sketchi cannot revoke or delete a link. Anyone with the full URL can decrypt it. Supported elements: rectangle, ellipse, diamond, arrow, line, freedraw, text; text must use Excalifont fontFamily 5; files and images are rejected. Render limits: element dimension ${String(8192)}, canvas dimension ${String(8192)}, canvas area ${String(n6.Z4)}, final PNG pixels ${String(n6.ce)}. --open is opt-in and only confirms whether the OS accepted the request.`),ul("Share an encrypted Excalidraw snapshot.")),fB=ui("pull",{diagramId:sF(sj,"diagram-id"),link:(P="URL|-",R="Excalidraw bearer share URL, or - for noninteractive stdin.",Object.assign(Object.create(Object.getPrototypeOf(N=sF("flag",M="link").pipe(oE(P),oS(R)))),N,{parse:e=>(e.flags[M]?.length??0)===1?N.parse(e):U.fJG(new su({option:M,value:(e.flags[M]?.length??0)===0?"not provided":"provided more than once",expected:`exactly one --${M} ${P}`,kind:"flag"}))}))},({diagramId:e,link:t})=>U.JkU(function*(){let{output:r}=yield*fx,n=U.JkU(function*(){let r=yield*fb(e),n=yield*fO(t);return yield*fv(e,n,r)});yield*fa("pull",r,n,({diagram:e})=>`pulled: ${e.manifest.id}
217
+ hint: ${e.hint}`),"text"===r&&"unconfirmed"===e.open.status){let e=yield*fb;yield*e.stderr("notice: the OS browser opener could not be confirmed; the share link is still valid.\n")}})}))})).pipe(uB(`Encrypt and upload the current authoritative Excalidraw artifact as one immutable excalidraw.com bearer snapshot. This makes exactly one credential-free HTTPS request. The storage service can observe connection metadata, timing, and ciphertext size; retention is uncontrolled, and Sketchi cannot revoke or delete a link. Anyone with the full URL can decrypt it. Supported elements: rectangle, ellipse, diamond, arrow, line, freedraw, text; text must use Excalifont fontFamily 5; files and images are rejected. Render limits: element dimension ${String(8192)}, canvas dimension ${String(8192)}, canvas area ${String(ip.Z4)}, final PNG pixels ${String(ip.ce)}. --open is opt-in and only confirms whether the OS accepted the request.`),uW("Share an encrypted Excalidraw snapshot.")),f7=uL("pull",{diagramId:ou(os,"diagram-id"),link:(P="URL|-",R="Excalidraw bearer share URL, or - for noninteractive stdin.",Object.assign(Object.create(Object.getPrototypeOf(M=ou("flag",N="link").pipe(o8(P),o3(R)))),M,{parse:e=>(e.flags[N]?.length??0)===1?M.parse(e):U.fJG(new sY({option:N,value:(e.flags[N]?.length??0)===0?"not provided":"provided more than once",expected:`exactly one --${N} ${P}`,kind:"flag"}))}))},({diagramId:e,link:t})=>U.JkU(function*(){let{output:r}=yield*fW,n=U.JkU(function*(){let r=yield*fL(e),n=yield*fG(t);return yield*fU(e,n,r)});yield*fI("pull",r,n,({diagram:e})=>`pulled: ${e.manifest.id}
186
218
  revision: ${String(e.manifest.revision)}
187
219
  authority: ${e.authority}
188
- source identity: unverified`,({diagram:e,sourceIdentity:t})=>({id:e.manifest.id,revision:e.manifest.revision,authority:e.authority,documentAuthoritative:e.documentAuthoritative,formats:e.manifest.formats,revisions:fE(e),sourceIdentity:t}))})).pipe(uo(`Fetch exactly one current-format excalidraw.com bearer snapshot, decrypt it locally, restore and strictly validate it, prove detached PNG renderability, then atomically preserve the prior full record and replace diagram.excalidraw as detached authority. The link carries no trusted Sketchi identity and may be unrelated to DIAGRAM_ID. This makes exactly one credential-free HTTPS request and never echoes or stores the input link or key. Supported elements: rectangle, ellipse, diamond, arrow, line, freedraw, text; text must use Excalifont fontFamily 5; files, images, external resources, and other fonts are rejected. Render limits: element dimension ${String(8192)}, canvas dimension ${String(8192)}, canvas area ${String(n6.Z4)}, final PNG pixels ${String(n6.ce)}.`),ul("Pull browser edits from an Excalidraw link.")),fY=ui("restore",{diagramId:sF(sj,"diagram-id"),revision:sU({name:"revision",primitiveType:sC,kind:"flag"}).pipe(oO(e=>e>0,e=>`Expected a positive revision, got ${String(e)}`),oE("N"),oS("Archived revision number to restore without consuming it."))},({diagramId:e,revision:t})=>U.JkU(function*(){let{output:r}=yield*fx,n=yield*ik,i=yield*nM,a=U.JkU(function*(){let r=yield*nN(e),a=yield*n.readRevision(r,t);return"LegacyDocument"===a._tag?yield*i.build(a.document).pipe(U.qIB(e=>n.restore(r,t,e))):yield*n.restore(r,t)});yield*fa("restore",r,a,e=>`restored: ${e.diagram.manifest.id}
220
+ source identity: unverified`,({diagram:e,sourceIdentity:t})=>({id:e.manifest.id,revision:e.manifest.revision,authority:e.authority,documentAuthoritative:e.documentAuthoritative,formats:e.manifest.formats,revisions:fz(e),sourceIdentity:t}))})).pipe(uB(`Fetch exactly one current-format excalidraw.com bearer snapshot, decrypt it locally, restore and strictly validate it, prove detached PNG renderability, then atomically preserve the prior full record and replace diagram.excalidraw as detached authority. The link carries no trusted Sketchi identity and may be unrelated to DIAGRAM_ID. This makes exactly one credential-free HTTPS request and never echoes or stores the input link or key. Supported elements: rectangle, ellipse, diamond, arrow, line, freedraw, text; text must use Excalifont fontFamily 5; files, images, external resources, and other fonts are rejected. Render limits: element dimension ${String(8192)}, canvas dimension ${String(8192)}, canvas area ${String(ip.Z4)}, final PNG pixels ${String(ip.ce)}.`),uW("Pull browser edits from an Excalidraw link.")),he=uL("restore",{diagramId:ou(os,"diagram-id"),revision:oc({name:"revision",primitiveType:ot,kind:"flag"}).pipe(o4(e=>e>0,e=>`Expected a positive revision, got ${String(e)}`),o8("N"),o3("Archived revision number to restore without consuming it."))},({diagramId:e,revision:t})=>U.JkU(function*(){let{output:r}=yield*fW,n=yield*iU,i=yield*nL,a=U.JkU(function*(){let r=yield*nD(e),a=yield*n.readRevision(r,t);return"LegacyDocument"===a._tag?yield*i.build(a.document).pipe(U.qIB(e=>n.restore(r,t,e))):yield*n.restore(r,t)});yield*fI("restore",r,a,e=>`restored: ${e.diagram.manifest.id}
189
221
  from revision: ${String(e.restoredFromRevision)}
190
222
  revision: ${String(e.diagram.manifest.revision)}
191
- authority: ${e.diagram.authority}`,e=>({id:e.diagram.manifest.id,restoredFromRevision:e.restoredFromRevision,revision:e.diagram.manifest.revision,authority:e.diagram.authority,documentAuthoritative:e.diagram.documentAuthoritative,formats:e.diagram.manifest.formats,revisions:fE(e.diagram)}))})).pipe(uo("Strictly offline recovery. Archive the current full state first, then restore revision N byte-for-byte without consuming it and commit at the next monotonic revision. Full snapshots restore artifacts and authority without rebuilding; legacy document-only revisions rebuild only while the record remains canonical."),ul("Restore a retained diagram revision."));function fW(e){let t=fq(e);return{id:e.id,format:e.format,destination:e.destination,sizeBytes:e.sizeBytes,...t?{hint:t}:{}}}function fq(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 fX=ui("export",{diagramId:sF(sj,"diagram-id"),format:ox("format",["scene","excalidraw","png"]).pipe(oS("Artifact format to export or render on demand."),oE("scene|excalidraw|png")),destination:sF("flag","dest").pipe(oS("Artifact byte destination path, or - for stdout."),oE("PATH|-"))},({destination:e,diagramId:t,format:r})=>U.JkU(function*(){let{output:n}=yield*fx,i=yield*iX,a=U.JkU(function*(){let n=yield*nN(t),a=yield*i.exportArtifact(n,r);return"-"!==e&&(yield*iq(e,a)),{id:n,format:r,destination:e,sizeBytes:a.byteLength,..."-"===e?{stdoutBytes:a}:{}}});yield*a.pipe(U.tvg({onFailure:e=>fn("export",n,e),onSuccess:e=>U.JkU(function*(){let t=yield*d4;e.stdoutBytes&&(yield*t.stdout(e.stdoutBytes));let r=fW(e),i=fq(e),a=[`exported: ${e.id}`,`format: ${e.format}`,`destination: ${e.destination}`,`bytes: ${String(e.sizeBytes)}`,...i?[`hint: ${i}`]:[]].join("\n");yield*fi("export",n,r,a,"stderr")})}))})).pipe(uo("Strictly offline export of a current stored artifact or on-demand PNG. Canonical PNG uses scene plus Excalidraw; detached PNG restores diagram.excalidraw directly, uses its viewBackgroundColor, and adds no stale canonical title. Detached scene export is unavailable. Rendering never starts a browser or network request and never writes the PNG back. Status always uses stderr, so --dest - leaves stdout byte-only. Render or write failures exit 8."),ul("Export scene, Excalidraw, or PNG bytes."),uc([{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."}])),fJ=fx.pipe(ua([fP,fk,fR,fj,fD,fL,fU,fY,fF,fB,fX])),fz=U.fn("sketchi.cli.run")(function*(e){let t,r,n,i,a,s,o,l,c,u,d=(t=e.lastIndexOf("--output"))>=0&&"json"===e[t+1]||e.some(e=>"--output=json"===e)?"json":"text";return yield*(r=oe({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=e.find(e=>dW.has(e)),s=e.every((t,r)=>"--output"===t||"--output=text"===t||"--output=json"===t||"--output"===e[r-1]&&("text"===t||"json"===t)),o=void 0===a&&(0===e.length||n||s),l=a??"sketchi",c={...r,formatHelpDoc:e=>{let t=r.formatHelpDoc(e).replace(/[ \t]+$/gmu,"");return i&&o?`${JSON.stringify({ok:!0,command:"sketchi",data:{help:dL({colors:"none",background:"dark"})}},null,2)}
192
- `:i&&!n?"":o?function(){let e,t,r=void 0===process.stdout.columns||process.stdout.columns<=0?80:process.stdout.columns,n=function(e=process.env){if("dumb"===e.TERM||"linux"===e.TERM)return!1;let t=[e.LC_ALL,e.LC_CTYPE,e.LANG].find(e=>void 0!==e&&e.length>0);return void 0!==t&&/(?:^|[._-])utf-?8(?:@|$)/iu.test(t)}();if(void 0!==process.env.NO_COLOR||"dumb"===process.env.TERM||"ansi"===process.env.TERM||!0!==process.stdout.isTTY)return dL({colors:"none",background:"dark",unicode:n,width:r});let i=process.stdout.hasColors(0x1000000)?"truecolor":process.stdout.hasColors(256)?"ansi256":"none";if("none"===i)return dL({colors:"none",background:"dark",unicode:n,width:r});let a=(e=process.env.COLORFGBG,(t=e?.split(";").at(-1))&&/^\d+$/u.test(t)?function(e,t){let r=dU(e);if(void 0===r)return{background:"dark",readable:!1};let n=dY(r,"dark",t),i=dY(r,"light",t);return{background:n>=i?"dark":"light",readable:Math.max(n,i)>=4.5}}(Number(t),i):{background:"dark",readable:!0});return a.readable?dL({colors:i,background:a.background,unicode:n,width:r}):dL({colors:"none",background:a.background,unicode:n,width:r})}():t},formatErrors:e=>{let t=e.map(e=>r.formatCliError(e)).join("; "),n=`Run sketchi${a?` ${a}`:""} --help for usage.`;return uf(i?`${JSON.stringify({ok:!1,command:l,error:{code:"usage_error",message:t,hint:n}},null,2)}
223
+ authority: ${e.diagram.authority}`,e=>({id:e.diagram.manifest.id,restoredFromRevision:e.restoredFromRevision,revision:e.diagram.manifest.revision,authority:e.diagram.authority,documentAuthoritative:e.diagram.documentAuthoritative,formats:e.diagram.manifest.formats,revisions:fz(e.diagram)}))})).pipe(uB("Strictly offline recovery. Archive the current full state first, then restore revision N byte-for-byte without consuming it and commit at the next monotonic revision. Full snapshots restore artifacts and authority without rebuilding; legacy document-only revisions rebuild only while the record remains canonical."),uW("Restore a retained diagram revision."));function ht(e){let t=hr(e);return{id:e.id,format:e.format,destination:e.destination,sizeBytes:e.sizeBytes,...t?{hint:t}:{}}}function hr(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 hn=uL("export",{diagramId:ou(os,"diagram-id"),format:o2("format",["scene","excalidraw","png"]).pipe(o3("Artifact format to export or render on demand."),o8("scene|excalidraw|png")),destination:ou("flag","dest").pipe(o3("Artifact byte destination path, or - for stdout."),o8("PATH|-"))},({destination:e,diagramId:t,format:r})=>U.JkU(function*(){let{output:n}=yield*fW,i=yield*ah,a=U.JkU(function*(){let n=yield*nD(t),a=yield*i.exportArtifact(n,r);return"-"!==e&&(yield*i6(e,a)),{id:n,format:r,destination:e,sizeBytes:a.byteLength,..."-"===e?{stdoutBytes:a}:{}}});yield*a.pipe(U.tvg({onFailure:e=>fk("export",n,e),onSuccess:e=>U.JkU(function*(){let t=yield*fb;e.stdoutBytes&&(yield*t.stdout(e.stdoutBytes));let r=ht(e),i=hr(e),a=[`exported: ${e.id}`,`format: ${e.format}`,`destination: ${e.destination}`,`bytes: ${String(e.sizeBytes)}`,...i?[`hint: ${i}`]:[]].join("\n");yield*fS("export",n,r,a,"stderr")})}))})).pipe(uB("Strictly offline export of a current stored artifact or on-demand PNG. Canonical PNG uses scene plus Excalidraw; detached PNG restores diagram.excalidraw directly, uses its viewBackgroundColor, and adds no stale canonical title. Detached scene export is unavailable. Rendering never starts a browser or network request and never writes the PNG back. Status always uses stderr, so --dest - leaves stdout byte-only. Render or write failures exit 8."),uW("Export scene, Excalidraw, or PNG bytes."),uq([{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."}])),hi=fW.pipe(uU([f0,f2,fq,f5,f3,f8,f6,f9,he,f4,f7,hn])),ha=U.fn("sketchi.cli.run")(function*(e){let t,r,n,i,a,s,o,l,c,u,d=(t=e.lastIndexOf("--output"))>=0&&"json"===e[t+1]||e.some(e=>"--output=json"===e)?"json":"text";return yield*(r=oP({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=e.find(e=>fh.has(e)),s=e.every((t,r)=>"--output"===t||"--output=text"===t||"--output=json"===t||"--output"===e[r-1]&&("text"===t||"json"===t)),o=void 0===a&&(0===e.length||n||s),l=a??"sketchi",c={...r,formatHelpDoc:e=>{let t=r.formatHelpDoc(e).replace(/[ \t]+$/gmu,"");return i&&o?`${JSON.stringify({ok:!0,command:"sketchi",data:{help:fl({colors:"none",background:"dark"})}},null,2)}
224
+ `:i&&!n?"":o?function(){let e,t,r=void 0===process.stdout.columns||process.stdout.columns<=0?80:process.stdout.columns,n=function(e=process.env){if("dumb"===e.TERM||"linux"===e.TERM)return!1;let t=[e.LC_ALL,e.LC_CTYPE,e.LANG].find(e=>void 0!==e&&e.length>0);return void 0!==t&&/(?:^|[._-])utf-?8(?:@|$)/iu.test(t)}();if(void 0!==process.env.NO_COLOR||"dumb"===process.env.TERM||"ansi"===process.env.TERM||!0!==process.stdout.isTTY)return fl({colors:"none",background:"dark",unicode:n,width:r});let i=process.stdout.hasColors(0x1000000)?"truecolor":process.stdout.hasColors(256)?"ansi256":"none";if("none"===i)return fl({colors:"none",background:"dark",unicode:n,width:r});let a=(e=process.env.COLORFGBG,(t=e?.split(";").at(-1))&&/^\d+$/u.test(t)?function(e,t){let r=fc(e);if(void 0===r)return{background:"dark",readable:!1};let n=ff(r,"dark",t),i=ff(r,"light",t);return{background:n>=i?"dark":"light",readable:Math.max(n,i)>=4.5}}(Number(t),i):{background:"dark",readable:!0});return a.readable?fl({colors:i,background:a.background,unicode:n,width:r}):fl({colors:"none",background:a.background,unicode:n,width:r})}():t},formatErrors:e=>{let t=e.map(e=>r.formatCliError(e)).join("; "),n=`Run sketchi${a?` ${a}`:""} --help for usage.`;return uX(i?`${JSON.stringify({ok:!1,command:l,error:{code:"usage_error",message:t,hint:n}},null,2)}
193
225
  `:`error: usage_error
194
226
  ${t}
195
227
  next: ${n}
196
- `)}},u=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}}),uu(fJ,{version:"0.4.3"})(e).pipe(U.sFT(e=>el.i5(e,sa)&&"ShowHelp"!==e._tag?sn(c.formatErrors([e])):U.rIH),U.PfK(o6,{builtIns:[o0,o1,o5]}),U.PfK(s7,c),U.PfK(st,u))).pipe(U.khu({onFailure:e=>U.JkU(function*(){let t,r=K.getOrUndefined(L.L$(e));if(r instanceof d7)return r.exitCode;if(r instanceof nh)return 7;let n=function(e){if(el.i5(e,sa))return"ShowHelp"===e._tag?2*(e.errors.length>0):2}(r);if(void 0!==n)return n;let i=yield*d4;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"===d?nA({ok:!1,command:"sketchi",error:t}):fr(t))).pipe(U.MfU(()=>U.rIH)),1}),onSuccess:()=>U.PyW(0)}))}),fG=z.Um(nd.Tx,(0,nd.rR)({createId:e=>`${e}_offline_cli`})),fV=z.Gt(nL,fG),fK=z.Gt(d2,fG),fH=z.Um(n3,iM),fQ=z.Gt(iW,fH),fZ=z.Gt(iG,z.Um(fQ,nH)),f0=z.Gt(fg,ff),f1=z.Um(n3,iM,fV,fK,fQ,fZ,nH,f0,fp,d8.pipe(z.Gt(n3)),ft,se),f2=z.S5(f1,nu);J(fz(process.argv.slice(2)).pipe(U.Mim(e=>U.OH5(()=>{process.exitCode=e})),U.Gte(f2)),{disableErrorReporting:!0})},5030(e,t,r){function n(e,t=0){let r=1/0,i=1/0,a=-1/0,s=-1/0;for(let t of e){var o;if(!("object"==typeof(o=t)&&null!==o&&!Array.isArray(o)&&"number"==typeof t.x&&Number.isFinite(t.x)&&"number"==typeof t.y&&Number.isFinite(t.y)&&"number"==typeof t.width&&Number.isFinite(t.width)&&"number"==typeof t.height&&Number.isFinite(t.height)))return"element geometry is invalid";let e=Math.abs(t.width),n=Math.abs(t.height);if(e>8192||n>8192)return`element dimension exceeds ${String(8192)}`;let l=Math.hypot(e,n)/2,c=t.x+t.width/2,u=t.y+t.height/2;r=Math.min(r,c-l),i=Math.min(i,u-l),a=Math.max(a,c+l),s=Math.max(s,u+l)}if(0===e.length)return;let l=a-r,c=s-i;return l>8192||c>8192?`canvas dimension exceeds ${String(8192)}`:l*c>4194304?`canvas area exceeds ${String(4194304)}`:(l+40)*2*((c+40+t)*2)>0x1000000?`PNG output exceeds ${String(0x1000000)} pixels`:void 0}function i(e,t){return!Number.isFinite(e)||!Number.isFinite(t)||e<=0||t<=0?"rendered SVG dimensions are invalid":e>16384||t>16384?"rendered SVG dimension exceeds the PNG limit":e*t>0x1000000?`PNG output exceeds ${String(0x1000000)} pixels`:void 0}r.d(t,{Gd:()=>n,n$:()=>i},{Z4:4194304,ce:0x1000000})},181(e){e.exports=t("buffer")},6982(e){e.exports=t("crypto")},932(e){e.exports=t("process")},76(e,t,r){let n=r(9095),i=process.env;function a(e){return"string"==typeof e?!!i[e]:"env"in e?i[e.env]&&i[e.env].includes(e.includes):"any"in e?e.any.some(function(e){return!!i[e]}):Object.keys(e).every(function(t){return i[t]===e[t]})}Object.defineProperty(t,"_vendors",{value:n.map(function(e){return e.constant})}),t.name=null,t.isPR=null,t.id=null,"false"!==i.CI&&n.forEach(function(e){let r=(Array.isArray(e.env)?e.env:[e.env]).every(function(e){return a(e)});t[e.constant]=r,r&&(t.name=e.name,t.isPR=function(e){switch(typeof e.pr){case"string":return!!i[e.pr];case"object":if("env"in e.pr)if("any"in e.pr)return e.pr.any.some(function(t){return i[e.pr.env]===t});else return e.pr.env in i&&i[e.pr.env]!==e.pr.ne;if("any"in e.pr)return e.pr.any.some(function(e){return!!i[e]});return a(e.pr);default:return null}}(e),t.id=e.constant)}),t.isCI=!!("false"!==i.CI&&(i.BUILD_ID||i.BUILD_NUMBER||i.CI||i.CI_APP_ID||i.CI_BUILD_ID||i.CI_BUILD_NUMBER||i.CI_NAME||i.CONTINUOUS_INTEGRATION||i.RUN_ID||t.name))},485(e,t,r){e.exports=r(76).isCI},7876(e,t,r){var n=r(6730),i=r(8376),a=r(73),s=r(7028),o=r(3244),l=r(6225),c=r(9661);function u(e,t,r,n,i,a){let s="block-map"===r.type?o.resolveBlockMap(e,t,r,n,a):"block-seq"===r.type?l.resolveBlockSeq(e,t,r,n,a):c.resolveFlowCollection(e,t,r,n,a),u=s.constructor;return"!"===i||i===u.tagName?s.tag=u.tagName:i&&(s.tag=i),s}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===a.YAMLMap.tagName&&"map"===f||d===s.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),a=r(4915),s=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=s.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=a.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),a=r(7876),s=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},a){let s=new n.Alias(r.substring(1));""===s.source&&a(t,"BAD_ALIAS","Alias cannot be an empty string"),s.source.endsWith(":")&&a(t+r.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let l=t+r.length,c=o.resolveEnd(i,l,e.strict,a);return s.range=[t,l,c.offset],c.comment&&(s.comment=c.comment),s}(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=s.composeScalar(e,t,g,l),m&&(u.anchor=m.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{u=a.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:a,anchor:o,tag:c,end:u},f){let h={type:"scalar",offset:l.emptyScalarPosition(t,r,n),indent:-1,source:""},p=s.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),a&&(p.comment=a,p.range[2]=u),p}t.composeEmptyNode=d,t.composeNode=u},5120(e,t,r){var n=r(6730),i=r(8376),a=r(2992),s=r(3165);t.composeScalar=function(e,t,r,o){let l,c,{value:u,type:d,comment:f,range:h}="block-scalar"===t.type?a.resolveBlockScalar(e,t,o):s.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,a){if("!"===r)return e[n.SCALAR];let s=[];for(let t of e.tags)if(!t.collection&&t.tag===r)if(!t.default||!t.test)return t;else s.push(t);for(let e of s)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):(a(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,a,s){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);s(a,"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 a=l.resolve(u,e=>o(r??t,"TAG_RESOLVE_FAILED",e),e.options);c=n.isScalar(a)?a:new i.Scalar(a)}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),a=r(9960),s=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 a=e[i];switch(a[0]){case"#":t+=(""===t?"":n?"\n\n":"\n")+(a.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 s.YAMLWarning(i,t,r)):this.errors.push(new s.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}
228
+ `)}},u=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}}),uY(hi,{version:"0.6.0"})(e).pipe(U.sFT(e=>el.i5(e,sU)&&"ShowHelp"!==e._tag?sD(c.formatErrors([e])):U.rIH),U.PfK(lT,{builtIns:[lS,lI,l$]}),U.PfK(oN,c),U.PfK(sR,u))).pipe(U.khu({onFailure:e=>U.JkU(function*(){let t,r=K.getOrUndefined(L.L$(e));if(r instanceof fv)return r.exitCode;if(r instanceof nh)return 7;let n=function(e){if(el.i5(e,sU))return"ShowHelp"===e._tag?2*(e.errors.length>0):2}(r);if(void 0!==n)return n;let i=yield*fb;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"===d?nR({ok:!1,command:"sketchi",error:t}):f_(t))).pipe(U.MfU(()=>U.rIH)),1}),onSuccess:()=>U.PyW(0)}))}),hs=J.Um(nd.Tx,(0,nd.rR)({createId:e=>`${e}_offline_cli`})),ho=J.Gt(nq,hs),hl=J.Gt(n5,hs),hc=J.Um(nG,iV),hu=J.Gt(i8,hc),hd=J.Gt(ag,J.Um(hu,af)),hf=J.Gt(fj,fM),hh=J.Um(nG,iV,ho,hl,hu,hd,af,hf,fP,n6.pipe(J.Gt(nG)),fx,sP),hp=J.S5(hh,nu);X(ha(process.argv.slice(2)).pipe(U.Mim(e=>U.OH5(()=>{process.exitCode=e})),U.Gte(hp)),{disableErrorReporting:!0})},1688(e,t,r){var n=r(8861);let i=n.xCb(["invalid_render_artifact","render_limit_exceeded","unsupported_render_glyph","rasterization_failed"]),a=n.xCb(["artifact","geometry","font","rasterization"]);class s extends n.X0d()("HeadlessPngRenderError",{cause:n.kld(),code:i,stage:a,message:n.QfV,details:n.O31(n.QfV)}){}r.d(t,{FG:()=>s})},5030(e,t,r){function n(e,t,r,n){return{code:e,message:t,...void 0===r?{}:{observed:r},...void 0===n?{}:{limit:n}}}function i(e,t=0){let r=1/0,a=1/0,s=-1/0,o=-1/0;for(let t of e){var l;if(!("object"==typeof(l=t)&&null!==l&&!Array.isArray(l)&&"number"==typeof t.x&&Number.isFinite(t.x)&&"number"==typeof t.y&&Number.isFinite(t.y)&&"number"==typeof t.width&&Number.isFinite(t.width)&&"number"==typeof t.height&&Number.isFinite(t.height)))return n("invalid_geometry","element geometry is invalid");let e=Math.abs(t.width),i=Math.abs(t.height);if(e>8192||i>8192)return n("element_dimension",`element dimension exceeds ${String(8192)}`,Math.max(e,i),8192);let c=Math.hypot(e,i)/2,u=t.x+t.width/2,d=t.y+t.height/2;r=Math.min(r,u-c),a=Math.min(a,d-c),s=Math.max(s,u+c),o=Math.max(o,d+c)}if(0===e.length)return;let c=s-r,u=o-a;if(c>8192||u>8192)return n("canvas_dimension",`canvas dimension exceeds ${String(8192)}`,Math.max(c,u),8192);let d=c*u;if(d>6291456)return n("canvas_area",`canvas area exceeds ${String(6291456)}`,d,6291456);let f=(c+40)*1*((u+40+t)*1);if(f>0x1800000)return n("output_pixels",`PNG output exceeds ${String(0x1800000)} pixels at minimum scale`,f,0x1800000)}function a(e,t=0){return i(e,t)?.message}function s(e,t){if(!Number.isFinite(e)||!Number.isFinite(t)||e<=0||t<=0)return n("invalid_geometry","rendered SVG dimensions are invalid");let r=Math.min(2,16384/e,16384/t,Math.sqrt(0x1800000/(e*t)));if(r<1){let r=e*t;return r>0x1800000?n("output_pixels",`PNG output exceeds ${String(0x1800000)} pixels at minimum scale`,r,0x1800000):n("output_dimension","rendered SVG dimension exceeds the PNG limit at minimum scale",Math.max(e,t),16384)}return Math.max(1,Math.floor(1e3*r)/1e3)}function o(e,t){return!Number.isFinite(e)||!Number.isFinite(t)||e<=0||t<=0?"rendered SVG dimensions are invalid":e>16384||t>16384?"rendered SVG dimension exceeds the PNG limit":e*t>0x1800000?`PNG output exceeds ${String(0x1800000)} pixels`:void 0}r.d(t,{Gd:()=>a,Ts:()=>i,Yu:()=>s,n$:()=>o},{Z4:6291456,ce:0x1800000})},181(e){e.exports=t("buffer")},6982(e){e.exports=t("crypto")},932(e){e.exports=t("process")},76(e,t,r){let n=r(9095),i=process.env;function a(e){return"string"==typeof e?!!i[e]:"env"in e?i[e.env]&&i[e.env].includes(e.includes):"any"in e?e.any.some(function(e){return!!i[e]}):Object.keys(e).every(function(t){return i[t]===e[t]})}Object.defineProperty(t,"_vendors",{value:n.map(function(e){return e.constant})}),t.name=null,t.isPR=null,t.id=null,"false"!==i.CI&&n.forEach(function(e){let r=(Array.isArray(e.env)?e.env:[e.env]).every(function(e){return a(e)});t[e.constant]=r,r&&(t.name=e.name,t.isPR=function(e){switch(typeof e.pr){case"string":return!!i[e.pr];case"object":if("env"in e.pr)if("any"in e.pr)return e.pr.any.some(function(t){return i[e.pr.env]===t});else return e.pr.env in i&&i[e.pr.env]!==e.pr.ne;if("any"in e.pr)return e.pr.any.some(function(e){return!!i[e]});return a(e.pr);default:return null}}(e),t.id=e.constant)}),t.isCI=!!("false"!==i.CI&&(i.BUILD_ID||i.BUILD_NUMBER||i.CI||i.CI_APP_ID||i.CI_BUILD_ID||i.CI_BUILD_NUMBER||i.CI_NAME||i.CONTINUOUS_INTEGRATION||i.RUN_ID||t.name))},485(e,t,r){e.exports=r(76).isCI},7876(e,t,r){var n=r(6730),i=r(8376),a=r(73),s=r(7028),o=r(3244),l=r(6225),c=r(9661);function u(e,t,r,n,i,a){let s="block-map"===r.type?o.resolveBlockMap(e,t,r,n,a):"block-seq"===r.type?l.resolveBlockSeq(e,t,r,n,a):c.resolveFlowCollection(e,t,r,n,a),u=s.constructor;return"!"===i||i===u.tagName?s.tag=u.tagName:i&&(s.tag=i),s}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===a.YAMLMap.tagName&&"map"===f||d===s.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),a=r(4915),s=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=s.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=a.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),a=r(7876),s=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},a){let s=new n.Alias(r.substring(1));""===s.source&&a(t,"BAD_ALIAS","Alias cannot be an empty string"),s.source.endsWith(":")&&a(t+r.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let l=t+r.length,c=o.resolveEnd(i,l,e.strict,a);return s.range=[t,l,c.offset],c.comment&&(s.comment=c.comment),s}(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=s.composeScalar(e,t,g,l),m&&(u.anchor=m.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{u=a.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:a,anchor:o,tag:c,end:u},f){let h={type:"scalar",offset:l.emptyScalarPosition(t,r,n),indent:-1,source:""},p=s.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),a&&(p.comment=a,p.range[2]=u),p}t.composeEmptyNode=d,t.composeNode=u},5120(e,t,r){var n=r(6730),i=r(8376),a=r(2992),s=r(3165);t.composeScalar=function(e,t,r,o){let l,c,{value:u,type:d,comment:f,range:h}="block-scalar"===t.type?a.resolveBlockScalar(e,t,o):s.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,a){if("!"===r)return e[n.SCALAR];let s=[];for(let t of e.tags)if(!t.collection&&t.tag===r)if(!t.default||!t.test)return t;else s.push(t);for(let e of s)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):(a(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,a,s){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);s(a,"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 a=l.resolve(u,e=>o(r??t,"TAG_RESOLVE_FAILED",e),e.options);c=n.isScalar(a)?a:new i.Scalar(a)}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),a=r(9960),s=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 a=e[i];switch(a[0]){case"#":t+=(""===t?"":n?"\n\n":"\n")+(a.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 s.YAMLWarning(i,t,r)):this.errors.push(new s.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}
197
229
  ${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}
198
230
  ${t}`:r}else{let e=i.commentBefore;i.commentBefore=e?`${r}
199
231
  ${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 s.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 s.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}
200
- ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new s.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 a.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),a=r(7800),s=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=a.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||s.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 _=v.end,x=g?e(r,g,v,d):t(r,_,f,null,v,d);r.schema.compat&&o.flowIndentCheck(u.indent,g,d),r.atKey=!1,l.mapIncludes(r,h.items,x)&&d(_,"DUPLICATE_KEY","Map keys must be unique");let k=a.resolveProps(y??[],{indicator:"map-value-ind",next:b,offset:x.range[2],onError:d,parentIndent:u.indent,startOnNewline:!g||"block-scalar"===g.type});if(p=k.end,k.found){w&&(b?.type!=="block-map"||k.hasNewline||d(p,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),r.options.strict&&v.start<k.found.offset-1024&&d(x.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let a=b?e(r,b,k,d):t(r,p,y,null,k,d);r.schema.compat&&o.flowIndentCheck(u.indent,b,d),p=a.range[2];let s=new n.Pair(x,a);r.options.keepSourceTokens&&(s.srcToken=i),h.items.push(s)}else{w&&d(x.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),k.comment&&(x.comment?x.comment+="\n"+k.comment:x.comment=k.comment);let e=new n.Pair(x);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,a=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],a=i[0],s=0,o="",l=-1;for(let t=1;t<i.length;++t){let r=i[t];if(o||"-"!==r&&"+"!==r){let n=Number(r);!s&&n?s=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:a,indent:s,chomp:o,comment:u,length:d}}(t,e.options.strict,r);if(!a)return{value:"",type:null,comment:"",range:[i,i,i]};let s=">"===a.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="+"===a.chomp&&o.length>0?"\n".repeat(Math.max(1,o.length-1)):"",r=i+a.length;return t.source&&(r+=t.source.length),{value:e,type:s,comment:a.comment,range:[i,r,r]}}let c=t.indent+a.indent,u=t.offset+a.length,d=0;for(let t=0;t<l;++t){let[n,i]=o[t];if(""===i||"\r"===i)0===a.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===a.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=a.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=""}s===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(a.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+a.length+t.source.length;return{value:f,type:s,comment:a.comment,range:[i,m,m]}}},6225(e,t,r){var n=r(7028),i=r(7800),a=r(7090);t.resolveBlockSeq=function({composeNode:e,composeEmptyNode:t},r,s,o,l){let c=new(l?.nodeClass??n.YAMLSeq)(r.schema);r.atRoot&&(r.atRoot=!1),r.atKey&&(r.atKey=!1);let u=s.offset,d=null;for(let{start:n,value:l}of s.items){let f=i.resolveProps(n,{indicator:"seq-item-ind",next:l,offset:u,onError:o,parentIndent:s.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&&a.flowIndentCheck(s.indent,l,o),u=h.range[2],c.items.push(h)}return c.range=[s.offset,u,d??u],c}},4915(e,t){t.resolveEnd=function(e,t,r,n){let i="";if(e){let a=!1,s="";for(let o of e){let{source:e,type:l}=o;switch(l){case"space":a=!0;break;case"comment":{r&&!a&&n(o,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let t=e.substring(1)||" ";i?i+=s+t:i=t,s="";break}case"newline":i&&(s+=e),a=!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),a=r(73),s=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?a.YAMLMap:s.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 s=0;s<h.items.length;++s){let o=h.items[s],{start:m,key:v,sep:_,value:x}=o,k=l.resolveProps(m,{flow:y,indicator:"explicit-key-ind",next:v??_?.[0],offset:w,onError:p,parentIndent:h.indent,startOnNewline:!1});if(!k.found){if(!k.anchor&&!k.tag&&!_&&!x){0===s&&k.comma?p(k.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${y}`):s<h.items.length-1&&p(k.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${y}`),k.comment&&(b.comment?b.comment+="\n"+k.comment:b.comment=k.comment),w=k.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===s)k.comma&&p(k.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${y}`);else if(k.comma||p(k.start,"MISSING_CHAR",`Missing , between ${y} items`),k.comment){let e="";t:for(let t of m)switch(t.type){case"comma":case"space":break;case"comment":e=t.source.substring(1);break t;default:break t}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,k.comment=k.comment.substring(e.length+1)}}if(g||_||k.found){r.atKey=!0;let n=k.end,s=v?e(r,v,k,p):t(r,n,m,null,k,p);f(v)&&p(s.range,"BLOCK_IN_FLOW",d),r.atKey=!1;let c=l.resolveProps(_??[],{flow:y,indicator:"map-value-ind",next:x,offset:s.range[2],onError:p,parentIndent:h.indent,startOnNewline:!1});if(c.found){if(!g&&!k.found&&r.options.strict){if(_)for(let e of _){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}}k.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 x&&("source"in x&&x.source?.[0]===":"?p(x,"MISSING_CHAR",`Missing space after : in ${y}`):p(c.start,"MISSING_CHAR",`Missing , or : between ${y} items`));let S=x?e(r,x,c,p):c.found?t(r,c.end,_,null,c,p):null;S?f(x)&&p(S.range,"BLOCK_IN_FLOW",d):c.comment&&(s.comment?s.comment+="\n"+c.comment:s.comment=c.comment);let E=new i.Pair(s,S);if(r.options.keepSourceTokens&&(E.srcToken=o),g)u.mapIncludes(r,b.items,s)&&p(n,"DUPLICATE_KEY","Map keys must be unique"),b.items.push(E);else{let e=new a.YAMLMap(r.schema);e.flow=!0,e.items.push(E);let t=(S??s).range;e.range=[s.range[0],t[1],t[2]],b.items.push(e)}w=S?S.range[2]:c.end}else{let n=x?e(r,x,k,p):t(r,k.end,_,null,k,p);b.items.push(n),w=n.range[2],f(x)&&p(n.range,"BLOCK_IN_FLOW",d)}}let _=g?"}":"]",[x,...k]=h.end,S=w;if(x?.source===_)S=x.offset+x.source.length;else{let e=y[0].toUpperCase()+y.substring(1),t=v?`${e} must end with a ${_}`:`${e} in block collection must be sufficiently indented and end with a ${_}`;p(w,v?"MISSING_CHAR":"BAD_INDENT",t),x&&1!==x.source.length&&k.unshift(x)}if(k.length>0){let e=o.resolveEnd(k,S,r.options.strict,p);e.comment&&(b.comment?b.comment+="\n"+e.comment:b.comment=e.comment),b.range=[h.offset,S,e.offset]}else b.range=[h.offset,S,S];return b}},3165(e,t,r){var n=r(8376),i=r(4915);function a(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],a=" ",s=t.lastIndex;for(r.lastIndex=s;n=r.exec(e);)""===n[1]?"\n"===a?i+=a:a="\n":(i+=a+n[1],a=" "),s=r.lastIndex;let o=/[ \t]*(.*)/sy;return o.lastIndex=s,n=o.exec(e),i+a+(n?.[1]??"")}let s={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}`),a(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=a(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],a=s[i];if(a)r+=a;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 a="x"===i?2:"u"===i?4:8;r+=function(e,t,r,n){let i=e.substr(t,r),a=i.length===r&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;try{return String.fromCodePoint(a)}catch{let i=e.substr(t-2,r+2);return n(t-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${i}`),i}}(e,n+1,a,t),n+=a}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,a=e[n+1];for(;" "===a||" "===a;)a=e[++n+1];"\n"!==a&&("\r"!==a||"\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:a,parentIndent:s,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,_=null;for(let i of e)switch(p&&("space"!==i.type&&"newline"!==i.type&&"comma"!==i.type&&a(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&&a(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||a(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&&a(i,"MULTIPLE_ANCHORS","A node can have at most one anchor"),i.source.endsWith(":")&&a(i.offset+i.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),g=i,_??(_=i.offset),c=!1,u=!1,p=!0;break;case"tag":y&&a(i,"MULTIPLE_TAGS","A node can have at most one tag"),y=i,_??(_=i.offset),c=!1,u=!1,p=!0;break;case r:(g||y)&&a(i,"BAD_PROP_ORDER",`Anchors and tags must be after the ${i.source} indicator`),w&&a(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&&a(i,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`),v=i,c=!1,u=!1;break}default:a(i,"UNEXPECTED_TOKEN",`Unexpected ${i.type} token`),c=!1,u=!1}let x=e[e.length-1],k=x?x.offset+x.source.length:i;return p&&n&&"space"!==n.type&&"newline"!==n.type&&"comma"!==n.type&&("scalar"!==n.type||""!==n.source)&&a(n.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),m&&(c&&m.indent<=s||n?.type==="block-map"||n?.type==="block-seq")&&a(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:k,start:_??k}}},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 a="function"==typeof i?i:(e,t)=>e===t||n.isScalar(e)&&n.isScalar(t)&&e.value===t.value;return t.some(e=>a(e.key,r))}},9960(e,t,r){var n=r(2298),i=r(7580),a=r(6730),s=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(a.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,a.NODE_TYPE,{value:a.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:s}=i;r?._directives?(this.directives=r._directives.atDocument(),this.directives.yaml.explicit&&(s=this.directives.yaml.version)):this.directives=new h.Directives({version:s}),this.setSchema(s,r),this.contents=void 0===e?null:this.createNode(e,n,r)}clone(){let t=Object.create(e.prototype,{[a.NODE_TYPE]:{value:a.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=a.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:s,flow:o,keepUndefined:l,onTagObj:c,tag:d}=r??{},{onAnchor:h,setAnchors:p,sourceObjects:m}=u.createNodeAnchors(this,s||"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&&a.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 s.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 a.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return i.isEmptyPath(e)?!t&&a.isScalar(this.contents)?this.contents.value:this.contents:a.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return!!a.isCollection(this.contents)&&this.contents.has(e)}hasIn(e){return i.isEmptyPath(e)?void 0!==this.contents:!!a.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:a}={}){let s={anchors:new Map,doc:this,keep:!e,mapAsMap:!0===r,mapKeyWarned:!1,maxAliasCount:"number"==typeof n?n:100},l=o.toJS(this.contents,t??"",s);if("function"==typeof i)for(let{count:e,res:t}of s.anchors.values())i(t,e);return"function"==typeof a?d.applyReviver(a,{"":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 a(e){let t=new Set;return i.visit(e,{Value(e,r){r.anchor&&t.add(r.anchor)}}),t}function s(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=a,t.createNodeAnchors=function(e,t){let r=[],i=new Map,o=null;return{onAnchor:n=>{r.push(n),o??(o=a(e));let i=s(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=s},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],a=e(t,i,String(r),n);void 0===a?delete i[r]:a!==n&&(i[r]=a)}else if(i instanceof Map)for(let r of Array.from(i.keys())){let n=i.get(r),a=e(t,i,r,n);void 0===a?i.delete(r):a!==n&&i.set(r,a)}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 a=e(t,i,r,n);void 0===a?delete i[r]:a!==n&&(i[r]=a)}return t.call(r,n,i)}},7377(e,t,r){var n=r(2298),i=r(6730),a=r(8376);t.createNode=function(e,t,r){let s;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(s=d.get(e))return s.anchor??(s.anchor=l(e)),new n.Alias(s.anchor);s={anchor:null,node:null},d.set(e,s)}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 a.Scalar(e);return s&&(s.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 a.Scalar(e);return t?h.tag=t:f.default||(h.tag=f.tag),s&&(s.node=h),h}},7087(e,t,r){var n=r(6730),i=r(7995);let a={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},s=e=>e.replace(/[!,[\]{}]/g,e=>a[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+s(e.substring(r.length));return"!"===e[0]?e:`!<${e}>`}toString(e){let t,r=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],a=Object.entries(this.tags);if(e&&a.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 a)("!!"!==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 a=i-1,s=e.substring(t.lineStarts[n-1],t.lineStarts[n]).replace(/[\n\r]+$/,"");if(a>=60&&s.length>80){let e=Math.min(a-39,s.length-79);s="…"+s.substring(e),a-=e-1}if(s.length>80&&(s=s.substring(0,79)+"…"),n>1&&/^ *$/.test(s.substring(0,a))){let r=e.substring(t.lineStarts[n-2],t.lineStarts[n-1]);r.length>80&&(r=r.substring(0,79)+"…\n"),s=r+s}if(/[^ ]/.test(s)){let e=1,t=r.linePos[1];t?.line===n&&t.col>i&&(e=Math.max(1,Math.min(t.col-i,80-a)));let o=" ".repeat(a)+"^".repeat(e);r.message+=`:
232
+ ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new s.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 a.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),a=r(7800),s=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=a.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||s.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,_=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,_)&&d(x,"DUPLICATE_KEY","Map keys must be unique");let k=a.resolveProps(y??[],{indicator:"map-value-ind",next:b,offset:_.range[2],onError:d,parentIndent:u.indent,startOnNewline:!g||"block-scalar"===g.type});if(p=k.end,k.found){w&&(b?.type!=="block-map"||k.hasNewline||d(p,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),r.options.strict&&v.start<k.found.offset-1024&&d(_.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let a=b?e(r,b,k,d):t(r,p,y,null,k,d);r.schema.compat&&o.flowIndentCheck(u.indent,b,d),p=a.range[2];let s=new n.Pair(_,a);r.options.keepSourceTokens&&(s.srcToken=i),h.items.push(s)}else{w&&d(_.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),k.comment&&(_.comment?_.comment+="\n"+k.comment:_.comment=k.comment);let e=new n.Pair(_);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,a=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],a=i[0],s=0,o="",l=-1;for(let t=1;t<i.length;++t){let r=i[t];if(o||"-"!==r&&"+"!==r){let n=Number(r);!s&&n?s=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:a,indent:s,chomp:o,comment:u,length:d}}(t,e.options.strict,r);if(!a)return{value:"",type:null,comment:"",range:[i,i,i]};let s=">"===a.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="+"===a.chomp&&o.length>0?"\n".repeat(Math.max(1,o.length-1)):"",r=i+a.length;return t.source&&(r+=t.source.length),{value:e,type:s,comment:a.comment,range:[i,r,r]}}let c=t.indent+a.indent,u=t.offset+a.length,d=0;for(let t=0;t<l;++t){let[n,i]=o[t];if(""===i||"\r"===i)0===a.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===a.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=a.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=""}s===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(a.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+a.length+t.source.length;return{value:f,type:s,comment:a.comment,range:[i,m,m]}}},6225(e,t,r){var n=r(7028),i=r(7800),a=r(7090);t.resolveBlockSeq=function({composeNode:e,composeEmptyNode:t},r,s,o,l){let c=new(l?.nodeClass??n.YAMLSeq)(r.schema);r.atRoot&&(r.atRoot=!1),r.atKey&&(r.atKey=!1);let u=s.offset,d=null;for(let{start:n,value:l}of s.items){let f=i.resolveProps(n,{indicator:"seq-item-ind",next:l,offset:u,onError:o,parentIndent:s.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&&a.flowIndentCheck(s.indent,l,o),u=h.range[2],c.items.push(h)}return c.range=[s.offset,u,d??u],c}},4915(e,t){t.resolveEnd=function(e,t,r,n){let i="";if(e){let a=!1,s="";for(let o of e){let{source:e,type:l}=o;switch(l){case"space":a=!0;break;case"comment":{r&&!a&&n(o,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let t=e.substring(1)||" ";i?i+=s+t:i=t,s="";break}case"newline":i&&(s+=e),a=!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),a=r(73),s=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?a.YAMLMap:s.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 s=0;s<h.items.length;++s){let o=h.items[s],{start:m,key:v,sep:x,value:_}=o,k=l.resolveProps(m,{flow:y,indicator:"explicit-key-ind",next:v??x?.[0],offset:w,onError:p,parentIndent:h.indent,startOnNewline:!1});if(!k.found){if(!k.anchor&&!k.tag&&!x&&!_){0===s&&k.comma?p(k.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${y}`):s<h.items.length-1&&p(k.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${y}`),k.comment&&(b.comment?b.comment+="\n"+k.comment:b.comment=k.comment),w=k.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===s)k.comma&&p(k.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${y}`);else if(k.comma||p(k.start,"MISSING_CHAR",`Missing , between ${y} items`),k.comment){let e="";t:for(let t of m)switch(t.type){case"comma":case"space":break;case"comment":e=t.source.substring(1);break t;default:break t}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,k.comment=k.comment.substring(e.length+1)}}if(g||x||k.found){r.atKey=!0;let n=k.end,s=v?e(r,v,k,p):t(r,n,m,null,k,p);f(v)&&p(s.range,"BLOCK_IN_FLOW",d),r.atKey=!1;let c=l.resolveProps(x??[],{flow:y,indicator:"map-value-ind",next:_,offset:s.range[2],onError:p,parentIndent:h.indent,startOnNewline:!1});if(c.found){if(!g&&!k.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}}k.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 _&&("source"in _&&_.source?.[0]===":"?p(_,"MISSING_CHAR",`Missing space after : in ${y}`):p(c.start,"MISSING_CHAR",`Missing , or : between ${y} items`));let S=_?e(r,_,c,p):c.found?t(r,c.end,x,null,c,p):null;S?f(_)&&p(S.range,"BLOCK_IN_FLOW",d):c.comment&&(s.comment?s.comment+="\n"+c.comment:s.comment=c.comment);let I=new i.Pair(s,S);if(r.options.keepSourceTokens&&(I.srcToken=o),g)u.mapIncludes(r,b.items,s)&&p(n,"DUPLICATE_KEY","Map keys must be unique"),b.items.push(I);else{let e=new a.YAMLMap(r.schema);e.flow=!0,e.items.push(I);let t=(S??s).range;e.range=[s.range[0],t[1],t[2]],b.items.push(e)}w=S?S.range[2]:c.end}else{let n=_?e(r,_,k,p):t(r,k.end,x,null,k,p);b.items.push(n),w=n.range[2],f(_)&&p(n.range,"BLOCK_IN_FLOW",d)}}let x=g?"}":"]",[_,...k]=h.end,S=w;if(_?.source===x)S=_.offset+_.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),_&&1!==_.source.length&&k.unshift(_)}if(k.length>0){let e=o.resolveEnd(k,S,r.options.strict,p);e.comment&&(b.comment?b.comment+="\n"+e.comment:b.comment=e.comment),b.range=[h.offset,S,e.offset]}else b.range=[h.offset,S,S];return b}},3165(e,t,r){var n=r(8376),i=r(4915);function a(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],a=" ",s=t.lastIndex;for(r.lastIndex=s;n=r.exec(e);)""===n[1]?"\n"===a?i+=a:a="\n":(i+=a+n[1],a=" "),s=r.lastIndex;let o=/[ \t]*(.*)/sy;return o.lastIndex=s,n=o.exec(e),i+a+(n?.[1]??"")}let s={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}`),a(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=a(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],a=s[i];if(a)r+=a;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 a="x"===i?2:"u"===i?4:8;r+=function(e,t,r,n){let i=e.substr(t,r),a=i.length===r&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;try{return String.fromCodePoint(a)}catch{let i=e.substr(t-2,r+2);return n(t-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${i}`),i}}(e,n+1,a,t),n+=a}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,a=e[n+1];for(;" "===a||" "===a;)a=e[++n+1];"\n"!==a&&("\r"!==a||"\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:a,parentIndent:s,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&&a(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&&a(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||a(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&&a(i,"MULTIPLE_ANCHORS","A node can have at most one anchor"),i.source.endsWith(":")&&a(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&&a(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)&&a(i,"BAD_PROP_ORDER",`Anchors and tags must be after the ${i.source} indicator`),w&&a(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&&a(i,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`),v=i,c=!1,u=!1;break}default:a(i,"UNEXPECTED_TOKEN",`Unexpected ${i.type} token`),c=!1,u=!1}let _=e[e.length-1],k=_?_.offset+_.source.length:i;return p&&n&&"space"!==n.type&&"newline"!==n.type&&"comma"!==n.type&&("scalar"!==n.type||""!==n.source)&&a(n.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),m&&(c&&m.indent<=s||n?.type==="block-map"||n?.type==="block-seq")&&a(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:k,start:x??k}}},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 a="function"==typeof i?i:(e,t)=>e===t||n.isScalar(e)&&n.isScalar(t)&&e.value===t.value;return t.some(e=>a(e.key,r))}},9960(e,t,r){var n=r(2298),i=r(7580),a=r(6730),s=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(a.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,a.NODE_TYPE,{value:a.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:s}=i;r?._directives?(this.directives=r._directives.atDocument(),this.directives.yaml.explicit&&(s=this.directives.yaml.version)):this.directives=new h.Directives({version:s}),this.setSchema(s,r),this.contents=void 0===e?null:this.createNode(e,n,r)}clone(){let t=Object.create(e.prototype,{[a.NODE_TYPE]:{value:a.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=a.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:s,flow:o,keepUndefined:l,onTagObj:c,tag:d}=r??{},{onAnchor:h,setAnchors:p,sourceObjects:m}=u.createNodeAnchors(this,s||"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&&a.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 s.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 a.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return i.isEmptyPath(e)?!t&&a.isScalar(this.contents)?this.contents.value:this.contents:a.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return!!a.isCollection(this.contents)&&this.contents.has(e)}hasIn(e){return i.isEmptyPath(e)?void 0!==this.contents:!!a.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:a}={}){let s={anchors:new Map,doc:this,keep:!e,mapAsMap:!0===r,mapKeyWarned:!1,maxAliasCount:"number"==typeof n?n:100},l=o.toJS(this.contents,t??"",s);if("function"==typeof i)for(let{count:e,res:t}of s.anchors.values())i(t,e);return"function"==typeof a?d.applyReviver(a,{"":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 a(e){let t=new Set;return i.visit(e,{Value(e,r){r.anchor&&t.add(r.anchor)}}),t}function s(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=a,t.createNodeAnchors=function(e,t){let r=[],i=new Map,o=null;return{onAnchor:n=>{r.push(n),o??(o=a(e));let i=s(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=s},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],a=e(t,i,String(r),n);void 0===a?delete i[r]:a!==n&&(i[r]=a)}else if(i instanceof Map)for(let r of Array.from(i.keys())){let n=i.get(r),a=e(t,i,r,n);void 0===a?i.delete(r):a!==n&&i.set(r,a)}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 a=e(t,i,r,n);void 0===a?delete i[r]:a!==n&&(i[r]=a)}return t.call(r,n,i)}},7377(e,t,r){var n=r(2298),i=r(6730),a=r(8376);t.createNode=function(e,t,r){let s;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(s=d.get(e))return s.anchor??(s.anchor=l(e)),new n.Alias(s.anchor);s={anchor:null,node:null},d.set(e,s)}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 a.Scalar(e);return s&&(s.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 a.Scalar(e);return t?h.tag=t:f.default||(h.tag=f.tag),s&&(s.node=h),h}},7087(e,t,r){var n=r(6730),i=r(7995);let a={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},s=e=>e.replace(/[!,[\]{}]/g,e=>a[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+s(e.substring(r.length));return"!"===e[0]?e:`!<${e}>`}toString(e){let t,r=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],a=Object.entries(this.tags);if(e&&a.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 a)("!!"!==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 a=i-1,s=e.substring(t.lineStarts[n-1],t.lineStarts[n]).replace(/[\n\r]+$/,"");if(a>=60&&s.length>80){let e=Math.min(a-39,s.length-79);s="…"+s.substring(e),a-=e-1}if(s.length>80&&(s=s.substring(0,79)+"…"),n>1&&/^ *$/.test(s.substring(0,a))){let r=e.substring(t.lineStarts[n-2],t.lineStarts[n-1]);r.length>80&&(r=r.substring(0,79)+"…\n"),s=r+s}if(/[^ ]/.test(s)){let e=1,t=r.linePos[1];t?.line===n&&t.col>i&&(e=Math.max(1,Math.min(t.col-i,80-a)));let o=" ".repeat(a)+"^".repeat(e);r.message+=`:
201
233
 
202
234
  ${s}
203
235
  ${o}
204
236
  `}}},2976(e,t,r){var n=r(2545),i=r(9960),a=r(8227),s=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,a.Schema,s.YAMLError,s.YAMLParseError,s.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),a=r(6730),s=r(5476),o=r(2234);class l extends s.NodeBase{constructor(e){super(a.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 s of(t?.aliasResolveCache?r=t.aliasResolveCache:(r=[],i.visit(e,{Node:(e,t)=>{(a.isAlias(t)||a.hasAnchor(t))&&r.push(t)}}),t&&(t.aliasResolveCache=r)),r)){if(s===this)break;s.anchor===this.source&&(n=s)}return n}toJSON(e,t){if(!t)return{source:this.source};let{anchors:r,doc:n,maxAliasCount:i}=t,s=this.resolve(n,t);if(!s)throw ReferenceError(`Unresolved alias (the anchor must be set before the alias): ${this.source}`);let l=r.get(s);if(l||(o.toJS(s,null,t),l=r.get(s)),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(a.isAlias(r)){let e=r.resolve(t),i=n&&e&&n.get(e);return i?i.count*i.aliasCount:0}if(a.isCollection(r)){let i=0;for(let a of r.items){let r=e(t,a,n);r>i&&(i=r)}return i}return a.isPair(r)?Math.max(e(t,r.key,n),e(t,r.value,n)):1}(n,s,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),a=r(5476);function s(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 a.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,a=this.get(r,!0);if(i.isCollection(a))a.addIn(n,t);else if(void 0===a&&this.schema)this.set(r,s(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,a=this.get(r,!0);return 0===n.length?!t&&i.isScalar(a)?a.value:a:i.isCollection(a)?a.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,s(this.schema,n,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${n}`)}}}t.Collection=l,t.collectionFromPath=s,t.isEmptyPath=o},5476(e,t,r){var n=r(9768),i=r(6730),a=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:s,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=a.toJS(this,"",l);if("function"==typeof s)for(let{count:e,res:t}of l.anchors.values())s(t,e);return"function"==typeof o?n.applyReviver(o,{"":c},"",c):c}}},7748(e,t,r){var n=r(7377),i=r(4711),a=r(3757),s=r(6730);class o{constructor(e,t=null){Object.defineProperty(this,s.NODE_TYPE,{value:s.PAIR}),this.key=e,this.value=t}clone(e){let{key:t,value:r}=this;return s.isNode(t)&&(t=t.clone(e)),s.isNode(r)&&(r=r.clone(e)),new o(t,r)}toJSON(e,t){let r=t?.mapAsMap?new Map:{};return a.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),a=r(2234);class s extends i.NodeBase{constructor(e){super(n.SCALAR),this.value=e}toJSON(e,t){return t?.keep?this.value:a.toJS(this.value,e,t)}toString(){return String(this.value)}}s.BLOCK_FOLDED="BLOCK_FOLDED",s.BLOCK_LITERAL="BLOCK_LITERAL",s.PLAIN="PLAIN",s.QUOTE_DOUBLE="QUOTE_DOUBLE",s.QUOTE_SINGLE="QUOTE_SINGLE",t.Scalar=s,t.isScalarValue=e=>!e||"function"!=typeof e&&"object"!=typeof e},73(e,t,r){var n=r(8143),i=r(3757),a=r(7580),s=r(6730),o=r(7748),l=r(8376);function c(e,t){let r=s.isScalar(t)?t.value:t;for(let n of e)if(s.isPair(n)&&(n.key===t||n.key===r||s.isScalar(n.key)&&n.key.value===r))return n}class u extends a.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(s.MAP,e),this.items=[]}static from(e,t,r){let{keepUndefined:n,replacer:i}=r,a=new this(e),s=(e,s)=>{if("function"==typeof i)s=i.call(t,e,s);else if(Array.isArray(i)&&!i.includes(e))return;(void 0!==s||n)&&a.items.push(o.createPair(e,s,r))};if(t instanceof Map)for(let[e,r]of t)s(e,r);else if(t&&"object"==typeof t)for(let e of Object.keys(t))s(e,t[e]);return"function"==typeof e.sortMapEntries&&a.items.sort(e.sortMapEntries),a}add(e,t){let r;r=s.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`);s.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&&s.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(!s.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),a=r(7580),s=r(6730),o=r(8376),l=r(2234);class c extends a.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(s.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&&s.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];s.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,a=new this(e);if(t&&Symbol.iterator in Object(t)){let e=0;for(let s of t){if("function"==typeof i){let r=t instanceof Set?s:String(e++);s=i.call(t,r,s)}a.items.push(n.createNode(s,void 0,r))}}return a}}function u(e){let t=s.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),a=r(6203),s=r(6730),o=r(2234);t.addPairToJSMap=function(e,t,{key:r,value:l}){if(s.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(s.isNode(e)&&r?.doc){let t=a.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"),a=Symbol.for("yaml.pair"),s=Symbol.for("yaml.scalar"),o=Symbol.for("yaml.seq"),l=Symbol.for("yaml.node.type"),c=e=>!!e&&"object"==typeof e&&e[l]===s;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=a,t.SCALAR=s,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 s:case o:return!0}return!1},t.isPair=e=>!!e&&"object"==typeof e&&e[l]===a,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 a=t.toJSON(r,i);return i.onCreate&&i.onCreate(a),a}return"bigint"!=typeof t||i?.keep?t:Number(t)}},8215(e,t,r){var n=r(2992),i=r(3165),a=r(3409),s=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:a=-1,type:l="PLAIN"}=t,c=s.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:a,indent:n,source:t}];return o(i,u)||i.push({type:"newline",offset:-1,indent:n,source:"\n"}),{type:"block-scalar",offset:a,indent:n,props:i,source:r}}case'"':return{type:"double-quoted-scalar",offset:a,indent:n,source:c,end:u};case"'":return{type:"single-quoted-scalar",offset:a,indent:n,source:c,end:u};default:return{type:"scalar",offset:a,indent:n,source:c,end:u}}},t.resolveAsScalar=function(e,t=!0,r){if(e){let s=(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 a.YAMLParseError([i,i+1],t,n)};switch(e.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return i.resolveFlowScalar(e,t,s);case"block-scalar":return n.resolveBlockScalar({options:{strict:t}},e,s)}}return null},t.setScalarValue=function(e,t,r={}){let{afterKey:n=!1,implicitKey:i=!1,inFlow:a=!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=s.stringifyString({type:c,value:t},{implicitKey:i||null===u,indent:null!==u&&u>0?" ".repeat(u):"",inFlow:a,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,a=[{type:"block-scalar-header",offset:t,indent:r,source:n}];for(let t of(o(a,"end"in e?e.end:void 0)||a.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:a,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:a}){let s="";for(let t of e)s+=t.source;if(t&&(s+=r(t)),i)for(let e of i)s+=e.source;return a&&(s+=r(a)),s}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 a(e,t){"type"in e&&"document"===e.type&&(e={start:e.start,value:e.value}),function e(t,n,a){let s=a(n,t);if("symbol"==typeof s)return s;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 s=e(Object.freeze(t.concat([[o,n]])),l.items[n],a);if("number"==typeof s)n=s-1;else{if(s===r)return r;s===i&&(l.items.splice(n,1),n-=1)}}"function"==typeof s&&"key"===o&&(s=s(n,t))}}return"function"==typeof s?s(n,t):s}(Object.freeze([]),e,t)}a.BREAK=r,a.SKIP=n,a.REMOVE=i,a.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},a.parentCollection=(e,t)=>{let r=a.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=a},9810(e,t,r){var n=r(8215),i=r(2142),a=r(1844);t.createScalarToken=n.createScalarToken,t.resolveAsScalar=n.resolveAsScalar,t.setScalarValue=n.setScalarValue,t.stringify=i.stringify,t.visit=a.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 a=new Set("0123456789ABCDEFabcdef"),s=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 a=this.getLine();if(null===a)return this.setNext("flow");if((-1!==r&&r<this.indentNext&&"#"!==a[0]||0===r&&(a.startsWith("---")||a.startsWith("..."))&&i(a[3]))&&(r!==this.indentNext-1||1!==this.flowLevel||"]"!==a[0]&&"}"!==a[0]))return this.flowLevel=0,yield n.FLOW_END,yield*this.parseLineStart();let s=0;for(;","===a[s];)s+=yield*this.pushCount(1),s+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(a[s+=yield*this.pushIndicators()]){case void 0:return"flow";case"#":return yield*this.pushCount(a.length-s),"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;t: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 t}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,a=this.pos-1;for(;e=this.buffer[++a];)if(":"===e){let e=this.buffer[a+1];if(i(e)||t&&o.has(e))break;r=a}else if(i(e)){let n=this.buffer[a+1];if("\r"===e&&("\n"===n?(a+=1,e="\n",n=this.buffer[a+1]):r=a),"#"===n||t&&o.has(n))break;if("\n"===e){let e=this.continueScalar(a+1);if(-1===e)break;a=Math.max(a,e-2)}}else{if(t&&o.has(e))break;r=a}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(s.has(t))t=this.buffer[++e];else if("%"===t&&a.has(this.buffer[e+1])&&a.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),a=r(7894);function s(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;t: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 t}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||s(t.start,"explicit-key-ind")||s(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 a.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(s(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)&&!s(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(s(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]}):s(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&&!s(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||s(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),a=r(3409),s=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),s=new c.Parser(r?.addNewLine),o=new n.Composer(t),l=null;for(let t of o.compose(s.parse(e),!0,e.length))if(l){if("silent"!==l.options.logLevel){l.errors.push(new a.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(a.prettifyError(e,r)),l.warnings.forEach(a.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=>s.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),s=new c.Parser(r?.addNewLine),o=new n.Composer(t),l=Array.from(o.compose(s.parse(e)));if(i&&r)for(let t of l)t.errors.forEach(a.prettifyError(e,r)),t.warnings.forEach(a.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),a=r(505),s=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:s.string}),Object.defineProperty(this,n.SEQ,{value:a.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 a={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=a},9305(e,t,r){var n=r(4374);let i=e=>"bigint"==typeof e||Number.isInteger(e),a=(e,t,r,{intAsBigInt:n})=>n?BigInt(e):parseInt(e.substring(t),r);function s(e,t,r){let{value:a}=e;return i(a)&&a>=0?r+a.toString(t):n.stringifyNumber(e)}t.int={identify:i,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,r)=>a(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)=>a(e,2,16,r),stringify:e=>s(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)=>a(e,2,8,r),stringify:e=>s(e,8,"0o")}},8537(e,t,r){var n=r(9988),i=r(5725),a=r(505),s=r(5613),o=r(4302),l=r(7878),c=r(9305);t.schema=[n.map,a.seq,s.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),a=r(505);function s(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:s,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})=>s(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,a.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),a=r(505),s=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,a.seq,s.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:a.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),a=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},s,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(s.options.lineWidth-s.indent.length,s.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 a.stringifyString({comment:e,type:t,value:c},s,o,l)}}},4211(e,t,r){var n=r(8376);function i({value:e,source:t},r){let n=e?a:s;return t&&n.test.test(t)?t:e?r.options.trueStr:r.options.falseStr}let a={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},s={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=s,t.trueTag=a},1489(e,t,r){var n=r(8376),i=r(4374);let a={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=a},5566(e,t,r){var n=r(4374);let i=e=>"bigint"==typeof e||Number.isInteger(e);function a(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 s=parseInt(e,r);return"-"===i?-1*s:s}function s(e,t,r){let{value:a}=e;if(i(a)){let e=a.toString(t);return a<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)=>a(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)=>a(e,2,2,r),stringify:e=>s(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)=>a(e,2,16,r),stringify:e=>s(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)=>a(e,1,8,r),stringify:e=>s(e,8,"0")}},8327(e,t,r){var n=r(6730),i=r(8376);let a={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:s}),stringify:()=>"<<"};function s(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=s,t.isMergeKey=(e,t)=>(a.identify(t)||n.isScalar(t)&&(!t.type||t.type===i.Scalar.PLAIN)&&a.identify(t.value))&&e?.doc.schema.tags.some(e=>e.tag===a.tag&&e.default),t.merge=a},8822(e,t,r){var n=r(6730),i=r(2234),a=r(73),s=r(7028),o=r(9946);class l extends s.YAMLSeq{constructor(){super(),this.add=a.YAMLMap.prototype.add.bind(this),this.delete=a.YAMLMap.prototype.delete.bind(this),this.get=a.YAMLMap.prototype.get.bind(this),this.has=a.YAMLMap.prototype.has.bind(this),this.set=a.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 a,s;if(n.isPair(e)?(a=i.toJS(e.key,"",t),s=i.toJS(e.value,a,t)):a=i.toJS(e,"",t),r.has(a))throw Error("Ordered maps must not include duplicate keys");r.set(a,s)}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),a=r(8376),s=r(7028);function o(e,t){if(n.isSeq(e))for(let r=0;r<e.items.length;++r){let s=e.items[r];if(!n.isPair(s)){if(n.isMap(s)){s.items.length>1&&t("Each pair must have its own sequence indicator");let e=s.items[0]||new i.Pair(new a.Scalar(null));if(s.commentBefore&&(e.key.commentBefore=e.key.commentBefore?`${s.commentBefore}
205
237
  ${e.key.commentBefore}`:s.commentBefore),s.comment){let t=e.value??e.key;t.comment=t.comment?`${s.comment}
206
- ${t.comment}`:s.comment}s=e}e.items[r]=n.isPair(s)?s:new i.Pair(s)}}else t("Expected a sequence for this tag");return e}function l(e,t,r){let{replacer:n}=r,a=new s.YAMLSeq(e);a.tag="tag:yaml.org,2002:pairs";let o=0;if(t&&Symbol.iterator in Object(t))for(let e of t){let s,l;if("function"==typeof n&&(e=n.call(t,String(o++),e)),Array.isArray(e))if(2===e.length)s=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[s=t[0]];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else s=e;a.items.push(i.createPair(s,l,r))}return a}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),a=r(505),s=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,a.seq,s.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),a=r(73);class s extends a.YAMLMap{constructor(e){super(e),this.tag=s.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),a.findPair(this.items,t.key)||this.items.push(t)}get(e,t){let r=a.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=a.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,a=new this(e);if(t&&Symbol.iterator in Object(t))for(let e of t)"function"==typeof n&&(e=n.call(t,e,e)),a.items.push(i.createPair(e,null,r));return a}}s.tag="tag:yaml.org,2002:set",t.YAMLSet=s,t.set={collection:"map",identify:e=>e instanceof Set,nodeClass:s,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,r)=>s.from(e,t,r),resolve(e,t){if(n.isMap(e))if(e.hasAllNullValues(!0))return Object.assign(new s,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),a=n.replace(/_/g,"").split(":").reduce((e,t)=>e*i(60)+i(t),i(0));return"-"===r?i(-1)*a:a}function a(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 a=r(60),s=[t%a];return t<60?s.unshift(0):(t=(t-s[0])/a,s.unshift(t%a),t>=60&&(t=(t-s[0])/a,s.unshift(t))),i+s.map(e=>String(e).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}let s={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(s.test);if(!t)throw Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,r,n,a,o,l,c]=t.map(Number),u=Date.UTC(r,n-1,a,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:a},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:a},t.timestamp=s},3980(e,t){let r="block",n="quoted";function i(e,t,r){let n=t,i=t+1,a=e[i];for(;" "===a||" "===a;)if(t<i+r)a=e[++t];else{do a=e[++t];while(a&&"\n"!==a)n=t,a=e[i=t+1]}return n}t.FOLD_BLOCK=r,t.FOLD_FLOW="flow",t.FOLD_QUOTED=n,t.foldFlowLines=function(e,t,a="flow",{indentAtStart:s,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 s&&(s>o-Math.max(2,l)?m.push(0):y=o-s);let b=!1,v=-1,w=-1,_=-1;for(a===r&&-1!==(v=i(e,v,t.length))&&(y=v+p);h=e[v+=1];){if(a===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}_=v}if("\n"===h)a===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(a===n){for(;" "===f||" "===f;)f=h,h=e[v+=1],b=!0;let t=v>_+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 x=e.slice(0,m[0]);for(let r=0;r<m.length;++r){let i=m[r],s=m[r+1]||e.length;0===i?x=`
207
- ${t}${e.slice(0,s)}`:(a===n&&g[i]&&(x+=`${e[i]}\\`),x+=`
208
- ${t}${e.slice(i+1,s)}`)}return x}},6203(e,t,r){var n=r(9531),i=r(6730),a=r(3202),s=r(4286);t.createStringifyContext=function(e,t){let r,n=Object.assign({blockQuote:!0,commentString:a.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,a){let o;if(i.isPair(e))return e.toString(t,r,a);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:a}){if(!a.directives)return"";let s=[],o=(i.isScalar(e)||i.isCollection(e))&&e.anchor;o&&n.anchorIsValid(o)&&(r.add(o),s.push(`&${o}`));let l=e.tag??(t.default?null:t.tag);return l&&s.push(a.directives.tagString(l)),s.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,a):i.isScalar(l)?s.stringifyString(l,t,r,a):l.toString(t,r,a);return c?i.isScalar(l)||"{"===u[0]||"["===u[0]?`${c} ${u}`:`${c}
238
+ ${t.comment}`:s.comment}s=e}e.items[r]=n.isPair(s)?s:new i.Pair(s)}}else t("Expected a sequence for this tag");return e}function l(e,t,r){let{replacer:n}=r,a=new s.YAMLSeq(e);a.tag="tag:yaml.org,2002:pairs";let o=0;if(t&&Symbol.iterator in Object(t))for(let e of t){let s,l;if("function"==typeof n&&(e=n.call(t,String(o++),e)),Array.isArray(e))if(2===e.length)s=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[s=t[0]];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else s=e;a.items.push(i.createPair(s,l,r))}return a}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),a=r(505),s=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,a.seq,s.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),a=r(73);class s extends a.YAMLMap{constructor(e){super(e),this.tag=s.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),a.findPair(this.items,t.key)||this.items.push(t)}get(e,t){let r=a.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=a.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,a=new this(e);if(t&&Symbol.iterator in Object(t))for(let e of t)"function"==typeof n&&(e=n.call(t,e,e)),a.items.push(i.createPair(e,null,r));return a}}s.tag="tag:yaml.org,2002:set",t.YAMLSet=s,t.set={collection:"map",identify:e=>e instanceof Set,nodeClass:s,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,r)=>s.from(e,t,r),resolve(e,t){if(n.isMap(e))if(e.hasAllNullValues(!0))return Object.assign(new s,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),a=n.replace(/_/g,"").split(":").reduce((e,t)=>e*i(60)+i(t),i(0));return"-"===r?i(-1)*a:a}function a(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 a=r(60),s=[t%a];return t<60?s.unshift(0):(t=(t-s[0])/a,s.unshift(t%a),t>=60&&(t=(t-s[0])/a,s.unshift(t))),i+s.map(e=>String(e).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}let s={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(s.test);if(!t)throw Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,r,n,a,o,l,c]=t.map(Number),u=Date.UTC(r,n-1,a,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:a},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:a},t.timestamp=s},3980(e,t){let r="block",n="quoted";function i(e,t,r){let n=t,i=t+1,a=e[i];for(;" "===a||" "===a;)if(t<i+r)a=e[++t];else{do a=e[++t];while(a&&"\n"!==a)n=t,a=e[i=t+1]}return n}t.FOLD_BLOCK=r,t.FOLD_FLOW="flow",t.FOLD_QUOTED=n,t.foldFlowLines=function(e,t,a="flow",{indentAtStart:s,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 s&&(s>o-Math.max(2,l)?m.push(0):y=o-s);let b=!1,v=-1,w=-1,x=-1;for(a===r&&-1!==(v=i(e,v,t.length))&&(y=v+p);h=e[v+=1];){if(a===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)a===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(a===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 _=e.slice(0,m[0]);for(let r=0;r<m.length;++r){let i=m[r],s=m[r+1]||e.length;0===i?_=`
239
+ ${t}${e.slice(0,s)}`:(a===n&&g[i]&&(_+=`${e[i]}\\`),_+=`
240
+ ${t}${e.slice(i+1,s)}`)}return _}},6203(e,t,r){var n=r(9531),i=r(6730),a=r(3202),s=r(4286);t.createStringifyContext=function(e,t){let r,n=Object.assign({blockQuote:!0,commentString:a.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,a){let o;if(i.isPair(e))return e.toString(t,r,a);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:a}){if(!a.directives)return"";let s=[],o=(i.isScalar(e)||i.isCollection(e))&&e.anchor;o&&n.anchorIsValid(o)&&(r.add(o),s.push(`&${o}`));let l=e.tag??(t.default?null:t.tag);return l&&s.push(a.directives.tagString(l)),s.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,a):i.isScalar(l)?s.stringifyString(l,t,r,a):l.toString(t,r,a);return c?i.isScalar(l)||"{"===u[0]||"["===u[0]?`${c} ${u}`:`${c}
209
241
  ${t.indent}${u}`:u}},8143(e,t,r){var n=r(6730),i=r(6203),a=r(3202);function s({indent:e,options:{commentString:t}},r,n,i){if(n&&i&&(n=n.replace(/^\n+/,"")),n){let i=a.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(""),s(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(""),s(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+=a.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?`
210
242
  ${c}${l}${t}`:"\n";return`${e}
211
243
  ${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(""),s(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(""),s(r,y,e.commentBefore,g))}g=!1;let d=i.stringify(l,m,()=>u=null,()=>g=!0);u&&(d+=a.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?`
212
- ${h}${t}`:"\n"}}return e?(f+="\n"+a.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),a=r(3202);t.stringifyDocument=function(e,t){let r=[],s=!0===t.directives;if(!1!==t.directives&&e.directives){let t=e.directives.toString(e);t?(r.push(t),s=!0):e.directives.docStart&&(s=!0)}s&&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(a.indentComment(t,""))}let c=!1,u=null;if(e.contents){if(n.isNode(e.contents)){if(e.contents.spaceBefore&&s&&r.push(""),e.contents.commentBefore){let t=l(e.contents.commentBefore);r.push(a.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+=a.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(a.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(a.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 a=Object.is(n,-0)?"-0":JSON.stringify(n);if(!e&&t&&(!r||"tag:yaml.org,2002:float"===r)&&/^-?\d/.test(a)&&!a.includes("e")){let e=a.indexOf(".");e<0&&(e=a.length,a+=".");let r=t-(a.length-e-1);for(;r-- >0;)a+="0"}return a}},4711(e,t,r){var n=r(6730),i=r(8376),a=r(6203),s=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 _=!1,x=!1,k=a.stringify(e,r,()=>_=!0,()=>x=!0);if(!w&&!r.inFlow&&k.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 _&&o&&o(),""===k?"?":w?`? ${k}`:k}else if(f&&!b||null==t&&w)return k=`? ${k}`,v&&!_?k+=s.lineComment(k,r.indent,g(v)):x&&l&&l(),k;_&&(v=null),w?(v&&(k+=s.lineComment(k,r.indent,g(v))),k=`? ${k}
213
- ${p}:`):(k=`${k}:`,v&&(k+=s.lineComment(k,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=k.length+1),x=!1,!(!y&&m.length>=2&&!r.inFlow&&!w&&n.isSeq(t))||t.flow||t.tag||t.anchor||(r.indent=r.indent.substring(2));let S=!1,E=a.stringify(t,r,()=>S=!0,()=>x=!0),I=" ";if(v||c||u){if(I=c?"\n":"",u){let e=g(u);I+=`
214
- ${s.indentComment(e,r.indent)}`}""!==E||r.inFlow?I+=`
215
- ${r.indent}`:"\n"===I&&d&&(I="\n\n")}else if(!w&&n.isCollection(t)){let e=E[0],n=E.indexOf("\n"),i=-1!==n,a=r.inFlow??t.flow??0===t.items.length;if(i||!a){let t=!1;if(i&&("&"===e||"!"===e)){let r=E.indexOf(" ");"&"===e&&-1!==r&&r<n&&"!"===E[r+1]&&(r=E.indexOf(" ",r+1)),(-1===r||n<r)&&(t=!0)}t||(I=`
216
- ${r.indent}`)}}else(""===E||"\n"===E[0])&&(I="");return k+=I+E,r.inFlow?S&&o&&o():d&&!S?k+=s.lineComment(k,r.indent,g(d)):x&&l&&l(),k}},4286(e,t,r){let n;var i=r(8376),a=r(3980);let s=(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:a.foldFlowLines(l,o,a.FOLD_QUOTED,s(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,`$&
217
- ${r}`)+"'";return t.implicitKey?n:a.foldFlowLines(n,r,a.FOLD_FLOW,s(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 _=r.substring(h),x=_.indexOf("\n");-1===x?f="-":r===_||x!==_.length-1?(f="+",d&&d()):f="",_&&(r=r.slice(0,-_.length),"\n"===_[_.length-1]&&(_=_.slice(0,-1)),_=_.replace(n,`$&${v}`));let k=!1,S=-1;for(p=0;p<r.length;++p){let e=r[p];if(" "===e)k=!0;else if("\n"===e)S=p;else break}let E=r.substring(0,S<p?S+1:p);E&&(r=r.substring(E.length),E=E.replace(/\n+/g,`$&${v}`));let I=v?"2":"1",$=(k?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=s(o,!0);"folded"!==g&&t!==i.Scalar.BLOCK_FOLDED&&(l.onOverflow=()=>{n=!0});let c=a.foldFlowLines(`${E}${e}${_}`,v,a.FOLD_BLOCK,l);if(!n)return`>${$}
244
+ ${h}${t}`:"\n"}}return e?(f+="\n"+a.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),a=r(3202);t.stringifyDocument=function(e,t){let r=[],s=!0===t.directives;if(!1!==t.directives&&e.directives){let t=e.directives.toString(e);t?(r.push(t),s=!0):e.directives.docStart&&(s=!0)}s&&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(a.indentComment(t,""))}let c=!1,u=null;if(e.contents){if(n.isNode(e.contents)){if(e.contents.spaceBefore&&s&&r.push(""),e.contents.commentBefore){let t=l(e.contents.commentBefore);r.push(a.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+=a.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(a.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(a.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 a=Object.is(n,-0)?"-0":JSON.stringify(n);if(!e&&t&&(!r||"tag:yaml.org,2002:float"===r)&&/^-?\d/.test(a)&&!a.includes("e")){let e=a.indexOf(".");e<0&&(e=a.length,a+=".");let r=t-(a.length-e-1);for(;r-- >0;)a+="0"}return a}},4711(e,t,r){var n=r(6730),i=r(8376),a=r(6203),s=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,_=!1,k=a.stringify(e,r,()=>x=!0,()=>_=!0);if(!w&&!r.inFlow&&k.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(),""===k?"?":w?`? ${k}`:k}else if(f&&!b||null==t&&w)return k=`? ${k}`,v&&!x?k+=s.lineComment(k,r.indent,g(v)):_&&l&&l(),k;x&&(v=null),w?(v&&(k+=s.lineComment(k,r.indent,g(v))),k=`? ${k}
245
+ ${p}:`):(k=`${k}:`,v&&(k+=s.lineComment(k,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=k.length+1),_=!1,!(!y&&m.length>=2&&!r.inFlow&&!w&&n.isSeq(t))||t.flow||t.tag||t.anchor||(r.indent=r.indent.substring(2));let S=!1,I=a.stringify(t,r,()=>S=!0,()=>_=!0),E=" ";if(v||c||u){if(E=c?"\n":"",u){let e=g(u);E+=`
246
+ ${s.indentComment(e,r.indent)}`}""!==I||r.inFlow?E+=`
247
+ ${r.indent}`:"\n"===E&&d&&(E="\n\n")}else if(!w&&n.isCollection(t)){let e=I[0],n=I.indexOf("\n"),i=-1!==n,a=r.inFlow??t.flow??0===t.items.length;if(i||!a){let t=!1;if(i&&("&"===e||"!"===e)){let r=I.indexOf(" ");"&"===e&&-1!==r&&r<n&&"!"===I[r+1]&&(r=I.indexOf(" ",r+1)),(-1===r||n<r)&&(t=!0)}t||(E=`
248
+ ${r.indent}`)}}else(""===I||"\n"===I[0])&&(E="");return k+=E+I,r.inFlow?S&&o&&o():d&&!S?k+=s.lineComment(k,r.indent,g(d)):_&&l&&l(),k}},4286(e,t,r){let n;var i=r(8376),a=r(3980);let s=(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:a.foldFlowLines(l,o,a.FOLD_QUOTED,s(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,`$&
249
+ ${r}`)+"'";return t.implicitKey?n:a.foldFlowLines(n,r,a.FOLD_FLOW,s(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),_=x.indexOf("\n");-1===_?f="-":r===x||_!==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 k=!1,S=-1;for(p=0;p<r.length;++p){let e=r[p];if(" "===e)k=!0;else if("\n"===e)S=p;else break}let I=r.substring(0,S<p?S+1:p);I&&(r=r.substring(I.length),I=I.replace(/\n+/g,`$&${v}`));let E=v?"2":"1",$=(k?E:"")+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=s(o,!0);"folded"!==g&&t!==i.Scalar.BLOCK_FOLDED&&(l.onOverflow=()=>{n=!0});let c=a.foldFlowLines(`${I}${e}${x}`,v,a.FOLD_BLOCK,l);if(!n)return`>${$}
218
250
  ${v}${c}`}return r=r.replace(/\n+/g,`$&${v}`),`|${$}
219
- ${v}${E}${r}${_}`}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,`$&
220
- ${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:a.foldFlowLines(g,h,a.FOLD_FLOW,s(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"),a=Symbol("skip children"),s=Symbol("remove node");function o(e,t){let r=d(t);n.isDocument(e)?l(null,e.contents,r,Object.freeze([e]))===s&&(e.contents=null):l(null,e,r,Object.freeze([]))}function l(e,t,r,a){let o=f(e,t,r,a);if(n.isNode(o)||n.isPair(o))return h(e,a,o),l(e,o,r,a);if("symbol"!=typeof o){if(n.isCollection(t)){a=Object.freeze(a.concat(t));for(let e=0;e<t.items.length;++e){let n=l(e,t.items[e],r,a);if("number"==typeof n)e=n-1;else{if(n===i)return i;n===s&&(t.items.splice(e,1),e-=1)}}}else if(n.isPair(t)){a=Object.freeze(a.concat(t));let e=l("key",t.key,r,a);if(e===i)return i;e===s&&(t.key=null);let n=l("value",t.value,r,a);if(n===i)return i;n===s&&(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]))===s&&(e.contents=null):await u(null,e,r,Object.freeze([]))}async function u(e,t,r,a){let o=await f(e,t,r,a);if(n.isNode(o)||n.isPair(o))return h(e,a,o),u(e,o,r,a);if("symbol"!=typeof o){if(n.isCollection(t)){a=Object.freeze(a.concat(t));for(let e=0;e<t.items.length;++e){let n=await u(e,t.items[e],r,a);if("number"==typeof n)e=n-1;else{if(n===i)return i;n===s&&(t.items.splice(e,1),e-=1)}}}else if(n.isPair(t)){a=Object.freeze(a.concat(t));let e=await u("key",t.key,r,a);if(e===i)return i;e===s&&(t.key=null);let n=await u("value",t.value,r,a);if(n===i)return i;n===s&&(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=a,o.REMOVE=s,c.BREAK=i,c.SKIP=a,c.REMOVE=s,t.visit=o,t.visitAsync=c},8927(e,t,r){r.d(t,{CN:()=>h,BC:()=>g,Ie:()=>T,pb:()=>N,i8:()=>S,g9:()=>k,Uk:()=>E,Ts:()=>p,CZ:()=>b,ET:()=>v,HV:()=>_,Tj:()=>C,YW:()=>m,of:()=>A,jB:()=>M,TS:()=>P,di:()=>I,KC:()=>O});var n=r(8036),i=r(1044),a=r(4650);let s=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,a.XY)(2,(e,{onEmpty:t,onNonEmpty:r})=>v(e)?r(e):t()),g=(0,a.XY)(2,(e,t)=>[...e,t]),y=(0,a.XY)(2,(e,t)=>p(e).concat(p(t)));f.isArray;let b=s,v=s,w=(0,a.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),_=e=>v(e)?l.some(x(e)):l.none(),x=e=>e[e.length-1],k=(0,a.XY)(2,(e,t)=>{let r=0;for(let n of e){if(t(n,r))return l.some(r);r++}return l.none()}),S=o.i8,E=(0,a.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,a.XY)(2,(e,t)=>{let r=f.from(e);return r.sort(t),r}),$=(0,a.XY)(3,(e,t,r)=>{let n=p(e),i=p(t);return v(n)?v(i)?R(r)(y(n,i)):n:i}),O=(0,a.XY)(2,(e,t)=>$(e,t,n.jI())),T=()=>[],A=e=>[e],C=(0,a.XY)(2,(e,t)=>e.map(t)),N=(0,a.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,a.XY)(2,(e,t)=>{let r=[],n=[],i=0;for(let a of e){let e=t(a,i++);d.oJ(e)?n.push(e.success):r.push(e.failure)}return[r,n]}),P=(0,a.XY)(3,(e,t,r)=>p(e).reduce((e,t,n)=>r(e,t,n),t));c.O3,i.O3;let R=(0,a.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),a=r(4650),s=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,[s.HR](){let e=k(this);return s.kg(s.tW(e.value),s.ai(e.scale))},[n.HR](e){return m(e)&&C(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%_===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),_=BigInt(10),x=y(b,0),k=e=>{if(void 0===e.normalized)if(e.value===b)e.normalized=x;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},S=(0,a.XY)(2,(e,t)=>t>e.scale?g(e.value*_**BigInt(t-e.scale),t):t<e.scale?g(e.value/_**BigInt(e.scale-t),t):e),E=(0,a.XY)(2,(e,t)=>t.value===b?e:e.value===b?t:e.scale>t.scale?g(S(t,e.scale).value+e.value,e.scale):e.scale<t.scale?g(S(e,t.scale).value+t.value,t.scale):g(e.value+t.value,e.scale)),I=c.L8((e,t)=>{let r=c.wN(T(e),T(t));return 0!==r?r:e.scale>t.scale?c.Qw(e.value,S(t,e.scale).value):e.scale<t.scale?c.Qw(S(e,t.scale).value,t.value):c.Qw(e.value,t.value)}),$=c.hl(I),O=c.yJ(I),T=e=>e.value===b?0:e.value<b?-1:1,A=i.L8((e,t)=>e.scale>t.scale?S(t,e.scale).value===e.value:e.scale<t.scale?S(e,t.scale).value===t.value:e.value===t.value),C=(0,a.XY)(2,(e,t)=>A(e,t)),N=e=>{let t,r,n=k(e);if(Math.abs(n.scale)>=16)return M(n);let i=n.value<b,a=i?`${n.value}`.substring(1):`${n.value}`;if(n.scale>=a.length)t="0",r="0".repeat(n.scale-a.length)+a;else{let e=a.length-n.scale;if(e>a.length){let n=e-a.length;t=`${a}${"0".repeat(n)}`,r=""}else r=a.slice(e),t=a.slice(0,e)}let s=""===r?t:`${t}.${r}`;return i?`-${s}`:s},M=e=>{if(P(e))return"0e+0";let t=k(e),r=`${(t.value<b?g(-t.value,t.scale):t).value}`,n=r.slice(0,1),i=r.slice(1),a=`${R(t)?"-":""}${n}`;""!==i&&(a+=`.${i}`);let s=i.length-t.scale;return`${a}e${s>=0?"+":""}${s}`},P=e=>e.value===b,R=e=>e.value<b,j=e=>m(e[0]),D=(0,a.XY)(j,(e,t=0)=>e.scale<=t?e:g(e.value/_**BigInt(e.scale-t),t)),L=(0,a.XY)(j,(e,t=0)=>{let r=D(e,t);return e.value>b&&$(r,e)?E(r,g(v,t)):r}),U=(0,a.XY)(j,(e,t=0)=>{let r=D(e,t);return R(e)&&O(r,e)?E(r,g(w,t)):r});r.d(t,{},{GP:N,L8:g,RI:U,hs:S,mk:L,pH:I,rs:A,s5:m,sH:e=>{let t,r,n,i;if(""===e)return l.some(x);let a=e.search(/[eE]/);if(-1!==a){let n=e.slice(a+1);if(t=e.slice(0,a),r=Number(n),""===t||!Number.isSafeInteger(r)||!f.test(n))return l.none()}else t=e,r=0;let s=t.search(/\./);if(-1!==s){let e=t.slice(0,s),r=t.slice(s+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 a=n.lC;n.Xb,n.ik,n.b5,n.DH;let s=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:s,iw:c,j9:h,kh:u,lC:a,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),a=r(4650),s=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)(S(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(S(t.context,this)))},useSync(e){return(0,o.R6)(t=>(0,o.xt)(e(S(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},[s.HR](){return s.ai(this.mapUnsafe.size)}},b=e=>(0,u.i5)(e,m),v=g(new Map),w=(e,t)=>g(new Map([[e.key,t]])),_=(0,a.XY)(3,(e,t,r)=>A(e,e=>{e.set(t.key,r)})),x=(0,a.XY)(2,(e,t)=>e.mapUnsafe.get(t.key)),k=(0,a.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=k,E="~effect/Context/defaultValue",I=e=>E in e?e[E]:e[E]=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},O=(0,a.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()),T=(0,a.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:S,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:_,Y6:x,aE:b,fp:k,h1:T,kA:(e,t)=>e.mapUnsafe.has(t.key)?e.mapUnsafe.get(t.key):I(t),kl:f,om:O})},2718(e,t,r){var n=r(8433),i=r(9138),a=r(5369);let s=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?a.$J:"$match"===t?o:e=>({...e,_tag:t})}),Xs:s,rN:c})},4705(e,t,r){r.d(t,{rs:()=>ef,pH:()=>eh,dv:()=>eI,Rd:()=>e$,tn:()=>ep,Ar:()=>es,kQ:()=>eo,rg:()=>ec,lU:()=>el,rr:()=>eu,Ry:()=>ed,L8:()=>eg,MO:()=>ey,TT:()=>em,yF:()=>eS,Xy:()=>eE,yT:()=>eb,ez:()=>ex,y3:()=>e_,k9:()=>ev,ko:()=>ew,xV:()=>ek}),r(8619);var n=r(4650),i=r(8543),a=r(190),s=(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 q(this).toJSON()}},y={...g,_tag:"Utc",[l.HR](){return l.ai(this.epochMilliseconds)},[s.HR](e){return k(e)&&"Utc"===e._tag&&this.epochMilliseconds===e.epochMilliseconds},toString(){return`DateTime.Utc(${q(this).toJSON()})`}},b={...g,_tag:"Zoned",[l.HR](){return l.kg(l.ai(this.epochMilliseconds))(l.tW(this.zone))},[s.HR](e){return k(e)&&"Zoned"===e._tag&&this.epochMilliseconds===e.epochMilliseconds&&s.aI(this.zone,e.zone)},toString(){return`DateTime.Zoned(${ea(this)})`}},v={[m]:m,[c.FX](){return this.toString()}},w={...v,_tag:"Named",[l.HR](){return l.Yj(`Named:${this.id}`)},[s.HR](e){return E(e)&&"Named"===e._tag&&this.id===e.id},toString(){return`TimeZone.Named(${this.id})`},toJSON(){return{_id:"TimeZone",_tag:"Named",id:this.id}}},_={...v,_tag:"Offset",[l.HR](){return l.Yj(`Offset:${this.offset}`)},[s.HR](e){return E(e)&&"Offset"===e._tag&&this.offset===e.offset},toString(){return`TimeZone.Offset(${z(this.offset)})`},toJSON(){return{_id:"TimeZone",_tag:"Offset",offset:this.offset}}},x=(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},k=e=>h.i5(e,p),S=e=>k(e[0]),E=e=>h.i5(e,m),I=e=>"Zoned"===e._tag,$=o.L8((e,t)=>e.epochMilliseconds===t.epochMilliseconds),O=d.L8((e,t)=>e.epochMilliseconds<t.epochMilliseconds?-1:+(e.epochMilliseconds>t.epochMilliseconds)),T=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 T(t)},C=e=>{if(k(e))return e;if(e instanceof Date)return A(e);if("object"==typeof e){if("epochMilliseconds"in e)return T(e.epochMilliseconds);let t=new Date(0);return V(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&&k(e)&&I(e))return e;let a=C(e);if(a.epochMilliseconds<-86399999568e5||a.epochMilliseconds>86399999496e5)throw RangeError(`Epoch millis out of range: ${a.epochMilliseconds}`);if(void 0===n&&"object"==typeof e&&"timeZoneId"in e&&(n=e.timeZoneId),void 0===n)r=F(-60*new Date(a.epochMilliseconds).getTimezoneOffset()*1e3);else if(E(n))r=n;else if("number"==typeof n)r=F(n);else{let e=W(n);if(u.isNone(e))throw new i.qw(`Invalid time zone: ${n}`);r=e.value}return t?.adjustForTimeZone!==!0?x(a.epochMilliseconds,r,a.partsUtc):K(a.epochMilliseconds,r,t?.disambiguation??"compatible")},P=u.liftThrowable(M),R=u.liftThrowable(C),j=/^(.{17,35})\[(.+)\]$/;a.Ru,a.Ru,(e,t,r)=>r?.adjustForTimeZone===!0?K(e.epochMilliseconds,t,r?.disambiguation??"compatible"):x(e.epochMilliseconds,t,e.partsUtc);let D=new Map,L={day:"numeric",month:"numeric",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"longOffset",fractionalSecondDigits:3,hourCycle:"h23"},U=e=>{if(D.has(e))return D.get(e);try{var t=new Intl.DateTimeFormat("en-US",{...L,timeZone:e});let r=t.resolvedOptions().timeZone;if(D.has(r))return D.get(r);let n=Object.create(w);return n.id=r,n.format=t,D.set(r,n),n}catch{throw new i.qw(`Invalid time zone: ${e}`)}},F=e=>{let t=Object.create(_);return t.offset=e,t},B=u.liftThrowable(U),Y=/^(?:GMT|[+-])/,W=e=>{if(Y.test(e)){let t=Q(e);return null===t?u.none():u.some(F(t))}return B(e)},q=e=>new Date(e.epochMilliseconds),X=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},J=e=>X(e).getTime()-G(e),z=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")}`},G=e=>e.epochMilliseconds,V=(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)},K=(e,t,r)=>{if("Offset"===t._tag)return x(e-t.offset,t);let n=Z(e-864e5,e,t),i=Z(e+864e5,e,t);if(n===i)return x(e-n,t);let a=n-i;if(n<i){if(Z(e-i,e,t)===i)return x(e-i,t);let a=x(e-n,t);if(e!==X(a).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 x(e-i,t)}return a}if(Z(e-n,e,t)===n){if("earlier"===r||"compatible"===r||Z(e-n+a,e+a,t)===n)return x(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 x(e-i,t)},H=/([+-])(\d{2}):(\d{2})$/,Q=e=>{let t=H.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?J(x(t,r)):i},ee=(0,n.XY)(S,(e,t,r)=>{if("Utc"===e._tag){let r=q(e);return t(r),T(r.getTime())}let n=new Date(X(e).getTime());return t(n),K(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(G(e));return"Utc"===e._tag?T(r):x(r,e.zone)})),er=((e,t)=>t(X(e)),(0,n.XY)(2,(e,t)=>t(q(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=X(e);return"Utc"===e._tag?t.toISOString():`${t.toISOString().slice(0,-1)}${z(J(e))}`}),ea=e=>"Offset"===e.zone._tag?ei(e):`${ei(e)}[${e.zone.id}]`;r(5089);let es=k,eo=E,el=e=>E(e)&&"Offset"===e._tag,ec=e=>E(e)&&"Named"===e._tag,eu=e=>"Utc"===e._tag,ed=I,ef=$,eh=O,ep=A,em=M,eg=R,ey=e=>{let t=j.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=>T(e.epochMilliseconds),ev=U,ew=F,e_=B,ex=W,ek=e=>"Offset"===e._tag?z(e.offset):e.id,eS=q,eE=G,eI=e=>q(e).toISOString(),e$=ea},3717(e,t,r){var n=r(4650),i=r(1136),a=r(9138);let s={"~effect/Deferred":{_A:n.D_,_E:n.D_},pipe(){return(0,a.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(s);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),a=r(4450),s=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 C(e);case"bigint":return A(e);case"string":{if("Infinity"===e)return O;if("-Infinity"===e)return T;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 a=Number(n);switch(i){case"milli":case"millis":return C(a);case"second":case"seconds":return N(a);case"minute":case"minutes":return M(a);case"hour":case"hours":return P(a);case"day":case"days":return R(a);case"week":case"weeks":return j(a)}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 T;if(e[0]===1/0||e[1]===1/0)return O;return E(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 E(t);return E(m(1e6*t+(e.microseconds??0)*1e3+(e.nanoseconds??0)))}}return v(e)},v=e=>{throw Error(`Invalid Input: ${e}`)},w=o.liftThrowable(b),_={_tag:"Millis",millis:0},x={_tag:"Infinity"},k={_tag:"NegativeInfinity"},S={[d]:d,[a.HR](){return a.QK(this.value)},[n.HR](e){return I(e)&&q(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"}}},[s.FX](){return this.toJSON()},pipe(){return(0,c.tT)(this,arguments)}},E=e=>{let t=Object.create(S);return"number"==typeof e?isNaN(e)||0===e||Object.is(e,-0)?t.value=_:Number.isFinite(e)?Number.isInteger(e)?t.value={_tag:"Millis",millis:e}:t.value={_tag:"Nanos",nanos:m(1e6*e)}:t.value=e>0?x:k:e===f?t.value=_:t.value={_tag:"Nanos",nanos:e},t},I=e=>(0,u.i5)(e,d),$=E(0),O=E(1/0),T=E(-1/0),A=e=>E(e),C=e=>E(e),N=e=>E(1e3*e),M=e=>E(6e4*e),P=e=>E(36e5*e),R=e=>E(864e5*e),j=e=>E(6048e5*e),D=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(D),U=(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)()}}),F=(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(D(e),t.value.nanos):r.onNanos(e.value.nanos,D(t))),B=l.L8((e,t)=>F(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)=>F(e,t,{onMillis:(e,t)=>e===t,onNanos:(e,t)=>e===t,onInfinity:(e,t)=>e.value._tag===t.value._tag}),W=l.bi(B),q=(0,i.XY)(2,(e,t)=>Y(e,t));r.d(t,{},{MI:e=>"Infinity"!==e.value._tag&&"NegativeInfinity"!==e.value._tag,Tn:O,bN:b,bi:W,cF:A,kE:e=>U(b(e),{onMillis:i.D_,onNanos:e=>Number(e)/1e6,onInfinity:()=>1/0,onNegativeInfinity:()=>-1/0}),lX:w,n$:I,ne:C,qv:T,rs:Y,tb:L,v_:$})},7720(e,t,r){r.d(t,{Q56:()=>e_,jGc:()=>ex,U9h:()=>ek,Q7R:()=>_,hgn:()=>W,swY:()=>eW,Muk:()=>eC,as:()=>V,NLW:()=>K,E2r:()=>N,MfU:()=>H,Tyx:()=>ee,osR:()=>et,KuX:()=>Q,loE:()=>Z,RKA:()=>eB,_32:()=>eN,_r7:()=>eq,yeE:()=>eS,NS5:()=>z,fJG:()=>R,ATB:()=>j,pVV:()=>D,qIB:()=>Y,Ab9:()=>eG,fn:()=>eF,D9k:()=>eU,vCS:()=>eV,jJl:()=>x,i4r:()=>eA,ar0:()=>eP,x6Z:()=>eR,yUA:()=>B,JkU:()=>P,XeO:()=>eo,GaK:()=>e$,yw5:()=>w,vVN:()=>eY,TjK:()=>G,q7Y:()=>ez,jkJ:()=>eX,xm_:()=>er,Z9x:()=>eJ,YWq:()=>ed,khu:()=>ef,tvg:()=>eh,ZmZ:()=>M,S5A:()=>eE,cfM:()=>eI,uKv:()=>J,QgK:()=>en,ivC:()=>S,Gte:()=>ep,PpN:()=>em,PfK:()=>ey,KT6:()=>eu,Ket:()=>X,L5P:()=>es,MY7:()=>ej,eJC:()=>eD,lKS:()=>eL,z8E:()=>eb,P1j:()=>ev,Pxi:()=>ew,Nav:()=>eg,yy4:()=>ec,PyW:()=>I,lwU:()=>$,nGE:()=>O,DYE:()=>T,OH5:()=>A,Mim:()=>q,dGm:()=>ea,sFT:()=>ei,mgX:()=>el,SvU:()=>U,$mh:()=>E,rfi:()=>eO,FcF:()=>eT,rIH:()=>C,iMI:()=>k,R6R:()=>F,fRP:()=>eM});var n=r(4650),i=r(8433),a=r(1136),s=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 s.aE(t)?a.PpN(e,t):(n=Array.isArray(t)?l.Um(...t):t,a.Pxi(t=>a.qIB(r?.local?l.H7(n,l.j6(),t):l.LT(n,t),t=>a.PpN(e,t))))});var u=r(3833),d=r(4505),f=r(3537);(e,t,r)=>a.qIB(o.xn(t),t=>{let n=o.d3.defaultValue();return a.h_t(a.i4r(a.Mim(a.qIB(a.DYE(()=>a.PfK(e,o.d3,n)),t),e=>a.OH5(()=>{n=e})),{disableYield:!0}),e=>i.$L(e)?a.PyW(e.value):r(e,0===n.attempt?u.none():u.some(n)))});let h=(0,n.XY)(3,(e,t,r)=>a.qIB(o.xn(t),t=>{let n,i=o.d3.defaultValue(),s=a.h_t(a.DYE(()=>a.PfK(e,o.d3,i)),e=>(n=e,a.qIB(t(e),e=>(i=e,s))));return d.m8(s,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),a.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:a.PyW(r)})),e.until&&(t=o.E6(t,({input:t})=>{let r=e.until(t);return i.yw(r)?a.TjK(r,e=>!e):a.PyW(!r)})),void 0!==e.times&&(t=o.E6(t,({attempt:t})=>a.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,_=a.Q7R;a.jBG,a.tfT,a.i8i,a.kAe;let x=a.jJl,k=a.iMI,S=a.ivC,E=a.$mh,I=a.PyW,$=a.lwU,O=a.nGE,T=a.DYE,A=a.OH5,C=a.rIH;a.Vxk;let N=a.E2r,M=a.ZmZ;a.Do,a.JrD,a.uVU,a.oIE;let P=a.JkU,R=a.fJG;a.gOk;let j=a.ATB,D=a.pVV,L=a.F_Q,U=a.SvU;a.m9E,a.KN3;let F=i.R6,B=a.yUA;a.sVm,a.pkL,a.bJ;let Y=a.qIB;a.Bqz;let W=a.hgn,q=a.Mim,X=a.Ket,J=a.uKv,z=a.NS5,G=a.TjK,V=a.as;a.Xx$;let K=a.NLW;a.UUz,a.yU6,a.OYO;let H=a.h_t,Q=a.KuX,Z=a.loE;a.AXC,a.zt4,a.scW;let ee=a.Tyx;a.Fig,a.XWm;let et=a.osR;a.U9Y,a.sJf,a.rNk;let er=a.xm_;a.UcN;let en=a.QgK,ei=a.sFT;a.k$L;let ea=a.dGm;a.cA6,a.bKC,a.nAi,a.u4Y;let es=p;a._Sg;let eo=a.XeO;a.GrF,a.$$g,a.DM4,a.Dd,a.wRz,a.D52;let el=a.mgX;a.cbG;let ec=a.yy4;a.ayu,a.Vdx,a.FfP,a.O4F;let eu=a.KT6;a.pbD,a.x1Q,a.E8K,a.Pm0,a.VtY,a.W$I,a.ahH,a.z7s;let ed=a.YWq;a.G$Q,a.D$$,a.NZb,a.wR5;let ef=a.khu,eh=a.tvg;a.N6O,a.oJd,a._OA,a.sxi;let ep=c,em=a.PpN;a.oao,a.euC;let eg=a.Nav;a.r_d,a.bUZ;let ey=a.PfK;a.c7E,a.KyM;let eb=a.z8E,ev=a.P1j,ew=a.Pxi,e_=a.Q56;a.N24;let ex=a.jGc,ek=a.U9h,eS=a.yeE,eE=a.S5A;a.BeE,a.iKM,a.r7h;let eI=a.cfM;a.fGe,a.uRq,a.PO3,a.Rgn,a.CJw;let e$=a.GaK;a.Inz,a.nAr;let eO=a.rfi,eT=a.FcF;a.eMl,a.dsN;let eA=a.i4r;a.aAq,a.Xrv,a.kJM,a._o1,a.nDN,a.MaT;let eC=a.Muk;a.ww9;let eN=a._32;a.Wj8,a.Fu6,a.WbR,a.A_r,a.Z98,a.Rd$,a.gvr;let eM=a.fRP;a.zr8,a.hq,a.zhn;let eP=a.ar0,eR=a.x6Z;a.yxg,a.PCg,a.pEE,a.ABT;let ej=a.MY7,eD=a.eJC;a.lSz,a.bPG,a.pR5,a.v2Q,a.NpQ,a.jqV,a.HZF,a.lE;let eL=a.lKS;a.rfH;let eU=a.D9k,eF=a.fn,eB=a.RKA;a.lIX;let eY=a.lIX("Error"),eW=(0,n.XY)(e=>w(e[0]),(e,...t)=>a.bUZ(e,v.iL,e=>{let r={...e};return 1===t.length?Object.assign(r,t[0]):r[t[0]]=t[1],r}));a.gsV;let eq=(e,t,r)=>(...n)=>N(i=>{try{e(...n,(e,r)=>{e?i(R(t?t(e,n):e)):i(I(r))})}catch(e){i(r?R(r(e,n)):L(e))}}),eX=a.jkJ,eJ=a.Z9x,ez=a.q7Y,eG=a.Ab9;a.UVN;let eV=a.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 a="~effect/encoding/EncodingError";class s extends n.rN("EncodingError"){[a]=a}let o=e=>{let t=f(e),r=t.length;if(r%4!=0)return i.fJ(new s({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 s({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 s({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 s({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 s({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 s({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 s({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,a,s=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 a=m.get(t);return a||(a=new WeakMap,m.set(t,a)),a.set(e,i),i}(e,t,p))}let f=new WeakSet,h=new WeakSet;function p(e,t){if(s.tW(e)!==s.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 a=r();return f.delete(e),h.delete(t),a}(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 a=(0,o.X)(r),s=(0,o.X)(n);if(a.size!==s.size)return!1;for(let e of a)if(!s.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,a]of e){let e=!1;for(let[s,o]of t)if(n(r,s)&&i(a,o)){e=!0;break}if(!e)return!1}return!0}),y=(a=d,function(e,t){for(let r of e){let e=!1;for(let n of t)if(a(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 a(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 s(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:()=>a,_k:()=>s},{L8:n,wN:i})},7598(e,t,r){var n=r(8433),i=r(1136);n.IH,n.b9;let a=n.xt,s=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:s,N6:u,Py:a,fJ:o,oJ:c,rI:l})},956(e,t,r){var n=r(4650),i=r(3833),a=r(5369),s=r(995);a.Kg,a.Et,a.Lm,a.sI,a.Bm,a.$P;let o=(0,n.XY)(2,(e,t)=>r=>{let n=e(r);if(s.N6(n))return s.fJ(r);let i=t(n.success);return s.N6(i)?s.fJ(r):i});r.d(t,{},{Bh:o,zL:e=>t=>{let r=e(t);return s.N6(r)?i.none():i.some(r.success)}})},6470(e,t,r){var n=r(5369),i=r(1743);let a="[Circular]";function s(e){return"string"==typeof e?JSON.stringify(e):String(e)}function o(e){return e.map(e=>`[${s(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 a;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`[
251
+ ${v}${I}${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,`$&
252
+ ${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:a.foldFlowLines(g,h,a.FOLD_FLOW,s(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"),a=Symbol("skip children"),s=Symbol("remove node");function o(e,t){let r=d(t);n.isDocument(e)?l(null,e.contents,r,Object.freeze([e]))===s&&(e.contents=null):l(null,e,r,Object.freeze([]))}function l(e,t,r,a){let o=f(e,t,r,a);if(n.isNode(o)||n.isPair(o))return h(e,a,o),l(e,o,r,a);if("symbol"!=typeof o){if(n.isCollection(t)){a=Object.freeze(a.concat(t));for(let e=0;e<t.items.length;++e){let n=l(e,t.items[e],r,a);if("number"==typeof n)e=n-1;else{if(n===i)return i;n===s&&(t.items.splice(e,1),e-=1)}}}else if(n.isPair(t)){a=Object.freeze(a.concat(t));let e=l("key",t.key,r,a);if(e===i)return i;e===s&&(t.key=null);let n=l("value",t.value,r,a);if(n===i)return i;n===s&&(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]))===s&&(e.contents=null):await u(null,e,r,Object.freeze([]))}async function u(e,t,r,a){let o=await f(e,t,r,a);if(n.isNode(o)||n.isPair(o))return h(e,a,o),u(e,o,r,a);if("symbol"!=typeof o){if(n.isCollection(t)){a=Object.freeze(a.concat(t));for(let e=0;e<t.items.length;++e){let n=await u(e,t.items[e],r,a);if("number"==typeof n)e=n-1;else{if(n===i)return i;n===s&&(t.items.splice(e,1),e-=1)}}}else if(n.isPair(t)){a=Object.freeze(a.concat(t));let e=await u("key",t.key,r,a);if(e===i)return i;e===s&&(t.key=null);let n=await u("value",t.value,r,a);if(n===i)return i;n===s&&(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=a,o.REMOVE=s,c.BREAK=i,c.SKIP=a,c.REMOVE=s,t.visit=o,t.visitAsync=c},8927(e,t,r){r.d(t,{CN:()=>h,BC:()=>g,Ie:()=>C,pb:()=>M,i8:()=>S,g9:()=>k,Uk:()=>I,Ts:()=>p,CZ:()=>b,ET:()=>v,HV:()=>x,Tj:()=>A,YW:()=>m,of:()=>T,jB:()=>N,TS:()=>P,di:()=>E,KC:()=>O});var n=r(8036),i=r(1044),a=r(4650);let s=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,a.XY)(2,(e,{onEmpty:t,onNonEmpty:r})=>v(e)?r(e):t()),g=(0,a.XY)(2,(e,t)=>[...e,t]),y=(0,a.XY)(2,(e,t)=>p(e).concat(p(t)));f.isArray;let b=s,v=s,w=(0,a.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(_(e)):l.none(),_=e=>e[e.length-1],k=(0,a.XY)(2,(e,t)=>{let r=0;for(let n of e){if(t(n,r))return l.some(r);r++}return l.none()}),S=o.i8,I=(0,a.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()}),E=(0,a.XY)(2,(e,t)=>{let r=f.from(e);return r.sort(t),r}),$=(0,a.XY)(3,(e,t,r)=>{let n=p(e),i=p(t);return v(n)?v(i)?R(r)(y(n,i)):n:i}),O=(0,a.XY)(2,(e,t)=>$(e,t,n.jI())),C=()=>[],T=e=>[e],A=(0,a.XY)(2,(e,t)=>e.map(t)),M=(0,a.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}),N=(0,a.XY)(2,(e,t)=>{let r=[],n=[],i=0;for(let a of e){let e=t(a,i++);d.oJ(e)?n.push(e.success):r.push(e.failure)}return[r,n]}),P=(0,a.XY)(3,(e,t,r)=>p(e).reduce((e,t,n)=>r(e,t,n),t));c.O3,i.O3;let R=(0,a.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),a=r(4650),s=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,[s.HR](){let e=k(this);return s.kg(s.tW(e.value),s.ai(e.scale))},[n.HR](e){return m(e)&&A(this,e)},toString(){return`BigDecimal(${M(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),_=y(b,0),k=e=>{if(void 0===e.normalized)if(e.value===b)e.normalized=_;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},S=(0,a.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),I=(0,a.XY)(2,(e,t)=>t.value===b?e:e.value===b?t:e.scale>t.scale?g(S(t,e.scale).value+e.value,e.scale):e.scale<t.scale?g(S(e,t.scale).value+t.value,t.scale):g(e.value+t.value,e.scale)),E=c.L8((e,t)=>{let r=c.wN(C(e),C(t));return 0!==r?r:e.scale>t.scale?c.Qw(e.value,S(t,e.scale).value):e.scale<t.scale?c.Qw(S(e,t.scale).value,t.value):c.Qw(e.value,t.value)}),$=c.hl(E),O=c.yJ(E),C=e=>e.value===b?0:e.value<b?-1:1,T=i.L8((e,t)=>e.scale>t.scale?S(t,e.scale).value===e.value:e.scale<t.scale?S(e,t.scale).value===t.value:e.value===t.value),A=(0,a.XY)(2,(e,t)=>T(e,t)),M=e=>{let t,r,n=k(e);if(Math.abs(n.scale)>=16)return N(n);let i=n.value<b,a=i?`${n.value}`.substring(1):`${n.value}`;if(n.scale>=a.length)t="0",r="0".repeat(n.scale-a.length)+a;else{let e=a.length-n.scale;if(e>a.length){let n=e-a.length;t=`${a}${"0".repeat(n)}`,r=""}else r=a.slice(e),t=a.slice(0,e)}let s=""===r?t:`${t}.${r}`;return i?`-${s}`:s},N=e=>{if(P(e))return"0e+0";let t=k(e),r=`${(t.value<b?g(-t.value,t.scale):t).value}`,n=r.slice(0,1),i=r.slice(1),a=`${R(t)?"-":""}${n}`;""!==i&&(a+=`.${i}`);let s=i.length-t.scale;return`${a}e${s>=0?"+":""}${s}`},P=e=>e.value===b,R=e=>e.value<b,j=e=>m(e[0]),D=(0,a.XY)(j,(e,t=0)=>e.scale<=t?e:g(e.value/x**BigInt(e.scale-t),t)),L=(0,a.XY)(j,(e,t=0)=>{let r=D(e,t);return e.value>b&&$(r,e)?I(r,g(v,t)):r}),U=(0,a.XY)(j,(e,t=0)=>{let r=D(e,t);return R(e)&&O(r,e)?I(r,g(w,t)):r});r.d(t,{},{GP:M,L8:g,RI:U,hs:S,mk:L,pH:E,rs:T,s5:m,sH:e=>{let t,r,n,i;if(""===e)return l.some(_);let a=e.search(/[eE]/);if(-1!==a){let n=e.slice(a+1);if(t=e.slice(0,a),r=Number(n),""===t||!Number.isSafeInteger(r)||!f.test(n))return l.none()}else t=e,r=0;let s=t.search(/\./);if(-1!==s){let e=t.slice(0,s),r=t.slice(s+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 a=n.lC;n.Xb,n.ik,n.b5,n.DH;let s=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:s,iw:c,j9:h,kh:u,lC:a,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),a=r(4650),s=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)(S(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(S(t.context,this)))},useSync(e){return(0,o.R6)(t=>(0,o.xt)(e(S(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},[s.HR](){return s.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,a.XY)(3,(e,t,r)=>T(e,e=>{e.set(t.key,r)})),_=(0,a.XY)(2,(e,t)=>e.mapUnsafe.get(t.key)),k=(0,a.XY)(2,(e,t)=>{if(!e.mapUnsafe.has(t.key)){if(p in t)return E(t);throw $(t)}return e.mapUnsafe.get(t.key)}),S=k,I="~effect/Context/defaultValue",E=e=>I in e?e[I]:e[I]=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},O=(0,a.XY)(2,(e,t)=>e.mapUnsafe.has(t.key)?c.some(e.mapUnsafe.get(t.key)):(0,u.i5)(t,p)?c.some(E(t)):c.none()),C=(0,a.XY)(2,(e,t)=>0===e.mapUnsafe.size?t:0===t.mapUnsafe.size?e:T(e,e=>{t.mapUnsafe.forEach((t,r)=>e.set(r,t))})),T=(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:S,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:_,aE:b,fp:k,h1:C,kA:(e,t)=>e.mapUnsafe.has(t.key)?e.mapUnsafe.get(t.key):E(t),kl:f,om:O})},2718(e,t,r){var n=r(8433),i=r(9138),a=r(5369);let s=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?a.$J:"$match"===t?o:e=>({...e,_tag:t})}),Xs:s,rN:c})},4705(e,t,r){r.d(t,{rs:()=>ef,pH:()=>eh,dv:()=>eE,Rd:()=>e$,tn:()=>ep,Ar:()=>es,kQ:()=>eo,rg:()=>ec,lU:()=>el,rr:()=>eu,Ry:()=>ed,L8:()=>eg,MO:()=>ey,TT:()=>em,yF:()=>eS,Xy:()=>eI,yT:()=>eb,ez:()=>e_,y3:()=>ex,k9:()=>ev,ko:()=>ew,xV:()=>ek}),r(8619);var n=r(4650),i=r(8543),a=r(190),s=(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 Y(this).toJSON()}},y={...g,_tag:"Utc",[l.HR](){return l.ai(this.epochMilliseconds)},[s.HR](e){return k(e)&&"Utc"===e._tag&&this.epochMilliseconds===e.epochMilliseconds},toString(){return`DateTime.Utc(${Y(this).toJSON()})`}},b={...g,_tag:"Zoned",[l.HR](){return l.kg(l.ai(this.epochMilliseconds))(l.tW(this.zone))},[s.HR](e){return k(e)&&"Zoned"===e._tag&&this.epochMilliseconds===e.epochMilliseconds&&s.aI(this.zone,e.zone)},toString(){return`DateTime.Zoned(${ea(this)})`}},v={[m]:m,[c.FX](){return this.toString()}},w={...v,_tag:"Named",[l.HR](){return l.Yj(`Named:${this.id}`)},[s.HR](e){return I(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}`)},[s.HR](e){return I(e)&&"Offset"===e._tag&&this.offset===e.offset},toString(){return`TimeZone.Offset(${J(this.offset)})`},toJSON(){return{_id:"TimeZone",_tag:"Offset",offset:this.offset}}},_=(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},k=e=>h.i5(e,p),S=e=>k(e[0]),I=e=>h.i5(e,m),E=e=>"Zoned"===e._tag,$=o.L8((e,t)=>e.epochMilliseconds===t.epochMilliseconds),O=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},T=e=>{let t=e.getTime();if(Number.isNaN(t))throw new i.qw("Invalid date");return C(t)},A=e=>{if(k(e))return e;if(e instanceof Date)return T(e);if("object"==typeof e){if("epochMilliseconds"in e)return C(e.epochMilliseconds);let t=new Date(0);return V(t,e),T(t)}return"string"!=typeof e||M(e)?T(new Date(e)):T(new Date(e+"Z"))},M=e=>/Z|GMT|[+-]\d{2}$|[+-]\d{2}:?\d{2}$|\]$/.test(e),N=(e,t)=>{let r,n=t?.timeZone;if(void 0===n&&k(e)&&E(e))return e;let a=A(e);if(a.epochMilliseconds<-86399999568e5||a.epochMilliseconds>86399999496e5)throw RangeError(`Epoch millis out of range: ${a.epochMilliseconds}`);if(void 0===n&&"object"==typeof e&&"timeZoneId"in e&&(n=e.timeZoneId),void 0===n)r=F(-60*new Date(a.epochMilliseconds).getTimezoneOffset()*1e3);else if(I(n))r=n;else if("number"==typeof n)r=F(n);else{let e=q(n);if(u.isNone(e))throw new i.qw(`Invalid time zone: ${n}`);r=e.value}return t?.adjustForTimeZone!==!0?_(a.epochMilliseconds,r,a.partsUtc):K(a.epochMilliseconds,r,t?.disambiguation??"compatible")},P=u.liftThrowable(N),R=u.liftThrowable(A),j=/^(.{17,35})\[(.+)\]$/;a.Ru,a.Ru,(e,t,r)=>r?.adjustForTimeZone===!0?K(e.epochMilliseconds,t,r?.disambiguation??"compatible"):_(e.epochMilliseconds,t,e.partsUtc);let D=new Map,L={day:"numeric",month:"numeric",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"longOffset",fractionalSecondDigits:3,hourCycle:"h23"},U=e=>{if(D.has(e))return D.get(e);try{var t=new Intl.DateTimeFormat("en-US",{...L,timeZone:e});let r=t.resolvedOptions().timeZone;if(D.has(r))return D.get(r);let n=Object.create(w);return n.id=r,n.format=t,D.set(r,n),n}catch{throw new i.qw(`Invalid time zone: ${e}`)}},F=e=>{let t=Object.create(x);return t.offset=e,t},B=u.liftThrowable(U),W=/^(?:GMT|[+-])/,q=e=>{if(W.test(e)){let t=Q(e);return null===t?u.none():u.some(F(t))}return B(e)},Y=e=>new Date(e.epochMilliseconds),z=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},X=e=>z(e).getTime()-G(e),J=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")}`},G=e=>e.epochMilliseconds,V=(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)},K=(e,t,r)=>{if("Offset"===t._tag)return _(e-t.offset,t);let n=Z(e-864e5,e,t),i=Z(e+864e5,e,t);if(n===i)return _(e-n,t);let a=n-i;if(n<i){if(Z(e-i,e,t)===i)return _(e-i,t);let a=_(e-n,t);if(e!==z(a).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 _(e-i,t)}return a}if(Z(e-n,e,t)===n){if("earlier"===r||"compatible"===r||Z(e-n+a,e+a,t)===n)return _(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 _(e-i,t)},H=/([+-])(\d{2}):(\d{2})$/,Q=e=>{let t=H.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?X(_(t,r)):i},ee=(0,n.XY)(S,(e,t,r)=>{if("Utc"===e._tag){let r=Y(e);return t(r),C(r.getTime())}let n=new Date(z(e).getTime());return t(n),K(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(G(e));return"Utc"===e._tag?C(r):_(r,e.zone)})),er=((e,t)=>t(z(e)),(0,n.XY)(2,(e,t)=>t(Y(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=z(e);return"Utc"===e._tag?t.toISOString():`${t.toISOString().slice(0,-1)}${J(X(e))}`}),ea=e=>"Offset"===e.zone._tag?ei(e):`${ei(e)}[${e.zone.id}]`;r(5089);let es=k,eo=I,el=e=>I(e)&&"Offset"===e._tag,ec=e=>I(e)&&"Named"===e._tag,eu=e=>"Utc"===e._tag,ed=E,ef=$,eh=O,ep=T,em=N,eg=R,ey=e=>{let t=j.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=U,ew=F,ex=B,e_=q,ek=e=>"Offset"===e._tag?J(e.offset):e.id,eS=Y,eI=G,eE=e=>Y(e).toISOString(),e$=ea},3717(e,t,r){var n=r(4650),i=r(1136),a=r(9138);let s={"~effect/Deferred":{_A:n.D_,_E:n.D_},pipe(){return(0,a.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(s);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),a=r(4450),s=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 A(e);case"bigint":return T(e);case"string":{if("Infinity"===e)return O;if("-Infinity"===e)return C;let t=y.exec(e);if(!t)break;let[r,n,i]=t;if("nano"===i||"nanos"===i)return T(g(n,h));if("micro"===i||"micros"===i)return T(g(n,p));let a=Number(n);switch(i){case"milli":case"millis":return A(a);case"second":case"seconds":return M(a);case"minute":case"minutes":return N(a);case"hour":case"hours":return P(a);case"day":case"days":return R(a);case"week":case"weeks":return j(a)}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 O;return I(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 I(t);return I(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},_={_tag:"Infinity"},k={_tag:"NegativeInfinity"},S={[d]:d,[a.HR](){return a.QK(this.value)},[n.HR](e){return E(e)&&Y(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"}}},[s.FX](){return this.toJSON()},pipe(){return(0,c.tT)(this,arguments)}},I=e=>{let t=Object.create(S);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:e===f?t.value=x:t.value={_tag:"Nanos",nanos:e},t},E=e=>(0,u.i5)(e,d),$=I(0),O=I(1/0),C=I(-1/0),T=e=>I(e),A=e=>I(e),M=e=>I(1e3*e),N=e=>I(6e4*e),P=e=>I(36e5*e),R=e=>I(864e5*e),j=e=>I(6048e5*e),D=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(D),U=(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)()}}),F=(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(D(e),t.value.nanos):r.onNanos(e.value.nanos,D(t))),B=l.L8((e,t)=>F(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})),W=(e,t)=>F(e,t,{onMillis:(e,t)=>e===t,onNanos:(e,t)=>e===t,onInfinity:(e,t)=>e.value._tag===t.value._tag}),q=l.bi(B),Y=(0,i.XY)(2,(e,t)=>W(e,t));r.d(t,{},{MI:e=>"Infinity"!==e.value._tag&&"NegativeInfinity"!==e.value._tag,Tn:O,bN:b,bi:q,cF:T,kE:e=>U(b(e),{onMillis:i.D_,onNanos:e=>Number(e)/1e6,onInfinity:()=>1/0,onNegativeInfinity:()=>-1/0}),lX:w,n$:E,ne:A,qv:C,rs:W,tb:L,v_:$})},7720(e,t,r){r.d(t,{Q56:()=>ex,jGc:()=>e_,U9h:()=>ek,Q7R:()=>x,hgn:()=>q,swY:()=>eq,Muk:()=>eA,as:()=>V,NLW:()=>K,E2r:()=>M,MfU:()=>H,Tyx:()=>ee,osR:()=>et,KuX:()=>Q,loE:()=>Z,RKA:()=>eB,_32:()=>eM,_r7:()=>eY,yeE:()=>eS,NS5:()=>J,fJG:()=>R,ATB:()=>j,pVV:()=>D,qIB:()=>W,Ab9:()=>eG,fn:()=>eF,D9k:()=>eU,vCS:()=>eV,jJl:()=>_,i4r:()=>eT,ar0:()=>eP,x6Z:()=>eR,yUA:()=>B,JkU:()=>P,XeO:()=>eo,GaK:()=>e$,yw5:()=>w,vVN:()=>eW,TjK:()=>G,q7Y:()=>eJ,jkJ:()=>ez,xm_:()=>er,Z9x:()=>eX,YWq:()=>ed,khu:()=>ef,tvg:()=>eh,ZmZ:()=>N,S5A:()=>eI,cfM:()=>eE,uKv:()=>X,QgK:()=>en,ivC:()=>S,Gte:()=>ep,PpN:()=>em,PfK:()=>ey,KT6:()=>eu,Ket:()=>z,L5P:()=>es,MY7:()=>ej,eJC:()=>eD,lKS:()=>eL,z8E:()=>eb,P1j:()=>ev,Pxi:()=>ew,Nav:()=>eg,yy4:()=>ec,PyW:()=>E,lwU:()=>$,nGE:()=>O,DYE:()=>C,OH5:()=>T,Mim:()=>Y,dGm:()=>ea,sFT:()=>ei,mgX:()=>el,SvU:()=>U,$mh:()=>I,rfi:()=>eO,FcF:()=>eC,rIH:()=>A,iMI:()=>k,R6R:()=>F,fRP:()=>eN});var n=r(4650),i=r(8433),a=r(1136),s=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 s.aE(t)?a.PpN(e,t):(n=Array.isArray(t)?l.Um(...t):t,a.Pxi(t=>a.qIB(r?.local?l.H7(n,l.j6(),t):l.LT(n,t),t=>a.PpN(e,t))))});var u=r(3833),d=r(4505),f=r(3537);(e,t,r)=>a.qIB(o.xn(t),t=>{let n=o.d3.defaultValue();return a.h_t(a.i4r(a.Mim(a.qIB(a.DYE(()=>a.PfK(e,o.d3,n)),t),e=>a.OH5(()=>{n=e})),{disableYield:!0}),e=>i.$L(e)?a.PyW(e.value):r(e,0===n.attempt?u.none():u.some(n)))});let h=(0,n.XY)(3,(e,t,r)=>a.qIB(o.xn(t),t=>{let n,i=o.d3.defaultValue(),s=a.h_t(a.DYE(()=>a.PfK(e,o.d3,i)),e=>(n=e,a.qIB(t(e),e=>(i=e,s))));return d.m8(s,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),a.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:a.PyW(r)})),e.until&&(t=o.E6(t,({input:t})=>{let r=e.until(t);return i.yw(r)?a.TjK(r,e=>!e):a.PyW(!r)})),void 0!==e.times&&(t=o.E6(t,({attempt:t})=>a.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=a.Q7R;a.jBG,a.tfT,a.i8i,a.kAe;let _=a.jJl,k=a.iMI,S=a.ivC,I=a.$mh,E=a.PyW,$=a.lwU,O=a.nGE,C=a.DYE,T=a.OH5,A=a.rIH;a.Vxk;let M=a.E2r,N=a.ZmZ;a.Do,a.JrD,a.uVU,a.oIE;let P=a.JkU,R=a.fJG;a.gOk;let j=a.ATB,D=a.pVV,L=a.F_Q,U=a.SvU;a.m9E,a.KN3;let F=i.R6,B=a.yUA;a.sVm,a.pkL,a.bJ;let W=a.qIB;a.Bqz;let q=a.hgn,Y=a.Mim,z=a.Ket,X=a.uKv,J=a.NS5,G=a.TjK,V=a.as;a.Xx$;let K=a.NLW;a.UUz,a.yU6,a.OYO;let H=a.h_t,Q=a.KuX,Z=a.loE;a.AXC,a.zt4,a.scW;let ee=a.Tyx;a.Fig,a.XWm;let et=a.osR;a.U9Y,a.sJf,a.rNk;let er=a.xm_;a.UcN;let en=a.QgK,ei=a.sFT;a.k$L;let ea=a.dGm;a.cA6,a.bKC,a.nAi,a.u4Y;let es=p;a._Sg;let eo=a.XeO;a.GrF,a.$$g,a.DM4,a.Dd,a.wRz,a.D52;let el=a.mgX;a.cbG;let ec=a.yy4;a.ayu,a.Vdx,a.FfP,a.O4F;let eu=a.KT6;a.pbD,a.x1Q,a.E8K,a.Pm0,a.VtY,a.W$I,a.ahH,a.z7s;let ed=a.YWq;a.G$Q,a.D$$,a.NZb,a.wR5;let ef=a.khu,eh=a.tvg;a.N6O,a.oJd,a._OA,a.sxi;let ep=c,em=a.PpN;a.oao,a.euC;let eg=a.Nav;a.r_d,a.bUZ;let ey=a.PfK;a.c7E,a.KyM;let eb=a.z8E,ev=a.P1j,ew=a.Pxi,ex=a.Q56;a.N24;let e_=a.jGc,ek=a.U9h,eS=a.yeE,eI=a.S5A;a.BeE,a.iKM,a.r7h;let eE=a.cfM;a.fGe,a.uRq,a.PO3,a.Rgn,a.CJw;let e$=a.GaK;a.Inz,a.nAr;let eO=a.rfi,eC=a.FcF;a.eMl,a.dsN;let eT=a.i4r;a.aAq,a.Xrv,a.kJM,a._o1,a.nDN,a.MaT;let eA=a.Muk;a.ww9;let eM=a._32;a.Wj8,a.Fu6,a.WbR,a.A_r,a.Z98,a.Rd$,a.gvr;let eN=a.fRP;a.zr8,a.hq,a.zhn;let eP=a.ar0,eR=a.x6Z;a.yxg,a.PCg,a.pEE,a.ABT;let ej=a.MY7,eD=a.eJC;a.lSz,a.bPG,a.pR5,a.v2Q,a.NpQ,a.jqV,a.HZF,a.lE;let eL=a.lKS;a.rfH;let eU=a.D9k,eF=a.fn,eB=a.RKA;a.lIX;let eW=a.lIX("Error"),eq=(0,n.XY)(e=>w(e[0]),(e,...t)=>a.bUZ(e,v.iL,e=>{let r={...e};return 1===t.length?Object.assign(r,t[0]):r[t[0]]=t[1],r}));a.gsV;let eY=(e,t,r)=>(...n)=>M(i=>{try{e(...n,(e,r)=>{e?i(R(t?t(e,n):e)):i(E(r))})}catch(e){i(r?R(r(e,n)):L(e))}}),ez=a.jkJ,eX=a.Z9x,eJ=a.q7Y,eG=a.Ab9;a.UVN;let eV=a.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 a="~effect/encoding/EncodingError";class s extends n.rN("EncodingError"){[a]=a}let o=e=>{let t=f(e),r=t.length;if(r%4!=0)return i.fJ(new s({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 s({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 s({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 s({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 s({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 s({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 s({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,a,s=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 a=m.get(t);return a||(a=new WeakMap,m.set(t,a)),a.set(e,i),i}(e,t,p))}let f=new WeakSet,h=new WeakSet;function p(e,t){if(s.tW(e)!==s.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 a=r();return f.delete(e),h.delete(t),a}(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 a=(0,o.X)(r),s=(0,o.X)(n);if(a.size!==s.size)return!1;for(let e of a)if(!s.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,a]of e){let e=!1;for(let[s,o]of t)if(n(r,s)&&i(a,o)){e=!0;break}if(!e)return!1}return!0}),y=(a=d,function(e,t){for(let r of e){let e=!1;for(let n of t)if(a(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 a(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 s(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:()=>a,_k:()=>s},{L8:n,wN:i})},7598(e,t,r){var n=r(8433),i=r(1136);n.IH,n.b9;let a=n.xt,s=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:s,N6:u,Py:a,fJ:o,oJ:c,rI:l})},956(e,t,r){var n=r(4650),i=r(3833),a=r(5369),s=r(995);a.Kg,a.Et,a.Lm,a.sI,a.Bm,a.$P;let o=(0,n.XY)(2,(e,t)=>r=>{let n=e(r);if(s.N6(n))return s.fJ(r);let i=t(n.success);return s.N6(i)?s.fJ(r):i});r.d(t,{},{Bh:o,zL:e=>t=>{let r=e(t);return s.N6(r)?i.none():i.some(r.success)}})},6470(e,t,r){var n=r(5369),i=r(1743);let a="[Circular]";function s(e){return"string"==typeof e?JSON.stringify(e):String(e)}function o(e){return e.map(e=>`[${s(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 a;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`[
221
253
  ${r=f+1,u.repeat(r)}${n}
222
254
  ${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 a;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=>`${s(e)}:${t(o[e],f)}`).join(",")}}`;return d(o,e)}let n=`{
223
255
  ${r.map(e=>{let r;return`${r=f+1,u.repeat(r)}${s(e)}: ${t(o[e],f+1)}`}).join(",\n")}
224
- ${u.repeat(f)}}`;return d(o,n)}return String(o)}(t,0)},IB:()=>c,Yq:()=>l,_r:()=>s,jV:()=>o})},4650(e,t,r){var n=r(9138);let i=e=>()=>e,a=i(!0),s=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,a,s,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 a(i(n(r(t(e.apply(this,arguments))))))};case 7:return function(){return s(a(i(n(r(t(e.apply(this,arguments)))))))};case 8:return function(){return o(s(a(i(n(r(t(e.apply(this,arguments))))))))};case 9:return function(){return l(o(s(a(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:s,ue:a})},4450(e,t,r){var n=r(4650),i=r(6516),a=r(5369);let s="~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(_.has(e))return _.get(e);let t=function(e,t){if(x.has(e))return h("[Circular]");x.add(e);let r=t();return x.delete(e),r}(e,()=>{if(d(e))return e[s]();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 _.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,a.i5)(e,s),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,_=new WeakMap,x=new WeakSet;r.d(t,{},{HR:s,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),a=r(1743);let s=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,a.E$)(e)};r.d(t,{},{FX:s,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)},[s](){return this.toJSON()},toString(){return(0,n.GP)(this.toJSON())}}})},8496(e,t,r){var n=r(4650),i=r(3833),a=r(5369);let s=(0,n.XY)(2,(e,t)=>{let r=0;for(let n of e){let e=t(n,r);if((0,a.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:s,pb:o})},5089(e,t,r){var n=r(8619),i=r(3717),a=r(4650),s=r(8433),o=r(1136),l=r(9138),c=r(2672);let u="~effect/Layer/MemoMap",d={"~effect/Layer":{_ROut:a.D_,_E:a.D_,_RIn:a.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 a,s,l,u=this.get(e,t);return u?u:(n=this,a=c.LZ(),s=i.LZ(),l={observers:1,effect:i.Tx(s),finalizer:t=>o.DYE(()=>(l.observers--,0===l.observers)?(n.map.delete(e),c.VN(a,t)):o.rIH)},n.map.set(e,l),o.Uio(t,l.finalizer).pipe(o.qIB(()=>r(n,a)),o.cfM(e=>(l.effect=e,i.Vw(s,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,a.XY)(3,(e,t,r)=>o.PfK(o.TjK(e.build(t,r),n.WQ(g,t)),g,t)),b=(0,a.XY)(2,(e,t)=>s.R6(r=>y(e,g.forkOrCreate(r.context),t))),v=e=>f((0,a.dY)(o.PyW(e))),w=(e,t)=>_(o.TjK(t,t=>n.L8(e,t))),_=e=>{var t;let r;return t=(t,r)=>c.Gt(e,r),r=h((e,n)=>e.getOrElseMemoize(r,n,t))},x=(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)))},k=(e,t,r)=>h((n,i)=>o.qIB(Array.isArray(t)?x(t,n,i):t.build(n,i),t=>e.build(n,i).pipe(o.PpN(t),o.TjK(e=>r(e,t))))),S=(0,a.XY)(2,(e,t)=>k(e,t,a.D_)),E=(0,a.XY)(2,(e,t)=>k(e,t,(e,t)=>n.h1(t,e)));r.d(t,{},{Gt:S,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:E,Um:(...e)=>h((t,r)=>x(e,t,r)),j6:m})},3833(e,t,r){r.r(t),r.d(t,{Do:()=>eh,all:()=>K,andThen:()=>B,as:()=>D,asVoid:()=>L,bind:()=>ef,bindTo:()=>eu,composeK:()=>J,contains:()=>el,containsWith:()=>eo,exists:()=>ec,filter:()=>er,filterMap:()=>et,firstSomeOf:()=>I,flatMap:()=>F,flatMapNullishOr:()=>Y,flatten:()=>W,fromIterable:()=>v,fromNullOr:()=>T,fromNullishOr:()=>$,fromUndefinedOr:()=>O,gen:()=>ep,getFailure:()=>_,getOrElse:()=>x,getOrNull:()=>C,getOrThrow:()=>R,getOrThrowWith:()=>P,getOrUndefined:()=>N,getSuccess:()=>w,isNone:()=>m,isOption:()=>p,isSome:()=>g,let:()=>ed,lift2:()=>ea,liftNullishOr:()=>A,liftPredicate:()=>es,liftThrowable:()=>M,makeCombinerFailFast:()=>eg,makeEquivalence:()=>en,makeOrder:()=>ei,makeReducer:()=>em,makeReducerFailFast:()=>ey,map:()=>j,match:()=>y,none:()=>f,orElse:()=>k,orElseResult:()=>E,orElseSome:()=>S,partitionMap:()=>ee,product:()=>G,productMany:()=>V,reduceCompact:()=>Q,some:()=>h,tap:()=>z,toArray:()=>Z,toRefinement:()=>b,void:()=>U,zipLeft:()=>X,zipRight:()=>q,zipWith:()=>H});var n=r(8036),i=r(1044),a=r(4650),s=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,a.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,_=l.L8,x=(0,a.XY)(2,(e,t)=>m(e)?t():e.value),k=(0,a.XY)(2,(e,t)=>m(e)?t():e),S=(0,a.XY)(2,(e,t)=>m(e)?h(t()):e),E=(0,a.XY)(2,(e,t)=>m(e)?j(t(),l.Py):j(e,l.fJ)),I=e=>{let t=f();for(t of e)if(g(t))break;return t},$=e=>null==e?f():h(e),O=e=>void 0===e?f():h(e),T=e=>null===e?f():h(e),A=e=>(...t)=>$(e(...t)),C=x(a.XR),N=x(a.MN),M=e=>(...t)=>{try{return h(e(...t))}catch{return f()}},P=(0,a.XY)(2,(e,t)=>{if(g(e))return e.value;throw t()}),R=P(()=>Error("getOrThrow called on a None")),j=(0,a.XY)(2,(e,t)=>m(e)?f():h(t(e.value))),D=(0,a.XY)(2,(e,t)=>j(e,()=>t)),L=D(void 0),U=h(void 0),F=(0,a.XY)(2,(e,t)=>m(e)?f():t(e.value)),B=(0,a.XY)(2,(e,t)=>F(e,e=>{let r=(0,u.Tn)(t)?t(e):t;return p(r)?r:h(r)})),Y=(0,a.XY)(2,(e,t)=>m(e)?f():$(t(e.value))),W=F(a.D_),q=(0,a.XY)(2,(e,t)=>F(e,()=>t)),X=(0,a.XY)(2,(e,t)=>z(e,()=>t)),J=(0,a.XY)(2,(e,t)=>r=>F(e(r),t)),z=(0,a.XY)(2,(e,t)=>F(e,e=>j(t(e),()=>e))),G=(e,t)=>g(e)&&g(t)?h([e.value,t.value]):f(),V=(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)},K=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)},H=(0,a.XY)(3,(e,t,r)=>j(G(e,t),([e,t])=>r(e,t))),Q=(0,a.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,a.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,a.XY)(2,(e,t)=>{if(m(e))return f();let r=t(e.value);return l.oJ(r)?h(r.success):f()}),er=(0,a.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),ea=e=>(0,a.XY)(2,(t,r)=>H(t,r,e)),es=(0,a.XY)(2,(e,t)=>t(e)?h(e):f()),eo=e=>(0,a.XY)(2,(t,r)=>!m(t)&&e(t.value,r)),el=eo(n.jI()),ec=(0,a.XY)(2,(e,t)=>!m(e)&&t(e.value)),eu=s.Jr(j),ed=s.zM(j),ef=s.oI(j,F),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 a=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),s=i((e,t)=>e<t?-1:1),o=(0,n.XY)(2,(e,t)=>i((r,n)=>e(t(r),t(n)))),l=o(a,e=>e.getTime());function c(e){return i((t,r)=>{let n=t.length,i=r.length,s=Math.min(n,i);for(let n=0;n<s;n++){let i=e(t[n],r[n]);if(0!==i)return i}return a(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:s,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:a,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)}},a=function(){function e(){}return e.prototype=i,e}();r.d(t,{},{Xs:a,tT:n})},5369(e,t,r){var n=r(4650);function i(e){return"string"==typeof e}function a(e){return"number"==typeof e}function s(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)||a(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),_=(0,n.XY)(2,(e,t)=>w(e,"_tag")&&e._tag===t);function x(e){return e instanceof Error}function k(e){return e instanceof Date}function S(e){return w(e,Symbol.iterator)||i(e)}function E(e){return e instanceof RegExp}r.d(t,{$P:()=>k,Bm:()=>l,EA:()=>f,Et:()=>a,Fw:()=>v,Gv:()=>b,Kg:()=>i,Lm:()=>s,Pd:()=>g,Pe:()=>h,Tn:()=>u,Vq:()=>m,b0:()=>d,bJ:()=>x,gd:()=>E,hL:()=>c,sI:()=>o,t8:()=>y,uy:()=>p,xZ:()=>S},{$J:_,i5:w})},4505(e,t,r){var n=r(8543),i=r(7598),a=r(956),s=r(4650),o=r(1136),l=r(995);let c=(0,s.XY)(2,(e,t)=>o.rNk(e,f,e=>t(e))),u=e=>"Fail"===e._tag&&n.$L(e.error),d=a.Bh(n.kh,e=>n.$L(e)?l.Py(e):l.fJ(e));n.kh;let f=a.Bh(n.kh,e=>n.$L(e)?l.Py(e.value):l.fJ(e)),h=(0,s.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]),a=(0,n.XY)(2,(e,t)=>{let r={...e};for(let n of o(e))r[n]=t(e[n],n);return r}),s=(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:a,Wo:i,pb:s})},1743(e,t,r){var n=r(9138),i=r(5369);let a=Symbol.for("~effect/Redactable");function s(e){return(0,i.i5)(e,a)?o(e):e}function o(e){return e[a](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$:()=>s,f6:()=>o},{fL:l,uC:a})},3864(e,t,r){var n=r(1136),i=r(8344);i.F8;let a=i.iL;i.Gl,i.d8,i.vA;let s=i.zQ;i.rf,i.ce,i.ls,i.nU,i.aG,n.d$_,n.olX,r.d(t,{},{iL:a,zQ:s})},995(e,t,r){var n=r(4650),i=r(5091),a=r(4403);let s=a.Py,o=a.fJ;a.sV,a.aI;let l=a.N6,c=a.oJ;a.Oz,a.L8;let u=(0,n.XY)(2,(e,t)=>l(e)?o(t(e.failure)):s(e.success)),d=(0,n.XY)(2,(e,t)=>c(e)?s(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:s,Tj:d,YW:f,fJ:o,oJ:c,xm:u})},3587(e,t,r){var n=r(8543),i=r(8619),a=r(2302),s=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,s.dY)({input:void 0,output:void 0,duration:a.v_,attempt:0,start:0,now:0,elapsed:0,elapsedSincePrevious:0})}),p={[f]:{_Out:s.D_,_In:s.D_,_Env:s.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 a=n-t,s=void 0===e?0:n-e;return e=n,{input:i,attempt:++r,start:t,now:n,elapsed:a,elapsedSincePrevious:s}}},y=e=>l.Tyx(e.step,e=>l.PyW(()=>l.ATB(e))),b=e=>{let t,r=a.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,s.XY)(2,(e,t)=>{let r=void 0===t.duration?void 0:a.bN(t.duration);return w(e,({attempt:e,elapsed:n})=>l.PyW((void 0===t.times||e<=t.times)&&(void 0===r||a.bi(a.ne(n),r))))}),w=(0,s.XY)(2,(e,t)=>m(l.TjK(y(e),e=>{let r=g();return(i,a)=>l.qIB(e(i,a),e=>{let[s,c]=e,u=t({...r(i,a),output:s,duration:c});return l.qIB((0,o.yw)(u)?u:l.PyW(u),t=>t?l.PyW(e):n.Vw(s))})}))),_=b(a.v_);r.d(t,{},{E6:w,GM:e=>(0,u.i5)(e,f),d3:h,i4:_,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(_,({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 a=r(i,n);return a.output=e,a.duration=t,l.as(l.yy4(t),a)})})}))})},8469(e,t,r){var n=r(8619);let i=n.Or("effect/Scheduler",{defaultValue:()=>new o}),a="setImmediate"in globalThis?e=>{let t=globalThis.setImmediate(e);return()=>globalThis.clearImmediate(t)}:e=>{let t=setTimeout(e,0);return()=>clearTimeout(t)};class s{buckets=[];scheduleTask(e,t){let r,n=this.buckets,i=n.length,a=0;for(;a<i&&!(n[a][0]>t);a++)r=n[a];r&&r[0]===t?r[1].push(e):a===i?n.push([t,[e]]):n.splice(a,0,[t,[e]])}drain(){let e=this.buckets;return this.buckets=[],e}}class o{executionMode;setImmediate;constructor(e="async",t=a){this.executionMode=e,this.setImmediate=t}shouldYield(e){return e.currentOpCount>=e.maxOpsBeforeYield}makeDispatcher(){return new l(this.setImmediate)}}class l{tasks=new s;running=void 0;setImmediate;constructor(e=a){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,a,s;r.d(t,{O31:()=>eS,v8c:()=>ev,Xsx:()=>e2,Nej:()=>ez,kld:()=>eq,PSP:()=>e5,wYs:()=>eG,Aiz:()=>eV,uSQ:()=>ep,xCb:()=>function e(t){let r=t.map(ep);return es(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:()=>eY,wNn:()=>eb,pHd:()=>eK,mSG:()=>ek,QfV:()=>ey,_kM:()=>ex,X0d:()=>e3,gPz:()=>eI,$r1:()=>em,rvE:()=>Q,usV:()=>Z,hzj:()=>H,GLL:()=>eA,_Re:()=>en,q$Z:()=>ei,svK:()=>ea,is:()=>er,MIs:()=>eL,yJO:()=>eU,OWK:()=>eF,tJb:()=>eB,Pto:()=>eD,nfo:()=>eR,HNH:()=>ej,fXn:()=>eE,Wa3:()=>ec,lqM:()=>el,Qrq:()=>eo,YPB:()=>eT,DYE:()=>eO,TcI:()=>eP,lHk:()=>e6,O3D:()=>ed,_oz:()=>e8,rcy:()=>et,AxX:()=>eu,tiU:()=>eM,E$i:()=>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),_=r(8433),x=r(8927),k=r(8036),S=r(5369),E=r(8099);S.gd;var I=r(9177),$=r(4888),O=r(9138);let T="~effect/SchemaError/SchemaError";class A extends m.rN("SchemaError"){[T]=T;constructor(e){super({issue:e})}get message(){return this.issue.toString()}toString(){return`SchemaError(${this.message})`}}var C=r(4858);let N="~effect/Schema/Schema",M={[N]:N,pipe(){return O.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=C.o(r);return r.makeEffect=(e,t)=>R(n(e,t)),r.make=C.L8(r),r.makeOption=C.YY(r),r}function R(e){return b.Tyx(e,e=>b.pVV(()=>p.Tj(e,e=>new A(e))))}let j=D(function(e){switch(e._tag){case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}});function D(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),a=e(n);return i!==a?i-a: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]),U=new Set(["title","description","default","examples","readOnly","writeOnly","format","contentEncoding","contentMediaType","contentSchema"]);function F(e){if(void 0!==e){let t=E.pb(e,(e,t)=>!L.has(t));if(!E.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 W(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(W).join("");case"Union":return e.types.map(W).join("|");default:throw new globalThis.Error("Unsupported part",{cause:e})}}var q=r(3833),X=r(6364),J=r(995),z=r(8469),G=r(6310),V=r(6030),K=r(5348);function H(){return(e,t,r)=>es(new I.D6(e.map(I.hu),e=>t(e.map(e=>es(e))),r))}r(1044)._k,X._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=C._R(e),n={errors:"all",...t?.parseOptions},i=V.ID(t),a=e=>{let t=new z.FG,a=b.MY7(b.YWq(r(e,n),{onFailure:i,onSuccess:e=>({value:e})}),{scheduler:t});a.currentDispatcher?.flush();let s=a.pollUnsafe();return s?ee(s):new Promise(e=>{a.addObserver(t=>{e(ee(t))})})};return"~standard"in e?("validate"in e["~standard"]||Object.assign(e["~standard"],{validate:a}),e):Object.assign(e,{"~standard":{version:1,vendor:"effect",validate:a}})}let er=C.is;function en(e,t){let r=C._R(e,t);return(e,t)=>R(r(e,t))}function ei(e,t){let r=C.q$(e,t);return(e,t)=>J.xm(r(e,t),e=>new A(e))}function ea(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,!S.i5(n,T)))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))}C.kv,C.y9,C.mR,C.IQ,C.GP;let es=P,eo=e=>es(I.Qr(e.ast),{schema:e}),el=e=>eo(e$(e)),ec=e=>es(I.W(e.ast),{schema:e}),eu=e=>es(I.Ax(e.ast),{schema:e}),ed=e=>es(I.O3(e.ast),{schema:e}),ef="~effect/Schema/flip";function eh(e){return S.i5(e,ef)&&e[ef]===ef?e.schema.rebuild(I.UU(e.ast)):es(I.UU(e.ast),{[ef]:ef,schema:e})}function ep(e){let t=es(new I.uS(e),{literal:e,transform:r=>t.pipe(eA(ep(r),{decode:G.pd(()=>r),encode:G.pd(()=>e)}))});return t}I.Zm,I.bz;let em=es(I.L5);I.ch;let eg=es(I.Vx),ey=es(I.Yj),eb=es(I.ai),ev=es(I.zM),ew=es(I.HR);function e_(e,t){return es(e,{fields:t,mapFields(e,t){let r=e(this.fields);return e_(I.w3(r,t?.unsafePreserveChecks?this.ast.checks:void 0),r)}})}function ex(e){return e_(I.w3(e,void 0),e)}function ek(e,t,r){let n=r?.keyValueCombiner?.decode||r?.keyValueCombiner?.encode?new I.E$(r.keyValueCombiner.decode,r.keyValueCombiner.encode):void 0;return es(I.g1(e.ast,t.ast,n),{key:e,value:t})}I.we,I.rI,I.ZG;let eS=e=>es(new I.DO(!1,[],[e.ast]),{value:e}),eE=e=>es(new I.DO(!0,e.ast.elements,e.ast.rest),{schema:e});function eI(e,t){return function e(t,r){return es(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 eO(e){return es(new I.V3(()=>e().ast))}function eT(e,t){return r=>es(I.EJ(r.ast,[I.D$(e,t)]),{schema:r})}function eA(e,t){return r=>es(I.GL(r.ast,e.ast,t?K.L8(t):K.le()),{from:r,to:e})}function eC(e){return b.Tyx(e,e=>b.pVV(()=>p.Tj(e,e=>e.issue)))}function eN(e,t){let r=t?.encodingStrategy==="omit"?G.cJ():G.le();return t=>eo(ed(t)).pipe(eA(t,{decode:G.IQ(eC(e)),encode:r}))}function eM(e,t){let r=t?.encodingStrategy==="omit"?G.cJ():G.le();return t=>el(ed(t)).pipe(eA(t,{decode:G.IQ(eC(e)),encode:r}))}function eP(e){var t;return ep(e).pipe((t=b.PyW(e),e=>es(I.Ez(e.ast,eC(t)),{schema:e})))}function eR(){return(e,t)=>new I.N_(e.ast,K.L8(t))}let ej=I.HN,eD=I.Pt;function eL(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 eU=(f={order:X.wN,annotate:e=>({meta:{_tag:"isGreaterThan",exclusiveMinimum:e}})},n=X.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})),eF=(o={order:X.wN,annotate:e=>({meta:{_tag:"isGreaterThanOrEqualTo",minimum:e}})},a=X.OW(o.order),s=o.formatter??w.GP,(e,t)=>ej(t=>a(t,e),{expected:`a value greater than or equal to ${s(e)}`,arbitrary:{constraint:{ordered:{order:o.order,minimum:e}}},...o.annotate?.(e),...t}));function eB(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})}X.wN,X.wN,X.wN,X.n9,X.n9,X.n9,X.n9,X.n9,X.Qw,X.Qw,X.Qw,X.Qw,X.Qw,h.pH,h.pH,h.pH,h.pH,h.pH;let eY=ey.check(eB(1,void 0)),eW=[];function eq(e){let t=e?.includeStack===!0|2*(e?.excludeCause===!0),r=eW[t];if(void 0!==r)return r;let n=tr.pipe(eA(em,K.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 eW[t]=n,n}K.nY;let eX=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:()=>eR()(eX,K.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===X.n9?t.constraint.ordered:void 0))},u=e=>e instanceof l,d=c,H()([],()=>(e,t)=>u(e)?b.PyW(e):b.fJG(new V.eE(t,q.some(e))),d));K.YZ,K.HO;let ez=eJ.check(ej(e=>!isNaN(e.getTime()),{expected:"a valid date",meta:{_tag:"isDateValid"},arbitrary:{constraint:{valid:!0}},...void 0}));y.n$,K.EJ,K.m8,K.PE;h.s5,K.dG;let eG=eb.check(eL()),eV=eb.check(ej(e=>globalThis.Number.isSafeInteger(e),{expected:"an integer",meta:{_tag:"isInt"},arbitrary:{constraint:{integer:!0}},...void 0}));K.ZK,K.ZK,K.R7,K.Ct,K.LL,K.Y5,K.Pp;let eK=eI([eG,ew,ey]);K.U0,g.yF,K.Nh,g.Xy,g.lU,g.rg,K.yd,g.kQ,K.XU,K.d9;let eH=globalThis.Symbol.for("immer-draftable"),eQ={};function eZ(e,t,r,n,i){var a,s,o;let l,c=(a=r,s=t,o=n,e=>{if(void 0!==l)return l;let t=new K.IT(G.pd(t=>new e(t)),G.le());return l=eA(es(new I.D6([a.ast],()=>(t,r)=>t instanceof e||S.i5(t,e0(s))?b.PyW(t):b.fJG(new V.eE(r,q.some(t))),{identifier:s,[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(a.ast),...o})),t)(a)}),u=e0(t),d=class extends e{constructor(...[e,t]){let n=t?.["~payload"],i=n?.token===eQ?n.value:r.make(e??{},t);super(i,{...t,disableChecks:!0,"~payload":{token:eQ,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 O.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 C.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 a=e1(t)?t:ex(t),s={...r.fields,...a.fields},o=I.w3(s,r.ast.checks,{identifier:e});return eZ(this,e,e_(I.EJ(o,a.ast.checks),s),n,i)}}static mapFields(e,t){return r.mapFields(e,t)}};return void 0!==i&&Object.assign(d.prototype,i(t)),d}function e0(e){return`~effect/Schema/Class/${e}`}function e1(e){return S.i5(e,N)&&e[N]===N}let e2=e=>(t,r)=>{let n=e1(t)?t:ex(t);return eZ(m.Xs,e,n,r,e=>({toString(){return`${e}(${(0,w.GP)({...this})})`}}))},e5=e=>(t,r)=>{let n=e1(t)?t:ex(t);return eZ(_.$D,e,n,r,e=>({name:e}))},e3=e=>(t,r,n)=>{let i=e1(r)?r.mapFields(e=>({_tag:eP(t),...e}),{unsafePreserveChecks:!0}):ex({_tag:eP(t),...r});return e5(e??t)(i,n)};function e8(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,a=E.Tj(e.references,e=>s(e));return{dialect:"draft-2020-12",schemas:x.Tj(e.representations,e=>s(e)),definitions:a};function s(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 s(t.encodedSchema);case"Suspend":return s(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=s(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 s({_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(W).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=s(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=s(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={},a=[];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=s(e.type),n=o(e.annotations);i[t]=n?Y(r,n):r,e.isOptional||a.push(t)}Object.keys(i).length>0&&(r.properties=i),a.length>0&&(r.required=a),r.additionalProperties=n;let l={};for(let n of t.indexSignatures){let t=s(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(W).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),S.Gv(r.additionalProperties)&&E.DM(r.additionalProperties)&&delete r.additionalProperties,r}case"Union":{let e=t.types.map(s);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,a;for(let e of(i=t.checks,a=r.type,i.map(function e(t){switch(t._tag){case"Filter":var r=t,n=a;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:s(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||U.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:x.Tj(e,e=>s(e)),references:t};function a(e){let t=e,r=0;for(;n.has(t);)t=`${e}${++r}`;return n.add(t),t}function s(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 s(c,u);if(void 0!==u){let n=a(u);r.set(e,n);let i=o(e),s=t[u];return void 0!==s&&k.aI(i,s)?(r.set(e,u),{_tag:"Reference",$ref:u}):(t[n]=i,{_tag:"Reference",$ref:n})}if(i.has(e)){let t=a(`${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=F(e.annotations);switch(e._tag){case"Declaration":{let r,n=s((r=e.annotations?.toCodecJson??e.annotations?.toCodec,S.Tn(r)?I.ES(e,[r(e.typeParameters.map(e=>P(I.O3(e))))]):I.ch));return{_tag:"Declaration",typeParameters:e.typeParameters.map(e=>s(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:s(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=>s(e)),...t};case"Arrays":return{_tag:e._tag,elements:e.elements.map(e=>{let t=I.S5(e);return{isOptional:I.dK(t),type:s(e),...F(t.context?.annotations)}}),rest:e.rest.map(e=>s(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:s(e.type),isOptional:I.dK(t),isMutable:I.bV(t),...F(t.context?.annotations)}}),indexSignatures:e.indexSignatures.map(e=>({parameter:s(e.parameter),type:s(e.type)})),checks:l(e.checks),...t};case"Union":{let r=j(e.types);return{_tag:e._tag,types:r.map(e=>s(e)),mode:e.mode,...t}}case"Suspend":return{_tag:"Suspend",checks:[],thunk:s(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:s(t.propertyNames)}:t,...F(e.annotations)};return}case"FilterGroup":{let t=l(e.checks);if(x.CZ(t))return{_tag:"FilterGroup",checks:t,...F(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 es(te(e.ast),{schema:e})}let e9=D(function(e){switch(e._tag){case"Null":case"Boolean":case"Number":case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}}),e4=new I.N_(new I.uS("null"),new K.IT(G.pd(()=>null),G.pd(()=>"null"))),e7=new I.N_(new I.gP([new I.uS("true"),new I.uS("false")],"anyOf"),new K.IT(G.pd(e=>"true"===e),G.Qf())),te=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(S.Tn(n)){let r=n(I.HC(e)?e.typeParameters.map(e=>es(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,[e4]);case"Boolean":return I.ES(e,[e7]);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=e9(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,te,e=>I.ES(e,[tt]));return t!==e&&I.dK(e)?I.nj(t):t}),tt=new I.N_(I.Vx,new K.IT(G.le(),G.pd(()=>void 0))),tr=es(I.LM);I.BF},9177(e,t,r){r.d(t,{DO:()=>Z,YA:()=>tc,D6:()=>j,bm:()=>en,LM:()=>td,E$:()=>ea,N_:()=>C,uS:()=>X,BF:()=>tf,XV:()=>e3,C3:()=>tu,V3:()=>ek,gP:()=>eb,fz:()=>eN,us:()=>eU,bz:()=>Y,EJ:()=>eP,oZ:()=>eD,we:()=>Q,Nt:()=>tn,zM:()=>K,Lp:()=>tl,SL:()=>em,GL:()=>eX,vr:()=>N,UU:()=>eH,hu:()=>ef,S5:()=>function e(t){return t.encoding?e(t.encoding[t.encoding.length-1].to):t},zm:()=>w,tF:()=>O,Lm:()=>E,HC:()=>_,c$:()=>I,bV:()=>eG,Et:()=>S,RP:()=>T,dK:()=>ez,Pt:()=>eO,Kg:()=>k,ZB:()=>tr,bk:()=>e9,IZ:()=>to,mi:()=>A,HN:()=>eI,D$:()=>e$,W:()=>eW,Zm:()=>B,ch:()=>D,ai:()=>V,ZG:()=>q,Qr:()=>eB,nj:()=>eF,xw:()=>e2,g1:()=>eJ,ES:()=>eA,Yj:()=>z,w3:()=>ed,HR:()=>H,O3:()=>eK,Ax:()=>eV,PV:()=>eh,Vx:()=>U,KC:()=>ep,L5:()=>W,tC:()=>th,rI:()=>F,Ez:()=>eq});var n=r(8927),i=r(8543),a=r(7720),s=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 _=v("Declaration"),x=v("Never"),k=v("String"),S=v("Number"),E=v("Boolean"),I=v("Literal"),$=v("UniqueSymbol"),O=v("Arrays"),T=v("Objects"),A=v("Union");class C{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 R{[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 j extends R{_tag="Declaration";typeParameters;run;encodingChecks;constructor(e,t,r,n,i,a,s){super(r,n,i,a),this.typeParameters=e,this.run=t,this.encodingChecks=s}getParser(){let e=this.run(this.typeParameters);return(t,r)=>h.isNone(t)?a.lwU:a.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 j(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 D=new class extends R{_tag="Null";getParser(){return eQ(this,null)}getExpected(){return"null"}},L=new C(D,new b.IT(g.pd(()=>void 0),g.pd(()=>null))),U=new class extends R{_tag="Undefined";getParser(){return eQ(this,void 0)}toCodecJson(){return eA(this,[L])}getExpected(){return"undefined"}},F=new class extends R{_tag="Void";getParser(){var e;let t;return e=void 0,t=a.nGE(e),e=>"None"===e._tag?a.lwU:t}toCodecJson(){return eA(this,[L])}getExpected(){return"void"}},B=new class extends R{_tag="Never";getParser(){return eZ(this,m.Pd)}getExpected(){return"never"}},Y=new class extends R{_tag="Any";getParser(){return eZ(this,m.t8)}getExpected(){return"any"}},W=new class extends R{_tag="Unknown";getParser(){return eZ(this,m.t8)}getExpected(){return"unknown"}},q=new class extends R{_tag="ObjectKeyword";getParser(){return eZ(this,m.Fw)}getExpected(){return"object | array | function"}};class X extends R{_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?J(this):this}toCodecStringTree(){return"string"==typeof this.literal?this:J(this)}getExpected(){return"string"==typeof this.literal?JSON.stringify(this.literal):globalThis.String(this.literal)}}function J(e){let t=globalThis.String(e.literal);return eA(e,[new C(new X(t),new b.IT(g.pd(()=>e.literal),g.pd(()=>t)))])}let z=new class extends R{_tag="String";getParser(){return eZ(this,m.Kg)}matchPart(e,t){return e0(this,e,t)}getExpected(){return"string"}};function G(e,t){return e.some(e=>{switch(e._tag){case"Filter":return e.annotations?.meta?._tag===t;case"FilterGroup":return G(e.checks,t)}})}let V=new class extends R{_tag="Number";getParser(){return eZ(this,m.Et)}matchKey(e,t){return this._match(e6,e,t)}matchPart(e,t){return this._match(e8,e,t)}_match(e,t,r){return e.test(t)?e0(this,globalThis.Number(t),r):void 0}toCodecJson(){return this.checks&&(G(this.checks,"isFinite")||G(this.checks,"isInt"))?this:eA(this,[e_])}toCodecStringTree(){return this.checks&&(G(this.checks,"isFinite")||G(this.checks,"isInt"))?eA(this,[e7]):eA(this,[te])}getExpected(){return"number"}},K=new class extends R{_tag="Boolean";getParser(){return eZ(this,m.Lm)}getExpected(){return"boolean"}},H=new class extends R{_tag="Symbol";getParser(){return eZ(this,m.Bm)}matchKey(e,t){return e0(this,e,t)}toCodecStringTree(){return eA(this,[ts])}getExpected(){return"symbol"}},Q=new class extends R{_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 R{_tag="Arrays";isMutable;elements;rest;encodingChecks;constructor(e,t,r,n,i,a,s,o){super(n,i,a,s),this.isMutable=e,this.elements=t,this.rest=r,this.encodingChecks=o;let l=t.findIndex(ez);if(-1!==l&&(t.slice(l+1).some(e=>!ez(e))||r.length>1))throw Error("A required element cannot follow an optional element. ts(1257)");if(r.length>1&&r.slice(1).some(ez))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,...o]=n,l=o.length;function c(e,t){return t<i?r[t]:t>=e?o[t-e]:s}return a.vCS(function*(e,r){if("None"===e._tag)return e;let n=e.value;if(!Array.isArray(n))return yield*a.fJG(new y.eE(t,e));let s=n.length,o={ast:t,getParser:c,oinput:e,len:s,tailThreshold:Math.max(i,s-l),output:new globalThis.Array(s),issues:void 0,options:r},u=et(r?.concurrency),d=ee(o,n,{concurrency:u?.concurrency,end:0===t.rest.length?i:Math.max(s,i+l)});if(d&&(yield*d),0===t.rest.length&&s>i)for(let l=i;l<=s-1;l++){let i=new y.gm([l],new y.vF(t,n[l]));if("all"!==r.errors)return yield*a.fJG(new y.eC(t,e,[i]));o.issues?o.issues.push(i):o.issues=[i]}return o.issues?yield*a.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(ez(t.ast))return;let r=new y.gm([n],new y.Mw(t.ast.context?.annotations));if("all"!==e.options.errors)return s.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 a=f.R(n.cause);if(void 0===a)return s.AT(i.Tj(n.cause,n=>new y.eC(t,e.oinput,[new y.gm([r],n)])));let o=new y.gm([r],a);if("all"!==e.options.errors)return s.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 ea{decode;encode;constructor(e,t){this.decode=e,this.encode=t}flip(){return new ea(this.encode,this.decode)}}function es(e){switch(e._tag){case"String":case"Number":case"Symbol":case"TemplateLiteral":return!0;case"Union":return e.types.every(es);default:return!1}}class eo{parameter;type;merge;constructor(e,t,r){if(!(es(e)&&es(eK(e))))throw Error(`Invalid index signature parameter ${e._tag}`);if(this.parameter=e,this.type=t,this.merge=r,ez(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 R{_tag="Objects";propertySignatures;indexSignatures;encodingChecks;constructor(e,t,r,n,i,a,s){super(r,n,i,a),this.propertySignatures=e,this.indexSignatures=t,this.encodingChecks=s;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,s=[];for(let n of t.propertySignatures)r.push(n.name),i.add(n.name),s.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:a.vCS(function*(r,[n,s]){let o=e(e1(s.parameter))(h.some(n),r.options),l=(0,c.OY)(o)?o:yield*a.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(s.type)(d,r.options),p=(0,c.OY)(f)?f:yield*a.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(s.merge&&s.merge.decode&&Object.hasOwn(r.out,e)){let[n,i]=s.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 a.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*a.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*a.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),_=ec(m,s,w);if(_&&(yield*_),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(a){switch(a._tag){case"String":case"TemplateLiteral":return(n??=Object.keys(e)).filter(e=>void 0!==a.matchPart(e,r));case"Number":return(n??=Object.keys(e)).filter(e=>void 0!==a.matchKey(e,r));case"Symbol":return(i??=Object.getOwnPropertySymbols(e)).filter(e=>void 0!==a.matchKey(e,r));case"Union":return[...new Set(a.types.flatMap(t))];default:return[]}}(e1(eK(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*a.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 a=eL(this.propertySignatures,t=>{let r=e(t.type);return r===t.type?t:new ei(t.name,r)}),s=eL(this.indexSignatures,n=>{let i=t(n.parameter),a=e(n.type),s=r?n.merge?.flip():n.merge;return i===n.parameter&&a===n.type&&s===n.merge?n:new eo(i,a,s)});return a===this.propertySignatures&&s===this.indexSignatures&&n===this.checks&&i===this.encodingChecks?this:new el(a,s,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(!ez(t.type)){let r=new y.gm([t.name],new y.Mw(t.type.context?.annotations));return"all"!==e.options.errors?s.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(!ez(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)&&!ez(e)?[{key:t,literal:e.literal}]:[]);case"Suspend":return em(e.thunk())}}let eg=new WeakMap;function ey(e){return t=>{let r=eK(t);return"Literal"===r._tag?r.literal===e:"UniqueSymbol"!==r._tag||r.symbol===e}}class eb extends R{_tag="Union";types;mode;encodingChecks;constructor(e,t,r,n,i,a,s){super(r,n,i,a),this.types=e,this.mode=t,this.encodingChecks=s}getParser(e){let t=this;return(r,n)=>{if("None"===r._tag)return a.PyW(r);let i=r.value,s=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=eK(e[r]);if(x(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),a=em(n);for(let e of(t.byType??={},i))(t.byType[e]??=[]).push(r);if(a.length>0)for(let{key:e,literal:n}of(t.bySentinel??=new Map,a)){let i=t.bySentinel.get(e);i||t.bySentinel.set(e,i=new Map);let a=i.get(n);a||i.set(n,a=[]),a.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,s,l?{...l,orderedStep:!0}:void 0);return c?a.qIB(c,e=>o.out?a.PyW(o.out):a.fJG(new y.W(t,i,o.issues??[]))):o.out?a.PyW(o.out):a.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=eK(t);switch(r._tag){case"Arrays":{let t=r.elements.filter(I);if(t.length>0)return`${ex(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=>`${ex(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),s.fJ(new y.E8(e.ast,e.input,e.successes));if(e.out=r.value,e.successes.push(t),"anyOf"===e.ast.mode)return s.rI}}}),ew=new eb([new X("Infinity"),new X("-Infinity"),new X("NaN")],"anyOf"),e_=new C(new eb([V,ew],"anyOf"),new b.IT(g.wN(),g.pd(e=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function ex(e){return e?"":"readonly "}class ek extends R{_tag="Suspend";thunk;constructor(e,t,r,n,i){let a,s;if(void 0!==r)throw Error("Cannot add checks to Suspend");super(t,void 0,n,i),this.thunk=(s=!1,()=>(s||(a=e(),s=!0),a))}getParser(e){return e(this.thunk())}recur(e){return new ek(()=>e(this.thunk()),this.annotations,void 0,void 0,this.context)}getExpected(e){return e(this.thunk())}}class eS 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 eS(this.run,{...this.annotations,...e},this.aborted)}abort(){return new eS(this.run,this.annotations,!0)}and(e,t){return new eE([this,e],t)}}class eE extends p.Xs{_tag="FilterGroup";checks;annotations;constructor(e,t){super(),this.checks=e,this.annotations=t}annotate(e){return new eE(this.checks,{...this.annotations,...e})}and(e,t){return new eE([this,e],t)}}function eI(e,t,r=!1){return new eS((t,r,n)=>y.L8(t,r,e(t,r,n)),t,r)}function e$(e,t){return new eS(t=>e(t)?void 0:new y.h6(h.some(t)),t,!0)}function eO(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 eT(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:eT(e,e=>{e.encoding.value=t})}function eC(e,t){return e.context===t?e:eT(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 eT(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:eT(e,e=>{e.checks.value=t})}function eP(e,t){return eM(e,eu(e.checks,t))}function eR(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 C(i,r.transformation)):e}function ej(e){return t=>t.encoding?eA(t,eR(t.encoding,e)):t}function eD(e){return(0,l.Bj)(function t(r){return r.encoding?eA(r,eR(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 a=e[i],s=t(a);s!==a&&(r=!0),n[i]=s}return r?n:e}function eU(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 eC(e,r)}let eF=ej(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 eF(eC(e,t))}let eY=ej(eW);function eW(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(eC(e,t))}function eq(e,t){let r=[new C(W,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 eC(e,n)}function eX(e,t,r){let n;return n=new C(e,r),eA(t,t.encoding?[...t.encoding,n]:[n])}function eJ(e,t,r){let n,i,{literals:a,parameters:s}=(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(a.map(e=>new ei(e,t)),s.map(e=>new eo(e,t,r)))}function ez(e){return e.context?.isOptional??!1}function eG(e){return e.context?.isMutable??!1}let eV=(0,l.Bj)(e=>{if(e.encoding)return eV(eA(e,void 0));let t=e.recur?.(eV)??e,r=t.encodingChecks;return r?eT(t,n=>{n.encodingChecks.value=void 0,t===e&&(n.checks.value=eu(t.checks,r))}):t}),eK=(0,l.Bj)(e=>eV(eH(e))),eH=(0,l.Bj)(e=>e.encoding?function(e,t){let r=t.length,n=t[r-1],i=[new C(eH(eA(e,void 0)),t[0].transformation.flip())];for(let e=1;e<r;e++)i.unshift(new C(eH(t[e-1].to),t[e].transformation.flip()));let a=eH(n.to);return a.encoding?eA(a,[...a.encoding,...i]):eA(a,i)}(e,e.encoding):e.flip?.(eH)??e.recur?.(eH)??e);function eQ(e,t){let r=a.nGE(t);return n=>"None"===n._tag?a.lwU:n.value===t?r:a.fJG(new y.eE(e,n))}function eZ(e,t){return r=>"None"===r._tag?a.lwU:t(r.value)?a.PyW(r):a.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=eD(e=>{switch(e._tag){default:return e;case"Number":return e.toCodecStringTree();case"Union":return e.recur(e1)}}),e2=eD(e=>{switch(e._tag){default:return e;case"Symbol":case"UniqueSymbol":return e.toCodecStringTree();case"Union":return e.recur(e2)}}),e5=eD(e=>{switch(e._tag){default:return e;case"Number":case"Literal":case"BigInt":return e.toCodecStringTree();case"Union":return e.recur(e5)}}),e3="[\\s\\S]*?",e8=new globalThis.RegExp(`^${en}$`),e6=new globalThis.RegExp(`(?:${en}|Infinity|-Infinity|NaN)`);function e9(e){return eO(e8,{expected:"a string representing a finite number",meta:{_tag:"isStringFinite",regExp:e8},...e})}let e4=eP(z,[e9()]),e7=new C(e4,b.ZK),te=new C(new eb([e4,ew],"anyOf"),b.ZK),tt=new globalThis.RegExp("^-?\\d+$");function tr(e){return eO(tt,{expected:"a string representing a bigint",meta:{_tag:"isStringBigInt",regExp:tt},...e})}let tn=eP(z,[tr({expected:"a string representing a bigint"})]),ti=new C(tn,b.R7),ta=new globalThis.RegExp("^Symbol\\((.*)\\)$"),ts=new C(eP(z,[to()]),new b.IT(g.pd(e=>globalThis.Symbol.for(ta.exec(e)[1])),g.K$(e=>void 0!==globalThis.Symbol.keyFor(e)?a.PyW(globalThis.String(e)):a.fJG(new y.cw(h.some(e),{message:"cannot serialize to string, Symbol is not registered"})))));function to(e){return eO(ta,{expected:"a string representing a symbol",meta:{_tag:"isStringSymbol",regExp:ta},...e})}function tl(e,t,r,n,i){for(let a=0;a<e.length;a++){let s=e[a];if("FilterGroup"===s._tag)tl(s.checks,t,r,n,i);else{let e=s.run(t,n,i);if(e&&(r.push(new y.dJ(t,s,e)),s.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 j([],()=>(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 a=i?t.every(e):Object.keys(t).every(r=>e(t[r]));return r.delete(t),a&&n.add(t),a}(e))?a.PyW(e):a.fJG(new y.eE(t,h.some(e)))},{typeConstructor:{_tag:"effect/Json"},generation:{runtime:"Schema.Json",Type:"Schema.Json"},expected:"JSON value",toCodecJson:()=>new C(W,b.le()),toArbitrary:()=>e=>e.jsonValue()}),tf=eN(td,{typeConstructor:{_tag:"effect/MutableJson"},generation:{runtime:"Schema.MutableJson",Type:"Schema.MutableJson"}}),th=new C(new j([],()=>(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))?a.PyW(e):a.fJG(new y.eE(t,h.some(e)))},{expected:"StringTree"}),b.le())},6310(e,t,r){var n=r(4705),i=r(7720),a=r(8983),s=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(s.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=s.map(e),new d(e=>i.PyW(t(e)))}function g(e){var t;return t=(t,r)=>e(t,r).pipe(i.jkJ(s.some)),new d((e,r)=>s.isNone(e)?i.lwU:t(e.value,r))}function y(){return new d(()=>i.lwU)}function b(e){return new d(t=>{let r=s.filter(t,l.EA);return s.isSome(r)?i.PyW(r):i.jkJ(e,s.some)})}function v(){return m(globalThis.String)}function w(){return m(globalThis.Number)}function _(){return m(globalThis.BigInt)}function x(){return m(e=>new globalThis.Date(e))}function k(){return m(a.WG)}function S(){return m(a.DX)}function E(){return m(a.mU)}function I(){return g(e=>i.Z9x(i.yUA(a.y4(e)),t=>new u.h6(s.some(e),{message:t.message})))}function $(){return g(e=>c.YW(a.$T(e),{onFailure:t=>i.fJG(new u.h6(s.some(e),{message:t.message})),onSuccess:i.PyW}))}function O(){return g(e=>c.YW(a.$X(e),{onFailure:t=>i.fJG(new u.h6(s.some(e),{message:t.message})),onSuccess:i.PyW}))}function T(){return g(e=>c.YW(a.UD(e),{onFailure:t=>i.fJG(new u.h6(s.some(e),{message:t.message})),onSuccess:i.PyW}))}function A(){return g(e=>c.YW(a.EF(e),{onFailure:t=>i.fJG(new u.h6(s.some(e),{message:t.message})),onSuccess:i.PyW}))}function C(){return g(e=>c.YW(a.xQ(e),{onFailure:t=>i.fJG(new u.h6(s.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(s.some(e),{message:t instanceof URIError?t.message:"Invalid URI component"}))}})}function P(){return g(e=>s.match(n.L8(e),{onNone:()=>i.fJG(new u.h6(s.some(e),{message:"Invalid DateTime input"})),onSome:e=>i.PyW(n.yT(e))}))}l.Kg,r.d(t,{$T:()=>$,$X:()=>O,A0:()=>P,DX:()=>S,EF:()=>A,IQ:()=>b,K$:()=>g,Qf:()=>v,Qw:()=>_,UD:()=>T,WG:()=>k,_p:()=>N,cJ:()=>y,le:()=>p,mF:()=>M,mU:()=>E,n9:()=>x,pd:()=>m,uB:()=>d,wN:()=>w,xQ:()=>C,y4:()=>I})},6030(e,t,r){var n=r(8927),i=r(6470),a=r(4888),s=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 T(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 _ extends u{_tag="OneOf";ast;actual;successes;constructor(e,t,r){super(),this.ast=e,this.actual=t,this.successes=r}}function x(e,t){if(c(t))return t;if("string"==typeof t)return new b(s.some(e),{message:t});let r="string"==typeof t.issue?new b(s.some(e),{message:t.issue}):t.issue;return new h(t.path,r)}function k(e,t,r){if(Array.isArray(r))return n.ET(r)?1===r.length?x(e,r[0]):new g(t,s.some(e),n.Tj(r,t=>x(e,t))):void 0;if(void 0!==r)return"boolean"==typeof r?r?void 0:new b(s.some(e)):x(e,r)}let S=e=>{let t=C(e);if(void 0!==t)return t;switch(e._tag){case"InvalidType":return $(a.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)}`}},E=e=>C(e.issue)??C(e);function I(e){return t=>({issues:O(t,[],e?.leafHook??S,e?.checkHook??E)})}function $(e,t){return`Expected ${e}, got ${t}`}function O(e,t,r,n){switch(e._tag){case"Filter":{let a=n(e);if(void 0!==a)return[{path:t,message:a}];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 O(e.issue,t,r,n)}case"Encoding":return O(e.issue,t,r,n);case"Pointer":return O(e.issue,[...t,...e.path],r,n);case"Composite":return e.issues.flatMap(e=>O(e,t,r,n));case"AnyOf":{let s=C(e);if(0===e.issues.length){if(void 0!==s)return[{path:t,message:s}];return[{path:t,message:$(a.bo(e.ast),(0,i.GP)(e.actual))}]}return e.issues.flatMap(e=>O(e,t,r,n))}default:return[{path:t,message:r(e)}]}}let T=e=>O(e,[],S,E).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+=`
225
- at ${r}`}return t}function C(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 C(e.issue)}}function N(e,t="message"){let r=e?.[t];if("string"==typeof r)return r}function M(e){return s.isNone(e)?"no value provided":(0,i.GP)(e.value)}r.d(t,{E8:()=>_,ID:()=>I,L8:()=>k,Mw:()=>p,W:()=>w,Wi:()=>f,cw:()=>v,dJ:()=>d,eC:()=>g,eE:()=>y,gh:()=>c,gm:()=>h,h6:()=>b,vF:()=>m},{vp:S})},4858(e,t,r){var n=r(8927),i=r(8543),a=r(7720),s=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=E(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=a.lKS(t(e,r));return s.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=a.lKS(t(e,r));if(s.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(E(f.Ax(t))),e=>{let t=r(e,f.vr);return!!s.oJ(t)||(l.q(t.cause,"Type guard adapter can only return false for schema issues"),!1)}}function v(e,t){let r=I(E(f.Ax(e.ast)))(t,f.vr);if(s.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=E(e.ast);return void 0===t?r:(e,n)=>r(e,S(t,n))}function _(e,t){return $(w(e,t))}function x(e,t){let r;return r=I(w(e,t)),(e,t)=>{let n=r(e,t);return s.oJ(n)?d.Py(n.value):d.fJ(l.q(n.cause,"Result adapter can only return schema issues"))}}function k(e,t){let r;return $((r=E(f.UU(e.ast)),void 0===t?r:(e,n)=>r(e,S(t,n))))}let S=(e,t)=>void 0===t?e:{...e,...t};function E(e){let t=T(e);return(e,r)=>a.Ab9(t(c.some(e),r??f.vr),e=>"None"===e._tag?a.fJG(new h.h6(e)):a.PyW(e.value))}function I(e){return(t,r)=>a.lKS(e(t,r))}function $(e){let t=I(e);return(e,r)=>{let n=t(e,r);return s.oJ(n)?c.some(n.value):(l.q(n.cause,"Option adapter can only return none for schema issues"),c.none())}}function O(e,t){return a.Tyx(e,e=>a.pVV(()=>i.Tj(e,t)))}let T=(0,o.Bj)(e=>{let t,r=e.checks,i=e.encoding,s=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(T),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=s-1;e>=0;e--){let t=i[e],r=T(t.to);if(m=m?a.Ab9(m,e=>r(e,p)):r(u,p),"Transformation"===t.transformation._tag){let e=t.transformation.decode;m=a.Ab9(m,t=>e.run(t,p))}else m=t.transformation.decode(m,p)}m=O(m,t=>new h.Wi(e,u,t))}t??=e.getParser(T);let g=i=>{let s=t(i,p);return o&&!p?.disableChecks&&(s=a.Ab9(s,t=>{if(c.isSome(i)&&c.isSome(t)){let t=[];if(f.Lp(o,i.value,t,e,p),n.CZ(t))return a.fJG(new h.eC(e,i,t))}return a.PyW(t)})),r&&!p?.disableChecks&&(p?.errors==="all"&&d&&d.length>0&&c.isSome(i)&&(s=O(s,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})),s=a.Ab9(s,t=>{if(c.isSome(t)){let i=t.value,s=[];if(f.Lp(r,i,s,e,p),n.CZ(s))return a.fJG(new h.eC(e,t,s))}return a.PyW(t)})),s};return m?a.Ab9(m,g):g(u)}});r.d(t,{IQ:()=>k,L8:()=>y,YY:()=>g,_R:()=>w,is:()=>b,kv:()=>v,o:()=>m,q$:()=>x,y9:()=>_},{GP:k,mR:_})},5348(e,t,r){var n=r(631),i=r(4705),a=r(2302),s=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)),_=new h(u.n9(),u.pd(e=>e.getTime())),x=p({decode:e=>l.match(a.lX(e),{onNone:()=>s.fJG(new d.h6(l.some(e),{message:`Invalid Duration string: ${e}`})),onSome:s.PyW}),encode:e=>s.PyW(globalThis.String(e))}),k=p({decode:e=>s.PyW(a.cF(e)),encode:e=>l.match(a.tb(e),{onNone:()=>s.fJG(new d.h6(l.some(e),{message:`Unable to encode ${e} into a bigint`})),onSome:e=>s.PyW(e)})}),S=m({decode:e=>a.ne(e),encode:e=>a.kE(e)}),E=e=>{let t;return c.Gv(e)&&"string"==typeof e.message?(t=Object.hasOwn(e,"cause")?Error(e.message,{cause:E(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)?s.PyW(new URL(e)):s.fJG(new d.h6(l.some(e),{message:`Invalid URL string: ${e}`})),encode:e=>s.PyW(e.href)}),$=p({decode:e=>{let t=n.sH(e);return l.isNone(t)?s.fJG(new d.h6(l.some(e),{message:`Invalid BigDecimal string: ${e}`})):s.PyW(t.value)},encode:e=>s.PyW(n.GP(e))}),O=new h(u.y4(),u.WG()),T=new h(u.$T(),u.WG()),A=new h(u.UD(),u.DX()),C=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:()=>s.fJG(new d.h6(l.some(e),{message:`Invalid IANA time zone: ${e}`})),onSome:s.PyW}),encode:e=>s.PyW(e.id)}),R=p({decode:e=>l.match(i.ez(e),{onNone:()=>s.fJG(new d.h6(l.some(e),{message:`Invalid time zone: ${e}`})),onSome:s.PyW}),encode:e=>s.PyW(i.xV(e))}),j=p({decode:e=>l.match(i.L8(e),{onNone:()=>s.fJG(new d.h6(l.some(e),{message:`Invalid UTC DateTime string: ${e}`})),onSome:e=>s.PyW(i.yT(e))}),encode:e=>s.PyW(i.dv(e))}),D=p({decode:e=>l.match(i.MO(e),{onNone:()=>s.fJG(new d.h6(l.some(e),{message:`Invalid Zoned DateTime string: ${e}`})),onSome:s.PyW}),encode:e=>s.PyW(i.Rd(e))});r.d(t,{IT:()=>h,K$:()=>p,le:()=>y,pd:()=>m},{Ct:T,EJ:x,HO:_,I9:M,L8:e=>c.i5(e,f)?e:new h(e.decode,e.encode),LL:A,Nh:j,PE:S,Pp:N,R7:v,U0:O,XU:R,Y5:C,YZ:w,ZK:b,d9:D,dG:$,m8:k,nY:I,sm:e=>{let t,r;return m({decode:E,encode:(t=new WeakSet,r=n=>{if(c.bJ(n)){var i;let a;if(t.has(n))return"[Circular]";t.add(n);let s=(i=r,a={name:n.name,message:"string"==typeof n.message?n.message:""},e?.includeStack&&"string"==typeof n.stack&&(a.stack=n.stack),e?.excludeCause||void 0===n.cause||(a.cause=i(n.cause)),a);return t.delete(n),s}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 a=n.d97,s=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:s,HG:i,LZ:a,U9:l,VN:u,a6:o})},755(e,t,r){let n,i;var a=r(8619),s=r(4650),o=r(3833);let l="effect/Tracer/ParentSpan";class c extends a.kl()(l){}let u=a.Or("effect/Tracer/DisablePropagation",{defaultValue:s.f4}),d=a.Or("effect/Tracer/CurrentTraceLevel",{defaultValue:()=>"Info"}),f=a.Or("effect/Tracer/MinimumTraceLevel",{defaultValue:()=>"All"}),h="effect/Tracer",p=a.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 a{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 a(this.self)}}let s=(i={[n="~effect/Utils/internal"]:e=>e()},i[n](()=>Error().stack)?.includes(n)===!0?i[n]:({[n]:e=>e()})[n]);r.d(t,{B:()=>a},{s:s})},8433(e,t,r){let n;var i=r(8036),a=r(6470),s=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:s.D_,_E:s.D_,_R:s.D_},m=`${f}/identifier`,g=`${f}/args`,y=`${f}/evaluate`,b=`${f}/successCont`,v=`${f}/failureCont`,w=`${f}/ensureCont`,_=Symbol.for("effect/Effect/Yield"),x={pipe(){return(0,c.tT)(this,arguments)},toJSON(){return{...this}},toString(){return(0,a.GP)(this.toJSON(),{ignoreToString:!0,space:2})},[l.FX](){return this.toJSON()}},k={[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}},S={[f]:p,...x,[Symbol.iterator](){return new d.B(this)},toJSON(){return{_id:"Effect",op:this[m],...g in this?{args:this[g]}:void 0}}},E=e=>(0,u.i5)(e,h),I="~effect/Cause",$="~effect/Cause/Reason",O=e=>(0,u.i5)(e,I);class T{[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,a.GP)(this.reasons)})`}[l.FX](){return this.toJSON()}[i.HR](e){return O(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 C{[$];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,a.GP)(this)}[l.FX](){return this.toString()}}let N=new Map;class M extends C{error;constructor(e,t=N){super("Fail",t,e),this.error=e}toString(){return`Fail(${(0,a.GP)(this.error)})`}toJSON(){return{_tag:"Fail",error:this.error}}[i.HR](e){return U(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 T([]),R=e=>new T([new M(e)]);class j extends C{defect;constructor(e,t=N){super("Die",t,e),this.defect=e}toString(){return`Die(${(0,a.GP)(this.defect)})`}toJSON(){return{_tag:"Die",defect:this.defect}}[i.HR](e){return F(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 D=e=>new T([new j(e)]),L=(0,s.XY)(e=>O(e[0]),(e,t,r)=>0===t.mapUnsafe.size?e:new T(e.reasons.map(e=>e.annotate(t,r)))),U=e=>"Fail"===e._tag,F=e=>"Die"===e._tag;function B(e){return V("Effect.evaluate: Not implemented")}let Y=e=>({...S,[m]:e.op,[y]:e[y]??B,[b]:e[b],[v]:e[v],[w]:e[w]}),W=e=>{let t=Y(e);return function(){let r=Object.create(t);return r[g]=!1===e.single?arguments:arguments[0],r}},q=e=>{let t={...Y(e),[h]:h,_tag:e.op,get[e.prop](){return this[g]},toString(){return`${e.op}(${(0,a.GP)(this[g])})`},toJSON(){return{_id:"Exit",_tag:e.op,[e.prop]:this[g]}},[i.HR](e){return E(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}},X=q({op:"Success",prop:"value",[y](e){let t=e.getCont(b);return t?t[b](this[g],e,this):e.yieldWith(this)}}),J={key:"effect/Cause/StackTrace"},z=q({op:"Failure",prop:"cause",[y](e){let t=this[g],r=!1;e.currentStackFrame&&(t=L(t,{mapUnsafe:new Map([[J.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:z(t))}}),G=e=>z(R(e)),V=e=>z(D(e)),K=W({op:"WithFiber",[y](e){return this[g](e)}}),H=function(){class e extends globalThis.Error{}let t=Y({op:"YieldableError",[y](){return G(this)}});return delete t.toString,Object.assign(e.prototype,t),e}(),Q=(n=Symbol.for("effect/Data/Error/plainArgs"),class extends H{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},ea=G(en);r.d(t,{ET:()=>C,Xm:()=>et,dM:()=>M,s0:()=>T},{$D:Q,$L:e=>(0,u.i5)(e,er),$n:f,Aj:O,B4:$,DH:P,Eh:L,GN:_,IH:h,In:k,Iu:D,OE:R,PW:e=>(0,u.i5)(e,ee),PX:I,QJ:{key:"effect/Cause/InterruptorStackTrace"},R6:K,RS:ei,Rk:G,Sc:v,Uf:W,V2:V,Vw:e=>void 0===e?ea:G(ei(e)),Wg:e=>(0,u.i5)(e,$),Xb:F,_3:y,a2:g,b5:e=>new T(e),b9:E,cb:z,dO:N,ee:b,fU:x,ik:e=>"Interrupt"===e._tag,lC:U,qB:ee,q_:er,rN:Z,u4:w,xt:X,yj:Y,yw:e=>(0,u.i5)(e,f),z8:J})},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,a;r.d(t,{RD4:()=>i2,cOF:()=>i0,a1U:()=>ij,z4N:()=>i6,d$_:()=>i7,Do:()=>nz,Aub:()=>iZ,F7W:()=>iH,qwd:()=>iK,t8c:()=>iG,LkF:()=>i9,olX:()=>ae,obm:()=>rG,kWD:()=>rz,MUS:()=>iz,DQo:()=>iX,Bk6:()=>i8,Kkt:()=>i5,dsN:()=>n$,N24:()=>nm,Q56:()=>nn,jGc:()=>np,U9h:()=>ni,Q7R:()=>nO,hgn:()=>tr,ww9:()=>iM,gsV:()=>at,Muk:()=>iN,as:()=>e7,Xx$:()=>te,NLW:()=>ti,PCg:()=>n0,oIE:()=>nV,JrD:()=>nG,PO3:()=>nb,CJw:()=>ng,Rgn:()=>ny,E2r:()=>eQ,Tyx:()=>rt,rNk:()=>ri,sJf:()=>rn,Fig:()=>ro,UVN:()=>tw,osR:()=>rm,XWm:()=>rp,U9Y:()=>rs,AXC:()=>rb,zt4:()=>rv,KuX:()=>rg,loE:()=>ry,h_t:()=>ra,On5:()=>K,h2c:()=>H,Bou:()=>X,nIy:()=>R,h74:()=>J,O$X:()=>Q,GyP:()=>el,RJ6:()=>ee,ReC:()=>Z,RKA:()=>iB,_OA:()=>tV,sxi:()=>tH,Wj8:()=>iR,_32:()=>iP,Rud:()=>iW,s0X:()=>iq,cbG:()=>rY,F_Q:()=>eB,OY:()=>th,yeE:()=>no,u4Y:()=>rI,NS5:()=>rL,Hox:()=>tF,ely:()=>tB,yJo:()=>t$,HIt:()=>tI,K$2:()=>tk,GUt:()=>tS,jCT:()=>tT,_OD:()=>tO,lgw:()=>tq,Sv3:()=>tW,kMI:()=>tY,YDM:()=>tC,_mh:()=>tN,lNM:()=>tA,_sz:()=>t_,VE1:()=>tE,CoE:()=>tx,v9O:()=>tP,EkE:()=>tj,zPu:()=>tR,Wtn:()=>tU,x5l:()=>tM,il9:()=>tL,fJG:()=>eT,ATB:()=>eO,pVV:()=>eF,gOk:()=>eY,pEE:()=>eG,zFM:()=>ev,C6p:()=>ew,ABT:()=>eV,mKq:()=>ek,DKo:()=>eE,$MQ:()=>eI,eGS:()=>eS,D7p:()=>e_,INJ:()=>ex,vTQ:()=>n3,pbD:()=>nq,x1Q:()=>nX,E8K:()=>nJ,VtY:()=>nY,ahH:()=>nW,Pm0:()=>nB,W$I:()=>t6,BbX:()=>Y,k7S:()=>B,khU:()=>L,L$u:()=>U,QE5:()=>D,i8i:()=>nC,kAe:()=>nM,tU5:()=>q,Dd:()=>rE,qIB:()=>tu,Ab9:()=>tp,Bqz:()=>tm,UUz:()=>tt,fn:()=>e3,D9k:()=>e1,vCS:()=>e6,jJl:()=>nj,i4r:()=>re,zhn:()=>nH,yxg:()=>nZ,ar0:()=>n1,x6Z:()=>n2,bJ:()=>eP,sVm:()=>eN,yUA:()=>eM,JkU:()=>e0,Iku:()=>ep,gpn:()=>F,myX:()=>j,prj:()=>W,nn5:()=>G,XeO:()=>r$,GrF:()=>rO,GaK:()=>nv,Inz:()=>nS,eMl:()=>nI,Rft:()=>i1,ASO:()=>iQ,N6O:()=>rF,_y:()=>iV,OPA:()=>i4,oJd:()=>rB,c8t:()=>iJ,PnV:()=>i3,h$X:()=>nU,uVU:()=>nK,A_r:()=>iI,lIX:()=>aa,ORc:()=>P,Fbb:()=>id,zzk:()=>iu,Z98:()=>i_,Rd$:()=>ix,TjK:()=>tg,UcN:()=>rx,q7Y:()=>tv,jkJ:()=>ty,xm_:()=>r_,Z9x:()=>tb,YWq:()=>rR,D$$:()=>rM,NZb:()=>rD,khu:()=>rC,wR5:()=>tf,G$Q:()=>rj,tvg:()=>rP,ZmZ:()=>eZ,S5A:()=>nu,iKM:()=>nf,BeE:()=>nd,cfM:()=>ns,uRq:()=>nc,fGe:()=>nl,r7h:()=>na,nAr:()=>nh,uKv:()=>rT,QgK:()=>rk,DM4:()=>rS,jBG:()=>nT,ivC:()=>eX,PpN:()=>tZ,AAo:()=>r7,PfK:()=>t0,c7E:()=>t2,O4F:()=>tl,Vdx:()=>ts,FfP:()=>to,KT6:()=>tc,tQ6:()=>V,aAq:()=>t4,Xrv:()=>t7,Ket:()=>rA,bPG:()=>n9,lSz:()=>n6,MY7:()=>n8,eJC:()=>n5,pR5:()=>it,NpQ:()=>n7,jqV:()=>n4,v2Q:()=>ie,HZF:()=>is,lKS:()=>ii,rfH:()=>ir,lE:()=>ia,_Sg:()=>ta,z8E:()=>r4,iLB:()=>r2,Uio:()=>r1,vDJ:()=>rK,fou:()=>rH,Z$R:()=>rZ,pSt:()=>r0,RWE:()=>r9,d97:()=>r8,DLK:()=>rV,mdu:()=>nt,P1j:()=>ne,Pxi:()=>nr,euC:()=>tX,Nav:()=>tJ,oao:()=>tQ,yy4:()=>iY,Fu6:()=>iS,WbR:()=>iE,PyW:()=>e$,lwU:()=>eL,nGE:()=>eD,DYE:()=>eC,OH5:()=>eA,Mim:()=>tn,dGm:()=>rl,bKC:()=>ru,cA6:()=>rc,nAi:()=>rh,sFT:()=>rd,k$L:()=>rf,ayu:()=>rJ,wRz:()=>rq,D52:()=>rX,mgX:()=>rW,kJM:()=>ih,pkL:()=>eU,SvU:()=>eq,$mh:()=>eJ,Vxk:()=>al,rfi:()=>nw,FcF:()=>nE,scW:()=>rw,r_d:()=>tz,bUZ:()=>tG,gvr:()=>iO,tfT:()=>nA,rIH:()=>eW,z7s:()=>t9,iMI:()=>nR,KyM:()=>t5,$$g:()=>ac,hq:()=>iA,fRP:()=>iC,zr8:()=>ik,_o1:()=>ip,nDN:()=>im,MaT:()=>ig,m9E:()=>ej,KN3:()=>eR,yU6:()=>t3,OYO:()=>t8});var s=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),_=r(995),x=r(8469),k=r(755),S=r(3537),E=r(8433),I=r(2849),$=r(9354),O=r(8344),T=r(3628);let A=e=>{if(e?.captureStackTrace===!1||e?.captureStackTrace!==void 0&&"boolean"!=typeof e.captureStackTrace)return e;let t=(0,T.jt)();(0,T.ft)(3);let r=Error();return(0,T.ft)(t),{...e,captureStackTrace:N(()=>r.stack)}},C=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=C(3);class M extends E.ET{fiberId;constructor(e,t=E.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,E.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),R=e=>new E.s0([new M(e)]),j=e=>e.reasons.some(E.lC),D=e=>{let t=e.reasons.find(E.lC);return t?_.Py(t):_.fJ(e)},L=e=>{for(let t=0;t<e.reasons.length;t++){let r=e.reasons[t];if("Fail"===r._tag)return _.Py(r.error)}return _.fJ(e)},U=u.zL(L),F=e=>e.reasons.some(E.Xb),B=e=>{let t=e.reasons.find(E.Xb);return t?_.Py(t):_.fJ(e)},Y=e=>{let t=e.reasons.find(E.Xb);return t?_.Py(t.defect):_.fJ(e)},W=e=>e.reasons.some(E.ik),q=e=>{let t=e.reasons.find(E.ik);return t?_.Py(t):_.fJ(e)},X=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?_.Py(t):_.fJ(e)},J=e=>{let t=X(e);return _.N6(t)?z:t.success},z=new Set,G=e=>e.reasons.length>0&&e.reasons.every(E.ik),V=e=>o.LZ(e.annotations),K=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)},H=(0,f.XY)(2,(e,t)=>{if(0===e.reasons.length)return t;if(0===t.reasons.length)return e;let r=new E.s0(s.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,E.lC)(e)?(r=!0,new E.dM(t(e.error))):e);return r?(0,E.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,T.jt)();for(let i of((0,T.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=es(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,T.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?ea(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"),a=[n];for(let e=1;e<i.length&&!/(?:Generator\.next|~effect\/Effect)/.test(i[e]);e++)a.push(i[e]);return r?ea(a.join("\n"),r):a.join("\n")},ea=(e,t)=>{let r=t?.get(E.z8.key);return r&&(e=`${e}
226
- ${eo(r)}`),e},es=(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(E.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} {
256
+ ${u.repeat(f)}}`;return d(o,n)}return String(o)}(t,0)},IB:()=>c,Yq:()=>l,_r:()=>s,jV:()=>o})},4650(e,t,r){var n=r(9138);let i=e=>()=>e,a=i(!0),s=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,a,s,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 a(i(n(r(t(e.apply(this,arguments))))))};case 7:return function(){return s(a(i(n(r(t(e.apply(this,arguments)))))))};case 8:return function(){return o(s(a(i(n(r(t(e.apply(this,arguments))))))))};case 9:return function(){return l(o(s(a(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:s,ue:a})},4450(e,t,r){var n=r(4650),i=r(6516),a=r(5369);let s="~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(_.has(e))return h("[Circular]");_.add(e);let r=t();return _.delete(e),r}(e,()=>{if(d(e))return e[s]();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,a.i5)(e,s),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,_=new WeakSet;r.d(t,{},{HR:s,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),a=r(1743);let s=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,a.E$)(e)};r.d(t,{},{FX:s,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)},[s](){return this.toJSON()},toString(){return(0,n.GP)(this.toJSON())}}})},8496(e,t,r){var n=r(4650),i=r(3833),a=r(5369);let s=(0,n.XY)(2,(e,t)=>{let r=0;for(let n of e){let e=t(n,r);if((0,a.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:s,pb:o})},5089(e,t,r){var n=r(8619),i=r(3717),a=r(4650),s=r(8433),o=r(1136),l=r(9138),c=r(2672);let u="~effect/Layer/MemoMap",d={"~effect/Layer":{_ROut:a.D_,_E:a.D_,_RIn:a.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 a,s,l,u=this.get(e,t);return u?u:(n=this,a=c.LZ(),s=i.LZ(),l={observers:1,effect:i.Tx(s),finalizer:t=>o.DYE(()=>(l.observers--,0===l.observers)?(n.map.delete(e),c.VN(a,t)):o.rIH)},n.map.set(e,l),o.Uio(t,l.finalizer).pipe(o.qIB(()=>r(n,a)),o.cfM(e=>(l.effect=e,i.Vw(s,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,a.XY)(3,(e,t,r)=>o.PfK(o.TjK(e.build(t,r),n.WQ(g,t)),g,t)),b=(0,a.XY)(2,(e,t)=>s.R6(r=>y(e,g.forkOrCreate(r.context),t))),v=e=>f((0,a.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))},_=(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)))},k=(e,t,r)=>h((n,i)=>o.qIB(Array.isArray(t)?_(t,n,i):t.build(n,i),t=>e.build(n,i).pipe(o.PpN(t),o.TjK(e=>r(e,t))))),S=(0,a.XY)(2,(e,t)=>k(e,t,a.D_)),I=(0,a.XY)(2,(e,t)=>k(e,t,(e,t)=>n.h1(t,e)));r.d(t,{},{Gt:S,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:I,Um:(...e)=>h((t,r)=>_(e,t,r)),j6:m})},3833(e,t,r){r.r(t),r.d(t,{Do:()=>eh,all:()=>K,andThen:()=>B,as:()=>D,asVoid:()=>L,bind:()=>ef,bindTo:()=>eu,composeK:()=>X,contains:()=>el,containsWith:()=>eo,exists:()=>ec,filter:()=>er,filterMap:()=>et,firstSomeOf:()=>E,flatMap:()=>F,flatMapNullishOr:()=>W,flatten:()=>q,fromIterable:()=>v,fromNullOr:()=>C,fromNullishOr:()=>$,fromUndefinedOr:()=>O,gen:()=>ep,getFailure:()=>x,getOrElse:()=>_,getOrNull:()=>A,getOrThrow:()=>R,getOrThrowWith:()=>P,getOrUndefined:()=>M,getSuccess:()=>w,isNone:()=>m,isOption:()=>p,isSome:()=>g,let:()=>ed,lift2:()=>ea,liftNullishOr:()=>T,liftPredicate:()=>es,liftThrowable:()=>N,makeCombinerFailFast:()=>eg,makeEquivalence:()=>en,makeOrder:()=>ei,makeReducer:()=>em,makeReducerFailFast:()=>ey,map:()=>j,match:()=>y,none:()=>f,orElse:()=>k,orElseResult:()=>I,orElseSome:()=>S,partitionMap:()=>ee,product:()=>G,productMany:()=>V,reduceCompact:()=>Q,some:()=>h,tap:()=>J,toArray:()=>Z,toRefinement:()=>b,void:()=>U,zipLeft:()=>z,zipRight:()=>Y,zipWith:()=>H});var n=r(8036),i=r(1044),a=r(4650),s=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,a.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,_=(0,a.XY)(2,(e,t)=>m(e)?t():e.value),k=(0,a.XY)(2,(e,t)=>m(e)?t():e),S=(0,a.XY)(2,(e,t)=>m(e)?h(t()):e),I=(0,a.XY)(2,(e,t)=>m(e)?j(t(),l.Py):j(e,l.fJ)),E=e=>{let t=f();for(t of e)if(g(t))break;return t},$=e=>null==e?f():h(e),O=e=>void 0===e?f():h(e),C=e=>null===e?f():h(e),T=e=>(...t)=>$(e(...t)),A=_(a.XR),M=_(a.MN),N=e=>(...t)=>{try{return h(e(...t))}catch{return f()}},P=(0,a.XY)(2,(e,t)=>{if(g(e))return e.value;throw t()}),R=P(()=>Error("getOrThrow called on a None")),j=(0,a.XY)(2,(e,t)=>m(e)?f():h(t(e.value))),D=(0,a.XY)(2,(e,t)=>j(e,()=>t)),L=D(void 0),U=h(void 0),F=(0,a.XY)(2,(e,t)=>m(e)?f():t(e.value)),B=(0,a.XY)(2,(e,t)=>F(e,e=>{let r=(0,u.Tn)(t)?t(e):t;return p(r)?r:h(r)})),W=(0,a.XY)(2,(e,t)=>m(e)?f():$(t(e.value))),q=F(a.D_),Y=(0,a.XY)(2,(e,t)=>F(e,()=>t)),z=(0,a.XY)(2,(e,t)=>J(e,()=>t)),X=(0,a.XY)(2,(e,t)=>r=>F(e(r),t)),J=(0,a.XY)(2,(e,t)=>F(e,e=>j(t(e),()=>e))),G=(e,t)=>g(e)&&g(t)?h([e.value,t.value]):f(),V=(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)},K=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)},H=(0,a.XY)(3,(e,t,r)=>j(G(e,t),([e,t])=>r(e,t))),Q=(0,a.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,a.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,a.XY)(2,(e,t)=>{if(m(e))return f();let r=t(e.value);return l.oJ(r)?h(r.success):f()}),er=(0,a.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),ea=e=>(0,a.XY)(2,(t,r)=>H(t,r,e)),es=(0,a.XY)(2,(e,t)=>t(e)?h(e):f()),eo=e=>(0,a.XY)(2,(t,r)=>!m(t)&&e(t.value,r)),el=eo(n.jI()),ec=(0,a.XY)(2,(e,t)=>!m(e)&&t(e.value)),eu=s.Jr(j),ed=s.zM(j),ef=s.oI(j,F),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 a=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),s=i((e,t)=>e<t?-1:1),o=(0,n.XY)(2,(e,t)=>i((r,n)=>e(t(r),t(n)))),l=o(a,e=>e.getTime());function c(e){return i((t,r)=>{let n=t.length,i=r.length,s=Math.min(n,i);for(let n=0;n<s;n++){let i=e(t[n],r[n]);if(0!==i)return i}return a(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:s,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:a,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)}},a=function(){function e(){}return e.prototype=i,e}();r.d(t,{},{Xs:a,tT:n})},5369(e,t,r){var n=r(4650);function i(e){return"string"==typeof e}function a(e){return"number"==typeof e}function s(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)||a(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 _(e){return e instanceof Error}function k(e){return e instanceof Date}function S(e){return w(e,Symbol.iterator)||i(e)}function I(e){return e instanceof RegExp}r.d(t,{$P:()=>k,Bm:()=>l,EA:()=>f,Et:()=>a,Fw:()=>v,Gv:()=>b,Kg:()=>i,Lm:()=>s,Pd:()=>g,Pe:()=>h,Tn:()=>u,Vq:()=>m,b0:()=>d,bJ:()=>_,gd:()=>I,hL:()=>c,sI:()=>o,t8:()=>y,uy:()=>p,xZ:()=>S},{$J:x,i5:w})},4505(e,t,r){var n=r(8543),i=r(7598),a=r(956),s=r(4650),o=r(1136),l=r(995);let c=(0,s.XY)(2,(e,t)=>o.rNk(e,f,e=>t(e))),u=e=>"Fail"===e._tag&&n.$L(e.error),d=a.Bh(n.kh,e=>n.$L(e)?l.Py(e):l.fJ(e));n.kh;let f=a.Bh(n.kh,e=>n.$L(e)?l.Py(e.value):l.fJ(e)),h=(0,s.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]),a=(0,n.XY)(2,(e,t)=>{let r={...e};for(let n of o(e))r[n]=t(e[n],n);return r}),s=(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:a,Wo:i,pb:s})},1743(e,t,r){var n=r(9138),i=r(5369);let a=Symbol.for("~effect/Redactable");function s(e){return(0,i.i5)(e,a)?o(e):e}function o(e){return e[a](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$:()=>s,f6:()=>o},{fL:l,uC:a})},3864(e,t,r){var n=r(1136),i=r(8344);i.F8;let a=i.iL;i.Gl,i.d8,i.vA;let s=i.zQ;i.rf,i.ce,i.ls,i.nU,i.aG,n.d$_,n.olX,r.d(t,{},{iL:a,zQ:s})},995(e,t,r){var n=r(4650),i=r(5091),a=r(4403);let s=a.Py,o=a.fJ;a.sV,a.aI;let l=a.N6,c=a.oJ;a.Oz,a.L8;let u=(0,n.XY)(2,(e,t)=>l(e)?o(t(e.failure)):s(e.success)),d=(0,n.XY)(2,(e,t)=>c(e)?s(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:s,Tj:d,YW:f,fJ:o,oJ:c,xm:u})},3587(e,t,r){var n=r(8543),i=r(8619),a=r(2302),s=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,s.dY)({input:void 0,output:void 0,duration:a.v_,attempt:0,start:0,now:0,elapsed:0,elapsedSincePrevious:0})}),p={[f]:{_Out:s.D_,_In:s.D_,_Env:s.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 a=n-t,s=void 0===e?0:n-e;return e=n,{input:i,attempt:++r,start:t,now:n,elapsed:a,elapsedSincePrevious:s}}},y=e=>l.Tyx(e.step,e=>l.PyW(()=>l.ATB(e))),b=e=>{let t,r=a.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,s.XY)(2,(e,t)=>{let r=void 0===t.duration?void 0:a.bN(t.duration);return w(e,({attempt:e,elapsed:n})=>l.PyW((void 0===t.times||e<=t.times)&&(void 0===r||a.bi(a.ne(n),r))))}),w=(0,s.XY)(2,(e,t)=>m(l.TjK(y(e),e=>{let r=g();return(i,a)=>l.qIB(e(i,a),e=>{let[s,c]=e,u=t({...r(i,a),output:s,duration:c});return l.qIB((0,o.yw)(u)?u:l.PyW(u),t=>t?l.PyW(e):n.Vw(s))})}))),x=b(a.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 a=r(i,n);return a.output=e,a.duration=t,l.as(l.yy4(t),a)})})}))})},8469(e,t,r){var n=r(8619);let i=n.Or("effect/Scheduler",{defaultValue:()=>new o}),a="setImmediate"in globalThis?e=>{let t=globalThis.setImmediate(e);return()=>globalThis.clearImmediate(t)}:e=>{let t=setTimeout(e,0);return()=>clearTimeout(t)};class s{buckets=[];scheduleTask(e,t){let r,n=this.buckets,i=n.length,a=0;for(;a<i&&!(n[a][0]>t);a++)r=n[a];r&&r[0]===t?r[1].push(e):a===i?n.push([t,[e]]):n.splice(a,0,[t,[e]])}drain(){let e=this.buckets;return this.buckets=[],e}}class o{executionMode;setImmediate;constructor(e="async",t=a){this.executionMode=e,this.setImmediate=t}shouldYield(e){return e.currentOpCount>=e.maxOpsBeforeYield}makeDispatcher(){return new l(this.setImmediate)}}class l{tasks=new s;running=void 0;setImmediate;constructor(e=a){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,a,s,o,l,c,u,d;r.d(t,{O31:()=>eA,v8c:()=>eE,Xsx:()=>tt,Nej:()=>e2,kld:()=>eZ,PSP:()=>tr,wYs:()=>e5,Aiz:()=>e3,uSQ:()=>ew,xCb:()=>function e(t){let r=t.map(ew);return ef(M.KC(r,"anyOf",void 0),{literals:t,members:r,mapMembers(e){return eN(e(this.members))},pick:t=>e(t),transform:e=>eN(r.map((t,r)=>t.transform(e[r])))})},ukk:()=>eH,T9y:()=>eP,wNn:()=>eI,pHd:()=>e8,mSG:()=>eT,QfV:()=>eS,_kM:()=>eC,X0d:()=>tn,gPz:()=>eN,$r1:()=>ex,rvE:()=>ei,usV:()=>ea,hzj:()=>en,GLL:()=>eL,_Re:()=>ec,q$Z:()=>eu,svK:()=>ed,is:()=>el,Bt9:()=>eV,MIs:()=>eX,yJO:()=>eJ,OWK:()=>eG,tJb:()=>eK,Pto:()=>ez,nfo:()=>eq,HNH:()=>eY,fXn:()=>eM,Wa3:()=>em,lqM:()=>ep,Qrq:()=>eh,YPB:()=>eD,DYE:()=>ej,TcI:()=>eW,lHk:()=>ta,O3D:()=>ey,_oz:()=>ti,rcy:()=>eo,AxX:()=>eg,tiU:()=>eB,E$i:()=>eF});var f,h,p,m,g,y,b,v=r(631),w=r(8543),x=r(2718),_=r(4705),k=r(2302),S=r(7720),I=(r(8983),r(7598)),E=r(6470),$=r(8433),O=r(8927),C=r(8036),T=r(5369),A=r(8099);T.gd;var M=r(9177),N=r(4888),P=r(9138);let R="~effect/SchemaError/SchemaError";class j extends x.rN("SchemaError"){[R]=R;constructor(e){super({issue:e})}get message(){return this.issue.toString()}toString(){return`SchemaError(${this.message})`}}var D=r(4858);let L="~effect/Schema/Schema",U={[L]:L,pipe(){return P.tT(this,arguments)},annotate(e){return this.rebuild(M.fz(this.ast,e))},annotateKey(e){return this.rebuild(M.us(this.ast,e))},check(...e){return this.rebuild(M.EJ(this.ast,e))}};function F(e,t){let r=Object.create(U);t&&Object.assign(r,t),r.ast=e,r.rebuild=e=>F(e,t);let n=D.o(r);return r.makeEffect=(e,t)=>B(n(e,t)),r.make=D.L8(r),r.makeOption=D.YY(r),r}function B(e){return S.Tyx(e,e=>S.pVV(()=>w.Tj(e,e=>new j(e))))}let W=q(function(e){switch(e._tag){case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}});function q(e){return t=>{let r=new Map;for(let e=0;e<t.length;e++)r.set(M.O3(t[e]),e);let n=[...t].sort((t,n)=>{t=M.O3(t),n=M.O3(n);let i=e(t),a=e(n);return i!==a?i-a:r.get(t)-r.get(n)});return n.some((e,r)=>e!==t[r])?n:t}}let Y=new Set(["~structural","~sentinels","meta","arbitrary","toArbitrary","toEquivalence","toFormatter","toCodec","toCodecJson","toCodecIso",M.YA]),z=new Set(["title","description","default","examples","readOnly","writeOnly","format","contentEncoding","contentMediaType","contentSchema"]);function X(e){if(void 0!==e){let t=A.pb(e,(e,t)=>!Y.has(t));if(!A.DM(t))return{annotations:t}}}function J(e,t){return e.some(e=>{switch(e._tag){case"Filter":return e.meta._tag===t;case"FilterGroup":return J(e.checks,t)}})}function G(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 V(e){switch(e._tag){case"Literal":return globalThis.String(e.literal).replace(/[/\\^$*+?.()|[\]{}]/g,"\\$&");case"String":return M.XV;case"Number":return M.bm;case"TemplateLiteral":return e.parts.map(V).join("");case"Union":return e.types.map(V).join("|");default:throw new globalThis.Error("Unsupported part",{cause:e})}}var K=r(3833),H=r(6364),Q=r(995),Z=r(8469),ee=r(6310),et=r(6030),er=r(5348);function en(){return(e,t,r)=>ef(new M.D6(e.map(M.hu),e=>t(e.map(e=>ef(e))),r))}r(1044)._k,H._k;function ei(e){return t=>ev(ev(t).annotate(e))}function ea(e){return t=>t.rebuild(M.us(t.ast,e))}function es(e){return I.oJ(e)?e.value:{issues:[{message:w.j9(e.cause)}]}}function eo(e,t){let r=D._R(e),n={errors:"all",...t?.parseOptions},i=et.ID(t),a=e=>{let t=new Z.FG,a=S.MY7(S.YWq(r(e,n),{onFailure:i,onSuccess:e=>({value:e})}),{scheduler:t});a.currentDispatcher?.flush();let s=a.pollUnsafe();return s?es(s):new Promise(e=>{a.addObserver(t=>{e(es(t))})})};return"~standard"in e?("validate"in e["~standard"]||Object.assign(e["~standard"],{validate:a}),e):Object.assign(e,{"~standard":{version:1,vendor:"effect",validate:a}})}let el=D.is;function ec(e,t){let r=D._R(e,t);return(e,t)=>B(r(e,t))}function eu(e,t){let r=D.q$(e,t);return(e,t)=>Q.xm(r(e,t),e=>new j(e))}function ed(e,t){let r=ec(e,t);return(e,t)=>(function(e){let t=S.lKS(e);if(I.oJ(t))return t.value;throw function(e,t){let r;for(let i of e.reasons){var n;if(!w.lC(i)||(n=i.error,!T.i5(n,R)))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))}D.kv,D.y9,D.mR,D.IQ,D.GP;let ef=F,eh=e=>ef(M.Qr(e.ast),{schema:e}),ep=e=>eh(eR(e)),em=e=>ef(M.W(e.ast),{schema:e}),eg=e=>ef(M.Ax(e.ast),{schema:e}),ey=e=>ef(M.O3(e.ast),{schema:e}),eb="~effect/Schema/flip";function ev(e){return T.i5(e,eb)&&e[eb]===eb?e.schema.rebuild(M.UU(e.ast)):ef(M.UU(e.ast),{[eb]:eb,schema:e})}function ew(e){let t=ef(new M.uS(e),{literal:e,transform:r=>t.pipe(eL(ew(r),{decode:ee.pd(()=>r),encode:ee.pd(()=>e)}))});return t}M.Zm,M.bz;let ex=ef(M.L5),e_=ef(M.ch),ek=ef(M.Vx),eS=ef(M.Yj),eI=ef(M.ai),eE=ef(M.zM),e$=ef(M.HR);function eO(e,t){return ef(e,{fields:t,mapFields(e,t){let r=e(this.fields);return eO(M.w3(r,t?.unsafePreserveChecks?this.ast.checks:void 0),r)}})}function eC(e){return eO(M.w3(e,void 0),e)}function eT(e,t,r){let n=r?.keyValueCombiner?.decode||r?.keyValueCombiner?.encode?new M.E$(r.keyValueCombiner.decode,r.keyValueCombiner.encode):void 0;return ef(M.g1(e.ast,t.ast,n),{key:e,value:t})}M.we,M.rI,M.ZG;let eA=e=>ef(new M.DO(!1,[],[e.ast]),{value:e}),eM=e=>ef(new M.DO(!0,e.ast.elements,e.ast.rest),{schema:e});function eN(e,t){return function e(t,r){return ef(t,{members:r,mapMembers(t,r){let n=t(this.members);return e(M.KC(n,this.ast.mode,r?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}(M.KC(e,t?.mode??"anyOf",void 0),e)}let eP=e=>eN([e,e_]),eR=e=>eN([e,ek]);function ej(e){return ef(new M.V3(()=>e().ast))}function eD(e,t){return r=>ef(M.EJ(r.ast,[M.D$(e,t)]),{schema:r})}function eL(e,t){return r=>ef(M.GL(r.ast,e.ast,t?er.L8(t):er.le()),{from:r,to:e})}function eU(e){return S.Tyx(e,e=>S.pVV(()=>w.Tj(e,e=>e.issue)))}function eF(e,t){let r=t?.encodingStrategy==="omit"?ee.cJ():ee.le();return t=>eh(ey(t)).pipe(eL(t,{decode:ee.IQ(eU(e)),encode:r}))}function eB(e,t){let r=t?.encodingStrategy==="omit"?ee.cJ():ee.le();return t=>ep(ey(t)).pipe(eL(t,{decode:ee.IQ(eU(e)),encode:r}))}function eW(e){var t;return ew(e).pipe((t=S.PyW(e),e=>ef(M.Ez(e.ast,eU(t)),{schema:e})))}function eq(){return(e,t)=>new M.N_(e.ast,er.L8(t))}let eY=M.HN,ez=M.Pt;function eX(e){return eY(e=>globalThis.Number.isFinite(e),{expected:"a finite number",meta:{_tag:"isFinite"},arbitrary:{constraint:{noInfinity:!0,noNaN:!0}},...e})}M.bk,M.ZB,M.IZ;let eJ=(y={order:H.wN,annotate:e=>({meta:{_tag:"isGreaterThan",exclusiveMinimum:e}})},n=H.yJ(y.order),i=y.formatter??E.GP,(e,t)=>eY(t=>n(t,e),{expected:`a value greater than ${i(e)}`,arbitrary:{constraint:{ordered:{order:y.order,minimum:e,exclusiveMinimum:!0}}},...y.annotate?.(e),...t})),eG=(f={order:H.wN,annotate:e=>({meta:{_tag:"isGreaterThanOrEqualTo",minimum:e}})},u=H.OW(f.order),d=f.formatter??E.GP,(e,t)=>eY(t=>u(t,e),{expected:`a value greater than or equal to ${d(e)}`,arbitrary:{constraint:{ordered:{order:f.order,minimum:e}}},...f.annotate?.(e),...t}));H.wN,H.wN;let eV=(b={order:H.wN,annotate:e=>({meta:{_tag:"isBetween",...e}})},a=H.OW(b.order),s=H.yJ(b.order),o=H.bi(b.order),l=H.hl(b.order),c=b.formatter??E.GP,(e,t)=>{let r=e.exclusiveMinimum?s:a,n=e.exclusiveMaximum?l:o;return eY(t=>r(t,e.minimum)&&n(t,e.maximum),{expected:`a value between ${c(e.minimum)}${e.exclusiveMinimum?" (excluded)":""} and ${c(e.maximum)}${e.exclusiveMaximum?" (excluded)":""}`,arbitrary:{constraint:{ordered:{order:b.order,minimum:e.minimum,maximum:e.maximum,...e.exclusiveMinimum&&{exclusiveMinimum:!0},...e.exclusiveMaximum&&{exclusiveMaximum:!0}}}},...b.annotate?.(e),...t})});function eK(e,t){return e=Math.max(0,Math.floor(e)),eY(t=>t.length>=e,{expected:`a value with a length of at least ${e}`,meta:{_tag:"isMinLength",minLength:e},[M.C3]:!0,arbitrary:{constraint:{minLength:e}},...t})}H.n9,H.n9,H.n9,H.n9,H.n9,H.Qw,H.Qw,H.Qw,H.Qw,H.Qw,v.pH,v.pH,v.pH,v.pH,v.pH;let eH=eS.check(eK(1,void 0)),eQ=[];function eZ(e){let t=e?.includeStack===!0|2*(e?.excludeCause===!0),r=eQ[t];if(void 0!==r)return r;let n=td.pipe(eL(ex,er.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 eQ[t]=n,n}er.nY;let e0=eS.annotate({expected:"a string in ISO 8601 format that will be decoded as a Date"}),e1=(h=globalThis.Date,p={typeConstructor:{_tag:"Date"},generation:{runtime:"Schema.Date",Type:"globalThis.Date"},expected:"Date",toCodecJson:()=>eq()(e0,er.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===H.n9?t.constraint.ordered:void 0))},m=e=>e instanceof h,g=p,en()([],()=>(e,t)=>m(e)?S.PyW(e):S.fJG(new et.eE(t,K.some(e))),g));er.YZ,er.HO;let e2=e1.check(eY(e=>!isNaN(e.getTime()),{expected:"a valid date",meta:{_tag:"isDateValid"},arbitrary:{constraint:{valid:!0}},...void 0}));k.n$,er.EJ,er.m8,er.PE;v.s5,er.dG;let e5=eI.check(eX()),e3=eI.check(eY(e=>globalThis.Number.isSafeInteger(e),{expected:"an integer",meta:{_tag:"isInt"},arbitrary:{constraint:{integer:!0}},...void 0}));er.ZK,er.ZK,er.R7,er.Ct,er.LL,er.Y5,er.Pp;let e8=eN([e5,e$,eS]);er.U0,_.yF,er.Nh,_.Xy,_.lU,_.rg,er.yd,_.kQ,er.XU,er.d9;let e6=globalThis.Symbol.for("immer-draftable"),e9={};function e4(e,t,r,n,i){var a,s,o;let l,c=(a=r,s=t,o=n,e=>{if(void 0!==l)return l;let t=new er.IT(ee.pd(t=>new e(t)),ee.le());return l=eL(ef(new M.D6([a.ast],()=>(t,r)=>t instanceof e||T.i5(t,e7(s))?S.PyW(t):S.fJG(new et.eE(r,K.some(t))),{identifier:s,[M.YA]:([e])=>new M.N_(e,t),toCodec:([e])=>new M.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":M.SL(a.ast),...o})),t)(a)}),u=e7(t),d=class extends e{constructor(...[e,t]){let n=t?.["~payload"],i=n?.token===e9?n.value:r.make(e??{},t);super(i,{...t,disableChecks:!0,"~payload":{token:e9,value:i}})}static [L]=L;get[u](){return u}static [e6]=!0;static identifier=t;static fields=r.fields;static get ast(){return c(this).ast}static pipe(){return P.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 D.YY(c(this))(e??{},t)}static makeEffect(e,t){return c(this).makeEffect(e??{},t)}static annotate(e){return this.rebuild(M.fz(this.ast,e))}static annotateKey(e){return this.rebuild(M.us(this.ast,e))}static check(...e){return this.rebuild(M.EJ(this.ast,e))}static extend(e){return(t,n)=>{let a=te(t)?t:eC(t),s={...r.fields,...a.fields},o=M.w3(s,r.ast.checks,{identifier:e});return e4(this,e,eO(M.EJ(o,a.ast.checks),s),n,i)}}static mapFields(e,t){return r.mapFields(e,t)}};return void 0!==i&&Object.assign(d.prototype,i(t)),d}function e7(e){return`~effect/Schema/Class/${e}`}function te(e){return T.i5(e,L)&&e[L]===L}let tt=e=>(t,r)=>{let n=te(t)?t:eC(t);return e4(x.Xs,e,n,r,e=>({toString(){return`${e}(${(0,E.GP)({...this})})`}}))},tr=e=>(t,r)=>{let n=te(t)?t:eC(t);return e4($.$D,e,n,r,e=>({name:e}))},tn=e=>(t,r,n)=>{let i=te(r)?r.mapFields(e=>({_tag:eW(t),...e}),{unsafePreserveChecks:!0}):eC({_tag:eW(t),...r});return tr(e??t)(i,n)};function ti(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,a=A.Tj(e.references,e=>s(e));return{dialect:"draft-2020-12",schemas:O.Tj(e.representations,e=>s(e)),definitions:a};function s(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 s(t.encodedSchema);case"Suspend":return s(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=s(t.contentSchema)),e}case"Number":return J(t.checks,"isInt")?{type:"integer"}:J(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 s({_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(V).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=s(e.type),n=o(e.annotations);return n?G(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=s(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={},a=[];for(let e of t.propertySignatures){let t=e.name;if("string"!=typeof t)throw new globalThis.Error(`Unsupported property signature name: ${(0,E.GP)(t)}`);let r=s(e.type),n=o(e.annotations);i[t]=n?G(r,n):r,e.isOptional||a.push(t)}Object.keys(i).length>0&&(r.properties=i),a.length>0&&(r.required=a),r.additionalProperties=n;let l={};for(let n of t.indexSignatures){let t=s(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(V).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),T.Gv(r.additionalProperties)&&A.DM(r.additionalProperties)&&delete r.additionalProperties,r}case"Union":{let e=t.types.map(s);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,a;for(let e of(i=t.checks,a=r.type,i.map(function e(t){switch(t._tag){case"Filter":var r=t,n=a;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:s(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=G(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||z.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:O.Tj(e,e=>s(e)),references:t};function a(e){let t=e,r=0;for(;n.has(t);)t=`${e}${++r}`;return n.add(t),t}function s(e,n){let l=r.get(e);if(void 0!==l)return{_tag:"Reference",$ref:l};let c=M.S5(e),u=N.KE(e)??n;if(e!==c)return s(c,u);if(void 0!==u){let n=a(u);r.set(e,n);let i=o(e),s=t[u];return void 0!==s&&C.aI(i,s)?(r.set(e,u),{_tag:"Reference",$ref:u}):(t[n]=i,{_tag:"Reference",$ref:n})}if(i.has(e)){let t=a(`${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=X(e.annotations);switch(e._tag){case"Declaration":{let r,n=s((r=e.annotations?.toCodecJson??e.annotations?.toCodec,T.Tn(r)?M.ES(e,[r(e.typeParameters.map(e=>F(M.O3(e))))]):M.ch));return{_tag:"Declaration",typeParameters:e.typeParameters.map(e=>s(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&&M.zm(n)?{contentSchema:s(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=>s(e)),...t};case"Arrays":return{_tag:e._tag,elements:e.elements.map(e=>{let t=M.S5(e);return{isOptional:M.dK(t),type:s(e),...X(t.context?.annotations)}}),rest:e.rest.map(e=>s(e)),checks:l(e.checks),...t};case"Objects":return{_tag:e._tag,propertySignatures:e.propertySignatures.map(e=>{let t=M.S5(e.type);return{name:e.name,type:s(e.type),isOptional:M.dK(t),isMutable:M.bV(t),...X(t.context?.annotations)}}),indexSignatures:e.indexSignatures.map(e=>({parameter:s(e.parameter),type:s(e.type)})),checks:l(e.checks),...t};case"Union":{let r=W(e.types);return{_tag:e._tag,types:r.map(e=>s(e)),mode:e.mode,...t}}case"Suspend":return{_tag:"Suspend",checks:[],thunk:s(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:s(t.propertyNames)}:t,...X(e.annotations)};return}case"FilterGroup":{let t=l(e.checks);if(O.CZ(t))return{_tag:"FilterGroup",checks:t,...X(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 ta(e){return ef(tc(e.ast),{schema:e})}let ts=q(function(e){switch(e._tag){case"Null":case"Boolean":case"Number":case"BigInt":case"Symbol":case"UniqueSymbol":return 0;default:return 1}}),to=new M.N_(new M.uS("null"),new er.IT(ee.pd(()=>null),ee.pd(()=>"null"))),tl=new M.N_(new M.gP([new M.uS("true"),new M.uS("false")],"anyOf"),new er.IT(ee.pd(e=>"true"===e),ee.Qf())),tc=M.oZ(e=>{if(M.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(T.Tn(n)){let r=n(M.HC(e)?e.typeParameters.map(e=>ef(t(M.O3(e)))):[]),i=t(r.to);return M.ES(e,i===r.to?[r]:[new M.N_(i,r.transformation)])}return r(e)}case"Null":return M.ES(e,[to]);case"Boolean":return M.ES(e,[tl]);case"Unknown":case"ObjectKeyword":return M.ES(e,[M.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,M.xw);case"Union":{let r=ts(e.types);if(r!==e.types)return new M.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,tc,e=>M.ES(e,[tu]));return t!==e&&M.dK(e)?M.nj(t):t}),tu=new M.N_(M.Vx,new er.IT(ee.le(),ee.pd(()=>void 0))),td=ef(M.LM);M.BF},9177(e,t,r){r.d(t,{DO:()=>Z,YA:()=>tc,D6:()=>j,bm:()=>en,LM:()=>td,E$:()=>ea,N_:()=>A,uS:()=>z,BF:()=>tf,XV:()=>e3,C3:()=>tu,V3:()=>ek,gP:()=>eb,fz:()=>eM,us:()=>eU,bz:()=>W,EJ:()=>eP,oZ:()=>eD,we:()=>Q,Nt:()=>tn,zM:()=>K,Lp:()=>tl,SL:()=>em,GL:()=>ez,vr:()=>M,UU:()=>eH,hu:()=>ef,S5:()=>function e(t){return t.encoding?e(t.encoding[t.encoding.length-1].to):t},zm:()=>w,tF:()=>O,Lm:()=>I,HC:()=>x,c$:()=>E,bV:()=>eG,Et:()=>S,RP:()=>C,dK:()=>eJ,Pt:()=>eO,Kg:()=>k,ZB:()=>tr,bk:()=>e9,IZ:()=>to,mi:()=>T,HN:()=>eE,D$:()=>e$,W:()=>eq,Zm:()=>B,ch:()=>D,ai:()=>V,ZG:()=>Y,Qr:()=>eB,nj:()=>eF,xw:()=>e2,g1:()=>eX,ES:()=>eT,Yj:()=>J,w3:()=>ed,HR:()=>H,O3:()=>eK,Ax:()=>eV,PV:()=>eh,Vx:()=>U,KC:()=>ep,L5:()=>q,tC:()=>th,rI:()=>F,Ez:()=>eY});var n=r(8927),i=r(8543),a=r(7720),s=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"),_=v("Never"),k=v("String"),S=v("Number"),I=v("Boolean"),E=v("Literal"),$=v("UniqueSymbol"),O=v("Arrays"),C=v("Objects"),T=v("Union");class A{to;transformation;constructor(e,t){this.to=e,this.transformation=t}}let M={};class N{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 R{[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 j extends R{_tag="Declaration";typeParameters;run;encodingChecks;constructor(e,t,r,n,i,a,s){super(r,n,i,a),this.typeParameters=e,this.run=t,this.encodingChecks=s}getParser(){let e=this.run(this.typeParameters);return(t,r)=>h.isNone(t)?a.lwU:a.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 j(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 D=new class extends R{_tag="Null";getParser(){return eQ(this,null)}getExpected(){return"null"}},L=new A(D,new b.IT(g.pd(()=>void 0),g.pd(()=>null))),U=new class extends R{_tag="Undefined";getParser(){return eQ(this,void 0)}toCodecJson(){return eT(this,[L])}getExpected(){return"undefined"}},F=new class extends R{_tag="Void";getParser(){var e;let t;return e=void 0,t=a.nGE(e),e=>"None"===e._tag?a.lwU:t}toCodecJson(){return eT(this,[L])}getExpected(){return"void"}},B=new class extends R{_tag="Never";getParser(){return eZ(this,m.Pd)}getExpected(){return"never"}},W=new class extends R{_tag="Any";getParser(){return eZ(this,m.t8)}getExpected(){return"any"}},q=new class extends R{_tag="Unknown";getParser(){return eZ(this,m.t8)}getExpected(){return"unknown"}},Y=new class extends R{_tag="ObjectKeyword";getParser(){return eZ(this,m.Fw)}getExpected(){return"object | array | function"}};class z extends R{_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?X(this):this}toCodecStringTree(){return"string"==typeof this.literal?this:X(this)}getExpected(){return"string"==typeof this.literal?JSON.stringify(this.literal):globalThis.String(this.literal)}}function X(e){let t=globalThis.String(e.literal);return eT(e,[new A(new z(t),new b.IT(g.pd(()=>e.literal),g.pd(()=>t)))])}let J=new class extends R{_tag="String";getParser(){return eZ(this,m.Kg)}matchPart(e,t){return e0(this,e,t)}getExpected(){return"string"}};function G(e,t){return e.some(e=>{switch(e._tag){case"Filter":return e.annotations?.meta?._tag===t;case"FilterGroup":return G(e.checks,t)}})}let V=new class extends R{_tag="Number";getParser(){return eZ(this,m.Et)}matchKey(e,t){return this._match(e6,e,t)}matchPart(e,t){return this._match(e8,e,t)}_match(e,t,r){return e.test(t)?e0(this,globalThis.Number(t),r):void 0}toCodecJson(){return this.checks&&(G(this.checks,"isFinite")||G(this.checks,"isInt"))?this:eT(this,[ex])}toCodecStringTree(){return this.checks&&(G(this.checks,"isFinite")||G(this.checks,"isInt"))?eT(this,[e7]):eT(this,[te])}getExpected(){return"number"}},K=new class extends R{_tag="Boolean";getParser(){return eZ(this,m.Lm)}getExpected(){return"boolean"}},H=new class extends R{_tag="Symbol";getParser(){return eZ(this,m.Bm)}matchKey(e,t){return e0(this,e,t)}toCodecStringTree(){return eT(this,[ts])}getExpected(){return"symbol"}},Q=new class extends R{_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 eT(this,[ti])}getExpected(){return"bigint"}};class Z extends R{_tag="Arrays";isMutable;elements;rest;encodingChecks;constructor(e,t,r,n,i,a,s,o){super(n,i,a,s),this.isMutable=e,this.elements=t,this.rest=r,this.encodingChecks=o;let l=t.findIndex(eJ);if(-1!==l&&(t.slice(l+1).some(e=>!eJ(e))||r.length>1))throw Error("A required element cannot follow an optional element. ts(1257)");if(r.length>1&&r.slice(1).some(eJ))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,...o]=n,l=o.length;function c(e,t){return t<i?r[t]:t>=e?o[t-e]:s}return a.vCS(function*(e,r){if("None"===e._tag)return e;let n=e.value;if(!Array.isArray(n))return yield*a.fJG(new y.eE(t,e));let s=n.length,o={ast:t,getParser:c,oinput:e,len:s,tailThreshold:Math.max(i,s-l),output:new globalThis.Array(s),issues:void 0,options:r},u=et(r?.concurrency),d=ee(o,n,{concurrency:u?.concurrency,end:0===t.rest.length?i:Math.max(s,i+l)});if(d&&(yield*d),0===t.rest.length&&s>i)for(let l=i;l<=s-1;l++){let i=new y.gm([l],new y.vF(t,n[l]));if("all"!==r.errors)return yield*a.fJG(new y.eC(t,e,[i]));o.issues?o.issues.push(i):o.issues=[i]}return o.issues?yield*a.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(eJ(t.ast))return;let r=new y.gm([n],new y.Mw(t.ast.context?.annotations));if("all"!==e.options.errors)return s.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 a=f.R(n.cause);if(void 0===a)return s.AT(i.Tj(n.cause,n=>new y.eC(t,e.oinput,[new y.gm([r],n)])));let o=new y.gm([r],a);if("all"!==e.options.errors)return s.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 ea{decode;encode;constructor(e,t){this.decode=e,this.encode=t}flip(){return new ea(this.encode,this.decode)}}function es(e){switch(e._tag){case"String":case"Number":case"Symbol":case"TemplateLiteral":return!0;case"Union":return e.types.every(es);default:return!1}}class eo{parameter;type;merge;constructor(e,t,r){if(!(es(e)&&es(eK(e))))throw Error(`Invalid index signature parameter ${e._tag}`);if(this.parameter=e,this.type=t,this.merge=r,eJ(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 R{_tag="Objects";propertySignatures;indexSignatures;encodingChecks;constructor(e,t,r,n,i,a,s){super(r,n,i,a),this.propertySignatures=e,this.indexSignatures=t,this.encodingChecks=s;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,s=[];for(let n of t.propertySignatures)r.push(n.name),i.add(n.name),s.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:a.vCS(function*(r,[n,s]){let o=e(e1(s.parameter))(h.some(n),r.options),l=(0,c.OY)(o)?o:yield*a.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(s.type)(d,r.options),p=(0,c.OY)(f)?f:yield*a.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(s.merge&&s.merge.decode&&Object.hasOwn(r.out,e)){let[n,i]=s.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 a.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*a.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*a.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,s,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=M){let n,i;return function t(a){switch(a._tag){case"String":case"TemplateLiteral":return(n??=Object.keys(e)).filter(e=>void 0!==a.matchPart(e,r));case"Number":return(n??=Object.keys(e)).filter(e=>void 0!==a.matchKey(e,r));case"Symbol":return(i??=Object.getOwnPropertySymbols(e)).filter(e=>void 0!==a.matchKey(e,r));case"Union":return[...new Set(a.types.flatMap(t))];default:return[]}}(e1(eK(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*a.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 a=eL(this.propertySignatures,t=>{let r=e(t.type);return r===t.type?t:new ei(t.name,r)}),s=eL(this.indexSignatures,n=>{let i=t(n.parameter),a=e(n.type),s=r?n.merge?.flip():n.merge;return i===n.parameter&&a===n.type&&s===n.merge?n:new eo(i,a,s)});return a===this.propertySignatures&&s===this.indexSignatures&&n===this.checks&&i===this.encodingChecks?this:new el(a,s,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(!eJ(t.type)){let r=new y.gm([t.name],new y.Mw(t.type.context?.annotations));return"all"!==e.options.errors?s.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(!eJ(t)){if(E(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)=>E(e)&&!eJ(e)?[{key:t,literal:e.literal}]:[]);case"Suspend":return em(e.thunk())}}let eg=new WeakMap;function ey(e){return t=>{let r=eK(t);return"Literal"===r._tag?r.literal===e:"UniqueSymbol"!==r._tag||r.symbol===e}}class eb extends R{_tag="Union";types;mode;encodingChecks;constructor(e,t,r,n,i,a,s){super(r,n,i,a),this.types=e,this.mode=t,this.encodingChecks=s}getParser(e){let t=this;return(r,n)=>{if("None"===r._tag)return a.PyW(r);let i=r.value,s=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=eK(e[r]);if(_(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),a=em(n);for(let e of(t.byType??={},i))(t.byType[e]??=[]).push(r);if(a.length>0)for(let{key:e,literal:n}of(t.bySentinel??=new Map,a)){let i=t.bySentinel.get(e);i||t.bySentinel.set(e,i=new Map);let a=i.get(n);a||i.set(n,a=[]),a.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,s,l?{...l,orderedStep:!0}:void 0);return c?a.qIB(c,e=>o.out?a.PyW(o.out):a.fJG(new y.W(t,i,o.issues??[]))):o.out?a.PyW(o.out):a.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=eK(t);switch(r._tag){case"Arrays":{let t=r.elements.filter(E);if(t.length>0)return`${e_(r.isMutable)}[ ${t.map(t=>e(t)+(t.context?.isOptional?"?":"")).join(", ")}, ... ]`;break}case"Objects":{let t=r.propertySignatures.filter(e=>E(e.type));if(t.length>0)return`{ ${t.map(t=>`${e_(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),s.fJ(new y.E8(e.ast,e.input,e.successes));if(e.out=r.value,e.successes.push(t),"anyOf"===e.ast.mode)return s.rI}}}),ew=new eb([new z("Infinity"),new z("-Infinity"),new z("NaN")],"anyOf"),ex=new A(new eb([V,ew],"anyOf"),new b.IT(g.wN(),g.pd(e=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function e_(e){return e?"":"readonly "}class ek extends R{_tag="Suspend";thunk;constructor(e,t,r,n,i){let a,s;if(void 0!==r)throw Error("Cannot add checks to Suspend");super(t,void 0,n,i),this.thunk=(s=!1,()=>(s||(a=e(),s=!0),a))}getParser(e){return e(this.thunk())}recur(e){return new ek(()=>e(this.thunk()),this.annotations,void 0,void 0,this.context)}getExpected(e){return e(this.thunk())}}class eS 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 eS(this.run,{...this.annotations,...e},this.aborted)}abort(){return new eS(this.run,this.annotations,!0)}and(e,t){return new eI([this,e],t)}}class eI extends p.Xs{_tag="FilterGroup";checks;annotations;constructor(e,t){super(),this.checks=e,this.annotations=t}annotate(e){return new eI(this.checks,{...this.annotations,...e})}and(e,t){return new eI([this,e],t)}}function eE(e,t,r=!1){return new eS((t,r,n)=>y.L8(t,r,e(t,r,n)),t,r)}function e$(e,t){return new eS(t=>e(t)?void 0:new y.h6(h.some(t)),t,!0)}function eO(e,t){let r=e.source;return eE(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 eT(e,t){return e.encoding===t?e:eC(e,e=>{e.encoding.value=t})}function eA(e,t){return e.context===t?e:eC(e,e=>{e.context.value=t})}function eM(e,t){if(e.checks){let r=e.checks[e.checks.length-1];return eN(e,n.BC(e.checks.slice(0,-1),r.annotate(t)))}return eC(e,e=>{e.annotations.value={...e.annotations.value,...t}})}function eN(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 eN(e,eu(e.checks,t))}function eR(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 A(i,r.transformation)):e}function ej(e){return t=>t.encoding?eT(t,eR(t.encoding,e)):t}function eD(e){return(0,l.Bj)(function t(r){return r.encoding?eT(r,eR(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 a=e[i],s=t(a);s!==a&&(r=!0),n[i]=s}return r?n:e}function eU(e,t){let r=e.context?new N(e.context.isOptional,e.context.isMutable,e.context.defaultValue,{...e.context.annotations,...t}):new N(!1,!1,void 0,t);return eA(e,r)}let eF=ej(eB);function eB(e){let t=e.context?!1===e.context.isOptional?new N(!0,e.context.isMutable,e.context.defaultValue,e.context.annotations):e.context:new N(!0,!1);return eF(eA(e,t))}let eW=ej(eq);function eq(e){let t=e.context?!1===e.context.isMutable?new N(e.context.isOptional,!0,e.context.defaultValue,e.context.annotations):e.context:new N(!1,!0);return eW(eA(e,t))}function eY(e,t){let r=[new A(q,new b.IT(g.IQ(t),g.le()))],n=e.context?new N(e.context.isOptional,e.context.isMutable,r,e.context.annotations):new N(!1,!1,r);return eA(e,n)}function ez(e,t,r){let n;return n=new A(e,r),eT(t,t.encoding?[...t.encoding,n]:[n])}function eX(e,t,r){let n,i,{literals:a,parameters:s}=(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(a.map(e=>new ei(e,t)),s.map(e=>new eo(e,t,r)))}function eJ(e){return e.context?.isOptional??!1}function eG(e){return e.context?.isMutable??!1}let eV=(0,l.Bj)(e=>{if(e.encoding)return eV(eT(e,void 0));let t=e.recur?.(eV)??e,r=t.encodingChecks;return r?eC(t,n=>{n.encodingChecks.value=void 0,t===e&&(n.checks.value=eu(t.checks,r))}):t}),eK=(0,l.Bj)(e=>eV(eH(e))),eH=(0,l.Bj)(e=>e.encoding?function(e,t){let r=t.length,n=t[r-1],i=[new A(eH(eT(e,void 0)),t[0].transformation.flip())];for(let e=1;e<r;e++)i.unshift(new A(eH(t[e-1].to),t[e].transformation.flip()));let a=eH(n.to);return a.encoding?eT(a,[...a.encoding,...i]):eT(a,i)}(e,e.encoding):e.flip?.(eH)??e.recur?.(eH)??e);function eQ(e,t){let r=a.nGE(t);return n=>"None"===n._tag?a.lwU:n.value===t?r:a.fJG(new y.eE(e,n))}function eZ(e,t){return r=>"None"===r._tag?a.lwU:t(r.value)?a.PyW(r):a.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=eD(e=>{switch(e._tag){default:return e;case"Number":return e.toCodecStringTree();case"Union":return e.recur(e1)}}),e2=eD(e=>{switch(e._tag){default:return e;case"Symbol":case"UniqueSymbol":return e.toCodecStringTree();case"Union":return e.recur(e2)}}),e5=eD(e=>{switch(e._tag){default:return e;case"Number":case"Literal":case"BigInt":return e.toCodecStringTree();case"Union":return e.recur(e5)}}),e3="[\\s\\S]*?",e8=new globalThis.RegExp(`^${en}$`),e6=new globalThis.RegExp(`(?:${en}|Infinity|-Infinity|NaN)`);function e9(e){return eO(e8,{expected:"a string representing a finite number",meta:{_tag:"isStringFinite",regExp:e8},...e})}let e4=eP(J,[e9()]),e7=new A(e4,b.ZK),te=new A(new eb([e4,ew],"anyOf"),b.ZK),tt=new globalThis.RegExp("^-?\\d+$");function tr(e){return eO(tt,{expected:"a string representing a bigint",meta:{_tag:"isStringBigInt",regExp:tt},...e})}let tn=eP(J,[tr({expected:"a string representing a bigint"})]),ti=new A(tn,b.R7),ta=new globalThis.RegExp("^Symbol\\((.*)\\)$"),ts=new A(eP(J,[to()]),new b.IT(g.pd(e=>globalThis.Symbol.for(ta.exec(e)[1])),g.K$(e=>void 0!==globalThis.Symbol.keyFor(e)?a.PyW(globalThis.String(e)):a.fJG(new y.cw(h.some(e),{message:"cannot serialize to string, Symbol is not registered"})))));function to(e){return eO(ta,{expected:"a string representing a symbol",meta:{_tag:"isStringSymbol",regExp:ta},...e})}function tl(e,t,r,n,i){for(let a=0;a<e.length;a++){let s=e[a];if("FilterGroup"===s._tag)tl(s.checks,t,r,n,i);else{let e=s.run(t,n,i);if(e&&(r.push(new y.dJ(t,s,e)),s.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 j([],()=>(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 a=i?t.every(e):Object.keys(t).every(r=>e(t[r]));return r.delete(t),a&&n.add(t),a}(e))?a.PyW(e):a.fJG(new y.eE(t,h.some(e)))},{typeConstructor:{_tag:"effect/Json"},generation:{runtime:"Schema.Json",Type:"Schema.Json"},expected:"JSON value",toCodecJson:()=>new A(q,b.le()),toArbitrary:()=>e=>e.jsonValue()}),tf=eM(td,{typeConstructor:{_tag:"effect/MutableJson"},generation:{runtime:"Schema.MutableJson",Type:"Schema.MutableJson"}}),th=new A(new j([],()=>(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))?a.PyW(e):a.fJG(new y.eE(t,h.some(e)))},{expected:"StringTree"}),b.le())},6310(e,t,r){var n=r(4705),i=r(7720),a=r(8983),s=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(s.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=s.map(e),new d(e=>i.PyW(t(e)))}function g(e){var t;return t=(t,r)=>e(t,r).pipe(i.jkJ(s.some)),new d((e,r)=>s.isNone(e)?i.lwU:t(e.value,r))}function y(){return new d(()=>i.lwU)}function b(e){return new d(t=>{let r=s.filter(t,l.EA);return s.isSome(r)?i.PyW(r):i.jkJ(e,s.some)})}function v(){return m(globalThis.String)}function w(){return m(globalThis.Number)}function x(){return m(globalThis.BigInt)}function _(){return m(e=>new globalThis.Date(e))}function k(){return m(a.WG)}function S(){return m(a.DX)}function I(){return m(a.mU)}function E(){return g(e=>i.Z9x(i.yUA(a.y4(e)),t=>new u.h6(s.some(e),{message:t.message})))}function $(){return g(e=>c.YW(a.$T(e),{onFailure:t=>i.fJG(new u.h6(s.some(e),{message:t.message})),onSuccess:i.PyW}))}function O(){return g(e=>c.YW(a.$X(e),{onFailure:t=>i.fJG(new u.h6(s.some(e),{message:t.message})),onSuccess:i.PyW}))}function C(){return g(e=>c.YW(a.UD(e),{onFailure:t=>i.fJG(new u.h6(s.some(e),{message:t.message})),onSuccess:i.PyW}))}function T(){return g(e=>c.YW(a.EF(e),{onFailure:t=>i.fJG(new u.h6(s.some(e),{message:t.message})),onSuccess:i.PyW}))}function A(){return g(e=>c.YW(a.xQ(e),{onFailure:t=>i.fJG(new u.h6(s.some(e),{message:t.message})),onSuccess:i.PyW}))}function M(){return m(encodeURIComponent)}function N(){return g(e=>{try{return i.PyW(globalThis.decodeURIComponent(e))}catch(t){return i.fJG(new u.h6(s.some(e),{message:t instanceof URIError?t.message:"Invalid URI component"}))}})}function P(){return g(e=>s.match(n.L8(e),{onNone:()=>i.fJG(new u.h6(s.some(e),{message:"Invalid DateTime input"})),onSome:e=>i.PyW(n.yT(e))}))}l.Kg,r.d(t,{$T:()=>$,$X:()=>O,A0:()=>P,DX:()=>S,EF:()=>T,IQ:()=>b,K$:()=>g,Qf:()=>v,Qw:()=>x,UD:()=>C,WG:()=>k,_p:()=>M,cJ:()=>y,le:()=>p,mF:()=>N,mU:()=>I,n9:()=>_,pd:()=>m,uB:()=>d,wN:()=>w,xQ:()=>A,y4:()=>E})},6030(e,t,r){var n=r(8927),i=r(6470),a=r(4888),s=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 _(e,t){if(c(t))return t;if("string"==typeof t)return new b(s.some(e),{message:t});let r="string"==typeof t.issue?new b(s.some(e),{message:t.issue}):t.issue;return new h(t.path,r)}function k(e,t,r){if(Array.isArray(r))return n.ET(r)?1===r.length?_(e,r[0]):new g(t,s.some(e),n.Tj(r,t=>_(e,t))):void 0;if(void 0!==r)return"boolean"==typeof r?r?void 0:new b(s.some(e)):_(e,r)}let S=e=>{let t=A(e);if(void 0!==t)return t;switch(e._tag){case"InvalidType":return $(a.bo(e.ast),N(e.actual));case"InvalidValue":return`Invalid data ${N(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)}`}},I=e=>A(e.issue)??A(e);function E(e){return t=>({issues:O(t,[],e?.leafHook??S,e?.checkHook??I)})}function $(e,t){return`Expected ${e}, got ${t}`}function O(e,t,r,n){switch(e._tag){case"Filter":{let a=n(e);if(void 0!==a)return[{path:t,message:a}];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 O(e.issue,t,r,n)}case"Encoding":return O(e.issue,t,r,n);case"Pointer":return O(e.issue,[...t,...e.path],r,n);case"Composite":return e.issues.flatMap(e=>O(e,t,r,n));case"AnyOf":{let s=A(e);if(0===e.issues.length){if(void 0!==s)return[{path:t,message:s}];return[{path:t,message:$(a.bo(e.ast),(0,i.GP)(e.actual))}]}return e.issues.flatMap(e=>O(e,t,r,n))}default:return[{path:t,message:r(e)}]}}let C=e=>O(e,[],S,I).map(T).join("\n");function T(e){let t=e.message;if(e.path&&e.path.length>0){let r=(0,i.jV)(e.path);t+=`
257
+ at ${r}`}return t}function A(e){switch(e._tag){case"InvalidType":case"OneOf":case"Composite":case"AnyOf":return M(e.ast.annotations);case"InvalidValue":case"Forbidden":return M(e.annotations);case"MissingKey":return M(e.annotations,"messageMissingKey");case"UnexpectedKey":return M(e.ast.annotations,"messageUnexpectedKey");case"Filter":return M(e.filter.annotations);case"Encoding":return A(e.issue)}}function M(e,t="message"){let r=e?.[t];if("string"==typeof r)return r}function N(e){return s.isNone(e)?"no value provided":(0,i.GP)(e.value)}r.d(t,{E8:()=>x,ID:()=>E,L8:()=>k,Mw:()=>p,W:()=>w,Wi:()=>f,cw:()=>v,dJ:()=>d,eC:()=>g,eE:()=>y,gh:()=>c,gm:()=>h,h6:()=>b,vF:()=>m},{vp:S})},4858(e,t,r){var n=r(8927),i=r(8543),a=r(7720),s=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=I(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=a.lKS(t(e,r));return s.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=a.lKS(t(e,r));if(s.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=E(I(f.Ax(t))),e=>{let t=r(e,f.vr);return!!s.oJ(t)||(l.q(t.cause,"Type guard adapter can only return false for schema issues"),!1)}}function v(e,t){let r=E(I(f.Ax(e.ast)))(t,f.vr);if(s.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=I(e.ast);return void 0===t?r:(e,n)=>r(e,S(t,n))}function x(e,t){return $(w(e,t))}function _(e,t){let r;return r=E(w(e,t)),(e,t)=>{let n=r(e,t);return s.oJ(n)?d.Py(n.value):d.fJ(l.q(n.cause,"Result adapter can only return schema issues"))}}function k(e,t){let r;return $((r=I(f.UU(e.ast)),void 0===t?r:(e,n)=>r(e,S(t,n))))}let S=(e,t)=>void 0===t?e:{...e,...t};function I(e){let t=C(e);return(e,r)=>a.Ab9(t(c.some(e),r??f.vr),e=>"None"===e._tag?a.fJG(new h.h6(e)):a.PyW(e.value))}function E(e){return(t,r)=>a.lKS(e(t,r))}function $(e){let t=E(e);return(e,r)=>{let n=t(e,r);return s.oJ(n)?c.some(n.value):(l.q(n.cause,"Option adapter can only return none for schema issues"),c.none())}}function O(e,t){return a.Tyx(e,e=>a.pVV(()=>i.Tj(e,t)))}let C=(0,o.Bj)(e=>{let t,r=e.checks,i=e.encoding,s=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=s-1;e>=0;e--){let t=i[e],r=C(t.to);if(m=m?a.Ab9(m,e=>r(e,p)):r(u,p),"Transformation"===t.transformation._tag){let e=t.transformation.decode;m=a.Ab9(m,t=>e.run(t,p))}else m=t.transformation.decode(m,p)}m=O(m,t=>new h.Wi(e,u,t))}t??=e.getParser(C);let g=i=>{let s=t(i,p);return o&&!p?.disableChecks&&(s=a.Ab9(s,t=>{if(c.isSome(i)&&c.isSome(t)){let t=[];if(f.Lp(o,i.value,t,e,p),n.CZ(t))return a.fJG(new h.eC(e,i,t))}return a.PyW(t)})),r&&!p?.disableChecks&&(p?.errors==="all"&&d&&d.length>0&&c.isSome(i)&&(s=O(s,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})),s=a.Ab9(s,t=>{if(c.isSome(t)){let i=t.value,s=[];if(f.Lp(r,i,s,e,p),n.CZ(s))return a.fJG(new h.eC(e,t,s))}return a.PyW(t)})),s};return m?a.Ab9(m,g):g(u)}});r.d(t,{IQ:()=>k,L8:()=>y,YY:()=>g,_R:()=>w,is:()=>b,kv:()=>v,o:()=>m,q$:()=>_,y9:()=>x},{GP:k,mR:x})},5348(e,t,r){var n=r(631),i=r(4705),a=r(2302),s=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())),_=p({decode:e=>l.match(a.lX(e),{onNone:()=>s.fJG(new d.h6(l.some(e),{message:`Invalid Duration string: ${e}`})),onSome:s.PyW}),encode:e=>s.PyW(globalThis.String(e))}),k=p({decode:e=>s.PyW(a.cF(e)),encode:e=>l.match(a.tb(e),{onNone:()=>s.fJG(new d.h6(l.some(e),{message:`Unable to encode ${e} into a bigint`})),onSome:e=>s.PyW(e)})}),S=m({decode:e=>a.ne(e),encode:e=>a.kE(e)}),I=e=>{let t;return c.Gv(e)&&"string"==typeof e.message?(t=Object.hasOwn(e,"cause")?Error(e.message,{cause:I(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},E=p({decode:e=>URL.canParse(e)?s.PyW(new URL(e)):s.fJG(new d.h6(l.some(e),{message:`Invalid URL string: ${e}`})),encode:e=>s.PyW(e.href)}),$=p({decode:e=>{let t=n.sH(e);return l.isNone(t)?s.fJG(new d.h6(l.some(e),{message:`Invalid BigDecimal string: ${e}`})):s.PyW(t.value)},encode:e=>s.PyW(n.GP(e))}),O=new h(u.y4(),u.WG()),C=new h(u.$T(),u.WG()),T=new h(u.UD(),u.DX()),A=new h(u.xQ(),u.mU()),M=new h(u.mF(),u._p()),N=m({decode:e=>i.ko(e),encode:e=>e.offset}),P=p({decode:e=>l.match(i.y3(e),{onNone:()=>s.fJG(new d.h6(l.some(e),{message:`Invalid IANA time zone: ${e}`})),onSome:s.PyW}),encode:e=>s.PyW(e.id)}),R=p({decode:e=>l.match(i.ez(e),{onNone:()=>s.fJG(new d.h6(l.some(e),{message:`Invalid time zone: ${e}`})),onSome:s.PyW}),encode:e=>s.PyW(i.xV(e))}),j=p({decode:e=>l.match(i.L8(e),{onNone:()=>s.fJG(new d.h6(l.some(e),{message:`Invalid UTC DateTime string: ${e}`})),onSome:e=>s.PyW(i.yT(e))}),encode:e=>s.PyW(i.dv(e))}),D=p({decode:e=>l.match(i.MO(e),{onNone:()=>s.fJG(new d.h6(l.some(e),{message:`Invalid Zoned DateTime string: ${e}`})),onSome:s.PyW}),encode:e=>s.PyW(i.Rd(e))});r.d(t,{IT:()=>h,K$:()=>p,le:()=>y,pd:()=>m},{Ct:C,EJ:_,HO:x,I9:N,L8:e=>c.i5(e,f)?e:new h(e.decode,e.encode),LL:T,Nh:j,PE:S,Pp:M,R7:v,U0:O,XU:R,Y5:A,YZ:w,ZK:b,d9:D,dG:$,m8:k,nY:E,sm:e=>{let t,r;return m({decode:I,encode:(t=new WeakSet,r=n=>{if(c.bJ(n)){var i;let a;if(t.has(n))return"[Circular]";t.add(n);let s=(i=r,a={name:n.name,message:"string"==typeof n.message?n.message:""},e?.includeStack&&"string"==typeof n.stack&&(a.stack=n.stack),e?.excludeCause||void 0===n.cause||(a.cause=i(n.cause)),a);return t.delete(n),s}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 a=n.d97,s=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:s,HG:i,LZ:a,U9:l,VN:u,a6:o})},755(e,t,r){let n,i;var a=r(8619),s=r(4650),o=r(3833);let l="effect/Tracer/ParentSpan";class c extends a.kl()(l){}let u=a.Or("effect/Tracer/DisablePropagation",{defaultValue:s.f4}),d=a.Or("effect/Tracer/CurrentTraceLevel",{defaultValue:()=>"Info"}),f=a.Or("effect/Tracer/MinimumTraceLevel",{defaultValue:()=>"All"}),h="effect/Tracer",p=a.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 a{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 a(this.self)}}let s=(i={[n="~effect/Utils/internal"]:e=>e()},i[n](()=>Error().stack)?.includes(n)===!0?i[n]:({[n]:e=>e()})[n]);r.d(t,{B:()=>a},{s:s})},8433(e,t,r){let n;var i=r(8036),a=r(6470),s=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:s.D_,_E:s.D_,_R:s.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"),_={pipe(){return(0,c.tT)(this,arguments)},toJSON(){return{...this}},toString(){return(0,a.GP)(this.toJSON(),{ignoreToString:!0,space:2})},[l.FX](){return this.toJSON()}},k={[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}},S={[f]:p,..._,[Symbol.iterator](){return new d.B(this)},toJSON(){return{_id:"Effect",op:this[m],...g in this?{args:this[g]}:void 0}}},I=e=>(0,u.i5)(e,h),E="~effect/Cause",$="~effect/Cause/Reason",O=e=>(0,u.i5)(e,E);class C{[E];reasons;constructor(e){this[E]=E,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,a.GP)(this.reasons)})`}[l.FX](){return this.toJSON()}[i.HR](e){return O(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 T=new WeakMap;class A{[$];annotations;_tag;constructor(e,t,r){if(this[$]=$,this._tag=e,t!==M&&"object"==typeof r&&null!==r&&t.size>0){let e=T.get(r);e&&(t=new Map([...e,...t])),T.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,a.GP)(this)}[l.FX](){return this.toString()}}let M=new Map;class N extends A{error;constructor(e,t=M){super("Fail",t,e),this.error=e}toString(){return`Fail(${(0,a.GP)(this.error)})`}toJSON(){return{_tag:"Fail",error:this.error}}[i.HR](e){return U(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([]),R=e=>new C([new N(e)]);class j extends A{defect;constructor(e,t=M){super("Die",t,e),this.defect=e}toString(){return`Die(${(0,a.GP)(this.defect)})`}toJSON(){return{_tag:"Die",defect:this.defect}}[i.HR](e){return F(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 D=e=>new C([new j(e)]),L=(0,s.XY)(e=>O(e[0]),(e,t,r)=>0===t.mapUnsafe.size?e:new C(e.reasons.map(e=>e.annotate(t,r)))),U=e=>"Fail"===e._tag,F=e=>"Die"===e._tag;function B(e){return V("Effect.evaluate: Not implemented")}let W=e=>({...S,[m]:e.op,[y]:e[y]??B,[b]:e[b],[v]:e[v],[w]:e[w]}),q=e=>{let t=W(e);return function(){let r=Object.create(t);return r[g]=!1===e.single?arguments:arguments[0],r}},Y=e=>{let t={...W(e),[h]:h,_tag:e.op,get[e.prop](){return this[g]},toString(){return`${e.op}(${(0,a.GP)(this[g])})`},toJSON(){return{_id:"Exit",_tag:e.op,[e.prop]:this[g]}},[i.HR](e){return I(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}},z=Y({op:"Success",prop:"value",[y](e){let t=e.getCont(b);return t?t[b](this[g],e,this):e.yieldWith(this)}}),X={key:"effect/Cause/StackTrace"},J=Y({op:"Failure",prop:"cause",[y](e){let t=this[g],r=!1;e.currentStackFrame&&(t=L(t,{mapUnsafe:new Map([[X.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:J(t))}}),G=e=>J(R(e)),V=e=>J(D(e)),K=q({op:"WithFiber",[y](e){return this[g](e)}}),H=function(){class e extends globalThis.Error{}let t=W({op:"YieldableError",[y](){return G(this)}});return delete t.toString,Object.assign(e.prototype,t),e}(),Q=(n=Symbol.for("effect/Data/Error/plainArgs"),class extends H{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},ea=G(en);r.d(t,{ET:()=>A,Xm:()=>et,dM:()=>N,s0:()=>C},{$D:Q,$L:e=>(0,u.i5)(e,er),$n:f,Aj:O,B4:$,DH:P,Eh:L,GN:x,IH:h,In:k,Iu:D,OE:R,PW:e=>(0,u.i5)(e,ee),PX:E,QJ:{key:"effect/Cause/InterruptorStackTrace"},R6:K,RS:ei,Rk:G,Sc:v,Uf:q,V2:V,Vw:e=>void 0===e?ea:G(ei(e)),Wg:e=>(0,u.i5)(e,$),Xb:F,_3:y,a2:g,b5:e=>new C(e),b9:I,cb:J,dO:M,ee:b,fU:_,ik:e=>"Interrupt"===e._tag,lC:U,qB:ee,q_:er,rN:Z,u4:w,xt:z,yj:W,yw:e=>(0,u.i5)(e,f),z8:X})},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,a;r.d(t,{RD4:()=>i2,cOF:()=>i0,a1U:()=>ij,z4N:()=>i6,d$_:()=>i7,Do:()=>nJ,Aub:()=>iZ,F7W:()=>iH,qwd:()=>iK,t8c:()=>iG,LkF:()=>i9,olX:()=>ae,obm:()=>rG,kWD:()=>rJ,MUS:()=>iJ,DQo:()=>iz,Bk6:()=>i8,Kkt:()=>i5,dsN:()=>n$,N24:()=>nm,Q56:()=>nn,jGc:()=>np,U9h:()=>ni,Q7R:()=>nO,hgn:()=>tr,ww9:()=>iN,gsV:()=>at,Muk:()=>iM,as:()=>e7,Xx$:()=>te,NLW:()=>ti,PCg:()=>n0,oIE:()=>nV,JrD:()=>nG,PO3:()=>nb,CJw:()=>ng,Rgn:()=>ny,E2r:()=>eQ,Tyx:()=>rt,rNk:()=>ri,sJf:()=>rn,Fig:()=>ro,UVN:()=>tw,osR:()=>rm,XWm:()=>rp,U9Y:()=>rs,AXC:()=>rb,zt4:()=>rv,KuX:()=>rg,loE:()=>ry,h_t:()=>ra,On5:()=>K,h2c:()=>H,Bou:()=>z,nIy:()=>R,h74:()=>X,O$X:()=>Q,GyP:()=>el,RJ6:()=>ee,ReC:()=>Z,RKA:()=>iB,_OA:()=>tV,sxi:()=>tH,Wj8:()=>iR,_32:()=>iP,Rud:()=>iq,s0X:()=>iY,cbG:()=>rW,F_Q:()=>eB,OY:()=>th,yeE:()=>no,u4Y:()=>rE,NS5:()=>rL,Hox:()=>tF,ely:()=>tB,yJo:()=>t$,HIt:()=>tE,K$2:()=>tk,GUt:()=>tS,jCT:()=>tC,_OD:()=>tO,lgw:()=>tY,Sv3:()=>tq,kMI:()=>tW,YDM:()=>tA,_mh:()=>tM,lNM:()=>tT,_sz:()=>tx,VE1:()=>tI,CoE:()=>t_,v9O:()=>tP,EkE:()=>tj,zPu:()=>tR,Wtn:()=>tU,x5l:()=>tN,il9:()=>tL,fJG:()=>eC,ATB:()=>eO,pVV:()=>eF,gOk:()=>eW,pEE:()=>eG,zFM:()=>ev,C6p:()=>ew,ABT:()=>eV,mKq:()=>ek,DKo:()=>eI,$MQ:()=>eE,eGS:()=>eS,D7p:()=>ex,INJ:()=>e_,vTQ:()=>n3,pbD:()=>nY,x1Q:()=>nz,E8K:()=>nX,VtY:()=>nW,ahH:()=>nq,Pm0:()=>nB,W$I:()=>t6,BbX:()=>W,k7S:()=>B,khU:()=>L,L$u:()=>U,QE5:()=>D,i8i:()=>nA,kAe:()=>nN,tU5:()=>Y,Dd:()=>rI,qIB:()=>tu,Ab9:()=>tp,Bqz:()=>tm,UUz:()=>tt,fn:()=>e3,D9k:()=>e1,vCS:()=>e6,jJl:()=>nj,i4r:()=>re,zhn:()=>nH,yxg:()=>nZ,ar0:()=>n1,x6Z:()=>n2,bJ:()=>eP,sVm:()=>eM,yUA:()=>eN,JkU:()=>e0,Iku:()=>ep,gpn:()=>F,myX:()=>j,prj:()=>q,nn5:()=>G,XeO:()=>r$,GrF:()=>rO,GaK:()=>nv,Inz:()=>nS,eMl:()=>nE,Rft:()=>i1,ASO:()=>iQ,N6O:()=>rF,_y:()=>iV,OPA:()=>i4,oJd:()=>rB,c8t:()=>iX,PnV:()=>i3,h$X:()=>nU,uVU:()=>nK,A_r:()=>iE,lIX:()=>aa,ORc:()=>P,Fbb:()=>id,zzk:()=>iu,Z98:()=>ix,Rd$:()=>i_,TjK:()=>tg,UcN:()=>r_,q7Y:()=>tv,jkJ:()=>ty,xm_:()=>rx,Z9x:()=>tb,YWq:()=>rR,D$$:()=>rN,NZb:()=>rD,khu:()=>rA,wR5:()=>tf,G$Q:()=>rj,tvg:()=>rP,ZmZ:()=>eZ,S5A:()=>nu,iKM:()=>nf,BeE:()=>nd,cfM:()=>ns,uRq:()=>nc,fGe:()=>nl,r7h:()=>na,nAr:()=>nh,uKv:()=>rC,QgK:()=>rk,DM4:()=>rS,jBG:()=>nC,ivC:()=>ez,PpN:()=>tZ,AAo:()=>r7,PfK:()=>t0,c7E:()=>t2,O4F:()=>tl,Vdx:()=>ts,FfP:()=>to,KT6:()=>tc,tQ6:()=>V,aAq:()=>t4,Xrv:()=>t7,Ket:()=>rT,bPG:()=>n9,lSz:()=>n6,MY7:()=>n8,eJC:()=>n5,pR5:()=>it,NpQ:()=>n7,jqV:()=>n4,v2Q:()=>ie,HZF:()=>is,lKS:()=>ii,rfH:()=>ir,lE:()=>ia,_Sg:()=>ta,z8E:()=>r4,iLB:()=>r2,Uio:()=>r1,vDJ:()=>rK,fou:()=>rH,Z$R:()=>rZ,pSt:()=>r0,RWE:()=>r9,d97:()=>r8,DLK:()=>rV,mdu:()=>nt,P1j:()=>ne,Pxi:()=>nr,euC:()=>tz,Nav:()=>tX,oao:()=>tQ,yy4:()=>iW,Fu6:()=>iS,WbR:()=>iI,PyW:()=>e$,lwU:()=>eL,nGE:()=>eD,DYE:()=>eA,OH5:()=>eT,Mim:()=>tn,dGm:()=>rl,bKC:()=>ru,cA6:()=>rc,nAi:()=>rh,sFT:()=>rd,k$L:()=>rf,ayu:()=>rX,wRz:()=>rY,D52:()=>rz,mgX:()=>rq,kJM:()=>ih,pkL:()=>eU,SvU:()=>eY,$mh:()=>eX,Vxk:()=>al,rfi:()=>nw,FcF:()=>nI,scW:()=>rw,r_d:()=>tJ,bUZ:()=>tG,gvr:()=>iO,tfT:()=>nT,rIH:()=>eq,z7s:()=>t9,iMI:()=>nR,KyM:()=>t5,$$g:()=>ac,hq:()=>iT,fRP:()=>iA,zr8:()=>ik,_o1:()=>ip,nDN:()=>im,MaT:()=>ig,m9E:()=>ej,KN3:()=>eR,yU6:()=>t3,OYO:()=>t8});var s=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),_=r(8469),k=r(755),S=r(3537),I=r(8433),E=r(2849),$=r(9354),O=r(8344),C=r(3628);let T=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:M(()=>r.stack)}},A=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()}},M=A(3);class N extends I.ET{fiberId;constructor(e,t=I.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,I.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 N(e),R=e=>new I.s0([new N(e)]),j=e=>e.reasons.some(I.lC),D=e=>{let t=e.reasons.find(I.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)},U=u.zL(L),F=e=>e.reasons.some(I.Xb),B=e=>{let t=e.reasons.find(I.Xb);return t?x.Py(t):x.fJ(e)},W=e=>{let t=e.reasons.find(I.Xb);return t?x.Py(t.defect):x.fJ(e)},q=e=>e.reasons.some(I.ik),Y=e=>{let t=e.reasons.find(I.ik);return t?x.Py(t):x.fJ(e)},z=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)},X=e=>{let t=z(e);return x.N6(t)?J:t.success},J=new Set,G=e=>e.reasons.length>0&&e.reasons.every(I.ik),V=e=>o.LZ(e.annotations),K=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)},H=(0,f.XY)(2,(e,t)=>{if(0===e.reasons.length)return t;if(0===t.reasons.length)return e;let r=new I.s0(s.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,I.lC)(e)?(r=!0,new I.dM(t(e.error))):e);return r?(0,I.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=es(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?ea(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"),a=[n];for(let e=1;e<i.length&&!/(?:Generator\.next|~effect\/Effect)/.test(i[e]);e++)a.push(i[e]);return r?ea(a.join("\n"),r):a.join("\n")},ea=(e,t)=>{let r=t?.get(I.z8.key);return r&&(e=`${e}
258
+ ${eo(r)}`),e},es=(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(I.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} {
227
259
  ${eu(e.cause," ")}
228
260
  }`: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+=`
229
261
  ${t}${r[e]}`;return e.cause&&(n+=` {
230
262
  ${eu(e.cause,`${t} `)}
231
- ${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=R(e);this.currentStackFrame&&(r=(0,E.Eh)(r,o.L8(E.z8,this.currentStackFrame))),t&&(r=(0,E.Eh)(r,t)),this._interruptedCause=this._interruptedCause?H(this._interruptedCause,r):r,this.interruptible&&this.evaluate(eO(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===E.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(ej,()=>e)}if(n=this.currentTracerContext?this.currentTracerContext(n,this):n[E._3](this),i!==this.currentLoopCount)return E.GN;if(n===E.GN){let e=this._yielded;if(E.IH in e)return this._yielded=void 0,e;return E.GN}}}catch(e){if(!(0,v.i5)(n,E._3))return(0,E.V2)(`Fiber.runLoop: Not a valid effect: ${String(n)}`);return this.runLoop((0,E.V2)(e))}finally{globalThis[w.fL]=t}}getCont(e){for(;;){let t=this._stack.pop();if(!t)return;let r=t[E.u4]&&t[E.u4](this);if(r)return r[e]=r,r;if(t[e])return t}}yieldWith(e){return this._yielded=e,E.GN}children(){return this._children??=new Set}pipe(){return(0,b.tT)(this,arguments)}setContext(e){this.context=e;let t=this.getRef(x._F);t!==this.currentScheduler&&(this.currentScheduler=t,this._dispatcher=void 0),this.currentSpan=e.mapUnsafe.get(k.WG),this.currentLogLevel=this.getRef(O.Gl),this.minimumLogLevel=this.getRef(O.zQ),this.currentStackFrame=e.mapUnsafe.get(O.vA.key),this.maxOpsBeforeYield=this.getRef(x.Zm),this.currentPreventYield=this.getRef(x.hf),this.runtimeMetrics=e.mapUnsafe.get($.F);let r=e.mapUnsafe.get(k.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(E.z8.key,e.currentStackFrame),o.LZ(t)},eb=e=>{if(void 0!==e._children&&0!==e._children.size)return eE(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 a=n.next();for(;!a.done;){if(a.value._exit){i.push(a.value._exit),a=n.next();continue}r=a.value.addObserver(t=>{i.push(t),e()});return}t(e$(i))}(),eA(()=>r?.())}),e_=e=>e._exit?e._exit:eQ(t=>e._exit?t(e._exit):eA(e.addObserver(t))),ex=e=>eQ(t=>{let r=Array.from(e);if(0===r.length)return t(e$(s.Ie()));let n=Array(r.length),i=s.Ie(),a=0,o=!1;for(let e=0;e<r.length&&!o;e++)i.push(r[e].addObserver(s=>{if(a++,"Failure"===s._tag)return o=!0,i.forEach(e=>e()),t(s);n[e]=s.value,a===r.length&&t(e$(n))}))}),ek=e=>(0,E.R6)(t=>eS(e,t.id)),eS=(0,f.XY)(e=>(0,v.i5)(e[0],ed),(e,t,r)=>(0,E.R6)(n=>{let i=ey(n);return i=i&&r?o.h1(i,r):i??r,e.interruptUnsafe(t,i),ti(ev(e))})),eE=e=>(0,E.R6)(t=>{let r=ey(t),n=s.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,E.R6)(r=>{let n=ey(r),i=s.Ie();for(let r of e)r.interruptUnsafe(t,n),i.push(r);return ti(ew(i))})),e$=E.xt,eO=E.cb,eT=E.Rk,eA=(0,E.Uf)({op:"Sync",[E._3](e){let t=this[E.a2](),r=e.getCont(E.ee);return r?r[E.ee](t,e):e.yieldWith((0,E.xt)(t))}}),eC=(0,E.Uf)({op:"Suspend",[E._3](e){return this[E.a2]()}}),eN=(0,f.XY)(e=>e.length>=2||g.isOption(e[0]),(e,t)=>g.isNone(e)?eT(t?t():new E.Xm("Effect.fromOption: Option.none")):e$(e.value)),eM=_.YW({onFailure:eT,onSuccess:e$}),eP=e=>null==e?eT(new E.Xm):e$(e),eR=(0,E.Uf)({op:"Yield",[E._3](e){let t=!1;return e.currentDispatcher.scheduleTask(()=>{t||e.evaluate(tM)},this[E.a2]??0),e.yieldWith(()=>{t=!0})}}),ej=eR(0),eD=e=>e$(g.some(e)),eL=e$(g.none()),eU=e=>g.isNone(e)?eL:tg(e.value,g.some),eF=e=>eC(()=>eO((0,S.s)(e))),eB=e=>(0,E.V2)(e),eY=e=>eC(()=>eT((0,S.s)(e))),eW=e$(void 0),eq=e=>{let t="function"==typeof e?e:e.try,r="function"==typeof e?e=>new i8(e,"An error occurred in Effect.try"):e.catch;return eC(()=>{try{return e$((0,S.s)(t))}catch(e){return eT((0,S.s)(()=>r(e)))}})},eX=e=>eK(function(t,r){(0,S.s)(()=>e(r)).then(e=>t(e$(e)),e=>t(eB(e)))},0!==e.length),eJ=e=>{let t="function"==typeof e?e:e.try,r="function"==typeof e?e=>new i8(e,"An error occurred in Effect.tryPromise"):e.catch;return eK(function(e,n){let i=t=>{try{e(eT((0,S.s)(()=>r(t))))}catch(t){e(eB(t))}};try{(0,S.s)(()=>t(n)).then(t=>e(e$(t)),i)}catch(e){i(e)}},0!==t.length)},ez=e=>(0,E.R6)(t=>e(t.id)),eG=(0,E.R6)(e$),eV=ez(e$),eK=(0,E.Uf)({op:"Async",single:!1,[E._3](e){let t=(0,S.s)(()=>this[E.a2][0].bind(e.currentScheduler)),r=!1,n=!1,i=this[E.a2][1]?new AbortController:void 0,a=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===a||e._stack.push(eH(()=>(r=!0,i?.abort(),a??tM))),E.GN)}}),eH=(0,E.Uf)({op:"AsyncFinalizer",[E.u4](e){e.interruptible&&(e.interruptible=!1,e._stack.push(nx))},[E.Sc](e,t){return W(e)?tu(this[E.a2](),()=>eO(e)):eO(e)}}),eQ=e=>eK(e,e.length>=2),eZ=eQ(f.Yi),e0=(...e)=>eC(()=>e4(1===e.length?e[0]():e[1].call(e[0].self))),e1=(e,...t)=>{let r=0===t.length?function(){return eC(()=>e4(e.apply(this,arguments)))}:function(){let r=eC(()=>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}),e5=C(2),e3=function(){let e="string"==typeof arguments[0],t=e?arguments[0]:"Effect.fn",r=e?arguments[1]:void 0,n=(0,T.jt)();(0,T.ft)(2);let i=new globalThis.Error;return((0,T.ft)(n),e)?(n,...a)=>e8(t,n,i,a,e,r):e8(t,arguments[0],i,Array.prototype.slice.call(arguments,1),e,r)},e8=(e,t,r,n,i,a)=>{let s="function"==typeof t?t:n.pop().bind(t.self);return e2(s.length,function(...t){let o=eC(()=>{let e=s.apply(this,arguments);return(0,E.yw)(e)?e:e4(e)});for(let e=0;e<n.length;e++)o=n[e](o,...t);if(!(0,E.yw)(o))return o;let l=(0,T.jt)();(0,T.ft)(2);let c=new globalThis.Error;return(0,T.ft)(l),tG(i?iO(e,a,e=>iT(o,e)):o,O.vA,t=>({name:e,stack:e5(()=>c.stack),parent:{name:`${e} (definition)`,stack:e5(()=>r.stack),parent:t}}))})},e6=(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 eC(()=>t?(t=!1,tu(n.value,e=>e4(r,e))):eC(()=>e4(e())))}}}catch(e){return eB(e)}},e4=(0,E.Uf)({op:"Iterator",single:!1,[E.ee](e,t){let r=this[E.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}},[E._3](e){return this[E.ee](this[E.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:eT}),tr=(0,f.XY)(2,(e,t)=>tu(e,e=>(0,E.yw)(t)?t:(0,S.s)(()=>t(e)))),tn=(0,f.XY)(2,(e,t)=>tu(e,e=>e7((0,E.yw)(t)?t:(0,S.s)(()=>t(e)),e))),ti=e=>tu(e,e=>tM),ta=e=>rt(e,eT),ts=(e,t)=>(0,E.R6)(r=>eQ(n=>{let i=s.Ts(e),a=i.length,o=0,l=!1,c=new Set,u=[],d=(e,i,s)=>{if(o++,"Failure"===e._tag){u.push(...e.cause.reasons),o>=a&&n(eO((0,E.b5)(u)));return}let d=!l;l=!0,n(0===c.size?e:tu(nw(eE(c)),()=>e)),d&&t?.onWinner&&t.onWinner({fiber:i,index:s,parentFiber:r})};for(let e=0;e<a;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 eE(c)})),to=(e,t)=>(0,E.R6)(r=>eQ(n=>{let i=!1,a=new Set,s=e=>{i=!0,n(0===a.size?e:tu(nw(eE(a)),()=>e))},o=0;for(let n of e){if(i)break;let e=o++,l=nQ(r,n,!0,!0,!1);a.add(l),l.addObserver(n=>{a.delete(l);let o=!i;s(n),o&&t?.onWinner&&t.onWinner({fiber:l,index:e,parentFiber:r})})}return eE(a)})),tl=(0,f.XY)(e=>(0,E.yw)(e[1]),(e,t,r)=>ts([e,t],r)),tc=(0,f.XY)(e=>(0,E.yw)(e[1]),(e,t,r)=>to([e,t],r)),tu=(0,f.XY)(2,(e,t)=>{let r=Object.create(td);return r[E.a2]=e,r[E.ee]=1!==t.length?e=>t(e):t,r}),td=(0,E.yj)({op:"OnSuccess",[E._3](e){return e._stack.push(this),this[E.a2]}}),tf=(0,f.XY)(2,(e,t)=>th(e)?"Success"===e._tag?t.onSuccess(e.value):t.onFailure(e.cause):rC(e,t)),th=e=>E.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.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)?tR(e,t):r_(e,t)),tv=(0,f.XY)(2,(e,t)=>th(e)?tj(e,t):rx(e,t)),tw=(0,f.XY)(2,(e,t)=>{if(th(e)){if("Success"===e._tag)return e;let r=L(e.cause);return _.N6(r)?e:t(r.success)}return ra(e,t)}),t_=e=>(0,E.cb)(R(e)),tx=e=>"Success"===e._tag,tk=e=>"Success"===e._tag?_.Py(e):_.fJ(e),tS=e=>"Success"===e._tag?_.Py(e.value):_.fJ(e),tE=e=>"Failure"===e._tag,tI=e=>"Failure"===e._tag?_.Py(e):_.fJ(e),t$=e=>"Failure"===e._tag?_.Py(e.cause):_.fJ(e),tO=u.Bh(t$,L),tT=u.Bh(t$,Y),tA=e=>"Failure"===e._tag&&W(e.cause),tC=e=>"Failure"===e._tag&&F(e.cause),tN=e=>"Failure"===e._tag&&j(e.cause),tM=(0,E.xt)(void 0),tP=(0,f.XY)(2,(e,t)=>"Success"===e._tag?(0,E.xt)(t(e.value)):e),tR=(0,f.XY)(2,(e,t)=>{if("Success"===e._tag)return e;let r=L(e.cause);return _.N6(r)?e:(0,E.Rk)(t(r.success))}),tj=(0,f.XY)(2,(e,t)=>{if("Success"===e._tag)return(0,E.xt)(t.onSuccess(e.value));let r=L(e.cause);return _.N6(r)?e:(0,E.Rk)(t.onFailure(r.success))}),tD=(0,f.XY)(2,(e,t)=>tx(e)?(0,E.xt)(t):e),tL=(0,f.XY)(2,(e,t)=>tx(e)?t:e),tU=(0,f.XY)(2,(e,t)=>tx(e)?t.onSuccess(e.value):t.onFailure(e.cause)),tF=tD(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,E.cb)((0,E.b5)(t))},tY=e=>tx(e)?g.some(e.value):g.none(),tW=e=>tE(e)?g.some(e.cause):g.none(),tq=e=>{let t=tO(e);return _.N6(t)?g.none():g.some(t.success)},tX=e=>e,tJ=e=>(0,E.R6)(t=>e$(o.om(t.context,e))),tz=(0,f.XY)(2,(e,t)=>(0,E.R6)(r=>{let n=r.context,i=t(n);return n===i?e:(r.setContext(i),na(e,()=>{r.setContext(n)}))})),tG=(0,f.XY)(3,(e,t,r)=>tz(e,e=>{let n=o.fp(e,t),i=r(n);return n===i?e:o.WQ(e,t,i)})),tV=()=>tK,tK=(0,E.R6)(e=>e$(e.context)),tH=e=>(0,E.R6)(t=>e(t.context)),tQ=(0,f.XY)(2,(e,t)=>tz(e,(0,f.dY)(t))),tZ=(0,f.XY)(2,(e,t)=>th(e)?e:tz(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)=>tz(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))),t5=t0(O.F8),t3=(0,f.XY)(e=>(0,E.yw)(e[1]),(e,t,r)=>t8(e,t,(e,t)=>[e,t],r)),t8=(0,f.XY)(e=>(0,E.yw)(e[1]),(e,t,r,n)=>n?.concurrent?tg(nO([e,t],{concurrency:2}),([e,t])=>(0,S.s)(()=>r(e,t))):tu(e,e=>tg(t,t=>(0,S.s)(()=>r(e,t))))),t6=(0,f.XY)(e=>(0,E.yw)(e[0]),(e,t,r)=>nB(e,t,r?e=>eT(r(e)):()=>eT(new E.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,E.yw)(e[0]),(e,t,r)=>nO(t4(e,t),r)),re=(0,f.XY)(e=>(0,E.yw)(e[0]),(e,t)=>nR({while:f.ue,body:(0,f.dY)(t?.disableYield?e:tu(e,e=>ej)),step:f.Yi})),rt=(0,f.XY)(2,(e,t)=>{let r=Object.create(rr);return r[E.a2]=e,r[E.Sc]=1!==t.length?e=>t(e):t,r}),rr=(0,E.yj)({op:"OnFailure",[E._3](e){return e._stack.push(this),this[E.a2]}}),rn=(0,f.XY)(3,(e,t,r)=>rt(e,e=>t(e)?(0,S.s)(()=>r(e)):eO(e))),ri=(0,f.XY)(3,(e,t,r)=>rt(e,e=>{let n=t(e);return _.N6(n)?eO(n.failure):(0,S.s)(()=>r(n.success,e))})),ra=(0,f.XY)(2,(e,t)=>ri(e,L,e=>t(e))),rs=e=>rP(e,{onFailure:e=>(0,E.PW)(e)?eL:eT(e),onSuccess:eD}),ro=(0,f.XY)(2,(e,t)=>ri(e,Y,t)),rl=(0,f.XY)(2,(e,t)=>rt(e,e=>tr((0,S.s)(()=>t(e)),eO(e)))),rc=(0,f.XY)(3,(e,t,r)=>rn(e,t,e=>tr((0,S.s)(()=>r(e)),eO(e)))),ru=(0,f.XY)(3,(e,t,r)=>rt(e,e=>{let n=t(e);return _.N6(n)?eO(e):tr((0,S.s)(()=>r(n.success,e)),eO(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):eW)}),rh=(0,f.XY)(2,(e,t)=>ru(e,Y,e=>t(e))),rp=(0,f.XY)(e=>(0,E.yw)(e[0]),(e,t,r,n)=>rt(e,e=>{let i=L(e);return _.N6(i)?eO(i.failure):t(i.success)?(0,S.s)(()=>r(i.success)):n?(0,S.s)(()=>n(i.success)):eO(e)})),rm=(0,f.XY)(e=>(0,E.yw)(e[0]),(e,t,r,n)=>rt(e,e=>{let i=L(e);if(_.N6(i))return eO(i.failure);let a=t(i.success);return _.N6(a)?n?(0,S.s)(()=>n(a.failure)):eO(e):(0,S.s)(()=>r(a.success))})),rg=(0,f.XY)(e=>(0,E.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,E.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)?_.Py(e):_.fJ(e)),e=>(0,S.s)(()=>t[e._tag](e)),r)}),rb=(0,f.XY)(e=>(0,E.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.s)(()=>i(t,e)):eT(e)})),rv=(0,f.XY)(e=>(0,E.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.s)(()=>r[t._tag](t,e)):n?(0,S.s)(()=>n(t,e)):eT(e)})}),rw=(0,f.XY)(2,(e,t)=>rm(e,e=>(0,v.$J)(e,t)&&(0,v.i5)(e,"reason")?_.Py(e.reason):_.fJ(e),eT)),r_=(0,f.XY)(2,(e,t)=>ra(e,e=>eY(()=>t(e)))),rx=(0,f.XY)(2,(e,t)=>rP(e,{onFailure:e=>eY(()=>t.onFailure(e)),onSuccess:e=>eA(()=>t.onSuccess(e))})),rk=e=>ra(e,eB),rS=(0,f.XY)(2,(e,t)=>ra(e,e=>eA(t))),rE=e=>eC(()=>{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:ra(r.value,t=>e(n))}(r)}),rI=e=>ra(e,t=>tu(ej,()=>rI(e))),r$=(0,f.XY)(e=>(0,E.yw)(e[0]),(e,t)=>{if(!t?.log)return rP(e,{onFailure:e=>eW,onSuccess:e=>eW});let r=aa(!0===t.log?void 0:t.log);return rC(e,{onFailure(e){let n=D(e);return _.N6(n)?eO(n.failure):void 0===t.message?r(e):r(t.message,e)},onSuccess:e=>eW})}),rO=(0,f.XY)(e=>(0,E.yw)(e[0]),(e,t)=>{if(!t?.log)return rC(e,{onFailure:e=>eW,onSuccess:e=>eW});let r=aa(!0===t.log?void 0:t.log);return rC(e,{onFailure:e=>void 0===t.message?r(e):r(t.message,e),onSuccess:e=>eW})}),rT=e=>rR(e,{onFailure:g.none,onSuccess:g.some}),rA=e=>rj(e,{onFailure:_.fJ,onSuccess:_.Py}),rC=(0,f.XY)(2,(e,t)=>{let r=Object.create(rN);return r[E.a2]=e,r[E.ee]=1!==t.onSuccess.length?e=>t.onSuccess(e):t.onSuccess,r[E.Sc]=1!==t.onFailure.length?e=>t.onFailure(e):t.onFailure,r}),rN=(0,E.yj)({op:"OnSuccessAndFailure",[E._3](e){return e._stack.push(this),this[E.a2]}}),rM=(0,f.XY)(2,(e,t)=>rC(e,{onFailure:e=>eA(()=>t.onFailure(e)),onSuccess:e=>eA(()=>t.onSuccess(e))})),rP=(0,f.XY)(2,(e,t)=>rC(e,{onFailure:e=>{let r=e.reasons.find(E.lC);return r?(0,S.s)(()=>t.onFailure(r.error)):eO(e)},onSuccess:t.onSuccess})),rR=(0,f.XY)(2,(e,t)=>rP(e,{onFailure:e=>eA(()=>t.onFailure(e)),onSuccess:e=>eA(()=>t.onSuccess(e))})),rj=(0,f.XY)(2,(e,t)=>{if(th(e)){if("Success"===e._tag)return(0,E.xt)(t.onSuccess(e.value));let r=L(e.cause);return _.N6(r)?e:(0,E.xt)(t.onFailure(r.success))}return rR(e,t)}),rD=(0,f.XY)(2,(e,t)=>th(e)?"Success"===e._tag?(0,E.xt)(t.onSuccess(e.value)):(0,E.xt)(t.onFailure(e.cause)):rM(e,t)),rL=e=>th(e)?(0,E.xt)(e):rU(e),rU=(0,E.Uf)({op:"Exit",[E._3](e){return e._stack.push(this),this[E.a2]},[E.ee]:(e,t,r)=>e$(r??(0,E.xt)(e)),[E.Sc]:(e,t,r)=>e$(r??(0,E.cb)(e))}),rF=rj({onFailure:()=>!0,onSuccess:()=>!1}),rB=rj({onFailure:()=>!1,onSuccess:()=>!0}),rY=(0,f.XY)(2,(e,t)=>tr(iY(t),e)),rW=(0,f.XY)(2,(e,t)=>tc(e,tu(iY(t.duration),t.orElse))),rq=(0,f.XY)(2,(e,t)=>rW(e,{duration:t,orElse:()=>eT(new iz)})),rX=(0,f.XY)(2,(e,t)=>tc(te(e),e7(iY(t),g.none()))),rJ=e=>iB(t=>{let r=t.currentTimeNanosUnsafe();return tg(e,e=>[l.cF(t.currentTimeNanosUnsafe()-r),e])}),rz="~effect/Scope",rG="~effect/Scope/Closeable",rV=o.kl("effect/Scope"),rK=(e,t)=>eC(()=>rH(e,t)??eW),rH=(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=[],a=Array.from(t.values()),s=ep();for(let t=a.length-1;t>=0;t--){let o=a[t];"sequential"===e.strategy?n.push((yield*rL(o(r)))):i.push(nQ(s,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=r8(t);if("Closed"===e.state._tag)return r.state=e.state,r;let n={};return r5(e,n,e=>rK(r,e)),r5(r,n,t=>eA(()=>r3(e,n))),r},r1=(e,t)=>eC(()=>"Closed"===e.state._tag?t(e.state.exit):(r5(e,{},t),eW)),r2=(e,t)=>r1(e,(0,f.dY)(t)),r5=(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)},r3=(e,t)=>{"Open"===e.state._tag&&e.state.finalizers.delete(t)},r8=(e="sequential")=>({[rG]:rG,[rz]:rz,strategy:e,state:r6}),r6={_tag:"Empty"},r9=e=>eA(()=>r8(e)),r4=rV,r7=t0(rV),ne=e=>(0,E.R6)(t=>{let r=t.context,n=r8();return t.setContext(o.WQ(t.context,rV,n)),na(e,e=>(t.setContext(r),rH(n,e)))}),nt=(0,f.XY)(2,(e,t)=>ns(r7(e,t),e=>eC(()=>rH(t,e)??eW))),nr=e=>eC(()=>{let t=r8();return ns(e(t),e=>eC(()=>rH(t,e)??eW))}),nn=(e,t,r)=>tH(n=>nE(i=>tu(r4,a=>tn(r?.interruptible?i(e):e,e=>r1(a,r=>tZ(t(e,r),n)))))),ni=e=>tu(r4,t=>tH(r=>r1(t,t=>tZ(e(t),r)))),na=(0,E.Uf)({op:"OnExit",single:!1,[E._3](e){return e._stack.push(this),this[E.a2][0]},[E.u4](e){e.interruptible&&!0!==this[E.a2][2]&&(e._stack.push(nx),e.interruptible=!1)},[E.ee](e,t,r){r??=(0,E.xt)(e);let n=this[E.a2][1](r);return n?tu(n,e=>r):r},[E.Sc](e,t,r){r??=(0,E.cb)(e);let n=this[E.a2][1](r);return n?tu(n,e=>r):r}}),ns=(0,f.XY)(2,na),no=(0,f.XY)(2,(e,t)=>ns(e,e=>t)),nl=(0,f.XY)(3,(e,t,r)=>ns(e,e=>t(e)?r(e):eW)),nc=(0,f.XY)(3,(e,t,r)=>ns(e,e=>{let n=t(e);return _.N6(n)?eW: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)=>ns(e,e=>{if("Failure"!==e._tag)return eW;let n=t(e.cause);return _.N6(n)?eW:r(n.success,e.cause)})),nh=(0,f.XY)(2,(e,t)=>nf(X,t)(e)),np=(e,t,r)=>nE(n=>tu(e,e=>na(n(t(e)),t=>r(e,t),!0))),nm=e=>nn(e,e=>(0,v.i5)(e,Symbol.asyncDispose)?eX(()=>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),a=iu(!1),s=0,o=!1,c=tu(a.await,()=>r);return[(0,E.R6)(t=>{let l=t.getRef(ij),u=i?l.currentTimeMillisUnsafe():0;return o||u<s?r??c:(o=!0,a.closeUnsafe(),r=void 0,ns(e,e=>eA(()=>{o=!1,s=l.currentTimeMillisUnsafe()+n,r=e,a.openUnsafe()})))}),eA(()=>{s=0,a.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,E.R6)(e=>eO(R(e.id))),nw=e=>(0,E.R6)(t=>(t.interruptible&&(t.interruptible=!1,t._stack.push(nx)),e)),n_=(0,E.Uf)({op:"SetInterruptible",[E.u4](e){if(e.interruptible=this[E.a2],e._interruptedCause&&e.interruptible)return()=>eO(e._interruptedCause)}}),nx=n_(!0),nk=n_(!1),nS=e=>(0,E.R6)(t=>t.interruptible?e:(t.interruptible=!0,t._stack.push(nk),t._interruptedCause)?eO(t._interruptedCause):e),nE=e=>(0,E.R6)(t=>t.interruptible?(t.interruptible=!1,t._stack.push(nx),e(nS)):e(f.D_)),nI=e=>(0,E.R6)(t=>t.interruptible?e(f.D_):(t.interruptible=!0,t._stack.push(nk),e(nw))),n$=tg(nn(eA(()=>new AbortController),e=>eA(()=>e.abort())),e=>e.signal),nO=(e,t)=>(0,v.xZ)(e)?t?.mode==="result"?nj(e,rA,t):nj(e,f.D_,t):t?.discard?"result"===t.mode?nj(Object.values(e),rA,t):nj(Object.values(e),f.D_,t):eC(()=>{let r={};return e7(nj(Object.entries(e),([e,n])=>tg(t?.mode==="result"?rA(n):n,t=>{r[e]=t}),{discard:!0,concurrency:t?.concurrency}),r)}),nT=(0,f.XY)(e=>(0,v.xZ)(e[0])&&!(0,E.yw)(e[0]),(e,t,r)=>tg(nj(e,(e,r)=>rA(t(e,r)),r),e=>s.jB(e,f.D_))),nA=(0,f.XY)(e=>(0,v.xZ)(e[0])&&!(0,E.yw)(e[0]),(e,t,r)=>tu(nT(e,t,{concurrency:r?.concurrency}),([e,t])=>s.CZ(e)?eT(e):r?.discard?eW:e$(t))),nC=(0,f.XY)(e=>(0,v.xZ)(e[0])&&!(0,E.yw)(e[0]),(e,t)=>eC(()=>{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 a=e.next();return a.done?e$(g.none()):nN(e,t+1,r,a.value)}),nM=(0,f.XY)(e=>(0,v.xZ)(e[0])&&!(0,E.yw)(e[0]),(e,t)=>eC(()=>{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(_.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)}),nR=(0,E.Uf)({op:"While",[E.ee](e,t){return(this[E.a2].step(e),this[E.a2].while())?(t._stack.push(this),this[E.a2].body()):tM},[E._3](e){return this[E.a2].while()?(e._stack.push(this),this[E.a2].body()):tM}}),nj=(0,f.XY)(e=>"function"==typeof e[1],(e,t,r)=>(0,E.R6)(n=>{let i=r?.concurrency==="inherit"?n.getRef(O.F8):r?.concurrency??1,a="unbounded"===i?1/0:Math.max(1,i);if(1===a)return nD(e,t,r);let o=s.Ts(e),l=o.length;if(0===l)return r?.discard?eW:e$([]);let c=r?.discard?void 0:Array(l),u=nF({f:t,out:c},o,{concurrency:a});return u?e7(u,c):e$(c)})),nD=(e,t,r)=>eC(()=>{let n=r?.discard?void 0:[],i=e[Symbol.iterator](),a=i.next(),s=0;return e7(nR({while:()=>!a.done,body:()=>t(a.value,s++),step:e=>{n&&n.push(e),a=i.next()}}),n)}),nL=e=>{let t=e.onItem,r=e.step;return(e,n,i)=>{let a,s,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,a)=>{if(!h)return r(e,t,i,a);if(l)return l;for(y[a]=i;g<d;){let t=y[g];if(void 0===t)return;y[g]=void 0;let i=g++,a=r(e,n[i],t,i);if(a)return a}},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()??eW));if(!a)return eQ(e=>{a=ep(),c=d,o=e;let t=v();return t?e(t):eC(()=>(l=tM,m=!0,s?eE(s):eW))});c=void 0;let e=nQ(a,d,!0,!0,"inherit");if(e._exit){if(l=b(i,e._exit,u))break;continue}s?s.add(e):s=new Set([e]);let t=u;if(e.addObserver(n=>{if(s.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,E.cb)((0,E.b5)([e]))}else{let e=b(i,n,t);e&&(l="Failure"===e._tag?(0,E.cb)((0,E.b5)(e.cause.reasons.slice())):e,v())}if(r){let e=v();e&&o(e)}else p&&0===s.size&&o(l??eW)}),s.size<f)continue;r=!0,u++;return}}if(p=!0,l){if(s&&s.size>0){let e=ey(a);s.forEach(t=>t.interruptUnsafe(a.id,e));return}if(o||"Failure"===l._tag)return l}else if(o)if(!s)return tM;else 0===s.size&&o(eW)};return v()}},nU=()=>nL,nF=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 _.N6(n)?r(n.failure):e$(n.success)})),nW=(0,f.XY)(e=>(0,E.yw)(e[0]),(e,t,r)=>nY(e,t,r?e=>eT(r(e)):()=>eT(new E.Xm))),nq=(0,f.XY)(e=>(0,v.xZ)(e[0])&&!(0,E.yw)(e[0]),(e,t,r)=>eC(()=>{let n=[];return e7(nj(e,(e,r)=>{let i=t(e,r);return"boolean"==typeof i?(i&&n.push(e),eW):tg(i,t=>{t&&n.push(e)})},{discard:!0,concurrency:r?.concurrency}),n)})),nX=(0,f.XY)(e=>(0,v.xZ)(e[0])&&!(0,E.yw)(e[0]),(e,t)=>eC(()=>{let r=[];for(let n of e){let e=t(n);_.oJ(e)&&r.push(e.success)}return e$(r)})),nJ=(0,f.XY)(e=>(0,v.xZ)(e[0])&&!(0,E.yw)(e[0]),(e,t,r)=>eC(()=>{let n=[];return e7(nj(e,e=>tg(t(e),e=>{_.oJ(e)&&n.push(e.success)}),{discard:!0,concurrency:r?.concurrency}),n)})),nz=e$({}),nG=I.Jr(tg),nV=I.oI(tg,tu),nK=I.zM(tg),nH=(0,f.XY)(e=>(0,E.yw)(e[0]),(e,t)=>(0,E.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 a="inherit"===i?e.interruptible:!i,s=new em(e.context,a);return r?s.evaluate(t):e.currentDispatcher.scheduleTask(()=>s.evaluate(t),0),n||s._exit||(e.children().add(s),s.addObserver(()=>e._children.delete(s))),s},nZ=(0,f.XY)(e=>(0,E.yw)(e[0]),(e,t)=>(0,E.R6)(r=>e$(nQ(r,e,t?.startImmediately,!0,t?.uninterruptible)))),n0=e=>(0,E.R6)(t=>{let r=t._children&&s.Ts(t._children);return ns(e,e=>{let n=t._children;return void 0===n||0===n.size?eW:(r&&(n=m.pb(n,e=>!r.includes(e))),ti(ew(n)))})}),n1=(0,f.XY)(e=>(0,E.yw)(e[0]),(e,t,r)=>(0,E.R6)(n=>{let i=nQ(n,e,r?.startImmediately,!0,r?.uninterruptible);if(!i._exit)if("Closed"!==t.state._tag){let e={};r5(t,e,()=>ez(e=>e===i.id?eW:ek(i))),i.addObserver(()=>r3(t,e))}else i.interruptUnsafe(n.id,ey(n));return e$(i)})),n2=(0,f.XY)(e=>(0,E.yw)(e[0]),(e,t)=>tu(r4,r=>n1(e,r,t))),n5=e=>(t,r)=>{let n=new em(r?.scheduler?o.WQ(e,x._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},n3=(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 r5(t,r,()=>ek(e)),e.addObserver(()=>r3(t,r)),e}),n8=n5(o.Ie()),n6=e=>{let t=n5(e);return(e,r)=>{let n=t(e,r);return r?.onExit&&n.addObserver(r.onExit),e=>n.interruptUnsafe(e)}},n9=n6(o.Ie()),n4=e=>{let t=n5(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=n5(e);return e=>{if(th(e))return e;let r=t(e,{scheduler:new x.FG("sync")});return r.currentDispatcher?.flush(),r._exit??(0,E.V2)(new i2(r))}},ii=ir(o.Ie()),ia=e=>{let t=ir(e);return e=>{let r=t(e);if("Failure"===r._tag)throw Z(r.cause);return r.value}},is=ia(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,E.R6)(e=>this._isOpen?il:(this._isOpen=!0,this.scheduleUnsafe(e)));release=(0,E.R6)(e=>this._isOpen?il:this.scheduleUnsafe(e));openUnsafe(){return!this._isOpen&&(this._isOpen=!0,this.flushWaiters(),!0)}await=eQ(e=>this._isOpen?e(eW):(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,E.R6)(e=>e$(e.getRef(k.sh))),ip=(0,f.XY)(2,(e,t)=>t0(e,k.sh,t)),im=t0(O.rf),ig=t0(O.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,k.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(O.rf)||r?.annotations&&o.Jt(r.annotations,k.DW),a=r?.parent!==void 0?g.some(r.parent):r?.root?g.none():iv(e.currentSpan);if(i){let e;e={name:t,parent:a,annotations:o.WQ(r?.annotations??o.Ie(),k.DW,!0)},n=Object.assign(Object.create(ib),e)}else{let i=e.getRef(k.sh),s=e.getRef(ij),l=e.getRef(O.nU),c=e.getRef(O.ce),u=e.getRef(O.ls),d=r?.level??e.getRef(k.pX),f=r?.links!==void 0?[...u,...r.links]:u.slice();for(let[u,h]of(n=i.span({name:t,parent:a,annotations:r?.annotations??o.Ie(),links:f,startTime:l?s.currentTimeNanosUnsafe():BigInt(0),kind:r?.kind??"internal",root:r?.root??g.isNone(a),sampled:r?.sampled??((!g.isSome(a)||!1!==a.value.sampled)&&!i4(e.getRef(k.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},i_=(e,t)=>(0,E.R6)(r=>e$(iw(r,e,t))),ix=(e,t)=>nw((0,E.R6)(r=>{let n=o.fp(r.context,rV),i=iw(r,e,t??{}),a=r.getRef(ij),s=r.getRef(O.nU);return e7(r1(n,e=>i$(i,e,a,s)),i)})),ik=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(ix(t,r),t=>iA(e,t,r))}return e=>tu(ix(t,r),t=>iA(e,t,r))},iS=O.ce,iE=O.ls,iI=(0,f.XY)(e=>(0,E.yw)(e[0]),(e,t,r={})=>{let n=(Array.isArray(t)?t:[t]).map(e=>({span:e,attributes:r}));return tG(e,O.ls,e=>[...e,...n])}),i$=(e,t,r,n)=>eA(()=>{"Ended"!==e.status._tag&&e.end(n?r.currentTimeNanosUnsafe():iy,t)}),iO=(e,...t)=>{let r=1===t.length?void 0:t[0],n=t[t.length-1];return(0,E.R6)(t=>{let i=iw(t,e,r),a=t.getRef(ij);return ns((0,S.s)(()=>n(i)),e=>eA(()=>{"Ended"!==i.status._tag&&i.end(a.currentTimeNanosUnsafe(),e)}))})},iT=t0(k.Tv),iA=function(){let e=(0,E.yw)(arguments[0]),t=e?arguments[1]:arguments[0],r=e?arguments[2]:arguments[1],n=f.D_;if("Span"===t._tag){var i,a;r=A(r),i=t.name,a="function"==typeof(a=r?.captureStackTrace)?a:f.MN,n=tG(O.vA,e=>({name:i,stack:a,parent:e}))}return e?iT(n(arguments[0]),t):e=>iT(n(e),t)},iC=function(){let e="string"!=typeof arguments[0],t=e?arguments[1]:arguments[0],r=A(arguments[2]);if(e){let e=arguments[0];return iO(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,...a)=>iO(t,n?n(...a):i,t=>iA(e,t,r))},iN=(0,f.XY)(e=>(0,E.yw)(e[0]),(e,...t)=>tG(e,O.ce,e=>{let r={...e};return 1===t.length?Object.assign(r,t[0]):r[t[0]]=t[1],r})),iM=(...e)=>(0,E.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 eW}),iP=(0,E.R6)(e=>{let t=e.currentSpanLocal;return t?e$(t):eT(new E.Xm)}),iR=(n=k.Tv,(0,E.R6)(e=>e.context.mapUnsafe.has(n.key)?e$(o.fp(e.context,n)):eT(new E.Xm))),ij=o.Or("effect/Clock",{defaultValue:()=>new iL}),iD=0x80000000-1;class iL{currentTimeMillisUnsafe(){return Date.now()}currentTimeMillis=eA(()=>this.currentTimeMillisUnsafe());currentTimeNanosUnsafe(){return iF()}currentTimeNanos=eA(()=>this.currentTimeNanosUnsafe());sleep(e){return this.sleepMillis(l.kE(e))}sleepMillis(e){return e<=0?ej:Number.isFinite(e)?eQ(t=>{let r=e>iD?this.sleepMillis(e-iD):eW,n=setTimeout(()=>t(r),Math.min(e,iD));return eA(()=>clearTimeout(n))}):eZ}}let iU=(a=BigInt(1e6),"u"<typeof performance||void 0===performance.now?()=>BigInt(Date.now())*a:()=>(i??=BigInt(Date.now())*a-BigInt(Math.round(1e6*performance.now())))+BigInt(Math.round(1e6*performance.now()))),iF=function(){let e="object"==typeof process&&"hrtime"in process&&"function"==typeof process.hrtime.bigint?process.hrtime:void 0;if(!e)return iU;let t=BigInt(Date.now())*BigInt(1e6)-e.bigint();return()=>t+e.bigint()}(),iB=e=>(0,E.R6)(t=>e(t.getRef(ij))),iY=e=>iB(t=>t.sleep(l.bN(e))),iW=iB(e=>e.currentTimeMillis),iq=iB(e=>e.currentTimeNanos),iX="~effect/Cause/TimeoutError",iJ=e=>(0,v.i5)(e,iX);class iz extends(0,E.rN)("TimeoutError"){[iX]=iX;constructor(e){super({message:e})}}let iG="~effect/Cause/IllegalArgumentError",iV=e=>(0,v.i5)(e,iG);class iK extends(0,E.rN)("IllegalArgumentError"){[iG]=iG;constructor(e){super({message:e})}}let iH="~effect/Cause/ExceededCapacityError",iQ=e=>(0,v.i5)(e,iH);class iZ extends(0,E.rN)("ExceededCapacityError"){[iH]=iH;constructor(e){super({message:e})}}let i0="~effect/Cause/AsyncFiberError",i1=e=>(0,v.i5)(e,i0);class i2 extends(0,E.rN)("AsyncFiberError"){[i0]=i0;constructor(e){super({message:"An asynchronous Effect was executed with Effect.runSync",fiber:e})}}let i5="~effect/Cause/UnknownError",i3=e=>(0,v.i5)(e,i5);class i8 extends(0,E.rN)("UnknownError"){[i5]=i5;constructor(e,t){super({message:t,cause:e})}}let i6=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([as,ao])}),ae=o.Or("effect/Logger/LogToStderr",{defaultValue:f.f4}),at=function(){let e="string"==typeof arguments[0]?[[arguments[0],arguments[1]]]:Object.entries(arguments[0]);return nw((0,E.R6)(t=>{let r=t.getRef(O.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,O.iL,n)),r1(o.fp(t.context,rV),n=>{let i=t.getRef(O.iL),a={...i};for(let t=0;t<e.length;t++){let[n,s]=e[t];i[n]===s&&(n in r?a[n]=r[n]:delete a[n])}return t.setContext(o.WQ(t.context,O.iL,a)),eW})}))},ar={"~effect/Logger":{_Message:f.D_,_Output:f.D_},pipe(){return(0,b.tT)(this,arguments)}},an=e=>{let t=Object.create(ar);return t.log=e,t},ai=(e,t)=>{let r=e[0].replace(/[\s="]/g,"_");return`${r}=${t-e[1]}ms`},aa=e=>(...t)=>{let r;for(let e=0,n=t.length;e<n;e++){let n=t[e];(0,E.Aj)(n)&&(r?t.splice(e,1):t=t.slice(0,e).concat(t.slice(e+1)),r=r?(0,E.b5)(r.reasons.concat(n.reasons)):n,e--)}return void 0===r&&(r=E.DH),(0,E.R6)(n=>{let i=e??n.currentLogLevel;if(i4(n.minimumLogLevel,i))return eW;let a=n.getRef(ij),s=n.getRef(i7);if(s.size>0){let e=new Date(a.currentTimeMillisUnsafe());for(let a of s)a.log({cause:r,fiber:n,date:e,logLevel:i,message:t})}return eW})},as=an(({cause:e,date:t,fiber:r,logLevel:n,message:i})=>{let a=Array.isArray(i)?i.slice():[i];e.reasons.length>0&&a.push(el(e));let s=t.getTime(),o=r.getRef(O.d8),l="";for(let e of o)l+=` ${ai(e,s)}`;let c=r.getRef(O.iL);Object.keys(c).length>0&&a.push(c);let u=r.getRef(i6);(r.getRef(ae)?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}:`,...a)}),ao=an(({cause:e,fiber:t,logLevel:r,message:n})=>{let i=t.getRef(ij),a=t.getRef(O.iL),s=t.currentSpan;if(void 0===s||"ExternalSpan"===s._tag)return;let o={};for(let[e,t]of Object.entries(a))o[e]=t;o["effect.fiberId"]=t.id,o["effect.logLevel"]=r.toUpperCase(),e.reasons.length>0&&(o["effect.cause"]=el(e)),s.event((0,p.ZK)(Array.isArray(n)&&1===n.length?n[0]:n),i.currentTimeNanosUnsafe(),o)}),al=e$(void 0),ac=(0,f.XY)(e=>(0,E.yw)(e[0]),(e,t)=>nu(e,e=>(0,E.R6)(r=>(au(r,e,t?.defectsOnly),eW)))),au=(e,t,r)=>{let n=e.getRef(O.oQ);if(0===n.size||r&&!F(t))return;let i={cause:t,fiber:e,timestamp:e.getRef(ij).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),a=r(4450),s=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)},[a.HR](){return a.kg(a.tW(this._tag))(a.tW(this.value))},toString(){return`some(${(0,i.GP)(this.value)})`},toJSON(){return{_id:"Option",_tag:this._tag,value:(0,s.aB)(this.value)}}}),"valueOrUndefined",{get(){return this.value}}),h=a.tW("None"),p=Object.assign(Object.create(d),{_tag:"None",_op:"None",valueOrUndefined:void 0,[n.HR]:e=>m(e)&&g(e),[a.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 a=n.Or("effect/References/CurrentConcurrency",{defaultValue:()=>"unbounded"}),s=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:a,Gl:h,aG:m,ce:u,d8:g,iL:f,ls:d,nU:c,oQ:s,rf:l,vA:o,zQ:p})},4403(e,t,r){var n=r(8036),i=r(6470),a=r(4650),s=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)},[s.HR](){return s.kg(s.tW(this._tag))(s.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)},[s.HR](){return s.kg(s.tW(this._tag))(s.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},_=(0,a.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:_})},4888(e,t,r){var n=r(4650);function i(e){return e.checks?e.checks[e.checks.length-1].annotations:e.annotations}function a(e){return t=>i(t)?.[e]}let s=a("identifier"),o=a("title"),l=a("description"),c=(0,n.Bj)(e=>{let t=s(e);return"string"==typeof t?t:e.getExpected(c)});r.d(t,{hd:()=>i,ip:()=>a},{DQ:o,KE:s,Pk:l,bo:c})},8045(e,t,r){var n=r(8543),i=r(6030);function a(e){let t;for(let r of e.reasons){if(!n.lC(r)||!i.gh(r.error))return;t??=r.error}return t}function s(e,t){let r=a(e);if(void 0===r)throw Error(t,{cause:e});return r}r.d(t,{R:()=>a,q:()=>s})},3628(e,t,r){let n,i=Object.getOwnPropertyDescriptor,a=Object.prototype.hasOwnProperty,s=Object.isExtensible,o=void 0===(n=i(Error,"stackTraceLimit"))?s(Error):a.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 a=0;for(;(e[a]||n)===t[a];)a++;if(a>0)return t.slice(0,a)+i(e.slice(a),t.slice(a),r)}let a=e?r.indexOf(e[0]):0,s=null!=t?r.indexOf(t[0]):r.length;return s-a>1?r[Math.round(.5*(a+s))]:t&&t.length>1?t.slice(0,1):r[a]+i(e.slice(1),null,r)}function a(e){if(e.length!==s(e[0]))throw Error("invalid integer part of order key: "+e)}function s(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=s(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){a(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 s=function(e,t){a(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==s)throw Error("cannot decrement any more");return s}if(null==t){let t=o(e),n=e.slice(t.length),a=c(t,r);return null==a?t+i(n,null,r):a}let s=o(e),d=e.slice(s.length),f=o(t),h=t.slice(f.length);if(s===f)return s+i(d,h,r);let p=c(s,r);if(null==p)throw Error("cannot increment any more");return p<t?p:s+i(d,null,r)}r.d(t,{TU:()=>u,YT:()=>function e(t,r,i,a=n){if(0===i)return[];if(1===i)return[u(t,r,a)];if(null==r){let e=u(t,r,a),n=[e];for(let t=0;t<i-1;t++)n.push(e=u(e,r,a));return n}if(null==t){let e=u(t,r,a),n=[e];for(let r=0;r<i-1;r++)n.push(e=u(t,e,a));return n.reverse(),n}let s=Math.floor(i/2),o=u(t,r,a);return[...e(t,o,s,a),o,...e(o,r,i-s-1,a)]}})},8689(e,t,r){let n,i,a,s,o;function l(e){let t=e.length;for(;--t>=0;)e[t]=0}let c=573,u=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),d=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),f=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),h=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),p=Array(576);l(p);let m=Array(60);l(m);let g=Array(512);l(g);let y=Array(256);l(y);let b=Array(29);l(b);let v=Array(30);function w(e,t,r,n,i){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=e&&e.length}function _(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}l(v);let x=e=>e<256?g[e]:g[256+(e>>>7)],k=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},S=(e,t,r)=>{e.bi_valid>16-r?(e.bi_buf|=t<<e.bi_valid&65535,k(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=r-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)},E=(e,t,r)=>{S(e,r[2*t],r[2*t+1])},I=(e,t)=>{let r=0;do r|=1&e,e>>>=1,r<<=1;while(--t>0)return r>>>1},$=(e,t,r)=>{let n,i,a=Array(16),s=0;for(n=1;n<=15;n++)a[n]=s=s+r[n-1]<<1;for(i=0;i<=t;i++){let t=e[2*i+1];0!==t&&(e[2*i]=I(a[t]++,t))}},O=e=>{let t;for(t=0;t<286;t++)e.dyn_ltree[2*t]=0;for(t=0;t<30;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0},T=e=>{e.bi_valid>8?k(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},A=(e,t,r,n)=>{let i=2*t,a=2*r;return e[i]<e[a]||e[i]===e[a]&&n[t]<=n[r]},C=(e,t,r)=>{let n=e.heap[r],i=r<<1;for(;i<=e.heap_len&&(i<e.heap_len&&A(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!A(t,n,e.heap[i],e.depth));)e.heap[r]=e.heap[i],r=i,i<<=1;e.heap[r]=n},N=(e,t,r)=>{let n,i,a,s,o=0;if(0!==e.last_lit)do n=e.pending_buf[e.d_buf+2*o]<<8|e.pending_buf[e.d_buf+2*o+1],i=e.pending_buf[e.l_buf+o],o++,0===n?E(e,i,t):(E(e,(a=y[i])+256+1,t),0!==(s=u[a])&&S(e,i-=b[a],s),E(e,a=x(--n),r),0!==(s=d[a])&&S(e,n-=v[a],s));while(o<e.last_lit)E(e,256,t)},M=(e,t)=>{let r,n,i,a=t.dyn_tree,s=t.stat_desc.static_tree,o=t.stat_desc.has_stree,l=t.stat_desc.elems,u=-1;for(e.heap_len=0,e.heap_max=c,r=0;r<l;r++)0!==a[2*r]?(e.heap[++e.heap_len]=u=r,e.depth[r]=0):a[2*r+1]=0;for(;e.heap_len<2;)a[2*(i=e.heap[++e.heap_len]=u<2?++u:0)]=1,e.depth[i]=0,e.opt_len--,o&&(e.static_len-=s[2*i+1]);for(t.max_code=u,r=e.heap_len>>1;r>=1;r--)C(e,a,r);i=l;do r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],C(e,a,1),n=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=n,a[2*i]=a[2*r]+a[2*n],e.depth[i]=(e.depth[r]>=e.depth[n]?e.depth[r]:e.depth[n])+1,a[2*r+1]=a[2*n+1]=i,e.heap[1]=i++,C(e,a,1);while(e.heap_len>=2)e.heap[--e.heap_max]=e.heap[1],((e,t)=>{let r,n,i,a,s,o,l=t.dyn_tree,u=t.max_code,d=t.stat_desc.static_tree,f=t.stat_desc.has_stree,h=t.stat_desc.extra_bits,p=t.stat_desc.extra_base,m=t.stat_desc.max_length,g=0;for(a=0;a<=15;a++)e.bl_count[a]=0;for(l[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;r<c;r++)(a=l[2*l[2*(n=e.heap[r])+1]+1]+1)>m&&(a=m,g++),l[2*n+1]=a,!(n>u)&&(e.bl_count[a]++,s=0,n>=p&&(s=h[n-p]),o=l[2*n],e.opt_len+=o*(a+s),f&&(e.static_len+=o*(d[2*n+1]+s)));if(0!==g){do{for(a=m-1;0===e.bl_count[a];)a--;e.bl_count[a]--,e.bl_count[a+1]+=2,e.bl_count[m]--,g-=2}while(g>0)for(a=m;0!==a;a--)for(n=e.bl_count[a];0!==n;)!((i=e.heap[--r])>u)&&(l[2*i+1]!==a&&(e.opt_len+=(a-l[2*i+1])*l[2*i],l[2*i+1]=a),n--)}})(e,t),$(a,u,e.bl_count)},P=(e,t,r)=>{let n,i,a=-1,s=t[1],o=0,l=7,c=4;for(0===s&&(l=138,c=3),t[(r+1)*2+1]=65535,n=0;n<=r;n++)i=s,s=t[(n+1)*2+1],++o<l&&i===s||(o<c?e.bl_tree[2*i]+=o:0!==i?(i!==a&&e.bl_tree[2*i]++,e.bl_tree[32]++):o<=10?e.bl_tree[34]++:e.bl_tree[36]++,o=0,a=i,0===s?(l=138,c=3):i===s?(l=6,c=3):(l=7,c=4))},R=(e,t,r)=>{let n,i,a=-1,s=t[1],o=0,l=7,c=4;for(0===s&&(l=138,c=3),n=0;n<=r;n++)if(i=s,s=t[(n+1)*2+1],!(++o<l)||i!==s){if(o<c)do E(e,i,e.bl_tree);while(0!=--o)else 0!==i?(i!==a&&(E(e,i,e.bl_tree),o--),E(e,16,e.bl_tree),S(e,o-3,2)):o<=10?(E(e,17,e.bl_tree),S(e,o-3,3)):(E(e,18,e.bl_tree),S(e,o-11,7));o=0,a=i,0===s?(l=138,c=3):i===s?(l=6,c=3):(l=7,c=4)}},j=!1,D=(e,t,r,n)=>{S(e,0+ +!!n,3),T(e),k(e,r),k(e,~r),e.pending_buf.set(e.window.subarray(t,t+r),e.pending),e.pending+=r};var L={_tr_init:e=>{j||((()=>{let e,t,r,s,o,l=Array(16);for(s=0,r=0;s<28;s++)for(b[s]=r,e=0;e<1<<u[s];e++)y[r++]=s;for(y[r-1]=s,o=0,s=0;s<16;s++)for(v[s]=o,e=0;e<1<<d[s];e++)g[o++]=s;for(o>>=7;s<30;s++)for(v[s]=o<<7,e=0;e<1<<d[s]-7;e++)g[256+o++]=s;for(t=0;t<=15;t++)l[t]=0;for(e=0;e<=143;)p[2*e+1]=8,e++,l[8]++;for(;e<=255;)p[2*e+1]=9,e++,l[9]++;for(;e<=279;)p[2*e+1]=7,e++,l[7]++;for(;e<=287;)p[2*e+1]=8,e++,l[8]++;for($(p,287,l),e=0;e<30;e++)m[2*e+1]=5,m[2*e]=I(e,5);n=new w(p,u,257,286,15),i=new w(m,d,0,30,15),a=new w([],f,0,19,7)})(),j=!0),e.l_desc=new _(e.dyn_ltree,n),e.d_desc=new _(e.dyn_dtree,i),e.bl_desc=new _(e.bl_tree,a),e.bi_buf=0,e.bi_valid=0,O(e)},_tr_stored_block:D,_tr_flush_block:(e,t,r,n)=>{let i,a,s=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,r=0xf3ffc07f;for(t=0;t<=31;t++,r>>>=1)if(1&r&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<256;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0})(e)),M(e,e.l_desc),M(e,e.d_desc),s=(e=>{let t;for(P(e,e.dyn_ltree,e.l_desc.max_code),P(e,e.dyn_dtree,e.d_desc.max_code),M(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*h[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),i=e.opt_len+3+7>>>3,(a=e.static_len+3+7>>>3)<=i&&(i=a)):i=a=r+5,r+4<=i&&-1!==t?D(e,t,r,n):4===e.strategy||a===i?(S(e,2+ +!!n,3),N(e,p,m)):(S(e,4+ +!!n,3),((e,t,r,n)=>{let i;for(S(e,t-257,5),S(e,r-1,5),S(e,n-4,4),i=0;i<n;i++)S(e,e.bl_tree[2*h[i]+1],3);R(e,e.dyn_ltree,t-1),R(e,e.dyn_dtree,r-1)})(e,e.l_desc.max_code+1,e.d_desc.max_code+1,s+1),N(e,e.dyn_ltree,e.dyn_dtree)),O(e),n&&T(e)},_tr_tally:(e,t,r)=>(e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&r,e.last_lit++,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[(y[r]+256+1)*2]++,e.dyn_dtree[2*x(t)]++),e.last_lit===e.lit_bufsize-1),_tr_align:e=>{S(e,2,3),E(e,256,p),16===e.bi_valid?(k(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}},U=(e,t,r,n)=>{let i=65535&e,a=e>>>16&65535,s=0;for(;0!==r;){s=r>2e3?2e3:r,r-=s;do a=a+(i=i+t[n++]|0)|0;while(--s)i%=65521,a%=65521}return i|a<<16};let F=new Uint32Array((()=>{let e,t=[];for(var r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?0xedb88320^e>>>1:e>>>1;t[r]=e}return t})());var B=(e,t,r,n)=>{let i=n+r;e^=-1;for(let r=n;r<i;r++)e=e>>>8^F[(e^t[r])&255];return -1^e},Y={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},W={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};let{_tr_init:q,_tr_stored_block:X,_tr_flush_block:J,_tr_tally:z,_tr_align:G}=L,{Z_NO_FLUSH:V,Z_PARTIAL_FLUSH:K,Z_FULL_FLUSH:H,Z_FINISH:Q,Z_BLOCK:Z,Z_OK:ee,Z_STREAM_END:et,Z_STREAM_ERROR:er,Z_DATA_ERROR:en,Z_BUF_ERROR:ei,Z_DEFAULT_COMPRESSION:ea,Z_FILTERED:es,Z_HUFFMAN_ONLY:eo,Z_RLE:el,Z_FIXED:ec,Z_DEFAULT_STRATEGY:eu,Z_UNKNOWN:ed,Z_DEFLATED:ef}=W,eh=573,ep=(e,t)=>(e.msg=Y[t],t),em=e=>(e<<1)-9*(e>4),eg=e=>{let t=e.length;for(;--t>=0;)e[t]=0},ey=(e,t,r)=>(t<<e.hash_shift^r)&e.hash_mask,eb=e=>{let t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+r),e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))},ev=(e,t)=>{J(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,eb(e.strm)},ew=(e,t)=>{e.pending_buf[e.pending++]=t},e_=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},ex=(e,t,r,n)=>{let i=e.avail_in;return(i>n&&(i=n),0===i)?0:(e.avail_in-=i,t.set(e.input.subarray(e.next_in,e.next_in+i),r),1===e.state.wrap?e.adler=U(e.adler,t,i,r):2===e.state.wrap&&(e.adler=B(e.adler,t,i,r)),e.next_in+=i,e.total_in+=i,i)},ek=(e,t)=>{let r,n,i=e.max_chain_length,a=e.strstart,s=e.prev_length,o=e.nice_match,l=e.strstart>e.w_size-262?e.strstart-(e.w_size-262):0,c=e.window,u=e.w_mask,d=e.prev,f=e.strstart+258,h=c[a+s-1],p=c[a+s];e.prev_length>=e.good_match&&(i>>=2),o>e.lookahead&&(o=e.lookahead);do{if(c[(r=t)+s]!==p||c[r+s-1]!==h||c[r]!==c[a]||c[++r]!==c[a+1])continue;a+=2,r++;do;while(c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&a<f)if(n=258-(f-a),a=f-258,n>s){if(e.match_start=t,s=n,n>=o)break;h=c[a+s-1],p=c[a+s]}}while((t=d[t&u])>l&&0!=--i)return s<=e.lookahead?s:e.lookahead},eS=e=>{let t,r,n,i,a,s=e.w_size;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=s+(s-262)){e.window.set(e.window.subarray(s,s+s),0),e.match_start-=s,e.strstart-=s,e.block_start-=s,t=r=e.hash_size;do n=e.head[--t],e.head[t]=n>=s?n-s:0;while(--r)t=r=s;do n=e.prev[--t],e.prev[t]=n>=s?n-s:0;while(--r)i+=s}if(0===e.strm.avail_in)break;if(r=ex(e.strm,e.window,e.strstart+e.lookahead,i),e.lookahead+=r,e.lookahead+e.insert>=3)for(a=e.strstart-e.insert,e.ins_h=e.window[a],e.ins_h=ey(e,e.ins_h,e.window[a+1]);e.insert&&(e.ins_h=ey(e,e.ins_h,e.window[a+3-1]),e.prev[a&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=a,a++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<262&&0!==e.strm.avail_in)},eE=(e,t)=>{let r,n;for(;;){if(e.lookahead<262){if(eS(e),e.lookahead<262&&t===V)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=ey(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==r&&e.strstart-r<=e.w_size-262&&(e.match_length=ek(e,r)),e.match_length>=3)if(n=z(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do e.strstart++,e.ins_h=ey(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;while(0!=--e.match_length)e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=ey(e,e.ins_h,e.window[e.strstart+1]);else n=z(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(ev(e,!1),0===e.strm.avail_out))return 1}return(e.insert=e.strstart<2?e.strstart:2,t===Q)?(ev(e,!0),0===e.strm.avail_out)?3:4:e.last_lit&&(ev(e,!1),0===e.strm.avail_out)?1:2},eI=(e,t)=>{let r,n,i;for(;;){if(e.lookahead<262){if(eS(e),e.lookahead<262&&t===V)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=ey(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==r&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-262&&(e.match_length=ek(e,r),e.match_length<=5&&(e.strategy===es||3===e.match_length&&e.strstart-e.match_start>4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-3,n=z(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=i&&(e.ins_h=ey(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart);while(0!=--e.prev_length)if(e.match_available=0,e.match_length=2,e.strstart++,n&&(ev(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if((n=z(e,0,e.window[e.strstart-1]))&&ev(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return(e.match_available&&(n=z(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Q)?(ev(e,!0),0===e.strm.avail_out)?3:4:e.last_lit&&(ev(e,!1),0===e.strm.avail_out)?1:2};function e$(e,t,r,n,i){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=n,this.func=i}let eO=[new e$(0,0,0,0,(e,t)=>{let r=65535;for(65535>e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(eS(e),0===e.lookahead&&t===V)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;let n=e.block_start+r;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,ev(e,!1),0===e.strm.avail_out)||e.strstart-e.block_start>=e.w_size-262&&(ev(e,!1),0===e.strm.avail_out))return 1}return(e.insert=0,t===Q)?(ev(e,!0),0===e.strm.avail_out)?3:4:(e.strstart>e.block_start&&(ev(e,!1),e.strm.avail_out),1)}),new e$(4,4,8,4,eE),new e$(4,5,16,8,eE),new e$(4,6,32,32,eE),new e$(4,4,16,16,eI),new e$(8,16,32,32,eI),new e$(8,16,128,128,eI),new e$(8,32,128,256,eI),new e$(32,128,258,1024,eI),new e$(32,258,258,4096,eI)];function eT(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=ef,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(2*eh),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),eg(this.dyn_ltree),eg(this.dyn_dtree),eg(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),eg(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),eg(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}var eA=(e,t)=>{let r,n;if(!e||!e.state||t>Z||t<0)return e?ep(e,er):er;let i=e.state;if(!e.output||!e.input&&0!==e.avail_in||666===i.status&&t!==Q)return ep(e,0===e.avail_out?ei:er);i.strm=e;let a=i.last_flush;if(i.last_flush=t,42===i.status)if(2===i.wrap)e.adler=0,ew(i,31),ew(i,139),ew(i,8),i.gzhead?(ew(i,+!!i.gzhead.text+2*!!i.gzhead.hcrc+4*!!i.gzhead.extra+8*!!i.gzhead.name+16*!!i.gzhead.comment),ew(i,255&i.gzhead.time),ew(i,i.gzhead.time>>8&255),ew(i,i.gzhead.time>>16&255),ew(i,i.gzhead.time>>24&255),ew(i,9===i.level?2:4*(i.strategy>=eo||i.level<2)),ew(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(ew(i,255&i.gzhead.extra.length),ew(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=B(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(ew(i,0),ew(i,0),ew(i,0),ew(i,0),ew(i,0),ew(i,9===i.level?2:4*(i.strategy>=eo||i.level<2)),ew(i,3),i.status=113);else{let t=ef+(i.w_bits-8<<4)<<8;t|=(i.strategy>=eo||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(t|=32),t+=31-t%31,i.status=113,e_(i,t),0!==i.strstart&&(e_(i,e.adler>>>16),e_(i,65535&e.adler)),e.adler=1}if(69===i.status)if(i.gzhead.extra){for(r=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>r&&(e.adler=B(e.adler,i.pending_buf,i.pending-r,r)),eb(e),r=i.pending,i.pending!==i.pending_buf_size));)ew(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>r&&(e.adler=B(e.adler,i.pending_buf,i.pending-r,r)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){r=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(e.adler=B(e.adler,i.pending_buf,i.pending-r,r)),eb(e),r=i.pending,i.pending===i.pending_buf_size)){n=1;break}n=i.gzindex<i.gzhead.name.length?255&i.gzhead.name.charCodeAt(i.gzindex++):0,ew(i,n)}while(0!==n)i.gzhead.hcrc&&i.pending>r&&(e.adler=B(e.adler,i.pending_buf,i.pending-r,r)),0===n&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){r=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(e.adler=B(e.adler,i.pending_buf,i.pending-r,r)),eb(e),r=i.pending,i.pending===i.pending_buf_size)){n=1;break}n=i.gzindex<i.gzhead.comment.length?255&i.gzhead.comment.charCodeAt(i.gzindex++):0,ew(i,n)}while(0!==n)i.gzhead.hcrc&&i.pending>r&&(e.adler=B(e.adler,i.pending_buf,i.pending-r,r)),0===n&&(i.status=103)}else i.status=103;if(103===i.status&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&eb(e),i.pending+2<=i.pending_buf_size&&(ew(i,255&e.adler),ew(i,e.adler>>8&255),e.adler=0,i.status=113)):i.status=113),0!==i.pending){if(eb(e),0===e.avail_out)return i.last_flush=-1,ee}else if(0===e.avail_in&&em(t)<=em(a)&&t!==Q)return ep(e,ei);if(666===i.status&&0!==e.avail_in)return ep(e,ei);if(0!==e.avail_in||0!==i.lookahead||t!==V&&666!==i.status){let r=i.strategy===eo?((e,t)=>{let r;for(;;){if(0===e.lookahead&&(eS(e),0===e.lookahead)){if(t===V)return 1;break}if(e.match_length=0,r=z(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(ev(e,!1),0===e.strm.avail_out))return 1}return(e.insert=0,t===Q)?(ev(e,!0),0===e.strm.avail_out)?3:4:e.last_lit&&(ev(e,!1),0===e.strm.avail_out)?1:2})(i,t):i.strategy===el?((e,t)=>{let r,n,i,a,s=e.window;for(;;){if(e.lookahead<=258){if(eS(e),e.lookahead<=258&&t===V)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(n=s[i=e.strstart-1])===s[++i]&&n===s[++i]&&n===s[++i]){a=e.strstart+258;do;while(n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&i<a)e.match_length=258-(a-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(r=z(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=z(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(ev(e,!1),0===e.strm.avail_out))return 1}return(e.insert=0,t===Q)?(ev(e,!0),0===e.strm.avail_out)?3:4:e.last_lit&&(ev(e,!1),0===e.strm.avail_out)?1:2})(i,t):eO[i.level].func(i,t);if((3===r||4===r)&&(i.status=666),1===r||3===r)return 0===e.avail_out&&(i.last_flush=-1),ee;if(2===r&&(t===K?G(i):t!==Z&&(X(i,0,0,!1),t===H&&(eg(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),eb(e),0===e.avail_out))return i.last_flush=-1,ee}return t!==Q?ee:i.wrap<=0?et:(2===i.wrap?(ew(i,255&e.adler),ew(i,e.adler>>8&255),ew(i,e.adler>>16&255),ew(i,e.adler>>24&255),ew(i,255&e.total_in),ew(i,e.total_in>>8&255),ew(i,e.total_in>>16&255),ew(i,e.total_in>>24&255)):(e_(i,e.adler>>>16),e_(i,65535&e.adler)),eb(e),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?ee:et)},eC=e=>{if(!e||!e.state)return er;let t=e.state.status;return 42!==t&&69!==t&&73!==t&&91!==t&&103!==t&&113!==t&&666!==t?ep(e,er):(e.state=null,113===t?ep(e,en):ee)};let eN=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var eM=function(e){let t=Array.prototype.slice.call(arguments,1);for(;t.length;){let r=t.shift();if(r){if("object"!=typeof r)throw TypeError(r+"must be non-object");for(let t in r)eN(r,t)&&(e[t]=r[t])}}return e},eP=e=>{let t=0;for(let r=0,n=e.length;r<n;r++)t+=e[r].length;let r=new Uint8Array(t);for(let t=0,n=0,i=e.length;t<i;t++){let i=e[t];r.set(i,n),n+=i.length}return r};let eR=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){eR=!1}let ej=new Uint8Array(256);for(let e=0;e<256;e++)ej[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;ej[254]=ej[254]=1;var eD=e=>{let t,r,n,i,a,s=e.length,o=0;for(i=0;i<s;i++)(64512&(r=e.charCodeAt(i)))==55296&&i+1<s&&(64512&(n=e.charCodeAt(i+1)))==56320&&(r=65536+(r-55296<<10)+(n-56320),i++),o+=r<128?1:r<2048?2:r<65536?3:4;for(t=new Uint8Array(o),a=0,i=0;a<o;i++)(64512&(r=e.charCodeAt(i)))==55296&&i+1<s&&(64512&(n=e.charCodeAt(i+1)))==56320&&(r=65536+(r-55296<<10)+(n-56320),i++),r<128?t[a++]=r:(r<2048?t[a++]=192|r>>>6:(r<65536?t[a++]=224|r>>>12:(t[a++]=240|r>>>18,t[a++]=128|r>>>12&63),t[a++]=128|r>>>6&63),t[a++]=128|63&r);return t},eL=(e,t)=>{let r,n,i=t||e.length,a=Array(2*i);for(n=0,r=0;r<i;){let t=e[r++];if(t<128){a[n++]=t;continue}let s=ej[t];if(s>4){a[n++]=65533,r+=s-1;continue}for(t&=2===s?31:3===s?15:7;s>1&&r<i;)t=t<<6|63&e[r++],s--;if(s>1){a[n++]=65533;continue}t<65536?a[n++]=t:(t-=65536,a[n++]=55296|t>>10&1023,a[n++]=56320|1023&t)}var s=n;if(s<65534&&a.subarray&&eR)return String.fromCharCode.apply(null,a.length===s?a:a.subarray(0,s));let o="";for(let e=0;e<s;e++)o+=String.fromCharCode(a[e]);return o},eU=(e,t)=>{(t=t||e.length)>e.length&&(t=e.length);let r=t-1;for(;r>=0&&(192&e[r])==128;)r--;return r<0||0===r?t:r+ej[e[r]]>t?r:t},eF=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};let eB=Object.prototype.toString,{Z_NO_FLUSH:eY,Z_SYNC_FLUSH:eW,Z_FULL_FLUSH:eq,Z_FINISH:eX,Z_OK:eJ,Z_STREAM_END:ez,Z_DEFAULT_COMPRESSION:eG,Z_DEFAULT_STRATEGY:eV,Z_DEFLATED:eK}=W;function eH(e){let t,r;this.options=eM({level:eG,method:eK,chunkSize:16384,windowBits:15,memLevel:8,strategy:eV},e||{});let n=this.options;n.raw&&n.windowBits>0?n.windowBits=-n.windowBits:n.gzip&&n.windowBits>0&&n.windowBits<16&&(n.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new eF,this.strm.avail_out=0;let i=((e,t,r,n,i,a)=>{var s,o;let l;if(!e)return er;let c=1;if(t===ea&&(t=6),n<0?(c=0,n=-n):n>15&&(c=2,n-=16),i<1||i>9||r!==ef||n<8||n>15||t<0||t>9||a<0||a>ec)return ep(e,er);8===n&&(n=9);let u=new eT;return e.state=u,u.strm=e,u.wrap=c,u.gzhead=null,u.w_bits=n,u.w_size=1<<u.w_bits,u.w_mask=u.w_size-1,u.hash_bits=i+7,u.hash_size=1<<u.hash_bits,u.hash_mask=u.hash_size-1,u.hash_shift=~~((u.hash_bits+3-1)/3),u.window=new Uint8Array(2*u.w_size),u.head=new Uint16Array(u.hash_size),u.prev=new Uint16Array(u.w_size),u.lit_bufsize=1<<i+6,u.pending_buf_size=4*u.lit_bufsize,u.pending_buf=new Uint8Array(u.pending_buf_size),u.d_buf=+u.lit_bufsize,u.l_buf=3*u.lit_bufsize,u.level=t,u.strategy=a,u.method=r,(l=(e=>{if(!e||!e.state)return ep(e,er);e.total_in=e.total_out=0,e.data_type=ed;let t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?42:113,e.adler=+(2!==t.wrap),t.last_flush=V,q(t),ee})(s=e))===ee&&((o=s.state).window_size=2*o.w_size,eg(o.head),o.max_lazy_match=eO[o.level].max_lazy,o.good_match=eO[o.level].good_length,o.nice_match=eO[o.level].nice_length,o.max_chain_length=eO[o.level].max_chain,o.strstart=0,o.block_start=0,o.lookahead=0,o.insert=0,o.match_length=o.prev_length=2,o.match_available=0,o.ins_h=0),l})(this.strm,n.level,n.method,n.windowBits,n.memLevel,n.strategy);if(i!==eJ)throw Error(Y[i]);if(n.header&&(t=this.strm,r=n.header,t&&t.state&&2===t.state.wrap&&(t.state.gzhead=r)),n.dictionary){let e;if(e="string"==typeof n.dictionary?eD(n.dictionary):"[object ArrayBuffer]"===eB.call(n.dictionary)?new Uint8Array(n.dictionary):n.dictionary,(i=((e,t)=>{let r=t.length;if(!e||!e.state)return er;let n=e.state,i=n.wrap;if(2===i||1===i&&42!==n.status||n.lookahead)return er;if(1===i&&(e.adler=U(e.adler,t,r,0)),n.wrap=0,r>=n.w_size){0===i&&(eg(n.head),n.strstart=0,n.block_start=0,n.insert=0);let e=new Uint8Array(n.w_size);e.set(t.subarray(r-n.w_size,r),0),t=e,r=n.w_size}let a=e.avail_in,s=e.next_in,o=e.input;for(e.avail_in=r,e.next_in=0,e.input=t,eS(n);n.lookahead>=3;){let e=n.strstart,t=n.lookahead-2;do n.ins_h=ey(n,n.ins_h,n.window[e+3-1]),n.prev[e&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=e,e++;while(--t)n.strstart=e,n.lookahead=2,eS(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,e.next_in=s,e.input=o,e.avail_in=a,n.wrap=i,ee})(this.strm,e))!==eJ)throw Error(Y[i]);this._dict_set=!0}}function eQ(e,t){let r=new eH(t);if(r.push(e,!0),r.err)throw r.msg||Y[r.err];return r.result}eH.prototype.push=function(e,t){let r,n,i=this.strm,a=this.options.chunkSize;if(this.ended)return!1;for(n=t===~~t?t:!0===t?eX:eY,"string"==typeof e?i.input=eD(e):"[object ArrayBuffer]"===eB.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;){if(0===i.avail_out&&(i.output=new Uint8Array(a),i.next_out=0,i.avail_out=a),(n===eW||n===eq)&&i.avail_out<=6){this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;continue}if((r=eA(i,n))===ez)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),r=eC(this.strm),this.onEnd(r),this.ended=!0,r===eJ;if(0===i.avail_out){this.onData(i.output);continue}if(n>0&&i.next_out>0){this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;continue}if(0===i.avail_in)break}return!0},eH.prototype.onData=function(e){this.chunks.push(e)},eH.prototype.onEnd=function(e){e===eJ&&(this.result=eP(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var eZ=function(e,t){let r,n,i,a,s,o,l,c,u,d,f,h,p,m,g,y,b,v,w,_,x,k,S,E,I=e.state;r=e.next_in,S=e.input,n=r+(e.avail_in-5),i=e.next_out,E=e.output,a=i-(t-e.avail_out),s=i+(e.avail_out-257),o=I.dmax,l=I.wsize,c=I.whave,u=I.wnext,d=I.window,f=I.hold,h=I.bits,p=I.lencode,m=I.distcode,g=(1<<I.lenbits)-1,y=(1<<I.distbits)-1;r:do for(h<15&&(f+=S[r++]<<h,h+=8,f+=S[r++]<<h,h+=8),b=p[f&g];;){if(f>>>=v=b>>>24,h-=v,0==(v=b>>>16&255))E[i++]=65535&b;else if(16&v)for(w=65535&b,(v&=15)&&(h<v&&(f+=S[r++]<<h,h+=8),w+=f&(1<<v)-1,f>>>=v,h-=v),h<15&&(f+=S[r++]<<h,h+=8,f+=S[r++]<<h,h+=8),b=m[f&y];;){if(f>>>=v=b>>>24,h-=v,16&(v=b>>>16&255)){if(_=65535&b,h<(v&=15)&&(f+=S[r++]<<h,(h+=8)<v&&(f+=S[r++]<<h,h+=8)),(_+=f&(1<<v)-1)>o){e.msg="invalid distance too far back",I.mode=30;break r}if(f>>>=v,h-=v,_>(v=i-a)){if((v=_-v)>c&&I.sane){e.msg="invalid distance too far back",I.mode=30;break r}if(x=0,k=d,0===u){if(x+=l-v,v<w){w-=v;do E[i++]=d[x++];while(--v)x=i-_,k=E}}else if(u<v){if(x+=l+u-v,(v-=u)<w){w-=v;do E[i++]=d[x++];while(--v)if(x=0,u<w){w-=v=u;do E[i++]=d[x++];while(--v)x=i-_,k=E}}}else if(x+=u-v,v<w){w-=v;do E[i++]=d[x++];while(--v)x=i-_,k=E}for(;w>2;)E[i++]=k[x++],E[i++]=k[x++],E[i++]=k[x++],w-=3;w&&(E[i++]=k[x++],w>1&&(E[i++]=k[x++]))}else{x=i-_;do E[i++]=E[x++],E[i++]=E[x++],E[i++]=E[x++],w-=3;while(w>2)w&&(E[i++]=E[x++],w>1&&(E[i++]=E[x++]))}}else if((64&v)==0){b=m[(65535&b)+(f&(1<<v)-1)];continue}else{e.msg="invalid distance code",I.mode=30;break r}break}else if((64&v)==0){b=p[(65535&b)+(f&(1<<v)-1)];continue}else if(32&v){I.mode=12;break r}else{e.msg="invalid literal/length code",I.mode=30;break r}break}while(r<n&&i<s)r-=w=h>>3,h-=w<<3,f&=(1<<h)-1,e.next_in=r,e.next_out=i,e.avail_in=r<n?5+(n-r):5-(r-n),e.avail_out=i<s?257+(s-i):257-(i-s),I.hold=f,I.bits=h};let e0=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),e1=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),e2=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),e5=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var e3=(e,t,r,n,i,a,s,o)=>{let l,c,u,d,f,h,p,m,g,y=o.bits,b=0,v=0,w=0,_=0,x=0,k=0,S=0,E=0,I=0,$=0,O=null,T=0,A=new Uint16Array(16),C=new Uint16Array(16),N=null,M=0;for(b=0;b<=15;b++)A[b]=0;for(v=0;v<n;v++)A[t[r+v]]++;for(x=y,_=15;_>=1&&0===A[_];_--);if(x>_&&(x=_),0===_)return i[a++]=0x1400000,i[a++]=0x1400000,o.bits=1,0;for(w=1;w<_&&0===A[w];w++);for(x<w&&(x=w),E=1,b=1;b<=15;b++)if(E<<=1,(E-=A[b])<0)return -1;if(E>0&&(0===e||1!==_))return -1;for(C[1]=0,b=1;b<15;b++)C[b+1]=C[b]+A[b];for(v=0;v<n;v++)0!==t[r+v]&&(s[C[t[r+v]]++]=v);if(0===e?(O=N=s,h=19):1===e?(O=e0,T-=257,N=e1,M-=257,h=256):(O=e2,N=e5,h=-1),$=0,v=0,b=w,f=a,k=x,S=0,u=-1,d=(I=1<<x)-1,1===e&&I>852||2===e&&I>592)return 1;for(;;){p=b-S,s[v]<h?(m=0,g=s[v]):s[v]>h?(m=N[M+s[v]],g=O[T+s[v]]):(m=96,g=0),l=1<<b-S,w=c=1<<k;do i[f+($>>S)+(c-=l)]=p<<24|m<<16|g;while(0!==c)for(l=1<<b-1;$&l;)l>>=1;if(0!==l?($&=l-1,$+=l):$=0,v++,0==--A[b]){if(b===_)break;b=t[r+s[v]]}if(b>x&&($&d)!==u){for(0===S&&(S=x),f+=w,E=1<<(k=b-S);k+S<_&&!((E-=A[k+S])<=0);)k++,E<<=1;if(I+=1<<k,1===e&&I>852||2===e&&I>592)return 1;i[u=$&d]=x<<24|k<<16|f-a}}return 0!==$&&(i[f+$]=b-S<<24|4194304),o.bits=x,0};let{Z_FINISH:e8,Z_BLOCK:e6,Z_TREES:e9,Z_OK:e4,Z_STREAM_END:e7,Z_NEED_DICT:te,Z_STREAM_ERROR:tt,Z_DATA_ERROR:tr,Z_MEM_ERROR:tn,Z_BUF_ERROR:ti,Z_DEFLATED:ta}=W,ts=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function to(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}let tl=e=>{if(!e||!e.state)return tt;let t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,(e=>{if(!e||!e.state)return tt;let t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,e4})(e)},tc=!0,tu=e=>{if(tc){s=new Int32Array(512),o=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(e3(1,e.lens,0,288,s,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;e3(2,e.lens,0,32,o,0,e.work,{bits:5}),tc=!1}e.lencode=s,e.lenbits=9,e.distcode=o,e.distbits=5},td=(e,t,r,n)=>{let i,a=e.state;return null===a.window&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new Uint8Array(a.wsize)),n>=a.wsize?(a.window.set(t.subarray(r-a.wsize,r),0),a.wnext=0,a.whave=a.wsize):((i=a.wsize-a.wnext)>n&&(i=n),a.window.set(t.subarray(r-n,r-n+i),a.wnext),(n-=i)?(a.window.set(t.subarray(r-n,r),0),a.wnext=n,a.whave=a.wsize):(a.wnext+=i,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=i))),0};var tf=(e,t)=>{let r,n,i,a,s,o,l,c,u,d,f,h,p,m,g,y,b,v,w,_,x,k,S,E,I=0,$=new Uint8Array(4),O=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return tt;12===(r=e.state).mode&&(r.mode=13),s=e.next_out,i=e.output,l=e.avail_out,a=e.next_in,n=e.input,o=e.avail_in,c=r.hold,u=r.bits,d=o,f=l,k=e4;n:for(;;)switch(r.mode){case 1:if(0===r.wrap){r.mode=13;break}for(;u<16;){if(0===o)break n;o--,c+=n[a++]<<u,u+=8}if(2&r.wrap&&35615===c){r.check=0,$[0]=255&c,$[1]=c>>>8&255,r.check=B(r.check,$,2,0),c=0,u=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&c)<<8)+(c>>8))%31){e.msg="incorrect header check",r.mode=30;break}if((15&c)!==ta){e.msg="unknown compression method",r.mode=30;break}if(c>>>=4,u-=4,x=(15&c)+8,0===r.wbits)r.wbits=x;else if(x>r.wbits){e.msg="invalid window size",r.mode=30;break}r.dmax=1<<r.wbits,e.adler=r.check=1,r.mode=512&c?10:12,c=0,u=0;break;case 2:for(;u<16;){if(0===o)break n;o--,c+=n[a++]<<u,u+=8}if(r.flags=c,(255&r.flags)!==ta){e.msg="unknown compression method",r.mode=30;break}if(57344&r.flags){e.msg="unknown header flags set",r.mode=30;break}r.head&&(r.head.text=c>>8&1),512&r.flags&&($[0]=255&c,$[1]=c>>>8&255,r.check=B(r.check,$,2,0)),c=0,u=0,r.mode=3;case 3:for(;u<32;){if(0===o)break n;o--,c+=n[a++]<<u,u+=8}r.head&&(r.head.time=c),512&r.flags&&($[0]=255&c,$[1]=c>>>8&255,$[2]=c>>>16&255,$[3]=c>>>24&255,r.check=B(r.check,$,4,0)),c=0,u=0,r.mode=4;case 4:for(;u<16;){if(0===o)break n;o--,c+=n[a++]<<u,u+=8}r.head&&(r.head.xflags=255&c,r.head.os=c>>8),512&r.flags&&($[0]=255&c,$[1]=c>>>8&255,r.check=B(r.check,$,2,0)),c=0,u=0,r.mode=5;case 5:if(1024&r.flags){for(;u<16;){if(0===o)break n;o--,c+=n[a++]<<u,u+=8}r.length=c,r.head&&(r.head.extra_len=c),512&r.flags&&($[0]=255&c,$[1]=c>>>8&255,r.check=B(r.check,$,2,0)),c=0,u=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&((h=r.length)>o&&(h=o),h&&(r.head&&(x=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(n.subarray(a,a+h),x)),512&r.flags&&(r.check=B(r.check,n,h,a)),o-=h,a+=h,r.length-=h),r.length))break n;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===o)break n;h=0;do x=n[a+h++],r.head&&x&&r.length<65536&&(r.head.name+=String.fromCharCode(x));while(x&&h<o)if(512&r.flags&&(r.check=B(r.check,n,h,a)),o-=h,a+=h,x)break n}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&r.flags){if(0===o)break n;h=0;do x=n[a+h++],r.head&&x&&r.length<65536&&(r.head.comment+=String.fromCharCode(x));while(x&&h<o)if(512&r.flags&&(r.check=B(r.check,n,h,a)),o-=h,a+=h,x)break n}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&r.flags){for(;u<16;){if(0===o)break n;o--,c+=n[a++]<<u,u+=8}if(c!==(65535&r.check)){e.msg="header crc mismatch",r.mode=30;break}c=0,u=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=12;break;case 10:for(;u<32;){if(0===o)break n;o--,c+=n[a++]<<u,u+=8}e.adler=r.check=ts(c),c=0,u=0,r.mode=11;case 11:if(0===r.havedict)return e.next_out=s,e.avail_out=l,e.next_in=a,e.avail_in=o,r.hold=c,r.bits=u,te;e.adler=r.check=1,r.mode=12;case 12:if(t===e6||t===e9)break n;case 13:if(r.last){c>>>=7&u,u-=7&u,r.mode=27;break}for(;u<3;){if(0===o)break n;o--,c+=n[a++]<<u,u+=8}switch(r.last=1&c,u-=1,3&(c>>>=1)){case 0:r.mode=14;break;case 1:if(tu(r),r.mode=20,t===e9){c>>>=2,u-=2;break n}break;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=30}c>>>=2,u-=2;break;case 14:for(c>>>=7&u,u-=7&u;u<32;){if(0===o)break n;o--,c+=n[a++]<<u,u+=8}if((65535&c)!=(c>>>16^65535)){e.msg="invalid stored block lengths",r.mode=30;break}if(r.length=65535&c,c=0,u=0,r.mode=15,t===e9)break n;case 15:r.mode=16;case 16:if(h=r.length){if(h>o&&(h=o),h>l&&(h=l),0===h)break n;i.set(n.subarray(a,a+h),s),o-=h,a+=h,l-=h,s+=h,r.length-=h;break}r.mode=12;break;case 17:for(;u<14;){if(0===o)break n;o--,c+=n[a++]<<u,u+=8}if(r.nlen=(31&c)+257,u-=5,r.ndist=(31&(c>>>=5))+1,u-=5,r.ncode=(15&(c>>>=5))+4,c>>>=4,u-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=30;break}r.have=0,r.mode=18;case 18:for(;r.have<r.ncode;){for(;u<3;){if(0===o)break n;o--,c+=n[a++]<<u,u+=8}r.lens[O[r.have++]]=7&c,c>>>=3,u-=3}for(;r.have<19;)r.lens[O[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,S={bits:r.lenbits},k=e3(0,r.lens,0,19,r.lencode,0,r.work,S),r.lenbits=S.bits,k){e.msg="invalid code lengths set",r.mode=30;break}r.have=0,r.mode=19;case 19:for(;r.have<r.nlen+r.ndist;){for(;g=(I=r.lencode[c&(1<<r.lenbits)-1])>>>24,y=I>>>16&255,b=65535&I,!(g<=u);){if(0===o)break n;o--,c+=n[a++]<<u,u+=8}if(b<16)c>>>=g,u-=g,r.lens[r.have++]=b;else{if(16===b){for(E=g+2;u<E;){if(0===o)break n;o--,c+=n[a++]<<u,u+=8}if(c>>>=g,u-=g,0===r.have){e.msg="invalid bit length repeat",r.mode=30;break}x=r.lens[r.have-1],h=3+(3&c),c>>>=2,u-=2}else if(17===b){for(E=g+3;u<E;){if(0===o)break n;o--,c+=n[a++]<<u,u+=8}c>>>=g,u-=g,x=0,h=3+(7&c),c>>>=3,u-=3}else{for(E=g+7;u<E;){if(0===o)break n;o--,c+=n[a++]<<u,u+=8}c>>>=g,u-=g,x=0,h=11+(127&c),c>>>=7,u-=7}if(r.have+h>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=30;break}for(;h--;)r.lens[r.have++]=x}}if(30===r.mode)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=30;break}if(r.lenbits=9,S={bits:r.lenbits},k=e3(1,r.lens,0,r.nlen,r.lencode,0,r.work,S),r.lenbits=S.bits,k){e.msg="invalid literal/lengths set",r.mode=30;break}if(r.distbits=6,r.distcode=r.distdyn,S={bits:r.distbits},k=e3(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,S),r.distbits=S.bits,k){e.msg="invalid distances set",r.mode=30;break}if(r.mode=20,t===e9)break n;case 20:r.mode=21;case 21:if(o>=6&&l>=258){e.next_out=s,e.avail_out=l,e.next_in=a,e.avail_in=o,r.hold=c,r.bits=u,eZ(e,f),s=e.next_out,i=e.output,l=e.avail_out,a=e.next_in,n=e.input,o=e.avail_in,c=r.hold,u=r.bits,12===r.mode&&(r.back=-1);break}for(r.back=0;g=(I=r.lencode[c&(1<<r.lenbits)-1])>>>24,y=I>>>16&255,b=65535&I,!(g<=u);){if(0===o)break n;o--,c+=n[a++]<<u,u+=8}if(y&&(240&y)==0){for(v=g,w=y,_=b;g=(I=r.lencode[_+((c&(1<<v+w)-1)>>v)])>>>24,y=I>>>16&255,b=65535&I,!(v+g<=u);){if(0===o)break n;o--,c+=n[a++]<<u,u+=8}c>>>=v,u-=v,r.back+=v}if(c>>>=g,u-=g,r.back+=g,r.length=b,0===y){r.mode=26;break}if(32&y){r.back=-1,r.mode=12;break}if(64&y){e.msg="invalid literal/length code",r.mode=30;break}r.extra=15&y,r.mode=22;case 22:if(r.extra){for(E=r.extra;u<E;){if(0===o)break n;o--,c+=n[a++]<<u,u+=8}r.length+=c&(1<<r.extra)-1,c>>>=r.extra,u-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;g=(I=r.distcode[c&(1<<r.distbits)-1])>>>24,y=I>>>16&255,b=65535&I,!(g<=u);){if(0===o)break n;o--,c+=n[a++]<<u,u+=8}if((240&y)==0){for(v=g,w=y,_=b;g=(I=r.distcode[_+((c&(1<<v+w)-1)>>v)])>>>24,y=I>>>16&255,b=65535&I,!(v+g<=u);){if(0===o)break n;o--,c+=n[a++]<<u,u+=8}c>>>=v,u-=v,r.back+=v}if(c>>>=g,u-=g,r.back+=g,64&y){e.msg="invalid distance code",r.mode=30;break}r.offset=b,r.extra=15&y,r.mode=24;case 24:if(r.extra){for(E=r.extra;u<E;){if(0===o)break n;o--,c+=n[a++]<<u,u+=8}r.offset+=c&(1<<r.extra)-1,c>>>=r.extra,u-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=30;break}r.mode=25;case 25:if(0===l)break n;if(h=f-l,r.offset>h){if((h=r.offset-h)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=30;break}h>r.wnext?(h-=r.wnext,p=r.wsize-h):p=r.wnext-h,h>r.length&&(h=r.length),m=r.window}else m=i,p=s-r.offset,h=r.length;h>l&&(h=l),l-=h,r.length-=h;do i[s++]=m[p++];while(--h)0===r.length&&(r.mode=21);break;case 26:if(0===l)break n;i[s++]=r.length,l--,r.mode=21;break;case 27:if(r.wrap){for(;u<32;){if(0===o)break n;o--,c|=n[a++]<<u,u+=8}if(f-=l,e.total_out+=f,r.total+=f,f&&(e.adler=r.check=r.flags?B(r.check,i,f,s-f):U(r.check,i,f,s-f)),f=l,(r.flags?c:ts(c))!==r.check){e.msg="incorrect data check",r.mode=30;break}c=0,u=0}r.mode=28;case 28:if(r.wrap&&r.flags){for(;u<32;){if(0===o)break n;o--,c+=n[a++]<<u,u+=8}if(c!==(0|r.total)){e.msg="incorrect length check",r.mode=30;break}c=0,u=0}r.mode=29;case 29:k=e7;break n;case 30:k=tr;break n;case 31:return tn;default:return tt}return e.next_out=s,e.avail_out=l,e.next_in=a,e.avail_in=o,r.hold=c,r.bits=u,(r.wsize||f!==e.avail_out&&r.mode<30&&(r.mode<27||t!==e8))&&td(e,e.output,e.next_out,f-e.avail_out),d-=e.avail_in,f-=e.avail_out,e.total_in+=d,e.total_out+=f,r.total+=f,r.wrap&&f&&(e.adler=r.check=r.flags?B(r.check,i,f,e.next_out-f):U(r.check,i,f,e.next_out-f)),e.data_type=r.bits+64*!!r.last+128*(12===r.mode)+256*(20===r.mode||15===r.mode),(0===d&&0===f||t===e8)&&k===e4&&(k=ti),k},th=e=>{if(!e||!e.state)return tt;let t=e.state;return t.window&&(t.window=null),e.state=null,e4},tp=(e,t)=>{let r,n=t.length;return e&&e.state&&(0===(r=e.state).wrap||11===r.mode)?11===r.mode&&U(1,t,n,0)!==r.check?tr:td(e,t,n,n)?(r.mode=31,tn):(r.havedict=1,e4):tt},tm=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};let tg=Object.prototype.toString,{Z_NO_FLUSH:ty,Z_FINISH:tb,Z_OK:tv,Z_STREAM_END:tw,Z_NEED_DICT:t_,Z_STREAM_ERROR:tx,Z_DATA_ERROR:tk,Z_MEM_ERROR:tS}=W;function tE(e){this.options=eM({chunkSize:65536,windowBits:15,to:""},e||{});let t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(e&&e.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(15&t.windowBits)==0&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new eF,this.strm.avail_out=0;let r=((e,t)=>{if(!e)return tt;let r=new to;e.state=r,r.window=null;let n=((e,t)=>{let r;if(!e||!e.state)return tt;let n=e.state;return(t<0?(r=0,t=-t):(r=(t>>4)+1,t<48&&(t&=15)),t&&(t<8||t>15))?tt:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,tl(e))})(e,t);return n!==e4&&(e.state=null),n})(this.strm,t.windowBits);if(r!==tv||(this.header=new tm,((e,t)=>{if(!e||!e.state)return;let r=e.state;return(2&r.wrap)==0||(r.head=t,t.done=!1)})(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=eD(t.dictionary):"[object ArrayBuffer]"===tg.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw)&&(r=tp(this.strm,t.dictionary))!==tv))throw Error(Y[r])}function tI(e,t){let r=new tE(t);if(r.push(e),r.err)throw r.msg||Y[r.err];return r.result}tE.prototype.push=function(e,t){let r,n,i,a=this.strm,s=this.options.chunkSize,o=this.options.dictionary;if(this.ended)return!1;for(n=t===~~t?t:!0===t?tb:ty,"[object ArrayBuffer]"===tg.call(e)?a.input=new Uint8Array(e):a.input=e,a.next_in=0,a.avail_in=a.input.length;;){for(0===a.avail_out&&(a.output=new Uint8Array(s),a.next_out=0,a.avail_out=s),(r=tf(a,n))===t_&&o&&((r=tp(a,o))===tv?r=tf(a,n):r===tk&&(r=t_));a.avail_in>0&&r===tw&&a.state.wrap>0&&0!==e[a.next_in];)tl(a),r=tf(a,n);switch(r){case tx:case tk:case t_:case tS:return this.onEnd(r),this.ended=!0,!1}if(i=a.avail_out,a.next_out&&(0===a.avail_out||r===tw))if("string"===this.options.to){let e=eU(a.output,a.next_out),t=a.next_out-e,r=eL(a.output,e);a.next_out=t,a.avail_out=s-t,t&&a.output.set(a.output.subarray(e,e+t),0),this.onData(r)}else this.onData(a.output.length===a.next_out?a.output:a.output.subarray(0,a.next_out));if(r!==tv||0!==i){if(r===tw)return r=th(this.strm),this.onEnd(r),this.ended=!0,!0;if(0===a.avail_in)break}}return!0},tE.prototype.onData=function(e){this.chunks.push(e)},tE.prototype.onEnd=function(e){e===tv&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=eP(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};let{Deflate:t$,deflate:tO,deflateRaw:tT,gzip:tA}={Deflate:eH,deflate:eQ,deflateRaw:function(e,t){return(t=t||{}).raw=!0,eQ(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,eQ(e,t)},constants:W},{Inflate:tC,inflate:tN,inflateRaw:tM,ungzip:tP}={Inflate:tE,inflate:tI,inflateRaw:function(e,t){return(t=t||{}).raw=!0,tI(e,t)},ungzip:tI,constants:W};r.d(t,{Gy:()=>t$,Kc:()=>tO,UD:()=>tN})},5810(e,t,r){let n;r.d(t,{Er:()=>t5,Ov:()=>rm,Tx:()=>rx,UA:()=>nV,yE:()=>tL,Ky:()=>e9,e5:()=>tE,Uh:()=>tP,OF:()=>iY,XV:()=>iF,r8:()=>iB,rR:()=>nK});var i=r(8861),a=r(8619),s=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=i.ukk,g=i.mSG(i.QfV,i.$r1),y=Object.freeze({paper:"#f6f1e7",card:"#fffdf8",ink:"#1a1712",accent:"#8f707f"}),b=Object.freeze({accentColor:y.accent,backgroundColor:y.card});function v(e,t){return e.pipe(i.tiU(s.PyW(t)))}function w(e,t){return i.svK(e,{errors:"all"})(t)}let _=u.ID();function x(e){return Object.assign(e,{parse:t=>w(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:_(r.failure.issue).issues.map(e=>({message:e.message,path:(e.path??[]).map(e=>"object"==typeof e?e.key:e)}))},success:!1}}})}let k=i.xCb(["flowchart","mindmap"]),S=i.xCb(["TB","BT","LR","RL"]),E=i.xCb(["straight","orthogonal","curved"]);class I extends i.Xsx("DiagramNode")({id:m,label:m,group:i.lqM(m),kind:i.lqM(m),metadata:v(g,{})}){}x(I);class $ extends i.Xsx("DiagramEdge")({id:m,source:m,target:m,label:i.lqM(m),metadata:v(g,{})}){}x($);let O=i.QfV.check(i.Pto(/^#[0-9a-fA-F]{6}$/));class T extends i.Xsx("DiagramStyle")({accentColor:v(O,b.accentColor),backgroundColor:v(O,b.backgroundColor)}){}x(T);class A extends i.Xsx("DiagramLayout")({direction:v(S,"LR"),edgeRouting:v(E,"orthogonal")}){}x(A);class C extends i.Xsx("IntermediateDiagram")({id:m,title:m,type:v(k,"flowchart"),nodes:i.O31(I).pipe(i.fXn).check(i.tJb(1)),edges:v(i.O31($).pipe(i.fXn),[]),layout:v(A,{direction:"LR",edgeRouting:"orthogonal"}),style:v(T,b),metadata:v(g,{})}){}x(C);class N extends Error{constructor(e){super(e),this.name="DiagramValidationError"}}let M=e=>{let t=new Set;for(let r of e){if(t.has(r))return r;t.add(r)}};function P(e){let t=M(e.nodes.map(e=>e.id));if(t)throw new N(`Duplicate node id "${t}" is not allowed.`);let r=M(e.edges.map(e=>e.id));if(r)throw new N(`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 N(`Edge "${t.id}" references missing source node "${t.source}".`);if(!n.has(t.target))throw new N(`Edge "${t.id}" references missing target node "${t.target}".`);if(t.source===t.target)throw new N(`Edge "${t.id}" cannot connect node "${t.source}" to itself.`)}return e}function R(e){return P(w(C,e))}let j="flowchart",D=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 L extends i.Xsx("FlowchartValidationIssueRef")({kind:i.xCb(["diagram","node","edge"]),id:i.lqM(i.ukk),path:i.lqM(i.ukk)}){}i.Xsx("FlowchartValidationIssue")({code:D,ref:i.lqM(L),message:i.ukk,hint:i.ukk});let U=i.xCb(["start","process","decision","end"]);class F extends I.extend("FlowchartNode")({kind:U,description:i.lqM(i.ukk)}){}class B extends $.extend("FlowchartEdge")({label:i.lqM(i.ukk)}){}class Y extends C.extend("FlowchartDiagram")({type:i.uSQ(j),nodes:i.O31(F).pipe(i.fXn).check(i.tJb(2)),edges:i.O31(B).pipe(i.fXn).check(i.tJb(1))}){}let W=x(Y);function q(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 X(e,t,r){let n=new Set,i=[...e];for(let e=0;e<i.length;e+=1){let a=i[e];if(!(void 0===a||n.has(a)))for(let e of(n.add(a),t.get(a)??[]))i.push(r(e))}return n}function J(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."}),q(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 q(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 a=e.nodes.filter(e=>"start"===e.kind),s=e.nodes.filter(e=>"end"===e.kind);for(let r of(0===a.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".'}):a.length>1&&t.push({code:"multiple_starts",ref:{kind:"diagram",id:e.id,path:"nodes"},message:`Flowchart has ${a.length} start nodes.`,hint:"Keep one start node and change the others to process, decision, or end."}),0===s.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)??[],a=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&&a.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===a.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 q(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,a))}let o=1===a.length?a[0]:void 0;if(o){let r=X([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(s.length>0){let a=X(s.map(e=>e.id),n,e=>e.source);for(let n of e.nodes)r.has(n.id)&&!a.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 z extends N{issues;constructor(e){super(e[0]?.message??"Flowchart failed semantic validation."),this.issues=e,this.name="FlowchartValidationError"}}function G(e){let t=J(e);if(t.length>0)throw new z(t);return e}let V=G(w(Y,{id:"onboarding-flow",title:"Sketchi onboarding decision flow",type:j,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"}}));G(w(Y,{id:"pharma-batch-disposition",title:"Pharma batch disposition flow",type:j,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"}}));let K="mindmap";class H extends i.Xsx("MindmapNodeMetadata")({depth:i.Aiz.check(i.OWK(0)),siblingIndex:i.Aiz.check(i.OWK(0))}){}class Q extends I.extend("MindmapNode")({kind:i.xCb(["root","topic"]),metadata:H}){}class Z extends i.Xsx("MindmapEdgeMetadata")({depth:i.Aiz.check(i.yJO(0)),siblingIndex:i.Aiz.check(i.OWK(0))}){}class ee extends $.extend("MindmapEdge")({metadata:Z}){}class et extends C.extend("MindmapDiagram")({type:i.uSQ(K),nodes:i.O31(Q).pipe(i.fXn).check(i.tJb(2)),edges:i.O31(ee).pipe(i.fXn).check(i.tJb(1))}){}function er(e){return function(e){P(e);let t=e.nodes.filter(e=>"root"===e.kind);if(1!==t.length)throw new N(`Mindmap must contain exactly one root topic; found ${t.length}.`);let r=t[0];if(!r||0!==r.metadata.depth)throw new N("Mindmap root topic must have depth 0.");let n=new Map,i=new Map(e.nodes.map(e=>[e.id,e])),a=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),s=r?.metadata.depth;if(void 0===e||s!==e+1)throw new N(`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 N(`Mindmap edge "${t.id}" metadata must match its child topic.`);a.set(t.source,[...a.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 N(`Mindmap topic "${t.id}" must have ${t.id===r.id?"no parent":"exactly one parent"}.`)}for(let[e,t]of a){let r=t.map((e,t)=>t);if([...t].sort((e,t)=>e-t).some((e,t)=>e!==r[t]))throw new N(`Mindmap children of "${e}" must use contiguous sibling ordering from 0.`)}return e}(w(et,e))}x(et);let en=er({id:"public-mindmap-capability",title:"Public mindmap generation",type:K,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"}});R(V),R(en);let ei=/[,;]\s*(?:id|label|kind|group|source|target|title|direction|nodes|edges)\s*:?\s*$/i;function ea(e){let t=e.trim();for(;;){let e=t.replace(ei,"").trim();if(e===t)return t;t=e}}class es extends i.Xsx("ContractSchemaIssue")({code:e_("custom"),message:i.QfV,path:i.O31(i.pHd)},{identifier:void 0}){}class eo extends i.X0d()("ContractSchemaError",{issues:i.O31(i.O3D(es))}){}let el=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}`},ec=u.ID({leafHook:el});function eu(e){return"string"==typeof e||"number"==typeof e||"symbol"==typeof e}function ed(e,t){let r,n=i.q$Z(e,{errors:"all"})(t);return f.oJ(n)?{data:n.success,success:!0}:{error:new eo({issues:(r=ec(n.failure.issue).issues.map(e=>{let t=(e.path??[]).flatMap(e=>{let t=eu(e)?e:null!==e&&"object"==typeof e&&"key"in e&&eu(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 ef(e){return Object.assign(e,{parse:t=>(function(e,t){let r=ed(e,t);if(r.success)return r.data;throw r.error})(e,t),safeParse:t=>ed(e,t)})}let eh=new Set(["const","exclusiveMaximum","exclusiveMinimum","maximum","maxLength","minimum","minItems","minLength","pattern"]);function ep(e){let t=i._oz(i.AxX(e),{includeAnnotationKey:e=>eh.has(e)});return{$schema:"https://json-schema.org/draft/2020-12/schema",...t.schema,...0===Object.keys(t.definitions).length?{}:{$defs:t.definitions}}}function em(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 eg(e){let t=i.hzj()([e],([e])=>(t,r,n)=>void 0===t?s.PyW(void 0):h._R(e)(t,n),{toCodecJson:([e])=>i.nfo()(e,{decode:p.le({strict:!1}),encode:new p.uB(e=>s.PyW(d.filter(e,e=>void 0!==e)))})});return i.Qrq(t)}function ey(e){return e.pipe(i.usV({messageMissingKey:"Invalid input: expected string, received undefined"}))}function eb(e){return e.pipe(i.usV({messageMissingKey:"Invalid input: expected object, received undefined"}))}function ev(e){return e.pipe(i.usV({messageMissingKey:"Invalid input: expected array, received undefined"}))}function ew(e){return i.xCb(e).annotate({message:`Invalid option: expected one of ${e.map(e=>JSON.stringify(e)).join("|")}`})}function e_(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 ex(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 ek(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 eS=i.QfV.annotate({minLength:1}).check(i.HNH(e=>e.length>=1,{message:"Too small: expected string to have >=1 characters"})),eE=ey(eS),eI=i.wYs,e$=i.wNn.annotate({exclusiveMinimum:0}).check(i.MIs(),i.HNH(e=>e>0,{message:"Too small: expected number to be >0"})),eO=/^#[0-9a-fA-F]{6}$/;function eT(e){return i.QfV.annotate({pattern:eO.source,...void 0===e?{}:{default:e}}).check(i.HNH(e=>eO.test(e),{message:`Invalid string: must match pattern /${eO.source}/`}))}let eA=eT();ef(eA);let eC=["excalidraw","scene","png"],eN=["excalidraw","scene"],eM=Object.assign(ef(ew(eC)),{options:eC}),eP=Object.assign(ef(ew(eN)),{options:eN});class eR extends i.Xsx("ArtifactProvenance")({sourceArtifactId:eE.pipe(i.Wa3)},{identifier:void 0}){}ef(eR);let ej=["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"],eD=Object.assign(ef(ew(ej)),{options:ej}),eL=ew(["request","diagram","node","edge","artifact"]),eU=ew(["input","flowchart","mindmap","quality","render","export","storage"]);class eF extends i.Xsx("CodeModeIssueRef")({kind:eL,id:eg(eS),path:eg(eS)},{identifier:void 0}){}ef(eF);class eB extends i.Xsx("CodeModeIssue")({code:eD,severity:ew(["error","warning"]),stage:eU,ref:eg(eF),message:eE,hint:eE},{identifier:void 0}){}ef(eB);let eY=["start","process","decision","end"],eW=Object.assign(ef(ew(eY)),{options:eY}),eq=["setDefaultStyle","setStyle","setShape","translate","replaceText","rerouteEdges"];Object.assign(ef(ew(eq)),{options:eq});class eX extends i.Xsx("FlowchartSpecNode")({id:eE,label:eE,kind:eW,description:eg(eS)},{identifier:void 0}){}class eJ extends i.Xsx("FlowchartSpecEdge")({id:eg(eS),source:eE,target:eE,label:eg(eS)},{identifier:void 0}){}let ez=ew(["TB","LR"]),eG=ez.annotate({default:"TB"}).pipe(i.tiU(s.PyW("TB")));class eV extends i.Xsx("FlowchartSpecLayout")({direction:eG},{identifier:void 0}){}let eK=b.accentColor,eH=eT(eK).pipe(i.tiU(s.PyW(eK))),eQ=b.backgroundColor,eZ=eT(eQ).pipe(i.tiU(s.PyW(eQ)));class e0 extends i.Xsx("FlowchartSpecStyle")({accentColor:eH,backgroundColor:eZ},{identifier:void 0}){}let e1=[],e2=i.O31(eJ).pipe(i.fXn).annotate({default:e1}).pipe(i.tiU(s.PyW(e1))),e5={direction:"TB"},e3=eV.annotate({default:e5}).pipe(i.tiU(s.PyW(e5))),e8={accentColor:b.accentColor,backgroundColor:b.backgroundColor},e6=e0.annotate({default:e8}).pipe(i.tiU(s.PyW(e8)));class e9 extends i.Xsx("FlowchartSpec")({id:eg(eS),title:eE,nodes:ev(em(eX)),edges:e2,layout:e3,style:e6},{identifier:void 0}){}ef(e9),ef(eX),ef(eJ),ef(eV),ef(e0);class e4 extends i.Xsx("SequenceParticipantSpec")({id:eE,label:eE,kind:eg(eS)},{identifier:void 0}){}class e7 extends i.Xsx("SequenceMessageSpec")({id:eg(eS),source:eE,target:eE,label:eE,type:eg(ew(["message","return"])),style:eg(ew(["solid","dashed"]))},{identifier:void 0}){}let te=[],tt=i.O31(e7).pipe(i.fXn).annotate({default:te}).pipe(i.tiU(s.PyW(te))),tr={accentColor:b.accentColor,backgroundColor:b.backgroundColor},tn=i._kM({accentColor:eT(eK).pipe(i.tiU(s.PyW(eK))),backgroundColor:eT(eQ).pipe(i.tiU(s.PyW(eQ)))}).annotate({default:tr}).pipe(i.tiU(s.PyW(tr)));class ti extends i.Xsx("SequenceDiagramSpec")({id:eg(eS),title:eE,participants:ev(em(e4)),messages:tt,style:tn},{identifier:void 0}){}ef(ti),ef(e4),ef(e7);let ta=eg(em(eM)),ts=eg(i.O31(eP).pipe(i.fXn)),to=eg(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 tl extends i.Xsx("BuildFlowchartOptions")({artifactFormats:ta,inlineArtifacts:ts,minQualityScore:to},{identifier:void 0}){}ef(eg(tl));class tc extends i.Xsx("BuildFlowchartRequest")({requestId:eg(eS),spec:eb(e9),options:eg(tl)},{identifier:void 0}){}let tu=e9.mapFields(({id:e,title:t,nodes:r,edges:n,layout:i})=>({id:e,title:t,nodes:r,edges:n,layout:i})),td=i._kM({requestId:eg(eS),spec:eb(tu)}),tf=i.rcy(td,{leafHook:el,parseOptions:{errors:"all"}});Object.assign(tf["~standard"],{jsonSchema:{input:()=>ep(td),output:()=>ep(td)}});let th=Object.assign(ef(tc),{omit:e=>tf});class tp extends i.Xsx("BuildSequenceDiagramRequest")({requestId:eg(eS),spec:eb(ti),options:eg(tl)},{identifier:void 0}){}let tm=ef(tp),tg=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=ea(e);return t.length>0&&!/^(?:""|''|``)$/.test(t)},{message:"Must contain semantic text after normalization."})),ty=eb(i.DYE(()=>tb).annotate({identifier:"__schema0"})),tb=i._kM({label:ey(tg),children:i.Qrq(i.O31(ty).pipe(i.fXn))});ef(ty);class tv extends i.Xsx("MindmapSpecLayout")({direction:ew(["LR","RL"]).annotate({default:"LR"}).pipe(i.tiU(s.PyW("LR")))},{identifier:void 0}){}let tw={direction:"LR"},t_=tv.annotate({default:tw}).pipe(i.tiU(s.PyW(tw))),tx={accentColor:b.accentColor,backgroundColor:b.backgroundColor},tk=i._kM({accentColor:eT(eK).pipe(i.tiU(s.PyW(tx.accentColor))),backgroundColor:eT(tx.backgroundColor).pipe(i.tiU(s.PyW(tx.backgroundColor)))}).annotate({default:tx}).pipe(i.tiU(s.PyW(tx))),tS=i._kM({id:eg(eS),title:ey(tg),root:ty,layout:t_,style:tk});class tE extends i.Xsx("MindmapSpec")(tS,{identifier:void 0}){}ef(tE);let tI=i._kM({requestId:eg(eS),spec:eb(tS),options:eg(tl)});i.Xsx("BuildMindmapRequest")(tI,{identifier:void 0});let t$=ef(tI);class tO extends i.Xsx("ScenePoint")({x:eI.pipe(i.Wa3),y:eI.pipe(i.Wa3)},{identifier:void 0}){}ef(tO);class tT extends i.Xsx("NodeSceneElement")({type:e_("node"),id:eE,nodeId:eE,kind:eg(eS),rendererRole:eg(ew(["sequence-lifeline"])),shape:ew(["rectangle","ellipse","diamond","circle"]).pipe(i.Wa3),fillColor:eg(eA).pipe(i.Wa3),strokeColor:eg(eA).pipe(i.Wa3),textColor:eg(eA).pipe(i.Wa3),x:eI.pipe(i.Wa3),y:eI.pipe(i.Wa3),width:e$.pipe(i.Wa3),height:e$.pipe(i.Wa3),label:eE.pipe(i.Wa3)},{identifier:void 0}){}class tA extends i.Xsx("TextSceneElement")({type:e_("text"),id:eE,containerId:eg(eS),textColor:eg(eA).pipe(i.Wa3),x:eI.pipe(i.Wa3),y:eI.pipe(i.Wa3),text:eE.pipe(i.Wa3),fontSize:e$,maxWidth:eg(e$)},{identifier:void 0}){}class tC extends i.Xsx("ArrowSceneElement")({type:e_("arrow"),id:eE,edgeId:eE,sourceNodeId:eE,targetNodeId:eE.pipe(i.Wa3),strokeColor:eg(eA).pipe(i.Wa3),strokeStyle:eg(ew(["dashed","dotted","solid"])).pipe(i.Wa3),textColor:eg(eA).pipe(i.Wa3),points:ev(i.O31(tO).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:eg(eS).pipe(i.Wa3)},{identifier:void 0}){}ef(tT),ef(tA),ef(tC);let tN=i.gPz([tT,tA,tC],{mode:"oneOf"});class tM extends i.Xsx("RenderedDiagramScene")({diagramId:eE,title:eE,width:e$.pipe(i.Wa3),height:e$.pipe(i.Wa3),accentColor:eA.pipe(i.Wa3),backgroundColor:eA.pipe(i.Wa3),elements:ev(i.O31(tN).pipe(i.fXn))},{identifier:void 0}){}let tP=ef(tM),tR=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"}));ef(tR);class tj extends i.Xsx("ExcalidrawScene")({appState:i.mSG(i.QfV,i.$r1),elements:i.O31(tR).pipe(i.fXn)},{identifier:void 0}){}ef(tj);class tD extends tj.extend("ExcalidrawFile")({files:i.mSG(i.QfV,i.$r1),source:eE,type:e_("excalidraw"),version:ex(2)},{identifier:void 0}){}let tL=ef(tD);class tU extends i.Xsx("GetArtifactRequest")({artifactId:eE,format:eg(eM),inline:eg(i.v8c)},{identifier:void 0}){}let tF=ef(tU);class tB extends i.Xsx("DiagramSelector")({ids:eg(i.O31(eS).pipe(i.fXn)),nodeIds:eg(i.O31(eS).pipe(i.fXn)),edgeIds:eg(i.O31(eS).pipe(i.fXn)),kinds:eg(i.O31(eW).pipe(i.fXn)),labels:eg(i.O31(eS).pipe(i.fXn)),scope:eg(ew(["all","nodes","edges"]))},{identifier:void 0}){}ef(tB);class tY extends i.Xsx("DiagramStylePatch")({strokeColor:eg(eA),fillColor:eg(eA),textColor:eg(eA),backgroundColor:eg(eA)},{identifier:void 0}){}ef(tY);let tW=["rectangle","diamond","ellipse","circle"],tq=Object.assign(ef(ew(tW)),{options:tW});class tX extends i.Xsx("SetDefaultStyleOperation")({op:e_("setDefaultStyle"),style:eb(tY)},{identifier:void 0}){}class tJ extends i.Xsx("SetStyleOperation")({op:e_("setStyle"),selector:eb(tB),style:eb(tY)},{identifier:void 0}){}class tz extends i.Xsx("SetShapeOperation")({op:e_("setShape"),selector:eb(tB),shape:tq},{identifier:void 0}){}class tG extends i.Xsx("TranslateOperation")({op:e_("translate"),selector:eb(tB),dx:eI,dy:eI},{identifier:void 0}){}class tV extends i.Xsx("ReplaceTextOperation")({op:e_("replaceText"),selector:eb(tB),text:eE},{identifier:void 0}){}class tK extends i.Xsx("RerouteEdgesOperation")({op:e_("rerouteEdges"),selector:eg(tB)},{identifier:void 0}){}let tH=i.gPz([tX,tJ,tz,tG,tV,tK],{mode:"oneOf"}).annotate({message:`Invalid discriminator value. Expected ${eq.map(e=>`'${e}'`).join(" | ")}`});class tQ extends i.Xsx("ArtifactPatchSource")({artifactId:eE,format:eg(e_("scene"))},{identifier:void 0}){}class tZ extends i.Xsx("InlineScenePatchSource")({scene:eb(tM)},{identifier:void 0}){}let t0=i.gPz([tQ,tZ]).annotate({message:"Invalid input"});class t1 extends i.Xsx("ApplyDiagramPatchOptions")({artifactFormats:ta,inlineArtifacts:ts,preserveConnectivity:eg(i.v8c)},{identifier:void 0}){}ef(eg(t1));class t2 extends i.Xsx("ApplyDiagramPatchRequest")({requestId:eg(eS),source:t0.annotateKey({messageMissingKey:"Invalid input"}),operations:ev(em(tH)).pipe(i.rvE({minItems:1})),options:eg(t1),intent:eg(eS)},{identifier:void 0}){}let t5=ef(t2),t3=i._kM({id:eS,title:eS,nodes:i.O31(eX).pipe(i.fXn),edges:i.O31(eJ.mapFields(e=>({...e,id:eS}))).pipe(i.fXn),layout:i._kM({direction:ez}),style:i._kM({accentColor:eA,backgroundColor:eA})}),t8=i._kM({id:eS,label:eS,children:i.O31(i.DYE(()=>t8)).pipe(i.fXn)}),t6=i._kM({id:eS,title:eS,root:t8,layout:i._kM({direction:ew(["LR","RL"])}),style:i._kM({accentColor:eA,backgroundColor:eA})}),t9=i._kM({id:eS,title:eS,participants:i.O31(e4).pipe(i.fXn),messages:i.O31(e7.mapFields(e=>({...e,id:eS}))).pipe(i.fXn),style:i._kM({accentColor:eA,backgroundColor:eA})}),t4=i._kM({code:i.QfV,passed:i.v8c,severity:ew(["error","warning"]),message:i.QfV,refs:i.O31(eF).pipe(i.fXn)}),t7=i._kM({accepted:i.v8c,score:i.wNn,threshold:i.wNn,summary:i._kM({nodeCount:i.wNn,edgeCount:i.wNn}),checks:i.O31(t4).pipe(i.fXn)}),re=i._kM({format:eM,mimeType:i.QfV,url:eg(i.QfV),expiresAt:eg(i.QfV),inline:eg(i.$r1),sizeBytes:eg(i.wNn)}),rt=i._kM({artifactId:i.QfV,diagramId:i.QfV,formats:i.O31(re).pipe(i.fXn),provenance:eg(eR),preview:eg(re)}),rr=i._kM({artifactId:eg(i.QfV),diagramId:eg(i.QfV),formats:eg(i.O31(re).pipe(i.fXn))});class rn extends i.Xsx("BuildFlowchartAccepted")({ok:ek(!0),status:e_("accepted"),buildId:i.QfV,requestId:eg(i.QfV),normalizedSpec:t3,quality:t7,artifact:rt,issues:i.O31(eB).pipe(i.fXn)},{identifier:void 0}){}class ri extends i.Xsx("BuildFlowchartRejected")({ok:ek(!1),status:ew(["invalid_input","invalid_flowchart","quality_failed","render_failed","export_failed","storage_failed"]),buildId:eg(i.QfV),requestId:eg(i.QfV),normalizedSpec:eg(t3),quality:eg(t7),partial:eg(rr),issues:i.O31(eB).pipe(i.fXn)},{identifier:void 0}){}i.gPz([rn,ri]);class ra extends i.Xsx("BuildMindmapAccepted")({ok:ek(!0),status:e_("accepted"),buildId:i.QfV,requestId:eg(i.QfV),normalizedSpec:t6,quality:t7,artifact:rt,issues:i.O31(eB).pipe(i.fXn)},{identifier:void 0}){}class rs extends i.Xsx("BuildMindmapRejected")({ok:ek(!1),status:ew(["invalid_input","invalid_mindmap","quality_failed","render_failed","export_failed","storage_failed"]),buildId:eg(i.QfV),requestId:eg(i.QfV),normalizedSpec:eg(t6),quality:eg(t7),partial:eg(rr),issues:i.O31(eB).pipe(i.fXn)},{identifier:void 0}){}i.gPz([ra,rs]);class ro extends i.Xsx("BuildSequenceDiagramAccepted")({ok:ek(!0),status:e_("accepted"),buildId:i.QfV,requestId:eg(i.QfV),normalizedSpec:t9,quality:t7,artifact:rt,issues:i.O31(eB).pipe(i.fXn)},{identifier:void 0}){}class rl extends i.Xsx("BuildSequenceDiagramRejected")({ok:ek(!1),status:ew(["invalid_input","invalid_sequence","quality_failed","render_failed","export_failed","storage_failed"]),buildId:eg(i.QfV),requestId:eg(i.QfV),normalizedSpec:eg(t9),quality:eg(t7),partial:eg(rr),issues:i.O31(eB).pipe(i.fXn)},{identifier:void 0}){}i.gPz([ro,rl]);class rc extends i.Xsx("GetArtifactAccepted")({ok:ek(!0),artifactId:i.QfV,diagramId:i.QfV,format:eM,mimeType:i.QfV,url:eg(i.QfV),expiresAt:eg(i.QfV),inline:eg(i.$r1),sizeBytes:eg(i.wNn),provenance:eg(eR)},{identifier:void 0}){}class ru extends i.Xsx("GetArtifactRejected")({ok:ek(!1),status:ew(["invalid_input","not_found","format_unavailable","expired","storage_failed"]),issues:i.O31(eB).pipe(i.fXn)},{identifier:void 0}){}i.gPz([rc,ru]);class rd extends i.Xsx("ApplyDiagramPatchAccepted")({ok:ek(!0),status:e_("accepted"),patchId:i.QfV,requestId:eg(i.QfV),sourceArtifactId:eg(i.QfV),artifact:rt,issues:i.O31(eB).pipe(i.fXn)},{identifier:void 0}){}class rf extends i.Xsx("ApplyDiagramPatchRejected")({ok:ek(!1),status:ew(["invalid_input","source_unavailable","target_not_found","unsupported_operation","connectivity_changed","render_failed","export_failed","storage_failed"]),patchId:eg(i.QfV),requestId:eg(i.QfV),sourceArtifactId:eg(i.QfV),partial:eg(rr),issues:i.O31(eB).pipe(i.fXn)},{identifier:void 0}){}i.gPz([rd,rf]);let rh=i.xCb(["read","readManifest","write"]);class rp extends i.X0d()("CodeModeArtifactStorageError",{cause:i.kld(),message:i.QfV,operation:rh}){}class rm extends a.kl()("@sketchi/diagram-agent/CodeModeArtifactStorage"){}let rg={excalidraw:"application/vnd.excalidraw+json",png:"image/png",scene:"application/vnd.sketchi.scene+json"};function ry(e){return"excalidraw"===e||"scene"===e}function rb(e){return{format:e.format,mimeType:e.mimeType,sizeBytes:e.sizeBytes}}function rv(e){return structuredClone(e)}function rw(e){return new TextEncoder().encode(JSON.stringify(e)).length}function r_(e){return t=>{var r;return rp.make({cause:t,message:(r="write"===e?"Artifact storage failed.":"Artifact read failed.",t instanceof Error?t.message:r),operation:e})}}let rx=l.QZ(rm)(s.Q56(s.OH5(function(){let e=new Map,t=new Map;return{close:s.OH5(()=>{t.clear(),e.clear()}),storage:{read:s.fn("codeMode.artifacts.memory.read")(function*(e,r){return yield*s.SvU({try:()=>{let n=t.get(`${e}:${r}`);return n?{...n,data:rv(n.data)}:null},catch:r_("read")})}),readManifest:s.fn("codeMode.artifacts.memory.readManifest")(function*(t){return yield*s.SvU({try:()=>{let r=e.get(t);return r?rv(r):null},catch:r_("readManifest")})}),write:s.fn("codeMode.artifacts.memory.write")(function*(r){let n=yield*o.Ru;return yield*s.SvU({try:()=>{var i;let a,s=r.formats.map(rb),o=r.provenance?rv(r.provenance):void 0,l={artifactId:r.artifactId,diagramId:r.diagramId,formats:s,...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:rv(n.data)});let c=r.formats.map(e=>{var t;return t=r.inlineFormats,{format:e.format,mimeType:e.mimeType,...ry(e.format)&&t.includes(e.format)?{inline:e.data}:{},sizeBytes:e.sizeBytes}});return a=(i={artifactId:r.artifactId,diagramId:r.diagramId,formats:c,...r.provenance?{provenance:rv(r.provenance)}:{}}).formats.find(e=>"scene"===e.format),{artifactId:i.artifactId,diagramId:i.diagramId,formats:i.formats,...i.provenance?{provenance:i.provenance}:{},...a?{preview:a}:{}}},catch:r_("write")})})}}}),e=>e.close).pipe(s.TjK(e=>e.storage)));function rk(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."}}function rS(e){return new Map(e.map((e,t)=>[e.id,t]))}function rE(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 rI(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function r$(e,t,r){return Math.min(r,Math.max(t,e))}function rO(e,t,r=0){let n,i=(n="top"===t||"bottom"===t?e.width/2-16:e.height/2-16)>0?r$(r,-n,n):0,a=rI(e),s=e.width/2,o=e.height/2;if("diamond"===e.shape&&s>0&&o>0){if("top"===t||"bottom"===t){let e=a.x+i,r=o*(1-Math.abs(i)/s);return{x:e,y:"top"===t?a.y-r:a.y+r}}let e=a.y+i,r=s*(1-Math.abs(i)/o);return{x:"left"===t?a.x-r:a.x+r,y:e}}if(("ellipse"===e.shape||"circle"===e.shape)&&s>0&&o>0){if("top"===t||"bottom"===t){let e=a.x+i,r=o*Math.sqrt(Math.max(0,1-(i/s)**2));return{x:e,y:"top"===t?a.y-r:a.y+r}}let e=a.y+i,r=s*Math.sqrt(Math.max(0,1-(i/o)**2));return{x:"left"===t?a.x-r:a.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 rT(e){return`${e.edgeId}:${e.endpoint}`}function rA(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 rC(e,t,r){return e>t+.01&&e<r-.01}function rN(e,t,r,n){return Math.min(t,n)-Math.max(e,r)>.01}function rM(e,t,r){let n=0;for(let i=0;i<e.length-1;i+=1){let a=e[i],s=e[i+1];if(a&&s)for(let e of t)!r.has(e.nodeId)&&(a.y===s.y?rC(a.y,e.y,e.y+e.height)&&rN(Math.min(a.x,s.x),Math.max(a.x,s.x),e.x,e.x+e.width):a.x===s.x&&rC(a.x,e.x,e.x+e.width)&&rN(Math.min(a.y,s.y),Math.max(a.y,s.y),e.y,e.y+e.height))&&(n+=1)}return n}function rP(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 rR(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 rj(e,t){return Math.min(e.max,t.max)-Math.max(e.min,t.min)}function rD(e,t,r){let n=rR({arrowId:`edge:${r.edge.id}`,points:e,sourceNodeId:r.edge.source,targetNodeId:r.edge.target}),i=t.flatMap(e=>rR({arrowId:e.id,points:e.points,sourceNodeId:e.sourceNodeId,targetNodeId:e.targetNodeId})),a=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>=rj(e,t)||(a+=1);return a}function rL(e,t){let r=rR({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>=rj(t,e)||(n+=1)}}return n}function rU(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),a=0;return r.x<t.x?a+=Math.max(0,Math.max(...n)-t.x):r.x>t.x&&(a+=Math.max(0,t.x-Math.min(...n))),r.y<t.y?a+=Math.max(0,Math.max(...i)-t.y):r.y>t.y&&(a+=Math.max(0,t.y-Math.min(...i))),a}function rF(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),a=0;return r.x<t.x?a+=Math.max(0,r.x-Math.min(...n)):r.x>t.x&&(a+=Math.max(0,Math.max(...n)-r.x)),r.y<t.y?a+=Math.max(0,r.y-Math.min(...i)):r.y>t.y&&(a+=Math.max(0,Math.max(...i)-r.y)),a}function rB(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 rY(e,t){let r=e[0],n=e[1],i=e[e.length-1],a=e[e.length-2],s=0;return n&&rB(r,n,t.sourceEdge)&&(s+=1),a&&i&&rB(i,a,t.targetEdge)&&(s+=1),s}function rW(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 a;let s,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||rI(e.target).x<rI(e.source).x,p="top"===e.sourceEdge||"top"===e.targetEdge||rI(e.source).y<=rI(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,_=h?y:g,x=p?b:v,k=p?v:b,S=[0,36+e.index%4*18],E=(n,i)=>{let a=i>0?rW(t,e.sourceEdge,i):t,s=i>0?rW(r,e.targetEdge,i):r;return rA([t,a,{x:n,y:a.y},{x:n,y:s.y},s,r])},I=(n,i)=>{let a=i>0?rW(t,e.sourceEdge,i):t,s=i>0?rW(r,e.targetEdge,i):r;return rA([t,a,{x:a.x,y:n},{x:s.x,y:n},s,r])},$=[...S.map(e=>I(x,e)),...S.map(e=>I(k,e)),...S.map(e=>E(w,e)),...S.map(e=>E(_,e))],O=[...S.map(e=>E(w,e)),...S.map(e=>E(_,e)),...S.map(e=>I(x,e)),...S.map(e=>I(k,e))];return(s=(a=o?$:O)[0])?a.slice(1).reduce((t,r)=>{let a=rM(t,n,l),s=rM(r,n,l);if(s<a)return r;if(a<s)return t;let o=rL(t,e),c=rL(r,e);if(c<o)return r;if(o<c)return t;let u=rD(t,i,e),d=rD(r,i,e);if(d<u)return r;if(u<d)return t;let f=rY(t,e),h=rY(r,e);if(h>f)return r;if(f>h)return t;let p=rU(t),m=rU(r);if(m<p)return r;if(p<m)return t;let g=rF(t),y=rF(r);return y<g?r:g<y?t:rP(r)<rP(t)?r:t},s):[{x:0,y:0}]}function rX(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 rJ(e,t,r){return{x:e.x+t,y:e.y+r}}function rz(e){var t;let r,n,i,a,s,o=R(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,a;return[e.id,(a=(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(...a.map(e=>e.length))*.62+36),height:Math.ceil(14*a.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 a(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||a(t.target)}n.set(e,"visited")}let s=e.nodes.find(e=>0===(t.get(e.id)??[]).length)??e.nodes[0];for(let t of(s&&a(s.id),e.nodes))n.has(t.id)||a(t.id);return i}(e,n.incoming,n.outgoing),a=function(e,t,r){let n=rS(e.nodes),i=new Map(e.nodes.map(e=>[e.id,0])),a=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 s=[];for(let t of e.nodes)(i.get(t.id)??0)===0&&s.push(t.id);let o=new Set;for(let e=0;e<s.length;e+=1){let l=s[e];if(!l||o.has(l))continue;o.add(l);let c=a.get(l)??0;for(let e of t.outgoing.get(l)??[]){if(r.has(e.id))continue;a.set(e.target,Math.max(a.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)}(s,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=>a.get(e.source)??0);a.set(n.id,e.length>0?Math.max(...e)+1:0)}return a}(e,n,i),s=Array.from((function(e,t,r,n,i){let a=rS(e.nodes),s=new Map;for(let n of e.nodes){let e=r.get(n.id)??0,i=t.get(n.id);i&&s.set(e,[...s.get(e)??[],i])}for(let e=0;e<4;e+=1)for(let e of Array.from(s.keys()).sort((e,t)=>e-t)){let t=s.get(e);if(!t||t.length<2)continue;let r=new Map;(s.get(e-1)??[]).forEach((e,t)=>{r.set(e.nodeId,t)});let o=new Map;(s.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?a.get(e.nodeId)??Number.MAX_SAFE_INTEGER:t.reduce((e,t)=>e+t,0)/t.length};s.set(e,[...t].sort((e,t)=>{let r=l(e)-l(t);return Math.abs(r)>.001?r:(a.get(e.nodeId)??Number.MAX_SAFE_INTEGER)-(a.get(t.nodeId)??Number.MAX_SAFE_INTEGER)}))}return s})(e,r,a,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(...s.map(e=>e.breadth)),l=48,c=[];for(let e of s){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),a=r.get(e.target);if(!i||!a)throw Error(`Cannot render edge "${e.id}" with unresolved nodes.`);let{sourceEdge:s,targetEdge:o}=function(e,t,r){let n=rI(e),i=rI(t),a=i.x-n.x,s=i.y-n.y,o=e.kind?.toLowerCase();if("LR"===r||"RL"===r)return a>=0?{sourceEdge:"right",targetEdge:"left"}:{sourceEdge:"left",targetEdge:"right"};if(s<0)return!(Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)>.01)&&Math.abs(a)>Math.abs(s)?{sourceEdge:a>0?"right":"left",targetEdge:"bottom"}:{sourceEdge:"top",targetEdge:"bottom"};let l="decision"===o&&s>e.height+96;return"decision"===o&&s>0&&(0!==a||l)?{sourceEdge:a<0?"left":"right",targetEdge:"top"}:s>0?{sourceEdge:"bottom",targetEdge:"top"}:Math.abs(a)>Math.abs(s)?a>0?{sourceEdge:"right",targetEdge:"left"}:{sourceEdge:"left",targetEdge:"right"}:s>0?{sourceEdge:"bottom",targetEdge:"top"}:{sourceEdge:"top",targetEdge:"bottom"}}(i,a,n);return{edge:e,index:t,source:i,sourceEdge:s,target:a,targetEdge:o}})(e,t,c,o.layout.direction)),d=function(e){let t=new Map;for(let s of e){var r,n,i,a;let e=(r=s.source.nodeId,n=s.sourceEdge,`${r}:${n}`),o=(i=s.target.nodeId,a=s.targetEdge,`${i}:${a}`);t.set(e,[...t.get(e)??[],{edgeId:s.edge.id,endpoint:"source"}]),t.set(o,[...t.get(o)??[],{edgeId:s.edge.id,endpoint:"target"}])}let s=new Map;for(let e of t.values())e.forEach((t,r)=>{s.set(rT(t),(r-(e.length-1)/2)*18)});return s}(u),f=[];for(let e of u)f.push(function(e,t,r,n,i,a){let{edge:s,source:o,sourceEdge:l,target:c,targetEdge:u}=e,d=rO(o,l,r.get(rT({edgeId:s.id,endpoint:"source"}))??0),f=rO(c,u,r.get(rT({edgeId:s.id,endpoint:"target"}))??0),h=rA([d,f]);if(function(e,t,r){let n=rI(e),i=rI(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,a))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,a=(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)?r$(t+g,r,n):t),s="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=rA([d,s,{x:s.x,y:a},{x:o.x,y:a},o,f])}return"orthogonal"===t&&(rM(h,n,new Set([o.nodeId,c.nodeId]))>0||rL(h,e)>0||rD(h,i,e)>0)&&(h=rq(e,d,f,n,i)),{type:"arrow",id:`edge:${s.id}`,edgeId:s.id,sourceNodeId:s.source,targetNodeId:s.target,points:h,...s.label?{label:s.label}:{}}}(e,o.layout.edgeRouting,d,l,f,o.layout.direction));let h=l.map(rE),p=(i=Math.max(0,48-(n={x:Math.min(...(r=rX(t=[...f,...l,...h])).map(e=>e.x)),y:Math.min(...r.map(e=>e.y))}).x),a=Math.max(0,48-n.y),0===i&&0===a?[...t]:t.map(e=>"arrow"===e.type?{...e,points:function(e,t,r){let[n,...i]=e;return[rJ(n,t,r),...i.map(e=>rJ(e,t,r))]}(e.points,i,a)}:{...e,x:e.x+i,y:e.y+a})),m={width:Math.max(...(s=rX(p)).map(e=>e.x))+48,height:Math.max(...s.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 rG="sequence-lifeline";function rV(e){return`${e}:lifeline`}var rK=r(1580);let rH=new Set(["rectangle","ellipse","diamond"]),rQ=y.ink;function rZ(e){return"number"==typeof e&&Number.isFinite(e)?e:null}function r0(e){if(!Array.isArray(e)||e.length<2)return null;let t=rZ(e[0]),r=rZ(e[1]);return null===t||null===r?null:[t,r]}function r1(e){let t=rZ(e.x),r=rZ(e.y),n=rZ(e.width),i=rZ(e.height);return null===t||null===r||null===n||null===i?null:{x:t,y:r,width:n,height:i}}function r2(e){return 1e-4>Math.abs(e-.5)?.5001:e}function r5(e,t){let r;return{elementId:e?.id??"",focus:0,gap:0,fixedPoint:e?(r=r1(e))&&0!==r.width&&0!==r.height?[r2((t.x-r.x)/r.width),r2((t.y-r.y)/r.height)]:null:null}}function r3(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 r8(e,t){return Math.ceil(e.split("\n").length*t*1.35)}function r6(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=r8(e.text,e.fontSize);return{...r3(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??rQ,text:e.text,textAlign:"center",verticalAlign:"middle",autoResize:!0}}function r9(e){return e.points[e.points.length-1]??e.points[0]}function r4(e){return"node"===e.type}function r7(e){return"text"===e.type}function ne(e){return"arrow"===e.type}function nt(e){let t=e.elements.filter(r4),r=new Map(e.elements.filter(r7).map(e=>[e.containerId??"",e])),n=e.elements.filter(ne),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),a=new Map,s=[],o=null,l=()=>{let e=(0,rK.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?r8(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{...r3(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,...e.shape.rendererRole===rG?{customData:{sketchiRendererRole:rG}}:{}}}({scene:e,shape:n,arrowIds:i.get(n.id)??[],index:l(),...t?{text:t}:{}});a.set(n.nodeId,o),s.push(o)}for(let t of e.elements.filter(r7))t.containerId&&s.push(r6({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){s.push(function(e){let t=e.arrow.points[0],r=r9(e.arrow),n=e.arrow.points.length>2;return{...r3(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:r5(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:r5(e.sourceShape,t),strokeColor:e.arrow.strokeColor??e.scene.accentColor,strokeStyle:e.arrow.strokeStyle??"solid"}}({arrow:t,scene:e,index:l(),sourceShape:a.get(t.sourceNodeId),targetShape:a.get(t.targetNodeId)}));let r=t.label?function(e){if(!e.arrow.label)return null;let t=e.arrow.points[0],r=r9(e.arrow);return r6({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&&s.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:s}}function nr(e,t){let r=e[t];if(!(r&&"object"==typeof r))return null;let n=r.elementId;return"string"==typeof n?n:null}function nn(e){return r0(e)}function ni(e){let t=rZ(e.x)??0,r=rZ(e.y)??0,n=nr(e,"startBinding"),i=nr(e,"endBinding"),a=Array.isArray(e.points)?e.points.map(nn).filter(e=>!!e):[],s=[];for(let o=0;o<a.length-1;o+=1){let l=a[o],c=a[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)){s.push({arrowId:e.id,endBindingElementId:i,isLastSegment:o===a.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)&&s.push({arrowId:e.id,endBindingElementId:i,isLastSegment:o===a.length-2,max:Math.max(m,y),min:Math.min(m,y),orientation:"vertical",segmentIndex:o,startBindingElementId:n,staticCoordinate:p})}return s.filter(e=>e.max-e.min>.001)}function na(e,t,r){return e>t+.01&&e<r-.01}function ns(e,t,r,n){return Math.min(t,n)-Math.max(e,r)>.01}function no(e,t,r){return e>=t-.01&&e<=r+.01}function nl(e,t){return .01>=Math.abs(e-t)}function nc(e){let t=[],r=new Map(e.elements.map(e=>[e.id,e])),n=new Set(e.elements.filter(e=>rH.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 a 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 s=nr(i,a);if(!(s&&n.has(s))){t.push({code:"missing-arrow-binding",elementId:i.id,message:`Arrow "${i.id}" has invalid ${a}.`});continue}let o=r.get(s);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=rZ(e.x)??0,n=rZ(e.y)??0,i=Array.isArray(e.points)?e.points.map(nn).filter(e=>!!e):[],a="startBinding"===t?i[0]:i[i.length-1];return a?{x:r+a[0],y:n+a[1]}:null}(i,a);if(o&&l&&!function(e,t){let r=r1(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,a=r.y+n;return nl(Math.abs(e.x-i)/t+Math.abs(e.y-a)/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,a=r.y+n;return nl(((e.x-i)/t)**2+((e.y-a)/n)**2,1)}let n=(nl(e.x,r.x)||nl(e.x,r.x+r.width))&&no(e.y,r.y,r.y+r.height),i=(nl(e.y,r.y)||nl(e.y,r.y+r.height))&&no(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}" ${a} endpoint does not land on "${o.id}".`}),o&&l&&e){let e=function(e,t){let r=e[t];return r&&"object"==typeof r?r0(r.fixedPoint):null}(i,a);e&&function(e,t,r){let n=r1(r);if(!n)return!1;let i=1e-4>Math.abs(e[0]-.5001)?.5:e[0],a=1e-4>Math.abs(e[1]-.5001)?.5:e[1];return nl(n.x+i*n.width,t.x)&&nl(n.y+a*n.height,t.y)}(e,l,o)||t.push({code:"invalid-elbow-binding",elementId:i.id,message:`Elbow arrow "${i.id}" has invalid ${a} 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 a="number"==typeof i.width?i.width:0,s="number"==typeof i.height?i.height:0,o="number"==typeof n.width?n.width:0,l="number"==typeof n.height?n.height:0;rH.has(n.type)&&(a+24>o||s+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(ni),r=e.filter(e=>rH.has(e.type)),n=[],i=new Set;for(let e of t)for(let t of r){if(function(e){let t=e.customData;return null!==t&&"object"==typeof t&&t.sketchiRendererRole===rG}(t)||t.id===e.startBindingElementId||t.id===e.endBindingElementId)continue;let r=r1(t);if(!r||("horizontal"===e.orientation?!(na(e.staticCoordinate,r.y,r.y+r.height)&&ns(e.min,e.max,r.x,r.x+r.width)):!(na(e.staticCoordinate,r.x,r.x+r.width)&&ns(e.min,e.max,r.y,r.y+r.height))))continue;let a=`${e.arrowId}:${e.segmentIndex}:${t.id}`;i.has(a)||(i.add(a),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(ni),r=[],n=new Set;for(let e=0;e<t.length;e+=1){let i=t[e];if(i)for(let a=e+1;a<t.length;a+=1){let e=t[a];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 s=[i.arrowId,i.segmentIndex,e.arrowId,e.segmentIndex].sort().join(":");n.has(s)||(n.add(s),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}}var nu=r(8927);r(2302);var nd=r(4650),nf=r(1136),nh=r(9354),np=r(6364),nm=r(9138),ng=r(5369);let ny=a.Or("effect/Metric/CurrentMetricAttributes",{defaultValue:()=>({})}),nb=a.Or("~effect/observability/Metric/MetricRegistryKey",{defaultValue:()=>new Map}),nv="~effect/observability/Metric";class nw{[nv]=nv;#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=a.Jt(e,ny);if(0===Object.keys(t).length)return ng.EA(this.#t)||(this.#t=this.getOrCreate(e,this.attributes)),this.#t.hooks;let r=nO(this.attributes,t),n=this.#e.get(r);return ng.EA(n)||(n=this.getOrCreate(e,r),this.#e.set(r,n)),n.hooks}getOrCreate(e,t){var r,n,i;let s,o=(r=this,n=t,s=`${r.type}:${r.id}`,ng.EA(r.description)&&(s+=`:${r.description}`),ng.EA(n)&&(s+=`:${(Array.isArray(i=n)?i:Object.entries(i)).map(([e,t])=>`${e}=${t}`).join(",")}`),s),l=a.Jt(e,nb);if(l.has(o))return l.get(o);let c=this.createHooks(),u={id:this.id,type:this.type,description:this.description,attributes:nT(t),hooks:c};return l.set(o,u),u}pipe(){return(0,nm.tT)(this,arguments)}}let n_=BigInt(0);class nx extends nw{type="Counter";#r;#n;constructor(e,t){super(e,t?.description,nT(t?.attributes)),this.#r=t?.bigint??!1,this.#n=t?.incremental??!1}createHooks(){let e=this.#r?n_:0,t=this.#n?this.#r?e=>e>=n_:e=>e>=0:e=>!0;return n$(()=>({count:e,incremental:this.#n}),r=>{t(r)&&(e+=r)})}}class nk extends nw{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 nS=(e,t)=>new nx(e,t),nE=(0,nd.XY)(2,(e,t)=>nf.sxi(r=>nf.OH5(()=>e.updateUnsafe(t,r)))),nI=(0,nd.XY)(2,(e,t)=>new nk(e,r=>e.valueUnsafe(nA(r,t)),(r,n)=>e.updateUnsafe(r,nA(n,t)),(r,n)=>e.modifyUnsafe(r,nA(n,t))));function n$(e,t,r){return{get:e,update:t,modify:r??t}}function nO(e,t){return{...nT(e),...nT(t)}}function nT(e){return ng.EA(e)&&Array.isArray(e)?e.reduce((e,[t,r])=>(e[t]=r,e),{}):e}function nA(e,t){let r=nO(a.Jt(e,ny),t);return a.WQ(e,ny,r)}nh.F,nh.F,nd.MN,r(7598),r(8543);var nC=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 nN={metric:()=>void 0},nM=a.Or("@sketchi/observability/TelemetryExporter",{defaultValue:()=>nN}),nP=a.Or("@sketchi/observability/TelemetryCorrelation",{defaultValue:()=>({})});function nR(e){let t=e?.trim();if(t&&!(t.length>128)&&/^[A-Za-z0-9][A-Za-z0-9._:-]*$/.test(t))return t}function nj(e){let t=nR(e.artifactId),r=nR(e.attemptId),n=nR(e.projectId),i=nR(e.requestId),a=nR(e.runId),s=nR(e.scenarioId),o=nR(e.traceId);return{...t?{artifactId:t}:{},...r?{attemptId:r}:{},...n?{projectId:n}:{},...i?{requestId:i}:{},...a?{runId:a}:{},...s?{scenarioId:s}:{},...o?{traceId:o}:{}}}function nD(e,t){return s.JkU(function*(){let r=nj({...yield*nP,...nj(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(s.PfK(nP,r),s.Muk(n),s.swY(n))})}a.Or("@sketchi/observability/TelemetryResource",{defaultValue:()=>({serviceName:"sketchi"})});let nL=s.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=nR(n);t&&(r[e]=t)}return r}(r);yield*nE(nI(e,n),t);let i=yield*nM,a=d.getOrUndefined((yield*s._32.pipe(s.uKv)));yield*s.OH5(()=>i.metric({attributes:n,metric:e.id,metricType:e.type,...a?{spanId:a.spanId,traceId:a.traceId}:{},value:t}))});nC.W1;let nU=/^(node|step|item|box|thing|process|task)\s*\d*$/i,nF=/^(diagram|untitled|flowchart|chart|sketch)$/i;function nB(e){return"decision"===e.kind||e.label.endsWith("?")}function nY(e){if(void 0===e)return;let t=ea(e);return t.length>0?t:void 0}let nW=["excalidraw","scene"],nq=["scene"];y.card,y.accent,y.ink;let nX=nS("sketchi_codemode_requests",{description:"Code Mode boundary requests by terminal outcome",incremental:!0}),nJ=nS("sketchi_codemode_failures",{description:"Code Mode boundary failures by typed status",incremental:!0}),nz=nS("sketchi_codemode_artifacts",{description:"Code Mode artifacts accepted at workflow boundaries",incremental:!0}),nG=new class e extends nw{type="Histogram";#i;constructor(e,t){super(e,t?.description,nT(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,a=0,s=Number.MAX_VALUE,o=5e-324;return nu.Tj(nu.di(e,np.wN),(e,t)=>{n[t]=e}),n$(()=>({buckets:(()=>{let e=nu.CN(t),i=0;for(let a=0;a<t;a++){let t=n[a];i+=r[a],e[a]=[t,i]}return e})(),count:i,min:s,max:o,sum:a}),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,a+=e,e<s&&(s=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],nu.BC(nu.pb(new Set(n),e=>e>0),1/0))});class nV extends a.kl()("@sketchi/diagram-agent/CodeModeRuntimeEnvironment"){}function nK(e={}){return l.Py(nV,{createId:e.createId??n8,...e.renderer?{renderer:e.renderer}:{},...e.artifactUrl?{artifactUrl:e.artifactUrl}:{}})}function nH(e){return null===e||"object"!=typeof e||Array.isArray(e)?void 0:Object.fromEntries(Object.entries(e))}function nQ(e,t,r){let n,i,a,l;return nD(s.JkU(function*(){let t=yield*o.Ru,n=yield*r,i=yield*o.Ru,a=n.ok?"success":"failure",s=n.ok?void 0:n.status??"unknown_failure";yield*nL(nX,1,{...s?{failureCategory:s}:{},operation:e,outcome:a,surface:"code_mode"}),yield*nL(nG,i-t,{...s?{failureCategory:s}:{},operation:e,outcome:a,surface:"code_mode"}),s&&(yield*nL(nJ,1,{failureCategory:s,operation:e,surface:"code_mode"}));let l="buildFlowchart"===e?"flowchart":"buildMindmap"===e?"mindmap":"buildSequenceDiagram"===e?"sequence":"applyDiagramPatch"===e?"patch":void 0;return n.ok&&l&&(yield*nL(nz,1,{artifactKind:l,operation:e,surface:"code_mode"})),n}),(n=nH(t),i=nH(n?.source),a="string"==typeof n?.artifactId?n.artifactId:"string"==typeof i?.artifactId?i.artifactId:void 0,l="string"==typeof n?.requestId?n.requestId:void 0,{...a?{artifactId:a}:{},...l?{requestId:l}:{}}))}l.Py(nV,{createId:n8});class nZ extends i.X0d()("CodeModeArtifactExportError",{cause:i.kld(),message:i.QfV,optionPath:i.v8c}){}class n0 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 n1 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 n2 extends i.X0d()("BuildSequenceDiagramFailure",{message:i.QfV,status:i.xCb(["invalid_input","invalid_sequence","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 n5 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 n3 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 n8(e){return`${e}_${globalThis.crypto.randomUUID()}`}function n6(e){return{code:e.code,severity:e.severity??"error",stage:e.stage,...e.ref?{ref:e.ref}:{},message:e.message,hint:e.hint}}function n9(e){return 0===e.length?"input":e.map(e=>"number"==typeof e?`[${e}]`:String(e)).join(".")}function n4(e){let t=n9(e.path);return n7(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 n7(e){return/^operations\.\[\d+\]\.op$/.test(e)}function ie(e){let t=e.issues.slice(0,20).map(e=>{let t=n9(e.path);return n6({code:n4(e),stage:"input",ref:{kind:"request",path:t},message:e.message,hint:n7(t)?`Use one of: ${eq.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(n6({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 it(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)}function ir(e){if(void 0===e)return;let t=ea(e);return t.length>0?t:void 0}function ii(e){return e.checks.map(e=>{var t;return n6({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 ia(e){return e?.artifactFormats??nW}function is(e){return e?.inlineArtifacts??nq}let io=s.fn("codeMode.artifacts.exportFormats")(function*(e){let t=[];for(let a of e.formats){var r,n,i;let o=yield*(r=e,"scene"===(n=a)?s.PyW(r.scene):"excalidraw"===n?s.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(s.xm_(e=>nZ.make({cause:e,message:e instanceof Error?e.message:"Artifact export failed.",optionPath:!1}))):s.fJG(nZ.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:a,mimeType:rg[a],data:o,sizeBytes:(i=o)instanceof ArrayBuffer||i instanceof Uint8Array?i.byteLength:rw(i)})}return t});function il(e){return[n6({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 ic(e){return e.map(e=>n6({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 iu(e){return structuredClone(e)}function id(e){return e.elements.filter(e=>"arrow"===e.type).map(e=>`${e.edgeId}:${e.sourceNodeId}->${e.targetNodeId}`).sort()}function ih(e){return e.elements.filter(e=>"node"===e.type)}function ip(e){return e.elements.filter(e=>"text"===e.type)}function im(e){return e.elements.filter(e=>"arrow"===e.type)}function ig(e,t){if(!e||0===e.length||!t)return!1;let r=t.trim().toLowerCase();return e.some(e=>e.trim().toLowerCase()===r)}function iy(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??[]),a=new Set(t?.nodeIds??[]),s=new Set(t?.edgeIds??[]),o=new Set(t?.kinds??[]),l=ih(e).filter(e=>"edges"!==r&&(!t||!n||i.has(e.id)||a.has(e.nodeId)||!!e.kind&&[...o].some(t=>t===e.kind)||ig(t.labels,e.label))),c=im(e).filter(e=>"nodes"!==r&&(!t||!n||i.has(e.id)||s.has(e.edgeId)||ig(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:ip(e).filter(e=>t&&n?i.has(e.id)||!!e.containerId&&u.has(e.containerId)||!!e.containerId&&d.has(e.containerId)||ig(t.labels,e.text):"nodes"===r?!!e.containerId&&u.has(e.containerId):"edges"!==r||!!e.containerId&&d.has(e.containerId))}}function ib(e){return n6({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 iv(e,t){return ip(e).find(e=>e.containerId===t)}function iw(e,t){let r=new Set(t);for(let t of im(e))(r.has(t.sourceNodeId)||r.has(t.targetNodeId))&&ik(e,t)}function i_(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function ix(e,t,r){let n=i_(e),i=i_(t),a=i.x-n.x,s=i.y-n.y;return Math.abs(a)>Math.abs(s)?a>=0&&r||a<0&&!r?{x:e.x+e.width,y:n.y}:{x:e.x,y:n.y}:s>=0&&r||s<0&&!r?{x:n.x,y:e.y+e.height}:{x:n.x,y:e.y}}function ik(e,t){let r,n,i=new Map(ih(e).map(e=>[e.nodeId,e])),a=i.get(t.sourceNodeId),s=i.get(t.targetNodeId);if(!a||!s)return[n6({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=ix(a,s,!0),l=ix(s,a,!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=iv(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 iS=s.fn("codeMode.patch.resolveSource")(function*(e){if("scene"in e.source)return{scene:iu(e.source.scene)};let t=yield*rm,r=yield*t.readManifest(e.source.artifactId).pipe(s.xm_(e=>new n3({status:"storage_failed",context:{issues:[rk(e.message,"storage_read_failed")]}})));if(!r||r.artifactId!==e.source.artifactId||!r.formats.some(e=>"scene"===e.format))return yield*new n3({status:"source_unavailable",context:{issues:[n6({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(s.xm_(e=>new n3({status:"storage_failed",context:{issues:[rk(e.message,"storage_read_failed")]}})));if(!n)return yield*new n3({status:"source_unavailable",context:{issues:[n6({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=tP.safeParse(n.data);return i.success?{scene:iu(i.data),sourceArtifactId:e.source.artifactId}:yield*new n3({status:"source_unavailable",context:{issues:[n6({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 iE(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 i$(e){return{diagramId:e.diagramId,formats:[{format:"scene",mimeType:rg.scene,inline:e,sizeBytes:rw(e)}]}}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 iT(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 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 iC(e){return{ok:!1,status:e.status,issues:e.issues}}function iN(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 iM(e,t){return rk(e.message,t)}let iP=s.fn("codeMode.buildMindmap.workflow")(function*(e){let t=yield*s.OH5(()=>(function(e){let t=nH(nH(nH(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[n6({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[n6({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=nH(t[n]);i&&r.push({depth:e.depth+1,topic:i})}}}return[]})(e)).pipe(s.fRP("codeMode.buildMindmap.preflight"));if(t.length>0)return yield*new n1({status:"invalid_mindmap",context:{issues:t}});let r=yield*s.OH5(()=>t$.safeParse(e)).pipe(s.fRP("codeMode.buildMindmap.parse"));if(!r.success)return yield*new n1({status:"invalid_input",context:{issues:ie(r.error)}});let n=yield*nV,i=yield*rm,a=r.data,o=yield*s.OH5(()=>n.createId("build")),l=yield*s.OH5(()=>{var e;let t,r;return e=a.spec,t=(e,r)=>({id:`topic-${r.join("-")}`,label:ea(e.label),children:(e.children??[]).map((e,n)=>t(e,[...r,n]))}),r=ea(e.title),{id:ir(e.id)??(it(r)||"sketchi-mindmap"),title:r,root:t(e.root,[0]),layout:{direction:e.layout.direction},style:{...b}}}).pipe(s.fRP("codeMode.buildMindmap.normalize")),c={buildId:o,...iE(a.requestId),normalizedSpec:l},u=yield*s.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(n6({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(n6({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(n6({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(s.fRP("codeMode.buildMindmap.validate"));if(u.length>0)return yield*new n1({status:"invalid_mindmap",context:{...c,issues:u}});let d=yield*s.SvU({try:()=>{let e,t,r;return e=[],t=[],(r=(n,i,a,s)=>{e.push({id:n.id,label:n.label,kind:0===i?"root":"topic",metadata:{depth:i,siblingIndex:a}}),s&&t.push({id:`branch-${n.id.slice(6)}`,source:s,target:n.id,metadata:{depth:i,siblingIndex:a}}),n.children.forEach((e,t)=>r(e,i+1,t,n.id))})(l.root,0,0),er({id:l.id,title:l.title,type:"mindmap",nodes:e,edges:t,layout:{direction:l.layout.direction,edgeRouting:"curved"},style:{...b}})},catch:e=>new n1({status:"invalid_mindmap",context:{...c,issues:[n6({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(s.fRP("codeMode.buildMindmap.canonicalize")),f=yield*s.OH5(()=>{var e;let t,r;return e=a.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(s.fRP("codeMode.buildMindmap.quality")),h={...c,quality:f};if(!f.accepted)return yield*new n1({status:"quality_failed",context:{...h,issues:ii(f)}});let p=yield*s.SvU({try:()=>rz(d),catch:e=>new n1({status:"render_failed",context:{...h,issues:[n6({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(s.fRP("codeMode.buildMindmap.render")),{excalidraw:m,exportValidation:g}=yield*s.OH5(()=>{let e=nt(p);return{excalidraw:e,exportValidation:nc(e)}}).pipe(s.fRP("codeMode.buildMindmap.exportValidate")),y={...h,partial:i$(p)};if(!g.ok)return yield*new n1({status:"export_failed",context:{...y,issues:ic(g.issues)}});let v=yield*io({formats:ia(a.options),scene:p,excalidraw:m,renderer:n.renderer}).pipe(s.xm_(e=>new n1({status:"export_failed",context:{...y,issues:il(e)}}))),w=yield*s.OH5(()=>n.createId("artifact")),_=yield*nD(i.write({artifactId:w,diagramId:p.diagramId,formats:v,inlineFormats:is(a.options)}),{artifactId:w,...a.requestId?{requestId:a.requestId}:{}}).pipe(s.xm_(e=>new n1({status:"storage_failed",context:{...h,partial:{diagramId:p.diagramId},issues:[iM(e,"storage_write_failed")]}})));return{ok:!0,status:"accepted",buildId:o,...iE(a.requestId),normalizedSpec:l,quality:f,artifact:iI(_,n.artifactUrl),issues:[]}}),iR=s.fn("codeMode.buildSequenceDiagram.workflow")(function*(e){yield*s.rIH.pipe(s.fRP("codeMode.buildSequenceDiagram.preflight"));let t=yield*s.OH5(()=>tm.safeParse(e)).pipe(s.fRP("codeMode.buildSequenceDiagram.parse"));if(!t.success)return yield*new n2({status:"invalid_input",context:{issues:ie(t.error)}});let r=yield*nV,n=yield*rm,i=t.data,a=yield*s.OH5(()=>r.createId("build")),o=yield*s.OH5(()=>{var e;let t;return t=ea((e=i.spec).title),{id:ir(e.id)??(it(t)||"sketchi-sequence"),title:t,participants:e.participants.map(e=>({id:ea(e.id),label:ea(e.label),...e.kind?{kind:ea(e.kind)}:{}})),messages:e.messages.map((e,t)=>({id:ir(e.id)??`message-${t+1}-${it(e.source)}-${it(e.target)}`,source:ea(e.source),target:ea(e.target),label:ea(e.label),...e.type?{type:e.type}:{},...e.style?{style:e.style}:{}})),style:{...b}}}).pipe(s.fRP("codeMode.buildSequenceDiagram.normalize")),l={buildId:a,...iE(i.requestId),normalizedSpec:o},c=yield*s.OH5(()=>{let e,t,r,n;return e=[],t=new Set,o.participants.forEach((r,n)=>{t.has(r.id)&&e.push(n6({code:"duplicate_node_id",stage:"input",ref:{kind:"request",path:`spec.participants.[${n}].id`},message:`Participant id "${r.id}" is duplicated.`,hint:"Give every participant a unique stable id and update message references."})),t.add(r.id)}),r=new Map(o.participants.map((e,t)=>[e.id,t])),o.participants.forEach(t=>{let n=rV(t.id),i=r.get(n);void 0!==i&&e.push(n6({code:"duplicate_node_id",stage:"input",ref:{kind:"request",path:`spec.participants.[${i}].id`},message:`Participant id "${n}" collides with the generated lifeline for "${t.id}".`,hint:"Rename the participant so its id does not equal another participant id followed by :lifeline."}))}),n=new Set,o.messages.forEach((r,i)=>{n.has(r.id)&&e.push(n6({code:"duplicate_edge_id",stage:"input",ref:{kind:"request",path:`spec.messages.[${i}].id`},message:`Message id "${r.id}" is duplicated.`,hint:"Give every message a unique id or omit message ids to generate them deterministically."})),n.add(r.id),t.has(r.source)||e.push(n6({code:"missing_edge_source",stage:"input",ref:{kind:"request",path:`spec.messages.[${i}].source`},message:`Message source "${r.source}" is not a participant.`,hint:"Use the id of a participant declared in spec.participants."})),t.has(r.target)||e.push(n6({code:"missing_edge_target",stage:"input",ref:{kind:"request",path:`spec.messages.[${i}].target`},message:`Message target "${r.target}" is not a participant.`,hint:"Use the id of a participant declared in spec.participants."})),r.source===r.target&&e.push(n6({code:"self_loop",stage:"input",ref:{kind:"request",path:`spec.messages.[${i}]`},message:`Message "${r.id}" is self-referential.`,hint:"Choose a different target participant; self messages are not supported."}))}),e}).pipe(s.fRP("codeMode.buildSequenceDiagram.validate"));if(c.length>0)return yield*new n2({status:"invalid_sequence",context:{...l,issues:c}});let u=yield*s.OH5(()=>{var e;return{accepted:10>=(e=i.options?.minQualityScore??8),score:10,threshold:e,summary:{nodeCount:o.participants.length,edgeCount:o.messages.length},checks:[]}}).pipe(s.fRP("codeMode.buildSequenceDiagram.quality")),d={...l,quality:u};if(!u.accepted)return yield*new n2({status:"quality_failed",context:{...d,issues:ii(u)}});let f=yield*s.SvU({try:()=>(function(e){let t=new Set(e.participants.map(e=>e.id));for(let r of e.participants){let e=rV(r.id);if(t.has(e))throw Error(`Sequence participant "${e}" collides with the generated lifeline for "${r.id}".`)}let r=Math.max(184,184+88*Math.max(0,e.messages.length-1))-120+56,n=new Map,i=[],a=[],s=[];e.participants.forEach((t,o)=>{let l=48+320*o,c=l+90;n.set(t.id,c),i.push({type:"node",id:`node:${t.id}`,nodeId:t.id,...t.kind?{kind:t.kind}:{},shape:"rectangle",x:l,y:48,width:180,height:72,label:t.label}),a.push({type:"text",id:`label:${t.id}`,containerId:`node:${t.id}`,x:c,y:84,text:t.label,fontSize:14,maxWidth:156}),s.push({type:"node",id:`node:${rV(t.id)}`,nodeId:rV(t.id),rendererRole:rG,shape:"rectangle",fillColor:e.style.backgroundColor,strokeColor:e.style.accentColor,x:c-1,y:120,width:2,height:r,label:`${t.label} lifeline`})});let o=e.messages.map((e,t)=>{let r=n.get(e.source),i=n.get(e.target);if(void 0===r||void 0===i)throw Error(`Sequence message "${e.id}" references an unknown participant.`);if(r===i)throw Error(`Sequence message "${e.id}" cannot target its source participant.`);let a=184+88*t,s=i>r?1:-1;return{type:"arrow",id:`arrow:${e.id}`,edgeId:e.id,sourceNodeId:rV(e.source),targetNodeId:rV(e.target),..."return"===e.type?{strokeColor:"#6b7280"}:{},..."dashed"===e.style||"return"===e.type?{strokeStyle:"dashed"}:{},points:[{x:r+2*s/2,y:a},{x:i-2*s/2,y:a}],label:e.label}});return{diagramId:e.id,title:e.title,width:276+320*Math.max(0,e.participants.length-1),height:120+r+48,accentColor:e.style.accentColor,backgroundColor:e.style.backgroundColor,elements:[...o,...s,...i,...a]}})(o),catch:e=>new n2({status:"render_failed",context:{...d,issues:[n6({code:"render_failed",stage:"render",ref:{kind:"diagram",id:o.id},message:e instanceof Error?e.message:"Unable to render sequence diagram scene.",hint:"Repair the participant/message structure and retry."})]}})}).pipe(s.fRP("codeMode.buildSequenceDiagram.render")),{excalidraw:h,validation:p}=yield*s.OH5(()=>{let e=nt(f);return{excalidraw:e,validation:nc(e)}}).pipe(s.fRP("codeMode.buildSequenceDiagram.exportValidate")),m={...d,partial:i$(f)};if(!p.ok)return yield*new n2({status:"export_failed",context:{...m,issues:ic(p.issues)}});let g=yield*io({formats:ia(i.options),scene:f,excalidraw:h,renderer:r.renderer}).pipe(s.xm_(e=>new n2({status:"export_failed",context:{...m,issues:il(e)}}))),y=yield*s.OH5(()=>r.createId("artifact")),v=yield*nD(n.write({artifactId:y,diagramId:f.diagramId,formats:g,inlineFormats:is(i.options)}),{artifactId:y,...i.requestId?{requestId:i.requestId}:{}}).pipe(s.xm_(e=>new n2({status:"storage_failed",context:{...d,issues:[iM(e,"storage_write_failed")]}})));return{ok:!0,status:"accepted",buildId:a,...iE(i.requestId),normalizedSpec:o,quality:u,artifact:iI(v,r.artifactUrl),issues:[]}}),ij=s.fn("codeMode.buildFlowchart.workflow")(function*(e){let t=yield*s.OH5(()=>th.safeParse(e)).pipe(s.fRP("codeMode.buildFlowchart.parse"));if(!t.success)return yield*new n0({status:"invalid_input",context:{issues:ie(t.error)}});let r=yield*nV,n=yield*rm,i=t.data,a=ia(i.options),o=yield*s.OH5(()=>r.createId("build")),l=yield*s.OH5(()=>{var e;let t;return t=ea((e=i.spec).title),{id:nY(e.id)??(t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"sketchi-flowchart"),title:t,nodes:e.nodes.map(e=>({id:ea(e.id),label:ea(e.label),kind:e.kind,...e.description?{description:ea(e.description)}:{}})),edges:e.edges.map((e,t)=>({id:nY(e.id)??`edge-${t+1}`,source:ea(e.source),target:ea(e.target),...e.label?{label:ea(e.label)}:{}})),layout:{direction:e.layout.direction},style:{...b}}}).pipe(s.fRP("codeMode.buildFlowchart.normalize")),c={buildId:o,...iE(i.requestId),normalizedSpec:l},u=yield*s.OH5(()=>W.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(s.fRP("codeMode.buildFlowchart.parseCanonical"));if(!u.success){var d;return yield*new n0({status:"invalid_flowchart",context:{...c,issues:(d=u.error,d.issues.slice(0,20).map(e=>{let t=function(e,t){let r=n9(e.path),n="input"===r?"spec":`spec.${r}`,[i,a]=e.path;if("nodes"===i&&"number"==typeof a){let e=t.nodes[a]?.id;return{kind:"node",...e?{id:e}:{},path:n}}if("edges"===i&&"number"==typeof a){let e=t.edges[a]?.id;return{kind:"edge",...e?{id:e}:{},path:n}}return{kind:"diagram",id:t.id,path:n}}(e,l);return n6({code:n4(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*s.OH5(()=>J(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 n6({code:e.code,stage:"flowchart",...t?{ref:t}:{},message:e.message,hint:e.hint})})).pipe(s.fRP("codeMode.buildFlowchart.validate"));if(h.length>0)return yield*new n0({status:"invalid_flowchart",context:{...c,issues:h}});yield*s.OH5(()=>G(f)).pipe(s.fRP("codeMode.buildFlowchart.assertValid"));let p=yield*s.OH5(()=>(function(e,t){let r=[],n=0,i=(e,t,i=!1)=>{n+=e,r.push({severity:i?"error":"warning",message:t})},a=new Map,s=new Map;for(let t of e.edges)a.set(t.source,(a.get(t.source)??0)+1),a.set(t.target,(a.get(t.target)??0)+1),s.set(t.source,[...s.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=>(a.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(nB)){let e=s.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=>nU.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||nF.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(s.fRP("codeMode.buildFlowchart.quality")),m={...c,quality:p};if(!p.accepted)return yield*new n0({status:"quality_failed",context:{...m,issues:ii(p)}});let g=yield*s.SvU({try:()=>rz(f),catch:e=>new n0({status:"render_failed",context:{...m,issues:[n6({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(s.fRP("codeMode.buildFlowchart.render")),{excalidraw:y,validation:v}=yield*s.OH5(()=>{let e=nt(g);return{excalidraw:e,validation:nc(e)}}).pipe(s.fRP("codeMode.buildFlowchart.exportValidate")),w={...m,partial:i$(g)};if(!v.ok)return yield*new n0({status:"export_failed",context:{...w,issues:ic(v.issues)}});let _=yield*io({formats:a,scene:g,excalidraw:y,renderer:r.renderer}).pipe(s.xm_(e=>new n0({status:"export_failed",context:{...w,issues:il(e)}}))),x=yield*s.OH5(()=>r.createId("artifact")),k=yield*nD(n.write({artifactId:x,diagramId:g.diagramId,formats:_,inlineFormats:is(i.options)}),{artifactId:x,...i.requestId?{requestId:i.requestId}:{}}).pipe(s.xm_(e=>new n0({status:"storage_failed",context:{...m,issues:[iM(e,"storage_write_failed")]}})));return{ok:!0,status:"accepted",buildId:o,...iE(i.requestId),normalizedSpec:l,quality:p,artifact:iI(k,r.artifactUrl),issues:[]}}),iD=s.fn("codeMode.getArtifact.workflow")(function*(e){let t=yield*s.OH5(()=>tF.safeParse(e)).pipe(s.fRP("codeMode.getArtifact.parse"));if(!t.success)return yield*new n5({status:"invalid_input",issues:ie(t.error)});let r=yield*nV,n=yield*rm,i=t.data,a=yield*n.readManifest(i.artifactId).pipe(s.xm_(e=>new n5({status:"storage_failed",issues:[iM(e,"storage_read_failed")]})));if(!a)return yield*new n5({status:"not_found",issues:[n6({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(!a.formats.some(e=>e.format===o))return yield*new n5({status:"format_unavailable",issues:[n6({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(s.xm_(e=>new n5({status:"storage_failed",issues:[iM(e,"storage_read_failed")]})));return l?{ok:!0,artifactId:i.artifactId,diagramId:a.diagramId,format:o,mimeType:l.mimeType,...r.artifactUrl?{url:r.artifactUrl({artifactId:i.artifactId,format:o})}:{},...!0!==i.inline||!ry(o)?{}:{inline:l.data},sizeBytes:l.sizeBytes,...a.provenance?{provenance:a.provenance}:{}}:yield*new n5({status:"format_unavailable",issues:[n6({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."})]})}),iL=s.fn("codeMode.applyDiagramPatch.workflow")(function*(e){let t=yield*s.OH5(()=>t5.safeParse(e)).pipe(s.fRP("codeMode.applyDiagramPatch.parse"));if(!t.success)return yield*new n3({status:"invalid_input",context:{issues:ie(t.error)}});let r=yield*nV,n=yield*rm,i=t.data,a=yield*s.OH5(()=>r.createId("patch")),o={patchId:a,...iE(i.requestId)},l=ia(i.options),c=yield*iS(i).pipe(s.xm_(e=>new n3({status:e.status,context:{...o,...e.context}}))),u={...o,...c.sourceArtifactId?{sourceArtifactId:c.sourceArtifactId}:{}},d=c.scene,f=id(d),h=yield*s.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),ih(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 im(e))t.style.strokeColor&&(r.strokeColor=t.style.strokeColor),t.style.textColor&&(r.textColor=t.style.textColor);for(let r of ip(e))t.style.textColor&&(r.textColor=t.style.textColor);return[]}let r=iy(e,t.selector);if(0===r.nodes.length&&0===r.arrows.length&&0===r.texts.length)return[ib(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=iv(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=iv(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=iy(e,t.selector);if(0===n.nodes.length)return[ib(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=iv(e,t.id);r&&(r.x=t.x+t.width/2,r.y=t.y+t.height/2)}(e,r)}return iw(e,i),[];case"translate":return function(e,t){let r=iy(e,t.selector);if(0===r.nodes.length&&0===r.arrows.length&&0===r.texts.length)return[ib(t)];let n=new Set,i=new Set;for(let a of r.nodes){a.x+=t.dx,a.y+=t.dy,n.add(a.nodeId);let r=iv(e,a.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=iv(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 iw(e,[...n]),function(e){let t=[e.width],r=[e.height];for(let n of ih(e))t.push(n.x+n.width),r.push(n.y+n.height);for(let n of ip(e))t.push(n.x+(n.maxWidth??0)),r.push(n.y+n.fontSize);for(let n of im(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 a=iy(e,t.selector);if(0===a.nodes.length&&0===a.arrows.length&&0===a.texts.length)return[ib(t)];for(let r of a.nodes){r.label=t.text;let n=iv(e,r.id);n&&(n.text=t.text)}for(let r of a.arrows){r.label=t.text;let n=iv(e,r.id);n&&(n.text=t.text)}for(let e of a.texts)e.text=t.text;return[];case"rerouteEdges":let s;return 0===(s=iy(e,t.selector)).arrows.length?[ib(t)]:s.arrows.flatMap(t=>ik(e,t))}}(d,e);if(t.length>0)return t}return[]}).pipe(s.fRP("codeMode.applyDiagramPatch.operations"));if(h.length>0)return yield*new n3({status:h[0]?.code==="unknown_patch_target"?"target_not_found":"unsupported_operation",context:{...u,issues:h}});if(i.options?.preserveConnectivity!==!1){let e=id(d);if(!(f.length===e.length&&f.every((t,r)=>t===e[r])))return yield*new n3({status:"connectivity_changed",context:{...u,issues:[n6({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*s.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 a=[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.strokeStyle?{strokeStyle:r.strokeStyle}:{},...r.textColor?{textColor:r.textColor}:{},points:a,...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}:{},..."sequence-lifeline"===r.rendererRole&&function(e,t){let r=":lifeline";if(!t.nodeId.endsWith(r)||t.id!==`node:${t.nodeId}`||"rectangle"!==t.shape||2!==t.width||t.height<120)return!1;let n=t.nodeId.slice(0,-r.length);if(0===n.length)return!1;let i=e.elements.find(e=>"node"===e.type&&e.id===`node:${n}`&&e.nodeId===n);return!!i&&.01>=Math.abs(t.x+t.width/2-(i.x+i.width/2))&&t.y>=i.y+i.height-.01}(e,r)?{rendererRole:r.rendererRole}:{},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(s.fRP("codeMode.applyDiagramPatch.normalize"));if(!p)return yield*new n3({status:"render_failed",context:{...u,issues:[n6({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*s.OH5(()=>{let e=nt(p);return{excalidraw:e,validation:nc(e)}}).pipe(s.fRP("codeMode.applyDiagramPatch.exportValidate")),y={...u,partial:i$(p)};if(!g.ok)return yield*new n3({status:"export_failed",context:{...y,issues:ic(g.issues)}});let b=yield*io({formats:l,scene:p,excalidraw:m,renderer:r.renderer}).pipe(s.xm_(e=>new n3({status:"export_failed",context:{...y,issues:il(e)}}))),v=yield*s.OH5(()=>r.createId("artifact")),w=yield*nD(n.write({artifactId:v,diagramId:p.diagramId,formats:b,inlineFormats:is(i.options),...c.sourceArtifactId?{provenance:{sourceArtifactId:c.sourceArtifactId}}:{}}),{artifactId:v,...i.requestId?{requestId:i.requestId}:{}}).pipe(s.xm_(e=>new n3({status:"storage_failed",context:{...u,issues:[iM(e,"storage_write_failed")]}})));return{ok:!0,status:"accepted",patchId:a,...iE(i.requestId),...c.sourceArtifactId?{sourceArtifactId:c.sourceArtifactId}:{},artifact:iI(w,r.artifactUrl),issues:[]}});function iU(e,t){return e.pipe(s.YWq({onFailure:t,onSuccess:e=>e}))}let iF=s.fn("codeMode.buildFlowchart")(e=>nQ("buildFlowchart",e,iU(ij(e),iO))),iB=s.fn("codeMode.buildMindmap")(e=>nQ("buildMindmap",e,iU(iP(e),iT)));s.fn("codeMode.buildSequenceDiagram")(e=>nQ("buildSequenceDiagram",e,iU(iR(e),iA))),s.fn("codeMode.getArtifact")(e=>nQ("getArtifact",e,iU(iD(e),iC)));let iY=s.fn("codeMode.applyDiagramPatch")(e=>nQ("applyDiagramPatch",e,iU(iL(e),iN)))},9095(e){e.exports=JSON.parse('[{"name":"Agola CI","constant":"AGOLA","env":"AGOLA_GIT_REF","pr":"AGOLA_PULL_REQUEST_ID"},{"name":"Alpic","constant":"ALPIC","env":"ALPIC_HOST"},{"name":"Appcircle","constant":"APPCIRCLE","env":"AC_APPCIRCLE","pr":{"env":"AC_GIT_PR","ne":"false"}},{"name":"AppVeyor","constant":"APPVEYOR","env":"APPVEYOR","pr":"APPVEYOR_PULL_REQUEST_NUMBER"},{"name":"AWS CodeBuild","constant":"CODEBUILD","env":"CODEBUILD_BUILD_ARN","pr":{"env":"CODEBUILD_WEBHOOK_EVENT","any":["PULL_REQUEST_CREATED","PULL_REQUEST_UPDATED","PULL_REQUEST_REOPENED"]}},{"name":"Azure Pipelines","constant":"AZURE_PIPELINES","env":"TF_BUILD","pr":{"BUILD_REASON":"PullRequest"}},{"name":"Bamboo","constant":"BAMBOO","env":"bamboo_planKey"},{"name":"Bitbucket Pipelines","constant":"BITBUCKET","env":"BITBUCKET_COMMIT","pr":"BITBUCKET_PR_ID"},{"name":"Bitrise","constant":"BITRISE","env":"BITRISE_IO","pr":"BITRISE_PULL_REQUEST"},{"name":"Buddy","constant":"BUDDY","env":"BUDDY_WORKSPACE_ID","pr":"BUDDY_EXECUTION_PULL_REQUEST_ID"},{"name":"Buildkite","constant":"BUILDKITE","env":"BUILDKITE","pr":{"env":"BUILDKITE_PULL_REQUEST","ne":"false"}},{"name":"CircleCI","constant":"CIRCLE","env":"CIRCLECI","pr":"CIRCLE_PULL_REQUEST"},{"name":"Cirrus CI","constant":"CIRRUS","env":"CIRRUS_CI","pr":"CIRRUS_PR"},{"name":"Cloudflare Pages","constant":"CLOUDFLARE_PAGES","env":"CF_PAGES"},{"name":"Cloudflare Workers","constant":"CLOUDFLARE_WORKERS","env":"WORKERS_CI"},{"name":"Codefresh","constant":"CODEFRESH","env":"CF_BUILD_ID","pr":{"any":["CF_PULL_REQUEST_NUMBER","CF_PULL_REQUEST_ID"]}},{"name":"Codemagic","constant":"CODEMAGIC","env":"CM_BUILD_ID","pr":"CM_PULL_REQUEST"},{"name":"Codeship","constant":"CODESHIP","env":{"CI_NAME":"codeship"}},{"name":"Drone","constant":"DRONE","env":"DRONE","pr":{"DRONE_BUILD_EVENT":"pull_request"}},{"name":"dsari","constant":"DSARI","env":"DSARI"},{"name":"Earthly","constant":"EARTHLY","env":"EARTHLY_CI"},{"name":"Expo Application Services","constant":"EAS","env":"EAS_BUILD"},{"name":"Gerrit","constant":"GERRIT","env":"GERRIT_PROJECT"},{"name":"Gitea Actions","constant":"GITEA_ACTIONS","env":"GITEA_ACTIONS"},{"name":"GitHub Actions","constant":"GITHUB_ACTIONS","env":"GITHUB_ACTIONS","pr":{"GITHUB_EVENT_NAME":"pull_request"}},{"name":"GitLab CI","constant":"GITLAB","env":"GITLAB_CI","pr":"CI_MERGE_REQUEST_ID"},{"name":"GoCD","constant":"GOCD","env":"GO_PIPELINE_LABEL"},{"name":"Google Cloud Build","constant":"GOOGLE_CLOUD_BUILD","env":"BUILDER_OUTPUT"},{"name":"Harness CI","constant":"HARNESS","env":"HARNESS_BUILD_ID"},{"name":"Heroku","constant":"HEROKU","env":{"env":"NODE","includes":"/app/.heroku/node/bin/node"}},{"name":"Hudson","constant":"HUDSON","env":"HUDSON_URL"},{"name":"Jenkins","constant":"JENKINS","env":["JENKINS_URL","BUILD_ID"],"pr":{"any":["ghprbPullId","CHANGE_ID"]}},{"name":"LayerCI","constant":"LAYERCI","env":"LAYERCI","pr":"LAYERCI_PULL_REQUEST"},{"name":"Magnum CI","constant":"MAGNUM","env":"MAGNUM"},{"name":"Netlify CI","constant":"NETLIFY","env":"NETLIFY","pr":{"env":"PULL_REQUEST","ne":"false"}},{"name":"Nevercode","constant":"NEVERCODE","env":"NEVERCODE","pr":{"env":"NEVERCODE_PULL_REQUEST","ne":"false"}},{"name":"Prow","constant":"PROW","env":"PROW_JOB_ID"},{"name":"ReleaseHub","constant":"RELEASEHUB","env":"RELEASE_BUILD_ID"},{"name":"Render","constant":"RENDER","env":"RENDER","pr":{"IS_PULL_REQUEST":"true"}},{"name":"Sail CI","constant":"SAIL","env":"SAILCI","pr":"SAIL_PULL_REQUEST_NUMBER"},{"name":"Screwdriver","constant":"SCREWDRIVER","env":"SCREWDRIVER","pr":{"env":"SD_PULL_REQUEST","ne":"false"}},{"name":"Semaphore","constant":"SEMAPHORE","env":"SEMAPHORE","pr":"PULL_REQUEST_NUMBER"},{"name":"Sourcehut","constant":"SOURCEHUT","env":{"CI_NAME":"sourcehut"}},{"name":"Strider CD","constant":"STRIDER","env":"STRIDER"},{"name":"TaskCluster","constant":"TASKCLUSTER","env":["TASK_ID","RUN_ID"]},{"name":"TeamCity","constant":"TEAMCITY","env":"TEAMCITY_VERSION"},{"name":"Travis CI","constant":"TRAVIS","env":"TRAVIS","pr":{"env":"TRAVIS_PULL_REQUEST","ne":"false"}},{"name":"Vela","constant":"VELA","env":"VELA","pr":{"VELA_PULL_REQUEST":"1"}},{"name":"Vercel","constant":"VERCEL","env":{"any":["NOW_BUILDER","VERCEL"]},"pr":"VERCEL_GIT_PULL_REQUEST_ID"},{"name":"Visual Studio App Center","constant":"APPCENTER","env":"APPCENTER_BUILD_ID"},{"name":"Woodpecker","constant":"WOODPECKER","env":{"CI":"woodpecker"},"pr":{"CI_BUILD_EVENT":"pull_request"}},{"name":"Xcode Cloud","constant":"XCODE_CLOUD","env":"CI_XCODE_PROJECT","pr":"CI_PULL_REQUEST_NUMBER"},{"name":"Xcode Server","constant":"XCODE_SERVER","env":"XCS"}]')}},o={};function l(e){var t=o[e];if(void 0!==t)return t.exports;var r=o[e]={exports:{}};return s[e].call(r.exports,r,r.exports,l),r.exports}l.m=s,l.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return l.d(t,{a:t}),t},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 a={};r=r||[null,n({}),n([]),n(n)];for(var s=2&t&&e;("object"==typeof s||"function"==typeof s)&&!~r.indexOf(s);s=n(s))Object.getOwnPropertyNames(s).forEach(t=>{a[t]=()=>e[t]});return a.default=()=>e,l.d(i,a),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:"bdee8e123d2a353d",869:"cacc093c4bbc5a04"})[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},a=e=>{var t,r,n=e.__rspack_esm_ids,a=e.__webpack_modules__,s=e.__rspack_esm_runtime,o=0;for(t in a)l.o(a,t)&&(l.m[t]=a[t]);for(s&&s(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(a,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(7192);
263
+ ${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=R(e);this.currentStackFrame&&(r=(0,I.Eh)(r,o.L8(I.z8,this.currentStackFrame))),t&&(r=(0,I.Eh)(r,t)),this._interruptedCause=this._interruptedCause?H(this._interruptedCause,r):r,this.interruptible&&this.evaluate(eO(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===I.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(ej,()=>e)}if(n=this.currentTracerContext?this.currentTracerContext(n,this):n[I._3](this),i!==this.currentLoopCount)return I.GN;if(n===I.GN){let e=this._yielded;if(I.IH in e)return this._yielded=void 0,e;return I.GN}}}catch(e){if(!(0,v.i5)(n,I._3))return(0,I.V2)(`Fiber.runLoop: Not a valid effect: ${String(n)}`);return this.runLoop((0,I.V2)(e))}finally{globalThis[w.fL]=t}}getCont(e){for(;;){let t=this._stack.pop();if(!t)return;let r=t[I.u4]&&t[I.u4](this);if(r)return r[e]=r,r;if(t[e])return t}}yieldWith(e){return this._yielded=e,I.GN}children(){return this._children??=new Set}pipe(){return(0,b.tT)(this,arguments)}setContext(e){this.context=e;let t=this.getRef(_._F);t!==this.currentScheduler&&(this.currentScheduler=t,this._dispatcher=void 0),this.currentSpan=e.mapUnsafe.get(k.WG),this.currentLogLevel=this.getRef(O.Gl),this.minimumLogLevel=this.getRef(O.zQ),this.currentStackFrame=e.mapUnsafe.get(O.vA.key),this.maxOpsBeforeYield=this.getRef(_.Zm),this.currentPreventYield=this.getRef(_.hf),this.runtimeMetrics=e.mapUnsafe.get($.F);let r=e.mapUnsafe.get(k.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(I.z8.key,e.currentStackFrame),o.LZ(t)},eb=e=>{if(void 0!==e._children&&0!==e._children.size)return eI(e._children)},ev=e=>e._exit?e$(e._exit):eQ(t=>e._exit?t(e$(e._exit)):eT(e.addObserver(e=>t(e$(e))))),ew=e=>eQ(t=>{let r,n=e[Symbol.iterator](),i=[];return!function e(){let a=n.next();for(;!a.done;){if(a.value._exit){i.push(a.value._exit),a=n.next();continue}r=a.value.addObserver(t=>{i.push(t),e()});return}t(e$(i))}(),eT(()=>r?.())}),ex=e=>e._exit?e._exit:eQ(t=>e._exit?t(e._exit):eT(e.addObserver(t))),e_=e=>eQ(t=>{let r=Array.from(e);if(0===r.length)return t(e$(s.Ie()));let n=Array(r.length),i=s.Ie(),a=0,o=!1;for(let e=0;e<r.length&&!o;e++)i.push(r[e].addObserver(s=>{if(a++,"Failure"===s._tag)return o=!0,i.forEach(e=>e()),t(s);n[e]=s.value,a===r.length&&t(e$(n))}))}),ek=e=>(0,I.R6)(t=>eS(e,t.id)),eS=(0,f.XY)(e=>(0,v.i5)(e[0],ed),(e,t,r)=>(0,I.R6)(n=>{let i=ey(n);return i=i&&r?o.h1(i,r):i??r,e.interruptUnsafe(t,i),ti(ev(e))})),eI=e=>(0,I.R6)(t=>{let r=ey(t),n=s.Ie();for(let i of e)i.interruptUnsafe(t.id,r),n.push(i);return ti(ew(n))}),eE=(0,f.XY)(2,(e,t)=>(0,I.R6)(r=>{let n=ey(r),i=s.Ie();for(let r of e)r.interruptUnsafe(t,n),i.push(r);return ti(ew(i))})),e$=I.xt,eO=I.cb,eC=I.Rk,eT=(0,I.Uf)({op:"Sync",[I._3](e){let t=this[I.a2](),r=e.getCont(I.ee);return r?r[I.ee](t,e):e.yieldWith((0,I.xt)(t))}}),eA=(0,I.Uf)({op:"Suspend",[I._3](e){return this[I.a2]()}}),eM=(0,f.XY)(e=>e.length>=2||g.isOption(e[0]),(e,t)=>g.isNone(e)?eC(t?t():new I.Xm("Effect.fromOption: Option.none")):e$(e.value)),eN=x.YW({onFailure:eC,onSuccess:e$}),eP=e=>null==e?eC(new I.Xm):e$(e),eR=(0,I.Uf)({op:"Yield",[I._3](e){let t=!1;return e.currentDispatcher.scheduleTask(()=>{t||e.evaluate(tN)},this[I.a2]??0),e.yieldWith(()=>{t=!0})}}),ej=eR(0),eD=e=>e$(g.some(e)),eL=e$(g.none()),eU=e=>g.isNone(e)?eL:tg(e.value,g.some),eF=e=>eA(()=>eO((0,S.s)(e))),eB=e=>(0,I.V2)(e),eW=e=>eA(()=>eC((0,S.s)(e))),eq=e$(void 0),eY=e=>{let t="function"==typeof e?e:e.try,r="function"==typeof e?e=>new i8(e,"An error occurred in Effect.try"):e.catch;return eA(()=>{try{return e$((0,S.s)(t))}catch(e){return eC((0,S.s)(()=>r(e)))}})},ez=e=>eK(function(t,r){(0,S.s)(()=>e(r)).then(e=>t(e$(e)),e=>t(eB(e)))},0!==e.length),eX=e=>{let t="function"==typeof e?e:e.try,r="function"==typeof e?e=>new i8(e,"An error occurred in Effect.tryPromise"):e.catch;return eK(function(e,n){let i=t=>{try{e(eC((0,S.s)(()=>r(t))))}catch(t){e(eB(t))}};try{(0,S.s)(()=>t(n)).then(t=>e(e$(t)),i)}catch(e){i(e)}},0!==t.length)},eJ=e=>(0,I.R6)(t=>e(t.id)),eG=(0,I.R6)(e$),eV=eJ(e$),eK=(0,I.Uf)({op:"Async",single:!1,[I._3](e){let t=(0,S.s)(()=>this[I.a2][0].bind(e.currentScheduler)),r=!1,n=!1,i=this[I.a2][1]?new AbortController:void 0,a=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===a||e._stack.push(eH(()=>(r=!0,i?.abort(),a??tN))),I.GN)}}),eH=(0,I.Uf)({op:"AsyncFinalizer",[I.u4](e){e.interruptible&&(e.interruptible=!1,e._stack.push(n_))},[I.Sc](e,t){return q(e)?tu(this[I.a2](),()=>eO(e)):eO(e)}}),eQ=e=>eK(e,e.length>=2),eZ=eQ(f.Yi),e0=(...e)=>eA(()=>e4(1===e.length?e[0]():e[1].call(e[0].self))),e1=(e,...t)=>{let r=0===t.length?function(){return eA(()=>e4(e.apply(this,arguments)))}:function(){let r=eA(()=>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}),e5=A(2),e3=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,...a)=>e8(t,n,i,a,e,r):e8(t,arguments[0],i,Array.prototype.slice.call(arguments,1),e,r)},e8=(e,t,r,n,i,a)=>{let s="function"==typeof t?t:n.pop().bind(t.self);return e2(s.length,function(...t){let o=eA(()=>{let e=s.apply(this,arguments);return(0,I.yw)(e)?e:e4(e)});for(let e=0;e<n.length;e++)o=n[e](o,...t);if(!(0,I.yw)(o))return o;let l=(0,C.jt)();(0,C.ft)(2);let c=new globalThis.Error;return(0,C.ft)(l),tG(i?iO(e,a,e=>iC(o,e)):o,O.vA,t=>({name:e,stack:e5(()=>c.stack),parent:{name:`${e} (definition)`,stack:e5(()=>r.stack),parent:t}}))})},e6=(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 eA(()=>t?(t=!1,tu(n.value,e=>e4(r,e))):eA(()=>e4(e())))}}}catch(e){return eB(e)}},e4=(0,I.Uf)({op:"Iterator",single:!1,[I.ee](e,t){let r=this[I.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}},[I._3](e){return this[I.ee](this[I.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,I.yw)(t)?t:(0,S.s)(()=>t(e)))),tn=(0,f.XY)(2,(e,t)=>tu(e,e=>e7((0,I.yw)(t)?t:(0,S.s)(()=>t(e)),e))),ti=e=>tu(e,e=>tN),ta=e=>rt(e,eC),ts=(e,t)=>(0,I.R6)(r=>eQ(n=>{let i=s.Ts(e),a=i.length,o=0,l=!1,c=new Set,u=[],d=(e,i,s)=>{if(o++,"Failure"===e._tag){u.push(...e.cause.reasons),o>=a&&n(eO((0,I.b5)(u)));return}let d=!l;l=!0,n(0===c.size?e:tu(nw(eI(c)),()=>e)),d&&t?.onWinner&&t.onWinner({fiber:i,index:s,parentFiber:r})};for(let e=0;e<a;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 eI(c)})),to=(e,t)=>(0,I.R6)(r=>eQ(n=>{let i=!1,a=new Set,s=e=>{i=!0,n(0===a.size?e:tu(nw(eI(a)),()=>e))},o=0;for(let n of e){if(i)break;let e=o++,l=nQ(r,n,!0,!0,!1);a.add(l),l.addObserver(n=>{a.delete(l);let o=!i;s(n),o&&t?.onWinner&&t.onWinner({fiber:l,index:e,parentFiber:r})})}return eI(a)})),tl=(0,f.XY)(e=>(0,I.yw)(e[1]),(e,t,r)=>ts([e,t],r)),tc=(0,f.XY)(e=>(0,I.yw)(e[1]),(e,t,r)=>to([e,t],r)),tu=(0,f.XY)(2,(e,t)=>{let r=Object.create(td);return r[I.a2]=e,r[I.ee]=1!==t.length?e=>t(e):t,r}),td=(0,I.yj)({op:"OnSuccess",[I._3](e){return e._stack.push(this),this[I.a2]}}),tf=(0,f.XY)(2,(e,t)=>th(e)?"Success"===e._tag?t.onSuccess(e.value):t.onFailure(e.cause):rA(e,t)),th=e=>I.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.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)?tR(e,t):rx(e,t)),tv=(0,f.XY)(2,(e,t)=>th(e)?tj(e,t):r_(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 ra(e,t)}),tx=e=>(0,I.cb)(R(e)),t_=e=>"Success"===e._tag,tk=e=>"Success"===e._tag?x.Py(e):x.fJ(e),tS=e=>"Success"===e._tag?x.Py(e.value):x.fJ(e),tI=e=>"Failure"===e._tag,tE=e=>"Failure"===e._tag?x.Py(e):x.fJ(e),t$=e=>"Failure"===e._tag?x.Py(e.cause):x.fJ(e),tO=u.Bh(t$,L),tC=u.Bh(t$,W),tT=e=>"Failure"===e._tag&&q(e.cause),tA=e=>"Failure"===e._tag&&F(e.cause),tM=e=>"Failure"===e._tag&&j(e.cause),tN=(0,I.xt)(void 0),tP=(0,f.XY)(2,(e,t)=>"Success"===e._tag?(0,I.xt)(t(e.value)):e),tR=(0,f.XY)(2,(e,t)=>{if("Success"===e._tag)return e;let r=L(e.cause);return x.N6(r)?e:(0,I.Rk)(t(r.success))}),tj=(0,f.XY)(2,(e,t)=>{if("Success"===e._tag)return(0,I.xt)(t.onSuccess(e.value));let r=L(e.cause);return x.N6(r)?e:(0,I.Rk)(t.onFailure(r.success))}),tD=(0,f.XY)(2,(e,t)=>t_(e)?(0,I.xt)(t):e),tL=(0,f.XY)(2,(e,t)=>t_(e)?t:e),tU=(0,f.XY)(2,(e,t)=>t_(e)?t.onSuccess(e.value):t.onFailure(e.cause)),tF=tD(void 0),tB=e=>{let t=[];for(let r of e)"Failure"===r._tag&&t.push(...r.cause.reasons);return 0===t.length?tN:(0,I.cb)((0,I.b5)(t))},tW=e=>t_(e)?g.some(e.value):g.none(),tq=e=>tI(e)?g.some(e.cause):g.none(),tY=e=>{let t=tO(e);return x.N6(t)?g.none():g.some(t.success)},tz=e=>e,tX=e=>(0,I.R6)(t=>e$(o.om(t.context,e))),tJ=(0,f.XY)(2,(e,t)=>(0,I.R6)(r=>{let n=r.context,i=t(n);return n===i?e:(r.setContext(i),na(e,()=>{r.setContext(n)}))})),tG=(0,f.XY)(3,(e,t,r)=>tJ(e,e=>{let n=o.fp(e,t),i=r(n);return n===i?e:o.WQ(e,t,i)})),tV=()=>tK,tK=(0,I.R6)(e=>e$(e.context)),tH=e=>(0,I.R6)(t=>e(t.context)),tQ=(0,f.XY)(2,(e,t)=>tJ(e,(0,f.dY)(t))),tZ=(0,f.XY)(2,(e,t)=>th(e)?e:tJ(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)=>tJ(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))),t5=t0(O.F8),t3=(0,f.XY)(e=>(0,I.yw)(e[1]),(e,t,r)=>t8(e,t,(e,t)=>[e,t],r)),t8=(0,f.XY)(e=>(0,I.yw)(e[1]),(e,t,r,n)=>n?.concurrent?tg(nO([e,t],{concurrency:2}),([e,t])=>(0,S.s)(()=>r(e,t))):tu(e,e=>tg(t,t=>(0,S.s)(()=>r(e,t))))),t6=(0,f.XY)(e=>(0,I.yw)(e[0]),(e,t,r)=>nB(e,t,r?e=>eC(r(e)):()=>eC(new I.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,I.yw)(e[0]),(e,t,r)=>nO(t4(e,t),r)),re=(0,f.XY)(e=>(0,I.yw)(e[0]),(e,t)=>nR({while:f.ue,body:(0,f.dY)(t?.disableYield?e:tu(e,e=>ej)),step:f.Yi})),rt=(0,f.XY)(2,(e,t)=>{let r=Object.create(rr);return r[I.a2]=e,r[I.Sc]=1!==t.length?e=>t(e):t,r}),rr=(0,I.yj)({op:"OnFailure",[I._3](e){return e._stack.push(this),this[I.a2]}}),rn=(0,f.XY)(3,(e,t,r)=>rt(e,e=>t(e)?(0,S.s)(()=>r(e)):eO(e))),ri=(0,f.XY)(3,(e,t,r)=>rt(e,e=>{let n=t(e);return x.N6(n)?eO(n.failure):(0,S.s)(()=>r(n.success,e))})),ra=(0,f.XY)(2,(e,t)=>ri(e,L,e=>t(e))),rs=e=>rP(e,{onFailure:e=>(0,I.PW)(e)?eL:eC(e),onSuccess:eD}),ro=(0,f.XY)(2,(e,t)=>ri(e,W,t)),rl=(0,f.XY)(2,(e,t)=>rt(e,e=>tr((0,S.s)(()=>t(e)),eO(e)))),rc=(0,f.XY)(3,(e,t,r)=>rn(e,t,e=>tr((0,S.s)(()=>r(e)),eO(e)))),ru=(0,f.XY)(3,(e,t,r)=>rt(e,e=>{let n=t(e);return x.N6(n)?eO(e):tr((0,S.s)(()=>r(n.success,e)),eO(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):eq)}),rh=(0,f.XY)(2,(e,t)=>ru(e,W,e=>t(e))),rp=(0,f.XY)(e=>(0,I.yw)(e[0]),(e,t,r,n)=>rt(e,e=>{let i=L(e);return x.N6(i)?eO(i.failure):t(i.success)?(0,S.s)(()=>r(i.success)):n?(0,S.s)(()=>n(i.success)):eO(e)})),rm=(0,f.XY)(e=>(0,I.yw)(e[0]),(e,t,r,n)=>rt(e,e=>{let i=L(e);if(x.N6(i))return eO(i.failure);let a=t(i.success);return x.N6(a)?n?(0,S.s)(()=>n(a.failure)):eO(e):(0,S.s)(()=>r(a.success))})),rg=(0,f.XY)(e=>(0,I.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,I.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.s)(()=>t[e._tag](e)),r)}),rb=(0,f.XY)(e=>(0,I.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.s)(()=>i(t,e)):eC(e)})),rv=(0,f.XY)(e=>(0,I.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.s)(()=>r[t._tag](t,e)):n?(0,S.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)=>ra(e,e=>eW(()=>t(e)))),r_=(0,f.XY)(2,(e,t)=>rP(e,{onFailure:e=>eW(()=>t.onFailure(e)),onSuccess:e=>eT(()=>t.onSuccess(e))})),rk=e=>ra(e,eB),rS=(0,f.XY)(2,(e,t)=>ra(e,e=>eT(t))),rI=e=>eA(()=>{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:ra(r.value,t=>e(n))}(r)}),rE=e=>ra(e,t=>tu(ej,()=>rE(e))),r$=(0,f.XY)(e=>(0,I.yw)(e[0]),(e,t)=>{if(!t?.log)return rP(e,{onFailure:e=>eq,onSuccess:e=>eq});let r=aa(!0===t.log?void 0:t.log);return rA(e,{onFailure(e){let n=D(e);return x.N6(n)?eO(n.failure):void 0===t.message?r(e):r(t.message,e)},onSuccess:e=>eq})}),rO=(0,f.XY)(e=>(0,I.yw)(e[0]),(e,t)=>{if(!t?.log)return rA(e,{onFailure:e=>eq,onSuccess:e=>eq});let r=aa(!0===t.log?void 0:t.log);return rA(e,{onFailure:e=>void 0===t.message?r(e):r(t.message,e),onSuccess:e=>eq})}),rC=e=>rR(e,{onFailure:g.none,onSuccess:g.some}),rT=e=>rj(e,{onFailure:x.fJ,onSuccess:x.Py}),rA=(0,f.XY)(2,(e,t)=>{let r=Object.create(rM);return r[I.a2]=e,r[I.ee]=1!==t.onSuccess.length?e=>t.onSuccess(e):t.onSuccess,r[I.Sc]=1!==t.onFailure.length?e=>t.onFailure(e):t.onFailure,r}),rM=(0,I.yj)({op:"OnSuccessAndFailure",[I._3](e){return e._stack.push(this),this[I.a2]}}),rN=(0,f.XY)(2,(e,t)=>rA(e,{onFailure:e=>eT(()=>t.onFailure(e)),onSuccess:e=>eT(()=>t.onSuccess(e))})),rP=(0,f.XY)(2,(e,t)=>rA(e,{onFailure:e=>{let r=e.reasons.find(I.lC);return r?(0,S.s)(()=>t.onFailure(r.error)):eO(e)},onSuccess:t.onSuccess})),rR=(0,f.XY)(2,(e,t)=>rP(e,{onFailure:e=>eT(()=>t.onFailure(e)),onSuccess:e=>eT(()=>t.onSuccess(e))})),rj=(0,f.XY)(2,(e,t)=>{if(th(e)){if("Success"===e._tag)return(0,I.xt)(t.onSuccess(e.value));let r=L(e.cause);return x.N6(r)?e:(0,I.xt)(t.onFailure(r.success))}return rR(e,t)}),rD=(0,f.XY)(2,(e,t)=>th(e)?"Success"===e._tag?(0,I.xt)(t.onSuccess(e.value)):(0,I.xt)(t.onFailure(e.cause)):rN(e,t)),rL=e=>th(e)?(0,I.xt)(e):rU(e),rU=(0,I.Uf)({op:"Exit",[I._3](e){return e._stack.push(this),this[I.a2]},[I.ee]:(e,t,r)=>e$(r??(0,I.xt)(e)),[I.Sc]:(e,t,r)=>e$(r??(0,I.cb)(e))}),rF=rj({onFailure:()=>!0,onSuccess:()=>!1}),rB=rj({onFailure:()=>!1,onSuccess:()=>!0}),rW=(0,f.XY)(2,(e,t)=>tr(iW(t),e)),rq=(0,f.XY)(2,(e,t)=>tc(e,tu(iW(t.duration),t.orElse))),rY=(0,f.XY)(2,(e,t)=>rq(e,{duration:t,orElse:()=>eC(new iJ)})),rz=(0,f.XY)(2,(e,t)=>tc(te(e),e7(iW(t),g.none()))),rX=e=>iB(t=>{let r=t.currentTimeNanosUnsafe();return tg(e,e=>[l.cF(t.currentTimeNanosUnsafe()-r),e])}),rJ="~effect/Scope",rG="~effect/Scope/Closeable",rV=o.kl("effect/Scope"),rK=(e,t)=>eA(()=>rH(e,t)??eq),rH=(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=[],a=Array.from(t.values()),s=ep();for(let t=a.length-1;t>=0;t--){let o=a[t];"sequential"===e.strategy?n.push((yield*rL(o(r)))):i.push(nQ(s,o(r),!0,!0,"inherit"))}return i.length>0&&(n=yield*ew(i)),yield*tB(n)}),rZ=(e,t)=>eT(()=>r0(e,t)),r0=(e,t)=>{let r=r8(t);if("Closed"===e.state._tag)return r.state=e.state,r;let n={};return r5(e,n,e=>rK(r,e)),r5(r,n,t=>eT(()=>r3(e,n))),r},r1=(e,t)=>eA(()=>"Closed"===e.state._tag?t(e.state.exit):(r5(e,{},t),eq)),r2=(e,t)=>r1(e,(0,f.dY)(t)),r5=(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)},r3=(e,t)=>{"Open"===e.state._tag&&e.state.finalizers.delete(t)},r8=(e="sequential")=>({[rG]:rG,[rJ]:rJ,strategy:e,state:r6}),r6={_tag:"Empty"},r9=e=>eT(()=>r8(e)),r4=rV,r7=t0(rV),ne=e=>(0,I.R6)(t=>{let r=t.context,n=r8();return t.setContext(o.WQ(t.context,rV,n)),na(e,e=>(t.setContext(r),rH(n,e)))}),nt=(0,f.XY)(2,(e,t)=>ns(r7(e,t),e=>eA(()=>rH(t,e)??eq))),nr=e=>eA(()=>{let t=r8();return ns(e(t),e=>eA(()=>rH(t,e)??eq))}),nn=(e,t,r)=>tH(n=>nI(i=>tu(r4,a=>tn(r?.interruptible?i(e):e,e=>r1(a,r=>tZ(t(e,r),n)))))),ni=e=>tu(r4,t=>tH(r=>r1(t,t=>tZ(e(t),r)))),na=(0,I.Uf)({op:"OnExit",single:!1,[I._3](e){return e._stack.push(this),this[I.a2][0]},[I.u4](e){e.interruptible&&!0!==this[I.a2][2]&&(e._stack.push(n_),e.interruptible=!1)},[I.ee](e,t,r){r??=(0,I.xt)(e);let n=this[I.a2][1](r);return n?tu(n,e=>r):r},[I.Sc](e,t,r){r??=(0,I.cb)(e);let n=this[I.a2][1](r);return n?tu(n,e=>r):r}}),ns=(0,f.XY)(2,na),no=(0,f.XY)(2,(e,t)=>ns(e,e=>t)),nl=(0,f.XY)(3,(e,t,r)=>ns(e,e=>t(e)?r(e):eq)),nc=(0,f.XY)(3,(e,t,r)=>ns(e,e=>{let n=t(e);return x.N6(n)?eq: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)=>ns(e,e=>{if("Failure"!==e._tag)return eq;let n=t(e.cause);return x.N6(n)?eq:r(n.success,e.cause)})),nh=(0,f.XY)(2,(e,t)=>nf(z,t)(e)),np=(e,t,r)=>nI(n=>tu(e,e=>na(n(t(e)),t=>r(e,t),!0))),nm=e=>nn(e,e=>(0,v.i5)(e,Symbol.asyncDispose)?ez(()=>e[Symbol.asyncDispose]()):eT(()=>e[Symbol.dispose]())),ng=(0,f.XY)(2,(e,t)=>eT(()=>{let r,n=l.kE(l.bN(t)),i=Number.isFinite(n),a=iu(!1),s=0,o=!1,c=tu(a.await,()=>r);return[(0,I.R6)(t=>{let l=t.getRef(ij),u=i?l.currentTimeMillisUnsafe():0;return o||u<s?r??c:(o=!0,a.closeUnsafe(),r=void 0,ns(e,e=>eT(()=>{o=!1,s=l.currentTimeMillisUnsafe()+n,r=e,a.openUnsafe()})))}),eT(()=>{s=0,a.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,I.R6)(e=>eO(R(e.id))),nw=e=>(0,I.R6)(t=>(t.interruptible&&(t.interruptible=!1,t._stack.push(n_)),e)),nx=(0,I.Uf)({op:"SetInterruptible",[I.u4](e){if(e.interruptible=this[I.a2],e._interruptedCause&&e.interruptible)return()=>eO(e._interruptedCause)}}),n_=nx(!0),nk=nx(!1),nS=e=>(0,I.R6)(t=>t.interruptible?e:(t.interruptible=!0,t._stack.push(nk),t._interruptedCause)?eO(t._interruptedCause):e),nI=e=>(0,I.R6)(t=>t.interruptible?(t.interruptible=!1,t._stack.push(n_),e(nS)):e(f.D_)),nE=e=>(0,I.R6)(t=>t.interruptible?e(f.D_):(t.interruptible=!0,t._stack.push(nk),e(nw))),n$=tg(nn(eT(()=>new AbortController),e=>eT(()=>e.abort())),e=>e.signal),nO=(e,t)=>(0,v.xZ)(e)?t?.mode==="result"?nj(e,rT,t):nj(e,f.D_,t):t?.discard?"result"===t.mode?nj(Object.values(e),rT,t):nj(Object.values(e),f.D_,t):eA(()=>{let r={};return e7(nj(Object.entries(e),([e,n])=>tg(t?.mode==="result"?rT(n):n,t=>{r[e]=t}),{discard:!0,concurrency:t?.concurrency}),r)}),nC=(0,f.XY)(e=>(0,v.xZ)(e[0])&&!(0,I.yw)(e[0]),(e,t,r)=>tg(nj(e,(e,r)=>rT(t(e,r)),r),e=>s.jB(e,f.D_))),nT=(0,f.XY)(e=>(0,v.xZ)(e[0])&&!(0,I.yw)(e[0]),(e,t,r)=>tu(nC(e,t,{concurrency:r?.concurrency}),([e,t])=>s.CZ(e)?eC(e):r?.discard?eq:e$(t))),nA=(0,f.XY)(e=>(0,v.xZ)(e[0])&&!(0,I.yw)(e[0]),(e,t)=>eA(()=>{let r=e[Symbol.iterator](),n=r.next();return n.done?e$(g.none()):nM(r,0,t,n.value)})),nM=(e,t,r,n)=>tu(r(n,t),i=>{if(i)return e$(g.some(n));let a=e.next();return a.done?e$(g.none()):nM(e,t+1,r,a.value)}),nN=(0,f.XY)(e=>(0,v.xZ)(e[0])&&!(0,I.yw)(e[0]),(e,t)=>eA(()=>{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)}),nR=(0,I.Uf)({op:"While",[I.ee](e,t){return(this[I.a2].step(e),this[I.a2].while())?(t._stack.push(this),this[I.a2].body()):tN},[I._3](e){return this[I.a2].while()?(e._stack.push(this),this[I.a2].body()):tN}}),nj=(0,f.XY)(e=>"function"==typeof e[1],(e,t,r)=>(0,I.R6)(n=>{let i=r?.concurrency==="inherit"?n.getRef(O.F8):r?.concurrency??1,a="unbounded"===i?1/0:Math.max(1,i);if(1===a)return nD(e,t,r);let o=s.Ts(e),l=o.length;if(0===l)return r?.discard?eq:e$([]);let c=r?.discard?void 0:Array(l),u=nF({f:t,out:c},o,{concurrency:a});return u?e7(u,c):e$(c)})),nD=(e,t,r)=>eA(()=>{let n=r?.discard?void 0:[],i=e[Symbol.iterator](),a=i.next(),s=0;return e7(nR({while:()=>!a.done,body:()=>t(a.value,s++),step:e=>{n&&n.push(e),a=i.next()}}),n)}),nL=e=>{let t=e.onItem,r=e.step;return(e,n,i)=>{let a,s,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,a)=>{if(!h)return r(e,t,i,a);if(l)return l;for(y[a]=i;g<d;){let t=y[g];if(void 0===t)return;y[g]=void 0;let i=g++,a=r(e,n[i],t,i);if(a)return a}},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()??eq));if(!a)return eQ(e=>{a=ep(),c=d,o=e;let t=v();return t?e(t):eA(()=>(l=tN,m=!0,s?eI(s):eq))});c=void 0;let e=nQ(a,d,!0,!0,"inherit");if(e._exit){if(l=b(i,e._exit,u))break;continue}s?s.add(e):s=new Set([e]);let t=u;if(e.addObserver(n=>{if(s.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,I.cb)((0,I.b5)([e]))}else{let e=b(i,n,t);e&&(l="Failure"===e._tag?(0,I.cb)((0,I.b5)(e.cause.reasons.slice())):e,v())}if(r){let e=v();e&&o(e)}else p&&0===s.size&&o(l??eq)}),s.size<f)continue;r=!0,u++;return}}if(p=!0,l){if(s&&s.size>0){let e=ey(a);s.forEach(t=>t.interruptUnsafe(a.id,e));return}if(o||"Failure"===l._tag)return l}else if(o)if(!s)return tN;else 0===s.size&&o(eq)};return v()}},nU=()=>nL,nF=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))),nW=(0,f.XY)(3,(e,t,r)=>tu(e,e=>{let n=t(e);return x.N6(n)?r(n.failure):e$(n.success)})),nq=(0,f.XY)(e=>(0,I.yw)(e[0]),(e,t,r)=>nW(e,t,r?e=>eC(r(e)):()=>eC(new I.Xm))),nY=(0,f.XY)(e=>(0,v.xZ)(e[0])&&!(0,I.yw)(e[0]),(e,t,r)=>eA(()=>{let n=[];return e7(nj(e,(e,r)=>{let i=t(e,r);return"boolean"==typeof i?(i&&n.push(e),eq):tg(i,t=>{t&&n.push(e)})},{discard:!0,concurrency:r?.concurrency}),n)})),nz=(0,f.XY)(e=>(0,v.xZ)(e[0])&&!(0,I.yw)(e[0]),(e,t)=>eA(()=>{let r=[];for(let n of e){let e=t(n);x.oJ(e)&&r.push(e.success)}return e$(r)})),nX=(0,f.XY)(e=>(0,v.xZ)(e[0])&&!(0,I.yw)(e[0]),(e,t,r)=>eA(()=>{let n=[];return e7(nj(e,e=>tg(t(e),e=>{x.oJ(e)&&n.push(e.success)}),{discard:!0,concurrency:r?.concurrency}),n)})),nJ=e$({}),nG=E.Jr(tg),nV=E.oI(tg,tu),nK=E.zM(tg),nH=(0,f.XY)(e=>(0,I.yw)(e[0]),(e,t)=>(0,I.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 a="inherit"===i?e.interruptible:!i,s=new em(e.context,a);return r?s.evaluate(t):e.currentDispatcher.scheduleTask(()=>s.evaluate(t),0),n||s._exit||(e.children().add(s),s.addObserver(()=>e._children.delete(s))),s},nZ=(0,f.XY)(e=>(0,I.yw)(e[0]),(e,t)=>(0,I.R6)(r=>e$(nQ(r,e,t?.startImmediately,!0,t?.uninterruptible)))),n0=e=>(0,I.R6)(t=>{let r=t._children&&s.Ts(t._children);return ns(e,e=>{let n=t._children;return void 0===n||0===n.size?eq:(r&&(n=m.pb(n,e=>!r.includes(e))),ti(ew(n)))})}),n1=(0,f.XY)(e=>(0,I.yw)(e[0]),(e,t,r)=>(0,I.R6)(n=>{let i=nQ(n,e,r?.startImmediately,!0,r?.uninterruptible);if(!i._exit)if("Closed"!==t.state._tag){let e={};r5(t,e,()=>eJ(e=>e===i.id?eq:ek(i))),i.addObserver(()=>r3(t,e))}else i.interruptUnsafe(n.id,ey(n));return e$(i)})),n2=(0,f.XY)(e=>(0,I.yw)(e[0]),(e,t)=>tu(r4,r=>n1(e,r,t))),n5=e=>(t,r)=>{let n=new em(r?.scheduler?o.WQ(e,_._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},n3=(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 r5(t,r,()=>ek(e)),e.addObserver(()=>r3(t,r)),e}),n8=n5(o.Ie()),n6=e=>{let t=n5(e);return(e,r)=>{let n=t(e,r);return r?.onExit&&n.addObserver(r.onExit),e=>n.interruptUnsafe(e)}},n9=n6(o.Ie()),n4=e=>{let t=n5(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=n5(e);return e=>{if(th(e))return e;let r=t(e,{scheduler:new _.FG("sync")});return r.currentDispatcher?.flush(),r._exit??(0,I.V2)(new i2(r))}},ii=ir(o.Ie()),ia=e=>{let t=ir(e);return e=>{let r=t(e);if("Failure"===r._tag)throw Z(r.cause);return r.value}},is=ia(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](tN)};open=(0,I.R6)(e=>this._isOpen?il:(this._isOpen=!0,this.scheduleUnsafe(e)));release=(0,I.R6)(e=>this._isOpen?il:this.scheduleUnsafe(e));openUnsafe(){return!this._isOpen&&(this._isOpen=!0,this.flushWaiters(),!0)}await=eQ(e=>this._isOpen?e(eq):(this.waiters.push(e),eT(()=>{let t=this.waiters.indexOf(e);-1!==t&&this.waiters.splice(t,1)})));closeUnsafe(){return!!this._isOpen&&(this._isOpen=!1,!0)}close=eT(()=>this.closeUnsafe());whenOpen=e=>tu(this.await,()=>e);isOpen(){return this._isOpen}}let iu=e=>new ic(e??!1),id=e=>eT(()=>iu(e)),ih=(0,I.R6)(e=>e$(e.getRef(k.sh))),ip=(0,f.XY)(2,(e,t)=>t0(e,k.sh,t)),im=t0(O.rf),ig=t0(O.nU),iy=BigInt(0),ib={_tag:"Span",spanId:"noop",traceId:"noop",sampled:!1,status:{_tag:"Ended",startTime:iy,endTime:iy,exit:tN},attributes:new Map,links:[],kind:"internal",attribute(){},event(){},end(){},addLinks(){}},iv=e=>e?o.Jt(e.annotations,k.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(O.rf)||r?.annotations&&o.Jt(r.annotations,k.DW),a=r?.parent!==void 0?g.some(r.parent):r?.root?g.none():iv(e.currentSpan);if(i){let e;e={name:t,parent:a,annotations:o.WQ(r?.annotations??o.Ie(),k.DW,!0)},n=Object.assign(Object.create(ib),e)}else{let i=e.getRef(k.sh),s=e.getRef(ij),l=e.getRef(O.nU),c=e.getRef(O.ce),u=e.getRef(O.ls),d=r?.level??e.getRef(k.pX),f=r?.links!==void 0?[...u,...r.links]:u.slice();for(let[u,h]of(n=i.span({name:t,parent:a,annotations:r?.annotations??o.Ie(),links:f,startTime:l?s.currentTimeNanosUnsafe():BigInt(0),kind:r?.kind??"internal",root:r?.root??g.isNone(a),sampled:r?.sampled??((!g.isSome(a)||!1!==a.value.sampled)&&!i4(e.getRef(k.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,I.R6)(r=>e$(iw(r,e,t))),i_=(e,t)=>nw((0,I.R6)(r=>{let n=o.fp(r.context,rV),i=iw(r,e,t??{}),a=r.getRef(ij),s=r.getRef(O.nU);return e7(r1(n,e=>i$(i,e,a,s)),i)})),ik=function(){let e="string"!=typeof arguments[0],t=e?arguments[1]:arguments[0],r=T(e?arguments[2]:arguments[1]);if(e){let e=arguments[0];return tu(i_(t,r),t=>iT(e,t,r))}return e=>tu(i_(t,r),t=>iT(e,t,r))},iS=O.ce,iI=O.ls,iE=(0,f.XY)(e=>(0,I.yw)(e[0]),(e,t,r={})=>{let n=(Array.isArray(t)?t:[t]).map(e=>({span:e,attributes:r}));return tG(e,O.ls,e=>[...e,...n])}),i$=(e,t,r,n)=>eT(()=>{"Ended"!==e.status._tag&&e.end(n?r.currentTimeNanosUnsafe():iy,t)}),iO=(e,...t)=>{let r=1===t.length?void 0:t[0],n=t[t.length-1];return(0,I.R6)(t=>{let i=iw(t,e,r),a=t.getRef(ij);return ns((0,S.s)(()=>n(i)),e=>eT(()=>{"Ended"!==i.status._tag&&i.end(a.currentTimeNanosUnsafe(),e)}))})},iC=t0(k.Tv),iT=function(){let e=(0,I.yw)(arguments[0]),t=e?arguments[1]:arguments[0],r=e?arguments[2]:arguments[1],n=f.D_;if("Span"===t._tag){var i,a;r=T(r),i=t.name,a="function"==typeof(a=r?.captureStackTrace)?a:f.MN,n=tG(O.vA,e=>({name:i,stack:a,parent:e}))}return e?iC(n(arguments[0]),t):e=>iC(n(e),t)},iA=function(){let e="string"!=typeof arguments[0],t=e?arguments[1]:arguments[0],r=T(arguments[2]);if(e){let e=arguments[0];return iO(t,arguments[2],t=>iT(e,t,r))}let n="function"==typeof arguments[1]?arguments[1]:void 0,i=n?void 0:arguments[1];return(e,...a)=>iO(t,n?n(...a):i,t=>iT(e,t,r))},iM=(0,f.XY)(e=>(0,I.yw)(e[0]),(e,...t)=>tG(e,O.ce,e=>{let r={...e};return 1===t.length?Object.assign(r,t[0]):r[t[0]]=t[1],r})),iN=(...e)=>(0,I.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 eq}),iP=(0,I.R6)(e=>{let t=e.currentSpanLocal;return t?e$(t):eC(new I.Xm)}),iR=(n=k.Tv,(0,I.R6)(e=>e.context.mapUnsafe.has(n.key)?e$(o.fp(e.context,n)):eC(new I.Xm))),ij=o.Or("effect/Clock",{defaultValue:()=>new iL}),iD=0x80000000-1;class iL{currentTimeMillisUnsafe(){return Date.now()}currentTimeMillis=eT(()=>this.currentTimeMillisUnsafe());currentTimeNanosUnsafe(){return iF()}currentTimeNanos=eT(()=>this.currentTimeNanosUnsafe());sleep(e){return this.sleepMillis(l.kE(e))}sleepMillis(e){return e<=0?ej:Number.isFinite(e)?eQ(t=>{let r=e>iD?this.sleepMillis(e-iD):eq,n=setTimeout(()=>t(r),Math.min(e,iD));return eT(()=>clearTimeout(n))}):eZ}}let iU=(a=BigInt(1e6),"u"<typeof performance||void 0===performance.now?()=>BigInt(Date.now())*a:()=>(i??=BigInt(Date.now())*a-BigInt(Math.round(1e6*performance.now())))+BigInt(Math.round(1e6*performance.now()))),iF=function(){let e="object"==typeof process&&"hrtime"in process&&"function"==typeof process.hrtime.bigint?process.hrtime:void 0;if(!e)return iU;let t=BigInt(Date.now())*BigInt(1e6)-e.bigint();return()=>t+e.bigint()}(),iB=e=>(0,I.R6)(t=>e(t.getRef(ij))),iW=e=>iB(t=>t.sleep(l.bN(e))),iq=iB(e=>e.currentTimeMillis),iY=iB(e=>e.currentTimeNanos),iz="~effect/Cause/TimeoutError",iX=e=>(0,v.i5)(e,iz);class iJ extends(0,I.rN)("TimeoutError"){[iz]=iz;constructor(e){super({message:e})}}let iG="~effect/Cause/IllegalArgumentError",iV=e=>(0,v.i5)(e,iG);class iK extends(0,I.rN)("IllegalArgumentError"){[iG]=iG;constructor(e){super({message:e})}}let iH="~effect/Cause/ExceededCapacityError",iQ=e=>(0,v.i5)(e,iH);class iZ extends(0,I.rN)("ExceededCapacityError"){[iH]=iH;constructor(e){super({message:e})}}let i0="~effect/Cause/AsyncFiberError",i1=e=>(0,v.i5)(e,i0);class i2 extends(0,I.rN)("AsyncFiberError"){[i0]=i0;constructor(e){super({message:"An asynchronous Effect was executed with Effect.runSync",fiber:e})}}let i5="~effect/Cause/UnknownError",i3=e=>(0,v.i5)(e,i5);class i8 extends(0,I.rN)("UnknownError"){[i5]=i5;constructor(e,t){super({message:t,cause:e})}}let i6=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([as,ao])}),ae=o.Or("effect/Logger/LogToStderr",{defaultValue:f.f4}),at=function(){let e="string"==typeof arguments[0]?[[arguments[0],arguments[1]]]:Object.entries(arguments[0]);return nw((0,I.R6)(t=>{let r=t.getRef(O.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,O.iL,n)),r1(o.fp(t.context,rV),n=>{let i=t.getRef(O.iL),a={...i};for(let t=0;t<e.length;t++){let[n,s]=e[t];i[n]===s&&(n in r?a[n]=r[n]:delete a[n])}return t.setContext(o.WQ(t.context,O.iL,a)),eq})}))},ar={"~effect/Logger":{_Message:f.D_,_Output:f.D_},pipe(){return(0,b.tT)(this,arguments)}},an=e=>{let t=Object.create(ar);return t.log=e,t},ai=(e,t)=>{let r=e[0].replace(/[\s="]/g,"_");return`${r}=${t-e[1]}ms`},aa=e=>(...t)=>{let r;for(let e=0,n=t.length;e<n;e++){let n=t[e];(0,I.Aj)(n)&&(r?t.splice(e,1):t=t.slice(0,e).concat(t.slice(e+1)),r=r?(0,I.b5)(r.reasons.concat(n.reasons)):n,e--)}return void 0===r&&(r=I.DH),(0,I.R6)(n=>{let i=e??n.currentLogLevel;if(i4(n.minimumLogLevel,i))return eq;let a=n.getRef(ij),s=n.getRef(i7);if(s.size>0){let e=new Date(a.currentTimeMillisUnsafe());for(let a of s)a.log({cause:r,fiber:n,date:e,logLevel:i,message:t})}return eq})},as=an(({cause:e,date:t,fiber:r,logLevel:n,message:i})=>{let a=Array.isArray(i)?i.slice():[i];e.reasons.length>0&&a.push(el(e));let s=t.getTime(),o=r.getRef(O.d8),l="";for(let e of o)l+=` ${ai(e,s)}`;let c=r.getRef(O.iL);Object.keys(c).length>0&&a.push(c);let u=r.getRef(i6);(r.getRef(ae)?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}:`,...a)}),ao=an(({cause:e,fiber:t,logLevel:r,message:n})=>{let i=t.getRef(ij),a=t.getRef(O.iL),s=t.currentSpan;if(void 0===s||"ExternalSpan"===s._tag)return;let o={};for(let[e,t]of Object.entries(a))o[e]=t;o["effect.fiberId"]=t.id,o["effect.logLevel"]=r.toUpperCase(),e.reasons.length>0&&(o["effect.cause"]=el(e)),s.event((0,p.ZK)(Array.isArray(n)&&1===n.length?n[0]:n),i.currentTimeNanosUnsafe(),o)}),al=e$(void 0),ac=(0,f.XY)(e=>(0,I.yw)(e[0]),(e,t)=>nu(e,e=>(0,I.R6)(r=>(au(r,e,t?.defectsOnly),eq)))),au=(e,t,r)=>{let n=e.getRef(O.oQ);if(0===n.size||r&&!F(t))return;let i={cause:t,fiber:e,timestamp:e.getRef(ij).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),a=r(4450),s=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)},[a.HR](){return a.kg(a.tW(this._tag))(a.tW(this.value))},toString(){return`some(${(0,i.GP)(this.value)})`},toJSON(){return{_id:"Option",_tag:this._tag,value:(0,s.aB)(this.value)}}}),"valueOrUndefined",{get(){return this.value}}),h=a.tW("None"),p=Object.assign(Object.create(d),{_tag:"None",_op:"None",valueOrUndefined:void 0,[n.HR]:e=>m(e)&&g(e),[a.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 a=n.Or("effect/References/CurrentConcurrency",{defaultValue:()=>"unbounded"}),s=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:a,Gl:h,aG:m,ce:u,d8:g,iL:f,ls:d,nU:c,oQ:s,rf:l,vA:o,zQ:p})},4403(e,t,r){var n=r(8036),i=r(6470),a=r(4650),s=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)},[s.HR](){return s.kg(s.tW(this._tag))(s.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)},[s.HR](){return s.kg(s.tW(this._tag))(s.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,a.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 a(e){return t=>i(t)?.[e]}let s=a("identifier"),o=a("title"),l=a("description"),c=(0,n.Bj)(e=>{let t=s(e);return"string"==typeof t?t:e.getExpected(c)});r.d(t,{hd:()=>i,ip:()=>a},{DQ:o,KE:s,Pk:l,bo:c})},8045(e,t,r){var n=r(8543),i=r(6030);function a(e){let t;for(let r of e.reasons){if(!n.lC(r)||!i.gh(r.error))return;t??=r.error}return t}function s(e,t){let r=a(e);if(void 0===r)throw Error(t,{cause:e});return r}r.d(t,{R:()=>a,q:()=>s})},3628(e,t,r){let n,i=Object.getOwnPropertyDescriptor,a=Object.prototype.hasOwnProperty,s=Object.isExtensible,o=void 0===(n=i(Error,"stackTraceLimit"))?s(Error):a.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 a=0;for(;(e[a]||n)===t[a];)a++;if(a>0)return t.slice(0,a)+i(e.slice(a),t.slice(a),r)}let a=e?r.indexOf(e[0]):0,s=null!=t?r.indexOf(t[0]):r.length;return s-a>1?r[Math.round(.5*(a+s))]:t&&t.length>1?t.slice(0,1):r[a]+i(e.slice(1),null,r)}function a(e){if(e.length!==s(e[0]))throw Error("invalid integer part of order key: "+e)}function s(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=s(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){a(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 s=function(e,t){a(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==s)throw Error("cannot decrement any more");return s}if(null==t){let t=o(e),n=e.slice(t.length),a=c(t,r);return null==a?t+i(n,null,r):a}let s=o(e),d=e.slice(s.length),f=o(t),h=t.slice(f.length);if(s===f)return s+i(d,h,r);let p=c(s,r);if(null==p)throw Error("cannot increment any more");return p<t?p:s+i(d,null,r)}r.d(t,{TU:()=>u,YT:()=>function e(t,r,i,a=n){if(0===i)return[];if(1===i)return[u(t,r,a)];if(null==r){let e=u(t,r,a),n=[e];for(let t=0;t<i-1;t++)n.push(e=u(e,r,a));return n}if(null==t){let e=u(t,r,a),n=[e];for(let r=0;r<i-1;r++)n.push(e=u(t,e,a));return n.reverse(),n}let s=Math.floor(i/2),o=u(t,r,a);return[...e(t,o,s,a),o,...e(o,r,i-s-1,a)]}})},8689(e,t,r){let n,i,a,s,o;function l(e){let t=e.length;for(;--t>=0;)e[t]=0}let c=573,u=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),d=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),f=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),h=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),p=Array(576);l(p);let m=Array(60);l(m);let g=Array(512);l(g);let y=Array(256);l(y);let b=Array(29);l(b);let v=Array(30);function w(e,t,r,n,i){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=e&&e.length}function x(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}l(v);let _=e=>e<256?g[e]:g[256+(e>>>7)],k=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},S=(e,t,r)=>{e.bi_valid>16-r?(e.bi_buf|=t<<e.bi_valid&65535,k(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=r-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)},I=(e,t,r)=>{S(e,r[2*t],r[2*t+1])},E=(e,t)=>{let r=0;do r|=1&e,e>>>=1,r<<=1;while(--t>0)return r>>>1},$=(e,t,r)=>{let n,i,a=Array(16),s=0;for(n=1;n<=15;n++)a[n]=s=s+r[n-1]<<1;for(i=0;i<=t;i++){let t=e[2*i+1];0!==t&&(e[2*i]=E(a[t]++,t))}},O=e=>{let t;for(t=0;t<286;t++)e.dyn_ltree[2*t]=0;for(t=0;t<30;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0},C=e=>{e.bi_valid>8?k(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},T=(e,t,r,n)=>{let i=2*t,a=2*r;return e[i]<e[a]||e[i]===e[a]&&n[t]<=n[r]},A=(e,t,r)=>{let n=e.heap[r],i=r<<1;for(;i<=e.heap_len&&(i<e.heap_len&&T(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!T(t,n,e.heap[i],e.depth));)e.heap[r]=e.heap[i],r=i,i<<=1;e.heap[r]=n},M=(e,t,r)=>{let n,i,a,s,o=0;if(0!==e.last_lit)do n=e.pending_buf[e.d_buf+2*o]<<8|e.pending_buf[e.d_buf+2*o+1],i=e.pending_buf[e.l_buf+o],o++,0===n?I(e,i,t):(I(e,(a=y[i])+256+1,t),0!==(s=u[a])&&S(e,i-=b[a],s),I(e,a=_(--n),r),0!==(s=d[a])&&S(e,n-=v[a],s));while(o<e.last_lit)I(e,256,t)},N=(e,t)=>{let r,n,i,a=t.dyn_tree,s=t.stat_desc.static_tree,o=t.stat_desc.has_stree,l=t.stat_desc.elems,u=-1;for(e.heap_len=0,e.heap_max=c,r=0;r<l;r++)0!==a[2*r]?(e.heap[++e.heap_len]=u=r,e.depth[r]=0):a[2*r+1]=0;for(;e.heap_len<2;)a[2*(i=e.heap[++e.heap_len]=u<2?++u:0)]=1,e.depth[i]=0,e.opt_len--,o&&(e.static_len-=s[2*i+1]);for(t.max_code=u,r=e.heap_len>>1;r>=1;r--)A(e,a,r);i=l;do r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],A(e,a,1),n=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=n,a[2*i]=a[2*r]+a[2*n],e.depth[i]=(e.depth[r]>=e.depth[n]?e.depth[r]:e.depth[n])+1,a[2*r+1]=a[2*n+1]=i,e.heap[1]=i++,A(e,a,1);while(e.heap_len>=2)e.heap[--e.heap_max]=e.heap[1],((e,t)=>{let r,n,i,a,s,o,l=t.dyn_tree,u=t.max_code,d=t.stat_desc.static_tree,f=t.stat_desc.has_stree,h=t.stat_desc.extra_bits,p=t.stat_desc.extra_base,m=t.stat_desc.max_length,g=0;for(a=0;a<=15;a++)e.bl_count[a]=0;for(l[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;r<c;r++)(a=l[2*l[2*(n=e.heap[r])+1]+1]+1)>m&&(a=m,g++),l[2*n+1]=a,!(n>u)&&(e.bl_count[a]++,s=0,n>=p&&(s=h[n-p]),o=l[2*n],e.opt_len+=o*(a+s),f&&(e.static_len+=o*(d[2*n+1]+s)));if(0!==g){do{for(a=m-1;0===e.bl_count[a];)a--;e.bl_count[a]--,e.bl_count[a+1]+=2,e.bl_count[m]--,g-=2}while(g>0)for(a=m;0!==a;a--)for(n=e.bl_count[a];0!==n;)!((i=e.heap[--r])>u)&&(l[2*i+1]!==a&&(e.opt_len+=(a-l[2*i+1])*l[2*i],l[2*i+1]=a),n--)}})(e,t),$(a,u,e.bl_count)},P=(e,t,r)=>{let n,i,a=-1,s=t[1],o=0,l=7,c=4;for(0===s&&(l=138,c=3),t[(r+1)*2+1]=65535,n=0;n<=r;n++)i=s,s=t[(n+1)*2+1],++o<l&&i===s||(o<c?e.bl_tree[2*i]+=o:0!==i?(i!==a&&e.bl_tree[2*i]++,e.bl_tree[32]++):o<=10?e.bl_tree[34]++:e.bl_tree[36]++,o=0,a=i,0===s?(l=138,c=3):i===s?(l=6,c=3):(l=7,c=4))},R=(e,t,r)=>{let n,i,a=-1,s=t[1],o=0,l=7,c=4;for(0===s&&(l=138,c=3),n=0;n<=r;n++)if(i=s,s=t[(n+1)*2+1],!(++o<l)||i!==s){if(o<c)do I(e,i,e.bl_tree);while(0!=--o)else 0!==i?(i!==a&&(I(e,i,e.bl_tree),o--),I(e,16,e.bl_tree),S(e,o-3,2)):o<=10?(I(e,17,e.bl_tree),S(e,o-3,3)):(I(e,18,e.bl_tree),S(e,o-11,7));o=0,a=i,0===s?(l=138,c=3):i===s?(l=6,c=3):(l=7,c=4)}},j=!1,D=(e,t,r,n)=>{S(e,0+ +!!n,3),C(e),k(e,r),k(e,~r),e.pending_buf.set(e.window.subarray(t,t+r),e.pending),e.pending+=r};var L={_tr_init:e=>{j||((()=>{let e,t,r,s,o,l=Array(16);for(s=0,r=0;s<28;s++)for(b[s]=r,e=0;e<1<<u[s];e++)y[r++]=s;for(y[r-1]=s,o=0,s=0;s<16;s++)for(v[s]=o,e=0;e<1<<d[s];e++)g[o++]=s;for(o>>=7;s<30;s++)for(v[s]=o<<7,e=0;e<1<<d[s]-7;e++)g[256+o++]=s;for(t=0;t<=15;t++)l[t]=0;for(e=0;e<=143;)p[2*e+1]=8,e++,l[8]++;for(;e<=255;)p[2*e+1]=9,e++,l[9]++;for(;e<=279;)p[2*e+1]=7,e++,l[7]++;for(;e<=287;)p[2*e+1]=8,e++,l[8]++;for($(p,287,l),e=0;e<30;e++)m[2*e+1]=5,m[2*e]=E(e,5);n=new w(p,u,257,286,15),i=new w(m,d,0,30,15),a=new w([],f,0,19,7)})(),j=!0),e.l_desc=new x(e.dyn_ltree,n),e.d_desc=new x(e.dyn_dtree,i),e.bl_desc=new x(e.bl_tree,a),e.bi_buf=0,e.bi_valid=0,O(e)},_tr_stored_block:D,_tr_flush_block:(e,t,r,n)=>{let i,a,s=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,r=0xf3ffc07f;for(t=0;t<=31;t++,r>>>=1)if(1&r&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<256;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0})(e)),N(e,e.l_desc),N(e,e.d_desc),s=(e=>{let t;for(P(e,e.dyn_ltree,e.l_desc.max_code),P(e,e.dyn_dtree,e.d_desc.max_code),N(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*h[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),i=e.opt_len+3+7>>>3,(a=e.static_len+3+7>>>3)<=i&&(i=a)):i=a=r+5,r+4<=i&&-1!==t?D(e,t,r,n):4===e.strategy||a===i?(S(e,2+ +!!n,3),M(e,p,m)):(S(e,4+ +!!n,3),((e,t,r,n)=>{let i;for(S(e,t-257,5),S(e,r-1,5),S(e,n-4,4),i=0;i<n;i++)S(e,e.bl_tree[2*h[i]+1],3);R(e,e.dyn_ltree,t-1),R(e,e.dyn_dtree,r-1)})(e,e.l_desc.max_code+1,e.d_desc.max_code+1,s+1),M(e,e.dyn_ltree,e.dyn_dtree)),O(e),n&&C(e)},_tr_tally:(e,t,r)=>(e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&r,e.last_lit++,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[(y[r]+256+1)*2]++,e.dyn_dtree[2*_(t)]++),e.last_lit===e.lit_bufsize-1),_tr_align:e=>{S(e,2,3),I(e,256,p),16===e.bi_valid?(k(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}},U=(e,t,r,n)=>{let i=65535&e,a=e>>>16&65535,s=0;for(;0!==r;){s=r>2e3?2e3:r,r-=s;do a=a+(i=i+t[n++]|0)|0;while(--s)i%=65521,a%=65521}return i|a<<16};let F=new Uint32Array((()=>{let e,t=[];for(var r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?0xedb88320^e>>>1:e>>>1;t[r]=e}return t})());var B=(e,t,r,n)=>{let i=n+r;e^=-1;for(let r=n;r<i;r++)e=e>>>8^F[(e^t[r])&255];return -1^e},W={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},q={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};let{_tr_init:Y,_tr_stored_block:z,_tr_flush_block:X,_tr_tally:J,_tr_align:G}=L,{Z_NO_FLUSH:V,Z_PARTIAL_FLUSH:K,Z_FULL_FLUSH:H,Z_FINISH:Q,Z_BLOCK:Z,Z_OK:ee,Z_STREAM_END:et,Z_STREAM_ERROR:er,Z_DATA_ERROR:en,Z_BUF_ERROR:ei,Z_DEFAULT_COMPRESSION:ea,Z_FILTERED:es,Z_HUFFMAN_ONLY:eo,Z_RLE:el,Z_FIXED:ec,Z_DEFAULT_STRATEGY:eu,Z_UNKNOWN:ed,Z_DEFLATED:ef}=q,eh=573,ep=(e,t)=>(e.msg=W[t],t),em=e=>(e<<1)-9*(e>4),eg=e=>{let t=e.length;for(;--t>=0;)e[t]=0},ey=(e,t,r)=>(t<<e.hash_shift^r)&e.hash_mask,eb=e=>{let t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+r),e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))},ev=(e,t)=>{X(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,eb(e.strm)},ew=(e,t)=>{e.pending_buf[e.pending++]=t},ex=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},e_=(e,t,r,n)=>{let i=e.avail_in;return(i>n&&(i=n),0===i)?0:(e.avail_in-=i,t.set(e.input.subarray(e.next_in,e.next_in+i),r),1===e.state.wrap?e.adler=U(e.adler,t,i,r):2===e.state.wrap&&(e.adler=B(e.adler,t,i,r)),e.next_in+=i,e.total_in+=i,i)},ek=(e,t)=>{let r,n,i=e.max_chain_length,a=e.strstart,s=e.prev_length,o=e.nice_match,l=e.strstart>e.w_size-262?e.strstart-(e.w_size-262):0,c=e.window,u=e.w_mask,d=e.prev,f=e.strstart+258,h=c[a+s-1],p=c[a+s];e.prev_length>=e.good_match&&(i>>=2),o>e.lookahead&&(o=e.lookahead);do{if(c[(r=t)+s]!==p||c[r+s-1]!==h||c[r]!==c[a]||c[++r]!==c[a+1])continue;a+=2,r++;do;while(c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&c[++a]===c[++r]&&a<f)if(n=258-(f-a),a=f-258,n>s){if(e.match_start=t,s=n,n>=o)break;h=c[a+s-1],p=c[a+s]}}while((t=d[t&u])>l&&0!=--i)return s<=e.lookahead?s:e.lookahead},eS=e=>{let t,r,n,i,a,s=e.w_size;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=s+(s-262)){e.window.set(e.window.subarray(s,s+s),0),e.match_start-=s,e.strstart-=s,e.block_start-=s,t=r=e.hash_size;do n=e.head[--t],e.head[t]=n>=s?n-s:0;while(--r)t=r=s;do n=e.prev[--t],e.prev[t]=n>=s?n-s:0;while(--r)i+=s}if(0===e.strm.avail_in)break;if(r=e_(e.strm,e.window,e.strstart+e.lookahead,i),e.lookahead+=r,e.lookahead+e.insert>=3)for(a=e.strstart-e.insert,e.ins_h=e.window[a],e.ins_h=ey(e,e.ins_h,e.window[a+1]);e.insert&&(e.ins_h=ey(e,e.ins_h,e.window[a+3-1]),e.prev[a&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=a,a++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<262&&0!==e.strm.avail_in)},eI=(e,t)=>{let r,n;for(;;){if(e.lookahead<262){if(eS(e),e.lookahead<262&&t===V)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=ey(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==r&&e.strstart-r<=e.w_size-262&&(e.match_length=ek(e,r)),e.match_length>=3)if(n=J(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do e.strstart++,e.ins_h=ey(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;while(0!=--e.match_length)e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=ey(e,e.ins_h,e.window[e.strstart+1]);else n=J(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(ev(e,!1),0===e.strm.avail_out))return 1}return(e.insert=e.strstart<2?e.strstart:2,t===Q)?(ev(e,!0),0===e.strm.avail_out)?3:4:e.last_lit&&(ev(e,!1),0===e.strm.avail_out)?1:2},eE=(e,t)=>{let r,n,i;for(;;){if(e.lookahead<262){if(eS(e),e.lookahead<262&&t===V)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=ey(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==r&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-262&&(e.match_length=ek(e,r),e.match_length<=5&&(e.strategy===es||3===e.match_length&&e.strstart-e.match_start>4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-3,n=J(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=i&&(e.ins_h=ey(e,e.ins_h,e.window[e.strstart+3-1]),r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart);while(0!=--e.prev_length)if(e.match_available=0,e.match_length=2,e.strstart++,n&&(ev(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if((n=J(e,0,e.window[e.strstart-1]))&&ev(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return(e.match_available&&(n=J(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Q)?(ev(e,!0),0===e.strm.avail_out)?3:4:e.last_lit&&(ev(e,!1),0===e.strm.avail_out)?1:2};function e$(e,t,r,n,i){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=n,this.func=i}let eO=[new e$(0,0,0,0,(e,t)=>{let r=65535;for(65535>e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(eS(e),0===e.lookahead&&t===V)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;let n=e.block_start+r;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,ev(e,!1),0===e.strm.avail_out)||e.strstart-e.block_start>=e.w_size-262&&(ev(e,!1),0===e.strm.avail_out))return 1}return(e.insert=0,t===Q)?(ev(e,!0),0===e.strm.avail_out)?3:4:(e.strstart>e.block_start&&(ev(e,!1),e.strm.avail_out),1)}),new e$(4,4,8,4,eI),new e$(4,5,16,8,eI),new e$(4,6,32,32,eI),new e$(4,4,16,16,eE),new e$(8,16,32,32,eE),new e$(8,16,128,128,eE),new e$(8,32,128,256,eE),new e$(32,128,258,1024,eE),new e$(32,258,258,4096,eE)];function eC(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=ef,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(2*eh),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),eg(this.dyn_ltree),eg(this.dyn_dtree),eg(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),eg(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),eg(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}var eT=(e,t)=>{let r,n;if(!e||!e.state||t>Z||t<0)return e?ep(e,er):er;let i=e.state;if(!e.output||!e.input&&0!==e.avail_in||666===i.status&&t!==Q)return ep(e,0===e.avail_out?ei:er);i.strm=e;let a=i.last_flush;if(i.last_flush=t,42===i.status)if(2===i.wrap)e.adler=0,ew(i,31),ew(i,139),ew(i,8),i.gzhead?(ew(i,+!!i.gzhead.text+2*!!i.gzhead.hcrc+4*!!i.gzhead.extra+8*!!i.gzhead.name+16*!!i.gzhead.comment),ew(i,255&i.gzhead.time),ew(i,i.gzhead.time>>8&255),ew(i,i.gzhead.time>>16&255),ew(i,i.gzhead.time>>24&255),ew(i,9===i.level?2:4*(i.strategy>=eo||i.level<2)),ew(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(ew(i,255&i.gzhead.extra.length),ew(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=B(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(ew(i,0),ew(i,0),ew(i,0),ew(i,0),ew(i,0),ew(i,9===i.level?2:4*(i.strategy>=eo||i.level<2)),ew(i,3),i.status=113);else{let t=ef+(i.w_bits-8<<4)<<8;t|=(i.strategy>=eo||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(t|=32),t+=31-t%31,i.status=113,ex(i,t),0!==i.strstart&&(ex(i,e.adler>>>16),ex(i,65535&e.adler)),e.adler=1}if(69===i.status)if(i.gzhead.extra){for(r=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>r&&(e.adler=B(e.adler,i.pending_buf,i.pending-r,r)),eb(e),r=i.pending,i.pending!==i.pending_buf_size));)ew(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>r&&(e.adler=B(e.adler,i.pending_buf,i.pending-r,r)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){r=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(e.adler=B(e.adler,i.pending_buf,i.pending-r,r)),eb(e),r=i.pending,i.pending===i.pending_buf_size)){n=1;break}n=i.gzindex<i.gzhead.name.length?255&i.gzhead.name.charCodeAt(i.gzindex++):0,ew(i,n)}while(0!==n)i.gzhead.hcrc&&i.pending>r&&(e.adler=B(e.adler,i.pending_buf,i.pending-r,r)),0===n&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){r=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(e.adler=B(e.adler,i.pending_buf,i.pending-r,r)),eb(e),r=i.pending,i.pending===i.pending_buf_size)){n=1;break}n=i.gzindex<i.gzhead.comment.length?255&i.gzhead.comment.charCodeAt(i.gzindex++):0,ew(i,n)}while(0!==n)i.gzhead.hcrc&&i.pending>r&&(e.adler=B(e.adler,i.pending_buf,i.pending-r,r)),0===n&&(i.status=103)}else i.status=103;if(103===i.status&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&eb(e),i.pending+2<=i.pending_buf_size&&(ew(i,255&e.adler),ew(i,e.adler>>8&255),e.adler=0,i.status=113)):i.status=113),0!==i.pending){if(eb(e),0===e.avail_out)return i.last_flush=-1,ee}else if(0===e.avail_in&&em(t)<=em(a)&&t!==Q)return ep(e,ei);if(666===i.status&&0!==e.avail_in)return ep(e,ei);if(0!==e.avail_in||0!==i.lookahead||t!==V&&666!==i.status){let r=i.strategy===eo?((e,t)=>{let r;for(;;){if(0===e.lookahead&&(eS(e),0===e.lookahead)){if(t===V)return 1;break}if(e.match_length=0,r=J(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(ev(e,!1),0===e.strm.avail_out))return 1}return(e.insert=0,t===Q)?(ev(e,!0),0===e.strm.avail_out)?3:4:e.last_lit&&(ev(e,!1),0===e.strm.avail_out)?1:2})(i,t):i.strategy===el?((e,t)=>{let r,n,i,a,s=e.window;for(;;){if(e.lookahead<=258){if(eS(e),e.lookahead<=258&&t===V)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(n=s[i=e.strstart-1])===s[++i]&&n===s[++i]&&n===s[++i]){a=e.strstart+258;do;while(n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&i<a)e.match_length=258-(a-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(r=J(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=J(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(ev(e,!1),0===e.strm.avail_out))return 1}return(e.insert=0,t===Q)?(ev(e,!0),0===e.strm.avail_out)?3:4:e.last_lit&&(ev(e,!1),0===e.strm.avail_out)?1:2})(i,t):eO[i.level].func(i,t);if((3===r||4===r)&&(i.status=666),1===r||3===r)return 0===e.avail_out&&(i.last_flush=-1),ee;if(2===r&&(t===K?G(i):t!==Z&&(z(i,0,0,!1),t===H&&(eg(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),eb(e),0===e.avail_out))return i.last_flush=-1,ee}return t!==Q?ee:i.wrap<=0?et:(2===i.wrap?(ew(i,255&e.adler),ew(i,e.adler>>8&255),ew(i,e.adler>>16&255),ew(i,e.adler>>24&255),ew(i,255&e.total_in),ew(i,e.total_in>>8&255),ew(i,e.total_in>>16&255),ew(i,e.total_in>>24&255)):(ex(i,e.adler>>>16),ex(i,65535&e.adler)),eb(e),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?ee:et)},eA=e=>{if(!e||!e.state)return er;let t=e.state.status;return 42!==t&&69!==t&&73!==t&&91!==t&&103!==t&&113!==t&&666!==t?ep(e,er):(e.state=null,113===t?ep(e,en):ee)};let eM=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var eN=function(e){let t=Array.prototype.slice.call(arguments,1);for(;t.length;){let r=t.shift();if(r){if("object"!=typeof r)throw TypeError(r+"must be non-object");for(let t in r)eM(r,t)&&(e[t]=r[t])}}return e},eP=e=>{let t=0;for(let r=0,n=e.length;r<n;r++)t+=e[r].length;let r=new Uint8Array(t);for(let t=0,n=0,i=e.length;t<i;t++){let i=e[t];r.set(i,n),n+=i.length}return r};let eR=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){eR=!1}let ej=new Uint8Array(256);for(let e=0;e<256;e++)ej[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;ej[254]=ej[254]=1;var eD=e=>{let t,r,n,i,a,s=e.length,o=0;for(i=0;i<s;i++)(64512&(r=e.charCodeAt(i)))==55296&&i+1<s&&(64512&(n=e.charCodeAt(i+1)))==56320&&(r=65536+(r-55296<<10)+(n-56320),i++),o+=r<128?1:r<2048?2:r<65536?3:4;for(t=new Uint8Array(o),a=0,i=0;a<o;i++)(64512&(r=e.charCodeAt(i)))==55296&&i+1<s&&(64512&(n=e.charCodeAt(i+1)))==56320&&(r=65536+(r-55296<<10)+(n-56320),i++),r<128?t[a++]=r:(r<2048?t[a++]=192|r>>>6:(r<65536?t[a++]=224|r>>>12:(t[a++]=240|r>>>18,t[a++]=128|r>>>12&63),t[a++]=128|r>>>6&63),t[a++]=128|63&r);return t},eL=(e,t)=>{let r,n,i=t||e.length,a=Array(2*i);for(n=0,r=0;r<i;){let t=e[r++];if(t<128){a[n++]=t;continue}let s=ej[t];if(s>4){a[n++]=65533,r+=s-1;continue}for(t&=2===s?31:3===s?15:7;s>1&&r<i;)t=t<<6|63&e[r++],s--;if(s>1){a[n++]=65533;continue}t<65536?a[n++]=t:(t-=65536,a[n++]=55296|t>>10&1023,a[n++]=56320|1023&t)}var s=n;if(s<65534&&a.subarray&&eR)return String.fromCharCode.apply(null,a.length===s?a:a.subarray(0,s));let o="";for(let e=0;e<s;e++)o+=String.fromCharCode(a[e]);return o},eU=(e,t)=>{(t=t||e.length)>e.length&&(t=e.length);let r=t-1;for(;r>=0&&(192&e[r])==128;)r--;return r<0||0===r?t:r+ej[e[r]]>t?r:t},eF=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};let eB=Object.prototype.toString,{Z_NO_FLUSH:eW,Z_SYNC_FLUSH:eq,Z_FULL_FLUSH:eY,Z_FINISH:ez,Z_OK:eX,Z_STREAM_END:eJ,Z_DEFAULT_COMPRESSION:eG,Z_DEFAULT_STRATEGY:eV,Z_DEFLATED:eK}=q;function eH(e){let t,r;this.options=eN({level:eG,method:eK,chunkSize:16384,windowBits:15,memLevel:8,strategy:eV},e||{});let n=this.options;n.raw&&n.windowBits>0?n.windowBits=-n.windowBits:n.gzip&&n.windowBits>0&&n.windowBits<16&&(n.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new eF,this.strm.avail_out=0;let i=((e,t,r,n,i,a)=>{var s,o;let l;if(!e)return er;let c=1;if(t===ea&&(t=6),n<0?(c=0,n=-n):n>15&&(c=2,n-=16),i<1||i>9||r!==ef||n<8||n>15||t<0||t>9||a<0||a>ec)return ep(e,er);8===n&&(n=9);let u=new eC;return e.state=u,u.strm=e,u.wrap=c,u.gzhead=null,u.w_bits=n,u.w_size=1<<u.w_bits,u.w_mask=u.w_size-1,u.hash_bits=i+7,u.hash_size=1<<u.hash_bits,u.hash_mask=u.hash_size-1,u.hash_shift=~~((u.hash_bits+3-1)/3),u.window=new Uint8Array(2*u.w_size),u.head=new Uint16Array(u.hash_size),u.prev=new Uint16Array(u.w_size),u.lit_bufsize=1<<i+6,u.pending_buf_size=4*u.lit_bufsize,u.pending_buf=new Uint8Array(u.pending_buf_size),u.d_buf=+u.lit_bufsize,u.l_buf=3*u.lit_bufsize,u.level=t,u.strategy=a,u.method=r,(l=(e=>{if(!e||!e.state)return ep(e,er);e.total_in=e.total_out=0,e.data_type=ed;let t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?42:113,e.adler=+(2!==t.wrap),t.last_flush=V,Y(t),ee})(s=e))===ee&&((o=s.state).window_size=2*o.w_size,eg(o.head),o.max_lazy_match=eO[o.level].max_lazy,o.good_match=eO[o.level].good_length,o.nice_match=eO[o.level].nice_length,o.max_chain_length=eO[o.level].max_chain,o.strstart=0,o.block_start=0,o.lookahead=0,o.insert=0,o.match_length=o.prev_length=2,o.match_available=0,o.ins_h=0),l})(this.strm,n.level,n.method,n.windowBits,n.memLevel,n.strategy);if(i!==eX)throw Error(W[i]);if(n.header&&(t=this.strm,r=n.header,t&&t.state&&2===t.state.wrap&&(t.state.gzhead=r)),n.dictionary){let e;if(e="string"==typeof n.dictionary?eD(n.dictionary):"[object ArrayBuffer]"===eB.call(n.dictionary)?new Uint8Array(n.dictionary):n.dictionary,(i=((e,t)=>{let r=t.length;if(!e||!e.state)return er;let n=e.state,i=n.wrap;if(2===i||1===i&&42!==n.status||n.lookahead)return er;if(1===i&&(e.adler=U(e.adler,t,r,0)),n.wrap=0,r>=n.w_size){0===i&&(eg(n.head),n.strstart=0,n.block_start=0,n.insert=0);let e=new Uint8Array(n.w_size);e.set(t.subarray(r-n.w_size,r),0),t=e,r=n.w_size}let a=e.avail_in,s=e.next_in,o=e.input;for(e.avail_in=r,e.next_in=0,e.input=t,eS(n);n.lookahead>=3;){let e=n.strstart,t=n.lookahead-2;do n.ins_h=ey(n,n.ins_h,n.window[e+3-1]),n.prev[e&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=e,e++;while(--t)n.strstart=e,n.lookahead=2,eS(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,e.next_in=s,e.input=o,e.avail_in=a,n.wrap=i,ee})(this.strm,e))!==eX)throw Error(W[i]);this._dict_set=!0}}function eQ(e,t){let r=new eH(t);if(r.push(e,!0),r.err)throw r.msg||W[r.err];return r.result}eH.prototype.push=function(e,t){let r,n,i=this.strm,a=this.options.chunkSize;if(this.ended)return!1;for(n=t===~~t?t:!0===t?ez:eW,"string"==typeof e?i.input=eD(e):"[object ArrayBuffer]"===eB.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;){if(0===i.avail_out&&(i.output=new Uint8Array(a),i.next_out=0,i.avail_out=a),(n===eq||n===eY)&&i.avail_out<=6){this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;continue}if((r=eT(i,n))===eJ)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),r=eA(this.strm),this.onEnd(r),this.ended=!0,r===eX;if(0===i.avail_out){this.onData(i.output);continue}if(n>0&&i.next_out>0){this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;continue}if(0===i.avail_in)break}return!0},eH.prototype.onData=function(e){this.chunks.push(e)},eH.prototype.onEnd=function(e){e===eX&&(this.result=eP(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var eZ=function(e,t){let r,n,i,a,s,o,l,c,u,d,f,h,p,m,g,y,b,v,w,x,_,k,S,I,E=e.state;r=e.next_in,S=e.input,n=r+(e.avail_in-5),i=e.next_out,I=e.output,a=i-(t-e.avail_out),s=i+(e.avail_out-257),o=E.dmax,l=E.wsize,c=E.whave,u=E.wnext,d=E.window,f=E.hold,h=E.bits,p=E.lencode,m=E.distcode,g=(1<<E.lenbits)-1,y=(1<<E.distbits)-1;r:do for(h<15&&(f+=S[r++]<<h,h+=8,f+=S[r++]<<h,h+=8),b=p[f&g];;){if(f>>>=v=b>>>24,h-=v,0==(v=b>>>16&255))I[i++]=65535&b;else if(16&v)for(w=65535&b,(v&=15)&&(h<v&&(f+=S[r++]<<h,h+=8),w+=f&(1<<v)-1,f>>>=v,h-=v),h<15&&(f+=S[r++]<<h,h+=8,f+=S[r++]<<h,h+=8),b=m[f&y];;){if(f>>>=v=b>>>24,h-=v,16&(v=b>>>16&255)){if(x=65535&b,h<(v&=15)&&(f+=S[r++]<<h,(h+=8)<v&&(f+=S[r++]<<h,h+=8)),(x+=f&(1<<v)-1)>o){e.msg="invalid distance too far back",E.mode=30;break r}if(f>>>=v,h-=v,x>(v=i-a)){if((v=x-v)>c&&E.sane){e.msg="invalid distance too far back",E.mode=30;break r}if(_=0,k=d,0===u){if(_+=l-v,v<w){w-=v;do I[i++]=d[_++];while(--v)_=i-x,k=I}}else if(u<v){if(_+=l+u-v,(v-=u)<w){w-=v;do I[i++]=d[_++];while(--v)if(_=0,u<w){w-=v=u;do I[i++]=d[_++];while(--v)_=i-x,k=I}}}else if(_+=u-v,v<w){w-=v;do I[i++]=d[_++];while(--v)_=i-x,k=I}for(;w>2;)I[i++]=k[_++],I[i++]=k[_++],I[i++]=k[_++],w-=3;w&&(I[i++]=k[_++],w>1&&(I[i++]=k[_++]))}else{_=i-x;do I[i++]=I[_++],I[i++]=I[_++],I[i++]=I[_++],w-=3;while(w>2)w&&(I[i++]=I[_++],w>1&&(I[i++]=I[_++]))}}else if((64&v)==0){b=m[(65535&b)+(f&(1<<v)-1)];continue}else{e.msg="invalid distance code",E.mode=30;break r}break}else if((64&v)==0){b=p[(65535&b)+(f&(1<<v)-1)];continue}else if(32&v){E.mode=12;break r}else{e.msg="invalid literal/length code",E.mode=30;break r}break}while(r<n&&i<s)r-=w=h>>3,h-=w<<3,f&=(1<<h)-1,e.next_in=r,e.next_out=i,e.avail_in=r<n?5+(n-r):5-(r-n),e.avail_out=i<s?257+(s-i):257-(i-s),E.hold=f,E.bits=h};let e0=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),e1=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),e2=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),e5=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var e3=(e,t,r,n,i,a,s,o)=>{let l,c,u,d,f,h,p,m,g,y=o.bits,b=0,v=0,w=0,x=0,_=0,k=0,S=0,I=0,E=0,$=0,O=null,C=0,T=new Uint16Array(16),A=new Uint16Array(16),M=null,N=0;for(b=0;b<=15;b++)T[b]=0;for(v=0;v<n;v++)T[t[r+v]]++;for(_=y,x=15;x>=1&&0===T[x];x--);if(_>x&&(_=x),0===x)return i[a++]=0x1400000,i[a++]=0x1400000,o.bits=1,0;for(w=1;w<x&&0===T[w];w++);for(_<w&&(_=w),I=1,b=1;b<=15;b++)if(I<<=1,(I-=T[b])<0)return -1;if(I>0&&(0===e||1!==x))return -1;for(A[1]=0,b=1;b<15;b++)A[b+1]=A[b]+T[b];for(v=0;v<n;v++)0!==t[r+v]&&(s[A[t[r+v]]++]=v);if(0===e?(O=M=s,h=19):1===e?(O=e0,C-=257,M=e1,N-=257,h=256):(O=e2,M=e5,h=-1),$=0,v=0,b=w,f=a,k=_,S=0,u=-1,d=(E=1<<_)-1,1===e&&E>852||2===e&&E>592)return 1;for(;;){p=b-S,s[v]<h?(m=0,g=s[v]):s[v]>h?(m=M[N+s[v]],g=O[C+s[v]]):(m=96,g=0),l=1<<b-S,w=c=1<<k;do i[f+($>>S)+(c-=l)]=p<<24|m<<16|g;while(0!==c)for(l=1<<b-1;$&l;)l>>=1;if(0!==l?($&=l-1,$+=l):$=0,v++,0==--T[b]){if(b===x)break;b=t[r+s[v]]}if(b>_&&($&d)!==u){for(0===S&&(S=_),f+=w,I=1<<(k=b-S);k+S<x&&!((I-=T[k+S])<=0);)k++,I<<=1;if(E+=1<<k,1===e&&E>852||2===e&&E>592)return 1;i[u=$&d]=_<<24|k<<16|f-a}}return 0!==$&&(i[f+$]=b-S<<24|4194304),o.bits=_,0};let{Z_FINISH:e8,Z_BLOCK:e6,Z_TREES:e9,Z_OK:e4,Z_STREAM_END:e7,Z_NEED_DICT:te,Z_STREAM_ERROR:tt,Z_DATA_ERROR:tr,Z_MEM_ERROR:tn,Z_BUF_ERROR:ti,Z_DEFLATED:ta}=q,ts=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function to(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}let tl=e=>{if(!e||!e.state)return tt;let t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,(e=>{if(!e||!e.state)return tt;let t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,e4})(e)},tc=!0,tu=e=>{if(tc){s=new Int32Array(512),o=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(e3(1,e.lens,0,288,s,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;e3(2,e.lens,0,32,o,0,e.work,{bits:5}),tc=!1}e.lencode=s,e.lenbits=9,e.distcode=o,e.distbits=5},td=(e,t,r,n)=>{let i,a=e.state;return null===a.window&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new Uint8Array(a.wsize)),n>=a.wsize?(a.window.set(t.subarray(r-a.wsize,r),0),a.wnext=0,a.whave=a.wsize):((i=a.wsize-a.wnext)>n&&(i=n),a.window.set(t.subarray(r-n,r-n+i),a.wnext),(n-=i)?(a.window.set(t.subarray(r-n,r),0),a.wnext=n,a.whave=a.wsize):(a.wnext+=i,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=i))),0};var tf=(e,t)=>{let r,n,i,a,s,o,l,c,u,d,f,h,p,m,g,y,b,v,w,x,_,k,S,I,E=0,$=new Uint8Array(4),O=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return tt;12===(r=e.state).mode&&(r.mode=13),s=e.next_out,i=e.output,l=e.avail_out,a=e.next_in,n=e.input,o=e.avail_in,c=r.hold,u=r.bits,d=o,f=l,k=e4;n:for(;;)switch(r.mode){case 1:if(0===r.wrap){r.mode=13;break}for(;u<16;){if(0===o)break n;o--,c+=n[a++]<<u,u+=8}if(2&r.wrap&&35615===c){r.check=0,$[0]=255&c,$[1]=c>>>8&255,r.check=B(r.check,$,2,0),c=0,u=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&c)<<8)+(c>>8))%31){e.msg="incorrect header check",r.mode=30;break}if((15&c)!==ta){e.msg="unknown compression method",r.mode=30;break}if(c>>>=4,u-=4,_=(15&c)+8,0===r.wbits)r.wbits=_;else if(_>r.wbits){e.msg="invalid window size",r.mode=30;break}r.dmax=1<<r.wbits,e.adler=r.check=1,r.mode=512&c?10:12,c=0,u=0;break;case 2:for(;u<16;){if(0===o)break n;o--,c+=n[a++]<<u,u+=8}if(r.flags=c,(255&r.flags)!==ta){e.msg="unknown compression method",r.mode=30;break}if(57344&r.flags){e.msg="unknown header flags set",r.mode=30;break}r.head&&(r.head.text=c>>8&1),512&r.flags&&($[0]=255&c,$[1]=c>>>8&255,r.check=B(r.check,$,2,0)),c=0,u=0,r.mode=3;case 3:for(;u<32;){if(0===o)break n;o--,c+=n[a++]<<u,u+=8}r.head&&(r.head.time=c),512&r.flags&&($[0]=255&c,$[1]=c>>>8&255,$[2]=c>>>16&255,$[3]=c>>>24&255,r.check=B(r.check,$,4,0)),c=0,u=0,r.mode=4;case 4:for(;u<16;){if(0===o)break n;o--,c+=n[a++]<<u,u+=8}r.head&&(r.head.xflags=255&c,r.head.os=c>>8),512&r.flags&&($[0]=255&c,$[1]=c>>>8&255,r.check=B(r.check,$,2,0)),c=0,u=0,r.mode=5;case 5:if(1024&r.flags){for(;u<16;){if(0===o)break n;o--,c+=n[a++]<<u,u+=8}r.length=c,r.head&&(r.head.extra_len=c),512&r.flags&&($[0]=255&c,$[1]=c>>>8&255,r.check=B(r.check,$,2,0)),c=0,u=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&((h=r.length)>o&&(h=o),h&&(r.head&&(_=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(n.subarray(a,a+h),_)),512&r.flags&&(r.check=B(r.check,n,h,a)),o-=h,a+=h,r.length-=h),r.length))break n;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===o)break n;h=0;do _=n[a+h++],r.head&&_&&r.length<65536&&(r.head.name+=String.fromCharCode(_));while(_&&h<o)if(512&r.flags&&(r.check=B(r.check,n,h,a)),o-=h,a+=h,_)break n}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&r.flags){if(0===o)break n;h=0;do _=n[a+h++],r.head&&_&&r.length<65536&&(r.head.comment+=String.fromCharCode(_));while(_&&h<o)if(512&r.flags&&(r.check=B(r.check,n,h,a)),o-=h,a+=h,_)break n}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&r.flags){for(;u<16;){if(0===o)break n;o--,c+=n[a++]<<u,u+=8}if(c!==(65535&r.check)){e.msg="header crc mismatch",r.mode=30;break}c=0,u=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=12;break;case 10:for(;u<32;){if(0===o)break n;o--,c+=n[a++]<<u,u+=8}e.adler=r.check=ts(c),c=0,u=0,r.mode=11;case 11:if(0===r.havedict)return e.next_out=s,e.avail_out=l,e.next_in=a,e.avail_in=o,r.hold=c,r.bits=u,te;e.adler=r.check=1,r.mode=12;case 12:if(t===e6||t===e9)break n;case 13:if(r.last){c>>>=7&u,u-=7&u,r.mode=27;break}for(;u<3;){if(0===o)break n;o--,c+=n[a++]<<u,u+=8}switch(r.last=1&c,u-=1,3&(c>>>=1)){case 0:r.mode=14;break;case 1:if(tu(r),r.mode=20,t===e9){c>>>=2,u-=2;break n}break;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=30}c>>>=2,u-=2;break;case 14:for(c>>>=7&u,u-=7&u;u<32;){if(0===o)break n;o--,c+=n[a++]<<u,u+=8}if((65535&c)!=(c>>>16^65535)){e.msg="invalid stored block lengths",r.mode=30;break}if(r.length=65535&c,c=0,u=0,r.mode=15,t===e9)break n;case 15:r.mode=16;case 16:if(h=r.length){if(h>o&&(h=o),h>l&&(h=l),0===h)break n;i.set(n.subarray(a,a+h),s),o-=h,a+=h,l-=h,s+=h,r.length-=h;break}r.mode=12;break;case 17:for(;u<14;){if(0===o)break n;o--,c+=n[a++]<<u,u+=8}if(r.nlen=(31&c)+257,u-=5,r.ndist=(31&(c>>>=5))+1,u-=5,r.ncode=(15&(c>>>=5))+4,c>>>=4,u-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=30;break}r.have=0,r.mode=18;case 18:for(;r.have<r.ncode;){for(;u<3;){if(0===o)break n;o--,c+=n[a++]<<u,u+=8}r.lens[O[r.have++]]=7&c,c>>>=3,u-=3}for(;r.have<19;)r.lens[O[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,S={bits:r.lenbits},k=e3(0,r.lens,0,19,r.lencode,0,r.work,S),r.lenbits=S.bits,k){e.msg="invalid code lengths set",r.mode=30;break}r.have=0,r.mode=19;case 19:for(;r.have<r.nlen+r.ndist;){for(;g=(E=r.lencode[c&(1<<r.lenbits)-1])>>>24,y=E>>>16&255,b=65535&E,!(g<=u);){if(0===o)break n;o--,c+=n[a++]<<u,u+=8}if(b<16)c>>>=g,u-=g,r.lens[r.have++]=b;else{if(16===b){for(I=g+2;u<I;){if(0===o)break n;o--,c+=n[a++]<<u,u+=8}if(c>>>=g,u-=g,0===r.have){e.msg="invalid bit length repeat",r.mode=30;break}_=r.lens[r.have-1],h=3+(3&c),c>>>=2,u-=2}else if(17===b){for(I=g+3;u<I;){if(0===o)break n;o--,c+=n[a++]<<u,u+=8}c>>>=g,u-=g,_=0,h=3+(7&c),c>>>=3,u-=3}else{for(I=g+7;u<I;){if(0===o)break n;o--,c+=n[a++]<<u,u+=8}c>>>=g,u-=g,_=0,h=11+(127&c),c>>>=7,u-=7}if(r.have+h>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=30;break}for(;h--;)r.lens[r.have++]=_}}if(30===r.mode)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=30;break}if(r.lenbits=9,S={bits:r.lenbits},k=e3(1,r.lens,0,r.nlen,r.lencode,0,r.work,S),r.lenbits=S.bits,k){e.msg="invalid literal/lengths set",r.mode=30;break}if(r.distbits=6,r.distcode=r.distdyn,S={bits:r.distbits},k=e3(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,S),r.distbits=S.bits,k){e.msg="invalid distances set",r.mode=30;break}if(r.mode=20,t===e9)break n;case 20:r.mode=21;case 21:if(o>=6&&l>=258){e.next_out=s,e.avail_out=l,e.next_in=a,e.avail_in=o,r.hold=c,r.bits=u,eZ(e,f),s=e.next_out,i=e.output,l=e.avail_out,a=e.next_in,n=e.input,o=e.avail_in,c=r.hold,u=r.bits,12===r.mode&&(r.back=-1);break}for(r.back=0;g=(E=r.lencode[c&(1<<r.lenbits)-1])>>>24,y=E>>>16&255,b=65535&E,!(g<=u);){if(0===o)break n;o--,c+=n[a++]<<u,u+=8}if(y&&(240&y)==0){for(v=g,w=y,x=b;g=(E=r.lencode[x+((c&(1<<v+w)-1)>>v)])>>>24,y=E>>>16&255,b=65535&E,!(v+g<=u);){if(0===o)break n;o--,c+=n[a++]<<u,u+=8}c>>>=v,u-=v,r.back+=v}if(c>>>=g,u-=g,r.back+=g,r.length=b,0===y){r.mode=26;break}if(32&y){r.back=-1,r.mode=12;break}if(64&y){e.msg="invalid literal/length code",r.mode=30;break}r.extra=15&y,r.mode=22;case 22:if(r.extra){for(I=r.extra;u<I;){if(0===o)break n;o--,c+=n[a++]<<u,u+=8}r.length+=c&(1<<r.extra)-1,c>>>=r.extra,u-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;g=(E=r.distcode[c&(1<<r.distbits)-1])>>>24,y=E>>>16&255,b=65535&E,!(g<=u);){if(0===o)break n;o--,c+=n[a++]<<u,u+=8}if((240&y)==0){for(v=g,w=y,x=b;g=(E=r.distcode[x+((c&(1<<v+w)-1)>>v)])>>>24,y=E>>>16&255,b=65535&E,!(v+g<=u);){if(0===o)break n;o--,c+=n[a++]<<u,u+=8}c>>>=v,u-=v,r.back+=v}if(c>>>=g,u-=g,r.back+=g,64&y){e.msg="invalid distance code",r.mode=30;break}r.offset=b,r.extra=15&y,r.mode=24;case 24:if(r.extra){for(I=r.extra;u<I;){if(0===o)break n;o--,c+=n[a++]<<u,u+=8}r.offset+=c&(1<<r.extra)-1,c>>>=r.extra,u-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=30;break}r.mode=25;case 25:if(0===l)break n;if(h=f-l,r.offset>h){if((h=r.offset-h)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=30;break}h>r.wnext?(h-=r.wnext,p=r.wsize-h):p=r.wnext-h,h>r.length&&(h=r.length),m=r.window}else m=i,p=s-r.offset,h=r.length;h>l&&(h=l),l-=h,r.length-=h;do i[s++]=m[p++];while(--h)0===r.length&&(r.mode=21);break;case 26:if(0===l)break n;i[s++]=r.length,l--,r.mode=21;break;case 27:if(r.wrap){for(;u<32;){if(0===o)break n;o--,c|=n[a++]<<u,u+=8}if(f-=l,e.total_out+=f,r.total+=f,f&&(e.adler=r.check=r.flags?B(r.check,i,f,s-f):U(r.check,i,f,s-f)),f=l,(r.flags?c:ts(c))!==r.check){e.msg="incorrect data check",r.mode=30;break}c=0,u=0}r.mode=28;case 28:if(r.wrap&&r.flags){for(;u<32;){if(0===o)break n;o--,c+=n[a++]<<u,u+=8}if(c!==(0|r.total)){e.msg="incorrect length check",r.mode=30;break}c=0,u=0}r.mode=29;case 29:k=e7;break n;case 30:k=tr;break n;case 31:return tn;default:return tt}return e.next_out=s,e.avail_out=l,e.next_in=a,e.avail_in=o,r.hold=c,r.bits=u,(r.wsize||f!==e.avail_out&&r.mode<30&&(r.mode<27||t!==e8))&&td(e,e.output,e.next_out,f-e.avail_out),d-=e.avail_in,f-=e.avail_out,e.total_in+=d,e.total_out+=f,r.total+=f,r.wrap&&f&&(e.adler=r.check=r.flags?B(r.check,i,f,e.next_out-f):U(r.check,i,f,e.next_out-f)),e.data_type=r.bits+64*!!r.last+128*(12===r.mode)+256*(20===r.mode||15===r.mode),(0===d&&0===f||t===e8)&&k===e4&&(k=ti),k},th=e=>{if(!e||!e.state)return tt;let t=e.state;return t.window&&(t.window=null),e.state=null,e4},tp=(e,t)=>{let r,n=t.length;return e&&e.state&&(0===(r=e.state).wrap||11===r.mode)?11===r.mode&&U(1,t,n,0)!==r.check?tr:td(e,t,n,n)?(r.mode=31,tn):(r.havedict=1,e4):tt},tm=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};let tg=Object.prototype.toString,{Z_NO_FLUSH:ty,Z_FINISH:tb,Z_OK:tv,Z_STREAM_END:tw,Z_NEED_DICT:tx,Z_STREAM_ERROR:t_,Z_DATA_ERROR:tk,Z_MEM_ERROR:tS}=q;function tI(e){this.options=eN({chunkSize:65536,windowBits:15,to:""},e||{});let t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(e&&e.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(15&t.windowBits)==0&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new eF,this.strm.avail_out=0;let r=((e,t)=>{if(!e)return tt;let r=new to;e.state=r,r.window=null;let n=((e,t)=>{let r;if(!e||!e.state)return tt;let n=e.state;return(t<0?(r=0,t=-t):(r=(t>>4)+1,t<48&&(t&=15)),t&&(t<8||t>15))?tt:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,tl(e))})(e,t);return n!==e4&&(e.state=null),n})(this.strm,t.windowBits);if(r!==tv||(this.header=new tm,((e,t)=>{if(!e||!e.state)return;let r=e.state;return(2&r.wrap)==0||(r.head=t,t.done=!1)})(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=eD(t.dictionary):"[object ArrayBuffer]"===tg.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw)&&(r=tp(this.strm,t.dictionary))!==tv))throw Error(W[r])}function tE(e,t){let r=new tI(t);if(r.push(e),r.err)throw r.msg||W[r.err];return r.result}tI.prototype.push=function(e,t){let r,n,i,a=this.strm,s=this.options.chunkSize,o=this.options.dictionary;if(this.ended)return!1;for(n=t===~~t?t:!0===t?tb:ty,"[object ArrayBuffer]"===tg.call(e)?a.input=new Uint8Array(e):a.input=e,a.next_in=0,a.avail_in=a.input.length;;){for(0===a.avail_out&&(a.output=new Uint8Array(s),a.next_out=0,a.avail_out=s),(r=tf(a,n))===tx&&o&&((r=tp(a,o))===tv?r=tf(a,n):r===tk&&(r=tx));a.avail_in>0&&r===tw&&a.state.wrap>0&&0!==e[a.next_in];)tl(a),r=tf(a,n);switch(r){case t_:case tk:case tx:case tS:return this.onEnd(r),this.ended=!0,!1}if(i=a.avail_out,a.next_out&&(0===a.avail_out||r===tw))if("string"===this.options.to){let e=eU(a.output,a.next_out),t=a.next_out-e,r=eL(a.output,e);a.next_out=t,a.avail_out=s-t,t&&a.output.set(a.output.subarray(e,e+t),0),this.onData(r)}else this.onData(a.output.length===a.next_out?a.output:a.output.subarray(0,a.next_out));if(r!==tv||0!==i){if(r===tw)return r=th(this.strm),this.onEnd(r),this.ended=!0,!0;if(0===a.avail_in)break}}return!0},tI.prototype.onData=function(e){this.chunks.push(e)},tI.prototype.onEnd=function(e){e===tv&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=eP(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};let{Deflate:t$,deflate:tO,deflateRaw:tC,gzip:tT}={Deflate:eH,deflate:eQ,deflateRaw:function(e,t){return(t=t||{}).raw=!0,eQ(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,eQ(e,t)},constants:q},{Inflate:tA,inflate:tM,inflateRaw:tN,ungzip:tP}={Inflate:tI,inflate:tE,inflateRaw:function(e,t){return(t=t||{}).raw=!0,tE(e,t)},ungzip:tE,constants:q};r.d(t,{Gy:()=>t$,Kc:()=>tO,UD:()=>tM})},3035(e,t,r){let n;r.d(t,{Er:()=>rT,y1:()=>t9,Ov:()=>r1,Tx:()=>r4,UA:()=>iM,JH:()=>rQ,yE:()=>ri,Ky:()=>tl,e5:()=>tj,Uh:()=>t4,nu:()=>tm,OF:()=>aN,XV:()=>aT,r8:()=>aA,rC:()=>aM,rR:()=>iN});var i=r(8861),a=r(8619),s=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=i.ukk,g=i.mSG(i.QfV,i.$r1),y=Object.freeze({paper:"#f6f1e7",card:"#fffdf8",ink:"#1a1712",accent:"#8f707f"}),b=Object.freeze({accentColor:y.accent,backgroundColor:y.card});function v(e,t){return e.pipe(i.tiU(s.PyW(t)))}function w(e,t){return i.svK(e,{errors:"all"})(t)}let x=u.ID();function _(e){return Object.assign(e,{parse:t=>w(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:x(r.failure.issue).issues.map(e=>({message:e.message,path:(e.path??[]).map(e=>"object"==typeof e?e.key:e)}))},success:!1}}})}let k=i.xCb(["flowchart","mindmap"]),S=i.xCb(["TB","BT","LR","RL"]),I=i.xCb(["straight","orthogonal","curved"]);class E extends i.Xsx("DiagramNode")({id:m,label:m,group:i.lqM(m),kind:i.lqM(m),metadata:v(g,{})}){}_(E);class $ extends i.Xsx("DiagramEdge")({id:m,source:m,target:m,label:i.lqM(m),metadata:v(g,{})}){}_($);let O=i.QfV.check(i.Pto(/^#[0-9a-fA-F]{6}$/));class C extends i.Xsx("DiagramStyle")({accentColor:v(O,b.accentColor),backgroundColor:v(O,b.backgroundColor)}){}_(C);class T extends i.Xsx("DiagramLayout")({direction:v(S,"LR"),edgeRouting:v(I,"orthogonal")}){}_(T);class A extends i.Xsx("IntermediateDiagram")({id:m,title:m,type:v(k,"flowchart"),nodes:i.O31(E).pipe(i.fXn).check(i.tJb(1)),edges:v(i.O31($).pipe(i.fXn),[]),layout:v(T,{direction:"LR",edgeRouting:"orthogonal"}),style:v(C,b),metadata:v(g,{})}){}_(A);class M extends Error{constructor(e){super(e),this.name="DiagramValidationError"}}let N=e=>{let t=new Set;for(let r of e){if(t.has(r))return r;t.add(r)}};function P(e){let t=N(e.nodes.map(e=>e.id));if(t)throw new M(`Duplicate node id "${t}" is not allowed.`);let r=N(e.edges.map(e=>e.id));if(r)throw new M(`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 M(`Edge "${t.id}" references missing source node "${t.source}".`);if(!n.has(t.target))throw new M(`Edge "${t.id}" references missing target node "${t.target}".`);if(t.source===t.target)throw new M(`Edge "${t.id}" cannot connect node "${t.source}" to itself.`)}return e}function R(e){return P(w(A,e))}let j="flowchart",D=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 L extends i.Xsx("FlowchartValidationIssueRef")({kind:i.xCb(["diagram","node","edge"]),id:i.lqM(i.ukk),path:i.lqM(i.ukk)}){}i.Xsx("FlowchartValidationIssue")({code:D,ref:i.lqM(L),message:i.ukk,hint:i.ukk});let U=i.xCb(["start","process","decision","end"]);class F extends E.extend("FlowchartNode")({kind:U,description:i.lqM(i.ukk)}){}class B extends $.extend("FlowchartEdge")({label:i.lqM(i.ukk)}){}class W extends A.extend("FlowchartDiagram")({type:i.uSQ(j),nodes:i.O31(F).pipe(i.fXn).check(i.tJb(2)),edges:i.O31(B).pipe(i.fXn).check(i.tJb(1))}){}let q=_(W);function Y(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 z(e,t,r){let n=new Set,i=[...e];for(let e=0;e<i.length;e+=1){let a=i[e];if(!(void 0===a||n.has(a)))for(let e of(n.add(a),t.get(a)??[]))i.push(r(e))}return n}function X(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."}),Y(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 Y(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 a=e.nodes.filter(e=>"start"===e.kind),s=e.nodes.filter(e=>"end"===e.kind);for(let r of(0===a.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".'}):a.length>1&&t.push({code:"multiple_starts",ref:{kind:"diagram",id:e.id,path:"nodes"},message:`Flowchart has ${a.length} start nodes.`,hint:"Keep one start node and change the others to process, decision, or end."}),0===s.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)??[],a=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&&a.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===a.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 Y(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,a))}let o=1===a.length?a[0]:void 0;if(o){let r=z([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(s.length>0){let a=z(s.map(e=>e.id),n,e=>e.source);for(let n of e.nodes)r.has(n.id)&&!a.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 J extends M{issues;constructor(e){super(e[0]?.message??"Flowchart failed semantic validation."),this.issues=e,this.name="FlowchartValidationError"}}function G(e){let t=X(e);if(t.length>0)throw new J(t);return e}let V=G(w(W,{id:"onboarding-flow",title:"Sketchi onboarding decision flow",type:j,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"}}));G(w(W,{id:"pharma-batch-disposition",title:"Pharma batch disposition flow",type:j,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"}}));let K="mindmap";class H extends i.Xsx("MindmapNodeMetadata")({depth:i.Aiz.check(i.OWK(0)),siblingIndex:i.Aiz.check(i.OWK(0))}){}class Q extends E.extend("MindmapNode")({kind:i.xCb(["root","topic"]),metadata:H}){}class Z extends i.Xsx("MindmapEdgeMetadata")({depth:i.Aiz.check(i.yJO(0)),siblingIndex:i.Aiz.check(i.OWK(0))}){}class ee extends $.extend("MindmapEdge")({metadata:Z}){}class et extends A.extend("MindmapDiagram")({type:i.uSQ(K),nodes:i.O31(Q).pipe(i.fXn).check(i.tJb(2)),edges:i.O31(ee).pipe(i.fXn).check(i.tJb(1))}){}function er(e){return function(e){P(e);let t=e.nodes.filter(e=>"root"===e.kind);if(1!==t.length)throw new M(`Mindmap must contain exactly one root topic; found ${t.length}.`);let r=t[0];if(!r||0!==r.metadata.depth)throw new M("Mindmap root topic must have depth 0.");let n=new Map,i=new Map(e.nodes.map(e=>[e.id,e])),a=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),s=r?.metadata.depth;if(void 0===e||s!==e+1)throw new M(`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 M(`Mindmap edge "${t.id}" metadata must match its child topic.`);a.set(t.source,[...a.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 M(`Mindmap topic "${t.id}" must have ${t.id===r.id?"no parent":"exactly one parent"}.`)}for(let[e,t]of a){let r=t.map((e,t)=>t);if([...t].sort((e,t)=>e-t).some((e,t)=>e!==r[t]))throw new M(`Mindmap children of "${e}" must use contiguous sibling ordering from 0.`)}return e}(w(et,e))}_(et);let en=er({id:"public-mindmap-capability",title:"Public mindmap generation",type:K,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"}});R(V),R(en);let ei=Object.freeze({maxDimension:16384,maxElements:600,maxGroupsPerElement:16,maxLayouts:128,maxLayers:64,maxPointsPerElement:256,maxSerializedBytes:15e5,maxTextLength:4096,maxZOrderEntries:600});function ea(e){let t=new Set;for(let r of e){if(t.has(r))return r;t.add(r)}}function es(e){return"x"in e&&"y"in e}function eo(e){let t=[];0===e.elements.length&&t.push({code:"empty_canvas",message:"CanvasSpec must contain at least one element.",path:"elements"}),e.elements.length>ei.maxElements&&t.push({code:"limit_exceeded",message:`Canvas exceeds ${ei.maxElements} elements.`,path:"elements"}),e.layers.length>ei.maxLayers&&t.push({code:"limit_exceeded",message:`Canvas exceeds ${ei.maxLayers} layers.`,path:"layers"}),e.layouts.length>ei.maxLayouts&&t.push({code:"limit_exceeded",message:`Canvas exceeds ${ei.maxLayouts} layout primitives.`,path:"layouts"}),(e.width>ei.maxDimension||e.height>ei.maxDimension)&&t.push({code:"limit_exceeded",message:`Canvas dimensions may not exceed ${ei.maxDimension}.`,path:"width"});let r=ea(e.elements.map(e=>e.id));r&&t.push({code:"duplicate_element_id",elementId:r,message:`Duplicate element id "${r}" is not allowed.`,path:"elements"});let n=ea(e.layers.map(e=>e.id));n&&t.push({code:"duplicate_layer_id",message:`Duplicate layer id "${n}" is not allowed.`,path:"layers"});let i=ea(e.zOrder);i&&t.push({code:"unknown_z_order_element",elementId:i,message:`zOrder contains duplicate element "${i}".`,path:"zOrder"}),e.zOrder.length>ei.maxZOrderEntries&&t.push({code:"limit_exceeded",message:`zOrder exceeds ${ei.maxZOrderEntries} entries.`,path:"zOrder"});let a=new Map(e.elements.map(e=>[e.id,e])),s=e.elements.filter(e=>"node"===e.type),o=new Map(s.map(e=>[e.nodeId,e])),l=ea(s.map(e=>e.nodeId));l&&t.push({code:"invalid_binding",message:`Duplicate nodeId "${l}" makes connector bindings ambiguous.`,path:"elements"});let c=ea(e.elements.flatMap(e=>"arrow"===e.type?[e.edgeId]:[]));c&&t.push({code:"invalid_binding",message:`Duplicate edgeId "${c}" makes connector selection ambiguous.`,path:"elements"});let u=ea(e.elements.flatMap(e=>"text"===e.type&&e.containerId?[e.containerId]:[]));u&&t.push({code:"invalid_binding",elementId:u,message:`Container "${u}" has more than one bound text element.`,path:"elements"});let d=new Set(e.layers.map(e=>e.id));e.elements.forEach((e,r)=>{let n,i;if(t.push(...(n=[],i=`elements[${r}]`,"width"in e&&"height"in e&&(!(e.width>0)||!(e.height>0))&&n.push({code:"invalid_geometry",elementId:e.id,message:`Element "${e.id}" must have positive width and height.`,path:i}),"points"in e&&void 0!==e.points&&e.points.length>ei.maxPointsPerElement&&n.push({code:"limit_exceeded",elementId:e.id,message:`Element "${e.id}" exceeds ${ei.maxPointsPerElement} points.`,path:`${i}.points`}),"text"in e&&e.text.length>ei.maxTextLength&&n.push({code:"limit_exceeded",elementId:e.id,message:`Text element "${e.id}" exceeds ${ei.maxTextLength} characters.`,path:`${i}.text`}),"node"===e.type&&"polygon"===e.shape&&(!e.points||e.points.length<3)&&n.push({code:"invalid_polygon",elementId:e.id,message:`Polygon "${e.id}" requires at least three points.`,path:`${i}.points`}),e.groupIds&&e.groupIds.length>ei.maxGroupsPerElement&&n.push({code:"limit_exceeded",elementId:e.id,message:`Element "${e.id}" exceeds ${ei.maxGroupsPerElement} groups.`,path:`${i}.groupIds`}),n)),e.frameId){let n=a.get(e.frameId);n&&"frame"===n.type||t.push({code:"invalid_composition",elementId:e.id,message:`Element "${e.id}" references missing frame "${e.frameId}".`,path:`elements[${r}].frameId`})}if(e.layerId&&!d.has(e.layerId)&&t.push({code:"invalid_composition",elementId:e.id,message:`Element "${e.id}" references missing layer "${e.layerId}".`,path:`elements[${r}].layerId`}),e.groupIds&&ea(e.groupIds)&&t.push({code:"invalid_composition",elementId:e.id,message:`Element "${e.id}" contains duplicate group ids.`,path:`elements[${r}].groupIds`}),"text"===e.type&&e.containerId){let n=a.get(e.containerId);n&&("node"===n.type||"arrow"===n.type)||t.push({code:"invalid_binding",elementId:e.id,message:`Text "${e.id}" references unsupported container "${e.containerId}".`,path:`elements[${r}].containerId`})}if("arrow"===e.type&&(o.has(e.sourceNodeId)||t.push({code:"invalid_binding",elementId:e.id,message:`Connector "${e.id}" references missing source "${e.sourceNodeId}".`,path:`elements[${r}].sourceNodeId`}),o.has(e.targetNodeId)||t.push({code:"invalid_binding",elementId:e.id,message:`Connector "${e.id}" references missing target "${e.targetNodeId}".`,path:`elements[${r}].targetNodeId`})),"line"===e.type)for(let[n,i]of[["startBinding",e.startBinding],["endBinding",e.endBinding]]){let s=i?a.get(i.elementId):void 0;i&&(!s||"node"!==s.type&&"frame"!==s.type)&&t.push({code:"invalid_binding",elementId:e.id,message:`Line "${e.id}" references missing binding "${i.elementId}".`,path:`elements[${r}].${n}`})}});let f=new Set(e.zOrder);for(let r of e.elements)f.has(r.id)||t.push({code:"missing_z_order_element",elementId:r.id,message:`Element "${r.id}" is missing from zOrder.`,path:"zOrder"});for(let r of e.zOrder)a.has(r)||t.push({code:"unknown_z_order_element",elementId:r,message:`zOrder references missing element "${r}".`,path:"zOrder"});for(let[r,n]of e.layouts.entries())for(let e of n.ids){let n=a.get(e);n&&es(n)||t.push({code:"unknown_layout_target",elementId:e,message:`Layout references missing or non-positioned element "${e}".`,path:`layouts[${r}].ids`})}for(let r of e.elements.filter(e=>"frame"===e.type)){let e=new Set([r.id]),n=r.frameId;for(;n;){if(e.has(n)){t.push({code:"invalid_composition",elementId:r.id,message:`Frame "${r.id}" participates in a frame nesting cycle.`,path:"elements"});break}e.add(n);let i=a.get(n);n=i?.type==="frame"?i.frameId:void 0}}return t}function el(e){if("text"===e.type){let t=e.text.split("\n");return{x:e.x,y:e.y,width:e.maxWidth??Math.max(...t.map(e=>e.length))*e.fontSize*.62,height:t.length*e.fontSize*1.35}}return{x:e.x,y:e.y,width:e.width,height:e.height}}function ec(e,t){let r=new Map(e.map(e=>[e.id,e]));return t.flatMap(e=>{let t=r.get(e);return t&&es(t)?[t]:[]})}function eu(e,t){return e.map(e=>{var r,n;let i=t.get(e.id);return i?(r=i.x,n=i.y,es(e)?{...e,x:r,y:n}:e):e})}function ed(e,t){return"x"===t?e.x:e.y}function ef(e,t){return"x"===t?e.width:e.height}function eh(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function ep(e,t){let r=eh(e),n=t.x-r.x,i=t.y-r.y;return Math.abs(n)>=Math.abs(i)?{x:n>=0?e.x+e.width:e.x,y:r.y}:{x:r.x,y:i>=0?e.y+e.height:e.y}}let em=/[,;]\s*(?:id|label|kind|group|source|target|title|direction|nodes|edges)\s*:?\s*$/i;function eg(e){let t=e.trim();for(;;){let e=t.replace(em,"").trim();if(e===t)return t;t=e}}class ey extends i.Xsx("ContractSchemaIssue")({code:eM("custom"),message:i.QfV,path:i.O31(i.pHd)},{identifier:void 0}){}class eb extends i.X0d()("ContractSchemaError",{issues:i.O31(i.O3D(ey))}){}let ev=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}`},ew=u.ID({leafHook:ev});function ex(e){return"string"==typeof e||"number"==typeof e||"symbol"==typeof e}function e_(e,t){let r,n=i.q$Z(e,{errors:"all"})(t);return f.oJ(n)?{data:n.success,success:!0}:{error:new eb({issues:(r=ew(n.failure.issue).issues.map(e=>{let t=(e.path??[]).flatMap(e=>{let t=ex(e)?e:null!==e&&"object"==typeof e&&"key"in e&&ex(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 ek(e){return Object.assign(e,{parse:t=>(function(e,t){let r=e_(e,t);if(r.success)return r.data;throw r.error})(e,t),safeParse:t=>e_(e,t)})}let eS=new Set(["const","exclusiveMaximum","exclusiveMinimum","maximum","maxLength","minimum","minItems","minLength","pattern"]);function eI(e){let t=i._oz(i.AxX(e),{includeAnnotationKey:e=>eS.has(e)});return{$schema:"https://json-schema.org/draft/2020-12/schema",...t.schema,...0===Object.keys(t.definitions).length?{}:{$defs:t.definitions}}}function eE(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$(e){let t=i.hzj()([e],([e])=>(t,r,n)=>void 0===t?s.PyW(void 0):h._R(e)(t,n),{toCodecJson:([e])=>i.nfo()(e,{decode:p.le({strict:!1}),encode:new p.uB(e=>s.PyW(d.filter(e,e=>void 0!==e)))})});return i.Qrq(t)}function eO(e){return e.pipe(i.usV({messageMissingKey:"Invalid input: expected string, received undefined"}))}function eC(e){return e.pipe(i.usV({messageMissingKey:"Invalid input: expected object, received undefined"}))}function eT(e){return e.pipe(i.usV({messageMissingKey:"Invalid input: expected array, received undefined"}))}function eA(e){return i.xCb(e).annotate({message:`Invalid option: expected one of ${e.map(e=>JSON.stringify(e)).join("|")}`})}function eM(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 eN(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 eP(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 eR=i.QfV.annotate({minLength:1}).check(i.HNH(e=>e.length>=1,{message:"Too small: expected string to have >=1 characters"})),ej=eO(eR),eD=i.wYs,eL=i.wNn.annotate({exclusiveMinimum:0}).check(i.MIs(),i.HNH(e=>e>0,{message:"Too small: expected number to be >0"})),eU=/^#[0-9a-fA-F]{6}$/;function eF(e){return i.QfV.annotate({pattern:eU.source,...void 0===e?{}:{default:e}}).check(i.HNH(e=>eU.test(e),{message:`Invalid string: must match pattern /${eU.source}/`}))}let eB=eF();ek(eB);let eW=["excalidraw","scene","png"],eq=["excalidraw","scene"],eY=Object.assign(ek(eA(eW)),{options:eW}),ez=Object.assign(ek(eA(eq)),{options:eq});class eX extends i.Xsx("ArtifactProvenance")({sourceArtifactId:ej.pipe(i.Wa3)},{identifier:void 0}){}ek(eX);let eJ=["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","duplicate_element_id","duplicate_layer_id","invalid_canvas_binding","invalid_canvas_composition","invalid_canvas_geometry","invalid_polygon","canvas_limit_exceeded","invalid_z_order","unknown_layout_target"],eG=Object.assign(ek(eA(eJ)),{options:eJ}),eV=eA(["request","diagram","node","edge","element","layer","artifact"]),eK=eA(["input","canvas","flowchart","mindmap","quality","render","export","storage"]);class eH extends i.Xsx("CodeModeIssueRef")({kind:eV,id:e$(eR),path:e$(eR)},{identifier:void 0}){}ek(eH);class eQ extends i.Xsx("CodeModeIssue")({code:eG,severity:eA(["error","warning"]),stage:eK,ref:e$(eH),message:ej,hint:ej},{identifier:void 0}){}ek(eQ);let eZ=["start","process","decision","end"],e0=Object.assign(ek(eA(eZ)),{options:eZ}),e1=["setDefaultStyle","setStyle","setShape","translate","replaceText","rerouteEdges","insert","remove","replace","reorder","group","ungroup"];Object.assign(ek(eA(e1)),{options:e1});class e2 extends i.Xsx("FlowchartSpecNode")({id:ej,label:ej,kind:e0,description:e$(eR)},{identifier:void 0}){}class e5 extends i.Xsx("FlowchartSpecEdge")({id:e$(eR),source:ej,target:ej,label:e$(eR)},{identifier:void 0}){}let e3=eA(["TB","LR"]),e8=e3.annotate({default:"TB"}).pipe(i.tiU(s.PyW("TB")));class e6 extends i.Xsx("FlowchartSpecLayout")({direction:e8},{identifier:void 0}){}let e9=b.accentColor,e4=eF(e9).pipe(i.tiU(s.PyW(e9))),e7=b.backgroundColor,te=eF(e7).pipe(i.tiU(s.PyW(e7)));class tt extends i.Xsx("FlowchartSpecStyle")({accentColor:e4,backgroundColor:te},{identifier:void 0}){}let tr=[],tn=i.O31(e5).pipe(i.fXn).annotate({default:tr}).pipe(i.tiU(s.PyW(tr))),ti={direction:"TB"},ta=e6.annotate({default:ti}).pipe(i.tiU(s.PyW(ti))),ts={accentColor:b.accentColor,backgroundColor:b.backgroundColor},to=tt.annotate({default:ts}).pipe(i.tiU(s.PyW(ts)));class tl extends i.Xsx("FlowchartSpec")({id:e$(eR),title:ej,nodes:eT(eE(e2)),edges:tn,layout:ta,style:to},{identifier:void 0}){}ek(tl),ek(e2),ek(e5),ek(e6),ek(tt);class tc extends i.Xsx("SequenceParticipantSpec")({id:ej,label:ej,kind:e$(eR)},{identifier:void 0}){}class tu extends i.Xsx("SequenceMessageSpec")({id:e$(eR),source:ej,target:ej,label:ej,type:e$(eA(["message","return"])),style:e$(eA(["solid","dashed"]))},{identifier:void 0}){}let td=[],tf=i.O31(tu).pipe(i.fXn).annotate({default:td}).pipe(i.tiU(s.PyW(td))),th={accentColor:b.accentColor,backgroundColor:b.backgroundColor},tp=i._kM({accentColor:eF(e9).pipe(i.tiU(s.PyW(e9))),backgroundColor:eF(e7).pipe(i.tiU(s.PyW(e7)))}).annotate({default:th}).pipe(i.tiU(s.PyW(th)));class tm extends i.Xsx("SequenceDiagramSpec")({id:e$(eR),title:ej,participants:eT(eE(tc)),messages:tf,style:tp},{identifier:void 0}){}ek(tm),ek(tc),ek(tu);let tg=e$(eE(eY)),ty=e$(i.O31(ez).pipe(i.fXn)),tb=e$(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 tv extends i.Xsx("BuildFlowchartOptions")({artifactFormats:tg,inlineArtifacts:ty,minQualityScore:tb},{identifier:void 0}){}ek(e$(tv));class tw extends i.Xsx("BuildFlowchartRequest")({requestId:e$(eR),spec:eC(tl),options:e$(tv)},{identifier:void 0}){}let tx=tl.mapFields(({id:e,title:t,nodes:r,edges:n,layout:i})=>({id:e,title:t,nodes:r,edges:n,layout:i})),t_=i._kM({requestId:e$(eR),spec:eC(tx)}),tk=i.rcy(t_,{leafHook:ev,parseOptions:{errors:"all"}});Object.assign(tk["~standard"],{jsonSchema:{input:()=>eI(t_),output:()=>eI(t_)}});let tS=Object.assign(ek(tw),{omit:e=>tk});class tI extends i.Xsx("BuildSequenceDiagramRequest")({requestId:e$(eR),spec:eC(tm),options:e$(tv)},{identifier:void 0}){}let tE=ek(tI),t$=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=eg(e);return t.length>0&&!/^(?:""|''|``)$/.test(t)},{message:"Must contain semantic text after normalization."})),tO=eC(i.DYE(()=>tC).annotate({identifier:"__schema0"})),tC=i._kM({label:eO(t$),children:i.Qrq(i.O31(tO).pipe(i.fXn))});ek(tO);class tT extends i.Xsx("MindmapSpecLayout")({direction:eA(["LR","RL"]).annotate({default:"LR"}).pipe(i.tiU(s.PyW("LR")))},{identifier:void 0}){}let tA={direction:"LR"},tM=tT.annotate({default:tA}).pipe(i.tiU(s.PyW(tA))),tN={accentColor:b.accentColor,backgroundColor:b.backgroundColor},tP=i._kM({accentColor:eF(e9).pipe(i.tiU(s.PyW(tN.accentColor))),backgroundColor:eF(tN.backgroundColor).pipe(i.tiU(s.PyW(tN.backgroundColor)))}).annotate({default:tN}).pipe(i.tiU(s.PyW(tN))),tR=i._kM({id:e$(eR),title:eO(t$),root:tO,layout:tM,style:tP});class tj extends i.Xsx("MindmapSpec")(tR,{identifier:void 0}){}ek(tj);let tD=i._kM({requestId:e$(eR),spec:eC(tR),options:e$(tv)});i.Xsx("BuildMindmapRequest")(tD,{identifier:void 0});let tL=ek(tD);class tU extends i.Xsx("ScenePoint")({x:eD.pipe(i.Wa3),y:eD.pipe(i.Wa3)},{identifier:void 0}){}ek(tU);let tF={frameId:e$(eR).pipe(i.Wa3),groupIds:e$(i.O31(eR).pipe(i.fXn).annotate({maxItems:ei.maxGroupsPerElement})).pipe(i.Wa3),layerId:e$(eR).pipe(i.Wa3),locked:e$(i.v8c).pipe(i.Wa3),opacity:e$(i.wNn.annotate({minimum:0,maximum:100}).check(i.MIs(),i.Bt9({minimum:0,maximum:100}))).pipe(i.Wa3),zIndex:e$(i.Aiz).pipe(i.Wa3)},tB={fillColor:e$(eB).pipe(i.Wa3),fillStyle:e$(eA(["cross-hatch","hachure","solid"])).pipe(i.Wa3),roughness:e$(eA([0,1,2])).pipe(i.Wa3),strokeColor:e$(eB).pipe(i.Wa3),strokeStyle:e$(eA(["dashed","dotted","solid"])).pipe(i.Wa3),strokeWidth:e$(eA([1,2,4])).pipe(i.Wa3)},tW=i.T9y(eA(["arrow","bar","circle","diamond","triangle"])),tq=i.O31(tU).pipe(i.fXn).annotate({minItems:2,maxItems:ei.maxPointsPerElement}).check(i.HNH(e=>e.length>=2,{message:"Too small: expected array to have >=2 items"}),i.HNH(e=>e.length<=ei.maxPointsPerElement,{message:`Too big: expected array to have <=${ei.maxPointsPerElement} items`}));class tY extends i.Xsx("NodeSceneElement")({...tF,...tB,type:eM("node"),id:ej,nodeId:ej,kind:e$(eR),rendererRole:e$(eA(["sequence-lifeline"])),shape:eA(["rectangle","ellipse","diamond","circle","polygon"]).pipe(i.Wa3),points:e$(tq).pipe(i.Wa3),textColor:e$(eB).pipe(i.Wa3),x:eD.pipe(i.Wa3),y:eD.pipe(i.Wa3),width:eL.pipe(i.Wa3),height:eL.pipe(i.Wa3),label:ej.pipe(i.Wa3)},{identifier:void 0}){}class tz extends i.Xsx("TextSceneElement")({...tF,type:eM("text"),id:ej,containerId:e$(eR),textColor:e$(eB).pipe(i.Wa3),x:eD.pipe(i.Wa3),y:eD.pipe(i.Wa3),text:ej.pipe(i.Wa3),fontSize:eL,fontFamily:e$(eA(["hand","mono","sans"])),maxWidth:e$(eL),textAlign:e$(eA(["center","left","right"])),verticalAlign:e$(eA(["bottom","middle","top"]))},{identifier:void 0}){}class tX extends i.Xsx("ArrowSceneElement")({...tF,...tB,type:eM("arrow"),id:ej,edgeId:ej,sourceNodeId:ej,targetNodeId:ej.pipe(i.Wa3),startArrowhead:e$(tW).pipe(i.Wa3),endArrowhead:e$(tW).pipe(i.Wa3),textColor:e$(eB).pipe(i.Wa3),points:eT(tq).pipe(i.Wa3),label:e$(eR).pipe(i.Wa3)},{identifier:void 0}){}class tJ extends i.Xsx("CanvasLineBinding")({elementId:ej,focus:e$(eD),gap:e$(eD)},{identifier:void 0}){}class tG extends i.Xsx("LineSceneElement")({...tF,...tB,type:eM("line"),id:ej,points:eT(tq).pipe(i.Wa3),startBinding:e$(tJ).pipe(i.Wa3),endBinding:e$(tJ).pipe(i.Wa3),startArrowhead:e$(tW).pipe(i.Wa3),endArrowhead:e$(tW).pipe(i.Wa3),label:e$(eR).pipe(i.Wa3),textColor:e$(eB).pipe(i.Wa3)},{identifier:void 0}){}class tV extends i.Xsx("FrameSceneElement")({...tF,...tB,type:eM("frame"),id:ej,name:e$(eR).pipe(i.Wa3),x:eD.pipe(i.Wa3),y:eD.pipe(i.Wa3),width:eL.pipe(i.Wa3),height:eL.pipe(i.Wa3)},{identifier:void 0}){}class tK extends i.Xsx("CanvasLayer")({id:ej,name:e$(eR),locked:e$(i.v8c),visible:e$(i.v8c)},{identifier:void 0}){}let tH=eT(eE(eR));class tQ extends i.Xsx("CanvasFlowLayout")({type:eA(["row","column","stack"]),ids:tH,x:e$(eD),y:e$(eD),gap:e$(eD)},{identifier:void 0}){}class tZ extends i.Xsx("CanvasGridLayout")({type:eM("grid"),ids:tH,columns:i.Aiz.annotate({minimum:1}).check(i.HNH(e=>e>=1,{message:"Too small: expected number to be >=1"})),x:e$(eD),y:e$(eD),columnGap:e$(eD),rowGap:e$(eD)},{identifier:void 0}){}class t0 extends i.Xsx("CanvasAlignLayout")({type:eM("align"),ids:tH,axis:eA(["x","y"]),alignment:eA(["center","end","start"])},{identifier:void 0}){}class t1 extends i.Xsx("CanvasDistributeLayout")({type:eM("distribute"),ids:tH,axis:eA(["x","y"]),gap:e$(eD)},{identifier:void 0}){}ek(tY),ek(tz),ek(tX),ek(tG),ek(tV);let t2=i.gPz([tY,tz,tX,tG,tV],{mode:"oneOf"}),t5=i.gPz([tQ,tZ,t0,t1],{mode:"oneOf"}),t3=i.O31(tK).pipe(i.fXn).annotate({default:[],maxItems:ei.maxLayers}).pipe(i.tiU(s.PyW([]))),t8=i.O31(t5).pipe(i.fXn).annotate({default:[],maxItems:ei.maxLayouts}).pipe(i.tiU(s.PyW([]))),t6=i.O31(eR).pipe(i.fXn).annotate({default:[],maxItems:ei.maxZOrderEntries}).pipe(i.tiU(s.PyW([])));class t9 extends i.Xsx("CanvasSpec")({kind:eM("canvas"),version:eN(1),diagramId:ej,title:ej,width:eL.pipe(i.Wa3),height:eL.pipe(i.Wa3),accentColor:eB.pipe(i.Wa3),backgroundColor:eB.pipe(i.Wa3),elements:eT(i.O31(t2).pipe(i.fXn).annotate({maxItems:ei.maxElements})),layers:t3,layouts:t8,zOrder:t6},{identifier:void 0}){}let t4=ek(t9);class t7 extends i.Xsx("CreateCanvasRequest")({requestId:e$(eR),spec:eC(t9),options:e$(tv)},{identifier:void 0}){}let re=ek(t7),rt=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"}));ek(rt);class rr extends i.Xsx("ExcalidrawScene")({appState:i.mSG(i.QfV,i.$r1),elements:i.O31(rt).pipe(i.fXn)},{identifier:void 0}){}ek(rr);class rn extends rr.extend("ExcalidrawFile")({files:i.mSG(i.QfV,i.$r1),source:ej,type:eM("excalidraw"),version:eN(2)},{identifier:void 0}){}let ri=ek(rn);class ra extends i.Xsx("GetArtifactRequest")({artifactId:ej,format:e$(eY),inline:e$(i.v8c)},{identifier:void 0}){}let rs=ek(ra);class ro extends i.Xsx("DiagramSelector")({ids:e$(i.O31(eR).pipe(i.fXn)),nodeIds:e$(i.O31(eR).pipe(i.fXn)),edgeIds:e$(i.O31(eR).pipe(i.fXn)),kinds:e$(i.O31(e0).pipe(i.fXn)),labels:e$(i.O31(eR).pipe(i.fXn)),scope:e$(eA(["all","nodes","edges"]))},{identifier:void 0}){}ek(ro);class rl extends i.Xsx("DiagramStylePatch")({strokeColor:e$(eB),fillColor:e$(eB),textColor:e$(eB),backgroundColor:e$(eB)},{identifier:void 0}){}ek(rl);let rc=["rectangle","diamond","ellipse","circle","polygon"],ru=Object.assign(ek(eA(rc)),{options:rc});class rd extends i.Xsx("SetDefaultStyleOperation")({op:eM("setDefaultStyle"),style:eC(rl)},{identifier:void 0}){}class rf extends i.Xsx("SetStyleOperation")({op:eM("setStyle"),selector:eC(ro),style:eC(rl)},{identifier:void 0}){}class rh extends i.Xsx("SetShapeOperation")({op:eM("setShape"),selector:eC(ro),shape:ru},{identifier:void 0}){}class rp extends i.Xsx("TranslateOperation")({op:eM("translate"),selector:eC(ro),dx:eD,dy:eD},{identifier:void 0}){}class rm extends i.Xsx("ReplaceTextOperation")({op:eM("replaceText"),selector:eC(ro),text:ej},{identifier:void 0}){}class rg extends i.Xsx("RerouteEdgesOperation")({op:eM("rerouteEdges"),selector:e$(ro)},{identifier:void 0}){}let ry=eT(eE(eR));class rb extends i.Xsx("InsertElementsOperation")({op:eM("insert"),elements:eT(eE(t2)),beforeId:e$(eR),afterId:e$(eR)},{identifier:void 0}){}class rv extends i.Xsx("RemoveElementsOperation")({op:eM("remove"),selector:eC(ro)},{identifier:void 0}){}class rw extends i.Xsx("ReplaceElementOperation")({op:eM("replace"),id:ej,element:eC(t2)},{identifier:void 0}){}class rx extends i.Xsx("ReorderElementsOperation")({op:eM("reorder"),ids:ry,beforeId:e$(eR),afterId:e$(eR)},{identifier:void 0}){}class r_ extends i.Xsx("GroupElementsOperation")({op:eM("group"),ids:ry,groupId:ej},{identifier:void 0}){}class rk extends i.Xsx("UngroupElementsOperation")({op:eM("ungroup"),ids:ry,groupId:e$(eR)},{identifier:void 0}){}let rS=i.gPz([rd,rf,rh,rp,rm,rg,rb,rv,rw,rx,r_,rk],{mode:"oneOf"}).annotate({message:`Invalid discriminator value. Expected ${e1.map(e=>`'${e}'`).join(" | ")}`});class rI extends i.Xsx("ArtifactPatchSource")({artifactId:ej,format:e$(eM("scene"))},{identifier:void 0}){}class rE extends i.Xsx("InlineScenePatchSource")({scene:eC(t9)},{identifier:void 0}){}let r$=i.gPz([rI,rE]).annotate({message:"Invalid input"});class rO extends i.Xsx("ApplyDiagramPatchOptions")({artifactFormats:tg,inlineArtifacts:ty,preserveConnectivity:e$(i.v8c)},{identifier:void 0}){}ek(e$(rO));class rC extends i.Xsx("ApplyDiagramPatchRequest")({requestId:e$(eR),source:r$.annotateKey({messageMissingKey:"Invalid input"}),operations:eT(eE(rS)).pipe(i.rvE({minItems:1})),options:e$(rO),intent:e$(eR)},{identifier:void 0}){}let rT=ek(rC),rA=i._kM({id:eR,title:eR,nodes:i.O31(e2).pipe(i.fXn),edges:i.O31(e5.mapFields(e=>({...e,id:eR}))).pipe(i.fXn),layout:i._kM({direction:e3}),style:i._kM({accentColor:eB,backgroundColor:eB})}),rM=i._kM({id:eR,label:eR,children:i.O31(i.DYE(()=>rM)).pipe(i.fXn)}),rN=i._kM({id:eR,title:eR,root:rM,layout:i._kM({direction:eA(["LR","RL"])}),style:i._kM({accentColor:eB,backgroundColor:eB})}),rP=i._kM({id:eR,title:eR,participants:i.O31(tc).pipe(i.fXn),messages:i.O31(tu.mapFields(e=>({...e,id:eR}))).pipe(i.fXn),style:i._kM({accentColor:eB,backgroundColor:eB})}),rR=i._kM({code:i.QfV,passed:i.v8c,severity:eA(["error","warning"]),message:i.QfV,refs:i.O31(eH).pipe(i.fXn)}),rj=i._kM({accepted:i.v8c,score:i.wNn,threshold:i.wNn,summary:i._kM({nodeCount:i.wNn,edgeCount:i.wNn}),checks:i.O31(rR).pipe(i.fXn)}),rD=i._kM({format:eY,mimeType:i.QfV,url:e$(i.QfV),expiresAt:e$(i.QfV),inline:e$(i.$r1),sizeBytes:e$(i.wNn)}),rL=i._kM({artifactId:i.QfV,diagramId:i.QfV,formats:i.O31(rD).pipe(i.fXn),provenance:e$(eX),preview:e$(rD)}),rU=i._kM({artifactId:e$(i.QfV),diagramId:e$(i.QfV),formats:e$(i.O31(rD).pipe(i.fXn))});class rF extends i.Xsx("BuildFlowchartAccepted")({ok:eP(!0),status:eM("accepted"),buildId:i.QfV,requestId:e$(i.QfV),normalizedSpec:rA,quality:rj,artifact:rL,issues:i.O31(eQ).pipe(i.fXn)},{identifier:void 0}){}class rB extends i.Xsx("BuildFlowchartRejected")({ok:eP(!1),status:eA(["invalid_input","invalid_flowchart","quality_failed","render_failed","export_failed","storage_failed"]),buildId:e$(i.QfV),requestId:e$(i.QfV),normalizedSpec:e$(rA),quality:e$(rj),partial:e$(rU),issues:i.O31(eQ).pipe(i.fXn)},{identifier:void 0}){}i.gPz([rF,rB]);class rW extends i.Xsx("BuildMindmapAccepted")({ok:eP(!0),status:eM("accepted"),buildId:i.QfV,requestId:e$(i.QfV),normalizedSpec:rN,quality:rj,artifact:rL,issues:i.O31(eQ).pipe(i.fXn)},{identifier:void 0}){}class rq extends i.Xsx("BuildMindmapRejected")({ok:eP(!1),status:eA(["invalid_input","invalid_mindmap","quality_failed","render_failed","export_failed","storage_failed"]),buildId:e$(i.QfV),requestId:e$(i.QfV),normalizedSpec:e$(rN),quality:e$(rj),partial:e$(rU),issues:i.O31(eQ).pipe(i.fXn)},{identifier:void 0}){}i.gPz([rW,rq]);class rY extends i.Xsx("BuildSequenceDiagramAccepted")({ok:eP(!0),status:eM("accepted"),buildId:i.QfV,requestId:e$(i.QfV),normalizedSpec:rP,quality:rj,artifact:rL,issues:i.O31(eQ).pipe(i.fXn)},{identifier:void 0}){}class rz extends i.Xsx("BuildSequenceDiagramRejected")({ok:eP(!1),status:eA(["invalid_input","invalid_sequence","quality_failed","render_failed","export_failed","storage_failed"]),buildId:e$(i.QfV),requestId:e$(i.QfV),normalizedSpec:e$(rP),quality:e$(rj),partial:e$(rU),issues:i.O31(eQ).pipe(i.fXn)},{identifier:void 0}){}i.gPz([rY,rz]);class rX extends i.Xsx("GetArtifactAccepted")({ok:eP(!0),artifactId:i.QfV,diagramId:i.QfV,format:eY,mimeType:i.QfV,url:e$(i.QfV),expiresAt:e$(i.QfV),inline:e$(i.$r1),sizeBytes:e$(i.wNn),provenance:e$(eX)},{identifier:void 0}){}class rJ extends i.Xsx("GetArtifactRejected")({ok:eP(!1),status:eA(["invalid_input","not_found","format_unavailable","expired","storage_failed"]),issues:i.O31(eQ).pipe(i.fXn)},{identifier:void 0}){}i.gPz([rX,rJ]);class rG extends i.Xsx("ApplyDiagramPatchAccepted")({ok:eP(!0),status:eM("accepted"),patchId:i.QfV,requestId:e$(i.QfV),sourceArtifactId:e$(i.QfV),artifact:rL,issues:i.O31(eQ).pipe(i.fXn)},{identifier:void 0}){}class rV extends i.Xsx("ApplyDiagramPatchRejected")({ok:eP(!1),status:eA(["invalid_input","source_unavailable","target_not_found","unsupported_operation","connectivity_changed","render_failed","export_failed","storage_failed"]),patchId:e$(i.QfV),requestId:e$(i.QfV),sourceArtifactId:e$(i.QfV),partial:e$(rU),issues:i.O31(eQ).pipe(i.fXn)},{identifier:void 0}){}i.gPz([rG,rV]);class rK extends i.Xsx("CreateCanvasAccepted")({ok:eP(!0),status:eM("accepted"),buildId:i.QfV,requestId:e$(i.QfV),normalizedSpec:t9,artifact:rL,issues:i.O31(eQ).pipe(i.fXn)},{identifier:void 0}){}class rH extends i.Xsx("CreateCanvasRejected")({ok:eP(!1),status:eA(["invalid_input","invalid_canvas","limit_exceeded","render_failed","export_failed","storage_failed"]),buildId:e$(i.QfV),requestId:e$(i.QfV),normalizedSpec:e$(t9),partial:e$(rU),issues:i.O31(eQ).pipe(i.fXn)},{identifier:void 0}){}let rQ=i.gPz([rK,rH]),rZ=i.xCb(["read","readManifest","write"]);class r0 extends i.X0d()("CodeModeArtifactStorageError",{cause:i.kld(),message:i.QfV,operation:rZ}){}class r1 extends a.kl()("@sketchi/diagram-agent/CodeModeArtifactStorage"){}let r2={excalidraw:"application/vnd.excalidraw+json",png:"image/png",scene:"application/vnd.sketchi.scene+json"};function r5(e){return"excalidraw"===e||"scene"===e}function r3(e){return{format:e.format,mimeType:e.mimeType,sizeBytes:e.sizeBytes}}function r8(e){return structuredClone(e)}function r6(e){return new TextEncoder().encode(JSON.stringify(e)).length}function r9(e){return t=>{var r;return r0.make({cause:t,message:(r="write"===e?"Artifact storage failed.":"Artifact read failed.",t instanceof Error?t.message:r),operation:e})}}let r4=l.QZ(r1)(s.Q56(s.OH5(function(){let e=new Map,t=new Map;return{close:s.OH5(()=>{t.clear(),e.clear()}),storage:{read:s.fn("codeMode.artifacts.memory.read")(function*(e,r){return yield*s.SvU({try:()=>{let n=t.get(`${e}:${r}`);return n?{...n,data:r8(n.data)}:null},catch:r9("read")})}),readManifest:s.fn("codeMode.artifacts.memory.readManifest")(function*(t){return yield*s.SvU({try:()=>{let r=e.get(t);return r?r8(r):null},catch:r9("readManifest")})}),write:s.fn("codeMode.artifacts.memory.write")(function*(r){let n=yield*o.Ru;return yield*s.SvU({try:()=>{var i;let a,s=r.formats.map(r3),o=r.provenance?r8(r.provenance):void 0,l={artifactId:r.artifactId,diagramId:r.diagramId,formats:s,...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:r8(n.data)});let c=r.formats.map(e=>{var t;return t=r.inlineFormats,{format:e.format,mimeType:e.mimeType,...r5(e.format)&&t.includes(e.format)?{inline:e.data}:{},sizeBytes:e.sizeBytes}});return a=(i={artifactId:r.artifactId,diagramId:r.diagramId,formats:c,...r.provenance?{provenance:r8(r.provenance)}:{}}).formats.find(e=>"scene"===e.format),{artifactId:i.artifactId,diagramId:i.diagramId,formats:i.formats,...i.provenance?{provenance:i.provenance}:{},...a?{preview:a}:{}}},catch:r9("write")})})}}}),e=>e.close).pipe(s.TjK(e=>e.storage)));function r7(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."}}function ne(e){return new Map(e.map((e,t)=>[e.id,t]))}function nt(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 nr(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function nn(e,t,r){return Math.min(r,Math.max(t,e))}function ni(e,t,r=0){let n,i=(n="top"===t||"bottom"===t?e.width/2-16:e.height/2-16)>0?nn(r,-n,n):0,a=nr(e),s=e.width/2,o=e.height/2;if("diamond"===e.shape&&s>0&&o>0){if("top"===t||"bottom"===t){let e=a.x+i,r=o*(1-Math.abs(i)/s);return{x:e,y:"top"===t?a.y-r:a.y+r}}let e=a.y+i,r=s*(1-Math.abs(i)/o);return{x:"left"===t?a.x-r:a.x+r,y:e}}if(("ellipse"===e.shape||"circle"===e.shape)&&s>0&&o>0){if("top"===t||"bottom"===t){let e=a.x+i,r=o*Math.sqrt(Math.max(0,1-(i/s)**2));return{x:e,y:"top"===t?a.y-r:a.y+r}}let e=a.y+i,r=s*Math.sqrt(Math.max(0,1-(i/o)**2));return{x:"left"===t?a.x-r:a.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 na(e){return`${e.edgeId}:${e.endpoint}`}function ns(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 no(e,t,r){return e>t+.01&&e<r-.01}function nl(e,t,r,n){return Math.min(t,n)-Math.max(e,r)>.01}function nc(e,t,r){let n=0;for(let i=0;i<e.length-1;i+=1){let a=e[i],s=e[i+1];if(a&&s)for(let e of t)!r.has(e.nodeId)&&(a.y===s.y?no(a.y,e.y,e.y+e.height)&&nl(Math.min(a.x,s.x),Math.max(a.x,s.x),e.x,e.x+e.width):a.x===s.x&&no(a.x,e.x,e.x+e.width)&&nl(Math.min(a.y,s.y),Math.max(a.y,s.y),e.y,e.y+e.height))&&(n+=1)}return n}function nu(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 nd(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 nf(e,t){return Math.min(e.max,t.max)-Math.max(e.min,t.min)}function nh(e,t,r){let n=nd({arrowId:`edge:${r.edge.id}`,points:e,sourceNodeId:r.edge.source,targetNodeId:r.edge.target}),i=t.flatMap(e=>nd({arrowId:e.id,points:e.points,sourceNodeId:e.sourceNodeId,targetNodeId:e.targetNodeId})),a=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>=nf(e,t)||(a+=1);return a}function np(e,t){let r=nd({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>=nf(t,e)||(n+=1)}}return n}function nm(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),a=0;return r.x<t.x?a+=Math.max(0,Math.max(...n)-t.x):r.x>t.x&&(a+=Math.max(0,t.x-Math.min(...n))),r.y<t.y?a+=Math.max(0,Math.max(...i)-t.y):r.y>t.y&&(a+=Math.max(0,t.y-Math.min(...i))),a}function ng(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),a=0;return r.x<t.x?a+=Math.max(0,r.x-Math.min(...n)):r.x>t.x&&(a+=Math.max(0,Math.max(...n)-r.x)),r.y<t.y?a+=Math.max(0,r.y-Math.min(...i)):r.y>t.y&&(a+=Math.max(0,Math.max(...i)-r.y)),a}function ny(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 nb(e,t){let r=e[0],n=e[1],i=e[e.length-1],a=e[e.length-2],s=0;return n&&ny(r,n,t.sourceEdge)&&(s+=1),a&&i&&ny(i,a,t.targetEdge)&&(s+=1),s}function nv(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 nw(e,t,r,n,i){var a;let s,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||nr(e.target).x<nr(e.source).x,p="top"===e.sourceEdge||"top"===e.targetEdge||nr(e.source).y<=nr(e.target).y,m=18*e.index,g=c-56-m,y=u+56+m,b=d-48-m,v=f+48+m,w=e.index%4*18/2,x=Math.min(e.source.x,e.target.x)-56-w,_=Math.max(e.source.x+e.source.width,e.target.x+e.target.width)+56+w,k=Math.min(e.source.y,e.target.y)-48-w,S=Math.max(e.source.y+e.source.height,e.target.y+e.target.height)+48+w,I=h?g:y,E=h?y:g,$=p?b:v,O=p?v:b,C=h?x:_,T=h?_:x,A=p?k:S,M=p?S:k,N=[0,36+e.index%4*18],P=(n,i)=>{let a=i>0?nv(t,e.sourceEdge,i):t,s=i>0?nv(r,e.targetEdge,i):r;return ns([t,a,{x:n,y:a.y},{x:n,y:s.y},s,r])},R=(n,i)=>{let a=i>0?nv(t,e.sourceEdge,i):t,s=i>0?nv(r,e.targetEdge,i):r;return ns([t,a,{x:a.x,y:n},{x:s.x,y:n},s,r])},j=[...N.map(e=>R(A,e)),...N.map(e=>R(M,e)),...N.map(e=>P(C,e)),...N.map(e=>P(T,e)),...N.map(e=>R($,e)),...N.map(e=>R(O,e)),...N.map(e=>P(I,e)),...N.map(e=>P(E,e))],D=[...N.map(e=>P(C,e)),...N.map(e=>P(T,e)),...N.map(e=>R(A,e)),...N.map(e=>R(M,e)),...N.map(e=>P(I,e)),...N.map(e=>P(E,e)),...N.map(e=>R($,e)),...N.map(e=>R(O,e))];return(s=(a=o?j:D)[0])?a.slice(1).reduce((t,r)=>{let a=nc(t,n,l),s=nc(r,n,l);if(s<a)return r;if(a<s)return t;let o=np(t,e),c=np(r,e);if(c<o)return r;if(o<c)return t;let u=nh(t,i,e),d=nh(r,i,e);if(d<u)return r;if(u<d)return t;let f=nb(t,e),h=nb(r,e);if(h>f)return r;if(f>h)return t;let p=nm(t),m=nm(r);if(m<p)return r;if(p<m)return t;let g=ng(t),y=ng(r);return y<g?r:g<y?t:nu(r)<nu(t)?r:t},s):[{x:0,y:0}]}function nx(e){return e.flatMap(e=>"arrow"===e.type||"line"===e.type?[...e.points]:"text"===e.type?[{x:e.x,y:e.y},{x:e.x+(e.maxWidth??e.text.length),y:e.y+e.fontSize}]:[{x:e.x,y:e.y},{x:e.x+e.width,y:e.y+e.height}])}function n_(e,t,r){return{x:e.x+t,y:e.y+r}}function nk(e){var t;let r,n,i,a,s,o=R(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,a;return[e.id,(a=(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(...a.map(e=>e.length))*.62+36),height:Math.ceil(14*a.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 a(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||a(t.target)}n.set(e,"visited")}let s=e.nodes.find(e=>0===(t.get(e.id)??[]).length)??e.nodes[0];for(let t of(s&&a(s.id),e.nodes))n.has(t.id)||a(t.id);return i}(e,n.incoming,n.outgoing),a=function(e,t,r){let n=ne(e.nodes),i=new Map(e.nodes.map(e=>[e.id,0])),a=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 s=[];for(let t of e.nodes)(i.get(t.id)??0)===0&&s.push(t.id);let o=new Set;for(let e=0;e<s.length;e+=1){let l=s[e];if(!l||o.has(l))continue;o.add(l);let c=a.get(l)??0;for(let e of t.outgoing.get(l)??[]){if(r.has(e.id))continue;a.set(e.target,Math.max(a.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)}(s,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=>a.get(e.source)??0);a.set(n.id,e.length>0?Math.max(...e)+1:0)}return a}(e,n,i),s=Array.from((function(e,t,r,n,i){let a=ne(e.nodes),s=new Map;for(let n of e.nodes){let e=r.get(n.id)??0,i=t.get(n.id);i&&s.set(e,[...s.get(e)??[],i])}for(let e=0;e<4;e+=1)for(let e of Array.from(s.keys()).sort((e,t)=>e-t)){let t=s.get(e);if(!t||t.length<2)continue;let r=new Map;(s.get(e-1)??[]).forEach((e,t)=>{r.set(e.nodeId,t)});let o=new Map;(s.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?a.get(e.nodeId)??Number.MAX_SAFE_INTEGER:t.reduce((e,t)=>e+t,0)/t.length};s.set(e,[...t].sort((e,t)=>{let r=l(e)-l(t);return Math.abs(r)>.001?r:(a.get(e.nodeId)??Number.MAX_SAFE_INTEGER)-(a.get(t.nodeId)??Number.MAX_SAFE_INTEGER)}))}return s})(e,r,a,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(...s.map(e=>e.breadth)),l=48,c=[];for(let e of s){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),a=r.get(e.target);if(!i||!a)throw Error(`Cannot render edge "${e.id}" with unresolved nodes.`);let{sourceEdge:s,targetEdge:o}=function(e,t,r){let n=nr(e),i=nr(t),a=i.x-n.x,s=i.y-n.y,o=e.kind?.toLowerCase();if("LR"===r||"RL"===r)return a>=0?{sourceEdge:"right",targetEdge:"left"}:{sourceEdge:"left",targetEdge:"right"};if(s<0)return!(Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)>.01)&&Math.abs(a)>Math.abs(s)?{sourceEdge:a>0?"right":"left",targetEdge:"bottom"}:{sourceEdge:"top",targetEdge:"bottom"};let l="decision"===o&&s>e.height+96;return"decision"===o&&s>0&&(0!==a||l)?{sourceEdge:a<0?"left":"right",targetEdge:"top"}:s>0?{sourceEdge:"bottom",targetEdge:"top"}:Math.abs(a)>Math.abs(s)?a>0?{sourceEdge:"right",targetEdge:"left"}:{sourceEdge:"left",targetEdge:"right"}:s>0?{sourceEdge:"bottom",targetEdge:"top"}:{sourceEdge:"top",targetEdge:"bottom"}}(i,a,n);return{edge:e,index:t,source:i,sourceEdge:s,target:a,targetEdge:o}})(e,t,c,o.layout.direction)),d=function(e){let t=new Map;for(let s of e){var r,n,i,a;let e=(r=s.source.nodeId,n=s.sourceEdge,`${r}:${n}`),o=(i=s.target.nodeId,a=s.targetEdge,`${i}:${a}`);t.set(e,[...t.get(e)??[],{edgeId:s.edge.id,endpoint:"source"}]),t.set(o,[...t.get(o)??[],{edgeId:s.edge.id,endpoint:"target"}])}let s=new Map;for(let e of t.values())e.forEach((t,r)=>{s.set(na(t),(r-(e.length-1)/2)*18)});return s}(u),f=[];for(let e of u)f.push(function(e,t,r,n,i,a){let{edge:s,source:o,sourceEdge:l,target:c,targetEdge:u}=e,d=ni(o,l,r.get(na({edgeId:s.id,endpoint:"source"}))??0),f=ni(c,u,r.get(na({edgeId:s.id,endpoint:"target"}))??0),h=ns([d,f]);if(function(e,t,r){let n=nr(e),i=nr(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,a))h=nw(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,a=(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)?nn(t+g,r,n):t),s="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=ns([d,s,{x:s.x,y:a},{x:o.x,y:a},o,f])}return"orthogonal"===t&&(nc(h,n,new Set([o.nodeId,c.nodeId]))>0||np(h,e)>0||nh(h,i,e)>0)&&(h=nw(e,d,f,n,i)),{type:"arrow",id:`edge:${s.id}`,edgeId:s.id,sourceNodeId:s.source,targetNodeId:s.target,points:h,...s.label?{label:s.label}:{}}}(e,o.layout.edgeRouting,d,l,f,o.layout.direction));let h=l.map(nt),p=(i=Math.max(0,48-(n={x:Math.min(...(r=nx(t=[...f,...l,...h])).map(e=>e.x)),y:Math.min(...r.map(e=>e.y))}).x),a=Math.max(0,48-n.y),0===i&&0===a?[...t]:t.map(e=>"arrow"===e.type?{...e,points:function(e,t,r){let[n,...i]=e;return[n_(n,t,r),...i.map(e=>n_(e,t,r))]}(e.points,i,a)}:"line"===e.type?{...e,points:function(e,t,r){let[n,i,...a]=e;return[n_(n,t,r),n_(i,t,r),...a.map(e=>n_(e,t,r))]}(e.points,i,a)}:{...e,x:e.x+i,y:e.y+a})),m={width:Math.max(...(s=nx(p)).map(e=>e.x))+48,height:Math.max(...s.map(e=>e.y))+48},g=[...l.map(e=>e.id),...h.map(e=>e.id),...f.map(e=>e.id)];return{kind:"canvas",version:1,diagramId:o.id,title:o.title,width:m.width,height:m.height,accentColor:o.style.accentColor,backgroundColor:o.style.backgroundColor,elements:p,layers:[],layouts:[],zOrder:g}}let nS="sequence-lifeline";function nI(e){return`${e}:lifeline`}var nE=r(1580);let n$=new Set(["rectangle","ellipse","diamond"]),nO=y.ink;function nC(e){return"number"==typeof e&&Number.isFinite(e)?e:null}function nT(e){if(!Array.isArray(e)||e.length<2)return null;let t=nC(e[0]),r=nC(e[1]);return null===t||null===r?null:[t,r]}function nA(e){let t=nC(e.x),r=nC(e.y),n=nC(e.width),i=nC(e.height);return null===t||null===r||null===n||null===i?null:{x:t,y:r,width:n,height:i}}function nM(e){return 1e-4>Math.abs(e-.5)?.5001:e}function nN(e,t){let r=nA(e);return r&&0!==r.width&&0!==r.height?[nM((t.x-r.x)/r.width),nM((t.y-r.y)/r.height)]:null}function nP(e,t){return{elementId:e?.id??"",focus:0,gap:0,fixedPoint:e?nN(e,t):null}}function nR(e,t,r){let n=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:r&&"fillStyle"in r?r.fillStyle??"solid":"solid",frameId:r?.frameId??null,groupIds:[...r?.groupIds??[]],index:t,isDeleted:!1,link:null,locked:r?.locked??!1,opacity:r?.opacity??100,roughness:r&&"roughness"in r?r.roughness??1:1,seed:n,strokeStyle:r&&"strokeStyle"in r?r.strokeStyle??"solid":"solid",strokeWidth:r&&"strokeWidth"in r?r.strokeWidth??2:2,updated:1,version:1,versionNonce:n+1}}function nj(e,t){return Math.ceil(e.split("\n").length*t*1.35)}function nD(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=nj(e.text,e.fontSize);return{...nR(e.id,e.index,e.element),...void 0===e.locked?{}:{locked:e.locked},type:"text",x:e.x-n/2,y:e.y-i/2,width:n,height:i,backgroundColor:"transparent",boundElements:null,containerId:e.containerId??null,fontFamily:e.element?.fontFamily==="mono"?3:e.element?.fontFamily==="sans"?2:5,fontSize:e.fontSize,lineHeight:1.35,originalText:e.text,roundness:null,strokeColor:e.textColor??nO,text:e.text,textAlign:e.element?.textAlign??"center",verticalAlign:e.element?.verticalAlign??"middle",autoResize:!0}}function nL(e){return e.points[e.points.length-1]??e.points[0]}function nU(e,t,r){if(!e)return null;let n=t.get(e.elementId);return n?{elementId:e.elementId,focus:e.focus??0,gap:e.gap??0,fixedPoint:nN(n,r)}:null}function nF(e){return"node"===e.type}function nB(e){return"text"===e.type}function nW(e){return"arrow"===e.type}function nq(e){return"line"===e.type}function nY(e){return"frame"===e.type}function nz(e){var t;let r,n,i,a,s,o,l,c=(r=new Map(e.layers.map(e=>[e.id,e])),i=new Set((n=e.elements.filter(e=>{let t=e.layerId?r.get(e.layerId):void 0;return t?.visible!==!1})).flatMap(e=>"node"===e.type?[e.nodeId]:[])),s=new Set((a=n.filter(e=>"arrow"!==e.type||i.has(e.sourceNodeId)&&i.has(e.targetNodeId))).flatMap(e=>"text"===e.type?[]:[e.id])),l=new Set((o=a.filter(e=>"text"!==e.type||!e.containerId||s.has(e.containerId))).map(e=>e.id)),o.map(e=>{let t=e.layerId?r.get(e.layerId):void 0;return{...e,...e.frameId&&!l.has(e.frameId)?{frameId:void 0}:{},...t?.locked===!0?{locked:!0}:{}}})),u=c.filter(nF),d=c.filter(nB),f=new Set(c.map(e=>e.id)),h=new Map,p=new Set(d.flatMap(e=>e.containerId?[e.containerId]:[]));for(let e of u){if(p.has(e.id)||e.rendererRole===nS)continue;let t=`__sketchi_node_label__${e.id}`,r=t,n=2;for(;f.has(r);)r=`${t}:${n}`,n+=1;f.add(r),h.set(r,e.id),d.push({type:"text",id:r,containerId:e.id,...e.frameId?{frameId:e.frameId}:{},...e.groupIds?{groupIds:[...e.groupIds]}:{},...e.layerId?{layerId:e.layerId}:{},...void 0!==e.locked?{locked:e.locked}:{},...void 0!==e.opacity?{opacity:e.opacity}:{},...e.textColor?{textColor:e.textColor}:{},x:e.x+e.width/2,y:e.y+e.height/2,text:e.label,fontSize:16,maxWidth:Math.max(1,e.width-24)})}let m=new Map(d.map(e=>[e.containerId??"",e])),g=c.filter(nW),y=c.filter(nq),b=function(e,t,r){let n=new Map,i=new Map(e.map(e=>[e.nodeId,e.id]));for(let e of t)for(let t of[e.sourceNodeId,e.targetNodeId]){let r=i.get(t);r&&n.set(r,[...n.get(r)??[],e.id])}for(let e of r)for(let t of[e.startBinding,e.endBinding])t&&n.set(t.elementId,[...n.get(t.elementId)??[],e.id]);return n}(u,g,y),v=new Map,w=[],x=null,_=()=>{let e=(0,nE.TU)(x,null);return x=e,e};for(let t of u){let r=m.get(t.id),n=function(e){let t=e.text?nj(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&&"polygon"!==e.shape.shape?[{id:e.text.id,type:"text"}]:[],...e.arrowIds.map(e=>({id:e,type:"arrow"}))];if("polygon"===e.shape.shape){let t=e.shape.points??[{x:e.shape.width/2,y:0},{x:e.shape.width,y:e.shape.height},{x:0,y:e.shape.height}],[r,...n]=t;return{...nR(e.shape.id,e.index,e.shape),type:"line",x:e.shape.x,y:e.shape.y,width:e.shape.width,height:e.shape.height,backgroundColor:e.shape.fillColor??"transparent",boundElements:e.arrowIds.map(e=>({id:e,type:"arrow"})),customData:{sketchiShape:"polygon"},endArrowhead:null,endBinding:null,lastCommittedPoint:null,points:[...t,r].map(e=>[e.x,e.y]),roundness:null,startArrowhead:null,startBinding:null,strokeColor:e.shape.strokeColor??e.scene.accentColor}}return{...nR(e.shape.id,e.index,e.shape),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,...e.shape.rendererRole===nS?{customData:{sketchiRendererRole:nS}}:{}}}({scene:e,shape:t,arrowIds:b.get(t.id)??[],index:_(),...r?{text:r}:{}});v.set(t.nodeId,n),w.push(n)}for(let r of c.filter(nY)){let n={...nR((t={element:r,index:_(),scene:e}).element.id,t.index,t.element),type:"frame",x:t.element.x,y:t.element.y,width:t.element.width,height:t.element.height,backgroundColor:t.element.fillColor??"transparent",boundElements:null,name:t.element.name??null,roundness:null,strokeColor:t.element.strokeColor??t.scene.accentColor},i=b.get(r.id)??[];n.boundElements=i.length?i.map(e=>({id:e,type:"arrow"})):null,w.push(n)}for(let e of d){let t=e.containerId&&(u.some(t=>t.id===e.containerId&&"polygon"!==t.shape)||g.some(t=>t.id===e.containerId));w.push(nD({element:e,id:e.id,index:_(),...t?{containerId:e.containerId}:{},fontSize:e.fontSize,maxWidth:e.maxWidth??160,...e.textColor?{textColor:e.textColor}:{},text:e.text,x:e.x,y:e.y}))}for(let t of g){let r=m.get(t.id);w.push(function(e){let t=e.arrow.points[0],r=nL(e.arrow),n=e.arrow.points.length>2;return{...nR(e.arrow.id,e.index,e.arrow),type:"arrow",x:t.x,y:t.y,width:r.x-t.x,height:r.y-t.y,backgroundColor:"transparent",boundElements:e.text?[{id:e.text.id,type:"text"}]:e.arrow.label?[{id:`${e.arrow.id}:label`,type:"text"}]:null,elbowed:n,endArrowhead:void 0===e.arrow.endArrowhead?"arrow":e.arrow.endArrowhead,endBinding:nP(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:e.arrow.startArrowhead??null,startBinding:nP(e.sourceShape,t),strokeColor:e.arrow.strokeColor??e.scene.accentColor,strokeStyle:e.arrow.strokeStyle??"solid"}}({arrow:t,scene:e,index:_(),sourceShape:v.get(t.sourceNodeId),targetShape:v.get(t.targetNodeId),...r?{text:r}:{}}));let n=t.label&&!r?function(e){if(!e.arrow.label)return null;let t=e.arrow.points[0],r=nL(e.arrow);return nD({id:`${e.arrow.id}:label`,index:e.index,containerId:e.arrow.id,fontSize:13,...void 0===e.arrow.locked?{}:{locked:e.arrow.locked},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:_()}):null;n&&w.push(n)}let k=new Map(w.map(e=>[e.id,e]));for(let t of y)if(w.push(function(e){let[t,...r]=e.element.points,n=r[r.length-1]??t,i=void 0!==e.element.startArrowhead||void 0!==e.element.endArrowhead||void 0!==e.element.startBinding||void 0!==e.element.endBinding,a=i&&e.element.points.length>2;return{...nR(e.element.id,e.index,e.element),type:i?"arrow":"line",x:t.x,y:t.y,width:n.x-t.x,height:n.y-t.y,backgroundColor:e.element.fillColor??"transparent",boundElements:null,...i?{elbowed:a}:{},endArrowhead:e.element.endArrowhead??null,endBinding:nU(e.element.endBinding,e.elementsById,n),...a?{fixedSegments:[],startIsSpecial:null,endIsSpecial:null}:{},points:e.element.points.map(e=>[e.x-t.x,e.y-t.y]),roundness:e.element.points.length>2&&!a?{type:2}:null,startArrowhead:e.element.startArrowhead??null,startBinding:nU(e.element.startBinding,e.elementsById,t),strokeColor:e.element.strokeColor??e.scene.accentColor}}({element:t,elementsById:k,index:_(),scene:e})),t.label){let e=t.points[0],r=t.points[t.points.length-1]??e;w.push(nD({id:`${t.id}:label`,index:_(),fontSize:13,...void 0===t.locked?{}:{locked:t.locked},maxWidth:160,...t.textColor?{textColor:t.textColor}:{},text:t.label,x:(e.x+r.x)/2,y:(e.y+r.y)/2-10}))}let S=new Map(e.zOrder.map((e,t)=>[e,t])),I=e=>{if(S.has(e.id))return e.id;let t=h.get(e.id);return t||(e.id.endsWith(":label")?e.id.slice(0,-6):e.id)};for(let e of(w.sort((e,t)=>(S.get(I(e))??Number.MAX_SAFE_INTEGER)-(S.get(I(t))??Number.MAX_SAFE_INTEGER)),x=null,w))e.index=_();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:w}}function nX(e,t){let r=e[t];if(!(r&&"object"==typeof r))return null;let n=r.elementId;return"string"==typeof n?n:null}function nJ(e){return nT(e)}function nG(e){let t=nC(e.x)??0,r=nC(e.y)??0,n=nX(e,"startBinding"),i=nX(e,"endBinding"),a=Array.isArray(e.points)?e.points.map(nJ).filter(e=>!!e):[],s=[];for(let o=0;o<a.length-1;o+=1){let l=a[o],c=a[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)){s.push({arrowId:e.id,endBindingElementId:i,isLastSegment:o===a.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)&&s.push({arrowId:e.id,endBindingElementId:i,isLastSegment:o===a.length-2,max:Math.max(m,y),min:Math.min(m,y),orientation:"vertical",segmentIndex:o,startBindingElementId:n,staticCoordinate:p})}return s.filter(e=>e.max-e.min>.001)}function nV(e,t,r){return e>t+.01&&e<r-.01}function nK(e,t,r,n){return Math.min(t,n)-Math.max(e,r)>.01}function nH(e){if(n$.has(e.type)||"frame"===e.type)return!0;let t=e.customData;return"line"===e.type&&null!==t&&"object"==typeof t&&"polygon"===t.sketchiShape}function nQ(e,t,r){return e>=t-.01&&e<=r+.01}function nZ(e,t){return .01>=Math.abs(e-t)}function n0(e){let t=[],r=new Map(e.elements.map(e=>[e.id,e])),n=new Set(e.elements.filter(nH).map(e=>e.id));for(let i of(0===e.elements.length&&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 a 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"])){if(null===i[a]||void 0===i[a])continue;let s=nX(i,a);if(!(s&&n.has(s))){t.push({code:"missing-arrow-binding",elementId:i.id,message:`Arrow "${i.id}" has invalid ${a}.`});continue}let o=r.get(s);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=nC(e.x)??0,n=nC(e.y)??0,i=Array.isArray(e.points)?e.points.map(nJ).filter(e=>!!e):[],a="startBinding"===t?i[0]:i[i.length-1];return a?{x:r+a[0],y:n+a[1]}:null}(i,a);if(o&&l&&!function(e,t){let r=nA(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,a=r.y+n;return nZ(Math.abs(e.x-i)/t+Math.abs(e.y-a)/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,a=r.y+n;return nZ(((e.x-i)/t)**2+((e.y-a)/n)**2,1)}let n=(nZ(e.x,r.x)||nZ(e.x,r.x+r.width))&&nQ(e.y,r.y,r.y+r.height),i=(nZ(e.y,r.y)||nZ(e.y,r.y+r.height))&&nQ(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}" ${a} endpoint does not land on "${o.id}".`}),o&&l&&e){let e=function(e,t){let r=e[t];return r&&"object"==typeof r?nT(r.fixedPoint):null}(i,a);e&&function(e,t,r){let n=nA(r);if(!n)return!1;let i=1e-4>Math.abs(e[0]-.5001)?.5:e[0],a=1e-4>Math.abs(e[1]-.5001)?.5:e[1];return nZ(n.x+i*n.width,t.x)&&nZ(n.y+a*n.height,t.y)}(e,l,o)||t.push({code:"invalid-elbow-binding",elementId:i.id,message:`Elbow arrow "${i.id}" has invalid ${a} 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 a="number"==typeof i.width?i.width:0,s="number"==typeof i.height?i.height:0,o="number"==typeof n.width?n.width:0,l="number"==typeof n.height?n.height:0;nH(n)&&(a+24>o||s+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(nG),r=e.filter(nH),n=[],i=new Set;for(let e of t)for(let t of r){if(function(e){let t=e.customData;return null!==t&&"object"==typeof t&&t.sketchiRendererRole===nS}(t)||t.id===e.startBindingElementId||t.id===e.endBindingElementId)continue;let r=nA(t);if(!r||("horizontal"===e.orientation?!(nV(e.staticCoordinate,r.y,r.y+r.height)&&nK(e.min,e.max,r.x,r.x+r.width)):!(nV(e.staticCoordinate,r.x,r.x+r.width)&&nK(e.min,e.max,r.y,r.y+r.height))))continue;let a=`${e.arrowId}:${e.segmentIndex}:${t.id}`;i.has(a)||(i.add(a),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(nG),r=[],n=new Set;for(let e=0;e<t.length;e+=1){let i=t[e];if(i)for(let a=e+1;a<t.length;a+=1){let e=t[a];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 s=[i.arrowId,i.segmentIndex,e.arrowId,e.segmentIndex].sort().join(":");n.has(s)||(n.add(s),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}}var n1=r(8927);r(2302);var n2=r(4650),n5=r(1136),n3=r(9354),n8=r(6364),n6=r(9138),n9=r(5369);let n4=a.Or("effect/Metric/CurrentMetricAttributes",{defaultValue:()=>({})}),n7=a.Or("~effect/observability/Metric/MetricRegistryKey",{defaultValue:()=>new Map}),ie="~effect/observability/Metric";class it{[ie]=ie;#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=a.Jt(e,n4);if(0===Object.keys(t).length)return n9.EA(this.#t)||(this.#t=this.getOrCreate(e,this.attributes)),this.#t.hooks;let r=iu(this.attributes,t),n=this.#e.get(r);return n9.EA(n)||(n=this.getOrCreate(e,r),this.#e.set(r,n)),n.hooks}getOrCreate(e,t){var r,n,i;let s,o=(r=this,n=t,s=`${r.type}:${r.id}`,n9.EA(r.description)&&(s+=`:${r.description}`),n9.EA(n)&&(s+=`:${(Array.isArray(i=n)?i:Object.entries(i)).map(([e,t])=>`${e}=${t}`).join(",")}`),s),l=a.Jt(e,n7);if(l.has(o))return l.get(o);let c=this.createHooks(),u={id:this.id,type:this.type,description:this.description,attributes:id(t),hooks:c};return l.set(o,u),u}pipe(){return(0,n6.tT)(this,arguments)}}let ir=BigInt(0);class ii extends it{type="Counter";#r;#n;constructor(e,t){super(e,t?.description,id(t?.attributes)),this.#r=t?.bigint??!1,this.#n=t?.incremental??!1}createHooks(){let e=this.#r?ir:0,t=this.#n?this.#r?e=>e>=ir:e=>e>=0:e=>!0;return ic(()=>({count:e,incremental:this.#n}),r=>{t(r)&&(e+=r)})}}class ia extends it{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 is=(e,t)=>new ii(e,t),io=(0,n2.XY)(2,(e,t)=>n5.sxi(r=>n5.OH5(()=>e.updateUnsafe(t,r)))),il=(0,n2.XY)(2,(e,t)=>new ia(e,r=>e.valueUnsafe(ih(r,t)),(r,n)=>e.updateUnsafe(r,ih(n,t)),(r,n)=>e.modifyUnsafe(r,ih(n,t))));function ic(e,t,r){return{get:e,update:t,modify:r??t}}function iu(e,t){return{...id(e),...id(t)}}function id(e){return n9.EA(e)&&Array.isArray(e)?e.reduce((e,[t,r])=>(e[t]=r,e),{}):e}function ih(e,t){let r=iu(a.Jt(e,n4),t);return a.WQ(e,n4,r)}n3.F,n3.F,n2.MN,r(7598),r(8543);var ip=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 im={metric:()=>void 0},ig=a.Or("@sketchi/observability/TelemetryExporter",{defaultValue:()=>im}),iy=a.Or("@sketchi/observability/TelemetryCorrelation",{defaultValue:()=>({})});function ib(e){let t=e?.trim();if(t&&!(t.length>128)&&/^[A-Za-z0-9][A-Za-z0-9._:-]*$/.test(t))return t}function iv(e){let t=ib(e.artifactId),r=ib(e.attemptId),n=ib(e.projectId),i=ib(e.requestId),a=ib(e.runId),s=ib(e.scenarioId),o=ib(e.traceId);return{...t?{artifactId:t}:{},...r?{attemptId:r}:{},...n?{projectId:n}:{},...i?{requestId:i}:{},...a?{runId:a}:{},...s?{scenarioId:s}:{},...o?{traceId:o}:{}}}function iw(e,t){return s.JkU(function*(){let r=iv({...yield*iy,...iv(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(s.PfK(iy,r),s.Muk(n),s.swY(n))})}a.Or("@sketchi/observability/TelemetryResource",{defaultValue:()=>({serviceName:"sketchi"})});let ix=s.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=ib(n);t&&(r[e]=t)}return r}(r);yield*io(il(e,n),t);let i=yield*ig,a=d.getOrUndefined((yield*s._32.pipe(s.uKv)));yield*s.OH5(()=>i.metric({attributes:n,metric:e.id,metricType:e.type,...a?{spanId:a.spanId,traceId:a.traceId}:{},value:t}))});ip.W1;let i_=/^(node|step|item|box|thing|process|task)\s*\d*$/i,ik=/^(diagram|untitled|flowchart|chart|sketch)$/i;function iS(e){return"decision"===e.kind||e.label.endsWith("?")}function iI(e){if(void 0===e)return;let t=eg(e);return t.length>0?t:void 0}let iE=["excalidraw","scene"],i$=["scene"];y.card,y.accent,y.ink;let iO=is("sketchi_codemode_requests",{description:"Code Mode boundary requests by terminal outcome",incremental:!0}),iC=is("sketchi_codemode_failures",{description:"Code Mode boundary failures by typed status",incremental:!0}),iT=is("sketchi_codemode_artifacts",{description:"Code Mode artifacts accepted at workflow boundaries",incremental:!0}),iA=new class e extends it{type="Histogram";#i;constructor(e,t){super(e,t?.description,id(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,a=0,s=Number.MAX_VALUE,o=5e-324;return n1.Tj(n1.di(e,n8.wN),(e,t)=>{n[t]=e}),ic(()=>({buckets:(()=>{let e=n1.CN(t),i=0;for(let a=0;a<t;a++){let t=n[a];i+=r[a],e[a]=[t,i]}return e})(),count:i,min:s,max:o,sum:a}),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,a+=e,e<s&&(s=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],n1.BC(n1.pb(new Set(n),e=>e>0),1/0))});class iM extends a.kl()("@sketchi/diagram-agent/CodeModeRuntimeEnvironment"){}function iN(e={}){return l.Py(iM,{createId:e.createId??iq,...e.renderer?{renderer:e.renderer}:{},...e.artifactUrl?{artifactUrl:e.artifactUrl}:{}})}function iP(e){return null===e||"object"!=typeof e||Array.isArray(e)?void 0:Object.fromEntries(Object.entries(e))}function iR(e,t,r){let n,i,a,l;return iw(s.JkU(function*(){let t=yield*o.Ru,n=yield*r,i=yield*o.Ru,a=n.ok?"success":"failure",s=n.ok?void 0:n.status??"unknown_failure";yield*ix(iO,1,{...s?{failureCategory:s}:{},operation:e,outcome:a,surface:"code_mode"}),yield*ix(iA,i-t,{...s?{failureCategory:s}:{},operation:e,outcome:a,surface:"code_mode"}),s&&(yield*ix(iC,1,{failureCategory:s,operation:e,surface:"code_mode"}));let l="buildFlowchart"===e?"flowchart":"buildMindmap"===e?"mindmap":"buildSequenceDiagram"===e?"sequence":"createCanvas"===e?"canvas":"applyDiagramPatch"===e?"patch":void 0;return n.ok&&l&&(yield*ix(iT,1,{artifactKind:l,operation:e,surface:"code_mode"})),n}),(n=iP(t),i=iP(n?.source),a="string"==typeof n?.artifactId?n.artifactId:"string"==typeof i?.artifactId?i.artifactId:void 0,l="string"==typeof n?.requestId?n.requestId:void 0,{...a?{artifactId:a}:{},...l?{requestId:l}:{}}))}l.Py(iM,{createId:iq});class ij extends i.X0d()("CodeModeArtifactExportError",{cause:i.kld(),message:i.QfV,optionPath:i.v8c}){}class iD 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 iL 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 iU extends i.X0d()("BuildSequenceDiagramFailure",{message:i.QfV,status:i.xCb(["invalid_input","invalid_sequence","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 iF extends i.X0d()("CreateCanvasFailure",{message:i.QfV,status:i.xCb(["invalid_input","invalid_canvas","limit_exceeded","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 iB 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 iW 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 iq(e){return`${e}_${globalThis.crypto.randomUUID()}`}function iY(e){return{code:e.code,severity:e.severity??"error",stage:e.stage,...e.ref?{ref:e.ref}:{},message:e.message,hint:e.hint}}function iz(e){return 0===e.length?"input":e.map(e=>"number"==typeof e?`[${e}]`:String(e)).join(".")}function iX(e){let t=iz(e.path);return iJ(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 iJ(e){return/^operations\.\[\d+\]\.op$/.test(e)}function iG(e){let t=e.issues.slice(0,20).map(e=>{let t=iz(e.path);return iY({code:iX(e),stage:"input",ref:{kind:"request",path:t},message:e.message,hint:iJ(t)?`Use one of: ${e1.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(iY({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 iV(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)}function iK(e){if(void 0===e)return;let t=eg(e);return t.length>0?t:void 0}function iH(e){return e.checks.map(e=>{var t;return iY({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 iQ(e){return e?.artifactFormats??iE}function iZ(e){return e?.inlineArtifacts??i$}let i0=s.fn("codeMode.artifacts.exportFormats")(function*(e){let t=[];for(let a of e.formats){var r,n,i;let o=yield*(r=e,"scene"===(n=a)?s.PyW(r.scene):"excalidraw"===n?s.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(s.xm_(e=>ij.make({cause:e,message:e instanceof Error?e.message:"Artifact export failed.",optionPath:!1}))):s.fJG(ij.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:a,mimeType:r2[a],data:o,sizeBytes:(i=o)instanceof ArrayBuffer||i instanceof Uint8Array?i.byteLength:r6(i)})}return t});function i1(e){return[iY({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 i2(e){return e.map(e=>iY({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 i5(e){return e.slice(0,20).map(e=>iY({code:function(e){switch(e.code){case"duplicate_element_id":return"duplicate_element_id";case"duplicate_layer_id":return"duplicate_layer_id";case"empty_canvas":case"invalid_geometry":return"invalid_canvas_geometry";case"invalid_binding":return"invalid_canvas_binding";case"invalid_composition":return"invalid_canvas_composition";case"invalid_polygon":return"invalid_polygon";case"limit_exceeded":return"canvas_limit_exceeded";case"missing_z_order_element":case"unknown_z_order_element":return"invalid_z_order";case"unknown_layout_target":return"unknown_layout_target"}}(e),stage:"canvas",ref:e.elementId?{kind:"element",id:e.elementId,path:e.path}:{kind:"diagram",path:e.path},message:e.message,hint:"Repair the referenced CanvasSpec field and call createCanvas again."}))}function i3(e){return i2(e.filter(e=>"overlapping-arrow-segment"!==e.code&&"arrow-segment-through-node"!==e.code))}function i8(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 a=[e,n,...i];t.push({...r,type:"arrow",id:r.id,edgeId:r.edgeId,sourceNodeId:r.sourceNodeId,targetNodeId:r.targetNodeId,...r.strokeColor?{strokeColor:r.strokeColor}:{},...r.strokeStyle?{strokeStyle:r.strokeStyle}:{},...r.textColor?{textColor:r.textColor}:{},points:a,...r.label?{label:r.label}:{}});continue}if("node"===r.type){let n=r.points;if("polygon"===r.shape&&(!n||!n[0]||!n[1]||!n[2]))return null;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}:{},x:r.x,y:r.y,width:r.width,height:r.height,label:r.label,...r.frameId?{frameId:r.frameId}:{},...r.groupIds?{groupIds:[...r.groupIds]}:{},...r.layerId?{layerId:r.layerId}:{},...void 0!==r.locked?{locked:r.locked}:{},...void 0!==r.opacity?{opacity:r.opacity}:{},...void 0!==r.zIndex?{zIndex:r.zIndex}:{},...r.fillStyle?{fillStyle:r.fillStyle}:{},...void 0!==r.roughness?{roughness:r.roughness}:{},...r.strokeStyle?{strokeStyle:r.strokeStyle}:{},...void 0!==r.strokeWidth?{strokeWidth:r.strokeWidth}:{},..."sequence-lifeline"===r.rendererRole&&function(e,t){let r=":lifeline";if(!t.nodeId.endsWith(r)||t.id!==`node:${t.nodeId}`||"rectangle"!==t.shape||2!==t.width||t.height<120)return!1;let n=t.nodeId.slice(0,-r.length);if(0===n.length)return!1;let i=e.elements.find(e=>"node"===e.type&&e.id===`node:${n}`&&e.nodeId===n);return!!i&&.01>=Math.abs(t.x+t.width/2-(i.x+i.width/2))&&t.y>=i.y+i.height-.01}(e,r)?{rendererRole:r.rendererRole}:{rendererRole:void 0},...r.textColor?{textColor:r.textColor}:{},..."polygon"===r.shape&&n?.[0]&&n[1]&&n[2]?{points:[n[0],n[1],n[2],...n.slice(3)]}:{points:void 0}});continue}if("line"===r.type){let e=r.points[0],n=r.points[1];if(!e||!n)return null;t.push({...r,points:[e,n,...r.points.slice(2)]});continue}t.push(structuredClone(r))}return{kind:e.kind,version:e.version,diagramId:e.diagramId,title:e.title,width:e.width,height:e.height,accentColor:e.accentColor,backgroundColor:e.backgroundColor,elements:t,layers:structuredClone(e.layers),layouts:structuredClone(e.layouts),zOrder:[...e.zOrder]}}function i6(e){return structuredClone(e)}function i9(e){return e.elements.flatMap(e=>"arrow"===e.type?[`arrow:${e.id}:${e.sourceNodeId}->${e.targetNodeId}`]:"line"===e.type?[`line:${e.id}:${e.startBinding?.elementId??""}->${e.endBinding?.elementId??""}`]:[]).sort()}function i4(e){return e.elements.filter(e=>"node"===e.type)}function i7(e){return e.elements.filter(e=>"text"===e.type)}function ae(e){return e.elements.filter(e=>"arrow"===e.type)}function at(e,t){if(!e||0===e.length||!t)return!1;let r=t.trim().toLowerCase();return e.some(e=>e.trim().toLowerCase()===r)}function ar(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??[]),a=new Set(t?.nodeIds??[]),s=new Set(t?.edgeIds??[]),o=new Set(t?.kinds??[]),l=i4(e).filter(e=>"edges"!==r&&(!t||!n||i.has(e.id)||a.has(e.nodeId)||!!e.kind&&[...o].some(t=>t===e.kind)||at(t.labels,e.label))),c=ae(e).filter(e=>"nodes"!==r&&(!t||!n||i.has(e.id)||s.has(e.edgeId)||at(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:i7(e).filter(e=>t&&n?i.has(e.id)||!!e.containerId&&u.has(e.containerId)||!!e.containerId&&d.has(e.containerId)||at(t.labels,e.text):"nodes"===r?!!e.containerId&&u.has(e.containerId):"edges"!==r||!!e.containerId&&d.has(e.containerId))}}function an(e){return iY({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 ai(e,t){return i7(e).find(e=>e.containerId===t)}function aa(e,t){let r=new Set(t);for(let t of ae(e))(r.has(t.sourceNodeId)||r.has(t.targetNodeId))&&al(e,t)}function as(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function ao(e,t,r){let n=as(e),i=as(t),a=i.x-n.x,s=i.y-n.y;return Math.abs(a)>Math.abs(s)?a>=0&&r||a<0&&!r?{x:e.x+e.width,y:n.y}:{x:e.x,y:n.y}:s>=0&&r||s<0&&!r?{x:n.x,y:e.y+e.height}:{x:n.x,y:e.y}}function al(e,t){let r,n,i=new Map(i4(e).map(e=>[e.nodeId,e])),a=i.get(t.sourceNodeId),s=i.get(t.targetNodeId);if(!a||!s)return[iY({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=ao(a,s,!0),l=ao(s,a,!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=ai(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),[]}function ac(e){let t=[e.width],r=[e.height];for(let n of i4(e))t.push(n.x+n.width),r.push(n.y+n.height);for(let n of i7(e))t.push(n.x+(n.maxWidth??0)),r.push(n.y+n.fontSize);for(let n of ae(e))for(let e of n.points)t.push(e.x),r.push(e.y);for(let n of e.elements){if("line"===n.type)for(let e of n.points)t.push(e.x),r.push(e.y);"frame"===n.type&&(t.push(n.x+n.width),r.push(n.y+n.height))}e.width=Math.max(...t)+48,e.height=Math.max(...r)+48}function au(e,t,r){if(!t||!r){if(t){let r=e.indexOf(t);return r>=0?r:void 0}if(r){let t=e.indexOf(r);return t>=0?t+1:void 0}return e.length}}function ad(e,t){return[iY({code:"patch_output_invalid",stage:"canvas",ref:{kind:"request",path:"operations"},message:t,hint:`Repair the ${e.op} operation and preserve unique, stable element ids.`})]}let af=s.fn("codeMode.patch.resolveSource")(function*(e){if("scene"in e.source)return{scene:i6(e.source.scene)};let t=yield*r1,r=yield*t.readManifest(e.source.artifactId).pipe(s.xm_(e=>new iW({status:"storage_failed",context:{issues:[r7(e.message,"storage_read_failed")]}})));if(!r||r.artifactId!==e.source.artifactId||!r.formats.some(e=>"scene"===e.format))return yield*new iW({status:"source_unavailable",context:{issues:[iY({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(s.xm_(e=>new iW({status:"storage_failed",context:{issues:[r7(e.message,"storage_read_failed")]}})));if(!n)return yield*new iW({status:"source_unavailable",context:{issues:[iY({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=t4.safeParse(n.data);return i.success?{scene:i6(i.data),sourceArtifactId:e.source.artifactId}:yield*new iW({status:"source_unavailable",context:{issues:[iY({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 ah(e){return e?{requestId:e}:{}}function ap(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 am(e){return{diagramId:e.diagramId,formats:[{format:"scene",mimeType:r2.scene,inline:e,sizeBytes:r6(e)}]}}function ag(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 ay(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 ab(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 av(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.partial?{partial:e.context.partial}:{},issues:e.context.issues}}function aw(e){return{ok:!1,status:e.status,issues:e.issues}}function ax(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 a_(e,t){return r7(e.message,t)}let ak=s.fn("codeMode.buildMindmap.workflow")(function*(e){let t=yield*s.OH5(()=>(function(e){let t=iP(iP(iP(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[iY({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[iY({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=iP(t[n]);i&&r.push({depth:e.depth+1,topic:i})}}}return[]})(e)).pipe(s.fRP("codeMode.buildMindmap.preflight"));if(t.length>0)return yield*new iL({status:"invalid_mindmap",context:{issues:t}});let r=yield*s.OH5(()=>tL.safeParse(e)).pipe(s.fRP("codeMode.buildMindmap.parse"));if(!r.success)return yield*new iL({status:"invalid_input",context:{issues:iG(r.error)}});let n=yield*iM,i=yield*r1,a=r.data,o=yield*s.OH5(()=>n.createId("build")),l=yield*s.OH5(()=>{var e;let t,r;return e=a.spec,t=(e,r)=>({id:`topic-${r.join("-")}`,label:eg(e.label),children:(e.children??[]).map((e,n)=>t(e,[...r,n]))}),r=eg(e.title),{id:iK(e.id)??(iV(r)||"sketchi-mindmap"),title:r,root:t(e.root,[0]),layout:{direction:e.layout.direction},style:{...b}}}).pipe(s.fRP("codeMode.buildMindmap.normalize")),c={buildId:o,...ah(a.requestId),normalizedSpec:l},u=yield*s.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(iY({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(iY({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(iY({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(s.fRP("codeMode.buildMindmap.validate"));if(u.length>0)return yield*new iL({status:"invalid_mindmap",context:{...c,issues:u}});let d=yield*s.SvU({try:()=>{let e,t,r;return e=[],t=[],(r=(n,i,a,s)=>{e.push({id:n.id,label:n.label,kind:0===i?"root":"topic",metadata:{depth:i,siblingIndex:a}}),s&&t.push({id:`branch-${n.id.slice(6)}`,source:s,target:n.id,metadata:{depth:i,siblingIndex:a}}),n.children.forEach((e,t)=>r(e,i+1,t,n.id))})(l.root,0,0),er({id:l.id,title:l.title,type:"mindmap",nodes:e,edges:t,layout:{direction:l.layout.direction,edgeRouting:"curved"},style:{...b}})},catch:e=>new iL({status:"invalid_mindmap",context:{...c,issues:[iY({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(s.fRP("codeMode.buildMindmap.canonicalize")),f=yield*s.OH5(()=>{var e;let t,r;return e=a.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(s.fRP("codeMode.buildMindmap.quality")),h={...c,quality:f};if(!f.accepted)return yield*new iL({status:"quality_failed",context:{...h,issues:iH(f)}});let p=yield*s.SvU({try:()=>nk(d),catch:e=>new iL({status:"render_failed",context:{...h,issues:[iY({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(s.fRP("codeMode.buildMindmap.render")),{excalidraw:m,exportValidation:g}=yield*s.OH5(()=>{let e=nz(p);return{excalidraw:e,exportValidation:n0(e)}}).pipe(s.fRP("codeMode.buildMindmap.exportValidate")),y={...h,partial:am(p)};if(!g.ok)return yield*new iL({status:"export_failed",context:{...y,issues:i2(g.issues)}});let v=yield*i0({formats:iQ(a.options),scene:p,excalidraw:m,renderer:n.renderer}).pipe(s.xm_(e=>new iL({status:"export_failed",context:{...y,issues:i1(e)}}))),w=yield*s.OH5(()=>n.createId("artifact")),x=yield*iw(i.write({artifactId:w,diagramId:p.diagramId,formats:v,inlineFormats:iZ(a.options)}),{artifactId:w,...a.requestId?{requestId:a.requestId}:{}}).pipe(s.xm_(e=>new iL({status:"storage_failed",context:{...h,partial:{diagramId:p.diagramId},issues:[a_(e,"storage_write_failed")]}})));return{ok:!0,status:"accepted",buildId:o,...ah(a.requestId),normalizedSpec:l,quality:f,artifact:ap(x,n.artifactUrl),issues:[]}}),aS=s.fn("codeMode.buildSequenceDiagram.workflow")(function*(e){yield*s.rIH.pipe(s.fRP("codeMode.buildSequenceDiagram.preflight"));let t=yield*s.OH5(()=>tE.safeParse(e)).pipe(s.fRP("codeMode.buildSequenceDiagram.parse"));if(!t.success)return yield*new iU({status:"invalid_input",context:{issues:iG(t.error)}});let r=yield*iM,n=yield*r1,i=t.data,a=yield*s.OH5(()=>r.createId("build")),o=yield*s.OH5(()=>{var e;let t;return t=eg((e=i.spec).title),{id:iK(e.id)??(iV(t)||"sketchi-sequence"),title:t,participants:e.participants.map(e=>({id:eg(e.id),label:eg(e.label),...e.kind?{kind:eg(e.kind)}:{}})),messages:e.messages.map((e,t)=>({id:iK(e.id)??`message-${t+1}-${iV(e.source)}-${iV(e.target)}`,source:eg(e.source),target:eg(e.target),label:eg(e.label),...e.type?{type:e.type}:{},...e.style?{style:e.style}:{}})),style:{...b}}}).pipe(s.fRP("codeMode.buildSequenceDiagram.normalize")),l={buildId:a,...ah(i.requestId),normalizedSpec:o},c=yield*s.OH5(()=>{let e,t,r,n;return e=[],t=new Set,o.participants.forEach((r,n)=>{t.has(r.id)&&e.push(iY({code:"duplicate_node_id",stage:"input",ref:{kind:"request",path:`spec.participants.[${n}].id`},message:`Participant id "${r.id}" is duplicated.`,hint:"Give every participant a unique stable id and update message references."})),t.add(r.id)}),r=new Map(o.participants.map((e,t)=>[e.id,t])),o.participants.forEach(t=>{let n=nI(t.id),i=r.get(n);void 0!==i&&e.push(iY({code:"duplicate_node_id",stage:"input",ref:{kind:"request",path:`spec.participants.[${i}].id`},message:`Participant id "${n}" collides with the generated lifeline for "${t.id}".`,hint:"Rename the participant so its id does not equal another participant id followed by :lifeline."}))}),n=new Set,o.messages.forEach((r,i)=>{n.has(r.id)&&e.push(iY({code:"duplicate_edge_id",stage:"input",ref:{kind:"request",path:`spec.messages.[${i}].id`},message:`Message id "${r.id}" is duplicated.`,hint:"Give every message a unique id or omit message ids to generate them deterministically."})),n.add(r.id),t.has(r.source)||e.push(iY({code:"missing_edge_source",stage:"input",ref:{kind:"request",path:`spec.messages.[${i}].source`},message:`Message source "${r.source}" is not a participant.`,hint:"Use the id of a participant declared in spec.participants."})),t.has(r.target)||e.push(iY({code:"missing_edge_target",stage:"input",ref:{kind:"request",path:`spec.messages.[${i}].target`},message:`Message target "${r.target}" is not a participant.`,hint:"Use the id of a participant declared in spec.participants."})),r.source===r.target&&e.push(iY({code:"self_loop",stage:"input",ref:{kind:"request",path:`spec.messages.[${i}]`},message:`Message "${r.id}" is self-referential.`,hint:"Choose a different target participant; self messages are not supported."}))}),e}).pipe(s.fRP("codeMode.buildSequenceDiagram.validate"));if(c.length>0)return yield*new iU({status:"invalid_sequence",context:{...l,issues:c}});let u=yield*s.OH5(()=>{var e;return{accepted:10>=(e=i.options?.minQualityScore??8),score:10,threshold:e,summary:{nodeCount:o.participants.length,edgeCount:o.messages.length},checks:[]}}).pipe(s.fRP("codeMode.buildSequenceDiagram.quality")),d={...l,quality:u};if(!u.accepted)return yield*new iU({status:"quality_failed",context:{...d,issues:iH(u)}});let f=yield*s.SvU({try:()=>(function(e){let t=new Set(e.participants.map(e=>e.id));for(let r of e.participants){let e=nI(r.id);if(t.has(e))throw Error(`Sequence participant "${e}" collides with the generated lifeline for "${r.id}".`)}let r=Math.max(184,184+88*Math.max(0,e.messages.length-1))-120+56,n=new Map,i=[],a=[],s=[];e.participants.forEach((t,o)=>{let l=48+320*o,c=l+90;n.set(t.id,c),i.push({type:"node",id:`node:${t.id}`,nodeId:t.id,...t.kind?{kind:t.kind}:{},shape:"rectangle",x:l,y:48,width:180,height:72,label:t.label}),a.push({type:"text",id:`label:${t.id}`,containerId:`node:${t.id}`,x:c,y:84,text:t.label,fontSize:14,maxWidth:156}),s.push({type:"node",id:`node:${nI(t.id)}`,nodeId:nI(t.id),rendererRole:nS,shape:"rectangle",fillColor:e.style.backgroundColor,strokeColor:e.style.accentColor,x:c-1,y:120,width:2,height:r,label:`${t.label} lifeline`})});let o=e.messages.map((e,t)=>{let r=n.get(e.source),i=n.get(e.target);if(void 0===r||void 0===i)throw Error(`Sequence message "${e.id}" references an unknown participant.`);if(r===i)throw Error(`Sequence message "${e.id}" cannot target its source participant.`);let a=184+88*t,s=i>r?1:-1;return{type:"arrow",id:`arrow:${e.id}`,edgeId:e.id,sourceNodeId:nI(e.source),targetNodeId:nI(e.target),..."return"===e.type?{strokeColor:"#6b7280"}:{},..."dashed"===e.style||"return"===e.type?{strokeStyle:"dashed"}:{},points:[{x:r+2*s/2,y:a},{x:i-2*s/2,y:a}],label:e.label}}),l=[...o,...s,...i,...a],c=[...s.map(e=>e.id),...i.map(e=>e.id),...a.map(e=>e.id),...o.map(e=>e.id)];return{kind:"canvas",version:1,diagramId:e.id,title:e.title,width:276+320*Math.max(0,e.participants.length-1),height:120+r+48,accentColor:e.style.accentColor,backgroundColor:e.style.backgroundColor,elements:l,layers:[],layouts:[],zOrder:c}})(o),catch:e=>new iU({status:"render_failed",context:{...d,issues:[iY({code:"render_failed",stage:"render",ref:{kind:"diagram",id:o.id},message:e instanceof Error?e.message:"Unable to render sequence diagram scene.",hint:"Repair the participant/message structure and retry."})]}})}).pipe(s.fRP("codeMode.buildSequenceDiagram.render")),{excalidraw:h,validation:p}=yield*s.OH5(()=>{let e=nz(f);return{excalidraw:e,validation:n0(e)}}).pipe(s.fRP("codeMode.buildSequenceDiagram.exportValidate")),m={...d,partial:am(f)};if(!p.ok)return yield*new iU({status:"export_failed",context:{...m,issues:i2(p.issues)}});let g=yield*i0({formats:iQ(i.options),scene:f,excalidraw:h,renderer:r.renderer}).pipe(s.xm_(e=>new iU({status:"export_failed",context:{...m,issues:i1(e)}}))),y=yield*s.OH5(()=>r.createId("artifact")),v=yield*iw(n.write({artifactId:y,diagramId:f.diagramId,formats:g,inlineFormats:iZ(i.options)}),{artifactId:y,...i.requestId?{requestId:i.requestId}:{}}).pipe(s.xm_(e=>new iU({status:"storage_failed",context:{...d,issues:[a_(e,"storage_write_failed")]}})));return{ok:!0,status:"accepted",buildId:a,...ah(i.requestId),normalizedSpec:o,quality:u,artifact:ap(v,r.artifactUrl),issues:[]}}),aI=s.fn("codeMode.createCanvas.workflow")(function*(e){let t=yield*s.OH5(()=>re.safeParse(e)).pipe(s.fRP("codeMode.createCanvas.parse"));if(!t.success)return yield*new iF({status:"invalid_input",context:{issues:iG(t.error)}});let r=yield*iM,n=yield*r1,i=t.data,a=yield*s.OH5(()=>r.createId("build")),o={buildId:a,...ah(i.requestId)};if(r6(i.spec)>ei.maxSerializedBytes)return yield*new iF({status:"limit_exceeded",context:{...o,issues:[iY({code:"canvas_limit_exceeded",stage:"canvas",ref:{kind:"request",path:"spec"},message:`CanvasSpec exceeds ${ei.maxSerializedBytes} serialized bytes.`,hint:"Split the visualization into a smaller canvas or reduce repeated text and points."})]}});let l=yield*s.OH5(()=>i8(i.spec)).pipe(s.fRP("codeMode.createCanvas.normalize"));if(!l)return yield*new iF({status:"invalid_canvas",context:{...o,issues:[iY({code:"invalid_canvas_geometry",stage:"canvas",ref:{kind:"request",path:"spec.elements"},message:"CanvasSpec contains an invalid point list.",hint:"Provide at least two points for lines/connectors and three points for polygons."})]}});let c=yield*s.OH5(()=>(function(e){var t;let r,n,i=[...e.elements];for(let t of e.layouts)i=function(e,t){switch(t.type){case"row":case"column":case"stack":return function(e,t){let r=ec(e,t.ids),n=r[0];if(!n)return[...e];let i=el(n),a=t.x??i.x,s=t.y??i.y,o="stack"===t.type?t.gap??0:t.gap??32,l=new Map,c="column"===t.type?s:a;for(let e of r){let r=el(e);l.set(e.id,{x:"column"===t.type||"stack"===t.type?a:c,y:"column"===t.type?c:s}),"stack"!==t.type&&(c+=("column"===t.type?r.height:r.width)+o)}return eu(e,l)}(e,t);case"grid":return function(e,t){let r=ec(e,t.ids);if(0===r.length)return[...e];let n=Math.max(1,Math.floor(t.columns)),i=r.map(el),a=Array.from({length:n},(e,t)=>Math.max(0,...i.filter((e,r)=>r%n===t).map(e=>e.width))),s=Array.from({length:Math.ceil(r.length/n)},(e,t)=>Math.max(0,...i.filter((e,r)=>Math.floor(r/n)===t).map(e=>e.height))),o=i[0];if(!o)return[...e];let l=t.x??o.x,c=t.y??o.y,u=t.columnGap??32,d=t.rowGap??32,f=new Map;return r.forEach((e,t)=>{let r=t%n,i=Math.floor(t/n);f.set(e.id,{x:l+a.slice(0,r).reduce((e,t)=>e+t,0)+u*r,y:c+s.slice(0,i).reduce((e,t)=>e+t,0)+d*i})}),eu(e,f)}(e,t);case"align":return function(e,t){let r=ec(e,t.ids);if(0===r.length)return[...e];let n=r.map(el),i=n.map(e=>ed(e,t.axis)),a=n.map(e=>ed(e,t.axis)+ef(e,t.axis)),s=n.map(e=>ed(e,t.axis)+ef(e,t.axis)/2),o="start"===t.alignment?Math.min(...i):"end"===t.alignment?Math.max(...a):s.reduce((e,t)=>e+t,0)/s.length,l=new Map;return r.forEach((e,r)=>{let i=n[r];if(!i)return;let a="start"===t.alignment?o:"end"===t.alignment?o-ef(i,t.axis):o-ef(i,t.axis)/2;l.set(e.id,{x:"x"===t.axis?a:i.x,y:"y"===t.axis?a:i.y})}),eu(e,l)}(e,t);case"distribute":return function(e,t){let r=ec(e,t.ids).sort((e,r)=>ed(el(e),t.axis)-ed(el(r),t.axis));if(r.length<2)return[...e];let n=r.map(el),i=n[0],a=n[n.length-1];if(!i||!a)return[...e];let s=ed(i,t.axis),o=ed(a,t.axis)+ef(a,t.axis),l=n.reduce((e,r)=>e+ef(r,t.axis),0),c=t.gap??Math.max(0,(o-s-l)/(r.length-1)),u=new Map,d=s;return r.forEach((e,r)=>{let i=n[r];i&&(u.set(e.id,{x:"x"===t.axis?d:i.x,y:"y"===t.axis?d:i.y}),d+=ef(i,t.axis)+c)}),eu(e,u)}(e,t)}}(i,t);let a=(r=(t=i=function(e){let t=new Map(e.filter(e=>"node"===e.type).map(e=>[e.nodeId,e])),r=new Map;for(let t of e)("node"===t.type||"frame"===t.type)&&r.set(t.id,t);let n=e.map(e=>{if("arrow"===e.type){let r=t.get(e.sourceNodeId),n=t.get(e.targetNodeId);return r&&n?{...e,points:[ep(r,eh(n)),...e.points.slice(1,-1),ep(n,eh(r))]}:e}if("line"===e.type){let t=e.startBinding?r.get(e.startBinding.elementId):void 0,n=e.endBinding?r.get(e.endBinding.elementId):void 0;if(!t&&!n)return e;let i=[e.points[0],e.points[1],...e.points.slice(2)];return t&&(i[0]=ep(t,n?eh(n):i[i.length-1]??i[0])),n&&(i[i.length-1]=ep(n,t?eh(t):i[0])),{...e,points:i}}return e}),i=new Map(n.map(e=>[e.id,e]));return n.map(e=>{if("text"!==e.type||!e.containerId)return e;let t=i.get(e.containerId);if(t?.type==="node"){let r=eh(t);return{...e,x:r.x,y:r.y}}if(t?.type==="arrow"){let r=t.points[0],n=t.points[t.points.length-1]??r;return{...e,x:(r.x+n.x)/2,y:(r.y+n.y)/2}}return e})}(i)).filter(es).map(el),n=t.filter(e=>"arrow"===e.type||"line"===e.type),{width:Math.max(1,...r.map(e=>e.x+e.width),...n.flatMap(e=>e.points.map(e=>e.x)))+48,height:Math.max(1,...r.map(e=>e.y+e.height),...n.flatMap(e=>e.points.map(e=>e.y)))+48}),s=e.zOrder.length?[...e.zOrder]:i.map((e,t)=>({element:e,index:t})).sort((e,t)=>(e.element.zIndex??e.index)-(t.element.zIndex??t.index)).map(({element:e})=>e.id);return{...e,width:Math.max(e.width,a.width),height:Math.max(e.height,a.height),elements:i,zOrder:s}})(l)).pipe(s.fRP("codeMode.createCanvas.layout")),u=yield*s.OH5(()=>eo(c)).pipe(s.fRP("codeMode.createCanvas.validate"));if(u.length>0){let e=i5(u);return yield*new iF({status:e.some(e=>"canvas_limit_exceeded"===e.code)?"limit_exceeded":"invalid_canvas",context:{...o,normalizedSpec:c,issues:e}})}let{excalidraw:d,validation:f}=yield*s.OH5(()=>{let e=nz(c);return{excalidraw:e,validation:n0(e)}}).pipe(s.fRP("codeMode.createCanvas.exportValidate")),h=i3(f.issues),p={...o,normalizedSpec:c,partial:am(c)};if(h.length>0)return yield*new iF({status:"export_failed",context:{...p,issues:h}});let m=yield*i0({formats:iQ(i.options),scene:c,excalidraw:d,renderer:r.renderer}).pipe(s.xm_(e=>new iF({status:"export_failed",context:{...p,issues:i1(e)}}))),g=yield*s.OH5(()=>r.createId("artifact")),y=yield*iw(n.write({artifactId:g,diagramId:c.diagramId,formats:m,inlineFormats:iZ(i.options)}),{artifactId:g,...i.requestId?{requestId:i.requestId}:{}}).pipe(s.xm_(e=>new iF({status:"storage_failed",context:{...p,issues:[a_(e,"storage_write_failed")]}})));return{ok:!0,status:"accepted",buildId:a,...ah(i.requestId),normalizedSpec:c,artifact:ap(y,r.artifactUrl),issues:[]}}),aE=s.fn("codeMode.buildFlowchart.workflow")(function*(e){let t=yield*s.OH5(()=>tS.safeParse(e)).pipe(s.fRP("codeMode.buildFlowchart.parse"));if(!t.success)return yield*new iD({status:"invalid_input",context:{issues:iG(t.error)}});let r=yield*iM,n=yield*r1,i=t.data,a=iQ(i.options),o=yield*s.OH5(()=>r.createId("build")),l=yield*s.OH5(()=>{var e;let t;return t=eg((e=i.spec).title),{id:iI(e.id)??(t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"sketchi-flowchart"),title:t,nodes:e.nodes.map(e=>({id:eg(e.id),label:eg(e.label),kind:e.kind,...e.description?{description:eg(e.description)}:{}})),edges:e.edges.map((e,t)=>({id:iI(e.id)??`edge-${t+1}`,source:eg(e.source),target:eg(e.target),...e.label?{label:eg(e.label)}:{}})),layout:{direction:e.layout.direction},style:{...b}}}).pipe(s.fRP("codeMode.buildFlowchart.normalize")),c={buildId:o,...ah(i.requestId),normalizedSpec:l},u=yield*s.OH5(()=>q.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(s.fRP("codeMode.buildFlowchart.parseCanonical"));if(!u.success){var d;return yield*new iD({status:"invalid_flowchart",context:{...c,issues:(d=u.error,d.issues.slice(0,20).map(e=>{let t=function(e,t){let r=iz(e.path),n="input"===r?"spec":`spec.${r}`,[i,a]=e.path;if("nodes"===i&&"number"==typeof a){let e=t.nodes[a]?.id;return{kind:"node",...e?{id:e}:{},path:n}}if("edges"===i&&"number"==typeof a){let e=t.edges[a]?.id;return{kind:"edge",...e?{id:e}:{},path:n}}return{kind:"diagram",id:t.id,path:n}}(e,l);return iY({code:iX(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*s.OH5(()=>X(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 iY({code:e.code,stage:"flowchart",...t?{ref:t}:{},message:e.message,hint:e.hint})})).pipe(s.fRP("codeMode.buildFlowchart.validate"));if(h.length>0)return yield*new iD({status:"invalid_flowchart",context:{...c,issues:h}});yield*s.OH5(()=>G(f)).pipe(s.fRP("codeMode.buildFlowchart.assertValid"));let p=yield*s.OH5(()=>(function(e,t){let r=[],n=0,i=(e,t,i=!1)=>{n+=e,r.push({severity:i?"error":"warning",message:t})},a=new Map,s=new Map;for(let t of e.edges)a.set(t.source,(a.get(t.source)??0)+1),a.set(t.target,(a.get(t.target)??0)+1),s.set(t.source,[...s.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=>(a.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(iS)){let e=s.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=>i_.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||ik.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(s.fRP("codeMode.buildFlowchart.quality")),m={...c,quality:p};if(!p.accepted)return yield*new iD({status:"quality_failed",context:{...m,issues:iH(p)}});let g=yield*s.SvU({try:()=>nk(f),catch:e=>new iD({status:"render_failed",context:{...m,issues:[iY({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(s.fRP("codeMode.buildFlowchart.render")),{excalidraw:y,validation:v}=yield*s.OH5(()=>{let e=nz(g);return{excalidraw:e,validation:n0(e)}}).pipe(s.fRP("codeMode.buildFlowchart.exportValidate")),w={...m,partial:am(g)};if(!v.ok)return yield*new iD({status:"export_failed",context:{...w,issues:i2(v.issues)}});let x=yield*i0({formats:a,scene:g,excalidraw:y,renderer:r.renderer}).pipe(s.xm_(e=>new iD({status:"export_failed",context:{...w,issues:i1(e)}}))),_=yield*s.OH5(()=>r.createId("artifact")),k=yield*iw(n.write({artifactId:_,diagramId:g.diagramId,formats:x,inlineFormats:iZ(i.options)}),{artifactId:_,...i.requestId?{requestId:i.requestId}:{}}).pipe(s.xm_(e=>new iD({status:"storage_failed",context:{...m,issues:[a_(e,"storage_write_failed")]}})));return{ok:!0,status:"accepted",buildId:o,...ah(i.requestId),normalizedSpec:l,quality:p,artifact:ap(k,r.artifactUrl),issues:[]}}),a$=s.fn("codeMode.getArtifact.workflow")(function*(e){let t=yield*s.OH5(()=>rs.safeParse(e)).pipe(s.fRP("codeMode.getArtifact.parse"));if(!t.success)return yield*new iB({status:"invalid_input",issues:iG(t.error)});let r=yield*iM,n=yield*r1,i=t.data,a=yield*n.readManifest(i.artifactId).pipe(s.xm_(e=>new iB({status:"storage_failed",issues:[a_(e,"storage_read_failed")]})));if(!a)return yield*new iB({status:"not_found",issues:[iY({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(!a.formats.some(e=>e.format===o))return yield*new iB({status:"format_unavailable",issues:[iY({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(s.xm_(e=>new iB({status:"storage_failed",issues:[a_(e,"storage_read_failed")]})));return l?{ok:!0,artifactId:i.artifactId,diagramId:a.diagramId,format:o,mimeType:l.mimeType,...r.artifactUrl?{url:r.artifactUrl({artifactId:i.artifactId,format:o})}:{},...!0!==i.inline||!r5(o)?{}:{inline:l.data},sizeBytes:l.sizeBytes,...a.provenance?{provenance:a.provenance}:{}}:yield*new iB({status:"format_unavailable",issues:[iY({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."})]})}),aO=s.fn("codeMode.applyDiagramPatch.workflow")(function*(e){let t=yield*s.OH5(()=>rT.safeParse(e)).pipe(s.fRP("codeMode.applyDiagramPatch.parse"));if(!t.success)return yield*new iW({status:"invalid_input",context:{issues:iG(t.error)}});let r=yield*iM,n=yield*r1,i=t.data,a=yield*s.OH5(()=>r.createId("patch")),o={patchId:a,...ah(i.requestId)},l=iQ(i.options),c=yield*af(i).pipe(s.xm_(e=>new iW({status:e.status,context:{...o,...e.context}}))),u={...o,...c.sourceArtifactId?{sourceArtifactId:c.sourceArtifactId}:{}},d=c.scene,f=i9(d),h=yield*s.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),i4(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 ae(e))t.style.strokeColor&&(r.strokeColor=t.style.strokeColor),t.style.textColor&&(r.textColor=t.style.textColor);for(let r of i7(e))t.style.textColor&&(r.textColor=t.style.textColor);return[]}let r=ar(e,t.selector);if(0===r.nodes.length&&0===r.arrows.length&&0===r.texts.length)return[an(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=ai(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=ai(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=ar(e,t.selector);if(0===n.nodes.length)return[an(t)];let i=[];for(let r of n.nodes){if(r.shape=t.shape,r.points="polygon"===t.shape?[{x:r.width/2,y:0},{x:r.width,y:r.height/2},{x:r.width/2,y:r.height},{x:0,y:r.height/2}]:void 0,"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=ai(e,t.id);r&&(r.x=t.x+t.width/2,r.y=t.y+t.height/2)}(e,r)}return aa(e,i),[];case"translate":return function(e,t){let r=ar(e,t.selector);if(0===r.nodes.length&&0===r.arrows.length&&0===r.texts.length)return[an(t)];let n=new Set,i=new Set;for(let a of r.nodes){a.x+=t.dx,a.y+=t.dy,n.add(a.nodeId);let r=ai(e,a.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=ai(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 aa(e,[...n]),ac(e),[]}(e,t);case"replaceText":let a=ar(e,t.selector);if(0===a.nodes.length&&0===a.arrows.length&&0===a.texts.length)return[an(t)];for(let r of a.nodes){r.label=t.text;let n=ai(e,r.id);n&&(n.text=t.text)}for(let r of a.arrows){r.label=t.text;let n=ai(e,r.id);n&&(n.text=t.text)}for(let e of a.texts)e.text=t.text;return[];case"rerouteEdges":let s;return 0===(s=ar(e,t.selector)).arrows.length?[an(t)]:s.arrows.flatMap(t=>al(e,t));case"insert":let o=new Set(e.elements.map(e=>e.id)),l=t.elements.map(e=>e.id);if(new Set(l).size!==l.length||l.some(e=>o.has(e)))return ad(t,"Inserted elements must use ids that are unique within the canvas.");let c=au(e.zOrder,t.beforeId,t.afterId);return void 0===c?ad(t,"Insert specifies an unknown anchor or both beforeId and afterId."):(e.elements.push(...t.elements.map(e=>structuredClone(e))),e.zOrder.splice(c,0,...l),[]);case"remove":return function(e,t){let r=function(e,t){let r=ar(e,t),n=new Set([...r.nodes.map(e=>e.id),...r.arrows.map(e=>e.id),...r.texts.map(e=>e.id)]),i=new Set(t.ids??[]);for(let t of e.elements)i.has(t.id)&&n.add(t.id);return n}(e,t.selector);if(0===r.size)return[an(t)];let n=new Set(e.elements.flatMap(e=>"node"===e.type&&r.has(e.id)?[e.nodeId]:[]));for(let t of e.elements)("text"===t.type&&t.containerId&&r.has(t.containerId)||"arrow"===t.type&&(n.has(t.sourceNodeId)||n.has(t.targetNodeId))||"line"===t.type&&(t.startBinding&&r.has(t.startBinding.elementId)||t.endBinding&&r.has(t.endBinding.elementId)))&&r.add(t.id);let i=e.elements.filter(e=>!r.has(e.id)).map(e=>e.frameId&&r.has(e.frameId)?{...e,frameId:void 0}:e);e.elements.splice(0,e.elements.length,...i);let a=e.zOrder.filter(e=>!r.has(e));e.zOrder.splice(0,e.zOrder.length,...a);let s=e.layouts.map(e=>({...e,ids:e.ids.filter(e=>!r.has(e))})).filter(e=>e.ids.length>0);return e.layouts.splice(0,e.layouts.length,...s),ac(e),[]}(e,t);case"replace":let u;return(u=e.elements.findIndex(e=>e.id===t.id))<0?[an(t)]:t.element.id!==t.id?ad(t,"Replacement element id must match the stable id being replaced."):(e.elements.splice(u,1,structuredClone(t.element)),ac(e),[]);case"reorder":let d=new Set(t.ids);if(d.size!==t.ids.length||t.ids.some(t=>!e.zOrder.includes(t)))return ad(t,"Reorder ids must be unique ids already present in zOrder.");let f=e.zOrder.filter(e=>!d.has(e)),h=au(f,t.beforeId,t.afterId);return void 0===h?ad(t,"Reorder specifies an unknown anchor or both beforeId and afterId."):(f.splice(h,0,...t.ids),e.zOrder.splice(0,e.zOrder.length,...f),[]);case"group":case"ungroup":let p=new Set(t.ids);if(t.ids.some(t=>!e.elements.some(e=>e.id===t)))return[an(t)];let m=e.elements.map(e=>p.has(e.id)?"group"===t.op?{...e,groupIds:[...new Set([...e.groupIds??[],t.groupId])]}:{...e,groupIds:t.groupId?(e.groupIds??[]).filter(e=>e!==t.groupId):[]}:e);return e.elements.splice(0,e.elements.length,...m),[]}}(d,e);if(t.length>0)return t}return[]}).pipe(s.fRP("codeMode.applyDiagramPatch.operations"));if(h.length>0)return yield*new iW({status:h[0]?.code==="unknown_patch_target"?"target_not_found":"unsupported_operation",context:{...u,issues:h}});if(i.options?.preserveConnectivity!==!1){let e=i9(d);if(!(f.length===e.length&&f.every((t,r)=>t===e[r])))return yield*new iW({status:"connectivity_changed",context:{...u,issues:[iY({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*s.OH5(()=>i8(d)).pipe(s.fRP("codeMode.applyDiagramPatch.normalize"));if(!p)return yield*new iW({status:"render_failed",context:{...u,issues:[iY({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 m=yield*s.OH5(()=>eo(p)).pipe(s.fRP("codeMode.applyDiagramPatch.validate"));if(m.length>0)return yield*new iW({status:"render_failed",context:{...u,partial:am(p),issues:i5(m)}});let{excalidraw:g,validation:y}=yield*s.OH5(()=>{let e=nz(p);return{excalidraw:e,validation:n0(e)}}).pipe(s.fRP("codeMode.applyDiagramPatch.exportValidate")),b={...u,partial:am(p)},v=i3(y.issues);if(v.length>0)return yield*new iW({status:"export_failed",context:{...b,issues:v}});let w=yield*i0({formats:l,scene:p,excalidraw:g,renderer:r.renderer}).pipe(s.xm_(e=>new iW({status:"export_failed",context:{...b,issues:i1(e)}}))),x=yield*s.OH5(()=>r.createId("artifact")),_=yield*iw(n.write({artifactId:x,diagramId:p.diagramId,formats:w,inlineFormats:iZ(i.options),...c.sourceArtifactId?{provenance:{sourceArtifactId:c.sourceArtifactId}}:{}}),{artifactId:x,...i.requestId?{requestId:i.requestId}:{}}).pipe(s.xm_(e=>new iW({status:"storage_failed",context:{...u,issues:[a_(e,"storage_write_failed")]}})));return{ok:!0,status:"accepted",patchId:a,...ah(i.requestId),...c.sourceArtifactId?{sourceArtifactId:c.sourceArtifactId}:{},artifact:ap(_,r.artifactUrl),issues:[]}});function aC(e,t){return e.pipe(s.YWq({onFailure:t,onSuccess:e=>e}))}let aT=s.fn("codeMode.buildFlowchart")(e=>iR("buildFlowchart",e,aC(aE(e),ag))),aA=s.fn("codeMode.buildMindmap")(e=>iR("buildMindmap",e,aC(ak(e),ay))),aM=s.fn("codeMode.buildSequenceDiagram")(e=>iR("buildSequenceDiagram",e,aC(aS(e),ab)));s.fn("codeMode.createCanvas")(e=>iR("createCanvas",e,aC(aI(e),av))),s.fn("codeMode.getArtifact")(e=>iR("getArtifact",e,aC(a$(e),aw)));let aN=s.fn("codeMode.applyDiagramPatch")(e=>iR("applyDiagramPatch",e,aC(aO(e),ax)))},9095(e){e.exports=JSON.parse('[{"name":"Agola CI","constant":"AGOLA","env":"AGOLA_GIT_REF","pr":"AGOLA_PULL_REQUEST_ID"},{"name":"Alpic","constant":"ALPIC","env":"ALPIC_HOST"},{"name":"Appcircle","constant":"APPCIRCLE","env":"AC_APPCIRCLE","pr":{"env":"AC_GIT_PR","ne":"false"}},{"name":"AppVeyor","constant":"APPVEYOR","env":"APPVEYOR","pr":"APPVEYOR_PULL_REQUEST_NUMBER"},{"name":"AWS CodeBuild","constant":"CODEBUILD","env":"CODEBUILD_BUILD_ARN","pr":{"env":"CODEBUILD_WEBHOOK_EVENT","any":["PULL_REQUEST_CREATED","PULL_REQUEST_UPDATED","PULL_REQUEST_REOPENED"]}},{"name":"Azure Pipelines","constant":"AZURE_PIPELINES","env":"TF_BUILD","pr":{"BUILD_REASON":"PullRequest"}},{"name":"Bamboo","constant":"BAMBOO","env":"bamboo_planKey"},{"name":"Bitbucket Pipelines","constant":"BITBUCKET","env":"BITBUCKET_COMMIT","pr":"BITBUCKET_PR_ID"},{"name":"Bitrise","constant":"BITRISE","env":"BITRISE_IO","pr":"BITRISE_PULL_REQUEST"},{"name":"Buddy","constant":"BUDDY","env":"BUDDY_WORKSPACE_ID","pr":"BUDDY_EXECUTION_PULL_REQUEST_ID"},{"name":"Buildkite","constant":"BUILDKITE","env":"BUILDKITE","pr":{"env":"BUILDKITE_PULL_REQUEST","ne":"false"}},{"name":"CircleCI","constant":"CIRCLE","env":"CIRCLECI","pr":"CIRCLE_PULL_REQUEST"},{"name":"Cirrus CI","constant":"CIRRUS","env":"CIRRUS_CI","pr":"CIRRUS_PR"},{"name":"Cloudflare Pages","constant":"CLOUDFLARE_PAGES","env":"CF_PAGES"},{"name":"Cloudflare Workers","constant":"CLOUDFLARE_WORKERS","env":"WORKERS_CI"},{"name":"Codefresh","constant":"CODEFRESH","env":"CF_BUILD_ID","pr":{"any":["CF_PULL_REQUEST_NUMBER","CF_PULL_REQUEST_ID"]}},{"name":"Codemagic","constant":"CODEMAGIC","env":"CM_BUILD_ID","pr":"CM_PULL_REQUEST"},{"name":"Codeship","constant":"CODESHIP","env":{"CI_NAME":"codeship"}},{"name":"Drone","constant":"DRONE","env":"DRONE","pr":{"DRONE_BUILD_EVENT":"pull_request"}},{"name":"dsari","constant":"DSARI","env":"DSARI"},{"name":"Earthly","constant":"EARTHLY","env":"EARTHLY_CI"},{"name":"Expo Application Services","constant":"EAS","env":"EAS_BUILD"},{"name":"Gerrit","constant":"GERRIT","env":"GERRIT_PROJECT"},{"name":"Gitea Actions","constant":"GITEA_ACTIONS","env":"GITEA_ACTIONS"},{"name":"GitHub Actions","constant":"GITHUB_ACTIONS","env":"GITHUB_ACTIONS","pr":{"GITHUB_EVENT_NAME":"pull_request"}},{"name":"GitLab CI","constant":"GITLAB","env":"GITLAB_CI","pr":"CI_MERGE_REQUEST_ID"},{"name":"GoCD","constant":"GOCD","env":"GO_PIPELINE_LABEL"},{"name":"Google Cloud Build","constant":"GOOGLE_CLOUD_BUILD","env":"BUILDER_OUTPUT"},{"name":"Harness CI","constant":"HARNESS","env":"HARNESS_BUILD_ID"},{"name":"Heroku","constant":"HEROKU","env":{"env":"NODE","includes":"/app/.heroku/node/bin/node"}},{"name":"Hudson","constant":"HUDSON","env":"HUDSON_URL"},{"name":"Jenkins","constant":"JENKINS","env":["JENKINS_URL","BUILD_ID"],"pr":{"any":["ghprbPullId","CHANGE_ID"]}},{"name":"LayerCI","constant":"LAYERCI","env":"LAYERCI","pr":"LAYERCI_PULL_REQUEST"},{"name":"Magnum CI","constant":"MAGNUM","env":"MAGNUM"},{"name":"Netlify CI","constant":"NETLIFY","env":"NETLIFY","pr":{"env":"PULL_REQUEST","ne":"false"}},{"name":"Nevercode","constant":"NEVERCODE","env":"NEVERCODE","pr":{"env":"NEVERCODE_PULL_REQUEST","ne":"false"}},{"name":"Prow","constant":"PROW","env":"PROW_JOB_ID"},{"name":"ReleaseHub","constant":"RELEASEHUB","env":"RELEASE_BUILD_ID"},{"name":"Render","constant":"RENDER","env":"RENDER","pr":{"IS_PULL_REQUEST":"true"}},{"name":"Sail CI","constant":"SAIL","env":"SAILCI","pr":"SAIL_PULL_REQUEST_NUMBER"},{"name":"Screwdriver","constant":"SCREWDRIVER","env":"SCREWDRIVER","pr":{"env":"SD_PULL_REQUEST","ne":"false"}},{"name":"Semaphore","constant":"SEMAPHORE","env":"SEMAPHORE","pr":"PULL_REQUEST_NUMBER"},{"name":"Sourcehut","constant":"SOURCEHUT","env":{"CI_NAME":"sourcehut"}},{"name":"Strider CD","constant":"STRIDER","env":"STRIDER"},{"name":"TaskCluster","constant":"TASKCLUSTER","env":["TASK_ID","RUN_ID"]},{"name":"TeamCity","constant":"TEAMCITY","env":"TEAMCITY_VERSION"},{"name":"Travis CI","constant":"TRAVIS","env":"TRAVIS","pr":{"env":"TRAVIS_PULL_REQUEST","ne":"false"}},{"name":"Vela","constant":"VELA","env":"VELA","pr":{"VELA_PULL_REQUEST":"1"}},{"name":"Vercel","constant":"VERCEL","env":{"any":["NOW_BUILDER","VERCEL"]},"pr":"VERCEL_GIT_PULL_REQUEST_ID"},{"name":"Visual Studio App Center","constant":"APPCENTER","env":"APPCENTER_BUILD_ID"},{"name":"Woodpecker","constant":"WOODPECKER","env":{"CI":"woodpecker"},"pr":{"CI_BUILD_EVENT":"pull_request"}},{"name":"Xcode Cloud","constant":"XCODE_CLOUD","env":"CI_XCODE_PROJECT","pr":"CI_PULL_REQUEST_NUMBER"},{"name":"Xcode Server","constant":"XCODE_SERVER","env":"XCS"}]')}},o={};function l(e){var t=o[e];if(void 0!==t)return t.exports;var r=o[e]={exports:{}};return s[e].call(r.exports,r,r.exports,l),r.exports}l.m=s,l.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return l.d(t,{a:t}),t},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 a={};r=r||[null,n({}),n([]),n(n)];for(var s=2&t&&e;("object"==typeof s||"function"==typeof s)&&!~r.indexOf(s);s=n(s))Object.getOwnPropertyNames(s).forEach(t=>{a[t]=()=>e[t]});return a.default=()=>e,l.d(i,a),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:"bdee8e123d2a353d",869:"e31d99c364363ef2"})[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},a=e=>{var t,r,n=e.__rspack_esm_ids,a=e.__webpack_modules__,s=e.__rspack_esm_runtime,o=0;for(t in a)l.o(a,t)&&(l.m[t]=a[t]);for(s&&s(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(a,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(9074);