@doguyilmaz/tapster 0.0.0-stage → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +95 -2
- package/dist/cli.js +1447 -0
- package/package.json +58 -4
package/dist/cli.js
ADDED
|
@@ -0,0 +1,1447 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
// @bun
|
|
3
|
+
var Uy=Object.defineProperty;var P=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Zy=(e)=>e;function Gy(e,t){this[e]=Zy.bind(null,t)}var wl=(e,t)=>{for(var n in t)Uy(e,n,{get:t[n],enumerable:!0,configurable:!0,set:Gy.bind(t,n)})};var Oe=import.meta.require;var N=P(function(Yy){var Fo=Symbol.for("yaml.alias"),_l=Symbol.for("yaml.document"),Nr=Symbol.for("yaml.map"),kl=Symbol.for("yaml.pair"),Ko=Symbol.for("yaml.scalar"),zr=Symbol.for("yaml.seq"),Je=Symbol.for("yaml.node.type"),qy=(e)=>!!e&&typeof e==="object"&&e[Je]===Fo,By=(e)=>!!e&&typeof e==="object"&&e[Je]===_l,Hy=(e)=>!!e&&typeof e==="object"&&e[Je]===Nr,Fy=(e)=>!!e&&typeof e==="object"&&e[Je]===kl,xl=(e)=>!!e&&typeof e==="object"&&e[Je]===Ko,Ky=(e)=>!!e&&typeof e==="object"&&e[Je]===zr;function Sl(e){if(e&&typeof e==="object")switch(e[Je]){case Nr:case zr:return!0}return!1}function Wy(e){if(e&&typeof e==="object")switch(e[Je]){case Fo:case Nr:case Ko:case zr:return!0}return!1}var Vy=(e)=>(xl(e)||Sl(e))&&!!e.anchor;Yy.ALIAS=Fo;Yy.DOC=_l;Yy.MAP=Nr;Yy.NODE_TYPE=Je;Yy.PAIR=kl;Yy.SCALAR=Ko;Yy.SEQ=zr;Yy.hasAnchor=Vy;Yy.isAlias=qy;Yy.isCollection=Sl;Yy.isDocument=By;Yy.isMap=Hy;Yy.isNode=Wy;Yy.isPair=Fy;Yy.isScalar=xl;Yy.isSeq=Ky});var An=P(function(hb){var V=N(),he=Symbol("break visit"),Al=Symbol("skip children"),Le=Symbol("remove node");function Dr(e,t){let n=$l(t);if(V.isDocument(e)){if(Ft(null,e.contents,n,Object.freeze([e]))===Le)e.contents=null}else Ft(null,e,n,Object.freeze([]))}Dr.BREAK=he;Dr.SKIP=Al;Dr.REMOVE=Le;function Ft(e,t,n,r){let i=Pl(e,t,n,r);if(V.isNode(i)||V.isPair(i))return Tl(e,r,i),Ft(e,i,n,r);if(typeof i!=="symbol"){if(V.isCollection(t)){r=Object.freeze(r.concat(t));for(let o=0;o<t.items.length;++o){let s=Ft(o,t.items[o],n,r);if(typeof s==="number")o=s-1;else if(s===he)return he;else if(s===Le)t.items.splice(o,1),o-=1}}else if(V.isPair(t)){r=Object.freeze(r.concat(t));let o=Ft("key",t.key,n,r);if(o===he)return he;else if(o===Le)t.key=null;let s=Ft("value",t.value,n,r);if(s===he)return he;else if(s===Le)t.value=null}}return i}async function Lr(e,t){let n=$l(t);if(V.isDocument(e)){if(await Kt(null,e.contents,n,Object.freeze([e]))===Le)e.contents=null}else await Kt(null,e,n,Object.freeze([]))}Lr.BREAK=he;Lr.SKIP=Al;Lr.REMOVE=Le;async function Kt(e,t,n,r){let i=await Pl(e,t,n,r);if(V.isNode(i)||V.isPair(i))return Tl(e,r,i),Kt(e,i,n,r);if(typeof i!=="symbol"){if(V.isCollection(t)){r=Object.freeze(r.concat(t));for(let o=0;o<t.items.length;++o){let s=await Kt(o,t.items[o],n,r);if(typeof s==="number")o=s-1;else if(s===he)return he;else if(s===Le)t.items.splice(o,1),o-=1}}else if(V.isPair(t)){r=Object.freeze(r.concat(t));let o=await Kt("key",t.key,n,r);if(o===he)return he;else if(o===Le)t.key=null;let s=await Kt("value",t.value,n,r);if(s===he)return he;else if(s===Le)t.value=null}}return i}function $l(e){if(typeof e==="object"&&(e.Collection||e.Node||e.Value))return 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);return e}function Pl(e,t,n,r){if(typeof n==="function")return n(e,t,r);if(V.isMap(t))return n.Map?.(e,t,r);if(V.isSeq(t))return n.Seq?.(e,t,r);if(V.isPair(t))return n.Pair?.(e,t,r);if(V.isScalar(t))return n.Scalar?.(e,t,r);if(V.isAlias(t))return n.Alias?.(e,t,r);return}function Tl(e,t,n){let r=t[t.length-1];if(V.isCollection(r))r.items[e]=n;else if(V.isPair(r))if(e==="key")r.key=n;else r.value=n;else if(V.isDocument(r))r.contents=n;else{let i=V.isAlias(r)?"alias":"scalar";throw Error(`Cannot replace node with ${i} parent`)}}hb.visit=Dr;hb.visitAsync=Lr});var Wo=P(function(bb){var El=N(),gb=An(),vb={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},yb=(e)=>e.replace(/[!,[\]{}]/g,(t)=>vb[t]);class xe{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},xe.defaultYaml,e),this.tags=Object.assign({},xe.defaultTags,t)}clone(){let e=new xe(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new xe(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:xe.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},xe.defaultTags);break}return e}add(e,t){if(this.atNextDocument)this.yaml={explicit:xe.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},xe.defaultTags),this.atNextDocument=!1;let n=e.trim().split(/[ \t]+/),r=n.shift();switch(r){case"%TAG":{if(n.length!==2){if(t(0,"%TAG directive should contain exactly two parts"),n.length<2)return!1}let[i,o]=n;return this.tags[i]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,n.length!==1)return t(0,"%YAML directive should contain exactly one part"),!1;let[i]=n;if(i==="1.1"||i==="1.2")return this.yaml.version=i,!0;else{let o=/^\d+\.\d+$/.test(i);return t(6,`Unsupported YAML version ${i}`,o),!1}}default:return t(0,`Unknown directive ${r}`,!0),!1}}tagName(e,t){if(e==="!")return"!";if(e[0]!=="!")return t(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let o=e.slice(2,-1);if(o==="!"||o==="!!")return t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null;if(e[e.length-1]!==">")t("Verbatim tags must end with a >");return o}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);if(!r)t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(o){return t(String(o)),null}if(n==="!")return e;return t(`Could not resolve tag: ${e}`),null}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+yb(e.substring(n.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],n=Object.entries(this.tags),r;if(e&&n.length>0&&El.isNode(e.contents)){let i={};gb.visit(e.contents,(o,s)=>{if(El.isNode(s)&&s.tag)i[s.tag]=!0}),r=Object.keys(i)}else r=[];for(let[i,o]of n){if(i==="!!"&&o==="tag:yaml.org,2002:")continue;if(!e||r.some((s)=>s.startsWith(o)))t.push(`%TAG ${i} ${o}`)}return t.join(`
|
|
4
|
+
`)}}xe.defaultYaml={explicit:!1,version:"1.2"};xe.defaultTags={"!!":"tag:yaml.org,2002:"};bb.Directives=xe});var jr=P(function(Sb){var Ol=N(),_b=An();function kb(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let n=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(n)}return!0}function Cl(e){let t=new Set;return _b.visit(e,{Value(n,r){if(r.anchor)t.add(r.anchor)}}),t}function Rl(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function xb(e,t){let n=[],r=new Map,i=null;return{onAnchor:(o)=>{n.push(o),i??(i=Cl(e));let s=Rl(t,i);return i.add(s),s},setAnchors:()=>{for(let o of n){let s=r.get(o);if(typeof s==="object"&&s.anchor&&(Ol.isScalar(s.node)||Ol.isCollection(s.node)))s.node.anchor=s.anchor;else{let a=Error("Failed to resolve repeated object (this should not happen)");throw a.source=o,a}}},sourceObjects:r}}Sb.anchorIsValid=kb;Sb.anchorNames=Cl;Sb.createNodeAnchors=xb;Sb.findNewAnchor=Rl});var Vo=P(function(Eb){function $n(e,t,n,r){if(r&&typeof r==="object")if(Array.isArray(r))for(let i=0,o=r.length;i<o;++i){let s=r[i],a=$n(e,r,String(i),s);if(a===void 0)delete r[i];else if(a!==s)r[i]=a}else if(r instanceof Map)for(let i of Array.from(r.keys())){let o=r.get(i),s=$n(e,r,i,o);if(s===void 0)r.delete(i);else if(s!==o)r.set(i,s)}else if(r instanceof Set)for(let i of Array.from(r)){let o=$n(e,r,i,i);if(o===void 0)r.delete(i);else if(o!==i)r.delete(i),r.add(o)}else for(let[i,o]of Object.entries(r)){let s=$n(e,r,i,o);if(s===void 0)delete r[i];else if(s!==o)r[i]=s}return e.call(t,n,r)}Eb.applyReviver=$n});var ct=P(function(Rb){var Cb=N();function Il(e,t,n){if(Array.isArray(e))return e.map((r,i)=>Il(r,String(i),n));if(e&&typeof e.toJSON==="function"){if(!n||!Cb.hasAnchor(e))return e.toJSON(t,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(e,r),n.onCreate=(o)=>{r.res=o,delete n.onCreate};let i=e.toJSON(t,n);if(n.onCreate)n.onCreate(i);return i}if(typeof e==="bigint"&&!n?.keep)return Number(e);return e}Rb.toJS=Il});var Mr=P(function(Db){var Nb=Vo(),Nl=N(),zb=ct();class zl{constructor(e){Object.defineProperty(this,Nl.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if(this.range)e.range=this.range.slice();return e}toJS(e,{mapAsMap:t,maxAliasCount:n,onAnchor:r,reviver:i}={}){if(!Nl.isDocument(e))throw TypeError("A document argument is required");let o={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof n==="number"?n:100},s=zb.toJS(this,"",o);if(typeof r==="function")for(let{count:a,res:c}of o.anchors.values())r(c,a);return typeof i==="function"?Nb.applyReviver(i,{"":s},"",s):s}}Db.NodeBase=zl});var Pn=P(function(Gb){var jb=jr(),Mb=An(),Wt=N(),Ub=Mr(),Zb=ct();class Dl extends Ub.NodeBase{constructor(e){super(Wt.ALIAS);this.source=e,Object.defineProperty(this,"tag",{set(){throw Error("Alias nodes cannot have tags")}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError("Alias resolution is disabled");let n;if(t?.aliasResolveCache)n=t.aliasResolveCache;else if(n=[],Mb.visit(e,{Node:(i,o)=>{if(Wt.isAlias(o)||Wt.hasAnchor(o))n.push(o)}}),t)t.aliasResolveCache=n;let r=void 0;for(let i of n){if(i===this)break;if(i.anchor===this.source)r=i}if(r&&t){let{anchors:i,doc:o,maxAliasCount:s}=t,a=i.get(r);if(!a)Zb.toJS(r,null,t),a=i.get(r);if(a?.res===void 0)throw ReferenceError("This should not happen: Alias anchor was not resolved?");if(s>=0){if(a.count+=1,a.aliasCount===0)a.aliasCount=Ur(o,r,i);if(a.count*a.aliasCount>s)throw ReferenceError("Excessive alias count indicates a resource exhaustion attack")}}return r}toJSON(e,t){if(!t)return{source:this.source};let n=this.resolve(t.doc,t);if(!n){let r=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(r)}return t.anchors.get(n).res}toString(e,t,n){let r=`*${this.source}`;if(e){if(jb.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let i=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(i)}if(e.implicitKey)return`${r} `}return r}}function Ur(e,t,n){if(Wt.isAlias(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}else if(Wt.isCollection(t)){let r=0;for(let i of t.items){let o=Ur(e,i,n);if(o>r)r=o}return r}else if(Wt.isPair(t)){let r=Ur(e,t.key,n),i=Ur(e,t.value,n);return Math.max(r,i)}return 1}Gb.Alias=Dl});var W=P(function(Wb){var Bb=N(),Hb=Mr(),Fb=ct(),Kb=(e)=>!e||typeof e!=="function"&&typeof e!=="object";class At extends Hb.NodeBase{constructor(e){super(Bb.SCALAR);this.value=e}toJSON(e,t){return t?.keep?this.value:Fb.toJS(this.value,e,t)}toString(){return String(this.value)}}At.BLOCK_FOLDED="BLOCK_FOLDED";At.BLOCK_LITERAL="BLOCK_LITERAL";At.PLAIN="PLAIN";At.QUOTE_DOUBLE="QUOTE_DOUBLE";At.QUOTE_SINGLE="QUOTE_SINGLE";Wb.Scalar=At;Wb.isScalarValue=Kb});var Tn=P(function(tw){var Jb=Pn(),$t=N(),Ll=W(),Qb="tag:yaml.org,2002:";function Xb(e,t,n){if(t){let r=n.filter((o)=>o.tag===t),i=r.find((o)=>!o.format)??r[0];if(!i)throw Error(`Tag ${t} not found`);return i}return n.find((r)=>r.identify?.(e)&&!r.format)}function ew(e,t,n){if($t.isDocument(e))e=e.contents;if($t.isNode(e))return e;if($t.isPair(e)){let p=n.schema[$t.MAP].createNode?.(n.schema,null,n);return p.items.push(e),p}if(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)e=e.valueOf();let{aliasDuplicateObjects:r,onAnchor:i,onTagObj:o,schema:s,sourceObjects:a}=n,c=void 0;if(r&&e&&typeof e==="object")if(c=a.get(e),c)return c.anchor??(c.anchor=i(e)),new Jb.Alias(c.anchor);else c={anchor:null,node:null},a.set(e,c);if(t?.startsWith("!!"))t=Qb+t.slice(2);let l=Xb(e,t,s.tags);if(!l){if(e&&typeof e.toJSON==="function")e=e.toJSON();if(!e||typeof e!=="object"){let p=new Ll.Scalar(e);if(c)c.node=p;return p}l=e instanceof Map?s[$t.MAP]:(Symbol.iterator in Object(e))?s[$t.SEQ]:s[$t.MAP]}if(o)o(l),delete n.onTagObj;let u=l?.createNode?l.createNode(n.schema,e,n):typeof l?.nodeClass?.from==="function"?l.nodeClass.from(n.schema,e,n):new Ll.Scalar(e);if(t)u.tag=t;else if(!l.default)u.tag=l.tag;if(c)c.node=u;return u}tw.createNode=ew});var Zr=P(function(ow){var rw=Tn(),je=N(),iw=Mr();function Yo(e,t,n){let r=n;for(let i=t.length-1;i>=0;--i){let o=t[i];if(typeof o==="number"&&Number.isInteger(o)&&o>=0){let s=[];s[o]=r,r=s}else r=new Map([[o,r]])}return rw.createNode(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}var jl=(e)=>e==null||typeof e==="object"&&!!e[Symbol.iterator]().next().done;class Ml extends iw.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));if(e)t.schema=e;if(t.items=t.items.map((n)=>je.isNode(n)||je.isPair(n)?n.clone(e):n),this.range)t.range=this.range.slice();return t}addIn(e,t){if(jl(e))this.add(t);else{let[n,...r]=e,i=this.get(n,!0);if(je.isCollection(i))i.addIn(r,t);else if(i===void 0&&this.schema)this.set(n,Yo(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}deleteIn(e){let[t,...n]=e;if(n.length===0)return this.delete(t);let r=this.get(t,!0);if(je.isCollection(r))return r.deleteIn(n);else throw Error(`Expected YAML collection at ${t}. Remaining path: ${n}`)}getIn(e,t){let[n,...r]=e,i=this.get(n,!0);if(r.length===0)return!t&&je.isScalar(i)?i.value:i;else return je.isCollection(i)?i.getIn(r,t):void 0}hasAllNullValues(e){return this.items.every((t)=>{if(!je.isPair(t))return!1;let n=t.value;return n==null||e&&je.isScalar(n)&&n.value==null&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(e){let[t,...n]=e;if(n.length===0)return this.has(t);let r=this.get(t,!0);return je.isCollection(r)?r.hasIn(n):!1}setIn(e,t){let[n,...r]=e;if(r.length===0)this.set(n,t);else{let i=this.get(n,!0);if(je.isCollection(i))i.setIn(r,t);else if(i===void 0&&this.schema)this.set(n,Yo(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}}ow.Collection=Ml;ow.collectionFromPath=Yo;ow.isEmptyPath=jl});var En=P(function(pw){var lw=(e)=>e.replace(/^(?!$)(?: $)?/gm,"#");function Jo(e,t){if(/^\n+$/.test(e))return e.substring(1);return t?e.replace(/^(?! *$)/gm,t):e}var uw=(e,t,n)=>e.endsWith(`
|
|
5
|
+
`)?Jo(n,t):n.includes(`
|
|
6
|
+
`)?`
|
|
7
|
+
`+Jo(n,t):(e.endsWith(" ")?"":" ")+n;pw.indentComment=Jo;pw.lineComment=uw;pw.stringifyComment=lw});var Zl=P(function(gw){function mw(e,t,n="flow",{indentAtStart:r,lineWidth:i=80,minContentWidth:o=20,onFold:s,onOverflow:a}={}){if(!i||i<0)return e;if(i<o)o=0;let c=Math.max(1+o,1+i-t.length);if(e.length<=c)return e;let l=[],u={},p=i-t.length;if(typeof r==="number")if(r>i-Math.max(2,o))l.push(0);else p=i-r;let d=void 0,h=void 0,f=!1,m=-1,g=-1,w=-1;if(n==="block"){if(m=Ul(e,m,t.length),m!==-1)p=m+c}for(let _;_=e[m+=1];){if(n==="quoted"&&_==="\\"){switch(g=m,e[m+1]){case"x":m+=3;break;case"u":m+=5;break;case"U":m+=9;break;default:m+=1}w=m}if(_===`
|
|
8
|
+
`){if(n==="block")m=Ul(e,m,t.length);p=m+t.length+c,d=void 0}else{if(_===" "&&h&&h!==" "&&h!==`
|
|
9
|
+
`&&h!=="\t"){let b=e[m+1];if(b&&b!==" "&&b!==`
|
|
10
|
+
`&&b!=="\t")d=m}if(m>=p)if(d)l.push(d),p=d+c,d=void 0;else if(n==="quoted"){while(h===" "||h==="\t")h=_,_=e[m+=1],f=!0;let b=m>w+1?m-2:g-1;if(u[b])return e;l.push(b),u[b]=!0,p=b+c,d=void 0}else f=!0}h=_}if(f&&a)a();if(l.length===0)return e;if(s)s();let x=e.slice(0,l[0]);for(let _=0;_<l.length;++_){let b=l[_],k=l[_+1]||e.length;if(b===0)x=`
|
|
11
|
+
${t}${e.slice(0,k)}`;else{if(n==="quoted"&&u[b])x+=`${e[b]}\\`;x+=`
|
|
12
|
+
${t}${e.slice(b+1,k)}`}}return x}function Ul(e,t,n){let r=t,i=t+1,o=e[i];while(o===" "||o==="\t")if(t<i+n)o=e[++t];else{do o=e[++t];while(o&&o!==`
|
|
13
|
+
`);r=t,i=t+1,o=e[i]}return r}gw.FOLD_BLOCK="block";gw.FOLD_FLOW="flow";gw.FOLD_QUOTED="quoted";gw.foldFlowLines=mw});var Cn=P(function(Sw){var Ce=W(),lt=Zl(),qr=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),Br=(e)=>/^(%|---|\.\.\.)/m.test(e);function _w(e,t,n){if(!t||t<0)return!1;let r=t-n,i=e.length;if(i<=r)return!1;for(let o=0,s=0;o<i;++o)if(e[o]===`
|
|
14
|
+
`){if(o-s>r)return!0;if(s=o+1,i-s<=r)return!1}return!0}function On(e,t){let n=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=t,i=t.options.doubleQuotedMinMultiLineLength,o=t.indent||(Br(e)?" ":""),s="",a=0;for(let c=0,l=n[c];l;l=n[++c]){if(l===" "&&n[c+1]==="\\"&&n[c+2]==="n")s+=n.slice(a,c)+"\\ ",c+=1,a=c,l="\\";if(l==="\\")switch(n[c+1]){case"u":{s+=n.slice(a,c);let u=n.substr(c+2,4);switch(u){case"0000":s+="\\0";break;case"0007":s+="\\a";break;case"000b":s+="\\v";break;case"001b":s+="\\e";break;case"0085":s+="\\N";break;case"00a0":s+="\\_";break;case"2028":s+="\\L";break;case"2029":s+="\\P";break;default:if(u.substr(0,2)==="00")s+="\\x"+u.substr(2);else s+=n.substr(c,6)}c+=5,a=c+1}break;case"n":if(r||n[c+2]==='"'||n.length<i)c+=1;else{s+=n.slice(a,c)+`
|
|
15
|
+
|
|
16
|
+
`;while(n[c+2]==="\\"&&n[c+3]==="n"&&n[c+4]!=='"')s+=`
|
|
17
|
+
`,c+=2;if(s+=o,n[c+2]===" ")s+="\\";c+=1,a=c+1}break;default:c+=1}}return s=a?s+n.slice(a):n,r?s:lt.foldFlowLines(s,o,lt.FOLD_QUOTED,qr(t,!1))}function Qo(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
|
|
18
|
+
`)||/[ \t]\n|\n[ \t]/.test(e))return On(e,t);let n=t.indent||(Br(e)?" ":""),r="'"+e.replace(/'/g,"''").replace(/\n+/g,`$&
|
|
19
|
+
${n}`)+"'";return t.implicitKey?r:lt.foldFlowLines(r,n,lt.FOLD_FLOW,qr(t,!1))}function Vt(e,t){let{singleQuote:n}=t.options,r;if(n===!1)r=On;else{let i=e.includes('"'),o=e.includes("'");if(i&&!o)r=Qo;else if(o&&!i)r=On;else r=n?Qo:On}return r(e,t)}var Xo;try{Xo=new RegExp(`(^|(?<!
|
|
20
|
+
))
|
|
21
|
+
+(?!
|
|
22
|
+
|$)`,"g")}catch{Xo=/\n+(?!\n|$)/g}function Gr({comment:e,type:t,value:n},r,i,o){let{blockQuote:s,commentString:a,lineWidth:c}=r.options;if(!s||/\n[\t ]+$/.test(n))return Vt(n,r);let l=r.indent||(r.forceBlockIndent||Br(n)?" ":""),u=s==="literal"?!0:s==="folded"||t===Ce.Scalar.BLOCK_FOLDED?!1:t===Ce.Scalar.BLOCK_LITERAL?!0:!_w(n,c,l.length);if(!n)return u?`|
|
|
23
|
+
`:`>
|
|
24
|
+
`;let p,d;for(d=n.length;d>0;--d){let k=n[d-1];if(k!==`
|
|
25
|
+
`&&k!=="\t"&&k!==" ")break}let h=n.substring(d),f=h.indexOf(`
|
|
26
|
+
`);if(f===-1)p="-";else if(n===h||f!==h.length-1){if(p="+",o)o()}else p="";if(h){if(n=n.slice(0,-h.length),h[h.length-1]===`
|
|
27
|
+
`)h=h.slice(0,-1);h=h.replace(Xo,`$&${l}`)}let m=!1,g,w=-1;for(g=0;g<n.length;++g){let k=n[g];if(k===" ")m=!0;else if(k===`
|
|
28
|
+
`)w=g;else break}let x=n.substring(0,w<g?w+1:g);if(x)n=n.substring(x.length),x=x.replace(/\n+/g,`$&${l}`);let b=(m?l?"2":"1":"")+p;if(e){if(b+=" "+a(e.replace(/ ?[\r\n]+/g," ")),i)i()}if(!u){let k=n.replace(/\n+/g,`
|
|
29
|
+
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${l}`),S=!1,O=qr(r,!0);if(s!=="folded"&&t!==Ce.Scalar.BLOCK_FOLDED)O.onOverflow=()=>{S=!0};let A=lt.foldFlowLines(`${x}${k}${h}`,l,lt.FOLD_BLOCK,O);if(!S)return`>${b}
|
|
30
|
+
${l}${A}`}return n=n.replace(/\n+/g,`$&${l}`),`|${b}
|
|
31
|
+
${l}${x}${n}${h}`}function kw(e,t,n,r){let{type:i,value:o}=e,{actualString:s,implicitKey:a,indent:c,indentStep:l,inFlow:u}=t;if(a&&o.includes(`
|
|
32
|
+
`)||u&&/[[\]{},]/.test(o))return Vt(o,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(o))return a||u||!o.includes(`
|
|
33
|
+
`)?Vt(o,t):Gr(e,t,n,r);if(!a&&!u&&i!==Ce.Scalar.PLAIN&&o.includes(`
|
|
34
|
+
`))return Gr(e,t,n,r);if(Br(o)){if(c==="")return t.forceBlockIndent=!0,Gr(e,t,n,r);else if(a&&c===l)return Vt(o,t)}let p=o.replace(/\n+/g,`$&
|
|
35
|
+
${c}`);if(s){let d=(m)=>m.default&&m.tag!=="tag:yaml.org,2002:str"&&m.test?.test(p),{compat:h,tags:f}=t.doc.schema;if(f.some(d)||h?.some(d))return Vt(o,t)}return a?p:lt.foldFlowLines(p,c,lt.FOLD_FLOW,qr(t,!1))}function xw(e,t,n,r){let{implicitKey:i,inFlow:o}=t,s=typeof e.value==="string"?e:Object.assign({},e,{value:String(e.value)}),{type:a}=e;if(a!==Ce.Scalar.QUOTE_DOUBLE){if(/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(s.value))a=Ce.Scalar.QUOTE_DOUBLE}let c=(u)=>{switch(u){case Ce.Scalar.BLOCK_FOLDED:case Ce.Scalar.BLOCK_LITERAL:return i||o?Vt(s.value,t):Gr(s,t,n,r);case Ce.Scalar.QUOTE_DOUBLE:return On(s.value,t);case Ce.Scalar.QUOTE_SINGLE:return Qo(s.value,t);case Ce.Scalar.PLAIN:return kw(s,t,n,r);default:return null}},l=c(a);if(l===null){let{defaultKeyType:u,defaultStringType:p}=t.options,d=i&&u||p;if(l=c(d),l===null)throw Error(`Unsupported default string type ${d}`)}return l}Sw.stringifyString=xw});var Rn=P(function(Iw){var $w=jr(),ut=N(),Pw=En(),Tw=Cn();function Ew(e,t){let n=Object.assign({blockQuote:!0,commentString:Pw.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),r;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:typeof n.indent==="number"?" ".repeat(n.indent):" ",inFlow:r,options:n}}function Ow(e,t){if(t.tag){let i=e.filter((o)=>o.tag===t.tag);if(i.length>0)return i.find((o)=>o.format===t.format)??i[0]}let n=void 0,r;if(ut.isScalar(t)){r=t.value;let i=e.filter((o)=>o.identify?.(r));if(i.length>1){let o=i.filter((s)=>s.test);if(o.length>0)i=o}n=i.find((o)=>o.format===t.format)??i.find((o)=>!o.format)}else r=t,n=e.find((i)=>i.nodeClass&&r instanceof i.nodeClass);if(!n){let i=r?.constructor?.name??(r===null?"null":typeof r);throw Error(`Tag not resolved for ${i} value`)}return n}function Cw(e,t,{anchors:n,doc:r}){if(!r.directives)return"";let i=[],o=(ut.isScalar(e)||ut.isCollection(e))&&e.anchor;if(o&&$w.anchorIsValid(o))n.add(o),i.push(`&${o}`);let s=e.tag??(t.default?null:t.tag);if(s)i.push(r.directives.tagString(s));return i.join(" ")}function Rw(e,t,n,r){if(ut.isPair(e))return e.toString(t,n,r);if(ut.isAlias(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError("Cannot stringify circular structure without alias nodes");else{if(t.resolvedAliases)t.resolvedAliases.add(e);else t.resolvedAliases=new Set([e]);e=e.resolve(t.doc)}}let i=void 0,o=ut.isNode(e)?e:t.doc.createNode(e,{onTagObj:(c)=>i=c});i??(i=Ow(t.doc.schema.tags,o));let s=Cw(o,i,t);if(s.length>0)t.indentAtStart=(t.indentAtStart??0)+s.length+1;let a=typeof i.stringify==="function"?i.stringify(o,t,n,r):ut.isScalar(o)?Tw.stringifyString(o,t,n,r):o.toString(t,n,r);if(!s)return a;return ut.isScalar(o)||a[0]==="{"||a[0]==="["?`${s} ${a}`:`${s}
|
|
36
|
+
${t.indent}${a}`}Iw.createStringifyContext=Ew;Iw.stringify=Rw});var Bl=P(function(Lw){var Qe=N(),Gl=W(),ql=Rn(),In=En();function Dw({key:e,value:t},n,r,i){let{allNullValues:o,doc:s,indent:a,indentStep:c,options:{commentString:l,indentSeq:u,simpleKeys:p}}=n,d=Qe.isNode(e)&&e.comment||null;if(p){if(d)throw Error("With simple keys, key nodes cannot have comments");if(Qe.isCollection(e)||!Qe.isNode(e)&&typeof e==="object")throw Error("With simple keys, collection cannot be used as a key value")}let h=!p&&(!e||d&&t==null&&!n.inFlow||Qe.isCollection(e)||(Qe.isScalar(e)?e.type===Gl.Scalar.BLOCK_FOLDED||e.type===Gl.Scalar.BLOCK_LITERAL:typeof e==="object"));n=Object.assign({},n,{allNullValues:!1,implicitKey:!h&&(p||!o),indent:a+c});let f=!1,m=!1,g=ql.stringify(e,n,()=>f=!0,()=>m=!0);if(!h&&!n.inFlow&&g.length>1024){if(p)throw Error("With simple keys, single line scalar must not span more than 1024 characters");h=!0}if(n.inFlow){if(o||t==null){if(f&&r)r();return g===""?"?":h?`? ${g}`:g}}else if(o&&!p||t==null&&h){if(g=`? ${g}`,d&&!f)g+=In.lineComment(g,n.indent,l(d));else if(m&&i)i();return g}if(f)d=null;if(h){if(d)g+=In.lineComment(g,n.indent,l(d));g=`? ${g}
|
|
37
|
+
${a}:`}else if(g=`${g}:`,d)g+=In.lineComment(g,n.indent,l(d));let w,x,_;if(Qe.isNode(t))w=!!t.spaceBefore,x=t.commentBefore,_=t.comment;else if(w=!1,x=null,_=null,t&&typeof t==="object")t=s.createNode(t);if(n.implicitKey=!1,!h&&!d&&Qe.isScalar(t))n.indentAtStart=g.length+1;if(m=!1,!u&&c.length>=2&&!n.inFlow&&!h&&Qe.isSeq(t)&&!t.flow&&!t.tag&&!t.anchor)n.indent=n.indent.substring(2);let b=!1,k=ql.stringify(t,n,()=>b=!0,()=>m=!0),S=" ";if(d||w||x){if(S=w?`
|
|
38
|
+
`:"",x){let O=l(x);S+=`
|
|
39
|
+
${In.indentComment(O,n.indent)}`}if(k===""&&!n.inFlow){if(S===`
|
|
40
|
+
`&&_)S=`
|
|
41
|
+
|
|
42
|
+
`}else S+=`
|
|
43
|
+
${n.indent}`}else if(!h&&Qe.isCollection(t)){let O=k[0],A=k.indexOf(`
|
|
44
|
+
`),L=A!==-1,ae=n.inFlow??t.flow??t.items.length===0;if(L||!ae){let ke=!1;if(L&&(O==="&"||O==="!")){let B=k.indexOf(" ");if(O==="&"&&B!==-1&&B<A&&k[B+1]==="!")B=k.indexOf(" ",B+1);if(B===-1||A<B)ke=!0}if(!ke)S=`
|
|
45
|
+
${n.indent}`}}else if(k===""||k[0]===`
|
|
46
|
+
`)S="";if(g+=S+k,n.inFlow){if(b&&r)r()}else if(_&&!b)g+=In.lineComment(g,n.indent,l(_));else if(m&&i)i();return g}Lw.stringifyPair=Dw});var es=P(function(Zw){var Hl=Oe("process");function Mw(e,...t){if(e==="debug")console.log(...t)}function Uw(e,t){if(e==="debug"||e==="warn")if(typeof Hl.emitWarning==="function")Hl.emitWarning(t);else console.warn(t)}Zw.debug=Mw;Zw.warn=Uw});var Wr=P(function(Hw){var Kr=N(),Fl=W(),Hr="<<",Fr={identify:(e)=>e===Hr||typeof e==="symbol"&&e.description===Hr,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new Fl.Scalar(Symbol(Hr)),{addToJSMap:Kl}),stringify:()=>Hr},Bw=(e,t)=>(Fr.identify(t)||Kr.isScalar(t)&&(!t.type||t.type===Fl.Scalar.PLAIN)&&Fr.identify(t.value))&&e?.doc.schema.tags.some((n)=>n.tag===Fr.tag&&n.default);function Kl(e,t,n){let r=Wl(e,n);if(Kr.isSeq(r))for(let i of r.items)ts(e,t,i);else if(Array.isArray(r))for(let i of r)ts(e,t,i);else ts(e,t,r)}function ts(e,t,n){let r=Wl(e,n);if(!Kr.isMap(r))throw Error("Merge sources must be maps or map aliases");let i=r.toJSON(null,e,Map);for(let[o,s]of i)if(t instanceof Map){if(!t.has(o))t.set(o,s)}else if(t instanceof Set)t.add(o);else if(!Object.prototype.hasOwnProperty.call(t,o))Object.defineProperty(t,o,{value:s,writable:!0,enumerable:!0,configurable:!0});return t}function Wl(e,t){return e&&Kr.isAlias(t)?t.resolve(e.doc,e):t}Hw.addMergeToJSMap=Kl;Hw.isMergeKey=Bw;Hw.merge=Fr});var rs=P(function(Xw){var Vw=es(),Vl=Wr(),Yw=Rn(),Yl=N(),ns=ct();function Jw(e,t,{key:n,value:r}){if(Yl.isNode(n)&&n.addToJSMap)n.addToJSMap(e,t,r);else if(Vl.isMergeKey(e,n))Vl.addMergeToJSMap(e,t,r);else{let i=ns.toJS(n,"",e);if(t instanceof Map)t.set(i,ns.toJS(r,i,e));else if(t instanceof Set)t.add(i);else{let o=Qw(n,i,e),s=ns.toJS(r,o,e);if(o in t)Object.defineProperty(t,o,{value:s,writable:!0,enumerable:!0,configurable:!0});else t[o]=s}}return t}function Qw(e,t,n){if(t===null)return"";if(typeof t!=="object")return String(t);if(Yl.isNode(e)&&n?.doc){let r=Yw.createStringifyContext(n.doc,{});r.anchors=new Set;for(let o of n.anchors.keys())r.anchors.add(o.anchor);r.inFlow=!0,r.inStringifyKey=!0;let i=e.toString(r);if(!n.mapKeyWarned){let o=JSON.stringify(i);if(o.length>40)o=o.substring(0,36)+'..."';Vw.warn(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${o}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return i}return JSON.stringify(t)}Xw.addPairToJSMap=Jw});var pt=P(function(i0){var Jl=Tn(),t0=Bl(),n0=rs(),Vr=N();function r0(e,t,n){let r=Jl.createNode(e,void 0,n),i=Jl.createNode(t,void 0,n);return new Yr(r,i)}class Yr{constructor(e,t=null){Object.defineProperty(this,Vr.NODE_TYPE,{value:Vr.PAIR}),this.key=e,this.value=t}clone(e){let{key:t,value:n}=this;if(Vr.isNode(t))t=t.clone(e);if(Vr.isNode(n))n=n.clone(e);return new Yr(t,n)}toJSON(e,t){let n=t?.mapAsMap?new Map:{};return n0.addPairToJSMap(t,n,this)}toString(e,t,n){return e?.doc?t0.stringifyPair(this,e,t,n):JSON.stringify(this)}}i0.Pair=Yr;i0.createPair=r0});var is=P(function(u0){var Pt=N(),Ql=Rn(),Jr=En();function a0(e,t,n){return(t.inFlow??e.flow?l0:c0)(e,t,n)}function c0({comment:e,items:t},n,{blockItemPrefix:r,flowChars:i,itemIndent:o,onChompKeep:s,onComment:a}){let{indent:c,options:{commentString:l}}=n,u=Object.assign({},n,{indent:o,type:null}),p=!1,d=[];for(let f=0;f<t.length;++f){let m=t[f],g=null;if(Pt.isNode(m)){if(!p&&m.spaceBefore)d.push("");if(Qr(n,d,m.commentBefore,p),m.comment)g=m.comment}else if(Pt.isPair(m)){let x=Pt.isNode(m.key)?m.key:null;if(x){if(!p&&x.spaceBefore)d.push("");Qr(n,d,x.commentBefore,p)}}p=!1;let w=Ql.stringify(m,u,()=>g=null,()=>p=!0);if(g)w+=Jr.lineComment(w,o,l(g));if(p&&g)p=!1;d.push(r+w)}let h;if(d.length===0)h=i.start+i.end;else{h=d[0];for(let f=1;f<d.length;++f){let m=d[f];h+=m?`
|
|
47
|
+
${c}${m}`:`
|
|
48
|
+
`}}if(e){if(h+=`
|
|
49
|
+
`+Jr.indentComment(l(e),c),a)a()}else if(p&&s)s();return h}function l0({items:e},t,{flowChars:n,itemIndent:r}){let{indent:i,indentStep:o,flowCollectionPadding:s,options:{commentString:a}}=t;r+=o;let c=Object.assign({},t,{indent:r,inFlow:!0,type:null}),l=!1,u=0,p=[];for(let f=0;f<e.length;++f){let m=e[f],g=null;if(Pt.isNode(m)){if(m.spaceBefore)p.push("");if(Qr(t,p,m.commentBefore,!1),m.comment)g=m.comment}else if(Pt.isPair(m)){let x=Pt.isNode(m.key)?m.key:null;if(x){if(x.spaceBefore)p.push("");if(Qr(t,p,x.commentBefore,!1),x.comment)l=!0}let _=Pt.isNode(m.value)?m.value:null;if(_){if(_.comment)g=_.comment;if(_.commentBefore)l=!0}else if(m.value==null&&x?.comment)g=x.comment}if(g)l=!0;let w=Ql.stringify(m,c,()=>g=null);if(l||(l=p.length>u||w.includes(`
|
|
50
|
+
`)),f<e.length-1)w+=",";else if(t.options.trailingComma){if(t.options.lineWidth>0)l||(l=p.reduce((x,_)=>x+_.length+2,2)+(w.length+2)>t.options.lineWidth);if(l)w+=","}if(g)w+=Jr.lineComment(w,r,a(g));p.push(w),u=p.length}let{start:d,end:h}=n;if(p.length===0)return d+h;else{if(!l){let f=p.reduce((m,g)=>m+g.length+2,2);l=t.options.lineWidth>0&&f>t.options.lineWidth}if(l){let f=d;for(let m of p)f+=m?`
|
|
51
|
+
${o}${i}${m}`:`
|
|
52
|
+
`;return`${f}
|
|
53
|
+
${i}${h}`}else return`${d}${s}${p.join(" ")}${s}${h}`}}function Qr({indent:e,options:{commentString:t}},n,r,i){if(r&&i)r=r.replace(/^\n+/,"");if(r){let o=Jr.indentComment(t(r),e);n.push(o.trimStart())}}u0.stringifyCollection=a0});var ht=P(function(g0){var d0=is(),h0=rs(),f0=Zr(),dt=N(),Xr=pt(),m0=W();function Nn(e,t){let n=dt.isScalar(t)?t.value:t;for(let r of e)if(dt.isPair(r)){if(r.key===t||r.key===n)return r;if(dt.isScalar(r.key)&&r.key.value===n)return r}return}class Xl extends f0.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(dt.MAP,e);this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:i}=n,o=new this(e),s=(a,c)=>{if(typeof i==="function")c=i.call(t,a,c);else if(Array.isArray(i)&&!i.includes(a))return;if(c!==void 0||r)o.items.push(Xr.createPair(a,c,n))};if(t instanceof Map)for(let[a,c]of t)s(a,c);else if(t&&typeof t==="object")for(let a of Object.keys(t))s(a,t[a]);if(typeof e.sortMapEntries==="function")o.items.sort(e.sortMapEntries);return o}add(e,t){let n;if(dt.isPair(e))n=e;else if(!e||typeof e!=="object"||!("key"in e))n=new Xr.Pair(e,e?.value);else n=new Xr.Pair(e.key,e.value);let r=Nn(this.items,n.key),i=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);if(dt.isScalar(r.value)&&m0.isScalarValue(n.value))r.value.value=n.value;else r.value=n.value}else if(i){let o=this.items.findIndex((s)=>i(n,s)<0);if(o===-1)this.items.push(n);else this.items.splice(o,0,n)}else this.items.push(n)}delete(e){let t=Nn(this.items,e);if(!t)return!1;return this.items.splice(this.items.indexOf(t),1).length>0}get(e,t){let r=Nn(this.items,e)?.value;return(!t&&dt.isScalar(r)?r.value:r)??void 0}has(e){return!!Nn(this.items,e)}set(e,t){this.add(new Xr.Pair(e,t),!0)}toJSON(e,t,n){let r=n?new n:t?.mapAsMap?new Map:{};if(t?.onCreate)t.onCreate(r);for(let i of this.items)h0.addPairToJSMap(t,r,i);return r}toString(e,t,n){if(!e)return JSON.stringify(this);for(let r of this.items)if(!dt.isPair(r))throw Error(`Map items must all be pairs; found ${JSON.stringify(r)} instead`);if(!e.allNullValues&&this.hasAllNullValues(!1))e=Object.assign({},e,{allNullValues:!0});return d0.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:n,onComment:t})}}g0.YAMLMap=Xl;g0.findPair=Nn});var Yt=P(function(_0){var b0=N(),eu=ht(),w0={collection:"map",default:!0,nodeClass:eu.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(e,t){if(!b0.isMap(e))t("Expected a mapping for this tag");return e},createNode:(e,t,n)=>eu.YAMLMap.from(e,t,n)};_0.map=w0});var ft=P(function(T0){var x0=Tn(),S0=is(),A0=Zr(),ti=N(),$0=W(),P0=ct();class tu extends A0.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(ti.SEQ,e);this.items=[]}add(e){this.items.push(e)}delete(e){let t=ei(e);if(typeof t!=="number")return!1;return this.items.splice(t,1).length>0}get(e,t){let n=ei(e);if(typeof n!=="number")return;let r=this.items[n];return!t&&ti.isScalar(r)?r.value:r}has(e){let t=ei(e);return typeof t==="number"&&t<this.items.length}set(e,t){let n=ei(e);if(typeof n!=="number")throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];if(ti.isScalar(r)&&$0.isScalarValue(t))r.value=t;else this.items[n]=t}toJSON(e,t){let n=[];if(t?.onCreate)t.onCreate(n);let r=0;for(let i of this.items)n.push(P0.toJS(i,String(r++),t));return n}toString(e,t,n){if(!e)return JSON.stringify(this);return S0.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:n,onComment:t})}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t)){let o=0;for(let s of t){if(typeof r==="function"){let a=t instanceof Set?s:String(o++);s=r.call(t,a,s)}i.items.push(x0.createNode(s,void 0,n))}}return i}}function ei(e){let t=ti.isScalar(e)?e.value:e;if(t&&typeof t==="string")t=Number(t);return typeof t==="number"&&Number.isInteger(t)&&t>=0?t:null}T0.YAMLSeq=tu});var Jt=P(function(R0){var O0=N(),nu=ft(),C0={collection:"seq",default:!0,nodeClass:nu.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(e,t){if(!O0.isSeq(e))t("Expected a sequence for this tag");return e},createNode:(e,t,n)=>nu.YAMLSeq.from(e,t,n)};R0.seq=C0});var zn=P(function(D0){var N0=Cn(),z0={identify:(e)=>typeof e==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(e)=>e,stringify(e,t,n,r){return t=Object.assign({actualString:!0},t),N0.stringifyString(e,t,n,r)}};D0.string=z0});var ni=P(function(j0){var ru=W(),iu={identify:(e)=>e==null,createNode:()=>new ru.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new ru.Scalar(null),stringify:({source:e},t)=>typeof e==="string"&&iu.test.test(e)?e:t.options.nullStr};j0.nullTag=iu});var os=P(function(Z0){var U0=W(),ou={identify:(e)=>typeof e==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:(e)=>new U0.Scalar(e[0]==="t"||e[0]==="T"),stringify({source:e,value:t},n){if(e&&ou.test.test(e)){let r=e[0]==="t"||e[0]==="T";if(t===r)return e}return t?n.options.trueStr:n.options.falseStr}};Z0.boolTag=ou});var Qt=P(function(B0){function q0({format:e,minFractionDigits:t,tag:n,value:r}){if(typeof r==="bigint")return String(r);let i=typeof r==="number"?r:Number(r);if(!isFinite(i))return isNaN(i)?".nan":i<0?"-.inf":".inf";let o=Object.is(r,-0)?"-0":JSON.stringify(r);if(!e&&t&&(!n||n==="tag:yaml.org,2002:float")&&/^-?\d/.test(o)&&!o.includes("e")){let s=o.indexOf(".");if(s<0)s=o.length,o+=".";let a=t-(o.length-s-1);while(a-- >0)o+="0"}return o}B0.stringifyNumber=q0});var as=P(function(Y0){var F0=W(),ss=Qt(),K0={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:(e)=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:ss.stringifyNumber},W0={identify:(e)=>typeof e==="number",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():ss.stringifyNumber(e)}},V0={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let t=new F0.Scalar(parseFloat(e)),n=e.indexOf(".");if(n!==-1&&e[e.length-1]==="0")t.minFractionDigits=e.length-n-1;return t},stringify:ss.stringifyNumber};Y0.float=V0;Y0.floatExp=W0;Y0.floatNaN=K0});var ls=P(function(r_){var su=Qt(),ri=(e)=>typeof e==="bigint"||Number.isInteger(e),cs=(e,t,n,{intAsBigInt:r})=>r?BigInt(e):parseInt(e.substring(t),n);function au(e,t,n){let{value:r}=e;if(ri(r)&&r>=0)return n+r.toString(t);return su.stringifyNumber(e)}var e_={identify:(e)=>ri(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,n)=>cs(e,2,8,n),stringify:(e)=>au(e,8,"0o")},t_={identify:ri,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,n)=>cs(e,0,10,n),stringify:su.stringifyNumber},n_={identify:(e)=>ri(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,n)=>cs(e,2,16,n),stringify:(e)=>au(e,16,"0x")};r_.int=t_;r_.intHex=n_;r_.intOct=e_});var cu=P(function(h_){var a_=Yt(),c_=ni(),l_=Jt(),u_=zn(),p_=os(),us=as(),ps=ls(),d_=[a_.map,l_.seq,u_.string,c_.nullTag,p_.boolTag,ps.intOct,ps.int,ps.intHex,us.floatNaN,us.floatExp,us.float];h_.schema=d_});var uu=P(function(__){var m_=W(),g_=Yt(),v_=Jt();function lu(e){return typeof e==="bigint"||Number.isInteger(e)}var ii=({value:e})=>JSON.stringify(e),y_=[{identify:(e)=>typeof e==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(e)=>e,stringify:ii},{identify:(e)=>e==null,createNode:()=>new m_.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:ii},{identify:(e)=>typeof e==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:(e)=>e==="true",stringify:ii},{identify:lu,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>lu(e)?e.toString():JSON.stringify(e)},{identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:(e)=>parseFloat(e),stringify:ii}],b_={default:!0,tag:"",test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}},w_=[g_.map,v_.seq].concat(y_,b_);__.schema=w_});var hs=P(function(A_){var Dn=Oe("buffer"),ds=W(),x_=Cn(),S_={identify:(e)=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if(typeof Dn.Buffer==="function")return Dn.Buffer.from(e,"base64");else if(typeof atob==="function"){let n=atob(e.replace(/[\n\r]/g,"")),r=new Uint8Array(n.length);for(let i=0;i<n.length;++i)r[i]=n.charCodeAt(i);return r}else return t("This environment does not support reading binary tags; either Buffer or atob is required"),e},stringify({comment:e,type:t,value:n},r,i,o){if(!n)return"";let s=n,a;if(typeof Dn.Buffer==="function")a=s instanceof Dn.Buffer?s.toString("base64"):Dn.Buffer.from(s.buffer).toString("base64");else if(typeof btoa==="function"){let c="";for(let l=0;l<s.length;++l)c+=String.fromCharCode(s[l]);a=btoa(c)}else throw Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(t??(t=ds.Scalar.BLOCK_LITERAL),t!==ds.Scalar.QUOTE_DOUBLE){let c=Math.max(r.options.lineWidth-r.indent.length,r.options.minContentWidth),l=Math.ceil(a.length/c),u=Array(l);for(let p=0,d=0;p<l;++p,d+=c)u[p]=a.substr(d,c);a=u.join(t===ds.Scalar.BLOCK_LITERAL?`
|
|
54
|
+
`:" ")}return x_.stringifyString({comment:e,type:t,value:a},r,i,o)}};A_.binary=S_});var si=P(function(O_){var oi=N(),fs=pt(),P_=W(),T_=ft();function pu(e,t){if(oi.isSeq(e))for(let n=0;n<e.items.length;++n){let r=e.items[n];if(oi.isPair(r))continue;else if(oi.isMap(r)){if(r.items.length>1)t("Each pair must have its own sequence indicator");let i=r.items[0]||new fs.Pair(new P_.Scalar(null));if(r.commentBefore)i.key.commentBefore=i.key.commentBefore?`${r.commentBefore}
|
|
55
|
+
${i.key.commentBefore}`:r.commentBefore;if(r.comment){let o=i.value??i.key;o.comment=o.comment?`${r.comment}
|
|
56
|
+
${o.comment}`:r.comment}r=i}e.items[n]=oi.isPair(r)?r:new fs.Pair(r)}else t("Expected a sequence for this tag");return e}function du(e,t,n){let{replacer:r}=n,i=new T_.YAMLSeq(e);i.tag="tag:yaml.org,2002:pairs";let o=0;if(t&&Symbol.iterator in Object(t))for(let s of t){if(typeof r==="function")s=r.call(t,String(o++),s);let a,c;if(Array.isArray(s))if(s.length===2)a=s[0],c=s[1];else throw TypeError(`Expected [key, value] tuple: ${s}`);else if(s&&s instanceof Object){let l=Object.keys(s);if(l.length===1)a=l[0],c=s[a];else throw TypeError(`Expected tuple with one key, not ${l.length} keys`)}else a=s;i.items.push(fs.createPair(a,c,n))}return i}var E_={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:pu,createNode:du};O_.createPairs=du;O_.pairs=E_;O_.resolvePairs=pu});var gs=P(function(D_){var hu=N(),ms=ct(),Ln=ht(),N_=ft(),fu=si();class Tt extends N_.YAMLSeq{constructor(){super();this.add=Ln.YAMLMap.prototype.add.bind(this),this.delete=Ln.YAMLMap.prototype.delete.bind(this),this.get=Ln.YAMLMap.prototype.get.bind(this),this.has=Ln.YAMLMap.prototype.has.bind(this),this.set=Ln.YAMLMap.prototype.set.bind(this),this.tag=Tt.tag}toJSON(e,t){if(!t)return super.toJSON(e);let n=new Map;if(t?.onCreate)t.onCreate(n);for(let r of this.items){let i,o;if(hu.isPair(r))i=ms.toJS(r.key,"",t),o=ms.toJS(r.value,i,t);else i=ms.toJS(r,"",t);if(n.has(i))throw Error("Ordered maps must not include duplicate keys");n.set(i,o)}return n}static from(e,t,n){let r=fu.createPairs(e,t,n),i=new this;return i.items=r.items,i}}Tt.tag="tag:yaml.org,2002:omap";var z_={collection:"seq",identify:(e)=>e instanceof Map,nodeClass:Tt,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let n=fu.resolvePairs(e,t),r=[];for(let{key:i}of n.items)if(hu.isScalar(i))if(r.includes(i.value))t(`Ordered maps must not include duplicate keys: ${i.value}`);else r.push(i.value);return Object.assign(new Tt,n)},createNode:(e,t,n)=>Tt.from(e,t,n)};D_.YAMLOMap=Tt;D_.omap=z_});var bu=P(function(M_){var mu=W();function gu({value:e,source:t},n){if(t&&(e?vu:yu).test.test(t))return t;return e?n.options.trueStr:n.options.falseStr}var vu={identify:(e)=>e===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new mu.Scalar(!0),stringify:gu},yu={identify:(e)=>e===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new mu.Scalar(!1),stringify:gu};M_.falseTag=yu;M_.trueTag=vu});var wu=P(function(F_){var G_=W(),vs=Qt(),q_={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:(e)=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:vs.stringifyNumber},B_={identify:(e)=>typeof e==="number",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():vs.stringifyNumber(e)}},H_={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new G_.Scalar(parseFloat(e.replace(/_/g,""))),n=e.indexOf(".");if(n!==-1){let r=e.substring(n+1).replace(/_/g,"");if(r[r.length-1]==="0")t.minFractionDigits=r.length}return t},stringify:vs.stringifyNumber};F_.float=H_;F_.floatExp=B_;F_.floatNaN=q_});var ku=P(function(ek){var _u=Qt(),jn=(e)=>typeof e==="bigint"||Number.isInteger(e);function ai(e,t,n,{intAsBigInt:r}){let i=e[0];if(i==="-"||i==="+")t+=1;if(e=e.substring(t).replace(/_/g,""),r){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let s=BigInt(e);return i==="-"?BigInt(-1)*s:s}let o=parseInt(e,n);return i==="-"?-1*o:o}function ys(e,t,n){let{value:r}=e;if(jn(r)){let i=r.toString(t);return r<0?"-"+n+i.substr(1):n+i}return _u.stringifyNumber(e)}var Y_={identify:jn,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>ai(e,2,2,n),stringify:(e)=>ys(e,2,"0b")},J_={identify:jn,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>ai(e,1,8,n),stringify:(e)=>ys(e,8,"0")},Q_={identify:jn,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>ai(e,0,10,n),stringify:_u.stringifyNumber},X_={identify:jn,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>ai(e,2,16,n),stringify:(e)=>ys(e,16,"0x")};ek.int=Q_;ek.intBin=Y_;ek.intHex=X_;ek.intOct=J_});var bs=P(function(sk){var ui=N(),ci=pt(),li=ht();class Et extends li.YAMLMap{constructor(e){super(e);this.tag=Et.tag}add(e){let t;if(ui.isPair(e))t=e;else if(e&&typeof e==="object"&&"key"in e&&"value"in e&&e.value===null)t=new ci.Pair(e.key,null);else t=new ci.Pair(e,null);if(!li.findPair(this.items,t.key))this.items.push(t)}get(e,t){let n=li.findPair(this.items,e);return!t&&ui.isPair(n)?ui.isScalar(n.key)?n.key.value:n.key:n}set(e,t){if(typeof t!=="boolean")throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let n=li.findPair(this.items,e);if(n&&!t)this.items.splice(this.items.indexOf(n),1);else if(!n&&t)this.items.push(new ci.Pair(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);else throw Error("Set items must all have null values")}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t))for(let o of t){if(typeof r==="function")o=r.call(t,o,o);i.items.push(ci.createPair(o,null,n))}return i}}Et.tag="tag:yaml.org,2002:set";var ok={collection:"map",identify:(e)=>e instanceof Set,nodeClass:Et,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,n)=>Et.from(e,t,n),resolve(e,t){if(ui.isMap(e))if(e.hasAllNullValues(!0))return Object.assign(new Et,e);else t("Set items must all have null values");else t("Expected a mapping for this tag");return e}};sk.YAMLSet=Et;sk.set=ok});var _s=P(function(dk){var lk=Qt();function ws(e,t){let n=e[0],r=n==="-"||n==="+"?e.substring(1):e,i=(s)=>t?BigInt(s):Number(s),o=r.replace(/_/g,"").split(":").reduce((s,a)=>s*i(60)+i(a),i(0));return n==="-"?i(-1)*o:o}function xu(e){let{value:t}=e,n=(s)=>s;if(typeof t==="bigint")n=(s)=>BigInt(s);else if(isNaN(t)||!isFinite(t))return lk.stringifyNumber(e);let r="";if(t<0)r="-",t*=n(-1);let i=n(60),o=[t%i];if(t<60)o.unshift(0);else if(t=(t-o[0])/i,o.unshift(t%i),t>=60)t=(t-o[0])/i,o.unshift(t);return r+o.map((s)=>String(s).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var uk={identify:(e)=>typeof e==="bigint"||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:n})=>ws(e,n),stringify:xu},pk={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:(e)=>ws(e,!1),stringify:xu},Su={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(Su.test);if(!t)throw Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,n,r,i,o,s,a]=t.map(Number),c=t[7]?Number((t[7]+"00").substr(1,3)):0,l=Date.UTC(n,r-1,i,o||0,s||0,a||0,c),u=t[8];if(u&&u!=="Z"){let p=ws(u,!1);if(Math.abs(p)<30)p*=60;l-=60000*p}return new Date(l)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};dk.floatTime=pk;dk.intTime=uk;dk.timestamp=Su});var $u=P(function($k){var gk=Yt(),vk=ni(),yk=Jt(),bk=zn(),wk=hs(),Au=bu(),ks=wu(),pi=ku(),_k=Wr(),kk=gs(),xk=si(),Sk=bs(),xs=_s(),Ak=[gk.map,yk.seq,bk.string,vk.nullTag,Au.trueTag,Au.falseTag,pi.intBin,pi.intOct,pi.int,pi.intHex,ks.floatNaN,ks.floatExp,ks.float,wk.binary,_k.merge,kk.omap,xk.pairs,Sk.set,xs.intTime,xs.floatTime,xs.timestamp];$k.schema=Ak});var Du=P(function(zk){var Ou=Yt(),Tk=ni(),Cu=Jt(),Ek=zn(),Ok=os(),Ss=as(),As=ls(),Ck=cu(),Rk=uu(),Ru=hs(),Mn=Wr(),Iu=gs(),Nu=si(),Pu=$u(),zu=bs(),di=_s(),Tu=new Map([["core",Ck.schema],["failsafe",[Ou.map,Cu.seq,Ek.string]],["json",Rk.schema],["yaml11",Pu.schema],["yaml-1.1",Pu.schema]]),Eu={binary:Ru.binary,bool:Ok.boolTag,float:Ss.float,floatExp:Ss.floatExp,floatNaN:Ss.floatNaN,floatTime:di.floatTime,int:As.int,intHex:As.intHex,intOct:As.intOct,intTime:di.intTime,map:Ou.map,merge:Mn.merge,null:Tk.nullTag,omap:Iu.omap,pairs:Nu.pairs,seq:Cu.seq,set:zu.set,timestamp:di.timestamp},Ik={"tag:yaml.org,2002:binary":Ru.binary,"tag:yaml.org,2002:merge":Mn.merge,"tag:yaml.org,2002:omap":Iu.omap,"tag:yaml.org,2002:pairs":Nu.pairs,"tag:yaml.org,2002:set":zu.set,"tag:yaml.org,2002:timestamp":di.timestamp};function Nk(e,t,n){let r=Tu.get(t);if(r&&!e)return n&&!r.includes(Mn.merge)?r.concat(Mn.merge):r.slice();let i=r;if(!i)if(Array.isArray(e))i=[];else{let o=Array.from(Tu.keys()).filter((s)=>s!=="yaml11").map((s)=>JSON.stringify(s)).join(", ");throw Error(`Unknown schema "${t}"; use one of ${o} or define customTags array`)}if(Array.isArray(e))for(let o of e)i=i.concat(o);else if(typeof e==="function")i=e(i.slice());if(n)i=i.concat(Mn.merge);return i.reduce((o,s)=>{let a=typeof s==="string"?Eu[s]:s;if(!a){let c=JSON.stringify(s),l=Object.keys(Eu).map((u)=>JSON.stringify(u)).join(", ");throw Error(`Unknown custom tag ${c}; use one of ${l}`)}if(!o.includes(a))o.push(a);return o},[])}zk.coreKnownTags=Ik;zk.getTags=Nk});var Ts=P(function(Gk){var $s=N(),jk=Yt(),Mk=Jt(),Uk=zn(),hi=Du(),Zk=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0;class Ps{constructor({compat:e,customTags:t,merge:n,resolveKnownTags:r,schema:i,sortMapEntries:o,toStringDefaults:s}){this.compat=Array.isArray(e)?hi.getTags(e,"compat"):e?hi.getTags(null,e):null,this.name=typeof i==="string"&&i||"core",this.knownTags=r?hi.coreKnownTags:{},this.tags=hi.getTags(t,this.name,n),this.toStringOptions=s??null,Object.defineProperty(this,$s.MAP,{value:jk.map}),Object.defineProperty(this,$s.SCALAR,{value:Uk.string}),Object.defineProperty(this,$s.SEQ,{value:Mk.seq}),this.sortMapEntries=typeof o==="function"?o:o===!0?Zk:null}clone(){let e=Object.create(Ps.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}}Gk.Schema=Ps});var Lu=P(function(Fk){var Bk=N(),Es=Rn(),Un=En();function Hk(e,t){let n=[],r=t.directives===!0;if(t.directives!==!1&&e.directives){let c=e.directives.toString(e);if(c)n.push(c),r=!0;else if(e.directives.docStart)r=!0}if(r)n.push("---");let i=Es.createStringifyContext(e,t),{commentString:o}=i.options;if(e.commentBefore){if(n.length!==1)n.unshift("");let c=o(e.commentBefore);n.unshift(Un.indentComment(c,""))}let s=!1,a=null;if(e.contents){if(Bk.isNode(e.contents)){if(e.contents.spaceBefore&&r)n.push("");if(e.contents.commentBefore){let u=o(e.contents.commentBefore);n.push(Un.indentComment(u,""))}i.forceBlockIndent=!!e.comment,a=e.contents.comment}let c=a?void 0:()=>s=!0,l=Es.stringify(e.contents,i,()=>a=null,c);if(a)l+=Un.lineComment(l,"",o(a));if((l[0]==="|"||l[0]===">")&&n[n.length-1]==="---")n[n.length-1]=`--- ${l}`;else n.push(l)}else n.push(Es.stringify(e.contents,i));if(e.directives?.docEnd)if(e.comment){let c=o(e.comment);if(c.includes(`
|
|
57
|
+
`))n.push("..."),n.push(Un.indentComment(c,""));else n.push(`... ${c}`)}else n.push("...");else{let c=e.comment;if(c&&s)c=c.replace(/^\n+/,"");if(c){if((!s||a)&&n[n.length-1]!=="")n.push("");n.push(Un.indentComment(o(c),""))}}return n.join(`
|
|
58
|
+
`)+`
|
|
59
|
+
`}Fk.stringifyDocument=Hk});var Zn=P(function(tx){var Wk=Pn(),Xt=Zr(),Se=N(),Vk=pt(),Yk=ct(),Jk=Ts(),Qk=Lu(),Os=jr(),Xk=Vo(),ex=Tn(),Cs=Wo();class Rs{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Se.NODE_TYPE,{value:Se.DOC});let r=null;if(typeof t==="function"||Array.isArray(t))r=t;else if(n===void 0&&t)n=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"},n);this.options=i;let{version:o}=i;if(n?._directives){if(this.directives=n._directives.atDocument(),this.directives.yaml.explicit)o=this.directives.yaml.version}else this.directives=new Cs.Directives({version:o});this.setSchema(o,n),this.contents=e===void 0?null:this.createNode(e,r,n)}clone(){let e=Object.create(Rs.prototype,{[Se.NODE_TYPE]:{value:Se.DOC}});if(e.commentBefore=this.commentBefore,e.comment=this.comment,e.errors=this.errors.slice(),e.warnings=this.warnings.slice(),e.options=Object.assign({},this.options),this.directives)e.directives=this.directives.clone();if(e.schema=this.schema.clone(),e.contents=Se.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range)e.range=this.range.slice();return e}add(e){if(en(this.contents))this.contents.add(e)}addIn(e,t){if(en(this.contents))this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let n=Os.anchorNames(this);e.anchor=!t||n.has(t)?Os.findNewAnchor(t||"a",n):t}return new Wk.Alias(e.anchor)}createNode(e,t,n){let r=void 0;if(typeof t==="function")e=t.call({"":e},"",e),r=t;else if(Array.isArray(t)){let m=(w)=>typeof w==="number"||w instanceof String||w instanceof Number,g=t.filter(m).map(String);if(g.length>0)t=t.concat(g);r=t}else if(n===void 0&&t)n=t,t=void 0;let{aliasDuplicateObjects:i,anchorPrefix:o,flow:s,keepUndefined:a,onTagObj:c,tag:l}=n??{},{onAnchor:u,setAnchors:p,sourceObjects:d}=Os.createNodeAnchors(this,o||"a"),h={aliasDuplicateObjects:i??!0,keepUndefined:a??!1,onAnchor:u,onTagObj:c,replacer:r,schema:this.schema,sourceObjects:d},f=ex.createNode(e,l,h);if(s&&Se.isCollection(f))f.flow=!0;return p(),f}createPair(e,t,n={}){let r=this.createNode(e,null,n),i=this.createNode(t,null,n);return new Vk.Pair(r,i)}delete(e){return en(this.contents)?this.contents.delete(e):!1}deleteIn(e){if(Xt.isEmptyPath(e)){if(this.contents==null)return!1;return this.contents=null,!0}return en(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return Se.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){if(Xt.isEmptyPath(e))return!t&&Se.isScalar(this.contents)?this.contents.value:this.contents;return Se.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return Se.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){if(Xt.isEmptyPath(e))return this.contents!==void 0;return Se.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,t){if(this.contents==null)this.contents=Xt.collectionFromPath(this.schema,[e],t);else if(en(this.contents))this.contents.set(e,t)}setIn(e,t){if(Xt.isEmptyPath(e))this.contents=t;else if(this.contents==null)this.contents=Xt.collectionFromPath(this.schema,Array.from(e),t);else if(en(this.contents))this.contents.setIn(e,t)}setSchema(e,t={}){if(typeof e==="number")e=String(e);let n;switch(e){case"1.1":if(this.directives)this.directives.yaml.version="1.1";else this.directives=new Cs.Directives({version:"1.1"});n={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":if(this.directives)this.directives.yaml.version=e;else this.directives=new Cs.Directives({version:e});n={resolveKnownTags:!0,schema:"core"};break;case null:if(this.directives)delete this.directives;n=null;break;default:{let r=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${r}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(n)this.schema=new Jk.Schema(Object.assign(n,t));else throw Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:t,mapAsMap:n,maxAliasCount:r,onAnchor:i,reviver:o}={}){let s={anchors:new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r==="number"?r:100},a=Yk.toJS(this.contents,t??"",s);if(typeof i==="function")for(let{count:c,res:l}of s.anchors.values())i(l,c);return typeof o==="function"?Xk.applyReviver(o,{"":a},"",a):a}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)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return Qk.stringifyDocument(this,e)}}function en(e){if(Se.isCollection(e))return!0;throw Error("Expected a YAML collection as document contents")}tx.Document=Rs});var Gn=P(function(ix){class fi extends Error{constructor(e,t,n,r){super();this.name=e,this.code=n,this.message=r,this.pos=t}}class ju extends fi{constructor(e,t,n){super("YAMLParseError",e,t,n)}}class Mu extends fi{constructor(e,t,n){super("YAMLWarning",e,t,n)}}var rx=(e,t)=>(n)=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map((a)=>t.linePos(a));let{line:r,col:i}=n.linePos[0];n.message+=` at line ${r}, column ${i}`;let o=i-1,s=e.substring(t.lineStarts[r-1],t.lineStarts[r]).replace(/[\n\r]+$/,"");if(o>=60&&s.length>80){let a=Math.min(o-39,s.length-79);s="\u2026"+s.substring(a),o-=a-1}if(s.length>80)s=s.substring(0,79)+"\u2026";if(r>1&&/^ *$/.test(s.substring(0,o))){let a=e.substring(t.lineStarts[r-2],t.lineStarts[r-1]);if(a.length>80)a=a.substring(0,79)+`\u2026
|
|
60
|
+
`;s=a+s}if(/[^ ]/.test(s)){let a=1,c=n.linePos[1];if(c?.line===r&&c.col>i)a=Math.max(1,Math.min(c.col-i,80-o));let l=" ".repeat(o)+"^".repeat(a);n.message+=`:
|
|
61
|
+
|
|
62
|
+
${s}
|
|
63
|
+
${l}
|
|
64
|
+
`}};ix.YAMLError=fi;ix.YAMLParseError=ju;ix.YAMLWarning=Mu;ix.prettifyError=rx});var qn=P(function(ux){function lx(e,{flow:t,indicator:n,next:r,offset:i,onError:o,parentIndent:s,startOnNewline:a}){let c=!1,l=a,u=a,p="",d="",h=!1,f=!1,m=null,g=null,w=null,x=null,_=null,b=null,k=null;for(let A of e){if(f){if(A.type!=="space"&&A.type!=="newline"&&A.type!=="comma")o(A.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");f=!1}if(m){if(l&&A.type!=="comment"&&A.type!=="newline")o(m,"TAB_AS_INDENT","Tabs are not allowed as indentation");m=null}switch(A.type){case"space":if(!t&&(n!=="doc-start"||r?.type!=="flow-collection")&&A.source.includes("\t"))m=A;u=!0;break;case"comment":{if(!u)o(A,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let L=A.source.substring(1)||" ";if(!p)p=L;else p+=d+L;d="",l=!1;break}case"newline":if(l){if(p)p+=A.source;else if(!b||n!=="seq-item-ind")c=!0}else d+=A.source;if(l=!0,h=!0,g||w)x=A;u=!0;break;case"anchor":if(g)o(A,"MULTIPLE_ANCHORS","A node can have at most one anchor");if(A.source.endsWith(":"))o(A.offset+A.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0);g=A,k??(k=A.offset),l=!1,u=!1,f=!0;break;case"tag":{if(w)o(A,"MULTIPLE_TAGS","A node can have at most one tag");w=A,k??(k=A.offset),l=!1,u=!1,f=!0;break}case n:if(g||w)o(A,"BAD_PROP_ORDER",`Anchors and tags must be after the ${A.source} indicator`);if(b)o(A,"UNEXPECTED_TOKEN",`Unexpected ${A.source} in ${t??"collection"}`);b=A,l=n==="seq-item-ind"||n==="explicit-key-ind",u=!1;break;case"comma":if(t){if(_)o(A,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`);_=A,l=!1,u=!1;break}default:o(A,"UNEXPECTED_TOKEN",`Unexpected ${A.type} token`),l=!1,u=!1}}let S=e[e.length-1],O=S?S.offset+S.source.length:i;if(f&&r&&r.type!=="space"&&r.type!=="newline"&&r.type!=="comma"&&(r.type!=="scalar"||r.source!==""))o(r.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");if(m&&(l&&m.indent<=s||r?.type==="block-map"||r?.type==="block-seq"))o(m,"TAB_AS_INDENT","Tabs are not allowed as indentation");return{comma:_,found:b,spaceBefore:c,comment:p,hasNewline:h,anchor:g,tag:w,newlineAfterProp:x,end:O,start:k??O}}ux.resolveProps=lx});var mi=P(function(dx){function Is(e){if(!e)return null;switch(e.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(e.source.includes(`
|
|
65
|
+
`))return!0;if(e.end){for(let t of e.end)if(t.type==="newline")return!0}return!1;case"flow-collection":for(let t of e.items){for(let n of t.start)if(n.type==="newline")return!0;if(t.sep){for(let n of t.sep)if(n.type==="newline")return!0}if(Is(t.key)||Is(t.value))return!0}return!1;default:return!0}}dx.containsNewline=Is});var Ns=P(function(gx){var fx=mi();function mx(e,t,n){if(t?.type==="flow-collection"){let r=t.end[0];if(r.indent===e&&(r.source==="]"||r.source==="}")&&fx.containsNewline(t))n(r,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}gx.flowIndentCheck=mx});var zs=P(function(bx){var Uu=N();function yx(e,t,n){let{uniqueKeys:r}=e.options;if(r===!1)return!1;let i=typeof r==="function"?r:(o,s)=>o===s||Uu.isScalar(o)&&Uu.isScalar(s)&&o.value===s.value;return t.some((o)=>i(o.key,n))}bx.mapIncludes=yx});var Hu=P(function(Ax){var Zu=pt(),_x=ht(),Gu=qn(),kx=mi(),qu=Ns(),xx=zs(),Bu="All mapping items must start at the same column";function Sx({composeNode:e,composeEmptyNode:t},n,r,i,o){let a=new(o?.nodeClass??_x.YAMLMap)(n.schema);if(n.atRoot)n.atRoot=!1;let c=r.offset,l=null;for(let u of r.items){let{start:p,key:d,sep:h,value:f}=u,m=Gu.resolveProps(p,{indicator:"explicit-key-ind",next:d??h?.[0],offset:c,onError:i,parentIndent:r.indent,startOnNewline:!0}),g=!m.found;if(g){if(d){if(d.type==="block-seq")i(c,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key");else if("indent"in d&&d.indent!==r.indent)i(c,"BAD_INDENT",Bu)}if(!m.anchor&&!m.tag&&!h){if(l=m.end,m.comment)if(a.comment)a.comment+=`
|
|
66
|
+
`+m.comment;else a.comment=m.comment;continue}if(m.newlineAfterProp||kx.containsNewline(d))i(d??p[p.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else if(m.found?.indent!==r.indent)i(c,"BAD_INDENT",Bu);n.atKey=!0;let w=m.end,x=d?e(n,d,m,i):t(n,w,p,null,m,i);if(n.schema.compat)qu.flowIndentCheck(r.indent,d,i);if(n.atKey=!1,xx.mapIncludes(n,a.items,x))i(w,"DUPLICATE_KEY","Map keys must be unique");let _=Gu.resolveProps(h??[],{indicator:"map-value-ind",next:f,offset:x.range[2],onError:i,parentIndent:r.indent,startOnNewline:!d||d.type==="block-scalar"});if(c=_.end,_.found){if(g){if(f?.type==="block-map"&&!_.hasNewline)i(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings");if(n.options.strict&&m.start<_.found.offset-1024)i(x.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key")}let b=f?e(n,f,_,i):t(n,c,h,null,_,i);if(n.schema.compat)qu.flowIndentCheck(r.indent,f,i);c=b.range[2];let k=new Zu.Pair(x,b);if(n.options.keepSourceTokens)k.srcToken=u;a.items.push(k)}else{if(g)i(x.range,"MISSING_CHAR","Implicit map keys need to be followed by map values");if(_.comment)if(x.comment)x.comment+=`
|
|
67
|
+
`+_.comment;else x.comment=_.comment;let b=new Zu.Pair(x);if(n.options.keepSourceTokens)b.srcToken=u;a.items.push(b)}}if(l&&l<c)i(l,"IMPOSSIBLE","Map comment with trailing content");return a.range=[r.offset,c,l??c],a}Ax.resolveBlockMap=Sx});var Fu=P(function(Cx){var Px=ft(),Tx=qn(),Ex=Ns();function Ox({composeNode:e,composeEmptyNode:t},n,r,i,o){let a=new(o?.nodeClass??Px.YAMLSeq)(n.schema);if(n.atRoot)n.atRoot=!1;if(n.atKey)n.atKey=!1;let c=r.offset,l=null;for(let{start:u,value:p}of r.items){let d=Tx.resolveProps(u,{indicator:"seq-item-ind",next:p,offset:c,onError:i,parentIndent:r.indent,startOnNewline:!0});if(!d.found)if(d.anchor||d.tag||p)if(p?.type==="block-seq")i(d.end,"BAD_INDENT","All sequence items must start at the same column");else i(c,"MISSING_CHAR","Sequence item without - indicator");else{if(l=d.end,d.comment)a.comment=d.comment;continue}let h=p?e(n,p,d,i):t(n,d.end,u,null,d,i);if(n.schema.compat)Ex.flowIndentCheck(r.indent,p,i);c=h.range[2],a.items.push(h)}return a.range=[r.offset,c,l??c],a}Cx.resolveBlockSeq=Ox});var tn=P(function(Nx){function Ix(e,t,n,r){let i="";if(e){let o=!1,s="";for(let a of e){let{source:c,type:l}=a;switch(l){case"space":o=!0;break;case"comment":{if(n&&!o)r(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let u=c.substring(1)||" ";if(!i)i=u;else i+=s+u;s="";break}case"newline":if(i)s+=c;o=!0;break;default:r(a,"UNEXPECTED_TOKEN",`Unexpected ${l} at node end`)}t+=c.length}}return{comment:i,offset:t}}Nx.resolveEnd=Ix});var Vu=P(function(qx){var Dx=N(),Lx=pt(),Ku=ht(),jx=ft(),Mx=tn(),Wu=qn(),Ux=mi(),Zx=zs(),Ds="Block collections are not allowed within flow collections",Ls=(e)=>e&&(e.type==="block-map"||e.type==="block-seq");function Gx({composeNode:e,composeEmptyNode:t},n,r,i,o){let s=r.start.source==="{",a=s?"flow map":"flow sequence",l=new(o?.nodeClass??(s?Ku.YAMLMap:jx.YAMLSeq))(n.schema);l.flow=!0;let u=n.atRoot;if(u)n.atRoot=!1;if(n.atKey)n.atKey=!1;let p=r.offset+r.start.source.length;for(let g=0;g<r.items.length;++g){let w=r.items[g],{start:x,key:_,sep:b,value:k}=w,S=Wu.resolveProps(x,{flow:a,indicator:"explicit-key-ind",next:_??b?.[0],offset:p,onError:i,parentIndent:r.indent,startOnNewline:!1});if(!S.found){if(!S.anchor&&!S.tag&&!b&&!k){if(g===0&&S.comma)i(S.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(g<r.items.length-1)i(S.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`);if(S.comment)if(l.comment)l.comment+=`
|
|
68
|
+
`+S.comment;else l.comment=S.comment;p=S.end;continue}if(!s&&n.options.strict&&Ux.containsNewline(_))i(_,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(g===0){if(S.comma)i(S.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`)}else{if(!S.comma)i(S.start,"MISSING_CHAR",`Missing , between ${a} items`);if(S.comment){let O="";e:for(let A of x)switch(A.type){case"comma":case"space":break;case"comment":O=A.source.substring(1);break e;default:break e}if(O){let A=l.items[l.items.length-1];if(Dx.isPair(A))A=A.value??A.key;if(A.comment)A.comment+=`
|
|
69
|
+
`+O;else A.comment=O;S.comment=S.comment.substring(O.length+1)}}}if(!s&&!b&&!S.found){let O=k?e(n,k,S,i):t(n,S.end,b,null,S,i);if(l.items.push(O),p=O.range[2],Ls(k))i(O.range,"BLOCK_IN_FLOW",Ds)}else{n.atKey=!0;let O=S.end,A=_?e(n,_,S,i):t(n,O,x,null,S,i);if(Ls(_))i(A.range,"BLOCK_IN_FLOW",Ds);n.atKey=!1;let L=Wu.resolveProps(b??[],{flow:a,indicator:"map-value-ind",next:k,offset:A.range[2],onError:i,parentIndent:r.indent,startOnNewline:!1});if(L.found){if(!s&&!S.found&&n.options.strict){if(b)for(let B of b){if(B===L.found)break;if(B.type==="newline"){i(B,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}if(S.start<L.found.offset-1024)i(L.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else if(k)if("source"in k&&k.source?.[0]===":")i(k,"MISSING_CHAR",`Missing space after : in ${a}`);else i(L.start,"MISSING_CHAR",`Missing , or : between ${a} items`);let ae=k?e(n,k,L,i):L.found?t(n,L.end,b,null,L,i):null;if(ae){if(Ls(k))i(ae.range,"BLOCK_IN_FLOW",Ds)}else if(L.comment)if(A.comment)A.comment+=`
|
|
70
|
+
`+L.comment;else A.comment=L.comment;let ke=new Lx.Pair(A,ae);if(n.options.keepSourceTokens)ke.srcToken=w;if(s){let B=l;if(Zx.mapIncludes(n,B.items,A))i(O,"DUPLICATE_KEY","Map keys must be unique");B.items.push(ke)}else{let B=new Ku.YAMLMap(n.schema);B.flow=!0,B.items.push(ke);let St=(ae??A).range;B.range=[A.range[0],St[1],St[2]],l.items.push(B)}p=ae?ae.range[2]:L.end}}let d=s?"}":"]",[h,...f]=r.end,m=p;if(h?.source===d)m=h.offset+h.source.length;else{let g=a[0].toUpperCase()+a.substring(1),w=u?`${g} must end with a ${d}`:`${g} in block collection must be sufficiently indented and end with a ${d}`;if(i(p,u?"MISSING_CHAR":"BAD_INDENT",w),h&&h.source.length!==1)f.unshift(h)}if(f.length>0){let g=Mx.resolveEnd(f,m,n.options.strict,i);if(g.comment)if(l.comment)l.comment+=`
|
|
71
|
+
`+g.comment;else l.comment=g.comment;l.range=[r.offset,m,g.offset]}else l.range=[r.offset,m,m];return l}qx.resolveFlowCollection=Gx});var Yu=P(function(Xx){var Hx=N(),Fx=W(),Kx=ht(),Wx=ft(),Vx=Hu(),Yx=Fu(),Jx=Vu();function js(e,t,n,r,i,o){let s=n.type==="block-map"?Vx.resolveBlockMap(e,t,n,r,o):n.type==="block-seq"?Yx.resolveBlockSeq(e,t,n,r,o):Jx.resolveFlowCollection(e,t,n,r,o),a=s.constructor;if(i==="!"||i===a.tagName)return s.tag=a.tagName,s;if(i)s.tag=i;return s}function Qx(e,t,n,r,i){let o=r.tag,s=!o?null:t.directives.tagName(o.source,(d)=>i(o,"TAG_RESOLVE_FAILED",d));if(n.type==="block-seq"){let{anchor:d,newlineAfterProp:h}=r,f=d&&o?d.offset>o.offset?d:o:d??o;if(f&&(!h||h.offset<f.offset))i(f,"MISSING_CHAR","Missing newline after block sequence props")}let a=n.type==="block-map"?"map":n.type==="block-seq"?"seq":n.start.source==="{"?"map":"seq";if(!o||!s||s==="!"||s===Kx.YAMLMap.tagName&&a==="map"||s===Wx.YAMLSeq.tagName&&a==="seq")return js(e,t,n,i,s);let c=t.schema.tags.find((d)=>d.tag===s&&d.collection===a);if(!c){let d=t.schema.knownTags[s];if(d?.collection===a)t.schema.tags.push(Object.assign({},d,{default:!1})),c=d;else{if(d)i(o,"BAD_COLLECTION_TYPE",`${d.tag} used for ${a} collection, but expects ${d.collection??"scalar"}`,!0);else i(o,"TAG_RESOLVE_FAILED",`Unresolved tag: ${s}`,!0);return js(e,t,n,i,s)}}let l=js(e,t,n,i,s,c),u=c.resolve?.(l,(d)=>i(o,"TAG_RESOLVE_FAILED",d),t.options)??l,p=Hx.isNode(u)?u:new Fx.Scalar(u);if(p.range=l.range,p.tag=s,c?.format)p.format=c.format;return p}Xx.composeCollection=Qx});var Us=P(function(iS){var Ms=W();function tS(e,t,n){let r=t.offset,i=nS(t,e.options.strict,n);if(!i)return{value:"",type:null,comment:"",range:[r,r,r]};let o=i.mode===">"?Ms.Scalar.BLOCK_FOLDED:Ms.Scalar.BLOCK_LITERAL,s=t.source?rS(t.source):[],a=s.length;for(let m=s.length-1;m>=0;--m){let g=s[m][1];if(g===""||g==="\r")a=m;else break}if(a===0){let m=i.chomp==="+"&&s.length>0?`
|
|
72
|
+
`.repeat(Math.max(1,s.length-1)):"",g=r+i.length;if(t.source)g+=t.source.length;return{value:m,type:o,comment:i.comment,range:[r,g,g]}}let c=t.indent+i.indent,l=t.offset+i.length,u=0;for(let m=0;m<a;++m){let[g,w]=s[m];if(w===""||w==="\r"){if(i.indent===0&&g.length>c)c=g.length}else{if(g.length<c)n(l+g.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator");if(i.indent===0)c=g.length;if(u=m,c===0&&!e.atRoot)n(l,"BAD_INDENT","Block scalar values in collections must be indented");break}l+=g.length+w.length+1}for(let m=s.length-1;m>=a;--m)if(s[m][0].length>c)a=m+1;let p="",d="",h=!1;for(let m=0;m<u;++m)p+=s[m][0].slice(c)+`
|
|
73
|
+
`;for(let m=u;m<a;++m){let[g,w]=s[m];l+=g.length+w.length+1;let x=w[w.length-1]==="\r";if(x)w=w.slice(0,-1);if(w&&g.length<c){let b=`Block scalar lines must not be less indented than their ${i.indent?"explicit indentation indicator":"first line"}`;n(l-w.length-(x?2:1),"BAD_INDENT",b),g=""}if(o===Ms.Scalar.BLOCK_LITERAL)p+=d+g.slice(c)+w,d=`
|
|
74
|
+
`;else if(g.length>c||w[0]==="\t"){if(d===" ")d=`
|
|
75
|
+
`;else if(!h&&d===`
|
|
76
|
+
`)d=`
|
|
77
|
+
|
|
78
|
+
`;p+=d+g.slice(c)+w,d=`
|
|
79
|
+
`,h=!0}else if(w==="")if(d===`
|
|
80
|
+
`)p+=`
|
|
81
|
+
`;else d=`
|
|
82
|
+
`;else p+=d+w,d=" ",h=!1}switch(i.chomp){case"-":break;case"+":for(let m=a;m<s.length;++m)p+=`
|
|
83
|
+
`+s[m][0].slice(c);if(p[p.length-1]!==`
|
|
84
|
+
`)p+=`
|
|
85
|
+
`;break;default:p+=`
|
|
86
|
+
`}let f=r+i.length+t.source.length;return{value:p,type:o,comment:i.comment,range:[r,f,f]}}function nS({offset:e,props:t},n,r){if(t[0].type!=="block-scalar-header")return r(t[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:i}=t[0],o=i[0],s=0,a="",c=-1;for(let d=1;d<i.length;++d){let h=i[d];if(!a&&(h==="-"||h==="+"))a=h;else{let f=Number(h);if(!s&&f)s=f;else if(c===-1)c=e+d}}if(c!==-1)r(c,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${i}`);let l=!1,u="",p=i.length;for(let d=1;d<t.length;++d){let h=t[d];switch(h.type){case"space":l=!0;case"newline":p+=h.source.length;break;case"comment":if(n&&!l)r(h,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");p+=h.source.length,u=h.source.substring(1);break;case"error":r(h,"UNEXPECTED_TOKEN",h.message),p+=h.source.length;break;default:{let f=`Unexpected token in block scalar header: ${h.type}`;r(h,"UNEXPECTED_TOKEN",f);let m=h.source;if(m&&typeof m==="string")p+=m.length}}}return{mode:o,indent:s,chomp:a,comment:u,length:p}}function rS(e){let t=e.split(/\n( *)/),n=t[0],r=n.match(/^( *)/),o=[r?.[1]?[r[1],n.slice(r[1].length)]:["",n]];for(let s=1;s<t.length;s+=2)o.push([t[s],t[s+1]]);return o}iS.resolveBlockScalar=tS});var Gs=P(function(fS){var Zs=W(),sS=tn();function aS(e,t,n){let{offset:r,type:i,source:o,end:s}=e,a,c,l=(d,h,f)=>n(r+d,h,f);switch(i){case"scalar":a=Zs.Scalar.PLAIN,c=cS(o,l);break;case"single-quoted-scalar":a=Zs.Scalar.QUOTE_SINGLE,c=lS(o,l);break;case"double-quoted-scalar":a=Zs.Scalar.QUOTE_DOUBLE,c=uS(o,l);break;default:return n(e,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${i}`),{value:"",type:null,comment:"",range:[r,r+o.length,r+o.length]}}let u=r+o.length,p=sS.resolveEnd(s,u,t,n);return{value:c,type:a,comment:p.comment,range:[r,u,p.offset]}}function cS(e,t){let n="";switch(e[0]){case"\t":n="a tab character";break;case",":n="flow indicator character ,";break;case"%":n="directive indicator character %";break;case"|":case">":{n=`block scalar indicator ${e[0]}`;break}case"@":case"`":{n=`reserved character ${e[0]}`;break}}if(n)t(0,"BAD_SCALAR_START",`Plain value cannot start with ${n}`);return Ju(e)}function lS(e,t){if(e[e.length-1]!=="'"||e.length===1)t(e.length,"MISSING_CHAR","Missing closing 'quote");return Ju(e.slice(1,-1)).replace(/''/g,"'")}function Ju(e){let t=/(.*?)\r?\n/sy,n=t.exec(e);if(!n)return e;let r,i;try{r=new RegExp("(?<![ \t])[ \t]+$"),i=new RegExp("^[ \t]+|(?<![ \t])[ \t]+$","g")}catch{r=/[ \t]+$/,i=/^[ \t]+|[ \t]+$/g}let o=n[1].replace(r,""),s=" ",a=t.lastIndex;while(n=t.exec(e)){let l=n[1].replace(i,"");if(l==="")if(s===`
|
|
87
|
+
`)o+=s;else s=`
|
|
88
|
+
`;else o+=s+l,s=" ";a=t.lastIndex}let c=/[ \t]*(.*)/sy;return c.lastIndex=a,n=c.exec(e),o+s+(n?.[1]??"")}function uS(e,t){let n="";for(let r=1;r<e.length-1;++r){let i=e[r];if(i==="\r"&&e[r+1]===`
|
|
89
|
+
`)continue;if(i===`
|
|
90
|
+
`){let{fold:o,offset:s}=pS(e,r);n+=o,r=s}else if(i==="\\"){let o=e[++r],s=dS[o];if(s)n+=s;else if(o===`
|
|
91
|
+
`){o=e[r+1];while(o===" "||o==="\t")o=e[++r+1]}else if(o==="\r"&&e[r+1]===`
|
|
92
|
+
`){o=e[++r+1];while(o===" "||o==="\t")o=e[++r+1]}else if(o==="x"||o==="u"||o==="U"){let a=o==="x"?2:o==="u"?4:8;n+=hS(e,r+1,a,t),r+=a}else{let a=e.substr(r-1,2);t(r-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),n+=a}}else if(i===" "||i==="\t"){let o=r,s=e[r+1];while(s===" "||s==="\t")s=e[++r+1];if(s!==`
|
|
93
|
+
`&&!(s==="\r"&&e[r+2]===`
|
|
94
|
+
`))n+=r>o?e.slice(o,r+1):i}else n+=i}if(e[e.length-1]!=='"'||e.length===1)t(e.length,"MISSING_CHAR",'Missing closing "quote');return n}function pS(e,t){let n="",r=e[t+1];while(r===" "||r==="\t"||r===`
|
|
95
|
+
`||r==="\r"){if(r==="\r"&&e[t+2]!==`
|
|
96
|
+
`)break;if(r===`
|
|
97
|
+
`)n+=`
|
|
98
|
+
`;t+=1,r=e[t+1]}if(!n)n=" ";return{fold:n,offset:t}}var dS={"0":"\x00",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
|
|
99
|
+
`,r:"\r",t:"\t",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\","\t":"\t"};function hS(e,t,n,r){let i=e.substr(t,n),s=i.length===n&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;try{return String.fromCodePoint(s)}catch{let a=e.substr(t-2,n+2);return r(t-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}}fS.resolveFlowScalar=aS});var Xu=P(function(_S){var Ot=N(),Qu=W(),gS=Us(),vS=Gs();function yS(e,t,n,r){let{value:i,type:o,comment:s,range:a}=t.type==="block-scalar"?gS.resolveBlockScalar(e,t,r):vS.resolveFlowScalar(t,e.options.strict,r),c=n?e.directives.tagName(n.source,(p)=>r(n,"TAG_RESOLVE_FAILED",p)):null,l;if(e.options.stringKeys&&e.atKey)l=e.schema[Ot.SCALAR];else if(c)l=bS(e.schema,i,c,n,r);else if(t.type==="scalar")l=wS(e,i,t,r);else l=e.schema[Ot.SCALAR];let u;try{let p=l.resolve(i,(d)=>r(n??t,"TAG_RESOLVE_FAILED",d),e.options);u=Ot.isScalar(p)?p:new Qu.Scalar(p)}catch(p){let d=p instanceof Error?p.message:String(p);r(n??t,"TAG_RESOLVE_FAILED",d),u=new Qu.Scalar(i)}if(u.range=a,u.source=i,o)u.type=o;if(c)u.tag=c;if(l.format)u.format=l.format;if(s)u.comment=s;return u}function bS(e,t,n,r,i){if(n==="!")return e[Ot.SCALAR];let o=[];for(let a of e.tags)if(!a.collection&&a.tag===n)if(a.default&&a.test)o.push(a);else return a;for(let a of o)if(a.test?.test(t))return a;let s=e.knownTags[n];if(s&&!s.collection)return e.tags.push(Object.assign({},s,{default:!1,test:void 0})),s;return i(r,"TAG_RESOLVE_FAILED",`Unresolved tag: ${n}`,n!=="tag:yaml.org,2002:str"),e[Ot.SCALAR]}function wS({atKey:e,directives:t,schema:n},r,i,o){let s=n.tags.find((a)=>(a.default===!0||e&&a.default==="key")&&a.test?.test(r))||n[Ot.SCALAR];if(n.compat){let a=n.compat.find((c)=>c.default&&c.test?.test(r))??n[Ot.SCALAR];if(s.tag!==a.tag){let c=t.tagString(s.tag),l=t.tagString(a.tag),u=`Value may be parsed as either ${c} or ${l}`;o(i,"TAG_RESOLVE_FAILED",u,!0)}}return s}_S.composeScalar=yS});var ep=P(function(SS){function xS(e,t,n){if(t){n??(n=t.length);for(let r=n-1;r>=0;--r){let i=t[r];switch(i.type){case"space":case"comment":case"newline":e-=i.source.length;continue}i=t[++r];while(i?.type==="space")e+=i.source.length,i=t[++r];break}}return e}SS.emptyScalarPosition=xS});var rp=P(function(IS){var $S=Pn(),PS=N(),TS=Yu(),tp=Xu(),ES=tn(),OS=ep(),CS={composeNode:np,composeEmptyNode:qs};function np(e,t,n,r){let i=e.atKey,{spaceBefore:o,comment:s,anchor:a,tag:c}=n,l,u=!0;switch(t.type){case"alias":if(l=RS(e,t,r),a||c)r(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":if(l=tp.composeScalar(e,t,c,r),a)l.anchor=a.source.substring(1);break;case"block-map":case"block-seq":case"flow-collection":try{if(l=TS.composeCollection(CS,e,t,n,r),a)l.anchor=a.source.substring(1)}catch(p){let d=p instanceof Error?p.message:String(p);r(t,"RESOURCE_EXHAUSTION",d)}break;default:{let p=t.type==="error"?t.message:`Unsupported token (type: ${t.type})`;r(t,"UNEXPECTED_TOKEN",p),u=!1}}if(l??(l=qs(e,t.offset,void 0,null,n,r)),a&&l.anchor==="")r(a,"BAD_ALIAS","Anchor cannot be an empty string");if(i&&e.options.stringKeys&&(!PS.isScalar(l)||typeof l.value!=="string"||l.tag&&l.tag!=="tag:yaml.org,2002:str"))r(c??t,"NON_STRING_KEY","With stringKeys, all keys must be strings");if(o)l.spaceBefore=!0;if(s)if(t.type==="scalar"&&t.source==="")l.comment=s;else l.commentBefore=s;if(e.options.keepSourceTokens&&u)l.srcToken=t;return l}function qs(e,t,n,r,{spaceBefore:i,comment:o,anchor:s,tag:a,end:c},l){let u={type:"scalar",offset:OS.emptyScalarPosition(t,n,r),indent:-1,source:""},p=tp.composeScalar(e,u,a,l);if(s){if(p.anchor=s.source.substring(1),p.anchor==="")l(s,"BAD_ALIAS","Anchor cannot be an empty string")}if(i)p.spaceBefore=!0;if(o)p.comment=o,p.range[2]=c;return p}function RS({options:e},{offset:t,source:n,end:r},i){let o=new $S.Alias(n.substring(1));if(o.source==="")i(t,"BAD_ALIAS","Alias cannot be an empty string");if(o.source.endsWith(":"))i(t+n.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let s=t+n.length,a=ES.resolveEnd(r,s,e.strict,i);if(o.range=[t,s,a.offset],a.comment)o.comment=a.comment;return o}IS.composeEmptyNode=qs;IS.composeNode=np});var op=P(function(US){var DS=Zn(),ip=rp(),LS=tn(),jS=qn();function MS(e,t,{offset:n,start:r,value:i,end:o},s){let a=Object.assign({_directives:t},e),c=new DS.Document(void 0,a),l={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},u=jS.resolveProps(r,{indicator:"doc-start",next:i??o?.[0],offset:n,onError:s,parentIndent:0,startOnNewline:!0});if(u.found){if(c.directives.docStart=!0,i&&(i.type==="block-map"||i.type==="block-seq")&&!u.hasNewline)s(u.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")}c.contents=i?ip.composeNode(l,i,u,s):ip.composeEmptyNode(l,u.end,r,null,u,s);let p=c.contents.range[2],d=LS.resolveEnd(o,p,!1,s);if(d.comment)c.comment=d.comment;return c.range=[n,p,d.offset],c}US.composeDoc=MS});var Bs=P(function(KS){var GS=Oe("process"),qS=Wo(),BS=Zn(),Bn=Gn(),sp=N(),HS=op(),FS=tn();function Hn(e){if(typeof e==="number")return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:n}=e;return[t,t+(typeof n==="string"?n.length:1)]}function ap(e){let t="",n=!1,r=!1;for(let i=0;i<e.length;++i){let o=e[i];switch(o[0]){case"#":t+=(t===""?"":r?`
|
|
100
|
+
|
|
101
|
+
`:`
|
|
102
|
+
`)+(o.substring(1)||" "),n=!0,r=!1;break;case"%":if(e[i+1]?.[0]!=="#")i+=1;n=!1;break;default:if(!n)r=!0;n=!1}}return{comment:t,afterEmptyLine:r}}class cp{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(t,n,r,i)=>{let o=Hn(t);if(i)this.warnings.push(new Bn.YAMLWarning(o,n,r));else this.errors.push(new Bn.YAMLParseError(o,n,r))},this.directives=new qS.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,t){let{comment:n,afterEmptyLine:r}=ap(this.prelude);if(n){let i=e.contents;if(t)e.comment=e.comment?`${e.comment}
|
|
103
|
+
${n}`:n;else if(r||e.directives.docStart||!i)e.commentBefore=n;else if(sp.isCollection(i)&&!i.flow&&i.items.length>0){let o=i.items[0];if(sp.isPair(o))o=o.key;let s=o.commentBefore;o.commentBefore=s?`${n}
|
|
104
|
+
${s}`:n}else{let o=i.commentBefore;i.commentBefore=o?`${n}
|
|
105
|
+
${o}`:n}}if(t){for(let i=0;i<this.errors.length;++i)e.errors.push(this.errors[i]);for(let i=0;i<this.warnings.length;++i)e.warnings.push(this.warnings[i])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:ap(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(let r of e)yield*this.next(r);yield*this.end(t,n)}*next(e){if(GS.env.LOG_STREAM)console.dir(e,{depth:null});switch(e.type){case"directive":this.directives.add(e.source,(t,n,r)=>{let i=Hn(e);i[0]+=t,this.onError(i,"BAD_DIRECTIVE",n,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let t=HS.composeDoc(this.options,this.directives,e,this.onError);if(this.atDirectives&&!t.directives.docStart)this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line");if(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,n=new Bn.YAMLParseError(Hn(e),"UNEXPECTED_TOKEN",t);if(this.atDirectives||!this.doc)this.errors.push(n);else this.doc.errors.push(n);break}case"doc-end":{if(!this.doc){this.errors.push(new Bn.YAMLParseError(Hn(e),"UNEXPECTED_TOKEN","Unexpected doc-end without preceding document"));break}this.doc.directives.docEnd=!0;let t=FS.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let n=this.doc.comment;this.doc.comment=n?`${n}
|
|
106
|
+
${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new Bn.YAMLParseError(Hn(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 n=Object.assign({_directives:this.directives},this.options),r=new BS.Document(void 0,n);if(this.atDirectives)this.onError(t,"MISSING_CHAR","Missing directives-end indicator line");r.range=[0,t,t],this.decorate(r,!1),yield r}}}KS.Composer=cp});var pp=P(function(n1){var VS=Us(),YS=Gs(),JS=Gn(),lp=Cn();function QS(e,t=!0,n){if(e){let r=(i,o,s)=>{let a=typeof i==="number"?i:Array.isArray(i)?i[0]:i.offset;if(n)n(a,o,s);else throw new JS.YAMLParseError([a,a+1],o,s)};switch(e.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return YS.resolveFlowScalar(e,t,r);case"block-scalar":return VS.resolveBlockScalar({options:{strict:t}},e,r)}}return null}function XS(e,t){let{implicitKey:n=!1,indent:r,inFlow:i=!1,offset:o=-1,type:s="PLAIN"}=t,a=lp.stringifyString({type:s,value:e},{implicitKey:n,indent:r>0?" ".repeat(r):"",inFlow:i,options:{blockQuote:!0,lineWidth:-1}}),c=t.end??[{type:"newline",offset:-1,indent:r,source:`
|
|
107
|
+
`}];switch(a[0]){case"|":case">":{let l=a.indexOf(`
|
|
108
|
+
`),u=a.substring(0,l),p=a.substring(l+1)+`
|
|
109
|
+
`,d=[{type:"block-scalar-header",offset:o,indent:r,source:u}];if(!up(d,c))d.push({type:"newline",offset:-1,indent:r,source:`
|
|
110
|
+
`});return{type:"block-scalar",offset:o,indent:r,props:d,source:p}}case'"':return{type:"double-quoted-scalar",offset:o,indent:r,source:a,end:c};case"'":return{type:"single-quoted-scalar",offset:o,indent:r,source:a,end:c};default:return{type:"scalar",offset:o,indent:r,source:a,end:c}}}function e1(e,t,n={}){let{afterKey:r=!1,implicitKey:i=!1,inFlow:o=!1,type:s}=n,a="indent"in e?e.indent:null;if(r&&typeof a==="number")a+=2;if(!s)switch(e.type){case"single-quoted-scalar":s="QUOTE_SINGLE";break;case"double-quoted-scalar":s="QUOTE_DOUBLE";break;case"block-scalar":{let l=e.props[0];if(l.type!=="block-scalar-header")throw Error("Invalid block scalar header");s=l.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:s="PLAIN"}let c=lp.stringifyString({type:s,value:t},{implicitKey:i||a===null,indent:a!==null&&a>0?" ".repeat(a):"",inFlow:o,options:{blockQuote:!0,lineWidth:-1}});switch(c[0]){case"|":case">":t1(e,c);break;case'"':Hs(e,c,"double-quoted-scalar");break;case"'":Hs(e,c,"single-quoted-scalar");break;default:Hs(e,c,"scalar")}}function t1(e,t){let n=t.indexOf(`
|
|
111
|
+
`),r=t.substring(0,n),i=t.substring(n+1)+`
|
|
112
|
+
`;if(e.type==="block-scalar"){let o=e.props[0];if(o.type!=="block-scalar-header")throw Error("Invalid block scalar header");o.source=r,e.source=i}else{let{offset:o}=e,s="indent"in e?e.indent:-1,a=[{type:"block-scalar-header",offset:o,indent:s,source:r}];if(!up(a,"end"in e?e.end:void 0))a.push({type:"newline",offset:-1,indent:s,source:`
|
|
113
|
+
`});for(let c of Object.keys(e))if(c!=="type"&&c!=="offset")delete e[c];Object.assign(e,{type:"block-scalar",indent:s,props:a,source:i})}}function up(e,t){if(t)for(let n of t)switch(n.type){case"space":case"comment":e.push(n);break;case"newline":return e.push(n),!0}return!1}function Hs(e,t,n){switch(e.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":e.type=n,e.source=t;break;case"block-scalar":{let r=e.props.slice(1),i=t.length;if(e.props[0].type==="block-scalar-header")i-=e.props[0].source.length;for(let o of r)o.offset+=i;delete e.props,Object.assign(e,{type:n,source:t,end:r});break}case"block-map":case"block-seq":{let i={type:"newline",offset:e.offset+t.length,indent:e.indent,source:`
|
|
114
|
+
`};delete e.items,Object.assign(e,{type:n,source:t,end:[i]});break}default:{let r="indent"in e?e.indent:-1,i="end"in e&&Array.isArray(e.end)?e.end.filter((o)=>o.type==="space"||o.type==="comment"||o.type==="newline"):[];for(let o of Object.keys(e))if(o!=="type"&&o!=="offset")delete e[o];Object.assign(e,{type:n,indent:r,source:t,end:i})}}}n1.createScalarToken=XS;n1.resolveAsScalar=QS;n1.setScalarValue=e1});var dp=P(function(a1){var s1=(e)=>("type"in e)?vi(e):gi(e);function vi(e){switch(e.type){case"block-scalar":{let t="";for(let n of e.props)t+=vi(n);return t+e.source}case"block-map":case"block-seq":{let t="";for(let n of e.items)t+=gi(n);return t}case"flow-collection":{let t=e.start.source;for(let n of e.items)t+=gi(n);for(let n of e.end)t+=n.source;return t}case"document":{let t=gi(e);if(e.end)for(let n of e.end)t+=n.source;return t}default:{let t=e.source;if("end"in e&&e.end)for(let n of e.end)t+=n.source;return t}}}function gi({start:e,key:t,sep:n,value:r}){let i="";for(let o of e)i+=o.source;if(t)i+=vi(t);if(n)for(let o of n)i+=o.source;if(r)i+=vi(r);return i}a1.stringify=s1});var mp=P(function(u1){var Fs=Symbol("break visit"),l1=Symbol("skip children"),hp=Symbol("remove item");function Ct(e,t){if("type"in e&&e.type==="document")e={start:e.start,value:e.value};fp(Object.freeze([]),e,t)}Ct.BREAK=Fs;Ct.SKIP=l1;Ct.REMOVE=hp;Ct.itemAtPath=(e,t)=>{let n=e;for(let[r,i]of t){let o=n?.[r];if(o&&"items"in o)n=o.items[i];else return}return n};Ct.parentCollection=(e,t)=>{let n=Ct.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],i=n?.[r];if(i&&"items"in i)return i;throw Error("Parent collection not found")};function fp(e,t,n){let r=n(t,e);if(typeof r==="symbol")return r;for(let i of["key","value"]){let o=t[i];if(o&&"items"in o){for(let s=0;s<o.items.length;++s){let a=fp(Object.freeze(e.concat([[i,s]])),o.items[s],n);if(typeof a==="number")s=a-1;else if(a===Fs)return Fs;else if(a===hp)o.items.splice(s,1),s-=1}if(typeof r==="function"&&i==="key")r=r(t,e)}}return typeof r==="function"?r(t,e):r}u1.visit=Ct});var yi=P(function(y1){var Ks=pp(),d1=dp(),h1=mp(),Ws="\uFEFF",Vs="\x02",Ys="\x18",Js="\x1F",f1=(e)=>!!e&&("items"in e),m1=(e)=>!!e&&(e.type==="scalar"||e.type==="single-quoted-scalar"||e.type==="double-quoted-scalar"||e.type==="block-scalar");function g1(e){switch(e){case Ws:return"<BOM>";case Vs:return"<DOC>";case Ys:return"<FLOW_END>";case Js:return"<SCALAR>";default:return JSON.stringify(e)}}function v1(e){switch(e){case Ws:return"byte-order-mark";case Vs:return"doc-mode";case Ys:return"flow-error-end";case Js:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
|
|
115
|
+
`:case`\r
|
|
116
|
+
`: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"\t":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}y1.createScalarToken=Ks.createScalarToken;y1.resolveAsScalar=Ks.resolveAsScalar;y1.setScalarValue=Ks.setScalarValue;y1.stringify=d1.stringify;y1.visit=h1.visit;y1.BOM=Ws;y1.DOCUMENT=Vs;y1.FLOW_END=Ys;y1.SCALAR=Js;y1.isCollection=f1;y1.isScalar=m1;y1.prettyToken=g1;y1.tokenType=v1});var Xs=P(function(N1){var Fn=yi();function Re(e){switch(e){case void 0:case" ":case`
|
|
117
|
+
`:case"\r":case"\t":return!0;default:return!1}}var gp=new Set("0123456789ABCDEFabcdef"),R1=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),bi=new Set(",[]{}"),I1=new Set(` ,[]{}
|
|
118
|
+
\r `),Qs=(e)=>!e||I1.has(e);class vp{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(typeof e!=="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let n=this.next??"stream";while(n&&(t||this.hasChars(1)))n=yield*this.parseNext(n)}atLineEnd(){let e=this.pos,t=this.buffer[e];while(t===" "||t==="\t")t=this.buffer[++e];if(!t||t==="#"||t===`
|
|
119
|
+
`)return!0;if(t==="\r")return this.buffer[e+1]===`
|
|
120
|
+
`;return!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let t=this.buffer[e];if(this.indentNext>0){let n=0;while(t===" ")t=this.buffer[++n+e];if(t==="\r"){let r=this.buffer[n+e+1];if(r===`
|
|
121
|
+
`||!r&&!this.atEnd)return e+n+1}return t===`
|
|
122
|
+
`||n>=this.indentNext||!t&&!this.atEnd?e+n:-1}if(t==="-"||t==="."){let n=this.buffer.substr(e,3);if((n==="---"||n==="...")&&Re(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;if(typeof e!=="number"||e!==-1&&e<this.pos)e=this.buffer.indexOf(`
|
|
123
|
+
`,this.pos),this.lineEndPos=e;if(e===-1)return this.atEnd?this.buffer.substring(this.pos):null;if(this.buffer[e-1]==="\r")e-=1;return 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(e===null)return this.setNext("stream");if(e[0]===Fn.BOM)yield*this.pushCount(1),e=e.substring(1);if(e[0]==="%"){let t=e.length,n=e.indexOf("#");while(n!==-1){let i=e[n-1];if(i===" "||i==="\t"){t=n-1;break}else n=e.indexOf("#",n+1)}while(!0){let i=e[t-1];if(i===" "||i==="\t")t-=1;else break}let r=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-r),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 Fn.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 t=this.peek(3);if((t==="---"||t==="...")&&Re(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,t==="---"?"doc":"stream"}if(this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!Re(this.charAt(1)))this.indentNext=this.indentValue;return yield*this.parseBlockStart()}*parseBlockStart(){let[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&Re(t)){let n=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=n,"block-start"}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)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(Qs),"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,n=-1;do{if(e=yield*this.pushNewline(),e>0)t=yield*this.pushSpaces(!1),this.indentValue=n=t;else t=0;t+=yield*this.pushSpaces(!0)}while(e+t>0);let r=this.getLine();if(r===null)return this.setNext("flow");if(n!==-1&&n<this.indentNext&&r[0]!=="#"||n===0&&(r.startsWith("---")||r.startsWith("..."))&&Re(r[3])){if(!(n===this.indentNext-1&&this.flowLevel===1&&(r[0]==="]"||r[0]==="}")))return this.flowLevel=0,yield Fn.FLOW_END,yield*this.parseLineStart()}let i=0;while(r[i]===",")i+=yield*this.pushCount(1),i+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(i+=yield*this.pushIndicators(),r[i]){case void 0:return"flow";case"#":return yield*this.pushCount(r.length-i),"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(Qs),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||Re(o)||o===",")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==="'")while(t!==-1&&this.buffer[t+1]==="'")t=this.buffer.indexOf("'",t+2);else while(t!==-1){let i=0;while(this.buffer[t-1-i]==="\\")i+=1;if(i%2===0)break;t=this.buffer.indexOf('"',t+1)}let n=this.buffer.substring(0,t),r=n.indexOf(`
|
|
124
|
+
`,this.pos);if(r!==-1){while(r!==-1){let i=this.continueScalar(r+1);if(i===-1)break;r=n.indexOf(`
|
|
125
|
+
`,i)}if(r!==-1)t=r-(n[r-1]==="\r"?2:1)}if(t===-1){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;while(!0){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((t)=>Re(t)||t==="#")}*parseBlockScalar(){let e=this.pos-1,t=0,n;e:for(let i=this.pos;n=this.buffer[i];++i)switch(n){case" ":t+=1;break;case`
|
|
126
|
+
`:e=i,t=0;break;case"\r":{let o=this.buffer[i+1];if(!o&&!this.atEnd)return this.setNext("block-scalar");if(o===`
|
|
127
|
+
`)break}default:break e}if(!n&&!this.atEnd)return this.setNext("block-scalar");if(t>=this.indentNext){if(this.blockScalarIndent===-1)this.indentNext=t;else this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let i=this.continueScalar(e+1);if(i===-1)break;e=this.buffer.indexOf(`
|
|
128
|
+
`,i)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext("block-scalar");e=this.buffer.length}}let r=e+1;n=this.buffer[r];while(n===" ")n=this.buffer[++r];if(n==="\t"){while(n==="\t"||n===" "||n==="\r"||n===`
|
|
129
|
+
`)n=this.buffer[++r];e=r-1}else if(!this.blockScalarKeep)do{let i=e-1,o=this.buffer[i];if(o==="\r")o=this.buffer[--i];let s=i;while(o===" ")o=this.buffer[--i];if(o===`
|
|
130
|
+
`&&i>=this.pos&&i+1+t>s)e=i;else break}while(!0);return yield Fn.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,t=this.pos-1,n=this.pos-1,r;while(r=this.buffer[++n])if(r===":"){let i=this.buffer[n+1];if(Re(i)||e&&bi.has(i))break;t=n}else if(Re(r)){let i=this.buffer[n+1];if(r==="\r")if(i===`
|
|
131
|
+
`)n+=1,r=`
|
|
132
|
+
`,i=this.buffer[n+1];else t=n;if(i==="#"||e&&bi.has(i))break;if(r===`
|
|
133
|
+
`){let o=this.continueScalar(n+1);if(o===-1)break;n=Math.max(n,o-2)}}else{if(e&&bi.has(r))break;t=n}if(!r&&!this.atEnd)return this.setNext("plain-scalar");return yield Fn.SCALAR,yield*this.pushToIndex(t+1,!0),e?"flow":"doc"}*pushCount(e){if(e>0)return yield this.buffer.substr(this.pos,e),this.pos+=e,e;return 0}*pushToIndex(e,t){let n=this.buffer.slice(this.pos,e);if(n)return yield n,this.pos+=n.length,n.length;else if(t)yield"";return 0}*pushIndicators(){let e=0;e:while(!0){switch(this.charAt(0)){case"!":e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue e;case"&":e+=yield*this.pushUntil(Qs),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let t=this.flowLevel>0,n=this.charAt(1);if(Re(n)||t&&bi.has(n)){if(!t)this.indentNext=this.indentValue+1;else if(this.flowKey)this.flowKey=!1;e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue e}}}break e}return e}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,t=this.buffer[e];while(!Re(t)&&t!==">")t=this.buffer[++e];return yield*this.pushToIndex(t===">"?e+1:e,!1)}else{let e=this.pos+1,t=this.buffer[e];while(t)if(R1.has(t))t=this.buffer[++e];else if(t==="%"&&gp.has(this.buffer[e+1])&&gp.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];if(e===`
|
|
134
|
+
`)return yield*this.pushCount(1);else if(e==="\r"&&this.charAt(1)===`
|
|
135
|
+
`)return yield*this.pushCount(2);else return 0}*pushSpaces(e){let t=this.pos-1,n;do n=this.buffer[++t];while(n===" "||e&&n==="\t");let r=t-this.pos;if(r>0)yield this.buffer.substr(this.pos,r),this.pos=t;return r}*pushUntil(e){let t=this.pos,n=this.buffer[t];while(!e(n))n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}}N1.Lexer=vp});var ea=P(function(D1){class yp{constructor(){this.lineStarts=[],this.addNewLine=(e)=>this.lineStarts.push(e),this.linePos=(e)=>{let t=0,n=this.lineStarts.length;while(t<n){let i=t+n>>1;if(this.lineStarts[i]<e)t=i+1;else n=i}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let r=this.lineStarts[t-1];return{line:t,col:e-r+1}}}}D1.LineCounter=yp});var ta=P(function(U1){var j1=Oe("process"),bp=yi(),M1=Xs();function mt(e,t){for(let n=0;n<e.length;++n)if(e[n].type===t)return!0;return!1}function wp(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 kp(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 wi(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 nn(e){if(e.length===0)return[];let t=e.length;e:while(--t>=0)switch(e[t].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}while(e[++t]?.type==="space");return e.splice(t,e.length)}function _i(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let n=0;n<t.length;++n)e.push(t[n])}function _p(e){if(e.start.type==="flow-seq-start"){for(let t of e.items)if(t.sep&&!t.value&&!mt(t.start,"explicit-key-ind")&&!mt(t.sep,"map-value-ind")){if(t.key)t.value=t.key;if(delete t.key,kp(t.value))if(t.value.end)_i(t.value.end,t.sep);else t.value.end=t.sep;else _i(t.start,t.sep);delete t.sep}}}class xp{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 M1.Lexer,this.onNewLine=e}*parse(e,t=!1){if(this.onNewLine&&this.offset===0)this.onNewLine(0);for(let n of this.lexer.lex(e,t))yield*this.next(n);if(!t)yield*this.end()}*next(e){if(this.source=e,j1.env.LOG_TOKENS)console.log("|",bp.prettyToken(e));if(this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=bp.tokenType(e);if(!t){let n=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:n,source:e}),this.offset+=e.length}else if(t==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=t,yield*this.step(),t){case"newline":if(this.atNewLine=!0,this.indent=0,this.onNewLine)this.onNewLine(this.offset+e.length);break;case"space":if(this.atNewLine&&e[0]===" ")this.indent+=e.length;break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":if(this.atNewLine)this.indent+=e.length;break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}}*end(){while(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(this.type==="doc-end"&&e?.type!=="doc-end"){while(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)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield t;else{let n=this.peek(1);if(t.type==="block-scalar")t.indent="indent"in n?n.indent:0;else if(t.type==="flow-collection"&&n.type==="document")t.indent=0;if(t.type==="flow-collection")_p(t);switch(n.type){case"document":n.value=t;break;case"block-scalar":n.props.push(t);break;case"block-map":{let r=n.items[n.items.length-1];if(r.value){n.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}else if(r.sep)r.value=t;else{Object.assign(r,{key:t,sep:[]}),this.onKeyLine=!r.explicitKey;return}break}case"block-seq":{let r=n.items[n.items.length-1];if(r.value)n.items.push({start:[],value:t});else r.value=t;break}case"flow-collection":{let r=n.items[n.items.length-1];if(!r||r.value)n.items.push({start:[],key:t,sep:[]});else if(r.sep)r.value=t;else Object.assign(r,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((n.type==="document"||n.type==="block-map"||n.type==="block-seq")&&(t.type==="block-map"||t.type==="block-seq")){let r=t.items[t.items.length-1];if(r&&!r.sep&&!r.value&&r.start.length>0&&wp(r.start)===-1&&(t.indent===0||r.start.every((i)=>i.type!=="comment"||i.indent<t.indent))){if(n.type==="document")n.end=r.start;else n.items.push({start:r.start});t.items.splice(-1,1)}}}}*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:[]};if(this.type==="doc-start")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":{if(wp(e.start)!==-1)yield*this.pop(),yield*this.step();else 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);if(t)this.stack.push(t);else yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type==="map-value-ind"){let t=wi(this.peek(2)),n=nn(t),r;if(e.end)r=e.end,r.push(this.sourceToken),delete e.end;else r=[this.sourceToken];let i={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:n,key:e,sep:r}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}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 t=this.source.indexOf(`
|
|
136
|
+
`)+1;while(t!==0)this.onNewLine(this.offset+t),t=this.source.indexOf(`
|
|
137
|
+
`,t)+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 n="end"in t.value?t.value.end:void 0;if((Array.isArray(n)?n[n.length-1]:void 0)?.type==="comment")n?.push(this.sourceToken);else e.items.push({start:[this.sourceToken]})}else if(t.sep)t.sep.push(this.sourceToken);else 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]?.value?.end;if(Array.isArray(r)){_i(r,t.start),r.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let n=!this.onKeyLine&&this.indent===e.indent,r=n&&(t.sep||t.explicitKey)&&this.type!=="seq-item-ind",i=[];if(r&&t.sep&&!t.value){let o=[];for(let s=0;s<t.sep.length;++s){let a=t.sep[s];switch(a.type){case"newline":o.push(s);break;case"space":break;case"comment":if(a.indent>e.indent)o.length=0;break;default:o.length=0}}if(o.length>=2)i=t.sep.splice(o[1])}switch(this.type){case"anchor":case"tag":if(r||t.value)i.push(this.sourceToken),e.items.push({start:i}),this.onKeyLine=!0;else if(t.sep)t.sep.push(this.sourceToken);else t.start.push(this.sourceToken);return;case"explicit-key-ind":if(!t.sep&&!t.explicitKey)t.start.push(this.sourceToken),t.explicitKey=!0;else if(r||t.value)i.push(this.sourceToken),e.items.push({start:i,explicitKey:!0});else this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]});this.onKeyLine=!0;return;case"map-value-ind":if(t.explicitKey)if(!t.sep)if(mt(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let o=nn(t.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]})}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(mt(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(kp(t.key)&&!mt(t.sep,"newline")){let o=nn(t.start),{key:s,sep:a}=t;a.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:s,sep:a}]})}else if(i.length>0)t.sep=t.sep.concat(i,this.sourceToken);else t.sep.push(this.sourceToken);else if(!t.sep)Object.assign(t,{key:null,sep:[this.sourceToken]});else if(t.value||r)e.items.push({start:i,key:null,sep:[this.sourceToken]});else if(mt(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]});else t.sep.push(this.sourceToken);this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let o=this.flowScalar(this.type);if(r||t.value)e.items.push({start:i,key:o,sep:[]}),this.onKeyLine=!0;else if(t.sep)this.stack.push(o);else Object.assign(t,{key:o,sep:[]}),this.onKeyLine=!0;return}default:{let o=this.startBlockValue(e);if(o){if(o.type==="block-seq"){if(!t.explicitKey&&t.sep&&!mt(t.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else if(n)e.items.push({start:i});this.stack.push(o);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 n="end"in t.value?t.value.end:void 0;if((Array.isArray(n)?n[n.length-1]:void 0)?.type==="comment")n?.push(this.sourceToken);else 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]?.value?.end;if(Array.isArray(r)){_i(r,t.start),r.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;if(t.value||mt(t.start,"seq-item-ind"))e.items.push({start:[this.sourceToken]});else t.start.push(this.sourceToken);return}if(this.indent>e.indent){let n=this.startBlockValue(e);if(n){this.stack.push(n);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type==="flow-error-end"){let n;do yield*this.pop(),n=this.peek(1);while(n?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":if(!t||t.sep)e.items.push({start:[this.sourceToken]});else t.start.push(this.sourceToken);return;case"map-value-ind":if(!t||t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else Object.assign(t,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":if(!t||t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else t.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let r=this.flowScalar(this.type);if(!t||t.value)e.items.push({start:[],key:r,sep:[]});else if(t.sep)this.stack.push(r);else Object.assign(t,{key:r,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let n=this.startBlockValue(e);if(n)this.stack.push(n);else yield*this.pop(),yield*this.step()}else{let n=this.peek(2);if(n.type==="block-map"&&(this.type==="map-value-ind"&&n.indent===e.indent||this.type==="newline"&&!n.items[n.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&n.type!=="flow-collection"){let r=wi(n),i=nn(r);_p(e);let o=e.end.splice(1,e.end.length);o.push(this.sourceToken);let s={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:i,key:e,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=s}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let t=this.source.indexOf(`
|
|
138
|
+
`)+1;while(t!==0)this.onNewLine(this.offset+t),t=this.source.indexOf(`
|
|
139
|
+
`,t)+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=wi(e),n=nn(t);return n.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let t=wi(e),n=nn(t);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){if(this.type!=="comment")return!1;if(this.indent<=t)return!1;return e.every((n)=>n.type==="newline"||n.type==="space")}*documentEnd(e){if(this.type!=="doc-mode"){if(e.end)e.end.push(this.sourceToken);else e.end=[this.sourceToken];if(this.type==="newline")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;case"space":case"comment":default:if(e.end)e.end.push(this.sourceToken);else e.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}}U1.Parser=xp});var Tp=P(function(V1){var Sp=Bs(),G1=Zn(),Kn=Gn(),q1=es(),B1=N(),H1=ea(),Ap=ta();function $p(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new H1.LineCounter||null,prettyErrors:t}}function F1(e,t={}){let{lineCounter:n,prettyErrors:r}=$p(t),i=new Ap.Parser(n?.addNewLine),o=new Sp.Composer(t),s=Array.from(o.compose(i.parse(e)));if(r&&n)for(let a of s)a.errors.forEach(Kn.prettifyError(e,n)),a.warnings.forEach(Kn.prettifyError(e,n));if(s.length>0)return s;return Object.assign([],{empty:!0},o.streamInfo())}function Pp(e,t={}){let{lineCounter:n,prettyErrors:r}=$p(t),i=new Ap.Parser(n?.addNewLine),o=new Sp.Composer(t),s=null;for(let a of o.compose(i.parse(e),!0,e.length))if(!s)s=a;else if(s.options.logLevel!=="silent"){s.errors.push(new Kn.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(r&&n)s.errors.forEach(Kn.prettifyError(e,n)),s.warnings.forEach(Kn.prettifyError(e,n));return s}function K1(e,t,n){let r=void 0;if(typeof t==="function")r=t;else if(n===void 0&&t&&typeof t==="object")n=t;let i=Pp(e,n);if(!i)return null;if(i.warnings.forEach((o)=>q1.warn(i.options.logLevel,o)),i.errors.length>0)if(i.options.logLevel!=="silent")throw i.errors[0];else i.errors=[];return i.toJS(Object.assign({reviver:r},n))}function W1(e,t,n){let r=null;if(typeof t==="function"||Array.isArray(t))r=t;else if(n===void 0&&t)n=t;if(typeof n==="string")n=n.length;if(typeof n==="number"){let i=Math.round(n);n=i<1?void 0:i>8?{indent:8}:{indent:i}}if(e===void 0){let{keepUndefined:i}=n??t??{};if(!i)return}if(B1.isDocument(e)&&!r)return e.toString(n);return new G1.Document(e,r,n).toString(n)}V1.parse=K1;V1.parseAllDocuments=F1;V1.parseDocument=Pp;V1.stringify=W1});var Cc={};wl(Cc,{default:()=>WT});var Rc={};wl(Rc,{default:()=>YT});class v extends Error{reason;fix;constructor(e,t){super(e);this.reason=e;this.fix=t;this.name="TapsterError"}}class R extends v{status;constructor(e,t,n){super(e,t);this.status=n;this.name="GitHubError"}}import{existsSync as xt,readdirSync as vv,readFileSync as hv}from"fs";import{basename as bo,join as ee}from"path";var eA=Bs(),tA=Zn(),nA=Ts(),na=Gn(),rA=Pn(),gt=N(),iA=pt(),oA=W(),sA=ht(),aA=ft(),kR=yi(),cA=Xs(),lA=ea(),uA=ta(),ki=Tp(),Ep=An();var pA=eA.Composer,dA=tA.Document,hA=nA.Schema,{YAMLError:fA,YAMLParseError:mA,YAMLWarning:gA}=na,vA=rA.Alias,{isAlias:yA,isCollection:bA,isDocument:wA,isMap:Ie,isNode:_A,isPair:kA,isScalar:xA,isSeq:Rt}=gt,SA=iA.Pair,AA=oA.Scalar,$A=sA.YAMLMap,PA=aA.YAMLSeq;var TA=cA.Lexer,EA=lA.LineCounter,OA=uA.Parser,{parse:ie,parseAllDocuments:CA,parseDocument:vt,stringify:RA}=ki,{visit:IA,visitAsync:NA}=Ep;function Vn(e){let t=Object.values(e).filter((r)=>typeof r==="number");return Object.entries(e).filter(([r,i])=>t.indexOf(+r)===-1).map(([r,i])=>i)}function ia(e,t="|"){return e.map((n)=>aa(n)).join(t)}function Yn(e,t){if(typeof t==="bigint")return t.toString();return t}class Op{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;if(e!==void 0)this._value=e(),this._getter=void 0;return this._value}}function Jn(e){return new Op(e)}function Cp(e){return e===null||e===void 0}function xi(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Rp(e,t){let n=e/t,r=Math.round(n),i=4*Number.EPSILON*Math.max(Math.abs(n),1);if(Math.abs(n-r)<i)return 0;return n-r}function ge(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Qn(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function Xe(e){return Qn(e._zod.def)??e._zod.def.shape}function Ip(e,t,n){Object.defineProperty(e,t,{get(){let r=n();return ge(this,t,r),r},enumerable:!0,configurable:!0})}function Np(e,t,n){if(t in e)ge(e,t,n);else e[t]=n}function It(e,t,n,r){let i=Xe(t);for(let o of n){let s=Object.getOwnPropertyDescriptor(i,o);if(!s.enumerable)continue;if(s.get)Ip(e,o,()=>{let a=t._zod.def.shape[o];return r?r(a,o):a});else Np(e,o,r?r(s.value,o):s.value)}}function zA(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);if(!r.enumerable)continue;if(r.get)Ip(e,n,()=>t[n]);else Np(e,n,r.value)}}function ve(...e){let t={};for(let n of e){let r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function zp(e){return JSON.stringify(e)}function Dp(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var oa="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function rn(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var Lp=Jn(()=>{if(ce.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function Nt(e){if(rn(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!=="function")return!0;let n=t.prototype;if(rn(n)===!1)return!1;if(Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)return!1;return!0}function sa(e){if(Nt(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}var jp=new Set(["string","number","symbol"]);function bt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Me(e,t,n){let r=new e._zod.constr(t??e._zod.def);if(!t||n?.parent)r._zod.parent=e;return r}function T(e){let t=e;if(!t)return{};if(typeof t==="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}if(delete t.message,typeof t.error==="string")return{...t,error:()=>t.error};return t}function aa(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function Mp(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var Si=(()=>({safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}))(),ca={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function DA(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let o={};return It(o,e,Ai(e,t)),Me(e,ve(n,{shape:o,checks:[]}))}function Ai(e,t){let n=Xe(e),r=[];for(let i of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,i)?.enumerable)throw Error(`Unrecognized key: "${String(i)}"`);if(t[i])r.push(i)}return r}function LA(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let o=new Set(Ai(e,t)),s={};return It(s,e,Reflect.ownKeys(Xe(e)).filter((a)=>!o.has(a))),Me(e,ve(n,{shape:s,checks:[]}))}function jA(e,t){if(!Nt(t))throw Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let i=Xe(e);for(let o of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(i,o)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Me(e,ve(e._zod.def,{shape:Up(e,t)}))}function Up(e,t){let n={};return It(n,e,Reflect.ownKeys(Xe(e))),zA(n,t),n}function MA(e,t){if(!Nt(t))throw Error("Invalid input to safeExtend: expected a plain object");return Me(e,ve(e._zod.def,{shape:Up(e,t)}))}function UA(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let n={};It(n,e,Reflect.ownKeys(Xe(e))),It(n,t,Reflect.ownKeys(Xe(t)));let r=ve(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Me(e,r)}function Zp(e,t,n,r="partial"){let o=t._zod.def.checks;if(o&&o.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(Ai(t,n)):void 0,c={};return It(c,t,Reflect.ownKeys(Xe(t)),e&&((l,u)=>a&&!a.has(u)?l:new e({type:"optional",innerType:l}))),Me(t,ve(t._zod.def,{shape:c,checks:[]}))}function ZA(e,t,n){let r=n?new Set(Ai(t,n)):void 0,i={};return It(i,t,Reflect.ownKeys(Xe(t)),(o,s)=>r&&!r.has(s)?o:new e({type:"nonoptional",innerType:o})),Me(t,ve(t._zod.def,{shape:i}))}function Ae(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Gp(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Ue(e,t){return t.map((n)=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function Wn(e){return typeof e==="string"?e:e?.message}function la(e){let t=[];for(let n of e??[]){let r=n._zod.def;if(!/_(length|size)$|_equals$/.test(r.check))break;let i=r.maximum??r.length??r.size;if(i>=0)t.push([i,n])}return t}function $i(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function Ze(e,t,n){var r;let i=e.inst?._zod?.traits;if(i?.has("$ZodType"))if(i.has("$ZodCheck"))(r=e).schema??(r.schema=e.inst);else e.schema=e.inst;let o=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,s=e.message?e.message:Wn(e.inst?._zod.def?.error?.(e))??Wn(o?.(e))??Wn(t?.error?.(e))??Wn(n.customError?.(e))??Wn(n.localeError?.(e))??"Invalid input",a={};for(let c of Object.keys(e)){if(c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__")continue;a[c]=e[c]}if(a.path??(a.path=[]),a.message=s,t?.reportInput)a.input=e.input;return a}var GA=/[\uD800-\uDBFF]/;function Pi(e){let t=e.length;if(!GA.test(e))return t;let n=t;for(let r=0;r<t-1;r++)if((e.charCodeAt(r)&64512)===55296&&(e.charCodeAt(r+1)&64512)===56320)n--,r++;return n}function Ti(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function qp(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function zt(...e){let[t,n,r]=e;if(typeof t==="string")return{message:t,code:"custom",input:n,inst:r};return{...t}}function Bp(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);if(r.get)Object.defineProperty(e,n,{...r,enumerable:!1});else qA(e,n,r.value)}}function et(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function Ei(e,t,n){return et(e,t,n,!1)}function Hp(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return et(this,n,r(this))},set(i){et(this,n,i)}})}return t}function qA(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:et(this,t,n.bind(this))},set(r){et(this,t,r)}})}function BA(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var ra,yt=!1,HA={configurable:!0,get(){yt=!0;return}};function D(e,t,n){let r=Object.getPrototypeOf(e._zod);if(t in r&&ra!==e._zod){ra=void 0;return}ra=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,HA);let i=yt;yt=!1;try{let o=n(this);if(yt)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o});return yt=yt||i,o}catch(o){throw delete this[t],yt=yt||i,o}},set(i){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i})}})}function FA(e,t,n,r){let i=BA(e,t);if(!i)return;Object.defineProperty(i,t,{configurable:!0,get(){let o={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,o),o.value=n(this),Object.defineProperty(this,t,o),o.value},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:o})}})}var KA="~constantCatch";function Fp(e){let t=()=>e;return t[KA]=!0,t}var Kp;var ua={value:void 0,enumerable:!1},Wp="captureStackTrace"in Error?Error:null;function WA(e){let t=Wp;if(t){let n=t.stackTraceLimit;if(typeof n==="number"){try{t.stackTraceLimit=0}catch{return Wp=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function y(e,t,n,r){let i={};function o(d){this.def=d,this.constr=p,this.traits=new Set}o.prototype=i;let s=n,a=s&&new WeakSet;function c(d,h){if(!d._zod){ua.value=new o(h);try{Object.defineProperty(d,"_zod",ua)}finally{ua.value=void 0}}else if(d._zod.traits.has(e))return;if(d._zod.traits.add(e),t(d,h),a){let m=Object.getPrototypeOf(d),g=d._zod.constr.prototype,w=m;while(w&&w!==g)w=Object.getPrototypeOf(w);let x=w??m;if(!a.has(x))a.add(x),Bp(x,s)}let f=p.prototype;for(let m in f){if(!Object.prototype.hasOwnProperty.call(f,m))continue;if(!(m in d))d[m]=f[m].bind(d)}}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function p(d){let h=r?.Parent?WA(u):this;c(h,d);let f=h._zod.deferred;if(f){for(let g of f)g();h._zod.deferred=void 0}let m=globalThis.__zod_globalConfig?.postProcessor;if(m)m(h);return h}return Object.defineProperty(p,"init",{value:c}),Object.defineProperty(p,Symbol.hasInstance,{value:(d)=>{if(r?.Parent&&d instanceof r.Parent)return!0;return d?._zod?.traits?.has(e)}}),Object.defineProperty(p,"name",{value:e}),p}class Ge extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Xn extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(Kp=globalThis).__zod_globalConfig??(Kp.__zod_globalConfig={});var ce=globalThis.__zod_globalConfig;function ye(e){if(e)Object.assign(ce,e);return ce}function VA(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Yn,2)),e.message}function YA(e){this._zod.message=e}var JA={get:VA,set:YA,enumerable:!0,configurable:!0},da={value:void 0,enumerable:!1},Vp=new WeakSet([Object.prototype,Error.prototype]),Yp=(e,t)=>{e.name="$ZodError",da.value=t,Object.defineProperty(e,"issues",da),da.value=void 0,Object.defineProperty(e,"message",JA);let n=Object.getPrototypeOf(e);if(!Vp.has(n))Vp.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let r=()=>this.message;return Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0})}})},Jp=y("$ZodError",Yp),PR=y("$ZodError",Yp,void 0,{Parent:Error});function QA(e,t,n){if(!Object.prototype.hasOwnProperty.call(e,t))if(t==="__proto__")Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0});else e[t]=n();return e[t]}function Qp(e,t=(n)=>n.message){let n={},r=[];for(let i of e.issues)if(i.path.length>0)QA(n,i.path[0],()=>[]).push(t(i));else r.push(t(i));return{formErrors:r,fieldErrors:n}}function Xp(e,t=(n)=>n.message){let n={_errors:[]},r=(i,o=[])=>{for(let s of i.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map((a)=>r({issues:a},[...o,...s.path]));else if(s.code==="invalid_key")r({issues:s.issues},[...o,...s.path]);else if(s.code==="invalid_element")r({issues:s.issues},[...o,...s.path]);else{let a=[...o,...s.path];if(a.length===0)n._errors.push(t(s));else{let c=n,l=0;while(l<a.length){let u=a[l],p=l===a.length-1;if(u==="_errors"){if(p)c._errors.push(t(s));l++;continue}if(!Object.prototype.hasOwnProperty.call(c,u))Object.defineProperty(c,u,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let d=c[u];if(p)d._errors.push(t(s));c=d,l++}}}};return r(e),n}function Oi(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Ci=(e)=>{let t=(n,r,i,o)=>{let s=i?{...i,async:!1}:{async:!1},a=n._zod.run({value:r,issues:[]},s);if(a instanceof Promise)throw new Ge;if(a.issues.length){let c=new(o?.Err??e)(a.issues.map((l)=>Ze(l,s,ye())));throw oa(c,o?.callee??t),c}return a.value};return t};var Ri=(e)=>{let t=async(n,r,i,o)=>{let s=i?{...i,async:!0}:{async:!0},a=n._zod.run({value:r,issues:[]},s);if(a instanceof Promise)a=await a;if(a.issues.length){let c=new(o?.Err??e)(a.issues.map((l)=>Ze(l,s,ye())));throw oa(c,o?.callee??t),c}return a.value};return t};var Ii=(e)=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},i);if(o instanceof Promise)throw new Ge;return o.issues.length?ed(e,o.issues,i):{success:!0,data:o.value}};function ed(e,t,n){let r;return{success:!1,get error(){if(!r)r=new e(t.map((i)=>Ze(i,n,ye()))),t=void 0,n=void 0;return r},set error(i){r=i,t=void 0,n=void 0}}}var Ni=(e)=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},i);if(o instanceof Promise)o=await o;return o.issues.length?ed(e,o.issues,i):{success:!0,data:o.value}};var XA=Symbol.for("zod.compile.invalid"),e$=Symbol.for("zod.compile.fallback"),ha=(e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==XA)return!0;if(r.definite===!0&&n===void 0)return!1}return t$(e,t,n)};function t$(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,o;if(i)r[e$]=!0,o=i({value:t,issues:[]},r);else o=e._zod.run({value:t,issues:[]},r);if(o instanceof Promise)throw new Ge;return o.issues.length===0}var fa=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);if(i instanceof Promise)i=await i;return i.issues.length===0},td=(e)=>{let t=Ci(e),n=(r,i,o,s)=>{let a=o?{...o,direction:"backward"}:{direction:"backward"};return t(r,i,a,Oi(n,s))};return n};var nd=(e)=>{let t=Ci(e),n=(r,i,o,s)=>t(r,i,o,Oi(n,s));return n};var rd=(e)=>{let t=Ri(e),n=async(r,i,o,s)=>{let a=o?{...o,direction:"backward"}:{direction:"backward"};return await t(r,i,a,Oi(n,s))};return n};var id=(e)=>{let t=Ri(e),n=async(r,i,o,s)=>await t(r,i,o,Oi(n,s));return n};var od=(e)=>(t,n,r)=>{let i=r?{...r,direction:"backward"}:{direction:"backward"};return Ii(e)(t,n,i)};var sd=(e)=>(t,n,r)=>Ii(e)(t,n,r);var ad=(e)=>async(t,n,r)=>{let i=r?{...r,direction:"backward"}:{direction:"backward"};return Ni(e)(t,n,i)};var cd=(e)=>async(t,n,r)=>Ni(e)(t,n,r);var ld=/^[cC][0-9a-z]{6,}$/,ud=/^[0-9a-z]+$/,pd=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,dd=/^[0-9a-vA-V]{20}$/,hd=/^[A-Za-z0-9]{27}$/,fd=/^[a-zA-Z0-9_-]{21}$/;function md(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var gd=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var vd=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,ga=(e)=>{if(!e)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var yd=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var n$="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function bd(){return new RegExp(n$,"u")}var wd=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,_d=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var kd=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,xd=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Sd=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ad=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var $d=/^https?$/,Pd=/^\+[1-9]\d{6,14}$/;var Td="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function r$(e){return new RegExp(`^${e}$`)}var Ed=r$(Td);function ma(e){return typeof e.precision==="number"?e.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":e.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?":"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function Od(e){return new RegExp(`^${ma(e)}$`)}function Cd(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${ma({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,r=e.local?`${n}|${ma({precision:e.precision})}`:n;return new RegExp(`^${Td}T(?:${r})$`)}var Rd=/^[\s\S]{0,}$/;var va=/^-?\d+$/,er=/^-?\d+(?:\.\d+)?$/,Id=/^(?:true|false)$/i;var Nd=/^[^A-Z]*$/,zd=/^[^a-z]*$/;var te=y("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])});var ya=(e)=>{let t=e.value;return!Cp(t)&&t.length!==void 0},zi={number:"number",bigint:"bigint",object:"date"},ba=y("$ZodCheckLessThan",(e,t)=>{te.init(e,t);let n=zi[typeof t.value];e._zod.check=(r)=>{if(t.inclusive?r.value<=t.value:r.value<t.value)return;r.issues.push({origin:zi[typeof r.value]??n,code:"too_big",maximum:typeof t.value==="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),wa=y("$ZodCheckGreaterThan",(e,t)=>{te.init(e,t);let n=zi[typeof t.value];e._zod.check=(r)=>{if(t.inclusive?r.value>=t.value:r.value>t.value)return;r.issues.push({origin:zi[typeof r.value]??n,code:"too_small",minimum:typeof t.value==="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Dd=y("$ZodCheckMultipleOf",(e,t)=>{te.init(e,t),e._zod.check=(n)=>{if(typeof n.value!==typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof n.value==="bigint"?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):Rp(n.value,t.value)===0)return;n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Ld=y("$ZodCheckNumberFormat",(e,t)=>{te.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),r=n?"int":"number",[i,o]=Si[t.format];e._zod.check=(s)=>{let a=s.value;if(n){if(!Number.isInteger(a)){s.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){if(a>0)s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});else s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}if(a<i)s.issues.push({origin:"number",input:a,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort});if(a>o)s.issues.push({origin:"number",input:a,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}});var jd=y("$ZodCheckMaxLength",(e,t)=>{var n;te.init(e,t),(n=e._zod.def).when??(n.when=ya),e._zod.check=(r)=>{let i=r.value,o=i.length;if((typeof i==="string"&&o>t.maximum?Pi(i):o)<=t.maximum)return;let a=Ti(i);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Md=y("$ZodCheckMinLength",(e,t)=>{var n;te.init(e,t),(n=e._zod.def).when??(n.when=ya),e._zod.check=(r)=>{let i=r.value,o=i.length;if((typeof i==="string"&&o>=t.minimum&&o<t.minimum*2?Pi(i):o)>=t.minimum)return;let a=Ti(i);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Ud=y("$ZodCheckLengthEquals",(e,t)=>{var n;te.init(e,t),(n=e._zod.def).when??(n.when=ya),e._zod.check=(r)=>{let i=r.value,o=i.length,s=typeof i==="string"&&o>=t.length&&o<=t.length*2?Pi(i):o;if(s===t.length)return;let a=Ti(i),c=s>t.length;r.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),nr=y("$ZodCheckStringFormat",(e,t)=>{var n,r;if(te.init(e,t),t.pattern)(n=e._zod).check??(n.check=(i)=>{if(t.pattern.lastIndex=0,t.pattern.test(i.value))return;i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(r=e._zod).check??(r.check=()=>{})}),Zd=y("$ZodCheckRegex",(e,t)=>{nr.init(e,t),e._zod.check=(n)=>{if(t.pattern.lastIndex=0,t.pattern.test(n.value))return;n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Gd=y("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Nd),nr.init(e,t)}),qd=y("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=zd),nr.init(e,t)}),Bd=y("$ZodCheckIncludes",(e,t)=>{te.init(e,t);let n=bt(t.includes),r=new RegExp(typeof t.position==="number"?`^.{${t.position},}${n}`:n);t.pattern=r,e._zod.check=(i)=>{if(i.value.includes(t.includes,t.position))return;i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:e,continue:!t.abort})}}),Hd=y("$ZodCheckStartsWith",(e,t)=>{te.init(e,t);let n=new RegExp(`^${bt(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.check=(r)=>{if(r.value.startsWith(t.prefix))return;r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),Fd=y("$ZodCheckEndsWith",(e,t)=>{te.init(e,t);let n=new RegExp(`.*${bt(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.check=(r)=>{if(r.value.endsWith(t.suffix))return;r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}});var Kd=y("$ZodCheckOverwrite",(e,t)=>{te.init(e,t),e._zod.check=(n)=>{n.value=t.tx(n.value)}});class _a{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let n=e.split(`
|
|
140
|
+
`).filter((o)=>o),r=Math.min(...n.map((o)=>o.length-o.trimStart().length)),i=n.map((o)=>o.slice(r)).map((o)=>" ".repeat(this.indent*2)+o);for(let o of i)this.content.push(o)}compile(){let e=Function,t=this?.content??[""];return new e(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
|
|
141
|
+
${t.join(`
|
|
142
|
+
`)}
|
|
143
|
+
};`)(...Object.values(this.closed))}}var Vd={major:4,minor:6,patch:7};var Z=y("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Vd;let r=e._zod.def.checks,i=e._zod.traits.has("$ZodCheck")?[e,...r??[]]:r?.length?[...r]:[];for(let o of i)for(let s of o._zod.onattach)s(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let o=(a,c,l)=>{if(a.memo)return a;let u=Ae(a),p;for(let d of c){if(d._zod.def.when){if(Gp(a))continue;if(!d._zod.def.when(a))continue}else if(u)continue;let h=a.issues.length,f=d._zod.check(a);if(f instanceof Promise&&l?.async===!1)throw new Ge;if(p||f instanceof Promise)p=(p??Promise.resolve()).then(async()=>{if(await f,a.issues.length===h)return;if($i(a.issues,h,e),!u)u=Ae(a,h)});else{if(a.issues.length===h)continue;if($i(a.issues,h,e),!u)u=Ae(a,h)}}if(p)return p.then(()=>a);return a},s=(a,c,l)=>{if(Ae(a))return a.aborted=!0,a;let u=o(c,i,l);if(u instanceof Promise){if(l.async===!1)throw new Ge;return u.then((p)=>e._zod.parse(p,l))}return e._zod.parse(u,l)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let u=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});if(u instanceof Promise)return u.then((p)=>s(p,a,c));return s(u,a,c)}let l=e._zod.parse(a,c);if(l instanceof Promise){if(c.async===!1)throw new Ge;return l.then((u)=>o(u,i,c))}return o(l,i,c)}}},{get "~standard"(){return Ei(this,"~standard",xa(this))},set "~standard"(e){et(this,"~standard",e)}}),lh=(e,t)=>e.issues.length?{issues:e.issues.map((n)=>Ze(n,t,ye()))}:{value:e.value};async function i$(e,t){let n={async:!0};return lh(await e._zod.run({value:t,issues:[]},n),n)}function xa(e){return{validate:(t)=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return lh(r,n)}catch(r){}return i$(e,t)},vendor:"zod",version:1}}var Mi=y("$ZodString",(e,t)=>{Z.init(e,t),e._zod.pattern=t.pattern??Rd,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch(i){}if(typeof n.value==="string")return n;return n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),G=y("$ZodStringFormat",(e,t)=>{nr.init(e,t),Mi.init(e,t)}),uh=y("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=vd),G.init(e,t)}),ph=y("$ZodUUID",(e,t)=>{if(t.version){let r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=ga(r))}else t.pattern??(t.pattern=ga());G.init(e,t)}),dh=y("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=yd),G.init(e,t)}),hh=1,Li=2;function fh(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function o$(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return fh(e)||Li;return s$(e,t)}function s$(e,t){if(!t.normalize&&t.protocol?.source===$d.source&&!/^https?:\/\//i.test(e))return hh;try{if(typeof URL<"u"){let n=URL;if(typeof n.parse==="function")return n.parse(e)??Li}return new URL(e)}catch{return Li}}var a$=/[\t\n\r]/g;function Yd(e){return e.replace(a$,"")}function c$(e,t){return t.lastIndex=0,t.test(e.hostname)}function l$(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var mh=y("$ZodURL",(e,t)=>{G.init(e,t),e._zod.check=(n)=>{try{let r=n.value.trim(),i=o$(r,t);if(i===hh){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(i===Li){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=Yd(r);return}if(t.hostname&&!c$(i,t.hostname))n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort});if(t.protocol&&!l$(i,t.protocol))n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort});n.value=t.normalize?i.href:Yd(r);return}catch(r){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),gh=y("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=bd()),G.init(e,t)}),vh=y("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?fd:md(t.length)),G.init(e,t)}),yh=y("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=ld),G.init(e,t)}),bh=y("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=ud),G.init(e,t)}),wh=y("$ZodULID",(e,t)=>{t.pattern??(t.pattern=pd),G.init(e,t)}),_h=y("$ZodXID",(e,t)=>{t.pattern??(t.pattern=dd),G.init(e,t)}),kh=y("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=hd),G.init(e,t)}),xh=y("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Cd(t)),G.init(e,t)}),Sh=y("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Ed),G.init(e,t)}),Ah=y("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Od(t)),G.init(e,t)}),$h=y("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=gd),G.init(e,t)}),Ph=y("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=wd),G.init(e,t)}),u$=/^[0-9a-fA-F:.]+$/;function Th(e){if(!u$.test(e))return!1;return fh(`http://[${e}]`)}var Eh=y("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=_d),G.init(e,t),e._zod.check=(n)=>{if(!Th(n.value))n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}});var Oh=y("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=kd),G.init(e,t)});function p$(e){let t=e.split("/");if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);if(`${i}`!==r)return!1;if(i<0||i>128)return!1;return Th(n)}var Ch=y("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=xd),G.init(e,t),e._zod.check=(n)=>{if(!p$(n.value))n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function Rh(e){if(e==="")return!0;if(/\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Sa=/^[0-9a-zA-Z+/]*={0,2}$/,Ih=y("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Sa),G.init(e,t),e._zod.check=(n)=>{if(Rh(n.value))return;n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),Ui=/^[A-Za-z0-9_-]*$/;function d$(e){if(!Ui.test(e))return!1;let t=e.replace(/[-_]/g,(r)=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Rh(n)}var Nh=y("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Ui),G.init(e,t),e._zod.check=(n)=>{if(d$(n.value))return;n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),zh=y("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Pd),G.init(e,t)});function h$(e,t=null){try{let n=e.split(".");if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));if("typ"in i&&i?.typ!=="JWT")return!1;if(!i.alg)return!1;if(t&&(!("alg"in i)||i.alg!==t))return!1;return!0}catch{return!1}}var Dh=y("$ZodJWT",(e,t)=>{G.init(e,t),e._zod.check=(n)=>{if(h$(n.value,t.alg))return;n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}});var Aa=y("$ZodNumber",(e,t)=>{Z.init(e,t),e._zod.pattern=er,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch(s){}let i=n.value;if(typeof i==="number"&&!Number.isNaN(i)&&Number.isFinite(i))return n;let o=typeof i==="number"?Number.isNaN(i)?"NaN":!Number.isFinite(i)?String(i):void 0:void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...o?{received:o}:{}}),n}}),Lh=y("$ZodNumberFormat",(e,t)=>{Ld.init(e,t),Aa.init(e,t)}),jh=y("$ZodBoolean",(e,t)=>{Z.init(e,t),e._zod.pattern=Id,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(o){}let i=n.value;if(typeof i==="boolean")return n;return n.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),n}});var Mh=y("$ZodUnknown",(e,t)=>{Z.init(e,t),e._zod.parse=(n)=>n}),Uh=y("$ZodNever",(e,t)=>{Z.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function f$(e,t){let n=la(e._zod.def.checks);if(!n.length)return;let r=Math.min(...n.map((o)=>o[0])),i=e._zod.parse;e._zod.parse=(o,s)=>{let a=t(o.value);if(a>r&&!s?.skipChecks&&s?.direction!=="backward"){for(let[c,l]of la(e._zod.def.checks))if(a>c&&l._zod.def.when(o)){let u=o.issues.length;return l._zod.check(o),o.issues[u].continue=!1,$i(o.issues,u,e),o}}return i(o,s)}}var m$=(e)=>Array.isArray(e)?e.length:-1;function Jd(e,t,n){if(e.issues.length)t.issues.push(...Ue(n,e.issues));t.value[n]=e.value}var Zh=y("$ZodArray",(e,t)=>{Z.init(e,t);let n=ce.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),r;r.value=n?n.alloc(e,r,Array(o.length),i):Array(o.length);let s=[],a=i?.abortEarly;for(let c=0;c<o.length;c++){let l=o[c],u=t.element._zod.run({value:l,issues:[]},i);if(u instanceof Promise)s.push(u.then((p)=>Jd(p,r,c)));else if(Jd(u,r,c),a&&u.issues.length!==0&&Ae(u))break}if(s.length)return Promise.all(s).then(()=>r);return r},f$(e,m$)});function ji(e,t,n,r,i,o){let s=n in r,a=o==="optional";if(!s&&a&&i==="optional")return;if(e.issues.length){if(i!==void 0&&a&&!s)return;t.issues.push(...Ue(n,e.issues))}if(!s&&i===void 0){if(!e.issues.length)t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}if(e.value===void 0){if(s||i==="defaulted"&&!a)t.value[n]=void 0}else t.value[n]=e.value}var g$=[];function Gh(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:g$,i=r.length?[...t,...r]:t;for(let s of i)if(!e.shape?.[s]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(s)}": expected a Zod schema`);let o=Mp(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(o)}}function qh(e,t,n,r,i,o,s){let a=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,{optin:p,optout:d}=l,h=0;for(let f in t){if(s&&n.issues.length!==h){if(Ae(n,h))break;h=n.issues.length}if(c.has(f))continue;if(f==="__proto__"){if(u==="never")a.push(f);continue}if(u==="never"){a.push(f);continue}let m=l.run({value:t[f],issues:[]},r);if(m instanceof Promise)e.push(m.then((g)=>ji(g,n,f,t,p,d)));else ji(m,n,f,t,p,d)}if(a.length)n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:o,continue:!0});if(!e.length)return n;return Promise.all(e).then(()=>n)}var v$=y("$ZodObject",(e,t)=>{Z.init(e,t);let n=Object.getOwnPropertyDescriptor(t,"shape"),r=n?.get?n.get.raw:t.shape??{};if(r){let l=()=>{let u={...r};return Object.defineProperty(t,"shape",{value:u}),l.raw=u,u};l.raw=r,Object.defineProperty(t,"shape",{get:l})}let i=Jn(()=>Gh(t));D(e,"propValues",(l)=>{let u=l.def.shape,p={};for(let d in u){let h=u[d]._zod;if(h.values){if(!Object.prototype.hasOwnProperty.call(p,d))ge(p,d,new Set);for(let f of h.values)p[d].add(f);if(h.optin!==void 0)p[d].add(void 0)}}return p});let o=rn,s=t.catchall,a,c=ce.memoizer;c?.attach(e),e._zod.parse=(l,u)=>{a??(a=i.value);let p=l.value;if(!o(p))return l.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),l;l.value=c?c.alloc(e,l,{},u):{};let d=[],h=a.shape,f=u?.abortEarly,m=l.issues.length;for(let g of a.allKeys){if(f&&l.issues.length!==m){if(Ae(l,m))break;m=l.issues.length}if(g==="__proto__")continue;let w=h[g],x=w._zod.optin,_=w._zod.optout,b=w._zod.run({value:p[g],issues:[]},u);if(b instanceof Promise)d.push(b.then((k)=>ji(k,l,g,p,x,_)));else ji(b,l,g,p,x,_)}if(!s)return d.length?Promise.all(d).then(()=>l):l;return qh(d,p,l,u,i.value,e,f===!0)}}),Bh=y("$ZodObjectJIT",(e,t)=>{v$.init(e,t);let n=e._zod.parse,r=Jn(()=>Gh(t)),i=ce.memoizer,o=(h)=>{let f=r.value,m=f.symbolKeys,g=new _a(["payload","ctx"],{shape:h,inst:e,memo:i,syms:m}),w=(k)=>`shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`,x=(k,S)=>`
|
|
144
|
+
let ${k}_ab = false;
|
|
145
|
+
for (let i = 0; i < ${k}.issues.length; i++) {
|
|
146
|
+
const iss = ${k}.issues[i];
|
|
147
|
+
iss.path = iss.path ? [${S}, ...iss.path] : [${S}];
|
|
148
|
+
payload.issues.push(iss);
|
|
149
|
+
if (iss.continue !== true) ${k}_ab = true;
|
|
150
|
+
}
|
|
151
|
+
if (${k}_ab && ctx && ctx.abortEarly) {
|
|
152
|
+
payload.value = newResult;
|
|
153
|
+
return payload;
|
|
154
|
+
}`;g.write("const input = payload.value;");let _=Object.create(null),b=0;for(let k of f.allKeys)_[k]=`key_${b++}`;g.write(i?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let k of f.allKeys){if(k==="__proto__")continue;let S=_[k],O=typeof k==="symbol"?`syms[${m.indexOf(k)}]`:zp(k),A=`${O} in input`,L=h[k],ae=L?._zod?.optin,ke=ae!==void 0,B=L?._zod?.optout==="optional";if(g.write(`const ${S} = ${w(O)};`),ke&&B){let St=ae==="optional"?`${S}_present`:`${S}.value !== undefined || ${S}_present`;g.write(`
|
|
155
|
+
const ${S}_present = ${A};
|
|
156
|
+
if (!${S}.issues.length || ${S}_present) {
|
|
157
|
+
if (${S}.issues.length) {${x(S,O)}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (${St}) {
|
|
161
|
+
newResult[${O}] = ${S}.value;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
`)}else if(!ke)g.write(`
|
|
166
|
+
const ${S}_present = ${A};
|
|
167
|
+
if (${S}.issues.length) {${x(S,O)}
|
|
168
|
+
}
|
|
169
|
+
if (!${S}_present && !${S}.issues.length) {
|
|
170
|
+
payload.issues.push({
|
|
171
|
+
code: "invalid_type",
|
|
172
|
+
expected: "nonoptional",
|
|
173
|
+
input: undefined,
|
|
174
|
+
path: [${O}]
|
|
175
|
+
});
|
|
176
|
+
if (ctx && ctx.abortEarly) {
|
|
177
|
+
payload.value = newResult;
|
|
178
|
+
return payload;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (${S}_present) {
|
|
183
|
+
newResult[${O}] = ${S}.value;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
`);else if(g.write(`
|
|
187
|
+
if (${S}.issues.length) {${x(S,O)}
|
|
188
|
+
}
|
|
189
|
+
`),ae==="defaulted")g.write(`newResult[${O}] = ${S}.value;`);else g.write(`
|
|
190
|
+
if (${S}.value !== undefined || ${A}) {
|
|
191
|
+
newResult[${O}] = ${S}.value;
|
|
192
|
+
}
|
|
193
|
+
`)}return g.write("payload.value = newResult;"),g.write("return payload;"),g.compile()},s,a=rn,c=!ce.jitless,u=c&&Lp.value,p=t.catchall,d;e._zod.parse=(h,f)=>{d??(d=r.value);let m=h.value;if(!a(m))return h.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),h;if(c&&u&&f?.async===!1&&f.jitless!==!0){if(!s)s=o(t.shape);if(h=s(h,f),!p)return h;return qh([],m,h,f,d,e,f?.abortEarly===!0)}return n(h,f)}});function Qd(e,t,n,r){for(let o of e)if(o.issues.length===0)return t.value=o.value,t;let i=e.filter((o)=>!Ae(o));if(i.length===1)return t.value=i[0].value,i[0];return t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map((o)=>o.issues.map((s)=>Ze(s,r,ye())))}),t}var $a=y("$ZodUnion",(e,t)=>{Z.init(e,t),D(e,"optin",(r)=>r.def.options.some((i)=>i._zod.optin==="defaulted")?"defaulted":r.def.options.some((i)=>i._zod.optin!==void 0)?"optional":void 0),D(e,"optout",(r)=>r.def.options.some((i)=>i._zod.optout==="optional")?"optional":void 0),D(e,"values",(r)=>{if(r.def.options.every((i)=>i._zod.values))return new Set(r.def.options.flatMap((i)=>Array.from(i._zod.values)));return}),D(e,"pattern",(r)=>{if(r.def.options.every((i)=>i._zod.pattern)){let i=r.def.options.map((o)=>o._zod.pattern);return new RegExp(`^(${i.map((o)=>xi(o.source)).join("|")})$`)}return});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let o=!1,s=[];for(let a of t.options){let c=a._zod.run({value:r.value,issues:[]},i);if(c instanceof Promise)s.push(c),o=!0;else{if(c.issues.length===0)return c;s.push(c)}}if(!o)return Qd(s,r,e,i);return Promise.all(s).then((a)=>Qd(a,r,e,i))}});function y$(e){let t=new Map;for(let n of e.options){let r=n._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let i of r)if(t.has(i)){if(i!==void 0)throw Error(`Duplicate discriminator value "${String(i)}"`);t.set(i,null)}else t.set(i,n)}return t}var Hh=y("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,$a.init(e,t);let n=e._zod.parse;D(e,"propValues",(i)=>{let o={},s=0;for(let a of i.def.options){let c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw Error(`Invalid discriminated union option at index "${i.def.options.indexOf(a)}"`);if(c[i.def.discriminator]?.has(void 0))s++;for(let[l,u]of Object.entries(c)){if(!Object.prototype.hasOwnProperty.call(o,l))ge(o,l,new Set);for(let p of u)o[l].add(p)}}if(!i.def.unionFallback&&s>1)o[i.def.discriminator]?.delete(void 0);return o}),t.options.forEach((i,o)=>{let s=Qn(i._zod.def);if(s&&!Object.prototype.hasOwnProperty.call(s,t.discriminator))throw Error(`Invalid discriminated union option at index "${o}"`)});let r=Jn(()=>y$(t));e._zod.parse=(i,o)=>{let s=i.value;if(!rn(s))return i.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),i;let a=s?.[t.discriminator],c=r.value.get(a);if(c&&(a!==void 0||o.direction!=="backward"))return c._zod.run(i,o);if(t.unionFallback||o.direction==="backward")return n(i,o);return i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(r.value.keys()).filter((l)=>r.value.get(l)!==null),input:s,path:[t.discriminator],inst:e}),i}}),Fh=y("$ZodIntersection",(e,t)=>{Z.init(e,t),e._zod.parse=(n,r)=>{let i=n.value,o=t.left._zod.run({value:i,issues:[]},r),s=t.right._zod.run({value:i,issues:[]},r);if(o instanceof Promise||s instanceof Promise)return Promise.all([o,s]).then(([c,l])=>Xd(n,c,l));return Xd(n,o,s)}});function ka(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(Nt(e)&&Nt(t)){let n=Object.keys(t),r=Object.keys(e).filter((o)=>n.indexOf(o)!==-1),i={...e,...t};if(Object.prototype.hasOwnProperty.call(i,"__proto__"))delete i.__proto__;for(let o of r){if(o==="__proto__")continue;let s=ka(e[o],t[o]);if(!s.valid)return{valid:!1,mergeErrorPath:[o,...s.mergeErrorPath]};i[o]=s.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],o=t[r],s=ka(i,o);if(!s.valid)return{valid:!1,mergeErrorPath:[r,...s.mergeErrorPath]};n.push(s.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Xd(e,t,n){let r=new Map,i,o=new Map,s=(l,u)=>{let p;if(l.code==="unrecognized_keys"&&!l.path?.length)i??(i=l),p=l.keys;else if(l.code==="invalid_key"&&l.origin==="record"&&l.path?.length===1){let d=String(l.path[0]);if(!o.has(d))o.set(d,l);p=[d]}else return!1;for(let d of p){if(!r.has(d))r.set(d,{});r.get(d)[u]=!0}return!0};for(let l of t.issues)if(!s(l,"l"))e.issues.push(l);for(let l of n.issues)if(!s(l,"r"))e.issues.push(l);let a=[...r].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(a.length){let l=i?a.filter((u)=>i.keys.includes(u)):[];if(l.length)e.issues.push({...i,keys:l});for(let u of a)if(!l.includes(u)&&o.has(u))e.issues.push(o.get(u))}let c=ka(t.value,n.value);if(!c.valid){if(Ae(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Kh=y("$ZodTuple",(e,t)=>{Z.init(e,t);let n=t.items,r=ce.memoizer;r?.attach(e),e._zod.parse=(i,o)=>{let s=i.value;if(!Array.isArray(s))return i.issues.push({input:s,inst:e,expected:"tuple",code:"invalid_type"}),i;i.value=r?r.alloc(e,i,[],o):[];let a=[],c=eh(n,"optin"),l=eh(n,"optout");if(!t.rest){if(s.length<c)return i.issues.push({code:"too_small",minimum:c,inclusive:!0,input:s,inst:e,origin:"array"}),i;if(s.length>n.length)i.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:s,inst:e,origin:"array"})}let u=Array(n.length),p=t.rest?o?.abortEarly:void 0,d=!1;for(let h=0;h<n.length;h++){let f=n[h]._zod.run({value:s[h],issues:[]},o);if(f instanceof Promise)a.push(f.then((m)=>{u[h]=m}));else if(u[h]=f,p&&!d&&f.issues.length)d=Ae(f)}if(t.rest&&!d){let h=n.length-1,f=s.slice(n.length),m=i.issues.length;for(let g of f){if(p&&i.issues.length!==m){if(Ae(i,m))break;m=i.issues.length}h++;let w=t.rest._zod.run({value:g,issues:[]},o);if(w instanceof Promise)a.push(w.then((x)=>th(x,i,h)));else th(w,i,h)}}if(a.length)return Promise.all(a).then(()=>nh(u,i,n,s,l));return nh(u,i,n,s,l)}});function eh(e,t){for(let n=e.length-1;n>=0;n--)if(!(t==="optin"?e[n]._zod.optin!==void 0:e[n]._zod.optout==="optional"))return n+1;return 0}function th(e,t,n){if(e.issues.length)t.issues.push(...Ue(n,e.issues));t.value[n]=e.value}function nh(e,t,n,r,i){for(let o=0;o<n.length;o++){let s=e[o],a=o<r.length;if(!a&&o>=i&&n[o]._zod.optin==="optional"){t.value.length=o;break}if(s.issues.length){if(!a&&o>=i){t.value.length=o;break}t.issues.push(...Ue(o,s.issues))}t.value[o]=s.value}for(let o=t.value.length-1;o>=r.length;o--)if(n[o]._zod.optout==="optional"&&t.value[o]===void 0)t.value.length=o;else break;return t}var Wh=y("$ZodRecord",(e,t)=>{Z.init(e,t);let n=ce.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let o=r.value;if(!Nt(o))return r.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),r;let s=[],a=t.keyType._zod.values;if(a&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};let c=new Set;for(let u of a)if(typeof u==="string"||typeof u==="number"||typeof u==="symbol"){if(c.add(typeof u==="number"?u.toString():u),u==="__proto__")continue;let p=t.keyType._zod.run({value:u,issues:[]},i);if(p instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(p.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:p.issues.map((f)=>Ze(f,i,ye())),input:u,path:[u],inst:e});continue}let d=p.value;if(d==="__proto__")continue;let h=t.valueType._zod.run({value:o[u],issues:[]},i);if(h instanceof Promise)s.push(h.then((f)=>{if(f.issues.length)r.issues.push(...Ue(u,f.issues));r.value[d]=f.value}));else{if(h.issues.length)r.issues.push(...Ue(u,h.issues));r.value[d]=h.value}}let l;for(let u in o)if(!c.has(u))if(t.mode==="loose"){if(u==="__proto__")continue;r.value[u]=o[u]}else l=l??[],l.push(u);if(l&&l.length>0)r.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:l,continue:!0})}else{r.value=n?n.alloc(e,r,{},i):{};let c;for(let l of Reflect.ownKeys(o)){if(l==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(o,l))continue;let u=t.keyType._zod.run({value:l,issues:[]},i);if(u instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof l==="string"&&er.test(l)&&u.issues.length){let f=t.keyType._zod.run({value:Number(l),issues:[]},i);if(f instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(f.issues.length===0)u=f}if(u.issues.length){if(t.mode==="loose")r.value[l]=o[l];else if(a)c=c??[],c.push(l);else r.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map((f)=>Ze(f,i,ye())),input:l,path:[l],inst:e});continue}let d=u.value;if(d==="__proto__")continue;let h=t.valueType._zod.run({value:o[l],issues:[]},i);if(h instanceof Promise)s.push(h.then((f)=>{if(f.issues.length)r.issues.push(...Ue(l,f.issues));r.value[d]=f.value}));else{if(h.issues.length)r.issues.push(...Ue(l,h.issues));r.value[d]=h.value}}if(c&&c.length>0)r.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:c,continue:!0})}if(s.length)return Promise.all(s).then(()=>r);return r}});var Vh=y("$ZodEnum",(e,t)=>{Z.init(e,t);let n=Vn(t.entries),r=new Set(n);e._zod.values=r,D(e,"pattern",(i)=>{let o=Vn(i.def.entries).filter((s)=>jp.has(typeof s));return new RegExp(o.length?`^(${o.map((s)=>bt(s.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(i,o)=>{let s=i.value;if(r.has(s))return i;return i.issues.push({code:"invalid_value",values:n,input:s,inst:e}),i}}),Yh=y("$ZodLiteral",(e,t)=>{Z.init(e,t);let n=new Set(t.values);e._zod.values=n,D(e,"pattern",(r)=>{let i=r.def.values;return new RegExp(i.length?`^(${i.map((o)=>typeof o==="string"?bt(o):o?bt(o.toString()):String(o)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,i)=>{let o=r.value;if(n.has(o))return r;return r.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),r}});var Jh=y("$ZodTransform",(e,t)=>{Z.init(e,t),e._zod.optin="optional",ce.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Xn(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then((s)=>(n.value=s,n));if(i instanceof Promise)throw new Ge;return n.value=i,n}});function rh(e,t){return e.value=t.issues.length?void 0:t.value,e}var Pa=y("$ZodOptional",(e,t)=>{Z.init(e,t),D(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",D(e,"values",(n)=>{let r=n.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),D(e,"pattern",(n)=>{let r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${xi(r.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;let i=t.innerType._zod.run({value:n.value,issues:[]},r);if(i instanceof Promise)return i.then((o)=>rh(n,o));return rh(n,i)}return t.innerType._zod.run(n,r)}}),Qh=y("$ZodExactOptional",(e,t)=>{Pa.init(e,t),D(e,"values",(n)=>n.def.innerType._zod.values),D(e,"pattern",(n)=>n.def.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),Xh=y("$ZodNullable",(e,t)=>{Z.init(e,t),D(e,"optin",(n)=>n.def.innerType._zod.optin),D(e,"optout",(n)=>n.def.innerType._zod.optout),D(e,"pattern",(n)=>{let r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${xi(r.source)}|null)$`):void 0}),D(e,"values",(n)=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>{if(n.value===null)return n;return t.innerType._zod.run(n,r)}}),ef=y("$ZodDefault",(e,t)=>{Z.init(e,t),e._zod.optin="defaulted",D(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;let i=t.innerType._zod.run(n,r);if(i instanceof Promise)return i.then((o)=>ih(o,t));return ih(i,t)}});function ih(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var tf=y("$ZodPrefault",(e,t)=>{Z.init(e,t),e._zod.optin="defaulted",D(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)n.value=t.defaultValue;return t.innerType._zod.run(n,r)}}),nf=y("$ZodNonOptional",(e,t)=>{Z.init(e,t),D(e,"values",(n)=>{let r=n.def.innerType._zod.values;return r?new Set([...r].filter((i)=>i!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);if(i instanceof Promise)return i.then((o)=>oh(o,e));return oh(i,e)}});function oh(e,t){if(!e.issues.length&&e.value===void 0)e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t});return e}function sh(e,t,n,r){if(!t.issues.length){if(e.value=t.value,t.memo)e.memo=!0;return e}return e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map((i)=>Ze(i,r,ye()))},input:e.value}),e}var rf=y("$ZodCatch",(e,t)=>{Z.init(e,t),D(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),D(e,"optout",(n)=>n.def.innerType._zod.optout),D(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);let i=t.innerType._zod.run({value:n.value,issues:[]},r);if(i instanceof Promise)return i.then((o)=>sh(n,o,t,r));return sh(n,i,t,r)}});var Ta=y("$ZodPipe",(e,t)=>{Z.init(e,t),D(e,"values",(n)=>n.def.in._zod.values),D(e,"optin",(n)=>n.def.in._zod.optin),D(e,"optout",(n)=>n.def.out._zod.optout),D(e,"propValues",(n)=>n.def.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){let o=t.out._zod.run(n,r);if(o instanceof Promise)return o.then((s)=>Di(s,t.in,r));return Di(o,t.in,r)}let i=t.in._zod.run(n,r);if(i instanceof Promise)return i.then((o)=>Di(o,t.out,r));return Di(i,t.out,r)}});function Di(e,t,n){if(e.issues.some((r)=>r.code!=="unrecognized_keys"))return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues},n)}var of=y("$ZodPreprocess",(e,t)=>{Ta.init(e,t)}),sf=y("$ZodReadonly",(e,t)=>{Z.init(e,t),D(e,"propValues",(n)=>n.def.innerType._zod.propValues),D(e,"values",(n)=>n.def.innerType._zod.values),D(e,"optin",(n)=>n.def.innerType?._zod?.optin),D(e,"optout",(n)=>n.def.innerType?._zod?.optout),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);let i=t.innerType._zod.run(n,r);if(i instanceof Promise)return i.then(ah);return ah(i)}});function ah(e){if(!e.memo)e.value=Object.freeze(e.value);return e}var af=y("$ZodCustom",(e,t)=>{te.init(e,t),Z.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=(n)=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then((o)=>ch(o,n,r,e));ch(i,n,r,e);return}});function ch(e,t,n,r){if(!e){let i={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};if(r._zod.def.params)i.params=r._zod.def.params;t.issues.push(zt(i))}}class lf extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var Oa="~memo",cf=[];function uf(e){return e!==null&&typeof e==="object"}function Ea(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var pf=new WeakMap,rr=0,qi=1,ir=2;function Bi(e,t,n){let r=pf.get(e);if(r!==void 0)return r?ir:rr;if(t.has(e))return ir;t.add(e);let i=rr,o=(u)=>{if(i!==ir&&u?._zod){let p=Bi(u,t,n);if(p>i)i=p}},s=(u,p)=>{let d=rr;for(let h of Reflect.ownKeys(u)){let f=Object.getOwnPropertyDescriptor(u,h);if(p&&!f.enumerable)continue;let m=f.get?qi:f.value?._zod?Bi(f.value,t,n):rr;if(m>d)d=m}return d},a=(u)=>{if(u>i)i=u},c=e._zod.def,l=c.type;switch(l){case"object":{let u=Qn(c);a(u?s(u,!0):qi),o(c.catchall);break}case"array":o(c.element);break;case"tuple":for(let u of c.items)o(u);o(c.rest);break;case"record":case"map":o(c.keyType),o(c.valueType);break;case"set":o(c.valueType);break;case"union":for(let u of c.options)o(u);break;case"intersection":o(c.left),o(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":o(c.innerType);break;case"pipe":o(c.in),o(c.out);break;case"function":o(c.input),o(c.output);break;case"lazy":{let u=c._cachedInner??(n?e._zod.innerType:void 0);a(u?Bi(u,t,!1):qi);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let u in c){let p=Object.getOwnPropertyDescriptor(c,u);if(!p||p.get)continue;let d=p.value;if(!d||typeof d!=="object")continue;if(d._zod)o(d);else if(Array.isArray(d))for(let h of d)o(h)}}return t.delete(e),b$(e,i)}function b$(e,t){if(t!==qi)pf.set(e,t===ir);return t}function w$(e,t){let n=e.buckets.get(t);if(!n)n=new WeakMap,e.buckets.set(t,n);return n}var Zi,Gi=[],_$={alloc(e,t,n){let r=Zi;if(!r)return n;Zi=void 0;let i={value:n,issues:null};return r.set(t.value,i),Gi.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let n=e._zod.parse,r=(i,o)=>{if(o.direction!=="backward"&&k$(o,i.value))throw new lf;return n(i,o)};if(e._zod.parse=r,e._zod.run===n)e._zod.run=r})},attach(e){var t;let n,r=!1,i,o;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let s=e._zod.parse,a=(c,l)=>{if(n===void 0){let w=Bi(e,new Set,!1);if(w===rr){if(e._zod.parse=s,e._zod.run===a)e._zod.run=s;return s(c,l)}if(w===ir||r)n=!0;else r=!0}let u=c.value;if(!uf(u))return s(c,l);let p=l[Oa];if(!p)p={buckets:new WeakMap,backEdges:void 0},l[Oa]=p;let d;if(i===l)d=o;else d=w$(p,e),i=l,o=d;let h=d.get(u);if(h){if(c.value=h.value,h.issues){if(h.issues.length)c.issues.push(...Ea(h.issues))}else c.memo=!0,p.backEdges??(p.backEdges=new WeakSet),p.backEdges.add(h.value);return c}Zi=d;let f=Gi.length,m=s(c,l);Zi=void 0;let g=Gi.length>f?Gi.pop():void 0;if(m instanceof Promise)return m.then((w)=>{if(g)g.issues=w.issues.length?Ea(w.issues):cf;return w});if(g)g.issues=m.issues.length?Ea(m.issues):cf;return m};if(e._zod.parse=a,e._zod.run===s)e._zod.run=a})}};function df(){return _$}function k$(e,t){let n=e[Oa]?.backEdges;return n!==void 0&&uf(t)&&n.has(t)}var x$=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(o){return e[o]??null}let n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},r={nan:"NaN"};function i(o,s){if(o==="number"&&typeof s==="number"&&!Number.isFinite(s))return String(s);return r[o]??o}return(o)=>{switch(o.code){case"invalid_type":{let s=i(o.expected),a=qp(o.input),c=i(a,o.input);return`Invalid input: expected ${s}, received ${c}`}case"invalid_value":if(o.values.length===1)return`Invalid input: expected ${aa(o.values[0])}`;return`Invalid option: expected one of ${ia(o.values,"|")}`;case"too_big":{let s=o.exact?"exactly ":o.inclusive?"<=":"<",a=t(o.origin);if(a)return`Too big: expected ${o.origin??"value"} to have ${s}${o.maximum.toString()} ${a.unit??"elements"}`;return`Too big: expected ${o.origin??"value"} to be ${s}${o.maximum.toString()}`}case"too_small":{let s=o.exact?"exactly ":o.inclusive?">=":">",a=t(o.origin);if(a)return`Too small: expected ${o.origin} to have ${s}${o.minimum.toString()} ${a.unit}`;return`Too small: expected ${o.origin} to be ${s}${o.minimum.toString()}`}case"invalid_format":{let s=o;if(s.format==="starts_with")return`Invalid string: must start with "${s.prefix}"`;if(s.format==="ends_with")return`Invalid string: must end with "${s.suffix}"`;if(s.format==="includes")return`Invalid string: must include "${s.includes}"`;if(s.format==="regex")return`Invalid string: must match pattern ${s.pattern}`;return`Invalid ${n[s.format]??o.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${o.divisor}`;case"unrecognized_keys":return`Unrecognized key${o.keys.length>1?"s":""}: ${ia(o.keys,", ")}`;case"invalid_key":return`Invalid key in ${o.origin}`;case"invalid_union":if(o.options&&Array.isArray(o.options)&&o.options.length>0)return`Invalid discriminator value. Expected ${o.options.map((a)=>`'${a}'`).join(" | ")}`;if(o.inclusive===!1)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${o.origin}`;default:return"Invalid input"}}};function Ca(){return{localeError:x$()}}var hf;class ff{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==="object"&&"id"in n)this._idmap.set(n.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t==="object"&&"id"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function S$(){return new ff}(hf=globalThis).__zod_globalRegistry??(hf.__zod_globalRegistry=S$());var Dt=globalThis.__zod_globalRegistry;function mf(e){if(e.checks)e.checks=[...e.checks];return e}function gf(e,t){return new e(mf({type:"string",...T(t)}))}function vf(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...T(t)})}function yf(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...T(t)})}function bf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...T(t)})}function wf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...T(t)})}function _f(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...T(t)})}function kf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...T(t)})}function Ra(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...T(t)})}function xf(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...T(t)})}function Sf(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...T(t)})}function Af(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...T(t)})}function $f(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...T(t)})}function Pf(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...T(t)})}function Tf(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...T(t)})}function Ef(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...T(t)})}function Of(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...T(t)})}function Cf(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...T(t)})}function Rf(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...T(t)})}function If(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...T(t)})}function Nf(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...T(t)})}function zf(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...T(t)})}function Df(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...T(t)})}function Lf(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...T(t)})}function jf(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...T(t)})}function Mf(e,t){return new e({type:"string",format:"date",check:"string_format",...T(t)})}function Uf(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...T(t)})}function Zf(e,t){return new e({type:"string",format:"duration",check:"string_format",...T(t)})}function Gf(e,t){return new e(mf({type:"number",checks:[],...T(t)}))}function qf(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...T(t)})}function Bf(e,t){return new e({type:"boolean",...T(t)})}function Hf(e){return new e({type:"unknown"})}function Ff(e,t){return new e({type:"never",...T(t)})}function Hi(e,t){return new ba({check:"less_than",...T(t),value:e,inclusive:!1})}function or(e,t){return new ba({check:"less_than",...T(t),value:e,inclusive:!0})}function Fi(e,t){return new wa({check:"greater_than",...T(t),value:e,inclusive:!1})}function sr(e,t){return new wa({check:"greater_than",...T(t),value:e,inclusive:!0})}function Ki(e,t){return new Dd({check:"multiple_of",...T(t),value:e})}function Wi(e,t){return new jd({check:"max_length",...T(t),maximum:e})}function on(e,t){return new Md({check:"min_length",...T(t),minimum:e})}function Vi(e,t){return new Ud({check:"length_equals",...T(t),length:e})}function Ia(e,t){return new Zd({check:"string_format",format:"regex",...T(t),pattern:e})}function Na(e){return new Gd({check:"string_format",format:"lowercase",...T(e)})}function za(e){return new qd({check:"string_format",format:"uppercase",...T(e)})}function Da(e,t){return new Bd({check:"string_format",format:"includes",...T(t),includes:e})}function La(e,t){return new Hd({check:"string_format",format:"starts_with",...T(t),prefix:e})}function ja(e,t){return new Fd({check:"string_format",format:"ends_with",...T(t),suffix:e})}function wt(e){return new Kd({check:"overwrite",tx:e})}function Ma(e){return wt((t)=>t.normalize(e))}function Ua(){return wt((e)=>e.trim())}function Za(){return wt((e)=>e.toLowerCase())}function Ga(){return wt((e)=>e.toUpperCase())}function qa(){return wt((e)=>Dp(e))}function Kf(e,t,n){return new e({type:"array",element:t,...T(n)})}function Wf(e,t,n){return new e({type:"custom",check:"custom",fn:t,...T(n)})}function Vf(e,t){let n=A$((r)=>(r.addIssue=(i)=>{if(typeof i==="string")r.issues.push(zt(i,r.value,n._zod.def));else{let o=i;if(o.fatal)o.continue=!1;if(o.code??(o.code="custom"),!("input"in o))o.input=r.value;o.inst??(o.inst=n),o.continue??(o.continue=!n._zod.def.abort),r.issues.push(zt(o))}},e(r.value,r)),t);return n}function A$(e,t){let n=new te({check:"custom",...T(t)});return n._zod.check=e,n}function ar(e,...t){for(let n of t)for(let r of Reflect.ownKeys(n))if(Object.prototype.propertyIsEnumerable.call(n,r))ge(e,r,n[r]);return e}function lr(e){let t=e?.target??"draft-2020-12";if(t==="draft-4")t="draft-04";if(t==="draft-7")t="draft-07";return{processors:e.processors??{},metadataRegistry:e?.metadata??Dt,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function Q(e,t,n,r,i){let o=typeof t.unrepresentable==="function"?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(o==="any")return!1;if(o===void 0||o==="throw")throw Error(i);return Object.assign(n,o),!0}function U(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,o=t.seen.get(e);if(o){if(o.count++,n.schemaPath.includes(e))o.cycle=n.path;return o.schema}let s={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,s),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{let u={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,u);else{let d=s.schema,h=t.processors[i.type];if(!h)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);h(e,t,d,u)}let p=e._zod.parent;if(p){if(!s.ref)s.ref=p;U(p,t,u),t.seen.get(p).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)ar(s.schema,c);if(t.io==="input"&&le(e))delete s.schema.examples,delete s.schema.default;if(t.io==="input"&&"_prefault"in s.schema)(r=s.schema).default??(r.default=s.schema._prefault);return delete s.schema._prefault,t.seen.get(e).schema}function Yf(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function ur(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let s of e.seen.entries()){let a=e.metadataRegistry.get(s[0])?.id;if(a){let c=r.get(a);if(c&&c!==s[0])throw Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(a,s[0])}}let i=(s)=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let p=e.external.registry.get(s[0])?.id,d=e.external.uri??((f)=>f);if(p)return{ref:d(p)};let h=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=h,{defId:h,ref:`${d("__shared")}#/${a}/${Yf(h)}`}}let c="#",l=`${c}/${a}/`;if(s[1]===n&&!s[1].schema.id)return{ref:c};let u=s[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+Yf(u)}},o=(s)=>{if(s[1].schema.$ref)return;let a=s[1],{ref:c,defId:l}=i(s);if(a.def={...a.schema},l)a.defId=l;let u=a.schema;for(let p in u)delete u[p];u.$ref=c};if(e.cycles==="throw")for(let s of e.seen.entries()){let a=s[1];if(a.cycle)throw Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
|
|
194
|
+
|
|
195
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let s of e.seen.entries()){let a=s[1];if(t===s[0]){o(s);continue}if(e.external){let l=e.external.registry.get(s[0])?.id;if(t!==s[0]&&l){o(s);continue}}if(e.metadataRegistry.get(s[0])?.id){o(s);continue}if(a.cycle){o(s);continue}if(a.count>1){if(e.reused==="ref")o(s)}}if(e.external)e.sharedDefsExtractedFor=e.external}function Xf(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let r of t){if(!r||typeof r!=="object")return;Xf(r);let i=Object.keys(r);if(i.length!==1||i[0]!=="type")return;let o=r.type;for(let s of Array.isArray(o)?o:[o]){if(typeof s!=="string")return;if(!n.includes(s))n.push(s)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var em=new Set(["type","properties","required","additionalProperties"]),Jf=["oneOf","anyOf"];function Qf(e){let t=e.additionalProperties;if(t===void 0||t===!1||typeof t!=="object"||t===null)return null;return Object.keys(t).length?t:null}function Ba(e){let t=[];for(let o of e){if(typeof o!=="object"||o.type!=="object")return null;for(let s in o)if(!em.has(s))return null;t.push(o)}let n={},r=new Set;for(let o of t){for(let s in o.properties){if(Object.prototype.hasOwnProperty.call(n,s))continue;let a=[];for(let l of t){let u=l.properties?.[s]??Qf(l);if(u===null||u===void 0)continue;if(!a.some((p)=>JSON.stringify(p)===JSON.stringify(u)))a.push(u)}let c=a.length===1?a[0]:Ba(a)??{allOf:a};ge(n,s,c)}for(let s of o.required??[])r.add(s)}let i={type:"object",properties:n};if(r.size)i.required=[...r];if(t.every((o)=>o.additionalProperties===!1))i.additionalProperties=!1;else{let o=[];for(let s of t){let a=Qf(s);if(a&&!o.some((c)=>JSON.stringify(c)===JSON.stringify(a)))o.push(a)}if(o.length===1)i.additionalProperties=o[0];else if(o.length>1)i.additionalProperties={allOf:o}}return i}function $$(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let i of em)if(i in e)return;let n=t.filter((i)=>Jf.some((o)=>Array.isArray(i[o]))),r=null;if(!n.length)r=Ba(t);else{let i=n[0],o=Jf.find((c)=>Array.isArray(i[c]));if(Object.keys(i).length!==1)return;let s=t.filter((c)=>c!==i),a=i[o].map((c)=>Ba([...s,c]));if(a.some((c)=>!c))return;r={[o]:a}}if(!r)return;delete e.allOf,ar(e,r)}function pr(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");let r=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let l=c.def??c.schema,u={...l},p=c.ref;if(c.ref=null,p){r(p);let h=e.seen.get(p),f=h.schema;if(f.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))l.allOf=l.allOf??[],l.allOf.push(f);else ar(l,f);if(ar(l,u),a._zod.parent===p)for(let g in l){if(g==="$ref"||g==="allOf")continue;if(!(g in u))delete l[g]}if(f.$ref&&h.def)for(let g in l){if(g==="$ref"||g==="allOf")continue;if(g in h.def&&JSON.stringify(l[g])===JSON.stringify(h.def[g]))delete l[g]}}let d=a._zod.parent;if(d&&d!==p){r(d);let h=e.seen.get(d);if(h?.schema.$ref){if(l.$ref=h.schema.$ref,h.def)for(let f in l){if(f==="$ref"||f==="allOf")continue;if(f in h.def&&JSON.stringify(l[f])===JSON.stringify(h.def[f]))delete l[f]}}}e.override({zodSchema:a,jsonSchema:l,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())r(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())Xf(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let l of[c.schema,c.def]){let u=l?.allOf;if(!Array.isArray(u))continue;let p=a.get(u);if(p)p.push(l);else a.set(u,[l])}for(let c of e.intersections)for(let l of a.get(c)??[])$$(l)}}let i={};if(e.target==="draft-2020-12")i.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")i.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")i.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(a)}ar(i,n.defId?n.schema:n.def??n.schema);let o=e.metadataRegistry.get(t)?.id;if(o!==void 0&&i.id===o)delete i.id;let s=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let a of e.seen.entries()){let c=a[1];if(c.def&&c.defId){if(c.def.id===c.defId)delete c.def.id;ge(s,c.defId,c.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(s).length>0)if(e.target==="draft-2020-12")i.$defs=s;else i.definitions=s;try{let a=JSON.parse(JSON.stringify(i));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:cr(t,"input",e.processors),output:cr(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function le(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return le(r.element,n);if(r.type==="set")return le(r.valueType,n);if(r.type==="lazy")return le(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault"||r.type==="catch")return le(r.innerType,n);if(r.type==="intersection")return le(r.left,n)||le(r.right,n);if(r.type==="record"||r.type==="map")return le(r.keyType,n)||le(r.valueType,n);if(r.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return le(r.in,n)||le(r.out,n)}if(r.type==="object"){for(let i in r.shape)if(le(r.shape[i],n))return!0;return!1}if(r.type==="union"){for(let i of r.options)if(le(i,n))return!0;return!1}if(r.type==="tuple"){for(let i of r.items)if(le(i,n))return!0;if(r.rest&&le(r.rest,n))return!0;return!1}return!1}var tm=(e,t={})=>(n)=>{let r=lr({...n,processors:t});return U(e,r),ur(r,e),pr(r,e)},cr=(e,t,n={})=>(r)=>{let{libraryOptions:i,target:o}=r??{},s=lr({...i??{},target:o,io:t,processors:n});return U(e,s),ur(s,e),pr(s,e)};var sn=(e,t,n)=>{if(e[t]===void 0||n>e[t])e[t]=n},an=(e,t,n)=>{if(e[t]===void 0||n<e[t])e[t]=n},nm=(e,t)=>{sn(e,"minimum",t),an(e,"maximum",t)},am=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},cm=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},lm=(e,t)=>{e.mime=e.mime?e.mime.filter((n)=>t.includes(n)):[...t]},um=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},rm=(e,t)=>sn(e,"minimum",t.minimum),im=(e,t)=>an(e,"maximum",t.maximum),om=(e)=>(t,n)=>{um(t,n.format);let[r,i]=e[n.format];sn(t,"minimum",r),an(t,"maximum",i)},P$={greater_than:(e,t)=>sn(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>an(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>am(e,t.value),number_format:om(Si),bigint_format:om(ca),min_length:rm,max_length:im,length_equals:(e,t)=>nm(e,t.length),min_size:rm,max_size:im,size_equals:(e,t)=>nm(e,t.size),string_format:(e,t)=>{if(um(e,t.format),t.pattern)cm(e,t.pattern);if(t.format==="base64"||t.format==="base64url")e.contentEncoding=t.format;if(t.local||t.precision===-1)e.laxFormat=!0},mime_type:(e,t)=>lm(e,t.mime)};function fe(e){let t={},n=e._zod.def,r=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(let o of r)P$[o._zod.def.check]?.(t,o._zod.def);let i=e._zod.bag;if(i.minimum!==void 0)sn(t,"minimum",i.minimum);if(i.exclusiveMinimum!==void 0)sn(t,"exclusiveMinimum",i.exclusiveMinimum);if(i.maximum!==void 0)an(t,"maximum",i.maximum);if(i.exclusiveMaximum!==void 0)an(t,"exclusiveMaximum",i.exclusiveMaximum);if(i.multipleOf!==void 0)am(t,i.multipleOf);if(i.format!==void 0){if(t.format??(t.format=i.format),i.format.includes("int"))t.isInt=!0}if(i.mime)lm(t,i.mime);for(let o of i.patterns??[])cm(t,o);return t}var T$={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},E$=new Map([[Sa,Sd],[Ui,Ad]]),pm=(e)=>E$.get(e)??e,Ka=(e,t,n,r)=>{let i=n;i.type="string";let{minimum:o,maximum:s,format:a,patterns:c,contentEncoding:l,laxFormat:u}=fe(e);if(typeof o==="number")i.minLength=o;if(typeof s==="number")i.maxLength=s;if(a){if(i.format=T$[a]??a,i.format==="")delete i.format;if(a==="time"||u)delete i.format}if(l)i.contentEncoding=l;if(c&&c.size>0){let p=[...c].map(pm);if(p.length===1)i.pattern=p[0].source;else if(p.length>1)i.allOf=[...p.map((d)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))]}},Wa=(e,t,n,r)=>{let i=n,{minimum:o,maximum:s,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=fe(e);i.type=u?"integer":"number";let p=typeof l==="number"&&l>=(o??Number.NEGATIVE_INFINITY),d=typeof c==="number"&&c<=(s??Number.POSITIVE_INFINITY),h=t.target==="draft-04"||t.target==="openapi-3.0";if(p)if(h)i.minimum=l,i.exclusiveMinimum=!0;else i.exclusiveMinimum=l;else if(typeof o==="number")i.minimum=o;if(d)if(h)i.maximum=c,i.exclusiveMaximum=!0;else i.exclusiveMaximum=c;else if(typeof s==="number")i.maximum=s;if(a){let f=new Set;for(let w of a)if(Number.isFinite(w)&&w!==0)f.add(Math.abs(w));else Q(e,t,i,r,`A multipleOf divisor of ${w} cannot be represented in JSON Schema`);let[m,...g]=f;if(m!==void 0)i.multipleOf=m;if(g.length)i.allOf=[...i.allOf??[],...g.map((w)=>({multipleOf:w}))]}},Va=(e,t,n,r)=>{n.type="boolean"},dm=(e,t,n,r)=>{Q(e,t,n,r,"BigInt cannot be represented in JSON Schema")},hm=(e,t,n,r)=>{Q(e,t,n,r,"Symbols cannot be represented in JSON Schema")},fm=(e,t,n,r)=>{if(t.target==="openapi-3.0")n.type="string",n.nullable=!0,n.enum=[null];else n.type="null"},mm=(e,t,n,r)=>{Q(e,t,n,r,"Undefined cannot be represented in JSON Schema")},gm=(e,t,n,r)=>{Q(e,t,n,r,"Void cannot be represented in JSON Schema")},Ya=(e,t,n,r)=>{n.not={}},vm=(e,t,n,r)=>{},Ja=(e,t,n,r)=>{},ym=(e,t,n,r)=>{Q(e,t,n,r,"Date cannot be represented in JSON Schema")},Qa=(e,t,n,r)=>{let i=e._zod.def,o=Vn(i.entries);if(o.length===0){n.not={};return}if(o.every((s)=>typeof s==="number"))n.type="number";if(o.every((s)=>typeof s==="string"))n.type="string";n.enum=o},Xa=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let o=[];for(let s of i.values)if(s===void 0){if(Q(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof s==="bigint"){if(Q(e,t,n,r,"BigInt literals cannot be represented in JSON Schema"))return;o.push(Number(s))}else o.push(s);if(o.length===0);else if(o.length===1){let s=o[0];if(n.type=s===null?"null":typeof s,t.target==="draft-04"||t.target==="openapi-3.0")n.enum=[s];else n.const=s}else{if(o.every((s)=>typeof s==="number"))n.type="number";if(o.every((s)=>typeof s==="string"))n.type="string";if(o.every((s)=>typeof s==="boolean"))n.type="boolean";if(o.every((s)=>s===null))n.type="null";n.enum=o}},bm=(e,t,n,r)=>{Q(e,t,n,r,"NaN cannot be represented in JSON Schema")},wm=(e,t,n,r)=>{let i=n,o=e._zod.pattern;if(!o)throw Error("Pattern not found in template literal");i.type="string",i.pattern=o.source},_m=(e,t,n,r)=>{let i=n;i.type="string",i.format="binary",i.contentEncoding="binary";let{minimum:o,maximum:s,mime:a}=fe(e);if(o!==void 0)i.minLength=o;if(s!==void 0)i.maxLength=s;if(!a)return;if(a.length===0)i.not={};else if(a.length===1)i.contentMediaType=a[0];else i.anyOf=a.map((c)=>({contentMediaType:c}))},km=(e,t,n,r)=>{n.type="boolean"},ec=(e,t,n,r)=>{Q(e,t,n,r,"Custom types cannot be represented in JSON Schema")},xm=(e,t,n,r)=>{Q(e,t,n,r,"Function types cannot be represented in JSON Schema")},tc=(e,t,n,r)=>{Q(e,t,n,r,"Transforms cannot be represented in JSON Schema")},Sm=(e,t,n,r)=>{Q(e,t,n,r,"Map cannot be represented in JSON Schema")},Am=(e,t,n,r)=>{Q(e,t,n,r,"Set cannot be represented in JSON Schema")},nc=(e,t,n,r)=>{let i=n,o=e._zod.def,{minimum:s,maximum:a}=fe(e);if(typeof s==="number")i.minItems=s;if(typeof a==="number")i.maxItems=a;i.type="array",i.items=U(o.element,t,{...r,path:[...r.path,"items"]})};function dr(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return dr(t.out);if(t.type==="catch")return dr(t.innerType);return e._zod.optin}var rc=(e,t,n,r)=>{let i=n,o=e._zod.def,s=o.shape;if(Object.getOwnPropertySymbols(s).length&&Q(e,t,i,r,"Symbol keys cannot be represented in JSON Schema"))return;i.type="object",i.properties={};for(let l in s)ge(i.properties,l,U(s[l],t,{...r,path:[...r.path,"properties",l]}));let c=[];for(let l of Object.keys(s)){let u=o.shape[l];if(t.io==="input"?dr(u)===void 0:u._zod.optout===void 0)c.push(l)}if(c.length>0)i.required=c;if(o.catchall?._zod.def.type==="never")i.additionalProperties=!1;else if(!o.catchall){if(t.io==="output")i.additionalProperties=!1}else if(o.catchall)i.additionalProperties=U(o.catchall,t,{...r,path:[...r.path,"additionalProperties"]})},ic=(e,t,n,r)=>{let i=e._zod.def,o=i.inclusive===!1,s=i.options.map((a,c)=>U(a,t,{...r,path:[...r.path,o?"oneOf":"anyOf",c]}));if(o)n.oneOf=s;else n.anyOf=s},oc=(e,t,n,r)=>{let i=e._zod.def,o=U(i.left,t,{...r,path:[...r.path,"allOf",0]}),s=U(i.right,t,{...r,path:[...r.path,"allOf",1]}),a=(l)=>("allOf"in l)&&Object.keys(l).length===1,c=[...a(o)?o.allOf:[o],...a(s)?s.allOf:[s]];n.allOf=c,t.intersections.push(c)},sc=(e,t,n,r)=>{let i=n,o=e._zod.def;i.type="array";let s=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"?"items":t.target==="openapi-3.0"?"items":"additionalItems",c=o.items.map((m,g)=>U(m,t,{...r,path:[...r.path,s,g]})),l=o.rest?U(o.rest,t,{...r,path:[...r.path,a,...t.target==="openapi-3.0"?[o.items.length]:[]]}):null,u=o.items.length;while(u>0){let m=o.items[u-1];if(!(t.io==="input"?dr(m)!==void 0:m._zod.optout==="optional"))break;u--}let p=o.items.length,d=!o.rest;if(t.target==="draft-2020-12"){if(i.prefixItems=c,d)i.items=!1;else if(l)i.items=l;if(u>0)i.minItems=u;if(d)i.maxItems=p}else if(t.target==="openapi-3.0"){if(i.items={anyOf:c},l)i.items.anyOf.push(l);if(u>0)i.minItems=u;if(d)i.maxItems=p}else{if(i.items=c,d)i.additionalItems=!1;else if(l)i.additionalItems=l;if(u>0)i.minItems=u;if(d)i.maxItems=p}let{minimum:h,maximum:f}=fe(e);if(typeof h==="number")i.minItems=h;if(typeof f==="number")i.maxItems=f};function Ha(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let f=e.get(t)?.def;if(!f)return t;let m=Ha(e,f,n);return m===f?t:m}for(let f of["anyOf","oneOf"]){let m=t[f];if(!Array.isArray(m))continue;let g=m.map((w)=>Ha(e,w,n));if(g.some((w,x)=>w!==m[x]))t={...t,[f]:g}}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes("string")&&r.some((f)=>f==="number"||f==="integer"),o=t.enum??(t.const!==void 0?[t.const]:void 0);if(!i&&!o?.some((f)=>typeof f==="number"))return t;let{minimum:s,maximum:a,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:p,id:d,...h}=t;if(h.enum)h.enum=h.enum.map((f)=>typeof f==="number"?String(f):f);else if(typeof h.const==="number")h.const=String(h.const);if(!i)return h;if(h.type="string",!o)h.pattern=(r.includes("number")?er:va).source;return h}var Fa=new WeakMap;function O$(e){let t=new Map;for(let r of e.seen.values())if(r.def&&!t.has(r.schema))t.set(r.schema,r);let n=new Map;for(let r of Fa.get(e)??[]){let i=e.seen.get(r),o=(i?.def??i?.schema)?.propertyNames;if(!o||o===!0||n.has(o))continue;let s=Ha(t,o,new Set);if(s!==o)n.set(o,s)}if(!n.size)return;for(let r of e.seen.values())for(let i of[r.schema,r.def]){let o=i&&n.get(i.propertyNames);if(o)i.propertyNames=o}}var ac=(e,t,n,r)=>{let i=n,o=e._zod.def;i.type="object";let s=o.keyType,a=fe(s).patterns;if(o.mode==="loose"&&a&&a.size>0){let u=U(o.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(let p of a)ge(i.patternProperties,pm(p).source,u)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){i.propertyNames=U(o.keyType,t,{...r,path:[...r.path,"propertyNames"]});let u=Fa.get(t);if(!u)u=[],Fa.set(t,u),t.deferred.push(()=>O$(t));u.push(e)}i.additionalProperties=U(o.valueType,t,{...r,path:[...r.path,"additionalProperties"]})}let c=s._zod.values,l=t.io==="input"&&dr(o.valueType)!==void 0;if(c&&!o.partial&&!l){let u=[...c].filter((p)=>typeof p==="string"||typeof p==="number");if(u.length>0)i.required=u.map(String)}},cc=(e,t,n,r)=>{let i=e._zod.def,o=U(i.innerType,t,r),s=t.seen.get(e);if(t.target==="openapi-3.0")s.ref=i.innerType,n.nullable=!0;else n.anyOf=[o,{type:"null"}]},lc=(e,t,n,r)=>{let i=e._zod.def;U(i.innerType,t,r);let o=t.seen.get(e);o.ref=i.innerType},uc=Symbol();function $m(e,t,n,r,i){let o=!1,s=JSON.stringify(e,(a,c)=>{if(typeof c!=="bigint")return c;return o=!0,null});if(!o)return JSON.parse(s);return Q(t,n,r,i,"BigInt defaults cannot be represented in JSON Schema"),uc}var pc=(e,t,n,r)=>{let i=e._zod.def;U(i.innerType,t,r);let o=t.seen.get(e);o.ref=i.innerType;let s=$m(i.defaultValue,e,t,n,r);if(s!==uc)n.default=s},dc=(e,t,n,r)=>{let i=e._zod.def;U(i.innerType,t,r);let o=t.seen.get(e);if(o.ref=i.innerType,t.io!=="input")return;let s=$m(i.defaultValue,e,t,n,r);if(s!==uc)n._prefault=s},hc=(e,t,n,r)=>{let i=e._zod.def;U(i.innerType,t,r);let o=t.seen.get(e);o.ref=i.innerType;let s;try{s=i.catchValue(void 0)}catch{Q(e,t,n,r,"Dynamic catch values are not supported in JSON Schema");return}n.default=s},fc=(e,t,n,r)=>{let i=e._zod.def,o=i.in._zod.traits.has("$ZodTransform"),s=t.io==="input"?o?i.out:i.in:i.out;U(s,t,r);let a=t.seen.get(e);a.ref=s},mc=(e,t,n,r)=>{let i=e._zod.def;U(i.innerType,t,r);let o=t.seen.get(e);o.ref=i.innerType,n.readOnly=!0},Pm=(e,t,n,r)=>{let i=e._zod.def;U(i.innerType,t,r);let o=t.seen.get(e);o.ref=i.innerType},Yi=(e,t,n,r)=>{let i=e._zod.def;U(i.innerType,t,r);let o=t.seen.get(e);o.ref=i.innerType},Tm=(e,t,n,r)=>{let i=e._zod.innerType;U(i,t,r);let o=t.seen.get(e);o.ref=i},sm={string:Ka,number:Wa,boolean:Va,bigint:dm,symbol:hm,null:fm,undefined:mm,void:gm,never:Ya,any:vm,unknown:Ja,date:ym,enum:Qa,literal:Xa,nan:bm,template_literal:wm,file:_m,success:km,custom:ec,function:xm,transform:tc,map:Sm,set:Am,array:nc,object:rc,union:ic,intersection:oc,tuple:sc,record:ac,nullable:cc,nonoptional:lc,default:pc,prefault:dc,catch:hc,pipe:fc,readonly:mc,promise:Pm,optional:Yi,lazy:Tm};function Em(e,t){if("_idmap"in e){let r=e,i=lr({...t,processors:sm}),o={};for(let c of r._idmap.entries()){let[l,u]=c;U(u,i)}let s={},a={registry:r,uri:t?.uri,defs:o};i.external=a;for(let c of r._idmap.entries()){let[l,u]=c;ur(i,u),ge(s,l,pr(i,u))}if(Object.keys(o).length>0){let c=i.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[c]:o}}return{schemas:s}}let n=lr({...t,processors:sm});return U(e,n),ur(n,e),pr(n,e)}var Om=new WeakSet([Object.prototype,Error.prototype]);function Qi(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let r=n(this);return Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0})}})}var M$=(e,t)=>{Jp.init(e,t),e.name="ZodError";let n=Object.getPrototypeOf(e);if(Om.has(n))return;Om.add(n),Qi(n,"format",(r)=>(i)=>Xp(r,i)),Qi(n,"flatten",(r)=>(i)=>Qp(r,i)),Qi(n,"addIssue",(r)=>(i)=>{r.issues.push(i),r.message=JSON.stringify(r.issues,Yn,2)}),Qi(n,"addIssues",(r)=>(i)=>{r.issues.push(...i),r.message=JSON.stringify(r.issues,Yn,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var be=y("ZodError",M$,void 0,{Parent:Error});var Cm=Ci(be),Rm=Ri(be),Im=Ii(be),Nm=Ni(be),zm=td(be),Dm=nd(be),Lm=rd(be),jm=id(be),Mm=od(be),Um=sd(be),Zm=ad(be),Gm=cd(be);function Z$(){if(!ce.localeError)ye(Ca())}function hr(){if(!ce.memoizer)ye({memoizer:df()})}var q=y("ZodType",(e,t)=>(Z$(),Z.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(ve(t,{checks:[...t.checks??[],...e.map((n)=>typeof n==="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Me(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(jP(e,t))},superRefine(e,t){return this.check(MP(e,t))},overwrite(e){return this.check(wt(e))},optional(){return Bm(this)},exactOptional(){return AP(this)},nullable(){return Hm(this)},nullish(){return Bm(Hm(this))},nonoptional(e){return CP(this,e)},array(){return ue(this)},or(e){return Qm([this,e])},and(e){return wP(this,e)},transform(e){return Fm(this,Xm(e))},default(e){return TP(this,e)},prefault(e){return OP(this,e)},catch(e){return IP(this,e)},pipe(e){return Fm(this,e)},readonly(){return DP(this)},describe(e){let t=this.clone();return Dt.add(t,{description:e}),t},meta(...e){if(e.length===0)return Dt.get(this);let t=this.clone();return Dt.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get "~standard"(){return Ei(this,"~standard",{...xa(this),jsonSchema:{input:cr(this,"input"),output:cr(this,"output")}})},set "~standard"(e){et(this,"~standard",e)},parse:function e(t,n){return Cm(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Rm(this,t,n,{callee:e})},safeParse(e,t){return Im(this,e,t)},async safeParseAsync(e,t){return Nm(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){et(this,"spa",e)},validate(e,t){return ha(this,e,t)},validateAsync(e,t){return fa(this,e,t)},encode:function e(t,n){return zm(this,t,n,{callee:e})},decode:function e(t,n){return Dm(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Lm(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await jm(this,t,n,{callee:e})},safeEncode(e,t){return Mm(this,e,t)},safeDecode(e,t){return Um(this,e,t)},async safeEncodeAsync(e,t){return Zm(this,e,t)},async safeDecodeAsync(e,t){return Gm(this,e,t)},toJSONSchema(e){return tm(this,{})(e)},get description(){return Dt.get(this)?.description},get _def(){return this._zod.def}}),Km=y("_ZodString",(e,t)=>{Mi.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Ka(e,n,r,i)},Hp({format:(e)=>fe(e).format??null,minLength:(e)=>fe(e).minimum??null,maxLength:(e)=>fe(e).maximum??null},{regex(...e){return this.check(Ia(...e))},includes(...e){return this.check(Da(...e))},startsWith(...e){return this.check(La(...e))},endsWith(...e){return this.check(ja(...e))},min(...e){return this.check(on(...e))},max(...e){return this.check(Wi(...e))},length(...e){return this.check(Vi(...e))},nonempty(...e){return this.check(on(1,...e))},lowercase(e){return this.check(Na(e))},uppercase(e){return this.check(za(e))},trim(){return this.check(Ua())},normalize(...e){return this.check(Ma(...e))},toLowerCase(){return this.check(Za())},toUpperCase(){return this.check(Ga())},slugify(){return this.check(qa())}})),G$=y("ZodString",(e,t)=>{Mi.init(e,t),Km.init(e,t)},{email(e){return this.check(vf(K$,e))},url(e){return this.check(Ra(Wm,e))},jwt(e){return this.check(Lf(lP,e))},emoji(e){return this.check(xf(V$,e))},guid(e){return this.check(yf(W$,e))},uuid(e){return this.check(bf(Xi,e))},uuidv4(e){return this.check(wf(Xi,e))},uuidv6(e){return this.check(_f(Xi,e))},uuidv7(e){return this.check(kf(Xi,e))},nanoid(e){return this.check(Sf(Y$,e))},cuid(e){return this.check(Af(J$,e))},cuid2(e){return this.check($f(Q$,e))},ulid(e){return this.check(Pf(X$,e))},base64(e){return this.check(Nf(sP,e))},base64url(e){return this.check(zf(aP,e))},xid(e){return this.check(Tf(eP,e))},ksuid(e){return this.check(Ef(tP,e))},ipv4(e){return this.check(Of(nP,e))},ipv6(e){return this.check(Cf(rP,e))},cidrv4(e){return this.check(Rf(iP,e))},cidrv6(e){return this.check(If(oP,e))},e164(e){return this.check(Df(cP,e))},datetime(e){return this.check(jf(q$,e))},date(e){return this.check(Mf(B$,e))},time(e){return this.check(Uf(H$,e))},duration(e){return this.check(Zf(F$,e))}});function E(e){return gf(G$,e)}var H=y("ZodStringFormat",(e,t)=>{G.init(e,t),Km.init(e,t)}),q$=y("ZodISODateTime",(e,t)=>{xh.init(e,t),H.init(e,t)}),B$=y("ZodISODate",(e,t)=>{Sh.init(e,t),H.init(e,t)}),H$=y("ZodISOTime",(e,t)=>{Ah.init(e,t),H.init(e,t)}),F$=y("ZodISODuration",(e,t)=>{$h.init(e,t),H.init(e,t)}),K$=y("ZodEmail",(e,t)=>{dh.init(e,t),H.init(e,t)});var W$=y("ZodGUID",(e,t)=>{uh.init(e,t),H.init(e,t)});var Xi=y("ZodUUID",(e,t)=>{ph.init(e,t),H.init(e,t)});var Wm=y("ZodURL",(e,t)=>{mh.init(e,t),H.init(e,t)});function Vm(e){return Ra(Wm,e)}var V$=y("ZodEmoji",(e,t)=>{gh.init(e,t),H.init(e,t)});var Y$=y("ZodNanoID",(e,t)=>{vh.init(e,t),H.init(e,t)});var J$=y("ZodCUID",(e,t)=>{yh.init(e,t),H.init(e,t)});var Q$=y("ZodCUID2",(e,t)=>{bh.init(e,t),H.init(e,t)});var X$=y("ZodULID",(e,t)=>{wh.init(e,t),H.init(e,t)});var eP=y("ZodXID",(e,t)=>{_h.init(e,t),H.init(e,t)});var tP=y("ZodKSUID",(e,t)=>{kh.init(e,t),H.init(e,t)});var nP=y("ZodIPv4",(e,t)=>{Ph.init(e,t),H.init(e,t)});var rP=y("ZodIPv6",(e,t)=>{Eh.init(e,t),H.init(e,t)});var iP=y("ZodCIDRv4",(e,t)=>{Oh.init(e,t),H.init(e,t)});var oP=y("ZodCIDRv6",(e,t)=>{Ch.init(e,t),H.init(e,t)});var sP=y("ZodBase64",(e,t)=>{Ih.init(e,t),H.init(e,t)});var aP=y("ZodBase64URL",(e,t)=>{Nh.init(e,t),H.init(e,t)});var cP=y("ZodE164",(e,t)=>{zh.init(e,t),H.init(e,t)});var lP=y("ZodJWT",(e,t)=>{Dh.init(e,t),H.init(e,t)});var Ym=y("ZodNumber",(e,t)=>{Aa.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Wa(e,n,r,i),e.isFinite=!0},Hp({minValue:(e)=>{let{minimum:t,exclusiveMinimum:n}=fe(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:n}=fe(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:n}=fe(e);return!!t||!!n?.some(Number.isSafeInteger)},format:(e)=>fe(e).format??null},{gt(e,t){return this.check(Fi(e,t))},gte(e,t){return this.check(sr(e,t))},min(e,t){return this.check(sr(e,t))},lt(e,t){return this.check(Hi(e,t))},lte(e,t){return this.check(or(e,t))},max(e,t){return this.check(or(e,t))},int(e){return this.check(qm(e))},safe(e){return this.check(qm(e))},positive(e){return this.check(Fi(0,e))},nonnegative(e){return this.check(sr(0,e))},negative(e){return this.check(Hi(0,e))},nonpositive(e){return this.check(or(0,e))},multipleOf(e,t){return this.check(Ki(e,t))},step(e,t){return this.check(Ki(e,t))},finite(){return this}}));function bc(e){return Gf(Ym,e)}var uP=y("ZodNumberFormat",(e,t)=>{Lh.init(e,t),Ym.init(e,t)});function qm(e){return qf(uP,e)}var pP=y("ZodBoolean",(e,t)=>{jh.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Va(e,n,r,i)});function tt(e){return Bf(pP,e)}var dP=y("ZodUnknown",(e,t)=>{Mh.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Ja(e,n,r,i)});function gc(){return Hf(dP)}var hP=y("ZodNever",(e,t)=>{Uh.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Ya(e,n,r,i)});function fP(e){return Ff(hP,e)}var mP=y("ZodArray",(e,t)=>{hr(),Zh.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>nc(e,n,r,i),e.element=t.element},{min(e,t){return this.check(on(e,t))},nonempty(e){return this.check(on(1,e))},max(e,t){return this.check(Wi(e,t))},length(e,t){return this.check(Vi(e,t))},unwrap(){return this.element}});function ue(e,t){return Kf(mP,e,t)}var gP=y("ZodObject",(e,t)=>{hr(),Bh.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>rc(e,n,r,i),FA(e,"shape",(n)=>n._zod.def.shape,!1)},{keyof(){return Lt(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(ve(this._zod.def,{catchall:e}))},passthrough(){return this.clone(ve(this._zod.def,{catchall:gc()}))},loose(){return this.clone(ve(this._zod.def,{catchall:gc()}))},strict(){return this.clone(ve(this._zod.def,{catchall:fP()}))},strip(){return this.clone(ve(this._zod.def,{catchall:void 0}))},extend(e){return jA(this,e)},safeExtend(e){return MA(this,e)},merge(e){return UA(this,e)},pick(e){return DA(this,e)},omit(e){return LA(this,e)},partial(...e){return Zp(kc,this,e[0])},exactPartial(...e){return Zp(eg,this,e[0],"exactPartial")},required(...e){return ZA(tg,this,e[0])}});function z(e,t){let n={type:"object",shape:e??{},...T(t)};return new gP(n)}var Jm=y("ZodUnion",(e,t)=>{$a.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ic(e,n,r,i),e.options=t.options});function Qm(e,t){return new Jm({type:"union",options:e,...T(t)})}var vP=y("ZodDiscriminatedUnion",(e,t)=>{Jm.init(e,t),Hh.init(e,t)});function yP(e,t,n){return new vP({type:"union",options:t,discriminator:e,...T(n)})}var bP=y("ZodIntersection",(e,t)=>{Fh.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>oc(e,n,r,i)});function wP(e,t){return new bP({type:"intersection",left:e,right:t})}var _P=y("ZodTuple",(e,t)=>{hr(),Kh.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>sc(e,n,r,i)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map((t)=>new kc({type:"optional",innerType:t}))})}});function wc(e,t,n){let r=t instanceof Z,i=r?n:t;return new _P({type:"tuple",items:e,rest:r?t:null,...T(i)})}var vc=y("ZodRecord",(e,t)=>{hr(),Wh.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ac(e,n,r,i),e.keyType=t.keyType,e.valueType=t.valueType});function eo(e,t,n){if(!t||!t._zod)return new vc({type:"record",keyType:E(),valueType:e,...T(t)});return new vc({type:"record",keyType:e,valueType:t,...T(n)})}function kP(e,t,n){return new vc({type:"record",keyType:e,valueType:t,...T(n),partial:!0})}var yc=y("ZodEnum",(e,t)=>{Vh.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,i,o)=>Qa(e,r,i,o),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(r,i)=>{let o={};for(let s of r)if(n.has(s))o[s]=t.entries[s];else throw Error(`Key ${s} not found in enum`);return new yc({...t,checks:[],...T(i),entries:o})},e.exclude=(r,i)=>{let o={...t.entries};for(let s of r)if(n.has(s))delete o[s];else throw Error(`Key ${s} not found in enum`);return new yc({...t,checks:[],...T(i),entries:o})}});function Lt(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map((r)=>[r,r])):e;return new yc({type:"enum",entries:n,...T(t)})}var xP=y("ZodLiteral",(e,t)=>{Yh.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Xa(e,n,r,i),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function _c(e,t){return new xP({type:"literal",values:Array.isArray(e)?e:[e],...T(t)})}var SP=y("ZodTransform",(e,t)=>{hr(),Jh.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>tc(e,n,r,i),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Xn(e.constructor.name);n.addIssue=(o)=>{if(typeof o==="string")n.issues.push(zt(o,n.value,t));else{let s=o;if(s.fatal)s.continue=!1;if(s.code??(s.code="custom"),!("input"in s))s.input=n.value;s.inst??(s.inst=e),n.issues.push(zt(s))}};let i=t.transform(n.value,n);if(i instanceof Promise)return i.then((o)=>(n.value=o,n));return n.value=i,n}});function Xm(e){return new SP({type:"transform",transform:e})}var kc=y("ZodOptional",(e,t)=>{Pa.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Yi(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Bm(e){return new kc({type:"optional",innerType:e})}var eg=y("ZodExactOptional",(e,t)=>{Qh.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Yi(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function AP(e){return new eg({type:"optional",innerType:e})}var $P=y("ZodNullable",(e,t)=>{Xh.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>cc(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Hm(e){return new $P({type:"nullable",innerType:e})}var PP=y("ZodDefault",(e,t)=>{ef.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>pc(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function TP(e,t){return new PP({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():sa(t)}})}var EP=y("ZodPrefault",(e,t)=>{tf.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>dc(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function OP(e,t){return new EP({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():sa(t)}})}var tg=y("ZodNonOptional",(e,t)=>{nf.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>lc(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function CP(e,t){return new tg({type:"nonoptional",innerType:e,...T(t)})}var RP=y("ZodCatch",(e,t)=>{rf.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>hc(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function IP(e,t){return new RP({type:"catch",innerType:e,catchValue:typeof t==="function"?t:Fp(t)})}var ng=y("ZodPipe",(e,t)=>{Ta.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>fc(e,n,r,i),e.in=t.in,e.out=t.out});function Fm(e,t){return new ng({type:"pipe",in:e,out:t})}var NP=y("ZodPreprocess",(e,t)=>{ng.init(e,t),of.init(e,t)}),zP=y("ZodReadonly",(e,t)=>{sf.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>mc(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function DP(e){return new zP({type:"readonly",innerType:e})}var LP=y("ZodCustom",(e,t)=>{af.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ec(e,n,r,i)});function jP(e,t={}){return Wf(LP,e,t)}function MP(e,t){return Vf(e,t)}function UP(e,t){return new NP({type:"pipe",in:Xm(e),out:t})}var ZP=["iOS","iPhone","macOS"];function ln(e,t){let n=[];if(e==="")return["it is empty"];if(/^\s/.test(e)||/\s$/.test(e))n.push("it has leading or trailing spaces");if(/command ?line/i.test(e))n.push('it should say "command-line"');if(/^(?:the|an?)(?=\s)/i.test(e))n.push("it starts with an article");if(/^[a-z]/.test(e)&&!ZP.includes(e.split(/\s+/)[0]))n.push("it starts with a lowercase letter");if(new RegExp(`^${t.replaceAll("-","").split("").join("[\\s\\-]?")}\\b`,"i").test(e))n.push("it starts with the package name");let r=/\b(macOS|Mac(?: ?OS(?: ?X)?)?|OS ?X)(?! virtual machines?)\b/i.exec(e);if(r&&r[1]!=="MAC")n.push("it names the platform");if(/\.$/.test(e)&&!e.endsWith("etc."))n.push("it ends with a full stop");if(/\p{So}/u.test(e))n.push("it contains a symbol or emoji");if([...e].length>80)n.push("it is longer than 80 characters");return n}var og=["darwin-universal","darwin-arm64","darwin-amd64","linux-arm64","linux-amd64","windows-amd64","windows-arm64"],xc=/^v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z]+(?:\.[0-9A-Za-z]+)*))?$/,un=/^[a-z0-9][a-z0-9-]*$/,GP=["com.apple.security.cs.allow-jit","com.apple.security.cs.allow-unsigned-executable-memory","com.apple.security.cs.disable-executable-page-protection","com.apple.security.cs.allow-dyld-environment-variables","com.apple.security.cs.disable-library-validation"],jt=E().regex(/^[A-Za-z0-9._-]+(\/[A-Za-z0-9._-]+)*$/).refine((e)=>!e.split("/").includes(".."),"must stay inside the archive"),rg=E().regex(/^[A-Za-z0-9.-]+$/),sg={uninstall:z({launchctl:ue(rg).optional(),quit:ue(rg).optional()}).strict().optional(),zap:z({trash:ue(E().regex(/^~\/[A-Za-z0-9 ._\/-]+$/))}).strict().optional(),caveats:E().min(1).max(2000).optional()},ag={name:E().regex(un),repo:E().regex(/^[A-Za-z0-9-]+\/[A-Za-z0-9._-]+$/),workflow:E().regex(/^[A-Za-z0-9._-]+\.ya?ml$/).default("release.yml"),assets:kP(Lt(og),E().regex(/^[A-Za-z0-9._{}-]+$/)),description:E().min(1).max(200).optional(),homepage:Vm().optional(),license:E().regex(/^[A-Za-z0-9.+-]+$/).optional(),attestation:Lt(["auto","off"]).default("auto"),protection:Lt(["on","off","dependabot"]).default("on")},qP=z({...ag,kind:Lt(["go","bun"]),binaries:ue(jt).min(1),completions:z({bash:jt.optional(),zsh:jt.optional(),fish:jt.optional()}).strict().optional(),scoop:tt().default(!1),entitlements:ue(Lt(GP)).default([]),cask:z(sg).strict().default({}),linux:tt().default(!1)}).strict(),to=/^[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)+$/,nt=bc().int().min(0).max(5000),BP=Qm([tt(),E().regex(/^[A-Za-z0-9._*{}-]+$/),ue(E().regex(/^[A-Za-z0-9._*{}-]+$/))]),HP=z({...ag,kind:_c("app"),app:E().regex(/^[A-Za-z0-9 ._-]+\.app$/),bundle_id:E().regex(to),carry:eo(E().regex(/^[A-Za-z0-9._-]+$/),E().regex(/^sha256:[0-9a-f]{64}$/)).default({}),dmg:z({name:E().regex(/^[A-Za-z0-9._{}-]+\.dmg$/),volume:E().regex(/^[A-Za-z0-9 ._-]{1,27}$/).optional(),volume_icon:jt.optional(),layout:z({window:wc([nt,nt,nt,nt]),icon_size:nt,app:wc([nt,nt]),applications:wc([nt,nt])}).strict().optional()}).strict(),sparkle:z({key:E().regex(/^[a-z0-9]+$/),feed:E().regex(/^[A-Za-z0-9._-]+\.xml$/).default("appcast.xml"),public_key:E().regex(/^[A-Za-z0-9+/]{43}=$/),next_key:E().regex(/^[a-z0-9]+$/).optional(),next_public_key:E().regex(/^[A-Za-z0-9+/]{43}=$/).optional()}).strict().optional(),code:eo(jt,z({identifier:E().regex(to).optional(),entitlements:eo(E().regex(/^[A-Za-z0-9.-]+$/),BP).optional()}).strict()).default({}),cask:z({...sg,binaries:ue(jt).optional(),auto_updates:tt().optional()}).strict().default({})}).strict(),cg=UP((e)=>e&&typeof e==="object"&&!Array.isArray(e)&&!("kind"in e)?{...e,kind:"go"}:e,yP("kind",[qP,HP])),FP=z({version:_c(1),tap:E().regex(/^[A-Za-z0-9-]+\/[a-z0-9-]+$/),linux:z({maintainer:E().regex(/^[A-Za-z0-9 .'-]+ <[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}>$/),url:Vm({protocol:/^https$/}).regex(/^https:\/\/[A-Za-z0-9.-]+(\/[A-Za-z0-9._-]+)*$/).optional()}).strict().optional(),packages:ue(cg)}).strict(),Y=(e)=>e.kind==="app",no=(e)=>Y(e)||Object.keys(e.assets).some((t)=>t.startsWith("darwin")),ig=(e)=>e.map((t)=>`${t.path.join(".")||"(root)"}: ${t.message}`).join("; ");function KP(e,t,n){if(Y(e))VP(e);if(e.repo.split("/")[0].toLowerCase()!==n.toLowerCase())throw new v(`${e.name}: ${e.repo} is not owned by ${n}`,"tapster publishes only repositories of the hub's owner.");let r=e.description===void 0?[]:ln(e.description,e.name);if(r.length)throw new v(`${e.name}: Homebrew rejects the description because ${r.join(" and ")}`,"Rewrite description in tapster.yml.");let i=Object.entries(e.assets);if(i.length===0)throw new v(`${e.name}: assets is empty`,"Map at least one platform to an asset name.");for(let[o,s]of i){if(s.replaceAll("{version}","").includes("{")||s.replaceAll("{version}","").includes("}"))throw new v(`${e.name}: ${s} uses a placeholder other than {version}`,"Only {version} is replaced in asset names.");if(o.startsWith("darwin")&&!s.endsWith(".tar.gz"))throw new v(`${e.name}: the ${o} asset must be a .tar.gz`,"Pack macOS builds as tar.gz; tapster reads them itself.")}if(Y(e)&&/[{}]/.test(e.dmg.name.replaceAll("{version}","")))throw new v(`${e.name}: ${e.dmg.name} uses a placeholder other than {version}`,"Only {version} is replaced in dmg.name.");if(!Y(e)&&e.scoop&&!Object.keys(e.assets).some((o)=>o.startsWith("windows-")))throw new v(`${e.name}: scoop needs a Windows asset`,"Map windows-amd64 or windows-arm64. Otherwise remove scoop: true.");if(Y(e)||!e.linux)return;if(!Object.keys(e.assets).some((o)=>o.startsWith("linux-")))throw new v(`${e.name}: linux needs a Linux asset`,"Map linux-amd64 or linux-arm64. Otherwise remove linux: true.");if(!t.linux)throw new v(`${e.name} ships Linux packages, but tapster.yml names no linux.maintainer`,'Add linux: { maintainer: "Name <address>" } at the top of tapster.yml.')}function WP(e){let t=new Map,n=(s,a)=>t.has(s)||t.set(s,a);for(let[s,a]of e)if(e.filter(([l,u])=>l!==s&&u.name===a.name).length)n(s,new v(`package ${a.name} is listed twice`,"Keep one entry per package."));let r=e.flatMap(([s,a])=>(Y(a)?a.cask.binaries??[]:a.binaries).map((c)=>({i:s,p:a,id:c.split("/").pop()})));for(let s of r)for(let a of r){if(s.i===a.i||s.id!==a.id||s.p.name===a.p.name)continue;n(s.i,new v(`${s.p.name} and ${a.p.name} both ship a binary named ${s.id}`,"Signed tools are identified by name, so each name may belong to one package."))}let i=(s,a)=>{let c=s.toLowerCase(),l=a.toLowerCase();return c===l||c.startsWith(`${l}.`)||l.startsWith(`${c}.`)},o=e.filter((s)=>Y(s[1]));for(let[s,a]of o){for(let[c,l]of o)if(s!==c&&i(a.bundle_id,l.bundle_id))n(s,new v(`${a.name} and ${l.name} have overlapping bundle ids`,"Each app needs its own bundle id, not one inside another."));for(let c of r){let l=c.id.toLowerCase();if(l!==a.bundle_id.toLowerCase()&&!l.startsWith(`${a.bundle_id.toLowerCase()}.`))continue;let u=new v(`the binary ${c.id} would carry ${a.name}'s identity`,"Rename the binary.");n(s,u),n(c.i,u)}}return t}function ne(e,t){let n;try{n=ie(e)}catch(u){let p=u.linePos?.[0]?.line;throw new v(`tapster.yml is not valid YAML${p?` at line ${p}`:""}`,"Fix the YAML syntax there.")}let r=FP.extend({packages:ue(gc())}).safeParse(n);if(!r.success)throw new v(`tapster.yml is invalid: ${ig(r.error.issues)}`,"Fix the listed fields.");let{packages:i,...o}=r.data,s=new Map,a=(u)=>{let p=u&&typeof u==="object"&&"repo"in u?u.repo:void 0;return typeof p==="string"?p:null},c=(u,p)=>{let d=u&&typeof u==="object"&&"name"in u?u.name:void 0;return typeof d==="string"&&un.test(d)?d:`packages[${p}]`},l=[];for(let[u,p]of i.entries()){let d=cg.safeParse(p);if(!d.success){s.set(u,{name:c(p,u),repo:a(p),reason:`${c(p,u)} is invalid: ${ig(d.error.issues)}`,fix:"Fix the listed fields in tapster.yml."});continue}let h=d.data;try{KP(h,o,t),l.push([u,h])}catch(f){if(!(f instanceof v))throw f;s.set(u,{name:h.name,repo:h.repo,reason:f.reason,fix:f.fix})}}for(let[u,p]of WP(l)){let d=l.find(([h])=>h===u)[1];s.set(u,{name:d.name,repo:d.repo,reason:p.reason,fix:p.fix})}return{config:{...o,packages:l.filter(([u])=>!s.has(u)).map(([,u])=>u)},invalid:[...s.entries()].sort(([u],[p])=>u-p).map(([,u])=>u)}}function VP(e){if(Object.keys(e.assets).filter((n)=>n.startsWith("darwin")).length!==1||Object.keys(e.assets).length!==1)throw new v(`${e.name}: an app needs exactly one darwin asset and nothing else`,"Map one of darwin-arm64, darwin-amd64 or darwin-universal to the app archive.");if(e.dmg.volume??=e.app.replace(/\.app$/,"").slice(0,27),e.sparkle&&e.sparkle.next_key===void 0!==(e.sparkle.next_public_key===void 0))throw new v(`${e.name}: a rotation needs both sparkle.next_key and next_public_key`,"Set both or neither.");for(let[n,r]of Object.entries(e.code))if(r.identifier&&!r.identifier.startsWith(`${e.bundle_id}.`))throw new v(`${e.name}: the identifier for ${n} is outside ${e.bundle_id}`,`Use an identifier that starts with ${e.bundle_id}.`)}function ro(e){let t=xc.exec(e);if(!t)return null;return{major:Number(t[1]),minor:Number(t[2]),patch:Number(t[3]),pre:t[4]??null}}function Sc(e,t){for(let i of["major","minor","patch"])if(e[i]!==t[i])return e[i]-t[i];if(e.pre===t.pre)return 0;if(e.pre===null)return 1;if(t.pre===null)return-1;let n=e.pre.split("."),r=t.pre.split(".");for(let i=0;i<Math.max(n.length,r.length);i++){let o=n[i],s=r[i];if(o===void 0)return-1;if(s===void 0)return 1;let a=/^\d+$/.test(o),c=/^\d+$/.test(s);if(a&&c&&Number(o)!==Number(s))return Number(o)-Number(s);if(a!==c)return a?-1:1;if(o!==s)return o<s?-1:1}return 0}function lg(e,t){let[n,r]=t.split("/");return e.linux?.url??`https://${n.toLowerCase()}.github.io/${r}`}import{spawn as PT}from"child_process";import{existsSync as TT}from"fs";import*as pg from"os";function fr(e){if(e===null||e===void 0)return"";else if(typeof e==="string"||e instanceof String)return e;return JSON.stringify(e)}function dg(e,t,n){let r=new hg(e,t,n);process.stdout.write(r.toString()+pg.EOL)}var ug="::";class hg{constructor(e,t,n){if(!e)e="missing.command";this.command=e,this.properties=t,this.message=n}toString(){let e=ug+this.command;if(this.properties&&Object.keys(this.properties).length>0){e+=" ";let t=!0;for(let n in this.properties)if(this.properties.hasOwnProperty(n)){let r=this.properties[n];if(r){if(t)t=!1;else e+=",";e+=`${n}=${JP(r)}`}}}return e+=`${ug}${YP(this.message)}`,e}}function YP(e){return fr(e).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A")}function JP(e){return fr(e).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A").replace(/:/g,"%3A").replace(/,/g,"%2C")}var JN=Oe("net"),QN=Oe("tls"),XP=Oe("http"),XN=Oe("https"),eT=Oe("events"),ez=Oe("assert"),tT=Oe("util");function io(e){var t=this;t.options=e||{},t.proxyOptions=t.options.proxy||{},t.maxSockets=t.options.maxSockets||XP.Agent.defaultMaxSockets,t.requests=[],t.sockets=[],t.on("free",function(r,i,o,s){var a=fg(i,o,s);for(var c=0,l=t.requests.length;c<l;++c){var u=t.requests[c];if(u.host===a.host&&u.port===a.port){t.requests.splice(c,1),u.request.onSocket(r);return}}r.destroy(),t.removeSocket(r)})}tT.inherits(io,eT.EventEmitter);io.prototype.addRequest=function(t,n,r,i){var o=this,s=mg({request:t},o.options,fg(n,r,i));if(o.sockets.length>=this.maxSockets){o.requests.push(s);return}o.createSocket(s,function(a){a.on("free",c),a.on("close",l),a.on("agentRemove",l),t.onSocket(a);function c(){o.emit("free",a,s)}function l(u){o.removeSocket(a),a.removeListener("free",c),a.removeListener("close",l),a.removeListener("agentRemove",l)}})};io.prototype.createSocket=function(t,n){var r=this,i={};r.sockets.push(i);var o=mg({},r.proxyOptions,{method:"CONNECT",path:t.host+":"+t.port,agent:!1,headers:{host:t.host+":"+t.port}});if(t.localAddress)o.localAddress=t.localAddress;if(o.proxyAuth)o.headers=o.headers||{},o.headers["Proxy-Authorization"]="Basic "+new Buffer(o.proxyAuth).toString("base64");Mt("making CONNECT request");var s=r.request(o);s.useChunkedEncodingByDefault=!1,s.once("response",a),s.once("upgrade",c),s.once("connect",l),s.once("error",u),s.end();function a(p){p.upgrade=!0}function c(p,d,h){process.nextTick(function(){l(p,d,h)})}function l(p,d,h){if(s.removeAllListeners(),d.removeAllListeners(),p.statusCode!==200){Mt("tunneling socket could not be established, statusCode=%d",p.statusCode),d.destroy();var f=Error("tunneling socket could not be established, statusCode="+p.statusCode);f.code="ECONNRESET",t.request.emit("error",f),r.removeSocket(i);return}if(h.length>0){Mt("got illegal response body from proxy"),d.destroy();var f=Error("got illegal response body from proxy");f.code="ECONNRESET",t.request.emit("error",f),r.removeSocket(i);return}return Mt("tunneling connection has established"),r.sockets[r.sockets.indexOf(i)]=d,n(d)}function u(p){s.removeAllListeners(),Mt(`tunneling socket could not be established, cause=%s
|
|
196
|
+
`,p.message,p.stack);var d=Error("tunneling socket could not be established, cause="+p.message);d.code="ECONNRESET",t.request.emit("error",d),r.removeSocket(i)}};io.prototype.removeSocket=function(t){var n=this.sockets.indexOf(t);if(n===-1)return;this.sockets.splice(n,1);var r=this.requests.shift();if(r)this.createSocket(r,function(i){r.request.onSocket(i)})};function fg(e,t,n){if(typeof e==="string")return{host:e,port:t,localAddress:n};return e}function mg(e){for(var t=1,n=arguments.length;t<n;++t){var r=arguments[t];if(typeof r==="object"){var i=Object.keys(r);for(var o=0,s=i.length;o<s;++o){var a=i[o];if(r[a]!==void 0)e[a]=r[a]}}}return e}var Mt;if(process.env.NODE_DEBUG&&/\btunnel\b/.test(process.env.NODE_DEBUG))Mt=function(){var e=Array.prototype.slice.call(arguments);if(typeof e[0]==="string")e[0]="TUNNEL: "+e[0];else e.unshift("TUNNEL:");console.error.apply(console,e)};else Mt=function(){};var qe;(function(e){e[e.OK=200]="OK",e[e.MultipleChoices=300]="MultipleChoices",e[e.MovedPermanently=301]="MovedPermanently",e[e.ResourceMoved=302]="ResourceMoved",e[e.SeeOther=303]="SeeOther",e[e.NotModified=304]="NotModified",e[e.UseProxy=305]="UseProxy",e[e.SwitchProxy=306]="SwitchProxy",e[e.TemporaryRedirect=307]="TemporaryRedirect",e[e.PermanentRedirect=308]="PermanentRedirect",e[e.BadRequest=400]="BadRequest",e[e.Unauthorized=401]="Unauthorized",e[e.PaymentRequired=402]="PaymentRequired",e[e.Forbidden=403]="Forbidden",e[e.NotFound=404]="NotFound",e[e.MethodNotAllowed=405]="MethodNotAllowed",e[e.NotAcceptable=406]="NotAcceptable",e[e.ProxyAuthenticationRequired=407]="ProxyAuthenticationRequired",e[e.RequestTimeout=408]="RequestTimeout",e[e.Conflict=409]="Conflict",e[e.Gone=410]="Gone",e[e.TooManyRequests=429]="TooManyRequests",e[e.InternalServerError=500]="InternalServerError",e[e.NotImplemented=501]="NotImplemented",e[e.BadGateway=502]="BadGateway",e[e.ServiceUnavailable=503]="ServiceUnavailable",e[e.GatewayTimeout=504]="GatewayTimeout"})(qe||(qe={}));var gg;(function(e){e.Accept="accept",e.ContentType="content-type"})(gg||(gg={}));var vg;(function(e){e.ApplicationJson="application/json"})(vg||(vg={}));var sz=[qe.MovedPermanently,qe.ResourceMoved,qe.SeeOther,qe.TemporaryRedirect,qe.PermanentRedirect],az=[qe.BadGateway,qe.ServiceUnavailable,qe.GatewayTimeout];import{EOL as rT}from"os";import{constants as yg,promises as iT}from"fs";var $c=function(e,t,n,r){function i(o){return o instanceof n?o:new n(function(s){s(o)})}return new(n||(n=Promise))(function(o,s){function a(u){try{l(r.next(u))}catch(p){s(p)}}function c(u){try{l(r.throw(u))}catch(p){s(p)}}function l(u){u.done?o(u.value):i(u.value).then(a,c)}l((r=r.apply(e,t||[])).next())})},{access:oT,appendFile:sT,writeFile:aT}=iT,bg="GITHUB_STEP_SUMMARY";class wg{constructor(){this._buffer=""}filePath(){return $c(this,void 0,void 0,function*(){if(this._filePath)return this._filePath;let e=process.env[bg];if(!e)throw Error(`Unable to find environment variable for $${bg}. Check if your runtime environment supports job summaries.`);try{yield oT(e,yg.R_OK|yg.W_OK)}catch(t){throw Error(`Unable to access summary file: '${e}'. Check if the file has correct read/write permissions.`)}return this._filePath=e,this._filePath})}wrap(e,t,n={}){let r=Object.entries(n).map(([i,o])=>` ${i}="${o}"`).join("");if(!t)return`<${e}${r}>`;return`<${e}${r}>${t}</${e}>`}write(e){return $c(this,void 0,void 0,function*(){let t=!!(e===null||e===void 0?void 0:e.overwrite),n=yield this.filePath();return yield(t?aT:sT)(n,this._buffer,{encoding:"utf8"}),this.emptyBuffer()})}clear(){return $c(this,void 0,void 0,function*(){return this.emptyBuffer().write({overwrite:!0})})}stringify(){return this._buffer}isEmptyBuffer(){return this._buffer.length===0}emptyBuffer(){return this._buffer="",this}addRaw(e,t=!1){return this._buffer+=e,t?this.addEOL():this}addEOL(){return this.addRaw(rT)}addCodeBlock(e,t){let n=Object.assign({},t&&{lang:t}),r=this.wrap("pre",this.wrap("code",e),n);return this.addRaw(r).addEOL()}addList(e,t=!1){let n=t?"ol":"ul",r=e.map((o)=>this.wrap("li",o)).join(""),i=this.wrap(n,r);return this.addRaw(i).addEOL()}addTable(e){let t=e.map((r)=>{let i=r.map((o)=>{if(typeof o==="string")return this.wrap("td",o);let{header:s,data:a,colspan:c,rowspan:l}=o,u=s?"th":"td",p=Object.assign(Object.assign({},c&&{colspan:c}),l&&{rowspan:l});return this.wrap(u,a,p)}).join("");return this.wrap("tr",i)}).join(""),n=this.wrap("table",t);return this.addRaw(n).addEOL()}addDetails(e,t){let n=this.wrap("details",this.wrap("summary",e)+t);return this.addRaw(n).addEOL()}addImage(e,t,n){let{width:r,height:i}=n||{},o=Object.assign(Object.assign({},r&&{width:r}),i&&{height:i}),s=this.wrap("img",null,Object.assign({src:e,alt:t},o));return this.addRaw(s).addEOL()}addHeading(e,t){let n=`h${t}`,r=["h1","h2","h3","h4","h5","h6"].includes(n)?n:"h1",i=this.wrap(r,e);return this.addRaw(i).addEOL()}addSeparator(){let e=this.wrap("hr",null);return this.addRaw(e).addEOL()}addBreak(){let e=this.wrap("br",null);return this.addRaw(e).addEOL()}addQuote(e,t){let n=Object.assign({},t&&{cite:t}),r=this.wrap("blockquote",e,n);return this.addRaw(r).addEOL()}addLink(e,t){let n=this.wrap("a",e,{href:t});return this.addRaw(n).addEOL()}}var bz=new wg;import kg from"os";import*as oo from"fs";var{chmod:cT,copyFile:lT,lstat:uT,mkdir:pT,open:kz,readdir:dT,rename:hT,rm:fT,rmdir:xz,stat:mT,symlink:gT,unlink:vT}=oo.promises,yT=process.platform==="win32";var Sz=oo.constants.O_RDONLY;var Ez=process.platform==="win32";var Nz=kg.platform(),zz=kg.arch();var xg;(function(e){e[e.Success=0]="Success",e[e.Failure=1]="Failure"})(xg||(xg={}));function Ac(e){dg("add-mask",{},e)}var Sg=4;var Pc=new Set;function $T(e){if(e.length<Sg)return[];let t=new Set,n=(i)=>{if(i.length>=Sg)t.add(i)};n(e);let r=Buffer.from(e,"utf8");n(r.toString("base64")),n(r.toString("hex")),n(r.toString("hex").toUpperCase()),n(encodeURIComponent(e));for(let i of e.split(/\r?\n/))n(i.trim());return[...t]}function pn(e){for(let t of $T(e)){if(Pc.has(t))continue;if(Pc.add(t),process.env.GITHUB_ACTIONS==="true")Ac(t)}}function dn(e){let t=e;for(let n of[...Pc].sort((r,i)=>i.length-r.length))t=t.split(n).join("***");return t}var hn={codesign:"/usr/bin/codesign",security:"/usr/bin/security",xcrun:"/usr/bin/xcrun",openssl:"/usr/bin/openssl",ditto:"/usr/bin/ditto",git:"/usr/bin/git",hdiutil:"/usr/bin/hdiutil",xattr:"/usr/bin/xattr",plutil:"/usr/bin/plutil",spctl:"/usr/sbin/spctl",gpg:"/usr/bin/gpg",gpgconf:"/usr/bin/gpgconf",rpm:"/usr/bin/rpm",rpmsign:"/usr/bin/rpmsign",rpm2archive:"/usr/bin/rpm2archive","dpkg-deb":"/usr/bin/dpkg-deb",createrepo_c:"/usr/bin/createrepo_c","apt-ftparchive":"/usr/bin/apt-ftparchive"},ET=["/opt/homebrew/bin/gh","/usr/local/bin/gh","/usr/bin/gh"];function OT(e={}){return{PATH:"/usr/bin:/bin",HOME:process.env.HOME??"/tmp",TMPDIR:process.env.RUNNER_TEMP??process.env.TMPDIR??"/tmp",...e}}function CT(e,t=5){return dn(e).split(/\r?\n/).filter((n)=>n.trim()!==""&&!/keychain/i.test(n)).slice(-t).join(" | ")}function Ag(e=ET){let t=e.find((n)=>TT(n));if(!t)throw new v("gh is not installed on this runner","Use a GitHub-hosted runner image, which ships gh.");return t}function $e(e,t,n={}){return j(hn[e],e,t,n)}function j(e,t,n,r={}){return new Promise((i,o)=>{let s=PT(e,n,{env:OT(r.env),cwd:r.cwd,shell:!1,stdio:["pipe","pipe","pipe"]}),a=[],c=[],l=0,u=null,p=(f)=>{u??=f,s.kill("SIGKILL")},d=r.timeoutMs?setTimeout(()=>p(new v(`${t} did not finish in time`,"Re-run the workflow; if it happens again, check the input it read.")),r.timeoutMs):null,h=(f)=>(m)=>{if(l+=m.length,r.maxOutput&&l>r.maxOutput)p(new v(`${t} wrote more output than tapster reads`,"Check the input it read."));else f.push(m)};s.stdout.on("data",h(a)),s.stderr.on("data",h(c)),s.on("error",()=>o(new v(`${t} could not start`,`Check that ${e} exists on this runner.`))),s.on("close",(f)=>{if(d)clearTimeout(d);if(u){o(u);return}let m=Buffer.concat(a),g={code:f??-1,stdout:m.toString("utf8"),stderr:Buffer.concat(c).toString("utf8"),bytes:m};if(g.code!==0&&!r.allowFail){o(new v(`${t} exited with ${g.code}`,CT(g.stderr)||"No error output."));return}i(g)}),s.stdin.end(r.stdin??"")})}var RT=1048576,$g=32,IT=1e5,C=(e)=>new v(`an Info.plist ${e}`,"Rebuild the app; tapster reads XML and binary property lists.");function Pg(e){if(e.length>RT)throw C("is larger than 1 MiB");if(e.subarray(0,8).toString("latin1")==="bplist00")return jT(e);if(e[0]===254||e[0]===255||e[0]===0)throw C("is not UTF-8");let t=e.toString("utf8").replace(/^\ufeff/,""),n=/^\s*<\?xml[^>]*\bencoding\s*=\s*["']([^"']*)["']/.exec(t)?.[1];if(n!==void 0&&!/^utf-?8$/i.test(n))throw C(`declares the encoding ${n}, not UTF-8`);return LT(t)}var NT={amp:"&",lt:"<",gt:">",quot:'"',apos:"'"};function zT(e){return e.replace(/&(#x[0-9a-fA-F]+|#[0-9]+|[a-z]+);/g,(t,n)=>{if(n.startsWith("#x"))return String.fromCodePoint(Number.parseInt(n.slice(2),16));if(n.startsWith("#"))return String.fromCodePoint(Number.parseInt(n.slice(1),10));let r=NT[n];if(r===void 0)throw C(`uses an unknown entity ${t}`);return r})}function DT(e){let t=[],n=0;while(n<e.length)if(e.startsWith("<!--",n)){let r=e.indexOf("-->",n+4);if(r===-1)throw C("has an unclosed comment");n=r+3}else if(e.startsWith("<![CDATA[",n)){let r=e.indexOf("]]>",n+9);if(r===-1)throw C("has an unclosed CDATA section");t.push({kind:"text",text:e.slice(n+9,r)}),n=r+3}else if(e.startsWith("<?",n)||e.startsWith("<!",n)){let r=e.indexOf(">",n);if(r===-1)throw C("is not valid XML");n=r+1}else if(e[n]==="<"){let r=e.indexOf(">",n);if(r===-1)throw C("is not valid XML");let i=e.slice(n+1,r).trim(),o=/^(\/)?([A-Za-z]+)(?:\s[^/]*)?(\/)?$/.exec(i);if(!o)throw C("has a tag tapster does not read");t.push({kind:o[1]?"close":o[3]?"empty":"open",name:o[2]}),n=r+1}else{let r=e.indexOf("<",n),i=e.slice(n,r===-1?e.length:r);t.push({kind:"text",text:zT(i)}),n=r===-1?e.length:r}return t}function LT(e){let t=DT(e).filter((u)=>!(u.kind==="text"&&u.text.trim()==="")),n=0,r=()=>t[n++],i=()=>t[n],o=(u)=>{let p="";for(;;){let d=r();if(!d)throw C(`has an unclosed <${u}>`);if(d.kind==="text")p+=d.text;else if(d.kind==="close"&&d.name===u)return p;else throw C(`has markup inside <${u}>`)}},s=(u)=>{if(u>$g)throw C("is nested too deeply");let p=r();if(!p||p.kind==="text"||p.kind==="close")throw C("is missing a value");if(p.kind==="empty"){if(p.name==="true")return!0;if(p.name==="false")return!1;if(p.name==="string")return"";if(p.name==="dict")return{};if(p.name==="array")return[];if(p.name==="data")return Buffer.alloc(0);throw C(`has an unknown <${p.name}/>`)}switch(p.name){case"string":return o("string");case"integer":{let d=o("integer").trim();if(!/^[+-]?\d{1,15}$/.test(d))throw C("has an integer tapster does not read");return Number(d)}case"real":{let d=Number(o("real").trim());if(!Number.isFinite(d))throw C("has an invalid real");return d}case"date":{let d=new Date(o("date").trim());if(Number.isNaN(d.getTime()))throw C("has an invalid date");return d}case"data":return Buffer.from(o("data").replace(/\s+/g,""),"base64");case"array":{let d=[];for(;;){let h=i();if(h?.kind==="close"&&h.name==="array")return n++,d;d.push(s(u+1))}}case"dict":{let d={};for(;;){let h=r();if(h?.kind==="close"&&h.name==="dict")return d;if(h?.kind!=="open"||h.name!=="key")throw C("has a dict entry without a key");let f=o("key");if(Object.hasOwn(d,f))throw C(`lists the key ${f} twice`);Object.defineProperty(d,f,{value:s(u+1),enumerable:!0,writable:!0,configurable:!0})}}default:throw C(`has an unknown <${p.name}>`)}},a=r();if(!a||a.kind!=="open"||a.name!=="plist")throw C("does not start with <plist>");let c=s(1),l=r();if(!l||l.kind!=="close"||l.name!=="plist"||n!==t.length)throw C("has content after its value");return c}function jT(e){if(e.length<40)throw C("is truncated");let t=e.subarray(e.length-32),n=t[6],r=t[7],i=Number(t.readBigUInt64BE(8)),o=Number(t.readBigUInt64BE(16)),s=Number(t.readBigUInt64BE(24));if(![1,2,4,8].includes(n)||![1,2,4,8].includes(r))throw C("has a damaged trailer");if(i<1||o>=i||s<8||s+i*n>e.length-32)throw C("has a damaged offset table");let a=(d,h)=>{if(d+h>e.length-32)throw C("is truncated");let f=h===8?e.readBigUInt64BE(d):BigInt(e.readUIntBE(d,h));if(f>BigInt(Number.MAX_SAFE_INTEGER))throw C("has a number tapster does not read");return Number(f)},c=(d)=>{if(d>=i)throw C("has a reference outside its objects");let h=a(s+d*n,n);if(h<8||h>=s)throw C("has an object outside its body");return h},l=new Set,u=0,p=(d,h)=>{if(h>$g)throw C("is nested too deeply");if(++u>IT)throw C("has too many objects");if(l.has(d))throw C("refers to itself");l.add(d);try{let f=c(d),m=e[f],g=m>>4,w=m&15,x=()=>{if(w!==15)return[w,f+1];let _=e[f+1];if(_>>4!==1)throw C("has a damaged length");let b=1<<(_&15);return[a(f+2,b),f+2+b]};switch(g){case 0:if(m===8)return!1;if(m===9)return!0;throw C("has an object tapster does not read");case 1:{let _=1<<w;if(_===8){if(f+9>e.length-32)throw C("is truncated");let b=e.readBigInt64BE(f+1);if(b>BigInt(Number.MAX_SAFE_INTEGER)||b<BigInt(Number.MIN_SAFE_INTEGER))throw C("has a number tapster does not read");return Number(b)}if(_>8)throw C("has a number tapster does not read");return a(f+1,_)}case 2:{if(w===2)return e.readFloatBE(f+1);if(w===3)return e.readDoubleBE(f+1);throw C("has a real tapster does not read")}case 3:if(m!==51)throw C("has a damaged date");return new Date((978307200+e.readDoubleBE(f+1))*1000);case 4:{let[_,b]=x();if(b+_>s)throw C("is truncated");return Buffer.from(e.subarray(b,b+_))}case 5:{let[_,b]=x();if(b+_>s)throw C("is truncated");return e.subarray(b,b+_).toString("latin1")}case 6:{let[_,b]=x();if(b+_*2>s)throw C("is truncated");let k=Buffer.from(e.subarray(b,b+_*2));return k.swap16(),k.toString("utf16le")}case 10:{let[_,b]=x();if(b+_*r>s)throw C("is truncated");return Array.from({length:_},(k,S)=>p(a(b+S*r,r),h+1))}case 13:{let[_,b]=x();if(b+2*_*r>s)throw C("is truncated");let k={};for(let S=0;S<_;S++){let O=p(a(b+S*r,r),h+1);if(typeof O!=="string")throw C("has a dict key that is not a string");if(Object.hasOwn(k,O))throw C(`lists the key ${O} twice`);Object.defineProperty(k,O,{value:p(a(b+(_+S)*r,r),h+1),enumerable:!0,writable:!0,configurable:!0})}return k}default:throw C("has an object tapster does not read")}}finally{l.delete(d)}};return p(o,1)}var so=[{actor_id:5,actor_type:"RepositoryRole",bypass_mode:"always"}],MT={actor_id:null,actor_type:"DeployKey",bypass_mode:"always"},Tc={name:"tapster tags",target:"tag",enforcement:"active",bypass_actors:so,conditions:{ref_name:{include:["~ALL"],exclude:[]}},rules:[{type:"creation"},{type:"update"},{type:"deletion"}]},Ec={name:"tapster branches",target:"branch",enforcement:"active",bypass_actors:so,conditions:{ref_name:{include:["~ALL"],exclude:[]}},rules:[{type:"creation"},{type:"update"},{type:"deletion"},{type:"non_fast_forward"}]},ao="refs/heads/dependabot/**";function UT(e,t=!1){let n=e?[...so,MT]:so,r={ref_name:{include:["~ALL"],exclude:t?[ao]:[]}};return[{...Tc,bypass_actors:n},{...Ec,bypass_actors:n,conditions:r}]}function Tg(e,t){if(t==="app")return e.current_user_can_bypass!=="never";return(e.bypass_actors??[]).some((n)=>!(n.actor_type==="DeployKey"||n.actor_type==="RepositoryRole"&&n.actor_id===5))}async function Eg(e,t,n,r,i,o){let s;try{s=await e.json("GET",`/repos/${t}/rulesets?targets=${n}`)}catch(h){if(h instanceof R&&(h.status===403||h.status===404))return{problems:["GitHub offers no rulesets on this repository; private repositories need a paid plan for them"],ok:!1};throw h}let a=await Promise.all(s.filter((h)=>h.target===n&&h.enforcement==="active").map((h)=>e.json("GET",`/repos/${t}/rulesets/${h.id}`)));if(a.length===0)return{problems:[`no active ${n} ruleset protects every ${n}`],ok:!1};let c=n==="branch"&&o?[ao]:[],l=a.filter((h)=>(h.conditions?.ref_name?.include??[]).includes("~ALL")&&(h.conditions?.ref_name?.exclude??[]).every((f)=>c.includes(f)));if(l.length===0)return{problems:[`no active ${n} ruleset covers every ${n} (~ALL) without exclusions`],ok:!1};let u=l.filter((h)=>Tg(h,i)).map((h)=>`the App or another actor can bypass ${h.name}`),p=new Set(l.filter((h)=>!Tg(h,i)).flatMap((h)=>(h.rules??[]).map((f)=>f.type))),d=r.filter((h)=>!p.has(h));if(d.length)u.push(`the ${n} rulesets do not restrict ${d.join(", ")}`);return{problems:u,ok:u.length===0}}async function Og(e,t,n,r,i=!1){let o=await Eg(e,t,"tag",Tc.rules.map((a)=>a.type),r,!1),s=await Eg(e,t,"branch",Ec.rules.map((a)=>a.type),r,i);if(s.ok){let a=new Set((await e.json("GET",`/repos/${t}/rules/branches/${encodeURIComponent(n)}`)).map((c)=>c.type));if(!["update","deletion","non_fast_forward"].every((c)=>a.has(c)))s.problems.push("GitHub does not enforce rulesets on this repository; private repositories need a paid plan for them")}return{tag:o.problems,branch:s.problems}}async function mr(e,t,n,r,i=!1){let o=await Og(e,t,n,r,i);return[...o.tag,...o.branch]}async function Cg(e,t,n,r=!1,i=!1){let o;try{o=await e.json("GET",`/repos/${t}/rulesets`)}catch(f){if(f instanceof R&&(f.status===403||f.status===404))return{status:"unavailable",deployKeys:r,dependabot:i};throw f}let s=await Promise.all(o.filter((f)=>f.name===Tc.name||f.name===Ec.name).map((f)=>e.json("GET",`/repos/${t}/rulesets/${f.id}`))),a=r||s.some((f)=>(f.bypass_actors??[]).some((m)=>m.actor_type==="DeployKey")),c=i||s.some((f)=>(f.conditions?.ref_name?.exclude??[]).includes(ao)),l=(f)=>({status:f,deployKeys:a,dependabot:c}),u=await Og(e,t,n,"admin",c);if(u.tag.concat(u.branch).some((f)=>f.includes("offers no rulesets")))return l("unavailable");let p=a!==s.some((f)=>(f.bypass_actors??[]).some((m)=>m.actor_type==="DeployKey"))||c!==s.some((f)=>(f.conditions?.ref_name?.exclude??[]).includes(ao));if(u.tag.length+u.branch.length===0&&!p)return l("exists");let[d,h]=UT(a,c);try{for(let[f,m]of[[d,u.tag],[h,u.branch]]){if(m.length===0&&!p)continue;let g=o.find((w)=>w.name===f.name);if(g)await e.json("PUT",`/repos/${t}/rulesets/${g.id}`,f);else await e.json("POST",`/repos/${t}/rulesets`,f)}}catch(f){if(f instanceof R&&(f.status===403||f.status===422))return l("unavailable");throw f}return l((await mr(e,t,n,"admin",c)).length===0?"created":"unavailable")}import{createPrivateKey as mE}from"crypto";import{spawn as gE}from"child_process";import{existsSync as Wg,readFileSync as vE}from"fs";import{writeFile as yr}from"fs/promises";import{delimiter as Mc,join as Ke}from"path";var ZT={401:"Your GitHub sign-in was rejected; run gh auth login again.",403:"Your account may not do this here; check that you own the repository, then run gh auth refresh to renew the sign-in.",404:"Not found or not visible to your gh sign-in; check the name and run gh auth status.",409:"GitHub reported a conflict; run the command again.",422:"GitHub rejected the request."},GT={401:"The credential was rejected; rotate it with tapster init --rotate.",403:"Access denied: check the App's permissions and that it is installed on this repository.",404:"Not found. The App may not be installed on this repository.",409:"GitHub reported a conflict; the next run retries.",422:"GitHub rejected the request."};function Oc(e){try{return new URL(e).pathname}catch{return"(url)"}}class pe{token;fetchImpl;sleep;who;constructor(e,t=fetch,n=(i)=>new Promise((o)=>setTimeout(o,i)),r="app"){this.token=e;this.fetchImpl=t;this.sleep=n;this.who=r}async request(e,t,n={}){let r=t.startsWith("https://")?t:`https://api.github.com${t}`,i={Accept:n.accept??"application/vnd.github+json","X-GitHub-Api-Version":"2022-11-28","User-Agent":"tapster"};if(n.auth!==!1)i.Authorization=`Bearer ${this.token}`;if(n.contentType)i["Content-Type"]=n.contentType;else if(n.body!==void 0)i["Content-Type"]="application/json";let o=n.raw??(n.body!==void 0?JSON.stringify(n.body):void 0);for(let s=0;;s++){let a;try{a=await this.fetchImpl(r,{method:e,headers:i,body:o,redirect:"manual"})}catch{if(s<4){await this.sleep(1000*2**s);continue}throw new R(`GitHub ${e} ${Oc(r)}: network error`,"GitHub did not answer; the next run retries.",0)}if((a.status>=500||a.status===429)&&s<4){await this.sleep(1000*2**s);continue}if(a.status>=400){await a.body?.cancel();let c=this.who==="user"?ZT:GT;throw new R(`GitHub ${e} ${Oc(r)} returned ${a.status}`,c[a.status]??(this.who==="user"?"Try again in a moment.":"The next run retries."),a.status)}return a}}async json(e,t,n){let r=await this.request(e,t,n===void 0?{}:{body:n});for(let i=0;r.status>=300&&r.status<400;i++){let o=r.headers.get("location"),s=null;try{s=o?new URL(o):null}catch{s=null}if(i>=3||!s||s.protocol!=="https:"||s.host!=="api.github.com")throw new R(`GitHub ${e} ${Oc(t)} moved somewhere tapster does not follow`,"Update the repository name in tapster.yml.",r.status);r=await this.request(e,s.toString(),n===void 0?{}:{body:n})}if(r.status===204)return;return await r.json()}async listReleases(e){let t=[];for(let n=1;n<=10;n++){let r=await this.json("GET",`/repos/${e}/releases?per_page=100&page=${n}`);if(t.push(...r),r.length<100)break}return t}getRelease=(e,t)=>this.json("GET",`/repos/${e}/releases/${t}`);getRepo=(e)=>this.json("GET",`/repos/${e}`);async downloadAsset(e,t){let n=await this.request("GET",`/repos/${e}/releases/assets/${t}`,{accept:"application/octet-stream"});if(n.status>=300&&n.status<400){let r=n.headers.get("location");if(!r)throw new R(`GitHub sent a redirect without a location for asset ${t}`,"The next run retries.",n.status);let i=await this.request("GET",r,{auth:!1,accept:"application/octet-stream"});return Buffer.from(await i.arrayBuffer())}return Buffer.from(await n.arrayBuffer())}async uploadAsset(e,t,n){let r=e.upload_url.replace(/\{.*\}$/,"");return await(await this.request("POST",`${r}?name=${encodeURIComponent(t)}`,{raw:n,contentType:"application/octet-stream"})).json()}deleteAsset=(e,t)=>this.request("DELETE",`/repos/${e}/releases/assets/${t}`).then(()=>{return});renameAsset=(e,t,n)=>this.json("PATCH",`/repos/${e}/releases/assets/${t}`,{name:n});updateRelease=(e,t,n,r)=>this.json("PATCH",`/repos/${e}/releases/${t}`,{...r,tag_name:n})}import{createSign as qT}from"crypto";var Rg=(e)=>Buffer.from(e).toString("base64url");function Be(e,t,n=Date.now()){let r=Math.floor(n/1000)-60,i=Rg(JSON.stringify({alg:"RS256",typ:"JWT"})),o=Rg(JSON.stringify({iat:r,exp:r+540,iss:e})),s=qT("RSA-SHA256").update(`${i}.${o}`).sign(t).toString("base64url"),a=`${i}.${o}.${s}`;return pn(a),a}async function Ig(e,t,n,r){let i=new pe(Be(e,t),r),o;try{o=await i.json("GET",`/users/${n}/installation`)}catch(c){if(c instanceof R&&c.status===404)return null;throw c}let{token:s}=await i.json("POST",`/app/installations/${o.id}/access_tokens`,{permissions:{metadata:"read"}});pn(s);let a=new pe(s,r);try{let c=[];for(let l=1;l<=10;l++){let u=await a.json("GET",`/installation/repositories?per_page=100&page=${l}`);if(c.push(...u.repositories.map((p)=>p.full_name)),u.repositories.length<100)return c}throw new v("the App is installed on more than 1000 repositories","Install it only on the projects tapster.yml lists.")}finally{await a.request("DELETE","/installation/token").catch(()=>{return})}}var Ng=`- name: Ring the tapster hub
|
|
197
|
+
if: \${{ vars.TAPSTER_DOORBELL != '' }}
|
|
198
|
+
continue-on-error: true
|
|
199
|
+
env: { DOORBELL: "\${{ vars.TAPSTER_DOORBELL }}" }
|
|
200
|
+
run: |
|
|
201
|
+
set -euo pipefail
|
|
202
|
+
token=$(curl -fsS -G --data-urlencode "audience=$DOORBELL" -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL" | jq -r .value)
|
|
203
|
+
echo "::add-mask::$token"
|
|
204
|
+
curl -fsS -X POST -H "Authorization: Bearer $token" "$DOORBELL"
|
|
205
|
+
`;var zg=`{
|
|
206
|
+
"lockfileVersion": 2,
|
|
207
|
+
"configVersion": 1,
|
|
208
|
+
"workspaces": {
|
|
209
|
+
"": {
|
|
210
|
+
"devDependencies": {
|
|
211
|
+
"wrangler": "4.151.1",
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
"packages": {
|
|
216
|
+
"@cloudflare/kv-asset-handler": ["@cloudflare/kv-asset-handler@0.5.0", "", {}, "sha512-jxQYkj8dSIzc0cD6cMMNdOc1UVjqSqu8BZdor5s8cGjW2I8BjODt/kWPVdY+u9zj3ms75Q5qaZgnxUad83+eAg=="],
|
|
217
|
+
|
|
218
|
+
"@cloudflare/unenv-preset": ["@cloudflare/unenv-preset@2.16.2", "", { "peerDependencies": { "unenv": "2.0.0-rc.24", "workerd": ">1.20260305.0 <2.0.0-0" }, "optionalPeers": ["workerd"] }, "sha512-JBP1+Z7ZSNG/d4mRP+y8VC5dka3tZVMLEZRvS+rzQ4DGV1EoxRFQckcJTTkXbHSQiTj0DtNI01Zwb/V2fX0mvQ=="],
|
|
219
|
+
|
|
220
|
+
"@cloudflare/workerd-darwin-64": ["@cloudflare/workerd-darwin-64@1.20261012.1", "", { "os": "darwin", "cpu": "x64" }, "sha512-dkTL9aY3V4D40b+jBpGPCistWUPFQ/M61wlWi6i1o8MvHFFgEw7EQkcaYEv6Yd3bkPDD/3TFT4hRsMb2xVZSwQ=="],
|
|
221
|
+
|
|
222
|
+
"@cloudflare/workerd-darwin-arm64": ["@cloudflare/workerd-darwin-arm64@1.20261012.1", "", { "os": "darwin", "cpu": "arm64" }, "sha512-2/nVGcKXjNNI+DhxKSepTKvFng9H7aN2WXv6Zu67iqgI6JrxypNt5kTPv4ZHosxrcfyKMci/2RfN7GIrN0BitQ=="],
|
|
223
|
+
|
|
224
|
+
"@cloudflare/workerd-linux-64": ["@cloudflare/workerd-linux-64@1.20261012.1", "", { "os": "linux", "cpu": "x64" }, "sha512-uMe7ONHnLxStD1Ye0YFHBO36uj4cStv5P53rW+5GVWXFT8BRjqVixlH0IqCAHe1Pmcwyd1+7fVoGde89MZSCJg=="],
|
|
225
|
+
|
|
226
|
+
"@cloudflare/workerd-linux-arm64": ["@cloudflare/workerd-linux-arm64@1.20261012.1", "", { "os": "linux", "cpu": "arm64" }, "sha512-I0VMdcXk7ygG5vYDce0ePTBFdnBXC0i9WiBY5mWiv0iTinbfea6/rHqSQ7B1UMpjgrYVs9E0m4bZ9ufsk5GCFA=="],
|
|
227
|
+
|
|
228
|
+
"@cloudflare/workerd-windows-64": ["@cloudflare/workerd-windows-64@1.20261012.1", "", { "os": "win32", "cpu": "x64" }, "sha512-c5hQvNx574UEoknaCFvMa/NdLrrYiALNbe6sx1okW8uOiRYWxrFuA8WpXFnBJ5XJypm0TEAHYaUTGv3rRLpY7Q=="],
|
|
229
|
+
|
|
230
|
+
"@cspotcode/source-map-support": ["@cspotcode/source-map-support@0.8.1", "", { "dependencies": { "@jridgewell/trace-mapping": "0.3.9" } }, "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw=="],
|
|
231
|
+
|
|
232
|
+
"@emnapi/runtime": ["@emnapi/runtime@1.11.3", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-Xz4Tpyki7XyrpbUK1jR1AhdAdaXyhhY4lZ3neLodmhpuWfy2PAQN5B46sAiU4liOXGLkHypn/qU+jvfWSCYYLA=="],
|
|
233
|
+
|
|
234
|
+
"@esbuild/aix-ppc64": ["@esbuild/aix-ppc64@0.28.2", "", { "os": "aix", "cpu": "ppc64" }, "sha512-XExcO+dvLKvVtNTibSTBej1NCAbaGhWn9Ww1ZPx80qsahhPFe/8jgWP0IchNe0F3HwkU7n8ejhH8bjonqht8mQ=="],
|
|
235
|
+
|
|
236
|
+
"@esbuild/android-arm": ["@esbuild/android-arm@0.28.2", "", { "os": "android", "cpu": "arm" }, "sha512-kXXoiPVVGQcnIYGOeaovwOURpniDBpSq4A03qkQ+BMQqtGG6HYap3xne9C1O1yo4TR3qxlCX5IqqmX6fFo2Lqg=="],
|
|
237
|
+
|
|
238
|
+
"@esbuild/android-arm64": ["@esbuild/android-arm64@0.28.2", "", { "os": "android", "cpu": "arm64" }, "sha512-5YfKeeI8qWfBZIX+u2xZC3Zlb3Os/gLS2sbEKM+I4ZOcsWmHS2WLysCcQZDAFRslDUU5Oiq44gf6PYN1vGwG5A=="],
|
|
239
|
+
|
|
240
|
+
"@esbuild/android-x64": ["@esbuild/android-x64@0.28.2", "", { "os": "android", "cpu": "x64" }, "sha512-O387ite7SzUyCcy3JQX4P4bLtEA7bLLkx+esve5JHnyYfNTxcVpXZo9jhdB0lTKN44gztELTdU7nS8Nr16Fs1Q=="],
|
|
241
|
+
|
|
242
|
+
"@esbuild/darwin-arm64": ["@esbuild/darwin-arm64@0.28.2", "", { "os": "darwin", "cpu": "arm64" }, "sha512-n4KqkOQrraxHJcgjM1RvwbigfQKIKJVpM7xp+KsxiyUSrRdIXnt73VhrPAx0fV44hgfmIVKjxMN9J1t5jySVkw=="],
|
|
243
|
+
|
|
244
|
+
"@esbuild/darwin-x64": ["@esbuild/darwin-x64@0.28.2", "", { "os": "darwin", "cpu": "x64" }, "sha512-uq6suIWYP37qzGddBKPw5QEQPi6HiLGsO7UmkpfyaYNQ3D+rN6w6WfwH+nuqcGXWvawGwxOEroO4YGnFh95azw=="],
|
|
245
|
+
|
|
246
|
+
"@esbuild/freebsd-arm64": ["@esbuild/freebsd-arm64@0.28.2", "", { "os": "freebsd", "cpu": "arm64" }, "sha512-n+I0BTSRIoy+d6RPKnEVwql5UwBJolytvY4mAOIEJorKlqgPII8ix6slVVrfZ5Tnj7glIZvloylbB/EJPMWEXw=="],
|
|
247
|
+
|
|
248
|
+
"@esbuild/freebsd-x64": ["@esbuild/freebsd-x64@0.28.2", "", { "os": "freebsd", "cpu": "x64" }, "sha512-78XJTJkvPs0kz2w61301PJjXl4g7q3JqiYMZ/M/yVI73EHBrCRTgkhu9oqG7vPqq+a/yadEW8aD+agKlk5xrmg=="],
|
|
249
|
+
|
|
250
|
+
"@esbuild/linux-arm": ["@esbuild/linux-arm@0.28.2", "", { "os": "linux", "cpu": "arm" }, "sha512-XlDnu2q5yoqems+xay6wSAcg9DDD7K9RLKZEBOMZm3ckNpJBvOX20tSfby8KfrrhINDyv9V2YVZKY/SpoGJI8w=="],
|
|
251
|
+
|
|
252
|
+
"@esbuild/linux-arm64": ["@esbuild/linux-arm64@0.28.2", "", { "os": "linux", "cpu": "arm64" }, "sha512-pW4AC0P3it8c7do9MVM4p51FzHzdM/TZrerurgRcHJ2WTa1VQ1CIq18xncfpBJw4ojkiZZrKW2yIBWBP92j6Ug=="],
|
|
253
|
+
|
|
254
|
+
"@esbuild/linux-ia32": ["@esbuild/linux-ia32@0.28.2", "", { "os": "linux", "cpu": "ia32" }, "sha512-CYbnj78HsIeA+DhgUKgFCfvNsTHFhMMrinUrMZpDXJXKN8T3XViTZ/+wtHeVxEWY8ewSzTFN+nRmSwO2tZaLUQ=="],
|
|
255
|
+
|
|
256
|
+
"@esbuild/linux-loong64": ["@esbuild/linux-loong64@0.28.2", "", { "os": "linux", "cpu": "none" }, "sha512-buwkd8nsph4R+ajRvw0qM5Hja/TXQow3ptzWO2EbG/cqcIkHloRrdlBtQlshyYGTNFvfkfJ5tpPLVkY4DtsPfQ=="],
|
|
257
|
+
|
|
258
|
+
"@esbuild/linux-mips64el": ["@esbuild/linux-mips64el@0.28.2", "", { "os": "linux", "cpu": "none" }, "sha512-ZVykbDyk7519VwiNb9Lcj9m8XM6v5V9uKPvrEMkkEedVewf+0itkhahp4HDpgERXhwLRpWFypsGbG/J8s0QjJA=="],
|
|
259
|
+
|
|
260
|
+
"@esbuild/linux-ppc64": ["@esbuild/linux-ppc64@0.28.2", "", { "os": "linux", "cpu": "ppc64" }, "sha512-CAXl+Dtd9UUuJd8pKKdwh6MLm3MUMiqMPmhZ3tTSXPqfyQ3vDl6R5hZdZ/kYojK4ofXtdfSv1tFq8XzWx3heNQ=="],
|
|
261
|
+
|
|
262
|
+
"@esbuild/linux-riscv64": ["@esbuild/linux-riscv64@0.28.2", "", { "os": "linux", "cpu": "none" }, "sha512-GeXCej4IQtU1B+QlDV8W/RRvbzI3O/Stss+/bCXv4lZls5WGRtu2a+3JkA3i4qIUlMXpcHebWpF8AkJhATowuA=="],
|
|
263
|
+
|
|
264
|
+
"@esbuild/linux-s390x": ["@esbuild/linux-s390x@0.28.2", "", { "os": "linux", "cpu": "s390x" }, "sha512-3H1weTYZPxt/WOhByszQZybS9w5lKzUn1FDMsgEChbHWQwHYQQRfBxgCcZvPhjHfKyJjIievvMmEUawJrdY9Dg=="],
|
|
265
|
+
|
|
266
|
+
"@esbuild/linux-x64": ["@esbuild/linux-x64@0.28.2", "", { "os": "linux", "cpu": "x64" }, "sha512-4xTZr1FUmSoQW4XIWmit3tzQrUTZM+N3P0XV8xROKYF50XfI7xeO90+1bZvNwxIufQ9hDQVRJH5YhgPVF8A/HQ=="],
|
|
267
|
+
|
|
268
|
+
"@esbuild/netbsd-arm64": ["@esbuild/netbsd-arm64@0.28.2", "", { "os": "none", "cpu": "arm64" }, "sha512-sSATRjPeDBg3pdgHoQfoYBob11Kk1FGa9lui5RIHZCoCkJa9QKlvl3/vKz2usCmYYjs7ymJR/2Nnsqe+Hjt5nw=="],
|
|
269
|
+
|
|
270
|
+
"@esbuild/netbsd-x64": ["@esbuild/netbsd-x64@0.28.2", "", { "os": "none", "cpu": "x64" }, "sha512-lqnzCV+mM0gIADaKihiCg6ifgfU2L3h5E33rNQBN1Y4MaVGnzryzmvvf7UHxprpQdE8hpqLolJ9Rl+SkIRDpyw=="],
|
|
271
|
+
|
|
272
|
+
"@esbuild/openbsd-arm64": ["@esbuild/openbsd-arm64@0.28.2", "", { "os": "openbsd", "cpu": "arm64" }, "sha512-AL2qJILH7lNjrDmCQDvdxMfAUIv8KMNZOvrwAQ8i8//ntL9FflhOyMJ8OZSMBb8/AWXe3/5v5S20y3zCoZWKoQ=="],
|
|
273
|
+
|
|
274
|
+
"@esbuild/openbsd-x64": ["@esbuild/openbsd-x64@0.28.2", "", { "os": "openbsd", "cpu": "x64" }, "sha512-QtiuPytchRyC4rwUKhexJdQKvDuZ6hWloi3igqPQNUJCS1/v9EiO3UTOXR6A3FoMo4fnAKbWJdqaIwhOzh8qEw=="],
|
|
275
|
+
|
|
276
|
+
"@esbuild/openharmony-arm64": ["@esbuild/openharmony-arm64@0.28.2", "", { "os": "none", "cpu": "arm64" }, "sha512-WkhYDmpTjLvGlScA1rwjRUmhl4k8oXR3cIbtqWmELgU/dFeHHlEllxDvdWcNJV9rbzCexB5vz8gtNewWLgCT7Q=="],
|
|
277
|
+
|
|
278
|
+
"@esbuild/sunos-x64": ["@esbuild/sunos-x64@0.28.2", "", { "os": "sunos", "cpu": "x64" }, "sha512-GPMSkTOtMnv2U2F8gxe4Io6qmVs+YKyp832Etqqxr0hFngmXQ3rzwytelm3GIn7T4VviRUlf3sOgBOiTdvaf7g=="],
|
|
279
|
+
|
|
280
|
+
"@esbuild/win32-arm64": ["@esbuild/win32-arm64@0.28.2", "", { "os": "win32", "cpu": "arm64" }, "sha512-PIhhEkE9uPBleRBrQEJpUn7MBnibZzbGzYWPmY3x+YoVg/95zbjB4CxPPOQ8l5tYYM4mMaCthF8/1DIfBQQyWQ=="],
|
|
281
|
+
|
|
282
|
+
"@esbuild/win32-ia32": ["@esbuild/win32-ia32@0.28.2", "", { "os": "win32", "cpu": "ia32" }, "sha512-YmJbfTlvU7Sdn9BB+4PRES4oB6pxgS37MAONj+hBr/cpXS1aBPKXxNnDbu+QCWPj0o9dgyxeq79g6c5P8KeuYA=="],
|
|
283
|
+
|
|
284
|
+
"@esbuild/win32-x64": ["@esbuild/win32-x64@0.28.2", "", { "os": "win32", "cpu": "x64" }, "sha512-5ebpxr3nWMzrL/rnUI755Jkuee0bHL/Gq0WTF9lvcpv73wAp5eu8MfBUgWK9bhWvZjj7yX8etf/8tI8Ney695g=="],
|
|
285
|
+
|
|
286
|
+
"@img/colour": ["@img/colour@1.1.0", "", {}, "sha512-Td76q7j57o/tLVdgS746cYARfSyxk8iEfRxewL9h4OMzYhbW4TAcppl0mT4eyqXddh6L/jwoM75mo7ixa/pCeQ=="],
|
|
287
|
+
|
|
288
|
+
"@img/sharp-darwin-arm64": ["@img/sharp-darwin-arm64@0.35.5", "", { "optionalDependencies": { "@img/sharp-libvips-darwin-arm64": "1.3.4" }, "os": "darwin", "cpu": "arm64" }, "sha512-QRUlFQ0WxvdWyqqG/WtI3iupfD5rBzmCHXSdPsY91sAtVtTo7Q4cb6zOccZ3gqEqkr0f1As1ehLqmEpDsRf+lg=="],
|
|
289
|
+
|
|
290
|
+
"@img/sharp-darwin-x64": ["@img/sharp-darwin-x64@0.35.5", "", { "optionalDependencies": { "@img/sharp-libvips-darwin-x64": "1.3.4" }, "os": "darwin", "cpu": "x64" }, "sha512-+BR255RhDlpygUpOc/Jdt1nT6DQ3XG/ERo5wbcdOf5Q320dKtPCKPLR1LJs9VGXRaMa8l1uUa0tkCNOXiAxZUw=="],
|
|
291
|
+
|
|
292
|
+
"@img/sharp-freebsd-wasm32": ["@img/sharp-freebsd-wasm32@0.35.5", "", { "dependencies": { "@img/sharp-wasm32": "0.35.5" }, "os": "freebsd" }, "sha512-Y/z91nEZ4uIBX5X3nfTovjU9lHNKFYbL2lpHCLVNmXQK03VIZvXBBt0KxbPGp2SdGSF+2mQU4e+hQaWOt86iAw=="],
|
|
293
|
+
|
|
294
|
+
"@img/sharp-libvips-darwin-arm64": ["@img/sharp-libvips-darwin-arm64@1.3.4", "", { "os": "darwin", "cpu": "arm64" }, "sha512-5R89nBYiRdUlSWJxPhO+GVtaXzXSxKnRu/xqMn3KTA3L9EB9Oy/P+Nn2f2vlhPuUdy/Zusb2DarbyTpGCfEDuw=="],
|
|
295
|
+
|
|
296
|
+
"@img/sharp-libvips-darwin-x64": ["@img/sharp-libvips-darwin-x64@1.3.4", "", { "os": "darwin", "cpu": "x64" }, "sha512-iR2OKH80yi0U+dUplyh3/xdpFvps6YkCwsXenIJxqxR1v9o+xtKTGbS9H7cps+2Vxjc8B1j96p75NmTGjIhtpQ=="],
|
|
297
|
+
|
|
298
|
+
"@img/sharp-libvips-linux-arm": ["@img/sharp-libvips-linux-arm@1.3.4", "", { "os": "linux", "cpu": "arm" }, "sha512-LmRtTsOHuvM2+wlO2Db37dx5MiZhB0FvSunciw48YjdOkZz9KAiRbm8ujeMOA1INqmei5NapFxYEK1D1ZSidmw=="],
|
|
299
|
+
|
|
300
|
+
"@img/sharp-libvips-linux-arm64": ["@img/sharp-libvips-linux-arm64@1.3.4", "", { "os": "linux", "cpu": "arm64" }, "sha512-Y3dgX/6lE2QhQb+Gxy0WZxfg9MEm/JBjamZpS2IklP7xIQoKN4hzAm7KcMVGtaVDt3neE9OKBC7vAfonA/Lr1A=="],
|
|
301
|
+
|
|
302
|
+
"@img/sharp-libvips-linux-ppc64": ["@img/sharp-libvips-linux-ppc64@1.3.4", "", { "os": "linux", "cpu": "ppc64" }, "sha512-Le6boB8Tai0Nis+gIxIpKx68UDVVIqdR8Tin5Yf1z2LJJQLDJvCDRqRu+jC2qCoD+eIomonmOwB4smBRxfVpYQ=="],
|
|
303
|
+
|
|
304
|
+
"@img/sharp-libvips-linux-riscv64": ["@img/sharp-libvips-linux-riscv64@1.3.4", "", { "os": "linux", "cpu": "none" }, "sha512-aHkkIEHPRdQEegJN20MLmGtxYD9R2wQr3Cwpddnu5+YKMt6Uzax7S9h5gpZTo8wyrGuZSlfQ63OevL5mTyOC7Q=="],
|
|
305
|
+
|
|
306
|
+
"@img/sharp-libvips-linux-s390x": ["@img/sharp-libvips-linux-s390x@1.3.4", "", { "os": "linux", "cpu": "s390x" }, "sha512-ra/mB6MikESDUO7Yg+Mi95bFBb9GsObURuhnOv3OqknjGe9sZrG8tCe9q0xSIGrtLgvgw0gKnFWcK4blSgQOuQ=="],
|
|
307
|
+
|
|
308
|
+
"@img/sharp-libvips-linux-x64": ["@img/sharp-libvips-linux-x64@1.3.4", "", { "os": "linux", "cpu": "x64" }, "sha512-GJ//SSXbnwSDes02umB3nDJLFcQzw8a18V8fyhqr6tV515tOEMdImjjxj1AoafMRz56F3PHgftnj1QEKSU1zkw=="],
|
|
309
|
+
|
|
310
|
+
"@img/sharp-libvips-linuxmusl-arm64": ["@img/sharp-libvips-linuxmusl-arm64@1.3.4", "", { "os": "linux", "cpu": "arm64" }, "sha512-hvulFwtjUcagsis6BBxHwGFwWoNZjgYmULGVrZcyfNbjA8hKILbRxGg15/7w5HDyXHXUos/j6baAWqnCyQ2DWA=="],
|
|
311
|
+
|
|
312
|
+
"@img/sharp-libvips-linuxmusl-x64": ["@img/sharp-libvips-linuxmusl-x64@1.3.4", "", { "os": "linux", "cpu": "x64" }, "sha512-6zXKeE/p39I1AmA3cJG35eyBGNqNddLnUXjhwBnsGjFPWqf5VKkDBEqaEkPDoTEtkxwi2vv8Tcr2mDyP4So7Fg=="],
|
|
313
|
+
|
|
314
|
+
"@img/sharp-linux-arm": ["@img/sharp-linux-arm@0.35.5", "", { "optionalDependencies": { "@img/sharp-libvips-linux-arm": "1.3.4" }, "os": "linux", "cpu": "arm" }, "sha512-LEaXK2WdXVK5ykcw0buWyPMsmLLL2vpHLD6yrNSW+JGEL3BZPA4tpKN6iaMc4AxTTAoaX/sU1rOL51lcIz48ZQ=="],
|
|
315
|
+
|
|
316
|
+
"@img/sharp-linux-arm64": ["@img/sharp-linux-arm64@0.35.5", "", { "optionalDependencies": { "@img/sharp-libvips-linux-arm64": "1.3.4" }, "os": "linux", "cpu": "arm64" }, "sha512-LYVx5JTsOM2CBzmxreh+nl64/3H6Xb09iSLknqH47z2T2DFFxDeFLP5y4dJwe6H7uGQlHPyEEtIqyo3DYsRwdQ=="],
|
|
317
|
+
|
|
318
|
+
"@img/sharp-linux-ppc64": ["@img/sharp-linux-ppc64@0.35.5", "", { "optionalDependencies": { "@img/sharp-libvips-linux-ppc64": "1.3.4" }, "os": "linux", "cpu": "ppc64" }, "sha512-QVxAAq8evVRI9ia2vqgwrmWucn5Dfv+JdWzj75pD8omHLPSP7f8p20O8jxzjCcuCEQEOtYOZUmX1hkiZ0kdevA=="],
|
|
319
|
+
|
|
320
|
+
"@img/sharp-linux-riscv64": ["@img/sharp-linux-riscv64@0.35.5", "", { "optionalDependencies": { "@img/sharp-libvips-linux-riscv64": "1.3.4" }, "os": "linux", "cpu": "none" }, "sha512-LtdreXguaavKODPIfzJ4kffx7UNt1omwtK0rch4EBbbSTXPnxWmYSayXdLJw0fJzQ97kHt1gL/yh4tvU+nCyRQ=="],
|
|
321
|
+
|
|
322
|
+
"@img/sharp-linux-s390x": ["@img/sharp-linux-s390x@0.35.5", "", { "optionalDependencies": { "@img/sharp-libvips-linux-s390x": "1.3.4" }, "os": "linux", "cpu": "s390x" }, "sha512-UZasTOFiYzotTsGOCu42BfUzP6Tu6Do/947iRm1RsLKvlllxwGcn4RN27LibGWceix4Y+Pmw3jsnTcCQIgWjqA=="],
|
|
323
|
+
|
|
324
|
+
"@img/sharp-linux-x64": ["@img/sharp-linux-x64@0.35.5", "", { "optionalDependencies": { "@img/sharp-libvips-linux-x64": "1.3.4" }, "os": "linux", "cpu": "x64" }, "sha512-SxFtLTeJInhAA9Q836kux2vZNeOBQEx658qvbboZScr0wIARym3IcGmW7KpVD5sbVg0Ojy+udFQdayYIZyoNog=="],
|
|
325
|
+
|
|
326
|
+
"@img/sharp-linuxmusl-arm64": ["@img/sharp-linuxmusl-arm64@0.35.5", "", { "optionalDependencies": { "@img/sharp-libvips-linuxmusl-arm64": "1.3.4" }, "os": "linux", "cpu": "arm64" }, "sha512-9HbMclmI1zlNkFRs3z9/eBtDjfD0sGlrX1z6b1qwmiFY5ElDLh4BC0LPBdVp7z1DXFiKlIcznf+ZlsuZzLxQqg=="],
|
|
327
|
+
|
|
328
|
+
"@img/sharp-linuxmusl-x64": ["@img/sharp-linuxmusl-x64@0.35.5", "", { "optionalDependencies": { "@img/sharp-libvips-linuxmusl-x64": "1.3.4" }, "os": "linux", "cpu": "x64" }, "sha512-4KOphqB035HrVdqLZfCgMzzERrQkkzOwRhl4OAkRO1YCldbaFjySXMaK534Mo0V+LndnlJk+sbUyLeU0ULyD1A=="],
|
|
329
|
+
|
|
330
|
+
"@img/sharp-wasm32": ["@img/sharp-wasm32@0.35.5", "", { "dependencies": { "@emnapi/runtime": "^1.11.3" } }, "sha512-Ptsga1su4tQx+LLF1ECS9U6nz5kmrXKo6XVbtR48Ke3ZRxxgaWBu7IDtEe1quo8hiupwm6WFqxVlXaSf7IINGQ=="],
|
|
331
|
+
|
|
332
|
+
"@img/sharp-webcontainers-wasm32": ["@img/sharp-webcontainers-wasm32@0.35.5", "", { "dependencies": { "@img/sharp-wasm32": "0.35.5" }, "cpu": "none" }, "sha512-hfhF/FmoQyTUkA0bIKFOtw536BQSeBMe6BF6QyWlrPxT754+TFLaZ7sKKTfvvM0yJgKgaYTwnFCIZ/GuDw5SUA=="],
|
|
333
|
+
|
|
334
|
+
"@img/sharp-win32-arm64": ["@img/sharp-win32-arm64@0.35.5", "", { "os": "win32", "cpu": "arm64" }, "sha512-X4t7g+7ZA5DKblCBEXGjUqqemj4vczING/5viFwAL8h4N3qYeyjwdCvRLHi4EdOUI+2Z7UFlp1VM+p/AuEtm6Q=="],
|
|
335
|
+
|
|
336
|
+
"@img/sharp-win32-ia32": ["@img/sharp-win32-ia32@0.35.5", "", { "os": "win32", "cpu": "ia32" }, "sha512-5Zm82LoBc43nhwNybZlG7Y1KO//Zhsn306fQl29ZOuStHLGTo3BWL83q3cznX0poxSAMuYL1On/BHBxkBeKr6A=="],
|
|
337
|
+
|
|
338
|
+
"@img/sharp-win32-x64": ["@img/sharp-win32-x64@0.35.5", "", { "os": "win32", "cpu": "x64" }, "sha512-x76eH0vEiHlcMQu8Y8IenntaACtddpT6W0wmXtWrnKcnKI7ME5DdgqhAD6SEWOEl1v2zDvkZDhFA9KnURwpfqg=="],
|
|
339
|
+
|
|
340
|
+
"@jridgewell/resolve-uri": ["@jridgewell/resolve-uri@3.1.2", "", {}, "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw=="],
|
|
341
|
+
|
|
342
|
+
"@jridgewell/sourcemap-codec": ["@jridgewell/sourcemap-codec@1.6.0", "", {}, "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw=="],
|
|
343
|
+
|
|
344
|
+
"@jridgewell/trace-mapping": ["@jridgewell/trace-mapping@0.3.9", "", { "dependencies": { "@jridgewell/resolve-uri": "^3.0.3", "@jridgewell/sourcemap-codec": "^1.4.10" } }, "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ=="],
|
|
345
|
+
|
|
346
|
+
"@poppinss/colors": ["@poppinss/colors@4.1.6", "", { "dependencies": { "kleur": "^4.1.5" } }, "sha512-H9xkIdFswbS8n1d6vmRd8+c10t2Qe+rZITbbDHHkQixH5+2x1FDGmi/0K+WgWiqQFKPSlIYB7jlH6Kpfn6Fleg=="],
|
|
347
|
+
|
|
348
|
+
"@poppinss/dumper": ["@poppinss/dumper@0.6.5", "", { "dependencies": { "@poppinss/colors": "^4.1.5", "@sindresorhus/is": "^7.0.2", "supports-color": "^10.0.0" } }, "sha512-NBdYIb90J7LfOI32dOewKI1r7wnkiH6m920puQ3qHUeZkxNkQiFnXVWoE6YtFSv6QOiPPf7ys6i+HWWecDz7sw=="],
|
|
349
|
+
|
|
350
|
+
"@poppinss/exception": ["@poppinss/exception@1.2.3", "", {}, "sha512-dCED+QRChTVatE9ibtoaxc+WkdzOSjYTKi/+uacHWIsfodVfpsueo3+DKpgU5Px8qXjgmXkSvhXvSCz3fnP9lw=="],
|
|
351
|
+
|
|
352
|
+
"@sindresorhus/is": ["@sindresorhus/is@7.2.0", "", {}, "sha512-P1Cz1dWaFfR4IR+U13mqqiGsLFf1KbayybWwdd2vfctdV6hDpUkgCY0nKOLLTMSoRd/jJNjtbqzf13K8DCCXQw=="],
|
|
353
|
+
|
|
354
|
+
"@speed-highlight/core": ["@speed-highlight/core@1.2.24", "", {}, "sha512-qeW2e1l78afw8VhRPfPQ1Gjj+KU5XFQ/OFV5ti6eTa9bruO7mJyZtA4vw0ofqmA3tKCkROE9xLk3VZoeRc98nw=="],
|
|
355
|
+
|
|
356
|
+
"blake3-wasm": ["blake3-wasm@2.1.5", "", {}, "sha512-F1+K8EbfOZE49dtoPtmxUQrpXaBIl3ICvasLh+nJta0xkz+9kF/7uet9fLnwKqhDrmj6g+6K3Tw9yQPUg2ka5g=="],
|
|
357
|
+
|
|
358
|
+
"cookie": ["cookie@1.1.1", "", {}, "sha512-ei8Aos7ja0weRpFzJnEA9UHJ/7XQmqglbRwnf2ATjcB9Wq874VKH9kfjjirM6UhU2/E5fFYadylyhFldcqSidQ=="],
|
|
359
|
+
|
|
360
|
+
"detect-libc": ["detect-libc@2.1.2", "", {}, "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ=="],
|
|
361
|
+
|
|
362
|
+
"error-stack-parser-es": ["error-stack-parser-es@1.0.5", "", {}, "sha512-5qucVt2XcuGMcEGgWI7i+yZpmpByQ8J1lHhcL7PwqCwu9FPP3VUXzT4ltHe5i2z9dePwEHcDVOAfSnHsOlCXRA=="],
|
|
363
|
+
|
|
364
|
+
"esbuild": ["esbuild@0.28.2", "", { "optionalDependencies": { "@esbuild/aix-ppc64": "0.28.2", "@esbuild/android-arm": "0.28.2", "@esbuild/android-arm64": "0.28.2", "@esbuild/android-x64": "0.28.2", "@esbuild/darwin-arm64": "0.28.2", "@esbuild/darwin-x64": "0.28.2", "@esbuild/freebsd-arm64": "0.28.2", "@esbuild/freebsd-x64": "0.28.2", "@esbuild/linux-arm": "0.28.2", "@esbuild/linux-arm64": "0.28.2", "@esbuild/linux-ia32": "0.28.2", "@esbuild/linux-loong64": "0.28.2", "@esbuild/linux-mips64el": "0.28.2", "@esbuild/linux-ppc64": "0.28.2", "@esbuild/linux-riscv64": "0.28.2", "@esbuild/linux-s390x": "0.28.2", "@esbuild/linux-x64": "0.28.2", "@esbuild/netbsd-arm64": "0.28.2", "@esbuild/netbsd-x64": "0.28.2", "@esbuild/openbsd-arm64": "0.28.2", "@esbuild/openbsd-x64": "0.28.2", "@esbuild/openharmony-arm64": "0.28.2", "@esbuild/sunos-x64": "0.28.2", "@esbuild/win32-arm64": "0.28.2", "@esbuild/win32-ia32": "0.28.2", "@esbuild/win32-x64": "0.28.2" }, "bin": { "esbuild": "bin/esbuild" } }, "sha512-HKVLS8dvII+xoKW9kmqxbRKrnWEXfJJr/FZhhJmiqIB0e053QNYFqOBouTMO/k5sID4MvCiUCvv8b9M4h32wIA=="],
|
|
365
|
+
|
|
366
|
+
"fsevents": ["fsevents@2.3.3", "", { "os": "darwin" }, "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw=="],
|
|
367
|
+
|
|
368
|
+
"kleur": ["kleur@4.1.5", "", {}, "sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ=="],
|
|
369
|
+
|
|
370
|
+
"miniflare": ["miniflare@5.20261012.1-beta", "", { "dependencies": { "@cspotcode/source-map-support": "0.8.1", "sharp": "0.35.5", "undici": "7.29.1", "workerd": "1.20261012.1", "ws": "8.21.0", "youch": "4.1.0-beta.10" } }, "sha512-8Canhy6g9+vAhqMc0o80YphqYIwpiA3aAp8aX+uDXU7J/qbUeoZzcII9c2V1P4uT/eHD4SB93qet1o1bRY3BuQ=="],
|
|
371
|
+
|
|
372
|
+
"path-to-regexp": ["path-to-regexp@6.3.0", "", {}, "sha512-Yhpw4T9C6hPpgPeA28us07OJeqZ5EzQTkbfwuhsUg0c237RomFoETJgmp2sa3F/41gfLE6G5cqcYwznmeEeOlQ=="],
|
|
373
|
+
|
|
374
|
+
"pathe": ["pathe@2.0.3", "", {}, "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w=="],
|
|
375
|
+
|
|
376
|
+
"semver": ["semver@7.8.5", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA=="],
|
|
377
|
+
|
|
378
|
+
"sharp": ["sharp@0.35.5", "", { "dependencies": { "@img/colour": "^1.1.0", "detect-libc": "^2.1.2", "semver": "^7.8.5" }, "optionalDependencies": { "@img/sharp-darwin-arm64": "0.35.5", "@img/sharp-darwin-x64": "0.35.5", "@img/sharp-freebsd-wasm32": "0.35.5", "@img/sharp-libvips-darwin-arm64": "1.3.4", "@img/sharp-libvips-darwin-x64": "1.3.4", "@img/sharp-libvips-linux-arm": "1.3.4", "@img/sharp-libvips-linux-arm64": "1.3.4", "@img/sharp-libvips-linux-ppc64": "1.3.4", "@img/sharp-libvips-linux-riscv64": "1.3.4", "@img/sharp-libvips-linux-s390x": "1.3.4", "@img/sharp-libvips-linux-x64": "1.3.4", "@img/sharp-libvips-linuxmusl-arm64": "1.3.4", "@img/sharp-libvips-linuxmusl-x64": "1.3.4", "@img/sharp-linux-arm": "0.35.5", "@img/sharp-linux-arm64": "0.35.5", "@img/sharp-linux-ppc64": "0.35.5", "@img/sharp-linux-riscv64": "0.35.5", "@img/sharp-linux-s390x": "0.35.5", "@img/sharp-linux-x64": "0.35.5", "@img/sharp-linuxmusl-arm64": "0.35.5", "@img/sharp-linuxmusl-x64": "0.35.5", "@img/sharp-webcontainers-wasm32": "0.35.5", "@img/sharp-win32-arm64": "0.35.5", "@img/sharp-win32-ia32": "0.35.5", "@img/sharp-win32-x64": "0.35.5" }, "peerDependencies": { "@types/node": "*" }, "optionalPeers": ["@types/node"] }, "sha512-Ywn4OnzGukp7CDMrp08RQ50YKmuwG47brZgIVPTvBaaAfQlRlygrRqSrxdCiL9M+LlzLBiJ68IR1QqvzHyjC7g=="],
|
|
379
|
+
|
|
380
|
+
"supports-color": ["supports-color@10.2.2", "", {}, "sha512-SS+jx45GF1QjgEXQx4NJZV9ImqmO2NPz5FNsIHrsDjh2YsHnawpan7SNQ1o8NuhrbHZy9AZhIoCUiCeaW/C80g=="],
|
|
381
|
+
|
|
382
|
+
"tslib": ["tslib@2.8.1", "", {}, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="],
|
|
383
|
+
|
|
384
|
+
"undici": ["undici@7.29.1", "", {}, "sha512-RYONW2MeafgYlkVOKYKkA/Ag7BmXqgIWCa8t1m0JcxrQg9pI9lEqRhAOruOBCbAohOa/gkCF+iPi9hrgvTzu6Q=="],
|
|
385
|
+
|
|
386
|
+
"unenv": ["unenv@2.0.0-rc.24", "", { "dependencies": { "pathe": "^2.0.3" } }, "sha512-i7qRCmY42zmCwnYlh9H2SvLEypEFGye5iRmEMKjcGi7zk9UquigRjFtTLz0TYqr0ZGLZhaMHl/foy1bZR+Cwlw=="],
|
|
387
|
+
|
|
388
|
+
"workerd": ["workerd@1.20261012.1", "", { "optionalDependencies": { "@cloudflare/workerd-darwin-64": "1.20261012.1", "@cloudflare/workerd-darwin-arm64": "1.20261012.1", "@cloudflare/workerd-linux-64": "1.20261012.1", "@cloudflare/workerd-linux-arm64": "1.20261012.1", "@cloudflare/workerd-windows-64": "1.20261012.1" }, "bin": { "workerd": "bin/workerd" } }, "sha512-tEHoMPsMga0seVjxfsR8Pd3f8IRqYwkq++dTUKI5Gdgj6zuSDluYwisydq+dn90SsIACwBquJUQ1nBpcOqaWTA=="],
|
|
389
|
+
|
|
390
|
+
"wrangler": ["wrangler@4.151.1", "", { "dependencies": { "@cloudflare/kv-asset-handler": "0.5.0", "@cloudflare/unenv-preset": "2.16.2", "blake3-wasm": "2.1.5", "esbuild": "0.28.2", "miniflare": "5.20261012.1-beta", "path-to-regexp": "6.3.0", "unenv": "2.0.0-rc.24", "workerd": "1.20261012.1" }, "optionalDependencies": { "fsevents": "2.3.3" }, "peerDependencies": { "@cloudflare/workers-types": "^5.20261006.1" }, "optionalPeers": ["@cloudflare/workers-types"], "bin": { "wrangler": "bin/wrangler.js", "wrangler2": "bin/wrangler.js", "cf-wrangler": "bin/cf-wrangler.js" } }, "sha512-OAsa9UAHZshM6mq2PXcVoyxXgWThAanZMBc/IirtqEWd/BauRtmUKzAniOu/pU0pd3pxKuMZ2vsbF4eo6RiNDA=="],
|
|
391
|
+
|
|
392
|
+
"ws": ["ws@8.21.0", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-Vsp28b7DRcimFQvrqu2Wek3z1iYxDCWqHYB8Qsnk/S4RfaCQzPGPyBNuVjJV3cd6UiKtUtp6sNM77gWvzcCH+g=="],
|
|
393
|
+
|
|
394
|
+
"youch": ["youch@4.1.0-beta.10", "", { "dependencies": { "@poppinss/colors": "^4.1.5", "@poppinss/dumper": "^0.6.4", "@speed-highlight/core": "^1.2.7", "cookie": "^1.0.2", "youch-core": "^0.3.3" } }, "sha512-rLfVLB4FgQneDr0dv1oddCVZmKjcJ6yX6mS4pU82Mq/Dt9a3cLZQ62pDBL4AUO+uVrCvtWz3ZFUL2HFAFJ/BXQ=="],
|
|
395
|
+
|
|
396
|
+
"youch-core": ["youch-core@0.3.3", "", { "dependencies": { "@poppinss/exception": "^1.2.2", "error-stack-parser-es": "^1.0.5" } }, "sha512-ho7XuGjLaJ2hWHoK8yFnsUGy2Y5uDpqSTq1FkHLK4/oqKtyUU1AFbOOxY4IpC9f0fTLjwYbslUz0Po5BpD1wrA=="],
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
`;var Dg={private:!0,devDependencies:{wrangler:"4.151.1"}};var WT=`export class DoorbellError extends Error {
|
|
400
|
+
constructor(
|
|
401
|
+
readonly status: 401 | 409 | 502,
|
|
402
|
+
readonly reason: string,
|
|
403
|
+
) {
|
|
404
|
+
super(reason);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
export type Claims = Record<string, unknown>;
|
|
409
|
+
export type Jwk = { kty?: string; n?: string; e?: string; kid?: string };
|
|
410
|
+
export type KeySource = (kid: string) => Promise<Jwk | null>;
|
|
411
|
+
|
|
412
|
+
const ISSUER = "https://token.actions.githubusercontent.com";
|
|
413
|
+
const JWKS = \`\${ISSUER}/.well-known/jwks\`;
|
|
414
|
+
const SKEW = 60;
|
|
415
|
+
const MAX_TOKEN = 8192;
|
|
416
|
+
const KEYS_TTL = 3600;
|
|
417
|
+
const REFETCH_GAP = 300;
|
|
418
|
+
const FAILURE_GAP = 30;
|
|
419
|
+
|
|
420
|
+
const refuse = (reason: string) => new DoorbellError(401, reason);
|
|
421
|
+
|
|
422
|
+
function decode(part: string): Uint8Array<ArrayBuffer> {
|
|
423
|
+
return Uint8Array.from(atob(part.replace(/-/g, "+").replace(/_/g, "/")), (c) => c.charCodeAt(0));
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
function json(part: string): Record<string, unknown> {
|
|
427
|
+
try {
|
|
428
|
+
const v = JSON.parse(new TextDecoder().decode(decode(part)));
|
|
429
|
+
if (typeof v === "object" && v !== null && !Array.isArray(v)) return v as Record<string, unknown>;
|
|
430
|
+
} catch {}
|
|
431
|
+
throw refuse("malformed token");
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
export function jwksSource(fetchImpl: typeof fetch, clock: () => number): KeySource {
|
|
435
|
+
let keys = new Map<string, Jwk>();
|
|
436
|
+
let fetchedAt = -Infinity;
|
|
437
|
+
let failedAt = -Infinity;
|
|
438
|
+
let inflight: Promise<void> | null = null;
|
|
439
|
+
const refresh = () =>
|
|
440
|
+
(inflight ??= (async () => {
|
|
441
|
+
try {
|
|
442
|
+
const res = await fetchImpl(JWKS, { headers: { accept: "application/json" } }).catch(() => null);
|
|
443
|
+
if (!res?.ok) throw new DoorbellError(502, "GitHub's key set is unreachable");
|
|
444
|
+
const body = (await res.json().catch(() => null)) as { keys?: unknown } | null;
|
|
445
|
+
const list = Array.isArray(body?.keys) ? (body.keys as Jwk[]) : [];
|
|
446
|
+
const next = new Map(list.filter((k) => typeof k.kid === "string" && k.kty === "RSA").map((k) => [k.kid!, k]));
|
|
447
|
+
if (next.size === 0) throw new DoorbellError(502, "GitHub's key set is empty");
|
|
448
|
+
keys = next;
|
|
449
|
+
fetchedAt = clock();
|
|
450
|
+
} catch (e) {
|
|
451
|
+
failedAt = clock();
|
|
452
|
+
throw e;
|
|
453
|
+
} finally {
|
|
454
|
+
inflight = null;
|
|
455
|
+
}
|
|
456
|
+
})());
|
|
457
|
+
return async (kid) => {
|
|
458
|
+
const now = clock();
|
|
459
|
+
const stale = now - fetchedAt > KEYS_TTL || (!keys.has(kid) && now - fetchedAt > REFETCH_GAP);
|
|
460
|
+
if (stale && now - failedAt >= FAILURE_GAP) await refresh();
|
|
461
|
+
else if (stale && !keys.has(kid)) throw new DoorbellError(502, "GitHub's key set is unreachable");
|
|
462
|
+
return keys.get(kid) ?? null;
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
export async function verifyOidc(token: string, origin: string, ownerId: string, keys: KeySource, now: number): Promise<Claims> {
|
|
467
|
+
if (token.length > MAX_TOKEN) throw refuse("token too large");
|
|
468
|
+
const parts = token.split(".");
|
|
469
|
+
if (parts.length !== 3 || !parts.every((p) => /^[A-Za-z0-9_-]+$/.test(p))) throw refuse("malformed token");
|
|
470
|
+
const [h, p, s] = parts as [string, string, string];
|
|
471
|
+
const header = json(h);
|
|
472
|
+
if (header.alg !== "RS256" || typeof header.kid !== "string") throw refuse("unexpected algorithm");
|
|
473
|
+
const jwk = await keys(header.kid);
|
|
474
|
+
if (!jwk) throw refuse("unknown key");
|
|
475
|
+
let key: CryptoKey;
|
|
476
|
+
try {
|
|
477
|
+
key = await crypto.subtle.importKey("jwk", { kty: "RSA", n: jwk.n, e: jwk.e }, { name: "RSASSA-PKCS1-v1_5", hash: "SHA-256" }, false, ["verify"]);
|
|
478
|
+
} catch {
|
|
479
|
+
throw new DoorbellError(502, "GitHub's key could not be read");
|
|
480
|
+
}
|
|
481
|
+
const valid = await crypto.subtle.verify("RSASSA-PKCS1-v1_5", key, decode(s), new TextEncoder().encode(\`\${h}.\${p}\`));
|
|
482
|
+
if (!valid) throw refuse("bad signature");
|
|
483
|
+
const c = json(p);
|
|
484
|
+
const num = (k: string) => (typeof c[k] === "number" ? (c[k] as number) : Number.NaN);
|
|
485
|
+
if (c.iss !== ISSUER) throw refuse("wrong issuer");
|
|
486
|
+
if (typeof c.aud !== "string" || c.aud !== origin) throw refuse("wrong audience");
|
|
487
|
+
if (typeof c.repository_owner_id !== "string" || c.repository_owner_id !== ownerId) throw refuse("wrong owner");
|
|
488
|
+
if (c.runner_environment !== "github-hosted") throw refuse("not a GitHub-hosted runner");
|
|
489
|
+
if (c.ref_type !== "tag" || typeof c.ref !== "string" || !c.ref.startsWith("refs/tags/v")) throw refuse("not a version tag");
|
|
490
|
+
if (c.event_name !== "push" && c.event_name !== "workflow_dispatch") throw refuse("unexpected event");
|
|
491
|
+
const [exp, nbf, iat] = [num("exp"), num("nbf"), num("iat")];
|
|
492
|
+
if (!(exp >= now - SKEW) || !(nbf <= now + SKEW) || !(iat <= now + SKEW) || !(exp - iat <= 3600)) throw refuse("token time is off");
|
|
493
|
+
return c;
|
|
494
|
+
}
|
|
495
|
+
`;var YT=`import { DoorbellError, type KeySource, jwksSource, verifyOidc } from "./jwt";
|
|
496
|
+
|
|
497
|
+
export type Env = { APP_ID: string; INSTALLATION_ID: string; HUB: string; HUB_ID: string; OWNER_ID: string; INTERVAL?: string; APP_KEY: string };
|
|
498
|
+
|
|
499
|
+
const API = "https://api.github.com";
|
|
500
|
+
const b64url = (data: Uint8Array | string) =>
|
|
501
|
+
btoa(typeof data === "string" ? data : String.fromCharCode(...data)).replace(/\\+/g, "-").replace(/\\//g, "_").replace(/=+$/, "");
|
|
502
|
+
|
|
503
|
+
async function appJwt(env: Env, now: number): Promise<string> {
|
|
504
|
+
const der = Uint8Array.from(atob(env.APP_KEY.replace(/-----[A-Z ]+-----/g, "").replace(/\\s+/g, "")), (c) => c.charCodeAt(0));
|
|
505
|
+
const key = await crypto.subtle.importKey("pkcs8", der, { name: "RSASSA-PKCS1-v1_5", hash: "SHA-256" }, false, ["sign"]);
|
|
506
|
+
const input = \`\${b64url(JSON.stringify({ alg: "RS256", typ: "JWT" }))}.\${b64url(JSON.stringify({ iat: now - 60, exp: now + 540, iss: env.APP_ID }))}\`;
|
|
507
|
+
const sig = new Uint8Array(await crypto.subtle.sign("RSASSA-PKCS1-v1_5", key, new TextEncoder().encode(input)));
|
|
508
|
+
return \`\${input}.\${b64url(sig)}\`;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
async function github(fetchImpl: typeof fetch, method: string, path: string, auth: string, body?: unknown): Promise<Response> {
|
|
512
|
+
const res = await fetchImpl(\`\${API}\${path}\`, {
|
|
513
|
+
method,
|
|
514
|
+
headers: {
|
|
515
|
+
authorization: \`Bearer \${auth}\`,
|
|
516
|
+
accept: "application/vnd.github+json",
|
|
517
|
+
"x-github-api-version": "2022-11-28",
|
|
518
|
+
"user-agent": "tapster-doorbell",
|
|
519
|
+
...(body ? { "content-type": "application/json" } : {}),
|
|
520
|
+
},
|
|
521
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
522
|
+
}).catch(() => null);
|
|
523
|
+
if (!res) throw new DoorbellError(502, \`\${method} \${path.split("/").slice(0, 3).join("/")} failed\`);
|
|
524
|
+
return res;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
export async function dispatch(env: Env, fetchImpl: typeof fetch, now: number, opts: { tick?: boolean } = {}): Promise<"dispatched" | "skipped"> {
|
|
528
|
+
const jwt = await appJwt(env, now);
|
|
529
|
+
const minted = await github(fetchImpl, "POST", \`/app/installations/\${env.INSTALLATION_ID}/access_tokens\`, jwt, { repository_ids: [Number(env.HUB_ID)], permissions: { actions: "write" } });
|
|
530
|
+
if (!minted.ok) throw new DoorbellError(502, \`GitHub refused a token (\${minted.status})\`);
|
|
531
|
+
const { token } = (await minted.json()) as { token: string };
|
|
532
|
+
const flow = \`/repos/\${env.HUB}/actions/workflows/tapster.yml\`;
|
|
533
|
+
try {
|
|
534
|
+
const wf = await github(fetchImpl, "GET", flow, token);
|
|
535
|
+
if (!wf.ok) throw new DoorbellError(502, \`GitHub did not show the hub workflow (\${wf.status})\`);
|
|
536
|
+
const { state } = (await wf.json()) as { state: string };
|
|
537
|
+
if (state === "disabled_inactivity") {
|
|
538
|
+
const on = await github(fetchImpl, "PUT", \`\${flow}/enable\`, token);
|
|
539
|
+
if (!on.ok) throw new DoorbellError(502, \`GitHub refused to turn the workflow back on (\${on.status})\`);
|
|
540
|
+
} else if (state !== "active") throw new DoorbellError(409, \`the hub workflow is \${state.replace(/_/g, " ")}\`);
|
|
541
|
+
if (opts.tick) {
|
|
542
|
+
const runs = await github(fetchImpl, "GET", \`\${flow}/runs?per_page=1\`, token);
|
|
543
|
+
if (!runs.ok) throw new DoorbellError(502, \`GitHub did not list the runs (\${runs.status})\`);
|
|
544
|
+
const last = ((await runs.json()) as { workflow_runs: { created_at: string }[] }).workflow_runs[0];
|
|
545
|
+
const interval = Number(env.INTERVAL ?? "10") * 60;
|
|
546
|
+
if (last && now - Date.parse(last.created_at) / 1000 < interval - 30) return "skipped";
|
|
547
|
+
}
|
|
548
|
+
const res = await github(fetchImpl, "POST", \`\${flow}/dispatches\`, token, { ref: "main" });
|
|
549
|
+
if (!res.ok) throw new DoorbellError(502, \`GitHub refused the dispatch (\${res.status})\`);
|
|
550
|
+
return "dispatched";
|
|
551
|
+
} finally {
|
|
552
|
+
await github(fetchImpl, "DELETE", "/installation/token", token).catch(() => null);
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
const clean = (v: unknown) => String(v).replace(/[^\\x20-\\x7e]/g, "").slice(0, 200);
|
|
557
|
+
|
|
558
|
+
export async function handle(request: Request, env: Env, fetchImpl: typeof fetch, now: number, log: (line: string) => void, keys?: KeySource): Promise<Response> {
|
|
559
|
+
if (request.method !== "POST") return new Response(null, { status: 405, headers: { allow: "POST" } });
|
|
560
|
+
const auth = request.headers.get("authorization") ?? "";
|
|
561
|
+
const token = auth.startsWith("Bearer ") ? auth.slice(7).trim() : "";
|
|
562
|
+
let claims: Record<string, unknown>;
|
|
563
|
+
try {
|
|
564
|
+
claims = await verifyOidc(token, new URL(request.url).origin, env.OWNER_ID, keys ?? jwksSource(fetchImpl, () => now), now);
|
|
565
|
+
} catch (e) {
|
|
566
|
+
const status = e instanceof DoorbellError ? e.status : 401;
|
|
567
|
+
log(\`refused: \${e instanceof DoorbellError ? e.reason : "unexpected error"} -> \${status}\`);
|
|
568
|
+
return new Response(null, { status });
|
|
569
|
+
}
|
|
570
|
+
const who = \`\${clean(claims.repository)} \${clean(claims.ref)}\`;
|
|
571
|
+
try {
|
|
572
|
+
await dispatch(env, fetchImpl, now);
|
|
573
|
+
} catch (e) {
|
|
574
|
+
log(\`rang: \${who} -> 502 (\${e instanceof DoorbellError ? e.reason : "unexpected error"})\`);
|
|
575
|
+
return new Response(null, { status: 502 });
|
|
576
|
+
}
|
|
577
|
+
log(\`rang: \${who} -> 202\`);
|
|
578
|
+
return new Response(null, { status: 202 });
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
const boundFetch = ((input, init) => fetch(input, init)) as typeof fetch;
|
|
582
|
+
let keys: KeySource | null = null;
|
|
583
|
+
|
|
584
|
+
export async function tick(env: Env, fetchImpl: typeof fetch, now: number, log: (line: string) => void): Promise<void> {
|
|
585
|
+
try {
|
|
586
|
+
log(\`tick: \${await dispatch(env, fetchImpl, now, { tick: true })}\`);
|
|
587
|
+
} catch (e) {
|
|
588
|
+
log(\`tick: failed (\${e instanceof DoorbellError ? e.reason : "unexpected error"})\`);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
export default {
|
|
593
|
+
fetch(request: Request, env: Env): Promise<Response> {
|
|
594
|
+
keys ??= jwksSource(boundFetch, () => Math.floor(Date.now() / 1000));
|
|
595
|
+
return handle(request, env, boundFetch, Math.floor(Date.now() / 1000), (line) => console.log(line), keys);
|
|
596
|
+
},
|
|
597
|
+
scheduled(_event: unknown, env: Env, ctx: { waitUntil(p: Promise<unknown>): void }): void {
|
|
598
|
+
ctx.waitUntil(tick(env, boundFetch, Math.floor(Date.now() / 1000), (line) => console.log(line)));
|
|
599
|
+
},
|
|
600
|
+
};
|
|
601
|
+
`;import{randomBytes as eE}from"crypto";var fn="data:image/webp;base64,UklGRowIAABXRUJQVlA4WAoAAAAQAAAAXwAAXwAAQUxQSPUAAAARd6C2kaQ2+x7vCYnIICICUE9IY/s3w78ZkGLbVh2dZmbmVpD6MjIiCTEQCX+UMflABQ1TlBDm5F0TH6r+FtAV0f8JUPhr6ctZgp16el3x80tL/O0qVsEZsHMdw1sZ8m8jampQP6Jm2LuQ0wWnuRaoGngvMCX5kjxDb0ifrEdpwirq1LE6azmDb7VpBwNaakTLzGjlBa25ov05Wsf+PexonRXtb0FrzmjlES0zoKXatIMcbevUsTprmrCK0ifrUfJYG5KmJF+SqqS9wOmC01wLqMa5U/iU4ivSWzH+NqJUcITOteLml8m9XSn+a+nLJdGpp9cVDgBWUDggcAcAAJAgAJ0BKmAAYAA+UR6NRKOhoRY9tXQ4BQS1AzgGCB/ee/5/8jPwz+bO5P5nkZD2ds843bX+Yj9kf2Z93z0U+gB0iPoAdKF+7v7Ye2RWO+UP077gbq9qQdr/7Thr+EWT3fpuZ8LGkp0APFRz2/VPsD/rf1s/SAQZ5oTHtl5+vGqupge+ws2FsPRaD62UdfItG+n1jDbxzytDaxkYsfS4x8lyBJig6aGlb22hCpshcpjipYUza1imkCH7/l2ZjIFhBOTUiHjNyQuxrYQXfSzMNW1qzW+dlsu1I6MDyqqn7zU4iamwVEUEZv5FyU7p6Vd3Pt5gooS7O2sYSecahovpLIhR64hfvZcljfG+tM8AAP70trGbK//s2rvZwfoB//09wZcz+Cfcx4XrAXrpQJ6C6jE5BgpOcnxZ94NNLPUOQ4HzkpZyLh3++badZ9IidhzLX4r2n8RmqVxYLMZCsUfCsBh4gaG52xAAJ4KN2H4DdWmH2DbIYA3oQzXK9Osexvr9qYEMv8qPWnBnq8nAuaL7WKQ187LR/6cONyjd9mVdTUP16wap5lgEINV1rSgcICC0OkPfqub61tJlCjn8uh0cXVNKOSx8W9AeuB9dFZSMBJa++eYv+YTIYyGHTpI04pjOpIDq3AOqPYESwBhWE9A42ImX8x6VtXYVOmwv8lW41Vgj09tdrrcZW1DZvWWGvOoIuk/rgKYrNbIx3qS48b+WBGqI50gCeoBcvIxNGUXBgfHz5rvFiKgBBT9jJzd8QC104TXXDX3YslDeVhutM/CEVJ7qO9mLcA0YwRhtkjMiOen7bo9hTRao1/KGhCsS/e4tYJMdRJjNYKsZ+Kp540o7pJM7zIhx5E+BN2oZjElAPt8O6koCFZsFT8W+Y2SvoBneW9Vk9O/6mQz4bmauo8KWSyQNUCGAIWMsE7iWA+kt4RsWAl+gw0V+01q5W5TI4PA2Kx8juMUKTsPInerJyWvSZcNxVLwG3+5dbicBchRRlYSKukU2Jp4ZVDe7I2fnLJ+UIOEomr9p+CBlPQARIxKHmaXm5V9a0+m7Cw/kpNojQus6JnAg86e/ianKAk5BhIisTy0pyIjUrBya7MJDsZH/v/DaPm7QFNK9hgzybPRJEY6KuL7bwQHVQ0jcboqu/tQvI+mhsDNz2K2tNCNOcMCA8HWf+pwu0GaQgSajBefemZ6reFjnoc1LBgmrFHFyyflxua7ool5jW9/r9hjxKVxHxs3o3F5Kc+vV/mdHDj50DHL+9duz30i+Jf82JCXGMbp7+FjGKhzcGyarYjXbiPFFl1Be4iW8OEVyWe7H241eXMl/qp5y5Q8B2dBYymhibQNm5UPgyzuM155RLLPrnrnc3xSPFbqv9fl7j5bSrdzwBZ8DjnI0dcr5UDCNGGZkglw5FB2rgioiB7jYrrnPfGrfuvrsAH0GodU+o0erjag24oZX6Sam8/LPLY8EiCVWAQMG6r5sTCO/idTDXTuMcAkBgzVgphSyUmDTduYey7e2NtCgoWS5wdflZstX4FceW4AVoWWuAOU+xs1jI9C7yCqQ+IMHeJjmB1qFaBGy4z14f5Y7tK6u57xfo7bCBu61laMUi+5mBj4Ba3kuu6YrskddXtCDx9z9cvgNTjJDgKdfDk/df4MCI49ZGVmOeTQ0Z9tt09gfxHuqiGCGmKYZzmeaA7dy2dHc8VbIAbfp0JKwq3RDugIs0J6AdPhFmM84ci3/NV0xDACfDfZcd8t3is54tH+5YGhIGswMHwYGo8VAHM8p+ORY7zU0zJdhF1/y8xEsp/hNm7ukLLZZN9qKY7OAX9uQCc0Ww0j8lEJMgBsUlMy8r7gBif1ipeFRE//+P9zTMtS9Qonr/60Dp8R3/quzj4Jslgk92itTQdNH3iPVCLA2aJT1L8cKf3ft1LyBsKJI4RPDrV9i5v+Ym9+CltyZq3JKlFVgAfrb3dawijRMdvj1x1y73VR6gzLFjyVv/sOtb6b+6K2JGHmnVIRmaw51s8qg9s1KxNdYetYQfGuG/0+M4ZqdGRzuDFTnoNmUz2QPjkXnF3cyguivLl3y+Lm+BmR5j1Ya1Uj0govN2frgHKjQjvWj5wwZFPFbyruAplSrHUAJQNqXZK6RQSpUOSi6JOGoXak2pTlPbQWayU3Ktn4HKXn0jW/HJxX7y9aHwuukGIVKGOzEVBTiB5HQ4hxfL+DZsNeViPXYmYJcQwZc01C/kXkVBxWpOy9Trs66Tr6k5aHmVSdHO8adOlCg2wEgbzREaX+7VfDTl0nI2YIN8w6KkwupCrkbBsPrWtkCYBeuEGFmKeZnf7KhveiRPinbtnmNAPcln00zDbiLs2Lbe6G0BMvfZIoORkHFoAzgqMYpHtMB1Vwrm+QYFcoOcQumhppN8dnidf78TWLer4Zf9DfMfVIyuMon+1lbhH5hDoSNQ/ChJH4bArnAZL9ODY8B/r4neoNTwEuZHNzVoqV/hRvSZYzs9bvRFMFdllnZXDFpCFvyJ8jdJ1PspW7B9XIilKsDMBmPs0BL3rPoQErXAAAA",co="data:image/webp;base64,UklGRqQeAABXRUJQVlA4WAoAAAAQAAAAZwEAZwEAQUxQSJgDAAARCjqybbuNqweiGkj0jbyUOvIbuQgxC1GnzGRYmAFTRsiRcQCs4jQ4gs45CPkYKateQAfzIJxvcd69ETEBdGN4ezzN8vV297Hc256opey4zrPp+HZofgxvvcg2X2zPpcqLW912O12VvjfrKpVuGk2W323vVuGoY4LfC9vbC2F3PFjYnq/SCUGytQBkErjualZaEOqMLosyC0WJXBW+tXB8K05K9xaQmrrnyY0HJZ+4Jc4tMDV2SGLBmbgiKiw8i8gJk9ICVOmAuQXpvG3xxsJU41Y9/miBKmzRGw9Wtubaw5UtyTxgpRULD1ltwdKDVhonHrbSMPXA1UZlHrrSoGsPXjbmjYcvG/LYA5iNiD8iSOImbCyEtQFzC+J5bRMLY9YUlTjSqJ7CArmoJbFQTmqILZjj6nI0aWVPPJxZ1Q2eWFHqAa2VhHtEqVTx1kL6bQWRBXV0WYYquejKw5qXzHClFwQlrpTnJRbYyXlbZPGsBx7acs4CW3pG4MHNU7+jS04V6CpOjCy8R8cm+OKxJb7k2Hd86ZHbHuBykCJMD1YI04MSYUryloe4kC8wRsMMY0JuMKbkF4zRhB7kchtlMkaZTlE2zVAmOcp0jbL1FmXcoWz3EWVSokz3KFM/+H/w/+D/wf+D/wf/D/4f/D/4f/D/4P/B/4P/B/8P/h/8P/j/vz8VZVqiTAVlskPZjijjGmXrHGWaoUymKJuOUaa3USYhysR8wRgNNxhTMsOYkC8wRsNbGBOSJcKUJFcI04MUYXpwG2FywO/4Uh5d4kuOTfDFYyN8jY6xQFfBk7+jS04F6OIpLrClPPMBtuQcbpFFc3aCrOS8oMSV8jzOcKW88ApXvIQZqoQXR6iKLuNbTL1lheEeUSpVMEWUstobPNFU/ARPrIo5mpSVx2iKq2OCpYR1FkgqWGtU4kijejjBEU3dcxTNWf8GQ8oGxh8RJHET+BhBNM18gx+apl6jh6a5GXaETV4gR9nsJW6ETRfUCJuvmFG2MUOMsJ3XeKFp6xu00LT38UekCE2b4w1ONGbL5yiZs/2TEiFK48KowEcR0ZEJOhK6M86RoTGd+uQGFXxinJvuEaEpXRy+xcNboaOjDAsS0eFXsxIFOqNxfJBsEcAkMF34YNH3VNiZwe9FfyuEpltHk+X3/qXCkenk2+mq7E+6SoWdfutFtvnSd6jy4pb5MQxvj6dZvt7uPpb7vqCl7LjOs+n4dmjcCFZQOCDmGgAAcJcAnQEqaAFoAT5tNpdIpCMiJCSTCSiADYllbvGALXqNzACijUqXk0Wm07e87qnWF6f+984PYvmk9K+b//r+rP9QewR+svT38zfnJf8D9pPfJ/efUW/uP/A61L0C/259PP2bv7Z/3PSV1QExq6YwCPafC5D75RP1Yx6HiO+79g+wl0uRn7uwevJYFxyd1XE1Edf/cXmY5/8ym/s587lniL9JNao71PqB5+xWOr/uWkKE+nwMaqRAi7A0ipKx5/+u2Hm94uGHewwoqtCl0y05kqKuh83e7SfxJbG0Aj/Wy7LpU++ISqGq4Do0GbhDXrBmB85VuaoIiAP1xOB3XymwbUtosSjGUIBbz9zuHaLckWg3/bi+f9df6XMS16utmeYrmibH/G01byjmU6uYJOKo2ibNUDw5lbSFjYNXmZrdpchl4MVzaapq4/8Aa65QcN/S12ZpsHAQZFy9IvroCMnlngOHbk/2xf3IqwNxAB3JJhybP8SxKWzK4oYeoR8HPZnFv85VWoRdnFoAd1VELS2Uz/sF+MyS+XWWqagqRmDTMj8knJ5kVayI43AYXdS2UVfc5bcmYM454t7d9GX/B4tUtAKq8YSgjhp/1wTaUSlufJssPKqJkle6MTpbsbP6ADWsxN0VHpk6mhBsDFoLTzfZaR5cx4TNMzUDrM9BIbfwWYgHfwXvyp+laVH8Af2JQQXSfM0GZi53BDDwRRcLHZVJ7eMbygvSEWE2sMwon162McjwZ5wHCajEFotQGwigvo+3s7rOhKCFimFUvAZkzJHrUbrnkYXBEaxPtsE+ASgr2oNVJkDSkroX7zNrPeIPgPNnKfs2kDE8qRY++QoEc0Uhqe7hYXpT4SiLkuzIj5d4WTGaAQ0nkn0GuE1TV84efp2GHE8vjisdShkoYq/0U+S1Kk08ACZssJSN7Of/50d0R9AfuVQSef+33m4Ggr/jNhD4Jq+N2RYtYW8lFWLYZhxGdwB+uCoREi7HpgZB51XX3Teg1QcPU5hBl6XkmYQbFP62076Wgw/vUvWx35HxVkXd17dPFIytFirK7p7J+b+4//9FPp5hvlifDzunBXZV6UxFVnGySwZTAnWf6YjLzzCD0TeWAhKmHIjfj/45O/uCJ05Rp9Ow9JUzXX4clTMVLf0kTC1EN5BWljFNkrXBiFyMsEtcEa1BFIit57H7zNONlSaHKB7zbc05sq8s7qSZ2LU1ayQfw/LHEq+NgVG7UEvKtJ5i4QhBlRrFWFC2KA+bfgOVReky7NYoEHgQMS33+noHkwXN38QCQUMYuwALRfsZjSKSl4SDhQ2KbQKBVLtzP64UAeqV3/N3O32i2afo5124BGF73Wc4ZFDz/kWllmg5bNgdVK6RcRKY/BcYHruFe8oq5E9Q0oGqcbcQkLE45PqaHhUAD+shNP/pwFo3HcEwxwzY6FGD1EbFcGTryelZTiIMB3iKfN0oBt4D3WgOaWGXxTYh3H3B1svg3BvHEbpcI7q4mZKX+F5lI5dm4nlM2RyXN33s1yriZiX6fXmOlwio9Lk8M2WT1JufZW2pfSSNIH8Idf1Qssd07F57ZR0Kie3JL84fZ0sTByIIPeKFf1Rg9RG0XPF+CqSZ+vJWsN/VGDT4urQA/u244/8Uj99f5OJR//m9/+WX9zeOEa228N0vEHIkUYZkO5PJm3LqbXtSkDp1LloVr821s3WOuX3voNznIz6pyRXgvbAVCQgC72kaMYHB1AMMlJ14VTDI+sW/uc7TmLba9sZTWI0YjqQg9Gk87qQ7c+9mMi9G645ag1md/EUDuiPQvLdprf0NgjCFtrT4XTn9LPQZEgftBILDARKHFHhHR93d3/5WxNAP3WLcrPQgGWoG7HWC+b426FhKlFESSokD+JQnAwxe83twiAmyR1KGzbDtCMmXJ5ou4FPHKE3dyfVicNPjvmfSYE1RY8lbDtPOwXwR3H/vEz4qGZEJseRlSs6KFoaYXqunYQ3/0fl6D2bVgm1V9Ivg/U0FqvKC4DyDNfg4FjUQqniJxcHXP6T3HbDi+mfLLs4BmE26EMVmDt8+0ifq1fki0v+gx6kBrIONSniKvLZq2Hee+9zHCXLxzpX74+G6oPgOVBzadQFk8vq9YYkGiWBRrBcAx8+n8TQEM7UTZhXxbiR7b3YPMadt/NHRRRDucAm0X2rPL6BHrg96eG8uzdSAyv4Edpt5LOGC8Uf2/nb6wtFuuJ61j6EXv5cF+p2wMxxzkjGHvkXq0wXHRouJFW/J8Cay2b4OwZAHLcohBRifhKW9l6S4WpkSAh4sv2pdGAv2uH4jZ+j658zNHNH7WQvPbvoFjt1H7eBRvSk5CgIzhn/HFH0bXKBZps1UYrRwtDwLAknGRbiuyNxM6azWXZtTfnhGhFlymgwPNDkfZZhRpA28zoBtVmMmvbjicAQtqXGRHpd6ByNZCuWhccLG8fvggZv+Go3MF85oEjI122B6cJ6A4jmG1Nzildm8XvV/c4r6XPQIFgw3QcJQrWRm3yGk29sdvb5zM8dlOFzl0w2ang1qFSG7AbZF+dmerMNDphPBSXoK68D4WtFMJQUuXIk3W5zj/cc/e8OKT6cg0JsQYD5+YlKdOUYPZJS+UjV3UMZhbUwAFJ3Y5zlXE+mqL4Qd0WuzZPROUGytTFgiCA8f61BCYiJWFQirIiKd9kznI3If2Gw682KJfAMPrYYBklLX81Rzwmt9CnaG8f9QLQW+cfE56LYRKfR4fVKxHkPfDXGBEOOUCII7SSnKeqpYlODK2csgjCdiWwkTr1Or4XSFuAW02fS3fct3MCi685wSGCjhDbgythwxZAvsXMKq93fAA3sR6g1w+Xft841GjLX0UDFVJ1uhBTYcjRGENIO8mKM5zhqbD5zrTcF1JDrVOsDgE0zHZKMlumzFynx4jbyZF7dIzZreVgIv8vDQWnBpSK2FcT5yG2Yp/p2U4RMrbG4nE5ZlVHvP2KGl12KisXVe1OOGB/dr37hxCre2iopacuE9d2iLQmU9EQ+BDuD0mWDm3xIfG3uVJAq1GDt/lqx4ei/JA02jlhS75a41lV56Yg/PjdoROL2XfS+TOY8Q9A4D8WG73oiLy5smCLhEzvCjDE4a/eTgbWj5CP/nCSgvZq+N/+8mAzl8NFdbzt3VO6jd2fAZ5F+tncPlmk04NWevzzKI5fbyyrPe67d7Cgv+Pr/dlgIIlacBLzcE/2BCes8lGxnof7j6xkeXHXTUs+YKRlJGq1etQ9e5USMv/eHDCBJAbVQ/PUUyS/e+2Hm6aOdm44YlHxtBUmlf89JauKNYcDSW1HT7SmtTV0D2PIEFR/0CMA8DWK8IxfvQPqNcr/i9/cn8RNekoRp+YDgZlhhwCKuYnv11E+7R/C2xgeOwhUwX+X5DXb3fg20z9OGgwXR4I0iC9NbOmwXeIBqCur/evL9bqrycvEqaS22mTqxg4mWYyJNdU3d5ZolwseCB/9iCLmHAwn/q1+qMDlWrsT5TwLjYmQsjqeWzXZ59OShVaHrJV5CDLyeAkBChkwYAW6YzGn2Ca5tTJh9Q8Ez1U/F1iyGxe7z6xm/CN3jP/Vb+NTO7KYXo1KWyFz6A7pCWj1XeG3XDe+w+6gWBye7U3jjAVAlE91goZ4MdkT21XR45+bWjFvozNmoU8pUm/u48M3IQubdYnoCgNaOhWYPuF5e5iOJMTT0pXFpU05y1JRTm8FtyH6opFNCA34+jl/X67jxkGPiOYf41F70Wi5B5Af3mf6/0GMVqCLtX96qnPe+4R5tP2buUz8jtJLxs36oTazYPSSrC+z7jHwQ0Ek3/TNkPeN53TgdfKzn2PsGQqwjWLjQwNY79FtmjzpfiV3+mMWlc9o5Vyj6qbxcg7pQP3u40jaB7iOf6EzB7e7ehIfnhzBUcbwIdej0Quek5/MnT5sRLA72Opd3HliZLljRmc2EFo/o8W4coXVaYSh1L9JDGEafGJ2MKGywwln2RMfKEZmorTeZzq/AA64leofH2knVdnrIlVyhdL4sgZR7CweKekREo1dHiL/efhmxrmT97J3MjfTHbjAa3+mr2QnYGb0/N8YGbe55csrr/ZTZkwQ0n10nfGYPOkEZAEAyHvYz+V0I46bq1TWWddBhq/MJLU/Exl/14oPvdjI28QuZyiuPn6Bteyzm8UkKhETz9mefl32jM1EsGgT2Njk0Lc+2ItNs39EoaQdh42VAaaHzy6AI0Fg9EAXwXmQwTdBDwC1Vy+k5oyFZUWMPVmBuLqFGlZCK8cYVGUp3hq9wNo9dMgbYWorC7iPMB2+eYNQ+NTSkkZZ4Dr2tE7TbEViNggxc4fkIiRKd/6prcQ+ycE3l9kJgufJ1dlQ4ahhFQzl6NYTk4BGpxTecseDaNqH1U/gsUhkSJZq4M5Az44Qy6YsZ6BWuFvoo5jtsfQNUvFsfUsOqGC72EGlvPvYiJ9W7/EGA2xeisch5LZn+6Qjdk6o1aX6ttNmzX+5aHY/vL52PWdpegrm+bXnnxrhtp5KqY4H7jQbfWKO+aClmbTE/8iL2zU61pEd9jFXk8icHRB4OZO5TvWhj1MgoORytZKT2ZrmA61Qw5jRYK3iYqeOeMkHQz/F7JzSbj2QeJV/uvPhBkjh5C/sfA++4UN3AUdxtS3eaN7CgY2jV2KpH65KvhiveXkkiG7SoqdDSlHNnKK/3HoNtGp1YwboQ8W1z0DOhkwNebHh7RGfwsGqpmnyNPZg4K1chsEdW51VpU6txPpxrjRTYMaYM0ejNofpIUB7Cr7kk9KO5/DZBMn3E6I3HonL4SC/gSNEhovtxZ46qHOVme5z0p87Xnlsp9L45FCBz/AJCTEJ2RytoHRXtmxrRpPBrB2Nawg9ceRE4/cqmMj0MYMxYDWlq/U7hdb6tq4AfEhOLtwLaVEM8h+6qMtz9JGb9FLruC+dX1rftXshZUvNec6hq6iDdPzgAAH3YmgUw9B34eZiHClFQm9OJtp8IQaKaGfV+HFFNYZc7nNTyC4LVMqNCa7PvGy3VbYjWPtNIhsAo1aZkFi4e+aa56UcC4XTW+usgxo31BJs8pTD3FCa3s2un+IG06/AJunrXYeMmEo8wm5L4X8agp49iigav2YGB/FAzmAjgWPxa16KXUx7i0Efc1GFrLJ8eK0ZPzMGRvbfssmOwjh36198MD7ZZZDjSBtB4uV+knbkL4BEsu28RBYxZczPv45c6lwJnhemk3PpYgr5IucEh38P8ILuEHpsKfqhSDeUM/87Ld1xHwzsJDjRxZHJ2OQWRnfKU7w7e3Tp3cvL7hIN0SX1OFZjrRKzUAvVXXq//qq8TXWfubhw+fDR5sxqtanbdut3qmnp7lIy2OGCfS40IJbXZySjLkQFMG87oI5Fhs6UpBPPgg3GyWPQ2/qbqwTi9D5X1uAU4uEwoIUm6ULMrj9FXotlq2Vm7LRABY7WFkcgtV5eOh2tTDy1C7UJBQNoPb9L8hQfYpZoh41Rmebqym3p1GiuofIPmcacqWdq3kiyvQBkMTD6QSYEJAEat0kne6w+1etUlrhUwhPoiUNroG4Blfdc6jpoohobETPZPMj0+morn8BC/reVLacxr902N/eGVQTkknBCMJWwgpnSwk78qkCyWAD10fO+pI8NulWb0QG5TZZfx97pkRhELPV87Kp0E/Uzjon8iK6Hy4F33SGNd9dCLvNrYQ/LV7tzb7H7y0wEBnVHfP98ecnLXWih5dGvuns3OaqHAs4OyWQx1zS+9ZMxni7lAD/hK7GDOmemySF2orKWmmwE1aGEt7DD+Fws/1IkgdG8XYt1fz3S6MgTf4yRFZvCHNfNHlmdyha8hypZT1+76zwc8kPtdUNGZHuwvJ2+mBxtWvfU7z857mcn52CpQUwCSJeA4a1DOYtq0W2/YktKZozrAA+ZWhte76U4J8LkN3ZhB4ZK2YoxHlgO6DPOfTClsaE42hM+GkHC6CsEEuABCs68aNilKdsM048xuEh2AuX/+LWehsL3DnKJfPjqcsod2cdEQPCArWS/UX/3OXgwANBi9smGJAqlSAqxFaLYgfmPdUsYR6G4IWWabfX/1PlVyYowyl+2Zit9s8pUGKnwVvo0x4GTBB6fohn1PO4U3NqK5r3ORCi0Iml3w7JCOlbdwazGHC9BP6uHJA2EHSLCUVS2vtRfuyMFF3Y2Td0EN0xQ3HBLGtJfQDJ4OEyBW3DxRe+jWFz/FgOyoyMegiRh+IV02bptyTgprfj8TASylp87G1nIVzqrLqZTYCxZHNPa0fTFss9L0CaCO35GPvV53HaeUZplvwOQZ9MRs80miIxlc2NHU1TWlWGKfqpbUpldSnVvcKaV6EAqBmvCpIb88NFbKclbeWZkrVSTwAfsG0zzpV1Xfy/6lmRrT4aBmhIEJPnFJMB2dQdZ571m3pvqloVClhUo0+RyntJuGkTWgEmMcrZCI7PtsTxXli9xzAa4OJIDXPmuJKqd2PoyZ9du86z/MbcKUm9F/JOWmO54zs9SNxBPK5uzVbn3Z7BSsPZOnbEb38+j/tRLCe0K9tpgEuLxNtZICCjQvCw0/GWL8wGV1p0UdEFyMV+FISXlG4HzxZxD14IxdncU0tOx7CXHLmYtEHWqyDARYMS5oQ5zAc0QCbXQjQcYSizHmm04qUmPHE//1Ine9gS9OnrMpGBJ/TSgsm6p6rmqlrIr1Qldu5xCBoKVoUWdZu1nSZ2dFp86oyQIQ9cCjr+JSl3jyySxD2k6pr01tkkibk1uxdkKQC3c3tgP2pUDy2lZknkYnBQRtN3RJqR0OqLQHk8b16I0eJhetI54O+utB0/03zpCk1T1LGf4XZe7LVVSUbhzX+UgfSGAss0FhNuTRp5nCpExulVswcCBTi5wDz3UGKMy1deBXoB95ZGIuXNb+x3RDLoJXIaZJ+1SbThtN56kmr0MjIKzncpZRPJ0vhFkhDqRgI7w/7WnPOxa3TQZzdUsTnllf80c/A2xdfWiYwI6v110fl4RrC/P1HFRFTOnKmSzdh+4ig3sUo7Hn9qwtjtoJajNFMyWdxtnbtLp4nolH+GKWHv7Ebi0Sxj4rqyhazDfrmVaUScvHvVCyF6+ftjzV5EElFMWUV+lQ0ixeP/R/n6Cl5MJ7uh2vciXOki+0Fc4Jt/HkrvWety06soCdg67yRyPJtGGk5PT0umfsf6KLCsA6xzNl6Uaygy+odr1tN/+zUkpsH+5gqHt5TI615FTmn/DBP+WJK/3Noy/uS9adMghMSy2maPG1xxEioYZkUgihi6aw+aDS65m4gU/gu+PPn15LbXcPOjmw2V2IghGeP2Z26/A0fnFlkj9WnAPD0LOL+iQNi4KlHSUYM7X8TpKMvBa159loQ2mQKk/1oIPfYcO5dWxwP6w38MHtv9Q6FrW/fzXgIOZGM+1ctu6QiS1GDevnwDiBPpNTfjQ5l3tt4WDxbJ1hyLW4/EXX6vVy+g4bhXqjVpk70k+5opGyzXg9nu3nClgScIhd1Q3SKwhYYSuIhpIsOXh3Z7OE7vV5+satxmDxLtAPUZ/t0LykWGojE9rAKMZEruBqjDHLl4l7z2ZEbBokv3tlwt1q/XP79NQpUpYsrhr3xIJvskZ4yz0olaJ9ABtKf+9LmuWKQ2iccN4LDMYLobykpVZfxXgJvbMfmzJosZ+wvKFQK4zlJAroQ8hywt4raFsCxrDK1lg046X8nUYiPO4k3rm4j3wS4V7fjX+AJY/ErEsaHwyacTo/uYRrxPYsN6GvM9ZO4cJ70kAtjk6+AF+Ch4F0JQpdJ3RX0oMHevLPH0fvqN2zDpEJFh+JrnTIeokmdcSlWzmgffw6UoIbzMiCBr2NB5LTUICNFuUfqdGF+HqORK1zf+PWEhaS4H4c3lY2ciFZ6R6KnbZ69fW3q0+/ut9EnHuCqFjP+9NscRieJ6gLWsHjwc6plBdN8qGEvbzkHAYMA4at29GvTSICnRcfqEvR+dyt/CjRG39ZbweM/8bu+MNOJUpKqz1NXhbRKgI1i4LMqTC1M/JQGBX3BXkXzKJw9TI8QeZpRGmttYkjOGJcGp3dML13H0Yu7uIY9GvsVlsIuAUN4c9BAMtvPstmfKNwPVXdoQVoqQmmDcXtw+oiW45KpszAQRM0BMh8wJHPvK21zEIJvyNzeppRE5tJ+LjZ3uLmfX6bVIkuYhmXa/tW86wCCUW5jvpkkGCm6F/G5ToabUoAJ+RXjIUM0bi/dF7H4OVbtDLyXqbpAw8XhDJGarT5HCsjPVWJ5x3F6NR9RTkWL0rcBAxqDlqakYhnVWnlLMkhppDW8qdCr+soPebafKd+ZQir2TpGhiHa7wiBbQAXDxE/8APNjjwXRPu8uRtMAY8nnIrcAZHNNyqqeOdv7Py4e/Pq9Ga5gq2evXUaThB5q0lWdcNXJQlQ++gljAGLUXxx4KaDFreOMWC3KLJsjbd7j+QY2lh5NUlFMvHfas1dK7hP7fU60xomDs90k7WhzeUruFQC00lUfilioyygNyoT+yhQ1t6CMRNxqfk+XRNwbSRQOnyKiS8dTNoKwk20B4mq4s21X9vJWIfV8KEfRAMIwRyx5zAgsnTsoCn+jQkpD0Y/j22uGfwS7SjZAoRNOU8yv8sgezkZ49CgiAFcdWuBGSH9PCU5N6GON3RtfmnLJIwA4LnxviRGak9yMid04i5t0PVpVF5vBG0WiHQLdjCA9Ui5cDlG3mCc0U/WRdo4pE/eHGpp9V+LQMs89HVGleEYwRVXhR7jPaRiABl5x/f5yInJCz+pF+bRoKuKXbrgdaoprJX2v1QNlYJ5hjKDGTxZ7I71sQb3XbejtP7Uzc9dqwJlqVR1BCJ+OhD+yRRqKpIXyn+bnky2+JO1XRag7Uc9qqFsErYddHYrTQ2+MiXGnTDqWmdWpQ8pSvQvRMmiGqS8GdQBm+TzivYwbETUhImusk6zgz1qpLCgI3uhdx2L2BPfPQJJ4teknHLrRxG8xJk1+TuYEIE/tjjXlxPF1q191ghe4IeBMLXZbrQ5oyGQ8x3pi5FO3YGkSQ1Prr86aQf0gQycLBo+/hqnm0JRzCtkWiA7up0/pAZ/mkJQ8ktMVQJDfC79y1YfoTdkHb9o/FP5D6GilMHIBK/r+DFCk5STDhklv+4ebu1KaJ9VIdfM0cneqLIlQFoBVx1GrOXlDUlqS+lz9eGvIA4Pu711k6Dq8QAAAAA==";var Pe=(e)=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""");var JT=`
|
|
602
|
+
:root {
|
|
603
|
+
--page: #f6f5f3; --paper: #ffffff; --ink: #1c1b19; --muted: #6f6b64; --line: #e4e2de; --code: #f3f2ef;
|
|
604
|
+
--orange: #f2891f; --link: #b9560a; --wax: #c8392f; --navy: #26315f;
|
|
605
|
+
--button: #f2891f; --button-hover: #f79a3c; --button-fg: #1c1b19;
|
|
606
|
+
--see: #1f8a55; --see-bg: #e6f6ec; --wait: #8a5a0a; --wait-bg: #fdf4e3; --keys: #2f4bb0; --keys-bg: #edf1fd;
|
|
607
|
+
--warn: #b3261e; --warn-bg: #fdeeec; --note: #6f6b64; --note-bg: #f3f2ef;
|
|
608
|
+
--sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
|
609
|
+
--mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
|
|
610
|
+
color-scheme: light dark;
|
|
611
|
+
}
|
|
612
|
+
@media (prefers-color-scheme: dark) {
|
|
613
|
+
:root {
|
|
614
|
+
--page: #1c1b19; --paper: #252421; --ink: #faf9f7; --muted: #9c9890; --line: #3a3834; --code: #2d2b28;
|
|
615
|
+
--link: #ffb066; --navy: #8a9be6;
|
|
616
|
+
--see: #6fd3a0; --see-bg: #12301f; --wait: #f2b860; --wait-bg: #2e2412; --keys: #9db0ff; --keys-bg: #1d2340;
|
|
617
|
+
--warn: #ff8d84; --warn-bg: #3a1b18; --note: #9c9890; --note-bg: #2d2b28;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
* { box-sizing: border-box; }
|
|
621
|
+
html { -webkit-text-size-adjust: 100%; }
|
|
622
|
+
body { margin: 0; background: var(--page); color: var(--ink); font: 400 17px/1.6 var(--sans); -webkit-font-smoothing: antialiased; }
|
|
623
|
+
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 3px; }
|
|
624
|
+
a:hover { text-decoration-thickness: 2px; }
|
|
625
|
+
h1, h2, h3 { line-height: 1.15; letter-spacing: -0.02em; }
|
|
626
|
+
h1 { font-size: 2rem; font-weight: 750; margin: 0 0 1rem; }
|
|
627
|
+
h2 { font-size: 1.45rem; font-weight: 750; margin: 2.6rem 0 0.7rem; }
|
|
628
|
+
h3 { font-size: 1.12rem; font-weight: 700; margin: 1.9rem 0 0.4rem; }
|
|
629
|
+
p, ul, ol, dl, table { margin: 0 0 1rem; }
|
|
630
|
+
li { margin: 0.25rem 0; }
|
|
631
|
+
strong { font-weight: 700; }
|
|
632
|
+
code { font: 0.86em/1.5 var(--mono); background: var(--code); border: 1px solid var(--line); border-radius: 5px; padding: 0.06em 0.32em; overflow-wrap: anywhere; }
|
|
633
|
+
pre { background: var(--code); border: 1px solid var(--line); border-left: 3px solid var(--navy); border-radius: 4px; padding: 0.95rem 1.1rem; overflow-x: auto; margin: 0 0 1.2rem; }
|
|
634
|
+
pre code { background: none; border: 0; padding: 0; font-size: 0.85rem; }
|
|
635
|
+
table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
|
|
636
|
+
th, td { border-bottom: 1px solid var(--line); padding: 0.5rem 0.6rem; text-align: left; vertical-align: top; }
|
|
637
|
+
th { font-weight: 700; }
|
|
638
|
+
.callout { border-left: 3px solid var(--note); background: var(--note-bg); border-radius: 0 6px 6px 0; padding: 0.8rem 1.1rem; margin: 0 0 1.2rem; }
|
|
639
|
+
.callout > :last-child { margin-bottom: 0; }
|
|
640
|
+
.callout .label { display: block; font-weight: 700; font-size: 0.92rem; color: var(--note); margin-bottom: 0.25rem; }
|
|
641
|
+
.callout.see { border-color: var(--see); background: var(--see-bg); } .callout.see .label { color: var(--see); }
|
|
642
|
+
.callout.wait { border-color: var(--wait); background: var(--wait-bg); } .callout.wait .label { color: var(--wait); }
|
|
643
|
+
.callout.keys { border-color: var(--keys); background: var(--keys-bg); } .callout.keys .label { color: var(--keys); }
|
|
644
|
+
.callout.warn { border-color: var(--warn); background: var(--warn-bg); } .callout.warn .label { color: var(--warn); }
|
|
645
|
+
.callout pre { background: var(--paper); }
|
|
646
|
+
.button { display: inline-block; background: var(--button); color: var(--button-fg); font: 650 1rem/1.2 var(--sans); padding: 0.85rem 1.4rem; border: 0; border-radius: 999px; text-decoration: none; cursor: pointer; }
|
|
647
|
+
.button:hover { background: var(--button-hover); }
|
|
648
|
+
.button:focus-visible, a:focus-visible { outline: 3px solid color-mix(in srgb, var(--orange) 55%, transparent); outline-offset: 2px; }
|
|
649
|
+
.brand { display: inline-flex; align-items: center; gap: 0.6rem; font-weight: 700; font-size: 1.15rem; color: var(--ink); text-decoration: none; letter-spacing: -0.01em; }
|
|
650
|
+
.brand img { border-radius: 22%; }
|
|
651
|
+
`;function Lg(e,t,n,r=`<link rel="icon" href="${fn}">`){return`<!doctype html>
|
|
652
|
+
<html lang="en">
|
|
653
|
+
<head>
|
|
654
|
+
<meta charset="utf-8">
|
|
655
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
656
|
+
<title>${Pe(e)}</title>
|
|
657
|
+
${n?`<meta name="description" content="${Pe(n)}">
|
|
658
|
+
`:""}${r}
|
|
659
|
+
<style>${JT}${t}</style>
|
|
660
|
+
</head>`}var QT=`
|
|
661
|
+
body { padding: 7vh 16px 48px; }
|
|
662
|
+
.card { max-width: 580px; margin: 0 auto; background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 2rem 2rem 1.4rem; box-shadow: 0 1px 2px rgb(0 0 0 / 4%), 0 14px 36px rgb(20 20 30 / 7%); }
|
|
663
|
+
.card .brand { margin-bottom: 1.6rem; }
|
|
664
|
+
.status { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 1rem; }
|
|
665
|
+
.hero { display: block; width: 168px; height: 168px; margin: 0 0 1rem; border-radius: 22%; }
|
|
666
|
+
.status.fail { background: var(--warn-bg); color: var(--warn); }
|
|
667
|
+
h1 { font-size: 1.6rem; }
|
|
668
|
+
.lead { font-size: 1.05rem; }
|
|
669
|
+
.facts { margin: 1.4rem 0 1.6rem; }
|
|
670
|
+
.facts dt { font-size: 0.95rem; font-weight: 700; color: var(--ink); margin-top: 1.2rem; }
|
|
671
|
+
.facts dd { margin: 0.3rem 0 0; }
|
|
672
|
+
.facts ul { padding-left: 1.1rem; margin: 0; }
|
|
673
|
+
ol.next { padding-left: 1.3rem; }
|
|
674
|
+
.local { margin: 1.6rem 0 0; padding-top: 1rem; border-top: 1px solid var(--line); font-size: 0.85rem; color: var(--muted); }
|
|
675
|
+
@media (max-width: 520px) { body { padding-top: 16px; } .card { padding: 1.4rem 1.2rem 1.1rem; } }
|
|
676
|
+
`,XT='<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.6" stroke-linecap="round" aria-hidden="true"><path d="M7 7l10 10M17 7L7 17"/></svg>';function Ic(e,t,n){let r=n==="ok"?`<img class="hero" src="${co}" width="168" height="168" alt="">
|
|
677
|
+
`:n?`<div class="status fail">${XT}</div>
|
|
678
|
+
`:"";return`${Lg(`${e} \xB7 tapster`,QT)}
|
|
679
|
+
<body>
|
|
680
|
+
<main class="card">
|
|
681
|
+
<span class="brand"><img src="${fn}" width="34" height="34" alt="">tapster</span>
|
|
682
|
+
${r}<h1>${Pe(e)}</h1>
|
|
683
|
+
${t}
|
|
684
|
+
</main>
|
|
685
|
+
</body>
|
|
686
|
+
</html>
|
|
687
|
+
`}function jg(e){return Ic(e.title,`<p class="lead">${Pe(e.lead)}</p>
|
|
688
|
+
<dl class="facts">
|
|
689
|
+
<dt>What it may do</dt>
|
|
690
|
+
<dd><ul>${e.permissions.map((t)=>`<li>${Pe(t)}</li>`).join("")}<li>Nothing else. It has no webhook and receives no events.</li></ul></dd>
|
|
691
|
+
<dt>Where its key goes</dt>
|
|
692
|
+
<dd>${Pe(e.key)}</dd>
|
|
693
|
+
</dl>
|
|
694
|
+
<form method="post" action="${Pe(e.action)}">
|
|
695
|
+
<input type="hidden" name="manifest" value="${Pe(e.manifest)}">
|
|
696
|
+
<button class="button" type="submit">Continue to GitHub</button>
|
|
697
|
+
</form>
|
|
698
|
+
<p class="local">This page comes from tapster on your computer (127.0.0.1). The button sends GitHub only this App's description: its name, these permissions and the address to return to. GitHub shows it to you again; click <strong>Create GitHub App</strong> there.</p>`)}function Mg(e){return Ic(e.title,`<p class="lead">Back in your terminal, tapster takes it from here:</p>
|
|
699
|
+
<ol class="next">${e.next.map((t)=>`<li>${Pe(t)}</li>`).join("")}</ol>
|
|
700
|
+
<p class="local">You can close this tab.</p>`,"ok")}function Nc(e){return Ic("Nothing was set up",`<p class="lead">${Pe(e.reason)}</p>
|
|
701
|
+
<p>Run <code>${Pe(e.again)}</code> again in your terminal. It continues where it stopped.</p>
|
|
702
|
+
<p class="local">You can close this tab.</p>`,"fail")}function Ut(e){console.log(` ${e}`),j(process.platform==="darwin"?"/usr/bin/open":"/usr/bin/xdg-open","open",[e],{allowFail:!0}).catch(()=>{return})}var tE={"contents:write":"Contents, read and write: publish releases and their files in the repositories you install it on. Your rulesets keep it from creating or moving branches and tags.","attestations:read":"Attestations, read: check that each file was built by the project's own workflow.","metadata:read":"Metadata, read: every GitHub App has this. It sees the names of the repositories you install it on.","actions:write":"Actions, read and write, on the hub only: start the tapster workflow and turn it back on when GitHub pauses it."};function zc(e){let t=e.default_permissions??{};return Object.entries(t).map(([n,r])=>{let i=tE[`${n}:${r}`];if(!i)throw new v(`the App asks for ${n}: ${r}, which tapster cannot explain`,"Report this at https://github.com/doguyilmaz/tapster/issues.");return i})}var nE={"content-type":"text/html; charset=utf-8","content-security-policy":"default-src 'none'; style-src 'unsafe-inline'; img-src data:; form-action https://github.com; base-uri 'none'; frame-ancestors 'none'","cache-control":"no-store","referrer-policy":"no-referrer","x-content-type-options":"nosniff"};function rE(e){let t=`http://127.0.0.1:${e.port}`,n=!1,r=(i,o=200)=>new Response(i,{status:o,headers:nE});return(i)=>{if(i.headers.get("host")!==`127.0.0.1:${e.port}`)return new Response("Forbidden",{status:403});let o=new URL(i.url);if(o.pathname==="/start"){let a=e.manifest(`${t}/callback`);return r(jg({...e.copy,permissions:zc(a),action:`https://github.com/settings/apps/new?state=${e.state}`,manifest:JSON.stringify(a)}))}if(o.pathname!=="/callback")return new Response("Not found",{status:404});if(n)return r(Nc({reason:"This App was already handled.",again:e.copy.again}),409);let s=o.searchParams.get("code");if(o.searchParams.get("state")!==e.state||!s||!/^[A-Za-z0-9_-]{1,128}$/.test(s))return r(Nc({reason:"This answer did not belong to the App this terminal started, so tapster ignored it.",again:e.copy.again}),400);return n=!0,e.settle({code:s}),r(Mg({title:e.copy.done,next:e.copy.next}))}}function iE(e,t){let n=e.owner?.login??"nobody";if(n.toLowerCase()!==t.toLowerCase())throw new v(`the new App belongs to ${n}, not ${t}`,"tapster stored nothing. Create the App from your own account, then run this again.")}async function lo(e,t,n){let r=eE(16).toString("hex"),i=()=>{},o=new Promise((p)=>i=p),s=()=>new Response(null,{status:503}),a=Bun.serve({hostname:"127.0.0.1",port:0,fetch:(p)=>s(p)});s=rE({manifest:e,copy:t,state:r,port:a.port,settle:i}),console.log(`Opening GitHub to create ${t.what}. Read the page, then click "Continue to GitHub" and "Create GitHub App".`),Ut(`http://127.0.0.1:${a.port}/start`),console.log("tapster waits up to 30 minutes until GitHub sends you back. If no page opened, open the address above. Ctrl+C stops it.");let c="If GitHub created the App anyway, delete it at https://github.com/settings/apps first, because its name would block a new one.",l=setTimeout(()=>i({error:new v("no App was created within 30 minutes",`${c} Then run ${t.again} again.`)}),1800000),u=await o;if(clearTimeout(l),setTimeout(()=>a.stop(),1000),"error"in u)throw u.error;return Dc(u.code,n,`${c} Then run ${t.again} again.`)}async function Dc(e,t,n,r=fetch){let i=await r(`https://api.github.com/app-manifests/${e}/conversions`,{method:"POST",headers:{Accept:"application/vnd.github+json"}});if(!i.ok)throw new v(`GitHub did not hand over the new App (status ${i.status})`,n);let o=await i.json();return iE(o,t),o}var Ug=()=>({HOME:process.env.HOME??"/tmp",...process.env.GH_CONFIG_DIR?{GH_CONFIG_DIR:process.env.GH_CONFIG_DIR}:{},GH_PROMPT_DISABLED:"1"});function Zg(e){try{return Ag(e)}catch{throw new v("the GitHub CLI (gh) is not installed","Install it (brew install gh or see https://cli.github.com), sign in with gh auth login, then run this again.")}}async function _t(){let e=await j(Zg(),"gh",["auth","token"],{env:Ug(),allowFail:!0}),t=e.stdout.trim();if(e.code!==0||!t)throw new v("gh is not signed in","Run gh auth login, then try again.");return new pe(t,fetch,void 0,"user")}async function He(e=process.cwd()){let t=(await $e("git",["-C",e,"remote","get-url","origin"],{allowFail:!0})).stdout.trim(),n=/github\.com[:/]([A-Za-z0-9-]+\/[A-Za-z0-9._-]+?)(?:\.git)?$/.exec(t);if(!n)throw new v("this folder is not a clone of a GitHub repository","Run tapster inside a clone (git remote origin on github.com).");return n[1]}var uo=async(e,t)=>{await j(Zg(),"gh",e,{env:Ug(),stdin:t})};var X=(e,t,n,r="tapster")=>uo(["secret","set",t,"--env",r,"--repo",e],n),ze=(e,t,n)=>uo(["variable","set",t,"--env","tapster","--repo",e,"--body",n]),po=(e,t,n)=>uo(["variable","set",t,"--repo",e,"--body",n]),Gg=(e,t,n="tapster")=>uo(["secret","delete",t,"--env",n,"--repo",e]);async function Zt(e,t,n){try{return(await e.json("GET",`/repos/${t}/environments/tapster/${n}?per_page=100`))[n]??[]}catch(r){if(r instanceof R&&r.status===404)throw new v(`${t} has no tapster environment yet`,"Run tapster init in a clone of the hub first.");throw r}}import{lstatSync as Hg,readFileSync as oE}from"fs";import{mkdir as sE,readFile as aE,writeFile as cE}from"fs/promises";import{join as qg}from"path";function mn(e,t=process.env.HOME??""){let n=e.trim();if(n=n.length>1&&(n[0]==="'"||n[0]==='"')&&n.at(-1)===n[0]?n.slice(1,-1):n.replace(/\\(.)/g,"$1"),!n)throw new v("no path was given","Type the path or drag the file into the terminal.");return n.replace(/^~(?=\/|$)/,t)}async function gn(e,t){try{return await aE(e)}catch(n){let r=n.code;if(r==="ENOENT")throw new v(`${e} does not exist`,`Check the path of ${t}.`);if(r==="EISDIR")throw new v(`${e} is a folder`,`Give the path of ${t} itself.`);throw new v(`${e} cannot be read`,`Check that you can open ${t}.`)}}function Lc(e,t=1048576){try{let n=Hg(e);if(!n.isFile()||n.size>t)return null;return oE(e)}catch{return null}}var oe=(e,t=1048576)=>Lc(e,t)?.toString("utf8")??null;function gr(e,t,n=1048576){let r=oe(e,n);if(r===null)throw new v(`${t} is not a regular file tapster can read`,"Replace a link or a very large file with the file itself, then try again.");return r}var Bg=(e)=>{try{return Hg(e)}catch{return null}};async function vr(e,t,n){let r=t.split("/"),i=e;for(let a of r.slice(0,-1)){i=qg(i,a);let c=Bg(i);if(c&&!c.isDirectory())throw new v(`${t} would be written through a link or a file`,"Replace the link with a real folder, then try again.");if(!c)await sE(i)}let o=qg(e,t),s=Bg(o);if(s&&!s.isFile())throw new v(`${t} is not a regular file`,"Replace the link with the file itself, then try again.");await cE(o,n)}async function ho(e,t={}){let{timeoutMs:n=600000,intervalMs:r=3000,sleep:i=(a)=>new Promise((c)=>setTimeout(c,a)),now:o=Date.now}=t,s=o()+n;for(;;){let a=await e();if(a!==null)return a;if(o()+r>s)return null;await i(r)}}import{createInterface as lE}from"readline";function me(e,t=!1){return new Promise((n)=>{let r=lE({input:process.stdin,output:process.stdout,terminal:!0});if(t)r._writeToOutput=(i)=>{if(i.includes(e))process.stdout.write(e)};r.question(e,(i)=>{if(r.close(),t)process.stdout.write(`
|
|
703
|
+
`);n(i.trim())})})}import{mkdtempSync as uE,rmSync as pE}from"fs";import{tmpdir as dE}from"os";import{join as hE}from"path";var jc=new Set;function kt(e){let t=uE(hE(dE(),e));return jc.add(t),t}function Fe(e){pE(e,{recursive:!0,force:!0}),jc.delete(e)}function fE(){for(let e of[...jc])Fe(e)}process.on("SIGINT",()=>{fE(),process.exit(130)});function fo(e){if(Number.isInteger(e)&&e>=5&&e<60&&60%e===0)return`7-59/${e} * * * *`;if(e===60)return"7 * * * *";let t=e/60;if(Number.isInteger(t)&&t>1&&t<=24&&24%t===0)return`7 */${t} * * *`;throw new v(`${e} minutes is not an interval tapster can schedule`,"Use 5, 6, 10, 12, 15, 20 or 30 minutes. Longer intervals must be 60 minutes times a divisor of 24.")}function rt(e){let t=ie(e)?.on?.schedule?.[0]?.cron;if(!t)return null;let n=/^7-59\/(\d+) \* \* \* \*$/.exec(t)??null;if(n)return Number(n[1]);if(t==="7 * * * *")return 60;let r=/^7 \*\/(\d+) \* \* \*$/.exec(t);return r?Number(r[1])*60:null}function Fg(e){if(e<60)return`*/${e} * * * *`;return e===60?"0 * * * *":`0 */${e/60} * * *`}var Kg=(e)=>e.default,wr=(e)=>Ng.trimEnd().split(`
|
|
704
|
+
`).map((t)=>`${" ".repeat(e)}${t}`).join(`
|
|
705
|
+
`);function yE(e,t,n){return{name:`tapster-doorbell-${e}-${t.split("/")[1].replace(/^homebrew-/,"")}`.toLowerCase().slice(0,34),url:`https://github.com/${t}`,redirect_url:n,public:!1,default_permissions:{actions:"write",metadata:"read"},default_events:[],hook_attributes:{url:"https://example.com/tapster-has-no-webhook",active:!1}}}function bE(e){for(let n of["APP_ID","INSTALLATION_ID","HUB_ID","OWNER_ID","INTERVAL"])if(!/^[0-9]+$/.test(e[n]))throw new v(`${n} must be a number`,"Run tapster init --doorbell again.");if(!/^[A-Za-z0-9-]+\/[A-Za-z0-9._-]+$/.test(e.HUB))throw new v("the hub name is not owner/repo","Run it in the hub clone.");let t={crons:[Fg(Number(e.INTERVAL))]};return`${JSON.stringify({name:"tapster-doorbell",main:"worker.ts",compatibility_date:"2026-10-01",workers_dev:!0,vars:e,triggers:t},null,2)}
|
|
706
|
+
`}function wE(e){for(let t of e.split(`
|
|
707
|
+
`)){let n;try{n=JSON.parse(t)}catch{continue}if(n.type!=="deploy"||!Array.isArray(n.targets))continue;for(let r of n.targets)if(typeof r==="string"&&/^https:\/\/[a-z0-9-]+\.[a-z0-9-]+\.workers\.dev\/?$/.test(r))return new URL(r).origin}return null}function _E(e){let t=`${e.stdout}
|
|
708
|
+
${e.stderr??""}`.split(`
|
|
709
|
+
`).map((r)=>r.trim()).filter(Boolean),n=t.filter((r)=>/\[ERROR\]/.test(r));return(n.length?n:t).slice(-2).join(" / ")||"no output"}var kE=(e)=>({PATH:e,BUN_BE_BUN:"1"});function Vg(e){let t=(n)=>e.variables.some((r)=>r.name===n);if(t("TAPSTER_DOORBELL"))return"done";return t("TAPSTER_DOORBELL_APP_ID")&&t("TAPSTER_DOORBELL_APP_SLUG")?"resume":"new"}var br="Run tapster init --doorbell again; it continues with the App it already created.";async function Yg(e,t){console.log(`Open the doorbell App's settings, scroll to "Private keys" and click "Generate a private key":`),Ut(`https://github.com/settings/apps/${t}`);let n=mn(await me("Path of the downloaded .pem file (drag it here): ")),r=(await gn(n,"the .pem file")).toString("utf8");return await new pe(Be(e,r)).json("GET","/app").catch(()=>{throw new v("that key does not belong to the doorbell App",`Generate the key on https://github.com/settings/apps/${t}.`)}),console.log(`Once tapster is done, delete ${n} and every older key on that page.`),r}function xE(){for(let e of(process.env.PATH??"").split(Mc))if(e&&Wg(Ke(e,"node")))return Ke(e,"node");throw new v("Wrangler needs Node.js, which is not on PATH","Install Node.js 20 or newer, then run this again.")}async function Jg(){let e=kt("tapster-doorbell-");await yr(Ke(e,"package.json"),`${JSON.stringify(Dg,null,2)}
|
|
710
|
+
`),await yr(Ke(e,"bun.lock"),zg),await j(process.execPath,"bun",["install","--frozen-lockfile","--ignore-scripts"],{cwd:e,env:kE(process.env.PATH??"")});let t=xE(),n=Ke(e,"node_modules","wrangler","bin","wrangler.js"),r=Object.fromEntries(["CLOUDFLARE_API_TOKEN","CLOUDFLARE_ACCOUNT_ID"].flatMap((o)=>process.env[o]?[[o,process.env[o]]]:[])),i={PATH:`${Ke(t,"..")}${Mc}/usr/bin${Mc}/bin`,WRANGLER_SEND_METRICS:"false",...r};return{dir:e,run(o,s={}){if(s.interactive)return new Promise((a)=>{gE(t,[n,...o],{cwd:e,stdio:"inherit",env:{HOME:process.env.HOME??"",...i,...s.env}}).on("close",(l)=>a({code:l??1,stdout:""}))});return j(t,"wrangler",[n,...o],{cwd:e,env:{...i,...s.env},stdin:s.stdin,allowFail:!0})}}}async function Qg(e){if((await e.run(["whoami"])).code===0)return;if(console.log("Sign in to Cloudflare in the browser that opens."),(await e.run(["login"],{interactive:!0})).code!==0)throw new v("Wrangler could not sign in to Cloudflare","Run tapster init --doorbell again.")}async function Xg(e,t,n){let r=new pe(Be(e,t));console.log(`Waiting until the App is installed on ${n} (only that repository); tapster continues by itself.`);let i=await ho(()=>r.json("GET",`/repos/${n}/installation`).then((o)=>o.id,()=>null));if(i!==null)return i;throw new v(`the doorbell App was not installed on ${n} within 10 minutes`,`Install it on ${n}, then ${br.charAt(0).toLowerCase()}${br.slice(1)}`)}async function ev(e,t,n,r,i,o,s){let a=(await t.json("GET",`/users/${n.split("/")[0]}`)).id,c=(await t.getRepo(n)).id;await yr(Ke(e.dir,"worker.ts"),Kg(Rc)),await yr(Ke(e.dir,"jwt.ts"),Kg(Cc)),await yr(Ke(e.dir,"wrangler.jsonc"),bE({APP_ID:r,INSTALLATION_ID:String(s),HUB:n,HUB_ID:String(c),OWNER_ID:String(a),INTERVAL:String(o)}));let l=Ke(e.dir,"out.ndjson"),u=await e.run(["deploy"],{env:{WRANGLER_OUTPUT_FILE_PATH:l}});if(u.code!==0)throw new v(`Wrangler could not deploy the doorbell: ${_E(u)}`,br);let p=wE(Wg(l)?vE(l,"utf8"):"");if(!p)throw new v("the doorbell has no workers.dev address",`Create your workers.dev subdomain in the Cloudflare dashboard (Workers & Pages). ${br}`);let d=mE(i).export({type:"pkcs8",format:"pem"}).toString();if((await e.run(["secret","put","APP_KEY"],{stdin:d})).code!==0)throw new v("Wrangler could not store the doorbell key",br);return await ze(n,"TAPSTER_DOORBELL_EVERY",String(o)),p}async function tv(e,t,n,r,i){let o={variables:(await Zt(e,t,"variables")).map((c)=>({name:c.name,value:c.value??""}))},s=Vg(o);if(s==="done")throw new v("the hub already has a doorbell","Run tapster init --rotate doorbell to replace its key. To start over, delete the App and the TAPSTER_DOORBELL variables.");let a=await Jg();try{await Qg(a);let[c]=t.split("/"),l,u;if(s==="resume")l=o.variables.find((d)=>d.name==="TAPSTER_DOORBELL_APP_ID").value,console.log("Continuing with the doorbell App created earlier."),u=await Yg(l,o.variables.find((d)=>d.name==="TAPSTER_DOORBELL_APP_SLUG").value);else{let d=await lo((h)=>yE(c,t,h),{what:"the doorbell App",title:"Create the doorbell App",lead:`GitHub asks you to confirm a second private App. The doorbell uses it only to start ${t}'s workflow when a project releases.`,key:"GitHub hands the App's private key to tapster in your terminal, once. tapster stores it as a secret of the doorbell Worker in your Cloudflare account. It goes nowhere else and no one else receives it.",done:"The doorbell App is created",next:["tapster opens the App's install page in a new tab.",`There, choose "Only select repositories" and pick ${t}, only that one.`,'Click "Install". tapster notices within seconds and deploys the Worker.'],again:"tapster init --doorbell"},c);l=String(d.id),u=d.pem,await ze(t,"TAPSTER_DOORBELL_APP_ID",l),await ze(t,"TAPSTER_DOORBELL_APP_SLUG",d.slug),Ut(`https://github.com/apps/${d.slug}/installations/new`)}let p=await ev(a,e,t,l,u,i,await Xg(l,u,t));for(let d of n.packages)await r(d.repo,"TAPSTER_DOORBELL",p);await ze(t,"TAPSTER_DOORBELL",p),console.log(`The doorbell answers at ${p}. Projects ring it after opening a draft.`)}finally{Fe(a.dir)}}async function nv(e,t,n){let r=await e.json("GET",`/repos/${t}/environments/tapster/variables`);if(Vg(r)!=="done")throw new v("the hub has no working doorbell yet","Run tapster init --doorbell.");let i=r.variables.find((a)=>a.name==="TAPSTER_DOORBELL_APP_ID").value,o=await Yg(i,r.variables.find((a)=>a.name==="TAPSTER_DOORBELL_APP_SLUG").value),s=await Jg();try{await Qg(s),await ev(s,e,t,i,o,n,await Xg(i,o,t))}finally{Fe(s.dir)}console.log(`Deployed the doorbell again with the new key; it starts the hub every ${n} minutes. Now delete every other key on the App's settings page.`)}var We={"actions/checkout":{tag:"v7.0.1",sha:"3d3c42e5aac5ba805825da76410c181273ba90b1"},"actions/attest-build-provenance":{tag:"v4.2.2",sha:"4d101475d8b20a2381f78447822ac1eab6504dd8"},"oven-sh/setup-bun":{tag:"v2.2.0",sha:"0c5077e51419868618aeaa5fe8019c62421857d6"},"actions/upload-artifact":{tag:"v7.0.1",sha:"043fb46d1a93c77aae656e7c1c64a875d1fc6a0a"},"actions/download-artifact":{tag:"v8.0.1",sha:"3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c"},"actions/upload-pages-artifact":{tag:"v5.0.0",sha:"fc324d3547104276b827a68afc52ff2a11cc49c9"},"actions/deploy-pages":{tag:"v5.0.1",sha:"368f82528645a54fb793d4d04e342629a3f51346"}};var rv=`name: release
|
|
711
|
+
on:
|
|
712
|
+
push:
|
|
713
|
+
tags: ["v[0-9]+.[0-9]+.[0-9]+"]
|
|
714
|
+
workflow_dispatch:
|
|
715
|
+
permissions: {}
|
|
716
|
+
jobs:
|
|
717
|
+
build:
|
|
718
|
+
runs-on: __RUNNER__
|
|
719
|
+
permissions: { contents: read }
|
|
720
|
+
steps:
|
|
721
|
+
- name: Refuse anything but a tag
|
|
722
|
+
if: \${{ github.ref_type != 'tag' }}
|
|
723
|
+
run: |
|
|
724
|
+
echo "::error::Run this workflow on a tag like v1.2.3."
|
|
725
|
+
exit 1
|
|
726
|
+
- uses: actions/checkout@__CHECKOUT_SHA__ # __CHECKOUT_TAG__
|
|
727
|
+
with: { persist-credentials: false }
|
|
728
|
+
- name: Build the app, signed ad hoc
|
|
729
|
+
env: { TAG: "\${{ github.ref_name }}" }
|
|
730
|
+
run: |
|
|
731
|
+
set -euo pipefail
|
|
732
|
+
export VERSION="\${TAG#v}"
|
|
733
|
+
__BUILD__
|
|
734
|
+
- name: Pack the app
|
|
735
|
+
env: { TAG: "\${{ github.ref_name }}" }
|
|
736
|
+
run: |
|
|
737
|
+
set -euo pipefail
|
|
738
|
+
mkdir -p "$RUNNER_TEMP/out"
|
|
739
|
+
tar -C "$(dirname "__APP_PATH__")" --no-mac-metadata --no-xattrs -czf "$RUNNER_TEMP/out/__APP_NAME__-\${TAG#v}.app.tar.gz" "$(basename "__APP_PATH__")"
|
|
740
|
+
- uses: actions/upload-artifact@__UPLOAD_SHA__ # __UPLOAD_TAG__
|
|
741
|
+
with: { name: app, path: "\${{ runner.temp }}/out", if-no-files-found: error, retention-days: 1 }
|
|
742
|
+
release:
|
|
743
|
+
needs: build
|
|
744
|
+
runs-on: ubuntu-24.04
|
|
745
|
+
permissions: { contents: write, id-token: write, attestations: write }
|
|
746
|
+
steps:
|
|
747
|
+
- uses: actions/checkout@__CHECKOUT_SHA__ # __CHECKOUT_TAG__
|
|
748
|
+
with: { persist-credentials: false }
|
|
749
|
+
- uses: actions/download-artifact@__DOWNLOAD_SHA__ # __DOWNLOAD_TAG__
|
|
750
|
+
with: { name: app, path: dist }
|
|
751
|
+
- name: List the files
|
|
752
|
+
run: |
|
|
753
|
+
set -euo pipefail
|
|
754
|
+
__CARRY__
|
|
755
|
+
cd dist && sha256sum * > checksums.txt
|
|
756
|
+
- uses: actions/attest-build-provenance@__ATTEST_SHA__ # __ATTEST_TAG__
|
|
757
|
+
if: \${{ !github.event.repository.private }}
|
|
758
|
+
with: { subject-checksums: dist/checksums.txt }
|
|
759
|
+
- name: Hand the draft to the tapster hub
|
|
760
|
+
env: { GH_TOKEN: "\${{ github.token }}", TAG: "\${{ github.ref_name }}" }
|
|
761
|
+
run: gh release create "$TAG" dist/* --draft --verify-tag --generate-notes --title "$TAG"
|
|
762
|
+
__RING__
|
|
763
|
+
`;var Uc=`name: release
|
|
764
|
+
on:
|
|
765
|
+
push:
|
|
766
|
+
tags: ["v[0-9]+.[0-9]+.[0-9]+", "v[0-9]+.[0-9]+.[0-9]+-*"]
|
|
767
|
+
permissions: {}
|
|
768
|
+
jobs:
|
|
769
|
+
build:
|
|
770
|
+
runs-on: ubuntu-24.04
|
|
771
|
+
permissions: { contents: read }
|
|
772
|
+
steps:
|
|
773
|
+
- uses: actions/checkout@__CHECKOUT_SHA__ # __CHECKOUT_TAG__
|
|
774
|
+
with: { persist-credentials: false }
|
|
775
|
+
- uses: oven-sh/setup-bun@__SETUP_BUN_SHA__ # __SETUP_BUN_TAG__
|
|
776
|
+
with: { bun-version: 1.4.3 }
|
|
777
|
+
- run: bun install --frozen-lockfile
|
|
778
|
+
- name: Build every target
|
|
779
|
+
env: { TAG: "\${{ github.ref_name }}" }
|
|
780
|
+
run: |
|
|
781
|
+
set -euo pipefail
|
|
782
|
+
v="\${TAG#v}"
|
|
783
|
+
mkdir -p dist
|
|
784
|
+
for t in darwin-arm64 darwin-x64 linux-arm64 linux-x64 windows-x64; do
|
|
785
|
+
exe=__NAME__; [ "\${t%%-*}" = windows ] && exe=__NAME__.exe
|
|
786
|
+
bun build __ENTRY__ --compile --target="bun-$t" --outfile "dist/$t/$exe"
|
|
787
|
+
done
|
|
788
|
+
mkdir -p out
|
|
789
|
+
for t in darwin-arm64 darwin-x64 linux-arm64 linux-x64; do
|
|
790
|
+
p="\${t/x64/amd64}"
|
|
791
|
+
tar -C "dist/$t" -czf "out/__NAME___\${v}_\${p/-/_}.tar.gz" __NAME__
|
|
792
|
+
done
|
|
793
|
+
(cd dist/windows-x64 && zip -qX "../../out/__NAME___\${v}_windows_amd64.zip" __NAME__.exe)
|
|
794
|
+
- uses: actions/upload-artifact@__UPLOAD_SHA__ # __UPLOAD_TAG__
|
|
795
|
+
with: { name: builds, path: out, if-no-files-found: error, retention-days: 1 }
|
|
796
|
+
release:
|
|
797
|
+
needs: build
|
|
798
|
+
runs-on: ubuntu-24.04
|
|
799
|
+
permissions: { contents: write, id-token: write, attestations: write }
|
|
800
|
+
steps:
|
|
801
|
+
- uses: actions/checkout@__CHECKOUT_SHA__ # __CHECKOUT_TAG__
|
|
802
|
+
with: { persist-credentials: false }
|
|
803
|
+
- uses: actions/download-artifact@__DOWNLOAD_SHA__ # __DOWNLOAD_TAG__
|
|
804
|
+
with: { name: builds, path: dist }
|
|
805
|
+
- name: List the files
|
|
806
|
+
run: cd dist && sha256sum *.tar.gz *.zip > checksums.txt
|
|
807
|
+
- uses: actions/attest-build-provenance@__ATTEST_SHA__ # __ATTEST_TAG__
|
|
808
|
+
if: \${{ !github.event.repository.private }}
|
|
809
|
+
with: { subject-checksums: dist/checksums.txt }
|
|
810
|
+
- name: Hand the draft to the tapster hub
|
|
811
|
+
env: { GH_TOKEN: "\${{ github.token }}", TAG: "\${{ github.ref_name }}" }
|
|
812
|
+
run: gh release create "$TAG" dist/*.tar.gz dist/*.zip dist/checksums.txt --draft --verify-tag --generate-notes --title "$TAG" $( [ "\${TAG#*-}" != "$TAG" ] && echo --prerelease )
|
|
813
|
+
__RING__
|
|
814
|
+
`;function go(e){if(!/^[A-Za-z0-9-]+\/[A-Za-z0-9._-]+$/.test(e))throw new v(`${e} is not a repository name`,"Name the hub as owner/repo, for example you/homebrew-tap.");return e}function vo(e,t){let n=(i)=>i.replace(/^\.\//,"");if(typeof e.bin==="string")return{bin:(e.name??t).replace(/^@[^/]+\//,""),entry:n(e.bin)};let r=Object.entries(e.bin??{})[0];return r?{bin:r[0],entry:n(r[1])}:null}var PE=[["darwin-arm64","darwin_arm64.tar.gz"],["darwin-amd64","darwin_amd64.tar.gz"],["linux-arm64","linux_arm64.tar.gz"],["linux-amd64","linux_amd64.tar.gz"],["windows-amd64","windows_amd64.zip"]];function Gc(e,t,n,r,i,o){return[` - name: ${e}`,` repo: ${t}`,` kind: ${n}`,` binaries: [${r.join(", ")}]`," assets:",...i.map(([s,a])=>` ${s}: "${a}"`),` scoop: ${o}`].join(`
|
|
815
|
+
`)}var iv=(e,t,n)=>Gc(e,t,"bun",[n],PE.map(([r,i])=>[r,`${n}_{version}_${i}`]),!0),mo={darwin_all:"darwin-universal",darwin_universal:"darwin-universal",darwin_arm64:"darwin-arm64",darwin_amd64:"darwin-amd64",linux_arm64:"linux-arm64",linux_amd64:"linux-amd64",windows_amd64:"windows-amd64",windows_arm64:"windows-arm64"};function qc(e,t,n,r,i){if(!i)return{entry:null,reason:"the project has its own release workflow and no release yet; run tapster add again after the first draft"};let o=[];for(let s of i.assets){let a=Object.keys(mo).find((c)=>s.includes(c));if(a&&!o.some(([c])=>c===mo[a]))o.push([mo[a],s.replaceAll(i.version,"{version}")])}if(o.length===0)return{entry:null,reason:"the latest release has no archives tapster recognizes"};return{entry:Gc(e,t,n,r,o,o.some(([s,a])=>s.startsWith("windows")&&a.endsWith(".zip"))),reason:null}}function ov(e,t,n,r){let i=(n?ie(n):null)??{},o=i.project_name??e,s=[...new Set((i.builds??[]).map((h)=>h.binary??o))],a=s.length?s:[o];if(r)return qc(e,t,"go",a,r);if((i.archives??[]).some((h)=>h.name_template!==void 0))return{entry:null,reason:"GoReleaser names the archives with its own template; run tapster add again after the first draft"};let c=(i.archives??[]).some((h)=>(h.format_overrides??[]).some((f)=>f.goos==="windows"&&(f.format==="zip"||f.formats?.includes("zip")))),l=i.builds?.[0]?.goos??["linux","darwin","windows"],u=i.builds?.[0]?.goarch??["amd64","arm64"],p=[],d=i.universal_binaries?.[0];for(let h of l)for(let f of u){let m=mo[`${h}_${f}`];if(!m||h==="darwin"&&d?.replace)continue;p.push([m,`${o}_{version}_${h}_${f}.${h==="windows"&&c?"zip":"tar.gz"}`])}if(d&&l.includes("darwin"))p.unshift(["darwin-universal",`${o}_{version}_darwin_all.tar.gz`]);return{entry:Gc(e,t,"go",a,p,c&&l.includes("windows")),reason:null}}var Zc=(e)=>e.replace(/([[{])\s+/g,"$1").replace(/\s+([\]}])/g,"$1");function _r(e,t){let n=new Map;for(let r of e.split(`
|
|
816
|
+
`))n.set(Zc(r),[...n.get(Zc(r))??[],r]);return t.split(`
|
|
817
|
+
`).map((r)=>n.get(Zc(r))?.shift()??r).join(`
|
|
818
|
+
`)}function TE(e,t,n){let r=vt(e);if((r.toJS().packages??[]).some((l)=>l?.name===n))throw new v(`${n} is already in the hub's tapster.yml`,"Edit its entry there instead.");let o=r.get("packages",!0);if(!Rt(o))throw new v("the hub's tapster.yml has no packages list","Add packages: [] to it.");let[s,a]=o.range??[0,0];if(o.flow&&o.items.length===0)return`${e.slice(0,s).replace(/[ \t]+$/,"")}
|
|
819
|
+
${t}${e.slice(a)}`;if(!o.flow){let l=e.slice(0,a);return`${l}${l.endsWith(`
|
|
820
|
+
`)?"":`
|
|
821
|
+
`}${t}
|
|
822
|
+
${e.slice(a)}`}let c=vt(t).contents;if(!Rt(c)||c.items.length!==1)throw new v("the entry is not one package","Report this as a tapster bug.");return o.flow=!1,o.items.push(c.items[0]),_r(e,r.toString())}function EE(e,t){if(!e||ln(e,t).length===0)return null;let n=e.trim().replace(/^(?:the|an?)\s+/i,"").replace(/command ?line/gi,"command-line").replace(/\.$/,"");return n=n.charAt(0).toUpperCase()+n.slice(1),ln(n,t).length===0?n:null}function sv(e,t){let n=e;if(t.kind==="go"&&t.workflow!=="release.yml")n+=`
|
|
823
|
+
workflow: ${t.workflow}`;if(t.dependabot)n+=`
|
|
824
|
+
protection: dependabot`;return n}function av(e,t){if(!e)return{line:"- the repository has no description, which Homebrew needs; set one on GitHub or add description: to the hub entry before the first release"};let n=ln(e,t);if(!n.length)return{};let r=EE(e,t);if(!r)return{line:`- Homebrew would reject the repository's description (${n.join(" and ")}); add description: to the hub entry before the first release`};return{line:`- Homebrew would reject the repository's description (${n.join(" and ")}); the entry says "${r}" instead`,add:` description: ${JSON.stringify(r)}`}}var yo=(e)=>e.filter((t)=>/^(HOMEBREW_TAP_|MACOS_)/.test(t)),OE=(e,t,n)=>`https://github.com/apps/${e}/installations/new/permissions?suggested_target_id=${t}&repository_ids[]=${n}`;function cv(e){return[" # in the job that decides the version, on the default branch:"," environment: release"," steps:",` - uses: actions/checkout@${e.sha} # ${e.tag}`,' with: { ssh-key: "${{ secrets.TAPSTER_TAG_KEY }}" }'," # ... compute VERSION ..."," - name: Push the release tag",' run: git tag "v$VERSION" && git push origin "v$VERSION"'].join(`
|
|
825
|
+
`)}async function CE(e,t){try{let n=await e.json("GET",`/repos/${t}/contents/tapster.yml?ref=main`);return{text:Buffer.from(n.content,"base64").toString("utf8"),sha:n.sha}}catch(n){if(n instanceof R&&n.status===404)throw new v(`${t} has no tapster.yml on main`,"Run tapster init in a clone of the hub and push it first.");throw n}}async function lv(e,t,n,r,i){if(!un.test(n))throw new v(`${n} is not a valid package name`,"Use lowercase letters, digits and dashes.");let{text:o,sha:s}=await CE(e,t),a=TE(o,i,n),{invalid:c}=ne(a,t.split("/")[0]),l=c.find((f)=>f.name===n);if(l)throw new v(`the hub would refuse this entry: ${l.reason}`,l.fix);let u=`tapster-add-${n}`,p=(await e.json("GET",`/repos/${t}/git/ref/heads/main`)).object.sha;try{await e.json("POST",`/repos/${t}/git/refs`,{ref:`refs/heads/${u}`,sha:p})}catch(f){if(f instanceof R&&f.status===422)throw new v(`the hub already has a branch ${u}`,`Merge or delete it on ${t}, then run tapster add again.`);throw f}await e.json("PUT",`/repos/${t}/contents/tapster.yml`,{message:`Add ${n}`,content:Buffer.from(a).toString("base64"),sha:s,branch:u});let d=[`tapster add prepared this entry for ${r}:`,"","```yaml",i,"```","",`Merge it to let the hub publish ${r}.`].join(`
|
|
826
|
+
`);return(await e.json("POST",`/repos/${t}/pulls`,{title:`Add ${n}`,head:u,base:"main",body:d})).html_url}async function kr(e,t){let n=await Zt(e,t,"variables"),r=n.find((i)=>i.name==="TAPSTER_APP_SLUG")?.value;if(!r)throw new v(`${t} has no App yet`,"Run tapster init in a clone of the hub first.");return{slug:r,apple:n.some((i)=>i.name==="TAPSTER_TEAM_ID")}}function uv(e){let t=e.split(`
|
|
827
|
+
`).filter((r)=>!/^ {6}darwin-[a-z0-9]+: /.test(r)),n=t.findIndex((r)=>/^ {4}assets:\s*$/.test(r));if(n>=0&&!/^ {6}\S/.test(t[n+1]??""))return null;return t.join(`
|
|
828
|
+
`)}async function pv(e,t,n){let r=await e.getRepo(n),i=await e.json("GET",`/users/${n.split("/")[0]}`);return OE(t,i.id,r.id)}var dv=(e,t)=>`- open this page and choose Install, unless the hub's App already reaches ${e}; the project is preselected (keep "Only select repositories"):
|
|
829
|
+
${t}`;function RE(e){let t=vt(e),n=[];t.setIn(["release","draft"],!0),n.push("release.draft: true; the tapster hub publishes after signing"),t.setIn(["checksum","name_template"],"checksums.txt"),n.push("checksum.name_template: checksums.txt; the hub reads this name");for(let r of["notarize","homebrew_casks","brews","scoops"])if(t.has(r))t.delete(r),n.push(`removed ${r}; the hub does this now`);return{text:_r(e,t.toString()),notes:n}}var yv=(e)=>e.value,bv="Ring the tapster hub";function IE(e,t,n){let r=vt(e),i=[],o=r.get("jobs");if(!Ie(o))throw new v("the release workflow has no jobs","Add the GoReleaser job first.");for(let s of o.items){let a=s.value.get("steps");if(!Rt(a))continue;let c=a.items.findIndex((g)=>Ie(g)&&String(g.get("uses")??"").startsWith("goreleaser/goreleaser-action"));if(c===-1)continue;let u=a.items[c].get("env");if(Ie(u))for(let g of[...u.items]){let w=String(g.key.value??g.key);if(/^(MACOS_|HOMEBREW_TAP_)/.test(w))u.delete(w),i.push(`removed ${w} from the GoReleaser step`)}let p=a.items.some((g)=>Ie(g)&&String(g.get("uses")??"").startsWith("actions/attest-build-provenance@")),d=yv(s),h=d.get("permissions"),f=r.get("permissions"),m=h??f;if(m!=="write-all"){let g=Ie(m)?m.toJSON():{};d.set("permissions",r.createNode({...g,contents:"write","id-token":"write",attestations:"write"}))}if(p)i.push("the attestation step is already there; permissions checked");else{let g=r.createNode({name:"Attest the archives for tapster",uses:`actions/attest-build-provenance@${t}`,if:"${{ !github.event.repository.private }}",with:{"subject-checksums":"dist/checksums.txt"}});g.get("uses",!0).comment=` ${n}`,a.items.splice(c+1,0,g),i.push(`added the attestation step (actions/attest-build-provenance ${n}) and its permissions`)}if(!a.items.some((g)=>Ie(g)&&g.get("name")===bv))a.items.push(r.createNode(ie(wr(0))[0])),i.push("added the step that rings the hub's doorbell after the draft is open");return{text:_r(e,r.toString()),notes:i}}throw new v("no GoReleaser step found in the release workflow","tapster add edits the job that runs goreleaser/goreleaser-action.")}function NE(e){let t;try{t=vt(e)}catch{return null}let n=t.get("jobs");if(!Ie(n))return null;for(let r of n.items){let i=yv(r).get("steps");if(!Rt(i))continue;if(!i.items.some((s)=>Ie(s)&&/gh release create[^\n]*--draft/.test(String(s.get("run")??""))))continue;if(i.items.some((s)=>Ie(s)&&s.get("name")===bv))return e;return i.items.push(t.createNode(ie(wr(0))[0])),_r(e,t.toString())}return null}function zE(e,t,n,r=!0){return(r?Uc:Uc.replaceAll("darwin-arm64 darwin-x64 ","")).replaceAll("__CHECKOUT_SHA__",n["actions/checkout"].sha).replaceAll("__CHECKOUT_TAG__",n["actions/checkout"].tag).replaceAll("__SETUP_BUN_SHA__",n["oven-sh/setup-bun"].sha).replaceAll("__SETUP_BUN_TAG__",n["oven-sh/setup-bun"].tag).replaceAll("__UPLOAD_SHA__",n["actions/upload-artifact"].sha).replaceAll("__UPLOAD_TAG__",n["actions/upload-artifact"].tag).replaceAll("__DOWNLOAD_SHA__",n["actions/download-artifact"].sha).replaceAll("__DOWNLOAD_TAG__",n["actions/download-artifact"].tag).replaceAll("__ATTEST_SHA__",n["actions/attest-build-provenance"].sha).replaceAll("__ATTEST_TAG__",n["actions/attest-build-provenance"].tag).replaceAll("__NAME__",e).replaceAll("__ENTRY__",t).replace(`__RING__
|
|
830
|
+
`,`${wr(6)}
|
|
831
|
+
`)}var DE=new Set([".git",".build","build","dist","DerivedData","node_modules","Pods","Carthage"]),vn=(e)=>typeof e==="string"&&!e.includes("$(")?e:null,fv=(e)=>typeof e==="string"?/\/releases\/latest\/download\/([A-Za-z0-9._-]+\.xml)$/.exec(e)?.[1]??null:null;function wv(e,t=0){if(t>5)return[];let n=[];for(let r of vv(e,{withFileTypes:!0})){if(r.isSymbolicLink()||DE.has(r.name)||r.name.endsWith(".app")||r.name.endsWith(".xcodeproj"))continue;if(r.isDirectory())n.push(...wv(ee(e,r.name),t+1));else if(r.name==="Info.plist")n.push(ee(e,r.name))}return n}function LE(e){let t=oe(ee(e,"Makefile"))??"";return{build:/^app:/m.test(t)?"make app":null,appPath:/^APP\s*:?=\s*([^\s].*?\.app)\s*$/m.exec(t)?.[1]??null}}function Bc(e){let t=vv(e);if(!t.some((o)=>o==="project.yml"||o==="Package.swift"||o.endsWith(".xcodeproj")))return null;let n=LE(e),r=oe(ee(e,"project.yml"));if(r!==null){let o=ie(r);for(let[s,a]of Object.entries(o?.targets??{})){if(a.type!=="application")continue;let c=a.info?.properties??{},l=fv(c.SUFeedURL);if(!l)continue;let u={...o.settings?.base??{},...a.settings?.base??{}};return{name:vn(u.PRODUCT_NAME)??s,bundleId:vn(u.PRODUCT_BUNDLE_IDENTIFIER),feed:l,publicKey:vn(c.SUPublicEDKey),universal:String(u.ARCHS??"").includes("x86_64"),...n}}}let i=t.find((o)=>o.endsWith(".xcodeproj"));for(let o of wv(e)){let s;try{let u=Lc(o);if(!u)continue;s=Pg(u)}catch{continue}let a=fv(s.SUFeedURL);if(!a)continue;let c=i&&oe(ee(e,i,"project.pbxproj"),16777216)||"",l=/PRODUCT_BUNDLE_IDENTIFIER = "?([A-Za-z0-9.-]+)"?;/.exec(c)?.[1]??null;return{name:vn(s.CFBundleName)??(i?bo(i,".xcodeproj"):bo(e)),bundleId:vn(s.CFBundleIdentifier)??l,feed:a,publicKey:vn(s.SUPublicEDKey),universal:/ARCHS = [^;]*x86_64/.test(c),...n}}return null}function jE(e,t,n){let r={...n,name:n.appPath?bo(n.appPath,".app"):n.name};return[` - name: ${e}`,` repo: ${t}`," kind: app",` app: ${r.name}.app`,` bundle_id: ${r.bundleId&&to.test(r.bundleId)?r.bundleId:"<bundle id>"}`," assets:",` ${r.universal?"darwin-universal":"darwin-arm64"}: "${r.name}-{version}.app.tar.gz"`," dmg:",` name: "${r.name}-{version}.dmg"`," sparkle:",` key: ${e.replace(/[^a-z0-9]/g,"")}`,...r.feed==="appcast.xml"?[]:[` feed: ${r.feed}`],` public_key: "${r.publicKey??"<SUPublicEDKey>"}"`].join(`
|
|
832
|
+
`)}function ME(e,t){if(/[\r\n]/.test(e.build))throw new v("the build command must be one line","Wrap several steps in a make target or a script.");if(!/^[A-Za-z0-9 ._\/-]+\.app$/.test(e.appPath))throw new v(`${e.appPath} is not a path to an .app`,"Pass the path the build writes the app to.");if(!/^macos-[0-9a-z.-]+$/.test(e.runner))throw new v(`${e.runner} is not a macOS runner`,"Use a runner like macos-15.");let n=e.carry.map((r)=>{let[i,o]=r.split(":");if(!i||!o||!/^[A-Za-z0-9._\/-]+$/.test(i)||!/^[A-Za-z0-9._-]+$/.test(o))throw new v(`${r} is not <path>:<asset name>`,"Name each carried file as path:name.");return` cp "${i}" "dist/${o}"`});return rv.replaceAll("__CHECKOUT_SHA__",t["actions/checkout"].sha).replaceAll("__CHECKOUT_TAG__",t["actions/checkout"].tag).replaceAll("__UPLOAD_SHA__",t["actions/upload-artifact"].sha).replaceAll("__UPLOAD_TAG__",t["actions/upload-artifact"].tag).replaceAll("__DOWNLOAD_SHA__",t["actions/download-artifact"].sha).replaceAll("__DOWNLOAD_TAG__",t["actions/download-artifact"].tag).replaceAll("__ATTEST_SHA__",t["actions/attest-build-provenance"].sha).replaceAll("__ATTEST_TAG__",t["actions/attest-build-provenance"].tag).replaceAll("__RUNNER__",e.runner).replaceAll("__BUILD__",e.build).replaceAll("__APP_PATH__",e.appPath).replaceAll("__APP_NAME__",bo(e.appPath,".app")).replace(`__CARRY__
|
|
833
|
+
`,n.map((r)=>`${r}
|
|
834
|
+
`).join("")).replace(`__RING__
|
|
835
|
+
`,`${wr(6)}
|
|
836
|
+
`)}async function UE(e,t,n=!1,r=!1){let i=(await e.getRepo(t)).default_branch,o=await Cg(e,t,i,n,r),s=[o.deployKeys&&!n?"--auto-tag":"",o.dependabot&&!r?"--allow-dependabot":""].filter(Boolean),a=s.length?` It keeps what an earlier ${s.join(" and ")} opened.`:"";if(o.status==="exists")return`- ${t} is already protected: only an admin can create, move or delete its branches and tags.${a}`;if(o.status==="created")return`- protected ${t}: only you can create, move or delete branches and tags; workflows and Apps, the hub's included, cannot. Push release tags yourself; GitHub then notes "Bypassed rule violations", which is your admin right at work.${o.dependabot?" Branches named dependabot/... stay open, so Dependabot can open pull requests; the hub accepts that only with protection: dependabot in its entry.":""}${a}`;return`- GitHub does not enforce rulesets on ${t} (private repositories need a paid plan for them). A stolen App key could tag code the hub would sign. Make it public or use a paid plan. To accept the risk, set protection: off for this package in the hub's tapster.yml; until then the hub refuses it.`}function Hc(e){let t={hub:null,force:!1,workflow:"release.yml",autoTag:!1,dependabot:!1};for(let n=0;n<e.length;n++){let r=e[n];if(r==="--force")t.force=!0;else if(r==="--auto-tag")t.autoTag=!0;else if(r==="--allow-dependabot")t.dependabot=!0;else if(r==="--hub"&&e[n+1])t.hub=go(e[++n]);else if(r==="--workflow"&&e[n+1]&&/^[A-Za-z0-9._-]+\.ya?ml$/.test(e[n+1]))t.workflow=e[++n];else throw new v(`unknown option ${r}`,"Run tapster add --help for the options.")}return t}async function mv(e,t,n,r){let i=ee(e,".github/workflows",t);if(xt(i)&&!r){let o=NE(gr(i,`.github/workflows/${t}`));if(o===null)throw new v(`.github/workflows/${t} already exists`,"Move it aside and run tapster add again. To replace it, run tapster add --force.");return await vr(e,`.github/workflows/${t}`,o),`- kept .github/workflows/${t}; it rings the hub after opening the draft`}return await vr(e,`.github/workflows/${t}`,n),`- wrote .github/workflows/${t} (build, attest, draft, ring the hub)`}async function ZE(e,t,n,r,i=!0){let o=Bc(e);if(o&&!i)throw new v("the hub has no Apple credentials, which a Mac app needs","Run tapster init --rotate certificate and tapster init --rotate notary in the hub clone, then tapster add again.");if(o){let a=o.build??'echo "Set the build command in .github/workflows/release.yml" && exit 1',c=o.appPath??`build/${o.name}.app`,l=[await mv(e,"release.yml",ME({build:a,appPath:c,runner:"macos-15",carry:[]},We),r.force)];if(!o.build||!o.appPath)l.push("- set the build command and the app path in that file; the build must sign the app ad hoc");return l.push("- the app must set SURequireSignedFeed and SUVerifyUpdateBeforeExtraction to true and stamp both version keys with the tag"),l.push(`- store the Sparkle key in the hub with tapster init --sparkle ${n.replace(/[^a-z0-9]/g,"")} (add --new to create one)`),{kind:"app",entry:jE(n,t,o),reason:null,notes:l,goreleaser:null,files:[".github/workflows/release.yml"]}}let s=[".goreleaser.yaml",".goreleaser.yml"].find((a)=>xt(ee(e,a)));if(s&&xt(ee(e,"go.mod"))){let a=RE(gr(ee(e,s),s));await vr(e,s,a.text);let c=ee(e,".github/workflows",r.workflow);if(!xt(c))throw new v(`no .github/workflows/${r.workflow} found`,"Name the workflow that runs GoReleaser with --workflow.");let l=IE(gr(c,`.github/workflows/${r.workflow}`),We["actions/attest-build-provenance"].sha,We["actions/attest-build-provenance"].tag);return await vr(e,`.github/workflows/${r.workflow}`,l.text),{kind:"go",entry:null,reason:null,notes:[...a.notes,...l.notes].map((u)=>`- ${u}`),goreleaser:a.text,files:[s,`.github/workflows/${r.workflow}`]}}if(xt(ee(e,"package.json"))&&(xt(ee(e,"bun.lock"))||xt(ee(e,"bun.lockb")))){let a;try{a=JSON.parse(gr(ee(e,"package.json"),"package.json"))}catch(p){if(p instanceof v)throw p;throw new v("package.json is not valid JSON","Fix package.json, then try again.")}let c=vo(a,n);if(!c)throw new v("package.json has no bin entry","Add the CLI entry file to bin in package.json.");let l=await mv(e,"release.yml",zE(c.bin,c.entry,We,i),r.force),u=l.startsWith("- kept");return{kind:"bun",entry:u?null:iv(n,t,c.bin),reason:null,notes:[l],goreleaser:null,bin:u?c.bin:null,files:[".github/workflows/release.yml"]}}throw new v("this project is not a GoReleaser-based Go CLI, a Bun CLI or an app with a Sparkle feed","tapster add supports those three.")}async function GE(e,t){let n=(await $e("git",["-C",e,"config","--get","tapster.hub"],{allowFail:!0})).stdout.trim(),r=t??(n?go(n):go(await me("Which hub publishes this project (owner/repo)? ")));return{hub:r,remember:async()=>void(r!==n&&await $e("git",["-C",e,"config","tapster.hub",r]))}}async function qE(e,t,n){let r=await e.json("GET",`/repos/${t}/keys`);if(r.some((a)=>a.title==="tapster tags"))return'- the tag key already exists; to replace it, delete the deploy key "tapster tags" and run this again';try{await e.json("PUT",`/repos/${t}/environments/release`,{deployment_branch_policy:{protected_branches:!1,custom_branch_policies:!0}})}catch(a){if(a instanceof R&&[403,404,422].includes(a.status))throw new v(`GitHub refused environments on ${t}`,"Automatic tags keep their key in an environment, which private repositories get with GitHub Pro. Make the project public or upgrade.");throw a}if(!(await e.json("GET",`/repos/${t}/environments/release/deployment-branch-policies`)).branch_policies.some((a)=>a.name===n))await e.json("POST",`/repos/${t}/environments/release/deployment-branch-policies`,{name:n,type:"branch"});let o=kt("tapster-tag-");try{await j("/usr/bin/ssh-keygen","ssh-keygen",["-q","-t","ed25519","-N","","-C",`tapster tags for ${t}`,"-f",ee(o,"key")]),await X(t,"TAPSTER_TAG_KEY",hv(ee(o,"key"),"utf8"),"release"),await e.json("POST",`/repos/${t}/keys`,{title:"tapster tags",key:hv(ee(o,"key.pub"),"utf8").trim(),read_only:!1})}finally{Fe(o)}let s=r.filter((a)=>!a.read_only).map((a)=>a.title);return[`- automatic tags: a deploy key for ${t} lives in its "release" environment, which only ${n} may use. The rulesets let deploy keys tag.`,...s.length?[` Every deploy key with write access can now tag too: ${s.join(", ")}. Remove the ones you do not need in the repository settings.`]:[]," Push tags from your release workflow like this:",cv(We["actions/checkout"])].join(`
|
|
837
|
+
`)}async function BE(e,t){try{return(await e.json("GET",`/repos/${t}/environments/tapster/variables/TAPSTER_DOORBELL`)).value}catch(n){if(n instanceof R&&n.status===404)return null;throw n}}async function gv(e,t){let r=(await e.listReleases(t)).filter((i)=>/^v\d/.test(i.tag_name)).sort((i,o)=>o.created_at.localeCompare(i.created_at))[0];return r?{assets:r.assets.map((i)=>i.name),version:r.tag_name.slice(1)}:null}async function Fc(e,t,n,r,i,o,s){let a=wo(n),{slug:c,apple:l}=i,u=await ZE(t,n,a,o,l);for(let x of u.notes)s(x);let p=await e.getRepo(n);if(s(await UE(e,n,o.autoTag,o.dependabot)),!o.dependabot&&[".github/dependabot.yml",".github/dependabot.yaml"].some((x)=>xt(ee(t,x))))s("- Dependabot cannot open pull requests here now: GitHub does not let personal repositories exempt it from the rules."),s(" To keep it, run tapster add --allow-dependabot. Branches named dependabot/... then stay open to anything with write access, the hub's App included, so a stolen App key could run your workflows on its own code there.");if(o.autoTag)s(await qE(e,n,p.default_branch));let{entry:d,reason:h}=u;if(u.kind==="go")({entry:d,reason:h}=ov(a,n,u.goreleaser,await gv(e,n)));if(u.kind==="bun"&&u.bin)({entry:d,reason:h}=qc(a,n,"bun",[u.bin],await gv(e,n)));if(d&&!l){if(d=uv(d),d)s("- the hub has no Apple credentials, so the entry leaves out the macOS builds");else h="the hub has no Apple credentials and the project builds only for macOS; run tapster init --rotate certificate and tapster init --rotate notary in the hub, then tapster add again";if(u.kind==="go"||u.bin)s(` Remove the macOS builds from ${u.kind==="go"?"the GoReleaser builds (goos: darwin)":".github/workflows/release.yml"} too: the hub refuses macOS code it cannot sign.`)}let f=null;if(d){d=sv(d,{kind:u.kind,workflow:o.workflow,dependabot:o.dependabot});let x=av(p.description,a);if(x.line)s(x.line);if(x.add)d=`${d}
|
|
838
|
+
${x.add}`;try{f=await lv(e,r,a,n,d),s(`- proposed the hub entry in ${f}; merge it to start publishing`)}catch(_){if(!(_ instanceof v))throw _;if(s(`- the hub entry was not proposed: ${_.reason}. ${_.fix}
|
|
839
|
+
The entry for ${r}'s tapster.yml:
|
|
840
|
+
${d}`),o.dependabot&&_.reason.includes("is already in"))s(" Its existing entry needs protection: dependabot, or the hub refuses the project.")}}else s(`- no hub entry yet: ${h}`);let m=await BE(e,r);if(m)await po(n,"TAPSTER_DOORBELL",m),s("- the release workflow rings the hub's doorbell, so the hub publishes right after the draft opens");let g=await e.json("GET",`/repos/${n}/actions/secrets?per_page=100`).then((x)=>yo(x.secrets.map((_)=>_.name)),()=>[]);if(g.length)s(`- ${n} still holds release secrets that the hub replaces: ${g.join(", ")}. Delete them once the hub has published a release: gh secret delete <name> --repo ${n}`);let w=await pv(e,c,n);return s(dv(n,w)),{pr:f,entry:d,installUrl:w,files:u.files,kind:u.kind}}var wo=(e)=>e.split("/")[1].toLowerCase().replace(/[^a-z0-9-]/g,"-");async function _v(e){let t=Hc(e),n=process.cwd(),r=await He(n),i=await _t(),{hub:o,remember:s}=await GE(n,t.hub),a=await kr(i,o);await s(),await Fc(i,n,r,o,a,t,(c)=>console.log(c)),console.log(`
|
|
841
|
+
Review the changes with git diff, commit and push them, then push a tag to release.`)}async function de(e,t,n,r){try{let i=await e.json("GET",`/repos/${t}/contents/${n}?ref=${r}`);return Buffer.from(i.content,"base64").toString("utf8")}catch(i){if(i instanceof R&&i.status===404)return null;throw i}}async function Kc(e,t,n,r){for(let i=0;i<5;i++){let s=(await e.json("GET",`/repos/${t}/git/ref/heads/main`)).object.sha,a=await e.json("GET",`/repos/${t}/git/commits/${s}`),c=await r((p)=>de(e,t,p,s));if(c.length===0)return"unchanged";let l=await e.json("POST",`/repos/${t}/git/trees`,{base_tree:a.tree.sha,tree:c.map((p)=>({path:p.path,mode:"100644",type:"blob",...p.content===null?{sha:null}:{content:p.content}}))}),u=await e.json("POST",`/repos/${t}/git/commits`,{message:n,tree:l.sha,parents:[s]});try{return await e.json("PATCH",`/repos/${t}/git/refs/heads/main`,{sha:u.sha,force:!1}),"committed"}catch(p){if(p instanceof R&&p.status===422)continue;throw p}}throw new v("the hub's main branch kept moving","The next run retries.")}var se={version:"1.1.0",sha:"94f641318261803138c0610f1e867a85f80bc21e"};var _o=`name: tapster
|
|
842
|
+
on:
|
|
843
|
+
schedule:
|
|
844
|
+
- cron: "__CRON__"
|
|
845
|
+
workflow_dispatch:
|
|
846
|
+
inputs:
|
|
847
|
+
package:
|
|
848
|
+
description: Only this package (optional)
|
|
849
|
+
required: false
|
|
850
|
+
default: ""
|
|
851
|
+
linux:
|
|
852
|
+
description: Rebuild the Linux repositories
|
|
853
|
+
type: boolean
|
|
854
|
+
default: false
|
|
855
|
+
permissions: {}
|
|
856
|
+
concurrency:
|
|
857
|
+
group: tapster
|
|
858
|
+
cancel-in-progress: false
|
|
859
|
+
jobs:
|
|
860
|
+
check:
|
|
861
|
+
runs-on: ubuntu-24.04
|
|
862
|
+
environment: { name: tapster, deployment: false }
|
|
863
|
+
permissions: { contents: read, issues: read }
|
|
864
|
+
outputs:
|
|
865
|
+
work: \${{ steps.check.outputs.work }}
|
|
866
|
+
macos: \${{ steps.check.outputs.macos }}
|
|
867
|
+
render: \${{ steps.check.outputs.render }}
|
|
868
|
+
linux: \${{ steps.check.outputs.linux }}
|
|
869
|
+
findings: \${{ steps.check.outputs.findings }}
|
|
870
|
+
report: \${{ steps.check.outputs.report }}
|
|
871
|
+
steps:
|
|
872
|
+
- name: Check out the hub
|
|
873
|
+
uses: actions/checkout@__CHECKOUT_SHA__ # __CHECKOUT_TAG__
|
|
874
|
+
with: { persist-credentials: false, ref: main }
|
|
875
|
+
- name: Check the projects for drafts
|
|
876
|
+
id: check
|
|
877
|
+
uses: doguyilmaz/tapster@__TAPSTER_SHA__ # __TAPSTER_TAG__
|
|
878
|
+
with: { mode: check, template: 2, package: "\${{ inputs.package }}", linux: "\${{ inputs.linux }}" }
|
|
879
|
+
env:
|
|
880
|
+
TAPSTER_APP_ID: \${{ vars.TAPSTER_APP_ID }}
|
|
881
|
+
TAPSTER_APP_PRIVATE_KEY: \${{ secrets.TAPSTER_APP_PRIVATE_KEY }}
|
|
882
|
+
GITHUB_TOKEN: \${{ github.token }}
|
|
883
|
+
TAPSTER_TEAM_ID: \${{ vars.TAPSTER_TEAM_ID }}
|
|
884
|
+
TAPSTER_CERT_EXPIRES: \${{ vars.TAPSTER_CERT_EXPIRES }}
|
|
885
|
+
report:
|
|
886
|
+
needs: check
|
|
887
|
+
if: \${{ !cancelled() && (needs.check.outputs.report == 'true' || (needs.check.result == 'failure' && needs.check.outputs.findings == '')) }}
|
|
888
|
+
runs-on: ubuntu-24.04
|
|
889
|
+
permissions: { issues: write }
|
|
890
|
+
steps:
|
|
891
|
+
- name: Update the hub's health issue
|
|
892
|
+
uses: doguyilmaz/tapster@__TAPSTER_SHA__ # __TAPSTER_TAG__
|
|
893
|
+
with: { mode: report, template: 2, findings: "\${{ needs.check.outputs.findings }}", check: "\${{ needs.check.result }}" }
|
|
894
|
+
env:
|
|
895
|
+
GITHUB_TOKEN: \${{ github.token }}
|
|
896
|
+
sign:
|
|
897
|
+
needs: check
|
|
898
|
+
if: \${{ !cancelled() && needs.check.outputs.work != '[]' && needs.check.outputs.work != '' }}
|
|
899
|
+
runs-on: \${{ needs.check.outputs.macos == 'false' && 'ubuntu-24.04' || 'macos-15' }}
|
|
900
|
+
environment: { name: tapster, deployment: false }
|
|
901
|
+
permissions: { contents: write }
|
|
902
|
+
outputs:
|
|
903
|
+
attest: \${{ steps.publish.outputs.attest }}
|
|
904
|
+
checksums: \${{ steps.publish.outputs.attest-checksums }}
|
|
905
|
+
steps:
|
|
906
|
+
- name: Check out the hub
|
|
907
|
+
uses: actions/checkout@__CHECKOUT_SHA__ # __CHECKOUT_TAG__
|
|
908
|
+
with: { persist-credentials: false, ref: main }
|
|
909
|
+
- name: Download the drafts and verify them
|
|
910
|
+
uses: doguyilmaz/tapster@__TAPSTER_SHA__ # __TAPSTER_TAG__
|
|
911
|
+
with: { mode: fetch, template: 2, work: "\${{ needs.check.outputs.work }}" }
|
|
912
|
+
env:
|
|
913
|
+
TAPSTER_APP_ID: \${{ vars.TAPSTER_APP_ID }}
|
|
914
|
+
TAPSTER_APP_PRIVATE_KEY: \${{ secrets.TAPSTER_APP_PRIVATE_KEY }}
|
|
915
|
+
- name: Sign and notarize macOS code
|
|
916
|
+
if: \${{ !cancelled() }}
|
|
917
|
+
uses: doguyilmaz/tapster@__TAPSTER_SHA__ # __TAPSTER_TAG__
|
|
918
|
+
with: { mode: sign, template: 2 }
|
|
919
|
+
env:
|
|
920
|
+
TAPSTER_TEAM_ID: \${{ vars.TAPSTER_TEAM_ID }}
|
|
921
|
+
MACOS_SIGN_P12: \${{ secrets.MACOS_SIGN_P12 }}
|
|
922
|
+
MACOS_SIGN_PASSWORD: \${{ secrets.MACOS_SIGN_PASSWORD }}
|
|
923
|
+
MACOS_NOTARY_KEY: \${{ secrets.MACOS_NOTARY_KEY }}
|
|
924
|
+
MACOS_NOTARY_KEY_ID: \${{ secrets.MACOS_NOTARY_KEY_ID }}
|
|
925
|
+
MACOS_NOTARY_ISSUER_ID: \${{ secrets.MACOS_NOTARY_ISSUER_ID }}
|
|
926
|
+
- name: Build the DMGs
|
|
927
|
+
if: \${{ !cancelled() }}
|
|
928
|
+
uses: doguyilmaz/tapster@__TAPSTER_SHA__ # __TAPSTER_TAG__
|
|
929
|
+
with: { mode: package, template: 2 }
|
|
930
|
+
- name: Sign, notarize and staple the DMGs
|
|
931
|
+
if: \${{ !cancelled() }}
|
|
932
|
+
uses: doguyilmaz/tapster@__TAPSTER_SHA__ # __TAPSTER_TAG__
|
|
933
|
+
with: { mode: seal, template: 2 }
|
|
934
|
+
env:
|
|
935
|
+
TAPSTER_TEAM_ID: \${{ vars.TAPSTER_TEAM_ID }}
|
|
936
|
+
MACOS_SIGN_P12: \${{ secrets.MACOS_SIGN_P12 }}
|
|
937
|
+
MACOS_SIGN_PASSWORD: \${{ secrets.MACOS_SIGN_PASSWORD }}
|
|
938
|
+
MACOS_NOTARY_KEY: \${{ secrets.MACOS_NOTARY_KEY }}
|
|
939
|
+
MACOS_NOTARY_KEY_ID: \${{ secrets.MACOS_NOTARY_KEY_ID }}
|
|
940
|
+
MACOS_NOTARY_ISSUER_ID: \${{ secrets.MACOS_NOTARY_ISSUER_ID }}
|
|
941
|
+
- name: Sign the Sparkle feeds
|
|
942
|
+
if: \${{ !cancelled() }}
|
|
943
|
+
uses: doguyilmaz/tapster@__TAPSTER_SHA__ # __TAPSTER_TAG__
|
|
944
|
+
with: { mode: sparkle, template: 2 }
|
|
945
|
+
env: __SPARKLE_ENV__
|
|
946
|
+
- name: Publish the signed releases
|
|
947
|
+
id: publish
|
|
948
|
+
if: \${{ !cancelled() }}
|
|
949
|
+
uses: doguyilmaz/tapster@__TAPSTER_SHA__ # __TAPSTER_TAG__
|
|
950
|
+
with: { mode: publish, template: 2 }
|
|
951
|
+
env:
|
|
952
|
+
TAPSTER_APP_ID: \${{ vars.TAPSTER_APP_ID }}
|
|
953
|
+
TAPSTER_APP_PRIVATE_KEY: \${{ secrets.TAPSTER_APP_PRIVATE_KEY }}
|
|
954
|
+
GITHUB_TOKEN: \${{ github.token }}
|
|
955
|
+
- name: Remove keychains and temporary files
|
|
956
|
+
if: always()
|
|
957
|
+
uses: doguyilmaz/tapster@__TAPSTER_SHA__ # __TAPSTER_TAG__
|
|
958
|
+
with: { mode: cleanup, template: 2 }
|
|
959
|
+
attest:
|
|
960
|
+
needs: sign
|
|
961
|
+
if: \${{ !cancelled() && needs.sign.outputs.attest == 'true' }}
|
|
962
|
+
runs-on: ubuntu-24.04
|
|
963
|
+
permissions: { contents: read, id-token: write, attestations: write }
|
|
964
|
+
steps:
|
|
965
|
+
- name: Write the checksums of the signed files
|
|
966
|
+
env: { CHECKSUMS: "\${{ needs.sign.outputs.checksums }}" }
|
|
967
|
+
run: printf '%s\\n' "$CHECKSUMS" > "$RUNNER_TEMP/checksums.txt"
|
|
968
|
+
- name: Attest the signed files
|
|
969
|
+
uses: actions/attest-build-provenance@__ATTEST_SHA__ # __ATTEST_TAG__
|
|
970
|
+
with: { subject-checksums: "\${{ runner.temp }}/checksums.txt" }
|
|
971
|
+
render:
|
|
972
|
+
needs: [check, sign]
|
|
973
|
+
if: \${{ !cancelled() && needs.check.outputs.render == 'true' }}
|
|
974
|
+
runs-on: ubuntu-24.04
|
|
975
|
+
permissions: { contents: write }
|
|
976
|
+
steps:
|
|
977
|
+
- name: Check out the hub
|
|
978
|
+
uses: actions/checkout@__CHECKOUT_SHA__ # __CHECKOUT_TAG__
|
|
979
|
+
with: { persist-credentials: false, ref: main }
|
|
980
|
+
- name: Write casks and the state
|
|
981
|
+
uses: doguyilmaz/tapster@__TAPSTER_SHA__ # __TAPSTER_TAG__
|
|
982
|
+
with: { mode: render, template: 2 }
|
|
983
|
+
env:
|
|
984
|
+
GITHUB_TOKEN: \${{ github.token }}
|
|
985
|
+
linux-build:
|
|
986
|
+
needs: [check, sign]
|
|
987
|
+
if: \${{ !cancelled() && needs.check.outputs.linux == 'true' }}
|
|
988
|
+
runs-on: ubuntu-24.04
|
|
989
|
+
permissions: { contents: read }
|
|
990
|
+
outputs:
|
|
991
|
+
changed: \${{ steps.build.outputs.changed }}
|
|
992
|
+
steps:
|
|
993
|
+
- name: Check out the hub
|
|
994
|
+
uses: actions/checkout@__CHECKOUT_SHA__ # __CHECKOUT_TAG__
|
|
995
|
+
with: { persist-credentials: false, ref: main }
|
|
996
|
+
- name: Build the Linux packages
|
|
997
|
+
id: build
|
|
998
|
+
uses: doguyilmaz/tapster@__TAPSTER_SHA__ # __TAPSTER_TAG__
|
|
999
|
+
with: { mode: linux-build, template: 2 }
|
|
1000
|
+
- name: Keep the Linux files for the next job
|
|
1001
|
+
if: \${{ steps.build.outputs.changed == 'true' }}
|
|
1002
|
+
uses: actions/upload-artifact@__UPLOAD_SHA__ # __UPLOAD_TAG__
|
|
1003
|
+
with: { name: linux-unsigned, path: "\${{ runner.temp }}/tapster-linux", if-no-files-found: error, retention-days: 1 }
|
|
1004
|
+
linux-sign:
|
|
1005
|
+
needs: linux-build
|
|
1006
|
+
if: \${{ !cancelled() && needs.linux-build.result == 'success' && needs.linux-build.outputs.changed == 'true' }}
|
|
1007
|
+
runs-on: ubuntu-24.04
|
|
1008
|
+
environment: { name: tapster, deployment: false }
|
|
1009
|
+
permissions: { contents: read }
|
|
1010
|
+
steps:
|
|
1011
|
+
- name: Install the signing tools from Ubuntu
|
|
1012
|
+
run: sudo apt-get update -qq && sudo apt-get install -y -qq --no-install-recommends apt-utils rpm createrepo-c dpkg gnupg
|
|
1013
|
+
- name: Check out the hub
|
|
1014
|
+
uses: actions/checkout@__CHECKOUT_SHA__ # __CHECKOUT_TAG__
|
|
1015
|
+
with: { persist-credentials: false, ref: main }
|
|
1016
|
+
- name: Download the Linux files
|
|
1017
|
+
uses: actions/download-artifact@__DOWNLOAD_SHA__ # __DOWNLOAD_TAG__
|
|
1018
|
+
with: { name: linux-unsigned, path: "\${{ runner.temp }}/tapster-linux" }
|
|
1019
|
+
- name: Sign the Linux repositories
|
|
1020
|
+
uses: doguyilmaz/tapster@__TAPSTER_SHA__ # __TAPSTER_TAG__
|
|
1021
|
+
with: { mode: linux-sign, template: 2 }
|
|
1022
|
+
env:
|
|
1023
|
+
TAPSTER_LINUX_KEY: \${{ secrets.TAPSTER_LINUX_KEY }}
|
|
1024
|
+
TAPSTER_LINUX_KEY_PREVIOUS: \${{ secrets.TAPSTER_LINUX_KEY_PREVIOUS }}
|
|
1025
|
+
- name: Keep the signed site for Pages
|
|
1026
|
+
uses: actions/upload-artifact@__UPLOAD_SHA__ # __UPLOAD_TAG__
|
|
1027
|
+
with: { name: linux-site, path: "\${{ runner.temp }}/tapster-linux", if-no-files-found: error, retention-days: 1 }
|
|
1028
|
+
linux-pages:
|
|
1029
|
+
needs: linux-sign
|
|
1030
|
+
if: \${{ !cancelled() && needs.linux-sign.result == 'success' }}
|
|
1031
|
+
runs-on: ubuntu-24.04
|
|
1032
|
+
environment: { name: github-pages, url: "\${{ steps.deploy.outputs.page_url }}" }
|
|
1033
|
+
permissions: { pages: write, id-token: write }
|
|
1034
|
+
steps:
|
|
1035
|
+
- name: Download the signed site
|
|
1036
|
+
uses: actions/download-artifact@__DOWNLOAD_SHA__ # __DOWNLOAD_TAG__
|
|
1037
|
+
with: { name: linux-site, path: site }
|
|
1038
|
+
- name: Hand the site to GitHub Pages
|
|
1039
|
+
uses: actions/upload-pages-artifact@__PAGES_UPLOAD_SHA__ # __PAGES_UPLOAD_TAG__
|
|
1040
|
+
with: { path: site }
|
|
1041
|
+
- name: Deploy the Linux repositories
|
|
1042
|
+
id: deploy
|
|
1043
|
+
uses: actions/deploy-pages@__PAGES_DEPLOY_SHA__ # __PAGES_DEPLOY_TAG__
|
|
1044
|
+
`;var kv=`# __TAP__
|
|
1045
|
+
|
|
1046
|
+
\`\`\`sh
|
|
1047
|
+
brew tap __TAP__
|
|
1048
|
+
brew trust __TAP__
|
|
1049
|
+
brew install __TAP__/<name>
|
|
1050
|
+
\`\`\`
|
|
1051
|
+
|
|
1052
|
+
Homebrew loads casks only from taps you trust; \`brew trust\` says that you trust this one.
|
|
1053
|
+
|
|
1054
|
+
On Windows this repository is also a Scoop bucket:
|
|
1055
|
+
|
|
1056
|
+
\`\`\`sh
|
|
1057
|
+
scoop bucket add __OWNER__ https://github.com/__HUB__
|
|
1058
|
+
scoop install __OWNER__/<name>
|
|
1059
|
+
\`\`\`
|
|
1060
|
+
|
|
1061
|
+
| Path | What it holds |
|
|
1062
|
+
| --- | --- |
|
|
1063
|
+
| \`Casks/\` | Homebrew casks, written by tapster from signed, notarized releases |
|
|
1064
|
+
| \`bucket/\` | Scoop manifests for packages with Windows builds |
|
|
1065
|
+
| \`tapster.yml\` | which projects this hub publishes |
|
|
1066
|
+
| \`.tapster/state.json\` | the releases tapster published |
|
|
1067
|
+
|
|
1068
|
+
Releases are signed and published by the \`tapster\` workflow; change the projects, not these files.
|
|
1069
|
+
`;var J=".github/workflows/tapster.yml";function Te(e){let t=e.packages.filter(Y).flatMap((n)=>n.sparkle?[n.sparkle.key,...n.sparkle.next_key?[n.sparkle.next_key]:[]]:[]);return[...new Set(t)]}function xv(e){let t=e.map((n)=>`SPARKLE_KEY_${n.toUpperCase()}: "\${{ secrets.SPARKLE_KEY_${n.toUpperCase()} }}"`);return t.length?`{ ${t.join(", ")} }`:"{}"}function Wc(e,t,n,r=[],i=10){return e.replaceAll("__CRON__",fo(i)).replaceAll("__SPARKLE_ENV__",xv(r)).replaceAll("__CHECKOUT_SHA__",t["actions/checkout"].sha).replaceAll("__CHECKOUT_TAG__",t["actions/checkout"].tag).replaceAll("__ATTEST_SHA__",t["actions/attest-build-provenance"].sha).replaceAll("__ATTEST_TAG__",t["actions/attest-build-provenance"].tag).replaceAll("__UPLOAD_SHA__",t["actions/upload-artifact"].sha).replaceAll("__UPLOAD_TAG__",t["actions/upload-artifact"].tag).replaceAll("__DOWNLOAD_SHA__",t["actions/download-artifact"].sha).replaceAll("__DOWNLOAD_TAG__",t["actions/download-artifact"].tag).replaceAll("__PAGES_UPLOAD_SHA__",t["actions/upload-pages-artifact"].sha).replaceAll("__PAGES_UPLOAD_TAG__",t["actions/upload-pages-artifact"].tag).replaceAll("__PAGES_DEPLOY_SHA__",t["actions/deploy-pages"].sha).replaceAll("__PAGES_DEPLOY_TAG__",t["actions/deploy-pages"].tag).replaceAll("__TAPSTER_SHA__",n.sha).replaceAll("__TAPSTER_TAG__",n.tag)}async function KE(e,t,n){if(n===null){if(t.sha)return{sha:t.sha,tag:`v${t.version}`};throw new v("this tapster was built from a checkout, so it does not know which tapster the hub should run","Pass --tapster <commit> with a full commit SHA from tapster's main or use a released tapster.")}if(!/^[0-9a-f]{40}$/.test(n))throw new v(`${n} is not a full commit SHA`,"Pass all 40 characters of the commit.");let r=await e.json("GET",`/repos/doguyilmaz/tapster/compare/${n}...main`);if(r.status!=="ahead"&&r.status!=="identical")throw new v(`${n} is not on tapster's main`,"Pin a commit that is on main.");return{sha:n,tag:"main"}}var Gt=/doguyilmaz\/tapster@([0-9a-f]{40}) # (\S+)/;function WE(e,t){let n=(o)=>`${o[2]} (${o[1].slice(0,7)})`,r=Gt.exec(t),i=e===null?null:Gt.exec(e);if(!i)return`tapster ${n(r)}`;return i[1]===r[1]&&i[2]===r[2]?`tapster ${n(i)}, unchanged`:`tapster ${n(i)} -> ${n(r)}`}function Vc(e,t,n){if(e===null)return"missing";let r=Gt.exec(e),i=n??t.sha;if(!r)return"other";if(r[1]===i)return"current";if(n!==null||!t.sha)return"other";let o=ro(r[2]),s=ro(`v${t.version}`);if(!o||!s)return"other";let a=Sc(o,s);return a<0?"older":a>0?"newer":"other"}function ko(e,t){let n=/(\n\s+with: \{ mode: sparkle(?:, template: \d+)? \}\n\s+env: ).*\n/;if(!n.test(e))throw new v("the hub workflow has no sparkle step","Run tapster init --workflow to rewrite it from the template.");return e.replace(n,(r,i)=>`${i}${xv(t)}
|
|
1070
|
+
`)}function VE(e,t,n){if(e===t)return[];let r=[`The hub looks for new drafts every ${e} minutes; change it with tapster init --workflow --every <minutes>.`];if(t!==null)r.push("If the hub has a doorbell, run tapster init --rotate doorbell after you push, so it keeps the same schedule.");if(n.isPrivate&&e>=60&&n.every===null)r.push("GitHub bills every run of a private hub as at least one minute: every 10 minutes would use about 4,300 of the 2,000 free minutes a month. The doorbell (tapster init --doorbell) still publishes right after each release.");return r}async function Yc(e,t,n,r,i){let o=await KE(e,se,r),s=t===null?null:rt(t),a=i.every??s??(i.isPrivate?60:10),c=Wc(_o,We,o,n,a);return{file:{path:J,content:c,before:t},change:WE(t,c),notes:VE(a,s,i)}}function xo(e){let[t,n]=e.split("/"),r=`${t}/${n.replace(/^homebrew-/,"")}`;return[{path:"tapster.yml",content:`version: 1
|
|
1071
|
+
tap: ${r}
|
|
1072
|
+
packages: []
|
|
1073
|
+
`,before:null},{path:".tapster/state.json",content:`${JSON.stringify({version:1,packages:{}},null,2)}
|
|
1074
|
+
`,before:null},{path:"README.md",content:kv.replaceAll("__TAP__",r).replaceAll("__OWNER__",t).replaceAll("__HUB__",e),before:null}]}async function So(e,t,n,r,i){let o=[],s=[];for(let u of xo(t))if(await n(u.path)===null)o.push(u);else s.push(u.path);let a=await n("tapster.yml"),c=a===null?[]:Te(ne(a,t.split("/")[0]).config),l=await Yc(e,await n(J),c,r,i);return o.push(l.file),{files:o,kept:s,change:l.change,notes:l.notes}}var F=(e,t)=>({name:e,ok:!0,fix:"",...t?{note:t}:{}}),M=(e,t)=>({name:e,ok:!1,fix:t});function YE(e){let n=ie(e)?.on,r=n&&typeof n==="object"&&!Array.isArray(n)?Object.keys(n):[];return r.length>0&&r.every((i)=>i==="schedule"||i==="workflow_dispatch")?F("the hub workflow runs only on schedule and manual dispatch"):M("the hub workflow runs only on schedule and manual dispatch","Other triggers (pull_request_target, issue_comment, workflow_run) would reach the credentials. Restore .github/workflows/tapster.yml with tapster init.")}function JE(e){let n=(i)=>{let o;try{o=ie(i)}catch{return!0}let s=o?.jobs;if(!s||typeof s!=="object")return!1;return Object.values(s).some((a)=>{let c=a?.environment,l=typeof c==="object"&&c!==null?c.name:c;return typeof l==="string"&&(l.trim().toLowerCase()==="tapster"||l.includes("${{"))})},r=Object.entries(e).filter(([,i])=>n(i)).map(([i])=>i);return r.length===0?F("no other workflow uses the tapster environment"):M("no other workflow uses the tapster environment",`Remove the tapster environment from ${r.join(", ")}.`)}function QE(e,t,n){let i=Te(e),o=i.filter((a)=>!t.includes(`SPARKLE_KEY_${a.toUpperCase()}`));if(o.length)return M("every Sparkle key is stored and passed to the sparkle step",o.map((a)=>`Run tapster init --sparkle ${a}.`).join(" "));let s=i.filter((a)=>!n.includes(`SPARKLE_KEY_${a.toUpperCase()}: "\${{ secrets.SPARKLE_KEY_${a.toUpperCase()} }}"`));if(s.length)return M("every Sparkle key is stored and passed to the sparkle step",`The workflow does not pass ${s.map((a)=>`SPARKLE_KEY_${a.toUpperCase()}`).join(", ")}. Run tapster init --workflow.`);return F("every Sparkle key is stored and passed to the sparkle step")}function XE(e,t){let r=Object.entries(t).filter(([,i])=>i!==e).map(([i])=>i);return r.length?M("every project rings the hub's doorbell",r.map((i)=>`gh variable set TAPSTER_DOORBELL --repo ${i} --body ${e}`).join("; ")):F("every project rings the hub's doorbell")}function eO(e,t,n,r){if(!n.includes("TAPSTER_LINUX_KEY"))return M("the Linux repositories can be signed and deployed","Run tapster init --linux to make and store the signing key.");if(!r)return M("the Linux repositories can be signed and deployed","Turn on GitHub Pages for the hub; tapster init --linux does it.");if(r.build_type!=="workflow")return M("the Linux repositories can be signed and deployed","Set the hub's Pages source to GitHub Actions; tapster init --linux does it.");let o=r.html_url.replace(/\/$/,"");if(o!==lg(e,t))return M("the Linux repositories can be signed and deployed",`Pages serves ${o}; set linux.url in tapster.yml to it.`);return F("the Linux repositories can be signed and deployed")}var Sv=["MACOS_SIGN_P12","MACOS_SIGN_PASSWORD","MACOS_NOTARY_KEY","MACOS_NOTARY_KEY_ID","MACOS_NOTARY_ISSUER_ID"],tO=[...Sv,"TAPSTER_APP_PRIVATE_KEY"];function nO(e,t,n){let i=e?.packages.some(no)??!1,o=[...["TAPSTER_APP_PRIVATE_KEY",...i?Sv:[]].filter((a)=>!t.includes(a)),...["TAPSTER_APP_ID","TAPSTER_APP_SLUG",...i?["TAPSTER_TEAM_ID"]:[]].filter((a)=>!n.includes(a))];if(o.length===0)return F("the credentials this hub needs are stored");let s=[...o.some((a)=>a.startsWith("TAPSTER_APP"))?["tapster init"]:[],...o.some((a)=>a.startsWith("MACOS_SIGN")||a==="TAPSTER_TEAM_ID")?["tapster init --rotate certificate"]:[],...o.some((a)=>a.startsWith("MACOS_NOTARY"))?["tapster init --rotate notary"]:[]];return M("the credentials this hub needs are stored",`Missing: ${o.join(", ")}. Run ${s.join(" and ")}.`)}function rO(e,t){let r=Gt.exec(e);if(!r)return M("the hub workflow is tapster's template","The workflow does not pin tapster. Run tapster init --workflow.");if(r[1]!==t.sha)return F("the hub workflow is tapster's template",`the hub runs tapster ${r[2]} (${r[1].slice(0,7)}) and this is tapster ${t.version}; tapster init --workflow moves the hub to this one. The tapster that wrote the workflow checks it byte for byte`);let i=[...e.matchAll(/SPARKLE_KEY_([A-Z0-9]+): "/g)].map((s)=>s[1].toLowerCase());return Wc(_o,We,{sha:r[1],tag:r[2]},i,rt(e)??10)===e?F("the hub workflow is tapster's template"):M("the hub workflow is tapster's template","The workflow differs from the template; hand edits can reach the credentials. Run tapster init --workflow and review the diff.")}function Jc(e){return e.some((r)=>r.enforcement==="active"&&r.target==="branch"&&(r.conditions?.ref_name?.include??[]).some((i)=>i==="~DEFAULT_BRANCH"||i==="~ALL"||i==="refs/heads/main")&&(r.conditions?.ref_name?.exclude??[]).length===0&&["deletion","non_fast_forward"].every((i)=>(r.rules??[]).some((o)=>o.type===i))&&(r.bypass_actors??[]).every((i)=>i.actor_type==="RepositoryRole"&&i.actor_id===5))?F("main cannot be deleted or force-pushed, by anyone"):M("main cannot be deleted or force-pushed, by anyone",'Run tapster init to restore the ruleset "tapster main" (active, deletion and force pushes blocked, no one else may bypass).')}function Qc(e,t){return e.allowed_actions==="selected"&&e.sha_pinning_required===!0&&t?.verified_allowed===!1&&(t.patterns_allowed??[]).every((i)=>i==="doguyilmaz/tapster@*")?F("the hub runs only GitHub's and tapster's actions, pinned by commit"):M("the hub runs only GitHub's and tapster's actions, pinned by commit","Run tapster init to restore the hub's Actions policy.")}function iO(e,t,n){let i=e.map((a)=>a.login).filter((a)=>a.toLowerCase()!==n.toLowerCase()),o=t.filter((a)=>!a.read_only).map((a)=>a.title);if(i.length===0&&o.length===0)return F("only you can change the hub");let s=[...i.length?[`collaborators ${i.join(", ")} can push to main and change what the hub signs`]:[],...o.length?[`deploy keys ${o.join(", ")} can push too`]:[]];return M("only you can change the hub",`${s.join("; ")}. Remove them in the hub's settings unless you trust them with your signing keys.`)}function oO(e,t){if(e===String(t))return F("the doorbell keeps the workflow's schedule");return M("the doorbell keeps the workflow's schedule",`The doorbell starts the hub every ${e??"10"} minutes and the workflow every ${t}. Run tapster init --rotate doorbell to move the doorbell to the workflow's schedule.`)}function sO(e,t,n){if(e.some((o)=>(o.event==="schedule"||o.event==="workflow_dispatch")&&t-Date.parse(o.created_at)<86400000))return F("the hub ran in the last day");return M("the hub ran in the last day",n?"Neither GitHub's schedule nor the doorbell started a run. Check the doorbell's logs with wrangler tail and the workflow in the Actions tab.":"GitHub's schedule did not start a run; it is best effort. tapster init --doorbell adds a second clock that starts the hub on time.")}async function it(e,t,n){try{let r=await e.json("GET",t);return(n?r[n]:r)??[]}catch(r){if(r instanceof R&&r.status===404)return[];throw r}}async function aO(e,t,n,r,i){let o=[],s=await e.json("GET",`/repos/${t}/environments/tapster`).catch(()=>null);if(!s)return[M("the tapster environment exists","Run tapster init.")];let a=await e.json("GET",`/repos/${t}/environments/tapster/deployment-branch-policies`);o.push(s.deployment_branch_policy?.custom_branch_policies&&a.branch_policies.length===1&&a.branch_policies[0].name==="main"&&(a.branch_policies[0].type??"branch")==="branch"?F("only main may open the tapster environment"):M("only main may open the tapster environment","Run tapster init to restore the branch rule."));let c=(await it(e,`/repos/${t}/environments/tapster/secrets?per_page=100`,"secrets")).map((b)=>b.name),l=await it(e,`/repos/${t}/environments/tapster/variables?per_page=100`,"variables");o.push(nO(r,c,l.map((b)=>b.name)));let u=l.find((b)=>b.name==="TAPSTER_CERT_EXPIRES")?.value;if(u&&Date.parse(`${u}T00:00:00Z`)-Date.now()<2592000000)o.push(M("the Developer ID certificate is valid for 30 more days",`It expires on ${u}. Renew it at developer.apple.com, then run tapster init --rotate certificate.`));if(r&&Te(r).length)o.push(QE(r,c,i));if(r?.packages.some((b)=>!Y(b)&&b.linux)){let b=await e.json("GET",`/repos/${t}/pages`).catch(()=>null);if(o.push(eO(r,t,c,b)),c.includes("TAPSTER_LINUX_KEY_PREVIOUS"))o.push(F("the Linux key rotation is running","the previous Linux key still signs; once apt and dnf users have the new key, run tapster init --rotate linux --finish"))}let p=await it(e,`/repos/${t}/actions/variables?per_page=100`,"variables"),d=[...l,...p].map((b)=>b.name).filter((b)=>tO.includes(b)||/^SPARKLE_KEY_/.test(b)||b.startsWith("TAPSTER_LINUX_KEY"));o.push(d.length?M("credentials are secrets, not variables",`Variables are readable by anyone with access; delete ${d.join(", ")} and store them with tapster init --rotate.`):F("credentials are secrets, not variables"));let h=l.find((b)=>b.name==="TAPSTER_DOORBELL")?.value;if(h&&r){let b={};for(let k of r.packages)b[k.repo]=await e.json("GET",`/repos/${k.repo}/actions/variables/TAPSTER_DOORBELL`).then((S)=>S.value).catch(()=>null);o.push(XE(h,b)),o.push(oO(l.find((k)=>k.name==="TAPSTER_DOORBELL_EVERY")?.value,rt(i)??10))}let f=await e.json("GET",`/repos/${t}/actions/permissions/workflow`);o.push(f.default_workflow_permissions==="read"?F("the default workflow token is read-only"):M("the default workflow token is read-only","Run tapster init."));let m=await Promise.all((await it(e,`/repos/${t}/rulesets`)).map((b)=>e.json("GET",`/repos/${t}/rulesets/${b.id}`)));o.push(Jc(m));let g=await e.json("GET",`/repos/${t}/actions/permissions`),w=g.allowed_actions==="selected"?await e.json("GET",`/repos/${t}/actions/permissions/selected-actions`):null;o.push(Qc(g,w)),o.push(iO(await it(e,`/repos/${t}/collaborators?affiliation=direct&per_page=100`),await it(e,`/repos/${t}/keys?per_page=100`),n));let x=await e.json("GET",`/repos/${t}/actions/workflows/tapster.yml`).catch(()=>null);o.push(x?.state==="active"?F("the hub workflow is enabled"):M("the hub workflow is enabled","Enable the tapster workflow in the hub's Actions tab (GitHub pauses it after 60 days without activity; the doorbell turns it back on)."));let _=await it(e,`/repos/${t}/actions/workflows/tapster.yml/runs?per_page=30`,"workflow_runs");o.push(sO(_,Date.now(),Boolean(h)));for(let b of r?.packages??[]){let k=await e.getRepo(b.repo).catch((A)=>A instanceof R?null:Promise.reject(A));if(!k){o.push(M(`${b.repo} exists`,"Fix the repo field in tapster.yml."));continue}if(k.private)o.push(F(`${b.repo} is published by the hub`,`${b.repo} is private: the hub publishes its releases, but Homebrew, Scoop, apt and dnf users can only install from public projects`));if(b.protection==="off")o.push(F(`${b.repo} is protected`,`protection is off for ${b.name}: a stolen App key could tag code there that the hub would sign`));else{let A=await mr(e,b.repo,k.default_branch,"admin",b.protection==="dependabot"),L=b.protection==="dependabot"?`branches named dependabot/... are open on ${b.repo}, so a stolen App key could run its workflows on code of its own there`:void 0;o.push(A.length?M(`${b.repo} is protected`,`${A.join("; ")}. Run tapster add in a clone of ${b.repo}.`):F(`${b.repo} is protected`,L))}let S=(await it(e,`/repos/${b.repo}/actions/secrets?per_page=100`,"secrets")).map((A)=>A.name),O=yo(S);o.push(O.length?M(`${b.repo} holds no release secrets`,`Delete ${O.join(", ")}: gh secret delete <name> --repo ${b.repo}`):F(`${b.repo} holds no release secrets`))}return o}async function cO(e,t,n){let i=(await e.json("GET",`/repos/${t}/environments/tapster/variables`).catch(()=>null))?.variables.find((o)=>o.name==="TAPSTER_APP_SLUG")?.value;if(!i||n.length===0)return null;return`note: the App must be installed on ${n.join(", ")} and not on ${t}; GitHub shows its repositories only to the App itself, so check them at https://github.com/apps/${i}/installations/new (the hub's check job also reports both)`}function lO(e,t){if(e===null)return{checks:[M("tapster.yml is valid","Run tapster init.")],config:null};try{let{config:n,invalid:r}=ne(e,t);if(r.length===0)return{checks:[F("tapster.yml is valid")],config:n};return{checks:r.map((i)=>M(`${i.name} in tapster.yml is valid`,`${i.reason}. ${i.fix}`)),config:n}}catch(n){return{checks:[M("tapster.yml is valid",n instanceof v?`${n.reason}. ${n.fix}`:"Run tapster init.")],config:null}}}async function uO(e,t){let n=(await it(e,`/repos/${t}/contents/.github/workflows?ref=main`)).filter((i)=>i.type==="file").map((i)=>i.name),r={};for(let i of n)r[i]=await de(e,t,`.github/workflows/${i}`,"main")??"";return{config:await de(e,t,"tapster.yml","main"),flows:r}}async function xr(e,t){let n=t.split("/")[0],r=await uO(e,t),i=[],o=lO(r.config,n),s=o.config;i.push(...o.checks);let a=r.flows["tapster.yml"];if(a)i.push(YE(a),rO(a,se));else i.push(M("the hub workflow exists","Run tapster init, commit and push."));let{"tapster.yml":c,...l}=r.flows;return i.push(JE(l)),i.push(...await aO(e,t,n,s,a??"")),{checks:i,note:await cO(e,t,s?.packages.map((u)=>u.repo)??[])}}async function Av(e){let t=await He(process.cwd()),n=await _t();console.log(`Checking ${t} as it is on GitHub's main branch.`);let{checks:r,note:i}=await xr(n,t);for(let o of r)if(console.log(o.ok?`ok ${o.name}`:`fix ${o.name}
|
|
1075
|
+
${o.fix}`),o.note)console.log(` note: ${o.note}`);if(i)console.log(i);return r.every((o)=>o.ok)?0:1}import{createHash as NO,createPrivateKey as zO,createPublicKey as DO}from"crypto";import{existsSync as yn,readFileSync as Or}from"fs";import{mkdir as Hv,writeFile as al}from"fs/promises";import{join as Ee}from"path";import{createHash as pO,createPrivateKey as dO,createPublicKey as $v,sign as hO,verify as fO}from"crypto";var qt=2n**255n-19n,Xc=2n**252n+27742317777372353535851937790883648493n,K=(e,t=qt)=>(e%t+t)%t,el=(e,t)=>{let n=1n,r=K(e);for(let i=t;i>0n;i>>=1n){if(i&1n)n=n*r%qt;r=r*r%qt}return n},Po=(e)=>el(e,qt-2n),Ev=K(-121665n*Po(121666n));function Pv([e,t,n,r],[i,o,s,a]){let c=K((t-e)*(o-i)),l=K((t+e)*(o+i)),u=K(2n*r*a*Ev),p=K(2n*n*s),d=l-c,h=p-u,f=p+u,m=l+c;return[K(d*h),K(f*m),K(h*f),K(d*m)]}function Ov(e,t){let n=[0n,1n,1n,0n],r=t;for(let i=e;i>0n;i>>=1n){if(i&1n)n=Pv(n,r);r=Pv(r,r)}return n}var Cv=(()=>{let e=K(4n*Po(5n)),t=K(e*e-1n),n=K(Ev*e*e+1n),r=el(K(t*Po(n)),(qt+3n)/8n);if(K(r*r*n-t)!==0n)r=K(r*el(2n,(qt-1n)/4n));if(r&1n)r=qt-r;return[r,e,1n,K(r*e)]})(),$o=(e)=>e.reduceRight((t,n)=>t<<8n|BigInt(n),0n);function Rv(e){let t=Buffer.alloc(32),n=e;for(let r=0;r<32;r++)t[r]=Number(n&255n),n>>=8n;return t}function Iv([e,t,n]){let r=Po(n),i=K(e*r),o=K(t*r);return Rv(o|(i&1n)<<255n)}var Tv=(...e)=>pO("sha512").update(Buffer.concat(e)).digest();function mO(e,t,n){let r=$o(e.subarray(0,32)),i=K($o(Tv(e.subarray(32,64),n)),Xc),o=Iv(Ov(i,Cv)),s=K($o(Tv(o,t,n)),Xc);return Buffer.concat([o,Rv(K(i+s*r,Xc))])}var gO=Buffer.from("302e020100300506032b657004220420","hex"),vO=Buffer.from("302a300506032b6570032100","hex"),Ao=(e)=>new v(`the Sparkle key ${e}`,"Store the app's Sparkle key again with tapster init --sparkle <label> --account <keychain account>.");function To(e){let t=e.trim();if(!/^[A-Za-z0-9+/]+={0,2}$/.test(t))throw Ao("is not base64");let n=Buffer.from(t,"base64");pn(n.toString("hex"));let r,i;if(n.length===32){let s=dO({key:Buffer.concat([gO,n]),format:"der",type:"pkcs8"}),a=$v(s).export({format:"der",type:"spki"});r=a.subarray(a.length-32),i=(c)=>hO(null,c,s)}else if(n.length===96){let s=n.subarray(0,64);if(pn(s.toString("base64")),r=Buffer.from(n.subarray(64)),!Iv(Ov($o(s.subarray(0,32)),Cv)).equals(r))throw Ao("is damaged: its two halves do not match");i=(a)=>mO(s,r,a)}else throw Ao(`decodes to ${n.length} bytes, not 32 or 96`);let o=$v({key:Buffer.concat([vO,r]),format:"der",type:"spki"});return{publicKey:r.toString("base64"),sign(s){let a=i(s);if(!fO(null,s,o,a))throw Ao("produced a signature that does not verify");return a}}}function Eo(e,t,n){return{name:`tapster-${e}-${t.split("/")[1].replace(/^homebrew-/,"")}`.toLowerCase().slice(0,34),url:`https://github.com/${t}`,redirect_url:n,public:!1,default_permissions:{contents:"write",attestations:"read",metadata:"read"},default_events:[],hook_attributes:{url:"https://example.com/tapster-has-no-webhook",active:!1}}}async function Sr(e,t){await ze(e,"TAPSTER_APP_ID",String(t.id)),await ze(e,"TAPSTER_APP_SLUG",t.slug),await X(e,"TAPSTER_APP_PRIVATE_KEY",t.pem)}async function Oo(e,t,n,r,i=new pe(Be(e,t))){let o;try{o=(await i.json("GET",`/users/${n}/installation`)).id}catch(a){if(a instanceof R&&a.status===404)return{id:null,onHub:!1};throw a}let s=await i.json("GET",`/repos/${r}/installation`).then(()=>!0,(a)=>a instanceof R&&a.status===404?!1:Promise.reject(a));return{id:o,onHub:s}}import{existsSync as yO}from"fs";import{writeFile as bO}from"fs/promises";import{join as wO}from"path";var tl=65536,nl=8192;function _O(e){return/(?:^|[,/]\s*)OU=([A-Z0-9]{10})(?:[,/]|$)/.exec(e)?.[1]??null}function kO(e,t,n=Date.now()){let r=/(?:^|,)CN=((?:[^,\\]|\\.)*)/.exec(e)?.[1]??"";if(!r.startsWith("Developer ID Application:"))throw new v(`the certificate is "${r||"unnamed"}", not a Developer ID Application certificate`,"Create a Developer ID Application certificate at developer.apple.com, export it with its key from Keychain Access as .p12, then run this again.");let i=_O(e);if(!i)throw new v("the certificate has no team ID","Export the Developer ID Application certificate from Keychain Access.");let o=Date.parse(t);if(Number.isNaN(o))throw new v("the certificate's expiry date cannot be read","Export the certificate again from Keychain Access.");let s=new Date(o).toISOString().slice(0,10);if(o<n)throw new v(`the certificate expired on ${s}`,"Create a new Developer ID Application certificate at developer.apple.com.");return{team:i,expires:s,name:r.replace(/\\(.)/g,"$1")}}function xO(e,t){if(/mac verify error|invalid password/i.test(e.stdout))throw new v("the .p12 could not be opened with that password","Check the password you set when exporting it or export it again.");if(/unsupported/i.test(e.stdout))throw new v("this system's openssl cannot read the .p12","Run this on macOS or export the certificate again from Keychain Access.");if(!/certificate bag/i.test(e.stdout))throw new v("the .p12 holds no certificate","Export the Developer ID Application certificate from My Certificates in Keychain Access.");if(!/key ?bag/i.test(e.stdout))throw new v("the .p12 holds the certificate but not its private key","Export it from My Certificates in Keychain Access on the Mac that holds the key.");if(t.code!==0||!t.stdout.includes("BEGIN CERTIFICATE"))throw new v("the .p12 could not be read","Export it again from My Certificates in Keychain Access.")}async function Co(e,t,n=Date.now()){if(e.length===0||e.length>tl)throw new v("that file is not a .p12 certificate","Export the Developer ID Application certificate from Keychain Access as .p12.");let r=t===""?"pass:":"env:TAPSTER_P12",i=(p)=>$e("openssl",["pkcs12",...p,"-passin",r],{env:{TAPSTER_P12:t},stdin:e,allowFail:!0}),o=[],s=await i(["-info","-noout"]);if(/unsupported/i.test(s.stderr))o=["-legacy"],s=await i([...o,"-info","-noout"]);let a=await i([...o,"-nokeys","-clcerts"]);xO({code:s.code,stdout:`${s.stdout}
|
|
1076
|
+
${s.stderr}`},a);let c=await $e("openssl",["x509","-noout","-subject","-enddate","-nameopt","RFC2253"],{stdin:a.stdout}),l=/^subject=\s*(.*)$/m.exec(c.stdout)?.[1]?.trim()??"",u=/^notAfter=(.*)$/m.exec(c.stdout)?.[1]?.trim()??"";return kO(l,u,n)}async function Ro(e,t,n,r){await X(e,"MACOS_SIGN_P12",Buffer.from(t).toString("base64")),await X(e,"MACOS_SIGN_PASSWORD",n),await ze(e,"TAPSTER_TEAM_ID",r.team),await ze(e,"TAPSTER_CERT_EXPIRES",r.expires)}var SO=(e,t,n)=>["notarytool","history","--key",e,"--key-id",t,"--issuer",n,"--output-format","json"];function AO(e){if(/HTTP status code: 401\b/.test(e))return new v("Apple rejected the notary key (HTTP 401)","Check the .p8 file, the Key ID and the Issuer ID in App Store Connect, then run this again.");if(/HTTP status code: 403\b/.test(e))return new v("Apple refused the notary key (HTTP 403)","Accept the latest agreements in App Store Connect and check that the key has Developer access, then run this again.");let t=e.split(`
|
|
1077
|
+
`).find((r)=>r.trim()!=="")?.trim()??"no message",n=/unable to find utility|notarytool.*not found/i.test(e);return new v(`notarytool could not check the key: ${dn(t).slice(0,300)}`,n?"Install Xcode or its command line tools (xcode-select --install), then run this again.":"Check your connection and the key in App Store Connect, then run this again.")}function rl(e){if(e.length===0||e.length>nl||!Buffer.from(e).toString("utf8").includes("BEGIN PRIVATE KEY"))throw new v("that file is not an App Store Connect key","Download the .p8 from App Store Connect, Users and Access, Integrations.")}function il(e){let t=e.trim();if(!/^[A-Z0-9]{10}$/.test(t))throw new v(`${t||"an empty Key ID"} is not a Key ID`,"Copy the 10-character Key ID next to the key in App Store Connect.");return t}function Io(e,t,n){rl(e);let r=il(t),i=n.trim().toLowerCase();if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(i))throw new v("that is not an Issuer ID","Copy the Issuer ID shown above the key list in App Store Connect.");return{p8:e,keyId:r,issuer:i}}async function No(e){if(process.platform!=="darwin"||!yO(hn.xcrun))return!1;let t=kt("tapster-notary-");try{let n=wO(t,`AuthKey_${e.keyId}.p8`);await bO(n,e.p8,{mode:384});let r=await j(hn.xcrun,"xcrun",SO(n,e.keyId,e.issuer),{allowFail:!0});if(r.code!==0)throw AO(r.stderr);return!0}finally{Fe(t)}}async function zo(e,t){await X(e,"MACOS_NOTARY_KEY",Buffer.from(t.p8).toString("base64")),await X(e,"MACOS_NOTARY_KEY_ID",t.keyId),await X(e,"MACOS_NOTARY_ISSUER_ID",t.issuer)}import{generateKeyPairSync as $O}from"crypto";import{existsSync as PO}from"fs";function Nv(){let{privateKey:e,publicKey:t}=$O("ed25519"),n=e.export({format:"der",type:"pkcs8"}).subarray(-32),r=t.export({format:"der",type:"spki"}).subarray(-32);return{seed:n.toString("base64"),publicKey:r.toString("base64")}}var TO=/^[A-Za-z0-9 .:/@_+=()-]+$/;function $r(e){for(let t of[e.service,e.account,e.label,...e.comment===void 0?[]:[e.comment]])if(!TO.test(t))throw new v(`"${t}" cannot name a keychain item`,"Use letters, digits and simple punctuation.")}function EO(e,t){$r(e);let n=e.comment===void 0?"":` -j "${e.comment}"`,r=`add-generic-password -s "${e.service}" -a "${e.account}" -l "${e.label}" -D "private key"${n} -T "" -X ${Buffer.from(t).toString("hex")}
|
|
1078
|
+
`;if(r.length>4000)throw new v("the key is too long for one security command","tapster stores large keys through the Security API instead.");return r}var OO=`ObjC.import("Security");
|
|
1079
|
+
ObjC.import("Foundation");
|
|
1080
|
+
function run(argv) {
|
|
1081
|
+
const k = (ref) => ObjC.castRefToObject(ref);
|
|
1082
|
+
const access = Ref();
|
|
1083
|
+
const made = $.SecAccessCreate($(argv[2]), $.NSArray.array, access);
|
|
1084
|
+
if (made !== 0) return String(made);
|
|
1085
|
+
const q = $.NSMutableDictionary.alloc.init;
|
|
1086
|
+
q.setObjectForKey(k(access[0]), k($.kSecAttrAccess));
|
|
1087
|
+
q.setObjectForKey(k($.kSecClassGenericPassword), k($.kSecClass));
|
|
1088
|
+
q.setObjectForKey($(argv[0]), k($.kSecAttrService));
|
|
1089
|
+
q.setObjectForKey($(argv[1]), k($.kSecAttrAccount));
|
|
1090
|
+
q.setObjectForKey($(argv[2]), k($.kSecAttrLabel));
|
|
1091
|
+
q.setObjectForKey($.NSFileHandle.fileHandleWithStandardInput.readDataToEndOfFile, k($.kSecValueData));
|
|
1092
|
+
return String($.SecItemAdd(q, null));
|
|
1093
|
+
}`;function CO(e){return $r(e),["-l","JavaScript","-e",OO,e.service,e.account,e.label]}function RO(e){return $r(e),["store","--label",e.label,"service",e.service,"account",e.account]}var Ar="/usr/bin/security",zv="/usr/bin/osascript",Do="/usr/bin/secret-tool",IO={kind:"keychain",exists:async(e)=>(await j(Ar,"security",["find-generic-password","-s",e.service,"-a",e.account],{allowFail:!0})).code===0,async save(e,t){let n=null;try{n=EO(e,t)}catch(i){if(!(i instanceof v)||!i.reason.includes("too long"))throw i}if(n!==null){let i=await j(Ar,"security",["-i"],{stdin:n,allowFail:!0});if(i.code===0&&!/error|returned/i.test(i.stderr))return;throw new v("the login keychain refused the key","Unlock the login keychain and run this again.")}let r=await j(zv,"osascript",CO(e),{stdin:t,allowFail:!0});if(r.code!==0||r.stdout.trim()!=="0")throw new v(`the login keychain refused the key (status ${r.stdout.trim()||r.code})`,"Unlock the login keychain and run this again.")},async read(e){let t=await j(Ar,"security",["find-generic-password","-s",e.service,"-a",e.account,"-w"],{allowFail:!0});return t.code===0?t.stdout.replace(/\n$/,""):null},async remove(e){await j(Ar,"security",["delete-generic-password","-s",e.service,"-a",e.account],{allowFail:!0})}},Dv={kind:"secret-service",exists:async(e)=>await Dv.read(e)!==null,async save(e,t){if((await j(Do,"secret-tool",RO(e),{stdin:t,allowFail:!0})).code!==0)throw new v("the Secret Service refused the key","Unlock your keyring (GNOME Keyring or KWallet) and run this again.")},async read(e){$r(e);let t=await j(Do,"secret-tool",["lookup","service",e.service,"account",e.account],{allowFail:!0});return t.code===0&&t.stdout!==""?t.stdout:null},async remove(e){$r(e),await j(Do,"secret-tool",["clear","service",e.service,"account",e.account],{allowFail:!0})}};function ol(e=process.platform,t=PO){if(e==="darwin")return t(Ar)&&t(zv)?IO:null;if(e==="linux")return t(Do)?Dv:null;return null}async function Lv(e,t){let n=await e.read(t);if(n!==null||!await e.exists(t))return n;throw new v("the previous key is in your keychain, but tapster could not read it","Choose Allow when macOS asks. Run this where you can see that question (not over SSH). Nothing was changed.")}function Pr(e){let t=ol();if(t)return t;throw new v(`tapster keeps a copy of ${e} in your keychain, but this system has none it can use`,"Run this on macOS or on Linux with secret-tool (libsecret-tools) installed. The key must never live only in GitHub, which never gives secrets back.")}function LO(e,t){let n=new Set(e.vars),r=new Set(e.secrets),i=[];if(!(n.has("TAPSTER_APP_ID")&&n.has("TAPSTER_APP_SLUG")))i.push("app");else if(!r.has("TAPSTER_APP_PRIVATE_KEY"))i.push("app-key");if(t&&!(n.has("TAPSTER_TEAM_ID")&&r.has("MACOS_SIGN_P12")&&r.has("MACOS_SIGN_PASSWORD")))i.push("certificate");if(t&&!["MACOS_NOTARY_KEY","MACOS_NOTARY_KEY_ID","MACOS_NOTARY_ISSUER_ID"].every((o)=>r.has(o)))i.push("notary");return i.push("files"),i}var Fv=(e)=>e.trim().toLowerCase()==="yes";function jO(e,t){return["app","certificate","notary"].filter((n)=>!e.includes(n)&&(n==="app"?!e.includes("app-key"):t))}function MO(e,t){if(!(e instanceof R)||!t||![403,404,422].includes(e.status))return e;return new v("GitHub refused environments on this private hub","Environments and their secrets need a public hub or GitHub Pro. Make the hub public or upgrade at https://github.com/settings/billing, then run tapster init again.")}function cl(e,t,n){let r=[];for(let i of e.packages.filter(Y)){let o=i.sparkle?.key===t?i.sparkle.public_key:i.sparkle?.next_key===t?i.sparkle.next_public_key:void 0;if(o===void 0)continue;if(o!==n)throw new v(`${i.name} pins ${o} for ${t}, but this key's public half is ${n}`,"Pick the keychain account of the key the app ships with or fix tapster.yml.");r.push(i.name)}if(r.length===0)throw new v(`no package in tapster.yml uses the Sparkle key ${t}`,"Add the package with its sparkle section first.");return r}async function Kv(e,t,n,r,i){console.log("Waiting up to 10 minutes until the App is installed; tapster continues by itself once you choose Install.");let o=await ho(async()=>{let s=await Oo(e,t,n,r).catch(()=>null);return s?.id?s:null});if(o===null){console.log(`The App is not installed yet. Install it at https://github.com/apps/${i}/installations/new; tapster add links there for each project too.`);return}if(o.onHub)console.log(`The App is installed on ${r}. Remove ${r} from it at https://github.com/settings/installations/${o.id}; the hub refuses to run until you do.`)}async function UO(e,t){console.log("GitHub creates a private App for your hub; it lets the hub publish your projects' releases. Confirm it on the page that opens.");let n=await lo((r)=>Eo(e,t,r),{what:"your tapster App",title:"Create your tapster App",lead:`GitHub asks you to confirm a private App on your account. ${t} uses it to publish the releases of the projects you install it on.`,key:`GitHub hands the App's private key to tapster in your terminal, once. tapster stores it as a secret of the tapster environment in ${t}. It goes nowhere else and no one else receives it.`,done:"Your tapster App is created",next:[`tapster stores the App's ID and key in ${t} and opens the App's install page in a new tab.`,`There, choose "Only select repositories" and pick the projects tapster should publish. Never pick ${t}: it holds your signing keys.`,'Click "Install". tapster notices within seconds and continues.'],again:"tapster init"},e);await Sr(t,n),console.log('Stored the App and its key in the hub. Now install it: choose "Only select repositories" and pick the projects tapster should publish.'),console.log(`Never pick ${t}: the App can write to every repository it is installed on. The hub holds your signing keys. tapster add can also install it on a project later.`),Ut(`https://github.com/apps/${n.slug}/installations/new`),await Kv(String(n.id),n.pem,e,t,n.slug)}function ZO(e){let t;try{t=zO(e)}catch{throw new v("that file is not a private key","Use the .pem file GitHub downloaded when you generated the key.")}if(t.asymmetricKeyType!=="rsa")throw new v("that file is not a GitHub App key","Use the .pem file GitHub downloaded when you generated the key.");let n=DO(t).export({type:"spki",format:"der"});return`SHA256:${NO("sha256").update(n).digest("base64")}`}async function jv(e,t){let n=await e.json("GET",`/repos/${t}/environments/tapster/variables`),r=n.variables.find((c)=>c.name==="TAPSTER_APP_ID")?.value,i=n.variables.find((c)=>c.name==="TAPSTER_APP_SLUG")?.value;if(!r||!i)throw new v("the hub has no App yet","Run tapster init first.");console.log(`Open the App's settings, scroll to "Private keys" and click "Generate a private key":`),Ut(`https://github.com/settings/apps/${i}`);let o=mn(await me("Path of the downloaded .pem file (drag it here): ")),s=(await gn(o,"the .pem file")).toString("utf8"),a=ZO(s);await new pe(Be(r,s)).json("GET","/app").catch(()=>{throw new v("that key does not belong to the hub's App",`Generate the key on https://github.com/settings/apps/${i}.`)}),await X(t,"TAPSTER_APP_PRIVATE_KEY",s),console.log(`Stored the new key (${a}).`),await Kv(r,s,t.split("/")[0],t,i),console.log(`Now delete every other key on that page so the old one stops working. Then delete ${o}.`)}async function Mv(e){console.log("Apple certificate: a Developer ID Application certificate exported as .p12. In Keychain Access, open My Certificates,"),console.log('right-click "Developer ID Application: ...", choose Export and save it as .p12 with a password. Create one at'),console.log("https://developer.apple.com/account/resources/certificates if you have none. It stays in your hub's secrets only.");let t=mn(await me(".p12 file (drag it here): ")),n=await gn(t,"the .p12 file"),r=await me(".p12 password: ",!0),i=await Co(n,r);await Ro(e,n,r,i),console.log(`Certificate stored for team ${i.team}. It expires on ${i.expires}; the hub warns 30 days before.`)}async function Uv(e){console.log("Notarization key: an App Store Connect API key. In App Store Connect open Users and Access, Integrations,"),console.log("App Store Connect API, Team Keys; create a key with Developer access and download AuthKey_<id>.p8 (Apple offers"),console.log("the download once). The Key ID is in the list and the Issuer ID above it. It stays in your hub's secrets only.");let t=mn(await me(".p8 file (drag it here): ")),n=await gn(t,"the .p8 file");rl(n);let r=il(await me("Key ID: ")),i=Io(n,r,await me("Issuer ID: "));console.log(await No(i)?"Apple accepted the key.":"Not on macOS, so the key is checked at the first release instead."),await zo(e,i),console.log(`Notarization key stored. You may delete ${t} once you keep a backup.`)}var sl={name:"tapster main",target:"branch",enforcement:"active",bypass_actors:[],conditions:{ref_name:{include:["~DEFAULT_BRANCH"],exclude:[]}},rules:[{type:"deletion"},{type:"non_fast_forward"}]};async function ll(e,t,n){try{await e.json("PUT",`/repos/${t}/environments/tapster`,{deployment_branch_policy:{protected_branches:!1,custom_branch_policies:!0}})}catch(o){throw MO(o,n)}let r=await e.json("GET",`/repos/${t}/environments/tapster/deployment-branch-policies`);for(let o of r.branch_policies.filter((s)=>s.name!=="main"))await e.json("DELETE",`/repos/${t}/environments/tapster/deployment-branch-policies/${o.id}`);if(!r.branch_policies.some((o)=>o.name==="main"))await e.json("POST",`/repos/${t}/environments/tapster/deployment-branch-policies`,{name:"main",type:"branch"});await e.json("PUT",`/repos/${t}/actions/permissions/workflow`,{default_workflow_permissions:"read",can_approve_pull_request_reviews:!1}),await e.json("PUT",`/repos/${t}/actions/permissions`,{enabled:!0,allowed_actions:"selected",sha_pinning_required:!0}),await e.json("PUT",`/repos/${t}/actions/permissions/selected-actions`,{github_owned_allowed:!0,verified_allowed:!1,patterns_allowed:["doguyilmaz/tapster@*"]});let i=(await e.json("GET",`/repos/${t}/rulesets`)).find((o)=>o.name===sl.name);if(i)await e.json("PUT",`/repos/${t}/rulesets/${i.id}`,sl);else await e.json("POST",`/repos/${t}/rulesets`,sl)}function Er(e,t){let n=Ee(e,"tapster.yml");if(!yn(n))throw new v("tapster.yml is missing","Run tapster init in the hub first.");let{config:r,invalid:i}=ne(Or(n,"utf8"),t.split("/")[0]);for(let o of i)console.log(`note: ${o.name} in tapster.yml is invalid and left out: ${o.reason}`);return r}async function GO(e,t,n,r,i){let o=yn(Ee(t,J))?Or(Ee(t,J),"utf8"):null,s=await Yc(e,o,n,r,i);await Hv(Ee(t,".github/workflows"),{recursive:!0}),await al(Ee(t,J),s.file.content),console.log(`wrote ${J} from the template, ${s.change}; hand edits in it are replaced`);for(let a of s.notes)console.log(a)}async function Wv(e,t){let n=Ee(e,J);if(!yn(n))throw new v(`${J} is missing`,"Run tapster init --workflow first.");await al(n,ko(Or(n,"utf8"),t)),console.log(`updated the sparkle step in ${J}`)}async function qO(e,t,n,r,i){if(!/^[a-z0-9]+$/.test(r))throw new v(`${r} is not a valid label`,"Use lowercase letters and digits, as in sparkle.key.");let o=Er(t,n);console.log("macOS asks whether tapster may read the Sparkle key from your keychain; choose Allow.");let s=await $e("security",["find-generic-password","-s","https://sparkle-project.org","-a",i,"-w"],{allowFail:!0});if(s.code!==0)throw new v(`the login keychain has no Sparkle key for the account ${i}`,"Pass the account generate_keys used with --account (ed25519 by default).");let a=s.stdout.trim(),c=To(a),l=cl(o,r,c.publicKey);console.log(`The key ${c.publicKey} signs updates for ${l.join(", ")}.`),console.log("If it is lost, installed copies can never update again; if it leaks, anyone can sign updates for them.");let u=await me("Do you keep an offline backup of this key? Type yes to store it in the hub: ");if(!Fv(u))throw new v("no offline backup confirmed","Back the key up first (generate_keys -x exports it), then run this again.");await X(n,`SPARKLE_KEY_${r.toUpperCase()}`,a),console.log(`Stored SPARKLE_KEY_${r.toUpperCase()}.`),await Wv(t,Te(o)),console.log("Review and commit the workflow change, then push.")}async function BO(e,t,n){if(!/^[a-z0-9]+$/.test(n))throw new v(`${n} is not a valid label`,"Use lowercase letters and digits, as in sparkle.key.");let r=Er(e,t),i=r.packages.filter(Y).filter((c)=>c.sparkle?.key===n||c.sparkle?.next_key===n);if(i.length)throw new v(`${i.map((c)=>c.name).join(", ")} already sign with the Sparkle key ${n}`,"A new key needs a new label. To change an app's key, follow Rotate a Sparkle key in the tapster docs (Mac apps with Sparkle).");let o=Pr("the Sparkle key"),s={service:"https://sparkle-project.org",account:n,label:"Private key for signing Sparkle updates"};if(await o.exists(s))throw new v(`your keychain already has a Sparkle key for the account ${n}`,`Store that one with tapster init --sparkle ${n} --account ${n} or pick another label.`);let a=Nv();if(await o.save({...s,comment:`Public key (SUPublicEDKey value) for this key is: ${a.publicKey}`},a.seed),console.log(`Saved a new Sparkle key in your ${o.kind==="keychain"?"login keychain":"keyring"} under the account ${n}. Sparkle's own tools find it there. macOS asks you before any app reads it.`),console.log(`Its public key is ${a.publicKey}. Put it in the app as SUPublicEDKey and in tapster.yml as sparkle.public_key.`),console.log("If this key is lost, installed copies can never update again. Keep an offline copy too, for example in your password manager:"),console.log(o.kind==="keychain"?` security find-generic-password -s https://sparkle-project.org -a ${n} -w (macOS asks you first)`:` secret-tool lookup service https://sparkle-project.org account ${n}`),!Fv(await me("Type yes once you keep an offline copy, to store the key in the hub: "))){console.log(`Not stored in the hub yet. Once you keep a copy, run tapster init --sparkle ${n} --account ${n}.`);return}await X(t,`SPARKLE_KEY_${n.toUpperCase()}`,a.seed),console.log(`Stored SPARKLE_KEY_${n.toUpperCase()} in the hub.`),await Wv(e,[...new Set([...Te(r),n])]),console.log("Review and commit the workflow change, then push.")}async function Zv(e,t,n){let r={...t,account:`${t.account} pending`,label:`${t.label} (pending)`};await e.remove(r),await e.save(r,n),await e.remove(t),await e.save(t,n),await e.remove(r)}var Tr=(e,t=!1)=>({service:"tapster-linux-key",account:t?`${e} previous`:e,label:`tapster Linux key for ${e}${t?" (previous)":""}`});async function HO(e,t){let n=(await Zt(e,t,"secrets")).map((r)=>r.name);if(await ol()?.remove(Tr(t,!0)),!n.includes("TAPSTER_LINUX_KEY_PREVIOUS")){console.log("No Linux key rotation is running, so there is nothing to finish.");return}await Gg(t,"TAPSTER_LINUX_KEY_PREVIOUS"),console.log("The previous Linux key no longer signs; apt and dnf trust only the new one from the next run.")}function FO(e,t){if(e.includes("TAPSTER_LINUX_KEY")&&!t)throw new v("the hub already has a Linux signing key","Replacing it makes every apt and dnf user fetch the new key. To do that, run tapster init --rotate linux.")}async function Gv(e,t,n,r){let i=Er(t,n),o=(await Zt(e,n,"secrets")).map((u)=>u.name);FO(o,r);let s=Pr("the Linux signing key"),a=["/opt/homebrew/bin/gpg","/usr/local/bin/gpg","/usr/bin/gpg"].find((u)=>yn(u));if(!a)throw new v("gpg is not installed","Install it with brew install gnupg, then run this again.");await e.json("POST",`/repos/${n}/pages`,{build_type:"workflow"}).catch(async(u)=>{if(!(u instanceof R)||u.status!==409)throw new v("GitHub Pages could not be turned on for the hub","A private hub needs a paid plan for Pages; make the hub public or turn Pages on by hand with GitHub Actions as the source.");await e.json("PUT",`/repos/${n}/pages`,{build_type:"workflow"})}),console.log("GitHub Pages serves the hub from GitHub Actions.");let c=kt("tl-"),l={GNUPGHOME:c};try{await j(a,"gpg",["--batch","--pinentry-mode","loopback","--passphrase","","--quick-gen-key",`${n.split("/")[0]} tapster (${n})`,"rsa4096","sign","never"],{env:l});let u=(await j(a,"gpg",["--batch","--armor","--export-secret-keys"],{env:l})).stdout,p=(await j(a,"gpg",["--batch","--with-colons","--list-secret-keys"],{env:l})).stdout.split(`
|
|
1094
|
+
`).find((f)=>f.startsWith("fpr:"))?.split(":")[9],d=null;if(r){if(s.kind==="keychain")console.log("macOS asks whether tapster may read the previous key from your keychain; choose Allow.");d=await Lv(s,Tr(n))}let h={...Tr(n),account:`${n} new`,label:`tapster Linux key for ${n} (new)`};if(await s.remove(h),await s.save(h,u),await X(n,"TAPSTER_LINUX_KEY",u),d)await X(n,"TAPSTER_LINUX_KEY_PREVIOUS",d);if(d)await Zv(s,Tr(n,!0),d);if(await Zv(s,Tr(n),u),await s.remove(h),console.log(`Stored the Linux key (fingerprint ${p}) in the hub and in your ${s.kind==="keychain"?"login keychain":"keyring"} as "tapster-linux-key".`),d)console.log("The previous key keeps signing next to the new one, so apt and dnf users can fetch the new key. Once they have, run tapster init --rotate linux --finish.");else if(r)console.log("The previous key is not in your keychain, so apt and dnf users must fetch the new key before they can update.")}finally{await j(Ee(a,"..","gpgconf"),"gpgconf",["--kill","all"],{env:l,allowFail:!0}).catch(()=>{return}),Fe(c)}if(!i.packages.some((u)=>!Y(u)&&u.linux))console.log("No package sets linux: true yet; add it to the CLI packages that should ship to apt and dnf.")}async function KO(e,t,n,r,i){let s=await So(e,n,async(a)=>yn(Ee(t,a))?Or(Ee(t,a),"utf8"):null,r,i);for(let a of s.files)await Hv(Ee(t,a.path,".."),{recursive:!0}),await al(Ee(t,a.path),a.content),console.log(a.path===J?`wrote ${J} from the template, ${s.change}; hand edits in it are replaced`:`wrote ${a.path}`);for(let a of s.notes)console.log(a)}async function WO(e){let t=(await me(e)).toLowerCase();return t===""||t==="y"||t==="yes"}async function VO(e,t){let n=async(r)=>{try{return((await e.json("GET",`/repos/${t}/environments/tapster/${r}?per_page=100`))[r]??[]).map((o)=>o.name)}catch(i){if(i instanceof R&&i.status===404)return[];throw i}};return{vars:await n("variables"),secrets:await n("secrets"),private:(await e.getRepo(t)).private}}function qv(e,t){let n=e.indexOf(t);if(n<0)return{value:null,rest:e};return{value:e[n+1]??"",rest:e.filter((r,i)=>i!==n&&i!==n+1)}}var YO="Run tapster init --help for the options.";function JO(e){let[t,n,r,i]=e;if(e.length===0)return{kind:"setup"};if(t==="--rotate"&&e.length===2&&["app","certificate","notary","doorbell","linux"].includes(n??""))return{kind:"rotate",what:n};if(t==="--rotate"&&n==="linux"&&r==="--finish"&&e.length===3)return{kind:"rotate",what:"linux-finish"};if(t==="--doorbell"&&e.length===1)return{kind:"doorbell"};if(t==="--linux"&&e.length===1)return{kind:"linux"};if(t==="--workflow"&&e.length===1)return{kind:"workflow"};if(t==="--sparkle"&&n&&!n.startsWith("-")){if(e.length===2)return{kind:"sparkle",label:n,account:"ed25519"};if(r==="--new"&&e.length===3)return{kind:"sparkle-new",label:n};if(r==="--account"&&i&&e.length===4)return{kind:"sparkle",label:n,account:i}}throw new v(`unknown option ${e.join(" ")}`,YO)}function Bv(e){let t=Ee(e,J);return yn(t)&&rt(Or(t,"utf8"))||10}async function Vv(e){let t=qv(e,"--tapster"),n=qv(t.rest,"--every"),r=t.value,i=n.value===null?null:Number(n.value),o=JO(n.rest);if(i!==null)fo(i);if((r!==null||i!==null)&&o.kind!=="setup"&&o.kind!=="workflow")throw new v("--tapster and --every go only with tapster init or init --workflow","Those are the commands that write the workflow.");let s=process.cwd(),a=await He(s),c=await _t();if(o.kind==="rotate"){if(o.what==="app")return jv(c,a);if(o.what==="certificate")return Mv(a);if(o.what==="notary")return Uv(a);if(o.what==="doorbell")return nv(c,a,Bv(s));if(o.what==="linux-finish")return HO(c,a);return Gv(c,s,a,!0)}if(o.kind==="doorbell")return tv(c,a,Er(s,a),po,Bv(s));if(o.kind==="linux")return Gv(c,s,a,!1);if(o.kind==="sparkle-new")return BO(s,a,o.label);if(o.kind==="sparkle")return qO(c,s,a,o.label,o.account);if(o.kind==="workflow")return GO(c,s,Te(Er(s,a)),r,{every:i,isPrivate:(await c.getRepo(a)).private});let l=await VO(c,a);await ll(c,a,l.private);let p=l.vars.includes("TAPSTER_TEAM_ID")||l.secrets.includes("MACOS_NOTARY_KEY")||await WO("Will this hub sign software for macOS (Mac apps or CLI tools with macOS builds)? [Y/n] "),d=LO(l,p),h=jO(d,p);if(h.length)console.log(`Already done: ${h.join(", ")}. To redo one, run tapster init --rotate <name>.`);for(let f of d){if(f==="app")await UO(a.split("/")[0],a);if(f==="app-key")await jv(c,a);if(f==="certificate")await Mv(a);if(f==="notary")await Uv(a);if(f==="files")await KO(c,s,a,r,{every:i,isPrivate:l.private})}if(!p)console.log("Skipped the Apple credentials. Add them later with tapster init --rotate certificate and tapster init --rotate notary.");console.log(`
|
|
1095
|
+
Done. Review and commit the new files, push, then run tapster add in each project.`)}import{homedir as Z2}from"os";import{randomBytes as a2}from"crypto";var QO=/^(\.tapster|Casks|bucket)\//;async function ul(e,t,n){let r=encodeURIComponent("refs/heads/main"),[i]=await e.json("GET",`/repos/${t}/activity?ref=${r}&actor=${n}&per_page=1`);if(!i)return[`GitHub shows no push by ${n} to main`];let o=i.after.slice(0,7),s=(await e.json("GET",`/repos/${t}/git/ref/heads/main`)).object.sha,a=await e.json("GET",`/repos/${t}/compare/${i.after}...${s}`);if(a.status==="identical")return[];if(a.status!=="ahead")return[`main no longer contains your last push (${o})`];let c=a.files??[];if(c.length>=300)return[`more files changed after your last push (${o}) than GitHub lists`];return c.filter((l)=>!QO.test(l.filename)).map((l)=>`${l.filename} changed after your last push (${o})`)}import{randomBytes as pl}from"crypto";var Yv=async()=>'var Ge,S,qt,ft,re,Gt,Kt,Yt,pt,Ve,Se,Jt,mt,dt,ht,Zn,Fe={},Le=[],Qn=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Ue=Array.isArray;function te(e,n){for(var s in n)e[s]=n[s];return e}function vt(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function es(e,n,s){var o,i,a,r={};for(a in n)a=="key"?o=n[a]:a=="ref"?i=n[a]:r[a]=n[a];if(arguments.length>2&&(r.children=arguments.length>3?Ge.call(arguments,2):s),typeof e=="function"&&e.defaultProps!=null)for(a in e.defaultProps)r[a]===void 0&&(r[a]=e.defaultProps[a]);return je(e,r,o,i,null)}function je(e,n,s,o,i){var a={type:e,props:n,key:s,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i==null?++qt:i,__i:-1,__u:0};return i==null&&S.vnode!=null&&S.vnode(a),a}function C(e){return e.children}function me(e,n){this.props=e,this.context=n}function ue(e,n){if(n==null)return e.__?ue(e.__,e.__i+1):null;for(var s;n<e.__k.length;n++)if((s=e.__k[n])!=null&&s.__e!=null)return s.__e;return typeof e.type=="function"?ue(e):null}function ts(e){if(e.__P&&e.__d){var n=e.__v,s=n.__e,o=[],i=[],a=te({},n);a.__v=n.__v+1,S.vnode&&S.vnode(a),bt(e.__P,a,n,e.__n,e.__P.namespaceURI,32&n.__u?[s]:null,o,s==null?ue(n):s,!!(32&n.__u),i),a.__v=n.__v,a.__.__k[a.__i]=a,tn(o,a,i),n.__e=n.__=null,a.__e!=s&&Xt(a)}}function Xt(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(n){if(n!=null&&n.__e!=null)return e.__e=e.__c.base=n.__e}),Xt(e)}function Ut(e){(!e.__d&&(e.__d=!0)&&re.push(e)&&!Be.__r++||Gt!=S.debounceRendering)&&((Gt=S.debounceRendering)||Kt)(Be)}function Be(){try{for(var e,n=1;re.length;)re.length>n&&re.sort(Yt),e=re.shift(),n=re.length,ts(e)}finally{re.length=Be.__r=0}}function Zt(e,n,s,o,i,a,r,c,p,u,h){var f,l,d,_,T,g,k=o&&o.__k||Le,y=n.length;for(p=ns(s,n,k,p,y),f=0;f<y;f++)(d=s.__k[f])!=null&&(l=d.__i!=-1&&k[d.__i]||Fe,d.__i=f,g=bt(e,d,l,i,a,r,c,p,u,h),_=d.__e,d.ref&&l.ref!=d.ref&&(l.ref&&yt(l.ref,null,d),h.push(d.ref,d.__c||_,d)),T==null&&_!=null&&(T=_),4&d.__u?(p=Qt(d,p,e),l.__e&&(l.__e=null)):typeof d.type=="function"&&g!==void 0?p=g:_&&(p=_.nextSibling),d.__u&=-7);return s.__e=T,p}function ns(e,n,s,o,i){var a,r,c,p,u,h=s.length,f=h,l=0;for(e.__k=Array(i),a=0;a<i;a++)(r=n[a])!=null&&typeof r!="boolean"&&typeof r!="function"?(typeof r=="string"||typeof r=="number"||typeof r=="bigint"||r.constructor==String?r=e.__k[a]=je(null,r,null,null,null):Ue(r)?r=e.__k[a]=je(C,{children:r},null,null,null):r.constructor===void 0&&r.__b>0?r=e.__k[a]=je(r.type,r.props,r.key,r.ref?r.ref:null,r.__v):e.__k[a]=r,p=a+l,r.__=e,r.__b=e.__b+1,c=null,(u=r.__i=ss(r,s,p,f))!=-1&&(f--,(c=s[u])&&(c.__u|=2)),c==null||c.__v==null?(u==-1&&(i>h?l--:i<h&&l++),typeof r.type!="function"&&(r.__u|=4)):u!=p&&(u==p-1?l--:u==p+1?l++:(u>p?l--:l++,r.__u|=4))):e.__k[a]=null;if(f)for(a=0;a<h;a++)(c=s[a])!=null&&(2&c.__u)==0&&(c.__e==o&&(o=ue(c)),sn(c,c));return o}function Qt(e,n,s){var o,i;if(typeof e.type=="function"){for(o=e.__k,i=0;o&&i<o.length;i++)o[i]&&(o[i].__=e,n=Qt(o[i],n,s));return n}e.__e!=n&&(n&&e.type&&!n.parentNode&&(n=ue(e)),n=s.insertBefore(e.__e,n||null));do n=n&&n.nextSibling;while(n!=null&&n.nodeType==8);return n}function ss(e,n,s,o){var i,a,r,{key:c,type:p}=e,u=n[s],h=u!=null&&(2&u.__u)==0;if(u===null&&c==null||h&&c==u.key&&p==u.type)return s;if(o>(h?1:0)){for(i=s-1,a=s+1;i>=0||a<n.length;)if((u=n[r=i>=0?i--:a++])!=null&&(2&u.__u)==0&&c==u.key&&p==u.type)return r}return-1}function Wt(e,n,s){n[0]=="-"?e.setProperty(n,s==null?"":s):e[n]=s==null?"":typeof s!="number"||Qn.test(n)?s:s+"px"}function Re(e,n,s,o,i){var a,r;e:if(n=="style")if(typeof s=="string")e.style.cssText=s;else{if(typeof o=="string"&&(e.style.cssText=o=""),o)for(n in o)s&&n in s||Wt(e.style,n,"");if(s)for(n in s)o&&s[n]==o[n]||Wt(e.style,n,s[n])}else if(n[0]=="o"&&n[1]=="n")a=n!=(n=n.replace(Jt,"$1")),r=n.toLowerCase(),n=r in e||n=="onFocusOut"||n=="onFocusIn"?r.slice(2):n.slice(2),e.l||(e.l={}),e.l[n+a]=s,s?o?s[Se]=o[Se]:(s[Se]=mt,e.addEventListener(n,a?ht:dt,a)):e.removeEventListener(n,a?ht:dt,a);else{if(i=="http://www.w3.org/2000/svg")n=n.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(n!="width"&&n!="height"&&n!="href"&&n!="list"&&n!="form"&&n!="tabIndex"&&n!="download"&&n!="rowSpan"&&n!="colSpan"&&n!="role"&&n!="popover"&&n in e)try{e[n]=s==null?"":s;break e}catch(c){}typeof s=="function"||(s==null||s===!1&&n[4]!="-"?e.removeAttribute(n):e.setAttribute(n,n=="popover"&&s==1?"":s))}}function zt(e){return function(n){if(this.l){var s=this.l[n.type+e];if(n[Ve]==null)n[Ve]=mt++;else if(n[Ve]<s[Se])return;return s(S.event?S.event(n):n)}}}function bt(e,n,s,o,i,a,r,c,p,u){var h,f,l,d,_,T,g,k,y,H,b,w,B,ee,ae,xe,K=n.type;if(n.constructor!==void 0)return null;128&s.__u&&(p=!!(32&s.__u),a=[c=n.__e=s.__e]),(h=S.__b)&&h(n);e:if(typeof K=="function"){f=r.length;try{if(y=n.props,H=K.prototype&&K.prototype.render,b=(h=K.contextType)&&o[h.__c],w=h?b?b.props.value:h.__:o,s.__c?k=(l=n.__c=s.__c).__=l.__E:(H?n.__c=l=new K(y,w):(n.__c=l=new me(y,w),l.constructor=K,l.render=as),b&&b.sub(l),l.state||(l.state={}),l.__n=o,d=l.__d=!0,l.__h=[],l._sb=[]),H&&l.__s==null&&(l.__s=l.state),H&&K.getDerivedStateFromProps!=null&&(l.__s==l.state&&(l.__s=te({},l.__s)),te(l.__s,K.getDerivedStateFromProps(y,l.__s))),_=l.props,T=l.state,l.__v=n,d)H&&K.getDerivedStateFromProps==null&&l.componentWillMount!=null&&l.componentWillMount(),H&&l.componentDidMount!=null&&l.__h.push(l.componentDidMount);else{if(H&&K.getDerivedStateFromProps==null&&y!==_&&l.componentWillReceiveProps!=null&&l.componentWillReceiveProps(y,w),n.__v==s.__v||!l.__e&&l.shouldComponentUpdate!=null&&l.shouldComponentUpdate(y,l.__s,w)===!1){n.__v!=s.__v&&(l.props=y,l.state=l.__s,l.__d=!1),n.__e=s.__e,n.__k=s.__k,n.__k.some(function(X){X&&(X.__=n)}),Le.push.apply(l.__h,l._sb),l._sb=[],l.__h.length&&r.push(l),c=ue(s);break e}l.componentWillUpdate!=null&&l.componentWillUpdate(y,l.__s,w),H&&l.componentDidUpdate!=null&&l.__h.push(function(){l.componentDidUpdate(_,T,g)})}if(l.context=w,l.props=y,l.__P=e,l.__e=!1,B=S.__r,ee=0,H)l.state=l.__s,l.__d=!1,B&&B(n),h=l.render(l.props,l.state,l.context),Le.push.apply(l.__h,l._sb),l._sb=[];else do l.__d=!1,B&&B(n),h=l.render(l.props,l.state,l.context),l.state=l.__s;while(l.__d&&++ee<25);l.state=l.__s,l.getChildContext!=null&&(o=te(te({},o),l.getChildContext())),H&&!d&&l.getSnapshotBeforeUpdate!=null&&(g=l.getSnapshotBeforeUpdate(_,T)),ae=h!=null&&h.type===C&&h.key==null?nn(h.props.children):h,c=Zt(e,Ue(ae)?ae:[ae],n,s,o,i,a,r,c,p,u),l.base=n.__e,n.__u&=-161,l.__h.length&&r.push(l),k&&(l.__E=l.__=null)}catch(X){if(r.length=f,n.__v=null,p||a!=null){if(X.then){for(n.__u|=p?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;a!=null&&(a[a.indexOf(c)]=null),n.__e=c}else if(a!=null)for(xe=a.length;xe--;)vt(a[xe])}else n.__e=s.__e;n.__k==null&&(n.__k=s.__k||[]),X.then||en(n),S.__e(X,n,s)}}else a==null&&n.__v==s.__v?(n.__k=s.__k,n.__e=s.__e):c=n.__e=os(s.__e,n,s,o,i,a,r,p,u);return(h=S.diffed)&&h(n),128&n.__u?void 0:c}function en(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(en))}function tn(e,n,s){for(var o=0;o<s.length;o++)yt(s[o],s[++o],s[++o]);S.__c&&S.__c(n,e),e.some(function(i){try{e=i.__h,i.__h=[],e.some(function(a){a.call(i)})}catch(a){S.__e(a,i.__v)}})}function nn(e){return typeof e!="object"||e==null||e.__b>0?e:Ue(e)?e.map(nn):e.constructor!==void 0?null:te({},e)}function os(e,n,s,o,i,a,r,c,p){var u,h,f,l,d,_,T,g=s.props||Fe,{props:k,type:y}=n;if(y=="svg"?i="http://www.w3.org/2000/svg":y=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),a!=null){for(u=0;u<a.length;u++)if((d=a[u])&&"setAttribute"in d==!!y&&(y?d.localName==y:d.nodeType==3)){e=d,a[u]=null;break}}if(e==null){if(y==null)return document.createTextNode(k);e=document.createElementNS(i,y,k.is&&k),c&&(S.__m&&S.__m(n,a),c=!1),a=null}if(y==null)g===k||c&&e.data==k||(e.data=k);else{if(a=y=="textarea"&&k.defaultValue!=null?null:a&&Ge.call(e.childNodes),!c&&a!=null)for(g={},u=0;u<e.attributes.length;u++)g[(d=e.attributes[u]).name]=d.value;for(u in g)d=g[u],u=="dangerouslySetInnerHTML"?f=d:u=="children"||(u in k)||u=="value"&&("defaultValue"in k)||u=="checked"&&("defaultChecked"in k)||Re(e,u,null,d,i);for(u in k)d=k[u],u=="children"?l=d:u=="dangerouslySetInnerHTML"?h=d:u=="value"?_=d:u=="checked"?T=d:c&&typeof d!="function"||g[u]===d||Re(e,u,d,g[u],i);if(h)c||f&&(h.__html==f.__html||h.__html==e.innerHTML)||(e.innerHTML=h.__html),n.__k=[];else if(f&&(e.innerHTML=""),Zt(n.type=="template"?e.content:e,Ue(l)?l:[l],n,s,o,y=="foreignObject"?"http://www.w3.org/1999/xhtml":i,a,r,a?a[0]:s.__k&&ue(s,0),c,p),a!=null)for(u=a.length;u--;)vt(a[u]);c&&y!="textarea"||(u="value",y=="progress"&&_==null?e.removeAttribute("value"):_!=null&&(_!==e[u]||y=="progress"&&!_||y=="option"&&_!=g[u])&&Re(e,u,_,g[u],i),u="checked",T!=null&&T!=e[u]&&Re(e,u,T,g[u],i))}return e}function yt(e,n,s){try{if(typeof e=="function"){var o=typeof e.__u=="function";o&&e.__u(),o&&n==null||(e.__u=e(n))}else e.current=n}catch(i){S.__e(i,s)}}function sn(e,n,s){var o,i;if(S.unmount&&S.unmount(e),(o=e.ref)&&(o.current&&o.current!=e.__e||yt(o,null,n)),(o=e.__c)!=null){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(a){S.__e(a,n)}o.base=o.__P=o.__n=null}if(o=e.__k)for(i=0;i<o.length;i++)o[i]&&sn(o[i],n,s||typeof e.type!="function");s||vt(e.__e),e.__c=e.__=e.__e=void 0}function as(e,n,s){return this.constructor(e,s)}function on(e,n,s){var o,i,a,r;n==document&&(n=document.documentElement),S.__&&S.__(e,n),i=(o=typeof s=="function")?null:s&&s.__k||n.__k,a=[],r=[],bt(n,e=(!o&&s||n).__k=es(C,null,[e]),i||Fe,Fe,n.namespaceURI,!o&&s?[s]:i?null:n.firstChild?Ge.call(n.childNodes):null,a,!o&&s?s:i?i.__e:n.firstChild,o,r),tn(a,e,r),e.props.children=null}Ge=Le.slice,S={__e:function(e,n,s,o){for(var i,a,r;n=n.__;)if((i=n.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),r=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,o||{}),r=i.__d),r)return i.__E=i}catch(c){e=c}throw e}},qt=0,ft=function(e){return e!=null&&e.constructor===void 0},me.prototype.setState=function(e,n){var s;s=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=te({},this.state),typeof e=="function"&&(e=e(te({},s),this.props)),e&&te(s,e),e!=null&&this.__v&&(n&&this._sb.push(n),Ut(this))},me.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Ut(this))},me.prototype.render=C,re=[],Kt=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Yt=function(e,n){return e.__v.__b-n.__v.__b},Be.__r=0,pt=Math.random().toString(8),Ve="__d"+pt,Se="__a"+pt,Jt=/(PointerCapture)$|Capture$/i,mt=0,dt=zt(!1),ht=zt(!0),Zn=0;var Ce,I,_t,an,ze=0,fn=[],M=S,{__b:rn,__r:ln,diffed:cn,__c:un,unmount:pn,__:dn}=M;function wt(e,n){M.__h&&M.__h(I,e,ze||n),ze=0;var s=I.__H||(I.__H={__:[],__h:[]});return e>=s.__.length&&s.__.push({}),s.__[e]}function m(e){return ze=1,is(vn,e)}function is(e,n,s){var o=wt(Ce++,2);if(o.t=e,!o.__c&&(o.__=[s?s(n):vn(void 0,n),function(c){var p=o.__N?o.__N[0]:o.__[0],u=o.t(p,c);p!==u&&(o.__N=[u,o.__[1]],o.__c.setState({}))}],o.__c=I,!I.__f)){var i=function(c,p,u){if(!o.__c.__H)return!0;var h=!1,f=o.__c.props!==c;if(o.__c.__H.__.some(function(d){if(d.__N){h=!0;var _=d.__[0];d.__=d.__N,d.__N=void 0,_!==d.__[0]&&(f=!0)}}),a){var l=a.call(this,c,p,u);return h?l||f:l}return!h||f};I.__f=!0;var a=I.shouldComponentUpdate,r=I.componentWillUpdate;I.componentWillUpdate=function(c,p,u){if(this.__e){var h=a;a=void 0,i(c,p,u),a=h}r&&r.call(this,c,p,u)},I.shouldComponentUpdate=i}return o.__N||o.__}function U(e,n){var s=wt(Ce++,3);!M.__s&&mn(s.__H,n)&&(s.__=e,s.u=n,I.__H.__h.push(s))}function Te(e){return ze=5,qe(function(){return{current:e}},[])}function qe(e,n){var s=wt(Ce++,7);return mn(s.__H,n)&&(s.__=e(),s.__H=n,s.__h=e),s.__}function rs(){for(var e;e=fn.shift();){var n=e.__H;if(e.__P&&n)try{n.__h.some(We),n.__h.some(gt),n.__h=[]}catch(s){n.__h=[],M.__e(s,e.__v)}}}M.__b=function(e){I=null,rn&&rn(e)},M.__=function(e,n){e&&n.__k&&n.__k.__m&&(e.__m=n.__k.__m),dn&&dn(e,n)},M.__r=function(e){ln&&ln(e),Ce=0;var n=(I=e.__c).__H;n&&(_t===I?(n.__h=[],I.__h=[],n.__.some(function(s){s.__N&&(s.__=s.__N),s.u=s.__N=void 0})):(n.__h.some(We),n.__h.some(gt),n.__h=[],Ce=0)),_t=I},M.diffed=function(e){cn&&cn(e);var n=e.__c;n&&n.__H&&(n.__H.__h.length&&(fn.push(n)!==1&&an===M.requestAnimationFrame||((an=M.requestAnimationFrame)||ls)(rs)),n.__H.__.some(function(s){s.u&&(s.__H=s.u,s.u=void 0)})),_t=I=null},M.__c=function(e,n){n.some(function(s){try{s.__h.some(We),s.__h=s.__h.filter(function(o){return!o.__||gt(o)})}catch(o){n.some(function(i){i.__h&&(i.__h=[])}),n=[],M.__e(o,s.__v)}}),un&&un(e,n)},M.unmount=function(e){pn&&pn(e);var n,s=e.__c;s&&s.__H&&(s.__H.__.some(function(o){try{We(o)}catch(i){n=i}}),s.__H=void 0,n&&M.__e(n,s.__v))};var hn=typeof requestAnimationFrame=="function";function ls(e){var n,s=function(){clearTimeout(o),hn&&cancelAnimationFrame(n),setTimeout(e)},o=setTimeout(s,35);hn&&(n=requestAnimationFrame(s))}function We(e){var n=I,s=e.__c;typeof s=="function"&&(e.__c=void 0,s()),I=n}function gt(e){var n=I;e.__c=e.__(),I=n}function mn(e,n){return!e||e.length!==n.length||n.some(function(s,o){return s!==e[o]})}function vn(e,n){return typeof n=="function"?n(e):n}var cs=Symbol.for("preact-signals");function Xe(){if(!(ne>1)){var e,n=!1;(function(){var i=Ye;Ye=void 0;while(i!==void 0){var a=i.S;if(a.v===i.v){for(var r=a.t;r!==void 0;r=r.x)if(r.i===i.i)r.i=a.i}i=i.o}})();while(He!==void 0){var s=He;He=void 0,Ke++;while(s!==void 0){var o=s.u;if(s.u=void 0,s.f&=-3,!(8&s.f)&&yn(s))try{s.c()}catch(i){if(!n)e=i,n=!0}s=o}}if(Ke=0,ne--,n)throw e}else ne--}function xt(e){if(ne>0)return e();kt=++us,ne++;try{return e()}finally{Xe()}}var Ae,P=void 0;function Pe(e){var n=P,s=Ae;P=void 0,Ae=void 0;try{return e()}finally{P=n,Ae=s}}var He=void 0,ne=0,Ke=0,us=0,kt=0,Ye=void 0,Je=0;function bn(e){if(P!==void 0){var n=e.n;if(n===void 0||n.t!==P){if(n={i:0,S:e,p:P.s,n:void 0,t:P,e:void 0,x:void 0,r:n},P.s!==void 0)P.s.n=n;if(P.s=n,e.n=n,32&P.f)e.S(n);return n}else if(n.i===-1){if(n.i=0,n.n!==void 0){if(n.n.p=n.p,n.p!==void 0)n.p.n=n.n;n.p=P.s,n.n=void 0,P.s.n=n,P.s=n}return n}}}function O(e,n){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=n==null?void 0:n.watched,this.Z=n==null?void 0:n.unwatched,this.name=n==null?void 0:n.name}O.prototype.brand=cs;O.prototype.h=function(){return!0};O.prototype.S=function(e){var n=this,s=this.t;if(s!==e&&e.e===void 0)if(e.x=s,this.t=e,s!==void 0)s.e=e;else Pe(function(){var o;(o=n.W)==null||o.call(n)})};O.prototype.U=function(e){var n=this;if(this.t!==void 0){var{e:s,x:o}=e;if(s!==void 0)s.x=o,e.e=void 0;if(o!==void 0)o.e=s,e.x=void 0;if(e===this.t){if(this.t=o,o===void 0)Pe(function(){var i;(i=n.Z)==null||i.call(n)})}}};O.prototype.subscribe=function(e){var n=this;return de(function(){var s=n.value;Pe(function(){return e(s)})},{name:"sub"})};O.prototype.valueOf=function(){return this.value};O.prototype.toString=function(){return this.value+""};O.prototype.toJSON=function(){return this.value};O.prototype.peek=function(){var e=this;return Pe(function(){return e.value})};Object.defineProperty(O.prototype,"value",{get:function(){var e=bn(this);if(e!==void 0)e.i=this.i;return this.v},set:function(e){if(e!==this.v){if(Ke>100)throw Error("Cycle detected");(function(s){if(ne!==0&&Ke===0){if(s.l!==kt)s.l=kt,Ye={S:s,v:s.v,i:s.i,o:Ye}}})(this),this.v=e,this.i++,Je++,ne++;try{for(var n=this.t;n!==void 0;n=n.x)n.t.N()}finally{Xe()}}}});function E(e,n){return new O(e,n)}function yn(e){for(var n=e.s;n!==void 0;n=n.n)if(n.S.i!==n.i||!n.S.h()||n.S.i!==n.i)return!0;return!1}function _n(e){for(var n=e.s;n!==void 0;n=n.n){var s=n.S.n;if(s!==void 0)n.r=s;if(n.S.n=n,n.i=-1,n.n===void 0){e.s=n;break}}}function gn(e){var n=e.s,s=void 0;while(n!==void 0){var o=n.p;if(n.i===-1){if(n.S.U(n),o!==void 0)o.n=n.n;if(n.n!==void 0)n.n.p=o}else s=n;if(n.S.n=n.r,n.r!==void 0)n.r=void 0;n=o}e.s=s}function pe(e,n){O.call(this,void 0,n),this.x=e,this.s=void 0,this.g=Je-1,this.f=4}pe.prototype=new O;pe.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32)return!0;if(this.f&=-5,this.g===Je)return!0;if(this.g=Je,this.f|=1,this.i>0&&!yn(this))return this.f&=-2,!0;var e=P;try{_n(this),P=this;var n=this.x();if(16&this.f||this.v!==n||this.i===0)this.v=n,this.f&=-17,this.i++}catch(s){this.v=s,this.f|=16,this.i++}return P=e,gn(this),this.f&=-2,!0};pe.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var n=this.s;n!==void 0;n=n.n)n.S.S(n)}O.prototype.S.call(this,e)};pe.prototype.U=function(e){if(this.t!==void 0){if(O.prototype.U.call(this,e),this.t===void 0){this.f&=-33;for(var n=this.s;n!==void 0;n=n.n)n.S.U(n)}}};pe.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}};Object.defineProperty(pe.prototype,"value",{get:function(){if(1&this.f)throw Error("Cycle detected");var e=bn(this);if(this.h(),e!==void 0)e.i=this.i;if(16&this.f)throw this.v;return this.v}});function Ze(e,n){return new pe(e,n)}function wn(e){var n=e.m;if(e.m=void 0,typeof n=="function"){ne++;var s=P;P=void 0;try{n()}catch(o){throw e.f&=-2,e.f|=8,St(e),o}finally{P=s,Xe()}}}function St(e){for(var n=e.s;n!==void 0;n=n.n)n.S.U(n);e.x=void 0,e.s=void 0,wn(e)}function ps(e){if(P!==this)throw Error("Out-of-order effect");if(gn(this),P=e,this.f&=-2,8&this.f)St(this);Xe()}function ve(e,n){if(this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=n==null?void 0:n.name,Ae)Ae.push(this)}ve.prototype.c=function(){var e=this.S();try{if(8&this.f)return;if(this.x===void 0)return;var n=this.x();if(typeof n=="function")this.m=n}finally{e()}};ve.prototype.S=function(){if(1&this.f)throw Error("Cycle detected");this.f|=1,this.f&=-9,wn(this),_n(this),ne++;var e=P;return P=this,ps.bind(this,e)};ve.prototype.N=function(){if(!(2&this.f))this.f|=2,this.u=He,He=this};ve.prototype.d=function(){if(this.f|=8,!(1&this.f))St(this)};ve.prototype.dispose=function(){this.d()};function de(e,n){var s=new ve(e,n);try{s.c()}catch(i){throw s.d(),i}var o=s.d.bind(s);return o[Symbol.dispose]=o,o}var kn,et,Qe,ds=typeof window<"u"&&!!window.__PREACT_SIGNALS_DEVTOOLS__;var xn=[];de(function(){kn=this.N})();function be(e,n){S[e]=n.bind(null,S[e]||function(){})}function Ne(e){if(Qe){var n=Qe;Qe=void 0,n()}Qe=e&&e.S()}function Sn(e){var n=this,s=e.data,o=fs(s);o.name="ReactiveDom",o.value=s;var i=qe(function(){var c=n,p=n.__v;while(p=p.__)if(p.__c){p.__c.__$f|=4;break}var u=Ze(function(){var d=o.value.value;return d===0?0:d===!0?"":d||""}),h=Ze(function(){return!Array.isArray(u.value)&&!ft(u.value)}),f=de(function(){if(this.N=Cn,h.value){var d=u.value;if(c.__v&&c.__v.__e&&c.__v.__e.nodeType===3)c.__v.__e.data=d}}),l=n.__$u.d;return n.__$u.d=function(){f(),l.call(this)},[h,u]},[]),a=i[0],r=i[1];return a.value?r.peek():r.value}Sn.displayName="ReactiveTextNode";Object.defineProperties(O.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:Sn},props:{configurable:!0,get:function(){var e=this;return{data:{get value(){return e.value}}}}},__b:{configurable:!0,value:1}});be("__b",function(e,n){if(Ne(),et=void 0,typeof n.type=="string"){var s,o=n.props;for(var i in o)if(i!=="children"){var a=o[i];if(a instanceof O){if(!s)n.__np=s={};s[i]=a,o[i]=a.peek()}}}e(n)});be("__r",function(e,n){if(e(n),n.type!==C){Ne();var s,o=n.__c;if(o){if(o.__$f&=-2,(s=o.__$u)===void 0)o.__$u=s=function(i,a){var r;return de(function(){r=this},{name:a}),r.c=i,r}(function(i){return function(){var a;if(ds)(a=this.y)==null||a.call(this);i.__$f|=1,i.setState({})}}(o),typeof n.type=="function"?n.type.displayName||n.type.name:"")}et=o,Ne(s)}});be("__e",function(e,n,s,o){Ne(),et=void 0,e(n,s,o)});be("diffed",function(e,n){Ne(),et=void 0;var s;if(typeof n.type=="string"&&(s=n.__e)){var{__np:o,props:i}=n,a=s.U;if(a)for(var r in a){var c=a[r];if(!(c===void 0||o&&(r in o)))c.d(),a[r]=void 0}if(o){if(!a)a={},s.U=a;for(var p in o){var u=a[p],h=o[p];if(u===void 0)u=hs(s,p,h,i),a[p]=u;else u.o(h,i)}}}e(n)});function hs(e,n,s,o){var i=n in e&&e.ownerSVGElement===void 0,a=E(s);return{o:function(r,c){a.value=r,o=c},d:de(function(){this.N=Cn;var r=a.value.value;if(o[n]!==r)if(o[n]=r,i)e[n]=r;else if(r!=null&&(r!==!1||n[4]==="-"))e.setAttribute(n,r);else e.removeAttribute(n)})}}be("unmount",function(e,n){if(typeof n.type=="string"){var s=n.__e;if(s){var o=s.U;if(o){s.U=void 0;for(var i in o){var a=o[i];if(a)a.d()}}}var r=n.__np;if(r){var c=n.props;for(var p in r)c[p]=r[p]}n.__np=void 0}else{var u=n.__c;if(u){u.__$f|=8;var h=u.__$u;if(h)u.__$u=void 0,h.d()}}e(n)});be("__h",function(e,n,s,o){if(o<3)n.__$f|=2;e(n,s,o)});me.prototype.shouldComponentUpdate=function(e,n){if(this.__R)return!0;var s=this.__$u,o=s&&s.s!==void 0;for(var i in n)return!0;if(this.__f||typeof this.u=="boolean"&&this.u===!0){var a=2&this.__$f;if(!(o||a||4&this.__$f))return!0;if(1&this.__$f)return!0}else{if(!(o||4&this.__$f))return!0;if(3&this.__$f)return!0}for(var r in e)if(r!=="__source"&&e[r]!==this.props[r])return!0;for(var c in this.props)if(!(c in e))return!0;return!1};function fs(e,n){return qe(function(){return E(e,n)},[])}var ms=function(e){queueMicrotask(function(){queueMicrotask(e)})};function vs(){xt(function(){var e;while(e=xn.shift())kn.call(e)})}function Cn(){if(xn.push(this)===1)(S.requestAnimationFrame||ms)(vs)}class se extends Error{problem;status;constructor(e,n){super(e.reason);this.problem=e;this.status=n}}var Ct={get:()=>{try{return sessionStorage.getItem("tapster.session")}catch{return null}},set:(e)=>{try{if(e===null)sessionStorage.removeItem("tapster.session");else sessionStorage.setItem("tapster.session",e)}catch{return}}},$e=Ct.get(),Tn=()=>{},An=()=>$e!==null,Hn=(e)=>{Tn=e};async function Pn(e){let n=await fetch("/api/claim",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({code:e})}),s=await n.json().catch(()=>({}));if(!n.ok||!s.token)throw new se(s.error??{reason:"the link did not work",fix:"Press Enter in the terminal that runs tapster setup for a fresh link."},n.status);$e=s.token,Ct.set($e)}async function Nn(e,n,s){let o={authorization:`Bearer ${$e??""}`},i;if(s instanceof FormData)i=s;else if(s!==void 0)o["content-type"]="application/json",i=JSON.stringify(s);let a;try{a=await fetch(n,{method:e,headers:o,body:i})}catch{throw new se({reason:"tapster setup is not answering",fix:"Check that tapster setup still runs in your terminal. If it stopped, start it again with bunx @doguyilmaz/tapster setup."},0)}let r=await a.json().catch(()=>null);if(a.status===401)$e=null,Ct.set(null),Tn();if(!a.ok||r===null)throw new se(r?.error??{reason:`tapster setup answered ${a.status}`,fix:"Reload the page and try again."},a.status);return r}var Z=(e)=>Nn("GET",e),A=(e,n)=>Nn("POST",e,n??{});var $n="tapster.hub",Tt=(e)=>{try{return localStorage.getItem(e)}catch{return null}},nt=(e,n)=>{try{if(n===null)localStorage.removeItem(e);else localStorage.setItem(e,n)}catch{return}},In=Tt,he=E(location.pathname),Me=E(null),oe=E(null),Ie=E(null),At=E(null),V=E(Tt($n)),le=E(null),tt=E(!1),_e=E(null),ye=E(null);function ce(e,n=!1){if(n)history.replaceState(null,"",e);else history.pushState(null,"",e);he.value=location.pathname,window.scrollTo({top:0})}addEventListener("popstate",()=>{he.value=location.pathname});function Y(e,n){ye.value={tone:e,text:n},setTimeout(()=>{if(ye.value?.text===n)ye.value=null},5000)}var R=(e)=>e instanceof se?e.problem:{reason:"something went wrong",fix:"Reload the page and try again."};async function st(){try{oe.value=await Z("/api/account"),Ie.value=null}catch(e){Ie.value=R(e)}}async function En(){let e=await Z("/api/hubs");At.value=e.hubs}function ot(e){if(e!==V.value)Q.value=null;if(V.value=e,nt($n,e),le.value=null,_e.value=null,e)W()}async function W(){let e=V.value;if(!e)return;tt.value=!0;try{let n=await Z(`/api/hub?hub=${encodeURIComponent(e)}`);if(V.value===e)le.value=n,_e.value=null}catch(n){if(V.value===e)_e.value=R(n)}finally{tt.value=!1}}var Mn=(e)=>`tapster.mac.${e}`,Ee=E({});function Dn(e){return Ee.value[e]??(Tt(Mn(e))||null)}function Ht(e,n){nt(Mn(e),n),Ee.value={...Ee.value,[e]:n}}var De=E(null),Q=E(null);function at(e){let n=Me.value?.home;if(!n)return e;return e===n?"~":e.startsWith(`${n}/`)?`~${e.slice(n.length)}`:e}var bs=0;function t(e,n,s,o,i,a){n||(n={});var r,c,p=n;if("ref"in p)for(c in p={},n)c=="ref"?r=n[c]:p[c]=n[c];var u={type:e,props:p,key:s,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--bs,__i:-1,__u:0,__source:i,__self:a};if(typeof e=="function"&&(r=e.defaultProps))for(c in r)p[c]===void 0&&(p[c]=r[c]);return S.vnode&&S.vnode(u),u}var ys={check:t("path",{d:"M20 6 9 17l-5-5"},void 0,!1,void 0,this),x:t("path",{d:"M18 6 6 18M6 6l12 12"},void 0,!1,void 0,this),alert:t("path",{d:"M12 9v4M12 17h.01M10.3 3.9 1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0z"},void 0,!1,void 0,this),info:t(C,{children:[t("circle",{cx:"12",cy:"12",r:"10"},void 0,!1,void 0,this),t("path",{d:"M12 16v-4M12 8h.01"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),lock:t(C,{children:[t("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2"},void 0,!1,void 0,this),t("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),copy:t(C,{children:[t("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"},void 0,!1,void 0,this),t("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),external:t("path",{d:"M15 3h6v6M10 14 21 3M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"},void 0,!1,void 0,this),file:t("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8zM14 2v6h6"},void 0,!1,void 0,this),folder:t("path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.7-.9L9.6 3.9A2 2 0 0 0 7.9 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2z"},void 0,!1,void 0,this),refresh:t("path",{d:"M21 12a9 9 0 1 1-3-6.7L21 8M21 3v5h-5"},void 0,!1,void 0,this),loader:t("path",{d:"M21 12a9 9 0 1 1-6.2-8.6"},void 0,!1,void 0,this),down:t("path",{d:"m6 9 6 6 6-6"},void 0,!1,void 0,this),right:t("path",{d:"m9 18 6-6-6-6"},void 0,!1,void 0,this),arrow:t("path",{d:"M5 12h14M12 5l7 7-7 7"},void 0,!1,void 0,this),eye:t(C,{children:[t("path",{d:"M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12z"},void 0,!1,void 0,this),t("circle",{cx:"12",cy:"12",r:"3"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),play:t("path",{d:"M7 4v16l13-8z"},void 0,!1,void 0,this),shield:t("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"},void 0,!1,void 0,this),pr:t(C,{children:[t("circle",{cx:"18",cy:"18",r:"3"},void 0,!1,void 0,this),t("circle",{cx:"6",cy:"6",r:"3"},void 0,!1,void 0,this),t("path",{d:"M13 6h3a2 2 0 0 1 2 2v7M6 9v12"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),package:t("path",{d:"M21 16V8a2 2 0 0 0-1-1.7l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.7l7 4a2 2 0 0 0 2 0l7-4a2 2 0 0 0 1-1.7zM3.3 7 12 12l8.7-5M12 22V12"},void 0,!1,void 0,this),upload:t("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M17 8l-5-5-5 5M12 3v12"},void 0,!1,void 0,this),key:t(C,{children:[t("circle",{cx:"7.5",cy:"15.5",r:"5.5"},void 0,!1,void 0,this),t("path",{d:"m21 2-9.6 9.6M15.5 7.5l3 3L22 7l-3-3"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),power:t("path",{d:"M18.4 6.6a9 9 0 1 1-12.8 0M12 2v10"},void 0,!1,void 0,this),plus:t("path",{d:"M12 5v14M5 12h14"},void 0,!1,void 0,this),circle:t("circle",{cx:"12",cy:"12",r:"9"},void 0,!1,void 0,this),git:t(C,{children:[t("circle",{cx:"12",cy:"12",r:"3"},void 0,!1,void 0,this),t("path",{d:"M12 3v6M12 15v6"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)};function v({name:e,spin:n,label:s}){return t("svg",{class:`icon${n?" spin":""}`,viewBox:"0 0 24 24","aria-hidden":s?void 0:"true",role:s?"img":void 0,"aria-label":s,children:ys[e]},void 0,!1,void 0,this)}function j({label:e="Working"}){return t(v,{name:"loader",spin:!0,label:e},void 0,!1,void 0,this)}var _s={keys:"lock",ok:"check",warn:"alert",error:"alert",info:"info"};function x({tone:e="info",title:n,children:s}){return t("div",{class:`note ${e}`,role:e==="error"?"alert":void 0,children:[t(v,{name:_s[e]},void 0,!1,void 0,this),t("div",{children:[n&&t("strong",{children:n},void 0,!1,void 0,this),s]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function N({problem:e}){if(!e)return null;let n=e.reason.charAt(0).toUpperCase()+e.reason.slice(1);return t(x,{tone:"error",title:`${n}.`,children:t("span",{children:e.fix},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function F({tone:e,children:n}){return t("span",{class:`badge${e?` ${e}`:""}`,children:n},void 0,!1,void 0,this)}function Pt({text:e,label:n="Copy"}){let[s,o]=m(!1);return t("button",{type:"button",class:"btn secondary small",onClick:async()=>{try{await navigator.clipboard.writeText(e),o(!0),setTimeout(()=>o(!1),1600)}catch{o(!1)}},children:[t(v,{name:s?"check":"copy"},void 0,!1,void 0,this),s?"Copied":n]},void 0,!0,void 0,this)}function z({text:e}){return t("div",{class:"cmd",children:[t("code",{children:e},void 0,!1,void 0,this),t(Pt,{text:e},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function q({href:e,children:n,class:s="btn secondary"}){return t("a",{class:s,href:e,target:"_blank",rel:"noopener noreferrer",children:[n,t(v,{name:"external"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Nt(e){let[n,s]=m(!1),o=(i)=>e.onFile(i&&i[0]?i[0]:null);return t("div",{class:"field",children:[t("span",{class:"label",id:`${e.name}-label`,children:e.label},void 0,!1,void 0,this),t("label",{class:`drop${n?" over":""}${e.file?" has":""}`,onDragOver:(i)=>{i.preventDefault(),s(!0)},onDragLeave:()=>s(!1),onDrop:(i)=>{i.preventDefault(),s(!1),o(i.dataTransfer?.files??null)},children:[t("input",{type:"file",name:e.name,accept:e.accept,"aria-labelledby":`${e.name}-label`,onChange:(i)=>o(i.currentTarget.files)},void 0,!1,void 0,this),t(v,{name:e.file?"check":"upload"},void 0,!1,void 0,this),t("span",{children:e.file?t(C,{children:[t("strong",{class:"mono",children:e.file.name},void 0,!1,void 0,this),t("span",{class:"muted small",children:[" (",Math.max(1,Math.round(e.file.size/1024))," KB). Drop or choose another file to replace it."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):t(C,{children:[t("strong",{children:"Drop the file here"},void 0,!1,void 0,this)," ",t("span",{class:"muted",children:"or click to choose it"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("span",{class:"hint",children:e.hint},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function $t({name:e,label:n,hint:s,autoComplete:o="current-password"}){let[i,a]=m(!1);return t("div",{class:"field",children:[t("label",{for:e,children:n},void 0,!1,void 0,this),t("div",{class:"with-toggle",children:[t("input",{class:"input",id:e,name:e,type:i?"text":"password",autoComplete:o,spellcheck:!1,autoCapitalize:"off",autoCorrect:"off"},void 0,!1,void 0,this),t("button",{type:"button",class:"btn quiet small",onClick:()=>a(!i),"aria-pressed":i,children:i?"Hide":"Show"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),s&&t("span",{class:"hint",children:s},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function ge({name:e,label:n,hint:s,value:o,placeholder:i,mono:a,autoComplete:r="off",onInput:c}){return t("div",{class:"field",children:[t("label",{for:e,children:n},void 0,!1,void 0,this),t("input",{class:`input${a?" mono":""}`,id:e,name:e,value:o,placeholder:i,autoComplete:r,spellcheck:!1,autoCapitalize:"off",autoCorrect:"off",onInput:c?(p)=>c(p.currentTarget.value):void 0},void 0,!1,void 0,this),s&&t("span",{class:"hint",children:s},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function L({busy:e,children:n,...s}){return t("button",{...s,disabled:e||s.disabled,"aria-busy":e,children:[e&&t(j,{},void 0,!1,void 0,this),n]},void 0,!0,void 0,this)}function It({text:e}){return t("div",{class:"gate",children:t("div",{class:"row muted",role:"status",children:[t(j,{},void 0,!1,void 0,this),t("span",{children:e},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function we({title:e,children:n}){return t(C,{children:[t("div",{class:"stripe"},void 0,!1,void 0,this),t("div",{class:"gate",children:t("div",{class:"card",children:[t("img",{class:"mascot",src:"/logo.webp",alt:"",width:"112",height:"112"},void 0,!1,void 0,this),t("h1",{class:"title",children:e},void 0,!1,void 0,this),n]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function On({problem:e}){return t(we,{title:e?"This link did not open tapster setup":"Open tapster setup from your terminal",children:[e&&t(N,{problem:e},void 0,!1,void 0,this),t("p",{class:"lead",children:"Each link from the terminal works once, so a copy of it in your history or someone else\'s hands is worthless. To get a fresh one, press Enter in the terminal where tapster setup runs."},void 0,!1,void 0,this),t("p",{class:"muted",children:"If tapster setup is not running, start it again:"},void 0,!1,void 0,this),t(z,{text:"bunx @doguyilmaz/tapster setup"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Rn(){return t(we,{title:"tapster setup stopped",children:[t("p",{class:"lead",children:"Everything you did is stored on GitHub. To continue later, start it again; it picks up where you left off."},void 0,!1,void 0,this),t(z,{text:"bunx @doguyilmaz/tapster setup"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Vn(){let e=oe.value;U(()=>{let o=3000,i=0,a=async()=>{if(!document.hidden)await st();o=Math.min(o*1.4,15000),i=window.setTimeout(a,o)};return i=window.setTimeout(a,o),()=>clearTimeout(i)},[]);let n=t("p",{class:"row muted small",children:[t(j,{},void 0,!1,void 0,this)," tapster checks again by itself every few seconds."]},void 0,!0,void 0,this);if(Ie.value)return t(we,{title:"tapster could not reach GitHub",children:[t(N,{problem:Ie.value},void 0,!1,void 0,this),n]},void 0,!0,void 0,this);if(e?.state==="no-gh")return t(we,{title:"Install the GitHub CLI",children:[t("p",{class:"lead",children:"tapster talks to GitHub through the GitHub CLI, so your sign-in stays with it and tapster never sees a password."},void 0,!1,void 0,this),t(z,{text:"brew install gh"},void 0,!1,void 0,this),t("p",{class:"muted small",children:["Not on a Mac? See ",t("a",{href:"https://cli.github.com",target:"_blank",rel:"noopener noreferrer",children:"cli.github.com"},void 0,!1,void 0,this),". Then sign in:"]},void 0,!0,void 0,this),t(z,{text:"gh auth login"},void 0,!1,void 0,this),n]},void 0,!0,void 0,this);if(e?.state==="signed-out")return t(we,{title:"Sign in to GitHub",children:[t("p",{class:"lead",children:"Run this in a terminal and follow its steps. tapster uses that sign-in to set up your hub; it never sees your password."},void 0,!1,void 0,this),t(z,{text:"gh auth login"},void 0,!1,void 0,this),n]},void 0,!0,void 0,this);let s=e?.state==="ok"?e.missing:[];return t(we,{title:"Allow gh to change workflows",children:[t("p",{class:"lead",children:["Your GitHub CLI sign-in lacks ",s.join(" and "),". tapster needs it to write the hub\'s workflow file."]},void 0,!0,void 0,this),t(z,{text:`gh auth refresh -s ${s.join(",")}`},void 0,!1,void 0,this),t(x,{tone:"keys",children:t("span",{children:"The sign-in stays in the GitHub CLI on this computer. tapster asks it for a token each time and keeps nothing."},void 0,!1,void 0,this)},void 0,!1,void 0,this),n]},void 0,!0,void 0,this)}var jn=(e)=>{let n=new Date(e),s=Math.round((Date.now()-n.getTime())/60000);if(s<1)return"just now";if(s<60)return`${s} min ago`;if(s<2880)return`${Math.round(s/60)} h ago`;return n.toLocaleDateString()},gs=new Set(["the tapster environment exists","only main may open the tapster environment","main cannot be deleted or force-pushed, by anyone","the hub runs only GitHub\'s and tapster\'s actions, pinned by commit","the default workflow token is read-only"]),ws=new Set(["the hub workflow exists","the hub workflow is tapster\'s template","the hub workflow runs only on schedule and manual dispatch","tapster.yml is valid"]);function ks({name:e,fix:n,hub:s,onFixed:o}){let[i,a]=m(!1),[r,c]=m(null);if(gs.has(e))return t("span",{class:"stack tight",children:[t("span",{class:"row",children:t(L,{busy:i,class:"btn secondary small",onClick:async()=>{a(!0),c(null);try{await A("/api/hub/protect",{hub:s}),await W(),o()}catch(u){c(R(u))}finally{a(!1)}},children:[t(v,{name:"shield"},void 0,!1,void 0,this),"Restore the protection"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),t(N,{problem:r},void 0,!1,void 0,this)]},void 0,!0,void 0,this);let p=ws.has(e)&&!(e==="tapster.yml is valid"&&n!=="Run tapster init.")?"files":e==="the credentials this hub needs are stored"?null:void 0;if(p===void 0)return null;return t("span",{class:"row",children:t("button",{type:"button",class:"btn secondary small",onClick:()=>{De.value=p,ce("/setup")},children:["Fix it in Setup",t(v,{name:"arrow"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}var Et=(e)=>e.charAt(0).toUpperCase()+e.slice(1),xs={success:{tone:"ok",text:"Done"},failure:{tone:"error",text:"Failed"},cancelled:{text:"Cancelled"},skipped:{text:"Skipped"}};function Fn(){let e=le.value,[n,s]=m(null),[o,i]=m(null),[a,r]=m(!1),[c,p]=m(!1),u=async()=>{if(!e)return;r(!0),i(null);try{s(await Z(`/api/hub/health?hub=${encodeURIComponent(e.name)}`))}catch(d){i(R(d))}finally{r(!1)}};if(U(()=>{u()},[e?.name]),!e)return null;let h=n?.checks.filter((d)=>!d.ok)??[],f=n?.checks.filter((d)=>d.ok)??[],l=async()=>{p(!0);try{await A("/api/hub/run",{hub:e.name}),Y("ok","The hub run started. It shows up below in a few seconds."),setTimeout(()=>void u(),4000)}catch(d){i(R(d))}finally{p(!1)}};return t("div",{class:"stack",style:"gap: 1.5rem; max-width: 900px",children:[t("div",{class:"spread",children:[t("div",{class:"stack tight",children:[t("p",{class:"eyebrow",children:"Health"},void 0,!1,void 0,this),t("h1",{class:"title",children:n?h.length?`${h.length} ${h.length===1?"thing needs":"things need"} you`:`${e.name} is healthy`:`Checking ${e.name}`},void 0,!1,void 0,this),t("p",{class:"lead",children:"The same checks as tapster doctor, run against the hub as it is on GitHub\'s main branch."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("div",{class:"row",children:[t("button",{type:"button",class:"btn secondary",onClick:()=>void u(),disabled:a,children:[t(v,{name:"refresh",spin:a},void 0,!1,void 0,this),"Check again"]},void 0,!0,void 0,this),t(L,{busy:c,class:"btn primary",onClick:l,children:[t(v,{name:"play"},void 0,!1,void 0,this),"Run the hub now"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),t(N,{problem:o},void 0,!1,void 0,this),e.issue&&t(x,{tone:"warn",title:`The hub opened issue #${e.issue.number}: tapster: the hub needs attention`,children:[t("span",{children:["Updated ",jn(e.issue.updated),". It closes itself once everything is fine."]},void 0,!0,void 0,this),t("details",{children:[t("summary",{class:"small",children:"Show what it says"},void 0,!1,void 0,this),t("pre",{class:"block",style:"white-space: pre-wrap; margin-top: 0.5rem",children:e.issue.body.replace(/<!--[\\s\\S]*?-->/g,"").trim()},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t(q,{href:e.issue.url,class:"btn secondary small",children:"Open the issue"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),a&&!n&&t("p",{class:"row muted",role:"status",children:[t(j,{},void 0,!1,void 0,this)," Running the checks"]},void 0,!0,void 0,this),n&&t("div",{class:"card list",children:[...h,...f].map((d)=>t("div",{class:"item",style:"grid-template-columns: auto minmax(0, 1fr); align-items: start",children:[t("span",{class:d.ok?"ok":"bad",style:`color: var(--${d.ok?"green":"wax"}); padding-top: 0.15rem`,children:t(v,{name:d.ok?"check":"alert",label:d.ok?"ok":"needs a fix"},void 0,!1,void 0,this)},void 0,!1,void 0,this),t("div",{class:"stack tight",style:"gap: 0.2rem",children:[t("span",{style:"font-weight: 550",children:Et(d.name)},void 0,!1,void 0,this),!d.ok&&t("span",{class:"muted small",children:d.fix},void 0,!1,void 0,this),!d.ok&&t(ks,{name:d.name,fix:d.fix,hub:e.name,onFixed:()=>void u()},void 0,!1,void 0,this),d.note&&t("span",{class:"faint small",children:[Et(d.note),"."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},d.name,!0,void 0,this))},void 0,!1,void 0,this),n?.note&&t("p",{class:"muted small",children:[Et(n.note.replace(/^note: /,"")),"."]},void 0,!0,void 0,this),n&&t("section",{class:"stack tight",children:[t("h2",{class:"section-title",children:"Recent hub runs"},void 0,!1,void 0,this),n.runs.length?t("div",{class:"card list",children:n.runs.map((d)=>{let _=d.status==="completed"?xs[d.conclusion??""]??{text:d.conclusion??"Done"}:{tone:"warn",text:d.status==="queued"?"Queued":"Running"};return t("div",{class:"item",children:[t("span",{class:"stack tight",style:"gap: 0.1rem",children:[t("span",{children:d.event==="schedule"?"On schedule":d.event==="workflow_dispatch"?"Started by hand or the doorbell":d.event},void 0,!1,void 0,this),t("span",{class:"faint small",children:jn(d.created)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("span",{class:"row",children:[t(F,{tone:_.tone,children:_.text},void 0,!1,void 0,this),t(q,{href:d.url,class:"btn quiet small",children:"Log"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},d.id,!0,void 0,this)})},void 0,!1,void 0,this):t("p",{class:"muted",children:"No runs yet. The workflow starts once the hub files are on main."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Ln({onChosen:e,onCancel:n}){let[s,o]=m(null),[i,a]=m("homebrew-tap"),[r,c]=m("public"),[p,u]=m(!1),h=oe.value?.state==="ok"?oe.value.login:"you";U(()=>{En().catch((g)=>o(R(g)))},[]);let f=At.value,l=Me.value?.here.hub??null,d=f?.some((g)=>g.name.toLowerCase()===`${h}/${i}`.toLowerCase())??!1,_=/^homebrew-[A-Za-z0-9._-]{1,80}$/.test(i),T=async(g)=>{g.preventDefault(),u(!0),o(null);try{let k=await A("/api/hubs",{name:i,private:r==="private"});e(k.hub)}catch(k){o(R(k))}finally{u(!1)}};return t("div",{class:"stack",style:"gap: 2rem; max-width: 860px",children:[t("div",{class:"hello",children:[t("div",{class:"stack tight",children:[t("h1",{class:"title",children:"Choose your hub"},void 0,!1,void 0,this),t("p",{class:"lead",children:["Your hub is your Homebrew tap: a repository whose name starts with ",t("code",{children:"homebrew-"},void 0,!1,void 0,this),". tapster turns it into the one place that signs, notarizes and publishes the releases of all your projects."]},void 0,!0,void 0,this),n&&t("p",{children:t("button",{type:"button",class:"btn quiet",onClick:n,children:"Keep the current hub"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("img",{src:"/courier.webp",alt:"The tapster octopus courier with sealed parcels",width:"220",height:"220"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t(N,{problem:s},void 0,!1,void 0,this),t("section",{class:"stack tight","aria-labelledby":"yours",children:[t("h2",{id:"yours",class:"section-title",children:"Your taps"},void 0,!1,void 0,this),f===null&&!s&&t("p",{class:"row muted",children:[t(j,{},void 0,!1,void 0,this)," Looking for repositories named homebrew-\u2026 on your account"]},void 0,!0,void 0,this),f?.length===0&&t("p",{class:"muted",children:"You have no repository named homebrew-\u2026 yet. Create one below."},void 0,!1,void 0,this),t("div",{class:"choices",children:f?.map((g)=>t("button",{type:"button",class:"choice",onClick:()=>e(g.name),children:[t(v,{name:"package"},void 0,!1,void 0,this),t("span",{class:"grow",children:[t("span",{class:"mono",children:g.name},void 0,!1,void 0,this),t("span",{class:"muted small",children:g.tapster?"Already a tapster hub":"A tap without tapster yet"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),g.name===l&&t(F,{tone:"next",children:"This folder"},void 0,!1,void 0,this),t(F,{tone:g.private?"warn":void 0,children:g.private?"Private":"Public"},void 0,!1,void 0,this),t(v,{name:"right"},void 0,!1,void 0,this)]},g.name,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("section",{class:"card pad stack","aria-labelledby":"new",children:[t("h2",{id:"new",class:"section-title",children:"Or create a new tap"},void 0,!1,void 0,this),t("form",{class:"stack",onSubmit:T,children:[t("div",{class:"field",children:[t("label",{for:"tap-name",children:"Repository name"},void 0,!1,void 0,this),t("div",{class:"row",style:"flex-wrap: nowrap",children:[t("span",{class:"mono muted",children:[h,"/"]},void 0,!0,void 0,this),t("input",{class:"input mono",id:"tap-name",value:i,onInput:(g)=>a(g.currentTarget.value.trim()),spellcheck:!1,autoComplete:"off"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("span",{class:"hint",children:["Users install with ",t("code",{children:["brew install ",h,"/",i.replace(/^homebrew-/,"")||"tap","/<name>"]},void 0,!0,void 0,this),"."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),t("fieldset",{class:"stack tight",style:"border: 0; padding: 0; margin: 0",children:[t("legend",{class:"label",style:"font-weight: 600; font-size: 0.92rem; margin-bottom: 0.4rem",children:"Visibility"},void 0,!1,void 0,this),t("label",{class:"switch",children:[t("input",{type:"radio",name:"visibility",checked:r==="public",onChange:()=>c("public")},void 0,!1,void 0,this),t("span",{children:[t("strong",{children:"Public (recommended)"},void 0,!1,void 0,this),t("span",{children:"GitHub gives public repositories free macOS runners, which signing needs. It also gives them the protected environment that holds your keys."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),t("label",{class:"switch",children:[t("input",{type:"radio",name:"visibility",checked:r==="private",onChange:()=>c("private")},void 0,!1,void 0,this),t("span",{children:[t("strong",{children:"Private"},void 0,!1,void 0,this),t("span",{children:"Needs GitHub Pro for the protected environment. Every run uses your plan\'s Actions minutes. Users can only install from public projects."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),d&&t(x,{tone:"warn",children:"You already have this repository. Pick it from the list above."},void 0,!1,void 0,this),t("div",{class:"row",children:[t(L,{busy:p,class:"btn primary",type:"submit",disabled:!_||d,children:["Create ",h,"/",i]},void 0,!0,void 0,this),!_&&t("span",{class:"muted small",children:"The name must start with homebrew-."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Mt(e,n=Date.now()){let s=Date.parse(`${e}T00:00:00Z`);return!Number.isNaN(s)&&s-n<2592000000}function Dt(e,n){if(e.apple.needed)return!0;return n===null?null:n==="yes"}function Bn(e,n,s=Date.now()){let o=Dt(e,n),i=e.protect.checks.filter((c)=>c.ok).length,a=[{id:"protect",name:"Protect the hub",done:e.protect.done,status:e.protect.done?"All protections are on":i?`${i} of ${e.protect.checks.length} protections on`:"Not protected yet",open:"Not protected yet"},{id:"app",name:"Create the GitHub App",done:Boolean(e.app.id&&e.app.slug&&e.app.key),attention:Boolean(e.app.id&&!e.app.key),status:e.app.id&&!e.app.key?"The App\'s private key is missing":e.app.slug?e.app.slug:"Not created yet",open:"Not created yet"},{id:"macos",name:"macOS or not",done:o===!0,skipped:o===!1,status:o===!0?"Signs macOS software":o===!1?"No macOS builds":"Your answer",open:"Your answer"},{id:"certificate",name:"Apple certificate",done:Boolean(e.apple.certificate&&e.apple.certificateStored),skipped:o===!1,attention:Boolean(e.apple.certificate&&Mt(e.apple.certificate.expires,s)),status:o===!1?"Not needed":e.apple.certificate?`Team ${e.apple.certificate.team}, expires ${e.apple.certificate.expires}`:"Not stored yet",open:"Not stored yet"},{id:"notary",name:"Notarization key",done:e.apple.notary,skipped:o===!1,status:o===!1?"Not needed":e.apple.notary?"Stored":"Not stored yet",open:"Not stored yet"},{id:"files",name:"Hub files",done:e.files.config&&e.files.state&&e.files.workflow!=="missing",attention:e.files.workflow==="older"||e.files.workflow==="other",status:e.files.workflow==="missing"?"Not written yet":e.files.workflow==="older"?`Runs ${e.files.pinned}; update available`:e.files.workflow==="other"?`Runs ${e.files.pinned??"a workflow tapster did not write"}; review it`:e.files.workflow==="newer"?`Runs ${e.files.pinned}, newer than this tapster`:`Runs ${e.files.pinned}`,open:"Not written yet"},{id:"project",name:"Your projects",done:e.packages.length>0,status:e.packages.length?`${e.packages.length} in the hub`:"None yet",open:"None yet"}],r=!1;return a.map((c)=>{let p;if(c.skipped)p="skipped";else if(c.attention)p="attention";else if(c.done)p="done";else if(!r)p="now",r=!0;else p="later";return{id:c.id,name:c.name,state:p,status:c.status}})}var Gn=(e)=>(e.find((n)=>n.state==="now"||n.state==="attention")??e[e.length-1]).id;function it(e,n){let s=e.split(`\n`),o=n.split(`\n`),i=s.length,a=o.length;if(i*a>4000000)return[...s.map((h)=>({kind:"del",text:h})),...o.map((h)=>({kind:"add",text:h}))];let r=Array.from({length:i+1},()=>Array(a+1).fill(0));for(let h=i-1;h>=0;h--)for(let f=a-1;f>=0;f--)r[h][f]=s[h]===o[f]?r[h+1][f+1]+1:Math.max(r[h+1][f],r[h][f+1]);let c=[],p=0,u=0;while(p<i&&u<a)if(s[p]===o[u])c.push({kind:"ctx",text:s[p]}),p++,u++;else if(r[p+1][u]>=r[p][u+1])c.push({kind:"del",text:s[p++]});else c.push({kind:"add",text:o[u++]});while(p<i)c.push({kind:"del",text:s[p++]});while(u<a)c.push({kind:"add",text:o[u++]});return c}function rt(e,n=3){let s=e.map((a,r)=>a.kind!=="ctx"||e.slice(Math.max(0,r-n),r+n+1).some((c)=>c.kind!=="ctx")),o=[],i=0;if(e.forEach((a,r)=>{if(s[r]){if(i)o.push({kind:"gap",text:`${i} unchanged lines`});i=0,o.push(a)}else i++}),i)o.push({kind:"gap",text:`${i} unchanged lines`});return o}var Ss=(e)=>{let n=Math.min(...e.filter((s)=>s.trim()).map((s)=>/^ */.exec(s)[0].length));return e.map((s)=>s.slice(n)).join(`\n`).trimEnd()};function Un(e){let n=[];for(let s of e){let[o="",...i]=s.split(`\n`),a=o.trim().replace(/^- /,"");if(!a||/^proposed the hub entry in |^open this page and choose Install/.test(a))continue;let r=n.at(-1),c;if(o.startsWith(" ")&&r&&r.block===null)c=r,c.text+=`${/[.:;!?]$/.test(c.text)?"":"."} ${a}`;else c={text:/^[a-z]+[._]/.test(a)?a:a.charAt(0).toUpperCase()+a.slice(1),block:null},n.push(c);let p=0;while(p<i.length&&!c.text.endsWith(":"))c.text+=` ${i[p++].trim()}`;if(p<i.length)c.block=Ss(i.slice(p))}return n}var Wn="tapster.roots",zn={go:"Go with GoReleaser",bun:"Bun",app:"Mac app with Sparkle"};function Cs(){try{let e=JSON.parse(In(Wn)??"[]");return Array.isArray(e)?e.filter((n)=>typeof n==="string").slice(0,10):[]}catch{return[]}}function Ot({p:e,onOpen:n}){return t("div",{class:"item",children:[t("button",{type:"button",class:"link",onClick:()=>n(e),disabled:!e.kind,children:[t("span",{class:"name",children:e.repo},void 0,!1,void 0,this),t("span",{class:"path",children:at(e.path)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("span",{class:"row",children:[e.kind?t(F,{children:zn[e.kind]},void 0,!1,void 0,this):t("span",{class:"muted small",children:e.why},void 0,!1,void 0,this),e.inHub?t(F,{tone:"ok",children:"In the hub"},void 0,!1,void 0,this):e.proposed?t(q,{href:e.proposed,class:"btn secondary small",children:"Merge the entry"},void 0,!1,void 0,this):e.kind?t("button",{type:"button",class:"btn secondary small",onClick:()=>n(e),children:["Add",t(v,{name:"arrow"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):null]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function qn(){let e=le.value,[n,s]=m(null),[o,i]=m(null),[a,r]=m(Cs()),[c,p]=m(""),[u,h]=m(!1),[f,l]=m(null),[d,_]=m(!1),T=async(w=a)=>{if(!e)return;_(!0),i(null);try{s(await A("/api/projects/scan",{hub:e.name,extra:w}))}catch(B){i(R(B))}finally{_(!1)}};if(U(()=>{T()},[e?.name]),!e)return null;let g=(w)=>{w.preventDefault();let B=c.trim().replace(/^[\'"]|[\'"]$/g,"");if(!B)return;let ee=[B,...a.filter((ae)=>ae!==B)].slice(0,10);r(ee),nt(Wn,JSON.stringify(ee)),p(""),T(ee)},k=n?.projects??[],y=k.filter((w)=>w.kind&&!w.inHub),H=k.filter((w)=>w.inHub),b=k.filter((w)=>!w.kind&&!w.inHub);return t("div",{class:"stack",style:"gap: 1.5rem",children:[t("div",{class:"spread",children:[t("div",{class:"stack tight",children:[t("p",{class:"eyebrow",children:"Projects on this computer"},void 0,!1,void 0,this),t("h1",{class:"title",children:["Add your projects to ",e.name]},void 0,!0,void 0,this),t("p",{class:"lead",children:["tapster looks for clones of your own repositories here. It reads each clone\'s ",t("code",{children:".git/config"},void 0,!1,void 0,this)," and checks which build files exist. Nothing leaves this computer."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),t("button",{type:"button",class:"btn secondary",onClick:()=>void T(),disabled:d,children:[t(v,{name:"refresh",spin:d},void 0,!1,void 0,this),"Look again"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),t("form",{class:"row",onSubmit:g,style:"flex-wrap: nowrap",children:[t("label",{class:"sr",for:"folder",children:"A folder to look in"},void 0,!1,void 0,this),t("input",{id:"folder",class:"input mono",placeholder:"A folder, such as /Users/you/Documents/code",value:c,onInput:(w)=>p(w.currentTarget.value),spellcheck:!1,autoComplete:"off"},void 0,!1,void 0,this),t("button",{class:"btn secondary",type:"submit",children:[t(v,{name:"folder"},void 0,!1,void 0,this),"Look there too"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),t(N,{problem:o},void 0,!1,void 0,this),d&&!n&&t("p",{class:"row muted",role:"status",children:[t(j,{},void 0,!1,void 0,this)," Looking through your folders"]},void 0,!0,void 0,this),n&&t(C,{children:[t("section",{class:"stack tight","aria-labelledby":"ready",children:[t("h2",{id:"ready",class:"section-title",children:["Ready to add (",y.length,")"]},void 0,!0,void 0,this),y.length?t("div",{class:"card list",children:y.map((w)=>t(Ot,{p:w,onOpen:l},w.path,!1,void 0,this))},void 0,!1,void 0,this):t("p",{class:"muted",children:[k.length?"Every supported clone here is in the hub already.":"No clone of your repositories turned up."," If a project lives elsewhere, add its folder above."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),H.length>0&&t("section",{class:"stack tight","aria-labelledby":"in-hub",children:[t("h2",{id:"in-hub",class:"section-title",children:["In the hub (",H.length,")"]},void 0,!0,void 0,this),t("div",{class:"card list",children:H.map((w)=>t(Ot,{p:w,onOpen:l},w.path,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),b.length>0&&t("section",{class:"stack tight",children:[t("button",{type:"button",class:"btn quiet",onClick:()=>h(!u),"aria-expanded":u,style:"justify-self: start",children:[t(v,{name:u?"down":"right"},void 0,!1,void 0,this),b.length," other ",b.length===1?"clone":"clones"," tapster cannot publish yet"]},void 0,!0,void 0,this),u&&t("div",{class:"card list",children:b.map((w)=>t(Ot,{p:w,onOpen:l},w.path,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("p",{class:"faint small",children:["Looked in ",n.roots.map(at).join(", "),n.truncated?"; it stopped early because there were many folders":"",". ",n.others?`${n.others} ${n.others===1?"clone belongs":"clones belong"} to other owners and ${n.others===1?"is":"are"} not listed.`:""]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),f&&t(As,{p:f,hubName:e.name,onClose:()=>l(null),onAdded:()=>void T()},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Rt({checked:e,onChange:n,title:s,children:o}){return t("label",{class:"switch",children:[t("input",{type:"checkbox",checked:e,onChange:(i)=>n(i.currentTarget.checked)},void 0,!1,void 0,this),t("span",{children:[t("strong",{children:s},void 0,!1,void 0,this),t("span",{children:o},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Ts({view:e}){return t("div",{class:"stack tight files",children:e.files.map((n)=>{let s=n.before===null?null:rt(it(n.before,n.after??""));return t("details",{class:"file",open:!0,children:[t("summary",{children:[t(v,{name:"file"},void 0,!1,void 0,this),t("code",{children:n.path},void 0,!1,void 0,this),t(F,{tone:n.before===null?"next":n.after===null?"error":"warn",children:n.before===null?"New":n.after===null?"Removed":"Changed"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("pre",{class:"block diff",children:s?s.map((o,i)=>t("span",{class:o.kind==="gap"?"hunk":o.kind,children:[o.kind==="add"?"+ ":o.kind==="del"?"- ":o.kind==="gap"?"@ ":" ",o.text,`\n`]},i,!0,void 0,this)):n.after},void 0,!1,void 0,this)]},n.path,!0,void 0,this)})},void 0,!1,void 0,this)}function As({p:e,hubName:n,onClose:s,onAdded:o}){let i=Te(null);U(()=>{let D=document.activeElement;i.current?.querySelector("button")?.focus();let G=(ie)=>{if(ie.key!=="Tab"||!i.current)return;let ct=[...i.current.querySelectorAll("a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), summary, [tabindex]:not([tabindex=\'-1\'])")],Oe=ct[0],ut=ct[ct.length-1];if(!Oe||!ut)return;if(!i.current.contains(document.activeElement))ie.preventDefault(),Oe.focus();else if(ie.shiftKey&&document.activeElement===Oe)ie.preventDefault(),ut.focus();else if(!ie.shiftKey&&document.activeElement===ut)ie.preventDefault(),Oe.focus()};return addEventListener("keydown",G),()=>{removeEventListener("keydown",G),D?.focus()}},[]);let[a,r]=m(null),[c,p]=m(null),[u,h]=m("release.yml"),[f,l]=m(!1),[d,_]=m(!1),[T,g]=m(!1),[k,y]=m(null),[H,b]=m(null),[w,B]=m(null),[ee,ae]=m(!1),[xe,K]=m(!1);U(()=>{A("/api/projects/inspect",{hub:n,path:e.path}).then((G)=>{if(r(G),_(G.dependabot),G.workflow)h(G.workflow)},(G)=>p(R(G)));let D=(G)=>G.key==="Escape"&&s();return addEventListener("keydown",D),()=>removeEventListener("keydown",D)},[e.path]);let X=async(D,G)=>{y(D),p(null);try{await G()}catch(ie){p(R(ie))}finally{y(null)}},Xn=()=>X("add",async()=>{let D=await A("/api/projects/add",{hub:n,path:e.path,options:{workflow:u,autoTag:f,dependabot:d,force:T}});b(D),B(await A("/api/projects/diff",{path:e.path,files:D.files})),o(),W()}),Lt=a?.dirty??[],Bt=a?.kind==="go"&&a.workflows.length===0;return t(C,{children:[t("div",{class:"sheet-back",onClick:s},void 0,!1,void 0,this),t("div",{class:"sheet",role:"dialog","aria-modal":"true","aria-labelledby":"sheet-title",ref:i,children:[t("div",{class:"sheet-head",children:[t("div",{class:"stack tight",style:"flex: 1; min-width: 0; gap: 0.1rem",children:[t("h2",{id:"sheet-title",class:"section-title mono",style:"font-size: 1.05rem; overflow-wrap: anywhere",children:e.repo},void 0,!1,void 0,this),t("span",{class:"faint small",style:"overflow-wrap: anywhere",children:at(e.path)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("button",{type:"button",class:"btn quiet small",onClick:s,"aria-label":"Close",children:t(v,{name:"x"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("div",{class:"sheet-body",children:[!a&&!c&&t("p",{class:"row muted",role:"status",children:[t(j,{},void 0,!1,void 0,this)," Reading the clone and its repository"]},void 0,!0,void 0,this),t(N,{problem:c},void 0,!1,void 0,this),a&&!H&&t(C,{children:[t("dl",{class:"facts",children:[t("dt",{children:"Kind"},void 0,!1,void 0,this),t("dd",{children:zn[a.kind]},void 0,!1,void 0,this),t("dt",{children:"Branch"},void 0,!1,void 0,this),t("dd",{class:"mono",children:a.branch},void 0,!1,void 0,this),t("dt",{children:"Repository"},void 0,!1,void 0,this),t("dd",{children:[a.private?"Private":"Public",", ",a.protected?"protected by tapster\'s rulesets":"not protected yet"]},void 0,!0,void 0,this),t("dt",{children:"Hub"},void 0,!1,void 0,this),t("dd",{children:a.inHub?"Already in the hub":a.proposed?"Proposed, waiting for you to merge":"Not in the hub yet"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),a.proposed&&t(x,{tone:"info",title:"The hub entry is waiting for you",children:[t("span",{children:"Merge the pull request to let the hub publish this project."},void 0,!1,void 0,this),t(q,{href:a.proposed,class:"btn secondary small",children:"Review the pull request"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),a.branch!==a.defaultBranch&&t(x,{tone:"warn",title:`This clone is on ${a.branch}, not ${a.defaultBranch}`,children:t("span",{children:["tapster changes the files on ",a.branch,". Releases use the workflow on ",a.defaultBranch,", so the change counts once it is merged there."]},void 0,!0,void 0,this)},void 0,!1,void 0,this),Lt.length>0&&t(x,{tone:"warn",title:"Uncommitted changes in files tapster edits",children:t("span",{children:[Lt.join(", "),". Commit or stash them first, so tapster\'s changes stay apart from yours."]},void 0,!0,void 0,this)},void 0,!1,void 0,this),a.private&&t(x,{tone:"warn",title:"This repository is private",children:t("span",{children:"The hub can publish it, but Homebrew, Scoop, apt and dnf users can only install from public projects. Its rulesets need a paid plan; without them the hub refuses it unless you accept the risk with protection: off."},void 0,!1,void 0,this)},void 0,!1,void 0,this),!a.apple&&t(x,{tone:"info",title:"The hub has no Apple credentials",children:"tapster leaves the macOS builds out of this project\'s entry."},void 0,!1,void 0,this),t("div",{class:"stack tight",children:[t("h3",{class:"section-title",children:"Options"},void 0,!1,void 0,this),a.kind==="go"&&(Bt?t(x,{tone:"error",title:"No workflow runs GoReleaser",children:t("span",{children:"tapster edits the workflow that runs goreleaser/goreleaser-action. Add one to .github/workflows first."},void 0,!1,void 0,this)},void 0,!1,void 0,this):t("div",{class:"field",children:[t("label",{for:"workflow",children:"The workflow that runs GoReleaser"},void 0,!1,void 0,this),t("select",{id:"workflow",class:"input",value:u,onChange:(D)=>h(D.currentTarget.value),children:a.workflows.map((D)=>t("option",{value:D,children:[".github/workflows/",D]},D,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)),a.kind!=="go"&&a.releaseFlow==="other"&&t(Rt,{checked:T,onChange:g,title:"Replace the existing release workflow",children:".github/workflows/release.yml exists and tapster does not recognize it. Without this, tapster only adds the step that rings the hub, if the workflow opens a draft release."},void 0,!1,void 0,this),t(Rt,{checked:f,onChange:l,title:"Let the release workflow push tags",children:"For workflows that decide the version and tag by themselves. tapster adds a deploy key that only the default branch\'s release environment can use; the rulesets let deploy keys tag."},void 0,!1,void 0,this),t(Rt,{checked:d,onChange:_,title:"Keep Dependabot\'s pull requests",children:[a.dependabot?"This clone uses Dependabot. ":"","Branches named dependabot/... stay open to anything with write access, the hub\'s App included, so a stolen App key could run your workflows on its own code there."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),t("div",{class:"stack tight",children:[t("h3",{class:"section-title",children:"What tapster does"},void 0,!1,void 0,this),t("ul",{class:"checks",children:[t("li",{children:[t(v,{name:"right"},void 0,!1,void 0,this),t("span",{children:[a.kind==="go"?`Edits .goreleaser.yaml and .github/workflows/${u}: drafts instead of releases, an attestation step and the step that rings the hub.`:"Writes .github/workflows/release.yml: build, attest, open a draft and ring the hub."," You review and commit these in the next step."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),t("li",{children:[t(v,{name:"right"},void 0,!1,void 0,this),t("span",{children:["Protects ",a.repo,": only you can create, move or delete branches and tags."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),t("li",{children:[t(v,{name:"right"},void 0,!1,void 0,this),t("span",{children:["Proposes the project\'s entry to ",n," as a pull request."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),f&&t("li",{children:[t(v,{name:"right"},void 0,!1,void 0,this),t("span",{children:\'Adds the deploy key "tapster tags" and a release environment.\'},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),t("div",{class:"row",children:t(L,{busy:k==="add",class:"btn primary",onClick:Xn,disabled:Bt,children:a.inHub?"Update the project":`Add to ${n}`},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),H&&t(C,{children:[t(x,{tone:"ok",title:`tapster prepared ${e.repo}`},void 0,!1,void 0,this),t("ul",{class:"checks small",children:Un(H.lines).map((D,G)=>t("li",{children:[t(v,{name:"right"},void 0,!1,void 0,this),t("span",{class:"stack tight",style:"min-width: 0",children:[t("span",{class:"muted",style:"overflow-wrap: anywhere",children:D.text},void 0,!1,void 0,this),D.block&&t("pre",{class:"block",children:D.block},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},G,!0,void 0,this))},void 0,!1,void 0,this),t("section",{class:"stack tight",children:[t("h3",{class:"section-title",children:"1. Review and commit the changes"},void 0,!1,void 0,this),w?t(Ts,{view:w},void 0,!1,void 0,this):t(j,{},void 0,!1,void 0,this),t("div",{class:"row",children:[ee?t(F,{tone:"ok",children:"Committed"},void 0,!1,void 0,this):t(L,{busy:k==="commit",class:"btn primary",onClick:()=>X("commit",async()=>{await A("/api/projects/commit",{path:e.path,files:H.files}),ae(!0)}),children:"Commit these files"},void 0,!1,void 0,this),ee&&(xe?t(F,{tone:"ok",children:"Pushed"},void 0,!1,void 0,this):t(L,{busy:k==="push",class:"btn primary",onClick:()=>X("push",async()=>{await A("/api/projects/push",{path:e.path}),K(!0),Y("ok",`Pushed ${e.repo}.`)}),children:"Push"},void 0,!1,void 0,this))]},void 0,!0,void 0,this),t("p",{class:"muted small",children:"tapster commits only these files, in your own git setup: your hooks and commit signing apply."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("section",{class:"stack tight",children:[t("h3",{class:"section-title",children:"2. Merge the hub entry"},void 0,!1,void 0,this),H.pr?t(C,{children:[t("p",{class:"muted",children:"GitHub shows you the exact change to the hub\'s tapster.yml. Merge it to start publishing."},void 0,!1,void 0,this),t("div",{class:"row",children:t(q,{href:H.pr,class:"btn secondary",children:[t(v,{name:"pr"},void 0,!1,void 0,this),"Review and merge on GitHub"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this):t("p",{class:"muted",children:"No pull request this time; the notes above say why."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("section",{class:"stack tight",children:[t("h3",{class:"section-title",children:"3. Let the hub reach it"},void 0,!1,void 0,this),t("p",{class:"muted",children:["Unless the App already reaches ",e.repo,\', install it there. GitHub preselects the project; keep "Only select repositories".\']},void 0,!0,void 0,this),t("div",{class:"row",children:t(q,{href:H.installUrl,class:"btn secondary",children:["Install the App on ",e.repo.split("/")[1]]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("section",{class:"stack tight",children:[t("h3",{class:"section-title",children:"4. Release"},void 0,!1,void 0,this),t("p",{class:"muted",children:"Push a version tag. The project\'s workflow opens a draft; the hub signs and publishes it on its next run."},void 0,!1,void 0,this),t(z,{text:`git -C ${JSON.stringify(e.path)} tag v1.0.0 && git -C ${JSON.stringify(e.path)} push origin v1.0.0`},void 0,!1,void 0,this),t("p",{class:"faint small",children:"Use your next version instead of v1.0.0."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Hs({stop:e,index:n}){if(e.state==="done")return t("span",{class:"dot",children:t(v,{name:"check"},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(e.state==="attention")return t("span",{class:"dot",children:t(v,{name:"alert"},void 0,!1,void 0,this)},void 0,!1,void 0,this);if(e.state==="skipped")return t("span",{class:"dot",children:"\u2013"},void 0,!1,void 0,this);return t("span",{class:"dot",children:n+1},void 0,!1,void 0,this)}function J({title:e,lead:n,children:s}){return t("div",{class:"panel-head",children:[t("div",{class:"spread",children:[t("h2",{class:"title",children:e},void 0,!1,void 0,this),s]},void 0,!0,void 0,this),t("p",{class:"lead",children:n},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Vt({text:e}){return t("div",{class:"row",children:[t("span",{class:"seal","aria-hidden":"true",children:t(v,{name:"check"},void 0,!1,void 0,this)},void 0,!1,void 0,this),t("strong",{children:e},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function fe(){let[e,n]=m(!1),[s,o]=m(null);return[e,s,async(a)=>{n(!0),o(null);try{await a()}catch(r){o(R(r))}finally{n(!1)}}]}var Kn=[["A tapster environment that only main can open","Your keys go into it, so a workflow on another branch never sees them."],["main cannot be deleted or force-pushed","By anyone, you included, so the hub\'s history stays as you pushed it."],["Only GitHub\'s and tapster\'s actions, pinned by commit","No other code runs next to your keys."],["A read-only default token","Workflows get write access only where the template asks for it."]];function Ps({h:e}){let[n,s,o]=fe();return t("div",{class:"panel",children:[t(J,{title:"Protect the hub",lead:"These settings keep a stolen key or a stray workflow away from your signing keys. You can run this again at any time; it only restores what is missing."},void 0,!1,void 0,this),t("ul",{class:"checks",children:e.protect.checks.map((i,a)=>t("li",{children:[t("span",{class:i.ok?"ok":"no",children:t(v,{name:i.ok?"check":"circle",label:i.ok?"on":"off"},void 0,!1,void 0,this)},void 0,!1,void 0,this),t("span",{class:"stack tight",style:"gap: 0.1rem",children:[t("span",{children:Kn[a]?.[0]??i.label},void 0,!1,void 0,this),t("span",{class:"muted small",children:Kn[a]?.[1]},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},i.label,!0,void 0,this))},void 0,!1,void 0,this),e.protect.others.length>0&&t(x,{tone:"warn",title:"These workflows stop running once the hub is protected",children:[t("span",{children:"They use actions from others or actions not pinned by commit. The hub does not need them. Their commits would make the hub refuse to run. You can remove them in Hub files."},void 0,!1,void 0,this),t("ul",{class:"log",children:e.protect.others.map((i)=>t("li",{children:[t("code",{children:[".github/workflows/",i.file]},void 0,!0,void 0,this),": ",i.actions.slice(0,3).join(", ")]},i.file,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t(N,{problem:s},void 0,!1,void 0,this),e.protect.done?t(Vt,{text:`${e.name} is protected`},void 0,!1,void 0,this):t("div",{class:"row",children:t(L,{busy:n,class:"btn primary",onClick:()=>o(async()=>{await A("/api/hub/protect",{hub:e.name}),await W(),Y("ok",`${e.name} is protected.`)}),children:[t(v,{name:"shield"},void 0,!1,void 0,this),e.protect.checks.some((i)=>i.ok)?"Restore the protection":`Protect ${e.name}`]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Ns({h:e,slug:n}){let[s,o]=m(e.app.installed);U(()=>{if(!e.app.installed)return;let a=0,r=4000,c=async()=>{if(!document.hidden)try{let p=await Z(`/api/hub/installation?hub=${encodeURIComponent(e.name)}`);o(p),r=p.id!==null&&!p.onHub?30000:4000}catch{r=Math.min(r*2,30000)}a=window.setTimeout(c,r)};return a=window.setTimeout(c,500),()=>clearTimeout(a)},[e.name,Boolean(e.app.installed)]);let i=`https://github.com/apps/${n}/installations/new`;return t("div",{class:"stack tight",children:[t("h3",{class:"section-title",children:"Install it on your projects"},void 0,!1,void 0,this),t("p",{class:"muted",children:["On GitHub, choose ",t("strong",{children:"Only select repositories"},void 0,!1,void 0,this)," and pick the projects the hub should publish. Never pick ",e.name,": the App can write to every repository it is installed on. The hub holds your signing keys. You can also install it per project later, from Projects."]},void 0,!0,void 0,this),s?.checked&&s.onHub&&t(x,{tone:"error",title:`The App is installed on ${e.name}`,children:[t("span",{children:["Remove ",e.name," from it; the hub refuses to run until you do."]},void 0,!0,void 0,this),t(q,{href:`https://github.com/settings/installations/${s.id}`,class:"btn secondary small",children:"Open the installation"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),s?.checked&&!s.onHub&&s.id!==null&&t(x,{tone:"ok",title:"The App is installed",children:t("span",{children:s.repos.length?`It reaches ${s.repos.join(", ")}.`:"It reaches no repository yet."},void 0,!1,void 0,this)},void 0,!1,void 0,this),s?.checked&&s.id===null&&t("p",{class:"row muted small",children:[t(j,{},void 0,!1,void 0,this)," Not installed yet. This updates by itself once you click Install on GitHub."]},void 0,!0,void 0,this),!s&&t("p",{class:"muted small",children:"GitHub shows an App\'s repositories only to the App itself. Each hub run reports a project the App cannot reach."},void 0,!1,void 0,this),t("div",{class:"row",children:[t(q,{href:i,class:s?.id?"btn secondary":"btn primary",children:s?.id?"Change its repositories":"Install the App"},void 0,!1,void 0,this),t(q,{href:`https://github.com/settings/apps/${n}`,class:"btn quiet",children:"App settings"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function $s({h:e,what:n,onGo:s}){return t("div",{class:"panel",children:[t(J,{title:n,lead:`This step stores a key in ${e.name}\'s tapster environment. Protect the hub first, so only workflows on main can open it.`},void 0,!1,void 0,this),t(x,{tone:"info",title:"Protect the hub first",children:t("span",{children:"Then come back here."},void 0,!1,void 0,this)},void 0,!1,void 0,this),t("div",{class:"row",children:t("button",{type:"button",class:"btn primary",onClick:s,children:[t(v,{name:"shield"},void 0,!1,void 0,this),"Go to Protect the hub"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Yn({h:e}){let[n,s]=m(null),[o,i]=m(null),[a,r,c]=fe(),p=Q.value,u=Boolean(e.app.id&&e.app.slug&&e.app.key);if(U(()=>{if(u||e.app.id||e.app.held||p?.kind==="unstored")return;A("/api/hub/app",{hub:e.name}).then(s,(h)=>i(R(h)))},[e.name,u,p?.kind]),(p?.kind==="unstored"||e.app.held)&&!u)return t("div",{class:"panel",children:[t(J,{title:"Store the App\'s key",lead:"GitHub created the App and handed its key to this setup, but storing it in the hub failed. The key is still in memory here, so try again."},void 0,!1,void 0,this),p?.kind==="unstored"&&t(N,{problem:p.problem},void 0,!1,void 0,this),t(N,{problem:r},void 0,!1,void 0,this),t("div",{class:"row",children:t(L,{busy:a,class:"btn primary",onClick:()=>c(async()=>{await A("/api/hub/app/store",{hub:e.name}),await W(),Q.value={kind:"created"}}),children:"Store the key again"},void 0,!1,void 0,this)},void 0,!1,void 0,this),t("p",{class:"muted small",children:"If this setup stops first, the key is gone. Then delete the App at github.com/settings/apps and create it again here."},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(e.app.id&&!e.app.key)return t("div",{class:"panel",children:[t(J,{title:"The App\'s key is missing",lead:`The hub knows its App (${e.app.slug??e.app.id}), but its private key is not stored. Generate a new key on GitHub and store it from a clone of the hub:`},void 0,!1,void 0,this),t(z,{text:"bunx @doguyilmaz/tapster init --rotate app"},void 0,!1,void 0,this),t(q,{href:`https://github.com/settings/apps/${e.app.slug??""}`,children:"Open the App on GitHub"},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(u)return t("div",{class:"panel",children:[t(J,{title:"The GitHub App",lead:"The hub uses this private App to write releases to the projects you install it on. It cannot touch anything else."},void 0,!1,void 0,this),p?.kind==="created"&&t(x,{tone:"ok",title:"GitHub created the App and tapster stored its key in the hub."},void 0,!1,void 0,this),t("dl",{class:"facts",children:[t("dt",{children:"App"},void 0,!1,void 0,this),t("dd",{class:"mono",children:e.app.slug},void 0,!1,void 0,this),t("dt",{children:"Key"},void 0,!1,void 0,this),t("dd",{children:["A secret of the tapster environment in ",e.name]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),t(Ns,{h:e,slug:e.app.slug},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return t("div",{class:"panel",children:[t(J,{title:"Create the GitHub App",lead:`${e.name} needs a GitHub App to write releases to your projects. GitHub creates it on your account after you confirm.`},void 0,!1,void 0,this),p?.kind==="failed"&&t(N,{problem:p.problem},void 0,!1,void 0,this),p?.kind==="unknown"&&t(x,{tone:"warn",title:"That answer from GitHub did not belong to this setup",children:"Start the App again below; nothing was stored."},void 0,!1,void 0,this),n&&t("div",{class:"stack tight",children:[t("h3",{class:"section-title",children:"It asks for"},void 0,!1,void 0,this),t("ul",{class:"checks",children:n.permissions.map((h)=>t("li",{children:[t(v,{name:"right"},void 0,!1,void 0,this),t("span",{children:h},void 0,!1,void 0,this)]},h,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t(x,{tone:"keys",title:"Where its key goes",children:t("span",{children:["GitHub hands the App\'s private key to tapster on this computer, once. tapster stores it as a secret of the tapster environment in ",e.name,". It goes nowhere else."]},void 0,!0,void 0,this)},void 0,!1,void 0,this),t(N,{problem:o},void 0,!1,void 0,this),n?t("form",{method:"post",action:n.action,class:"stack tight",children:[t("input",{type:"hidden",name:"manifest",value:n.manifest},void 0,!1,void 0,this),t("div",{class:"row",children:t("button",{class:"btn primary",type:"submit",children:["Continue to GitHub",t(v,{name:"arrow"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),t("p",{class:"muted small",children:["GitHub shows the App ",t("code",{children:n.name},void 0,!1,void 0,this),". Click ",t("strong",{children:"Create GitHub App"},void 0,!1,void 0,this)," there and GitHub brings you back here."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):!o&&t("p",{class:"row muted",children:[t(j,{},void 0,!1,void 0,this)," Preparing the App"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Is({h:e,choice:n}){let s=Dt(e,n);return t("div",{class:"panel",children:[t(J,{title:"Will this hub sign macOS software?",lead:"Mac apps and command line tools with macOS builds must be signed and notarized by Apple. That needs an Apple Developer Program membership and two files from Apple."},void 0,!1,void 0,this),e.apple.needed?t(x,{tone:"ok",title:"Yes",children:t("span",{children:e.apple.certificate||e.apple.notary?"The hub already holds Apple credentials.":"tapster.yml lists packages with macOS code."},void 0,!1,void 0,this)},void 0,!1,void 0,this):t("div",{class:"choices",children:[t("button",{type:"button",class:"choice","aria-pressed":s===!0,onClick:()=>Ht(e.name,"yes"),children:[t(v,{name:s===!0?"check":"circle"},void 0,!1,void 0,this),t("span",{class:"grow",children:[t("strong",{children:"Yes, sign macOS software"},void 0,!1,void 0,this),t("span",{class:"muted small",children:"Next: your Developer ID certificate and a notarization key."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),t("button",{type:"button",class:"choice","aria-pressed":s===!1,onClick:()=>Ht(e.name,"no"),children:[t(v,{name:s===!1?"check":"circle"},void 0,!1,void 0,this),t("span",{class:"grow",children:[t("strong",{children:"No, only Linux and Windows"},void 0,!1,void 0,this),t("span",{class:"muted small",children:"The hub leaves macOS builds out. You can add Apple credentials later, here."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function jt(e){history.pushState(null,"",`/setup?saved=${encodeURIComponent(e)}`),setTimeout(()=>history.replaceState(null,"","/setup"),1500)}function Es({h:e}){let[n,s]=m(null),[o,i]=m(!1),[a,r,c]=fe(),p=e.apple.certificate,u=!p||!e.apple.certificateStored||o,h=(f)=>{f.preventDefault();let l=f.currentTarget;c(async()=>{if(!n)throw new se({reason:"no .p12 file is chosen",fix:"Drop the .p12 you exported from Keychain Access."},0);let d=new FormData(l);d.delete("username"),d.set("hub",e.name),d.set("p12",n);let _=await A("/api/hub/certificate",d);jt("certificate"),i(!1),s(null),await W(),Y("ok",`Certificate stored for team ${_.team}. It expires on ${_.expires}.`)})};return t("div",{class:"panel",children:[t(J,{title:"Apple certificate",lead:"A Developer ID Application certificate, exported with its private key as a .p12 file. The hub signs your macOS code with it."},void 0,!1,void 0,this),p&&e.apple.certificateStored&&t(C,{children:[t("dl",{class:"facts",children:[t("dt",{children:"Team"},void 0,!1,void 0,this),t("dd",{class:"mono",children:p.team},void 0,!1,void 0,this),t("dt",{children:"Expires"},void 0,!1,void 0,this),t("dd",{children:[p.expires," ",Mt(p.expires)&&t(F,{tone:"error",children:"Renew it soon"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),!o&&t("div",{class:"row",children:[t("button",{type:"button",class:"btn secondary",onClick:()=>i(!0),children:"Replace the certificate"},void 0,!1,void 0,this),t("span",{class:"muted small",children:"For a renewal or a new team."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),u&&t(C,{children:[t("details",{class:"card pad",open:!p,children:[t("summary",{children:t("strong",{children:"How to get the .p12"},void 0,!1,void 0,this)},void 0,!1,void 0,this),t("ol",{class:"stack tight",style:"margin: 0.8rem 0 0; padding-left: 1.2rem",children:[t("li",{children:["No certificate yet? Create a ",t("strong",{children:"Developer ID Application"},void 0,!1,void 0,this)," certificate at"," ",t("a",{href:"https://developer.apple.com/account/resources/certificates",target:"_blank",rel:"noopener noreferrer",children:"developer.apple.com"},void 0,!1,void 0,this),"."]},void 0,!0,void 0,this),t("li",{children:["In Keychain Access, open ",t("strong",{children:"My Certificates"},void 0,!1,void 0,this),", right-click ",t("strong",{children:"Developer ID Application: \u2026"},void 0,!1,void 0,this)," and choose ",t("strong",{children:"Export"},void 0,!1,void 0,this),"."]},void 0,!0,void 0,this),t("li",{children:"Save it as .p12 with a password. Your password manager can make one."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),t("form",{class:"secret",onSubmit:h,autoComplete:"on",children:[t(ge,{name:"username",label:"Name in your password manager",value:`${e.name}: Developer ID certificate`,autoComplete:"username",hint:"Your password manager saves the .p12 password under this name, so it can fill it in next time."},void 0,!1,void 0,this),t(Nt,{name:"p12",accept:".p12,application/x-pkcs12",label:"The .p12 file",file:n,onFile:s,hint:"It stays in memory on this computer until tapster stores it in the hub."},void 0,!1,void 0,this),t($t,{name:"password",label:"Its password",hint:"The password you set when exporting it."},void 0,!1,void 0,this),t(x,{tone:"keys",title:"Where it goes",children:t("span",{children:["tapster opens the file with your password on this computer to check it is a Developer ID Application certificate that has not expired. Then the file and its password become secrets of the tapster environment in ",e.name,". Keep your own backup: GitHub never shows a secret again."]},void 0,!0,void 0,this)},void 0,!1,void 0,this),t(N,{problem:r},void 0,!1,void 0,this),t("div",{class:"row",children:[t(L,{busy:a,class:"btn primary",type:"submit",children:"Check and store"},void 0,!1,void 0,this),o&&t("button",{type:"button",class:"btn quiet",onClick:()=>i(!1),children:"Cancel"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Ms({h:e}){let[n,s]=m(null),[o,i]=m(!1),[a,r,c]=fe(),p=!e.apple.notary||o,u=(h)=>{h.preventDefault();let f=h.currentTarget;c(async()=>{if(!n)throw new se({reason:"no .p8 file is chosen",fix:"Drop the AuthKey_\u2026.p8 you downloaded from App Store Connect."},0);let l=new FormData(f);l.set("hub",e.name),l.set("p8",n);let d=await A("/api/hub/notary",l);jt("notary"),i(!1),s(null),await W(),Y("ok",d.checked?"Apple accepted the key and tapster stored it.":"Key stored. Apple checks it at the first release.")})};return t("div",{class:"panel",children:[t(J,{title:"Notarization key",lead:"An App Store Connect API key. The hub sends your signed code to Apple with it; Apple notarizes it."},void 0,!1,void 0,this),e.apple.notary&&!o&&t(C,{children:[t(Vt,{text:"The notarization key is stored"},void 0,!1,void 0,this),t("div",{class:"row",children:t("button",{type:"button",class:"btn secondary",onClick:()=>i(!0),children:"Replace the key"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),p&&t(C,{children:[t("details",{class:"card pad",open:!e.apple.notary,children:[t("summary",{children:t("strong",{children:"How to get the key"},void 0,!1,void 0,this)},void 0,!1,void 0,this),t("ol",{class:"stack tight",style:"margin: 0.8rem 0 0; padding-left: 1.2rem",children:[t("li",{children:["In"," ",t("a",{href:"https://appstoreconnect.apple.com/access/integrations/api",target:"_blank",rel:"noopener noreferrer",children:"App Store Connect"},void 0,!1,void 0,this),", open ",t("strong",{children:"Users and Access"},void 0,!1,void 0,this),", ",t("strong",{children:"Integrations"},void 0,!1,void 0,this),", ",t("strong",{children:"App Store Connect API"},void 0,!1,void 0,this),", ",t("strong",{children:"Team Keys"},void 0,!1,void 0,this),"."]},void 0,!0,void 0,this),t("li",{children:["Create a key with ",t("strong",{children:"Developer"},void 0,!1,void 0,this)," access and download ",t("code",{children:"AuthKey_\u2026.p8"},void 0,!1,void 0,this),". Apple offers the download once."]},void 0,!0,void 0,this),t("li",{children:"The Key ID is in the list; the Issuer ID is above it."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),t("form",{class:"secret",onSubmit:u,autoComplete:"off",children:[t(Nt,{name:"p8",accept:".p8",label:"The .p8 file",file:n,onFile:s,hint:"It stays in memory on this computer until tapster stores it in the hub."},void 0,!1,void 0,this),t("div",{class:"grid2",children:[t(ge,{name:"keyId",label:"Key ID",mono:!0,placeholder:"ABCDE12345"},void 0,!1,void 0,this),t(ge,{name:"issuerId",label:"Issuer ID",mono:!0,placeholder:"00000000-0000-0000-0000-000000000000"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t(x,{tone:"keys",title:"Where it goes",children:t("span",{children:["On a Mac, tapster asks Apple whether the key works before storing it. The key and its two IDs become secrets of the tapster environment in ",e.name,"."]},void 0,!0,void 0,this)},void 0,!1,void 0,this),t(N,{problem:r},void 0,!1,void 0,this),t("div",{class:"row",children:[t(L,{busy:a,class:"btn primary",type:"submit",children:"Check with Apple and store"},void 0,!1,void 0,this),o&&t("button",{type:"button",class:"btn quiet",onClick:()=>i(!1),children:"Cancel"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var Ds=[5,10,15,20,30,60,120,180,360];function Os({f:e}){let n=e.change==="create"?"next":e.change==="update"?"warn":e.change==="remove"?"error":void 0,s={create:"New",update:"Changes",same:"Unchanged",remove:"Removed"}[e.change],o=e.change==="update"&&e.before!==null?rt(it(e.before,e.content)):null;return t("details",{class:"file",children:[t("summary",{children:[t(v,{name:"file"},void 0,!1,void 0,this),t("code",{children:e.path},void 0,!1,void 0,this),t(F,{tone:n,children:s},void 0,!1,void 0,this),t(v,{name:"down"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("pre",{class:"block diff",children:o?o.map((i,a)=>t("span",{class:i.kind==="gap"?"hunk":i.kind,children:[i.kind==="add"?"+ ":i.kind==="del"?"- ":i.kind==="gap"?"@ ":" ",i.text,`\n`]},a,!0,void 0,this)):e.change==="remove"?e.before:e.content},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Rs({h:e}){let[n,s]=m(e.files.every),[o,i]=m([]),[a,r]=m(!1),[c,p]=m(null),[u,h,f]=fe(),[l,d,_]=fe(),[T,g]=m(!1),k=e.protect.others.map((b)=>b.file);U(()=>{f(async()=>p(await A("/api/hub/files/preview",{hub:e.name,every:n,remove:o,readme:a})))},[e.name,n,o.join(","),a]);let y=c?.files.filter((b)=>b.change!=="same")??[],H=()=>_(async()=>{let b=await A("/api/hub/files",{hub:e.name,every:n,remove:o,readme:a});g(!0),await W(),p(await A("/api/hub/files/preview",{hub:e.name,every:n,remove:[],readme:!1})),i([]),r(!1),Y("ok",b.result==="committed"?`Wrote the hub files to ${e.name}.`:"The hub files were already up to date.")});return t("div",{class:"panel",children:[t(J,{title:"Hub files",lead:"The hub\'s settings, its record of published releases, a README for your users and the workflow that does the work. tapster writes them to main in one commit."},void 0,!1,void 0,this),t("div",{class:"grid2",children:t("div",{class:"field",children:[t("label",{for:"every",children:"Look for new releases every"},void 0,!1,void 0,this),t("select",{id:"every",class:"input",value:String(n??(e.private?60:10)),onChange:(b)=>s(Number(b.currentTarget.value)),children:Ds.map((b)=>t("option",{value:b,children:b<60?`${b} minutes`:b===60?"hour":`${b/60} hours`},b,!1,void 0,this))},void 0,!1,void 0,this),t("span",{class:"hint",children:e.private?"A private hub bills every run as at least one minute; hourly keeps a hub within the free minutes.":"Public hubs run for free. The doorbell can start the hub right after each release."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),e.files.workflow==="newer"&&t(x,{tone:"warn",title:`The hub runs ${e.files.pinned}, newer than this tapster`,children:t("span",{children:["tapster keeps the hub\'s workflow, so it does not move the hub back. To change the workflow, run the latest: ",t("code",{children:"bunx @doguyilmaz/tapster@latest setup"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),k.length>0&&t("div",{class:"stack tight",children:[t("h3",{class:"section-title",children:"The tap\'s old workflows"},void 0,!1,void 0,this),k.map((b)=>t("label",{class:"switch",children:[t("input",{type:"checkbox",checked:o.includes(b),onChange:(w)=>i(w.currentTarget.checked?[...o,b]:o.filter((B)=>B!==b))},void 0,!1,void 0,this),t("span",{children:[t("strong",{children:["Remove .github/workflows/",b]},void 0,!0,void 0,this),t("span",{children:"It stops running once the hub is protected. Its commits would make the hub refuse to run."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},b,!0,void 0,this))]},void 0,!0,void 0,this),(c?.readme||a)&&t("label",{class:"switch",children:[t("input",{type:"checkbox",checked:a,onChange:(b)=>r(b.currentTarget.checked)},void 0,!1,void 0,this),t("span",{children:[t("strong",{children:"Replace README.md with tapster\'s"},void 0,!1,void 0,this),t("span",{children:"It tells your users how to install from the hub, including brew trust, which Homebrew asks for before it loads casks from a tap. Your current README goes away; the diff below shows both."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),u&&!c&&t("p",{class:"row muted",children:[t(j,{},void 0,!1,void 0,this)," Comparing with ",e.name]},void 0,!0,void 0,this),t(N,{problem:h},void 0,!1,void 0,this),c&&t("div",{class:"stack tight files",children:[t("div",{class:"spread",children:[t("h3",{class:"section-title",children:y.length?`${y.length} ${y.length===1?"change":"changes"} for main`:"main is up to date"},void 0,!1,void 0,this),t("span",{class:"muted small",children:["Workflow: ",c.pin]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),c.files.map((b)=>t(Os,{f:b},b.path,!1,void 0,this)),c.kept.length>0&&t("p",{class:"muted small",children:["Kept as they are: ",c.kept.join(", "),"."]},void 0,!0,void 0,this),c.notes.filter((b)=>!b.startsWith("The hub looks for new drafts every")).map((b)=>t("p",{class:"muted small",children:b},b,!1,void 0,this))]},void 0,!0,void 0,this),c&&c.foreign.length>0&&t(x,{tone:"error",title:"main changed in ways only you may change it",children:[t("ul",{class:"log",children:c.foreign.map((b)=>t("li",{children:b},b,!1,void 0,this))},void 0,!1,void 0,this),t("span",{children:"Review those commits on GitHub and revert what you did not make. tapster writes nothing to main until then, because a write from you would mark them as reviewed."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t(N,{problem:d},void 0,!1,void 0,this),T&&t(x,{tone:"info",title:"Have a clone of the hub on this computer?",children:t("span",{children:["Run ",t("code",{children:"git pull"},void 0,!1,void 0,this)," in it, so it has the new files."]},void 0,!0,void 0,this)},void 0,!1,void 0,this),c&&y.length>0&&c.foreign.length===0&&t("div",{class:"row",children:t(L,{busy:l,class:"btn primary",onClick:H,children:["Write ",y.length===1?"the change":`the ${y.length} changes`," to main"]},void 0,!0,void 0,this)},void 0,!1,void 0,this),c&&y.length===0&&t(Vt,{text:"The hub files are up to date"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Vs({h:e}){return t("div",{class:"panel",children:[t(J,{title:e.packages.length?"Your projects":"Add your first project",lead:"tapster finds the projects cloned on this computer and adds them to the hub: it prepares the release workflow, protects the repository and proposes the hub entry."},void 0,!1,void 0,this),e.packages.length>0&&t("div",{class:"card list",children:e.packages.map((n)=>t("div",{class:"item",children:[t("span",{children:[t("span",{class:"name",children:n.name},void 0,!1,void 0,this),t("span",{class:"path",children:[" ",n.repo]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),t(F,{children:n.kind==="app"?"Mac app":n.kind==="bun"?"Bun":"Go"},void 0,!1,void 0,this)]},n.name,!0,void 0,this))},void 0,!1,void 0,this),e.invalid.length>0&&t(x,{tone:"warn",title:"The hub leaves these entries out",children:t("ul",{class:"log",children:e.invalid.map((n)=>t("li",{children:[t("code",{children:n.name},void 0,!1,void 0,this),": ",n.reason]},n.name,!0,void 0,this))},void 0,!1,void 0,this)},void 0,!1,void 0,this),t("div",{class:"row",children:t("button",{type:"button",class:"btn primary",onClick:()=>ce("/projects"),children:[e.packages.length?"Add more projects":"Find my projects",t(v,{name:"arrow"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function js({h:e,label:n}){let[s,o]=m("ed25519"),[i,a]=m(null),[r,c]=m(!1),[p,u,h]=fe();if(!i)return t("form",{class:"card pad stack tight",onSubmit:(l)=>{l.preventDefault(),h(async()=>a(await A("/api/hub/sparkle/read",{hub:e.name,label:n,account:s})))},children:[t("strong",{children:["Sparkle key ",t("code",{children:n},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("p",{class:"muted small",children:"tapster reads it from your login keychain, where Sparkle\'s generate_keys keeps it. macOS asks you first; choose Allow."},void 0,!1,void 0,this),t("div",{class:"row",style:"flex-wrap: nowrap; align-items: end",children:[t(ge,{name:`account-${n}`,label:"Keychain account",value:s,mono:!0,onInput:o},void 0,!1,void 0,this),t(L,{busy:p,class:"btn primary",type:"submit",children:[t(v,{name:"key"},void 0,!1,void 0,this),"Read it from my keychain"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),t(N,{problem:u},void 0,!1,void 0,this)]},void 0,!0,void 0,this);let f=(l)=>{l.preventDefault();let d=String(new FormData(l.currentTarget).get("password")??"");h(async()=>{await A("/api/hub/sparkle/store",{hub:e.name,label:n,pasted:d}),jt(`sparkle-${n}`),await W(),Y("ok",`Stored the Sparkle key ${n} in the hub.`)})};return t("div",{class:"card pad stack tight",children:[t("strong",{children:["Sparkle key ",t("code",{children:n},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("p",{class:"muted small",children:["It signs updates for ",i.users.join(", "),". Its public key, ",t("code",{children:i.publicKey},void 0,!1,void 0,this),", matches tapster.yml."]},void 0,!0,void 0,this),t("div",{class:"cmd",children:[t("code",{children:r?i.key:"\u2022".repeat(32)},void 0,!1,void 0,this),t("button",{type:"button",class:"btn quiet small",onClick:()=>c(!r),"aria-pressed":r,children:r?"Hide":"Show"},void 0,!1,void 0,this),t(Pt,{text:i.key},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t(x,{tone:"keys",title:"Keep a copy outside your Mac",children:t("span",{children:"If this key is lost, installed copies of the app can never update again. Paste it below: your password manager offers to save it when you store the key. tapster checks that the pasted key is the right one."},void 0,!1,void 0,this)},void 0,!1,void 0,this),t("form",{class:"secret",onSubmit:f,autoComplete:"on",children:[t(ge,{name:"username",label:"Name in your password manager",value:`${e.name}: Sparkle key ${n}`,autoComplete:"username"},void 0,!1,void 0,this),t($t,{name:"password",label:"Paste the key",hint:"The key from the box above, pasted as it is."},void 0,!1,void 0,this),t(N,{problem:u},void 0,!1,void 0,this),t("div",{class:"row",children:t(L,{busy:p,class:"btn primary",type:"submit",children:"Store in the hub"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Fs({h:e}){let n=e.name.split("/")[1],s=e.extras.sparkle.filter((o)=>!o.stored);return t("div",{class:"panel",children:[t(J,{title:"Optional extras",lead:"The hub works without these. The doorbell and the apt and dnf key run in a terminal for now, in a clone of the hub, because they need Wrangler or gpg on your computer."},void 0,!1,void 0,this),t(z,{text:`gh repo clone ${e.name} && cd ${n}`},void 0,!1,void 0,this),t("section",{class:"stack tight",children:[t("div",{class:"spread",children:[t("h3",{class:"section-title",children:"Faster releases: the doorbell"},void 0,!1,void 0,this),t(F,{tone:e.extras.doorbell?"ok":void 0,children:e.extras.doorbell?"On":"Off"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("p",{class:"muted",children:"A small Worker on your own Cloudflare account starts the hub as soon as a project opens its draft, instead of at the next scheduled run. Wrangler asks you to sign in to Cloudflare in your browser."},void 0,!1,void 0,this),!e.extras.doorbell&&t(z,{text:"bunx @doguyilmaz/tapster init --doorbell"},void 0,!1,void 0,this),t("a",{href:"https://tapster.doguyilmaz.com/guides/doorbell/",target:"_blank",rel:"noopener noreferrer",class:"small",children:"Read the doorbell guide"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("section",{class:"stack tight",children:[t("div",{class:"spread",children:[t("h3",{class:"section-title",children:"apt and dnf repositories"},void 0,!1,void 0,this),t(F,{tone:e.extras.linux.stored?"ok":e.extras.linux.wanted?"warn":void 0,children:e.extras.linux.stored?"Key stored":e.extras.linux.wanted?"Key missing":"Off"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("p",{class:"muted",children:e.extras.linux.wanted&&!e.extras.linux.stored?"tapster.yml asks for Linux packages, but the hub has no key to sign them yet.":"Linux users install your command line tools with apt and dnf from the hub\'s GitHub Pages. tapster makes the signing key with gpg and keeps a copy in your keychain."},void 0,!1,void 0,this),!e.extras.linux.stored&&t(z,{text:"bunx @doguyilmaz/tapster init --linux"},void 0,!1,void 0,this),t("a",{href:"https://tapster.doguyilmaz.com/guides/linux/",target:"_blank",rel:"noopener noreferrer",class:"small",children:"Read the apt and dnf guide"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),e.extras.sparkle.length>0&&t("section",{class:"stack tight",children:[t("div",{class:"spread",children:[t("h3",{class:"section-title",children:"Sparkle keys"},void 0,!1,void 0,this),t(F,{tone:s.length?"warn":"ok",children:s.length?`${s.length} missing`:"All stored"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("p",{class:"muted",children:"Each Mac app signs its update feed with a Sparkle key. tapster keeps it in your keychain and in the hub."},void 0,!1,void 0,this),s[0]&&t(js,{h:e,label:s[0].label},s[0].label,!1,void 0,this),s.length>1&&t("p",{class:"muted small",children:["Then: ",s.slice(1).map((o)=>o.label).join(", "),". One key at a time, so your password manager saves each under its own name."]},void 0,!0,void 0,this),t("p",{class:"faint small",children:["No key yet? Make one in a terminal with ",t("code",{children:"bunx @doguyilmaz/tapster init --sparkle <label> --new"},void 0,!1,void 0,this),"; see the"," ",t("a",{href:"https://tapster.doguyilmaz.com/guides/sparkle/",target:"_blank",rel:"noopener noreferrer",children:"Sparkle guide"},void 0,!1,void 0,this),"."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Ls({h:e}){return t("div",{class:"card pad row",style:"gap: 1.25rem; flex-wrap: nowrap",children:[t("img",{src:"/courier.webp",alt:"",width:"96",height:"96",style:"border-radius: 20%; flex: none"},void 0,!1,void 0,this),t("div",{class:"stack tight",children:[t("h2",{class:"section-title",style:"font-size: 1.15rem",children:[e.name," is ready"]},void 0,!0,void 0,this),t("p",{class:"muted",children:"Push a version tag in a project and the hub signs and publishes it on its next run. Health shows how the hub is doing."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Jn(){let e=le.value,[n,s]=m(()=>{let l=De.value;return De.value=null,l}),o=Te(null);if(Ee.value,_e.value)return t("div",{class:"stack",style:"max-width: 640px",children:[t(N,{problem:_e.value},void 0,!1,void 0,this),t("div",{class:"row",children:t("button",{type:"button",class:"btn secondary",onClick:()=>void W(),children:[t(v,{name:"refresh"},void 0,!1,void 0,this),"Try again"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(!e||e.name!==V.value)return t("p",{class:"row muted",role:"status",children:[t(j,{},void 0,!1,void 0,this)," Reading ",V.value," from GitHub"]},void 0,!0,void 0,this);let i=Dn(e.name),a=Bn(e,i),r=n??(Q.value?.kind==="created"?"app":Gn(a)),c=a.filter((l)=>l.state==="done"||l.state==="skipped").length,p=a.find((l)=>l.state==="now"||l.state==="attention"),u=(l)=>{if(s(l),window.matchMedia("(max-width: 900px)").matches)o.current?.scrollIntoView({behavior:"smooth",block:"start"})},h=(l,d)=>e.protect.environment?d:t($s,{h:e,what:l,onGo:()=>u("protect")},void 0,!1,void 0,this),f={extras:t(Fs,{h:e},void 0,!1,void 0,this),protect:t(Ps,{h:e},void 0,!1,void 0,this),app:e.app.id||e.app.held||Q.value?.kind==="unstored"?t(Yn,{h:e},void 0,!1,void 0,this):h("Create the GitHub App",t(Yn,{h:e},void 0,!1,void 0,this)),macos:t(Is,{h:e,choice:i},void 0,!1,void 0,this),certificate:h("Apple certificate",t(Es,{h:e},void 0,!1,void 0,this)),notary:h("Notarization key",t(Ms,{h:e},void 0,!1,void 0,this)),files:t(Rs,{h:e},void 0,!1,void 0,this),project:t(Vs,{h:e},void 0,!1,void 0,this)};return t("div",{class:"stack",style:"gap: 1.5rem",children:[t("div",{class:"spread",children:[t("div",{class:"stack tight",children:[t("p",{class:"eyebrow",children:[c," of ",a.length," done",p?`. Next: ${p.name}`:"",tt.value&&t(j,{label:"Checking GitHub"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("h1",{class:"title",children:p?`Set up ${e.name}`:`${e.name} is set up`},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t(q,{href:e.url,class:"btn quiet",children:[e.name," on GitHub"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),t("div",{class:"progress","aria-hidden":"true",children:t("span",{style:`width: ${c/a.length*100}%`},void 0,!1,void 0,this)},void 0,!1,void 0,this),!p&&t(Ls,{h:e},void 0,!1,void 0,this),e.empty&&t(x,{tone:"info",title:`${e.name} has no commits yet`,children:"tapster gives it a first commit when it writes the hub files."},void 0,!1,void 0,this),t("div",{class:"setup",children:[t("ol",{class:"route","aria-label":"Setup steps",children:[a.map((l,d)=>t("li",{class:`${l.state}${l.id===r?" open":""}`,children:t("button",{type:"button",onClick:()=>u(l.id),"aria-current":l.id===r?"step":void 0,"aria-label":`${l.name}: ${l.status}${l.state==="now"?", next":l.state==="attention"?", needs you":""}`,children:[t(Hs,{stop:l,index:d},void 0,!1,void 0,this),t("span",{children:[t("span",{class:"stop-name",children:l.name},void 0,!1,void 0,this),t("span",{class:"stop-state",children:l.status},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},l.id,!1,void 0,this)),t("li",{class:`extra${r==="extras"?" open":""}`,children:t("button",{type:"button",onClick:()=>u("extras"),"aria-current":r==="extras"?"step":void 0,children:[t("span",{class:"dot",children:t(v,{name:"plus"},void 0,!1,void 0,this)},void 0,!1,void 0,this),t("span",{children:[t("span",{class:"stop-name",children:"Optional extras"},void 0,!1,void 0,this),t("span",{class:"stop-state",children:"Doorbell, apt and dnf, Sparkle"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("div",{class:"card pad stack",ref:o,style:"gap: 1.5rem",children:[f[r],(()=>{let l=a.findIndex((T)=>T.id===r),d=a[l],_=a.slice(l+1).find((T)=>T.state!=="done"&&T.state!=="skipped");if(!d||d.state!=="done"&&d.state!=="skipped"||!_)return null;return t("div",{class:"row",style:"border-top: 1px solid var(--line); padding-top: 1.25rem",children:t("button",{type:"button",class:"btn primary",onClick:()=>u(_.id),children:["Continue: ",_.name,t(v,{name:"arrow"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)})()]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var ke=E({kind:"claiming"}),lt=E(!1);function Bs(){let e=new URLSearchParams(location.search),n=e.get("app");if(!n)return;let s=e.get("hub");if(s&&s!==V.value)ot(s);let o={reason:e.get("reason")??"the App could not be created",fix:e.get("fix")??"Try again."};if(n==="created")Q.value={kind:"created"};else if(n==="failed"||n==="unstored")Q.value={kind:n,problem:o};else Q.value={kind:"unknown"};history.replaceState(null,"",location.pathname)}async function Gs(){let e=/^#c=([0-9a-f]{32})$/.exec(location.hash)?.[1];if(location.hash)history.replaceState(null,"",location.pathname+location.search);if(e)try{await Pn(e)}catch(n){ke.value={kind:"failed",problem:R(n)};return}if(!An()){ke.value={kind:"no-session"};return}if(Bs(),ke.value={kind:"ready"},Z("/api/session").then((n)=>{if(Me.value=n,!V.value&&n.here.hub)ot(n.here.hub)}),await st(),V.value)W()}Hn(()=>{ke.value={kind:"no-session"}});async function Us(){try{await A("/api/quit")}catch{return}ke.value={kind:"stopped"}}function Ft({to:e,children:n}){let s=he.value===e||e==="/setup"&&he.value==="/";return t("a",{href:e,"aria-current":s?"page":void 0,onClick:(o)=>{o.preventDefault(),ce(e)},children:n},void 0,!1,void 0,this)}function Ws(){let e=oe.value;return t("header",{class:"top",children:[t("div",{class:"stripe"},void 0,!1,void 0,this),t("div",{class:"bar",children:[t("a",{class:"brand",href:"/setup",onClick:(n)=>{n.preventDefault(),ce("/setup")},children:[t("img",{src:"/logo.webp",alt:"",width:"28",height:"28"},void 0,!1,void 0,this),"tapster ",t("small",{children:"setup"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),V.value&&t("nav",{class:"nav","aria-label":"Sections",children:[t(Ft,{to:"/setup",children:"Setup"},void 0,!1,void 0,this),t(Ft,{to:"/projects",children:"Projects"},void 0,!1,void 0,this),t(Ft,{to:"/health",children:"Health"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),t("div",{class:"end",children:[V.value&&t("button",{type:"button",class:"picker",onClick:()=>lt.value=!0,"aria-label":`Hub: ${V.value}. Choose another hub`,children:[t(v,{name:"package"},void 0,!1,void 0,this),t("span",{children:V.value},void 0,!1,void 0,this),t(v,{name:"down"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),e?.state==="ok"&&t("span",{class:"who",children:["@",e.login]},void 0,!0,void 0,this),t("button",{type:"button",class:"btn quiet small",onClick:Us,title:"Stop tapster setup",children:[t(v,{name:"power"},void 0,!1,void 0,this),"Close"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function zs(){let e=ye.value;if(!e)return null;return t("div",{class:"toast",role:"status",onClick:()=>ye.value=null,children:t(x,{tone:e.tone==="ok"?"ok":"error",children:t("span",{children:e.text},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function qs(){if(!V.value||lt.value)return t(Ln,{onChosen:(e)=>{lt.value=!1,ot(e),ce("/setup",!0)},onCancel:V.value?()=>lt.value=!1:null},void 0,!1,void 0,this);if(he.value==="/projects")return t(qn,{},void 0,!1,void 0,this);if(he.value==="/health")return t(Fn,{},void 0,!1,void 0,this);return t(Jn,{},void 0,!1,void 0,this)}function Ks(){let e=ke.value;if(e.kind==="claiming")return t(It,{text:"Opening tapster setup"},void 0,!1,void 0,this);if(e.kind==="stopped")return t(Rn,{},void 0,!1,void 0,this);if(e.kind==="no-session"||e.kind==="failed")return t(On,{problem:e.kind==="failed"?e.problem:null},void 0,!1,void 0,this);let n=oe.value;if(!n)return t(It,{text:"Checking your GitHub sign-in"},void 0,!1,void 0,this);if(n.state!=="ok"||n.missing.length)return t(Vn,{},void 0,!1,void 0,this);return t(C,{children:[t(Ws,{},void 0,!1,void 0,this),t("main",{id:"main",children:t(qs,{},void 0,!1,void 0,this)},void 0,!1,void 0,this),t(zs,{},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}on(t(Ks,{},void 0,!1,void 0,this),document.getElementById("app"));Gs().catch((e)=>Y("error",R(e).reason));\n';import{timingSafeEqual as XO}from"crypto";var e2="default-src 'none'; script-src 'self'; style-src 'self'; img-src 'self' data:; connect-src 'self'; form-action 'self' https://github.com; frame-ancestors 'none'; base-uri 'none'",t2={"content-security-policy":e2,"x-content-type-options":"nosniff","referrer-policy":"no-referrer","cache-control":"no-store","cross-origin-opener-policy":"same-origin","cross-origin-resource-policy":"same-origin"};function Ve(e,t,n,r={}){return new Response(e,{status:t,headers:{...t2,...n?{"content-type":n}:{},...r}})}var ot=(e,t=200)=>Ve(JSON.stringify(e),t,"application/json; charset=utf-8");function Jv(e){if(e instanceof R)return{status:502,body:{error:{reason:e.reason,fix:e.fix}}};if(e instanceof v)return{status:400,body:{error:{reason:e.reason,fix:e.fix}}};return{status:500,body:{error:{reason:"tapster hit an unexpected error",fix:"The terminal that runs tapster setup shows the details. Try again; if it repeats, open an issue at https://github.com/doguyilmaz/tapster/issues."}}}}function Qv(e,t){return e===`127.0.0.1:${t}`||e===`localhost:${t}`}function Xv(e,t){let n=/^Bearer ([0-9a-f]{64})$/.exec(e??"")?.[1];if(!n)return!1;let r=Buffer.from(n),i=Buffer.from(t);return r.length===i.length&&XO(r,i)}var ey=`:root {
|
|
1096
|
+
--page: #f3f4f6;
|
|
1097
|
+
--paper: #ffffff;
|
|
1098
|
+
--raised: #fafafb;
|
|
1099
|
+
--ink: #16171b;
|
|
1100
|
+
--muted: #5c606c;
|
|
1101
|
+
--faint: #6e7280;
|
|
1102
|
+
--line: #e1e3e8;
|
|
1103
|
+
--line-strong: #cdd0d7;
|
|
1104
|
+
--orange: #f2891f;
|
|
1105
|
+
--orange-hover: #f79a3c;
|
|
1106
|
+
--orange-ink: #1c1206;
|
|
1107
|
+
--orange-soft: #fdf0e1;
|
|
1108
|
+
--link: #a84d06;
|
|
1109
|
+
--navy: #26315f;
|
|
1110
|
+
--navy-soft: #e9ecf6;
|
|
1111
|
+
--wax: #c8392f;
|
|
1112
|
+
--wax-soft: #fbeceb;
|
|
1113
|
+
--green: #18794a;
|
|
1114
|
+
--green-soft: #e5f4ec;
|
|
1115
|
+
--amber: #8a5a00;
|
|
1116
|
+
--amber-soft: #fbf2df;
|
|
1117
|
+
--code: #f1f2f5;
|
|
1118
|
+
--focus: color-mix(in srgb, var(--orange) 60%, transparent);
|
|
1119
|
+
--shadow: 0 1px 2px rgb(20 22 30 / 0.05), 0 8px 24px -12px rgb(20 22 30 / 0.18);
|
|
1120
|
+
--sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
|
|
1121
|
+
--mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
|
|
1122
|
+
--radius: 12px;
|
|
1123
|
+
color-scheme: light dark;
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
@media (prefers-color-scheme: dark) {
|
|
1127
|
+
:root {
|
|
1128
|
+
--page: #111217;
|
|
1129
|
+
--paper: #191b22;
|
|
1130
|
+
--raised: #1e2028;
|
|
1131
|
+
--ink: #eceef3;
|
|
1132
|
+
--muted: #a3a8b5;
|
|
1133
|
+
--faint: #8f94a3;
|
|
1134
|
+
--line: #2a2d37;
|
|
1135
|
+
--line-strong: #3a3e4a;
|
|
1136
|
+
--orange-soft: #33220f;
|
|
1137
|
+
--link: #ffae63;
|
|
1138
|
+
--navy: #93a3ea;
|
|
1139
|
+
--navy-soft: #1d2236;
|
|
1140
|
+
--wax: #ff8b80;
|
|
1141
|
+
--wax-soft: #3a1b19;
|
|
1142
|
+
--green: #69d29d;
|
|
1143
|
+
--green-soft: #12291d;
|
|
1144
|
+
--amber: #f2c063;
|
|
1145
|
+
--amber-soft: #2e2410;
|
|
1146
|
+
--code: #22252e;
|
|
1147
|
+
--shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 10px 30px -14px rgb(0 0 0 / 0.6);
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
* { box-sizing: border-box; }
|
|
1152
|
+
html { -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; }
|
|
1153
|
+
body { margin: 0; min-height: 100vh; background: var(--page); color: var(--ink); font: 400 15px/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
|
|
1154
|
+
a { color: var(--link); text-underline-offset: 3px; text-decoration-thickness: 1px; }
|
|
1155
|
+
a:hover { text-decoration-thickness: 2px; }
|
|
1156
|
+
h1, h2, h3 { margin: 0; letter-spacing: -0.015em; line-height: 1.2; }
|
|
1157
|
+
p { margin: 0; }
|
|
1158
|
+
code, .mono { font-family: var(--mono); font-size: 0.88em; }
|
|
1159
|
+
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
|
|
1160
|
+
button, input, select { font: inherit; color: inherit; }
|
|
1161
|
+
.noscript { padding: 2rem; }
|
|
1162
|
+
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
|
|
1163
|
+
|
|
1164
|
+
/* shell */
|
|
1165
|
+
.stripe { height: 4px; background: repeating-linear-gradient(-45deg, var(--wax) 0 10px, transparent 10px 15px, var(--navy) 15px 25px, transparent 25px 30px); }
|
|
1166
|
+
.top { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--page) 88%, transparent); backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--line); }
|
|
1167
|
+
.bar { max-width: 1180px; margin: 0 auto; padding: 0.7rem 1.25rem; display: flex; align-items: center; gap: 1rem; }
|
|
1168
|
+
.brand { display: inline-flex; align-items: center; gap: 0.55rem; font-weight: 700; font-size: 1.02rem; letter-spacing: -0.02em; color: var(--ink); text-decoration: none; white-space: nowrap; }
|
|
1169
|
+
.brand img { width: 28px; height: 28px; border-radius: 22%; }
|
|
1170
|
+
.brand small { font-weight: 500; color: var(--muted); font-size: 0.9rem; letter-spacing: 0; }
|
|
1171
|
+
.nav { display: flex; gap: 0.25rem; margin-left: 0.5rem; }
|
|
1172
|
+
.nav a { color: var(--muted); text-decoration: none; padding: 0.4rem 0.75rem; border-radius: 8px; font-weight: 550; }
|
|
1173
|
+
.nav a:hover { color: var(--ink); background: var(--raised); }
|
|
1174
|
+
.nav a[aria-current="page"] { color: var(--ink); background: var(--paper); box-shadow: inset 0 0 0 1px var(--line); }
|
|
1175
|
+
.bar .end { margin-left: auto; display: flex; align-items: center; gap: 0.6rem; }
|
|
1176
|
+
.who { color: var(--muted); font-size: 0.9rem; white-space: nowrap; }
|
|
1177
|
+
.picker { display: inline-flex; align-items: center; gap: 0.45rem; border: 1px solid var(--line); background: var(--paper); border-radius: 9px; padding: 0.35rem 0.65rem; cursor: pointer; font-family: var(--mono); font-size: 0.86rem; max-width: 260px; }
|
|
1178
|
+
.picker span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
1179
|
+
.picker:hover { border-color: var(--line-strong); }
|
|
1180
|
+
main { max-width: 1180px; margin: 0 auto; padding: 1.75rem 1.25rem 4rem; }
|
|
1181
|
+
|
|
1182
|
+
/* type */
|
|
1183
|
+
.eyebrow { color: var(--muted); font-size: 0.86rem; font-weight: 550; }
|
|
1184
|
+
.title { font-size: 1.65rem; font-weight: 700; }
|
|
1185
|
+
.lead { color: var(--muted); font-size: 1rem; max-width: 62ch; }
|
|
1186
|
+
.muted { color: var(--muted); }
|
|
1187
|
+
.faint { color: var(--faint); }
|
|
1188
|
+
.small { font-size: 0.88rem; }
|
|
1189
|
+
|
|
1190
|
+
/* buttons */
|
|
1191
|
+
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem; border: 1px solid transparent; border-radius: 10px; padding: 0.6rem 1.05rem; font-weight: 600; cursor: pointer; text-decoration: none; line-height: 1.2; white-space: nowrap; transition: background 0.12s, border-color 0.12s; }
|
|
1192
|
+
.btn.primary { background: var(--orange); color: var(--orange-ink); }
|
|
1193
|
+
.btn.primary:hover { background: var(--orange-hover); }
|
|
1194
|
+
.btn.secondary { background: var(--paper); border-color: var(--line-strong); color: var(--ink); }
|
|
1195
|
+
.btn.secondary:hover { border-color: var(--faint); }
|
|
1196
|
+
.btn.quiet { background: none; color: var(--link); padding: 0.4rem 0.5rem; }
|
|
1197
|
+
.btn.quiet:hover { background: var(--raised); }
|
|
1198
|
+
.btn.danger { background: var(--wax); color: #fff; }
|
|
1199
|
+
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
|
|
1200
|
+
.btn.small { padding: 0.38rem 0.7rem; font-size: 0.88rem; border-radius: 8px; }
|
|
1201
|
+
.row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
|
|
1202
|
+
.stack { display: grid; gap: 1rem; }
|
|
1203
|
+
.stack.tight { gap: 0.5rem; }
|
|
1204
|
+
.spread { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
|
|
1205
|
+
|
|
1206
|
+
/* icons */
|
|
1207
|
+
.icon { width: 1.1em; height: 1.1em; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
|
|
1208
|
+
.spin { animation: spin 0.9s linear infinite; }
|
|
1209
|
+
@keyframes spin { to { transform: rotate(360deg); } }
|
|
1210
|
+
|
|
1211
|
+
/* cards and notes */
|
|
1212
|
+
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
|
|
1213
|
+
.card.pad { padding: 1.5rem; }
|
|
1214
|
+
.note { display: flex; gap: 0.7rem; align-items: flex-start; border-radius: 10px; padding: 0.8rem 1rem; background: var(--raised); border: 1px solid var(--line); font-size: 0.93rem; }
|
|
1215
|
+
.note .icon { margin-top: 0.18rem; }
|
|
1216
|
+
.note > div { display: grid; gap: 0.25rem; min-width: 0; }
|
|
1217
|
+
.note strong { font-weight: 650; }
|
|
1218
|
+
.note.keys { background: var(--navy-soft); border-color: color-mix(in srgb, var(--navy) 25%, transparent); }
|
|
1219
|
+
.note.keys .icon { color: var(--navy); }
|
|
1220
|
+
.note.ok { background: var(--green-soft); border-color: color-mix(in srgb, var(--green) 25%, transparent); }
|
|
1221
|
+
.note.ok .icon { color: var(--green); }
|
|
1222
|
+
.note.warn { background: var(--amber-soft); border-color: color-mix(in srgb, var(--amber) 28%, transparent); }
|
|
1223
|
+
.note.warn .icon { color: var(--amber); }
|
|
1224
|
+
.note.error { background: var(--wax-soft); border-color: color-mix(in srgb, var(--wax) 30%, transparent); }
|
|
1225
|
+
.note.error .icon { color: var(--wax); }
|
|
1226
|
+
.badge { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.78rem; font-weight: 600; padding: 0.14rem 0.5rem; border-radius: 999px; background: var(--raised); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
|
|
1227
|
+
.badge.ok { background: var(--green-soft); color: var(--green); border-color: transparent; }
|
|
1228
|
+
.badge.warn { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
|
|
1229
|
+
.badge.error { background: var(--wax-soft); color: var(--wax); border-color: transparent; }
|
|
1230
|
+
.badge.next { background: var(--orange-soft); color: var(--link); border-color: transparent; }
|
|
1231
|
+
|
|
1232
|
+
/* command rows */
|
|
1233
|
+
.cmd { display: flex; align-items: center; gap: 0.5rem; background: var(--code); border: 1px solid var(--line); border-radius: 9px; padding: 0.45rem 0.45rem 0.45rem 0.8rem; font-family: var(--mono); font-size: 0.86rem; min-width: 0; }
|
|
1234
|
+
.cmd code { flex: 1; overflow-x: auto; white-space: nowrap; font-size: inherit; }
|
|
1235
|
+
.cmd .btn { flex: none; }
|
|
1236
|
+
pre.block { margin: 0; background: var(--code); border: 1px solid var(--line); border-radius: 9px; padding: 0.8rem 1rem; overflow: auto; font: 0.82rem/1.55 var(--mono); max-height: 26rem; }
|
|
1237
|
+
|
|
1238
|
+
/* forms */
|
|
1239
|
+
form.secret { display: grid; gap: 1rem; }
|
|
1240
|
+
.field { display: grid; gap: 0.35rem; }
|
|
1241
|
+
.field > label, .field > .label { font-weight: 600; font-size: 0.92rem; }
|
|
1242
|
+
.field .hint { color: var(--muted); font-size: 0.86rem; }
|
|
1243
|
+
.input { width: 100%; border: 1px solid var(--line-strong); background: var(--paper); border-radius: 9px; padding: 0.55rem 0.75rem; min-width: 0; }
|
|
1244
|
+
.input:hover { border-color: var(--faint); }
|
|
1245
|
+
.input:focus { outline: 3px solid var(--focus); outline-offset: 0; border-color: var(--orange); }
|
|
1246
|
+
.input.mono { font-family: var(--mono); font-size: 0.88rem; }
|
|
1247
|
+
.with-toggle { position: relative; }
|
|
1248
|
+
.with-toggle .input { padding-right: 4.6rem; }
|
|
1249
|
+
.with-toggle button { position: absolute; right: 0.35rem; top: 50%; transform: translateY(-50%); }
|
|
1250
|
+
.drop { position: relative; display: flex; align-items: center; gap: 0.9rem; border: 1.5px dashed var(--line-strong); border-radius: 11px; padding: 0.95rem 1rem; background: var(--raised); cursor: pointer; transition: border-color 0.12s, background 0.12s; }
|
|
1251
|
+
.drop:hover, .drop.over { border-color: var(--orange); background: var(--orange-soft); }
|
|
1252
|
+
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
|
|
1253
|
+
.drop:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
|
|
1254
|
+
.drop .icon { width: 1.6rem; height: 1.6rem; color: var(--muted); }
|
|
1255
|
+
.drop.has { border-style: solid; border-color: color-mix(in srgb, var(--green) 45%, transparent); background: var(--green-soft); }
|
|
1256
|
+
.drop.has .icon { color: var(--green); }
|
|
1257
|
+
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
|
|
1258
|
+
.switch { display: flex; gap: 0.75rem; align-items: flex-start; padding: 0.85rem 1rem; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); cursor: pointer; }
|
|
1259
|
+
.switch input { margin-top: 0.25rem; accent-color: var(--orange); width: 1.05rem; height: 1.05rem; flex: none; }
|
|
1260
|
+
.switch strong { display: block; font-weight: 600; }
|
|
1261
|
+
.switch span { color: var(--muted); font-size: 0.88rem; }
|
|
1262
|
+
select.input { appearance: auto; }
|
|
1263
|
+
|
|
1264
|
+
/* setup route */
|
|
1265
|
+
.setup { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 2rem; align-items: start; }
|
|
1266
|
+
.route { position: sticky; top: 5.5rem; list-style: none; margin: 0; padding: 0; }
|
|
1267
|
+
.route li { position: relative; }
|
|
1268
|
+
.route li.extra { margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px dashed var(--line); }
|
|
1269
|
+
.route li.extra::before, .route li:has(+ li.extra)::before { display: none; }
|
|
1270
|
+
.route li:not(:last-child)::before { content: ""; position: absolute; left: 15px; top: 34px; bottom: -6px; width: 2px; background: var(--line); }
|
|
1271
|
+
.route li.done:not(:last-child)::before { background: color-mix(in srgb, var(--green) 45%, var(--line)); }
|
|
1272
|
+
.route button { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 0.75rem; align-items: start; width: 100%; text-align: left; padding: 0.45rem 0.6rem 0.9rem 0; background: none; border: 0; cursor: pointer; border-radius: 10px; }
|
|
1273
|
+
.route button:hover .stop-name { color: var(--link); }
|
|
1274
|
+
.dot { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--paper); border: 2px solid var(--line-strong); color: var(--faint); font-size: 0.8rem; font-weight: 700; }
|
|
1275
|
+
.done .dot { background: var(--green); border-color: var(--green); color: #fff; }
|
|
1276
|
+
.now .dot { border-color: var(--orange); color: var(--link); box-shadow: 0 0 0 4px var(--orange-soft); }
|
|
1277
|
+
.skipped .dot { border-style: dashed; }
|
|
1278
|
+
.attention .dot { border-color: var(--wax); color: var(--wax); }
|
|
1279
|
+
.stop-name { display: block; font-weight: 600; line-height: 1.3; padding-top: 0.25rem; }
|
|
1280
|
+
.stop-state { display: block; color: var(--muted); font-size: 0.84rem; }
|
|
1281
|
+
.route li.open .stop-name { color: var(--ink); }
|
|
1282
|
+
.now .stop-state { color: var(--link); font-weight: 550; }
|
|
1283
|
+
.attention .stop-state { color: var(--wax); font-weight: 550; }
|
|
1284
|
+
.eyebrow .icon { margin-left: 0.4rem; vertical-align: -0.15em; }
|
|
1285
|
+
.route li.open button { background: var(--paper); box-shadow: inset 0 0 0 1px var(--line); padding-left: 0; }
|
|
1286
|
+
.panel { display: grid; gap: 1.4rem; }
|
|
1287
|
+
.panel-head { display: grid; gap: 0.45rem; }
|
|
1288
|
+
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 0.45rem 1.25rem; margin: 0; }
|
|
1289
|
+
.facts dt { color: var(--muted); }
|
|
1290
|
+
.facts dd { margin: 0; font-weight: 550; overflow-wrap: anywhere; }
|
|
1291
|
+
.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.45rem; }
|
|
1292
|
+
.checks li { display: flex; gap: 0.6rem; align-items: flex-start; }
|
|
1293
|
+
.checks .icon { margin-top: 0.2rem; }
|
|
1294
|
+
.checks .ok { color: var(--green); }
|
|
1295
|
+
.checks .no { color: var(--faint); }
|
|
1296
|
+
.checks .bad { color: var(--wax); }
|
|
1297
|
+
.section-title { font-size: 0.95rem; font-weight: 650; }
|
|
1298
|
+
.seal { display: inline-grid; place-items: center; width: 54px; height: 54px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ee6b56, #c8392f 60%, #8f2019); color: #ffe0d8; box-shadow: 0 6px 14px -6px rgb(143 32 25 / 0.6); }
|
|
1299
|
+
.seal .icon { width: 26px; height: 26px; stroke-width: 3; }
|
|
1300
|
+
.progress { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
|
|
1301
|
+
.progress span { display: block; height: 100%; background: var(--green); border-radius: inherit; transition: width 0.3s; }
|
|
1302
|
+
|
|
1303
|
+
/* lists */
|
|
1304
|
+
.list { display: grid; }
|
|
1305
|
+
.item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1rem; align-items: center; padding: 0.95rem 1.1rem; border-top: 1px solid var(--line); }
|
|
1306
|
+
.item:first-child { border-top: 0; }
|
|
1307
|
+
.item > .badge { justify-self: start; }
|
|
1308
|
+
.item .name { font-family: var(--mono); font-weight: 600; font-size: 0.93rem; overflow-wrap: anywhere; }
|
|
1309
|
+
.item .path { color: var(--faint); font-size: 0.83rem; overflow-wrap: anywhere; }
|
|
1310
|
+
.item button.link { all: unset; cursor: pointer; display: grid; gap: 0.15rem; min-width: 0; }
|
|
1311
|
+
.item button.link:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; border-radius: 6px; }
|
|
1312
|
+
.item:hover .name { color: var(--link); }
|
|
1313
|
+
.files .file { border: 1px solid var(--line); border-radius: 10px; background: var(--paper); }
|
|
1314
|
+
.files summary { display: flex; align-items: center; gap: 0.7rem; padding: 0.7rem 0.9rem; cursor: pointer; list-style: none; }
|
|
1315
|
+
.files summary::-webkit-details-marker { display: none; }
|
|
1316
|
+
.files summary code { flex: 1; }
|
|
1317
|
+
.files .file pre { border: 0; border-top: 1px solid var(--line); border-radius: 0 0 10px 10px; }
|
|
1318
|
+
.diff .add { background: var(--green-soft); color: var(--green); display: block; }
|
|
1319
|
+
.diff .del { background: var(--wax-soft); color: var(--wax); display: block; }
|
|
1320
|
+
.diff .ctx { display: block; color: var(--muted); }
|
|
1321
|
+
.diff .hunk { display: block; color: var(--navy); }
|
|
1322
|
+
.log { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.45rem; font-size: 0.92rem; }
|
|
1323
|
+
.log li { white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
1324
|
+
|
|
1325
|
+
/* sheet */
|
|
1326
|
+
.sheet-back { position: fixed; inset: 0; background: rgb(10 12 18 / 0.45); z-index: 40; animation: fade 0.15s ease-out; }
|
|
1327
|
+
.sheet { position: fixed; top: 0; right: 0; bottom: 0; width: min(720px, 100vw); background: var(--page); z-index: 41; overflow-y: auto; box-shadow: -20px 0 50px -20px rgb(0 0 0 / 0.35); animation: slide 0.2s ease-out; }
|
|
1328
|
+
.sheet-head { position: sticky; top: 0; background: color-mix(in srgb, var(--page) 92%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); padding: 1rem 1.4rem; display: flex; align-items: center; gap: 1rem; z-index: 1; }
|
|
1329
|
+
.sheet-body { padding: 1.4rem; display: grid; gap: 1.25rem; }
|
|
1330
|
+
.sheet-body > *, .panel > *, .stack > * { min-width: 0; }
|
|
1331
|
+
@keyframes fade { from { opacity: 0; } }
|
|
1332
|
+
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
|
|
1333
|
+
|
|
1334
|
+
/* gates */
|
|
1335
|
+
.gate { min-height: calc(100vh - 4px); display: grid; place-items: center; padding: 1.5rem; }
|
|
1336
|
+
.gate .card { max-width: 560px; width: 100%; padding: 2rem; display: grid; gap: 1.1rem; }
|
|
1337
|
+
.gate img.mascot { width: 112px; height: 112px; border-radius: 24%; }
|
|
1338
|
+
.hello { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 2rem; align-items: center; }
|
|
1339
|
+
.hello img { width: 220px; height: 220px; border-radius: 22%; box-shadow: var(--shadow); }
|
|
1340
|
+
.choices { display: grid; gap: 0.6rem; }
|
|
1341
|
+
.choice { display: flex; align-items: center; gap: 0.9rem; padding: 0.95rem 1.1rem; border: 1px solid var(--line); border-radius: 11px; background: var(--paper); cursor: pointer; text-align: left; width: 100%; }
|
|
1342
|
+
.choice:hover { border-color: var(--orange); }
|
|
1343
|
+
.choice .grow { flex: 1; min-width: 0; display: grid; gap: 0.1rem; }
|
|
1344
|
+
.toast { cursor: pointer; position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); z-index: 50; max-width: min(560px, calc(100vw - 2rem)); animation: rise 0.2s ease-out; }
|
|
1345
|
+
@keyframes rise { from { transform: translate(-50%, 10px); opacity: 0; } }
|
|
1346
|
+
|
|
1347
|
+
@media (max-width: 900px) {
|
|
1348
|
+
.setup { grid-template-columns: minmax(0, 1fr); gap: 1.25rem; }
|
|
1349
|
+
.route { position: static; display: flex; overflow-x: auto; gap: 0.25rem; padding-bottom: 0.25rem; }
|
|
1350
|
+
.route li:not(:last-child)::before { display: none; }
|
|
1351
|
+
.route li.extra { margin: 0; padding: 0 0 0 0.25rem; border-top: 0; border-left: 1px dashed var(--line); }
|
|
1352
|
+
.route li { flex: none; }
|
|
1353
|
+
.route button { grid-template-columns: 28px auto; padding: 0.4rem 0.7rem 0.4rem 0.4rem; align-items: center; }
|
|
1354
|
+
.route .stop-state { display: none; }
|
|
1355
|
+
.route .stop-name { padding: 0; font-size: 0.88rem; }
|
|
1356
|
+
.dot { width: 28px; height: 28px; }
|
|
1357
|
+
.hello { grid-template-columns: minmax(0, 1fr); }
|
|
1358
|
+
.hello img { width: 140px; height: 140px; }
|
|
1359
|
+
}
|
|
1360
|
+
|
|
1361
|
+
@media (max-width: 640px) {
|
|
1362
|
+
.bar { flex-wrap: wrap; gap: 0.6rem; padding: 0.6rem 1rem; }
|
|
1363
|
+
.bar .end { order: 2; width: 100%; margin: 0; justify-content: space-between; }
|
|
1364
|
+
.picker { flex: 1; max-width: none; }
|
|
1365
|
+
.nav { order: 3; width: 100%; margin: 0; }
|
|
1366
|
+
.who { display: none; }
|
|
1367
|
+
main { padding: 1.25rem 1rem 3rem; }
|
|
1368
|
+
.card.pad { padding: 1.1rem; }
|
|
1369
|
+
.grid2 { grid-template-columns: minmax(0, 1fr); }
|
|
1370
|
+
.item { grid-template-columns: minmax(0, 1fr); }
|
|
1371
|
+
.facts { grid-template-columns: minmax(0, 1fr); gap: 0.1rem; }
|
|
1372
|
+
.facts dd { margin-bottom: 0.5rem; }
|
|
1373
|
+
.title { font-size: 1.4rem; }
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1376
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1377
|
+
*, *::before, *::after { animation: none !important; transition: none !important; }
|
|
1378
|
+
}
|
|
1379
|
+
`;var r2=600000,i2=new Set(["/","/setup","/projects","/health"]),ty=(e)=>Buffer.from(e.slice(e.indexOf(",")+1),"base64"),ny={"/logo.webp":ty(fn),"/courier.webp":ty(co)},o2=`<!doctype html>
|
|
1380
|
+
<html lang="en">
|
|
1381
|
+
<head>
|
|
1382
|
+
<meta charset="utf-8">
|
|
1383
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
1384
|
+
<meta name="color-scheme" content="light dark">
|
|
1385
|
+
<title>tapster setup</title>
|
|
1386
|
+
<link rel="icon" href="/logo.webp">
|
|
1387
|
+
<link rel="stylesheet" href="/app.css">
|
|
1388
|
+
<script type="module" src="/app.js"></script>
|
|
1389
|
+
</head>
|
|
1390
|
+
<body>
|
|
1391
|
+
<div id="app"></div>
|
|
1392
|
+
<noscript><p class="noscript">tapster setup needs JavaScript. The same steps work in a terminal: tapster init and tapster add.</p></noscript>
|
|
1393
|
+
</body>
|
|
1394
|
+
</html>
|
|
1395
|
+
`;function Lo(e,t){let n={deps:e,port:t,token:pl(32).toString("hex"),codes:new Map,claimed:new Set,pending:new Map,apps:new Map,sparkle:new Map,touched:Date.now(),login:null,link:()=>{let r=pl(16).toString("hex");return n.codes.set(r,Date.now()+r2),`http://127.0.0.1:${n.port}/#c=${r}`}};return n}async function re(e,t){let n;try{n=await e.json()}catch{throw new v("the request was not JSON","Reload the page and try again.")}let r=t.safeParse(n);if(!r.success)throw new v("the request did not have the expected fields","Reload the page and try again.");return r.data}function s2(e,t){if(typeof t!=="string"||!/^[0-9a-f]{32}$/.test(t))return ot({error:{reason:"this link is not a tapster setup link",fix:"Press Enter in the terminal that runs tapster setup for a fresh link."}},400);if(e.claimed.has(t))return e.token=pl(32).toString("hex"),e.codes.clear(),e.deps.log("tapster setup: the same link was opened twice, so tapster ended every session for safety."),e.deps.log(`Open this fresh link in your browser: ${e.link()}`),ot({error:{reason:"this link was already used",fix:"tapster ended every session for safety. Open the fresh link the terminal printed."}},409);let n=e.codes.get(t);if(n===void 0||n<Date.now())return ot({error:{reason:"this link has expired",fix:"Press Enter in the terminal that runs tapster setup for a fresh link."}},410);return e.codes.delete(t),e.claimed.add(t),e.touched=Date.now(),ot({token:e.token})}function ry(e,t,n){return async(r)=>{if(!Qv(r.headers.get("host"),e.port))return Ve("Misdirected request",421,"text/plain; charset=utf-8");let i=new URL(r.url),o=i.pathname;if(r.method==="GET"&&i2.has(o))return Ve(o2,200,"text/html; charset=utf-8");if(r.method==="GET"&&o==="/app.css")return Ve(ey,200,"text/css; charset=utf-8");if(r.method==="GET"&&o==="/app.js")return Ve(await Yv(),200,"text/javascript; charset=utf-8");if(r.method==="GET"&&ny[o])return Ve(new Uint8Array(ny[o]),200,"image/webp");if(r.method==="GET"&&o==="/app/callback")return n({s:e,req:r,url:i});if(r.method==="POST"&&o==="/api/claim"){let a=await r.json().catch(()=>null);return s2(e,a?.code)}if(!o.startsWith("/api/"))return Ve("Not found",404,"text/plain; charset=utf-8");if(!Xv(r.headers.get("authorization"),e.token))return ot({error:{reason:"this page is not signed in to tapster setup",fix:"Press Enter in the terminal that runs tapster setup for a fresh link."}},401);e.touched=Date.now();let s=t[`${r.method} ${o}`];if(!s)return ot({error:{reason:"unknown request",fix:"Reload the page."}},404);try{return ot(await s({s:e,req:r,url:i})??{})}catch(a){let c=Jv(a);if(c.status===500)e.deps.log(`tapster setup: ${r.method} ${o} failed: ${dn(a instanceof Error?`${a.name}: ${a.message}`:"unknown error")}`);return ot(c.body,c.status)}}}var c2=/^[A-Za-z0-9-]+\/homebrew-[A-Za-z0-9._-]+$/,l2="tapster: the hub needs attention";async function u2(e){let t;try{t=await e.deps.github()}catch(s){if(s instanceof v&&/not installed/.test(s.reason))return{state:"no-gh"};return{state:"signed-out"}}let n;try{n=await t.request("GET","/user")}catch(s){if(s instanceof R&&s.status===401)return{state:"signed-out"};throw s}let r=await n.json();e.login=r.login;let i=n.headers.get("x-oauth-scopes"),o=i===null?null:i.split(",").map((s)=>s.trim());return{state:"ok",login:r.login,missing:o===null?[]:["repo","workflow"].filter((s)=>!o.includes(s))}}async function Ye(e){let t=await e.deps.github();return e.login??=(await t.json("GET","/user")).login,{gh:t,login:e.login}}function st(e,t){if(typeof e!=="string"||!c2.test(e))throw new v("that is not a hub name","A hub is one of your repositories whose name starts with homebrew-, such as you/homebrew-tap.");if(e.split("/")[0].toLowerCase()!==t.toLowerCase())throw new v(`${e} does not belong to ${t}`,"tapster serves repositories of your own account.");return e}async function we(e,t){let{gh:n,login:r}=await Ye(e.s);return{gh:n,hub:st(t,r),login:r}}var dl=async(e)=>{try{return await e}catch(t){if(t instanceof R&&t.status===404)return null;throw t}},iy=async(e,t)=>{try{return(await e.json("GET",`/repos/${t}/git/ref/heads/main`)).object.sha}catch(n){if(n instanceof R&&(n.status===404||n.status===409))return null;throw n}};async function hl(e,t){let n=[];for(let i=1;i<=5;i++){let o=await e.json("GET",`/user/repos?affiliation=owner&sort=updated&per_page=100&page=${i}`);if(n.push(...o),o.length<100)break}let r=n.filter((i)=>i.name.startsWith("homebrew-")&&i.owner.login.toLowerCase()===t.toLowerCase());return Promise.all(r.map(async(i)=>({name:i.full_name,private:i.private,url:i.html_url,tapster:await dl(e.json("GET",`/repos/${i.full_name}/environments/tapster`))!==null})))}function p2(e){let t=[];for(let[n,r]of Object.entries(e)){if(n==="tapster.yml")continue;let i;try{i=ie(r)}catch{t.push({file:n,actions:["(the file is not valid YAML)"]});continue}let o=i?.jobs??{},a=Object.values(o).flatMap((c)=>[c?.uses,...(c?.steps??[]).map((l)=>l?.uses)]).filter((c)=>typeof c==="string").filter((c)=>{if(c.startsWith("./"))return!1;let[l,u]=c.split("@"),p=(l??"").split("/")[0].toLowerCase();return!(p==="actions"||p==="github"||(l??"").toLowerCase()==="doguyilmaz/tapster")||!/^[0-9a-f]{40}$/.test(u??"")});if(a.length)t.push({file:n,actions:[...new Set(a)]})}return t}async function fl(e,t,n){let r=await t.json("GET",`/repos/${n}`),o=await iy(t,n)===null,s=await dl(t.json("GET",`/repos/${n}/environments/tapster`)),a=async(I)=>s?(await t.json("GET",`/repos/${n}/environments/tapster/${I}?per_page=100`))[I]??[]:[],[c,l,u,p,d,h]=await Promise.all([a("variables"),a("secrets"),s?t.json("GET",`/repos/${n}/environments/tapster/deployment-branch-policies`):Promise.resolve({branch_policies:[]}),t.json("GET",`/repos/${n}/rulesets`).catch(()=>[]),t.json("GET",`/repos/${n}/actions/permissions`),t.json("GET",`/repos/${n}/actions/permissions/workflow`)]),f=await Promise.all(p.map((I)=>t.json("GET",`/repos/${n}/rulesets/${I.id}`))),m=d.allowed_actions==="selected"?await t.json("GET",`/repos/${n}/actions/permissions/selected-actions`):null,g=(I)=>o?Promise.resolve(null):de(t,n,I,"main"),[w,x,_,b,k]=await Promise.all([g("tapster.yml"),g(".tapster/state.json"),g("README.md"),g(J),o?Promise.resolve([]):t.json("GET",`/repos/${n}/contents/.github/workflows?ref=main`).catch(()=>[])]),S={};for(let I of k.filter((Ht)=>Ht.type==="file"&&/\.ya?ml$/.test(Ht.name)))S[I.name]=await g(`.github/workflows/${I.name}`)??"";let O=(I)=>I.map((Ht)=>Ht.name),A=(I)=>c.find((Ht)=>Ht.name===I)?.value??null,L=w===null?null:(()=>{try{return ne(w,n.split("/")[0])}catch{return null}})(),ae=Boolean(s?.deployment_branch_policy?.custom_branch_policies)&&u.branch_policies.length===1&&u.branch_policies[0].name==="main",ke=[{label:"a tapster environment that only main may open",ok:ae},{label:"main cannot be deleted or force-pushed",ok:Jc(f).ok},{label:"workflows run only GitHub's and tapster's actions, pinned by commit",ok:Qc(d,m).ok},{label:"the workflows' default token is read-only",ok:h.default_workflow_permissions==="read"}],B=A("TAPSTER_APP_ID"),St=e.apps.get(n),jy=L?.config.packages.some(no)??!1,My=Boolean(A("TAPSTER_TEAM_ID"))||O(l).includes("MACOS_NOTARY_KEY"),Ho=b?Gt.exec(b):null,Sn=(await t.json("GET",`/repos/${n}/issues?state=open&creator=${encodeURIComponent("github-actions[bot]")}&per_page=100`).catch(()=>[])).find((I)=>I.title===l2&&I.user?.login==="github-actions[bot]");return{name:n,url:r.html_url,private:r.private,empty:o,protect:{done:ke.every((I)=>I.ok),environment:ae,checks:ke,others:p2(S)},app:{id:B,slug:A("TAPSTER_APP_SLUG"),key:O(l).includes("TAPSTER_APP_PRIVATE_KEY"),held:Boolean(St),installed:St?await oy(e,n):null},apple:{needed:My||jy?!0:null,certificate:A("TAPSTER_TEAM_ID")?{team:A("TAPSTER_TEAM_ID"),expires:A("TAPSTER_CERT_EXPIRES")??""}:null,certificateStored:["MACOS_SIGN_P12","MACOS_SIGN_PASSWORD"].every((I)=>O(l).includes(I)),notary:["MACOS_NOTARY_KEY","MACOS_NOTARY_KEY_ID","MACOS_NOTARY_ISSUER_ID"].every((I)=>O(l).includes(I))},files:{config:w!==null,state:x!==null,readme:_!==null,workflow:Vc(b,se,e.deps.pin),pinned:Ho?`${Ho[2]} (${Ho[1].slice(0,7)})`:null,every:b?rt(b):null},packages:(L?.config.packages??[]).map((I)=>({name:I.name,repo:I.repo,kind:Y(I)?"app":I.kind})),invalid:(L?.invalid??[]).map((I)=>({name:I.name,reason:I.reason})),issue:Sn?{url:Sn.html_url,number:Sn.number,updated:Sn.updated_at,body:Sn.body??""}:null,extras:{doorbell:A("TAPSTER_DOORBELL")!==null,linux:{wanted:L?.config.packages.some((I)=>!Y(I)&&I.linux)??!1,stored:O(l).includes("TAPSTER_LINUX_KEY")},sparkle:(L?Te(L.config):[]).map((I)=>({label:I,stored:O(l).includes(`SPARKLE_KEY_${I.toUpperCase()}`)}))}}}async function oy(e,t){let n=e.apps.get(t);if(!n)return{checked:!1,id:null,onHub:!1,repos:[]};let r=t.split("/")[0],i=await Oo(n.id,n.pem,r,t,new pe(Be(n.id,n.pem),e.deps.fetch)),o=i.id===null?[]:await Ig(n.id,n.pem,r,e.deps.fetch)??[];return{checked:!0,id:i.id,onHub:i.onHub,repos:o}}async function bn(e,t){let n=await dl(e.json("GET",`/repos/${t}/environments/tapster`)),r=n?await e.json("GET",`/repos/${t}/environments/tapster/deployment-branch-policies`):{branch_policies:[]};if(!(Boolean(n?.deployment_branch_policy?.custom_branch_policies)&&r.branch_policies.length===1&&r.branch_policies[0].name==="main"&&(r.branch_policies[0].type??"branch")==="branch"))throw new v(`${t}'s tapster environment is not locked to main`,"Protect the hub first: keys go into that environment only once workflows on other branches cannot open it.")}async function sy(e,t,n){let i=(await ul(e,t,n).catch((o)=>{if(o instanceof R&&o.status===404)return[];throw o})).filter((o)=>!o.startsWith("GitHub shows no push by"));if(i.length)throw new v(`main changed in ways only you may change it: ${i.join("; ")}`,"Review those commits on GitHub and revert what you did not make. tapster writes nothing to main until then, because a write from you would mark them as reviewed.")}var jo=z({hub:E()}).strict();async function d2(e){let{hub:t}=await re(e.req,jo),{gh:n}=await we(e,t),r=await n.json("GET",`/repos/${t}`);return await ll(n,t,r.private),{done:!0}}async function h2(e){let{hub:t}=await re(e.req,jo),{gh:n,login:r}=await we(e,t);await bn(n,t);let i=a2(16).toString("hex");for(let[s,a]of e.s.pending)if(Date.now()-a.at>3600000)e.s.pending.delete(s);e.s.pending.set(i,{hub:t,owner:r,at:Date.now()});let o=Eo(r,t,`http://127.0.0.1:${e.s.port}/app/callback`);return{action:`https://github.com/settings/apps/new?state=${i}`,manifest:JSON.stringify(o),permissions:zc(o),name:o.name}}async function ay(e){let t=(s)=>new Response(null,{status:303,headers:{location:`/setup?${new URLSearchParams(s)}`,"cache-control":"no-store","referrer-policy":"no-referrer"}}),n=e.url.searchParams.get("state")??"",r=e.url.searchParams.get("code")??"",i=e.s.pending.get(n);if(!i||!/^[A-Za-z0-9_-]{1,128}$/.test(r))return t({app:"unknown"});e.s.pending.delete(n);let o;try{o=await Dc(r,i.owner,"If GitHub created the App anyway, delete it at https://github.com/settings/apps first, because its name would block a new one. Then create it again.",e.s.deps.fetch)}catch(s){let a=s instanceof v?s:new v("GitHub did not hand over the new App","Try again from Setup.");return t({app:"failed",hub:i.hub,reason:a.reason,fix:a.fix})}e.s.apps.set(i.hub,{id:String(o.id),pem:o.pem,slug:o.slug});try{return await bn(await e.s.deps.github(),i.hub),await Sr(i.hub,o),t({app:"created",hub:i.hub})}catch(s){let a=s instanceof v?s:new v("the App's key could not be stored","Try again.");return t({app:"unstored",hub:i.hub,reason:a.reason,fix:a.fix})}}async function f2(e){let{hub:t}=await re(e.req,jo),{gh:n}=await we(e,t);await bn(n,t);let r=e.s.apps.get(t);if(!r)throw new v("this setup no longer holds the App's key","GitHub hands the key over only once. Delete the App at https://github.com/settings/apps, then create it again here.");return await Sr(t,{id:Number(r.id),slug:r.slug,pem:r.pem}),{stored:!0}}async function m2(e){let{hub:t}=await we(e,e.url.searchParams.get("hub"));return oy(e.s,t)}var cy=(e,t,n)=>{let r=e.get(t);if(!(r instanceof File)||r.size===0)throw new v(`no ${t} file was attached`,"Choose the file and try again.");if(r.size>n)throw new v(`that ${t} file is too large`,"Choose the file Apple or Keychain Access gave you.");return r.arrayBuffer().then((i)=>new Uint8Array(i))};async function ly(e){try{return await e.req.formData()}catch{throw new v("the form could not be read","Reload the page and try again.")}}async function g2(e){let t=await ly(e),{gh:n,hub:r}=await we(e,t.get("hub"));await bn(n,r);let i=await cy(t,"p12",tl),o=String(t.get("password")??""),s=await Co(i,o);return await Ro(r,i,o,s),s}async function v2(e){let t=await ly(e),{gh:n,hub:r}=await we(e,t.get("hub"));await bn(n,r);let i=Io(await cy(t,"p8",nl),String(t.get("keyId")??""),String(t.get("issuerId")??"")),o=await e.s.deps.notary(i);return await zo(r,i),{checked:o}}var uy=z({hub:E(),every:bc().int().nullable(),remove:ue(E()).max(20),readme:tt()}).strict();async function py(e,t,n,r,i,o,s){let a=await t.json("GET",`/repos/${n}`),c=await So(t,n,s,e.s.deps.pin,{every:r,isPrivate:a.private}),l=Vc(await s(J),se,e.s.deps.pin)==="newer",u=[];for(let f of c.files.filter((m)=>!(l&&m.path===J)))u.push({path:f.path,content:f.content,before:f.before,change:f.before===null?"create":f.before===f.content?"same":"update"});let p=xo(n).find((f)=>f.path==="README.md"),d=c.kept.includes("README.md")?await s("README.md"):null;if(o&&d!==null&&d!==p.content)u.push({path:"README.md",content:p.content,before:d,change:"update"});let h=i.filter((f)=>/^[A-Za-z0-9._-]+\.ya?ml$/.test(f)&&f!=="tapster.yml");for(let f of h){let m=await s(`.github/workflows/${f}`);if(m!==null)u.push({path:`.github/workflows/${f}`,content:"",before:m,change:"remove"})}return{files:u,kept:c.kept,pin:l?"kept: the hub runs a newer tapster than this one":c.change,notes:l?[]:c.notes,foreign:[],readme:d!==null&&d!==p.content}}async function y2(e){let t=await re(e.req,uy),{gh:n,hub:r,login:i}=await we(e,t.hub),o=await py(e,n,r,t.every,t.remove,t.readme,(a)=>de(n,r,a,"main")),s=await ul(n,r,i).catch(()=>[]);return{...o,foreign:s.filter((a)=>!a.startsWith("GitHub shows no push by"))}}async function b2(e){let t=await re(e.req,uy),{gh:n,hub:r,login:i}=await we(e,t.hub);if(await iy(n,r)===null){let s=xo(r).find((a)=>a.path==="README.md");if(await n.json("PUT",`/repos/${r}/contents/README.md`,{message:"Start the tap",content:Buffer.from(s.content).toString("base64"),branch:"main"}),(await n.json("GET",`/repos/${r}`)).default_branch!=="main")await n.json("PATCH",`/repos/${r}`,{default_branch:"main"})}return await sy(n,r,i),{result:await Kc(n,r,"Set up tapster",async(s)=>(await py(e,n,r,t.every,t.remove,t.readme,s)).files.filter((c)=>c.change!=="same").map((c)=>({path:c.path,content:c.change==="remove"?null:c.content})))}}async function w2(e){let t=await re(e.req,z({name:E().regex(/^homebrew-[A-Za-z0-9._-]{1,80}$/),private:tt()}).strict()),{gh:n,login:r}=await Ye(e.s);try{return{hub:(await n.json("POST","/user/repos",{name:t.name,private:t.private,auto_init:!1,description:"Homebrew tap, published by tapster"})).full_name}}catch(i){if(i instanceof R&&i.status===422)throw new v(`${r}/${t.name} already exists`,"Pick it from the list instead.");throw i}}var _2=z({hub:E(),label:E().regex(/^[a-z0-9]{1,40}$/),account:E().regex(/^[A-Za-z0-9 ._@-]{1,64}$/)}).strict();async function dy(e,t,n){let r=await de(e,t,"tapster.yml","main"),i=r===null?null:ne(r,t.split("/")[0]).config;if(!i||!Te(i).includes(n))throw new v(`no app in ${t}'s tapster.yml signs with the Sparkle key ${n}`,"Add the app with its sparkle section first.");return i}async function k2(e){let t=await re(e.req,_2),{gh:n,hub:r}=await we(e,t.hub),i=await dy(n,r,t.label),o=await e.s.deps.keychain(t.account);if(o===null)throw new v(`your keychain gave no Sparkle key for the account ${t.account}`,"Choose Allow when macOS asks. generate_keys uses the account ed25519 unless you passed --account.");let s=To(o),a=cl(i,t.label,s.publicKey);return e.s.sparkle.set(`${r} ${t.label}`,{seed:o.trim(),at:Date.now()}),{publicKey:s.publicKey,users:a,key:o.trim()}}async function x2(e){let t=await re(e.req,z({hub:E(),label:E().regex(/^[a-z0-9]{1,40}$/),pasted:E().max(400)}).strict()),{gh:n,hub:r,login:i}=await we(e,t.hub),o=e.s.sparkle.get(`${r} ${t.label}`);if(!o||Date.now()-o.at>1800000)throw new v("read the key from your keychain first","Click Read it from my keychain again.");if(t.pasted.trim()!==o.seed)throw new v("that is not the key shown above","Paste the key itself, so the copy your password manager keeps is the right one.");let s=await dy(n,r,t.label);await bn(n,r),await sy(n,r,i),await X(r,`SPARKLE_KEY_${t.label.toUpperCase()}`,o.seed);let a=await Kc(n,r,`Pass the Sparkle key ${t.label} to the hub workflow`,async(c)=>{let l=await c(J);if(l===null)return[];let u=ko(l,Te(s));return u===l?[]:[{path:J,content:u}]});return e.s.sparkle.delete(`${r} ${t.label}`),{stored:!0,workflow:a}}async function S2(e){let{gh:t,hub:n}=await we(e,e.url.searchParams.get("hub")),[{checks:r,note:i},o]=await Promise.all([xr(t,n),t.json("GET",`/repos/${n}/actions/workflows/tapster.yml/runs?per_page=8`).catch(()=>({workflow_runs:[]}))]);return{checks:r,note:i,runs:o.workflow_runs.map((s)=>({id:s.id,url:s.html_url,event:s.event,status:s.status,conclusion:s.conclusion,created:s.created_at}))}}async function A2(e){let{hub:t}=await re(e.req,jo),{gh:n}=await we(e,t);return await n.json("POST",`/repos/${t}/actions/workflows/tapster.yml/dispatches`,{ref:"main"}),{started:!0}}var hy={"GET /api/account":(e)=>u2(e.s),"GET /api/hubs":async(e)=>{let{gh:t,login:n}=await Ye(e.s);return{hubs:await hl(t,n)}},"POST /api/hubs":w2,"GET /api/hub":async(e)=>{let{gh:t,hub:n}=await we(e,e.url.searchParams.get("hub"));return fl(e.s,t,n)},"POST /api/hub/protect":d2,"POST /api/hub/app":h2,"POST /api/hub/app/store":f2,"GET /api/hub/installation":m2,"POST /api/hub/certificate":g2,"POST /api/hub/notary":v2,"POST /api/hub/files/preview":y2,"POST /api/hub/files":b2,"GET /api/hub/health":S2,"POST /api/hub/run":A2,"POST /api/hub/sparkle/read":k2,"POST /api/hub/sparkle/store":x2};import{existsSync as qo,lstatSync as yy,readdirSync as wy}from"fs";import{isAbsolute as yl,join as De,normalize as _y,resolve as ky}from"path";import{lstatSync as ml,readdirSync as $2,realpathSync as vy}from"fs";import{dirname as P2,join as Bt,resolve as Mo,sep as fy}from"path";var T2=new Set(["node_modules","Library","Applications","Pictures","Music","Movies","Documents","Desktop","Downloads","Public","vendor","Pods","DerivedData","build","dist","target","out"]),E2=["Developer","Projects","projects","code","Code","src","dev","git","GitHub","repos","workspace","work"];var O2=(e)=>{try{return ml(e).isFile()}catch{return!1}};function gl(e){let t=/\[remote "origin"\]([\s\S]*?)(?=\n\s*\[|$)/.exec(e)?.[1]??"",n=/^\s*url\s*=\s*(\S+)\s*$/m.exec(t)?.[1]??"";return/^(?:https:\/\/github\.com\/|git@github\.com:|ssh:\/\/git@github\.com\/)([A-Za-z0-9-]+\/[A-Za-z0-9._-]+?)(?:\.git)?\/?$/.exec(n)?.[1]??null}function vl(e,t){let n=(r)=>t.includes(r)&&O2(Bt(e,r));if(t.some((r)=>r==="project.yml"||r==="Package.swift"||r.endsWith(".xcodeproj")))return{kind:"app",why:null};if(n("go.mod"))return n(".goreleaser.yaml")||n(".goreleaser.yml")?{kind:"go",why:null}:{kind:null,why:"a Go project without GoReleaser"};if(n("package.json")){if(!n("bun.lock")&&!n("bun.lockb"))return{kind:null,why:"a JavaScript project without Bun"};let r=null;try{r=JSON.parse(oe(Bt(e,"package.json"))??"{}").bin}catch{r=null}return r?{kind:"bun",why:null}:{kind:null,why:"a Bun project without a command (no bin in package.json)"}}return{kind:null,why:"no build that tapster knows"}}function Uo(e,t){return[t,P2(t),...E2.map((n)=>Bt(e,n))].filter((n)=>Zo(n,e)&&n!==Mo(e))}var my=(e,t)=>e===t||e.startsWith(t.endsWith(fy)?t:`${t}${fy}`),gy=(e)=>{try{return vy(e)}catch{return Mo(e)}};function Zo(e,t){return my(Mo(e),Mo(t))||my(gy(e),gy(t))}function Go(e,t={}){let n=t.depth??3,r=t.maxDirs??4000,i=t.deadline??Date.now()+3000,o=new Set,s=[],a=0,c=!1,l=(u,p)=>{if(a>=r||Date.now()>i){c=!0;return}let d;try{d=vy(u)}catch{return}if(o.has(d))return;o.add(d),a++;let h;try{h=$2(d)}catch{return}if(h.includes(".git")){let f=null;try{f=ml(Bt(d,".git"))}catch{f=null}let m=f?.isDirectory()?oe(Bt(d,".git","config"),65536):null,g=m?gl(m):null;if(g)s.push({path:u,repo:g,owner:g.split("/")[0],inHub:!1,proposed:null,...vl(d,h)});return}if(p>=n)return;for(let f of h){if(f.startsWith(".")||T2.has(f))continue;try{if(!ml(Bt(d,f)).isDirectory())continue}catch{continue}l(Bt(u,f),p+1)}};for(let u of e)l(u,0);return{found:s,truncated:c}}var by="Release through the tapster hub";function Cr(e,t){if(typeof e!=="string"||!yl(e))throw new v("that is not a full folder path","Give the folder's full path, such as /Users/you/Developer/my-tool.");let n=ky(_y(e));if(!Zo(n,t))throw new v(`${n} is outside your home folder`,"tapster reads clones inside your home folder only.");let r;try{r=yy(n)}catch{throw new v(`${n} does not exist`,"Check the path.")}if(!r.isDirectory())throw new v(`${n} is not a folder`,"Give the folder of the clone.");if(!qo(De(n,".git"))||!yy(De(n,".git")).isDirectory())throw new v(`${n} is not a git clone`,"Give the top folder of a clone, the one that holds .git.");return n}function Rr(e,t){let n=gl(oe(De(e,".git","config"),65536)??"");if(!n)throw new v("this clone's origin is not a GitHub repository","tapster adds clones whose origin is on github.com.");if(n.split("/")[0].toLowerCase()!==t.toLowerCase())throw new v(`${n} does not belong to ${t}`,"tapster publishes repositories of your own account.");return n}async function wn(e,t,n={}){let r=n.user?{...process.env,GIT_TERMINAL_PROMPT:"0",GIT_SSH_COMMAND:process.env.GIT_SSH_COMMAND??"ssh -o BatchMode=yes"}:{GIT_TERMINAL_PROMPT:"0"};return j(hn.git,"git",["-C",e,...t],{env:r,allowFail:!0,timeoutMs:n.timeoutMs??20000,maxOutput:4194304})}async function xy(e,t){let n=await wn(e,["cat-file","-p",`HEAD:${t}`]);return n.code===0?n.stdout:null}function C2(e){let t=oe(De(e,".git","HEAD"),4096)?.trim()??"";return/^ref: refs\/heads\/(.+)$/.exec(t)?.[1]??"a detached HEAD"}async function R2(e,t){let n=[];for(let r of t){let i=oe(De(e,r));if(i!==null&&i!==await xy(e,r))n.push(r)}return n}var Sy={hub:E()};async function I2(e){let t=await re(e.req,z({hub:E(),extra:ue(E()).max(10)}).strict()),{gh:n,login:r}=await Ye(e.s),i=st(t.hub,r),o=t.extra.map((m)=>ky(m)).filter((m)=>yl(m)&&Zo(m,e.s.deps.home)&&qo(m)),s=[...new Set([...o,...Uo(e.s.deps.home,e.s.deps.cwd)])].filter((m)=>qo(m)),{found:a,truncated:c}=Go(s),l=await de(n,i,"tapster.yml","main").catch(()=>null),u=new Set(l?ne(l,r).config.packages.map((m)=>m.repo.toLowerCase()):[]),p=await n.json("GET",`/repos/${i}/pulls?state=open&per_page=100`).catch(()=>[]),d=new Map(p.filter((m)=>m.head?.ref?.startsWith("tapster-add-")).map((m)=>[m.head.ref.slice(12),m.html_url])),h=a.filter((m)=>m.owner.toLowerCase()===r.toLowerCase()&&m.repo.toLowerCase()!==i.toLowerCase());return{projects:[...new Map(h.map((m)=>[m.path,m])).values()].map(({owner:m,...g})=>({...g,inHub:u.has(g.repo.toLowerCase()),proposed:d.get(wo(g.repo))??null})).sort((m,g)=>Number(g.kind!==null)-Number(m.kind!==null)||m.repo.localeCompare(g.repo)),roots:s,others:a.length-h.length,truncated:c}}function N2(e){let t=De(e,".github","workflows"),n;try{n=wy(t).filter((r)=>/^[A-Za-z0-9._-]+\.ya?ml$/.test(r))}catch{return[]}return n.filter((r)=>(oe(De(t,r))??"").includes("goreleaser/goreleaser-action")).sort()}async function z2(e){let t=await re(e.req,z({...Sy,path:E()}).strict()),{gh:n,login:r}=await Ye(e.s),i=st(t.hub,r),o=Cr(t.path,e.s.deps.home),s=Rr(o,r),a=wo(s),c=wy(o),{kind:l,why:u}=vl(o,c);if(l==="app"&&!Bc(o))l=null,u="an Xcode project without a Sparkle feed (SUFeedURL ending in /releases/latest/download/<name>.xml)";if(l==="bun"){let k=oe(De(o,"package.json")),S=null;try{S=k?JSON.parse(k):null}catch{S=null}if(!S||!vo(S,a))l=null,u="package.json has no bin entry, so there is no command to publish"}if(l===null)throw new v(`tapster cannot publish ${s} yet: it is ${u}`,"tapster publishes GoReleaser Go tools, Bun command line tools and Mac apps that update with Sparkle.");let p=l==="go"?N2(o):[],d=oe(De(o,".github","workflows","release.yml")),h=await R2(o,[".github/workflows/release.yml",".goreleaser.yaml",".goreleaser.yml",...p.map((k)=>`.github/workflows/${k}`)]),f=C2(o),[m,g,w]=await Promise.all([n.getRepo(s),kr(n,i).catch(()=>null),de(n,i,"tapster.yml","main").catch(()=>null)]),x=await mr(n,s,m.default_branch,"admin").catch(()=>["unknown"]),_=await n.json("GET",`/repos/${i}/pulls?state=open&head=${encodeURIComponent(`${r}:tapster-add-${a}`)}`).catch(()=>[]),b=w?ne(w,r).config.packages.some((k)=>k.repo.toLowerCase()===s.toLowerCase()):!1;if(!g)throw new v(`${i} has no App yet`,"Finish the hub's setup first.");return{path:o,repo:s,name:a,kind:l,branch:f,defaultBranch:m.default_branch,dirty:[...new Set(h)],workflows:p,workflow:p.includes("release.yml")?"release.yml":p[0]??null,releaseFlow:d===null?"missing":d.includes("Ring the tapster hub")?"ours":"other",dependabot:[".github/dependabot.yml",".github/dependabot.yaml"].some((k)=>qo(De(o,k))),private:m.private,protected:x.length===0,inHub:b,proposed:_[0]?.html_url??null,apple:g.apple}}var D2=z({...Sy,path:E(),options:z({workflow:E().regex(/^[A-Za-z0-9._-]+\.ya?ml$/),autoTag:tt(),dependabot:tt(),force:tt()}).strict()}).strict();async function L2(e){let t=await re(e.req,D2),{gh:n,login:r}=await Ye(e.s),i=st(t.hub,r),o=Cr(t.path,e.s.deps.home),s=Rr(o,r),a=t.options,c=Hc([...a.force?["--force"]:[],...a.autoTag?["--auto-tag"]:[],...a.dependabot?["--allow-dependabot"]:[],"--workflow",a.workflow]),l=await kr(n,i);await wn(o,["config","tapster.hub",i],{user:!0});let u=[],p=await Fc(n,o,s,i,l,c,(d)=>u.push(d));return{lines:u,pr:p.pr,entry:p.entry,installUrl:p.installUrl,files:p.files}}function Ay(e){for(let t of e)if(yl(t)||_y(t).startsWith("..")||!/^[A-Za-z0-9._/-]+$/.test(t))throw new v(`${t} is not a file of this clone`,"Reload the page and try again.");return e}var $y=z({path:E(),files:ue(E()).min(1).max(10)}).strict();async function j2(e){let t=await re(e.req,$y),{login:n}=await Ye(e.s),r=Cr(t.path,e.s.deps.home);Rr(r,n);let i=[];for(let o of Ay(t.files))i.push({path:o,before:await xy(r,o),after:oe(De(r,o))});return{files:i}}async function M2(e){let t=await re(e.req,$y),{login:n}=await Ye(e.s),r=Cr(t.path,e.s.deps.home);Rr(r,n);let i=Ay(t.files),o=await wn(r,["add","--",...i],{user:!0});if(o.code!==0)throw new v("git could not stage the files",o.stderr.trim().split(`
|
|
1396
|
+
`).at(-1)??"Run git status in the clone.");let s=await wn(r,["commit","-m",by,"--",...i],{user:!0,timeoutMs:60000});if(s.code!==0){let a=`${s.stdout}
|
|
1397
|
+
${s.stderr}`;if(/nothing to commit|no changes added/i.test(a))return{committed:!1};throw new v("git could not commit",`${a.trim().split(`
|
|
1398
|
+
`).at(-1)??""} Commit in a terminal: git commit -m "${by}" -- ${i.join(" ")}`)}return{committed:!0}}async function U2(e){let t=await re(e.req,z({path:E()}).strict()),{login:n}=await Ye(e.s),r=Cr(t.path,e.s.deps.home);Rr(r,n);let o=(await wn(r,["rev-parse","--abbrev-ref","--symbolic-full-name","@{u}"])).code===0?["push"]:["push","--set-upstream","origin","HEAD"];if((await wn(r,o,{user:!0,timeoutMs:90000}).catch((a)=>{if(a instanceof v)return{code:1,stdout:"",stderr:a.reason};throw a})).code!==0)throw new v("git could not push without asking for a password or passphrase",`Push from a terminal in ${r}: git ${o.join(" ")}`);return{pushed:!0}}var Py={"POST /api/projects/scan":I2,"POST /api/projects/inspect":z2,"POST /api/projects/add":L2,"POST /api/projects/diff":j2,"POST /api/projects/commit":M2,"POST /api/projects/push":U2};var Ir=8277,G2=7200000;function q2(e){let t={open:!0,port:null,pin:null};for(let n=0;n<e.length;n++){let r=e[n],i=e[n+1];if(r==="--no-open")t.open=!1;else if(r==="--port"&&i&&/^\d{2,5}$/.test(i)&&Number(i)>=1024&&Number(i)<=65535)t.port=Number(e[++n]);else if(r==="--tapster"&&i&&/^[0-9a-f]{40}$/.test(i))t.pin=e[++n];else throw new v(`unknown option ${r}`,"Run tapster setup --help for the options.")}return t}function B2(e,t){return{...hy,...Py,"GET /api/session":async()=>{let n=await He(e.deps.cwd).catch(()=>null),r=n!==null&&/\/homebrew-/.test(n);return{version:se.version,dev:se.sha===null&&e.deps.pin===null,platform:process.platform,home:e.deps.home,here:{hub:r?n:null,repo:r?null:n,path:e.deps.cwd}}},"POST /api/quit":async()=>(setTimeout(t,200),{stopping:!0})}}function H2(e){let t=process.platform==="darwin"?"/usr/bin/open":"/usr/bin/xdg-open";j(t,"open",[e],{allowFail:!0}).catch(()=>{return})}function bl(e){let t=null;return{async github(){if(t&&Date.now()-t.at<60000)return t.gh;let n=await _t();return t={gh:n,at:Date.now()},n},fetch,home:Z2(),cwd:process.cwd(),pin:e,log:(n)=>console.log(n),open:H2,notary:No,keychain:(n)=>Pr("the Sparkle key").read({service:"https://sparkle-project.org",account:n,label:"Private key for signing Sparkle updates"})}}function Ty(e,t){return Bun.serve({hostname:"127.0.0.1",port:e,fetch:t,development:!1,error:()=>Ve("tapster setup hit an unexpected error. The terminal that runs it may say more.",500,"text/plain; charset=utf-8"),maxRequestBodySize:1048576,idleTimeout:120})}async function Ey(e,t){let n=q2(e);if(process.platform==="win32")throw new v("tapster setup runs on macOS and Linux","Run it on a Mac or a Linux computer; the hub itself serves Windows users through Scoop.");let r=t??bl(n.pin),i=async()=>new Response(null,{status:503}),o;try{o=Ty(n.port??Ir,(d)=>i(d))}catch{if(n.port!==null)throw new v(`port ${n.port} is in use`,"Pick another one with --port or close the program that uses it.");o=Ty(0,(d)=>i(d)),r.log(`Port ${Ir} is in use (another tapster setup may be open), so this one uses ${o.port}. Password managers save entries per address, so they may not offer the ones saved on ${Ir}.`)}let s=()=>{},a=new Promise((d)=>s=d),c=Lo(r,o.port),l=()=>{clearInterval(u),process.stdin.pause(),o.stop(),s()};i=ry(c,B2(c,l),(d)=>ay(d));let u=setInterval(()=>{if(Date.now()-c.touched>G2)r.log("tapster setup stopped after two hours without use. Run it again to continue; everything you did is on GitHub."),l()},60000),p=()=>{let d=c.link();if(r.log(`
|
|
1399
|
+
${d}
|
|
1400
|
+
`),n.open)r.open(d)};if(r.log(`tapster setup runs on this computer at http://127.0.0.1:${o.port}. Your keys go from here to your own GitHub account only.`),r.log(n.open?"It opens in your browser now. If it does not, open this link (it works once):":"Open this link in your browser (it works once):"),p(),r.log("Press Enter for a fresh link, for example after closing the tab. Ctrl+C stops tapster setup."),process.stdin.isTTY)process.stdin.setEncoding("utf8"),process.stdin.on("data",(d)=>{if(d.includes(`
|
|
1401
|
+
`))p()}),process.stdin.resume();await a,r.log("tapster setup stopped.")}import{createInterface as J2}from"readline";var F2=z({tag:E().regex(xc),releaseId:bc().int().positive(),checksums:E().regex(/^[0-9a-f]{64}$/),status:Lt(["publishing","published"]),app:z({macos:E().regex(/^[a-z_]+$/),identifiers:ue(E().regex(/^[A-Za-z0-9.-]+$/))}).strict().optional()}).strict(),K2=z({version:_c(1),packages:eo(E().regex(un),ue(F2))}).strict(),W2=()=>({version:1,packages:{}}),Oy=()=>new v(".tapster/state.json is damaged","Restore it from the hub's git history.");function Cy(e){if(e===null)return W2();let t;try{t=JSON.parse(e)}catch{throw Oy()}let n=K2.safeParse(t);if(!n.success)throw Oy();return n.data}function Ry(e){let t=new RegExp("<!-- tapster -->\\s*([\\s\\S]*?)<!-- /tapster -->").exec(e??"")?.[1];return t?t.replace(/^>\s*/,"").replace(/\*\*/g,"").trim():null}function V2(e,t=Date.now()){let n=Date.parse(`${e}T00:00:00Z`);return!Number.isNaN(n)&&n-t<2592000000}function Y2(e,t){if(e.apple.needed)return!0;return t===null?null:t==="yes"}function Iy(e,t,n=Date.now()){let r=Y2(e,t),i=e.protect.checks.filter((a)=>a.ok).length,o=[{id:"protect",name:"Protect the hub",done:e.protect.done,status:e.protect.done?"All protections are on":i?`${i} of ${e.protect.checks.length} protections on`:"Not protected yet",open:"Not protected yet"},{id:"app",name:"Create the GitHub App",done:Boolean(e.app.id&&e.app.slug&&e.app.key),attention:Boolean(e.app.id&&!e.app.key),status:e.app.id&&!e.app.key?"The App's private key is missing":e.app.slug?e.app.slug:"Not created yet",open:"Not created yet"},{id:"macos",name:"macOS or not",done:r===!0,skipped:r===!1,status:r===!0?"Signs macOS software":r===!1?"No macOS builds":"Your answer",open:"Your answer"},{id:"certificate",name:"Apple certificate",done:Boolean(e.apple.certificate&&e.apple.certificateStored),skipped:r===!1,attention:Boolean(e.apple.certificate&&V2(e.apple.certificate.expires,n)),status:r===!1?"Not needed":e.apple.certificate?`Team ${e.apple.certificate.team}, expires ${e.apple.certificate.expires}`:"Not stored yet",open:"Not stored yet"},{id:"notary",name:"Notarization key",done:e.apple.notary,skipped:r===!1,status:r===!1?"Not needed":e.apple.notary?"Stored":"Not stored yet",open:"Not stored yet"},{id:"files",name:"Hub files",done:e.files.config&&e.files.state&&e.files.workflow!=="missing",attention:e.files.workflow==="older"||e.files.workflow==="other",status:e.files.workflow==="missing"?"Not written yet":e.files.workflow==="older"?`Runs ${e.files.pinned}; update available`:e.files.workflow==="other"?`Runs ${e.files.pinned??"a workflow tapster did not write"}; review it`:e.files.workflow==="newer"?`Runs ${e.files.pinned}, newer than this tapster`:`Runs ${e.files.pinned}`,open:"Not written yet"},{id:"project",name:"Your projects",done:e.packages.length>0,status:e.packages.length?`${e.packages.length} in the hub`:"None yet",open:"None yet"}],s=!1;return o.map((a)=>{let c;if(a.skipped)c="skipped";else if(a.attention)c="attention";else if(a.done)c="done";else if(!s)c="now",s=!0;else c="later";return{id:a.id,name:a.name,state:c,status:a.status}})}var Ny=["2025-11-25","2025-06-18","2025-03-26","2024-11-05"],Q2=`tapster turns the user's Homebrew tap into a release hub that signs, notarizes and publishes the releases of their projects.
|
|
1402
|
+
These tools read the hub and the projects through the user's GitHub CLI sign-in and can start a hub run. They cannot set up a hub: creating the GitHub App needs the user's click and the Apple files live on their computer. For setup, tell the user to run "bunx @doguyilmaz/tapster setup", which opens a local page that walks through it. In a project, "bunx @doguyilmaz/tapster add" does the same from a terminal. Docs: https://tapster.doguyilmaz.com/`,_n={hub:E().optional().describe("The hub as owner/homebrew-name. Leave it out to use the hub of the current folder or the user's only hub.")};async function kn(e,t){let n=await e.gh(),r=(await n.json("GET","/user")).login;if(typeof t==="string"&&t)return{gh:n,hub:st(t,r),login:r};let i=(u)=>u&&u.split("/")[0].toLowerCase()===r.toLowerCase()&&/\/homebrew-/.test(u)?u:null,o=i((await $e("git",["-C",e.deps.cwd,"config","--get","tapster.hub"],{allowFail:!0})).stdout.trim());if(o)return{gh:n,hub:st(o,r),login:r};let s=i(await He(e.deps.cwd).catch(()=>null));if(s)return{gh:n,hub:st(s,r),login:r};let a=await hl(n,r),c=a.filter((u)=>u.tapster),l=c.length===1?c[0]:a.length===1?a[0]:null;if(l)return{gh:n,hub:l.name,login:r};throw new v("there is no single hub to read",a.length?`Pass hub as one of: ${a.map((u)=>u.name).join(", ")}.`:"The user has no repository named homebrew-...; they can create one with bunx @doguyilmaz/tapster setup.")}var zy=[{name:"hub_status",title:"Hub setup status",description:"Where the hub's setup stands: each step with its state, the projects it publishes, entries it refuses and the open health issue.",input:z(_n),readOnly:!0,async run(e,t){let{gh:n,hub:r}=await kn(t,e.hub),i=await fl(Lo(t.deps,0),n,r);return{hub:r,steps:Iy(i,null).map((o)=>({step:o.name,state:o.state,status:o.status})),projects:i.packages,refused:i.invalid,healthIssue:i.issue?{url:i.issue.url,updated:i.issue.updated,body:i.issue.body}:null,extras:i.extras}}},{name:"doctor",title:"Check the hub",description:"Run tapster doctor: every setting the hub's security depends on, each with the fix when it fails.",input:z(_n),readOnly:!0,async run(e,t){let{gh:n,hub:r}=await kn(t,e.hub),{checks:i,note:o}=await xr(n,r);return{hub:r,problems:i.filter((s)=>!s.ok),passed:i.filter((s)=>s.ok).map((s)=>s.name),note:o}}},{name:"hub_runs",title:"Recent hub runs",description:"The hub workflow's latest runs with their result and a link to each log.",input:z(_n),readOnly:!0,async run(e,t){let{gh:n,hub:r}=await kn(t,e.hub),i=await n.json("GET",`/repos/${r}/actions/workflows/tapster.yml/runs?per_page=10`);return{hub:r,runs:i.workflow_runs.map((o)=>({started:o.created_at,by:o.event,status:o.status,result:o.conclusion,log:o.html_url}))}}},{name:"release_status",title:"A project's releases",description:"A project's latest releases and drafts, what the hub wrote on a draft it will not publish and what the hub has published.",input:z({..._n,repo:E().regex(/^[A-Za-z0-9-]+\/[A-Za-z0-9._-]+$/).describe("The project as owner/name.")}),readOnly:!0,async run(e,t){let{gh:n,hub:r,login:i}=await kn(t,e.hub),o=String(e.repo),s=(await n.listReleases(o)).slice(0,8),a=await de(n,r,"tapster.yml","main"),c=a?ne(a,i).config.packages.find((u)=>u.repo.toLowerCase()===o.toLowerCase()):void 0,l=Cy(await de(n,r,".tapster/state.json","main"));return{hub:r,repo:o,inHub:c?c.name:null,releases:s.map((u)=>({tag:u.tag_name,draft:u.draft,published:u.published_at,files:u.assets.length,hubNote:Ry(u.body)})),publishedByHub:c?(l.packages[c.name]??[]).map((u)=>({tag:u.tag,status:u.status})):[]}}},{name:"local_projects",title:"Projects on this computer",description:"Clones of the user's own repositories on this computer, the kind tapster recognizes and whether the hub publishes them.",input:z(_n),readOnly:!0,async run(e,t){let{gh:n,hub:r,login:i}=await kn(t,e.hub),o=await de(n,r,"tapster.yml","main"),s=new Set(o?ne(o,i).config.packages.map((l)=>l.repo.toLowerCase()):[]),{found:a,truncated:c}=Go(Uo(t.deps.home,t.deps.cwd).filter(Boolean));return{hub:r,projects:a.filter((l)=>l.owner.toLowerCase()===i.toLowerCase()).map((l)=>({repo:l.repo,path:l.path,kind:l.kind,notSupported:l.why,inHub:s.has(l.repo.toLowerCase())})),truncated:c,next:"To add one, the user runs bunx @doguyilmaz/tapster setup (Projects) or bunx @doguyilmaz/tapster add in its folder."}}},{name:"run_hub",title:"Start the hub",description:"Start a hub run now instead of waiting for its schedule. The hub then publishes the drafts that are ready.",input:z(_n),readOnly:!1,async run(e,t){let{gh:n,hub:r}=await kn(t,e.hub);return await n.json("POST",`/repos/${r}/actions/workflows/tapster.yml/dispatches`,{ref:"main"}),{hub:r,started:!0,runs:`https://github.com/${r}/actions/workflows/tapster.yml`}}}],xn=(e,t)=>({jsonrpc:"2.0",id:e,result:t}),Bo=(e,t,n)=>({jsonrpc:"2.0",id:e??null,error:{code:t,message:n}});async function X2(e,t){if(e===null||typeof e!=="object"||Array.isArray(e))return Bo(null,-32600,"invalid request: send one JSON-RPC object per line");if(e.id===void 0||e.id===null)return null;if(e.method==="initialize"){let n=String(e.params?.protocolVersion??"");return xn(e.id,{protocolVersion:Ny.includes(n)?n:Ny[0],capabilities:{tools:{listChanged:!1}},serverInfo:{name:"tapster",title:"tapster",version:se.version},instructions:Q2})}if(e.method==="ping")return xn(e.id,{});if(e.method==="tools/list")return xn(e.id,{tools:zy.map((n)=>({name:n.name,title:n.title,description:n.description,inputSchema:Em(n.input),annotations:{readOnlyHint:n.readOnly,openWorldHint:!0}}))});if(e.method==="tools/call"){let n=zy.find((i)=>i.name===e.params?.name);if(!n)return Bo(e.id,-32602,`unknown tool ${String(e.params?.name)}`);let r=n.input.safeParse(e.params?.arguments??{});if(!r.success)return xn(e.id,{content:[{type:"text",text:`Invalid arguments: ${r.error.issues.map((i)=>`${i.path.join(".")}: ${i.message}`).join("; ")}`}],isError:!0});try{let i=await n.run(r.data,t);return xn(e.id,{content:[{type:"text",text:JSON.stringify(i,null,2)}],structuredContent:i})}catch(i){let o=i instanceof v?`${i.reason}. ${i.fix}`:"tapster hit an unexpected error. Try again; if it repeats, the user can run the same check in a terminal.";return xn(e.id,{content:[{type:"text",text:o}],isError:!0})}}return Bo(e.id,-32601,`unknown method ${String(e.method)}`)}async function eC(e,t=process.stdin,n=(r)=>process.stdout.write(`${r}
|
|
1403
|
+
`)){let r=J2({input:t,crlfDelay:1/0});for await(let i of r){if(!i.trim())continue;let o;try{o=JSON.parse(i)}catch{n(JSON.stringify(Bo(null,-32700,"parse error")));continue}let s=await X2(o,e);if(s)n(JSON.stringify(s))}}async function Dy(e){if(e.length)throw new v(`unknown option ${e.join(" ")}`,"tapster mcp takes no options.");let t={...bl(null),log:(n)=>process.stderr.write(`${n}
|
|
1404
|
+
`)};await eC({deps:t,gh:()=>t.github()})}var tC=`tapster: publish your projects' releases from one Homebrew tap
|
|
1405
|
+
|
|
1406
|
+
tapster setup open the setup in your browser: the hub, your projects and their health
|
|
1407
|
+
tapster init set up this hub clone; run it again to finish or repair the setup
|
|
1408
|
+
tapster add prepare this project clone and propose it to the hub
|
|
1409
|
+
tapster doctor check the hub's setup and name the fix for each finding
|
|
1410
|
+
tapster mcp serve tapster's tools to an AI assistant over MCP (stdio)
|
|
1411
|
+
tapster --version show this tapster and the commit it pins hubs to
|
|
1412
|
+
|
|
1413
|
+
Run tapster <command> --help for the options: Sparkle and Linux keys, the doorbell, rotations and more.`,Ly={setup:`tapster setup: set up the hub and add your projects in your browser
|
|
1414
|
+
|
|
1415
|
+
tapster setup [--no-open] [--port <port>] [--tapster <commit>]
|
|
1416
|
+
--no-open print the link instead of opening the browser
|
|
1417
|
+
--port listen on this port instead of ${Ir}
|
|
1418
|
+
--tapster pin the hub workflow to this commit (for a tapster built from a checkout)
|
|
1419
|
+
|
|
1420
|
+
The page runs on this computer only and works until you stop tapster setup with Ctrl+C.`,init:`tapster init: set up the hub in this clone; every step can run again and skips what is done
|
|
1421
|
+
|
|
1422
|
+
tapster init [--every <minutes>] [--tapster <commit>]
|
|
1423
|
+
tapster init --rotate app|certificate|notary|doorbell|linux
|
|
1424
|
+
tapster init --rotate linux --finish stop signing with the previous Linux key
|
|
1425
|
+
tapster init --sparkle <label> [--account <account>]
|
|
1426
|
+
store a Sparkle key from your keychain in the hub
|
|
1427
|
+
tapster init --sparkle <label> --new
|
|
1428
|
+
make a Sparkle key, keep it in your keychain and store it in the hub
|
|
1429
|
+
tapster init --doorbell deploy the Worker that starts the hub when a project releases
|
|
1430
|
+
tapster init --linux make the key for the apt and dnf repositories
|
|
1431
|
+
tapster init --workflow [--every <minutes>] [--tapster <commit>]
|
|
1432
|
+
rewrite the hub workflow, pinned to this tapster`,add:`tapster add: prepare this project clone and propose it to the hub
|
|
1433
|
+
|
|
1434
|
+
tapster add [--hub owner/repo] [--workflow file.yml] [--auto-tag] [--allow-dependabot] [--force]
|
|
1435
|
+
--hub the hub that publishes this project (remembered in git config)
|
|
1436
|
+
--workflow the workflow that runs GoReleaser, if not release.yml
|
|
1437
|
+
--auto-tag let the project's release workflow push tags with a deploy key
|
|
1438
|
+
--allow-dependabot leave branches named dependabot/... open so Dependabot can open pull requests
|
|
1439
|
+
--force replace an existing release workflow`,doctor:`tapster doctor: check the hub's setup on GitHub and name the command that fixes each finding
|
|
1440
|
+
|
|
1441
|
+
tapster doctor`,mcp:`tapster mcp: serve tapster's tools to an AI assistant over MCP, on stdin and stdout
|
|
1442
|
+
|
|
1443
|
+
claude mcp add tapster -- bunx @doguyilmaz/tapster mcp
|
|
1444
|
+
|
|
1445
|
+
The tools read the hub, its runs, a project's releases and the projects on this computer. One of them starts a hub run.
|
|
1446
|
+
They use your GitHub CLI sign-in and never touch your keys.`},[_e,...at]=process.argv.slice(2);try{if(_e==="--version"||_e==="-v")console.log(`tapster ${se.version} (${se.sha?se.sha.slice(0,12):"built from a checkout; init --workflow needs --tapster <commit>"})`);else if(_e&&Ly[_e]&&(at[0]==="--help"||at[0]==="-h"))console.log(Ly[_e]);else if(_e==="setup")await Ey(at);else if(_e==="mcp")await Dy(at);else if(_e==="init")await Vv(at);else if(_e==="add")await _v(at);else if(_e==="doctor"){if(at.length)throw new v(`unknown option ${at.join(" ")}`,"tapster doctor takes no options.");process.exitCode=await Av(at)}else console.log(tC),process.exitCode=_e&&_e!=="help"&&_e!=="--help"?1:0}catch(e){console.error(e instanceof v?`tapster: ${e.reason}
|
|
1447
|
+
${e.fix}`:"tapster: unexpected error"),process.exitCode=1}
|